text
stringlengths
157
7.64M
meta
dict
(* Title: HOL/HOLCF/Library/Option_Cpo.thy Author: Brian Huffman *) section ‹Cpo class instance for HOL option type› theory Option_Cpo imports HOLCF Sum_Cpo begin subsection ‹Ordering on option type› instantiation option :: (below) below begin definition below_option_def: "x ⊑ y ≡ case x of None ⇒ (case y of None ⇒ True | Some b ⇒ False) | Some a ⇒ (case y of None ⇒ False | Some b ⇒ a ⊑ b)" instance .. end lemma None_below_None [simp]: "None ⊑ None" unfolding below_option_def (*goal: ‹case None of None ⇒ case None of None ⇒ True | Some (b::'a::below) ⇒ False | Some (a::'a::below) ⇒ case None of None ⇒ False | Some (b::'a::below) ⇒ a ⊑ b›*) by simp lemma Some_below_Some [simp]: "Some x ⊑ Some y ⟷ x ⊑ y" unfolding below_option_def (*goal: ‹(case Some x of None ⇒ case Some y of None ⇒ True | Some b ⇒ False | Some a ⇒ case Some y of None ⇒ False | Some b ⇒ a ⊑ b) = (x ⊑ y)›*) by simp lemma Some_below_None [simp]: "¬ Some x ⊑ None" unfolding below_option_def (*goal: ‹¬ (case Some (x::'a) of None ⇒ case None of None ⇒ True | Some (b::'a) ⇒ False | Some (a::'a) ⇒ case None of None ⇒ False | Some (b::'a) ⇒ a ⊑ b)›*) by simp lemma None_below_Some [simp]: "¬ None ⊑ Some y" unfolding below_option_def (*goal: ‹¬ (case None of None ⇒ case Some y of None ⇒ True | Some b ⇒ False | Some a ⇒ case Some y of None ⇒ False | Some b ⇒ a ⊑ b)›*) by simp lemma Some_mono: "x ⊑ y ⟹ Some x ⊑ Some y" by simp lemma None_below_iff [simp]: "None ⊑ x ⟷ x = None" apply (cases x) (*goals: 1. ‹x = None ⟹ (None ⊑ x) = (x = None)› 2. ‹⋀a. x = Some a ⟹ (None ⊑ x) = (x = None)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma below_None_iff [simp]: "x ⊑ None ⟷ x = None" apply (cases x) (*goals: 1. ‹x = None ⟹ (x ⊑ None) = (x = None)› 2. ‹⋀a. x = Some a ⟹ (x ⊑ None) = (x = None)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma option_below_cases: assumes "x ⊑ y" obtains "x = None" and "y = None" | a b where "x = Some a" and "y = Some b" and "a ⊑ b" using assms (*‹x ⊑ y›*) unfolding below_option_def (*goal: ‹⟦⟦x = None; y = None⟧ ⟹ thesis; ⋀a b. ⟦x = Some a; y = Some b; a ⊑ b⟧ ⟹ thesis⟧ ⟹ thesis›*) by (simp split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) subsection ‹Option type is a complete partial order› instance option :: (po) po proof fix x :: "'a option" show "x ⊑ x" unfolding below_option_def by (simp split: option.split) next fix x y :: "'a option" assume "x ⊑ y" and "y ⊑ x" thus "x = y" unfolding below_option_def by (auto split: option.split_asm intro: below_antisym) next fix x y z :: "'a option" assume "x ⊑ y" and "y ⊑ z" thus "x ⊑ z" unfolding below_option_def by (auto split: option.split_asm intro: below_trans) qed lemma monofun_the: "monofun the" apply (rule monofunI (*‹(⋀(x::?'a::po) y::?'a::po. x ⊑ y ⟹ (?f::?'a::po ⇒ ?'b::po) x ⊑ ?f y) ⟹ monofun ?f›*)) (*goal: ‹monofun the›*) apply (erule option_below_cases (*‹⟦?x ⊑ ?y; ⟦?x = None; ?y = None⟧ ⟹ ?thesis; ⋀a b. ⟦?x = Some a; ?y = Some b; a ⊑ b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀(x::'a option) y::'a option. ⟦x = None; y = None⟧ ⟹ the x ⊑ the y› 2. ‹⋀(x::'a option) (y::'a option) (a::'a) b::'a. ⟦x = Some a; y = Some b; a ⊑ b⟧ ⟹ the x ⊑ the y› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma option_chain_cases: assumes Y: "chain Y" obtains "Y = (λi. None)" | A where "chain A" and "Y = (λi. Some (A i))" apply (cases "Y 0") (*goals: 1. ‹⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = None⟧ ⟹ thesis› 2. ‹⋀a. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = Some a⟧ ⟹ thesis› discuss goal 1*) apply (rule that( (*‹Y = (λi. None) ⟹ thesis›*) 1)) (*top goal: ‹⟦(Y::nat ⇒ 'a option) = (λi::nat. None) ⟹ thesis::bool; ⋀A::nat ⇒ 'a. ⟦chain A; Y = (λi::nat. Some (A i))⟧ ⟹ thesis; Y (0::nat) = None⟧ ⟹ thesis› and 1 goal remains*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*top goal: ‹⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = None⟧ ⟹ Y = (λi. None)› and 1 goal remains*) apply (cut_tac j=i in chain_mono [OF Y le0] (*‹Y 0 ⊑ Y ?j›*)) (*top goal: ‹⋀i. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = None⟧ ⟹ Y i = None› and 1 goal remains*) apply simp (*discuss goal 2*) apply (rule that( (*‹⟦chain ?A; Y = (λi. Some (?A i))⟧ ⟹ thesis›*) 2)) (*goals: 1. ‹⋀a. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = Some a⟧ ⟹ chain (?A10 a)› 2. ‹⋀a. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = Some a⟧ ⟹ Y = (λi. Some (?A10 a i))› discuss goal 1*) apply (rule ch2ch_monofun [OF monofun_the Y] (*‹chain (λi. the (Y i))›*)) (*discuss goal 2*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀a. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = Some a⟧ ⟹ Y = (λi. Some (the (Y i)))›*) apply (cut_tac j=i in chain_mono [OF Y le0] (*‹(Y::nat ⇒ 'a::po option) (0::nat) ⊑ Y (?j::nat)›*)) (*goal: ‹⋀a i. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = Some a⟧ ⟹ Y i = Some (the (Y i))›*) apply simp (*goal: ‹⋀a i. ⟦Y = (λi. None) ⟹ thesis; ⋀A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ thesis; Y 0 = Some a; Y 0 ⊑ Y i⟧ ⟹ Y i = Some (the (Y i))›*) apply (case_tac "Y i") (*goals: 1. ‹⋀(a::'a::po) i::nat. ⟦(Y::nat ⇒ 'a::po option) = (λi::nat. None) ⟹ thesis::bool; ⋀A::nat ⇒ 'a::po. ⟦chain A; Y = (λi::nat. Some (A i))⟧ ⟹ thesis; Y (0::nat) = Some a; Some a ⊑ Y i; Y i = None⟧ ⟹ Y i = Some (the (Y i))› 2. ‹⋀(a::'a::po) (i::nat) aa::'a::po. ⟦(Y::nat ⇒ 'a::po option) = (λi::nat. None) ⟹ thesis::bool; ⋀A::nat ⇒ 'a::po. ⟦chain A; Y = (λi::nat. Some (A i))⟧ ⟹ thesis; Y (0::nat) = Some a; Some a ⊑ Y i; Y i = Some aa⟧ ⟹ Y i = Some (the (Y i))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma is_lub_Some: "range S <<| x ⟹ range (λi. Some (S i)) <<| Some x" apply (rule is_lubI (*‹⟦?S <| ?x; ⋀u. ?S <| u ⟹ ?x ⊑ u⟧ ⟹ ?S <<| ?x›*)) (*goals: 1. ‹range S <<| x ⟹ range (λi. Some (S i)) <| Some x› 2. ‹⋀u. ⟦range S <<| x; range (λi. Some (S i)) <| u⟧ ⟹ Some x ⊑ u› discuss goal 1*) apply (rule ub_rangeI (*‹(⋀i. ?S i ⊑ ?x) ⟹ range ?S <| ?x›*)) (*top goal: ‹range S <<| x ⟹ range (λi. Some (S i)) <| Some x› and 1 goal remains*) apply (simp add: is_lub_rangeD1 (*‹range ?S <<| ?x ⟹ ?S ?i ⊑ ?x›*)) (*discuss goal 2*) apply (frule ub_rangeD [where i=arbitrary] (*‹range ?S <| ?x ⟹ ?S arbitrary ⊑ ?x›*)) (*goal: ‹⋀u. ⟦range S <<| x; range (λi. Some (S i)) <| u⟧ ⟹ Some x ⊑ u›*) apply (case_tac u) (*goals: 1. ‹⋀u. ⟦range S <<| x; range (λi. Some (S i)) <| u; Some (S arbitrary) ⊑ u; u = None⟧ ⟹ Some x ⊑ u› 2. ‹⋀u a. ⟦range S <<| x; range (λi. Some (S i)) <| u; Some (S arbitrary) ⊑ u; u = Some a⟧ ⟹ Some x ⊑ u› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀u a. ⟦range S <<| x; range (λi. Some (S i)) <| u; Some (S arbitrary) ⊑ u; u = Some a⟧ ⟹ Some x ⊑ u›*) apply (erule is_lubD2 (*‹⟦?S <<| ?x; ?S <| ?u⟧ ⟹ ?x ⊑ ?u›*)) (*goal: ‹⋀u a. ⟦range S <<| x; range (λi. Some (S i)) <| Some a; S arbitrary ⊑ a; u = Some a⟧ ⟹ x ⊑ a›*) apply (rule ub_rangeI (*‹(⋀i::?'b. (?S::?'b ⇒ ?'a) i ⊑ (?x::?'a)) ⟹ range ?S <| ?x›*)) (*goal: ‹⋀(u::'a option) a::'a. ⟦range (λi::'b. Some ((S::'b ⇒ 'a) i)) <| Some a; S (arbitrary::'b) ⊑ a; u = Some a⟧ ⟹ range S <| a›*) apply (drule ub_rangeD (*‹range ?S <| ?x ⟹ ?S ?i ⊑ ?x›*)) (*goal: ‹⋀u a i. ⟦range (λi. Some (S i)) <| Some a; S arbitrary ⊑ a; u = Some a⟧ ⟹ S i ⊑ a›*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . instance option :: (cpo) cpo apply intro_classes apply (erule option_chain_cases, safe) apply (rule exI, rule is_lub_const) apply (rule exI) apply (rule is_lub_Some) apply (erule cpo_lubI) done subsection ‹Continuity of Some and case function› lemma cont_Some: "cont Some" by (intro contI (*‹(⋀Y. chain Y ⟹ range (λi. ?f (Y i)) <<| ?f (⨆i. Y i)) ⟹ cont ?f›*) is_lub_Some (*‹range ?S <<| ?x ⟹ range (λi. Some (?S i)) <<| Some ?x›*) cpo_lubI (*‹chain ?S ⟹ range ?S <<| (⨆i. ?S i)›*)) lemmas cont2cont_Some [simp, cont2cont] = cont_compose [OF cont_Some] lemmas ch2ch_Some [simp] = ch2ch_cont [OF cont_Some] lemmas lub_Some = cont2contlubE [OF cont_Some, symmetric] lemma cont2cont_case_option: assumes f: "cont (λx. f x)" assumes g: "cont (λx. g x)" assumes h1: "⋀a. cont (λx. h x a)" assumes h2: "⋀x. cont (λa. h x a)" shows "cont (λx. case f x of None ⇒ g x | Some a ⇒ h x a)" apply (rule cont_apply [OF f] (*‹⟦⋀x. cont (?f x); ⋀y. cont (λx. ?f x y)⟧ ⟹ cont (λx. ?f x (f x))›*)) (*goals: 1. ‹⋀x::'a. cont (λy::'b option. case y of None ⇒ (g::'a ⇒ 'c) x | Some (a::'b) ⇒ (h::'a ⇒ 'b ⇒ 'c) x a)› 2. ‹⋀y::'b option. cont (λx::'a. case y of None ⇒ (g::'a ⇒ 'c) x | Some (a::'b) ⇒ (h::'a ⇒ 'b ⇒ 'c) x a)› discuss goal 1*) apply (rule contI (*‹(⋀Y. chain Y ⟹ range (λi. ?f (Y i)) <<| ?f (⨆i. Y i)) ⟹ cont ?f›*)) (*top goal: ‹⋀x. cont (λy. case y of None ⇒ g x | Some a ⇒ h x a)› and 1 goal remains*) apply (erule option_chain_cases (*‹⟦chain ?Y; ?Y = (λi. None) ⟹ ?thesis; ⋀A. ⟦chain A; ?Y = (λi. Some (A i))⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀x Y. Y = (λi. None) ⟹ range (λi. case Y i of None ⇒ g x | Some a ⇒ h x a) <<| (case ⨆i. Y i of None ⇒ g x | Some a ⇒ h x a)› 2. ‹⋀x Y A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ range (λi. case Y i of None ⇒ g x | Some a ⇒ h x a) <<| (case ⨆i. Y i of None ⇒ g x | Some a ⇒ h x a)› discuss goal 1*) apply (simp add: is_lub_const (*‹range (λx. ?c) <<| ?c›*)) (*discuss goal 2*) apply (simp add: lub_Some (*‹chain ?Y ⟹ (⨆i. Some (?Y i)) = Some (⨆i. ?Y i)›*)) (*top goal: ‹⋀x Y A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ range (λi. case Y i of None ⇒ g x | Some a ⇒ h x a) <<| (case ⨆i. Y i of None ⇒ g x | Some a ⇒ h x a)› and 1 goal remains*) apply (simp add: cont2contlubE [OF h2] (*‹chain (?Y::nat ⇒ 'b::cpo) ⟹ (h::'a::cpo ⇒ 'b::cpo ⇒ 'c::cpo) (?x1::'a::cpo) (⨆i::nat. ?Y i) = (⨆i::nat. h ?x1 (?Y i))›*)) (*top goal: ‹⋀x Y A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ range (λxa. h x (A xa)) <<| h x (⨆x. A x)› and 1 goal remains*) apply (rule cpo_lubI (*‹chain ?S ⟹ range ?S <<| (⨆i. ?S i)›*)) (*top goal: ‹⋀x Y A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ range (λxa. h x (A xa)) <<| (⨆i. h x (A i))› and 1 goal remains*) apply (rule chainI (*‹(⋀i. ?Y i ⊑ ?Y (Suc i)) ⟹ chain ?Y›*)) (*top goal: ‹⋀x Y A. ⟦chain A; Y = (λi. Some (A i))⟧ ⟹ chain (λxa. h x (A xa))› and 1 goal remains*) apply (erule cont2monofunE [OF h2 chainE] (*‹chain ?Y1 ⟹ h ?x2 (?Y1 ?i1) ⊑ h ?x2 (?Y1 (Suc ?i1))›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (case_tac y) (*goals: 1. ‹⋀y::'b::cpo option. y = None ⟹ cont (λx::'a::cpo. case y of None ⇒ (g::'a::cpo ⇒ 'c::cpo) x | Some (a::'b::cpo) ⇒ (h::'a::cpo ⇒ 'b::cpo ⇒ 'c::cpo) x a)› 2. ‹⋀(y::'b::cpo option) a::'b::cpo. y = Some a ⟹ cont (λx::'a::cpo. case y of None ⇒ (g::'a::cpo ⇒ 'c::cpo) x | Some (a::'b::cpo) ⇒ (h::'a::cpo ⇒ 'b::cpo ⇒ 'c::cpo) x a)› discuss goal 1*) apply (simp add: g (*‹cont g›*) h1 (*‹cont (λx. h x ?a)›*)) (*discuss goal 2*) apply (simp add: g (*‹cont g›*) h1 (*‹cont (λx. h x ?a)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma cont2cont_case_option' [simp, cont2cont]: assumes f: "cont (λx. f x)" assumes g: "cont (λx. g x)" assumes h: "cont (λp. h (fst p) (snd p))" shows "cont (λx. case f x of None ⇒ g x | Some a ⇒ h x a)" using assms (*‹cont (f::'a ⇒ 'b option)› ‹cont g› ‹cont (λp. h (fst p) (snd p))›*) by (simp add: cont2cont_case_option (*‹⟦cont ?f; cont ?g; ⋀a. cont (λx. ?h x a); ⋀x. cont (?h x)⟧ ⟹ cont (λx. case ?f x of None ⇒ ?g x | Some a ⇒ ?h x a)›*) prod_cont_iff (*‹cont ?f = ((∀y. cont (λx. ?f (x, y))) ∧ (∀x. cont (λy. ?f (x, y))))›*)) text ‹Simple version for when the element type is not a cpo.› lemma cont2cont_case_option_simple [simp, cont2cont]: assumes "cont (λx. f x)" assumes "⋀a. cont (λx. g x a)" shows "cont (λx. case z of None ⇒ f x | Some a ⇒ g x a)" using assms (*‹cont (f::'a ⇒ 'b)› ‹cont (λx. g x ?a)›*) apply (cases z) (*goals: 1. ‹⟦cont f; ⋀a. cont (λx. g x a); z = None⟧ ⟹ cont (λx. case z of None ⇒ f x | Some a ⇒ g x a)› 2. ‹⋀a. ⟦cont f; ⋀a. cont (λx. g x a); z = Some a⟧ ⟹ cont (λx. case z of None ⇒ f x | Some a ⇒ g x a)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹Continuity rule for map.› lemma cont2cont_map_option [simp, cont2cont]: assumes f: "cont (λ(x, y). f x y)" assumes g: "cont (λx. g x)" shows "cont (λx. map_option (λy. f x y) (g x))" using assms (*‹cont (λ(x, y). f x y)› ‹cont g›*) by (simp add: prod_cont_iff (*‹cont ?f = ((∀y. cont (λx. ?f (x, y))) ∧ (∀x. cont (λy. ?f (x, y))))›*) map_option_case (*‹map_option ?f ?y = (case ?y of None ⇒ None | Some x ⇒ Some (?f x))›*)) subsection ‹Compactness and chain-finiteness› lemma compact_None [simp]: "compact None" apply (rule compactI2 (*‹(⋀Y. ⟦chain Y; ?x ⊑ (⨆i. Y i)⟧ ⟹ ∃i. ?x ⊑ Y i) ⟹ compact ?x›*)) (*goal: ‹compact None›*) apply (erule option_chain_cases (*‹⟦chain ?Y; ?Y = (λi. None) ⟹ ?thesis; ⋀A. ⟦chain A; ?Y = (λi. Some (A i))⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀Y. ⟦None ⊑ (⨆i. Y i); Y = (λi. None)⟧ ⟹ ∃i. None ⊑ Y i› 2. ‹⋀Y A. ⟦None ⊑ (⨆i. Y i); chain A; Y = (λi. Some (A i))⟧ ⟹ ∃i. None ⊑ Y i› discuss goal 1*) apply ((safe)[1]) (*top goal: ‹⋀Y. ⟦None ⊑ (⨆i. Y i); Y = (λi. None)⟧ ⟹ ∃i. None ⊑ Y i› and 1 goal remains*) apply simp (*discuss goal 2*) apply ((safe)[1]) (*goal: ‹⋀Y A. ⟦None ⊑ (⨆i. Y i); chain A; Y = (λi. Some (A i))⟧ ⟹ ∃i. None ⊑ Y i›*) apply (simp add: lub_Some (*‹chain ?Y ⟹ (⨆i. Some (?Y i)) = Some (⨆i. ?Y i)›*)) (*proven 2 subgoals*) . lemma compact_Some: "compact a ⟹ compact (Some a)" apply (rule compactI2 (*‹(⋀Y::nat ⇒ ?'a. ⟦chain Y; (?x::?'a) ⊑ (⨆i::nat. Y i)⟧ ⟹ ∃i::nat. ?x ⊑ Y i) ⟹ compact ?x›*)) (*goal: ‹compact a ⟹ compact (Some a)›*) apply (erule option_chain_cases (*‹⟦chain ?Y; ?Y = (λi. None) ⟹ ?thesis; ⋀A. ⟦chain A; ?Y = (λi. Some (A i))⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀Y. ⟦compact a; Some a ⊑ (⨆i. Y i); Y = (λi. None)⟧ ⟹ ∃i. Some a ⊑ Y i› 2. ‹⋀Y A. ⟦compact a; Some a ⊑ (⨆i. Y i); chain A; Y = (λi. Some (A i))⟧ ⟹ ∃i. Some a ⊑ Y i› discuss goal 1*) apply ((safe)[1]) (*top goal: ‹⋀Y::nat ⇒ 'a option. ⟦compact (a::'a); Some a ⊑ (⨆i::nat. Y i); Y = (λi::nat. None)⟧ ⟹ ∃i::nat. Some a ⊑ Y i› and 1 goal remains*) apply simp (*discuss goal 2*) apply ((safe)[1]) (*goal: ‹⋀Y A. ⟦compact a; Some a ⊑ (⨆i. Y i); chain A; Y = (λi. Some (A i))⟧ ⟹ ∃i. Some a ⊑ Y i›*) apply (simp add: lub_Some (*‹chain (?Y::nat ⇒ ?'a) ⟹ (⨆i::nat. Some (?Y i)) = Some (⨆i::nat. ?Y i)›*)) (*goal: ‹⋀(Y::nat ⇒ 'a option) A::nat ⇒ 'a. ⟦compact (a::'a); Some a ⊑ (⨆i::nat. Some (A i)); chain A⟧ ⟹ ∃i::nat. Some a ⊑ Some (A i)›*) apply (erule (2) compactD2 (*‹⟦compact ?x; chain ?Y; ?x ⊑ (⨆i. ?Y i)⟧ ⟹ ∃i. ?x ⊑ ?Y i›*)) (*proven 2 subgoals*) . lemma compact_Some_rev: "compact (Some a) ⟹ compact a" unfolding compact_def (*goal: ‹adm ((\<notsqsubseteq>) (Some (a::'a))) ⟹ adm ((\<notsqsubseteq>) a)›*) apply (drule adm_subst [OF cont_Some] (*‹adm (?P::?'a::cpo option ⇒ bool) ⟹ adm (λx::?'a::cpo. ?P (Some x))›*)) (*goal: ‹adm ((\<notsqsubseteq>) (Some a)) ⟹ adm ((\<notsqsubseteq>) a)›*) by simp lemma compact_Some_iff [simp]: "compact (Some a) = compact a" by (safe elim!: compact_Some (*‹compact ?a ⟹ compact (Some ?a)›*) compact_Some_rev (*‹compact (Some ?a) ⟹ compact ?a›*)) instance option :: (chfin) chfin apply intro_classes apply (erule compact_imp_max_in_chain) apply (case_tac "⨆i. Y i", simp_all) done instance option :: (discrete_cpo) discrete_cpo by intro_classes (simp add: below_option_def split: option.split) subsection ‹Using option types with Fixrec› definition "match_None = (Λ x k. case x of None ⇒ k | Some a ⇒ Fixrec.fail)" definition "match_Some = (Λ x k. case x of None ⇒ Fixrec.fail | Some a ⇒ k⋅a)" lemma match_None_simps [simp]: "match_None⋅None⋅k = k" "match_None⋅(Some a)⋅k = Fixrec.fail" unfolding match_None_def (*goals: 1. ‹(Λ x k. case x of None ⇒ k | Some a ⇒ Fixrec.fail)⋅None⋅k = k› 2. ‹(Λ x k. case x of None ⇒ k | Some a ⇒ Fixrec.fail)⋅(Some a)⋅k = Fixrec.fail›*) (*goals: 1. ‹(Λ x k. case x of None ⇒ k | Some a ⇒ Fixrec.fail)⋅None⋅k = k› 2. ‹(Λ x k. case x of None ⇒ k | Some a ⇒ Fixrec.fail)⋅(Some a)⋅k = Fixrec.fail› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma match_Some_simps [simp]: "match_Some⋅None⋅k = Fixrec.fail" "match_Some⋅(Some a)⋅k = k⋅a" unfolding match_Some_def (*goals: 1. ‹(Λ x k. case x of None ⇒ Fixrec.fail | Some x ⇒ k⋅x)⋅None⋅k = Fixrec.fail› 2. ‹(Λ x k. case x of None ⇒ Fixrec.fail | Some x ⇒ k⋅x)⋅(Some a)⋅k = k⋅a›*) (*goals: 1. ‹(Λ x k. case x of None ⇒ Fixrec.fail | Some x ⇒ k⋅x)⋅None⋅k = Fixrec.fail› 2. ‹(Λ x k. case x of None ⇒ Fixrec.fail | Some x ⇒ k⋅x)⋅(Some a)⋅k = k⋅a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . setup ‹ Fixrec.add_matchers [ (\<^const_name>‹None›, \<^const_name>‹match_None›), (\<^const_name>‹Some›, \<^const_name>‹match_Some›) ] › subsection ‹Option type is a predomain› definition "encode_option = (Λ x. case x of None ⇒ Inl () | Some a ⇒ Inr a)" definition "decode_option = (Λ x. case x of Inl (u::unit) ⇒ None | Inr a ⇒ Some a)" lemma decode_encode_option [simp]: "decode_option⋅(encode_option⋅x) = x" unfolding decode_option_def encode_option_def (*goal: ‹Abs_cfun (case_sum (λu::unit. None) Some)⋅(Abs_cfun (case_option (Inl ()) Inr)⋅(x::'a option)) = x›*) apply (cases x) (*goals: 1. ‹x = None ⟹ Abs_cfun (case_sum (λu. None) Some)⋅(Abs_cfun (case_option (Inl ()) Inr)⋅x) = x› 2. ‹⋀a. x = Some a ⟹ Abs_cfun (case_sum (λu. None) Some)⋅(Abs_cfun (case_option (Inl ()) Inr)⋅x) = x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma encode_decode_option [simp]: "encode_option⋅(decode_option⋅x) = x" unfolding decode_option_def encode_option_def (*goal: ‹Abs_cfun (case_option (Inl ()) Inr)⋅(Abs_cfun (case_sum (λu::unit. None) Some)⋅(x::unit + 'a)) = x›*) apply (cases x) (*goals: 1. ‹⋀a. x = Inl a ⟹ Abs_cfun (case_option (Inl ()) Inr)⋅(Abs_cfun (case_sum (λu. None) Some)⋅x) = x› 2. ‹⋀b. x = Inr b ⟹ Abs_cfun (case_option (Inl ()) Inr)⋅(Abs_cfun (case_sum (λu. None) Some)⋅x) = x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . instantiation option :: (predomain) predomain begin definition "liftemb = liftemb oo u_map⋅encode_option" definition "liftprj = u_map⋅decode_option oo liftprj" definition "liftdefl (t::('a option) itself) = LIFTDEFL(unit + 'a)" instance proof show "ep_pair liftemb (liftprj :: udom u → ('a option) u)" unfolding liftemb_option_def liftprj_option_def apply (intro ep_pair_comp ep_pair_u_map predomain_ep) apply (rule ep_pair.intro, simp, simp) done show "cast⋅LIFTDEFL('a option) = liftemb oo (liftprj :: udom u → ('a option) u)" unfolding liftemb_option_def liftprj_option_def liftdefl_option_def by (simp add: cast_liftdefl cfcomp1 u_map_map ID_def [symmetric] u_map_ID) qed end subsection ‹Configuring domain package to work with option type› lemma liftdefl_option [domain_defl_simps]: "LIFTDEFL('a::predomain option) = LIFTDEFL(unit + 'a)" by (rule liftdefl_option_def (*‹liftdefl ?t = LIFTDEFL(unit + ?'a)›*)) abbreviation option_map where "option_map f ≡ Abs_cfun (map_option (Rep_cfun f))" lemma option_map_ID [domain_map_ID]: "option_map ID = ID" by (simp add: ID_def (*‹ID = (Λ x. x)›*) cfun_eq_iff (*‹(?f = ?g) = (∀x. ?f⋅x = ?g⋅x)›*) option.map_id[unfolded id_def] (*‹map_option (λx. x) ?t = ?t›*) id_def (*‹id = (λx. x)›*)) lemma deflation_option_map [domain_deflation]: "deflation d ⟹ deflation (option_map d)" apply standard (*goals: 1. ‹⋀x. deflation d ⟹ option_map d⋅(option_map d⋅x) = option_map d⋅x› 2. ‹⋀x. deflation d ⟹ option_map d⋅x ⊑ x› discuss goal 1*) apply (induct_tac x) (*goals: 1. ‹⋀x::'a option. deflation (d::'a → 'a) ⟹ option_map d⋅(option_map d⋅None) = option_map d⋅None› 2. ‹⋀(x::'a option) option::'a. deflation (d::'a → 'a) ⟹ option_map d⋅(option_map d⋅(Some option)) = option_map d⋅(Some option)› discuss goal 1*) apply (simp add: deflation.idem (*‹deflation ?d ⟹ ?d⋅(?d⋅?x) = ?d⋅?x›*)) (*discuss goal 2*) apply (simp add: deflation.idem (*‹deflation ?d ⟹ ?d⋅(?d⋅?x) = ?d⋅?x›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: deflation.idem (*‹deflation ?d ⟹ ?d⋅(?d⋅?x) = ?d⋅?x›*)) (*goal: ‹⋀x. deflation d ⟹ option_map d⋅x ⊑ x›*) apply (induct_tac x) (*goals: 1. ‹⋀x. deflation d ⟹ map_option (Rep_cfun d) None ⊑ None› 2. ‹⋀x option. deflation d ⟹ map_option (Rep_cfun d) (Some option) ⊑ Some option› discuss goal 1*) apply (simp add: deflation.below (*‹deflation (?d::?'a::cpo → ?'a::cpo) ⟹ ?d⋅(?x::?'a::cpo) ⊑ ?x›*)) (*discuss goal 2*) apply (simp add: deflation.below (*‹deflation ?d ⟹ ?d⋅?x ⊑ ?x›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma encode_option_option_map: "encode_option⋅(map_option (λx. f⋅x) (decode_option⋅x)) = map_sum' ID f⋅x" apply (induct x) (*goals: 1. ‹⋀a. encode_option⋅(map_option (Rep_cfun f) (decode_option⋅(Inl a))) = map_sum' ID f⋅(Inl a)› 2. ‹⋀b. encode_option⋅(map_option (Rep_cfun f) (decode_option⋅(Inr b))) = map_sum' ID f⋅(Inr b)› discuss goal 1*) apply (simp add: decode_option_def (*‹decode_option = (Λ x. case x of Inl u ⇒ None | Inr a ⇒ Some a)›*) encode_option_def (*‹encode_option = (Λ x. case x of None ⇒ Inl () | Some a ⇒ Inr a)›*)) (*discuss goal 2*) apply (simp add: decode_option_def (*‹decode_option = (Λ x. case x of Inl u ⇒ None | Inr a ⇒ Some a)›*) encode_option_def (*‹encode_option = (Λ x. case x of None ⇒ Inl () | Some a ⇒ Inr a)›*)) (*proven 2 subgoals*) . lemma isodefl_option [domain_isodefl]: assumes "isodefl' d t" shows "isodefl' (option_map d) (sum_liftdefl⋅(liftdefl_of⋅DEFL(unit))⋅t)" using isodefl_sum[OF isodefl_LIFTDEFL [ where 'a = unit ] assms] (*‹isodefl' (map_sum' ID d) (sum_liftdefl⋅LIFTDEFL(unit)⋅t)›*) unfolding isodefl'_def liftemb_option_def liftprj_option_def liftdefl_eq (*goal: ‹cast⋅(sum_liftdefl⋅(liftdefl_of⋅DEFL(unit))⋅t) = (liftemb oo u_map⋅encode_option) oo u_map⋅(option_map d) oo u_map⋅decode_option oo liftprj›*) by (simp add: cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) u_map_map (*‹u_map⋅?f⋅(u_map⋅?g⋅?p) = u_map⋅(Λ x. ?f⋅(?g⋅x))⋅?p›*) encode_option_option_map (*‹encode_option⋅(map_option (Rep_cfun ?f) (decode_option⋅?x)) = map_sum' ID ?f⋅?x›*)) setup ‹ Domain_Take_Proofs.add_rec_type (\<^type_name>‹option›, [true]) › end
{ "path": "Isabelle2024/src/HOL/HOLCF/Library/Option_Cpo.thy", "repo": "Isabelle2024", "sha": "b6ecbd7cfaceb093b4e9a18561bf391163927c92c7be80db6e3448e287fd94d5" }
(* Author: Tobias Nipkow *) section "Weighted Path Length of BST" theory Weighted_Path_Length imports "HOL-Library.Tree" begin text ‹This theory presents two definitions of the \emph{weighted path length} of a BST, the objective function we want to minimize, and proves them equivalent. Function ‹Wpl› is the intuitive global definition that sums ‹a› over all leaves and ‹b› over all nodes, taking their depth (= number of comparisons to reach that point) into account. Function ‹wpl› is a recursive definition and thus suitable for the later dynamic programming approaches to building a BST with the minimal weighted path length. › lemma inorder_upto_split: assumes "inorder ⟨l,k,r⟩ = [i..j]" shows "inorder l = [i..k-1]" "inorder r = [k+1..j]" "i ≤ k" "k ≤ j" proof (-) (*goals: 1. ‹inorder l = [i..k - 1]› 2. ‹inorder r = [k + 1..j]› 3. ‹i ≤ k› 4. ‹k ≤ j›*) have k: "k∈set[i..j]" using assms (*‹inorder ⟨l, k, r⟩ = [i..j]›*) by (metis set_inorder (*‹set (inorder ?t) = set_tree ?t›*) tree.set_intros( (*‹?x22.0 ∈ set_tree ⟨?x21.0, ?x22.0, ?x23.0⟩›*) 2)) have "[i..k-1] @ k # [k+1..j] = [i..j]" using k (*‹(k::int) ∈ set [i::int..j::int]›*) upto_rec1 (*‹?i ≤ ?j ⟹ [?i..?j] = ?i # [?i + 1..?j]›*) upto_split1 (*‹⟦(?i::int) ≤ (?j::int); ?j ≤ (?k::int)⟧ ⟹ [?i..?k] = [?i..?j - (1::int)] @ [?j..?k]›*) by (metis atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) set_upto (*‹set [?i..?j] = {?i..?j}›*)) also (*calculation: ‹[i..k - 1] @ k # [k + 1..j] = [i..j]›*) have "… = inorder l @ k # inorder r" using assms (*‹inorder ⟨l, k, r⟩ = [i..j]›*) by auto finally (*calculation: ‹[i..k - 1] @ k # [k + 1..j] = inorder l @ k # inorder r›*) have "inorder l = [i..k-1] ∧ inorder r = [k+1..j]" (is "?A ∧ ?B") by (auto simp: append_Cons_eq_iff (*‹⟦?x ∉ set ?xs; ?x ∉ set ?ys⟧ ⟹ (?xs @ ?x # ?ys = ?xs' @ ?x # ?ys') = (?xs = ?xs' ∧ ?ys = ?ys')›*)) thus "?A" "?B" apply - (*goals: 1. ‹inorder (l::int tree) = [i::int..(k::int) - (1::int)] ∧ inorder (r::int tree) = [k + (1::int)..j::int] ⟹ inorder l = [i..k - (1::int)]› 2. ‹inorder (l::int tree) = [i::int..(k::int) - (1::int)] ∧ inorder (r::int tree) = [k + (1::int)..j::int] ⟹ inorder r = [k + (1::int)..j]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "i ≤ k" "k ≤ j" using k (*‹k ∈ set [i..j]›*) apply - (*goals: 1. ‹(k::int) ∈ set [i::int..j::int] ⟹ i ≤ k› 2. ‹(k::int) ∈ set [i::int..j::int] ⟹ k ≤ j› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed fun incr2 :: "int × nat ⇒ int × nat" where "incr2 (x,n) = (x, n + 1)" fun leaves :: "int ⇒ int tree ⇒ (int * nat) set" where "leaves i Leaf = {(i,0)}" | "leaves i (Node l k r) = incr2 ` (leaves i l ∪ leaves (k+1) r)" fun nodes :: "int tree ⇒ (int * nat) set" where "nodes Leaf = {}" | "nodes (Node l k r) = {(k,1)} ∪ incr2 ` (nodes l ∪ nodes r)" lemma finite_nodes: "finite (nodes t)" apply (induction t) (*goals: 1. ‹finite (nodes ⟨⟩)› 2. ‹⋀t1 x2 t2. ⟦finite (nodes t1); finite (nodes t2)⟧ ⟹ finite (nodes ⟨t1, x2, t2⟩)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma finite_leaves: "finite (leaves i t)" apply (induction i t rule: leaves.induct (*‹⟦⋀i. ?P i ⟨⟩; ⋀i l k r. ⟦?P i l; ?P (k + 1) r⟧ ⟹ ?P i ⟨l, k, r⟩⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀i. finite (leaves i ⟨⟩)› 2. ‹⋀i l k r. ⟦finite (leaves i l); finite (leaves (k + 1) r)⟧ ⟹ finite (leaves i ⟨l, k, r⟩)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma notin_nodes0: "(k, 0) ∉ nodes t" apply (induction t) (*goals: 1. ‹(k, 0) ∉ nodes ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦(k, 0) ∉ nodes t1; (k, 0) ∉ nodes t2⟧ ⟹ (k, 0) ∉ nodes ⟨t1, x2, t2⟩› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma sum_incr2: "sum f (incr2 ` A) = sum (λxy. f(fst xy,snd xy+1)) A" proof (-) (*goal: ‹sum f (incr2 ` A) = (∑xy∈A. f (fst xy, snd xy + 1))›*) have "sum f (incr2 ` A) = sum (f o incr2) A" apply (subst sum.reindex (*‹inj_on (?h::?'b::type ⇒ ?'c::type) (?A::?'b::type set) ⟹ sum (?g::?'c::type ⇒ ?'a::comm_monoid_add) (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on incr2 (A::(int × nat) set)› 2. ‹sum ((f::int × nat ⇒ 'a) ∘ incr2) (A::(int × nat) set) = sum (f ∘ incr2) A› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹sum f (incr2 ` A) = sum (f ∘ incr2) A›*) have "f o incr2 = (λxy. f(fst xy,snd xy+1))" by (auto simp: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) finally (*calculation: ‹sum f (incr2 ` A) = (∑a∈A. f (fst a, snd a + 1))›*) show "?thesis" (*goal: ‹sum f (incr2 ` A) = (∑xy∈A. f (fst xy, snd xy + 1))›*) by simp qed lemma fst_nodes: "fst ` nodes t = set_tree t" apply (induction t) (*goals: 1. ‹fst ` nodes ⟨⟩ = set_tree ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦fst ` nodes t1 = set_tree t1; fst ` nodes t2 = set_tree t2⟧ ⟹ fst ` nodes ⟨t1, x2, t2⟩ = set_tree ⟨t1, x2, t2⟩› discuss goal 1*) apply simp (*discuss goal 2*) apply (fastforce simp: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*)) (*proven 2 subgoals*) . lemma fst_leaves: "⟦ inorder t = [i..j]; i ≤ j+1⟧ ⟹ fst ` leaves i t = {i..j+1}" proof (induction t arbitrary: i j) (*goals: 1. ‹⋀i j. ⟦inorder ⟨⟩ = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i ⟨⟩ = {i..j + 1}› 2. ‹⋀t1 x2 t2 i j. ⟦⋀i j. ⟦inorder t1 = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i t1 = {i..j + 1}; ⋀i j. ⟦inorder t2 = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i t2 = {i..j + 1}; inorder ⟨t1, x2, t2⟩ = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i ⟨t1, x2, t2⟩ = {i..j + 1}›*) case Leaf (*‹inorder ⟨⟩ = [i..j]› ‹i ≤ j + 1›*) then show "?case" (*goal: ‹fst ` leaves i ⟨⟩ = {i..j + 1}›*) by auto next (*goal: ‹⋀t1 x2 t2 i j. ⟦⋀i j. ⟦inorder t1 = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i t1 = {i..j + 1}; ⋀i j. ⟦inorder t2 = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i t2 = {i..j + 1}; inorder ⟨t1, x2, t2⟩ = [i..j]; i ≤ j + 1⟧ ⟹ fst ` leaves i ⟨t1, x2, t2⟩ = {i..j + 1}›*) case (Node t1 k t2) (*‹⟦inorder t1 = [?i..?j]; ?i ≤ ?j + 1⟧ ⟹ fst ` leaves ?i t1 = {?i..?j + 1}› ‹⟦inorder t2 = [?i..?j]; ?i ≤ ?j + 1⟧ ⟹ fst ` leaves ?i t2 = {?i..?j + 1}› ‹inorder ⟨t1, k, t2⟩ = [i..j]› ‹i ≤ j + 1›*) note inorder = inorder_upto_split[OF Node.prems ( 1 )] (*‹inorder t1 = [i..k - 1]› ‹inorder t2 = [k + 1..j]› ‹i ≤ k› ‹k ≤ j›*) show "?case" (*goal: ‹fst ` leaves (i::int) ⟨t1::int tree, k::int, t2::int tree⟩ = {i..(j::int) + (1::int)}›*) using Node.IH(1)[OF inorder ( 1 )] (*‹i ≤ k - 1 + 1 ⟹ fst ` leaves i t1 = {i..k - 1 + 1}›*) Node.IH(2)[OF inorder ( 2 )] (*‹k + 1 ≤ j + 1 ⟹ fst ` leaves (k + 1) t2 = {k + 1..j + 1}›*) inorder(3,4) (*‹(i::int) ≤ (k::int)› ‹k ≤ j›*) Node.prems(2) (*‹i ≤ j + 1›*) by (fastforce simp: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*) set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*) bex_Un (*‹(∃x∈?A ∪ ?B. ?P x) = ((∃x∈?A. ?P x) ∨ (∃x∈?B. ?P x))›*)) qed lemma sum_leaves: "⟦ inorder t = [i..j]; i ≤ j+1 ⟧ ⟹ (∑x∈leaves i t. (f(fst x) :: nat)) = sum f {i..j+1}" proof (induction t arbitrary: i j) (*goals: 1. ‹⋀i j. ⟦inorder ⟨⟩ = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i ⟨⟩. f (fst x)) = sum f {i..j + 1}› 2. ‹⋀t1 x2 t2 i j. ⟦⋀i j. ⟦inorder t1 = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i t1. f (fst x)) = sum f {i..j + 1}; ⋀i j. ⟦inorder t2 = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i t2. f (fst x)) = sum f {i..j + 1}; inorder ⟨t1, x2, t2⟩ = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i ⟨t1, x2, t2⟩. f (fst x)) = sum f {i..j + 1}›*) case Leaf (*‹inorder ⟨⟩ = [i..j]› ‹i ≤ j + 1›*) hence "i = j+1" by simp thus "?case" (*goal: ‹(∑x::int × nat∈leaves (i::int) ⟨⟩. (f::int ⇒ nat) (fst x)) = sum f {i..(j::int) + (1::int)}›*) by simp next (*goal: ‹⋀t1 x2 t2 i j. ⟦⋀i j. ⟦inorder t1 = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i t1. f (fst x)) = sum f {i..j + 1}; ⋀i j. ⟦inorder t2 = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i t2. f (fst x)) = sum f {i..j + 1}; inorder ⟨t1, x2, t2⟩ = [i..j]; i ≤ j + 1⟧ ⟹ (∑x∈leaves i ⟨t1, x2, t2⟩. f (fst x)) = sum f {i..j + 1}›*) case (Node l k r) (*‹⟦inorder l = [?i..?j]; ?i ≤ ?j + 1⟧ ⟹ (∑x∈leaves ?i l. f (fst x)) = sum f {?i..?j + 1}› ‹⟦inorder r = [?i..?j]; ?i ≤ ?j + 1⟧ ⟹ (∑x∈leaves ?i r. f (fst x)) = sum f {?i..?j + 1}› ‹inorder ⟨l::int tree, k::int, r::int tree⟩ = [i::int..j::int]› ‹i ≤ j + 1›*) note inorder = inorder_upto_split[OF Node.prems ( 1 )] (*‹inorder l = [i..k - 1]› ‹inorder r = [k + 1..j]› ‹(i::int) ≤ (k::int)› ‹k ≤ j›*) let ?Ll = "leaves i l" let ?Lr = "leaves (k+1) r" let ?L = "?Ll ∪ ?Lr" have "fst ` ?Ll ∩ fst ` ?Lr = {}" using inorder (*‹inorder l = [i..k - 1]› ‹inorder r = [k + 1..j]› ‹(i::int) ≤ (k::int)› ‹k ≤ j›*) by (simp add: fst_leaves (*‹⟦inorder (?t::int tree) = [?i::int..?j::int]; ?i ≤ ?j + (1::int)⟧ ⟹ fst ` leaves ?i ?t = {?i..?j + (1::int)}›*) del: set_inorder (*‹set (inorder (?t::?'a tree)) = set_tree ?t›*) add: set_inorder[symmetric] (*‹set_tree (?t::?'a tree) = set (inorder ?t)›*)) hence l0: "?Ll ∩ ?Lr = {}" by auto have "{i..j+1} = {i..k} ∪ {k+1..j+1}" using inorder(3,4) (*‹i ≤ k› ‹k ≤ j›*) by auto thus "?case" (*goal: ‹(∑x∈leaves i ⟨l, k, r⟩. f (fst x)) = sum f {i..j + 1}›*) using Node.IH(1)[OF inorder ( 1 )] (*‹(i::int) ≤ (k::int) - (1::int) + (1::int) ⟹ (∑x::int × nat∈leaves i (l::int tree). (f::int ⇒ nat) (fst x)) = sum f {i..k - (1::int) + (1::int)}›*) Node.IH(2)[OF inorder ( 2 )] (*‹k + 1 ≤ j + 1 ⟹ (∑x∈leaves (k + 1) r. f (fst x)) = sum f {k + 1..j + 1}›*) inorder(3,4) (*‹i ≤ k› ‹(k::int) ≤ (j::int)›*) Node.prems(2) (*‹i ≤ j + 1›*) by (simp add: sum_incr2 (*‹sum ?f (incr2 ` ?A) = (∑xy∈?A. ?f (fst xy, snd xy + 1))›*) sum_Un_nat (*‹⟦finite ?A; finite ?B⟧ ⟹ sum ?f (?A ∪ ?B) = sum ?f ?A + sum ?f ?B - sum ?f (?A ∩ ?B)›*) finite_leaves (*‹finite (leaves ?i ?t)›*) l0 (*‹leaves i l ∩ leaves (k + 1) r = {}›*)) qed lemma sum_nodes: "inorder t = [i..j] ⟹ (∑xy∈nodes t. (f(fst xy) :: nat)) = sum f {i..j}" sorry locale wpl = fixes w :: "int ⇒ int ⇒ nat" begin fun wpl :: "int ⇒ int ⇒ int tree ⇒ nat" where "wpl i j Leaf = 0" | "wpl i j (Node l k r) = wpl i (k-1) l + wpl (k+1) j r + w i j" end locale Wpl = fixes a b :: "int ⇒ nat" begin definition Wpl :: "int ⇒ int tree ⇒ nat" where "Wpl i t = sum (λ(k,c). c * b k) (nodes t) + sum (λ(k,c). c * a k) (leaves i t)" definition w :: "int ⇒ int ⇒ nat" where "w i j = sum a {i..j+1} + sum b {i..j}" sublocale wpl where w = w . lemma "inorder t = [i..j] ⟹ wpl i j t = Wpl i t" proof (induction t arbitrary: i j) (*goals: 1. ‹⋀i j. inorder ⟨⟩ = [i..j] ⟹ wpl i j ⟨⟩ = Wpl i ⟨⟩› 2. ‹⋀t1 x2 t2 i j. ⟦⋀i j. inorder t1 = [i..j] ⟹ wpl i j t1 = Wpl i t1; ⋀i j. inorder t2 = [i..j] ⟹ wpl i j t2 = Wpl i t2; inorder ⟨t1, x2, t2⟩ = [i..j]⟧ ⟹ wpl i j ⟨t1, x2, t2⟩ = Wpl i ⟨t1, x2, t2⟩›*) case Leaf (*‹inorder ⟨⟩ = [i..j]›*) thus "?case" (*goal: ‹wpl (i::int) (j::int) ⟨⟩ = Wpl i ⟨⟩›*) by (simp add: Wpl_def (*‹Wpl ?i ?t = (∑(k, c)∈nodes ?t. c * b k) + (∑(k, c)∈leaves ?i ?t. c * a k)›*)) next (*goal: ‹⋀(t1::int tree) (x2::int) (t2::int tree) (i::int) j::int. ⟦⋀(i::int) j::int. inorder t1 = [i..j] ⟹ wpl i j t1 = Wpl i t1; ⋀(i::int) j::int. inorder t2 = [i..j] ⟹ wpl i j t2 = Wpl i t2; inorder ⟨t1, x2, t2⟩ = [i..j]⟧ ⟹ wpl i j ⟨t1, x2, t2⟩ = Wpl i ⟨t1, x2, t2⟩›*) case (Node l k r) (*‹inorder l = [?i..?j] ⟹ wpl ?i ?j l = Wpl ?i l› ‹inorder r = [?i..?j] ⟹ wpl ?i ?j r = Wpl ?i r› ‹inorder ⟨l, k, r⟩ = [i..j]›*) let ?b = "λ(k,c). c * b k" let ?a = "λ(k,c). c * a k" note inorder = inorder_upto_split[OF Node.prems] (*‹inorder l = [i..k - 1]› ‹inorder (r::int tree) = [(k::int) + (1::int)..j::int]› ‹(i::int) ≤ (k::int)› ‹k ≤ j›*) let ?Nl = "nodes l" let ?Nr = "nodes r" let ?N = "?Nl ∪ ?Nr" let ?Ll = "leaves i l" let ?Lr = "leaves (k+1) r" let ?L = "?Ll ∪ ?Lr" have "(fst ` ?Nl) ∩ (fst ` ?Nr) = {}" using inorder(1,2) (*‹inorder l = [i..k - 1]› ‹inorder r = [k + 1..j]›*) by (simp add: fst_nodes (*‹fst ` nodes ?t = set_tree ?t›*) del: set_inorder (*‹set (inorder ?t) = set_tree ?t›*) add: set_inorder[symmetric] (*‹set_tree ?t = set (inorder ?t)›*)) hence n0: "?Nl ∩ ?Nr = {}" by auto have "fst ` ?Ll ∩ fst ` ?Lr = {}" using inorder (*‹inorder (l::int tree) = [i::int..(k::int) - (1::int)]› ‹inorder r = [k + 1..j]› ‹i ≤ k› ‹k ≤ j›*) by (simp add: fst_leaves (*‹⟦inorder (?t::int tree) = [?i::int..?j::int]; ?i ≤ ?j + (1::int)⟧ ⟹ fst ` leaves ?i ?t = {?i..?j + (1::int)}›*) del: set_inorder (*‹set (inorder (?t::?'a tree)) = set_tree ?t›*) add: set_inorder[symmetric] (*‹set_tree (?t::?'a tree) = set (inorder ?t)›*)) hence l0: "?Ll ∩ ?Lr = {}" by auto have "wpl i j (Node l k r) = Wpl i l + Wpl (k + 1) r + w i j" using Node.IH (*‹inorder l = [?i..?j] ⟹ wpl ?i ?j l = Wpl ?i l› ‹inorder r = [?i..?j] ⟹ wpl ?i ?j r = Wpl ?i r›*) inorder (*‹inorder l = [i..k - 1]› ‹inorder r = [k + 1..j]› ‹i ≤ k› ‹k ≤ j›*) by simp also (*calculation: ‹wpl i j ⟨l, k, r⟩ = Wpl i l + Wpl (k + 1) r + w i j›*) have "… = sum ?b (nodes l) + sum ?a (leaves i l) + sum ?b (nodes r) + sum ?a (leaves (k+1) r) + w i j" by (simp add: Wpl_def (*‹Wpl ?i ?t = (∑(k, c)∈nodes ?t. c * b k) + (∑(k, c)∈leaves ?i ?t. c * a k)›*)) also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈nodes l. c * b k) + (∑(k, c)∈leaves i l. c * a k) + (∑(k, c)∈nodes r. c * b k) + (∑(k, c)∈leaves (k + 1) r. c * a k) + w i j›*) have "… = (sum ?b (nodes l) + sum ?b (nodes r)) + (sum ?a (leaves i l) + sum ?a (leaves (k+1) r)) + w i j" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*)) also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈nodes l. c * b k) + (∑(k, c)∈nodes r. c * b k) + ((∑(k, c)∈leaves i l. c * a k) + (∑(k, c)∈leaves (k + 1) r. c * a k)) + w i j›*) have "… = sum ?b ?N + sum ?a ?L + w i j" by (simp add: sum_Un_nat (*‹⟦finite ?A; finite ?B⟧ ⟹ sum ?f (?A ∪ ?B) = sum ?f ?A + sum ?f ?B - sum ?f (?A ∩ ?B)›*) finite_nodes (*‹finite (nodes ?t)›*) finite_leaves (*‹finite (leaves ?i ?t)›*) l0 (*‹leaves i l ∩ leaves (k + 1) r = {}›*) n0 (*‹nodes l ∩ nodes r = {}›*)) also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈nodes l ∪ nodes r. c * b k) + (∑(k, c)∈leaves i l ∪ leaves (k + 1) r. c * a k) + w i j›*) have "… = sum ?b ?N + sum ?a ?L + sum a {i..j+1} + sum b {i..j}" by (simp add: w_def (*‹w (?i::int) (?j::int) = sum (a::int ⇒ nat) {?i..?j + (1::int)} + sum (b::int ⇒ nat) {?i..?j}›*)) also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈nodes l ∪ nodes r. c * b k) + (∑(k, c)∈leaves i l ∪ leaves (k + 1) r. c * a k) + sum a {i..j + 1} + sum b {i..j}›*) have "… = sum ?b ?N + sum b {i..j} + (sum ?a ?L + sum a {i..j+1})" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*)) also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈nodes l ∪ nodes r. c * b k) + sum b {i..j} + ((∑(k, c)∈leaves i l ∪ leaves (k + 1) r. c * a k) + sum a {i..j + 1})›*) have "sum ?a ?L + sum a {i..j+1} = sum ?a (incr2 ` ?L)" proof (-) (*goal: ‹(∑(k, c)∈leaves i l ∪ leaves (k + 1) r. c * a k) + sum a {i..j + 1} = (∑(k, c)∈incr2 ` (leaves i l ∪ leaves (k + 1) r). c * a k)›*) have "{i..j+1} = {i..k} ∪ {k+1..j+1}" using inorder(3,4) (*‹(i::int) ≤ (k::int)› ‹k ≤ j›*) by auto thus "?thesis" (*goal: ‹(∑(k::int, c::nat)∈leaves (i::int) (l::int tree) ∪ leaves ((k::int) + (1::int)) (r::int tree). c * (a::int ⇒ nat) k) + sum a {i..(j::int) + (1::int)} = (∑(k::int, c::nat)∈incr2 ` (leaves i l ∪ leaves (k + (1::int)) r). c * a k)›*) using inorder(3,4) (*‹i ≤ k› ‹(k::int) ≤ (j::int)›*) by (simp add: sum_incr2 (*‹sum ?f (incr2 ` ?A) = (∑xy∈?A. ?f (fst xy, snd xy + 1))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) sum_Un_nat (*‹⟦finite ?A; finite ?B⟧ ⟹ sum ?f (?A ∪ ?B) = sum ?f ?A + sum ?f ?B - sum ?f (?A ∩ ?B)›*) finite_leaves (*‹finite (leaves ?i ?t)›*) l0 (*‹leaves i l ∩ leaves (k + 1) r = {}›*) sum_leaves[OF inorder(1)] (*‹i ≤ k - 1 + 1 ⟹ (∑x∈leaves i l. ?f (fst x)) = sum ?f {i..k - 1 + 1}›*) sum_leaves[OF inorder(2)] (*‹k + 1 ≤ j + 1 ⟹ (∑x∈leaves (k + 1) r. ?f (fst x)) = sum ?f {k + 1..j + 1}›*)) qed also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑a∈nodes l ∪ nodes r. case a of (k, c) ⇒ c * b k) + sum b {i..j} + (∑(k, c)∈incr2 ` (leaves i l ∪ leaves (k + 1) r). c * a k)›*) have "sum ?b ?N + sum b {i..j} = sum ?b ?N + sum b ({i..k-1} ∪ {k+1..j}) + b k" proof (-) (*goal: ‹(∑(k, c)∈nodes l ∪ nodes r. c * b k) + sum b {i..j} = (∑(k, c)∈nodes l ∪ nodes r. c * b k) + sum b ({i..k - 1} ∪ {k + 1..j}) + b k›*) have "{i..j} = {k} ∪ {i..k-1} ∪ {k+1..j}" using inorder(3,4) (*‹i ≤ k› ‹k ≤ j›*) by auto thus "?thesis" (*goal: ‹(∑(k, c)∈nodes l ∪ nodes r. c * b k) + sum b {i..j} = (∑(k, c)∈nodes l ∪ nodes r. c * b k) + sum b ({i..k - 1} ∪ {k + 1..j}) + b k›*) by simp qed also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈nodes l ∪ nodes r. c * b k) + sum b ({i..k - 1} ∪ {k + 1..j}) + b k + (∑b∈incr2 ` (leaves i l ∪ leaves (k + 1) r). case b of (k, c) ⇒ c * a k)›*) have "sum ?b ?N + sum b ({i..k-1} ∪ {k+1..j}) = sum ?b (incr2 ` ?N)" by (simp add: sum_incr2 (*‹sum ?f (incr2 ` ?A) = (∑xy∈?A. ?f (fst xy, snd xy + 1))›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) sum_Un_nat (*‹⟦finite ?A; finite ?B⟧ ⟹ sum ?f (?A ∪ ?B) = sum ?f ?A + sum ?f ?B - sum ?f (?A ∩ ?B)›*) finite_nodes (*‹finite (nodes ?t)›*) n0 (*‹nodes l ∩ nodes r = {}›*) sum_nodes[OF inorder(1)] (*‹(∑xy∈nodes l. ?f (fst xy)) = sum ?f {i..k - 1}›*) sum_nodes[OF inorder(2)] (*‹(∑xy∈nodes r. ?f (fst xy)) = sum ?f {k + 1..j}›*)) also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈incr2 ` (nodes l ∪ nodes r). c * b k) + b k + (∑b∈incr2 ` (leaves i l ∪ leaves (k + 1) r). case b of (k, c) ⇒ c * a k)›*) have "sum ?b (incr2 ` ?N) + b k = sum ?b ({(k,1)} ∪ incr2 ` ?N)" apply simp (*goal: ‹(∑(k, c)∈incr2 ` (nodes l ∪ nodes r). c * b k) + b k = (∑(k, c)∈{(k, 1)} ∪ incr2 ` (nodes l ∪ nodes r). c * b k)›*) apply (subst sum.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ sum ?g (insert ?x ?A) = ?g ?x + sum ?g ?A›*)) (*goals: 1. ‹finite (incr2 ` (nodes l ∪ nodes r))› 2. ‹(k, Suc 0) ∉ incr2 ` (nodes l ∪ nodes r)› 3. ‹(∑(k, c)∈incr2 ` (nodes l ∪ nodes r). c * b k) + b k = (case (k, Suc 0) of (k, c) ⇒ c * b k) + (∑(k, c)∈incr2 ` (nodes l ∪ nodes r). c * b k)› discuss goal 1*) apply ((auto simp add: finite_nodes (*‹finite (nodes (?t::int tree))›*) notin_nodes0 (*‹(?k::int, 0::nat) ∉ nodes (?t::int tree)›*))[1]) (*discuss goal 2*) apply ((auto simp add: finite_nodes (*‹finite (nodes ?t)›*) notin_nodes0 (*‹(?k, 0) ∉ nodes ?t›*))[1]) (*discuss goal 3*) apply ((auto simp add: finite_nodes (*‹finite (nodes ?t)›*) notin_nodes0 (*‹(?k, 0) ∉ nodes ?t›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹wpl i j ⟨l, k, r⟩ = (∑(k, c)∈{(k, 1)} ∪ incr2 ` (nodes l ∪ nodes r). c * b k) + (∑b∈incr2 ` (leaves i l ∪ leaves (k + 1) r). case b of (k, c) ⇒ c * a k)›*) have "sum ?b ({(k,1)} ∪ incr2 ` ?N) + sum ?a (incr2 ` ?L) = Wpl i ⟨l,k,r⟩" by (simp add: Wpl_def (*‹Wpl ?i ?t = (∑(k, c)∈nodes ?t. c * b k) + (∑(k, c)∈leaves ?i ?t. c * a k)›*)) finally (*calculation: ‹wpl i j ⟨l, k, r⟩ = Wpl i ⟨l, k, r⟩›*) show "?case" (*goal: ‹wpl i j ⟨l, k, r⟩ = Wpl i ⟨l, k, r⟩›*) . qed end end
{ "path": "afp-2025-02-12/thys/Optimal_BST/Weighted_Path_Length.thy", "repo": "afp-2025-02-12", "sha": "27d0d7bf0de3a1b1cee85d24fc89dbde2f4676cdde1f4bdaea4280d1583ce5d3" }
(* Title: HOL/ex/Unification.thy Author: Martin Coen, Cambridge University Computer Laboratory Author: Konrad Slind, TUM & Cambridge University Computer Laboratory Author: Alexander Krauss, TUM *) section ‹Substitution and Unification› theory Unification imports Main begin text ‹ Implements Manna \& Waldinger's formalization, with Paulson's simplifications, and some new simplifications by Slind and Krauss. Z Manna \& R Waldinger, Deductive Synthesis of the Unification Algorithm. SCP 1 (1981), 5-48 L C Paulson, Verifying the Unification Algorithm in LCF. SCP 5 (1985), 143-170 K Slind, Reasoning about Terminating Functional Programs, Ph.D. thesis, TUM, 1999, Sect. 5.8 A Krauss, Partial and Nested Recursive Function Definitions in Higher-Order Logic, JAR 44(4):303-336, 2010. Sect. 6.3 › subsection ‹Terms› text ‹Binary trees with leaves that are constants or variables.› datatype 'a trm = Var 'a | Const 'a | Comb "'a trm" "'a trm" (infix "⋅" 60) primrec vars_of :: "'a trm ⇒ 'a set" where "vars_of (Var v) = {v}" | "vars_of (Const c) = {}" | "vars_of (M ⋅ N) = vars_of M ∪ vars_of N" fun occs :: "'a trm ⇒ 'a trm ⇒ bool" (infixl "≺" 54) where "u ≺ Var v ⟷ False" | "u ≺ Const c ⟷ False" | "u ≺ M ⋅ N ⟷ u = M ∨ u = N ∨ u ≺ M ∨ u ≺ N" lemma finite_vars_of[intro]: "finite (vars_of t)" apply (induct t) (*goals: 1. ‹⋀x. finite (vars_of (Var x))› 2. ‹⋀x. finite (vars_of (Const x))› 3. ‹⋀t1 t2. ⟦finite (vars_of t1); finite (vars_of t2)⟧ ⟹ finite (vars_of (t1 ⋅ t2))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma vars_iff_occseq: "x ∈ vars_of t ⟷ Var x ≺ t ∨ Var x = t" apply (induct t) (*goals: 1. ‹⋀xa. (x ∈ vars_of (Var xa)) = (Var x ≺ Var xa ∨ Var x = Var xa)› 2. ‹⋀xa. (x ∈ vars_of (Const xa)) = (Var x ≺ Const xa ∨ Var x = Const xa)› 3. ‹⋀t1 t2. ⟦(x ∈ vars_of t1) = (Var x ≺ t1 ∨ Var x = t1); (x ∈ vars_of t2) = (Var x ≺ t2 ∨ Var x = t2)⟧ ⟹ (x ∈ vars_of (t1 ⋅ t2)) = (Var x ≺ t1 ⋅ t2 ∨ Var x = t1 ⋅ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma occs_vars_subset: "M ≺ N ⟹ vars_of M ⊆ vars_of N" apply (induct N) (*goals: 1. ‹⋀x. M ≺ Var x ⟹ vars_of M ⊆ vars_of (Var x)› 2. ‹⋀x. M ≺ Const x ⟹ vars_of M ⊆ vars_of (Const x)› 3. ‹⋀N1 N2. ⟦M ≺ N1 ⟹ vars_of M ⊆ vars_of N1; M ≺ N2 ⟹ vars_of M ⊆ vars_of N2; M ≺ N1 ⋅ N2⟧ ⟹ vars_of M ⊆ vars_of (N1 ⋅ N2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma size_less_size_if_occs: "t ≺ u ⟹ size t < size u" proof (induction u arbitrary: t) (*goals: 1. ‹⋀(x::'a) t::'a trm. t ≺ Var x ⟹ size t < size (Var x)› 2. ‹⋀(x::'a) t::'a trm. t ≺ Const x ⟹ size t < size (Const x)› 3. ‹⋀(u1::'a trm) (u2::'a trm) t::'a trm. ⟦⋀t::'a trm. t ≺ u1 ⟹ size t < size u1; ⋀t::'a trm. t ≺ u2 ⟹ size t < size u2; t ≺ u1 ⋅ u2⟧ ⟹ size t < size (u1 ⋅ u2)›*) case (Comb u1 u2) (*‹?t ≺ u1 ⟹ size ?t < size u1› ‹?t ≺ u2 ⟹ size ?t < size u2› ‹t ≺ u1 ⋅ u2›*) thus "?case" (*goal: ‹size t < size (u1 ⋅ u2)›*) by fastforce qed (simp_all) (*solves the remaining goals: 1. ‹⋀x t. t ≺ Var x ⟹ size t < size (Var x)› 2. ‹⋀x t. t ≺ Const x ⟹ size t < size (Const x)›*) corollary neq_if_occs: "t ≺ u ⟹ t ≠ u" using size_less_size_if_occs (*‹?t ≺ ?u ⟹ size ?t < size ?u›*) by auto subsection ‹Substitutions› type_synonym 'a subst = "('a × 'a trm) list" fun assoc :: "'a ⇒ 'b ⇒ ('a × 'b) list ⇒ 'b" where "assoc x d [] = d" | "assoc x d ((p,q)#t) = (if x = p then q else assoc x d t)" primrec subst :: "'a trm ⇒ 'a subst ⇒ 'a trm" (infixl "⊲" 55) where "(Var v) ⊲ s = assoc v (Var v) s" | "(Const c) ⊲ s = (Const c)" | "(M ⋅ N) ⊲ s = (M ⊲ s) ⋅ (N ⊲ s)" definition subst_eq (infixr "≐" 52) where "s1 ≐ s2 ⟷ (∀t. t ⊲ s1 = t ⊲ s2)" fun comp :: "'a subst ⇒ 'a subst ⇒ 'a subst" (infixl "◊" 56) where "[] ◊ bl = bl" | "((a,b) # al) ◊ bl = (a, b ⊲ bl) # (al ◊ bl)" lemma subst_Nil[simp]: "t ⊲ [] = t" apply (induct t) (*goals: 1. ‹⋀x. Var x ⊲ [] = Var x› 2. ‹⋀x. Const x ⊲ [] = Const x› 3. ‹⋀t1 t2. ⟦t1 ⊲ [] = t1; t2 ⊲ [] = t2⟧ ⟹ t1 ⋅ t2 ⊲ [] = t1 ⋅ t2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma subst_mono: "t ≺ u ⟹ t ⊲ s ≺ u ⊲ s" apply (induct u) (*goals: 1. ‹⋀x::'a. (t::'a trm) ≺ Var x ⟹ t ⊲ (s::('a × 'a trm) list) ≺ Var x ⊲ s› 2. ‹⋀x::'a. (t::'a trm) ≺ Const x ⟹ t ⊲ (s::('a × 'a trm) list) ≺ Const x ⊲ s› 3. ‹⋀(u1::'a trm) u2::'a trm. ⟦(t::'a trm) ≺ u1 ⟹ t ⊲ (s::('a × 'a trm) list) ≺ u1 ⊲ s; t ≺ u2 ⟹ t ⊲ s ≺ u2 ⊲ s; t ≺ u1 ⋅ u2⟧ ⟹ t ⊲ s ≺ u1 ⋅ u2 ⊲ s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma agreement: "(t ⊲ r = t ⊲ s) ⟷ (∀v ∈ vars_of t. Var v ⊲ r = Var v ⊲ s)" apply (induct t) (*goals: 1. ‹⋀x. (Var x ⊲ r = Var x ⊲ s) = (∀v∈vars_of (Var x). Var v ⊲ r = Var v ⊲ s)› 2. ‹⋀x. (Const x ⊲ r = Const x ⊲ s) = (∀v∈vars_of (Const x). Var v ⊲ r = Var v ⊲ s)› 3. ‹⋀t1 t2. ⟦(t1 ⊲ r = t1 ⊲ s) = (∀v∈vars_of t1. Var v ⊲ r = Var v ⊲ s); (t2 ⊲ r = t2 ⊲ s) = (∀v∈vars_of t2. Var v ⊲ r = Var v ⊲ s)⟧ ⟹ (t1 ⋅ t2 ⊲ r = t1 ⋅ t2 ⊲ s) = (∀v∈vars_of (t1 ⋅ t2). Var v ⊲ r = Var v ⊲ s)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma repl_invariance: "v ∉ vars_of t ⟹ t ⊲ (v,u) # s = t ⊲ s" by (simp add: agreement (*‹(?t ⊲ ?r = ?t ⊲ ?s) = (∀v∈vars_of ?t. Var v ⊲ ?r = Var v ⊲ ?s)›*)) lemma remove_var: "v ∉ vars_of s ⟹ v ∉ vars_of (t ⊲ [(v, s)])" apply (induct t) (*goals: 1. ‹⋀x. v ∉ vars_of s ⟹ v ∉ vars_of (Var x ⊲ [(v, s)])› 2. ‹⋀x. v ∉ vars_of s ⟹ v ∉ vars_of (Const x ⊲ [(v, s)])› 3. ‹⋀t1 t2. ⟦v ∉ vars_of s ⟹ v ∉ vars_of (t1 ⊲ [(v, s)]); v ∉ vars_of s ⟹ v ∉ vars_of (t2 ⊲ [(v, s)]); v ∉ vars_of s⟧ ⟹ v ∉ vars_of (t1 ⋅ t2 ⊲ [(v, s)])› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma subst_refl[iff]: "s ≐ s" by (auto simp:subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma subst_sym[sym]: "⟦s1 ≐ s2⟧ ⟹ s2 ≐ s1" by (auto simp:subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma subst_trans[trans]: "⟦s1 ≐ s2; s2 ≐ s3⟧ ⟹ s1 ≐ s3" by (auto simp:subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma subst_no_occs: "¬ Var v ≺ t ⟹ Var v ≠ t ⟹ t ⊲ [(v,s)] = t" apply (induct t) (*goals: 1. ‹⋀x. ⟦¬ Var v ≺ Var x; Var v ≠ Var x⟧ ⟹ Var x ⊲ [(v, s)] = Var x› 2. ‹⋀x. ⟦¬ Var v ≺ Const x; Var v ≠ Const x⟧ ⟹ Const x ⊲ [(v, s)] = Const x› 3. ‹⋀t1 t2. ⟦⟦¬ Var v ≺ t1; Var v ≠ t1⟧ ⟹ t1 ⊲ [(v, s)] = t1; ⟦¬ Var v ≺ t2; Var v ≠ t2⟧ ⟹ t2 ⊲ [(v, s)] = t2; ¬ Var v ≺ t1 ⋅ t2; Var v ≠ t1 ⋅ t2⟧ ⟹ t1 ⋅ t2 ⊲ [(v, s)] = t1 ⋅ t2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma comp_Nil[simp]: "σ ◊ [] = σ" apply (induct σ) (*goals: 1. ‹[] ◊ [] = []› 2. ‹⋀(a::'a::type × 'a::type trm) σ::('a::type × 'a::type trm) list. σ ◊ [] = σ ⟹ a # σ ◊ [] = a # σ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma subst_comp[simp]: "t ⊲ (r ◊ s) = t ⊲ r ⊲ s" proof (induct t) (*goals: 1. ‹⋀x. Var x ⊲ r ◊ s = Var x ⊲ r ⊲ s› 2. ‹⋀x. Const x ⊲ r ◊ s = Const x ⊲ r ⊲ s› 3. ‹⋀t1 t2. ⟦t1 ⊲ r ◊ s = t1 ⊲ r ⊲ s; t2 ⊲ r ◊ s = t2 ⊲ r ⊲ s⟧ ⟹ t1 ⋅ t2 ⊲ r ◊ s = t1 ⋅ t2 ⊲ r ⊲ s›*) case (Var v) (*no hyothesis introduced yet*) thus "?case" (*goal: ‹Var v ⊲ r ◊ s = Var v ⊲ r ⊲ s›*) apply (induct r) (*goals: 1. ‹Var v ⊲ [] ◊ s = Var v ⊲ [] ⊲ s› 2. ‹⋀a r. Var v ⊲ r ◊ s = Var v ⊲ r ⊲ s ⟹ Var v ⊲ a # r ◊ s = Var v ⊲ a # r ⊲ s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (auto) (*solves the remaining goals: 1. ‹⋀x. Const x ⊲ r ◊ s = Const x ⊲ r ⊲ s› 2. ‹⋀t1 t2. ⟦t1 ⊲ r ◊ s = t1 ⊲ r ⊲ s; t2 ⊲ r ◊ s = t2 ⊲ r ⊲ s⟧ ⟹ t1 ⋅ t2 ⊲ r ◊ s = t1 ⋅ t2 ⊲ r ⊲ s›*) lemma subst_eq_intro[intro]: "(⋀t. t ⊲ σ = t ⊲ θ) ⟹ σ ≐ θ" by (auto simp:subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma subst_eq_dest[dest]: "s1 ≐ s2 ⟹ t ⊲ s1 = t ⊲ s2" by (auto simp:subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma comp_assoc: "(a ◊ b) ◊ c ≐ a ◊ (b ◊ c)" by auto lemma subst_cong: "⟦σ ≐ σ'; θ ≐ θ'⟧ ⟹ (σ ◊ θ) ≐ (σ' ◊ θ')" by (auto simp: subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma var_self: "[(v, Var v)] ≐ []" proof (standard) (*goal: ‹⋀t. t ⊲ [(v, Var v)] = t ⊲ []›*) fix t show "t ⊲ [(v, Var v)] = t ⊲ []" apply (induct t) (*goals: 1. ‹⋀x. Var x ⊲ [(v, Var v)] = Var x ⊲ []› 2. ‹⋀x. Const x ⊲ [(v, Var v)] = Const x ⊲ []› 3. ‹⋀t1 t2. ⟦t1 ⊲ [(v, Var v)] = t1 ⊲ []; t2 ⊲ [(v, Var v)] = t2 ⊲ []⟧ ⟹ t1 ⋅ t2 ⊲ [(v, Var v)] = t1 ⋅ t2 ⊲ []› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . qed lemma var_same[simp]: "[(v, t)] ≐ [] ⟷ t = Var v" by (metis assoc.simps( (*‹assoc ?x ?d ((?p, ?q) # ?t) = (if ?x = ?p then ?q else assoc ?x ?d ?t)›*) 2) subst.simps( (*‹Var ?v ⊲ ?s = assoc ?v (Var ?v) ?s›*) 1) subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*) var_self (*‹[(?v, Var ?v)] ≐ []›*)) lemma vars_of_subst_conv_Union: "vars_of (t ⊲ η) = ⋃(vars_of ` (λx. Var x ⊲ η) ` vars_of t)" apply (induction t) (*goals: 1. ‹⋀x. vars_of (Var x ⊲ η) = ⋃ (vars_of ` (λx. Var x ⊲ η) ` vars_of (Var x))› 2. ‹⋀x. vars_of (Const x ⊲ η) = ⋃ (vars_of ` (λx. Var x ⊲ η) ` vars_of (Const x))› 3. ‹⋀t1 t2. ⟦vars_of (t1 ⊲ η) = ⋃ (vars_of ` (λx. Var x ⊲ η) ` vars_of t1); vars_of (t2 ⊲ η) = ⋃ (vars_of ` (λx. Var x ⊲ η) ` vars_of t2)⟧ ⟹ vars_of (t1 ⋅ t2 ⊲ η) = ⋃ (vars_of ` (λx. Var x ⊲ η) ` vars_of (t1 ⋅ t2))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma domain_comp: "fst ` set (σ ◊ θ) = fst ` (set σ ∪ set θ)" apply (induction σ θ rule: comp.induct (*‹⟦⋀bl::(?'a × ?'a trm) list. (?P::(?'a × ?'a trm) list ⇒ (?'a × ?'a trm) list ⇒ bool) [] bl; ⋀(a::?'a) (b::?'a trm) (al::(?'a × ?'a trm) list) bl::(?'a × ?'a trm) list. ?P al bl ⟹ ?P ((a, b) # al) bl⟧ ⟹ ?P (?a0.0::(?'a × ?'a trm) list) (?a1.0::(?'a × ?'a trm) list)›*)) (*goals: 1. ‹⋀bl. fst ` set ([] ◊ bl) = fst ` (set [] ∪ set bl)› 2. ‹⋀a b al bl. fst ` set (al ◊ bl) = fst ` (set al ∪ set bl) ⟹ fst ` set ((a, b) # al ◊ bl) = fst ` (set ((a, b) # al) ∪ set bl)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection ‹Unifiers and Most General Unifiers› definition Unifier :: "'a subst ⇒ 'a trm ⇒ 'a trm ⇒ bool" where "Unifier σ t u ⟷ (t ⊲ σ = u ⊲ σ)" lemma not_occs_if_Unifier: assumes "Unifier σ t u" shows "¬ (t ≺ u) ∧ ¬ (u ≺ t)" proof (-) (*goal: ‹¬ t ≺ u ∧ ¬ u ≺ t›*) from assms (*‹Unifier σ t u›*) have "t ⊲ σ = u ⊲ σ" unfolding Unifier_def (*goal: ‹t ⊲ σ = u ⊲ σ›*) by simp thus "?thesis" (*goal: ‹¬ t ≺ u ∧ ¬ u ≺ t›*) using neq_if_occs (*‹?t ≺ ?u ⟹ ?t ≠ ?u›*) subst_mono (*‹?t ≺ ?u ⟹ ?t ⊲ ?s ≺ ?u ⊲ ?s›*) by metis qed definition MGU :: "'a subst ⇒ 'a trm ⇒ 'a trm ⇒ bool" where "MGU σ t u ⟷ Unifier σ t u ∧ (∀θ. Unifier θ t u ⟶ (∃γ. θ ≐ σ ◊ γ))" lemma MGUI[intro]: "⟦t ⊲ σ = u ⊲ σ; ⋀θ. t ⊲ θ = u ⊲ θ ⟹ ∃γ. θ ≐ σ ◊ γ⟧ ⟹ MGU σ t u" apply (simp only:Unifier_def (*‹Unifier ?σ ?t ?u = (?t ⊲ ?σ = ?u ⊲ ?σ)›*) MGU_def (*‹MGU ?σ ?t ?u = (Unifier ?σ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ (∃γ. θ ≐ ?σ ◊ γ)))›*)) (*goal: ‹⟦(t::'a trm) ⊲ (σ::('a × 'a trm) list) = (u::'a trm) ⊲ σ; ⋀θ::('a × 'a trm) list. t ⊲ θ = u ⊲ θ ⟹ ∃γ::('a × 'a trm) list. θ ≐ σ ◊ γ⟧ ⟹ MGU σ t u›*) by auto lemma MGU_sym[sym]: "MGU σ s t ⟹ MGU σ t s" by (auto simp:MGU_def (*‹MGU (?σ::(?'a × ?'a trm) list) (?t::?'a trm) (?u::?'a trm) = (Unifier ?σ ?t ?u ∧ (∀θ::(?'a × ?'a trm) list. Unifier θ ?t ?u ⟶ (∃γ::(?'a × ?'a trm) list. θ ≐ ?σ ◊ γ)))›*) Unifier_def (*‹Unifier (?σ::(?'a × ?'a trm) list) (?t::?'a trm) (?u::?'a trm) = (?t ⊲ ?σ = ?u ⊲ ?σ)›*)) lemma MGU_is_Unifier: "MGU σ t u ⟹ Unifier σ t u" unfolding MGU_def (*goal: ‹Unifier σ t u ∧ (∀θ. Unifier θ t u ⟶ (∃γ. θ ≐ σ ◊ γ)) ⟹ Unifier σ t u›*) by (rule conjunct1 (*‹?P ∧ ?Q ⟹ ?P›*)) lemma MGU_Var: assumes "¬ Var v ≺ t" shows "MGU [(v,t)] (Var v) t" proof (intro MGUI (*‹⟦?t ⊲ ?σ = ?u ⊲ ?σ; ⋀θ. ?t ⊲ θ = ?u ⊲ θ ⟹ ∃γ. θ ≐ ?σ ◊ γ⟧ ⟹ MGU ?σ ?t ?u›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goals: 1. ‹Var v ⊲ [(v, t)] = t ⊲ [(v, t)]› 2. ‹⋀θ. Var v ⊲ θ = t ⊲ θ ⟹ θ ≐ [(v, t)] ◊ ?γ1 θ›*) show "Var v ⊲ [(v,t)] = t ⊲ [(v,t)]" using assms (*‹¬ Var v ≺ t›*) by (metis assoc.simps( (*‹assoc ?x ?d ((?p, ?q) # ?t) = (if ?x = ?p then ?q else assoc ?x ?d ?t)›*) 2) repl_invariance (*‹?v ∉ vars_of ?t ⟹ ?t ⊲ (?v, ?u) # ?s = ?t ⊲ ?s›*) subst.simps( (*‹Var ?v ⊲ ?s = assoc ?v (Var ?v) ?s›*) 1) subst_Nil (*‹?t ⊲ [] = ?t›*) vars_iff_occseq (*‹(?x ∈ vars_of ?t) = (Var ?x ≺ ?t ∨ Var ?x = ?t)›*)) next (*goal: ‹⋀θ. Var v ⊲ θ = t ⊲ θ ⟹ θ ≐ [(v, t)] ◊ ?γ1 θ›*) fix θ assume th: "Var v ⊲ θ = t ⊲ θ" (*‹Var (v::'a) ⊲ (θ::('a × 'a trm) list) = (t::'a trm) ⊲ θ›*) show "θ ≐ [(v,t)] ◊ θ" proof (standard) (*goal: ‹⋀ta. ta ⊲ θ = ta ⊲ [(v, t)] ◊ θ›*) fix s show "s ⊲ θ = s ⊲ [(v,t)] ◊ θ" using th (*‹Var v ⊲ θ = t ⊲ θ›*) apply (induct s) (*goals: 1. ‹⋀x. Var v ⊲ θ = t ⊲ θ ⟹ Var x ⊲ θ = Var x ⊲ [(v, t)] ◊ θ› 2. ‹⋀x. Var v ⊲ θ = t ⊲ θ ⟹ Const x ⊲ θ = Const x ⊲ [(v, t)] ◊ θ› 3. ‹⋀s1 s2. ⟦Var v ⊲ θ = t ⊲ θ ⟹ s1 ⊲ θ = s1 ⊲ [(v, t)] ◊ θ; Var v ⊲ θ = t ⊲ θ ⟹ s2 ⊲ θ = s2 ⊲ [(v, t)] ◊ θ; Var v ⊲ θ = t ⊲ θ⟧ ⟹ s1 ⋅ s2 ⊲ θ = s1 ⋅ s2 ⊲ [(v, t)] ◊ θ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed qed lemma MGU_Const: "MGU [] (Const c) (Const d) ⟷ c = d" by (auto simp: MGU_def (*‹MGU ?σ ?t ?u = (Unifier ?σ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ (∃γ. θ ≐ ?σ ◊ γ)))›*) Unifier_def (*‹Unifier ?σ ?t ?u = (?t ⊲ ?σ = ?u ⊲ ?σ)›*)) subsection ‹The unification algorithm› function unify :: "'a trm ⇒ 'a trm ⇒ 'a subst option" where "unify (Const c) (M ⋅ N) = None" | "unify (M ⋅ N) (Const c) = None" | "unify (Const c) (Var v) = Some [(v, Const c)]" | "unify (M ⋅ N) (Var v) = (if Var v ≺ M ⋅ N then None else Some [(v, M ⋅ N)])" | "unify (Var v) M = (if Var v ≺ M then None else Some [(v, M)])" | "unify (Const c) (Const d) = (if c=d then Some [] else None)" | "unify (M ⋅ N) (M' ⋅ N') = (case unify M M' of None ⇒ None | Some θ ⇒ (case unify (N ⊲ θ) (N' ⊲ θ) of None ⇒ None | Some σ ⇒ Some (θ ◊ σ)))" by pat_completeness auto subsection ‹Properties used in termination proof› text ‹Elimination of variables by a substitution:› definition "elim σ v ≡ ∀t. v ∉ vars_of (t ⊲ σ)" lemma elim_intro[intro]: "(⋀t. v ∉ vars_of (t ⊲ σ)) ⟹ elim σ v" by (auto simp:elim_def (*‹elim ?σ ?v ≡ ∀t. ?v ∉ vars_of (t ⊲ ?σ)›*)) lemma elim_dest[dest]: "elim σ v ⟹ v ∉ vars_of (t ⊲ σ)" by (auto simp:elim_def (*‹elim (?σ::(?'a × ?'a trm) list) (?v::?'a) ≡ ∀t::?'a trm. ?v ∉ vars_of (t ⊲ ?σ)›*)) lemma elim_eq: "σ ≐ θ ⟹ elim σ x = elim θ x" by (auto simp:elim_def (*‹elim ?σ ?v ≡ ∀t. ?v ∉ vars_of (t ⊲ ?σ)›*) subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma occs_elim: "¬ Var v ≺ t ⟹ elim [(v,t)] v ∨ [(v,t)] ≐ []" by (metis elim_intro (*‹(⋀t. ?v ∉ vars_of (t ⊲ ?σ)) ⟹ elim ?σ ?v›*) remove_var (*‹?v ∉ vars_of ?s ⟹ ?v ∉ vars_of (?t ⊲ [(?v, ?s)])›*) var_same (*‹[(?v, ?t)] ≐ [] = (?t = Var ?v)›*) vars_iff_occseq (*‹(?x ∈ vars_of ?t) = (Var ?x ≺ ?t ∨ Var ?x = ?t)›*)) text ‹The result of a unification never introduces new variables:› declare unify.psimps[simp] lemma unify_vars: assumes "unify_dom (M, N)" assumes "unify M N = Some σ" shows "vars_of (t ⊲ σ) ⊆ vars_of M ∪ vars_of N ∪ vars_of t" (is "?P M N σ t") using assms (*‹unify_dom (M, N)› ‹unify M N = Some σ›*) proof (induct M N arbitrary:σ t) (*goals: 1. ‹⋀c M N σ t. ⟦unify_dom (Const c, M ⋅ N); unify (Const c) (M ⋅ N) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N) ∪ vars_of t› 2. ‹⋀M N c σ t. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c) ∪ vars_of t› 3. ‹⋀c v σ t. ⟦unify_dom (Const c, Var v); unify (Const c) (Var v) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Var v) ∪ vars_of t› 4. ‹⋀M N v σ t. ⟦unify_dom (M ⋅ N, Var v); unify (M ⋅ N) (Var v) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of t› 5. ‹⋀v M σ t. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of t› 6. ‹⋀c d σ t. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Const d) ∪ vars_of t› 7. ‹⋀M N M' N' σ t. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ t. unify M M' = Some σ ⟹ vars_of (t ⊲ σ) ⊆ vars_of M ∪ vars_of M' ∪ vars_of t; ⋀x2 σ t. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2) ∪ vars_of t; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) case (3 c v) (*‹unify_dom (Const c, Var v)› ‹unify (Const c) (Var v) = Some σ›*) hence "σ = [(v, Const c)]" by simp thus "?case" (*goal: ‹vars_of ((t::'a trm) ⊲ (σ::('a × 'a trm) list)) ⊆ vars_of (Const (c::'a)) ∪ vars_of (Var (v::'a)) ∪ vars_of t›*) apply (induct t) (*goals: 1. ‹⋀x. σ = [(v, Const c)] ⟹ vars_of (Var x ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Var v) ∪ vars_of (Var x)› 2. ‹⋀x. σ = [(v, Const c)] ⟹ vars_of (Const x ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Var v) ∪ vars_of (Const x)› 3. ‹⋀t1 t2. ⟦σ = [(v, Const c)] ⟹ vars_of (t1 ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Var v) ∪ vars_of t1; σ = [(v, Const c)] ⟹ vars_of (t2 ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Var v) ∪ vars_of t2; σ = [(v, Const c)]⟧ ⟹ vars_of (t1 ⋅ t2 ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Var v) ∪ vars_of (t1 ⋅ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀c M N σ t. ⟦unify_dom (Const c, M ⋅ N); unify (Const c) (M ⋅ N) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N) ∪ vars_of t› 2. ‹⋀M N c σ t. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c) ∪ vars_of t› 3. ‹⋀M N v σ t. ⟦unify_dom (M ⋅ N, Var v); unify (M ⋅ N) (Var v) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of t› 4. ‹⋀v M σ t. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of t› 5. ‹⋀c d σ t. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Const d) ∪ vars_of t› 6. ‹⋀M N M' N' σ t. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ t. unify M M' = Some σ ⟹ vars_of (t ⊲ σ) ⊆ vars_of M ∪ vars_of M' ∪ vars_of t; ⋀x2 σ t. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2) ∪ vars_of t; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) case (4 M N v) (*‹unify_dom (M ⋅ N, Var v)› ‹unify (M ⋅ N) (Var v) = Some σ›*) hence "¬ Var v ≺ M ⋅ N" by auto with "4" (*‹unify_dom (M ⋅ N, Var v)› ‹unify (M ⋅ N) (Var v) = Some σ›*) have "σ = [(v, M⋅N)]" by simp thus "?case" (*goal: ‹vars_of ((t::'a trm) ⊲ (σ::('a × 'a trm) list)) ⊆ vars_of ((M::'a trm) ⋅ (N::'a trm)) ∪ vars_of (Var (v::'a)) ∪ vars_of t›*) apply (induct t) (*goals: 1. ‹⋀x::'a. (σ::('a × 'a trm) list) = [(v::'a, (M::'a trm) ⋅ (N::'a trm))] ⟹ vars_of (Var x ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of (Var x)› 2. ‹⋀x::'a. (σ::('a × 'a trm) list) = [(v::'a, (M::'a trm) ⋅ (N::'a trm))] ⟹ vars_of (Const x ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of (Const x)› 3. ‹⋀(t1::'a trm) t2::'a trm. ⟦(σ::('a × 'a trm) list) = [(v::'a, (M::'a trm) ⋅ (N::'a trm))] ⟹ vars_of (t1 ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of t1; σ = [(v, M ⋅ N)] ⟹ vars_of (t2 ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of t2; σ = [(v, M ⋅ N)]⟧ ⟹ vars_of (t1 ⋅ t2 ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v) ∪ vars_of (t1 ⋅ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀c M N σ t. ⟦unify_dom (Const c, M ⋅ N); unify (Const c) (M ⋅ N) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N) ∪ vars_of t› 2. ‹⋀M N c σ t. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c) ∪ vars_of t› 3. ‹⋀v M σ t. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of t› 4. ‹⋀c d σ t. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Const d) ∪ vars_of t› 5. ‹⋀M N M' N' σ t. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ t. unify M M' = Some σ ⟹ vars_of (t ⊲ σ) ⊆ vars_of M ∪ vars_of M' ∪ vars_of t; ⋀x2 σ t. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2) ∪ vars_of t; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) case (5 v M) (*‹unify_dom (Var v, M)› ‹unify (Var v) M = Some σ›*) hence "¬ Var v ≺ M" by auto with "5" (*‹unify_dom (Var (v::'a::type), M::'a::type trm)› ‹unify (Var v) M = Some σ›*) have "σ = [(v, M)]" by simp thus "?case" (*goal: ‹vars_of (t ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of t›*) apply (induct t) (*goals: 1. ‹⋀x. σ = [(v, M)] ⟹ vars_of (Var x ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of (Var x)› 2. ‹⋀x. σ = [(v, M)] ⟹ vars_of (Const x ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of (Const x)› 3. ‹⋀t1 t2. ⟦σ = [(v, M)] ⟹ vars_of (t1 ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of t1; σ = [(v, M)] ⟹ vars_of (t2 ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of t2; σ = [(v, M)]⟧ ⟹ vars_of (t1 ⋅ t2 ⊲ σ) ⊆ vars_of (Var v) ∪ vars_of M ∪ vars_of (t1 ⋅ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀(c::'a) (M::'a trm) (N::'a trm) (σ::('a × 'a trm) list) t::'a trm. ⟦unify_dom (Const c, M ⋅ N); unify (Const c) (M ⋅ N) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N) ∪ vars_of t› 2. ‹⋀(M::'a trm) (N::'a trm) (c::'a) (σ::('a × 'a trm) list) t::'a trm. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c) ∪ vars_of t› 3. ‹⋀(c::'a) (d::'a) (σ::('a × 'a trm) list) t::'a trm. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Const d) ∪ vars_of t› 4. ‹⋀(M::'a trm) (N::'a trm) (M'::'a trm) (N'::'a trm) (σ::('a × 'a trm) list) t::'a trm. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀(σ::('a × 'a trm) list) t::'a trm. unify M M' = Some σ ⟹ vars_of (t ⊲ σ) ⊆ vars_of M ∪ vars_of M' ∪ vars_of t; ⋀(x2::('a × 'a trm) list) (σ::('a × 'a trm) list) t::'a trm. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2) ∪ vars_of t; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) case (7 M N M' N' σ) (*‹unify_dom ((M::'a trm) ⋅ (N::'a trm), (M'::'a trm) ⋅ (N'::'a trm))› ‹unify M M' = Some ?σ ⟹ vars_of (?t ⊲ ?σ) ⊆ vars_of M ∪ vars_of M' ∪ vars_of ?t› ‹⟦unify M M' = Some ?x2.0; unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ vars_of (?t ⊲ ?σ) ⊆ vars_of (N ⊲ ?x2.0) ∪ vars_of (N' ⊲ ?x2.0) ∪ vars_of ?t› ‹unify (M ⋅ N) (M' ⋅ N') = Some σ›*) then obtain θ1 and θ2 where "unify M M' = Some θ1" and "unify (N ⊲ θ1) (N' ⊲ θ1) = Some θ2" and "σ": "σ = θ1 ◊ θ2" and ih1: "⋀t. ?P M M' θ1 t" and ih2: "⋀t. ?P (N⊲θ1) (N'⊲θ1) θ2 t" (*goal: ‹(⋀θ1 θ2. ⟦unify M M' = Some θ1; unify (N ⊲ θ1) (N' ⊲ θ1) = Some θ2; σ = θ1 ◊ θ2; ⋀t. vars_of (t ⊲ θ1) ⊆ vars_of M ∪ vars_of M' ∪ vars_of t; ⋀t. vars_of (t ⊲ θ2) ⊆ vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1) ∪ vars_of t⟧ ⟹ thesis) ⟹ thesis›*) by (auto split:option.split_asm (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) show "?case" (*goal: ‹vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) proof (standard) (*goal: ‹⋀x. x ∈ vars_of (t ⊲ σ) ⟹ x ∈ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) fix v assume a: "v ∈ vars_of (t ⊲ σ)" (*‹(v::'a) ∈ vars_of ((t::'a trm) ⊲ (σ::('a × 'a trm) list))›*) show "v ∈ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t" proof (cases "v ∉ vars_of M ∧ v ∉ vars_of M' ∧ v ∉ vars_of N ∧ v ∉ vars_of N'") (*goals: 1. ‹v ∉ vars_of M ∧ v ∉ vars_of M' ∧ v ∉ vars_of N ∧ v ∉ vars_of N' ⟹ v ∈ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t› 2. ‹¬ (v ∉ vars_of M ∧ v ∉ vars_of M' ∧ v ∉ vars_of N ∧ v ∉ vars_of N') ⟹ v ∈ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) case True (*‹v ∉ vars_of M ∧ v ∉ vars_of M' ∧ v ∉ vars_of N ∧ v ∉ vars_of N'›*) with ih1 (*‹vars_of ((?t::'a trm) ⊲ (θ1::('a × 'a trm) list)) ⊆ vars_of (M::'a trm) ∪ vars_of (M'::'a trm) ∪ vars_of ?t›*) have l: "⋀t. v ∈ vars_of (t ⊲ θ1) ⟹ v ∈ vars_of t" by auto from a (*‹v ∈ vars_of (t ⊲ σ)›*) ih2[where t = "t ⊲ θ1"] (*‹vars_of (t ⊲ θ1 ⊲ θ2) ⊆ vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1) ∪ vars_of (t ⊲ θ1)›*) have "v ∈ vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1) ∨ v ∈ vars_of (t ⊲ θ1)" unfolding "σ" (*goal: ‹v ∈ vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1) ∨ v ∈ vars_of (t ⊲ θ1)›*) by auto hence "v ∈ vars_of t" proof (standard) (*goals: 1. ‹(v::'a) ∈ vars_of ((N::'a trm) ⊲ (θ1::('a × 'a trm) list)) ∪ vars_of ((N'::'a trm) ⊲ θ1) ⟹ v ∈ vars_of (t::'a trm)› 2. ‹(v::'a) ∈ vars_of ((t::'a trm) ⊲ (θ1::('a × 'a trm) list)) ⟹ v ∈ vars_of t›*) assume "v ∈ vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1)" (*‹(v::'a) ∈ vars_of ((N::'a trm) ⊲ (θ1::('a × 'a trm) list)) ∪ vars_of ((N'::'a trm) ⊲ θ1)›*) with True (*‹v ∉ vars_of M ∧ v ∉ vars_of M' ∧ v ∉ vars_of N ∧ v ∉ vars_of N'›*) show "?thesis" (*goal: ‹v ∈ vars_of t›*) by (auto dest:l (*‹v ∈ vars_of (?t ⊲ θ1) ⟹ v ∈ vars_of ?t›*)) next (*goal: ‹v ∈ vars_of (t ⊲ θ1) ⟹ v ∈ vars_of t›*) assume "v ∈ vars_of (t ⊲ θ1)" (*‹(v::'a) ∈ vars_of ((t::'a trm) ⊲ (θ1::('a × 'a trm) list))›*) thus "?thesis" (*goal: ‹v ∈ vars_of t›*) by (rule l (*‹v ∈ vars_of (?t ⊲ θ1) ⟹ v ∈ vars_of ?t›*)) qed thus "?thesis" (*goal: ‹v ∈ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) by auto qed (auto) (*solved the remaining goal: ‹¬ (v ∉ vars_of M ∧ v ∉ vars_of M' ∧ v ∉ vars_of N ∧ v ∉ vars_of N') ⟹ v ∈ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N') ∪ vars_of t›*) qed qed (auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*solves the remaining goals: 1. ‹⋀c M N σ t. ⟦unify_dom (Const c, M ⋅ N); unify (Const c) (M ⋅ N) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N) ∪ vars_of t› 2. ‹⋀M N c σ t. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c) ∪ vars_of t› 3. ‹⋀c d σ t. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ vars_of (t ⊲ σ) ⊆ vars_of (Const c) ∪ vars_of (Const d) ∪ vars_of t›*) text ‹The result of a unification is either the identity substitution or it eliminates a variable from one of the terms:› lemma unify_eliminates: assumes "unify_dom (M, N)" assumes "unify M N = Some σ" shows "(∃v∈vars_of M ∪ vars_of N. elim σ v) ∨ σ ≐ []" (is "?P M N σ") using assms (*‹unify_dom (M, N)› ‹unify M N = Some σ›*) proof (induct M N arbitrary:σ) (*goals: 1. ‹⋀c M N σ. ⟦unify_dom (Const c, M ⋅ N); unify (Const c) (M ⋅ N) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (M ⋅ N)) (elim σ) ∨ σ ≐ []› 2. ‹⋀M N c σ. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (Const c)) (elim σ) ∨ σ ≐ []› 3. ‹⋀c v σ. ⟦unify_dom (Const c, Var v); unify (Const c) (Var v) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 4. ‹⋀M N v σ. ⟦unify_dom (M ⋅ N, Var v); unify (M ⋅ N) (Var v) = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 5. ‹⋀v M σ. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ Bex (vars_of (Var v) ∪ vars_of M) (elim σ) ∨ σ ≐ []› 6. ‹⋀c d σ. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Const d)) (elim σ) ∨ σ ≐ []› 7. ‹⋀M N M' N' σ. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case 1 (*‹unify_dom (Const c_, M_ ⋅ N_)› ‹unify (Const (c_::'a::type)) ((M_::'a::type trm) ⋅ (N_::'a::type trm)) = Some (σ::('a::type × 'a::type trm) list)›*) thus "?case" (*goal: ‹(∃a∈vars_of (Const c_) ∪ vars_of (M_ ⋅ N_). elim σ a) ∨ σ ≐ []›*) by simp next (*goals: 1. ‹⋀M N c σ. ⟦unify_dom (M ⋅ N, Const c); unify (M ⋅ N) (Const c) = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (Const c)) (elim σ) ∨ σ ≐ []› 2. ‹⋀c v σ. ⟦unify_dom (Const c, Var v); unify (Const c) (Var v) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 3. ‹⋀M N v σ. ⟦unify_dom (M ⋅ N, Var v); unify (M ⋅ N) (Var v) = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 4. ‹⋀v M σ. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ Bex (vars_of (Var v) ∪ vars_of M) (elim σ) ∨ σ ≐ []› 5. ‹⋀c d σ. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Const d)) (elim σ) ∨ σ ≐ []› 6. ‹⋀M N M' N' σ. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case 2 (*‹unify_dom (M_ ⋅ N_, Const c_)› ‹unify (M_ ⋅ N_) (Const c_) = Some σ›*) thus "?case" (*goal: ‹(∃a∈vars_of (M_ ⋅ N_) ∪ vars_of (Const c_). elim σ a) ∨ σ ≐ []›*) by simp next (*goals: 1. ‹⋀c v σ. ⟦unify_dom (Const c, Var v); unify (Const c) (Var v) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 2. ‹⋀M N v σ. ⟦unify_dom (M ⋅ N, Var v); unify (M ⋅ N) (Var v) = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 3. ‹⋀v M σ. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ Bex (vars_of (Var v) ∪ vars_of M) (elim σ) ∨ σ ≐ []› 4. ‹⋀c d σ. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Const d)) (elim σ) ∨ σ ≐ []› 5. ‹⋀M N M' N' σ. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case (3 c v) (*‹unify_dom (Const c, Var v)› ‹unify (Const c) (Var v) = Some σ›*) have no_occs: "¬ Var v ≺ Const c" by simp with "3" (*‹unify_dom (Const (c::'a), Var (v::'a))› ‹unify (Const c) (Var v) = Some σ›*) have "σ = [(v, Const c)]" by simp with occs_elim[OF no_occs] (*‹elim [(v, Const c)] v ∨ [(v, Const c)] ≐ []›*) show "?case" (*goal: ‹(∃a∈vars_of (Const c) ∪ vars_of (Var v). elim σ a) ∨ σ ≐ []›*) by auto next (*goals: 1. ‹⋀M N v σ. ⟦unify_dom (M ⋅ N, Var v); unify (M ⋅ N) (Var v) = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (Var v)) (elim σ) ∨ σ ≐ []› 2. ‹⋀v M σ. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ Bex (vars_of (Var v) ∪ vars_of M) (elim σ) ∨ σ ≐ []› 3. ‹⋀c d σ. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Const d)) (elim σ) ∨ σ ≐ []› 4. ‹⋀M N M' N' σ. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case (4 M N v) (*‹unify_dom (M ⋅ N, Var v)› ‹unify (M ⋅ N) (Var v) = Some σ›*) hence no_occs: "¬ Var v ≺ M ⋅ N" by auto with "4" (*‹unify_dom ((M::'a trm) ⋅ (N::'a trm), Var (v::'a))› ‹unify (M ⋅ N) (Var v) = Some σ›*) have "σ = [(v, M⋅N)]" by simp with occs_elim[OF no_occs] (*‹elim [(v, M ⋅ N)] v ∨ [(v, M ⋅ N)] ≐ []›*) show "?case" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (Var v). elim σ a) ∨ σ ≐ []›*) by auto next (*goals: 1. ‹⋀(v::'a) (M::'a trm) σ::('a × 'a trm) list. ⟦unify_dom (Var v, M); unify (Var v) M = Some σ⟧ ⟹ Bex (vars_of (Var v) ∪ vars_of M) (elim σ) ∨ σ ≐ []› 2. ‹⋀(c::'a) (d::'a) σ::('a × 'a trm) list. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Const d)) (elim σ) ∨ σ ≐ []› 3. ‹⋀(M::'a trm) (N::'a trm) (M'::'a trm) (N'::'a trm) σ::('a × 'a trm) list. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ::('a × 'a trm) list. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀(x2::('a × 'a trm) list) σ::('a × 'a trm) list. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case (5 v M) (*‹unify_dom (Var (v::'a::type), M::'a::type trm)› ‹unify (Var v) M = Some σ›*) hence no_occs: "¬ Var v ≺ M" by auto with "5" (*‹unify_dom (Var (v::'a), M::'a trm)› ‹unify (Var (v::'a::type)) (M::'a::type trm) = Some (σ::('a::type × 'a::type trm) list)›*) have "σ = [(v, M)]" by simp with occs_elim[OF no_occs] (*‹elim [(v, M)] v ∨ [(v, M)] ≐ []›*) show "?case" (*goal: ‹(∃a∈vars_of (Var v) ∪ vars_of M. elim σ a) ∨ σ ≐ []›*) by auto next (*goals: 1. ‹⋀c d σ. ⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ⟧ ⟹ Bex (vars_of (Const c) ∪ vars_of (Const d)) (elim σ) ∨ σ ≐ []› 2. ‹⋀M N M' N' σ. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case (6 c d) (*‹unify_dom (Const c, Const d)› ‹unify (Const c) (Const d) = Some σ›*) thus "?case" (*goal: ‹(∃a::'a::type∈vars_of (Const (c::'a::type)) ∪ vars_of (Const (d::'a::type)). elim (σ::('a::type × 'a::type trm) list) a) ∨ σ ≐ []›*) apply (cases "c = d") (*goals: 1. ‹⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ; c = d⟧ ⟹ (∃a∈vars_of (Const c) ∪ vars_of (Const d). elim σ a) ∨ σ ≐ []› 2. ‹⟦unify_dom (Const c, Const d); unify (Const c) (Const d) = Some σ; c ≠ d⟧ ⟹ (∃a∈vars_of (Const c) ∪ vars_of (Const d). elim σ a) ∨ σ ≐ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹⋀M N M' N' σ. ⟦unify_dom (M ⋅ N, M' ⋅ N'); ⋀σ. unify M M' = Some σ ⟹ Bex (vars_of M ∪ vars_of M') (elim σ) ∨ σ ≐ []; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Bex (vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2)) (elim σ) ∨ σ ≐ []; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Bex (vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')) (elim σ) ∨ σ ≐ []›*) case (7 M N M' N' σ) (*‹unify_dom ((M::'a trm) ⋅ (N::'a trm), (M'::'a trm) ⋅ (N'::'a trm))› ‹unify M M' = Some ?σ ⟹ (∃a∈vars_of M ∪ vars_of M'. elim ?σ a) ∨ ?σ ≐ []› ‹⟦unify M M' = Some ?x2.0; unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ (∃a∈vars_of (N ⊲ ?x2.0) ∪ vars_of (N' ⊲ ?x2.0). elim ?σ a) ∨ ?σ ≐ []› ‹unify (M ⋅ N) (M' ⋅ N') = Some σ›*) then obtain θ1 and θ2 where "unify M M' = Some θ1" and "unify (N ⊲ θ1) (N' ⊲ θ1) = Some θ2" and "σ": "σ = θ1 ◊ θ2" and ih1: "?P M M' θ1" and ih2: "?P (N⊲θ1) (N'⊲θ1) θ2" (*goal: ‹(⋀θ1 θ2. ⟦unify M M' = Some θ1; unify (N ⊲ θ1) (N' ⊲ θ1) = Some θ2; σ = θ1 ◊ θ2; (∃v∈vars_of M ∪ vars_of M'. elim θ1 v) ∨ θ1 ≐ []; (∃v∈vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1). elim θ2 v) ∨ θ2 ≐ []⟧ ⟹ thesis) ⟹ thesis›*) by (auto split:option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) from ‹unify_dom (M ⋅ N, M' ⋅ N')› (*‹unify_dom (M ⋅ N, M' ⋅ N')›*) have "unify_dom (M, M')" apply (rule accp_downward (*‹⟦Wellfounded.accp ?r ?b; ?r ?a ?b⟧ ⟹ Wellfounded.accp ?r ?a›*)) (*goal: ‹unify_dom (M, M')›*) by (rule unify_rel.intros (*‹unify_rel (?M, ?M') (?M ⋅ ?N, ?M' ⋅ ?N')› ‹unify_sumC (?M, ?M') = Some ?x2.0 ⟹ unify_rel (?N ⊲ ?x2.0, ?N' ⊲ ?x2.0) (?M ⋅ ?N, ?M' ⋅ ?N')›*)) hence no_new_vars: "⋀t. vars_of (t ⊲ θ1) ⊆ vars_of M ∪ vars_of M' ∪ vars_of t" apply (rule unify_vars (*‹⟦unify_dom (?M, ?N); unify ?M ?N = Some ?σ⟧ ⟹ vars_of (?t ⊲ ?σ) ⊆ vars_of ?M ∪ vars_of ?N ∪ vars_of ?t›*)) (*goal: ‹⋀t::'a::type trm. vars_of (t ⊲ (θ1::('a::type × 'a::type trm) list)) ⊆ vars_of (M::'a::type trm) ∪ vars_of (M'::'a::type trm) ∪ vars_of t›*) by (rule ‹unify M M' = Some θ1›) from ih2 (*‹(∃v∈vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1). elim θ2 v) ∨ θ2 ≐ []›*) show "?case" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) proof (standard) (*goals: 1. ‹∃v∈vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1). elim θ2 v ⟹ (∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []› 2. ‹θ2 ≐ [] ⟹ (∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) assume "∃v∈vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1). elim θ2 v" (*‹∃v::'a∈vars_of ((N::'a trm) ⊲ (θ1::('a × 'a trm) list)) ∪ vars_of ((N'::'a trm) ⊲ θ1). elim (θ2::('a × 'a trm) list) v›*) then obtain v where "v∈vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1)" and el: "elim θ2 v" (*goal: ‹(⋀v. ⟦v ∈ vars_of (N ⊲ θ1) ∪ vars_of (N' ⊲ θ1); elim θ2 v⟧ ⟹ thesis) ⟹ thesis›*) by auto with no_new_vars (*‹vars_of (?t ⊲ θ1) ⊆ vars_of M ∪ vars_of M' ∪ vars_of ?t›*) show "?thesis" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) unfolding "σ" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim (θ1 ◊ θ2) a) ∨ θ1 ◊ θ2 ≐ []›*) by (auto simp:elim_def (*‹elim ?σ ?v ≡ ∀t. ?v ∉ vars_of (t ⊲ ?σ)›*)) next (*goal: ‹θ2 ≐ [] ⟹ (∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) assume empty[simp]: "θ2 ≐ []" (*‹(θ2::('a × 'a trm) list) ≐ []›*) have "σ ≐ (θ1 ◊ [])" unfolding "σ" (*goal: ‹θ1 ◊ θ2 ≐ θ1 ◊ []›*) apply (rule subst_cong (*‹⟦?σ ≐ ?σ'; ?θ ≐ ?θ'⟧ ⟹ ?σ ◊ ?θ ≐ ?σ' ◊ ?θ'›*)) (*goals: 1. ‹θ1 ≐ θ1› 2. ‹θ2 ≐ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹σ ≐ θ1 ◊ []›*) have "… ≐ θ1" by auto finally (*calculation: ‹σ ≐ θ1›*) have "σ ≐ θ1" . from ih1 (*‹(∃v∈vars_of M ∪ vars_of M'. elim θ1 v) ∨ θ1 ≐ []›*) show "?thesis" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) proof (standard) (*goals: 1. ‹∃v::'a∈vars_of (M::'a trm) ∪ vars_of (M'::'a trm). elim (θ1::('a × 'a trm) list) v ⟹ (∃a::'a∈vars_of (M ⋅ (N::'a trm)) ∪ vars_of (M' ⋅ (N'::'a trm)). elim (σ::('a × 'a trm) list) a) ∨ σ ≐ []› 2. ‹(θ1::('a × 'a trm) list) ≐ [] ⟹ (∃a::'a∈vars_of ((M::'a trm) ⋅ (N::'a trm)) ∪ vars_of ((M'::'a trm) ⋅ (N'::'a trm)). elim (σ::('a × 'a trm) list) a) ∨ σ ≐ []›*) assume "∃v∈vars_of M ∪ vars_of M'. elim θ1 v" (*‹∃v::'a∈vars_of (M::'a trm) ∪ vars_of (M'::'a trm). elim (θ1::('a × 'a trm) list) v›*) with elim_eq[OF ‹σ ≐ θ1›] (*‹elim σ ?x = elim θ1 ?x›*) show "?thesis" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) by auto next (*goal: ‹(θ1::('a × 'a trm) list) ≐ [] ⟹ (∃a::'a∈vars_of ((M::'a trm) ⋅ (N::'a trm)) ∪ vars_of ((M'::'a trm) ⋅ (N'::'a trm)). elim (σ::('a × 'a trm) list) a) ∨ σ ≐ []›*) note ‹σ ≐ θ1› (*‹σ ≐ θ1›*) also (*calculation: ‹σ ≐ θ1›*) assume "θ1 ≐ []" (*‹(θ1::('a × 'a trm) list) ≐ []›*) finally (*calculation: ‹σ ≐ []›*) show "?thesis" (*goal: ‹(∃a∈vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N'). elim σ a) ∨ σ ≐ []›*) by standard qed qed qed declare unify.psimps[simp del] subsection ‹Termination proof› termination unify proof let ?R = "measures [λ(M,N). card (vars_of M ∪ vars_of N), λ(M, N). size M]" show "wf ?R" by simp fix M N M' N' :: "'a trm" show "((M, M'), (M ⋅ N, M' ⋅ N')) ∈ ?R" ― ‹Inner call› by (rule measures_lesseq) (auto intro: card_mono) fix θ ― ‹Outer call› assume inner: "unify_dom (M, M')" "unify M M' = Some θ" from unify_eliminates[OF inner] show "((N ⊲ θ, N' ⊲ θ), (M ⋅ N, M' ⋅ N')) ∈?R" proof ― ‹Either a variable is eliminated \ldots› assume "(∃v∈vars_of M ∪ vars_of M'. elim θ v)" then obtain v where "elim θ v" and "v∈vars_of M ∪ vars_of M'" by auto with unify_vars[OF inner] have "vars_of (N⊲θ) ∪ vars_of (N'⊲θ) ⊂ vars_of (M⋅N) ∪ vars_of (M'⋅N')" by auto thus ?thesis by (auto intro!: measures_less intro: psubset_card_mono) next ― ‹Or the substitution is empty› assume "θ ≐ []" hence "N ⊲ θ = N" and "N' ⊲ θ = N'" by auto thus ?thesis by (auto intro!: measures_less intro: psubset_card_mono) qed qed subsection ‹Unification returns a Most General Unifier› lemma unify_computes_MGU: "unify M N = Some σ ⟹ MGU σ M N" proof (induct M N arbitrary: σ rule: unify.induct) (*goals: 1. ‹⋀c M N σ. unify (Const c) (M ⋅ N) = Some σ ⟹ MGU σ (Const c) (M ⋅ N)› 2. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ MGU σ (M ⋅ N) (Const c)› 3. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ MGU σ (Const c) (Var v)› 4. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ MGU σ (M ⋅ N) (Var v)› 5. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ MGU σ (Var v) M› 6. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ MGU σ (Const c) (Const d)› 7. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ MGU σ M M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ MGU σ (N ⊲ x2) (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ MGU σ (M ⋅ N) (M' ⋅ N')›*) case (7 M N M' N' σ) (*‹unify M M' = Some ?σ ⟹ MGU ?σ M M'› ‹⟦unify M M' = Some ?x2.0; unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ MGU ?σ (N ⊲ ?x2.0) (N' ⊲ ?x2.0)› ‹unify (M ⋅ N) (M' ⋅ N') = Some σ›*) then obtain θ1 and θ2 where "unify M M' = Some θ1" and "unify (N ⊲ θ1) (N' ⊲ θ1) = Some θ2" and "σ": "σ = θ1 ◊ θ2" and MGU_inner: "MGU θ1 M M'" and MGU_outer: "MGU θ2 (N ⊲ θ1) (N' ⊲ θ1)" (*goal: ‹(⋀θ1 θ2. ⟦unify M M' = Some θ1; unify (N ⊲ θ1) (N' ⊲ θ1) = Some θ2; σ = θ1 ◊ θ2; MGU θ1 M M'; MGU θ2 (N ⊲ θ1) (N' ⊲ θ1)⟧ ⟹ thesis) ⟹ thesis›*) by (auto split:option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) show "?case" (*goal: ‹MGU (σ::('a × 'a trm) list) ((M::'a trm) ⋅ (N::'a trm)) ((M'::'a trm) ⋅ (N'::'a trm))›*) proof (standard) (*goals: 1. ‹M ⋅ N ⊲ σ = M' ⋅ N' ⊲ σ› 2. ‹⋀θ. M ⋅ N ⊲ θ = M' ⋅ N' ⊲ θ ⟹ ∃γ. θ ≐ σ ◊ γ›*) from MGU_inner (*‹MGU θ1 M M'›*) MGU_outer (*‹MGU θ2 (N ⊲ θ1) (N' ⊲ θ1)›*) have "M ⊲ θ1 = M' ⊲ θ1" and "N ⊲ θ1 ⊲ θ2 = N' ⊲ θ1 ⊲ θ2" unfolding MGU_def Unifier_def (*goals: 1. ‹M ⊲ θ1 = M' ⊲ θ1› 2. ‹N ⊲ θ1 ⊲ θ2 = N' ⊲ θ1 ⊲ θ2›*) apply - (*goals: 1. ‹⟦(M::'a::type trm) ⊲ (θ1::('a::type × 'a::type trm) list) = (M'::'a::type trm) ⊲ θ1 ∧ (∀θ::('a::type × 'a::type trm) list. M ⊲ θ = M' ⊲ θ ⟶ (∃γ::('a::type × 'a::type trm) list. θ ≐ θ1 ◊ γ)); (N::'a::type trm) ⊲ θ1 ⊲ (θ2::('a::type × 'a::type trm) list) = (N'::'a::type trm) ⊲ θ1 ⊲ θ2 ∧ (∀θ::('a::type × 'a::type trm) list. N ⊲ θ1 ⊲ θ = N' ⊲ θ1 ⊲ θ ⟶ (∃γ::('a::type × 'a::type trm) list. θ ≐ θ2 ◊ γ))⟧ ⟹ M ⊲ θ1 = M' ⊲ θ1› 2. ‹⟦(M::'a::type trm) ⊲ (θ1::('a::type × 'a::type trm) list) = (M'::'a::type trm) ⊲ θ1 ∧ (∀θ::('a::type × 'a::type trm) list. M ⊲ θ = M' ⊲ θ ⟶ (∃γ::('a::type × 'a::type trm) list. θ ≐ θ1 ◊ γ)); (N::'a::type trm) ⊲ θ1 ⊲ (θ2::('a::type × 'a::type trm) list) = (N'::'a::type trm) ⊲ θ1 ⊲ θ2 ∧ (∀θ::('a::type × 'a::type trm) list. N ⊲ θ1 ⊲ θ = N' ⊲ θ1 ⊲ θ ⟶ (∃γ::('a::type × 'a::type trm) list. θ ≐ θ2 ◊ γ))⟧ ⟹ N ⊲ θ1 ⊲ θ2 = N' ⊲ θ1 ⊲ θ2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "M ⋅ N ⊲ σ = M' ⋅ N' ⊲ σ" unfolding "σ" (*goal: ‹M ⋅ N ⊲ θ1 ◊ θ2 = M' ⋅ N' ⊲ θ1 ◊ θ2›*) by simp next (*goal: ‹⋀θ::('a::type × 'a::type trm) list. (M::'a::type trm) ⋅ (N::'a::type trm) ⊲ θ = (M'::'a::type trm) ⋅ (N'::'a::type trm) ⊲ θ ⟹ ∃γ::('a::type × 'a::type trm) list. θ ≐ (σ::('a::type × 'a::type trm) list) ◊ γ›*) fix σ' assume "M ⋅ N ⊲ σ' = M' ⋅ N' ⊲ σ'" (*‹(M::'a trm) ⋅ (N::'a trm) ⊲ (σ'::('a × 'a trm) list) = (M'::'a trm) ⋅ (N'::'a trm) ⊲ σ'›*) hence "M ⊲ σ' = M' ⊲ σ'" and Ns: "N ⊲ σ' = N' ⊲ σ'" apply - (*goals: 1. ‹M ⋅ N ⊲ σ' = M' ⋅ N' ⊲ σ' ⟹ M ⊲ σ' = M' ⊲ σ'› 2. ‹M ⋅ N ⊲ σ' = M' ⋅ N' ⊲ σ' ⟹ N ⊲ σ' = N' ⊲ σ'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with MGU_inner (*‹MGU θ1 M M'›*) obtain δ where eqv: "σ' ≐ θ1 ◊ δ" (*goal: ‹(⋀δ. σ' ≐ θ1 ◊ δ ⟹ thesis) ⟹ thesis›*) unfolding MGU_def Unifier_def (*goal: ‹(⋀δ. σ' ≐ θ1 ◊ δ ⟹ thesis) ⟹ thesis›*) by auto from Ns (*‹N ⊲ σ' = N' ⊲ σ'›*) have "N ⊲ θ1 ⊲ δ = N' ⊲ θ1 ⊲ δ" by (simp add:subst_eq_dest[OF eqv] (*‹?t ⊲ σ' = ?t ⊲ θ1 ◊ δ›*)) with MGU_outer (*‹MGU θ2 (N ⊲ θ1) (N' ⊲ θ1)›*) obtain ρ where eqv2: "δ ≐ θ2 ◊ ρ" (*goal: ‹(⋀ρ. δ ≐ θ2 ◊ ρ ⟹ thesis) ⟹ thesis›*) unfolding MGU_def Unifier_def (*goal: ‹(⋀ρ. δ ≐ θ2 ◊ ρ ⟹ thesis) ⟹ thesis›*) by auto have "σ' ≐ σ ◊ ρ" unfolding "σ" (*goal: ‹(σ'::('a × 'a trm) list) ≐ (θ1::('a × 'a trm) list) ◊ (θ2::('a × 'a trm) list) ◊ (ρ::('a × 'a trm) list)›*) apply (rule subst_eq_intro (*‹(⋀t. t ⊲ ?σ = t ⊲ ?θ) ⟹ ?σ ≐ ?θ›*)) (*goal: ‹σ' ≐ θ1 ◊ θ2 ◊ ρ›*) by (auto simp:subst_eq_dest[OF eqv] (*‹?t ⊲ σ' = ?t ⊲ θ1 ◊ δ›*) subst_eq_dest[OF eqv2] (*‹?t ⊲ δ = ?t ⊲ θ2 ◊ ρ›*)) thus "∃γ. σ' ≐ σ ◊ γ" by standard qed qed (auto simp: MGU_Const (*‹MGU [] (Const ?c) (Const ?d) = (?c = ?d)›*) intro: MGU_Var (*‹¬ Var ?v ≺ ?t ⟹ MGU [(?v, ?t)] (Var ?v) ?t›*) MGU_Var[symmetric] (*‹¬ Var ?v ≺ ?t ⟹ MGU [(?v, ?t)] ?t (Var ?v)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*solves the remaining goals: 1. ‹⋀c M N σ. unify (Const c) (M ⋅ N) = Some σ ⟹ MGU σ (Const c) (M ⋅ N)› 2. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ MGU σ (M ⋅ N) (Const c)› 3. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ MGU σ (Const c) (Var v)› 4. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ MGU σ (M ⋅ N) (Var v)› 5. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ MGU σ (Var v) M› 6. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ MGU σ (Const c) (Const d)›*) subsection ‹Unification returns Idempotent Substitution› definition Idem :: "'a subst ⇒ bool" where "Idem s ⟷ (s ◊ s) ≐ s" lemma Idem_Nil [iff]: "Idem []" by (simp add: Idem_def (*‹Idem ?s = ?s ◊ ?s ≐ ?s›*)) lemma Var_Idem: assumes "~ (Var v ≺ t)" shows "Idem [(v,t)]" unfolding Idem_def (*goal: ‹[(v, t)] ◊ [(v, t)] ≐ [(v, t)]›*) proof (standard) (*goal: ‹⋀ta. ta ⊲ [(v, t)] ◊ [(v, t)] = ta ⊲ [(v, t)]›*) from assms (*‹¬ Var v ≺ t›*) have [simp]: "t ⊲ [(v, t)] = t" by (metis assoc.simps( (*‹assoc ?x ?d ((?p, ?q) # ?t) = (if ?x = ?p then ?q else assoc ?x ?d ?t)›*) 2) subst.simps( (*‹Var ?v ⊲ ?s = assoc ?v (Var ?v) ?s›*) 1) subst_no_occs (*‹⟦¬ Var ?v ≺ ?t; Var ?v ≠ ?t⟧ ⟹ ?t ⊲ [(?v, ?s)] = ?t›*)) fix s show "s ⊲ [(v, t)] ◊ [(v, t)] = s ⊲ [(v, t)]" apply (induct s) (*goals: 1. ‹⋀x. Var x ⊲ [(v, t)] ◊ [(v, t)] = Var x ⊲ [(v, t)]› 2. ‹⋀x. Const x ⊲ [(v, t)] ◊ [(v, t)] = Const x ⊲ [(v, t)]› 3. ‹⋀s1 s2. ⟦s1 ⊲ [(v, t)] ◊ [(v, t)] = s1 ⊲ [(v, t)]; s2 ⊲ [(v, t)] ◊ [(v, t)] = s2 ⊲ [(v, t)]⟧ ⟹ s1 ⋅ s2 ⊲ [(v, t)] ◊ [(v, t)] = s1 ⋅ s2 ⊲ [(v, t)]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed lemma Unifier_Idem_subst: "Idem(r) ⟹ Unifier s (t ⊲ r) (u ⊲ r) ⟹ Unifier (r ◊ s) (t ⊲ r) (u ⊲ r)" by (simp add: Idem_def (*‹Idem ?s = ?s ◊ ?s ≐ ?s›*) Unifier_def (*‹Unifier ?σ ?t ?u = (?t ⊲ ?σ = ?u ⊲ ?σ)›*) subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) lemma Idem_comp: "Idem r ⟹ Unifier s (t ⊲ r) (u ⊲ r) ⟹ (!!q. Unifier q (t ⊲ r) (u ⊲ r) ⟹ s ◊ q ≐ q) ⟹ Idem (r ◊ s)" apply (frule Unifier_Idem_subst (*‹⟦Idem ?r; Unifier ?s (?t ⊲ ?r) (?u ⊲ ?r)⟧ ⟹ Unifier (?r ◊ ?s) (?t ⊲ ?r) (?u ⊲ ?r)›*)) (*goals: 1. ‹⟦Idem r; Unifier s (t ⊲ r) (u ⊲ r); ⋀q. Unifier q (t ⊲ r) (u ⊲ r) ⟹ s ◊ q ≐ q⟧ ⟹ Unifier ?s (?t ⊲ r) (?u ⊲ r)› 2. ‹⟦Idem r; Unifier s (t ⊲ r) (u ⊲ r); ⋀q. Unifier q (t ⊲ r) (u ⊲ r) ⟹ s ◊ q ≐ q; Unifier (r ◊ ?s) (?t ⊲ r) (?u ⊲ r)⟧ ⟹ Idem (r ◊ s)› discuss goal 1*) apply blast (*discuss goal 2*) apply (force simp add: Idem_def (*‹Idem ?s = ?s ◊ ?s ≐ ?s›*) subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*)) (*proven 2 subgoals*) . theorem unify_gives_Idem: "unify M N = Some σ ⟹ Idem σ" proof (induct M N arbitrary: σ rule: unify.induct) (*goals: 1. ‹⋀c M N σ. unify (Const c) (M ⋅ N) = Some σ ⟹ Idem σ› 2. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ Idem σ› 3. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ Idem σ› 4. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ Idem σ› 5. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ Idem σ› 6. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ Idem σ› 7. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ Idem σ; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ Idem σ; unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ Idem σ›*) case (7 M M' N N' σ) (*‹unify M N = Some ?σ ⟹ Idem ?σ› ‹⟦unify M N = Some ?x2.0; unify (M' ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ Idem ?σ› ‹unify (M ⋅ M') (N ⋅ N') = Some σ›*) then obtain θ1 and θ2 where "unify M N = Some θ1" and "θ2": "unify (M' ⊲ θ1) (N' ⊲ θ1) = Some θ2" and "σ": "σ = θ1 ◊ θ2" and "Idem θ1" and "Idem θ2" (*goal: ‹(⋀θ1 θ2. ⟦unify M N = Some θ1; unify (M' ⊲ θ1) (N' ⊲ θ1) = Some θ2; σ = θ1 ◊ θ2; Idem θ1; Idem θ2⟧ ⟹ thesis) ⟹ thesis›*) by (auto split: option.split_asm (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) from "θ2" (*‹unify (M' ⊲ θ1) (N' ⊲ θ1) = Some θ2›*) have "Unifier θ2 (M' ⊲ θ1) (N' ⊲ θ1)" by (rule unify_computes_MGU[THEN MGU_is_Unifier] (*‹unify (?t::?'a trm) (?u::?'a trm) = Some (?σ::(?'a × ?'a trm) list) ⟹ Unifier ?σ ?t ?u›*)) with ‹Idem θ1› (*‹Idem θ1›*) show "Idem σ" unfolding "σ" (*goal: ‹Idem (θ1 ◊ θ2)›*) proof (rule Idem_comp (*‹⟦Idem ?r; Unifier ?s (?t ⊲ ?r) (?u ⊲ ?r); ⋀q. Unifier q (?t ⊲ ?r) (?u ⊲ ?r) ⟹ ?s ◊ q ≐ q⟧ ⟹ Idem (?r ◊ ?s)›*)) (*goal: ‹⋀q. Unifier q (M' ⊲ θ1) (N' ⊲ θ1) ⟹ θ2 ◊ q ≐ q›*) fix σ assume "Unifier σ (M' ⊲ θ1) (N' ⊲ θ1)" (*‹Unifier (σ::('a × 'a trm) list) ((M'::'a trm) ⊲ (θ1::('a × 'a trm) list)) ((N'::'a trm) ⊲ θ1)›*) with "θ2" (*‹unify (M' ⊲ θ1) (N' ⊲ θ1) = Some θ2›*) obtain γ where "σ": "σ ≐ θ2 ◊ γ" (*goal: ‹(⋀γ::('a × 'a trm) list. (σ::('a × 'a trm) list) ≐ (θ2::('a × 'a trm) list) ◊ γ ⟹ thesis::bool) ⟹ thesis›*) using unify_computes_MGU (*‹unify ?M ?N = Some ?σ ⟹ MGU ?σ ?M ?N›*) MGU_def (*‹MGU ?σ ?t ?u = (Unifier ?σ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ (∃γ. θ ≐ ?σ ◊ γ)))›*) by blast have "θ2 ◊ σ ≐ θ2 ◊ (θ2 ◊ γ)" apply (rule subst_cong (*‹⟦?σ ≐ ?σ'; ?θ ≐ ?θ'⟧ ⟹ ?σ ◊ ?θ ≐ ?σ' ◊ ?θ'›*)) (*goals: 1. ‹θ2 ≐ θ2› 2. ‹σ ≐ θ2 ◊ γ› discuss goal 1*) apply ((auto simp: σ (*‹σ ≐ θ2 ◊ γ›*))[1]) (*discuss goal 2*) apply ((auto simp: σ (*‹σ ≐ θ2 ◊ γ›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹θ2 ◊ σ ≐ θ2 ◊ (θ2 ◊ γ)›*) have "... ≐ (θ2 ◊ θ2) ◊ γ" by (rule comp_assoc[symmetric] (*‹(?a::(?'a × ?'a trm) list) ◊ ((?b::(?'a × ?'a trm) list) ◊ (?c::(?'a × ?'a trm) list)) ≐ ?a ◊ ?b ◊ ?c›*)) also (*calculation: ‹θ2 ◊ σ ≐ θ2 ◊ θ2 ◊ γ›*) have "... ≐ θ2 ◊ γ" apply (rule subst_cong (*‹⟦?σ ≐ ?σ'; ?θ ≐ ?θ'⟧ ⟹ ?σ ◊ ?θ ≐ ?σ' ◊ ?θ'›*)) (*goals: 1. ‹(θ2::('a::type × 'a::type trm) list) ◊ θ2 ≐ θ2› 2. ‹(γ::('a::type × 'a::type trm) list) ≐ γ› discuss goal 1*) apply ((auto simp: ‹Idem θ2›[unfolded Idem_def])[1]) (*discuss goal 2*) apply ((auto simp: ‹Idem θ2›[unfolded Idem_def])[1]) (*proven 2 subgoals*) . also (*calculation: ‹θ2 ◊ σ ≐ θ2 ◊ γ›*) have "... ≐ σ" by (rule σ[symmetric] (*‹θ2 ◊ γ ≐ σ›*)) finally (*calculation: ‹θ2 ◊ σ ≐ σ›*) show "θ2 ◊ σ ≐ σ" . qed qed (auto intro!: Var_Idem (*‹¬ Var ?v ≺ ?t ⟹ Idem [(?v, ?t)]›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*solves the remaining goals: 1. ‹⋀c M N σ. unify (Const c) (M ⋅ N) = Some σ ⟹ Idem σ› 2. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ Idem σ› 3. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ Idem σ› 4. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ Idem σ› 5. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ Idem σ› 6. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ Idem σ›*) subsection ‹Unification Returns Substitution With Minimal Domain And Range› definition range_vars where "range_vars σ = ⋃ {vars_of (Var x ⊲ σ) |x. Var x ⊲ σ ≠ Var x}" lemma vars_of_subst_subset: "vars_of (N ⊲ σ) ⊆ vars_of N ∪ range_vars σ" proof (rule subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. x ∈ vars_of (N ⊲ σ) ⟹ x ∈ vars_of N ∪ range_vars σ›*) fix x assume "x ∈ vars_of (N ⊲ σ)" (*‹(x::'a) ∈ vars_of ((N::'a trm) ⊲ (σ::('a × 'a trm) list))›*) thus "x ∈ vars_of N ∪ range_vars σ" proof (induction N) (*goals: 1. ‹⋀xa::'a. (x::'a) ∈ vars_of (Var xa ⊲ (σ::('a × 'a trm) list)) ⟹ x ∈ vars_of (Var xa) ∪ range_vars σ› 2. ‹⋀xa::'a. (x::'a) ∈ vars_of (Const xa ⊲ (σ::('a × 'a trm) list)) ⟹ x ∈ vars_of (Const xa) ∪ range_vars σ› 3. ‹⋀(N1::'a trm) N2::'a trm. ⟦(x::'a) ∈ vars_of (N1 ⊲ (σ::('a × 'a trm) list)) ⟹ x ∈ vars_of N1 ∪ range_vars σ; x ∈ vars_of (N2 ⊲ σ) ⟹ x ∈ vars_of N2 ∪ range_vars σ; x ∈ vars_of (N1 ⋅ N2 ⊲ σ)⟧ ⟹ x ∈ vars_of (N1 ⋅ N2) ∪ range_vars σ›*) case (Var y) (*‹x ∈ vars_of (Var y ⊲ σ)›*) thus "?case" (*goal: ‹(x::'a) ∈ vars_of (Var (y::'a)) ∪ range_vars (σ::('a × 'a trm) list)›*) unfolding range_vars_def vars_of.simps (*goal: ‹x ∈ {y} ∪ ⋃ {vars_of (Var x ⊲ σ) |x. Var x ⊲ σ ≠ Var x}›*) by force next (*goals: 1. ‹⋀xa. x ∈ vars_of (Const xa ⊲ σ) ⟹ x ∈ vars_of (Const xa) ∪ range_vars σ› 2. ‹⋀N1 N2. ⟦x ∈ vars_of (N1 ⊲ σ) ⟹ x ∈ vars_of N1 ∪ range_vars σ; x ∈ vars_of (N2 ⊲ σ) ⟹ x ∈ vars_of N2 ∪ range_vars σ; x ∈ vars_of (N1 ⋅ N2 ⊲ σ)⟧ ⟹ x ∈ vars_of (N1 ⋅ N2) ∪ range_vars σ›*) case (Const y) (*‹x ∈ vars_of (Const y ⊲ σ)›*) thus "?case" (*goal: ‹(x::'a) ∈ vars_of (Const (y::'a)) ∪ range_vars (σ::('a × 'a trm) list)›*) by simp next (*goal: ‹⋀(N1::'a trm) N2::'a trm. ⟦(x::'a) ∈ vars_of (N1 ⊲ (σ::('a × 'a trm) list)) ⟹ x ∈ vars_of N1 ∪ range_vars σ; x ∈ vars_of (N2 ⊲ σ) ⟹ x ∈ vars_of N2 ∪ range_vars σ; x ∈ vars_of (N1 ⋅ N2 ⊲ σ)⟧ ⟹ x ∈ vars_of (N1 ⋅ N2) ∪ range_vars σ›*) case (Comb N1 N2) (*‹(x::'a) ∈ vars_of ((N1::'a trm) ⊲ (σ::('a × 'a trm) list)) ⟹ x ∈ vars_of N1 ∪ range_vars σ› ‹x ∈ vars_of (N2 ⊲ σ) ⟹ x ∈ vars_of N2 ∪ range_vars σ› ‹x ∈ vars_of (N1 ⋅ N2 ⊲ σ)›*) thus "?case" (*goal: ‹(x::'a) ∈ vars_of ((N1::'a trm) ⋅ (N2::'a trm)) ∪ range_vars (σ::('a × 'a trm) list)›*) by auto qed qed lemma range_vars_comp_subset: "range_vars (σ₁ ◊ σ₂) ⊆ range_vars σ₁ ∪ range_vars σ₂" proof (rule subsetI (*‹(⋀x::?'a::type. x ∈ (?A::?'a::type set) ⟹ x ∈ (?B::?'a::type set)) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. x ∈ range_vars (σ₁ ◊ σ₂) ⟹ x ∈ range_vars σ₁ ∪ range_vars σ₂›*) fix x assume "x ∈ range_vars (σ₁ ◊ σ₂)" (*‹(x::'a) ∈ range_vars ((σ₁::('a × 'a trm) list) ◊ (σ₂::('a × 'a trm) list))›*) then obtain x' where "x'_σ₁_σ₂": "Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x'" and x_in: "x ∈ vars_of (Var x' ⊲ σ₁ ⊲ σ₂)" (*goal: ‹(⋀x'. ⟦Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x'; x ∈ vars_of (Var x' ⊲ σ₁ ⊲ σ₂)⟧ ⟹ thesis) ⟹ thesis›*) unfolding range_vars_def (*goal: ‹(⋀x'. ⟦Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x'; x ∈ vars_of (Var x' ⊲ σ₁ ⊲ σ₂)⟧ ⟹ thesis) ⟹ thesis›*) by auto show "x ∈ range_vars σ₁ ∪ range_vars σ₂" proof (cases "Var x' ⊲ σ₁ = Var x'") (*goals: 1. ‹Var x' ⊲ σ₁ = Var x' ⟹ x ∈ range_vars σ₁ ∪ range_vars σ₂› 2. ‹Var x' ⊲ σ₁ ≠ Var x' ⟹ x ∈ range_vars σ₁ ∪ range_vars σ₂›*) case True (*‹Var x' ⊲ σ₁ = Var x'›*) with "x'_σ₁_σ₂" (*‹Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x'›*) x_in (*‹x ∈ vars_of (Var x' ⊲ σ₁ ⊲ σ₂)›*) show "?thesis" (*goal: ‹x ∈ range_vars σ₁ ∪ range_vars σ₂›*) unfolding range_vars_def (*goal: ‹(x::'a) ∈ ⋃ {vars_of (Var x ⊲ (σ₁::('a × 'a trm) list)) |x::'a. Var x ⊲ σ₁ ≠ Var x} ∪ ⋃ {vars_of (Var x ⊲ (σ₂::('a × 'a trm) list)) |x::'a. Var x ⊲ σ₂ ≠ Var x}›*) by auto next (*goal: ‹Var (x'::'a::type) ⊲ (σ₁::('a::type × 'a::type trm) list) ≠ Var x' ⟹ (x::'a::type) ∈ range_vars σ₁ ∪ range_vars (σ₂::('a::type × 'a::type trm) list)›*) case "x'_σ₁_neq": False (*‹Var x' ⊲ σ₁ ≠ Var x'›*) show "?thesis" (*goal: ‹x ∈ range_vars σ₁ ∪ range_vars σ₂›*) proof (cases "Var x' ⊲ σ₁ ⊲ σ₂ = Var x' ⊲ σ₁") (*goals: 1. ‹Var x' ⊲ σ₁ ⊲ σ₂ = Var x' ⊲ σ₁ ⟹ x ∈ range_vars σ₁ ∪ range_vars σ₂› 2. ‹Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x' ⊲ σ₁ ⟹ x ∈ range_vars σ₁ ∪ range_vars σ₂›*) case True (*‹Var (x'::'a) ⊲ (σ₁::('a × 'a trm) list) ⊲ (σ₂::('a × 'a trm) list) = Var x' ⊲ σ₁›*) with "x'_σ₁_σ₂" (*‹Var (x'::'a) ⊲ (σ₁::('a × 'a trm) list) ⊲ (σ₂::('a × 'a trm) list) ≠ Var x'›*) x_in (*‹x ∈ vars_of (Var x' ⊲ σ₁ ⊲ σ₂)›*) "x'_σ₁_neq" (*‹Var x' ⊲ σ₁ ≠ Var x'›*) show "?thesis" (*goal: ‹x ∈ range_vars σ₁ ∪ range_vars σ₂›*) unfolding range_vars_def (*goal: ‹x ∈ ⋃ {vars_of (Var x ⊲ σ₁) |x. Var x ⊲ σ₁ ≠ Var x} ∪ ⋃ {vars_of (Var x ⊲ σ₂) |x. Var x ⊲ σ₂ ≠ Var x}›*) by auto next (*goal: ‹Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x' ⊲ σ₁ ⟹ x ∈ range_vars σ₁ ∪ range_vars σ₂›*) case False (*‹Var x' ⊲ σ₁ ⊲ σ₂ ≠ Var x' ⊲ σ₁›*) with x_in (*‹(x::'a) ∈ vars_of (Var (x'::'a) ⊲ (σ₁::('a × 'a trm) list) ⊲ (σ₂::('a × 'a trm) list))›*) obtain y where "y ∈ vars_of (Var x' ⊲ σ₁)" and "x ∈ vars_of (Var y ⊲ σ₂)" (*goal: ‹(⋀y. ⟦y ∈ vars_of (Var x' ⊲ σ₁); x ∈ vars_of (Var y ⊲ σ₂)⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) UN_E (*‹⟦?b ∈ ⋃ (?B ` ?A); ⋀x. ⟦x ∈ ?A; ?b ∈ ?B x⟧ ⟹ ?R⟧ ⟹ ?R›*) UN_simps( (*‹⋃ (?B ` ?f ` ?A) = (⋃a∈?A. ?B (?f a))›*) 10) vars_of_subst_conv_Union (*‹vars_of (?t ⊲ ?η) = ⋃ (vars_of ` (λx. Var x ⊲ ?η) ` vars_of ?t)›*)) with "x'_σ₁_neq" (*‹Var x' ⊲ σ₁ ≠ Var x'›*) show "?thesis" (*goal: ‹x ∈ range_vars σ₁ ∪ range_vars σ₂›*) unfolding range_vars_def (*goal: ‹x ∈ ⋃ {vars_of (Var x ⊲ σ₁) |x. Var x ⊲ σ₁ ≠ Var x} ∪ ⋃ {vars_of (Var x ⊲ σ₂) |x. Var x ⊲ σ₂ ≠ Var x}›*) by force qed qed qed theorem unify_gives_minimal_range: "unify M N = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of N" proof (induct M N arbitrary: σ rule: unify.induct) (*goals: 1. ‹⋀c M N σ. unify (Const c) (M ⋅ N) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N)› 2. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c)› 3. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Var v)› 4. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 5. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ range_vars σ ⊆ vars_of (Var v) ∪ vars_of M› 6. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 7. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (1 c M N) (*‹unify (Const (c::'a)) ((M::'a trm) ⋅ (N::'a trm)) = Some (σ::('a × 'a trm) list)›*) thus "?case" (*goal: ‹range_vars σ ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N)›*) by simp next (*goals: 1. ‹⋀(M::'a::type trm) (N::'a::type trm) (c::'a::type) σ::('a::type × 'a::type trm) list. unify (M ⋅ N) (Const c) = Some σ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c)› 2. ‹⋀(c::'a::type) (v::'a::type) σ::('a::type × 'a::type trm) list. unify (Const c) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Var v)› 3. ‹⋀(M::'a::type trm) (N::'a::type trm) (v::'a::type) σ::('a::type × 'a::type trm) list. unify (M ⋅ N) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 4. ‹⋀(v::'a::type) (M::'a::type trm) σ::('a::type × 'a::type trm) list. unify (Var v) M = Some σ ⟹ range_vars σ ⊆ vars_of (Var v) ∪ vars_of M› 5. ‹⋀(c::'a::type) (d::'a::type) σ::('a::type × 'a::type trm) list. unify (Const c) (Const d) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 6. ‹⋀(M::'a::type trm) (N::'a::type trm) (M'::'a::type trm) (N'::'a::type trm) σ::('a::type × 'a::type trm) list. ⟦⋀σ::('a::type × 'a::type trm) list. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀(x2::('a::type × 'a::type trm) list) σ::('a::type × 'a::type trm) list. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (2 M N c) (*‹unify (M ⋅ N) (Const c) = Some σ›*) thus "?case" (*goal: ‹range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c)›*) by simp next (*goals: 1. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Var v)› 2. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 3. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ range_vars σ ⊆ vars_of (Var v) ∪ vars_of M› 4. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 5. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (3 c v) (*‹unify (Const c) (Var v) = Some σ›*) hence "σ = [(v, Const c)]" by simp thus "?case" (*goal: ‹range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Var v)›*) by (simp add: range_vars_def (*‹range_vars ?σ = ⋃ {vars_of (Var x ⊲ ?σ) |x. Var x ⊲ ?σ ≠ Var x}›*)) next (*goals: 1. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 2. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ range_vars σ ⊆ vars_of (Var v) ∪ vars_of M› 3. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 4. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (4 M N v) (*‹unify (M ⋅ N) (Var v) = Some σ›*) hence "σ = [(v, M ⋅ N)]" by (metis option.discI (*‹?option = Some ?x2.0 ⟹ ?option ≠ None›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*) unify.simps( (*‹unify (?M ⋅ ?N) (Var ?v) = (if Var ?v ≺ ?M ⋅ ?N then None else Some [(?v, ?M ⋅ ?N)])›*) 4)) thus "?case" (*goal: ‹range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)›*) by (auto simp: range_vars_def (*‹range_vars ?σ = ⋃ {vars_of (Var x ⊲ ?σ) |x. Var x ⊲ ?σ ≠ Var x}›*)) next (*goals: 1. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ range_vars σ ⊆ vars_of (Var v) ∪ vars_of M› 2. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 3. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (5 v M) (*‹unify (Var (v::'a)) (M::'a trm) = Some (σ::('a × 'a trm) list)›*) hence "σ = [(v, M)]" by (metis option.discI (*‹?option = Some ?x2.0 ⟹ ?option ≠ None›*) option.inject (*‹(Some ?x2.0 = Some ?y2.0) = (?x2.0 = ?y2.0)›*) unify.simps( (*‹unify (Var ?v) ?M = (if Var ?v ≺ ?M then None else Some [(?v, ?M)])›*) 5)) thus "?case" (*goal: ‹range_vars σ ⊆ vars_of (Var v) ∪ vars_of M›*) by (auto simp: range_vars_def (*‹range_vars ?σ = ⋃ {vars_of (Var x ⊲ ?σ) |x. Var x ⊲ ?σ ≠ Var x}›*)) next (*goals: 1. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 2. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (6 c d) (*‹unify (Const c) (Const d) = Some σ›*) hence "σ = []" by (metis option.distinct( (*‹None ≠ Some ?x2.0›*) 1) option.sel (*‹the (Some ?x2.0) = ?x2.0›*) unify.simps( (*‹unify (Const ?c) (Const ?d) = (if ?c = ?d then Some [] else None)›*) 6)) thus "?case" (*goal: ‹range_vars σ ⊆ vars_of (Const c) ∪ vars_of (Const d)›*) by (simp add: range_vars_def (*‹range_vars ?σ = ⋃ {vars_of (Var x ⊲ ?σ) |x. Var x ⊲ ?σ ≠ Var x}›*)) next (*goal: ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ range_vars σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (7 M N M' N') (*‹unify M M' = Some ?σ ⟹ range_vars ?σ ⊆ vars_of M ∪ vars_of M'› ‹⟦unify (M::'a trm) (M'::'a trm) = Some (?x2.0::('a × 'a trm) list); unify ((N::'a trm) ⊲ ?x2.0) ((N'::'a trm) ⊲ ?x2.0) = Some (?σ::('a × 'a trm) list)⟧ ⟹ range_vars ?σ ⊆ vars_of (N ⊲ ?x2.0) ∪ vars_of (N' ⊲ ?x2.0)› ‹unify (M ⋅ N) (M' ⋅ N') = Some σ›*) from "7.prems" (*‹unify (M ⋅ N) (M' ⋅ N') = Some σ›*) obtain θ₁ and θ₂ where "unify M M' = Some θ₁" and "unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂" and "σ = θ₁ ◊ θ₂" (*goal: ‹(⋀θ₁ θ₂. ⟦unify M M' = Some θ₁; unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂; σ = θ₁ ◊ θ₂⟧ ⟹ thesis) ⟹ thesis›*) apply simp (*goal: ‹(⋀(θ₁::('a × 'a trm) list) θ₂::('a × 'a trm) list. ⟦unify (M::'a trm) (M'::'a trm) = Some θ₁; unify ((N::'a trm) ⊲ θ₁) ((N'::'a trm) ⊲ θ₁) = Some θ₂; (σ::('a × 'a trm) list) = θ₁ ◊ θ₂⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis (no_types, lifting) option.case_eq_if (*‹(case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (if ?option = None then ?f1.0 else ?f2.0 (the ?option))›*) option.collapse (*‹?option ≠ None ⟹ Some (the ?option) = ?option›*) option.discI (*‹?option = Some ?x2.0 ⟹ ?option ≠ None›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) from "7.hyps"(1) (*‹unify (M::'a trm) (M'::'a trm) = Some (?σ::('a × 'a trm) list) ⟹ range_vars ?σ ⊆ vars_of M ∪ vars_of M'›*) have "range_θ₁": "range_vars θ₁ ⊆ vars_of M ∪ vars_of M'" using ‹unify M M' = Some θ₁› (*‹unify M M' = Some θ₁›*) by simp from "7.hyps"(2) (*‹⟦unify M M' = Some ?x2.0; unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ range_vars ?σ ⊆ vars_of (N ⊲ ?x2.0) ∪ vars_of (N' ⊲ ?x2.0)›*) have "range_vars θ₂ ⊆ vars_of (N ⊲ θ₁) ∪ vars_of (N' ⊲ θ₁)" using ‹unify M M' = Some θ₁› (*‹unify (M::'a trm) (M'::'a trm) = Some (θ₁::('a × 'a trm) list)›*) ‹unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂› (*‹unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂›*) by simp hence "range_θ₂": "range_vars θ₂ ⊆ vars_of N ∪ vars_of N' ∪ range_vars θ₁" using vars_of_subst_subset[of _ θ₁] (*‹vars_of (?N ⊲ θ₁) ⊆ vars_of ?N ∪ range_vars θ₁›*) by auto have "range_vars σ = range_vars (θ₁ ◊ θ₂)" unfolding ‹σ = θ₁ ◊ θ₂› (*goal: ‹range_vars (θ₁ ◊ θ₂) = range_vars (θ₁ ◊ θ₂)›*) by simp also (*calculation: ‹range_vars (σ::('a × 'a trm) list) = range_vars ((θ₁::('a × 'a trm) list) ◊ (θ₂::('a × 'a trm) list))›*) have "... ⊆ range_vars θ₁ ∪ range_vars θ₂" by (rule range_vars_comp_subset (*‹range_vars (?σ₁ ◊ ?σ₂) ⊆ range_vars ?σ₁ ∪ range_vars ?σ₂›*)) also (*calculation: ‹range_vars σ ⊆ range_vars θ₁ ∪ range_vars θ₂›*) have "... ⊆ range_vars θ₁ ∪ vars_of N ∪ vars_of N'" using "range_θ₂" (*‹range_vars θ₂ ⊆ vars_of N ∪ vars_of N' ∪ range_vars θ₁›*) by auto also (*calculation: ‹range_vars σ ⊆ range_vars θ₁ ∪ vars_of N ∪ vars_of N'›*) have "... ⊆ vars_of M ∪ vars_of M' ∪ vars_of N ∪ vars_of N'" using "range_θ₁" (*‹range_vars θ₁ ⊆ vars_of M ∪ vars_of M'›*) by auto finally (*calculation: ‹range_vars σ ⊆ vars_of M ∪ vars_of M' ∪ vars_of N ∪ vars_of N'›*) show "?case" (*goal: ‹range_vars σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) by auto qed theorem unify_gives_minimal_domain: "unify M N = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of N" proof (induct M N arbitrary: σ rule: unify.induct) (*goals: 1. ‹⋀c M N σ. unify (Const c) (M ⋅ N) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N)› 2. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c)› 3. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Var v)› 4. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 5. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ fst ` set σ ⊆ vars_of (Var v) ∪ vars_of M› 6. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 7. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (1 c M N) (*‹unify (Const c) (M ⋅ N) = Some σ›*) thus "?case" (*goal: ‹fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (M ⋅ N)›*) by simp next (*goals: 1. ‹⋀M N c σ. unify (M ⋅ N) (Const c) = Some σ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c)› 2. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Var v)› 3. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 4. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ fst ` set σ ⊆ vars_of (Var v) ∪ vars_of M› 5. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 6. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (2 M N c) (*‹unify ((M::'a trm) ⋅ (N::'a trm)) (Const (c::'a)) = Some (σ::('a × 'a trm) list)›*) thus "?case" (*goal: ‹fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Const c)›*) by simp next (*goals: 1. ‹⋀c v σ. unify (Const c) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Var v)› 2. ‹⋀M N v σ. unify (M ⋅ N) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 3. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ fst ` set σ ⊆ vars_of (Var v) ∪ vars_of M› 4. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 5. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (3 c v) (*‹unify (Const c) (Var v) = Some σ›*) hence "σ = [(v, Const c)]" by simp thus "?case" (*goal: ‹fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Var v)›*) by (simp add: dom_def (*‹dom ?m = {a. ?m a ≠ None}›*)) next (*goals: 1. ‹⋀(M::'a::type trm) (N::'a::type trm) (v::'a::type) σ::('a::type × 'a::type trm) list. unify (M ⋅ N) (Var v) = Some σ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)› 2. ‹⋀(v::'a::type) (M::'a::type trm) σ::('a::type × 'a::type trm) list. unify (Var v) M = Some σ ⟹ fst ` set σ ⊆ vars_of (Var v) ∪ vars_of M› 3. ‹⋀(c::'a::type) (d::'a::type) σ::('a::type × 'a::type trm) list. unify (Const c) (Const d) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 4. ‹⋀(M::'a::type trm) (N::'a::type trm) (M'::'a::type trm) (N'::'a::type trm) σ::('a::type × 'a::type trm) list. ⟦⋀σ::('a::type × 'a::type trm) list. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀(x2::('a::type × 'a::type trm) list) σ::('a::type × 'a::type trm) list. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (4 M N v) (*‹unify ((M::'a::type trm) ⋅ (N::'a::type trm)) (Var (v::'a::type)) = Some (σ::('a::type × 'a::type trm) list)›*) hence "σ = [(v, M ⋅ N)]" by (metis option.distinct( (*‹None ≠ Some (?x2.0::?'a::type)›*) 1) option.inject (*‹(Some (?x2.0::?'a::type) = Some (?y2.0::?'a::type)) = (?x2.0 = ?y2.0)›*) unify.simps( (*‹unify ((?M::?'a::type trm) ⋅ (?N::?'a::type trm)) (Var (?v::?'a::type)) = (if Var ?v ≺ ?M ⋅ ?N then None else Some [(?v, ?M ⋅ ?N)])›*) 4)) thus "?case" (*goal: ‹fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (Var v)›*) by (simp add: dom_def (*‹dom (?m::?'a::type ⇒ ?'b::type option) = {a::?'a::type. ?m a ≠ None}›*)) next (*goals: 1. ‹⋀v M σ. unify (Var v) M = Some σ ⟹ fst ` set σ ⊆ vars_of (Var v) ∪ vars_of M› 2. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 3. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (5 v M) (*‹unify (Var v) M = Some σ›*) hence "σ = [(v, M)]" by (metis option.distinct( (*‹None ≠ Some ?x2.0›*) 1) option.inject (*‹(Some ?x2.0 = Some ?y2.0) = (?x2.0 = ?y2.0)›*) unify.simps( (*‹unify (Var ?v) ?M = (if Var ?v ≺ ?M then None else Some [(?v, ?M)])›*) 5)) thus "?case" (*goal: ‹fst ` set σ ⊆ vars_of (Var v) ∪ vars_of M›*) by (simp add: dom_def (*‹dom (?m::?'a ⇒ ?'b option) = {a::?'a. ?m a ≠ None}›*)) next (*goals: 1. ‹⋀c d σ. unify (Const c) (Const d) = Some σ ⟹ fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)› 2. ‹⋀M N M' N' σ. ⟦⋀σ. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀x2 σ. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (6 c d) (*‹unify (Const c) (Const d) = Some σ›*) hence "σ = []" by (metis option.distinct( (*‹None ≠ Some ?x2.0›*) 1) option.sel (*‹the (Some ?x2.0) = ?x2.0›*) unify.simps( (*‹unify (Const ?c) (Const ?d) = (if ?c = ?d then Some [] else None)›*) 6)) thus "?case" (*goal: ‹fst ` set σ ⊆ vars_of (Const c) ∪ vars_of (Const d)›*) by simp next (*goal: ‹⋀(M::'a::type trm) (N::'a::type trm) (M'::'a::type trm) (N'::'a::type trm) σ::('a::type × 'a::type trm) list. ⟦⋀σ::('a::type × 'a::type trm) list. unify M M' = Some σ ⟹ fst ` set σ ⊆ vars_of M ∪ vars_of M'; ⋀(x2::('a::type × 'a::type trm) list) σ::('a::type × 'a::type trm) list. ⟦unify M M' = Some x2; unify (N ⊲ x2) (N' ⊲ x2) = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (N ⊲ x2) ∪ vars_of (N' ⊲ x2); unify (M ⋅ N) (M' ⋅ N') = Some σ⟧ ⟹ fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) case (7 M N M' N') (*‹unify M M' = Some ?σ ⟹ fst ` set ?σ ⊆ vars_of M ∪ vars_of M'› ‹⟦unify M M' = Some ?x2.0; unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ fst ` set ?σ ⊆ vars_of (N ⊲ ?x2.0) ∪ vars_of (N' ⊲ ?x2.0)› ‹unify (M ⋅ N) (M' ⋅ N') = Some σ›*) from "7.prems" (*‹unify ((M::'a trm) ⋅ (N::'a trm)) ((M'::'a trm) ⋅ (N'::'a trm)) = Some (σ::('a × 'a trm) list)›*) obtain θ₁ and θ₂ where "unify M M' = Some θ₁" and "unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂" and "σ = θ₁ ◊ θ₂" (*goal: ‹(⋀θ₁ θ₂. ⟦unify M M' = Some θ₁; unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂; σ = θ₁ ◊ θ₂⟧ ⟹ thesis) ⟹ thesis›*) apply simp (*goal: ‹(⋀θ₁ θ₂. ⟦unify M M' = Some θ₁; unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂; σ = θ₁ ◊ θ₂⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) option.case_eq_if (*‹(case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (if ?option = None then ?f1.0 else ?f2.0 (the ?option))›*) option.collapse (*‹?option ≠ None ⟹ Some (the ?option) = ?option›*) option.discI (*‹?option = Some ?x2.0 ⟹ ?option ≠ None›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) from "7.hyps"(1) (*‹unify M M' = Some ?σ ⟹ fst ` set ?σ ⊆ vars_of M ∪ vars_of M'›*) have "dom_θ₁": "fst ` set θ₁ ⊆ vars_of M ∪ vars_of M'" using ‹unify M M' = Some θ₁› (*‹unify M M' = Some θ₁›*) by simp from "7.hyps"(2) (*‹⟦unify M M' = Some ?x2.0; unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some ?σ⟧ ⟹ fst ` set ?σ ⊆ vars_of (N ⊲ ?x2.0) ∪ vars_of (N' ⊲ ?x2.0)›*) have "fst ` set θ₂ ⊆ vars_of (N ⊲ θ₁) ∪ vars_of (N' ⊲ θ₁)" using ‹unify M M' = Some θ₁› (*‹unify M M' = Some θ₁›*) ‹unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂› (*‹unify (N ⊲ θ₁) (N' ⊲ θ₁) = Some θ₂›*) by simp hence "dom_θ₂": "fst ` set θ₂ ⊆ vars_of N ∪ vars_of N' ∪ range_vars θ₁" using vars_of_subst_subset[of _ θ₁] (*‹vars_of (?N ⊲ θ₁) ⊆ vars_of ?N ∪ range_vars θ₁›*) by auto have "fst ` set σ = fst ` set (θ₁ ◊ θ₂)" unfolding ‹σ = θ₁ ◊ θ₂› (*goal: ‹fst ` set (θ₁ ◊ θ₂) = fst ` set (θ₁ ◊ θ₂)›*) by simp also (*calculation: ‹fst ` set σ = fst ` set (θ₁ ◊ θ₂)›*) have "... = fst ` set θ₁ ∪ fst ` set θ₂" by (auto simp: domain_comp (*‹fst ` set (?σ ◊ ?θ) = fst ` (set ?σ ∪ set ?θ)›*)) also (*calculation: ‹fst ` set σ = fst ` set θ₁ ∪ fst ` set θ₂›*) have "... ⊆ vars_of M ∪ vars_of M' ∪ fst ` set θ₂" using "dom_θ₁" (*‹fst ` set θ₁ ⊆ vars_of M ∪ vars_of M'›*) by auto also (*calculation: ‹fst ` set σ ⊆ vars_of M ∪ vars_of M' ∪ fst ` set θ₂›*) have "... ⊆ vars_of M ∪ vars_of M' ∪ vars_of N ∪ vars_of N' ∪ range_vars θ₁" using "dom_θ₂" (*‹fst ` set θ₂ ⊆ vars_of N ∪ vars_of N' ∪ range_vars θ₁›*) by auto also (*calculation: ‹fst ` set (σ::('a × 'a trm) list) ⊆ vars_of (M::'a trm) ∪ vars_of (M'::'a trm) ∪ vars_of (N::'a trm) ∪ vars_of (N'::'a trm) ∪ range_vars (θ₁::('a × 'a trm) list)›*) have "... ⊆ vars_of M ∪ vars_of M' ∪ vars_of N ∪ vars_of N'" using unify_gives_minimal_range[OF ‹unify M M' = Some θ₁›] (*‹range_vars (θ₁::('a::type × 'a::type trm) list) ⊆ vars_of (M::'a::type trm) ∪ vars_of (M'::'a::type trm)›*) by auto finally (*calculation: ‹fst ` set σ ⊆ vars_of M ∪ vars_of M' ∪ vars_of N ∪ vars_of N'›*) show "?case" (*goal: ‹fst ` set σ ⊆ vars_of (M ⋅ N) ∪ vars_of (M' ⋅ N')›*) by auto qed subsection ‹Idempotent Most General Unifier› definition IMGU :: "'a subst ⇒ 'a trm ⇒ 'a trm ⇒ bool" where "IMGU μ t u ⟷ Unifier μ t u ∧ (∀θ. Unifier θ t u ⟶ θ ≐ μ ◊ θ)" lemma IMGU_iff_Idem_and_MGU: "IMGU μ t u ⟷ Idem μ ∧ MGU μ t u" unfolding IMGU_def Idem_def MGU_def (*goal: ‹(Unifier μ t u ∧ (∀θ. Unifier θ t u ⟶ θ ≐ μ ◊ θ)) = (μ ◊ μ ≐ μ ∧ Unifier μ t u ∧ (∀θ. Unifier θ t u ⟶ (∃γ. θ ≐ μ ◊ γ)))›*) by (meson Unification.comp_assoc (*‹?a ◊ ?b ◊ ?c ≐ ?a ◊ (?b ◊ ?c)›*) subst_cong (*‹⟦?σ ≐ ?σ'; ?θ ≐ ?θ'⟧ ⟹ ?σ ◊ ?θ ≐ ?σ' ◊ ?θ'›*) subst_refl (*‹?s ≐ ?s›*) subst_sym (*‹?s1.0 ≐ ?s2.0 ⟹ ?s2.0 ≐ ?s1.0›*) subst_trans (*‹⟦?s1.0 ≐ ?s2.0; ?s2.0 ≐ ?s3.0⟧ ⟹ ?s1.0 ≐ ?s3.0›*)) lemma unify_computes_IMGU: "unify M N = Some σ ⟹ IMGU σ M N" by (simp add: IMGU_iff_Idem_and_MGU (*‹IMGU (?μ::(?'a::type × ?'a::type trm) list) (?t::?'a::type trm) (?u::?'a::type trm) = (Idem ?μ ∧ MGU ?μ ?t ?u)›*) unify_computes_MGU (*‹unify (?M::?'a::type trm) (?N::?'a::type trm) = Some (?σ::(?'a::type × ?'a::type trm) list) ⟹ MGU ?σ ?M ?N›*) unify_gives_Idem (*‹unify (?M::?'a::type trm) (?N::?'a::type trm) = Some (?σ::(?'a::type × ?'a::type trm) list) ⟹ Idem ?σ›*)) subsection ‹Unification is complete› lemma unify_eq_Some_if_Unifier: assumes "Unifier σ t u" shows "∃τ. unify t u = Some τ" using assms (*‹Unifier (σ::('a::type × 'a::type trm) list) (t::'a::type trm) (u::'a::type trm)›*) proof (induction t u rule: unify.induct (*‹⟦⋀c M N. ?P (Const c) (M ⋅ N); ⋀M N c. ?P (M ⋅ N) (Const c); ⋀c v. ?P (Const c) (Var v); ⋀M N v. ?P (M ⋅ N) (Var v); ⋀v M. ?P (Var v) M; ⋀c d. ?P (Const c) (Const d); ⋀M N M' N'. ⟦?P M M'; ⋀x2. unify M M' = Some x2 ⟹ ?P (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ?P (M ⋅ N) (M' ⋅ N')⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀c M N. Unifier σ (Const c) (M ⋅ N) ⟹ ∃τ. unify (Const c) (M ⋅ N) = Some τ› 2. ‹⋀M N c. Unifier σ (M ⋅ N) (Const c) ⟹ ∃τ. unify (M ⋅ N) (Const c) = Some τ› 3. ‹⋀c v. Unifier σ (Const c) (Var v) ⟹ ∃τ. unify (Const c) (Var v) = Some τ› 4. ‹⋀M N v. Unifier σ (M ⋅ N) (Var v) ⟹ ∃τ. unify (M ⋅ N) (Var v) = Some τ› 5. ‹⋀v M. Unifier σ (Var v) M ⟹ ∃τ. unify (Var v) M = Some τ› 6. ‹⋀c d. Unifier σ (Const c) (Const d) ⟹ ∃τ. unify (Const c) (Const d) = Some τ› 7. ‹⋀M N M' N'. ⟦Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ; ⋀x2. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (1 c M N) (*‹Unifier (σ::('a × 'a trm) list) (Const (c::'a)) ((M::'a trm) ⋅ (N::'a trm))›*) thus "?case" (*goal: ‹∃τ. unify (Const c) (M ⋅ N) = Some τ›*) by (simp add: Unifier_def (*‹Unifier ?σ ?t ?u = (?t ⊲ ?σ = ?u ⊲ ?σ)›*)) next (*goals: 1. ‹⋀M N c. Unifier σ (M ⋅ N) (Const c) ⟹ ∃τ. unify (M ⋅ N) (Const c) = Some τ› 2. ‹⋀c v. Unifier σ (Const c) (Var v) ⟹ ∃τ. unify (Const c) (Var v) = Some τ› 3. ‹⋀M N v. Unifier σ (M ⋅ N) (Var v) ⟹ ∃τ. unify (M ⋅ N) (Var v) = Some τ› 4. ‹⋀v M. Unifier σ (Var v) M ⟹ ∃τ. unify (Var v) M = Some τ› 5. ‹⋀c d. Unifier σ (Const c) (Const d) ⟹ ∃τ. unify (Const c) (Const d) = Some τ› 6. ‹⋀M N M' N'. ⟦Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ; ⋀x2. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (2 M N c) (*‹Unifier σ (M ⋅ N) (Const c)›*) thus "?case" (*goal: ‹∃τ::('a × 'a trm) list. unify ((M::'a trm) ⋅ (N::'a trm)) (Const (c::'a)) = Some τ›*) by (simp add: Unifier_def (*‹Unifier ?σ ?t ?u = (?t ⊲ ?σ = ?u ⊲ ?σ)›*)) next (*goals: 1. ‹⋀(c::'a) v::'a. Unifier (σ::('a × 'a trm) list) (Const c) (Var v) ⟹ ∃τ::('a × 'a trm) list. unify (Const c) (Var v) = Some τ› 2. ‹⋀(M::'a trm) (N::'a trm) v::'a. Unifier (σ::('a × 'a trm) list) (M ⋅ N) (Var v) ⟹ ∃τ::('a × 'a trm) list. unify (M ⋅ N) (Var v) = Some τ› 3. ‹⋀(v::'a) M::'a trm. Unifier (σ::('a × 'a trm) list) (Var v) M ⟹ ∃τ::('a × 'a trm) list. unify (Var v) M = Some τ› 4. ‹⋀(c::'a) d::'a. Unifier (σ::('a × 'a trm) list) (Const c) (Const d) ⟹ ∃τ::('a × 'a trm) list. unify (Const c) (Const d) = Some τ› 5. ‹⋀(M::'a trm) (N::'a trm) (M'::'a trm) N'::'a trm. ⟦Unifier (σ::('a × 'a trm) list) M M' ⟹ ∃τ::('a × 'a trm) list. unify M M' = Some τ; ⋀x2::('a × 'a trm) list. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ::('a × 'a trm) list. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ::('a × 'a trm) list. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (3 c v) (*‹Unifier σ (Const c) (Var v)›*) thus "?case" (*goal: ‹∃τ. unify (Const c) (Var v) = Some τ›*) by simp next (*goals: 1. ‹⋀M N v. Unifier σ (M ⋅ N) (Var v) ⟹ ∃τ. unify (M ⋅ N) (Var v) = Some τ› 2. ‹⋀v M. Unifier σ (Var v) M ⟹ ∃τ. unify (Var v) M = Some τ› 3. ‹⋀c d. Unifier σ (Const c) (Const d) ⟹ ∃τ. unify (Const c) (Const d) = Some τ› 4. ‹⋀M N M' N'. ⟦Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ; ⋀x2. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (4 M N v) (*‹Unifier (σ::('a × 'a trm) list) ((M::'a trm) ⋅ (N::'a trm)) (Var (v::'a))›*) hence "¬ (Var v ≺ M ⋅ N)" by (auto dest: not_occs_if_Unifier (*‹Unifier ?σ ?t ?u ⟹ ¬ ?t ≺ ?u ∧ ¬ ?u ≺ ?t›*)) thus "?case" (*goal: ‹∃τ. unify (M ⋅ N) (Var v) = Some τ›*) by simp next (*goals: 1. ‹⋀v M. Unifier σ (Var v) M ⟹ ∃τ. unify (Var v) M = Some τ› 2. ‹⋀c d. Unifier σ (Const c) (Const d) ⟹ ∃τ. unify (Const c) (Const d) = Some τ› 3. ‹⋀M N M' N'. ⟦Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ; ⋀x2. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (5 v M) (*‹Unifier σ (Var v) M›*) thus "?case" (*goal: ‹∃τ. unify (Var v) M = Some τ›*) by (auto dest: not_occs_if_Unifier (*‹Unifier ?σ ?t ?u ⟹ ¬ ?t ≺ ?u ∧ ¬ ?u ≺ ?t›*)) next (*goals: 1. ‹⋀c d. Unifier σ (Const c) (Const d) ⟹ ∃τ. unify (Const c) (Const d) = Some τ› 2. ‹⋀M N M' N'. ⟦Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ; ⋀x2. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (6 c d) (*‹Unifier σ (Const c) (Const d)›*) thus "?case" (*goal: ‹∃τ. unify (Const c) (Const d) = Some τ›*) by (simp add: Unifier_def (*‹Unifier (?σ::(?'a × ?'a trm) list) (?t::?'a trm) (?u::?'a trm) = (?t ⊲ ?σ = ?u ⊲ ?σ)›*)) next (*goal: ‹⋀M N M' N'. ⟦Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ; ⋀x2. ⟦unify M M' = Some x2; Unifier σ (N ⊲ x2) (N' ⊲ x2)⟧ ⟹ ∃τ. unify (N ⊲ x2) (N' ⊲ x2) = Some τ; Unifier σ (M ⋅ N) (M' ⋅ N')⟧ ⟹ ∃τ. unify (M ⋅ N) (M' ⋅ N') = Some τ›*) case (7 M N M' N') (*‹Unifier σ M M' ⟹ ∃τ. unify M M' = Some τ› ‹⟦unify M M' = Some ?x2.0; Unifier σ (N ⊲ ?x2.0) (N' ⊲ ?x2.0)⟧ ⟹ ∃τ. unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some τ› ‹Unifier σ (M ⋅ N) (M' ⋅ N')›*) from "7.prems" (*‹Unifier σ (M ⋅ N) (M' ⋅ N')›*) have "Unifier σ M M'" by (simp add: Unifier_def (*‹Unifier (?σ::(?'a::type × ?'a::type trm) list) (?t::?'a::type trm) (?u::?'a::type trm) = (?t ⊲ ?σ = ?u ⊲ ?σ)›*)) with "7.IH"(1) (*‹Unifier (σ::('a × 'a trm) list) (M::'a trm) (M'::'a trm) ⟹ ∃τ::('a × 'a trm) list. unify M M' = Some τ›*) obtain τ where "τ": "unify M M' = Some τ" (*goal: ‹(⋀τ. unify M M' = Some τ ⟹ thesis) ⟹ thesis›*) by auto then have "Unifier σ (N ⊲ τ) (N' ⊲ τ)" unfolding Unifier_def (*goal: ‹N ⊲ τ ⊲ σ = N' ⊲ τ ⊲ σ›*) by (metis "7.prems" (*‹Unifier σ (M ⋅ N) (M' ⋅ N')›*) IMGU_def (*‹IMGU ?μ ?t ?u = (Unifier ?μ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ θ ≐ ?μ ◊ θ))›*) Unifier_def (*‹Unifier ?σ ?t ?u = (?t ⊲ ?σ = ?u ⊲ ?σ)›*) subst.simps( (*‹?M ⋅ ?N ⊲ ?s = (?M ⊲ ?s) ⋅ (?N ⊲ ?s)›*) 3) subst_comp (*‹?t ⊲ ?r ◊ ?s = ?t ⊲ ?r ⊲ ?s›*) subst_eq_def (*‹?s1.0 ≐ ?s2.0 = (∀t. t ⊲ ?s1.0 = t ⊲ ?s2.0)›*) trm.distinct( (*‹Var ?x1.0 ≠ ?x31.0 ⋅ ?x32.0›*) 3) trm.distinct( (*‹Const ?x2.0 ≠ ?x31.0 ⋅ ?x32.0›*) 5) trm.exhaust (*‹⟦⋀x1. ?y = Var x1 ⟹ ?P; ⋀x2. ?y = Const x2 ⟹ ?P; ⋀x31 x32. ?y = x31 ⋅ x32 ⟹ ?P⟧ ⟹ ?P›*) trm.inject( (*‹(?x31.0 ⋅ ?x32.0 = ?y31.0 ⋅ ?y32.0) = (?x31.0 = ?y31.0 ∧ ?x32.0 = ?y32.0)›*) 3) unify_computes_IMGU (*‹unify ?M ?N = Some ?σ ⟹ IMGU ?σ ?M ?N›*)) with "τ" (*‹unify M M' = Some τ›*) show "?case" (*goal: ‹∃τ::('a × 'a trm) list. unify ((M::'a trm) ⋅ (N::'a trm)) ((M'::'a trm) ⋅ (N'::'a trm)) = Some τ›*) using "7.IH"(2) (*‹⟦unify M M' = Some ?x2.0; Unifier σ (N ⊲ ?x2.0) (N' ⊲ ?x2.0)⟧ ⟹ ∃τ. unify (N ⊲ ?x2.0) (N' ⊲ ?x2.0) = Some τ›*) by auto qed definition subst_domain where "subst_domain σ = {x. Var x ⊲ σ ≠ Var x}" lemma subst_domain_subset_list_domain: "subst_domain σ ⊆ fst ` set σ" proof (rule Set.subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. x ∈ subst_domain σ ⟹ x ∈ fst ` set σ›*) fix x assume "x ∈ subst_domain σ" (*‹(x::'a) ∈ subst_domain (σ::('a × 'a trm) list)›*) hence "Var x ⊲ σ ≠ Var x" by (simp add: subst_domain_def (*‹subst_domain ?σ = {x. Var x ⊲ ?σ ≠ Var x}›*)) then show "x ∈ fst ` set σ" proof (induction σ) (*goals: 1. ‹Var x ⊲ [] ≠ Var x ⟹ x ∈ fst ` set []› 2. ‹⋀a σ. ⟦Var x ⊲ σ ≠ Var x ⟹ x ∈ fst ` set σ; Var x ⊲ a # σ ≠ Var x⟧ ⟹ x ∈ fst ` set (a # σ)›*) case Nil (*‹Var x ⊲ [] ≠ Var x›*) thus "?case" (*goal: ‹x ∈ fst ` set []›*) by simp next (*goal: ‹⋀a σ. ⟦Var x ⊲ σ ≠ Var x ⟹ x ∈ fst ` set σ; Var x ⊲ a # σ ≠ Var x⟧ ⟹ x ∈ fst ` set (a # σ)›*) case (Cons p σ) (*‹Var x ⊲ σ ≠ Var x ⟹ x ∈ fst ` set σ› ‹Var x ⊲ p # σ ≠ Var x›*) show "?case" (*goal: ‹x ∈ fst ` set (p # σ)›*) proof (cases "x = fst p") (*goals: 1. ‹x = fst p ⟹ x ∈ fst ` set (p # σ)› 2. ‹x ≠ fst p ⟹ x ∈ fst ` set (p # σ)›*) case True (*‹x = fst p›*) thus "?thesis" (*goal: ‹x ∈ fst ` set (p # σ)›*) by simp next (*goal: ‹x ≠ fst p ⟹ x ∈ fst ` set (p # σ)›*) case False (*‹x ≠ fst p›*) with Cons.IH (*‹Var x ⊲ σ ≠ Var x ⟹ x ∈ fst ` set σ›*) Cons.prems (*‹Var x ⊲ p # σ ≠ Var x›*) show "?thesis" (*goal: ‹x ∈ fst ` set (p # σ)›*) apply (cases p) (*goal: ‹(x::'a) ∈ fst ` set ((p::'a × 'a trm) # (σ::('a × 'a trm) list))›*) by simp qed qed qed lemma subst_apply_eq_Var: assumes "s ⊲ σ = Var x" obtains y where "s = Var y" and "Var y ⊲ σ = Var x" using assms (*‹s ⊲ σ = Var x›*) apply (induct s) (*goals: 1. ‹⋀xa. ⟦⋀y. ⟦Var xa = Var y; Var y ⊲ σ = Var x⟧ ⟹ thesis; Var xa ⊲ σ = Var x⟧ ⟹ thesis› 2. ‹⋀xa. ⟦⋀y. ⟦Const xa = Var y; Var y ⊲ σ = Var x⟧ ⟹ thesis; Const xa ⊲ σ = Var x⟧ ⟹ thesis› 3. ‹⋀s1 s2. ⟦⟦⋀y. ⟦s1 = Var y; Var y ⊲ σ = Var x⟧ ⟹ thesis; s1 ⊲ σ = Var x⟧ ⟹ thesis; ⟦⋀y. ⟦s2 = Var y; Var y ⊲ σ = Var x⟧ ⟹ thesis; s2 ⊲ σ = Var x⟧ ⟹ thesis; ⋀y. ⟦s1 ⋅ s2 = Var y; Var y ⊲ σ = Var x⟧ ⟹ thesis; s1 ⋅ s2 ⊲ σ = Var x⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma mem_range_varsI: assumes "Var x ⊲ σ = Var y" and "x ≠ y" shows "y ∈ range_vars σ" using assms (*‹Var x ⊲ σ = Var y› ‹x ≠ y›*) unfolding range_vars_def (*goal: ‹y ∈ ⋃ {vars_of (Var x ⊲ σ) |x. Var x ⊲ σ ≠ Var x}›*) by (metis (mono_tags, lifting) UnionI (*‹⟦?X ∈ ?C; ?A ∈ ?X⟧ ⟹ ?A ∈ ⋃ ?C›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) trm.inject( (*‹(Var ?x1.0 = Var ?y1.0) = (?x1.0 = ?y1.0)›*) 1) vars_iff_occseq (*‹(?x ∈ vars_of ?t) = (Var ?x ≺ ?t ∨ Var ?x = ?t)›*)) lemma IMGU_subst_domain_subset: assumes "IMGU μ t u" shows "subst_domain μ ⊆ vars_of t ∪ vars_of u" proof (rule Set.subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. x ∈ subst_domain μ ⟹ x ∈ vars_of t ∪ vars_of u›*) from assms (*‹IMGU μ t u›*) have "Unifier μ t u" by (simp add: IMGU_def (*‹IMGU (?μ::(?'a × ?'a trm) list) (?t::?'a trm) (?u::?'a trm) = (Unifier ?μ ?t ?u ∧ (∀θ::(?'a × ?'a trm) list. Unifier θ ?t ?u ⟶ θ ≐ ?μ ◊ θ))›*)) then obtain υ where "unify t u = Some υ" (*goal: ‹(⋀υ. unify t u = Some υ ⟹ thesis) ⟹ thesis›*) using unify_eq_Some_if_Unifier (*‹Unifier ?σ ?t ?u ⟹ ∃τ. unify ?t ?u = Some τ›*) by metis hence "Unifier υ t u" using MGU_def (*‹MGU ?σ ?t ?u = (Unifier ?σ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ (∃γ. θ ≐ ?σ ◊ γ)))›*) unify_computes_MGU (*‹unify ?M ?N = Some ?σ ⟹ MGU ?σ ?M ?N›*) by blast with assms (*‹IMGU μ t u›*) have "υ ≐ μ ◊ υ" by (simp add: IMGU_def (*‹IMGU (?μ::(?'a::type × ?'a::type trm) list) (?t::?'a::type trm) (?u::?'a::type trm) = (Unifier ?μ ?t ?u ∧ (∀θ::(?'a::type × ?'a::type trm) list. Unifier θ ?t ?u ⟶ θ ≐ ?μ ◊ θ))›*)) fix x assume "x ∈ subst_domain μ" (*‹(x::'a) ∈ subst_domain (μ::('a × 'a trm) list)›*) hence "Var x ⊲ μ ≠ Var x" by (simp add: subst_domain_def (*‹subst_domain ?σ = {x. Var x ⊲ ?σ ≠ Var x}›*)) show "x ∈ vars_of t ∪ vars_of u" proof (cases "x ∈ subst_domain υ") (*goals: 1. ‹x ∈ subst_domain υ ⟹ x ∈ vars_of t ∪ vars_of u› 2. ‹x ∉ subst_domain υ ⟹ x ∈ vars_of t ∪ vars_of u›*) case True (*‹x ∈ subst_domain υ›*) hence "x ∈ fst ` set υ" using subst_domain_subset_list_domain (*‹subst_domain ?σ ⊆ fst ` set ?σ›*) by fast thus "?thesis" (*goal: ‹(x::'a) ∈ vars_of (t::'a trm) ∪ vars_of (u::'a trm)›*) using unify_gives_minimal_domain[OF ‹unify t u = Some υ›] (*‹fst ` set υ ⊆ vars_of t ∪ vars_of u›*) by auto next (*goal: ‹x ∉ subst_domain υ ⟹ x ∈ vars_of t ∪ vars_of u›*) case False (*‹x ∉ subst_domain υ›*) hence "Var x ⊲ υ = Var x" by (simp add: subst_domain_def (*‹subst_domain ?σ = {x. Var x ⊲ ?σ ≠ Var x}›*)) hence "Var x ⊲ μ ⊲ υ = Var x" using ‹υ ≐ μ ◊ υ› (*‹υ ≐ μ ◊ υ›*) by (metis subst_comp (*‹?t ⊲ ?r ◊ ?s = ?t ⊲ ?r ⊲ ?s›*) subst_eq_dest (*‹?s1.0 ≐ ?s2.0 ⟹ ?t ⊲ ?s1.0 = ?t ⊲ ?s2.0›*)) then show "?thesis" (*goal: ‹x ∈ vars_of t ∪ vars_of u›*) apply (rule subst_apply_eq_Var (*‹⟦?s ⊲ ?σ = Var ?x; ⋀y. ⟦?s = Var y; Var y ⊲ ?σ = Var ?x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹x ∈ vars_of t ∪ vars_of u›*) using ‹Var x ⊲ μ ≠ Var x› (*‹Var (x::'a) ⊲ (μ::('a × 'a trm) list) ≠ Var x›*) using unify_gives_minimal_range[OF ‹unify t u = Some υ›] (*‹range_vars υ ⊆ vars_of t ∪ vars_of u›*) using mem_range_varsI (*‹⟦Var ?x ⊲ ?σ = Var ?y; ?x ≠ ?y⟧ ⟹ ?y ∈ range_vars ?σ›*) by force qed qed lemma IMGU_range_vars_subset: assumes "IMGU μ t u" shows "range_vars μ ⊆ vars_of t ∪ vars_of u" proof (rule Set.subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goal: ‹⋀x. x ∈ range_vars μ ⟹ x ∈ vars_of t ∪ vars_of u›*) from assms (*‹IMGU (μ::('a::type × 'a::type trm) list) (t::'a::type trm) (u::'a::type trm)›*) have "Unifier μ t u" by (simp add: IMGU_def (*‹IMGU ?μ ?t ?u = (Unifier ?μ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ θ ≐ ?μ ◊ θ))›*)) then obtain υ where "unify t u = Some υ" (*goal: ‹(⋀υ. unify t u = Some υ ⟹ thesis) ⟹ thesis›*) using unify_eq_Some_if_Unifier (*‹Unifier ?σ ?t ?u ⟹ ∃τ. unify ?t ?u = Some τ›*) by metis hence "Unifier υ t u" using MGU_def (*‹MGU ?σ ?t ?u = (Unifier ?σ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ (∃γ. θ ≐ ?σ ◊ γ)))›*) unify_computes_MGU (*‹unify ?M ?N = Some ?σ ⟹ MGU ?σ ?M ?N›*) by blast with assms (*‹IMGU μ t u›*) have "υ ≐ μ ◊ υ" by (simp add: IMGU_def (*‹IMGU ?μ ?t ?u = (Unifier ?μ ?t ?u ∧ (∀θ. Unifier θ ?t ?u ⟶ θ ≐ ?μ ◊ θ))›*)) have ball_subst_dom: "∀x ∈ subst_domain υ. vars_of (Var x ⊲ υ) ⊆ vars_of t ∪ vars_of u" using unify_gives_minimal_range[OF ‹unify t u = Some υ›] (*‹range_vars υ ⊆ vars_of t ∪ vars_of u›*) using range_vars_def (*‹range_vars (?σ::(?'a × ?'a trm) list) = ⋃ {vars_of (Var x ⊲ ?σ) |x::?'a. Var x ⊲ ?σ ≠ Var x}›*) subst_domain_def (*‹subst_domain (?σ::(?'a × ?'a trm) list) = {x::?'a. Var x ⊲ ?σ ≠ Var x}›*) by fastforce fix x assume "x ∈ range_vars μ" (*‹(x::'a) ∈ range_vars (μ::('a × 'a trm) list)›*) then obtain y where "x ∈ vars_of (Var y ⊲ μ)" and "Var y ⊲ μ ≠ Var y" (*goal: ‹(⋀y. ⟦x ∈ vars_of (Var y ⊲ μ); Var y ⊲ μ ≠ Var y⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: range_vars_def (*‹range_vars (?σ::(?'a × ?'a trm) list) = ⋃ {vars_of (Var x ⊲ ?σ) |x::?'a. Var x ⊲ ?σ ≠ Var x}›*)) have "vars_of_y_υ": "vars_of (Var y ⊲ υ) ⊆ vars_of t ∪ vars_of u" using ball_subst_dom (*‹∀x∈subst_domain υ. vars_of (Var x ⊲ υ) ⊆ vars_of t ∪ vars_of u›*) by (metis (mono_tags, lifting) IMGU_subst_domain_subset (*‹IMGU ?μ ?t ?u ⟹ subst_domain ?μ ⊆ vars_of ?t ∪ vars_of ?u›*) ‹Var y ⊲ μ ≠ Var y› assms (*‹IMGU μ t u›*) empty_iff (*‹(?c ∈ {}) = False›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) subst_domain_def (*‹subst_domain ?σ = {x. Var x ⊲ ?σ ≠ Var x}›*) vars_of.simps( (*‹vars_of (Var ?v) = {?v}›*) 1)) show "x ∈ vars_of t ∪ vars_of u" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹(x::'a) ∉ vars_of (t::'a trm) ∪ vars_of (u::'a trm) ⟹ False›*) assume "x ∉ vars_of t ∪ vars_of u" (*‹(x::'a) ∉ vars_of (t::'a trm) ∪ vars_of (u::'a trm)›*) hence "x ∉ vars_of (Var y ⊲ υ)" using "vars_of_y_υ" (*‹vars_of (Var y ⊲ υ) ⊆ vars_of t ∪ vars_of u›*) by blast moreover have "x ∈ vars_of (Var y ⊲ μ ⊲ υ)" proof (-) (*goal: ‹x ∈ vars_of (Var y ⊲ μ ⊲ υ)›*) have "Var x ⊲ υ = Var x" using ‹x ∉ vars_of t ∪ vars_of u› (*‹(x::'a::type) ∉ vars_of (t::'a::type trm) ∪ vars_of (u::'a::type trm)›*) using IMGU_subst_domain_subset (*‹IMGU ?μ ?t ?u ⟹ subst_domain ?μ ⊆ vars_of ?t ∪ vars_of ?u›*) ‹unify t u = Some υ› (*‹unify t u = Some υ›*) subst_domain_def (*‹subst_domain ?σ = {x. Var x ⊲ ?σ ≠ Var x}›*) unify_computes_IMGU (*‹unify (?M::?'a::type trm) (?N::?'a::type trm) = Some (?σ::(?'a::type × ?'a::type trm) list) ⟹ IMGU ?σ ?M ?N›*) by fastforce thus "?thesis" (*goal: ‹(x::'a) ∈ vars_of (Var (y::'a) ⊲ (μ::('a × 'a trm) list) ⊲ (υ::('a × 'a trm) list))›*) by (metis ‹x ∈ vars_of (Var y ⊲ μ)› subst_mono (*‹?t ≺ ?u ⟹ ?t ⊲ ?s ≺ ?u ⊲ ?s›*) vars_iff_occseq (*‹(?x ∈ vars_of ?t) = (Var ?x ≺ ?t ∨ Var ?x = ?t)›*)) qed ultimately show False using ‹υ ≐ μ ◊ υ› (*‹υ ≐ μ ◊ υ›*) by (metis subst_comp (*‹?t ⊲ ?r ◊ ?s = ?t ⊲ ?r ⊲ ?s›*) subst_eq_dest (*‹?s1.0 ≐ ?s2.0 ⟹ ?t ⊲ ?s1.0 = ?t ⊲ ?s2.0›*)) qed qed end
{ "path": "Isabelle2024/src/HOL/ex/Unification.thy", "repo": "Isabelle2024", "sha": "d8eb0f1ee75bb37e1667b765338c16c0247614a1851a05e932f1157ce9eddc7d" }
(* Title: Safe OCL Author: Denis Nikiforov, March 2019 Maintainer: Denis Nikiforov <denis.nikif at gmail.com> License: LGPL *) chapter ‹Typing› theory OCL_Typing imports OCL_Object_Model "HOL-Library.Transitive_Closure_Table" begin text ‹ The following rules are more restrictive than rules given in the OCL specification. This allows one to identify more errors in expressions. However, these restrictions may be revised if necessary. Perhaps some of them could be separated and should cause warnings instead of errors.› (*** Operations Typing ******************************************************) section ‹Operations Typing› subsection ‹Metaclass Operations› text ‹ All basic types in the theory are either nullable or non-nullable. For example, instead of @{text Boolean} type we have two types: @{text "Boolean[1]"} and @{text "Boolean[?]"}. The @{text "allInstances()"} operation is extended accordingly:› text ‹ ▩‹Boolean[1].allInstances() = Set{true, false} Boolean[?].allInstances() = Set{true, false, null}›› inductive mataop_type where "mataop_type τ AllInstancesOp (Set τ)" subsection ‹Type Operations› text ‹ At first we decided to allow casting only to subtypes. However sometimes it is necessary to cast expressions to supertypes, for example, to access overridden attributes of a supertype. So we allow casting to subtypes and supertypes. Casting to other types is meaningless.› text ‹ According to the Section 7.4.7 of the OCL specification @{text "oclAsType()"} can be applied to collections as well as to single values. I guess we can allow @{text "oclIsTypeOf()"} and @{text "oclIsKindOf()"} for collections too.› text ‹ Please take a note that the following expressions are prohibited, because they always return true or false:› text ‹ ▩‹1.oclIsKindOf(OclAny[?]) 1.oclIsKindOf(String[1])›› text ‹ Please take a note that:› text ‹ ▩‹Set{1,2,null,'abc'}->selectByKind(Integer[1]) = Set{1,2} Set{1,2,null,'abc'}->selectByKind(Integer[?]) = Set{1,2,null}›› text ‹ The following expressions are prohibited, because they always returns either the same or empty collections:› text ‹ ▩‹Set{1,2,null,'abc'}->selectByKind(OclAny[?]) Set{1,2,null,'abc'}->selectByKind(Collection(Boolean[1]))›› inductive typeop_type where "σ < τ ∨ τ < σ ⟹ typeop_type DotCall OclAsTypeOp τ σ σ" | "σ < τ ⟹ typeop_type DotCall OclIsTypeOfOp τ σ Boolean[1]" | "σ < τ ⟹ typeop_type DotCall OclIsKindOfOp τ σ Boolean[1]" | "element_type τ ρ ⟹ σ < ρ ⟹ update_element_type τ σ υ ⟹ typeop_type ArrowCall SelectByKindOp τ σ υ" | "element_type τ ρ ⟹ σ < ρ ⟹ update_element_type τ σ υ ⟹ typeop_type ArrowCall SelectByTypeOp τ σ υ" subsection ‹OclSuper Operations› text ‹ It makes sense to compare values only with compatible types.› (* We have to specify the predicate type explicitly to let a generated code work *) inductive super_binop_type :: "super_binop ⇒ ('a :: order) type ⇒ 'a type ⇒ 'a type ⇒ bool" where "τ ≤ σ ∨ σ < τ ⟹ super_binop_type EqualOp τ σ Boolean[1]" | "τ ≤ σ ∨ σ < τ ⟹ super_binop_type NotEqualOp τ σ Boolean[1]" subsection ‹OclAny Operations› text ‹ The OCL specification defines @{text "toString()"} operation only for boolean and numeric types. However, I guess it is a good idea to define it once for all basic types. Maybe it should be defined for collections as well.› inductive any_unop_type where "τ ≤ OclAny[?] ⟹ any_unop_type OclAsSetOp τ (Set (to_required_type τ))" | "τ ≤ OclAny[?] ⟹ any_unop_type OclIsNewOp τ Boolean[1]" | "τ ≤ OclAny[?] ⟹ any_unop_type OclIsUndefinedOp τ Boolean[1]" | "τ ≤ OclAny[?] ⟹ any_unop_type OclIsInvalidOp τ Boolean[1]" | "τ ≤ OclAny[?] ⟹ any_unop_type OclLocaleOp τ String[1]" | "τ ≤ OclAny[?] ⟹ any_unop_type ToStringOp τ String[1]" subsection ‹Boolean Operations› text ‹ Please take a note that:› text ‹ ▩‹true or false : Boolean[1] true and null : Boolean[?] null and null : OclVoid[?]›› inductive boolean_unop_type where "τ ≤ Boolean[?] ⟹ boolean_unop_type NotOp τ τ" inductive boolean_binop_type where "τ ⊔ σ = ρ ⟹ ρ ≤ Boolean[?] ⟹ boolean_binop_type AndOp τ σ ρ" | "τ ⊔ σ = ρ ⟹ ρ ≤ Boolean[?] ⟹ boolean_binop_type OrOp τ σ ρ" | "τ ⊔ σ = ρ ⟹ ρ ≤ Boolean[?] ⟹ boolean_binop_type XorOp τ σ ρ" | "τ ⊔ σ = ρ ⟹ ρ ≤ Boolean[?] ⟹ boolean_binop_type ImpliesOp τ σ ρ" subsection ‹Numeric Operations› text ‹ The expression @{text "1 + null"} is not well-typed. Nullable numeric values should be converted to non-nullable ones. This is a significant difference from the OCL specification.› text ‹ Please take a note that many operations automatically casts unlimited naturals to integers.› text ‹ The difference between @{text "oclAsType(Integer)"} and @{text "toInteger()"} for unlimited naturals is unclear.› inductive numeric_unop_type where "τ = Real[1] ⟹ numeric_unop_type UMinusOp τ Real[1]" | "τ = UnlimitedNatural[1]─Integer[1] ⟹ numeric_unop_type UMinusOp τ Integer[1]" | "τ = Real[1] ⟹ numeric_unop_type AbsOp τ Real[1]" | "τ = UnlimitedNatural[1]─Integer[1] ⟹ numeric_unop_type AbsOp τ Integer[1]" | "τ = UnlimitedNatural[1]─Real[1] ⟹ numeric_unop_type FloorOp τ Integer[1]" | "τ = UnlimitedNatural[1]─Real[1] ⟹ numeric_unop_type RoundOp τ Integer[1]" | "τ = UnlimitedNatural[1] ⟹ numeric_unop_type numeric_unop.ToIntegerOp τ Integer[1]" inductive numeric_binop_type where "τ ⊔ σ = ρ ⟹ ρ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type PlusOp τ σ ρ" | "τ ⊔ σ = Real[1] ⟹ numeric_binop_type MinusOp τ σ Real[1]" | "τ ⊔ σ = UnlimitedNatural[1]─Integer[1] ⟹ numeric_binop_type MinusOp τ σ Integer[1]" | "τ ⊔ σ = ρ ⟹ ρ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type MultOp τ σ ρ" | "τ = UnlimitedNatural[1]─Real[1] ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type DivideOp τ σ Real[1]" | "τ ⊔ σ = ρ ⟹ ρ = UnlimitedNatural[1]─Integer[1] ⟹ numeric_binop_type DivOp τ σ ρ" | "τ ⊔ σ = ρ ⟹ ρ = UnlimitedNatural[1]─Integer[1] ⟹ numeric_binop_type ModOp τ σ ρ" | "τ ⊔ σ = ρ ⟹ ρ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type MaxOp τ σ ρ" | "τ ⊔ σ = ρ ⟹ ρ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type MinOp τ σ ρ" | "τ = UnlimitedNatural[1]─Real[1] ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type numeric_binop.LessOp τ σ Boolean[1]" | "τ = UnlimitedNatural[1]─Real[1] ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type numeric_binop.LessEqOp τ σ Boolean[1]" | "τ = UnlimitedNatural[1]─Real[1] ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type numeric_binop.GreaterOp τ σ Boolean[1]" | "τ = UnlimitedNatural[1]─Real[1] ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ numeric_binop_type numeric_binop.GreaterEqOp τ σ Boolean[1]" subsection ‹String Operations› inductive string_unop_type where "string_unop_type SizeOp String[1] Integer[1]" | "string_unop_type CharactersOp String[1] (Sequence String[1])" | "string_unop_type ToUpperCaseOp String[1] String[1]" | "string_unop_type ToLowerCaseOp String[1] String[1]" | "string_unop_type ToBooleanOp String[1] Boolean[1]" | "string_unop_type ToIntegerOp String[1] Integer[1]" | "string_unop_type ToRealOp String[1] Real[1]" inductive string_binop_type where "string_binop_type ConcatOp String[1] String[1] String[1]" | "string_binop_type EqualsIgnoreCaseOp String[1] String[1] Boolean[1]" | "string_binop_type LessOp String[1] String[1] Boolean[1]" | "string_binop_type LessEqOp String[1] String[1] Boolean[1]" | "string_binop_type GreaterOp String[1] String[1] Boolean[1]" | "string_binop_type GreaterEqOp String[1] String[1] Boolean[1]" | "string_binop_type IndexOfOp String[1] String[1] Integer[1]" | "τ = UnlimitedNatural[1]─Integer[1] ⟹ string_binop_type AtOp String[1] τ String[1]" inductive string_ternop_type where "σ = UnlimitedNatural[1]─Integer[1] ⟹ ρ = UnlimitedNatural[1]─Integer[1] ⟹ string_ternop_type SubstringOp String[1] σ ρ String[1]" subsection ‹Collection Operations› text ‹ Please take a note, that @{text "flatten()"} preserves a collection kind.› inductive collection_unop_type where "element_type τ _ ⟹ collection_unop_type CollectionSizeOp τ Integer[1]" | "element_type τ _ ⟹ collection_unop_type IsEmptyOp τ Boolean[1]" | "element_type τ _ ⟹ collection_unop_type NotEmptyOp τ Boolean[1]" | "element_type τ σ ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ collection_unop_type CollectionMaxOp τ σ" | "element_type τ σ ⟹ operation σ STR ''max'' [σ] oper ⟹ collection_unop_type CollectionMaxOp τ σ" | "element_type τ σ ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ collection_unop_type CollectionMinOp τ σ" | "element_type τ σ ⟹ operation σ STR ''min'' [σ] oper ⟹ collection_unop_type CollectionMinOp τ σ" | "element_type τ σ ⟹ σ = UnlimitedNatural[1]─Real[1] ⟹ collection_unop_type SumOp τ σ" | "element_type τ σ ⟹ operation σ STR ''+'' [σ] oper ⟹ collection_unop_type SumOp τ σ" | "element_type τ σ ⟹ collection_unop_type AsSetOp τ (Set σ)" | "element_type τ σ ⟹ collection_unop_type AsOrderedSetOp τ (OrderedSet σ)" | "element_type τ σ ⟹ collection_unop_type AsBagOp τ (Bag σ)" | "element_type τ σ ⟹ collection_unop_type AsSequenceOp τ (Sequence σ)" | "update_element_type τ (to_single_type τ) σ ⟹ collection_unop_type FlattenOp τ σ" | "collection_unop_type FirstOp (OrderedSet τ) τ" | "collection_unop_type FirstOp (Sequence τ) τ" | "collection_unop_type LastOp (OrderedSet τ) τ" | "collection_unop_type LastOp (Sequence τ) τ" | "collection_unop_type ReverseOp (OrderedSet τ) (OrderedSet τ)" | "collection_unop_type ReverseOp (Sequence τ) (Sequence τ)" text ‹ Please take a note that if both arguments are collections, then an element type of the resulting collection is a super type of element types of orginal collections. However for single-valued operations (@{text "append()"}, @{text "insertAt()"}, ...) this behavior looks undesirable. So we restrict such arguments to have a subtype of the collection element type.› text ‹ Please take a note that we allow the following expressions:› text ‹ ▩‹let nullable_value : Integer[?] = null in Sequence{1..3}->inculdes(nullable_value) and Sequence{1..3}->inculdes(null) and Sequence{1..3}->inculdesAll(Set{1,null})›› text ‹ The OCL specification defines @{text "including()"} and @{text "excluding()"} operations for the @{text Sequence} type but does not define them for the @{text OrderedSet} type. We define them for all collection types. It is a good idea to prohibit including of values that do not conform to a collection element type. However we do not restrict it. At first we defined the following typing rules for the @{text "excluding()"} operation: {\isacharbar}\ {\isachardoublequoteopen}element{\isacharunderscore}type\ {\isasymtau}\ {\isasymrho}\ {\isasymLongrightarrow}\ {\isasymsigma}\ {\isasymle}\ {\isasymrho}\ {\isasymLongrightarrow}\ {\isasymsigma}\ {\isasymnoteq}\ OclVoid{\isacharbrackleft}{\isacharquery}{\isacharbrackright}\ {\isasymLongrightarrow}\isanewline \ \ \ collection{\isacharunderscore}binop{\isacharunderscore}type\ ExcludingOp\ {\isasymtau}\ {\isasymsigma}\ {\isasymtau}{\isachardoublequoteclose}\isanewline {\isacharbar}\ {\isachardoublequoteopen}element{\isacharunderscore}type\ {\isasymtau}\ {\isasymrho}\ {\isasymLongrightarrow}\ {\isasymsigma}\ {\isasymle}\ {\isasymrho}\ {\isasymLongrightarrow}\ {\isasymsigma}\ {\isacharequal}\ OclVoid{\isacharbrackleft}{\isacharquery}{\isacharbrackright}\ {\isasymLongrightarrow}\isanewline \ \ \ update{\isacharunderscore}element{\isacharunderscore}type\ {\isasymtau}\ {\isacharparenleft}to{\isacharunderscore}required{\isacharunderscore}type\ {\isasymrho}{\isacharparenright}\ {\isasymupsilon}\ {\isasymLongrightarrow}\isanewline \ \ \ collection{\isacharunderscore}binop{\isacharunderscore}type\ ExcludingOp\ {\isasymtau}\ {\isasymsigma}\ {\isasymupsilon}{\isachardoublequoteclose}\isanewline This operation could play a special role in a definition of safe navigation operations:› text ‹ ▩‹Sequence{1,2,null}->exculding(null) : Integer[1]›› text ‹ However it is more natural to use a @{text "selectByKind(T[1])"} operation instead.› inductive collection_binop_type where "element_type τ ρ ⟹ σ ≤ to_optional_type_nested ρ ⟹ collection_binop_type IncludesOp τ σ Boolean[1]" | "element_type τ ρ ⟹ σ ≤ to_optional_type_nested ρ ⟹ collection_binop_type ExcludesOp τ σ Boolean[1]" | "element_type τ ρ ⟹ σ ≤ to_optional_type_nested ρ ⟹ collection_binop_type CountOp τ σ Integer[1]" | "element_type τ ρ ⟹ element_type σ υ ⟹ υ ≤ to_optional_type_nested ρ ⟹ collection_binop_type IncludesAllOp τ σ Boolean[1]" | "element_type τ ρ ⟹ element_type σ υ ⟹ υ ≤ to_optional_type_nested ρ ⟹ collection_binop_type ExcludesAllOp τ σ Boolean[1]" | "element_type τ ρ ⟹ element_type σ υ ⟹ collection_binop_type ProductOp τ σ (Set (Tuple (fmap_of_list [(STR ''first'', ρ), (STR ''second'', υ)])))" | "collection_binop_type UnionOp (Set τ) (Set σ) (Set (τ ⊔ σ))" | "collection_binop_type UnionOp (Set τ) (Bag σ) (Bag (τ ⊔ σ))" | "collection_binop_type UnionOp (Bag τ) (Set σ) (Bag (τ ⊔ σ))" | "collection_binop_type UnionOp (Bag τ) (Bag σ) (Bag (τ ⊔ σ))" | "collection_binop_type IntersectionOp (Set τ) (Set σ) (Set (τ ⊔ σ))" | "collection_binop_type IntersectionOp (Set τ) (Bag σ) (Set (τ ⊔ σ))" | "collection_binop_type IntersectionOp (Bag τ) (Set σ) (Set (τ ⊔ σ))" | "collection_binop_type IntersectionOp (Bag τ) (Bag σ) (Bag (τ ⊔ σ))" | "collection_binop_type SetMinusOp (Set τ) (Set σ) (Set τ)" | "collection_binop_type SymmetricDifferenceOp (Set τ) (Set σ) (Set (τ ⊔ σ))" | "element_type τ ρ ⟹ update_element_type τ (ρ ⊔ σ) υ ⟹ collection_binop_type IncludingOp τ σ υ" | "element_type τ ρ ⟹ σ ≤ ρ ⟹ collection_binop_type ExcludingOp τ σ τ" | "σ ≤ τ ⟹ collection_binop_type AppendOp (OrderedSet τ) σ (OrderedSet τ)" | "σ ≤ τ ⟹ collection_binop_type AppendOp (Sequence τ) σ (Sequence τ)" | "σ ≤ τ ⟹ collection_binop_type PrependOp (OrderedSet τ) σ (OrderedSet τ)" | "σ ≤ τ ⟹ collection_binop_type PrependOp (Sequence τ) σ (Sequence τ)" | "σ = UnlimitedNatural[1]─Integer[1] ⟹ collection_binop_type CollectionAtOp (OrderedSet τ) σ τ" | "σ = UnlimitedNatural[1]─Integer[1] ⟹ collection_binop_type CollectionAtOp (Sequence τ) σ τ" | "σ ≤ τ ⟹ collection_binop_type CollectionIndexOfOp (OrderedSet τ) σ Integer[1]" | "σ ≤ τ ⟹ collection_binop_type CollectionIndexOfOp (Sequence τ) σ Integer[1]" inductive collection_ternop_type where "σ = UnlimitedNatural[1]─Integer[1] ⟹ ρ ≤ τ ⟹ collection_ternop_type InsertAtOp (OrderedSet τ) σ ρ (OrderedSet τ)" | "σ = UnlimitedNatural[1]─Integer[1] ⟹ ρ ≤ τ ⟹ collection_ternop_type InsertAtOp (Sequence τ) σ ρ (Sequence τ)" | "σ = UnlimitedNatural[1]─Integer[1] ⟹ ρ = UnlimitedNatural[1]─Integer[1] ⟹ collection_ternop_type SubOrderedSetOp (OrderedSet τ) σ ρ (OrderedSet τ)" | "σ = UnlimitedNatural[1]─Integer[1] ⟹ ρ = UnlimitedNatural[1]─Integer[1] ⟹ collection_ternop_type SubSequenceOp (Sequence τ) σ ρ (Sequence τ)" subsection ‹Coercions› inductive unop_type where "any_unop_type op τ σ ⟹ unop_type (Inl op) DotCall τ σ" | "boolean_unop_type op τ σ ⟹ unop_type (Inr (Inl op)) DotCall τ σ" | "numeric_unop_type op τ σ ⟹ unop_type (Inr (Inr (Inl op))) DotCall τ σ" | "string_unop_type op τ σ ⟹ unop_type (Inr (Inr (Inr (Inl op)))) DotCall τ σ" | "collection_unop_type op τ σ ⟹ unop_type (Inr (Inr (Inr (Inr op)))) ArrowCall τ σ" inductive binop_type where "super_binop_type op τ σ ρ ⟹ binop_type (Inl op) DotCall τ σ ρ" | "boolean_binop_type op τ σ ρ ⟹ binop_type (Inr (Inl op)) DotCall τ σ ρ" | "numeric_binop_type op τ σ ρ ⟹ binop_type (Inr (Inr (Inl op))) DotCall τ σ ρ" | "string_binop_type op τ σ ρ ⟹ binop_type (Inr (Inr (Inr (Inl op)))) DotCall τ σ ρ" | "collection_binop_type op τ σ ρ ⟹ binop_type (Inr (Inr (Inr (Inr op)))) ArrowCall τ σ ρ" inductive ternop_type where "string_ternop_type op τ σ ρ υ ⟹ ternop_type (Inl op) DotCall τ σ ρ υ" | "collection_ternop_type op τ σ ρ υ ⟹ ternop_type (Inr op) ArrowCall τ σ ρ υ" inductive op_type where "unop_type op k τ υ ⟹ op_type (Inl op) k τ [] υ" | "binop_type op k τ σ υ ⟹ op_type (Inr (Inl op)) k τ [σ] υ" | "ternop_type op k τ σ ρ υ ⟹ op_type (Inr (Inr (Inl op))) k τ [σ, ρ] υ" | "operation τ op π oper ⟹ op_type (Inr (Inr (Inr op))) DotCall τ π (oper_type oper)" (*** Simplification Rules ***************************************************) subsection ‹Simplification Rules› inductive_simps op_type_alt_simps: "mataop_type τ op σ" "typeop_type k op τ σ ρ" "op_type op k τ π σ" "unop_type op k τ σ" "binop_type op k τ σ ρ" "ternop_type op k τ σ ρ υ" "any_unop_type op τ σ" "boolean_unop_type op τ σ" "numeric_unop_type op τ σ" "string_unop_type op τ σ" "collection_unop_type op τ σ" "super_binop_type op τ σ ρ" "boolean_binop_type op τ σ ρ" "numeric_binop_type op τ σ ρ" "string_binop_type op τ σ ρ" "collection_binop_type op τ σ ρ" "string_ternop_type op τ σ ρ υ" "collection_ternop_type op τ σ ρ υ" (*** Determinism ************************************************************) subsection ‹Determinism› lemma typeop_type_det: "typeop_type op k τ σ ρ₁ ⟹ typeop_type op k τ σ ρ₂ ⟹ ρ₁ = ρ₂" apply ((induct rule: typeop_type.induct (*‹⟦typeop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0; ⋀σ τ. σ < τ ∨ τ < σ ⟹ ?P DotCall OclAsTypeOp τ σ σ; ⋀σ τ. σ < τ ⟹ ?P DotCall OclIsTypeOfOp τ σ Boolean[1]; ⋀σ τ. σ < τ ⟹ ?P DotCall OclIsKindOfOp τ σ Boolean[1]; ⋀τ ρ σ υ. ⟦element_type τ ρ; σ < ρ; update_element_type τ σ υ⟧ ⟹ ?P ArrowCall SelectByKindOp τ σ υ; ⋀τ ρ σ υ. ⟦element_type τ ρ; σ < ρ; update_element_type τ σ υ⟧ ⟹ ?P ArrowCall SelectByTypeOp τ σ υ⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0›*))[1]) (*goals: 1. ‹⋀(σ::'a OCL_Types.type) τ::'a OCL_Types.type. ⟦σ < τ ∨ τ < σ; typeop_type DotCall OclAsTypeOp τ σ (ρ₂::'a OCL_Types.type)⟧ ⟹ σ = ρ₂› 2. ‹⋀(σ::'a OCL_Types.type) τ::'a OCL_Types.type. ⟦σ < τ; typeop_type DotCall OclIsTypeOfOp τ σ (ρ₂::'a OCL_Types.type)⟧ ⟹ Boolean[1] = ρ₂› 3. ‹⋀(σ::'a OCL_Types.type) τ::'a OCL_Types.type. ⟦σ < τ; typeop_type DotCall OclIsKindOfOp τ σ (ρ₂::'a OCL_Types.type)⟧ ⟹ Boolean[1] = ρ₂› 4. ‹⋀(τ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (σ::'a OCL_Types.type) υ::'a OCL_Types.type. ⟦element_type τ ρ; σ < ρ; update_element_type τ σ υ; typeop_type ArrowCall SelectByKindOp τ σ (ρ₂::'a OCL_Types.type)⟧ ⟹ υ = ρ₂› 5. ‹⋀(τ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (σ::'a OCL_Types.type) υ::'a OCL_Types.type. ⟦element_type τ ρ; σ < ρ; update_element_type τ σ υ; typeop_type ArrowCall SelectByTypeOp τ σ (ρ₂::'a OCL_Types.type)⟧ ⟹ υ = ρ₂› discuss goal 1*) apply ((auto simp add: typeop_type.simps (*‹typeop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclAsTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = σ ∧ (σ < τ ∨ τ < σ)) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsTypeOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsKindOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByKindOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ))›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: typeop_type.simps (*‹typeop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclAsTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = σ ∧ (σ < τ ∨ τ < σ)) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsTypeOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsKindOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByKindOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ))›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: typeop_type.simps (*‹typeop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclAsTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = σ ∧ (σ < τ ∨ τ < σ)) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsTypeOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsKindOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByKindOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ))›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: typeop_type.simps (*‹typeop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclAsTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = σ ∧ (σ < τ ∨ τ < σ)) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsTypeOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃σ τ. ?a1.0 = DotCall ∧ ?a2.0 = OclIsKindOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByKindOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ) ∨ (∃τ ρ σ υ. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ))›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: typeop_type.simps (*‹typeop_type (?a1.0::call_kind) (?a2.0::typeop) (?a3.0::?'a::order OCL_Types.type) (?a4.0::?'a::order OCL_Types.type) (?a5.0::?'a::order OCL_Types.type) = ((∃(σ::?'a::order OCL_Types.type) τ::?'a::order OCL_Types.type. ?a1.0 = DotCall ∧ ?a2.0 = OclAsTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = σ ∧ (σ < τ ∨ τ < σ)) ∨ (∃(σ::?'a::order OCL_Types.type) τ::?'a::order OCL_Types.type. ?a1.0 = DotCall ∧ ?a2.0 = OclIsTypeOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃(σ::?'a::order OCL_Types.type) τ::?'a::order OCL_Types.type. ?a1.0 = DotCall ∧ ?a2.0 = OclIsKindOfOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = Boolean[1] ∧ σ < τ) ∨ (∃(τ::?'a::order OCL_Types.type) (ρ::?'a::order OCL_Types.type) (σ::?'a::order OCL_Types.type) υ::?'a::order OCL_Types.type. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByKindOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ) ∨ (∃(τ::?'a::order OCL_Types.type) (ρ::?'a::order OCL_Types.type) (σ::?'a::order OCL_Types.type) υ::?'a::order OCL_Types.type. ?a1.0 = ArrowCall ∧ ?a2.0 = SelectByTypeOp ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = υ ∧ element_type τ ρ ∧ σ < ρ ∧ update_element_type τ σ υ))›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 5 subgoals*) . lemma any_unop_type_det: "any_unop_type op τ σ₁ ⟹ any_unop_type op τ σ₂ ⟹ σ₁ = σ₂" apply (induct rule: any_unop_type.induct (*‹⟦any_unop_type ?x1.0 ?x2.0 ?x3.0; ⋀τ. τ ≤ OclAny[?] ⟹ ?P OclAsSetOp τ (Set (to_required_type τ)); ⋀τ. τ ≤ OclAny[?] ⟹ ?P OclIsNewOp τ Boolean[1]; ⋀τ. τ ≤ OclAny[?] ⟹ ?P OclIsUndefinedOp τ Boolean[1]; ⋀τ. τ ≤ OclAny[?] ⟹ ?P OclIsInvalidOp τ Boolean[1]; ⋀τ. τ ≤ OclAny[?] ⟹ ?P OclLocaleOp τ String[1]; ⋀τ. τ ≤ OclAny[?] ⟹ ?P ToStringOp τ String[1]⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀τ::'a::order OCL_Types.type. ⟦τ ≤ OclAny[?]; any_unop_type OclAsSetOp τ (σ₂::'a::order OCL_Types.type)⟧ ⟹ Set (to_required_type τ) = σ₂› 2. ‹⋀τ::'a::order OCL_Types.type. ⟦τ ≤ OclAny[?]; any_unop_type OclIsNewOp τ (σ₂::'a::order OCL_Types.type)⟧ ⟹ Boolean[1] = σ₂› 3. ‹⋀τ::'a::order OCL_Types.type. ⟦τ ≤ OclAny[?]; any_unop_type OclIsUndefinedOp τ (σ₂::'a::order OCL_Types.type)⟧ ⟹ Boolean[1] = σ₂› 4. ‹⋀τ::'a::order OCL_Types.type. ⟦τ ≤ OclAny[?]; any_unop_type OclIsInvalidOp τ (σ₂::'a::order OCL_Types.type)⟧ ⟹ Boolean[1] = σ₂› 5. ‹⋀τ::'a::order OCL_Types.type. ⟦τ ≤ OclAny[?]; any_unop_type OclLocaleOp τ (σ₂::'a::order OCL_Types.type)⟧ ⟹ String[1] = σ₂› 6. ‹⋀τ::'a::order OCL_Types.type. ⟦τ ≤ OclAny[?]; any_unop_type ToStringOp τ (σ₂::'a::order OCL_Types.type)⟧ ⟹ String[1] = σ₂› discuss goal 1*) apply (simp add: any_unop_type.simps (*‹any_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = OclAsSetOp ∧ ?a2.0 = τ ∧ ?a3.0 = Set (to_required_type τ) ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsNewOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsUndefinedOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsInvalidOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclLocaleOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = ToStringOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]))›*)) (*discuss goal 2*) apply (simp add: any_unop_type.simps (*‹any_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = OclAsSetOp ∧ ?a2.0 = τ ∧ ?a3.0 = Set (to_required_type τ) ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsNewOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsUndefinedOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsInvalidOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclLocaleOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = ToStringOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]))›*)) (*discuss goal 3*) apply (simp add: any_unop_type.simps (*‹any_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = OclAsSetOp ∧ ?a2.0 = τ ∧ ?a3.0 = Set (to_required_type τ) ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsNewOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsUndefinedOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsInvalidOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclLocaleOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = ToStringOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]))›*)) (*discuss goal 4*) apply (simp add: any_unop_type.simps (*‹any_unop_type (?a1.0::any_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'a OCL_Types.type) = ((∃τ::?'a OCL_Types.type. ?a1.0 = OclAsSetOp ∧ ?a2.0 = τ ∧ ?a3.0 = Set (to_required_type τ) ∧ τ ≤ OclAny[?]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = OclIsNewOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = OclIsUndefinedOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = OclIsInvalidOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = OclLocaleOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = ToStringOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]))›*)) (*discuss goal 5*) apply (simp add: any_unop_type.simps (*‹any_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = OclAsSetOp ∧ ?a2.0 = τ ∧ ?a3.0 = Set (to_required_type τ) ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsNewOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsUndefinedOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsInvalidOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclLocaleOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = ToStringOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]))›*)) (*discuss goal 6*) apply (simp add: any_unop_type.simps (*‹any_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = OclAsSetOp ∧ ?a2.0 = τ ∧ ?a3.0 = Set (to_required_type τ) ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsNewOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsUndefinedOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclIsInvalidOp ∧ ?a2.0 = τ ∧ ?a3.0 = Boolean[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = OclLocaleOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]) ∨ (∃τ. ?a1.0 = ToStringOp ∧ ?a2.0 = τ ∧ ?a3.0 = String[1] ∧ τ ≤ OclAny[?]))›*)) (*proven 6 subgoals*) . lemma boolean_unop_type_det: "boolean_unop_type op τ σ₁ ⟹ boolean_unop_type op τ σ₂ ⟹ σ₁ = σ₂" apply (induct rule: boolean_unop_type.induct (*‹⟦boolean_unop_type ?x1.0 ?x2.0 ?x3.0; ⋀τ. τ ≤ Boolean[?] ⟹ ?P NotOp τ τ⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goal: ‹⟦boolean_unop_type op τ σ₁; boolean_unop_type op τ σ₂⟧ ⟹ σ₁ = σ₂›*) by (simp add: boolean_unop_type.simps (*‹boolean_unop_type ?a1.0 ?a2.0 ?a3.0 = (∃τ. ?a1.0 = NotOp ∧ ?a2.0 = τ ∧ ?a3.0 = τ ∧ τ ≤ Boolean[?])›*)) lemma numeric_unop_type_det: "numeric_unop_type op τ σ₁ ⟹ numeric_unop_type op τ σ₂ ⟹ σ₁ = σ₂" apply ((induct rule: numeric_unop_type.induct (*‹⟦numeric_unop_type (?x1.0::numeric_unop) (?x2.0::?'a::order OCL_Types.type) (?x3.0::?'b::order OCL_Types.type); ⋀τ::?'a::order OCL_Types.type. τ = Real[1] ⟹ (?P::numeric_unop ⇒ ?'a::order OCL_Types.type ⇒ ?'b::order OCL_Types.type ⇒ bool) UMinusOp τ Real[1]; ⋀τ::?'a::order OCL_Types.type. τ = UnlimitedNatural[1]─Integer[1] ⟹ ?P UMinusOp τ Integer[1]; ⋀τ::?'a::order OCL_Types.type. τ = Real[1] ⟹ ?P AbsOp τ Real[1]; ⋀τ::?'a::order OCL_Types.type. τ = UnlimitedNatural[1]─Integer[1] ⟹ ?P AbsOp τ Integer[1]; ⋀τ::?'a::order OCL_Types.type. τ = UnlimitedNatural[1]─Real[1] ⟹ ?P FloorOp τ Integer[1]; ⋀τ::?'a::order OCL_Types.type. τ = UnlimitedNatural[1]─Real[1] ⟹ ?P RoundOp τ Integer[1]; ⋀τ::?'a::order OCL_Types.type. τ = UnlimitedNatural[1] ⟹ ?P numeric_unop.ToIntegerOp τ Integer[1]⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*))[1]) (*goals: 1. ‹⋀τ. ⟦τ = Real[1]; numeric_unop_type UMinusOp τ σ₂⟧ ⟹ Real[1] = σ₂› 2. ‹⋀τ. ⟦τ = UnlimitedNatural[1]─Integer[1]; numeric_unop_type UMinusOp τ σ₂⟧ ⟹ Integer[1] = σ₂› 3. ‹⋀τ. ⟦τ = Real[1]; numeric_unop_type AbsOp τ σ₂⟧ ⟹ Real[1] = σ₂› 4. ‹⋀τ. ⟦τ = UnlimitedNatural[1]─Integer[1]; numeric_unop_type AbsOp τ σ₂⟧ ⟹ Integer[1] = σ₂› 5. ‹⋀τ. ⟦τ = UnlimitedNatural[1]─Real[1]; numeric_unop_type FloorOp τ σ₂⟧ ⟹ Integer[1] = σ₂› 6. ‹⋀τ. ⟦τ = UnlimitedNatural[1]─Real[1]; numeric_unop_type RoundOp τ σ₂⟧ ⟹ Integer[1] = σ₂› 7. ‹⋀τ. ⟦τ = UnlimitedNatural[1]; numeric_unop_type numeric_unop.ToIntegerOp τ σ₂⟧ ⟹ Integer[1] = σ₂› discuss goal 1*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type (?a1.0::numeric_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'b OCL_Types.type) = ((∃τ::?'a OCL_Types.type. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*discuss goal 2*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*discuss goal 3*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*discuss goal 4*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*discuss goal 5*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type (?a1.0::numeric_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'b OCL_Types.type) = ((∃τ::?'a OCL_Types.type. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ::?'a OCL_Types.type. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*discuss goal 6*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*discuss goal 7*) apply ((auto simp add: numeric_unop_type.simps (*‹numeric_unop_type ?a1.0 ?a2.0 ?a3.0 = ((∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = UMinusOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Real[1] ∧ τ = Real[1]) ∨ (∃τ. ?a1.0 = AbsOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Integer[1]) ∨ (∃τ. ?a1.0 = FloorOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = RoundOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]─Real[1]) ∨ (∃τ. ?a1.0 = numeric_unop.ToIntegerOp ∧ ?a2.0 = τ ∧ ?a3.0 = Integer[1] ∧ τ = UnlimitedNatural[1]))›*))[1]) (*proven 7 subgoals*) . lemma string_unop_type_det: "string_unop_type op τ σ₁ ⟹ string_unop_type op τ σ₂ ⟹ σ₁ = σ₂" apply (induct rule: string_unop_type.induct (*‹⟦string_unop_type ?x1.0 ?x2.0 ?x3.0; ?P SizeOp String[1] Integer[1]; ?P CharactersOp String[1] (Sequence String[1]); ?P ToUpperCaseOp String[1] String[1]; ?P ToLowerCaseOp String[1] String[1]; ?P ToBooleanOp String[1] Boolean[1]; ?P string_unop.ToIntegerOp String[1] Integer[1]; ?P ToRealOp String[1] Real[1]⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹string_unop_type SizeOp String[1] σ₂ ⟹ Integer[1] = σ₂› 2. ‹string_unop_type CharactersOp String[1] σ₂ ⟹ Sequence String[1] = σ₂› 3. ‹string_unop_type ToUpperCaseOp String[1] σ₂ ⟹ String[1] = σ₂› 4. ‹string_unop_type ToLowerCaseOp String[1] σ₂ ⟹ String[1] = σ₂› 5. ‹string_unop_type ToBooleanOp String[1] σ₂ ⟹ Boolean[1] = σ₂› 6. ‹string_unop_type string_unop.ToIntegerOp String[1] σ₂ ⟹ Integer[1] = σ₂› 7. ‹string_unop_type ToRealOp String[1] σ₂ ⟹ Real[1] = σ₂› discuss goal 1*) apply (simp add: string_unop_type.simps (*‹string_unop_type (?a1.0::string_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'b OCL_Types.type) = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*discuss goal 2*) apply (simp add: string_unop_type.simps (*‹string_unop_type (?a1.0::string_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'b OCL_Types.type) = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*discuss goal 3*) apply (simp add: string_unop_type.simps (*‹string_unop_type ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*discuss goal 4*) apply (simp add: string_unop_type.simps (*‹string_unop_type ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*discuss goal 5*) apply (simp add: string_unop_type.simps (*‹string_unop_type ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*discuss goal 6*) apply (simp add: string_unop_type.simps (*‹string_unop_type ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*discuss goal 7*) apply (simp add: string_unop_type.simps (*‹string_unop_type ?a1.0 ?a2.0 ?a3.0 = (?a1.0 = SizeOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = CharactersOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Sequence String[1] ∨ ?a1.0 = ToUpperCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToLowerCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∨ ?a1.0 = ToBooleanOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Boolean[1] ∨ ?a1.0 = string_unop.ToIntegerOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Integer[1] ∨ ?a1.0 = ToRealOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = Real[1])›*)) (*proven 7 subgoals*) . lemma collection_unop_type_det: "collection_unop_type op τ σ₁ ⟹ collection_unop_type op τ σ₂ ⟹ σ₁ = σ₂" apply ((induct rule: collection_unop_type.induct (*‹⟦collection_unop_type ?x1.0 ?x2.0 ?x3.0; ⋀τ uu_. element_type τ uu_ ⟹ ?P CollectionSizeOp τ Integer[1]; ⋀τ uv_. element_type τ uv_ ⟹ ?P IsEmptyOp τ Boolean[1]; ⋀τ uw_. element_type τ uw_ ⟹ ?P NotEmptyOp τ Boolean[1]; ⋀τ σ. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P CollectionMaxOp τ σ; ⋀τ σ oper. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P CollectionMaxOp τ σ; ⋀τ σ. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P CollectionMinOp τ σ; ⋀τ σ oper. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P CollectionMinOp τ σ; ⋀τ σ. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P SumOp τ σ; ⋀τ σ oper. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P SumOp τ σ; ⋀τ σ. element_type τ σ ⟹ ?P AsSetOp τ (Set σ); ⋀τ σ. element_type τ σ ⟹ ?P AsOrderedSetOp τ (OrderedSet σ); ⋀τ σ. element_type τ σ ⟹ ?P AsBagOp τ (Bag σ); ⋀τ σ. element_type τ σ ⟹ ?P AsSequenceOp τ (Sequence σ); ⋀τ σ. update_element_type τ (to_single_type τ) σ ⟹ ?P FlattenOp τ σ; ⋀τ. ?P FirstOp (OrderedSet τ) τ; ⋀τ. ?P FirstOp (Sequence τ) τ; ⋀τ. ?P LastOp (OrderedSet τ) τ; ⋀τ. ?P LastOp (Sequence τ) τ; ⋀τ. ?P ReverseOp (OrderedSet τ) (OrderedSet τ); ⋀τ. ?P ReverseOp (Sequence τ) (Sequence τ)⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*))[1]) (*goals: 1. ‹⋀τ uu_. ⟦element_type τ uu_; collection_unop_type CollectionSizeOp τ σ₂⟧ ⟹ Integer[1] = σ₂› 2. ‹⋀τ uv_. ⟦element_type τ uv_; collection_unop_type IsEmptyOp τ σ₂⟧ ⟹ Boolean[1] = σ₂› 3. ‹⋀τ uw_. ⟦element_type τ uw_; collection_unop_type NotEmptyOp τ σ₂⟧ ⟹ Boolean[1] = σ₂› 4. ‹⋀τ σ. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; collection_unop_type CollectionMaxOp τ σ₂⟧ ⟹ σ = σ₂› 5. ‹⋀τ σ oper. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; collection_unop_type CollectionMaxOp τ σ₂⟧ ⟹ σ = σ₂› 6. ‹⋀τ σ. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; collection_unop_type CollectionMinOp τ σ₂⟧ ⟹ σ = σ₂› 7. ‹⋀τ σ oper. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; collection_unop_type CollectionMinOp τ σ₂⟧ ⟹ σ = σ₂› 8. ‹⋀τ σ. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; collection_unop_type SumOp τ σ₂⟧ ⟹ σ = σ₂› 9. ‹⋀τ σ oper. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; collection_unop_type SumOp τ σ₂⟧ ⟹ σ = σ₂› 10. ‹⋀τ σ. ⟦element_type τ σ; collection_unop_type AsSetOp τ σ₂⟧ ⟹ Set σ = σ₂› 11. ‹⋀τ σ. ⟦element_type τ σ; collection_unop_type AsOrderedSetOp τ σ₂⟧ ⟹ OrderedSet σ = σ₂› 12. ‹⋀τ σ. ⟦element_type τ σ; collection_unop_type AsBagOp τ σ₂⟧ ⟹ Bag σ = σ₂› 13. ‹⋀τ σ. ⟦element_type τ σ; collection_unop_type AsSequenceOp τ σ₂⟧ ⟹ Sequence σ = σ₂› 14. ‹⋀τ σ. ⟦update_element_type τ (to_single_type τ) σ; collection_unop_type FlattenOp τ σ₂⟧ ⟹ σ = σ₂› 15. ‹⋀τ. collection_unop_type FirstOp (OrderedSet τ) σ₂ ⟹ τ = σ₂› 16. ‹⋀τ. collection_unop_type FirstOp (Sequence τ) σ₂ ⟹ τ = σ₂› 17. ‹⋀τ. collection_unop_type LastOp (OrderedSet τ) σ₂ ⟹ τ = σ₂› 18. ‹⋀τ. collection_unop_type LastOp (Sequence τ) σ₂ ⟹ τ = σ₂› 19. ‹⋀τ. collection_unop_type ReverseOp (OrderedSet τ) σ₂ ⟹ OrderedSet τ = σ₂› 20. ‹⋀τ. collection_unop_type ReverseOp (Sequence τ) σ₂ ⟹ Sequence τ = σ₂› discuss goal 1*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ uu_ τ' uua_. ⟦element_type τ uu_; CollectionSizeOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uua_⟧ ⟹ Integer[1] = σ₂› 2. ‹⋀τ uu_ τ' uv_. ⟦element_type τ uu_; CollectionSizeOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ Integer[1] = σ₂› 3. ‹⋀τ uu_ τ' uw_. ⟦element_type τ uu_; CollectionSizeOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ Integer[1] = σ₂› 4. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = CollectionMaxOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Integer[1] = σ₂› 5. ‹⋀τ uu_ τ' σ oper. ⟦element_type τ uu_; CollectionSizeOp = CollectionMaxOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ Integer[1] = σ₂› 6. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = CollectionMinOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Integer[1] = σ₂› 7. ‹⋀τ uu_ τ' σ oper. ⟦element_type τ uu_; CollectionSizeOp = CollectionMinOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ Integer[1] = σ₂› 8. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = SumOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Integer[1] = σ₂› 9. ‹⋀τ uu_ τ' σ oper. ⟦element_type τ uu_; CollectionSizeOp = SumOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ Integer[1] = σ₂› 10. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = AsSetOp; τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ Integer[1] = σ₂› 11. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ Integer[1] = σ₂› 12. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = AsBagOp; τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ Integer[1] = σ₂› 13. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ Integer[1] = σ₂› 14. ‹⋀τ uu_ τ' σ. ⟦element_type τ uu_; CollectionSizeOp = FlattenOp; τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ Integer[1] = σ₂› 15. ‹⋀τ uu_ τ'. ⟦element_type τ uu_; CollectionSizeOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Integer[1] = σ₂› 16. ‹⋀τ uu_ τ'. ⟦element_type τ uu_; CollectionSizeOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Integer[1] = σ₂› 17. ‹⋀τ uu_ τ'. ⟦element_type τ uu_; CollectionSizeOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Integer[1] = σ₂› 18. ‹⋀τ uu_ τ'. ⟦element_type τ uu_; CollectionSizeOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Integer[1] = σ₂› 19. ‹⋀τ uu_ τ'. ⟦element_type τ uu_; CollectionSizeOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Integer[1] = σ₂› 20. ‹⋀τ uu_ τ'. ⟦element_type τ uu_; CollectionSizeOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Integer[1] = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 2*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ uv_ τ' uu_. ⟦element_type τ uv_; IsEmptyOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ Boolean[1] = σ₂› 2. ‹⋀τ uv_ τ' uva_. ⟦element_type τ uv_; IsEmptyOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uva_⟧ ⟹ Boolean[1] = σ₂› 3. ‹⋀τ uv_ τ' uw_. ⟦element_type τ uv_; IsEmptyOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ Boolean[1] = σ₂› 4. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = CollectionMaxOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Boolean[1] = σ₂› 5. ‹⋀τ uv_ τ' σ oper. ⟦element_type τ uv_; IsEmptyOp = CollectionMaxOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ Boolean[1] = σ₂› 6. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = CollectionMinOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Boolean[1] = σ₂› 7. ‹⋀τ uv_ τ' σ oper. ⟦element_type τ uv_; IsEmptyOp = CollectionMinOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ Boolean[1] = σ₂› 8. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = SumOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Boolean[1] = σ₂› 9. ‹⋀τ uv_ τ' σ oper. ⟦element_type τ uv_; IsEmptyOp = SumOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ Boolean[1] = σ₂› 10. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = AsSetOp; τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 11. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 12. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = AsBagOp; τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 13. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 14. ‹⋀τ uv_ τ' σ. ⟦element_type τ uv_; IsEmptyOp = FlattenOp; τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ Boolean[1] = σ₂› 15. ‹⋀τ uv_ τ'. ⟦element_type τ uv_; IsEmptyOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 16. ‹⋀τ uv_ τ'. ⟦element_type τ uv_; IsEmptyOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 17. ‹⋀τ uv_ τ'. ⟦element_type τ uv_; IsEmptyOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 18. ‹⋀τ uv_ τ'. ⟦element_type τ uv_; IsEmptyOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 19. ‹⋀τ uv_ τ'. ⟦element_type τ uv_; IsEmptyOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Boolean[1] = σ₂› 20. ‹⋀τ uv_ τ'. ⟦element_type τ uv_; IsEmptyOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Boolean[1] = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 3*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ uw_ τ' uu_. ⟦element_type τ uw_; NotEmptyOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ Boolean[1] = σ₂› 2. ‹⋀τ uw_ τ' uv_. ⟦element_type τ uw_; NotEmptyOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ Boolean[1] = σ₂› 3. ‹⋀τ uw_ τ' uwa_. ⟦element_type τ uw_; NotEmptyOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uwa_⟧ ⟹ Boolean[1] = σ₂› 4. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = CollectionMaxOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Boolean[1] = σ₂› 5. ‹⋀τ uw_ τ' σ oper. ⟦element_type τ uw_; NotEmptyOp = CollectionMaxOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ Boolean[1] = σ₂› 6. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = CollectionMinOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Boolean[1] = σ₂› 7. ‹⋀τ uw_ τ' σ oper. ⟦element_type τ uw_; NotEmptyOp = CollectionMinOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ Boolean[1] = σ₂› 8. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = SumOp; τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Boolean[1] = σ₂› 9. ‹⋀τ uw_ τ' σ oper. ⟦element_type τ uw_; NotEmptyOp = SumOp; τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ Boolean[1] = σ₂› 10. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = AsSetOp; τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 11. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 12. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = AsBagOp; τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 13. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ Boolean[1] = σ₂› 14. ‹⋀τ uw_ τ' σ. ⟦element_type τ uw_; NotEmptyOp = FlattenOp; τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ Boolean[1] = σ₂› 15. ‹⋀τ uw_ τ'. ⟦element_type τ uw_; NotEmptyOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 16. ‹⋀τ uw_ τ'. ⟦element_type τ uw_; NotEmptyOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 17. ‹⋀τ uw_ τ'. ⟦element_type τ uw_; NotEmptyOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 18. ‹⋀τ uw_ τ'. ⟦element_type τ uw_; NotEmptyOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Boolean[1] = σ₂› 19. ‹⋀τ uw_ τ'. ⟦element_type τ uw_; NotEmptyOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Boolean[1] = σ₂› 20. ‹⋀τ uw_ τ'. ⟦element_type τ uw_; NotEmptyOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Boolean[1] = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 4*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) uu_::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = CollectionSizeOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) uv_::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = IsEmptyOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) uw_::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = NotEmptyOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = CollectionMaxOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = CollectionMaxOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ σ = σ₂› 6. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = CollectionMinOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = CollectionMinOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ σ = σ₂› 8. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = SumOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = SumOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ σ = σ₂› 10. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = AsSetOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = AsOrderedSetOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = AsBagOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = AsSequenceOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = FlattenOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = FirstOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = FirstOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = LastOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = LastOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = ReverseOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMaxOp = ReverseOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 5*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ oper τ' uu_. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀τ σ oper τ' uv_. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀τ σ oper τ' uw_. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀τ σ oper τ' σ' opera. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] opera⟧ ⟹ σ = σ₂› 6. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀τ σ oper τ' σ' opera. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] opera⟧ ⟹ σ = σ₂› 8. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀τ σ oper τ' σ' opera. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] opera⟧ ⟹ σ = σ₂› 10. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''max'' [σ] oper; CollectionMaxOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 6*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type (?a1.0::collection_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'a OCL_Types.type); ⋀(τ::?'a OCL_Types.type) uu_::?'a OCL_Types.type. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P::bool; ⋀(τ::?'a OCL_Types.type) uv_::?'a OCL_Types.type. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) uw_::?'a OCL_Types.type. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ τ' uu_. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀τ σ τ' uv_. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀τ σ τ' uw_. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ σ = σ₂› 6. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ σ = σ₂› 8. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ σ = σ₂› 10. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀τ σ τ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀τ σ τ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀τ σ τ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀τ σ τ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀τ σ τ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀τ σ τ'. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; CollectionMinOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 7*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) uu_::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = CollectionSizeOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) uv_::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = IsEmptyOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) uw_::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = NotEmptyOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = CollectionMaxOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) opera::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = CollectionMaxOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] opera⟧ ⟹ σ = σ₂› 6. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = CollectionMinOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) opera::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = CollectionMinOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] opera⟧ ⟹ σ = σ₂› 8. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = SumOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) opera::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = SumOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] opera⟧ ⟹ σ = σ₂› 10. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = AsSetOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = AsOrderedSetOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = AsBagOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = AsSequenceOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = FlattenOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = FirstOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = FirstOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = LastOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = LastOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = ReverseOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) τ'::'a::ocl_object_model OCL_Types.type. ⟦element_type τ σ; operation σ STR ''min'' [σ] oper; CollectionMinOp = ReverseOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 8*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type (?a1.0::collection_unop) (?a2.0::?'a::ocl_object_model OCL_Types.type) (?a3.0::?'a::ocl_object_model OCL_Types.type); ⋀(τ::?'a::ocl_object_model OCL_Types.type) uu_::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P::bool; ⋀(τ::?'a::ocl_object_model OCL_Types.type) uv_::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) uw_::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) (σ::?'a::ocl_object_model OCL_Types.type) oper::String.literal × ?'a::ocl_object_model OCL_Types.type × (String.literal × ?'a::ocl_object_model OCL_Types.type × param_dir) list × ?'a::ocl_object_model OCL_Types.type × bool × ?'a::ocl_object_model expr option. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) (σ::?'a::ocl_object_model OCL_Types.type) oper::String.literal × ?'a::ocl_object_model OCL_Types.type × (String.literal × ?'a::ocl_object_model OCL_Types.type × param_dir) list × ?'a::ocl_object_model OCL_Types.type × bool × ?'a::ocl_object_model expr option. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) (σ::?'a::ocl_object_model OCL_Types.type) oper::String.literal × ?'a::ocl_object_model OCL_Types.type × (String.literal × ?'a::ocl_object_model OCL_Types.type × param_dir) list × ?'a::ocl_object_model OCL_Types.type × bool × ?'a::ocl_object_model expr option. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) uu_::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = CollectionSizeOp; τ = τ'; (σ₂::'a OCL_Types.type) = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) uv_::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = IsEmptyOp; τ = τ'; (σ₂::'a OCL_Types.type) = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) uw_::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = NotEmptyOp; τ = τ'; (σ₂::'a OCL_Types.type) = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = CollectionMaxOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) (σ'::'a OCL_Types.type) oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = CollectionMaxOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ σ = σ₂› 6. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = CollectionMinOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) (σ'::'a OCL_Types.type) oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = CollectionMinOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ σ = σ₂› 8. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = SumOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) (σ'::'a OCL_Types.type) oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = SumOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ σ = σ₂› 10. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = AsSetOp; τ = τ'; (σ₂::'a OCL_Types.type) = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = AsOrderedSetOp; τ = τ'; (σ₂::'a OCL_Types.type) = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = AsBagOp; τ = τ'; (σ₂::'a OCL_Types.type) = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = AsSequenceOp; τ = τ'; (σ₂::'a OCL_Types.type) = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = FlattenOp; τ = τ'; (σ₂::'a OCL_Types.type) = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = FirstOp; τ = OrderedSet τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = FirstOp; τ = Sequence τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = LastOp; τ = OrderedSet τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = LastOp; τ = Sequence τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = ReverseOp; τ = OrderedSet τ'; (σ₂::'a OCL_Types.type) = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀(τ::'a OCL_Types.type) (σ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦element_type τ σ; σ = UnlimitedNatural[1]─Real[1]; SumOp = ReverseOp; τ = Sequence τ'; (σ₂::'a OCL_Types.type) = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 9*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type (?a1.0::collection_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'a OCL_Types.type); ⋀(τ::?'a OCL_Types.type) uu_::?'a OCL_Types.type. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P::bool; ⋀(τ::?'a OCL_Types.type) uv_::?'a OCL_Types.type. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) uw_::?'a OCL_Types.type. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ oper τ' uu_. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀τ σ oper τ' uv_. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀τ σ oper τ' uw_. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀τ σ oper τ' σ' opera. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] opera⟧ ⟹ σ = σ₂› 6. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀τ σ oper τ' σ' opera. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] opera⟧ ⟹ σ = σ₂› 8. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀τ σ oper τ' σ' opera. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] opera⟧ ⟹ σ = σ₂› 10. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀τ σ oper τ' σ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀τ σ oper τ'. ⟦element_type τ σ; operation σ STR ''+'' [σ] oper; SumOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 10*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type (?a1.0::collection_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'a OCL_Types.type); ⋀(τ::?'a OCL_Types.type) uu_::?'a OCL_Types.type. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P::bool; ⋀(τ::?'a OCL_Types.type) uv_::?'a OCL_Types.type. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) uw_::?'a OCL_Types.type. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ τ' uu_. ⟦element_type τ σ; AsSetOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ Set σ = σ₂› 2. ‹⋀τ σ τ' uv_. ⟦element_type τ σ; AsSetOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ Set σ = σ₂› 3. ‹⋀τ σ τ' uw_. ⟦element_type τ σ; AsSetOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ Set σ = σ₂› 4. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Set σ = σ₂› 5. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsSetOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ Set σ = σ₂› 6. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Set σ = σ₂› 7. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsSetOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ Set σ = σ₂› 8. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Set σ = σ₂› 9. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsSetOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ Set σ = σ₂› 10. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ Set σ = σ₂› 11. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ Set σ = σ₂› 12. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ Set σ = σ₂› 13. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ Set σ = σ₂› 14. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSetOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ Set σ = σ₂› 15. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSetOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Set σ = σ₂› 16. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSetOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Set σ = σ₂› 17. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSetOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Set σ = σ₂› 18. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSetOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Set σ = σ₂› 19. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSetOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Set σ = σ₂› 20. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSetOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Set σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 11*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ τ' uu_. ⟦element_type τ σ; AsOrderedSetOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ OrderedSet σ = σ₂› 2. ‹⋀τ σ τ' uv_. ⟦element_type τ σ; AsOrderedSetOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ OrderedSet σ = σ₂› 3. ‹⋀τ σ τ' uw_. ⟦element_type τ σ; AsOrderedSetOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ OrderedSet σ = σ₂› 4. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ OrderedSet σ = σ₂› 5. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsOrderedSetOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ OrderedSet σ = σ₂› 6. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ OrderedSet σ = σ₂› 7. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsOrderedSetOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ OrderedSet σ = σ₂› 8. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ OrderedSet σ = σ₂› 9. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsOrderedSetOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ OrderedSet σ = σ₂› 10. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ OrderedSet σ = σ₂› 11. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ OrderedSet σ = σ₂› 12. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ OrderedSet σ = σ₂› 13. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ OrderedSet σ = σ₂› 14. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsOrderedSetOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ OrderedSet σ = σ₂› 15. ‹⋀τ σ τ'. ⟦element_type τ σ; AsOrderedSetOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ OrderedSet σ = σ₂› 16. ‹⋀τ σ τ'. ⟦element_type τ σ; AsOrderedSetOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ OrderedSet σ = σ₂› 17. ‹⋀τ σ τ'. ⟦element_type τ σ; AsOrderedSetOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ OrderedSet σ = σ₂› 18. ‹⋀τ σ τ'. ⟦element_type τ σ; AsOrderedSetOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ OrderedSet σ = σ₂› 19. ‹⋀τ σ τ'. ⟦element_type τ σ; AsOrderedSetOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ OrderedSet σ = σ₂› 20. ‹⋀τ σ τ'. ⟦element_type τ σ; AsOrderedSetOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ OrderedSet σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 12*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ τ' uu_. ⟦element_type τ σ; AsBagOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ Bag σ = σ₂› 2. ‹⋀τ σ τ' uv_. ⟦element_type τ σ; AsBagOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ Bag σ = σ₂› 3. ‹⋀τ σ τ' uw_. ⟦element_type τ σ; AsBagOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ Bag σ = σ₂› 4. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Bag σ = σ₂› 5. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsBagOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ Bag σ = σ₂› 6. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Bag σ = σ₂› 7. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsBagOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ Bag σ = σ₂› 8. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Bag σ = σ₂› 9. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsBagOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ Bag σ = σ₂› 10. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ Bag σ = σ₂› 11. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ Bag σ = σ₂› 12. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ Bag σ = σ₂› 13. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ Bag σ = σ₂› 14. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsBagOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ Bag σ = σ₂› 15. ‹⋀τ σ τ'. ⟦element_type τ σ; AsBagOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Bag σ = σ₂› 16. ‹⋀τ σ τ'. ⟦element_type τ σ; AsBagOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Bag σ = σ₂› 17. ‹⋀τ σ τ'. ⟦element_type τ σ; AsBagOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Bag σ = σ₂› 18. ‹⋀τ σ τ'. ⟦element_type τ σ; AsBagOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Bag σ = σ₂› 19. ‹⋀τ σ τ'. ⟦element_type τ σ; AsBagOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Bag σ = σ₂› 20. ‹⋀τ σ τ'. ⟦element_type τ σ; AsBagOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Bag σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 13*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type (?a1.0::collection_unop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'a OCL_Types.type); ⋀(τ::?'a OCL_Types.type) uu_::?'a OCL_Types.type. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P::bool; ⋀(τ::?'a OCL_Types.type) uv_::?'a OCL_Types.type. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) uw_::?'a OCL_Types.type. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) σ::?'a OCL_Types.type. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ::?'a OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ σ τ' uu_. ⟦element_type τ σ; AsSequenceOp = CollectionSizeOp; τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ Sequence σ = σ₂› 2. ‹⋀τ σ τ' uv_. ⟦element_type τ σ; AsSequenceOp = IsEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ Sequence σ = σ₂› 3. ‹⋀τ σ τ' uw_. ⟦element_type τ σ; AsSequenceOp = NotEmptyOp; τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ Sequence σ = σ₂› 4. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Sequence σ = σ₂› 5. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsSequenceOp = CollectionMaxOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ Sequence σ = σ₂› 6. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Sequence σ = σ₂› 7. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsSequenceOp = CollectionMinOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ Sequence σ = σ₂› 8. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ Sequence σ = σ₂› 9. ‹⋀τ σ τ' σ' oper. ⟦element_type τ σ; AsSequenceOp = SumOp; τ = τ'; σ₂ = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ Sequence σ = σ₂› 10. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = AsSetOp; τ = τ'; σ₂ = Set σ'; element_type τ' σ'⟧ ⟹ Sequence σ = σ₂› 11. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = AsOrderedSetOp; τ = τ'; σ₂ = OrderedSet σ'; element_type τ' σ'⟧ ⟹ Sequence σ = σ₂› 12. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = AsBagOp; τ = τ'; σ₂ = Bag σ'; element_type τ' σ'⟧ ⟹ Sequence σ = σ₂› 13. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = AsSequenceOp; τ = τ'; σ₂ = Sequence σ'; element_type τ' σ'⟧ ⟹ Sequence σ = σ₂› 14. ‹⋀τ σ τ' σ'. ⟦element_type τ σ; AsSequenceOp = FlattenOp; τ = τ'; σ₂ = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ Sequence σ = σ₂› 15. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSequenceOp = FirstOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Sequence σ = σ₂› 16. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSequenceOp = FirstOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Sequence σ = σ₂› 17. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSequenceOp = LastOp; τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Sequence σ = σ₂› 18. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSequenceOp = LastOp; τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Sequence σ = σ₂› 19. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSequenceOp = ReverseOp; τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Sequence σ = σ₂› 20. ‹⋀τ σ τ'. ⟦element_type τ σ; AsSequenceOp = ReverseOp; τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Sequence σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 14*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) uu_::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = CollectionSizeOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Integer[1]; element_type τ' uu_⟧ ⟹ σ = σ₂› 2. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) uv_::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = IsEmptyOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Boolean[1]; element_type τ' uv_⟧ ⟹ σ = σ₂› 3. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) uw_::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = NotEmptyOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Boolean[1]; element_type τ' uw_⟧ ⟹ σ = σ₂› 4. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = CollectionMaxOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 5. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = CollectionMaxOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''max'' [σ'] oper⟧ ⟹ σ = σ₂› 6. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = CollectionMinOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 7. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = CollectionMinOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''min'' [σ'] oper⟧ ⟹ σ = σ₂› 8. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = SumOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; σ' = UnlimitedNatural[1]─Real[1]⟧ ⟹ σ = σ₂› 9. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) (σ'::'a::ocl_object_model OCL_Types.type) oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = SumOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; element_type τ' σ'; operation σ' STR ''+'' [σ'] oper⟧ ⟹ σ = σ₂› 10. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = AsSetOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Set σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 11. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = AsOrderedSetOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = OrderedSet σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 12. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = AsBagOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Bag σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 13. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = AsSequenceOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Sequence σ'; element_type τ' σ'⟧ ⟹ σ = σ₂› 14. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (τ'::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = FlattenOp; τ = τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = σ'; update_element_type τ' (to_single_type τ') σ'⟧ ⟹ σ = σ₂› 15. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = FirstOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 16. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = FirstOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 17. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = LastOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 18. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = LastOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = τ'⟧ ⟹ σ = σ₂› 19. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = ReverseOp; τ = OrderedSet τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = OrderedSet τ'⟧ ⟹ σ = σ₂› 20. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) τ'::'a::ocl_object_model OCL_Types.type. ⟦update_element_type τ (to_single_type τ) σ; FlattenOp = ReverseOp; τ = Sequence τ'; (σ₂::'a::ocl_object_model OCL_Types.type) = Sequence τ'⟧ ⟹ σ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 15*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type (?a1.0::collection_unop) (?a2.0::?'a::ocl_object_model OCL_Types.type) (?a3.0::?'a::ocl_object_model OCL_Types.type); ⋀(τ::?'a::ocl_object_model OCL_Types.type) uu_::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P::bool; ⋀(τ::?'a::ocl_object_model OCL_Types.type) uv_::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) uw_::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) (σ::?'a::ocl_object_model OCL_Types.type) oper::String.literal × ?'a::ocl_object_model OCL_Types.type × (String.literal × ?'a::ocl_object_model OCL_Types.type × param_dir) list × ?'a::ocl_object_model OCL_Types.type × bool × ?'a::ocl_object_model expr option. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) (σ::?'a::ocl_object_model OCL_Types.type) oper::String.literal × ?'a::ocl_object_model OCL_Types.type × (String.literal × ?'a::ocl_object_model OCL_Types.type × param_dir) list × ?'a::ocl_object_model OCL_Types.type × bool × ?'a::ocl_object_model expr option. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) (σ::?'a::ocl_object_model OCL_Types.type) oper::String.literal × ?'a::ocl_object_model OCL_Types.type × (String.literal × ?'a::ocl_object_model OCL_Types.type × param_dir) list × ?'a::ocl_object_model OCL_Types.type × bool × ?'a::ocl_object_model expr option. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀(τ::?'a::ocl_object_model OCL_Types.type) σ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ::?'a::ocl_object_model OCL_Types.type. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ τ' uu_. ⟦FirstOp = CollectionSizeOp; OrderedSet τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ τ = σ₂› 2. ‹⋀τ τ' uv_. ⟦FirstOp = IsEmptyOp; OrderedSet τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ τ = σ₂› 3. ‹⋀τ τ' uw_. ⟦FirstOp = NotEmptyOp; OrderedSet τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ τ = σ₂› 4. ‹⋀τ τ' σ. ⟦FirstOp = CollectionMaxOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 5. ‹⋀τ τ' σ oper. ⟦FirstOp = CollectionMaxOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ τ = σ₂› 6. ‹⋀τ τ' σ. ⟦FirstOp = CollectionMinOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 7. ‹⋀τ τ' σ oper. ⟦FirstOp = CollectionMinOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ τ = σ₂› 8. ‹⋀τ τ' σ. ⟦FirstOp = SumOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 9. ‹⋀τ τ' σ oper. ⟦FirstOp = SumOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ τ = σ₂› 10. ‹⋀τ τ' σ. ⟦FirstOp = AsSetOp; OrderedSet τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ τ = σ₂› 11. ‹⋀τ τ' σ. ⟦FirstOp = AsOrderedSetOp; OrderedSet τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ τ = σ₂› 12. ‹⋀τ τ' σ. ⟦FirstOp = AsBagOp; OrderedSet τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ τ = σ₂› 13. ‹⋀τ τ' σ. ⟦FirstOp = AsSequenceOp; OrderedSet τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ τ = σ₂› 14. ‹⋀τ τ' σ. ⟦FirstOp = FlattenOp; OrderedSet τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ τ = σ₂› 15. ‹⋀τ τ'. ⟦FirstOp = FirstOp; OrderedSet τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 16. ‹⋀τ τ'. ⟦FirstOp = FirstOp; OrderedSet τ = Sequence τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 17. ‹⋀τ τ'. ⟦FirstOp = LastOp; OrderedSet τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 18. ‹⋀τ τ'. ⟦FirstOp = LastOp; OrderedSet τ = Sequence τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 19. ‹⋀τ τ'. ⟦FirstOp = ReverseOp; OrderedSet τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ τ = σ₂› 20. ‹⋀τ τ'. ⟦FirstOp = ReverseOp; OrderedSet τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ τ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 16*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ τ' uu_. ⟦FirstOp = CollectionSizeOp; Sequence τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ τ = σ₂› 2. ‹⋀τ τ' uv_. ⟦FirstOp = IsEmptyOp; Sequence τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ τ = σ₂› 3. ‹⋀τ τ' uw_. ⟦FirstOp = NotEmptyOp; Sequence τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ τ = σ₂› 4. ‹⋀τ τ' σ. ⟦FirstOp = CollectionMaxOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 5. ‹⋀τ τ' σ oper. ⟦FirstOp = CollectionMaxOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ τ = σ₂› 6. ‹⋀τ τ' σ. ⟦FirstOp = CollectionMinOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 7. ‹⋀τ τ' σ oper. ⟦FirstOp = CollectionMinOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ τ = σ₂› 8. ‹⋀τ τ' σ. ⟦FirstOp = SumOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 9. ‹⋀τ τ' σ oper. ⟦FirstOp = SumOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ τ = σ₂› 10. ‹⋀τ τ' σ. ⟦FirstOp = AsSetOp; Sequence τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ τ = σ₂› 11. ‹⋀τ τ' σ. ⟦FirstOp = AsOrderedSetOp; Sequence τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ τ = σ₂› 12. ‹⋀τ τ' σ. ⟦FirstOp = AsBagOp; Sequence τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ τ = σ₂› 13. ‹⋀τ τ' σ. ⟦FirstOp = AsSequenceOp; Sequence τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ τ = σ₂› 14. ‹⋀τ τ' σ. ⟦FirstOp = FlattenOp; Sequence τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ τ = σ₂› 15. ‹⋀τ τ'. ⟦FirstOp = FirstOp; Sequence τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 16. ‹⋀τ τ'. ⟦FirstOp = FirstOp; Sequence τ = Sequence τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 17. ‹⋀τ τ'. ⟦FirstOp = LastOp; Sequence τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 18. ‹⋀τ τ'. ⟦FirstOp = LastOp; Sequence τ = Sequence τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 19. ‹⋀τ τ'. ⟦FirstOp = ReverseOp; Sequence τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ τ = σ₂› 20. ‹⋀τ τ'. ⟦FirstOp = ReverseOp; Sequence τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ τ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 17*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) uu_::'a OCL_Types.type. ⟦LastOp = CollectionSizeOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = Integer[1]; element_type τ' uu_⟧ ⟹ τ = σ₂› 2. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) uv_::'a OCL_Types.type. ⟦LastOp = IsEmptyOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = Boolean[1]; element_type τ' uv_⟧ ⟹ τ = σ₂› 3. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) uw_::'a OCL_Types.type. ⟦LastOp = NotEmptyOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = Boolean[1]; element_type τ' uw_⟧ ⟹ τ = σ₂› 4. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = CollectionMaxOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 5. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) (σ::'a OCL_Types.type) oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option. ⟦LastOp = CollectionMaxOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ τ = σ₂› 6. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = CollectionMinOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 7. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) (σ::'a OCL_Types.type) oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option. ⟦LastOp = CollectionMinOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ τ = σ₂› 8. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = SumOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 9. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) (σ::'a OCL_Types.type) oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option. ⟦LastOp = SumOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ τ = σ₂› 10. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = AsSetOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = Set σ; element_type τ' σ⟧ ⟹ τ = σ₂› 11. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = AsOrderedSetOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = OrderedSet σ; element_type τ' σ⟧ ⟹ τ = σ₂› 12. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = AsBagOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = Bag σ; element_type τ' σ⟧ ⟹ τ = σ₂› 13. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = AsSequenceOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = Sequence σ; element_type τ' σ⟧ ⟹ τ = σ₂› 14. ‹⋀(τ::'a OCL_Types.type) (τ'::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦LastOp = FlattenOp; OrderedSet τ = τ'; (σ₂::'a OCL_Types.type) = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ τ = σ₂› 15. ‹⋀(τ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦LastOp = FirstOp; OrderedSet τ = OrderedSet τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ τ = σ₂› 16. ‹⋀(τ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦LastOp = FirstOp; OrderedSet τ = Sequence τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ τ = σ₂› 17. ‹⋀(τ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦LastOp = LastOp; OrderedSet τ = OrderedSet τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ τ = σ₂› 18. ‹⋀(τ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦LastOp = LastOp; OrderedSet τ = Sequence τ'; (σ₂::'a OCL_Types.type) = τ'⟧ ⟹ τ = σ₂› 19. ‹⋀(τ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦LastOp = ReverseOp; OrderedSet τ = OrderedSet τ'; (σ₂::'a OCL_Types.type) = OrderedSet τ'⟧ ⟹ τ = σ₂› 20. ‹⋀(τ::'a OCL_Types.type) τ'::'a OCL_Types.type. ⟦LastOp = ReverseOp; OrderedSet τ = Sequence τ'; (σ₂::'a OCL_Types.type) = Sequence τ'⟧ ⟹ τ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 18*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ τ' uu_. ⟦LastOp = CollectionSizeOp; Sequence τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ τ = σ₂› 2. ‹⋀τ τ' uv_. ⟦LastOp = IsEmptyOp; Sequence τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ τ = σ₂› 3. ‹⋀τ τ' uw_. ⟦LastOp = NotEmptyOp; Sequence τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ τ = σ₂› 4. ‹⋀τ τ' σ. ⟦LastOp = CollectionMaxOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 5. ‹⋀τ τ' σ oper. ⟦LastOp = CollectionMaxOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ τ = σ₂› 6. ‹⋀τ τ' σ. ⟦LastOp = CollectionMinOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 7. ‹⋀τ τ' σ oper. ⟦LastOp = CollectionMinOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ τ = σ₂› 8. ‹⋀τ τ' σ. ⟦LastOp = SumOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ τ = σ₂› 9. ‹⋀τ τ' σ oper. ⟦LastOp = SumOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ τ = σ₂› 10. ‹⋀τ τ' σ. ⟦LastOp = AsSetOp; Sequence τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ τ = σ₂› 11. ‹⋀τ τ' σ. ⟦LastOp = AsOrderedSetOp; Sequence τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ τ = σ₂› 12. ‹⋀τ τ' σ. ⟦LastOp = AsBagOp; Sequence τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ τ = σ₂› 13. ‹⋀τ τ' σ. ⟦LastOp = AsSequenceOp; Sequence τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ τ = σ₂› 14. ‹⋀τ τ' σ. ⟦LastOp = FlattenOp; Sequence τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ τ = σ₂› 15. ‹⋀τ τ'. ⟦LastOp = FirstOp; Sequence τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 16. ‹⋀τ τ'. ⟦LastOp = FirstOp; Sequence τ = Sequence τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 17. ‹⋀τ τ'. ⟦LastOp = LastOp; Sequence τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 18. ‹⋀τ τ'. ⟦LastOp = LastOp; Sequence τ = Sequence τ'; σ₂ = τ'⟧ ⟹ τ = σ₂› 19. ‹⋀τ τ'. ⟦LastOp = ReverseOp; Sequence τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ τ = σ₂› 20. ‹⋀τ τ'. ⟦LastOp = ReverseOp; Sequence τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ τ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 19*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ τ' uu_. ⟦ReverseOp = CollectionSizeOp; OrderedSet τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ OrderedSet τ = σ₂› 2. ‹⋀τ τ' uv_. ⟦ReverseOp = IsEmptyOp; OrderedSet τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ OrderedSet τ = σ₂› 3. ‹⋀τ τ' uw_. ⟦ReverseOp = NotEmptyOp; OrderedSet τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ OrderedSet τ = σ₂› 4. ‹⋀τ τ' σ. ⟦ReverseOp = CollectionMaxOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ OrderedSet τ = σ₂› 5. ‹⋀τ τ' σ oper. ⟦ReverseOp = CollectionMaxOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ OrderedSet τ = σ₂› 6. ‹⋀τ τ' σ. ⟦ReverseOp = CollectionMinOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ OrderedSet τ = σ₂› 7. ‹⋀τ τ' σ oper. ⟦ReverseOp = CollectionMinOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ OrderedSet τ = σ₂› 8. ‹⋀τ τ' σ. ⟦ReverseOp = SumOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ OrderedSet τ = σ₂› 9. ‹⋀τ τ' σ oper. ⟦ReverseOp = SumOp; OrderedSet τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ OrderedSet τ = σ₂› 10. ‹⋀τ τ' σ. ⟦ReverseOp = AsSetOp; OrderedSet τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ OrderedSet τ = σ₂› 11. ‹⋀τ τ' σ. ⟦ReverseOp = AsOrderedSetOp; OrderedSet τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ OrderedSet τ = σ₂› 12. ‹⋀τ τ' σ. ⟦ReverseOp = AsBagOp; OrderedSet τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ OrderedSet τ = σ₂› 13. ‹⋀τ τ' σ. ⟦ReverseOp = AsSequenceOp; OrderedSet τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ OrderedSet τ = σ₂› 14. ‹⋀τ τ' σ. ⟦ReverseOp = FlattenOp; OrderedSet τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ OrderedSet τ = σ₂› 15. ‹⋀τ τ'. ⟦ReverseOp = FirstOp; OrderedSet τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ OrderedSet τ = σ₂› 16. ‹⋀τ τ'. ⟦ReverseOp = FirstOp; OrderedSet τ = Sequence τ'; σ₂ = τ'⟧ ⟹ OrderedSet τ = σ₂› 17. ‹⋀τ τ'. ⟦ReverseOp = LastOp; OrderedSet τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ OrderedSet τ = σ₂› 18. ‹⋀τ τ'. ⟦ReverseOp = LastOp; OrderedSet τ = Sequence τ'; σ₂ = τ'⟧ ⟹ OrderedSet τ = σ₂› 19. ‹⋀τ τ'. ⟦ReverseOp = ReverseOp; OrderedSet τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ OrderedSet τ = σ₂› 20. ‹⋀τ τ'. ⟦ReverseOp = ReverseOp; OrderedSet τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ OrderedSet τ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*discuss goal 20*) apply ((erule collection_unop_type.cases (*‹⟦collection_unop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ uu_. ⟦?a1.0 = CollectionSizeOp; ?a2.0 = τ; ?a3.0 = Integer[1]; element_type τ uu_⟧ ⟹ ?P; ⋀τ uv_. ⟦?a1.0 = IsEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uv_⟧ ⟹ ?P; ⋀τ uw_. ⟦?a1.0 = NotEmptyOp; ?a2.0 = τ; ?a3.0 = Boolean[1]; element_type τ uw_⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMaxOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''max'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = CollectionMinOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''min'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ ?P; ⋀τ σ oper. ⟦?a1.0 = SumOp; ?a2.0 = τ; ?a3.0 = σ; element_type τ σ; operation σ STR ''+'' [σ] oper⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSetOp; ?a2.0 = τ; ?a3.0 = Set σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsOrderedSetOp; ?a2.0 = τ; ?a3.0 = OrderedSet σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsBagOp; ?a2.0 = τ; ?a3.0 = Bag σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = AsSequenceOp; ?a2.0 = τ; ?a3.0 = Sequence σ; element_type τ σ⟧ ⟹ ?P; ⋀τ σ. ⟦?a1.0 = FlattenOp; ?a2.0 = τ; ?a3.0 = σ; update_element_type τ (to_single_type τ) σ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = FirstOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = OrderedSet τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = LastOp; ?a2.0 = Sequence τ; ?a3.0 = τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = OrderedSet τ; ?a3.0 = OrderedSet τ⟧ ⟹ ?P; ⋀τ. ⟦?a1.0 = ReverseOp; ?a2.0 = Sequence τ; ?a3.0 = Sequence τ⟧ ⟹ ?P⟧ ⟹ ?P›*))[1]) (*goals: 1. ‹⋀τ τ' uu_. ⟦ReverseOp = CollectionSizeOp; Sequence τ = τ'; σ₂ = Integer[1]; element_type τ' uu_⟧ ⟹ Sequence τ = σ₂› 2. ‹⋀τ τ' uv_. ⟦ReverseOp = IsEmptyOp; Sequence τ = τ'; σ₂ = Boolean[1]; element_type τ' uv_⟧ ⟹ Sequence τ = σ₂› 3. ‹⋀τ τ' uw_. ⟦ReverseOp = NotEmptyOp; Sequence τ = τ'; σ₂ = Boolean[1]; element_type τ' uw_⟧ ⟹ Sequence τ = σ₂› 4. ‹⋀τ τ' σ. ⟦ReverseOp = CollectionMaxOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Sequence τ = σ₂› 5. ‹⋀τ τ' σ oper. ⟦ReverseOp = CollectionMaxOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''max'' [σ] oper⟧ ⟹ Sequence τ = σ₂› 6. ‹⋀τ τ' σ. ⟦ReverseOp = CollectionMinOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Sequence τ = σ₂› 7. ‹⋀τ τ' σ oper. ⟦ReverseOp = CollectionMinOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''min'' [σ] oper⟧ ⟹ Sequence τ = σ₂› 8. ‹⋀τ τ' σ. ⟦ReverseOp = SumOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; σ = UnlimitedNatural[1]─Real[1]⟧ ⟹ Sequence τ = σ₂› 9. ‹⋀τ τ' σ oper. ⟦ReverseOp = SumOp; Sequence τ = τ'; σ₂ = σ; element_type τ' σ; operation σ STR ''+'' [σ] oper⟧ ⟹ Sequence τ = σ₂› 10. ‹⋀τ τ' σ. ⟦ReverseOp = AsSetOp; Sequence τ = τ'; σ₂ = Set σ; element_type τ' σ⟧ ⟹ Sequence τ = σ₂› 11. ‹⋀τ τ' σ. ⟦ReverseOp = AsOrderedSetOp; Sequence τ = τ'; σ₂ = OrderedSet σ; element_type τ' σ⟧ ⟹ Sequence τ = σ₂› 12. ‹⋀τ τ' σ. ⟦ReverseOp = AsBagOp; Sequence τ = τ'; σ₂ = Bag σ; element_type τ' σ⟧ ⟹ Sequence τ = σ₂› 13. ‹⋀τ τ' σ. ⟦ReverseOp = AsSequenceOp; Sequence τ = τ'; σ₂ = Sequence σ; element_type τ' σ⟧ ⟹ Sequence τ = σ₂› 14. ‹⋀τ τ' σ. ⟦ReverseOp = FlattenOp; Sequence τ = τ'; σ₂ = σ; update_element_type τ' (to_single_type τ') σ⟧ ⟹ Sequence τ = σ₂› 15. ‹⋀τ τ'. ⟦ReverseOp = FirstOp; Sequence τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Sequence τ = σ₂› 16. ‹⋀τ τ'. ⟦ReverseOp = FirstOp; Sequence τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Sequence τ = σ₂› 17. ‹⋀τ τ'. ⟦ReverseOp = LastOp; Sequence τ = OrderedSet τ'; σ₂ = τ'⟧ ⟹ Sequence τ = σ₂› 18. ‹⋀τ τ'. ⟦ReverseOp = LastOp; Sequence τ = Sequence τ'; σ₂ = τ'⟧ ⟹ Sequence τ = σ₂› 19. ‹⋀τ τ'. ⟦ReverseOp = ReverseOp; Sequence τ = OrderedSet τ'; σ₂ = OrderedSet τ'⟧ ⟹ Sequence τ = σ₂› 20. ‹⋀τ τ'. ⟦ReverseOp = ReverseOp; Sequence τ = Sequence τ'; σ₂ = Sequence τ'⟧ ⟹ Sequence τ = σ₂› discuss goal 1*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 2*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 3*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 4*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 5*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 6*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 7*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 8*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 9*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 10*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 11*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 12*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 13*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 14*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 15*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 16*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 17*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 18*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 19*) apply ((auto simp add: element_type_det (*‹⟦element_type (?τ::?'a::type OCL_Types.type) (?σ₁::?'a::type OCL_Types.type); element_type ?τ (?σ₂::?'a::type OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*discuss goal 20*) apply ((auto simp add: element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*))[1]) (*proven 20 subgoals*) (*proven 20 subgoals*) . lemma unop_type_det: "unop_type op k τ σ₁ ⟹ unop_type op k τ σ₂ ⟹ σ₁ = σ₂" apply (induct rule: unop_type.induct (*‹⟦unop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0; ⋀op τ σ. any_unop_type op τ σ ⟹ ?P (Inl op) DotCall τ σ; ⋀op τ σ. boolean_unop_type op τ σ ⟹ ?P (Inr (Inl op)) DotCall τ σ; ⋀op τ σ. numeric_unop_type op τ σ ⟹ ?P (Inr (Inr (Inl op))) DotCall τ σ; ⋀op τ σ. string_unop_type op τ σ ⟹ ?P (Inr (Inr (Inr (Inl op)))) DotCall τ σ; ⋀op τ σ. collection_unop_type op τ σ ⟹ ?P (Inr (Inr (Inr (Inr op)))) ArrowCall τ σ⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0›*)) (*goals: 1. ‹⋀op τ σ. ⟦any_unop_type op τ σ; unop_type (Inl op) DotCall τ σ₂⟧ ⟹ σ = σ₂› 2. ‹⋀op τ σ. ⟦boolean_unop_type op τ σ; unop_type (Inr (Inl op)) DotCall τ σ₂⟧ ⟹ σ = σ₂› 3. ‹⋀op τ σ. ⟦numeric_unop_type op τ σ; unop_type (Inr (Inr (Inl op))) DotCall τ σ₂⟧ ⟹ σ = σ₂› 4. ‹⋀op τ σ. ⟦string_unop_type op τ σ; unop_type (Inr (Inr (Inr (Inl op)))) DotCall τ σ₂⟧ ⟹ σ = σ₂› 5. ‹⋀op τ σ. ⟦collection_unop_type op τ σ; unop_type (Inr (Inr (Inr (Inr op)))) ArrowCall τ σ₂⟧ ⟹ σ = σ₂› discuss goal 1*) apply (simp add: unop_type.simps (*‹unop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃op τ σ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ any_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ boolean_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ numeric_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ string_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ collection_unop_type op τ σ))›*) any_unop_type_det (*‹⟦any_unop_type ?op ?τ ?σ₁; any_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) boolean_unop_type_det (*‹⟦boolean_unop_type ?op ?τ ?σ₁; boolean_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) numeric_unop_type_det (*‹⟦numeric_unop_type ?op ?τ ?σ₁; numeric_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) string_unop_type_det (*‹⟦string_unop_type ?op ?τ ?σ₁; string_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) collection_unop_type_det (*‹⟦collection_unop_type ?op ?τ ?σ₁; collection_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 2*) apply (simp add: unop_type.simps (*‹unop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃op τ σ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ any_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ boolean_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ numeric_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ string_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ collection_unop_type op τ σ))›*) any_unop_type_det (*‹⟦any_unop_type ?op ?τ ?σ₁; any_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) boolean_unop_type_det (*‹⟦boolean_unop_type ?op ?τ ?σ₁; boolean_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) numeric_unop_type_det (*‹⟦numeric_unop_type ?op ?τ ?σ₁; numeric_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) string_unop_type_det (*‹⟦string_unop_type ?op ?τ ?σ₁; string_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) collection_unop_type_det (*‹⟦collection_unop_type ?op ?τ ?σ₁; collection_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 3*) apply (simp add: unop_type.simps (*‹unop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃op τ σ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ any_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ boolean_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ numeric_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ string_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ collection_unop_type op τ σ))›*) any_unop_type_det (*‹⟦any_unop_type ?op ?τ ?σ₁; any_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) boolean_unop_type_det (*‹⟦boolean_unop_type ?op ?τ ?σ₁; boolean_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) numeric_unop_type_det (*‹⟦numeric_unop_type ?op ?τ ?σ₁; numeric_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) string_unop_type_det (*‹⟦string_unop_type ?op ?τ ?σ₁; string_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) collection_unop_type_det (*‹⟦collection_unop_type ?op ?τ ?σ₁; collection_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 4*) apply (simp add: unop_type.simps (*‹unop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃op τ σ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ any_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ boolean_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ numeric_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ string_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ collection_unop_type op τ σ))›*) any_unop_type_det (*‹⟦any_unop_type ?op ?τ ?σ₁; any_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) boolean_unop_type_det (*‹⟦boolean_unop_type ?op ?τ ?σ₁; boolean_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) numeric_unop_type_det (*‹⟦numeric_unop_type ?op ?τ ?σ₁; numeric_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) string_unop_type_det (*‹⟦string_unop_type ?op ?τ ?σ₁; string_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) collection_unop_type_det (*‹⟦collection_unop_type ?op ?τ ?σ₁; collection_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 5*) apply (simp add: unop_type.simps (*‹unop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃op τ σ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ any_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ boolean_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ numeric_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ string_unop_type op τ σ) ∨ (∃op τ σ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ collection_unop_type op τ σ))›*) any_unop_type_det (*‹⟦any_unop_type ?op ?τ ?σ₁; any_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) boolean_unop_type_det (*‹⟦boolean_unop_type ?op ?τ ?σ₁; boolean_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) numeric_unop_type_det (*‹⟦numeric_unop_type ?op ?τ ?σ₁; numeric_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) string_unop_type_det (*‹⟦string_unop_type ?op ?τ ?σ₁; string_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) collection_unop_type_det (*‹⟦collection_unop_type ?op ?τ ?σ₁; collection_unop_type ?op ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*proven 5 subgoals*) . lemma super_binop_type_det: "super_binop_type op τ σ ρ₁ ⟹ super_binop_type op τ σ ρ₂ ⟹ ρ₁ = ρ₂" sorry lemma boolean_binop_type_det: "boolean_binop_type op τ σ ρ₁ ⟹ boolean_binop_type op τ σ ρ₂ ⟹ ρ₁ = ρ₂" apply (induct rule: boolean_binop_type.induct (*‹⟦boolean_binop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0; ⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]⟧ ⟹ ?P AndOp τ σ ρ; ⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]⟧ ⟹ ?P OrOp τ σ ρ; ⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]⟧ ⟹ ?P XorOp τ σ ρ; ⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]⟧ ⟹ ?P ImpliesOp τ σ ρ⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0›*)) (*goals: 1. ‹⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]; boolean_binop_type AndOp τ σ ρ₂⟧ ⟹ ρ = ρ₂› 2. ‹⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]; boolean_binop_type OrOp τ σ ρ₂⟧ ⟹ ρ = ρ₂› 3. ‹⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]; boolean_binop_type XorOp τ σ ρ₂⟧ ⟹ ρ = ρ₂› 4. ‹⋀τ σ ρ. ⟦τ ⊔ σ = ρ; ρ ≤ Boolean[?]; boolean_binop_type ImpliesOp τ σ ρ₂⟧ ⟹ ρ = ρ₂› discuss goal 1*) apply (simp add: boolean_binop_type.simps (*‹boolean_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃τ σ ρ. ?a1.0 = AndOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = OrOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = XorOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = ImpliesOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]))›*)) (*discuss goal 2*) apply (simp add: boolean_binop_type.simps (*‹boolean_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃τ σ ρ. ?a1.0 = AndOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = OrOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = XorOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = ImpliesOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]))›*)) (*discuss goal 3*) apply (simp add: boolean_binop_type.simps (*‹boolean_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃τ σ ρ. ?a1.0 = AndOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = OrOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = XorOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = ImpliesOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]))›*)) (*discuss goal 4*) apply (simp add: boolean_binop_type.simps (*‹boolean_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃τ σ ρ. ?a1.0 = AndOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = OrOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = XorOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]) ∨ (∃τ σ ρ. ?a1.0 = ImpliesOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ τ ⊔ σ = ρ ∧ ρ ≤ Boolean[?]))›*)) (*proven 4 subgoals*) . lemma numeric_binop_type_det: "numeric_binop_type op τ σ ρ₁ ⟹ numeric_binop_type op τ σ ρ₂ ⟹ ρ₁ = ρ₂" sorry lemma string_binop_type_det: "string_binop_type op τ σ ρ₁ ⟹ string_binop_type op τ σ ρ₂ ⟹ ρ₁ = ρ₂" apply (induct rule: string_binop_type.induct (*‹⟦string_binop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0; ?P ConcatOp String[1] String[1] String[1]; ?P EqualsIgnoreCaseOp String[1] String[1] Boolean[1]; ?P string_binop.LessOp String[1] String[1] Boolean[1]; ?P string_binop.LessEqOp String[1] String[1] Boolean[1]; ?P string_binop.GreaterOp String[1] String[1] Boolean[1]; ?P string_binop.GreaterEqOp String[1] String[1] Boolean[1]; ?P IndexOfOp String[1] String[1] Integer[1]; ⋀τ. τ = UnlimitedNatural[1]─Integer[1] ⟹ ?P AtOp String[1] τ String[1]⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0›*)) (*goals: 1. ‹string_binop_type ConcatOp String[1] String[1] ρ₂ ⟹ String[1] = ρ₂› 2. ‹string_binop_type EqualsIgnoreCaseOp String[1] String[1] ρ₂ ⟹ Boolean[1] = ρ₂› 3. ‹string_binop_type string_binop.LessOp String[1] String[1] ρ₂ ⟹ Boolean[1] = ρ₂› 4. ‹string_binop_type string_binop.LessEqOp String[1] String[1] ρ₂ ⟹ Boolean[1] = ρ₂› 5. ‹string_binop_type string_binop.GreaterOp String[1] String[1] ρ₂ ⟹ Boolean[1] = ρ₂› 6. ‹string_binop_type string_binop.GreaterEqOp String[1] String[1] ρ₂ ⟹ Boolean[1] = ρ₂› 7. ‹string_binop_type IndexOfOp String[1] String[1] ρ₂ ⟹ Integer[1] = ρ₂› 8. ‹⋀τ. ⟦τ = UnlimitedNatural[1]─Integer[1]; string_binop_type AtOp String[1] τ ρ₂⟧ ⟹ String[1] = ρ₂› discuss goal 1*) apply (simp add: string_binop_type.simps (*‹string_binop_type (?a1.0::string_binop) (?a2.0::?'a OCL_Types.type) (?a3.0::?'b OCL_Types.type) (?a4.0::?'c OCL_Types.type) = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ::?'b OCL_Types.type. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 2*) apply (simp add: string_binop_type.simps (*‹string_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 3*) apply (simp add: string_binop_type.simps (*‹string_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 4*) apply (simp add: string_binop_type.simps (*‹string_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 5*) apply (simp add: string_binop_type.simps (*‹string_binop_type (?a1.0::string_binop) (?a2.0::?'a::order OCL_Types.type) (?a3.0::?'b::order OCL_Types.type) (?a4.0::?'c::order OCL_Types.type) = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ::?'b::order OCL_Types.type. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 6*) apply (simp add: string_binop_type.simps (*‹string_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 7*) apply (simp add: string_binop_type.simps (*‹string_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 8*) apply (simp add: string_binop_type.simps (*‹string_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = (?a1.0 = ConcatOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = String[1] ∨ ?a1.0 = EqualsIgnoreCaseOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.LessEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = string_binop.GreaterEqOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Boolean[1] ∨ ?a1.0 = IndexOfOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = String[1] ∧ ?a4.0 = Integer[1] ∨ (∃τ. ?a1.0 = AtOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = τ ∧ ?a4.0 = String[1] ∧ τ = UnlimitedNatural[1]─Integer[1]))›*)) (*proven 8 subgoals*) . lemma collection_binop_type_det: "collection_binop_type op τ σ ρ₁ ⟹ collection_binop_type op τ σ ρ₂ ⟹ ρ₁ = ρ₂" apply (induct rule: collection_binop_type.induct (*‹⟦collection_binop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0; ⋀τ ρ σ. ⟦element_type τ ρ; σ ≤ to_optional_type_nested ρ⟧ ⟹ ?P IncludesOp τ σ Boolean[1]; ⋀τ ρ σ. ⟦element_type τ ρ; σ ≤ to_optional_type_nested ρ⟧ ⟹ ?P ExcludesOp τ σ Boolean[1]; ⋀τ ρ σ. ⟦element_type τ ρ; σ ≤ to_optional_type_nested ρ⟧ ⟹ ?P CountOp τ σ Integer[1]; ⋀τ ρ σ υ. ⟦element_type τ ρ; element_type σ υ; υ ≤ to_optional_type_nested ρ⟧ ⟹ ?P IncludesAllOp τ σ Boolean[1]; ⋀τ ρ σ υ. ⟦element_type τ ρ; element_type σ υ; υ ≤ to_optional_type_nested ρ⟧ ⟹ ?P ExcludesAllOp τ σ Boolean[1]; ⋀τ ρ σ υ. ⟦element_type τ ρ; element_type σ υ⟧ ⟹ ?P ProductOp τ σ (Set (Tuple (fmap_of_list [(STR ''first'', ρ), (STR ''second'', υ)]))); ⋀τ σ. ?P UnionOp (Set τ) (Set σ) (Set (τ ⊔ σ)); ⋀τ σ. ?P UnionOp (Set τ) (Bag σ) (Bag (τ ⊔ σ)); ⋀τ σ. ?P UnionOp (Bag τ) (Set σ) (Bag (τ ⊔ σ)); ⋀τ σ. ?P UnionOp (Bag τ) (Bag σ) (Bag (τ ⊔ σ)); ⋀τ σ. ?P IntersectionOp (Set τ) (Set σ) (Set (τ ⊔ σ)); ⋀τ σ. ?P IntersectionOp (Set τ) (Bag σ) (Set (τ ⊔ σ)); ⋀τ σ. ?P IntersectionOp (Bag τ) (Set σ) (Set (τ ⊔ σ)); ⋀τ σ. ?P IntersectionOp (Bag τ) (Bag σ) (Bag (τ ⊔ σ)); ⋀τ σ. ?P SetMinusOp (Set τ) (Set σ) (Set τ); ⋀τ σ. ?P SymmetricDifferenceOp (Set τ) (Set σ) (Set (τ ⊔ σ)); ⋀τ ρ σ υ. ⟦element_type τ ρ; update_element_type τ (ρ ⊔ σ) υ⟧ ⟹ ?P IncludingOp τ σ υ; ⋀τ ρ σ. ⟦element_type τ ρ; σ ≤ ρ⟧ ⟹ ?P ExcludingOp τ σ τ; ⋀σ τ. σ ≤ τ ⟹ ?P AppendOp (OrderedSet τ) σ (OrderedSet τ); ⋀σ τ. σ ≤ τ ⟹ ?P AppendOp (Sequence τ) σ (Sequence τ); ⋀σ τ. σ ≤ τ ⟹ ?P PrependOp (OrderedSet τ) σ (OrderedSet τ); ⋀σ τ. σ ≤ τ ⟹ ?P PrependOp (Sequence τ) σ (Sequence τ); ⋀σ τ. σ = UnlimitedNatural[1]─Integer[1] ⟹ ?P CollectionAtOp (OrderedSet τ) σ τ; ⋀σ τ. σ = UnlimitedNatural[1]─Integer[1] ⟹ ?P CollectionAtOp (Sequence τ) σ τ; ⋀σ τ. σ ≤ τ ⟹ ?P CollectionIndexOfOp (OrderedSet τ) σ Integer[1]; ⋀σ τ. σ ≤ τ ⟹ ?P CollectionIndexOfOp (Sequence τ) σ Integer[1]⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0›*); simp add: collection_binop_type.simps (*‹collection_binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 = ((∃τ ρ σ. ?a1.0 = IncludesOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = Boolean[1] ∧ element_type τ ρ ∧ σ ≤ to_optional_type_nested ρ) ∨ (∃τ ρ σ. ?a1.0 = ExcludesOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = Boolean[1] ∧ element_type τ ρ ∧ σ ≤ to_optional_type_nested ρ) ∨ (∃τ ρ σ. ?a1.0 = CountOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = Integer[1] ∧ element_type τ ρ ∧ σ ≤ to_optional_type_nested ρ) ∨ (∃τ ρ σ υ. ?a1.0 = IncludesAllOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = Boolean[1] ∧ element_type τ ρ ∧ element_type σ υ ∧ υ ≤ to_optional_type_nested ρ) ∨ (∃τ ρ σ υ. ?a1.0 = ExcludesAllOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = Boolean[1] ∧ element_type τ ρ ∧ element_type σ υ ∧ υ ≤ to_optional_type_nested ρ) ∨ (∃τ ρ σ υ. ?a1.0 = ProductOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = Set (Tuple (fmap_of_list [(STR ''first'', ρ), (STR ''second'', υ)])) ∧ element_type τ ρ ∧ element_type σ υ) ∨ (∃τ σ. ?a1.0 = UnionOp ∧ ?a2.0 = Set τ ∧ ?a3.0 = Set σ ∧ ?a4.0 = Set (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = UnionOp ∧ ?a2.0 = Set τ ∧ ?a3.0 = Bag σ ∧ ?a4.0 = Bag (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = UnionOp ∧ ?a2.0 = Bag τ ∧ ?a3.0 = Set σ ∧ ?a4.0 = Bag (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = UnionOp ∧ ?a2.0 = Bag τ ∧ ?a3.0 = Bag σ ∧ ?a4.0 = Bag (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = IntersectionOp ∧ ?a2.0 = Set τ ∧ ?a3.0 = Set σ ∧ ?a4.0 = Set (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = IntersectionOp ∧ ?a2.0 = Set τ ∧ ?a3.0 = Bag σ ∧ ?a4.0 = Set (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = IntersectionOp ∧ ?a2.0 = Bag τ ∧ ?a3.0 = Set σ ∧ ?a4.0 = Set (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = IntersectionOp ∧ ?a2.0 = Bag τ ∧ ?a3.0 = Bag σ ∧ ?a4.0 = Bag (τ ⊔ σ)) ∨ (∃τ σ. ?a1.0 = SetMinusOp ∧ ?a2.0 = Set τ ∧ ?a3.0 = Set σ ∧ ?a4.0 = Set τ) ∨ (∃τ σ. ?a1.0 = SymmetricDifferenceOp ∧ ?a2.0 = Set τ ∧ ?a3.0 = Set σ ∧ ?a4.0 = Set (τ ⊔ σ)) ∨ (∃τ ρ σ υ. ?a1.0 = IncludingOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = υ ∧ element_type τ ρ ∧ update_element_type τ (ρ ⊔ σ) υ) ∨ (∃τ ρ σ. ?a1.0 = ExcludingOp ∧ ?a2.0 = τ ∧ ?a3.0 = σ ∧ ?a4.0 = τ ∧ element_type τ ρ ∧ σ ≤ ρ) ∨ (∃σ τ. ?a1.0 = AppendOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = OrderedSet τ ∧ σ ≤ τ) ∨ (∃σ τ. ?a1.0 = AppendOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = Sequence τ ∧ σ ≤ τ) ∨ (∃σ τ. ?a1.0 = PrependOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = OrderedSet τ ∧ σ ≤ τ) ∨ (∃σ τ. ?a1.0 = PrependOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = Sequence τ ∧ σ ≤ τ) ∨ (∃σ τ. ?a1.0 = CollectionAtOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = τ ∧ σ = UnlimitedNatural[1]─Integer[1]) ∨ (∃σ τ. ?a1.0 = CollectionAtOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = τ ∧ σ = UnlimitedNatural[1]─Integer[1]) ∨ (∃σ τ. ?a1.0 = CollectionIndexOfOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = Integer[1] ∧ σ ≤ τ) ∨ (∃σ τ. ?a1.0 = CollectionIndexOfOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = Integer[1] ∧ σ ≤ τ))›*)) (*goal: ‹⟦collection_binop_type op τ σ ρ₁; collection_binop_type op τ σ ρ₂⟧ ⟹ ρ₁ = ρ₂›*) using element_type_det (*‹⟦element_type (?τ::?'a OCL_Types.type) (?σ₁::?'a OCL_Types.type); element_type ?τ (?σ₂::?'a OCL_Types.type)⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type ?τ ?σ ?ρ₁; update_element_type ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) apply - (*goals: 1. ‹⋀τ ρ σ υ. ⟦element_type τ ρ; element_type σ υ; ∃ρ υ. ρ₂ = Set (Tuple [STR ''second'' ↦⇩f υ, STR ''first'' ↦⇩f ρ]) ∧ element_type τ ρ ∧ element_type σ υ; ⋀τ σ₁ σ₂. ⟦element_type τ σ₁; element_type τ σ₂⟧ ⟹ σ₁ = σ₂; ⋀τ σ ρ₁ ρ₂. ⟦update_element_type τ σ ρ₁; update_element_type τ σ ρ₂⟧ ⟹ ρ₁ = ρ₂⟧ ⟹ Set (Tuple [STR ''second'' ↦⇩f υ, STR ''first'' ↦⇩f ρ]) = ρ₂› 2. ‹⋀τ ρ σ υ. ⟦element_type τ ρ; update_element_type τ (ρ ⊔ σ) υ; ∃ρ. element_type τ ρ ∧ update_element_type τ (ρ ⊔ σ) ρ₂; ⋀τ σ₁ σ₂. ⟦element_type τ σ₁; element_type τ σ₂⟧ ⟹ σ₁ = σ₂; ⋀τ σ ρ₁ ρ₂. ⟦update_element_type τ σ ρ₁; update_element_type τ σ ρ₂⟧ ⟹ ρ₁ = ρ₂⟧ ⟹ υ = ρ₂› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma binop_type_det: "binop_type op k τ σ ρ₁ ⟹ binop_type op k τ σ ρ₂ ⟹ ρ₁ = ρ₂" apply (induct rule: binop_type.induct (*‹⟦binop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0; ⋀op τ σ ρ. super_binop_type op τ σ ρ ⟹ ?P (Inl op) DotCall τ σ ρ; ⋀op τ σ ρ. boolean_binop_type op τ σ ρ ⟹ ?P (Inr (Inl op)) DotCall τ σ ρ; ⋀op τ σ ρ. numeric_binop_type op τ σ ρ ⟹ ?P (Inr (Inr (Inl op))) DotCall τ σ ρ; ⋀op τ σ ρ. string_binop_type op τ σ ρ ⟹ ?P (Inr (Inr (Inr (Inl op)))) DotCall τ σ ρ; ⋀op τ σ ρ. collection_binop_type op τ σ ρ ⟹ ?P (Inr (Inr (Inr (Inr op)))) ArrowCall τ σ ρ⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0›*)) (*goals: 1. ‹⋀op τ σ ρ. ⟦super_binop_type op τ σ ρ; binop_type (Inl op) DotCall τ σ ρ₂⟧ ⟹ ρ = ρ₂› 2. ‹⋀op τ σ ρ. ⟦boolean_binop_type op τ σ ρ; binop_type (Inr (Inl op)) DotCall τ σ ρ₂⟧ ⟹ ρ = ρ₂› 3. ‹⋀op τ σ ρ. ⟦numeric_binop_type op τ σ ρ; binop_type (Inr (Inr (Inl op))) DotCall τ σ ρ₂⟧ ⟹ ρ = ρ₂› 4. ‹⋀op τ σ ρ. ⟦string_binop_type op τ σ ρ; binop_type (Inr (Inr (Inr (Inl op)))) DotCall τ σ ρ₂⟧ ⟹ ρ = ρ₂› 5. ‹⋀op τ σ ρ. ⟦collection_binop_type op τ σ ρ; binop_type (Inr (Inr (Inr (Inr op)))) ArrowCall τ σ ρ₂⟧ ⟹ ρ = ρ₂› discuss goal 1*) apply (simp add: binop_type.simps (*‹binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃op τ σ ρ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ super_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ boolean_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ numeric_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ string_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ collection_binop_type op τ σ ρ))›*) super_binop_type_det (*‹⟦super_binop_type ?op ?τ ?σ ?ρ₁; super_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) boolean_binop_type_det (*‹⟦boolean_binop_type ?op ?τ ?σ ?ρ₁; boolean_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) numeric_binop_type_det (*‹⟦numeric_binop_type ?op ?τ ?σ ?ρ₁; numeric_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) string_binop_type_det (*‹⟦string_binop_type ?op ?τ ?σ ?ρ₁; string_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) collection_binop_type_det (*‹⟦collection_binop_type ?op ?τ ?σ ?ρ₁; collection_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 2*) apply (simp add: binop_type.simps (*‹binop_type (?a1.0::super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) (?a2.0::call_kind) (?a3.0::?'a OCL_Types.type) (?a4.0::?'a OCL_Types.type) (?a5.0::?'a OCL_Types.type) = ((∃(op::super_binop) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) ρ::?'a OCL_Types.type. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ super_binop_type op τ σ ρ) ∨ (∃(op::boolean_binop) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) ρ::?'a OCL_Types.type. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ boolean_binop_type op τ σ ρ) ∨ (∃(op::numeric_binop) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) ρ::?'a OCL_Types.type. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ numeric_binop_type op τ σ ρ) ∨ (∃(op::string_binop) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) ρ::?'a OCL_Types.type. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ string_binop_type op τ σ ρ) ∨ (∃(op::collection_binop) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) ρ::?'a OCL_Types.type. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ collection_binop_type op τ σ ρ))›*) super_binop_type_det (*‹⟦super_binop_type (?op::super_binop) (?τ::?'a OCL_Types.type) (?σ::?'a OCL_Types.type) (?ρ₁::?'a OCL_Types.type); super_binop_type ?op ?τ ?σ (?ρ₂::?'a OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*) boolean_binop_type_det (*‹⟦boolean_binop_type (?op::boolean_binop) (?τ::?'a OCL_Types.type) (?σ::?'a OCL_Types.type) (?ρ₁::?'a OCL_Types.type); boolean_binop_type ?op ?τ ?σ (?ρ₂::?'a OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*) numeric_binop_type_det (*‹⟦numeric_binop_type (?op::numeric_binop) (?τ::?'a OCL_Types.type) (?σ::?'a OCL_Types.type) (?ρ₁::?'a OCL_Types.type); numeric_binop_type ?op ?τ ?σ (?ρ₂::?'a OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*) string_binop_type_det (*‹⟦string_binop_type (?op::string_binop) (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'c OCL_Types.type); string_binop_type ?op ?τ ?σ (?ρ₂::?'c OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*) collection_binop_type_det (*‹⟦collection_binop_type (?op::collection_binop) (?τ::?'a OCL_Types.type) (?σ::?'a OCL_Types.type) (?ρ₁::?'a OCL_Types.type); collection_binop_type ?op ?τ ?σ (?ρ₂::?'a OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 3*) apply (simp add: binop_type.simps (*‹binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃op τ σ ρ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ super_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ boolean_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ numeric_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ string_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ collection_binop_type op τ σ ρ))›*) super_binop_type_det (*‹⟦super_binop_type ?op ?τ ?σ ?ρ₁; super_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) boolean_binop_type_det (*‹⟦boolean_binop_type ?op ?τ ?σ ?ρ₁; boolean_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) numeric_binop_type_det (*‹⟦numeric_binop_type ?op ?τ ?σ ?ρ₁; numeric_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) string_binop_type_det (*‹⟦string_binop_type ?op ?τ ?σ ?ρ₁; string_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) collection_binop_type_det (*‹⟦collection_binop_type ?op ?τ ?σ ?ρ₁; collection_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 4*) apply (simp add: binop_type.simps (*‹binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃op τ σ ρ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ super_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ boolean_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ numeric_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ string_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ collection_binop_type op τ σ ρ))›*) super_binop_type_det (*‹⟦super_binop_type ?op ?τ ?σ ?ρ₁; super_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) boolean_binop_type_det (*‹⟦boolean_binop_type ?op ?τ ?σ ?ρ₁; boolean_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) numeric_binop_type_det (*‹⟦numeric_binop_type ?op ?τ ?σ ?ρ₁; numeric_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) string_binop_type_det (*‹⟦string_binop_type ?op ?τ ?σ ?ρ₁; string_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) collection_binop_type_det (*‹⟦collection_binop_type ?op ?τ ?σ ?ρ₁; collection_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 5*) apply (simp add: binop_type.simps (*‹binop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃op τ σ ρ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ super_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inl op) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ boolean_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inl op)) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ numeric_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inl op))) ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ string_binop_type op τ σ ρ) ∨ (∃op τ σ ρ. ?a1.0 = Inr (Inr (Inr (Inr op))) ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ collection_binop_type op τ σ ρ))›*) super_binop_type_det (*‹⟦super_binop_type ?op ?τ ?σ ?ρ₁; super_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) boolean_binop_type_det (*‹⟦boolean_binop_type ?op ?τ ?σ ?ρ₁; boolean_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) numeric_binop_type_det (*‹⟦numeric_binop_type ?op ?τ ?σ ?ρ₁; numeric_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) string_binop_type_det (*‹⟦string_binop_type ?op ?τ ?σ ?ρ₁; string_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*) collection_binop_type_det (*‹⟦collection_binop_type ?op ?τ ?σ ?ρ₁; collection_binop_type ?op ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*proven 5 subgoals*) . lemma string_ternop_type_det: "string_ternop_type op τ σ ρ υ₁ ⟹ string_ternop_type op τ σ ρ υ₂ ⟹ υ₁ = υ₂" apply (induct rule: string_ternop_type.induct (*‹⟦string_ternop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0; ⋀σ ρ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ = UnlimitedNatural[1]─Integer[1]⟧ ⟹ ?P SubstringOp String[1] σ ρ String[1]⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0›*)) (*goal: ‹⟦string_ternop_type op τ σ ρ υ₁; string_ternop_type op τ σ ρ υ₂⟧ ⟹ υ₁ = υ₂›*) by (simp add: string_ternop_type.simps (*‹string_ternop_type (?a1.0::string_ternop) (?a2.0::?'c OCL_Types.type) (?a3.0::?'a OCL_Types.type) (?a4.0::?'b OCL_Types.type) (?a5.0::?'d OCL_Types.type) = (∃(σ::?'a OCL_Types.type) ρ::?'b OCL_Types.type. ?a1.0 = SubstringOp ∧ ?a2.0 = String[1] ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = String[1] ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1])›*)) lemma collection_ternop_type_det: "collection_ternop_type op τ σ ρ υ₁ ⟹ collection_ternop_type op τ σ ρ υ₂ ⟹ υ₁ = υ₂" apply (induct rule: collection_ternop_type.induct (*‹⟦collection_ternop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0; ⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ ≤ τ⟧ ⟹ ?P InsertAtOp (OrderedSet τ) σ ρ (OrderedSet τ); ⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ ≤ τ⟧ ⟹ ?P InsertAtOp (Sequence τ) σ ρ (Sequence τ); ⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ = UnlimitedNatural[1]─Integer[1]⟧ ⟹ ?P SubOrderedSetOp (OrderedSet τ) σ ρ (OrderedSet τ); ⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ = UnlimitedNatural[1]─Integer[1]⟧ ⟹ ?P SubSequenceOp (Sequence τ) σ ρ (Sequence τ)⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0›*)) (*goals: 1. ‹⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ ≤ τ; collection_ternop_type InsertAtOp (OrderedSet τ) σ ρ υ₂⟧ ⟹ OrderedSet τ = υ₂› 2. ‹⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ ≤ τ; collection_ternop_type InsertAtOp (Sequence τ) σ ρ υ₂⟧ ⟹ Sequence τ = υ₂› 3. ‹⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ = UnlimitedNatural[1]─Integer[1]; collection_ternop_type SubOrderedSetOp (OrderedSet τ) σ ρ υ₂⟧ ⟹ OrderedSet τ = υ₂› 4. ‹⋀σ ρ τ. ⟦σ = UnlimitedNatural[1]─Integer[1]; ρ = UnlimitedNatural[1]─Integer[1]; collection_ternop_type SubSequenceOp (Sequence τ) σ ρ υ₂⟧ ⟹ Sequence τ = υ₂› discuss goal 1*) apply (simp add: collection_ternop_type.simps (*‹collection_ternop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃σ ρ τ. ?a1.0 = InsertAtOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃σ ρ τ. ?a1.0 = InsertAtOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃σ ρ τ. ?a1.0 = SubOrderedSetOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]) ∨ (∃σ ρ τ. ?a1.0 = SubSequenceOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 2*) apply (simp add: collection_ternop_type.simps (*‹collection_ternop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 = ((∃σ ρ τ. ?a1.0 = InsertAtOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃σ ρ τ. ?a1.0 = InsertAtOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃σ ρ τ. ?a1.0 = SubOrderedSetOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]) ∨ (∃σ ρ τ. ?a1.0 = SubSequenceOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 3*) apply (simp add: collection_ternop_type.simps (*‹collection_ternop_type (?a1.0::collection_ternop) (?a2.0::?'b::order OCL_Types.type) (?a3.0::?'a::order OCL_Types.type) (?a4.0::?'b::order OCL_Types.type) (?a5.0::?'b::order OCL_Types.type) = ((∃(σ::?'a::order OCL_Types.type) (ρ::?'b::order OCL_Types.type) τ::?'b::order OCL_Types.type. ?a1.0 = InsertAtOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃(σ::?'a::order OCL_Types.type) (ρ::?'b::order OCL_Types.type) τ::?'b::order OCL_Types.type. ?a1.0 = InsertAtOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃(σ::?'a::order OCL_Types.type) (ρ::?'b::order OCL_Types.type) τ::?'b::order OCL_Types.type. ?a1.0 = SubOrderedSetOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]) ∨ (∃(σ::?'a::order OCL_Types.type) (ρ::?'b::order OCL_Types.type) τ::?'b::order OCL_Types.type. ?a1.0 = SubSequenceOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]))›*)) (*discuss goal 4*) apply (simp add: collection_ternop_type.simps (*‹collection_ternop_type (?a1.0::collection_ternop) (?a2.0::?'b OCL_Types.type) (?a3.0::?'a OCL_Types.type) (?a4.0::?'b OCL_Types.type) (?a5.0::?'b OCL_Types.type) = ((∃(σ::?'a OCL_Types.type) (ρ::?'b OCL_Types.type) τ::?'b OCL_Types.type. ?a1.0 = InsertAtOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃(σ::?'a OCL_Types.type) (ρ::?'b OCL_Types.type) τ::?'b OCL_Types.type. ?a1.0 = InsertAtOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ ≤ τ) ∨ (∃(σ::?'a OCL_Types.type) (ρ::?'b OCL_Types.type) τ::?'b OCL_Types.type. ?a1.0 = SubOrderedSetOp ∧ ?a2.0 = OrderedSet τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = OrderedSet τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]) ∨ (∃(σ::?'a OCL_Types.type) (ρ::?'b OCL_Types.type) τ::?'b OCL_Types.type. ?a1.0 = SubSequenceOp ∧ ?a2.0 = Sequence τ ∧ ?a3.0 = σ ∧ ?a4.0 = ρ ∧ ?a5.0 = Sequence τ ∧ σ = UnlimitedNatural[1]─Integer[1] ∧ ρ = UnlimitedNatural[1]─Integer[1]))›*)) (*proven 4 subgoals*) . lemma ternop_type_det: "ternop_type op k τ σ ρ υ₁ ⟹ ternop_type op k τ σ ρ υ₂ ⟹ υ₁ = υ₂" apply (induct rule: ternop_type.induct (*‹⟦ternop_type ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0 ?x6.0; ⋀op τ σ ρ υ. string_ternop_type op τ σ ρ υ ⟹ ?P (Inl op) DotCall τ σ ρ υ; ⋀op τ σ ρ υ. collection_ternop_type op τ σ ρ υ ⟹ ?P (Inr op) ArrowCall τ σ ρ υ⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0 ?x6.0›*)) (*goals: 1. ‹⋀op τ σ ρ υ. ⟦string_ternop_type op τ σ ρ υ; ternop_type (Inl op) DotCall τ σ ρ υ₂⟧ ⟹ υ = υ₂› 2. ‹⋀op τ σ ρ υ. ⟦collection_ternop_type op τ σ ρ υ; ternop_type (Inr op) ArrowCall τ σ ρ υ₂⟧ ⟹ υ = υ₂› discuss goal 1*) apply (simp add: ternop_type.simps (*‹ternop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 ?a6.0 = ((∃op τ σ ρ υ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ ?a6.0 = υ ∧ string_ternop_type op τ σ ρ υ) ∨ (∃op τ σ ρ υ. ?a1.0 = Inr op ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ ?a6.0 = υ ∧ collection_ternop_type op τ σ ρ υ))›*) string_ternop_type_det (*‹⟦string_ternop_type ?op ?τ ?σ ?ρ ?υ₁; string_ternop_type ?op ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*) collection_ternop_type_det (*‹⟦collection_ternop_type ?op ?τ ?σ ?ρ ?υ₁; collection_ternop_type ?op ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*)) (*discuss goal 2*) apply (simp add: ternop_type.simps (*‹ternop_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0 ?a6.0 = ((∃op τ σ ρ υ. ?a1.0 = Inl op ∧ ?a2.0 = DotCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ ?a6.0 = υ ∧ string_ternop_type op τ σ ρ υ) ∨ (∃op τ σ ρ υ. ?a1.0 = Inr op ∧ ?a2.0 = ArrowCall ∧ ?a3.0 = τ ∧ ?a4.0 = σ ∧ ?a5.0 = ρ ∧ ?a6.0 = υ ∧ collection_ternop_type op τ σ ρ υ))›*) string_ternop_type_det (*‹⟦string_ternop_type ?op ?τ ?σ ?ρ ?υ₁; string_ternop_type ?op ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*) collection_ternop_type_det (*‹⟦collection_ternop_type ?op ?τ ?σ ?ρ ?υ₁; collection_ternop_type ?op ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*)) (*proven 2 subgoals*) . lemma op_type_det: "op_type op k τ π σ ⟹ op_type op k τ π ρ ⟹ σ = ρ" apply (induct rule: op_type.induct (*‹⟦op_type ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0; ⋀op k τ υ. unop_type op k τ υ ⟹ ?P (Inl op) k τ [] υ; ⋀op k τ σ υ. binop_type op k τ σ υ ⟹ ?P (Inr (Inl op)) k τ [σ] υ; ⋀op k τ σ ρ υ. ternop_type op k τ σ ρ υ ⟹ ?P (Inr (Inr (Inl op))) k τ [σ, ρ] υ; ⋀τ op π oper. operation τ op π oper ⟹ ?P (Inr (Inr (Inr op))) DotCall τ π (oper_type oper)⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0›*)) (*goals: 1. ‹⋀op k τ υ. ⟦unop_type op k τ υ; op_type (Inl op) k τ [] ρ⟧ ⟹ υ = ρ› 2. ‹⋀op k τ σ υ. ⟦binop_type op k τ σ υ; op_type (Inr (Inl op)) k τ [σ] ρ⟧ ⟹ υ = ρ› 3. ‹⋀op k τ σ ρ' υ. ⟦ternop_type op k τ σ ρ' υ; op_type (Inr (Inr (Inl op))) k τ [σ, ρ'] ρ⟧ ⟹ υ = ρ› 4. ‹⋀τ op π oper. ⟦operation τ op π oper; op_type (Inr (Inr (Inr op))) DotCall τ π ρ⟧ ⟹ oper_type oper = ρ› discuss goal 1*) apply (erule op_type.cases (*‹⟦op_type (?a1.0::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (?a2.0::call_kind) (?a3.0::?'a OCL_Types.type) (?a4.0::?'a OCL_Types.type list) (?a5.0::?'a OCL_Types.type); ⋀(op::any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) (k::call_kind) (τ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inl op; ?a2.0 = k; ?a3.0 = τ; ?a4.0 = []; ?a5.0 = υ; unop_type op k τ υ⟧ ⟹ ?P::bool; ⋀(op::super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) (k::call_kind) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inr (Inl op); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ]; ?a5.0 = υ; binop_type op k τ σ υ⟧ ⟹ ?P; ⋀(op::string_ternop + collection_ternop) (k::call_kind) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) (ρ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inr (Inr (Inl op)); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ, ρ]; ?a5.0 = υ; ternop_type op k τ σ ρ υ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (op::String.literal) (π::?'a OCL_Types.type list) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = Inr (Inr (Inr op)); ?a2.0 = DotCall; ?a3.0 = τ; ?a4.0 = π; ?a5.0 = oper_type oper; operation τ op π oper⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀op k τ υ opa ka τ' υ'. ⟦unop_type op k τ υ; Inl op = Inl opa; k = ka; τ = τ'; [] = []; ρ = υ'; unop_type opa ka τ' υ'⟧ ⟹ υ = ρ› 2. ‹⋀op k τ υ opa ka τ' σ υ'. ⟦unop_type op k τ υ; Inl op = Inr (Inl opa); k = ka; τ = τ'; [] = [σ]; ρ = υ'; binop_type opa ka τ' σ υ'⟧ ⟹ υ = ρ› 3. ‹⋀op k τ υ opa ka τ' σ ρ' υ'. ⟦unop_type op k τ υ; Inl op = Inr (Inr (Inl opa)); k = ka; τ = τ'; [] = [σ, ρ']; ρ = υ'; ternop_type opa ka τ' σ ρ' υ'⟧ ⟹ υ = ρ› 4. ‹⋀op k τ υ τ' opa π oper. ⟦unop_type op k τ υ; Inl op = Inr (Inr (Inr opa)); k = DotCall; τ = τ'; [] = π; ρ = oper_type oper; operation τ' opa π oper⟧ ⟹ υ = ρ› discuss goal 1*) apply (simp add: unop_type_det (*‹⟦unop_type ?op ?k ?τ ?σ₁; unop_type ?op ?k ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 2*) apply (simp add: unop_type_det (*‹⟦unop_type ?op ?k ?τ ?σ₁; unop_type ?op ?k ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 3*) apply (simp add: unop_type_det (*‹⟦unop_type ?op ?k ?τ ?σ₁; unop_type ?op ?k ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*discuss goal 4*) apply (simp add: unop_type_det (*‹⟦unop_type ?op ?k ?τ ?σ₁; unop_type ?op ?k ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*)) (*proven 4 subgoals*) (*discuss goal 2*) apply (erule op_type.cases (*‹⟦op_type (?a1.0::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (?a2.0::call_kind) (?a3.0::?'a OCL_Types.type) (?a4.0::?'a OCL_Types.type list) (?a5.0::?'a OCL_Types.type); ⋀(op::any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) (k::call_kind) (τ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inl op; ?a2.0 = k; ?a3.0 = τ; ?a4.0 = []; ?a5.0 = υ; unop_type op k τ υ⟧ ⟹ ?P::bool; ⋀(op::super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) (k::call_kind) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inr (Inl op); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ]; ?a5.0 = υ; binop_type op k τ σ υ⟧ ⟹ ?P; ⋀(op::string_ternop + collection_ternop) (k::call_kind) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) (ρ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inr (Inr (Inl op)); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ, ρ]; ?a5.0 = υ; ternop_type op k τ σ ρ υ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (op::String.literal) (π::?'a OCL_Types.type list) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = Inr (Inr (Inr op)); ?a2.0 = DotCall; ?a3.0 = τ; ?a4.0 = π; ?a5.0 = oper_type oper; operation τ op π oper⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀op k τ σ υ opa ka τ' υ'. ⟦binop_type op k τ σ υ; Inr (Inl op) = Inl opa; k = ka; τ = τ'; [σ] = []; ρ = υ'; unop_type opa ka τ' υ'⟧ ⟹ υ = ρ› 2. ‹⋀op k τ σ υ opa ka τ' σ' υ'. ⟦binop_type op k τ σ υ; Inr (Inl op) = Inr (Inl opa); k = ka; τ = τ'; [σ] = [σ']; ρ = υ'; binop_type opa ka τ' σ' υ'⟧ ⟹ υ = ρ› 3. ‹⋀op k τ σ υ opa ka τ' σ' ρ' υ'. ⟦binop_type op k τ σ υ; Inr (Inl op) = Inr (Inr (Inl opa)); k = ka; τ = τ'; [σ] = [σ', ρ']; ρ = υ'; ternop_type opa ka τ' σ' ρ' υ'⟧ ⟹ υ = ρ› 4. ‹⋀op k τ σ υ τ' opa π oper. ⟦binop_type op k τ σ υ; Inr (Inl op) = Inr (Inr (Inr opa)); k = DotCall; τ = τ'; [σ] = π; ρ = oper_type oper; operation τ' opa π oper⟧ ⟹ υ = ρ› discuss goal 1*) apply (simp add: binop_type_det (*‹⟦binop_type ?op ?k ?τ ?σ ?ρ₁; binop_type ?op ?k ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 2*) apply (simp add: binop_type_det (*‹⟦binop_type ?op ?k ?τ ?σ ?ρ₁; binop_type ?op ?k ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 3*) apply (simp add: binop_type_det (*‹⟦binop_type ?op ?k ?τ ?σ ?ρ₁; binop_type ?op ?k ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*discuss goal 4*) apply (simp add: binop_type_det (*‹⟦binop_type ?op ?k ?τ ?σ ?ρ₁; binop_type ?op ?k ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) (*proven 4 subgoals*) (*discuss goal 3*) apply (erule op_type.cases (*‹⟦op_type (?a1.0::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (?a2.0::call_kind) (?a3.0::?'a OCL_Types.type) (?a4.0::?'a OCL_Types.type list) (?a5.0::?'a OCL_Types.type); ⋀(op::any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) (k::call_kind) (τ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inl op; ?a2.0 = k; ?a3.0 = τ; ?a4.0 = []; ?a5.0 = υ; unop_type op k τ υ⟧ ⟹ ?P::bool; ⋀(op::super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) (k::call_kind) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inr (Inl op); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ]; ?a5.0 = υ; binop_type op k τ σ υ⟧ ⟹ ?P; ⋀(op::string_ternop + collection_ternop) (k::call_kind) (τ::?'a OCL_Types.type) (σ::?'a OCL_Types.type) (ρ::?'a OCL_Types.type) υ::?'a OCL_Types.type. ⟦?a1.0 = Inr (Inr (Inl op)); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ, ρ]; ?a5.0 = υ; ternop_type op k τ σ ρ υ⟧ ⟹ ?P; ⋀(τ::?'a OCL_Types.type) (op::String.literal) (π::?'a OCL_Types.type list) oper::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option. ⟦?a1.0 = Inr (Inr (Inr op)); ?a2.0 = DotCall; ?a3.0 = τ; ?a4.0 = π; ?a5.0 = oper_type oper; operation τ op π oper⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀op k τ σ ρ' υ opa ka τ' υ'. ⟦ternop_type op k τ σ ρ' υ; Inr (Inr (Inl op)) = Inl opa; k = ka; τ = τ'; [σ, ρ'] = []; ρ = υ'; unop_type opa ka τ' υ'⟧ ⟹ υ = ρ› 2. ‹⋀op k τ σ ρ' υ opa ka τ' σ' υ'. ⟦ternop_type op k τ σ ρ' υ; Inr (Inr (Inl op)) = Inr (Inl opa); k = ka; τ = τ'; [σ, ρ'] = [σ']; ρ = υ'; binop_type opa ka τ' σ' υ'⟧ ⟹ υ = ρ› 3. ‹⋀op k τ σ ρ' υ opa ka τ' σ' ρ'' υ'. ⟦ternop_type op k τ σ ρ' υ; Inr (Inr (Inl op)) = Inr (Inr (Inl opa)); k = ka; τ = τ'; [σ, ρ'] = [σ', ρ'']; ρ = υ'; ternop_type opa ka τ' σ' ρ'' υ'⟧ ⟹ υ = ρ› 4. ‹⋀op k τ σ ρ' υ τ' opa π oper. ⟦ternop_type op k τ σ ρ' υ; Inr (Inr (Inl op)) = Inr (Inr (Inr opa)); k = DotCall; τ = τ'; [σ, ρ'] = π; ρ = oper_type oper; operation τ' opa π oper⟧ ⟹ υ = ρ› discuss goal 1*) apply (simp add: ternop_type_det (*‹⟦ternop_type ?op ?k ?τ ?σ ?ρ ?υ₁; ternop_type ?op ?k ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*)) (*discuss goal 2*) apply (simp add: ternop_type_det (*‹⟦ternop_type ?op ?k ?τ ?σ ?ρ ?υ₁; ternop_type ?op ?k ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*)) (*discuss goal 3*) apply (simp add: ternop_type_det (*‹⟦ternop_type ?op ?k ?τ ?σ ?ρ ?υ₁; ternop_type ?op ?k ?τ ?σ ?ρ ?υ₂⟧ ⟹ ?υ₁ = ?υ₂›*)) (*discuss goal 4*) apply (simp add: ternop_type_det (*‹⟦ternop_type (?op::string_ternop + collection_ternop) (?k::call_kind) (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ::?'a OCL_Types.type) (?υ₁::?'a OCL_Types.type); ternop_type ?op ?k ?τ ?σ ?ρ (?υ₂::?'a OCL_Types.type)⟧ ⟹ ?υ₁ = ?υ₂›*)) (*proven 4 subgoals*) (*discuss goal 4*) apply (erule op_type.cases (*‹⟦op_type ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀op k τ υ. ⟦?a1.0 = Inl op; ?a2.0 = k; ?a3.0 = τ; ?a4.0 = []; ?a5.0 = υ; unop_type op k τ υ⟧ ⟹ ?P; ⋀op k τ σ υ. ⟦?a1.0 = Inr (Inl op); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ]; ?a5.0 = υ; binop_type op k τ σ υ⟧ ⟹ ?P; ⋀op k τ σ ρ υ. ⟦?a1.0 = Inr (Inr (Inl op)); ?a2.0 = k; ?a3.0 = τ; ?a4.0 = [σ, ρ]; ?a5.0 = υ; ternop_type op k τ σ ρ υ⟧ ⟹ ?P; ⋀τ op π oper. ⟦?a1.0 = Inr (Inr (Inr op)); ?a2.0 = DotCall; ?a3.0 = τ; ?a4.0 = π; ?a5.0 = oper_type oper; operation τ op π oper⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (op::String.literal) (π::'a::ocl_object_model OCL_Types.type list) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (opa::any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) (k::call_kind) (τ'::'a::ocl_object_model OCL_Types.type) υ::'a::ocl_object_model OCL_Types.type. ⟦operation τ op π oper; Inr (Inr (Inr op)) = Inl opa; DotCall = k; τ = τ'; π = []; (ρ::'a::ocl_object_model OCL_Types.type) = υ; unop_type opa k τ' υ⟧ ⟹ oper_type oper = ρ› 2. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (op::String.literal) (π::'a::ocl_object_model OCL_Types.type list) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (opa::super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) (k::call_kind) (τ'::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) υ::'a::ocl_object_model OCL_Types.type. ⟦operation τ op π oper; Inr (Inr (Inr op)) = Inr (Inl opa); DotCall = k; τ = τ'; π = [σ]; (ρ::'a::ocl_object_model OCL_Types.type) = υ; binop_type opa k τ' σ υ⟧ ⟹ oper_type oper = ρ› 3. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (op::String.literal) (π::'a::ocl_object_model OCL_Types.type list) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (opa::string_ternop + collection_ternop) (k::call_kind) (τ'::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ'::'a::ocl_object_model OCL_Types.type) υ::'a::ocl_object_model OCL_Types.type. ⟦operation τ op π oper; Inr (Inr (Inr op)) = Inr (Inr (Inl opa)); DotCall = k; τ = τ'; π = [σ, ρ']; (ρ::'a::ocl_object_model OCL_Types.type) = υ; ternop_type opa k τ' σ ρ' υ⟧ ⟹ oper_type oper = ρ› 4. ‹⋀(τ::'a::ocl_object_model OCL_Types.type) (op::String.literal) (π::'a::ocl_object_model OCL_Types.type list) (oper::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option) (τ'::'a::ocl_object_model OCL_Types.type) (opa::String.literal) (π'::'a::ocl_object_model OCL_Types.type list) opera::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option. ⟦operation τ op π oper; Inr (Inr (Inr op)) = Inr (Inr (Inr opa)); DotCall = DotCall; τ = τ'; π = π'; (ρ::'a::ocl_object_model OCL_Types.type) = oper_type opera; operation τ' opa π' opera⟧ ⟹ oper_type oper = ρ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*goal: ‹⋀τ op π oper τ' opa π' opera. ⟦operation τ op π oper; Inr (Inr (Inr op)) = Inr (Inr (Inr opa)); DotCall = DotCall; τ = τ'; π = π'; ρ = oper_type opera; operation τ' opa π' opera⟧ ⟹ oper_type oper = ρ›*) apply (metis operation_det (*‹⟦operation (?τ::?'a OCL_Types.type) (?name::String.literal) (?π::?'a OCL_Types.type list) (?oper₁::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option); operation ?τ ?name ?π (?oper₂::String.literal × ?'a OCL_Types.type × (String.literal × ?'a OCL_Types.type × param_dir) list × ?'a OCL_Types.type × bool × ?'a expr option)⟧ ⟹ ?oper₁ = ?oper₂›*)) (*proven 4 subgoals*) (*proven 4 subgoals*) . (*** Expressions Typing *****************************************************) section ‹Expressions Typing› text ‹ The following typing rules are preliminary. The final rules are given at the end of the next chapter.› inductive typing :: "('a :: ocl_object_model) type env ⇒ 'a expr ⇒ 'a type ⇒ bool" ("(1_/ ⊢⇩E/ (_ :/ _))" [51,51,51] 50) and collection_parts_typing ("(1_/ ⊢⇩C/ (_ :/ _))" [51,51,51] 50) and collection_part_typing ("(1_/ ⊢⇩P/ (_ :/ _))" [51,51,51] 50) and iterator_typing ("(1_/ ⊢⇩I/ (_ :/ _))" [51,51,51] 50) and expr_list_typing ("(1_/ ⊢⇩L/ (_ :/ _))" [51,51,51] 50) where ― ‹Primitive Literals› NullLiteralT: "Γ ⊢⇩E NullLiteral : OclVoid[?]" |BooleanLiteralT: "Γ ⊢⇩E BooleanLiteral c : Boolean[1]" |RealLiteralT: "Γ ⊢⇩E RealLiteral c : Real[1]" |IntegerLiteralT: "Γ ⊢⇩E IntegerLiteral c : Integer[1]" |UnlimitedNaturalLiteralT: "Γ ⊢⇩E UnlimitedNaturalLiteral c : UnlimitedNatural[1]" |StringLiteralT: "Γ ⊢⇩E StringLiteral c : String[1]" |EnumLiteralT: "has_literal enum lit ⟹ Γ ⊢⇩E EnumLiteral enum lit : (Enum enum)[1]" ― ‹Collection Literals› |SetLiteralT: "Γ ⊢⇩C prts : τ ⟹ Γ ⊢⇩E CollectionLiteral SetKind prts : Set τ" |OrderedSetLiteralT: "Γ ⊢⇩C prts : τ ⟹ Γ ⊢⇩E CollectionLiteral OrderedSetKind prts : OrderedSet τ" |BagLiteralT: "Γ ⊢⇩C prts : τ ⟹ Γ ⊢⇩E CollectionLiteral BagKind prts : Bag τ" |SequenceLiteralT: "Γ ⊢⇩C prts : τ ⟹ Γ ⊢⇩E CollectionLiteral SequenceKind prts : Sequence τ" ― ‹We prohibit empty collection literals, because their type is unclear. We could use @{text "OclVoid[1]"} element type for empty collections, but the typing rules will give wrong types for nested collections, because, for example, @{text "OclVoid[1] ⊔ Set(Integer[1]) = OclSuper"}› |CollectionPartsSingletonT: "Γ ⊢⇩P x : τ ⟹ Γ ⊢⇩C [x] : τ" |CollectionPartsListT: "Γ ⊢⇩P x : τ ⟹ Γ ⊢⇩C y # xs : σ ⟹ Γ ⊢⇩C x # y # xs : τ ⊔ σ" |CollectionPartItemT: "Γ ⊢⇩E a : τ ⟹ Γ ⊢⇩P CollectionItem a : τ" |CollectionPartRangeT: "Γ ⊢⇩E a : τ ⟹ Γ ⊢⇩E b : σ ⟹ τ = UnlimitedNatural[1]─Integer[1] ⟹ σ = UnlimitedNatural[1]─Integer[1] ⟹ Γ ⊢⇩P CollectionRange a b : Integer[1]" ― ‹Tuple Literals› ― ‹We do not prohibit empty tuples, because it could be useful. @{text "Tuple()"} is a supertype of all other tuple types.› |TupleLiteralNilT: "Γ ⊢⇩E TupleLiteral [] : Tuple fmempty" |TupleLiteralConsT: "Γ ⊢⇩E TupleLiteral elems : Tuple ξ ⟹ Γ ⊢⇩E tuple_element_expr el : τ ⟹ tuple_element_type el = Some σ ⟹ τ ≤ σ ⟹ Γ ⊢⇩E TupleLiteral (el # elems) : Tuple (ξ(tuple_element_name el ↦⇩f σ))" ― ‹Misc Expressions› |LetT: "Γ ⊢⇩E init : σ ⟹ σ ≤ τ ⟹ Γ(v ↦⇩f τ) ⊢⇩E body : ρ ⟹ Γ ⊢⇩E Let v (Some τ) init body : ρ" |VarT: "fmlookup Γ v = Some τ ⟹ Γ ⊢⇩E Var v : τ" |IfT: "Γ ⊢⇩E a : Boolean[1] ⟹ Γ ⊢⇩E b : σ ⟹ Γ ⊢⇩E c : ρ ⟹ Γ ⊢⇩E If a b c : σ ⊔ ρ" ― ‹Call Expressions› |MetaOperationCallT: "mataop_type τ op σ ⟹ Γ ⊢⇩E MetaOperationCall τ op : σ" |StaticOperationCallT: "Γ ⊢⇩L params : π ⟹ static_operation τ op π oper ⟹ Γ ⊢⇩E StaticOperationCall τ op params : oper_type oper" |TypeOperationCallT: "Γ ⊢⇩E a : τ ⟹ typeop_type k op τ σ ρ ⟹ Γ ⊢⇩E TypeOperationCall a k op σ : ρ" |AttributeCallT: "Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1] ⟹ attribute 𝒞 prop 𝒟 τ ⟹ Γ ⊢⇩E AttributeCall src DotCall prop : τ" |AssociationEndCallT: "Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1] ⟹ association_end 𝒞 from role 𝒟 end ⟹ Γ ⊢⇩E AssociationEndCall src DotCall from role : assoc_end_type end" |AssociationClassCallT: "Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1] ⟹ referred_by_association_class 𝒞 from 𝒜 𝒟 ⟹ Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : class_assoc_type 𝒜" |AssociationClassEndCallT: "Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1] ⟹ association_class_end 𝒜 role end ⟹ Γ ⊢⇩E AssociationClassEndCall src DotCall role : class_assoc_end_type end" |OperationCallT: "Γ ⊢⇩E src : τ ⟹ Γ ⊢⇩L params : π ⟹ op_type op k τ π σ ⟹ Γ ⊢⇩E OperationCall src k op params : σ" |TupleElementCallT: "Γ ⊢⇩E src : Tuple π ⟹ fmlookup π elem = Some τ ⟹ Γ ⊢⇩E TupleElementCall src DotCall elem : τ" ― ‹Iterator Expressions› |IteratorT: "Γ ⊢⇩E src : τ ⟹ element_type τ σ ⟹ σ ≤ its_ty ⟹ Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ ⟹ Γ ⊢⇩I (src, its, (Some its_ty), body) : (τ, σ, ρ)" |IterateT: "Γ ⊢⇩I (src, its, its_ty, Let res (Some res_t) res_init body) : (τ, σ, ρ) ⟹ ρ ≤ res_t ⟹ Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : ρ" |AnyIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ ρ ≤ Boolean[?] ⟹ Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ" |ClosureIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ to_single_type ρ ≤ σ ⟹ to_unique_collection τ υ ⟹ Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : υ" |CollectIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ to_nonunique_collection τ υ ⟹ update_element_type υ (to_single_type ρ) φ ⟹ Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : φ" |CollectNestedIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ to_nonunique_collection τ υ ⟹ update_element_type υ ρ φ ⟹ Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : φ" |ExistsIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ ρ ≤ Boolean[?] ⟹ Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : ρ" |ForAllIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ ρ ≤ Boolean[?] ⟹ Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : ρ" |OneIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ ρ ≤ Boolean[?] ⟹ Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : Boolean[1]" |IsUniqueIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : Boolean[1]" |SelectIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ ρ ≤ Boolean[?] ⟹ Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : τ" |RejectIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ ρ ≤ Boolean[?] ⟹ Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : τ" |SortedByIteratorT: "Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ) ⟹ length its ≤ 1 ⟹ to_ordered_collection τ υ ⟹ Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : υ" ― ‹Expression Lists› |ExprListNilT: "Γ ⊢⇩L [] : []" |ExprListConsT: "Γ ⊢⇩E expr : τ ⟹ Γ ⊢⇩L exprs : π ⟹ Γ ⊢⇩L expr # exprs : τ # π" (*** Elimination Rules ******************************************************) section ‹Elimination Rules› inductive_cases NullLiteralTE [elim]: "Γ ⊢⇩E NullLiteral : τ" inductive_cases BooleanLiteralTE [elim]: "Γ ⊢⇩E BooleanLiteral c : τ" inductive_cases RealLiteralTE [elim]: "Γ ⊢⇩E RealLiteral c : τ" inductive_cases IntegerLiteralTE [elim]: "Γ ⊢⇩E IntegerLiteral c : τ" inductive_cases UnlimitedNaturalLiteralTE [elim]: "Γ ⊢⇩E UnlimitedNaturalLiteral c : τ" inductive_cases StringLiteralTE [elim]: "Γ ⊢⇩E StringLiteral c : τ" inductive_cases EnumLiteralTE [elim]: "Γ ⊢⇩E EnumLiteral enm lit : τ" inductive_cases CollectionLiteralTE [elim]: "Γ ⊢⇩E CollectionLiteral k prts : τ" inductive_cases TupleLiteralTE [elim]: "Γ ⊢⇩E TupleLiteral elems : τ" inductive_cases LetTE [elim]: "Γ ⊢⇩E Let v τ init body : σ" inductive_cases VarTE [elim]: "Γ ⊢⇩E Var v : τ" inductive_cases IfTE [elim]: "Γ ⊢⇩E If a b c : τ" inductive_cases MetaOperationCallTE [elim]: "Γ ⊢⇩E MetaOperationCall τ op : σ" inductive_cases StaticOperationCallTE [elim]: "Γ ⊢⇩E StaticOperationCall τ op as : σ" inductive_cases TypeOperationCallTE [elim]: "Γ ⊢⇩E TypeOperationCall a k op σ : τ" inductive_cases AttributeCallTE [elim]: "Γ ⊢⇩E AttributeCall src k prop : τ" inductive_cases AssociationEndCallTE [elim]: "Γ ⊢⇩E AssociationEndCall src k role from : τ" inductive_cases AssociationClassCallTE [elim]: "Γ ⊢⇩E AssociationClassCall src k a from : τ" inductive_cases AssociationClassEndCallTE [elim]: "Γ ⊢⇩E AssociationClassEndCall src k role : τ" inductive_cases OperationCallTE [elim]: "Γ ⊢⇩E OperationCall src k op params : τ" inductive_cases TupleElementCallTE [elim]: "Γ ⊢⇩E TupleElementCall src k elem : τ" inductive_cases IteratorTE [elim]: "Γ ⊢⇩I (src, its, body) : ys" inductive_cases IterateTE [elim]: "Γ ⊢⇩E IterateCall src k its its_ty res res_t res_init body : τ" inductive_cases AnyIteratorTE [elim]: "Γ ⊢⇩E AnyIteratorCall src k its its_ty body : τ" inductive_cases ClosureIteratorTE [elim]: "Γ ⊢⇩E ClosureIteratorCall src k its its_ty body : τ" inductive_cases CollectIteratorTE [elim]: "Γ ⊢⇩E CollectIteratorCall src k its its_ty body : τ" inductive_cases CollectNestedIteratorTE [elim]: "Γ ⊢⇩E CollectNestedIteratorCall src k its its_ty body : τ" inductive_cases ExistsIteratorTE [elim]: "Γ ⊢⇩E ExistsIteratorCall src k its its_ty body : τ" inductive_cases ForAllIteratorTE [elim]: "Γ ⊢⇩E ForAllIteratorCall src k its its_ty body : τ" inductive_cases OneIteratorTE [elim]: "Γ ⊢⇩E OneIteratorCall src k its its_ty body : τ" inductive_cases IsUniqueIteratorTE [elim]: "Γ ⊢⇩E IsUniqueIteratorCall src k its its_ty body : τ" inductive_cases SelectIteratorTE [elim]: "Γ ⊢⇩E SelectIteratorCall src k its its_ty body : τ" inductive_cases RejectIteratorTE [elim]: "Γ ⊢⇩E RejectIteratorCall src k its its_ty body : τ" inductive_cases SortedByIteratorTE [elim]: "Γ ⊢⇩E SortedByIteratorCall src k its its_ty body : τ" inductive_cases CollectionPartsNilTE [elim]: "Γ ⊢⇩C [x] : τ" inductive_cases CollectionPartsItemTE [elim]: "Γ ⊢⇩C x # y # xs : τ" inductive_cases CollectionItemTE [elim]: "Γ ⊢⇩P CollectionItem a : τ" inductive_cases CollectionRangeTE [elim]: "Γ ⊢⇩P CollectionRange a b : τ" inductive_cases ExprListTE [elim]: "Γ ⊢⇩L exprs : π" (*** Simplification Rules ***************************************************) section ‹Simplification Rules› inductive_simps typing_alt_simps: "Γ ⊢⇩E NullLiteral : τ" "Γ ⊢⇩E BooleanLiteral c : τ" "Γ ⊢⇩E RealLiteral c : τ" "Γ ⊢⇩E UnlimitedNaturalLiteral c : τ" "Γ ⊢⇩E IntegerLiteral c : τ" "Γ ⊢⇩E StringLiteral c : τ" "Γ ⊢⇩E EnumLiteral enm lit : τ" "Γ ⊢⇩E CollectionLiteral k prts : τ" "Γ ⊢⇩E TupleLiteral [] : τ" "Γ ⊢⇩E TupleLiteral (x # xs) : τ" "Γ ⊢⇩E Let v τ init body : σ" "Γ ⊢⇩E Var v : τ" "Γ ⊢⇩E If a b c : τ" "Γ ⊢⇩E MetaOperationCall τ op : σ" "Γ ⊢⇩E StaticOperationCall τ op as : σ" "Γ ⊢⇩E TypeOperationCall a k op σ : τ" "Γ ⊢⇩E AttributeCall src k prop : τ" "Γ ⊢⇩E AssociationEndCall src k role from : τ" "Γ ⊢⇩E AssociationClassCall src k a from : τ" "Γ ⊢⇩E AssociationClassEndCall src k role : τ" "Γ ⊢⇩E OperationCall src k op params : τ" "Γ ⊢⇩E TupleElementCall src k elem : τ" "Γ ⊢⇩I (src, its, body) : ys" "Γ ⊢⇩E IterateCall src k its its_ty res res_t res_init body : τ" "Γ ⊢⇩E AnyIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E ClosureIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E CollectIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E CollectNestedIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E ExistsIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E ForAllIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E OneIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E IsUniqueIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E SelectIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E RejectIteratorCall src k its its_ty body : τ" "Γ ⊢⇩E SortedByIteratorCall src k its its_ty body : τ" "Γ ⊢⇩C [x] : τ" "Γ ⊢⇩C x # y # xs : τ" "Γ ⊢⇩P CollectionItem a : τ" "Γ ⊢⇩P CollectionRange a b : τ" "Γ ⊢⇩L [] : π" "Γ ⊢⇩L x # xs : π" (*** Determinism ************************************************************) section ‹Determinism› lemma typing_det: "Γ ⊢⇩E expr : τ ⟹ Γ ⊢⇩E expr : σ ⟹ τ = σ" and collection_parts_typing_det: "Γ ⊢⇩C prts : τ ⟹ Γ ⊢⇩C prts : σ ⟹ τ = σ" and collection_part_typing_det: "Γ ⊢⇩P prt : τ ⟹ Γ ⊢⇩P prt : σ ⟹ τ = σ" and iterator_typing_det: "Γ ⊢⇩I (src, its, body) : xs ⟹ Γ ⊢⇩I (src, its, body) : ys ⟹ xs = ys" and expr_list_typing_det: "Γ ⊢⇩L exprs : π ⟹ Γ ⊢⇩L exprs : ξ ⟹ π = ξ" proof (induct arbitrary: σ and σ and σ and ys and ξ rule: typing_collection_parts_typing_collection_part_typing_iterator_typing_expr_list_typing.inducts) (*goals: 1. ‹⋀Γ σ. Γ ⊢⇩E Literal NullLiteral : σ ⟹ OclVoid[?] = σ› 2. ‹⋀Γ c σ. Γ ⊢⇩E Literal (BooleanLiteral c) : σ ⟹ Boolean[1] = σ› 3. ‹⋀Γ c σ. Γ ⊢⇩E Literal (RealLiteral c) : σ ⟹ Real[1] = σ› 4. ‹⋀Γ c σ. Γ ⊢⇩E Literal (IntegerLiteral c) : σ ⟹ Integer[1] = σ› 5. ‹⋀Γ c σ. Γ ⊢⇩E Literal (UnlimitedNaturalLiteral c) : σ ⟹ UnlimitedNatural[1] = σ› 6. ‹⋀Γ c σ. Γ ⊢⇩E Literal (StringLiteral c) : σ ⟹ String[1] = σ› 7. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 8. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 9. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 10. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 11. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 12. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 13. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 14. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 15. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 16. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 17. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 18. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 19. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 20. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 21. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 22. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 23. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 24. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 25. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 26. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 27. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 28. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 29. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 30. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 31. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 37. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 38. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 39. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 40. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 41. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 42. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 43. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 44. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (NullLiteralT Γ) (*‹Γ ⊢⇩E Literal NullLiteral : σ›*) thus "?case" (*goal: ‹OclVoid[?] = σ›*) by auto next (*goals: 1. ‹⋀Γ c σ. Γ ⊢⇩E Literal (BooleanLiteral c) : σ ⟹ Boolean[1] = σ› 2. ‹⋀Γ c σ. Γ ⊢⇩E Literal (RealLiteral c) : σ ⟹ Real[1] = σ› 3. ‹⋀Γ c σ. Γ ⊢⇩E Literal (IntegerLiteral c) : σ ⟹ Integer[1] = σ› 4. ‹⋀Γ c σ. Γ ⊢⇩E Literal (UnlimitedNaturalLiteral c) : σ ⟹ UnlimitedNatural[1] = σ› 5. ‹⋀Γ c σ. Γ ⊢⇩E Literal (StringLiteral c) : σ ⟹ String[1] = σ› 6. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 7. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 8. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 9. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 10. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 11. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 12. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 13. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 14. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 15. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 16. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 17. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 18. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 19. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 20. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 21. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 22. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 23. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 24. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 25. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 26. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 27. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 28. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 29. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 30. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 37. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 38. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 39. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 40. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 41. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 42. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 43. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (BooleanLiteralT Γ c) (*‹Γ ⊢⇩E Literal (BooleanLiteral c) : σ›*) thus "?case" (*goal: ‹Boolean[1] = σ›*) by auto next (*goals: 1. ‹⋀Γ c σ. Γ ⊢⇩E Literal (RealLiteral c) : σ ⟹ Real[1] = σ› 2. ‹⋀Γ c σ. Γ ⊢⇩E Literal (IntegerLiteral c) : σ ⟹ Integer[1] = σ› 3. ‹⋀Γ c σ. Γ ⊢⇩E Literal (UnlimitedNaturalLiteral c) : σ ⟹ UnlimitedNatural[1] = σ› 4. ‹⋀Γ c σ. Γ ⊢⇩E Literal (StringLiteral c) : σ ⟹ String[1] = σ› 5. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 6. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 7. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 8. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 9. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 10. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 11. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 12. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 13. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 14. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 15. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 16. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 17. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 18. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 19. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 20. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 21. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 22. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 23. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 24. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 25. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 26. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 27. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 28. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 29. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 37. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 38. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 39. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 40. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 41. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 42. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (RealLiteralT Γ c) (*‹Γ ⊢⇩E Literal (RealLiteral c) : σ›*) thus "?case" (*goal: ‹Real[1] = σ›*) by auto next (*goals: 1. ‹⋀Γ c σ. Γ ⊢⇩E Literal (IntegerLiteral c) : σ ⟹ Integer[1] = σ› 2. ‹⋀Γ c σ. Γ ⊢⇩E Literal (UnlimitedNaturalLiteral c) : σ ⟹ UnlimitedNatural[1] = σ› 3. ‹⋀Γ c σ. Γ ⊢⇩E Literal (StringLiteral c) : σ ⟹ String[1] = σ› 4. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 5. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 6. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 7. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 8. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 9. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 10. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 11. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 12. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 13. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 14. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 15. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 16. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 17. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 18. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 19. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 20. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 21. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 22. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 23. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 24. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 25. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 26. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 27. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 28. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 37. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 38. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 39. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 40. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 41. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (IntegerLiteralT Γ c) (*‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E Literal (IntegerLiteral (c::int)) : (σ::'a::ocl_object_model OCL_Types.type)›*) thus "?case" (*goal: ‹Integer[1] = σ›*) by auto next (*goals: 1. ‹⋀Γ c σ. Γ ⊢⇩E Literal (UnlimitedNaturalLiteral c) : σ ⟹ UnlimitedNatural[1] = σ› 2. ‹⋀Γ c σ. Γ ⊢⇩E Literal (StringLiteral c) : σ ⟹ String[1] = σ› 3. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 4. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 5. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 6. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 7. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 8. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 9. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 10. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 11. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 12. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 13. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 14. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 15. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 16. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 17. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 18. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 19. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 20. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 21. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 22. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 23. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 24. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 25. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 26. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 27. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 37. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 38. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 39. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 40. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (UnlimitedNaturalLiteralT Γ c) (*‹Γ ⊢⇩E Literal (UnlimitedNaturalLiteral c) : σ›*) thus "?case" (*goal: ‹UnlimitedNatural[1] = σ›*) by auto next (*goals: 1. ‹⋀Γ c σ. Γ ⊢⇩E Literal (StringLiteral c) : σ ⟹ String[1] = σ› 2. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 3. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 4. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 5. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 6. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 7. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 8. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 9. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 10. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 11. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 12. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 13. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 14. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 15. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 16. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 17. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 18. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 19. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 20. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 21. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 22. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 23. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 24. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 25. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 26. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 37. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 38. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 39. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (StringLiteralT Γ c) (*‹Γ ⊢⇩E Literal (StringLiteral c) : σ›*) thus "?case" (*goal: ‹String[1] = σ›*) by auto next (*goals: 1. ‹⋀enum lit Γ σ. ⟦has_literal enum lit; Γ ⊢⇩E Literal (EnumLiteral enum lit) : σ⟧ ⟹ (Enum enum)[1] = σ› 2. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 3. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 4. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 5. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 6. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 7. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 8. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 9. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 10. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 11. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 12. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 13. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 14. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 15. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 16. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 17. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 18. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 19. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 20. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 21. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 22. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 23. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 24. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 25. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 36. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 37. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 38. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (EnumLiteralT Γ τ lit) (*‹has_literal Γ τ› ‹lit ⊢⇩E Literal (EnumLiteral Γ τ) : σ›*) thus "?case" (*goal: ‹(Enum (Γ::('a, String.literal) phantom))[1] = (σ::'a OCL_Types.type)›*) by auto next (*goals: 1. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SetKind prts) : σ⟧ ⟹ Set τ = σ› 2. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 3. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 4. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 5. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 6. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 7. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 8. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 9. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 10. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 11. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 12. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 13. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 14. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 15. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 16. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 17. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 18. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 19. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 20. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 21. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 22. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 23. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 24. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 35. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 36. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 37. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (SetLiteralT Γ prts τ) (*‹Γ ⊢⇩C prts : τ› ‹Γ ⊢⇩C prts : ?σ ⟹ τ = ?σ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E Literal (CollectionLiteral SetKind (prts::'a::ocl_object_model collection_literal_part_expr list)) : (σ::'a::ocl_object_model OCL_Types.type)›*) thus "?case" (*goal: ‹Set (τ::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) by blast next (*goals: 1. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ⟧ ⟹ OrderedSet τ = σ› 2. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 3. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 4. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 5. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 6. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 7. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 8. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 9. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 10. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 11. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 12. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 13. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 14. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 15. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 16. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 17. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 18. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 19. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 20. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 21. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 22. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 23. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 34. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 35. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 36. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (OrderedSetLiteralT Γ prts τ) (*‹Γ ⊢⇩C prts : τ› ‹Γ ⊢⇩C prts : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩E Literal (CollectionLiteral OrderedSetKind prts) : σ›*) thus "?case" (*goal: ‹OrderedSet (τ::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) by blast next (*goals: 1. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral BagKind prts) : σ⟧ ⟹ Bag τ = σ› 2. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 3. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 4. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 5. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 6. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 7. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 8. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 9. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 10. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 11. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 12. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 13. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 14. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 15. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 16. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 17. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 18. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 19. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 20. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 21. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 22. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 33. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 34. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 35. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (BagLiteralT Γ prts τ) (*‹Γ ⊢⇩C prts : τ› ‹Γ ⊢⇩C prts : ?σ ⟹ τ = ?σ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E Literal (CollectionLiteral BagKind (prts::'a::ocl_object_model collection_literal_part_expr list)) : (σ::'a::ocl_object_model OCL_Types.type)›*) thus "?case" (*goal: ‹Bag τ = σ›*) by blast next (*goals: 1. ‹⋀Γ prts τ σ. ⟦Γ ⊢⇩C prts : τ; ⋀σ. Γ ⊢⇩C prts : σ ⟹ τ = σ; Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ⟧ ⟹ Sequence τ = σ› 2. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 3. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 4. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 5. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 6. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 7. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 8. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 9. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 10. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 11. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 12. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 13. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 14. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 15. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 16. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 17. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 18. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 19. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 20. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 21. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 32. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 33. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 34. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (SequenceLiteralT Γ prts τ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩C (prts::'a collection_literal_part_expr list) : (τ::'a OCL_Types.type)› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩C (prts::'a collection_literal_part_expr list) : (?σ::'a OCL_Types.type) ⟹ (τ::'a OCL_Types.type) = ?σ› ‹Γ ⊢⇩E Literal (CollectionLiteral SequenceKind prts) : σ›*) thus "?case" (*goal: ‹Sequence τ = σ›*) by blast next (*goals: 1. ‹⋀Γ x τ σ. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C [x] : σ⟧ ⟹ τ = σ› 2. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 3. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 4. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 5. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 6. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 7. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 8. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 9. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 10. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 11. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 12. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 13. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 14. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 15. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 16. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 17. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 18. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 19. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 20. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 31. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 32. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 33. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (CollectionPartsSingletonT Γ x τ) (*‹Γ ⊢⇩P x : τ› ‹Γ ⊢⇩P x : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩C [x] : σ›*) thus "?case" (*goal: ‹τ = σ›*) by blast next (*goals: 1. ‹⋀Γ x τ y xs σ σ'. ⟦Γ ⊢⇩P x : τ; ⋀σ. Γ ⊢⇩P x : σ ⟹ τ = σ; Γ ⊢⇩C y # xs : σ; ⋀σ'. Γ ⊢⇩C y # xs : σ' ⟹ σ = σ'; Γ ⊢⇩C x # y # xs : σ'⟧ ⟹ τ ⊔ σ = σ'› 2. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 3. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 4. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 5. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 6. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 7. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 8. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 9. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 10. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 11. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 12. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 13. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 14. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 15. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 16. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 17. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 18. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 19. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 30. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 31. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 32. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (CollectionPartsListT Γ x τ y xs σ) (*‹Γ ⊢⇩P x : τ› ‹Γ ⊢⇩P x : ?σ ⟹ τ = ?σ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩C (y::'a::ocl_object_model collection_literal_part_expr) # (xs::'a::ocl_object_model collection_literal_part_expr list) : (σ'__::'a::ocl_object_model OCL_Types.type)› ‹Γ ⊢⇩C y # xs : ?σ ⟹ σ'__ = ?σ› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩C (x::'a collection_literal_part_expr) # (y::'a collection_literal_part_expr) # (xs::'a collection_literal_part_expr list) : (σ::'a OCL_Types.type)›*) thus "?case" (*goal: ‹τ ⊔ σ'__ = σ›*) by blast next (*goals: 1. ‹⋀Γ a τ σ. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩P CollectionItem a : σ⟧ ⟹ τ = σ› 2. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 3. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 4. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 5. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 6. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 7. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 8. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 9. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 10. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 11. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 12. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 13. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 14. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 15. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 16. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 17. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 18. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 29. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 30. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 31. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (CollectionPartItemT Γ a τ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (a::'a expr) : (τ::'a OCL_Types.type)› ‹Γ ⊢⇩E a : ?σ ⟹ τ = ?σ› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩P CollectionItem (a::'a expr) : (σ::'a OCL_Types.type)›*) thus "?case" (*goal: ‹τ = σ›*) by blast next (*goals: 1. ‹⋀Γ a τ b σ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; τ = UnlimitedNatural[1]─Integer[1]; σ = UnlimitedNatural[1]─Integer[1]; Γ ⊢⇩P CollectionRange a b : σ'⟧ ⟹ Integer[1] = σ'› 2. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 3. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 4. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 5. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 6. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 7. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 8. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 9. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 10. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 11. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 12. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 13. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 14. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 15. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 16. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 17. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 28. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 29. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 30. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (CollectionPartRangeT Γ a τ b σ) (*‹Γ ⊢⇩E a : τ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E (a::'a::ocl_object_model expr) : (?σ::'a::ocl_object_model OCL_Types.type) ⟹ (τ::'a::ocl_object_model OCL_Types.type) = ?σ› ‹Γ ⊢⇩E b : σ'__› ‹Γ ⊢⇩E b : ?σ ⟹ σ'__ = ?σ› ‹τ = UnlimitedNatural[1]─Integer[1]› ‹σ'__ = UnlimitedNatural[1]─Integer[1]› ‹Γ ⊢⇩P CollectionRange a b : σ›*) thus "?case" (*goal: ‹Integer[1] = σ›*) by blast next (*goals: 1. ‹⋀Γ σ. Γ ⊢⇩E Literal (TupleLiteral []) : σ ⟹ Tuple fmempty = σ› 2. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 3. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 4. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 5. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 6. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 7. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 8. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 9. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 10. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 11. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 12. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 13. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 14. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 15. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 16. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 27. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 28. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 29. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (TupleLiteralNilT Γ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E Literal (TupleLiteral []) : (σ::'a OCL_Types.type)›*) thus "?case" (*goal: ‹Tuple fmempty = σ›*) by auto next (*goals: 1. ‹⋀Γ elems ξ el τ σ σ'. ⟦Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ⋀σ. Γ ⊢⇩E Literal (TupleLiteral elems) : σ ⟹ Tuple ξ = σ; Γ ⊢⇩E tuple_element_expr el : τ; ⋀σ. Γ ⊢⇩E tuple_element_expr el : σ ⟹ τ = σ; tuple_element_type el = Some σ; τ ≤ σ; Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ'⟧ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ)) = σ'› 2. ‹⋀Γ init σ τ v body ρ σ'. ⟦Γ ⊢⇩E init : σ; ⋀σ'. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 3. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 4. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 5. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 6. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 7. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 8. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 9. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 10. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 11. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 12. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 13. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 14. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 15. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 25. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 26. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 27. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 28. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (TupleLiteralConsT Γ elems ξ el τ) (*‹Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ› ‹Γ ⊢⇩E Literal (TupleLiteral elems) : ?σ ⟹ Tuple ξ = ?σ› ‹Γ ⊢⇩E tuple_element_expr el : τ› ‹Γ ⊢⇩E tuple_element_expr el : ?σ ⟹ τ = ?σ› ‹tuple_element_type (el::String.literal × 'a OCL_Types.type option × 'a expr) = Some (σ_::'a OCL_Types.type)› ‹(τ::'a OCL_Types.type) ≤ (σ_::'a OCL_Types.type)› ‹Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ›*) show "?case" (*goal: ‹Tuple (ξ(tuple_element_name el ↦⇩f σ_)) = σ›*) apply (insert TupleLiteralConsT.prems (*‹Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ›*)) (*goal: ‹Tuple (ξ(tuple_element_name el ↦⇩f σ_)) = σ›*) apply (erule TupleLiteralTE (*‹⟦?Γ ⊢⇩E Literal (TupleLiteral ?elems) : ?τ; ⟦?elems = []; ?τ = Tuple fmempty⟧ ⟹ ?P; ⋀elems ξ el τ σ. ⟦?elems = el # elems; ?τ = Tuple (ξ(tuple_element_name el ↦⇩f σ)); ?Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ; ?Γ ⊢⇩E tuple_element_expr el : τ; tuple_element_type el = Some σ; τ ≤ σ⟧ ⟹ ?P⟧ ⟹ ?P›*), simp) (*goal: ‹Γ ⊢⇩E Literal (TupleLiteral (el # elems)) : σ ⟹ Tuple (ξ(tuple_element_name el ↦⇩f σ_)) = σ›*) using TupleLiteralConsT.hyps (*‹Γ ⊢⇩E Literal (TupleLiteral elems) : Tuple ξ› ‹Γ ⊢⇩E Literal (TupleLiteral elems) : ?σ ⟹ Tuple ξ = ?σ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E tuple_element_expr (el::String.literal × 'a::ocl_object_model OCL_Types.type option × 'a::ocl_object_model expr) : (τ::'a::ocl_object_model OCL_Types.type)› ‹Γ ⊢⇩E tuple_element_expr el : ?σ ⟹ τ = ?σ› ‹tuple_element_type el = Some σ_› ‹τ ≤ σ_›*) by auto next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (init::'a expr) (σ::'a OCL_Types.type) (τ::'a OCL_Types.type) (v::String.literal) (body::'a expr) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩E init : σ; ⋀σ'::'a OCL_Types.type. Γ ⊢⇩E init : σ' ⟹ σ = σ'; σ ≤ τ; Γ(v ↦⇩f τ) ⊢⇩E body : ρ; ⋀σ::'a OCL_Types.type. Γ(v ↦⇩f τ) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩E expr.Let v (Some τ) init body : σ'⟧ ⟹ ρ = σ'› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (v::String.literal) (τ::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (a::'a expr) (b::'a expr) (σ::'a OCL_Types.type) (c::'a expr) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'::'a OCL_Types.type. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 4. ‹⋀(τ::'a OCL_Types.type) (op::metaop) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (params::'a expr list) (π::'a OCL_Types.type list) (τ::'a OCL_Types.type) (op::String.literal) (oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option) σ::'a OCL_Types.type. ⟦Γ ⊢⇩L params : π; ⋀ξ::'a OCL_Types.type list. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (a::'a expr) (τ::'a OCL_Types.type) (k::call_kind) (op::typeop) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩E a : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒞::'a) (prop::String.literal) (𝒟::'a) (τ::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒞::'a) (from::String.literal option) (role::String.literal) (𝒟::'a) (end::'a × nat × enat × bool × bool) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒞::'a) (from::String.literal option) (𝒜::'a) (𝒟::'a) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒜::'a) (role::String.literal) (end::'a × nat × enat × bool × bool) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 11. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (τ::'a OCL_Types.type) (params::'a expr list) (π::'a OCL_Types.type list) (op::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (k::call_kind) (σ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩E src : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ::'a OCL_Types.type list. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 12. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (π::String.literal ⇀⇩f 'a OCL_Types.type) (elem::String.literal) (τ::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 13. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (its_ty::'a OCL_Types.type) (its::String.literal list) (body::'a expr) (ρ::'a OCL_Types.type) ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. ⟦Γ ⊢⇩E src : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ::'a OCL_Types.type. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 14. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (res::String.literal) (res_t::'a OCL_Types.type) (res_init::'a expr) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 15. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 16. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 17. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) (φ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 18. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) (φ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 19. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 20. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 21. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 22. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 23. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 24. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 25. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 26. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ξ::'a OCL_Types.type list. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 27. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (expr::'a expr) (τ::'a OCL_Types.type) (exprs::'a expr list) (π::'a OCL_Types.type list) ξ::'a OCL_Types.type list. ⟦Γ ⊢⇩E expr : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ::'a OCL_Types.type list. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (LetT Γ ℳ init σ τ v body ρ) (*‹Γ ⊢⇩E ℳ : init› ‹Γ ⊢⇩E ℳ : ?σ ⟹ init = ?σ› ‹init ≤ σ› ‹Γ(τ ↦⇩f σ) ⊢⇩E v : body› ‹Γ(τ ↦⇩f σ) ⊢⇩E v : ?σ ⟹ body = ?σ› ‹Γ ⊢⇩E expr.Let τ (Some σ) ℳ v : ρ›*) thus "?case" (*goal: ‹body = ρ›*) by blast next (*goals: 1. ‹⋀Γ v τ σ. ⟦fmlookup Γ v = Some τ; Γ ⊢⇩E Var v : σ⟧ ⟹ τ = σ› 2. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 3. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 4. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 5. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 6. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 7. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 8. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 9. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 10. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 11. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 12. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 13. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 24. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 25. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 26. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (VarT Γ v τ ℳ) (*‹fmlookup Γ v = Some τ› ‹Γ ⊢⇩E Var v : ℳ›*) thus "?case" (*goal: ‹τ = ℳ›*) by auto next (*goals: 1. ‹⋀Γ a b σ c ρ σ'. ⟦Γ ⊢⇩E a : Boolean[1]; ⋀σ. Γ ⊢⇩E a : σ ⟹ Boolean[1] = σ; Γ ⊢⇩E b : σ; ⋀σ'. Γ ⊢⇩E b : σ' ⟹ σ = σ'; Γ ⊢⇩E c : ρ; ⋀σ. Γ ⊢⇩E c : σ ⟹ ρ = σ; Γ ⊢⇩E expr.If a b c : σ'⟧ ⟹ σ ⊔ ρ = σ'› 2. ‹⋀τ op σ Γ σ'. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 3. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 4. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 5. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 6. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 7. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 8. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 9. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 10. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 11. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 12. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 22. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 23. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 24. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 25. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (IfT Γ a τ b σ c ρ) (*‹Γ ⊢⇩E a : Boolean[1]› ‹Γ ⊢⇩E a : ?σ ⟹ Boolean[1] = ?σ› ‹Γ ⊢⇩E τ : b› ‹Γ ⊢⇩E τ : ?σ ⟹ b = ?σ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E (σ::'a::ocl_object_model expr) : (c::'a::ocl_object_model OCL_Types.type)› ‹Γ ⊢⇩E σ : ?σ ⟹ c = ?σ› ‹Γ ⊢⇩E expr.If a τ σ : ρ›*) thus "?case" (*goal: ‹b ⊔ c = ρ›*) apply (insert IfT.prems (*‹Γ ⊢⇩E expr.If a τ σ : ρ›*)) (*goal: ‹b ⊔ c = ρ›*) apply (erule IfTE (*‹⟦?Γ ⊢⇩E expr.If ?a ?b ?c : ?τ; ⋀σ ρ. ⟦?τ = σ ⊔ ρ; ?Γ ⊢⇩E ?a : Boolean[1]; ?Γ ⊢⇩E ?b : σ; ?Γ ⊢⇩E ?c : ρ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E expr.If (a::'a expr) (τ::'a expr) (σ::'a expr) : (ρ::'a OCL_Types.type) ⟹ (b::'a OCL_Types.type) ⊔ (c::'a OCL_Types.type) = ρ›*) by (simp add: IfT.hyps (*‹Γ ⊢⇩E a : Boolean[1]› ‹Γ ⊢⇩E a : ?σ ⟹ Boolean[1] = ?σ› ‹Γ ⊢⇩E τ : b› ‹Γ ⊢⇩E τ : ?σ ⟹ b = ?σ› ‹Γ ⊢⇩E σ : c› ‹Γ ⊢⇩E σ : ?σ ⟹ c = ?σ›*)) next (*goals: 1. ‹⋀(τ::'a OCL_Types.type) (op::metaop) (σ::'a OCL_Types.type) (Γ::String.literal ⇀⇩f 'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦mataop_type τ op σ; Γ ⊢⇩E MetaOperationCall τ op : σ'⟧ ⟹ σ = σ'› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (params::'a expr list) (π::'a OCL_Types.type list) (τ::'a OCL_Types.type) (op::String.literal) (oper::String.literal × 'a OCL_Types.type × (String.literal × 'a OCL_Types.type × param_dir) list × 'a OCL_Types.type × bool × 'a expr option) σ::'a OCL_Types.type. ⟦Γ ⊢⇩L params : π; ⋀ξ::'a OCL_Types.type list. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (a::'a expr) (τ::'a OCL_Types.type) (k::call_kind) (op::typeop) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩E a : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒞::'a) (prop::String.literal) (𝒟::'a) (τ::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒞::'a) (from::String.literal option) (role::String.literal) (𝒟::'a) (end::'a × nat × enat × bool × bool) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒞::'a) (from::String.literal option) (𝒜::'a) (𝒟::'a) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (𝒜::'a) (role::String.literal) (end::'a × nat × enat × bool × bool) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (τ::'a OCL_Types.type) (params::'a expr list) (π::'a OCL_Types.type list) (op::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (k::call_kind) (σ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩E src : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ::'a OCL_Types.type list. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (π::String.literal ⇀⇩f 'a OCL_Types.type) (elem::String.literal) (τ::'a OCL_Types.type) σ::'a OCL_Types.type. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (its_ty::'a OCL_Types.type) (its::String.literal list) (body::'a expr) (ρ::'a OCL_Types.type) ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. ⟦Γ ⊢⇩E src : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ::'a OCL_Types.type. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 11. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (res::String.literal) (res_t::'a OCL_Types.type) (res_init::'a expr) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 12. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 13. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 14. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) (φ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 15. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) (φ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 16. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 17. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 18. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 19. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 20. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 21. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 22. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (src::'a expr) (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) (τ::'a OCL_Types.type) (σ::'a OCL_Types.type) (ρ::'a OCL_Types.type) (υ::'a OCL_Types.type) σ'::'a OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 23. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ξ::'a OCL_Types.type list. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 24. ‹⋀(Γ::String.literal ⇀⇩f 'a OCL_Types.type) (expr::'a expr) (τ::'a OCL_Types.type) (exprs::'a expr list) (π::'a OCL_Types.type list) ξ::'a OCL_Types.type list. ⟦Γ ⊢⇩E expr : τ; ⋀σ::'a OCL_Types.type. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ::'a OCL_Types.type list. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (MetaOperationCallT τ op σ Γ) (*‹mataop_type τ op σ'__› ‹Γ ⊢⇩E MetaOperationCall τ op : σ›*) thus "?case" (*goal: ‹(σ'__::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) by (metis MetaOperationCallTE (*‹⟦?Γ ⊢⇩E MetaOperationCall ?τ ?op : ?σ; mataop_type ?τ ?op ?σ ⟹ ?P⟧ ⟹ ?P›*) mataop_type.cases (*‹⟦mataop_type ?a1.0 ?a2.0 ?a3.0; ⋀τ. ⟦?a1.0 = τ; ?a2.0 = AllInstancesOp; ?a3.0 = Set τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goals: 1. ‹⋀Γ params π τ op oper σ. ⟦Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; static_operation τ op π oper; Γ ⊢⇩E StaticOperationCall τ op params : σ⟧ ⟹ oper_type oper = σ› 2. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 3. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 4. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 5. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 6. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 7. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 8. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 9. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 10. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 21. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 22. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 23. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (StaticOperationCallT τ op π oper Γ as) (*‹τ ⊢⇩L op : π› ‹τ ⊢⇩L op : ?ξ ⟹ π = ?ξ› ‹static_operation oper Γ π as› ‹τ ⊢⇩E StaticOperationCall oper Γ op : σ›*) thus "?case" (*goal: ‹oper_type as = σ›*) apply (insert StaticOperationCallT.prems (*‹τ ⊢⇩E StaticOperationCall oper Γ op : σ›*)) (*goal: ‹oper_type as = σ›*) apply (erule StaticOperationCallTE (*‹⟦?Γ ⊢⇩E StaticOperationCall ?τ ?op ?as : ?σ; ⋀π oper. ⟦?σ = oper_type oper; ?Γ ⊢⇩L ?as : π; static_operation ?τ ?op π oper⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹τ ⊢⇩E StaticOperationCall oper Γ op : σ ⟹ oper_type as = σ›*) using StaticOperationCallT.hyps (*‹τ ⊢⇩L op : π› ‹(τ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩L (op::'a expr list) : (?ξ::'a OCL_Types.type list) ⟹ (π::'a OCL_Types.type list) = ?ξ› ‹static_operation (oper::'a::ocl_object_model OCL_Types.type) (Γ::String.literal) (π::'a::ocl_object_model OCL_Types.type list) (as::String.literal × 'a::ocl_object_model OCL_Types.type × (String.literal × 'a::ocl_object_model OCL_Types.type × param_dir) list × 'a::ocl_object_model OCL_Types.type × bool × 'a::ocl_object_model expr option)›*) static_operation_det (*‹⟦static_operation ?τ ?name ?π ?oper₁; static_operation ?τ ?name ?π ?oper₂⟧ ⟹ ?oper₁ = ?oper₂›*) by blast next (*goals: 1. ‹⋀Γ a τ k op σ ρ σ'. ⟦Γ ⊢⇩E a : τ; ⋀σ. Γ ⊢⇩E a : σ ⟹ τ = σ; typeop_type k op τ σ ρ; Γ ⊢⇩E TypeOperationCall a k op σ : σ'⟧ ⟹ ρ = σ'› 2. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 3. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 4. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 5. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 6. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 7. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 8. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 9. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 20. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 21. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 22. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (TypeOperationCallT Γ a τ op σ ρ) (*‹Γ ⊢⇩E a : τ› ‹Γ ⊢⇩E a : ?σ ⟹ τ = ?σ› ‹typeop_type op σ'__ τ ρ ρ_› ‹Γ ⊢⇩E TypeOperationCall a op σ'__ ρ : σ›*) thus "?case" (*goal: ‹ρ_ = σ›*) by (metis TypeOperationCallTE (*‹⟦?Γ ⊢⇩E TypeOperationCall ?a ?k ?op ?σ : ?τ; ⋀τ. ⟦?Γ ⊢⇩E ?a : τ; typeop_type ?k ?op τ ?σ ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*) typeop_type_det (*‹⟦typeop_type ?op ?k ?τ ?σ ?ρ₁; typeop_type ?op ?k ?τ ?σ ?ρ₂⟧ ⟹ ?ρ₁ = ?ρ₂›*)) next (*goals: 1. ‹⋀Γ src 𝒞 prop 𝒟 τ σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; attribute 𝒞 prop 𝒟 τ; Γ ⊢⇩E AttributeCall src DotCall prop : σ⟧ ⟹ τ = σ› 2. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 3. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 4. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 5. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 6. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 7. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 8. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 19. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 20. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 21. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (AttributeCallT Γ src τ 𝒞 prop 𝒟 σ) (*‹Γ ⊢⇩E src : ⟨τ⟩⇩𝒯[1]› ‹Γ ⊢⇩E src : ?σ ⟹ ⟨τ⟩⇩𝒯[1] = ?σ› ‹attribute τ 𝒞 prop 𝒟› ‹Γ ⊢⇩E AttributeCall src DotCall 𝒞 : σ›*) show "?case" (*goal: ‹𝒟 = σ›*) apply (insert AttributeCallT.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E AttributeCall (src::'a expr) DotCall (𝒞::String.literal) : (σ::'a OCL_Types.type)›*)) (*goal: ‹𝒟 = σ›*) apply (erule AttributeCallTE (*‹⟦?Γ ⊢⇩E AttributeCall ?src ?k ?prop : ?τ; ⋀𝒞 𝒟. ⟦?k = DotCall; ?Γ ⊢⇩E ?src : ⟨𝒞⟩⇩𝒯[1]; attribute 𝒞 ?prop 𝒟 ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E AttributeCall (src::'a expr) DotCall (𝒞::String.literal) : (σ::'a OCL_Types.type) ⟹ (𝒟::'a OCL_Types.type) = σ›*) using AttributeCallT.hyps (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src::'a expr) : ⟨τ::'a⟩⇩𝒯[1]› ‹Γ ⊢⇩E src : ?σ ⟹ ⟨τ⟩⇩𝒯[1] = ?σ› ‹attribute τ 𝒞 prop 𝒟›*) attribute_det (*‹⟦attribute (?𝒞::?'a) (?attr::String.literal) (?𝒟₁::?'a) (?τ₁::?'a OCL_Types.type); attribute ?𝒞 ?attr (?𝒟₂::?'a) (?τ₂::?'a OCL_Types.type)⟧ ⟹ ?𝒟₁ = ?𝒟₂ ∧ ?τ₁ = ?τ₂›*) by blast next (*goals: 1. ‹⋀Γ src 𝒞 from role 𝒟 end σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; association_end 𝒞 from role 𝒟 end; Γ ⊢⇩E AssociationEndCall src DotCall from role : σ⟧ ⟹ assoc_end_type end = σ› 2. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 3. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 4. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 5. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 6. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 7. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 18. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 19. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 20. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (AssociationEndCallT Γ src 𝒞 from role 𝒟 end) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src::'a expr) : ⟨𝒞::'a⟩⇩𝒯[1]› ‹Γ ⊢⇩E src : ?σ ⟹ ⟨𝒞⟩⇩𝒯[1] = ?σ› ‹association_end (𝒞::'a) (from::String.literal option) (role::String.literal) (𝒟::'a) (end::'a × nat × enat × bool × bool)› ‹Γ ⊢⇩E AssociationEndCall src DotCall from role : σ›*) show "?case" (*goal: ‹assoc_end_type end = σ›*) apply (insert AssociationEndCallT.prems (*‹Γ ⊢⇩E AssociationEndCall src DotCall from role : σ›*)) (*goal: ‹assoc_end_type end = σ›*) apply (erule AssociationEndCallTE (*‹⟦?Γ ⊢⇩E AssociationEndCall ?src ?k ?role ?from : ?τ; ⋀𝒞 𝒟 end. ⟦?k = DotCall; ?τ = assoc_end_type end; ?Γ ⊢⇩E ?src : ⟨𝒞⟩⇩𝒯[1]; association_end 𝒞 ?role ?from 𝒟 end⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E AssociationEndCall src DotCall from role : σ ⟹ assoc_end_type end = σ›*) using AssociationEndCallT.hyps (*‹Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]› ‹Γ ⊢⇩E src : ?σ ⟹ ⟨𝒞⟩⇩𝒯[1] = ?σ› ‹association_end 𝒞 from role 𝒟 end›*) association_end_det (*‹⟦association_end ?𝒞 ?from ?role ?𝒟₁ ?end₁; association_end ?𝒞 ?from ?role ?𝒟₂ ?end₂⟧ ⟹ ?𝒟₁ = ?𝒟₂ ∧ ?end₁ = ?end₂›*) by blast next (*goals: 1. ‹⋀Γ src 𝒞 from 𝒜 𝒟 σ. ⟦Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒞⟩⇩𝒯[1] = σ; referred_by_association_class 𝒞 from 𝒜 𝒟; Γ ⊢⇩E AssociationClassCall src DotCall from 𝒜 : σ⟧ ⟹ class_assoc_type 𝒜 = σ› 2. ‹⋀Γ src 𝒜 role end σ. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 3. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 4. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 5. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 6. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 16. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 17. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 18. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 19. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (AssociationClassCallT Γ src 𝒞 from 𝒜) (*‹Γ ⊢⇩E src : ⟨𝒞⟩⇩𝒯[1]› ‹Γ ⊢⇩E src : ?σ ⟹ ⟨𝒞⟩⇩𝒯[1] = ?σ› ‹referred_by_association_class 𝒞 from 𝒜 𝒟_› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E AssociationClassCall (src::'a expr) DotCall (from::String.literal option) (𝒜::'a) : (σ::'a OCL_Types.type)›*) thus "?case" (*goal: ‹class_assoc_type 𝒜 = σ›*) by blast next (*goals: 1. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (𝒜::'a::ocl_object_model) (role::String.literal) (end::'a::ocl_object_model × nat × enat × bool × bool) σ::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩E src : ⟨𝒜⟩⇩𝒯[1]; ⋀σ::'a::ocl_object_model OCL_Types.type. Γ ⊢⇩E src : σ ⟹ ⟨𝒜⟩⇩𝒯[1] = σ; association_class_end 𝒜 role end; Γ ⊢⇩E AssociationClassEndCall src DotCall role : σ⟧ ⟹ class_assoc_end_type end = σ› 2. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (params::'a::ocl_object_model expr list) (π::'a::ocl_object_model OCL_Types.type list) (op::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (k::call_kind) (σ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩E src : τ; ⋀σ::'a::ocl_object_model OCL_Types.type. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ::'a::ocl_object_model OCL_Types.type list. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 3. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (π::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (elem::String.literal) (τ::'a::ocl_object_model OCL_Types.type) σ::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ::'a::ocl_object_model OCL_Types.type. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 4. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (its_ty::'a::ocl_object_model OCL_Types.type) (its::String.literal list) (body::'a::ocl_object_model expr) (ρ::'a::ocl_object_model OCL_Types.type) ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩E src : τ; ⋀σ::'a::ocl_object_model OCL_Types.type. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ::'a::ocl_object_model OCL_Types.type. Γ ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 5. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (res::String.literal) (res_t::'a::ocl_object_model OCL_Types.type) (res_init::'a::ocl_object_model expr) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 6. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 7. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) (υ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 8. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) (υ::'a::ocl_object_model OCL_Types.type) (φ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 9. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) (υ::'a::ocl_object_model OCL_Types.type) (φ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 10. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 11. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 12. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 13. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 14. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 15. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 16. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (src::'a::ocl_object_model expr) (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (σ::'a::ocl_object_model OCL_Types.type) (ρ::'a::ocl_object_model OCL_Types.type) (υ::'a::ocl_object_model OCL_Types.type) σ'::'a::ocl_object_model OCL_Types.type. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ (1::nat); to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 17. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ξ::'a::ocl_object_model OCL_Types.type list. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 18. ‹⋀(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) (expr::'a::ocl_object_model expr) (τ::'a::ocl_object_model OCL_Types.type) (exprs::'a::ocl_object_model expr list) (π::'a::ocl_object_model OCL_Types.type list) ξ::'a::ocl_object_model OCL_Types.type list. ⟦Γ ⊢⇩E expr : τ; ⋀σ::'a::ocl_object_model OCL_Types.type. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ::'a::ocl_object_model OCL_Types.type list. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (AssociationClassEndCallT Γ src τ 𝒜 role end) (*‹Γ ⊢⇩E src : ⟨τ⟩⇩𝒯[1]› ‹Γ ⊢⇩E src : ?σ ⟹ ⟨τ⟩⇩𝒯[1] = ?σ› ‹association_class_end τ 𝒜 role› ‹Γ ⊢⇩E AssociationClassEndCall src DotCall 𝒜 : end›*) show "?case" (*goal: ‹class_assoc_end_type (role::'a::ocl_object_model × nat × enat × bool × bool) = (end::'a::ocl_object_model OCL_Types.type)›*) apply (insert AssociationClassEndCallT.prems (*‹Γ ⊢⇩E AssociationClassEndCall src DotCall 𝒜 : end›*)) (*goal: ‹class_assoc_end_type (role::'a × nat × enat × bool × bool) = (end::'a OCL_Types.type)›*) apply (erule AssociationClassEndCallTE (*‹⟦?Γ ⊢⇩E AssociationClassEndCall ?src ?k ?role : ?τ; ⋀𝒜 end. ⟦?k = DotCall; ?τ = class_assoc_end_type end; ?Γ ⊢⇩E ?src : ⟨𝒜⟩⇩𝒯[1]; association_class_end 𝒜 ?role end⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E AssociationClassEndCall src DotCall 𝒜 : end ⟹ class_assoc_end_type role = end›*) using AssociationClassEndCallT.hyps (*‹Γ ⊢⇩E src : ⟨τ⟩⇩𝒯[1]› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E (src::'a expr) : (?σ::'a OCL_Types.type) ⟹ ⟨τ::'a⟩⇩𝒯[1] = ?σ› ‹association_class_end τ 𝒜 role›*) association_class_end_det (*‹⟦association_class_end ?𝒜 ?role ?end₁; association_class_end ?𝒜 ?role ?end₂⟧ ⟹ ?end₁ = ?end₂›*) by blast next (*goals: 1. ‹⋀Γ src τ params π op k σ σ'. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; Γ ⊢⇩L params : π; ⋀ξ. Γ ⊢⇩L params : ξ ⟹ π = ξ; op_type op k τ π σ; Γ ⊢⇩E OperationCall src k op params : σ'⟧ ⟹ σ = σ'› 2. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 3. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 4. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 15. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 16. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 17. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (OperationCallT Γ src τ params π op k) (*‹Γ ⊢⇩E src : τ› ‹Γ ⊢⇩E src : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩L params : π› ‹Γ ⊢⇩L params : ?ξ ⟹ π = ?ξ› ‹op_type op k τ π σ_› ‹Γ ⊢⇩E OperationCall src k op params : σ›*) show "?case" (*goal: ‹(σ_::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) apply (insert OperationCallT.prems (*‹Γ ⊢⇩E OperationCall src k op params : σ›*)) (*goal: ‹σ_ = σ›*) apply (erule OperationCallTE (*‹⟦?Γ ⊢⇩E OperationCall ?src ?k ?op ?params : ?τ; ⋀τ π. ⟦?Γ ⊢⇩E ?src : τ; ?Γ ⊢⇩L ?params : π; op_type ?op ?k τ π ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E OperationCall src k op params : σ ⟹ σ_ = σ›*) using OperationCallT.hyps (*‹Γ ⊢⇩E src : τ› ‹Γ ⊢⇩E src : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩L params : π› ‹Γ ⊢⇩L params : ?ξ ⟹ π = ?ξ› ‹op_type op k τ π σ_›*) op_type_det (*‹⟦op_type (?op::(any_unop + boolean_unop + numeric_unop + string_unop + collection_unop) + (super_binop + boolean_binop + numeric_binop + string_binop + collection_binop) + (string_ternop + collection_ternop) + String.literal) (?k::call_kind) (?τ::?'a OCL_Types.type) (?π::?'a OCL_Types.type list) (?σ::?'a OCL_Types.type); op_type ?op ?k ?τ ?π (?ρ::?'a OCL_Types.type)⟧ ⟹ ?σ = ?ρ›*) by blast next (*goals: 1. ‹⋀Γ src π elem τ σ. ⟦Γ ⊢⇩E src : Tuple π; ⋀σ. Γ ⊢⇩E src : σ ⟹ Tuple π = σ; fmlookup π elem = Some τ; Γ ⊢⇩E TupleElementCall src DotCall elem : σ⟧ ⟹ τ = σ› 2. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 3. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 14. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 15. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 16. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (TupleElementCallT Γ src π elem τ) (*‹Γ ⊢⇩E src : Tuple π› ‹Γ ⊢⇩E src : ?σ ⟹ Tuple π = ?σ› ‹fmlookup π elem = Some τ› ‹Γ ⊢⇩E TupleElementCall src DotCall elem : σ›*) thus "?case" (*goal: ‹τ = σ›*) apply (insert TupleElementCallT.prems (*‹Γ ⊢⇩E TupleElementCall src DotCall elem : σ›*)) (*goal: ‹(τ::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) apply (erule TupleElementCallTE (*‹⟦?Γ ⊢⇩E TupleElementCall ?src ?k ?elem : ?τ; ⋀π. ⟦?k = DotCall; ?Γ ⊢⇩E ?src : Tuple π; fmlookup π ?elem = Some ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E TupleElementCall src DotCall elem : σ ⟹ τ = σ›*) using TupleElementCallT.hyps (*‹Γ ⊢⇩E src : Tuple π› ‹Γ ⊢⇩E src : ?σ ⟹ Tuple π = ?σ› ‹fmlookup π elem = Some τ›*) by fastforce next (*goals: 1. ‹⋀Γ src τ σ its_ty its body ρ ys. ⟦Γ ⊢⇩E src : τ; ⋀σ. Γ ⊢⇩E src : σ ⟹ τ = σ; element_type τ σ; σ ≤ its_ty; Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ; ⋀σ. Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : σ ⟹ ρ = σ; Γ ⊢⇩I (src, its, Some its_ty, body) : ys⟧ ⟹ (τ, σ, ρ) = ys› 2. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 13. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 14. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 15. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (IteratorT Γ src τ σ its_ty its body ρ) (*‹Γ ⊢⇩E src : τ› ‹Γ ⊢⇩E src : ?σ ⟹ τ = ?σ› ‹element_type τ σ› ‹σ ≤ its_ty› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ++⇩f fmap_of_list (map (λit::String.literal. (it, its_ty::'a OCL_Types.type)) (its::String.literal list)) ⊢⇩E (body::'a expr) : (ρ::'a OCL_Types.type)› ‹Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ?σ ⟹ ρ = ?σ› ‹Γ ⊢⇩I (src, its, Some its_ty, body) : ys›*) show "?case" (*goal: ‹(τ, σ, ρ) = ys›*) apply (insert IteratorT.prems (*‹Γ ⊢⇩I (src, its, Some its_ty, body) : ys›*)) (*goal: ‹(τ, σ, ρ) = ys›*) apply (erule IteratorTE (*‹⟦?Γ ⊢⇩I (?src, ?its, ?body) : ?ys; ⋀τ σ its_ty body ρ. ⟦?body = (Some its_ty, body); ?ys = (τ, σ, ρ); ?Γ ⊢⇩E ?src : τ; element_type τ σ; σ ≤ its_ty; ?Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) ?its) ⊢⇩E body : ρ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (src::'a expr, its::String.literal list, Some (its_ty::'a OCL_Types.type), body::'a expr) : (ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type) ⟹ (τ::'a OCL_Types.type, σ::'a OCL_Types.type, ρ::'a OCL_Types.type) = ys›*) using IteratorT.hyps (*‹Γ ⊢⇩E src : τ› ‹Γ ⊢⇩E src : ?σ ⟹ τ = ?σ› ‹element_type τ σ› ‹(σ::'a::ocl_object_model OCL_Types.type) ≤ (its_ty::'a::ocl_object_model OCL_Types.type)› ‹Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ρ› ‹Γ ++⇩f fmap_of_list (map (λit. (it, its_ty)) its) ⊢⇩E body : ?σ ⟹ ρ = ?σ›*) element_type_det (*‹⟦element_type ?τ ?σ₁; element_type ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) by blast next (*goals: 1. ‹⋀Γ src its its_ty res res_t res_init body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ res_t; Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ'⟧ ⟹ ρ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 12. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 13. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 14. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (IterateT Γ src its its_ty res res_t res_init body τ σ ρ) (*‹Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹ρ ≤ res_t› ‹Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ›*) show "?case" (*goal: ‹ρ = σ›*) apply (insert IterateT.prems (*‹Γ ⊢⇩E IterateCall src ArrowCall its its_ty res (Some res_t) res_init body : σ›*)) (*goal: ‹ρ = σ›*) using IterateT.hyps (*‹Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, expr.Let res (Some res_t) res_init body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹ρ ≤ res_t›*) by blast next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ σ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 11. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 12. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 13. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (AnyIteratorT Γ src its its_ty body τ σ ρ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (src::'a expr, its::String.literal list, its_ty::'a OCL_Types.type option, body::'a expr) : (τ::'a OCL_Types.type, σ'__::'a OCL_Types.type, ρ::'a OCL_Types.type)› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩I (src::'a::ocl_object_model expr, its::String.literal list, its_ty::'a::ocl_object_model OCL_Types.type option, body::'a::ocl_object_model expr) : (?ys::'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type × 'a::ocl_object_model OCL_Types.type) ⟹ (τ::'a::ocl_object_model OCL_Types.type, σ'__::'a::ocl_object_model OCL_Types.type, ρ::'a::ocl_object_model OCL_Types.type) = ?ys› ‹length its ≤ 1› ‹ρ ≤ Boolean[?]› ‹Γ ⊢⇩E AnyIteratorCall src ArrowCall its its_ty body : σ›*) thus "?case" (*goal: ‹(σ'__::'a::ocl_object_model OCL_Types.type) = (σ::'a::ocl_object_model OCL_Types.type)›*) by (meson AnyIteratorTE (*‹⟦?Γ ⊢⇩E AnyIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ ρ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, ?τ, ρ); length ?its ≤ Suc 0; ρ ≤ Boolean[?]⟧ ⟹ ?P⟧ ⟹ ?P›*) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*)) next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_single_type ρ ≤ σ; to_unique_collection τ υ; Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 10. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 11. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 12. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (ClosureIteratorT Γ src its its_ty body τ σ ρ υ) (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹length its ≤ 1› ‹to_single_type ρ ≤ σ'__› ‹to_unique_collection τ υ› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E ClosureIteratorCall (src::'a::ocl_object_model expr) ArrowCall (its::String.literal list) (its_ty::'a::ocl_object_model OCL_Types.type option) (body::'a::ocl_object_model expr) : (σ::'a::ocl_object_model OCL_Types.type)›*) show "?case" (*goal: ‹υ = σ›*) apply (insert ClosureIteratorT.prems (*‹Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ›*)) (*goal: ‹υ = σ›*) apply (erule ClosureIteratorTE (*‹⟦?Γ ⊢⇩E ClosureIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ ρ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ρ); length ?its ≤ Suc 0; to_single_type ρ ≤ σ; to_unique_collection τ ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E ClosureIteratorCall src ArrowCall its its_ty body : σ ⟹ υ = σ›*) using ClosureIteratorT.hyps (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹length (its::String.literal list) ≤ (1::nat)› ‹to_single_type ρ ≤ σ'__› ‹to_unique_collection (τ::'a::ocl_object_model OCL_Types.type) (υ::'a::ocl_object_model OCL_Types.type)›*) to_unique_collection_det (*‹⟦to_unique_collection ?τ ?σ₁; to_unique_collection ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) by blast next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) φ; Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 9. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 10. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 11. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (CollectIteratorT Γ src its its_ty body τ σ ρ υ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (src::'a expr, its::String.literal list, its_ty::'a OCL_Types.type option, body::'a expr) : (τ::'a OCL_Types.type, σ'__::'a OCL_Types.type, ρ::'a OCL_Types.type)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹length (its::String.literal list) ≤ (1::nat)› ‹to_nonunique_collection τ υ› ‹update_element_type υ (to_single_type ρ) φ_› ‹Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ›*) show "?case" (*goal: ‹φ_ = σ›*) apply (insert CollectIteratorT.prems (*‹Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ›*)) (*goal: ‹(φ_::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) apply (erule CollectIteratorTE (*‹⟦?Γ ⊢⇩E CollectIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ ρ υ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ρ); length ?its ≤ Suc 0; to_nonunique_collection τ υ; update_element_type υ (to_single_type ρ) ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E CollectIteratorCall src ArrowCall its its_ty body : σ ⟹ φ_ = σ›*) using CollectIteratorT.hyps (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹length its ≤ 1› ‹to_nonunique_collection τ υ› ‹update_element_type (υ::'a OCL_Types.type) (to_single_type (ρ::'a OCL_Types.type)) (φ_::'a OCL_Types.type)›*) to_nonunique_collection_det (*‹⟦to_nonunique_collection ?τ ?σ₁; to_nonunique_collection ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a OCL_Types.type) (?σ::?'b OCL_Types.type) (?ρ₁::?'b OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*) by metis next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ υ φ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_nonunique_collection τ υ; update_element_type υ ρ φ; Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ φ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 8. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 9. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 10. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (CollectNestedIteratorT Γ src its its_ty body τ σ ρ υ) (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹length (its::String.literal list) ≤ (1::nat)› ‹to_nonunique_collection τ υ› ‹update_element_type υ ρ φ_› ‹Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ›*) show "?case" (*goal: ‹φ_ = σ›*) apply (insert CollectNestedIteratorT.prems (*‹Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ›*)) (*goal: ‹φ_ = σ›*) apply (erule CollectNestedIteratorTE (*‹⟦?Γ ⊢⇩E CollectNestedIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ ρ υ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ρ); length ?its ≤ Suc 0; to_nonunique_collection τ υ; update_element_type υ ρ ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E CollectNestedIteratorCall src ArrowCall its its_ty body : σ ⟹ φ_ = σ›*) using CollectNestedIteratorT.hyps (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹length its ≤ 1› ‹to_nonunique_collection τ υ› ‹update_element_type υ ρ φ_›*) to_nonunique_collection_det (*‹⟦to_nonunique_collection ?τ ?σ₁; to_nonunique_collection ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) update_element_type_det (*‹⟦update_element_type (?τ::?'a::type OCL_Types.type) (?σ::?'b::type OCL_Types.type) (?ρ₁::?'b::type OCL_Types.type); update_element_type ?τ ?σ (?ρ₂::?'b::type OCL_Types.type)⟧ ⟹ ?ρ₁ = ?ρ₂›*) Pair_inject (*‹⟦(?a::?'a, ?b::?'b) = (?a'::?'a, ?b'::?'b); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R::bool⟧ ⟹ ?R›*) by metis next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 7. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 8. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 9. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (ExistsIteratorT Γ src its its_ty body τ σ ρ) (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹ρ ≤ Boolean[?]› ‹Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ›*) show "?case" (*goal: ‹(ρ::'a OCL_Types.type) = (σ::'a OCL_Types.type)›*) apply (insert ExistsIteratorT.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E ExistsIteratorCall (src::'a expr) ArrowCall (its::String.literal list) (its_ty::'a OCL_Types.type option) (body::'a expr) : (σ::'a OCL_Types.type)›*)) (*goal: ‹ρ = σ›*) apply (erule ExistsIteratorTE (*‹⟦?Γ ⊢⇩E ExistsIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ?τ); ?τ ≤ Boolean[?]⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E ExistsIteratorCall src ArrowCall its its_ty body : σ ⟹ ρ = σ›*) using ExistsIteratorT.hyps (*‹Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ'__, ρ)› ‹Γ ⊢⇩I (src, its, its_ty, body) : ?ys ⟹ (τ, σ'__, ρ) = ?ys› ‹ρ ≤ Boolean[?]›*) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*) by metis next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; ρ ≤ Boolean[?]; Γ ⊢⇩E ForAllIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ ρ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 6. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 7. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 8. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (ForAllIteratorT Γ ℳ src its its_ty body τ σ ρ) (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹σ ≤ Boolean[?]› ‹Γ ⊢⇩E ForAllIteratorCall ℳ ArrowCall src its its_ty : ρ›*) show "?case" (*goal: ‹σ = ρ›*) apply (insert ForAllIteratorT.prems (*‹Γ ⊢⇩E ForAllIteratorCall ℳ ArrowCall src its its_ty : ρ›*)) (*goal: ‹σ = ρ›*) apply (erule ForAllIteratorTE (*‹⟦?Γ ⊢⇩E ForAllIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ?τ); ?τ ≤ Boolean[?]⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E ForAllIteratorCall (ℳ::'a::ocl_object_model expr) ArrowCall (src::String.literal list) (its::'a::ocl_object_model OCL_Types.type option) (its_ty::'a::ocl_object_model expr) : (ρ::'a::ocl_object_model OCL_Types.type) ⟹ (σ::'a::ocl_object_model OCL_Types.type) = ρ›*) using ForAllIteratorT.hyps (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (ℳ::'a expr, src::String.literal list, its::'a OCL_Types.type option, its_ty::'a expr) : (?ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type) ⟹ (body::'a OCL_Types.type, τ::'a OCL_Types.type, σ::'a OCL_Types.type) = ?ys› ‹(σ::'a OCL_Types.type) ≤ Boolean[?]›*) Pair_inject (*‹⟦(?a, ?b) = (?a', ?b'); ⟦?a = ?a'; ?b = ?b'⟧ ⟹ ?R⟧ ⟹ ?R›*) by metis next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E OneIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 5. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 6. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 7. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (OneIteratorT Γ ℳ src its its_ty body τ σ ρ) (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length src ≤ 1› ‹σ ≤ Boolean[?]› ‹Γ ⊢⇩E OneIteratorCall ℳ ArrowCall src its its_ty : ρ›*) show "?case" (*goal: ‹Boolean[1] = (ρ::'a OCL_Types.type)›*) apply (insert OneIteratorT.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E OneIteratorCall (ℳ::'a expr) ArrowCall (src::String.literal list) (its::'a OCL_Types.type option) (its_ty::'a expr) : (ρ::'a OCL_Types.type)›*)) (*goal: ‹Boolean[1] = ρ›*) apply (erule OneIteratorTE (*‹⟦?Γ ⊢⇩E OneIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ ρ. ⟦?k = ArrowCall; ?τ = Boolean[1]; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ρ); length ?its ≤ Suc 0; ρ ≤ Boolean[?]⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E OneIteratorCall (ℳ::'a expr) ArrowCall (src::String.literal list) (its::'a OCL_Types.type option) (its_ty::'a expr) : (ρ::'a OCL_Types.type) ⟹ Boolean[1] = ρ›*) by simp next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; Γ ⊢⇩E IsUniqueIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ Boolean[1] = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 4. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 5. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 6. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (IsUniqueIteratorT Γ ℳ src its its_ty body τ σ ρ) (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length (src::String.literal list) ≤ (1::nat)› ‹(Γ::String.literal ⇀⇩f 'a::ocl_object_model OCL_Types.type) ⊢⇩E IsUniqueIteratorCall (ℳ::'a::ocl_object_model expr) ArrowCall (src::String.literal list) (its::'a::ocl_object_model OCL_Types.type option) (its_ty::'a::ocl_object_model expr) : (ρ::'a::ocl_object_model OCL_Types.type)›*) show "?case" (*goal: ‹Boolean[1] = ρ›*) apply (insert IsUniqueIteratorT.prems (*‹Γ ⊢⇩E IsUniqueIteratorCall ℳ ArrowCall src its its_ty : ρ›*)) (*goal: ‹Boolean[1] = ρ›*) apply (erule IsUniqueIteratorTE (*‹⟦?Γ ⊢⇩E IsUniqueIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ ρ. ⟦?k = ArrowCall; ?τ = Boolean[1]; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ρ); length ?its ≤ Suc 0⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E IsUniqueIteratorCall (ℳ::'a expr) ArrowCall (src::String.literal list) (its::'a OCL_Types.type option) (its_ty::'a expr) : (ρ::'a OCL_Types.type) ⟹ Boolean[1] = ρ›*) by simp next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E SelectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 3. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 4. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 5. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (SelectIteratorT Γ ℳ src its its_ty body τ σ ρ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (ℳ::'a expr, src::String.literal list, its::'a OCL_Types.type option, its_ty::'a expr) : (body::'a OCL_Types.type, τ::'a OCL_Types.type, σ::'a OCL_Types.type)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length src ≤ 1› ‹(σ::'a OCL_Types.type) ≤ Boolean[?]› ‹Γ ⊢⇩E SelectIteratorCall ℳ ArrowCall src its its_ty : ρ›*) show "?case" (*goal: ‹(body::'a::ocl_object_model OCL_Types.type) = (ρ::'a::ocl_object_model OCL_Types.type)›*) apply (insert SelectIteratorT.prems (*‹Γ ⊢⇩E SelectIteratorCall ℳ ArrowCall src its its_ty : ρ›*)) (*goal: ‹body = ρ›*) apply (erule SelectIteratorTE (*‹⟦?Γ ⊢⇩E SelectIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀σ ρ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (?τ, σ, ρ); length ?its ≤ Suc 0; ρ ≤ Boolean[?]⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E SelectIteratorCall ℳ ArrowCall src its its_ty : ρ ⟹ body = ρ›*) using SelectIteratorT.hyps (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length (src::String.literal list) ≤ (1::nat)› ‹σ ≤ Boolean[?]›*) by blast next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; ρ ≤ Boolean[?]; Γ ⊢⇩E RejectIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ τ = σ'› 2. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 3. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 4. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (RejectIteratorT Γ ℳ src its its_ty body τ σ ρ) (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length (src::String.literal list) ≤ (1::nat)› ‹σ ≤ Boolean[?]› ‹Γ ⊢⇩E RejectIteratorCall ℳ ArrowCall src its its_ty : ρ›*) show "?case" (*goal: ‹body = ρ›*) apply (insert RejectIteratorT.prems (*‹Γ ⊢⇩E RejectIteratorCall ℳ ArrowCall src its its_ty : ρ›*)) (*goal: ‹(body::'a OCL_Types.type) = (ρ::'a OCL_Types.type)›*) apply (erule RejectIteratorTE (*‹⟦?Γ ⊢⇩E RejectIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀σ ρ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (?τ, σ, ρ); length ?its ≤ Suc 0; ρ ≤ Boolean[?]⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E RejectIteratorCall ℳ ArrowCall src its its_ty : ρ ⟹ body = ρ›*) using RejectIteratorT.hyps (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length (src::String.literal list) ≤ (1::nat)› ‹σ ≤ Boolean[?]›*) by blast next (*goals: 1. ‹⋀Γ src its its_ty body τ σ ρ υ σ'. ⟦Γ ⊢⇩I (src, its, its_ty, body) : (τ, σ, ρ); ⋀ys. Γ ⊢⇩I (src, its, its_ty, body) : ys ⟹ (τ, σ, ρ) = ys; length its ≤ 1; to_ordered_collection τ υ; Γ ⊢⇩E SortedByIteratorCall src ArrowCall its its_ty body : σ'⟧ ⟹ υ = σ'› 2. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 3. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (SortedByIteratorT Γ ℳ src its its_ty body τ σ ρ υ) (*‹Γ ⊢⇩I (ℳ, src, its, its_ty) : (body, τ, σ)› ‹Γ ⊢⇩I (ℳ, src, its, its_ty) : ?ys ⟹ (body, τ, σ) = ?ys› ‹length src ≤ 1› ‹to_ordered_collection body ρ› ‹Γ ⊢⇩E SortedByIteratorCall ℳ ArrowCall src its its_ty : υ›*) show "?case" (*goal: ‹(ρ::'a OCL_Types.type) = (υ::'a OCL_Types.type)›*) apply (insert SortedByIteratorT.prems (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩E SortedByIteratorCall (ℳ::'a expr) ArrowCall (src::String.literal list) (its::'a OCL_Types.type option) (its_ty::'a expr) : (υ::'a OCL_Types.type)›*)) (*goal: ‹ρ = υ›*) apply (erule SortedByIteratorTE (*‹⟦?Γ ⊢⇩E SortedByIteratorCall ?src ?k ?its ?its_ty ?body : ?τ; ⋀τ σ ρ. ⟦?k = ArrowCall; ?Γ ⊢⇩I (?src, ?its, ?its_ty, ?body) : (τ, σ, ρ); length ?its ≤ Suc 0; to_ordered_collection τ ?τ⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹Γ ⊢⇩E SortedByIteratorCall ℳ ArrowCall src its its_ty : υ ⟹ ρ = υ›*) using SortedByIteratorT.hyps (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (ℳ::'a expr, src::String.literal list, its::'a OCL_Types.type option, its_ty::'a expr) : (body::'a OCL_Types.type, τ::'a OCL_Types.type, σ::'a OCL_Types.type)› ‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩I (ℳ::'a expr, src::String.literal list, its::'a OCL_Types.type option, its_ty::'a expr) : (?ys::'a OCL_Types.type × 'a OCL_Types.type × 'a OCL_Types.type) ⟹ (body::'a OCL_Types.type, τ::'a OCL_Types.type, σ::'a OCL_Types.type) = ?ys› ‹length (src::String.literal list) ≤ (1::nat)› ‹to_ordered_collection (body::'a OCL_Types.type) (ρ::'a OCL_Types.type)›*) to_ordered_collection_det (*‹⟦to_ordered_collection ?τ ?σ₁; to_ordered_collection ?τ ?σ₂⟧ ⟹ ?σ₁ = ?σ₂›*) by blast next (*goals: 1. ‹⋀Γ ξ. Γ ⊢⇩L [] : ξ ⟹ [] = ξ› 2. ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (ExprListNilT Γ) (*‹(Γ::String.literal ⇀⇩f 'a OCL_Types.type) ⊢⇩L [] : (ξ::'a OCL_Types.type list)›*) thus "?case" (*goal: ‹[] = ξ›*) using expr_list_typing.cases (*‹⟦(?a1.0::String.literal ⇀⇩f ?'a OCL_Types.type) ⊢⇩L (?a2.0::?'a expr list) : (?a3.0::?'a OCL_Types.type list); ⋀Γ::String.literal ⇀⇩f ?'a OCL_Types.type. ⟦?a1.0 = Γ; ?a2.0 = []; ?a3.0 = []⟧ ⟹ ?P::bool; ⋀(Γ::String.literal ⇀⇩f ?'a OCL_Types.type) (expr::?'a expr) (τ::?'a OCL_Types.type) (exprs::?'a expr list) π::?'a OCL_Types.type list. ⟦?a1.0 = Γ; ?a2.0 = expr # exprs; ?a3.0 = τ # π; Γ ⊢⇩E expr : τ; Γ ⊢⇩L exprs : π⟧ ⟹ ?P⟧ ⟹ ?P›*) by auto next (*goal: ‹⋀Γ expr τ exprs π ξ. ⟦Γ ⊢⇩E expr : τ; ⋀σ. Γ ⊢⇩E expr : σ ⟹ τ = σ; Γ ⊢⇩L exprs : π; ⋀ξ. Γ ⊢⇩L exprs : ξ ⟹ π = ξ; Γ ⊢⇩L expr # exprs : ξ⟧ ⟹ τ # π = ξ›*) case (ExprListConsT Γ expr τ exprs π) (*‹Γ ⊢⇩E expr : τ› ‹Γ ⊢⇩E expr : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩L exprs : π› ‹Γ ⊢⇩L exprs : ?ξ ⟹ π = ?ξ› ‹Γ ⊢⇩L expr # exprs : ξ›*) show "?case" (*goal: ‹(τ::'a::ocl_object_model OCL_Types.type) # (π::'a::ocl_object_model OCL_Types.type list) = (ξ::'a::ocl_object_model OCL_Types.type list)›*) apply (insert ExprListConsT.prems (*‹Γ ⊢⇩L expr # exprs : ξ›*)) (*goal: ‹τ # π = ξ›*) apply (erule ExprListTE (*‹⟦?Γ ⊢⇩L ?exprs : ?π; ⟦?exprs = []; ?π = []⟧ ⟹ ?P; ⋀expr τ exprs π. ⟦?exprs = expr # exprs; ?π = τ # π; ?Γ ⊢⇩E expr : τ; ?Γ ⊢⇩L exprs : π⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦expr # exprs = []; ξ = []⟧ ⟹ τ # π = ξ› 2. ‹⋀expr τ exprs π. ⟦expr # exprs = expr # exprs; ξ = τ # π; Γ ⊢⇩E expr : τ; Γ ⊢⇩L exprs : π⟧ ⟹ τ # π = ξ› discuss goal 1*) apply (simp add: ExprListConsT.hyps (*‹Γ ⊢⇩E expr : τ› ‹Γ ⊢⇩E expr : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩L exprs : π› ‹Γ ⊢⇩L exprs : ?ξ ⟹ π = ?ξ›*)) (*discuss goal 2*) apply (simp add: ExprListConsT.hyps (*‹Γ ⊢⇩E expr : τ› ‹Γ ⊢⇩E expr : ?σ ⟹ τ = ?σ› ‹Γ ⊢⇩L exprs : π› ‹Γ ⊢⇩L exprs : ?ξ ⟹ π = ?ξ›*)) (*proven 2 subgoals*) . qed (*** Code Setup *************************************************************) section ‹Code Setup› code_pred op_type . code_pred (modes: i ⇒ i ⇒ i ⇒ bool, i ⇒ i ⇒ o ⇒ bool) iterator_typing . end
{ "path": "afp-2025-02-12/thys/Safe_OCL/OCL_Typing.thy", "repo": "afp-2025-02-12", "sha": "8650c8e579cada155f2a8f3e6ef272702930619a0fc11f2ad717584ed74de3f3" }
theory Auxiliary imports Main "HOL-Library.Extended_Nonnegative_Real" begin section ‹Auxiliary Material› context fixes S :: "'s set" assumes "finite S" begin lemma Max_image_commute: "(MAX x ∈ S. MAX y ∈ S. f x y) = (MAX y ∈ S. MAX x ∈ S. f x y)" proof (rule Max_eq_if (*‹⟦finite ?A; finite ?B; ∀a∈?A. ∃b∈?B. a ≤ b; ∀b∈?B. ∃a∈?A. b ≤ a⟧ ⟹ Max ?A = Max ?B›*), goal_cases) (*goals: 1. ‹finite ((λx::'s. Max ((f::'s ⇒ 's ⇒ 'a) x ` (S::'s set))) ` S)› 2. ‹finite ((λy::'s. MAX x::'s∈S::'s set. (f::'s ⇒ 's ⇒ 'a) x y) ` S)› 3. ‹∀a::'a∈(λx::'s. Max ((f::'s ⇒ 's ⇒ 'a) x ` (S::'s set))) ` S. ∃b::'a∈(λy::'s. MAX x::'s∈S. f x y) ` S. a ≤ b› 4. ‹∀b::'a∈(λy::'s. MAX x::'s∈S::'s set. (f::'s ⇒ 's ⇒ 'a) x y) ` S. ∃a::'a∈(λx::'s. Max (f x ` S)) ` S. b ≤ a›*) case 3 (*no hyothesis introduced yet*) { fix a assume "a ∈ S" (*‹(a::'s) ∈ (S::'s set)›*) with Max_in[OF finite_imageI [ OF ‹finite S› ], of "f a"] (*‹f a ` S ≠ {} ⟹ Max (f a ` S) ∈ f a ` S›*) have "Max (f a ` S) ∈ f a ` S" by auto then obtain b where "f a b = Max (f a ` S)" "b ∈ S" (*goal: ‹(⋀b::'s. ⟦(f::'s ⇒ 's ⇒ 'a) (a::'s) b = Max (f a ` (S::'s set)); b ∈ S⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto from ‹a ∈ S› (*‹(a::'s::type) ∈ (S::'s::type set)›*) have "f a b ≤ (MAX a ∈ S. f a b)" by (auto intro: Max_ge (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) finite_imageI[OF ‹finite S›] (*‹finite (?h ` S)›*)) with ‹f a b = _› (*‹(f::'s ⇒ 's ⇒ 'a) (a::'s) (b::'s) = Max (f a ` (S::'s set))›*) ‹b ∈ S› (*‹(b::'s) ∈ (S::'s set)›*) have "∃b∈S. Max (f a ` S) ≤ (MAX a ∈ S. f a b)" by auto } then show "?case" (*goal: ‹∀a∈(λx. Max (f x ` S)) ` S. ∃b∈(λy. MAX x∈S. f x y) ` S. a ≤ b›*) by auto next (*goals: 1. ‹finite ((λx. Max (f x ` S)) ` S)› 2. ‹finite ((λy. MAX x∈S. f x y) ` S)› 3. ‹∀b∈(λy. MAX x∈S. f x y) ` S. ∃a∈(λx. Max (f x ` S)) ` S. b ≤ a›*) case 4 (*no hyothesis introduced yet*) { fix b assume "b ∈ S" (*‹(b::'s) ∈ (S::'s set)›*) with Max_in[OF finite_imageI [ OF ‹finite S› ], of "λ a. f a b"] (*‹(λa. f a b) ` S ≠ {} ⟹ (MAX a∈S. f a b) ∈ (λa. f a b) ` S›*) have "(MAX a ∈ S. f a b) ∈ (λa. f a b) ` S" by auto then obtain a where "f a b = (MAX a ∈ S. f a b)" "a ∈ S" (*goal: ‹(⋀a. ⟦f a b = (MAX a∈S. f a b); a ∈ S⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹b ∈ S› (*‹(b::'s) ∈ (S::'s set)›*) have "f a b ≤ Max (f a ` S)" by (auto intro: Max_ge (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*) finite_imageI[OF ‹finite S›] (*‹finite (?h ` S)›*)) with ‹f a b = _› (*‹f a b = (MAX a∈S. f a b)›*) ‹a ∈ S› (*‹a ∈ S›*) have "∃a∈S. (MAX a ∈ S. f a b) ≤ Max (f a ` S)" by auto } then show "?case" (*goal: ‹∀b∈(λy. MAX x∈S. f x y) ` S. ∃a∈(λx. Max (f x ` S)) ` S. b ≤ a›*) by auto qed (use ‹finite S› in auto) (*solves the remaining goals: 1. ‹finite ((λx. Max (f x ` S)) ` S)› 2. ‹finite ((λy. MAX x∈S. f x y) ` S)›*) lemma Max_image_left_mult: "(MAX x ∈ S. c * f x) = (c :: ennreal) * (MAX x ∈ S. f x)" if "S ≠ {}" apply (rule Max_eqI (*‹⟦finite (?A::?'a set); ⋀y::?'a. y ∈ ?A ⟹ y ≤ (?x::?'a); ?x ∈ ?A⟧ ⟹ Max ?A = ?x›*)) (*goal: ‹(MAX x∈S. c * f x) = c * Max (f ` S)›*) subgoal for using ‹finite S› (*‹finite S›*) by auto subgoal for y using ‹finite S› (*‹finite S›*) by (auto intro: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) subgoal for using Max_in[OF finite_imageI [ OF ‹finite S› ], of f] (*‹f ` S ≠ {} ⟹ Max (f ` S) ∈ f ` S›*) ‹S ≠ {}› (*‹S ≠ {}›*) by auto . end (* Finite set *) lemma Max_to_image: "Max {f t | t. t ∈ S} = Max (f ` S)" apply (rule arg_cong[where f = Max] (*‹?x = ?y ⟹ Max ?x = Max ?y›*)) (*goal: ‹Max {f t |t. t ∈ S} = Max (f ` S)›*) by auto lemma Max_to_image2: "Max {f t | t. P t} = Max (f ` {t. P t})" apply (rule arg_cong[where f = Max] (*‹?x = ?y ⟹ Max ?x = Max ?y›*)) (*goal: ‹Max {f t |t. P t} = Max (f ` {t. P t})›*) by auto lemma Max_image_cong: "Max (f ` S) = Max (g ` T)" if "S = T" "⋀x. x ∈ T ⟹ f x = g x" by (intro arg_cong[where f = Max] (*‹?x = ?y ⟹ Max ?x = Max ?y›*) image_cong[OF that] (*‹(⋀x. x ∈ T ⟹ ?x1 x ∈ T) ⟹ (λx. f (?x1 x)) ` S = (λx. g (?x1 x)) ` T›*)) lemma Max_image_cong_simp: "Max (f ` S) = Max (g ` T)" if "S = T" "⋀x. x ∈ T =simp=> f x = g x" using Max_image_cong[OF that [ unfolded simp_implies_def ]] (*‹(⋀x. x ∈ T ⟹ ?x1 x ∈ T) ⟹ (MAX x∈S. f (?x1 x)) = (MAX x∈T. g (?x1 x))›*) . lemma Max_eq_image_if: assumes "finite S" "finite T" "∀x ∈ S. ∃y ∈ T. f x ≤ g y" "∀x ∈ T. ∃y ∈ S. g x ≤ f y" shows "Max (f ` S) = Max (g ` T)" using assms (*‹finite S› ‹finite T› ‹∀x::'a::type∈S::'a::type set. ∃y::'b::type∈T::'b::type set. (f::'a::type ⇒ 'c::linorder) x ≤ (g::'b::type ⇒ 'c::linorder) y› ‹∀x∈T. ∃y∈S. g x ≤ f y›*) by (auto intro: Max_eq_if (*‹⟦finite ?A; finite ?B; ∀a∈?A. ∃b∈?B. a ≤ b; ∀b∈?B. ∃a∈?A. b ≤ a⟧ ⟹ Max ?A = Max ?B›*)) theorem Max_in_image: assumes "finite A" and "A ≠ {}" obtains x where "x ∈ A" and "Max (f ` A) = f x" proof (-) (*goal: ‹(⋀x. ⟦x ∈ A; Max (f ` A) = f x⟧ ⟹ thesis) ⟹ thesis›*) from Max_in[of "f ` A"] (*‹⟦finite ((f::'a::type ⇒ 'b::linorder) ` (A::'a::type set)); f ` A ≠ {}⟧ ⟹ Max (f ` A) ∈ f ` A›*) assms (*‹finite A› ‹A ≠ {}›*) have "Max (f ` A) ∈ f ` A" by auto then show "?thesis" (*goal: ‹thesis›*) by (auto intro: that (*‹⟦?x ∈ A; Max (f ` A) = f ?x⟧ ⟹ thesis›*)) qed lemma Max_ge_image: "Max (f ` S) ≥ f x" if "finite S" "x ∈ S" using that (*‹finite S› ‹(x::'a::type) ∈ (S::'a::type set)›*) by (auto intro: Max_ge (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ ?x ≤ Max ?A›*)) lemma Max_image_pair: assumes "finite S" "finite T" "T ≠ {}" shows "(MAX s ∈ S. MAX t ∈ T. f s t) = (MAX (s, t) ∈ S × T. f s t)" proof (rule Max_eq_image_if (*‹⟦finite ?S; finite ?T; ∀x∈?S. ∃y∈?T. ?f x ≤ ?g y; ∀x∈?T. ∃y∈?S. ?g x ≤ ?f y⟧ ⟹ Max (?f ` ?S) = Max (?g ` ?T)›*); (clarsimp)?, goal_cases) (*goals: 1. ‹finite S› 2. ‹finite (S × T)› 3. ‹⋀x. x ∈ S ⟹ ∃xa∈S. ∃y∈T. Max (f x ` T) ≤ f xa y› 4. ‹⋀x y. ⟦x ∈ S; y ∈ T⟧ ⟹ ∃ya∈S. f x y ≤ Max (f ya ` T)›*) case (3 x) (*‹x ∈ S›*) from ‹finite T› (*‹finite T›*) ‹T ≠ {}› (*‹T ≠ {}›*) obtain y where "y ∈ T" and "Max (f x ` T) = f x y" (*goal: ‹(⋀y::'b. ⟦y ∈ (T::'b set); Max ((f::'a ⇒ 'b ⇒ 'c) (x::'a) ` T) = f x y⟧ ⟹ thesis::bool) ⟹ thesis›*) by (rule Max_in_image (*‹⟦finite (?A::?'a::type set); ?A ≠ {}; ⋀x::?'a::type. ⟦x ∈ ?A; Max ((?f::?'a::type ⇒ ?'b::linorder) ` ?A) = ?f x⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) with ‹x ∈ S› (*‹(x::'a) ∈ (S::'a set)›*) show "?case" (*goal: ‹∃xa∈S. ∃y∈T. Max (f x ` T) ≤ f xa y›*) by auto next (*goals: 1. ‹finite S› 2. ‹finite (S × T)› 3. ‹⋀x y. ⟦x ∈ S; y ∈ T⟧ ⟹ ∃ya∈S. f x y ≤ Max (f ya ` T)›*) case (4 a b) (*‹a ∈ S› ‹b ∈ T›*) with ‹finite T› (*‹finite T›*) show "?case" (*goal: ‹∃y∈S. f a b ≤ Max (f y ` T)›*) by force qed (use assms in auto) (*solves the remaining goals: 1. ‹finite S› 2. ‹finite (S × T)›*) fun argmax where "argmax f (x # xs) = List.fold (λ a (b, v). let w = f a in if w > v then (a, w) else (b, v)) xs (x, f x)" lemma list_cases: assumes "xs = [] ⟹ P []" and "⋀ x. xs = [x] ⟹ P [x]" and "⋀ x y ys. xs = (x # y # ys) ⟹ P (x # y # ys)" shows "P xs" apply (cases xs) (*goal: ‹(P::'a list ⇒ bool) (xs::'a list)›*) apply (simp add: assms (*‹xs = [] ⟹ P []› ‹xs = [?x] ⟹ P [?x]› ‹xs = ?x # ?y # ?ys ⟹ P (?x # ?y # ?ys)›*)) (*top goal: ‹xs = [] ⟹ P xs› and 1 goal remains*) subgoal for y and ys apply (cases ys) (*goals: 1. ‹⟦xs = y # ys; ys = []⟧ ⟹ P xs› 2. ‹⋀a list. ⟦xs = y # ys; ys = a # list⟧ ⟹ P xs› discuss goal 1*) apply (simp add: assms (*‹xs = [] ⟹ P []› ‹xs = [?x] ⟹ P [?x]› ‹xs = ?x # ?y # ?ys ⟹ P (?x # ?y # ?ys)›*)) (*discuss goal 2*) apply (simp add: assms (*‹(xs::'a::type list) = [] ⟹ (P::'a::type list ⇒ bool) []› ‹(xs::'a::type list) = [?x::'a::type] ⟹ (P::'a::type list ⇒ bool) [?x]› ‹(xs::'a::type list) = (?x::'a::type) # (?y::'a::type) # (?ys::'a::type list) ⟹ (P::'a::type list ⇒ bool) (?x # ?y # ?ys)›*)) (*proven 2 subgoals*) . . lemma argmax: assumes "xs ≠ []" shows "fst (argmax f xs) ∈ set xs" (is "?A") "f (fst (argmax f xs)) = snd (argmax f xs)" (is "?B") "snd (argmax f xs) = (MAX x ∈ set xs. f x)" (is "?C") proof (-) (*goals: 1. ‹fst (argmax f xs) ∈ set xs› 2. ‹f (fst (argmax f xs)) = snd (argmax f xs)› 3. ‹snd (argmax f xs) = Max (f ` set xs)›*) let ?f = "λ a (b, v). let w = f a in if w > v then (a, w) else (b, v)" have "fst (List.fold ?f xs (x, f x)) ∈ {x} ∪ set xs" if "xs ≠ []" for x and xs using that (*‹(xs::'a::type list) ≠ []›*) apply (induction xs arbitrary: x rule: list_nonempty_induct) (*goals: 1. ‹⋀x xa. fst (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) [x] (xa, f xa)) ∈ {xa} ∪ set [x]› 2. ‹⋀x xs xa. ⟦xs ≠ []; ⋀x. fst (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)) ∈ {x} ∪ set xs⟧ ⟹ fst (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) (x # xs) (xa, f xa)) ∈ {xa} ∪ set (x # xs)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*proven 2 subgoals*) . with ‹xs ≠ []› (*‹(xs::'a::type list) ≠ []›*) show "?A" apply (cases xs rule: list_cases (*‹⟦?xs = [] ⟹ ?P []; ⋀x. ?xs = [x] ⟹ ?P [x]; ⋀x y ys. ?xs = x # y # ys ⟹ ?P (x # y # ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦(xs::'a::type list) ≠ []; ⋀(xs::'a::type list) x::'a::type. xs ≠ [] ⟹ fst (fold (λ(a::'a::type) (b::'a::type, v::'b::linorder). let w::'b::linorder = (f::'a::type ⇒ 'b::linorder) a in if v < w then (a, w) else (b, v)) xs (x, f x)) ∈ {x} ∪ set xs; xs = []⟧ ⟹ fst (argmax f []) ∈ set []› 2. ‹⋀x::'a::type. ⟦(xs::'a::type list) ≠ []; ⋀(xs::'a::type list) x::'a::type. xs ≠ [] ⟹ fst (fold (λ(a::'a::type) (b::'a::type, v::'b::linorder). let w::'b::linorder = (f::'a::type ⇒ 'b::linorder) a in if v < w then (a, w) else (b, v)) xs (x, f x)) ∈ {x} ∪ set xs; xs = [x]⟧ ⟹ fst (argmax f [x]) ∈ set [x]› 3. ‹⋀(x::'a::type) (y::'a::type) ys::'a::type list. ⟦(xs::'a::type list) ≠ []; ⋀(xs::'a::type list) x::'a::type. xs ≠ [] ⟹ fst (fold (λ(a::'a::type) (b::'a::type, v::'b::linorder). let w::'b::linorder = (f::'a::type ⇒ 'b::linorder) a in if v < w then (a, w) else (b, v)) xs (x, f x)) ∈ {x} ∪ set xs; xs = x # y # ys⟧ ⟹ fst (argmax f (x # y # ys)) ∈ set (x # y # ys)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply fastforce (*proven 3 subgoals*) . have "f (fst (List.fold ?f xs (x, f x))) = snd (List.fold ?f xs (x, f x))" if "xs ≠ []" for x and xs using that (*‹xs ≠ []›*) apply (induction xs arbitrary: x rule: list_nonempty_induct) (*goals: 1. ‹⋀(x::'a) xa::'a. (f::'a ⇒ 'b) (fst (fold (λ(a::'a) (b::'a, v::'b). let w::'b = f a in if v < w then (a, w) else (b, v)) [x] (xa, f xa))) = snd (fold (λ(a::'a) (b::'a, v::'b). let w::'b = f a in if v < w then (a, w) else (b, v)) [x] (xa, f xa))› 2. ‹⋀(x::'a) (xs::'a list) xa::'a. ⟦xs ≠ []; ⋀x::'a. (f::'a ⇒ 'b) (fst (fold (λ(a::'a) (b::'a, v::'b). let w::'b = f a in if v < w then (a, w) else (b, v)) xs (x, f x))) = snd (fold (λ(a::'a) (b::'a, v::'b). let w::'b = f a in if v < w then (a, w) else (b, v)) xs (x, f x))⟧ ⟹ f (fst (fold (λ(a::'a) (b::'a, v::'b). let w::'b = f a in if v < w then (a, w) else (b, v)) (x # xs) (xa, f xa))) = snd (fold (λ(a::'a) (b::'a, v::'b). let w::'b = f a in if v < w then (a, w) else (b, v)) (x # xs) (xa, f xa))› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) max_def (*‹max (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*proven 2 subgoals*) . with ‹xs ≠ []› (*‹xs ≠ []›*) show "?B" apply (cases xs rule: list_cases (*‹⟦(?xs::?'a list) = [] ⟹ (?P::?'a list ⇒ bool) []; ⋀x::?'a. ?xs = [x] ⟹ ?P [x]; ⋀(x::?'a) (y::?'a) ys::?'a list. ?xs = x # y # ys ⟹ ?P (x # y # ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦xs ≠ []; ⋀xs x. xs ≠ [] ⟹ f (fst (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x))) = snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)); xs = []⟧ ⟹ f (fst (argmax f [])) = snd (argmax f [])› 2. ‹⋀x. ⟦xs ≠ []; ⋀xs x. xs ≠ [] ⟹ f (fst (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x))) = snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)); xs = [x]⟧ ⟹ f (fst (argmax f [x])) = snd (argmax f [x])› 3. ‹⋀x y ys. ⟦xs ≠ []; ⋀xs x. xs ≠ [] ⟹ f (fst (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x))) = snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)); xs = x # y # ys⟧ ⟹ f (fst (argmax f (x # y # ys))) = snd (argmax f (x # y # ys))› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply fastforce (*proven 3 subgoals*) . have "snd (List.fold ?f xs (x, f x)) = (MAX x ∈ {x} ∪ set xs. f x)" if "xs ≠ []" for x and xs using that (*‹(xs::'a::type list) ≠ []›*) apply (induction xs arbitrary: x rule: list_nonempty_induct) (*goals: 1. ‹⋀x xa. snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) [x] (xa, f xa)) = Max (f ` ({xa} ∪ set [x]))› 2. ‹⋀x xs xa. ⟦xs ≠ []; ⋀x. snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)) = Max (f ` ({x} ∪ set xs))⟧ ⟹ snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) (x # xs) (xa, f xa)) = Max (f ` ({xa} ∪ set (x # xs)))› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*proven 2 subgoals*) . with ‹xs ≠ []› (*‹xs ≠ []›*) show "?C" apply (cases xs rule: list_cases (*‹⟦(?xs::?'a list) = [] ⟹ (?P::?'a list ⇒ bool) []; ⋀x::?'a. ?xs = [x] ⟹ ?P [x]; ⋀(x::?'a) (y::?'a) ys::?'a list. ?xs = x # y # ys ⟹ ?P (x # y # ys)⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦xs ≠ []; ⋀xs x. xs ≠ [] ⟹ snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)) = Max (f ` ({x} ∪ set xs)); xs = []⟧ ⟹ snd (argmax f []) = Max (f ` set [])› 2. ‹⋀x. ⟦xs ≠ []; ⋀xs x. xs ≠ [] ⟹ snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)) = Max (f ` ({x} ∪ set xs)); xs = [x]⟧ ⟹ snd (argmax f [x]) = Max (f ` set [x])› 3. ‹⋀x y ys. ⟦xs ≠ []; ⋀xs x. xs ≠ [] ⟹ snd (fold (λa (b, v). let w = f a in if v < w then (a, w) else (b, v)) xs (x, f x)) = Max (f ` ({x} ∪ set xs)); xs = x # y # ys⟧ ⟹ snd (argmax f (x # y # ys)) = Max (f ` set (x # y # ys))› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply fastforce (*proven 3 subgoals*) . qed end (* Theory *)
{ "path": "afp-2025-02-12/thys/Hidden_Markov_Models/Auxiliary.thy", "repo": "afp-2025-02-12", "sha": "a3a7bb971feb909bd5d110166c2c55273099d47f4022d9a068ff9a549fec0e3b" }
(* Copyright 2021 (C) Mihails Milehins *) section‹Category ‹Set› and universal constructions› theory CZH_UCAT_Set imports CZH_UCAT_Complete begin subsection‹Discrete functor with tiny maps to the category ‹Set›› lemma (in 𝒵) tm_cf_discrete_cat_Set_if_VLambda_in_Vset: assumes "VLambda I F ∈⇩∘ Vset α" shows "tm_cf_discrete α I F (cat_Set α)" proof (intro tm_cf_discreteI (*‹⟦category ?α ?ℭ; ⋀i. i ∈⇩∘ ?I ⟹ ?F i ∈⇩∘ ?ℭ⦇Obj⦈; VLambda ?I ?F ∈⇩∘ Vset ?α; (λi∈⇩∘?I. ?ℭ⦇CId⦈⦇?F i⦈) ∈⇩∘ Vset ?α⟧ ⟹ tm_cf_discrete ?α ?I ?F ?ℭ›*)) (*goals: 1. ‹category α (cat_Set α)› 2. ‹⋀i. i ∈⇩∘ I ⟹ F i ∈⇩∘ cat_Set α⦇Obj⦈› 3. ‹VLambda I F ∈⇩∘ Vset α› 4. ‹(λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ∈⇩∘ Vset α›*) from assms (*‹VLambda I F ∈⇩∘ Vset α›*) have vrange_F_in_Vset: "ℛ⇩∘ (VLambda I F) ∈⇩∘ Vset α" by (auto intro: vrange_in_VsetI (*‹?r ∈⇩∘ Vset ?α ⟹ ℛ⇩∘ ?r ∈⇩∘ Vset ?α›*)) show "(λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ∈⇩∘ Vset α" proof (rule vbrelation.vbrelation_Limit_in_VsetI (*‹⟦vbrelation ?r; Limit ?α; 𝒟⇩∘ ?r ∈⇩∘ Vset ?α; ℛ⇩∘ ?r ∈⇩∘ Vset ?α⟧ ⟹ ?r ∈⇩∘ Vset ?α›*)) (*goals: 1. ‹vbrelation (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈)› 2. ‹Limit α› 3. ‹𝒟⇩∘ (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ∈⇩∘ Vset α› 4. ‹ℛ⇩∘ (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ∈⇩∘ Vset α›*) from assms (*‹VLambda I F ∈⇩∘ Vset α›*) show "𝒟⇩∘ (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ∈⇩∘ Vset α" by (metis vdomain_VLambda (*‹𝒟⇩∘ (VLambda ?A ?f) = ?A›*) vdomain_in_VsetI (*‹?r ∈⇩∘ Vset ?α ⟹ 𝒟⇩∘ ?r ∈⇩∘ Vset ?α›*)) define Q where "Q i = ( if i = 0 then VPow ((⋃⇩∘i∈⇩∘I. F i) ×⇩∘ (⋃⇩∘i∈⇩∘I. F i)) else set (F ` elts I) )" for i :: V have "ℛ⇩∘ (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ⊆⇩∘ (∏⇩∘i∈⇩∘ set {0, 1⇩ℕ, 2⇩ℕ}. Q i)" apply (intro vsubsetI (*‹(⋀x. x ∈⇩∘ ?A ⟹ x ∈⇩∘ ?B) ⟹ ?A ⊆⇩∘ ?B›*)) (*goal: ‹ℛ⇩∘ (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ⊆⇩∘ vproduct (ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ}) Q›*) proof (unfold cat_Set_components (*‹cat_Set ?α⦇Obj⦈ = Vset ?α› ‹cat_Set ?α⦇Arr⦈ = ZFC_in_HOL.set {T. arr_Set ?α T}› ‹cat_Set ?α⦇Dom⦈ = (λT∈⇩∘ZFC_in_HOL.set {T. arr_Set ?α T}. T⦇ArrDom⦈)› ‹cat_Set ?α⦇Cod⦈ = (λT∈⇩∘ZFC_in_HOL.set {T. arr_Set ?α T}. T⦇ArrCod⦈)› ‹cat_Set ?α⦇Comp⦈ = (λST∈⇩∘composable_arrs (dg_Set ?α). ST⦇[]⇩∘⦈ ∘⇩R⇩e⇩l ST⦇1⇩ℕ⦈)› ‹cat_Set ?α⦇CId⦈ = VLambda (Vset ?α) id_Rel›*)) (*goal: ‹⋀x. x ∈⇩∘ ℛ⇩∘ (λi∈⇩∘I. VLambda (Vset α) id_Rel⦇F i⦈) ⟹ x ∈⇩∘ vproduct (ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ}) Q›*) fix y assume "y ∈⇩∘ ℛ⇩∘ (λi∈⇩∘I. VLambda (Vset α) id_Set⦇F i⦈)" (*‹(y::V) ∈⇩∘ ℛ⇩∘ (λi::V∈⇩∘I::V. VLambda (Vset (α::V)) id_Rel⦇(F::V ⇒ V) i⦈)›*) then obtain i where i: "i ∈⇩∘ I" and y_def: "y = VLambda (Vset α) id_Set⦇F i⦈" (*goal: ‹(⋀i. ⟦i ∈⇩∘ I; y = VLambda (Vset α) id_Rel⦇F i⦈⟧ ⟹ thesis) ⟹ thesis›*) by auto from i (*‹i ∈⇩∘ I›*) have "F i ∈⇩∘ ℛ⇩∘ (VLambda I F)" by auto with vrange_F_in_Vset (*‹ℛ⇩∘ (VLambda I F) ∈⇩∘ Vset α›*) have "F i ∈⇩∘ Vset α" by auto then have y_def: "y = id_Set (F i)" unfolding y_def (*goal: ‹VLambda (Vset α) id_Rel⦇F i⦈ = id_Rel (F i)›*) by auto show "y ∈⇩∘ (∏⇩∘i∈⇩∘set {0, 1⇩ℕ, 2⇩ℕ}. Q i)" unfolding y_def (*goal: ‹id_Rel (F i) ∈⇩∘ vproduct (ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ}) Q›*) proof (intro vproductI (*‹⟦vsv ?f; 𝒟⇩∘ ?f = ?I; ∀i∈elts ?I. ?f⦇i⦈ ∈⇩∘ ?A i⟧ ⟹ ?f ∈⇩∘ vproduct ?I ?A›*), unfold Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*); (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*))?) (*goals: 1. ‹vsv (id_Rel ((F::V ⇒ V) (i::V)))› 2. ‹𝒟⇩∘ (id_Rel ((F::V ⇒ V) (i::V))) = ZFC_in_HOL.set {[]⇩∘, (1::nat)⇩ℕ, (2::nat)⇩ℕ}› 3. ‹⋀x::V. x ∈⇩∘ ZFC_in_HOL.set {[]⇩∘, (1::nat)⇩ℕ, (2::nat)⇩ℕ} ⟹ id_Rel ((F::V ⇒ V) (i::V))⦇x⦈ ∈⇩∘ (Q::V ⇒ V) x›*) show "𝒟⇩∘ (id_Rel (F i)) = set {0, 1⇩ℕ, 2⇩ℕ}" by (simp add: id_Rel_def (*‹id_Rel ?A = incl_Rel ?A ?A›*) incl_Rel_def (*‹incl_Rel ?A ?B = [vid_on ?A, ?A, ?B]⇩∘›*) three (*‹3⇩ℕ = ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ}›*) nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) fix j assume "j ∈⇩∘ set {0, 1⇩ℕ, 2⇩ℕ}" (*‹(j::V) ∈⇩∘ ZFC_in_HOL.set {[]⇩∘, (1::nat)⇩ℕ, (2::nat)⇩ℕ}›*) then consider "j = 0" | "j = 1⇩ℕ" | "j = 2⇩ℕ" (*goal: ‹⟦j = []⇩∘ ⟹ thesis; j = 1⇩ℕ ⟹ thesis; j = 2⇩ℕ ⟹ thesis⟧ ⟹ thesis›*) by auto then show "id_Rel (F i)⦇j⦈ ∈⇩∘ Q j" proof (cases) (*goals: 1. ‹j = []⇩∘ ⟹ id_Rel (F i)⦇j⦈ ∈⇩∘ Q j› 2. ‹j = 1⇩ℕ ⟹ id_Rel (F i)⦇j⦈ ∈⇩∘ Q j› 3. ‹j = 2⇩ℕ ⟹ id_Rel (F i)⦇j⦈ ∈⇩∘ Q j›*) case 1 (*‹(j::V) = []⇩∘›*) from i (*‹i ∈⇩∘ I›*) show "?thesis" (*goal: ‹id_Rel ((F::V ⇒ V) (i::V))⦇(j::V)⦈ ∈⇩∘ (Q::V ⇒ V) j›*) unfolding "1" (*goal: ‹id_Rel (F i)⦇[]⇩∘⦈ ∈⇩∘ Q []⇩∘›*) apply (subst arr_field_simps(1)[symmetric] (*‹[]⇩∘ = ArrVal›*)) (*goal: ‹id_Rel (F i)⦇[]⇩∘⦈ ∈⇩∘ Q []⇩∘›*) apply (unfold id_Rel_components (*‹id_Rel ?A⦇ArrVal⦈ = vid_on ?A› ‹id_Rel ?A⦇ArrDom⦈ = ?A› ‹id_Rel ?A⦇ArrCod⦈ = ?A›*) Q_def (*‹Q ?i = (if ?i = []⇩∘ ⇒ VPow (⋃⇩∘ (VLambda I F `⇩∘ I) ×⇩∘ ⋃⇩∘ (VLambda I F `⇩∘ I)) | otherwise ⇒ ZFC_in_HOL.set (F ` elts I))›*)) (*goal: ‹(i::V) ∈⇩∘ (I::V) ⟹ id_Rel ((F::V ⇒ V) i)⦇ArrVal⦈ ∈⇩∘ (Q::V ⇒ V) []⇩∘›*) by force next (*goals: 1. ‹j = 1⇩ℕ ⟹ id_Rel (F i)⦇j⦈ ∈⇩∘ Q j› 2. ‹j = 2⇩ℕ ⟹ id_Rel (F i)⦇j⦈ ∈⇩∘ Q j›*) case 2 (*‹j = 1⇩ℕ›*) from i (*‹i ∈⇩∘ I›*) show "?thesis" (*goal: ‹id_Rel (F i)⦇j⦈ ∈⇩∘ Q j›*) unfolding "2" (*goal: ‹id_Rel (F i)⦇1⇩ℕ⦈ ∈⇩∘ Q (1⇩ℕ)›*) apply (subst arr_field_simps(2)[symmetric] (*‹1⇩ℕ = ArrDom›*)) (*goal: ‹id_Rel (F i)⦇1⇩ℕ⦈ ∈⇩∘ Q (1⇩ℕ)›*) apply (unfold id_Rel_components (*‹id_Rel ?A⦇ArrVal⦈ = vid_on ?A› ‹id_Rel ?A⦇ArrDom⦈ = ?A› ‹id_Rel ?A⦇ArrCod⦈ = ?A›*) Q_def (*‹Q ?i = (if ?i = []⇩∘ ⇒ VPow (⋃⇩∘ (VLambda I F `⇩∘ I) ×⇩∘ ⋃⇩∘ (VLambda I F `⇩∘ I)) | otherwise ⇒ ZFC_in_HOL.set (F ` elts I))›*)) (*goal: ‹i ∈⇩∘ I ⟹ id_Rel (F i)⦇ArrDom⦈ ∈⇩∘ Q (1⇩ℕ)›*) by auto next (*goal: ‹j = 2⇩ℕ ⟹ id_Rel (F i)⦇j⦈ ∈⇩∘ Q j›*) case 3 (*‹(j::V) = (2::nat)⇩ℕ›*) from i (*‹i ∈⇩∘ I›*) show "?thesis" (*goal: ‹id_Rel (F i)⦇j⦈ ∈⇩∘ Q j›*) unfolding "3" (*goal: ‹id_Rel (F i)⦇2⇩ℕ⦈ ∈⇩∘ Q (2⇩ℕ)›*) apply (subst arr_field_simps(3)[symmetric] (*‹2⇩ℕ = ArrCod›*)) (*goal: ‹id_Rel (F i)⦇2⇩ℕ⦈ ∈⇩∘ Q (2⇩ℕ)›*) apply (unfold id_Rel_components (*‹id_Rel ?A⦇ArrVal⦈ = vid_on ?A› ‹id_Rel ?A⦇ArrDom⦈ = ?A› ‹id_Rel ?A⦇ArrCod⦈ = ?A›*) Q_def (*‹Q ?i = (if ?i = []⇩∘ ⇒ VPow (⋃⇩∘ (VLambda I F `⇩∘ I) ×⇩∘ ⋃⇩∘ (VLambda I F `⇩∘ I)) | otherwise ⇒ ZFC_in_HOL.set (F ` elts I))›*)) (*goal: ‹i ∈⇩∘ I ⟹ id_Rel (F i)⦇ArrCod⦈ ∈⇩∘ Q (2⇩ℕ)›*) by auto qed qed (auto simp: id_Rel_def (*‹id_Rel ?A = incl_Rel ?A ?A›*) cat_Set_cs_intros (*‹vsv (?S ∘⇩R⇩e⇩l ?T)› ‹vsv (incl_Rel ?A ?B⦇ArrVal⦈)› ‹vfsequence (incl_Rel ?A ?B)› ‹vfsequence (id_Rel ?A)› ‹⟦arr_Set ?α ?S; arr_Set ?α ?T; ℛ⇩∘ (?T⦇ArrVal⦈) ⊆⇩∘ 𝒟⇩∘ (?S⦇ArrVal⦈)⟧ ⟹ arr_Set ?α (?S ∘⇩R⇩e⇩l ?T)› ‹⟦?F : ?A ↦⇘cat_Set ?α⇙ ?B; ?a ∈⇩∘ ?A⟧ ⟹ ?F⦇ArrVal⦈⦇?a⦈ ∈⇩∘ ?B› ‹⟦arr_Set ?α ?S; ?S⦇ArrDom⦈ = ?A; ?S⦇ArrCod⦈ = ?B⟧ ⟹ ?S : ?A ↦⇘cat_Set ?α⇙ ?B› ‹⟦𝒵 ?α; ?A ∈⇩∘ cat_Set ?α⦇Obj⦈; ?B ∈⇩∘ cat_Set ?α⦇Obj⦈; ?A ⊆⇩∘ ?B; ?A' = ?A; ?B' = ?B; ?ℭ' = cat_Set ?α⟧ ⟹ incl_Rel ?A ?B : ?A' ↦⇘?ℭ'⇙ ?B'› ‹vsv (vprojection_arrow ?I ?A ?i⦇ArrVal⦈)› ‹vsv (vcinjection_arrow ?I ?A ?i⦇ArrVal⦈)› ‹vsv (cat_Set_obj_prod_up ?I ?F ?A ?φ⦇ArrVal⦈)› ‹vsv (cat_Set_obj_coprod_up ?I ?F ?A ?φ⦇ArrVal⦈)› and more 4 facts*)) (*solved the remaining goal: ‹vsv (id_Rel ((F::V ⇒ V) (i::V)))›*) qed moreover have "(∏⇩∘i∈⇩∘ set {0, 1⇩ℕ, 2⇩ℕ}. Q i) ∈⇩∘ Vset α" proof (rule Limit_vproduct_in_VsetI (*‹⟦Limit ?α; ?I ∈⇩∘ Vset ?α; ⋀i. i ∈⇩∘ ?I ⟹ ?A i ∈⇩∘ Vset ?α; vfinite ?I⟧ ⟹ vproduct ?I ?A ∈⇩∘ Vset ?α›*)) (*goals: 1. ‹Limit α› 2. ‹ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ} ∈⇩∘ Vset α› 3. ‹⋀i. i ∈⇩∘ ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ} ⟹ Q i ∈⇩∘ Vset α› 4. ‹vfinite (ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ})›*) show "set {0, 1⇩ℕ, 2⇩ℕ} ∈⇩∘ Vset α" unfolding three[symmetric] (*goal: ‹3⇩ℕ ∈⇩∘ Vset α›*) by simp from assms (*‹VLambda I F ∈⇩∘ Vset α›*) have "VPow ((⋃⇩∘i∈⇩∘I. F i) ×⇩∘ (⋃⇩∘i∈⇩∘I. F i)) ∈⇩∘ Vset α" apply (intro Limit_VPow_in_VsetI (*‹⟦Limit ?α; ?A ∈⇩∘ Vset ?α⟧ ⟹ VPow ?A ∈⇩∘ Vset ?α›*) Limit_vtimes_in_VsetI (*‹⟦Limit ?α; ?A ∈⇩∘ Vset ?α; ?B ∈⇩∘ Vset ?α⟧ ⟹ ?A ×⇩∘ ?B ∈⇩∘ Vset ?α›*) Limit_vifunion_in_Vset_if_VLambda_in_VsetI (*‹⟦Limit ?α; VLambda ?I ?A ∈⇩∘ Vset ?α⟧ ⟹ ⋃⇩∘ (VLambda ?I ?A `⇩∘ ?I) ∈⇩∘ Vset ?α›*)) (*goals: 1. ‹VLambda I F ∈⇩∘ Vset α ⟹ Limit α› 2. ‹VLambda I F ∈⇩∘ Vset α ⟹ Limit α› 3. ‹VLambda I F ∈⇩∘ Vset α ⟹ Limit α› 4. ‹VLambda I F ∈⇩∘ Vset α ⟹ VLambda I F ∈⇩∘ Vset α› 5. ‹VLambda I F ∈⇩∘ Vset α ⟹ Limit α› 6. ‹VLambda I F ∈⇩∘ Vset α ⟹ VLambda I F ∈⇩∘ Vset α› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . then show "Q i ∈⇩∘ Vset α" if "i ∈⇩∘ set {0, 1⇩ℕ, 2⇩ℕ}" for i using that (*‹i ∈⇩∘ ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ}›*) vrange_VLambda (*‹ℛ⇩∘ (VLambda ?A ?f) = ZFC_in_HOL.set (?f ` elts ?A)›*) by (auto intro!: vrange_F_in_Vset (*‹ℛ⇩∘ (VLambda I F) ∈⇩∘ Vset α›*) simp: Q_def (*‹Q ?i = (if ?i = []⇩∘ ⇒ VPow (⋃⇩∘ (VLambda I F `⇩∘ I) ×⇩∘ ⋃⇩∘ (VLambda I F `⇩∘ I)) | otherwise ⇒ ZFC_in_HOL.set (F ` elts I))›*) nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) qed (auto) (*solves the remaining goals: 1. ‹Limit α› 2. ‹vfinite (ZFC_in_HOL.set {[]⇩∘, 1⇩ℕ, 2⇩ℕ})›*) ultimately show "ℛ⇩∘ (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈) ∈⇩∘ Vset α" by (meson vsubset_in_VsetI (*‹⟦?a ⊆⇩∘ ?A; ?A ∈⇩∘ Vset ?i⟧ ⟹ ?a ∈⇩∘ Vset ?i›*)) qed (auto) (*solves the remaining goals: 1. ‹vbrelation (λi∈⇩∘I. cat_Set α⦇CId⦈⦇F i⦈)› 2. ‹Limit α›*) fix i assume prems: "i ∈⇩∘ I" (*‹(i::V) ∈⇩∘ (I::V)›*) from assms (*‹VLambda (I::V) (F::V ⇒ V) ∈⇩∘ Vset (α::V)›*) have "ℛ⇩∘ (VLambda I F) ∈⇩∘ Vset α" by (auto simp: vrange_in_VsetI (*‹?r ∈⇩∘ Vset ?α ⟹ ℛ⇩∘ ?r ∈⇩∘ Vset ?α›*)) moreover from prems (*‹i ∈⇩∘ I›*) have "F i ∈⇩∘ ℛ⇩∘ (VLambda I F)" by auto ultimately show "F i ∈⇩∘ cat_Set α⦇Obj⦈" unfolding cat_Set_components (*goal: ‹F i ∈⇩∘ Vset α›*) by auto qed ((cs_concl cs_shallow cs_intro: cat_cs_intros assms)+) (*solves the remaining goals: 1. ‹category α (cat_Set α)› 2. ‹VLambda I F ∈⇩∘ Vset α›*) subsection‹Product cone and coproduct cocone for the category ‹Set›› subsubsection‹Definition and elementary properties› definition ntcf_Set_obj_prod :: "V ⇒ V ⇒ (V ⇒ V) ⇒ V" where "ntcf_Set_obj_prod α I F = ntcf_obj_prod_base (cat_Set α) I F (∏⇩∘i∈⇩∘I. F i) (λi. vprojection_arrow I F i)" definition ntcf_Set_obj_coprod :: "V ⇒ V ⇒ (V ⇒ V) ⇒ V" where "ntcf_Set_obj_coprod α I F = ntcf_obj_coprod_base (cat_Set α) I F (∐⇩∘i∈⇩∘I. F i) (λi. vcinjection_arrow I F i)" text‹Components.› lemma ntcf_Set_obj_prod_components: shows "ntcf_Set_obj_prod α I F⦇NTMap⦈ = (λi∈⇩∘:⇩C I⦇Obj⦈. vprojection_arrow I F i)" and "ntcf_Set_obj_prod α I F⦇NTDom⦈ = cf_const (:⇩C I) (cat_Set α) (∏⇩∘i∈⇩∘I. F i)" and "ntcf_Set_obj_prod α I F⦇NTCod⦈ = :→: I F (cat_Set α)" and "ntcf_Set_obj_prod α I F⦇NTDGDom⦈ = :⇩C I" and "ntcf_Set_obj_prod α I F⦇NTDGCod⦈ = cat_Set α" unfolding ntcf_Set_obj_prod_def ntcf_obj_prod_base_components (*goals: 1. ‹VLambda (:⇩C I⦇Obj⦈) (vprojection_arrow I F) = VLambda (:⇩C I⦇Obj⦈) (vprojection_arrow I F)› 2. ‹dghm_const (:⇩C I) (cat_Set α) (vproduct I F) (cat_Set α⦇CId⦈⦇vproduct I F⦈) = dghm_const (:⇩C I) (cat_Set α) (vproduct I F) (cat_Set α⦇CId⦈⦇vproduct I F⦈)› 3. ‹:→: I F (cat_Set α) = :→: I F (cat_Set α)› 4. ‹:⇩C I = :⇩C I› 5. ‹cat_Set α = cat_Set α›*) (*goals: 1. ‹VLambda (:⇩C I⦇Obj⦈) (vprojection_arrow I F) = VLambda (:⇩C I⦇Obj⦈) (vprojection_arrow I F)› 2. ‹dghm_const (:⇩C I) (cat_Set α) (vproduct I F) (cat_Set α⦇CId⦈⦇vproduct I F⦈) = dghm_const (:⇩C I) (cat_Set α) (vproduct I F) (cat_Set α⦇CId⦈⦇vproduct I F⦈)› 3. ‹:→: I F (cat_Set α) = :→: I F (cat_Set α)› 4. ‹:⇩C I = :⇩C I› 5. ‹cat_Set α = cat_Set α› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . lemma ntcf_Set_obj_coprod_components: shows "ntcf_Set_obj_coprod α I F⦇NTMap⦈ = (λi∈⇩∘:⇩C I⦇Obj⦈. vcinjection_arrow I F i)" and "ntcf_Set_obj_coprod α I F⦇NTDom⦈ = :→: I F (cat_Set α)" and "ntcf_Set_obj_coprod α I F⦇NTCod⦈ = cf_const (:⇩C I) (cat_Set α) (∐⇩∘i∈⇩∘I. F i)" and "ntcf_Set_obj_coprod α I F⦇NTDGDom⦈ = :⇩C I" and "ntcf_Set_obj_coprod α I F⦇NTDGCod⦈ = cat_Set α" unfolding ntcf_Set_obj_coprod_def ntcf_obj_coprod_base_components (*goals: 1. ‹VLambda (:⇩C I⦇Obj⦈) (vcinjection_arrow I F) = VLambda (:⇩C I⦇Obj⦈) (vcinjection_arrow I F)› 2. ‹:→: I F (cat_Set α) = :→: I F (cat_Set α)› 3. ‹dghm_const (:⇩C I) (cat_Set α) (VSigma I F) (cat_Set α⦇CId⦈⦇VSigma I F⦈) = dghm_const (:⇩C I) (cat_Set α) (VSigma I F) (cat_Set α⦇CId⦈⦇VSigma I F⦈)› 4. ‹:⇩C I = :⇩C I› 5. ‹cat_Set α = cat_Set α›*) (*goals: 1. ‹VLambda (:⇩C (I::V)⦇Obj⦈) (vcinjection_arrow I (F::V ⇒ V)) = VLambda (:⇩C I⦇Obj⦈) (vcinjection_arrow I F)› 2. ‹:→: (I::V) (F::V ⇒ V) (cat_Set (α::V)) = :→: I F (cat_Set α)› 3. ‹dghm_const (:⇩C (I::V)) (cat_Set (α::V)) (VSigma I (F::V ⇒ V)) (cat_Set α⦇CId⦈⦇VSigma I F⦈) = dghm_const (:⇩C I) (cat_Set α) (VSigma I F) (cat_Set α⦇CId⦈⦇VSigma I F⦈)› 4. ‹:⇩C (I::V) = :⇩C I› 5. ‹cat_Set (α::V) = cat_Set α› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . subsubsection‹Natural transformation map› mk_VLambda ntcf_Set_obj_prod_components(1) |vsv ntcf_Set_obj_prod_NTMap_vsv[cat_cs_intros]| |vdomain ntcf_Set_obj_prod_NTMap_vdomain[cat_cs_simps]| |app ntcf_Set_obj_prod_NTMap_app[cat_cs_simps]| mk_VLambda ntcf_Set_obj_coprod_components(1) |vsv ntcf_Set_obj_coprod_NTMap_vsv[cat_cs_intros]| |vdomain ntcf_Set_obj_coprod_NTMap_vdomain[cat_cs_simps]| |app ntcf_Set_obj_coprod_NTMap_app[cat_cs_simps]| subsubsection‹ Product cone for the category ‹Set› is a universal cone and product cocone for the category ‹Set› is a universal cocone › lemma (in 𝒵) tm_cf_discrete_ntcf_obj_prod_base_is_cat_obj_prod: ―‹See Theorem 5.2 in Chapter Introduction in \cite{hungerford_algebra_2003}.› assumes "VLambda I F ∈⇩∘ Vset α" shows "ntcf_Set_obj_prod α I F : (∏⇩∘i∈⇩∘I. F i) <⇩C⇩F⇩.⇩∏ F : I ↦↦⇩C⇘α⇙ cat_Set α" proof (intro is_cat_obj_prodI (*‹⟦?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ; cf_discrete ?α ?I ?A ?ℭ⟧ ⟹ ?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ›*) is_cat_limitI (*‹⟦?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ; ⋀u' r'. u' : r' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ∃!f'. f' : r' ↦⇘?ℭ⇙ ?r ∧ u' = ?u ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const ?𝔍 ?ℭ f'⟧ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α› 2. ‹⋀u' r'. u' : r' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α ⟹ ∃!f'. f' : r' ↦⇘cat_Set α⇙ vproduct I F ∧ u' = ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f'› 3. ‹cf_discrete α I F (cat_Set α)›*) interpret Set: tm_cf_discrete "α" I F "cat_Set α" by (rule tm_cf_discrete_cat_Set_if_VLambda_in_Vset[OF assms] (*‹tm_cf_discrete α I F (cat_Set α)›*)) let ?F = "ntcf_Set_obj_prod α I F" show "cf_discrete α I F (cat_Set α)" by (auto simp: cat_small_discrete_cs_intros (*‹cat_discrete ?α ?ℭ ⟹ category ?α ?ℭ› ‹vsv (:⇩C ?I⦇Dom⦈)› ‹vsv (:⇩C ?I⦇Cod⦈)› ‹vsv (:⇩C ?I⦇Comp⦈)› ‹vsv (:⇩C ?I⦇CId⦈)› ‹⟦?i ∈⇩∘ ?I; ?a = ?i; ?b = ?i⟧ ⟹ ?i : ?a ↦⇘:⇩C ?I⇙ ?b› ‹cf_discrete ?α ?I ?F ?ℭ ⟹ category ?α ?ℭ› ‹vsv (:→: ?I ?F ?ℭ⦇ObjMap⦈)› ‹vsv (:→: ?I ?F ?ℭ⦇ArrMap⦈)› ‹⟦cf_discrete ?α ?I ?F ?ℭ; ?𝔄' = :⇩C ?I; ?ℭ' = ?ℭ⟧ ⟹ :→: ?I ?F ?ℭ : ?𝔄' ↦↦⇩C⇘?α⇙ ?ℭ'› ‹tiny_cat_discrete ?α ?ℭ ⟹ cat_discrete ?α ?ℭ› ‹tiny_cat_discrete ?α ?ℭ ⟹ tiny_category ?α ?ℭ› and more 6 facts*)) show F_is_cat_cone: "?F : (∏⇩∘i∈⇩∘I. F i) <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" unfolding ntcf_Set_obj_prod_def (*goal: ‹ntcf_obj_prod_base (cat_Set α) I F (vproduct I F) (vprojection_arrow I F) : vproduct I F <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) proof (rule Set.tm_cf_discrete_ntcf_obj_prod_base_is_cat_cone (*‹⟦?P ∈⇩∘ cat_Set α⦇Obj⦈; ⋀a. a ∈⇩∘ I ⟹ ?f a : ?P ↦⇘cat_Set α⇙ F a⟧ ⟹ ntcf_obj_prod_base (cat_Set α) I F ?P ?f : ?P <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*)) (*goals: 1. ‹vproduct I F ∈⇩∘ cat_Set α⦇Obj⦈› 2. ‹⋀a. a ∈⇩∘ I ⟹ vprojection_arrow I F a : vproduct I F ↦⇘cat_Set α⇙ F a›*) show "(∏⇩∘i∈⇩∘I. F i) ∈⇩∘ cat_Set α⦇Obj⦈" unfolding cat_Set_components (*goal: ‹vproduct I F ∈⇩∘ Vset α›*) apply (intro Limit_vproduct_in_Vset_if_VLambda_in_VsetI (*‹⟦Limit ?α; VLambda ?I ?A ∈⇩∘ Vset ?α⟧ ⟹ vproduct ?I ?A ∈⇩∘ Vset ?α›*) Set.tm_cf_discrete_ObjMap_in_Vset (*‹VLambda I F ∈⇩∘ Vset α›*)) (*goal: ‹vproduct (I::V) (F::V ⇒ V) ∈⇩∘ Vset (α::V)›*) by auto qed (intro vprojection_arrow_is_arr (*‹⟦(?i::V) ∈⇩∘ (?I::V); VLambda ?I (?A::V ⇒ V) ∈⇩∘ Vset (α::V)⟧ ⟹ vprojection_arrow ?I ?A ?i : vproduct ?I ?A ↦⇘cat_Set α⇙ ?A ?i›*) Set.tm_cf_discrete_ObjMap_in_Vset (*‹VLambda (I::V) (F::V ⇒ V) ∈⇩∘ Vset (α::V)›*)) (*solved the remaining goal: ‹⋀a. a ∈⇩∘ I ⟹ vprojection_arrow I F a : vproduct I F ↦⇘cat_Set α⇙ F a›*) interpret F: is_cat_cone "α" "∏⇩∘i∈⇩∘I. F i" ":⇩C I" "cat_Set α" ":→: I F (cat_Set α)" "?F" by (rule F_is_cat_cone (*‹ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*)) fix π' and P' assume prems: "π' : P' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" (*‹(π'::V) : (P'::V) <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I (F::V ⇒ V) (cat_Set α) : :⇩C (I::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) let ?π'i = "λi. π'⦇NTMap⦈⦇i⦈" let ?up' = "cat_Set_obj_prod_up I F P' ?π'i" interpret π': is_cat_cone "α" P' ":⇩C I" "cat_Set α" ":→: I F (cat_Set α)" "π'" by (rule prems( (*‹(π'::V) : (P'::V) <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I (F::V ⇒ V) (cat_Set α) : :⇩C (I::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) 1)) show "∃!f'. f' : P' ↦⇘cat_Set α⇙ (∏⇩∘i∈⇩∘I. F i) ∧ π' = ?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f'" proof (intro ex1I (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ∃!x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); (elim conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*))?) (*goals: 1. ‹?a1 : P' ↦⇘cat_Set α⇙ vproduct I F› 2. ‹π' = ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?a1› 3. ‹⋀f'. ⟦f' : P' ↦⇘cat_Set α⇙ vproduct I F; π' = ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f'⟧ ⟹ f' = ?a1›*) show up': "?up' : P' ↦⇘cat_Set α⇙ (∏⇩∘i∈⇩∘I. F i)" proof (rule cat_Set_obj_prod_up_cat_Set_is_arr (*‹⟦?A ∈⇩∘ cat_Set α⦇Obj⦈; VLambda ?I ?F ∈⇩∘ Vset α; ⋀i. i ∈⇩∘ ?I ⟹ ?φ i : ?A ↦⇘cat_Set α⇙ ?F i⟧ ⟹ cat_Set_obj_prod_up ?I ?F ?A ?φ : ?A ↦⇘cat_Set α⇙ vproduct ?I ?F›*)) (*goals: 1. ‹P' ∈⇩∘ cat_Set α⦇Obj⦈› 2. ‹VLambda I F ∈⇩∘ Vset α› 3. ‹⋀i. i ∈⇩∘ I ⟹ π'⦇NTMap⦈⦇i⦈ : P' ↦⇘cat_Set α⇙ F i›*) show "P' ∈⇩∘ cat_Set α⦇Obj⦈" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 254 facts*) cat_lim_cs_intros (*‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹⟦?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔅 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔊 : ?𝔄 ↦↦⇩C⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅; ?𝔄' = ?𝔉 ∘⇩D⇩G⇩H⇩M ?𝔊⟧ ⟹ ?u ∘⇩T⇩D⇩G⇩H⇩M₋⇩D⇩G⇩H⇩M ?𝔊 : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔄' : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ cf_discrete ?α ?I ?A ?ℭ› ‹?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› and more 20 facts*)) fix i assume "i ∈⇩∘ I" (*‹(i::V) ∈⇩∘ (I::V)›*) then show "π'⦇NTMap⦈⦇i⦈ : P' ↦⇘cat_Set α⇙ F i" by (cs_concl cs_shallow cs_simp: the_cat_discrete_components(1) cat_cs_simps cat_discrete_cs_simps cs_intro: cat_cs_intros) qed (rule assms (*‹VLambda I F ∈⇩∘ Vset α›*)) (*solved the remaining goal: ‹VLambda I F ∈⇩∘ Vset α›*) then have P': "P' ∈⇩∘ cat_Set α⦇Obj⦈" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 254 facts*) cat_lim_cs_intros (*‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹⟦?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔅 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔊 : ?𝔄 ↦↦⇩C⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅; ?𝔄' = ?𝔉 ∘⇩D⇩G⇩H⇩M ?𝔊⟧ ⟹ ?u ∘⇩T⇩D⇩G⇩H⇩M₋⇩D⇩G⇩H⇩M ?𝔊 : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔄' : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ cf_discrete ?α ?I ?A ?ℭ› ‹?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› and more 20 facts*)) have "π'i_i": "?π'i i : P' ↦⇘cat_Set α⇙ F i" if "i ∈⇩∘ I" for i using "π'.ntcf_NTMap_is_arr"[unfolded the_cat_discrete_components ( 1 ), OF that] (*‹π'⦇NTMap⦈⦇i⦈ : dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈)⦇ObjMap⦈⦇i⦈ ↦⇘cat_Set α⇙ :→: I F (cat_Set α)⦇ObjMap⦈⦇i⦈›*) that (*‹(i::V) ∈⇩∘ (I::V)›*) by (cs_prems cs_shallow cs_simp: cat_cs_simps cat_discrete_cs_simps the_cat_discrete_components(1)) from cat_Set_obj_prod_up_cat_Set_is_arr[OF P' assms ( 1 ) π'i_i] (*‹(⋀i. i ∈⇩∘ I ⟹ i ∈⇩∘ I) ⟹ cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)) : P' ↦⇘cat_Set α⇙ vproduct I F›*) have "π'i": "cat_Set_obj_prod_up I F P' ?π'i : P' ↦⇘cat_Set α⇙ (∏⇩∘i∈⇩∘I. F i)" . show "π' = ?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?up'" proof (rule ntcf_eqI (*‹⟦?𝔑 : ?𝔉 ↦⇩C⇩F ?𝔊 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔑' : ?𝔉' ↦⇩C⇩F ?𝔊' : ?𝔄' ↦↦⇩C⇘?α⇙ ?𝔅'; ?𝔑⦇NTMap⦈ = ?𝔑'⦇NTMap⦈; ?𝔉 = ?𝔉'; ?𝔊 = ?𝔊'; ?𝔄 = ?𝔄'; ?𝔅 = ?𝔅'⟧ ⟹ ?𝔑 = ?𝔑'›*), rule π'.is_ntcf_axioms (*‹π' : dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈) ↦⇩C⇩F :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*)) (*goals: 1. ‹ntcf_Set_obj_prod α (I::V) (F::V ⇒ V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_prod_up I F (P'::V) (app ((π'::V)⦇NTMap⦈))) : (?𝔉'::V) ↦⇩C⇩F (?𝔊'::V) : (?𝔄'::V) ↦↦⇩C⇘α::V⇙ (?𝔅'::V)› 2. ‹(π'::V)⦇NTMap⦈ = (ntcf_Set_obj_prod (α::V) (I::V) (F::V ⇒ V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_prod_up I F (P'::V) (app (π'⦇NTMap⦈))))⦇NTMap⦈› 3. ‹dghm_const (:⇩C (I::V)) (cat_Set (α::V)) (P'::V) (cat_Set α⦇CId⦈⦇P'⦈) = (?𝔉'::V)› 4. ‹:→: (I::V) (F::V ⇒ V) (cat_Set (α::V)) = (?𝔊'::V)› 5. ‹:⇩C (I::V) = (?𝔄'::V)› 6. ‹cat_Set (α::V) = (?𝔅'::V)›*) from F_is_cat_cone (*‹ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) "π'i" (*‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)) : P' ↦⇘cat_Set α⇙ vproduct I F›*) show "?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?up' : cf_const (:⇩C I) (cat_Set α) P' ↦⇩C⇩F :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_intro: cat_cs_intros) have dom_lhs: "𝒟⇩∘ (π'⦇NTMap⦈) = :⇩C I⦇Obj⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps) from F_is_cat_cone (*‹ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩c⇩o⇩n⇩e :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) "π'i" (*‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)) : P' ↦⇘cat_Set α⇙ vproduct I F›*) have dom_rhs: "𝒟⇩∘ ((?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?up')⦇NTMap⦈) = :⇩C I⦇Obj⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) show "π'⦇NTMap⦈ = (?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?up')⦇NTMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ ((π'::V)⦇NTMap⦈) = :⇩C (I::V)⦇Obj⦈›*) dom_rhs (*‹𝒟⇩∘ ((ntcf_Set_obj_prod (α::V) (I::V) (F::V ⇒ V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_prod_up I F (P'::V) (app ((π'::V)⦇NTMap⦈))))⦇NTMap⦈) = :⇩C I⦇Obj⦈›*)) (*goals: 1. ‹vsv (π'⦇NTMap⦈)› 2. ‹vsv ((ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))))⦇NTMap⦈)› 3. ‹:⇩C I⦇Obj⦈ = :⇩C I⦇Obj⦈› 4. ‹⋀a. a ∈⇩∘ :⇩C I⦇Obj⦈ ⟹ π'⦇NTMap⦈⦇a⦈ = (ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))))⦇NTMap⦈⦇a⦈›*) fix i assume prems': "i ∈⇩∘ :⇩C I⦇Obj⦈" (*‹(i::V) ∈⇩∘ :⇩C (I::V)⦇Obj⦈›*) then have i: "i ∈⇩∘ I" unfolding the_cat_discrete_components (*goal: ‹i ∈⇩∘ I›*) by simp have [cat_cs_simps]: "vprojection_arrow I F i ∘⇩A⇘cat_Set α⇙ ?up' = π'⦇NTMap⦈⦇i⦈" apply (rule cat_Set_cf_comp_proj_obj_prod_up[ OF P' assms π'i_i i, symmetric (*‹(⋀i::V. i ∈⇩∘ (I::V) ⟹ i ∈⇩∘ I) ⟹ vprojection_arrow I (F::V ⇒ V) (i::V) ∘⇩A⇘cat_Set (α::V)⇙ cat_Set_obj_prod_up I F (P'::V) (app ((π'::V)⦇NTMap⦈)) = π'⦇NTMap⦈⦇i⦈›*) ]) (*goal: ‹vprojection_arrow I F i ∘⇩A⇘cat_Set α⇙ cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)) = π'⦇NTMap⦈⦇i⦈›*) by auto from "π'i" (*‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)) : P' ↦⇘cat_Set α⇙ vproduct I F›*) prems' (*‹i ∈⇩∘ :⇩C I⦇Obj⦈›*) show "π'⦇NTMap⦈⦇i⦈ = (?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?up')⦇NTMap⦈⦇i⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_Rel_cs_simps cs_intro: cat_cs_intros) qed (auto simp: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 254 facts*)) (*solves the remaining goals: 1. ‹vsv (π'⦇NTMap⦈)› 2. ‹vsv ((ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))))⦇NTMap⦈)› 3. ‹:⇩C I⦇Obj⦈ = :⇩C I⦇Obj⦈›*) qed (simp_all) (*solves the remaining goals: 1. ‹dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈) = dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈)› 2. ‹:→: I F (cat_Set α) = :→: I F (cat_Set α)› 3. ‹:⇩C I = :⇩C I› 4. ‹cat_Set α = cat_Set α›*) fix f' assume prems: "f' : P' ↦⇘cat_Set α⇙ (∏⇩∘i∈⇩∘I. F i)" "π' = ?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f'" (*‹(f'::V) : (P'::V) ↦⇘cat_Set (α::V)⇙ vproduct (I::V) (F::V ⇒ V)› ‹(π'::V) = ntcf_Set_obj_prod (α::V) (I::V) (F::V ⇒ V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (f'::V)›*) from prems(2) (*‹π' = ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f'›*) have "π'_eq_F_f'": "π'⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈ = (?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f')⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈" if "i ∈⇩∘ I" and "a ∈⇩∘ P'" for i and a by simp have [cat_Set_cs_simps]: "π'⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈ = f'⦇ArrVal⦈⦇a⦈⦇i⦈" if "i ∈⇩∘ I" and "a ∈⇩∘ P'" for i and a using "π'_eq_F_f'"[OF that] (*‹π'⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈ = (ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f')⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈›*) assms (*‹VLambda (I::V) (F::V ⇒ V) ∈⇩∘ Vset (α::V)›*) prems (*‹f' : P' ↦⇘cat_Set α⇙ vproduct I F› ‹π' = ntcf_Set_obj_prod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) f'›*) that (*‹i ∈⇩∘ I› ‹a ∈⇩∘ P'›*) vprojection_arrow_is_arr[OF that ( 1 ) assms] (*‹vprojection_arrow I F i : vproduct I F ↦⇘cat_Set α⇙ F i›*) by (cs_prems cs_shallow cs_simp: cat_Set_cs_simps cat_cs_simps vprojection_arrow_ArrVal_app the_cat_discrete_components(1) cs_intro: cat_Set_cs_intros cat_cs_intros) note f' = cat_Set_is_arrD[OF prems ( 1 )] (*‹arr_Set (α::V) (f'::V)› ‹f'⦇ArrDom⦈ = P'› ‹(f'::V)⦇ArrCod⦈ = vproduct (I::V) (F::V ⇒ V)›*) note up' = cat_Set_is_arrD[OF up'] (*‹arr_Set α (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)))› ‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈ = P'› ‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈ = vproduct I F›*) interpret f': arr_Set "α" f' by (rule f'( (*‹arr_Set α f'›*) 1)) interpret u': arr_Set "α" "(cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)))" by (rule up'( (*‹arr_Set α (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)))›*) 1)) show "f' = ?up'" proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α f'› 2. ‹arr_Set α (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)))› 3. ‹f'⦇ArrVal⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈› 4. ‹f'⦇ArrDom⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈› 5. ‹f'⦇ArrCod⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈›*) have dom_lhs: "𝒟⇩∘ (f'⦇ArrVal⦈) = P'" by (simp add: cat_Set_cs_simps (*‹arr_Set ?α ?T ⟹ 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈› ‹⟦arr_Set ?α ?F; ?F⦇ArrCod⦈ = ?A⟧ ⟹ id_Rel ?A ∘⇩R⇩e⇩l ?F = ?F› ‹⟦arr_Set ?α ?F; ?F⦇ArrDom⦈ = ?A⟧ ⟹ ?F ∘⇩R⇩e⇩l id_Rel ?A = ?F› ‹(?x ∈⇩∘ cat_Set ?α⦇Arr⦈) = arr_Set ?α ?x› ‹arr_Set ?α ?x ⟹ cat_Set ?α⦇Cod⦈⦇?x⦈ = ?x⦇ArrCod⦈› ‹⟦?S : ?b ↦⇘cat_Set ?α⇙ ?c; ?T : ?a ↦⇘cat_Set ?α⇙ ?b⟧ ⟹ ?S ∘⇩A⇘cat_Set ?α⇙ ?T = ?S ∘⇩R⇩e⇩l ?T› ‹𝒟⇩∘ (cat_Set ?α⦇Comp⦈) = composable_arrs (cat_Set ?α)› ‹?A ∈⇩∘ Vset ?α ⟹ cat_Set ?α⦇CId⦈⦇?A⦈ = id_Rel ?A› ‹?T : ?A ↦⇩i⇩s⇩o⇘cat_Set ?α⇙ ?B ⟹ ?T¯⇩C⇘cat_Set ?α⇙ = ?T¯⇩R⇩e⇩l› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrVal⦈ = ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrDom⦈ = 𝒟⇩∘ ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrCod⦈ = ?B› and more 47 facts*) f' (*‹arr_Set α f'› ‹f'⦇ArrDom⦈ = P'› ‹f'⦇ArrCod⦈ = vproduct I F›*)) have dom_rhs: "𝒟⇩∘ (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈) = P'" by (simp add: cat_Set_cs_simps (*‹arr_Set ?α ?T ⟹ 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈› ‹⟦arr_Set ?α ?F; ?F⦇ArrCod⦈ = ?A⟧ ⟹ id_Rel ?A ∘⇩R⇩e⇩l ?F = ?F› ‹⟦arr_Set ?α ?F; ?F⦇ArrDom⦈ = ?A⟧ ⟹ ?F ∘⇩R⇩e⇩l id_Rel ?A = ?F› ‹(?x ∈⇩∘ cat_Set ?α⦇Arr⦈) = arr_Set ?α ?x› ‹arr_Set ?α ?x ⟹ cat_Set ?α⦇Cod⦈⦇?x⦈ = ?x⦇ArrCod⦈› ‹⟦?S : ?b ↦⇘cat_Set ?α⇙ ?c; ?T : ?a ↦⇘cat_Set ?α⇙ ?b⟧ ⟹ ?S ∘⇩A⇘cat_Set ?α⇙ ?T = ?S ∘⇩R⇩e⇩l ?T› ‹𝒟⇩∘ (cat_Set ?α⦇Comp⦈) = composable_arrs (cat_Set ?α)› ‹?A ∈⇩∘ Vset ?α ⟹ cat_Set ?α⦇CId⦈⦇?A⦈ = id_Rel ?A› ‹?T : ?A ↦⇩i⇩s⇩o⇘cat_Set ?α⇙ ?B ⟹ ?T¯⇩C⇘cat_Set ?α⇙ = ?T¯⇩R⇩e⇩l› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrVal⦈ = ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrDom⦈ = 𝒟⇩∘ ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrCod⦈ = ?B› and more 47 facts*) up' (*‹arr_Set α (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)))› ‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈ = P'› ‹cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈ = vproduct I F›*)) show "f'⦇ArrVal⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (f'⦇ArrVal⦈) = P'›*) dom_rhs (*‹𝒟⇩∘ (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈) = P'›*)) (*goals: 1. ‹vsv (f'⦇ArrVal⦈)› 2. ‹vsv (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈)› 3. ‹P' = P'› 4. ‹⋀a. a ∈⇩∘ P' ⟹ f'⦇ArrVal⦈⦇a⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈›*) fix a assume prems': "a ∈⇩∘ P'" (*‹(a::V) ∈⇩∘ (P'::V)›*) from prems(1) (*‹f' : P' ↦⇘cat_Set α⇙ vproduct I F›*) prems' (*‹a ∈⇩∘ P'›*) have "f'⦇ArrVal⦈⦇a⦈ ∈⇩∘ (∏⇩∘i∈⇩∘I. F i)" by (cs_concl cs_shallow cs_intro: cat_Set_cs_intros) note f'a = vproductD[OF this] (*‹vsv (f'⦇ArrVal⦈⦇a⦈)› ‹𝒟⇩∘ ((f'::V)⦇ArrVal⦈⦇(a::V)⦈) = (I::V)› ‹∀i∈elts I. f'⦇ArrVal⦈⦇a⦈⦇i⦈ ∈⇩∘ F i›*) from prems' (*‹a ∈⇩∘ P'›*) have dom_rhs: "𝒟⇩∘ (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈) = I" by (cs_concl cs_shallow cs_simp: cat_Set_cs_simps) show "f'⦇ArrVal⦈⦇a⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold f'a (*‹vsv ((f'::V)⦇ArrVal⦈⦇(a::V)⦈)› ‹𝒟⇩∘ ((f'::V)⦇ArrVal⦈⦇(a::V)⦈) = (I::V)› ‹∀i::V∈elts (I::V). (f'::V)⦇ArrVal⦈⦇(a::V)⦈⦇i⦈ ∈⇩∘ (F::V ⇒ V) i›*) dom_rhs (*‹𝒟⇩∘ (cat_Set_obj_prod_up (I::V) (F::V ⇒ V) (P'::V) (app ((π'::V)⦇NTMap⦈))⦇ArrVal⦈⦇(a::V)⦈) = I›*)) (*goals: 1. ‹vsv (f'⦇ArrVal⦈⦇a⦈)› 2. ‹vsv (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈)› 3. ‹I = I› 4. ‹⋀aa. aa ∈⇩∘ I ⟹ f'⦇ArrVal⦈⦇a⦈⦇aa⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈⦇aa⦈›*) fix i assume "i ∈⇩∘ I" (*‹(i::V) ∈⇩∘ (I::V)›*) with prems' (*‹a ∈⇩∘ P'›*) show "f'⦇ArrVal⦈⦇a⦈⦇i⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈⦇i⦈" by (cs_concl cs_shallow cs_simp: cat_Set_cs_simps) qed (simp_all add: prems' f'a(1) cat_Set_obj_prod_up_ArrVal_app) (*solves the remaining goals: 1. ‹vsv (f'⦇ArrVal⦈⦇a⦈)› 2. ‹vsv (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈)› 3. ‹I = I›*) qed (auto) (*solves the remaining goals: 1. ‹vsv (f'⦇ArrVal⦈)› 2. ‹vsv (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈)› 3. ‹P' = P'›*) qed (simp_all add: cat_Set_obj_prod_up_components f' up'(1)) (*solves the remaining goals: 1. ‹arr_Set α f'› 2. ‹arr_Set α (cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈)))› 3. ‹f'⦇ArrDom⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈› 4. ‹f'⦇ArrCod⦈ = cat_Set_obj_prod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈›*) qed qed lemma (in 𝒵) tm_cf_discrete_ntcf_obj_prod_base_is_tm_cat_obj_prod: ―‹See Theorem 5.2 in Chapter Introduction in \cite{hungerford_algebra_2003}.› assumes "VLambda I F ∈⇩∘ Vset α" shows "ntcf_Set_obj_prod α I F : (∏⇩∘i∈⇩∘I. F i) <⇩C⇩F⇩.⇩t⇩m⇩.⇩∏ F : I ↦↦⇩C⇩.⇩t⇩m⇘α⇙ cat_Set α" proof (intro is_tm_cat_obj_prodI (*‹⟦?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ; tm_cf_discrete ?α ?I ?A ?ℭ⟧ ⟹ ?π : ?P <⇩C⇩F⇩.⇩t⇩m⇩.⇩∏ ?A : ?I ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩l⇩i⇩m :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α› 2. ‹tm_cf_discrete α I F (cat_Set α)›*) from assms (*‹VLambda I F ∈⇩∘ Vset α›*) show "tm_cf_discrete α I F (cat_Set α)" by (rule tm_cf_discrete_cat_Set_if_VLambda_in_Vset (*‹VLambda (?I::V) (?F::V ⇒ V) ∈⇩∘ Vset (α::V) ⟹ tm_cf_discrete α ?I ?F (cat_Set α)›*)) show "ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩l⇩i⇩m :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" by (rule is_cat_obj_prodD[ OF tm_cf_discrete_ntcf_obj_prod_base_is_cat_obj_prod[OF assms] (*‹ntcf_Set_obj_prod α I F : vproduct I F <⇩C⇩F⇩.⇩l⇩i⇩m :→: I F (cat_Set α) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α› ‹cf_discrete α I F (cat_Set α)›*) ]) qed lemma (in 𝒵) tm_cf_discrete_ntcf_obj_coprod_base_is_cat_obj_coprod: ―‹See Theorem 5.2 in Chapter Introduction in \cite{hungerford_algebra_2003}.› assumes "VLambda I F ∈⇩∘ Vset α" shows "ntcf_Set_obj_coprod α I F : F >⇩C⇩F⇩.⇩∐ (∐⇩∘i∈⇩∘I. F i) : I ↦↦⇩C⇘α⇙ cat_Set α" proof (intro is_cat_obj_coprodI (*‹⟦?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ; cf_discrete ?α ?I ?A ?ℭ⟧ ⟹ ?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ›*) is_cat_colimitI (*‹⟦?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ; ⋀u' r'. u' : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e r' : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ∃!f'. f' : ?r ↦⇘?ℭ⇙ r' ∧ u' = ntcf_const ?𝔍 ?ℭ f' ∙⇩N⇩T⇩S⇩M⇩C⇩F ?u⟧ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹ntcf_Set_obj_coprod α I F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α› 2. ‹⋀u' r'. u' : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e r' : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α ⟹ ∃!f'. f' : VSigma I F ↦⇘cat_Set α⇙ r' ∧ u' = ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F› 3. ‹cf_discrete α I F (cat_Set α)›*) interpret Set: tm_cf_discrete "α" I F "cat_Set α" by (rule tm_cf_discrete_cat_Set_if_VLambda_in_Vset[OF assms] (*‹tm_cf_discrete (α::V) (I::V) (F::V ⇒ V) (cat_Set α)›*)) let ?F = "ntcf_Set_obj_coprod α I F" show "cf_discrete α I F (cat_Set α)" by (auto simp: cat_small_discrete_cs_intros (*‹cat_discrete ?α ?ℭ ⟹ category ?α ?ℭ› ‹vsv (:⇩C ?I⦇Dom⦈)› ‹vsv (:⇩C ?I⦇Cod⦈)› ‹vsv (:⇩C ?I⦇Comp⦈)› ‹vsv (:⇩C ?I⦇CId⦈)› ‹⟦?i ∈⇩∘ ?I; ?a = ?i; ?b = ?i⟧ ⟹ ?i : ?a ↦⇘:⇩C ?I⇙ ?b› ‹cf_discrete ?α ?I ?F ?ℭ ⟹ category ?α ?ℭ› ‹vsv (:→: ?I ?F ?ℭ⦇ObjMap⦈)› ‹vsv (:→: ?I ?F ?ℭ⦇ArrMap⦈)› ‹⟦cf_discrete ?α ?I ?F ?ℭ; ?𝔄' = :⇩C ?I; ?ℭ' = ?ℭ⟧ ⟹ :→: ?I ?F ?ℭ : ?𝔄' ↦↦⇩C⇘?α⇙ ?ℭ'› ‹tiny_cat_discrete ?α ?ℭ ⟹ cat_discrete ?α ?ℭ› ‹tiny_cat_discrete ?α ?ℭ ⟹ tiny_category ?α ?ℭ› and more 6 facts*)) show F_is_cat_cocone: "?F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e (∐⇩∘i∈⇩∘I. F i) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" unfolding ntcf_Set_obj_coprod_def (*goal: ‹ntcf_obj_coprod_base (cat_Set α) I F (VSigma I F) (vcinjection_arrow I F) : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) proof (rule Set.tm_cf_discrete_ntcf_obj_coprod_base_is_cat_cocone (*‹⟦?P ∈⇩∘ cat_Set α⦇Obj⦈; ⋀a. a ∈⇩∘ I ⟹ ?f a : F a ↦⇘cat_Set α⇙ ?P⟧ ⟹ ntcf_obj_coprod_base (cat_Set α) I F ?P ?f : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?P : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*)) (*goals: 1. ‹VSigma (I::V) (F::V ⇒ V) ∈⇩∘ cat_Set (α::V)⦇Obj⦈› 2. ‹⋀a::V. a ∈⇩∘ (I::V) ⟹ vcinjection_arrow I F a : (F::V ⇒ V) a ↦⇘cat_Set (α::V)⇙ VSigma I F›*) show "(∐⇩∘i∈⇩∘I. F i) ∈⇩∘ cat_Set α⦇Obj⦈" unfolding cat_Set_components (*goal: ‹VSigma I F ∈⇩∘ Vset α›*) apply (intro Limit_vdunion_in_Vset_if_VLambda_in_VsetI (*‹⟦Limit (?α::V); VLambda (?I::V) (?A::V ⇒ V) ∈⇩∘ Vset ?α⟧ ⟹ VSigma ?I ?A ∈⇩∘ Vset ?α›*) Set.tm_cf_discrete_ObjMap_in_Vset (*‹VLambda (I::V) (F::V ⇒ V) ∈⇩∘ Vset (α::V)›*)) (*goal: ‹VSigma I F ∈⇩∘ Vset α›*) by auto qed (intro vcinjection_arrow_is_arr (*‹⟦?i ∈⇩∘ ?I; VLambda ?I ?A ∈⇩∘ Vset α⟧ ⟹ vcinjection_arrow ?I ?A ?i : ?A ?i ↦⇘cat_Set α⇙ VSigma ?I ?A›*) Set.tm_cf_discrete_ObjMap_in_Vset (*‹VLambda I F ∈⇩∘ Vset α›*)) (*solved the remaining goal: ‹⋀a. a ∈⇩∘ I ⟹ vcinjection_arrow I F a : F a ↦⇘cat_Set α⇙ VSigma I F›*) then interpret F: is_cat_cocone "α" "∐⇩∘i∈⇩∘I. F i" ":⇩C I" "cat_Set α" ":→: I F (cat_Set α)" "?F" . fix π' and P' assume prems: "π' : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e P' : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" (*‹(π'::V) : :→: I (F::V ⇒ V) (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e (P'::V) : :⇩C (I::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) let ?π'i = "λi. π'⦇NTMap⦈⦇i⦈" let ?up' = "cat_Set_obj_coprod_up I F P' ?π'i" interpret π': is_cat_cocone "α" P' ":⇩C I" "cat_Set α" ":→: I F (cat_Set α)" "π'" by (rule prems( (*‹π' : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e P' : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) 1)) show "∃!f'. f' : VSigma I F ↦⇘cat_Set α⇙ P' ∧ π' = ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩C⇩F ntcf_Set_obj_coprod α I F" proof (intro ex1I (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ∃!x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); (elim conjE (*‹⟦(?P::bool) ∧ (?Q::bool); ⟦?P; ?Q⟧ ⟹ ?R::bool⟧ ⟹ ?R›*))?) (*goals: 1. ‹(?a1::V) : VSigma (I::V) (F::V ⇒ V) ↦⇘cat_Set (α::V)⇙ (P'::V)› 2. ‹(π'::V) = ntcf_const (:⇩C (I::V)) (cat_Set (α::V)) (?a1::V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I (F::V ⇒ V)› 3. ‹⋀f'::V. ⟦f' : VSigma (I::V) (F::V ⇒ V) ↦⇘cat_Set (α::V)⇙ (P'::V); (π'::V) = ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F⟧ ⟹ f' = (?a1::V)›*) show up': "?up' : (∐⇩∘i∈⇩∘I. F i) ↦⇘cat_Set α⇙ P'" proof (rule cat_Set_obj_coprod_up_cat_Set_is_arr (*‹⟦?A ∈⇩∘ cat_Set α⦇Obj⦈; VLambda ?I ?F ∈⇩∘ Vset α; ⋀i. i ∈⇩∘ ?I ⟹ ?φ i : ?F i ↦⇘cat_Set α⇙ ?A⟧ ⟹ cat_Set_obj_coprod_up ?I ?F ?A ?φ : VSigma ?I ?F ↦⇘cat_Set α⇙ ?A›*)) (*goals: 1. ‹P' ∈⇩∘ cat_Set α⦇Obj⦈› 2. ‹VLambda I F ∈⇩∘ Vset α› 3. ‹⋀i. i ∈⇩∘ I ⟹ π'⦇NTMap⦈⦇i⦈ : F i ↦⇘cat_Set α⇙ P'›*) show "P' ∈⇩∘ cat_Set α⦇Obj⦈" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 254 facts*) cat_lim_cs_intros (*‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹⟦?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔅 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔊 : ?𝔄 ↦↦⇩C⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅; ?𝔄' = ?𝔉 ∘⇩D⇩G⇩H⇩M ?𝔊⟧ ⟹ ?u ∘⇩T⇩D⇩G⇩H⇩M₋⇩D⇩G⇩H⇩M ?𝔊 : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔄' : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ cf_discrete ?α ?I ?A ?ℭ› ‹?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› and more 20 facts*)) fix i assume "i ∈⇩∘ I" (*‹(i::V) ∈⇩∘ (I::V)›*) then show "π'⦇NTMap⦈⦇i⦈ : F i ↦⇘cat_Set α⇙ P'" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_discrete_cs_simps the_cat_discrete_components(1) cs_intro: cat_cs_intros) qed (rule assms (*‹VLambda I F ∈⇩∘ Vset α›*)) (*solved the remaining goal: ‹VLambda (I::V) (F::V ⇒ V) ∈⇩∘ Vset (α::V)›*) then have P': "P' ∈⇩∘ cat_Set α⦇Obj⦈" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 254 facts*) cat_lim_cs_intros (*‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹⟦?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔅 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔊 : ?𝔄 ↦↦⇩C⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅; ?𝔄' = ?𝔉 ∘⇩D⇩G⇩H⇩M ?𝔊⟧ ⟹ ?u ∘⇩T⇩D⇩G⇩H⇩M₋⇩D⇩G⇩H⇩M ?𝔊 : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔄' : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ cf_discrete ?α ?I ?A ?ℭ› ‹?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› and more 20 facts*)) have "π'i_i": "?π'i i : F i ↦⇘cat_Set α⇙ P'" if "i ∈⇩∘ I" for i using "π'.ntcf_NTMap_is_arr"[unfolded the_cat_discrete_components ( 1 ), OF that] (*‹π'⦇NTMap⦈⦇i⦈ : :→: I F (cat_Set α)⦇ObjMap⦈⦇i⦈ ↦⇘cat_Set α⇙ dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈)⦇ObjMap⦈⦇i⦈›*) that (*‹i ∈⇩∘ I›*) by (cs_prems cs_shallow cs_simp: cat_cs_simps cat_discrete_cs_simps the_cat_discrete_components(1)) from cat_Set_obj_coprod_up_cat_Set_is_arr[OF P' assms ( 1 ) π'i_i] (*‹(⋀i. i ∈⇩∘ I ⟹ i ∈⇩∘ I) ⟹ cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)) : VSigma I F ↦⇘cat_Set α⇙ P'›*) have "π'i": "?up' : (∐⇩∘i∈⇩∘I. F i) ↦⇘cat_Set α⇙ P'" . show "π' = ntcf_const (:⇩C I) (cat_Set α) ?up' ∙⇩N⇩T⇩C⇩F ?F" proof (rule ntcf_eqI (*‹⟦?𝔑 : ?𝔉 ↦⇩C⇩F ?𝔊 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔑' : ?𝔉' ↦⇩C⇩F ?𝔊' : ?𝔄' ↦↦⇩C⇘?α⇙ ?𝔅'; ?𝔑⦇NTMap⦈ = ?𝔑'⦇NTMap⦈; ?𝔉 = ?𝔉'; ?𝔊 = ?𝔊'; ?𝔄 = ?𝔄'; ?𝔅 = ?𝔅'⟧ ⟹ ?𝔑 = ?𝔑'›*), rule π'.is_ntcf_axioms (*‹π' : :→: I F (cat_Set α) ↦⇩C⇩F dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈) : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*)) (*goals: 1. ‹ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F : ?𝔉' ↦⇩C⇩F ?𝔊' : ?𝔄' ↦↦⇩C⇘α⇙ ?𝔅'› 2. ‹π'⦇NTMap⦈ = (ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈› 3. ‹:→: I F (cat_Set α) = ?𝔉'› 4. ‹dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈) = ?𝔊'› 5. ‹:⇩C I = ?𝔄'› 6. ‹cat_Set α = ?𝔅'›*) from F_is_cat_cocone (*‹ntcf_Set_obj_coprod α I F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) "π'i" (*‹cat_Set_obj_coprod_up I F P' (app ((π'::V)⦇NTMap⦈)) : VSigma (I::V) (F::V ⇒ V) ↦⇘cat_Set (α::V)⇙ (P'::V)›*) show "ntcf_const (:⇩C I) (cat_Set α) ?up' ∙⇩N⇩T⇩C⇩F ?F : :→: I F (cat_Set α) ↦⇩C⇩F cf_const (:⇩C I) (cat_Set α) P' : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_intro: cat_cs_intros) have dom_lhs: "𝒟⇩∘ (π'⦇NTMap⦈) = :⇩C I⦇Obj⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps) from F_is_cat_cocone (*‹ntcf_Set_obj_coprod α I F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α›*) "π'i" (*‹cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)) : VSigma I F ↦⇘cat_Set α⇙ P'›*) have dom_rhs: "𝒟⇩∘ ((?F ∙⇩N⇩T⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) ?up')⦇NTMap⦈) = :⇩C I⦇Obj⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) show "π'⦇NTMap⦈ = (ntcf_const (:⇩C I) (cat_Set α) ?up' ∙⇩N⇩T⇩C⇩F ?F)⦇NTMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (π'⦇NTMap⦈) = :⇩C I⦇Obj⦈›*) dom_rhs (*‹𝒟⇩∘ ((ntcf_Set_obj_coprod α I F ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))))⦇NTMap⦈) = :⇩C I⦇Obj⦈›*)) (*goals: 1. ‹vsv (π'⦇NTMap⦈)› 2. ‹vsv ((ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈)› 3. ‹:⇩C I⦇Obj⦈ = 𝒟⇩∘ ((ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈)› 4. ‹⋀a. a ∈⇩∘ :⇩C I⦇Obj⦈ ⟹ π'⦇NTMap⦈⦇a⦈ = (ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈⦇a⦈›*) fix i assume prems': "i ∈⇩∘ :⇩C I⦇Obj⦈" (*‹(i::V) ∈⇩∘ :⇩C (I::V)⦇Obj⦈›*) then have i: "i ∈⇩∘ I" unfolding the_cat_discrete_components (*goal: ‹i ∈⇩∘ I›*) by simp have [cat_cs_simps]: "?up' ∘⇩A⇘cat_Set α⇙ vcinjection_arrow I F i = π'⦇NTMap⦈⦇i⦈" by (simp add: cat_Set_cf_comp_coprod_up_vcia[ OF P' assms π'i_i i, symmetric (*‹(⋀i. i ∈⇩∘ I ⟹ i ∈⇩∘ I) ⟹ cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)) ∘⇩A⇘cat_Set α⇙ vcinjection_arrow I F i = π'⦇NTMap⦈⦇i⦈›*) ]) from "π'i" (*‹cat_Set_obj_coprod_up I F P' (app ((π'::V)⦇NTMap⦈)) : VSigma (I::V) (F::V ⇒ V) ↦⇘cat_Set (α::V)⇙ (P'::V)›*) prems' (*‹i ∈⇩∘ :⇩C I⦇Obj⦈›*) show "π'⦇NTMap⦈⦇i⦈ = (ntcf_const (:⇩C I) (cat_Set α) ?up' ∙⇩N⇩T⇩C⇩F ?F)⦇NTMap⦈⦇i⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_Rel_cs_simps cs_intro: cat_cs_intros) qed ((cs_concl cs_simp: cat_cs_simps cs_intro: V_cs_intros cat_cs_intros)+) (*solves the remaining goals: 1. ‹vsv (π'⦇NTMap⦈)› 2. ‹vsv ((ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈)› 3. ‹:⇩C I⦇Obj⦈ = 𝒟⇩∘ ((ntcf_const (:⇩C I) (cat_Set α) (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈)›*) qed (simp_all) (*solves the remaining goals: 1. ‹:→: I F (cat_Set α) = :→: I F (cat_Set α)› 2. ‹dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈) = dghm_const (:⇩C I) (cat_Set α) P' (cat_Set α⦇CId⦈⦇P'⦈)› 3. ‹:⇩C I = :⇩C I› 4. ‹cat_Set α = cat_Set α›*) fix f' assume prems: "f' : (∐⇩∘i∈⇩∘I. F i) ↦⇘cat_Set α⇙ P'" "π' = ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩C⇩F ?F" (*‹(f'::V) : VSigma (I::V) (F::V ⇒ V) ↦⇘cat_Set (α::V)⇙ (P'::V)› ‹(π'::V) = ntcf_const (:⇩C (I::V)) (cat_Set (α::V)) (f'::V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I (F::V ⇒ V)›*) from prems(2) (*‹π' = ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F›*) have "π'_eq_F_f'": "π'⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈ = (ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩C⇩F ?F)⦇NTMap⦈⦇i⦈⦇ArrVal⦈⦇a⦈" if "i ∈⇩∘ I" and "a ∈⇩∘ P'" for i and a by simp note f' = cat_Set_is_arrD[OF prems ( 1 )] (*‹arr_Set α f'› ‹f'⦇ArrDom⦈ = VSigma I F› ‹f'⦇ArrCod⦈ = P'›*) note up' = cat_Set_is_arrD[OF up'] (*‹arr_Set α (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)))› ‹cat_Set_obj_coprod_up (I::V) (F::V ⇒ V) (P'::V) (app ((π'::V)⦇NTMap⦈))⦇ArrDom⦈ = VSigma I F› ‹cat_Set_obj_coprod_up (I::V) (F::V ⇒ V) (P'::V) (app ((π'::V)⦇NTMap⦈))⦇ArrCod⦈ = P'›*) interpret f': arr_Set "α" f' by (rule f'( (*‹arr_Set α f'›*) 1)) interpret u': arr_Set "α" "(cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)))" by (rule up'( (*‹arr_Set α (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)))›*) 1)) show "f' = ?up'" proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α f'› 2. ‹arr_Set α (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)))› 3. ‹f'⦇ArrVal⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈› 4. ‹f'⦇ArrDom⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈› 5. ‹f'⦇ArrCod⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈›*) have dom_lhs: "𝒟⇩∘ (f'⦇ArrVal⦈) = (∐⇩∘i∈⇩∘I. F i)" by (simp add: cat_Set_cs_simps (*‹arr_Set ?α ?T ⟹ 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈› ‹⟦arr_Set ?α ?F; ?F⦇ArrCod⦈ = ?A⟧ ⟹ id_Rel ?A ∘⇩R⇩e⇩l ?F = ?F› ‹⟦arr_Set ?α ?F; ?F⦇ArrDom⦈ = ?A⟧ ⟹ ?F ∘⇩R⇩e⇩l id_Rel ?A = ?F› ‹(?x ∈⇩∘ cat_Set ?α⦇Arr⦈) = arr_Set ?α ?x› ‹arr_Set ?α ?x ⟹ cat_Set ?α⦇Cod⦈⦇?x⦈ = ?x⦇ArrCod⦈› ‹⟦?S : ?b ↦⇘cat_Set ?α⇙ ?c; ?T : ?a ↦⇘cat_Set ?α⇙ ?b⟧ ⟹ ?S ∘⇩A⇘cat_Set ?α⇙ ?T = ?S ∘⇩R⇩e⇩l ?T› ‹𝒟⇩∘ (cat_Set ?α⦇Comp⦈) = composable_arrs (cat_Set ?α)› ‹?A ∈⇩∘ Vset ?α ⟹ cat_Set ?α⦇CId⦈⦇?A⦈ = id_Rel ?A› ‹?T : ?A ↦⇩i⇩s⇩o⇘cat_Set ?α⇙ ?B ⟹ ?T¯⇩C⇘cat_Set ?α⇙ = ?T¯⇩R⇩e⇩l› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrVal⦈ = ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrDom⦈ = 𝒟⇩∘ ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrCod⦈ = ?B› and more 46 facts*) f' (*‹arr_Set α f'› ‹f'⦇ArrDom⦈ = VSigma I F› ‹f'⦇ArrCod⦈ = P'›*)) have dom_rhs: "𝒟⇩∘ (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈) = (∐⇩∘i∈⇩∘I. F i)" by (simp add: cat_Set_cs_simps (*‹arr_Set ?α ?T ⟹ 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈› ‹⟦arr_Set ?α ?F; ?F⦇ArrCod⦈ = ?A⟧ ⟹ id_Rel ?A ∘⇩R⇩e⇩l ?F = ?F› ‹⟦arr_Set ?α ?F; ?F⦇ArrDom⦈ = ?A⟧ ⟹ ?F ∘⇩R⇩e⇩l id_Rel ?A = ?F› ‹(?x ∈⇩∘ cat_Set ?α⦇Arr⦈) = arr_Set ?α ?x› ‹arr_Set ?α ?x ⟹ cat_Set ?α⦇Cod⦈⦇?x⦈ = ?x⦇ArrCod⦈› ‹⟦?S : ?b ↦⇘cat_Set ?α⇙ ?c; ?T : ?a ↦⇘cat_Set ?α⇙ ?b⟧ ⟹ ?S ∘⇩A⇘cat_Set ?α⇙ ?T = ?S ∘⇩R⇩e⇩l ?T› ‹𝒟⇩∘ (cat_Set ?α⦇Comp⦈) = composable_arrs (cat_Set ?α)› ‹?A ∈⇩∘ Vset ?α ⟹ cat_Set ?α⦇CId⦈⦇?A⦈ = id_Rel ?A› ‹?T : ?A ↦⇩i⇩s⇩o⇘cat_Set ?α⇙ ?B ⟹ ?T¯⇩C⇘cat_Set ?α⇙ = ?T¯⇩R⇩e⇩l› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrVal⦈ = ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrDom⦈ = 𝒟⇩∘ ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrCod⦈ = ?B› and more 46 facts*) up' (*‹arr_Set α (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)))› ‹cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈ = VSigma I F› ‹cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈ = P'›*)) show "f'⦇ArrVal⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv (?r::V); vsv (?s::V); 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a::V. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (f'⦇ArrVal⦈) = VSigma I F›*) dom_rhs (*‹𝒟⇩∘ (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈) = VSigma I F›*)) (*goals: 1. ‹vsv (f'⦇ArrVal⦈)› 2. ‹vsv (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈)› 3. ‹VSigma I F = VSigma I F› 4. ‹⋀a. a ∈⇩∘ VSigma I F ⟹ f'⦇ArrVal⦈⦇a⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇a⦈›*) fix ix assume prems': "ix ∈⇩∘ (∐⇩∘i∈⇩∘I. F i)" (*‹(ix::V) ∈⇩∘ VSigma (I::V) (F::V ⇒ V)›*) then obtain i and x where ix_def: "ix = ⟨i, x⟩" and i: "i ∈⇩∘ I" and x: "x ∈⇩∘ F i" (*goal: ‹(⋀i x. ⟦ix = ⟨i, x⟩; i ∈⇩∘ I; x ∈⇩∘ F i⟧ ⟹ thesis) ⟹ thesis›*) by auto from assms (*‹VLambda I F ∈⇩∘ Vset α›*) prems(1) (*‹f' : VSigma I F ↦⇘cat_Set α⇙ P'›*) prems' (*‹(ix::V) ∈⇩∘ VSigma (I::V) (F::V ⇒ V)›*) i (*‹i ∈⇩∘ I›*) x (*‹x ∈⇩∘ F i›*) show "f'⦇ArrVal⦈⦇ix⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈⦇ix⦈" unfolding ix_def prems(2) (*goal: ‹f'⦇ArrVal⦈⦇⟨i, x⟩⦈ = cat_Set_obj_coprod_up I F P' (app ((ntcf_const (:⇩C I) (cat_Set α) f' ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_Set_obj_coprod α I F)⦇NTMap⦈))⦇ArrVal⦈⦇⟨i, x⟩⦈›*) by (cs_concl cs_shallow cs_simp: cat_Set_cs_simps cat_cs_simps the_cat_discrete_components(1) cs_intro: cat_cs_intros) qed (auto) (*solves the remaining goals: 1. ‹vsv (f'⦇ArrVal⦈)› 2. ‹vsv (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrVal⦈)› 3. ‹VSigma I F = VSigma I F›*) qed (simp_all add: cat_Set_obj_coprod_up_components f' up'(1)) (*solves the remaining goals: 1. ‹arr_Set α f'› 2. ‹arr_Set α (cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈)))› 3. ‹f'⦇ArrDom⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrDom⦈› 4. ‹f'⦇ArrCod⦈ = cat_Set_obj_coprod_up I F P' (app (π'⦇NTMap⦈))⦇ArrCod⦈›*) qed qed lemma (in 𝒵) ntcf_Set_obj_coprod_is_tm_cat_obj_coprod: ―‹See Theorem 5.2 in Chapter Introduction in \cite{hungerford_algebra_2003}.› assumes "VLambda I F ∈⇩∘ Vset α" shows "ntcf_Set_obj_coprod α I F : F >⇩C⇩F⇩.⇩t⇩m⇩.⇩∐ (∐⇩∘i∈⇩∘I. F i) : I ↦↦⇩C⇩.⇩t⇩m⇘α⇙ cat_Set α" proof (intro is_tm_cat_obj_coprodI (*‹⟦(?π::V) : :→: ?I (?A::V ⇒ V) ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m (?U::V) : :⇩C (?I::V) ↦↦⇩C⇘?α::V⇙ (?ℭ::V); tm_cf_discrete ?α ?I ?A ?ℭ⟧ ⟹ ?π : ?A >⇩C⇩F⇩.⇩t⇩m⇩.⇩∐ ?U : ?I ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹ntcf_Set_obj_coprod α I F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α› 2. ‹tm_cf_discrete α I F (cat_Set α)›*) from assms (*‹VLambda I F ∈⇩∘ Vset α›*) show "tm_cf_discrete α I F (cat_Set α)" by (rule tm_cf_discrete_cat_Set_if_VLambda_in_Vset (*‹VLambda ?I ?F ∈⇩∘ Vset α ⟹ tm_cf_discrete α ?I ?F (cat_Set α)›*)) show "ntcf_Set_obj_coprod α I F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α" by (rule is_cat_obj_coprodD[ OF tm_cf_discrete_ntcf_obj_coprod_base_is_cat_obj_coprod[OF assms] (*‹ntcf_Set_obj_coprod α I F : :→: I F (cat_Set α) >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m VSigma I F : :⇩C I ↦↦⇩C⇘α⇙ cat_Set α› ‹cf_discrete α I F (cat_Set α)›*) ]) qed subsection‹Equalizer for the category ‹Set›› subsubsection‹Definition and elementary properties› abbreviation ntcf_Set_equalizer_map :: "V ⇒ V ⇒ V ⇒ V ⇒ V ⇒ V" where "ntcf_Set_equalizer_map α a g f i ≡ ( i = 𝔞⇩P⇩L₂ ? incl_Set (vequalizer a g f) a : g ∘⇩A⇘cat_Set α⇙ incl_Set (vequalizer a g f) a )" definition ntcf_Set_equalizer :: "V ⇒ V ⇒ V ⇒ V ⇒ V ⇒ V" where "ntcf_Set_equalizer α a b g f = ntcf_equalizer_base (cat_Set α) a b g f (vequalizer a g f) (ntcf_Set_equalizer_map α a g f)" text‹Components.› context fixes a g f α :: V begin lemmas ntcf_Set_equalizer_components = ntcf_equalizer_base_components[ where ℭ=‹cat_Set α› and e=‹ntcf_Set_equalizer_map α a g f› and E=‹vequalizer a g f› and 𝔞=a and 𝔤=g and 𝔣=f, folded ntcf_Set_equalizer_def ] end subsubsection‹Natural transformation map› mk_VLambda ntcf_Set_equalizer_components(1) |vsv ntcf_Set_equalizer_NTMap_vsv[cat_Set_cs_intros]| |vdomain ntcf_Set_equalizer_NTMap_vdomain[cat_Set_cs_simps]| |app ntcf_Set_equalizer_NTMap_app| lemma ntcf_Set_equalizer_2_NTMap_app_𝔞[cat_Set_cs_simps]: assumes "x = 𝔞⇩P⇩L₂" shows "ntcf_Set_equalizer α a b g f⦇NTMap⦈⦇x⦈ = incl_Set (vequalizer a g f) a" unfolding assms the_cat_parallel_2_components(1) ntcf_Set_equalizer_components (*goal: ‹(λx∈⇩∘ZFC_in_HOL.set {𝔞⇩P⇩L₂, 𝔟⇩P⇩L₂}. if x = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer a g f) a | otherwise ⇒ g ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer a g f) a)⦇𝔞⇩P⇩L₂⦈ = incl_Rel (vequalizer a g f) a›*) by simp lemma ntcf_Set_equalizer_2_NTMap_app_𝔟[cat_Set_cs_simps]: assumes "x = 𝔟⇩P⇩L₂" shows "ntcf_Set_equalizer α a b g f⦇NTMap⦈⦇x⦈ = g ∘⇩A⇘cat_Set α⇙ incl_Set (vequalizer a g f) a" unfolding assms the_cat_parallel_2_components(1) ntcf_Set_equalizer_components (*goal: ‹(λx∈⇩∘ZFC_in_HOL.set {𝔞⇩P⇩L₂, 𝔟⇩P⇩L₂}. if x = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer a g f) a | otherwise ⇒ g ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer a g f) a)⦇𝔟⇩P⇩L₂⦈ = g ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer a g f) a›*) using cat_PL2_ineq (*‹𝔞⇩P⇩L₂ ≠ 𝔟⇩P⇩L₂› ‹𝔞⇩P⇩L₂ ≠ 𝔤⇩P⇩L› ‹𝔞⇩P⇩L₂ ≠ 𝔣⇩P⇩L› ‹𝔟⇩P⇩L₂ ≠ 𝔤⇩P⇩L› ‹𝔟⇩P⇩L₂ ≠ 𝔣⇩P⇩L› ‹𝔤⇩P⇩L ≠ 𝔣⇩P⇩L›*) by auto subsubsection‹Equalizer for the category ‹Set› is an equalizer› lemma (in 𝒵) ntcf_Set_equalizer_2_is_cat_equalizer_2: assumes "𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟" and "𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟" shows "ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 : vequalizer 𝔞 𝔤 𝔣 <⇩C⇩F⇩.⇩e⇩q (𝔞,𝔟,𝔤,𝔣) : ↑↑⇩C ↦↦⇩C⇘α⇙ cat_Set α" proof (intro is_cat_equalizer_2I (*‹⟦?ε : ?E <⇩C⇩F⇩.⇩l⇩i⇩m ↑↑→↑↑⇩C⇩F ?ℭ 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ?𝔞 ?𝔟 ?𝔤 ?𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔤 : ?𝔞 ↦⇘?ℭ⇙ ?𝔟; ?𝔣 : ?𝔞 ↦⇘?ℭ⇙ ?𝔟⟧ ⟹ ?ε : ?E <⇩C⇩F⇩.⇩e⇩q (?𝔞,?𝔟,?𝔤,?𝔣) : ↑↑⇩C ↦↦⇩C⇘?α⇙ ?ℭ›*) is_cat_equalizerI (*‹⟦?ε : ?E <⇩C⇩F⇩.⇩l⇩i⇩m ⇑→⇑⇩C⇩F ?ℭ (𝔞⇩P⇩L ?F) (𝔟⇩P⇩L ?F) ?F ?𝔞 ?𝔟 ?F' : ⇑⇩C (𝔞⇩P⇩L ?F) (𝔟⇩P⇩L ?F) ?F ↦↦⇩C⇘?α⇙ ?ℭ; vsv ?F'; ?F ∈⇩∘ Vset ?α; ?F ≠ []⇩∘; 𝒟⇩∘ ?F' = ?F; ⋀𝔣. 𝔣 ∈⇩∘ ?F ⟹ ?F'⦇𝔣⦈ : ?𝔞 ↦⇘?ℭ⇙ ?𝔟⟧ ⟹ ?ε : ?E <⇩C⇩F⇩.⇩e⇩q (?𝔞,?𝔟,?F,?F') : ⇑⇩C ↦↦⇩C⇘?α⇙ ?ℭ›*) is_cat_limitI (*‹⟦?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ; ⋀u' r'. u' : r' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ∃!f'. f' : r' ↦⇘?ℭ⇙ ?r ∧ u' = ?u ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const ?𝔍 ?ℭ f'⟧ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ›*)) (*goals: 1. ‹ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 : vequalizer 𝔞 𝔤 𝔣 <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘α⇙ cat_Set α› 2. ‹⋀u' r'. u' : r' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘α⇙ cat_Set α ⟹ ∃!f'. f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣 ∧ u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) f'› 3. ‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› 4. ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) let ?II_II = "↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣" and ?II = "↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L" note "𝔤" = cat_Set_is_arrD[OF assms ( 1 )] (*‹arr_Set (α::V) (𝔤::V)› ‹𝔤⦇ArrDom⦈ = 𝔞› ‹𝔤⦇ArrCod⦈ = 𝔟›*) interpret 𝔤: arr_Set "α" "𝔤" rewrites "𝔤⦇ArrDom⦈ = 𝔞" and "𝔤⦇ArrCod⦈ = 𝔟" (*goals: 1. ‹arr_Set (α::V) (𝔤::V)› 2. ‹(𝔤::V)⦇ArrDom⦈ = (𝔞::V)› 3. ‹(𝔤::V)⦇ArrCod⦈ = (𝔟::V)› discuss goal 1*) apply (rule 𝔤( (*‹arr_Set (α::V) (𝔤::V)›*) 1)) (*discuss goal 2*) apply (simp add: 𝔤 (*‹arr_Set α 𝔤› ‹𝔤⦇ArrDom⦈ = 𝔞› ‹𝔤⦇ArrCod⦈ = 𝔟›*)) (*discuss goal 3*) apply (simp add: 𝔤 (*‹arr_Set α 𝔤› ‹𝔤⦇ArrDom⦈ = 𝔞› ‹𝔤⦇ArrCod⦈ = 𝔟›*)) (*proven 3 subgoals*) . note "𝔣" = cat_Set_is_arrD[OF assms ( 2 )] (*‹arr_Set (α::V) (𝔣::V)› ‹𝔣⦇ArrDom⦈ = 𝔞› ‹𝔣⦇ArrCod⦈ = 𝔟›*) interpret 𝔣: arr_Set "α" "𝔣" rewrites "𝔣⦇ArrDom⦈ = 𝔞" and "𝔣⦇ArrCod⦈ = 𝔟" (*goals: 1. ‹arr_Set α 𝔣› 2. ‹𝔣⦇ArrDom⦈ = 𝔞› 3. ‹𝔣⦇ArrCod⦈ = 𝔟› discuss goal 1*) apply (rule 𝔣( (*‹arr_Set α 𝔣›*) 1)) (*discuss goal 2*) apply (simp add: 𝔣 (*‹arr_Set α 𝔣› ‹𝔣⦇ArrDom⦈ = 𝔞› ‹𝔣⦇ArrCod⦈ = 𝔟›*)) (*discuss goal 3*) apply (simp add: 𝔣 (*‹arr_Set α 𝔣› ‹𝔣⦇ArrDom⦈ = 𝔞› ‹𝔣⦇ArrCod⦈ = 𝔟›*)) (*proven 3 subgoals*) . note [cat_Set_cs_intros] = "𝔤.arr_Set_ArrDom_in_Vset" (*‹𝔞 ∈⇩∘ Vset α›*) "𝔣.arr_Set_ArrCod_in_Vset" (*‹𝔟 ∈⇩∘ Vset α›*) let ?incl = "incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞" show "𝔞𝔟𝔤𝔣_is_cat_cone": "ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 : vequalizer 𝔞 𝔤 𝔣 <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?II_II : ?II ↦↦⇩C⇘α⇙ cat_Set α" unfolding ntcf_Set_equalizer_def (*goal: ‹ntcf_equalizer_base (cat_Set α) 𝔞 𝔟 𝔤 𝔣 (vequalizer 𝔞 𝔤 𝔣) (λi::V. if i = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞) : vequalizer (𝔞::V) (𝔤::V) (𝔣::V) <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 (𝔟::V) 𝔤 𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘α::V⇙ cat_Set α›*) proof (intro category.cat_ntcf_equalizer_base_is_cat_cone (*‹⟦category (?α::V) (?ℭ::V); (?e::V ⇒ V) 𝔞⇩P⇩L₂ : (?E::V) ↦⇘?ℭ⇙ (?𝔞::V); ?e 𝔟⇩P⇩L₂ : ?E ↦⇘?ℭ⇙ (?𝔟::V); ?e 𝔟⇩P⇩L₂ = (?𝔤::V) ∘⇩A⇘?ℭ⇙ ?e 𝔞⇩P⇩L₂; ?e 𝔟⇩P⇩L₂ = (?𝔣::V) ∘⇩A⇘?ℭ⇙ ?e 𝔞⇩P⇩L₂; ?𝔤 : ?𝔞 ↦⇘?ℭ⇙ ?𝔟; ?𝔣 : ?𝔞 ↦⇘?ℭ⇙ ?𝔟⟧ ⟹ ntcf_equalizer_base ?ℭ ?𝔞 ?𝔟 ?𝔤 ?𝔣 ?E ?e : ?E <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ↑↑→↑↑⇩C⇩F ?ℭ 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ?𝔞 ?𝔟 ?𝔤 ?𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘?α⇙ ?ℭ›*) category.cat_cf_parallel_2_cat_equalizer (*‹⟦category (?α::V) (?ℭ::V); (?𝔤::V) : (?𝔞::V) ↦⇘?ℭ⇙ (?𝔟::V); (?𝔣::V) : ?𝔞 ↦⇘?ℭ⇙ ?𝔟⟧ ⟹ cf_parallel_2 ?α 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ?𝔞 ?𝔟 ?𝔤 ?𝔣 ?ℭ›*)) (*goals: 1. ‹category (α::V) (cat_Set α)› 2. ‹(if 𝔞⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞) : vequalizer (𝔞::V) (𝔤::V) (𝔣::V) ↦⇘cat_Set (α::V)⇙ 𝔞› 3. ‹(if 𝔟⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞) : vequalizer (𝔞::V) (𝔤::V) (𝔣::V) ↦⇘cat_Set (α::V)⇙ (𝔟::V)› 4. ‹(if 𝔟⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer (𝔞::V) (𝔤::V) (𝔣::V)) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set (α::V)⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞) = 𝔤 ∘⇩A⇘cat_Set α⇙ (if 𝔞⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞)› 5. ‹(if 𝔟⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer (𝔞::V) (𝔤::V) (𝔣::V)) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set (α::V)⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞) = 𝔣 ∘⇩A⇘cat_Set α⇙ (if 𝔞⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞)› 6. ‹(𝔤::V) : (𝔞::V) ↦⇘cat_Set (α::V)⇙ (𝔟::V)› 7. ‹(𝔣::V) : (𝔞::V) ↦⇘cat_Set (α::V)⇙ (𝔟::V)›*) from assms (*‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) show "(𝔟⇩P⇩L₂ = 𝔞⇩P⇩L₂ ? ?incl : 𝔤 ∘⇩A⇘cat_Set α⇙ ?incl) : vequalizer 𝔞 𝔤 𝔣 ↦⇘cat_Set α⇙ 𝔟" by (cs_concl cs_simp: V_cs_simps cs_intro: V_cs_intros cat_Set_cs_intros cat_cs_intros cat_PL2_ineq[symmetric]) show "(𝔟⇩P⇩L₂ = 𝔞⇩P⇩L₂ ? ?incl : 𝔤 ∘⇩A⇘cat_Set α⇙ ?incl) = 𝔤 ∘⇩A⇘cat_Set α⇙ (𝔞⇩P⇩L₂ = 𝔞⇩P⇩L₂ ? ?incl : 𝔤 ∘⇩A⇘cat_Set α⇙ ?incl)" by (cs_concl cs_simp: V_cs_simps cs_intro: V_cs_intros cat_Set_cs_intros cat_cs_intros cat_PL2_ineq[symmetric]) from assms (*‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) show "(𝔟⇩P⇩L₂ = 𝔞⇩P⇩L₂ ? ?incl : 𝔤 ∘⇩A⇘cat_Set α⇙ ?incl) = 𝔣 ∘⇩A⇘cat_Set α⇙ (𝔞⇩P⇩L₂ = 𝔞⇩P⇩L₂ ? ?incl : 𝔤 ∘⇩A⇘cat_Set α⇙ ?incl)" by (cs_concl cs_simp: V_cs_simps cat_Set_incl_Set_commute cs_intro: V_cs_intros cat_PL2_ineq[symmetric]) qed ((cs_concl cs_intro: cat_cs_intros V_cs_intros cat_Set_cs_intros assms cs_simp: V_cs_simps cat_cs_simps cat_Set_components(1))+) (*solves the remaining goals: 1. ‹category α (cat_Set α)› 2. ‹(if 𝔞⇩P⇩L₂ = 𝔞⇩P⇩L₂ ⇒ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 | otherwise ⇒ 𝔤 ∘⇩A⇘cat_Set α⇙ incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞) : vequalizer 𝔞 𝔤 𝔣 ↦⇘cat_Set α⇙ 𝔞› 3. ‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› 4. ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) interpret 𝔞𝔟𝔤𝔣: is_cat_cone "α" "vequalizer 𝔞 𝔤 𝔣" "?II" "cat_Set α" "?II_II" "ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣" by (rule 𝔞𝔟𝔤𝔣_is_cat_cone (*‹ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 : vequalizer (𝔞::V) (𝔤::V) (𝔣::V) <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 (𝔟::V) 𝔤 𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘α::V⇙ cat_Set α›*)) show "∃!f'. f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣 ∧ u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) f'" if "u' : r' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?II_II : ?II ↦↦⇩C⇘α⇙ cat_Set α" for u' and r' proof (-) (*goal: ‹∃!f'. f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣 ∧ u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) f'›*) interpret u': is_cat_cone "α" r' "?II" "cat_Set α" "?II_II" u' by (rule that( (*‹u' : r' <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣 : ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L ↦↦⇩C⇘α⇙ cat_Set α›*) 1)) have "𝔞⇩P⇩L₂ ∈⇩∘ ?II⦇Obj⦈" unfolding the_cat_parallel_2_components(1) (*goal: ‹𝔞⇩P⇩L₂ ∈⇩∘ ZFC_in_HOL.set {𝔞⇩P⇩L₂, 𝔟⇩P⇩L₂}›*) by simp from u'.ntcf_NTMap_is_arr[OF this] (*‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : dghm_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) (r'::V) (cat_Set α⦇CId⦈⦇r'⦈)⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈ ↦⇘cat_Set (α::V)⇙ ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L (𝔞::V) (𝔟::V) (𝔤::V) (𝔣::V)⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈›*) "𝔞𝔟𝔤𝔣.NTDom.HomCod.cat_cf_parallel_2_cat_equalizer"[OF assms] (*‹cf_parallel_2 (α::V) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L (𝔞::V) (𝔟::V) (𝔤::V) (𝔣::V) (cat_Set α)›*) have "u'_𝔞⇩P⇩L_is_arr": "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ 𝔞" apply - (*goal: ‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ 𝔞›*) apply ((cs_prems_atom_step cat_cs_simps)[1]) (*goals: 1. ‹⟦u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : dghm_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) r' (cat_Set α⦇CId⦈⦇r'⦈)⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈ ↦⇘cat_Set α⇙ ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈; cf_parallel_2 α 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣 (cat_Set α)⟧ ⟹ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : dghm_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) r' (cat_Set α⦇CId⦈⦇r'⦈)⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈ ↦⇘cat_Set α⇙ ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈› 2. ‹⟦u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : dghm_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) r' (cat_Set α⦇CId⦈⦇r'⦈)⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈ ↦⇘cat_Set α⇙ ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈; cf_parallel_2 α 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣 (cat_Set α)⟧ ⟹ 𝔞⇩P⇩L₂ ∈⇩∘ ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈› 3. ‹⟦u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣⦇ObjMap⦈⦇𝔞⇩P⇩L₂⦈; cf_parallel_2 α 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣 (cat_Set α)⟧ ⟹ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ 𝔞› discuss goal 1*) apply ((msorry)[1]) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . note "u'_𝔞⇩P⇩L" = cat_Set_is_arrD[OF u'_𝔞⇩P⇩L_is_arr] (*‹arr_Set α (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)› ‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrDom⦈ = (r'::V)› ‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrCod⦈ = (𝔞::V)›*) interpret u'_𝔞⇩P⇩L: arr_Set "α" "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈" by (rule u'_𝔞⇩P⇩L( (*‹arr_Set α (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)›*) 1)) have "𝔟⇩P⇩L₂ ∈⇩∘ ?II⦇Obj⦈" by (cs_concl cs_shallow cs_intro: cat_parallel_cs_intros) from u'.ntcf_NTMap_is_arr[OF this] (*‹(u'::V)⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ : dghm_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) (r'::V) (cat_Set α⦇CId⦈⦇r'⦈)⦇ObjMap⦈⦇𝔟⇩P⇩L₂⦈ ↦⇘cat_Set (α::V)⇙ ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L (𝔞::V) (𝔟::V) (𝔤::V) (𝔣::V)⦇ObjMap⦈⦇𝔟⇩P⇩L₂⦈›*) "𝔞𝔟𝔤𝔣.NTDom.HomCod.cat_cf_parallel_2_cat_equalizer"[OF assms] (*‹cf_parallel_2 (α::V) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L (𝔞::V) (𝔟::V) (𝔤::V) (𝔣::V) (cat_Set α)›*) have "u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ 𝔟" by (cs_prems cs_shallow cs_simp: cat_cs_simps cat_parallel_cs_simps cs_intro: cat_parallel_cs_intros) note "u'_𝔤u'" = cat_cone_cf_par_2_eps_NTMap_app(1)[OF that ( 1 ) assms] (*‹u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ = 𝔤 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈›*) define q where "q = [u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘" have q_components[cat_Set_cs_simps]: "q⦇ArrVal⦈ = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈" "q⦇ArrDom⦈ = r'" "q⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣" unfolding q_def arr_field_simps (*goals: 1. ‹[u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘⦇[]⇩∘⦈ = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈› 2. ‹[u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘⦇1⇩ℕ⦈ = r'› 3. ‹[u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘⦇2⇩ℕ⦈ = vequalizer 𝔞 𝔤 𝔣›*) (*goals: 1. ‹[u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘⦇[]⇩∘⦈ = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈› 2. ‹[u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘⦇1⇩ℕ⦈ = r'› 3. ‹[u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇[]⇩∘⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘⦇2⇩ℕ⦈ = vequalizer 𝔞 𝔤 𝔣› discuss goal 1*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 2*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 3*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*proven 3 subgoals*) . from cat_cone_cf_par_2_eps_NTMap_app[OF that ( 1 ) assms] (*‹u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ = 𝔤 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈› ‹u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ = 𝔣 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈›*) have "𝔤u'_eq_𝔣u'": "(𝔤 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)⦇ArrVal⦈⦇x⦈ = (𝔣 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)⦇ArrVal⦈⦇x⦈" for x by simp show "?thesis" (*goal: ‹∃!f'. f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣 ∧ u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) f'›*) proof (intro ex1I (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ∃!x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*); (elim conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*))?) (*goals: 1. ‹(?a1::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)› 2. ‹(u'::V) = ntcf_Set_equalizer (α::V) (𝔞::V) (𝔟::V) (𝔤::V) (𝔣::V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) (?a1::V)› 3. ‹⋀f'::V. ⟦f' : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V); (u'::V) = ntcf_Set_equalizer α 𝔞 (𝔟::V) 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) f'⟧ ⟹ f' = (?a1::V)›*) have u'_NTMap_vrange: "ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ vequalizer 𝔞 𝔤 𝔣" proof (rule vsubsetI (*‹(⋀x. x ∈⇩∘ ?A ⟹ x ∈⇩∘ ?B) ⟹ ?A ⊆⇩∘ ?B›*)) (*goal: ‹⋀x. x ∈⇩∘ ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⟹ x ∈⇩∘ vequalizer 𝔞 𝔤 𝔣›*) fix y assume prems: "y ∈⇩∘ ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)" (*‹(y::V) ∈⇩∘ ℛ⇩∘ ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)›*) then obtain x where x: "x ∈⇩∘ 𝒟⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)" and y_def: "y = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇x⦈" (*goal: ‹(⋀x. ⟦x ∈⇩∘ 𝒟⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈); y = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇x⦈⟧ ⟹ thesis) ⟹ thesis›*) by (blast dest: u'_𝔞⇩P⇩L.ArrVal.vrange_atD (*‹(?b::V) ∈⇩∘ ℛ⇩∘ ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⟹ ∃a::V∈elts (𝒟⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)). u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇a⦈ = ?b›*)) have x: "x ∈⇩∘ r'" by (use x u'_𝔞⇩P⇩L_is_arr in ‹cs_prems cs_shallow cs_simp: cat_cs_simps›) from "𝔤u'_eq_𝔣u'"[of x] (*‹(𝔤 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)⦇ArrVal⦈⦇x⦈ = (𝔣 ∘⇩A⇘cat_Set α⇙ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)⦇ArrVal⦈⦇x⦈›*) assms (*‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) x (*‹x ∈⇩∘ r'›*) "u'_𝔞⇩P⇩L_is_arr" (*‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ 𝔞›*) have [simp]: "𝔤⦇ArrVal⦈⦇u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇x⦈⦈ = 𝔣⦇ArrVal⦈⦇u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇x⦈⦈" by (cs_prems cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) from prems (*‹y ∈⇩∘ ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)›*) "u'_𝔞⇩P⇩L.arr_Set_ArrVal_vrange"[unfolded u'_𝔞⇩P⇩L] (*‹ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ 𝔞›*) show "y ∈⇩∘ vequalizer 𝔞 𝔤 𝔣" apply (intro vequalizerI (*‹⟦?x ∈⇩∘ ?X; ?f⦇ArrVal⦈⦇?x⦈ = ?g⦇ArrVal⦈⦇?x⦈⟧ ⟹ ?x ∈⇩∘ vequalizer ?X ?f ?g›*)) (*goals: 1. ‹⟦(y::V) ∈⇩∘ ℛ⇩∘ ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈); ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ (𝔞::V)⟧ ⟹ y ∈⇩∘ 𝔞› 2. ‹⟦(y::V) ∈⇩∘ ℛ⇩∘ ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈); ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ (𝔞::V)⟧ ⟹ (𝔤::V)⦇ArrVal⦈⦇y⦈ = (𝔣::V)⦇ArrVal⦈⦇y⦈› discuss goal 1*) apply ((unfold y_def (*‹y = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇x⦈›*))[1]) (*top goal: ‹⟦y ∈⇩∘ ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈); ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ 𝔞⟧ ⟹ y ∈⇩∘ 𝔞› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((unfold y_def (*‹(y::V) = (u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇(x::V)⦈›*))[1]) (*goal: ‹⟦y ∈⇩∘ ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈); ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ 𝔞⟧ ⟹ 𝔤⦇ArrVal⦈⦇y⦈ = 𝔣⦇ArrVal⦈⦇y⦈›*) apply ((auto)[1]) (*proven 2 subgoals*) . qed show q_is_arr: "q : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣" proof (intro cat_Set_is_arrI (*‹⟦arr_Set (?α::V) (?S::V); ?S⦇ArrDom⦈ = (?A::V); ?S⦇ArrCod⦈ = (?B::V)⟧ ⟹ ?S : ?A ↦⇘cat_Set ?α⇙ ?B›*) arr_SetI (*‹⟦𝒵 (?α::V); vfsequence (?T::V); vsv (?T⦇ArrVal⦈); vcard ?T = (3::nat)⇩ℕ; 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈; ℛ⇩∘ (?T⦇ArrVal⦈) ⊆⇩∘ ?T⦇ArrCod⦈; ?T⦇ArrDom⦈ ∈⇩∘ Vset ?α; ?T⦇ArrCod⦈ ∈⇩∘ Vset ?α⟧ ⟹ arr_Set ?α ?T›*)) (*goals: 1. ‹𝒵 α› 2. ‹vfsequence q› 3. ‹vsv (q⦇ArrVal⦈)› 4. ‹vcard q = 3⇩ℕ› 5. ‹𝒟⇩∘ (q⦇ArrVal⦈) = q⦇ArrDom⦈› 6. ‹ℛ⇩∘ (q⦇ArrVal⦈) ⊆⇩∘ q⦇ArrCod⦈› 7. ‹q⦇ArrDom⦈ ∈⇩∘ Vset α› 8. ‹q⦇ArrCod⦈ ∈⇩∘ Vset α› 9. ‹q⦇ArrDom⦈ = r'› 10. ‹q⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣›*) show "q⦇ArrCod⦈ ∈⇩∘ Vset α" by (auto simp: q_components (*‹q⦇ArrVal⦈ = u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈› ‹q⦇ArrDom⦈ = r'› ‹q⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣›*) intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 263 facts*) cat_lim_cs_intros (*‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹⟦?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔅 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔊 : ?𝔄 ↦↦⇩C⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅; ?𝔄' = ?𝔉 ∘⇩D⇩G⇩H⇩M ?𝔊⟧ ⟹ ?u ∘⇩T⇩D⇩G⇩H⇩M₋⇩D⇩G⇩H⇩M ?𝔊 : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔄' : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ cf_discrete ?α ?I ?A ?ℭ› ‹?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› and more 20 facts*)) qed (auto simp: cat_Set_cs_simps (*‹arr_Set ?α ?T ⟹ 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈› ‹⟦arr_Set ?α ?F; ?F⦇ArrCod⦈ = ?A⟧ ⟹ id_Rel ?A ∘⇩R⇩e⇩l ?F = ?F› ‹⟦arr_Set ?α ?F; ?F⦇ArrDom⦈ = ?A⟧ ⟹ ?F ∘⇩R⇩e⇩l id_Rel ?A = ?F› ‹(?x ∈⇩∘ cat_Set ?α⦇Arr⦈) = arr_Set ?α ?x› ‹arr_Set ?α ?x ⟹ cat_Set ?α⦇Cod⦈⦇?x⦈ = ?x⦇ArrCod⦈› ‹⟦?S : ?b ↦⇘cat_Set ?α⇙ ?c; ?T : ?a ↦⇘cat_Set ?α⇙ ?b⟧ ⟹ ?S ∘⇩A⇘cat_Set ?α⇙ ?T = ?S ∘⇩R⇩e⇩l ?T› ‹𝒟⇩∘ (cat_Set ?α⦇Comp⦈) = composable_arrs (cat_Set ?α)› ‹?A ∈⇩∘ Vset ?α ⟹ cat_Set ?α⦇CId⦈⦇?A⦈ = id_Rel ?A› ‹?T : ?A ↦⇩i⇩s⇩o⇘cat_Set ?α⇙ ?B ⟹ ?T¯⇩C⇘cat_Set ?α⇙ = ?T¯⇩R⇩e⇩l› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrVal⦈ = ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrDom⦈ = 𝒟⇩∘ ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrCod⦈ = ?B› and more 55 facts*) nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*) u'_𝔞⇩P⇩L (*‹arr_Set α (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)› ‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrDom⦈ = r'› ‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrCod⦈ = 𝔞›*) q_def (*‹q = [u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈, r', vequalizer 𝔞 𝔤 𝔣]⇩∘›*) u'_NTMap_vrange (*‹ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ vequalizer 𝔞 𝔤 𝔣›*) 𝔞𝔟𝔤𝔣.NTDom.HomCod.cat_in_Obj_in_Vset (*‹?a ∈⇩∘ cat_Set α⦇Obj⦈ ⟹ ?a ∈⇩∘ Vset α›*) intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 263 facts*) cat_lim_cs_intros (*‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹⟦?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔅 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔊 : ?𝔄 ↦↦⇩C⇩.⇩i⇩s⇩o⇘?α⇙ ?𝔅; ?𝔄' = ?𝔉 ∘⇩D⇩G⇩H⇩M ?𝔊⟧ ⟹ ?u ∘⇩T⇩D⇩G⇩H⇩M₋⇩D⇩G⇩H⇩M ?𝔊 : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔄' : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩n⇩e ?𝔉 : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩t⇩m⇩.⇩c⇩o⇩c⇩o⇩n⇩e ?r : ?𝔍 ↦↦⇩C⇩.⇩t⇩m⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?r <⇩C⇩F⇩.⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?𝔉 : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ› ‹?u : ?𝔉 >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m⇩.⇩f⇩i⇩n ?r : ?𝔍 ↦↦⇩C⇘?α⇙ ?ℭ ⟹ finite_category ?α ?𝔍› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : ?P <⇩C⇩F⇩.⇩l⇩i⇩m :→: ?I ?A ?ℭ : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› ‹?π : ?P <⇩C⇩F⇩.⇩∏ ?A : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ cf_discrete ?α ?I ?A ?ℭ› ‹?π : ?A >⇩C⇩F⇩.⇩∐ ?U : ?I ↦↦⇩C⇘?α⇙ ?ℭ ⟹ ?π : :→: ?I ?A ?ℭ >⇩C⇩F⇩.⇩c⇩o⇩l⇩i⇩m ?U : :⇩C ?I ↦↦⇩C⇘?α⇙ ?ℭ› and more 20 facts*)) (*solves the remaining goals: 1. ‹𝒵 α› 2. ‹vfsequence q› 3. ‹vsv (q⦇ArrVal⦈)› 4. ‹vcard q = 3⇩ℕ› 5. ‹𝒟⇩∘ (q⦇ArrVal⦈) = q⦇ArrDom⦈› 6. ‹ℛ⇩∘ (q⦇ArrVal⦈) ⊆⇩∘ q⦇ArrCod⦈› 7. ‹q⦇ArrDom⦈ ∈⇩∘ Vset α› 8. ‹q⦇ArrDom⦈ = r'› 9. ‹q⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣›*) from q_is_arr (*‹(q::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)›*) have "𝔞_q": "incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q : r' ↦⇘cat_Set α⇙ 𝔞" by (cs_concl cs_simp: cat_cs_simps cat_Set_components(1) cs_intro: V_cs_intros cat_cs_intros cat_Set_cs_intros) interpret arr_Set "α" "incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q" using "𝔞_q" (*‹incl_Rel (vequalizer 𝔞 (𝔤::V) (𝔣::V)) 𝔞 ∘⇩A⇘cat_Set α⇙ (q::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ (𝔞::V)›*) by (auto dest: cat_Set_is_arrD (*‹(?S::V) : (?A::V) ↦⇘cat_Set (?α::V)⇙ (?B::V) ⟹ arr_Set ?α ?S› ‹(?S::V) : (?A::V) ↦⇘cat_Set (?α::V)⇙ (?B::V) ⟹ ?S⦇ArrDom⦈ = ?A› ‹(?S::V) : (?A::V) ↦⇘cat_Set (?α::V)⇙ (?B::V) ⟹ ?S⦇ArrCod⦈ = ?B›*)) show "u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q" proof (rule ntcf_eqI (*‹⟦?𝔑 : ?𝔉 ↦⇩C⇩F ?𝔊 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔑' : ?𝔉' ↦⇩C⇩F ?𝔊' : ?𝔄' ↦↦⇩C⇘?α⇙ ?𝔅'; ?𝔑⦇NTMap⦈ = ?𝔑'⦇NTMap⦈; ?𝔉 = ?𝔉'; ?𝔊 = ?𝔊'; ?𝔄 = ?𝔄'; ?𝔅 = ?𝔅'⟧ ⟹ ?𝔑 = ?𝔑'›*)) (*goals: 1. ‹u' : ?𝔉 ↦⇩C⇩F ?𝔊 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅› 2. ‹ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q : ?𝔉' ↦⇩C⇩F ?𝔊' : ?𝔄' ↦↦⇩C⇘?α⇙ ?𝔅'› 3. ‹u'⦇NTMap⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈› 4. ‹?𝔉 = ?𝔉'› 5. ‹?𝔊 = ?𝔊'› 6. ‹?𝔄 = ?𝔄'› 7. ‹?𝔅 = ?𝔅'›*) from q_is_arr (*‹(q::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)›*) show "ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q : cf_const ?II (cat_Set α) r' ↦⇩C⇩F ?II_II : ?II ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) have dom_lhs: "𝒟⇩∘ (u'⦇NTMap⦈) = ?II⦇Obj⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps) from q_is_arr (*‹q : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣›*) have dom_rhs: "𝒟⇩∘ ( (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q )⦇NTMap⦈) = ?II⦇Obj⦈" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) show "u'⦇NTMap⦈ = ( ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q )⦇NTMap⦈" proof (rule vsv_eqI (*‹⟦vsv (?r::V); vsv (?s::V); 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a::V. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (u'⦇NTMap⦈) = ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈›*) dom_rhs (*‹𝒟⇩∘ ((ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈) = ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈›*)) (*goals: 1. ‹vsv (u'⦇NTMap⦈)› 2. ‹vsv ((ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈)› 3. ‹↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈ = ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈› 4. ‹⋀a. a ∈⇩∘ ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈ ⟹ u'⦇NTMap⦈⦇a⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇a⦈›*) show "vsv (( ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q )⦇NTMap⦈)" by (cs_concl cs_intro: cat_cs_intros) fix a assume prems: "a ∈⇩∘ ?II⦇Obj⦈" (*‹(a::V) ∈⇩∘ ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈›*) have [symmetric, cat_Set_cs_simps]: "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q" proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)› 2. ‹arr_Set α (incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)› 3. ‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈ = (incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈› 4. ‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrDom⦈ = (incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrDom⦈› 5. ‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrCod⦈ = (incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrCod⦈›*) from "u'_𝔞⇩P⇩L_is_arr" (*‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : r' ↦⇘cat_Set α⇙ 𝔞›*) have dom_lhs: "𝒟⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) = r'" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) from "𝔞_q" (*‹incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q : r' ↦⇘cat_Set α⇙ 𝔞›*) have dom_rhs: "𝒟⇩∘ ((incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈) = r'" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) show "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈ = (incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) = r'›*) dom_rhs (*‹𝒟⇩∘ ((incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈) = r'›*)) (*goals: 1. ‹vsv (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)› 2. ‹vsv ((incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈)› 3. ‹r' = r'› 4. ‹⋀a. a ∈⇩∘ r' ⟹ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇a⦈ = (incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈⦇a⦈›*) fix a assume prems: "a ∈⇩∘ r'" (*‹(a::V) ∈⇩∘ (r'::V)›*) with u'_NTMap_vrange (*‹ℛ⇩∘ ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⊆⇩∘ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)›*) dom_lhs (*‹𝒟⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) = r'›*) "u'_𝔞⇩P⇩L.ArrVal.vsv_vimageI2" (*‹(?a::V) ∈⇩∘ 𝒟⇩∘ ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈) ⟹ u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇?a⦈ ∈⇩∘ ℛ⇩∘ (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)›*) have "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇a⦈ ∈⇩∘ vequalizer 𝔞 𝔤 𝔣" by blast with prems (*‹(a::V) ∈⇩∘ (r'::V)›*) q_is_arr (*‹q : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣›*) "u'_𝔞⇩P⇩L_is_arr" (*‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ : (r'::V) ↦⇘cat_Set (α::V)⇙ (𝔞::V)›*) show "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈⦇a⦈ = (incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈⦇a⦈" by (cs_concl cs_shallow cs_simp: cat_Set_cs_simps cat_cs_simps cs_intro: V_cs_intros cat_cs_intros cat_Set_cs_intros) qed (auto) (*solves the remaining goals: 1. ‹vsv (u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrVal⦈)› 2. ‹vsv ((incl_Rel (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ q)⦇ArrVal⦈)› 3. ‹r' = r'›*) qed ((use u'_𝔞⇩P⇩L 𝔞_q in ‹ cs_concl cs_shallow cs_intro: cat_Set_is_arrD(1) cs_simp: cat_cs_simps ›)+) (*solves the remaining goals: 1. ‹arr_Set (α::V) ((u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈)› 2. ‹arr_Set (α::V) (incl_Rel (vequalizer (𝔞::V) (𝔤::V) (𝔣::V)) 𝔞 ∘⇩A⇘cat_Set α⇙ (q::V))› 3. ‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrDom⦈ = (incl_Rel (vequalizer (𝔞::V) (𝔤::V) (𝔣::V)) 𝔞 ∘⇩A⇘cat_Set (α::V)⇙ (q::V))⦇ArrDom⦈› 4. ‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈⦇ArrCod⦈ = (incl_Rel (vequalizer (𝔞::V) (𝔤::V) (𝔣::V)) 𝔞 ∘⇩A⇘cat_Set (α::V)⇙ (q::V))⦇ArrCod⦈›*) from q_is_arr (*‹q : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣›*) have u'_NTMap_app_I: "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = ( ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q )⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈" by (cs_concl cs_intro: cat_cs_intros cat_parallel_cs_intros cs_simp: cat_Set_cs_simps cat_cs_simps V_cs_simps) from q_is_arr (*‹(q::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)›*) assms (*‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) have u'_NTMap_app_sI: "u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ = ( ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q )⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈" by (cs_concl cs_simp: cat_Set_cs_simps cat_cs_simps u'_𝔤u' cs_intro: V_cs_intros cat_cs_intros cat_Set_cs_intros cat_parallel_cs_intros) from prems (*‹a ∈⇩∘ ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈›*) consider "a = 𝔞⇩P⇩L₂" | "a = 𝔟⇩P⇩L₂" (*goal: ‹⟦a = 𝔞⇩P⇩L₂ ⟹ thesis; a = 𝔟⇩P⇩L₂ ⟹ thesis⟧ ⟹ thesis›*) apply (elim the_cat_parallel_2_ObjE (*‹⟦?a ∈⇩∘ ↑↑⇩C ?𝔞 ?𝔟 ?𝔤 ?𝔣⦇Obj⦈; ?a = ?𝔞 ⟹ ?thesis; ?a = ?𝔟 ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦a = 𝔞⇩P⇩L₂ ⟹ thesis; a = 𝔟⇩P⇩L₂ ⟹ thesis; a = 𝔞⇩P⇩L₂⟧ ⟹ thesis› 2. ‹⟦a = 𝔞⇩P⇩L₂ ⟹ thesis; a = 𝔟⇩P⇩L₂ ⟹ thesis; a = 𝔟⇩P⇩L₂⟧ ⟹ thesis› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) then show "u'⦇NTMap⦈⦇a⦈ = ( ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) q )⦇NTMap⦈⦇a⦈" apply cases (*goals: 1. ‹a = 𝔞⇩P⇩L₂ ⟹ u'⦇NTMap⦈⦇a⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇a⦈› 2. ‹a = 𝔟⇩P⇩L₂ ⟹ u'⦇NTMap⦈⦇a⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇a⦈› discuss goal 1*) apply (simp add: u'_NTMap_app_I (*‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈›*) u'_NTMap_app_sI (*‹u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈›*)) (*discuss goal 2*) apply (simp add: u'_NTMap_app_I (*‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈›*) u'_NTMap_app_sI (*‹u'⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) q)⦇NTMap⦈⦇𝔟⇩P⇩L₂⦈›*)) (*proven 2 subgoals*) . qed (auto) (*solves the remaining goals: 1. ‹vsv ((u'::V)⦇NTMap⦈)› 2. ‹↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈ = ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L⦇Obj⦈›*) qed (simp_all add: u'.is_ntcf_axioms) (*solves the remaining goals: 1. ‹u' : ?𝔉 ↦⇩C⇩F ?𝔊 : ?𝔄 ↦↦⇩C⇘α⇙ ?𝔅› 2. ‹?𝔉 = dghm_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) r' (cat_Set α⦇CId⦈⦇r'⦈)› 3. ‹?𝔊 = ↑↑→↑↑⇩C⇩F (cat_Set α) 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L 𝔞 𝔟 𝔤 𝔣› 4. ‹?𝔄 = ↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L› 5. ‹?𝔅 = cat_Set α›*) fix f' assume prems: "f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣" "u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) f'" (*‹(f'::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)› ‹(u'::V) = ntcf_Set_equalizer (α::V) (𝔞::V) (𝔟::V) (𝔤::V) (𝔣::V) ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) (f'::V)›*) from prems(2) (*‹u' = ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) f'›*) have u'_NTMap_app: "u'⦇NTMap⦈⦇x⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩C⇩F ntcf_const ?II (cat_Set α) f')⦇NTMap⦈⦇x⦈" for x by simp have u'_f': "u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = incl_Set (vequalizer 𝔞 𝔤 𝔣) 𝔞 ∘⇩A⇘cat_Set α⇙ f'" using u'_NTMap_app[of 𝔞⇩P⇩L₂] (*‹u'⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = (ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 ∙⇩N⇩T⇩S⇩M⇩C⇩F ntcf_const (↑↑⇩C 𝔞⇩P⇩L₂ 𝔟⇩P⇩L₂ 𝔤⇩P⇩L 𝔣⇩P⇩L) (cat_Set α) f')⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈›*) prems(1) (*‹f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣›*) apply (cs_prems cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_parallel_cs_intros) (*goal: ‹(u'::V)⦇NTMap⦈⦇𝔞⇩P⇩L₂⦈ = incl_Rel (vequalizer (𝔞::V) (𝔤::V) (𝔣::V)) 𝔞 ∘⇩A⇘cat_Set (α::V)⇙ (f'::V)›*) by (cs_prems cs_shallow cs_simp: cat_Set_cs_simps cs_intro: cat_parallel_cs_intros) note f' = cat_Set_is_arrD[OF prems ( 1 )] (*‹arr_Set (α::V) (f'::V)› ‹f'⦇ArrDom⦈ = r'› ‹f'⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣›*) note q = cat_Set_is_arrD[OF q_is_arr] (*‹arr_Set α q› ‹q⦇ArrDom⦈ = r'› ‹q⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣›*) interpret f': arr_Set "α" f' using prems(1) (*‹f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣›*) by (auto dest: cat_Set_is_arrD (*‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ arr_Set ?α ?S› ‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ ?S⦇ArrDom⦈ = ?A› ‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ ?S⦇ArrCod⦈ = ?B›*)) interpret q: arr_Set "α" q using q (*‹arr_Set α q› ‹q⦇ArrDom⦈ = r'› ‹(q::V)⦇ArrCod⦈ = vequalizer (𝔞::V) (𝔤::V) (𝔣::V)›*) by (auto dest: cat_Set_is_arrD (*‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ arr_Set ?α ?S› ‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ ?S⦇ArrDom⦈ = ?A› ‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ ?S⦇ArrCod⦈ = ?B›*)) show "f' = q" proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α f'› 2. ‹arr_Set α q› 3. ‹f'⦇ArrVal⦈ = q⦇ArrVal⦈› 4. ‹f'⦇ArrDom⦈ = q⦇ArrDom⦈› 5. ‹f'⦇ArrCod⦈ = q⦇ArrCod⦈›*) have dom_lhs: "𝒟⇩∘ (f'⦇ArrVal⦈) = r'" by (simp add: cat_Set_cs_simps (*‹arr_Set ?α ?T ⟹ 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈› ‹⟦arr_Set ?α ?F; ?F⦇ArrCod⦈ = ?A⟧ ⟹ id_Rel ?A ∘⇩R⇩e⇩l ?F = ?F› ‹⟦arr_Set ?α ?F; ?F⦇ArrDom⦈ = ?A⟧ ⟹ ?F ∘⇩R⇩e⇩l id_Rel ?A = ?F› ‹(?x ∈⇩∘ cat_Set ?α⦇Arr⦈) = arr_Set ?α ?x› ‹arr_Set ?α ?x ⟹ cat_Set ?α⦇Cod⦈⦇?x⦈ = ?x⦇ArrCod⦈› ‹⟦?S : ?b ↦⇘cat_Set ?α⇙ ?c; ?T : ?a ↦⇘cat_Set ?α⇙ ?b⟧ ⟹ ?S ∘⇩A⇘cat_Set ?α⇙ ?T = ?S ∘⇩R⇩e⇩l ?T› ‹𝒟⇩∘ (cat_Set ?α⦇Comp⦈) = composable_arrs (cat_Set ?α)› ‹?A ∈⇩∘ Vset ?α ⟹ cat_Set ?α⦇CId⦈⦇?A⦈ = id_Rel ?A› ‹?T : ?A ↦⇩i⇩s⇩o⇘cat_Set ?α⇙ ?B ⟹ ?T¯⇩C⇘cat_Set ?α⇙ = ?T¯⇩R⇩e⇩l› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrVal⦈ = ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrDom⦈ = 𝒟⇩∘ ?f› ‹cat_Set_arr_of_vsv ?f ?B⦇ArrCod⦈ = ?B› and more 64 facts*) f' (*‹arr_Set α f'› ‹f'⦇ArrDom⦈ = r'› ‹f'⦇ArrCod⦈ = vequalizer 𝔞 𝔤 𝔣›*)) from q_is_arr (*‹(q::V) : (r'::V) ↦⇘cat_Set (α::V)⇙ vequalizer (𝔞::V) (𝔤::V) (𝔣::V)›*) have dom_rhs: "𝒟⇩∘ (q⦇ArrVal⦈) = r'" by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_Set_cs_intros) show "f'⦇ArrVal⦈ = q⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (f'⦇ArrVal⦈) = r'›*) dom_rhs (*‹𝒟⇩∘ (q⦇ArrVal⦈) = r'›*)) (*goals: 1. ‹vsv (f'⦇ArrVal⦈)› 2. ‹vsv (q⦇ArrVal⦈)› 3. ‹r' = r'› 4. ‹⋀a. a ∈⇩∘ r' ⟹ f'⦇ArrVal⦈⦇a⦈ = q⦇ArrVal⦈⦇a⦈›*) fix i assume "i ∈⇩∘ r'" (*‹(i::V) ∈⇩∘ (r'::V)›*) with prems(1) (*‹f' : r' ↦⇘cat_Set α⇙ vequalizer 𝔞 𝔤 𝔣›*) show "f'⦇ArrVal⦈⦇i⦈ = q⦇ArrVal⦈⦇i⦈" by (cs_concl cs_simp: cat_Set_cs_simps cat_cs_simps q_components u'_f' cat_Set_components(1) cs_intro: V_cs_intros cat_cs_intros cat_Set_cs_intros) qed (auto) (*solves the remaining goals: 1. ‹vsv (f'⦇ArrVal⦈)› 2. ‹vsv (q⦇ArrVal⦈)› 3. ‹r' = r'›*) qed ((use prems(1) q_is_arr in ‹ cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: q cat_Set_is_arrD ›)+) (*solves the remaining goals: 1. ‹arr_Set α f'› 2. ‹arr_Set α q› 3. ‹f'⦇ArrDom⦈ = q⦇ArrDom⦈› 4. ‹f'⦇ArrCod⦈ = q⦇ArrCod⦈›*) qed qed qed (auto intro: assms (*‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*)) (*solves the remaining goals: 1. ‹𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟› 2. ‹𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟›*) subsection‹The category ‹Set› is small-complete› lemma (in 𝒵) cat_small_complete_cat_Set: "cat_small_complete α (cat_Set α)" ―‹This lemma appears as a remark on page 113 in \cite{mac_lane_categories_2010}.› proof (rule category.cat_small_complete_if_eq_and_obj_prod (*‹⟦category (?α::V) (?ℭ::V); ⋀(𝔞::V) (𝔟::V) (𝔤::V) 𝔣::V. ⟦𝔣 : 𝔞 ↦⇘?ℭ⇙ 𝔟; 𝔤 : 𝔞 ↦⇘?ℭ⇙ 𝔟⟧ ⟹ ∃(E::V) ε::V. ε : E <⇩C⇩F⇩.⇩e⇩q (𝔞,𝔟,𝔤,𝔣) : ↑↑⇩C ↦↦⇩C⇘?α⇙ ?ℭ; ⋀(A::V ⇒ V) I::V. tm_cf_discrete ?α I A ?ℭ ⟹ ∃(P::V) π::V. π : P <⇩C⇩F⇩.⇩∏ A : I ↦↦⇩C⇘?α⇙ ?ℭ⟧ ⟹ cat_small_complete ?α ?ℭ›*)) (*goals: 1. ‹category α (cat_Set α)› 2. ‹⋀𝔞 𝔟 𝔤 𝔣. ⟦𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟; 𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟⟧ ⟹ ∃E ε. ε : E <⇩C⇩F⇩.⇩e⇩q (𝔞,𝔟,𝔤,𝔣) : ↑↑⇩C ↦↦⇩C⇘α⇙ cat_Set α› 3. ‹⋀A I. tm_cf_discrete α I A (cat_Set α) ⟹ ∃P π. π : P <⇩C⇩F⇩.⇩∏ A : I ↦↦⇩C⇘α⇙ cat_Set α›*) show "∃E ε. ε : E <⇩C⇩F⇩.⇩e⇩q (𝔞,𝔟,𝔤,𝔣) : ↑↑⇩C ↦↦⇩C⇘α⇙ cat_Set α" if "𝔣 : 𝔞 ↦⇘cat_Set α⇙ 𝔟" and "𝔤 : 𝔞 ↦⇘cat_Set α⇙ 𝔟" for 𝔞 and 𝔟 and 𝔤 and 𝔣 using ntcf_Set_equalizer_2_is_cat_equalizer_2[OF that ( 2 , 1 )] (*‹ntcf_Set_equalizer α 𝔞 𝔟 𝔤 𝔣 : vequalizer 𝔞 𝔤 𝔣 <⇩C⇩F⇩.⇩e⇩q (𝔞,𝔟,𝔤,𝔣) : ↑↑⇩C ↦↦⇩C⇘α⇙ cat_Set α›*) by auto show "∃P π. π : P <⇩C⇩F⇩.⇩∏ A : I ↦↦⇩C⇘α⇙ cat_Set α" if "tm_cf_discrete α I A (cat_Set α)" for A and I apply (intro exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*goal: ‹∃(P::V) π::V. π : P <⇩C⇩F⇩.⇩∏ (A::V ⇒ V) : (I::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) proof (rule tm_cf_discrete_ntcf_obj_prod_base_is_cat_obj_prod (*‹VLambda ?I ?F ∈⇩∘ Vset α ⟹ ntcf_Set_obj_prod α ?I ?F : vproduct ?I ?F <⇩C⇩F⇩.⇩∏ ?F : ?I ↦↦⇩C⇘α⇙ cat_Set α›*)) (*goal: ‹VLambda I A ∈⇩∘ Vset α›*) interpret tm_cf_discrete "α" I A "cat_Set α" by (rule that (*‹tm_cf_discrete α I A (cat_Set α)›*)) show "VLambda I A ∈⇩∘ Vset α" by (rule tm_cf_discrete_ObjMap_in_Vset (*‹VLambda I A ∈⇩∘ Vset α›*)) qed qed (rule category_cat_Set (*‹category α (cat_Set α)›*)) (*solved the remaining goal: ‹category α (cat_Set α)›*) text‹\newpage› end
{ "path": "afp-2025-02-12/thys/CZH_Universal_Constructions/czh_ucategories/CZH_UCAT_Set.thy", "repo": "afp-2025-02-12", "sha": "e767f50ebb59f47f9c73b5da1fb99f8ab9bd8fdbe9168578a7c66f490249327b" }
(* Author: Gertrud Bauer, Tobias Nipkow *) section ‹Graph› theory Graph imports Rotation begin syntax "_UNION1" :: "pttrns ⇒ 'b set ⇒ 'b set" ("(3⋃(‹unbreakable›⇘_⇙)/ _)" [0, 10] 10) "_INTER1" :: "pttrns ⇒ 'b set ⇒ 'b set" ("(3⋂(‹unbreakable›⇘_⇙)/ _)" [0, 10] 10) "_UNION" :: "pttrn ⇒ 'a set ⇒ 'b set ⇒ 'b set" ("(3⋃(‹unbreakable›⇘_∈_⇙)/ _)" [0, 0, 10] 10) "_INTER" :: "pttrn ⇒ 'a set ⇒ 'b set ⇒ 'b set" ("(3⋂(‹unbreakable›⇘_∈_⇙)/ _)" [0, 0, 10] 10) subsection‹Notation› type_synonym vertex = "nat" consts vertices :: "'a ⇒ vertex list" edges :: "'a ⇒ (vertex × vertex) set" ("ℰ") abbreviation vertices_set :: "'a ⇒ vertex set" ("𝒱") where "𝒱 f ≡ set (vertices f)" subsection ‹Faces› text ‹ We represent faces by (distinct) lists of vertices and a face type. › datatype facetype = Final | Nonfinal datatype face = Face "(vertex list)" facetype consts final :: "'a ⇒ bool" consts type :: "'a ⇒ facetype" overloading final_face ≡ "final :: face ⇒ bool" type_face ≡ "type :: face ⇒ facetype" vertices_face ≡ "vertices :: face ⇒ vertex list" cong_face ≡ "pr_isomorphic :: face ⇒ face ⇒ bool" begin primrec final_face where "final (Face vs f) = (case f of Final ⇒ True | Nonfinal ⇒ False)" primrec type_face where "type (Face vs f) = f" primrec vertices_face where "vertices (Face vs f) = vs" definition cong_face :: "face ⇒ face ⇒ bool" where "(f₁ :: face) ≅ f₂ ≡ vertices f₁ ≅ vertices f₂" end text ‹The following operation makes a face final.› definition setFinal :: "face ⇒ face" where "setFinal f ≡ Face (vertices f) Final" text ‹The function ‹nextVertex› (written ‹f ∙ v›) is based on ‹nextElem›, that returns the successor of an element in a list.› primrec nextElem :: "'a list ⇒ 'a ⇒ 'a ⇒ 'a" where "nextElem [] b x = b" |"nextElem (a#as) b x = (if x=a then (case as of [] ⇒ b | (a'#as') ⇒ a') else nextElem as b x)" definition nextVertex :: "face ⇒ vertex ⇒ vertex" (*<*)("_ ∙" [999]) (*>*)where (* *) "f ∙ ≡ let vs = vertices f in nextElem vs (hd vs)" text ‹‹nextVertices› is $n$-fold application of ‹nextvertex›.› definition nextVertices :: "face ⇒ nat ⇒ vertex ⇒ vertex" (*<*)("_⇗_⇖ ∙ _" [100, 0, 100]) (*>*)where (* *) "f⇗n⇖ ∙ v ≡ (f ∙ ^^ n) v" lemma nextV2: "f⇗2⇖∙v = f∙ (f∙ v)" by (simp add: nextVertices_def (*‹(?f::face)⇗?n::nat⇖ ∙ (?v::nat) ≡ (?f ∙ ^^ ?n) ?v›*) eval_nat_numeral (*‹Numeral1 = Suc (0::nat)› ‹numeral (num.Bit0 (?n::num)) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 (?n::num)) = Suc (numeral (num.Bit0 ?n))›*)) (*<*) overloading edges_face ≡ "edges :: face ⇒ (vertex × vertex) set" begin definition "ℰ f ≡ {(a, f ∙ a)|a. a ∈ 𝒱 f}" end (*>*) (*<*)consts op :: "'a ⇒ 'a" ("_⇗op⇖" [1000] 999) (*>*) (* *) overloading op_vertices ≡ "Graph.op :: vertex list ⇒ vertex list" begin definition "(vs::vertex list)⇗op⇖ ≡ rev vs" end overloading op_graph ≡ "Graph.op :: face ⇒ face" begin primrec op_graph where "(Face vs f)⇗op⇖ = Face (rev vs) f" end (*<*) lemma [simp]: "vertices ((f::face)⇗op⇖) = (vertices f)⇗op⇖" apply (induct f) (*goal: ‹vertices (f⇗op⇖) = (vertices f)⇗op⇖›*) by (simp add: op_vertices_def (*‹?vs⇗op⇖ ≡ rev ?vs›*)) lemma [simp]: "xs ≠ [] ⟹ hd (rev xs)= last xs" apply (induct xs) (*goals: 1. ‹[] ≠ [] ⟹ hd (rev []) = last []› 2. ‹⋀a xs. ⟦xs ≠ [] ⟹ hd (rev xs) = last xs; a # xs ≠ []⟧ ⟹ hd (rev (a # xs)) = last (a # xs)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . (*>*) (* *) definition prevVertex :: "face ⇒ vertex ⇒ vertex" (*<*)("_⇗-1⇖ ∙" [100]) (*>*)where (* *) "f⇗-1⇖ ∙ v ≡ (let vs = vertices f in nextElem (rev vs) (last vs) v)" abbreviation triangle :: "face ⇒ bool" where "triangle f == |vertices f| = 3" subsection ‹Graphs› datatype graph = Graph "(face list)" "nat" "face list list" "nat list" primrec faces :: "graph ⇒ face list" where "faces (Graph fs n f h) = fs" abbreviation Faces :: "graph ⇒ face set" ("ℱ") where "ℱ g == set(faces g)" primrec countVertices :: "graph ⇒ nat" where "countVertices (Graph fs n f h) = n" overloading vertices_graph ≡ "vertices :: graph ⇒ vertex list" begin primrec vertices_graph where "vertices (Graph fs n f h) = [0 ..< n]" end lemma vertices_graph: "vertices g = [0 ..< countVertices g]" apply (induct g) (*goal: ‹vertices g = [0..<countVertices g]›*) by simp lemma in_vertices_graph: "v ∈ set (vertices g) = (v < countVertices g)" by (simp add:vertices_graph (*‹vertices ?g = [0..<countVertices ?g]›*)) lemma len_vertices_graph: "|vertices g| = countVertices g" by (simp add:vertices_graph (*‹vertices ?g = [0..<countVertices ?g]›*)) primrec faceListAt :: "graph ⇒ face list list" where "faceListAt (Graph fs n f h) = f" definition facesAt :: "graph ⇒ vertex ⇒ face list" where "facesAt g v ≡ ⌦‹if v ∈ set(vertices g) then› faceListAt g ! v ⌦‹else []›" primrec heights :: "graph ⇒ nat list" where "heights (Graph fs n f h) = h" definition height :: "graph ⇒ vertex ⇒ nat" where "height g v ≡ heights g ! v" definition graph :: "nat ⇒ graph" where "graph n ≡ (let vs = [0 ..< n]; fs = [ Face vs Final, Face (rev vs) Nonfinal] in (Graph fs n (replicate n fs) (replicate n 0)))" subsection‹Operations on graphs› text ‹final graph, final / nonfinal faces› definition finals :: "graph ⇒ face list" where "finals g ≡ [f ← faces g. final f]" definition nonFinals :: "graph ⇒ face list" where "nonFinals g ≡ [f ← faces g. ¬ final f]" definition countNonFinals :: "graph ⇒ nat" where "countNonFinals g ≡ |nonFinals g|" overloading finalGraph ≡ "final :: graph ⇒ bool" begin definition "finalGraph g ≡ (nonFinals g = [])" end lemma finalGraph_faces[simp]: "final g ⟹ finals g = faces g" by (simp add: finalGraph_def (*‹final (?g::graph) ≡ nonFinals ?g = []›*) finals_def (*‹finals (?g::graph) ≡ filter final (faces ?g)›*) nonFinals_def (*‹nonFinals (?g::graph) ≡ filter (λf::face. ¬ final f) (faces ?g)›*) filter_compl1 (*‹(filter (?P::?'a ⇒ bool) (?xs::?'a list) = []) = (filter (λx::?'a. ¬ ?P x) ?xs = ?xs)›*)) lemma finalGraph_face: "final g ⟹ f ∈ set (faces g) ⟹ final f" apply (simp only: finalGraph_faces[symmetric] (*‹final ?g ⟹ faces ?g = finals ?g›*)) (*goal: ‹⟦final g; f ∈ ℱ g⟧ ⟹ final f›*) by (simp add: finals_def (*‹finals ?g ≡ filter final (faces ?g)›*)) definition finalVertex :: "graph ⇒ vertex ⇒ bool" where "finalVertex g v ≡ ∀f ∈ set(facesAt g v). final f" lemma finalVertex_final_face[dest]: "finalVertex g v ⟹ f ∈ set (facesAt g v) ⟹ final f" by (auto simp add: finalVertex_def (*‹finalVertex (?g::graph) (?v::nat) ≡ ∀f::face∈set (facesAt ?g ?v). final f›*)) text ‹counting faces› definition degree :: "graph ⇒ vertex ⇒ nat" where "degree g v ≡ |facesAt g v|" definition tri :: "graph ⇒ vertex ⇒ nat" where "tri g v ≡ |[f ← facesAt g v. final f ∧ |vertices f| = 3]|" definition quad :: "graph ⇒ vertex ⇒ nat" where "quad g v ≡ |[f ← facesAt g v. final f ∧ |vertices f| = 4]|" definition except :: "graph ⇒ vertex ⇒ nat" where "except g v ≡ |[f ← facesAt g v. final f ∧ 5 ≤ |vertices f| ]|" definition vertextype :: "graph ⇒ vertex ⇒ nat × nat × nat" where "vertextype g v ≡ (tri g v, quad g v, except g v)" lemma[simp]: "0 ≤ tri g v" by (simp add: tri_def (*‹tri (?g::graph) (?v::nat) ≡ |filter (λf::face. final f ∧ triangle f) (facesAt ?g ?v)|›*)) lemma[simp]: "0 ≤ quad g v" by (simp add: quad_def (*‹quad ?g ?v ≡ |filter (λf. final f ∧ |vertices f| = 4) (facesAt ?g ?v)|›*)) lemma[simp]: "0 ≤ except g v" by (simp add: except_def (*‹except ?g ?v ≡ |filter (λf. final f ∧ 5 ≤ |vertices f|) (facesAt ?g ?v)|›*)) definition exceptionalVertex :: "graph ⇒ vertex ⇒ bool" where "exceptionalVertex g v ≡ except g v ≠ 0" definition noExceptionals :: "graph ⇒ vertex set ⇒ bool" where "noExceptionals g V ≡ (∀v ∈ V. ¬ exceptionalVertex g v)" text ‹An edge $(a,b)$ is contained in face f, $b$ is the successor of $a$ in $f$.› (*>*) overloading edges_graph ≡ "edges :: graph ⇒ (vertex × vertex) set" begin definition "ℰ (g::graph) ≡ ⋃⇘f ∈ ℱ g⇙ edges f" end definition neighbors :: "graph ⇒ vertex ⇒ vertex list" where "neighbors g v ≡ [f∙v. f ← facesAt g v]" subsection ‹Navigation in graphs› text ‹ The function $s'$ permutating the faces at a vertex, is implemeted by the function ‹nextFace› › definition nextFace :: "graph × vertex ⇒ face ⇒ face" (*<*)("_ ∙") (*>*)where (*<*) nextFace_def_aux: "p ∙ ≡ λf. (let (g,v) = p; fs = (facesAt g v) in (case fs of [] ⇒ f | g#gs ⇒ nextElem fs (hd fs) f))" (*>*) (* precondition a b in f *) definition directedLength :: "face ⇒ vertex ⇒ vertex ⇒ nat" where "directedLength f a b ≡ if a = b then 0 else |(between (vertices f) a b)| + 1" subsection ‹Code generator setup› definition final_face :: "face ⇒ bool" where final_face_code_def: "final_face = final" declare final_face_code_def [symmetric, code_unfold] lemma final_face_code [code]: "final_face (Face vs Final) ⟷ True" "final_face (Face vs Nonfinal) ⟷ False" (*goals: 1. ‹final_face (Face (vs::nat list) Final) = True› 2. ‹final_face (Face (vs::nat list) Nonfinal) = False› discuss goal 1*) apply (simp add: final_face_code_def (*‹final_face = final›*)) (*discuss goal 2*) apply (simp add: final_face_code_def (*‹final_face = final›*)) (*proven 2 subgoals*) . definition final_graph :: "graph ⇒ bool" where final_graph_code_def: "final_graph = final" declare final_graph_code_def [symmetric, code_unfold] lemma final_graph_code [code]: "final_graph g = List.null (nonFinals g)" unfolding final_graph_code_def finalGraph_def null_def (*goal: ‹(nonFinals (g::graph) = []) = (nonFinals g = [])›*) by standard definition vertices_face :: "face ⇒ vertex list" where vertices_face_code_def: "vertices_face = vertices" declare vertices_face_code_def [symmetric, code_unfold] lemma vertices_face_code [code]: "vertices_face (Face vs f) = vs" unfolding vertices_face_code_def (*goal: ‹vertices (Face vs f) = vs›*) by simp definition vertices_graph :: "graph ⇒ vertex list" where vertices_graph_code_def: "vertices_graph = vertices" declare vertices_graph_code_def [symmetric, code_unfold] lemma vertices_graph_code [code]: "vertices_graph (Graph fs n f h) = [0 ..< n]" unfolding vertices_graph_code_def (*goal: ‹vertices (Graph fs n f h) = [0..<n]›*) by simp end
{ "path": "afp-2025-02-12/thys/Flyspeck-Tame/Graph.thy", "repo": "afp-2025-02-12", "sha": "07c8cd41b74e23ec376517911c642fac5dd2226dd307cb3605bc0a1097242463" }
section ‹Preliminary probability/UHF lemmas› text ‹ This section proves some simplified/specialized forms of lemmas that will be used in the algorithm's analysis later. › theory ApproxMCPreliminaries imports Frequency_Moments.Probability_Ext Concentration_Inequalities.Bienaymes_Identity Concentration_Inequalities.Paley_Zygmund_Inequality begin lemma card_inter_sum_indicat_real: assumes "finite A" shows "card (A ∩ B) = sum (indicat_real B) A" by (simp add: assms (*‹finite A›*) indicator_def (*‹indicator ?S ?x = of_bool (?x ∈ ?S)›*)) (* Counting number of finite maps *) lemma card_dom_ran: assumes "finite D" shows "card {w. dom w = D ∧ ran w ⊆ R} = card R ^ card D" using assms (*‹finite D›*) proof (induct rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹card {w::'a ⇒ 'b option. dom w = {} ∧ ran w ⊆ (R::'b set)} = card R ^ card {}› 2. ‹⋀(x::'a) F::'a set. ⟦finite F; x ∉ F; card {w::'a ⇒ 'b option. dom w = F ∧ ran w ⊆ (R::'b set)} = card R ^ card F⟧ ⟹ card {w::'a ⇒ 'b option. dom w = insert x F ∧ ran w ⊆ R} = card R ^ card (insert x F)›*) case empty (*no hyothesis introduced yet*) have "{w::'a ⇒ 'b option. w = Map.empty ∧ ran w ⊆ R} = {Map.empty}" by auto then show "?case" (*goal: ‹card {w. dom w = {} ∧ ran w ⊆ R} = card R ^ card {}›*) by auto next (*goal: ‹⋀(x::'a) F::'a set. ⟦finite F; x ∉ F; card {w::'a ⇒ 'b option. dom w = F ∧ ran w ⊆ (R::'b set)} = card R ^ card F⟧ ⟹ card {w::'a ⇒ 'b option. dom w = insert x F ∧ ran w ⊆ R} = card R ^ card (insert x F)›*) case (insert a A) (*‹finite A› ‹a ∉ A› ‹card {w::'a ⇒ 'b option. dom w = (A::'a set) ∧ ran w ⊆ (R::'b set)} = card R ^ card A›*) have 1: "inj_on (λ(w, r). w(a ↦ r)) ({w. dom w = A ∧ ran w ⊆ R} × R)" unfolding inj_on_def (*goal: ‹∀x∈{w. dom w = A ∧ ran w ⊆ R} × R. ∀y∈{w. dom w = A ∧ ran w ⊆ R} × R. (case x of (w, r) ⇒ w(a ↦ r)) = (case y of (w, r) ⇒ w(a ↦ r)) ⟶ x = y›*) by (smt (verit, del_insts) CollectD (*‹?a ∈ {x. ?P x} ⟹ ?P ?a›*) SigmaE (*‹⟦?c ∈ Sigma ?A ?B; ⋀x y. ⟦x ∈ ?A; y ∈ ?B x; ?c = (x, y)⟧ ⟹ ?P⟧ ⟹ ?P›*) fun_upd_None_if_notin_dom (*‹?k ∉ dom ?m ⟹ ?m(?k := None) = ?m›*) local.insert( (*‹a ∉ A›*) 2) map_upd_eqD1 (*‹?m(?a ↦ ?x) = ?n(?a ↦ ?y) ⟹ ?x = ?y›*) prod.simps( (*‹(case (?x1.0, ?x2.0) of (x, xa) ⇒ ?f x xa) = ?f ?x1.0 ?x2.0›*) 2) restrict_complement_singleton_eq (*‹?f |` (- {?x}) = ?f(?x := None)›*) restrict_upd_same (*‹?m(?x ↦ ?y) |` (- {?x}) = ?m |` (- {?x})›*)) have 21: "(λ(w, r). w(a ↦ r)) ` ({w. dom w = A ∧ ran w ⊆ R} × R) ⊆ {w. dom w = insert a A ∧ ran w ⊆ R}" unfolding image_def (*goal: ‹{y. ∃x∈{w. dom w = A ∧ ran w ⊆ R} × R. y = (case x of (w, r) ⇒ w(a ↦ r))} ⊆ {w. dom w = insert a A ∧ ran w ⊆ R}›*) using CollectD (*‹(?a::?'a::type) ∈ {x::?'a::type. (?P::?'a::type ⇒ bool) x} ⟹ ?P ?a›*) local.insert(2) (*‹a ∉ A›*) by force have "⋀x. dom x = insert a A ⟹ ran x ⊆ R ⟹ ∃xa. dom xa = A ∧ ran xa ⊆ R ∧ (∃y∈R. x = xa(a ↦ y))" by (smt (verit, del_insts) Diff_insert_absorb (*‹?x ∉ ?A ⟹ insert ?x ?A - {?x} = ?A›*) domD (*‹?a ∈ dom ?m ⟹ ∃b. ?m ?a = Some b›*) dom_fun_upd (*‹dom (?f(?x := ?y)) = (if ?y = None then dom ?f - {?x} else insert ?x (dom ?f))›*) fun_upd_triv (*‹?f(?x := ?f ?x) = ?f›*) fun_upd_upd (*‹?f(?x := ?y, ?x := ?z) = ?f(?x := ?z)›*) insert.hyps( (*‹a ∉ A›*) 2) insertCI (*‹(?a ∉ ?B ⟹ ?a = ?b) ⟹ ?a ∈ insert ?b ?B›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) ran_map_upd (*‹?m ?a = None ⟹ ran (?m(?a ↦ ?b)) = insert ?b (ran ?m)›*)) then have 22: " {w. dom w = insert a A ∧ ran w ⊆ R} ⊆ (λ(w, r). w(a ↦ r)) ` ({w. dom w = A ∧ ran w ⊆ R} × R)" by (clarsimp simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*)) have "bij_betw (λ(w,r). w(a↦r)) ({w. dom w = A ∧ ran w ⊆ R} × R) {w. dom w = insert a A ∧ ran w ⊆ R} " unfolding bij_betw_def (*goal: ‹inj_on (λ(w, r). w(a ↦ r)) ({w. dom w = A ∧ ran w ⊆ R} × R) ∧ (λ(w, r). w(a ↦ r)) ` ({w. dom w = A ∧ ran w ⊆ R} × R) = {w. dom w = insert a A ∧ ran w ⊆ R}›*) using "1" (*‹inj_on (λ(w, r). w(a ↦ r)) ({w. dom w = A ∧ ran w ⊆ R} × R)›*) "21" (*‹(λ(w::'a::type ⇒ 'b::type option, r::'b::type). w(a::'a::type ↦ r)) ` ({w::'a::type ⇒ 'b::type option. dom w = (A::'a::type set) ∧ ran w ⊆ (R::'b::type set)} × R) ⊆ {w::'a::type ⇒ 'b::type option. dom w = insert a A ∧ ran w ⊆ R}›*) "22" (*‹{w. dom w = insert a A ∧ ran w ⊆ R} ⊆ (λ(w, r). w(a ↦ r)) ` ({w. dom w = A ∧ ran w ⊆ R} × R)›*) by clarsimp then have "card {w. dom w = insert a A ∧ ran w ⊆ R} = card ({w. dom w = A ∧ ran w ⊆ R} × R)" by (auto simp add: bij_betw_same_card (*‹bij_betw ?f ?A ?B ⟹ card ?A = card ?B›*) 1 (*‹inj_on (λ(w, r). w(a ↦ r)) ({w. dom w = A ∧ ran w ⊆ R} × R)›*) 21 (*‹(λ(w, r). w(a ↦ r)) ` ({w. dom w = A ∧ ran w ⊆ R} × R) ⊆ {w. dom w = insert a A ∧ ran w ⊆ R}›*) 22 (*‹{w. dom w = insert a A ∧ ran w ⊆ R} ⊆ (λ(w, r). w(a ↦ r)) ` ({w. dom w = A ∧ ran w ⊆ R} × R)›*)) moreover have "... = card R ^ card A * card R" apply (subst card_cartesian_product (*‹card (?A × ?B) = card ?A * card ?B›*)) (*goal: ‹card ({w. dom w = A ∧ ran w ⊆ R} × R) = card R ^ card A * card R›*) by (use insert.hyps(3) in auto) ultimately show "?case" (*goal: ‹card {w. dom w = insert a A ∧ ran w ⊆ R} = card R ^ card (insert a A)›*) using insert.hyps (*‹finite A› ‹a ∉ A› ‹card {w::'a ⇒ 'b option. dom w = (A::'a set) ∧ ran w ⊆ (R::'b set)} = card R ^ card A›*) by (auto simp add: card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*)) qed lemma finite_set_pmf_expectation_sum: fixes f :: "'a ⇒ 'c ⇒ 'b::{banach, second_countable_topology}" assumes "finite (set_pmf A)" shows "measure_pmf.expectation A (λx. sum (f x) T) = (∑i∈T. measure_pmf.expectation A (λx. f x i))" apply (intro Bochner_Integration.integral_sum (*‹(⋀i. i ∈ ?I ⟹ integrable ?M (?f i)) ⟹ LINT x|?M. (∑i∈?I. ?f i x) = (∑i∈?I. integral⇧L ?M (?f i))›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*)) (*goal: ‹measure_pmf.expectation A (λx. sum (f x) T) = (∑i∈T. measure_pmf.expectation A (λx. f x i))›*) using assms (*‹finite (set_pmf A)›*) by auto lemma (in prob_space) k_universal_prob_unif: assumes "k_universal k H D R" assumes "w ∈ D" "α ∈ R" shows "prob {s ∈ space M. H w s = α} = 1 / card R" proof (-) (*goal: ‹prob {s ∈ space M. H w s = α} = 1 / real (card R)›*) have "uniform_on (H w) R" using assms (*‹k_universal k H D R› ‹(w::'b) ∈ (D::'b set)› ‹(α::'c) ∈ (R::'c set)›*) unfolding k_universal_def (*goal: ‹uniform_on ((H::'b::type ⇒ 'a::type ⇒ 'c::type) (w::'b::type)) (R::'c::type set)›*) by auto from uniform_onD[OF this] (*‹prob {ω ∈ space M. H w ω ∈ ?B} = real (card (R ∩ ?B)) / real (card R)›*) have "prob {ω ∈ space M. H w ω ∈ {α}} = real (card (R ∩ {α})) / real (card R)" . thus "?thesis" (*goal: ‹prob {s ∈ space M. H w s = α} = 1 / real (card R)›*) using assms (*‹k_universal (k::nat) (H::'b ⇒ 'a ⇒ 'c) (D::'b set) (R::'c set)› ‹w ∈ D› ‹(α::'c) ∈ (R::'c set)›*) by auto qed (* For h: D → R, k-universal, S ⊆ D. E( | {w ∈ S. h w = α} | ) = |S| / |R| *) lemma k_universal_expectation_eq: assumes p: "finite (set_pmf p)" assumes ind: "prob_space.k_universal p k H D R" assumes S: "finite S" "S ⊆ D" assumes a: "α ∈ R" shows "prob_space.expectation p (λs. real (card (S ∩ {w. H w s = α}))) = real (card S) / card R" proof (-) (*goal: ‹measure_pmf.expectation (p::'a::type pmf) (λs::'a::type. real (card ((S::'b::type set) ∩ {w::'b::type. (H::'b::type ⇒ 'a::type ⇒ 'c::type) w s = (α::'c::type)}))) = real (card S) / real (card (R::'c::type set))›*) have 1: "prob_space (measure_pmf p)" by (simp add: prob_space_measure_pmf (*‹prob_space (measure_pmf ?p)›*)) have 2: "space (measure_pmf p) = UNIV" by auto from prob_space.k_universal_prob_unif[OF 1 ind _ a] (*‹?w ∈ D ⟹ measure_pmf.prob p {s ∈ space (measure_pmf p). H ?w s = α} = 1 / real (card R)›*) have "*": "⋀w. w ∈ S ⟹ prob_space.prob p {s. H w s = α} = 1 / real (card R)" using S(2) (*‹S ⊆ D›*) by auto have "measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))) = measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S)" unfolding card_inter_sum_indicat_real[OF S ( 1 )] (*goal: ‹measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S) = measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S)›*) by presburger moreover have "... = (∑i∈S. measure_pmf.expectation p (indicat_real {s. H i s = α}))" apply (subst finite_set_pmf_expectation_sum (*‹finite (set_pmf ?A) ⟹ measure_pmf.expectation ?A (λx. sum (?f x) ?T) = (∑i∈?T. measure_pmf.expectation ?A (λx. ?f x i))›*)) (*goal: ‹measure_pmf.expectation (p::'a pmf) (λs::'a. sum (indicat_real {w::'b. (H::'b ⇒ 'a ⇒ 'c) w s = (α::'c)}) (S::'b set)) = (∑i::'b∈S. measure_pmf.expectation p (indicat_real {s::'a. H i s = α}))›*) using assms (*‹finite (set_pmf p)› ‹prob_space.k_universal (measure_pmf p) k H D R› ‹finite S› ‹(S::'b set) ⊆ (D::'b set)› ‹α ∈ R›*) unfolding indicator_def (*goals: 1. ‹finite (set_pmf p)› 2. ‹(∑i∈S. measure_pmf.expectation p (λx. of_bool (i ∈ {w. H w x = α}))) = (∑i∈S. measure_pmf.expectation p (λx. of_bool (x ∈ {s. H i s = α})))›*) apply - (*goals: 1. ‹⟦finite (set_pmf p); prob_space.k_universal (measure_pmf p) k H D R; finite S; S ⊆ D; α ∈ R⟧ ⟹ finite (set_pmf p)› 2. ‹⟦finite (set_pmf p); prob_space.k_universal (measure_pmf p) k H D R; finite S; S ⊆ D; α ∈ R⟧ ⟹ (∑i∈S. measure_pmf.expectation p (λx. of_bool (i ∈ {w. H w x = α}))) = (∑i∈S. measure_pmf.expectation p (λx. of_bool (x ∈ {s. H i s = α})))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have " ... = (∑i∈ S. measure_pmf.prob p {s. H i s = α})" by auto moreover have "... = (∑i∈S. 1 / card R)" using "*" (*‹?w ∈ S ⟹ measure_pmf.prob p {s. H ?w s = α} = 1 / real (card R)›*) by auto ultimately show "?thesis" (*goal: ‹measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))) = real (card S) / real (card R)›*) by auto qed lemma (in prob_space) two_universal_indep_var: assumes "k_universal 2 H D R" assumes "w ∈ D" "w' ∈ D" "w ≠ w'" shows "indep_var borel (λx. indicat_real {w. H w x = α} w) borel (λx. indicat_real {w. H w x = α} w')" proof (-) (*goal: ‹indep_var borel (λx::'a. indicat_real {w::'b. (H::'b ⇒ 'a ⇒ 'c) w x = (α::'c)} (w::'b)) borel (λx::'a. indicat_real {w::'b. H w x = α} (w'::'b))›*) have Y: "(λz. (of_bool (z = α))::real) ∈ (count_space UNIV) →⇩M borel" by auto have "k_wise_indep_vars 2 (λ_. count_space UNIV) H D" using assms (*‹k_universal 2 H D R› ‹w ∈ D› ‹w' ∈ D› ‹w ≠ w'›*) unfolding k_universal_def (*goal: ‹k_wise_indep_vars 2 (λ_. Universal_Hash_Families_More_Independent_Families.discrete) H D›*) by auto then have "indep_vars (λ_. count_space UNIV) H {w, w'}" unfolding k_wise_indep_vars_def (*goal: ‹indep_vars (λ_. Universal_Hash_Families_More_Independent_Families.discrete) H {w, w'}›*) by (metis UNIV_bool (*‹UNIV = {False, True}›*) assms( (*‹w ∈ D›*) 2) assms( (*‹w' ∈ D›*) 3) card.empty (*‹card {} = 0›*) card.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*) card_UNIV_bool (*‹CARD(bool) = 2›*) card_insert_le (*‹card ?A ≤ card (insert ?x ?A)›*) empty_iff (*‹(?c ∈ {}) = False›*) empty_subsetI (*‹{} ⊆ ?A›*) finite.emptyI (*‹finite {}›*) finite.insertI (*‹finite ?A ⟹ finite (insert ?a ?A)›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) order.refl (*‹?a ≤ ?a›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*) singleton_insert_inj_eq' (*‹(insert ?a ?A = {?b}) = (?a = ?b ∧ ?A ⊆ {?b})›*)) from indep_var_from_indep_vars[OF assms ( 4 ) this] (*‹indep_var Universal_Hash_Families_More_Independent_Families.discrete (H w) Universal_Hash_Families_More_Independent_Families.discrete (H w')›*) have "indep_var (count_space UNIV) (H w) (count_space UNIV) (H w')" . from indep_var_compose[OF this Y Y] (*‹indep_var borel ((λz. of_bool (z = α)) ∘ H w) borel ((λz. of_bool (z = α)) ∘ H w')›*) show "?thesis" (*goal: ‹indep_var borel (λx::'a::type. indicat_real {w::'b::type. (H::'b::type ⇒ 'a::type ⇒ 'c::type) w x = (α::'c::type)} (w::'b::type)) borel (λx::'a::type. indicat_real {w::'b::type. H w x = α} (w'::'b::type))›*) unfolding indicator_def (*goal: ‹indep_var borel (λx. of_bool (w ∈ {w. H w x = α})) borel (λx. of_bool (w' ∈ {w. H w x = α}))›*) by (auto simp add: o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*)) qed (* For h: D → R, 2-universal, S ⊆ D. V( | {w ∈ S. h w = α} | ) ≤ E( | {w ∈ S. h w = α} | ) *) lemma two_universal_variance_bound: assumes p: "finite (set_pmf p)" assumes ind: "prob_space.k_universal (measure_pmf p) 2 H D R" assumes S: "finite S" "S ⊆ D" assumes a: "α ∈ R" shows "measure_pmf.variance p (λs. real (card (S ∩ {w. H w s = α}))) ≤ measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α})))" proof (-) (*goal: ‹measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) ≤ measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α})))›*) have vb: "measure_pmf.variance p (λx. (indicat_real {w. H w x = α} i)) ≤ measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i))" for i proof (-) (*goal: ‹measure_pmf.expectation (p::'a pmf) (λx::'a. (indicat_real {w::'b. (H::'b ⇒ 'a ⇒ 'c) w x = (α::'c)} (i::'b) - measure_pmf.expectation p (λx::'a. indicat_real {w::'b. H w x = α} i))²) ≤ measure_pmf.expectation p (λx::'a. indicat_real {w::'b. H w x = α} i)›*) have "measure_pmf.variance p (λx. (indicat_real {w. H w x = α} i)) = measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i)²) - (measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i))²" apply (subst measure_pmf.variance_eq (*‹⟦integrable (measure_pmf ?M) ?X; integrable (measure_pmf ?M) (λx. (?X x)²)⟧ ⟹ measure_pmf.expectation ?M (λx. (?X x - measure_pmf.expectation ?M ?X)²) = measure_pmf.expectation ?M (λx. (?X x)²) - (measure_pmf.expectation ?M ?X)²›*)) (*goals: 1. ‹integrable (measure_pmf (p::'a pmf)) (λx::'a. indicat_real {w::'b. (H::'b ⇒ 'a ⇒ 'c) w x = (α::'c)} (i::'b))› 2. ‹integrable (measure_pmf (p::'a pmf)) (λx::'a. (indicat_real {w::'b. (H::'b ⇒ 'a ⇒ 'c) w x = (α::'c)} (i::'b))²)› 3. ‹measure_pmf.expectation (p::'a pmf) (λx::'a. (indicat_real {w::'b. (H::'b ⇒ 'a ⇒ 'c) w x = (α::'c)} (i::'b))²) - (measure_pmf.expectation p (λx::'a. indicat_real {w::'b. H w x = α} i))² = measure_pmf.expectation p (λx::'a. (indicat_real {w::'b. H w x = α} i)²) - (measure_pmf.expectation p (λx::'a. indicat_real {w::'b. H w x = α} i))²› discuss goal 1*) apply ((auto simp add: p (*‹finite (set_pmf (p::'a pmf))›*) integrable_measure_pmf_finite (*‹finite (set_pmf (?M::?'a pmf)) ⟹ integrable (measure_pmf ?M) (?f::?'a ⇒ ?'b)›*))[1]) (*discuss goal 2*) apply ((auto simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*discuss goal 3*) apply ((auto simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*proven 3 subgoals*) . moreover have "... ≤ measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i)²)" by simp moreover have "... = measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i))" by (metis (mono_tags, lifting) indicator_simps( (*‹?x ∈ ?S ⟹ indicator ?S ?x = 1›*) 1) indicator_simps( (*‹?x ∉ ?S ⟹ indicator ?S ?x = 0›*) 2) power2_eq_1_iff (*‹(?a² = 1) = (?a = 1 ∨ ?a = - 1)›*) zero_eq_power2 (*‹(?a² = 0) = (?a = 0)›*)) ultimately show "?thesis" (*goal: ‹measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i - measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i))²) ≤ measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i)›*) by linarith qed have "measure_pmf.variance p (λs. real (card (S ∩ {w. H w s = α}))) = measure_pmf.variance p (λs. sum (indicat_real {w. H w s = α}) S)" unfolding card_inter_sum_indicat_real[OF S ( 1 )] (*goal: ‹measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²) = measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²)›*) by presburger then have "... = (∑i∈S. measure_pmf.variance p (λx. (indicat_real {w. H w x = α} i)))" apply (subst measure_pmf.bienaymes_identity_pairwise_indep (*‹⟦finite ?I; ⋀i. i ∈ ?I ⟹ measure_pmf.random_variable ?M borel (?f i); ⋀i. i ∈ ?I ⟹ integrable (measure_pmf ?M) (λω. (?f i ω)²); ⋀i j. ⟦i ∈ ?I; j ∈ ?I; i ≠ j⟧ ⟹ prob_space.indep_var (measure_pmf ?M) borel (?f i) borel (?f j)⟧ ⟹ measure_pmf.expectation ?M (λx. ((∑i∈?I. ?f i x) - measure_pmf.expectation ?M (λω. ∑i∈?I. ?f i ω))²) = (∑i∈?I. measure_pmf.expectation ?M (λx. (?f i x - measure_pmf.expectation ?M (?f i))²))›*)) (*goal: ‹measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²) = (∑i∈S. measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i - measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i))²))›*) using S (*‹finite S› ‹S ⊆ D›*) prob_space_measure_pmf (*‹prob_space (measure_pmf ?p)›*) apply - (*goals: 1. ‹⟦measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) = measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²); finite S; S ⊆ D; ⋀p. prob_space (measure_pmf p)⟧ ⟹ finite S› 2. ‹⋀i. ⟦measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) = measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²); i ∈ S; finite S; S ⊆ D; ⋀p. prob_space (measure_pmf p)⟧ ⟹ measure_pmf.random_variable p borel (λx. indicat_real {w. H w x = α} i)› 3. ‹⋀i. ⟦measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) = measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²); i ∈ S; finite S; S ⊆ D; ⋀p. prob_space (measure_pmf p)⟧ ⟹ integrable (measure_pmf p) (λω. (indicat_real {w. H w ω = α} i)²)› 4. ‹⋀i j. ⟦measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) = measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²); i ∈ S; j ∈ S; i ≠ j; finite S; S ⊆ D; ⋀p. prob_space (measure_pmf p)⟧ ⟹ prob_space.indep_var (measure_pmf p) borel (λx. indicat_real {w. H w x = α} i) borel (λx. indicat_real {w. H w x = α} j)› 5. ‹⟦measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) = measure_pmf.expectation p (λx. (sum (indicat_real {w. H w x = α}) S - measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S))²); finite S; S ⊆ D; ⋀p. prob_space (measure_pmf p)⟧ ⟹ (∑i∈S. measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i - measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i))²)) = (∑i∈S. measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i - measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i))²))› discuss goal 1*) apply ((auto intro!: prob_space.two_universal_indep_var[OF _ ind] (*‹⟦prob_space (measure_pmf p); ?w ∈ D; ?w' ∈ D; ?w ≠ ?w'⟧ ⟹ prob_space.indep_var (measure_pmf p) borel (λx. indicat_real {w. H w x = ?α} ?w) borel (λx. indicat_real {w. H w x = ?α} ?w')›*) simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*discuss goal 2*) apply ((auto intro!: prob_space.two_universal_indep_var[OF _ ind] (*‹⟦prob_space (measure_pmf p); ?w ∈ D; ?w' ∈ D; ?w ≠ ?w'⟧ ⟹ prob_space.indep_var (measure_pmf p) borel (λx. indicat_real {w. H w x = ?α} ?w) borel (λx. indicat_real {w. H w x = ?α} ?w')›*) simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*discuss goal 3*) apply ((auto intro!: prob_space.two_universal_indep_var[OF _ ind] (*‹⟦prob_space (measure_pmf p); ?w ∈ D; ?w' ∈ D; ?w ≠ ?w'⟧ ⟹ prob_space.indep_var (measure_pmf p) borel (λx. indicat_real {w. H w x = ?α} ?w) borel (λx. indicat_real {w. H w x = ?α} ?w')›*) simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*discuss goal 4*) apply ((auto intro!: prob_space.two_universal_indep_var[OF _ ind] (*‹⟦prob_space (measure_pmf p); ?w ∈ D; ?w' ∈ D; ?w ≠ ?w'⟧ ⟹ prob_space.indep_var (measure_pmf p) borel (λx. indicat_real {w. H w x = ?α} ?w) borel (λx. indicat_real {w. H w x = ?α} ?w')›*) simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*discuss goal 5*) apply ((auto intro!: prob_space.two_universal_indep_var[OF _ ind] (*‹⟦prob_space (measure_pmf p); ?w ∈ D; ?w' ∈ D; ?w ≠ ?w'⟧ ⟹ prob_space.indep_var (measure_pmf p) borel (λx. indicat_real {w. H w x = ?α} ?w) borel (λx. indicat_real {w. H w x = ?α} ?w')›*) simp add: p (*‹finite (set_pmf p)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*))[1]) (*proven 5 subgoals*) . moreover have "... ≤ (∑i∈S. measure_pmf.expectation p (λx. (indicat_real {w. H w x = α} i)))" by (simp add: sum_mono (*‹(⋀i::?'b::type. i ∈ (?K::?'b::type set) ⟹ (?f::?'b::type ⇒ ?'a::ordered_comm_monoid_add) i ≤ (?g::?'b::type ⇒ ?'a::ordered_comm_monoid_add) i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) vb (*‹measure_pmf.expectation (p::'a::type pmf) (λx::'a::type. (indicat_real {w::'b::type. (H::'b::type ⇒ 'a::type ⇒ 'c::type) w x = (α::'c::type)} (?i::'b::type) - measure_pmf.expectation p (λx::'a::type. indicat_real {w::'b::type. H w x = α} ?i))²) ≤ measure_pmf.expectation p (λx::'a::type. indicat_real {w::'b::type. H w x = α} ?i)›*)) moreover have "... = measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S)" apply (subst finite_set_pmf_expectation_sum (*‹finite (set_pmf ?A) ⟹ measure_pmf.expectation ?A (λx. sum (?f x) ?T) = (∑i∈?T. measure_pmf.expectation ?A (λx. ?f x i))›*)) (*goal: ‹(∑i∈S. measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i)) = measure_pmf.expectation p (λs. sum (indicat_real {w. H w s = α}) S)›*) using assms (*‹finite (set_pmf p)› ‹prob_space.k_universal (measure_pmf p) 2 H D R› ‹finite S› ‹S ⊆ D› ‹(α::'c) ∈ (R::'c set)›*) apply - (*goals: 1. ‹⟦finite (set_pmf p); prob_space.k_universal (measure_pmf p) 2 H D R; finite S; S ⊆ D; α ∈ R⟧ ⟹ finite (set_pmf p)› 2. ‹⟦finite (set_pmf p); prob_space.k_universal (measure_pmf p) 2 H D R; finite S; S ⊆ D; α ∈ R⟧ ⟹ (∑i∈S. measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i)) = (∑i∈S. measure_pmf.expectation p (λx. indicat_real {w. H w x = α} i))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹measure_pmf.expectation p (λx. (real (card (S ∩ {w. H w x = α})) - measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α}))))²) ≤ measure_pmf.expectation p (λs. real (card (S ∩ {w. H w s = α})))›*) by (simp add: assms( (*‹finite S›*) 3) card_inter_sum_indicat_real (*‹finite ?A ⟹ real (card (?A ∩ ?B)) = sum (indicat_real ?B) ?A›*)) qed lemma (in prob_space) k_universal_mono: assumes "k' ≤ k" assumes"k_universal k H D R" shows"k_universal k' H D R" using assms (*‹k' ≤ k› ‹k_universal k H D R›*) unfolding k_universal_def k_wise_indep_vars_def (*goal: ‹(∀J⊆D. card J ≤ k' ⟶ finite J ⟶ indep_vars (λ_. Universal_Hash_Families_More_Independent_Families.discrete) H J) ∧ (∀i∈D. uniform_on (H i) R)›*) by auto lemma finite_set_pmf_expectation_add: assumes "finite (set_pmf S)" shows "measure_pmf.expectation S (λx. ((f x)::real) + g x) = measure_pmf.expectation S f + measure_pmf.expectation S g" by (auto intro: Bochner_Integration.integral_add (*‹⟦integrable ?M ?f; integrable ?M ?g⟧ ⟹ LINT x|?M. ?f x + ?g x = integral⇧L ?M ?f + integral⇧L ?M ?g›*) simp add: assms (*‹finite (set_pmf S)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*)) lemma finite_set_pmf_expectation_add_const: assumes "finite (set_pmf S)" shows "measure_pmf.expectation S (λx. ((f x)::real) + g) = measure_pmf.expectation S f + g" proof (-) (*goal: ‹measure_pmf.expectation S (λx. f x + g) = measure_pmf.expectation S f + g›*) have "g = measure_pmf.expectation S (λx. g)" by simp thus "?thesis" (*goal: ‹measure_pmf.expectation S (λx. f x + g) = measure_pmf.expectation S f + g›*) by (simp add: assms (*‹finite (set_pmf S)›*) finite_set_pmf_expectation_add (*‹finite (set_pmf ?S) ⟹ measure_pmf.expectation ?S (λx. ?f x + ?g x) = measure_pmf.expectation ?S ?f + measure_pmf.expectation ?S ?g›*)) qed lemma finite_set_pmf_expectation_diff: assumes "finite (set_pmf S)" shows "measure_pmf.expectation S (λx. ((f x)::real) - g x) = measure_pmf.expectation S f - measure_pmf.expectation S g" by (auto intro: Bochner_Integration.integral_diff (*‹⟦integrable ?M ?f; integrable ?M ?g⟧ ⟹ LINT x|?M. ?f x - ?g x = integral⇧L ?M ?f - integral⇧L ?M ?g›*) simp add: assms (*‹finite (set_pmf S)›*) integrable_measure_pmf_finite (*‹finite (set_pmf ?M) ⟹ integrable (measure_pmf ?M) ?f›*)) (* convenient forms of library inequalities *) lemma spec_paley_zygmund_inequality: assumes fin: "finite (set_pmf p)" assumes Zpos: "⋀z. Z z ≥ 0" assumes t: "θ ≤ 1" shows " (measure_pmf.variance p Z + (1-θ)^2 * (measure_pmf.expectation p Z)^2) * measure_pmf.prob p {z. Z z > θ * measure_pmf.expectation p Z} ≥ (1-θ)^2 * (measure_pmf.expectation p Z)^2" proof (-) (*goal: ‹(1 - θ)² * (measure_pmf.expectation p Z)² ≤ (measure_pmf.expectation p (λx. (Z x - measure_pmf.expectation p Z)²) + (1 - θ)² * (measure_pmf.expectation p Z)²) * measure_pmf.prob p {z. θ * measure_pmf.expectation p Z < Z z}›*) have "prob_space (measure_pmf p)" by (auto simp add: prob_space_measure_pmf (*‹prob_space (measure_pmf ?p)›*)) from prob_space.paley_zygmund_inequality[OF this _ integrable_measure_pmf_finite [ OF fin ] t] (*‹⟦measure_pmf.random_variable p borel ?Z; ⋀z. z ∈ space (measure_pmf p) ⟹ 0 ≤ ?Z z⟧ ⟹ (1 - θ)² * (measure_pmf.expectation p ?Z)² ≤ (measure_pmf.expectation p (λx. (?Z x - measure_pmf.expectation p ?Z)²) + (1 - θ)² * (measure_pmf.expectation p ?Z)²) * measure_pmf.prob p {z ∈ space (measure_pmf p). θ * measure_pmf.expectation p ?Z < ?Z z}›*) show "?thesis" (*goal: ‹(1 - θ)² * (measure_pmf.expectation p Z)² ≤ (measure_pmf.expectation p (λx. (Z x - measure_pmf.expectation p Z)²) + (1 - θ)² * (measure_pmf.expectation p Z)²) * measure_pmf.prob p {z. θ * measure_pmf.expectation p Z < Z z}›*) using Zpos (*‹0 ≤ Z ?z›*) by auto qed lemma spec_chebyshev_inequality: assumes fin: "finite (set_pmf p)" assumes pvar: "measure_pmf.variance p Y > 0" assumes k: "k > 0" shows " measure_pmf.prob p {y. (Y y - measure_pmf.expectation p Y)^2 ≥ k^2 * measure_pmf.variance p Y} ≤ 1 / k^2" proof (-) (*goal: ‹measure_pmf.prob (p::'a::type pmf) {y::'a::type. (k::real)² * measure_pmf.expectation p (λx::'a::type. ((Y::'a::type ⇒ real) x - measure_pmf.expectation p Y)²) ≤ (Y y - measure_pmf.expectation p Y)²} ≤ (1::real) / k²›*) define f where "f x = Y x / sqrt(measure_pmf.variance p Y)" for x have 1: "measure_pmf.random_variable p borel f" by auto have "*": "(λx. (f x)²) = (λx. (Y x)²/ measure_pmf.variance p Y)" unfolding f_def (*goal: ‹(λx. (Y x / sqrt (measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²)))²) = (λx. (Y x)² / measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²))›*) by (simp add: power_divide (*‹((?a::?'a) / (?b::?'a)) ^ (?n::nat) = ?a ^ ?n / ?b ^ ?n›*)) have 2: "integrable p (λx. (f x)²)" unfolding "*" (*goal: ‹integrable (measure_pmf p) (λx. (Y x)² / measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²))›*) by (intro integrable_measure_pmf_finite[OF fin] (*‹integrable (measure_pmf p) ?f›*)) from measure_pmf.Chebyshev_inequality[OF 1 2 k] (*‹measure_pmf.prob p {x ∈ space (measure_pmf p). k ≤ ¦f x - measure_pmf.expectation p f¦} ≤ measure_pmf.expectation p (λx. (f x - measure_pmf.expectation p f)²) / k²›*) have ineq1: "measure_pmf.prob p {x . k ≤ ¦f x - measure_pmf.expectation p f¦} ≤ measure_pmf.expectation p (λx. (f x - measure_pmf.expectation p f)²) / k²" by auto have "(λx. (f x - measure_pmf.expectation p f)²) = (λx. ((Y x - measure_pmf.expectation p Y) / sqrt(measure_pmf.variance p Y))²)" unfolding f_def (*goal: ‹(λx. (Y x / sqrt (measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²)) - measure_pmf.expectation p (λx. Y x / sqrt (measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²))))²) = (λx. ((Y x - measure_pmf.expectation p Y) / sqrt (measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²)))²)›*) by (simp add: diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*)) moreover have "... = (λx. (Y x - measure_pmf.expectation p Y)^2 / (sqrt(measure_pmf.variance p Y))^2)" by (simp add: power_divide (*‹(?a / ?b) ^ ?n = ?a ^ ?n / ?b ^ ?n›*)) moreover have "... = (λx. (Y x - measure_pmf.expectation p Y)^2 / measure_pmf.variance p Y)" by simp ultimately have unfold: "(λx. (f x - measure_pmf.expectation p f)²) = (λx. (Y x - measure_pmf.expectation p Y)^2 / measure_pmf.variance p Y)" by auto then have "measure_pmf.expectation p (λx. (f x - measure_pmf.expectation p f)²) / k² = measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)^2 / measure_pmf.variance p Y) / k²" by auto moreover have "... = measure_pmf.variance p Y / measure_pmf.variance p Y / k²" by simp moreover have "... = 1 / k²" using pvar (*‹(0::real) < measure_pmf.expectation (p::'a::type pmf) (λx::'a::type. ((Y::'a::type ⇒ real) x - measure_pmf.expectation p Y)²)›*) by force ultimately have eq1: "measure_pmf.expectation p (λx. (f x - measure_pmf.expectation p f)²) / k² = 1 / k²" by auto have "(λx. k ≤ ¦f x - measure_pmf.expectation p f¦) = (λx. k² ≤ (f x - measure_pmf.expectation p f)²)" by (metis (no_types, opaque_lifting) abs_of_nonneg (*‹0 ≤ ?a ⟹ ¦?a¦ = ?a›*) k (*‹0 < k›*) less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*) real_le_rsqrt (*‹?x² ≤ ?y ⟹ ?x ≤ sqrt ?y›*) real_sqrt_abs (*‹sqrt (?x²) = ¦?x¦›*) sqrt_ge_absD (*‹¦?x¦ ≤ sqrt ?y ⟹ ?x² ≤ ?y›*)) moreover have "... = (λx. k² ≤ ((Y x - measure_pmf.expectation p Y)^2 / measure_pmf.variance p Y))" by (metis unfold (*‹(λx. (f x - measure_pmf.expectation p f)²) = (λx. (Y x - measure_pmf.expectation p Y)² / measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²))›*)) moreover have "... = (λx. (Y x - measure_pmf.expectation p Y)^2 ≥ k² * measure_pmf.variance p Y)" by (simp add: pos_le_divide_eq (*‹0 < ?c ⟹ (?a ≤ ?b / ?c) = (?a * ?c ≤ ?b)›*) pvar (*‹0 < measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²)›*)) ultimately have cond: "(λx. k ≤ ¦f x - measure_pmf.expectation p f¦) = (λx. (Y x - measure_pmf.expectation p Y)^2 ≥ k² * measure_pmf.variance p Y)" by auto show "?thesis" (*goal: ‹measure_pmf.prob p {y. k² * measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²) ≤ (Y y - measure_pmf.expectation p Y)²} ≤ 1 / k²›*) using ineq1 (*‹measure_pmf.prob p {x. k ≤ ¦f x - measure_pmf.expectation p f¦} ≤ measure_pmf.expectation p (λx. (f x - measure_pmf.expectation p f)²) / k²›*) cond (*‹(λx. k ≤ ¦f x - measure_pmf.expectation p f¦) = (λx. k² * measure_pmf.expectation p (λx. (Y x - measure_pmf.expectation p Y)²) ≤ (Y x - measure_pmf.expectation p Y)²)›*) eq1 (*‹measure_pmf.expectation p (λx. (f x - measure_pmf.expectation p f)²) / k² = 1 / k²›*) by auto qed end
{ "path": "afp-2025-02-12/thys/Approximate_Model_Counting/ApproxMCPreliminaries.thy", "repo": "afp-2025-02-12", "sha": "1990973f5dfe759c2735697f3966185f6f09f25462ccee44deb05bebc4f98ad5" }
section ‹Background material: the neighbours of vertices› text ‹Preliminaries for the Book Algorithm› theory Neighbours imports General_Extras "Ramsey_Bounds.Ramsey_Bounds" begin abbreviation set_difference :: "['a set,'a set] ⇒ 'a set" (infixl "∖" 65) where "A ∖ B ≡ A-B" subsection ‹Preliminaries on graphs› context ulgraph begin text ‹The set of \emph{undirected} edges between two sets› definition all_edges_betw_un :: "'a set ⇒ 'a set ⇒ 'a set set" where "all_edges_betw_un X Y ≡ {{x, y}| x y. x ∈ X ∧ y ∈ Y ∧ {x, y} ∈ E}" lemma all_edges_betw_un_commute1: "all_edges_betw_un X Y ⊆ all_edges_betw_un Y X" by (smt (verit, del_insts) Collect_mono (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x ⟶ (?Q::?'a ⇒ bool) x) ⟹ Collect ?P ⊆ Collect ?Q›*) all_edges_betw_un_def (*‹all_edges_betw_un (?X::'a set) (?Y::'a set) ≡ {{x, y} |(x::'a) y::'a. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) insert_commute (*‹insert (?x::?'a) (insert (?y::?'a) (?A::?'a set)) = insert ?y (insert ?x ?A)›*)) lemma all_edges_betw_un_commute: "all_edges_betw_un X Y = all_edges_betw_un Y X" by (simp add: all_edges_betw_un_commute1 (*‹all_edges_betw_un ?X ?Y ⊆ all_edges_betw_un ?Y ?X›*) subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*)) lemma all_edges_betw_un_iff_mk_edge: "all_edges_betw_un X Y = mk_edge ` all_edges_between X Y" using all_edges_between_set (*‹mk_edge ` all_edges_between (?X::'a::type set) (?Y::'a::type set) = {{x, y} |(x::'a::type) y::'a::type. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) by presburger lemma all_uedges_betw_subset: "all_edges_betw_un X Y ⊆ E" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_uedges_betw_I: "x ∈ X ⟹ y ∈ Y ⟹ {x, y} ∈ E ⟹ {x, y} ∈ all_edges_betw_un X Y" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_subset: "all_edges_betw_un X Y ⊆ Pow (X∪Y)" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_empty [simp]: "all_edges_betw_un {} Z = {}" "all_edges_betw_un Z {} = {}" (*goals: 1. ‹all_edges_betw_un {} Z = {}› 2. ‹all_edges_betw_un Z {} = {}› discuss goal 1*) apply ((auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*))[1]) (*discuss goal 2*) apply ((auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*))[1]) (*proven 2 subgoals*) . lemma card_all_uedges_betw_le: assumes "finite X" "finite Y" shows "card (all_edges_betw_un X Y) ≤ card (all_edges_between X Y)" by (simp add: all_edges_betw_un_iff_mk_edge (*‹all_edges_betw_un ?X ?Y = mk_edge ` all_edges_between ?X ?Y›*) assms (*‹finite X› ‹finite Y›*) card_image_le (*‹finite ?A ⟹ card (?f ` ?A) ≤ card ?A›*) finite_all_edges_between (*‹⟦finite ?X; finite ?Y⟧ ⟹ finite (all_edges_between ?X ?Y)›*)) lemma all_edges_betw_un_le: assumes "finite X" "finite Y" shows "card (all_edges_betw_un X Y) ≤ card X * card Y" by (meson assms (*‹finite X› ‹finite Y›*) card_all_uedges_betw_le (*‹⟦finite ?X; finite ?Y⟧ ⟹ card (all_edges_betw_un ?X ?Y) ≤ card (all_edges_between ?X ?Y)›*) max_all_edges_between (*‹⟦finite ?X; finite ?Y⟧ ⟹ card (all_edges_between ?X ?Y) ≤ card ?X * card ?Y›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) lemma all_edges_betw_un_insert1: "all_edges_betw_un (insert v X) Y = ({{v, y}| y. y ∈ Y} ∩ E) ∪ all_edges_betw_un X Y" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_insert2: "all_edges_betw_un X (insert v Y) = ({{x, v}| x. x ∈ X} ∩ E) ∪ all_edges_betw_un X Y" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un (?X::'a::type set) (?Y::'a::type set) ≡ {{x, y} |(x::'a::type) y::'a::type. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_Un1: "all_edges_betw_un (X ∪ Y) Z = all_edges_betw_un X Z ∪ all_edges_betw_un Y Z" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_Un2: "all_edges_betw_un X (Y ∪ Z) = all_edges_betw_un X Y ∪ all_edges_betw_un X Z" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma finite_all_edges_betw_un: assumes "finite X" "finite Y" shows "finite (all_edges_betw_un X Y)" by (simp add: all_edges_betw_un_iff_mk_edge (*‹all_edges_betw_un ?X ?Y = mk_edge ` all_edges_between ?X ?Y›*) assms (*‹finite X› ‹finite Y›*) finite_all_edges_between (*‹⟦finite ?X; finite ?Y⟧ ⟹ finite (all_edges_between ?X ?Y)›*)) lemma all_edges_betw_un_Union1: "all_edges_betw_un (Union 𝒳) Y = (⋃X∈𝒳. all_edges_betw_un X Y)" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un (?X::'a::type set) (?Y::'a::type set) ≡ {{x, y} |(x::'a::type) y::'a::type. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_Union2: "all_edges_betw_un X (Union 𝒴) = (⋃Y∈𝒴. all_edges_betw_un X Y)" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_mono1: "Y ⊆ Z ⟹ all_edges_betw_un Y X ⊆ all_edges_betw_un Z X" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma all_edges_betw_un_mono2: "Y ⊆ Z ⟹ all_edges_betw_un X Y ⊆ all_edges_betw_un X Z" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) lemma disjnt_all_edges_betw_un: assumes "disjnt X Y" "disjnt X Z" shows "disjnt (all_edges_betw_un X Z) (all_edges_betw_un Y Z)" using assms (*‹disjnt X Y› ‹disjnt (X::'a::type set) (Z::'a::type set)›*) by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) disjnt_iff (*‹disjnt ?A ?B = (∀x. ¬ (x ∈ ?A ∧ x ∈ ?B))›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) end subsection ‹Neighbours of a vertex› definition Neighbours :: "'a set set ⇒ 'a ⇒ 'a set" where "Neighbours ≡ λE x. {y. {x,y} ∈ E}" lemma in_Neighbours_iff: "y ∈ Neighbours E x ⟷ {x,y} ∈ E" by (simp add: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*)) lemma finite_Neighbours: assumes "finite E" shows "finite (Neighbours E x)" proof (-) (*goal: ‹finite (Neighbours E x)›*) have "Neighbours E x ⊆ Neighbours {X∈E. finite X} x" by (auto simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*)) also (*calculation: ‹Neighbours E x ⊆ Neighbours {X ∈ E. finite X} x›*) have "… ⊆ (⋃{X∈E. finite X})" by (meson Union_iff (*‹(?A ∈ ⋃ ?C) = (∃X∈?C. ?A ∈ X)›*) in_Neighbours_iff (*‹(?y ∈ Neighbours ?E ?x) = ({?x, ?y} ∈ ?E)›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) finally (*calculation: ‹Neighbours (E::'a::type set set) (x::'a::type) ⊆ ⋃ {X::'a::type set ∈ E. finite X}›*) show "?thesis" (*goal: ‹finite (Neighbours E x)›*) using assms (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by fastforce qed lemma (in fin_sgraph) not_own_Neighbour: "E' ⊆ E ⟹ x ∉ Neighbours E' x" by (force simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*) singleton_not_edge (*‹{?x} ∉ E›*)) context fin_sgraph begin declare singleton_not_edge [simp] text ‹"A graph on vertex set @{term"S ∪ T"} that contains all edges incident to @{term"S"}" (page 3). In fact, @{term S} is a clique and every vertex in @{term T} has an edge into @{term S}.› definition book :: "'a set ⇒ 'a set ⇒ 'a set set ⇒ bool" where "book ≡ λS T F. disjnt S T ∧ all_edges_betw_un S (S∪T) ⊆ F" text ‹Cliques of a given number of vertices; the definition of clique from Ramsey is used› definition size_clique :: "nat ⇒ 'a set ⇒ 'a set set ⇒ bool" where "size_clique p K F ≡ card K = p ∧ clique K F ∧ K ⊆ V" lemma size_clique_smaller: "⟦size_clique p K F; p' < p⟧ ⟹ ∃K'. size_clique p' K' F" unfolding size_clique_def (*goal: ‹⟦card K = p ∧ clique K F ∧ K ⊆ V; p' < p⟧ ⟹ ∃K'. card K' = p' ∧ clique K' F ∧ K' ⊆ V›*) by (meson card_Ex_subset (*‹?k ≤ card ?M ⟹ ∃N⊆?M. card N = ?k›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*) less_imp_le_nat (*‹?m < ?n ⟹ ?m ≤ ?n›*) smaller_clique (*‹⟦clique ?R ?E; ?R' ⊆ ?R⟧ ⟹ clique ?R' ?E›*)) subsection ‹Density: for calculating the parameter p› definition "edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)" definition "gen_density ≡ λC X Y. edge_card C X Y / (card X * card Y)" lemma edge_card_empty [simp]: "edge_card C {} X = 0" "edge_card C X {} = 0" (*goals: 1. ‹edge_card C {} X = 0› 2. ‹edge_card C X {} = 0› discuss goal 1*) apply ((auto simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*))[1]) (*discuss goal 2*) apply ((auto simp: edge_card_def (*‹edge_card ≡ λ(C::'a::type set set) (X::'a::type set) Y::'a::type set. card (C ∩ all_edges_betw_un X Y)›*))[1]) (*proven 2 subgoals*) . lemma edge_card_commute: "edge_card C X Y = edge_card C Y X" using all_edges_betw_un_commute (*‹all_edges_betw_un ?X ?Y = all_edges_betw_un ?Y ?X›*) edge_card_def (*‹edge_card ≡ λ(C::'a set set) (X::'a set) Y::'a set. card (C ∩ all_edges_betw_un X Y)›*) by presburger lemma edge_card_le: assumes "finite X" "finite Y" shows "edge_card C X Y ≤ card X * card Y" proof (-) (*goal: ‹edge_card C X Y ≤ card X * card Y›*) have "edge_card C X Y ≤ card (all_edges_betw_un X Y)" by (simp add: assms (*‹finite X› ‹finite Y›*) card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) finite_all_edges_betw_un (*‹⟦finite ?X; finite ?Y⟧ ⟹ finite (all_edges_betw_un ?X ?Y)›*)) then show "?thesis" (*goal: ‹edge_card C X Y ≤ card X * card Y›*) by (meson all_edges_betw_un_le (*‹⟦finite ?X; finite ?Y⟧ ⟹ card (all_edges_betw_un ?X ?Y) ≤ card ?X * card ?Y›*) assms (*‹finite X› ‹finite Y›*) le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*)) qed text ‹the assumption that @{term Z} is disjoint from @{term X} (or @{term Y}) is necessary› lemma edge_card_Un: assumes "disjnt X Y" "disjnt X Z" "finite X" "finite Y" shows "edge_card C (X ∪ Y) Z = edge_card C X Z + edge_card C Y Z" proof (-) (*goal: ‹edge_card (C::'a::type set set) ((X::'a::type set) ∪ (Y::'a::type set)) (Z::'a::type set) = edge_card C X Z + edge_card C Y Z›*) have [simp]: "finite (all_edges_betw_un U Z)" for U by (meson all_uedges_betw_subset (*‹all_edges_betw_un ?X ?Y ⊆ E›*) fin_edges (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) have "disjnt (C ∩ all_edges_betw_un X Z) (C ∩ all_edges_betw_un Y Z)" using assms (*‹disjnt X Y› ‹disjnt X Z› ‹finite X› ‹finite Y›*) by (meson Int_iff (*‹((?c::?'a::type) ∈ (?A::?'a::type set) ∩ (?B::?'a::type set)) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) disjnt_all_edges_betw_un (*‹⟦disjnt (?X::'a::type set) (?Y::'a::type set); disjnt ?X (?Z::'a::type set)⟧ ⟹ disjnt (all_edges_betw_un ?X ?Z) (all_edges_betw_un ?Y ?Z)›*) disjnt_iff (*‹disjnt (?A::?'a::type set) (?B::?'a::type set) = (∀x::?'a::type. ¬ (x ∈ ?A ∧ x ∈ ?B))›*)) then show "?thesis" (*goal: ‹edge_card C (X ∪ Y) Z = edge_card C X Z + edge_card C Y Z›*) by (simp add: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) card_Un_disjnt (*‹⟦finite ?A; finite ?B; disjnt ?A ?B⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) all_edges_betw_un_Un1 (*‹all_edges_betw_un (?X ∪ ?Y) ?Z = all_edges_betw_un ?X ?Z ∪ all_edges_betw_un ?Y ?Z›*) Int_Un_distrib (*‹?A ∩ (?B ∪ ?C) = ?A ∩ ?B ∪ ?A ∩ ?C›*)) qed lemma edge_card_diff: assumes "Y⊆X" "disjnt X Z" "finite X" shows "edge_card C (X-Y) Z = edge_card C X Z - edge_card C Y Z" proof (-) (*goal: ‹edge_card (C::'a set set) ((X::'a set) ∖ (Y::'a set)) (Z::'a set) = edge_card C X Z - edge_card C Y Z›*) have "(X∖Y) ∪ Y = X" "disjnt (X∖Y) Y" (*goals: 1. ‹X ∖ Y ∪ Y = X› 2. ‹disjnt (X ∖ Y) Y› discuss goal 1*) apply ((auto simp: Un_absorb2 (*‹?B ⊆ ?A ⟹ ?A ∪ ?B = ?A›*) assms (*‹Y ⊆ X› ‹disjnt X Z› ‹finite X›*) disjnt_iff (*‹disjnt ?A ?B = (∀x. ¬ (x ∈ ?A ∧ x ∈ ?B))›*))[1]) (*discuss goal 2*) apply ((auto simp: Un_absorb2 (*‹(?B::?'a::type set) ⊆ (?A::?'a::type set) ⟹ ?A ∪ ?B = ?A›*) assms (*‹(Y::'a::type set) ⊆ (X::'a::type set)› ‹disjnt (X::'a::type set) (Z::'a::type set)› ‹finite (X::'a::type set)›*) disjnt_iff (*‹disjnt (?A::?'a::type set) (?B::?'a::type set) = (∀x::?'a::type. ¬ (x ∈ ?A ∧ x ∈ ?B))›*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹edge_card C (X ∖ Y) Z = edge_card C X Z - edge_card C Y Z›*) by (metis add_diff_cancel_right' (*‹?a + ?b - ?b = ?a›*) assms (*‹Y ⊆ X› ‹disjnt X Z› ‹finite X›*) disjnt_Un1 (*‹disjnt (?A ∪ ?B) ?C = (disjnt ?A ?C ∧ disjnt ?B ?C)›*) edge_card_Un (*‹⟦disjnt ?X ?Y; disjnt ?X ?Z; finite ?X; finite ?Y⟧ ⟹ edge_card ?C (?X ∪ ?Y) ?Z = edge_card ?C ?X ?Z + edge_card ?C ?Y ?Z›*) finite_Diff (*‹finite ?A ⟹ finite (?A ∖ ?B)›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed lemma edge_card_mono: assumes "Y⊆X" shows "edge_card C Y Z ≤ edge_card C X Z" unfolding edge_card_def (*goal: ‹card (C ∩ all_edges_betw_un Y Z) ≤ card (C ∩ all_edges_betw_un X Z)›*) proof (intro card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*)) (*goals: 1. ‹finite (C ∩ all_edges_betw_un X Z)› 2. ‹C ∩ all_edges_betw_un Y Z ⊆ C ∩ all_edges_betw_un X Z›*) show "finite (C ∩ all_edges_betw_un X Z)" by (meson all_uedges_betw_subset (*‹all_edges_betw_un ?X ?Y ⊆ E›*) fin_edges (*‹finite E›*) finite_Int (*‹finite ?F ∨ finite ?G ⟹ finite (?F ∩ ?G)›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) show "C ∩ all_edges_betw_un Y Z ⊆ C ∩ all_edges_betw_un X Z" by (meson Int_mono (*‹⟦?A ⊆ ?C; ?B ⊆ ?D⟧ ⟹ ?A ∩ ?B ⊆ ?C ∩ ?D›*) all_edges_betw_un_mono1 (*‹?Y ⊆ ?Z ⟹ all_edges_betw_un ?Y ?X ⊆ all_edges_betw_un ?Z ?X›*) assms (*‹Y ⊆ X›*) subset_refl (*‹?A ⊆ ?A›*)) qed lemma edge_card_eq_sum_Neighbours: assumes "C⊆E" and B: "finite B" "disjnt A B" shows "edge_card C A B = (∑i∈B. card (Neighbours C i ∩ A))" using B (*‹finite B› ‹disjnt A B›*) proof (induction B) (*goals: 1. ‹disjnt A {} ⟹ edge_card C A {} = (∑i∈{}. card (Neighbours C i ∩ A))› 2. ‹⋀x F. ⟦finite F; x ∉ F; disjnt A F ⟹ edge_card C A F = (∑i∈F. card (Neighbours C i ∩ A)); disjnt A (insert x F)⟧ ⟹ edge_card C A (insert x F) = (∑i∈insert x F. card (Neighbours C i ∩ A))›*) case empty (*‹disjnt (A::'a set) {}›*) then show "?case" (*goal: ‹edge_card C A {} = (∑i∈{}. card (Neighbours C i ∩ A))›*) by (auto simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*)) next (*goal: ‹⋀(x::'a::type) F::'a::type set. ⟦finite F; x ∉ F; disjnt (A::'a::type set) F ⟹ edge_card (C::'a::type set set) A F = (∑i::'a::type∈F. card (Neighbours C i ∩ A)); disjnt A (insert x F)⟧ ⟹ edge_card C A (insert x F) = (∑i::'a::type∈insert x F. card (Neighbours C i ∩ A))›*) case (insert b B) (*‹finite B› ‹b ∉ B› ‹disjnt A B ⟹ edge_card C A B = (∑i∈B. card (Neighbours C i ∩ A))› ‹disjnt A (insert b B)›*) have "finite C" using assms(1) (*‹(C::'a set set) ⊆ E›*) fin_edges (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast have bij: "bij_betw (λe. the_elem(e-{b})) (C ∩ {{x, b} |x. x ∈ A}) (Neighbours C b ∩ A)" unfolding bij_betw_def (*goal: ‹inj_on (λe. the_elem (e ∖ {b})) (C ∩ {{x, b} |x. x ∈ A}) ∧ (λe. the_elem (e ∖ {b})) ` (C ∩ {{x, b} |x. x ∈ A}) = Neighbours C b ∩ A›*) proof (standard) (*goals: 1. ‹inj_on (λe. the_elem (e ∖ {b})) (C ∩ {{x, b} |x. x ∈ A})› 2. ‹(λe. the_elem (e ∖ {b})) ` (C ∩ {{x, b} |x. x ∈ A}) = Neighbours C b ∩ A›*) have [simp]: "the_elem ({x, b} - {b}) = x" if "x ∈ A" for x using insert.prems (*‹disjnt (A::'a set) (insert (b::'a) (B::'a set))›*) by (simp add: disjnt_iff (*‹disjnt ?A ?B = (∀x. ¬ (x ∈ ?A ∧ x ∈ ?B))›*) insert_Diff_if (*‹insert ?x ?A ∖ ?B = (if ?x ∈ ?B then ?A ∖ ?B else insert ?x (?A ∖ ?B))›*) that (*‹x ∈ A›*)) show "inj_on (λe. the_elem (e - {b})) (C ∩ {{x, b} |x. x ∈ A})" by (auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*)) show "(λe. the_elem (e - {b})) ` (C ∩ {{x, b} |x. x ∈ A}) = Neighbours C b ∩ A" by (fastforce simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*)) qed have "(C ∩ all_edges_betw_un A (insert b B)) = (C ∩ ({{x, b} |x. x ∈ A} ∪ all_edges_betw_un A B))" using ‹C ⊆ E› (*‹(C::'a set set) ⊆ E›*) by (auto simp: all_edges_betw_un_insert2 (*‹all_edges_betw_un ?X (insert ?v ?Y) = {{x, ?v} |x. x ∈ ?X} ∩ E ∪ all_edges_betw_un ?X ?Y›*)) then have "edge_card C A (insert b B) = card ((C ∩ ({{x,b} |x. x ∈ A}) ∪ (C ∩ all_edges_betw_un A B)))" by (simp add: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) Int_Un_distrib (*‹?A ∩ (?B ∪ ?C) = ?A ∩ ?B ∪ ?A ∩ ?C›*)) also (*calculation: ‹edge_card C A (insert b B) = card (C ∩ {{x, b} |x. x ∈ A} ∪ C ∩ all_edges_betw_un A B)›*) have "… = card (C ∩ {{x,b} |x. x ∈ A}) + card (C ∩ all_edges_betw_un A B)" proof (rule card_Un_disjnt (*‹⟦finite ?A; finite ?B; disjnt ?A ?B⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*)) (*goals: 1. ‹finite (C ∩ {{x, b} |x. x ∈ A})› 2. ‹finite (C ∩ all_edges_betw_un A B)› 3. ‹disjnt (C ∩ {{x, b} |x. x ∈ A}) (C ∩ all_edges_betw_un A B)›*) show "disjnt (C ∩ {{x, b} |x. x ∈ A}) (C ∩ all_edges_betw_un A B)" using insert (*‹finite B› ‹b ∉ B› ‹disjnt A B ⟹ edge_card C A B = (∑i∈B. card (Neighbours C i ∩ A))› ‹disjnt (A::'a set) (insert (b::'a) (B::'a set))›*) by (auto simp: disjnt_iff (*‹disjnt ?A ?B = (∀x. ¬ (x ∈ ?A ∧ x ∈ ?B))›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) qed (use ‹finite C› in auto) (*solves the remaining goals: 1. ‹finite (C ∩ {{x, b} |x. x ∈ A})› 2. ‹finite (C ∩ all_edges_betw_un A B)›*) also (*calculation: ‹edge_card C A (insert b B) = card (C ∩ {{x, b} |x. x ∈ A}) + card (C ∩ all_edges_betw_un A B)›*) have "… = card (Neighbours C b ∩ A) + card (C ∩ all_edges_betw_un A B)" using bij_betw_same_card[OF bij] (*‹card ((C::'a::type set set) ∩ {{x, b::'a::type} |x::'a::type. x ∈ (A::'a::type set)}) = card (Neighbours C b ∩ A)›*) by simp also (*calculation: ‹edge_card C A (insert b B) = card (Neighbours C b ∩ A) + card (C ∩ all_edges_betw_un A B)›*) have "… = (∑i∈insert b B. card (Neighbours C i ∩ A))" using insert (*‹finite B› ‹b ∉ B› ‹disjnt A B ⟹ edge_card C A B = (∑i∈B. card (Neighbours C i ∩ A))› ‹disjnt A (insert b B)›*) by (simp add: edge_card_def (*‹edge_card ≡ λ(C::'a::type set set) (X::'a::type set) Y::'a::type set. card (C ∩ all_edges_betw_un X Y)›*)) finally (*calculation: ‹edge_card C A (insert b B) = (∑i∈insert b B. card (Neighbours C i ∩ A))›*) show "?case" (*goal: ‹edge_card (C::'a::type set set) (A::'a::type set) (insert (b::'a::type) (B::'a::type set)) = (∑i::'a::type∈insert b B. card (Neighbours C i ∩ A))›*) . qed lemma sum_eq_card: "finite A ⟹ (∑x ∈ A. if x ∈ B then 1 else 0) = card (A∩B)" by (metis (no_types, lifting) card_eq_sum (*‹card ?A = (∑x∈?A. 1)›*) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*) sum.inter_restrict (*‹finite ?A ⟹ sum ?g (?A ∩ ?B) = (∑x∈?A. if x ∈ ?B then ?g x else 0)›*)) lemma sum_eq_card_Neighbours: assumes "x ∈ V" "C ⊆ E" shows "(∑y ∈ V∖{x}. if {x,y} ∈ C then 1 else 0) = card (Neighbours C x)" proof (-) (*goal: ‹(∑y∈V ∖ {x}. if {x, y} ∈ C then 1 else 0) = card (Neighbours C x)›*) have "Neighbours C x = (V ∖ {x}) ∩ {y. {x, y} ∈ C}" using assms (*‹x ∈ V› ‹C ⊆ E›*) wellformed (*‹(?e::'a set) ∈ E ⟹ ?e ⊆ V›*) by (auto simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*)) with finV (*‹finite V›*) sum_eq_card[of _ "{y. {x,y}∈C}"] (*‹finite ?A ⟹ (∑xa∈?A. if xa ∈ {y. {x, y} ∈ C} then 1 else 0) = card (?A ∩ {y. {x, y} ∈ C})›*) show "?thesis" (*goal: ‹(∑y∈V ∖ {x}. if {x, y} ∈ C then 1 else 0) = card (Neighbours C x)›*) by simp qed lemma Neighbours_insert_NO_MATCH: "NO_MATCH {} C ⟹ Neighbours (insert e C) x = Neighbours {e} x ∪ Neighbours C x" by (auto simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*)) lemma Neighbours_sing_2: assumes "e ∈ E" shows "(∑x∈V. card (Neighbours {e} x)) = 2" proof (-) (*goal: ‹(∑x∈V. card (Neighbours {e} x)) = 2›*) obtain u and v where uv: "e = {u,v}" "u≠v" (*goal: ‹(⋀u v. ⟦e = {u, v}; u ≠ v⟧ ⟹ thesis) ⟹ thesis›*) by (meson assms (*‹e ∈ E›*) card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) two_edges (*‹?e ∈ E ⟹ card ?e = 2›*)) then have "u ∈ V" "v ∈ V" using assms (*‹e ∈ E›*) wellformed (*‹?e ∈ E ⟹ ?e ⊆ V›*) uv (*‹e = {u, v}› ‹(u::'a) ≠ (v::'a)›*) apply - (*goals: 1. ‹⟦e = {u, v}; u ≠ v; e ∈ E; ⋀e. e ∈ E ⟹ e ⊆ V; e = {u, v}; u ≠ v⟧ ⟹ u ∈ V› 2. ‹⟦e = {u, v}; u ≠ v; e ∈ E; ⋀e. e ∈ E ⟹ e ⊆ V; e = {u, v}; u ≠ v⟧ ⟹ v ∈ V› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "*": "Neighbours {e} x = (if x=u then {v} else if x=v then {u} else {})" for x by (auto simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*) uv (*‹e = {u, v}› ‹u ≠ v›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) show "?thesis" (*goal: ‹(∑x∈V. card (Neighbours {e} x)) = 2›*) using ‹u≠v› (*‹u ≠ v›*) by (simp add: * (*‹Neighbours {e} ?x = (if ?x = u then {v} else if ?x = v then {u} else {})›*) if_distrib [of card] (*‹card (if ?c then ?x else ?y) = (if ?c then card ?x else card ?y)›*) finV (*‹finite V›*) sum.delta_remove (*‹finite ?S ⟹ (∑k∈?S. if k = ?a then ?b k else ?c k) = (if ?a ∈ ?S then ?b ?a + sum ?c (?S ∖ {?a}) else sum ?c (?S ∖ {?a}))›*) ‹u ∈ V› ‹v ∈ V› cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) qed lemma sum_Neighbours_eq_card: assumes "finite C" "C⊆E" shows "(∑i∈V. card (Neighbours C i)) = card C * 2" using assms (*‹finite C› ‹C ⊆ E›*) proof (induction C) (*goals: 1. ‹{} ⊆ E ⟹ (∑i∈V. card (Neighbours {} i)) = card {} * 2› 2. ‹⋀x F. ⟦finite F; x ∉ F; F ⊆ E ⟹ (∑i∈V. card (Neighbours F i)) = card F * 2; insert x F ⊆ E⟧ ⟹ (∑i∈V. card (Neighbours (insert x F) i)) = card (insert x F) * 2›*) case empty (*‹{} ⊆ E›*) then show "?case" (*goal: ‹(∑i∈V. card (Neighbours {} i)) = card {} * 2›*) by (auto simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*)) next (*goal: ‹⋀x F. ⟦finite F; x ∉ F; F ⊆ E ⟹ (∑i∈V. card (Neighbours F i)) = card F * 2; insert x F ⊆ E⟧ ⟹ (∑i∈V. card (Neighbours (insert x F) i)) = card (insert x F) * 2›*) case (insert e C) (*‹finite (C::'a::type set set)› ‹e ∉ C› ‹C ⊆ E ⟹ (∑i∈V. card (Neighbours C i)) = card C * 2› ‹insert e C ⊆ E›*) then have [simp]: "Neighbours {e} x ∩ Neighbours C x = {}" for x by (auto simp: Neighbours_def (*‹Neighbours ≡ λE x. {y. {x, y} ∈ E}›*)) with insert (*‹finite (C::'a set set)› ‹e ∉ C› ‹C ⊆ E ⟹ (∑i∈V. card (Neighbours C i)) = card C * 2› ‹insert e C ⊆ E›*) show "?case" (*goal: ‹(∑i∈V. card (Neighbours (insert e C) i)) = card (insert e C) * 2›*) by (auto simp: card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) finite_Neighbours (*‹finite ?E ⟹ finite (Neighbours ?E ?x)›*) Neighbours_insert_NO_MATCH (*‹NO_MATCH {} ?C ⟹ Neighbours (insert ?e ?C) ?x = Neighbours {?e} ?x ∪ Neighbours ?C ?x›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) Neighbours_sing_2 (*‹?e ∈ E ⟹ (∑x∈V. card (Neighbours {?e} x)) = 2›*)) qed lemma gen_density_empty [simp]: "gen_density C {} X = 0" "gen_density C X {} = 0" (*goals: 1. ‹gen_density C {} X = 0› 2. ‹gen_density C X {} = 0› discuss goal 1*) apply ((auto simp: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*))[1]) (*discuss goal 2*) apply ((auto simp: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*))[1]) (*proven 2 subgoals*) . lemma gen_density_commute: "gen_density C X Y = gen_density C Y X" by (simp add: edge_card_commute (*‹edge_card ?C ?X ?Y = edge_card ?C ?Y ?X›*) gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*)) lemma gen_density_ge0: "gen_density C X Y ≥ 0" by (auto simp: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*)) lemma gen_density_gt0: assumes "finite X" "finite Y" "{x,y} ∈ C" "x ∈ X" "y ∈ Y" "C ⊆ E" shows "gen_density C X Y > 0" proof (-) (*goal: ‹0 < gen_density C X Y›*) have xy: "{x,y} ∈ all_edges_betw_un X Y" using assms (*‹finite X› ‹finite Y› ‹{x, y} ∈ C› ‹(x::'a::type) ∈ (X::'a::type set)› ‹y ∈ Y› ‹C ⊆ E›*) by (force simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) moreover have "finite (all_edges_betw_un X Y)" by (simp add: assms (*‹finite X› ‹finite Y› ‹{x, y} ∈ C› ‹x ∈ X› ‹y ∈ Y› ‹C ⊆ E›*) finite_all_edges_betw_un (*‹⟦finite ?X; finite ?Y⟧ ⟹ finite (all_edges_betw_un ?X ?Y)›*)) ultimately have "edge_card C X Y > 0" by (metis IntI (*‹⟦(?c::?'a::type) ∈ (?A::?'a::type set); ?c ∈ (?B::?'a::type set)⟧ ⟹ ?c ∈ ?A ∩ ?B›*) assms( (*‹{x::'a::type, y::'a::type} ∈ (C::'a::type set set)›*) 3) card_0_eq (*‹finite (?A::?'a::type set) ⟹ (card ?A = (0::nat)) = (?A = {})›*) edge_card_def (*‹edge_card ≡ λ(C::'a::type set set) (X::'a::type set) Y::'a::type set. card (C ∩ all_edges_betw_un X Y)›*) emptyE (*‹(?a::?'a::type) ∈ {} ⟹ ?P::bool›*) finite_Int (*‹finite (?F::?'a::type set) ∨ finite (?G::?'a::type set) ⟹ finite (?F ∩ ?G)›*) gr0I (*‹((?n::nat) = (0::nat) ⟹ False) ⟹ (0::nat) < ?n›*)) with xy (*‹{x, y} ∈ all_edges_betw_un X Y›*) show "?thesis" (*goal: ‹0 < gen_density C X Y›*) using assms (*‹finite X› ‹finite Y› ‹{x::'a::type, y::'a::type} ∈ (C::'a::type set set)› ‹x ∈ X› ‹(y::'a) ∈ (Y::'a set)› ‹C ⊆ E›*) gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*) less_eq_real_def (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) by fastforce qed lemma gen_density_le1: "gen_density C X Y ≤ 1" unfolding gen_density_def (*goal: ‹real (edge_card C X Y) / real (card X * card Y) ≤ 1›*) by (smt (verit) card.infinite (*‹infinite (?A::?'a set) ⟹ card ?A = (0::nat)›*) divide_le_eq_1 (*‹((?b::?'a) / (?a::?'a) ≤ (1::?'a)) = ((0::?'a) < ?a ∧ ?b ≤ ?a ∨ ?a < (0::?'a) ∧ ?a ≤ ?b ∨ ?a = (0::?'a))›*) edge_card_le (*‹⟦finite (?X::'a set); finite (?Y::'a set)⟧ ⟹ edge_card (?C::'a set set) ?X ?Y ≤ card ?X * card ?Y›*) mult_eq_0_iff (*‹((?a::?'a) * (?b::?'a) = (0::?'a)) = (?a = (0::?'a) ∨ ?b = (0::?'a))›*) of_nat_le_0_iff (*‹(of_nat (?m::nat) ≤ (0::?'a)) = (?m = (0::nat))›*) of_nat_mono (*‹(?i::nat) ≤ (?j::nat) ⟹ of_nat ?i ≤ of_nat ?j›*)) lemma gen_density_le_1_minus: shows "gen_density C X Y ≤ 1 - gen_density (E-C) X Y" proof (cases "finite X ∧ finite Y") (*goals: 1. ‹finite X ∧ finite Y ⟹ gen_density C X Y ≤ 1 - gen_density (E ∖ C) X Y› 2. ‹¬ (finite X ∧ finite Y) ⟹ gen_density C X Y ≤ 1 - gen_density (E ∖ C) X Y›*) case True (*‹finite X ∧ finite Y›*) have "C ∩ all_edges_betw_un X Y ∪ (E - C) ∩ all_edges_betw_un X Y = all_edges_betw_un X Y" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) with True (*‹finite X ∧ finite Y›*) have "(edge_card C X Y) + (edge_card (E - C) X Y) ≤ card (all_edges_betw_un X Y)" unfolding edge_card_def (*goal: ‹card ((C::'a set set) ∩ all_edges_betw_un (X::'a set) (Y::'a set)) + card ((E ∖ C) ∩ all_edges_betw_un X Y) ≤ card (all_edges_betw_un X Y)›*) by (metis Diff_Int_distrib2 (*‹(?A ∖ ?B) ∩ ?C = ?A ∩ ?C ∖ ?B ∩ ?C›*) Diff_disjoint (*‹?A ∩ (?B ∖ ?A) = {}›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) card_Un_le (*‹card (?A ∪ ?B) ≤ card ?A + card ?B›*) finite_Int (*‹finite ?F ∨ finite ?G ⟹ finite (?F ∩ ?G)›*) finite_all_edges_betw_un (*‹⟦finite ?X; finite ?Y⟧ ⟹ finite (all_edges_betw_un ?X ?Y)›*)) with True (*‹finite (X::'a::type set) ∧ finite (Y::'a::type set)›*) show "?thesis" (*goal: ‹gen_density C X Y ≤ 1 - gen_density (E ∖ C) X Y›*) apply (simp add: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) (*goal: ‹gen_density C X Y ≤ 1 - gen_density (E ∖ C) X Y›*) by (smt (verit) all_edges_betw_un_le (*‹⟦finite ?X; finite ?Y⟧ ⟹ card (all_edges_betw_un ?X ?Y) ≤ card ?X * card ?Y›*) of_nat_add (*‹of_nat (?m + ?n) = of_nat ?m + of_nat ?n›*) of_nat_mono (*‹?i ≤ ?j ⟹ of_nat ?i ≤ of_nat ?j›*) of_nat_mult (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*)) qed (auto simp: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*)) (*solved the remaining goal: ‹¬ (finite X ∧ finite Y) ⟹ gen_density C X Y ≤ 1 - gen_density (E ∖ C) X Y›*) lemma gen_density_lt1: assumes "{x,y} ∈ E-C" "x ∈ X" "y ∈ Y" "C ⊆ E" shows "gen_density C X Y < 1" proof (cases "finite X ∧ finite Y") (*goals: 1. ‹finite (X::'a set) ∧ finite (Y::'a set) ⟹ gen_density (C::'a set set) X Y < (1::real)› 2. ‹¬ (finite (X::'a set) ∧ finite (Y::'a set)) ⟹ gen_density (C::'a set set) X Y < (1::real)›*) case True (*‹finite X ∧ finite Y›*) then have "0 < gen_density (E - C) X Y" using assms (*‹{x, y} ∈ E ∖ C› ‹x ∈ X› ‹y ∈ Y› ‹C ⊆ E›*) gen_density_gt0 (*‹⟦finite ?X; finite ?Y; {?x, ?y} ∈ ?C; ?x ∈ ?X; ?y ∈ ?Y; ?C ⊆ E⟧ ⟹ 0 < gen_density ?C ?X ?Y›*) by auto have "gen_density C X Y ≤ 1 - gen_density (E - C) X Y" by (intro gen_density_le_1_minus (*‹gen_density ?C ?X ?Y ≤ 1 - gen_density (E ∖ ?C) ?X ?Y›*)) then show "?thesis" (*goal: ‹gen_density C X Y < 1›*) using ‹0 < gen_density (E - C) X Y› (*‹0 < gen_density (E ∖ C) X Y›*) by linarith qed (auto simp: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*)) (*solved the remaining goal: ‹¬ (finite X ∧ finite Y) ⟹ gen_density C X Y < 1›*) lemma gen_density_le_iff: assumes "disjnt X Z" "finite X" "Y⊆X" "Y ≠ {}" "finite Z" shows "gen_density C X Z ≤ gen_density C Y Z ⟷ edge_card C X Z / card X ≤ edge_card C Y Z / card Y" using assms (*‹disjnt X Z› ‹finite X› ‹Y ⊆ X› ‹Y ≠ {}› ‹finite Z›*) by (simp add: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) mult_less_0_iff (*‹(?a * ?b < 0) = (0 < ?a ∧ ?b < 0 ∨ ?a < 0 ∧ 0 < ?b)›*) zero_less_mult_iff (*‹(0 < ?a * ?b) = (0 < ?a ∧ 0 < ?b ∨ ?a < 0 ∧ ?b < 0)›*)) text ‹"Removing vertices whose degree is less than the average can only increase the density from the remaining set" (page 17) › lemma gen_density_below_avg_ge: assumes "disjnt X Z" "finite X" "Y⊂X" "finite Z" and genY: "gen_density C Y Z ≤ gen_density C X Z" shows "gen_density C (X-Y) Z ≥ gen_density C X Z" proof (-) (*goal: ‹gen_density (C::'a set set) (X::'a set) (Z::'a set) ≤ gen_density C (X ∖ (Y::'a set)) Z›*) have "real (edge_card C Y Z) / card Y ≤ real (edge_card C X Z) / card X" using assms (*‹disjnt (X::'a::type set) (Z::'a::type set)› ‹finite X› ‹(Y::'a set) ⊂ (X::'a set)› ‹finite (Z::'a set)› ‹gen_density C Y Z ≤ gen_density C X Z›*) by (force simp: gen_density_def (*‹gen_density ≡ λ(C::'a::type set set) (X::'a::type set) Y::'a::type set. real (edge_card C X Y) / real (card X * card Y)›*) divide_simps (*‹inverse (?a::?'a::division_ring) = (1::?'a::division_ring) / ?a› ‹(?a::?'a::division_ring) + (?b::?'a::division_ring) / (?z::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a::division_ring) / (?z::?'a::division_ring) + (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a::division_ring) / (?z::?'a::division_ring)) + (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a::division_ring) - (?b::?'a::division_ring) / (?z::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a::division_ring) / (?z::?'a::division_ring) - (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a::division_ring) / (?z::?'a::division_ring)) - (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a::division_ring) / (?c::?'a::division_ring) = (?a::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then ?b = ?a * ?c else ?a = (0::?'a::division_ring))› ‹((?a::?'a::division_ring) = (?b::?'a::division_ring) / (?c::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then ?a * ?c = ?b else ?a = (0::?'a::division_ring))› ‹(- ((?b::?'a::division_ring) / (?c::?'a::division_ring)) = (?a::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then - ?b = ?a * ?c else ?a = (0::?'a::division_ring))› ‹((?a::?'a::division_ring) = - ((?b::?'a::division_ring) / (?c::?'a::division_ring))) = (if ?c ≠ (0::?'a::division_ring) then ?a * ?c = - ?b else ?a = (0::?'a::division_ring))› ‹((?a::?'a::linordered_field) ≤ (?b::?'a::linordered_field) / (?c::?'a::linordered_field)) = (if (0::?'a::linordered_field) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a::linordered_field) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a::linordered_field))› and more 13 facts*) zero_less_mult_iff (*‹((0::?'a::linordered_ring_strict) < (?a::?'a::linordered_ring_strict) * (?b::?'a::linordered_ring_strict)) = ((0::?'a::linordered_ring_strict) < ?a ∧ (0::?'a::linordered_ring_strict) < ?b ∨ ?a < (0::?'a::linordered_ring_strict) ∧ ?b < (0::?'a::linordered_ring_strict))›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) have "card Y < card X" by (simp add: assms (*‹disjnt (X::'a set) (Z::'a set)› ‹finite (X::'a set)› ‹(Y::'a set) ⊂ (X::'a set)› ‹finite (Z::'a set)› ‹gen_density (C::'a set set) (Y::'a set) (Z::'a set) ≤ gen_density C (X::'a set) Z›*) psubset_card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) have "*": "finite Y" "Y ⊆ X" "X≠{}" using assms (*‹disjnt X Z› ‹finite (X::'a set)› ‹Y ⊂ X› ‹finite Z› ‹gen_density C Y Z ≤ gen_density C X Z›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) apply - (*goals: 1. ‹⟦disjnt X Z; finite X; Y ⊂ X; finite Z; gen_density C Y Z ≤ gen_density C X Z; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ finite Y› 2. ‹⟦disjnt X Z; finite X; Y ⊂ X; finite Z; gen_density C Y Z ≤ gen_density C X Z; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ Y ⊆ X› 3. ‹⟦disjnt X Z; finite X; Y ⊂ X; finite Z; gen_density C Y Z ≤ gen_density C X Z; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ X ≠ {}› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*proven 3 subgoals*) . then have "card X * edge_card C Y Z ≤ card Y * edge_card C X Z" using genY (*‹gen_density C Y Z ≤ gen_density C X Z›*) assms (*‹disjnt (X::'a set) (Z::'a set)› ‹finite (X::'a set)› ‹Y ⊂ X› ‹finite Z› ‹gen_density C Y Z ≤ gen_density C X Z›*) by (simp add: gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*) field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*) card_eq_0_iff (*‹(card ?A = 0) = (?A = {} ∨ infinite ?A)›*) flip: of_nat_mult (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) with assms (*‹disjnt (X::'a set) (Z::'a set)› ‹finite X› ‹Y ⊂ X› ‹finite Z› ‹gen_density (C::'a set set) (Y::'a set) (Z::'a set) ≤ gen_density C (X::'a set) Z›*) "*" (*‹finite Y› ‹Y ⊆ X› ‹X ≠ {}›*) ‹card Y < card X› (*‹card Y < card X›*) show "?thesis" (*goal: ‹gen_density C X Z ≤ gen_density C (X ∖ Y) Z›*) by (simp add: gen_density_le_iff (*‹⟦disjnt ?X ?Z; finite ?X; ?Y ⊆ ?X; ?Y ≠ {}; finite ?Z⟧ ⟹ (gen_density ?C ?X ?Z ≤ gen_density ?C ?Y ?Z) = (real (edge_card ?C ?X ?Z) / real (card ?X) ≤ real (edge_card ?C ?Y ?Z) / real (card ?Y))›*) field_split_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 65 facts*) edge_card_diff (*‹⟦?Y ⊆ ?X; disjnt ?X ?Z; finite ?X⟧ ⟹ edge_card ?C (?X ∖ ?Y) ?Z = edge_card ?C ?X ?Z - edge_card ?C ?Y ?Z›*) card_Diff_subset (*‹⟦finite ?B; ?B ⊆ ?A⟧ ⟹ card (?A ∖ ?B) = card ?A - card ?B›*) edge_card_mono (*‹?Y ⊆ ?X ⟹ edge_card ?C ?Y ?Z ≤ edge_card ?C ?X ?Z›*) flip: of_nat_mult (*‹of_nat (?m * ?n) = of_nat ?m * of_nat ?n›*)) qed lemma edge_card_insert: assumes "NO_MATCH {} F" and "e ∉ F" shows "edge_card (insert e F) X Y = edge_card {e} X Y + edge_card F X Y" proof (-) (*goal: ‹edge_card (insert e F) X Y = edge_card {e} X Y + edge_card F X Y›*) have fin: "finite (all_edges_betw_un X Y)" by (meson all_uedges_betw_subset (*‹all_edges_betw_un ?X ?Y ⊆ E›*) fin_edges (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) have "insert e F ∩ all_edges_betw_un X Y = {e} ∩ all_edges_betw_un X Y ∪ F ∩ all_edges_betw_un X Y" by auto with ‹e∉F› (*‹e ∉ F›*) show "?thesis" (*goal: ‹edge_card (insert e F) X Y = edge_card {e} X Y + edge_card F X Y›*) by (auto simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) fin (*‹finite (all_edges_betw_un X Y)›*)) qed lemma edge_card_sing: assumes "e ∈ E" shows "edge_card {e} U U = (if e ⊆ U then 1 else 0)" proof (cases "e ⊆ U") (*goals: 1. ‹e ⊆ U ⟹ edge_card {e} U U = (if e ⊆ U then 1 else 0)› 2. ‹¬ e ⊆ U ⟹ edge_card {e} U U = (if e ⊆ U then 1 else 0)›*) case True (*‹e ⊆ U›*) obtain x and y where xy: "e = {x,y}" "x≠y" (*goal: ‹(⋀x y. ⟦e = {x, y}; x ≠ y⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹e ∈ E›*) by (metis card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) two_edges (*‹?e ∈ E ⟹ card ?e = 2›*)) with True (*‹e ⊆ U›*) assms (*‹(e::'a set) ∈ E›*) have "{e} ∩ all_edges_betw_un U U = {e}" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un (?X::'a set) (?Y::'a set) ≡ {{x, y} |(x::'a) y::'a. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) with True (*‹e ⊆ U›*) show "?thesis" (*goal: ‹edge_card {e} U U = (if e ⊆ U then 1 else 0)›*) by (simp add: edge_card_def (*‹edge_card ≡ λ(C::'a::type set set) (X::'a::type set) Y::'a::type set. card (C ∩ all_edges_betw_un X Y)›*)) qed (auto simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*)) (*solved the remaining goal: ‹¬ e ⊆ U ⟹ edge_card {e} U U = (if e ⊆ U then 1 else 0)›*) lemma sum_edge_card_choose: assumes "2≤k" "C ⊆ E" shows "(∑U∈[V]⇗k⇖. edge_card C U U) = (card V - 2 choose (k-2)) * card C" proof (-) (*goal: ‹(∑U::'a set∈[V]⇗(k::nat)⇖. edge_card (C::'a set set) U U) = (gorder - (2::nat) choose (k - (2::nat))) * card C›*) have "*": "card {A ∈ [V]⇗k⇖. e ⊆ A} = card V - 2 choose (k-2)" if e: "e ∈ C" for e proof (-) (*goal: ‹card {A ∈ [V]⇗k⇖. e ⊆ A} = gorder - 2 choose (k - 2)›*) have "e ⊆ V" using ‹C⊆E› (*‹(C::'a set set) ⊆ E›*) e (*‹e ∈ C›*) wellformed (*‹(?e::'a set) ∈ E ⟹ ?e ⊆ V›*) by force obtain x and y where xy: "e = {x,y}" "x≠y" (*goal: ‹(⋀(x::'a) y::'a. ⟦(e::'a set) = {x, y}; x ≠ y⟧ ⟹ thesis::bool) ⟹ thesis›*) using ‹C⊆E› (*‹C ⊆ E›*) e (*‹e ∈ C›*) by (metis in_mono (*‹?A ⊆ ?B ⟹ ?x ∈ ?A ⟶ ?x ∈ ?B›*) card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) two_edges (*‹?e ∈ E ⟹ card ?e = 2›*)) define 𝒜 where "𝒜 ≡ {A ∈ [V]⇗k⇖. e ⊆ A}" have "⋀A. A ∈ 𝒜 ⟹ A = e ∪ (A∖e) ∧ A∖e ∈ [V∖e]⇗(k - 2)⇖" by (auto simp: 𝒜_def (*‹𝒜 ≡ {A ∈ [V]⇗k⇖. e ⊆ A}›*) nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*) xy (*‹e = {x, y}› ‹x ≠ y›*)) moreover have "⋀xa. ⟦xa ∈ [V ∖ e]⇗(k - 2)⇖⟧ ⟹ e ∪ xa ∈ 𝒜" using ‹e ⊆ V› (*‹e ⊆ V›*) assms (*‹2 ≤ k› ‹C ⊆ E›*) by (auto simp: 𝒜_def (*‹𝒜 ≡ {A ∈ [V]⇗k⇖. e ⊆ A}›*) nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*) xy (*‹e = {x, y}› ‹x ≠ y›*) card_insert_if (*‹finite ?A ⟹ card (insert ?x ?A) = (if ?x ∈ ?A then card ?A else Suc (card ?A))›*)) ultimately have "𝒜 = (∪)e ` [V∖e]⇗(k-2)⇖" by auto moreover have "inj_on ((∪) e) ([V∖e]⇗(k - 2)⇖)" by (auto simp: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*) nsets_def (*‹[?A::?'a set]⇗(?n::nat)⇖ ≡ {N::?'a set. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*)) moreover have "card (V∖e) = card V - 2" by (metis ‹C⊆E› ‹e ∈ C› subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) card_Diff_subset (*‹⟦finite ?B; ?B ⊆ ?A⟧ ⟹ card (?A ∖ ?B) = card ?A - card ?B›*) finV (*‹finite V›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) two_edges (*‹?e ∈ E ⟹ card ?e = 2›*) wellformed (*‹?e ∈ E ⟹ ?e ⊆ V›*)) ultimately show "?thesis" (*goal: ‹card {A ∈ [V]⇗k⇖. e ⊆ A} = gorder - 2 choose (k - 2)›*) using assms (*‹(2::nat) ≤ (k::nat)› ‹C ⊆ E›*) by (simp add: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) 𝒜_def (*‹𝒜 ≡ {A ∈ [V]⇗k⇖. e ⊆ A}›*)) qed have "(∑U∈[V]⇗k⇖. edge_card R U U) = ((card V - 2) choose (k-2)) * card R" if "finite R" "R ⊆ C" for R using that (*‹finite R› ‹R ⊆ C›*) proof (induction R) (*goals: 1. ‹{} ⊆ C ⟹ (∑U∈[V]⇗k⇖. edge_card {} U U) = (gorder - 2 choose (k - 2)) * card {}› 2. ‹⋀x F. ⟦finite F; x ∉ F; F ⊆ C ⟹ (∑U∈[V]⇗k⇖. edge_card F U U) = (gorder - 2 choose (k - 2)) * card F; insert x F ⊆ C⟧ ⟹ (∑U∈[V]⇗k⇖. edge_card (insert x F) U U) = (gorder - 2 choose (k - 2)) * card (insert x F)›*) case empty (*‹{} ⊆ C›*) then show "?case" (*goal: ‹(∑U∈[V]⇗k⇖. edge_card {} U U) = (gorder - 2 choose (k - 2)) * card {}›*) by (simp add: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*)) next (*goal: ‹⋀x F. ⟦finite F; x ∉ F; F ⊆ C ⟹ (∑U∈[V]⇗k⇖. edge_card F U U) = (gorder - 2 choose (k - 2)) * card F; insert x F ⊆ C⟧ ⟹ (∑U∈[V]⇗k⇖. edge_card (insert x F) U U) = (gorder - 2 choose (k - 2)) * card (insert x F)›*) case (insert e R) (*‹finite R› ‹e ∉ R› ‹R ⊆ C ⟹ (∑U∈[V]⇗k⇖. edge_card R U U) = (gorder - 2 choose (k - 2)) * card R› ‹insert (e::'a set) (R::'a set set) ⊆ (C::'a set set)›*) with assms (*‹2 ≤ k› ‹(C::'a set set) ⊆ E›*) have "e∈E" by blast with insert (*‹finite R› ‹e ∉ R› ‹R ⊆ C ⟹ (∑U∈[V]⇗k⇖. edge_card R U U) = (gorder - 2 choose (k - 2)) * card R› ‹insert e R ⊆ C›*) show "?case" (*goal: ‹(∑U∈[V]⇗k⇖. edge_card (insert e R) U U) = (gorder - 2 choose (k - 2)) * card (insert e R)›*) by (simp add: edge_card_insert (*‹⟦NO_MATCH {} (?F::'a set set); (?e::'a set) ∉ ?F⟧ ⟹ edge_card (insert ?e ?F) (?X::'a set) (?Y::'a set) = edge_card {?e} ?X ?Y + edge_card ?F ?X ?Y›*) * (*‹(?e::'a set) ∈ (C::'a set set) ⟹ card {A::'a set ∈ [V]⇗(k::nat)⇖. ?e ⊆ A} = gorder - (2::nat) choose (k - (2::nat))›*) sum.distrib (*‹(∑x::?'b∈(?A::?'b set). (?g::?'b ⇒ ?'a) x + (?h::?'b ⇒ ?'a) x) = sum ?g ?A + sum ?h ?A›*) edge_card_sing (*‹(?e::'a set) ∈ E ⟹ edge_card {?e} (?U::'a set) ?U = (if ?e ⊆ ?U then 1::nat else (0::nat))›*) Ramsey.finite_imp_finite_nsets (*‹finite (?A::?'a set) ⟹ finite ([?A]⇗(?k::nat)⇖)›*) finV (*‹finite V›*) flip: sum.inter_filter (*‹finite (?A::?'b set) ⟹ sum (?g::?'b ⇒ ?'a) {x::?'b ∈ ?A. (?P::?'b ⇒ bool) x} = (∑x::?'b∈?A. if ?P x then ?g x else (0::?'a))›*)) qed then show "?thesis" (*goal: ‹(∑U∈[V]⇗k⇖. edge_card C U U) = (gorder - 2 choose (k - 2)) * card C›*) by (meson ‹C⊆E› fin_edges (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) set_eq_subset (*‹(?A = ?B) = (?A ⊆ ?B ∧ ?B ⊆ ?A)›*)) qed lemma sum_nsets_Compl: assumes "finite A" "k ≤ card A" shows "(∑U∈[A]⇗k⇖. f (A∖U)) = (∑U∈[A]⇗(card A - k)⇖. f U)" proof (-) (*goal: ‹(∑U∈[A]⇗k⇖. f (A ∖ U)) = sum f ([A]⇗(card A - k)⇖)›*) have "B ∈ (∖) A ` [A]⇗k⇖" if "B ∈ [A]⇗(card A - k)⇖" for B proof (-) (*goal: ‹B ∈ (∖) A ` [A]⇗k⇖›*) have "card (A∖B) = k" using assms (*‹finite A› ‹k ≤ card A›*) that (*‹B ∈ [A]⇗(card A - k)⇖›*) by (simp add: nsets_def (*‹[?A::?'a set]⇗(?n::nat)⇖ ≡ {N::?'a set. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*) card_Diff_subset (*‹⟦finite (?B::?'a set); ?B ⊆ (?A::?'a set)⟧ ⟹ card (?A ∖ ?B) = card ?A - card ?B›*)) moreover have "B = A∖(A∖B)" using that (*‹B ∈ [A]⇗(card A - k)⇖›*) by (auto simp: nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*)) ultimately show "?thesis" (*goal: ‹B ∈ (∖) A ` [A]⇗k⇖›*) using assms (*‹finite A› ‹k ≤ card A›*) unfolding nsets_def image_iff (*goal: ‹∃x::'b set∈{N::'b set. N ⊆ (A::'b set) ∧ finite N ∧ card N = (k::nat)}. (B::'b set) = A ∖ x›*) by blast qed then have "bij_betw (λU. A∖U) ([A]⇗k⇖) ([A]⇗(card A - k)⇖)" using assms (*‹finite A› ‹k ≤ card A›*) by (auto simp: nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) card_Diff_subset (*‹⟦finite ?B; ?B ⊆ ?A⟧ ⟹ card (?A ∖ ?B) = card ?A - card ?B›*)) then show "?thesis" (*goal: ‹(∑U∈[A]⇗k⇖. f (A ∖ U)) = sum f ([A]⇗(card A - k)⇖)›*) using sum.reindex_bij_betw (*‹bij_betw ?h ?S ?T ⟹ (∑x∈?S. ?g (?h x)) = sum ?g ?T›*) by blast qed subsection ‹Lemma 9.2 preliminaries› text ‹Equation (45) in the text, page 30, is seemingly a huge gap. The development below relies on binomial coefficient identities.› definition "graph_density ≡ λC. card C / card E" lemma graph_density_Un: assumes "disjnt C D" "C ⊆ E" "D ⊆ E" shows "graph_density (C ∪ D) = graph_density C + graph_density D" proof (cases "card E > 0") (*goals: 1. ‹0 < graph_size ⟹ graph_density (C ∪ D) = graph_density C + graph_density D› 2. ‹¬ 0 < graph_size ⟹ graph_density (C ∪ D) = graph_density C + graph_density D›*) case True (*‹0 < graph_size›*) with assms (*‹disjnt C D› ‹C ⊆ E› ‹(D::'a set set) ⊆ E›*) obtain "finite C" "finite D" (*goal: ‹(⟦finite C; finite D⟧ ⟹ thesis) ⟹ thesis›*) by (metis card_ge_0_finite (*‹0 < card ?A ⟹ finite ?A›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) with assms (*‹disjnt C D› ‹C ⊆ E› ‹D ⊆ E›*) show "?thesis" (*goal: ‹graph_density ((C::'a set set) ∪ (D::'a set set)) = graph_density C + graph_density D›*) by (auto simp: graph_density_def (*‹graph_density ≡ λC. real (card C) / real graph_size›*) card_Un_disjnt (*‹⟦finite ?A; finite ?B; disjnt ?A ?B⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) qed (auto simp: graph_density_def (*‹graph_density ≡ λC. real (card C) / real graph_size›*)) (*solved the remaining goal: ‹¬ 0 < graph_size ⟹ graph_density (C ∪ D) = graph_density C + graph_density D›*) text ‹Could be generalised to any complete graph› lemma density_eq_average: assumes "C ⊆ E" and complete: "E = all_edges V" shows "graph_density C = real (∑x ∈ V. ∑y ∈ V∖{x}. if {x,y} ∈ C then 1 else 0) / (card V * (card V - 1))" proof (-) (*goal: ‹graph_density C = real (∑x∈V. ∑y∈V ∖ {x}. if {x, y} ∈ C then 1 else 0) / real (gorder * (gorder - 1))›*) have cardE: "card E = card V choose 2" using card_all_edges (*‹finite (?A::?'a set) ⟹ card (all_edges ?A) = card ?A choose (2::nat)›*) complete (*‹E = all_edges V›*) finV (*‹finite V›*) by blast have "finite C" using assms (*‹C ⊆ E› ‹E = all_edges V›*) fin_edges (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast then have "*": "(∑x∈V. ∑y∈V∖{x}. if {x, y} ∈ C then 1 else 0) = card C * 2" using assms (*‹C ⊆ E› ‹E = all_edges V›*) by (simp add: sum_eq_card_Neighbours (*‹⟦?x ∈ V; ?C ⊆ E⟧ ⟹ (∑y∈V ∖ {?x}. if {?x, y} ∈ ?C then 1 else 0) = card (Neighbours ?C ?x)›*) sum_Neighbours_eq_card (*‹⟦finite ?C; ?C ⊆ E⟧ ⟹ (∑i∈V. card (Neighbours ?C i)) = card ?C * 2›*)) show "?thesis" (*goal: ‹graph_density C = real (∑x∈V. ∑y∈V ∖ {x}. if {x, y} ∈ C then 1 else 0) / real (gorder * (gorder - 1))›*) by (auto simp: graph_density_def (*‹graph_density ≡ λC. real (card C) / real graph_size›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) cardE (*‹graph_size = gorder choose 2›*) choose_two_real (*‹real (?n choose 2) = real ?n * (real ?n - 1) / 2›*) * (*‹(∑x∈V. ∑y∈V ∖ {x}. if {x, y} ∈ C then 1 else 0) = card C * 2›*)) qed lemma edge_card_V_V: assumes "C ⊆ E" and complete: "E = all_edges V" shows "edge_card C V V = card C" proof (-) (*goal: ‹edge_card C V V = card C›*) have "C ⊆ all_edges_betw_un V V" using assms (*‹C ⊆ E› ‹E = all_edges V›*) clique_iff (*‹(?F::?'a set set) ⊆ all_edges (?K::?'a set) ⟹ clique ?K ?F = (?F = all_edges ?K)›*) complete (*‹E = all_edges V›*) subset_refl (*‹?A ⊆ ?A›*) by (metis all_uedges_betw_I (*‹⟦(?x::'a) ∈ (?X::'a set); (?y::'a) ∈ (?Y::'a set); {?x, ?y} ∈ E⟧ ⟹ {?x, ?y} ∈ all_edges_betw_un ?X ?Y›*) all_uedges_betw_subset (*‹all_edges_betw_un (?X::'a set) (?Y::'a set) ⊆ E›*) clique_def (*‹clique (?V::?'a set) (?E::?'a set set) = (∀v::?'a∈?V. ∀w::?'a∈?V. v ≠ w ⟶ {v, w} ∈ ?E)›*)) then show "?thesis" (*goal: ‹edge_card (C::'a set set) V V = card C›*) by (metis Int_absorb2 (*‹?A ⊆ ?B ⟹ ?A ∩ ?B = ?A›*) edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*)) qed text ‹Bhavik's statement; own proof› proposition density_eq_average_partition: assumes k: "0 < k" "k < card V" and "C ⊆ E" and complete: "E = all_edges V" shows "graph_density C = (∑U∈[V]⇗k⇖. gen_density C U (V∖U)) / (card V choose k)" proof (cases "k=1 ∨ gorder = Suc k") (*goals: 1. ‹k = 1 ∨ gorder = Suc k ⟹ graph_density C = (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) / real (gorder choose k)› 2. ‹¬ (k = 1 ∨ gorder = Suc k) ⟹ graph_density C = (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) / real (gorder choose k)›*) case True (*‹(k::nat) = (1::nat) ∨ gorder = Suc k›*) then have [simp]: "gorder choose k = gorder" by auto have eq: "(C ∩ {{x, y} |y. y ∈ V ∧ y ≠ x ∧ {x, y} ∈ E}) = (λy. {x,y}) ` {y. {x,y} ∈ C}" for x using ‹C⊆E› (*‹C ⊆ E›*) wellformed (*‹(?e::'a set) ∈ E ⟹ ?e ⊆ V›*) by fastforce have "V ≠ {}" using assms (*‹0 < k› ‹k < gorder› ‹C ⊆ E› ‹E = all_edges V›*) by force then have nontriv: "E ≠ {}" using assms (*‹(0::nat) < (k::nat)› ‹k < gorder› ‹C ⊆ E› ‹E = all_edges V›*) card_all_edges (*‹finite (?A::?'a::type set) ⟹ card (all_edges ?A) = card ?A choose (2::nat)›*) finV (*‹finite V›*) by force have "(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))" using True (*‹(k::nat) = (1::nat) ∨ gorder = Suc k›*) proof (standard) (*goals: 1. ‹k = 1 ⟹ (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))› 2. ‹gorder = Suc k ⟹ (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))›*) assume "k = 1" (*‹(k::nat) = (1::nat)›*) then show "?thesis" (*goal: ‹(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))›*) by (simp add: sum_nsets_one (*‹sum ?f ([?V]⇗Suc 0⇖) = (∑x∈?V. ?f {x})›*)) next (*goal: ‹gorder = Suc k ⟹ (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))›*) assume "§": "gorder = Suc k" (*‹gorder = Suc (k::nat)›*) then have "V-A ≠ {}" if "card A = k" "finite A" for A using that (*‹card (A::'a set) = (k::nat)› ‹finite A›*) by (metis assms( (*‹(k::nat) < gorder›*) 2) card.empty (*‹card {} = (0::nat)›*) card_less_sym_Diff (*‹⟦finite (?A::?'a set); finite (?B::?'a set); card ?A < card ?B⟧ ⟹ card (?A ∖ ?B) < card (?B ∖ ?A)›*) finV (*‹finite V›*) less_nat_zero_code (*‹((?n::nat) < (0::nat)) = False›*)) then have bij: "bij_betw (λx. V ∖ {x}) V ([V]⇗k⇖)" using finV (*‹finite V›*) "§" (*‹gorder = Suc k›*) apply (auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*) nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*)) (*goal: ‹bij_betw (λx. V ∖ {x}) V ([V]⇗k⇖)›*) by (metis Diff_insert_absorb (*‹?x ∉ ?A ⟹ insert ?x ?A ∖ {?x} = ?A›*) card.insert (*‹⟦finite ?A; ?x ∉ ?A⟧ ⟹ card (insert ?x ?A) = Suc (card ?A)›*) card_subset_eq (*‹⟦finite ?B; ?A ⊆ ?B; card ?A = card ?B⟧ ⟹ ?A = ?B›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) moreover have "V∖(V∖{x}) = {x}" if "x∈V" for x using that (*‹(x::'a::type) ∈ V›*) by auto ultimately show "?thesis" (*goal: ‹(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))›*) using sum.reindex_bij_betw[OF bij] (*‹(∑x∈V. ?g (V ∖ {x})) = sum ?g ([V]⇗k⇖)›*) gen_density_commute (*‹gen_density ?C ?X ?Y = gen_density ?C ?Y ?X›*) by (metis (no_types, lifting) sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) qed also (*calculation: ‹(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. gen_density C {x} (V ∖ {x}))›*) have "… = (∑x∈V. real (edge_card C {x} (V ∖ {x}))) / (gorder - 1)" by (simp add: ‹C⊆E› gen_density_def (*‹gen_density ≡ λC X Y. real (edge_card C X Y) / real (card X * card Y)›*) flip: sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*)) also (*calculation: ‹(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = (∑x∈V. real (edge_card C {x} (V ∖ {x}))) / real (gorder - 1)›*) have "… = (∑i∈V. card (Neighbours C i)) / (gorder - 1)" unfolding edge_card_def Neighbours_def all_edges_betw_un_def (*goal: ‹(∑x∈V. real (card (C ∩ {{xa, y} |xa y. xa ∈ {x} ∧ y ∈ V ∖ {x} ∧ {xa, y} ∈ E}))) / real (gorder - 1) = real (∑i∈V. card {y. {i, y} ∈ C}) / real (gorder - 1)›*) by (simp add: eq (*‹C ∩ {{?x1, y} |y. y ∈ V ∧ y ≠ ?x1 ∧ {?x1, y} ∈ E} = (λy. {?x1, y}) ` {y. {?x1, y} ∈ C}›*) card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) also (*calculation: ‹(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = real (∑i∈V. card (Neighbours C i)) / real (gorder - 1)›*) have "… = graph_density C * gorder" using assms (*‹(0::nat) < (k::nat)› ‹(k::nat) < gorder› ‹(C::'a set set) ⊆ E› ‹E = all_edges V›*) density_eq_average[OF ‹C⊆E› complete] (*‹graph_density C = real (∑x∈V. ∑y∈V ∖ {x}. if {x, y} ∈ C then 1 else 0) / real (gorder * (gorder - 1))›*) by (simp add: sum_eq_card_Neighbours (*‹⟦?x ∈ V; ?C ⊆ E⟧ ⟹ (∑y∈V ∖ {?x}. if {?x, y} ∈ ?C then 1 else 0) = card (Neighbours ?C ?x)›*)) finally (*calculation: ‹(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) = graph_density C * real gorder›*) show "?thesis" (*goal: ‹graph_density C = (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) / real (gorder choose k)›*) using k (*‹0 < k› ‹k < gorder›*) by simp next (*goal: ‹¬ (k = 1 ∨ gorder = Suc k) ⟹ graph_density C = (∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) / real (gorder choose k)›*) case False (*‹¬ (k = 1 ∨ gorder = Suc k)›*) then have K: "gorder > Suc k" "k≥2" using assms (*‹0 < k› ‹k < gorder› ‹C ⊆ E› ‹E = all_edges V›*) apply - (*goals: 1. ‹⟦¬ ((k::nat) = (1::nat) ∨ gorder = Suc k); (0::nat) < k; k < gorder; (C::'a set set) ⊆ E; E = all_edges V⟧ ⟹ Suc k < gorder› 2. ‹⟦¬ ((k::nat) = (1::nat) ∨ gorder = Suc k); (0::nat) < k; k < gorder; (C::'a set set) ⊆ E; E = all_edges V⟧ ⟹ (2::nat) ≤ k› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "gorder - Suc (Suc (gorder - Suc (Suc k))) = k" using assms (*‹(0::nat) < (k::nat)› ‹k < gorder› ‹(C::'a set set) ⊆ E› ‹E = all_edges V›*) by auto then have [simp]: "gorder - 2 choose (gorder - Suc (Suc k)) = (gorder - 2 choose k)" using binomial_symmetric[of "(gorder - Suc (Suc k))"] (*‹gorder - Suc (Suc k) ≤ ?n ⟹ ?n choose (gorder - Suc (Suc k)) = ?n choose (?n - (gorder - Suc (Suc k)))›*) by simp have cardE: "card E = card V choose 2" using card_all_edges (*‹finite ?A ⟹ card (all_edges ?A) = card ?A choose 2›*) complete (*‹E = all_edges V›*) finV (*‹finite V›*) by blast have "card E > 0" using k (*‹0 < k› ‹k < gorder›*) cardE (*‹graph_size = gorder choose 2›*) by auto have in_E_iff[iff]: "{v,w} ∈ E ⟷ v∈V ∧ w∈V ∧ v≠w" for v and w by (auto simp: complete (*‹E = all_edges V›*) all_edges_alt (*‹all_edges ?S = {{x, y} |x y. x ∈ ?S ∧ y ∈ ?S ∧ x ≠ y}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) have B: "edge_card C V V = edge_card C U U + edge_card C U (V∖U) + edge_card C (V∖U) (V∖U)" (is "?L = ?R") if "U ⊆ V" for U proof (-) (*goal: ‹edge_card C V V = edge_card C U U + edge_card C U (V ∖ U) + edge_card C (V ∖ U) (V ∖ U)›*) have fin: "finite (all_edges_betw_un U U')" for U' by (meson all_uedges_betw_subset (*‹all_edges_betw_un ?X ?Y ⊆ E›*) fin_edges (*‹finite E›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) have dis: "all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}" by (auto simp: all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) have "all_edges_betw_un V V = all_edges_betw_un U U ∪ all_edges_betw_un U (V∖U) ∪ all_edges_betw_un (V∖U) (V∖U)" by (smt (verit) that (*‹U ⊆ V›*) Diff_partition (*‹?A ⊆ ?B ⟹ ?A ∪ (?B ∖ ?A) = ?B›*) Un_absorb (*‹?A ∪ ?A = ?A›*) Un_assoc (*‹?A ∪ ?B ∪ ?C = ?A ∪ (?B ∪ ?C)›*) all_edges_betw_un_Un2 (*‹all_edges_betw_un ?X (?Y ∪ ?Z) = all_edges_betw_un ?X ?Y ∪ all_edges_betw_un ?X ?Z›*) all_edges_betw_un_commute (*‹all_edges_betw_un ?X ?Y = all_edges_betw_un ?Y ?X›*)) with that (*‹U ⊆ V›*) have "?L = card (C ∩ all_edges_betw_un U U ∪ C ∩ all_edges_betw_un U (V ∖ U) ∪ C ∩ all_edges_betw_un (V ∖ U) (V ∖ U))" by (simp add: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) Int_Un_distrib (*‹?A ∩ (?B ∪ ?C) = ?A ∩ ?B ∪ ?A ∩ ?C›*)) also (*calculation: ‹edge_card C V V = card (C ∩ all_edges_betw_un U U ∪ C ∩ all_edges_betw_un U (V ∖ U) ∪ C ∩ all_edges_betw_un (V ∖ U) (V ∖ U))›*) have "… = ?R" using fin (*‹finite (all_edges_betw_un U ?U'1)›*) dis (*‹all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}›*) ‹C⊆E› (*‹C ⊆ E›*) fin_edges (*‹finite E›*) finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*) apply (subst card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*)) (*goals: 1. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ finite (C ∩ all_edges_betw_un U U ∪ C ∩ all_edges_betw_un U (V ∖ U))› 2. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ finite (C ∩ all_edges_betw_un (V ∖ U) (V ∖ U))› 3. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ (C ∩ all_edges_betw_un U U ∪ C ∩ all_edges_betw_un U (V ∖ U)) ∩ (C ∩ all_edges_betw_un (V ∖ U) (V ∖ U)) = {}› 4. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ card (C ∩ all_edges_betw_un U U ∪ C ∩ all_edges_betw_un U (V ∖ U)) + card (C ∩ all_edges_betw_un (V ∖ U) (V ∖ U)) = edge_card C U U + edge_card C U (V ∖ U) + edge_card C (V ∖ U) (V ∖ U)› discuss goal 1*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*discuss goal 2*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*discuss goal 3*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*discuss goal 4*) apply (subst card_Un_disjoint (*‹⟦finite (?A::?'a set); finite (?B::?'a set); ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*)) (*goals: 1. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ finite (C ∩ all_edges_betw_un U U)› 2. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ finite (C ∩ all_edges_betw_un U (V ∖ U))› 3. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ C ∩ all_edges_betw_un U U ∩ (C ∩ all_edges_betw_un U (V ∖ U)) = {}› 4. ‹⟦⋀U'. finite (all_edges_betw_un U U'); all_edges_betw_un U U ∩ all_edges_betw_un U (V ∖ U) = {}; C ⊆ E; finite E; ⋀A B. ⟦A ⊆ B; finite B⟧ ⟹ finite A⟧ ⟹ card (C ∩ all_edges_betw_un U U) + card (C ∩ all_edges_betw_un U (V ∖ U)) + card (C ∩ all_edges_betw_un (V ∖ U) (V ∖ U)) = edge_card C U U + edge_card C U (V ∖ U) + edge_card C (V ∖ U) (V ∖ U)› discuss goal 1*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λ(C::'a set set) (X::'a set) Y::'a set. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un (?X::'a set) (?Y::'a set) ≡ {{x, y} |(x::'a) y::'a. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a::?'a, ?b::?'a} = {?c::?'a, ?d::?'a}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*discuss goal 2*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*discuss goal 3*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*discuss goal 4*) apply (fastforce simp: edge_card_def (*‹edge_card ≡ λC X Y. card (C ∩ all_edges_betw_un X Y)›*) all_edges_betw_un_def (*‹all_edges_betw_un ?X ?Y ≡ {{x, y} |x y. x ∈ ?X ∧ y ∈ ?Y ∧ {x, y} ∈ E}›*) doubleton_eq_iff (*‹({?a, ?b} = {?c, ?d}) = (?a = ?c ∧ ?b = ?d ∨ ?a = ?d ∧ ?b = ?c)›*)) (*proven 4 subgoals*) (*proven 4 subgoals*) . finally (*calculation: ‹edge_card C V V = edge_card C U U + edge_card C U (V ∖ U) + edge_card C (V ∖ U) (V ∖ U)›*) show "?thesis" (*goal: ‹edge_card C V V = edge_card C U U + edge_card C U (V ∖ U) + edge_card C (V ∖ U) (V ∖ U)›*) . qed have C: "(∑U∈[V]⇗k⇖. real (edge_card C U (V∖U))) = (card V choose k) * card C - real(∑U∈[V]⇗k⇖. edge_card C U U + edge_card C (V∖U) (V∖U))" (is "?L = ?R") proof (-) (*goal: ‹(∑U::'a set∈[V]⇗(k::nat)⇖. real (edge_card (C::'a set set) U (V ∖ U))) = real ((gorder choose k) * card C) - real (∑U::'a set∈[V]⇗k⇖. edge_card C U U + edge_card C (V ∖ U) (V ∖ U))›*) have "?L = (∑U∈[V]⇗k⇖. edge_card C V V - real (edge_card C U U + edge_card C (V∖U) (V∖U)))" unfolding nsets_def (*goal: ‹(∑U∈{N. N ⊆ V ∧ finite N ∧ card N = k}. real (edge_card C U (V ∖ U))) = (∑U∈{N. N ⊆ V ∧ finite N ∧ card N = k}. real (edge_card C V V) - real (edge_card C U U + edge_card C (V ∖ U) (V ∖ U)))›*) apply (rule sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹{N::'a set. N ⊆ V ∧ finite N ∧ card N = (k::nat)} = {N::'a set. N ⊆ V ∧ finite N ∧ card N = k}› 2. ‹⋀x::'a set. x ∈ {N::'a set. N ⊆ V ∧ finite N ∧ card N = (k::nat)} ⟹ real (edge_card (C::'a set set) x (V ∖ x)) = real (edge_card C V V) - real (edge_card C x x + edge_card C (V ∖ x) (V ∖ x))› discuss goal 1*) apply ((auto simp: B (*‹?U1 ⊆ V ⟹ edge_card C V V = edge_card C ?U1 ?U1 + edge_card C ?U1 (V ∖ ?U1) + edge_card C (V ∖ ?U1) (V ∖ ?U1)›*))[1]) (*discuss goal 2*) apply ((auto simp: B (*‹?U1 ⊆ V ⟹ edge_card C V V = edge_card C ?U1 ?U1 + edge_card C ?U1 (V ∖ ?U1) + edge_card C (V ∖ ?U1) (V ∖ ?U1)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∑U∈[V]⇗k⇖. real (edge_card C U (V ∖ U))) = (∑U∈[V]⇗k⇖. real (edge_card C V V) - real (edge_card C U U + edge_card C (V ∖ U) (V ∖ U)))›*) have "… = ?R" using ‹C⊆E› (*‹C ⊆ E›*) complete (*‹E = all_edges V›*) edge_card_V_V (*‹⟦?C ⊆ E; E = all_edges V⟧ ⟹ edge_card ?C V V = card ?C›*) by (simp add: ‹C⊆E› sum_subtractf (*‹(∑x∈?A. ?f x - ?g x) = sum ?f ?A - sum ?g ?A›*) edge_card_V_V (*‹⟦?C ⊆ E; E = all_edges V⟧ ⟹ edge_card ?C V V = card ?C›*)) finally (*calculation: ‹(∑U::'a set∈[V]⇗(k::nat)⇖. real (edge_card (C::'a set set) U (V ∖ U))) = real ((gorder choose k) * card C) - real (∑U::'a set∈[V]⇗k⇖. edge_card C U U + edge_card C (V ∖ U) (V ∖ U))›*) show "?thesis" (*goal: ‹(∑U::'a::type set∈[V]⇗(k::nat)⇖. real (edge_card (C::'a::type set set) U (V ∖ U))) = real ((gorder choose k) * card C) - real (∑U::'a::type set∈[V]⇗k⇖. edge_card C U U + edge_card C (V ∖ U) (V ∖ U))›*) . qed have "(gorder-2 choose k) + (gorder-2 choose (k-2)) + 2 * (gorder-2 choose (k-1)) = (gorder choose k)" using assms (*‹(0::nat) < (k::nat)› ‹k < gorder› ‹C ⊆ E› ‹E = all_edges V›*) K (*‹Suc k < gorder› ‹2 ≤ k›*) by (auto simp: choose_reduce_nat [of "gorder"] (*‹⟦(0::nat) < gorder; (0::nat) < (?k::nat)⟧ ⟹ gorder choose ?k = gorder - (1::nat) choose (?k - (1::nat)) + (gorder - (1::nat) choose ?k)›*) choose_reduce_nat [of "gorder-Suc 0"] (*‹⟦(0::nat) < gorder - Suc (0::nat); (0::nat) < (?k::nat)⟧ ⟹ gorder - Suc (0::nat) choose ?k = gorder - Suc (0::nat) - (1::nat) choose (?k - (1::nat)) + (gorder - Suc (0::nat) - (1::nat) choose ?k)›*) eval_nat_numeral (*‹Numeral1 = Suc (0::nat)› ‹numeral (num.Bit0 (?n::num)) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 (?n::num)) = Suc (numeral (num.Bit0 ?n))›*)) moreover have "(gorder - 1) * (gorder-2 choose (k-1)) = (gorder-k) * (gorder-1 choose (k-1))" by (metis Suc_1 (*‹Suc 1 = 2›*) Suc_diff_1 (*‹0 < ?n ⟹ Suc (?n - 1) = ?n›*) binomial_absorb_comp (*‹(?n - ?k) * (?n choose ?k) = ?n * (?n - 1 choose ?k)›*) diff_Suc_eq_diff_pred (*‹?m - Suc ?n = ?m - 1 - ?n›*) ‹k>0›) ultimately have F: "(gorder - 1) * (gorder-2 choose k) + (gorder - 1) * (gorder-2 choose (k-2)) + 2 * (gorder-k) * (gorder-1 choose (k-1)) = (gorder - 1) * (gorder choose k)" by (smt (verit) add_mult_distrib2 (*‹?k * (?m + ?n) = ?k * ?m + ?k * ?n›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) mult.left_commute (*‹?b * (?a * ?c) = ?a * (?b * ?c)›*)) have "(∑U∈[V]⇗k⇖. edge_card C U (V∖U) / (real (card U) * card (V∖U))) = (∑U∈[V]⇗k⇖. edge_card C U (V∖U) / (real k * (card V - k)))" using card_Diff_subset (*‹⟦finite ?B; ?B ⊆ ?A⟧ ⟹ card (?A ∖ ?B) = card ?A - card ?B›*) apply (intro sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹(⋀(B::?'a::type set) A::?'a::type set. ⟦finite B; B ⊆ A⟧ ⟹ card (A ∖ B) = card A - card B) ⟹ [V]⇗(k::nat)⇖ = [V]⇗k⇖› 2. ‹⋀x::'a::type set. ⟦⋀(B::?'a::type set) A::?'a::type set. ⟦finite B; B ⊆ A⟧ ⟹ card (A ∖ B) = card A - card B; x ∈ [V]⇗(k::nat)⇖⟧ ⟹ real (edge_card (C::'a::type set set) x (V ∖ x)) / (real (card x) * real (card (V ∖ x))) = real (edge_card C x (V ∖ x)) / (real k * real (gorder - k))› discuss goal 1*) apply ((auto simp: nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*))[1]) (*discuss goal 2*) apply ((auto simp: nsets_def (*‹[?A]⇗?n⇖ ≡ {N. N ⊆ ?A ∧ finite N ∧ card N = ?n}›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∑U::'a::type set∈[V]⇗(k::nat)⇖. real (edge_card (C::'a::type set set) U (V ∖ U)) / (real (card U) * real (card (V ∖ U)))) = (∑U::'a::type set∈[V]⇗k⇖. real (edge_card C U (V ∖ U)) / (real k * real (gorder - k)))›*) have "… = (∑U∈[V]⇗k⇖. edge_card C U (V∖U)) / (k * (card V - k))" by (simp add: sum_divide_distrib (*‹sum (?f::?'b ⇒ ?'a) (?A::?'b set) / (?r::?'a) = (∑n::?'b∈?A. ?f n / ?r)›*)) finally (*calculation: ‹(∑U∈[V]⇗k⇖. real (edge_card C U (V ∖ U)) / (real (card U) * real (card (V ∖ U)))) = real (∑U∈[V]⇗k⇖. edge_card C U (V ∖ U)) / real (k * (gorder - k))›*) have "*": "(∑U∈[V]⇗k⇖. edge_card C U (V∖U) / (real (card U) * card (V∖U))) = (∑U∈[V]⇗k⇖. edge_card C U (V∖U)) / (k * (card V - k))" . have choose_m1: "gorder * (gorder - 1 choose (k - 1)) = k * (gorder choose k)" using ‹k>0› (*‹(0::nat) < (k::nat)›*) times_binomial_minus1_eq (*‹(0::nat) < (?k::nat) ⟹ ?k * ((?n::nat) choose ?k) = ?n * (?n - (1::nat) choose (?k - (1::nat)))›*) by presburger have "**": "(real k * (real gorder - real k) * real (gorder choose k)) = (real (gorder choose k) - (real (gorder - 2 choose (k - 2)) + real (gorder - 2 choose k))) * real (gorder choose 2)" using assms (*‹0 < k› ‹k < gorder› ‹C ⊆ E› ‹E = all_edges V›*) K (*‹Suc k < gorder› ‹(2::nat) ≤ (k::nat)›*) arg_cong[OF F, of "λu. real gorder * real u"] (*‹real gorder * real ((gorder - (1::nat)) * (gorder - (2::nat) choose (k::nat)) + (gorder - (1::nat)) * (gorder - (2::nat) choose (k - (2::nat))) + (2::nat) * (gorder - k) * (gorder - (1::nat) choose (k - (1::nat)))) = real gorder * real ((gorder - (1::nat)) * (gorder choose k))›*) arg_cong[OF choose_m1, of real] (*‹real (gorder * (gorder - (1::nat) choose ((k::nat) - (1::nat)))) = real (k * (gorder choose k))›*) apply (simp add: choose_two_real (*‹real (?n choose 2) = real ?n * (real ?n - 1) / 2›*) ring_distribs (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c› ‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c› ‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c› ‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) (*goal: ‹real k * (real gorder - real k) * real (gorder choose k) = (real (gorder choose k) - (real (gorder - 2 choose (k - 2)) + real (gorder - 2 choose k))) * real (gorder choose 2)›*) by (smt (verit) distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) mult_2_right (*‹?z * 2 = ?z + ?z›*) mult_of_nat_commute (*‹of_nat ?x * ?y = ?y * of_nat ?x›*)) have eq: "(∑U∈[V]⇗k⇖. real (edge_card C (V∖U) (V∖U))) = (∑U∈[V]⇗(gorder-k)⇖. real (edge_card C U U))" using K (*‹Suc (k::nat) < gorder› ‹2 ≤ k›*) finV (*‹finite V›*) apply (subst sum_nsets_Compl (*‹⟦finite (?A::?'b set); (?k::nat) ≤ card ?A⟧ ⟹ (∑U::?'b set∈[?A]⇗?k⇖. (?f::?'b set ⇒ ?'c) (?A ∖ U)) = sum ?f ([?A]⇗(card ?A - ?k)⇖)›*)) (*goals: 1. ‹⟦Suc k < gorder; 2 ≤ k; finite V⟧ ⟹ finite V› 2. ‹⟦Suc k < gorder; 2 ≤ k; finite V⟧ ⟹ k ≤ gorder› 3. ‹⟦Suc k < gorder; 2 ≤ k; finite V⟧ ⟹ (∑U∈[V]⇗(gorder - k)⇖. real (edge_card C U U)) = (∑U∈[V]⇗(gorder - k)⇖. real (edge_card C U U))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . show "?thesis" (*goal: ‹graph_density (C::'a set set) = (∑U::'a set∈[V]⇗(k::nat)⇖. gen_density C U (V ∖ U)) / real (gorder choose k)›*) unfolding graph_density_def gen_density_def (*goal: ‹real (card C) / real graph_size = (∑U∈[V]⇗k⇖. real (edge_card C U (V ∖ U)) / real (card U * card (V ∖ U))) / real (gorder choose k)›*) using K (*‹Suc k < gorder› ‹2 ≤ k›*) ‹card E > 0› (*‹0 < graph_size›*) ‹C⊆E› (*‹C ⊆ E›*) apply (simp add: eq (*‹(∑U∈[V]⇗k⇖. real (edge_card C (V ∖ U) (V ∖ U))) = (∑U∈[V]⇗(gorder - k)⇖. real (edge_card C U U))›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) B (*‹?U1 ⊆ V ⟹ edge_card C V V = edge_card C ?U1 ?U1 + edge_card C ?U1 (V ∖ ?U1) + edge_card C (V ∖ ?U1) (V ∖ ?U1)›*) C (*‹(∑U∈[V]⇗k⇖. real (edge_card C U (V ∖ U))) = real ((gorder choose k) * card C) - real (∑U∈[V]⇗k⇖. edge_card C U U + edge_card C (V ∖ U) (V ∖ U))›*) sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*) * (*‹(∑U∈[V]⇗k⇖. real (edge_card C U (V ∖ U)) / (real (card U) * real (card (V ∖ U)))) = real (∑U∈[V]⇗k⇖. edge_card C U (V ∖ U)) / real (k * (gorder - k))›*)) (*goal: ‹real (card C) / real graph_size = (∑U∈[V]⇗k⇖. real (edge_card C U (V ∖ U)) / real (card U * card (V ∖ U))) / real (gorder choose k)›*) apply (simp add: ** (*‹real k * (real gorder - real k) * real (gorder choose k) = (real (gorder choose k) - (real (gorder - 2 choose (k - 2)) + real (gorder - 2 choose k))) * real (gorder choose 2)›*) sum_edge_card_choose (*‹⟦2 ≤ ?k; ?C ⊆ E⟧ ⟹ (∑U∈[V]⇗?k⇖. edge_card ?C U U) = (gorder - 2 choose (?k - 2)) * card ?C›*) cardE (*‹graph_size = gorder choose 2›*) flip: of_nat_sum (*‹of_nat (sum ?f ?A) = (∑x∈?A. of_nat (?f x))›*)) (*goal: ‹⟦Suc k < gorder; 2 ≤ k; 0 < graph_size; C ⊆ E⟧ ⟹ real (card C) * (real k * (real gorder - real k) * real (gorder choose k)) = (real (gorder choose k) * real (card C) - ((∑x∈[V]⇗k⇖. real (edge_card C x x)) + (∑x∈[V]⇗(gorder - k)⇖. real (edge_card C x x)))) * real graph_size›*) by argo qed lemma exists_density_edge_density: assumes k: "0 < k" "k < card V" and "C ⊆ E" and complete: "E = all_edges V" obtains U where "card U = k" "U⊆V" "graph_density C ≤ gen_density C U (V∖U)" proof (-) (*goal: ‹(⋀U. ⟦card U = k; U ⊆ V; graph_density C ≤ gen_density C U (V ∖ U)⟧ ⟹ thesis) ⟹ thesis›*) have False if "⋀U. U ∈ [V]⇗k⇖ ⟹ graph_density C > gen_density C U (V∖U)" proof (-) (*goal: ‹False›*) have "card([V]⇗k⇖) > 0" using assms (*‹0 < k› ‹k < gorder› ‹C ⊆ E› ‹E = all_edges V›*) by auto then have "(∑U∈[V]⇗k⇖. gen_density C U (V ∖ U)) < card([V]⇗k⇖) * graph_density C" by (meson sum_bounded_above_strict (*‹⟦⋀i. i ∈ ?A ⟹ ?f i < ?K; 0 < card ?A⟧ ⟹ sum ?f ?A < of_nat (card ?A) * ?K›*) that (*‹?U1 ∈ [V]⇗k⇖ ⟹ gen_density C ?U1 (V ∖ ?U1) < graph_density C›*)) with density_eq_average_partition (*‹⟦0 < ?k; ?k < gorder; ?C ⊆ E; E = all_edges V⟧ ⟹ graph_density ?C = (∑U∈[V]⇗?k⇖. gen_density ?C U (V ∖ U)) / real (gorder choose ?k)›*) assms (*‹0 < k› ‹k < gorder› ‹(C::'a set set) ⊆ E› ‹E = all_edges V›*) show False by force qed with that (*‹⟦card ?U1 = k; ?U1 ⊆ V; graph_density C ≤ gen_density C ?U1 (V ∖ ?U1)⟧ ⟹ thesis›*) show thesis unfolding nsets_def (*goal: ‹thesis›*) by fastforce qed end (*fin_sgraph*) end
{ "path": "afp-2025-02-12/thys/Diagonal_Ramsey/Neighbours.thy", "repo": "afp-2025-02-12", "sha": "9a957db5335985cfe41891beb48b084a549a1d1e1010ce57e9cb2a17ecb1b6d9" }
(* Title: JinjaThreads/Common/StartConfig.thy Author: Andreas Lochbihler *) section ‹The initial configuration› theory StartConfig imports Exceptions Observable_Events begin definition initialization_list :: "cname list" where "initialization_list = Thread # sys_xcpts_list" context heap_base begin definition create_initial_object :: "'heap × 'addr list × bool ⇒ cname ⇒ 'heap × 'addr list × bool" where "create_initial_object = (λ(h, ads, b) C. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ads @ [a''], True) else (h, ads, False))" definition start_heap_data :: "'heap × 'addr list × bool" where "start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list" definition start_heap :: 'heap where "start_heap = fst start_heap_data" definition start_heap_ok :: bool where "start_heap_ok = snd (snd (start_heap_data))" definition start_heap_obs :: "('addr, 'thread_id) obs_event list" where "start_heap_obs = map (λ(C, a). NewHeapElem a (Class_type C)) (zip initialization_list (fst (snd start_heap_data)))" definition start_addrs :: "'addr list" where "start_addrs = fst (snd start_heap_data)" definition addr_of_sys_xcpt :: "cname ⇒ 'addr" where "addr_of_sys_xcpt C = the (map_of (zip initialization_list start_addrs) C)" definition start_tid :: 'thread_id where "start_tid = addr2thread_id (hd start_addrs)" definition start_state :: "(cname ⇒ mname ⇒ ty list ⇒ ty ⇒ 'm ⇒ 'addr val list ⇒ 'x) ⇒ 'm prog ⇒ cname ⇒ mname ⇒ 'addr val list ⇒ ('addr,'thread_id,'x,'heap,'addr) state" where "start_state f P C M vs ≡ let (D, Ts, T, m) = method P C M in (K$ None, ([start_tid ↦ (f D M Ts T (the m) vs, no_wait_locks)], start_heap), Map.empty, {})" lemma create_initial_object_simps: "create_initial_object (h, ads, b) C = (if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ads @ [a''], True) else (h, ads, False))" unfolding create_initial_object_def (*goal: ‹(case (h, ads, b) of (h, ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ads @ [a''], True) else (h, ads, False)) C = (if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ads @ [a''], True) else (h, ads, False))›*) by simp lemma create_initial_object_False [simp]: "create_initial_object (h, ads, False) C = (h, ads, False)" by (simp add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) lemma foldl_create_initial_object_False [simp]: "foldl create_initial_object (h, ads, False) Cs = (h, ads, False)" apply (induct Cs) (*goals: 1. ‹foldl create_initial_object (h, ads, False) [] = (h, ads, False)› 2. ‹⋀a Cs. foldl create_initial_object (h, ads, False) Cs = (h, ads, False) ⟹ foldl create_initial_object (h, ads, False) (a # Cs) = (h, ads, False)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma NewHeapElem_start_heap_obs_start_addrsD: "NewHeapElem a CTn ∈ set start_heap_obs ⟹ a ∈ set start_addrs" unfolding start_heap_obs_def start_addrs_def (*goal: ‹NewHeapElem a CTn ∈ set (map2 (λC a. NewHeapElem a (Class_type C)) initialization_list (fst (snd start_heap_data))) ⟹ a ∈ set (fst (snd start_heap_data))›*) by (auto dest: set_zip_rightD (*‹(?x, ?y) ∈ set (zip ?xs ?ys) ⟹ ?y ∈ set ?ys›*)) lemma shr_start_state: "shr (start_state f P C M vs) = start_heap" by (simp add: start_state_def (*‹start_state ?f ?P ?C ?M ?vs ≡ let (D, Ts, T, m) = method ?P ?C ?M in (K$ None, ([start_tid ↦ (?f D ?M Ts T (the m) ?vs, no_wait_locks)], start_heap), λx. None, {})›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) lemma start_heap_obs_not_Read: "ReadMem ad al v ∉ set start_heap_obs" unfolding start_heap_obs_def (*goal: ‹ReadMem ad al v ∉ set (map2 (λC a. NewHeapElem a (Class_type C)) initialization_list (fst (snd start_heap_data)))›*) by auto lemma length_initialization_list_le_length_start_addrs: "length initialization_list ≥ length start_addrs" proof (-) (*goal: ‹length start_addrs ≤ length initialization_list›*) { fix h and ads and xs have "length (fst (snd (foldl create_initial_object (h, ads, True) xs))) ≤ length ads + length xs" proof (induct xs arbitrary: h ads) (*goals: 1. ‹⋀h ads. length (fst (snd (foldl create_initial_object (h, ads, True) []))) ≤ length ads + length []› 2. ‹⋀a xs h ads. (⋀h ads. length (fst (snd (foldl create_initial_object (h, ads, True) xs))) ≤ length ads + length xs) ⟹ length (fst (snd (foldl create_initial_object (h, ads, True) (a # xs)))) ≤ length ads + length (a # xs)›*) case Nil (*no hyothesis introduced yet*) thus "?case" (*goal: ‹length (fst (snd (foldl create_initial_object (h, ads, True) []))) ≤ length ads + length []›*) by simp next (*goal: ‹⋀a xs h ads. (⋀h ads. length (fst (snd (foldl create_initial_object (h, ads, True) xs))) ≤ length ads + length xs) ⟹ length (fst (snd (foldl create_initial_object (h, ads, True) (a # xs)))) ≤ length ads + length (a # xs)›*) case (Cons x xs) (*‹length (fst (snd (foldl create_initial_object (?h3, ?ads3, True) xs))) ≤ length ?ads3 + length xs›*) from this[of "fst (SOME ha. ha ∈ allocate h (Class_type x))" "ads @ [snd (SOME ha. ha ∈ allocate h (Class_type x))]"] (*‹length (fst (snd (foldl create_initial_object (fst (SOME haa. haa ∈ allocate h (Class_type x)), ads @ [snd (SOME haa. haa ∈ allocate h (Class_type x))], True) xs))) ≤ length (ads @ [snd (SOME haa. haa ∈ allocate h (Class_type x))]) + length xs›*) show "?case" (*goal: ‹length (fst (snd (foldl create_initial_object (h, ads, True) (x # xs)))) ≤ length ads + length (x # xs)›*) by (clarsimp simp add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) qed } from this[of empty_heap "[]" initialization_list] (*‹length (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ≤ length [] + length initialization_list›*) show "?thesis" (*goal: ‹length start_addrs ≤ length initialization_list›*) unfolding start_heap_def start_addrs_def start_heap_data_def (*goal: ‹length (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ≤ length initialization_list›*) by simp qed lemma (in -) distinct_initialization_list: "distinct initialization_list" by (simp add: initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*)) lemma (in -) wf_syscls_initialization_list_is_class: "⟦ wf_syscls P; C ∈ set initialization_list ⟧ ⟹ is_class P C" by (auto simp add: initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) lemma start_addrs_NewHeapElem_start_heap_obsD: "a ∈ set start_addrs ⟹ ∃CTn. NewHeapElem a CTn ∈ set start_heap_obs" using length_initialization_list_le_length_start_addrs (*‹length start_addrs ≤ length initialization_list›*) unfolding start_heap_obs_def start_addrs_def (*goal: ‹a ∈ set (fst (snd start_heap_data)) ⟹ ∃CTn. NewHeapElem a CTn ∈ set (map2 (λC a. NewHeapElem a (Class_type C)) initialization_list (fst (snd start_heap_data)))›*) by (force simp add: set_zip (*‹set (zip (?xs::?'a list) (?ys::?'b list)) = {(?xs ! i, ?ys ! i) |i::nat. i < min (length ?xs) (length ?ys)}›*) in_set_conv_nth (*‹((?x::?'a) ∈ set (?xs::?'a list)) = (∃i<length ?xs. ?xs ! i = ?x)›*) intro: rev_image_eqI (*‹⟦(?x::?'a) ∈ (?A::?'a set); (?b::?'b) = (?f::?'a ⇒ ?'b) ?x⟧ ⟹ ?b ∈ ?f ` ?A›*)) lemma in_set_start_addrs_conv_NewHeapElem: "a ∈ set start_addrs ⟷ (∃CTn. NewHeapElem a CTn ∈ set start_heap_obs)" by (blast dest: start_addrs_NewHeapElem_start_heap_obsD (*‹?a ∈ set start_addrs ⟹ ∃CTn. NewHeapElem ?a CTn ∈ set start_heap_obs›*) intro: NewHeapElem_start_heap_obs_start_addrsD (*‹NewHeapElem ?a ?CTn ∈ set start_heap_obs ⟹ ?a ∈ set start_addrs›*)) subsection ‹@{term preallocated}› definition preallocated :: "'heap ⇒ bool" where "preallocated h ≡ ∀C ∈ sys_xcpts. typeof_addr h (addr_of_sys_xcpt C) = ⌊Class_type C⌋" lemma typeof_addr_sys_xcp: "⟦ preallocated h; C ∈ sys_xcpts ⟧ ⟹ typeof_addr h (addr_of_sys_xcpt C) = ⌊Class_type C⌋" by (simp add: preallocated_def (*‹preallocated ?h ≡ ∀C∈sys_xcpts. typeof_addr ?h (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*)) lemma typeof_sys_xcp: "⟦ preallocated h; C ∈ sys_xcpts ⟧ ⟹ typeof⇘h⇙ (Addr (addr_of_sys_xcpt C)) = ⌊Class C⌋" by (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) lemma addr_of_sys_xcpt_start_addr: "⟦ start_heap_ok; C ∈ sys_xcpts ⟧ ⟹ addr_of_sys_xcpt C ∈ set start_addrs" unfolding start_heap_ok_def start_heap_data_def initialization_list_def sys_xcpts_list_def preallocated_def start_heap_def start_addrs_def (*goal: ‹⟦snd (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])); C ∈ sys_xcpts⟧ ⟹ addr_of_sys_xcpt C ∈ set (fst (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])))›*) apply (simp split: prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*goal: ‹⟦snd (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])); C ∈ sys_xcpts⟧ ⟹ addr_of_sys_xcpt C ∈ set (fst (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])))›*) apply (erule sys_xcpts_cases (*‹⟦?C ∈ sys_xcpts; ?P NullPointer; ?P OutOfMemory; ?P ClassCast; ?P ArrayIndexOutOfBounds; ?P ArrayStore; ?P NegativeArraySize; ?P ArithmeticException; ?P IllegalMonitorState; ?P IllegalThreadState; ?P InterruptedException⟧ ⟹ ?P ?C›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt NullPointer = x2 ∨ addr_of_sys_xcpt NullPointer = x2a ∨ addr_of_sys_xcpt NullPointer = x2b ∨ addr_of_sys_xcpt NullPointer = x2c ∨ addr_of_sys_xcpt NullPointer = x2d ∨ addr_of_sys_xcpt NullPointer = x2e ∨ addr_of_sys_xcpt NullPointer = x2f ∨ addr_of_sys_xcpt NullPointer = x2g ∨ addr_of_sys_xcpt NullPointer = x2h ∨ addr_of_sys_xcpt NullPointer = x2i ∨ addr_of_sys_xcpt NullPointer = x2j› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt OutOfMemory = x2 ∨ addr_of_sys_xcpt OutOfMemory = x2a ∨ addr_of_sys_xcpt OutOfMemory = x2b ∨ addr_of_sys_xcpt OutOfMemory = x2c ∨ addr_of_sys_xcpt OutOfMemory = x2d ∨ addr_of_sys_xcpt OutOfMemory = x2e ∨ addr_of_sys_xcpt OutOfMemory = x2f ∨ addr_of_sys_xcpt OutOfMemory = x2g ∨ addr_of_sys_xcpt OutOfMemory = x2h ∨ addr_of_sys_xcpt OutOfMemory = x2i ∨ addr_of_sys_xcpt OutOfMemory = x2j› 3. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt ClassCast = x2 ∨ addr_of_sys_xcpt ClassCast = x2a ∨ addr_of_sys_xcpt ClassCast = x2b ∨ addr_of_sys_xcpt ClassCast = x2c ∨ addr_of_sys_xcpt ClassCast = x2d ∨ addr_of_sys_xcpt ClassCast = x2e ∨ addr_of_sys_xcpt ClassCast = x2f ∨ addr_of_sys_xcpt ClassCast = x2g ∨ addr_of_sys_xcpt ClassCast = x2h ∨ addr_of_sys_xcpt ClassCast = x2i ∨ addr_of_sys_xcpt ClassCast = x2j› 4. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2 ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2a ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2b ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2c ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2d ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2e ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2f ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2g ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2h ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2i ∨ addr_of_sys_xcpt ArrayIndexOutOfBounds = x2j› 5. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt ArrayStore = x2 ∨ addr_of_sys_xcpt ArrayStore = x2a ∨ addr_of_sys_xcpt ArrayStore = x2b ∨ addr_of_sys_xcpt ArrayStore = x2c ∨ addr_of_sys_xcpt ArrayStore = x2d ∨ addr_of_sys_xcpt ArrayStore = x2e ∨ addr_of_sys_xcpt ArrayStore = x2f ∨ addr_of_sys_xcpt ArrayStore = x2g ∨ addr_of_sys_xcpt ArrayStore = x2h ∨ addr_of_sys_xcpt ArrayStore = x2i ∨ addr_of_sys_xcpt ArrayStore = x2j› 6. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt NegativeArraySize = x2 ∨ addr_of_sys_xcpt NegativeArraySize = x2a ∨ addr_of_sys_xcpt NegativeArraySize = x2b ∨ addr_of_sys_xcpt NegativeArraySize = x2c ∨ addr_of_sys_xcpt NegativeArraySize = x2d ∨ addr_of_sys_xcpt NegativeArraySize = x2e ∨ addr_of_sys_xcpt NegativeArraySize = x2f ∨ addr_of_sys_xcpt NegativeArraySize = x2g ∨ addr_of_sys_xcpt NegativeArraySize = x2h ∨ addr_of_sys_xcpt NegativeArraySize = x2i ∨ addr_of_sys_xcpt NegativeArraySize = x2j› 7. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt ArithmeticException = x2 ∨ addr_of_sys_xcpt ArithmeticException = x2a ∨ addr_of_sys_xcpt ArithmeticException = x2b ∨ addr_of_sys_xcpt ArithmeticException = x2c ∨ addr_of_sys_xcpt ArithmeticException = x2d ∨ addr_of_sys_xcpt ArithmeticException = x2e ∨ addr_of_sys_xcpt ArithmeticException = x2f ∨ addr_of_sys_xcpt ArithmeticException = x2g ∨ addr_of_sys_xcpt ArithmeticException = x2h ∨ addr_of_sys_xcpt ArithmeticException = x2i ∨ addr_of_sys_xcpt ArithmeticException = x2j› 8. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt IllegalMonitorState = x2 ∨ addr_of_sys_xcpt IllegalMonitorState = x2a ∨ addr_of_sys_xcpt IllegalMonitorState = x2b ∨ addr_of_sys_xcpt IllegalMonitorState = x2c ∨ addr_of_sys_xcpt IllegalMonitorState = x2d ∨ addr_of_sys_xcpt IllegalMonitorState = x2e ∨ addr_of_sys_xcpt IllegalMonitorState = x2f ∨ addr_of_sys_xcpt IllegalMonitorState = x2g ∨ addr_of_sys_xcpt IllegalMonitorState = x2h ∨ addr_of_sys_xcpt IllegalMonitorState = x2i ∨ addr_of_sys_xcpt IllegalMonitorState = x2j› 9. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt IllegalThreadState = x2 ∨ addr_of_sys_xcpt IllegalThreadState = x2a ∨ addr_of_sys_xcpt IllegalThreadState = x2b ∨ addr_of_sys_xcpt IllegalThreadState = x2c ∨ addr_of_sys_xcpt IllegalThreadState = x2d ∨ addr_of_sys_xcpt IllegalThreadState = x2e ∨ addr_of_sys_xcpt IllegalThreadState = x2f ∨ addr_of_sys_xcpt IllegalThreadState = x2g ∨ addr_of_sys_xcpt IllegalThreadState = x2h ∨ addr_of_sys_xcpt IllegalThreadState = x2i ∨ addr_of_sys_xcpt IllegalThreadState = x2j› 10. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ addr_of_sys_xcpt InterruptedException = x2 ∨ addr_of_sys_xcpt InterruptedException = x2a ∨ addr_of_sys_xcpt InterruptedException = x2b ∨ addr_of_sys_xcpt InterruptedException = x2c ∨ addr_of_sys_xcpt InterruptedException = x2d ∨ addr_of_sys_xcpt InterruptedException = x2e ∨ addr_of_sys_xcpt InterruptedException = x2f ∨ addr_of_sys_xcpt InterruptedException = x2g ∨ addr_of_sys_xcpt InterruptedException = x2h ∨ addr_of_sys_xcpt InterruptedException = x2i ∨ addr_of_sys_xcpt InterruptedException = x2j› discuss goal 1*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 2*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 3*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 4*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 5*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 6*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 7*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 8*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 9*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*discuss goal 10*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*proven 10 subgoals*) . lemma [simp]: assumes "preallocated h" shows typeof_ClassCast: "typeof_addr h (addr_of_sys_xcpt ClassCast) = Some(Class_type ClassCast)" and typeof_OutOfMemory: "typeof_addr h (addr_of_sys_xcpt OutOfMemory) = Some(Class_type OutOfMemory)" and typeof_NullPointer: "typeof_addr h (addr_of_sys_xcpt NullPointer) = Some(Class_type NullPointer)" and typeof_ArrayIndexOutOfBounds: "typeof_addr h (addr_of_sys_xcpt ArrayIndexOutOfBounds) = Some(Class_type ArrayIndexOutOfBounds)" and typeof_ArrayStore: "typeof_addr h (addr_of_sys_xcpt ArrayStore) = Some(Class_type ArrayStore)" and typeof_NegativeArraySize: "typeof_addr h (addr_of_sys_xcpt NegativeArraySize) = Some(Class_type NegativeArraySize)" and typeof_ArithmeticException: "typeof_addr h (addr_of_sys_xcpt ArithmeticException) = Some(Class_type ArithmeticException)" and typeof_IllegalMonitorState: "typeof_addr h (addr_of_sys_xcpt IllegalMonitorState) = Some(Class_type IllegalMonitorState)" and typeof_IllegalThreadState: "typeof_addr h (addr_of_sys_xcpt IllegalThreadState) = Some(Class_type IllegalThreadState)" and typeof_InterruptedException: "typeof_addr h (addr_of_sys_xcpt InterruptedException) = Some(Class_type InterruptedException)" using assms (*‹preallocated h›*) apply - (*goals: 1. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt ClassCast) = ⌊Class_type ClassCast⌋› 2. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt OutOfMemory) = ⌊Class_type OutOfMemory⌋› 3. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt NullPointer) = ⌊Class_type NullPointer⌋› 4. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt ArrayIndexOutOfBounds) = ⌊Class_type ArrayIndexOutOfBounds⌋› 5. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt ArrayStore) = ⌊Class_type ArrayStore⌋› 6. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt NegativeArraySize) = ⌊Class_type NegativeArraySize⌋› 7. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt ArithmeticException) = ⌊Class_type ArithmeticException⌋› 8. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt IllegalMonitorState) = ⌊Class_type IllegalMonitorState⌋› 9. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt IllegalThreadState) = ⌊Class_type IllegalThreadState⌋› 10. ‹preallocated h ⟹ typeof_addr h (addr_of_sys_xcpt InterruptedException) = ⌊Class_type InterruptedException⌋› discuss goal 1*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated (?h::'heap::type); (?C::String.literal) ∈ sys_xcpts⟧ ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 2*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 3*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 4*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 5*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 6*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 7*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 8*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 9*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*discuss goal 10*) apply (simp add: typeof_addr_sys_xcp (*‹⟦preallocated (?h::'heap::type); (?C::String.literal) ∈ sys_xcpts⟧ ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*proven 10 subgoals*) . lemma cname_of_xcp [simp]: "⟦ preallocated h; C ∈ sys_xcpts ⟧ ⟹ cname_of h (addr_of_sys_xcpt C) = C" apply (drule (1) typeof_addr_sys_xcp (*‹⟦preallocated ?h; ?C ∈ sys_xcpts⟧ ⟹ typeof_addr ?h (addr_of_sys_xcpt ?C) = ⌊Class_type ?C⌋›*)) (*goal: ‹⟦preallocated h; C ∈ sys_xcpts⟧ ⟹ cname_of h (addr_of_sys_xcpt C) = C›*) by (simp add: cname_of_def (*‹cname_of (?h::'heap::type) (?a::'addr::addr) = the_Class (ty_of_htype (the ((typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h ?a)))›*)) lemma preallocated_hext: "⟦ preallocated h; h ⊴ h' ⟧ ⟹ preallocated h'" by (auto simp add: preallocated_def (*‹preallocated ?h ≡ ∀C∈sys_xcpts. typeof_addr ?h (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) dest: hext_objD (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊Class_type ?C⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊Class_type ?C⌋›*)) end context heap begin lemma preallocated_heap_ops: assumes "preallocated h" shows preallocated_allocate: "⋀a. (h', a) ∈ allocate h hT ⟹ preallocated h'" and preallocated_write_field: "heap_write h a al v h' ⟹ preallocated h'" using preallocated_hext[OF assms, of h'] (*‹h ⊴ h' ⟹ preallocated h'›*) apply - (*goals: 1. ‹⋀a::'addr. ⟦(h'::'heap, a) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (hT::htype); h ⊴ h' ⟹ preallocated h'⟧ ⟹ preallocated h'› 2. ‹⟦(heap_write::'heap ⇒ 'addr ⇒ addr_loc ⇒ 'addr val ⇒ 'heap ⇒ bool) (h::'heap) (a::'addr) (al::addr_loc) (v::'addr val) (h'::'heap); h ⊴ h' ⟹ preallocated h'⟧ ⟹ preallocated h'› discuss goal 1*) apply (blast intro: hext_heap_ops (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'› ‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*)) (*discuss goal 2*) apply (blast intro: hext_heap_ops (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'› ‹heap_write ?h ?a ?al ?v ?h' ⟹ ?h ⊴ ?h'›*)) (*proven 2 subgoals*) . lemma not_empty_pairE: "⟦ A ≠ {}; ⋀a b. (a, b) ∈ A ⟹ thesis ⟧ ⟹ thesis" by auto lemma allocate_not_emptyI: "(h', a) ∈ allocate h hT ⟹ allocate h hT ≠ {}" by auto lemma allocate_Eps: "⟦ (h'', a'') ∈ allocate h hT; (SOME ha. ha ∈ allocate h hT) = (h', a') ⟧ ⟹ (h', a') ∈ allocate h hT" apply (drule sym (*‹?s = ?t ⟹ ?t = ?s›*)) (*goal: ‹⟦(h'', a'') ∈ allocate h hT; (SOME ha. ha ∈ allocate h hT) = (h', a')⟧ ⟹ (h', a') ∈ allocate h hT›*) by (auto intro: someI (*‹?P ?x ⟹ ?P (Eps ?P)›*)) lemma preallocated_start_heap: "⟦ start_heap_ok; wf_syscls P ⟧ ⟹ preallocated start_heap" unfolding start_heap_ok_def start_heap_data_def initialization_list_def sys_xcpts_list_def preallocated_def start_heap_def start_addrs_def (*goal: ‹⟦snd (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])); wf_syscls P⟧ ⟹ ∀C∈sys_xcpts. typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])) (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (clarsimp split: prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*)) (*goal: ‹⟦snd (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])); wf_syscls P⟧ ⟹ ∀C∈sys_xcpts. typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])) (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C. ⟦wf_syscls P; allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦(?A::(?'a::type × ?'b::type) set) ≠ {}; ⋀(a::?'a::type) b::?'b::type. (a, b) ∈ ?A ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) ba::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer)⟧ ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) bc::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory)⟧ ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦(?A::(?'a::type × ?'b::type) set) ≠ {}; ⋀(a::?'a::type) b::?'b::type. (a, b) ∈ ?A ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦(?A::(?'a × ?'b) set) ≠ {}; ⋀(a::?'a) b::?'b. (a, b) ∈ ?A ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) bh::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState)⟧ ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h''::'heap, ?a''::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype); (SOME ha::'heap × 'addr. ha ∈ allocate ?h ?hT) = (?h'::'heap, ?a'::'addr)⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) (x2j::'addr::addr) (C::String.literal) (a::'heap::type) (b::'addr::addr) (aa::'heap::type) (ba::'addr::addr) (ab::'heap::type) (bb::'addr::addr) (ac::'heap::type) (bc::'addr::addr) (ad::'heap::type) (bd::'addr::addr) (ae::'heap::type) (be::'addr::addr) (af::'heap::type) (bf::'addr::addr) (ag::'heap::type) (bg::'addr::addr) (ah::'heap::type) (bh::'addr::addr) (ai::'heap::type) (bi::'addr::addr) (aj::'heap::type) bj::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h''::'heap, ?a''::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype); (SOME ha::'heap × 'addr. ha ∈ allocate ?h ?hT) = (?h'::'heap, ?a'::'addr)⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize)⟧ ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 13) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts⟧ ⟹ is_htype P (Class_type Thread)› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1, x2) ∈ allocate empty_heap (Class_type Thread); (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1a, x2a) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread)⟧ ⟹ is_htype P (Class_type NullPointer)› 2. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1a, x2a) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1a, x2a) ∈ allocate x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1a, x2a) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1 (Class_type NullPointer); (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1b, x2b) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer)⟧ ⟹ is_htype P (Class_type ClassCast)› 2. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1b, x2b) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦(?C::String.literal) ∈ sys_xcpts; wf_syscls (?P::?'a prog)⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1b, x2b) ∈ allocate x1a (Class_type ClassCast); (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast)⟧ ⟹ is_htype P (Class_type OutOfMemory)› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1d, x2d) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory)⟧ ⟹ is_htype P (Class_type ArrayIndexOutOfBounds)› 2. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1d, x2d) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)⟧ ⟹ is_htype P (Class_type ArrayStore)› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1f, x2f) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore)⟧ ⟹ is_htype P (Class_type NegativeArraySize)› 2. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1f, x2f) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦(?C::String.literal) ∈ sys_xcpts; wf_syscls (?P::?'a prog)⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1g, x2g) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize)⟧ ⟹ is_htype P (Class_type ArithmeticException)› 2. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1g, x2g) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1g, x2g) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException)⟧ ⟹ is_htype P (Class_type IllegalMonitorState)› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1h, x2h) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h'::'heap::type, ?a::'addr::addr) ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (?h::'heap::type) (?hT::htype); is_htype (P::'m::type prog) ?hT⟧ ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState)⟧ ⟹ is_htype P (Class_type IllegalThreadState)› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1i, x2i) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1h (Class_type IllegalThreadState); (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (frule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState)⟧ ⟹ is_htype P (Class_type InterruptedException)› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋› discuss goal 1*) apply (simp add: wf_syscls_is_class_xcpt (*‹⟦?C ∈ sys_xcpts; wf_syscls ?P⟧ ⟹ is_class ?P ?C›*)) (*discuss goal 2*) apply (frule hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦(x1j, x2j) ∈ allocate x1i (Class_type InterruptedException); wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (rotate_tac 1) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦(x1j, x2j) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) x1i (Class_type InterruptedException); wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ allocate (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); C ∈ sys_xcpts; (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt C) = ⌊Class_type C⌋›*) apply (erule sys_xcpts_cases (*‹⟦?C ∈ sys_xcpts; ?P NullPointer; ?P OutOfMemory; ?P ClassCast; ?P ArrayIndexOutOfBounds; ?P ArrayStore; ?P NegativeArraySize; ?P ArithmeticException; ?P IllegalMonitorState; ?P IllegalThreadState; ?P InterruptedException⟧ ⟹ ?P ?C›*)) (*goals: 1. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt NullPointer) = ⌊Class_type NullPointer⌋› 2. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt OutOfMemory) = ⌊Class_type OutOfMemory⌋› 3. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ClassCast) = ⌊Class_type ClassCast⌋› 4. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ArrayIndexOutOfBounds) = ⌊Class_type ArrayIndexOutOfBounds⌋› 5. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ArrayStore) = ⌊Class_type ArrayStore⌋› 6. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt NegativeArraySize) = ⌊Class_type NegativeArraySize⌋› 7. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ArithmeticException) = ⌊Class_type ArithmeticException⌋› 8. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt IllegalMonitorState) = ⌊Class_type IllegalMonitorState⌋› 9. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt IllegalThreadState) = ⌊Class_type IllegalThreadState⌋› 10. ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt InterruptedException) = ⌊Class_type InterruptedException⌋› discuss goal 1*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt NullPointer) = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1g x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1f x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1e x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1d x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1c x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1b x2a = ⌊Class_type NullPointer⌋› and 9 goals remain*) apply assumption (*discuss goal 2*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt OutOfMemory) = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1g x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1f x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1e x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1d x2c = ⌊Class_type OutOfMemory⌋› and 8 goals remain*) apply assumption (*discuss goal 3*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt (?C::String.literal) = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap::'heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h::'heap, ?ads::'addr list, ?b::bool) (?C::String.literal) = (if ?b then let HA::('heap × 'addr) set = (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h'::'heap, a''::'addr) = SOME ha::'heap × 'addr. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ClassCast) = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1g x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1f x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1e x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1d x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1c x2b = ⌊Class_type ClassCast⌋› and 7 goals remain*) apply assumption (*discuss goal 4*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ArrayIndexOutOfBounds) = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2d = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2d = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2d = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1g x2d = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1f x2d = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1e x2d = ⌊Class_type ArrayIndexOutOfBounds⌋› and 6 goals remain*) apply assumption (*discuss goal 5*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ArrayStore) = ⌊Class_type ArrayStore⌋› and 5 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2e = ⌊Class_type ArrayStore⌋› and 5 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2e = ⌊Class_type ArrayStore⌋› and 5 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2e = ⌊Class_type ArrayStore⌋› and 5 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1g x2e = ⌊Class_type ArrayStore⌋› and 5 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1f x2e = ⌊Class_type ArrayStore⌋› and 5 goals remain*) apply assumption (*discuss goal 6*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt NegativeArraySize) = ⌊Class_type NegativeArraySize⌋› and 4 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap::type) ⊴ (?h'::'heap::type); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h (?a::'addr::addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2f = ⌊Class_type NegativeArraySize⌋› and 4 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2f = ⌊Class_type NegativeArraySize⌋› and 4 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2f = ⌊Class_type NegativeArraySize⌋› and 4 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦(?h::'heap::type) ⊴ (?h'::'heap::type); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) ?h (?a::'addr::addr) = ⌊?hT::htype⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1g x2f = ⌊Class_type NegativeArraySize⌋› and 4 goals remain*) apply assumption (*discuss goal 7*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt ArithmeticException) = ⌊Class_type ArithmeticException⌋› and 3 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2g = ⌊Class_type ArithmeticException⌋› and 3 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2g = ⌊Class_type ArithmeticException⌋› and 3 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1h x2g = ⌊Class_type ArithmeticException⌋› and 3 goals remain*) apply assumption (*discuss goal 8*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt (?C::String.literal) = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap::'heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h::'heap, ?ads::'addr list, ?b::bool) (?C::String.literal) = (if ?b then let HA::('heap × 'addr) set = (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h'::'heap, a''::'addr) = SOME ha::'heap × 'addr. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (C::String.literal) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt IllegalMonitorState) = ⌊Class_type IllegalMonitorState⌋› and 2 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) x2j::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2h = ⌊Class_type IllegalMonitorState⌋› and 2 goals remain*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1i x2h = ⌊Class_type IllegalMonitorState⌋› and 2 goals remain*) apply assumption (*discuss goal 9*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j C a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); typeof_addr x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j (addr_of_sys_xcpt IllegalThreadState) = ⌊Class_type IllegalThreadState⌋› and 1 goal remains*) apply (erule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*top goal: ‹⋀(x1::'heap::type) (x2::'addr::addr) (x1a::'heap::type) (x2a::'addr::addr) (x1b::'heap::type) (x2b::'addr::addr) (x1c::'heap::type) (x2c::'addr::addr) (x1d::'heap::type) (x2d::'addr::addr) (x1e::'heap::type) (x2e::'addr::addr) (x1f::'heap::type) (x2f::'addr::addr) (x1g::'heap::type) (x2g::'addr::addr) (x1h::'heap::type) (x2h::'addr::addr) (x1i::'heap::type) (x2i::'addr::addr) (x1j::'heap::type) x2j::'addr::addr. ⟦wf_syscls (P::'m::type prog); (SOME ha::'heap::type × 'addr::addr. ha ∈ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (empty_heap::'heap::type) (Class_type Thread)) = (x1, x2); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap::type × 'addr::addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋; empty_heap ⊴ x1; (x1, x2) ∈ allocate empty_heap (Class_type Thread); typeof_addr x1a x2a = ⌊Class_type NullPointer⌋; x1 ⊴ x1a; (x1a, x2a) ∈ allocate x1 (Class_type NullPointer); typeof_addr x1b x2b = ⌊Class_type ClassCast⌋; x1a ⊴ x1b; (x1b, x2b) ∈ allocate x1a (Class_type ClassCast); typeof_addr x1c x2c = ⌊Class_type OutOfMemory⌋; x1b ⊴ x1c; (x1c, x2c) ∈ allocate x1b (Class_type OutOfMemory); typeof_addr x1d x2d = ⌊Class_type ArrayIndexOutOfBounds⌋; x1c ⊴ x1d; (x1d, x2d) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); typeof_addr x1e x2e = ⌊Class_type ArrayStore⌋; x1d ⊴ x1e; (x1e, x2e) ∈ allocate x1d (Class_type ArrayStore); typeof_addr x1f x2f = ⌊Class_type NegativeArraySize⌋; x1e ⊴ x1f; (x1f, x2f) ∈ allocate x1e (Class_type NegativeArraySize); typeof_addr x1g x2g = ⌊Class_type ArithmeticException⌋; x1f ⊴ x1g; (x1g, x2g) ∈ allocate x1f (Class_type ArithmeticException); typeof_addr x1h x2h = ⌊Class_type IllegalMonitorState⌋; x1g ⊴ x1h; (x1h, x2h) ∈ allocate x1g (Class_type IllegalMonitorState); typeof_addr x1i x2i = ⌊Class_type IllegalThreadState⌋; x1h ⊴ x1i; (x1i, x2i) ∈ allocate x1h (Class_type IllegalThreadState); typeof_addr x1j x2j = ⌊Class_type InterruptedException⌋; x1i ⊴ x1j; (x1j, x2j) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ typeof_addr x1j x2i = ⌊Class_type IllegalThreadState⌋› and 1 goal remains*) apply assumption (*discuss goal 10*) apply (simp add: addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt (?C::String.literal) = the (map_of (zip initialization_list start_addrs) ?C)›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*) sys_xcpts_neqs (*‹NullPointer ≠ ClassCast› ‹NullPointer ≠ OutOfMemory› ‹NullPointer ≠ ArrayIndexOutOfBounds› ‹NullPointer ≠ ArrayStore› ‹NullPointer ≠ NegativeArraySize› ‹NullPointer ≠ IllegalMonitorState› ‹NullPointer ≠ IllegalThreadState› ‹NullPointer ≠ InterruptedException› ‹NullPointer ≠ ArithmeticException› ‹ClassCast ≠ OutOfMemory› ‹ClassCast ≠ ArrayIndexOutOfBounds› ‹ClassCast ≠ ArrayStore› and more 78 facts*) Thread_neq_sys_xcpts (*‹Thread ≠ NullPointer› ‹Thread ≠ ClassCast› ‹Thread ≠ OutOfMemory› ‹Thread ≠ ArrayIndexOutOfBounds› ‹Thread ≠ ArrayStore› ‹Thread ≠ NegativeArraySize› ‹Thread ≠ ArithmeticException› ‹Thread ≠ IllegalMonitorState› ‹Thread ≠ IllegalThreadState› ‹Thread ≠ InterruptedException› ‹NullPointer ≠ Thread› ‹ClassCast ≠ Thread› and more 8 facts*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap::'heap, [], True) initialization_list›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) create_initial_object_simps (*‹create_initial_object (?h::'heap, ?ads::'addr list, ?b::bool) (?C::String.literal) = (if ?b then let HA::('heap × 'addr) set = (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h'::'heap, a''::'addr) = SOME ha::'heap × 'addr. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) allocate_not_emptyI (*‹(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype) ⟹ allocate ?h ?hT ≠ {}›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*proven 10 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma start_tid_start_addrs: "⟦ wf_syscls P; start_heap_ok ⟧ ⟹ thread_id2addr start_tid ∈ set start_addrs" unfolding start_heap_ok_def start_heap_data_def initialization_list_def sys_xcpts_list_def preallocated_def start_heap_def start_addrs_def (*goal: ‹⟦wf_syscls P; snd (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]))⟧ ⟹ thread_id2addr start_tid ∈ set (fst (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])))›*) apply (simp split: prod.split_asm (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) addr_of_sys_xcpt_def (*‹addr_of_sys_xcpt ?C = the (map_of (zip initialization_list start_addrs) ?C)›*) start_addrs_def (*‹start_addrs = fst (snd start_heap_data)›*) start_tid_def (*‹start_tid = addr2thread_id (hd start_addrs)›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) initialization_list_def (*‹initialization_list = Thread # sys_xcpts_list›*) sys_xcpts_list_def (*‹sys_xcpts_list = [NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]›*)) (*goal: ‹⟦wf_syscls P; snd (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException]))⟧ ⟹ thread_id2addr start_tid ∈ set (fst (snd (foldl create_initial_object (empty_heap, [], True) [Thread, NullPointer, ClassCast, OutOfMemory, ArrayIndexOutOfBounds, ArrayStore, NegativeArraySize, ArithmeticException, IllegalMonitorState, IllegalThreadState, InterruptedException])))›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j. ⟦wf_syscls P; allocate empty_heap (Class_type Thread) ≠ {}; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); allocate x1 (Class_type NullPointer) ≠ {}; (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦(?A::(?'a × ?'b) set) ≠ {}; ⋀(a::?'a) b::?'b. (a, b) ∈ ?A ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); allocate x1a (Class_type ClassCast) ≠ {}; (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); allocate x1b (Class_type OutOfMemory) ≠ {}; (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); allocate x1c (Class_type ArrayIndexOutOfBounds) ≠ {}; (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); allocate x1d (Class_type ArrayStore) ≠ {}; (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) be::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); allocate x1e (Class_type NegativeArraySize) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore)⟧ ⟹ (thread_id2addr::'thread_id ⇒ 'addr) ((addr2thread_id::'addr ⇒ 'thread_id) x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦(?A::(?'a × ?'b) set) ≠ {}; ⋀(a::?'a) b::?'b. (a, b) ∈ ?A ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd ae be af bf. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); allocate x1f (Class_type ArithmeticException) ≠ {}; (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd ae be af bf ag bg. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); allocate x1g (Class_type IllegalMonitorState) ≠ {}; (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); allocate x1h (Class_type IllegalThreadState) ≠ {}; (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (erule not_empty_pairE (*‹⟦?A ≠ {}; ⋀a b. (a, b) ∈ ?A ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); allocate x1i (Class_type InterruptedException) ≠ {}; (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (drule (1) allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (a, b) ∈ allocate empty_heap (Class_type Thread); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (rotate_tac -1) (*goal: ‹⋀x1 x2 x1a x2a x1b x2b x1c x2c x1d x2d x1e x2e x1f x2f x1g x2g x1h x2h x1i x2i x1j x2j a b aa ba ab bb ac bc ad bd ae be af bf ag bg ah bh ai bi aj bj. ⟦wf_syscls P; (SOME ha. ha ∈ allocate empty_heap (Class_type Thread)) = (x1, x2); (SOME ha. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (x1, x2) ∈ allocate empty_heap (Class_type Thread)⟧ ⟹ thread_id2addr (addr2thread_id x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j›*) apply (drule allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) (*goals: 1. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException)⟧ ⟹ is_htype P (Class_type Thread)› 2. ‹⋀(x1::'heap) (x2::'addr) (x1a::'heap) (x2a::'addr) (x1b::'heap) (x2b::'addr) (x1c::'heap) (x2c::'addr) (x1d::'heap) (x2d::'addr) (x1e::'heap) (x2e::'addr) (x1f::'heap) (x2f::'addr) (x1g::'heap) (x2g::'addr) (x1h::'heap) (x2h::'addr) (x1i::'heap) (x2i::'addr) (x1j::'heap) (x2j::'addr) (a::'heap) (b::'addr) (aa::'heap) (ba::'addr) (ab::'heap) (bb::'addr) (ac::'heap) (bc::'addr) (ad::'heap) (bd::'addr) (ae::'heap) (be::'addr) (af::'heap) (bf::'addr) (ag::'heap) (bg::'addr) (ah::'heap) (bh::'addr) (ai::'heap) (bi::'addr) (aj::'heap) bj::'addr. ⟦wf_syscls (P::'m prog); (SOME ha::'heap × 'addr. ha ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (empty_heap::'heap) (Class_type Thread)) = (x1, x2); (SOME ha::'heap × 'addr. ha ∈ allocate x1 (Class_type NullPointer)) = (x1a, x2a); (SOME ha::'heap × 'addr. ha ∈ allocate x1a (Class_type ClassCast)) = (x1b, x2b); (SOME ha::'heap × 'addr. ha ∈ allocate x1b (Class_type OutOfMemory)) = (x1c, x2c); (SOME ha::'heap × 'addr. ha ∈ allocate x1c (Class_type ArrayIndexOutOfBounds)) = (x1d, x2d); (SOME ha::'heap × 'addr. ha ∈ allocate x1d (Class_type ArrayStore)) = (x1e, x2e); (SOME ha::'heap × 'addr. ha ∈ allocate x1e (Class_type NegativeArraySize)) = (x1f, x2f); (SOME ha::'heap × 'addr. ha ∈ allocate x1f (Class_type ArithmeticException)) = (x1g, x2g); (SOME ha::'heap × 'addr. ha ∈ allocate x1g (Class_type IllegalMonitorState)) = (x1h, x2h); (SOME ha::'heap × 'addr. ha ∈ allocate x1h (Class_type IllegalThreadState)) = (x1i, x2i); (SOME ha::'heap × 'addr. ha ∈ allocate x1i (Class_type InterruptedException)) = (x1j, x2j); (aa, ba) ∈ allocate x1 (Class_type NullPointer); (ab, bb) ∈ allocate x1a (Class_type ClassCast); (ac, bc) ∈ allocate x1b (Class_type OutOfMemory); (ad, bd) ∈ allocate x1c (Class_type ArrayIndexOutOfBounds); (ae, be) ∈ allocate x1d (Class_type ArrayStore); (af, bf) ∈ allocate x1e (Class_type NegativeArraySize); (ag, bg) ∈ allocate x1f (Class_type ArithmeticException); (ah, bh) ∈ allocate x1g (Class_type IllegalMonitorState); (ai, bi) ∈ allocate x1h (Class_type IllegalThreadState); (aj, bj) ∈ allocate x1i (Class_type InterruptedException); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) x1 x2 = ⌊Class_type Thread⌋⟧ ⟹ (thread_id2addr::'thread_id ⇒ 'addr) ((addr2thread_id::'addr ⇒ 'thread_id) x2) = x2 ∨ thread_id2addr (addr2thread_id x2) = x2a ∨ thread_id2addr (addr2thread_id x2) = x2b ∨ thread_id2addr (addr2thread_id x2) = x2c ∨ thread_id2addr (addr2thread_id x2) = x2d ∨ thread_id2addr (addr2thread_id x2) = x2e ∨ thread_id2addr (addr2thread_id x2) = x2f ∨ thread_id2addr (addr2thread_id x2) = x2g ∨ thread_id2addr (addr2thread_id x2) = x2h ∨ thread_id2addr (addr2thread_id x2) = x2i ∨ thread_id2addr (addr2thread_id x2) = x2j› discuss goal 1*) apply simp (*discuss goal 2*) apply (auto intro: addr2thread_id_inverse (*‹⟦typeof_addr ?h ?a = ⌊Class_type ?C⌋; P ⊢ ?C ≼⇧* Thread⟧ ⟹ thread_id2addr (addr2thread_id ?a) = ?a›*)) (*proven 2 subgoals*) . lemma assumes "wf_syscls P" shows dom_typeof_addr_start_heap: "set start_addrs ⊆ dom (typeof_addr start_heap)" and distinct_start_addrs: "distinct start_addrs" proof (-) (*goals: 1. ‹set start_addrs ⊆ dom (typeof_addr start_heap)› 2. ‹distinct start_addrs›*) { fix h and ads and b and Cs :: "cname list" and xs :: "cname list" assume "set ads ⊆ dom (typeof_addr h)" and "distinct (Cs @ xs)" and "length Cs = length ads" and "⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋" and "⋀C. C ∈ set xs ⟹ is_class P C" (*‹set (ads::'addr list) ⊆ dom ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h::'heap))› ‹distinct ((Cs::String.literal list) @ (xs::String.literal list))› ‹length (Cs::String.literal list) = length (ads::'addr list)› ‹(?C3::String.literal, ?a3::'addr) ∈ set (zip (Cs::String.literal list) (ads::'addr list)) ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h::'heap) ?a3 = ⌊Class_type ?C3⌋› ‹(?C3::String.literal) ∈ set (xs::String.literal list) ⟹ is_class (P::'m prog) ?C3›*) hence "set (fst (snd (foldl create_initial_object (h, ads, b) xs))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) xs))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) xs))))" (is "?concl xs h ads b Cs") proof (induct xs arbitrary: h ads b Cs) (*goals: 1. ‹⋀h ads b Cs. ⟦set ads ⊆ dom (typeof_addr h); distinct (Cs @ []); length Cs = length ads; ⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋; ⋀C. C ∈ set [] ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) []))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) []))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) []))))› 2. ‹⋀a xs h ads b Cs. ⟦⋀h ads b Cs. ⟦set ads ⊆ dom (typeof_addr h); distinct (Cs @ xs); length Cs = length ads; ⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋; ⋀C. C ∈ set xs ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) xs))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) xs))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) xs)))); set ads ⊆ dom (typeof_addr h); distinct (Cs @ a # xs); length Cs = length ads; ⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋; ⋀C. C ∈ set (a # xs) ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) (a # xs)))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) (a # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (a # xs)))))›*) case Nil (*‹set ads ⊆ dom (typeof_addr h)› ‹distinct ((Cs::String.literal list) @ [])› ‹length Cs = length ads› ‹(?C3, ?a3) ∈ set (zip Cs ads) ⟹ typeof_addr h ?a3 = ⌊Class_type ?C3⌋› ‹?C3 ∈ set [] ⟹ is_class P ?C3›*) thus "?case" (*goal: ‹set (fst (snd (foldl create_initial_object (h, ads, b) []))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) []))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) []))))›*) by auto next (*goal: ‹⋀a xs h ads b Cs. ⟦⋀h ads b Cs. ⟦set ads ⊆ dom (typeof_addr h); distinct (Cs @ xs); length Cs = length ads; ⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋; ⋀C. C ∈ set xs ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) xs))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) xs))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) xs)))); set ads ⊆ dom (typeof_addr h); distinct (Cs @ a # xs); length Cs = length ads; ⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋; ⋀C. C ∈ set (a # xs) ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) (a # xs)))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) (a # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (a # xs)))))›*) case (Cons x xs) (*‹⟦set ?ads3 ⊆ dom (typeof_addr ?h3); distinct (?Cs3 @ xs); length ?Cs3 = length ?ads3; ⋀C a. (C, a) ∈ set (zip ?Cs3 ?ads3) ⟹ typeof_addr ?h3 a = ⌊Class_type C⌋; ⋀C. C ∈ set xs ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (?h3, ?ads3, ?b3) xs))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (?h3, ?ads3, ?b3) xs))) ∧ (distinct ?ads3 ⟶ distinct (fst (snd (foldl create_initial_object (?h3, ?ads3, ?b3) xs))))› ‹set ads ⊆ dom (typeof_addr h)› ‹distinct (Cs @ x # xs)› ‹length Cs = length ads› ‹(?C3, ?a3) ∈ set (zip Cs ads) ⟹ typeof_addr h ?a3 = ⌊Class_type ?C3⌋› ‹?C3 ∈ set (x # xs) ⟹ is_class P ?C3›*) note ads = ‹set ads ⊆ dom (typeof_addr h)› (*‹set (ads::'addr list) ⊆ dom ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h::'heap))›*) note dist = ‹distinct (Cs @ x # xs)› (*‹distinct ((Cs::String.literal list) @ (x::String.literal) # (xs::String.literal list))›*) note len = ‹length Cs = length ads› (*‹length Cs = length ads›*) note type = ‹⋀C a. (C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋› (*‹(?C::String.literal, ?a::'addr::addr) ∈ set (zip (Cs::String.literal list) (ads::'addr::addr list)) ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (h::'heap::type) ?a = ⌊Class_type ?C⌋›*) note is_class = ‹⋀C. C ∈ set (x # xs) ⟹ is_class P C› (*‹?C ∈ set (x # xs) ⟹ is_class P ?C›*) show "?case" (*goal: ‹set (fst (snd (foldl create_initial_object (h::'heap::type, ads::'addr::addr list, b::bool) ((x::String.literal) # (xs::String.literal list))))) ⊆ dom ((typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (fst (foldl create_initial_object (h, ads, b) (x # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) proof (cases "b ∧ allocate h (Class_type x) ≠ {}") (*goals: 1. ‹b ∧ allocate h (Class_type x) ≠ {} ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))› 2. ‹¬ (b ∧ allocate h (Class_type x) ≠ {}) ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) case False (*‹¬ (b ∧ allocate h (Class_type x) ≠ {})›*) thus "?thesis" (*goal: ‹set (fst (snd (foldl create_initial_object (h::'heap, ads::'addr list, b::bool) ((x::String.literal) # (xs::String.literal list))))) ⊆ dom ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) (fst (foldl create_initial_object (h, ads, b) (x # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) using ads (*‹set (ads::'addr list) ⊆ dom ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h::'heap))›*) len (*‹length Cs = length ads›*) by (auto simp add: create_initial_object_simps (*‹create_initial_object (?h::'heap, ?ads::'addr list, ?b::bool) (?C::String.literal) = (if ?b then let HA::('heap × 'addr) set = (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h'::'heap, a''::'addr) = SOME ha::'heap × 'addr. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) zip_append1 (*‹zip ((?xs::?'a list) @ (?ys::?'a list)) (?zs::?'b list) = zip ?xs (take (length ?xs) ?zs) @ zip ?ys (drop (length ?xs) ?zs)›*)) next (*goal: ‹b ∧ allocate h (Class_type x) ≠ {} ⟹ set (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) case [simp]: True (*‹(b::bool) ∧ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (Class_type (x::String.literal)) ≠ {}›*) obtain h' and a' where h'a': "(SOME ha. ha ∈ allocate h (Class_type x)) = (h', a')" (*goal: ‹(⋀h' a'. (SOME haa. haa ∈ allocate h (Class_type x)) = (h', a') ⟹ thesis) ⟹ thesis›*) by (cases "SOME ha. ha ∈ allocate h (Class_type x)") with True (*‹b ∧ allocate h (Class_type x) ≠ {}›*) have new_obj: "(h', a') ∈ allocate h (Class_type x)" by (auto simp del: True (*‹b ∧ allocate h (Class_type x) ≠ {}›*) intro: allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) hence hext: "h ⊴ h'" by (rule hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*)) with ads (*‹set ads ⊆ dom (typeof_addr h)›*) new_obj (*‹(h'::'heap, a'::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (Class_type (x::String.literal))›*) have ads': "set ads ⊆ dom (typeof_addr h')" by (auto dest: typeof_addr_hext_mono[OF hext_allocate] (*‹⟦(?h', ?a1) ∈ allocate ?h ?hT1; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) moreover { from new_obj (*‹(h', a') ∈ allocate h (Class_type x)›*) ads' (*‹set ads ⊆ dom (typeof_addr h')›*) is_class[of x] (*‹(x::String.literal) ∈ set (x # (xs::String.literal list)) ⟹ is_class (P::'m prog) x›*) have "set (ads @ [a']) ⊆ dom (typeof_addr h')" by (auto dest: allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) moreover from dist (*‹distinct ((Cs::String.literal list) @ (x::String.literal) # (xs::String.literal list))›*) have "distinct ((Cs @ [x]) @ xs)" by simp moreover have "length (Cs @ [x]) = length (ads @ [a'])" using len (*‹length (Cs::String.literal list) = length (ads::'addr list)›*) by simp moreover { fix C and a assume "(C, a) ∈ set (zip (Cs @ [x]) (ads @ [a']))" (*‹(C::String.literal, a::'addr) ∈ set (zip ((Cs::String.literal list) @ [x::String.literal]) ((ads::'addr list) @ [a'::'addr]))›*) hence "typeof_addr h' a = ⌊Class_type C⌋" using hext (*‹h ⊴ h'›*) new_obj (*‹(h'::'heap, a'::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (Class_type (x::String.literal))›*) type[of C a] (*‹(C, a) ∈ set (zip Cs ads) ⟹ typeof_addr h a = ⌊Class_type C⌋›*) len (*‹length Cs = length ads›*) is_class (*‹(?C::String.literal) ∈ set ((x::String.literal) # (xs::String.literal list)) ⟹ is_class (P::'m::type prog) ?C›*) by (auto dest: allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*) hext_objD (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊Class_type ?C⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊Class_type ?C⌋›*)) } note type' = this (*‹(?C5::String.literal, ?a5::'addr) ∈ set (zip ((Cs::String.literal list) @ [x::String.literal]) ((ads::'addr list) @ [a'::'addr])) ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h'::'heap) ?a5 = ⌊Class_type ?C5⌋›*) moreover have is_class': "⋀C. C ∈ set xs ⟹ is_class P C" using is_class (*‹?C ∈ set (x # xs) ⟹ is_class P ?C›*) by simp ultimately have "?concl xs h' (ads @ [a']) True (Cs @ [x])" apply (rule Cons (*‹⟦set (?ads3::'addr::addr list) ⊆ dom ((typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (?h3::'heap::type)); distinct ((?Cs3::String.literal list) @ (xs::String.literal list)); length ?Cs3 = length ?ads3; ⋀(C::String.literal) a::'addr::addr. (C, a) ∈ set (zip ?Cs3 ?ads3) ⟹ typeof_addr ?h3 a = ⌊Class_type C⌋; ⋀C::String.literal. C ∈ set xs ⟹ is_class (P::'m::type prog) C⟧ ⟹ set (fst (snd (foldl create_initial_object (?h3, ?ads3, ?b3::bool) xs))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (?h3, ?ads3, ?b3) xs))) ∧ (distinct ?ads3 ⟶ distinct (fst (snd (foldl create_initial_object (?h3, ?ads3, ?b3) xs))))› ‹set (ads::'addr::addr list) ⊆ dom ((typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (h::'heap::type))› ‹distinct ((Cs::String.literal list) @ (x::String.literal) # (xs::String.literal list))› ‹length (Cs::String.literal list) = length (ads::'addr::addr list)› ‹(?C3::String.literal, ?a3::'addr::addr) ∈ set (zip (Cs::String.literal list) (ads::'addr::addr list)) ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (h::'heap::type) ?a3 = ⌊Class_type ?C3⌋› ‹(?C3::String.literal) ∈ set ((x::String.literal) # (xs::String.literal list)) ⟹ is_class (P::'m::type prog) ?C3›*)) (*goals: 1. ‹⋀C a. (C, a) ∈ set (zip (Cs @ [x]) (ads @ [a'])) ⟹ (C, a) ∈ set (zip (Cs @ [x]) (ads @ [a']))› 2. ‹⋀C. C ∈ set xs ⟹ C ∈ set xs› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) moreover have "a' ∉ set ads" proof (standard) (*goal: ‹a' ∈ set ads ⟹ False›*) assume a': "a' ∈ set ads" (*‹(a'::'addr) ∈ set (ads::'addr list)›*) then obtain C where "(C, a') ∈ set (zip Cs ads)" "C ∈ set Cs" (*goal: ‹(⋀C. ⟦(C, a') ∈ set (zip Cs ads); C ∈ set Cs⟧ ⟹ thesis) ⟹ thesis›*) using len (*‹length Cs = length ads›*) unfolding set_zip in_set_conv_nth (*goal: ‹(⋀C. ⟦(C, a') ∈ {(Cs ! i, ads ! i) |i. i < min (length Cs) (length ads)}; ∃i<length Cs. Cs ! i = C⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "typeof_addr h a' = ⌊Class_type C⌋" apply - (*goal: ‹typeof_addr h a' = ⌊Class_type C⌋›*) by (rule type (*‹(?C::String.literal, ?a::'addr::addr) ∈ set (zip (Cs::String.literal list) (ads::'addr::addr list)) ⟹ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (h::'heap::type) ?a = ⌊Class_type ?C⌋›*)) with hext (*‹h ⊴ h'›*) have "typeof_addr h' a' = ⌊Class_type C⌋" by (rule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) moreover from new_obj (*‹(h', a') ∈ allocate h (Class_type x)›*) is_class (*‹?C ∈ set (x # xs) ⟹ is_class P ?C›*) have "typeof_addr h' a' = ⌊Class_type x⌋" by (auto dest: allocate_SomeD (*‹⟦(?h'::'heap, ?a::'addr) ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (?h::'heap) (?hT::htype); is_htype (P::'m prog) ?hT⟧ ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h' ?a = ⌊?hT⌋›*)) ultimately have "C = x" by simp with dist (*‹distinct (Cs @ x # xs)›*) ‹C ∈ set Cs› (*‹C ∈ set Cs›*) show False by simp qed moreover note calculation (*‹set (fst (snd (foldl create_initial_object (h', ads @ [a'], True) xs))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h', ads @ [a'], True) xs))) ∧ (distinct (ads @ [a']) ⟶ distinct (fst (snd (foldl create_initial_object (h', ads @ [a'], True) xs))))› ‹a' ∉ set ads›*) } ultimately show "?thesis" (*goal: ‹set (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs)))) ∧ (distinct ads ⟶ distinct (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) by (simp add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) new_obj (*‹(h', a') ∈ allocate h (Class_type x)›*) h'a' (*‹(SOME haa. haa ∈ allocate h (Class_type x)) = (h', a')›*)) qed qed } from this[of "[]" empty_heap "[]" initialization_list True] (*‹⟦set [] ⊆ dom (typeof_addr empty_heap); distinct ([] @ initialization_list); length [] = length []; ⋀C a. (C, a) ∈ set (zip [] []) ⟹ typeof_addr empty_heap a = ⌊Class_type C⌋; ⋀C. C ∈ set initialization_list ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) initialization_list))) ∧ (distinct [] ⟶ distinct (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))))›*) distinct_initialization_list (*‹distinct initialization_list›*) wf_syscls_initialization_list_is_class[OF assms] (*‹?C ∈ set initialization_list ⟹ is_class P ?C›*) show "set start_addrs ⊆ dom (typeof_addr start_heap)" and "distinct start_addrs" unfolding start_heap_def start_addrs_def start_heap_data_def (*goals: 1. ‹set (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) initialization_list)))› 2. ‹distinct (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list)))›*) apply - (*goals: 1. ‹⟦⟦set [] ⊆ dom ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) (empty_heap::'heap)); distinct ([] @ initialization_list); length [] = length []; ⋀(C::String.literal) a::'addr. (C, a) ∈ set (zip [] []) ⟹ typeof_addr empty_heap a = ⌊Class_type C⌋; ⋀C::String.literal. C ∈ set initialization_list ⟹ is_class (P::'m prog) C⟧ ⟹ set (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) initialization_list))) ∧ (distinct [] ⟶ distinct (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list)))); distinct initialization_list; ⋀C::String.literal. C ∈ set initialization_list ⟹ is_class P C⟧ ⟹ set (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) initialization_list)))› 2. ‹⟦⟦set [] ⊆ dom ((typeof_addr::'heap ⇒ 'addr ⇒ htype option) (empty_heap::'heap)); distinct ([] @ initialization_list); length [] = length []; ⋀(C::String.literal) a::'addr. (C, a) ∈ set (zip [] []) ⟹ typeof_addr empty_heap a = ⌊Class_type C⌋; ⋀C::String.literal. C ∈ set initialization_list ⟹ is_class (P::'m prog) C⟧ ⟹ set (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list))) ⊆ dom (typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) initialization_list))) ∧ (distinct [] ⟶ distinct (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list)))); distinct initialization_list; ⋀C::String.literal. C ∈ set initialization_list ⟹ is_class P C⟧ ⟹ distinct (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list)))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma NewHeapElem_start_heap_obsD: assumes "wf_syscls P" and "NewHeapElem a hT ∈ set start_heap_obs" shows "typeof_addr start_heap a = ⌊hT⌋" proof (-) (*goal: ‹typeof_addr start_heap a = ⌊hT⌋›*) show "?thesis" (*goal: ‹typeof_addr start_heap a = ⌊hT⌋›*) proof (cases hT) (*goals: 1. ‹⋀x1::String.literal. (hT::htype) = Class_type x1 ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) start_heap (a::'addr) = ⌊hT⌋› 2. ‹⋀(x21::ty) x22::nat. (hT::htype) = Array_type x21 x22 ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) start_heap (a::'addr) = ⌊hT⌋›*) case (Class_type C) (*‹hT = Class_type C›*) { fix h and ads and b and xs and Cs assume "(C, a) ∈ set (zip (Cs @ xs) (fst (snd (foldl create_initial_object (h, ads, b) xs))))" and "∀(C, a) ∈ set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋" and "length Cs = length ads" and "∀C ∈ set xs. is_class P C" (*‹(C::String.literal, a::'addr) ∈ set (zip ((Cs::String.literal list) @ (xs::String.literal list)) (fst (snd (foldl create_initial_object (h::'heap, ads::'addr list, b::bool) xs))))› ‹∀(C::String.literal, a::'addr)∈set (zip (Cs::String.literal list) (ads::'addr list)). (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h::'heap) a = ⌊Class_type C⌋› ‹length (Cs::String.literal list) = length (ads::'addr list)› ‹∀C::String.literal∈set (xs::String.literal list). is_class (P::'m prog) C›*) hence "typeof_addr (fst (foldl create_initial_object (h, ads, b) xs)) a = ⌊Class_type C⌋" proof (induct xs arbitrary: h ads b Cs) (*goals: 1. ‹⋀h ads b Cs. ⟦(C, a) ∈ set (zip (Cs @ []) (fst (snd (foldl create_initial_object (h, ads, b) [])))); ∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋; length Cs = length ads; Ball (set []) (is_class P)⟧ ⟹ typeof_addr (fst (foldl create_initial_object (h, ads, b) [])) a = ⌊Class_type C⌋› 2. ‹⋀aa xs h ads b Cs. ⟦⋀h ads b Cs. ⟦(C, a) ∈ set (zip (Cs @ xs) (fst (snd (foldl create_initial_object (h, ads, b) xs)))); ∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋; length Cs = length ads; Ball (set xs) (is_class P)⟧ ⟹ typeof_addr (fst (foldl create_initial_object (h, ads, b) xs)) a = ⌊Class_type C⌋; (C, a) ∈ set (zip (Cs @ aa # xs) (fst (snd (foldl create_initial_object (h, ads, b) (aa # xs))))); ∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋; length Cs = length ads; Ball (set (aa # xs)) (is_class P)⟧ ⟹ typeof_addr (fst (foldl create_initial_object (h, ads, b) (aa # xs))) a = ⌊Class_type C⌋›*) case Nil (*‹(C, a) ∈ set (zip (Cs @ []) (fst (snd (foldl create_initial_object (h, ads, b) []))))› ‹∀a∈set (zip Cs ads). case a of (C, a) ⇒ typeof_addr h a = ⌊Class_type C⌋› ‹length Cs = length ads› ‹∀a∈set []. is_class P a›*) thus "?case" (*goal: ‹typeof_addr (fst (foldl create_initial_object (h, ads, b) [])) a = ⌊Class_type C⌋›*) by auto next (*goal: ‹⋀aa xs h ads b Cs. ⟦⋀h ads b Cs. ⟦(C, a) ∈ set (zip (Cs @ xs) (fst (snd (foldl create_initial_object (h, ads, b) xs)))); ∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋; length Cs = length ads; Ball (set xs) (is_class P)⟧ ⟹ typeof_addr (fst (foldl create_initial_object (h, ads, b) xs)) a = ⌊Class_type C⌋; (C, a) ∈ set (zip (Cs @ aa # xs) (fst (snd (foldl create_initial_object (h, ads, b) (aa # xs))))); ∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋; length Cs = length ads; Ball (set (aa # xs)) (is_class P)⟧ ⟹ typeof_addr (fst (foldl create_initial_object (h, ads, b) (aa # xs))) a = ⌊Class_type C⌋›*) case (Cons x xs) (*‹⟦(C, a) ∈ set (zip (?Cs3 @ xs) (fst (snd (foldl create_initial_object (?h3, ?ads3, ?b3) xs)))); ∀a∈set (zip ?Cs3 ?ads3). case a of (C, a) ⇒ typeof_addr ?h3 a = ⌊Class_type C⌋; length ?Cs3 = length ?ads3; ∀a∈set xs. is_class P a⟧ ⟹ typeof_addr (fst (foldl create_initial_object (?h3, ?ads3, ?b3) xs)) a = ⌊Class_type C⌋› ‹(C, a) ∈ set (zip (Cs @ x # xs) (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))› ‹∀a::String.literal × 'addr::addr∈set (zip (Cs::String.literal list) (ads::'addr::addr list)). case a of (C::String.literal, a::'addr::addr) ⇒ (typeof_addr::'heap::type ⇒ 'addr::addr ⇒ htype option) (h::'heap::type) a = ⌊Class_type C⌋› ‹length Cs = length ads› ‹∀a∈set (x # xs). is_class P a›*) note inv = ‹∀(C, a) ∈ set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋› (*‹∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋›*) and Ca = ‹(C, a) ∈ set (zip (Cs @ x # xs) (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))› (*‹(C, a) ∈ set (zip (Cs @ x # xs) (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) and len = ‹length Cs = length ads› (*‹length Cs = length ads›*) and is_class = ‹∀C ∈ set (x # xs). is_class P C› (*‹∀C∈set (x # xs). is_class P C›*) show "?case" (*goal: ‹typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs))) a = ⌊Class_type C⌋›*) proof (cases "b ∧ allocate h (Class_type x) ≠ {}") (*goals: 1. ‹(b::bool) ∧ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (Class_type (x::String.literal)) ≠ {} ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (fst (foldl create_initial_object (h, ads::'addr list, b) (x # (xs::String.literal list)))) (a::'addr) = ⌊Class_type (C::String.literal)⌋› 2. ‹¬ ((b::bool) ∧ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (Class_type (x::String.literal)) ≠ {}) ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (fst (foldl create_initial_object (h, ads::'addr list, b) (x # (xs::String.literal list)))) (a::'addr) = ⌊Class_type (C::String.literal)⌋›*) case False (*‹¬ (b ∧ allocate h (Class_type x) ≠ {})›*) thus "?thesis" (*goal: ‹typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs))) a = ⌊Class_type C⌋›*) using inv (*‹∀(C, a)∈set (zip Cs ads). typeof_addr h a = ⌊Class_type C⌋›*) Ca (*‹(C, a) ∈ set (zip (Cs @ x # xs) (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) len (*‹length Cs = length ads›*) by (auto simp add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) zip_append1 (*‹zip (?xs @ ?ys) ?zs = zip ?xs (take (length ?xs) ?zs) @ zip ?ys (drop (length ?xs) ?zs)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goal: ‹b ∧ allocate h (Class_type x) ≠ {} ⟹ typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs))) a = ⌊Class_type C⌋›*) case [simp]: True (*‹(b::bool) ∧ (allocate::'heap::type ⇒ htype ⇒ ('heap::type × 'addr::addr) set) (h::'heap::type) (Class_type (x::String.literal)) ≠ {}›*) obtain h' and a' where h'a': "(SOME ha. ha ∈ allocate h (Class_type x)) = (h', a')" (*goal: ‹(⋀h' a'. (SOME haa. haa ∈ allocate h (Class_type x)) = (h', a') ⟹ thesis) ⟹ thesis›*) by (cases "SOME ha. ha ∈ allocate h (Class_type x)") with True (*‹b ∧ allocate h (Class_type x) ≠ {}›*) have new_obj: "(h', a') ∈ allocate h (Class_type x)" by (auto simp del: True (*‹b ∧ allocate h (Class_type x) ≠ {}›*) intro: allocate_Eps (*‹⟦(?h'', ?a'') ∈ allocate ?h ?hT; (SOME ha. ha ∈ allocate ?h ?hT) = (?h', ?a')⟧ ⟹ (?h', ?a') ∈ allocate ?h ?hT›*)) hence hext: "h ⊴ h'" by (rule hext_allocate (*‹(?h', ?a) ∈ allocate ?h ?hT ⟹ ?h ⊴ ?h'›*)) have "(C, a) ∈ set (zip ((Cs @ [x]) @ xs) (fst (snd (foldl create_initial_object (h', ads @ [a'], True) xs))))" using Ca (*‹(C, a) ∈ set (zip (Cs @ x # xs) (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))›*) new_obj (*‹(h', a') ∈ allocate h (Class_type x)›*) by (simp add: create_initial_object_simps (*‹create_initial_object (?h, ?ads, ?b) ?C = (if ?b then let HA = allocate ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) h'a' (*‹(SOME haa. haa ∈ allocate h (Class_type x)) = (h', a')›*)) moreover have "∀(C, a)∈set (zip (Cs @ [x]) (ads @ [a'])). typeof_addr h' a = ⌊Class_type C⌋" proof (clarify) (*goal: ‹⋀(a::String.literal) b::'addr. (a, b) ∈ set (zip ((Cs::String.literal list) @ [x::String.literal]) ((ads::'addr list) @ [a'::'addr])) ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h'::'heap) b = ⌊Class_type a⌋›*) fix C and a assume "(C, a) ∈ set (zip (Cs @ [x]) (ads @ [a']))" (*‹(C::String.literal, a::'addr) ∈ set (zip ((Cs::String.literal list) @ [x::String.literal]) ((ads::'addr list) @ [a'::'addr]))›*) thus "typeof_addr h' a = ⌊Class_type C⌋" using inv (*‹∀(C::String.literal, a::'addr)∈set (zip (Cs::String.literal list) (ads::'addr list)). (typeof_addr::'heap ⇒ 'addr ⇒ htype option) (h::'heap) a = ⌊Class_type C⌋›*) len (*‹length Cs = length ads›*) hext (*‹h ⊴ h'›*) new_obj (*‹(h', a') ∈ allocate h (Class_type x)›*) is_class (*‹∀C∈set (x # xs). is_class P C›*) by (auto dest: allocate_SomeD (*‹⟦(?h', ?a) ∈ allocate ?h ?hT; is_htype P ?hT⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*) typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) qed moreover have "length (Cs @ [x]) = length (ads @ [a'])" using len (*‹length Cs = length ads›*) by simp moreover have "∀C ∈ set xs. is_class P C" using is_class (*‹∀C∈set (x # xs). is_class P C›*) by simp ultimately have "typeof_addr (fst (foldl create_initial_object (h', ads @ [a'], True) xs)) a = ⌊Class_type C⌋" by (rule Cons (*‹⟦(C, a) ∈ set (zip (?Cs3 @ xs) (fst (snd (foldl create_initial_object (?h3, ?ads3, ?b3) xs)))); ∀a∈set (zip ?Cs3 ?ads3). case a of (C, a) ⇒ typeof_addr ?h3 a = ⌊Class_type C⌋; length ?Cs3 = length ?ads3; ∀a∈set xs. is_class P a⟧ ⟹ typeof_addr (fst (foldl create_initial_object (?h3, ?ads3, ?b3) xs)) a = ⌊Class_type C⌋› ‹(C, a) ∈ set (zip (Cs @ x # xs) (fst (snd (foldl create_initial_object (h, ads, b) (x # xs)))))› ‹∀a∈set (zip Cs ads). case a of (C, a) ⇒ typeof_addr h a = ⌊Class_type C⌋› ‹length Cs = length ads› ‹∀a∈set (x # xs). is_class P a›*)) thus "?thesis" (*goal: ‹typeof_addr (fst (foldl create_initial_object (h, ads, b) (x # xs))) a = ⌊Class_type C⌋›*) using new_obj (*‹(h', a') ∈ allocate h (Class_type x)›*) by (simp add: create_initial_object_simps (*‹create_initial_object (?h::'heap, ?ads::'addr list, ?b::bool) (?C::String.literal) = (if ?b then let HA::('heap × 'addr) set = (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) ?h (Class_type ?C) in if HA = {} then (?h, ?ads, False) else let (h'::'heap, a''::'addr) = SOME ha::'heap × 'addr. ha ∈ HA in (h', ?ads @ [a''], True) else (?h, ?ads, False))›*) h'a' (*‹(SOME haa::'heap × 'addr. haa ∈ (allocate::'heap ⇒ htype ⇒ ('heap × 'addr) set) (h::'heap) (Class_type (x::String.literal))) = (h'::'heap, a'::'addr)›*)) qed qed } from this[of "[]" initialization_list empty_heap "[]" True] (*‹⟦(C, a) ∈ set (zip ([] @ initialization_list) (fst (snd (foldl create_initial_object (empty_heap, [], True) initialization_list)))); ∀(C, a)∈set (zip [] []). typeof_addr empty_heap a = ⌊Class_type C⌋; length [] = length []; ∀C∈set initialization_list. is_class P C⟧ ⟹ typeof_addr (fst (foldl create_initial_object (empty_heap, [], True) initialization_list)) a = ⌊Class_type C⌋›*) assms (*‹wf_syscls P› ‹NewHeapElem a hT ∈ set start_heap_obs›*) wf_syscls_initialization_list_is_class[of P] (*‹⟦wf_syscls P; ?C ∈ set initialization_list⟧ ⟹ is_class P ?C›*) show "?thesis" (*goal: ‹typeof_addr start_heap a = ⌊hT⌋›*) by (auto simp add: start_heap_obs_def (*‹start_heap_obs = map2 (λC a. NewHeapElem a (Class_type C)) initialization_list (fst (snd start_heap_data))›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap, [], True) initialization_list›*) start_heap_def (*‹start_heap = fst start_heap_data›*) Class_type (*‹hT = Class_type C›*)) next (*goal: ‹⋀(x21::ty) x22::nat. (hT::htype) = Array_type x21 x22 ⟹ (typeof_addr::'heap ⇒ 'addr ⇒ htype option) start_heap (a::'addr) = ⌊hT⌋›*) case Array_type (*‹hT = Array_type x21_ x22_›*) thus "?thesis" (*goal: ‹(typeof_addr::'heap ⇒ 'addr ⇒ htype option) start_heap (a::'addr) = ⌊hT::htype⌋›*) using assms (*‹wf_syscls P› ‹NewHeapElem a hT ∈ set start_heap_obs›*) by (auto simp add: start_heap_obs_def (*‹start_heap_obs = map2 (λ(C::String.literal) a::'addr::addr. NewHeapElem a (Class_type C)) initialization_list (fst (snd start_heap_data))›*) start_heap_data_def (*‹start_heap_data = foldl create_initial_object (empty_heap::'heap::type, [], True) initialization_list›*) start_heap_def (*‹start_heap = fst start_heap_data›*)) qed qed end subsection ‹Code generation› definition pick_addr :: "('heap × 'addr) set ⇒ 'heap × 'addr" where "pick_addr HA = (SOME ha. ha ∈ HA)" lemma pick_addr_code [code]: "pick_addr (set [ha]) = ha" by (simp add: pick_addr_def (*‹pick_addr ?HA = (SOME ha. ha ∈ ?HA)›*)) lemma (in heap_base) start_heap_data_code: "start_heap_data = (let (h, ads, b) = foldl (λ(h, ads, b) C. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = pick_addr HA in (h', a'' # ads, True) else (h, ads, False)) (empty_heap, [], True) initialization_list in (h, rev ads, b))" unfolding start_heap_data_def create_initial_object_def pick_addr_def (*goal: ‹foldl (λ(h, ads, b) C. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', ads @ [a''], True) else (h, ads, False)) (empty_heap, [], True) initialization_list = (let (h, ads, b) = foldl (λ(h, ads, b) C. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let (h', a'') = SOME ha. ha ∈ HA in (h', a'' # ads, True) else (h, ads, False)) (empty_heap, [], True) initialization_list in (h, rev ads, b))›*) apply (rule rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹foldl (λa. case a of (h, a) ⇒ case a of (ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let a = SOME ha. ha ∈ HA in case a of (h', a'') ⇒ (h', ads @ [a''], True) else (h, ads, False)) (empty_heap, [], True) [] = (let a = foldl (λa. case a of (h, a) ⇒ case a of (ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let a = SOME ha. ha ∈ HA in case a of (h', a'') ⇒ (h', a'' # ads, True) else (h, ads, False)) (empty_heap, [], True) [] in case a of (h, ads, b) ⇒ (h, rev ads, b))› 2. ‹⋀x xs. foldl (λa. case a of (h, a) ⇒ case a of (ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let a = SOME ha. ha ∈ HA in case a of (h', a'') ⇒ (h', ads @ [a''], True) else (h, ads, False)) (empty_heap, [], True) xs = (let a = foldl (λa. case a of (h, a) ⇒ case a of (ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let a = SOME ha. ha ∈ HA in case a of (h', a'') ⇒ (h', a'' # ads, True) else (h, ads, False)) (empty_heap, [], True) xs in case a of (h, ads, b) ⇒ (h, rev ads, b)) ⟹ foldl (λa. case a of (h, a) ⇒ case a of (ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let a = SOME ha. ha ∈ HA in case a of (h', a'') ⇒ (h', ads @ [a''], True) else (h, ads, False)) (empty_heap, [], True) (xs @ [x]) = (let a = foldl (λa. case a of (h, a) ⇒ case a of (ads, b) ⇒ λC. if b then let HA = allocate h (Class_type C) in if HA = {} then (h, ads, False) else let a = SOME ha. ha ∈ HA in case a of (h', a'') ⇒ (h', a'' # ads, True) else (h, ads, False)) (empty_heap, [], True) (xs @ [x]) in case a of (h, ads, b) ⇒ (h, rev ads, b))› discuss goal 1*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) (*discuss goal 2*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) (*proven 2 subgoals*) . lemmas [code] = heap_base.start_heap_data_code heap_base.start_heap_def heap_base.start_heap_ok_def heap_base.start_heap_obs_def heap_base.start_addrs_def heap_base.addr_of_sys_xcpt_def heap_base.start_tid_def heap_base.start_state_def end
{ "path": "afp-2025-02-12/thys/JinjaThreads/Common/StartConfig.thy", "repo": "afp-2025-02-12", "sha": "48959f438a8ce49d32486ae7a3e189bcb5b92ebae32a2e9d545fab91093f3b36" }
(* Title: HOL/Nonstandard_Analysis/HSeries.thy Author: Jacques D. Fleuriot Copyright: 1998 University of Cambridge Converted to Isar and polished by lcp *) section ‹Finite Summation and Infinite Series for Hyperreals› theory HSeries imports HSEQ begin definition sumhr :: "hypnat × hypnat × (nat ⇒ real) ⇒ hypreal" where "sumhr = (λ(M,N,f). starfun2 (λm n. sum f {m..<n}) M N)" definition NSsums :: "(nat ⇒ real) ⇒ real ⇒ bool" (infixr "NSsums" 80) where "f NSsums s = (λn. sum f {..<n}) ⇢⇩N⇩S s" definition NSsummable :: "(nat ⇒ real) ⇒ bool" where "NSsummable f ⟷ (∃s. f NSsums s)" definition NSsuminf :: "(nat ⇒ real) ⇒ real" where "NSsuminf f = (THE s. f NSsums s)" lemma sumhr_app: "sumhr (M, N, f) = ( *f2* (λm n. sum f {m..<n})) M N" by (simp add: sumhr_def (*‹sumhr = (λ(M, N, f). (*f2* (λm n. sum f {m..<n})) M N)›*)) text ‹Base case in definition of \<^term>‹sumr›.› lemma sumhr_zero [simp]: "⋀m. sumhr (m, 0, f) = 0" unfolding sumhr_app (*goal: ‹⋀m. (*f2* (λm n. sum f {m..<n})) m 0 = 0›*) apply transfer (*goal: ‹⋀m. (*f2* (λm n. sum f {m..<n})) m 0 = 0›*) by simp text ‹Recursive case in definition of \<^term>‹sumr›.› lemma sumhr_if: "⋀m n. sumhr (m, n + 1, f) = (if n + 1 ≤ m then 0 else sumhr (m, n, f) + ( *f* f) n)" unfolding sumhr_app (*goal: ‹⋀m n. (*f2* (λm n. sum f {m..<n})) m (n + 1) = (if n + 1 ≤ m then 0 else (*f2* (λm n. sum f {m..<n})) m n + (*f* f) n)›*) apply transfer (*goal: ‹⋀m n. (*f2* (λm n. sum f {m..<n})) m (n + 1) = (if n + 1 ≤ m then 0 else (*f2* (λm n. sum f {m..<n})) m n + (*f* f) n)›*) by simp lemma sumhr_Suc_zero [simp]: "⋀n. sumhr (n + 1, n, f) = 0" unfolding sumhr_app (*goal: ‹⋀n. (*f2* (λm n. sum f {m..<n})) (n + 1) n = 0›*) apply transfer (*goal: ‹⋀n. (*f2* (λm n. sum f {m..<n})) (n + 1) n = 0›*) by simp lemma sumhr_eq_bounds [simp]: "⋀n. sumhr (n, n, f) = 0" unfolding sumhr_app (*goal: ‹⋀n. (*f2* (λm n. sum f {m..<n})) n n = 0›*) apply transfer (*goal: ‹⋀n. (*f2* (λm n. sum f {m..<n})) n n = 0›*) by simp lemma sumhr_Suc [simp]: "⋀m. sumhr (m, m + 1, f) = ( *f* f) m" unfolding sumhr_app (*goal: ‹⋀m::nat star. (*f2* (λ(m::nat) n::nat. sum (f::nat ⇒ real) {m..<n})) m (m + (1::nat star)) = (*f* f) m›*) apply transfer (*goal: ‹⋀m. (*f2* (λm n. sum f {m..<n})) m (m + 1) = (*f* f) m›*) by simp lemma sumhr_add_lbound_zero [simp]: "⋀k m. sumhr (m + k, k, f) = 0" unfolding sumhr_app (*goal: ‹⋀k m. (*f2* (λm n. sum f {m..<n})) (m + k) k = 0›*) apply transfer (*goal: ‹⋀k m. (*f2* (λm n. sum f {m..<n})) (m + k) k = 0›*) by simp lemma sumhr_add: "⋀m n. sumhr (m, n, f) + sumhr (m, n, g) = sumhr (m, n, λi. f i + g i)" unfolding sumhr_app (*goal: ‹⋀m n. (*f2* (λm n. sum f {m..<n})) m n + (*f2* (λm n. sum g {m..<n})) m n = (*f2* (λm n. ∑i = m..<n. f i + g i)) m n›*) apply transfer (*goal: ‹⋀m n. (*f2* (λm n. sum f {m..<n})) m n + (*f2* (λm n. sum g {m..<n})) m n = (*f2* (λm n. ∑i = m..<n. f i + g i)) m n›*) by (rule sum.distrib [symmetric] (*‹sum (?g::?'b::type ⇒ ?'a::comm_monoid_add) (?A::?'b::type set) + sum (?h::?'b::type ⇒ ?'a::comm_monoid_add) ?A = (∑x::?'b::type∈?A. ?g x + ?h x)›*)) lemma sumhr_mult: "⋀m n. hypreal_of_real r * sumhr (m, n, f) = sumhr (m, n, λn. r * f n)" unfolding sumhr_app (*goal: ‹⋀m n. hypreal_of_real r * (*f2* (λm n. sum f {m..<n})) m n = (*f2* (λm n. ∑n = m..<n. r * f n)) m n›*) apply transfer (*goal: ‹⋀m n. hypreal_of_real r * (*f2* (λm n. sum f {m..<n})) m n = (*f2* (λm n. ∑n = m..<n. r * f n)) m n›*) by (rule sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*)) lemma sumhr_split_add: "⋀n p. n < p ⟹ sumhr (0, n, f) + sumhr (n, p, f) = sumhr (0, p, f)" unfolding sumhr_app (*goal: ‹⋀n p. n < p ⟹ (*f2* (λm n. sum f {m..<n})) 0 n + (*f2* (λm n. sum f {m..<n})) n p = (*f2* (λm n. sum f {m..<n})) 0 p›*) apply transfer (*goal: ‹⋀n p. n < p ⟹ (*f2* (λm n. sum f {m..<n})) 0 n + (*f2* (λm n. sum f {m..<n})) n p = (*f2* (λm n. sum f {m..<n})) 0 p›*) by (simp add: sum.atLeastLessThan_concat (*‹⟦(?m::nat) ≤ (?n::nat); ?n ≤ (?p::nat)⟧ ⟹ sum (?g::nat ⇒ ?'a) {?m..<?n} + sum ?g {?n..<?p} = sum ?g {?m..<?p}›*)) lemma sumhr_split_diff: "n < p ⟹ sumhr (0, p, f) - sumhr (0, n, f) = sumhr (n, p, f)" apply (drule sumhr_split_add [symmetric, where f = f] (*‹?n < ?p ⟹ sumhr (0, ?p, f) = sumhr (0, ?n, f) + sumhr (?n, ?p, f)›*)) (*goal: ‹n < p ⟹ sumhr (0, p, f) - sumhr (0, n, f) = sumhr (n, p, f)›*) by simp lemma sumhr_hrabs: "⋀m n. ¦sumhr (m, n, f)¦ ≤ sumhr (m, n, λi. ¦f i¦)" unfolding sumhr_app (*goal: ‹⋀m n. ¦(*f2* (λm n. sum f {m..<n})) m n¦ ≤ (*f2* (λm n. ∑i = m..<n. ¦f i¦)) m n›*) apply transfer (*goal: ‹⋀(m::nat star) n::nat star. ¦(*f2* (λ(m::nat) n::nat. sum (f::nat ⇒ real) {m..<n})) m n¦ ≤ (*f2* (λ(m::nat) n::nat. ∑i::nat = m..<n. ¦f i¦)) m n›*) by (rule sum_abs (*‹¦sum ?f ?A¦ ≤ (∑i∈?A. ¦?f i¦)›*)) text ‹Other general version also needed.› lemma sumhr_fun_hypnat_eq: "(∀r. m ≤ r ∧ r < n ⟶ f r = g r) ⟶ sumhr (hypnat_of_nat m, hypnat_of_nat n, f) = sumhr (hypnat_of_nat m, hypnat_of_nat n, g)" unfolding sumhr_app (*goal: ‹(∀r. m ≤ r ∧ r < n ⟶ f r = g r) ⟶ (*f2* (λm n. sum f {m..<n})) (hypnat_of_nat m) (hypnat_of_nat n) = (*f2* (λm n. sum g {m..<n})) (hypnat_of_nat m) (hypnat_of_nat n)›*) apply transfer (*goal: ‹(∀r. m ≤ r ∧ r < n ⟶ f r = g r) ⟶ (*f2* (λm n. sum f {m..<n})) (hypnat_of_nat m) (hypnat_of_nat n) = (*f2* (λm n. sum g {m..<n})) (hypnat_of_nat m) (hypnat_of_nat n)›*) by simp lemma sumhr_const: "⋀n. sumhr (0, n, λi. r) = hypreal_of_hypnat n * hypreal_of_real r" unfolding sumhr_app (*goal: ‹⋀n::nat star. (*f2* (λ(m::nat) n::nat. ∑i::nat = m..<n. (r::real))) (0::nat star) n = hypreal_of_hypnat n * hypreal_of_real r›*) apply transfer (*goal: ‹⋀n::nat star. (*f2* (λ(m::nat) n::nat. ∑i::nat = m..<n. (r::real))) (0::nat star) n = hypreal_of_hypnat n * hypreal_of_real r›*) by simp lemma sumhr_less_bounds_zero [simp]: "⋀m n. n < m ⟹ sumhr (m, n, f) = 0" unfolding sumhr_app (*goal: ‹⋀m n. n < m ⟹ (*f2* (λm n. sum f {m..<n})) m n = 0›*) apply transfer (*goal: ‹⋀m n. n < m ⟹ (*f2* (λm n. sum f {m..<n})) m n = 0›*) by simp lemma sumhr_minus: "⋀m n. sumhr (m, n, λi. - f i) = - sumhr (m, n, f)" unfolding sumhr_app (*goal: ‹⋀m n. (*f2* (λm n. ∑i = m..<n. - f i)) m n = - (*f2* (λm n. sum f {m..<n})) m n›*) apply transfer (*goal: ‹⋀m n. (*f2* (λm n. ∑i = m..<n. - f i)) m n = - (*f2* (λm n. sum f {m..<n})) m n›*) by (rule sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*)) lemma sumhr_shift_bounds: "⋀m n. sumhr (m + hypnat_of_nat k, n + hypnat_of_nat k, f) = sumhr (m, n, λi. f (i + k))" unfolding sumhr_app (*goal: ‹⋀(m::nat star) n::nat star. (*f2* (λ(m::nat) n::nat. sum (f::nat ⇒ real) {m..<n})) (m + hypnat_of_nat (k::nat)) (n + hypnat_of_nat k) = (*f2* (λ(m::nat) n::nat. ∑i::nat = m..<n. f (i + k))) m n›*) apply transfer (*goal: ‹⋀m n. (*f2* (λm n. sum f {m..<n})) (m + hypnat_of_nat k) (n + hypnat_of_nat k) = (*f2* (λm n. ∑i = m..<n. f (i + k))) m n›*) by (rule sum.shift_bounds_nat_ivl (*‹sum ?g {?m + ?k..<?n + ?k} = (∑i = ?m..<?n. ?g (i + ?k))›*)) subsection ‹Nonstandard Sums› text ‹Infinite sums are obtained by summing to some infinite hypernatural (such as \<^term>‹whn›).› lemma sumhr_hypreal_of_hypnat_omega: "sumhr (0, whn, λi. 1) = hypreal_of_hypnat whn" by (simp add: sumhr_const (*‹sumhr (0, ?n, λi. ?r) = hypreal_of_hypnat ?n * hypreal_of_real ?r›*)) lemma whn_eq_ωm1: "hypreal_of_hypnat whn = ω - 1" unfolding star_class_defs omega_def hypnat_omega_def of_hypnat_def star_of_def (*goal: ‹(*f* real) (star_n (λn. n)) = (*f2* (-)) (star_n (λn. real (Suc n))) (star_n (λn. 1))›*) by (simp add: starfun_star_n (*‹(*f* ?f) (star_n ?X) = star_n (λn. ?f (?X n))›*) starfun2_star_n (*‹(*f2* ?f) (star_n ?X) (star_n ?Y) = star_n (λn. ?f (?X n) (?Y n))›*)) lemma sumhr_hypreal_omega_minus_one: "sumhr(0, whn, λi. 1) = ω - 1" by (simp add: sumhr_const (*‹sumhr (0, ?n, λi. ?r) = hypreal_of_hypnat ?n * hypreal_of_real ?r›*) whn_eq_ωm1 (*‹hypreal_of_hypnat whn = ω - 1›*)) lemma sumhr_minus_one_realpow_zero [simp]: "⋀N. sumhr (0, N + N, λi. (-1) ^ (i + 1)) = 0" unfolding sumhr_app (*goal: ‹⋀N. (*f2* (λm n. ∑i = m..<n. (- 1) ^ (i + 1))) 0 (N + N) = 0›*) apply transfer (*goal: ‹⋀N. (*f2* (λm n. ∑i = m..<n. (- 1) ^ (i + 1))) 0 (N + N) = 0›*) apply (induct_tac N) (*goals: 1. ‹⋀N::nat. (∑i::nat = 0::nat..<(0::nat) + (0::nat). (- (1::real)) ^ (i + (1::nat))) = (0::real)› 2. ‹⋀(N::nat) n::nat. (∑i::nat = 0::nat..<n + n. (- (1::real)) ^ (i + (1::nat))) = (0::real) ⟹ (∑i::nat = 0::nat..<Suc n + Suc n. (- (1::real)) ^ (i + (1::nat))) = (0::real)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma sumhr_interval_const: "(∀n. m ≤ Suc n ⟶ f n = r) ∧ m ≤ na ⟹ sumhr (hypnat_of_nat m, hypnat_of_nat na, f) = hypreal_of_nat (na - m) * hypreal_of_real r" unfolding sumhr_app (*goal: ‹(∀n. m ≤ Suc n ⟶ f n = r) ∧ m ≤ na ⟹ (*f2* (λm n. sum f {m..<n})) (hypnat_of_nat m) (hypnat_of_nat na) = hypreal_of_nat (na - m) * hypreal_of_real r›*) apply transfer (*goal: ‹(∀n. m ≤ Suc n ⟶ f n = r) ∧ m ≤ na ⟹ (*f2* (λm n. sum f {m..<n})) (hypnat_of_nat m) (hypnat_of_nat na) = hypreal_of_nat (na - m) * hypreal_of_real r›*) by simp lemma starfunNat_sumr: "⋀N. ( *f* (λn. sum f {0..<n})) N = sumhr (0, N, f)" unfolding sumhr_app (*goal: ‹⋀N. (*f* (λn. sum f {0..<n})) N = (*f2* (λm n. sum f {m..<n})) 0 N›*) apply transfer (*goal: ‹⋀N::nat star. (*f* (λn::nat. sum (f::nat ⇒ real) {0::nat..<n})) N = (*f2* (λ(m::nat) n::nat. sum f {m..<n})) (0::nat star) N›*) by (rule refl (*‹?t = ?t›*)) lemma sumhr_hrabs_approx [simp]: "sumhr (0, M, f) ≈ sumhr (0, N, f) ⟹ ¦sumhr (M, N, f)¦ ≈ 0" using linorder_less_linear[where x = M and y = N] (*‹M < N ∨ M = N ∨ N < M›*) by (metis (no_types, lifting) abs_zero (*‹¦0¦ = 0›*) approx_hrabs (*‹?x ≈ ?y ⟹ ¦?x¦ ≈ ¦?y¦›*) approx_minus_iff (*‹(?x ≈ ?y) = (?x - ?y ≈ 0)›*) approx_refl (*‹?x ≈ ?x›*) approx_sym (*‹?x ≈ ?y ⟹ ?y ≈ ?x›*) sumhr_eq_bounds (*‹sumhr (?n, ?n, ?f) = 0›*) sumhr_less_bounds_zero (*‹?n < ?m ⟹ sumhr (?m, ?n, ?f) = 0›*) sumhr_split_diff (*‹?n < ?p ⟹ sumhr (0, ?p, ?f) - sumhr (0, ?n, ?f) = sumhr (?n, ?p, ?f)›*)) subsection ‹Infinite sums: Standard and NS theorems› lemma sums_NSsums_iff: "f sums l ⟷ f NSsums l" by (simp add: sums_def (*‹?f sums ?s = (λn. sum ?f {..<n}) ⇢ ?s›*) NSsums_def (*‹?f NSsums ?s = (λn. sum ?f {..<n}) ⇢⇩N⇩S ?s›*) LIMSEQ_NSLIMSEQ_iff (*‹?f ⇢ ?L = ?f ⇢⇩N⇩S ?L›*)) lemma summable_NSsummable_iff: "summable f ⟷ NSsummable f" by (simp add: summable_def (*‹summable (?f::nat ⇒ ?'a) = (∃s::?'a. ?f sums s)›*) NSsummable_def (*‹NSsummable (?f::nat ⇒ real) = (∃s::real. ?f NSsums s)›*) sums_NSsums_iff (*‹(?f::nat ⇒ real) sums (?l::real) = ?f NSsums ?l›*)) lemma suminf_NSsuminf_iff: "suminf f = NSsuminf f" by (simp add: suminf_def (*‹suminf (?f::nat ⇒ ?'a::{comm_monoid_add,topological_space}) = (THE s::?'a::{comm_monoid_add,topological_space}. ?f sums s)›*) NSsuminf_def (*‹NSsuminf (?f::nat ⇒ real) = (THE s::real. ?f NSsums s)›*) sums_NSsums_iff (*‹(?f::nat ⇒ real) sums (?l::real) = ?f NSsums ?l›*)) lemma NSsums_NSsummable: "f NSsums l ⟹ NSsummable f" unfolding NSsums_def NSsummable_def (*goal: ‹(λn. sum f {..<n}) ⇢⇩N⇩S l ⟹ Ex (NSLIMSEQ (λn. sum f {..<n}))›*) by blast lemma NSsummable_NSsums: "NSsummable f ⟹ f NSsums (NSsuminf f)" unfolding NSsummable_def NSsuminf_def NSsums_def (*goal: ‹Ex (NSLIMSEQ (λn. sum f {..<n})) ⟹ (λn. sum f {..<n}) ⇢⇩N⇩S The (NSLIMSEQ (λn. sum f {..<n}))›*) by (blast intro: theI (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ ?P (THE x. ?P x)›*) NSLIMSEQ_unique (*‹⟦?X ⇢⇩N⇩S ?a; ?X ⇢⇩N⇩S ?b⟧ ⟹ ?a = ?b›*)) lemma NSsums_unique: "f NSsums s ⟹ s = NSsuminf f" by (simp add: suminf_NSsuminf_iff [symmetric] (*‹NSsuminf ?f = suminf ?f›*) sums_NSsums_iff (*‹?f sums ?l = ?f NSsums ?l›*) sums_unique (*‹?f sums ?s ⟹ ?s = suminf ?f›*)) lemma NSseries_zero: "∀m. n ≤ Suc m ⟶ f m = 0 ⟹ f NSsums (sum f {..<n})" by (auto simp add: sums_NSsums_iff [symmetric] (*‹?f NSsums ?l = ?f sums ?l›*) not_le[symmetric] (*‹(?y < ?x) = (¬ ?x ≤ ?y)›*) intro!: sums_finite (*‹⟦finite ?N; ⋀n. n ∉ ?N ⟹ ?f n = 0⟧ ⟹ ?f sums sum ?f ?N›*)) lemma NSsummable_NSCauchy: "NSsummable f ⟷ (∀M ∈ HNatInfinite. ∀N ∈ HNatInfinite. ¦sumhr (M, N, f)¦ ≈ 0)" (is "?L=?R") proof (-) (*goal: ‹NSsummable f = (∀M∈HNatInfinite. ∀N∈HNatInfinite. ¦sumhr (M, N, f)¦ ≈ 0)›*) have "?L = (∀M∈HNatInfinite. ∀N∈HNatInfinite. sumhr (0, M, f) ≈ sumhr (0, N, f))" by (auto simp add: summable_iff_convergent (*‹summable ?f = convergent (λn. sum ?f {..<n})›*) convergent_NSconvergent_iff (*‹convergent ?X = NSconvergent ?X›*) NSCauchy_def (*‹NSCauchy ?X = (∀M∈HNatInfinite. ∀N∈HNatInfinite. (*f* ?X) M ≈ (*f* ?X) N)›*) starfunNat_sumr (*‹(*f* (λn. sum ?f {0..<n})) ?N = sumhr (0, ?N, ?f)›*) simp flip: NSCauchy_NSconvergent_iff (*‹NSCauchy ?X = NSconvergent ?X›*) summable_NSsummable_iff (*‹summable ?f = NSsummable ?f›*) atLeast0LessThan (*‹{0..<?n} = {..<?n}›*)) also (*calculation: ‹NSsummable f = (∀M∈HNatInfinite. ∀N∈HNatInfinite. sumhr (0, M, f) ≈ sumhr (0, N, f))›*) have "... ⟷ ?R" by (metis approx_hrabs_zero_cancel (*‹¦?x¦ ≈ 0 ⟹ ?x ≈ 0›*) approx_minus_iff (*‹(?x ≈ ?y) = (?x - ?y ≈ 0)›*) approx_refl (*‹?x ≈ ?x›*) approx_sym (*‹?x ≈ ?y ⟹ ?y ≈ ?x›*) linorder_less_linear (*‹?x < ?y ∨ ?x = ?y ∨ ?y < ?x›*) sumhr_hrabs_approx (*‹sumhr (0, ?M, ?f) ≈ sumhr (0, ?N, ?f) ⟹ ¦sumhr (?M, ?N, ?f)¦ ≈ 0›*) sumhr_split_diff (*‹?n < ?p ⟹ sumhr (0, ?p, ?f) - sumhr (0, ?n, ?f) = sumhr (?n, ?p, ?f)›*)) finally (*calculation: ‹NSsummable (f::nat ⇒ real) = (∀M::nat star∈HNatInfinite. ∀N::nat star∈HNatInfinite. ¦sumhr (M, N, f)¦ ≈ (0::real star))›*) show "?thesis" (*goal: ‹NSsummable f = (∀M∈HNatInfinite. ∀N∈HNatInfinite. ¦sumhr (M, N, f)¦ ≈ 0)›*) . qed text ‹Terms of a convergent series tend to zero.› lemma NSsummable_NSLIMSEQ_zero: "NSsummable f ⟹ f ⇢⇩N⇩S 0" by (metis HNatInfinite_add (*‹(?x::nat star) ∈ HNatInfinite ⟹ ?x + (?y::nat star) ∈ HNatInfinite›*) NSLIMSEQ_def (*‹(?X::nat ⇒ ?'a) ⇢⇩N⇩S (?L::?'a) = (∀N::nat star∈HNatInfinite. (*f* ?X) N ≈ star_of ?L)›*) NSsummable_NSCauchy (*‹NSsummable (?f::nat ⇒ real) = (∀M::nat star∈HNatInfinite. ∀N::nat star∈HNatInfinite. ¦sumhr (M, N, ?f)¦ ≈ (0::real star))›*) approx_hrabs_zero_cancel (*‹¦?x::real star¦ ≈ (0::real star) ⟹ ?x ≈ (0::real star)›*) star_of_zero (*‹star_of (0::?'a) = (0::?'a star)›*) sumhr_Suc (*‹sumhr (?m::nat star, ?m + (1::nat star), ?f::nat ⇒ real) = (*f* ?f) ?m›*)) text ‹Nonstandard comparison test.› lemma NSsummable_comparison_test: "∃N. ∀n. N ≤ n ⟶ ¦f n¦ ≤ g n ⟹ NSsummable g ⟹ NSsummable f" by (metis real_norm_def (*‹norm ?r = ¦?r¦›*) summable_NSsummable_iff (*‹summable ?f = NSsummable ?f›*) summable_comparison_test (*‹⟦∃N. ∀n≥N. norm (?f n) ≤ ?g n; summable ?g⟧ ⟹ summable ?f›*)) lemma NSsummable_rabs_comparison_test: "∃N. ∀n. N ≤ n ⟶ ¦f n¦ ≤ g n ⟹ NSsummable g ⟹ NSsummable (λk. ¦f k¦)" apply (rule NSsummable_comparison_test (*‹⟦∃N. ∀n≥N. ¦?f n¦ ≤ ?g n; NSsummable ?g⟧ ⟹ NSsummable ?f›*)) (*goals: 1. ‹⟦∃N. ∀n≥N. ¦f n¦ ≤ g n; NSsummable g⟧ ⟹ ∃N. ∀n≥N. ¦¦f n¦¦ ≤ ?g n› 2. ‹⟦∃N. ∀n≥N. ¦f n¦ ≤ g n; NSsummable g⟧ ⟹ NSsummable ?g› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . end
{ "path": "Isabelle2024/src/HOL/Nonstandard_Analysis/HSeries.thy", "repo": "Isabelle2024", "sha": "875d4618d4e77abcd24974b997d1e934fdcefa2c4fb37785773782a7cd6cecc6" }
theory PI_Code_Export_Rat imports PI_Code begin code_datatype set RBT_set Complement Collect_set Set_Monad DList_set lemmas List.subset_code(1)[code] List.in_set_member[code] lemma finite_set_code[code]: "finite (set xs) = True" by auto lemma set_fold_cfc_code[code]:" set_fold_cfc f b (set (xs :: 'c::ccompare list)) = (case ID ccompare of None ⇒ Code.abort STR ''set_fold_cfc RBT_set: ccompare = None'' (λ_. set_fold_cfc f b (set xs)) | Some (x :: 'c ⇒ 'c ⇒ order) ⇒ fold (comp_fun_commute_apply f) (remdups xs) b)" unfolding set_fold_cfc.rep_eq (*goal: ‹Finite_Set.fold (comp_fun_commute_apply (f::('c, 'a) comp_fun_commute)) (b::'a) (set (xs::'c list)) = (case ID ccompare of None ⇒ Code.abort STR ''set_fold_cfc RBT_set: ccompare = None'' (λ_::unit. Finite_Set.fold (comp_fun_commute_apply f) b (set xs)) | Some (x::'c ⇒ 'c ⇒ order) ⇒ fold (comp_fun_commute_apply f) (remdups xs) b)›*) by (auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp: comp_fun_commute.comp_fun_commute (*‹comp_fun_commute (?f::?'a ⇒ ?'b ⇒ ?'b) ⟹ ?f (?y::?'a) ∘ ?f (?x::?'a) = ?f ?x ∘ ?f ?y›*) comp_fun_commute_def' (*‹comp_fun_commute (?f::?'a ⇒ ?'b ⇒ ?'b) = Finite_Set.comp_fun_commute_on UNIV ?f›*) intro!: comp_fun_commute_on.fold_set_fold_remdups[of "set xs"] (*‹⟦Finite_Set.comp_fun_commute_on (set (xs::'c list)) (?f::'c ⇒ ?'b ⇒ ?'b); set (?xs::'c list) ⊆ set xs⟧ ⟹ Finite_Set.fold ?f (?y::?'b) (set ?xs) = fold ?f (remdups ?xs) ?y›*) Finite_Set.comp_fun_commute_on.intro (*‹(⋀(x::?'a) y::?'a. ⟦x ∈ (?S::?'a set); y ∈ ?S⟧ ⟹ (?f::?'a ⇒ ?'b ⇒ ?'b) y ∘ ?f x = ?f x ∘ ?f y) ⟹ Finite_Set.comp_fun_commute_on ?S ?f›*)) export_code ord_real_inst.less_eq_real quotient_of plus_real_inst.plus_real minus_real_inst.minus_real d0 to_valid_MDP MDP RBT_Map.update Rat.of_int divide divide_rat_inst.divide_rat divide_real_inst.divide_real nat_map_from_list assoc_list_to_MDP nat_pmf_of_list RBT_Set.empty PI_code pmf_of_list nat_of_integer Ratreal int_of_integer inverse_divide Tree2.inorder integer_of_nat in SML module_name PI_Code_Rat file_prefix PI_Code_Rat end
{ "path": "afp-2025-02-12/thys/MDP-Algorithms/code/PI_Code_Export_Rat.thy", "repo": "afp-2025-02-12", "sha": "27320a08d6ee406d91f882b2b21439b8c71861e54a265555828bc7c48386b186" }
(* Title: HOL/Datatype_Examples/Lambda_Term.thy Author: Dmitriy Traytel, TU Muenchen Author: Andrei Popescu, TU Muenchen Copyright 2012 Lambda-terms. *) section ‹Lambda-Terms› theory Lambda_Term imports "HOL-Library.FSet" begin section ‹Datatype definition› datatype 'a trm = Var 'a | App "'a trm" "'a trm" | Lam 'a "'a trm" | Lt "('a × 'a trm) fset" "'a trm" subsection ‹Example: The set of all variables varsOf and free variables fvarsOf of a term› primrec varsOf :: "'a trm ⇒ 'a set" where "varsOf (Var a) = {a}" | "varsOf (App f x) = varsOf f ∪ varsOf x" | "varsOf (Lam x b) = {x} ∪ varsOf b" | "varsOf (Lt F t) = varsOf t ∪ (⋃{{x} ∪ X | x X. (x,X) |∈| fimage (map_prod id varsOf) F})" primrec fvarsOf :: "'a trm ⇒ 'a set" where "fvarsOf (Var x) = {x}" | "fvarsOf (App t1 t2) = fvarsOf t1 ∪ fvarsOf t2" | "fvarsOf (Lam x t) = fvarsOf t - {x}" | "fvarsOf (Lt xts t) = fvarsOf t - {x | x X. (x,X) |∈| fimage (map_prod id varsOf) xts} ∪ (⋃{X | x X. (x,X) |∈| fimage (map_prod id varsOf) xts})" lemma diff_Un_incl_triv: "⟦A ⊆ D; C ⊆ E⟧ ⟹ A - B ∪ C ⊆ D ∪ E" by blast lemma in_fimage_map_prod_fset_iff[simp]: "(x, y) |∈| fimage (map_prod f g) xts ⟷ (∃ t1 t2. (t1, t2) |∈| xts ∧ x = f t1 ∧ y = g t2)" by force lemma fvarsOf_varsOf: "fvarsOf t ⊆ varsOf t" proof (induct) (*goals: 1. ‹⋀x. fvarsOf (Var x) ⊆ varsOf (Var x)› 2. ‹⋀x1a x2. ⟦fvarsOf x1a ⊆ varsOf x1a; fvarsOf x2 ⊆ varsOf x2⟧ ⟹ fvarsOf (App x1a x2) ⊆ varsOf (App x1a x2)› 3. ‹⋀x1a x2. fvarsOf x2 ⊆ varsOf x2 ⟹ fvarsOf (Lam x1a x2) ⊆ varsOf (Lam x1a x2)› 4. ‹⋀x1a x2. ⟦⋀x1aa x1aaa. ⟦x1aa |∈| x1a; x1aaa ∈ Basic_BNFs.snds x1aa⟧ ⟹ fvarsOf x1aaa ⊆ varsOf x1aaa; fvarsOf x2 ⊆ varsOf x2⟧ ⟹ fvarsOf (Lt x1a x2) ⊆ varsOf (Lt x1a x2)›*) case (Lt xts t) (*‹⟦(?x1aa::'a × 'a trm) |∈| (xts::('a × 'a trm) fset); (?x1aaa::'a trm) ∈ Basic_BNFs.snds ?x1aa⟧ ⟹ fvarsOf ?x1aaa ⊆ varsOf ?x1aaa› ‹fvarsOf (t::'a trm) ⊆ varsOf t›*) thus "?case" (*goal: ‹fvarsOf (Lt xts t) ⊆ varsOf (Lt xts t)›*) unfolding fvarsOf.simps varsOf.simps (*goal: ‹fvarsOf t - {uu_. ∃x X. uu_ = x ∧ (x, X) |∈| map_prod id varsOf |`| xts} ∪ ⋃ {uu_. ∃x X. uu_ = X ∧ (x, X) |∈| map_prod id varsOf |`| xts} ⊆ varsOf t ∪ ⋃ {{x} ∪ X |x X. (x, X) |∈| map_prod id varsOf |`| xts}›*) apply (elim diff_Un_incl_triv (*‹⟦?A ⊆ ?D; ?C ⊆ ?E⟧ ⟹ ?A - ?B ∪ ?C ⊆ ?D ∪ ?E›*)) (*goal: ‹fvarsOf t - {uu_. ∃x X. uu_ = x ∧ (x, X) |∈| map_prod id varsOf |`| xts} ∪ ⋃ {uu_. ∃x X. uu_ = X ∧ (x, X) |∈| map_prod id varsOf |`| xts} ⊆ varsOf t ∪ ⋃ {{x} ∪ X |x X. (x, X) |∈| map_prod id varsOf |`| xts}›*) by auto qed (auto) (*solves the remaining goals: 1. ‹⋀x. fvarsOf (Var x) ⊆ varsOf (Var x)› 2. ‹⋀x1a x2. ⟦fvarsOf x1a ⊆ varsOf x1a; fvarsOf x2 ⊆ varsOf x2⟧ ⟹ fvarsOf (App x1a x2) ⊆ varsOf (App x1a x2)› 3. ‹⋀x1a x2. fvarsOf x2 ⊆ varsOf x2 ⟹ fvarsOf (Lam x1a x2) ⊆ varsOf (Lam x1a x2)›*) end
{ "path": "Isabelle2024/src/HOL/Datatype_Examples/Lambda_Term.thy", "repo": "Isabelle2024", "sha": "986d35410e39b43db3feba06a4084a292dcd9f2a0856fb91436e534df418f60d" }
(* Title: Examples/SML_Relativization/Foundations/SML_Relations.thy Author: Mihails Milehins Copyright 2021 (C) Mihails Milehins *) section‹Relativization of the results about relations› theory SML_Relations imports Main begin subsection‹Definitions and common properties› context notes [[inductive_internals]] begin inductive_set trancl_on :: "['a set, ('a × 'a) set] ⇒ ('a × 'a) set" (‹on _/ (_⁺)› [1000, 1000] 999) for U :: "'a set" and r :: "('a × 'a) set" where r_into_trancl[intro, Pure.intro]: "⟦ a ∈ U; b ∈ U; (a, b) ∈ r ⟧ ⟹ (a, b) ∈ on U r⁺" | trancl_into_trancl[Pure.intro]: " ⟦ a ∈ U; b ∈ U; c ∈ U; (a, b) ∈ on U r⁺; (b, c) ∈ r ⟧ ⟹ (a, c) ∈ on U r⁺ " abbreviation tranclp_on (‹on _/ (_⁺⁺)› [1000, 1000] 1000) where "tranclp_on ≡ trancl_onp" declare trancl_on_def[nitpick_unfold del] lemmas tranclp_on_def = trancl_onp_def end definition transp_on :: "['a set, ['a, 'a] ⇒ bool] ⇒ bool" where "transp_on U = (λr. (∀x∈U. ∀y∈U. ∀z∈U. r x y ⟶ r y z ⟶ r x z))" definition acyclic_on :: "['a set, ('a × 'a) set] ⇒ bool" where "acyclic_on U = (λr. (∀x∈U. (x, x) ∉ on U r⁺))" lemma trancl_on_eq_tranclp_on: "on P (λx y. (x, y) ∈ r)⁺⁺ x y = ((x, y) ∈ on (Collect P) r⁺)" unfolding trancl_on_def tranclp_on_def Set.mem_Collect_eq (*goal: ‹lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ P a ∧ P b ∧ (a, b) ∈ r) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ P a ∧ P b ∧ P c ∧ p a b ∧ (b, c) ∈ r)) x y = (case (x, y) of (x, xa) ⇒ lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ P a ∧ P b ∧ (a, b) ∈ r) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ P a ∧ P b ∧ P c ∧ p a b ∧ (b, c) ∈ r)) x xa)›*) by simp lemma trancl_on_imp_U: "(x, y) ∈ on U r⁺ ⟹ (x, y) ∈ U × U" by (auto dest: trancl_on.cases (*‹⟦(?a1.0::?'a, ?a2.0::?'a) ∈ on (?U::?'a set) (?r::(?'a × ?'a) set)⁺; ⋀(a::?'a) b::?'a. ⟦?a1.0 = a; ?a2.0 = b; a ∈ ?U; b ∈ ?U; (a, b) ∈ ?r⟧ ⟹ ?P::bool; ⋀(a::?'a) (b::?'a) c::?'a. ⟦?a1.0 = a; ?a2.0 = c; a ∈ ?U; b ∈ ?U; c ∈ ?U; (a, b) ∈ on ?U ?r⁺; (b, c) ∈ ?r⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemmas tranclp_on_imp_P = trancl_on_imp_U[to_pred, simplified] lemma trancl_on_imp_trancl: "(x, y) ∈ on U r⁺ ⟹ (x, y) ∈ r⁺" apply (induction rule: trancl_on.induct (*‹⟦(?x1.0::?'a, ?x2.0::?'a) ∈ on (?U::?'a set) (?r::(?'a × ?'a) set)⁺; ⋀(a::?'a) b::?'a. ⟦a ∈ ?U; b ∈ ?U; (a, b) ∈ ?r⟧ ⟹ (?P::?'a ⇒ ?'a ⇒ bool) a b; ⋀(a::?'a) (b::?'a) c::?'a. ⟦a ∈ ?U; b ∈ ?U; c ∈ ?U; (a, b) ∈ on ?U ?r⁺; ?P a b; (b, c) ∈ ?r⟧ ⟹ ?P a c⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀(a::'a::type) b::'a::type. ⟦a ∈ (U::'a::type set); b ∈ U; (a, b) ∈ (r::('a::type × 'a::type) set)⟧ ⟹ (a, b) ∈ r⁺› 2. ‹⋀(a::'a::type) (b::'a::type) c::'a::type. ⟦a ∈ (U::'a::type set); b ∈ U; c ∈ U; (a, b) ∈ on U (r::('a::type × 'a::type) set)⁺; (a, b) ∈ r⁺; (b, c) ∈ r⟧ ⟹ (a, c) ∈ r⁺› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemmas tranclp_on_imp_tranclp = trancl_on_imp_trancl[to_pred] lemma tranclp_eq_tranclp_on: "r⁺⁺ = on (λx. True) r⁺⁺" unfolding tranclp_def tranclp_on_def (*goal: ‹lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ r a b) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ p a b ∧ r b c)) = lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ True ∧ True ∧ r a b) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ True ∧ True ∧ True ∧ p a b ∧ r b c))›*) by simp lemma trancl_eq_trancl_on: "r⁺ = on UNIV r⁺" unfolding trancl_def trancl_on_def (*goal: ‹{(x, y). (λx xa. (x, xa) ∈ r)⁺⁺ x y} = {(x, y). on (λx. x ∈ UNIV) (λx xa. (x, xa) ∈ r)⁺⁺ x y}›*) by (simp add: tranclp_eq_tranclp_on (*‹?r⁺⁺ = on (λx. True) ?r⁺⁺›*)) lemma transp_on_empty[simp]: "transp_on {} r" unfolding transp_on_def (*goal: ‹∀x::'a∈{}. ∀y::'a∈{}. ∀z::'a∈{}. (r::'a ⇒ 'a ⇒ bool) x y ⟶ r y z ⟶ r x z›*) by simp lemma transp_eq_transp_on: "transp = transp_on UNIV" unfolding transp_def transp_on_def (*goal: ‹(λR. ∀x y z. R x y ⟶ R y z ⟶ R x z) = (λr. ∀x∈UNIV. ∀y∈UNIV. ∀z∈UNIV. r x y ⟶ r y z ⟶ r x z)›*) by simp lemma acyclic_on_empty[simp]: "acyclic_on {} r" unfolding acyclic_on_def (*goal: ‹∀x::'a∈{}. (x, x) ∉ on {} (r::('a × 'a) set)⁺›*) by simp lemma acyclic_eq_acyclic_on: "acyclic = acyclic_on UNIV" unfolding acyclic_def acyclic_on_def (*goal: ‹(λr. ∀x. (x, x) ∉ r⁺) = (λr. ∀x∈UNIV. (x, x) ∉ on UNIV r⁺)›*) unfolding trancl_def tranclp_def trancl_on_def tranclp_on_def (*goal: ‹(λr. ∀x. (x, x) ∉ {(x, y). lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ (a, b) ∈ r) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ p a b ∧ (b, c) ∈ r)) x y}) = (λr. ∀x∈UNIV. (x, x) ∉ {(x, y). lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ a ∈ UNIV ∧ b ∈ UNIV ∧ (a, b) ∈ r) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ a ∈ UNIV ∧ b ∈ UNIV ∧ c ∈ UNIV ∧ p a b ∧ (b, c) ∈ r)) x y})›*) by simp subsection‹Transfer rules I: \<^const>‹lfp› transfer› text‹ The following context contains code from \<^cite>‹"immler_re_2019"›. › context includes lifting_syntax begin lemma Inf_transfer[transfer_rule]: "(rel_set (A ===> (=)) ===> A ===> (=)) Inf Inf" unfolding Inf_fun_def (*goal: ‹(rel_set (A ===> (=)) ===> A ===> (=)) (λA x. INF f∈A. f x) (λA x. INF f∈A. f x)›*) by transfer_prover lemma less_eq_pred_transfer[transfer_rule]: assumes [transfer_rule]: "right_total A" shows "((A ===> (=)) ===> (A ===> (=)) ===> (=)) (λf g. ∀x∈Collect(Domainp A). f x ≤ g x) (≤)" unfolding le_fun_def (*goal: ‹((A ===> (=)) ===> (A ===> (=)) ===> (=)) (λf g. ∀x∈Collect (Domainp A). f x ≤ g x) (λf g. ∀x. f x ≤ g x)›*) by transfer_prover lemma lfp_transfer[transfer_rule]: assumes [transfer_rule]: "bi_unique A" "right_total A" defines "R ≡ (((A ===> (=)) ===> (A ===> (=))) ===> (A ===> (=)))" shows "R (λf. lfp (λu x. if Domainp A x then f u x else bot)) lfp" proof (-) (*goal: ‹R (λf. lfp (λu x. if Domainp A x then f u x else bot)) lfp›*) have "R (λf. Inf {u. ∀x∈Collect (Domainp A). f u x ≤ u x}) lfp" unfolding R_def lfp_def (*goal: ‹(((A ===> (=)) ===> A ===> (=)) ===> A ===> (=)) (λf. Inf {u. ∀x∈Collect (Domainp A). f u x ≤ u x}) (λf. Inf {u. f u ≤ u})›*) by transfer_prover thus "?thesis" (*goal: ‹R (λf. lfp (λu x. if Domainp A x then f u x else bot)) lfp›*) by (auto simp: le_fun_def (*‹((?f::?'a::type ⇒ ?'b::ord) ≤ (?g::?'a::type ⇒ ?'b::ord)) = (∀x::?'a::type. ?f x ≤ ?g x)›*) lfp_def (*‹lfp (?f::?'a::complete_lattice ⇒ ?'a::complete_lattice) = Inf {u::?'a::complete_lattice. ?f u ≤ u}›*)) qed lemma Inf2_transfer[transfer_rule]: "(rel_set (T ===> T ===> (=)) ===> T ===> T ===> (=)) Inf Inf" unfolding Inf_fun_def (*goal: ‹(rel_set ((T::'a ⇒ 'c ⇒ bool) ===> T ===> (=)) ===> T ===> T ===> (=)) (λ(A::('a ⇒ 'a ⇒ 'b) set) (x::'a) xa::'a. INF f::'a ⇒ 'b∈(λf::'a ⇒ 'a ⇒ 'b. f x) ` A. f xa) (λ(A::('c ⇒ 'c ⇒ 'b) set) (x::'c) xa::'c. INF f::'c ⇒ 'b∈(λf::'c ⇒ 'c ⇒ 'b. f x) ` A. f xa)›*) by transfer_prover lemma less_eq2_pred_transfer[transfer_rule]: assumes [transfer_rule]: "right_total T" shows "((T ===> T ===> (=)) ===> (T ===> T ===> (=)) ===> (=)) (λf g. ∀x∈Collect(Domainp T). ∀y∈Collect(Domainp T). f x y ≤ g x y) (≤)" unfolding le_fun_def (*goal: ‹((T ===> T ===> (=)) ===> (T ===> T ===> (=)) ===> (=)) (λf g. ∀x∈Collect (Domainp T). ∀y∈Collect (Domainp T). f x y ≤ g x y) (λf g. ∀x xa. f x xa ≤ g x xa)›*) by transfer_prover lemma lfp2_transfer[transfer_rule]: assumes [transfer_rule]: "bi_unique A" "right_total A" defines "R ≡ (((A ===> A ===> (=)) ===> (A ===> A ===> (=))) ===> (A ===> A ===> (=)))" shows "R ( λf. lfp ( λu x y. if Domainp A x then if Domainp A y then (f u) x y else bot else bot ) ) lfp" proof (-) (*goal: ‹R (λf. lfp (λu x y. if Domainp A x then if Domainp A y then f u x y else bot else bot)) lfp›*) have "R ( λf. Inf { u. ∀x∈Collect (Domainp A). ∀y∈Collect (Domainp A). (f u) x y ≤ u x y } ) lfp" unfolding R_def lfp_def (*goal: ‹(((A ===> A ===> (=)) ===> A ===> A ===> (=)) ===> A ===> A ===> (=)) (λf. Inf {u. ∀x∈Collect (Domainp A). ∀y∈Collect (Domainp A). f u x y ≤ u x y}) (λf. Inf {u. f u ≤ u})›*) by transfer_prover thus "?thesis" (*goal: ‹R (λf. lfp (λu x y. if Domainp A x then if Domainp A y then f u x y else bot else bot)) lfp›*) by (auto simp: le_fun_def (*‹((?f::?'a ⇒ ?'b) ≤ (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x ≤ ?g x)›*) lfp_def (*‹lfp (?f::?'a ⇒ ?'a) = Inf {u::?'a. ?f u ≤ u}›*)) qed end subsection‹Transfer rules II: application-specific rules› context includes lifting_syntax begin lemma transp_rt_transfer[transfer_rule]: assumes[transfer_rule]: "right_total A" shows "((A ===> A ===> (=)) ===> (=)) (transp_on (Collect (Domainp A))) transp" unfolding transp_def transp_on_def (*goal: ‹(((A::'a ⇒ 'b ⇒ bool) ===> A ===> (=)) ===> (=)) (λr::'a ⇒ 'a ⇒ bool. ∀x::'a∈Collect (Domainp A). ∀y::'a∈Collect (Domainp A). ∀z::'a∈Collect (Domainp A). r x y ⟶ r y z ⟶ r x z) (λR::'b ⇒ 'b ⇒ bool. ∀(x::'b) (y::'b) z::'b. R x y ⟶ R y z ⟶ R x z)›*) by transfer_prover lemma tranclp_rt_bu_transfer[transfer_rule]: assumes[transfer_rule]: "bi_unique A" "right_total A" shows "((A ===> A ===> (=)) ===> (A ===> A ===> (=))) (tranclp_on (Domainp A)) tranclp" unfolding tranclp_on_def tranclp_def (*goal: ‹(((A::'a ⇒ 'b ⇒ bool) ===> A ===> (=)) ===> A ===> A ===> (=)) (λr::'a ⇒ 'a ⇒ bool. lfp (λ(p::'a ⇒ 'a ⇒ bool) (x1::'a) x2::'a. (∃(a::'a) b::'a. x1 = a ∧ x2 = b ∧ Domainp A a ∧ Domainp A b ∧ r a b) ∨ (∃(a::'a) (b::'a) c::'a. x1 = a ∧ x2 = c ∧ Domainp A a ∧ Domainp A b ∧ Domainp A c ∧ p a b ∧ r b c))) (λr::'b ⇒ 'b ⇒ bool. lfp (λ(p::'b ⇒ 'b ⇒ bool) (x1::'b) x2::'b. (∃(a::'b) b::'b. x1 = a ∧ x2 = b ∧ r a b) ∨ (∃(a::'b) (b::'b) c::'b. x1 = a ∧ x2 = c ∧ p a b ∧ r b c)))›*) apply transfer_prover_start (*goal: ‹((A ===> A ===> (=)) ===> A ===> A ===> (=)) (λr. lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ Domainp A a ∧ Domainp A b ∧ r a b) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ Domainp A a ∧ Domainp A b ∧ Domainp A c ∧ p a b ∧ r b c))) (λr. lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ r a b) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ p a b ∧ r b c)))›*) apply ((transfer_step)+) (*top goal: ‹Transfer.Rel (?Rg35 ===> (=) ===> ?Ry35) ?ao35 (∧)› and 16 goals remain*) proof (standard) (*goal: ‹⋀r. lfp (λp x1 x2. (∃a b. x1 = a ∧ x2 = b ∧ Domainp A a ∧ Domainp A b ∧ r a b) ∨ (∃a b c. x1 = a ∧ x2 = c ∧ Domainp A a ∧ Domainp A b ∧ Domainp A c ∧ p a b ∧ r b c)) = lfp (λu x y. if Domainp A x then if Domainp A y then (∃a∈Collect (Domainp A). ∃b∈Collect (Domainp A). x = a ∧ y = b ∧ r a b) ∨ (∃a∈Collect (Domainp A). ∃b∈Collect (Domainp A). ∃c∈Collect (Domainp A). x = a ∧ y = c ∧ u a b ∧ r b c) else bot else bot)›*) fix r have "( λp x y. (∃a b. x = a ∧ y = b ∧ Domainp A a ∧ Domainp A b ∧ r a b) ∨ ( ∃a b c. x = a ∧ y = c ∧ Domainp A a ∧ Domainp A b ∧ Domainp A c ∧ p a b ∧ r b c ) ) = ( λp x y. if Domainp A x then if Domainp A y then ( ∃a∈Collect (Domainp A). ∃b∈Collect (Domainp A). x = a ∧ y = b ∧ r a b) ∨ ( ∃a∈Collect (Domainp A). ∃b∈Collect (Domainp A). ∃c∈Collect (Domainp A). x = a ∧ y = c ∧ p a b ∧ r b c ) else bot else bot )" (is "?lhs = ?rhs") apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹(λp x y. (∃a b. x = a ∧ y = b ∧ Domainp A a ∧ Domainp A b ∧ r a b) ∨ (∃a b c. x = a ∧ y = c ∧ Domainp A a ∧ Domainp A b ∧ Domainp A c ∧ p a b ∧ r b c)) = (λp x y. if Domainp A x then if Domainp A y then (∃a∈Collect (Domainp A). ∃b∈Collect (Domainp A). x = a ∧ y = b ∧ r a b) ∨ (∃a∈Collect (Domainp A). ∃b∈Collect (Domainp A). ∃c∈Collect (Domainp A). x = a ∧ y = c ∧ p a b ∧ r b c) else bot else bot)›*) by simp thus "lfp ?lhs = lfp ?rhs" by clarsimp qed lemma trancl_rt_bu_transfer[transfer_rule]: assumes[transfer_rule]: "bi_unique A" "right_total A" shows "(rel_set (rel_prod A A) ===> rel_set (rel_prod A A)) (trancl_on (Collect (Domainp A))) trancl" unfolding trancl_on_def trancl_def (*goal: ‹(rel_set (rel_prod A A) ===> rel_set (rel_prod A A)) (λr. {(x, y). on (λx. x ∈ Collect (Domainp A)) (λx xa. (x, xa) ∈ r)⁺⁺ x y}) (λr. {(xa, x). (λx xa. (x, xa) ∈ r)⁺⁺ xa x})›*) apply transfer_prover_start (*goals: 1. ‹Transfer.Rel (?Ri12 ===> ?Rj12 ===> ?Rl12) ?ad12 Pair› 2. ‹Transfer.Rel (?Rl12 ===> rel_set (rel_prod A A) ===> ?Rk12) ?ac12 (∈)› 3. ‹Transfer.Rel ((?Ri12 ===> ?Rj12 ===> ?Rk12) ===> ?Rf12 ===> ?Rg12 ===> ?Rh12) ?ab12 tranclp› 4. ‹Transfer.Rel ((?Rf12 ===> ?Rg12 ===> ?Rh12) ===> ?Rd12) ?aa12 case_prod› 5. ‹Transfer.Rel (?Rd12 ===> rel_set (rel_prod A A)) ?a12 Collect› 6. ‹(λr. {(x, y). on (λx. x ∈ Collect (Domainp A)) (λx xa. (x, xa) ∈ r)⁺⁺ x y}) = (λr. ?a12 (?aa12 (?ab12 (λx xa. ?ac12 (?ad12 x xa) r))))› discuss goal 1*) apply transfer_step (*discuss goal 2*) apply transfer_step (*discuss goal 3*) apply transfer_step (*discuss goal 4*) apply transfer_step (*discuss goal 5*) apply transfer_step (*discuss goal 6*) apply (auto simp: tranclp_on_imp_P[where U="Domainp A"] (*‹on (Domainp (A::'a ⇒ 'b ⇒ bool)) (?r::'a ⇒ 'a ⇒ bool)⁺⁺ (?x::'a) (?y::'a) ⟹ Domainp A ?x ∧ Domainp A ?y›*)) (*proven 6 subgoals*) . lemma acyclic_rt_bu_transfer[transfer_rule]: assumes[transfer_rule]: "bi_unique A" "right_total A" shows "((rel_set (rel_prod A A)) ===> (=)) (acyclic_on (Collect (Domainp A))) acyclic" unfolding acyclic_on_def acyclic_def (*goal: ‹(rel_set (rel_prod (A::'a ⇒ 'b ⇒ bool) A) ===> (=)) (λr::('a × 'a) set. ∀x::'a∈Collect (Domainp A). (x, x) ∉ on (Collect (Domainp A)) r⁺) (λr::('b × 'b) set. ∀x::'b. (x, x) ∉ r⁺)›*) by transfer_prover end text‹\newpage› end
{ "path": "afp-2025-02-12/thys/Types_To_Sets_Extension/Examples/SML_Relativization/Foundations/SML_Relations.thy", "repo": "afp-2025-02-12", "sha": "0f6ce5908ff467754d80aa37538647fbf57a7c427c03aedea328867949bac383" }
(* File: Quicksort.thy Author: Bohua Zhan *) section ‹Quicksort› theory Quicksort imports Arrays_Ex begin text ‹ Functional version of quicksort. Implementation of quicksort is largely based on theory Imperative\_Quicksort in HOL/Imperative\_HOL/ex in the Isabelle library. › subsection ‹Outer remains› definition outer_remains :: "'a list ⇒ 'a list ⇒ nat ⇒ nat ⇒ bool" where [rewrite]: "outer_remains xs xs' l r ⟷ (length xs = length xs' ∧ (∀i. i < l ∨ r < i ⟶ xs ! i = xs' ! i))" lemma outer_remains_length [forward]: "outer_remains xs xs' l r ⟹ length xs = length xs'" by auto2 lemma outer_remains_eq [rewrite_back]: "outer_remains xs xs' l r ⟹ i < l ⟹ xs ! i = xs' ! i" "outer_remains xs xs' l r ⟹ r < i ⟹ xs ! i = xs' ! i" (*goals: 1. ‹⟦outer_remains xs xs' l r; i < l⟧ ⟹ xs ! i = xs' ! i› 2. ‹⟦outer_remains xs xs' l r; r < i⟧ ⟹ xs ! i = xs' ! i› discuss goal 1*) apply auto2 (*discuss goal 2*) apply auto2 (*proven 2 subgoals*) . lemma outer_remains_sublist [backward2]: "outer_remains xs xs' l r ⟹ i < l ⟹ take i xs = take i xs'" "outer_remains xs xs' l r ⟹ r < i ⟹ drop i xs = drop i xs'" "i ≤ j ⟹ j ≤ length xs ⟹ outer_remains xs xs' l r ⟹ j ≤ l ⟹ sublist i j xs = sublist i j xs'" "i ≤ j ⟹ j ≤ length xs ⟹ outer_remains xs xs' l r ⟹ i > r ⟹ sublist i j xs = sublist i j xs'" (*goals: 1. ‹⟦outer_remains xs xs' l r; i < l⟧ ⟹ take i xs = take i xs'› 2. ‹⟦outer_remains xs xs' l r; r < i⟧ ⟹ drop i xs = drop i xs'› 3. ‹⟦i ≤ j; j ≤ length xs; outer_remains xs xs' l r; j ≤ l⟧ ⟹ sublist i j xs = sublist i j xs'› 4. ‹⟦i ≤ j; j ≤ length xs; outer_remains xs xs' l r; r < i⟧ ⟹ sublist i j xs = sublist i j xs'› discuss goal 1*) apply auto2 (*discuss goal 2*) apply auto2 (*discuss goal 3*) apply auto2 (*discuss goal 4*) apply auto2 (*proven 4 subgoals*) . setup ‹del_prfstep_thm_eqforward @{thm outer_remains_def}› subsection ‹part1 function› function part1 :: "('a::linorder) list ⇒ nat ⇒ nat ⇒ 'a ⇒ (nat × 'a list)" where "part1 xs l r a = ( if r ≤ l then (r, xs) else if xs ! l ≤ a then part1 xs (l + 1) r a else part1 (list_swap xs l r) l (r - 1) a)" by auto termination by (relation "measure (λ(_,l,r,_). r - l)") auto setup ‹register_wellform_data ("part1 xs l r a", ["r < length xs"])› setup ‹add_prfstep_check_req ("part1 xs l r a", "r < length xs")› lemma part1_basic: "r < length xs ⟹ l ≤ r ⟹ (rs, xs') = part1 xs l r a ⟹ outer_remains xs xs' l r ∧ mset xs' = mset xs ∧ l ≤ rs ∧ rs ≤ r" @proof @fun_induct "part1 xs l r a" @unfold "part1 xs l r a" @qed setup ‹add_forward_prfstep_cond @{thm part1_basic} [with_term "part1 ?xs ?l ?r ?a"]› lemma part1_partitions1 [backward]: "r < length xs ⟹ (rs, xs') = part1 xs l r a ⟹ l ≤ i ⟹ i < rs ⟹ xs' ! i ≤ a" @proof @fun_induct "part1 xs l r a" @unfold "part1 xs l r a" @qed lemma part1_partitions2 [backward]: "r < length xs ⟹ (rs, xs') = part1 xs l r a ⟹ rs < i ⟹ i ≤ r ⟹ xs' ! i ≥ a" @proof @fun_induct "part1 xs l r a" @unfold "part1 xs l r a" @qed subsection ‹Paritition function› definition partition :: "('a::linorder list) ⇒ nat ⇒ nat ⇒ (nat × 'a list)" where [rewrite]: "partition xs l r = ( let p = xs ! r; (m, xs') = part1 xs l (r - 1) p; m' = if xs' ! m ≤ p then m + 1 else m in (m', list_swap xs' m' r))" setup ‹register_wellform_data ("partition xs l r", ["l < r", "r < length xs"])› lemma partition_basic: "l < r ⟹ r < length xs ⟹ (rs, xs') = partition xs l r ⟹ outer_remains xs xs' l r ∧ mset xs' = mset xs ∧ l ≤ rs ∧ rs ≤ r" by (msorry) setup ‹add_forward_prfstep_cond @{thm partition_basic} [with_term "partition ?xs ?l ?r"]› lemma partition_partitions1 [forward]: "l < r ⟹ r < length xs ⟹ (rs, xs') = partition xs l r ⟹ x ∈ set (sublist l rs xs') ⟹ x ≤ xs' ! rs" @proof @obtain i where "i ≥ l" "i < rs" "x = xs' ! i" @qed lemma partition_partitions2 [forward]: "l < r ⟹ r < length xs ⟹ (rs, xs'') = partition xs l r ⟹ x ∈ set (sublist (rs + 1) (r + 1) xs'') ⟹ x ≥ xs'' ! rs" @proof @obtain i where "i ≥ rs + 1" "i < r + 1" "x = xs'' ! i" @let "p = xs ! r" @let "m = fst (part1 xs l (r - 1) p)" @let "xs' = snd (part1 xs l (r - 1) p)" @case "xs' ! m ≤ p" @qed setup ‹del_prfstep_thm @{thm partition_def}› lemma quicksort_term1: "¬r ≤ l ⟹ ¬ length xs ≤ r ⟹ x = partition xs l r ⟹ (p, xs1) = x ⟹ p - Suc l < r - l" @proof @have "fst (partition xs l r) - l - 1 < r - l" @qed lemma quicksort_term2: "¬r ≤ l ⟹ ¬ length xs ≤ r ⟹ x = partition xs l r ⟹ (p, xs2) = x ⟹ r - Suc p < r - l" @proof @have "r - fst (partition xs l r) - 1 < r - l" @qed subsection ‹Quicksort function› function quicksort :: "('a::linorder) list ⇒ nat ⇒ nat ⇒ 'a list" where "quicksort xs l r = ( if l ≥ r then xs else if r ≥ length xs then xs else let (p, xs1) = partition xs l r; xs2 = quicksort xs1 l (p - 1) in quicksort xs2 (p + 1) r)" by auto termination apply (relation "measure (λ(a, l, r). (r - l))") by (auto simp add: quicksort_term1 quicksort_term2) lemma quicksort_basic [rewrite_arg]: "mset (quicksort xs l r) = mset xs ∧ outer_remains xs (quicksort xs l r) l r" @proof @fun_induct "quicksort xs l r" @unfold "quicksort xs l r" @qed lemma quicksort_trivial1 [rewrite]: "l ≥ r ⟹ quicksort xs l r = xs" @proof @unfold "quicksort xs l r" @qed lemma quicksort_trivial2 [rewrite]: "r ≥ length xs ⟹ quicksort xs l r = xs" @proof @unfold "quicksort xs l r" @qed lemma quicksort_permutes [resolve]: "xs' = quicksort xs l r ⟹ set (sublist l (r + 1) xs') = set (sublist l (r + 1) xs)" @proof @case "l ≥ r" @case "r ≥ length xs" @have "xs = take l xs @ sublist l (r + 1) xs @ drop (r + 1) xs" @have "xs' = take l xs' @ sublist l (r + 1) xs' @ drop (r + 1) xs'" @have "take l xs = take l xs'" @have "drop (r + 1) xs = drop (r + 1) xs'" @qed lemma quicksort_sorts [forward_arg]: "r < length xs ⟹ sorted (sublist l (r + 1) (quicksort xs l r))" @proof @fun_induct "quicksort xs l r" @case "l ≥ r" @with @case "l = r" @end @case "r ≥ length xs" @let "p = fst (partition xs l r)" @let "xs1 = snd (partition xs l r)" @let "xs2 = quicksort xs1 l (p - 1)" @let "xs3 = quicksort xs2 (p + 1) r" @have "sorted (sublist l (r + 1) xs3)" @with @have "l ≤ p" @have "p + 1 ≤ r + 1" @have "r + 1 ≤ length xs3" @have "sublist l p xs2 = sublist l p xs3" @have "set (sublist l p xs1) = set (sublist l p xs2)" @have "sublist (p + 1) (r + 1) xs1 = sublist (p + 1) (r + 1) xs2" @have "set (sublist (p + 1) (r + 1) xs2) = set (sublist (p + 1) (r + 1) xs3)" @have "∀x∈set (sublist l p xs3). x ≤ xs3 ! p" @have "∀x∈set (sublist (p + 1) (r + 1) xs3). x ≥ xs3 ! p" @have "sorted (sublist l p xs3)" @have "sorted (sublist (p + 1) (r + 1) xs3)" @have "sublist l (r + 1) xs3 = sublist l p xs3 @ (xs3 ! p) # sublist (p + 1) (r + 1) xs3" @end @unfold "quicksort xs l r" @qed text ‹Main result: correctness of functional quicksort.› theorem quicksort_sorts_all [rewrite]: "xs ≠ [] ⟹ quicksort xs 0 (length xs - 1) = sort xs" @proof @let "xs' = quicksort xs 0 (length xs - 1)" @have "sublist 0 (length xs - 1 + 1) xs' = xs'" @qed end
{ "path": "afp-2025-02-12/thys/Auto2_Imperative_HOL/Functional/Quicksort.thy", "repo": "afp-2025-02-12", "sha": "309c6f0fe256f3757aaac43ea0533902b011f99daa9bba58cae8d24ea02f2323" }
section‹More Instances of Replacement› theory Replacement_Instances imports Separation_Instances Transitive_Models.Pointed_DC_Relative begin lemma composition_fm_type[TC]: "a0 ∈ ω ⟹ a1 ∈ ω ⟹ a2 ∈ ω ⟹ composition_fm(a0,a1,a2) ∈ formula" unfolding composition_fm_def (*goal: ‹⟦(a0::i) ∈ ω; (a1::i) ∈ ω; (a2::i) ∈ ω⟧ ⟹ (⋅∀⋅⋅0 ∈ succ(a2)⋅ ↔ (⋅∃(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅⟨4,2⟩ is 5 ⋅ ∧ ⋅⋅⟨4,3⟩ is 1 ⋅ ∧ ⋅⋅⟨3,2⟩ is 0 ⋅ ∧ ⋅⋅1 ∈ a1 +⇩ω 6⋅ ∧ ⋅0 ∈ a0 +⇩ω 6⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)⋅)⋅⋅) ∈ formula›*) by simp arity_theorem for "composition_fm" definition is_omega_funspace :: "[i⇒o,i,i,i]⇒o" where "is_omega_funspace(N,B,n,z) ≡ ∃o[N]. omega(N,o) ∧ n∈o ∧ is_funspace(N, n, B, z)" synthesize "omega_funspace" from_definition "is_omega_funspace" assuming "nonempty" arity_theorem for "omega_funspace_fm" definition HAleph_wfrec_repl_body where "HAleph_wfrec_repl_body(N,mesa,x,z) ≡ ∃y[N]. pair(N, x, y, z) ∧ (∃g[N]. (∀u[N]. u ∈ g ⟷ (∃a[N]. ∃y[N]. ∃ax[N]. ∃sx[N]. ∃r_sx[N]. ∃f_r_sx[N]. pair(N, a, y, u) ∧ pair(N, a, x, ax) ∧ upair(N, a, a, sx) ∧ pre_image(N, mesa, sx, r_sx) ∧ restriction(N, g, r_sx, f_r_sx) ∧ ax ∈ mesa ∧ is_HAleph(N, a, f_r_sx, y))) ∧ is_HAleph(N, x, g, y))" (* MOVE THIS to an appropriate place *) arity_theorem for "ordinal_fm" arity_theorem for "is_Limit_fm" arity_theorem for "empty_fm" arity_theorem for "fun_apply_fm" synthesize "HAleph_wfrec_repl_body" from_definition assuming "nonempty" arity_theorem for "HAleph_wfrec_repl_body_fm" definition dcwit_repl_body where "dcwit_repl_body(N,mesa,A,a,s,R) ≡ λx z. ∃y[N]. pair(N, x, y, z) ∧ is_wfrec (N, λn f. is_nat_case (N, a, λm bmfm. ∃fm[N]. ∃cp[N]. is_apply(N, f, m, fm) ∧ is_Collect(N, A, λx. ∃fmx[N]. (N(x) ∧ fmx ∈ R) ∧ pair(N, fm, x, fmx), cp) ∧ is_apply(N, s, cp, bmfm), n), mesa, x, y)" manual_schematic for "dcwit_repl_body" assuming "nonempty" unfolding dcwit_repl_body_def by (rule iff_sats is_nat_case_iff_sats is_eclose_iff_sats sep_rules | simp)+ synthesize "dcwit_repl_body" from_schematic definition dcwit_aux_fm where "dcwit_aux_fm(A,s,R) ≡ (⋅∃⋅⋅4`2 is 0⋅ ∧ (⋅∃⋅Collect_fm (succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(A)))))))))), (⋅∃⋅⋅0 ∈ succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(R)))))))))))) ⋅ ∧ pair_fm(3, 1, 0) ⋅⋅), 0) ∧ ⋅ succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(s))))))))))`0 is 2⋅⋅⋅)⋅⋅)" arity_theorem for "dcwit_aux_fm" lemma dcwit_aux_fm_type[TC]: "A ∈ ω ⟹ s ∈ ω ⟹ R ∈ ω ⟹ dcwit_aux_fm(A,s,R) ∈ formula" by (simp add: dcwit_aux_fm_def (*‹dcwit_aux_fm(?A, ?s, ?R) ≡ (⋅∃⋅⋅4`2 is 0⋅ ∧ (⋅∃⋅Collect_fm(succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(?A)))))))))), (⋅∃⋅⋅0 ∈ succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(?R))))))))))))⋅ ∧ ⋅⟨3,1⟩ is 0 ⋅⋅⋅), 0) ∧ ⋅succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(?s))))))))))`0 is 2⋅⋅⋅)⋅⋅)›*)) definition is_nat_case_dcwit_aux_fm where "is_nat_case_dcwit_aux_fm(A,a,s,R) ≡ is_nat_case_fm (succ(succ(succ(succ(succ(succ(a)))))),dcwit_aux_fm(A,s,R), 2, 0)" lemma is_nat_case_dcwit_aux_fm_type[TC]: "A ∈ ω ⟹ a ∈ ω ⟹ s ∈ ω ⟹ R ∈ ω ⟹ is_nat_case_dcwit_aux_fm(A,a,s,R) ∈ formula" by (simp add: is_nat_case_dcwit_aux_fm_def (*‹is_nat_case_dcwit_aux_fm(?A, ?a, ?s, ?R) ≡ is_nat_case_fm(succ(succ(succ(succ(succ(succ(?a)))))), dcwit_aux_fm(?A, ?s, ?R), 2, 0)›*)) manual_arity for "is_nat_case_dcwit_aux_fm" unfolding is_nat_case_dcwit_aux_fm_def by (rule arity_dcwit_aux_fm[THEN [6] arity_is_nat_case_fm]) simp_all manual_arity for "dcwit_repl_body_fm" using arity_is_nat_case_dcwit_aux_fm[THEN [6] arity_is_wfrec_fm] unfolding dcwit_repl_body_fm_def is_nat_case_dcwit_aux_fm_def dcwit_aux_fm_def by (auto simp add: arity(1-33)) lemma arity_dcwit_repl_body: "arity(dcwit_repl_body_fm(6,5,4,3,2,0,1)) = 7" by (simp add: FOL_arities (*‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))›*) arity_dcwit_repl_body_fm (*‹⟦?mesa ∈ ω; ?A ∈ ω; ?a ∈ ω; ?s ∈ ω; ?R ∈ ω; ?x ∈ ω; ?z ∈ ω⟧ ⟹ arity(dcwit_repl_body_fm(?mesa, ?A, ?a, ?s, ?R, ?x, ?z)) = pred(succ(succ(?x)) ∪ 1 ∪ succ(succ(?z)) ∪ (succ(succ(?mesa)) ∪ succ(succ(?x)) ∪ 1 ∪ pred(pred(pred(pred(pred(succ(succ(succ(succ(succ(succ(succ(?a))))))) ∪ 3 ∪ 1 ∪ pred(pred(2 ∪ 4 ∪ (succ(succ(succ(succ(succ(succ(succ(succ(succ(?A))))))))) ∪ succ(succ(succ(succ(succ(succ(succ(succ(succ(?R))))))))) ∪ (succ(succ(succ(succ(succ(succ(succ(succ(succ(?s))))))))) ∪ 1)))))))))))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*)) definition fst2_snd2 where "fst2_snd2(x) ≡ ⟨fst(fst(x)), snd(snd(x))⟩" relativize functional "fst2_snd2" "fst2_snd2_rel" relationalize "fst2_snd2_rel" "is_fst2_snd2" lemma (in M_trivial) fst2_snd2_abs: assumes "M(x)" "M(res)" shows "is_fst2_snd2(M, x, res) ⟷ res = fst2_snd2(x)" unfolding is_fst2_snd2_def fst2_snd2_def (*goal: ‹(∃a[M]. ∃b[M]. ∃c[M]. ∃d[M]. pair(M, b, d, res) ∧ is_snd(M, c, d) ∧ is_snd(M, x, c) ∧ is_fst(M, a, b) ∧ is_fst(M, x, a)) ⟷ res = ⟨fst(fst(x)), snd(snd(x))⟩›*) using fst_rel_abs (*‹M(?p) ⟹ fst_rel(M, ?p) = fst(?p)›*) snd_rel_abs (*‹M(?p) ⟹ snd_rel(M, ?p) = snd(?p)›*) fst_abs (*‹⟦M(?p); M(?x)⟧ ⟹ is_fst(M, ?p, ?x) ⟷ ?x = fst(?p)›*) snd_abs (*‹⟦(M::i ⇒ o)(?p::i); M(?y::i)⟧ ⟹ is_snd(M, ?p, ?y) ⟷ ?y = snd(?p)›*) assms (*‹M(x)› ‹M(res)›*) by simp synthesize "is_fst2_snd2" from_definition assuming "nonempty" arity_theorem for "is_fst2_snd2_fm" definition sndfst_fst2_snd2 where "sndfst_fst2_snd2(x) ≡ ⟨snd(fst(x)), fst(fst(x)), snd(snd(x))⟩" relativize functional "sndfst_fst2_snd2" "sndfst_fst2_snd2_rel" relationalize "sndfst_fst2_snd2_rel" "is_sndfst_fst2_snd2" synthesize "is_sndfst_fst2_snd2" from_definition assuming "nonempty" arity_theorem for "is_sndfst_fst2_snd2_fm" definition order_eq_map where "order_eq_map(M,A,r,a,z) ≡ ∃x[M]. ∃g[M]. ∃mx[M]. ∃par[M]. ordinal(M,x) & pair(M,a,x,z) & membership(M,x,mx) & pred_set(M,A,a,r,par) & order_isomorphism(M,par,r,x,mx,g)" synthesize "order_eq_map" from_definition assuming "nonempty" arity_theorem for "is_ord_iso_fm" arity_theorem for "order_eq_map_fm" (* Banach *) synthesize "is_banach_functor" from_definition assuming "nonempty" arity_theorem for "is_banach_functor_fm" definition banach_body_iterates where "banach_body_iterates(M,X,Y,f,g,W,n,x,z) ≡ ∃y[M]. pair(M, x, y, z) ∧ (∃fa[M]. (∀z[M]. z ∈ fa ⟷ (∃xa[M]. ∃y[M]. ∃xaa[M]. ∃sx[M]. ∃r_sx[M]. ∃f_r_sx[M]. ∃sn[M]. ∃msn[M]. successor(M,n,sn) ∧ membership(M,sn,msn) ∧ pair(M, xa, y, z) ∧ pair(M, xa, x, xaa) ∧ upair(M, xa, xa, sx) ∧ pre_image(M, msn, sx, r_sx) ∧ restriction(M, fa, r_sx, f_r_sx) ∧ xaa ∈ msn ∧ (empty(M, xa) ⟶ y = W) ∧ (∀m[M]. successor(M, m, xa) ⟶ (∃gm[M]. is_apply(M, f_r_sx, m, gm) ∧ is_banach_functor(M, X, Y, f, g, gm, y))) ∧ (is_quasinat(M, xa) ∨ empty(M, y)))) ∧ (empty(M, x) ⟶ y = W) ∧ (∀m[M]. successor(M, m, x) ⟶ (∃gm[M]. is_apply(M, fa, m, gm) ∧ is_banach_functor(M, X, Y, f, g, gm, y))) ∧ (is_quasinat(M, x) ∨ empty(M, y)))" synthesize "is_quasinat" from_definition assuming "nonempty" arity_theorem for "is_quasinat_fm" synthesize "banach_body_iterates" from_definition assuming "nonempty" arity_theorem for "banach_body_iterates_fm" definition banach_is_iterates_body where "banach_is_iterates_body(M,X,Y,f,g,W,n,y) ≡ ∃om[M]. omega(M,om) ∧ n ∈ om ∧ (∃sn[M]. ∃msn[M]. successor(M, n, sn) ∧ membership(M, sn, msn) ∧ (∃fa[M]. (∀z[M]. z ∈ fa ⟷ (∃x[M]. ∃y[M]. ∃xa[M]. ∃sx[M]. ∃r_sx[M]. ∃f_r_sx[M]. pair(M, x, y, z) ∧ pair(M, x, n, xa) ∧ upair(M, x, x, sx) ∧ pre_image(M, msn, sx, r_sx) ∧ restriction(M, fa, r_sx, f_r_sx) ∧ xa ∈ msn ∧ (empty(M, x) ⟶ y = W) ∧ (∀m[M]. successor(M, m, x) ⟶ (∃gm[M]. fun_apply(M, f_r_sx, m, gm) ∧ is_banach_functor(M, X, Y, f, g, gm, y))) ∧ (is_quasinat(M, x) ∨ empty(M, y)))) ∧ (empty(M, n) ⟶ y = W) ∧ (∀m[M]. successor(M, m, n) ⟶ (∃gm[M]. fun_apply(M, fa, m, gm) ∧ is_banach_functor(M, X, Y, f, g, gm, y))) ∧ (is_quasinat(M, n) ∨ empty(M, y))))" synthesize "banach_is_iterates_body" from_definition assuming "nonempty" arity_theorem for "banach_is_iterates_body_fm" (* (##M)(f) ⟹ strong_replacement(##M, λx y. y = ⟨x, transrec(x, λa g. f ` (g `` a))⟩) *) definition trans_apply_image where "trans_apply_image(f) ≡ λa g. f ` (g `` a)" relativize functional "trans_apply_image" "trans_apply_image_rel" relationalize "trans_apply_image" "is_trans_apply_image" (* MOVE THIS to an appropriate place *) schematic_goal arity_is_recfun_fm[arity]: "p ∈ formula ⟹ a ∈ ω ⟹ z ∈ ω ⟹ r ∈ ω ⟹ arity(is_recfun_fm(p, a, z ,r)) = ?ar" unfolding is_recfun_fm_def (*goal: ‹⟦(p::i) ∈ formula; (a::i) ∈ ω; (z::i) ∈ ω; (r::i) ∈ ω⟧ ⟹ arity((⋅∀⋅⋅0 ∈ succ(r)⋅ ↔ (⋅∃(⋅∃(⋅∃⋅p ∧ ⋅⋅⟨2,0⟩ is 3 ⋅ ∧ (⋅∃(⋅∃(⋅∃⋅⋅⟨5,z +⇩ω 7⟩ is 2 ⋅ ∧ ⋅⋅{5,5} is 1 ⋅ ∧ ⋅⋅a +⇩ω 7 -`` 1 is 0 ⋅ ∧ ⋅⋅r +⇩ω 7 ↾ 0 is 4 ⋅ ∧ ⋅2 ∈ a +⇩ω 7⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅⋅⋅)⋅)⋅)⋅⋅)) = (?ar::i)›*) by (simp add:arity (*‹⟦?φ ∈ formula; ?t ∈ ω; ?f ∈ ω; ?r ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))› ‹⟦?t1.0 ∈ ω; ?t2.0 ∈ ω; ?up ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦?r ∈ ω; ?s ∈ ω; ?t ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 164 facts*)) (* clean simpset from arities, use correct attrib *) (* Don't know why it doesn't use the theorem at 🗏‹Arities› *) schematic_goal arity_is_wfrec_fm[arity]: "p ∈ formula ⟹ a ∈ ω ⟹ z ∈ ω ⟹ r ∈ ω ⟹ arity(is_wfrec_fm(p, a, z ,r)) = ?ar" unfolding is_wfrec_fm_def (*goal: ‹⟦p ∈ formula; a ∈ ω; z ∈ ω; r ∈ ω⟧ ⟹ arity((⋅∃⋅is_recfun_fm(p, succ(a), succ(z), 0) ∧ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅2 = z +⇩ω 5⋅ ∧ ⋅⋅1 = 4⋅ ∧ ⋅⋅0 = r +⇩ω 5⋅ ∧ p⋅⋅⋅⋅)⋅)⋅)⋅)⋅⋅)) = ?ar›*) by (simp add:arity (*‹⟦?φ ∈ formula; ?t ∈ ω; ?f ∈ ω; ?r ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))› ‹⟦?t1.0 ∈ ω; ?t2.0 ∈ ω; ?up ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦?r ∈ ω; ?s ∈ ω; ?t ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 165 facts*)) schematic_goal arity_is_transrec_fm[arity]: "p ∈ formula ⟹ a ∈ ω ⟹ z ∈ ω ⟹ arity(is_transrec_fm(p, a, z)) = ?ar" unfolding is_transrec_fm_def (*goal: ‹⟦(p::i) ∈ formula; (a::i) ∈ ω; (z::i) ∈ ω⟧ ⟹ arity((⋅∃(⋅∃(⋅∃⋅⋅{a +⇩ω 3,a +⇩ω 3} is 2 ⋅ ∧ ⋅is_eclose_fm(2, 1) ∧ ⋅⋅Memrel(1) is 0⋅ ∧ is_wfrec_fm(p, 0, a +⇩ω 3, z +⇩ω 3)⋅⋅⋅⋅)⋅)⋅)) = (?ar::i)›*) by (simp add:arity (*‹⟦?φ ∈ formula; ?t ∈ ω; ?f ∈ ω; ?r ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))› ‹⟦?t1.0 ∈ ω; ?t2.0 ∈ ω; ?up ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦?r ∈ ω; ?s ∈ ω; ?t ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 166 facts*)) synthesize "is_trans_apply_image" from_definition assuming "nonempty" arity_theorem for "is_trans_apply_image_fm" definition transrec_apply_image_body where "transrec_apply_image_body(M,f,mesa,x,z) ≡ ∃y[M]. pair(M, x, y, z) ∧ (∃fa[M]. (∀z[M]. z ∈ fa ⟷ (∃xa[M]. ∃y[M]. ∃xaa[M]. ∃sx[M]. ∃r_sx[M]. ∃f_r_sx[M]. pair(M, xa, y, z) ∧ pair(M, xa, x, xaa) ∧ upair(M, xa, xa, sx) ∧ pre_image(M, mesa, sx, r_sx) ∧ restriction(M, fa, r_sx, f_r_sx) ∧ xaa ∈ mesa ∧ is_trans_apply_image(M, f, xa, f_r_sx, y))) ∧ is_trans_apply_image(M, f, x, fa, y))" synthesize "transrec_apply_image_body" from_definition assuming "nonempty" arity_theorem for "transrec_apply_image_body_fm" definition is_trans_apply_image_body where "is_trans_apply_image_body(M,f,β,a,w) ≡ ∃z[M]. pair(M,a,z,w) ∧ a∈β ∧ (∃sa[M]. ∃esa[M]. ∃mesa[M]. upair(M, a, a, sa) ∧ is_eclose(M, sa, esa) ∧ membership(M, esa, mesa) ∧ (∃fa[M]. (∀z[M]. z ∈ fa ⟷ (∃x[M]. ∃y[M]. ∃xa[M]. ∃sx[M]. ∃r_sx[M]. ∃f_r_sx[M]. pair(M, x, y, z) ∧ pair(M, x, a, xa) ∧ upair(M, x, x, sx) ∧ pre_image(M, mesa, sx, r_sx) ∧ restriction(M, fa, r_sx, f_r_sx) ∧ xa ∈ mesa ∧ is_trans_apply_image(M, f, x, f_r_sx, y))) ∧ is_trans_apply_image(M, f, a, fa, z)))" synthesize "is_trans_apply_image_body" from_definition assuming "nonempty" arity_theorem for "is_trans_apply_image_body_fm" definition replacement_is_omega_funspace_fm where "replacement_is_omega_funspace_fm ≡ omega_funspace_fm(2,0,1)" definition wfrec_Aleph_fm where "wfrec_Aleph_fm ≡ HAleph_wfrec_repl_body_fm(2,0,1)" definition replacement_is_fst2_snd2_fm where "replacement_is_fst2_snd2_fm ≡ is_fst2_snd2_fm(0,1)" definition replacement_is_sndfst_fst2_snd2_fm where "replacement_is_sndfst_fst2_snd2_fm ≡ is_sndfst_fst2_snd2_fm(0,1)" definition omap_replacement_fm where "omap_replacement_fm ≡ order_eq_map_fm(2,3,0,1)" definition rec_constr_abs_fm where "rec_constr_abs_fm ≡ transrec_apply_image_body_fm(3,2,0,1)" definition banach_replacement_iterates_fm where "banach_replacement_iterates_fm ≡ banach_is_iterates_body_fm(6,5,4,3,2,0,1)" definition rec_constr_fm where "rec_constr_fm ≡ is_trans_apply_image_body_fm(3,2,0,1)" (* definition banach_iterates_fm where "banach_iterates_fm ≡ banach_body_iterates_fm(7,6,5,4,3,2,0,1)" *) definition dc_abs_fm where "dc_abs_fm ≡ dcwit_repl_body_fm(6,5,4,3,2,0,1)" definition lam_replacement_check_fm where "lam_replacement_check_fm ≡ Lambda_in_M_fm(check_fm(2,0,1),1)" text‹The following instances are needed only on the ground model. The first one corresponds to the recursive definition of forces for atomic formulas; the next two corresponds to \<^term>‹PHcheck›; the following is used to get a generic filter using some form of choice.› locale M_ZF_ground = M_ZF1 + assumes ZF_ground_replacements: "replacement_assm(M,env,wfrec_Hfrc_at_fm)" "replacement_assm(M,env,wfrec_Hcheck_fm)" "replacement_assm(M,env,lam_replacement_check_fm)" locale M_ZF_ground_trans = M_ZF1_trans + M_ZF_ground definition instances_ground_fms where "instances_ground_fms ≡ { wfrec_Hfrc_at_fm, wfrec_Hcheck_fm, lam_replacement_check_fm }" lemmas replacement_instances_ground_defs = wfrec_Hfrc_at_fm_def wfrec_Hcheck_fm_def lam_replacement_check_fm_def declare (in M_ZF_ground) replacement_instances_ground_defs [simp] lemma instances_ground_fms_type[TC]: "instances_ground_fms ⊆ formula" using Lambda_in_M_fm_type (*‹⟦?φ ∈ formula; ?len ∈ ω⟧ ⟹ Lambda_in_M_fm(?φ, ?len) ∈ formula›*) unfolding instances_ground_fms_def replacement_instances_ground_defs (*goal: ‹{(⋅∃⋅⋅⟨1,0⟩ is 2 ⋅ ∧ is_wfrec_fm(Hfrc_at_fm(8, 9, 2, 1, 0), 5, 1, 0)⋅⋅), (⋅∃⋅⋅⟨1,0⟩ is 2 ⋅ ∧ is_wfrec_fm(is_Hcheck_fm(8, 2, 1, 0), 4, 1, 0)⋅⋅), Lambda_in_M_fm(⋅2⇧v0 is 1⋅, 1)} ⊆ formula›*) by simp locale M_ZF_ground_notCH = M_ZF_ground + assumes ZF_ground_notCH_replacements: "replacement_assm(M,env,rec_constr_abs_fm)" "replacement_assm(M,env,rec_constr_fm)" definition instances_ground_notCH_fms where "instances_ground_notCH_fms ≡ { rec_constr_abs_fm, rec_constr_fm }" lemma instances_ground_notCH_fms_type[TC]: "instances_ground_notCH_fms ⊆ formula" unfolding instances_ground_notCH_fms_def rec_constr_abs_fm_def rec_constr_fm_def (*goal: ‹{transrec_apply_image_body_fm(3, 2, 0, 1), is_trans_apply_image_body_fm(3, 2, 0, 1)} ⊆ formula›*) by simp declare (in M_ZF_ground_notCH) rec_constr_abs_fm_def[simp] rec_constr_fm_def[simp] locale M_ZF_ground_notCH_trans = M_ZF_ground_trans + M_ZF_ground_notCH locale M_ZF_ground_CH = M_ZF_ground_notCH + assumes dcwit_replacement: "replacement_assm(M,env,dc_abs_fm)" declare (in M_ZF_ground_CH) dc_abs_fm_def [simp] locale M_ZF_ground_CH_trans = M_ZF_ground_notCH_trans + M_ZF_ground_CH locale M_ctm1 = M_ZF1_trans + M_ZF_ground_trans + fixes enum assumes M_countable: "enum∈bij(nat,M)" locale M_ctm1_AC = M_ctm1 + M_ZFC1_trans context M_ZF_ground_CH_trans begin lemma replacement_dcwit_repl_body: "(##M)(mesa) ⟹ (##M)(A) ⟹ (##M)(a) ⟹ (##M)(s) ⟹ (##M)(R) ⟹ strong_replacement(##M, dcwit_repl_body(##M,mesa,A,a,s,R))" using strong_replacement_rel_in_ctm[where φ = "dcwit_repl_body_fm(6,5,4,3,2,0,1)" and env = "[R,s,a,A,mesa]" and f = "dcwit_repl_body(##M,mesa,A,a,s,R)"] (*‹⟦dcwit_repl_body_fm(6, 5, 4, 3, 2, 0, 1) ∈ formula; arity(dcwit_repl_body_fm(6, 5, 4, 3, 2, 0, 1)) ≤ 2 +⇩ω length([R::i, s::i, a::i, A::i, mesa::i]); ⋀(x::i) y::i. ⟦x ∈ (M::i); y ∈ M⟧ ⟹ (M, [x, y] @ [R, s, a, A, mesa] ⊨ dcwit_repl_body_fm(6, 5, 4, 3, 2, 0, 1)) ⟷ dcwit_repl_body(##M, mesa, A, a, s, R, x, y); replacement_assm(M, [R, s, a, A, mesa], dcwit_repl_body_fm(6, 5, 4, 3, 2, 0, 1)); [R, s, a, A, mesa] ∈ list(M)⟧ ⟹ strong_replacement(##M, dcwit_repl_body(##M, mesa, A, a, s, R))›*) zero_in_M (*‹0 ∈ M›*) arity_dcwit_repl_body (*‹arity(dcwit_repl_body_fm(6, 5, 4, 3, 2, 0, 1)) = 7›*) dcwit_replacement (*‹replacement_assm(M, ?env, dc_abs_fm)›*) unfolding dc_abs_fm_def (*goal: ‹⟦(##(M::i))(mesa::i); (##M)(A::i); (##M)(a::i); (##M)(s::i); (##M)(R::i)⟧ ⟹ strong_replacement(##M, dcwit_repl_body(##M, mesa, A, a, s, R))›*) by simp lemma dcwit_repl: "(##M)(sa) ⟹ (##M)(esa) ⟹ (##M)(mesa) ⟹ (##M)(A) ⟹ (##M)(a) ⟹ (##M)(s) ⟹ (##M)(R) ⟹ strong_replacement ((##M), λx z. ∃y[(##M)]. pair((##M), x, y, z) ∧ is_wfrec ((##M), λn f. is_nat_case ((##M), a, λm bmfm. ∃fm[(##M)]. ∃cp[(##M)]. is_apply((##M), f, m, fm) ∧ is_Collect((##M), A, λx. ∃fmx[(##M)]. ((##M)(x) ∧ fmx ∈ R) ∧ pair((##M), fm, x, fmx), cp) ∧ is_apply((##M), s, cp, bmfm), n), mesa, x, y))" using replacement_dcwit_repl_body (*‹⟦(##(M::i))(?mesa::i); (##M)(?A::i); (##M)(?a::i); (##M)(?s::i); (##M)(?R::i)⟧ ⟹ strong_replacement(##M, dcwit_repl_body(##M, ?mesa, ?A, ?a, ?s, ?R))›*) unfolding dcwit_repl_body_def (*goal: ‹⟦(##M)(sa); (##M)(esa); (##M)(mesa); (##M)(A); (##M)(a); (##M)(s); (##M)(R)⟧ ⟹ strong_replacement(##M, λx z. ∃y[##M]. pair(##M, x, y, z) ∧ is_wfrec(##M, λn f. is_nat_case(##M, a, λm bmfm. ∃fm[##M]. ∃cp[##M]. is_apply(##M, f, m, fm) ∧ is_Collect(##M, A, λx. ∃fmx[##M]. ((##M)(x) ∧ fmx ∈ R) ∧ pair(##M, fm, x, fmx), cp) ∧ is_apply(##M, s, cp, bmfm), n), mesa, x, y))›*) by simp end ― ‹\<^locale>‹M_ZF_ground_CH_trans›› context M_ZF1_trans begin lemmas M_replacement_ZF_instances = lam_replacement_fst lam_replacement_snd lam_replacement_Union lam_replacement_Image lam_replacement_middle_del lam_replacement_prodRepl lemmas M_separation_ZF_instances = separation_fstsnd_in_sndsnd separation_sndfst_eq_fstsnd lemma separation_is_dcwit_body: assumes "(##M)(A)" "(##M)(a)" "(##M)(g)" "(##M)(R)" shows "separation(##M,is_dcwit_body(##M, A, a, g, R))" using assms (*‹(##M)(A)› ‹(##M)(a)› ‹(##(M::i))(g::i)› ‹(##M)(R)›*) separation_in_ctm[where env = "[A,a,g,R]" and φ = "is_dcwit_body_fm(1,2,3,4,0)", OF _ _ _ is_dcwit_body_iff_sats [ symmetric ], of "λ_.A" "λ_.a" "λ_.g" "λ_.R" "λx. x"] (*‹⟦is_dcwit_body_fm(1, 2, 3, 4, 0) ∈ formula; [A, a, g, R] ∈ list(M); arity(is_dcwit_body_fm(1, 2, 3, 4, 0)) ≤ 1 +⇩ω length([A, a, g, R]); ⋀x. x ∈ M ⟹ nth(1, [x] @ [A, a, g, R]) = A; ⋀x. x ∈ M ⟹ nth(2, [x] @ [A, a, g, R]) = a; ⋀x. x ∈ M ⟹ nth(3, [x] @ [A, a, g, R]) = g; ⋀x. x ∈ M ⟹ nth(4, [x] @ [A, a, g, R]) = R; ⋀x. x ∈ M ⟹ nth(0, [x] @ [A, a, g, R]) = x; ⋀x. x ∈ M ⟹ 1 ∈ ω; ⋀x. x ∈ M ⟹ 2 ∈ ω; ⋀x. x ∈ M ⟹ 3 ∈ ω; ⋀x. x ∈ M ⟹ 4 ∈ ω; ⋀x. x ∈ M ⟹ 0 ∈ ω; ⋀x. x ∈ M ⟹ [x] @ [A, a, g, R] ∈ list(M); ⋀x. x ∈ M ⟹ 0 ∈ M⟧ ⟹ separation(##M, λx. is_dcwit_body(##M, A, a, g, R, x))›*) nonempty (*‹(##M)(0)›*) arity_is_dcwit_body_fm (*‹⟦?A ∈ ω; ?a ∈ ω; ?g ∈ ω; ?R ∈ ω; ?p ∈ ω⟧ ⟹ arity(is_dcwit_body_fm(?A, ?a, ?g, ?R, ?p)) = succ(?a) ∪ (succ(?g) ∪ (succ(?A) ∪ succ(?R))) ∪ succ(?p)›*) is_dcwit_body_fm_type (*‹⟦(?A::i) ∈ ω; (?a::i) ∈ ω; (?g::i) ∈ ω; (?R::i) ∈ ω; (?p::i) ∈ ω⟧ ⟹ is_dcwit_body_fm(?A, ?a, ?g, ?R, ?p) ∈ formula›*) by (simp add:ord_simp_union (*‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*)) end ― ‹\<^locale>‹M_ZF1_trans›› sublocale M_ZF1_trans ⊆ M_replacement "##M" using M_replacement_ZF_instances (*‹lam_replacement(##(M::i), fst)› ‹lam_replacement(##M, snd)› ‹lam_replacement(##M, Union)› ‹lam_replacement(##M, λx. fst(x) `` snd(x))› ‹lam_replacement(##M, λr. middle_del(fst(r), snd(r)))› ‹lam_replacement(##M, λr. prodRepl(fst(r), snd(r)))›*) M_separation_ZF_instances (*‹separation(##(M::i), λx::i. fst(snd(x)) ∈ snd(snd(x)))› ‹separation(##(M::i), λx::i. snd(fst(x)) = fst(snd(x)))›*) apply unfold_locales (*goals: 1. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ lam_replacement(##M, fst)› 2. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ lam_replacement(##M, snd)› 3. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ lam_replacement(##M, Union)› 4. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ lam_replacement(##M, λr. middle_del(fst(r), snd(r)))› 5. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ lam_replacement(##M, λr. prodRepl(fst(r), snd(r)))› 6. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ lam_replacement(##M, λp. fst(p) `` snd(p))› 7. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ separation(##M, λx. snd(fst(x)) = fst(snd(x)))› 8. ‹⟦lam_replacement(##M, fst); lam_replacement(##M, snd); lam_replacement(##M, Union); lam_replacement(##M, λx. fst(x) `` snd(x)); lam_replacement(##M, λr. middle_del(fst(r), snd(r))); lam_replacement(##M, λr. prodRepl(fst(r), snd(r))); separation(##M, λx. fst(snd(x)) ∈ snd(snd(x))); separation(##M, λx. snd(fst(x)) = fst(snd(x)))⟧ ⟹ separation(##M, λy. fst(snd(y)) ∈ snd(snd(y)))› discuss goal 1*) apply simp (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) apply ((assumption)[1]) (*discuss goal 5*) apply ((assumption)[1]) (*discuss goal 6*) apply ((assumption)[1]) (*discuss goal 7*) apply ((assumption)[1]) (*discuss goal 8*) . (*proven 8 subgoals*) context M_ZF1_trans begin lemma separation_Pow_rel: "A∈M ⟹ separation(##M, λy. ∃x ∈ M . x∈A ∧ y = ⟨x, Pow⇗##M⇖(x)⟩)" using separation_assm_sats[of "is_Pow_fm(0,1)"] (*‹⟦is_Pow_fm(0, 1) ∈ formula; arity(is_Pow_fm(0, 1)) = 2; ⋀(env::i) (x::i) y::i. ⟦env ∈ list(M::i); x ∈ M; y ∈ M⟧ ⟹ (M, [x, y] @ env ⊨ is_Pow_fm(0, 1)) ⟷ (?is_f::i ⇒ i ⇒ o)(x, y); ⋀(x::i) y::i. ⟦x ∈ M; y ∈ M⟧ ⟹ ?is_f(x, y) ⟷ y = (?f::i ⇒ i)(x); ⋀x::i. x ∈ M ⟹ ?f(x) ∈ M; (?A::i) ∈ M⟧ ⟹ separation(##M, λy::i. ∃x::i∈M. x ∈ ?A ∧ y = ⟨x, ?f(x)⟩)›*) arity_is_Pow_fm (*‹⟦?A ∈ ω; ?z ∈ ω⟧ ⟹ arity(is_Pow_fm(?A, ?z)) = succ(?z) ∪ succ(?A)›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*) Pow_rel_closed (*‹(##(M::i))(?r::i) ⟹ (##M)(Pow⇗M⇖(?r))›*) nonempty (*‹(##M)(0)›*) Pow_rel_iff (*‹⟦(##M)(?r); (##M)(?d)⟧ ⟹ is_Pow(##M, ?r, ?d) ⟷ ?d = Pow⇗M⇖(?r)›*) by simp lemma strong_replacement_Powapply_rel: "f∈M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(f,x))" using Powapply_rel_replacement (*‹⟦∀A[##M]. separation(##M, λy. ∃x[##M]. x ∈ A ∧ y = ⟨x, Pow⇗M⇖(x)⟩); (##M)(?f)⟧ ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(?f,x))›*) separation_Pow_rel (*‹(?A::i) ∈ (M::i) ⟹ separation(##M, λy::i. ∃x::i∈M. x ∈ ?A ∧ y = ⟨x, Pow⇗M⇖(x)⟩)›*) transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) by simp end ― ‹\<^locale>‹M_ZF1_trans›› sublocale M_ZF1_trans ⊆ M_Vfrom "##M" using power_ax (*‹power_ax(##M)›*) strong_replacement_Powapply_rel (*‹?f ∈ M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(?f,x))›*) phrank_repl (*‹(##M)(?f) ⟹ strong_replacement(##M, λx y. y = succ(?f ` x))›*) trans_repl_HVFrom (*‹⟦?A ∈ M; ?i ∈ M⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, ?A), ?i)›*) wfrec_rank (*‹?X ∈ M ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(?X))›*) apply unfold_locales (*goals: 1. ‹⋀f. ⟦power_ax(##M); ⋀f. f ∈ M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(f,x)); ⋀f. (##M)(f) ⟹ strong_replacement(##M, λx y. y = succ(f ` x)); ⋀A i. ⟦A ∈ M; i ∈ M⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i); ⋀X. X ∈ M ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(X)); (##M)(f)⟧ ⟹ strong_replacement(##M, λy z. z = Powapply⇗##M⇖(f,y))› 2. ‹⋀A i. ⟦power_ax(##M); ⋀f. f ∈ M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(f,x)); ⋀f. (##M)(f) ⟹ strong_replacement(##M, λx y. y = succ(f ` x)); ⋀A i. ⟦A ∈ M; i ∈ M⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i); ⋀X. X ∈ M ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(X)); (##M)(A); (##M)(i)⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i)› 3. ‹⋀f. ⟦power_ax(##M); ⋀f. f ∈ M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(f,x)); ⋀f. (##M)(f) ⟹ strong_replacement(##M, λx y. y = succ(f ` x)); ⋀A i. ⟦A ∈ M; i ∈ M⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i); ⋀X. X ∈ M ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(X)); (##M)(f)⟧ ⟹ strong_replacement(##M, λx y. y = succ(f ` x))› 4. ‹⋀x. ⟦power_ax(##M); ⋀f. f ∈ M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(f,x)); ⋀f. (##M)(f) ⟹ strong_replacement(##M, λx y. y = succ(f ` x)); ⋀A i. ⟦A ∈ M; i ∈ M⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i); ⋀X. X ∈ M ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(X)); (##M)(x)⟧ ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(x))› 5. ‹⋀i A. ⟦power_ax(##M); ⋀f. f ∈ M ⟹ strong_replacement(##M, λx y. y = Powapply⇗##M⇖(f,x)); ⋀f. (##M)(f) ⟹ strong_replacement(##M, λx y. y = succ(f ` x)); ⋀A i. ⟦A ∈ M; i ∈ M⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i); ⋀X. X ∈ M ⟹ wfrec_replacement(##M, is_Hrank(##M), rrank(X)); (##M)(i); (##M)(A)⟧ ⟹ transrec_replacement(##M, is_HVfrom(##M, A), i)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . sublocale M_ZF1_trans ⊆ M_Perm "##M" using separation_PiP_rel (*‹(##M)(?A) ⟹ separation(##M, PiP_rel(##M, ?A))›*) separation_injP_rel (*‹(##M)(?A) ⟹ separation(##M, injP_rel(##M, ?A))›*) separation_surjP_rel (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ separation(##M, surjP_rel(##M, ?A, ?B))›*) lam_replacement_imp_strong_replacement[OF lam_replacement_Sigfun [ OF lam_replacement_constant ]] (*‹⟦(##M)(?f3); ∀y[##M]. (##M)(?f3)⟧ ⟹ strong_replacement(##M, λx y. y = Sigfun(x, λ_. ?f3))›*) Pi_replacement1 (*‹⟦(##(M::i))(?x::i); (##M)(?y::i)⟧ ⟹ strong_replacement(##M, λ(ya::i) z::i. ya ∈ ?y ∧ z = {⟨?x, ya⟩})›*) unfolding Sigfun_def (*goal: ‹M_Perm(##M)›*) apply unfold_locales (*goals: 1. ‹⋀A. ⟦⋀A. (##M)(A) ⟹ separation(##M, PiP_rel(##M, A)); ⋀A. (##M)(A) ⟹ separation(##M, injP_rel(##M, A)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ separation(##M, surjP_rel(##M, A, B)); ⋀f. ⟦(##M)(f); ∀y[##M]. (##M)(f)⟧ ⟹ strong_replacement(##M, λx y. y = (⋃y∈f. {⟨x, y⟩})); ⋀x y. ⟦(##M)(x); (##M)(y)⟧ ⟹ strong_replacement(##M, λya z. ya ∈ y ∧ z = {⟨x, ya⟩}); (##M)(A)⟧ ⟹ separation(##M, PiP_rel(##M, A))› 2. ‹⋀x y. ⟦⋀A. (##M)(A) ⟹ separation(##M, PiP_rel(##M, A)); ⋀A. (##M)(A) ⟹ separation(##M, injP_rel(##M, A)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ separation(##M, surjP_rel(##M, A, B)); ⋀f. ⟦(##M)(f); ∀y[##M]. (##M)(f)⟧ ⟹ strong_replacement(##M, λx y. y = (⋃y∈f. {⟨x, y⟩})); ⋀x y. ⟦(##M)(x); (##M)(y)⟧ ⟹ strong_replacement(##M, λya z. ya ∈ y ∧ z = {⟨x, ya⟩}); (##M)(x); (##M)(y)⟧ ⟹ strong_replacement(##M, λya z. ya ∈ y ∧ z = {⟨x, ya⟩})› 3. ‹⋀y. ⟦⋀A. (##M)(A) ⟹ separation(##M, PiP_rel(##M, A)); ⋀A. (##M)(A) ⟹ separation(##M, injP_rel(##M, A)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ separation(##M, surjP_rel(##M, A, B)); ⋀f. ⟦(##M)(f); ∀y[##M]. (##M)(f)⟧ ⟹ strong_replacement(##M, λx y. y = (⋃y∈f. {⟨x, y⟩})); ⋀x y. ⟦(##M)(x); (##M)(y)⟧ ⟹ strong_replacement(##M, λya z. ya ∈ y ∧ z = {⟨x, ya⟩}); (##M)(y)⟧ ⟹ strong_replacement(##M, λx z. z = (⋃xa∈y. {⟨x, xa⟩}))› 4. ‹⋀r. ⟦⋀A. (##M)(A) ⟹ separation(##M, PiP_rel(##M, A)); ⋀A. (##M)(A) ⟹ separation(##M, injP_rel(##M, A)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ separation(##M, surjP_rel(##M, A, B)); ⋀f. ⟦(##M)(f); ∀y[##M]. (##M)(f)⟧ ⟹ strong_replacement(##M, λx y. y = (⋃y∈f. {⟨x, y⟩})); ⋀x y. ⟦(##M)(x); (##M)(y)⟧ ⟹ strong_replacement(##M, λya z. ya ∈ y ∧ z = {⟨x, ya⟩}); (##M)(r)⟧ ⟹ separation(##M, injP_rel(##M, r))› 5. ‹⋀A B. ⟦⋀A. (##M)(A) ⟹ separation(##M, PiP_rel(##M, A)); ⋀A. (##M)(A) ⟹ separation(##M, injP_rel(##M, A)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ separation(##M, surjP_rel(##M, A, B)); ⋀f. ⟦(##M)(f); ∀y[##M]. (##M)(f)⟧ ⟹ strong_replacement(##M, λx y. y = (⋃y∈f. {⟨x, y⟩})); ⋀x y. ⟦(##M)(x); (##M)(y)⟧ ⟹ strong_replacement(##M, λya z. ya ∈ y ∧ z = {⟨x, ya⟩}); (##M)(A); (##M)(B)⟧ ⟹ separation(##M, λx. surjP_rel(##M, A, B, x))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . sublocale M_ZF1_trans ⊆ M_pre_seqspace "##M" by unfold_locales context M_ZF1_trans begin lemma separation_inj_rel: "A∈M ⟹ separation(##M, λy. ∃x∈M. x ∈ A ∧ y = ⟨x, inj_rel(##M,fst(x), snd(x))⟩)" using arity_is_inj_fm (*‹⟦?A ∈ ω; ?B ∈ ω; ?I ∈ ω⟧ ⟹ arity(⋅inj(?A,?B) is ?I⋅) = succ(?A) ∪ succ(?B) ∪ succ(?I)›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) nonempty (*‹(##M)(0)›*) inj_rel_closed[simplified] (*‹⟦?x ∈ M; ?y ∈ M⟧ ⟹ inj⇗M⇖(?x,?y) ∈ M›*) inj_rel_iff[simplified] (*‹⟦(?x::i) ∈ (M::i); (?y::i) ∈ M; (?d::i) ∈ M⟧ ⟹ is_inj(##M, ?x, ?y, ?d) ⟷ ?d = inj⇗M⇖(?x,?y)›*) apply (rule_tac separation_assm_bin_sats[of "is_inj_fm(0,1,2)"] (*‹⟦⋅inj(0,1) is 2⋅ ∈ formula; arity(⋅inj(0,1) is 2⋅) = 3; ⋀env x z y. ⟦env ∈ list(M); x ∈ M; z ∈ M; y ∈ M⟧ ⟹ (M, [x, z, y] @ env ⊨ ⋅inj(0,1) is 2⋅) ⟷ ?is_f(x, z, y); ⋀x z y. ⟦x ∈ M; z ∈ M; y ∈ M⟧ ⟹ ?is_f(x, z, y) ⟷ y = ?f(x, z); ⋀x z. ⟦x ∈ M; z ∈ M⟧ ⟹ ?f(x, z) ∈ M; ?A ∈ M⟧ ⟹ separation(##M, λy. ∃x∈M. x ∈ ?A ∧ y = ⟨x, ?f(fst(x), snd(x))⟩)›*)) (*goals: 1. ‹⟦A ∈ M; ⋀A B I. ⟦A ∈ ω; B ∈ ω; I ∈ ω⟧ ⟹ arity(⋅inj(A,B) is I⋅) = succ(A) ∪ succ(B) ∪ succ(I); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ i ∪ j = max(i, j); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ Ord(max(i, j)); ⋀x y. max(x, y) ≡ if x ≤ y then y else x; (##M)(0); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ inj⇗M⇖(x,y) ∈ M; ⋀x y d. ⟦x ∈ M; y ∈ M; d ∈ M⟧ ⟹ is_inj(##M, x, y, d) ⟷ d = inj⇗M⇖(x,y)⟧ ⟹ ⋅inj(0,1) is 2⋅ ∈ formula› 2. ‹⟦A ∈ M; ⋀A B I. ⟦A ∈ ω; B ∈ ω; I ∈ ω⟧ ⟹ arity(⋅inj(A,B) is I⋅) = succ(A) ∪ succ(B) ∪ succ(I); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ i ∪ j = max(i, j); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ Ord(max(i, j)); ⋀x y. max(x, y) ≡ if x ≤ y then y else x; (##M)(0); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ inj⇗M⇖(x,y) ∈ M; ⋀x y d. ⟦x ∈ M; y ∈ M; d ∈ M⟧ ⟹ is_inj(##M, x, y, d) ⟷ d = inj⇗M⇖(x,y)⟧ ⟹ arity(⋅inj(0,1) is 2⋅) = 3› 3. ‹⋀env x z y. ⟦A ∈ M; ⋀A B I. ⟦A ∈ ω; B ∈ ω; I ∈ ω⟧ ⟹ arity(⋅inj(A,B) is I⋅) = succ(A) ∪ succ(B) ∪ succ(I); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ i ∪ j = max(i, j); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ Ord(max(i, j)); ⋀x y. max(x, y) ≡ if x ≤ y then y else x; (##M)(0); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ inj⇗M⇖(x,y) ∈ M; ⋀x y d. ⟦x ∈ M; y ∈ M; d ∈ M⟧ ⟹ is_inj(##M, x, y, d) ⟷ d = inj⇗M⇖(x,y); env ∈ list(M); x ∈ M; z ∈ M; y ∈ M⟧ ⟹ (M, [x, z, y] @ env ⊨ ⋅inj(0,1) is 2⋅) ⟷ ?is_f14(x, z, y)› 4. ‹⋀x z y. ⟦A ∈ M; ⋀A B I. ⟦A ∈ ω; B ∈ ω; I ∈ ω⟧ ⟹ arity(⋅inj(A,B) is I⋅) = succ(A) ∪ succ(B) ∪ succ(I); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ i ∪ j = max(i, j); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ Ord(max(i, j)); ⋀x y. max(x, y) ≡ if x ≤ y then y else x; (##M)(0); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ inj⇗M⇖(x,y) ∈ M; ⋀x y d. ⟦x ∈ M; y ∈ M; d ∈ M⟧ ⟹ is_inj(##M, x, y, d) ⟷ d = inj⇗M⇖(x,y); x ∈ M; z ∈ M; y ∈ M⟧ ⟹ ?is_f14(x, z, y) ⟷ y = inj⇗M⇖(x,z)› 5. ‹⋀x z. ⟦A ∈ M; ⋀A B I. ⟦A ∈ ω; B ∈ ω; I ∈ ω⟧ ⟹ arity(⋅inj(A,B) is I⋅) = succ(A) ∪ succ(B) ∪ succ(I); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ i ∪ j = max(i, j); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ Ord(max(i, j)); ⋀x y. max(x, y) ≡ if x ≤ y then y else x; (##M)(0); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ inj⇗M⇖(x,y) ∈ M; ⋀x y d. ⟦x ∈ M; y ∈ M; d ∈ M⟧ ⟹ is_inj(##M, x, y, d) ⟷ d = inj⇗M⇖(x,y); x ∈ M; z ∈ M⟧ ⟹ inj⇗M⇖(x,z) ∈ M› 6. ‹⟦A ∈ M; ⋀A B I. ⟦A ∈ ω; B ∈ ω; I ∈ ω⟧ ⟹ arity(⋅inj(A,B) is I⋅) = succ(A) ∪ succ(B) ∪ succ(I); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ i ∪ j = max(i, j); ⋀i j. ⟦Ord(i); Ord(j)⟧ ⟹ Ord(max(i, j)); ⋀x y. max(x, y) ≡ if x ≤ y then y else x; (##M)(0); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ inj⇗M⇖(x,y) ∈ M; ⋀x y d. ⟦x ∈ M; y ∈ M; d ∈ M⟧ ⟹ is_inj(##M, x, y, d) ⟷ d = inj⇗M⇖(x,y)⟧ ⟹ A ∈ M› discuss goal 1*) apply (simp add:setclass_def (*‹##?A ≡ λx. x ∈ ?A›*)) (*discuss goal 2*) apply (simp add:setclass_def (*‹##(?A::i) ≡ λx::i. x ∈ ?A›*)) (*discuss goal 3*) apply (simp add:setclass_def (*‹##(?A::i) ≡ λx::i. x ∈ ?A›*)) (*discuss goal 4*) apply (simp add:setclass_def (*‹##?A ≡ λx. x ∈ ?A›*)) (*discuss goal 5*) apply (simp add:setclass_def (*‹##?A ≡ λx. x ∈ ?A›*)) (*discuss goal 6*) apply (simp add:setclass_def (*‹##?A ≡ λx. x ∈ ?A›*)) (*proven 6 subgoals*) . lemma lam_replacement_inj_rel: "lam_replacement(##M, λx . inj_rel(##M,fst(x),snd(x)))" using lam_replacement_inj_rel' (*‹∀A::i[##(M::i)]. separation(##M, λy::i. ∃x::i[##M]. x ∈ A ∧ y = ⟨x, inj⇗M⇖(fst(x),snd(x))⟩) ⟹ lam_replacement(##M, λr::i. inj⇗M⇖(fst(r),snd(r)))›*) separation_inj_rel (*‹?A ∈ M ⟹ separation(##M, λy. ∃x∈M. x ∈ ?A ∧ y = ⟨x, inj⇗M⇖(fst(x),snd(x))⟩)›*) by simp (* These lemmas were required for the original proof of Schröder-Bernstein. lemma banach_iterates: assumes "X∈M" "Y∈M" "f∈M" "g∈M" "W∈M" shows "iterates_replacement(##M, is_banach_functor(##M,X,Y,f,g), W)" proof - have "strong_replacement(##M, λ x z . banach_body_iterates(##M,X,Y,f,g,W,n,x,z))" if "n∈ω" for n using assms that arity_banach_body_iterates_fm ord_simp_union nat_into_M strong_replacement_rel_in_ctm[where φ="banach_body_iterates_fm(7,6,5,4,3,2,0,1)" and env="[n,W,g,f,Y,X]"] replacement_ax2(3) by simp then show ?thesis using assms nat_into_M Memrel_closed unfolding iterates_replacement_def wfrec_replacement_def is_wfrec_def M_is_recfun_def is_nat_case_def iterates_MH_def banach_body_iterates_def by simp qed lemma separation_banach_functor_iterates: assumes "X∈M" "Y∈M" "f∈M" "g∈M" "A∈M" shows "separation(##M, λb. ∃x∈A. x ∈ ω ∧ b = banach_functor(X, Y, f, g)^x (0))" proof - have " (∃xa∈M. xa ∈ A ∧ xa ∈ ω ∧ banach_is_iterates_body(##M, X, Y, f, g, 0, xa, x)) ⟷ (∃n∈A. n ∈ ω ∧ banach_is_iterates_body(##M, X, Y, f, g, 0, n, x))" if "x∈M" for x using assms nat_into_M nat_in_M transM[of _ A] transM[of _ ω] that by auto then have "separation(##M, λ z . ∃n∈A . n∈ω ∧ banach_is_iterates_body(##M,X,Y,f,g,0,n,z))" using assms nat_into_M nat_in_M arity_banach_is_iterates_body_fm[of 6 5 4 3 2 0 1] ord_simp_union separation_in_ctm[where φ="(⋅∃ ⋅⋅0∈7⋅ ∧ ⋅⋅0∈8⋅ ∧ banach_is_iterates_body_fm(6,5,4,3,2,0,1) ⋅⋅⋅)" and env="[0,g,f,Y,X,A,ω]"] by (simp add:arity_Exists arity_And) moreover from assms have "(∃x∈A. x ∈ ω ∧ is_iterates(##M,is_banach_functor(##M,X, Y, f, g),0,x,z)) ⟷ (∃n∈A . n∈ω ∧ banach_is_iterates_body(##M,X,Y,f,g,0,n,z))" if "z∈M" for z using nat_in_M nat_into_M transM[of _ A] transM[of _ ω] unfolding is_iterates_def wfrec_replacement_def is_wfrec_def M_is_recfun_def is_nat_case_def iterates_MH_def banach_body_iterates_def banach_is_iterates_body_def by simp moreover from assms have "(∃x∈A. x ∈ ω ∧ is_iterates(##M,is_banach_functor(##M,X, Y, f, g),0,x,z)) ⟷ (∃x∈A. x ∈ ω ∧ z = banach_functor(X, Y, f, g)^x (0))" if "z∈M" for z using transM[of _ A] nat_in_M nat_into_M that iterates_abs[OF banach_iterates banach_functor_abs] banach_functor_closed by auto ultimately show ?thesis by(rule_tac separation_cong[THEN iffD2],auto) qed lemma banach_replacement: assumes "X∈M" "Y∈M" "f∈M" "g∈M" shows "strong_replacement(##M, λn y. n∈nat ∧ y = banach_functor(X, Y, f, g)^n (0))" using assms banach_repl_iter' separation_banach_functor_iterates by simp *) end ― ‹\<^locale>‹M_ZF1_trans›› lemma (in M_basic) rel2_trans_apply: "M(f) ⟹ relation2(M,is_trans_apply_image(M,f),trans_apply_image(f))" unfolding is_trans_apply_image_def trans_apply_image_def relation2_def (*goal: ‹M(f) ⟹ ∀x[M]. ∀y[M]. ∀z[M]. (∃b[M]. is_apply(M, f, b, z) ∧ image(M, y, x, b)) ⟷ z = f ` (y `` x)›*) by auto lemma (in M_basic) apply_image_closed: shows "M(f) ⟹ ∀x[M]. ∀g[M]. M(trans_apply_image(f, x, g))" unfolding trans_apply_image_def (*goal: ‹M(f) ⟹ ∀x[M]. ∀g[M]. M(f ` (g `` x))›*) by simp context M_ZF_ground_notCH_trans begin lemma replacement_transrec_apply_image_body : "(##M)(f) ⟹ (##M)(mesa) ⟹ strong_replacement(##M,transrec_apply_image_body(##M,f,mesa))" using strong_replacement_rel_in_ctm[where φ = "transrec_apply_image_body_fm(3,2,0,1)" and env = "[mesa,f]"] (*‹⟦transrec_apply_image_body_fm(3, 2, 0, 1) ∈ formula; arity(transrec_apply_image_body_fm(3, 2, 0, 1)) ≤ 2 +⇩ω length([mesa, f]); ⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ (M, [x, y] @ [mesa, f] ⊨ transrec_apply_image_body_fm(3, 2, 0, 1)) ⟷ ?f(x, y); replacement_assm(M, [mesa, f], transrec_apply_image_body_fm(3, 2, 0, 1)); [mesa, f] ∈ list(M)⟧ ⟹ strong_replacement(##M, ?f)›*) zero_in_M (*‹0 ∈ M›*) arity_transrec_apply_image_body_fm (*‹⟦(?f::i) ∈ ω; (?mesa::i) ∈ ω; (?x::i) ∈ ω; (?z::i) ∈ ω⟧ ⟹ arity(transrec_apply_image_body_fm(?f, ?mesa, ?x, ?z)) = succ(?x) ∪ succ(?z) ∪ (succ(?x) ∪ (succ(?mesa) ∪ (succ(?mesa) ∪ succ(?f))) ∪ (succ(?f) ∪ succ(?x)))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) ZF_ground_notCH_replacements(1) (*‹replacement_assm(M, ?env, rec_constr_abs_fm)›*) by simp lemma transrec_replacement_apply_image: assumes "(##M)(f)" "(##M)(α)" shows "transrec_replacement(##M, is_trans_apply_image(##M, f), α)" using replacement_transrec_apply_image_body[unfolded transrec_apply_image_body_def] (*‹⟦(##M)(?f); (##M)(?mesa)⟧ ⟹ strong_replacement(##M, λx z. ∃y[##M]. pair(##M, x, y, z) ∧ (∃fa[##M]. (∀z[##M]. z ∈ fa ⟷ (∃xa[##M]. ∃y[##M]. ∃xaa[##M]. ∃sx[##M]. ∃r_sx[##M]. ∃f_r_sx[##M]. pair(##M, xa, y, z) ∧ pair(##M, xa, x, xaa) ∧ upair(##M, xa, xa, sx) ∧ pre_image(##M, ?mesa, sx, r_sx) ∧ restriction(##M, fa, r_sx, f_r_sx) ∧ xaa ∈ ?mesa ∧ is_trans_apply_image(##M, ?f, xa, f_r_sx, y))) ∧ is_trans_apply_image(##M, ?f, x, fa, y)))›*) assms (*‹(##M)(f)› ‹(##(M::i))(α::i)›*) Memrel_closed (*‹(##M)(?A) ⟹ (##M)(Memrel(?A))›*) singleton_closed (*‹(##M)(?a) ⟹ (##M)({?a})›*) eclose_closed (*‹(##M)(?A) ⟹ (##M)(eclose(?A))›*) unfolding transrec_replacement_def wfrec_replacement_def is_wfrec_def M_is_recfun_def (*goal: ‹∃sa[##M]. ∃esa[##M]. ∃mesa[##M]. upair(##M, α, α, sa) ∧ is_eclose(##M, sa, esa) ∧ membership(##M, esa, mesa) ∧ strong_replacement(##M, λx z. ∃y[##M]. pair(##M, x, y, z) ∧ (∃fa[##M]. (∀z[##M]. z ∈ fa ⟷ (∃xa[##M]. ∃y[##M]. ∃xaa[##M]. ∃sx[##M]. ∃r_sx[##M]. ∃f_r_sx[##M]. pair(##M, xa, y, z) ∧ pair(##M, xa, x, xaa) ∧ upair(##M, xa, xa, sx) ∧ pre_image(##M, mesa, sx, r_sx) ∧ restriction(##M, fa, r_sx, f_r_sx) ∧ xaa ∈ mesa ∧ is_trans_apply_image(##M, f, xa, f_r_sx, y))) ∧ is_trans_apply_image(##M, f, x, fa, y)))›*) by simp lemma rec_trans_apply_image_abs: assumes "(##M)(f)" "(##M)(x)" "(##M)(y)" "Ord(x)" shows "is_transrec(##M,is_trans_apply_image(##M, f),x,y) ⟷ y = transrec(x,trans_apply_image(f))" using transrec_abs[OF transrec_replacement_apply_image rel2_trans_apply] (*‹⟦(##M)(?f1); (##M)(?i); (##M)(?f1); Ord(?i); (##M)(?i); (##M)(?z); ∀x[##M]. ∀g[##M]. function(g) ⟶ (##M)(trans_apply_image(?f1, x, g))⟧ ⟹ is_transrec(##M, is_trans_apply_image(##M, ?f1), ?i, ?z) ⟷ ?z = transrec(?i, trans_apply_image(?f1))›*) assms (*‹(##M)(f)› ‹(##M)(x)› ‹(##(M::i))(y::i)› ‹Ord(x)›*) apply_image_closed (*‹(##M)(?f) ⟹ ∀x[##M]. ∀g[##M]. (##M)(trans_apply_image(?f, x, g))›*) by simp lemma replacement_is_trans_apply_image: "(##M)(f) ⟹ (##M)(β) ⟹ strong_replacement(##M, λ x z . ∃y[##M]. pair(##M,x,y,z) ∧ x∈β ∧ (is_transrec(##M,is_trans_apply_image(##M, f),x,y)))" unfolding is_transrec_def is_wfrec_def M_is_recfun_def (*goal: ‹⟦(##M)(f); (##M)(β)⟧ ⟹ strong_replacement(##M, λx z. ∃y[##M]. pair(##M, x, y, z) ∧ x ∈ β ∧ (∃sa[##M]. ∃esa[##M]. ∃mesa[##M]. upair(##M, x, x, sa) ∧ is_eclose(##M, sa, esa) ∧ membership(##M, esa, mesa) ∧ (∃fa[##M]. (∀z[##M]. z ∈ fa ⟷ (∃xa[##M]. ∃y[##M]. ∃xaa[##M]. ∃sx[##M]. ∃r_sx[##M]. ∃f_r_sx[##M]. pair(##M, xa, y, z) ∧ pair(##M, xa, x, xaa) ∧ upair(##M, xa, xa, sx) ∧ pre_image(##M, mesa, sx, r_sx) ∧ restriction(##M, fa, r_sx, f_r_sx) ∧ xaa ∈ mesa ∧ is_trans_apply_image(##M, f, xa, f_r_sx, y))) ∧ is_trans_apply_image(##M, f, x, fa, y))))›*) apply (rule_tac strong_replacement_cong[ where P="λ x z. M,[x,z,β,f] ⊨ is_trans_apply_image_body_fm(3,2,0,1)",THEN iffD1] (*‹⟦⋀x y. ⟦?M1(x); ?M1(y)⟧ ⟹ (M, [x, y, β, f] ⊨ is_trans_apply_image_body_fm(3, 2, 0, 1)) ⟷ ?P'1(x, y); strong_replacement(?M1, λx y. M, [x, y, β, f] ⊨ is_trans_apply_image_body_fm(3, 2, 0, 1))⟧ ⟹ strong_replacement(?M1, λx y. ?P'1(x, y))›*)) (*goals: 1. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ (M, [x, z, β, f] ⊨ is_trans_apply_image_body_fm(3, 2, 0, 1)) ⟷ (∃y[##M]. pair(##M, x, y, z) ∧ x ∈ β ∧ (∃sa[##M]. ∃esa[##M]. ∃mesa[##M]. upair(##M, x, x, sa) ∧ is_eclose(##M, sa, esa) ∧ membership(##M, esa, mesa) ∧ (∃fa[##M]. (∀z[##M]. z ∈ fa ⟷ (∃xa[##M]. ∃y[##M]. ∃xaa[##M]. ∃sx[##M]. ∃r_sx[##M]. ∃f_r_sx[##M]. pair(##M, xa, y, z) ∧ pair(##M, xa, x, xaa) ∧ upair(##M, xa, xa, sx) ∧ pre_image(##M, mesa, sx, r_sx) ∧ restriction(##M, fa, r_sx, f_r_sx) ∧ xaa ∈ mesa ∧ is_trans_apply_image(##M, f, xa, f_r_sx, y))) ∧ is_trans_apply_image(##M, f, x, fa, y))))› 2. ‹⟦(##M)(f); (##M)(β)⟧ ⟹ strong_replacement(##M, λx z. M, [x, z, β, f] ⊨ is_trans_apply_image_body_fm(3, 2, 0, 1))› discuss goal 1*) apply (rule_tac is_trans_apply_image_body_iff_sats[symmetric,unfolded is_trans_apply_image_body_def,where env="[_,_,β,f]"] (*‹⟦nth(?f::i, [?uu4::i, ?uua4::i, β::i, f::i]) = (?fa::i); nth(?β::i, [?uu4, ?uua4, β, f]) = (?β'::i); nth(?a::i, [?uu4, ?uua4, β, f]) = (?aa::i); nth(?w::i, [?uu4, ?uua4, β, f]) = (?wa::i); ?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω; [?uu4, ?uua4, β, f] ∈ list(?A::i); 0 ∈ ?A⟧ ⟹ (?A, [?uu4, ?uua4, β, f] ⊨ is_trans_apply_image_body_fm(?f, ?β, ?a, ?w)) ⟷ (∃z::i[##?A]. pair(##?A, ?aa, z, ?wa) ∧ ?aa ∈ ?β' ∧ (∃sa::i[##?A]. ∃esa::i[##?A]. ∃mesa::i[##?A]. upair(##?A, ?aa, ?aa, sa) ∧ is_eclose(##?A, sa, esa) ∧ membership(##?A, esa, mesa) ∧ (∃fa::i[##?A]. (∀z::i[##?A]. z ∈ fa ⟷ (∃x::i[##?A]. ∃y::i[##?A]. ∃xa::i[##?A]. ∃sx::i[##?A]. ∃r_sx::i[##?A]. ∃f_r_sx::i[##?A]. pair(##?A, x, y, z) ∧ pair(##?A, x, ?aa, xa) ∧ upair(##?A, x, x, sx) ∧ pre_image(##?A, mesa, sx, r_sx) ∧ restriction(##?A, fa, r_sx, f_r_sx) ∧ xa ∈ mesa ∧ is_trans_apply_image(##?A, ?fa, x, f_r_sx, y))) ∧ is_trans_apply_image(##?A, ?fa, ?aa, fa, z))))›*)) (*goals: 1. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ nth(3, [x, z, β, f]) = f› 2. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ nth(2, [x, z, β, f]) = β› 3. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ nth(0, [x, z, β, f]) = x› 4. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ nth(1, [x, z, β, f]) = z› 5. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ 3 ∈ ω› 6. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ 2 ∈ ω› 7. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ 0 ∈ ω› 8. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ 1 ∈ ω› 9. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ [x, z, β, f] ∈ list(M)› 10. ‹⋀x z. ⟦(##M)(f); (##M)(β); (##M)(x); (##M)(z)⟧ ⟹ 0 ∈ M› discuss goal 1*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 2*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 3*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 4*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 5*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 6*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 7*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 8*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 9*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*discuss goal 10*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*proven 10 subgoals*) (*discuss goal 2*) apply (simp add:zero_in_M (*‹0 ∈ M›*)) (*goal: ‹⟦(##M)(f); (##M)(β)⟧ ⟹ strong_replacement(##M, λx z. M, [x, z, β, f] ⊨ is_trans_apply_image_body_fm(3, 2, 0, 1))›*) apply (rule_tac ZF_ground_notCH_replacements(2)[unfolded replacement_assm_def, rule_format, where env="[β,f]",simplified] (*‹⟦is_trans_apply_image_body_fm(3, 2, 0, 1) ∈ formula; β ∈ M ∧ f ∈ M; arity(is_trans_apply_image_body_fm(3, 2, 0, 1)) ≤ 4⟧ ⟹ strong_replacement(##M, λx y. M, [x, y, β, f] ⊨ is_trans_apply_image_body_fm(3, 2, 0, 1))›*)) (*goals: 1. ‹⟦f ∈ M; β ∈ M⟧ ⟹ is_trans_apply_image_body_fm(3, 2, 0, 1) ∈ formula› 2. ‹⟦f ∈ M; β ∈ M⟧ ⟹ β ∈ M ∧ f ∈ M› 3. ‹⟦f ∈ M; β ∈ M⟧ ⟹ arity(is_trans_apply_image_body_fm(3, 2, 0, 1)) ≤ 4› discuss goal 1*) apply (simp add: arity_is_trans_apply_image_body_fm (*‹⟦?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω⟧ ⟹ arity(is_trans_apply_image_body_fm(?f, ?β, ?a, ?w)) = succ(?a) ∪ succ(?w) ∪ (succ(?a) ∪ succ(?β) ∪ (succ(?a) ∪ (succ(?a) ∪ succ(?f) ∪ (succ(?f) ∪ succ(?a)))))›*) is_trans_apply_image_body_fm_type (*‹⟦?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω⟧ ⟹ is_trans_apply_image_body_fm(?f, ?β, ?a, ?w) ∈ formula›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*)) (*discuss goal 2*) apply (simp add: arity_is_trans_apply_image_body_fm (*‹⟦?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω⟧ ⟹ arity(is_trans_apply_image_body_fm(?f, ?β, ?a, ?w)) = succ(?a) ∪ succ(?w) ∪ (succ(?a) ∪ succ(?β) ∪ (succ(?a) ∪ (succ(?a) ∪ succ(?f) ∪ (succ(?f) ∪ succ(?a)))))›*) is_trans_apply_image_body_fm_type (*‹⟦?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω⟧ ⟹ is_trans_apply_image_body_fm(?f, ?β, ?a, ?w) ∈ formula›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*)) (*discuss goal 3*) apply (simp add: arity_is_trans_apply_image_body_fm (*‹⟦?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω⟧ ⟹ arity(is_trans_apply_image_body_fm(?f, ?β, ?a, ?w)) = succ(?a) ∪ succ(?w) ∪ (succ(?a) ∪ succ(?β) ∪ (succ(?a) ∪ (succ(?a) ∪ succ(?f) ∪ (succ(?f) ∪ succ(?a)))))›*) is_trans_apply_image_body_fm_type (*‹⟦?f ∈ ω; ?β ∈ ω; ?a ∈ ω; ?w ∈ ω⟧ ⟹ is_trans_apply_image_body_fm(?f, ?β, ?a, ?w) ∈ formula›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma trans_apply_abs: "(##M)(f) ⟹ (##M)(β) ⟹ Ord(β) ⟹ (##M)(x) ⟹ (##M)(z) ⟹ (x∈β ∧ z = ⟨x, transrec(x, λa g. f ` (g `` a)) ⟩) ⟷ (∃y[##M]. pair(##M,x,y,z) ∧ x∈β ∧ (is_transrec(##M,is_trans_apply_image(##M, f),x,y)))" using rec_trans_apply_image_abs (*‹⟦(##M)(?f); (##M)(?x); (##M)(?y); Ord(?x)⟧ ⟹ is_transrec(##M, is_trans_apply_image(##M, ?f), ?x, ?y) ⟷ ?y = transrec(?x, trans_apply_image(?f))›*) Ord_in_Ord (*‹⟦Ord(?i); ?j ∈ ?i⟧ ⟹ Ord(?j)›*) transrec_closed[OF transrec_replacement_apply_image rel2_trans_apply, of f, simplified] (*‹⟦f ∈ M; ?i ∈ M; Ord(?i); ?i ∈ M; ∀x∈M. ∀g∈M. function(g) ⟶ trans_apply_image(f, x, g) ∈ M⟧ ⟹ transrec(?i, trans_apply_image(f)) ∈ M›*) apply_image_closed (*‹(##M)(?f) ⟹ ∀x[##M]. ∀g[##M]. (##M)(trans_apply_image(?f, x, g))›*) unfolding trans_apply_image_def (*goal: ‹⟦(##M)(f); (##M)(β); Ord(β); (##M)(x); (##M)(z)⟧ ⟹ x ∈ β ∧ z = ⟨x, transrec(x, λa g. f ` (g `` a))⟩ ⟷ (∃y[##M]. pair(##M, x, y, z) ∧ x ∈ β ∧ is_transrec(##M, is_trans_apply_image(##M, f), x, y))›*) by auto lemma replacement_trans_apply_image: "(##M)(f) ⟹ (##M)(β) ⟹ Ord(β) ⟹ strong_replacement(##M, λx y. x∈β ∧ y = ⟨x, transrec(x, λa g. f ` (g `` a))⟩)" using strong_replacement_cong[THEN iffD1, OF _ replacement_is_trans_apply_image, simplified] (*‹⟦⋀x y. ⟦x ∈ M; y ∈ M⟧ ⟹ (∃ya∈M. y = ⟨x, ya⟩ ∧ x ∈ ?β2 ∧ is_transrec(##M, is_trans_apply_image(##M, ?f2), x, ya)) ⟷ ?P'1(x, y); ?f2 ∈ M; ?β2 ∈ M⟧ ⟹ strong_replacement(##M, λx y. ?P'1(x, y))›*) trans_apply_abs (*‹⟦(##(M::i))(?f::i); (##M)(?β::i); Ord(?β); (##M)(?x::i); (##M)(?z::i)⟧ ⟹ ?x ∈ ?β ∧ ?z = ⟨?x, transrec(?x, λ(a::i) g::i. ?f ` (g `` a))⟩ ⟷ (∃y::i[##M]. pair(##M, ?x, y, ?z) ∧ ?x ∈ ?β ∧ is_transrec(##M, is_trans_apply_image(##M, ?f), ?x, y))›*) Ord_in_Ord (*‹⟦Ord(?i); ?j ∈ ?i⟧ ⟹ Ord(?j)›*) by simp end ― ‹\<^locale>‹M_ZF_ground_notCH_trans›› definition ifrFb_body where "ifrFb_body(M,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then if M(converse(f) ` i) then converse(f) ` i else 0 else 0 else if M(i) then i else 0)" relativize functional "ifrFb_body" "ifrFb_body_rel" relationalize "ifrFb_body_rel" "is_ifrFb_body" synthesize "is_ifrFb_body" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body_fm" definition ifrangeF_body :: "[i⇒o,i,i,i,i] ⇒ o" where "ifrangeF_body(M,A,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body(M,b,f,x,i)⟩" relativize functional "ifrangeF_body" "ifrangeF_body_rel" relationalize "ifrangeF_body_rel" "is_ifrangeF_body" synthesize "is_ifrangeF_body" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body: "(##M)(A) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body(##M,A,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body_fm(1,2,3,0)" and env = "[A,r,s]"] (*‹⟦is_ifrangeF_body_fm(1, 2, 3, 0) ∈ formula; [A::i, r::i, s::i] ∈ list(M::i); arity(is_ifrangeF_body_fm(1, 2, 3, 0)) ≤ 1 +⇩ω length([A, r, s]); ⋀x::i. x ∈ M ⟹ (M, [x] @ [A, r, s] ⊨ is_ifrangeF_body_fm(1, 2, 3, 0)) ⟷ (?Q::i ⇒ o)(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ M›*) arity_is_ifrangeF_body_fm (*‹⟦?A ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body_fm(?A, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ succ(?f)))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body_fm_type (*‹⟦?A ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body_fm(?A, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) is_ifrFb_body_closed: "M(r) ⟹ M(s) ⟹ is_ifrFb_body(M, r, s, x, i) ⟹ M(i)" unfolding ifrangeF_body_def is_ifrangeF_body_def is_ifrFb_body_def If_abs (*goal: ‹⟦M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. (x::i) ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i::i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦(M::i ⇒ o)(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. (x::i) ∈ k ∧ k = (if empty(M, r) then h else j) ∧ j = (if M(i::i) then i else e) ∧ h = (if i ∈ a then g else e) ∧ g = (if M(d) then d else e) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body_abs: assumes "(##M)(A)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body(##M,A,r,s,x) ⟷ ifrangeF_body(##M,A,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body(##M, A, r, s, x) ⟷ ifrangeF_body(##M, A, r, s, x)›*) { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##M)(A)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body(##M, r, s, z, i))= (μ i. is_ifrFb_body(##M, r, s, z, i))" for z using is_ifrFb_body_closed[of r s z] (*‹⟦(##M)(r); (##M)(s); is_ifrFb_body(##M, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body(##M,r,s,z,i)"] (*‹(⋀y::i. y ∈ (M::i) ∧ is_ifrFb_body(##M, r::i, s::i, z::i, y) ⟷ (?Q::i ⇒ o)(y)) ⟹ (μ x::i. x ∈ M ∧ is_ifrFb_body(##M, r, s, z, x)) = (μ x::i. ?Q(x))›*)) (*goal: ‹(μ i::i. i ∈ (M::i) ∧ is_ifrFb_body(##M, r::i, s::i, z::i, i)) = (μ i::i. is_ifrFb_body(##M, r, s, z, i))›*) by auto moreover have "(μ i. is_ifrFb_body(##M, r, s, z, i))= (μ i. ifrFb_body(##M, r, s, z, i))" for z proof (rule_tac Least_cong[of "λi. is_ifrFb_body(##M,r,s,z,i)" "λi. ifrFb_body(##M,r,s,z,i)"] (*‹(⋀y. is_ifrFb_body(##M, r, s, z, y) ⟷ ifrFb_body(##M, r, s, z, y)) ⟹ (μ x. is_ifrFb_body(##M, r, s, z, x)) = (μ x. ifrFb_body(##M, r, s, z, x))›*)) (*goal: ‹⋀y. is_ifrFb_body(##M, r, s, z, y) ⟷ ifrFb_body(##M, r, s, z, y)›*) fix y from assms (*‹(##M)(A)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) ‹a∈M› (*‹a ∈ M›*) show "is_ifrFb_body(##M, r, s, z, y) ⟷ ifrFb_body(##M, r, s, z, y)" using If_abs (*‹is_If(##(M::i), ?b::o, ?t::i, ?f::i, ?r::i) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹?a ∉ domain(?f) ⟹ ?f ` ?a = 0›*) unfolding ifrFb_body_def is_ifrFb_body_def (*goal: ‹(∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)›*) apply ((cases "y∈M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(s); (##M)(x); (##M)(a); ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. ¬ (##domain(f))(a) ⟹ f ` a = 0; ¬ (##M)(y); ¬ (##range(s))(y); r = 0; (##0)(z)⟧ ⟹ ∃a∈M. ∃c∈M. ∃d∈M. ((##M)(d) ⟶ ((##a)(y) ⟶ (##d)(z) ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s)) ∧ (¬ (##a)(y) ⟶ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s))) ∧ (¬ (##M)(d) ⟶ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s))› 2. ‹⟦(##M)(A); (##M)(r); (##M)(s); (##M)(x); (##M)(a); ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. ¬ (##domain(f))(a) ⟹ f ` a = 0; ¬ (##M)(y); ¬ (##range(s))(y); r ≠ 0; (##0)(z)⟧ ⟹ ∃x∈M. is_apply(##M, converse(s), y, x)› discuss goal 1*) apply ((force simp only:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((force simp only:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*goal: ‹⟦(##(M::i))(A::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. (z::i) ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_If(##M, (##M)(y), y, e, j) ∧ is_If(##M, y ∈ a, g, e, h) ∧ is_If(##M, (##M)(d), d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then converse(s) ` y else 0 else 0 else if (##M)(y) then y else 0)›*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed moreover from ‹a∈M› (*‹(a::i) ∈ (M::i)›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body(##M, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body(##M, r, s, z,i))" for z using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body(##M,r,s,z,i)" a] (*‹⟦⋀x. (##M)(x) ∧ is_ifrFb_body(##M, r, s, z, x) ⟹ (##M)(x); (##M)(a)⟧ ⟹ least(##M, λi. (##M)(i) ∧ is_ifrFb_body(##M, r, s, z, i), a) ⟷ a = (μ x. (##M)(x) ∧ is_ifrFb_body(##M, r, s, z, x))›*) by simp ultimately have "least(##M, λi. i ∈ M ∧ is_ifrFb_body(##M, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body(##M, r, s, z,i))" for z by simp } with assms (*‹(##M)(A)› ‹(##M)(r)› ‹(##M)(s)› ‹(##(M::i))(x::i)›*) show "?thesis" (*goal: ‹is_ifrangeF_body(##M, A, r, s, x) ⟷ ifrangeF_body(##M, A, r, s, x)›*) using pair_in_M_iff (*‹(##(M::i))(⟨?a::i, ?b::i⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦(?y::i) ∈ (A::i); A ∈ (M::i)⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body_def is_ifrangeF_body_def (*goal: ‹(∃xa[##M]. ∃a[##M]. (xa ∈ A ∧ pair(##M, xa, a, x)) ∧ least(##M, λi. (##M)(i) ∧ is_ifrFb_body(##M, r, s, xa, i), a)) ⟷ (∃xa∈A. x = ⟨xa, Least(ifrFb_body(##M, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body: "(##M)(A) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation (##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λx. if (##M)(x) then x else 0, b, f, i)⟩)" using separation_is_ifrangeF_body (*‹⟦(##M)(?A); (##M)(?r); (##M)(?s)⟧ ⟹ separation(##M, is_ifrangeF_body(##M, ?A, ?r, ?s))›*) ifrangeF_body_abs (*‹⟦(##M)(?A); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body(##M, ?A, ?r, ?s, ?x) ⟷ ifrangeF_body(##M, ?A, ?r, ?s, ?x)›*) separation_cong[where P = "is_ifrangeF_body(##M,A,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x. (##M)(x) ⟹ is_ifrangeF_body(##M, A, b, f, x) ⟷ ?P'1(x); separation(##M, λx. is_ifrangeF_body(##M, A, b, f, x))⟧ ⟹ separation(##M, λx. ?P'1(x))›*) unfolding ifrangeF_body_def if_range_F_def if_range_F_else_F_def ifrFb_body_def (*goal: ‹⟦(##(M::i))(A::i); (##M)(b::i); (##M)(f::i)⟧ ⟹ separation(##M, λy::i. ∃x::i∈A. y = ⟨x, μ i::i. x ∈ (if b = 0 then if i ∈ range(f) then if (##M)(converse(f) ` i) then converse(f) ` i else 0 else 0 else if (##M)(i) then i else 0)⟩)›*) by simp (* (##M)(A) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λa. if (##M)(a) then G`a else 0, b, f, i)⟩) *) definition ifrFb_body2 where "ifrFb_body2(M,G,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then if M(converse(f) ` i) then G`(converse(f) ` i) else 0 else 0 else if M(i) then G`i else 0)" relativize functional "ifrFb_body2" "ifrFb_body2_rel" relationalize "ifrFb_body2_rel" "is_ifrFb_body2" synthesize "is_ifrFb_body2" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body2_fm" definition ifrangeF_body2 :: "[i⇒o,i,i,i,i,i] ⇒ o" where "ifrangeF_body2(M,A,G,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body2(M,G,b,f,x,i)⟩" relativize functional "ifrangeF_body2" "ifrangeF_body2_rel" relationalize "ifrangeF_body2_rel" "is_ifrangeF_body2" synthesize "is_ifrangeF_body2" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body2_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body2: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body2(##M,A,G,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body2_fm(1,2,3,4,0)" and env = "[A,G,r,s]"] (*‹⟦is_ifrangeF_body2_fm(1, 2, 3, 4, 0) ∈ formula; [A, G, r, s] ∈ list(M); arity(is_ifrangeF_body2_fm(1, 2, 3, 4, 0)) ≤ 1 +⇩ω length([A, G, r, s]); ⋀x. x ∈ M ⟹ (M, [x] @ [A, G, r, s] ⊨ is_ifrangeF_body2_fm(1, 2, 3, 4, 0)) ⟷ ?Q(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ M›*) arity_is_ifrangeF_body2_fm (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body2_fm(?A, ?G, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ (succ(?G) ∪ (succ(?G) ∪ succ(?f)))))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body2_fm_type (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body2_fm(?A, ?G, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) is_ifrFb_body2_closed: "M(G) ⟹ M(r) ⟹ M(s) ⟹ is_ifrFb_body2(M, G, r, s, x, i) ⟹ M(i)" unfolding ifrangeF_body2_def is_ifrangeF_body2_def is_ifrFb_body2_def If_abs (*goal: ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. ∃l::i[M]. ∃m::i[M]. (x::i) ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i::i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. ∃l::i[M]. ∃m::i[M]. (x::i) ∈ m ∧ m = (if empty(M, r) then j else l) ∧ l = (if M(i::i) then k else g) ∧ is_apply(M, G, i, k) ∧ j = (if i ∈ a then h else g) ∧ h = (if M(d) then e else g) ∧ empty(M, g) ∧ is_apply(M, G, d, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body2_abs: assumes "(##M)(A)" "(##M)(G)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body2(##M,A,G,r,s,x) ⟷ ifrangeF_body2(##M,A,G,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body2(##M, A, G, r, s, x) ⟷ ifrangeF_body2(##M, A, G, r, s, x)›*) { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##(M::i))(r::i)› ‹(##M)(s)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body2(##M, G, r, s, z, i))= (μ i. is_ifrFb_body2(##M, G, r, s, z, i))" for z using is_ifrFb_body2_closed[of G r s z] (*‹⟦(##M)(G); (##M)(r); (##M)(s); is_ifrFb_body2(##M, G, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body2(##M,G,r,s,z,i)"] (*‹(⋀y. y ∈ M ∧ is_ifrFb_body2(##M, G, r, s, z, y) ⟷ ?Q(y)) ⟹ (μ x. x ∈ M ∧ is_ifrFb_body2(##M, G, r, s, z, x)) = (μ x. ?Q(x))›*)) (*goal: ‹(μ i::i. i ∈ (M::i) ∧ is_ifrFb_body2(##M, G::i, r::i, s::i, z::i, i)) = (μ i::i. is_ifrFb_body2(##M, G, r, s, z, i))›*) by auto moreover have "(μ i. is_ifrFb_body2(##M, G, r, s, z, i))= (μ i. ifrFb_body2(##M, G, r, s, z, i))" for z proof (rule_tac Least_cong[of "λi. is_ifrFb_body2(##M,G,r,s,z,i)" "λi. ifrFb_body2(##M,G,r,s,z,i)"] (*‹(⋀y::i. is_ifrFb_body2(##(M::i), G::i, r::i, s::i, z::i, y) ⟷ ifrFb_body2(##M, G, r, s, z, y)) ⟹ (μ x::i. is_ifrFb_body2(##M, G, r, s, z, x)) = (μ x::i. ifrFb_body2(##M, G, r, s, z, x))›*)) (*goal: ‹⋀y. is_ifrFb_body2(##M, G, r, s, z, y) ⟷ ifrFb_body2(##M, G, r, s, z, y)›*) fix y from assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) ‹a∈M› (*‹(a::i) ∈ (M::i)›*) show "is_ifrFb_body2(##M, G, r, s, z, y) ⟷ ifrFb_body2(##M, G, r, s, z, y)" using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹(?a::i) ∉ domain(?f::i) ⟹ ?f ` ?a = 0›*) unfolding ifrFb_body2_def is_ifrFb_body2_def (*goal: ‹(∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)›*) apply ((cases "y∈M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∉ range(s)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. (z::i) ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(s); (##M)(x); (##M)(a); ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. ¬ (##domain(f))(a) ⟹ f ` a = 0; ¬ (##M)(y); ¬ (##range(s))(y); r = 0; (##0)(z)⟧ ⟹ ∃a∈M. ∃c∈M. ∃d∈M. ((##M)(d) ⟶ ((##a)(y) ⟶ (##G ` d)(z) ∧ (∃x∈M. is_apply(##M, G, y, x)) ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s)) ∧ (¬ (##a)(y) ⟶ (∃x∈M. is_apply(##M, G, y, x)) ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s))) ∧ (¬ (##M)(d) ⟶ (##M)(G ` d) ∧ (∃x∈M. is_apply(##M, G, y, x)) ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s))› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); (##M)(a); ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. ¬ (##domain(f))(a) ⟹ f ` a = 0; ¬ (##M)(y); ¬ (##range(s))(y); r ≠ 0; (##0)(z)⟧ ⟹ ∃a∈M. ∃c∈M. ∃d∈M. ((##M)(d) ⟶ (∃x∈M. is_apply(##M, G, y, x)) ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s)) ∧ (¬ (##M)(d) ⟶ (##M)(G ` d) ∧ (∃x∈M. is_apply(##M, G, y, x)) ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s))› discuss goal 1*) apply ((force simp only:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((force simp only:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), j, l, m) ∧ is_If(##M, (##M)(y), k, g, l) ∧ is_apply(##M, G, y, k) ∧ is_If(##M, y ∈ a, h, g, j) ∧ is_If(##M, (##M)(d), e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G ` (converse(s) ` y) else 0 else 0 else if (##M)(y) then G ` y else 0)›*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed moreover from ‹a∈M› (*‹a ∈ M›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body2(##M, G, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body2(##M, G, r, s, z,i))" for z using If_abs (*‹is_If(##(M::i), ?b::o, ?t::i, ?f::i, ?r::i) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body2(##M,G,r,s,z,i)" a] (*‹⟦⋀x. (##M)(x) ∧ is_ifrFb_body2(##M, G, r, s, z, x) ⟹ (##M)(x); (##M)(a)⟧ ⟹ least(##M, λi. (##M)(i) ∧ is_ifrFb_body2(##M, G, r, s, z, i), a) ⟷ a = (μ x. (##M)(x) ∧ is_ifrFb_body2(##M, G, r, s, z, x))›*) by simp ultimately have "least(##M, λi. i ∈ M ∧ is_ifrFb_body2(##M, G, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body2(##M, G, r, s, z,i))" for z by simp } with assms (*‹(##M)(A)› ‹(##(M::i))(G::i)› ‹(##M)(r)› ‹(##M)(s)› ‹(##(M::i))(x::i)›*) show "?thesis" (*goal: ‹is_ifrangeF_body2(##(M::i), A::i, G::i, r::i, s::i, x::i) ⟷ ifrangeF_body2(##M, A, G, r, s, x)›*) using pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦?y ∈ A; A ∈ M⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body2_def is_ifrangeF_body2_def (*goal: ‹(∃xa[##M]. ∃a[##M]. (xa ∈ A ∧ pair(##M, xa, a, x)) ∧ least(##M, λi. (##M)(i) ∧ is_ifrFb_body2(##M, G, r, s, xa, i), a)) ⟷ (∃xa∈A. x = ⟨xa, Least(ifrFb_body2(##M, G, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body2: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation (##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λa. if (##M)(a) then G ` a else 0, b, f, i)⟩)" using separation_is_ifrangeF_body2 (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s)⟧ ⟹ separation(##M, is_ifrangeF_body2(##M, ?A, ?G, ?r, ?s))›*) ifrangeF_body2_abs (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body2(##M, ?A, ?G, ?r, ?s, ?x) ⟷ ifrangeF_body2(##M, ?A, ?G, ?r, ?s, ?x)›*) separation_cong[where P = "is_ifrangeF_body2(##M,A,G,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x. (##M)(x) ⟹ is_ifrangeF_body2(##M, A, G, b, f, x) ⟷ ?P'1(x); separation(##M, λx. is_ifrangeF_body2(##M, A, G, b, f, x))⟧ ⟹ separation(##M, λx. ?P'1(x))›*) unfolding ifrangeF_body2_def if_range_F_def if_range_F_else_F_def ifrFb_body2_def (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(b); (##M)(f)⟧ ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ (if b = 0 then if i ∈ range(f) then if (##M)(converse(f) ` i) then G ` (converse(f) ` i) else 0 else 0 else if (##M)(i) then G ` i else 0)⟩)›*) by simp (* (##M)(A) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ (##M)(F) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λa. if (##M)(a) then F -`` {a} else 0, b, f, i)⟩) *) definition ifrFb_body3 where "ifrFb_body3(M,G,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then if M(converse(f) ` i) then G-``{converse(f) ` i} else 0 else 0 else if M(i) then G-``{i} else 0)" relativize functional "ifrFb_body3" "ifrFb_body3_rel" relationalize "ifrFb_body3_rel" "is_ifrFb_body3" synthesize "is_ifrFb_body3" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body3_fm" definition ifrangeF_body3 :: "[i⇒o,i,i,i,i,i] ⇒ o" where "ifrangeF_body3(M,A,G,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body3(M,G,b,f,x,i)⟩" relativize functional "ifrangeF_body3" "ifrangeF_body3_rel" relationalize "ifrangeF_body3_rel" "is_ifrangeF_body3" synthesize "is_ifrangeF_body3" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body3_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body3: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body3(##M,A,G,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body3_fm(1,2,3,4,0)" and env = "[A,G,r,s]"] (*‹⟦is_ifrangeF_body3_fm(1, 2, 3, 4, 0) ∈ formula; [A, G, r, s] ∈ list(M); arity(is_ifrangeF_body3_fm(1, 2, 3, 4, 0)) ≤ 1 +⇩ω length([A, G, r, s]); ⋀x. x ∈ M ⟹ (M, [x] @ [A, G, r, s] ⊨ is_ifrangeF_body3_fm(1, 2, 3, 4, 0)) ⟷ ?Q(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ M›*) arity_is_ifrangeF_body3_fm (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body3_fm(?A, ?G, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ (succ(?G) ∪ (succ(?G) ∪ succ(?f)))))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body3_fm_type (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body3_fm(?A, ?G, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) is_ifrFb_body3_closed: "M(G) ⟹ M(r) ⟹ M(s) ⟹ is_ifrFb_body3(M, G, r, s, x, i) ⟹ M(i)" unfolding ifrangeF_body3_def is_ifrangeF_body3_def is_ifrFb_body3_def If_abs (*goal: ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. ∃n[M]. ∃o[M]. x ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. ∃n[M]. ∃o[M]. x ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. ∃n[M]. ∃o[M]. x ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. ∃l::i[M]. ∃m::i[M]. ∃n::i[M]. ∃o::i[M]. (x::i) ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i::i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. ∃l::i[M]. ∃m::i[M]. ∃n::i[M]. ∃o::i[M]. (x::i) ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i::i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. ∃n[M]. ∃o[M]. x ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. ∃n[M]. ∃o[M]. x ∈ o ∧ o = (if empty(M, r) then k else n) ∧ n = (if M(i) then m else e) ∧ pre_image(M, G, l, m) ∧ is_cons(M, i, e, l) ∧ k = (if i ∈ a then j else e) ∧ j = (if M(d) then h else e) ∧ pre_image(M, G, g, h) ∧ is_cons(M, d, e, g) ∧ empty(M, e) ∧ is_apply(M, c, i, d) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body3_abs: assumes "(##M)(A)" "(##M)(G)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body3(##M,A,G,r,s,x) ⟷ ifrangeF_body3(##M,A,G,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body3(##M, A, G, r, s, x) ⟷ ifrangeF_body3(##M, A, G, r, s, x)›*) { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##(M::i))(A::i)› ‹(##(M::i))(G::i)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body3(##M, G, r, s, z, i))= (μ i. is_ifrFb_body3(##M, G, r, s, z, i))" for z using is_ifrFb_body3_closed[of G r s z] (*‹⟦(##M)(G); (##M)(r); (##M)(s); is_ifrFb_body3(##M, G, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body3(##M,G,r,s,z,i)"] (*‹(⋀y. y ∈ M ∧ is_ifrFb_body3(##M, G, r, s, z, y) ⟷ ?Q(y)) ⟹ (μ x. x ∈ M ∧ is_ifrFb_body3(##M, G, r, s, z, x)) = (μ x. ?Q(x))›*)) (*goal: ‹(μ i. i ∈ M ∧ is_ifrFb_body3(##M, G, r, s, z, i)) = (μ i. is_ifrFb_body3(##M, G, r, s, z, i))›*) by auto moreover have "(μ i. is_ifrFb_body3(##M, G, r, s, z, i))= (μ i. ifrFb_body3(##M, G, r, s, z, i))" for z proof (rule_tac Least_cong[of "λi. is_ifrFb_body3(##M,G,r,s,z,i)" "λi. ifrFb_body3(##M,G,r,s,z,i)"] (*‹(⋀y. is_ifrFb_body3(##M, G, r, s, z, y) ⟷ ifrFb_body3(##M, G, r, s, z, y)) ⟹ (μ x. is_ifrFb_body3(##M, G, r, s, z, x)) = (μ x. ifrFb_body3(##M, G, r, s, z, x))›*)) (*goal: ‹⋀y. is_ifrFb_body3(##M, G, r, s, z, y) ⟷ ifrFb_body3(##M, G, r, s, z, y)›*) fix y from assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) ‹a∈M› (*‹(a::i) ∈ (M::i)›*) show "is_ifrFb_body3(##M, G, r, s, z, y) ⟷ ifrFb_body3(##M, G, r, s, z, y)" using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹?a ∉ domain(?f) ⟹ ?f ` ?a = 0›*) unfolding ifrFb_body3_def is_ifrFb_body3_def (*goal: ‹(∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)›*) apply ((cases "y∈M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##(?A::i))(?x::i) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∈ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. ∃n::i[##M]. ∃o::i[##M]. (z::i) ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∈ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. ∃n::i[##M]. ∃o::i[##M]. (z::i) ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "converse(s)`y ∈ M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); converse(s) ` y ∈ M⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. ∃m::i[##M]. ∃n::i[##M]. ∃o::i[##M]. (z::i) ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*top goal: ‹⟦A ∈ M; G ∈ M; r ∈ M; s ∈ M; x ∈ M; a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); 0 ∈ M⟧ ⟹ (∃a∈M. ∃c∈M. ∃d∈M. {d} ∈ M ∧ G -`` {d} ∈ M ∧ (if y ∈ a then if d ∈ M then G -`` {d} else 0 else 0) ∈ M ∧ (if r = 0 then if y ∈ a then if d ∈ M then G -`` {d} else 0 else 0 else 0) ∈ M ∧ z ∈ (if r = 0 then if y ∈ a then if d ∈ M then G -`` {d} else 0 else 0 else 0) ∧ {y} ∈ M ∧ G -`` {y} ∈ M ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)› and 1 goal remains*) apply ((force simp only:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); converse(s) ` y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. ∃n[##M]. ∃o[##M]. z ∈ o ∧ is_If(##M, empty(##M, r), k, n, o) ∧ is_If(##M, (##M)(y), m, e, n) ∧ pre_image(##M, G, l, m) ∧ is_cons(##M, y, e, l) ∧ is_If(##M, y ∈ a, j, e, k) ∧ is_If(##M, (##M)(d), h, e, j) ∧ pre_image(##M, G, g, h) ∧ is_cons(##M, d, e, g) ∧ empty(##M, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then if (##M)(converse(s) ` y) then G -`` {converse(s) ` y} else 0 else 0 else if (##M)(y) then G -`` {y} else 0)›*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed moreover from ‹a∈M› (*‹(a::i) ∈ (M::i)›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body3(##M, G, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body3(##M, G, r, s, z,i))" for z using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body3(##M,G,r,s,z,i)" a] (*‹⟦⋀x::i. (##(M::i))(x) ∧ is_ifrFb_body3(##M, G::i, r::i, s::i, z::i, x) ⟹ (##M)(x); (##M)(a::i)⟧ ⟹ least(##M, λi::i. (##M)(i) ∧ is_ifrFb_body3(##M, G, r, s, z, i), a) ⟷ a = (μ x::i. (##M)(x) ∧ is_ifrFb_body3(##M, G, r, s, z, x))›*) by simp ultimately have "least(##M, λi. i ∈ M ∧ is_ifrFb_body3(##M, G, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body3(##M, G, r, s, z,i))" for z by simp } with assms (*‹(##M)(A)› ‹(##(M::i))(G::i)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) show "?thesis" (*goal: ‹is_ifrangeF_body3(##M, A, G, r, s, x) ⟷ ifrangeF_body3(##M, A, G, r, s, x)›*) using pair_in_M_iff (*‹(##(M::i))(⟨?a::i, ?b::i⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦?y ∈ A; A ∈ M⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body3_def is_ifrangeF_body3_def (*goal: ‹(∃xa[##M]. ∃a[##M]. (xa ∈ A ∧ pair(##M, xa, a, x)) ∧ least(##M, λi. (##M)(i) ∧ is_ifrFb_body3(##M, G, r, s, xa, i), a)) ⟷ (∃xa∈A. x = ⟨xa, Least(ifrFb_body3(##M, G, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body3: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation (##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λa. if (##M)(a) then G-``{a} else 0, b, f, i)⟩)" using separation_is_ifrangeF_body3 (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s)⟧ ⟹ separation(##M, is_ifrangeF_body3(##M, ?A, ?G, ?r, ?s))›*) ifrangeF_body3_abs (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body3(##M, ?A, ?G, ?r, ?s, ?x) ⟷ ifrangeF_body3(##M, ?A, ?G, ?r, ?s, ?x)›*) separation_cong[where P = "is_ifrangeF_body3(##M,A,G,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x. (##M)(x) ⟹ is_ifrangeF_body3(##M, A, G, b, f, x) ⟷ ?P'1(x); separation(##M, λx. is_ifrangeF_body3(##M, A, G, b, f, x))⟧ ⟹ separation(##M, λx. ?P'1(x))›*) unfolding ifrangeF_body3_def if_range_F_def if_range_F_else_F_def ifrFb_body3_def (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(b); (##M)(f)⟧ ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ (if b = 0 then if i ∈ range(f) then if (##M)(converse(f) ` i) then G -`` {converse(f) ` i} else 0 else 0 else if (##M)(i) then G -`` {i} else 0)⟩)›*) by simp (* (##M)(A) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ (##M)(A') ⟹ separation(##M, λy. ∃x∈A'. y = ⟨x, μ i. x ∈ if_range_F_else_F((`)(A), b, f, i)⟩) *) definition ifrFb_body4 where "ifrFb_body4(G,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then G`(converse(f) ` i) else 0 else G`i)" relativize functional "ifrFb_body4" "ifrFb_body4_rel" relationalize "ifrFb_body4_rel" "is_ifrFb_body4" synthesize "is_ifrFb_body4" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body4_fm" definition ifrangeF_body4 :: "[i⇒o,i,i,i,i,i] ⇒ o" where "ifrangeF_body4(M,A,G,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body4(G,b,f,x,i)⟩" relativize functional "ifrangeF_body4" "ifrangeF_body4_rel" relationalize "ifrangeF_body4_rel" "is_ifrangeF_body4" synthesize "is_ifrangeF_body4" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body4_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body4: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body4(##M,A,G,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body4_fm(1,2,3,4,0)" and env = "[A,G,r,s]"] (*‹⟦is_ifrangeF_body4_fm(1, 2, 3, 4, 0) ∈ formula; [A, G, r, s] ∈ list(M); arity(is_ifrangeF_body4_fm(1, 2, 3, 4, 0)) ≤ 1 +⇩ω length([A, G, r, s]); ⋀x. x ∈ M ⟹ (M, [x] @ [A, G, r, s] ⊨ is_ifrangeF_body4_fm(1, 2, 3, 4, 0)) ⟷ ?Q(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ M›*) arity_is_ifrangeF_body4_fm (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body4_fm(?A, ?G, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ (succ(?G) ∪ (succ(?G) ∪ succ(?f)))))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body4_fm_type (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body4_fm(?A, ?G, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) is_ifrFb_body4_closed: "M(G) ⟹ M(r) ⟹ M(s) ⟹ is_ifrFb_body4(M, G, r, s, x, i) ⟹ M(i)" using If_abs (*‹is_If(M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) unfolding ifrangeF_body4_def is_ifrangeF_body4_def is_ifrFb_body4_def fun_apply_def (*goal: ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, j)) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, d, d, xs) ∧ image(M, G, xs, fxs) ∧ big_union(M, fxs, e)) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body4_abs: assumes "(##M)(A)" "(##M)(G)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body4(##M,A,G,r,s,x) ⟷ ifrangeF_body4(##M,A,G,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body4(##M, A, G, r, s, x) ⟷ ifrangeF_body4(##M, A, G, r, s, x)›*) { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body4(##M, G, r, s, z, i))= (μ i. is_ifrFb_body4(##M, G, r, s, z, i))" for z using is_ifrFb_body4_closed[of G r s z] (*‹⟦(##M)(G); (##M)(r); (##M)(s); is_ifrFb_body4(##M, G, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body4(##M,G,r,s,z,i)"] (*‹(⋀y. y ∈ M ∧ is_ifrFb_body4(##M, G, r, s, z, y) ⟷ ?Q(y)) ⟹ (μ x. x ∈ M ∧ is_ifrFb_body4(##M, G, r, s, z, x)) = (μ x. ?Q(x))›*)) (*goal: ‹(μ i. i ∈ M ∧ is_ifrFb_body4(##M, G, r, s, z, i)) = (μ i. is_ifrFb_body4(##M, G, r, s, z, i))›*) by auto moreover have "(μ i. is_ifrFb_body4(##M, G, r, s, z, i))= (μ i. ifrFb_body4(G, r, s, z, i))" if "z∈M" for z proof (rule_tac Least_cong[of "λi. is_ifrFb_body4(##M,G,r,s,z,i)" "λi. ifrFb_body4(G,r,s,z,i)"] (*‹(⋀y. is_ifrFb_body4(##M, G, r, s, z, y) ⟷ ifrFb_body4(G, r, s, z, y)) ⟹ (μ x. is_ifrFb_body4(##M, G, r, s, z, x)) = (μ x. ifrFb_body4(G, r, s, z, x))›*)) (*goal: ‹⋀y. is_ifrFb_body4(##M, G, r, s, z, y) ⟷ ifrFb_body4(G, r, s, z, y)›*) fix y from assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##(M::i))(r::i)› ‹(##M)(s)› ‹(##M)(x)›*) ‹a∈M› (*‹a ∈ M›*) ‹z∈M› (*‹z ∈ M›*) show "is_ifrFb_body4(##M, G, r, s, z, y) ⟷ ifrFb_body4(G, r, s, z, y)" using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹?a ∉ domain(?f) ⟹ ?f ` ?a = 0›*) unfolding ifrFb_body4_def is_ifrFb_body4_def (*goal: ‹(∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)›*) apply ((cases "y∈M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); r = 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); r ≠ 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› and 4 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∈ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∈ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); r = 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); r ≠ 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∉ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∈ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∈ M; y ∉ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s); r = 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s); r ≠ 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∈ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); r = 0⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); r ≠ 0⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; y ∉ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*goal: ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; (y::i) ∉ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_apply(##M, G, y, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_apply(##M, G, d, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then G ` (converse(s) ` y) else 0 else G ` y)›*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed moreover from ‹a∈M› (*‹a ∈ M›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body4(##M, G, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body4(##M, G, r, s, z,i))" for z using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body4(##M,G,r,s,z,i)" a] (*‹⟦⋀x. (##M)(x) ∧ is_ifrFb_body4(##M, G, r, s, z, x) ⟹ (##M)(x); (##M)(a)⟧ ⟹ least(##M, λi. (##M)(i) ∧ is_ifrFb_body4(##M, G, r, s, z, i), a) ⟷ a = (μ x. (##M)(x) ∧ is_ifrFb_body4(##M, G, r, s, z, x))›*) by simp ultimately have "z∈M ⟹ least(##M, λi. i ∈ M ∧ is_ifrFb_body4(##M, G, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body4(G, r, s, z,i))" for z by simp } with assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) show "?thesis" (*goal: ‹is_ifrangeF_body4(##M, A, G, r, s, x) ⟷ ifrangeF_body4(##M, A, G, r, s, x)›*) using pair_in_M_iff (*‹(##(M::i))(⟨?a::i, ?b::i⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##(M::i))(?f::i); (##M)(?a::i)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦?y ∈ A; A ∈ M⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body4_def is_ifrangeF_body4_def (*goal: ‹(∃xa[##M]. ∃a[##M]. (xa ∈ A ∧ pair(##M, xa, a, x)) ∧ least(##M, λi. (##M)(i) ∧ is_ifrFb_body4(##M, G, r, s, xa, i), a)) ⟷ (∃xa∈A. x = ⟨xa, Least(ifrFb_body4(G, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body4: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F((`)(G), b, f, i)⟩)" using separation_is_ifrangeF_body4 (*‹⟦(##(M::i))(?A::i); (##M)(?G::i); (##M)(?r::i); (##M)(?s::i)⟧ ⟹ separation(##M, is_ifrangeF_body4(##M, ?A, ?G, ?r, ?s))›*) ifrangeF_body4_abs (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body4(##M, ?A, ?G, ?r, ?s, ?x) ⟷ ifrangeF_body4(##M, ?A, ?G, ?r, ?s, ?x)›*) separation_cong[where P = "is_ifrangeF_body4(##M,A,G,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x. (##M)(x) ⟹ is_ifrangeF_body4(##M, A, G, b, f, x) ⟷ ?P'1(x); separation(##M, λx. is_ifrangeF_body4(##M, A, G, b, f, x))⟧ ⟹ separation(##M, λx. ?P'1(x))›*) unfolding ifrangeF_body4_def if_range_F_def if_range_F_else_F_def ifrFb_body4_def (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(b); (##M)(f)⟧ ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ (if b = 0 then if i ∈ range(f) then G ` (converse(f) ` i) else 0 else G ` i)⟩)›*) by simp (* (##M)(G) ⟹ (##M)(A) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λx. {xa ∈ G . x ∈ xa}, b, f, i)⟩) *) definition ifrFb_body5 where "ifrFb_body5(G,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then {xa ∈ G . converse(f) ` i ∈ xa} else 0 else {xa ∈ G . i ∈ xa})" relativize functional "ifrFb_body5" "ifrFb_body5_rel" relationalize "ifrFb_body5_rel" "is_ifrFb_body5" synthesize "is_ifrFb_body5" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body5_fm" definition ifrangeF_body5 :: "[i⇒o,i,i,i,i,i] ⇒ o" where "ifrangeF_body5(M,A,G,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body5(G,b,f,x,i)⟩" relativize functional "ifrangeF_body5" "ifrangeF_body5_rel" relationalize "ifrangeF_body5_rel" "is_ifrangeF_body5" synthesize "is_ifrangeF_body5" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body5_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body5: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body5(##M,A,G,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body5_fm(1,2,3,4,0)" and env = "[A,G,r,s]"] (*‹⟦is_ifrangeF_body5_fm(1, 2, 3, 4, 0) ∈ formula; [A, G, r, s] ∈ list(M); arity(is_ifrangeF_body5_fm(1, 2, 3, 4, 0)) ≤ 1 +⇩ω length([A, G, r, s]); ⋀x. x ∈ M ⟹ (M, [x] @ [A, G, r, s] ⊨ is_ifrangeF_body5_fm(1, 2, 3, 4, 0)) ⟷ ?Q(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ M›*) arity_is_ifrangeF_body5_fm (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body5_fm(?A, ?G, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ (succ(?G) ∪ (succ(?G) ∪ succ(?f)))))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body5_fm_type (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body5_fm(?A, ?G, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) is_ifrFb_body5_closed: "M(G) ⟹ M(r) ⟹ M(s) ⟹ is_ifrFb_body5(M, G, r, s, x, i) ⟹ M(i)" using If_abs (*‹is_If(M::i ⇒ o, ?b::o, ?t::i, ?f::i, ?r::i) ⟷ ?r = (if ?b then ?t else ?f)›*) unfolding ifrangeF_body5_def is_ifrangeF_body5_def is_ifrFb_body5_def fun_apply_def (*goal: ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa. M(xa) ∧ i ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa. M(xa) ∧ d ∈ xa, e) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa. M(xa) ∧ i ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa. M(xa) ∧ d ∈ xa, e) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa. M(xa) ∧ i ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa. M(xa) ∧ d ∈ xa, e) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa. M(xa) ∧ i ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa. M(xa) ∧ d ∈ xa, e) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃c[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. x ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa. M(xa) ∧ i ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa. M(xa) ∧ d ∈ xa, e) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. (x::i) ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa::i. M(xa) ∧ (i::i) ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa::i. M(xa) ∧ d ∈ xa, e) ∧ (∃xs::i[M]. ∃fxs::i[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃c::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. (x::i) ∈ k ∧ is_If(M, empty(M, r), h, j, k) ∧ is_Collect(M, G, λxa::i. M(xa) ∧ (i::i) ∈ xa, j) ∧ is_If(M, i ∈ a, e, g, h) ∧ empty(M, g) ∧ is_Collect(M, G, λxa::i. M(xa) ∧ d ∈ xa, e) ∧ (∃xs::i[M]. ∃fxs::i[M]. upair(M, i, i, xs) ∧ image(M, c, xs, fxs) ∧ big_union(M, fxs, d)) ∧ is_converse(M, s, c) ∧ is_range(M, s, a); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body5_abs: assumes "(##M)(A)" "(##M)(G)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body5(##M,A,G,r,s,x) ⟷ ifrangeF_body5(##M,A,G,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body5(##M, A, G, r, s, x) ⟷ ifrangeF_body5(##M, A, G, r, s, x)›*) { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##M)(A)› ‹(##(M::i))(G::i)› ‹(##M)(r)› ‹(##(M::i))(s::i)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body5(##M, G, r, s, z, i))= (μ i. is_ifrFb_body5(##M, G, r, s, z, i))" for z using is_ifrFb_body5_closed[of G r s z] (*‹⟦(##M)(G); (##M)(r); (##M)(s); is_ifrFb_body5(##M, G, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body5(##M,G,r,s,z,i)"] (*‹(⋀y. y ∈ M ∧ is_ifrFb_body5(##M, G, r, s, z, y) ⟷ ?Q(y)) ⟹ (μ x. x ∈ M ∧ is_ifrFb_body5(##M, G, r, s, z, x)) = (μ x. ?Q(x))›*)) (*goal: ‹(μ i::i. i ∈ (M::i) ∧ is_ifrFb_body5(##M, G::i, r::i, s::i, z::i, i)) = (μ i::i. is_ifrFb_body5(##M, G, r, s, z, i))›*) by auto moreover have "(μ i. is_ifrFb_body5(##M, G, r, s, z, i))= (μ i. ifrFb_body5(G, r, s, z, i))" if "z∈M" for z proof (rule_tac Least_cong[of "λi. is_ifrFb_body5(##M,G,r,s,z,i)" "λi. ifrFb_body5(G,r,s,z,i)"] (*‹(⋀y. is_ifrFb_body5(##M, G, r, s, z, y) ⟷ ifrFb_body5(G, r, s, z, y)) ⟹ (μ x. is_ifrFb_body5(##M, G, r, s, z, x)) = (μ x. ifrFb_body5(G, r, s, z, x))›*)) (*goal: ‹⋀y. is_ifrFb_body5(##M, G, r, s, z, y) ⟷ ifrFb_body5(G, r, s, z, y)›*) fix y from assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##(M::i))(s::i)› ‹(##M)(x)›*) ‹a∈M› (*‹a ∈ M›*) ‹z∈M› (*‹z ∈ M›*) show "is_ifrFb_body5(##M, G, r, s, z, y) ⟷ ifrFb_body5(G, r, s, z, y)" using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹?a ∉ domain(?f) ⟹ ?f ` ?a = 0›*) separation_in_constant (*‹(##M)(?a) ⟹ separation(##M, λx. x ∈ ?a)›*) separation_in_rev (*‹(##M)(?a) ⟹ separation(##M, λx. ?a ∈ x)›*) unfolding ifrFb_body5_def is_ifrFb_body5_def (*goal: ‹(∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})›*) apply ((cases "y∈M")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∈ M; y ∈ range(s); r = 0⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∈ M; y ∈ range(s); r ≠ 0⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› and 4 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∈ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› and 3 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∈ M; y ∈ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r = 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r ≠ 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› and 2 goals remain*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*top goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∈ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› and 1 goal remains*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈range(s)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∈ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∈ range(s); r = 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∈ range(s); r ≠ 0⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∉ M; y ∈ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∉ M; y ∈ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∈ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∈ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∉ M; y ∉ range(s); r = 0⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› 2. ‹⟦(##(M::i))(A::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (a::i) ∈ M; (z::i) ∈ M; ⋀(b::o) (t::i) (f::i) r::i. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀(a::i) f::i. a ∉ domain(f) ⟹ f ` a = 0; ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. x ∈ a); ⋀a::i. (##M)(a) ⟹ separation(##M, λx::i. a ∈ x); (y::i) ∉ M; y ∉ range(s); r ≠ 0⟧ ⟹ (∃a::i[##M]. ∃c::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa::i. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa::i ∈ G . converse(s) ` y ∈ xa} else 0 else {xa::i ∈ G . y ∈ xa})› discuss goal 1*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s); r = 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s); r = 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (##(M::i))(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹(?P::i ⇒ o)(if (?Q::o) then ?x::i else ?y::i) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P::o ⟹ ?Q::o; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "y∈domain(G)")[1]) (*goals: 1. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s); r ≠ 0; y ∈ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› 2. ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*) split del: split_if (*‹?P(if ?Q then ?x else ?y) ⟷ (?Q ⟶ ?P(?x)) ∧ (¬ ?Q ⟶ ?P(?y))›*) del:iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*))[1]) (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(r); (##M)(s); (##M)(x); a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. (##M)(a) ⟹ separation(##M, λx. x ∈ a); ⋀a. (##M)(a) ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ (∃a[##M]. ∃c[##M]. ∃d[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. z ∈ k ∧ is_If(##M, empty(##M, r), h, j, k) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ y ∈ xa, j) ∧ is_If(##M, y ∈ a, e, g, h) ∧ empty(##M, g) ∧ is_Collect(##M, G, λxa. (##M)(xa) ∧ d ∈ xa, e) ∧ is_apply(##M, c, y, d) ∧ is_converse(##M, s, c) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {xa ∈ G . converse(s) ` y ∈ xa} else 0 else {xa ∈ G . y ∈ xa})›*) apply ((auto simp flip:setclass_iff (*‹(##?A)(?x) ⟷ ?x ∈ ?A›*) simp: fun_apply_def (*‹is_apply(?M, ?f, ?x, ?y) ≡ ∃xs[?M]. ∃fxs[?M]. upair(?M, ?x, ?x, xs) ∧ image(?M, ?f, xs, fxs) ∧ big_union(?M, fxs, ?y)›*))[1]) (*goal: ‹⟦A ∈ M; G ∈ M; r ∈ M; s ∈ M; x ∈ M; a ∈ M; z ∈ M; ⋀b t f r. is_If(##M, b, t, f, r) ⟷ r = (if b then t else f); ⋀a f. a ∉ domain(f) ⟹ f ` a = 0; ⋀a. a ∈ M ⟹ separation(##M, λx. x ∈ a); ⋀a. a ∈ M ⟹ separation(##M, λx. a ∈ x); y ∉ M; y ∉ range(s); r ≠ 0; y ∉ domain(G)⟧ ⟹ {xa ∈ G . xa ∈ M ∧ y ∈ xa} ∈ M ∧ z ∈ G ∧ y ∈ z ∧ 0 ∈ M ∧ (∃a∈M. ∃c∈M. ∃d∈M. {xa ∈ G . xa ∈ M ∧ d ∈ xa} ∈ M ∧ (if y ∈ a then {xa ∈ G . xa ∈ M ∧ d ∈ xa} else 0) ∈ M ∧ is_apply(##M, c, y, d) ∧ c = converse(s) ∧ a = range(s)) ⟷ z ∈ G ∧ y ∈ z›*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed moreover from ‹a∈M› (*‹a ∈ M›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body5(##M, G, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body5(##M, G, r, s, z,i))" for z using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body5(##M,G,r,s,z,i)" a] (*‹⟦⋀x::i. (##(M::i))(x) ∧ is_ifrFb_body5(##M, G::i, r::i, s::i, z::i, x) ⟹ (##M)(x); (##M)(a::i)⟧ ⟹ least(##M, λi::i. (##M)(i) ∧ is_ifrFb_body5(##M, G, r, s, z, i), a) ⟷ a = (μ x::i. (##M)(x) ∧ is_ifrFb_body5(##M, G, r, s, z, x))›*) by simp ultimately have "z∈M ⟹ least(##M, λi. i ∈ M ∧ is_ifrFb_body5(##M, G, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body5(G, r, s, z,i))" for z by simp } with assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) show "?thesis" (*goal: ‹is_ifrangeF_body5(##M, A, G, r, s, x) ⟷ ifrangeF_body5(##M, A, G, r, s, x)›*) using pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦?y ∈ A; A ∈ M⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body5_def is_ifrangeF_body5_def (*goal: ‹(∃xa[##M]. ∃a[##M]. (xa ∈ A ∧ pair(##M, xa, a, x)) ∧ least(##M, λi. (##M)(i) ∧ is_ifrFb_body5(##M, G, r, s, xa, i), a)) ⟷ (∃xa∈A. x = ⟨xa, Least(ifrFb_body5(G, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body5: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λx. {xa ∈ G . x ∈ xa}, b, f, i)⟩)" using separation_is_ifrangeF_body5 (*‹⟦(##(M::i))(?A::i); (##M)(?G::i); (##M)(?r::i); (##M)(?s::i)⟧ ⟹ separation(##M, is_ifrangeF_body5(##M, ?A, ?G, ?r, ?s))›*) ifrangeF_body5_abs (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body5(##M, ?A, ?G, ?r, ?s, ?x) ⟷ ifrangeF_body5(##M, ?A, ?G, ?r, ?s, ?x)›*) separation_cong[where P = "is_ifrangeF_body5(##M,A,G,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x. (##M)(x) ⟹ is_ifrangeF_body5(##M, A, G, b, f, x) ⟷ ?P'1(x); separation(##M, λx. is_ifrangeF_body5(##M, A, G, b, f, x))⟧ ⟹ separation(##M, λx. ?P'1(x))›*) unfolding ifrangeF_body5_def if_range_F_def if_range_F_else_F_def ifrFb_body5_def (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(b); (##M)(f)⟧ ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ (if b = 0 then if i ∈ range(f) then Collect(G, (∈)(converse(f) ` i)) else 0 else Collect(G, (∈)(i)))⟩)›*) by simp (* (##M)(A) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation(##M, λy. ∃x∈A'. y = ⟨x, μ i. x ∈ if_range_F_else_F(λa. {p ∈ A . domain(p) = a}, b, f, i)⟩) *) definition ifrFb_body6 where "ifrFb_body6(G,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then {p∈G . domain(p) = converse(f) ` i} else 0 else {p∈G . domain(p) = i})" relativize functional "ifrFb_body6" "ifrFb_body6_rel" relationalize "ifrFb_body6_rel" "is_ifrFb_body6" synthesize "is_ifrFb_body6" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body6_fm" definition ifrangeF_body6 :: "[i⇒o,i,i,i,i,i] ⇒ o" where "ifrangeF_body6(M,A,G,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body6(G,b,f,x,i)⟩" relativize functional "ifrangeF_body6" "ifrangeF_body6_rel" relationalize "ifrangeF_body6_rel" "is_ifrangeF_body6" synthesize "is_ifrangeF_body6" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body6_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body6: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body6(##M,A,G,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body6_fm(1,2,3,4,0)" and env = "[A,G,r,s]"] (*‹⟦is_ifrangeF_body6_fm(1, 2, 3, 4, 0) ∈ formula; [A::i, G::i, r::i, s::i] ∈ list(M::i); arity(is_ifrangeF_body6_fm(1, 2, 3, 4, 0)) ≤ 1 +⇩ω length([A, G, r, s]); ⋀x::i. x ∈ M ⟹ (M, [x] @ [A, G, r, s] ⊨ is_ifrangeF_body6_fm(1, 2, 3, 4, 0)) ⟷ (?Q::i ⇒ o)(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ M›*) arity_is_ifrangeF_body6_fm (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body6_fm(?A, ?G, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ (succ(?G) ∪ (succ(?G) ∪ succ(?f)))))›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body6_fm_type (*‹⟦?A ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body6_fm(?A, ?G, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) ifrFb_body6_closed: "M(G) ⟹ M(r) ⟹ M(s) ⟹ ifrFb_body6(G, r, s, x, i) ⟷ M(i) ∧ ifrFb_body6(G, r, s, x, i)" using If_abs (*‹is_If(M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) unfolding ifrangeF_body6_def is_ifrangeF_body6_def ifrFb_body6_def fun_apply_def (*goal: ‹⟦M(G); M(r); M(s)⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i})›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s)⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i})› 2. ‹⟦M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s)⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i})› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r = 0⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i})› 2. ‹⟦M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r ≠ 0⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p ∈ G . domain(p) = converse(s) ` i} else 0 else {p ∈ G . domain(p) = i})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); (i::i) ∉ range(s); r = 0⟧ ⟹ (x::i) ∈ (if r = 0 then if i ∈ range(s) then {p::i ∈ G . domain(p) = converse(s) ` i} else 0 else {p::i ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p::i ∈ G . domain(p) = converse(s) ` i} else 0 else {p::i ∈ G . domain(p) = i})› 2. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); (i::i) ∉ range(s); r ≠ 0⟧ ⟹ (x::i) ∈ (if r = 0 then if i ∈ range(s) then {p::i ∈ G . domain(p) = converse(s) ` i} else 0 else {p::i ∈ G . domain(p) = i}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {p::i ∈ G . domain(p) = converse(s) ` i} else 0 else {p::i ∈ G . domain(p) = i})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_basic) is_ifrFb_body6_closed: "M(G) ⟹ M(r) ⟹ M(s) ⟹ is_ifrFb_body6(M, G, r, s, x, i) ⟹ M(i)" using If_abs (*‹is_If(M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) unfolding ifrangeF_body6_def is_ifrangeF_body6_def is_ifrFb_body6_def fun_apply_def (*goal: ‹⟦M(G); M(r); M(s); ∃a[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. x ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp. M(p) ∧ is_domain(M, p, i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp. ∃c[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. x ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp. M(p) ∧ is_domain(M, p, i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp. ∃c[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. x ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp. M(p) ∧ is_domain(M, p, i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp. ∃c[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. x ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp. M(p) ∧ is_domain(M, p, i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp. ∃c[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(G); M(r); M(s); ∃a[M]. ∃d[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. x ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp. M(p) ∧ is_domain(M, p, i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp. ∃c[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. ∃l::i[M]. (x::i) ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp::i. M(p) ∧ is_domain(M, p, i::i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp::i. ∃c::i[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs::i[M]. ∃fxs::i[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦(M::i ⇒ o)(G::i); M(r::i); M(s::i); ∃a::i[M]. ∃d::i[M]. ∃e::i[M]. ∃g::i[M]. ∃h::i[M]. ∃j::i[M]. ∃k::i[M]. ∃l::i[M]. (x::i) ∈ l ∧ is_If(M, empty(M, r), j, k, l) ∧ is_Collect(M, G, λp::i. M(p) ∧ is_domain(M, p, i::i), k) ∧ is_If(M, i ∈ a, g, h, j) ∧ empty(M, h) ∧ is_Collect(M, G, λp::i. ∃c::i[M]. (M(p) ∧ c = e) ∧ is_domain(M, p, c), g) ∧ (∃xs::i[M]. ∃fxs::i[M]. upair(M, i, i, xs) ∧ image(M, d, xs, fxs) ∧ big_union(M, fxs, e)) ∧ is_converse(M, s, d) ∧ is_range(M, s, a); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body6_abs: assumes "(##M)(A)" "(##M)(G)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body6(##M,A,G,r,s,x) ⟷ ifrangeF_body6(##M,A,G,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body6(##M, A, G, r, s, x) ⟷ ifrangeF_body6(##M, A, G, r, s, x)›*) { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##(M::i))(r::i)› ‹(##M)(s)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, i))= (μ i. is_ifrFb_body6(##M, G, r, s, z, i))" for z using is_ifrFb_body6_closed[of G r s z] (*‹⟦(##M)(G); (##M)(r); (##M)(s); is_ifrFb_body6(##M, G, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body6(##M,G,r,s,z,i)"] (*‹(⋀y::i. y ∈ (M::i) ∧ is_ifrFb_body6(##M, G::i, r::i, s::i, z::i, y) ⟷ (?Q::i ⇒ o)(y)) ⟹ (μ x::i. x ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, x)) = (μ x::i. ?Q(x))›*)) (*goal: ‹(μ i. i ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, i)) = (μ i. is_ifrFb_body6(##M, G, r, s, z, i))›*) by auto moreover have "(μ i. i∈M ∧ is_ifrFb_body6(##M, G, r, s, z, i))= (μ i. i∈M ∧ ifrFb_body6(G, r, s, z, i))" if "z∈M" for z proof (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body6(##M,G,r,s,z,i)" "λi. i∈M ∧ ifrFb_body6(G,r,s,z,i)"] (*‹(⋀y. y ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, y) ⟷ y ∈ M ∧ ifrFb_body6(G, r, s, z, y)) ⟹ (μ x. x ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, x)) = (μ x. x ∈ M ∧ ifrFb_body6(G, r, s, z, x))›*)) (*goal: ‹⋀y. y ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, y) ⟷ y ∈ M ∧ ifrFb_body6(G, r, s, z, y)›*) fix y from assms (*‹(##(M::i))(A::i)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) ‹a∈M› (*‹a ∈ M›*) ‹z∈M› (*‹z ∈ M›*) show "y∈M ∧ is_ifrFb_body6(##M, G, r, s, z, y) ⟷ y∈M ∧ ifrFb_body6(G, r, s, z, y)" using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹(?a::i) ∉ domain(?f::i) ⟹ ?f ` ?a = 0›*) separation_in_constant (*‹(##M)(?a) ⟹ separation(##M, λx. x ∈ ?a)›*) transitivity[of _ G] (*‹⟦(?y::i) ∈ (G::i); G ∈ (M::i)⟧ ⟹ ?y ∈ M›*) separation_closed (*‹⟦separation(##(M::i), ?P::i ⇒ o); (##M)(?A::i)⟧ ⟹ (##M)(Collect(?A, ?P))›*) converse_closed (*‹(##M)(?r) ⟹ (##M)(converse(?r))›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) range_closed (*‹(##M)(?r) ⟹ (##M)(range(?r))›*) zero_in_M (*‹0 ∈ M›*) separation_cong[OF eq_commute, THEN iffD1, OF domain_eq_separation] (*‹(##M)(?b4) ⟹ separation(##M, λx. ?b4 = domain(x))›*) unfolding ifrFb_body6_def is_ifrFb_body6_def (*goal: ‹(y::i) ∈ (M::i) ∧ (∃a::i[##M]. ∃d::i[##M]. ∃e::i[##M]. ∃g::i[##M]. ∃h::i[##M]. ∃j::i[##M]. ∃k::i[##M]. ∃l::i[##M]. (z::i) ∈ l ∧ is_If(##M, empty(##M, r::i), j, k, l) ∧ is_Collect(##M, G::i, λp::i. (##M)(p) ∧ is_domain(##M, p, y), k) ∧ is_If(##M, y ∈ a, g, h, j) ∧ empty(##M, h) ∧ is_Collect(##M, G, λp::i. ∃c::i[##M]. ((##M)(p) ∧ c = e) ∧ is_domain(##M, p, c), g) ∧ is_apply(##M, d, y, e) ∧ is_converse(##M, s::i, d) ∧ is_range(##M, s, a)) ⟷ y ∈ M ∧ z ∈ (if r = 0 then if y ∈ range(s) then {p::i ∈ G . domain(p) = converse(s) ` y} else 0 else {p::i ∈ G . domain(p) = y})›*) by auto qed moreover from ‹a∈M› (*‹a ∈ M›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body6(##M, G, r, s, z,i))" for z using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body6(##M,G,r,s,z,i)" a] (*‹⟦⋀x. (##M)(x) ∧ is_ifrFb_body6(##M, G, r, s, z, x) ⟹ (##M)(x); (##M)(a)⟧ ⟹ least(##M, λi. (##M)(i) ∧ is_ifrFb_body6(##M, G, r, s, z, i), a) ⟷ a = (μ x. (##M)(x) ∧ is_ifrFb_body6(##M, G, r, s, z, x))›*) by simp ultimately have "z∈M ⟹ least(##M, λi. i ∈ M ∧ is_ifrFb_body6(##M, G, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body6(G, r, s, z,i))" for z using Least_cong[OF ifrFb_body6_closed [ of G r s ]] (*‹⟦⋀y. (##M)(G); ⋀y. (##M)(r); ⋀y. (##M)(s)⟧ ⟹ (μ x. ifrFb_body6(G, r, s, ?x1(x), ?i1(x))) = (μ x. (##M)(?i1(x)) ∧ ifrFb_body6(G, r, s, ?x1(x), ?i1(x)))›*) assms (*‹(##M)(A)› ‹(##M)(G)› ‹(##M)(r)› ‹(##(M::i))(s::i)› ‹(##M)(x)›*) by simp } with assms (*‹(##(M::i))(A::i)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##(M::i))(x::i)›*) show "?thesis" (*goal: ‹is_ifrangeF_body6(##M, A, G, r, s, x) ⟷ ifrangeF_body6(##M, A, G, r, s, x)›*) using pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦?y ∈ A; A ∈ M⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body6_def is_ifrangeF_body6_def (*goal: ‹(∃xa::i[##(M::i)]. ∃a::i[##M]. (xa ∈ (A::i) ∧ pair(##M, xa, a, x::i)) ∧ least(##M, λi::i. (##M)(i) ∧ is_ifrFb_body6(##M, G::i, r::i, s::i, xa, i), a)) ⟷ (∃xa::i∈A. x = ⟨xa, Least(ifrFb_body6(G, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body6: "(##M)(A) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(λa. {p ∈ G . domain(p) = a}, b, f, i)⟩)" using separation_is_ifrangeF_body6 (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s)⟧ ⟹ separation(##M, is_ifrangeF_body6(##M, ?A, ?G, ?r, ?s))›*) ifrangeF_body6_abs (*‹⟦(##M)(?A); (##M)(?G); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body6(##M, ?A, ?G, ?r, ?s, ?x) ⟷ ifrangeF_body6(##M, ?A, ?G, ?r, ?s, ?x)›*) separation_cong[where P = "is_ifrangeF_body6(##M,A,G,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x::i. (##(M::i))(x) ⟹ is_ifrangeF_body6(##M, A::i, G::i, b::i, f::i, x) ⟷ (?P'1::i ⇒ o)(x); separation(##M, λx::i. is_ifrangeF_body6(##M, A, G, b, f, x))⟧ ⟹ separation(##M, λx::i. ?P'1(x))›*) unfolding ifrangeF_body6_def if_range_F_def if_range_F_else_F_def ifrFb_body6_def (*goal: ‹⟦(##M)(A); (##M)(G); (##M)(b); (##M)(f)⟧ ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ (if b = 0 then if i ∈ range(f) then {p ∈ G . domain(p) = converse(f) ` i} else 0 else {p ∈ G . domain(p) = i})⟩)›*) by simp (* (##M)(A) ⟹ (##M)(f) ⟹ (##M)(b) ⟹ (##M)(D) ⟹ (##M)(r') ⟹ (##M)(A') ⟹ separation(##M, λy. ∃x∈A'. y = ⟨x, μ i. x ∈ if_range_F_else_F(drSR_Y(r', D, A), b, f, i)⟩) *) definition ifrFb_body7 where "ifrFb_body7(B,D,A,b,f,x,i) ≡ x ∈ (if b = 0 then if i ∈ range(f) then {d ∈ D . ∃r∈A. restrict(r, B) = converse(f) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈A. restrict(r, B) = i ∧ d = domain(r)})" relativize functional "ifrFb_body7" "ifrFb_body7_rel" relationalize "ifrFb_body7_rel" "is_ifrFb_body7" synthesize "is_ifrFb_body7" from_definition assuming "nonempty" arity_theorem for "is_ifrFb_body7_fm" definition ifrangeF_body7 :: "[i⇒o,i,i,i,i,i,i,i] ⇒ o" where "ifrangeF_body7(M,A,B,D,G,b,f) ≡ λy. ∃x∈A. y = ⟨x,μ i. ifrFb_body7(B,D,G,b,f,x,i)⟩" relativize functional "ifrangeF_body7" "ifrangeF_body7_rel" relationalize "ifrangeF_body7_rel" "is_ifrangeF_body7" synthesize "is_ifrangeF_body7" from_definition assuming "nonempty" arity_theorem for "is_ifrangeF_body7_fm" lemma (in M_Z_trans) separation_is_ifrangeF_body7: "(##M)(A) ⟹ (##M)(B) ⟹ (##M)(D) ⟹ (##M)(G) ⟹ (##M)(r) ⟹ (##M)(s) ⟹ separation(##M, is_ifrangeF_body7(##M,A,B,D,G,r,s))" using separation_in_ctm[where φ = "is_ifrangeF_body7_fm(1,2,3,4,5,6,0)" and env = "[A,B,D,G,r,s]"] (*‹⟦is_ifrangeF_body7_fm(1, 2, 3, 4, 5, 6, 0) ∈ formula; [A, B, D, G, r, s] ∈ list(M); arity(is_ifrangeF_body7_fm(1, 2, 3, 4, 5, 6, 0)) ≤ 1 +⇩ω length([A, B, D, G, r, s]); ⋀x. x ∈ M ⟹ (M, [x] @ [A, B, D, G, r, s] ⊨ is_ifrangeF_body7_fm(1, 2, 3, 4, 5, 6, 0)) ⟷ ?Q(x)⟧ ⟹ separation(##M, ?Q)›*) zero_in_M (*‹0 ∈ (M::i)›*) arity_is_ifrangeF_body7_fm (*‹⟦?A ∈ ω; ?B ∈ ω; ?D ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ arity(is_ifrangeF_body7_fm(?A, ?B, ?D, ?G, ?b, ?f, ?y)) = succ(?A) ∪ (succ(?y) ∪ (succ(?b) ∪ (succ(?D) ∪ (succ(?G) ∪ succ(?B)) ∪ (succ(?D) ∪ (succ(?G) ∪ succ(?B)) ∪ succ(?f)))))›*) ord_simp_union (*‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*) is_ifrangeF_body7_fm_type (*‹⟦?A ∈ ω; ?B ∈ ω; ?D ∈ ω; ?G ∈ ω; ?b ∈ ω; ?f ∈ ω; ?y ∈ ω⟧ ⟹ is_ifrangeF_body7_fm(?A, ?B, ?D, ?G, ?b, ?f, ?y) ∈ formula›*) by simp lemma (in M_basic) ifrFb_body7_closed: "M(B) ⟹ M(D) ⟹ M(G) ⟹ M(r) ⟹ M(s) ⟹ ifrFb_body7(B,D,G, r, s, x, i) ⟷ M(i) ∧ ifrFb_body7(B,D,G, r, s, x, i)" using If_abs (*‹is_If(M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) unfolding ifrangeF_body7_def is_ifrangeF_body7_def ifrFb_body7_def fun_apply_def (*goal: ‹⟦M(B); M(D); M(G); M(r); M(s)⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)})›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦(M::i ⇒ o)(B::i); M(D::i); M(G::i); M(r::i); M(s::i); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); (i::i) ∈ range(s)⟧ ⟹ (x::i) ∈ (if r = 0 then if i ∈ range(s) then {d::i ∈ D . ∃r::i∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d::i ∈ D . ∃r::i∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d::i ∈ D . ∃r::i∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d::i ∈ D . ∃r::i∈G. restrict(r, B) = i ∧ d = domain(r)})› 2. ‹⟦(M::i ⇒ o)(B::i); M(D::i); M(G::i); M(r::i); M(s::i); ⋀(b::o) (t::i) (f::i) r::i. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); (i::i) ∉ range(s)⟧ ⟹ (x::i) ∈ (if r = 0 then if i ∈ range(s) then {d::i ∈ D . ∃r::i∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d::i ∈ D . ∃r::i∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d::i ∈ D . ∃r::i∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d::i ∈ D . ∃r::i∈G. restrict(r, B) = i ∧ d = domain(r)})› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(B); M(D); M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r = 0⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)})› 2. ‹⟦M(B); M(D); M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r ≠ 0⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(B); M(D); M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r = 0⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)})› 2. ‹⟦M(B); M(D); M(G); M(r); M(s); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r ≠ 0⟧ ⟹ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)}) ⟷ M(i) ∧ x ∈ (if r = 0 then if i ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` i ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = i ∧ d = domain(r)})› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_basic) is_ifrFb_body7_closed: "M(B) ⟹ M(D) ⟹ M(G) ⟹ M(r) ⟹ M(s) ⟹ is_ifrFb_body7(M, B,D,G, r, s, x, i) ⟹ M(i)" using If_abs (*‹is_If(M::i ⇒ o, ?b::o, ?t::i, ?f::i, ?r::i) ⟷ ?r = (if ?b then ?t else ?f)›*) unfolding ifrangeF_body7_def is_ifrangeF_body7_def is_ifrFb_body7_def fun_apply_def (*goal: ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a)⟧ ⟹ M(i)›*) apply ((cases "i∈range(s)")[1]) (*goals: 1. ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s)⟧ ⟹ M(i)› 2. ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s)⟧ ⟹ M(i)› discuss goal 1*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∈ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cases "r=0")[1]) (*goals: 1. ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r = 0⟧ ⟹ M(i)› 2. ‹⟦M(B); M(D); M(G); M(r); M(s); ∃a[M]. ∃e[M]. ∃g[M]. ∃h[M]. ∃j[M]. ∃k[M]. ∃l[M]. ∃m[M]. x ∈ m ∧ is_If(M, empty(M, r), k, l, m) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. r ∈ G ∧ restriction(M, r, B, i) ∧ is_domain(M, r, d)), l) ∧ is_If(M, i ∈ a, h, j, k) ∧ empty(M, j) ∧ is_Collect(M, D, λd. M(d) ∧ (∃r[M]. ∃c[M]. (r ∈ G ∧ c = g ∧ is_domain(M, r, d)) ∧ restriction(M, r, B, c)), h) ∧ (∃xs[M]. ∃fxs[M]. upair(M, i, i, xs) ∧ image(M, e, xs, fxs) ∧ big_union(M, fxs, g)) ∧ is_converse(M, s, e) ∧ is_range(M, s, a); ⋀b t f r. is_If(M, b, t, f, r) ⟷ r = (if b then t else f); i ∉ range(s); r ≠ 0⟧ ⟹ M(i)› discuss goal 1*) apply ((auto dest:transM (*‹⟦?y ∈ ?x; M(?x)⟧ ⟹ M(?y)›*))[1]) (*discuss goal 2*) apply ((auto dest:transM (*‹⟦(?y::i) ∈ (?x::i); (M::i ⇒ o)(?x)⟧ ⟹ M(?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma (in M_ZF1_trans) ifrangeF_body7_abs: assumes "(##M)(A)" "(##M)(B)" "(##M)(D)" "(##M)(G)" "(##M)(r)" "(##M)(s)" "(##M)(x)" shows "is_ifrangeF_body7(##M,A,B,D,G,r,s,x) ⟷ ifrangeF_body7(##M,A,B,D,G,r,s,x)" proof (-) (*goal: ‹is_ifrangeF_body7(##M, A, B, D, G, r, s, x) ⟷ ifrangeF_body7(##M, A, B, D, G, r, s, x)›*) from assms (*‹(##M)(A)› ‹(##M)(B)› ‹(##(M::i))(D::i)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) have sep_dr: "y∈M ⟹ separation(##M, λd . ∃r∈M . r∈G ∧ y = restrict(r, B) ∧ d = domain(r))" for y apply (rule_tac separation_cong[where P'="λd . ∃r∈ M . r∈G ∧ y = restrict(r, B) ∧ d = domain(r)",THEN iffD1,OF _ separation_restrict_eq_dom_eq[rule_format,of G B y]] (*‹⟦⋀x. (##M)(x) ⟹ (∃r∈G. restrict(r, B) = y ∧ x = domain(r)) ⟷ (∃r∈M. r ∈ G ∧ y = restrict(r, B) ∧ x = domain(r)); (##M)(G); (##M)(B); (##M)(y)⟧ ⟹ separation(##M, λx. ∃r∈M. r ∈ G ∧ y = restrict(r, B) ∧ x = domain(r))›*)) (*goals: 1. ‹⋀d::i. ⟦(y::i) ∈ (M::i); (##M)(A::i); (##M)(B::i); (##M)(D::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i); (##M)(d)⟧ ⟹ (∃r::i∈G. restrict(r, B) = y ∧ d = domain(r)) ⟷ (∃r::i∈M. r ∈ G ∧ y = restrict(r, B) ∧ d = domain(r))› 2. ‹⟦(y::i) ∈ (M::i); (##M)(A::i); (##M)(B::i); (##M)(D::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i)⟧ ⟹ (##M)(G)› 3. ‹⟦(y::i) ∈ (M::i); (##M)(A::i); (##M)(B::i); (##M)(D::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i)⟧ ⟹ (##M)(B)› 4. ‹⟦(y::i) ∈ (M::i); (##M)(A::i); (##M)(B::i); (##M)(D::i); (##M)(G::i); (##M)(r::i); (##M)(s::i); (##M)(x::i)⟧ ⟹ (##M)(y)› discuss goal 1*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*))[1]) (*discuss goal 2*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*))[1]) (*discuss goal 3*) apply ((auto simp:transitivity[of _ G] (*‹⟦(?y::i) ∈ (G::i); G ∈ (M::i)⟧ ⟹ ?y ∈ M›*))[1]) (*discuss goal 4*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*))[1]) (*proven 4 subgoals*) . from assms (*‹(##M)(A)› ‹(##M)(B)› ‹(##M)(D)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) have sep_dr'': "y∈M ⟹ separation(##M, λd . ∃r∈M. r ∈ G ∧ d = domain(r) ∧ converse(s) ` y = restrict(r, B))" for y apply (rule_tac separation_cong[THEN iffD1,OF _ separation_restrict_eq_dom_eq[rule_format,of G B "converse(s) ` y "]] (*‹⟦⋀x. (##M)(x) ⟹ (∃r∈G. restrict(r, B) = converse(s) ` y ∧ x = domain(r)) ⟷ ?P'1(x); (##M)(G); (##M)(B); (##M)(converse(s) ` y)⟧ ⟹ separation(##M, λx. ?P'1(x))›*)) (*goals: 1. ‹⋀d. ⟦y ∈ M; (##M)(A); (##M)(B); (##M)(D); (##M)(G); (##M)(r); (##M)(s); (##M)(x); (##M)(d)⟧ ⟹ (∃r∈G. restrict(r, B) = converse(s) ` y ∧ d = domain(r)) ⟷ (∃r∈M. r ∈ G ∧ d = domain(r) ∧ converse(s) ` y = restrict(r, B))› 2. ‹⟦y ∈ M; (##M)(A); (##M)(B); (##M)(D); (##M)(G); (##M)(r); (##M)(s); (##M)(x)⟧ ⟹ (##M)(G)› 3. ‹⟦y ∈ M; (##M)(A); (##M)(B); (##M)(D); (##M)(G); (##M)(r); (##M)(s); (##M)(x)⟧ ⟹ (##M)(B)› 4. ‹⟦y ∈ M; (##M)(A); (##M)(B); (##M)(D); (##M)(G); (##M)(r); (##M)(s); (##M)(x)⟧ ⟹ (##M)(converse(s) ` y)› discuss goal 1*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*) apply_closed[simplified] (*‹⟦?f ∈ M; ?a ∈ M⟧ ⟹ ?f ` ?a ∈ M›*) converse_closed[simplified] (*‹?r ∈ M ⟹ converse(?r) ∈ M›*))[1]) (*discuss goal 2*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*) apply_closed[simplified] (*‹⟦?f ∈ M; ?a ∈ M⟧ ⟹ ?f ` ?a ∈ M›*) converse_closed[simplified] (*‹?r ∈ M ⟹ converse(?r) ∈ M›*))[1]) (*discuss goal 3*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*) apply_closed[simplified] (*‹⟦?f ∈ M; ?a ∈ M⟧ ⟹ ?f ` ?a ∈ M›*) converse_closed[simplified] (*‹?r ∈ M ⟹ converse(?r) ∈ M›*))[1]) (*discuss goal 4*) apply ((auto simp:transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*) apply_closed[simplified] (*‹⟦?f ∈ M; ?a ∈ M⟧ ⟹ ?f ` ?a ∈ M›*) converse_closed[simplified] (*‹?r ∈ M ⟹ converse(?r) ∈ M›*))[1]) (*proven 4 subgoals*) . { fix a assume "a∈M" (*‹(a::i) ∈ (M::i)›*) with assms (*‹(##(M::i))(A::i)› ‹(##M)(B)› ‹(##(M::i))(D::i)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) have "(μ i. i∈ M ∧ is_ifrFb_body7(##M, B,D,G, r, s, z, i))= (μ i. is_ifrFb_body7(##M,B,D, G, r, s, z, i))" for z using is_ifrFb_body7_closed[of B D G r s z] (*‹⟦(##M)(B); (##M)(D); (##M)(G); (##M)(r); (##M)(s); is_ifrFb_body7(##M, B, D, G, r, s, z, ?i)⟧ ⟹ (##M)(?i)›*) apply (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body7(##M,B,D,G,r,s,z,i)"] (*‹(⋀y::i. y ∈ (M::i) ∧ is_ifrFb_body7(##M, B::i, D::i, G::i, r::i, s::i, z::i, y) ⟷ (?Q::i ⇒ o)(y)) ⟹ (μ x::i. x ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, x)) = (μ x::i. ?Q(x))›*)) (*goal: ‹(μ i. i ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, i)) = (μ i. is_ifrFb_body7(##M, B, D, G, r, s, z, i))›*) by auto moreover from this (*‹(μ i. i ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, ?z, i)) = (μ i. is_ifrFb_body7(##M, B, D, G, r, s, ?z, i))›*) have "(μ i. i∈M ∧ is_ifrFb_body7(##M, B,D,G, r, s, z, i))= (μ i. i∈M ∧ ifrFb_body7(B,D,G, r, s, z, i))" if "z∈M" for z proof (rule_tac Least_cong[of "λi. i∈M ∧ is_ifrFb_body7(##M,B,D,G,r,s,z,i)" "λi. i∈M ∧ ifrFb_body7(B,D,G,r,s,z,i)"] (*‹(⋀y::i. y ∈ (M::i) ∧ is_ifrFb_body7(##M, B::i, D::i, G::i, r::i, s::i, z::i, y) ⟷ y ∈ M ∧ ifrFb_body7(B, D, G, r, s, z, y)) ⟹ (μ x::i. x ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, x)) = (μ x::i. x ∈ M ∧ ifrFb_body7(B, D, G, r, s, z, x))›*)) (*goal: ‹⋀y. (⋀z. (μ i. i ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, i)) = (μ i. is_ifrFb_body7(##M, B, D, G, r, s, z, i))) ⟹ y ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, y) ⟷ y ∈ M ∧ ifrFb_body7(B, D, G, r, s, z, y)›*) from assms (*‹(##M)(A)› ‹(##(M::i))(B::i)› ‹(##M)(D)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) ‹a∈M› (*‹a ∈ M›*) ‹z∈M› (*‹z ∈ M›*) have "is_ifrFb_body7(##M, B,D,G, r, s, z, y) ⟷ ifrFb_body7(B,D,G, r, s, z, y)" if "y∈M" for y using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) apply_0 (*‹?a ∉ domain(?f) ⟹ ?f ` ?a = 0›*) separation_closed (*‹⟦separation(##M, ?P); (##M)(?A)⟧ ⟹ (##M)(Collect(?A, ?P))›*) converse_closed (*‹(##M)(?r) ⟹ (##M)(converse(?r))›*) apply_closed (*‹⟦(##M)(?f); (##M)(?a)⟧ ⟹ (##M)(?f ` ?a)›*) range_closed (*‹(##M)(?r) ⟹ (##M)(range(?r))›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ D] (*‹⟦?y ∈ D; D ∈ M⟧ ⟹ ?y ∈ M›*) transitivity[of _ G] (*‹⟦?y ∈ G; G ∈ M⟧ ⟹ ?y ∈ M›*) that (*‹y ∈ M›*) sep_dr (*‹?y ∈ M ⟹ separation(##M, λd. ∃r∈M. r ∈ G ∧ ?y = restrict(r, B) ∧ d = domain(r))›*) sep_dr'' (*‹?y ∈ M ⟹ separation(##M, λd. ∃r∈M. r ∈ G ∧ d = domain(r) ∧ converse(s) ` ?y = restrict(r, B))›*) unfolding ifrFb_body7_def is_ifrFb_body7_def (*goal: ‹(∃a[##M]. ∃e[##M]. ∃g[##M]. ∃h[##M]. ∃j[##M]. ∃k[##M]. ∃l[##M]. ∃m[##M]. z ∈ m ∧ is_If(##M, empty(##M, r), k, l, m) ∧ is_Collect(##M, D, λd. (##M)(d) ∧ (∃r[##M]. r ∈ G ∧ restriction(##M, r, B, y) ∧ is_domain(##M, r, d)), l) ∧ is_If(##M, y ∈ a, h, j, k) ∧ empty(##M, j) ∧ is_Collect(##M, D, λd. (##M)(d) ∧ (∃r[##M]. ∃c[##M]. (r ∈ G ∧ c = g ∧ is_domain(##M, r, d)) ∧ restriction(##M, r, B, c)), h) ∧ is_apply(##M, e, y, g) ∧ is_converse(##M, s, e) ∧ is_range(##M, s, a)) ⟷ z ∈ (if r = 0 then if y ∈ range(s) then {d ∈ D . ∃r∈G. restrict(r, B) = converse(s) ` y ∧ d = domain(r)} else 0 else {d ∈ D . ∃r∈G. restrict(r, B) = y ∧ d = domain(r)})›*) by auto then show " y ∈ M ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, y) ⟷ y ∈ M ∧ ifrFb_body7(B, D, G, r, s, z, y)" for y using conj_cong (*‹⟦?P ⟷ ?P'; ?P' ⟹ ?Q ⟷ ?Q'⟧ ⟹ ?P ∧ ?Q ⟷ ?P' ∧ ?Q'›*) by simp qed moreover from ‹a∈M› (*‹a ∈ M›*) have "least(##M, λi. i ∈ M ∧ is_ifrFb_body7(##M, B,D,G, r, s, z, i), a) ⟷ a = (μ i. i∈ M ∧ is_ifrFb_body7(##M,B,D,G, r, s, z,i))" for z using If_abs (*‹is_If(##M, ?b, ?t, ?f, ?r) ⟷ ?r = (if ?b then ?t else ?f)›*) least_abs'[of "λi. (##M)(i) ∧ is_ifrFb_body7(##M,B,D,G,r,s,z,i)" a] (*‹⟦⋀x. (##M)(x) ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, x) ⟹ (##M)(x); (##M)(a)⟧ ⟹ least(##M, λi. (##M)(i) ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, i), a) ⟷ a = (μ x. (##M)(x) ∧ is_ifrFb_body7(##M, B, D, G, r, s, z, x))›*) by simp ultimately have "z∈M ⟹ least(##M, λi. i ∈ M ∧ is_ifrFb_body7(##M,B,D,G, r, s, z, i), a) ⟷ a = (μ i. ifrFb_body7(B,D,G, r, s, z,i))" for z using Least_cong[OF ifrFb_body7_closed [ of B D G r s ]] (*‹⟦⋀y. (##M)(B); ⋀y. (##M)(D); ⋀y. (##M)(G); ⋀y. (##M)(r); ⋀y. (##M)(s)⟧ ⟹ (μ x. ifrFb_body7(B, D, G, r, s, ?x1(x), ?i1(x))) = (μ x. (##M)(?i1(x)) ∧ ifrFb_body7(B, D, G, r, s, ?x1(x), ?i1(x)))›*) assms (*‹(##(M::i))(A::i)› ‹(##M)(B)› ‹(##M)(D)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##(M::i))(x::i)›*) by simp } with assms (*‹(##(M::i))(A::i)› ‹(##M)(B)› ‹(##(M::i))(D::i)› ‹(##M)(G)› ‹(##M)(r)› ‹(##M)(s)› ‹(##M)(x)›*) show "?thesis" (*goal: ‹is_ifrangeF_body7(##M, A, B, D, G, r, s, x) ⟷ ifrangeF_body7(##M, A, B, D, G, r, s, x)›*) using pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) apply_closed (*‹⟦(##(M::i))(?f::i); (##M)(?a::i)⟧ ⟹ (##M)(?f ` ?a)›*) zero_in_M (*‹0 ∈ M›*) transitivity[of _ A] (*‹⟦(?y::i) ∈ (A::i); A ∈ (M::i)⟧ ⟹ ?y ∈ M›*) unfolding ifrangeF_body7_def is_ifrangeF_body7_def (*goal: ‹(∃xa[##M]. ∃a[##M]. (xa ∈ A ∧ pair(##M, xa, a, x)) ∧ least(##M, λi. (##M)(i) ∧ is_ifrFb_body7(##M, B, D, G, r, s, xa, i), a)) ⟷ (∃xa∈A. x = ⟨xa, Least(ifrFb_body7(B, D, G, r, s, xa))⟩)›*) by (auto dest:transM (*‹⟦?y ∈ ?x; (##M)(?x)⟧ ⟹ (##M)(?y)›*)) qed lemma (in M_ZF1_trans) separation_ifrangeF_body7: "(##M)(A) ⟹ (##M)(B) ⟹ (##M)(D) ⟹ (##M)(G) ⟹ (##M)(b) ⟹ (##M)(f) ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ if_range_F_else_F(drSR_Y(B, D, G), b, f, i)⟩)" using separation_is_ifrangeF_body7 (*‹⟦(##(M::i))(?A::i); (##M)(?B::i); (##M)(?D::i); (##M)(?G::i); (##M)(?r::i); (##M)(?s::i)⟧ ⟹ separation(##M, is_ifrangeF_body7(##M, ?A, ?B, ?D, ?G, ?r, ?s))›*) ifrangeF_body7_abs (*‹⟦(##M)(?A); (##M)(?B); (##M)(?D); (##M)(?G); (##M)(?r); (##M)(?s); (##M)(?x)⟧ ⟹ is_ifrangeF_body7(##M, ?A, ?B, ?D, ?G, ?r, ?s, ?x) ⟷ ifrangeF_body7(##M, ?A, ?B, ?D, ?G, ?r, ?s, ?x)›*) drSR_Y_equality (*‹drSR_Y(?B, ?D, ?A, ?x) = {dr ∈ ?D . ∃r∈?A. restrict(r, ?B) = ?x ∧ dr = domain(r)}›*) separation_cong[where P = "is_ifrangeF_body7(##M,A,B,D,G,b,f)" and M = "##M", THEN iffD1] (*‹⟦⋀x. (##M)(x) ⟹ is_ifrangeF_body7(##M, A, B, D, G, b, f, x) ⟷ ?P'1(x); separation(##M, λx. is_ifrangeF_body7(##M, A, B, D, G, b, f, x))⟧ ⟹ separation(##M, λx. ?P'1(x))›*) unfolding ifrangeF_body7_def if_range_F_def if_range_F_else_F_def ifrFb_body7_def (*goal: ‹⟦(##M)(A); (##M)(B); (##M)(D); (##M)(G); (##M)(b); (##M)(f)⟧ ⟹ separation(##M, λy. ∃x∈A. y = ⟨x, μ i. x ∈ (if b = 0 then if i ∈ range(f) then drSR_Y(B, D, G, converse(f) ` i) else 0 else drSR_Y(B, D, G, i))⟩)›*) by simp definition omfunspace :: "[i,i] ⇒ o" where "omfunspace(B) ≡ λz. ∃x. ∃n∈ω. z∈x ∧ x = n→B" relativize functional "omfunspace" "omfunspace_rel" relationalize "omfunspace_rel" "is_omfunspace" synthesize "is_omfunspace" from_definition assuming "nonempty" arity_theorem for "is_omfunspace_fm" context M_pre_seqspace begin is_iff_rel for "omfunspace" using is_function_space_iff unfolding omfunspace_rel_def is_omfunspace_def by (simp add:absolut) end ― ‹\<^locale>‹M_pre_seqspace›› context M_ZF1_trans begin lemma separation_omfunspace: assumes "(##M)(B)" shows "separation(##M, λz. ∃x[##M]. ∃n[##M]. n ∈ ω ∧ z ∈ x ∧ x = n →⇗M⇖ B)" using assms (*‹(##M)(B)›*) separation_in_ctm[where env = "[B]" and φ = "is_omfunspace_fm(1,0)" and Q = "is_omfunspace(##M,B)"] (*‹⟦is_omfunspace_fm(1, 0) ∈ formula; [B] ∈ list(M); arity(is_omfunspace_fm(1, 0)) ≤ 1 +⇩ω length([B]); ⋀x. x ∈ M ⟹ (M, [x] @ [B] ⊨ is_omfunspace_fm(1, 0)) ⟷ is_omfunspace(##M, B, x)⟧ ⟹ separation(##M, is_omfunspace(##M, B))›*) nonempty (*‹(##M)(0)›*) is_omfunspace_iff[of B, THEN separation_cong, of "##M"] (*‹⟦⋀x::i. (##(M::i))(x) ⟹ (##M)(B::i); ⋀x::i. (##M)(x) ⟹ (##M)((?z1::i ⇒ i)(x))⟧ ⟹ separation(##M, λx::i. is_omfunspace(##M, B, ?z1(x))) ⟷ separation(##M, λx::i. omfunspace_rel(##M, B, ?z1(x)))›*) arity_is_omfunspace_fm (*‹⟦?B ∈ ω; ?z ∈ ω⟧ ⟹ arity(is_omfunspace_fm(?B, ?z)) = succ(?z) ∪ succ(?B)›*) is_omfunspace_fm_type (*‹⟦?B ∈ ω; ?z ∈ ω⟧ ⟹ is_omfunspace_fm(?B, ?z) ∈ formula›*) unfolding omfunspace_rel_def (*goal: ‹separation(##M, λz. ∃x[##M]. ∃n[##M]. n ∈ ω ∧ z ∈ x ∧ x = n →⇗M⇖ B)›*) by (auto simp add:ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*)) end ― ‹\<^locale>‹M_ZF1_trans›› sublocale M_ZF1_trans ⊆ M_seqspace "##M" using separation_omfunspace (*‹(##M)(?B) ⟹ separation(##M, λz. ∃x[##M]. ∃n[##M]. n ∈ ω ∧ z ∈ x ∧ x = n →⇗M⇖ ?B)›*) by unfold_locales definition cdltgamma :: "[i,i] ⇒ o" where "cdltgamma(γ) ≡ λZ . |Z| < γ" relativize functional "cdltgamma" "cdltgamma_rel" relationalize "cdltgamma_rel" "is_cdltgamma" synthesize "is_cdltgamma" from_definition assuming "nonempty" arity_theorem for "is_cdltgamma_fm" definition cdeqgamma :: "[i] ⇒ o" where "cdeqgamma ≡ λZ . |fst(Z)| = snd(Z)" relativize functional "cdeqgamma" "cdeqgamma_rel" relationalize "cdeqgamma_rel" "is_cdeqgamma" synthesize "is_cdeqgamma" from_definition assuming "nonempty" arity_theorem for "is_cdeqgamma_fm" context M_Perm begin is_iff_rel for "cdltgamma" using is_cardinal_iff unfolding cdltgamma_rel_def is_cdltgamma_def by (simp add:absolut) is_iff_rel for "cdeqgamma" using is_cardinal_iff fst_rel_abs snd_rel_abs unfolding cdeqgamma_rel_def is_cdeqgamma_def by (auto simp add:absolut) lemma is_cdeqgamma_iff_split: "M(Z) ⟹ cdeqgamma_rel(M, Z) ⟷ (λ⟨x,y⟩. |x|⇗M⇖ = y)(Z)" using fst_rel_abs (*‹M(?p) ⟹ fst_rel(M, ?p) = fst(?p)›*) snd_rel_abs (*‹M(?p) ⟹ snd_rel(M, ?p) = snd(?p)›*) unfolding cdeqgamma_rel_def split_def (*goal: ‹M(Z) ⟹ |fst_rel(M, Z)|⇗M⇖ = snd_rel(M, Z) ⟷ |fst(Z)|⇗M⇖ = snd(Z)›*) by simp end context M_ZF1_trans begin lemma separation_cdltgamma: assumes "(##M)(γ)" shows "separation(##M, λZ . cardinal_rel(##M,Z) < γ)" using assms (*‹(##M)(γ)›*) separation_in_ctm[where env = "[γ]" and φ = "is_cdltgamma_fm(1,0)" and Q = "cdltgamma_rel(##M,γ)"] (*‹⟦is_cdltgamma_fm(1, 0) ∈ formula; [γ] ∈ list(M); arity(is_cdltgamma_fm(1, 0)) ≤ 1 +⇩ω length([γ]); ⋀x. x ∈ M ⟹ (M, [x] @ [γ] ⊨ is_cdltgamma_fm(1, 0)) ⟷ cdltgamma_rel(##M, γ, x)⟧ ⟹ separation(##M, cdltgamma_rel(##M, γ))›*) nonempty (*‹(##M)(0)›*) is_cdltgamma_iff[of γ] (*‹⟦(##M)(γ); (##M)(?Z)⟧ ⟹ is_cdltgamma(##M, γ, ?Z) ⟷ cdltgamma_rel(##M, γ, ?Z)›*) arity_is_cdltgamma_fm (*‹⟦?γ ∈ ω; ?Z ∈ ω⟧ ⟹ arity(is_cdltgamma_fm(?γ, ?Z)) = succ(?γ) ∪ succ(?Z)›*) is_cdltgamma_fm_type (*‹⟦?γ ∈ ω; ?Z ∈ ω⟧ ⟹ is_cdltgamma_fm(?γ, ?Z) ∈ formula›*) unfolding cdltgamma_rel_def (*goal: ‹separation(##M, λZ. |Z|⇗M⇖ < γ)›*) by (auto simp add:ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*)) lemma separation_cdeqgamma: shows "separation(##M, λZ. (λ⟨x,y⟩ . cardinal_rel(##M,x) = y)(Z))" using separation_in_ctm[where env = "[]" and φ = "is_cdeqgamma_fm(0)" and Q = "cdeqgamma_rel(##M)"] (*‹⟦is_cdeqgamma_fm(0) ∈ formula; [] ∈ list(M); arity(is_cdeqgamma_fm(0)) ≤ 1 +⇩ω length([]); ⋀x. x ∈ M ⟹ (M, [x] @ [] ⊨ is_cdeqgamma_fm(0)) ⟷ cdeqgamma_rel(##M, x)⟧ ⟹ separation(##M, cdeqgamma_rel(##M))›*) is_cdeqgamma_iff_split (*‹(##M)(?Z) ⟹ cdeqgamma_rel(##M, ?Z) ⟷ (λ⟨x,y⟩. |x|⇗M⇖ = y)(?Z)›*) nonempty (*‹(##M)(0)›*) is_cdeqgamma_iff (*‹(##M)(?Z) ⟹ is_cdeqgamma(##M, ?Z) ⟷ cdeqgamma_rel(##M, ?Z)›*) arity_is_cdeqgamma_fm (*‹?Z ∈ ω ⟹ arity(is_cdeqgamma_fm(?Z)) = succ(?Z)›*) is_cdeqgamma_fm_type (*‹?Z ∈ ω ⟹ is_cdeqgamma_fm(?Z) ∈ formula›*) separation_cong[OF is_cdeqgamma_iff_split, of "##M"] (*‹(⋀x. (##M)(x) ⟹ (##M)(?Z1(x))) ⟹ separation(##M, λx. cdeqgamma_rel(##M, ?Z1(x))) ⟷ separation(##M, λx. (λ⟨x,y⟩. |x|⇗M⇖ = y)(?Z1(x)))›*) unfolding cdeqgamma_rel_def (*goal: ‹separation(##M, λZ. (λ⟨x,y⟩. |x|⇗M⇖ = y)(Z))›*) by (simp add:ord_simp_union (*‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*)) end ― ‹\<^locale>‹M_ZF1_trans›› end
{ "path": "afp-2025-02-12/thys/Independence_CH/Replacement_Instances.thy", "repo": "afp-2025-02-12", "sha": "fc6044c4d1cd2b1ebadd64e0e4b8ed053beaa48055a6743ed1b82046a4cb59ed" }
section "Splay Tree" theory Splay_Tree imports "HOL-Library.Tree" "HOL-Data_Structures.Set_Specs" "HOL-Data_Structures.Cmp" begin declare sorted_wrt.simps(2)[simp del] text‹Splay trees were invented by Sleator and Tarjan~\<^cite>‹"SleatorT-JACM85"›.› subsection "Function ‹splay›" function splay :: "'a::linorder ⇒ 'a tree ⇒ 'a tree" where "splay x Leaf = Leaf" | "splay x (Node AB x CD) = Node AB x CD" | "x<b ⟹ splay x (Node (Node A x B) b CD) = Node A x (Node B b CD)" | "x<b ⟹ splay x (Node Leaf b CD) = Node Leaf b CD" | "x<a ⟹ x<b ⟹ splay x (Node (Node Leaf a B) b CD) = Node Leaf a (Node B b CD)" | "x<a ⟹ x<b ⟹ A ≠ Leaf ⟹ splay x (Node (Node A a B) b CD) = (case splay x A of Node A1 a' A2 ⇒ Node A1 a' (Node A2 a (Node B b CD)))" | "a<x ⟹ x<b ⟹ splay x (Node (Node A a Leaf) b CD) = Node A a (Node Leaf b CD)" | "a<x ⟹ x<b ⟹ B ≠ Leaf ⟹ splay x (Node (Node A a B) b CD) = (case splay x B of Node B1 b' B2 ⇒ Node (Node A a B1) b' (Node B2 b CD))" | "b<x ⟹ splay x (Node AB b (Node C x D)) = Node (Node AB b C) x D" | "b<x ⟹ splay x (Node AB b Leaf) = Node AB b Leaf" | "b<x ⟹ x<c ⟹ C ≠ Leaf ⟹ splay x (Node AB b (Node C c D)) = (case splay x C of Node C1 c' C ⇒ Node (Node AB b C1) c' (Node C c D))" | "b<x ⟹ x<c ⟹ splay x (Node AB b (Node Leaf c D)) = Node (Node AB b Leaf) c D" | "b<x ⟹ c<x ⟹ splay x (Node AB b (Node C c Leaf)) = Node (Node AB b C) c Leaf" | "a<x ⟹ c<x ⟹ D ≠ Leaf ⟹ splay x (Node AB a (Node C c D)) = (case splay x D of Node D1 d' D2 ⇒ Node (Node (Node AB a C) c D1) d' D2)" apply(atomize_elim) apply(auto) (* 1 subgoal *) apply (subst (asm) neq_Leaf_iff) apply(auto) apply (metis tree.exhaust le_less_linear less_linear)+ done termination splay by lexicographic_order lemma splay_code: "splay x (Node AB b CD) = (case cmp x b of EQ ⇒ Node AB b CD | LT ⇒ (case AB of Leaf ⇒ Node AB b CD | Node A a B ⇒ (case cmp x a of EQ ⇒ Node A a (Node B b CD) | LT ⇒ if A = Leaf then Node A a (Node B b CD) else case splay x A of Node A₁ a' A₂ ⇒ Node A₁ a' (Node A₂ a (Node B b CD)) | GT ⇒ if B = Leaf then Node A a (Node B b CD) else case splay x B of Node B₁ b' B₂ ⇒ Node (Node A a B₁) b' (Node B₂ b CD))) | GT ⇒ (case CD of Leaf ⇒ Node AB b CD | Node C c D ⇒ (case cmp x c of EQ ⇒ Node (Node AB b C) c D | LT ⇒ if C = Leaf then Node (Node AB b C) c D else case splay x C of Node C₁ c' C₂ ⇒ Node (Node AB b C₁) c' (Node C₂ c D) | GT ⇒ if D=Leaf then Node (Node AB b C) c D else case splay x D of Node D₁ d D₂ ⇒ Node (Node (Node AB b C) c D₁) d D₂)))" by (auto split!: tree.split (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) definition is_root :: "'a ⇒ 'a tree ⇒ bool" where "is_root x t = (case t of Leaf ⇒ False | Node l a r ⇒ x = a)" definition "isin t x = is_root x (splay x t)" definition empty :: "'a tree" where "empty = Leaf" hide_const (open) insert fun insert :: "'a::linorder ⇒ 'a tree ⇒ 'a tree" where "insert x t = (if t = Leaf then Node Leaf x Leaf else case splay x t of Node l a r ⇒ case cmp x a of EQ ⇒ Node l a r | LT ⇒ Node l x (Node Leaf a r) | GT ⇒ Node (Node l a Leaf) x r)" fun splay_max :: "'a tree ⇒ 'a tree" where "splay_max Leaf = Leaf" | "splay_max (Node A a Leaf) = Node A a Leaf" | "splay_max (Node A a (Node B b CD)) = (if CD = Leaf then Node (Node A a B) b Leaf else case splay_max CD of Node C c D ⇒ Node (Node (Node A a B) b C) c D)" lemma splay_max_code: "splay_max t = (case t of Leaf ⇒ t | Node la a ra ⇒ (case ra of Leaf ⇒ t | Node lb b rb ⇒ (if rb=Leaf then Node (Node la a lb) b rb else case splay_max rb of Node lc c rc ⇒ Node (Node (Node la a lb) b lc) c rc)))" by (auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) definition delete :: "'a::linorder ⇒ 'a tree ⇒ 'a tree" where "delete x t = (if t = Leaf then Leaf else case splay x t of Node l a r ⇒ if x ≠ a then Node l a r else if l = Leaf then r else case splay_max l of Node l' m r' ⇒ Node l' m r)" subsection "Functional Correctness Proofs I" text ‹This subsection follows the automated method by Nipkow \<^cite>‹"Nipkow-ITP16"›.› lemma splay_Leaf_iff[simp]: "(splay a t = Leaf) = (t = Leaf)" apply (induction a t rule: splay.induct (*‹⟦⋀x. ?P x ⟨⟩; ⋀x AB CD. ?P x ⟨AB, x, CD⟩; ⋀x b A B CD. x < b ⟹ ?P x ⟨⟨A, x, B⟩, b, CD⟩; ⋀x b CD. x < b ⟹ ?P x ⟨⟨⟩, b, CD⟩; ⋀x a b B CD. ⟦x < a; x < b⟧ ⟹ ?P x ⟨⟨⟨⟩, a, B⟩, b, CD⟩; ⋀x a b A B CD. ⟦x < a; x < b; A ≠ ⟨⟩; ?P x A⟧ ⟹ ?P x ⟨⟨A, a, B⟩, b, CD⟩; ⋀a x b A CD. ⟦a < x; x < b⟧ ⟹ ?P x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩; ⋀a x b B A CD. ⟦a < x; x < b; B ≠ ⟨⟩; ?P x B⟧ ⟹ ?P x ⟨⟨A, a, B⟩, b, CD⟩; ⋀b x AB C D. b < x ⟹ ?P x ⟨AB, b, ⟨C, x, D⟩⟩; ⋀b x AB. b < x ⟹ ?P x ⟨AB, b, ⟨⟩⟩; ⋀b x c C AB D. ⟦b < x; x < c; C ≠ ⟨⟩; ?P x C⟧ ⟹ ?P x ⟨AB, b, ⟨C, c, D⟩⟩; ⋀b x c AB D. ⟦b < x; x < c⟧ ⟹ ?P x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩; ⋀b x c AB C. ⟦b < x; c < x⟧ ⟹ ?P x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩; ⋀a x c D AB C. ⟦a < x; c < x; D ≠ ⟨⟩; ?P x D⟧ ⟹ ?P x ⟨AB, a, ⟨C, c, D⟩⟩⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀x. (splay x ⟨⟩ = ⟨⟩) = (⟨⟩ = ⟨⟩)› 2. ‹⋀x AB CD. (splay x ⟨AB, x, CD⟩ = ⟨⟩) = (⟨AB, x, CD⟩ = ⟨⟩)› 3. ‹⋀x b A B CD. x < b ⟹ (splay x ⟨⟨A, x, B⟩, b, CD⟩ = ⟨⟩) = (⟨⟨A, x, B⟩, b, CD⟩ = ⟨⟩)› 4. ‹⋀x b CD. x < b ⟹ (splay x ⟨⟨⟩, b, CD⟩ = ⟨⟩) = (⟨⟨⟩, b, CD⟩ = ⟨⟩)› 5. ‹⋀x a b B CD. ⟦x < a; x < b⟧ ⟹ (splay x ⟨⟨⟨⟩, a, B⟩, b, CD⟩ = ⟨⟩) = (⟨⟨⟨⟩, a, B⟩, b, CD⟩ = ⟨⟩)› 6. ‹⋀x a b A B CD. ⟦x < a; x < b; A ≠ ⟨⟩; (splay x A = ⟨⟩) = (A = ⟨⟩)⟧ ⟹ (splay x ⟨⟨A, a, B⟩, b, CD⟩ = ⟨⟩) = (⟨⟨A, a, B⟩, b, CD⟩ = ⟨⟩)› 7. ‹⋀a x b A CD. ⟦a < x; x < b⟧ ⟹ (splay x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩ = ⟨⟩) = (⟨⟨A, a, ⟨⟩⟩, b, CD⟩ = ⟨⟩)› 8. ‹⋀a x b B A CD. ⟦a < x; x < b; B ≠ ⟨⟩; (splay x B = ⟨⟩) = (B = ⟨⟩)⟧ ⟹ (splay x ⟨⟨A, a, B⟩, b, CD⟩ = ⟨⟩) = (⟨⟨A, a, B⟩, b, CD⟩ = ⟨⟩)› 9. ‹⋀b x AB C D. b < x ⟹ (splay x ⟨AB, b, ⟨C, x, D⟩⟩ = ⟨⟩) = (⟨AB, b, ⟨C, x, D⟩⟩ = ⟨⟩)› 10. ‹⋀b x AB. b < x ⟹ (splay x ⟨AB, b, ⟨⟩⟩ = ⟨⟩) = (⟨AB, b, ⟨⟩⟩ = ⟨⟩)› 11. ‹⋀b x c C AB D. ⟦b < x; x < c; C ≠ ⟨⟩; (splay x C = ⟨⟩) = (C = ⟨⟩)⟧ ⟹ (splay x ⟨AB, b, ⟨C, c, D⟩⟩ = ⟨⟩) = (⟨AB, b, ⟨C, c, D⟩⟩ = ⟨⟩)› 12. ‹⋀b x c AB D. ⟦b < x; x < c⟧ ⟹ (splay x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩ = ⟨⟩) = (⟨AB, b, ⟨⟨⟩, c, D⟩⟩ = ⟨⟩)› 13. ‹⋀b x c AB C. ⟦b < x; c < x⟧ ⟹ (splay x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩ = ⟨⟩) = (⟨AB, b, ⟨C, c, ⟨⟩⟩⟩ = ⟨⟩)› 14. ‹⋀a x c D AB C. ⟦a < x; c < x; D ≠ ⟨⟩; (splay x D = ⟨⟩) = (D = ⟨⟩)⟧ ⟹ (splay x ⟨AB, a, ⟨C, c, D⟩⟩ = ⟨⟩) = (⟨AB, a, ⟨C, c, D⟩⟩ = ⟨⟩)› discuss goal 1*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 2*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 3*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 4*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 5*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 6*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 7*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 8*) apply ((auto split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 9*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 10*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 11*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 12*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 13*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 14*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*proven 14 subgoals*) . lemma splay_max_Leaf_iff[simp]: "(splay_max t = Leaf) = (t = Leaf)" apply (induction t rule: splay_max.induct (*‹⟦?P ⟨⟩; ⋀A a. ?P ⟨A, a, ⟨⟩⟩; ⋀A a B b CD. (CD ≠ ⟨⟩ ⟹ ?P CD) ⟹ ?P ⟨A, a, ⟨B, b, CD⟩⟩⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹(splay_max ⟨⟩ = ⟨⟩) = (⟨⟩ = ⟨⟩)› 2. ‹⋀(A::'a tree) a::'a. (splay_max ⟨A, a, ⟨⟩⟩ = ⟨⟩) = (⟨A, a, ⟨⟩⟩ = ⟨⟩)› 3. ‹⋀(A::'a tree) (a::'a) (B::'a tree) (b::'a) CD::'a tree. (CD ≠ ⟨⟩ ⟹ (splay_max CD = ⟨⟩) = (CD = ⟨⟩)) ⟹ (splay_max ⟨A, a, ⟨B, b, CD⟩⟩ = ⟨⟩) = (⟨A, a, ⟨B, b, CD⟩⟩ = ⟨⟩)› discuss goal 1*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 2*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 3*) apply ((auto split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*proven 3 subgoals*) . subsubsection "Verification of @{const isin}" lemma splay_elemsD: "splay x t = Node l a r ⟹ sorted(inorder t) ⟹ x ∈ set (inorder t) ⟷ x=a" apply (induction x t arbitrary: l a r rule: splay.induct) (*goals: 1. ‹⋀x l a r. ⟦splay x ⟨⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟩)) = (x = a)› 2. ‹⋀x AB CD l a r. ⟦splay x ⟨AB, x, CD⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨AB, x, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, x, CD⟩)) = (x = a)› 3. ‹⋀x b A B CD l a r. ⟦x < b; splay x ⟨⟨A, x, B⟩, b, CD⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨⟨A, x, B⟩, b, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟨A, x, B⟩, b, CD⟩)) = (x = a)› 4. ‹⋀x b CD l a r. ⟦x < b; splay x ⟨⟨⟩, b, CD⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨⟨⟩, b, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟨⟩, b, CD⟩)) = (x = a)› 5. ‹⋀x a b B CD l aa r. ⟦x < a; x < b; splay x ⟨⟨⟨⟩, a, B⟩, b, CD⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨⟨⟨⟩, a, B⟩, b, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟨⟨⟩, a, B⟩, b, CD⟩)) = (x = aa)› 6. ‹⋀x a b A B CD l aa r. ⟦x < a; x < b; A ≠ ⟨⟩; ⋀l a r. ⟦splay x A = ⟨l, a, r⟩; Sorted_Less.sorted (inorder A)⟧ ⟹ (x ∈ set (inorder A)) = (x = a); splay x ⟨⟨A, a, B⟩, b, CD⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨⟨A, a, B⟩, b, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟨A, a, B⟩, b, CD⟩)) = (x = aa)› 7. ‹⋀a x b A CD l aa r. ⟦a < x; x < b; splay x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨⟨A, a, ⟨⟩⟩, b, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟨A, a, ⟨⟩⟩, b, CD⟩)) = (x = aa)› 8. ‹⋀a x b B A CD l aa r. ⟦a < x; x < b; B ≠ ⟨⟩; ⋀l a r. ⟦splay x B = ⟨l, a, r⟩; Sorted_Less.sorted (inorder B)⟧ ⟹ (x ∈ set (inorder B)) = (x = a); splay x ⟨⟨A, a, B⟩, b, CD⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨⟨A, a, B⟩, b, CD⟩)⟧ ⟹ (x ∈ set (inorder ⟨⟨A, a, B⟩, b, CD⟩)) = (x = aa)› 9. ‹⋀b x AB C D l a r. ⟦b < x; splay x ⟨AB, b, ⟨C, x, D⟩⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨AB, b, ⟨C, x, D⟩⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, b, ⟨C, x, D⟩⟩)) = (x = a)› 10. ‹⋀b x AB l a r. ⟦b < x; splay x ⟨AB, b, ⟨⟩⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨AB, b, ⟨⟩⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, b, ⟨⟩⟩)) = (x = a)› 11. ‹⋀b x c C AB D l a r. ⟦b < x; x < c; C ≠ ⟨⟩; ⋀l a r. ⟦splay x C = ⟨l, a, r⟩; Sorted_Less.sorted (inorder C)⟧ ⟹ (x ∈ set (inorder C)) = (x = a); splay x ⟨AB, b, ⟨C, c, D⟩⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨AB, b, ⟨C, c, D⟩⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, b, ⟨C, c, D⟩⟩)) = (x = a)› 12. ‹⋀b x c AB D l a r. ⟦b < x; x < c; splay x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨AB, b, ⟨⟨⟩, c, D⟩⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, b, ⟨⟨⟩, c, D⟩⟩)) = (x = a)› 13. ‹⋀b x c AB C l a r. ⟦b < x; c < x; splay x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩)) = (x = a)› 14. ‹⋀a x c D AB C l aa r. ⟦a < x; c < x; D ≠ ⟨⟩; ⋀l a r. ⟦splay x D = ⟨l, a, r⟩; Sorted_Less.sorted (inorder D)⟧ ⟹ (x ∈ set (inorder D)) = (x = a); splay x ⟨AB, a, ⟨C, c, D⟩⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨AB, a, ⟨C, c, D⟩⟩)⟧ ⟹ (x ∈ set (inorder ⟨AB, a, ⟨C, c, D⟩⟩)) = (x = aa)› discuss goal 1*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 2*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 3*) apply ((auto simp: isin_simps (*‹NO_MATCH [] (?ys::?'b list) ⟹ Sorted_Less.sorted ((?xs::?'b list) @ (?y::?'b) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list)) = ((∀y::?'a∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted ((?xs::?'a list) @ [?x::?'a]) = (Sorted_Less.sorted ?xs ∧ (∀y::?'a∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x::?'a∈(?A::?'a set) ∪ (?B::?'a set). (?P::?'a ⇒ bool) x) = ((∀x::?'a∈?A. ?P x) ∧ (∀x::?'a∈?B. ?P x))›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 4*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 5*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 6*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 7*) apply ((auto simp: isin_simps (*‹NO_MATCH [] (?ys::?'b list) ⟹ Sorted_Less.sorted ((?xs::?'b list) @ (?y::?'b) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list)) = ((∀y::?'a∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted ((?xs::?'a list) @ [?x::?'a]) = (Sorted_Less.sorted ?xs ∧ (∀y::?'a∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x::?'a∈(?A::?'a set) ∪ (?B::?'a set). (?P::?'a ⇒ bool) x) = ((∀x::?'a∈?A. ?P x) ∧ (∀x::?'a∈?B. ?P x))›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 8*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 9*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 10*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 11*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 12*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 13*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 14*) apply ((auto simp: isin_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)› ‹Sorted_Less.sorted (?xs @ [?x]) = (Sorted_Less.sorted ?xs ∧ (∀y∈set ?xs. y < ?x))›*) ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*proven 14 subgoals*) . lemma isin_set: "sorted(inorder t) ⟹ isin t x = (x ∈ set (inorder t))" by (auto simp: isin_def (*‹isin (?t::?'a tree) (?x::?'a) = is_root ?x (splay ?x ?t)›*) is_root_def (*‹is_root (?x::?'a) (?t::?'a tree) = (case ?t of ⟨⟩ ⇒ False | ⟨l::?'a tree, a::?'a, r::?'a tree⟩ ⇒ ?x = a)›*) dest: splay_elemsD (*‹⟦splay (?x::?'a) (?t::?'a tree) = ⟨?l::?'a tree, ?a::?'a, ?r::?'a tree⟩; Sorted_Less.sorted (inorder ?t)⟧ ⟹ (?x ∈ set (inorder ?t)) = (?x = ?a)›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*)) subsubsection "Verification of @{const insert}" lemma inorder_splay: "inorder(splay x t) = inorder t" apply (induction x t rule: splay.induct (*‹⟦⋀x. ?P x ⟨⟩; ⋀x AB CD. ?P x ⟨AB, x, CD⟩; ⋀x b A B CD. x < b ⟹ ?P x ⟨⟨A, x, B⟩, b, CD⟩; ⋀x b CD. x < b ⟹ ?P x ⟨⟨⟩, b, CD⟩; ⋀x a b B CD. ⟦x < a; x < b⟧ ⟹ ?P x ⟨⟨⟨⟩, a, B⟩, b, CD⟩; ⋀x a b A B CD. ⟦x < a; x < b; A ≠ ⟨⟩; ?P x A⟧ ⟹ ?P x ⟨⟨A, a, B⟩, b, CD⟩; ⋀a x b A CD. ⟦a < x; x < b⟧ ⟹ ?P x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩; ⋀a x b B A CD. ⟦a < x; x < b; B ≠ ⟨⟩; ?P x B⟧ ⟹ ?P x ⟨⟨A, a, B⟩, b, CD⟩; ⋀b x AB C D. b < x ⟹ ?P x ⟨AB, b, ⟨C, x, D⟩⟩; ⋀b x AB. b < x ⟹ ?P x ⟨AB, b, ⟨⟩⟩; ⋀b x c C AB D. ⟦b < x; x < c; C ≠ ⟨⟩; ?P x C⟧ ⟹ ?P x ⟨AB, b, ⟨C, c, D⟩⟩; ⋀b x c AB D. ⟦b < x; x < c⟧ ⟹ ?P x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩; ⋀b x c AB C. ⟦b < x; c < x⟧ ⟹ ?P x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩; ⋀a x c D AB C. ⟦a < x; c < x; D ≠ ⟨⟩; ?P x D⟧ ⟹ ?P x ⟨AB, a, ⟨C, c, D⟩⟩⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀x. inorder (splay x ⟨⟩) = inorder ⟨⟩› 2. ‹⋀x AB CD. inorder (splay x ⟨AB, x, CD⟩) = inorder ⟨AB, x, CD⟩› 3. ‹⋀x b A B CD. x < b ⟹ inorder (splay x ⟨⟨A, x, B⟩, b, CD⟩) = inorder ⟨⟨A, x, B⟩, b, CD⟩› 4. ‹⋀x b CD. x < b ⟹ inorder (splay x ⟨⟨⟩, b, CD⟩) = inorder ⟨⟨⟩, b, CD⟩› 5. ‹⋀x a b B CD. ⟦x < a; x < b⟧ ⟹ inorder (splay x ⟨⟨⟨⟩, a, B⟩, b, CD⟩) = inorder ⟨⟨⟨⟩, a, B⟩, b, CD⟩› 6. ‹⋀x a b A B CD. ⟦x < a; x < b; A ≠ ⟨⟩; inorder (splay x A) = inorder A⟧ ⟹ inorder (splay x ⟨⟨A, a, B⟩, b, CD⟩) = inorder ⟨⟨A, a, B⟩, b, CD⟩› 7. ‹⋀a x b A CD. ⟦a < x; x < b⟧ ⟹ inorder (splay x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩) = inorder ⟨⟨A, a, ⟨⟩⟩, b, CD⟩› 8. ‹⋀a x b B A CD. ⟦a < x; x < b; B ≠ ⟨⟩; inorder (splay x B) = inorder B⟧ ⟹ inorder (splay x ⟨⟨A, a, B⟩, b, CD⟩) = inorder ⟨⟨A, a, B⟩, b, CD⟩› 9. ‹⋀b x AB C D. b < x ⟹ inorder (splay x ⟨AB, b, ⟨C, x, D⟩⟩) = inorder ⟨AB, b, ⟨C, x, D⟩⟩› 10. ‹⋀b x AB. b < x ⟹ inorder (splay x ⟨AB, b, ⟨⟩⟩) = inorder ⟨AB, b, ⟨⟩⟩› 11. ‹⋀b x c C AB D. ⟦b < x; x < c; C ≠ ⟨⟩; inorder (splay x C) = inorder C⟧ ⟹ inorder (splay x ⟨AB, b, ⟨C, c, D⟩⟩) = inorder ⟨AB, b, ⟨C, c, D⟩⟩› 12. ‹⋀b x c AB D. ⟦b < x; x < c⟧ ⟹ inorder (splay x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩) = inorder ⟨AB, b, ⟨⟨⟩, c, D⟩⟩› 13. ‹⋀b x c AB C. ⟦b < x; c < x⟧ ⟹ inorder (splay x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩) = inorder ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩› 14. ‹⋀a x c D AB C. ⟦a < x; c < x; D ≠ ⟨⟩; inorder (splay x D) = inorder D⟧ ⟹ inorder (splay x ⟨AB, a, ⟨C, c, D⟩⟩) = inorder ⟨AB, a, ⟨C, c, D⟩⟩› discuss goal 1*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 2*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 3*) apply ((auto simp: neq_Leaf_iff (*‹((?t::?'a tree) ≠ ⟨⟩) = (∃(l::?'a tree) (a::?'a) r::?'a tree. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 4*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 5*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 6*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 7*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 8*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 9*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 10*) apply ((auto simp: neq_Leaf_iff (*‹((?t::?'a::type tree) ≠ ⟨⟩) = (∃(l::?'a::type tree) (a::?'a::type) r::?'a::type tree. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹(?P::?'b::type ⇒ bool) (case ?tree::?'a::type tree of ⟨⟩ ⇒ ?f1.0::?'b::type | ⟨x::?'a::type tree, xa::?'a::type, xb::?'a::type tree⟩ ⇒ (?f2.0::?'a::type tree ⇒ ?'a::type ⇒ ?'a::type tree ⇒ ?'b::type) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a::type tree) (x22::?'a::type) x23::?'a::type tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 11*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 12*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 13*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*discuss goal 14*) apply ((auto simp: neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*))[1]) (*proven 14 subgoals*) . lemma sorted_splay: "sorted(inorder t) ⟹ splay x t = Node l a r ⟹ sorted(inorder l @ x # inorder r)" unfolding inorder_splay[of x t, symmetric] (*goal: ‹⟦Sorted_Less.sorted (inorder (splay x t)); splay x t = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)›*) apply (induction x t arbitrary: l a r rule: splay.induct) (*goals: 1. ‹⋀x l a r. ⟦Sorted_Less.sorted (inorder (splay x ⟨⟩)); splay x ⟨⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 2. ‹⋀x AB CD l a r. ⟦Sorted_Less.sorted (inorder (splay x ⟨AB, x, CD⟩)); splay x ⟨AB, x, CD⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 3. ‹⋀x b A B CD l a r. ⟦x < b; Sorted_Less.sorted (inorder (splay x ⟨⟨A, x, B⟩, b, CD⟩)); splay x ⟨⟨A, x, B⟩, b, CD⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 4. ‹⋀x b CD l a r. ⟦x < b; Sorted_Less.sorted (inorder (splay x ⟨⟨⟩, b, CD⟩)); splay x ⟨⟨⟩, b, CD⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 5. ‹⋀x a b B CD l aa r. ⟦x < a; x < b; Sorted_Less.sorted (inorder (splay x ⟨⟨⟨⟩, a, B⟩, b, CD⟩)); splay x ⟨⟨⟨⟩, a, B⟩, b, CD⟩ = ⟨l, aa, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 6. ‹⋀x a b A B CD l aa r. ⟦x < a; x < b; A ≠ ⟨⟩; ⋀l a r. ⟦Sorted_Less.sorted (inorder (splay x A)); splay x A = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r); Sorted_Less.sorted (inorder (splay x ⟨⟨A, a, B⟩, b, CD⟩)); splay x ⟨⟨A, a, B⟩, b, CD⟩ = ⟨l, aa, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 7. ‹⋀a x b A CD l aa r. ⟦a < x; x < b; Sorted_Less.sorted (inorder (splay x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩)); splay x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩ = ⟨l, aa, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 8. ‹⋀a x b B A CD l aa r. ⟦a < x; x < b; B ≠ ⟨⟩; ⋀l a r. ⟦Sorted_Less.sorted (inorder (splay x B)); splay x B = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r); Sorted_Less.sorted (inorder (splay x ⟨⟨A, a, B⟩, b, CD⟩)); splay x ⟨⟨A, a, B⟩, b, CD⟩ = ⟨l, aa, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 9. ‹⋀b x AB C D l a r. ⟦b < x; Sorted_Less.sorted (inorder (splay x ⟨AB, b, ⟨C, x, D⟩⟩)); splay x ⟨AB, b, ⟨C, x, D⟩⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 10. ‹⋀b x AB l a r. ⟦b < x; Sorted_Less.sorted (inorder (splay x ⟨AB, b, ⟨⟩⟩)); splay x ⟨AB, b, ⟨⟩⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 11. ‹⋀b x c C AB D l a r. ⟦b < x; x < c; C ≠ ⟨⟩; ⋀l a r. ⟦Sorted_Less.sorted (inorder (splay x C)); splay x C = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r); Sorted_Less.sorted (inorder (splay x ⟨AB, b, ⟨C, c, D⟩⟩)); splay x ⟨AB, b, ⟨C, c, D⟩⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 12. ‹⋀b x c AB D l a r. ⟦b < x; x < c; Sorted_Less.sorted (inorder (splay x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩)); splay x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 13. ‹⋀b x c AB C l a r. ⟦b < x; c < x; Sorted_Less.sorted (inorder (splay x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩)); splay x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩ = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› 14. ‹⋀a x c D AB C l aa r. ⟦a < x; c < x; D ≠ ⟨⟩; ⋀l a r. ⟦Sorted_Less.sorted (inorder (splay x D)); splay x D = ⟨l, a, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r); Sorted_Less.sorted (inorder (splay x ⟨AB, a, ⟨C, c, D⟩⟩)); splay x ⟨AB, a, ⟨C, c, D⟩⟩ = ⟨l, aa, r⟩⟧ ⟹ Sorted_Less.sorted (inorder l @ x # inorder r)› discuss goal 1*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 2*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 3*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 4*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] (?ys::?'b list) ⟹ Sorted_Less.sorted ((?xs::?'b list) @ (?y::?'b) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list) @ (?y::?'a) # (?ys::?'a list)) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?y::?'a])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))); (?y::?'a) ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?x::?'a])); ?x ≤ (?y::?'a)⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 5*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 6*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] (?ys::?'b list) ⟹ Sorted_Less.sorted ((?xs::?'b list) @ (?y::?'b) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list) @ (?y::?'a) # (?ys::?'a list)) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?y::?'a])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))); (?y::?'a) ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?x::?'a])); ?x ≤ (?y::?'a)⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 7*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 8*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 9*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 10*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 11*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 12*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 13*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] (?ys::?'b list) ⟹ Sorted_Less.sorted ((?xs::?'b list) @ (?y::?'b) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list) @ (?y::?'a) # (?ys::?'a list)) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?y::?'a])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))); (?y::?'a) ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?x::?'a])); ?x ≤ (?y::?'a)⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*discuss goal 14*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) sorted_Cons_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?x # ?xs)); ?y ≤ ?x⟧ ⟹ Sorted_Less.sorted (?y # ?xs)›*) sorted_snoc_le (*‹⟦ASSUMPTION (Sorted_Less.sorted (?xs @ [?x])); ?x ≤ ?y⟧ ⟹ Sorted_Less.sorted (?xs @ [?y])›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*))[1]) (*proven 14 subgoals*) . lemma inorder_insert: "sorted(inorder t) ⟹ inorder(insert x t) = ins_list x (inorder t)" using inorder_splay[of x t, symmetric] (*‹inorder t = inorder (splay x t)›*) sorted_splay[of t x] (*‹⟦Sorted_Less.sorted (inorder t); splay x t = ⟨?l, ?a, ?r⟩⟧ ⟹ Sorted_Less.sorted (inorder ?l @ x # inorder ?r)›*) by (auto simp: ins_list_simps (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs› ‹⟦Sorted_Less.sorted (?xs @ [?a]); ?a ≤ ?x⟧ ⟹ ins_list ?x (?xs @ ?a # ?ys) = ?xs @ ins_list ?x (?a # ?ys)› ‹⟦Sorted_Less.sorted (?xs @ [?a]); ?x < ?a⟧ ⟹ ins_list ?x (?xs @ ?a # ?ys) = ins_list ?x ?xs @ ?a # ?ys›*) ins_list_Cons (*‹Sorted_Less.sorted (?x # ?xs) ⟹ ins_list ?x ?xs = ?x # ?xs›*) ins_list_snoc (*‹Sorted_Less.sorted (?xs @ [?x]) ⟹ ins_list ?x ?xs = ?xs @ [?x]›*) neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) subsubsection "Verification of @{const delete}" lemma inorder_splay_maxD: "splay_max t = Node l a r ⟹ sorted(inorder t) ⟹ inorder l @ [a] = inorder t ∧ r = Leaf" apply (induction t arbitrary: l a r rule: splay_max.induct) (*goals: 1. ‹⋀(l::'a::linorder tree) (a::'a::linorder) r::'a::linorder tree. ⟦splay_max ⟨⟩ = ⟨l, a, r⟩; Sorted_Less.sorted (inorder ⟨⟩)⟧ ⟹ inorder l @ [a] = inorder ⟨⟩ ∧ r = ⟨⟩› 2. ‹⋀(A::'a::linorder tree) (a::'a::linorder) (l::'a::linorder tree) (aa::'a::linorder) r::'a::linorder tree. ⟦splay_max ⟨A, a, ⟨⟩⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨A, a, ⟨⟩⟩)⟧ ⟹ inorder l @ [aa] = inorder ⟨A, a, ⟨⟩⟩ ∧ r = ⟨⟩› 3. ‹⋀(A::'a::linorder tree) (a::'a::linorder) (B::'a::linorder tree) (b::'a::linorder) (CD::'a::linorder tree) (l::'a::linorder tree) (aa::'a::linorder) r::'a::linorder tree. ⟦⋀(l::'a::linorder tree) (a::'a::linorder) r::'a::linorder tree. ⟦CD ≠ ⟨⟩; splay_max CD = ⟨l, a, r⟩; Sorted_Less.sorted (inorder CD)⟧ ⟹ inorder l @ [a] = inorder CD ∧ r = ⟨⟩; splay_max ⟨A, a, ⟨B, b, CD⟩⟩ = ⟨l, aa, r⟩; Sorted_Less.sorted (inorder ⟨A, a, ⟨B, b, CD⟩⟩)⟧ ⟹ inorder l @ [aa] = inorder ⟨A, a, ⟨B, b, CD⟩⟩ ∧ r = ⟨⟩› discuss goal 1*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] ?ys ⟹ Sorted_Less.sorted (?xs @ ?y # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted (?x # ?xs @ ?y # ?ys) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted (?x # ?xs)) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted (?xs @ [?y])) ⟹ Sorted_Less.sorted ?xs›*) split: tree.splits (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 3*) apply ((auto simp: sorted_lems (*‹NO_MATCH [] (?ys::?'b::linorder list) ⟹ Sorted_Less.sorted ((?xs::?'b::linorder list) @ (?y::?'b::linorder) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a::linorder) # (?xs::?'a::linorder list) @ (?y::?'a::linorder) # (?ys::?'a::linorder list)) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted ((?x::?'a::linorder) # (?xs::?'a::linorder list))) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted ((?xs::?'a::linorder list) @ [?y::?'a::linorder])) ⟹ Sorted_Less.sorted ?xs›*) split: tree.splits (*‹(?P::?'b::type ⇒ bool) (case ?tree::?'a::type tree of ⟨⟩ ⇒ ?f1.0::?'b::type | ⟨x::?'a::type tree, xa::?'a::type, xb::?'a::type tree⟩ ⇒ (?f2.0::?'a::type tree ⇒ ?'a::type ⇒ ?'a::type tree ⇒ ?'b::type) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a::type tree) (x22::?'a::type) x23::?'a::type tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b::type ⇒ bool) (case ?tree::?'a::type tree of ⟨⟩ ⇒ ?f1.0::?'b::type | ⟨x::?'a::type tree, xa::?'a::type, xb::?'a::type tree⟩ ⇒ (?f2.0::?'a::type tree ⇒ ?'a::type ⇒ ?'a::type tree ⇒ ?'b::type) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a::type tree) (x22::?'a::type) x23::?'a::type tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*) if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 3 subgoals*) . lemma inorder_delete: "sorted(inorder t) ⟹ inorder(delete x t) = del_list x (inorder t)" using inorder_splay[of x t, symmetric] (*‹inorder t = inorder (splay x t)›*) sorted_splay[of t x] (*‹⟦Sorted_Less.sorted (inorder (t::'a::linorder tree)); splay (x::'a::linorder) t = ⟨?l::'a::linorder tree, ?a::'a::linorder, ?r::'a::linorder tree⟩⟧ ⟹ Sorted_Less.sorted (inorder ?l @ x # inorder ?r)›*) by (auto simp: del_list_simps (*‹NO_MATCH [] (?ys::?'b list) ⟹ Sorted_Less.sorted ((?xs::?'b list) @ (?y::?'b) # ?ys) = (Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list) @ (?y::?'a) # (?ys::?'a list)) = (Sorted_Less.sorted (?x # ?xs) ∧ ?x < ?y ∧ Sorted_Less.sorted (?xs @ [?y]) ∧ Sorted_Less.sorted (?y # ?ys))› ‹ASSUMPTION (Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list))) ⟹ Sorted_Less.sorted ?xs› ‹ASSUMPTION (Sorted_Less.sorted ((?xs::?'a list) @ [?y::?'a])) ⟹ Sorted_Less.sorted ?xs› ‹⟦Sorted_Less.sorted ((?xs::?'a list) @ (?a::?'a) # (?ys::?'a list)); ?a ≤ (?x::?'a)⟧ ⟹ del_list ?x (?xs @ ?a # ?ys) = ?xs @ del_list ?x (?a # ?ys)› ‹⟦Sorted_Less.sorted ((?xs::?'a list) @ (?a::?'a) # (?ys::?'a list)); (?x::?'a) < ?a⟧ ⟹ del_list ?x (?xs @ ?a # ?ys) = del_list ?x ?xs @ ?a # ?ys› ‹⟦Sorted_Less.sorted ((?xs::?'a list) @ (?a::?'a) # (?ys::?'a list) @ (?b::?'a) # (?zs::?'a list)); (?x::?'a) < ?b⟧ ⟹ del_list ?x (?xs @ ?a # ?ys @ ?b # ?zs) = del_list ?x (?xs @ ?a # ?ys) @ ?b # ?zs› ‹⟦Sorted_Less.sorted ((?xs::?'a list) @ (?a::?'a) # (?ys::?'a list) @ (?b::?'a) # (?zs::?'a list) @ (?c::?'a) # (?us::?'a list)); (?x::?'a) < ?c⟧ ⟹ del_list ?x (?xs @ ?a # ?ys @ ?b # ?zs @ ?c # ?us) = del_list ?x (?xs @ ?a # ?ys @ ?b # ?zs) @ ?c # ?us› ‹⟦Sorted_Less.sorted ((?xs::?'a list) @ (?a::?'a) # (?ys::?'a list) @ (?b::?'a) # (?zs::?'a list) @ (?c::?'a) # (?us::?'a list) @ (?d::?'a) # (?vs::?'a list)); (?x::?'a) < ?d⟧ ⟹ del_list ?x (?xs @ ?a # ?ys @ ?b # ?zs @ ?c # ?us @ ?d # ?vs) = del_list ?x (?xs @ ?a # ?ys @ ?b # ?zs @ ?c # ?us) @ ?d # ?vs›*) del_list_sorted_app (*‹Sorted_Less.sorted ((?xs::?'a list) @ [?x::?'a]) ⟹ del_list ?x (?xs @ (?ys::?'a list)) = ?xs @ del_list ?x ?ys›*) delete_def (*‹delete (?x::?'a) (?t::?'a tree) = (if ?t = ⟨⟩ then ⟨⟩ else case splay ?x ?t of ⟨l::?'a tree, a::?'a, r::?'a tree⟩ ⇒ if ?x ≠ a then ⟨l, a, r⟩ else if l = ⟨⟩ then r else case splay_max l of ⟨l'::?'a tree, m::?'a, r'::?'a tree⟩ ⇒ ⟨l', m, r⟩)›*) del_list_notin_Cons (*‹Sorted_Less.sorted ((?x::?'a) # (?xs::?'a list)) ⟹ del_list ?x ?xs = ?xs›*) inorder_splay_maxD (*‹⟦splay_max (?t::?'a tree) = ⟨?l::?'a tree, ?a::?'a, ?r::?'a tree⟩; Sorted_Less.sorted (inorder ?t)⟧ ⟹ inorder ?l @ [?a] = inorder ?t ∧ ?r = ⟨⟩›*) split: tree.splits (*‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))› ‹(?P::?'b ⇒ bool) (case ?tree::?'a tree of ⟨⟩ ⇒ ?f1.0::?'b | ⟨x::?'a tree, xa::?'a, xb::?'a tree⟩ ⇒ (?f2.0::?'a tree ⇒ ?'a ⇒ ?'a tree ⇒ ?'b) x xa xb) = (¬ (?tree = ⟨⟩ ∧ ¬ ?P ?f1.0 ∨ (∃(x21::?'a tree) (x22::?'a) x23::?'a tree. ?tree = ⟨x21, x22, x23⟩ ∧ ¬ ?P (?f2.0 x21 x22 x23))))›*)) subsubsection "Overall Correctness" interpretation splay: Set_by_Ordered where empty = empty and isin = isin and insert = insert and delete = delete and inorder = inorder and inv = "λ_. True" proof (standard, goal_cases) (*goals: 1. ‹inorder Splay_Tree.empty = []› 2. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ isin t x = (x ∈ set (inorder t))› 3. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ inorder (insert x t) = ins_list x (inorder t)› 4. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ inorder (delete x t) = del_list x (inorder t)› 5. ‹True› 6. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ True›*) case 2 (*‹True ∧ Sorted_Less.sorted (inorder t_)›*) thus "?case" (*goal: ‹isin t_ x_ = (x_ ∈ set (inorder t_))›*) by (simp add: isin_set (*‹Sorted_Less.sorted (inorder ?t) ⟹ isin ?t ?x = (?x ∈ set (inorder ?t))›*)) next (*goals: 1. ‹inorder Splay_Tree.empty = []› 2. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ inorder (insert x t) = ins_list x (inorder t)› 3. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ inorder (delete x t) = del_list x (inorder t)› 4. ‹True› 5. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ True›*) case 3 (*‹True ∧ Sorted_Less.sorted (inorder (t_::'a tree))›*) thus "?case" (*goal: ‹inorder (insert x_ t_) = ins_list x_ (inorder t_)›*) by (simp add: inorder_insert (*‹Sorted_Less.sorted (inorder ?t) ⟹ inorder (insert ?x ?t) = ins_list ?x (inorder ?t)›*) del: insert.simps (*‹insert ?x ?t = (if ?t = ⟨⟩ then ⟨⟨⟩, ?x, ⟨⟩⟩ else case splay ?x ?t of ⟨l, a, r⟩ ⇒ case cmp ?x a of LT ⇒ ⟨l, ?x, ⟨⟨⟩, a, r⟩⟩ | EQ ⇒ ⟨l, a, r⟩ | GT ⇒ ⟨⟨l, a, ⟨⟩⟩, ?x, r⟩)›*)) next (*goals: 1. ‹inorder Splay_Tree.empty = []› 2. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ inorder (delete x t) = del_list x (inorder t)› 3. ‹True› 4. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ True›*) case 4 (*‹True ∧ Sorted_Less.sorted (inorder (t_::'a tree))›*) thus "?case" (*goal: ‹inorder (delete x_ t_) = del_list x_ (inorder t_)›*) by (simp add: inorder_delete (*‹Sorted_Less.sorted (inorder ?t) ⟹ inorder (delete ?x ?t) = del_list ?x (inorder ?t)›*)) qed (auto simp: empty_def (*‹Splay_Tree.empty = ⟨⟩›*)) (*solves the remaining goals: 1. ‹inorder Splay_Tree.empty = []› 2. ‹True› 3. ‹⋀t x. True ∧ Sorted_Less.sorted (inorder t) ⟹ True›*) text ‹Corollaries:› lemma bst_splay: "bst t ⟹ bst (splay x t)" by (simp add: bst_iff_sorted_wrt_less (*‹bst ?t = Sorted_Less.sorted (inorder ?t)›*) inorder_splay (*‹inorder (splay ?x ?t) = inorder ?t›*)) lemma bst_insert: "bst t ⟹ bst(insert x t)" using splay.invar_insert[of t x] (*‹splay.invar (t::'a tree) ⟹ splay.invar (insert (x::'a) t)›*) by (simp add: bst_iff_sorted_wrt_less (*‹bst (?t::?'a tree) = Sorted_Less.sorted (inorder ?t)›*) splay.invar_def (*‹splay.invar (?t::?'a tree) = (True ∧ Sorted_Less.sorted (inorder ?t))›*)) lemma bst_delete: "bst t ⟹ bst(delete x t)" using splay.invar_delete[of t x] (*‹splay.invar t ⟹ splay.invar (delete x t)›*) by (simp add: bst_iff_sorted_wrt_less (*‹bst ?t = Sorted_Less.sorted (inorder ?t)›*) splay.invar_def (*‹splay.invar ?t = (True ∧ Sorted_Less.sorted (inorder ?t))›*)) lemma splay_bstL: "bst t ⟹ splay a t = Node l e r ⟹ x ∈ set_tree l ⟹ x < a" by (metis bst_iff_sorted_wrt_less (*‹bst ?t = Sorted_Less.sorted (inorder ?t)›*) list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1) set_inorder (*‹set (inorder ?t) = set_tree ?t›*) sorted_splay (*‹⟦Sorted_Less.sorted (inorder ?t); splay ?x ?t = ⟨?l, ?a, ?r⟩⟧ ⟹ Sorted_Less.sorted (inorder ?l @ ?x # inorder ?r)›*) sorted_wrt_append (*‹sorted_wrt ?P (?xs @ ?ys) = (sorted_wrt ?P ?xs ∧ sorted_wrt ?P ?ys ∧ (∀x∈set ?xs. ∀y∈set ?ys. ?P x y))›*)) lemma splay_bstR: "bst t ⟹ splay a t = Node l e r ⟹ x ∈ set_tree r ⟹ a < x" by (metis bst_iff_sorted_wrt_less (*‹bst ?t = Sorted_Less.sorted (inorder ?t)›*) sorted_Cons_iff (*‹Sorted_Less.sorted (?x # ?xs) = ((∀y∈set ?xs. ?x < y) ∧ Sorted_Less.sorted ?xs)›*) set_inorder (*‹set (inorder ?t) = set_tree ?t›*) sorted_splay (*‹⟦Sorted_Less.sorted (inorder ?t); splay ?x ?t = ⟨?l, ?a, ?r⟩⟧ ⟹ Sorted_Less.sorted (inorder ?l @ ?x # inorder ?r)›*) sorted_wrt_append (*‹sorted_wrt ?P (?xs @ ?ys) = (sorted_wrt ?P ?xs ∧ sorted_wrt ?P ?ys ∧ (∀x∈set ?xs. ∀y∈set ?ys. ?P x y))›*)) subsubsection "Size lemmas" lemma size_splay[simp]: "size (splay a t) = size t" apply (induction a t rule: splay.induct (*‹⟦⋀x. ?P x ⟨⟩; ⋀x AB CD. ?P x ⟨AB, x, CD⟩; ⋀x b A B CD. x < b ⟹ ?P x ⟨⟨A, x, B⟩, b, CD⟩; ⋀x b CD. x < b ⟹ ?P x ⟨⟨⟩, b, CD⟩; ⋀x a b B CD. ⟦x < a; x < b⟧ ⟹ ?P x ⟨⟨⟨⟩, a, B⟩, b, CD⟩; ⋀x a b A B CD. ⟦x < a; x < b; A ≠ ⟨⟩; ?P x A⟧ ⟹ ?P x ⟨⟨A, a, B⟩, b, CD⟩; ⋀a x b A CD. ⟦a < x; x < b⟧ ⟹ ?P x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩; ⋀a x b B A CD. ⟦a < x; x < b; B ≠ ⟨⟩; ?P x B⟧ ⟹ ?P x ⟨⟨A, a, B⟩, b, CD⟩; ⋀b x AB C D. b < x ⟹ ?P x ⟨AB, b, ⟨C, x, D⟩⟩; ⋀b x AB. b < x ⟹ ?P x ⟨AB, b, ⟨⟩⟩; ⋀b x c C AB D. ⟦b < x; x < c; C ≠ ⟨⟩; ?P x C⟧ ⟹ ?P x ⟨AB, b, ⟨C, c, D⟩⟩; ⋀b x c AB D. ⟦b < x; x < c⟧ ⟹ ?P x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩; ⋀b x c AB C. ⟦b < x; c < x⟧ ⟹ ?P x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩; ⋀a x c D AB C. ⟦a < x; c < x; D ≠ ⟨⟩; ?P x D⟧ ⟹ ?P x ⟨AB, a, ⟨C, c, D⟩⟩⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀x::'a. size (splay x ⟨⟩) = size ⟨⟩› 2. ‹⋀(x::'a) (AB::'a tree) CD::'a tree. size (splay x ⟨AB, x, CD⟩) = size ⟨AB, x, CD⟩› 3. ‹⋀(x::'a) (b::'a) (A::'a tree) (B::'a tree) CD::'a tree. x < b ⟹ size (splay x ⟨⟨A, x, B⟩, b, CD⟩) = size ⟨⟨A, x, B⟩, b, CD⟩› 4. ‹⋀(x::'a) (b::'a) CD::'a tree. x < b ⟹ size (splay x ⟨⟨⟩, b, CD⟩) = size ⟨⟨⟩, b, CD⟩› 5. ‹⋀(x::'a) (a::'a) (b::'a) (B::'a tree) CD::'a tree. ⟦x < a; x < b⟧ ⟹ size (splay x ⟨⟨⟨⟩, a, B⟩, b, CD⟩) = size ⟨⟨⟨⟩, a, B⟩, b, CD⟩› 6. ‹⋀(x::'a) (a::'a) (b::'a) (A::'a tree) (B::'a tree) CD::'a tree. ⟦x < a; x < b; A ≠ ⟨⟩; size (splay x A) = size A⟧ ⟹ size (splay x ⟨⟨A, a, B⟩, b, CD⟩) = size ⟨⟨A, a, B⟩, b, CD⟩› 7. ‹⋀(a::'a) (x::'a) (b::'a) (A::'a tree) CD::'a tree. ⟦a < x; x < b⟧ ⟹ size (splay x ⟨⟨A, a, ⟨⟩⟩, b, CD⟩) = size ⟨⟨A, a, ⟨⟩⟩, b, CD⟩› 8. ‹⋀(a::'a) (x::'a) (b::'a) (B::'a tree) (A::'a tree) CD::'a tree. ⟦a < x; x < b; B ≠ ⟨⟩; size (splay x B) = size B⟧ ⟹ size (splay x ⟨⟨A, a, B⟩, b, CD⟩) = size ⟨⟨A, a, B⟩, b, CD⟩› 9. ‹⋀(b::'a) (x::'a) (AB::'a tree) (C::'a tree) D::'a tree. b < x ⟹ size (splay x ⟨AB, b, ⟨C, x, D⟩⟩) = size ⟨AB, b, ⟨C, x, D⟩⟩› 10. ‹⋀(b::'a) (x::'a) AB::'a tree. b < x ⟹ size (splay x ⟨AB, b, ⟨⟩⟩) = size ⟨AB, b, ⟨⟩⟩› 11. ‹⋀(b::'a) (x::'a) (c::'a) (C::'a tree) (AB::'a tree) D::'a tree. ⟦b < x; x < c; C ≠ ⟨⟩; size (splay x C) = size C⟧ ⟹ size (splay x ⟨AB, b, ⟨C, c, D⟩⟩) = size ⟨AB, b, ⟨C, c, D⟩⟩› 12. ‹⋀(b::'a) (x::'a) (c::'a) (AB::'a tree) D::'a tree. ⟦b < x; x < c⟧ ⟹ size (splay x ⟨AB, b, ⟨⟨⟩, c, D⟩⟩) = size ⟨AB, b, ⟨⟨⟩, c, D⟩⟩› 13. ‹⋀(b::'a) (x::'a) (c::'a) (AB::'a tree) C::'a tree. ⟦b < x; c < x⟧ ⟹ size (splay x ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩) = size ⟨AB, b, ⟨C, c, ⟨⟩⟩⟩› 14. ‹⋀(a::'a) (x::'a) (c::'a) (D::'a tree) (AB::'a tree) C::'a tree. ⟦a < x; c < x; D ≠ ⟨⟩; size (splay x D) = size D⟧ ⟹ size (splay x ⟨AB, a, ⟨C, c, D⟩⟩) = size ⟨AB, a, ⟨C, c, D⟩⟩› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*top goal: ‹⋀x a b A B CD. ⟦x < a; x < b; A ≠ ⟨⟩; size (splay x A) = size A⟧ ⟹ size (splay x ⟨⟨A, a, B⟩, b, CD⟩) = size ⟨⟨A, a, B⟩, b, CD⟩› and 8 goals remain*) apply (force split: tree.split (*‹(?P::?'b::type ⇒ bool) (case ?tree::?'a::type tree of ⟨⟩ ⇒ ?f1.0::?'b::type | ⟨x::?'a::type tree, xa::?'a::type, xb::?'a::type tree⟩ ⇒ (?f2.0::?'a::type tree ⇒ ?'a::type ⇒ ?'a::type tree ⇒ ?'b::type) x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀(x21::?'a::type tree) (x22::?'a::type) x23::?'a::type tree. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*top goal: ‹⋀a x b B A CD. ⟦a < x; x < b; B ≠ ⟨⟩; size (splay x B) = size B⟧ ⟹ size (splay x ⟨⟨A, a, B⟩, b, CD⟩) = size ⟨⟨A, a, B⟩, b, CD⟩› and 6 goals remain*) apply (force split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*top goal: ‹⋀b x c C AB D. ⟦b < x; x < c; C ≠ ⟨⟩; size (splay x C) = size C⟧ ⟹ size (splay x ⟨AB, b, ⟨C, c, D⟩⟩) = size ⟨AB, b, ⟨C, c, D⟩⟩› and 3 goals remain*) apply (force split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*goal: ‹⋀(a::'a::linorder) (x::'a::linorder) (c::'a::linorder) (D::'a::linorder tree) (AB::'a::linorder tree) C::'a::linorder tree. ⟦a < x; c < x; D ≠ ⟨⟩; size (splay x D) = size D⟧ ⟹ size (splay x ⟨AB, a, ⟨C, c, D⟩⟩) = size ⟨AB, a, ⟨C, c, D⟩⟩›*) apply (force split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) (*proven 14 subgoals*) . lemma size_if_splay: "splay a t = Node l u r ⟹ size t = size l + size r + 1" by (metis One_nat_def (*‹1 = Suc 0›*) size_splay (*‹size (splay ?a ?t) = size ?t›*) tree.size( (*‹size ⟨?x21.0, ?x22.0, ?x23.0⟩ = size ?x21.0 + size ?x23.0 + Suc 0›*) 4)) lemma splay_not_Leaf: "t ≠ Leaf ⟹ ∃l x r. splay a t = Node l x r" by (metis neq_Leaf_iff (*‹(?t ≠ ⟨⟩) = (∃l a r. ?t = ⟨l, a, r⟩)›*) splay_Leaf_iff (*‹(splay ?a ?t = ⟨⟩) = (?t = ⟨⟩)›*)) lemma size_splay_max: "size(splay_max t) = size t" apply (induction t rule: splay_max.induct (*‹⟦?P ⟨⟩; ⋀A a. ?P ⟨A, a, ⟨⟩⟩; ⋀A a B b CD. (CD ≠ ⟨⟩ ⟹ ?P CD) ⟹ ?P ⟨A, a, ⟨B, b, CD⟩⟩⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹size (splay_max ⟨⟩) = size ⟨⟩› 2. ‹⋀(A::'a tree) a::'a. size (splay_max ⟨A, a, ⟨⟩⟩) = size ⟨A, a, ⟨⟩⟩› 3. ‹⋀(A::'a tree) (a::'a) (B::'a tree) (b::'a) CD::'a tree. (CD ≠ ⟨⟩ ⟹ size (splay_max CD) = size CD) ⟹ size (splay_max ⟨A, a, ⟨B, b, CD⟩⟩) = size ⟨A, a, ⟨B, b, CD⟩⟩› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply (clarsimp split: tree.split (*‹?P (case ?tree of ⟨⟩ ⇒ ?f1.0 | ⟨x, xa, xb⟩ ⇒ ?f2.0 x xa xb) = ((?tree = ⟨⟩ ⟶ ?P ?f1.0) ∧ (∀x21 x22 x23. ?tree = ⟨x21, x22, x23⟩ ⟶ ?P (?f2.0 x21 x22 x23)))›*)) (*proven 3 subgoals*) . lemma size_if_splay_max: "splay_max t = Node l u r ⟹ size t = size l + size r + 1" sorry (* subsection "Functional Correctness Proofs II" text ‹This subsection follows the traditional approach, is less automated and is retained more for historic reasons.› lemma set_splay: "set_tree(splay a t) = set_tree t" proof(induction a t rule: splay.induct) case (6 a) with splay_not_Leaf[OF 6(3), of a] show ?case by(fastforce) next case (8 _ a) with splay_not_Leaf[OF 8(3), of a] show ?case by(fastforce) next case (11 _ a) with splay_not_Leaf[OF 11(3), of a] show ?case by(fastforce) next case (14 _ a) with splay_not_Leaf[OF 14(3), of a] show ?case by(fastforce) qed auto lemma splay_bstL: "bst t ⟹ splay a t = Node l e r ⟹ x ∈ set_tree l ⟹ x < a" apply(induction a t arbitrary: l x r rule: splay.induct) apply (auto split: tree.splits) apply auto done lemma splay_bstR: "bst t ⟹ splay a t = Node l e r ⟹ x ∈ set_tree r ⟹ a < x" apply(induction a t arbitrary: l e x r rule: splay.induct) apply auto apply (fastforce split!: tree.splits)+ done lemma bst_splay: "bst t ⟹ bst(splay a t)" proof(induction a t rule: splay.induct) case (6 a _ _ ll) with splay_not_Leaf[OF 6(3), of a] set_splay[of a ll,symmetric] show ?case by (fastforce) next case (8 _ a _ t) with splay_not_Leaf[OF 8(3), of a] set_splay[of a t,symmetric] show ?case by fastforce next case (11 _ a _ t) with splay_not_Leaf[OF 11(3), of a] set_splay[of a t,symmetric] show ?case by fastforce next case (14 _ a _ t) with splay_not_Leaf[OF 14(3), of a] set_splay[of a t,symmetric] show ?case by fastforce qed auto lemma splay_to_root: "⟦ bst t; splay a t = t' ⟧ ⟹ a ∈ set_tree t ⟷ (∃l r. t' = Node l a r)" proof(induction a t arbitrary: t' rule: splay.induct) case (6 a) with splay_not_Leaf[OF 6(3), of a] show ?case by auto next case (8 _ a) with splay_not_Leaf[OF 8(3), of a] show ?case by auto next case (11 _ a) with splay_not_Leaf[OF 11(3), of a] show ?case by auto next case (14 _ a) with splay_not_Leaf[OF 14(3), of a] show ?case by auto qed fastforce+ subsubsection "Verification of Is-in Test" text‹To test if an element ‹a› is in ‹t›, first perform @{term"splay a t"}, then check if the root is ‹a›. One could put this into one function that returns both a new tree and the test result.› lemma is_root_splay: "bst t ⟹ is_root a (splay a t) ⟷ a ∈ set_tree t" by(auto simp add: is_root_def splay_to_root split: tree.split) subsubsection "Verification of @{const insert}" lemma set_insert: "set_tree(insert a t) = Set.insert a (set_tree t)" apply(cases t) apply simp using set_splay[of a t] by(simp split: tree.split) fastforce lemma bst_insert: "bst t ⟹ bst(insert a t)" apply(cases t) apply simp using bst_splay[of t a] splay_bstL[of t a] splay_bstR[of t a] by(auto simp: ball_Un split: tree.split) subsubsection "Verification of ‹splay_max›" lemma set_splay_max: "set_tree(splay_max t) = set_tree t" apply(induction t rule: splay_max.induct) apply(simp) apply(simp) apply(force split: tree.split) done lemma bst_splay_max: "bst t ⟹ bst (splay_max t)" proof(induction t rule: splay_max.induct) case (3 l b rl c rr) { fix rrl' d' rrr' have "splay_max rr = Node rrl' d' rrr' ⟹ ∀x ∈ set_tree(Node rrl' d' rrr'). c < x" using "3.prems" set_splay_max[of rr] by (clarsimp split: tree.split simp: ball_Un) } with 3 show ?case by (fastforce split: tree.split simp: ball_Un) qed auto lemma splay_max_Leaf: "splay_max t = Node l a r ⟹ r = Leaf" by(induction t arbitrary: l rule: splay_max.induct) (auto split: tree.splits if_splits) text‹For sanity purposes only:› lemma splay_max_eq_splay: "bst t ⟹ ∀x ∈ set_tree t. x ≤ a ⟹ splay_max t = splay a t" proof(induction a t rule: splay.induct) case (2 a l r) show ?case proof (cases r) case Leaf with 2 show ?thesis by simp next case Node with 2 show ?thesis by(auto) qed qed (auto simp: neq_Leaf_iff) lemma splay_max_eq_splay_ex: assumes "bst t" shows "∃a. splay_max t = splay a t" proof(cases t) case Leaf thus ?thesis by simp next case Node hence "splay_max t = splay (Max(set_tree t)) t" using assms by (auto simp: splay_max_eq_splay) thus ?thesis by auto qed subsubsection "Verification of @{const delete}" lemma set_delete: assumes "bst t" shows "set_tree (delete a t) = set_tree t - {a}" proof(cases t) case Leaf thus ?thesis by(simp add: delete_def) next case (Node l x r) obtain l' x' r' where sp[simp]: "splay a (Node l x r) = Node l' x' r'" by (metis neq_Leaf_iff splay_Leaf_iff) show ?thesis proof cases assume [simp]: "x' = a" show ?thesis proof cases assume "l' = Leaf" thus ?thesis using Node assms set_splay[of a "Node l x r"] bst_splay[of "Node l x r" a] by(simp add: delete_def split: tree.split prod.split)(fastforce) next assume "l' ≠ Leaf" moreover then obtain l'' m r'' where "splay_max l' = Node l'' m r''" using splay_max_Leaf_iff tree.exhaust by blast moreover have "a ∉ set_tree l'" by (metis (no_types) Node assms less_irrefl sp splay_bstL) ultimately show ?thesis using Node assms set_splay[of a "Node l x r"] bst_splay[of "Node l x r" a] splay_max_Leaf[of l' l'' m r''] set_splay_max[of l'] by(clarsimp simp: delete_def split: tree.split) auto qed next assume "x' ≠ a" thus ?thesis using Node assms set_splay[of a "Node l x r"] splay_to_root[OF _ sp] by (simp add: delete_def) qed qed lemma bst_delete: assumes "bst t" shows "bst (delete a t)" proof(cases t) case Leaf thus ?thesis by(simp add: delete_def) next case (Node l x r) obtain l' x' r' where sp[simp]: "splay a (Node l x r) = Node l' x' r'" by (metis neq_Leaf_iff splay_Leaf_iff) show ?thesis proof cases assume [simp]: "x' = a" show ?thesis proof cases assume "l' = Leaf" thus ?thesis using Node assms bst_splay[of "Node l x r" a] by(simp add: delete_def split: tree.split prod.split) next assume "l' ≠ Leaf" thus ?thesis using Node assms set_splay[of a "Node l x r"] bst_splay[of "Node l x r" a] bst_splay_max[of l'] set_splay_max[of l'] by(clarsimp simp: delete_def split: tree.split) (metis (no_types) insertI1 less_trans) qed next assume "x' ≠ a" thus ?thesis using Node assms bst_splay[of "Node l x r" a] by(auto simp: delete_def split: tree.split prod.split) qed qed *) end
{ "path": "afp-2025-02-12/thys/Splay_Tree/Splay_Tree.thy", "repo": "afp-2025-02-12", "sha": "c7773624abe585d99b7dc2761d4a58c302945235fe2e828a15e234fcd00e6239" }
subsection "Infinitesimals" theory Infinitesimals imports ExecutiblePolyProps LinearCase QuadraticCase NegInfinity Debruijn begin lemma freeIn_substInfinitesimalQuadratic : assumes "var ∉ vars a" "var ∉ vars b" "var ∉ vars c" "var ∉ vars d" shows "freeIn var (substInfinitesimalQuadratic var a b c d At)" proof (cases At) (*goals: 1. ‹⋀x1. At = Less x1 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)› 2. ‹⋀x2. At = Eq x2 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)› 3. ‹⋀x3. At = Leq x3 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)› 4. ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)›*) case (Less p) (*‹At = Less p›*) show "?thesis" (*goal: ‹freeIn var (substInfinitesimalQuadratic var a b c d At)›*) unfolding substInfinitesimalQuadratic.simps Less (*goal: ‹freeIn var (quadratic_sub_fm var a b c d (convertDerivative var p))›*) apply (rule free_in_quad_fm[of var a b c d "(convertDerivative var p)"] (*‹⟦var ∉ vars a; var ∉ vars b; var ∉ vars c; var ∉ vars d⟧ ⟹ freeIn var (quadratic_sub_fm var a b c d (convertDerivative var p))›*)) (*goal: ‹freeIn var (quadratic_sub_fm var a b c d (convertDerivative var p))›*) using assms (*‹(var::nat) ∉ vars (a::real mpoly)› ‹var ∉ vars b› ‹(var::nat) ∉ vars (c::real mpoly)› ‹var ∉ vars d›*) apply - (*goals: 1. ‹⟦var ∉ vars a; var ∉ vars b; var ∉ vars c; var ∉ vars d⟧ ⟹ var ∉ vars a› 2. ‹⟦var ∉ vars a; var ∉ vars b; var ∉ vars c; var ∉ vars d⟧ ⟹ var ∉ vars b› 3. ‹⟦var ∉ vars a; var ∉ vars b; var ∉ vars c; var ∉ vars d⟧ ⟹ var ∉ vars c› 4. ‹⟦var ∉ vars a; var ∉ vars b; var ∉ vars c; var ∉ vars d⟧ ⟹ var ∉ vars d› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . next (*goals: 1. ‹⋀x2. At = Eq x2 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)› 2. ‹⋀x3. At = Leq x3 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)› 3. ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)›*) case (Eq p) (*‹At = Eq p›*) then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalQuadratic var a b c d At)›*) apply simp (*goal: ‹freeIn var (substInfinitesimalQuadratic var a b c d At)›*) apply (rule freeIn_list_conj (*‹∀f∈set ?F. freeIn ?var f ⟹ freeIn ?var (list_conj ?F)›*)) (*goal: ‹(At::atom) = Eq (p::real mpoly) ⟹ freeIn (var::nat) (list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p var i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]))›*) apply auto (*goal: ‹At = Eq p ⟹ ∀f∈set (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]). freeIn var f›*) using not_in_isovarspar (*‹isolate_variable_sparse ?p ?var ?x = ?q ⟹ ?var ∉ vars ?q›*) apply - (*goals: 1. ‹⟦(At::atom) = Eq (p::real mpoly); (var::nat) ∈ vars (isolate_variable_sparse p var (MPoly_Type.degree p var)); ⋀(p::real mpoly) (var::nat) (x::nat) q::real mpoly. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› 2. ‹⋀x::nat. ⟦(At::atom) = Eq (p::real mpoly); x < MPoly_Type.degree p (var::nat); var ∈ vars (isolate_variable_sparse p var x); ⋀(p::real mpoly) (var::nat) (x::nat) q::real mpoly. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . next (*goals: 1. ‹⋀x3. At = Leq x3 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)› 2. ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)›*) case (Leq p) (*‹At = Leq p›*) then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalQuadratic var a b c d At)›*) unfolding substInfinitesimalQuadratic.simps Leq freeIn.simps (*goal: ‹freeIn var (allZero p var) ∧ freeIn var (quadratic_sub_fm var a b c d (convertDerivative var p))›*) using free_in_quad_fm[of var a b c d "(convertDerivative var p)", OF assms] (*‹freeIn var (quadratic_sub_fm var a b c d (convertDerivative var p))›*) apply simp (*goal: ‹freeIn (var::nat) (allZero (p::real mpoly) var) ∧ freeIn var (quadratic_sub_fm var (a::real mpoly) (b::real mpoly) (c::real mpoly) (d::real mpoly) (convertDerivative var p))›*) apply (rule freeIn_list_conj (*‹∀f∈set ?F. freeIn ?var f ⟹ freeIn ?var (list_conj ?F)›*)) (*goal: ‹freeIn var (liftmap (λx. quadratic_sub (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (if MPoly_Type.degree p var = 0 then fm.Atom (Less p) else Or (fm.Atom (Less p)) (And (fm.Atom (Eq p)) (convertDerivative var (derivative var p)))) 0) ⟹ freeIn var (list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]))›*) using not_in_isovarspar (*‹isolate_variable_sparse (?p::real mpoly) (?var::nat) (?x::nat) = (?q::real mpoly) ⟹ ?var ∉ vars ?q›*) by simp next (*goal: ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalQuadratic var a b c d At)›*) case (Neq p) (*‹At = Neq p›*) then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalQuadratic var a b c d At)›*) apply (auto simp add:neg_def (*‹neg ?φ = (if ?φ = TrueF then FalseF else if ?φ = FalseF then TrueF else Neg ?φ)›*)) (*goal: ‹freeIn var (substInfinitesimalQuadratic var a b c d At)›*) apply (rule freeIn_list_conj (*‹∀f∈set ?F. freeIn ?var f ⟹ freeIn ?var (list_conj ?F)›*)) (*goal: ‹⟦At = Neq p; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF⟧ ⟹ freeIn var (list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]))›*) apply auto (*goal: ‹⟦At = Neq p; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF⟧ ⟹ ∀f∈set (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]). freeIn var f›*) using not_in_isovarspar (*‹isolate_variable_sparse ?p ?var ?x = ?q ⟹ ?var ∉ vars ?q›*) apply - (*goals: 1. ‹⟦At = Neq p; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF; var ∈ vars (isolate_variable_sparse p var (MPoly_Type.degree p var)); ⋀p var x q. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› 2. ‹⋀x. ⟦At = Neq p; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF; x < MPoly_Type.degree p var; var ∈ vars (isolate_variable_sparse p var x); ⋀p var x q. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed lemma freeIn_substInfinitesimalQuadratic_fm : assumes "var ∉ vars a" "var ∉ vars b" "var ∉ vars c" "var ∉ vars d" shows"freeIn var (substInfinitesimalQuadratic_fm var a b c d F)" proof (-) (*goal: ‹freeIn var (substInfinitesimalQuadratic_fm var a b c d F)›*) { fix z have "freeIn (var+z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)" apply (induction F arbitrary:z) (*goals: 1. ‹⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) TrueF z)› 2. ‹⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) FalseF z)› 3. ‹⋀x z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (fm.Atom x) z)› 4. ‹⋀F1 F2 z. ⟦⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F1 z); ⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F2 z)⟧ ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (And F1 F2) z)› 5. ‹⋀F1 F2 z. ⟦⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F1 z); ⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F2 z)⟧ ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (Or F1 F2) z)› 6. ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (Neg F) z)› 7. ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (ExQ F) z)› 8. ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (AllQ F) z)› 9. ‹⋀x1 F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (ExN x1 F) z)› 10. ‹⋀x1 F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (AllN x1 F) z)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*top goal: ‹⋀x z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (fm.Atom x) z)› and 7 goals remain*) apply (rule freeIn_substInfinitesimalQuadratic (*‹⟦?var ∉ vars ?a; ?var ∉ vars ?b; ?var ∉ vars ?c; ?var ∉ vars ?d⟧ ⟹ freeIn ?var (substInfinitesimalQuadratic ?var ?a ?b ?c ?d ?At)›*)) (*goals: 1. ‹⋀x z. var + z ∉ vars (liftPoly 0 z a)› 2. ‹⋀x z. var + z ∉ vars (liftPoly 0 z b)› 3. ‹⋀x z. var + z ∉ vars (liftPoly 0 z c)› 4. ‹⋀x z. var + z ∉ vars (liftPoly 0 z d)› discuss goal 1*) apply (simp add: assms (*‹var ∉ vars a› ‹var ∉ vars b› ‹var ∉ vars c› ‹var ∉ vars d›*) not_in_lift (*‹?var ∉ vars ?p ⟹ ?var + ?z ∉ vars (liftPoly 0 ?z ?p)›*)) (*discuss goal 2*) apply (simp add: assms (*‹(var::nat) ∉ vars (a::real mpoly)› ‹(var::nat) ∉ vars (b::real mpoly)› ‹(var::nat) ∉ vars (c::real mpoly)› ‹(var::nat) ∉ vars (d::real mpoly)›*) not_in_lift (*‹(?var::nat) ∉ vars (?p::real mpoly) ⟹ ?var + (?z::nat) ∉ vars (liftPoly (0::nat) ?z ?p)›*)) (*discuss goal 3*) apply (simp add: assms (*‹(var::nat) ∉ vars (a::real mpoly)› ‹(var::nat) ∉ vars (b::real mpoly)› ‹(var::nat) ∉ vars (c::real mpoly)› ‹(var::nat) ∉ vars (d::real mpoly)›*) not_in_lift (*‹(?var::nat) ∉ vars (?p::real mpoly) ⟹ ?var + (?z::nat) ∉ vars (liftPoly (0::nat) ?z ?p)›*)) (*discuss goal 4*) apply (simp add: assms (*‹var ∉ vars a› ‹var ∉ vars b› ‹var ∉ vars c› ‹var ∉ vars d›*) not_in_lift (*‹?var ∉ vars ?p ⟹ ?var + ?z ∉ vars (liftPoly 0 ?z ?p)›*)) (*proven 4 subgoals*) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*top goal: ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (ExQ F) z)› and 3 goals remain*) apply (metis (no_types, lifting) add_Suc_right (*‹?m + Suc ?n = Suc (?m + ?n)›*)) (*discuss goal 8*) apply ((auto)[1]) (*top goal: ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (AllQ F) z)› and 2 goals remain*) apply (metis (mono_tags, lifting) add_Suc_right (*‹?m + Suc ?n = Suc (?m + ?n)›*)) (*discuss goal 9*) apply ((auto)[1]) (*top goal: ‹⋀(x1::nat) (F::atom fm) z::nat. (⋀z::nat. freeIn ((var::nat) + z) (liftmap (λx::nat. substInfinitesimalQuadratic (var + x) (liftPoly (0::nat) x (a::real mpoly)) (liftPoly (0::nat) x (b::real mpoly)) (liftPoly (0::nat) x (c::real mpoly)) (liftPoly (0::nat) x (d::real mpoly))) F z)) ⟹ freeIn (var + z) (liftmap (λx::nat. substInfinitesimalQuadratic (var + x) (liftPoly (0::nat) x a) (liftPoly (0::nat) x b) (liftPoly (0::nat) x c) (liftPoly (0::nat) x d)) (ExN x1 F) z)› and 1 goal remains*) apply (simp add: ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1)) (*discuss goal 10*) apply ((auto)[1]) (*goal: ‹⋀x1 F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) (AllN x1 F) z)›*) apply (simp add: add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) (*proven 10 subgoals*) . } then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalQuadratic_fm var a b c d F)›*) unfolding substInfinitesimalQuadratic_fm.simps (*goal: ‹freeIn var (liftmap (λx. substInfinitesimalQuadratic (var + x) (liftPoly 0 x a) (liftPoly 0 x b) (liftPoly 0 x c) (liftPoly 0 x d)) F 0)›*) by (metis (no_types, lifting) add.right_neutral (*‹(?a::?'a) + (0::?'a) = ?a›*)) qed lemma freeIn_substInfinitesimalLinear: assumes "var ∉ vars a" "var ∉ vars b" shows "freeIn var (substInfinitesimalLinear var a b At)" proof (cases At) (*goals: 1. ‹⋀x1. At = Less x1 ⟹ freeIn var (substInfinitesimalLinear var a b At)› 2. ‹⋀x2. At = Eq x2 ⟹ freeIn var (substInfinitesimalLinear var a b At)› 3. ‹⋀x3. At = Leq x3 ⟹ freeIn var (substInfinitesimalLinear var a b At)› 4. ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalLinear var a b At)›*) case (Less p) (*‹At = Less p›*) show "?thesis" (*goal: ‹freeIn var (substInfinitesimalLinear var a b At)›*) unfolding Less substInfinitesimalLinear.simps (*goal: ‹freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (convertDerivative var p) 0)›*) using var_not_in_linear_fm[of var a b "(convertDerivative var p)", OF assms] (*‹freeIn var (linear_substitution_fm var a b (convertDerivative var p))›*) unfolding linear_substitution_fm.simps linear_substitution_fm_helper.simps (*goal: ‹freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (convertDerivative var p) 0)›*) . next (*goals: 1. ‹⋀x2. At = Eq x2 ⟹ freeIn var (substInfinitesimalLinear var a b At)› 2. ‹⋀x3. At = Leq x3 ⟹ freeIn var (substInfinitesimalLinear var a b At)› 3. ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalLinear var a b At)›*) case (Eq p) (*‹At = Eq p›*) then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalLinear var a b At)›*) apply simp (*goal: ‹freeIn var (substInfinitesimalLinear var a b At)›*) apply (rule freeIn_list_conj (*‹∀f∈set ?F. freeIn ?var f ⟹ freeIn ?var (list_conj ?F)›*)) (*goal: ‹At = Eq p ⟹ freeIn var (list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]))›*) apply auto (*goal: ‹(At::atom) = Eq (p::real mpoly) ⟹ ∀f::atom fm∈set (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p (var::nat) i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]). freeIn var f›*) using not_in_isovarspar (*‹isolate_variable_sparse ?p ?var ?x = ?q ⟹ ?var ∉ vars ?q›*) apply - (*goals: 1. ‹⟦At = Eq p; var ∈ vars (isolate_variable_sparse p var (MPoly_Type.degree p var)); ⋀p var x q. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› 2. ‹⋀x. ⟦At = Eq p; x < MPoly_Type.degree p var; var ∈ vars (isolate_variable_sparse p var x); ⋀p var x q. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . next (*goals: 1. ‹⋀x3. At = Leq x3 ⟹ freeIn var (substInfinitesimalLinear var a b At)› 2. ‹⋀x4. At = Neq x4 ⟹ freeIn var (substInfinitesimalLinear var a b At)›*) case (Leq p) (*‹(At::atom) = Leq (p::real mpoly)›*) show "?thesis" (*goal: ‹freeIn (var::nat) (substInfinitesimalLinear var (a::real mpoly) (b::real mpoly) (At::atom))›*) unfolding Leq substInfinitesimalLinear.simps freeIn.simps (*goal: ‹freeIn var (allZero p var) ∧ freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (convertDerivative var p) 0)›*) using var_not_in_linear_fm[of var a b "(convertDerivative var p)", OF assms] (*‹freeIn var (linear_substitution_fm var a b (convertDerivative var p))›*) unfolding linear_substitution_fm.simps linear_substitution_fm_helper.simps (*goal: ‹freeIn var (allZero p var) ∧ freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (convertDerivative var p) 0)›*) apply simp (*goal: ‹freeIn (var::nat) (allZero (p::real mpoly) var) ∧ freeIn var (liftmap (λ(x::nat) A::atom. fm.Atom (linear_substitution (var + x) (liftPoly (0::nat) x (a::real mpoly)) (liftPoly (0::nat) x (b::real mpoly)) A)) (convertDerivative var p) (0::nat))›*) apply (rule freeIn_list_conj (*‹∀f::atom fm∈set (?F::atom fm list). freeIn (?var::nat) f ⟹ freeIn ?var (list_conj ?F)›*)) (*goal: ‹freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (if MPoly_Type.degree p var = 0 then fm.Atom (Less p) else Or (fm.Atom (Less p)) (And (fm.Atom (Eq p)) (convertDerivative var (derivative var p)))) 0) ⟹ freeIn var (list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]))›*) apply auto (*goal: ‹freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (if MPoly_Type.degree p var = 0 then fm.Atom (Less p) else Or (fm.Atom (Less p)) (And (fm.Atom (Eq p)) (convertDerivative var (derivative var p)))) 0) ⟹ ∀f∈set (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]). freeIn var f›*) using not_in_isovarspar (*‹isolate_variable_sparse ?p ?var ?x = ?q ⟹ ?var ∉ vars ?q›*) apply - (*goals: 1. ‹⟦freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (if MPoly_Type.degree p var = 0 then fm.Atom (Less p) else Or (fm.Atom (Less p)) (And (fm.Atom (Eq p)) (convertDerivative var (derivative var p)))) 0); var ∈ vars (isolate_variable_sparse p var (MPoly_Type.degree p var)); ⋀p var x q. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› 2. ‹⋀x. ⟦x < MPoly_Type.degree p var; var ∈ vars (isolate_variable_sparse p var x); freeIn var (fm.Atom (let d = MPoly_Type.degree p var in Less (((∑i = 0..<d. isolate_variable_sparse p var i * liftPoly 0 0 a ^ i * liftPoly 0 0 b ^ (d - i)) + isolate_variable_sparse p var d * liftPoly 0 0 a ^ d) * liftPoly 0 0 b ^ (d mod 2)))); freeIn var (fm.Atom (let d = MPoly_Type.degree p var in Eq ((∑i = 0..<d. isolate_variable_sparse p var i * liftPoly 0 0 a ^ i * liftPoly 0 0 b ^ (d - i)) + isolate_variable_sparse p var d * liftPoly 0 0 a ^ d))); freeIn var (liftmap (λx A. fm.Atom (linear_substitution (var + x) (liftPoly 0 x a) (liftPoly 0 x b) A)) (if MPoly_Type.degree (derivative var p) var = 0 then fm.Atom (Less (derivative var p)) else Or (fm.Atom (Less (derivative var p))) (And (fm.Atom (Eq (derivative var p))) (convertDerivative var (derivative var (derivative var p))))) 0); ⋀p var x q. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . next (*goal: ‹⋀x4::real mpoly. (At::atom) = Neq x4 ⟹ freeIn (var::nat) (substInfinitesimalLinear var (a::real mpoly) (b::real mpoly) At)›*) case (Neq p) (*‹At = Neq p›*) then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalLinear var a b At)›*) apply (auto simp add:neg_def (*‹neg ?φ = (if ?φ = TrueF then FalseF else if ?φ = FalseF then TrueF else Neg ?φ)›*)) (*goal: ‹freeIn var (substInfinitesimalLinear var a b At)›*) apply (rule freeIn_list_conj (*‹∀f∈set ?F. freeIn ?var f ⟹ freeIn ?var (list_conj ?F)›*)) (*goal: ‹⟦(At::atom) = Neq (p::real mpoly); list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p (var::nat) i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p var i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF⟧ ⟹ freeIn var (list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p var i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]))›*) apply auto (*goal: ‹⟦At = Neq p; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF⟧ ⟹ ∀f∈set (map (λi. fm.Atom (Eq (isolate_variable_sparse p var i))) [0..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]). freeIn var f›*) using not_in_isovarspar (*‹isolate_variable_sparse (?p::real mpoly) (?var::nat) (?x::nat) = (?q::real mpoly) ⟹ ?var ∉ vars ?q›*) apply - (*goals: 1. ‹⟦(At::atom) = Neq (p::real mpoly); list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p (var::nat) i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p var i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF; var ∈ vars (isolate_variable_sparse p var (MPoly_Type.degree p var)); ⋀(p::real mpoly) (var::nat) (x::nat) q::real mpoly. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› 2. ‹⋀x::nat. ⟦(At::atom) = Neq (p::real mpoly); list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p (var::nat) i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ FalseF; list_conj (map (λi::nat. fm.Atom (Eq (isolate_variable_sparse p var i))) [0::nat..<MPoly_Type.degree p var] @ [fm.Atom (Eq (isolate_variable_sparse p var (MPoly_Type.degree p var)))]) ≠ TrueF; x < MPoly_Type.degree p var; var ∈ vars (isolate_variable_sparse p var x); ⋀(p::real mpoly) (var::nat) (x::nat) q::real mpoly. isolate_variable_sparse p var x = q ⟹ var ∉ vars q⟧ ⟹ False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed lemma freeIn_substInfinitesimalLinear_fm: assumes "var ∉ vars a" "var ∉ vars b" shows "freeIn var (substInfinitesimalLinear_fm var a b F)" proof (-) (*goal: ‹freeIn var (substInfinitesimalLinear_fm var a b F)›*) { fix z have "freeIn (var+z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)" apply (induction F arbitrary:z) (*goals: 1. ‹⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) TrueF z)› 2. ‹⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) FalseF z)› 3. ‹⋀x z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (fm.Atom x) z)› 4. ‹⋀F1 F2 z. ⟦⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F1 z); ⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F2 z)⟧ ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (And F1 F2) z)› 5. ‹⋀F1 F2 z. ⟦⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F1 z); ⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F2 z)⟧ ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (Or F1 F2) z)› 6. ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (Neg F) z)› 7. ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (ExQ F) z)› 8. ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (AllQ F) z)› 9. ‹⋀x1 F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (ExN x1 F) z)› 10. ‹⋀x1 F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (AllN x1 F) z)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*top goal: ‹⋀x z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (fm.Atom x) z)› and 7 goals remain*) apply (rule freeIn_substInfinitesimalLinear (*‹⟦(?var::nat) ∉ vars (?a::real mpoly); ?var ∉ vars (?b::real mpoly)⟧ ⟹ freeIn ?var (substInfinitesimalLinear ?var ?a ?b (?At::atom))›*)) (*goals: 1. ‹⋀x z. var + z ∉ vars (liftPoly 0 z a)› 2. ‹⋀x z. var + z ∉ vars (liftPoly 0 z b)› discuss goal 1*) apply (simp add: assms (*‹var ∉ vars a› ‹var ∉ vars b›*) not_in_lift (*‹?var ∉ vars ?p ⟹ ?var + ?z ∉ vars (liftPoly 0 ?z ?p)›*)) (*discuss goal 2*) apply (simp add: assms (*‹var ∉ vars a› ‹var ∉ vars b›*) not_in_lift (*‹?var ∉ vars ?p ⟹ ?var + ?z ∉ vars (liftPoly 0 ?z ?p)›*)) (*proven 2 subgoals*) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*top goal: ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (ExQ F) z)› and 3 goals remain*) apply (metis (full_types) Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1)) (*discuss goal 8*) apply ((auto)[1]) (*top goal: ‹⋀F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (AllQ F) z)› and 2 goals remain*) apply (metis (full_types) Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1)) (*discuss goal 9*) apply ((auto)[1]) (*top goal: ‹⋀x1 F z. (⋀z. freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F z)) ⟹ freeIn (var + z) (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) (ExN x1 F) z)› and 1 goal remains*) apply (simp add: add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) (*discuss goal 10*) apply ((auto)[1]) (*goal: ‹⋀(x1::nat) (F::atom fm) z::nat. (⋀z::nat. freeIn ((var::nat) + z) (liftmap (λx::nat. substInfinitesimalLinear (var + x) (liftPoly (0::nat) x (a::real mpoly)) (liftPoly (0::nat) x (b::real mpoly))) F z)) ⟹ freeIn (var + z) (liftmap (λx::nat. substInfinitesimalLinear (var + x) (liftPoly (0::nat) x a) (liftPoly (0::nat) x b)) (AllN x1 F) z)›*) apply (simp add: add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) (*proven 10 subgoals*) . } then show "?thesis" (*goal: ‹freeIn var (substInfinitesimalLinear_fm var a b F)›*) unfolding substInfinitesimalLinear_fm.simps (*goal: ‹freeIn var (liftmap (λx. substInfinitesimalLinear (var + x) (liftPoly 0 x a) (liftPoly 0 x b)) F 0)›*) by (metis (no_types, lifting) add.right_neutral (*‹?a + 0 = ?a›*)) qed end
{ "path": "afp-2025-02-12/thys/Virtual_Substitution/Infinitesimals.thy", "repo": "afp-2025-02-12", "sha": "68cba105dfb5359c316945cf271c5ccbf9457d36ad9be14b2d01f7ba14d642c0" }
(* Title: HOL/Nonstandard_Analysis/Star.thy Author: Jacques D. Fleuriot Copyright: 1998 University of Cambridge Conversion to Isar and new proofs by Lawrence C Paulson, 2003/4 *) section ‹Star-Transforms in Non-Standard Analysis› theory Star imports NSA begin definition ― ‹internal sets› starset_n :: "(nat ⇒ 'a set) ⇒ 'a star set" ("*sn* _" [80] 80) where "*sn* As = Iset (star_n As)" definition InternalSets :: "'a star set set" where "InternalSets = {X. ∃As. X = *sn* As}" definition ― ‹nonstandard extension of function› is_starext :: "('a star ⇒ 'a star) ⇒ ('a ⇒ 'a) ⇒ bool" where "is_starext F f ⟷ (∀x y. ∃X ∈ Rep_star x. ∃Y ∈ Rep_star y. y = F x ⟷ eventually (λn. Y n = f(X n)) 𝒰)" definition ― ‹internal functions› starfun_n :: "(nat ⇒ 'a ⇒ 'b) ⇒ 'a star ⇒ 'b star" ("*fn* _" [80] 80) where "*fn* F = Ifun (star_n F)" definition InternalFuns :: "('a star => 'b star) set" where "InternalFuns = {X. ∃F. X = *fn* F}" subsection ‹Preamble - Pulling ‹∃› over ‹∀›› text ‹This proof does not need AC and was suggested by the referee for the JCM Paper: let ‹f x› be least ‹y› such that ‹Q x y›.› lemma no_choice: "∀x. ∃y. Q x y ⟹ ∃f :: 'a ⇒ nat. ∀x. Q x (f x)" apply (rule exI [where x = "λx. LEAST y. Q x y"] (*‹(?P::('a ⇒ nat) ⇒ bool) (λx::'a. LEAST y::nat. (Q::'a ⇒ nat ⇒ bool) x y) ⟹ ∃x::'a ⇒ nat. ?P x›*)) (*goal: ‹∀x. ∃y. Q x y ⟹ ∃f. ∀x. Q x (f x)›*) by (blast intro: LeastI (*‹(?P::?'a ⇒ bool) (?k::?'a) ⟹ ?P (LEAST x::?'a. ?P x)›*)) subsection ‹Properties of the Star-transform Applied to Sets of Reals› lemma STAR_star_of_image_subset: "star_of ` A ⊆ *s* A" by auto lemma STAR_hypreal_of_real_Int: "*s* X ∩ ℝ = hypreal_of_real ` X" by (auto simp add: SReal_def (*‹ℝ ≡ {x. ∃r. x = hypreal_of_real r}›*)) lemma STAR_star_of_Int: "*s* X ∩ Standard = star_of ` X" by (auto simp add: Standard_def (*‹Standard = range star_of›*)) lemma lemma_not_hyprealA: "x ∉ hypreal_of_real ` A ⟹ ∀y ∈ A. x ≠ hypreal_of_real y" by auto lemma lemma_not_starA: "x ∉ star_of ` A ⟹ ∀y ∈ A. x ≠ star_of y" by auto lemma STAR_real_seq_to_hypreal: "∀n. (X n) ∉ M ⟹ star_n X ∉ *s* M" by (simp add: starset_def (*‹*s* (?A::?'a::type set) = Iset (star_of ?A)›*) star_of_def (*‹star_of (?x::?'a::type) ≡ star_n (λn::nat. ?x)›*) Iset_star_n (*‹(star_n (?X::nat ⇒ ?'a::type) ∈ Iset (star_n (?A::nat ⇒ ?'a::type set))) = (∀⇩F n::nat in 𝒰. ?X n ∈ ?A n)›*) FreeUltrafilterNat.proper (*‹𝒰 ≠ bot›*)) lemma STAR_singleton: "*s* {x} = {star_of x}" by simp lemma STAR_not_mem: "x ∉ F ⟹ star_of x ∉ *s* F" by transfer lemma STAR_subset_closed: "x ∈ *s* A ⟹ A ⊆ B ⟹ x ∈ *s* B" apply (erule rev_subsetD (*‹⟦?c ∈ ?A; ?A ⊆ ?B⟧ ⟹ ?c ∈ ?B›*)) (*goal: ‹⟦x ∈ *s* A; A ⊆ B⟧ ⟹ x ∈ *s* B›*) by simp text ‹Nonstandard extension of a set (defined using a constant sequence) as a special case of an internal set.› lemma starset_n_starset: "∀n. As n = A ⟹ *sn* As = *s* A" apply (drule fun_eq_iff [THEN iffD2] (*‹∀x. ?f1 x = ?g1 x ⟹ ?f1 = ?g1›*)) (*goal: ‹∀n. As n = A ⟹ *sn* As = *s* A›*) by (simp add: starset_n_def (*‹*sn* ?As = Iset (star_n ?As)›*) starset_def (*‹*s* ?A = Iset (star_of ?A)›*) star_of_def (*‹star_of ?x ≡ star_n (λn. ?x)›*)) subsection ‹Theorems about nonstandard extensions of functions› text ‹Nonstandard extension of a function (defined using a constant sequence) as a special case of an internal function.› lemma starfun_n_starfun: "F = (λn. f) ⟹ *fn* F = *f* f" by (simp add: starfun_n_def (*‹*fn* ?F = Ifun (star_n ?F)›*) starfun_def (*‹*f* ?f ≡ Ifun (star_of ?f)›*) star_of_def (*‹star_of ?x ≡ star_n (λn. ?x)›*)) text ‹Prove that ‹abs› for hypreal is a nonstandard extension of abs for real w/o use of congruence property (proved after this for general nonstandard extensions of real valued functions). Proof now Uses the ultrafilter tactic!› lemma hrabs_is_starext_rabs: "is_starext abs abs" proof (-) (*goal: ‹is_starext abs abs›*) have "∃f∈Rep_star (star_n h). ∃g∈Rep_star (star_n k). (star_n k = ¦star_n h¦) = (∀⇩F n in 𝒰. (g n::'a) = ¦f n¦)" for x :: "'a star" and y :: "'a star" and h and k by (metis (full_types) Rep_star_star_n (*‹?X ∈ Rep_star (star_n ?X)›*) star_n_abs (*‹¦star_n ?X¦ = star_n (λn. ¦?X n¦)›*) star_n_eq_iff (*‹(star_n ?X = star_n ?Y) = (∀⇩F n in 𝒰. ?X n = ?Y n)›*)) then show "?thesis" (*goal: ‹is_starext abs abs›*) unfolding is_starext_def (*goal: ‹∀x y. ∃X∈Rep_star x. ∃Y∈Rep_star y. (y = ¦x¦) = (∀⇩F n in 𝒰. Y n = ¦X n¦)›*) by (metis star_cases (*‹(⋀X. ?x = star_n X ⟹ ?thesis) ⟹ ?thesis›*)) qed text ‹Nonstandard extension of functions.› lemma starfun: "( *f* f) (star_n X) = star_n (λn. f (X n))" by (rule starfun_star_n (*‹(*f* ?f) (star_n ?X) = star_n (λn. ?f (?X n))›*)) lemma starfun_if_eq: "⋀w. w ≠ star_of x ⟹ ( *f* (λz. if z = x then a else g z)) w = ( *f* g) w" apply transfer (*goal: ‹⋀w. w ≠ star_of x ⟹ (*f* (λz. if z = x then a else g z)) w = (*f* g) w›*) by simp text ‹Multiplication: ‹( *f) x ( *g) = *(f x g)›› lemma starfun_mult: "⋀x. ( *f* f) x * ( *f* g) x = ( *f* (λx. f x * g x)) x" apply transfer (*goal: ‹⋀x::'a star. (*f* (f::'a ⇒ 'b)) x * (*f* (g::'a ⇒ 'b)) x = (*f* (λx::'a. f x * g x)) x›*) by (rule refl (*‹?t = ?t›*)) declare starfun_mult [symmetric, simp] text ‹Addition: ‹( *f) + ( *g) = *(f + g)›› lemma starfun_add: "⋀x. ( *f* f) x + ( *f* g) x = ( *f* (λx. f x + g x)) x" apply transfer (*goal: ‹⋀x. (*f* f) x + (*f* g) x = (*f* (λx. f x + g x)) x›*) by (rule refl (*‹?t = ?t›*)) declare starfun_add [symmetric, simp] text ‹Subtraction: ‹( *f) + -( *g) = *(f + -g)›› lemma starfun_minus: "⋀x. - ( *f* f) x = ( *f* (λx. - f x)) x" apply transfer (*goal: ‹⋀x::'a::type star. - (*f* (f::'a::type ⇒ 'b::uminus)) x = (*f* (λx::'a::type. - f x)) x›*) by (rule refl (*‹?t = ?t›*)) declare starfun_minus [symmetric, simp] (*FIXME: delete*) lemma starfun_add_minus: "⋀x. ( *f* f) x + -( *f* g) x = ( *f* (λx. f x + -g x)) x" apply transfer (*goal: ‹⋀x. (*f* f) x + - (*f* g) x = (*f* (λx. f x + - g x)) x›*) by (rule refl (*‹?t = ?t›*)) declare starfun_add_minus [symmetric, simp] lemma starfun_diff: "⋀x. ( *f* f) x - ( *f* g) x = ( *f* (λx. f x - g x)) x" apply transfer (*goal: ‹⋀x. (*f* f) x - (*f* g) x = (*f* (λx. f x - g x)) x›*) by (rule refl (*‹?t = ?t›*)) declare starfun_diff [symmetric, simp] text ‹Composition: ‹( *f) ∘ ( *g) = *(f ∘ g)›› lemma starfun_o2: "(λx. ( *f* f) (( *f* g) x)) = *f* (λx. f (g x))" apply transfer (*goal: ‹(λx. (*f* f) ((*f* g) x)) = *f* (λx. f (g x))›*) by (rule refl (*‹?t = ?t›*)) lemma starfun_o: "( *f* f) ∘ ( *f* g) = ( *f* (f ∘ g))" apply (transfer o_def) (*goal: ‹*f* f ∘ *f* g = *f* (f ∘ g)›*) by (rule refl (*‹?t = ?t›*)) text ‹NS extension of constant function.› lemma starfun_const_fun [simp]: "⋀x. ( *f* (λx. k)) x = star_of k" apply transfer (*goal: ‹⋀x. (*f* (λx. k)) x = star_of k›*) by (rule refl (*‹(?t::?'a::type) = ?t›*)) text ‹The NS extension of the identity function.› lemma starfun_Id [simp]: "⋀x. ( *f* (λx. x)) x = x" apply transfer (*goal: ‹⋀x::'a star. (*f* (λx::'a. x)) x = x›*) by (rule refl (*‹?t = ?t›*)) text ‹The Star-function is a (nonstandard) extension of the function.› lemma is_starext_starfun: "is_starext ( *f* f) f" proof (-) (*goal: ‹is_starext (*f* f) f›*) have "∃X∈Rep_star x. ∃Y∈Rep_star y. (y = (*f* f) x) = (∀⇩F n in 𝒰. Y n = f (X n))" for x and y by (metis (mono_tags) Rep_star_star_n (*‹?X ∈ Rep_star (star_n ?X)›*) star_cases (*‹(⋀X. ?x = star_n X ⟹ ?thesis) ⟹ ?thesis›*) star_n_eq_iff (*‹(star_n ?X = star_n ?Y) = (∀⇩F n in 𝒰. ?X n = ?Y n)›*) starfun_star_n (*‹(*f* ?f) (star_n ?X) = star_n (λn. ?f (?X n))›*)) then show "?thesis" (*goal: ‹is_starext (*f* f) f›*) by (auto simp: is_starext_def (*‹is_starext ?F ?f = (∀x y. ∃X∈Rep_star x. ∃Y∈Rep_star y. (y = ?F x) = (∀⇩F n in 𝒰. Y n = ?f (X n)))›*)) qed text ‹Any nonstandard extension is in fact the Star-function.› lemma is_starfun_starext: assumes "is_starext F f" shows "F = *f* f" proof (-) (*goal: ‹F = *f* f›*) have "F x = (*f* f) x" if "∀x y. ∃X∈Rep_star x. ∃Y∈Rep_star y. (y = F x) = (∀⇩F n in 𝒰. Y n = f (X n))" for x by (metis that (*‹∀x y. ∃X∈Rep_star x. ∃Y∈Rep_star y. (y = F x) = (∀⇩F n in 𝒰. Y n = f (X n))›*) mem_Rep_star_iff (*‹(?X ∈ Rep_star ?x) = (?x = star_n ?X)›*) star_n_eq_iff (*‹(star_n ?X = star_n ?Y) = (∀⇩F n in 𝒰. ?X n = ?Y n)›*) starfun_star_n (*‹(*f* ?f) (star_n ?X) = star_n (λn. ?f (?X n))›*)) with assms (*‹is_starext F f›*) show "?thesis" (*goal: ‹F = *f* f›*) by (force simp add: is_starext_def (*‹is_starext ?F ?f = (∀x y. ∃X∈Rep_star x. ∃Y∈Rep_star y. (y = ?F x) = (∀⇩F n in 𝒰. Y n = ?f (X n)))›*)) qed lemma is_starext_starfun_iff: "is_starext F f ⟷ F = *f* f" by (blast intro: is_starfun_starext (*‹is_starext ?F ?f ⟹ ?F = *f* ?f›*) is_starext_starfun (*‹is_starext (*f* ?f) ?f›*)) text ‹Extended function has same solution as its standard version for real arguments. i.e they are the same for all real arguments.› lemma starfun_eq: "( *f* f) (star_of a) = star_of (f a)" by (rule starfun_star_of (*‹(*f* ?f) (star_of ?x) = star_of (?f ?x)›*)) lemma starfun_approx: "( *f* f) (star_of a) ≈ star_of (f a)" by simp text ‹Useful for NS definition of derivatives.› lemma starfun_lambda_cancel: "⋀x'. ( *f* (λh. f (x + h))) x' = ( *f* f) (star_of x + x')" apply transfer (*goal: ‹⋀x'. (*f* (λh. f (x + h))) x' = (*f* f) (star_of x + x')›*) by (rule refl (*‹?t = ?t›*)) lemma starfun_lambda_cancel2: "( *f* (λh. f (g (x + h)))) x' = ( *f* (f ∘ g)) (star_of x + x')" unfolding o_def (*goal: ‹(*f* (λh::'b::plus. (f::'c::type ⇒ 'a::type) ((g::'b::plus ⇒ 'c::type) ((x::'b::plus) + h)))) (x'::'b::plus star) = (*f* (λx::'b::plus. f (g x))) (star_of x + x')›*) by (rule starfun_lambda_cancel (*‹(*f* (λh. ?f (?x + h))) ?x' = (*f* ?f) (star_of ?x + ?x')›*)) lemma starfun_mult_HFinite_approx: "( *f* f) x ≈ l ⟹ ( *f* g) x ≈ m ⟹ l ∈ HFinite ⟹ m ∈ HFinite ⟹ ( *f* (λx. f x * g x)) x ≈ l * m" for l m :: "'a::real_normed_algebra star" using approx_mult_HFinite (*‹⟦?a ≈ ?b; ?c ≈ ?d; ?b ∈ HFinite; ?d ∈ HFinite⟧ ⟹ ?a * ?c ≈ ?b * ?d›*) by auto lemma starfun_add_approx: "( *f* f) x ≈ l ⟹ ( *f* g) x ≈ m ⟹ ( *f* (%x. f x + g x)) x ≈ l + m" by (auto intro: approx_add (*‹⟦(?a::?'a star) ≈ (?b::?'a star); (?c::?'a star) ≈ (?d::?'a star)⟧ ⟹ ?a + ?c ≈ ?b + ?d›*)) text ‹Examples: ‹hrabs› is nonstandard extension of ‹rabs›, ‹inverse› is nonstandard extension of ‹inverse›.› text ‹Can be proved easily using theorem ‹starfun› and properties of ultrafilter as for inverse below we use the theorem we proved above instead.› lemma starfun_rabs_hrabs: "*f* abs = abs" by (simp only: star_abs_def (*‹abs ≡ *f* abs›*)) lemma starfun_inverse_inverse [simp]: "( *f* inverse) x = inverse x" by (simp only: star_inverse_def (*‹inverse ≡ *f* inverse›*)) lemma starfun_inverse: "⋀x. inverse (( *f* f) x) = ( *f* (λx. inverse (f x))) x" apply transfer (*goal: ‹⋀x. inverse ((*f* f) x) = (*f* (λx. inverse (f x))) x›*) by (rule refl (*‹(?t::?'a) = ?t›*)) declare starfun_inverse [symmetric, simp] lemma starfun_divide: "⋀x. ( *f* f) x / ( *f* g) x = ( *f* (λx. f x / g x)) x" apply transfer (*goal: ‹⋀x. (*f* f) x / (*f* g) x = (*f* (λx. f x / g x)) x›*) by (rule refl (*‹(?t::?'a) = ?t›*)) declare starfun_divide [symmetric, simp] lemma starfun_inverse2: "⋀x. inverse (( *f* f) x) = ( *f* (λx. inverse (f x))) x" apply transfer (*goal: ‹⋀x. inverse ((*f* f) x) = (*f* (λx. inverse (f x))) x›*) by (rule refl (*‹?t = ?t›*)) text ‹General lemma/theorem needed for proofs in elementary topology of the reals.› lemma starfun_mem_starset: "⋀x. ( *f* f) x ∈ *s* A ⟹ x ∈ *s* {x. f x ∈ A}" apply transfer (*goal: ‹⋀x. (*f* f) x ∈ *s* A ⟹ x ∈ *s* {x. f x ∈ A}›*) by simp text ‹Alternative definition for ‹hrabs› with ‹rabs› function applied entrywise to equivalence class representative. This is easily proved using @{thm [source] starfun} and ns extension thm.› lemma hypreal_hrabs: "¦star_n X¦ = star_n (λn. ¦X n¦)" by (simp only: starfun_rabs_hrabs [symmetric] (*‹abs = *f* abs›*) starfun (*‹(*f* (?f::?'b::type ⇒ ?'a::type)) (star_n (?X::nat ⇒ ?'b::type)) = star_n (λn::nat. ?f (?X n))›*)) text ‹Nonstandard extension of set through nonstandard extension of ‹rabs› function i.e. ‹hrabs›. A more general result should be where we replace ‹rabs› by some arbitrary function ‹f› and ‹hrabs› by its NS extenson. See second NS set extension below.› lemma STAR_rabs_add_minus: "*s* {x. ¦x + - y¦ < r} = {x. ¦x + -star_of y¦ < star_of r}" apply transfer (*goal: ‹*s* {x. ¦x + - y¦ < r} = {x. ¦x + - star_of y¦ < star_of r}›*) by (rule refl (*‹?t = ?t›*)) lemma STAR_starfun_rabs_add_minus: "*s* {x. ¦f x + - y¦ < r} = {x. ¦( *f* f) x + -star_of y¦ < star_of r}" apply transfer (*goal: ‹*s* {x. ¦f x + - y¦ < r} = {x. ¦(*f* f) x + - star_of y¦ < star_of r}›*) by (rule refl (*‹?t = ?t›*)) text ‹Another characterization of Infinitesimal and one of ‹≈› relation. In this theory since ‹hypreal_hrabs› proved here. Maybe move both theorems??› lemma Infinitesimal_FreeUltrafilterNat_iff2: "star_n X ∈ Infinitesimal ⟷ (∀m. eventually (λn. norm (X n) < inverse (real (Suc m))) 𝒰)" by (simp add: Infinitesimal_hypreal_of_nat_iff (*‹Infinitesimal = {x::?'a::real_normed_vector star. ∀n::nat. hnorm x < inverse (hypreal_of_nat (Suc n))}›*) star_of_def (*‹star_of (?x::?'a::type) ≡ star_n (λn::nat. ?x)›*) hnorm_def (*‹hnorm = *f* norm›*) star_of_nat_def (*‹of_nat (?n::nat) = star_of (of_nat ?n)›*) starfun_star_n (*‹(*f* (?f::?'b::type ⇒ ?'a::type)) (star_n (?X::nat ⇒ ?'b::type)) = star_n (λn::nat. ?f (?X n))›*) star_n_inverse (*‹inverse (star_n (?X::nat ⇒ ?'a::inverse)) = star_n (λn::nat. inverse (?X n))›*) star_n_less (*‹(star_n (?X::nat ⇒ ?'a::ord) < star_n (?Y::nat ⇒ ?'a::ord)) = (∀⇩F n::nat in 𝒰. ?X n < ?Y n)›*)) lemma HNatInfinite_inverse_Infinitesimal [simp]: assumes "n ∈ HNatInfinite" shows "inverse (hypreal_of_hypnat n) ∈ Infinitesimal" proof (cases n) (*goal: ‹⋀X. n = star_n X ⟹ inverse (hypreal_of_hypnat n) ∈ Infinitesimal›*) case (star_n X) (*‹(n::nat star) = star_n (X::nat ⇒ nat)›*) then have "*": "⋀k. ∀⇩F n in 𝒰. k < X n" using HNatInfinite_FreeUltrafilterNat (*‹star_n ?X ∈ HNatInfinite ⟹ ∀u. ∀⇩F n in 𝒰. u < ?X n›*) assms (*‹n ∈ HNatInfinite›*) by blast have "∀⇩F n in 𝒰. inverse (real (X n)) < inverse (1 + real m)" for m using "*"[of "Suc m"] (*‹∀⇩F n in 𝒰. Suc m < X n›*) by (auto elim!: eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*)) then show "?thesis" (*goal: ‹inverse (hypreal_of_hypnat (n::nat star)) ∈ Infinitesimal›*) using star_n (*‹(n::nat star) = star_n (X::nat ⇒ nat)›*) by (auto simp: of_hypnat_def (*‹of_hypnat = *f* of_nat›*) starfun_star_n (*‹(*f* ?f) (star_n ?X) = star_n (λn. ?f (?X n))›*) star_n_inverse (*‹inverse (star_n ?X) = star_n (λn. inverse (?X n))›*) Infinitesimal_FreeUltrafilterNat_iff2 (*‹(star_n ?X ∈ Infinitesimal) = (∀m. ∀⇩F n in 𝒰. norm (?X n) < inverse (real (Suc m)))›*)) qed lemma approx_FreeUltrafilterNat_iff: "star_n X ≈ star_n Y ⟷ (∀r>0. eventually (λn. norm (X n - Y n) < r) 𝒰)" (is "?lhs = ?rhs") proof (-) (*goal: ‹(star_n (X::nat ⇒ 'a) ≈ star_n (Y::nat ⇒ 'a)) = (∀r>0::real. ∀⇩F n::nat in 𝒰. norm (X n - Y n) < r)›*) have "?lhs = (star_n X - star_n Y ≈ 0)" using approx_minus_iff (*‹(?x ≈ ?y) = (?x - ?y ≈ 0)›*) by blast also (*calculation: ‹(star_n X ≈ star_n Y) = (star_n X - star_n Y ≈ 0)›*) have "... = ?rhs" by (metis (full_types) Infinitesimal_FreeUltrafilterNat_iff (*‹(star_n ?X ∈ Infinitesimal) = (∀u>0. ∀⇩F n in 𝒰. norm (?X n) < u)›*) mem_infmal_iff (*‹(?x ∈ Infinitesimal) = (?x ≈ 0)›*) star_n_diff (*‹star_n ?X - star_n ?Y = star_n (λn. ?X n - ?Y n)›*)) finally (*calculation: ‹(star_n X ≈ star_n Y) = (∀r>0. ∀⇩F n in 𝒰. norm (X n - Y n) < r)›*) show "?thesis" (*goal: ‹(star_n X ≈ star_n Y) = (∀r>0. ∀⇩F n in 𝒰. norm (X n - Y n) < r)›*) . qed lemma approx_FreeUltrafilterNat_iff2: "star_n X ≈ star_n Y ⟷ (∀m. eventually (λn. norm (X n - Y n) < inverse (real (Suc m))) 𝒰)" (is "?lhs = ?rhs") proof (-) (*goal: ‹(star_n X ≈ star_n Y) = (∀m. ∀⇩F n in 𝒰. norm (X n - Y n) < inverse (real (Suc m)))›*) have "?lhs = (star_n X - star_n Y ≈ 0)" using approx_minus_iff (*‹(?x ≈ ?y) = (?x - ?y ≈ 0)›*) by blast also (*calculation: ‹(star_n X ≈ star_n Y) = (star_n X - star_n Y ≈ 0)›*) have "... = ?rhs" by (metis (full_types) Infinitesimal_FreeUltrafilterNat_iff2 (*‹(star_n ?X ∈ Infinitesimal) = (∀m. ∀⇩F n in 𝒰. norm (?X n) < inverse (real (Suc m)))›*) mem_infmal_iff (*‹(?x ∈ Infinitesimal) = (?x ≈ 0)›*) star_n_diff (*‹star_n ?X - star_n ?Y = star_n (λn. ?X n - ?Y n)›*)) finally (*calculation: ‹(star_n X ≈ star_n Y) = (∀m. ∀⇩F n in 𝒰. norm (X n - Y n) < inverse (real (Suc m)))›*) show "?thesis" (*goal: ‹(star_n (X::nat ⇒ 'a::real_normed_vector) ≈ star_n (Y::nat ⇒ 'a::real_normed_vector)) = (∀m::nat. ∀⇩F n::nat in 𝒰. norm (X n - Y n) < inverse (real (Suc m)))›*) . qed lemma inj_starfun: "inj starfun" proof (rule inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*)) (*goal: ‹⋀x y. ⟦x ∈ UNIV; y ∈ UNIV; *f* x = *f* y⟧ ⟹ x = y›*) show "φ = ψ" if eq: "*f* φ = *f* ψ" for φ :: "'a ⇒ 'b" and ψ :: "'a ⇒ 'b" apply (rule ext (*‹(⋀x::?'a::type. (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x) ⟹ ?f = ?g›*)) (*goal: ‹(φ::'a::type ⇒ 'b::type) = (ψ::'a::type ⇒ 'b::type)›*) proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹⋀x::'a. (φ::'a ⇒ 'b) x ≠ (ψ::'a ⇒ 'b) x ⟹ False›*) show False if "φ x ≠ ψ x" for x by (metis eq (*‹*f* φ = *f* ψ›*) that (*‹φ x ≠ ψ x›*) star_of_inject (*‹(star_of ?x = star_of ?y) = (?x = ?y)›*) starfun_eq (*‹(*f* ?f) (star_of ?a) = star_of (?f ?a)›*)) qed qed end
{ "path": "Isabelle2024/src/HOL/Nonstandard_Analysis/Star.thy", "repo": "Isabelle2024", "sha": "f2fe68393cc3300a55ac67c42d28a2d8dadb50bee253622db790eb8499c3e0fb" }
section‹The general Rasiowa-Sikorski lemma› theory Rasiowa_Sikorski imports Forcing_Notions Pointed_DC begin context countable_generic begin lemma RS_relation: assumes "p∈P" "n∈nat" shows "∃y∈P. ⟨p,y⟩ ∈ (λm∈nat. {⟨x,y⟩∈P×P. y≼x ∧ y∈𝒟`(pred(m))})`n" proof (-) (*goal: ‹∃y∈P. ⟨p, y⟩ ∈ (λm∈nat. {⟨x,y⟩ ∈ P × P . y ≼ x ∧ y ∈ 𝒟 ` Arith.pred(m)}) ` n›*) from seq_of_denses (*‹∀n∈nat. dense(𝒟 ` n)›*) ‹n∈nat› (*‹(n::i) ∈ nat›*) have "dense(𝒟 ` pred(n))" by simp with ‹p∈P› (*‹p ∈ P›*) have "∃d∈𝒟 ` Arith.pred(n). d≼ p" unfolding dense_def (*goal: ‹∃d∈𝒟 ` Arith.pred(n). d ≼ p›*) by simp then obtain d where 3: "d ∈ 𝒟 ` Arith.pred(n) ∧ d≼ p" (*goal: ‹(⋀d. d ∈ 𝒟 ` Arith.pred(n) ∧ d ≼ p ⟹ thesis) ⟹ thesis›*) by blast from countable_subs_of_P (*‹𝒟 ∈ nat → Pow(P)›*) ‹n∈nat› (*‹(n::i) ∈ nat›*) have "𝒟 ` Arith.pred(n) ∈ Pow(P)" by (blast dest:apply_funtype (*‹⟦?f ∈ ?A → ?B; ?a ∈ ?A⟧ ⟹ ?f ` ?a ∈ ?B›*) intro:pred_type (*‹?i ∈ nat ⟹ Arith.pred(?i) ∈ nat›*)) then have "𝒟 ` Arith.pred(n) ⊆ P" by (rule PowD (*‹?A ∈ Pow(?B) ⟹ ?A ⊆ ?B›*)) with "3" (*‹d ∈ 𝒟 ` Arith.pred(n) ∧ d ≼ p›*) have "d ∈ P ∧ d≼ p ∧ d ∈ 𝒟 ` Arith.pred(n)" by auto with ‹p∈P› (*‹(p::i) ∈ (P::i)›*) ‹n∈nat› (*‹n ∈ nat›*) show "?thesis" (*goal: ‹∃y∈P. ⟨p, y⟩ ∈ (λm∈nat. {⟨x,y⟩ ∈ P × P . y ≼ x ∧ y ∈ 𝒟 ` Arith.pred(m)}) ` n›*) by auto qed lemma DC_imp_RS_sequence: assumes "p∈P" shows "∃f. f: nat→P ∧ f ` 0 = p ∧ (∀n∈nat. f ` succ(n)≼ f ` n ∧ f ` succ(n) ∈ 𝒟 ` n)" proof (-) (*goal: ‹∃f::i. f ∈ nat → (P::i) ∧ f ` 0 = (p::i) ∧ (∀n::i∈nat. f ` succ(n) ≼ f ` n ∧ f ` succ(n) ∈ (𝒟::i) ` n)›*) let ?S = "(λm∈nat. {⟨x,y⟩∈P×P. y≼x ∧ y∈𝒟`(pred(m))})" have "∀x∈P. ∀n∈nat. ∃y∈P. ⟨x,y⟩ ∈ ?S`n" using RS_relation (*‹⟦?p ∈ P; ?n ∈ nat⟧ ⟹ ∃y∈P. ⟨?p, y⟩ ∈ (λm∈nat. {⟨x,y⟩ ∈ P × P . y ≼ x ∧ y ∈ 𝒟 ` Arith.pred(m)}) ` ?n›*) by auto then have "∀a∈P. (∃f ∈ nat→P. f`0 = a ∧ (∀n ∈ nat. ⟨f`n,f`succ(n)⟩∈?S`succ(n)))" using sequence_DC (*‹∀x∈?A. ∀n∈nat. ∃y∈?A. ⟨x, y⟩ ∈ ?S ` n ⟹ ∀a∈?A. ∃f∈nat → ?A. f ` 0 = a ∧ (∀n∈nat. ⟨f ` n, f ` succ(n)⟩ ∈ ?S ` succ(n))›*) by blast with ‹p∈P› (*‹(p::i) ∈ (P::i)›*) show "?thesis" (*goal: ‹∃f. f ∈ nat → P ∧ f ` 0 = p ∧ (∀n∈nat. f ` succ(n) ≼ f ` n ∧ f ` succ(n) ∈ 𝒟 ` n)›*) by auto qed theorem rasiowa_sikorski: "p∈P ⟹ ∃G. p∈G ∧ D_generic(G)" using RS_sequence_imp_rasiowa_sikorski (*‹⟦(?p::i) ∈ (P::i); (?f::i) ∈ nat → P; ?f ` 0 = ?p; ⋀n::i. n ∈ nat ⟹ ?f ` succ(n) ≼ ?f ` n ∧ ?f ` succ(n) ∈ (𝒟::i) ` n⟧ ⟹ ∃G::i. ?p ∈ G ∧ D_generic(G)›*) by (auto dest:DC_imp_RS_sequence (*‹(?p::i) ∈ (P::i) ⟹ ∃f::i. f ∈ nat → P ∧ f ` 0 = ?p ∧ (∀n::i∈nat. f ` succ(n) ≼ f ` n ∧ f ` succ(n) ∈ (𝒟::i) ` n)›*)) end (* countable_generic *) end
{ "path": "afp-2025-02-12/thys/Forcing/Rasiowa_Sikorski.thy", "repo": "afp-2025-02-12", "sha": "690670c21799d096122e1861772c8165da9ab4b9743c25a7e458dc485281bd31" }
(* Author: Norbert Schirmer Maintainer: Norbert Schirmer, norbert.schirmer at web de Copyright (C) 2006-2008 Norbert Schirmer Copyright (c) 2022 Apple Inc. All rights reserved. *) section "Experiments on State Composition" theory Compose imports "../HoareTotalProps" begin text ‹ We develop some theory to support state-space modular development of programs. These experiments aim at the representation of state-spaces with records. If we use ‹statespaces› instead we get this kind of compositionality for free. › subsection ‹Changing the State-Space› (* Lift a command on statespace 'b to work on statespace 'a *) definition lift⇩f:: "('S ⇒ 's) ⇒ ('S ⇒ 's ⇒ 'S) ⇒ ('s ⇒ 's) ⇒ ('S ⇒ 'S)" where "lift⇩f prj inject f = (λS. inject S (f (prj S)))" definition lift⇩s:: "('S ⇒ 's) ⇒ 's set ⇒ 'S set" where "lift⇩s prj A = {S. prj S ∈ A}" definition lift⇩r:: "('S ⇒ 's) ⇒ ('S ⇒ 's ⇒ 'S) ⇒ ('s × 's) set ⇒ ('S × 'S) set" where "lift⇩r prj inject R = {(S,T). (prj S,prj T) ∈ R ∧ T=inject S (prj T)}" primrec lift⇩c:: "('S ⇒ 's) ⇒ ('S ⇒ 's ⇒ 'S) ⇒ ('s,'p,'f) com ⇒ ('S,'p,'f) com" where "lift⇩c prj inject Skip = Skip" | "lift⇩c prj inject (Basic f) = Basic (lift⇩f prj inject f)" | "lift⇩c prj inject (Spec r) = Spec (lift⇩r prj inject r)" | "lift⇩c prj inject (Seq c₁ c₂) = (Seq (lift⇩c prj inject c₁) (lift⇩c prj inject c₂))" | "lift⇩c prj inject (Cond b c₁ c₂) = Cond (lift⇩s prj b) (lift⇩c prj inject c₁) (lift⇩c prj inject c₂)" | "lift⇩c prj inject (While b c) = While (lift⇩s prj b) (lift⇩c prj inject c)" | "lift⇩c prj inject (Call p) = Call p" | "lift⇩c prj inject (DynCom c) = DynCom (λs. lift⇩c prj inject (c (prj s)))" | "lift⇩c prj inject (Guard f g c) = Guard f (lift⇩s prj g) (lift⇩c prj inject c)" | "lift⇩c prj inject Throw = Throw" | "lift⇩c prj inject (Catch c₁ c₂) = Catch (lift⇩c prj inject c₁) (lift⇩c prj inject c₂)" lemma lift⇩c_Skip: "(lift⇩c prj inject c = Skip) = (c = Skip)" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Skip) = (c = Skip)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Basic: "(lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Basic lf) = (∃f. c = Basic f ∧ lf = lift⇩f prj inject f)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Spec: "(lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Spec lr) = (∃r. c = Spec r ∧ lr = lift⇩r prj inject r)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Seq: "(lift⇩c prj inject c = Seq lc₁ lc₂) = (∃ c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂ )" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Seq lc₁ lc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Cond: "(lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂ )" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Cond lb lc₁ lc₂) = (∃b c₁ c₂. c = Cond b c₁ c₂ ∧ lb = lift⇩s prj b ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_While: "(lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = While lb lc') = (∃b c'. c = While b c' ∧ lb = lift⇩s prj b ∧ lc' = lift⇩c prj inject c')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Call: "(lift⇩c prj inject c = Call p) = (c = Call p)" apply (cases c) (*goals: 1. ‹(c::('d, 'b, 'c) com) = Skip ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 2. ‹⋀x2::'d ⇒ 'd. (c::('d, 'b, 'c) com) = Basic x2 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 3. ‹⋀x3::('d × 'd) set. (c::('d, 'b, 'c) com) = Spec x3 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 4. ‹⋀(x41::('d, 'b, 'c) com) x42::('d, 'b, 'c) com. (c::('d, 'b, 'c) com) = Seq x41 x42 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 5. ‹⋀(x51::'d set) (x52::('d, 'b, 'c) com) x53::('d, 'b, 'c) com. (c::('d, 'b, 'c) com) = Cond x51 x52 x53 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 6. ‹⋀(x61::'d set) x62::('d, 'b, 'c) com. (c::('d, 'b, 'c) com) = While x61 x62 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 7. ‹⋀x7::'b. (c::('d, 'b, 'c) com) = Call x7 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 8. ‹⋀x8::'d ⇒ ('d, 'b, 'c) com. (c::('d, 'b, 'c) com) = DynCom x8 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 9. ‹⋀(x91::'c) (x92::'d set) x93::('d, 'b, 'c) com. (c::('d, 'b, 'c) com) = Guard x91 x92 x93 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 10. ‹(c::('d, 'b, 'c) com) = Throw ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› 11. ‹⋀(x111::('d, 'b, 'c) com) x112::('d, 'b, 'c) com. (c::('d, 'b, 'c) com) = Catch x111 x112 ⟹ (lift⇩c (prj::'a ⇒ 'd) (inject::'a ⇒ 'd ⇒ 'a) c = Call (p::'b)) = (c = Call p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_DynCom: "(lift⇩c prj inject c = DynCom lc) = (∃C. c=DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = DynCom lc) = (∃C. c = DynCom C ∧ lc = (λs. lift⇩c prj inject (C (prj s))))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Guard: "(lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Guard f lg lc') = (∃g c'. c = Guard f g c' ∧ lg = lift⇩s prj g ∧ lc' = lift⇩c prj inject c')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Throw: "(lift⇩c prj inject c = Throw) = (c = Throw)" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Throw) = (c = Throw)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma lift⇩c_Catch: "(lift⇩c prj inject c = Catch lc₁ lc₂) = (∃ c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂ )" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 2. ‹⋀x2. c = Basic x2 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 3. ‹⋀x3. c = Spec x3 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 7. ‹⋀x7. c = Call x7 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 8. ‹⋀x8. c = DynCom x8 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 10. ‹c = Throw ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (lift⇩c prj inject c = Catch lc₁ lc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ lc₁ = lift⇩c prj inject c₁ ∧ lc₂ = lift⇩c prj inject c₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . definition xstate_map:: "('S ⇒ 's) ⇒ ('S,'f) xstate ⇒ ('s,'f) xstate" where "xstate_map g x = (case x of Normal s ⇒ Normal (g s) | Abrupt s ⇒ Abrupt (g s) | Fault f ⇒ Fault f | Stuck ⇒ Stuck)" lemma xstate_map_simps [simp]: "xstate_map g (Normal s) = Normal (g s)" "xstate_map g (Abrupt s) = Abrupt (g s)" "xstate_map g (Fault f) = (Fault f)" "xstate_map g Stuck = Stuck" (*goals: 1. ‹xstate_map (g::'c ⇒ 'a) (Normal (s::'c)) = Normal (g s)› 2. ‹xstate_map (g::'c ⇒ 'a) (Abrupt (s::'c)) = Abrupt (g s)› 3. ‹xstate_map (g::'c ⇒ 'a) (Fault (f::'e)) = Fault f› 4. ‹xstate_map (g::'c ⇒ 'a) Stuck = Stuck› discuss goal 1*) apply ((auto simp add: xstate_map_def (*‹xstate_map ?g ?x = (case ?x of Normal s ⇒ Normal (?g s) | Abrupt s ⇒ Abrupt (?g s) | Fault f ⇒ Fault f | Stuck ⇒ Stuck)›*))[1]) (*discuss goal 2*) apply ((auto simp add: xstate_map_def (*‹xstate_map ?g ?x = (case ?x of Normal s ⇒ Normal (?g s) | Abrupt s ⇒ Abrupt (?g s) | Fault f ⇒ Fault f | Stuck ⇒ Stuck)›*))[1]) (*discuss goal 3*) apply ((auto simp add: xstate_map_def (*‹xstate_map ?g ?x = (case ?x of Normal s ⇒ Normal (?g s) | Abrupt s ⇒ Abrupt (?g s) | Fault f ⇒ Fault f | Stuck ⇒ Stuck)›*))[1]) (*discuss goal 4*) apply ((auto simp add: xstate_map_def (*‹xstate_map (?g::?'S ⇒ ?'s) (?x::(?'S, ?'f) xstate) = (case ?x of Normal (s::?'S) ⇒ Normal (?g s) | Abrupt (s::?'S) ⇒ Abrupt (?g s) | Fault (f::?'f) ⇒ Fault f | Stuck ⇒ Stuck)›*))[1]) (*proven 4 subgoals*) . lemma xstate_map_Normal_conv: "xstate_map g S = Normal s = (∃s'. S=Normal s' ∧ s = g s')" apply (cases S) (*goals: 1. ‹⋀x1. S = Normal x1 ⟹ (xstate_map g S = Normal s) = (∃s'. S = Normal s' ∧ s = g s')› 2. ‹⋀x2. S = Abrupt x2 ⟹ (xstate_map g S = Normal s) = (∃s'. S = Normal s' ∧ s = g s')› 3. ‹⋀x3. S = Fault x3 ⟹ (xstate_map g S = Normal s) = (∃s'. S = Normal s' ∧ s = g s')› 4. ‹S = Stuck ⟹ (xstate_map g S = Normal s) = (∃s'. S = Normal s' ∧ s = g s')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemma xstate_map_Abrupt_conv: "xstate_map g S = Abrupt s = (∃s'. S=Abrupt s' ∧ s = g s')" apply (cases S) (*goals: 1. ‹⋀x1. S = Normal x1 ⟹ (xstate_map g S = Abrupt s) = (∃s'. S = Abrupt s' ∧ s = g s')› 2. ‹⋀x2. S = Abrupt x2 ⟹ (xstate_map g S = Abrupt s) = (∃s'. S = Abrupt s' ∧ s = g s')› 3. ‹⋀x3. S = Fault x3 ⟹ (xstate_map g S = Abrupt s) = (∃s'. S = Abrupt s' ∧ s = g s')› 4. ‹S = Stuck ⟹ (xstate_map g S = Abrupt s) = (∃s'. S = Abrupt s' ∧ s = g s')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemma xstate_map_Fault_conv: "xstate_map g S = Fault f = (S=Fault f)" apply (cases S) (*goals: 1. ‹⋀x1. S = Normal x1 ⟹ (xstate_map g S = Fault f) = (S = Fault f)› 2. ‹⋀x2. S = Abrupt x2 ⟹ (xstate_map g S = Fault f) = (S = Fault f)› 3. ‹⋀x3. S = Fault x3 ⟹ (xstate_map g S = Fault f) = (S = Fault f)› 4. ‹S = Stuck ⟹ (xstate_map g S = Fault f) = (S = Fault f)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemma xstate_map_Stuck_conv: "xstate_map g S = Stuck = (S=Stuck)" apply (cases S) (*goals: 1. ‹⋀x1. S = Normal x1 ⟹ (xstate_map g S = Stuck) = (S = Stuck)› 2. ‹⋀x2. S = Abrupt x2 ⟹ (xstate_map g S = Stuck) = (S = Stuck)› 3. ‹⋀x3. S = Fault x3 ⟹ (xstate_map g S = Stuck) = (S = Stuck)› 4. ‹S = Stuck ⟹ (xstate_map g S = Stuck) = (S = Stuck)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemmas xstate_map_convs = xstate_map_Normal_conv xstate_map_Abrupt_conv xstate_map_Fault_conv xstate_map_Stuck_conv definition state:: "('s,'f) xstate ⇒ 's" where "state x = (case x of Normal s ⇒ s | Abrupt s ⇒ s | Fault g ⇒ undefined | Stuck ⇒ undefined)" lemma state_simps [simp]: "state (Normal s) = s" "state (Abrupt s) = s" (*goals: 1. ‹state (Normal s) = s› 2. ‹state (Abrupt s) = s› discuss goal 1*) apply ((auto simp add: state_def (*‹state (?x::(?'s, ?'f) xstate) = (case ?x of Normal (s::?'s) ⇒ s | Abrupt (s::?'s) ⇒ s)›*))[1]) (*discuss goal 2*) apply ((auto simp add: state_def (*‹state ?x = (case ?x of Normal s ⇒ s | Abrupt s ⇒ s)›*))[1]) (*proven 2 subgoals*) . locale lift_state_space = fixes project::"'S ⇒ 's" fixes "inject"::"'S ⇒ 's ⇒ 'S" fixes "project⇩x"::"('S,'f) xstate ⇒ ('s,'f) xstate" fixes "lift⇩e"::"('s,'p,'f) body ⇒ ('S,'p,'f) body" fixes lift⇩c:: "('s,'p,'f) com ⇒ ('S,'p,'f) com" fixes lift⇩f:: "('s ⇒ 's) ⇒ ('S ⇒ 'S)" fixes lift⇩s:: "'s set ⇒ 'S set" fixes lift⇩r:: "('s × 's) set ⇒ ('S × 'S) set" assumes proj_inj_commute: "⋀S s. project (inject S s) = s" defines "lift⇩c ≡ Compose.lift⇩c project inject" defines "project⇩x ≡ xstate_map project" defines "lift⇩e ≡ (λΓ p. map_option lift⇩c (Γ p))" defines "lift⇩f ≡ Compose.lift⇩f project inject" defines "lift⇩s ≡ Compose.lift⇩s project" defines "lift⇩r ≡ Compose.lift⇩r project inject" lemma (in lift_state_space) lift⇩f_simp: "lift⇩f f ≡ λS. inject S (f (project S))" by (simp add: lift⇩f_def (*‹lift⇩f ≡ lift⇩f project inject›*) Compose.lift⇩f_def (*‹lift⇩f ?prj ?inject ?f = (λS. ?inject S (?f (?prj S)))›*)) lemma (in lift_state_space) lift⇩s_simp: "lift⇩s A ≡ {S. project S ∈ A}" by (simp add: lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*)) lemma (in lift_state_space) lift⇩r_simp: "lift⇩r R ≡ {(S,T). (project S,project T) ∈ R ∧ T=inject S (project T)}" by (simp add: lift⇩r_def (*‹lift⇩r ≡ lift⇩r project inject›*) Compose.lift⇩r_def (*‹lift⇩r ?prj ?inject ?R = {(S, T). (?prj S, ?prj T) ∈ ?R ∧ T = ?inject S (?prj T)}›*)) (* Causes loop when instantiating locale lemmas (in lift_state_space) lift⇩f_simp = Compose.lift⇩f_def [of project "inject", folded lift⇩f_def] lemmas (in lift_state_space) lift⇩s_simp = Compose.lift⇩s_def [of project, folded lift⇩s_def] lemmas (in lift_state_space) lift⇩r_simp = Compose.lift⇩r_def [of project "inject", folded lift⇩r_def] *) lemma (in lift_state_space) lift⇩c_Skip_simp [simp]: "lift⇩c Skip = Skip" by (simp add: lift⇩c_def (*‹lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com ≡ lift⇩c (project::'S::type ⇒ 's::type) (inject::'S::type ⇒ 's::type ⇒ 'S::type)›*)) lemma (in lift_state_space) lift⇩c_Basic_simp [simp]: "lift⇩c (Basic f) = Basic (lift⇩f f)" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩f_def (*‹lift⇩f ≡ lift⇩f project inject›*)) lemma (in lift_state_space) lift⇩c_Spec_simp [simp]: "lift⇩c (Spec r) = Spec (lift⇩r r)" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩r_def (*‹lift⇩r ≡ lift⇩r project inject›*)) lemma (in lift_state_space) lift⇩c_Seq_simp [simp]: "lift⇩c (Seq c₁ c₂) = (Seq (lift⇩c c₁) (lift⇩c c₂))" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) lemma (in lift_state_space) lift⇩c_Cond_simp [simp]: "lift⇩c (Cond b c₁ c₂) = Cond (lift⇩s b) (lift⇩c c₁) (lift⇩c c₂)" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*)) lemma (in lift_state_space) lift⇩c_While_simp [simp]: "lift⇩c (While b c) = While (lift⇩s b) (lift⇩c c)" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*)) lemma (in lift_state_space) lift⇩c_Call_simp [simp]: "lift⇩c (Call p) = Call p" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) lemma (in lift_state_space) lift⇩c_DynCom_simp [simp]: "lift⇩c (DynCom c) = DynCom (λs. lift⇩c (c (project s)))" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) lemma (in lift_state_space) lift⇩c_Guard_simp [simp]: "lift⇩c (Guard f g c) = Guard f (lift⇩s g) (lift⇩c c)" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*)) lemma (in lift_state_space) lift⇩c_Throw_simp [simp]: "lift⇩c Throw = Throw" by (simp add: lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) lemma (in lift_state_space) lift⇩c_Catch_simp [simp]: "lift⇩c (Catch c₁ c₂) = Catch (lift⇩c c₁) (lift⇩c c₂)" by (simp add: lift⇩c_def (*‹lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com ≡ lift⇩c (project::'S ⇒ 's) (inject::'S ⇒ 's ⇒ 'S)›*)) lemma (in lift_state_space) project⇩x_def': "project⇩x s ≡ (case s of Normal s ⇒ Normal (project s) | Abrupt s ⇒ Abrupt (project s) | Fault f ⇒ Fault f | Stuck ⇒ Stuck)" by (simp add: xstate_map_def (*‹xstate_map ?g ?x = (case ?x of Normal s ⇒ Normal (?g s) | Abrupt s ⇒ Abrupt (?g s) | Fault f ⇒ Fault f | Stuck ⇒ Stuck)›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) lemma (in lift_state_space) lift⇩e_def': "lift⇩e Γ p ≡ (case Γ p of Some bdy ⇒ Some (lift⇩c bdy) | None ⇒ None)" by (simp add: lift⇩e_def (*‹lift⇩e ≡ λΓ p. map_option lift⇩c (Γ p)›*) map_option_case (*‹map_option ?f ?y = (case ?y of None ⇒ None | Some x ⇒ Some (?f x))›*)) text ‹ The problem is that @{term "(lift⇩c project inject ∘ Γ)"} is quite a strong premise. The problem is that @{term "Γ"} is a function here. A map would be better. We only have to lift those procedures in the domain of @{term "Γ"}: ‹Γ p = Some bdy ⟶ Γ' p = Some lift⇩c project inject bdy›. We then can com up with theorems that allow us to extend the domains of @{term Γ} and preserve validity. › lemma (in lift_state_space) "{(S,T). ∃t. (project S,t) ∈ r ∧ T=inject S t} ⊆ {(S,T). (project S,project T) ∈ r ∧ T=inject S (project T)}" apply clarsimp (*goal: ‹{(S, T). ∃t. (project S, t) ∈ r ∧ T = inject S t} ⊆ {(S, T). (project S, project T) ∈ r ∧ T = inject S (project T)}›*) apply (rename_tac S t) (*goal: ‹⋀(a::'S) t::'s. ((project::'S ⇒ 's) a, t) ∈ (r::('s × 's) set) ⟹ (project a, project ((inject::'S ⇒ 's ⇒ 'S) a t)) ∈ r ∧ inject a t = inject a (project (inject a t))›*) by (simp add: proj_inj_commute (*‹project (inject ?S ?s) = ?s›*)) lemma (in lift_state_space) "{(S,T). (project S,project T) ∈ r ∧ T=inject S (project T)} ⊆ {(S,T). ∃t. (project S,t) ∈ r ∧ T=inject S t}" apply clarsimp (*goal: ‹{(S, T). (project S, project T) ∈ r ∧ T = inject S (project T)} ⊆ {(S, T). ∃t. (project S, t) ∈ r ∧ T = inject S t}›*) apply (rename_tac S T) (*goal: ‹⋀a b. ⟦(project a, project b) ∈ r; b = inject a (project b)⟧ ⟹ ∃t. (project a, t) ∈ r ∧ b = inject a t›*) apply (rule_tac x="project T" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀S T. ⟦(project S, project T) ∈ r; T = inject S (project T)⟧ ⟹ ∃t. (project S, t) ∈ r ∧ T = inject S t›*) by simp lemma (in lift_state_space) lift_exec: assumes exec_lc: "(lift⇩e Γ)⊢⟨lc,s⟩ ⇒ t" shows "⋀c. ⟦ lift⇩c c = lc⟧ ⟹ Γ⊢⟨c,project⇩x s⟩ ⇒ project⇩x t" using exec_lc (*‹lift⇩e Γ⊢ ⟨lc,s⟩ ⇒ t›*) proof (induct) (*goals: 1. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Skip ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal s)› 2. ‹⋀(s::'S) (g::'S set) (c::('S, 'p, 'f) com) (t::('S, 'f) xstate) (f::'f) ca::('s, 'p, 'f) com. ⟦s ∈ g; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = Guard f g c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀(s::'S) (g::'S set) (f::'f) (c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. ⟦s ∉ g; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = Guard f g c⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Fault f)› 4. ‹⋀(c::('S, 'p, 'f) com) (f::'f) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Fault f)⟩ ⇒ project⇩x (Fault f)› 5. ‹⋀(f::'S ⇒ 'S) (s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Basic f ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal (f s))› 6. ‹⋀(s::'S) (t::'S) (r::('S × 'S) set) c::('s, 'p, 'f) com. ⟦(s, t) ∈ r; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Spec r⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal t)› 7. ‹⋀(s::'S) (r::('S × 'S) set) c::('s, 'p, 'f) com. ⟦∀t::'S. (s, t) ∉ r; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Spec r⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 8. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀(s::'S) (b::'S set) (c₁::('S, 'p, 'f) com) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 10. ‹⋀(s::'S) (b::'S set) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) (c₁::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₂ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 11. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) (s'::('S, 'f) xstate) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 12. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = While b c⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal s)› 13. ‹⋀(p::'p) (bdy::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = bdy ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 14. ‹⋀(p::'p) (s::'S) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Call p⟧ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 15. ‹⋀(c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) Stuck⟩ ⇒ project⇩x Stuck› 16. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 17. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 18. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 19. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 20. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Skip (*‹lift⇩c c = Skip›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x (Normal s_)›*) by (auto simp add: project⇩x_def (*‹project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate ≡ xstate_map (project::'S ⇒ 's)›*) lift⇩c_Skip (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = Skip) = (?c = Skip)›*) lift⇩c_def (*‹lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com ≡ lift⇩c (project::'S ⇒ 's) (inject::'S ⇒ 's ⇒ 'S)›*) intro: exec.Skip (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Skip,Normal (?s::?'s)⟩ ⇒ Normal ?s›*)) next (*goals: 1. ‹⋀s g c t f ca. ⟦s ∈ g; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = Guard f g c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀s g f c ca. ⟦s ∉ g; lift⇩c ca = Guard f g c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Fault f)› 3. ‹⋀c f ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Fault f)⟩ ⇒ project⇩x (Fault f)› 4. ‹⋀f s c. lift⇩c c = Basic f ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal (f s))› 5. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal t)› 6. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 7. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 10. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 11. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 12. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 13. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 14. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 15. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 16. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 17. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 18. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 19. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Guard (*‹s_ ∈ g_› ‹lift⇩e Γ⊢ ⟨c_,Normal s_⟩ ⇒ t_› ‹lift⇩c ?c = c_ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_› ‹lift⇩c c = Guard f_ g_ c_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) lift⇩c_Guard (*‹(lift⇩c ?prj ?inject ?c = Guard ?f ?lg ?lc') = (∃g c'. ?c = Guard ?f g c' ∧ ?lg = lift⇩s ?prj g ∧ ?lc' = lift⇩c ?prj ?inject c')›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.Guard (*‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t›*)) next (*goals: 1. ‹⋀s g f c ca. ⟦s ∉ g; lift⇩c ca = Guard f g c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Fault f)› 2. ‹⋀c f ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Fault f)⟩ ⇒ project⇩x (Fault f)› 3. ‹⋀f s c. lift⇩c c = Basic f ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal (f s))› 4. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal t)› 5. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 6. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 10. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 11. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 12. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 13. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 14. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 15. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 16. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 17. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 18. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case GuardFault (*‹s_ ∉ g_› ‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c::('s, 'p, 'f) com) = Guard (f_::'f) (g_::'S set) (c_::('S, 'p, 'f) com)›*) thus "?case" (*goal: ‹(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s_::'S))⟩ ⇒ project⇩x (Fault (f_::'f))›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) lift⇩c_Guard (*‹(lift⇩c ?prj ?inject ?c = Guard ?f ?lg ?lc') = (∃g c'. ?c = Guard ?f g c' ∧ ?lg = lift⇩s ?prj g ∧ ?lc' = lift⇩c ?prj ?inject c')›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.GuardFault (*‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f›*)) next (*goals: 1. ‹⋀c f ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Fault f)⟩ ⇒ project⇩x (Fault f)› 2. ‹⋀f s c. lift⇩c c = Basic f ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal (f s))› 3. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal t)› 4. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 5. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 10. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 11. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 12. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 13. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 14. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 15. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 16. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 17. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case FaultProp (*‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c::('s, 'p, 'f) com) = (c_::('S, 'p, 'f) com)›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Fault f_)⟩ ⇒ project⇩x (Fault f_)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) next (*goals: 1. ‹⋀f s c. lift⇩c c = Basic f ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal (f s))› 2. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal t)› 3. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 4. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 9. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 10. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 11. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 12. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 13. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 14. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 15. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 16. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Basic (*‹lift⇩c c = Basic f_›*) thus "?case" (*goal: ‹(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s_::'S))⟩ ⇒ project⇩x (Normal ((f_::'S ⇒ 'S) s_))›*) by (fastforce simp add: project⇩x_def (*‹project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate ≡ xstate_map (project::'S::type ⇒ 's::type)›*) lift⇩c_Basic (*‹(lift⇩c (?prj::?'a::type ⇒ ?'d::type) (?inject::?'a::type ⇒ ?'d::type ⇒ ?'a::type) (?c::(?'d::type, ?'b::type, ?'c::type) com) = Basic (?lf::?'a::type ⇒ ?'a::type)) = (∃f::?'d::type ⇒ ?'d::type. ?c = Basic f ∧ ?lf = lift⇩f ?prj ?inject f)›*) lift⇩f_def (*‹lift⇩f::('s::type ⇒ 's::type) ⇒ 'S::type ⇒ 'S::type ≡ lift⇩f (project::'S::type ⇒ 's::type) (inject::'S::type ⇒ 's::type ⇒ 'S::type)›*) Compose.lift⇩f_def (*‹lift⇩f (?prj::?'S::type ⇒ ?'s::type) (?inject::?'S::type ⇒ ?'s::type ⇒ ?'S::type) (?f::?'s::type ⇒ ?'s::type) = (λS::?'S::type. ?inject S (?f (?prj S)))›*) lift⇩c_def (*‹lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com ≡ lift⇩c (project::'S::type ⇒ 's::type) (inject::'S::type ⇒ 's::type ⇒ 'S::type)›*) proj_inj_commute (*‹(project::'S::type ⇒ 's::type) ((inject::'S::type ⇒ 's::type ⇒ 'S::type) (?S::'S::type) (?s::'s::type)) = ?s›*) intro: exec.Basic (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Basic (?f::?'s::type ⇒ ?'s::type),Normal (?s::?'s::type)⟩ ⇒ Normal (?f ?s)›*)) next (*goals: 1. ‹⋀(s::'S) (t::'S) (r::('S × 'S) set) c::('s, 'p, 'f) com. ⟦(s, t) ∈ r; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Spec r⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal t)› 2. ‹⋀(s::'S) (r::('S × 'S) set) c::('s, 'p, 'f) com. ⟦∀t::'S. (s, t) ∉ r; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Spec r⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 3. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀(s::'S) (b::'S set) (c₁::('S, 'p, 'f) com) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀(s::'S) (b::'S set) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) (c₁::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₂ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) (s'::('S, 'f) xstate) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = While b c⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal s)› 8. ‹⋀(p::'p) (bdy::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = bdy ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀(p::'p) (s::'S) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Call p⟧ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 10. ‹⋀(c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) Stuck⟩ ⇒ project⇩x Stuck› 11. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 12. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 13. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 14. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 15. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Spec (*‹(s_, t_) ∈ r_› ‹lift⇩c c = Spec r_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x (Normal t_)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Spec (*‹(lift⇩c ?prj ?inject ?c = Spec ?lr) = (∃r. ?c = Spec r ∧ ?lr = lift⇩r ?prj ?inject r)›*) lift⇩f_def (*‹lift⇩f ≡ lift⇩f project inject›*) Compose.lift⇩f_def (*‹lift⇩f ?prj ?inject ?f = (λS. ?inject S (?f (?prj S)))›*) lift⇩r_def (*‹lift⇩r ≡ lift⇩r project inject›*) Compose.lift⇩r_def (*‹lift⇩r ?prj ?inject ?R = {(S, T). (?prj S, ?prj T) ∈ ?R ∧ T = ?inject S (?prj T)}›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) proj_inj_commute (*‹project (inject ?S ?s) = ?s›*) intro: exec.Spec (*‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t›*)) next (*goals: 1. ‹⋀(s::'S) (r::('S × 'S) set) c::('s, 'p, 'f) com. ⟦∀t::'S. (s, t) ∉ r; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Spec r⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 2. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀(s::'S) (b::'S set) (c₁::('S, 'p, 'f) com) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀(s::'S) (b::'S set) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) (c₁::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₂ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) (s'::('S, 'f) xstate) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = While b c⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal s)› 7. ‹⋀(p::'p) (bdy::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = bdy ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀(p::'p) (s::'S) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Call p⟧ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 9. ‹⋀(c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) Stuck⟩ ⇒ project⇩x Stuck› 10. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 11. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 12. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 13. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 14. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case (SpecStuck s r) (*‹∀t. (s, t) ∉ r› ‹(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c::('s::type, 'p::type, 'f::type) com) = Spec (r::('S::type × 'S::type) set)›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck›*) apply (simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck›*) apply (clarsimp simp add: lift⇩c_Spec (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = Spec (?lr::(?'a × ?'a) set)) = (∃r::(?'d × ?'d) set. ?c = Spec r ∧ ?lr = lift⇩r ?prj ?inject r)›*) lift⇩c_def (*‹lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com ≡ lift⇩c (project::'S ⇒ 's) (inject::'S ⇒ 's ⇒ 'S)›*)) (*goal: ‹⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r⟧ ⟹ Γ⊢ ⟨c,Normal (project s)⟩ ⇒ Stuck›*) apply (unfold lift⇩r_def (*‹lift⇩r::('s × 's) set ⇒ ('S × 'S) set ≡ lift⇩r (project::'S ⇒ 's) (inject::'S ⇒ 's ⇒ 'S)›*) Compose.lift⇩r_def (*‹lift⇩r (?prj::?'S ⇒ ?'s) (?inject::?'S ⇒ ?'s ⇒ ?'S) (?R::(?'s × ?'s) set) = {(S::?'S, T::?'S). (?prj S, ?prj T) ∈ ?R ∧ T = ?inject S (?prj T)}›*)) (*goal: ‹⋀ra. ⟦∀t. (s, t) ∉ lift⇩r project inject ra; r = lift⇩r project inject ra; c = Spec ra⟧ ⟹ Γ⊢ ⟨Spec ra,Normal (project s)⟩ ⇒ Stuck›*) apply (rule exec.SpecStuck (*‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck›*)) (*goal: ‹⋀ra::('s × 's) set. ⟦∀t::'S. (s::'S, t) ∉ {(S::'S, T::'S). ((project::'S ⇒ 's) S, project T) ∈ ra ∧ T = (inject::'S ⇒ 's ⇒ 'S) S (project T)}; (r::('S × 'S) set) = {(S::'S, T::'S). (project S, project T) ∈ ra ∧ T = inject S (project T)}; (c::('s, 'p, 'f) com) = Spec ra⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨Spec ra,Normal (project s)⟩ ⇒ Stuck›*) apply (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*)) (*goal: ‹⋀ra. ⟦∀t. (s, t) ∉ {(S, T). (project S, project T) ∈ ra ∧ T = inject S (project T)}; r = {(S, T). (project S, project T) ∈ ra ∧ T = inject S (project T)}; c = Spec ra⟧ ⟹ ∀t. (project s, t) ∉ ra›*) apply (erule_tac x="inject s t" in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀(ra::('s::type × 's::type) set) t::'s::type. ⟦∀t::'S::type. (s::'S::type, t) ∉ {(S::'S::type, T::'S::type). ((project::'S::type ⇒ 's::type) S, project T) ∈ ra ∧ T = (inject::'S::type ⇒ 's::type ⇒ 'S::type) S (project T)}; (r::('S::type × 'S::type) set) = {(S::'S::type, T::'S::type). (project S, project T) ∈ ra ∧ T = inject S (project T)}; (c::('s::type, 'p::type, 'f::type) com) = Spec ra⟧ ⟹ (project s, t) ∉ ra›*) apply clarsimp (*goal: ‹⋀ra t. ⟦r = {(S, T). (project S, project T) ∈ ra ∧ T = inject S (project T)}; c = Spec ra; (s, inject s t) ∉ {(S, T). (project S, project T) ∈ ra ∧ T = inject S (project T)}⟧ ⟹ (project s, t) ∉ ra›*) by (simp add: proj_inj_commute (*‹project (inject ?S ?s) = ?s›*)) next (*goals: 1. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c c = Seq c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 6. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 8. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 9. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 10. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 11. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 12. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 13. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Seq (*‹lift⇩e Γ⊢ ⟨c₁_,Normal s_⟩ ⇒ s'_› ‹lift⇩c ?c = c₁_ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s_)⟩ ⇒ project⇩x s'_› ‹lift⇩e Γ⊢ ⟨c₂_,s'_⟩ ⇒ t_› ‹lift⇩c ?c = c₂_ ⟹ Γ⊢ ⟨?c,project⇩x s'_⟩ ⇒ project⇩x t_› ‹lift⇩c c = Seq c₁_ c₂_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Seq (*‹(lift⇩c ?prj ?inject ?c = Seq ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Seq c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 5. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 7. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 8. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 10. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 11. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 12. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case CondTrue (*‹s_ ∈ b_› ‹lift⇩e Γ⊢ ⟨c₁_,Normal s_⟩ ⇒ t_› ‹lift⇩c ?c = c₁_ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_› ‹(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c::('s::type, 'p::type, 'f::type) com) = Cond (b_::'S::type set) (c₁_::('S::type, 'p::type, 'f::type) com) (c₂_::('S::type, 'p::type, 'f::type) com)›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) lift⇩c_Cond (*‹(lift⇩c ?prj ?inject ?c = Cond ?lb ?lc₁ ?lc₂) = (∃b c₁ c₂. ?c = Cond b c₁ c₂ ∧ ?lb = lift⇩s ?prj b ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.CondTrue (*‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t›*)) next (*goals: 1. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Cond b c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x (Normal s)› 4. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = bdy ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 6. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 7. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 9. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 10. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 11. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case CondFalse (*‹(s_::'S) ∉ (b_::'S set)› ‹lift⇩e Γ⊢ ⟨c₂_,Normal s_⟩ ⇒ t_› ‹lift⇩c ?c = c₂_ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_› ‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c::('s, 'p, 'f) com) = Cond (b_::'S set) (c₁_::('S, 'p, 'f) com) (c₂_::('S, 'p, 'f) com)›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) lift⇩c_Cond (*‹(lift⇩c ?prj ?inject ?c = Cond ?lb ?lc₁ ?lc₂) = (∃b c₁ c₂. ?c = Cond b c₁ c₂ ∧ ?lb = lift⇩s ?prj b ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.CondFalse (*‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t›*)) next (*goals: 1. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) (s'::('S, 'f) xstate) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦s ∈ b; (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x s'; lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. lift⇩c ca = While b c ⟹ Γ⊢ ⟨ca,project⇩x s'⟩ ⇒ project⇩x t; lift⇩c ca = While b c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = While b c⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal s)› 3. ‹⋀(p::'p) (bdy::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = bdy ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀(p::'p) (s::'S) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Call p⟧ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 5. ‹⋀(c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) Stuck⟩ ⇒ project⇩x Stuck› 6. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 8. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 9. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 10. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case WhileTrue (*‹s_ ∈ b_› ‹lift⇩e Γ⊢ ⟨c_,Normal s_⟩ ⇒ s'_› ‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (?c::('s, 'p, 'f) com) = (c_::('S, 'p, 'f) com) ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨?c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s_::'S))⟩ ⇒ project⇩x (s'_::('S, 'f) xstate)› ‹lift⇩e Γ⊢ ⟨While b_ c_,s'_⟩ ⇒ t_› ‹lift⇩c ?c = While b_ c_ ⟹ Γ⊢ ⟨?c,project⇩x s'_⟩ ⇒ project⇩x t_› ‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c::('s, 'p, 'f) com) = While (b_::'S set) (c_::('S, 'p, 'f) com)›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) lift⇩c_While (*‹(lift⇩c ?prj ?inject ?c = While ?lb ?lc') = (∃b c'. ?c = While b c' ∧ ?lb = lift⇩s ?prj b ∧ ?lc' = lift⇩c ?prj ?inject c')›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.WhileTrue (*‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t›*)) next (*goals: 1. ‹⋀(s::'S) (b::'S set) (c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. ⟦s ∉ b; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = While b c⟧ ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Normal s)› 2. ‹⋀(p::'p) (bdy::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = bdy ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀(p::'p) (s::'S) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Call p⟧ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 4. ‹⋀(c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) Stuck⟩ ⇒ project⇩x Stuck› 5. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 7. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 8. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 9. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case WhileFalse (*‹(s_::'S) ∉ (b_::'S set)› ‹lift⇩c c = While b_ c_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x (Normal s_)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) lift⇩c_While (*‹(lift⇩c ?prj ?inject ?c = While ?lb ?lc') = (∃b c'. ?c = While b c' ∧ ?lb = lift⇩s ?prj b ∧ ?lc' = lift⇩c ?prj ?inject c')›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.WhileFalse (*‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s›*)) next (*goals: 1. ‹⋀(p::'p) (bdy::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = bdy ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀(p::'p) (s::'S) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Call p⟧ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x Stuck› 3. ‹⋀(c::('S, 'p, 'f) com) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) Stuck⟩ ⇒ project⇩x Stuck› 4. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 6. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 7. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 8. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Call (*‹lift⇩e Γ p_ = Some bdy_› ‹lift⇩e Γ⊢ ⟨bdy_,Normal s_⟩ ⇒ t_› ‹lift⇩c ?c = bdy_ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_› ‹(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c::('s::type, 'p::type, 'f::type) com) = Call (p_::'p::type)›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Call (*‹(lift⇩c ?prj ?inject ?c = Call ?p) = (?c = Call ?p)›*) lift⇩f_def (*‹lift⇩f ≡ lift⇩f project inject›*) Compose.lift⇩f_def (*‹lift⇩f ?prj ?inject ?f = (λS. ?inject S (?f (?prj S)))›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩e_def (*‹lift⇩e ≡ λΓ p. map_option lift⇩c (Γ p)›*) intro: exec.Call (*‹⟦?Γ ?p = Some ?bdy; ?Γ⊢ ⟨?bdy,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Call ?p,Normal ?s⟩ ⇒ ?t›*)) next (*goals: 1. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x Stuck› 2. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 3. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 5. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 6. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 7. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case CallUndefined (*‹lift⇩e Γ p_ = None› ‹lift⇩c c = Call p_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x Stuck›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Call (*‹(lift⇩c ?prj ?inject ?c = Call ?p) = (?c = Call ?p)›*) lift⇩f_def (*‹lift⇩f ≡ lift⇩f project inject›*) Compose.lift⇩f_def (*‹lift⇩f ?prj ?inject ?f = (λS. ?inject S (?f (?prj S)))›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) lift⇩e_def (*‹lift⇩e ≡ λΓ p. map_option lift⇩c (Γ p)›*) intro: exec.CallUndefined (*‹?Γ ?p = None ⟹ ?Γ⊢ ⟨Call ?p,Normal ?s⟩ ⇒ Stuck›*)) next (*goals: 1. ‹⋀c ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x Stuck⟩ ⇒ project⇩x Stuck› 2. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. lift⇩c ca = c s ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 4. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 5. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 6. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case StuckProp (*‹lift⇩c c = c_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x Stuck⟩ ⇒ project⇩x Stuck›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) next (*goals: 1. ‹⋀(c::'S ⇒ ('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) ca::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c s ⟹ Γ⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; lift⇩c ca = DynCom c⟧ ⟹ Γ⊢ ⟨ca,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀(s::'S) c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = Throw ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 3. ‹⋀(c::('S, 'p, 'f) com) (s::'S) ca::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ca = c ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨ca,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 4. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 5. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case DynCom (*‹lift⇩e Γ⊢ ⟨c_ s_,Normal s_⟩ ⇒ t_› ‹lift⇩c ?c = c_ s_ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_› ‹lift⇩c c = DynCom c_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_DynCom (*‹(lift⇩c ?prj ?inject ?c = DynCom ?lc) = (∃C. ?c = DynCom C ∧ ?lc = (λs. lift⇩c ?prj ?inject (C (?prj s))))›*) lift⇩f_def (*‹lift⇩f ≡ lift⇩f project inject›*) Compose.lift⇩f_def (*‹lift⇩f ?prj ?inject ?f = (λS. ?inject S (?f (?prj S)))›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.DynCom (*‹?Γ⊢ ⟨?c ?s,Normal ?s⟩ ⇒ ?t ⟹ ?Γ⊢ ⟨DynCom ?c,Normal ?s⟩ ⇒ ?t›*)) next (*goals: 1. ‹⋀s c. lift⇩c c = Throw ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s)› 2. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 3. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case Throw (*‹lift⇩c c = Throw›*) thus "?case" (*goal: ‹(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s_::'S))⟩ ⇒ project⇩x (Abrupt s_)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Throw (*‹(lift⇩c ?prj ?inject ?c = Throw) = (?c = Throw)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.Throw (*‹?Γ⊢ ⟨Throw,Normal ?s⟩ ⇒ Abrupt ?s›*)) next (*goals: 1. ‹⋀c s ca. lift⇩c ca = c ⟹ Γ⊢ ⟨ca,project⇩x (Abrupt s)⟩ ⇒ project⇩x (Abrupt s)› 2. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case AbruptProp (*‹lift⇩c c = c_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Abrupt s_)⟩ ⇒ project⇩x (Abrupt s_)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) next (*goals: 1. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (s'::'S) (c₂::('S, 'p, 'f) com) (t::('S, 'f) xstate) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x (Abrupt s'); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. lift⇩c c = c₂ ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀(c₁::('S, 'p, 'f) com) (s::'S) (t::('S, 'f) xstate) (c₂::('S, 'p, 'f) com) c::('s, 'p, 'f) com. ⟦(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('s, 'p, 'f) com. (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c = c₁ ⟹ Γ⊢ ⟨c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case CatchMatch (*‹lift⇩e Γ⊢ ⟨c₁_,Normal s_⟩ ⇒ Abrupt s'_› ‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (?c::('s, 'p, 'f) com) = (c₁_::('S, 'p, 'f) com) ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨?c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s_::'S))⟩ ⇒ project⇩x (Abrupt (s'_::'S))› ‹lift⇩e Γ⊢ ⟨c₂_,Normal s'_⟩ ⇒ t_› ‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (?c::('s, 'p, 'f) com) = (c₂_::('S, 'p, 'f) com) ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨?c,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s'_::'S))⟩ ⇒ project⇩x (t_::('S, 'f) xstate)› ‹lift⇩c c = Catch c₁_ c₂_›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s_)⟩ ⇒ project⇩x t_›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Catch (*‹(lift⇩c ?prj ?inject ?c = Catch ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.CatchMatch (*‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ Abrupt ?s'; ?Γ⊢ ⟨?c₂,Normal ?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Catch ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t›*)) next (*goal: ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) case (CatchMiss c₁ s t c₂ c) (*‹lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t› ‹lift⇩c ?c = c₁ ⟹ Γ⊢ ⟨?c,project⇩x (Normal s)⟩ ⇒ project⇩x t› ‹¬ isAbr t› ‹lift⇩c c = Catch c₁ c₂›*) thus "?case" (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) apply (cases t) (*goals: 1. ‹⋀x1. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t = Normal x1⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 2. ‹⋀x2. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t = Abrupt x2⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 3. ‹⋀x3. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t = Fault x3⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› 4. ‹⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. lift⇩c c = c₁ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t; ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t = Stuck⟧ ⟹ Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t› discuss goal 1*) apply (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Catch (*‹(lift⇩c ?prj ?inject ?c = Catch ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.CatchMiss (*‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t; ¬ isAbr ?t⟧ ⟹ ?Γ⊢ ⟨Catch ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t›*)) (*discuss goal 2*) apply (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Catch (*‹(lift⇩c ?prj ?inject ?c = Catch ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.CatchMiss (*‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t; ¬ isAbr ?t⟧ ⟹ ?Γ⊢ ⟨Catch ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t›*)) (*discuss goal 3*) apply (fastforce simp add: project⇩x_def (*‹project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate ≡ xstate_map (project::'S ⇒ 's)›*) lift⇩c_Catch (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = Catch (?lc₁::(?'a, ?'b, ?'c) com) (?lc₂::(?'a, ?'b, ?'c) com)) = (∃(c₁::(?'d, ?'b, ?'c) com) c₂::(?'d, ?'b, ?'c) com. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com ≡ lift⇩c (project::'S ⇒ 's) (inject::'S ⇒ 's ⇒ 'S)›*) intro: exec.CatchMiss (*‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal (?s::?'s)⟩ ⇒ (?t::(?'s, ?'f) xstate); ¬ isAbr ?t⟧ ⟹ ?Γ⊢ ⟨Catch ?c₁ (?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ ?t›*)) (*discuss goal 4*) apply (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩c_Catch (*‹(lift⇩c ?prj ?inject ?c = Catch ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*) intro: exec.CatchMiss (*‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t; ¬ isAbr ?t⟧ ⟹ ?Γ⊢ ⟨Catch ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t›*)) (*proven 4 subgoals*) . qed lemma (in lift_state_space) lift_exec': assumes exec_lc: "(lift⇩e Γ)⊢⟨lift⇩c c,s⟩ ⇒ t" shows "Γ⊢⟨c,project⇩x s⟩ ⇒ project⇩x t" using lift_exec[OF exec_lc] (*‹(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (?c::('s::type, 'p::type, 'f::type) com) = lift⇩c (c::('s::type, 'p::type, 'f::type) com) ⟹ (Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢ ⟨?c,(project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate) (s::('S::type, 'f::type) xstate)⟩ ⇒ project⇩x (t::('S::type, 'f::type) xstate)›*) by simp lemma (in lift_state_space) lift_valid: assumes valid: "Γ⊨⇘/F⇙ P c Q,A" shows "(lift⇩e Γ)⊨⇘/F⇙ (lift⇩s P) (lift⇩c c) (lift⇩s Q),(lift⇩s A)" proof (rule validI (*‹(⋀s t. ⟦?Γ⊢ ⟨?c,Normal s⟩ ⇒ t; s ∈ ?P; t ∉ Fault ` ?F⟧ ⟹ t ∈ Normal ` ?Q ∪ Abrupt ` ?A) ⟹ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀s t. ⟦lift⇩e Γ⊢ ⟨lift⇩c c,Normal s⟩ ⇒ t; s ∈ lift⇩s P; t ∉ Fault ` F⟧ ⟹ t ∈ Normal ` lift⇩s Q ∪ Abrupt ` lift⇩s A›*) fix s and t assume lexec: "(lift⇩e Γ)⊢⟨lift⇩c c,Normal s⟩ ⇒ t" (*‹(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c::('s, 'p, 'f) com),Normal (s::'S)⟩ ⇒ (t::('S, 'f) xstate)›*) assume lP: "s ∈ lift⇩s P" (*‹(s::'S) ∈ (lift⇩s::'s set ⇒ 'S set) (P::'s set)›*) assume noFault: "t ∉ Fault ` F" (*‹(t::('S, 'f) xstate) ∉ Fault ` (F::'f set)›*) show "t ∈ Normal ` lift⇩s Q ∪ Abrupt ` lift⇩s A" proof (-) (*goal: ‹(t::('S, 'f) xstate) ∈ Normal ` (lift⇩s::'s set ⇒ 'S set) (Q::'s set) ∪ Abrupt ` lift⇩s (A::'s set)›*) from lexec (*‹lift⇩e Γ⊢ ⟨lift⇩c c,Normal s⟩ ⇒ t›*) have "Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ (project⇩x t)" apply (rule lift_exec (*‹⟦lift⇩e ?Γ⊢ ⟨?lc,?s⟩ ⇒ ?t; lift⇩c ?c = ?lc⟧ ⟹ ?Γ⊢ ⟨?c,project⇩x ?s⟩ ⇒ project⇩x ?t›*)) (*goal: ‹Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) by simp moreover from lP (*‹(s::'S) ∈ (lift⇩s::'s set ⇒ 'S set) (P::'s set)›*) have "project s ∈ P" by (simp add: lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) ultimately have "project⇩x t ∈ Normal ` Q ∪ Abrupt ` A" using valid (*‹Γ⊨⇘/F⇙ P c Q,A›*) noFault (*‹t ∉ Fault ` F›*) apply (clarsimp simp add: valid_def (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ ∀s t. ?Γ⊢ ⟨?c,s⟩ ⇒ t ⟶ s ∈ Normal ` ?P ⟶ t ∉ Fault ` ?F ⟶ t ∈ Normal ` ?Q ∪ Abrupt ` ?A›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) (*goal: ‹project⇩x t ∈ Normal ` Q ∪ Abrupt ` A›*) apply (cases t) (*goals: 1. ‹⋀x1::'S. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),Normal ((project::'S ⇒ 's) (s::'S))⟩ ⇒ xstate_map project (t::('S, 'f) xstate); project s ∈ (P::'s set); ∀(s::('s, 'f) xstate) t::('s, 'f) xstate. Γ⊢ ⟨c,s⟩ ⇒ t ⟶ s ∈ Normal ` P ⟶ t ∉ Fault ` (F::'f set) ⟶ t ∈ Normal ` (Q::'s set) ∨ t ∈ Abrupt ` (A::'s set); t ∉ Fault ` F; xstate_map project t ∉ Abrupt ` A; t = Normal x1⟧ ⟹ xstate_map project t ∈ Normal ` Q› 2. ‹⋀x2::'S. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),Normal ((project::'S ⇒ 's) (s::'S))⟩ ⇒ xstate_map project (t::('S, 'f) xstate); project s ∈ (P::'s set); ∀(s::('s, 'f) xstate) t::('s, 'f) xstate. Γ⊢ ⟨c,s⟩ ⇒ t ⟶ s ∈ Normal ` P ⟶ t ∉ Fault ` (F::'f set) ⟶ t ∈ Normal ` (Q::'s set) ∨ t ∈ Abrupt ` (A::'s set); t ∉ Fault ` F; xstate_map project t ∉ Abrupt ` A; t = Abrupt x2⟧ ⟹ xstate_map project t ∈ Normal ` Q› 3. ‹⋀x3::'f. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),Normal ((project::'S ⇒ 's) (s::'S))⟩ ⇒ xstate_map project (t::('S, 'f) xstate); project s ∈ (P::'s set); ∀(s::('s, 'f) xstate) t::('s, 'f) xstate. Γ⊢ ⟨c,s⟩ ⇒ t ⟶ s ∈ Normal ` P ⟶ t ∉ Fault ` (F::'f set) ⟶ t ∈ Normal ` (Q::'s set) ∨ t ∈ Abrupt ` (A::'s set); t ∉ Fault ` F; xstate_map project t ∉ Abrupt ` A; t = Fault x3⟧ ⟹ xstate_map project t ∈ Normal ` Q› 4. ‹⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(c::('s, 'p, 'f) com),Normal ((project::'S ⇒ 's) (s::'S))⟩ ⇒ xstate_map project (t::('S, 'f) xstate); project s ∈ (P::'s set); ∀(s::('s, 'f) xstate) t::('s, 'f) xstate. Γ⊢ ⟨c,s⟩ ⇒ t ⟶ s ∈ Normal ` P ⟶ t ∉ Fault ` (F::'f set) ⟶ t ∈ Normal ` (Q::'s set) ∨ t ∈ Abrupt ` (A::'s set); t ∉ Fault ` F; xstate_map project t ∉ Abrupt ` A; t = Stuck⟧ ⟹ xstate_map project t ∈ Normal ` Q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . thus "?thesis" (*goal: ‹(t::('S, 'f) xstate) ∈ Normal ` (lift⇩s::'s set ⇒ 'S set) (Q::'s set) ∪ Abrupt ` lift⇩s (A::'s set)›*) apply (simp add: lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*)) (*goal: ‹t ∈ Normal ` lift⇩s Q ∪ Abrupt ` lift⇩s A›*) apply (cases t) (*goals: 1. ‹⋀x1. ⟦project⇩x t ∈ Normal ` Q ∨ project⇩x t ∈ Abrupt ` A; t = Normal x1⟧ ⟹ t ∈ Normal ` {S. project S ∈ Q} ∨ t ∈ Abrupt ` {S. project S ∈ A}› 2. ‹⋀x2. ⟦project⇩x t ∈ Normal ` Q ∨ project⇩x t ∈ Abrupt ` A; t = Abrupt x2⟧ ⟹ t ∈ Normal ` {S. project S ∈ Q} ∨ t ∈ Abrupt ` {S. project S ∈ A}› 3. ‹⋀x3. ⟦project⇩x t ∈ Normal ` Q ∨ project⇩x t ∈ Abrupt ` A; t = Fault x3⟧ ⟹ t ∈ Normal ` {S. project S ∈ Q} ∨ t ∈ Abrupt ` {S. project S ∈ A}› 4. ‹⟦project⇩x t ∈ Normal ` Q ∨ project⇩x t ∈ Abrupt ` A; t = Stuck⟧ ⟹ t ∈ Normal ` {S. project S ∈ Q} ∨ t ∈ Abrupt ` {S. project S ∈ A}› discuss goal 1*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*discuss goal 2*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*discuss goal 3*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*discuss goal 4*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*proven 4 subgoals*) . qed qed lemma (in lift_state_space) lift_hoarep: assumes deriv: "Γ,{}⊢⇘/F⇙ P c Q,A" shows "(lift⇩e Γ),{}⊢⇘/F⇙ (lift⇩s P) (lift⇩c c) (lift⇩s Q),(lift⇩s A)" apply (rule hoare_complete (*‹(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option)⊨⇘/(?F::?'c::type set)⇙ (?P::?'b::type set) (?c::(?'b::type, ?'a::type, ?'c::type) com) (?Q::?'b::type set),(?A::?'b::type set) ⟹ ?Γ,{}⊢⇘/?F ⇙?P ?c ?Q,?A›*)) (*goal: ‹lift⇩e Γ,{}⊢⇘/F ⇙(lift⇩s P) lift⇩c c (lift⇩s Q),(lift⇩s A)›*) apply (insert hoare_sound [OF deriv] (*‹Γ,{}⊨⇘/F⇙ P c Q,A›*)) (*goal: ‹(lift⇩e::('p::type ⇒ ('s::type, 'p::type, 'f::type) com option) ⇒ 'p::type ⇒ ('S::type, 'p::type, 'f::type) com option) (Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊨⇘/(F::'f::type set)⇙ ((lift⇩s::'s::type set ⇒ 'S::type set) (P::'s::type set)) (lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c::('s::type, 'p::type, 'f::type) com) (lift⇩s (Q::'s::type set)),(lift⇩s (A::'s::type set))›*) apply (rule lift_valid (*‹(?Γ::'p ⇒ ('s, 'p, 'f) com option)⊨⇘/(?F::'f set)⇙ (?P::'s set) (?c::('s, 'p, 'f) com) (?Q::'s set),(?A::'s set) ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) ?Γ⊨⇘/?F⇙ ((lift⇩s::'s set ⇒ 'S set) ?P) (lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) ?c (lift⇩s ?Q),(lift⇩s ?A)›*)) (*goal: ‹Γ,{}⊨⇘/F⇙ P c Q,A ⟹ lift⇩e Γ⊨⇘/F⇙ (lift⇩s P) lift⇩c c (lift⇩s Q),(lift⇩s A)›*) by (simp add: cvalid_def (*‹?Γ,?Θ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) lemma (in lift_state_space) lift_hoarep': "∀Z. Γ,{}⊢⇘/F⇙ (P Z) c (Q Z),(A Z) ⟹ ∀Z. (lift⇩e Γ),{}⊢⇘/F⇙ (lift⇩s (P Z)) (lift⇩c c) (lift⇩s (Q Z)),(lift⇩s (A Z))" by (iprover intro: lift_hoarep) lemma (in lift_state_space) lift_termination: assumes termi: "Γ⊢c↓s" shows "⋀S. project⇩x S = s ⟹ lift⇩e Γ ⊢(lift⇩c c)↓S" using termi (*‹Γ⊢c ↓ s›*) proof (induct) (*goals: 1. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Skip ↓ S› 2. ‹⋀f s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (Basic f) ↓ S› 3. ‹⋀r s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (Spec r) ↓ S› 4. ‹⋀s g c f S. ⟦s ∈ g; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 5. ‹⋀s g f c S. ⟦s ∉ g; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 6. ‹⋀c f S. project⇩x S = Fault f ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 7. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 8. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 9. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 10. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 11. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 12. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 13. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 14. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 15. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 16. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 17. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 18. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Skip (*‹(project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate) (S::('S::type, 'f::type) xstate) = Normal (s_::'s::type)›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c Skip ↓ S›*) by (clarsimp simp add: terminates.Skip (*‹?Γ⊢Skip ↓ Normal ?s›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*)) next (*goals: 1. ‹⋀f s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (Basic f) ↓ S› 2. ‹⋀r s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (Spec r) ↓ S› 3. ‹⋀s g c f S. ⟦s ∈ g; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 4. ‹⋀s g f c S. ⟦s ∉ g; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 5. ‹⋀c f S. project⇩x S = Fault f ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 6. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 7. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 8. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 9. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 10. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 11. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 12. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 13. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 14. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 15. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 16. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 17. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Basic (*‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Basic f_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀r s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (Spec r) ↓ S› 2. ‹⋀s g c f S. ⟦s ∈ g; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 3. ‹⋀s g f c S. ⟦s ∉ g; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 4. ‹⋀c f S. project⇩x S = Fault f ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 5. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 6. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 7. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 8. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 9. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 10. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 11. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 12. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 13. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 14. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 15. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 16. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Spec (*‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (Spec (r_::('s × 's) set)) ↓ (S::('S, 'f) xstate)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s g c f S. ⟦s ∈ g; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 2. ‹⋀s g f c S. ⟦s ∉ g; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 3. ‹⋀c f S. project⇩x S = Fault f ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 4. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 5. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 6. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 7. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 8. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 9. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 10. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 11. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 12. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 13. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 14. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 15. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Guard (*‹(s_::'s) ∈ (g_::'s set)› ‹(Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(c_::('s::type, 'p::type, 'f::type) com) ↓ Normal (s_::'s::type)› ‹project⇩x ?S = Normal s_ ⟹ lift⇩e Γ⊢lift⇩c c_ ↓ ?S› ‹(project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate) (S::('S::type, 'f::type) xstate) = Normal (s_::'s::type)›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Guard f_ g_ c_) ↓ S›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s g f c S. ⟦s ∉ g; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Guard f g c) ↓ S› 2. ‹⋀c f S. project⇩x S = Fault f ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 3. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 4. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 5. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 6. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 7. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 8. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 9. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 10. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 11. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 12. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 13. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 14. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case GuardFault (*‹s_ ∉ g_› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Guard f_ g_ c_) ↓ S›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀c f S. project⇩x S = Fault f ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 2. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 3. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 4. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 5. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 6. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 7. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 8. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 9. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 10. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 11. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 12. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 13. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Fault (*‹project⇩x S = Fault f_›*) thus "?case" (*goal: ‹(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c_::('s, 'p, 'f) com) ↓ (S::('S, 'f) xstate)›*) by (clarsimp simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*)) next (*goals: 1. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Seq c₁ c₂) ↓ S› 2. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 3. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 4. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 5. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 6. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 7. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 8. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 9. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 10. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 11. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 12. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case (Seq c1 s c2) (*‹Γ⊢c1 ↓ Normal s› ‹project⇩x ?S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c1 ↓ ?S› ‹∀s'. Γ⊢ ⟨c1,Normal s⟩ ⇒ s' ⟶ Γ⊢c2 ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c2 ↓ x)› ‹project⇩x S = Normal s›*) have "project⇩x S = Normal s" by fact then obtain s' where S: "S=Normal s'" and s: "s = project s'" (*goal: ‹(⋀s'::'S::type. ⟦(S::('S::type, 'f::type) xstate) = Normal s'; (s::'s::type) = (project::'S::type ⇒ 's::type) s'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*)) from Seq (*‹Γ⊢c1 ↓ Normal s› ‹project⇩x ?S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c1 ↓ ?S› ‹∀s'. Γ⊢ ⟨c1,Normal s⟩ ⇒ s' ⟶ Γ⊢c2 ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c c2 ↓ x)› ‹(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (S::('S, 'f) xstate) = Normal (s::'s)›*) have "lift⇩e Γ⊢lift⇩c c1 ↓ S" by simp moreover { fix w assume exec_lc1: "lift⇩e Γ⊢⟨lift⇩c c1,Normal s'⟩ ⇒ w" (*‹(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c1::('s, 'p, 'f) com),Normal (s'::'S)⟩ ⇒ (w::('S, 'f) xstate)›*) have "lift⇩e Γ⊢lift⇩c c2 ↓ w" proof (cases w) (*goals: 1. ‹⋀x1. w = Normal x1 ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w› 2. ‹⋀x2. w = Abrupt x2 ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w› 3. ‹⋀x3. w = Fault x3 ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w› 4. ‹w = Stuck ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w›*) case (Normal w') (*‹w = Normal w'›*) with lift_exec[where c = c1, OF exec_lc1] (*‹(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c1::('s, 'p, 'f) com) = lift⇩c c1 ⟹ (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨c1,(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (Normal (s'::'S))⟩ ⇒ project⇩x (w::('S, 'f) xstate)›*) s (*‹s = project s'›*) have "Γ⊢⟨c1,Normal s⟩ ⇒ Normal (project w')" by (simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) from Seq.hyps(3)[rule_format, OF this] (*‹Γ⊢c2 ↓ Normal (project w') ∧ (∀x. project⇩x x = Normal (project w') ⟶ lift⇩e Γ⊢lift⇩c c2 ↓ x)›*) Normal (*‹w = Normal w'›*) show "lift⇩e Γ⊢lift⇩c c2 ↓ w" by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*)) qed (auto) (*solves the remaining goals: 1. ‹⋀x2. w = Abrupt x2 ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w› 2. ‹⋀x3. w = Fault x3 ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w› 3. ‹w = Stuck ⟹ lift⇩e Γ⊢lift⇩c c2 ↓ w›*) } ultimately show "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Seq c1 c2) ↓ S›*) using S (*‹(S::('S::type, 'f::type) xstate) = Normal (s'::'S::type)›*) s (*‹s = project s'›*) by (auto intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s b c₁ c₂ S. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 2. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 3. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 4. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 5. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 6. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 7. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 8. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 9. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 10. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 11. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case CondTrue (*‹s_ ∈ b_› ‹Γ⊢c₁_ ↓ Normal s_› ‹(project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate) (?S::('S::type, 'f::type) xstate) = Normal (s_::'s::type) ⟹ (lift⇩e::('p::type ⇒ ('s::type, 'p::type, 'f::type) com option) ⇒ 'p::type ⇒ ('S::type, 'p::type, 'f::type) com option) (Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c₁_::('s::type, 'p::type, 'f::type) com) ↓ ?S› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Cond b_ c₁_ c₂_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s b c₂ c₁ S. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₂ ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Cond b c₁ c₂) ↓ S› 2. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 3. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 4. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 5. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 6. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 7. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 8. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 9. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 10. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case CondFalse (*‹s_ ∉ b_› ‹Γ⊢c₂_ ↓ Normal s_› ‹project⇩x ?S = Normal s_ ⟹ lift⇩e Γ⊢lift⇩c c₂_ ↓ ?S› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Cond b_ c₁_ c₂_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s b c S. ⟦s ∈ b; Γ⊢c ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 2. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 3. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 4. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 5. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 6. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 7. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 8. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 9. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case (WhileTrue s b c) (*‹s ∈ b› ‹Γ⊢c ↓ Normal s› ‹(project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate) (?S::('S::type, 'f::type) xstate) = Normal (s::'s::type) ⟹ (lift⇩e::('p::type ⇒ ('s::type, 'p::type, 'f::type) com option) ⇒ 'p::type ⇒ ('S::type, 'p::type, 'f::type) com option) (Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c::('s::type, 'p::type, 'f::type) com) ↓ ?S› ‹∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x)› ‹project⇩x S = Normal s›*) have "project⇩x S = Normal s" by fact then obtain s' where S: "S=Normal s'" and s: "s = project s'" (*goal: ‹(⋀s'. ⟦S = Normal s'; s = project s'⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: project⇩x_def (*‹project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate ≡ xstate_map (project::'S ⇒ 's)›*) xstate_map_convs (*‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Normal (?s::?'a)) = (∃s'::?'c. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Abrupt (?s::?'a)) = (∃s'::?'c. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Fault (?f::?'b)) = (?S = Fault ?f)› ‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Stuck) = (?S = Stuck)›*)) from WhileTrue (*‹s ∈ b› ‹Γ⊢c ↓ Normal s› ‹project⇩x ?S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c ↓ ?S› ‹∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (∀x. project⇩x x = s' ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x)› ‹project⇩x S = Normal s›*) have "lift⇩e Γ⊢lift⇩c c ↓ S" by simp moreover { fix w assume exec_lc: "lift⇩e Γ⊢⟨lift⇩c c,Normal s'⟩ ⇒ w" (*‹(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c::('s, 'p, 'f) com),Normal (s'::'S)⟩ ⇒ (w::('S, 'f) xstate)›*) have "lift⇩e Γ⊢lift⇩c (While b c) ↓ w" proof (cases w) (*goals: 1. ‹⋀x1. w = Normal x1 ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w› 2. ‹⋀x2. w = Abrupt x2 ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w› 3. ‹⋀x3. w = Fault x3 ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w› 4. ‹w = Stuck ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w›*) case (Normal w') (*‹(w::('S, 'f) xstate) = Normal (w'::'S)›*) with lift_exec[where c = c, OF exec_lc] (*‹lift⇩c c = lift⇩c c ⟹ Γ⊢ ⟨c,project⇩x (Normal s')⟩ ⇒ project⇩x w›*) s (*‹(s::'s) = (project::'S ⇒ 's) (s'::'S)›*) have "Γ⊢⟨c,Normal s⟩ ⇒ Normal (project w')" by (simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) from WhileTrue.hyps(4)[rule_format, OF this] (*‹Γ⊢While b c ↓ Normal (project w') ∧ (∀x. project⇩x x = Normal (project w') ⟶ lift⇩e Γ⊢lift⇩c (While b c) ↓ x)›*) Normal (*‹w = Normal w'›*) show "lift⇩e Γ⊢lift⇩c (While b c) ↓ w" by (auto simp add: project⇩x_def (*‹project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate ≡ xstate_map (project::'S ⇒ 's)›*) xstate_map_convs (*‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Normal (?s::?'a)) = (∃s'::?'c. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Abrupt (?s::?'a)) = (∃s'::?'c. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Fault (?f::?'b)) = (?S = Fault ?f)› ‹(xstate_map (?g::?'c ⇒ ?'a) (?S::(?'c, ?'b) xstate) = Stuck) = (?S = Stuck)›*)) qed (auto) (*solves the remaining goals: 1. ‹⋀x2. w = Abrupt x2 ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w› 2. ‹⋀x3. w = Fault x3 ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w› 3. ‹w = Stuck ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ w›*) } ultimately show "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (While b c) ↓ S›*) using S (*‹S = Normal s'›*) s (*‹s = project s'›*) by (auto intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s b c S. ⟦s ∉ b; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (While b c) ↓ S› 2. ‹⋀p bdy s S. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 3. ‹⋀p s S. ⟦Γ p = None; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 4. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 5. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 6. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 7. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 8. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case WhileFalse (*‹s_ ∉ b_› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (While b_ c_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀(p::'p) (bdy::('s, 'p, 'f) com) (s::'s) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option) p = Some bdy; Γ⊢bdy ↓ Normal s; ⋀S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) bdy ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Call p) ↓ S› 2. ‹⋀(p::'p) (s::'s) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s⟧ ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (Call p) ↓ S› 3. ‹⋀(c::('s, 'p, 'f) com) S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Stuck ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c ↓ S› 4. ‹⋀(c::'s ⇒ ('s, 'p, 'f) com) (s::'s) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢c s ↓ Normal s; ⋀S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 5. ‹⋀(s::'s) S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) Throw ↓ S› 6. ‹⋀(c::('s, 'p, 'f) com) (s::'s) S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Abrupt s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c ↓ S› 7. ‹⋀(c₁::('s, 'p, 'f) com) (s::'s) (c₂::('s, 'p, 'f) com) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢c₁ ↓ Normal s; ⋀S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c₁ ↓ S; ∀s'::'s. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x::('S, 'f) xstate. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Call (*‹Γ p_ = Some bdy_› ‹Γ⊢bdy_ ↓ Normal s_› ‹(project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) (?S::('S, 'f) xstate) = Normal (s_::'s) ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (bdy_::('s, 'p, 'f) com) ↓ ?S› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Call p_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) lift⇩e_def (*‹lift⇩e ≡ λΓ p. map_option lift⇩c (Γ p)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀(p::'p) (s::'s) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option) p = None; (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s⟧ ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (Call p) ↓ S› 2. ‹⋀(c::('s, 'p, 'f) com) S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Stuck ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c ↓ S› 3. ‹⋀(c::'s ⇒ ('s, 'p, 'f) com) (s::'s) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢c s ↓ Normal s; ⋀S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 4. ‹⋀(s::'s) S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) Throw ↓ S› 5. ‹⋀(c::('s, 'p, 'f) com) (s::'s) S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Abrupt s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c ↓ S› 6. ‹⋀(c₁::('s, 'p, 'f) com) (s::'s) (c₂::('s, 'p, 'f) com) S::('S, 'f) xstate. ⟦(Γ::'p ⇒ ('s, 'p, 'f) com option)⊢c₁ ↓ Normal s; ⋀S::('S, 'f) xstate. (project⇩x::('S, 'f) xstate ⇒ ('s, 'f) xstate) S = Normal s ⟹ (lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) Γ⊢(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) c₁ ↓ S; ∀s'::'s. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x::('S, 'f) xstate. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case CallUndefined (*‹Γ p_ = None› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Call p_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) lift⇩e_def (*‹lift⇩e ≡ λΓ p. map_option lift⇩c (Γ p)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀c S. project⇩x S = Stuck ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 2. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 3. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 4. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 5. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Stuck (*‹project⇩x S = Stuck›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c c_ ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*)) next (*goals: 1. ‹⋀c s S. ⟦Γ⊢c s ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c (c s) ↓ S; project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (DynCom c) ↓ S› 2. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 3. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 4. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case DynCom (*‹(Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(c_::'s::type ⇒ ('s::type, 'p::type, 'f::type) com) (s_::'s::type) ↓ Normal s_› ‹project⇩x ?S = Normal s_ ⟹ lift⇩e Γ⊢lift⇩c (c_ s_) ↓ ?S› ‹project⇩x S = Normal s_›*) thus "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (DynCom c_) ↓ S›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c Throw ↓ S› 2. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 3. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Throw (*‹(project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate) (S::('S::type, 'f::type) xstate) = Normal (s_::'s::type)›*) thus "?case" (*goal: ‹(lift⇩e::('p::type ⇒ ('s::type, 'p::type, 'f::type) com option) ⇒ 'p::type ⇒ ('S::type, 'p::type, 'f::type) com option) (Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) Throw ↓ (S::('S::type, 'f::type) xstate)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀c s S. project⇩x S = Abrupt s ⟹ lift⇩e Γ⊢lift⇩c c ↓ S› 2. ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case Abrupt (*‹project⇩x S = Abrupt s_›*) thus "?case" (*goal: ‹(lift⇩e::('p::type ⇒ ('s::type, 'p::type, 'f::type) com option) ⇒ 'p::type ⇒ ('S::type, 'p::type, 'f::type) com option) (Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) (c_::('s::type, 'p::type, 'f::type) com) ↓ (S::('S::type, 'f::type) xstate)›*) by (fastforce simp add: project⇩x_def (*‹project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate ≡ xstate_map (project::'S::type ⇒ 's::type)›*) xstate_map_convs (*‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Normal (?s::?'a::type)) = (∃s'::?'c::type. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Abrupt (?s::?'a::type)) = (∃s'::?'c::type. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Fault (?f::?'b::type)) = (?S = Fault ?f)› ‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Stuck) = (?S = Stuck)›*) intro: terminates.intros (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Skip ↓ Normal (?s::?'s::type)› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Basic (?f::?'s::type ⇒ ?'s::type) ↓ Normal (?s::?'s::type)› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Spec (?r::(?'s::type × ?'s::type) set) ↓ Normal (?s::?'s::type)› ‹⟦(?s::?'s::type) ∈ (?g::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard (?f::?'f::type) ?g ?c ↓ Normal ?s› ‹(?s::?'s::type) ∉ (?g::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Guard (?f::?'f::type) ?g (?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Fault (?f::?'f::type)› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₁::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal (?s::?'s::type); ∀s'::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢(?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₁::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ (?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹⟦(?s::?'s::type) ∉ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b (?c₁::(?'s::type, ?'p::type, ?'f::type) com) ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s; ∀s'::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹(?s::?'s::type) ∉ (?b::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢While ?b (?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option) (?p::?'p::type) = Some (?bdy::(?'s::type, ?'p::type, ?'f::type) com); ?Γ⊢?bdy ↓ Normal (?s::?'s::type)⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goal: ‹⋀c₁ s c₂ S. ⟦Γ⊢c₁ ↓ Normal s; ⋀S. project⇩x S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c₁ ↓ S; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c₂ ↓ x); project⇩x S = Normal s⟧ ⟹ lift⇩e Γ⊢lift⇩c (Catch c₁ c₂) ↓ S›*) case (Catch c1 s c2) (*‹(Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(c1::('s::type, 'p::type, 'f::type) com) ↓ Normal (s::'s::type)› ‹project⇩x ?S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c1 ↓ ?S› ‹∀s'. Γ⊢ ⟨c1,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c2 ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c2 ↓ x)› ‹project⇩x S = Normal s›*) have "project⇩x S = Normal s" by fact then obtain s' where S: "S=Normal s'" and s: "s = project s'" (*goal: ‹(⋀s'. ⟦S = Normal s'; s = project s'⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) xstate_map_convs (*‹(xstate_map ?g ?S = Normal ?s) = (∃s'. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Abrupt ?s) = (∃s'. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map ?g ?S = Fault ?f) = (?S = Fault ?f)› ‹(xstate_map ?g ?S = Stuck) = (?S = Stuck)›*)) from Catch (*‹(Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option)⊢(c1::('s::type, 'p::type, 'f::type) com) ↓ Normal (s::'s::type)› ‹project⇩x ?S = Normal s ⟹ lift⇩e Γ⊢lift⇩c c1 ↓ ?S› ‹∀s'. Γ⊢ ⟨c1,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c2 ↓ Normal s' ∧ (∀x. project⇩x x = Normal s' ⟶ lift⇩e Γ⊢lift⇩c c2 ↓ x)› ‹project⇩x S = Normal s›*) have "lift⇩e Γ⊢lift⇩c c1 ↓ S" by simp moreover { fix w assume exec_lc1: "lift⇩e Γ⊢⟨lift⇩c c1,Normal s'⟩ ⇒ Abrupt w" (*‹(lift⇩e::('p ⇒ ('s, 'p, 'f) com option) ⇒ 'p ⇒ ('S, 'p, 'f) com option) (Γ::'p ⇒ ('s, 'p, 'f) com option)⊢ ⟨(lift⇩c::('s, 'p, 'f) com ⇒ ('S, 'p, 'f) com) (c1::('s, 'p, 'f) com),Normal (s'::'S)⟩ ⇒ Abrupt (w::'S)›*) have "lift⇩e Γ⊢lift⇩c c2 ↓ Normal w" proof (-) (*goal: ‹lift⇩e Γ⊢lift⇩c c2 ↓ Normal w›*) from lift_exec[where c = c1, OF exec_lc1] (*‹lift⇩c c1 = lift⇩c c1 ⟹ Γ⊢ ⟨c1,project⇩x (Normal s')⟩ ⇒ project⇩x (Abrupt w)›*) s (*‹s = project s'›*) have "Γ⊢⟨c1,Normal s⟩ ⇒ Abrupt (project w)" by (simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) from Catch.hyps(3)[rule_format, OF this] (*‹Γ⊢c2 ↓ Normal (project w) ∧ (∀x. project⇩x x = Normal (project w) ⟶ lift⇩e Γ⊢lift⇩c c2 ↓ x)›*) show "lift⇩e Γ⊢lift⇩c c2 ↓ Normal w" by (auto simp add: project⇩x_def (*‹project⇩x::('S::type, 'f::type) xstate ⇒ ('s::type, 'f::type) xstate ≡ xstate_map (project::'S::type ⇒ 's::type)›*) xstate_map_convs (*‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Normal (?s::?'a::type)) = (∃s'::?'c::type. ?S = Normal s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Abrupt (?s::?'a::type)) = (∃s'::?'c::type. ?S = Abrupt s' ∧ ?s = ?g s')› ‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Fault (?f::?'b::type)) = (?S = Fault ?f)› ‹(xstate_map (?g::?'c::type ⇒ ?'a::type) (?S::(?'c::type, ?'b::type) xstate) = Stuck) = (?S = Stuck)›*)) qed } ultimately show "?case" (*goal: ‹lift⇩e Γ⊢lift⇩c (Catch c1 c2) ↓ S›*) using S (*‹S = Normal s'›*) s (*‹s = project s'›*) by (auto intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) qed lemma (in lift_state_space) lift_termination': assumes termi: "Γ⊢c↓project⇩x S" shows "lift⇩e Γ ⊢(lift⇩c c)↓S" using lift_termination[OF termi] (*‹project⇩x ?S = project⇩x S ⟹ lift⇩e Γ⊢lift⇩c c ↓ ?S›*) by iprover lemma (in lift_state_space) lift_validt: assumes valid: "Γ⊨⇩t⇘/F⇙ P c Q,A" shows "(lift⇩e Γ)⊨⇩t⇘/F⇙ (lift⇩s P) (lift⇩c c) (lift⇩s Q),(lift⇩s A)" proof (-) (*goal: ‹lift⇩e Γ⊨⇩t⇘/F⇙ (lift⇩s P) lift⇩c c (lift⇩s Q),(lift⇩s A)›*) from valid (*‹Γ⊨⇩t⇘/F⇙ P c Q,A›*) have "(lift⇩e Γ)⊨⇘/F⇙ (lift⇩s P) (lift⇩c c) (lift⇩s Q),(lift⇩s A)" by (auto intro: lift_valid (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ⟹ lift⇩e ?Γ⊨⇘/?F⇙ (lift⇩s ?P) lift⇩c ?c (lift⇩s ?Q),(lift⇩s ?A)›*) simp add: validt_def (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s∈Normal ` ?P. ?Γ⊢?c ↓ s)›*)) moreover { fix S assume "S ∈ lift⇩s P" (*‹(S::'S) ∈ (lift⇩s::'s set ⇒ 'S set) (P::'s set)›*) hence "project S ∈ P" by (simp add: lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*)) with valid (*‹Γ⊨⇩t⇘/F⇙ P c Q,A›*) have "Γ⊢c ↓ project⇩x (Normal S)" by (simp add: validt_def (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s∈Normal ` ?P. ?Γ⊢?c ↓ s)›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) hence "lift⇩e Γ⊢lift⇩c c ↓ Normal S" by (rule lift_termination' (*‹?Γ⊢?c ↓ project⇩x ?S ⟹ lift⇩e ?Γ⊢lift⇩c ?c ↓ ?S›*)) } ultimately show "?thesis" (*goal: ‹lift⇩e Γ⊨⇩t⇘/F⇙ (lift⇩s P) lift⇩c c (lift⇩s Q),(lift⇩s A)›*) by (simp add: validt_def (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s∈Normal ` ?P. ?Γ⊢?c ↓ s)›*)) qed lemma (in lift_state_space) lift_hoaret: assumes deriv: "Γ,{}⊢⇩t⇘/F⇙ P c Q,A" shows "(lift⇩e Γ),{}⊢⇩t⇘/F⇙ (lift⇩s P) (lift⇩c c) (lift⇩s Q),(lift⇩s A)" apply (rule hoaret_complete (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ⟹ ?Γ,{}⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹lift⇩e Γ,{}⊢⇩t⇘/F⇙ (lift⇩s P) lift⇩c c (lift⇩s Q),(lift⇩s A)›*) apply (insert hoaret_sound [OF deriv] (*‹Γ,{}⊨⇩t⇘/F⇙ P c Q,A›*)) (*goal: ‹lift⇩e Γ⊨⇩t⇘/F⇙ (lift⇩s P) lift⇩c c (lift⇩s Q),(lift⇩s A)›*) apply (rule lift_validt (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ⟹ lift⇩e ?Γ⊨⇩t⇘/?F⇙ (lift⇩s ?P) lift⇩c ?c (lift⇩s ?Q),(lift⇩s ?A)›*)) (*goal: ‹(Γ::'p::type ⇒ ('s::type, 'p::type, 'f::type) com option),{}⊨⇩t⇘/(F::'f::type set)⇙ (P::'s::type set) (c::('s::type, 'p::type, 'f::type) com) (Q::'s::type set),(A::'s::type set) ⟹ (lift⇩e::('p::type ⇒ ('s::type, 'p::type, 'f::type) com option) ⇒ 'p::type ⇒ ('S::type, 'p::type, 'f::type) com option) Γ⊨⇩t⇘/F⇙ ((lift⇩s::'s::type set ⇒ 'S::type set) P) (lift⇩c::('s::type, 'p::type, 'f::type) com ⇒ ('S::type, 'p::type, 'f::type) com) c (lift⇩s Q),(lift⇩s A)›*) by (simp add: cvalidt_def (*‹?Γ,?Θ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇩t⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) locale lift_state_space_ext = lift_state_space + assumes inj_proj_commute: "⋀S. inject S (project S) = S" assumes inject_last: "⋀S s t. inject (inject S s) t = inject S t" (* ∃x. state t = inject (state s) x *) lemma (in lift_state_space_ext) lift_exec_inject_same: assumes exec_lc: "(lift⇩e Γ)⊢⟨lc,s⟩ ⇒ t" shows "⋀c. ⟦lift⇩c c = lc; t ∉ (Fault ` UNIV) ∪ {Stuck}⟧ ⟹ state t = inject (state s) (project (state t))" using exec_lc (*‹(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(lc::('a, 'd, 'c) com),(s::('a, 'c) xstate)⟩ ⇒ (t::('a, 'c) xstate)›*) proof (induct) (*goals: 1. ‹⋀s c. ⟦lift⇩c c = Skip; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 2. ‹⋀s g c t f ca. ⟦s ∈ g; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = Guard f g c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀s g f c ca. ⟦s ∉ g; lift⇩c ca = Guard f g c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Normal s)) (project (state (Fault f)))› 4. ‹⋀c f ca. ⟦lift⇩c ca = c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Fault f)) (project (state (Fault f)))› 5. ‹⋀f s c. ⟦lift⇩c c = Basic f; Normal (f s) ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal (f s)) = inject (state (Normal s)) (project (state (Normal (f s))))› 6. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r; Normal t ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal t) = inject (state (Normal s)) (project (state (Normal t)))› 7. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 8. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 10. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 11. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 12. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 13. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 14. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 15. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 16. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 17. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 18. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 19. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 20. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Skip (*‹lift⇩c c = Skip› ‹Normal (s_::'a::type) ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Normal s_) = inject (state (Normal s_)) (project (state (Normal s_)))›*) by (clarsimp simp add: inj_proj_commute (*‹(inject::'a::type ⇒ 'b::type ⇒ 'a::type) (?S::'a::type) ((project::'a::type ⇒ 'b::type) ?S) = ?S›*)) next (*goals: 1. ‹⋀s g c t f ca. ⟦s ∈ g; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = Guard f g c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀s g f c ca. ⟦s ∉ g; lift⇩c ca = Guard f g c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Normal s)) (project (state (Fault f)))› 3. ‹⋀c f ca. ⟦lift⇩c ca = c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Fault f)) (project (state (Fault f)))› 4. ‹⋀f s c. ⟦lift⇩c c = Basic f; Normal (f s) ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal (f s)) = inject (state (Normal s)) (project (state (Normal (f s))))› 5. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r; Normal t ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal t) = inject (state (Normal s)) (project (state (Normal t)))› 6. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 7. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 10. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 11. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 12. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 13. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 14. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 15. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 16. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 17. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 18. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 19. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Guard (*‹s_ ∈ g_› ‹lift⇩e Γ⊢ ⟨c_,Normal s_⟩ ⇒ t_› ‹⟦lift⇩c ?c = c_; t_ ∉ range Fault ∪ {Stuck}⟧ ⟹ state t_ = inject (state (Normal s_)) (project (state t_))› ‹lift⇩c c = Guard f_ g_ c_› ‹t_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state t_ = inject (state (Normal s_)) (project (state t_))›*) by (clarsimp simp add: lift⇩c_Guard (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = Guard (?f::?'c) (?lg::?'a set) (?lc'::(?'a, ?'b, ?'c) com)) = (∃(g::?'d set) c'::(?'d, ?'b, ?'c) com. ?c = Guard ?f g c' ∧ ?lg = lift⇩s ?prj g ∧ ?lc' = lift⇩c ?prj ?inject c')›*) lift⇩c_def (*‹lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com ≡ lift⇩c (project::'a ⇒ 'b) (inject::'a ⇒ 'b ⇒ 'a)›*)) next (*goals: 1. ‹⋀s g f c ca. ⟦s ∉ g; lift⇩c ca = Guard f g c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Normal s)) (project (state (Fault f)))› 2. ‹⋀c f ca. ⟦lift⇩c ca = c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Fault f)) (project (state (Fault f)))› 3. ‹⋀f s c. ⟦lift⇩c c = Basic f; Normal (f s) ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal (f s)) = inject (state (Normal s)) (project (state (Normal (f s))))› 4. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r; Normal t ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal t) = inject (state (Normal s)) (project (state (Normal t)))› 5. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 6. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 10. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 11. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 12. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 13. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 14. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 15. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 16. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 17. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 18. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case GuardFault (*‹(s_::'a) ∉ (g_::'a set)› ‹lift⇩c c = Guard f_ g_ c_› ‹Fault f_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Fault (f_::'c::type)) = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s_::'a::type))) ((project::'a::type ⇒ 'b::type) (state (Fault f_)))›*) by simp next (*goals: 1. ‹⋀c f ca. ⟦lift⇩c ca = c; Fault f ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Fault f) = inject (state (Fault f)) (project (state (Fault f)))› 2. ‹⋀f s c. ⟦lift⇩c c = Basic f; Normal (f s) ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal (f s)) = inject (state (Normal s)) (project (state (Normal (f s))))› 3. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r; Normal t ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal t) = inject (state (Normal s)) (project (state (Normal t)))› 4. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 5. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 10. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 11. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 12. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 13. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 14. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 15. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 16. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 17. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case FaultProp (*‹lift⇩c c = c_› ‹Fault (f_::'c) ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Fault f_) = inject (state (Fault f_)) (project (state (Fault f_)))›*) by simp next (*goals: 1. ‹⋀f s c. ⟦lift⇩c c = Basic f; Normal (f s) ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal (f s)) = inject (state (Normal s)) (project (state (Normal (f s))))› 2. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r; Normal t ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal t) = inject (state (Normal s)) (project (state (Normal t)))› 3. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 4. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 9. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 10. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 11. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 12. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 13. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 14. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 15. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 16. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Basic (*‹lift⇩c c = Basic f_› ‹Normal (f_ s_) ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Normal (f_ s_)) = inject (state (Normal s_)) (project (state (Normal (f_ s_))))›*) by (clarsimp simp add: lift⇩f_def (*‹lift⇩f::('b ⇒ 'b) ⇒ 'a ⇒ 'a ≡ lift⇩f (project::'a ⇒ 'b) (inject::'a ⇒ 'b ⇒ 'a)›*) Compose.lift⇩f_def (*‹lift⇩f (?prj::?'S ⇒ ?'s) (?inject::?'S ⇒ ?'s ⇒ ?'S) (?f::?'s ⇒ ?'s) = (λS::?'S. ?inject S (?f (?prj S)))›*) proj_inj_commute (*‹(project::'a ⇒ 'b) ((inject::'a ⇒ 'b ⇒ 'a) (?S::'a) (?s::'b)) = ?s›*) lift⇩c_Basic (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = Basic (?lf::?'a ⇒ ?'a)) = (∃f::?'d ⇒ ?'d. ?c = Basic f ∧ ?lf = lift⇩f ?prj ?inject f)›*) lift⇩c_def (*‹lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com ≡ lift⇩c (project::'a ⇒ 'b) (inject::'a ⇒ 'b ⇒ 'a)›*)) next (*goals: 1. ‹⋀s t r c. ⟦(s, t) ∈ r; lift⇩c c = Spec r; Normal t ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal t) = inject (state (Normal s)) (project (state (Normal t)))› 2. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 3. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 8. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 10. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 11. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 12. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 13. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 14. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 15. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (Spec r) (*‹(r, t_) ∈ r_› ‹lift⇩c c = Spec r_› ‹Normal (t_::'a) ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Normal t_) = inject (state (Normal r)) (project (state (Normal t_)))›*) by (clarsimp simp add: Compose.lift⇩r_def (*‹lift⇩r (?prj::?'S ⇒ ?'s) (?inject::?'S ⇒ ?'s ⇒ ?'S) (?R::(?'s × ?'s) set) = {(S::?'S, T::?'S). (?prj S, ?prj T) ∈ ?R ∧ T = ?inject S (?prj T)}›*) lift⇩c_Spec (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = Spec (?lr::(?'a × ?'a) set)) = (∃r::(?'d × ?'d) set. ?c = Spec r ∧ ?lr = lift⇩r ?prj ?inject r)›*) lift⇩c_def (*‹lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com ≡ lift⇩c (project::'a ⇒ 'b) (inject::'a ⇒ 'b ⇒ 'a)›*)) next (*goals: 1. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; lift⇩c c = Spec r; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 2. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 7. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 9. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 10. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 11. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 12. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 13. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 14. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case SpecStuck (*‹∀t::'a::type. (s_::'a::type, t) ∉ (r_::('a::type × 'a::type) set)› ‹(lift⇩c::('b::type, 'd::type, 'c::type) com ⇒ ('a::type, 'd::type, 'c::type) com) (c::('b::type, 'd::type, 'c::type) com) = Spec (r_::('a::type × 'a::type) set)› ‹Stuck ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state Stuck = inject (state (Normal s_)) (project (state Stuck))›*) by simp next (*goals: 1. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. ⟦lift⇩c c = c₁; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c c = Seq c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 6. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 8. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 9. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 10. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 11. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 12. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 13. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (Seq lc1 s s' lc2 t c) (*‹lift⇩e Γ⊢ ⟨lc1,Normal s⟩ ⇒ s'› ‹⟦lift⇩c ?c = lc1; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s'))› ‹lift⇩e Γ⊢ ⟨lc2,s'⟩ ⇒ t› ‹⟦lift⇩c ?c = lc2; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t))› ‹lift⇩c c = Seq lc1 lc2› ‹t ∉ range Fault ∪ {Stuck}›*) have t: "t ∉ Fault ` UNIV ∪ {Stuck}" by fact have "lift⇩c c = Seq lc1 lc2" by fact then obtain c1 and c2 where c: "c = Seq c1 c2" and lc1: "lc1 = lift⇩c c1" and lc2: "lc2 = lift⇩c c2" (*goal: ‹(⋀c1 c2. ⟦c = Seq c1 c2; lc1 = lift⇩c c1; lc2 = lift⇩c c2⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: lift⇩c_Seq (*‹(lift⇩c ?prj ?inject ?c = Seq ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Seq c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) show "?case" (*goal: ‹state (t::('a, 'c) xstate) = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal (s::'a))) ((project::'a ⇒ 'b) (state t))›*) proof (cases s') (*goals: 1. ‹⋀x1. s' = Normal x1 ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀x2. s' = Abrupt x2 ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀x3. s' = Fault x3 ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹s' = Stuck ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (Normal s'') (*‹s' = Normal s''›*) from Seq.hyps(2)[OF lc1 [ symmetric ]] (*‹s' ∉ range Fault ∪ {Stuck} ⟹ state s' = inject (state (Normal s)) (project (state s'))›*) this (*‹s' = Normal s''›*) have "s'' = inject s (project s'')" by auto moreover from Seq.hyps(4)[OF lc2 [ symmetric ]] (*‹t ∉ range Fault ∪ {Stuck} ⟹ state t = inject (state s') (project (state t))›*) Normal (*‹(s'::('a::type, 'c::type) xstate) = Normal (s''::'a::type)›*) t (*‹t ∉ range Fault ∪ {Stuck}›*) have "state t = inject s'' (project (state t))" by auto ultimately have "state t = inject (inject s (project s'')) (project (state t))" by simp then show "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by (simp add: inject_last (*‹inject (inject ?S ?s) ?t = inject ?S ?t›*)) next (*goals: 1. ‹⋀x2. s' = Abrupt x2 ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀x3. s' = Fault x3 ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹s' = Stuck ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (Abrupt s'') (*‹s' = Abrupt s''›*) from Seq.hyps(2)[OF lc1 [ symmetric ]] (*‹s' ∉ range Fault ∪ {Stuck} ⟹ state s' = inject (state (Normal s)) (project (state s'))›*) this (*‹s' = Abrupt s''›*) have "s'' = inject s (project s'')" by auto moreover from Seq.hyps(4)[OF lc2 [ symmetric ]] (*‹t ∉ range Fault ∪ {Stuck} ⟹ state t = inject (state s') (project (state t))›*) Abrupt (*‹s' = Abrupt s''›*) t (*‹t ∉ range Fault ∪ {Stuck}›*) have "state t = inject s'' (project (state t))" by auto ultimately have "state t = inject (inject s (project s'')) (project (state t))" by simp then show "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by (simp add: inject_last (*‹inject (inject ?S ?s) ?t = inject ?S ?t›*)) next (*goals: 1. ‹⋀x3::'c::type. (s'::('a::type, 'c::type) xstate) = Fault x3 ⟹ state (t::('a::type, 'c::type) xstate) = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s::'a::type))) ((project::'a::type ⇒ 'b::type) (state t))› 2. ‹(s'::('a::type, 'c::type) xstate) = Stuck ⟹ state (t::('a::type, 'c::type) xstate) = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s::'a::type))) ((project::'a::type ⇒ 'b::type) (state t))›*) case (Fault f) (*‹s' = Fault f›*) with Seq (*‹lift⇩e Γ⊢ ⟨lc1,Normal s⟩ ⇒ s'› ‹⟦lift⇩c ?c = lc1; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s'))› ‹lift⇩e Γ⊢ ⟨lc2,s'⟩ ⇒ t› ‹⟦lift⇩c ?c = lc2; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t))› ‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) = Seq (lc1::('a, 'd, 'c) com) (lc2::('a, 'd, 'c) com)› ‹t ∉ range Fault ∪ {Stuck}›*) have "t = Fault f" by (auto dest: Fault_end (*‹⟦?Γ⊢ ⟨?c,?s⟩ ⇒ ?t; ?s = Fault ?f⟧ ⟹ ?t = Fault ?f›*)) with t (*‹(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}›*) have False by simp thus "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by standard next (*goal: ‹s' = Stuck ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Stuck (*‹s' = Stuck›*) with Seq (*‹lift⇩e Γ⊢ ⟨lc1,Normal s⟩ ⇒ s'› ‹⟦(lift⇩c::('b::type, 'd::type, 'c::type) com ⇒ ('a::type, 'd::type, 'c::type) com) (?c::('b::type, 'd::type, 'c::type) com) = (lc1::('a::type, 'd::type, 'c::type) com); (s'::('a::type, 'c::type) xstate) ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s::'a::type))) ((project::'a::type ⇒ 'b::type) (state s'))› ‹lift⇩e Γ⊢ ⟨lc2,s'⟩ ⇒ t› ‹⟦lift⇩c ?c = lc2; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t))› ‹lift⇩c c = Seq lc1 lc2› ‹(t::('a::type, 'c::type) xstate) ∉ range Fault ∪ {Stuck}›*) have "t = Stuck" by (auto dest: Stuck_end (*‹⟦?Γ⊢ ⟨?c,?s⟩ ⇒ ?t; ?s = Stuck⟧ ⟹ ?t = Stuck›*)) with t (*‹(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}›*) have False by simp thus "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by standard qed next (*goals: 1. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 5. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 7. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 8. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 10. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 11. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 12. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case CondTrue (*‹s_ ∈ b_› ‹lift⇩e Γ⊢ ⟨c₁_,Normal s_⟩ ⇒ t_› ‹⟦lift⇩c ?c = c₁_; t_ ∉ range Fault ∪ {Stuck}⟧ ⟹ state t_ = inject (state (Normal s_)) (project (state t_))› ‹lift⇩c c = Cond b_ c₁_ c₂_› ‹t_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state t_ = inject (state (Normal s_)) (project (state t_))›*) by (clarsimp simp add: lift⇩c_Cond (*‹(lift⇩c ?prj ?inject ?c = Cond ?lb ?lc₁ ?lc₂) = (∃b c₁ c₂. ?c = Cond b c₁ c₂ ∧ ?lb = lift⇩s ?prj b ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) next (*goals: 1. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; lift⇩e Γ⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Cond b c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 4. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 6. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 7. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 9. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 10. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 11. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case CondFalse (*‹s_ ∉ b_› ‹(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(c₂_::('a, 'd, 'c) com),Normal (s_::'a)⟩ ⇒ (t_::('a, 'c) xstate)› ‹⟦lift⇩c ?c = c₂_; t_ ∉ range Fault ∪ {Stuck}⟧ ⟹ state t_ = inject (state (Normal s_)) (project (state t_))› ‹lift⇩c c = Cond b_ c₁_ c₂_› ‹t_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state t_ = inject (state (Normal s_)) (project (state t_))›*) by (clarsimp simp add: lift⇩c_Cond (*‹(lift⇩c ?prj ?inject ?c = Cond ?lb ?lc₁ ?lc₂) = (∃b c₁ c₂. ?c = Cond b c₁ c₂ ∧ ?lb = lift⇩s ?prj b ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) next (*goals: 1. ‹⋀s b c s' t ca. ⟦s ∈ b; lift⇩e Γ⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. ⟦lift⇩c ca = c; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s')); lift⇩e Γ⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t)); lift⇩c ca = While b c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀s b c ca. ⟦s ∉ b; lift⇩c ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = inject (state (Normal s)) (project (state (Normal s)))› 3. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 5. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 6. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 8. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 9. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 10. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (WhileTrue s lb lc' s' t c) (*‹s ∈ lb› ‹lift⇩e Γ⊢ ⟨lc',Normal s⟩ ⇒ s'› ‹⟦lift⇩c ?c = lc'; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s'))› ‹lift⇩e Γ⊢ ⟨While lb lc',s'⟩ ⇒ t› ‹⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (?c::('b, 'd, 'c) com) = While (lb::'a set) (lc'::('a, 'd, 'c) com); (t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = (inject::'a ⇒ 'b ⇒ 'a) (state (s'::('a, 'c) xstate)) ((project::'a ⇒ 'b) (state t))› ‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) = While (lb::'a set) (lc'::('a, 'd, 'c) com)› ‹(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}›*) have t: "t ∉ Fault ` UNIV ∪ {Stuck}" by fact have lw: "lift⇩c c = While lb lc'" by fact then obtain b and c' where c: "c = While b c'" and lb: "lb = lift⇩s b" and lc: "lc' = lift⇩c c'" (*goal: ‹(⋀(b::'b set) c'::('b, 'd, 'c) com. ⟦(c::('b, 'd, 'c) com) = While b c'; (lb::'a set) = (lift⇩s::'b set ⇒ 'a set) b; (lc'::('a, 'd, 'c) com) = (lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: lift⇩c_While (*‹(lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (?c::(?'d, ?'b, ?'c) com) = While (?lb::?'a set) (?lc'::(?'a, ?'b, ?'c) com)) = (∃(b::?'d set) c'::(?'d, ?'b, ?'c) com. ?c = While b c' ∧ ?lb = lift⇩s ?prj b ∧ ?lc' = lift⇩c ?prj ?inject c')›*) lift⇩s_def (*‹lift⇩s::'b set ⇒ 'a set ≡ lift⇩s (project::'a ⇒ 'b)›*) lift⇩c_def (*‹lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com ≡ lift⇩c (project::'a ⇒ 'b) (inject::'a ⇒ 'b ⇒ 'a)›*)) show "?case" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) proof (cases s') (*goals: 1. ‹⋀x1. s' = Normal x1 ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀x2. s' = Abrupt x2 ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀x3. s' = Fault x3 ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹s' = Stuck ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (Normal s'') (*‹s' = Normal s''›*) from WhileTrue.hyps(3)[OF lc [ symmetric ]] (*‹s' ∉ range Fault ∪ {Stuck} ⟹ state s' = inject (state (Normal s)) (project (state s'))›*) this (*‹(s'::('a::type, 'c::type) xstate) = Normal (s''::'a::type)›*) have "s'' = inject s (project s'')" by auto moreover from WhileTrue.hyps(5)[OF lw] (*‹(t::('a::type, 'c::type) xstate) ∉ range Fault ∪ {Stuck} ⟹ state t = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (s'::('a::type, 'c::type) xstate)) ((project::'a::type ⇒ 'b::type) (state t))›*) Normal (*‹s' = Normal s''›*) t (*‹t ∉ range Fault ∪ {Stuck}›*) have "state t = inject s'' (project (state t))" by auto ultimately have "state t = inject (inject s (project s'')) (project (state t))" by simp then show "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by (simp add: inject_last (*‹inject (inject ?S ?s) ?t = inject ?S ?t›*)) next (*goals: 1. ‹⋀x2::'a::type. (s'::('a::type, 'c::type) xstate) = Abrupt x2 ⟹ state (t::('a::type, 'c::type) xstate) = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s::'a::type))) ((project::'a::type ⇒ 'b::type) (state t))› 2. ‹⋀x3::'c::type. (s'::('a::type, 'c::type) xstate) = Fault x3 ⟹ state (t::('a::type, 'c::type) xstate) = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s::'a::type))) ((project::'a::type ⇒ 'b::type) (state t))› 3. ‹(s'::('a::type, 'c::type) xstate) = Stuck ⟹ state (t::('a::type, 'c::type) xstate) = (inject::'a::type ⇒ 'b::type ⇒ 'a::type) (state (Normal (s::'a::type))) ((project::'a::type ⇒ 'b::type) (state t))›*) case (Abrupt s'') (*‹s' = Abrupt s''›*) from WhileTrue.hyps(3)[OF lc [ symmetric ]] (*‹(s'::('a, 'c) xstate) ∉ range Fault ∪ {Stuck} ⟹ state s' = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal (s::'a))) ((project::'a ⇒ 'b) (state s'))›*) this (*‹s' = Abrupt s''›*) have "s'' = inject s (project s'')" by auto moreover from WhileTrue.hyps(5)[OF lw] (*‹t ∉ range Fault ∪ {Stuck} ⟹ state t = inject (state s') (project (state t))›*) Abrupt (*‹s' = Abrupt s''›*) t (*‹t ∉ range Fault ∪ {Stuck}›*) have "state t = inject s'' (project (state t))" by auto ultimately have "state t = inject (inject s (project s'')) (project (state t))" by simp then show "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by (simp add: inject_last (*‹inject (inject ?S ?s) ?t = inject ?S ?t›*)) next (*goals: 1. ‹⋀x3. s' = Fault x3 ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹s' = Stuck ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (Fault f) (*‹(s'::('a, 'c) xstate) = Fault (f::'c)›*) with WhileTrue (*‹s ∈ lb› ‹lift⇩e Γ⊢ ⟨lc',Normal s⟩ ⇒ s'› ‹⟦lift⇩c ?c = lc'; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s'))› ‹lift⇩e Γ⊢ ⟨While lb lc',s'⟩ ⇒ t› ‹⟦lift⇩c ?c = While lb lc'; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t))› ‹lift⇩c c = While lb lc'› ‹t ∉ range Fault ∪ {Stuck}›*) have "t = Fault f" by (auto dest: Fault_end (*‹⟦?Γ⊢ ⟨?c,?s⟩ ⇒ ?t; ?s = Fault ?f⟧ ⟹ ?t = Fault ?f›*)) with t (*‹t ∉ range Fault ∪ {Stuck}›*) have False by simp thus "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by standard next (*goal: ‹s' = Stuck ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Stuck (*‹s' = Stuck›*) with WhileTrue (*‹s ∈ lb› ‹lift⇩e Γ⊢ ⟨lc',Normal s⟩ ⇒ s'› ‹⟦lift⇩c ?c = lc'; s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state s' = inject (state (Normal s)) (project (state s'))› ‹lift⇩e Γ⊢ ⟨While lb lc',s'⟩ ⇒ t› ‹⟦lift⇩c ?c = While lb lc'; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state s') (project (state t))› ‹lift⇩c c = While lb lc'› ‹t ∉ range Fault ∪ {Stuck}›*) have "t = Stuck" by (auto dest: Stuck_end (*‹⟦?Γ⊢ ⟨?c,?s⟩ ⇒ ?t; ?s = Stuck⟧ ⟹ ?t = Stuck›*)) with t (*‹t ∉ range Fault ∪ {Stuck}›*) have False by simp thus "?thesis" (*goal: ‹state t = inject (state (Normal s)) (project (state t))›*) by standard qed next (*goals: 1. ‹⋀(s::'a) (b::'a set) (c::('a, 'd, 'c) com) ca::('b, 'd, 'c) com. ⟦s ∉ b; (lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) ca = While b c; Normal s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Normal s) = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state (Normal s)))› 2. ‹⋀(p::'d) (bdy::('a, 'd, 'c) com) (s::'a) (t::('a, 'c) xstate) c::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option) p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀(p::'d) (s::'a) c::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option) p = None; (lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state Stuck))› 4. ‹⋀(c::('a, 'd, 'c) com) ca::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = (inject::'a ⇒ 'b ⇒ 'a) (state Stuck) ((project::'a ⇒ 'b) (state Stuck))› 5. ‹⋀(c::'a ⇒ ('a, 'd, 'c) com) (s::'a) (t::('a, 'c) xstate) ca::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀(s::'a) c::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state (Abrupt s)))› 7. ‹⋀(c::('a, 'd, 'c) com) (s::'a) ca::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = (inject::'a ⇒ 'b ⇒ 'a) (state (Abrupt s)) ((project::'a ⇒ 'b) (state (Abrupt s)))› 8. ‹⋀(c₁::('a, 'd, 'c) com) (s::'a) (s'::'a) (c₂::('a, 'd, 'c) com) (t::('a, 'c) xstate) c::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('b, 'd, 'c) com. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 9. ‹⋀(c₁::('a, 'd, 'c) com) (s::'a) (t::('a, 'c) xstate) (c₂::('a, 'd, 'c) com) c::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case WhileFalse (*‹s_ ∉ b_› ‹(lift⇩c::('b::type, 'd::type, 'c::type) com ⇒ ('a::type, 'd::type, 'c::type) com) (c::('b::type, 'd::type, 'c::type) com) = While (b_::'a::type set) (c_::('a::type, 'd::type, 'c::type) com)› ‹Normal s_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Normal s_) = inject (state (Normal s_)) (project (state (Normal s_)))›*) by (clarsimp simp add: lift⇩c_While (*‹(lift⇩c ?prj ?inject ?c = While ?lb ?lc') = (∃b c'. ?c = While b c' ∧ ?lb = lift⇩s ?prj b ∧ ?lc' = lift⇩c ?prj ?inject c')›*) inj_proj_commute (*‹inject ?S (project ?S) = ?S›*)) next (*goals: 1. ‹⋀p bdy s t c. ⟦lift⇩e Γ p = Some bdy; lift⇩e Γ⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = bdy; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c c = Call p; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 3. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 4. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 6. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 7. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 8. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Call (*‹lift⇩e Γ p_ = Some bdy_› ‹lift⇩e Γ⊢ ⟨bdy_,Normal s_⟩ ⇒ t_› ‹⟦lift⇩c ?c = bdy_; t_ ∉ range Fault ∪ {Stuck}⟧ ⟹ state t_ = inject (state (Normal s_)) (project (state t_))› ‹lift⇩c c = Call p_› ‹(t_::('a::type, 'c::type) xstate) ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state t_ = inject (state (Normal s_)) (project (state t_))›*) by (clarsimp simp add: inject_last (*‹inject (inject ?S ?s) ?t = inject ?S ?t›*) lift⇩c_Call (*‹(lift⇩c ?prj ?inject ?c = Call ?p) = (?c = Call ?p)›*) lift⇩e_def (*‹lift⇩e ≡ λΓ p. map_option lift⇩c (Γ p)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) next (*goals: 1. ‹⋀p s c. ⟦lift⇩e Γ p = None; lift⇩c c = Call p; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state (Normal s)) (project (state Stuck))› 2. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 3. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 5. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 6. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 7. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case CallUndefined (*‹lift⇩e Γ p_ = None› ‹lift⇩c c = Call p_› ‹Stuck ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state Stuck = inject (state (Normal s_)) (project (state Stuck))›*) by simp next (*goals: 1. ‹⋀c ca. ⟦lift⇩c ca = c; Stuck ∉ range Fault ∪ {Stuck}⟧ ⟹ state Stuck = inject (state Stuck) (project (state Stuck))› 2. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 4. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 5. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 6. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case StuckProp (*‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) = (c_::('a, 'd, 'c) com)› ‹Stuck ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state Stuck = inject (state Stuck) (project (state Stuck))›*) by simp next (*goals: 1. ‹⋀c s t ca. ⟦lift⇩e Γ⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. ⟦lift⇩c ca = c s; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); lift⇩c ca = DynCom c; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 3. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 4. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 5. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case DynCom (*‹lift⇩e Γ⊢ ⟨c_ s_,Normal s_⟩ ⇒ t_› ‹⟦lift⇩c ?c = c_ s_; t_ ∉ range Fault ∪ {Stuck}⟧ ⟹ state t_ = inject (state (Normal s_)) (project (state t_))› ‹lift⇩c c = DynCom c_› ‹t_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state t_ = inject (state (Normal s_)) (project (state t_))›*) by (clarsimp simp add: lift⇩c_DynCom (*‹(lift⇩c ?prj ?inject ?c = DynCom ?lc) = (∃C. ?c = DynCom C ∧ ?lc = (λs. lift⇩c ?prj ?inject (C (?prj s))))›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) next (*goals: 1. ‹⋀s c. ⟦lift⇩c c = Throw; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Normal s)) (project (state (Abrupt s)))› 2. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 3. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 4. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case Throw (*‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) = Throw› ‹Abrupt (s_::'a) ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Abrupt s_) = inject (state (Normal s_)) (project (state (Abrupt s_)))›*) by (simp add: inj_proj_commute (*‹inject ?S (project ?S) = ?S›*)) next (*goals: 1. ‹⋀c s ca. ⟦lift⇩c ca = c; Abrupt s ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s) = inject (state (Abrupt s)) (project (state (Abrupt s)))› 2. ‹⋀c₁ s s' c₂ t c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. ⟦lift⇩c c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 3. ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case AbruptProp (*‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) = (c_::('a, 'd, 'c) com)› ‹Abrupt s_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state (Abrupt s_) = inject (state (Abrupt s_)) (project (state (Abrupt s_)))›*) by (simp add: inj_proj_commute (*‹inject ?S (project ?S) = ?S›*)) next (*goals: 1. ‹⋀(c₁::('a, 'd, 'c) com) (s::'a) (s'::'a) (c₂::('a, 'd, 'c) com) (t::('a, 'c) xstate) c::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = c₁; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state (Abrupt s'))); lift⇩e Γ⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('b, 'd, 'c) com. ⟦lift⇩c c = c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t)); lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))› 2. ‹⋀(c₁::('a, 'd, 'c) com) (s::'a) (t::('a, 'c) xstate) (c₂::('a, 'd, 'c) com) c::('b, 'd, 'c) com. ⟦(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('b, 'd, 'c) com. ⟦(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal s)) ((project::'a ⇒ 'b) (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case (CatchMatch lc1 s s' lc2 t c) (*‹lift⇩e Γ⊢ ⟨lc1,Normal s⟩ ⇒ Abrupt s'› ‹⟦lift⇩c ?c = lc1; Abrupt s' ∉ range Fault ∪ {Stuck}⟧ ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s')))› ‹lift⇩e Γ⊢ ⟨lc2,Normal s'⟩ ⇒ t› ‹⟦lift⇩c ?c = lc2; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s')) (project (state t))› ‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) = Catch (lc1::('a, 'd, 'c) com) (lc2::('a, 'd, 'c) com)› ‹t ∉ range Fault ∪ {Stuck}›*) have t: "t ∉ Fault ` UNIV ∪ {Stuck}" by fact have "lift⇩c c = Catch lc1 lc2" by fact then obtain c1 and c2 where c: "c = Catch c1 c2" and lc1: "lc1 = lift⇩c c1" and lc2: "lc2 = lift⇩c c2" (*goal: ‹(⋀c1 c2. ⟦c = Catch c1 c2; lc1 = lift⇩c c1; lc2 = lift⇩c c2⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: lift⇩c_Catch (*‹(lift⇩c ?prj ?inject ?c = Catch ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) from CatchMatch.hyps(2)[OF lc1 [ symmetric ]] (*‹Abrupt s' ∉ range Fault ∪ {Stuck} ⟹ state (Abrupt s') = inject (state (Normal s)) (project (state (Abrupt s')))›*) this (*‹(c::('b::type, 'd::type, 'c::type) com) = Catch (c1::('b::type, 'd::type, 'c::type) com) (c2::('b::type, 'd::type, 'c::type) com)› ‹lc1 = lift⇩c c1› ‹lc2 = lift⇩c c2›*) have "s' = inject s (project s')" by auto moreover from CatchMatch.hyps(4)[OF lc2 [ symmetric ]] (*‹(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck} ⟹ state t = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal (s'::'a))) ((project::'a ⇒ 'b) (state t))›*) t (*‹t ∉ range Fault ∪ {Stuck}›*) have "state t = inject s' (project (state t))" by auto ultimately have "state t = inject (inject s (project s')) (project (state t))" by simp then show "?case" (*goal: ‹state (t::('a, 'c) xstate) = (inject::'a ⇒ 'b ⇒ 'a) (state (Normal (s::'a))) ((project::'a ⇒ 'b) (state t))›*) by (simp add: inject_last (*‹inject (inject ?S ?s) ?t = inject ?S ?t›*)) next (*goal: ‹⋀c₁ s t c₂ c. ⟦lift⇩e Γ⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. ⟦lift⇩c c = c₁; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t)); ¬ isAbr t; lift⇩c c = Catch c₁ c₂; t ∉ range Fault ∪ {Stuck}⟧ ⟹ state t = inject (state (Normal s)) (project (state t))›*) case CatchMiss (*‹lift⇩e Γ⊢ ⟨c₁_,Normal s_⟩ ⇒ t_› ‹⟦lift⇩c ?c = c₁_; t_ ∉ range Fault ∪ {Stuck}⟧ ⟹ state t_ = inject (state (Normal s_)) (project (state t_))› ‹¬ isAbr t_› ‹lift⇩c c = Catch c₁_ c₂_› ‹t_ ∉ range Fault ∪ {Stuck}›*) thus "?case" (*goal: ‹state t_ = inject (state (Normal s_)) (project (state t_))›*) by (clarsimp simp add: lift⇩c_Catch (*‹(lift⇩c ?prj ?inject ?c = Catch ?lc₁ ?lc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?lc₁ = lift⇩c ?prj ?inject c₁ ∧ ?lc₂ = lift⇩c ?prj ?inject c₂)›*) lift⇩c_def (*‹lift⇩c ≡ lift⇩c project inject›*)) qed lemma (in lift_state_space_ext) valid_inject_project: assumes noFaultStuck: "Γ⊢⟨c,Normal (project σ)⟩ ⇒∉(Fault ` UNIV ∪ {Stuck})" shows "lift⇩e Γ⊨⇘/F⇙ {σ} lift⇩c c {t. t=inject σ (project t)}, {t. t=inject σ (project t)}" proof (rule validI (*‹(⋀s t. ⟦?Γ⊢ ⟨?c,Normal s⟩ ⇒ t; s ∈ ?P; t ∉ Fault ` ?F⟧ ⟹ t ∈ Normal ` ?Q ∪ Abrupt ` ?A) ⟹ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀s t. ⟦lift⇩e Γ⊢ ⟨lift⇩c c,Normal s⟩ ⇒ t; s ∈ {σ}; t ∉ Fault ` F⟧ ⟹ t ∈ Normal ` {t. t = inject σ (project t)} ∪ Abrupt ` {t. t = inject σ (project t)}›*) fix s and t assume exec: "lift⇩e Γ⊢⟨lift⇩c c,Normal s⟩ ⇒ t" (*‹(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com),Normal (s::'a)⟩ ⇒ (t::('a, 'c) xstate)›*) assume P: "s ∈ {σ}" (*‹(s::'a) ∈ {σ::'a}›*) assume noFault: "t ∉ Fault ` F" (*‹(t::('a, 'c) xstate) ∉ Fault ` (F::'c set)›*) show "t ∈ Normal ` {t. t = inject σ (project t)} ∪ Abrupt ` {t. t = inject σ (project t)}" proof (-) (*goal: ‹t ∈ Normal ` {t. t = inject σ (project t)} ∪ Abrupt ` {t. t = inject σ (project t)}›*) from lift_exec[OF exec] (*‹lift⇩c ?c = lift⇩c c ⟹ Γ⊢ ⟨?c,project⇩x (Normal s)⟩ ⇒ project⇩x t›*) have "Γ⊢⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t" by simp with noFaultStuck (*‹Γ⊢ ⟨c,Normal (project σ)⟩ ⇒∉range Fault ∪ {Stuck}›*) P (*‹s ∈ {σ}›*) have t: "t ∉ Fault ` UNIV ∪ {Stuck}" by (auto simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) from lift_exec_inject_same[OF exec refl this] (*‹state t = inject (state (Normal s)) (project (state t))›*) P (*‹s ∈ {σ}›*) have "state t = inject σ (project (state t))" by simp with t (*‹t ∉ range Fault ∪ {Stuck}›*) show "?thesis" (*goal: ‹(t::('a, 'c) xstate) ∈ Normal ` {t::'a. t = (inject::'a ⇒ 'b ⇒ 'a) (σ::'a) ((project::'a ⇒ 'b) t)} ∪ Abrupt ` {t::'a. t = inject σ (project t)}›*) apply (cases t) (*goals: 1. ‹⋀x1::'a. ⟦(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}; state t = (inject::'a ⇒ 'b ⇒ 'a) (σ::'a) ((project::'a ⇒ 'b) (state t)); t = Normal x1⟧ ⟹ t ∈ Normal ` {t::'a. t = inject σ (project t)} ∪ Abrupt ` {t::'a. t = inject σ (project t)}› 2. ‹⋀x2::'a. ⟦(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}; state t = (inject::'a ⇒ 'b ⇒ 'a) (σ::'a) ((project::'a ⇒ 'b) (state t)); t = Abrupt x2⟧ ⟹ t ∈ Normal ` {t::'a. t = inject σ (project t)} ∪ Abrupt ` {t::'a. t = inject σ (project t)}› 3. ‹⋀x3::'c. ⟦(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}; state t = (inject::'a ⇒ 'b ⇒ 'a) (σ::'a) ((project::'a ⇒ 'b) (state t)); t = Fault x3⟧ ⟹ t ∈ Normal ` {t::'a. t = inject σ (project t)} ∪ Abrupt ` {t::'a. t = inject σ (project t)}› 4. ‹⟦(t::('a, 'c) xstate) ∉ range Fault ∪ {Stuck}; state t = (inject::'a ⇒ 'b ⇒ 'a) (σ::'a) ((project::'a ⇒ 'b) (state t)); t = Stuck⟧ ⟹ t ∈ Normal ` {t::'a. t = inject σ (project t)} ∪ Abrupt ` {t::'a. t = inject σ (project t)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed qed lemma (in lift_state_space_ext) lift_exec_inject_same': assumes exec_lc: "(lift⇩e Γ)⊢⟨lift⇩c c,S⟩ ⇒ T" shows "⋀c. ⟦T ∉ (Fault ` UNIV) ∪ {Stuck}⟧ ⟹ state T = inject (state S) (project (state T))" using lift_exec_inject_same[OF exec_lc] (*‹⟦lift⇩c ?c = lift⇩c c; T ∉ range Fault ∪ {Stuck}⟧ ⟹ state T = inject (state S) (project (state T))›*) by simp lemma (in lift_state_space_ext) valid_lift_modifies: assumes valid: "∀s. Γ⊨⇘/F⇙ {s} c (Modif s),(ModifAbr s)" shows "(lift⇩e Γ)⊨⇘/F⇙ {S} (lift⇩c c) {T. T ∈ lift⇩s (Modif (project S)) ∧ T=inject S (project T)}, {T. T ∈ lift⇩s (ModifAbr (project S)) ∧ T=inject S (project T)}" proof (rule validI (*‹(⋀s t. ⟦?Γ⊢ ⟨?c,Normal s⟩ ⇒ t; s ∈ ?P; t ∉ Fault ` ?F⟧ ⟹ t ∈ Normal ` ?Q ∪ Abrupt ` ?A) ⟹ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀s t. ⟦lift⇩e Γ⊢ ⟨lift⇩c c,Normal s⟩ ⇒ t; s ∈ {S}; t ∉ Fault ` F⟧ ⟹ t ∈ Normal ` {T ∈ lift⇩s (Modif (project S)). T = inject S (project T)} ∪ Abrupt ` {T ∈ lift⇩s (ModifAbr (project S)). T = inject S (project T)}›*) fix s and t assume exec: "lift⇩e Γ⊢⟨lift⇩c c,Normal s⟩ ⇒ t" (*‹(lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com),Normal (s::'a)⟩ ⇒ (t::('a, 'c) xstate)›*) assume P: "s ∈ {S}" (*‹(s::'a) ∈ {S::'a}›*) assume noFault: "t ∉ Fault ` F" (*‹(t::('a, 'c) xstate) ∉ Fault ` (F::'c set)›*) show "t ∈ Normal ` {t ∈ lift⇩s (Modif (project S)). t = inject S (project t)} ∪ Abrupt ` {t ∈ lift⇩s (ModifAbr (project S)). t = inject S (project t)}" proof (-) (*goal: ‹t ∈ Normal ` {t ∈ lift⇩s (Modif (project S)). t = inject S (project t)} ∪ Abrupt ` {t ∈ lift⇩s (ModifAbr (project S)). t = inject S (project t)}›*) from lift_exec[OF exec] (*‹(lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (?c::('b, 'd, 'c) com) = lift⇩c (c::('b, 'd, 'c) com) ⟹ (Γ::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨?c,(project⇩x::('a, 'c) xstate ⇒ ('b, 'c) xstate) (Normal (s::'a))⟩ ⇒ project⇩x (t::('a, 'c) xstate)›*) have "Γ⊢ ⟨c,project⇩x (Normal s)⟩ ⇒ project⇩x t" by auto moreover from noFault (*‹t ∉ Fault ` F›*) have "project⇩x t ∉ Fault ` F" apply (cases "t") (*goals: 1. ‹⋀x1. ⟦t ∉ Fault ` F; t = Normal x1⟧ ⟹ project⇩x t ∉ Fault ` F› 2. ‹⋀x2. ⟦t ∉ Fault ` F; t = Abrupt x2⟧ ⟹ project⇩x t ∉ Fault ` F› 3. ‹⋀x3. ⟦t ∉ Fault ` F; t = Fault x3⟧ ⟹ project⇩x t ∉ Fault ` F› 4. ‹⟦t ∉ Fault ` F; t = Stuck⟧ ⟹ project⇩x t ∉ Fault ` F› discuss goal 1*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*discuss goal 2*) apply ((auto simp add: project⇩x_def (*‹project⇩x::('a, 'c) xstate ⇒ ('b, 'c) xstate ≡ xstate_map (project::'a ⇒ 'b)›*))[1]) (*discuss goal 3*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*discuss goal 4*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*))[1]) (*proven 4 subgoals*) . ultimately have "project⇩x t ∈ Normal ` (Modif (project s)) ∪ Abrupt ` (ModifAbr (project s))" using valid[rule_format, of "(project s)"] (*‹Γ⊨⇘/F⇙ {project s} c (Modif (project s)),(ModifAbr (project s))›*) by (auto simp add: valid_def (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ ∀s t. ?Γ⊢ ⟨?c,s⟩ ⇒ t ⟶ s ∈ Normal ` ?P ⟶ t ∉ Fault ` ?F ⟶ t ∈ Normal ` ?Q ∪ Abrupt ` ?A›*) project⇩x_def (*‹project⇩x ≡ xstate_map project›*)) hence t: "t ∈ Normal ` lift⇩s (Modif (project s)) ∪ Abrupt ` lift⇩s (ModifAbr (project s))" apply (cases t) (*goals: 1. ‹⋀x1::'a::type. ⟦(project⇩x::('a::type, 'c::type) xstate ⇒ ('b::type, 'c::type) xstate) (t::('a::type, 'c::type) xstate) ∈ Normal ` (Modif::'b::type ⇒ 'b::type set) ((project::'a::type ⇒ 'b::type) (s::'a::type)) ∪ Abrupt ` (ModifAbr::'b::type ⇒ 'b::type set) (project s); t = Normal x1⟧ ⟹ t ∈ Normal ` (lift⇩s::'b::type set ⇒ 'a::type set) (Modif (project s)) ∪ Abrupt ` lift⇩s (ModifAbr (project s))› 2. ‹⋀x2::'a::type. ⟦(project⇩x::('a::type, 'c::type) xstate ⇒ ('b::type, 'c::type) xstate) (t::('a::type, 'c::type) xstate) ∈ Normal ` (Modif::'b::type ⇒ 'b::type set) ((project::'a::type ⇒ 'b::type) (s::'a::type)) ∪ Abrupt ` (ModifAbr::'b::type ⇒ 'b::type set) (project s); t = Abrupt x2⟧ ⟹ t ∈ Normal ` (lift⇩s::'b::type set ⇒ 'a::type set) (Modif (project s)) ∪ Abrupt ` lift⇩s (ModifAbr (project s))› 3. ‹⋀x3::'c::type. ⟦(project⇩x::('a::type, 'c::type) xstate ⇒ ('b::type, 'c::type) xstate) (t::('a::type, 'c::type) xstate) ∈ Normal ` (Modif::'b::type ⇒ 'b::type set) ((project::'a::type ⇒ 'b::type) (s::'a::type)) ∪ Abrupt ` (ModifAbr::'b::type ⇒ 'b::type set) (project s); t = Fault x3⟧ ⟹ t ∈ Normal ` (lift⇩s::'b::type set ⇒ 'a::type set) (Modif (project s)) ∪ Abrupt ` lift⇩s (ModifAbr (project s))› 4. ‹⟦(project⇩x::('a::type, 'c::type) xstate ⇒ ('b::type, 'c::type) xstate) (t::('a::type, 'c::type) xstate) ∈ Normal ` (Modif::'b::type ⇒ 'b::type set) ((project::'a::type ⇒ 'b::type) (s::'a::type)) ∪ Abrupt ` (ModifAbr::'b::type ⇒ 'b::type set) (project s); t = Stuck⟧ ⟹ t ∈ Normal ` (lift⇩s::'b::type set ⇒ 'a::type set) (Modif (project s)) ∪ Abrupt ` lift⇩s (ModifAbr (project s))› discuss goal 1*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*))[1]) (*discuss goal 2*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*))[1]) (*discuss goal 3*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*))[1]) (*discuss goal 4*) apply ((auto simp add: project⇩x_def (*‹project⇩x ≡ xstate_map project›*) lift⇩s_def (*‹lift⇩s ≡ lift⇩s project›*) Compose.lift⇩s_def (*‹lift⇩s ?prj ?A = {S. ?prj S ∈ ?A}›*))[1]) (*proven 4 subgoals*) . then have "t ∉ Fault ` UNIV ∪ {Stuck}" apply (cases t) (*goals: 1. ‹⋀x1::'a. ⟦(t::('a, 'c) xstate) ∈ Normal ` (lift⇩s::'b set ⇒ 'a set) ((Modif::'b ⇒ 'b set) ((project::'a ⇒ 'b) (s::'a))) ∪ Abrupt ` lift⇩s ((ModifAbr::'b ⇒ 'b set) (project s)); t = Normal x1⟧ ⟹ t ∉ range Fault ∪ {Stuck}› 2. ‹⋀x2::'a. ⟦(t::('a, 'c) xstate) ∈ Normal ` (lift⇩s::'b set ⇒ 'a set) ((Modif::'b ⇒ 'b set) ((project::'a ⇒ 'b) (s::'a))) ∪ Abrupt ` lift⇩s ((ModifAbr::'b ⇒ 'b set) (project s)); t = Abrupt x2⟧ ⟹ t ∉ range Fault ∪ {Stuck}› 3. ‹⋀x3::'c. ⟦(t::('a, 'c) xstate) ∈ Normal ` (lift⇩s::'b set ⇒ 'a set) ((Modif::'b ⇒ 'b set) ((project::'a ⇒ 'b) (s::'a))) ∪ Abrupt ` lift⇩s ((ModifAbr::'b ⇒ 'b set) (project s)); t = Fault x3⟧ ⟹ t ∉ range Fault ∪ {Stuck}› 4. ‹⟦(t::('a, 'c) xstate) ∈ Normal ` (lift⇩s::'b set ⇒ 'a set) ((Modif::'b ⇒ 'b set) ((project::'a ⇒ 'b) (s::'a))) ∪ Abrupt ` lift⇩s ((ModifAbr::'b ⇒ 'b set) (project s)); t = Stuck⟧ ⟹ t ∉ range Fault ∪ {Stuck}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . from lift_exec_inject_same[OF exec _ this] (*‹lift⇩c ?c = lift⇩c c ⟹ state t = inject (state (Normal s)) (project (state t))›*) have "state t = inject (state (Normal s)) (project (state t))" by simp with t (*‹t ∈ Normal ` lift⇩s (Modif (project s)) ∪ Abrupt ` lift⇩s (ModifAbr (project s))›*) show "?thesis" (*goal: ‹t ∈ Normal ` {t ∈ lift⇩s (Modif (project S)). t = inject S (project t)} ∪ Abrupt ` {t ∈ lift⇩s (ModifAbr (project S)). t = inject S (project t)}›*) using P (*‹(s::'a::type) ∈ {S::'a::type}›*) by auto qed qed lemma (in lift_state_space_ext) hoare_lift_modifies: assumes deriv: "∀σ. Γ,{}⊢⇘/F⇙ {σ} c (Modif σ),(ModifAbr σ)" shows "∀σ. (lift⇩e Γ),{}⊢⇘/F⇙ {σ} (lift⇩c c) {T. T ∈ lift⇩s (Modif (project σ)) ∧ T=inject σ (project T)}, {T. T ∈ lift⇩s (ModifAbr (project σ)) ∧ T=inject σ (project T)}" apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀σ. lift⇩e Γ,{}⊢⇘/F ⇙{σ} lift⇩c c {T ∈ lift⇩s (Modif (project σ)). T = inject σ (project T)},{T ∈ lift⇩s (ModifAbr (project σ)). T = inject σ (project T)}›*) apply (rule hoare_complete (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ⟹ ?Γ,{}⊢⇘/?F ⇙?P ?c ?Q,?A›*)) (*goal: ‹⋀σ. lift⇩e Γ,{}⊢⇘/F ⇙{σ} lift⇩c c {T ∈ lift⇩s (Modif (project σ)). T = inject σ (project T)},{T ∈ lift⇩s (ModifAbr (project σ)). T = inject σ (project T)}›*) apply (rule valid_lift_modifies (*‹∀s. ?Γ⊨⇘/?F⇙ {s} ?c (?Modif s),(?ModifAbr s) ⟹ lift⇩e ?Γ⊨⇘/?F⇙ {?S} lift⇩c ?c {T ∈ lift⇩s (?Modif (project ?S)). T = inject ?S (project T)},{T ∈ lift⇩s (?ModifAbr (project ?S)). T = inject ?S (project T)}›*)) (*goal: ‹⋀σ::'a. (lift⇩e::('d ⇒ ('b, 'd, 'c) com option) ⇒ 'd ⇒ ('a, 'd, 'c) com option) (Γ::'d ⇒ ('b, 'd, 'c) com option)⊨⇘/(F::'c set)⇙ {σ} (lift⇩c::('b, 'd, 'c) com ⇒ ('a, 'd, 'c) com) (c::('b, 'd, 'c) com) {T::'a ∈ (lift⇩s::'b set ⇒ 'a set) ((Modif::'b ⇒ 'b set) ((project::'a ⇒ 'b) σ)). T = (inject::'a ⇒ 'b ⇒ 'a) σ (project T)},{T::'a ∈ lift⇩s ((ModifAbr::'b ⇒ 'b set) (project σ)). T = inject σ (project T)}›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀σ. ∀s. Γ⊨⇘/F⇙ {s} c (Modif s),(ModifAbr s)›*) apply (insert hoare_sound [OF deriv [rule_format]] (*‹Γ,{}⊨⇘/F⇙ {?σ1} c (Modif ?σ1),(ModifAbr ?σ1)›*)) (*goal: ‹⋀σ s. Γ⊨⇘/F⇙ {s} c (Modif s),(ModifAbr s)›*) by (simp add: cvalid_def (*‹?Γ,?Θ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) lemma (in lift_state_space_ext) hoare_lift_modifies': assumes deriv: "∀σ. Γ,{}⊢⇘/F⇙ {σ} c (Modif σ),(ModifAbr σ)" shows "∀σ. (lift⇩e Γ),{}⊢⇘/F⇙ {σ} (lift⇩c c) {T. T ∈ lift⇩s (Modif (project σ)) ∧ (∃T'. T=inject σ T')}, {T. T ∈ lift⇩s (ModifAbr (project σ)) ∧ (∃T'. T=inject σ T')}" apply (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*)) (*goal: ‹∀σ. lift⇩e Γ,{}⊢⇘/F ⇙{σ} lift⇩c c {T ∈ lift⇩s (Modif (project σ)). ∃T'. T = inject σ T'},{T ∈ lift⇩s (ModifAbr (project σ)). ∃T'. T = inject σ T'}›*) apply (rule HoarePartialDef.conseq [OF hoare_lift_modifies [OF deriv]] (*‹∀s. s ∈ ?P ⟶ (∃Z. s ∈ {Z} ∧ {T ∈ lift⇩s (Modif (project Z)). T = inject Z (project T)} ⊆ ?Q ∧ {T ∈ lift⇩s (ModifAbr (project Z)). T = inject Z (project T)} ⊆ ?A) ⟹ lift⇩e Γ,{}⊢⇘/F ⇙?P lift⇩c c ?Q,?A›*)) (*goal: ‹⋀σ. lift⇩e Γ,{}⊢⇘/F ⇙{σ} lift⇩c c {T ∈ lift⇩s (Modif (project σ)). ∃T'. T = inject σ T'},{T ∈ lift⇩s (ModifAbr (project σ)). ∃T'. T = inject σ T'}›*) by blast subsection ‹Renaming Procedures› primrec rename:: "('p ⇒ 'q) ⇒ ('s,'p,'f) com ⇒ ('s,'q,'f) com" where "rename N Skip = Skip" | "rename N (Basic f) = Basic f" | "rename N (Spec r) = Spec r" | "rename N (Seq c₁ c₂) = (Seq (rename N c₁) (rename N c₂))" | "rename N (Cond b c₁ c₂) = Cond b (rename N c₁) (rename N c₂)" | "rename N (While b c) = While b (rename N c)" | "rename N (Call p) = Call (N p)" | "rename N (DynCom c) = DynCom (λs. rename N (c s))" | "rename N (Guard f g c) = Guard f g (rename N c)" | "rename N Throw = Throw" | "rename N (Catch c₁ c₂) = Catch (rename N c₁) (rename N c₂)" lemma rename_Skip: "rename h c = Skip = (c=Skip)" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (rename h c = Skip) = (c = Skip)› 2. ‹⋀x2. c = Basic x2 ⟹ (rename h c = Skip) = (c = Skip)› 3. ‹⋀x3. c = Spec x3 ⟹ (rename h c = Skip) = (c = Skip)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (rename h c = Skip) = (c = Skip)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (rename h c = Skip) = (c = Skip)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (rename h c = Skip) = (c = Skip)› 7. ‹⋀x7. c = Call x7 ⟹ (rename h c = Skip) = (c = Skip)› 8. ‹⋀x8. c = DynCom x8 ⟹ (rename h c = Skip) = (c = Skip)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (rename h c = Skip) = (c = Skip)› 10. ‹c = Throw ⟹ (rename h c = Skip) = (c = Skip)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (rename h c = Skip) = (c = Skip)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Basic: "(rename h c = Basic f) = (c=Basic f)" apply (cases c) (*goals: 1. ‹(c::('a, 'd, 'c) com) = Skip ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 2. ‹⋀x2::'a ⇒ 'a. (c::('a, 'd, 'c) com) = Basic x2 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 3. ‹⋀x3::('a × 'a) set. (c::('a, 'd, 'c) com) = Spec x3 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 4. ‹⋀(x41::('a, 'd, 'c) com) x42::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Seq x41 x42 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 5. ‹⋀(x51::'a set) (x52::('a, 'd, 'c) com) x53::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Cond x51 x52 x53 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 6. ‹⋀(x61::'a set) x62::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = While x61 x62 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 7. ‹⋀x7::'d. (c::('a, 'd, 'c) com) = Call x7 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 8. ‹⋀x8::'a ⇒ ('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = DynCom x8 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 9. ‹⋀(x91::'c) (x92::'a set) x93::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Guard x91 x92 x93 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 10. ‹(c::('a, 'd, 'c) com) = Throw ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› 11. ‹⋀(x111::('a, 'd, 'c) com) x112::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Catch x111 x112 ⟹ (rename (h::'d ⇒ 'b) c = Basic (f::'a ⇒ 'a)) = (c = Basic f)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Spec: "(rename h c = Spec r) = (c=Spec r)" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (rename h c = Spec r) = (c = Spec r)› 2. ‹⋀x2. c = Basic x2 ⟹ (rename h c = Spec r) = (c = Spec r)› 3. ‹⋀x3. c = Spec x3 ⟹ (rename h c = Spec r) = (c = Spec r)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (rename h c = Spec r) = (c = Spec r)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (rename h c = Spec r) = (c = Spec r)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (rename h c = Spec r) = (c = Spec r)› 7. ‹⋀x7. c = Call x7 ⟹ (rename h c = Spec r) = (c = Spec r)› 8. ‹⋀x8. c = DynCom x8 ⟹ (rename h c = Spec r) = (c = Spec r)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (rename h c = Spec r) = (c = Spec r)› 10. ‹c = Throw ⟹ (rename h c = Spec r) = (c = Spec r)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (rename h c = Spec r) = (c = Spec r)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Seq: "(rename h c = Seq rc₁ rc₂) = (∃ c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂ )" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 2. ‹⋀x2. c = Basic x2 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 3. ‹⋀x3. c = Spec x3 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 7. ‹⋀x7. c = Call x7 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 8. ‹⋀x8. c = DynCom x8 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 10. ‹c = Throw ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (rename h c = Seq rc₁ rc₂) = (∃c₁ c₂. c = Seq c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Cond: "(rename h c = Cond b rc₁ rc₂) = (∃c₁ c₂. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂ )" apply (cases c) (*goals: 1. ‹(c::('a, 'd, 'c) com) = Skip ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 2. ‹⋀x2::'a ⇒ 'a. (c::('a, 'd, 'c) com) = Basic x2 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 3. ‹⋀x3::('a × 'a) set. (c::('a, 'd, 'c) com) = Spec x3 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 4. ‹⋀(x41::('a, 'd, 'c) com) x42::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Seq x41 x42 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 5. ‹⋀(x51::'a set) (x52::('a, 'd, 'c) com) x53::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Cond x51 x52 x53 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 6. ‹⋀(x61::'a set) x62::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = While x61 x62 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 7. ‹⋀x7::'d. (c::('a, 'd, 'c) com) = Call x7 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 8. ‹⋀x8::'a ⇒ ('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = DynCom x8 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 9. ‹⋀(x91::'c) (x92::'a set) x93::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Guard x91 x92 x93 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 10. ‹(c::('a, 'd, 'c) com) = Throw ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 11. ‹⋀(x111::('a, 'd, 'c) com) x112::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Catch x111 x112 ⟹ (rename (h::'d ⇒ 'b) c = Cond (b::'a set) (rc₁::('a, 'b, 'c) com) (rc₂::('a, 'b, 'c) com)) = (∃(c₁::('a, 'd, 'c) com) c₂::('a, 'd, 'c) com. c = Cond b c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_While: "(rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 2. ‹⋀x2. c = Basic x2 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 3. ‹⋀x3. c = Spec x3 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 7. ‹⋀x7. c = Call x7 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 8. ‹⋀x8. c = DynCom x8 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 10. ‹c = Throw ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (rename h c = While b rc') = (∃c'. c = While b c' ∧ rc' = rename h c')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Call: "(rename h c = Call q) = (∃p. c = Call p ∧ q=h p)" apply (cases c) (*goals: 1. ‹(c::('a, 'd, 'c) com) = Skip ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 2. ‹⋀x2::'a ⇒ 'a. (c::('a, 'd, 'c) com) = Basic x2 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 3. ‹⋀x3::('a × 'a) set. (c::('a, 'd, 'c) com) = Spec x3 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 4. ‹⋀(x41::('a, 'd, 'c) com) x42::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Seq x41 x42 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 5. ‹⋀(x51::'a set) (x52::('a, 'd, 'c) com) x53::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Cond x51 x52 x53 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 6. ‹⋀(x61::'a set) x62::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = While x61 x62 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 7. ‹⋀x7::'d. (c::('a, 'd, 'c) com) = Call x7 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 8. ‹⋀x8::'a ⇒ ('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = DynCom x8 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 9. ‹⋀(x91::'c) (x92::'a set) x93::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Guard x91 x92 x93 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 10. ‹(c::('a, 'd, 'c) com) = Throw ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› 11. ‹⋀(x111::('a, 'd, 'c) com) x112::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Catch x111 x112 ⟹ (rename (h::'d ⇒ 'b) c = Call (q::'b)) = (∃p::'d. c = Call p ∧ q = h p)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_DynCom: "(rename h c = DynCom rc) = (∃C. c=DynCom C ∧ rc = (λs. rename h (C s)))" sorry lemma rename_Guard: "(rename h c = Guard f g rc') = (∃c'. c = Guard f g c' ∧ rc' = rename h c')" apply (cases c) (*goals: 1. ‹(c::('a::type, 'd::type, 'c::type) com) = Skip ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 2. ‹⋀x2::'a::type ⇒ 'a::type. (c::('a::type, 'd::type, 'c::type) com) = Basic x2 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 3. ‹⋀x3::('a::type × 'a::type) set. (c::('a::type, 'd::type, 'c::type) com) = Spec x3 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 4. ‹⋀(x41::('a::type, 'd::type, 'c::type) com) x42::('a::type, 'd::type, 'c::type) com. (c::('a::type, 'd::type, 'c::type) com) = Seq x41 x42 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 5. ‹⋀(x51::'a::type set) (x52::('a::type, 'd::type, 'c::type) com) x53::('a::type, 'd::type, 'c::type) com. (c::('a::type, 'd::type, 'c::type) com) = Cond x51 x52 x53 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 6. ‹⋀(x61::'a::type set) x62::('a::type, 'd::type, 'c::type) com. (c::('a::type, 'd::type, 'c::type) com) = While x61 x62 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 7. ‹⋀x7::'d::type. (c::('a::type, 'd::type, 'c::type) com) = Call x7 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 8. ‹⋀x8::'a::type ⇒ ('a::type, 'd::type, 'c::type) com. (c::('a::type, 'd::type, 'c::type) com) = DynCom x8 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 9. ‹⋀(x91::'c::type) (x92::'a::type set) x93::('a::type, 'd::type, 'c::type) com. (c::('a::type, 'd::type, 'c::type) com) = Guard x91 x92 x93 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 10. ‹(c::('a::type, 'd::type, 'c::type) com) = Throw ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› 11. ‹⋀(x111::('a::type, 'd::type, 'c::type) com) x112::('a::type, 'd::type, 'c::type) com. (c::('a::type, 'd::type, 'c::type) com) = Catch x111 x112 ⟹ (rename (h::'d::type ⇒ 'b::type) c = Guard (f::'c::type) (g::'a::type set) (rc'::('a::type, 'b::type, 'c::type) com)) = (∃c'::('a::type, 'd::type, 'c::type) com. c = Guard f g c' ∧ rc' = rename h c')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Throw: "(rename h c = Throw) = (c = Throw)" apply (cases c) (*goals: 1. ‹(c::('a, 'd, 'c) com) = Skip ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 2. ‹⋀x2::'a ⇒ 'a. (c::('a, 'd, 'c) com) = Basic x2 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 3. ‹⋀x3::('a × 'a) set. (c::('a, 'd, 'c) com) = Spec x3 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 4. ‹⋀(x41::('a, 'd, 'c) com) x42::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Seq x41 x42 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 5. ‹⋀(x51::'a set) (x52::('a, 'd, 'c) com) x53::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Cond x51 x52 x53 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 6. ‹⋀(x61::'a set) x62::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = While x61 x62 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 7. ‹⋀x7::'d. (c::('a, 'd, 'c) com) = Call x7 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 8. ‹⋀x8::'a ⇒ ('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = DynCom x8 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 9. ‹⋀(x91::'c) (x92::'a set) x93::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Guard x91 x92 x93 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 10. ‹(c::('a, 'd, 'c) com) = Throw ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› 11. ‹⋀(x111::('a, 'd, 'c) com) x112::('a, 'd, 'c) com. (c::('a, 'd, 'c) com) = Catch x111 x112 ⟹ (rename (h::'d ⇒ 'b) c = Throw) = (c = Throw)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma rename_Catch: "(rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂ )" apply (cases c) (*goals: 1. ‹c = Skip ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 2. ‹⋀x2. c = Basic x2 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 3. ‹⋀x3. c = Spec x3 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 4. ‹⋀x41 x42. c = Seq x41 x42 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 5. ‹⋀x51 x52 x53. c = Cond x51 x52 x53 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 6. ‹⋀x61 x62. c = While x61 x62 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 7. ‹⋀x7. c = Call x7 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 8. ‹⋀x8. c = DynCom x8 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 9. ‹⋀x91 x92 x93. c = Guard x91 x92 x93 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 10. ‹c = Throw ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› 11. ‹⋀x111 x112. c = Catch x111 x112 ⟹ (rename h c = Catch rc₁ rc₂) = (∃c₁ c₂. c = Catch c₁ c₂ ∧ rc₁ = rename h c₁ ∧ rc₂ = rename h c₂)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*proven 11 subgoals*) . lemma exec_rename_to_exec: assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (h p) = Some (rename h bdy)" assumes exec: "Γ'⊢⟨rc,s⟩ ⇒ t" shows "⋀c. rename h c = rc⟹ ∃t'. Γ⊢⟨c,s⟩ ⇒ t' ∧ (t'=Stuck ∨ t'=t)" using exec (*‹Γ'⊢ ⟨rc,s⟩ ⇒ t›*) proof (induct) (*goals: 1. ‹⋀s c. rename h c = Skip ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 2. ‹⋀s g c t f ca. ⟦s ∈ g; Γ'⊢ ⟨c,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = Guard f g c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀s g f c ca. ⟦s ∉ g; rename h ca = Guard f g c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 4. ‹⋀c f ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Fault f⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 5. ‹⋀f s c. rename h c = Basic f ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal (f s))› 6. ‹⋀s t r c. ⟦(s, t) ∈ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t)› 7. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 8. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 10. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 11. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 12. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 13. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 14. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 15. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 16. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 17. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 18. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 19. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 20. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case Skip (*‹rename h c = Skip›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s_)›*) by (fastforce intro: exec.intros (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Skip,Normal (?s::?'s)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s) ∈ (?g::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?g::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Guard (?f::?'f) ?g (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Fault (?f::?'f)⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Basic (?f::?'s ⇒ ?'s),Normal (?s::?'s)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s, ?t::?'s) ∈ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s. (?s::?'s, t) ∉ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal (?s::?'s)⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∉ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s, ?'p, ?'f) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?b::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨While ?b (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Skip (*‹(rename (?h::?'d ⇒ ?'b) (?c::(?'a, ?'d, ?'c) com) = Skip) = (?c = Skip)›*)) next (*goals: 1. ‹⋀s g c t f ca. ⟦s ∈ g; Γ'⊢ ⟨c,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = Guard f g c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀s g f c ca. ⟦s ∉ g; rename h ca = Guard f g c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 3. ‹⋀c f ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Fault f⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 4. ‹⋀f s c. rename h c = Basic f ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal (f s))› 5. ‹⋀s t r c. ⟦(s, t) ∈ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t)› 6. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 7. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 10. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 11. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 12. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 13. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 14. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 15. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 16. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 17. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 18. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 19. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case Guard (*‹s_ ∈ g_› ‹Γ'⊢ ⟨c_,Normal s_⟩ ⇒ t_› ‹rename h ?c = c_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)› ‹rename h c = Guard f_ g_ c_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Guard (*‹(rename ?h ?c = Guard ?f ?g ?rc') = (∃c'. ?c = Guard ?f ?g c' ∧ ?rc' = rename ?h c')›*)) next (*goals: 1. ‹⋀s g f c ca. ⟦s ∉ g; rename h ca = Guard f g c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 2. ‹⋀c f ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Fault f⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 3. ‹⋀f s c. rename h c = Basic f ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal (f s))› 4. ‹⋀s t r c. ⟦(s, t) ∈ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t)› 5. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 6. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 10. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 11. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 12. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 13. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 14. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 15. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 16. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 17. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 18. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case GuardFault (*‹s_ ∉ g_› ‹rename h c = Guard f_ g_ c_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f_)›*) by (fastforce intro: exec.intros (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Skip,Normal (?s::?'s::type)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?g::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f::type) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s::type) ∉ (?g::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Guard (?f::?'f::type) ?g (?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Fault (?f::?'f::type)⟩ ⇒ Fault ?f› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Basic (?f::?'s::type ⇒ ?'s::type),Normal (?s::?'s::type)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s::type, ?t::?'s::type) ∈ (?r::(?'s::type × ?'s::type) set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s::type. (?s::?'s::type, t) ∉ (?r::(?'s::type × ?'s::type) set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₁::(?'s::type, ?'p::type, ?'f::type) com),Normal (?s::?'s::type)⟩ ⇒ (?s'::(?'s::type, ?'f::type) xstate); ?Γ⊢ ⟨(?c₂::(?'s::type, ?'p::type, ?'f::type) com),?s'⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₁::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∉ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₂::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s::type, ?'p::type, ?'f::type) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?s'::(?'s::type, ?'f::type) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s::type) ∉ (?b::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨While ?b (?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Guard (*‹(rename (?h::?'d::type ⇒ ?'b::type) (?c::(?'a::type, ?'d::type, ?'c::type) com) = Guard (?f::?'c::type) (?g::?'a::type set) (?rc'::(?'a::type, ?'b::type, ?'c::type) com)) = (∃c'::(?'a::type, ?'d::type, ?'c::type) com. ?c = Guard ?f ?g c' ∧ ?rc' = rename ?h c')›*)) next (*goals: 1. ‹⋀c f ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Fault f⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f)› 2. ‹⋀f s c. rename h c = Basic f ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal (f s))› 3. ‹⋀s t r c. ⟦(s, t) ∈ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t)› 4. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 5. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 10. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 11. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 12. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 13. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 14. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 15. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 16. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 17. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case FaultProp (*‹rename (h::'a ⇒ 'd) (c::('b, 'a, 'c) com) = (c_::('b, 'd, 'c) com)›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Fault f_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Fault f_)›*) by (fastforce intro: exec.intros (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Skip,Normal (?s::?'s)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s) ∈ (?g::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?g::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Guard (?f::?'f) ?g (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Fault (?f::?'f)⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Basic (?f::?'s ⇒ ?'s),Normal (?s::?'s)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s, ?t::?'s) ∈ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s. (?s::?'s, t) ∉ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal (?s::?'s)⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∉ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s, ?'p, ?'f) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?b::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨While ?b (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀f s c. rename h c = Basic f ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal (f s))› 2. ‹⋀s t r c. ⟦(s, t) ∈ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t)› 3. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 4. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 9. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 10. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 11. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 12. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 13. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 14. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 15. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 16. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case Basic (*‹rename h c = Basic f_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal (f_ s_))›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Basic (*‹(rename ?h ?c = Basic ?f) = (?c = Basic ?f)›*)) next (*goals: 1. ‹⋀s t r c. ⟦(s, t) ∈ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t)› 2. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 3. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 8. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 10. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 11. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 12. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 13. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 14. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 15. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case Spec (*‹(s_::'b, t_::'b) ∈ (r_::('b × 'b) set)› ‹rename h c = Spec r_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal t_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Spec (*‹(rename ?h ?c = Spec ?r) = (?c = Spec ?r)›*)) next (*goals: 1. ‹⋀s r c. ⟦∀t. (s, t) ∉ r; rename h c = Spec r⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 2. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 7. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 9. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 10. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 11. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 12. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 13. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 14. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case SpecStuck (*‹∀t. (s_, t) ∉ r_› ‹rename h c = Spec r_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Spec (*‹(rename ?h ?c = Spec ?r) = (?c = Spec ?r)›*)) next (*goals: 1. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨c₂,s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Seq c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀s b c₁ t c₂ c. ⟦s ∈ b; Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 6. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 8. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 9. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 10. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 11. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 12. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 13. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case Seq (*‹Γ'⊢ ⟨c₁_,Normal s_⟩ ⇒ s'_› ‹rename h ?c = c₁_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'_)› ‹Γ'⊢ ⟨c₂_,s'_⟩ ⇒ t_› ‹rename h ?c = c₂_ ⟹ ∃t'. Γ⊢ ⟨?c,s'_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)› ‹rename h c = Seq c₁_ c₂_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Skip,Normal (?s::?'s::type)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?g::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f::type) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s::type) ∉ (?g::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Guard (?f::?'f::type) ?g (?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Fault (?f::?'f::type)⟩ ⇒ Fault ?f› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Basic (?f::?'s::type ⇒ ?'s::type),Normal (?s::?'s::type)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s::type, ?t::?'s::type) ∈ (?r::(?'s::type × ?'s::type) set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s::type. (?s::?'s::type, t) ∉ (?r::(?'s::type × ?'s::type) set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₁::(?'s::type, ?'p::type, ?'f::type) com),Normal (?s::?'s::type)⟩ ⇒ (?s'::(?'s::type, ?'f::type) xstate); ?Γ⊢ ⟨(?c₂::(?'s::type, ?'p::type, ?'f::type) com),?s'⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₁::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∉ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₂::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s::type, ?'p::type, ?'f::type) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?s'::(?'s::type, ?'f::type) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s::type) ∉ (?b::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨While ?b (?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Seq (*‹(rename (?h::?'d::type ⇒ ?'b::type) (?c::(?'a::type, ?'d::type, ?'c::type) com) = Seq (?rc₁::(?'a::type, ?'b::type, ?'c::type) com) (?rc₂::(?'a::type, ?'b::type, ?'c::type) com)) = (∃(c₁::(?'a::type, ?'d::type, ?'c::type) com) c₂::(?'a::type, ?'d::type, ?'c::type) com. ?c = Seq c₁ c₂ ∧ ?rc₁ = rename ?h c₁ ∧ ?rc₂ = rename ?h c₂)›*)) next (*goals: 1. ‹⋀(s::'b) (b::'b set) (c₁::('b, 'd, 'c) com) (t::('b, 'c) xstate) (c₂::('b, 'd, 'c) com) c::('b, 'a, 'c) com. ⟦s ∈ b; (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) c = c₁ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀(s::'b) (b::'b set) (c₂::('b, 'd, 'c) com) (t::('b, 'c) xstate) (c₁::('b, 'd, 'c) com) c::('b, 'a, 'c) com. ⟦s ∉ b; (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) c = c₂ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀(s::'b) (b::'b set) (c::('b, 'd, 'c) com) (s'::('b, 'c) xstate) (t::('b, 'c) xstate) ca::('b, 'a, 'c) com. ⟦s ∈ b; (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) ca = c ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca::('b, 'a, 'c) com. rename h ca = While b c ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀(s::'b) (b::'b set) (c::('b, 'd, 'c) com) ca::('b, 'a, 'c) com. ⟦s ∉ b; rename (h::'a ⇒ 'd) ca = While b c⟧ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 5. ‹⋀(p::'d) (bdy::('b, 'd, 'c) com) (s::'b) (t::('b, 'c) xstate) c::('b, 'a, 'c) com. ⟦(Γ'::'d ⇒ ('b, 'd, 'c) com option) p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) c = bdy ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀(p::'d) (s::'b) c::('b, 'a, 'c) com. ⟦(Γ'::'d ⇒ ('b, 'd, 'c) com option) p = None; rename (h::'a ⇒ 'd) c = Call p⟧ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 7. ‹⋀(c::('b, 'd, 'c) com) ca::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) ca = c ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 8. ‹⋀(c::'b ⇒ ('b, 'd, 'c) com) (s::'b) (t::('b, 'c) xstate) ca::('b, 'a, 'c) com. ⟦(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) ca = c s ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀(s::'b) c::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) c = Throw ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 10. ‹⋀(c::('b, 'd, 'c) com) (s::'b) ca::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) ca = c ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 11. ‹⋀(c₁::('b, 'd, 'c) com) (s::'b) (s'::'b) (c₂::('b, 'd, 'c) com) (t::('b, 'c) xstate) c::('b, 'a, 'c) com. ⟦(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) c = c₁ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c::('b, 'a, 'c) com. rename h c = c₂ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 12. ‹⋀(c₁::('b, 'd, 'c) com) (s::'b) (t::('b, 'c) xstate) (c₂::('b, 'd, 'c) com) c::('b, 'a, 'c) com. ⟦(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c::('b, 'a, 'c) com. rename (h::'a ⇒ 'd) c = c₁ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case CondTrue (*‹s_ ∈ b_› ‹Γ'⊢ ⟨c₁_,Normal s_⟩ ⇒ t_› ‹rename h ?c = c₁_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)› ‹rename (h::'a ⇒ 'd) (c::('b, 'a, 'c) com) = Cond (b_::'b set) (c₁_::('b, 'd, 'c) com) (c₂_::('b, 'd, 'c) com)›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Cond (*‹(rename ?h ?c = Cond ?b ?rc₁ ?rc₂) = (∃c₁ c₂. ?c = Cond ?b c₁ c₂ ∧ ?rc₁ = rename ?h c₁ ∧ ?rc₂ = rename ?h c₂)›*)) next (*goals: 1. ‹⋀s b c₂ t c₁ c. ⟦s ∉ b; Γ'⊢ ⟨c₂,Normal s⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Cond b c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 4. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 6. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 7. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 9. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 10. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 11. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case CondFalse (*‹s_ ∉ b_› ‹Γ'⊢ ⟨c₂_,Normal s_⟩ ⇒ t_› ‹rename h ?c = c₂_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)› ‹rename h c = Cond b_ c₁_ c₂_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Cond (*‹(rename ?h ?c = Cond ?b ?rc₁ ?rc₂) = (∃c₁ c₂. ?c = Cond ?b c₁ c₂ ∧ ?rc₁ = rename ?h c₁ ∧ ?rc₂ = rename ?h c₂)›*)) next (*goals: 1. ‹⋀s b c s' t ca. ⟦s ∈ b; Γ'⊢ ⟨c,Normal s⟩ ⇒ s'; ⋀ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'); Γ'⊢ ⟨While b c,s'⟩ ⇒ t; ⋀ca. rename h ca = While b c ⟹ ∃t'. Γ⊢ ⟨ca,s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 3. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 5. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 6. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 8. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 9. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 10. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case WhileTrue (*‹s_ ∈ b_› ‹Γ'⊢ ⟨c_,Normal s_⟩ ⇒ s'_› ‹rename h ?c = c_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = s'_)› ‹Γ'⊢ ⟨While b_ c_,s'_⟩ ⇒ t_› ‹rename h ?c = While b_ c_ ⟹ ∃t'. Γ⊢ ⟨?c,s'_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)› ‹rename h c = While b_ c_›*) thus "?case" (*goal: ‹∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨(c::('b, 'a, 'c) com),Normal (s_::'b)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t_::('b, 'c) xstate))›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_While (*‹(rename ?h ?c = While ?b ?rc') = (∃c'. ?c = While ?b c' ∧ ?rc' = rename ?h c')›*)) next (*goals: 1. ‹⋀s b c ca. ⟦s ∉ b; rename h ca = While b c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s)› 2. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 4. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 5. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 7. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 8. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 9. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case WhileFalse (*‹s_ ∉ b_› ‹rename h c = While b_ c_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Normal s_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_While (*‹(rename ?h ?c = While ?b ?rc') = (∃c'. ?c = While ?b c' ∧ ?rc' = rename ?h c')›*)) next (*goals: 1. ‹⋀p bdy s t c. ⟦Γ' p = Some bdy; Γ'⊢ ⟨bdy,Normal s⟩ ⇒ t; ⋀c. rename h c = bdy ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 3. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 4. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 6. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 7. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 8. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case (Call p rbdy s t) (*‹Γ' p = Some rbdy› ‹Γ'⊢ ⟨rbdy,Normal s⟩ ⇒ t› ‹rename h ?c = rbdy ⟹ ∃t'. Γ⊢ ⟨?c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› ‹rename (h::'a ⇒ 'd) (c::('b, 'a, 'c) com) = Call (p::'d)›*) have rbdy: "Γ' p = Some rbdy" by fact have "rename h c = Call p" by fact then obtain q where c: "c=Call q" and p: "p=h q" (*goal: ‹(⋀q::'a. ⟦(c::('b, 'a, 'c) com) = Call q; (p::'d) = (h::'a ⇒ 'd) q⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: rename_Call (*‹(rename ?h ?c = Call ?q) = (∃p. ?c = Call p ∧ ?q = ?h p)›*)) show "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) proof (cases "Γ q") (*goals: 1. ‹(Γ::'a ⇒ ('b, 'a, 'c) com option) (q::'a) = None ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨(c::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t::('b, 'c) xstate))› 2. ‹⋀a::('b, 'a, 'c) com. (Γ::'a ⇒ ('b, 'a, 'c) com option) (q::'a) = Some a ⟹ ∃t'::('b, 'c) xstate. Γ⊢ ⟨(c::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t::('b, 'c) xstate))›*) case None (*‹(Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option) (q::'a::type) = None›*) with c (*‹c = Call q›*) show "?thesis" (*goal: ‹∃t'::('b::type, 'c::type) xstate. (Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option)⊢ ⟨(c::('b::type, 'a::type, 'c::type) com),Normal (s::'b::type)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t::('b::type, 'c::type) xstate))›*) by (auto intro: exec.CallUndefined (*‹?Γ ?p = None ⟹ ?Γ⊢ ⟨Call ?p,Normal ?s⟩ ⇒ Stuck›*)) next (*goal: ‹⋀a. Γ q = Some a ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case (Some bdy) (*‹Γ q = Some bdy›*) from "Γ"[rule_format, OF this] (*‹(Γ'::'d::type ⇒ ('b::type, 'd::type, 'c::type) com option) ((h::'a::type ⇒ 'd::type) (q::'a::type)) = Some (rename h (bdy::('b::type, 'a::type, 'c::type) com))›*) p (*‹p = h q›*) rbdy (*‹Γ' p = Some rbdy›*) have "rename h bdy = rbdy" by simp with Call.hyps (*‹(Γ'::'d::type ⇒ ('b::type, 'd::type, 'c::type) com option) (p::'d::type) = Some (rbdy::('b::type, 'd::type, 'c::type) com)› ‹Γ'⊢ ⟨rbdy,Normal s⟩ ⇒ t› ‹rename h ?c = rbdy ⟹ ∃t'. Γ⊢ ⟨?c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) c (*‹c = Call q›*) Some (*‹Γ q = Some bdy›*) show "?thesis" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) qed next (*goals: 1. ‹⋀p s c. ⟦Γ' p = None; rename h c = Call p⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 2. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 3. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 5. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 6. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 7. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case (CallUndefined p s) (*‹Γ' p = None› ‹rename (h::'a ⇒ 'd) (c::('b, 'a, 'c) com) = Call (p::'d)›*) have undef: "Γ' p = None" by fact have "rename h c = Call p" by fact then obtain q where c: "c=Call q" and p: "p=h q" (*goal: ‹(⋀q::'a. ⟦(c::('b, 'a, 'c) com) = Call q; (p::'d) = (h::'a ⇒ 'd) q⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: rename_Call (*‹(rename ?h ?c = Call ?q) = (∃p. ?c = Call p ∧ ?q = ?h p)›*)) from undef (*‹Γ' p = None›*) p (*‹p = h q›*) "Γ" (*‹∀p bdy. Γ p = Some bdy ⟶ Γ' (h p) = Some (rename h bdy)›*) have "Γ q = None" apply (cases "Γ q") (*goals: 1. ‹⟦Γ' p = None; p = h q; ∀p bdy. Γ p = Some bdy ⟶ Γ' (h p) = Some (rename h bdy); Γ q = None⟧ ⟹ Γ q = None› 2. ‹⋀a. ⟦Γ' p = None; p = h q; ∀p bdy. Γ p = Some bdy ⟶ Γ' (h p) = Some (rename h bdy); Γ q = Some a⟧ ⟹ Γ q = None› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with p (*‹p = h q›*) c (*‹c = Call q›*) show "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)›*) by (auto intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀c ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)› 2. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 4. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 5. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 6. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case StuckProp (*‹rename (h::'a ⇒ 'd) (c::('b, 'a, 'c) com) = (c_::('b, 'd, 'c) com)›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Stuck⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Stuck)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀c s t ca. ⟦Γ'⊢ ⟨c s,Normal s⟩ ⇒ t; ⋀ca. rename h ca = c s ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h ca = DynCom c⟧ ⟹ ∃t'. Γ⊢ ⟨ca,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 3. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 4. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 5. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case DynCom (*‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(c_::'b ⇒ ('b, 'd, 'c) com) (s_::'b),Normal s_⟩ ⇒ (t_::('b, 'c) xstate)› ‹rename (h::'a ⇒ 'd) (?c::('b, 'a, 'c) com) = (c_::'b ⇒ ('b, 'd, 'c) com) (s_::'b) ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t_::('b, 'c) xstate))› ‹rename h c = DynCom c_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_DynCom (*‹(rename ?h ?c = DynCom ?rc) = (∃C. ?c = DynCom C ∧ ?rc = (λs. rename ?h (C s)))›*)) next (*goals: 1. ‹⋀s c. rename h c = Throw ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 2. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 3. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 4. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case Throw (*‹rename (h::'a::type ⇒ 'd::type) (c::('b::type, 'a::type, 'c::type) com) = Throw›*) thus "?case" (*goal: ‹∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨(c::('b, 'a, 'c) com),Normal (s_::'b)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Throw (*‹(rename ?h ?c = Throw) = (?c = Throw)›*)) next (*goals: 1. ‹⋀c s ca. rename h ca = c ⟹ ∃t'. Γ⊢ ⟨ca,Abrupt s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s)› 2. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 3. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case AbruptProp (*‹rename (h::'a ⇒ 'd) (c::('b, 'a, 'c) com) = (c_::('b, 'd, 'c) com)›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Abrupt s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀c₁ s s' c₂ t c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s'; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'); Γ'⊢ ⟨c₂,Normal s'⟩ ⇒ t; ⋀c. rename h c = c₂ ⟹ ∃t'. Γ⊢ ⟨c,Normal s'⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)› 2. ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case CatchMatch (*‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(c₁_::('b, 'd, 'c) com),Normal (s_::'b)⟩ ⇒ Abrupt (s'_::'b)› ‹rename h ?c = c₁_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt s'_)› ‹Γ'⊢ ⟨c₂_,Normal s'_⟩ ⇒ t_› ‹rename (h::'a ⇒ 'd) (?c::('b, 'a, 'c) com) = (c₂_::('b, 'd, 'c) com) ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨?c,Normal (s'_::'b)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t_::('b, 'c) xstate))› ‹rename h c = Catch c₁_ c₂_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Skip,Normal (?s::?'s)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s) ∈ (?g::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?g::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Guard (?f::?'f) ?g (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Fault (?f::?'f)⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Basic (?f::?'s ⇒ ?'s),Normal (?s::?'s)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s, ?t::?'s) ∈ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s. (?s::?'s, t) ∉ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal (?s::?'s)⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∉ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s, ?'p, ?'f) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?b::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨While ?b (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Catch (*‹(rename (?h::?'d ⇒ ?'b) (?c::(?'a, ?'d, ?'c) com) = Catch (?rc₁::(?'a, ?'b, ?'c) com) (?rc₂::(?'a, ?'b, ?'c) com)) = (∃(c₁::(?'a, ?'d, ?'c) com) c₂::(?'a, ?'d, ?'c) com. ?c = Catch c₁ c₂ ∧ ?rc₁ = rename ?h c₁ ∧ ?rc₂ = rename ?h c₂)›*)) next (*goal: ‹⋀c₁ s t c₂ c. ⟦Γ'⊢ ⟨c₁,Normal s⟩ ⇒ t; ⋀c. rename h c = c₁ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t); ¬ isAbr t; rename h c = Catch c₁ c₂⟧ ⟹ ∃t'. Γ⊢ ⟨c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) case CatchMiss (*‹Γ'⊢ ⟨c₁_,Normal s_⟩ ⇒ t_› ‹rename h ?c = c₁_ ⟹ ∃t'. Γ⊢ ⟨?c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)› ‹¬ isAbr t_› ‹rename h c = Catch c₁_ c₂_›*) thus "?case" (*goal: ‹∃t'. Γ⊢ ⟨c,Normal s_⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t_)›*) by (fastforce intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) simp add: rename_Catch (*‹(rename ?h ?c = Catch ?rc₁ ?rc₂) = (∃c₁ c₂. ?c = Catch c₁ c₂ ∧ ?rc₁ = rename ?h c₁ ∧ ?rc₂ = rename ?h c₂)›*)) qed lemma exec_rename_to_exec': assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes exec: "Γ'⊢⟨rename N c,s⟩ ⇒ t" shows "∃t'. Γ⊢⟨c,s⟩ ⇒ t' ∧ (t'=Stuck ∨ t'=t)" using exec_rename_to_exec[OF Γ exec] (*‹rename N ?c = rename N c ⟹ ∃t'. Γ⊢ ⟨?c,s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) by auto lemma valid_to_valid_rename: assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes valid: "Γ⊨⇘/F⇙ P c Q,A" shows "Γ'⊨⇘/F⇙ P (rename N c) Q,A" proof (rule validI (*‹(⋀(s::?'a) t::(?'a, ?'b) xstate. ⟦(?Γ::?'c ⇒ (?'a, ?'c, ?'b) com option)⊢ ⟨(?c::(?'a, ?'c, ?'b) com),Normal s⟩ ⇒ t; s ∈ (?P::?'a set); t ∉ Fault ` (?F::?'b set)⟧ ⟹ t ∈ Normal ` (?Q::?'a set) ∪ Abrupt ` (?A::?'a set)) ⟹ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀s t. ⟦Γ'⊢ ⟨rename N c,Normal s⟩ ⇒ t; s ∈ P; t ∉ Fault ` F⟧ ⟹ t ∈ Normal ` Q ∪ Abrupt ` A›*) fix s and t assume execr: "Γ'⊢ ⟨rename N c,Normal s⟩ ⇒ t" (*‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨rename (N::'a ⇒ 'd) (c::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ (t::('b, 'c) xstate)›*) assume P: "s ∈ P" (*‹(s::'b) ∈ (P::'b set)›*) assume noFault: "t ∉ Fault ` F" (*‹(t::('b, 'c) xstate) ∉ Fault ` (F::'c set)›*) show "t ∈ Normal ` Q ∪ Abrupt ` A" proof (-) (*goal: ‹t ∈ Normal ` Q ∪ Abrupt ` A›*) from exec_rename_to_exec[OF Γ execr] (*‹rename N ?c = rename N c ⟹ ∃t'. Γ⊢ ⟨?c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = t)›*) obtain t' where exec: "Γ⊢ ⟨c,Normal s⟩ ⇒ t'" and t': "(t' = Stuck ∨ t' = t)" (*goal: ‹(⋀t'. ⟦Γ⊢ ⟨c,Normal s⟩ ⇒ t'; t' = Stuck ∨ t' = t⟧ ⟹ thesis) ⟹ thesis›*) by auto with valid (*‹Γ⊨⇘/F⇙ P c Q,A›*) noFault (*‹t ∉ Fault ` F›*) P (*‹s ∈ P›*) show "?thesis" (*goal: ‹t ∈ Normal ` Q ∪ Abrupt ` A›*) by (auto simp add: valid_def (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ ∀s t. ?Γ⊢ ⟨?c,s⟩ ⇒ t ⟶ s ∈ Normal ` ?P ⟶ t ∉ Fault ` ?F ⟶ t ∈ Normal ` ?Q ∪ Abrupt ` ?A›*)) qed qed lemma hoare_to_hoare_rename: assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes deriv: "Γ,{}⊢⇘/F⇙ P c Q,A" shows "Γ',{}⊢⇘/F⇙ P (rename N c) Q,A" apply (rule hoare_complete (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ⟹ ?Γ,{}⊢⇘/?F ⇙?P ?c ?Q,?A›*)) (*goal: ‹Γ',{}⊢⇘/F ⇙P rename N c Q,A›*) apply (insert hoare_sound [OF deriv] (*‹Γ,{}⊨⇘/F⇙ P c Q,A›*)) (*goal: ‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊨⇘/(F::'c set)⇙ (P::'b set) rename (N::'a ⇒ 'd) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set)›*) apply (rule valid_to_valid_rename (*‹⟦∀p bdy. ?Γ p = Some bdy ⟶ ?Γ' (?N p) = Some (rename ?N bdy); ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A⟧ ⟹ ?Γ'⊨⇘/?F⇙ ?P rename ?N ?c ?Q,?A›*)) (*goals: 1. ‹(Γ::'a ⇒ ('b, 'a, 'c) com option),{}⊨⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set) ⟹ ∀(p::'a) bdy::('b, 'a, 'c) com. (?Γ4::'a ⇒ ('b, 'a, 'c) com option) p = Some bdy ⟶ (Γ'::'d ⇒ ('b, 'd, 'c) com option) ((N::'a ⇒ 'd) p) = Some (rename N bdy)› 2. ‹(Γ::'a ⇒ ('b, 'a, 'c) com option),{}⊨⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set) ⟹ (?Γ4::'a ⇒ ('b, 'a, 'c) com option)⊨⇘/F⇙ P c Q,A› discuss goal 1*) apply (rule Γ (*‹∀(p::'a) bdy::('b, 'a, 'c) com. (Γ::'a ⇒ ('b, 'a, 'c) com option) p = Some bdy ⟶ (Γ'::'d ⇒ ('b, 'd, 'c) com option) ((N::'a ⇒ 'd) p) = Some (rename N bdy)›*)) (*discuss goal 2*) apply (simp add: cvalid_def (*‹?Γ,?Θ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*)) (*proven 2 subgoals*) . lemma hoare_to_hoare_rename': assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes deriv: "∀Z. Γ,{}⊢⇘/F⇙ (P Z) c (Q Z),(A Z)" shows "∀Z. Γ',{}⊢⇘/F⇙ (P Z) (rename N c) (Q Z),(A Z)" apply rule (*goal: ‹∀Z. Γ',{}⊢⇘/F ⇙(P Z) rename N c (Q Z),(A Z)›*) apply (rule hoare_to_hoare_rename [OF Γ] (*‹(Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option),{}⊢⇘/(?F::'c::type set) ⇙(?P::'b::type set) (?c::('b::type, 'a::type, 'c::type) com) (?Q::'b::type set),(?A::'b::type set) ⟹ (Γ'::'d::type ⇒ ('b::type, 'd::type, 'c::type) com option),{}⊢⇘/?F ⇙?P rename (N::'a::type ⇒ 'd::type) ?c ?Q,?A›*)) (*goal: ‹⋀Z. Γ',{}⊢⇘/F ⇙(P Z) rename N c (Q Z),(A Z)›*) by (rule deriv[rule_format] (*‹Γ,{}⊢⇘/F ⇙(P ?Z) c (Q ?Z),(A ?Z)›*)) lemma terminates_to_terminates_rename: assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes termi: "Γ⊢ c ↓ s" assumes noStuck: "Γ⊢ ⟨c,s⟩ ⇒∉{Stuck}" shows "Γ'⊢ rename N c ↓ s" using termi (*‹Γ⊢c ↓ s›*) noStuck (*‹Γ⊢ ⟨c,s⟩ ⇒∉{Stuck}›*) proof (induct) (*goals: 1. ‹⋀s. Γ⊢ ⟨Skip,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Skip ↓ Normal s› 2. ‹⋀f s. Γ⊢ ⟨Basic f,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (Basic f) ↓ Normal s› 3. ‹⋀r s. Γ⊢ ⟨Spec r,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (Spec r) ↓ Normal s› 4. ‹⋀s g c f. ⟦s ∈ g; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 5. ‹⋀s g f c. ⟦s ∉ g; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 6. ‹⋀c f. Γ⊢ ⟨c,Fault f⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Fault f› 7. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 8. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 9. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 10. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 11. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 12. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 13. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 14. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 15. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 16. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 17. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 18. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Skip (*‹Γ⊢ ⟨Skip,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N Skip ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀f s. Γ⊢ ⟨Basic f,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (Basic f) ↓ Normal s› 2. ‹⋀r s. Γ⊢ ⟨Spec r,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (Spec r) ↓ Normal s› 3. ‹⋀s g c f. ⟦s ∈ g; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 4. ‹⋀s g f c. ⟦s ∉ g; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 5. ‹⋀c f. Γ⊢ ⟨c,Fault f⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Fault f› 6. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 7. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 8. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 9. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 10. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 11. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 12. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 13. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 14. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 15. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 16. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 17. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Basic (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Basic (f_::'b ⇒ 'b),Normal (s_::'b)⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (Basic (f_::'b ⇒ 'b)) ↓ Normal (s_::'b)›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀r s. Γ⊢ ⟨Spec r,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (Spec r) ↓ Normal s› 2. ‹⋀s g c f. ⟦s ∈ g; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 3. ‹⋀s g f c. ⟦s ∉ g; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 4. ‹⋀c f. Γ⊢ ⟨c,Fault f⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Fault f› 5. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 6. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 7. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 8. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 9. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 10. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 11. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 12. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 13. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 14. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 15. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 16. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Spec (*‹Γ⊢ ⟨Spec r_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N (Spec r_) ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s g c f. ⟦s ∈ g; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 2. ‹⋀s g f c. ⟦s ∉ g; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 3. ‹⋀c f. Γ⊢ ⟨c,Fault f⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Fault f› 4. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 5. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 6. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 7. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 8. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 9. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 10. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 11. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 12. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 13. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 14. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 15. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Guard (*‹s_ ∈ g_› ‹Γ⊢c_ ↓ Normal s_› ‹Γ⊢ ⟨c_,Normal s_⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c_ ↓ Normal s_› ‹Γ⊢ ⟨Guard f_ g_ c_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N (Guard f_ g_ c_) ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*) simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀s g f c. ⟦s ∉ g; Γ⊢ ⟨Guard f g c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Guard f g c) ↓ Normal s› 2. ‹⋀c f. Γ⊢ ⟨c,Fault f⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Fault f› 3. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 4. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 5. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 6. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 7. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 8. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 9. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 10. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 11. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 12. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 13. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 14. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case GuardFault (*‹s_ ∉ g_› ‹Γ⊢ ⟨Guard f_ g_ c_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹(Γ'::'d::type ⇒ ('b::type, 'd::type, 'c::type) com option)⊢rename (N::'a::type ⇒ 'd::type) (Guard (f_::'c::type) (g_::'b::type set) (c_::('b::type, 'a::type, 'c::type) com)) ↓ Normal (s_::'b::type)›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀c f. Γ⊢ ⟨c,Fault f⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Fault f› 2. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 3. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 4. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 5. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 6. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 7. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 8. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 9. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 10. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 11. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 12. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 13. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Fault (*‹Γ⊢ ⟨c_,Fault f_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N c_ ↓ Fault f_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀(c₁::('b, 'a, 'c) com) (s::'b) c₂::('b, 'a, 'c) com. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; ∀s'::('b, 'c) xstate. Γ⊢ ⟨c₁,Normal s⟩ ⇒ s' ⟶ Γ⊢c₂ ↓ s' ∧ (Γ⊢ ⟨c₂,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ s'); Γ⊢ ⟨Seq c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Seq c₁ c₂) ↓ Normal s› 2. ‹⋀(s::'b) (b::'b set) (c₁::('b, 'a, 'c) com) c₂::('b, 'a, 'c) com. ⟦s ∈ b; (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 3. ‹⋀(s::'b) (b::'b set) (c₂::('b, 'a, 'c) com) c₁::('b, 'a, 'c) com. ⟦s ∉ b; (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 4. ‹⋀(s::'b) (b::'b set) c::('b, 'a, 'c) com. ⟦s ∈ b; (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Normal s; ∀s'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 5. ‹⋀(s::'b) (b::'b set) c::('b, 'a, 'c) com. ⟦s ∉ b; (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (While b c) ↓ Normal s› 6. ‹⋀(p::'a) (bdy::('b, 'a, 'c) com) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option) p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 7. ‹⋀(p::'a) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option) p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (Call p) ↓ Normal s› 8. ‹⋀c::('b, 'a, 'c) com. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Stuck› 9. ‹⋀(c::'b ⇒ ('b, 'a, 'c) com) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 10. ‹⋀s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) Throw ↓ Normal s› 11. ‹⋀(c::('b, 'a, 'c) com) s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Abrupt s› 12. ‹⋀(c₁::('b, 'a, 'c) com) (s::'b) c₂::('b, 'a, 'c) com. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; ∀s'::'b. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Seq (*‹Γ⊢c₁_ ↓ Normal s_› ‹Γ⊢ ⟨c₁_,Normal s_⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁_ ↓ Normal s_› ‹∀s'. Γ⊢ ⟨c₁_,Normal s_⟩ ⇒ s' ⟶ Γ⊢c₂_ ↓ s' ∧ (Γ⊢ ⟨c₂_,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂_ ↓ s')› ‹Γ⊢ ⟨Seq c₁_ c₂_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N (Seq c₁_ c₂_) ↓ Normal s_›*) by (force intro!: terminates.intros (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Skip ↓ Normal (?s::?'s)› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Basic (?f::?'s ⇒ ?'s) ↓ Normal (?s::?'s)› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Spec (?r::(?'s × ?'s) set) ↓ Normal (?s::?'s)› ‹⟦(?s::?'s) ∈ (?g::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard (?f::?'f) ?g ?c ↓ Normal ?s› ‹(?s::?'s) ∉ (?g::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Guard (?f::?'f) ?g (?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c::(?'s, ?'p, ?'f) com) ↓ Fault (?f::?'f)› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c₁::(?'s, ?'p, ?'f) com) ↓ Normal (?s::?'s); ∀s'::(?'s, ?'f) xstate. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢(?c₂::(?'s, ?'p, ?'f) com) ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c₁::(?'s, ?'p, ?'f) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ (?c₂::(?'s, ?'p, ?'f) com) ↓ Normal ?s› ‹⟦(?s::?'s) ∉ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c₂::(?'s, ?'p, ?'f) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b (?c₁::(?'s, ?'p, ?'f) com) ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s; ∀s'::(?'s, ?'f) xstate. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹(?s::?'s) ∉ (?b::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢While ?b (?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option) (?p::?'p) = Some (?bdy::(?'s, ?'p, ?'f) com); ?Γ⊢?bdy ↓ Normal (?s::?'s)⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*) exec.intros (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Skip,Normal (?s::?'s)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s) ∈ (?g::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?g::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Guard (?f::?'f) ?g (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Fault (?f::?'f)⟩ ⇒ Fault ?f› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Basic (?f::?'s ⇒ ?'s),Normal (?s::?'s)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s, ?t::?'s) ∈ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s. (?s::?'s, t) ∉ (?r::(?'s × ?'s) set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal (?s::?'s)⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₁::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∉ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c₂::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s, ?'p, ?'f) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ (?s'::(?'s, ?'f) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s, ?'f) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s) ∉ (?b::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨While ?b (?c::(?'s, ?'p, ?'f) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*) dest: exec_rename_to_exec [OF Γ] (*‹⟦(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨(?rc::('b, 'd, 'c) com),(?s::('b, 'c) xstate)⟩ ⇒ (?t::('b, 'c) xstate); rename (N::'a ⇒ 'd) (?c::('b, 'a, 'c) com) = ?rc⟧ ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨?c,?s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = ?t)›*) simp add: final_notin_def (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢ ⟨(?c::(?'s, ?'p, ?'f) com),(?s::(?'s, ?'f) xstate)⟩ ⇒∉(?T::(?'s, ?'f) xstate set) = (∀t::(?'s, ?'f) xstate. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*)) next (*goals: 1. ‹⋀s b c₁ c₂. ⟦s ∈ b; Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 2. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 3. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 4. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 5. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 6. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 7. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 8. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 9. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 10. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 11. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case CondTrue (*‹s_ ∈ b_› ‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢(c₁_::('b, 'a, 'c) com) ↓ Normal (s_::'b)› ‹Γ⊢ ⟨c₁_,Normal s_⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁_ ↓ Normal s_› ‹Γ⊢ ⟨Cond b_ c₁_ c₂_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (Cond (b_::'b set) (c₁_::('b, 'a, 'c) com) (c₂_::('b, 'a, 'c) com)) ↓ Normal (s_::'b)›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*) simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀s b c₂ c₁. ⟦s ∉ b; Γ⊢c₂ ↓ Normal s; Γ⊢ ⟨c₂,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂ ↓ Normal s; Γ⊢ ⟨Cond b c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Cond b c₁ c₂) ↓ Normal s› 2. ‹⋀s b c. ⟦s ∈ b; Γ⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s; ∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 3. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 4. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 5. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 6. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 7. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 8. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 9. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 10. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case CondFalse (*‹(s_::'b::type) ∉ (b_::'b::type set)› ‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢(c₂_::('b, 'a, 'c) com) ↓ Normal (s_::'b)› ‹Γ⊢ ⟨c₂_,Normal s_⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₂_ ↓ Normal s_› ‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Cond (b_::'b set) (c₁_::('b, 'a, 'c) com) (c₂_::('b, 'a, 'c) com),Normal (s_::'b)⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N (Cond b_ c₁_ c₂_) ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Skip ↓ Normal (?s::?'s::type)› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Basic (?f::?'s::type ⇒ ?'s::type) ↓ Normal (?s::?'s::type)› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Spec (?r::(?'s::type × ?'s::type) set) ↓ Normal (?s::?'s::type)› ‹⟦(?s::?'s::type) ∈ (?g::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard (?f::?'f::type) ?g ?c ↓ Normal ?s› ‹(?s::?'s::type) ∉ (?g::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Guard (?f::?'f::type) ?g (?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Fault (?f::?'f::type)› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₁::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal (?s::?'s::type); ∀s'::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢(?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₁::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ (?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹⟦(?s::?'s::type) ∉ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b (?c₁::(?'s::type, ?'p::type, ?'f::type) com) ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s; ∀s'::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹(?s::?'s::type) ∉ (?b::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢While ?b (?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option) (?p::?'p::type) = Some (?bdy::(?'s::type, ?'p::type, ?'f::type) com); ?Γ⊢?bdy ↓ Normal (?s::?'s::type)⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*) simp add: final_notin_def (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),(?s::(?'s::type, ?'f::type) xstate)⟩ ⇒∉(?T::(?'s::type, ?'f::type) xstate set) = (∀t::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) exec.intros (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Skip,Normal (?s::?'s::type)⟩ ⇒ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?g::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Guard (?f::?'f::type) ?g ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s::type) ∉ (?g::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Guard (?f::?'f::type) ?g (?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ Fault ?f› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Fault (?f::?'f::type)⟩ ⇒ Fault ?f› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Basic (?f::?'s::type ⇒ ?'s::type),Normal (?s::?'s::type)⟩ ⇒ Normal (?f ?s)› ‹(?s::?'s::type, ?t::?'s::type) ∈ (?r::(?'s::type × ?'s::type) set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t::?'s::type. (?s::?'s::type, t) ∉ (?r::(?'s::type × ?'s::type) set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₁::(?'s::type, ?'p::type, ?'f::type) com),Normal (?s::?'s::type)⟩ ⇒ (?s'::(?'s::type, ?'f::type) xstate); ?Γ⊢ ⟨(?c₂::(?'s::type, ?'p::type, ?'f::type) com),?s'⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₁::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ (?c₂::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∉ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c₂::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨Cond ?b (?c₁::(?'s::type, ?'p::type, ?'f::type) com) ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨(?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ (?s'::(?'s::type, ?'f::type) xstate); ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ (?t::(?'s::type, ?'f::type) xstate)⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹(?s::?'s::type) ∉ (?b::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢ ⟨While ?b (?c::(?'s::type, ?'p::type, ?'f::type) com),Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀(s::'b) (b::'b set) c::('b, 'a, 'c) com. ⟦s ∈ b; (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c ↓ Normal s; Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Normal s; ∀s'::('b, 'c) xstate. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s'); Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 2. ‹⋀(s::'b) (b::'b set) c::('b, 'a, 'c) com. ⟦s ∉ b; (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (While b c) ↓ Normal s› 3. ‹⋀(p::'a) (bdy::('b, 'a, 'c) com) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option) p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 4. ‹⋀(p::'a) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option) p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (Call p) ↓ Normal s› 5. ‹⋀c::('b, 'a, 'c) com. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Stuck› 6. ‹⋀(c::'b ⇒ ('b, 'a, 'c) com) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 7. ‹⋀s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) Throw ↓ Normal s› 8. ‹⋀(c::('b, 'a, 'c) com) s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Abrupt s› 9. ‹⋀(c₁::('b, 'a, 'c) com) (s::'b) c₂::('b, 'a, 'c) com. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; ∀s'::'b. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case (WhileTrue s b c) (*‹(s::'b::type) ∈ (b::'b::type set)› ‹Γ⊢c ↓ Normal s› ‹Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s› ‹∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s')› ‹Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}›*) have s_in_b: "s ∈ b" by fact have noStuck: "Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}" by fact with s_in_b (*‹(s::'b) ∈ (b::'b set)›*) have "Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck}" by (auto simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) with WhileTrue.hyps (*‹s ∈ b› ‹Γ⊢c ↓ Normal s› ‹Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s› ‹∀s'. Γ⊢ ⟨c,Normal s⟩ ⇒ s' ⟶ Γ⊢While b c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N (While b c) ↓ s')›*) have "Γ'⊢rename N c ↓ Normal s" by simp moreover { fix t assume exec_rc: "Γ'⊢ ⟨rename N c,Normal s⟩ ⇒ t" (*‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨rename (N::'a ⇒ 'd) (c::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ (t::('b, 'c) xstate)›*) have "Γ'⊢ While b (rename N c) ↓ t" proof (-) (*goal: ‹Γ'⊢While b (rename N c) ↓ t›*) from exec_rename_to_exec[OF Γ exec_rc] (*‹rename (N::'a ⇒ 'd) (?c::('b, 'a, 'c) com) = rename N (c::('b, 'a, 'c) com) ⟹ ∃t'::('b, 'c) xstate. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨?c,Normal (s::'b)⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = (t::('b, 'c) xstate))›*) obtain t' where exec_c: "Γ⊢ ⟨c,Normal s⟩ ⇒ t'" and t': "(t' = Stuck ∨ t' = t)" (*goal: ‹(⋀t'::('b, 'c) xstate. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨(c::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ t'; t' = Stuck ∨ t' = (t::('b, 'c) xstate)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto with s_in_b (*‹s ∈ b›*) noStuck (*‹Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}›*) obtain "t'=t" and "Γ⊢ ⟨While b c,t⟩ ⇒∉{Stuck}" (*goal: ‹(⟦t' = t; Γ⊢ ⟨While b c,t⟩ ⇒∉{Stuck}⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) with exec_c (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨(c::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ (t'::('b, 'c) xstate)›*) WhileTrue.hyps (*‹s ∈ b› ‹Γ⊢c ↓ Normal s› ‹Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Normal s› ‹∀s'::('b::type, 'c::type) xstate. (Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option)⊢ ⟨(c::('b::type, 'a::type, 'c::type) com),Normal (s::'b::type)⟩ ⇒ s' ⟶ Γ⊢While (b::'b::type set) c ↓ s' ∧ (Γ⊢ ⟨While b c,s'⟩ ⇒∉{Stuck} ⟶ (Γ'::'d::type ⇒ ('b::type, 'd::type, 'c::type) com option)⊢rename (N::'a::type ⇒ 'd::type) (While b c) ↓ s')›*) show "?thesis" (*goal: ‹Γ'⊢While b (rename N c) ↓ t›*) by auto qed } ultimately show "?case" (*goal: ‹Γ'⊢rename N (While b c) ↓ Normal s›*) using s_in_b (*‹(s::'b::type) ∈ (b::'b::type set)›*) by (auto intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀s b c. ⟦s ∉ b; Γ⊢ ⟨While b c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (While b c) ↓ Normal s› 2. ‹⋀p bdy s. ⟦Γ p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 3. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 4. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 5. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 6. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 7. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 8. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case WhileFalse (*‹s_ ∉ b_› ‹Γ⊢ ⟨While b_ c_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N (While b_ c_) ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Skip ↓ Normal (?s::?'s::type)› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Basic (?f::?'s::type ⇒ ?'s::type) ↓ Normal (?s::?'s::type)› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Spec (?r::(?'s::type × ?'s::type) set) ↓ Normal (?s::?'s::type)› ‹⟦(?s::?'s::type) ∈ (?g::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard (?f::?'f::type) ?g ?c ↓ Normal ?s› ‹(?s::?'s::type) ∉ (?g::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢Guard (?f::?'f::type) ?g (?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Fault (?f::?'f::type)› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₁::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal (?s::?'s::type); ∀s'::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢(?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₁::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ (?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹⟦(?s::?'s::type) ∉ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c₂::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b (?c₁::(?'s::type, ?'p::type, ?'f::type) com) ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s::type) ∈ (?b::?'s::type set); (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢(?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s; ∀s'::(?'s::type, ?'f::type) xstate. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹(?s::?'s::type) ∉ (?b::?'s::type set) ⟹ (?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option)⊢While ?b (?c::(?'s::type, ?'p::type, ?'f::type) com) ↓ Normal ?s› ‹⟦(?Γ::?'p::type ⇒ (?'s::type, ?'p::type, ?'f::type) com option) (?p::?'p::type) = Some (?bdy::(?'s::type, ?'p::type, ?'f::type) com); ?Γ⊢?bdy ↓ Normal (?s::?'s::type)⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀(p::'a) (bdy::('b, 'a, 'c) com) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option) p = Some bdy; Γ⊢bdy ↓ Normal s; Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) bdy ↓ Normal s; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 2. ‹⋀(p::'a) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option) p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (Call p) ↓ Normal s› 3. ‹⋀c::('b, 'a, 'c) com. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Stuck› 4. ‹⋀(c::'b ⇒ ('b, 'a, 'c) com) s::'b. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 5. ‹⋀s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) Throw ↓ Normal s› 6. ‹⋀(c::('b, 'a, 'c) com) s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Abrupt s› 7. ‹⋀(c₁::('b, 'a, 'c) com) (s::'b) c₂::('b, 'a, 'c) com. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; ∀s'::'b. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case (Call p bdy s) (*‹Γ p = Some bdy› ‹Γ⊢bdy ↓ Normal s› ‹Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s› ‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Call (p::'a),Normal (s::'b)⟩ ⇒∉{Stuck}›*) have "Γ p = Some bdy" by fact from "Γ"[rule_format, OF this] (*‹(Γ'::'d ⇒ ('b, 'd, 'c) com option) ((N::'a ⇒ 'd) (p::'a)) = Some (rename N (bdy::('b, 'a, 'c) com))›*) have bdy': "Γ' (N p) = Some (rename N bdy)" . from Call (*‹Γ p = Some bdy› ‹Γ⊢bdy ↓ Normal s› ‹Γ⊢ ⟨bdy,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N bdy ↓ Normal s› ‹Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}›*) have "Γ'⊢rename N bdy ↓ Normal s" by (auto simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) with bdy' (*‹Γ' (N p) = Some (rename N bdy)›*) have "Γ'⊢Call (N p) ↓ Normal s" by (auto intro: terminates.intros (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Skip ↓ Normal (?s::?'s)› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Basic (?f::?'s ⇒ ?'s) ↓ Normal (?s::?'s)› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Spec (?r::(?'s × ?'s) set) ↓ Normal (?s::?'s)› ‹⟦(?s::?'s) ∈ (?g::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard (?f::?'f) ?g ?c ↓ Normal ?s› ‹(?s::?'s) ∉ (?g::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢Guard (?f::?'f) ?g (?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s› ‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c::(?'s, ?'p, ?'f) com) ↓ Fault (?f::?'f)› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c₁::(?'s, ?'p, ?'f) com) ↓ Normal (?s::?'s); ∀s'::(?'s, ?'f) xstate. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢(?c₂::(?'s, ?'p, ?'f) com) ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c₁::(?'s, ?'p, ?'f) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ (?c₂::(?'s, ?'p, ?'f) com) ↓ Normal ?s› ‹⟦(?s::?'s) ∉ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c₂::(?'s, ?'p, ?'f) com) ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b (?c₁::(?'s, ?'p, ?'f) com) ?c₂ ↓ Normal ?s› ‹⟦(?s::?'s) ∈ (?b::?'s set); (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢(?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s; ∀s'::(?'s, ?'f) xstate. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹(?s::?'s) ∉ (?b::?'s set) ⟹ (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊢While ?b (?c::(?'s, ?'p, ?'f) com) ↓ Normal ?s› ‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option) (?p::?'p) = Some (?bdy::(?'s, ?'p, ?'f) com); ?Γ⊢?bdy ↓ Normal (?s::?'s)⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) thus "?case" (*goal: ‹Γ'⊢rename N (Call p) ↓ Normal s›*) by simp next (*goals: 1. ‹⋀p s. ⟦Γ p = None; Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Call p) ↓ Normal s› 2. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 3. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 4. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 5. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 6. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case (CallUndefined p s) (*‹Γ p = None› ‹Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}›*) have "Γ p = None" "Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}" (*goals: 1. ‹Γ p = None› 2. ‹Γ⊢ ⟨Call p,Normal s⟩ ⇒∉{Stuck}› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . hence False by (auto simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) thus "?case" (*goal: ‹Γ'⊢rename N (Call p) ↓ Normal s›*) by standard next (*goals: 1. ‹⋀c. Γ⊢ ⟨c,Stuck⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Stuck› 2. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 3. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 4. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 5. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Stuck (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨(c_::('b, 'a, 'c) com),Stuck⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N c_ ↓ Stuck›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀c s. ⟦Γ⊢c s ↓ Normal s; Γ⊢ ⟨c s,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c s) ↓ Normal s; Γ⊢ ⟨DynCom c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (DynCom c) ↓ Normal s› 2. ‹⋀s. Γ⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N Throw ↓ Normal s› 3. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 4. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case DynCom (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢(c_::'b ⇒ ('b, 'a, 'c) com) (s_::'b) ↓ Normal s_› ‹Γ⊢ ⟨c_ s_,Normal s_⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N (c_ s_) ↓ Normal s_› ‹Γ⊢ ⟨DynCom c_,Normal s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N (DynCom c_) ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*) simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) next (*goals: 1. ‹⋀s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Throw,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) Throw ↓ Normal s› 2. ‹⋀(c::('b, 'a, 'c) com) s::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c ↓ Abrupt s› 3. ‹⋀(c₁::('b, 'a, 'c) com) (s::'b) c₂::('b, 'a, 'c) com. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; ∀s'::'b. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Throw (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Throw,Normal (s_::'b)⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N Throw ↓ Normal s_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goals: 1. ‹⋀c s. Γ⊢ ⟨c,Abrupt s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c ↓ Abrupt s› 2. ‹⋀c₁ s c₂. ⟦Γ⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c₁ ↓ Normal s; ∀s'. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case Abrupt (*‹Γ⊢ ⟨c_,Abrupt s_⟩ ⇒∉{Stuck}›*) thus "?case" (*goal: ‹Γ'⊢rename N c_ ↓ Abrupt s_›*) by (fastforce intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) next (*goal: ‹⋀(c₁::('b, 'a, 'c) com) (s::'b) c₂::('b, 'a, 'c) com. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢c₁ ↓ Normal s; Γ⊢ ⟨c₁,Normal s⟩ ⇒∉{Stuck} ⟹ (Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢rename (N::'a ⇒ 'd) c₁ ↓ Normal s; ∀s'::'b. Γ⊢ ⟨c₁,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c₂ ↓ Normal s' ∧ (Γ⊢ ⟨c₂,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c₂ ↓ Normal s'); Γ⊢ ⟨Catch c₁ c₂,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ Γ'⊢rename N (Catch c₁ c₂) ↓ Normal s›*) case (Catch c1 s c2) (*‹Γ⊢c1 ↓ Normal s› ‹Γ⊢ ⟨c1,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c1 ↓ Normal s› ‹∀s'::'b::type. (Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option)⊢ ⟨(c1::('b::type, 'a::type, 'c::type) com),Normal (s::'b::type)⟩ ⇒ Abrupt s' ⟶ Γ⊢(c2::('b::type, 'a::type, 'c::type) com) ↓ Normal s' ∧ (Γ⊢ ⟨c2,Normal s'⟩ ⇒∉{Stuck} ⟶ (Γ'::'d::type ⇒ ('b::type, 'd::type, 'c::type) com option)⊢rename (N::'a::type ⇒ 'd::type) c2 ↓ Normal s')› ‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨Catch (c1::('b, 'a, 'c) com) (c2::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒∉{Stuck}›*) have noStuck: "Γ⊢ ⟨Catch c1 c2,Normal s⟩ ⇒∉{Stuck}" by fact hence "Γ⊢ ⟨c1,Normal s⟩ ⇒∉{Stuck}" by (fastforce simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) with Catch.hyps (*‹Γ⊢c1 ↓ Normal s› ‹Γ⊢ ⟨c1,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c1 ↓ Normal s› ‹∀s'. Γ⊢ ⟨c1,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c2 ↓ Normal s' ∧ (Γ⊢ ⟨c2,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c2 ↓ Normal s')›*) have "Γ'⊢rename N c1 ↓ Normal s" by auto moreover { fix t assume exec_rc1: "Γ'⊢ ⟨rename N c1,Normal s⟩ ⇒ Abrupt t" (*‹(Γ'::'d ⇒ ('b, 'd, 'c) com option)⊢ ⟨rename (N::'a ⇒ 'd) (c1::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ Abrupt (t::'b)›*) have "Γ'⊢rename N c2 ↓ Normal t" proof (-) (*goal: ‹Γ'⊢rename N c2 ↓ Normal t›*) from exec_rename_to_exec[OF Γ exec_rc1] (*‹rename N ?c = rename N c1 ⟹ ∃t'. Γ⊢ ⟨?c,Normal s⟩ ⇒ t' ∧ (t' = Stuck ∨ t' = Abrupt t)›*) obtain t' where exec_c: "Γ⊢ ⟨c1,Normal s⟩ ⇒ t'" and "(t' = Stuck ∨ t' = Abrupt t)" (*goal: ‹(⋀t'::('b, 'c) xstate. ⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢ ⟨(c1::('b, 'a, 'c) com),Normal (s::'b)⟩ ⇒ t'; t' = Stuck ∨ t' = Abrupt (t::'b)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto with noStuck (*‹Γ⊢ ⟨Catch c1 c2,Normal s⟩ ⇒∉{Stuck}›*) have t': "t'=Abrupt t" by (fastforce simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) with exec_c (*‹Γ⊢ ⟨c1,Normal s⟩ ⇒ t'›*) noStuck (*‹Γ⊢ ⟨Catch c1 c2,Normal s⟩ ⇒∉{Stuck}›*) have "Γ⊢ ⟨c2,Normal t⟩ ⇒∉{Stuck}" by (auto simp add: final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*) intro: exec.intros (*‹?Γ⊢ ⟨Skip,Normal ?s⟩ ⇒ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?g ⟹ ?Γ⊢ ⟨Guard ?f ?g ?c,Normal ?s⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨?c,Fault ?f⟩ ⇒ Fault ?f› ‹?Γ⊢ ⟨Basic ?f,Normal ?s⟩ ⇒ Normal (?f ?s)› ‹(?s, ?t) ∈ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Normal ?t› ‹∀t. (?s, t) ∉ ?r ⟹ ?Γ⊢ ⟨Spec ?r,Normal ?s⟩ ⇒ Stuck› ‹⟦?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨?c₂,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Seq ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∉ ?b; ?Γ⊢ ⟨?c₂,Normal ?s⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨Cond ?b ?c₁ ?c₂,Normal ?s⟩ ⇒ ?t› ‹⟦?s ∈ ?b; ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ ?s'; ?Γ⊢ ⟨While ?b ?c,?s'⟩ ⇒ ?t⟧ ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ ?t› ‹?s ∉ ?b ⟹ ?Γ⊢ ⟨While ?b ?c,Normal ?s⟩ ⇒ Normal ?s› and more 8 facts*)) with exec_c (*‹Γ⊢ ⟨c1,Normal s⟩ ⇒ t'›*) t' (*‹(t'::('b, 'c) xstate) = Abrupt (t::'b)›*) Catch.hyps (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢(c1::('b, 'a, 'c) com) ↓ Normal (s::'b)› ‹Γ⊢ ⟨c1,Normal s⟩ ⇒∉{Stuck} ⟹ Γ'⊢rename N c1 ↓ Normal s› ‹∀s'. Γ⊢ ⟨c1,Normal s⟩ ⇒ Abrupt s' ⟶ Γ⊢c2 ↓ Normal s' ∧ (Γ⊢ ⟨c2,Normal s'⟩ ⇒∉{Stuck} ⟶ Γ'⊢rename N c2 ↓ Normal s')›*) show "?thesis" (*goal: ‹Γ'⊢rename N c2 ↓ Normal t›*) by auto qed } ultimately show "?case" (*goal: ‹Γ'⊢rename N (Catch c1 c2) ↓ Normal s›*) by (auto intro: terminates.intros (*‹?Γ⊢Skip ↓ Normal ?s› ‹?Γ⊢Basic ?f ↓ Normal ?s› ‹?Γ⊢Spec ?r ↓ Normal ?s› ‹⟦?s ∈ ?g; ?Γ⊢?c ↓ Normal ?s⟧ ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?s ∉ ?g ⟹ ?Γ⊢Guard ?f ?g ?c ↓ Normal ?s› ‹?Γ⊢?c ↓ Fault ?f› ‹⟦?Γ⊢?c₁ ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c₁,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢?c₂ ↓ s'⟧ ⟹ ?Γ⊢Seq ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c₁ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∉ ?b; ?Γ⊢?c₂ ↓ Normal ?s⟧ ⟹ ?Γ⊢Cond ?b ?c₁ ?c₂ ↓ Normal ?s› ‹⟦?s ∈ ?b; ?Γ⊢?c ↓ Normal ?s; ∀s'. ?Γ⊢ ⟨?c,Normal ?s⟩ ⇒ s' ⟶ ?Γ⊢While ?b ?c ↓ s'⟧ ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹?s ∉ ?b ⟹ ?Γ⊢While ?b ?c ↓ Normal ?s› ‹⟦?Γ ?p = Some ?bdy; ?Γ⊢?bdy ↓ Normal ?s⟧ ⟹ ?Γ⊢Call ?p ↓ Normal ?s› and more 6 facts*)) qed lemma validt_to_validt_rename: assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes valid: "Γ⊨⇩t⇘/F⇙ P c Q,A" shows "Γ'⊨⇩t⇘/F⇙ P (rename N c) Q,A" proof (-) (*goal: ‹Γ'⊨⇩t⇘/F⇙ P rename N c Q,A›*) from valid (*‹Γ⊨⇩t⇘/F⇙ P c Q,A›*) have "Γ'⊨⇘/F⇙ P (rename N c) Q,A" by (auto intro: valid_to_valid_rename [OF Γ] (*‹Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ⟹ Γ'⊨⇘/?F⇙ ?P rename N ?c ?Q,?A›*) simp add: validt_def (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s∈Normal ` ?P. ?Γ⊢?c ↓ s)›*)) moreover { fix s assume "s ∈ P" (*‹(s::'b) ∈ (P::'b set)›*) with valid (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option)⊨⇩t⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set)›*) obtain "Γ⊢c ↓ (Normal s)" "Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck}" (*goal: ‹(⟦(Γ::'a ⇒ ('b, 'a, 'c) com option)⊢(c::('b, 'a, 'c) com) ↓ Normal (s::'b); Γ⊢ ⟨c,Normal s⟩ ⇒∉{Stuck}⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: validt_def (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s∈Normal ` ?P. ?Γ⊢?c ↓ s)›*) valid_def (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ ∀s t. ?Γ⊢ ⟨?c,s⟩ ⇒ t ⟶ s ∈ Normal ` ?P ⟶ t ∉ Fault ` ?F ⟶ t ∈ Normal ` ?Q ∪ Abrupt ` ?A›*) final_notin_def (*‹?Γ⊢ ⟨?c,?s⟩ ⇒∉?T = (∀t. ?Γ⊢ ⟨?c,?s⟩ ⇒ t ⟶ t ∉ ?T)›*)) from terminates_to_terminates_rename[OF Γ this] (*‹Γ'⊢rename N c ↓ Normal s›*) have "Γ'⊢rename N c ↓ Normal s" . } ultimately show "?thesis" (*goal: ‹Γ'⊨⇩t⇘/F⇙ P rename N c Q,A›*) by (simp add: validt_def (*‹(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option)⊨⇩t⇘/(?F::?'f set)⇙ (?P::?'s set) (?c::(?'s, ?'p, ?'f) com) (?Q::?'s set),(?A::?'s set) ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s::(?'s, ?'f) xstate∈Normal ` ?P. ?Γ⊢?c ↓ s)›*)) qed lemma hoaret_to_hoaret_rename: assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes deriv: "Γ,{}⊢⇩t⇘/F⇙ P c Q,A" shows "Γ',{}⊢⇩t⇘/F⇙ P (rename N c) Q,A" apply (rule hoaret_complete (*‹(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option)⊨⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set) ⟹ ?Γ,{}⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹(Γ'::'d ⇒ ('b, 'd, 'c) com option),{}⊢⇩t⇘/(F::'c set)⇙ (P::'b set) rename (N::'a ⇒ 'd) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set)›*) apply (insert hoaret_sound [OF deriv] (*‹(Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option),{}⊨⇩t⇘/(F::'c::type set)⇙ (P::'b::type set) (c::('b::type, 'a::type, 'c::type) com) (Q::'b::type set),(A::'b::type set)›*)) (*goal: ‹Γ'⊨⇩t⇘/F⇙ P rename N c Q,A›*) apply (rule validt_to_validt_rename (*‹⟦∀p bdy. ?Γ p = Some bdy ⟶ ?Γ' (?N p) = Some (rename ?N bdy); ?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A⟧ ⟹ ?Γ'⊨⇩t⇘/?F⇙ ?P rename ?N ?c ?Q,?A›*)) (*goals: 1. ‹Γ,{}⊨⇩t⇘/F⇙ P c Q,A ⟹ ∀p bdy. ?Γ4 p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)› 2. ‹Γ,{}⊨⇩t⇘/F⇙ P c Q,A ⟹ ?Γ4⊨⇩t⇘/F⇙ P c Q,A› discuss goal 1*) apply (rule Γ (*‹∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)›*)) (*discuss goal 2*) apply (simp add: cvalidt_def (*‹?Γ,?Θ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇩t⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*proven 2 subgoals*) . lemma hoaret_to_hoaret_rename': assumes Γ: "∀p bdy. Γ p = Some bdy ⟶ Γ' (N p) = Some (rename N bdy)" assumes deriv: "∀Z. Γ,{}⊢⇩t⇘/F⇙ (P Z) c (Q Z),(A Z)" shows "∀Z. Γ',{}⊢⇩t⇘/F⇙ (P Z) (rename N c) (Q Z),(A Z)" apply rule (*goal: ‹∀Z. Γ',{}⊢⇩t⇘/F⇙ (P Z) rename N c (Q Z),(A Z)›*) apply (rule hoaret_to_hoaret_rename [OF Γ] (*‹Γ,{}⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A ⟹ Γ',{}⊢⇩t⇘/?F⇙ ?P rename N ?c ?Q,?A›*)) (*goal: ‹⋀Z::'e. (Γ'::'d ⇒ ('b, 'd, 'c) com option),{}⊢⇩t⇘/(F::'c set)⇙ ((P::'e ⇒ 'b set) Z) rename (N::'a ⇒ 'd) (c::('b, 'a, 'c) com) ((Q::'e ⇒ 'b set) Z),((A::'e ⇒ 'b set) Z)›*) by (rule deriv[rule_format] (*‹Γ,{}⊢⇩t⇘/F⇙ (P ?Z) c (Q ?Z),(A ?Z)›*)) lemma lift⇩c_whileAnno [simp]: "lift⇩c prj inject (whileAnno b I V c) = whileAnno (lift⇩s prj b) (lift⇩s prj I) (lift⇩r prj inject V) (lift⇩c prj inject c)" by (simp add: whileAnno_def (*‹whileAnno ?b ?I ?V ?c = While ?b ?c›*)) lemma lift⇩c_block [simp]: "lift⇩c prj inject (block init bdy return c) = block (lift⇩f prj inject init) (lift⇩c prj inject bdy) (λs. (lift⇩f prj inject (return (prj s)))) (λs t. lift⇩c prj inject (c (prj s) (prj t)))" by (simp add: block_def (*‹block (?init::?'s ⇒ ?'s) (?bdy::(?'s, ?'p, ?'f) com) (?return::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = block_exn ?init ?bdy ?return (λ(s::?'s) t::?'s. s) ?c›*) block_exn_def (*‹block_exn (?init::?'s ⇒ ?'s) (?bdy::(?'s, ?'p, ?'f) com) (?return::?'s ⇒ ?'s ⇒ ?'s) (?result_exn::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = DynCom (λs::?'s. Seq (Catch (Seq (Basic ?init) ?bdy) (Seq (Basic (λt::?'s. ?result_exn (?return s t) t)) Throw)) (DynCom (λt::?'s. Seq (Basic (?return s)) (?c s t))))›*)) (* lemma lift⇩c_block [simp]: "lift⇩c prj inject (block init bdy return c) = block (lift⇩f prj inject init) (lift⇩c prj inject bdy) (λs t. inject s (return (prj s) (prj t))) (λs t. lift⇩c prj inject (c (prj s) (prj t)))" apply (simp add: block_def) apply (simp add: lift⇩f_def) *) lemma lift⇩c_call [simp]: "lift⇩c prj inject (call init p return c) = call (lift⇩f prj inject init) p (λs. (lift⇩f prj inject (return (prj s)))) (λs t. lift⇩c prj inject (c (prj s) (prj t)))" by (simp add: call_def (*‹call (?init::?'s ⇒ ?'s) (?p::?'p) (?return::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = block ?init (Call ?p) ?return ?c›*) lift⇩c_block (*‹lift⇩c (?prj::?'a ⇒ ?'d) (?inject::?'a ⇒ ?'d ⇒ ?'a) (block (?init::?'d ⇒ ?'d) (?bdy::(?'d, ?'b, ?'c) com) (?return::?'d ⇒ ?'d ⇒ ?'d) (?c::?'d ⇒ ?'d ⇒ (?'d, ?'b, ?'c) com)) = block (lift⇩f ?prj ?inject ?init) (lift⇩c ?prj ?inject ?bdy) (λs::?'a. lift⇩f ?prj ?inject (?return (?prj s))) (λ(s::?'a) t::?'a. lift⇩c ?prj ?inject (?c (?prj s) (?prj t)))›*)) lemma rename_whileAnno [simp]: "rename h (whileAnno b I V c) = whileAnno b I V (rename h c)" by (simp add: whileAnno_def (*‹whileAnno ?b ?I ?V ?c = While ?b ?c›*)) lemma rename_block [simp]: "rename h (block init bdy return c) = block init (rename h bdy) return (λs t. rename h (c s t))" by (simp add: block_def (*‹block ?init ?bdy ?return ?c = block_exn ?init ?bdy ?return (λs t. s) ?c›*) block_exn_def (*‹block_exn ?init ?bdy ?return ?result_exn ?c = DynCom (λs. Seq (Catch (Seq (Basic ?init) ?bdy) (Seq (Basic (λt. ?result_exn (?return s t) t)) Throw)) (DynCom (λt. Seq (Basic (?return s)) (?c s t))))›*)) lemma rename_call [simp]: "rename h (call init p return c) = call init (h p) return (λs t. rename h (c s t))" by (simp add: call_def (*‹call ?init ?p ?return ?c = block ?init (Call ?p) ?return ?c›*)) end
{ "path": "afp-2025-02-12/thys/Simpl/ex/Compose.thy", "repo": "afp-2025-02-12", "sha": "a049c3dd58de52126b4009db71c58a56e1445721d9e97372c2aad84e8959dbb2" }
section‹The First Monotonicity Calculus› theory Mcalc imports Mono begin context ProblemIk begin subsection‹Naked variables› fun nvT where "nvT (Var x) = {x}" | "nvT (Fn f Tl) = {}" fun nvA where "nvA (Eq T1 T2) = nvT T1 ∪ nvT T2" | "nvA (Pr p Tl) = {}" fun nvL where "nvL (Pos at) = nvA at" | "nvL (Neg at) = {}" definition "nvC c ≡ ⋃ (set (map nvL c))" definition "nvPB ≡ ⋃ c ∈ Φ. nvC c" lemma nvT_vars[simp]: "x ∈ nvT T ⟹ x ∈ vars T" apply (induct T) (*goals: 1. ‹⋀xa::Preliminaries.var. (x::Preliminaries.var) ∈ nvT (Var xa) ⟹ x ∈ vars (Var xa)› 2. ‹⋀(f::'a::type) Tl::'a::type trm list. ⟦list_all (λa::'a::type trm. (x::Preliminaries.var) ∈ nvT a ⟶ x ∈ vars a) Tl; x ∈ nvT (Fn f Tl)⟧ ⟹ x ∈ vars (Fn f Tl)› discuss goal 1*) apply ((auto split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . lemma nvA_varsA[simp]: "x ∈ nvA at ⟹ x ∈ varsA at" apply (cases at) (*goals: 1. ‹⋀x11 x12. ⟦x ∈ nvA at; at = Eq x11 x12⟧ ⟹ x ∈ varsA at› 2. ‹⋀x21 x22. ⟦x ∈ nvA at; at = Pr x21 x22⟧ ⟹ x ∈ varsA at› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma nvL_varsL[simp]: "x ∈ nvL l ⟹ x ∈ varsL l" apply (cases l) (*goals: 1. ‹⋀x1::('a, 'b) atm. ⟦(x::Preliminaries.var) ∈ nvL (l::('a, 'b) lit); l = Pos x1⟧ ⟹ x ∈ varsL l› 2. ‹⋀x2::('a, 'b) atm. ⟦(x::Preliminaries.var) ∈ nvL (l::('a, 'b) lit); l = Neg x2⟧ ⟹ x ∈ varsL l› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma nvC_varsC[simp]: "x ∈ nvC c ⟹ x ∈ varsC c" unfolding varsC_def nvC_def (*goal: ‹x ∈ ⋃ (set (map nvL c)) ⟹ x ∈ ⋃ (set (map varsL c))›*) apply (induct c) (*goals: 1. ‹x ∈ ⋃ (set (map nvL [])) ⟹ x ∈ ⋃ (set (map varsL []))› 2. ‹⋀a c. ⟦x ∈ ⋃ (set (map nvL c)) ⟹ x ∈ ⋃ (set (map varsL c)); x ∈ ⋃ (set (map nvL (a # c)))⟧ ⟹ x ∈ ⋃ (set (map varsL (a # c)))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma nvPB_varsPB[simp]: "x ∈ nvPB ⟹ x ∈ varsPB Φ" unfolding varsPB_def nvPB_def (*goal: ‹x ∈ ⋃ (nvC ` Φ) ⟹ x ∈ ⋃ {varsC c |c. c ∈ Φ}›*) by auto subsection‹The calculus› inductive mcalc (infix "⊢" 40) where [simp]: "infTp σ ⟹ σ ⊢ c" |[simp]: "(∀ x ∈ nvC c. tpOfV x ≠ σ) ⟹ σ ⊢ c" lemma mcalc_iff: "σ ⊢ c ⟷ infTp σ ∨ (∀ x ∈ nvC c. tpOfV x ≠ σ)" unfolding mcalc.simps (*goal: ‹((∃(σ'::'tp) ca::('a, 'b) lit list. (σ::'tp) = σ' ∧ (c::('a, 'b) lit list) = ca ∧ (infTp::'tp ⇒ bool) σ') ∨ (∃(ca::('a, 'b) lit list) σ'::'tp. σ = σ' ∧ c = ca ∧ (∀x::Preliminaries.var∈nvC ca. tpOfV x ≠ σ'))) = (infTp σ ∨ (∀x::Preliminaries.var∈nvC c. tpOfV x ≠ σ))›*) by simp end (* context ProblemIk *) locale ProblemIkMcalc = ProblemIk wtFsym wtPsym arOf resOf parOf Φ infTp for wtFsym :: "'fsym ⇒ bool" and wtPsym :: "'psym ⇒ bool" and arOf :: "'fsym ⇒ 'tp list" and resOf and parOf and Φ and infTp + assumes mcalc: "⋀ σ c. c ∈ Φ ⟹ σ ⊢ c" locale ModelIkMcalc = ModelIk wtFsym wtPsym arOf resOf parOf Φ infTp intT intF intP + ProblemIkMcalc wtFsym wtPsym arOf resOf parOf Φ infTp for wtFsym :: "'fsym ⇒ bool" and wtPsym :: "'psym ⇒ bool" and arOf :: "'fsym ⇒ 'tp list" and resOf and parOf and Φ and infTp and intT and intF and intP subsection‹Extension of a structure to an infinite structure by adding indistinguishable elements› context ModelIkMcalc begin text‹The projection from univ to a structure:› definition proj where "proj σ a ≡ if intT σ a then a else pickT σ" lemma intT_proj[simp]: "intT σ (proj σ a)" unfolding proj_def (*goal: ‹intT σ (if intT σ a then a else pickT σ)›*) using pickT (*‹intT ?σ (pickT ?σ)›*) by auto lemma proj_id[simp]: "intT σ a ⟹ proj σ a = a" unfolding proj_def (*goal: ‹intT σ a ⟹ (if intT σ a then a else pickT σ) = a›*) by auto lemma surj_proj: assumes "intT σ a" shows "∃ b. proj σ b = a" using assms (*‹intT σ a›*) apply (intro exI[of _ a] (*‹?P a ⟹ ∃x. ?P x›*)) (*goal: ‹∃b. proj σ b = a›*) by simp definition "I_intT σ (a::univ) ≡ infTp σ ⟶ intT σ a" definition "I_intF f al ≡ intF f (map2 proj (arOf f) al)" definition "I_intP p al ≡ intP p (map2 proj (parOf p) al)" lemma not_infTp_I_intT[simp]: "¬ infTp σ ⟹ I_intT σ a" unfolding I_intT_def (*goal: ‹¬ infTp σ ⟹ infTp σ ⟶ intT σ a›*) by simp lemma infTp_I_intT[simp]: "infTp σ ⟹ I_intT σ a = intT σ a" unfolding I_intT_def (*goal: ‹infTp σ ⟹ (infTp σ ⟶ intT σ a) = intT σ a›*) by simp lemma NE_I_intT: "NE (I_intT σ)" using NE_intT (*‹∃a::univ. (intT::'tp ⇒ univ ⇒ bool) (?σ::'tp) a›*) apply (cases "infTp σ") (*goals: 1. ‹⟦⋀σ::'tp. ∃a::univ. (intT::'tp ⇒ univ ⇒ bool) σ a; (infTp::'tp ⇒ bool) (σ::'tp)⟧ ⟹ ∃a::univ. I_intT σ a› 2. ‹⟦⋀σ::'tp. ∃a::univ. (intT::'tp ⇒ univ ⇒ bool) σ a; ¬ (infTp::'tp ⇒ bool) (σ::'tp)⟧ ⟹ ∃a::univ. I_intT σ a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma I_intF: assumes f: "wtFsym f" and al: "list_all2 I_intT (arOf f) al" shows "I_intT (resOf f) (I_intF f al)" unfolding I_intT_def I_intF_def (*goal: ‹(infTp::'tp ⇒ bool) ((resOf::'fsym ⇒ 'tp) (f::'fsym)) ⟶ (intT::'tp ⇒ univ ⇒ bool) (resOf f) ((intF::'fsym ⇒ univ list ⇒ univ) f (map2 proj ((arOf::'fsym ⇒ 'tp list) f) (al::univ list)))›*) apply safe (*goal: ‹infTp (resOf f) ⟶ intT (resOf f) (intF f (map2 proj (arOf f) al))›*) apply (rule intF[OF f] (*‹list_all2 intT (arOf f) ?al ⟹ intT (resOf f) (intF f ?al)›*)) (*goal: ‹(infTp::'tp ⇒ bool) ((resOf::'fsym ⇒ 'tp) (f::'fsym)) ⟹ (intT::'tp ⇒ univ ⇒ bool) (resOf f) ((intF::'fsym ⇒ univ list ⇒ univ) f (map2 proj ((arOf::'fsym ⇒ 'tp list) f) (al::univ list)))›*) using al (*‹list_all2 I_intT (arOf f) al›*) unfolding list_all2_length (*goal: ‹infTp (resOf f) ⟹ length (arOf f) = length (map2 proj (arOf f) al) ∧ (∀i<length (arOf f). intT (arOf f ! i) (map2 proj (arOf f) al ! i))›*) by auto lemma Tstruct_I_intT: "Tstruct I_intT" apply standard (*goal: ‹CM.Tstruct I_intT›*) by (rule NE_I_intT (*‹∃a::univ. I_intT (?σ::'tp) a›*)) lemma inf_I_intT: "infinite {a. I_intT σ a}" apply (cases "infTp σ") (*goals: 1. ‹infTp σ ⟹ infinite {a. I_intT σ a}› 2. ‹¬ infTp σ ⟹ infinite {a. I_intT σ a}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma InfStruct: "IInfStruct I_intT I_intF I_intP" apply standard (*goal: ‹IInfStruct I_intT I_intF I_intP›*) using NE_I_intT (*‹∃a. I_intT ?σ a›*) I_intF (*‹⟦wtFsym ?f; list_all2 I_intT (arOf ?f) ?al⟧ ⟹ I_intT (resOf ?f) (I_intF ?f ?al)›*) Tstruct_I_intT (*‹CM.Tstruct I_intT›*) inf_I_intT (*‹infinite {a. I_intT ?σ a}›*) apply - (*goals: 1. ‹⋀σ. ⟦⋀σ. ∃a. I_intT σ a; ⋀f al. ⟦wtFsym f; list_all2 I_intT (arOf f) al⟧ ⟹ I_intT (resOf f) (I_intF f al); CM.Tstruct I_intT; ⋀σ. infinite {a. I_intT σ a}⟧ ⟹ ∃a. I_intT σ a› 2. ‹⋀f al. ⟦wtFsym f; list_all2 I_intT (arOf f) al; ⋀σ. ∃a. I_intT σ a; ⋀f al. ⟦wtFsym f; list_all2 I_intT (arOf f) al⟧ ⟹ I_intT (resOf f) (I_intF f al); CM.Tstruct I_intT; ⋀σ. infinite {a. I_intT σ a}⟧ ⟹ I_intT (resOf f) (I_intF f al)› 3. ‹⟦⋀σ. ∃a. I_intT σ a; ⋀f al. ⟦wtFsym f; list_all2 I_intT (arOf f) al⟧ ⟹ I_intT (resOf f) (I_intF f al); CM.Tstruct I_intT; ⋀σ. infinite {a. I_intT σ a}⟧ ⟹ I_intP = I_intP› 4. ‹⋀σ. ⟦⋀σ. ∃a. I_intT σ a; ⋀f al. ⟦wtFsym f; list_all2 I_intT (arOf f) al⟧ ⟹ I_intT (resOf f) (I_intF f al); CM.Tstruct I_intT; ⋀σ. infinite {a. I_intT σ a}⟧ ⟹ infinite {a. I_intT σ a}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . end (* context ModelIkMcalc *) sublocale ModelIkMcalc < InfStruct where intT = I_intT and intF = I_intF and intP = I_intP using InfStruct (*‹IInfStruct I_intT I_intF I_intP›*) . subsection‹The soundness of the calculus› text‹In what follows, ``Ik'' stands for the original (augmented with infiniteness-knowledge) and ``I'' for the infinite structure constructed from it through the above sublocale statement.› context ModelIkMcalc begin text‹The environment translation along the projection:› definition "transE ξ ≡ λ x. proj (tpOfV x) (ξ x)" lemma transE[simp]: "transE ξ x = proj (tpOfV x) (ξ x)" sorry lemma wtE_transE[simp]: "I.wtE ξ ⟹ Ik.wtE (transE ξ)" unfolding Ik.wtE_def I.wtE_def transE_def (*goal: ‹∀x::Preliminaries.var. I_intT (tpOfV x) ((ξ::Preliminaries.var ⇒ univ) x) ⟹ ∀x::Preliminaries.var. (intT::'tp ⇒ univ ⇒ bool) (tpOfV x) (proj (tpOfV x) (ξ x))›*) by auto abbreviation "Ik_intT ≡ intT" abbreviation "Ik_intF ≡ intF" abbreviation "Ik_intP ≡ intP" lemma Ik_intT_int: assumes wt: "Ik.wt T" and ξ: "I.wtE ξ" and snv: "⋀ σ. infTp σ ∨ (∀ x ∈ nvT T. tpOfV x ≠ σ)" shows "Ik_intT (tpOf T) (I.int ξ T)" proof (cases "∃ x. T = Var x") (*goals: 1. ‹∃x. T = Var x ⟹ Ik_intT (tpOf T) (I.int ξ T)› 2. ‹∄x. T = Var x ⟹ Ik_intT (tpOf T) (I.int ξ T)›*) case True (*‹∃x. T = Var x›*) then obtain x where T: "T = Var x" (*goal: ‹(⋀x. T = Var x ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹Ik_intT (tpOf T) (I.int ξ T)›*) proof (cases "infTp (tpOf T)") (*goals: 1. ‹infTp (tpOf T) ⟹ Ik_intT (tpOf T) (I.int ξ T)› 2. ‹¬ infTp (tpOf T) ⟹ Ik_intT (tpOf T) (I.int ξ T)›*) case True (*‹(infTp::'tp ⇒ bool) (tpOf (T::'fsym trm))›*) thus "?thesis" (*goal: ‹Ik_intT (tpOf T) (I.int ξ T)›*) using T (*‹T = Var x›*) using wtE_transE[OF ξ] (*‹Ik.wtE (transE ξ)›*) by (metis I.wt_int (*‹⟦I.wtE ?ξ; wt ?T⟧ ⟹ I_intT (tpOf ?T) (I.int ?ξ ?T)›*) I_intT_def (*‹I_intT ?σ ?a ≡ infTp ?σ ⟶ Ik_intT ?σ ?a›*) ξ (*‹I.wtE ξ›*) wt (*‹wt T›*)) next (*goal: ‹¬ infTp (tpOf T) ⟹ Ik_intT (tpOf T) (I.int ξ T)›*) case False (*‹¬ infTp (tpOf T)›*) hence "∀ x ∈ nvT T. tpOfV x ≠ tpOf T" using snv (*‹infTp ?σ2 ∨ (∀x∈nvT T. tpOfV x ≠ ?σ2)›*) by auto hence "Ik.full (tpOf T)" using T (*‹T = Var x›*) apply (cases T) (*goals: 1. ‹⋀x1. ⟦∀x∈nvT T. tpOfV x ≠ tpOf T; T = Var x; T = Var x1⟧ ⟹ Ik.full (tpOf T)› 2. ‹⋀x21 x22. ⟦∀x∈nvT T. tpOfV x ≠ tpOf T; T = Var x; T = Fn x21 x22⟧ ⟹ Ik.full (tpOf T)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹Ik_intT (tpOf T) (I.int ξ T)›*) unfolding Ik.full_def (*goal: ‹Ik_intT (tpOf T) (I.int ξ T)›*) by simp qed next (*goal: ‹∄x. T = Var x ⟹ Ik_intT (tpOf T) (I.int ξ T)›*) case False (*‹∄x. T = Var x›*) hence nonVar: "¬ (∃ x. T = Var x)" apply (cases T) (*goals: 1. ‹⋀x1. ⟦∄x. T = Var x; T = Var x1⟧ ⟹ ∄x. T = Var x› 2. ‹⋀x21 x22. ⟦∄x. T = Var x; T = Fn x21 x22⟧ ⟹ ∄x. T = Var x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹Ik_intT (tpOf T) (I.int ξ T)›*) using nonVar (*‹∄x. T = Var x›*) wt (*‹wt T›*) apply (induct T, force) (*goal: ‹Ik_intT (tpOf T) (I.int ξ T)›*) unfolding I_intF_def tpOf.simps int.simps (*goal: ‹⋀f Tl. ⟦list_all (λa. (∄x. a = Var x) ⟶ (∄x. a = Var x) ⟶ wt a ⟶ Ik_intT (tpOf a) (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ a)) Tl; ∄x. Fn f Tl = Var x; ∄x. Fn f Tl = Var x; wt (Fn f Tl)⟧ ⟹ Ik_intT (resOf f) (Ik_intF f (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl)))›*) apply (rule Ik.intF (*‹⟦wtFsym ?f; list_all2 Ik_intT (arOf ?f) ?al⟧ ⟹ Ik_intT (resOf ?f) (Ik_intF ?f ?al)›*)) (*goals: 1. ‹⋀f Tl. ⟦list_all (λa. (∄x. a = Var x) ⟶ (∄x. a = Var x) ⟶ wt a ⟶ Ik_intT (tpOf a) (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ a)) Tl; ∄x. Fn f Tl = Var x; ∄x. Fn f Tl = Var x; wt (Fn f Tl)⟧ ⟹ wtFsym f› 2. ‹⋀f Tl. ⟦list_all (λa. (∄x. a = Var x) ⟶ (∄x. a = Var x) ⟶ wt a ⟶ Ik_intT (tpOf a) (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ a)) Tl; ∄x. Fn f Tl = Var x; ∄x. Fn f Tl = Var x; wt (Fn f Tl)⟧ ⟹ list_all2 Ik_intT (arOf f) (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl))› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule listAll2_map2I (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?R (?xs ! i) (?f (?xs ! i) (?ys ! i))⟧ ⟹ list_all2 ?R ?xs (map2 ?f ?xs ?ys)›*)) (*goals: 1. ‹⋀f Tl. ⟦list_all (λa. (∄x. a = Var x) ⟶ (∄x. a = Var x) ⟶ wt a ⟶ Ik_intT (tpOf a) (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ a)) Tl; ∄x. Fn f Tl = Var x; ∄x. Fn f Tl = Var x; wt (Fn f Tl)⟧ ⟹ length (arOf f) = length (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl)› 2. ‹⋀f Tl i. ⟦list_all (λa. (∄x. a = Var x) ⟶ (∄x. a = Var x) ⟶ wt a ⟶ Ik_intT (tpOf a) (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ a)) Tl; ∄x. Fn f Tl = Var x; ∄x. Fn f Tl = Var x; wt (Fn f Tl); i < length (arOf f)⟧ ⟹ Ik_intT (arOf f ! i) (proj (arOf f ! i) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl ! i))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed lemma int_transE_proj: assumes wt: "Ik.wt T" shows "Ik.int (transE ξ) T = proj (tpOf T) (I.int ξ T)" using wt (*‹wt T›*) proof (induct T) (*goals: 1. ‹⋀x. wt (Var x) ⟹ Ik.int (transE ξ) (Var x) = proj (tpOf (Var x)) (I.int ξ (Var x))› 2. ‹⋀f Tl. ⟦list_all (λa. wt a ⟶ Ik.int (transE ξ) a = proj (tpOf a) (I.int ξ a)) Tl; wt (Fn f Tl)⟧ ⟹ Ik.int (transE ξ) (Fn f Tl) = proj (tpOf (Fn f Tl)) (I.int ξ (Fn f Tl))›*) case (Fn f Tl) (*‹list_all (λa. wt a ⟶ Ik.int (transE ξ) a = proj (tpOf a) (I.int ξ a)) Tl› ‹wt (Fn f Tl)›*) have 0: "Ik_intT (resOf f) (I_intF f (map (int ξ) Tl))" (is "Ik_intT ?σ ?a") unfolding I_intF_def (*goal: ‹Ik_intT (resOf f) (Ik_intF f (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl)))›*) apply (rule Ik.intF (*‹⟦wtFsym ?f; list_all2 Ik_intT (arOf ?f) ?al⟧ ⟹ Ik_intT (resOf ?f) (Ik_intF ?f ?al)›*)) (*goal: ‹Ik_intT (resOf f) (Ik_intF f (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl)))›*) using Fn (*‹list_all (λa::'fsym::type trm. wt a ⟶ Ik.int (transE (ξ::Preliminaries.var ⇒ univ)) a = proj (tpOf a) (I.int ξ a)) (Tl::'fsym::type trm list)› ‹wt (Fn (f::'fsym) (Tl::'fsym trm list))›*) unfolding list_all2_length list_all_iff (*goals: 1. ‹wtFsym f› 2. ‹length (arOf f) = length (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl)) ∧ (∀i<length (arOf f). Ik_intT (arOf f ! i) (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl) ! i))›*) apply - (*goals: 1. ‹⟦∀a∈set Tl. wt a ⟶ Ik.int (transE ξ) a = proj (tpOf a) (I.int ξ a); wt (Fn f Tl)⟧ ⟹ wtFsym f› 2. ‹⟦∀a∈set Tl. wt a ⟶ Ik.int (transE ξ) a = proj (tpOf a) (I.int ξ a); wt (Fn f Tl)⟧ ⟹ length (arOf f) = length (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl)) ∧ (∀i<length (arOf f). Ik_intT (arOf f ! i) (map2 proj (arOf f) (map (Struct.int (λf al. Ik_intF f (map2 proj (arOf f) al)) ξ) Tl) ! i))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have 1: "proj ?σ ?a = ?a" using proj_id[OF 0] (*‹proj (resOf f) (I_intF f (map (I.int ξ) Tl)) = I_intF f (map (I.int ξ) Tl)›*) . show "?case" (*goal: ‹Ik.int (transE (ξ::Preliminaries.var ⇒ univ)) (Fn (f::'fsym::type) (Tl::'fsym::type trm list)) = proj (tpOf (Fn f Tl)) (I.int ξ (Fn f Tl))›*) using [unfold_abs_def = false] (*‹TERM _›*) unfolding Ik.int.simps int.simps tpOf.simps "1" (*goal: ‹Ik_intF f (map (Ik.int (transE ξ)) Tl) = I_intF f (map (I.int ξ) Tl)›*) unfolding I_intF_def (*goal: ‹Ik_intF f (map (Ik.int (transE ξ)) Tl) = Ik_intF f (map2 proj (arOf f) (map (I.int ξ) Tl))›*) apply (rule arg_cong[of _ _ "intF f"] (*‹?x = ?y ⟹ Ik_intF f ?x = Ik_intF f ?y›*)) (*goal: ‹Ik_intF f (map (Ik.int (transE ξ)) Tl) = Ik_intF f (map2 proj (arOf f) (map (I.int ξ) Tl))›*) proof (rule nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*)) (*goals: 1. ‹length (map (Ik.int (transE ξ)) Tl) = length (map2 proj (arOf f) (map (I.int ξ) Tl))› 2. ‹⋀i. i < length (map (Ik.int (transE ξ)) Tl) ⟹ map (Ik.int (transE ξ)) Tl ! i = map2 proj (arOf f) (map (I.int ξ) Tl) ! i›*) have l[simp]: "length (arOf f) = length Tl" using Fn (*‹list_all (λa. wt a ⟶ Ik.int (transE ξ) a = proj (tpOf a) (I.int ξ a)) Tl› ‹wt (Fn (f::'fsym) (Tl::'fsym trm list))›*) by simp fix i assume "i < length (map (Ik.int (transE ξ)) Tl)" (*‹(i::nat) < length (map (Ik.int (transE (ξ::Preliminaries.var ⇒ univ))) (Tl::'fsym trm list))›*) hence i[simp]: "i < length Tl" by simp have 0: "arOf f ! i = tpOf (Tl ! i)" using Fn (*‹list_all (λa::'fsym trm. wt a ⟶ Ik.int (transE (ξ::Preliminaries.var ⇒ univ)) a = proj (tpOf a) (I.int ξ a)) (Tl::'fsym trm list)› ‹wt (Fn f Tl)›*) by simp have [simp]: "Ik.int (transE ξ) (Tl ! i) = proj (arOf f ! i) (I.int ξ (Tl ! i))" unfolding "0" (*goal: ‹Ik.int (transE (ξ::Preliminaries.var ⇒ univ)) ((Tl::'fsym::type trm list) ! (i::nat)) = proj (tpOf (Tl ! i)) (I.int ξ (Tl ! i))›*) using Fn (*‹list_all (λa::'fsym trm. wt a ⟶ Ik.int (transE (ξ::Preliminaries.var ⇒ univ)) a = proj (tpOf a) (I.int ξ a)) (Tl::'fsym trm list)› ‹wt (Fn f Tl)›*) by (auto simp: list_all_length (*‹list_all ?P ?xs = (∀n<length ?xs. ?P (?xs ! n))›*) transE_def (*‹transE ?ξ ≡ λx. proj (tpOfV x) (?ξ x)›*)) show "map (Ik.int (transE ξ)) Tl ! i = map2 proj (arOf f) (map (I.int ξ) Tl) ! i" using Fn (*‹list_all (λa::'fsym trm. wt a ⟶ Ik.int (transE (ξ::Preliminaries.var ⇒ univ)) a = proj (tpOf a) (I.int ξ a)) (Tl::'fsym trm list)› ‹wt (Fn (f::'fsym::type) (Tl::'fsym::type trm list))›*) unfolding list_all_length (*goal: ‹map (Ik.int (transE ξ)) Tl ! i = map2 proj (arOf f) (map (I.int ξ) Tl) ! i›*) by simp qed (use Fn in simp) (*solved the remaining goal: ‹length (map (Ik.int (transE ξ)) Tl) = length (map2 proj (arOf f) (map (I.int ξ) Tl))›*) qed (simp) (*solved the remaining goal: ‹⋀x. wt (Var x) ⟹ Ik.int (transE ξ) (Var x) = proj (tpOf (Var x)) (I.int ξ (Var x))›*) lemma int_transE_snv[simp]: assumes wt: "Ik.wt T" and ξ: "I.wtE ξ" and snv: "⋀ σ. infTp σ ∨ (∀ x ∈ nvT T. tpOfV x ≠ σ)" shows "Ik.int (transE ξ) T = I.int ξ T" unfolding int_transE_proj[OF wt] (*goal: ‹proj (tpOf T) (I.int ξ T) = I.int ξ T›*) apply (rule proj_id (*‹Ik_intT ?σ ?a ⟹ proj ?σ ?a = ?a›*)) (*goal: ‹proj (tpOf T) (I.int ξ T) = I.int ξ T›*) using Ik_intT_int[OF wt ξ snv] (*‹Ik_intT (tpOf T) (I.int ξ T)›*) . lemma int_transE_Fn: assumes wt: "list_all wt Tl" and f: "wtFsym f" and ξ: "I.wtE ξ" and ar: "arOf f = map tpOf Tl" shows "Ik.int (transE ξ) (Fn f Tl) = I.int ξ (Fn f Tl)" apply (rule int_transE_snv (*‹⟦wt ?T; I.wtE ?ξ; ⋀σ. infTp σ ∨ (∀x∈nvT ?T. tpOfV x ≠ σ)⟧ ⟹ Ik.int (transE ?ξ) ?T = I.int ?ξ ?T›*)) (*goal: ‹Ik.int (transE ξ) (Fn f Tl) = I.int ξ (Fn f Tl)›*) using assms (*‹list_all wt Tl› ‹wtFsym f› ‹I.wtE (ξ::Preliminaries.var ⇒ univ)› ‹(arOf::'fsym ⇒ 'tp list) (f::'fsym) = map tpOf (Tl::'fsym trm list)›*) apply - (*goals: 1. ‹⟦list_all wt (Tl::'fsym trm list); (wtFsym::'fsym ⇒ bool) (f::'fsym); I.wtE (ξ::Preliminaries.var ⇒ univ); (arOf::'fsym ⇒ 'tp list) f = map tpOf Tl⟧ ⟹ wt (Fn f Tl)› 2. ‹⟦list_all wt (Tl::'fsym trm list); (wtFsym::'fsym ⇒ bool) (f::'fsym); I.wtE (ξ::Preliminaries.var ⇒ univ); (arOf::'fsym ⇒ 'tp list) f = map tpOf Tl⟧ ⟹ I.wtE ξ› 3. ‹⋀σ::'tp. ⟦list_all wt (Tl::'fsym trm list); (wtFsym::'fsym ⇒ bool) (f::'fsym); I.wtE (ξ::Preliminaries.var ⇒ univ); (arOf::'fsym ⇒ 'tp list) f = map tpOf Tl⟧ ⟹ (infTp::'tp ⇒ bool) σ ∨ (∀x::Preliminaries.var∈nvT (Fn f Tl). tpOfV x ≠ σ)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma intP_transE[simp]: assumes wt: "list_all wt Tl" and p: "wtPsym p" and ar: "parOf p = map tpOf Tl" shows "Ik_intP p (map (Ik.int (transE ξ)) Tl) = I_intP p (map (I.int ξ) Tl)" unfolding I_intP_def (*goal: ‹Ik_intP (p::'psym::type) (map (Ik.int (transE (ξ::Preliminaries.var ⇒ univ))) (Tl::'fsym::type trm list)) = Ik_intP p (map2 proj ((parOf::'psym::type ⇒ 'tp::type list) p) (map (I.int ξ) Tl))›*) apply (rule arg_cong[of _ _ "Ik_intP p"] (*‹?x = ?y ⟹ Ik_intP p ?x = Ik_intP p ?y›*)) (*goal: ‹Ik_intP p (map (Ik.int (transE ξ)) Tl) = Ik_intP p (map2 proj (parOf p) (map (I.int ξ) Tl))›*) apply (rule nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*)) (*goal: ‹map (Ik.int (transE ξ)) Tl = map2 proj (parOf p) (map (I.int ξ) Tl)›*) using assms (*‹list_all wt Tl› ‹(wtPsym::'psym::type ⇒ bool) (p::'psym::type)› ‹(parOf::'psym::type ⇒ 'tp::type list) (p::'psym::type) = map tpOf (Tl::'fsym::type trm list)›*) using int_transE_proj (*‹wt ?T ⟹ Ik.int (transE ?ξ) ?T = proj (tpOf ?T) (I.int ?ξ ?T)›*) unfolding list_all_length (*goals: 1. ‹length (map (Ik.int (transE ξ)) Tl) = length (map2 proj (parOf p) (map (I.int ξ) Tl))› 2. ‹⋀i. i < length (map (Ik.int (transE ξ)) Tl) ⟹ map (Ik.int (transE ξ)) Tl ! i = map2 proj (parOf p) (map (I.int ξ) Tl) ! i›*) apply - (*goals: 1. ‹⟦∀n<length Tl. wt (Tl ! n); wtPsym p; parOf p = map tpOf Tl; ⋀T ξ. wt T ⟹ Ik.int (transE ξ) T = proj (tpOf T) (I.int ξ T)⟧ ⟹ length (map (Ik.int (transE ξ)) Tl) = length (map2 proj (parOf p) (map (I.int ξ) Tl))› 2. ‹⋀i. ⟦i < length (map (Ik.int (transE ξ)) Tl); ∀n<length Tl. wt (Tl ! n); wtPsym p; parOf p = map tpOf Tl; ⋀T ξ. wt T ⟹ Ik.int (transE ξ) T = proj (tpOf T) (I.int ξ T)⟧ ⟹ map (Ik.int (transE ξ)) Tl ! i = map2 proj (parOf p) (map (I.int ξ) Tl) ! i› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma satA_snvA_transE[simp]: assumes wtA: "Ik.wtA at" and ξ: "I.wtE ξ" and pA: "⋀ σ. infTp σ ∨ (∀ x ∈ nvA at. tpOfV x ≠ σ)" shows "Ik.satA (transE ξ) at ⟷ I.satA ξ at" using assms (*‹wtA (at::('fsym::type, 'psym::type) atm)› ‹I.wtE ξ› ‹(infTp::'tp ⇒ bool) (?σ2::'tp) ∨ (∀x::Preliminaries.var∈nvA (at::('fsym, 'psym) atm). tpOfV x ≠ ?σ2)›*) apply (cases at) (*goals: 1. ‹⋀x11 x12. ⟦wtA at; I.wtE ξ; ⋀σ. infTp σ ∨ (∀x∈nvA at. tpOfV x ≠ σ); at = Eq x11 x12⟧ ⟹ Ik.satA (transE ξ) at = I.satA ξ at› 2. ‹⋀x21 x22. ⟦wtA at; I.wtE ξ; ⋀σ. infTp σ ∨ (∀x∈nvA at. tpOfV x ≠ σ); at = Pr x21 x22⟧ ⟹ Ik.satA (transE ξ) at = I.satA ξ at› discuss goal 1*) apply (simp add: ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*)) (*top goal: ‹⋀x11 x12. ⟦wtA at; I.wtE ξ; ⋀σ. infTp σ ∨ (∀x∈nvA at. tpOfV x ≠ σ); at = Eq x11 x12⟧ ⟹ Ik.satA (transE ξ) at = I.satA ξ at› and 1 goal remains*) apply (metis int_transE_snv (*‹⟦wt ?T; I.wtE ?ξ; ⋀σ. infTp σ ∨ (∀x∈nvT ?T. tpOfV x ≠ σ)⟧ ⟹ Ik.int (transE ?ξ) ?T = I.int ?ξ ?T›*)) (*discuss goal 2*) apply (simp add: ball_Un (*‹(∀x∈?A ∪ ?B. ?P x) = ((∀x∈?A. ?P x) ∧ (∀x∈?B. ?P x))›*)) (*proven 2 subgoals*) . (* The next contrapositive twist is crucial for proving satL_transE: *) lemma satA_transE[simp]: assumes wtA: "Ik.wtA at" and "I.satA ξ at" shows "Ik.satA (transE ξ) at" using assms (*‹wtA at› ‹I.satA ξ at›*) apply (cases at) (*goal: ‹Ik.satA (transE ξ) at›*) using int_transE_proj (*‹wt (?T::'fsym trm) ⟹ Ik.int (transE (?ξ::Preliminaries.var ⇒ univ)) ?T = proj (tpOf ?T) (I.int ?ξ ?T)›*) apply - (*goals: 1. ‹⋀x11 x12. ⟦wtA at; I.satA ξ at; at = Eq x11 x12; ⋀T ξ. wt T ⟹ Ik.int (transE ξ) T = proj (tpOf T) (I.int ξ T)⟧ ⟹ Ik.satA (transE ξ) at› 2. ‹⋀x21 x22. ⟦wtA at; I.satA ξ at; at = Pr x21 x22; ⋀T ξ. wt T ⟹ Ik.int (transE ξ) T = proj (tpOf T) (I.int ξ T)⟧ ⟹ Ik.satA (transE ξ) at› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma satL_snvL_transE[simp]: assumes wtL: "Ik.wtL l" and ξ: "I.wtE ξ" and pL: "⋀ σ. infTp σ ∨ (∀ x ∈ nvL l. tpOfV x ≠ σ)" and "Ik.satL (transE ξ) l" shows "I.satL ξ l" using assms (*‹wtL l› ‹I.wtE ξ› ‹(infTp::'tp ⇒ bool) (?σ2::'tp) ∨ (∀x::Preliminaries.var∈nvL (l::('fsym, 'psym) lit). tpOfV x ≠ ?σ2)› ‹Ik.satL (transE ξ) l›*) apply (cases l) (*goals: 1. ‹⋀x1. ⟦wtL l; I.wtE ξ; ⋀σ. infTp σ ∨ (∀x∈nvL l. tpOfV x ≠ σ); Ik.satL (transE ξ) l; l = Pos x1⟧ ⟹ I.satL ξ l› 2. ‹⋀x2. ⟦wtL l; I.wtE ξ; ⋀σ. infTp σ ∨ (∀x∈nvL l. tpOfV x ≠ σ); Ik.satL (transE ξ) l; l = Neg x2⟧ ⟹ I.satL ξ l› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma satC_snvC_transE[simp]: assumes wtC: "Ik.wtC c" and ξ: "I.wtE ξ" and pC: "⋀ σ. σ ⊢ c" and "Ik.satC (transE ξ) c" shows "I.satC ξ c" using assms (*‹wtC c› ‹I.wtE ξ› ‹?σ2 ⊢ c› ‹Ik.satC (transE ξ) c›*) unfolding Ik.mcalc_iff Ik.satC_def satC_def Ik.wtC_def nvC_def (*goal: ‹list_ex (I.satL ξ) c›*) unfolding list_all_iff list_ex_iff (*goal: ‹Bex (set c) (I.satL ξ)›*) apply simp (*goal: ‹Bex (set c) (I.satL ξ)›*) by (metis nth_mem (*‹?n < length ?xs ⟹ ?xs ! ?n ∈ set ?xs›*) satL_snvL_transE (*‹⟦wtL ?l; I.wtE ?ξ; ⋀σ. infTp σ ∨ (∀x∈nvL ?l. tpOfV x ≠ σ); Ik.satL (transE ?ξ) ?l⟧ ⟹ I.satL ?ξ ?l›*)) lemma satPB_snvPB_transE[simp]: assumes ξ: "I.wtE ξ" shows "I.satPB ξ Φ" using "Ik.wt_Φ" (*‹wtPB Φ›*) "Ik.sat_Φ"[OF wtE_transE [ OF ξ ]] (*‹Ik.satPB (transE (ξ::Preliminaries.var ⇒ univ)) (Φ::('fsym, 'psym) lit list set)›*) using mcalc (*‹?c ∈ Φ ⟹ ?σ ⊢ ?c›*) "ξ" (*‹I.wtE ξ›*) unfolding Ik.satPB_def satPB_def Ik.wtPB_def nvPB_def (*goal: ‹∀c∈Φ. I.satC ξ c›*) by auto lemma I_SAT: "I.SAT Φ" unfolding I.SAT_def (*goal: ‹∀ξ. I.wtE ξ ⟶ I.satPB ξ Φ›*) by auto lemma InfModel: "IInfModel I_intT I_intF I_intP" apply standard (*goal: ‹IInfModel I_intT I_intF I_intP›*) by (rule I_SAT (*‹I.SAT Φ›*)) end (* context ModelIkMcalc *) sublocale ModelIkMcalc < inf?: InfModel where intT = I_intT and intF = I_intF and intP = I_intP using InfModel (*‹IInfModel I_intT I_intF I_intP›*) . context ProblemIkMcalc begin abbreviation "MModelIkMcalc ≡ ModelIkMcalc wtFsym wtPsym arOf resOf parOf Φ infTp" theorem monot: monot sorry end (* context ProblemIkMcalc *) text‹Final theorem in sublocale form: Any problem that passes the monotonicity calculus is monotonic:› sublocale ProblemIkMcalc < MonotProblem apply standard (*goal: ‹MonotProblem wtFsym wtPsym arOf resOf parOf Φ›*) by (rule monot (*‹monot›*)) end
{ "path": "afp-2025-02-12/thys/Sort_Encodings/Mcalc.thy", "repo": "afp-2025-02-12", "sha": "874a36cb7ebe631e52f55b8d970a4862fda58aa1979efebb191a2286fc8b1f8c" }
(*<*) theory Sotomayor imports Main begin (*>*) section‹ \<^citet>‹"Sotomayor:1996"›: A non-constructive proof of the existence of stable marriages \label{sec:sotomayor} › text‹ We set the scene with a non-constructive proof of the existence of stable matches due to \<^citet>‹"Sotomayor:1996"›. This approach is pleasantly agnostic about the strictness of preferences, and moreover avoids getting bogged down in reasoning about programs; most existing proofs involve such but omit formal treatments of the requisite assertions. This tradition started with \<^citet>‹"GaleShapley:1962"›; see \<^citet>‹"Bijlsma:1991"› for a rigorous treatment. The following contains the full details of an Isabelle/HOL formalization of her proof, and aims to introduce the machinery we will make heavy use of later. Further developments will elide many of the more tedious technicalities that we include here. The scenario consists of disjoint finite sets of men @{term "M"} and women @{term "W"}, represented as types ‹'m::finite"› and ‹'w::finite› respectively. We diverge from \citeauthor{Sotomayor:1996} by having each man and woman rank only acceptable partners in a way that is transitive and complete. (Here completeness requires @{const "Refl"} in addition to @{const "Total"} as the latter does not imply the former, and so we end up with a total preorder.) Such orders therefore include cycles of indifference, i.e., are not antisymmetric. Also matches are treated as relations rather than functions. We model this scenario in a @{theory_text "locale"}, a sectioning mechanism for stating a series of lemmas relative to a set of fixed variables (@{theory_text "fixes"}) and assumptions (@{theory_text "assumes"}) that can later be instantiated and discharged. › type_synonym ('m, 'w) match = "('m × 'w) set" locale StableMarriage = fixes Pm :: "'m::finite ⇒ 'w::finite rel" fixes Pw :: "'w ⇒ 'm rel" assumes Pm_pref: "∀m. Preorder (Pm m) ∧ Total (Pm m)" assumes Pw_pref: "∀w. Preorder (Pw w) ∧ Total (Pw w)" begin text‹ A @{emph ‹match›} assigns at most one man to each woman, and vice-versa. It is also @{emph ‹individually rational›}, i.e., the partners are acceptable to each other. The constant @{const "Field"} is the union of the @{const "Domain"} and @{const "Range"} of a relation. › definition match :: "('m, 'w) match ⇒ bool" where "match μ ⟷ inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∩ (⋃w. Field (Pw w) × {w})" text‹ A woman @{emph ‹prefers›} one man to another if her preference order ranks the former over the latter, and @{emph ‹strictly prefers›} him if additionally the latter is not ranked over the former, and similarly for the men. › (* AboveS doesn't work in the following: consider a cycle of indifference of length > 1. Two things may be not-equal but agent is indifferent. Suggests AboveS is for antisym rels only. *) abbreviation (input) "m_for w μ ≡ {m. (m, w) ∈ μ}" abbreviation (input) "w_for m μ ≡ {w. (m, w) ∈ μ}" definition m_prefers :: "'m ⇒ ('m, 'w) match ⇒ 'w set" where "m_prefers m μ = {w' ∈ Field (Pm m). ∀w∈w_for m μ. (w, w') ∈ Pm m}" definition w_prefers :: "'w ⇒ ('m, 'w) match ⇒ 'm set" where "w_prefers w μ = {m' ∈ Field (Pw w). ∀m∈m_for w μ. (m, m') ∈ Pw w}" definition m_strictly_prefers :: "'m ⇒ ('m, 'w) match ⇒ 'w set" where "m_strictly_prefers m μ = {w' ∈ Field (Pm m). ∀w∈w_for m μ. (w, w') ∈ Pm m ∧ (w', w) ∉ Pm m}" definition w_strictly_prefers :: "'w ⇒ ('m, 'w) match ⇒ 'm set" where "w_strictly_prefers w μ = {m' ∈ Field (Pw w). ∀m∈m_for w μ. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}" text‹ A couple @{emph ‹blocks›} a match ‹μ› if both strictly prefer each other to anyone they are matched with in ‹μ›. › definition blocks :: "'m ⇒ 'w ⇒ ('m, 'w) match ⇒ bool" where "blocks m w μ ⟷ w ∈ m_strictly_prefers m μ ∧ m ∈ w_strictly_prefers w μ" text‹ We say a match is @{emph ‹stable›} if there are no blocking couples. › definition stable :: "('m, 'w) match ⇒ bool" where "stable μ ⟷ match μ ∧ (∀m w. ¬ blocks m w μ)" lemma stable_match: assumes "stable μ" shows "match μ" using assms (*‹local.stable μ›*) unfolding stable_def (*goal: ‹match μ›*) by blast text‹ Our goal is to show that for every preference order there is a stable match. Stable matches in this scenario form a lattice, and this proof implicitly adopts the traditional view that men propose and women choose. The definitions above form the trust basis for this existence theorem; the following are merely part of the proof apparatus, and Isabelle/HOL enforces their soundness with respect to the argument. We will see these concepts again in later developments. Firstly, a match is @{emph ‹simple›} if every woman party to a blocking pair is single. The most obvious such match leaves everyone single. › definition simple :: "('m, 'w) match ⇒ bool" where "simple μ ⟷ match μ ∧ (∀m w. blocks m w μ ⟶ w ∉ Range μ)" lemma simple_match: assumes "simple μ" shows "match μ" using assms (*‹simple μ›*) unfolding simple_def (*goal: ‹match μ›*) by blast lemma simple_ex: "∃μ. simple μ" unfolding simple_def blocks_def match_def (*goal: ‹∃μ::('m::finite × 'w::finite) set. (inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m::'m::finite. {m} × Field ((Pm::'m::finite ⇒ ('w::finite × 'w::finite) set) m)) ∩ (⋃w::'w::finite. Field ((Pw::'w::finite ⇒ ('m::finite × 'm::finite) set) w) × {w})) ∧ (∀(m::'m::finite) w::'w::finite. w ∈ m_strictly_prefers m μ ∧ m ∈ w_strictly_prefers w μ ⟶ w ∉ Range μ)›*) by auto text‹ \citeauthor{Sotomayor:1996} observes the following: › lemma simple_no_single_women_stable: assumes "simple μ" assumes "∀w. w ∈ Range μ" ― ‹No woman is single› shows "stable μ" using assms (*‹simple μ› ‹∀w::'w. w ∈ Range (μ::('m × 'w) set)›*) unfolding simple_def stable_def (*goal: ‹match μ ∧ (∀m w. ¬ blocks m w μ)›*) by blast lemma stable_simple: assumes "stable μ" shows "simple μ" using assms (*‹local.stable (μ::('m::finite × 'w::finite) set)›*) unfolding simple_def stable_def (*goal: ‹match μ ∧ (∀m w. blocks m w μ ⟶ w ∉ Range μ)›*) by blast text‹ Secondly, a @{emph ‹weakly Pareto optimal match for men (among all simple matches)›} is one for which there is no other match that all men like as much and some man likes more. › definition m_weakly_prefers :: "'m ⇒ ('m, 'w) match ⇒ 'w set" where "m_weakly_prefers m μ = {w' ∈ Field (Pm m). ∀w∈w_for m μ. (w, w') ∈ Pm m}" definition weakly_preferred_by_men :: "('m, 'w) match ⇒ ('m, 'w) match ⇒ bool" where "weakly_preferred_by_men μ μ' ⟷ (∀m. ∀w∈w_for m μ. ∃w'∈w_for m μ'. w' ∈ m_weakly_prefers m μ)" definition strictly_preferred_by_a_man :: "('m, 'w) match ⇒ ('m, 'w) match ⇒ bool" where "strictly_preferred_by_a_man μ μ' ⟷ (∃m. ∃w∈w_for m μ'. w ∈ m_strictly_prefers m μ)" definition weakly_Pareto_optimal_for_men :: "('m, 'w) match ⇒ bool" where "weakly_Pareto_optimal_for_men μ ⟷ simple μ ∧ ¬(∃μ'. simple μ' ∧ weakly_preferred_by_men μ μ' ∧ strictly_preferred_by_a_man μ μ')" text‹ We will often provide @{emph ‹introduction rules›} for more complex predicates, and sometimes derive these by elementary syntactic manipulations expressed by the @{emph ‹attributes›} enclosed in square brackets after a use-mention of a lemma. The @{command "lemmas"} command binds a name to the result. To conform with the Isar structured proof language, we use meta-logic (``Pure'' in Isabelle terminology) connectives: ‹⋀› denotes universal quantification, and ‹⟹› implication. › lemma weakly_preferred_by_menI: assumes "⋀m w. (m, w) ∈ μ ⟹ ∃w'. (m, w') ∈ μ' ∧ w' ∈ m_weakly_prefers m μ" shows "weakly_preferred_by_men μ μ'" using assms (*‹(?m, ?w) ∈ μ ⟹ ∃w'. (?m, w') ∈ μ' ∧ w' ∈ m_weakly_prefers ?m μ›*) unfolding weakly_preferred_by_men_def (*goal: ‹∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ m_weakly_prefers m μ›*) by blast lemmas simpleI = iffD2[OF simple_def, unfolded conj_imp_eq_imp_imp, rule_format] lemma weakly_Pareto_optimal_for_men_simple: assumes "weakly_Pareto_optimal_for_men μ" shows "simple μ" using assms (*‹weakly_Pareto_optimal_for_men (μ::('m::finite × 'w::finite) set)›*) unfolding weakly_Pareto_optimal_for_men_def (*goal: ‹simple μ›*) by simp text‹ Later we will elide obvious technical lemmas like the following. The more obscure proofs are typically generated automatically by sledgehammer \<^citep>‹"Blanchette:2016"›. › lemma m_weakly_prefers_Pm: assumes "match μ" assumes "(m, w) ∈ μ" shows "w' ∈ m_weakly_prefers m μ ⟷ (w, w') ∈ Pm m" using spec[OF Pm_pref, where x = m] (*‹Preorder (Pm m) ∧ Total (Pm m)›*) assms (*‹match μ› ‹(m, w) ∈ μ›*) unfolding m_weakly_prefers_def match_def preorder_on_def (*goal: ‹((w'::'w) ∈ {w'::'w ∈ Field ((Pm::'m ⇒ ('w × 'w) set) (m::'m)). ∀w::'w∈{w::'w. (m, w) ∈ (μ::('m × 'w) set)}. (w, w') ∈ Pm m}) = ((w::'w, w') ∈ Pm m)›*) apply simp (*goal: ‹(w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m}) = ((w, w') ∈ Pm m)›*) by (metis (no_types, opaque_lifting) FieldI2 (*‹(?i, ?j) ∈ ?R ⟹ ?j ∈ Field ?R›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) inj_on_contraD (*‹⟦inj_on ?f ?A; ?x ≠ ?y; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?f ?x ≠ ?f ?y›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) lemma match_Field: assumes "match μ" assumes "(m, w) ∈ μ" shows "w ∈ Field (Pm m)" and "m ∈ Field (Pw w)" sorry lemma weakly_preferred_by_men_refl: assumes "match μ" shows "weakly_preferred_by_men μ μ" using assms (*‹match μ›*) unfolding weakly_preferred_by_men_def m_weakly_prefers_def (*goal: ‹∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m}›*) apply clarsimp (*goal: ‹∀m::'m. ∀w::'w∈{w::'w. (m, w) ∈ (μ::('m × 'w) set)}. ∃w'::'w∈{w::'w. (m, w) ∈ μ}. w' ∈ {w'::'w ∈ Field ((Pm::'m ⇒ ('w × 'w) set) m). ∀w::'w∈{w::'w. (m, w) ∈ μ}. (w, w') ∈ Pm m}›*) by (meson Pm_pref (*‹∀m. Preorder (Pm m) ∧ Total (Pm m)›*) m_weakly_prefers_Pm (*‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ (?w' ∈ m_weakly_prefers ?m ?μ) = ((?w, ?w') ∈ Pm ?m)›*) match_Field( (*‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ ?w ∈ Field (Pm ?m)›*) 1) preorder_on_def (*‹preorder_on ?A ?r ≡ refl_on ?A ?r ∧ trans ?r›*) refl_onD (*‹⟦refl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∈ ?r›*)) text‹ \citeauthor[p137]{Sotomayor:1996} provides an alternative definition of @{const "weakly_preferred_by_men"}. The syntax @{theory_text "(is ?lhs ⟷ pat)"} binds the @{emph ‹schematic variables›} ‹?lhs› and ‹?rhs› to the terms separated by ‹⟷›. › lemma weakly_preferred_by_men_strictly_preferred_by_a_man: assumes "match μ" assumes "match μ'" shows "weakly_preferred_by_men μ μ' ⟷ ¬strictly_preferred_by_a_man μ' μ" (is "?lhs ⟷ ?rhs") proof (rule iffI (*‹⟦?P::bool ⟹ ?Q::bool; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹weakly_preferred_by_men μ μ' ⟹ ¬ strictly_preferred_by_a_man μ' μ› 2. ‹¬ strictly_preferred_by_a_man μ' μ ⟹ weakly_preferred_by_men μ μ'›*) assume "?lhs" (*‹weakly_preferred_by_men (μ::('m × 'w) set) (μ'::('m × 'w) set)›*) then show "?rhs" unfolding weakly_preferred_by_men_def strictly_preferred_by_a_man_def m_weakly_prefers_def m_strictly_prefers_def (*goal: ‹∄m. ∃w∈{w. (m, w) ∈ μ}. w ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ'}. (w, w') ∈ Pm m ∧ (w', w) ∉ Pm m}›*) by fastforce next (*goal: ‹¬ strictly_preferred_by_a_man (μ'::('m::finite × 'w::finite) set) (μ::('m::finite × 'w::finite) set) ⟹ weakly_preferred_by_men μ μ'›*) assume "?rhs" (*‹¬ strictly_preferred_by_a_man (μ'::('m × 'w) set) (μ::('m × 'w) set)›*) show "?lhs" proof (rule weakly_preferred_by_menI (*‹(⋀m w. (m, w) ∈ ?μ ⟹ ∃w'. (m, w') ∈ ?μ' ∧ w' ∈ m_weakly_prefers m ?μ) ⟹ weakly_preferred_by_men ?μ ?μ'›*)) (*goal: ‹⋀m w. (m, w) ∈ μ ⟹ ∃w'. (m, w') ∈ μ' ∧ w' ∈ m_weakly_prefers m μ›*) fix m and w assume "(m, w) ∈ μ" (*‹(m::'m, w::'w) ∈ (μ::('m × 'w) set)›*) from assms (*‹match μ› ‹match μ'›*) ‹?rhs› (*‹¬ strictly_preferred_by_a_man μ' μ›*) ‹(m, w) ∈ μ› (*‹(m::'m, w::'w) ∈ (μ::('m × 'w) set)›*) obtain w' where XXX: "(m, w') ∈ μ'" "(w', w) ∈ Pm m ⟶ (w, w') ∈ Pm m" (*goal: ‹(⋀w'. ⟦(m, w') ∈ μ'; (w', w) ∈ Pm m ⟶ (w, w') ∈ Pm m⟧ ⟹ thesis) ⟹ thesis›*) unfolding match_def strictly_preferred_by_a_man_def m_strictly_prefers_def (*goal: ‹(⋀w'. ⟦(m, w') ∈ μ'; (w', w) ∈ Pm m ⟶ (w, w') ∈ Pm m⟧ ⟹ thesis) ⟹ thesis›*) by blast with spec[OF Pm_pref, where x = m] (*‹Preorder (Pm m) ∧ Total (Pm m)›*) assms (*‹match μ› ‹match μ'›*) ‹(m, w) ∈ μ› (*‹(m, w) ∈ μ›*) show "∃w'. (m, w') ∈ μ' ∧ w' ∈ m_weakly_prefers m μ" unfolding preorder_on_def total_on_def (*goal: ‹∃w'. (m, w') ∈ μ' ∧ w' ∈ m_weakly_prefers m μ›*) by (metis m_weakly_prefers_Pm (*‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ (?w' ∈ m_weakly_prefers ?m ?μ) = ((?w, ?w') ∈ Pm ?m)›*) match_Field( (*‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ ?w ∈ Field (Pm ?m)›*) 1) refl_onD (*‹⟦refl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∈ ?r›*)) qed qed lemma weakly_Pareto_optimal_for_men_def2: "weakly_Pareto_optimal_for_men μ ⟷ simple μ ∧ (∀μ'. simple μ' ∧ strictly_preferred_by_a_man μ μ' ⟶ strictly_preferred_by_a_man μ' μ)" unfolding weakly_Pareto_optimal_for_men_def simple_def (*goal: ‹((match μ ∧ (∀m w. blocks m w μ ⟶ w ∉ Range μ)) ∧ (∄μ'. (match μ' ∧ (∀m w. blocks m w μ' ⟶ w ∉ Range μ')) ∧ weakly_preferred_by_men μ μ' ∧ strictly_preferred_by_a_man μ μ')) = ((match μ ∧ (∀m w. blocks m w μ ⟶ w ∉ Range μ)) ∧ (∀μ'. (match μ' ∧ (∀m w. blocks m w μ' ⟶ w ∉ Range μ')) ∧ strictly_preferred_by_a_man μ μ' ⟶ strictly_preferred_by_a_man μ' μ))›*) by (meson weakly_preferred_by_men_strictly_preferred_by_a_man (*‹⟦match ?μ; match ?μ'⟧ ⟹ weakly_preferred_by_men ?μ ?μ' = (¬ strictly_preferred_by_a_man ?μ' ?μ)›*)) text‹ \citeauthor{Sotomayor:1996} claims that the existence of such a weakly Pareto optimal match for men is ``guaranteed by the fact that @{emph ‹the set of simple matchings is nonempty›} [our @{thm [source] "simple_ex"} lemma] @{emph ‹and finite and the preferences are transitive.›}'' The following lemmas express this intuition: › lemma trans_finite_has_maximal_elt: assumes "trans r" assumes "finite (Field r)" assumes "Field r ≠ {}" shows "∃x∈Field r. (∀y∈Field r. (x, y) ∈ r ⟶ (y, x) ∈ r)" using assms(2,1,3) (*‹finite (Field r)› ‹trans r› ‹Field (r::('a × 'a) set) ≠ {}›*) apply induct (*goals: 1. ‹⟦trans r; {} ≠ {}⟧ ⟹ ∃x∈{}. ∀y∈{}. (x, y) ∈ r ⟶ (y, x) ∈ r› 2. ‹⋀x F. ⟦finite F; x ∉ F; ⟦trans r; F ≠ {}⟧ ⟹ ∃x∈F. ∀y∈F. (x, y) ∈ r ⟶ (y, x) ∈ r; trans r; insert x F ≠ {}⟧ ⟹ ∃xa∈insert x F. ∀y∈insert x F. (xa, y) ∈ r ⟶ (y, xa) ∈ r› discuss goal 1*) apply ((auto elim: transE (*‹⟦trans ?r; (?x, ?y) ∈ ?r; (?y, ?z) ∈ ?r; (?x, ?z) ∈ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim: transE (*‹⟦trans (?r::(?'a::type × ?'a::type) set); (?x::?'a::type, ?y::?'a::type) ∈ ?r; (?y, ?z::?'a::type) ∈ ?r; (?x, ?z) ∈ ?r ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))[1]) (*proven 2 subgoals*) . lemma weakly_Pareto_optimal_for_men_ex: "∃μ. weakly_Pareto_optimal_for_men μ" proof (-) (*goal: ‹Ex weakly_Pareto_optimal_for_men›*) let ?r = "{(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}" from trans_finite_has_maximal_elt[where r = "?r"] (*‹⟦trans {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; finite (Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}); Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ≠ {}⟧ ⟹ ∃x∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}›*) obtain x where "x ∈ Field ?r" "∀y∈Field ?r. (x, y) ∈ ?r ⟶ (y, x) ∈ ?r" (*goal: ‹(⋀x::('m × 'w) set. ⟦x ∈ Field {(μ::('m × 'w) set, μ'::('m × 'w) set). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y::('m × 'w) set∈Field {(μ::('m × 'w) set, μ'::('m × 'w) set). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ::('m × 'w) set, μ'::('m × 'w) set). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ::('m × 'w) set, μ'::('m × 'w) set). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis::bool) ⟹ thesis›*) proof (standard) (*goals: 1. ‹(⋀x. ⟦x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis) ⟹ trans {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}› 2. ‹(⋀x. ⟦x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis) ⟹ finite (Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'})› 3. ‹(⋀x. ⟦x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis) ⟹ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ≠ {}› 4. ‹⋀x. ⟦⋀x. ⟦x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis; x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis›*) from Pm_pref (*‹∀m::'m. Preorder ((Pm::'m ⇒ ('w × 'w) set) m) ∧ Total (Pm m)›*) show "trans ?r" unfolding trans_def weakly_preferred_by_men_def m_weakly_prefers_def m_strictly_prefers_def (*goal: ‹∀x y z. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ (∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m})} ⟶ (y, z) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ (∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m})} ⟶ (x, z) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ (∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m})}›*) apply simp (*goal: ‹∀x y z. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ (∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m})} ⟶ (y, z) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ (∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m})} ⟶ (x, z) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ (∀m. ∀w∈{w. (m, w) ∈ μ}. ∃w'∈{w. (m, w) ∈ μ'}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ}. (w, w') ∈ Pm m})}›*) by (meson order_on_defs( (*‹preorder_on ?A ?r ≡ refl_on ?A ?r ∧ trans ?r›*) 1) transE (*‹⟦trans ?r; (?x, ?y) ∈ ?r; (?y, ?z) ∈ ?r; (?x, ?z) ∈ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*)) from simple_ex (*‹Ex simple›*) weakly_preferred_by_men_refl[OF simple_match] (*‹simple ?μ ⟹ weakly_preferred_by_men ?μ ?μ›*) show "Field ?r ≠ {}" unfolding Field_def (*goal: ‹Domain {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ∪ Range {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ≠ {}›*) by force qed (simp_all) (*solves the remaining goals: 1. ‹(⋀x. ⟦x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis) ⟹ finite (Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'})› 2. ‹⋀x. ⟦⋀x. ⟦x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis; x ∈ Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}; ∀y∈Field {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}. (x, y) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'} ⟶ (y, x) ∈ {(μ, μ'). simple μ ∧ simple μ' ∧ weakly_preferred_by_men μ μ'}⟧ ⟹ thesis›*) then show "?thesis" (*goal: ‹Ex weakly_Pareto_optimal_for_men›*) unfolding weakly_Pareto_optimal_for_men_def Field_def (*goal: ‹∃μ. simple μ ∧ (∄μ'. simple μ' ∧ weakly_preferred_by_men μ μ' ∧ strictly_preferred_by_a_man μ μ')›*) using simple_match (*‹simple ?μ ⟹ match ?μ›*) weakly_preferred_by_men_strictly_preferred_by_a_man (*‹⟦match ?μ; match ?μ'⟧ ⟹ weakly_preferred_by_men ?μ ?μ' = (¬ strictly_preferred_by_a_man ?μ' ?μ)›*) by auto qed text‹ The main result proceeds by contradiction. › lemma weakly_Pareto_optimal_for_men_stable: assumes "weakly_Pareto_optimal_for_men μ" shows "stable μ" proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ local.stable (μ::('m::finite × 'w::finite) set) ⟹ False›*) assume "¬stable μ" (*‹¬ local.stable (μ::('m × 'w) set)›*) from ‹weakly_Pareto_optimal_for_men μ› (*‹weakly_Pareto_optimal_for_men μ›*) have "simple μ" by (rule weakly_Pareto_optimal_for_men_simple (*‹weakly_Pareto_optimal_for_men ?μ ⟹ simple ?μ›*)) from ‹¬stable μ› (*‹¬ local.stable μ›*) ‹simple μ› (*‹simple (μ::('m::finite × 'w::finite) set)›*) obtain m' and w where "blocks m' w μ" and "w ∉ Range μ" (*goal: ‹(⋀m' w. ⟦blocks m' w μ; w ∉ Range μ⟧ ⟹ thesis) ⟹ thesis›*) unfolding simple_def stable_def (*goal: ‹(⋀m' w. ⟦blocks m' w μ; w ∉ Range μ⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?r = "Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}" from trans_finite_has_maximal_elt[where r = "?r"] (*‹⟦trans (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); finite (Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ})); Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}) ≠ {}⟧ ⟹ ∃x∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). ∀y∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (x, y) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (y, x) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}›*) obtain m where "m ∈ Field ?r" "∀m'∈Field ?r. (m, m') ∈ ?r ⟶ (m', m) ∈ ?r" (*goal: ‹(⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis) ⟹ thesis›*) proof (standard) (*goals: 1. ‹(⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis) ⟹ trans (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ})› 2. ‹(⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis) ⟹ finite (Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}))› 3. ‹(⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis) ⟹ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}) ≠ {}› 4. ‹⋀x. ⟦⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis; x ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀y∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (x, y) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (y, x) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis›*) from Pw_pref (*‹∀w. Preorder (Pw w) ∧ Total (Pw w)›*) show "trans ?r" unfolding preorder_on_def (*goal: ‹trans (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ})›*) by (blast intro: trans_Restr (*‹trans ?r ⟹ trans (Restr ?r ?A)›*)) from Pw_pref (*‹∀w. Preorder (Pw w) ∧ Total (Pw w)›*) ‹blocks m' w μ› (*‹blocks (m'::'m) (w::'w) (μ::('m × 'w) set)›*) have "(m', m') ∈ ?r" unfolding blocks_def w_strictly_prefers_def preorder_on_def (*goal: ‹(m'::'m, m') ∈ Restr ((Pw::'w ⇒ ('m × 'm) set) (w::'w)) {m::'m. w ∈ m_strictly_prefers m (μ::('m × 'w) set)}›*) by (blast dest: refl_onD (*‹⟦refl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∈ ?r›*)) then show "Field ?r ≠ {}" by (metis FieldI2 (*‹(?i, ?j) ∈ ?R ⟹ ?j ∈ Field ?R›*) empty_iff (*‹(?c ∈ {}) = False›*)) qed (simp_all) (*solves the remaining goals: 1. ‹(⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis) ⟹ finite (Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}))› 2. ‹⋀x. ⟦⋀m. ⟦m ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis; x ∈ Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀y∈Field (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (x, y) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (y, x) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ thesis›*) with ‹blocks m' w μ› (*‹blocks m' w μ›*) ‹w ∉ Range μ› (*‹(w::'w) ∉ Range (μ::('m × 'w) set)›*) have "blocks m w μ" and "∀m'. blocks m' w μ ∧ (m, m') ∈ Pw w ⟶ (m', m) ∈ Pw w" unfolding blocks_def w_strictly_prefers_def Field_def (*goals: 1. ‹w ∈ m_strictly_prefers m μ ∧ m ∈ {m' ∈ Domain (Pw w) ∪ Range (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}› 2. ‹∀m'. (w ∈ m_strictly_prefers m' μ ∧ m' ∈ {m' ∈ Domain (Pw w) ∪ Range (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}) ∧ (m, m') ∈ Pw w ⟶ (m', m) ∈ Pw w›*) apply - (*goals: 1. ‹⟦w ∈ m_strictly_prefers m' μ ∧ m' ∈ {m' ∈ Domain (Pw w) ∪ Range (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}; w ∉ Range μ; m ∈ Domain (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}) ∪ Range (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Domain (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}) ∪ Range (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ w ∈ m_strictly_prefers m μ ∧ m ∈ {m' ∈ Domain (Pw w) ∪ Range (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}› 2. ‹⟦w ∈ m_strictly_prefers m' μ ∧ m' ∈ {m' ∈ Domain (Pw w) ∪ Range (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}; w ∉ Range μ; m ∈ Domain (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}) ∪ Range (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}); ∀m'∈Domain (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}) ∪ Range (Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}). (m, m') ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ} ⟶ (m', m) ∈ Restr (Pw w) {m. w ∈ m_strictly_prefers m μ}⟧ ⟹ ∀m'. (w ∈ m_strictly_prefers m' μ ∧ m' ∈ {m' ∈ Domain (Pw w) ∪ Range (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}) ∧ (m, m') ∈ Pw w ⟶ (m', m) ∈ Pw w› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?μ' = "μ - {(m, w') |w'. True} ∪ {(m, w)}" have "simple ?μ'" proof (rule simpleI (*‹⟦match ?μ; ⋀m w. blocks m w ?μ ⟹ w ∉ Range ?μ⟧ ⟹ simple ?μ›*)) (*goals: 1. ‹match ((μ::('m × 'w) set) - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)})› 2. ‹⋀(ma::'m) wa::'w. blocks ma wa ((μ::('m × 'w) set) - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)}) ⟹ wa ∉ Range (μ - {(m, w') |w'::'w. True} ∪ {(m, w)})›*) from ‹simple μ› (*‹simple μ›*) ‹blocks m w μ› (*‹blocks m w μ›*) show "match ?μ'" unfolding blocks_def match_def simple_def m_strictly_prefers_def w_strictly_prefers_def (*goal: ‹inj_on fst ((μ::('m × 'w) set) - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)}) ∧ inj_on snd (μ - {(m, w') |w'::'w. True} ∪ {(m, w)}) ∧ μ - {(m, w') |w'::'w. True} ∪ {(m, w)} ⊆ (⋃m::'m. {m} × Field ((Pm::'m ⇒ ('w × 'w) set) m)) ∩ (⋃w::'w. Field ((Pw::'w ⇒ ('m × 'm) set) w) × {w})›*) apply - (*goal: ‹inj_on fst (μ - {(m, w') |w'. True} ∪ {(m, w)}) ∧ inj_on snd (μ - {(m, w') |w'. True} ∪ {(m, w)}) ∧ μ - {(m, w') |w'. True} ∪ {(m, w)} ⊆ (⋃m. {m} × Field (Pm m)) ∩ (⋃w. Field (Pw w) × {w})›*) by (msorry) fix m' and w' assume "blocks m' w' ?μ'" (*‹blocks (m'::'m) (w'::'w) ((μ::('m × 'w) set) - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)})›*) from ‹blocks m' w' ?μ'› (*‹blocks (m'::'m) (w'::'w) ((μ::('m × 'w) set) - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)})›*) ‹∀m'. blocks m' w μ ∧ (m, m') ∈ Pw w ⟶ (m', m) ∈ Pw w› (*‹∀m'. blocks m' w μ ∧ (m, m') ∈ Pw w ⟶ (m', m) ∈ Pw w›*) have "w' ≠ w" unfolding blocks_def m_strictly_prefers_def w_strictly_prefers_def (*goal: ‹(w'::'w) ≠ (w::'w)›*) by auto show "w' ∉ Range ?μ'" proof (cases "(m, w') ∈ μ") (*goals: 1. ‹(m::'m, w'::'w) ∈ (μ::('m × 'w) set) ⟹ w' ∉ Range (μ - {(m, w') |w'::'w. True} ∪ {(m, w::'w)})› 2. ‹(m::'m, w'::'w) ∉ (μ::('m × 'w) set) ⟹ w' ∉ Range (μ - {(m, w') |w'::'w. True} ∪ {(m, w::'w)})›*) case True (*‹(m, w') ∈ μ›*) from ‹simple μ› (*‹simple μ›*) ‹blocks m' w' ?μ'› (*‹blocks m' w' (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) ‹w' ≠ w› (*‹(w'::'w) ≠ (w::'w)›*) ‹(m, w') ∈ μ› (*‹(m::'m, w'::'w) ∈ (μ::('m × 'w) set)›*) show "?thesis" (*goal: ‹w' ∉ Range (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) unfolding simple_def match_def (*goal: ‹w' ∉ Range (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) apply clarsimp (*goal: ‹w' ∉ Range (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) by (metis (no_types, opaque_lifting) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) inj_on_contraD (*‹⟦inj_on ?f ?A; ?x ≠ ?y; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?f ?x ≠ ?f ?y›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) next (*goal: ‹(m, w') ∉ μ ⟹ w' ∉ Range (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) case False (*‹(m, w') ∉ μ›*) from Pm_pref (*‹∀m. Preorder (Pm m) ∧ Total (Pm m)›*) ‹blocks m w μ› (*‹blocks m w μ›*) ‹blocks m' w' ?μ'› (*‹blocks m' w' (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) ‹(m, w') ∉ μ› (*‹(m, w') ∉ μ›*) have "blocks m' w' μ" unfolding preorder_on_def blocks_def m_strictly_prefers_def w_strictly_prefers_def (*goal: ‹w' ∈ {w' ∈ Field (Pm m'). ∀w∈{w. (m', w) ∈ μ}. (w, w') ∈ Pm m' ∧ (w', w) ∉ Pm m'} ∧ m' ∈ {m' ∈ Field (Pw w'). ∀m∈{m. (m, w') ∈ μ}. (m, m') ∈ Pw w' ∧ (m', m) ∉ Pw w'}›*) apply simp (*goal: ‹w' ∈ {w' ∈ Field (Pm m'). ∀w∈{w. (m', w) ∈ μ}. (w, w') ∈ Pm m' ∧ (w', w) ∉ Pm m'} ∧ m' ∈ {m' ∈ Field (Pw w'). ∀m∈{m. (m, w') ∈ μ}. (m, m') ∈ Pw w' ∧ (m', m) ∉ Pw w'}›*) by (metis transE (*‹⟦trans ?r; (?x, ?y) ∈ ?r; (?y, ?z) ∈ ?r; (?x, ?z) ∈ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*)) with ‹simple μ› (*‹simple μ›*) ‹w' ≠ w› (*‹w' ≠ w›*) show "?thesis" (*goal: ‹(w'::'w) ∉ Range ((μ::('m × 'w) set) - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)})›*) unfolding simple_def (*goal: ‹w' ∉ Range (μ - {(m, w') |w'. True} ∪ {(m, w)})›*) by blast qed qed moreover have "weakly_preferred_by_men μ ?μ'" proof (rule weakly_preferred_by_menI (*‹(⋀m w. (m, w) ∈ ?μ ⟹ ∃w'. (m, w') ∈ ?μ' ∧ w' ∈ m_weakly_prefers m ?μ) ⟹ weakly_preferred_by_men ?μ ?μ'›*)) (*goal: ‹⋀(ma::'m) wa::'w. (ma, wa) ∈ (μ::('m × 'w) set) ⟹ ∃w'::'w. (ma, w') ∈ μ - {(m::'m, w') |w'::'w. True} ∪ {(m, w::'w)} ∧ w' ∈ m_weakly_prefers ma μ›*) fix m' and w' assume "(m', w') ∈ μ" (*‹(m'::'m, w'::'w) ∈ (μ::('m × 'w) set)›*) then show "∃w'. (m', w') ∈ ?μ' ∧ w' ∈ m_weakly_prefers m' μ" proof (cases "m' = m") (*goals: 1. ‹⟦(m'::'m, w'::'w) ∈ (μ::('m × 'w) set); m' = (m::'m)⟧ ⟹ ∃w'::'w. (m', w') ∈ μ - {(m, w') |w'::'w. True} ∪ {(m, w::'w)} ∧ w' ∈ m_weakly_prefers m' μ› 2. ‹⟦(m'::'m, w'::'w) ∈ (μ::('m × 'w) set); m' ≠ (m::'m)⟧ ⟹ ∃w'::'w. (m', w') ∈ μ - {(m, w') |w'::'w. True} ∪ {(m, w::'w)} ∧ w' ∈ m_weakly_prefers m' μ›*) case True (*‹m' = m›*) from ‹blocks m w μ› (*‹blocks (m::'m::finite) (w::'w::finite) (μ::('m::finite × 'w::finite) set)›*) ‹(m', w') ∈ μ› (*‹(m'::'m, w'::'w) ∈ (μ::('m × 'w) set)›*) ‹m' = m› (*‹m' = m›*) show "?thesis" (*goal: ‹∃w'. (m', w') ∈ μ - {(m, w') |w'. True} ∪ {(m, w)} ∧ w' ∈ m_weakly_prefers m' μ›*) unfolding m_weakly_prefers_def blocks_def m_strictly_prefers_def (*goal: ‹∃w'. (m', w') ∈ μ - {(m, w') |w'. True} ∪ {(m, w)} ∧ w' ∈ {w' ∈ Field (Pm m'). ∀w∈{w. (m', w) ∈ μ}. (w, w') ∈ Pm m'}›*) by blast next (*goal: ‹⟦(m', w') ∈ μ; m' ≠ m⟧ ⟹ ∃w'. (m', w') ∈ μ - {(m, w') |w'. True} ∪ {(m, w)} ∧ w' ∈ m_weakly_prefers m' μ›*) case False (*‹(m'::'m::finite) ≠ (m::'m::finite)›*) from Pm_pref (*‹∀m. Preorder (Pm m) ∧ Total (Pm m)›*) ‹simple μ› (*‹simple μ›*) ‹(m', w') ∈ μ› (*‹(m', w') ∈ μ›*) ‹m' ≠ m› (*‹m' ≠ m›*) show "?thesis" (*goal: ‹∃w'. (m', w') ∈ μ - {(m, w') |w'. True} ∪ {(m, w)} ∧ w' ∈ m_weakly_prefers m' μ›*) apply clarsimp (*goal: ‹∃w'. (m', w') ∈ μ - {(m, w') |w'. True} ∪ {(m, w)} ∧ w' ∈ m_weakly_prefers m' μ›*) by (meson m_weakly_prefers_Pm (*‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ (?w' ∈ m_weakly_prefers ?m ?μ) = ((?w, ?w') ∈ Pm ?m)›*) match_Field (*‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ ?w ∈ Field (Pm ?m)› ‹⟦match ?μ; (?m, ?w) ∈ ?μ⟧ ⟹ ?m ∈ Field (Pw ?w)›*) preorder_on_def (*‹preorder_on ?A ?r ≡ refl_on ?A ?r ∧ trans ?r›*) refl_onD (*‹⟦refl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∈ ?r›*) simple_match (*‹simple ?μ ⟹ match ?μ›*)) qed qed moreover from ‹blocks m w μ› (*‹blocks (m::'m::finite) (w::'w::finite) (μ::('m::finite × 'w::finite) set)›*) have "strictly_preferred_by_a_man μ ?μ'" unfolding strictly_preferred_by_a_man_def blocks_def (*goal: ‹∃ma. ∃w∈{wa. (ma, wa) ∈ μ - {(m, w') |w'. True} ∪ {(m, w)}}. w ∈ m_strictly_prefers ma μ›*) by blast moreover note ‹weakly_Pareto_optimal_for_men μ› (*‹weakly_Pareto_optimal_for_men μ›*) ultimately show False unfolding weakly_Pareto_optimal_for_men_def (*goal: ‹False›*) by blast qed theorem stable_ex: "∃μ. stable μ" using weakly_Pareto_optimal_for_men_stable (*‹weakly_Pareto_optimal_for_men ?μ ⟹ local.stable ?μ›*) weakly_Pareto_optimal_for_men_ex (*‹Ex weakly_Pareto_optimal_for_men›*) by blast text‹ We can exit the locale context and later re-enter it. › end text‹ We @{emph ‹interpret›} the locale by supplying constants that instantiate the variables we fixed earlier, and proving that these satisfy the assumptions. In this case we provide concrete preference orders, and by doing so we demonstrate that our theory is non-vacuous. We arbitrarily choose \<^citet>‹‹Example~2.15› in "RothSotomayor:1990"› which demonstrates the non-existence of man- or woman-optimal matches if preferences are non-strict. (We define optimality shortly.) The following bunch of types eases the description of this particular scenario. › datatype M = M1 | M2 | M3 datatype W = W1 | W2 | W3 lemma M_UNIV: "UNIV = set [M1, M2, M3]" using M.exhaust (*‹⟦?y = M1 ⟹ ?P; ?y = M2 ⟹ ?P; ?y = M3 ⟹ ?P⟧ ⟹ ?P›*) by auto lemma W_UNIV: "UNIV = set [W1, W2, W3]" using W.exhaust (*‹⟦?y = W1 ⟹ ?P; ?y = W2 ⟹ ?P; ?y = W3 ⟹ ?P⟧ ⟹ ?P›*) by auto instance M :: finite by standard (simp add: M_UNIV) instance W :: finite by standard (simp add: W_UNIV) lemma M_All: shows "(∀m. P m) ⟷ (∀m∈set [M1, M2, M3]. P m)" by (metis M_UNIV (*‹UNIV = set [M1, M2, M3]›*) UNIV_I (*‹(?x::?'a) ∈ UNIV›*)) lemma W_All: shows "(∀w. P w) ⟷ (∀w∈set [W1, W2, W3]. P w)" by (metis W_UNIV (*‹UNIV = set [W1, W2, W3]›*) UNIV_I (*‹?x ∈ UNIV›*)) primrec Pm :: "M ⇒ W rel" where "Pm M1 = { (W1, W1), (W1, W2), (W1, W3), (W2, W2), (W2, W3), (W3, W3), (W3, W2) }" | "Pm M2 = { (W1, W1), (W1, W2), (W2, W2) }" | "Pm M3 = { (W1, W1), (W1, W3), (W3, W3) }" primrec Pw :: "W ⇒ M rel" where "Pw W1 = { (M3, M3), (M3, M2), (M3, M1), (M2, M2), (M2, M1), (M1, M1) }" | "Pw W2 = { (M2, M2), (M2, M1), (M1, M1) }" | "Pw W3 = { (M3, M3), (M3, M1), (M1, M1) }" lemma Pm: "Preorder (Pm m) ∧ Total (Pm m)" sorry lemma Pw: "Preorder (Pw w) ∧ Total (Pw w)" unfolding preorder_on_def refl_on_def trans_def total_on_def (*goal: ‹((Pw w ⊆ Field (Pw w) × Field (Pw w) ∧ (∀x∈Field (Pw w). (x, x) ∈ Pw w)) ∧ (∀x y z. (x, y) ∈ Pw w ⟶ (y, z) ∈ Pw w ⟶ (x, z) ∈ Pw w)) ∧ (∀x∈Field (Pw w). ∀y∈Field (Pw w). x ≠ y ⟶ (x, y) ∈ Pw w ∨ (y, x) ∈ Pw w)›*) apply (cases w) (*goals: 1. ‹w = W1 ⟹ ((Pw w ⊆ Field (Pw w) × Field (Pw w) ∧ (∀x∈Field (Pw w). (x, x) ∈ Pw w)) ∧ (∀x y z. (x, y) ∈ Pw w ⟶ (y, z) ∈ Pw w ⟶ (x, z) ∈ Pw w)) ∧ (∀x∈Field (Pw w). ∀y∈Field (Pw w). x ≠ y ⟶ (x, y) ∈ Pw w ∨ (y, x) ∈ Pw w)› 2. ‹w = W2 ⟹ ((Pw w ⊆ Field (Pw w) × Field (Pw w) ∧ (∀x∈Field (Pw w). (x, x) ∈ Pw w)) ∧ (∀x y z. (x, y) ∈ Pw w ⟶ (y, z) ∈ Pw w ⟶ (x, z) ∈ Pw w)) ∧ (∀x∈Field (Pw w). ∀y∈Field (Pw w). x ≠ y ⟶ (x, y) ∈ Pw w ∨ (y, x) ∈ Pw w)› 3. ‹w = W3 ⟹ ((Pw w ⊆ Field (Pw w) × Field (Pw w) ∧ (∀x∈Field (Pw w). (x, x) ∈ Pw w)) ∧ (∀x y z. (x, y) ∈ Pw w ⟶ (y, z) ∈ Pw w ⟶ (x, z) ∈ Pw w)) ∧ (∀x∈Field (Pw w). ∀y∈Field (Pw w). x ≠ y ⟶ (x, y) ∈ Pw w ∨ (y, x) ∈ Pw w)› discuss goal 1*) apply ((safe)[1]) (*goals: 1. ‹⋀a b. ⟦w = W1; (a, b) ∈ Pw W1⟧ ⟹ a ∈ Field (Pw W1)› 2. ‹⋀a b. ⟦w = W1; (a, b) ∈ Pw W1⟧ ⟹ b ∈ Field (Pw W1)› 3. ‹⋀x. ⟦w = W1; x ∈ Field (Pw W1)⟧ ⟹ (x, x) ∈ Pw W1› 4. ‹⋀x y z. ⟦w = W1; (x, y) ∈ Pw W1; (y, z) ∈ Pw W1⟧ ⟹ (x, z) ∈ Pw W1› 5. ‹⋀x y. ⟦w = W1; x ∈ Field (Pw W1); y ∈ Field (Pw W1); x ≠ y; (y, x) ∉ Pw W1⟧ ⟹ (x, y) ∈ Pw W1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) (*discuss goal 2*) apply ((safe)[1]) (*goals: 1. ‹⋀(a::M) b::M. ⟦(w::W) = W2; (a, b) ∈ Pw W2⟧ ⟹ a ∈ Field (Pw W2)› 2. ‹⋀(a::M) b::M. ⟦(w::W) = W2; (a, b) ∈ Pw W2⟧ ⟹ b ∈ Field (Pw W2)› 3. ‹⋀x::M. ⟦(w::W) = W2; x ∈ Field (Pw W2)⟧ ⟹ (x, x) ∈ Pw W2› 4. ‹⋀(x::M) (y::M) z::M. ⟦(w::W) = W2; (x, y) ∈ Pw W2; (y, z) ∈ Pw W2⟧ ⟹ (x, z) ∈ Pw W2› 5. ‹⋀(x::M) y::M. ⟦(w::W) = W2; x ∈ Field (Pw W2); y ∈ Field (Pw W2); x ≠ y; (y, x) ∉ Pw W2⟧ ⟹ (x, y) ∈ Pw W2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) (*discuss goal 3*) apply ((safe)[1]) (*goals: 1. ‹⋀a b. ⟦w = W3; (a, b) ∈ Pw W3⟧ ⟹ a ∈ Field (Pw W3)› 2. ‹⋀a b. ⟦w = W3; (a, b) ∈ Pw W3⟧ ⟹ b ∈ Field (Pw W3)› 3. ‹⋀x. ⟦w = W3; x ∈ Field (Pw W3)⟧ ⟹ (x, x) ∈ Pw W3› 4. ‹⋀x y z. ⟦w = W3; (x, y) ∈ Pw W3; (y, z) ∈ Pw W3⟧ ⟹ (x, z) ∈ Pw W3› 5. ‹⋀x y. ⟦w = W3; x ∈ Field (Pw W3); y ∈ Field (Pw W3); x ≠ y; (y, x) ∉ Pw W3⟧ ⟹ (x, y) ∈ Pw W3› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) (*proven 3 subgoals*) . interpretation Non_Strict: StableMarriage Pm Pw using Pm (*‹Preorder (Pm ?m) ∧ Total (Pm ?m)›*) Pw (*‹Preorder (Pw ?w) ∧ Total (Pw ?w)›*) apply unfold_locales (*goals: 1. ‹⟦⋀m. Preorder (Pm m) ∧ Total (Pm m); ⋀w. Preorder (Pw w) ∧ Total (Pw w)⟧ ⟹ ∀m. Preorder (Pm m) ∧ Total (Pm m)› 2. ‹⟦⋀m. Preorder (Pm m) ∧ Total (Pm m); ⋀w. Preorder (Pw w) ∧ Total (Pw w)⟧ ⟹ ∀w. Preorder (Pw w) ∧ Total (Pw w)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . text‹ We demonstrate that there are only two stable matches in this scenario. Isabelle/HOL does not have any special support for these types of model checking problems, so we simply try all combinations of men and women. Clearly this does not scale, and for larger domains we need to be a bit cleverer (see \S\ref{sec:bossiness}). › lemma Non_Strict_stable1: shows "Non_Strict.stable {(M1, W2), (M2, W1), (M3, W3)}" unfolding Non_Strict.stable_def Non_Strict.match_def Non_Strict.blocks_def Non_Strict.m_strictly_prefers_def Non_Strict.w_strictly_prefers_def (*goal: ‹(inj_on fst {(M1, W2), (M2, W1), (M3, W3)} ∧ inj_on snd {(M1, W2), (M2, W1), (M3, W3)} ∧ {(M1, W2), (M2, W1), (M3, W3)} ⊆ (⋃m::M. {m} × Field (Pm m)) ∩ (⋃w::W. Field (Pw w) × {w})) ∧ (∀(m::M) w::W. ¬ (w ∈ {w'::W ∈ Field (Pm m). ∀w::W∈{w::W. (m, w) ∈ {(M1, W2), (M2, W1), (M3, W3)}}. (w, w') ∈ Pm m ∧ (w', w) ∉ Pm m} ∧ m ∈ {m'::M ∈ Field (Pw w). ∀m::M∈{m::M. (m, w) ∈ {(M1, W2), (M2, W1), (M3, W3)}}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}))›*) apply clarsimp (*goal: ‹(inj_on fst {(M1, W2), (M2, W1), (M3, W3)} ∧ inj_on snd {(M1, W2), (M2, W1), (M3, W3)} ∧ {(M1, W2), (M2, W1), (M3, W3)} ⊆ (⋃m. {m} × Field (Pm m)) ∩ (⋃w. Field (Pw w) × {w})) ∧ (∀m w. ¬ (w ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ {(M1, W2), (M2, W1), (M3, W3)}}. (w, w') ∈ Pm m ∧ (w', w) ∉ Pm m} ∧ m ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ {(M1, W2), (M2, W1), (M3, W3)}}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}))›*) by (metis M.exhaust (*‹⟦?y = M1 ⟹ ?P; ?y = M2 ⟹ ?P; ?y = M3 ⟹ ?P⟧ ⟹ ?P›*)) lemma Non_Strict_stable2: shows "Non_Strict.stable {(M1, W3), (M2, W2), (M3, W1)}" unfolding Non_Strict.stable_def Non_Strict.match_def Non_Strict.blocks_def Non_Strict.m_strictly_prefers_def Non_Strict.w_strictly_prefers_def (*goal: ‹(inj_on fst {(M1, W3), (M2, W2), (M3, W1)} ∧ inj_on snd {(M1, W3), (M2, W2), (M3, W1)} ∧ {(M1, W3), (M2, W2), (M3, W1)} ⊆ (⋃m. {m} × Field (Pm m)) ∩ (⋃w. Field (Pw w) × {w})) ∧ (∀m w. ¬ (w ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ {(M1, W3), (M2, W2), (M3, W1)}}. (w, w') ∈ Pm m ∧ (w', w) ∉ Pm m} ∧ m ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ {(M1, W3), (M2, W2), (M3, W1)}}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}))›*) apply clarsimp (*goal: ‹(inj_on fst {(M1, W3), (M2, W2), (M3, W1)} ∧ inj_on snd {(M1, W3), (M2, W2), (M3, W1)} ∧ {(M1, W3), (M2, W2), (M3, W1)} ⊆ (⋃m. {m} × Field (Pm m)) ∩ (⋃w. Field (Pw w) × {w})) ∧ (∀m w. ¬ (w ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ {(M1, W3), (M2, W2), (M3, W1)}}. (w, w') ∈ Pm m ∧ (w', w) ∉ Pm m} ∧ m ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ {(M1, W3), (M2, W2), (M3, W1)}}. (m, m') ∈ Pw w ∧ (m', m) ∉ Pw w}))›*) by (metis M.exhaust (*‹⟦?y = M1 ⟹ ?P; ?y = M2 ⟹ ?P; ?y = M3 ⟹ ?P⟧ ⟹ ?P›*)) lemma Non_Strict_stable_matches: "Non_Strict.stable μ ⟷ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}" (is "?lhs ⟷ ?rhs") proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹Non_Strict.stable μ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 2. ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)} ⟹ Non_Strict.stable μ›*) assume "?lhs" (*‹Non_Strict.stable (μ::(M × W) set)›*) have "μ ∈ set ` set (subseqs (List.product [M1, M2, M3] [W1, W2, W3]))" apply (subst subseqs_powset (*‹set ` set (subseqs ?xs) = Pow (set ?xs)›*)) (*goal: ‹(μ::(M × W) set) ∈ set ` set (subseqs (List.product [M1, M2, M3] [W1, W2, W3]))›*) apply clarsimp (*goal: ‹(μ::(M × W) set) ∈ Pow (set (List.product [M1, M2, M3] [W1, W2, W3]))›*) by (metis M.exhaust (*‹⟦?y = M1 ⟹ ?P; ?y = M2 ⟹ ?P; ?y = M3 ⟹ ?P⟧ ⟹ ?P›*) W.exhaust (*‹⟦?y = W1 ⟹ ?P; ?y = W2 ⟹ ?P; ?y = W3 ⟹ ?P⟧ ⟹ ?P›*)) with ‹?lhs› (*‹Non_Strict.stable μ›*) show "?rhs" unfolding Non_Strict.stable_def Non_Strict.match_def (*goal: ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}›*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*goal: ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}›*) apply (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 2. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 3. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 4. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 5. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 6. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 7. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 8. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 9. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 10. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 11. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 12. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 13. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 14. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 15. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 16. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 17. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 18. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 19. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 20. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 21. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 22. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 23. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 24. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 25. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 26. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 27. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 28. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 29. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 30. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 31. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 32. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 33. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 34. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 35. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 36. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 37. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 38. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 39. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 40. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 41. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 42. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 43. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 44. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 45. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 46. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 47. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 48. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 49. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 50. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 51. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 52. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 53. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 54. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 55. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 56. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 57. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 58. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 59. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 60. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 61. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 62. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 63. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 64. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M1, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 65. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 66. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 67. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 68. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 69. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 70. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 71. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 72. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 73. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 74. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 75. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 76. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 77. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 78. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 79. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 80. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 81. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 82. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 83. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 84. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 85. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 86. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 87. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 88. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 89. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 90. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 91. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 92. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 93. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 94. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 95. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 96. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 97. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 98. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 99. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 100. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 101. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 102. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 103. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 104. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 105. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 106. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 107. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 108. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 109. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 110. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 111. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 112. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 113. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 114. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 115. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 116. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 117. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 118. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 119. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 120. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 121. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 122. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 123. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 124. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 125. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 126. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 127. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 128. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 129. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 130. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 131. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 132. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 133. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 134. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 135. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 136. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 137. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 138. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 139. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 140. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 141. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 142. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 143. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 144. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 145. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 146. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 147. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 148. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 149. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 150. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 151. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 152. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 153. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 154. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 155. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 156. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 157. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 158. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 159. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 160. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 161. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 162. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 163. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 164. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 165. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 166. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 167. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 168. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 169. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 170. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 171. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 172. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 173. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 174. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 175. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 176. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 177. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 178. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 179. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 180. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 181. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 182. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 183. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 184. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 185. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 186. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 187. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 188. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 189. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 190. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 191. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 192. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M1, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 193. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 194. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 195. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 196. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 197. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 198. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 199. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 200. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 201. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 202. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 203. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 204. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 205. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 206. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 207. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 208. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 209. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 210. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 211. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 212. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 213. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 214. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 215. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 216. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 217. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 218. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 219. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 220. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 221. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 222. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 223. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 224. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 225. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 226. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 227. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 228. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 229. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 230. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 231. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 232. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 233. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 234. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 235. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 236. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 237. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 238. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 239. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 240. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 241. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 242. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 243. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 244. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 245. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 246. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 247. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 248. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 249. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 250. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 251. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 252. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 253. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 254. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 255. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 256. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 257. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 258. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 259. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 260. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 261. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 262. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 263. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 264. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 265. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 266. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 267. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 268. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 269. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 270. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 271. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 272. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 273. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 274. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 275. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 276. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 277. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 278. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 279. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 280. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 281. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 282. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 283. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 284. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 285. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 286. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 287. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 288. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 289. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 290. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 291. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 292. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 293. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 294. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 295. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 296. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 297. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 298. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 299. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 300. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 301. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 302. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 303. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 304. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 305. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 306. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 307. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 308. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 309. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 310. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 311. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 312. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 313. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 314. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 315. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 316. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 317. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 318. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 319. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 320. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M1, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 321. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 322. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 323. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 324. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 325. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 326. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 327. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 328. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 329. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 330. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 331. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 332. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 333. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 334. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 335. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 336. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 337. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 338. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 339. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 340. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 341. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 342. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 343. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 344. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 345. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 346. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 347. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 348. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 349. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 350. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 351. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 352. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 353. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 354. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 355. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 356. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 357. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 358. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 359. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 360. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 361. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 362. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 363. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 364. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 365. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 366. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 367. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 368. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 369. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 370. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 371. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 372. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 373. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 374. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 375. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 376. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 377. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 378. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 379. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 380. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 381. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 382. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 383. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 384. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 385. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 386. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 387. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 388. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 389. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 390. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 391. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 392. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 393. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 394. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 395. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 396. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 397. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 398. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 399. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 400. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 401. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 402. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 403. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 404. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 405. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 406. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 407. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 408. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 409. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 410. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 411. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 412. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 413. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 414. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 415. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 416. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 417. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 418. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 419. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 420. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 421. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 422. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 423. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 424. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 425. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 426. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 427. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 428. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 429. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 430. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 431. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 432. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 433. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 434. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 435. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 436. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 437. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 438. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 439. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 440. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 441. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 442. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 443. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 444. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 445. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 446. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 447. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 448. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 449. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 450. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 451. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 452. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 453. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 454. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 455. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 456. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 457. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 458. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 459. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 460. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 461. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 462. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 463. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 464. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 465. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 466. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 467. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 468. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 469. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 470. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 471. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 472. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 473. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 474. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 475. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 476. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 477. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 478. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 479. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 480. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 481. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 482. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 483. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 484. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 485. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 486. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 487. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 488. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 489. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 490. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 491. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 492. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 493. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 494. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 495. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 496. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 497. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 498. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 499. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 500. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 501. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 502. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 503. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 504. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 505. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W1), (M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 506. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W1), (M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 507. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 508. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 509. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 510. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 511. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› 512. ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› discuss goal 1*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 2*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 3*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 4*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 5*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 6*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 7*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 8*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 9*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 10*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 11*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 12*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 13*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 14*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 15*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 16*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 17*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 18*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 19*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 20*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 21*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 22*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 23*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 24*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 25*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 26*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 27*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 28*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 29*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 30*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 31*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 32*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 33*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 34*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 35*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 36*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 37*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 38*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 39*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 40*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 41*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 42*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 43*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 44*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 45*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 46*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 47*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 48*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 49*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 50*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 51*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 52*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 53*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 54*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 55*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 56*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 57*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 58*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 59*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 60*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 61*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 62*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 63*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 64*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 65*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 66*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 67*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 68*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 69*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 70*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 71*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 72*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 73*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 74*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 75*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 76*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 77*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 78*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 79*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 80*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 81*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 82*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 83*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 84*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 85*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 86*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 87*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 88*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 89*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 90*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 91*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 92*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 93*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 94*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 95*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 96*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 97*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 98*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 99*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 100*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 101*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 102*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 103*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 104*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 105*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 106*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 107*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 108*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 109*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 110*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 111*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 112*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 113*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 114*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 115*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 116*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 117*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 118*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 119*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 120*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 121*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 122*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 123*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 124*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 125*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 126*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 127*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 128*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 129*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 130*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 131*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 132*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 133*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 134*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 135*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 136*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 137*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 138*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 139*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 140*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 141*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 142*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 143*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 144*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 145*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 146*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 147*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 148*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 149*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 150*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 151*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 152*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 153*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 154*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 155*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 156*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 157*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 158*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 159*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 160*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 161*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 162*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 163*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 164*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 165*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 166*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 167*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 168*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 169*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 170*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 171*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 172*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 173*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 174*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 175*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 176*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 177*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 178*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 179*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 180*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 181*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 182*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 183*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 184*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 185*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 186*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 187*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 188*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 189*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 190*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 191*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 192*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 193*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 194*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 195*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 196*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 197*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 198*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 199*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 200*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 201*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 202*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 203*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 204*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 205*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 206*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 207*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 208*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 209*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 210*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 211*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 212*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 213*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 214*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 215*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 216*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 217*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 218*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 219*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 220*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 221*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 222*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 223*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 224*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 225*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 226*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 227*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 228*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 229*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 230*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 231*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 232*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 233*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 234*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 235*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 236*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 237*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 238*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 239*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 273 goals remain*) apply (simp add: M_All (*‹(∀m::M. (?P::M ⇒ bool) m) = (∀m::M∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w::W. (?P::W ⇒ bool) w) = (∀w::W∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks (?m::M) (?w::W) (?μ::(M × W) set) = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers (?m::M) (?μ::(M × W) set) = {w'::W ∈ Field (Pm ?m). ∀w::W∈{w::W. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers (?w::W) (?μ::(M × W) set) = {m'::M ∈ Field (Pw ?w). ∀m::M∈{m::M. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 240*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 272 goals remain*) apply (simp add: M_All (*‹(∀m::M. (?P::M ⇒ bool) m) = (∀m::M∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w::W. (?P::W ⇒ bool) w) = (∀w::W∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks (?m::M) (?w::W) (?μ::(M × W) set) = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers (?m::M) (?μ::(M × W) set) = {w'::W ∈ Field (Pm ?m). ∀w::W∈{w::W. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers (?w::W) (?μ::(M × W) set) = {m'::M ∈ Field (Pw ?w). ∀m::M∈{m::M. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 241*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 242*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 243*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 244*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 245*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 246*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 247*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 248*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 249*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 250*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 251*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 252*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 253*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 254*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 255*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 257 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 256*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 256 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 257*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 258*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 259*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 260*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 261*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 262*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 263*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 264*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 265*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 266*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 267*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 268*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 269*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 270*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 271*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 272*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 273*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 274*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 275*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 276*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 277*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 278*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 279*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 280*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 281*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 282*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 283*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 284*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 285*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 286*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 287*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 288*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 289*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 290*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 291*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 292*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 293*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 294*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 295*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 296*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 297*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 298*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 299*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 300*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 301*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 302*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 303*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 304*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 305*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 306*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 307*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 308*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 309*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 310*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 311*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 312*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 313*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 314*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 315*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 316*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 317*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 318*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 319*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 320*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 321*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 322*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 323*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 324*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 325*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 326*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 327*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 328*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 329*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 330*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 331*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 332*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 333*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 334*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 335*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 336*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 337*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 338*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 339*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 340*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 341*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 342*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 343*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 344*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 345*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 346*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 347*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 348*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 349*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 350*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 351*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 352*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 160 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 353*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 354*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 355*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 356*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 357*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 358*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 359*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 360*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 361*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 362*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 363*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 364*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 365*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 366*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 367*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 368*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 369*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 370*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 371*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 372*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 373*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 374*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 375*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 376*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 377*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 378*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 379*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 380*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 132 goals remain*) apply (simp add: M_All (*‹(∀m::M. (?P::M ⇒ bool) m) = (∀m::M∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w::W. (?P::W ⇒ bool) w) = (∀w::W∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks (?m::M) (?w::W) (?μ::(M × W) set) = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers (?m::M) (?μ::(M × W) set) = {w'::W ∈ Field (Pm ?m). ∀w::W∈{w::W. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers (?w::W) (?μ::(M × W) set) = {m'::M ∈ Field (Pw ?w). ∀m::M∈{m::M. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 381*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 382*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 383*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 129 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 384*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 128 goals remain*) apply (simp add: M_All (*‹(∀m::M. (?P::M ⇒ bool) m) = (∀m::M∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w::W. (?P::W ⇒ bool) w) = (∀w::W∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks (?m::M) (?w::W) (?μ::(M × W) set) = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers (?m::M) (?μ::(M × W) set) = {w'::W ∈ Field (Pm ?m). ∀w::W∈{w::W. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers (?w::W) (?μ::(M × W) set) = {m'::M ∈ Field (Pw ?w). ∀m::M∈{m::M. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 385*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 386*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 387*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 388*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 389*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 390*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 391*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 392*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 393*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 394*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 395*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 396*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 397*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 398*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 399*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 400*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 401*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 402*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 403*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 404*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 405*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 406*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 407*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 408*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 409*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 410*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 411*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 412*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 413*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 414*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 415*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 416*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 96 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 417*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 418*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 419*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 420*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 421*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 422*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 423*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 424*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 425*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 426*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 427*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 428*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 429*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 430*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 431*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 432*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 80 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 433*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 434*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 435*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 436*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 437*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 438*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 439*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 440*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 441*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 442*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 443*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 444*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 68 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 445*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 446*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 447*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 448*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M1, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 64 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 449*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 450*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 451*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 452*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 453*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 454*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 455*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 456*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 457*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 458*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 459*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 460*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 461*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 462*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 463*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 464*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 465*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 466*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 467*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 468*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 469*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 470*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 471*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 472*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 473*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 474*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 475*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 476*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 477*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 478*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 479*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 33 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 480*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M2, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 32 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 481*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 482*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 483*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 484*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 485*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 486*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 487*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 488*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 489*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 490*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 491*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 492*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Inf) x = (?D::?'b::type ⇒ ?'a::Inf) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B =simp=> (?C::?'b::type ⇒ ?'a::Sup) x = (?D::?'b::type ⇒ ?'a::Sup) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a::type set) = (?N::?'a::type set); ⋀x::?'a::type. x ∈ ?N =simp=> (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst (μ::(M × W) set) ∧ inj_on snd μ ∧ μ ⊆ (⋃m::M. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w::W. Field (Pw w) × {w}) ∧ (∀(m::M) w::W. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 20 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 493*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 494*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 495*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2), (M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 17 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 496*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M2, W2)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 16 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 497*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 498*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 499*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 500*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 501*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 502*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 503*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 504*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 505*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 506*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 507*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 508*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M3, W1)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 4 goals remain*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 509*) apply (simp cong: INF_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B =simp=> (?C::?'b ⇒ ?'a) x = (?D::?'b ⇒ ?'a) x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦(?M::?'a set) = (?N::?'a set); ⋀x::?'a. x ∈ ?N =simp=> (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 510*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 511*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*top goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {(M3, W3)}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}› and 1 goal remains*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*discuss goal 512*) apply (simp cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*goal: ‹⟦inj_on fst μ ∧ inj_on snd μ ∧ μ ⊆ (⋃m. {m} × Field (Pm m)) ∧ μ ⊆ (⋃w. Field (Pw w) × {w}) ∧ (∀m w. ¬ Non_Strict.blocks m w μ); μ = {}⟧ ⟹ μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}›*) apply (simp add: M_All (*‹(∀m. ?P m) = (∀m∈set [M1, M2, M3]. ?P m)›*) W_All (*‹(∀w. ?P w) = (∀w∈set [W1, W2, W3]. ?P w)›*) Non_Strict.blocks_def (*‹Non_Strict.blocks ?m ?w ?μ = (?w ∈ Non_Strict.m_strictly_prefers ?m ?μ ∧ ?m ∈ Non_Strict.w_strictly_prefers ?w ?μ)›*) Non_Strict.m_strictly_prefers_def (*‹Non_Strict.m_strictly_prefers ?m ?μ = {w' ∈ Field (Pm ?m). ∀w∈{w. (?m, w) ∈ ?μ}. (w, w') ∈ Pm ?m ∧ (w', w) ∉ Pm ?m}›*) Non_Strict.w_strictly_prefers_def (*‹Non_Strict.w_strictly_prefers ?w ?μ = {m' ∈ Field (Pw ?w). ∀m∈{m. (m, ?w) ∈ ?μ}. (m, m') ∈ Pw ?w ∧ (m', m) ∉ Pw ?w}›*) cong: INF_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Inf (?C ` ?A) = Inf (?D ` ?B)›*) SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) (*proven 512 subgoals*) . next (*goal: ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)} ⟹ Non_Strict.stable μ›*) assume "?rhs" (*‹(μ::(M × W) set) = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}›*) with Non_Strict_stable1 (*‹Non_Strict.stable {(M1, W2), (M2, W1), (M3, W3)}›*) Non_Strict_stable2 (*‹Non_Strict.stable {(M1, W3), (M2, W2), (M3, W1)}›*) show "?lhs" by blast qed text‹ So far the only interesting result in this interpretation of ‹StableMarriage› is the @{thm [source] "Non_Strict.stable_ex"} theorem, i.e., that there is a stable match. We now add the notion of @{emph ‹optimality›} to our locale, and all interpretations will automatically inherit it. Later we will also extend locales by adding new fixed variables and assumptions. Following \<^citet>‹‹Definition~2.11› in "RothSotomayor:1990"›, a stable match is @{emph ‹optimal for men›} if every man likes it at least as much as any other stable match (and similarly for an @{emph ‹optimal for women›} match). › context StableMarriage begin definition optimal_for_men :: "('m, 'w) match ⇒ bool" where "optimal_for_men μ ⟷ stable μ ∧ (∀μ'. stable μ' ⟶ weakly_preferred_by_men μ' μ)" definition w_weakly_prefers :: "'w ⇒ ('m, 'w) match ⇒ 'm set" where "w_weakly_prefers w μ = {m' ∈ Field (Pw w). ∀m∈m_for w μ. (m, m') ∈ Pw w}" definition weakly_preferred_by_women :: "('m, 'w) match ⇒ ('m, 'w) match ⇒ bool" where "weakly_preferred_by_women μ μ' ⟷ (∀w. ∀m∈m_for w μ. ∃m'∈m_for w μ'. m' ∈ w_weakly_prefers w μ)" definition optimal_for_women :: "('m, 'w) match ⇒ bool" where "optimal_for_women μ ⟷ stable μ ∧ (∀μ'. stable μ' ⟶ weakly_preferred_by_women μ μ')" end text‹ We can show that there is no optimal stable match for these preferences: › lemma NonStrict_not_optimal: assumes "Non_Strict.stable μ" shows "¬Non_Strict.optimal_for_men μ ∧ ¬Non_Strict.optimal_for_women μ" proof (-) (*goal: ‹¬ Non_Strict.optimal_for_men μ ∧ ¬ Non_Strict.optimal_for_women μ›*) from assms[unfolded Non_Strict_stable_matches] (*‹μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}›*) show "?thesis" (*goal: ‹¬ Non_Strict.optimal_for_men (μ::(M × W) set) ∧ ¬ Non_Strict.optimal_for_women μ›*) proof (rule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹(μ::(M × W) set) = {(M1, W2), (M2, W1), (M3, W3)} ⟹ ¬ Non_Strict.optimal_for_men μ ∧ ¬ Non_Strict.optimal_for_women μ› 2. ‹(μ::(M × W) set) = {(M1, W3), (M2, W2), (M3, W1)} ⟹ ¬ Non_Strict.optimal_for_men μ ∧ ¬ Non_Strict.optimal_for_women μ›*) assume "μ = {(M1, W2), (M2, W1), (M3, W3)}" (*‹(μ::(M × W) set) = {(M1, W2), (M2, W1), (M3, W3)}›*) with assms (*‹Non_Strict.stable μ›*) show "?thesis" (*goal: ‹¬ Non_Strict.optimal_for_men (μ::(M × W) set) ∧ ¬ Non_Strict.optimal_for_women μ›*) unfolding Non_Strict.optimal_for_men_def Non_Strict.weakly_preferred_by_men_def Non_Strict.m_weakly_prefers_def Non_Strict.optimal_for_women_def Non_Strict.weakly_preferred_by_women_def Non_Strict.w_weakly_prefers_def Non_Strict_stable_matches (*goal: ‹¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀m. ∀w∈{w. (m, w) ∈ μ'}. ∃w'∈{w. (m, w) ∈ μ}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ'}. (w, w') ∈ Pm m}))) ∧ ¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀w. ∀m∈{m. (m, w) ∈ μ}. ∃m'∈{m. (m, w) ∈ μ'}. m' ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w})))›*) apply clarsimp (*goal: ‹¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀m. ∀w∈{w. (m, w) ∈ μ'}. ∃w'∈{w. (m, w) ∈ μ}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ'}. (w, w') ∈ Pm m}))) ∧ ¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀w. ∀m∈{m. (m, w) ∈ μ}. ∃m'∈{m. (m, w) ∈ μ'}. m' ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w})))›*) apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ⟹ ∃μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃m. (∃w. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀w'. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W2) ∧ (m = M2 ⟶ w' ≠ W1) ∧ (m = M3 ⟶ w' ≠ W3) ∨ (∃w. m = M1 ∧ w = W2 ∧ w' ≠ W2 ∧ w' ≠ W3 ∨ m = M2 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W3 ∧ w' ≠ W3))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃m. (∃w. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀w'. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W2) ∧ (m = M2 ⟶ w' ≠ W1) ∧ (m = M3 ⟶ w' ≠ W3) ∨ (∃w. m = M1 ∧ w = W3 ∧ w' ≠ W3 ∧ w' ≠ W2 ∨ m = M2 ∧ w = W2 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W3)))› 2. ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ⟹ ∃μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃w. (∃m. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀m'. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W2) ∧ (m' = M2 ⟶ w ≠ W1) ∧ (m' = M3 ⟶ w ≠ W3) ∨ (∃m. m = M1 ∧ w = W2 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W1 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W3 ∧ m' ≠ M3 ∧ m' ≠ M1))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃w. (∃m. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀m'. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W3) ∧ (m' = M2 ⟶ w ≠ W2) ∧ (m' = M3 ⟶ w ≠ W1) ∨ (∃m. m = M1 ∧ w = W2 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W1 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W3 ∧ m' ≠ M3 ∧ m' ≠ M1)))› discuss goal 1*) apply (rule exI[where x="{(M1, W3), (M2, W2), (M3, W1)}"] (*‹?P {(M1, W3), (M2, W2), (M3, W1)} ⟹ ∃x. ?P x›*)) (*top goal: ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ⟹ ∃μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃m. (∃w. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀w'. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W2) ∧ (m = M2 ⟶ w' ≠ W1) ∧ (m = M3 ⟶ w' ≠ W3) ∨ (∃w. m = M1 ∧ w = W2 ∧ w' ≠ W2 ∧ w' ≠ W3 ∨ m = M2 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W3 ∧ w' ≠ W3))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃m. (∃w. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀w'. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W2) ∧ (m = M2 ⟶ w' ≠ W1) ∧ (m = M3 ⟶ w' ≠ W3) ∨ (∃w. m = M1 ∧ w = W3 ∧ w' ≠ W3 ∧ w' ≠ W2 ∨ m = M2 ∧ w = W2 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W3)))› and 1 goal remains*) apply blast (*discuss goal 2*) apply (rule exI[where x="{(M1, W3), (M2, W2), (M3, W1)}"] (*‹?P {(M1, W3), (M2, W2), (M3, W1)} ⟹ ∃x. ?P x›*)) (*goal: ‹μ = {(M1, W2), (M2, W1), (M3, W3)} ⟹ ∃μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃w. (∃m. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀m'. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W2) ∧ (m' = M2 ⟶ w ≠ W1) ∧ (m' = M3 ⟶ w ≠ W3) ∨ (∃m. m = M1 ∧ w = W2 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W1 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W3 ∧ m' ≠ M3 ∧ m' ≠ M1))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃w. (∃m. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀m'. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W3) ∧ (m' = M2 ⟶ w ≠ W2) ∧ (m' = M3 ⟶ w ≠ W1) ∨ (∃m. m = M1 ∧ w = W2 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W1 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W3 ∧ m' ≠ M3 ∧ m' ≠ M1)))›*) apply blast (*proven 2 subgoals*) . next (*goal: ‹μ = {(M1, W3), (M2, W2), (M3, W1)} ⟹ ¬ Non_Strict.optimal_for_men μ ∧ ¬ Non_Strict.optimal_for_women μ›*) assume "μ = {(M1, W3), (M2, W2), (M3, W1)}" (*‹(μ::(M × W) set) = {(M1, W3), (M2, W2), (M3, W1)}›*) with assms (*‹Non_Strict.stable (μ::(M × W) set)›*) show "?thesis" (*goal: ‹¬ Non_Strict.optimal_for_men μ ∧ ¬ Non_Strict.optimal_for_women μ›*) unfolding Non_Strict.optimal_for_men_def Non_Strict.weakly_preferred_by_men_def Non_Strict.m_weakly_prefers_def Non_Strict.optimal_for_women_def Non_Strict.weakly_preferred_by_women_def Non_Strict.w_weakly_prefers_def Non_Strict_stable_matches (*goal: ‹¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀m. ∀w∈{w. (m, w) ∈ μ'}. ∃w'∈{w. (m, w) ∈ μ}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ'}. (w, w') ∈ Pm m}))) ∧ ¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀w. ∀m∈{m. (m, w) ∈ μ}. ∃m'∈{m. (m, w) ∈ μ'}. m' ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w})))›*) apply clarsimp (*goal: ‹¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀m. ∀w∈{w. (m, w) ∈ μ'}. ∃w'∈{w. (m, w) ∈ μ}. w' ∈ {w' ∈ Field (Pm m). ∀w∈{w. (m, w) ∈ μ'}. (w, w') ∈ Pm m}))) ∧ ¬ ((μ = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ = {(M1, W3), (M2, W2), (M3, W1)}) ∧ (∀μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ⟶ (∀w. ∀m∈{m. (m, w) ∈ μ}. ∃m'∈{m. (m, w) ∈ μ'}. m' ∈ {m' ∈ Field (Pw w). ∀m∈{m. (m, w) ∈ μ}. (m, m') ∈ Pw w})))›*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹(μ::(M × W) set) = {(M1, W3), (M2, W2), (M3, W1)} ⟹ ∃μ'::(M × W) set. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃m::M. (∃w::W. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀w'::W. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W3) ∧ (m = M2 ⟶ w' ≠ W2) ∧ (m = M3 ⟶ w' ≠ W1) ∨ (∃w::W. m = M1 ∧ w = W2 ∧ w' ≠ W2 ∧ w' ≠ W3 ∨ m = M2 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W3 ∧ w' ≠ W3))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃m::M. (∃w::W. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀w'::W. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W3) ∧ (m = M2 ⟶ w' ≠ W2) ∧ (m = M3 ⟶ w' ≠ W1) ∨ (∃w::W. m = M1 ∧ w = W3 ∧ w' ≠ W3 ∧ w' ≠ W2 ∨ m = M2 ∧ w = W2 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W3)))› 2. ‹(μ::(M × W) set) = {(M1, W3), (M2, W2), (M3, W1)} ⟹ ∃μ'::(M × W) set. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃w::W. (∃m::M. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀m'::M. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W2) ∧ (m' = M2 ⟶ w ≠ W1) ∧ (m' = M3 ⟶ w ≠ W3) ∨ (∃m::M. m = M1 ∧ w = W3 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W2 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W1 ∧ m' ≠ M3 ∧ m' ≠ M2 ∧ m' ≠ M1))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃w::W. (∃m::M. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀m'::M. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W3) ∧ (m' = M2 ⟶ w ≠ W2) ∧ (m' = M3 ⟶ w ≠ W1) ∨ (∃m::M. m = M1 ∧ w = W3 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W2 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W1 ∧ m' ≠ M3 ∧ m' ≠ M2 ∧ m' ≠ M1)))› discuss goal 1*) apply (rule exI[where x="{(M1, W2), (M2, W1), (M3, W3)}"] (*‹?P {(M1, W2), (M2, W1), (M3, W3)} ⟹ ∃x. ?P x›*)) (*top goal: ‹μ = {(M1, W3), (M2, W2), (M3, W1)} ⟹ ∃μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃m. (∃w. m = M1 ∧ w = W2 ∨ m = M2 ∧ w = W1 ∨ m = M3 ∧ w = W3) ∧ (∀w'. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W3) ∧ (m = M2 ⟶ w' ≠ W2) ∧ (m = M3 ⟶ w' ≠ W1) ∨ (∃w. m = M1 ∧ w = W2 ∧ w' ≠ W2 ∧ w' ≠ W3 ∨ m = M2 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W3 ∧ w' ≠ W3))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃m. (∃w. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀w'. w' ∈ Field (Pm m) ⟶ (m = M1 ⟶ w' ≠ W3) ∧ (m = M2 ⟶ w' ≠ W2) ∧ (m = M3 ⟶ w' ≠ W1) ∨ (∃w. m = M1 ∧ w = W3 ∧ w' ≠ W3 ∧ w' ≠ W2 ∨ m = M2 ∧ w = W2 ∧ w' ≠ W2 ∨ m = M3 ∧ w = W1 ∧ w' ≠ W1 ∧ w' ≠ W3)))› and 1 goal remains*) apply blast (*discuss goal 2*) apply (rule exI[where x="{(M1, W2), (M2, W1), (M3, W3)}"] (*‹?P {(M1, W2), (M2, W1), (M3, W3)} ⟹ ∃x. ?P x›*)) (*goal: ‹μ = {(M1, W3), (M2, W2), (M3, W1)} ⟹ ∃μ'. μ' = {(M1, W2), (M2, W1), (M3, W3)} ∧ (∃w. (∃m. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀m'. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W2) ∧ (m' = M2 ⟶ w ≠ W1) ∧ (m' = M3 ⟶ w ≠ W3) ∨ (∃m. m = M1 ∧ w = W3 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W2 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W1 ∧ m' ≠ M3 ∧ m' ≠ M2 ∧ m' ≠ M1))) ∨ μ' = {(M1, W3), (M2, W2), (M3, W1)} ∧ (∃w. (∃m. m = M1 ∧ w = W3 ∨ m = M2 ∧ w = W2 ∨ m = M3 ∧ w = W1) ∧ (∀m'. m' ∈ Field (Pw w) ⟶ (m' = M1 ⟶ w ≠ W3) ∧ (m' = M2 ⟶ w ≠ W2) ∧ (m' = M3 ⟶ w ≠ W1) ∨ (∃m. m = M1 ∧ w = W3 ∧ m' ≠ M1 ∨ m = M2 ∧ w = W2 ∧ m' ≠ M2 ∧ m' ≠ M1 ∨ m = M3 ∧ w = W1 ∧ m' ≠ M3 ∧ m' ≠ M2 ∧ m' ≠ M1)))›*) apply blast (*proven 2 subgoals*) . qed qed text‹ \<^citet>‹"Sotomayor:1996"› remarks that, if the preferences are strict, there is only one weakly Pareto optimal match for men, and that it is man-optimal. (This is the match found by the classic man-proposing deferred acceptance algorithm due to \<^citet>‹"GaleShapley:1962"›.) However she omits a proof that the man-optimal match actually exists under strict preferences. The easiest way to show this and further results is to exhibit the lattice structure of the stable matches discovered by Conway (see \<^citet>‹‹Theorem~2.16› in "RothSotomayor:1990"›), where the men- and women-optimal matches are the extremal points. This suggests looking for a monotonic function whose fixed points are this lattice, which is the essence of the analysis of matching with contracts in \S\ref{sec:contracts}. › (*<*) end (*>*)
{ "path": "afp-2025-02-12/thys/Stable_Matching/Sotomayor.thy", "repo": "afp-2025-02-12", "sha": "e145f57de54621ac5756031553c9150293deeee4a33709ea86ef24f495127aa3" }
(* File: IMO2019_Q5.thy Author: Manuel Eberl, TU München *) section ‹Q5› theory IMO2019_Q5 imports Complex_Main begin text ‹ Given a sequence $(c_1,\ldots, c_n)$ of coins, each of which can be heads (‹H›) or tails (‹T›), Harry performs the following process: Let ‹k› be the number of coins that show ‹H›. If ‹k > 0›, flip the ‹k›-th coin and repeat the process. Otherwise, stop. What is the average number of steps that this process takes, averaged over all $2^n$ coin sequences of length ‹n›? › subsection ‹Definition› text ‹ We represent coins as Booleans, where @{term True} indicates ‹H› and @{term False} indicates ‹T›. Coin sequences are then simply lists of Booleans. The following function flips the ‹i›-th coin in the sequence (in Isabelle, the convention is that the first list element is indexed with 0). › definition flip :: "bool list ⇒ nat ⇒ bool list" where "flip xs i = xs[i := ¬xs ! i]" lemma flip_Cons_pos [simp]: "n > 0 ⟹ flip (x # xs) n = x # flip xs (n - 1)" apply (cases n) (*goals: 1. ‹⟦0 < n; n = 0⟧ ⟹ flip (x # xs) n = x # flip xs (n - 1)› 2. ‹⋀nat. ⟦0 < n; n = Suc nat⟧ ⟹ flip (x # xs) n = x # flip xs (n - 1)› discuss goal 1*) apply ((auto simp: flip_def (*‹flip ?xs ?i = ?xs[?i := ¬ ?xs ! ?i]›*))[1]) (*discuss goal 2*) apply ((auto simp: flip_def (*‹flip ?xs ?i = ?xs[?i := ¬ ?xs ! ?i]›*))[1]) (*proven 2 subgoals*) . lemma flip_Cons_0 [simp]: "flip (x # xs) 0 = (¬x) # xs" by (simp add: flip_def (*‹flip ?xs ?i = ?xs[?i := ¬ ?xs ! ?i]›*)) lemma flip_append1 [simp]: "n < length xs ⟹ flip (xs @ ys) n = flip xs n @ ys" and flip_append2 [simp]: "n ≥ length xs ⟹ n < length xs + length ys ⟹ flip (xs @ ys) n = xs @ flip ys (n - length xs)" (*goals: 1. ‹n < length xs ⟹ flip (xs @ ys) n = flip xs n @ ys› 2. ‹⟦length xs ≤ n; n < length xs + length ys⟧ ⟹ flip (xs @ ys) n = xs @ flip ys (n - length xs)› discuss goal 1*) apply ((auto simp: flip_def (*‹flip ?xs ?i = ?xs[?i := ¬ ?xs ! ?i]›*) list_update_append (*‹(?xs @ ?ys)[?n := ?x] = (if ?n < length ?xs then ?xs[?n := ?x] @ ?ys else ?xs @ ?ys[?n - length ?xs := ?x])›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*))[1]) (*discuss goal 2*) apply ((auto simp: flip_def (*‹flip (?xs::bool list) (?i::nat) = ?xs[?i := ¬ ?xs ! ?i]›*) list_update_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list))[?n::nat := ?x::?'a::type] = (if ?n < length ?xs then ?xs[?n := ?x] @ ?ys else ?xs @ ?ys[?n - length ?xs := ?x])›*) nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*))[1]) (*proven 2 subgoals*) . lemma length_flip [simp]: "length (flip xs i) = length xs" by (simp add: flip_def (*‹flip ?xs ?i = ?xs[?i := ¬ ?xs ! ?i]›*)) text ‹ The following function computes the number of ‹H› in a coin sequence. › definition heads :: "bool list ⇒ nat" where "heads xs = length (filter id xs)" lemma heads_True [simp]: "heads (True # xs) = 1 + heads xs" and heads_False [simp]: "heads (False # xs) = heads xs" and heads_append [simp]: "heads (xs @ ys) = heads xs + heads ys" and heads_Nil [simp]: "heads [] = 0" (*goals: 1. ‹heads (True # xs) = 1 + heads xs› 2. ‹heads (False # xs) = heads xs› 3. ‹heads (xs @ ys) = heads xs + heads ys› 4. ‹heads [] = 0› discuss goal 1*) apply ((auto simp: heads_def (*‹heads (?xs::bool list) = length (filter id ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: heads_def (*‹heads ?xs = length (filter id ?xs)›*))[1]) (*discuss goal 3*) apply ((auto simp: heads_def (*‹heads ?xs = length (filter id ?xs)›*))[1]) (*discuss goal 4*) apply ((auto simp: heads_def (*‹heads ?xs = length (filter id ?xs)›*))[1]) (*proven 4 subgoals*) . lemma heads_Cons: "heads (x # xs) = (if x then heads xs + 1 else heads xs)" by (auto simp: heads_def (*‹heads ?xs = length (filter id ?xs)›*)) lemma heads_pos: "True ∈ set xs ⟹ heads xs > 0" apply (induction xs) (*goals: 1. ‹True ∈ set [] ⟹ (0::nat) < heads []› 2. ‹⋀(a::bool) xs::bool list. ⟦True ∈ set xs ⟹ (0::nat) < heads xs; True ∈ set (a # xs)⟧ ⟹ (0::nat) < heads (a # xs)› discuss goal 1*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*proven 2 subgoals*) . lemma heads_eq_0 [simp]: "True ∉ set xs ⟹ heads xs = 0" apply (induction xs) (*goals: 1. ‹True ∉ set [] ⟹ heads [] = 0› 2. ‹⋀a xs. ⟦True ∉ set xs ⟹ heads xs = 0; True ∉ set (a # xs)⟧ ⟹ heads (a # xs) = 0› discuss goal 1*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*proven 2 subgoals*) . lemma heads_eq_0_iff [simp]: "heads xs = 0 ⟷ True ∉ set xs" apply (induction xs) (*goals: 1. ‹(heads [] = 0) = (True ∉ set [])› 2. ‹⋀a xs. (heads xs = 0) = (True ∉ set xs) ⟹ (heads (a # xs) = 0) = (True ∉ set (a # xs))› discuss goal 1*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*proven 2 subgoals*) . lemma heads_pos_iff [simp]: "heads xs > 0 ⟷ True ∈ set xs" apply (induction xs) (*goals: 1. ‹(0 < heads []) = (True ∈ set [])› 2. ‹⋀a xs. (0 < heads xs) = (True ∈ set xs) ⟹ (0 < heads (a # xs)) = (True ∈ set (a # xs))› discuss goal 1*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: heads_Cons (*‹heads (?x # ?xs) = (if ?x then heads ?xs + 1 else heads ?xs)›*))[1]) (*proven 2 subgoals*) . lemma heads_le_length: "heads xs ≤ length xs" by (auto simp: heads_def (*‹heads (?xs::bool list) = length (filter id ?xs)›*)) text ‹ The following function performs a single step of Harry's process. › definition harry_step :: "bool list ⇒ bool list" where "harry_step xs = flip xs (heads xs - 1)" lemma length_harry_step [simp]: "length (harry_step xs) = length xs" by (simp add: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*)) text ‹ The following is the measure function for Harry's process, i.e. how many steps the process takes to terminate starting from the given sequence. We define it like this now and prove the correctness later. › function harry_meas where "harry_meas xs = (if xs = [] then 0 else if hd xs then 1 + harry_meas (tl xs) else if ¬last xs then harry_meas (butlast xs) else let n = length xs in harry_meas (take (n - 2) (tl xs)) + 2 * n - 1)" by auto termination by (relation "Wellfounded.measure length") (auto simp: min_def) lemmas [simp del] = harry_meas.simps text ‹ We now prove some simple properties of @{const harry_meas} and @{const harry_step}. › text ‹ We prove a more convenient case distinction rule for lists that allows us to distinguish between lists starting with @{term True}, ending with @{term False}, and starting with @{term False} and ending with @{term True}. › lemma head_last_cases [case_names Nil True False False_True]: assumes "xs = [] ⟹ P" assumes "⋀ys. xs = True # ys ⟹ P" "⋀ys. xs = ys @ [False] ⟹ P" "⋀ys. xs = False # ys @ [True] ⟹ P" shows "P" proof (-) (*goal: ‹P›*) consider "length xs = 0" | "length xs = 1" | "length xs ≥ 2" (*goal: ‹⟦length xs = 0 ⟹ thesis; length xs = 1 ⟹ thesis; 2 ≤ length xs ⟹ thesis⟧ ⟹ thesis›*) by linarith thus "?thesis" (*goal: ‹P›*) proof (cases) (*goals: 1. ‹length xs = 0 ⟹ P› 2. ‹length xs = 1 ⟹ P› 3. ‹2 ≤ length xs ⟹ P›*) assume "length xs = 1" (*‹length (xs::bool list) = (1::nat)›*) hence "xs = [hd xs]" apply (cases xs) (*goals: 1. ‹⟦length xs = 1; xs = []⟧ ⟹ xs = [hd xs]› 2. ‹⋀a list. ⟦length xs = 1; xs = a # list⟧ ⟹ xs = [hd xs]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus P using assms(2)[of "[]"] (*‹xs = [True] ⟹ P›*) assms(3)[of "[]"] (*‹xs = [] @ [False] ⟹ P›*) apply (cases "hd xs") (*goals: 1. ‹⟦xs = [hd xs]; xs = [True] ⟹ P; xs = [] @ [False] ⟹ P; hd xs⟧ ⟹ P› 2. ‹⟦xs = [hd xs]; xs = [True] ⟹ P; xs = [] @ [False] ⟹ P; ¬ hd xs⟧ ⟹ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹length xs = 0 ⟹ P› 2. ‹2 ≤ length xs ⟹ P›*) assume len: "length xs ≥ 2" (*‹(2::nat) ≤ length (xs::bool list)›*) from len (*‹2 ≤ length xs›*) obtain x and xs' where "*": "xs = x # xs'" (*goal: ‹(⋀x xs'. xs = x # xs' ⟹ thesis) ⟹ thesis›*) apply (cases xs) (*goals: 1. ‹⟦⋀x xs'. xs = x # xs' ⟹ thesis; 2 ≤ length xs; xs = []⟧ ⟹ thesis› 2. ‹⋀a list. ⟦⋀x xs'. xs = x # xs' ⟹ thesis; 2 ≤ length xs; xs = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "**": "xs' = butlast xs' @ [last xs']" using len (*‹2 ≤ length xs›*) apply (subst append_butlast_last_id (*‹?xs ≠ [] ⟹ butlast ?xs @ [last ?xs] = ?xs›*)) (*goals: 1. ‹2 ≤ length xs ⟹ xs' ≠ []› 2. ‹2 ≤ length xs ⟹ xs' = xs'› discuss goal 1*) apply ((auto simp: * (*‹xs = x # xs'›*))[1]) (*discuss goal 2*) apply ((auto simp: * (*‹xs = x # xs'›*))[1]) (*proven 2 subgoals*) . have [simp]: "xs = x # butlast xs' @ [last xs']" apply (subst * (*‹xs = x # xs'›*)) (*goal: ‹xs = x # butlast xs' @ [last xs']›*) apply (subst ** (*‹xs' = butlast xs' @ [last xs']›*)) (*goal: ‹x # xs' = x # butlast xs' @ [last xs']›*) by auto show P using assms(2)[of xs'] (*‹xs = True # xs' ⟹ P›*) assms(3)[of "x # butlast xs'"] (*‹(xs::bool list) = ((x::bool) # butlast (xs'::bool list)) @ [False] ⟹ P::bool›*) assms(4)[of "butlast xs'"] (*‹xs = False # butlast xs' @ [True] ⟹ P›*) "**" (*‹xs' = butlast xs' @ [last xs']›*) apply (cases x) (*goals: 1. ‹⟦xs = True # xs' ⟹ P; xs = (x # butlast xs') @ [False] ⟹ P; xs = False # butlast xs' @ [True] ⟹ P; xs' = butlast xs' @ [last xs']; x⟧ ⟹ P› 2. ‹⟦xs = True # xs' ⟹ P; xs = (x # butlast xs') @ [False] ⟹ P; xs = False # butlast xs' @ [True] ⟹ P; xs' = butlast xs' @ [last xs']; ¬ x⟧ ⟹ P› discuss goal 1*) apply (cases "last xs'") (*goals: 1. ‹⟦xs = True # xs' ⟹ P; xs = (x # butlast xs') @ [False] ⟹ P; xs = False # butlast xs' @ [True] ⟹ P; xs' = butlast xs' @ [last xs']; x; last xs'⟧ ⟹ P› 2. ‹⟦xs = True # xs' ⟹ P; xs = (x # butlast xs') @ [False] ⟹ P; xs = False # butlast xs' @ [True] ⟹ P; xs' = butlast xs' @ [last xs']; x; ¬ last xs'⟧ ⟹ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases "last xs'") (*goals: 1. ‹⟦xs = True # xs' ⟹ P; xs = (x # butlast xs') @ [False] ⟹ P; xs = False # butlast xs' @ [True] ⟹ P; xs' = butlast xs' @ [last xs']; ¬ x; last xs'⟧ ⟹ P› 2. ‹⟦xs = True # xs' ⟹ P; xs = (x # butlast xs') @ [False] ⟹ P; xs = False # butlast xs' @ [True] ⟹ P; xs' = butlast xs' @ [last xs']; ¬ x; ¬ last xs'⟧ ⟹ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed (use assms in auto) (*solved the remaining goal: ‹length xs = 0 ⟹ P›*) qed lemma harry_meas_Nil [simp]: "harry_meas [] = 0" by (simp add: harry_meas.simps (*‹harry_meas ?xs = (if ?xs = [] then 0 else if hd ?xs then 1 + harry_meas (tl ?xs) else if ¬ last ?xs then harry_meas (butlast ?xs) else let n = length ?xs in harry_meas (take (n - 2) (tl ?xs)) + 2 * n - 1)›*)) lemma harry_meas_True_start [simp]: "harry_meas (True # xs) = 1 + harry_meas xs" apply (subst harry_meas.simps (*‹harry_meas ?xs = (if ?xs = [] then 0 else if hd ?xs then 1 + harry_meas (tl ?xs) else if ¬ last ?xs then harry_meas (butlast ?xs) else let n = length ?xs in harry_meas (take (n - 2) (tl ?xs)) + 2 * n - 1)›*)) (*goal: ‹harry_meas (True # (xs::bool list)) = (1::nat) + harry_meas xs›*) by auto lemma harry_meas_False_end [simp]: "harry_meas (xs @ [False]) = harry_meas xs" proof (induction xs) (*goals: 1. ‹harry_meas ([] @ [False]) = harry_meas []› 2. ‹⋀a xs. harry_meas (xs @ [False]) = harry_meas xs ⟹ harry_meas ((a # xs) @ [False]) = harry_meas (a # xs)›*) case (Cons x xs) (*‹harry_meas (xs @ [False]) = harry_meas xs›*) thus "?case" (*goal: ‹harry_meas ((x # xs) @ [False]) = harry_meas (x # xs)›*) apply (cases x) (*goals: 1. ‹⟦harry_meas ((xs::bool list) @ [False]) = harry_meas xs; x::bool⟧ ⟹ harry_meas ((x # xs) @ [False]) = harry_meas (x # xs)› 2. ‹⟦harry_meas ((xs::bool list) @ [False]) = harry_meas xs; ¬ (x::bool)⟧ ⟹ harry_meas ((x # xs) @ [False]) = harry_meas (x # xs)› discuss goal 1*) apply ((auto simp: harry_meas.simps (*‹harry_meas ?xs = (if ?xs = [] then 0 else if hd ?xs then 1 + harry_meas (tl ?xs) else if ¬ last ?xs then harry_meas (butlast ?xs) else let n = length ?xs in harry_meas (take (n - 2) (tl ?xs)) + 2 * n - 1)›*))[1]) (*discuss goal 2*) apply ((auto simp: harry_meas.simps (*‹harry_meas (?xs::bool list) = (if ?xs = [] then 0::nat else if hd ?xs then (1::nat) + harry_meas (tl ?xs) else if ¬ last ?xs then harry_meas (butlast ?xs) else let n::nat = length ?xs in harry_meas (take (n - (2::nat)) (tl ?xs)) + (2::nat) * n - (1::nat))›*))[1]) (*proven 2 subgoals*) . qed (auto simp: harry_meas.simps (*‹harry_meas ?xs = (if ?xs = [] then 0 else if hd ?xs then 1 + harry_meas (tl ?xs) else if ¬ last ?xs then harry_meas (butlast ?xs) else let n = length ?xs in harry_meas (take (n - 2) (tl ?xs)) + 2 * n - 1)›*)) (*solved the remaining goal: ‹harry_meas ([] @ [False]) = harry_meas []›*) lemma harry_meas_False_True: "harry_meas (False # xs @ [True]) = harry_meas xs + 2 * length xs + 3" apply (subst harry_meas.simps (*‹harry_meas ?xs = (if ?xs = [] then 0 else if hd ?xs then 1 + harry_meas (tl ?xs) else if ¬ last ?xs then harry_meas (butlast ?xs) else let n = length ?xs in harry_meas (take (n - 2) (tl ?xs)) + 2 * n - 1)›*)) (*goal: ‹harry_meas (False # xs @ [True]) = harry_meas xs + 2 * length xs + 3›*) by auto lemma harry_meas_eq_0 [simp]: assumes "True ∉ set xs" shows "harry_meas xs = 0" using assms (*‹True ∉ set xs›*) apply (induction xs rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹True ∉ set [] ⟹ harry_meas [] = 0› 2. ‹⋀x xs. ⟦True ∉ set xs ⟹ harry_meas xs = 0; True ∉ set (xs @ [x])⟧ ⟹ harry_meas (xs @ [x]) = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹ If the sequence starts with ‹H›, the process runs on the remaining sequence until it terminates and then flips this ‹H› in another single step. › lemma harry_step_True_start [simp]: "harry_step (True # xs) = (if True ∈ set xs then True # harry_step xs else False # xs)" by (auto simp: harry_step_def (*‹harry_step (?xs::bool list) = flip ?xs (heads ?xs - (1::nat))›*)) text ‹ If the sequence ends in ‹T›, the process simply runs on the remaining sequence as if it were not present. › lemma harry_step_False_end [simp]: assumes "True ∈ set xs" shows "harry_step (xs @ [False]) = harry_step xs @ [False]" proof (-) (*goal: ‹harry_step (xs @ [False]) = harry_step xs @ [False]›*) have "harry_step (xs @ [False]) = flip (xs @ [False]) (heads xs - 1)" using heads_le_length[of xs] (*‹heads xs ≤ length xs›*) by (auto simp: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*)) also (*calculation: ‹harry_step (xs @ [False]) = flip (xs @ [False]) (heads xs - 1)›*) have "… = harry_step xs @ [False]" using Suc_less_eq (*‹(Suc ?m < Suc ?n) = (?m < ?n)›*) assms (*‹True ∈ set xs›*) heads_le_length[of xs] (*‹heads xs ≤ length xs›*) apply (subst flip_append1 (*‹?n < length ?xs ⟹ flip (?xs @ ?ys) ?n = flip ?xs ?n @ ?ys›*)) (*goals: 1. ‹⟦⋀m n. (Suc m < Suc n) = (m < n); True ∈ set xs; heads xs ≤ length xs⟧ ⟹ heads xs - 1 < length xs› 2. ‹⟦⋀m n. (Suc m < Suc n) = (m < n); True ∈ set xs; heads xs ≤ length xs⟧ ⟹ flip xs (heads xs - 1) @ [False] = harry_step xs @ [False]› discuss goal 1*) apply (fastforce simp: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*)) (*discuss goal 2*) apply (fastforce simp: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*)) (*proven 2 subgoals*) . finally (*calculation: ‹harry_step (xs @ [False]) = harry_step xs @ [False]›*) show "?thesis" (*goal: ‹harry_step (xs @ [False]) = harry_step xs @ [False]›*) . qed text ‹ If the sequence starts with ‹T› and ends with ‹H›, the process runs on the remaining sequence inbetween as if these two were not present, eventually leaving a sequence that consists entirely if ‹T› except for a single final ‹H›. › lemma harry_step_False_True: assumes "True ∈ set xs" shows "harry_step (False # xs @ [True]) = False # harry_step xs @ [True]" proof (-) (*goal: ‹harry_step (False # xs @ [True]) = False # harry_step xs @ [True]›*) have "harry_step (False # xs @ [True]) = False # flip (xs @ [True]) (heads xs - 1)" using assms (*‹True ∈ set (xs::bool list)›*) heads_le_length[of xs] (*‹heads xs ≤ length xs›*) by (auto simp: harry_step_def (*‹harry_step (?xs::bool list) = flip ?xs (heads ?xs - (1::nat))›*) heads_le_length (*‹heads (?xs::bool list) ≤ length ?xs›*)) also (*calculation: ‹harry_step (False # (xs::bool list) @ [True]) = False # flip (xs @ [True]) (heads xs - (1::nat))›*) have "… = False # harry_step xs @ [True]" using assms (*‹True ∈ set (xs::bool list)›*) apply (subst flip_append1 (*‹?n < length ?xs ⟹ flip (?xs @ ?ys) ?n = flip ?xs ?n @ ?ys›*)) (*goals: 1. ‹True ∈ set xs ⟹ heads xs - 1 < length xs› 2. ‹True ∈ set xs ⟹ False # flip xs (heads xs - 1) @ [True] = False # harry_step xs @ [True]› discuss goal 1*) apply ((auto simp: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*) Suc_less_SucD (*‹Suc ?m < Suc ?n ⟹ ?m < ?n›*) heads_le_length (*‹heads ?xs ≤ length ?xs›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*))[1]) (*discuss goal 2*) apply ((auto simp: harry_step_def (*‹harry_step (?xs::bool list) = flip ?xs (heads ?xs - (1::nat))›*) Suc_less_SucD (*‹Suc (?m::nat) < Suc (?n::nat) ⟹ ?m < ?n›*) heads_le_length (*‹heads (?xs::bool list) ≤ length ?xs›*) less_Suc_eq_le (*‹((?m::nat) < Suc (?n::nat)) = (?m ≤ ?n)›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹harry_step (False # xs @ [True]) = False # harry_step xs @ [True]›*) show "?thesis" (*goal: ‹harry_step (False # xs @ [True]) = False # harry_step xs @ [True]›*) . qed text ‹ That sequence consisting only of ‹T› except for a single final ‹H› is then turned into an all-‹T› sequence in ‹2n+1› steps. › lemma harry_meas_Falses_True [simp]: "harry_meas (replicate n False @ [True]) = 2 * n + 1" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ harry_meas (replicate n False @ [True]) = 2 * n + 1› 2. ‹n ≠ 0 ⟹ harry_meas (replicate n False @ [True]) = 2 * n + 1›*) case False (*‹n ≠ 0›*) hence "replicate n False @ [True] = False # replicate (n - 1) False @ [True]" apply (cases n) (*goals: 1. ‹⟦n ≠ 0; n = 0⟧ ⟹ replicate n False @ [True] = False # replicate (n - 1) False @ [True]› 2. ‹⋀nat. ⟦n ≠ 0; n = Suc nat⟧ ⟹ replicate n False @ [True] = False # replicate (n - 1) False @ [True]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹replicate n False @ [True] = False # replicate (n - 1) False @ [True]›*) have "harry_meas … = 2 * n + 1" using False (*‹n ≠ 0›*) by (simp add: harry_meas_False_True (*‹harry_meas (False # ?xs @ [True]) = harry_meas ?xs + 2 * length ?xs + 3›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*)) finally (*calculation: ‹harry_meas (replicate n False @ [True]) = 2 * n + 1›*) show "?thesis" (*goal: ‹harry_meas (replicate (n::nat) False @ [True]) = (2::nat) * n + (1::nat)›*) . qed (auto) (*solved the remaining goal: ‹n = 0 ⟹ harry_meas (replicate n False @ [True]) = 2 * n + 1›*) lemma harry_step_Falses_True [simp]: "n > 0 ⟹ harry_step (replicate n False @ [True]) = True # replicate (n - 1) False @ [True]" apply (cases n) (*goals: 1. ‹⟦0 < n; n = 0⟧ ⟹ harry_step (replicate n False @ [True]) = True # replicate (n - 1) False @ [True]› 2. ‹⋀nat. ⟦0 < n; n = Suc nat⟧ ⟹ harry_step (replicate n False @ [True]) = True # replicate (n - 1) False @ [True]› discuss goal 1*) apply (simp add: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*)) (*discuss goal 2*) apply (simp add: harry_step_def (*‹harry_step ?xs = flip ?xs (heads ?xs - 1)›*)) (*proven 2 subgoals*) . subsection ‹Correctness of the measure› text ‹ We will now show that @{const harry_meas} indeed counts the length of the process. As a first step, we will show that if there is a ‹H› in a sequence, applying a single step decreases the measure by one. › lemma harry_meas_step_aux: assumes "True ∈ set xs" shows "harry_meas xs = Suc (harry_meas (harry_step xs))" using assms (*‹True ∈ set xs›*) proof (induction xs rule: length_induct (*‹(⋀xs::?'a list. ∀ys::?'a list. length ys < length xs ⟶ (?P::?'a list ⇒ bool) ys ⟹ ?P xs) ⟹ ?P (?xs::?'a list)›*)) (*goal: ‹⋀xs. ⟦∀ys. length ys < length xs ⟶ True ∈ set ys ⟶ harry_meas ys = Suc (harry_meas (harry_step ys)); True ∈ set xs⟧ ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) case (1 xs) (*‹∀ys. length ys < length xs ⟶ True ∈ set ys ⟶ harry_meas ys = Suc (harry_meas (harry_step ys))› ‹True ∈ set xs›*) hence IH: "harry_meas ys = Suc (harry_meas (harry_step ys))" if "length ys < length xs" "True ∈ set ys" for ys using that (*‹length ys < length xs› ‹True ∈ set ys›*) by blast show "?case" (*goal: ‹harry_meas xs = Suc (harry_meas (harry_step xs))›*) proof (cases xs rule: head_last_cases (*‹⟦?xs = [] ⟹ ?P; ⋀ys. ?xs = True # ys ⟹ ?P; ⋀ys. ?xs = ys @ [False] ⟹ ?P; ⋀ys. ?xs = False # ys @ [True] ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹xs = [] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 2. ‹⋀ys. xs = True # ys ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 3. ‹⋀ys. xs = ys @ [False] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 4. ‹⋀ys. xs = False # ys @ [True] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) case (True ys) (*‹(xs::bool list) = True # (ys::bool list)›*) thus "?thesis" (*goal: ‹harry_meas xs = Suc (harry_meas (harry_step xs))›*) by (auto simp: IH (*‹⟦length ?ys < length xs; True ∈ set ?ys⟧ ⟹ harry_meas ?ys = Suc (harry_meas (harry_step ?ys))›*)) next (*goals: 1. ‹xs = [] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 2. ‹⋀ys. xs = ys @ [False] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 3. ‹⋀ys. xs = False # ys @ [True] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) case (False ys) (*‹xs = ys @ [False]›*) thus "?thesis" (*goal: ‹harry_meas xs = Suc (harry_meas (harry_step xs))›*) using "1.prems" (*‹True ∈ set xs›*) by (auto simp: IH (*‹⟦length ?ys < length xs; True ∈ set ?ys⟧ ⟹ harry_meas ?ys = Suc (harry_meas (harry_step ?ys))›*)) next (*goals: 1. ‹xs = [] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 2. ‹⋀ys. xs = False # ys @ [True] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) case (False_True ys) (*‹(xs::bool list) = False # (ys::bool list) @ [True]›*) thus "?thesis" (*goal: ‹harry_meas (xs::bool list) = Suc (harry_meas (harry_step xs))›*) proof (cases "True ∈ set ys") (*goals: 1. ‹⟦xs = False # ys @ [True]; True ∈ set ys⟧ ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))› 2. ‹⟦xs = False # ys @ [True]; True ∉ set ys⟧ ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) case False (*‹True ∉ set ys›*) define n where "n = length ys + 1" have "n > 0" by (simp add: n_def (*‹n = length ys + 1›*)) from False (*‹True ∉ set ys›*) have "ys = replicate (n - 1) False" unfolding n_def (*goal: ‹ys = replicate (length ys + 1 - 1) False›*) apply (induction ys) (*goals: 1. ‹True ∉ set [] ⟹ [] = replicate (length [] + 1 - 1) False› 2. ‹⋀a ys. ⟦True ∉ set ys ⟹ ys = replicate (length ys + 1 - 1) False; True ∉ set (a # ys)⟧ ⟹ a # ys = replicate (length (a # ys) + 1 - 1) False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with False_True (*‹xs = False # ys @ [True]›*) ‹n > 0› (*‹(0::nat) < (n::nat)›*) have [simp]: "xs = replicate n False @ [True]" apply (cases n) (*goals: 1. ‹⟦xs = False # ys @ [True]; 0 < n; ys = replicate (n - 1) False; n = 0⟧ ⟹ xs = replicate n False @ [True]› 2. ‹⋀nat. ⟦xs = False # ys @ [True]; 0 < n; ys = replicate (n - 1) False; n = Suc nat⟧ ⟹ xs = replicate n False @ [True]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹harry_meas xs = Suc (harry_meas (harry_step xs))›*) using ‹n > 0› (*‹0 < n›*) by auto qed (auto simp: IH (*‹⟦length ?ys < length xs; True ∈ set ?ys⟧ ⟹ harry_meas ?ys = Suc (harry_meas (harry_step ?ys))›*) False_True (*‹xs = False # ys @ [True]›*) harry_step_False_True (*‹True ∈ set ?xs ⟹ harry_step (False # ?xs @ [True]) = False # harry_step ?xs @ [True]›*) harry_meas_False_True (*‹harry_meas (False # ?xs @ [True]) = harry_meas ?xs + 2 * length ?xs + 3›*)) (*solved the remaining goal: ‹⟦(xs::bool list) = False # (ys::bool list) @ [True]; True ∈ set ys⟧ ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) qed (use 1 in auto) (*solved the remaining goal: ‹(xs::bool list) = [] ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) qed lemma harry_meas_step: "True ∈ set xs ⟹ harry_meas (harry_step xs) = harry_meas xs - 1" using harry_meas_step_aux[of xs] (*‹True ∈ set xs ⟹ harry_meas xs = Suc (harry_meas (harry_step xs))›*) by simp text ‹ Next, we show that the measure is zero if and only if there is no ‹H› left in the sequence. › lemma harry_meas_eq_0_iff [simp]: "harry_meas xs = 0 ⟷ True ∉ set xs" proof (induction xs rule: length_induct (*‹(⋀xs. ∀ys. length ys < length xs ⟶ ?P ys ⟹ ?P xs) ⟹ ?P ?xs›*)) (*goal: ‹⋀xs. ∀ys. length ys < length xs ⟶ (harry_meas ys = 0) = (True ∉ set ys) ⟹ (harry_meas xs = 0) = (True ∉ set xs)›*) case (1 xs) (*‹∀ys. length ys < length xs ⟶ (harry_meas ys = 0) = (True ∉ set ys)›*) show "?case" (*goal: ‹(harry_meas xs = 0) = (True ∉ set xs)›*) apply (cases xs rule: head_last_cases (*‹⟦?xs = [] ⟹ ?P; ⋀ys. ?xs = True # ys ⟹ ?P; ⋀ys. ?xs = ys @ [False] ⟹ ?P; ⋀ys. ?xs = False # ys @ [True] ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹xs = [] ⟹ (harry_meas xs = 0) = (True ∉ set xs)› 2. ‹⋀ys. xs = True # ys ⟹ (harry_meas xs = 0) = (True ∉ set xs)› 3. ‹⋀ys. xs = ys @ [False] ⟹ (harry_meas xs = 0) = (True ∉ set xs)› 4. ‹⋀ys. xs = False # ys @ [True] ⟹ (harry_meas xs = 0) = (True ∉ set xs)› discuss goal 1*) apply ((auto simp: 1 (*‹∀ys. length ys < length xs ⟶ (harry_meas ys = 0) = (True ∉ set ys)›*) harry_meas_False_True (*‹harry_meas (False # ?xs @ [True]) = harry_meas ?xs + 2 * length ?xs + 3›*) 1 (*‹∀ys. length ys < length xs ⟶ (harry_meas ys = 0) = (True ∉ set ys)›*))[1]) (*discuss goal 2*) apply ((auto simp: 1 (*‹∀ys::bool list. length ys < length (xs::bool list) ⟶ (harry_meas ys = (0::nat)) = (True ∉ set ys)›*) harry_meas_False_True (*‹harry_meas (False # (?xs::bool list) @ [True]) = harry_meas ?xs + (2::nat) * length ?xs + (3::nat)›*) 1 (*‹∀ys::bool list. length ys < length (xs::bool list) ⟶ (harry_meas ys = (0::nat)) = (True ∉ set ys)›*))[1]) (*discuss goal 3*) apply ((auto simp: 1 (*‹∀ys::bool list. length ys < length (xs::bool list) ⟶ (harry_meas ys = (0::nat)) = (True ∉ set ys)›*) harry_meas_False_True (*‹harry_meas (False # (?xs::bool list) @ [True]) = harry_meas ?xs + (2::nat) * length ?xs + (3::nat)›*) 1 (*‹∀ys::bool list. length ys < length (xs::bool list) ⟶ (harry_meas ys = (0::nat)) = (True ∉ set ys)›*))[1]) (*discuss goal 4*) apply ((auto simp: 1 (*‹∀ys. length ys < length xs ⟶ (harry_meas ys = 0) = (True ∉ set ys)›*) harry_meas_False_True (*‹harry_meas (False # ?xs @ [True]) = harry_meas ?xs + 2 * length ?xs + 3›*) 1 (*‹∀ys. length ys < length xs ⟶ (harry_meas ys = 0) = (True ∉ set ys)›*))[1]) (*proven 4 subgoals*) . qed text ‹ It follows by induction that if the measure of a sequence is ‹n›, then iterating the step less than ‹n› times yields a sequence with at least one ‹H› in it, but iterating it exactly ‹n› times yields a sequence that contains no more ‹H›. › lemma True_in_funpow_harry_step: assumes "n < harry_meas xs" shows "True ∈ set ((harry_step ^^ n) xs)" using assms (*‹n < harry_meas xs›*) proof (induction n arbitrary: xs) (*goals: 1. ‹⋀xs. 0 < harry_meas xs ⟹ True ∈ set ((harry_step ^^ 0) xs)› 2. ‹⋀n xs. ⟦⋀xs. n < harry_meas xs ⟹ True ∈ set ((harry_step ^^ n) xs); Suc n < harry_meas xs⟧ ⟹ True ∈ set ((harry_step ^^ Suc n) xs)›*) case 0 (*‹0 < harry_meas xs›*) show "?case" (*goal: ‹True ∈ set ((harry_step ^^ (0::nat)) (xs::bool list))›*) apply (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹True ∈ set ((harry_step ^^ 0) xs)›*) by (use 0 in auto) next (*goal: ‹⋀n xs. ⟦⋀xs. n < harry_meas xs ⟹ True ∈ set ((harry_step ^^ n) xs); Suc n < harry_meas xs⟧ ⟹ True ∈ set ((harry_step ^^ Suc n) xs)›*) case (Suc n) (*‹n < harry_meas ?xs ⟹ True ∈ set ((harry_step ^^ n) ?xs)› ‹Suc (n::nat) < harry_meas (xs::bool list)›*) have "True ∈ set xs" apply (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹True ∈ set xs›*) by (use Suc in auto) have "(harry_step ^^ Suc n) xs = (harry_step ^^ n) (harry_step xs)" by (simp only: funpow_Suc_right (*‹?f ^^ Suc ?n = ?f ^^ ?n ∘ ?f›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹(harry_step ^^ Suc n) xs = (harry_step ^^ n) (harry_step xs)›*) have "True ∈ set …" using Suc (*‹(n::nat) < harry_meas (?xs::bool list) ⟹ True ∈ set ((harry_step ^^ n) ?xs)› ‹Suc (n::nat) < harry_meas (xs::bool list)›*) ‹True ∈ set xs› (*‹True ∈ set xs›*) apply (intro Suc (*‹n < harry_meas ?xs ⟹ True ∈ set ((harry_step ^^ n) ?xs)› ‹Suc n < harry_meas xs›*)) (*goal: ‹True ∈ set ((harry_step ^^ (n::nat)) (harry_step (xs::bool list)))›*) by (auto simp: harry_meas_step (*‹True ∈ set ?xs ⟹ harry_meas (harry_step ?xs) = harry_meas ?xs - 1›*)) finally (*calculation: ‹True ∈ set ((harry_step ^^ Suc n) xs)›*) show "?case" (*goal: ‹True ∈ set ((harry_step ^^ Suc (n::nat)) (xs::bool list))›*) . qed lemma True_notin_funpow_harry_step: "True ∉ set ((harry_step ^^ harry_meas xs) xs)" proof (induction "harry_meas xs" arbitrary: xs) (*goals: 1. ‹⋀xs. 0 = harry_meas xs ⟹ True ∉ set ((harry_step ^^ harry_meas xs) xs)› 2. ‹⋀x xs. ⟦⋀xs. x = harry_meas xs ⟹ True ∉ set ((harry_step ^^ harry_meas xs) xs); Suc x = harry_meas xs⟧ ⟹ True ∉ set ((harry_step ^^ harry_meas xs) xs)›*) case (Suc n) (*‹n = harry_meas ?xs ⟹ True ∉ set ((harry_step ^^ harry_meas ?xs) ?xs)› ‹Suc n = harry_meas xs›*) have "True ∈ set xs" apply (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹True ∈ set (xs::bool list)›*) by (use Suc in auto) have "(harry_step ^^ harry_meas xs) xs = (harry_step ^^ Suc n) xs" by (simp only: Suc (*‹n = harry_meas ?xs ⟹ True ∉ set ((harry_step ^^ harry_meas ?xs) ?xs)› ‹Suc n = harry_meas xs›*)) also (*calculation: ‹(harry_step ^^ harry_meas xs) xs = (harry_step ^^ Suc n) xs›*) have "… = (harry_step ^^ n) (harry_step xs)" by (simp only: funpow_Suc_right (*‹?f ^^ Suc ?n = ?f ^^ ?n ∘ ?f›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹(harry_step ^^ harry_meas (xs::bool list)) xs = (harry_step ^^ (n::nat)) (harry_step xs)›*) have "… = (harry_step ^^ (harry_meas xs - 1)) (harry_step xs)" by (simp flip: Suc( (*‹Suc n = harry_meas xs›*) 2)) also (*calculation: ‹(harry_step ^^ harry_meas xs) xs = (harry_step ^^ (harry_meas xs - 1)) (harry_step xs)›*) have "harry_meas xs - 1 = harry_meas (harry_step xs)" using ‹True ∈ set xs› (*‹True ∈ set (xs::bool list)›*) apply (subst harry_meas_step (*‹True ∈ set ?xs ⟹ harry_meas (harry_step ?xs) = harry_meas ?xs - 1›*)) (*goals: 1. ‹True ∈ set xs ⟹ True ∈ set xs› 2. ‹True ∈ set xs ⟹ harry_meas xs - 1 = harry_meas xs - 1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹(harry_step ^^ harry_meas xs) xs = (harry_step ^^ harry_meas (harry_step xs)) (harry_step xs)›*) have "True ∉ set ((harry_step ^^ …) (harry_step xs))" using Suc (*‹n = harry_meas ?xs ⟹ True ∉ set ((harry_step ^^ harry_meas ?xs) ?xs)› ‹Suc (n::nat) = harry_meas (xs::bool list)›*) ‹True ∈ set xs› (*‹True ∈ set xs›*) apply (intro Suc (*‹(n::nat) = harry_meas (?xs::bool list) ⟹ True ∉ set ((harry_step ^^ harry_meas ?xs) ?xs)› ‹Suc (n::nat) = harry_meas (xs::bool list)›*)) (*goal: ‹True ∉ set ((harry_step ^^ harry_meas (harry_step xs)) (harry_step xs))›*) by (auto simp: harry_meas_step (*‹True ∈ set ?xs ⟹ harry_meas (harry_step ?xs) = harry_meas ?xs - 1›*)) finally (*calculation: ‹True ∉ set ((harry_step ^^ harry_meas (xs::bool list)) xs)›*) show "?case" (*goal: ‹True ∉ set ((harry_step ^^ harry_meas xs) xs)›*) . qed (auto) (*solved the remaining goal: ‹⋀xs. 0 = harry_meas xs ⟹ True ∉ set ((harry_step ^^ harry_meas xs) xs)›*) text ‹ This shows that the measure is indeed the correct one: It is the smallest number such that iterating Harry's step that often yields a sequence with no heads in it. › theorem "harry_meas xs = (LEAST n. True ∉ set ((harry_step ^^ n) xs))" proof (rule sym (*‹?s = ?t ⟹ ?t = ?s›*), rule Least_equality (*‹⟦?P ?x; ⋀y. ?P y ⟹ ?x ≤ y⟧ ⟹ Least ?P = ?x›*), goal_cases) (*goals: 1. ‹True ∉ set ((harry_step ^^ harry_meas xs) xs)› 2. ‹⋀y. True ∉ set ((harry_step ^^ y) xs) ⟹ harry_meas xs ≤ y›*) show "True ∉ set ((harry_step ^^ harry_meas xs) xs)" by (rule True_notin_funpow_harry_step (*‹True ∉ set ((harry_step ^^ harry_meas ?xs) ?xs)›*)) next (*goal: ‹⋀y. True ∉ set ((harry_step ^^ y) xs) ⟹ harry_meas xs ≤ y›*) case (2 y) (*‹True ∉ set ((harry_step ^^ (y::nat)) (xs::bool list))›*) show "?case" (*goal: ‹harry_meas xs ≤ y›*) apply (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹harry_meas xs ≤ y›*) by (use 2 True_in_funpow_harry_step[of y] in auto) qed subsection ‹Average-case analysis› text ‹ The set of all coin sequences of a given length. › definition seqs where "seqs n = {xs :: bool list . length xs = n}" lemma length_seqs [dest]: "xs ∈ seqs n ⟹ length xs = n" by (simp add: seqs_def (*‹seqs ?n = {xs. length xs = ?n}›*)) lemma seqs_0 [simp]: "seqs 0 = {[]}" by (auto simp: seqs_def (*‹seqs ?n = {xs. length xs = ?n}›*)) text ‹ The coin sequences of length ‹n + 1› are simply what is obtained by appending either ‹H› or ‹T› to each coin sequence of length ‹n›. › lemma seqs_Suc: "seqs (Suc n) = (λxs. True # xs) ` seqs n ∪ (λxs. False # xs) ` seqs n" by (auto simp: seqs_def (*‹seqs ?n = {xs. length xs = ?n}›*) length_Suc_conv (*‹(length ?xs = Suc ?n) = (∃y ys. ?xs = y # ys ∧ length ys = ?n)›*)) text ‹ The set of coin sequences of length ‹n› is invariant under reversal. › lemma seqs_rev [simp]: "rev ` seqs n = seqs n" proof (standard) (*goals: 1. ‹rev ` seqs (n::nat) ⊆ seqs n› 2. ‹seqs (n::nat) ⊆ rev ` seqs n›*) show "rev ` seqs n ⊆ seqs n" by (auto simp: seqs_def (*‹seqs ?n = {xs. length xs = ?n}›*)) hence "rev ` rev ` seqs n ⊆ rev ` seqs n" by blast thus "seqs n ⊆ rev ` seqs n" by (simp add: image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*)) qed text ‹ Hence we get a similar decomposition theorem that appends at the end. › lemma seqs_Suc': "seqs (Suc n) = (λxs. xs @ [True]) ` seqs n ∪ (λxs. xs @ [False]) ` seqs n" proof (-) (*goal: ‹seqs (Suc (n::nat)) = (λxs::bool list. xs @ [True]) ` seqs n ∪ (λxs::bool list. xs @ [False]) ` seqs n›*) have "rev ` rev ` ((λxs. xs @ [True]) ` seqs n ∪ (λxs. xs @ [False]) ` seqs n) = rev ` ((λxs. True # xs) ` rev ` seqs n ∪ (λxs. False # xs) ` rev ` seqs n)" unfolding image_Un image_image (*goal: ‹(λx. rev (rev (x @ [True]))) ` seqs n ∪ (λx. rev (rev (x @ [False]))) ` seqs n = (λx. rev (True # rev x)) ` seqs n ∪ (λx. rev (False # rev x)) ` seqs n›*) by simp also (*calculation: ‹rev ` rev ` ((λxs::bool list. xs @ [True]) ` seqs (n::nat) ∪ (λxs::bool list. xs @ [False]) ` seqs n) = rev ` ((#) True ` rev ` seqs n ∪ (#) False ` rev ` seqs n)›*) have "(λxs. True # xs) ` rev ` seqs n ∪ (λxs. False # xs) ` rev ` seqs n = seqs (Suc n)" by (simp add: seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*)) finally (*calculation: ‹rev ` rev ` ((λxs. xs @ [True]) ` seqs n ∪ (λxs. xs @ [False]) ` seqs n) = rev ` seqs (Suc n)›*) show "?thesis" (*goal: ‹seqs (Suc n) = (λxs. xs @ [True]) ` seqs n ∪ (λxs. xs @ [False]) ` seqs n›*) by (simp add: image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*)) qed lemma finite_seqs [intro]: "finite (seqs n)" apply (induction n) (*goals: 1. ‹finite (seqs 0)› 2. ‹⋀n. finite (seqs n) ⟹ finite (seqs (Suc n))› discuss goal 1*) apply ((auto simp: seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*))[1]) (*proven 2 subgoals*) . lemma card_seqs [simp]: "card (seqs n) = 2 ^ n" proof (induction n) (*goals: 1. ‹card (seqs 0) = 2 ^ 0› 2. ‹⋀n. card (seqs n) = 2 ^ n ⟹ card (seqs (Suc n)) = 2 ^ Suc n›*) case (Suc n) (*‹card (seqs n) = 2 ^ n›*) have "card (seqs (Suc n)) = card ((#) True ` seqs n ∪ (#) False ` seqs n)" by (auto simp: seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*)) also (*calculation: ‹card (seqs (Suc n)) = card ((#) True ` seqs n ∪ (#) False ` seqs n)›*) from Suc.IH (*‹card (seqs n) = 2 ^ n›*) have "… = 2 ^ Suc n" apply (subst card_Un_disjoint (*‹⟦finite (?A::?'a::type set); finite (?B::?'a::type set); ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*)) (*goals: 1. ‹card (seqs n) = 2 ^ n ⟹ finite ((#) True ` seqs n)› 2. ‹card (seqs n) = 2 ^ n ⟹ finite ((#) False ` seqs n)› 3. ‹card (seqs n) = 2 ^ n ⟹ (#) True ` seqs n ∩ (#) False ` seqs n = {}› 4. ‹card (seqs n) = 2 ^ n ⟹ card ((#) True ` seqs n) + card ((#) False ` seqs n) = 2 ^ Suc n› discuss goal 1*) apply ((auto simp: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*))[1]) (*discuss goal 3*) apply ((auto simp: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*))[1]) (*discuss goal 4*) apply ((auto simp: card_image (*‹inj_on ?f ?A ⟹ card (?f ` ?A) = card ?A›*))[1]) (*proven 4 subgoals*) . finally (*calculation: ‹card (seqs (Suc (n::nat))) = (2::nat) ^ Suc n›*) show "?case" (*goal: ‹card (seqs (Suc n)) = 2 ^ Suc n›*) . qed (auto) (*solved the remaining goal: ‹card (seqs 0) = 2 ^ 0›*) lemmas seqs_code [code] = seqs_0 seqs_Suc text ‹ The sum of the measures over all possible coin sequences of a given length (defined as a recurrence relation; correctness proven later). › fun harry_sum :: "nat ⇒ nat" where "harry_sum 0 = 0" | "harry_sum (Suc 0) = 1" | "harry_sum (Suc (Suc n)) = 2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n" lemma Suc_Suc_induct: "P 0 ⟹ P (Suc 0) ⟹ (⋀n. P n ⟹ P (Suc n) ⟹ P (Suc (Suc n))) ⟹ P n" apply induction_schema (*goals: 1. ‹⋀P n. ⟦n = 0 ⟹ P; n = Suc 0 ⟹ P; ⋀na__. n = Suc (Suc na__) ⟹ P⟧ ⟹ P› 2. ‹wf ?R2› 3. ‹⋀na__. (na__, Suc (Suc na__)) ∈ ?R2› 4. ‹⋀na__. (Suc na__, Suc (Suc na__)) ∈ ?R2› discuss goal 1*) apply pat_completeness (*discuss goal 2*) apply (rule wf_measure[of id] (*‹wf (measure id)›*)) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . text ‹ The recurrence relation really does describe the sum over all measures: › lemma harry_sum_correct: "harry_sum n = sum harry_meas (seqs n)" proof (induction n rule: Suc_Suc_induct (*‹⟦?P 0; ?P (Suc 0); ⋀n. ⟦?P n; ?P (Suc n)⟧ ⟹ ?P (Suc (Suc n))⟧ ⟹ ?P ?n›*)) (*goals: 1. ‹harry_sum (0::nat) = sum harry_meas (seqs (0::nat))› 2. ‹harry_sum (Suc (0::nat)) = sum harry_meas (seqs (Suc (0::nat)))› 3. ‹⋀n::nat. ⟦harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))⟧ ⟹ harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))›*) case (3 n) (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*) have "seqs (Suc (Suc n)) = (λxs. xs @ [False]) ` seqs (Suc n) ∪ (λxs. True # xs @ [True]) ` seqs n ∪ (λxs. False # xs @ [True]) ` seqs n" apply (subst (1) seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*)) (*goal: ‹seqs (Suc (Suc (n::nat))) = (λxs::bool list. xs @ [False]) ` seqs (Suc n) ∪ (λxs::bool list. True # xs @ [True]) ` seqs n ∪ (λxs::bool list. False # xs @ [True]) ` seqs n›*) apply (subst (1 2) seqs_Suc' (*‹seqs (Suc (?n::nat)) = (λxs::bool list. xs @ [True]) ` seqs ?n ∪ (λxs::bool list. xs @ [False]) ` seqs ?n›*)) (*goal: ‹(#) True ` seqs (Suc n) ∪ (#) False ` seqs (Suc n) = (λxs. xs @ [False]) ` seqs (Suc n) ∪ (λxs. True # xs @ [True]) ` seqs n ∪ (λxs. False # xs @ [True]) ` seqs n›*) by (simp add: image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) Un_ac (*‹?A ∪ ?B ∪ ?C = ?A ∪ (?B ∪ ?C)› ‹?A ∪ (?A ∪ ?B) = ?A ∪ ?B› ‹?A ∪ ?B = ?B ∪ ?A› ‹?A ∪ (?B ∪ ?C) = ?B ∪ (?A ∪ ?C)›*) seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*)) also (*calculation: ‹seqs (Suc (Suc n)) = (λxs. xs @ [False]) ` seqs (Suc n) ∪ (λxs. True # xs @ [True]) ` seqs n ∪ (λxs. False # xs @ [True]) ` seqs n›*) have "int (sum harry_meas …) = int (harry_sum (Suc n)) + int (∑xs∈seqs n. 1 + harry_meas (xs @ [True])) + int (∑xs∈seqs n. harry_meas (False # xs @ [True]))" apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹finite ((λxs::bool list. xs @ [False]) ` seqs (Suc (n::nat)) ∪ (λxs::bool list. True # xs @ [True]) ` seqs n)› 2. ‹finite ((λxs::bool list. False # xs @ [True]) ` seqs (n::nat))› 3. ‹((λxs::bool list. xs @ [False]) ` seqs (Suc (n::nat)) ∪ (λxs::bool list. True # xs @ [True]) ` seqs n) ∩ (λxs::bool list. False # xs @ [True]) ` seqs n = {}› 4. ‹int (sum harry_meas ((λxs::bool list. xs @ [False]) ` seqs (Suc (n::nat)) ∪ (λxs::bool list. True # xs @ [True]) ` seqs n) + sum harry_meas ((λxs::bool list. False # xs @ [True]) ` seqs n)) = int (harry_sum (Suc n)) + int (∑xs::bool list∈seqs n. (1::nat) + harry_meas (xs @ [True])) + int (∑xs::bool list∈seqs n. harry_meas (False # xs @ [True]))› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 3*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum (n::nat) = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 4*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*goal: ‹int (sum harry_meas ((λxs. xs @ [False]) ` seqs (Suc n) ∪ (λxs. True # xs @ [True]) ` seqs n) + sum harry_meas ((λxs. False # xs @ [True]) ` seqs n)) = int (harry_sum (Suc n)) + int (∑xs∈seqs n. 1 + harry_meas (xs @ [True])) + int (∑xs∈seqs n. harry_meas (False # xs @ [True]))›*) apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹finite ((λxs. xs @ [False]) ` seqs (Suc n))› 2. ‹finite ((λxs. True # xs @ [True]) ` seqs n)› 3. ‹(λxs. xs @ [False]) ` seqs (Suc n) ∩ (λxs. True # xs @ [True]) ` seqs n = {}› 4. ‹(∑x∈(λxs. xs @ [False]) ` seqs (Suc n). int (harry_meas x)) + (∑x∈(λxs. True # xs @ [True]) ` seqs n. int (harry_meas x)) + (∑x∈(λxs. False # xs @ [True]) ` seqs n. int (harry_meas x)) = (∑x∈seqs (Suc n). int (harry_meas x)) + (∑x∈seqs n. 1 + int (harry_meas (x @ [True]))) + (∑x∈seqs n. int (harry_meas (False # x @ [True])))› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) = (∀x::?'a::type∈?A. ∀y::?'a::type∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum (n::nat) = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) = (∀x::?'a::type∈?A. ∀y::?'a::type∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum (n::nat) = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 3*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum (n::nat) = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 4*) apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λxs. xs @ [False]) (seqs (Suc n))› 2. ‹sum ((λx. int (harry_meas x)) ∘ (λxs. xs @ [False])) (seqs (Suc n)) + (∑x∈(λxs. True # xs @ [True]) ` seqs n. int (harry_meas x)) + (∑x∈(λxs. False # xs @ [True]) ` seqs n. int (harry_meas x)) = (∑x∈seqs (Suc n). int (harry_meas x)) + (∑x∈seqs n. 1 + int (harry_meas (x @ [True]))) + (∑x∈seqs n. int (harry_meas (False # x @ [True])))› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*goal: ‹sum ((λx. int (harry_meas x)) ∘ (λxs. xs @ [False])) (seqs (Suc n)) + (∑x∈(λxs. True # xs @ [True]) ` seqs n. int (harry_meas x)) + (∑x∈(λxs. False # xs @ [True]) ` seqs n. int (harry_meas x)) = (∑x∈seqs (Suc n). int (harry_meas x)) + (∑x∈seqs n. 1 + int (harry_meas (x @ [True]))) + (∑x∈seqs n. int (harry_meas (False # x @ [True])))›*) apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λxs. True # xs @ [True]) (seqs n)› 2. ‹sum ((λx. int (harry_meas x)) ∘ (λxs. True # xs @ [True])) (seqs n) + (∑x∈(λxs. False # xs @ [True]) ` seqs n. int (harry_meas x)) = (∑x∈seqs n. 1 + int (harry_meas (x @ [True]))) + (∑x∈seqs n. int (harry_meas (False # x @ [True])))› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*goal: ‹sum ((λx. int (harry_meas x)) ∘ (λxs. True # xs @ [True])) (seqs n) + (∑x∈(λxs. False # xs @ [True]) ` seqs n. int (harry_meas x)) = (∑x∈seqs n. 1 + int (harry_meas (x @ [True]))) + (∑x∈seqs n. int (harry_meas (False # x @ [True])))›*) apply (subst sum.union_disjoint (*‹⟦finite (?A::?'b::type set); finite (?B::?'b::type set); ?A ∩ ?B = {}⟧ ⟹ sum (?g::?'b::type ⇒ ?'a::comm_monoid_add) (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on (?h::?'b::type ⇒ ?'c::type) (?A::?'b::type set) ⟹ sum (?g::?'c::type ⇒ ?'a::comm_monoid_add) (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λxs. False # xs @ [True]) (seqs n)› 2. ‹sum ((λx. int (harry_meas x)) ∘ (λxs. False # xs @ [True])) (seqs n) = (∑x∈seqs n. int (harry_meas (False # x @ [True])))› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) = (∀x::?'a::type∈?A. ∀y::?'a::type∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum (n::nat) = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) 3 (*‹harry_sum n = sum harry_meas (seqs n)› ‹harry_sum (Suc n) = sum harry_meas (seqs (Suc n))›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 4 subgoals*) (*proven 4 subgoals*) . also (*calculation: ‹int (sum harry_meas (seqs (Suc (Suc n)))) = int (harry_sum (Suc n)) + int (∑xs∈seqs n. 1 + harry_meas (xs @ [True])) + int (∑xs∈seqs n. harry_meas (False # xs @ [True]))›*) have "int (∑xs∈seqs n. 1 + harry_meas (xs @ [True])) = 2 ^ n + int (∑xs∈seqs n. harry_meas (xs @ [True]))" apply (subst sum.distrib (*‹(∑x∈?A. ?g x + ?h x) = sum ?g ?A + sum ?h ?A›*)) (*goal: ‹int (∑xs∈seqs n. 1 + harry_meas (xs @ [True])) = 2 ^ n + int (∑xs∈seqs n. harry_meas (xs @ [True]))›*) by auto also (*calculation: ‹int (sum harry_meas (seqs (Suc (Suc n)))) = int (harry_sum (Suc n)) + (2 ^ n + int (∑xs∈seqs n. harry_meas (xs @ [True]))) + int (∑xs∈seqs n. harry_meas (False # xs @ [True]))›*) have "(∑xs∈seqs n. harry_meas (False # xs @ [True])) = harry_sum n + (2 * n + 3) * 2 ^ n" by (auto simp: 3 (*‹harry_sum (n::nat) = sum harry_meas (seqs n)› ‹harry_sum (Suc (n::nat)) = sum harry_meas (seqs (Suc n))›*) harry_meas_False_True (*‹harry_meas (False # (?xs::bool list) @ [True]) = harry_meas ?xs + (2::nat) * length ?xs + (3::nat)›*) sum.distrib (*‹(∑x::?'b∈(?A::?'b set). (?g::?'b ⇒ ?'a) x + (?h::?'b ⇒ ?'a) x) = sum ?g ?A + sum ?h ?A›*) algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 15 facts*) length_seqs (*‹(?xs::bool list) ∈ seqs (?n::nat) ⟹ length ?xs = ?n›*)) also (*calculation: ‹int (sum harry_meas (seqs (Suc (Suc n)))) = int (harry_sum (Suc n)) + (2 ^ n + int (∑xs∈seqs n. harry_meas (xs @ [True]))) + int (harry_sum n + (2 * n + 3) * 2 ^ n)›*) have "harry_sum (Suc n) = (∑xs∈seqs n. harry_meas (xs @ [True])) + harry_sum n" unfolding seqs_Suc' "3" (*goal: ‹sum harry_meas ((λxs::bool list. xs @ [True]) ` seqs (n::nat) ∪ (λxs::bool list. xs @ [False]) ` seqs n) = (∑xs::bool list∈seqs n. harry_meas (xs @ [True])) + sum harry_meas (seqs n)›*) apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹finite ((λxs. xs @ [True]) ` seqs n)› 2. ‹finite ((λxs. xs @ [False]) ` seqs n)› 3. ‹(λxs. xs @ [True]) ` seqs n ∩ (λxs. xs @ [False]) ` seqs n = {}› 4. ‹sum harry_meas ((λxs. xs @ [True]) ` seqs n) + sum harry_meas ((λxs. xs @ [False]) ` seqs n) = (∑xs∈seqs n. harry_meas (xs @ [True])) + sum harry_meas (seqs n)› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 3*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 4*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*goal: ‹sum harry_meas ((λxs::bool list. xs @ [True]) ` seqs (n::nat)) + sum harry_meas ((λxs::bool list. xs @ [False]) ` seqs n) = (∑xs::bool list∈seqs n. harry_meas (xs @ [True])) + sum harry_meas (seqs n)›*) apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λxs. xs @ [True]) (seqs n)› 2. ‹sum (harry_meas ∘ (λxs. xs @ [True])) (seqs n) + sum harry_meas ((λxs. xs @ [False]) ` seqs n) = (∑xs∈seqs n. harry_meas (xs @ [True])) + sum harry_meas (seqs n)› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*goal: ‹sum (harry_meas ∘ (λxs. xs @ [True])) (seqs n) + sum harry_meas ((λxs. xs @ [False]) ` seqs n) = (∑xs∈seqs n. harry_meas (xs @ [True])) + sum harry_meas (seqs n)›*) apply (subst sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*) sum.reindex (*‹inj_on ?h ?A ⟹ sum ?g (?h ` ?A) = sum (?g ∘ ?h) ?A›*)) (*goals: 1. ‹inj_on (λxs. xs @ [False]) (seqs n)› 2. ‹sum (harry_meas ∘ (λxs. xs @ [False])) (seqs n) = sum harry_meas (seqs n)› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 4 subgoals*) . hence "int (∑xs∈seqs n. harry_meas (xs @ [True])) = int (harry_sum (Suc n)) - int (harry_sum n)" by simp finally (*calculation: ‹int (sum harry_meas (seqs (Suc (Suc (n::nat))))) = int (harry_sum (Suc n)) + ((2::int) ^ n + (int (harry_sum (Suc n)) - int (harry_sum n))) + int (harry_sum n + ((2::nat) * n + (3::nat)) * (2::nat) ^ n)›*) have "int (∑x∈seqs (Suc (Suc n)). harry_meas x) = int (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)" unfolding of_nat_add (*goal: ‹int (sum harry_meas (seqs (Suc (Suc n)))) = int (2 * harry_sum (Suc n)) + int ((2 * n + 4) * 2 ^ n)›*) by (simp add: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 15 facts*)) hence "(∑x∈seqs (Suc (Suc n)). (harry_meas x)) = (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)" by linarith thus "?case" (*goal: ‹harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))›*) by simp qed (auto simp: seqs_Suc (*‹seqs (Suc ?n) = (#) True ` seqs ?n ∪ (#) False ` seqs ?n›*)) (*solves the remaining goals: 1. ‹harry_sum (0::nat) = sum harry_meas (seqs (0::nat))› 2. ‹harry_sum (Suc (0::nat)) = sum harry_meas (seqs (Suc (0::nat)))›*) lemma harry_sum_closed_form_aux: "4 * harry_sum n = n * (n + 1) * 2 ^ n" apply (induction n rule: harry_sum.induct (*‹⟦?P 0; ?P (Suc 0); ⋀n. ?P (Suc n) ⟹ ?P (Suc (Suc n))⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹4 * harry_sum 0 = 0 * (0 + 1) * 2 ^ 0› 2. ‹4 * harry_sum (Suc 0) = Suc 0 * (Suc 0 + 1) * 2 ^ Suc 0› 3. ‹⋀n. 4 * harry_sum (Suc n) = Suc n * (Suc n + 1) * 2 ^ Suc n ⟹ 4 * harry_sum (Suc (Suc n)) = Suc (Suc n) * (Suc (Suc n) + 1) * 2 ^ Suc (Suc n)› discuss goal 1*) apply ((auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*))[1]) (*discuss goal 2*) apply ((auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*))[1]) (*discuss goal 3*) apply ((auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*))[1]) (*proven 3 subgoals*) . text ‹ Solving the recurrence gives us the following solution: › theorem harry_sum_closed_form: "harry_sum n = n * (n + 1) * 2 ^ n div 4" using harry_sum_closed_form_aux[of n] (*‹(4::nat) * harry_sum (n::nat) = n * (n + (1::nat)) * (2::nat) ^ n›*) by simp text ‹ The average is now a simple consequence: › definition harry_avg where "harry_avg n = harry_sum n / card (seqs n)" corollary "harry_avg n = n * (n + 1) / 4" proof (-) (*goal: ‹harry_avg n = real n * (real n + 1) / 4›*) have "real (4 * harry_sum n) = n * (n + 1) * 2 ^ n" apply (subst harry_sum_closed_form_aux (*‹(4::nat) * harry_sum (?n::nat) = ?n * (?n + (1::nat)) * (2::nat) ^ ?n›*)) (*goal: ‹real (4 * harry_sum n) = real (n * (n + 1) * 2 ^ n)›*) by auto hence "real (harry_sum n) = n * (n + 1) * 2 ^ n / 4" by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*)) thus "?thesis" (*goal: ‹harry_avg (n::nat) = real n * (real n + (1::real)) / (4::real)›*) by (simp add: harry_avg_def (*‹harry_avg ?n = real (harry_sum ?n) / real (card (seqs ?n))›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*)) qed end
{ "path": "afp-2025-02-12/thys/IMO2019/IMO2019_Q5.thy", "repo": "afp-2025-02-12", "sha": "fb758944e3470b8dc096b9441d63ae45afe9556b2fc3b58ae93a434f2809ab1e" }
section ‹Generic Computability› theory Computability imports HOLCF HOLCFUtils begin text ‹ Shivers proves the computability of the abstract semantics functions only by generic and slightly simplified example. This theory contains the abstract treatment in Section 4.4.3. Later, we will work out the details apply this to ‹\<aPR>›. › subsection ‹Non-branching case› text ‹ After the following lemma (which could go into @{theory HOL.Set_Interval}), we show Shivers' Theorem 10. This says that the least fixed point of the equation \[ f\ x = g\ x \cup f\ (r\ x) \] is given by \[ f\ x = \bigcup_{i\ge 0} g\ (r^i\ x). \] The proof follows the standard proof of showing an equality involving a fixed point: First we show that the right hand side fulfills the above equation and then show that our solution is less than any other solution to that equation. › lemma insert_greaterThan: "insert (n::nat) {n<..} = {n..}" by auto lemma theorem10: fixes g :: "'a::cpo → 'b::type set" and r :: "'a → 'a" shows "fix⋅(Λ f x. g⋅x ∪ f⋅(r⋅x)) = (Λ x. (⋃i. g⋅(r⇗i⇖⋅x)))" proof (induct rule:fix_eqI[OF cfun_eqI cfun_belowI, case_names fp least] (*‹⟦⋀x. ?F⋅?x⋅x = ?x⋅x; ⋀z x. ?F⋅z = z ⟹ ?x⋅x ⊑ z⋅x⟧ ⟹ fix⋅?F = ?x›*)) (*goals: 1. ‹⋀x::'a::cpo. (Λ (f::'a::cpo → 'b::type set) (x::'a::cpo). (g::'a::cpo → 'b::type set)⋅x ∪ f⋅((r::'a::cpo → 'a::cpo)⋅x))⋅(Λ (x::'a::cpo). ⋃i::nat. g⋅(r⇗i⇖⋅x))⋅x = (Λ (x::'a::cpo). ⋃i::nat. g⋅(r⇗i⇖⋅x))⋅x› 2. ‹⋀(z::'a::cpo → 'b::type set) x::'a::cpo. (Λ (f::'a::cpo → 'b::type set) (x::'a::cpo). (g::'a::cpo → 'b::type set)⋅x ∪ f⋅((r::'a::cpo → 'a::cpo)⋅x))⋅z = z ⟹ (Λ (x::'a::cpo). ⋃i::nat. g⋅(r⇗i⇖⋅x))⋅x ⊑ z⋅x›*) case (fp x) (*no hyothesis introduced yet*) have "g⋅x ∪ (⋃i. g⋅(r⇗i⇖⋅(r⋅x))) = g⋅(r⇗0⇖⋅x) ∪ (⋃i. g⋅(r⇗Suc i⇖⋅x))" by (simp add: iterate_Suc2 (*‹(?F::?'a → ?'a)⇗Suc (?n::nat)⇖⋅(?x::?'a) = ?F⇗?n⇖⋅(?F⋅?x)›*) del: iterate_Suc (*‹(?F::?'a → ?'a)⇗Suc (?n::nat)⇖⋅(?x::?'a) = ?F⋅(?F⇗?n⇖⋅?x)›*)) also (*calculation: ‹(g::'a → 'b set)⋅(x::'a) ∪ (⋃i::nat. g⋅((r::'a → 'a)⇗i⇖⋅(r⋅x))) = g⋅(r⇗0::nat⇖⋅x) ∪ (⋃i::nat. g⋅(r⇗Suc i⇖⋅x))›*) have "… = g⋅(r⇗0⇖⋅x) ∪ (⋃i∈{0<..}. g⋅(r⇗i⇖⋅x))" using less_iff_Suc_add (*‹(?m < ?n) = (∃k. ?n = Suc (?m + k))›*) by auto also (*calculation: ‹g⋅x ∪ (⋃i. g⋅(r⇗i⇖⋅(r⋅x))) = g⋅(r⇗0⇖⋅x) ∪ (⋃i∈{0<..}. g⋅(r⇗i⇖⋅x))›*) have "… = (⋃i∈insert 0 {0<..}. g⋅(r⇗i⇖⋅x))" by simp also (*calculation: ‹(g::'a → 'b set)⋅(x::'a) ∪ (⋃i::nat. g⋅((r::'a → 'a)⇗i⇖⋅(r⋅x))) = (⋃i::nat∈insert (0::nat) {0::nat<..}. g⋅(r⇗i⇖⋅x))›*) have "... = (⋃i. g⋅(r⇗i⇖⋅x))" by (simp only: insert_greaterThan (*‹insert ?n {?n<..} = {?n..}›*) atLeast_0 (*‹{0..} = UNIV›*)) finally (*calculation: ‹g⋅x ∪ (⋃i. g⋅(r⇗i⇖⋅(r⋅x))) = (⋃i. g⋅(r⇗i⇖⋅x))›*) show "?case" (*goal: ‹(Λ f x. g⋅x ∪ f⋅(r⋅x))⋅(Λ x. ⋃i. g⋅(r⇗i⇖⋅x))⋅x = (Λ x. ⋃i. g⋅(r⇗i⇖⋅x))⋅x›*) by auto next (*goal: ‹⋀z x. (Λ f x. g⋅x ∪ f⋅(r⋅x))⋅z = z ⟹ (Λ x. ⋃i. g⋅(r⇗i⇖⋅x))⋅x ⊑ z⋅x›*) case (least f x) (*‹(Λ f x. g⋅x ∪ f⋅(r⋅x))⋅f = f›*) hence expand: "⋀x. f⋅x = (g⋅x ∪ f⋅(r⋅x))" by (auto simp:cfun_eq_iff (*‹(?f = ?g) = (∀x. ?f⋅x = ?g⋅x)›*)) { fix n have "f⋅x = (⋃i∈{..n}. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc n⇖⋅x)" proof (induct n) (*goals: 1. ‹f⋅x = (⋃i≤0. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc 0⇖⋅x)› 2. ‹⋀n. f⋅x = (⋃i≤n. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc n⇖⋅x) ⟹ f⋅x = (⋃i≤Suc n. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)›*) case 0 (*no hyothesis introduced yet*) thus "?case" (*goal: ‹(f::'a::cpo → 'b::type set)⋅(x::'a::cpo) = (⋃i::nat≤0::nat. (g::'a::cpo → 'b::type set)⋅((r::'a::cpo → 'a::cpo)⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (0::nat)⇖⋅x)›*) by (auto simp add:expand[of x] (*‹f⋅x = g⋅x ∪ f⋅(r⋅x)›*)) case (Suc n) (*‹(f::'a → 'b set)⋅(x::'a) = (⋃i::nat≤n::nat. (g::'a → 'b set)⋅((r::'a → 'a)⇗i⇖⋅x)) ∪ f⋅(r⇗Suc n⇖⋅x)›*) then have "f⋅x = (⋃i∈{..n}. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc n⇖⋅x)" by simp also (*calculation: ‹f⋅x = (⋃i≤n. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc n⇖⋅x)›*) have "… = (⋃i∈{..n}. g⋅(r⇗i⇖⋅x)) ∪ g⋅(r⇗Suc n⇖⋅x) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)" apply (subst expand[of "r⇗Suc n⇖⋅x"] (*‹f⋅(r⇗Suc n⇖⋅x) = g⋅(r⇗Suc n⇖⋅x) ∪ f⋅(r⋅(r⇗Suc n⇖⋅x))›*)) (*goal: ‹(⋃i≤n. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc n⇖⋅x) = (⋃i≤n. g⋅(r⇗i⇖⋅x)) ∪ g⋅(r⇗Suc n⇖⋅x) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)›*) by auto also (*calculation: ‹(f::'a::cpo → 'b::type set)⋅(x::'a::cpo) = (⋃i::nat≤n::nat. (g::'a::cpo → 'b::type set)⋅((r::'a::cpo → 'a::cpo)⇗i⇖⋅x)) ∪ g⋅(r⇗Suc n⇖⋅x) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)›*) have "… = (⋃i∈insert (Suc n) {..n}. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)" by auto also (*calculation: ‹f⋅x = (⋃i∈insert (Suc n) {..n}. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)›*) have "… = (⋃i∈{..Suc n}. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)" by (simp add:atMost_Suc (*‹{..Suc ?k} = insert (Suc ?k) {..?k}›*)) finally (*calculation: ‹f⋅x = (⋃i≤Suc n. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)›*) show "?case" (*goal: ‹f⋅x = (⋃i≤Suc n. g⋅(r⇗i⇖⋅x)) ∪ f⋅(r⇗Suc (Suc n)⇖⋅x)›*) . qed } note fin = this (*‹(f::'a → 'b set)⋅(x::'a) = (⋃i::nat≤?n2::nat. (g::'a → 'b set)⋅((r::'a → 'a)⇗i⇖⋅x)) ∪ f⋅(r⇗Suc ?n2⇖⋅x)›*) have "(⋃i. g⋅(r⇗i⇖⋅x)) ⊆ f⋅x" proof (rule UN_least (*‹(⋀x. x ∈ ?A ⟹ ?B x ⊆ ?C) ⟹ ⋃ (?B ` ?A) ⊆ ?C›*)) (*goal: ‹⋀i::nat. i ∈ UNIV ⟹ (g::'a → 'b set)⋅((r::'a → 'a)⇗i⇖⋅(x::'a)) ⊆ (f::'a → 'b set)⋅x›*) fix i show "g⋅(r⇗i⇖⋅x) ⊆ f⋅x" using fin[of i] (*‹(f::'a → 'b set)⋅(x::'a) = (⋃i::nat≤i::nat. (g::'a → 'b set)⋅((r::'a → 'a)⇗i⇖⋅x)) ∪ f⋅(r⇗Suc i⇖⋅x)›*) by auto qed thus "?case" (*goal: ‹(Λ x. ⋃i. g⋅(r⇗i⇖⋅x))⋅x ⊑ f⋅x›*) apply (subst sqsubset_is_subset (*‹(?A ⊑ ?B) = (?A ⊆ ?B)›*)) (*goal: ‹(Λ x. ⋃i. g⋅(r⇗i⇖⋅x))⋅x ⊑ f⋅x›*) by auto qed subsection ‹Branching case› text ‹ Actually, our functions are more complicated than the one above: The abstract semantics functions recurse with multiple arguments. So we have to handle a recursive equation of the kind \[ f\ x = g\ x \cup \bigcup_{a \in R\ x} f\ r. \] By moving to the power-set relatives of our function, e.g. \[ {\uline g}Y = \bigcup_{a\in A} g\ a \quad \text{and} {\uline R}Y = \bigcup_{a\in R} R\ a \] the equation becomes \[ {\uline f}Y ={\uline g}Y \cup {\uline f}\ ({\uline R}Y) \] (which is shown in Lemma 11) and we can apply Theorem 10 to obtain Theorem 12. We define the power-set relative for a function together with some properties. › definition powerset_lift :: "('a::cpo → 'b::type set) ⇒ 'a set → 'b set" ("\<^ps>") where "\<^ps>f = (Λ S. (⋃y∈S . f⋅y))" lemma powerset_lift_singleton[simp]: "\<^ps>f⋅{x} = f⋅x" unfolding powerset_lift_def (*goal: ‹(Λ S. ⋃ (Rep_cfun f ` S))⋅{x} = f⋅x›*) by simp lemma powerset_lift_union[simp]: "\<^ps>f⋅(A ∪ B) = \<^ps>f⋅A ∪ \<^ps>f⋅B" unfolding powerset_lift_def (*goal: ‹(Λ S. ⋃ (Rep_cfun f ` S))⋅(A ∪ B) = (Λ S. ⋃ (Rep_cfun f ` S))⋅A ∪ (Λ S. ⋃ (Rep_cfun f ` S))⋅B›*) by auto lemma UNION_commute:"(⋃x∈A. ⋃y∈B . P x y) = (⋃y∈B. ⋃x∈A . P x y)" by auto lemma powerset_lift_UNION: "(⋃x∈S. \<^ps>g⋅(A x)) = \<^ps>g⋅(⋃x∈S. A x)" unfolding powerset_lift_def (*goal: ‹(⋃x∈S. (Λ S. ⋃ (Rep_cfun g ` S))⋅(A x)) = (Λ S. ⋃ (Rep_cfun g ` S))⋅(⋃ (A ` S))›*) by auto lemma powerset_lift_iterate_UNION: "(⋃x∈S. (\<^ps>g)⇗i⇖⋅(A x)) = (\<^ps>g)⇗i⇖⋅(⋃x∈S. A x)" apply (induct i) (*goals: 1. ‹(⋃x∈S. (\<^ps> g)⇗0⇖⋅(A x)) = (\<^ps> g)⇗0⇖⋅(⋃ (A ` S))› 2. ‹⋀i. (⋃x∈S. (\<^ps> g)⇗i⇖⋅(A x)) = (\<^ps> g)⇗i⇖⋅(⋃ (A ` S)) ⟹ (⋃x∈S. (\<^ps> g)⇗Suc i⇖⋅(A x)) = (\<^ps> g)⇗Suc i⇖⋅(⋃ (A ` S))› discuss goal 1*) apply ((auto simp add:powerset_lift_UNION (*‹(⋃x∈?S. \<^ps> ?g⋅(?A x)) = \<^ps> ?g⋅(⋃ (?A ` ?S))›*))[1]) (*discuss goal 2*) apply ((auto simp add:powerset_lift_UNION (*‹(⋃x∈?S. \<^ps> ?g⋅(?A x)) = \<^ps> ?g⋅(⋃ (?A ` ?S))›*))[1]) (*proven 2 subgoals*) . lemmas powerset_distr = powerset_lift_UNION powerset_lift_iterate_UNION text ‹ Lemma 11 shows that if a function satisfies the relation with the branching $R$, its power-set function satisfies the powerset variant of the equation. › lemma lemma11: fixes f :: "'a → 'b set" and g :: "'a → 'b set" and R :: "'a → 'a set" assumes "⋀x. f⋅x = g⋅x ∪ (⋃y∈R⋅x. f⋅y)" shows "\<^ps>f⋅S = \<^ps>g⋅S ∪ \<^ps>f⋅(\<^ps>R⋅S)" proof (-) (*goal: ‹\<^ps> f⋅S = \<^ps> g⋅S ∪ \<^ps> f⋅(\<^ps> R⋅S)›*) have "\<^ps>f⋅S = (⋃x∈S . f⋅x)" unfolding powerset_lift_def (*goal: ‹(Λ S. ⋃ (Rep_cfun f ` S))⋅S = ⋃ (Rep_cfun f ` S)›*) by auto also (*calculation: ‹\<^ps> f⋅S = ⋃ (Rep_cfun f ` S)›*) have "… = (⋃x∈S . g⋅x ∪ (⋃y∈R⋅x. f⋅y))" apply (subst assms (*‹f⋅?x = g⋅?x ∪ ⋃ (Rep_cfun f ` R⋅?x)›*)) (*goal: ‹⋃ (Rep_cfun f ` S) = (⋃x∈S. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))›*) by simp also (*calculation: ‹\<^ps> f⋅S = (⋃x∈S. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))›*) have "… = \<^ps>g⋅S ∪ \<^ps>f⋅(\<^ps>R⋅S)" by (auto simp add:powerset_lift_def (*‹\<^ps> ?f = (Λ S. ⋃ (Rep_cfun ?f ` S))›*)) finally (*calculation: ‹\<^ps> f⋅S = \<^ps> g⋅S ∪ \<^ps> f⋅(\<^ps> R⋅S)›*) show "?thesis" (*goal: ‹\<^ps> f⋅S = \<^ps> g⋅S ∪ \<^ps> f⋅(\<^ps> R⋅S)›*) . qed text ‹ Theorem 10 as it will be used in Theorem 12. › lemmas theorem10ps = theorem10[of "\<^ps>g" "\<^ps>r"] for g r text ‹ Now we can show Lemma 12: If $F$ is the least solution to the recursive power-set equation, then $x \mapsto F\ {x}$ is the least solution to the equation with branching $R$. We fix the type variable ‹'a› to be a discrete cpo, as otherwise $x \mapsto \{x\}$ is not continuous. › (* discrete_cpo, otherwise x ↦ {x} not continuous *) lemma theorem12': fixes g :: "'a::discrete_cpo → 'b::type set" and R :: "'a → 'a set" assumes F_fix: "F = fix⋅(Λ F x. \<^ps>g⋅x ∪ F⋅(\<^ps>R⋅x))" shows "fix⋅(Λ f x. g⋅x ∪ (⋃y∈R⋅x. f⋅y)) = (Λ x. F⋅{x})" proof (induct rule:fix_eqI[OF cfun_eqI cfun_belowI, case_names fp least] (*‹⟦⋀x. ?F⋅?x⋅x = ?x⋅x; ⋀z x. ?F⋅z = z ⟹ ?x⋅x ⊑ z⋅x⟧ ⟹ fix⋅?F = ?x›*)) (*goals: 1. ‹⋀x. (Λ f x. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))⋅(Λ x. F⋅{x})⋅x = (Λ x. F⋅{x})⋅x› 2. ‹⋀z x. (Λ f x. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))⋅z = z ⟹ (Λ x. F⋅{x})⋅x ⊑ z⋅x›*) have F_union: "F = (Λ x. ⋃i. \<^ps>g⋅((\<^ps>R)⇗i⇖⋅x))" using F_fix (*‹F = (μ F. Λ x. \<^ps> g⋅x ∪ F⋅(\<^ps> R⋅x))›*) apply simp (*goal: ‹(F::'a::discrete_cpo set → 'b::type set) = (Λ (x::'a::discrete_cpo set). ⋃i::nat. \<^ps> (g::'a::discrete_cpo → 'b::type set)⋅((\<^ps> (R::'a::discrete_cpo → 'a::discrete_cpo set))⇗i⇖⋅x))›*) by (rule theorem10ps (*‹(μ f. Λ x. \<^ps> ?g⋅x ∪ f⋅(\<^ps> ?r⋅x)) = (Λ x. ⋃i. \<^ps> ?g⋅((\<^ps> ?r)⇗i⇖⋅x))›*)) case (fp x) (*no hyothesis introduced yet*) have "g⋅x ∪ (⋃x'∈R⋅x. F⋅{x'}) = \<^ps>g⋅{x} ∪ F⋅(\<^ps>R⋅{x})" unfolding powerset_lift_singleton (*goal: ‹g⋅x ∪ (⋃x'∈R⋅x. F⋅{x'}) = g⋅x ∪ F⋅(R⋅x)›*) by (auto simp add: powerset_distr (*‹(⋃x∈?S. \<^ps> ?g⋅(?A x)) = \<^ps> ?g⋅(⋃ (?A ` ?S))› ‹(⋃x∈?S. (\<^ps> ?g)⇗?i⇖⋅(?A x)) = (\<^ps> ?g)⇗?i⇖⋅(⋃ (?A ` ?S))›*) UNION_commute (*‹(⋃x∈?A. ⋃ (?P x ` ?B)) = (⋃y∈?B. ⋃x∈?A. ?P x y)›*) F_union (*‹F = (Λ x. ⋃i. \<^ps> g⋅((\<^ps> R)⇗i⇖⋅x))›*)) also (*calculation: ‹g⋅x ∪ (⋃x'∈R⋅x. F⋅{x'}) = \<^ps> g⋅{x} ∪ F⋅(\<^ps> R⋅{x})›*) have "… = F⋅{x}" apply (subst (2) fix_eq4[OF F_fix] (*‹(F::'a set → 'b set) = (Λ (F::'a set → 'b set) (x::'a set). \<^ps> (g::'a → 'b set)⋅x ∪ F⋅(\<^ps> (R::'a → 'a set)⋅x))⋅F›*)) (*goal: ‹\<^ps> g⋅{x} ∪ F⋅(\<^ps> R⋅{x}) = F⋅{x}›*) by auto finally (*calculation: ‹g⋅x ∪ (⋃x'∈R⋅x. F⋅{x'}) = F⋅{x}›*) show "?case" (*goal: ‹(Λ f x. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))⋅(Λ x. F⋅{x})⋅x = (Λ x. F⋅{x})⋅x›*) by simp next (*goal: ‹⋀z x. (Λ f x. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))⋅z = z ⟹ (Λ x. F⋅{x})⋅x ⊑ z⋅x›*) case (least f' x) (*‹(Λ f x. g⋅x ∪ ⋃ (Rep_cfun f ` R⋅x))⋅f' = f'›*) hence expand: "f' = (Λ x. g⋅x ∪ (⋃y∈R⋅x. f'⋅y))" by simp have "\<^ps>f' = (Λ S. \<^ps>g⋅S ∪ \<^ps>f'⋅(\<^ps>R⋅S))" apply (subst expand (*‹f' = (Λ x. g⋅x ∪ ⋃ (Rep_cfun f' ` R⋅x))›*)) (*goal: ‹\<^ps> f' = (Λ S. \<^ps> g⋅S ∪ \<^ps> f'⋅(\<^ps> R⋅S))›*) apply (rule cfun_eqI (*‹(⋀x. ?f⋅x = ?g⋅x) ⟹ ?f = ?g›*)) (*goal: ‹\<^ps> (Λ x. g⋅x ∪ ⋃ (Rep_cfun f' ` R⋅x)) = (Λ S. \<^ps> g⋅S ∪ \<^ps> f'⋅(\<^ps> R⋅S))›*) by (auto simp add:powerset_lift_def (*‹\<^ps> ?f = (Λ S. ⋃ (Rep_cfun ?f ` S))›*)) hence "(Λ F. Λ x. \<^ps>g⋅x ∪ F⋅(\<^ps>R⋅x))⋅(\<^ps>f') = \<^ps>f'" by simp from fix_least[OF this] (*‹(μ F. Λ x. \<^ps> g⋅x ∪ F⋅(\<^ps> R⋅x)) ⊑ \<^ps> f'›*) F_fix (*‹F = (μ F. Λ x. \<^ps> g⋅x ∪ F⋅(\<^ps> R⋅x))›*) have "F ⊑ \<^ps>f'" by simp hence "F⋅{x} ⊑ \<^ps>f'⋅{x}" apply (subst (asm)cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*)) (*goal: ‹F⋅{x} ⊑ \<^ps> f'⋅{x}›*) by (auto simp del:powerset_lift_singleton (*‹\<^ps> (?f::?'b::cpo → ?'a::type set)⋅{?x::?'b::cpo} = ?f⋅?x›*)) thus "?case" (*goal: ‹(Λ x. F⋅{x})⋅x ⊑ f'⋅x›*) by (auto simp add:sqsubset_is_subset (*‹(?A ⊑ ?B) = (?A ⊆ ?B)›*)) qed lemma theorem12: fixes g :: "'a::discrete_cpo → 'b::type set" and R :: "'a → 'a set" shows "fix⋅(Λ f x. g⋅x ∪ (⋃y∈R⋅x. f⋅y))⋅x = \<^ps>g⋅(⋃i.((\<^ps>R)⇗i⇖⋅{x}))" apply (subst theorem12'[OF theorem10ps[THEN sym]] (*‹(μ f. Λ x. ?g⋅x ∪ ⋃ (Rep_cfun f ` ?R⋅x)) = (Λ x. (Λ x. ⋃i. \<^ps> ?g⋅((\<^ps> ?R)⇗i⇖⋅x))⋅{x})›*)) (*goal: ‹(μ f::'a::discrete_cpo → 'b::type set. Λ (x::'a::discrete_cpo). (g::'a::discrete_cpo → 'b::type set)⋅x ∪ ⋃ (Rep_cfun f ` (R::'a::discrete_cpo → 'a::discrete_cpo set)⋅x))⋅(x::'a::discrete_cpo) = \<^ps> g⋅(⋃i::nat. (\<^ps> R)⇗i⇖⋅{x})›*) by (auto simp add:powerset_distr (*‹(⋃x::?'b::type∈?S::?'b::type set. \<^ps> (?g::?'c::cpo → ?'a::type set)⋅((?A::?'b::type ⇒ ?'c::cpo set) x)) = \<^ps> ?g⋅(⋃ (?A ` ?S))› ‹(⋃x::?'b::type∈?S::?'b::type set. (\<^ps> (?g::?'a::cpo → ?'a::cpo set))⇗?i::nat⇖⋅((?A::?'b::type ⇒ ?'a::cpo set) x)) = (\<^ps> ?g)⇗?i⇖⋅(⋃ (?A ` ?S))›*)) end
{ "path": "afp-2025-02-12/thys/Shivers-CFA/Computability.thy", "repo": "afp-2025-02-12", "sha": "402c193e8f3a7db7cb87d7d32c74b5b034b300e37d23afb57c33c4d8eba3826b" }
(* Title: HOL/Wellfounded.thy Author: Tobias Nipkow Author: Lawrence C Paulson Author: Konrad Slind Author: Alexander Krauss Author: Andrei Popescu, TU Muenchen Author: Martin Desharnais, MPI-INF Saarbruecken *) section ‹Well-founded Recursion› theory Wellfounded imports Transitive_Closure begin subsection ‹Basic Definitions› definition wf_on :: "'a set ⇒ 'a rel ⇒ bool" where "wf_on A r ⟷ (∀P. (∀x ∈ A. (∀y ∈ A. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟶ (∀x ∈ A. P x))" abbreviation wf :: "('a × 'a) set ⇒ bool" where "wf ≡ wf_on UNIV" definition wfp_on :: "'a set ⇒ ('a ⇒ 'a ⇒ bool) ⇒ bool" where "wfp_on A R ⟷ (∀P. (∀x ∈ A. (∀y ∈ A. R y x ⟶ P y) ⟶ P x) ⟶ (∀x ∈ A. P x))" abbreviation wfP :: "('a ⇒ 'a ⇒ bool) ⇒ bool" where "wfP ≡ wfp_on UNIV" alias wfp = wfP text ‹We keep old name \<^const>‹wfP› for backward compatibility, but offer new name \<^const>‹wfp› to be consistent with similar predicates, e.g., \<^const>‹asymp›, \<^const>‹transp›, \<^const>‹totalp›.› subsection ‹Equivalence of Definitions› lemma wfp_on_wf_on_eq[pred_set_conv]: "wfp_on A (λx y. (x, y) ∈ r) ⟷ wf_on A r" by (simp add: wfp_on_def (*‹wfp_on ?A ?R = (∀P. (∀x∈?A. (∀y∈?A. ?R y x ⟶ P y) ⟶ P x) ⟶ (∀x∈?A. P x))›*) wf_on_def (*‹wf_on ?A ?r = (∀P. (∀x∈?A. (∀y∈?A. (y, x) ∈ ?r ⟶ P y) ⟶ P x) ⟶ (∀x∈?A. P x))›*)) lemma wf_def: "wf r ⟷ (∀P. (∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟶ (∀x. P x))" unfolding wf_on_def (*goal: ‹(∀P. (∀x∈UNIV. (∀y∈UNIV. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟶ Ball UNIV P) = (∀P. (∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟶ (∀x. P x))›*) by simp lemma wfP_def: "wfP r ⟷ wf {(x, y). r x y}" unfolding wf_def wfp_on_def (*goal: ‹(∀P::'a ⇒ bool. (∀x::'a∈UNIV. (∀y::'a∈UNIV. (r::'a ⇒ 'a ⇒ bool) y x ⟶ P y) ⟶ P x) ⟶ Ball UNIV P) = (∀P::'a ⇒ bool. (∀x::'a. (∀y::'a. (y, x) ∈ {(x::'a, y::'a). r x y} ⟶ P y) ⟶ P x) ⟶ All P)›*) by simp lemma wfP_wf_eq: "wfP (λx y. (x, y) ∈ r) = wf r" using wfp_on_wf_on_eq (*‹wfp_on ?A (λx y. (x, y) ∈ ?r) = wf_on ?A ?r›*) . subsection ‹Induction Principles› lemma wf_on_induct[consumes 1, case_names in_set less, induct set: wf_on]: assumes "wf_on A r" and "x ∈ A" and "⋀x. x ∈ A ⟹ (⋀y. y ∈ A ⟹ (y, x) ∈ r ⟹ P y) ⟹ P x" shows "P x" using assms(2,3) (*‹(x::'a) ∈ (A::'a set)› ‹⟦?x ∈ A; ⋀y. ⟦y ∈ A; (y, ?x) ∈ r⟧ ⟹ P y⟧ ⟹ P ?x›*) by (auto intro: ‹wf_on A r›[unfolded wf_on_def, rule_format]) lemma wfp_on_induct[consumes 1, case_names in_set less, induct pred: wfp_on]: assumes "wfp_on A r" and "x ∈ A" and "⋀x. x ∈ A ⟹ (⋀y. y ∈ A ⟹ r y x ⟹ P y) ⟹ P x" shows "P x" using assms (*‹wfp_on (A::'a set) (r::'a ⇒ 'a ⇒ bool)› ‹x ∈ A› ‹⟦(?x::'a) ∈ (A::'a set); ⋀y::'a. ⟦y ∈ A; (r::'a ⇒ 'a ⇒ bool) y ?x⟧ ⟹ (P::'a ⇒ bool) y⟧ ⟹ P ?x›*) by (fact wf_on_induct[to_pred] (*‹⟦wfp_on ?A ?r; ?x ∈ ?A; ⋀x. ⟦x ∈ ?A; ⋀y. ⟦y ∈ ?A; ?r y x⟧ ⟹ ?P y⟧ ⟹ ?P x⟧ ⟹ ?P ?x›*)) lemma wf_induct: assumes "wf r" and "⋀x. ∀y. (y, x) ∈ r ⟶ P y ⟹ P x" shows "P a" using assms (*‹wf r› ‹∀y. (y, ?x) ∈ r ⟶ P y ⟹ P ?x›*) by (auto intro: wf_on_induct[of UNIV] (*‹⟦wf ?r; ?x ∈ UNIV; ⋀x. ⟦x ∈ UNIV; ⋀y. ⟦y ∈ UNIV; (y, x) ∈ ?r⟧ ⟹ ?P y⟧ ⟹ ?P x⟧ ⟹ ?P ?x›*)) lemmas wfP_induct = wf_induct [to_pred] lemmas wf_induct_rule = wf_induct [rule_format, consumes 1, case_names less, induct set: wf] lemmas wfP_induct_rule = wf_induct_rule [to_pred, induct set: wfP] lemma wf_on_iff_wf: "wf_on A r ⟷ wf {(x, y) ∈ r. x ∈ A ∧ y ∈ A}" proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹wf_on A r ⟹ wf {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A}› 2. ‹wf {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A} ⟹ wf_on A r›*) assume wf: "wf_on A r" (*‹wf_on (A::'a set) (r::('a × 'a) set)›*) show "wf {(x, y) ∈ r. x ∈ A ∧ y ∈ A}" unfolding wf_def (*goal: ‹∀P. (∀x. (∀y. (y, x) ∈ {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A} ⟶ P y) ⟶ P x) ⟶ All P›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀(P::'a ⇒ bool) x::'a. ∀x::'a. (∀y::'a. (y, x) ∈ {(x::'a, y::'a). (x, y) ∈ (r::('a × 'a) set) ∧ x ∈ (A::'a set) ∧ y ∈ A} ⟶ P y) ⟶ P x ⟹ P x›*) fix P and x assume IH: "∀x. (∀y. (y, x) ∈ {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A} ⟶ P y) ⟶ P x" (*‹∀x::'a. (∀y::'a. (y, x) ∈ {(x::'a, y::'a). (x, y) ∈ (r::('a × 'a) set) ∧ x ∈ (A::'a set) ∧ y ∈ A} ⟶ (P::'a ⇒ bool) y) ⟶ P x›*) show "P x" proof (cases "x ∈ A") (*goals: 1. ‹x ∈ A ⟹ P x› 2. ‹x ∉ A ⟹ P x›*) case True (*‹x ∈ A›*) show "?thesis" (*goal: ‹P x›*) using wf (*‹wf_on A r›*) proof (induction x rule: wf_on_induct (*‹⟦wf_on ?A ?r; ?x ∈ ?A; ⋀x. ⟦x ∈ ?A; ⋀y. ⟦y ∈ ?A; (y, x) ∈ ?r⟧ ⟹ ?P y⟧ ⟹ ?P x⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹x ∈ A› 2. ‹⋀x. ⟦x ∈ A; ⋀y. ⟦y ∈ A; (y, x) ∈ r⟧ ⟹ P y⟧ ⟹ P x›*) case in_set (*no hyothesis introduced yet*) thus "?case" (*goal: ‹x ∈ A›*) using True (*‹x ∈ A›*) . next (*goal: ‹⋀x. ⟦x ∈ A; ⋀y. ⟦y ∈ A; (y, x) ∈ r⟧ ⟹ P y⟧ ⟹ P x›*) case (less x) (*‹(x::'a) ∈ (A::'a set)› ‹⟦(?y::'a) ∈ (A::'a set); (?y, x::'a) ∈ (r::('a × 'a) set)⟧ ⟹ (P::'a ⇒ bool) ?y›*) thus "?case" (*goal: ‹P x›*) by (auto intro: IH[rule_format] (*‹(⋀y. (y, ?x) ∈ {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A} ⟹ P y) ⟹ P ?x›*)) qed next (*goal: ‹x ∉ A ⟹ P x›*) case False (*‹x ∉ A›*) then show "?thesis" (*goal: ‹P x›*) by (auto intro: IH[rule_format] (*‹(⋀y. (y, ?x) ∈ {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A} ⟹ P y) ⟹ P ?x›*)) qed qed next (*goal: ‹wf {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A} ⟹ wf_on A r›*) assume wf: "wf {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A}" (*‹wf {(x::'a, y::'a). (x, y) ∈ (r::('a × 'a) set) ∧ x ∈ (A::'a set) ∧ y ∈ A}›*) show "wf_on A r" unfolding wf_on_def (*goal: ‹∀P::'a ⇒ bool. (∀x::'a∈A::'a set. (∀y::'a∈A. (y, x) ∈ (r::('a × 'a) set) ⟶ P y) ⟶ P x) ⟶ Ball A P›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀P x. ⟦∀x∈A. (∀y∈A. (y, x) ∈ r ⟶ P y) ⟶ P x; x ∈ A⟧ ⟹ P x›*) fix P and x assume IH: "∀x∈A. (∀y∈A. (y, x) ∈ r ⟶ P y) ⟶ P x" and "x ∈ A" (*‹∀x::'a∈A::'a set. (∀y::'a∈A. (y, x) ∈ (r::('a × 'a) set) ⟶ (P::'a ⇒ bool) y) ⟶ P x› ‹(x::'a) ∈ (A::'a set)›*) show "P x" using wf (*‹wf {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A}›*) ‹x ∈ A› (*‹(x::'a) ∈ (A::'a set)›*) proof (induction x rule: wf_on_induct (*‹⟦wf_on ?A ?r; ?x ∈ ?A; ⋀x. ⟦x ∈ ?A; ⋀y. ⟦y ∈ ?A; (y, x) ∈ ?r⟧ ⟹ ?P y⟧ ⟹ ?P x⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹(x::'a) ∈ UNIV› 2. ‹⋀x::'a. ⟦x ∈ UNIV; ⋀y::'a. ⟦y ∈ UNIV; (y, x) ∈ {(x::'a, y::'a). (x, y) ∈ (r::('a × 'a) set) ∧ x ∈ (A::'a set) ∧ y ∈ A}; y ∈ A⟧ ⟹ (P::'a ⇒ bool) y; x ∈ A⟧ ⟹ P x›*) case in_set (*no hyothesis introduced yet*) show "?case" (*goal: ‹(x::'a) ∈ UNIV›*) by simp next (*goal: ‹⋀x::'a. ⟦x ∈ UNIV; ⋀y::'a. ⟦y ∈ UNIV; (y, x) ∈ {(x::'a, y::'a). (x, y) ∈ (r::('a × 'a) set) ∧ x ∈ (A::'a set) ∧ y ∈ A}; y ∈ A⟧ ⟹ (P::'a ⇒ bool) y; x ∈ A⟧ ⟹ P x›*) case (less y) (*‹y ∈ UNIV› ‹⟦?y ∈ UNIV; (?y, y) ∈ {(x, y). (x, y) ∈ r ∧ x ∈ A ∧ y ∈ A}; ?y ∈ A⟧ ⟹ P ?y› ‹y ∈ A›*) hence "⋀z. (z, y) ∈ r ⟹ z ∈ A ⟹ P z" by simp thus "?case" (*goal: ‹P y›*) using IH[rule_format, OF ‹y ∈ A›] (*‹(⋀ya. ⟦ya ∈ A; (ya, y) ∈ r⟧ ⟹ P ya) ⟹ P y›*) by simp qed qed qed subsection ‹Introduction Rules› lemma wfUNIVI: "(⋀P x. (∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟹ P x) ⟹ wf r" unfolding wf_def (*goal: ‹(⋀P x. ∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x ⟹ P x) ⟹ ∀P. (∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟶ All P›*) by blast lemmas wfPUNIVI = wfUNIVI [to_pred] text ‹Restriction to domain ‹A› and range ‹B›. If ‹r› is well-founded over their intersection, then ‹wf r›.› lemma wfI: assumes "r ⊆ A × B" and "⋀x P. ⟦∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x; x ∈ A; x ∈ B⟧ ⟹ P x" shows "wf r" using assms (*‹r ⊆ A × B› ‹⟦∀x. (∀y. (y, x) ∈ r ⟶ ?P y) ⟶ ?P x; ?x ∈ A; ?x ∈ B⟧ ⟹ ?P ?x›*) unfolding wf_def (*goal: ‹∀P. (∀x. (∀y. (y, x) ∈ r ⟶ P y) ⟶ P x) ⟶ All P›*) by blast subsection ‹Ordering Properties› lemma wf_not_sym: "wf r ⟹ (a, x) ∈ r ⟹ (x, a) ∉ r" apply (induct a arbitrary: x set: wf) (*goal: ‹⟦wf (r::('a::type × 'a::type) set); (a::'a::type, x::'a::type) ∈ r⟧ ⟹ (x, a) ∉ r›*) by blast lemma wf_asym: assumes "wf r" "(a, x) ∈ r" obtains "(x, a) ∉ r" by (drule wf_not_sym[OF assms] (*‹(x, a) ∉ r›*)) lemma wf_imp_asym: "wf r ⟹ asym r" by (auto intro: asymI (*‹(⋀x y. (x, y) ∈ ?r ⟹ (y, x) ∉ ?r) ⟹ asym ?r›*) elim: wf_asym (*‹⟦wf ?r; (?a, ?x) ∈ ?r; (?x, ?a) ∉ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma wfP_imp_asymp: "wfP r ⟹ asymp r" by (rule wf_imp_asym[to_pred] (*‹wfp ?r ⟹ asymp ?r›*)) lemma wf_not_refl [simp]: "wf r ⟹ (a, a) ∉ r" by (blast elim: wf_asym (*‹⟦wf ?r; (?a, ?x) ∈ ?r; (?x, ?a) ∉ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma wf_irrefl: assumes "wf r" obtains "(a, a) ∉ r" by (drule wf_not_refl[OF assms] (*‹(?a, ?a) ∉ r›*)) lemma wf_imp_irrefl: assumes "wf r" shows "irrefl r" using wf_irrefl[OF assms] (*‹((?a, ?a) ∉ r ⟹ ?thesis) ⟹ ?thesis›*) by (auto simp add: irrefl_def (*‹irrefl ?r = (∀a. (a, a) ∉ ?r)›*)) lemma wfP_imp_irreflp: "wfP r ⟹ irreflp r" by (rule wf_imp_irrefl[to_pred] (*‹wfp ?r ⟹ irreflp ?r›*)) lemma wf_wellorderI: assumes wf: "wf {(x::'a::ord, y). x < y}" and lin: "OFCLASS('a::ord, linorder_class)" shows "OFCLASS('a::ord, wellorder_class)" apply (rule wellorder_class.intro [OF lin] (*‹class.wellorder_axioms (<) ⟹ OFCLASS('a, wellorder_class)›*)) (*goal: ‹OFCLASS('a, wellorder_class)›*) by (simp add: wellorder_class.intro (*‹⟦OFCLASS(?'a, linorder_class); class.wellorder_axioms (<)⟧ ⟹ OFCLASS(?'a, wellorder_class)›*) class.wellorder_axioms.intro (*‹(⋀P a. (⋀x. (⋀y. ?less y x ⟹ P y) ⟹ P x) ⟹ P a) ⟹ class.wellorder_axioms ?less›*) wf_induct_rule [OF wf] (*‹(⋀x. (⋀y. (y, x) ∈ {(x, y). x < y} ⟹ ?P y) ⟹ ?P x) ⟹ ?P ?a›*)) lemma (in wellorder) wf: "wf {(x, y). x < y}" unfolding wf_def (*goal: ‹∀P::'a ⇒ bool. (∀x::'a. (∀y::'a. (y, x) ∈ {(x::'a, y::'a). x < y} ⟶ P y) ⟶ P x) ⟶ All P›*) by (blast intro: less_induct (*‹(⋀x. (⋀y. y < x ⟹ ?P y) ⟹ ?P x) ⟹ ?P ?a›*)) lemma (in wellorder) wfP_less[simp]: "wfP (<)" by (simp add: wf (*‹wf {(x::'a, y::'a). x < y}›*) wfP_def (*‹wfp (?r::?'a ⇒ ?'a ⇒ bool) = wf {(x::?'a, y::?'a). ?r x y}›*)) lemma (in wellorder) wfp_on_less[simp]: "wfp_on A (<)" unfolding wfp_on_def (*goal: ‹∀P. (∀x∈A. (∀y∈A. y < x ⟶ P y) ⟶ P x) ⟶ Ball A P›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀P x. ⟦∀x∈A. (∀y∈A. y < x ⟶ P y) ⟶ P x; x ∈ A⟧ ⟹ P x›*) fix P and x assume hyps: "∀x∈A. (∀y∈A. y < x ⟶ P y) ⟶ P x" (*‹∀x::'a∈A::'a set. (∀y::'a∈A. y < x ⟶ (P::'a ⇒ bool) y) ⟶ P x›*) show "x ∈ A ⟹ P x" proof (induction x rule: less_induct (*‹(⋀x. (⋀y. y < x ⟹ ?P y) ⟹ ?P x) ⟹ ?P ?a›*)) (*goal: ‹⋀x. ⟦⋀y. ⟦y < x; y ∈ A⟧ ⟹ P y; x ∈ A⟧ ⟹ P x›*) case (less x) (*‹⟦?y < x; ?y ∈ A⟧ ⟹ P ?y› ‹x ∈ A›*) show "?case" (*goal: ‹P x›*) proof (rule hyps[rule_format] (*‹⟦?x ∈ A; ⋀y. ⟦y ∈ A; y < ?x⟧ ⟹ P y⟧ ⟹ P ?x›*)) (*goals: 1. ‹x ∈ A› 2. ‹⋀y. ⟦y ∈ A; y < x⟧ ⟹ P y›*) show "x ∈ A" using ‹x ∈ A› (*‹x ∈ A›*) . next (*goal: ‹⋀y. ⟦y ∈ A; y < x⟧ ⟹ P y›*) show "⋀y. y ∈ A ⟹ y < x ⟹ P y" using less.IH (*‹⟦?y < x; ?y ∈ A⟧ ⟹ P ?y›*) . qed qed qed subsection ‹Basic Results› text ‹Point-free characterization of well-foundedness› lemma wf_onE_pf: assumes wf: "wf_on A r" and "B ⊆ A" and "B ⊆ r `` B" shows "B = {}" proof (-) (*goal: ‹B = {}›*) have "x ∉ B" if "x ∈ A" for x using wf (*‹wf_on A r›*) proof (induction x rule: wf_on_induct (*‹⟦wf_on ?A ?r; ?x ∈ ?A; ⋀x. ⟦x ∈ ?A; ⋀y. ⟦y ∈ ?A; (y, x) ∈ ?r⟧ ⟹ ?P y⟧ ⟹ ?P x⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹x ∈ A› 2. ‹⋀x. ⟦x ∈ A; ⋀y. ⟦y ∈ A; (y, x) ∈ r⟧ ⟹ y ∉ B⟧ ⟹ x ∉ B›*) case in_set (*no hyothesis introduced yet*) show "?case" (*goal: ‹x ∈ A›*) using that (*‹(x::'a) ∈ (A::'a set)›*) . next (*goal: ‹⋀x. ⟦x ∈ A; ⋀y. ⟦y ∈ A; (y, x) ∈ r⟧ ⟹ y ∉ B⟧ ⟹ x ∉ B›*) case (less x) (*‹(x::'a) ∈ (A::'a set)› ‹⟦?y ∈ A; (?y, x) ∈ r⟧ ⟹ ?y ∉ B›*) have "x ∉ r `` B" using less.IH (*‹⟦?y ∈ A; (?y, x) ∈ r⟧ ⟹ ?y ∉ B›*) ‹B ⊆ A› (*‹B ⊆ A›*) by blast thus "?case" (*goal: ‹x ∉ B›*) using ‹B ⊆ r `` B› (*‹B ⊆ r `` B›*) by blast qed with ‹B ⊆ A› (*‹B ⊆ A›*) show "?thesis" (*goal: ‹B = {}›*) by blast qed lemma wfE_pf: "wf R ⟹ A ⊆ R `` A ⟹ A = {}" using wf_onE_pf[of UNIV, simplified] (*‹⟦wf ?r; ?B ⊆ ?r `` ?B⟧ ⟹ ?B = {}›*) . lemma wf_onI_pf: assumes "⋀B. B ⊆ A ⟹ B ⊆ R `` B ⟹ B = {}" shows "wf_on A R" unfolding wf_on_def (*goal: ‹∀P::'a ⇒ bool. (∀x::'a∈A::'a set. (∀y::'a∈A. (y, x) ∈ (R::('a × 'a) set) ⟶ P y) ⟶ P x) ⟶ Ball A P›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀P x. ⟦∀x∈A. (∀y∈A. (y, x) ∈ R ⟶ P y) ⟶ P x; x ∈ A⟧ ⟹ P x›*) fix P :: "'a ⇒ bool" and x :: 'a let ?B = "{x ∈ A. ¬ P x}" assume "∀x∈A. (∀y∈A. (y, x) ∈ R ⟶ P y) ⟶ P x" (*‹∀x::'a∈A::'a set. (∀y::'a∈A. (y, x) ∈ (R::('a × 'a) set) ⟶ (P::'a ⇒ bool) y) ⟶ P x›*) hence "?B ⊆ R `` ?B" by blast hence "{x ∈ A. ¬ P x} = {}" using assms(1)[of ?B] (*‹⟦{x ∈ A. ¬ P x} ⊆ A; {x ∈ A. ¬ P x} ⊆ R `` {x ∈ A. ¬ P x}⟧ ⟹ {x ∈ A. ¬ P x} = {}›*) by simp moreover assume "x ∈ A" (*‹(x::'a) ∈ (A::'a set)›*) ultimately show "P x" by simp qed lemma wfI_pf: "(⋀A. A ⊆ R `` A ⟹ A = {}) ⟹ wf R" using wf_onI_pf[of UNIV, simplified] (*‹(⋀B. B ⊆ ?R `` B ⟹ B = {}) ⟹ wf ?R›*) . subsubsection ‹Minimal-element characterization of well-foundedness› lemma wf_on_iff_ex_minimal: "wf_on A R ⟷ (∀B ⊆ A. B ≠ {} ⟶ (∃z ∈ B. ∀y. (y, z) ∈ R ⟶ y ∉ B))" proof (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀B::'a set. ⟦wf_on (A::'a set) (R::('a × 'a) set); B ⊆ A; B ≠ {}⟧ ⟹ ∃z::'a∈B. ∀y::'a. (y, z) ∈ R ⟶ y ∉ B› 2. ‹∀B⊆A::'a set. B ≠ {} ⟶ (∃z::'a∈B. ∀y::'a. (y, z) ∈ (R::('a × 'a) set) ⟶ y ∉ B) ⟹ wf_on A R›*) fix B assume "wf_on A R" and "B ⊆ A" and "B ≠ {}" (*‹wf_on (A::'a set) (R::('a × 'a) set)› ‹(B::'a set) ⊆ (A::'a set)› ‹(B::'a set) ≠ {}›*) show "∃z ∈ B. ∀y. (y, z) ∈ R ⟶ y ∉ B" using wf_onE_pf[OF ‹wf_on A R› ‹B ⊆ A›] (*‹B ⊆ R `` B ⟹ B = {}›*) ‹B ≠ {}› (*‹B ≠ {}›*) by blast next (*goal: ‹∀B⊆A::'a set. B ≠ {} ⟶ (∃z::'a∈B. ∀y::'a. (y, z) ∈ (R::('a × 'a) set) ⟶ y ∉ B) ⟹ wf_on A R›*) assume ex_min: "∀B⊆A. B ≠ {} ⟶ (∃z∈B. ∀y. (y, z) ∈ R ⟶ y ∉ B)" (*‹∀B⊆A::'a set. B ≠ {} ⟶ (∃z::'a∈B. ∀y::'a. (y, z) ∈ (R::('a × 'a) set) ⟶ y ∉ B)›*) show "wf_on A R " proof (rule wf_onI_pf (*‹(⋀B. ⟦B ⊆ ?A; B ⊆ ?R `` B⟧ ⟹ B = {}) ⟹ wf_on ?A ?R›*)) (*goal: ‹⋀B. ⟦B ⊆ A; B ⊆ R `` B⟧ ⟹ B = {}›*) fix B assume "B ⊆ A" and "B ⊆ R `` B" (*‹(B::'a set) ⊆ (A::'a set)› ‹(B::'a set) ⊆ (R::('a × 'a) set) `` B›*) have False if "B ≠ {}" using ex_min[rule_format, OF ‹B ⊆ A› ‹B ≠ {}›] (*‹∃z∈B. ∀y. (y, z) ∈ R ⟶ y ∉ B›*) using ‹B ⊆ R `` B› (*‹(B::'a set) ⊆ (R::('a × 'a) set) `` B›*) by blast thus "B = {}" by blast qed qed lemma wf_iff_ex_minimal: "wf R ⟷ (∀B. B ≠ {} ⟶ (∃z ∈ B. ∀y. (y, z) ∈ R ⟶ y ∉ B))" using wf_on_iff_ex_minimal[of UNIV, simplified] (*‹wf ?R = (∀B. B ≠ {} ⟶ (∃z∈B. ∀y. (y, z) ∈ ?R ⟶ y ∉ B))›*) . lemma wfp_on_iff_ex_minimal: "wfp_on A R ⟷ (∀B ⊆ A. B ≠ {} ⟶ (∃z ∈ B. ∀y. R y z ⟶ y ∉ B))" using wf_on_iff_ex_minimal[of A, to_pred] (*‹wfp_on A ?R = (∀B⊆A. B ≠ {x. ⊥ x} ⟶ (∃z∈B. ∀y. ?R y z ⟶ y ∉ B))›*) by simp lemma wfp_iff_ex_minimal: "wfp R ⟷ (∀B. B ≠ {} ⟶ (∃z ∈ B. ∀y. R y z ⟶ y ∉ B))" using wfp_on_iff_ex_minimal[of UNIV, simplified] (*‹wfp ?R = (∀B. B ≠ {} ⟶ (∃z∈B. ∀y. ?R y z ⟶ y ∉ B))›*) . lemma wfE_min: assumes wf: "wf R" and Q: "x ∈ Q" obtains z where "z ∈ Q" "⋀y. (y, z) ∈ R ⟹ y ∉ Q" using Q (*‹(x::'a::type) ∈ (Q::'a::type set)›*) wfE_pf[OF wf, of Q] (*‹Q ⊆ R `` Q ⟹ Q = {}›*) by blast lemma wfE_min': "wf R ⟹ Q ≠ {} ⟹ (⋀z. z ∈ Q ⟹ (⋀y. (y, z) ∈ R ⟹ y ∉ Q) ⟹ thesis) ⟹ thesis" using wfE_min[of R _ Q] (*‹⟦wf R; ?x ∈ Q; ⋀z. ⟦z ∈ Q; ⋀y. (y, z) ∈ R ⟹ y ∉ Q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast lemma wfI_min: assumes a: "⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ R ⟶ y ∉ Q" shows "wf R" proof (rule wfI_pf (*‹(⋀A. A ⊆ ?R `` A ⟹ A = {}) ⟹ wf ?R›*)) (*goal: ‹⋀A. A ⊆ R `` A ⟹ A = {}›*) fix A assume b: "A ⊆ R `` A" (*‹(A::'a set) ⊆ (R::('a × 'a) set) `` A›*) have False if "x ∈ A" for x using a[OF that] (*‹∃z::'a∈A::'a set. ∀y::'a. (y, z) ∈ (R::('a × 'a) set) ⟶ y ∉ A›*) b (*‹A ⊆ R `` A›*) by blast then show "A = {}" by blast qed lemma wf_eq_minimal: "wf r ⟷ (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ r ⟶ y ∉ Q))" unfolding wf_iff_ex_minimal (*goal: ‹(∀B. B ≠ {} ⟶ (∃z∈B. ∀y. (y, z) ∈ r ⟶ y ∉ B)) = (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ r ⟶ y ∉ Q))›*) by blast lemmas wfP_eq_minimal = wf_eq_minimal [to_pred] subsubsection ‹Antimonotonicity› lemma wf_on_antimono_strong: assumes "wf_on B r" and "A ⊆ B" and "(⋀x y. x ∈ A ⟹ y ∈ A ⟹ (x, y) ∈ q ⟹ (x, y) ∈ r)" shows "wf_on A q" unfolding wf_on_iff_ex_minimal (*goal: ‹∀B⊆A. B ≠ {} ⟶ (∃z∈B. ∀y. (y, z) ∈ q ⟶ y ∉ B)›*) proof (intro allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀B. ⟦B ⊆ A; B ≠ {}⟧ ⟹ ∃z∈B. ∀y. (y, z) ∈ q ⟶ y ∉ B›*) fix AA assume "AA ⊆ A" and "AA ≠ {}" (*‹(AA::'a set) ⊆ (A::'a set)› ‹(AA::'a set) ≠ {}›*) hence "∃z∈AA. ∀y. (y, z) ∈ r ⟶ y ∉ AA" using ‹wf_on B r› (*‹wf_on B r›*) ‹A ⊆ B› (*‹A ⊆ B›*) by (simp add: wf_on_iff_ex_minimal (*‹wf_on ?A ?R = (∀B⊆?A. B ≠ {} ⟶ (∃z∈B. ∀y. (y, z) ∈ ?R ⟶ y ∉ B))›*)) then show "∃z∈AA. ∀y. (y, z) ∈ q ⟶ y ∉ AA" using ‹AA ⊆ A› (*‹(AA::'a set) ⊆ (A::'a set)›*) assms(3) (*‹⟦?x ∈ A; ?y ∈ A; (?x, ?y) ∈ q⟧ ⟹ (?x, ?y) ∈ r›*) by blast qed lemma wfp_on_antimono_strong: "wfp_on B R ⟹ A ⊆ B ⟹ (⋀x y. x ∈ A ⟹ y ∈ A ⟹ Q x y ⟹ R x y) ⟹ wfp_on A Q" using wf_on_antimono_strong[of B _ A, to_pred] (*‹⟦wfp_on B ?r; A ⊆ B; ⋀x y. ⟦x ∈ A; y ∈ A; ?q x y⟧ ⟹ ?r x y⟧ ⟹ wfp_on A ?q›*) . lemma wf_on_antimono: "A ⊆ B ⟹ q ⊆ r ⟹ wf_on B r ≤ wf_on A q" using wf_on_antimono_strong[of B r A q] (*‹⟦wf_on (B::'a set) (r::('a × 'a) set); (A::'a set) ⊆ B; ⋀(x::'a) y::'a. ⟦x ∈ A; y ∈ A; (x, y) ∈ (q::('a × 'a) set)⟧ ⟹ (x, y) ∈ r⟧ ⟹ wf_on A q›*) by auto lemma wfp_on_antimono: "A ⊆ B ⟹ Q ≤ R ⟹ wfp_on B R ≤ wfp_on A Q" using wfp_on_antimono_strong[of B R A Q] (*‹⟦wfp_on B R; A ⊆ B; ⋀x y. ⟦x ∈ A; y ∈ A; Q x y⟧ ⟹ R x y⟧ ⟹ wfp_on A Q›*) by auto lemma wf_on_subset: "wf_on B r ⟹ A ⊆ B ⟹ wf_on A r" using wf_on_antimono_strong (*‹⟦wf_on ?B ?r; ?A ⊆ ?B; ⋀x y. ⟦x ∈ ?A; y ∈ ?A; (x, y) ∈ ?q⟧ ⟹ (x, y) ∈ ?r⟧ ⟹ wf_on ?A ?q›*) . lemma wfp_on_subset: "wfp_on B R ⟹ A ⊆ B ⟹ wfp_on A R" using wfp_on_antimono_strong (*‹⟦wfp_on (?B::?'a set) (?R::?'a ⇒ ?'a ⇒ bool); (?A::?'a set) ⊆ ?B; ⋀(x::?'a) y::?'a. ⟦x ∈ ?A; y ∈ ?A; (?Q::?'a ⇒ ?'a ⇒ bool) x y⟧ ⟹ ?R x y⟧ ⟹ wfp_on ?A ?Q›*) . subsubsection ‹Well-foundedness of transitive closure› lemma wf_trancl: assumes "wf r" shows "wf (r⁺)" proof (-) (*goal: ‹wf (r⁺)›*) have "P x" if induct_step: "⋀x. (⋀y. (y, x) ∈ r⁺ ⟹ P y) ⟹ P x" for P and x proof (rule induct_step (*‹(⋀y::'a. (y, ?x::'a) ∈ (r::('a × 'a) set)⁺ ⟹ (P::'a ⇒ bool) y) ⟹ P ?x›*)) (*goal: ‹⋀y. (y, x) ∈ r⁺ ⟹ P y›*) show "P y" if "(y, x) ∈ r⁺" for y using ‹wf r› (*‹wf r›*) that (*‹(y, x) ∈ r⁺›*) proof (induct x arbitrary: y) (*goal: ‹⋀(x::'a) y::'a. ⟦⋀(y::'a) ya::'a. ⟦(y, x) ∈ (r::('a × 'a) set); (ya, y) ∈ r⁺⟧ ⟹ (P::'a ⇒ bool) ya; (y, x) ∈ r⁺⟧ ⟹ P y›*) case (less x) (*‹⟦(?y::'a, x::'a) ∈ (r::('a × 'a) set); (?ya::'a, ?y) ∈ r⁺⟧ ⟹ (P::'a ⇒ bool) ?ya› ‹(y, x) ∈ r⁺›*) note hyp = ‹⋀x' y'. (x', x) ∈ r ⟹ (y', x') ∈ r⁺ ⟹ P y'› (*‹⟦(?x', x) ∈ r; (?y', ?x') ∈ r⁺⟧ ⟹ P ?y'›*) from ‹(y, x) ∈ r⁺› (*‹(y, x) ∈ r⁺›*) show "P y" proof (cases) (*goals: 1. ‹(y::'a::type, x::'a::type) ∈ (r::('a::type × 'a::type) set) ⟹ (P::'a::type ⇒ bool) y› 2. ‹⋀c::'a::type. ⟦(y::'a::type, c) ∈ (r::('a::type × 'a::type) set)⁺; (c, x::'a::type) ∈ r⟧ ⟹ (P::'a::type ⇒ bool) y›*) case base (*‹(y::'a::type, x::'a::type) ∈ (r::('a::type × 'a::type) set)›*) show "P y" proof (rule induct_step (*‹(⋀y. (y, ?x) ∈ r⁺ ⟹ P y) ⟹ P ?x›*)) (*goal: ‹⋀y. (y, y) ∈ r⁺ ⟹ P y›*) fix y' assume "(y', y) ∈ r⁺" (*‹(y'::'a, y::'a) ∈ (r::('a × 'a) set)⁺›*) with ‹(y, x) ∈ r› (*‹(y, x) ∈ r›*) show "P y'" by (rule hyp [of y y'] (*‹⟦(y, x) ∈ r; (y', y) ∈ r⁺⟧ ⟹ P y'›*)) qed next (*goal: ‹⋀c. ⟦(y, c) ∈ r⁺; (c, x) ∈ r⟧ ⟹ P y›*) case step (*‹(y::'a, c_::'a) ∈ (r::('a × 'a) set)⁺› ‹(c_, x) ∈ r›*) then obtain x' where "(x', x) ∈ r" and "(y, x') ∈ r⁺" (*goal: ‹(⋀x'. ⟦(x', x) ∈ r; (y, x') ∈ r⁺⟧ ⟹ thesis) ⟹ thesis›*) by simp then show "P y" by (rule hyp [of x' y] (*‹⟦(x', x) ∈ r; (y, x') ∈ r⁺⟧ ⟹ P y›*)) qed qed qed then show "?thesis" (*goal: ‹wf (r⁺)›*) unfolding wf_def (*goal: ‹∀P. (∀x. (∀y. (y, x) ∈ r⁺ ⟶ P y) ⟶ P x) ⟶ All P›*) by blast qed lemmas wfP_trancl = wf_trancl [to_pred] lemma wf_converse_trancl: "wf (r¯) ⟹ wf ((r⁺)¯)" apply (subst trancl_converse [symmetric] (*‹(?r⁺)¯ = (?r¯)⁺›*)) (*goal: ‹wf (r¯) ⟹ wf ((r⁺)¯)›*) by (erule wf_trancl (*‹wf (?r::(?'a::type × ?'a::type) set) ⟹ wf (?r⁺)›*)) text ‹Well-foundedness of subsets› lemma wf_subset: "wf r ⟹ p ⊆ r ⟹ wf p" apply (simp add: wf_eq_minimal (*‹wf ?r = (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ ?r ⟶ y ∉ Q))›*)) (*goal: ‹⟦wf r; p ⊆ r⟧ ⟹ wf p›*) by fast lemmas wfP_subset = wf_subset [to_pred] text ‹Well-foundedness of the empty relation› lemma wf_empty [iff]: "wf {}" by (simp add: wf_def (*‹wf (?r::(?'a × ?'a) set) = (∀P::?'a ⇒ bool. (∀x::?'a. (∀y::?'a. (y, x) ∈ ?r ⟶ P y) ⟶ P x) ⟶ (∀x::?'a. P x))›*)) lemma wfP_empty [iff]: "wfP (λx y. False)" proof (-) (*goal: ‹wfp (λx y. False)›*) have "wfP bot" by (fact wf_empty[to_pred bot_empty_eq2] (*‹wfp ⊥›*)) then show "?thesis" (*goal: ‹wfp (λx y. False)›*) by (simp add: bot_fun_def (*‹⊥ = (λx::?'a. ⊥)›*)) qed lemma wf_Int1: "wf r ⟹ wf (r ∩ r')" apply (erule wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) (*goal: ‹wf r ⟹ wf (r ∩ r')›*) by (rule Int_lower1 (*‹(?A::?'a::type set) ∩ (?B::?'a::type set) ⊆ ?A›*)) lemma wf_Int2: "wf r ⟹ wf (r' ∩ r)" apply (erule wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) (*goal: ‹wf r ⟹ wf (r' ∩ r)›*) by (rule Int_lower2 (*‹?A ∩ ?B ⊆ ?B›*)) text ‹Exponentiation.› lemma wf_exp: assumes "wf (R ^^ n)" shows "wf R" proof (rule wfI_pf (*‹(⋀A::?'a set. A ⊆ (?R::(?'a × ?'a) set) `` A ⟹ A = {}) ⟹ wf ?R›*)) (*goal: ‹⋀A. A ⊆ R `` A ⟹ A = {}›*) fix A assume "A ⊆ R `` A" (*‹(A::'a set) ⊆ (R::('a × 'a) set) `` A›*) then have "A ⊆ (R ^^ n) `` A" apply (induct n) (*goals: 1. ‹(A::'a set) ⊆ (R::('a × 'a) set) `` A ⟹ A ⊆ (R ^^ (0::nat)) `` A› 2. ‹⋀n::nat. ⟦(A::'a set) ⊆ (R::('a × 'a) set) `` A ⟹ A ⊆ (R ^^ n) `` A; A ⊆ R `` A⟧ ⟹ A ⊆ (R ^^ Suc n) `` A› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . with ‹wf (R ^^ n)› (*‹wf (R ^^ n)›*) show "A = {}" by (rule wfE_pf (*‹⟦wf ?R; ?A ⊆ ?R `` ?A⟧ ⟹ ?A = {}›*)) qed text ‹Well-foundedness of ‹insert›.› lemma wf_insert [iff]: "wf (insert (y,x) r) ⟷ wf r ∧ (x,y) ∉ r⇧*" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹wf (insert (y, x) r) ⟹ wf r ∧ (x, y) ∉ r⇧*› 2. ‹wf r ∧ (x, y) ∉ r⇧* ⟹ wf (insert (y, x) r)›*) assume "?lhs" (*‹wf (insert (y::'a, x::'a) (r::('a × 'a) set))›*) then show "?rhs" by (blast elim: wf_trancl [THEN wf_irrefl] (*‹⟦wf (?r1::(?'a × ?'a) set); (?a::?'a, ?a) ∉ ?r1⁺ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: rtrancl_into_trancl1 (*‹⟦(?a::?'a, ?b::?'a) ∈ (?r::(?'a × ?'a) set)⇧*; (?b, ?c::?'a) ∈ ?r⟧ ⟹ (?a, ?c) ∈ ?r⁺›*) wf_subset (*‹⟦wf (?r::(?'a × ?'a) set); (?p::(?'a × ?'a) set) ⊆ ?r⟧ ⟹ wf ?p›*) rtrancl_mono [THEN subsetD] (*‹⟦(?r1::(?'a1 × ?'a1) set) ⊆ (?s1::(?'a1 × ?'a1) set); (?c::?'a1 × ?'a1) ∈ ?r1⇧*⟧ ⟹ ?c ∈ ?s1⇧*›*)) next (*goal: ‹wf (r::('a × 'a) set) ∧ (x::'a, y::'a) ∉ r⇧* ⟹ wf (insert (y, x) r)›*) assume R: "?rhs" (*‹wf (r::('a × 'a) set) ∧ (x::'a, y::'a) ∉ r⇧*›*) then have R': "Q ≠ {} ⟹ (∃z∈Q. ∀y. (y, z) ∈ r ⟶ y ∉ Q)" for Q by (auto simp: wf_eq_minimal (*‹wf (?r::(?'a × ?'a) set) = (∀(Q::?'a set) x::?'a. x ∈ Q ⟶ (∃z::?'a∈Q. ∀y::?'a. (y, z) ∈ ?r ⟶ y ∉ Q))›*)) show "?lhs" unfolding wf_eq_minimal (*goal: ‹∀Q xa. xa ∈ Q ⟶ (∃z∈Q. ∀ya. (ya, z) ∈ insert (y, x) r ⟶ ya ∉ Q)›*) proof (clarify) (*goal: ‹⋀Q xa. xa ∈ Q ⟹ ∃z∈Q. ∀ya. (ya, z) ∈ insert (y, x) r ⟶ ya ∉ Q›*) fix Q :: "'a set" and q assume "q ∈ Q" (*‹(q::'a) ∈ (Q::'a set)›*) then obtain a where "a ∈ Q" and a: "⋀y. (y, a) ∈ r ⟹ y ∉ Q" (*goal: ‹(⋀a. ⟦a ∈ Q; ⋀y. (y, a) ∈ r ⟹ y ∉ Q⟧ ⟹ thesis) ⟹ thesis›*) using R (*‹wf r ∧ (x, y) ∉ r⇧*›*) by (auto simp: wf_eq_minimal (*‹wf ?r = (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ ?r ⟶ y ∉ Q))›*)) show "∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q" proof (cases "a=x") (*goals: 1. ‹a = x ⟹ ∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q› 2. ‹a ≠ x ⟹ ∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) case True (*‹(a::'a) = (x::'a)›*) show "?thesis" (*goal: ‹∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) proof (cases "y ∈ Q") (*goals: 1. ‹y ∈ Q ⟹ ∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q› 2. ‹y ∉ Q ⟹ ∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) case True (*‹y ∈ Q›*) then obtain z where "z ∈ Q" "(z, y) ∈ r⇧*" "⋀z'. (z', z) ∈ r ⟶ z' ∈ Q ⟶ (z', y) ∉ r⇧*" (*goal: ‹(⋀z::'a. ⟦z ∈ (Q::'a set); (z, y::'a) ∈ (r::('a × 'a) set)⇧*; ⋀z'::'a. (z', z) ∈ r ⟶ z' ∈ Q ⟶ (z', y) ∉ r⇧*⟧ ⟹ thesis::bool) ⟹ thesis›*) using R'[of "{z ∈ Q. (z,y) ∈ r⇧*}"] (*‹{z::'a::type ∈ Q::'a::type set. (z, y::'a::type) ∈ (r::('a::type × 'a::type) set)⇧*} ≠ {} ⟹ ∃z::'a::type∈{z::'a::type ∈ Q. (z, y) ∈ r⇧*}. ∀ya::'a::type. (ya, z) ∈ r ⟶ ya ∉ {z::'a::type ∈ Q. (z, y) ∈ r⇧*}›*) by auto then have "∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q" using R (*‹wf (r::('a × 'a) set) ∧ (x::'a, y::'a) ∉ r⇧*›*) by (blast intro: rtrancl_trans (*‹⟦(?x, ?y) ∈ ?r⇧*; (?y, ?z) ∈ ?r⇧*⟧ ⟹ (?x, ?z) ∈ ?r⇧*›*)) then show "?thesis" (*goal: ‹∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) apply (rule bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) (*goal: ‹∃z::'a∈Q::'a set. ∀y'::'a. (y', z) ∈ insert (y::'a, x::'a) (r::('a × 'a) set) ⟶ y' ∉ Q›*) by fact next (*goal: ‹y ∉ Q ⟹ ∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) case False (*‹(y::'a) ∉ (Q::'a set)›*) then show "?thesis" (*goal: ‹∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) using a (*‹(?y, a) ∈ r ⟹ ?y ∉ Q›*) ‹a ∈ Q› (*‹a ∈ Q›*) by blast qed next (*goal: ‹a ≠ x ⟹ ∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) case False (*‹a ≠ x›*) with a (*‹(?y, a) ∈ r ⟹ ?y ∉ Q›*) ‹a ∈ Q› (*‹a ∈ Q›*) show "?thesis" (*goal: ‹∃z∈Q. ∀y'. (y', z) ∈ insert (y, x) r ⟶ y' ∉ Q›*) by blast qed qed qed subsubsection ‹Well-foundedness of image› lemma wf_map_prod_image_Dom_Ran: fixes r:: "('a × 'a) set" and f:: "'a ⇒ 'b" assumes wf_r: "wf r" and inj: "⋀ a a'. a ∈ Domain r ⟹ a' ∈ Range r ⟹ f a = f a' ⟹ a = a'" shows "wf (map_prod f f ` r)" apply (unfold wf_eq_minimal (*‹wf (?r::(?'a::type × ?'a::type) set) = (∀(Q::?'a::type set) x::?'a::type. x ∈ Q ⟶ (∃z::?'a::type∈Q. ∀y::?'a::type. (y, z) ∈ ?r ⟶ y ∉ Q))›*)) (*goal: ‹wf (map_prod f f ` r)›*) proof (clarify) (*goal: ‹⋀Q x. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ Q›*) fix B :: "'b set" and b :: 'b assume "b ∈ B" (*‹(b::'b) ∈ (B::'b set)›*) define A where "A = f -` B ∩ Domain r" show "∃z∈B. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ B" proof (cases "A = {}") (*goals: 1. ‹A = {} ⟹ ∃z∈B. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ B› 2. ‹A ≠ {} ⟹ ∃z∈B. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ B›*) case False (*‹A ≠ {}›*) then obtain a0 where "a0 ∈ A" and "∀a. (a, a0) ∈ r ⟶ a ∉ A" (*goal: ‹(⋀a0. ⟦a0 ∈ A; ∀a. (a, a0) ∈ r ⟶ a ∉ A⟧ ⟹ thesis) ⟹ thesis›*) using wfE_min[OF wf_r] (*‹⟦?x ∈ ?Q; ⋀z. ⟦z ∈ ?Q; ⋀y. (y, z) ∈ r ⟹ y ∉ ?Q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by auto thus "?thesis" (*goal: ‹∃z∈B. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ B›*) using inj (*‹⟦?a ∈ Domain r; ?a' ∈ Range r; f ?a = f ?a'⟧ ⟹ ?a = ?a'›*) unfolding A_def (*goal: ‹∃z∈B. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ B›*) apply (intro bexI[of _ "f a0"] (*‹⟦?P (f a0); f a0 ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) (*goals: 1. ‹⟦(a0::'a) ∈ (f::'a ⇒ 'b) -` (B::'b set) ∩ Domain (r::('a × 'a) set); ∀a::'a. (a, a0) ∈ r ⟶ a ∉ f -` B ∩ Domain r; ⋀(a::'a) a'::'a. ⟦a ∈ Domain r; a' ∈ Range r; f a = f a'⟧ ⟹ a = a'⟧ ⟹ ∀y::'b. (y, f a0) ∈ map_prod f f ` r ⟶ y ∉ B› 2. ‹⟦(a0::'a) ∈ (f::'a ⇒ 'b) -` (B::'b set) ∩ Domain (r::('a × 'a) set); ∀a::'a. (a, a0) ∈ r ⟶ a ∉ f -` B ∩ Domain r; ⋀(a::'a) a'::'a. ⟦a ∈ Domain r; a' ∈ Range r; f a = f a'⟧ ⟹ a = a'⟧ ⟹ f a0 ∈ B› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (use ‹b ∈ B› in ‹unfold A_def, auto›) (*solved the remaining goal: ‹A = {} ⟹ ∃z∈B. ∀y. (y, z) ∈ map_prod f f ` r ⟶ y ∉ B›*) qed lemma wf_map_prod_image: "wf r ⟹ inj f ⟹ wf (map_prod f f ` r)" apply (rule wf_map_prod_image_Dom_Ran (*‹⟦wf ?r; ⋀a a'. ⟦a ∈ Domain ?r; a' ∈ Range ?r; ?f a = ?f a'⟧ ⟹ a = a'⟧ ⟹ wf (map_prod ?f ?f ` ?r)›*)) (*goals: 1. ‹⟦wf r; inj f⟧ ⟹ wf r› 2. ‹⋀a a'. ⟦wf r; inj f; a ∈ Domain r; a' ∈ Range r; f a = f a'⟧ ⟹ a = a'› discuss goal 1*) apply ((auto dest: inj_onD (*‹⟦inj_on ?f ?A; ?f ?x = ?f ?y; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x = ?y›*))[1]) (*discuss goal 2*) apply ((auto dest: inj_onD (*‹⟦inj_on ?f ?A; ?f ?x = ?f ?y; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x = ?y›*))[1]) (*proven 2 subgoals*) . lemma wfp_on_image: "wfp_on (f ` A) R ⟷ wfp_on A (λa b. R (f a) (f b))" proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹wfp_on (f ` A) R ⟹ wfp_on A (λa b. R (f a) (f b))› 2. ‹wfp_on A (λa b. R (f a) (f b)) ⟹ wfp_on (f ` A) R›*) assume hyp: "wfp_on (f ` A) R" (*‹wfp_on ((f::'b ⇒ 'a) ` (A::'b set)) (R::'a ⇒ 'a ⇒ bool)›*) show "wfp_on A (λa b. R (f a) (f b))" unfolding wfp_on_iff_ex_minimal (*goal: ‹∀B⊆A. B ≠ {} ⟶ (∃z∈B. ∀y. R (f y) (f z) ⟶ y ∉ B)›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀B. ⟦B ⊆ A; B ≠ {}⟧ ⟹ ∃z∈B. ∀y. R (f y) (f z) ⟶ y ∉ B›*) fix B assume "B ⊆ A" and "B ≠ {}" (*‹(B::'b set) ⊆ (A::'b set)› ‹(B::'b set) ≠ {}›*) hence "f ` B ⊆ f ` A" and "f ` B ≠ {}" unfolding atomize_conj image_is_empty (*goal: ‹f ` B ⊆ f ` A ∧ B ≠ {}›*) using image_mono (*‹(?A::?'a::type set) ⊆ (?B::?'a::type set) ⟹ (?f::?'a::type ⇒ ?'b::type) ` ?A ⊆ ?f ` ?B›*) by iprover hence "∃z∈f ` B. ∀y. R y z ⟶ y ∉ f ` B" using hyp[unfolded wfp_on_iff_ex_minimal, rule_format] (*‹⟦?B ⊆ f ` A; ?B ≠ {}⟧ ⟹ ∃z∈?B. ∀y. R y z ⟶ y ∉ ?B›*) by iprover then obtain fz where "fz ∈ f ` B" and fz_max: "∀y. R y fz ⟶ y ∉ f ` B" (*goal: ‹(⋀fz. ⟦fz ∈ f ` B; ∀y. R y fz ⟶ y ∉ f ` B⟧ ⟹ thesis) ⟹ thesis›*) by standard obtain z where "z ∈ B" and "fz = f z" (*goal: ‹(⋀z. ⟦z ∈ B; fz = f z⟧ ⟹ thesis) ⟹ thesis›*) using ‹fz ∈ f ` B› (*‹fz ∈ f ` B›*) unfolding image_iff (*goal: ‹(⋀z. ⟦z ∈ B; fz = f z⟧ ⟹ thesis) ⟹ thesis›*) by standard show "∃z∈B. ∀y. R (f y) (f z) ⟶ y ∉ B" proof (intro bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀y::'b. (R::'a ⇒ 'a ⇒ bool) ((f::'b ⇒ 'a) y) (f (?z::'b)) ⟹ y ∉ (B::'b set)› 2. ‹(?z::'b) ∈ (B::'b set)›*) show "z ∈ B" using ‹z ∈ B› (*‹z ∈ B›*) . next (*goal: ‹⋀y. R (f y) (f z) ⟹ y ∉ B›*) fix y assume "R (f y) (f z)" (*‹(R::'a ⇒ 'a ⇒ bool) ((f::'b ⇒ 'a) (y::'b)) (f (z::'b))›*) hence "f y ∉ f ` B" using fz_max (*‹∀y. R y fz ⟶ y ∉ f ` B›*) ‹fz = f z› (*‹fz = f z›*) by iprover thus "y ∉ B" apply (rule contrapos_nn (*‹⟦¬ ?Q; ?P ⟹ ?Q⟧ ⟹ ¬ ?P›*)) (*goal: ‹y ∉ B›*) by (rule imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) qed qed next (*goal: ‹wfp_on (A::'b set) (λ(a::'b) b::'b. (R::'a ⇒ 'a ⇒ bool) ((f::'b ⇒ 'a) a) (f b)) ⟹ wfp_on (f ` A) R›*) assume hyp: "wfp_on A (λa b. R (f a) (f b))" (*‹wfp_on (A::'b set) (λ(a::'b) b::'b. (R::'a ⇒ 'a ⇒ bool) ((f::'b ⇒ 'a) a) (f b))›*) show "wfp_on (f ` A) R" unfolding wfp_on_iff_ex_minimal (*goal: ‹∀B⊆f ` A. B ≠ {} ⟶ (∃z∈B. ∀y. R y z ⟶ y ∉ B)›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀B. ⟦B ⊆ f ` A; B ≠ {}⟧ ⟹ ∃z∈B. ∀y. R y z ⟶ y ∉ B›*) fix fA assume "fA ⊆ f ` A" and "fA ≠ {}" (*‹(fA::'a set) ⊆ (f::'b ⇒ 'a) ` (A::'b set)› ‹(fA::'a set) ≠ {}›*) then obtain A' where "A' ⊆ A" and "A' ≠ {}" and "fA = f ` A'" (*goal: ‹(⋀A'. ⟦A' ⊆ A; A' ≠ {}; fA = f ` A'⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp only: subset_image_iff (*‹(?B ⊆ ?f ` ?A) = (∃AA⊆?A. ?B = ?f ` AA)›*)) obtain z where "z ∈ A'" and z_max: "∀y. R (f y) (f z) ⟶ y ∉ A'" (*goal: ‹(⋀z. ⟦z ∈ A'; ∀y. R (f y) (f z) ⟶ y ∉ A'⟧ ⟹ thesis) ⟹ thesis›*) using hyp[unfolded wfp_on_iff_ex_minimal, rule_format, OF ‹A' ⊆ A› ‹A' ≠ {}›] (*‹∃z∈A'. ∀y. R (f y) (f z) ⟶ y ∉ A'›*) by blast show "∃z∈fA. ∀y. R y z ⟶ y ∉ fA" proof (intro bexI (*‹⟦(?P::?'a ⇒ bool) (?x::?'a); ?x ∈ (?A::?'a set)⟧ ⟹ ∃x::?'a∈?A. ?P x›*) allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*) impI (*‹(?P::bool ⟹ ?Q::bool) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀y. R y ?z ⟹ y ∉ fA› 2. ‹?z ∈ fA›*) show "f z ∈ fA" unfolding ‹fA = f ` A'› (*goal: ‹(f::'b ⇒ 'a) (z::'b) ∈ f ` (A'::'b set)›*) using imageI[OF ‹z ∈ A'›] (*‹?f z ∈ ?f ` A'›*) . next (*goal: ‹⋀y. R y (f z) ⟹ y ∉ fA›*) show "⋀y. R y (f z) ⟹ y ∉ fA" unfolding ‹fA = f ` A'› (*goal: ‹⋀y. R y (f z) ⟹ y ∉ f ` A'›*) using z_max (*‹∀y. R (f y) (f z) ⟶ y ∉ A'›*) by auto qed qed qed subsection ‹Well-Foundedness Results for Unions› lemma wf_union_compatible: assumes "wf R" "wf S" assumes "R O S ⊆ R" shows "wf (R ∪ S)" proof (rule wfI_min (*‹(⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ ?R ⟶ y ∉ Q) ⟹ wf ?R›*)) (*goal: ‹⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ R ∪ S ⟶ y ∉ Q›*) fix x :: 'a and Q let ?Q' = "{x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q}" assume "x ∈ Q" (*‹(x::'a) ∈ (Q::'a set)›*) obtain a where "a ∈ ?Q'" (*goal: ‹(⋀a. a ∈ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q} ⟹ thesis) ⟹ thesis›*) apply (rule wfE_min [OF ‹wf R› ‹x ∈ Q›] (*‹(⋀z. ⟦z ∈ Q; ⋀y. (y, z) ∈ R ⟹ y ∉ Q⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹(⋀a. a ∈ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q} ⟹ thesis) ⟹ thesis›*) by blast with ‹wf S› (*‹wf S›*) obtain z where "z ∈ ?Q'" and zmin: "⋀y. (y, z) ∈ S ⟹ y ∉ ?Q'" (*goal: ‹(⋀z. ⟦z ∈ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q}; ⋀y. (y, z) ∈ S ⟹ y ∉ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q}⟧ ⟹ thesis) ⟹ thesis›*) by (erule wfE_min (*‹⟦wf ?R; ?x ∈ ?Q; ⋀z. ⟦z ∈ ?Q; ⋀y. (y, z) ∈ ?R ⟹ y ∉ ?Q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) have "y ∉ Q" if "(y, z) ∈ S" for y proof (standard) (*goal: ‹(y::'a) ∈ (Q::'a set) ⟹ False›*) from that (*‹(y, z) ∈ S›*) have "y ∉ ?Q'" by (rule zmin (*‹(?y, z) ∈ S ⟹ ?y ∉ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q}›*)) assume "y ∈ Q" (*‹(y::'a) ∈ (Q::'a set)›*) with ‹y ∉ ?Q'› (*‹y ∉ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q}›*) obtain w where "(w, y) ∈ R" and "w ∈ Q" (*goal: ‹(⋀w. ⟦(w, y) ∈ R; w ∈ Q⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹(w, y) ∈ R› (*‹(w, y) ∈ R›*) ‹(y, z) ∈ S› (*‹(y, z) ∈ S›*) have "(w, z) ∈ R O S" by (rule relcompI (*‹⟦(?a::?'a::type, ?b::?'b::type) ∈ (?r::(?'a::type × ?'b::type) set); (?b, ?c::?'c::type) ∈ (?s::(?'b::type × ?'c::type) set)⟧ ⟹ (?a, ?c) ∈ ?r O ?s›*)) with ‹R O S ⊆ R› (*‹R O S ⊆ R›*) have "(w, z) ∈ R" by standard with ‹z ∈ ?Q'› (*‹z ∈ {x ∈ Q. ∀y. (y, x) ∈ R ⟶ y ∉ Q}›*) have "w ∉ Q" by blast with ‹w ∈ Q› (*‹(w::'a) ∈ (Q::'a set)›*) show False by contradiction qed with ‹z ∈ ?Q'› (*‹(z::'a::type) ∈ {x::'a::type ∈ Q::'a::type set. ∀y::'a::type. (y, x) ∈ (R::('a::type × 'a::type) set) ⟶ y ∉ Q}›*) show "∃z∈Q. ∀y. (y, z) ∈ R ∪ S ⟶ y ∉ Q" by blast qed text ‹Well-foundedness of indexed union with disjoint domains and ranges.› lemma wf_UN: assumes r: "⋀i. i ∈ I ⟹ wf (r i)" and disj: "⋀i j. ⟦i ∈ I; j ∈ I; r i ≠ r j⟧ ⟹ Domain (r i) ∩ Range (r j) = {}" shows "wf (⋃i∈I. r i)" unfolding wf_eq_minimal (*goal: ‹∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ ⋃ (r ` I) ⟶ y ∉ Q)›*) proof (clarify) (*goal: ‹⋀Q x. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ ⋃ (r ` I) ⟶ y ∉ Q›*) fix A and a :: 'b assume "a ∈ A" (*‹(a::'b) ∈ (A::'b set)›*) show "∃z∈A. ∀y. (y, z) ∈ ⋃(r ` I) ⟶ y ∉ A" proof (cases "∃i∈I. ∃a∈A. ∃b∈A. (b, a) ∈ r i") (*goals: 1. ‹∃i∈I. ∃a∈A. ∃b∈A. (b, a) ∈ r i ⟹ ∃z∈A. ∀y. (y, z) ∈ ⋃ (r ` I) ⟶ y ∉ A› 2. ‹¬ (∃i∈I. ∃a∈A. ∃b∈A. (b, a) ∈ r i) ⟹ ∃z∈A. ∀y. (y, z) ∈ ⋃ (r ` I) ⟶ y ∉ A›*) case True (*‹∃i∈I. ∃a∈A. ∃b∈A. (b, a) ∈ r i›*) then obtain i and b and c where ibc: "i ∈ I" "b ∈ A" "c ∈ A" "(c,b) ∈ r i" (*goal: ‹(⋀i b c. ⟦i ∈ I; b ∈ A; c ∈ A; (c, b) ∈ r i⟧ ⟹ thesis) ⟹ thesis›*) by blast have ri: "⋀Q. Q ≠ {} ⟹ ∃z∈Q. ∀y. (y, z) ∈ r i ⟶ y ∉ Q" using r[OF ‹i ∈ I›] (*‹wf (r i)›*) unfolding wf_eq_minimal (*goal: ‹⋀Q::'b::type set. Q ≠ {} ⟹ ∃z::'b::type∈Q. ∀y::'b::type. (y, z) ∈ (r::'a::type ⇒ ('b::type × 'b::type) set) (i::'a::type) ⟶ y ∉ Q›*) by auto show "?thesis" (*goal: ‹∃z::'b∈A::'b set. ∀y::'b. (y, z) ∈ ⋃ ((r::'a ⇒ ('b × 'b) set) ` (I::'a set)) ⟶ y ∉ A›*) using ri[of "{a. a ∈ A ∧ (∃b∈A. (b, a) ∈ r i) }"] (*‹{a ∈ A. ∃b∈A. (b, a) ∈ r i} ≠ {} ⟹ ∃z∈{a ∈ A. ∃b∈A. (b, a) ∈ r i}. ∀y. (y, z) ∈ r i ⟶ y ∉ {a ∈ A. ∃b∈A. (b, a) ∈ r i}›*) ibc (*‹i ∈ I› ‹b ∈ A› ‹c ∈ A› ‹(c::'b, b::'b) ∈ (r::'a ⇒ ('b × 'b) set) (i::'a)›*) disj (*‹⟦?i ∈ I; ?j ∈ I; r ?i ≠ r ?j⟧ ⟹ Domain (r ?i) ∩ Range (r ?j) = {}›*) by blast next (*goal: ‹¬ (∃i∈I. ∃a∈A. ∃b∈A. (b, a) ∈ r i) ⟹ ∃z∈A. ∀y. (y, z) ∈ ⋃ (r ` I) ⟶ y ∉ A›*) case False (*‹¬ (∃i∈I. ∃a∈A. ∃b∈A. (b, a) ∈ r i)›*) with ‹a ∈ A› (*‹a ∈ A›*) show "?thesis" (*goal: ‹∃z::'b∈A::'b set. ∀y::'b. (y, z) ∈ ⋃ ((r::'a ⇒ ('b × 'b) set) ` (I::'a set)) ⟶ y ∉ A›*) by blast qed qed lemma wfP_SUP: "∀i. wfP (r i) ⟹ ∀i j. r i ≠ r j ⟶ inf (Domainp (r i)) (Rangep (r j)) = bot ⟹ wfP (⨆(range r))" apply (rule wf_UN[to_pred] (*‹⟦⋀i. i ∈ ?I ⟹ wfp (?r i); ⋀i j. ⟦i ∈ ?I; j ∈ ?I; ?r i ≠ ?r j⟧ ⟹ Domainp (?r i) ⊓ Rangep (?r j) = ⊥⟧ ⟹ wfp (⨆ (?r ` ?I))›*)) (*goals: 1. ‹⋀i. ⟦∀i. wfp (r i); ∀i j. r i ≠ r j ⟶ Domainp (r i) ⊓ Rangep (r j) = ⊥; i ∈ UNIV⟧ ⟹ wfp (r i)› 2. ‹⋀i j. ⟦∀i. wfp (r i); ∀i j. r i ≠ r j ⟶ Domainp (r i) ⊓ Rangep (r j) = ⊥; i ∈ UNIV; j ∈ UNIV; r i ≠ r j⟧ ⟹ Domainp (r i) ⊓ Rangep (r j) = ⊥› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma wf_Union: assumes "∀r∈R. wf r" and "∀r∈R. ∀s∈R. r ≠ s ⟶ Domain r ∩ Range s = {}" shows "wf (⋃R)" using assms (*‹∀r∈R. wf r› ‹∀r::('a × 'a) set∈R::('a × 'a) set set. ∀s::('a × 'a) set∈R. r ≠ s ⟶ Domain r ∩ Range s = {}›*) wf_UN[of R "λi. i"] (*‹⟦⋀i. i ∈ R ⟹ wf i; ⋀i j. ⟦i ∈ R; j ∈ R; i ≠ j⟧ ⟹ Domain i ∩ Range j = {}⟧ ⟹ wf (⋃i∈R. i)›*) by simp text ‹ Intuition: We find an ‹R ∪ S›-min element of a nonempty subset ‹A› by case distinction. ▸ There is a step ‹a ─R→ b› with ‹a, b ∈ A›. Pick an ‹R›-min element ‹z› of the (nonempty) set ‹{a∈A | ∃b∈A. a ─R→ b}›. By definition, there is ‹z' ∈ A› s.t. ‹z ─R→ z'›. Because ‹z› is ‹R›-min in the subset, ‹z'› must be ‹R›-min in ‹A›. Because ‹z'› has an ‹R›-predecessor, it cannot have an ‹S›-successor and is thus ‹S›-min in ‹A› as well. ▸ There is no such step. Pick an ‹S›-min element of ‹A›. In this case it must be an ‹R›-min element of ‹A› as well. › lemma wf_Un: "wf r ⟹ wf s ⟹ Domain r ∩ Range s = {} ⟹ wf (r ∪ s)" using wf_union_compatible[of s r] (*‹⟦wf s; wf r; s O r ⊆ s⟧ ⟹ wf (s ∪ r)›*) by (auto simp: Un_ac (*‹?A ∪ ?B ∪ ?C = ?A ∪ (?B ∪ ?C)› ‹?A ∪ (?A ∪ ?B) = ?A ∪ ?B› ‹?A ∪ ?B = ?B ∪ ?A› ‹?A ∪ (?B ∪ ?C) = ?B ∪ (?A ∪ ?C)›*)) lemma wf_union_merge: "wf (R ∪ S) = wf (R O R ∪ S O R ∪ S)" (is "wf ?A = wf ?B") proof (standard) (*goals: 1. ‹wf ((R::('a × 'a) set) ∪ (S::('a × 'a) set)) ⟹ wf (R O R ∪ S O R ∪ S)› 2. ‹wf ((R::('a × 'a) set) O R ∪ (S::('a × 'a) set) O R ∪ S) ⟹ wf (R ∪ S)›*) assume "wf ?A" (*‹wf ((R::('a × 'a) set) ∪ (S::('a × 'a) set))›*) with wf_trancl (*‹wf ?r ⟹ wf (?r⁺)›*) have wfT: "wf (?A⁺)" . moreover have "?B ⊆ ?A⁺" apply (subst trancl_unfold (*‹?r⁺ = ?r ∪ ?r⁺ O ?r›*)) (*goal: ‹R O R ∪ S O R ∪ S ⊆ (R ∪ S)⁺›*) apply (subst trancl_unfold (*‹?r⁺ = ?r ∪ ?r⁺ O ?r›*)) (*goal: ‹(R::('a × 'a) set) O R ∪ (S::('a × 'a) set) O R ∪ S ⊆ R ∪ S ∪ (R ∪ S)⁺ O (R ∪ S)›*) by blast ultimately show "wf ?B" by (rule wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) next (*goal: ‹wf (R O R ∪ S O R ∪ S) ⟹ wf (R ∪ S)›*) assume "wf ?B" (*‹wf ((R::('a × 'a) set) O R ∪ (S::('a × 'a) set) O R ∪ S)›*) show "wf ?A" proof (rule wfI_min (*‹(⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ ?R ⟶ y ∉ Q) ⟹ wf ?R›*)) (*goal: ‹⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ R ∪ S ⟶ y ∉ Q›*) fix Q :: "'a set" and x assume "x ∈ Q" (*‹(x::'a) ∈ (Q::'a set)›*) with ‹wf ?B› (*‹wf (R O R ∪ S O R ∪ S)›*) obtain z where "z ∈ Q" and "⋀y. (y, z) ∈ ?B ⟹ y ∉ Q" (*goal: ‹(⋀z. ⟦z ∈ Q; ⋀y. (y, z) ∈ R O R ∪ S O R ∪ S ⟹ y ∉ Q⟧ ⟹ thesis) ⟹ thesis›*) by (erule wfE_min (*‹⟦wf ?R; ?x ∈ ?Q; ⋀z. ⟦z ∈ ?Q; ⋀y. (y, z) ∈ ?R ⟹ y ∉ ?Q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then have 1: "⋀y. (y, z) ∈ R O R ⟹ y ∉ Q" and 2: "⋀y. (y, z) ∈ S O R ⟹ y ∉ Q" and 3: "⋀y. (y, z) ∈ S ⟹ y ∉ Q" apply - (*goals: 1. ‹⋀y. ⟦(y, z) ∈ R O R; z ∈ Q; ⋀y. (y, z) ∈ R O R ∪ S O R ∪ S ⟹ y ∉ Q⟧ ⟹ y ∉ Q› 2. ‹⋀y. ⟦(y, z) ∈ S O R; z ∈ Q; ⋀y. (y, z) ∈ R O R ∪ S O R ∪ S ⟹ y ∉ Q⟧ ⟹ y ∉ Q› 3. ‹⋀y. ⟦(y, z) ∈ S; z ∈ Q; ⋀y. (y, z) ∈ R O R ∪ S O R ∪ S ⟹ y ∉ Q⟧ ⟹ y ∉ Q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "∃z∈Q. ∀y. (y, z) ∈ ?A ⟶ y ∉ Q" proof (cases "∀y. (y, z) ∈ R ⟶ y ∉ Q") (*goals: 1. ‹∀y::'a. (y, z::'a) ∈ (R::('a × 'a) set) ⟶ y ∉ (Q::'a set) ⟹ ∃z::'a∈Q. ∀y::'a. (y, z) ∈ R ∪ (S::('a × 'a) set) ⟶ y ∉ Q› 2. ‹¬ (∀y::'a. (y, z::'a) ∈ (R::('a × 'a) set) ⟶ y ∉ (Q::'a set)) ⟹ ∃z::'a∈Q. ∀y::'a. (y, z) ∈ R ∪ (S::('a × 'a) set) ⟶ y ∉ Q›*) case True (*‹∀y. (y, z) ∈ R ⟶ y ∉ Q›*) with ‹z ∈ Q› (*‹z ∈ Q›*) "3" (*‹(?y, z) ∈ S ⟹ ?y ∉ Q›*) show "?thesis" (*goal: ‹∃z∈Q. ∀y. (y, z) ∈ R ∪ S ⟶ y ∉ Q›*) by blast next (*goal: ‹¬ (∀y. (y, z) ∈ R ⟶ y ∉ Q) ⟹ ∃z∈Q. ∀y. (y, z) ∈ R ∪ S ⟶ y ∉ Q›*) case False (*‹¬ (∀y. (y, z) ∈ R ⟶ y ∉ Q)›*) then obtain z' where "z'∈Q" "(z', z) ∈ R" (*goal: ‹(⋀z'. ⟦z' ∈ Q; (z', z) ∈ R⟧ ⟹ thesis) ⟹ thesis›*) by blast have "∀y. (y, z') ∈ ?A ⟶ y ∉ Q" proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀y. (y, z') ∈ R ∪ S ⟹ y ∉ Q›*) fix y assume "(y, z') ∈ ?A" (*‹(y::'a, z'::'a) ∈ (R::('a × 'a) set) ∪ (S::('a × 'a) set)›*) then show "y ∉ Q" proof (standard) (*goals: 1. ‹(y, z') ∈ R ⟹ y ∉ Q› 2. ‹(y, z') ∈ S ⟹ y ∉ Q›*) assume "(y, z') ∈ R" (*‹(y::'a, z'::'a) ∈ (R::('a × 'a) set)›*) then have "(y, z) ∈ R O R" using ‹(z', z) ∈ R› (*‹(z', z) ∈ R›*) by standard with "1" (*‹(?y, z) ∈ R O R ⟹ ?y ∉ Q›*) show "y ∉ Q" . next (*goal: ‹(y, z') ∈ S ⟹ y ∉ Q›*) assume "(y, z') ∈ S" (*‹(y::'a, z'::'a) ∈ (S::('a × 'a) set)›*) then have "(y, z) ∈ S O R" using ‹(z', z) ∈ R› (*‹(z', z) ∈ R›*) by standard with "2" (*‹(?y, z) ∈ S O R ⟹ ?y ∉ Q›*) show "y ∉ Q" . qed qed with ‹z' ∈ Q› (*‹z' ∈ Q›*) show "?thesis" (*goal: ‹∃z∈Q. ∀y. (y, z) ∈ R ∪ S ⟶ y ∉ Q›*) by standard qed qed qed lemma wf_comp_self: "wf R ⟷ wf (R O R)" ― ‹special case› by (rule wf_union_merge [where S = "{}", simplified] (*‹wf (?R::(?'b1 × ?'b1) set) = wf (?R O ?R)›*)) subsection ‹Well-Foundedness of Composition› text ‹Bachmair and Dershowitz 1986, Lemma 2. [Provided by Tjark Weber]› lemma qc_wf_relto_iff: assumes "R O S ⊆ (R ∪ S)⇧* O R" ― ‹R quasi-commutes over S› shows "wf (S⇧* O R O S⇧*) ⟷ wf R" (is "wf ?S ⟷ _") proof (standard) (*goals: 1. ‹wf (S⇧* O R O S⇧*) ⟹ wf R› 2. ‹wf R ⟹ wf (S⇧* O R O S⇧*)›*) show "wf R" if "wf ?S" proof (-) (*goal: ‹wf R›*) have "R ⊆ ?S" by auto with wf_subset[of ?S] (*‹⟦wf (S⇧* O R O S⇧*); ?p ⊆ S⇧* O R O S⇧*⟧ ⟹ wf ?p›*) that (*‹wf (S⇧* O R O S⇧*)›*) show "wf R" by auto qed next (*goal: ‹wf R ⟹ wf (S⇧* O R O S⇧*)›*) show "wf ?S" if "wf R" proof (rule wfI_pf (*‹(⋀A. A ⊆ ?R `` A ⟹ A = {}) ⟹ wf ?R›*)) (*goal: ‹⋀A::'a::type set. A ⊆ ((S::('a::type × 'a::type) set)⇧* O (R::('a::type × 'a::type) set) O S⇧*) `` A ⟹ A = {}›*) fix A assume A: "A ⊆ ?S `` A" (*‹(A::'a set) ⊆ ((S::('a × 'a) set)⇧* O (R::('a × 'a) set) O S⇧*) `` A›*) let ?X = "(R ∪ S)⇧* `` A" have "*": "R O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O R" proof (-) (*goal: ‹R O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O R›*) have "(x, z) ∈ (R ∪ S)⇧* O R" if "(y, z) ∈ (R ∪ S)⇧*" and "(x, y) ∈ R" for x and y and z using that (*‹(y, z) ∈ (R ∪ S)⇧*› ‹(x, y) ∈ R›*) proof (induct y z) (*goals: 1. ‹⋀a. (x, a) ∈ R ⟹ (x, a) ∈ (R ∪ S)⇧* O R› 2. ‹⋀a b c. ⟦(a, b) ∈ (R ∪ S)⇧*; (x, a) ∈ R ⟹ (x, b) ∈ (R ∪ S)⇧* O R; (b, c) ∈ R ∪ S; (x, a) ∈ R⟧ ⟹ (x, c) ∈ (R ∪ S)⇧* O R›*) case rtrancl_refl (*‹(x, a_) ∈ R›*) then show "?case" (*goal: ‹(x, a_) ∈ (R ∪ S)⇧* O R›*) by auto next (*goal: ‹⋀a b c. ⟦(a, b) ∈ (R ∪ S)⇧*; (x, a) ∈ R ⟹ (x, b) ∈ (R ∪ S)⇧* O R; (b, c) ∈ R ∪ S; (x, a) ∈ R⟧ ⟹ (x, c) ∈ (R ∪ S)⇧* O R›*) case (rtrancl_into_rtrancl a b c) (*‹(a, b) ∈ (R ∪ S)⇧*› ‹(x, a) ∈ R ⟹ (x, b) ∈ (R ∪ S)⇧* O R› ‹(b, c) ∈ R ∪ S› ‹(x::'a, a::'a) ∈ (R::('a × 'a) set)›*) then have "(x, c) ∈ ((R ∪ S)⇧* O (R ∪ S)⇧*) O R" using assms (*‹(R::('a × 'a) set) O (S::('a × 'a) set) ⊆ (R ∪ S)⇧* O R›*) by blast then show "?case" (*goal: ‹(x, c) ∈ (R ∪ S)⇧* O R›*) by simp qed then show "?thesis" (*goal: ‹(R::('a × 'a) set) O (R ∪ (S::('a × 'a) set))⇧* ⊆ (R ∪ S)⇧* O R›*) by auto qed then have "R O S⇧* ⊆ (R ∪ S)⇧* O R" using rtrancl_Un_subset (*‹(?R::(?'a × ?'a) set)⇧* ∪ (?S::(?'a × ?'a) set)⇧* ⊆ (?R ∪ ?S)⇧*›*) by blast then have "?S ⊆ (R ∪ S)⇧* O (R ∪ S)⇧* O R" by (simp add: relcomp_mono (*‹⟦(?r'::(?'a × ?'b) set) ⊆ (?r::(?'a × ?'b) set); (?s'::(?'b × ?'c) set) ⊆ (?s::(?'b × ?'c) set)⟧ ⟹ ?r' O ?s' ⊆ ?r O ?s›*) rtrancl_mono (*‹(?r::(?'a × ?'a) set) ⊆ (?s::(?'a × ?'a) set) ⟹ ?r⇧* ⊆ ?s⇧*›*)) also (*calculation: ‹(S::('a::type × 'a::type) set)⇧* O (R::('a::type × 'a::type) set) O S⇧* ⊆ (R ∪ S)⇧* O (R ∪ S)⇧* O R›*) have "… = (R ∪ S)⇧* O R" by (simp add: O_assoc[symmetric] (*‹?R O ?S O ?T = (?R O ?S) O ?T›*)) finally (*calculation: ‹S⇧* O R O S⇧* ⊆ (R ∪ S)⇧* O R›*) have "?S O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O R O (R ∪ S)⇧*" by (simp add: O_assoc[symmetric] (*‹(?R::(?'a × ?'d) set) O (?S::(?'d × ?'c) set) O (?T::(?'c × ?'b) set) = (?R O ?S) O ?T›*) relcomp_mono (*‹⟦(?r'::(?'a × ?'b) set) ⊆ (?r::(?'a × ?'b) set); (?s'::(?'b × ?'c) set) ⊆ (?s::(?'b × ?'c) set)⟧ ⟹ ?r' O ?s' ⊆ ?r O ?s›*)) also (*calculation: ‹((S::('a × 'a) set)⇧* O (R::('a × 'a) set) O S⇧*) O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O R O (R ∪ S)⇧*›*) have "… ⊆ (R ∪ S)⇧* O (R ∪ S)⇧* O R" using "*" (*‹R O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O R›*) by (simp add: relcomp_mono (*‹⟦?r' ⊆ ?r; ?s' ⊆ ?s⟧ ⟹ ?r' O ?s' ⊆ ?r O ?s›*)) finally (*calculation: ‹(S⇧* O R O S⇧*) O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O (R ∪ S)⇧* O R›*) have "?S O (R ∪ S)⇧* ⊆ (R ∪ S)⇧* O R" by (simp add: O_assoc[symmetric] (*‹?R O ?S O ?T = (?R O ?S) O ?T›*)) then have "(?S O (R ∪ S)⇧*) `` A ⊆ ((R ∪ S)⇧* O R) `` A" by (simp add: Image_mono (*‹⟦?r' ⊆ ?r; ?A' ⊆ ?A⟧ ⟹ ?r' `` ?A' ⊆ ?r `` ?A›*)) moreover have "?X ⊆ (?S O (R ∪ S)⇧*) `` A" using A (*‹A ⊆ (S⇧* O R O S⇧*) `` A›*) by (auto simp: relcomp_Image (*‹(?X O ?Y) `` ?Z = ?Y `` ?X `` ?Z›*)) ultimately have "?X ⊆ R `` ?X" by (auto simp: relcomp_Image (*‹(?X O ?Y) `` ?Z = ?Y `` ?X `` ?Z›*)) then have "?X = {}" using ‹wf R› (*‹wf R›*) by (simp add: wfE_pf (*‹⟦wf ?R; ?A ⊆ ?R `` ?A⟧ ⟹ ?A = {}›*)) moreover have "A ⊆ ?X" by auto ultimately show "A = {}" by simp qed qed corollary wf_relcomp_compatible: assumes "wf R" and "R O S ⊆ S O R" shows "wf (S O R)" proof (-) (*goal: ‹wf (S O R)›*) have "R O S ⊆ (R ∪ S)⇧* O R" using assms (*‹wf R› ‹(R::('a × 'a) set) O (S::('a × 'a) set) ⊆ S O R›*) by blast then have "wf (S⇧* O R O S⇧*)" by (simp add: assms (*‹wf R› ‹R O S ⊆ S O R›*) qc_wf_relto_iff (*‹?R O ?S ⊆ (?R ∪ ?S)⇧* O ?R ⟹ wf (?S⇧* O ?R O ?S⇧*) = wf ?R › * )) then show "?thesis" (*goal: ‹wf (S O R)›*) apply (rule Wellfounded.wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) (*goal: ‹wf ((S::('a × 'a) set) O (R::('a × 'a) set))›*) by blast qed subsection ‹Acyclic relations› lemma wf_acyclic: "wf r ⟹ acyclic r" apply (simp add: acyclic_def (*‹acyclic ?r = (∀x. (x, x) ∉ ?r⁺)›*)) (*goal: ‹wf r ⟹ acyclic r›*) by (blast elim: wf_trancl [THEN wf_irrefl] (*‹⟦wf ?r1; (?a, ?a) ∉ ?r1⁺ ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemmas wfP_acyclicP = wf_acyclic [to_pred] subsubsection ‹Wellfoundedness of finite acyclic relations› lemma finite_acyclic_wf: assumes "finite r" "acyclic r" shows "wf r" using assms (*‹finite r› ‹acyclic r›*) proof (induction r rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹acyclic {} ⟹ wf {}› 2. ‹⋀x F. ⟦finite F; x ∉ F; acyclic F ⟹ wf F; acyclic (insert x F)⟧ ⟹ wf (insert x F)›*) case (insert x r) (*‹finite r› ‹(x::'a × 'a) ∉ (r::('a × 'a) set)› ‹acyclic r ⟹ wf r› ‹acyclic (insert (x::'a × 'a) (r::('a × 'a) set))›*) then show "?case" (*goal: ‹wf (insert x r)›*) apply (cases x) (*goal: ‹wf (insert x r)›*) by simp qed (simp) (*solved the remaining goal: ‹acyclic {} ⟹ wf {}›*) lemma finite_acyclic_wf_converse: "finite r ⟹ acyclic r ⟹ wf (r¯)" apply (erule finite_converse [THEN iffD2, THEN finite_acyclic_wf] (*‹⟦finite ?r2; acyclic (?r2¯)⟧ ⟹ wf (?r2¯)›*)) (*goal: ‹⟦finite r; acyclic r⟧ ⟹ wf (r¯)›*) by (erule acyclic_converse [THEN iffD2] (*‹acyclic ?r1 ⟹ acyclic (?r1¯)›*)) text ‹ Observe that the converse of an irreflexive, transitive, and finite relation is again well-founded. Thus, we may employ it for well-founded induction. › lemma wf_converse: assumes "irrefl r" and "trans r" and "finite r" shows "wf (r¯)" proof (-) (*goal: ‹wf (r¯)›*) have "acyclic r" using ‹irrefl r› (*‹irrefl r›*) ‹trans r› (*‹trans r›*) by (simp add: irrefl_def (*‹irrefl ?r = (∀a. (a, a) ∉ ?r)›*) acyclic_irrefl (*‹acyclic ?r = irrefl (?r⁺)›*)) with ‹finite r› (*‹finite r›*) show "?thesis" (*goal: ‹wf (r¯)›*) by (rule finite_acyclic_wf_converse (*‹⟦finite ?r; acyclic ?r⟧ ⟹ wf (?r¯)›*)) qed lemma wf_iff_acyclic_if_finite: "finite r ⟹ wf r = acyclic r" by (blast intro: finite_acyclic_wf (*‹⟦finite ?r; acyclic ?r⟧ ⟹ wf ?r›*) wf_acyclic (*‹wf ?r ⟹ acyclic ?r›*)) subsection ‹\<^typ>‹nat› is well-founded› lemma less_nat_rel: "(<) = (λm n. n = Suc m)⁺⁺" proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*), rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*), rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹⋀x xa. x < xa ⟹ (λm n. n = Suc m)⁺⁺ x xa› 2. ‹⋀x xa. (λm n. n = Suc m)⁺⁺ x xa ⟹ x < xa›*) fix n :: nat and m :: nat show "(λm n. n = Suc m)⁺⁺ m n" if "m < n" using that (*‹(m::nat) < (n::nat)›*) proof (induct n) (*goals: 1. ‹m < 0 ⟹ (λm n. n = Suc m)⁺⁺ m 0› 2. ‹⋀n. ⟦m < n ⟹ (λm n. n = Suc m)⁺⁺ m n; m < Suc n⟧ ⟹ (λm n. n = Suc m)⁺⁺ m (Suc n)›*) case 0 (*‹(m::nat) < (0::nat)›*) then show "?case" (*goal: ‹(λm n. n = Suc m)⁺⁺ m 0›*) by auto next (*goal: ‹⋀n. ⟦m < n ⟹ (λm n. n = Suc m)⁺⁺ m n; m < Suc n⟧ ⟹ (λm n. n = Suc m)⁺⁺ m (Suc n)›*) case (Suc n) (*‹(m::nat) < (n::nat) ⟹ (λ(m::nat) n::nat. n = Suc m)⁺⁺ m n› ‹(m::nat) < Suc (n::nat)›*) then show "?case" (*goal: ‹(λm n. n = Suc m)⁺⁺ m (Suc n)›*) by (auto simp add: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) le_less (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*)) qed show "m < n" if "(λm n. n = Suc m)⁺⁺ m n" using that (*‹(λm n. n = Suc m)⁺⁺ m n›*) apply (induct n) (*goals: 1. ‹⋀y. y = Suc m ⟹ m < y› 2. ‹⋀y z. ⟦(λm n. n = Suc m)⁺⁺ m y; z = Suc y; m < y⟧ ⟹ m < z› discuss goal 1*) apply (simp add: less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) reflexive (*‹?x ≡ ?x›*) le_less (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*)) (*discuss goal 2*) apply (simp add: less_Suc_eq_le (*‹((?m::nat) < Suc (?n::nat)) = (?m ≤ ?n)›*) reflexive (*‹?x::?'a::{} ≡ ?x›*) le_less (*‹((?x::?'a::order) ≤ (?y::?'a::order)) = (?x < ?y ∨ ?x = ?y)›*)) (*proven 2 subgoals*) . qed definition pred_nat :: "(nat × nat) set" where "pred_nat = {(m, n). n = Suc m}" definition less_than :: "(nat × nat) set" where "less_than = pred_nat⁺" lemma less_eq: "(m, n) ∈ pred_nat⁺ ⟷ m < n" unfolding less_nat_rel pred_nat_def trancl_def (*goal: ‹((m, n) ∈ {(x, y). (λx xa. (x, xa) ∈ {(m, n). n = Suc m})⁺⁺ x y}) = (λm n. n = Suc m)⁺⁺ m n›*) by simp lemma pred_nat_trancl_eq_le: "(m, n) ∈ pred_nat⇧* ⟷ m ≤ n" unfolding less_eq rtrancl_eq_or_trancl (*goal: ‹(m = n ∨ m ≠ n ∧ m < n) = (m ≤ n)›*) by auto lemma wf_pred_nat: "wf pred_nat" unfolding wf_def (*goal: ‹∀P. (∀x. (∀y. (y, x) ∈ pred_nat ⟶ P y) ⟶ P x) ⟶ All P›*) proof (clarify) (*goal: ‹⋀P x. ∀x. (∀y. (y, x) ∈ pred_nat ⟶ P y) ⟶ P x ⟹ P x›*) fix P and x assume "∀x'. (∀y. (y, x') ∈ pred_nat ⟶ P y) ⟶ P x'" (*‹∀x'::nat. (∀y::nat. (y, x') ∈ pred_nat ⟶ (P::nat ⇒ bool) y) ⟶ P x'›*) then show "P x" unfolding pred_nat_def (*goal: ‹P x›*) apply (induction x) (*goals: 1. ‹∀x'. (∀y. (y, x') ∈ {(m, n). n = Suc m} ⟶ P y) ⟶ P x' ⟹ P 0› 2. ‹⋀x. ⟦∀x'. (∀y. (y, x') ∈ {(m, n). n = Suc m} ⟶ P y) ⟶ P x' ⟹ P x; ∀x'. (∀y. (y, x') ∈ {(m, n). n = Suc m} ⟶ P y) ⟶ P x'⟧ ⟹ P (Suc x)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . qed lemma wf_less_than [iff]: "wf less_than" by (simp add: less_than_def (*‹less_than = pred_nat⁺›*) wf_pred_nat [THEN wf_trancl] (*‹wf (pred_nat⁺)›*)) lemma trans_less_than [iff]: "trans less_than" by (simp add: less_than_def (*‹less_than = pred_nat⁺›*)) lemma less_than_iff [iff]: "((x,y) ∈ less_than) = (x<y)" by (simp add: less_than_def (*‹less_than = pred_nat⁺›*) less_eq (*‹((?m, ?n) ∈ pred_nat⁺) = (?m < ?n)›*)) lemma irrefl_less_than: "irrefl less_than" using irrefl_def (*‹irrefl (?r::(?'a × ?'a) set) = (∀a::?'a. (a, a) ∉ ?r)›*) by blast lemma asym_less_than: "asym less_than" apply (rule asymI (*‹(⋀x y. (x, y) ∈ ?r ⟹ (y, x) ∉ ?r) ⟹ asym ?r›*)) (*goal: ‹asym less_than›*) by simp lemma total_less_than: "total less_than" and total_on_less_than [simp]: "total_on A less_than" using total_on_def (*‹total_on ?A ?r = (∀x∈?A. ∀y∈?A. x ≠ y ⟶ (x, y) ∈ ?r ∨ (y, x) ∈ ?r)›*) apply - (*goals: 1. ‹(⋀(A::?'a2 set) r::(?'a2 × ?'a2) set. total_on A r = (∀x::?'a2∈A. ∀y::?'a2∈A. x ≠ y ⟶ (x, y) ∈ r ∨ (y, x) ∈ r)) ⟹ total less_than› 2. ‹(⋀(A::?'a set) r::(?'a × ?'a) set. total_on A r = (∀x::?'a∈A. ∀y::?'a∈A. x ≠ y ⟶ (x, y) ∈ r ∨ (y, x) ∈ r)) ⟹ total_on (A::nat set) less_than› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . lemma wf_less: "wf {(x, y::nat). x < y}" by (rule Wellfounded.wellorder_class.wf (*‹wf {(x, y). x < y}›*)) subsection ‹Accessible Part› text ‹ Inductive definition of the accessible part ‹acc r› of a relation; see also \<^cite>‹"paulin-tlca"›. › inductive_set acc :: "('a × 'a) set ⇒ 'a set" for r :: "('a × 'a) set" where accI: "(⋀y. (y, x) ∈ r ⟹ y ∈ acc r) ⟹ x ∈ acc r" abbreviation termip :: "('a ⇒ 'a ⇒ bool) ⇒ 'a ⇒ bool" where "termip r ≡ accp (r¯¯)" abbreviation termi :: "('a × 'a) set ⇒ 'a set" where "termi r ≡ acc (r¯)" lemmas accpI = accp.accI lemma accp_eq_acc [code]: "accp r = (λx. x ∈ Wellfounded.acc {(x, y). r x y})" by (simp add: acc_def (*‹acc ≡ λr. {x. accp (λx xa. (x, xa) ∈ r) x}›*)) text ‹Induction rules› theorem accp_induct: assumes major: "accp r a" assumes hyp: "⋀x. accp r x ⟹ ∀y. r y x ⟶ P y ⟹ P x" shows "P a" apply (rule major [THEN accp.induct] (*‹(⋀x. ⟦⋀y. r y x ⟹ accp r y; ⋀y. r y x ⟹ ?P y⟧ ⟹ ?P x) ⟹ ?P a›*)) (*goal: ‹P a›*) apply (rule hyp (*‹⟦accp r ?x; ∀y. r y ?x ⟶ P y⟧ ⟹ P ?x›*)) (*goals: 1. ‹⋀x. ⟦⋀y. r y x ⟹ accp r y; ⋀y. r y x ⟹ P y⟧ ⟹ accp r x› 2. ‹⋀x. ⟦⋀y. r y x ⟹ accp r y; ⋀y. r y x ⟹ P y⟧ ⟹ ∀y. r y x ⟶ P y› discuss goal 1*) apply (rule accp.accI (*‹(⋀y. ?r y ?x ⟹ accp ?r y) ⟹ accp ?r ?x›*)) (*top goal: ‹⋀x. ⟦⋀y. r y x ⟹ accp r y; ⋀y. r y x ⟹ P y⟧ ⟹ accp r x› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemmas accp_induct_rule = accp_induct [rule_format, induct set: accp] theorem accp_downward: "accp r b ⟹ r a b ⟹ accp r a" apply (cases rule: accp.cases (*‹⟦accp ?r ?a; ⋀x. ⟦?a = x; ⋀y. ?r y x ⟹ accp ?r y⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦accp r b; r a b⟧ ⟹ accp ?r ?a› 2. ‹⟦accp r b; r a b; ⋀y. ?r y ?a ⟹ accp ?r y⟧ ⟹ accp r a› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma not_accp_down: assumes na: "¬ accp R x" obtains z where "R z x" and "¬ accp R z" proof (-) (*goal: ‹(⋀z. ⟦R z x; ¬ accp R z⟧ ⟹ thesis) ⟹ thesis›*) assume a: "⋀z. R z x ⟹ ¬ accp R z ⟹ thesis" (*‹⟦(R::'a ⇒ 'a ⇒ bool) (?z::'a) (x::'a); ¬ accp R ?z⟧ ⟹ thesis::bool›*) show thesis proof (cases "∀z. R z x ⟶ accp R z") (*goals: 1. ‹∀z. R z x ⟶ accp R z ⟹ thesis› 2. ‹¬ (∀z. R z x ⟶ accp R z) ⟹ thesis›*) case True (*‹∀z. R z x ⟶ accp R z›*) then have "⋀z. R z x ⟹ accp R z" by auto then have "accp R x" by (rule accp.accI (*‹(⋀y. ?r y ?x ⟹ accp ?r y) ⟹ accp ?r ?x›*)) with na (*‹¬ accp R x›*) show thesis by standard next (*goal: ‹¬ (∀z. R z x ⟶ accp R z) ⟹ thesis›*) case False (*‹¬ (∀z. R z x ⟶ accp R z)›*) then obtain z where "R z x" and "¬ accp R z" (*goal: ‹(⋀z. ⟦R z x; ¬ accp R z⟧ ⟹ thesis) ⟹ thesis›*) by auto with a (*‹⟦R ?z x; ¬ accp R ?z⟧ ⟹ thesis›*) show thesis . qed qed lemma accp_downwards_aux: "r⇧*⇧* b a ⟹ accp r a ⟶ accp r b" apply (erule rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹accp r b ⟶ accp r b› 2. ‹⋀y z. ⟦r⇧*⇧* b y; r y z; accp r y ⟶ accp r b⟧ ⟹ accp r z ⟶ accp r b› discuss goal 1*) apply (blast dest: accp_downward (*‹⟦accp ?r ?b; ?r ?a ?b⟧ ⟹ accp ?r ?a›*)) (*discuss goal 2*) apply (blast dest: accp_downward (*‹⟦accp ?r ?b; ?r ?a ?b⟧ ⟹ accp ?r ?a›*)) (*proven 2 subgoals*) . theorem accp_downwards: "accp r a ⟹ r⇧*⇧* b a ⟹ accp r b" by (blast dest: accp_downwards_aux (*‹?r⇧*⇧* ?b ?a ⟹ accp ?r ?a ⟶ accp ?r ?b›*)) theorem accp_wfPI: "∀x. accp r x ⟹ wfP r" proof (rule wfPUNIVI (*‹(⋀P x. ∀x. (∀y. ?r y x ⟶ P y) ⟶ P x ⟹ P x) ⟹ wfp ?r›*)) (*goal: ‹⋀P x. ⟦∀x. accp r x; ∀x. (∀y. r y x ⟶ P y) ⟶ P x⟧ ⟹ P x›*) fix P and x assume "∀x. accp r x" "∀x. (∀y. r y x ⟶ P y) ⟶ P x" (*‹∀x::'a. accp (r::'a ⇒ 'a ⇒ bool) x› ‹∀x::'a. (∀y::'a. (r::'a ⇒ 'a ⇒ bool) y x ⟶ (P::'a ⇒ bool) y) ⟶ P x›*) then show "P x" using accp_induct[where P = P] (*‹⟦accp ?r ?a; ⋀x. ⟦accp ?r x; ∀y. ?r y x ⟶ P y⟧ ⟹ P x⟧ ⟹ P ?a›*) by blast qed theorem accp_wfPD: "wfP r ⟹ accp r x" apply (erule wfP_induct_rule (*‹⟦wfp ?r; ⋀x. (⋀y. ?r y x ⟹ ?P y) ⟹ ?P x⟧ ⟹ ?P ?a›*)) (*goal: ‹wfp r ⟹ accp r x›*) apply (rule accp.accI (*‹(⋀y. ?r y ?x ⟹ accp ?r y) ⟹ accp ?r ?x›*)) (*goal: ‹⋀x. (⋀y. r y x ⟹ accp r y) ⟹ accp r x›*) by blast theorem wfP_accp_iff: "wfP r = (∀x. accp r x)" by (blast intro: accp_wfPI (*‹∀x::?'a. accp (?r::?'a ⇒ ?'a ⇒ bool) x ⟹ wfp ?r›*) dest: accp_wfPD (*‹wfp (?r::?'a ⇒ ?'a ⇒ bool) ⟹ accp ?r (?x::?'a)›*)) text ‹Smaller relations have bigger accessible parts:› lemma accp_subset: assumes "R1 ≤ R2" shows "accp R2 ≤ accp R1" proof (rule predicate1I (*‹(⋀x. ?P x ⟹ ?Q x) ⟹ ?P ≤ ?Q›*)) (*goal: ‹⋀x. accp R2 x ⟹ accp R1 x›*) fix x assume "accp R2 x" (*‹accp (R2::'a ⇒ 'a ⇒ bool) (x::'a)›*) then show "accp R1 x" proof (induct x) (*goal: ‹⋀x. ⟦accp R2 x; ⋀y. R2 y x ⟹ accp R1 y⟧ ⟹ accp R1 x›*) fix x assume "⋀y. R2 y x ⟹ accp R1 y" (*‹(R2::'a ⇒ 'a ⇒ bool) (?y::'a) (x::'a) ⟹ accp (R1::'a ⇒ 'a ⇒ bool) ?y›*) with assms (*‹(R1::'a::type ⇒ 'a::type ⇒ bool) ≤ (R2::'a::type ⇒ 'a::type ⇒ bool)›*) show "accp R1 x" by (blast intro: accp.accI (*‹(⋀y. ?r y ?x ⟹ accp ?r y) ⟹ accp ?r ?x›*)) qed qed text ‹This is a generalized induction theorem that works on subsets of the accessible part.› lemma accp_subset_induct: assumes subset: "D ≤ accp R" and dcl: "⋀x z. D x ⟹ R z x ⟹ D z" and "D x" and istep: "⋀x. D x ⟹ (⋀z. R z x ⟹ P z) ⟹ P x" shows "P x" proof (-) (*goal: ‹P x›*) from subset (*‹(D::'a ⇒ bool) ≤ accp (R::'a ⇒ 'a ⇒ bool)›*) ‹D x› (*‹D x›*) have "accp R x" by standard then show "P x" using ‹D x› (*‹D x›*) proof (induct x) (*goal: ‹⋀x. ⟦accp R x; ⋀y. ⟦R y x; D y⟧ ⟹ P y; D x⟧ ⟹ P x›*) fix x assume "D x" and "⋀y. R y x ⟹ D y ⟹ P y" (*‹(D::'a ⇒ bool) (x::'a)› ‹⟦(R::'a ⇒ 'a ⇒ bool) (?y::'a) (x::'a); (D::'a ⇒ bool) ?y⟧ ⟹ (P::'a ⇒ bool) ?y›*) with dcl (*‹⟦D ?x; R ?z ?x⟧ ⟹ D ?z›*) istep (*‹⟦D ?x; ⋀z. R z ?x ⟹ P z⟧ ⟹ P ?x›*) show "P x" by blast qed qed text ‹Set versions of the above theorems› lemmas acc_induct = accp_induct [to_set] lemmas acc_induct_rule = acc_induct [rule_format, induct set: acc] lemmas acc_downward = accp_downward [to_set] lemmas not_acc_down = not_accp_down [to_set] lemmas acc_downwards_aux = accp_downwards_aux [to_set] lemmas acc_downwards = accp_downwards [to_set] lemmas acc_wfI = accp_wfPI [to_set] lemmas acc_wfD = accp_wfPD [to_set] lemmas wf_acc_iff = wfP_accp_iff [to_set] lemmas acc_subset = accp_subset [to_set] lemmas acc_subset_induct = accp_subset_induct [to_set] subsection ‹Tools for building wellfounded relations› text ‹Inverse Image› lemma wf_inv_image [simp,intro!]: fixes f :: "'a ⇒ 'b" assumes "wf r" shows "wf (inv_image r f)" proof (-) (*goal: ‹wf (inv_image r f)›*) have "⋀x P. x ∈ P ⟹ ∃z∈P. ∀y. (f y, f z) ∈ r ⟶ y ∉ P" proof (-) (*goal: ‹⋀x P. x ∈ P ⟹ ∃z∈P. ∀y. (f y, f z) ∈ r ⟶ y ∉ P›*) fix P and x :: 'a assume "x ∈ P" (*‹(x::'a) ∈ (P::'a set)›*) then obtain w where w: "w ∈ {w. ∃x::'a. x ∈ P ∧ f x = w}" (*goal: ‹(⋀w::'b. w ∈ {w::'b. ∃x::'a. x ∈ (P::'a set) ∧ (f::'a ⇒ 'b) x = w} ⟹ thesis::bool) ⟹ thesis›*) by auto have "*": "⋀Q u. u ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ r ⟶ y ∉ Q" using assms (*‹wf (r::('b::type × 'b::type) set)›*) by (auto simp add: wf_eq_minimal (*‹wf ?r = (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ ?r ⟶ y ∉ Q))›*)) show "∃z∈P. ∀y. (f y, f z) ∈ r ⟶ y ∉ P" using "*"[OF w] (*‹∃z∈{w. ∃x. x ∈ P ∧ f x = w}. ∀y. (y, z) ∈ r ⟶ y ∉ {w. ∃x. x ∈ P ∧ f x = w}›*) by auto qed then show "?thesis" (*goal: ‹wf (inv_image r f)›*) by (clarsimp simp: inv_image_def (*‹inv_image ?r ?f = {(x, y). (?f x, ?f y) ∈ ?r}›*) wf_eq_minimal (*‹wf ?r = (∀Q x. x ∈ Q ⟶ (∃z∈Q. ∀y. (y, z) ∈ ?r ⟶ y ∉ Q))›*)) qed lemma wfp_on_inv_imagep: assumes wf: "wfp_on (f ` A) R" shows "wfp_on A (inv_imagep R f)" unfolding wfp_on_iff_ex_minimal (*goal: ‹∀B⊆A. B ≠ {} ⟶ (∃z∈B. ∀y. inv_imagep R f y z ⟶ y ∉ B)›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀B::'b set. ⟦B ⊆ (A::'b set); B ≠ {}⟧ ⟹ ∃z::'b∈B. ∀y::'b. inv_imagep (R::'a ⇒ 'a ⇒ bool) (f::'b ⇒ 'a) y z ⟶ y ∉ B›*) fix B assume "B ⊆ A" and "B ≠ {}" (*‹(B::'b set) ⊆ (A::'b set)› ‹(B::'b set) ≠ {}›*) hence "∃z∈f ` B. ∀y. R y z ⟶ y ∉ f ` B" using wf[unfolded wfp_on_iff_ex_minimal, rule_format, of "f ` B"] (*‹⟦f ` B ⊆ f ` A; f ` B ≠ {}⟧ ⟹ ∃z∈f ` B. ∀y. R y z ⟶ y ∉ f ` B›*) by blast thus "∃z∈B. ∀y. inv_imagep R f y z ⟶ y ∉ B" unfolding inv_imagep_def (*goal: ‹∃z∈B. ∀y. R (f y) (f z) ⟶ y ∉ B›*) by auto qed subsubsection ‹Conversion to a known well-founded relation› lemma wfp_on_if_convertible_to_wfp_on: assumes wf: "wfp_on (f ` A) Q" and convertible: "(⋀x y. x ∈ A ⟹ y ∈ A ⟹ R x y ⟹ Q (f x) (f y))" shows "wfp_on A R" unfolding wfp_on_iff_ex_minimal (*goal: ‹∀B⊆A. B ≠ {} ⟶ (∃z∈B. ∀y. R y z ⟶ y ∉ B)›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀B. ⟦B ⊆ A; B ≠ {}⟧ ⟹ ∃z∈B. ∀y. R y z ⟶ y ∉ B›*) fix B assume "B ⊆ A" and "B ≠ {}" (*‹(B::'b set) ⊆ (A::'b set)› ‹(B::'b set) ≠ {}›*) moreover from wf (*‹wfp_on (f ` A) Q›*) have "wfp_on A (inv_imagep Q f)" by (rule wfp_on_inv_imagep (*‹wfp_on ((?f::?'b ⇒ ?'a) ` (?A::?'b set)) (?R::?'a ⇒ ?'a ⇒ bool) ⟹ wfp_on ?A (inv_imagep ?R ?f)›*)) ultimately obtain y where "y ∈ B" and "⋀z. Q (f z) (f y) ⟹ z ∉ B" (*goal: ‹(⋀y. ⟦y ∈ B; ⋀z. Q (f z) (f y) ⟹ z ∉ B⟧ ⟹ thesis) ⟹ thesis›*) unfolding wfp_on_iff_ex_minimal in_inv_imagep (*goal: ‹(⋀y. ⟦y ∈ B; ⋀z. Q (f z) (f y) ⟹ z ∉ B⟧ ⟹ thesis) ⟹ thesis›*) by blast thus "∃z ∈ B. ∀y. R y z ⟶ y ∉ B" using ‹B ⊆ A› (*‹B ⊆ A›*) convertible (*‹⟦?x ∈ A; ?y ∈ A; R ?x ?y⟧ ⟹ Q (f ?x) (f ?y)›*) by blast qed lemma wf_on_if_convertible_to_wf_on: "wf_on (f ` A) Q ⟹ (⋀x y. x ∈ A ⟹ y ∈ A ⟹ (x, y) ∈ R ⟹ (f x, f y) ∈ Q) ⟹ wf_on A R" using wfp_on_if_convertible_to_wfp_on[to_set] (*‹⟦wf_on (?f ` ?A) ?Q; ⋀x y. ⟦x ∈ ?A; y ∈ ?A; (x, y) ∈ ?R⟧ ⟹ (?f x, ?f y) ∈ ?Q⟧ ⟹ wf_on ?A ?R›*) . lemma wf_if_convertible_to_wf: fixes r :: "'a rel" and s :: "'b rel" and f :: "'a ⇒ 'b" assumes "wf s" and convertible: "⋀x y. (x, y) ∈ r ⟹ (f x, f y) ∈ s" shows "wf r" proof (rule wf_on_if_convertible_to_wf_on (*‹⟦wf_on (?f ` ?A) ?Q; ⋀x y. ⟦x ∈ ?A; y ∈ ?A; (x, y) ∈ ?R⟧ ⟹ (?f x, ?f y) ∈ ?Q⟧ ⟹ wf_on ?A ?R›*)) (*goals: 1. ‹wf_on (range ?f) ?Q› 2. ‹⋀x y. ⟦x ∈ UNIV; y ∈ UNIV; (x, y) ∈ r⟧ ⟹ (?f x, ?f y) ∈ ?Q›*) show "wf_on (range f) s" using wf_on_subset[OF ‹wf s› subset_UNIV] (*‹wf_on ?A s›*) . next (*goal: ‹⋀x y. ⟦x ∈ UNIV; y ∈ UNIV; (x, y) ∈ r⟧ ⟹ (f x, f y) ∈ s›*) show "⋀x y. (x, y) ∈ r ⟹ (f x, f y) ∈ s" using convertible (*‹(?x::'a::type, ?y::'a::type) ∈ (r::('a::type × 'a::type) set) ⟹ ((f::'a::type ⇒ 'b::type) ?x, f ?y) ∈ (s::('b::type × 'b::type) set)›*) . qed lemma wfP_if_convertible_to_wfP: "wfP S ⟹ (⋀x y. R x y ⟹ S (f x) (f y)) ⟹ wfP R" using wf_if_convertible_to_wf[to_pred, of S R f] (*‹⟦wfp S; ⋀x y. R x y ⟹ S (f x) (f y)⟧ ⟹ wfp R›*) by simp text ‹Converting to @{typ nat} is a very common special case that might be found more easily by Sledgehammer.› lemma wfP_if_convertible_to_nat: fixes f :: "_ ⇒ nat" shows "(⋀x y. R x y ⟹ f x < f y) ⟹ wfP R" by (rule wfP_if_convertible_to_wfP[of "(<) :: nat ⇒ nat ⇒ bool", simplified] (*‹(⋀x y. ?R x y ⟹ ?f x < ?f y) ⟹ wfp ?R›*)) subsubsection ‹Measure functions into \<^typ>‹nat›› definition measure :: "('a ⇒ nat) ⇒ ('a × 'a) set" where "measure = inv_image less_than" lemma in_measure[simp, code_unfold]: "(x, y) ∈ measure f ⟷ f x < f y" by (simp add:measure_def (*‹measure = inv_image less_than›*)) lemma wf_measure [iff]: "wf (measure f)" unfolding measure_def (*goal: ‹wf (inv_image less_than f)›*) by (rule wf_less_than [THEN wf_inv_image] (*‹wf (inv_image less_than ?f)›*)) lemma wf_if_measure: "(⋀x. P x ⟹ f(g x) < f x) ⟹ wf {(y,x). P x ∧ y = g x}" for f :: "'a ⇒ nat" using wf_measure[of f] (*‹wf (measure f)›*) unfolding measure_def inv_image_def less_than_def less_eq (*goal: ‹(⋀x. P x ⟹ f (g x) < f x) ⟹ wf {(y, x). P x ∧ y = g x}›*) apply (rule wf_subset (*‹⟦wf ?r; ?p ⊆ ?r⟧ ⟹ wf ?p›*)) (*goal: ‹(⋀x. P x ⟹ f (g x) < f x) ⟹ wf {(y, x). P x ∧ y = g x}›*) by auto subsubsection ‹Lexicographic combinations› definition lex_prod :: "('a ×'a) set ⇒ ('b × 'b) set ⇒ (('a × 'b) × ('a × 'b)) set" (infixr "<*lex*>" 80) where "ra <*lex*> rb = {((a, b), (a', b')). (a, a') ∈ ra ∨ a = a' ∧ (b, b') ∈ rb}" lemma in_lex_prod[simp]: "((a, b), (a', b')) ∈ r <*lex*> s ⟷ (a, a') ∈ r ∨ a = a' ∧ (b, b') ∈ s" by (auto simp:lex_prod_def (*‹?ra <*lex*> ?rb = {((a, b), a', b'). (a, a') ∈ ?ra ∨ a = a' ∧ (b, b') ∈ ?rb}›*)) lemma wf_lex_prod [intro!]: assumes "wf ra" "wf rb" shows "wf (ra <*lex*> rb)" proof (rule wfI (*‹⟦?r ⊆ ?A × ?B; ⋀x P. ⟦∀x. (∀y. (y, x) ∈ ?r ⟶ P y) ⟶ P x; x ∈ ?A; x ∈ ?B⟧ ⟹ P x⟧ ⟹ wf ?r›*)) (*goals: 1. ‹(ra::('a × 'a) set) <*lex*> (rb::('b × 'b) set) ⊆ (?A::('a × 'b) set) × (?B::('a × 'b) set)› 2. ‹⋀(x::'a × 'b) P::'a × 'b ⇒ bool. ⟦∀x::'a × 'b. (∀y::'a × 'b. (y, x) ∈ (ra::('a × 'a) set) <*lex*> (rb::('b × 'b) set) ⟶ P y) ⟶ P x; x ∈ (?A::('a × 'b) set); x ∈ (?B::('a × 'b) set)⟧ ⟹ P x›*) fix z :: "'a × 'b" and P assume "*"[rule_format]: "∀u. (∀v. (v, u) ∈ ra <*lex*> rb ⟶ P v) ⟶ P u" (*‹(⋀v::'a × 'b. (v, ?u::'a × 'b) ∈ (ra::('a × 'a) set) <*lex*> (rb::('b × 'b) set) ⟹ (P::'a × 'b ⇒ bool) v) ⟹ P ?u›*) obtain x and y where zeq: "z = (x,y)" (*goal: ‹(⋀x y. z = (x, y) ⟹ thesis) ⟹ thesis›*) by fastforce have "P(x,y)" using ‹wf ra› (*‹wf ra›*) proof (induction x arbitrary: y rule: wf_induct_rule) (*goal: ‹⋀x y. (⋀y ya. (y, x) ∈ ra ⟹ P (y, ya)) ⟹ P (x, y)›*) case (less x) (*‹(?y, x) ∈ ra ⟹ P (?y, ?ya)›*) note lessx = less (*‹(?y, x) ∈ ra ⟹ P (?y, ?ya)›*) show "?case" (*goal: ‹P (x, y)›*) using ‹wf rb› (*‹wf rb›*) less (*‹(?y, x) ∈ ra ⟹ P (?y, ?ya)›*) proof (induction y rule: wf_induct_rule (*‹⟦wf ?r; ⋀x. (⋀y. (y, x) ∈ ?r ⟹ ?P y) ⟹ ?P x⟧ ⟹ ?P ?a›*)) (*goal: ‹⋀x::'b::type. ⟦⋀y::'b::type. ⟦(y, x) ∈ (rb::('b::type × 'b::type) set); ⋀(y::'a::type) ya::'b::type. (y, x::'a::type) ∈ (ra::('a::type × 'a::type) set) ⟹ (P::'a::type × 'b::type ⇒ bool) (y, ya)⟧ ⟹ P (x, y); ⋀(y::'a::type) ya::'b::type. (y, x) ∈ ra ⟹ P (y, ya)⟧ ⟹ P (x, x)›*) case (less y) (*‹⟦(?y, y) ∈ rb; ⋀y ya. (y, x) ∈ ra ⟹ P (y, ya)⟧ ⟹ P (x, ?y)› ‹(?y, x) ∈ ra ⟹ P (?y, ?ya)›*) show "?case" (*goal: ‹(P::'a × 'b ⇒ bool) (x::'a, y::'b)›*) by (force intro: * (*‹(⋀v::'a × 'b. (v, ?u::'a × 'b) ∈ (ra::('a × 'a) set) <*lex*> (rb::('b × 'b) set) ⟹ (P::'a × 'b ⇒ bool) v) ⟹ P ?u›*) less.IH (*‹⟦(?y::'b, y::'b) ∈ (rb::('b × 'b) set); ⋀(y::'a) ya::'b. (y, x::'a) ∈ (ra::('a × 'a) set) ⟹ (P::'a × 'b ⇒ bool) (y, ya)⟧ ⟹ P (x, ?y)›*) lessx (*‹(?y::'a, x::'a) ∈ (ra::('a × 'a) set) ⟹ (P::'a × 'b ⇒ bool) (?y, ?ya::'b)›*)) qed qed then show "P z" by (simp add: zeq (*‹z = (x, y)›*)) qed (auto) (*solved the remaining goal: ‹(ra::('a × 'a) set) <*lex*> (rb::('b × 'b) set) ⊆ (?A::('a × 'b) set) × (?B::('a × 'b) set)›*) lemma refl_lex_prod[simp]: "refl r⇩B ⟹ refl (r⇩A <*lex*> r⇩B)" by (auto intro!: reflI (*‹(⋀x. (x, x) ∈ ?r) ⟹ refl ?r›*) dest: refl_onD (*‹⟦refl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∈ ?r›*)) lemma irrefl_on_lex_prod[simp]: "irrefl_on A r⇩A ⟹ irrefl_on B r⇩B ⟹ irrefl_on (A × B) (r⇩A <*lex*> r⇩B)" by (auto intro!: irrefl_onI (*‹(⋀a. a ∈ ?A ⟹ (a, a) ∉ ?r) ⟹ irrefl_on ?A ?r›*) dest: irrefl_onD (*‹⟦irrefl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∉ ?r›*)) lemma irrefl_lex_prod[simp]: "irrefl r⇩A ⟹ irrefl r⇩B ⟹ irrefl (r⇩A <*lex*> r⇩B)" apply (rule irrefl_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV] (*‹⟦irrefl (?r⇩A::(?'c1 × ?'c1) set); irrefl (?r⇩B::(?'d1 × ?'d1) set)⟧ ⟹ irrefl (?r⇩A <*lex*> ?r⇩B)›*)) (*goals: 1. ‹⟦irrefl r⇩A; irrefl r⇩B⟧ ⟹ irrefl r⇩A› 2. ‹⟦irrefl r⇩A; irrefl r⇩B⟧ ⟹ irrefl r⇩B› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma sym_on_lex_prod[simp]: "sym_on A r⇩A ⟹ sym_on B r⇩B ⟹ sym_on (A × B) (r⇩A <*lex*> r⇩B)" by (auto intro!: sym_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; (x, y) ∈ ?r⟧ ⟹ (y, x) ∈ ?r) ⟹ sym_on ?A ?r›*) dest: sym_onD (*‹⟦sym_on ?A ?r; ?x ∈ ?A; ?y ∈ ?A; (?x, ?y) ∈ ?r⟧ ⟹ (?y, ?x) ∈ ?r›*)) lemma sym_lex_prod[simp]: "sym r⇩A ⟹ sym r⇩B ⟹ sym (r⇩A <*lex*> r⇩B)" apply (rule sym_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV] (*‹⟦sym ?r⇩A; sym ?r⇩B⟧ ⟹ sym (?r⇩A <*lex*> ?r⇩B)›*)) (*goals: 1. ‹⟦sym r⇩A; sym r⇩B⟧ ⟹ sym r⇩A› 2. ‹⟦sym r⇩A; sym r⇩B⟧ ⟹ sym r⇩B› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma asym_on_lex_prod[simp]: "asym_on A r⇩A ⟹ asym_on B r⇩B ⟹ asym_on (A × B) (r⇩A <*lex*> r⇩B)" by (auto intro!: asym_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; (x, y) ∈ ?r⟧ ⟹ (y, x) ∉ ?r) ⟹ asym_on ?A ?r›*) dest: asym_onD (*‹⟦asym_on ?A ?r; ?x ∈ ?A; ?y ∈ ?A; (?x, ?y) ∈ ?r⟧ ⟹ (?y, ?x) ∉ ?r›*)) lemma asym_lex_prod[simp]: "asym r⇩A ⟹ asym r⇩B ⟹ asym (r⇩A <*lex*> r⇩B)" apply (rule asym_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV] (*‹⟦asym ?r⇩A; asym ?r⇩B⟧ ⟹ asym (?r⇩A <*lex*> ?r⇩B)›*)) (*goals: 1. ‹⟦asym r⇩A; asym r⇩B⟧ ⟹ asym r⇩A› 2. ‹⟦asym r⇩A; asym r⇩B⟧ ⟹ asym r⇩B› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma trans_on_lex_prod[simp]: assumes "trans_on A r⇩A" and "trans_on B r⇩B" shows "trans_on (A × B) (r⇩A <*lex*> r⇩B)" proof (rule trans_onI (*‹(⋀x y z. ⟦x ∈ ?A; y ∈ ?A; z ∈ ?A; (x, y) ∈ ?r; (y, z) ∈ ?r⟧ ⟹ (x, z) ∈ ?r) ⟹ trans_on ?A ?r›*)) (*goal: ‹⋀x y z. ⟦x ∈ A × B; y ∈ A × B; z ∈ A × B; (x, y) ∈ r⇩A <*lex*> r⇩B; (y, z) ∈ r⇩A <*lex*> r⇩B⟧ ⟹ (x, z) ∈ r⇩A <*lex*> r⇩B›*) fix x and y and z show "x ∈ A × B ⟹ y ∈ A × B ⟹ z ∈ A × B ⟹ (x, y) ∈ r⇩A <*lex*> r⇩B ⟹ (y, z) ∈ r⇩A <*lex*> r⇩B ⟹ (x, z) ∈ r⇩A <*lex*> r⇩B" using trans_onD[OF ‹trans_on A r⇩A›, of "fst x" "fst y" "fst z"] (*‹⟦fst x ∈ A; fst y ∈ A; fst z ∈ A; (fst x, fst y) ∈ r⇩A; (fst y, fst z) ∈ r⇩A⟧ ⟹ (fst x, fst z) ∈ r⇩A›*) using trans_onD[OF ‹trans_on B r⇩B›, of "snd x" "snd y" "snd z"] (*‹⟦snd x ∈ B; snd y ∈ B; snd z ∈ B; (snd x, snd y) ∈ r⇩B; (snd y, snd z) ∈ r⇩B⟧ ⟹ (snd x, snd z) ∈ r⇩B›*) by auto qed lemma trans_lex_prod [simp,intro!]: "trans r⇩A ⟹ trans r⇩B ⟹ trans (r⇩A <*lex*> r⇩B)" apply (rule trans_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV] (*‹⟦trans ?r⇩A; trans ?r⇩B⟧ ⟹ trans (?r⇩A <*lex*> ?r⇩B)›*)) (*goals: 1. ‹⟦trans r⇩A; trans r⇩B⟧ ⟹ trans r⇩A› 2. ‹⟦trans r⇩A; trans r⇩B⟧ ⟹ trans r⇩B› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma total_on_lex_prod[simp]: "total_on A r⇩A ⟹ total_on B r⇩B ⟹ total_on (A × B) (r⇩A <*lex*> r⇩B)" by (auto simp: total_on_def (*‹total_on ?A ?r = (∀x∈?A. ∀y∈?A. x ≠ y ⟶ (x, y) ∈ ?r ∨ (y, x) ∈ ?r)›*)) lemma total_lex_prod[simp]: "total r⇩A ⟹ total r⇩B ⟹ total (r⇩A <*lex*> r⇩B)" apply (rule total_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV] (*‹⟦total ?r⇩A; total ?r⇩B⟧ ⟹ total (?r⇩A <*lex*> ?r⇩B)›*)) (*goals: 1. ‹⟦total r⇩A; total r⇩B⟧ ⟹ total r⇩A› 2. ‹⟦total r⇩A; total r⇩B⟧ ⟹ total r⇩B› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) text ‹lexicographic combinations with measure functions› definition mlex_prod :: "('a ⇒ nat) ⇒ ('a × 'a) set ⇒ ('a × 'a) set" (infixr "<*mlex*>" 80) where "f <*mlex*> R = inv_image (less_than <*lex*> R) (λx. (f x, x))" lemma wf_mlex: "wf R ⟹ wf (f <*mlex*> R)" and mlex_less: "f x < f y ⟹ (x, y) ∈ f <*mlex*> R" and mlex_leq: "f x ≤ f y ⟹ (x, y) ∈ R ⟹ (x, y) ∈ f <*mlex*> R" and mlex_iff: "(x, y) ∈ f <*mlex*> R ⟷ f x < f y ∨ f x = f y ∧ (x, y) ∈ R" (*goals: 1. ‹wf R ⟹ wf (f <*mlex*> R)› 2. ‹f x < f y ⟹ (x, y) ∈ f <*mlex*> R› 3. ‹⟦f x ≤ f y; (x, y) ∈ R⟧ ⟹ (x, y) ∈ f <*mlex*> R› 4. ‹((x, y) ∈ f <*mlex*> R) = (f x < f y ∨ f x = f y ∧ (x, y) ∈ R)› discuss goal 1*) apply ((auto simp: mlex_prod_def (*‹(?f::?'a ⇒ nat) <*mlex*> (?R::(?'a × ?'a) set) = inv_image (less_than <*lex*> ?R) (λx::?'a. (?f x, x))›*))[1]) (*discuss goal 2*) apply ((auto simp: mlex_prod_def (*‹?f <*mlex*> ?R = inv_image (less_than <*lex*> ?R) (λx. (?f x, x))›*))[1]) (*discuss goal 3*) apply ((auto simp: mlex_prod_def (*‹(?f::?'a ⇒ nat) <*mlex*> (?R::(?'a × ?'a) set) = inv_image (less_than <*lex*> ?R) (λx::?'a. (?f x, x))›*))[1]) (*discuss goal 4*) apply ((auto simp: mlex_prod_def (*‹?f <*mlex*> ?R = inv_image (less_than <*lex*> ?R) (λx. (?f x, x))›*))[1]) (*proven 4 subgoals*) . text ‹Proper subset relation on finite sets.› definition finite_psubset :: "('a set × 'a set) set" where "finite_psubset = {(A, B). A ⊂ B ∧ finite B}" lemma wf_finite_psubset[simp]: "wf finite_psubset" apply (unfold finite_psubset_def (*‹finite_psubset = {(A, B). A ⊂ B ∧ finite B}›*)) (*goal: ‹wf finite_psubset›*) apply (rule wf_measure [THEN wf_subset] (*‹?p ⊆ measure ?f1 ⟹ wf ?p›*)) (*goal: ‹wf {(A, B). A ⊂ B ∧ finite B}›*) apply (simp add: measure_def (*‹measure = inv_image less_than›*) inv_image_def (*‹inv_image ?r ?f = {(x, y). (?f x, ?f y) ∈ ?r}›*) less_than_def (*‹less_than = pred_nat⁺›*) less_eq (*‹((?m, ?n) ∈ pred_nat⁺) = (?m < ?n)›*)) (*goal: ‹{(A, B). A ⊂ B ∧ finite B} ⊆ measure ?f1›*) by (fast elim!: psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) lemma trans_finite_psubset: "trans finite_psubset" by (auto simp: finite_psubset_def (*‹finite_psubset = {(A, B). A ⊂ B ∧ finite B}›*) less_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ?x ≠ ?y)›*) trans_def (*‹trans ?r = (∀x y z. (x, y) ∈ ?r ⟶ (y, z) ∈ ?r ⟶ (x, z) ∈ ?r)›*)) lemma in_finite_psubset[simp]: "(A, B) ∈ finite_psubset ⟷ A ⊂ B ∧ finite B" unfolding finite_psubset_def (*goal: ‹((A, B) ∈ {(A, B). A ⊂ B ∧ finite B}) = (A ⊂ B ∧ finite B)›*) by auto text ‹max- and min-extension of order to finite sets› inductive_set max_ext :: "('a × 'a) set ⇒ ('a set × 'a set) set" for R :: "('a × 'a) set" where max_extI[intro]: "finite X ⟹ finite Y ⟹ Y ≠ {} ⟹ (⋀x. x ∈ X ⟹ ∃y∈Y. (x, y) ∈ R) ⟹ (X, Y) ∈ max_ext R" lemma max_ext_wf: assumes wf: "wf r" shows "wf (max_ext r)" apply (rule acc_wfI (*‹∀x. x ∈ acc ?r ⟹ wf ?r›*)) (*goal: ‹wf (max_ext r)›*) proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⋀x. x ∈ acc (max_ext r)›*) show "M ∈ acc (max_ext r)" (is "_ ∈ ?W") for M proof (induct M rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*)) (*goals: 1. ‹⋀A. infinite A ⟹ A ∈ acc (max_ext r)› 2. ‹{} ∈ acc (max_ext r)› 3. ‹⋀x F. ⟦finite F; x ∉ F; F ∈ acc (max_ext r)⟧ ⟹ insert x F ∈ acc (max_ext r)›*) case empty (*no hyothesis introduced yet*) show "?case" (*goal: ‹{} ∈ acc (max_ext (r::('a × 'a) set))›*) apply (rule accI (*‹(⋀y. (y, ?x) ∈ ?r ⟹ y ∈ acc ?r) ⟹ ?x ∈ acc ?r›*)) (*goal: ‹{} ∈ acc (max_ext (r::('a × 'a) set))›*) by (auto elim: max_ext.cases (*‹⟦(?a1.0, ?a2.0) ∈ max_ext ?R; ⋀X Y. ⟦?a1.0 = X; ?a2.0 = Y; finite X; finite Y; Y ≠ {}; ⋀x. x ∈ X ⟹ ∃xa∈Y. (x, xa) ∈ ?R⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goals: 1. ‹⋀A. infinite A ⟹ A ∈ acc (max_ext r)› 2. ‹⋀x F. ⟦finite F; x ∉ F; F ∈ acc (max_ext r)⟧ ⟹ insert x F ∈ acc (max_ext r)›*) case (insert a M) (*‹finite M› ‹a ∉ M› ‹(M::'a::type set) ∈ acc (max_ext (r::('a::type × 'a::type) set))›*) from wf (*‹wf (r::('a × 'a) set)›*) ‹M ∈ ?W› (*‹M ∈ acc (max_ext r)›*) ‹finite M› (*‹finite (M::'a set)›*) show "insert a M ∈ ?W" proof (induct arbitrary: M) (*goal: ‹⋀x M. ⟦⋀y M. ⟦(y, x) ∈ r; M ∈ acc (max_ext r); finite M⟧ ⟹ insert y M ∈ acc (max_ext r); M ∈ acc (max_ext r); finite M⟧ ⟹ insert x M ∈ acc (max_ext r)›*) fix M and a assume "M ∈ ?W" (*‹(M::'a set) ∈ acc (max_ext (r::('a × 'a) set))›*) assume [intro]: "finite M" (*‹finite (M::'a set)›*) assume hyp: "⋀b M. (b, a) ∈ r ⟹ M ∈ ?W ⟹ finite M ⟹ insert b M ∈ ?W" (*‹⟦(?b::'a, a::'a) ∈ (r::('a × 'a) set); (?M::'a set) ∈ acc (max_ext r); finite ?M⟧ ⟹ insert ?b ?M ∈ acc (max_ext r)›*) have add_less: "M ∈ ?W ⟹ (⋀y. y ∈ N ⟹ (y, a) ∈ r) ⟹ N ∪ M ∈ ?W" if "finite N" "finite M" for N :: "'a set" and M :: "'a set" using that (*‹finite N› ‹finite (M::'a set)›*) apply (induct N arbitrary: M) (*goals: 1. ‹⋀M. ⟦M ∈ acc (max_ext r); ⋀y. y ∈ {} ⟹ (y, a) ∈ r; finite M⟧ ⟹ {} ∪ M ∈ acc (max_ext r)› 2. ‹⋀x F M. ⟦finite F; x ∉ F; ⋀M. ⟦M ∈ acc (max_ext r); ⋀y. y ∈ F ⟹ (y, a) ∈ r; finite M⟧ ⟹ F ∪ M ∈ acc (max_ext r); M ∈ acc (max_ext r); ⋀y. y ∈ insert x F ⟹ (y, a) ∈ r; finite M⟧ ⟹ insert x F ∪ M ∈ acc (max_ext r)› discuss goal 1*) apply ((auto simp: hyp (*‹⟦(?b, a) ∈ r; ?M ∈ acc (max_ext r); finite ?M⟧ ⟹ insert ?b ?M ∈ acc (max_ext r)›*))[1]) (*discuss goal 2*) apply ((auto simp: hyp (*‹⟦(?b::'a, a::'a) ∈ (r::('a × 'a) set); (?M::'a set) ∈ acc (max_ext r); finite ?M⟧ ⟹ insert ?b ?M ∈ acc (max_ext r)›*))[1]) (*proven 2 subgoals*) . show "insert a M ∈ ?W" proof (rule accI (*‹(⋀y. (y, ?x) ∈ ?r ⟹ y ∈ acc ?r) ⟹ ?x ∈ acc ?r›*)) (*goal: ‹⋀y::'a set. (y, insert (a::'a) (M::'a set)) ∈ max_ext (r::('a × 'a) set) ⟹ y ∈ acc (max_ext r)›*) fix N assume Nless: "(N, insert a M) ∈ max_ext r" (*‹(N::'a set, insert (a::'a) (M::'a set)) ∈ max_ext (r::('a × 'a) set)›*) then have "*": "⋀x. x ∈ N ⟹ (x, a) ∈ r ∨ (∃y ∈ M. (x, y) ∈ r)" by (auto elim!: max_ext.cases (*‹⟦(?a1.0::?'a set, ?a2.0::?'a set) ∈ max_ext (?R::(?'a × ?'a) set); ⋀(X::?'a set) Y::?'a set. ⟦?a1.0 = X; ?a2.0 = Y; finite X; finite Y; Y ≠ {}; ⋀x::?'a. x ∈ X ⟹ ∃xa::?'a∈Y. (x, xa) ∈ ?R⟧ ⟹ ?P::bool⟧ ⟹ ?P›*)) let ?N1 = "{n ∈ N. (n, a) ∈ r}" let ?N2 = "{n ∈ N. (n, a) ∉ r}" have N: "?N1 ∪ ?N2 = N" apply (rule set_eqI (*‹(⋀x. (x ∈ ?A) = (x ∈ ?B)) ⟹ ?A = ?B›*)) (*goal: ‹{n ∈ N. (n, a) ∈ r} ∪ {n ∈ N. (n, a) ∉ r} = N›*) by auto from Nless (*‹(N, insert a M) ∈ max_ext r›*) have "finite N" by (auto elim: max_ext.cases (*‹⟦(?a1.0, ?a2.0) ∈ max_ext ?R; ⋀X Y. ⟦?a1.0 = X; ?a2.0 = Y; finite X; finite Y; Y ≠ {}; ⋀x. x ∈ X ⟹ ∃xa∈Y. (x, xa) ∈ ?R⟧ ⟹ ?P⟧ ⟹ ?P›*)) then have finites: "finite ?N1" "finite ?N2" apply - (*goals: 1. ‹finite N ⟹ finite {n ∈ N. (n, a) ∈ r}› 2. ‹finite N ⟹ finite {n ∈ N. (n, a) ∉ r}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "?N2 ∈ ?W" proof (cases "M = {}") (*goals: 1. ‹(M::'a set) = {} ⟹ {n::'a ∈ N::'a set. (n, a::'a) ∉ (r::('a × 'a) set)} ∈ acc (max_ext r)› 2. ‹(M::'a set) ≠ {} ⟹ {n::'a ∈ N::'a set. (n, a::'a) ∉ (r::('a × 'a) set)} ∈ acc (max_ext r)›*) case [simp]: True (*‹M = {}›*) have Mw: "{} ∈ ?W" apply (rule accI (*‹(⋀y. (y, ?x) ∈ ?r ⟹ y ∈ acc ?r) ⟹ ?x ∈ acc ?r›*)) (*goal: ‹{} ∈ acc (max_ext r)›*) by (auto elim: max_ext.cases (*‹⟦(?a1.0::?'a set, ?a2.0::?'a set) ∈ max_ext (?R::(?'a × ?'a) set); ⋀(X::?'a set) Y::?'a set. ⟦?a1.0 = X; ?a2.0 = Y; finite X; finite Y; Y ≠ {}; ⋀x::?'a. x ∈ X ⟹ ∃xa::?'a∈Y. (x, xa) ∈ ?R⟧ ⟹ ?P::bool⟧ ⟹ ?P›*)) from "*" (*‹(?x::'a::type) ∈ (N::'a::type set) ⟹ (?x, a::'a::type) ∈ (r::('a::type × 'a::type) set) ∨ (∃y::'a::type∈M::'a::type set. (?x, y) ∈ r)›*) have "?N2 = {}" by auto with Mw (*‹{} ∈ acc (max_ext r)›*) show "?N2 ∈ ?W" by (simp only:) next (*goal: ‹M ≠ {} ⟹ {n ∈ N. (n, a) ∉ r} ∈ acc (max_ext r)›*) case False (*‹M ≠ {}›*) from "*" (*‹?x ∈ N ⟹ (?x, a) ∈ r ∨ (∃y∈M. (?x, y) ∈ r)›*) finites (*‹finite {n::'a ∈ N::'a set. (n, a::'a) ∈ (r::('a × 'a) set)}› ‹finite {n::'a ∈ N::'a set. (n, a::'a) ∉ (r::('a × 'a) set)}›*) have N2: "(?N2, M) ∈ max_ext r" using max_extI[OF _ _ ‹M ≠ {}›, where ?X = ?N2] (*‹⟦finite {n ∈ N. (n, a) ∉ r}; finite M; ⋀x. x ∈ {n ∈ N. (n, a) ∉ r} ⟹ ∃xa∈M. (x, xa) ∈ ?R⟧ ⟹ ({n ∈ N. (n, a) ∉ r}, M) ∈ max_ext ?R›*) by auto with ‹M ∈ ?W› (*‹M ∈ acc (max_ext r)›*) show "?N2 ∈ ?W" by (rule acc_downward (*‹⟦?b ∈ acc ?r; (?a, ?b) ∈ ?r⟧ ⟹ ?a ∈ acc ?r›*)) qed with finites (*‹finite {n ∈ N. (n, a) ∈ r}› ‹finite {n ∈ N. (n, a) ∉ r}›*) have "?N1 ∪ ?N2 ∈ ?W" apply (rule add_less (*‹⟦finite ?N; finite ?M; ?M ∈ acc (max_ext r); ⋀y. y ∈ ?N ⟹ (y, a) ∈ r⟧ ⟹ ?N ∪ ?M ∈ acc (max_ext r)›*)) (*goal: ‹{n ∈ N. (n, a) ∈ r} ∪ {n ∈ N. (n, a) ∉ r} ∈ acc (max_ext r)›*) by simp then show "N ∈ ?W" by (simp only: N (*‹{n ∈ N. (n, a) ∈ r} ∪ {n ∈ N. (n, a) ∉ r} = N›*)) qed qed next (*goal: ‹⋀A. infinite A ⟹ A ∈ acc (max_ext r)›*) case infinite (*‹infinite A_›*) show "?case" (*goal: ‹A_ ∈ acc (max_ext r)›*) apply (rule accI (*‹(⋀y::?'a. (y, ?x::?'a) ∈ (?r::(?'a × ?'a) set) ⟹ y ∈ acc ?r) ⟹ ?x ∈ acc ?r›*)) (*goal: ‹A_ ∈ acc (max_ext r)›*) by (auto elim: max_ext.cases (*‹⟦(?a1.0, ?a2.0) ∈ max_ext ?R; ⋀X Y. ⟦?a1.0 = X; ?a2.0 = Y; finite X; finite Y; Y ≠ {}; ⋀x. x ∈ X ⟹ ∃xa∈Y. (x, xa) ∈ ?R⟧ ⟹ ?P⟧ ⟹ ?P›*) simp: infinite (*‹infinite A_›*)) qed qed lemma max_ext_additive: "(A, B) ∈ max_ext R ⟹ (C, D) ∈ max_ext R ⟹ (A ∪ C, B ∪ D) ∈ max_ext R" by (force elim!: max_ext.cases (*‹⟦(?a1.0, ?a2.0) ∈ max_ext ?R; ⋀X Y. ⟦?a1.0 = X; ?a2.0 = Y; finite X; finite Y; Y ≠ {}; ⋀x. x ∈ X ⟹ ∃xa∈Y. (x, xa) ∈ ?R⟧ ⟹ ?P⟧ ⟹ ?P›*)) definition min_ext :: "('a × 'a) set ⇒ ('a set × 'a set) set" where "min_ext r = {(X, Y) | X Y. X ≠ {} ∧ (∀y ∈ Y. (∃x ∈ X. (x, y) ∈ r))}" lemma min_ext_wf: assumes "wf r" shows "wf (min_ext r)" proof (rule wfI_min (*‹(⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ ?R ⟶ y ∉ Q) ⟹ wf ?R›*)) (*goal: ‹⋀x Q. x ∈ Q ⟹ ∃z∈Q. ∀y. (y, z) ∈ min_ext r ⟶ y ∉ Q›*) show "∃m ∈ Q. (∀n. (n, m) ∈ min_ext r ⟶ n ∉ Q)" if nonempty: "x ∈ Q" for Q :: "'a set set" and x proof (cases "Q = {{}}") (*goals: 1. ‹Q = {{}} ⟹ ∃m∈Q. ∀n. (n, m) ∈ min_ext r ⟶ n ∉ Q› 2. ‹Q ≠ {{}} ⟹ ∃m∈Q. ∀n. (n, m) ∈ min_ext r ⟶ n ∉ Q›*) case True (*‹Q = {{}}›*) then show "?thesis" (*goal: ‹∃m∈Q. ∀n. (n, m) ∈ min_ext r ⟶ n ∉ Q›*) by (simp add: min_ext_def (*‹min_ext ?r = {(X, Y) |X Y. X ≠ {} ∧ (∀y∈Y. ∃x∈X. (x, y) ∈ ?r)}›*)) next (*goal: ‹Q ≠ {{}} ⟹ ∃m∈Q. ∀n. (n, m) ∈ min_ext r ⟶ n ∉ Q›*) case False (*‹(Q::'a set set) ≠ {{}}›*) with nonempty (*‹(x::'a set) ∈ (Q::'a set set)›*) obtain e and x where "x ∈ Q" "e ∈ x" (*goal: ‹(⋀x e. ⟦x ∈ Q; e ∈ x⟧ ⟹ thesis) ⟹ thesis›*) by force then have eU: "e ∈ ⋃Q" by auto with ‹wf r› (*‹wf r›*) obtain z where z: "z ∈ ⋃Q" "⋀y. (y, z) ∈ r ⟹ y ∉ ⋃Q" (*goal: ‹(⋀z::'a. ⟦z ∈ ⋃ (Q::'a set set); ⋀y::'a. (y, z) ∈ (r::('a × 'a) set) ⟹ y ∉ ⋃ Q⟧ ⟹ thesis::bool) ⟹ thesis›*) by (erule wfE_min (*‹⟦wf ?R; ?x ∈ ?Q; ⋀z. ⟦z ∈ ?Q; ⋀y. (y, z) ∈ ?R ⟹ y ∉ ?Q⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) from z (*‹(z::'a) ∈ ⋃ (Q::'a set set)› ‹(?y::'a, z::'a) ∈ (r::('a × 'a) set) ⟹ ?y ∉ ⋃ (Q::'a set set)›*) obtain m where "m ∈ Q" "z ∈ m" (*goal: ‹(⋀m::'a::type set. ⟦m ∈ (Q::'a::type set set); (z::'a::type) ∈ m⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto from ‹m ∈ Q› (*‹m ∈ Q›*) show "?thesis" (*goal: ‹∃m::'a::type set∈Q::'a::type set set. ∀n::'a::type set. (n, m) ∈ min_ext (r::('a::type × 'a::type) set) ⟶ n ∉ Q›*) proof (intro rev_bexI (*‹⟦?x ∈ ?A; ?P ?x⟧ ⟹ ∃x∈?A. ?P x›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹m ∈ Q ⟹ ?m1 ∈ Q› 2. ‹⋀n. ⟦m ∈ Q; (n, ?m1) ∈ min_ext r⟧ ⟹ n ∉ Q›*) fix n assume smaller: "(n, m) ∈ min_ext r" (*‹(n::'a set, m::'a set) ∈ min_ext (r::('a × 'a) set)›*) with ‹z ∈ m› (*‹z ∈ m›*) obtain y where "y ∈ n" "(y, z) ∈ r" (*goal: ‹(⋀y::'a. ⟦y ∈ (n::'a set); (y, z::'a) ∈ (r::('a × 'a) set)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: min_ext_def (*‹min_ext ?r = {(X, Y) |X Y. X ≠ {} ∧ (∀y∈Y. ∃x∈X. (x, y) ∈ ?r)}›*)) with z(2) (*‹(?y, z) ∈ r ⟹ ?y ∉ ⋃ Q›*) show "n ∉ Q" by auto qed qed qed subsubsection ‹Bounded increase must terminate› lemma wf_bounded_measure: fixes ub :: "'a ⇒ nat" and f :: "'a ⇒ nat" assumes "⋀a b. (b, a) ∈ r ⟹ ub b ≤ ub a ∧ ub a ≥ f b ∧ f b > f a" shows "wf r" apply (rule wf_subset[OF wf_measure[of "λa. ub a - f a"]] (*‹(?p::('a::type × 'a::type) set) ⊆ measure (λa::'a::type. (ub::'a::type ⇒ nat) a - (f::'a::type ⇒ nat) a) ⟹ wf ?p›*)) (*goal: ‹wf r›*) by (auto dest: assms (*‹(?b, ?a) ∈ r ⟹ ub ?b ≤ ub ?a ∧ f ?b ≤ ub ?a ∧ f ?a < f ?b›*)) lemma wf_bounded_set: fixes ub :: "'a ⇒ 'b set" and f :: "'a ⇒ 'b set" assumes "⋀a b. (b,a) ∈ r ⟹ finite (ub a) ∧ ub b ⊆ ub a ∧ ub a ⊇ f b ∧ f b ⊃ f a" shows "wf r" apply (rule wf_bounded_measure[of r "λa. card (ub a)" "λa. card (f a)"] (*‹(⋀a b. (b, a) ∈ r ⟹ card (ub b) ≤ card (ub a) ∧ card (f b) ≤ card (ub a) ∧ card (f a) < card (f b)) ⟹ wf r›*)) (*goal: ‹wf r›*) apply (drule assms (*‹(?b, ?a) ∈ r ⟹ finite (ub ?a) ∧ ub ?b ⊆ ub ?a ∧ f ?b ⊆ ub ?a ∧ f ?a ⊂ f ?b›*)) (*goal: ‹⋀a b. (b, a) ∈ r ⟹ card (ub b) ≤ card (ub a) ∧ card (f b) ≤ card (ub a) ∧ card (f a) < card (f b)›*) by (blast intro: card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*) dest: psubset_eq[THEN iffD2] (*‹?A1 ⊆ ?B1 ∧ ?A1 ≠ ?B1 ⟹ ?A1 ⊂ ?B1›*)) lemma finite_subset_wf: assumes "finite A" shows "wf {(X, Y). X ⊂ Y ∧ Y ⊆ A}" apply (rule wf_subset[OF wf_finite_psubset[unfolded finite_psubset_def]] (*‹?p ⊆ {(A, B). A ⊂ B ∧ finite B} ⟹ wf ?p›*)) (*goal: ‹wf {(X, Y). X ⊂ Y ∧ Y ⊆ A}›*) by (auto intro: finite_subset[OF _ assms] (*‹?A ⊆ A ⟹ finite ?A›*)) hide_const (open) acc accp subsection ‹Code Generation Setup› text ‹Code equations with \<^const>‹wf› or \<^const>‹wfp› on the left-hand side are not supported by the code generation module because of the \<^const>‹UNIV› hidden behind the abbreviations. To sidestep this problem, we provide the following wrapper definitions and use @{attribute code_abbrev} to register the definitions with the pre- and post-processors of the code generator.› definition wf_code :: "('a × 'a) set ⇒ bool" where [code_abbrev]: "wf_code r ⟷ wf r" definition wfp_code :: "('a ⇒ 'a ⇒ bool) ⇒ bool" where [code_abbrev]: "wfp_code R ⟷ wfp R" end
{ "path": "Isabelle2024/src/HOL/Wellfounded.thy", "repo": "Isabelle2024", "sha": "9489b7d8f3600b30c1df9a85a8d6cf52b70533843e1f74e385b3720572cc9283" }
(* Author: Norbert Schirmer Maintainer: Norbert Schirmer, norbert.schirmer at web de Copyright (C) 2004-2008 Norbert Schirmer Copyright (c) 2022 Apple Inc. All rights reserved. *) section ‹Derived Hoare Rules for Total Correctness› theory HoareTotal imports HoareTotalProps begin lemma conseq_no_aux: "⟦Γ,Θ ⊢⇩t⇘/F⇙ P' c Q',A'; ∀s. s ∈ P ⟶ (s∈P' ∧ (Q' ⊆ Q)∧ (A' ⊆ A))⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A" apply (rule conseq [where P'="λZ. P'" and Q'="λZ. Q'" and A'="λZ. A'"] (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ P' ?c Q',A'; ∀s. s ∈ ?P ⟶ (∃Z. s ∈ P' ∧ Q' ⊆ ?Q ∧ A' ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P' c Q',A'; ∀s. s ∈ P ⟶ s ∈ P' ∧ Q' ⊆ Q ∧ A' ⊆ A⟧ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ P' c Q',A'› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P' c Q',A'; ∀s. s ∈ P ⟶ s ∈ P' ∧ Q' ⊆ Q ∧ A' ⊆ A⟧ ⟹ ∀s. s ∈ P ⟶ (∃Z. s ∈ P' ∧ Q' ⊆ Q ∧ A' ⊆ A)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹If for example a specification for a "procedure pointer" parameter is in the precondition we can extract it with this rule› lemma conseq_exploit_pre: "⟦∀s ∈ P. Γ,Θ ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A" apply (rule Conseq (*‹∀s∈?P. ∃P' Q' A'. ?Γ,?Θ⊢⇩t⇘/?F⇙ P' ?c Q',A' ∧ s ∈ P' ∧ Q' ⊆ ?Q ∧ A' ⊆ ?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹∀s::'a::type∈P::'a::type set. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ({s} ∩ P) (c::('a::type, 'b::type, 'c::type) com) (Q::'a::type set),(A::'a::type set) ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A›*) apply clarify (*goal: ‹∀s∈P. Γ,Θ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q,A ⟹ ∀s∈P. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c Q',A' ∧ s ∈ P' ∧ Q' ⊆ Q ∧ A' ⊆ A›*) apply (rule_tac x="{s} ∩ P" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀s. ⟦∀s∈P. Γ,Θ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q,A; s ∈ P⟧ ⟹ ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c Q',A' ∧ s ∈ P' ∧ Q' ⊆ Q ∧ A' ⊆ A›*) apply (rule_tac x="Q" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀s. ⟦∀s∈P. Γ,Θ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q,A; s ∈ P⟧ ⟹ ∃Q' A'. Γ,Θ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q',A' ∧ s ∈ {s} ∩ P ∧ Q' ⊆ Q ∧ A' ⊆ A›*) apply (rule_tac x="A" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀s. ⟦∀s∈P. Γ,Θ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q,A; s ∈ P⟧ ⟹ ∃A'. Γ,Θ⊢⇩t⇘/F⇙ ({s} ∩ P) c Q,A' ∧ s ∈ {s} ∩ P ∧ Q ⊆ Q ∧ A' ⊆ A›*) by simp lemma conseq:"⟦∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z); ∀s. s ∈ P ⟶ (∃ Z. s∈P' Z ∧ (Q' Z ⊆ Q)∧ (A' Z ⊆ A))⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A" apply (rule Conseq' (*‹∀s. s ∈ ?P ⟶ (∃P' Q' A'. (∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (P' Z) ?c (Q' Z),(A' Z)) ∧ (∃Z. s ∈ P' Z ∧ Q' Z ⊆ ?Q ∧ A' Z ⊆ ?A)) ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z); ∀s. s ∈ P ⟶ (∃Z. s ∈ P' Z ∧ Q' Z ⊆ Q ∧ A' Z ⊆ A)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A›*) by blast lemma Lem:"⟦∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z); P ⊆ {s. ∃ Z. s∈P' Z ∧ (Q' Z ⊆ Q) ∧ (A' Z ⊆ A)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (lem x c) Q,A" apply (unfold lem_def (*‹lem ?x ?c = ?c›*)) (*goal: ‹⟦∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z); P ⊆ {s. ∃Z. s ∈ P' Z ∧ Q' Z ⊆ Q ∧ A' Z ⊆ A}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P lem x c Q,A›*) apply (erule conseq (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c (?Q' Z),(?A' Z); ∀s. s ∈ ?P ⟶ (∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦∀Z::'a::type. (Γ::'b::type ⇒ ('c::type, 'b::type, 'd::type) com option),(Θ::('c::type set × 'b::type × 'c::type set × 'c::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ ((P'::'a::type ⇒ 'c::type set) Z) (c::('c::type, 'b::type, 'd::type) com) ((Q'::'a::type ⇒ 'c::type set) Z),((A'::'a::type ⇒ 'c::type set) Z); (P::'c::type set) ⊆ {s::'c::type. ∃Z::'a::type. s ∈ P' Z ∧ Q' Z ⊆ (Q::'c::type set) ∧ A' Z ⊆ (A::'c::type set)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A›*) by blast lemma LemAnno: assumes conseq: "P ⊆ {s. ∃Z. s∈P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q) ∧ (∀t. t ∈ A' Z ⟶ t ∈ A)}" assumes lem: "∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (lem x c) Q,A" apply (rule Lem [OF lem] (*‹?P ⊆ {s. ∃Z. s ∈ P' Z ∧ Q' Z ⊆ ?Q ∧ A' Z ⊆ ?A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P lem ?x c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P lem x c Q,A›*) using conseq (*‹P ⊆ {s. ∃Z. s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q) ∧ (∀t. t ∈ A' Z ⟶ t ∈ A)}›*) by blast lemma LemAnnoNoAbrupt: assumes conseq: "P ⊆ {s. ∃Z. s∈P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q)}" assumes lem: "∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (lem x c) Q,{}" apply (rule Lem [OF lem] (*‹?P ⊆ {s. ∃Z. s ∈ P' Z ∧ Q' Z ⊆ ?Q ∧ {} ⊆ ?A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P lem ?x c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P lem x c Q,{}›*) using conseq (*‹P ⊆ {s. ∃Z. s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q)}›*) by blast lemma TrivPost: "∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z) ⟹ ∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c UNIV,UNIV" apply (rule allI (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a. ?P x›*)) (*goal: ‹∀Z::'a. (Γ::'b ⇒ ('c, 'b, 'd) com option),(Θ::('c set × 'b × 'c set × 'c set) set)⊢⇩t⇘/(F::'d set)⇙ ((P'::'a ⇒ 'c set) Z) (c::('c, 'b, 'd) com) ((Q'::'a ⇒ 'c set) Z),((A'::'a ⇒ 'c set) Z) ⟹ ∀Z::'a. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c UNIV,UNIV›*) apply (erule conseq (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c (?Q' Z),(?A' Z); ∀s. s ∈ ?P ⟶ (∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀Z. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),(A' Z) ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c UNIV,UNIV›*) by auto lemma TrivPostNoAbr: "∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),{} ⟹ ∀Z. Γ,Θ ⊢⇩t⇘/F⇙ (P' Z) c UNIV,{}" apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀Z::'a. (Γ::'b ⇒ ('c, 'b, 'd) com option),(Θ::('c set × 'b × 'c set × 'c set) set)⊢⇩t⇘/(F::'d set)⇙ ((P'::'a ⇒ 'c set) Z) (c::('c, 'b, 'd) com) ((Q'::'a ⇒ 'c set) Z),{} ⟹ ∀Z::'a. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c UNIV,{}›*) apply (erule conseq (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c (?Q' Z),(?A' Z); ∀s. s ∈ ?P ⟶ (∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀Z. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c (Q' Z),{} ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c UNIV,{}›*) by auto lemma DynComConseq: assumes "P ⊆ {s. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F ⇙P' (c s) Q',A' ∧ P ⊆ P' ∧ Q' ⊆ Q ∧ A' ⊆ A}" shows "Γ,Θ⊢⇩t⇘/F ⇙P DynCom c Q,A" using assms (*‹P ⊆ {s. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c s Q',A' ∧ P ⊆ P' ∧ Q' ⊆ Q ∧ A' ⊆ A}›*) apply - (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P DynCom c Q,A›*) apply (rule hoaret.DynCom (*‹∀s∈?P. ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c s ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*goal: ‹P ⊆ {s. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c s Q',A' ∧ P ⊆ P' ∧ Q' ⊆ Q ∧ A' ⊆ A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P DynCom c Q,A›*) apply clarsimp (*goal: ‹P ⊆ {s. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c s Q',A' ∧ P ⊆ P' ∧ Q' ⊆ Q ∧ A' ⊆ A} ⟹ ∀s∈P. Γ,Θ⊢⇩t⇘/F⇙ P c s Q,A›*) apply (rule hoaret.Conseq (*‹∀s∈?P. ∃P' Q' A'. ?Γ,?Θ⊢⇩t⇘/?F⇙ P' ?c Q',A' ∧ s ∈ P' ∧ Q' ⊆ ?Q ∧ A' ⊆ ?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⋀s. ⟦P ⊆ {s. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c s Q',A' ∧ P ⊆ P' ∧ Q' ⊆ Q ∧ A' ⊆ A}; s ∈ P⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c s Q,A›*) apply clarsimp (*goal: ‹⋀s. ⟦P ⊆ {s. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c s Q',A' ∧ P ⊆ P' ∧ Q' ⊆ Q ∧ A' ⊆ A}; s ∈ P⟧ ⟹ ∀sa∈P. ∃P' Q' A'. Γ,Θ⊢⇩t⇘/F⇙ P' c s Q',A' ∧ sa ∈ P' ∧ Q' ⊆ Q ∧ A' ⊆ A›*) by blast lemma SpecAnno: assumes consequence: "P ⊆ {s. (∃ Z. s∈P' Z ∧ (Q' Z ⊆ Q) ∧ (A' Z ⊆ A))}" assumes spec: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) (c Z) (Q' Z),(A' Z)" assumes bdy_constant: "∀Z. c Z = c undefined" shows "Γ,Θ⊢⇩t⇘/F⇙ P (specAnno P' c Q' A') Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P specAnno P' c Q' A' Q,A›*) from spec (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),(A' Z)›*) bdy_constant (*‹∀Z::'b. (c::'b ⇒ ('a, 'c, 'd) com) Z = c undefined›*) have "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) (c undefined) (Q' Z),(A' Z)" apply - (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c undefined (Q' Z),(A' Z)›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹⟦∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),(A' Z); ∀Z. c Z = c undefined⟧ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c undefined (Q' Z),(A' Z)›*) apply (erule_tac x=Z in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀Z. ⟦∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),(A' Z); ∀Z. c Z = c undefined⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c undefined (Q' Z),(A' Z)›*) apply (erule_tac x=Z in allE (*‹⟦∀x::?'a. (?P::?'a ⇒ bool) x; ?P (?x::?'a) ⟹ ?R::bool⟧ ⟹ ?R›*)) (*goal: ‹⋀Z. ⟦∀Z. c Z = c undefined; Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),(A' Z)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c undefined (Q' Z),(A' Z)›*) by simp with consequence (*‹P ⊆ {s. ∃Z. s ∈ P' Z ∧ Q' Z ⊆ Q ∧ A' Z ⊆ A}›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P specAnno P' c Q' A' Q,A›*) apply (simp add: specAnno_def (*‹specAnno ?P ?c ?Q ?A = ?c undefined›*)) (*goal: ‹(Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ (P::'a::type set) specAnno (P'::'b::type ⇒ 'a::type set) (c::'b::type ⇒ ('a::type, 'c::type, 'd::type) com) (Q'::'b::type ⇒ 'a::type set) (A'::'b::type ⇒ 'a::type set) (Q::'a::type set),(A::'a::type set)›*) apply (erule conseq (*‹⟦∀Z::?'a. (?Γ::?'b ⇒ (?'c, ?'b, ?'d) com option),(?Θ::(?'c set × ?'b × ?'c set × ?'c set) set)⊢⇩t⇘/(?F::?'d set)⇙ ((?P'::?'a ⇒ ?'c set) Z) (?c::(?'c, ?'b, ?'d) com) ((?Q'::?'a ⇒ ?'c set) Z),((?A'::?'a ⇒ ?'c set) Z); ∀s::?'c. s ∈ (?P::?'c set) ⟶ (∃Z::?'a. s ∈ ?P' Z ∧ ?Q' Z ⊆ (?Q::?'c set) ∧ ?A' Z ⊆ (?A::?'c set))⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦P ⊆ {s. ∃Z. s ∈ P' Z ∧ Q' Z ⊆ Q ∧ A' Z ⊆ A}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c undefined (Q' Z),(A' Z)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c undefined Q,A›*) by blast qed lemma SpecAnno': "⟦P ⊆ {s. ∃ Z. s∈P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q) ∧ (∀t. t ∈ A' Z ⟶ t ∈ A)}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) (c Z) (Q' Z),(A' Z); ∀Z. c Z = c undefined ⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (specAnno P' c Q' A') Q,A" apply (simp only: subset_iff [THEN sym] (*‹(∀t. t ∈ ?A1 ⟶ t ∈ ?B1) = (?A1 ⊆ ?B1)›*)) (*goal: ‹⟦(P::'a::type set) ⊆ {s::'a::type. ∃Z::'b::type. s ∈ (P'::'b::type ⇒ 'a::type set) Z ∧ (∀t::'a::type. t ∈ (Q'::'b::type ⇒ 'a::type set) Z ⟶ t ∈ (Q::'a::type set)) ∧ (∀t::'a::type. t ∈ (A'::'b::type ⇒ 'a::type set) Z ⟶ t ∈ (A::'a::type set))}; ∀Z::'b::type. (Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ (P' Z) (c::'b::type ⇒ ('a::type, 'c::type, 'd::type) com) Z (Q' Z),(A' Z); ∀Z::'b::type. c Z = c undefined⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P specAnno P' c Q' A' Q,A›*) apply (erule (1) SpecAnno (*‹⟦?P ⊆ {s. ∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A}; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c Z (?Q' Z),(?A' Z); ∀Z. ?c Z = ?c undefined⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P specAnno ?P' ?c ?Q' ?A' ?Q,?A›*)) (*goal: ‹⟦P ⊆ {s. ∃Z. s ∈ P' Z ∧ Q' Z ⊆ Q ∧ A' Z ⊆ A}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),(A' Z); ∀Z. c Z = c undefined⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P specAnno P' c Q' A' Q,A›*) by assumption lemma SpecAnnoNoAbrupt: "⟦P ⊆ {s. ∃ Z. s∈P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q)}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) (c Z) (Q' Z),{}; ∀Z. c Z = c undefined ⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (specAnno P' c Q' (λs. {})) Q,A" apply (rule SpecAnno' (*‹⟦?P ⊆ {s. ∃Z. s ∈ ?P' Z ∧ (∀t. t ∈ ?Q' Z ⟶ t ∈ ?Q) ∧ (∀t. t ∈ ?A' Z ⟶ t ∈ ?A)}; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c Z (?Q' Z),(?A' Z); ∀Z. ?c Z = ?c undefined⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P specAnno ?P' ?c ?Q' ?A' ?Q,?A›*)) (*goals: 1. ‹⟦P ⊆ {s. ∃Z. s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q)}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),{}; ∀Z. c Z = c undefined⟧ ⟹ P ⊆ {s. ∃Z. s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q) ∧ (∀t. t ∈ {} ⟶ t ∈ A)}› 2. ‹⟦P ⊆ {s. ∃Z. s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q)}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),{}; ∀Z. c Z = c undefined⟧ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),{}› 3. ‹⟦P ⊆ {s. ∃Z. s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ t ∈ Q)}; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) c Z (Q' Z),{}; ∀Z. c Z = c undefined⟧ ⟹ ∀Z. c Z = c undefined› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma Skip: "P ⊆ Q ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Skip Q,A" apply (rule hoaret.Skip [THEN conseqPre] (*‹(?P::?'b set) ⊆ (?P'::?'b set) ⟹ (?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ ?P Skip ?P',(?A::?'b set)›*)) (*goal: ‹P ⊆ Q ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Skip Q,A›*) by simp lemma Basic: "P ⊆ {s. (f s) ∈ Q} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Basic f) Q,A" by (rule hoaret.Basic [THEN conseqPre] (*‹?P ⊆ {s. ?f1 s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f1 ?Q,?A›*)) lemma BasicCond: "⟦P ⊆ {s. (b s ⟶ f s∈Q) ∧ (¬ b s ⟶ g s∈Q)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Basic (λs. if b s then f s else g s) Q,A" apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*goal: ‹P ⊆ {s. (b s ⟶ f s ∈ Q) ∧ (¬ b s ⟶ g s ∈ Q)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Basic (λs. if b s then f s else g s) Q,A›*) by auto lemma Spec: "P ⊆ {s. (∀t. (s,t) ∈ r ⟶ t ∈ Q) ∧ (∃t. (s,t) ∈ r)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Spec r) Q,A" by (rule hoaret.Spec [THEN conseqPre] (*‹?P ⊆ {s. (∀t. (s, t) ∈ ?r1 ⟶ t ∈ ?Q) ∧ (∃t. (s, t) ∈ ?r1)} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Spec ?r1 ?Q,?A›*)) lemma SpecIf: "⟦P ⊆ {s. (b s ⟶ f s ∈ Q) ∧ (¬ b s ⟶ g s ∈ Q ∧ h s ∈ Q)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Spec (if_rel b f g h) Q,A" apply (rule Spec (*‹?P ⊆ {s. (∀t. (s, t) ∈ ?r ⟶ t ∈ ?Q) ∧ (∃t. (s, t) ∈ ?r)} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Spec ?r ?Q,?A›*)) (*goal: ‹P ⊆ {s. (b s ⟶ f s ∈ Q) ∧ (¬ b s ⟶ g s ∈ Q ∧ h s ∈ Q)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Spec (if_rel b f g h) Q,A›*) by (auto simp add: if_rel_def (*‹if_rel (?b::?'s ⇒ bool) (?f::?'s ⇒ ?'s) (?g::?'s ⇒ ?'s) (?h::?'s ⇒ ?'s) = {(s::?'s, t::?'s). if ?b s then t = ?f s else t = ?g s ∨ t = ?h s}›*)) lemma Seq [trans, intro?]: "⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Seq c₁ c₂ Q,A" apply (rule hoaret.Seq (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?R,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c₁ ?R,A› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c₂ Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma SeqSwap: "⟦Γ,Θ⊢⇩t⇘/F⇙ R c2 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c1 R,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Seq c1 c2 Q,A" apply (rule Seq (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?R,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦(Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option),(Θ::('b::type set × 'a::type × 'b::type set × 'b::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (R::'b::type set) (c2::('b::type, 'a::type, 'c::type) com) (Q::'b::type set),(A::'b::type set); Γ,Θ⊢⇩t⇘/F⇙ (P::'b::type set) (c1::('b::type, 'a::type, 'c::type) com) R,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c1 (?R::'b::type set),A› 2. ‹⟦(Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option),(Θ::('b::type set × 'a::type × 'b::type set × 'b::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (R::'b::type set) (c2::('b::type, 'a::type, 'c::type) com) (Q::'b::type set),(A::'b::type set); Γ,Θ⊢⇩t⇘/F⇙ (P::'b::type set) (c1::('b::type, 'a::type, 'c::type) com) R,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R::'b::type set) c2 Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma BSeq: "⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (bseq c₁ c₂) Q,A" apply (unfold bseq_def (*‹bseq = Seq›*)) (*goal: ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P bseq c₁ c₂ Q,A›*) apply (rule Seq (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?R,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c₁ ?R,A› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ R,A; Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c₂ Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma Cond: assumes wp: "P ⊆ {s. (s∈b ⟶ s∈P₁) ∧ (s∉b ⟶ s∈P₂)}" assumes deriv_c1: "Γ,Θ⊢⇩t⇘/F⇙ P₁ c₁ Q,A" assumes deriv_c2: "Γ,Θ⊢⇩t⇘/F⇙ P₂ c₂ Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c₁ c₂) Q,A" proof (rule hoaret.Cond [THEN conseqPre] (*‹⟦(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option),(?Θ::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⊢⇩t⇘/(?F::?'c::type set)⇙ ((?P'::?'b::type set) ∩ (?b1::?'b::type set)) (?c₁1::(?'b::type, ?'a::type, ?'c::type) com) (?Q::?'b::type set),(?A::?'b::type set); ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' ∩ - ?b1) (?c₂1::(?'b::type, ?'a::type, ?'c::type) com) ?Q,?A; (?P::?'b::type set) ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b1 ?c₁1 ?c₂1 ?Q,?A›*)) (*goals: 1. ‹Γ,Θ⊢⇩t⇘/F⇙ (?P' ∩ b) c₁ Q,A› 2. ‹Γ,Θ⊢⇩t⇘/F⇙ (?P' ∩ - b) c₂ Q,A› 3. ‹P ⊆ ?P'›*) from deriv_c1 (*‹Γ,Θ⊢⇩t⇘/F⇙ P₁ c₁ Q,A›*) show "Γ,Θ⊢⇩t⇘/F⇙ ({s. (s ∈ b ⟶ s ∈ P₁) ∧ (s ∉ b ⟶ s ∈ P₂)} ∩ b) c₁ Q,A" apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. (s ∈ b ⟶ s ∈ P₁) ∧ (s ∉ b ⟶ s ∈ P₂)} ∩ b) c₁ Q,A›*) by blast next (*goals: 1. ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. (s ∈ b ⟶ s ∈ P₁) ∧ (s ∉ b ⟶ s ∈ P₂)} ∩ - b) c₂ Q,A› 2. ‹P ⊆ {s. (s ∈ b ⟶ s ∈ P₁) ∧ (s ∉ b ⟶ s ∈ P₂)}›*) from deriv_c2 (*‹Γ,Θ⊢⇩t⇘/F⇙ P₂ c₂ Q,A›*) show "Γ,Θ⊢⇩t⇘/F⇙ ({s. (s ∈ b ⟶ s ∈ P₁) ∧ (s ∉ b ⟶ s ∈ P₂)} ∩ - b) c₂ Q,A" apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. (s ∈ b ⟶ s ∈ P₁) ∧ (s ∉ b ⟶ s ∈ P₂)} ∩ - b) c₂ Q,A›*) by blast qed (insert wp (*‹(P::'a set) ⊆ {s::'a. (s ∈ (b::'a set) ⟶ s ∈ (P₁::'a set)) ∧ (s ∉ b ⟶ s ∈ (P₂::'a set))}›*)) (*solved the remaining goal: ‹(P::'a set) ⊆ {s::'a. (s ∈ (b::'a set) ⟶ s ∈ (P₁::'a set)) ∧ (s ∉ b ⟶ s ∈ (P₂::'a set))}›*) lemma CondSwap: "⟦Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A; P ⊆ {s. (s∈b ⟶ s∈P1) ∧ (s∉b ⟶ s∈P2)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c1 c2) Q,A" apply (rule Cond (*‹⟦?P ⊆ {s. (s ∈ ?b ⟶ s ∈ ?P₁) ∧ (s ∉ ?b ⟶ s ∈ ?P₂)}; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₁ ?c₁ ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₂ ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A; P ⊆ {s. (s ∈ b ⟶ s ∈ P1) ∧ (s ∉ b ⟶ s ∈ P2)}⟧ ⟹ P ⊆ {s. (s ∈ b ⟶ s ∈ ?P₁) ∧ (s ∉ b ⟶ s ∈ ?P₂)}› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A; P ⊆ {s. (s ∈ b ⟶ s ∈ P1) ∧ (s ∉ b ⟶ s ∈ P2)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P₁ c1 Q,A› 3. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A; P ⊆ {s. (s ∈ b ⟶ s ∈ P1) ∧ (s ∉ b ⟶ s ∈ P2)}⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P₂ c2 Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma Cond': "⟦P ⊆ {s. (b ⊆ P1) ∧ (- b ⊆ P2)};Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c1 c2) Q,A" apply (rule CondSwap (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P1.0::?'b set) (?c1.0::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P2.0::?'b set) (?c2.0::(?'b, ?'a, ?'c) com) ?Q,?A; (?P::?'b set) ⊆ {s::?'b. (s ∈ (?b::?'b set) ⟶ s ∈ ?P1.0) ∧ (s ∉ ?b ⟶ s ∈ ?P2.0)}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⟦P ⊆ {s. b ⊆ P1 ∧ - b ⊆ P2}; Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P1.0 c1 Q,A› 2. ‹⟦P ⊆ {s. b ⊆ P1 ∧ - b ⊆ P2}; Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P2.0 c2 Q,A› 3. ‹⟦P ⊆ {s. b ⊆ P1 ∧ - b ⊆ P2}; Γ,Θ⊢⇩t⇘/F⇙ P1 c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ P2 c2 Q,A⟧ ⟹ P ⊆ {s. (s ∈ b ⟶ s ∈ ?P1.0) ∧ (s ∉ b ⟶ s ∈ ?P2.0)}› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*proven 3 subgoals*) . lemma CondInv: assumes wp: "P ⊆ Q" assumes inv: "Q ⊆ {s. (s∈b ⟶ s∈P₁) ∧ (s∉b ⟶ s∈P₂)}" assumes deriv_c1: "Γ,Θ⊢⇩t⇘/F⇙ P₁ c₁ Q,A" assumes deriv_c2: "Γ,Θ⊢⇩t⇘/F⇙ P₂ c₂ Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c₁ c₂) Q,A" proof (-) (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) Cond (b::'a set) (c₁::('a, 'b, 'c) com) (c₂::('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) from wp (*‹P ⊆ Q›*) inv (*‹(Q::'a set) ⊆ {s::'a. (s ∈ (b::'a set) ⟶ s ∈ (P₁::'a set)) ∧ (s ∉ b ⟶ s ∈ (P₂::'a set))}›*) have "P ⊆ {s. (s∈b ⟶ s∈P₁) ∧ (s∉b ⟶ s∈P₂)}" by blast from Cond[OF this deriv_c1 deriv_c2] (*‹Γ,Θ⊢⇩t⇘/F⇙ P Cond b c₁ c₂ Q,A›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P Cond b c₁ c₂ Q,A›*) . qed lemma CondInv': assumes wp: "P ⊆ I" assumes inv: "I ⊆ {s. (s∈b ⟶ s∈P₁) ∧ (s∉b ⟶ s∈P₂)}" assumes wp': "I ⊆ Q" assumes deriv_c1: "Γ,Θ⊢⇩t⇘/F⇙ P₁ c₁ I,A" assumes deriv_c2: "Γ,Θ⊢⇩t⇘/F⇙ P₂ c₂ I,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c₁ c₂) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P Cond b c₁ c₂ Q,A›*) from CondInv[OF wp inv deriv_c1 deriv_c2] (*‹Γ,Θ⊢⇩t⇘/F⇙ P Cond b c₁ c₂ I,A›*) have "Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c₁ c₂) I,A" . from conseqPost[OF this wp' subset_refl] (*‹Γ,Θ⊢⇩t⇘/F⇙ P Cond b c₁ c₂ Q,A›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P Cond b c₁ c₂ Q,A›*) . qed lemma switchNil: "P ⊆ Q ⟹ Γ,Θ⊢⇩t⇘/F ⇙P (switch v []) Q,A" by (simp add: Skip (*‹?P ⊆ ?Q ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Skip ?Q,?A›*)) lemma switchCons: "⟦P ⊆ {s. (v s ∈ V ⟶ s ∈ P₁) ∧ (v s ∉ V ⟶ s ∈ P₂)}; Γ,Θ⊢⇩t⇘/F ⇙P₁ c Q,A; Γ,Θ⊢⇩t⇘/F ⇙P₂ (switch v vs) Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F ⇙P (switch v ((V,c)#vs)) Q,A" by (simp add: Cond (*‹⟦(?P::?'a set) ⊆ {s::?'a. (s ∈ (?b::?'a set) ⟶ s ∈ (?P₁::?'a set)) ∧ (s ∉ ?b ⟶ s ∈ (?P₂::?'a set))}; (?Γ::?'b ⇒ (?'a, ?'b, ?'c) com option),(?Θ::(?'a set × ?'b × ?'a set × ?'a set) set)⊢⇩t⇘/(?F::?'c set)⇙ ?P₁ (?c₁::(?'a, ?'b, ?'c) com) (?Q::?'a set),(?A::?'a set); ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₂ (?c₂::(?'a, ?'b, ?'c) com) ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b ?c₁ ?c₂ ?Q,?A›*)) lemma Guard: "⟦P ⊆ g ∩ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Guard f g c Q,A" apply (rule HoareTotalDef.Guard [THEN conseqPre, of _ _ _ _ R] (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ (?g1 ∩ R) ?c1 ?Q,?A; ?P ⊆ ?g1 ∩ R⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f1 ?g1 ?c1 ?Q,?A›*)) (*goals: 1. ‹⟦(P::'a set) ⊆ (g::'a set) ∩ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (g ∩ R) c Q,A› 2. ‹⟦(P::'a set) ⊆ (g::'a set) ∩ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ P ⊆ g ∩ R› discuss goal 1*) apply (erule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*top goal: ‹⟦P ⊆ g ∩ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (g ∩ R) c Q,A› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma GuardSwap: "⟦ Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ g ∩ R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Guard f g c Q,A" apply (rule Guard (*‹⟦?P ⊆ ?g ∩ ?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ g ∩ R⟧ ⟹ P ⊆ g ∩ ?R› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ g ∩ R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma Guarantee: "⟦P ⊆ {s. s ∈ g ⟶ s ∈ R}; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Guard f g c) Q,A" apply (rule Guarantee [THEN conseqPre, of _ _ _ _ _ "{s. s ∈ g ⟶ s ∈ R}"] (*‹⟦?f1 ∈ ?F; ?Γ,?Θ⊢⇩t⇘/?F⇙ (?g1 ∩ {s. s ∈ g ⟶ s ∈ R}) ?c1 ?Q,?A; ?P ⊆ {s. s ∈ g ⟶ s ∈ R}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f1 ?g1 ?c1 ?Q,?A›*)) (*goals: 1. ‹⟦P ⊆ {s. s ∈ g ⟶ s ∈ R}; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ f ∈ F› 2. ‹⟦P ⊆ {s. s ∈ g ⟶ s ∈ R}; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (g ∩ {s. s ∈ g ⟶ s ∈ R}) c Q,A› 3. ‹⟦P ⊆ {s. s ∈ g ⟶ s ∈ R}; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ P ⊆ {s. s ∈ g ⟶ s ∈ R}› discuss goal 1*) apply assumption (*discuss goal 2*) apply (erule conseqPre (*‹⟦(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option),(?Θ::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⊢⇩t⇘/(?F::?'c::type set)⇙ (?P'::?'b::type set) (?c::(?'b::type, ?'a::type, ?'c::type) com) (?Q::?'b::type set),(?A::?'b::type set); (?P::?'b::type set) ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*top goal: ‹⟦P ⊆ {s. s ∈ g ⟶ s ∈ R}; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (g ∩ {s. s ∈ g ⟶ s ∈ R}) c Q,A› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma GuaranteeSwap: "⟦ Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ {s. s ∈ g ⟶ s ∈ R}; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Guard f g c) Q,A" apply (rule Guarantee (*‹⟦(?P::?'a set) ⊆ {s::?'a. s ∈ (?g::?'a set) ⟶ s ∈ (?R::?'a set)}; (?Γ::?'b ⇒ (?'a, ?'b, ?'c) com option),(?Θ::(?'a set × ?'b × ?'a set × ?'a set) set)⊢⇩t⇘/(?F::?'c set)⇙ ?R (?c::(?'a, ?'b, ?'c) com) (?Q::?'a set),(?A::?'a set); (?f::?'c) ∈ ?F⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ {s. s ∈ g ⟶ s ∈ R}; f ∈ F⟧ ⟹ P ⊆ {s. s ∈ g ⟶ s ∈ ?R}› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ {s. s ∈ g ⟶ s ∈ R}; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c Q,A› 3. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ {s. s ∈ g ⟶ s ∈ R}; f ∈ F⟧ ⟹ f ∈ F› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma GuardStrip: "⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Guard f g c) Q,A" apply (rule Guarantee [THEN conseqPre] (*‹⟦?P' ⊆ {s. s ∈ ?g1 ⟶ s ∈ ?R1}; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R1 ?c1 ?Q,?A; ?f1 ∈ ?F; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f1 ?g1 ?c1 ?Q,?A›*)) (*goals: 1. ‹⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ ?P' ⊆ {s. s ∈ g ⟶ s ∈ ?R1}› 2. ‹⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R1 c Q,A› 3. ‹⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ f ∈ F› 4. ‹⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ P ⊆ ?P'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemma GuardStripSwap: "⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Guard f g c) Q,A" apply (rule GuardStrip (*‹⟦?P ⊆ ?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c ?Q,?A; ?f ∈ ?F⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ P ⊆ ?R› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c Q,A› 3. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ f ∈ F› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma GuaranteeStrip: "⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (guaranteeStrip f g c) Q,A" apply (unfold guaranteeStrip_def (*‹guaranteeStrip (?f::?'f::type) (?g::?'s::type set) (?c::(?'s::type, ?'p::type, ?'f::type) com) = Guard ?f ?g ?c›*)) (*goal: ‹⟦P ⊆ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P guaranteeStrip f g c Q,A›*) apply (rule GuardStrip (*‹⟦(?P::?'a set) ⊆ (?R::?'a set); (?Γ::?'b ⇒ (?'a, ?'b, ?'c) com option),(?Θ::(?'a set × ?'b × ?'a set × ?'a set) set)⊢⇩t⇘/(?F::?'c set)⇙ ?R (?c::(?'a, ?'b, ?'c) com) (?Q::?'a set),(?A::?'a set); (?f::?'c) ∈ ?F⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f (?g::?'a set) ?c ?Q,?A›*)) (*goals: 1. ‹⟦(P::'a set) ⊆ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set); (f::'c) ∈ F⟧ ⟹ P ⊆ (?R::'a set)› 2. ‹⟦(P::'a set) ⊆ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set); (f::'c) ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R::'a set) c Q,A› 3. ‹⟦(P::'a set) ⊆ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set); (f::'c) ∈ F⟧ ⟹ f ∈ F› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma GuaranteeStripSwap: "⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (guaranteeStrip f g c) Q,A" apply (unfold guaranteeStrip_def (*‹guaranteeStrip (?f::?'f) (?g::?'s set) (?c::(?'s, ?'p, ?'f) com) = Guard ?f ?g ?c›*)) (*goal: ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P guaranteeStrip f g c Q,A›*) apply (rule GuardStrip (*‹⟦?P ⊆ ?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c ?Q,?A; ?f ∈ ?F⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ P ⊆ ?R› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c Q,A› 3. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ R; f ∈ F⟧ ⟹ f ∈ F› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma GuaranteeAsGuard: "⟦P ⊆ g ∩ R; Γ,Θ⊢⇩t⇘/F⇙ R c Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P guaranteeStrip f g c Q,A" apply (unfold guaranteeStrip_def (*‹guaranteeStrip ?f ?g ?c = Guard ?f ?g ?c›*)) (*goal: ‹⟦(P::'a set) ⊆ (g::'a set) ∩ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P guaranteeStrip (f::'c) g c Q,A›*) apply (rule Guard (*‹⟦?P ⊆ ?g ∩ ?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦(P::'a set) ⊆ (g::'a set) ∩ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ P ⊆ g ∩ (?R::'a set)› 2. ‹⟦(P::'a set) ⊆ (g::'a set) ∩ (R::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ R (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R::'a set) c Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma GuaranteeAsGuardSwap: "⟦ Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ g ∩ R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P guaranteeStrip f g c Q,A" apply (rule GuaranteeAsGuard (*‹⟦?P ⊆ ?g ∩ ?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P guaranteeStrip ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ g ∩ R⟧ ⟹ P ⊆ g ∩ ?R› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c Q,A; P ⊆ g ∩ R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma GuardsNil: "Γ,Θ⊢⇩t⇘/F⇙ P c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (guards [] c) Q,A" by simp lemma GuardsCons: "Γ,Θ⊢⇩t⇘/F⇙ P Guard f g (guards gs c) Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (guards ((f,g)#gs) c) Q,A" sorry lemma GuardsConsGuaranteeStrip: "Γ,Θ⊢⇩t⇘/F⇙ P guaranteeStrip f g (guards gs c) Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (guards (guaranteeStripPair f g#gs) c) Q,A" by (simp add: guaranteeStripPair_def (*‹guaranteeStripPair (?f::?'f) (?g::?'s set) = (?f, ?g)›*) guaranteeStrip_def (*‹guaranteeStrip (?f::?'f) (?g::?'s set) (?c::(?'s, ?'p, ?'f) com) = Guard ?f ?g ?c›*)) lemma While: assumes P_I: "P ⊆ I" assumes deriv_body: "∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A" assumes I_Q: "I ∩ -b ⊆ Q" assumes wf: "wf V" shows "Γ,Θ⊢⇩t⇘/F⇙ P (whileAnno b I V c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnno b I V c Q,A›*) from wf (*‹wf V›*) deriv_body (*‹∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A›*) P_I (*‹P ⊆ I›*) I_Q (*‹I ∩ - b ⊆ Q›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnno b I V c Q,A›*) apply (unfold whileAnno_def (*‹whileAnno (?b::?'s set) (?I::?'s set) (?V::(?'s × ?'s) set) (?c::(?'s, ?'p, ?'f) com) = While ?b ?c›*)) (*goal: ‹(Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (P::'a::type set) whileAnno (b::'a::type set) (I::'a::type set) (V::('a::type × 'a::type) set) (c::('a::type, 'b::type, 'c::type) com) (Q::'a::type set),(A::'a::type set)›*) apply (erule conseqPrePost [OF HoareTotalDef.While] (*‹⟦wf ?r1; ∀σ. ?Γ,?Θ⊢⇩t⇘/?F⇙ ({σ} ∩ ?P' ∩ ?b1) ?c1 ({t. (t, σ) ∈ ?r1} ∩ ?P'),?A'; ?P ⊆ ?P'; ?P' ∩ - ?b1 ⊆ ?Q; ?A' ⊆ ?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P While ?b1 ?c1 ?Q,?A›*)) (*goals: 1. ‹⟦∀σ::'a::type. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ({σ} ∩ (I::'a::type set) ∩ (b::'a::type set)) (c::('a::type, 'b::type, 'c::type) com) ({t::'a::type. (t, σ) ∈ (V::('a::type × 'a::type) set)} ∩ I),(A::'a::type set); (P::'a::type set) ⊆ I; I ∩ - b ⊆ (Q::'a::type set)⟧ ⟹ ∀σ::'a::type. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ (?P'4::'a::type set) ∩ b) c ({t::'a::type. (t, σ) ∈ V} ∩ ?P'4),(?A'4::'a::type set)› 2. ‹⟦∀σ::'a::type. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ({σ} ∩ (I::'a::type set) ∩ (b::'a::type set)) (c::('a::type, 'b::type, 'c::type) com) ({t::'a::type. (t, σ) ∈ (V::('a::type × 'a::type) set)} ∩ I),(A::'a::type set); (P::'a::type set) ⊆ I; I ∩ - b ⊆ (Q::'a::type set)⟧ ⟹ P ⊆ (?P'4::'a::type set)› 3. ‹⟦∀σ::'a::type. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ({σ} ∩ (I::'a::type set) ∩ (b::'a::type set)) (c::('a::type, 'b::type, 'c::type) com) ({t::'a::type. (t, σ) ∈ (V::('a::type × 'a::type) set)} ∩ I),(A::'a::type set); (P::'a::type set) ⊆ I; I ∩ - b ⊆ (Q::'a::type set)⟧ ⟹ (?P'4::'a::type set) ∩ - b ⊆ Q› 4. ‹⟦∀σ::'a::type. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ({σ} ∩ (I::'a::type set) ∩ (b::'a::type set)) (c::('a::type, 'b::type, 'c::type) com) ({t::'a::type. (t, σ) ∈ (V::('a::type × 'a::type) set)} ∩ I),(A::'a::type set); (P::'a::type set) ⊆ I; I ∩ - b ⊆ (Q::'a::type set)⟧ ⟹ (?A'4::'a::type set) ⊆ A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed lemma WhileInvPost: assumes P_I: "P ⊆ I" assumes termi_body: "∀σ. Γ,Θ⊢⇩t⇘/UNIV⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ P),A" assumes deriv_body: "Γ,Θ⊢⇘/F⇙ (I ∩ b) c I,A" assumes I_Q: "I ∩ -b ⊆ Q" assumes wf: "wf V" shows "Γ,Θ⊢⇩t⇘/F⇙ P (whileAnno b I V c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnno b I V c Q,A›*) have "∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A" proof (standard) (*goal: ‹⋀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A›*) fix σ from hoare_sound[OF deriv_body] (*‹Γ,Θ⊨⇘/F⇙ (I ∩ b) c I,A›*) hoaret_sound[OF termi_body [ rule_format , of σ ]] (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊨⇩t⇘/UNIV⇙ ({σ::'a} ∩ (I::'a set) ∩ (b::'a set)) (c::('a, 'b, 'c) com) ({t::'a. (t, σ) ∈ (V::('a × 'a) set)} ∩ (P::'a set)),(A::'a set)›*) have "Γ,Θ⊨⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A" by (fastforce simp add: cvalidt_def (*‹?Γ,?Θ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇩t⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A›*) validt_def (*‹?Γ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ≡ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ∧ (∀s∈Normal ` ?P. ?Γ⊢?c ↓ s)›*) cvalid_def (*‹?Γ,?Θ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ (∀(P, p, Q, A)∈?Θ. ?Γ⊨⇘/?F⇙ P Call p Q,A) ⟶ ?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A›*) valid_def (*‹?Γ⊨⇘/?F⇙ ?P ?c ?Q,?A ≡ ∀s t. ?Γ⊢ ⟨?c,s⟩ ⇒ t ⟶ s ∈ Normal ` ?P ⟶ t ∉ Fault ` ?F ⟶ t ∈ Normal ` ?Q ∪ Abrupt ` ?A›*)) then show "Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A" by (rule hoaret_complete' (*‹?Γ,?Θ⊨⇩t⇘/?F⇙ ?P ?c ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) qed from While[OF P_I this I_Q wf] (*‹(Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (P::'a::type set) whileAnno (b::'a::type set) (I::'a::type set) (V::('a::type × 'a::type) set) (c::('a::type, 'b::type, 'c::type) com) (Q::'a::type set),(A::'a::type set)›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnno b I V c Q,A›*) . qed (* *) lemma "Γ,Θ⊢⇘/F⇙ (P ∩ b) c Q,A ⟹ Γ,Θ⊢⇘/F⇙ (P ∩ b) (Seq c (Guard f Q Skip)) Q,A" oops text ‹@{term "J"} will be instantiated by tactic with @{term "gs' ∩ I"} for those guards that are not stripped.› lemma WhileAnnoG: "Γ,Θ⊢⇩t⇘/F⇙ P (guards gs (whileAnno b J V (Seq c (guards gs Skip)))) Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoG gs b I V c) Q,A" by (simp add: whileAnnoG_def (*‹whileAnnoG ?gs ?b ?I ?V ?c = while ?gs ?b ?c›*) whileAnno_def (*‹whileAnno ?b ?I ?V ?c = While ?b ?c›*) while_def (*‹while ?gs ?b ?c = guards ?gs (While ?b (Seq ?c (guards ?gs Skip)))›*)) text ‹This form stems from @{term "strip_guards F (whileAnnoG gs b I V c)"}› lemma WhileNoGuard': assumes P_I: "P ⊆ I" assumes deriv_body: "∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ∩ b) c ({t. (t, σ) ∈ V} ∩ I),A" assumes I_Q: "I ∩ -b ⊆ Q" assumes wf: "wf V" shows "Γ,Θ⊢⇩t⇘/F⇙ P (whileAnno b I V (Seq c Skip)) Q,A" sorry lemma WhileAnnoFix: assumes consequence: "P ⊆ {s. (∃ Z. s∈I Z ∧ (I Z ∩ -b ⊆ Q)) }" assumes bdy: "∀Z σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) (c Z) ({t. (t, σ) ∈ V Z} ∩ I Z),A" assumes bdy_constant: "∀Z. c Z = c undefined" assumes wf: "∀Z. wf (V Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoFix b I V c) Q,A" proof (-) (*goal: ‹(Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ (P::'a::type set) whileAnnoFix (b::'a::type set) (I::'b::type ⇒ 'a::type set) (V::'b::type ⇒ ('a::type × 'a::type) set) (c::'b::type ⇒ ('a::type, 'c::type, 'd::type) com) (Q::'a::type set),(A::'a::type set)›*) from bdy (*‹∀Z σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c Z ({t. (t, σ) ∈ V Z} ∩ I Z),A›*) bdy_constant (*‹∀Z. c Z = c undefined›*) have bdy': "⋀Z. ∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) (c undefined) ({t. (t, σ) ∈ V Z} ∩ I Z),A" apply - (*goal: ‹⋀Z. ∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c undefined ({t. (t, σ) ∈ V Z} ∩ I Z),A›*) apply (erule_tac x=Z in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀Z. ⟦∀Z σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c Z ({t. (t, σ) ∈ V Z} ∩ I Z),A; ∀Z. c Z = c undefined⟧ ⟹ ∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c undefined ({t. (t, σ) ∈ V Z} ∩ I Z),A›*) apply (erule_tac x=Z in allE (*‹⟦∀x. ?P x; ?P ?x ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀Z. ⟦∀Z. c Z = c undefined; ∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c Z ({t. (t, σ) ∈ V Z} ∩ I Z),A⟧ ⟹ ∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c undefined ({t. (t, σ) ∈ V Z} ∩ I Z),A›*) by simp have "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (I Z) (whileAnnoFix b I V c) (I Z ∩ -b),A" apply rule (*goal: ‹∀Z::'b::type. (Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ ((I::'b::type ⇒ 'a::type set) Z) whileAnnoFix (b::'a::type set) I (V::'b::type ⇒ ('a::type × 'a::type) set) (c::'b::type ⇒ ('a::type, 'c::type, 'd::type) com) (I Z ∩ - b),(A::'a::type set)›*) apply (unfold whileAnnoFix_def (*‹whileAnnoFix ?b ?I ?V ?c = While ?b (?c undefined)›*)) (*goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ (I Z) whileAnnoFix b I V c (I Z ∩ - b),A›*) apply (rule hoaret.While (*‹⟦wf ?r; ∀σ. ?Γ,?Θ⊢⇩t⇘/?F⇙ ({σ} ∩ ?P ∩ ?b) ?c ({t. (t, σ) ∈ ?r} ∩ ?P),?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P While ?b ?c (?P ∩ - ?b),?A›*)) (*goals: 1. ‹⋀Z. wf (?r2 Z)› 2. ‹⋀Z. ∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) c undefined ({t. (t, σ) ∈ ?r2 Z} ∩ I Z),A› discuss goal 1*) apply (rule wf [rule_format] (*‹wf (V ?Z)›*)) (*discuss goal 2*) apply (rule bdy' (*‹∀σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I ?Z ∩ b) c undefined ({t. (t, σ) ∈ V ?Z} ∩ I ?Z),A›*)) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnnoFix b I V c Q,A›*) apply (rule conseq (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c (?Q' Z),(?A' Z); ∀s. s ∈ ?P ⟶ (∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnnoFix b I V c Q,A›*) using consequence (*‹P ⊆ {s. ∃Z. s ∈ I Z ∧ I Z ∩ - b ⊆ Q}›*) by blast qed lemma WhileAnnoFix': assumes consequence: "P ⊆ {s. (∃ Z. s∈I Z ∧ (∀t. t ∈ I Z ∩ -b ⟶ t ∈ Q)) }" assumes bdy: "∀Z σ. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ I Z ∩ b) (c Z) ({t. (t, σ) ∈ V Z} ∩ I Z),A" assumes bdy_constant: "∀Z. c Z = c undefined" assumes wf: "∀Z. wf (V Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoFix b I V c) Q,A" apply (rule WhileAnnoFix [OF _ bdy bdy_constant wf] (*‹(?P::'a set) ⊆ {s::'a. ∃Z::'b. s ∈ (I::'b ⇒ 'a set) Z ∧ I Z ∩ - (b::'a set) ⊆ (?Q::'a set)} ⟹ (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ ?P whileAnnoFix b I (V::'b ⇒ ('a × 'a) set) (c::'b ⇒ ('a, 'c, 'd) com) ?Q,(A::'a set)›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P whileAnnoFix b I V c Q,A›*) using consequence (*‹P ⊆ {s. ∃Z. s ∈ I Z ∧ (∀t. t ∈ I Z ∩ - b ⟶ t ∈ Q)}›*) by blast lemma WhileAnnoGFix: assumes whileAnnoFix: "Γ,Θ⊢⇩t⇘/F⇙ P (guards gs (whileAnnoFix b J V (λZ. (Seq (c Z) (guards gs Skip))))) Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoGFix gs b I V c) Q,A" using whileAnnoFix (*‹(Γ::'a::type ⇒ ('b::type, 'a::type, 'c::type) com option),(Θ::('b::type set × 'a::type × 'b::type set × 'b::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (P::'b::type set) guards (gs::('c::type × 'b::type set) list) (whileAnnoFix (b::'b::type set) (J::'d::type ⇒ 'b::type set) (V::'d::type ⇒ ('b::type × 'b::type) set) (λZ::'d::type. Seq ((c::'d::type ⇒ ('b::type, 'a::type, 'c::type) com) Z) (guards gs Skip))) (Q::'b::type set),(A::'b::type set)›*) by (simp add: whileAnnoGFix_def (*‹whileAnnoGFix ?gs ?b ?I ?V ?c = while ?gs ?b (?c undefined)›*) whileAnnoFix_def (*‹whileAnnoFix ?b ?I ?V ?c = While ?b (?c undefined)›*) while_def (*‹while ?gs ?b ?c = guards ?gs (While ?b (Seq ?c (guards ?gs Skip)))›*)) lemma Bind: assumes adapt: "P ⊆ {s. s ∈ P' s}" assumes c: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) (c (e s)) Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (bind e c) Q,A" apply (rule conseq [where P'="λZ. {s. s=Z ∧ s ∈ P' Z}" and Q'="λZ. Q" and A'="λZ. A"] (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ {s. s = Z ∧ s ∈ P' Z} ?c Q,A; ∀s. s ∈ ?P ⟶ (∃Z. s ∈ {s. s = Z ∧ s ∈ P' Z} ∧ Q ⊆ ?Q ∧ A ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) bind (e::'a ⇒ 'd) (c::'d ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) apply (rule allI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ bool) x) ⟹ ∀x::?'a::type. ?P x›*)) (*top goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P' Z} bind e c Q,A› and 1 goal remains*) apply (unfold bind_def (*‹bind (?e::?'s ⇒ ?'v) (?c::?'v ⇒ (?'s, ?'p, ?'f) com) = DynCom (λs::?'s. ?c (?e s))›*)) (*top goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P' Z} bind e c Q,A› and 1 goal remains*) apply (rule HoareTotalDef.DynCom (*‹∀s::?'s∈?P::?'s set. (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option),(?Θ::(?'s set × ?'p × ?'s set × ?'s set) set)⊢⇩t⇘/(?F::?'f set)⇙ ?P (?c::?'s ⇒ (?'s, ?'p, ?'f) com) s (?Q::?'s set),(?A::?'s set) ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*top goal: ‹⋀Z::'a::type. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ {s::'a::type. s = Z ∧ s ∈ (P'::'a::type ⇒ 'a::type set) Z} DynCom (λs::'a::type. (c::'d::type ⇒ ('a::type, 'b::type, 'c::type) com) ((e::'a::type ⇒ 'd::type) s)) (Q::'a::type set),(A::'a::type set)› and 1 goal remains*) apply (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*top goal: ‹⋀Z. ∀s∈{s. s = Z ∧ s ∈ P' Z}. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P' Z} c (e s) Q,A› and 1 goal remains*) apply clarsimp (*top goal: ‹⋀(Z::'a) s::'a. s ∈ {s::'a. s = Z ∧ s ∈ (P'::'a ⇒ 'a set) Z} ⟹ (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ {s::'a. s = Z ∧ s ∈ P' Z} (c::'d ⇒ ('a, 'b, 'c) com) ((e::'a ⇒ 'd) s) (Q::'a set),(A::'a set)› and 1 goal remains*) apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*top goal: ‹⋀Z. Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P' Z} c (e Z) Q,A› and 1 goal remains*) apply (rule c [rule_format] (*‹Γ,Θ⊢⇩t⇘/F⇙ (P' ?s) c (e ?s) Q,A›*)) (*top goal: ‹⋀Z. Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?P'11 Z) c (e Z) Q,A› and 2 goals remain*) apply blast (*top goal: ‹⋀Z. Z ∈ P' Z ⟹ {s. s = Z ∧ s ∈ P' Z} ⊆ P' Z› and 1 goal remains*) using adapt (*‹(P::'a set) ⊆ {s::'a. s ∈ (P'::'a ⇒ 'a set) s}›*) by blast lemma Block_exn: assumes adapt: "P ⊆ {s. init s ∈ P' s}" assumes bdy: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (block_exn init bdy return result_exn c) Q,A" apply (rule conseq [where P'="λZ. {s. s=Z ∧ init s ∈ P' Z}" and Q'="λZ. Q" and A'="λZ. A"] (*‹⟦∀Z::'a. (?Γ::?'b ⇒ ('a, ?'b, ?'d) com option),(?Θ::('a set × ?'b × 'a set × 'a set) set)⊢⇩t⇘/(?F::?'d set)⇙ {s::'a. s = Z ∧ (init::'a ⇒ 'a) s ∈ (P'::'a ⇒ 'a set) Z} (?c::('a, ?'b, ?'d) com) (Q::'a set),(A::'a set); ∀s::'a. s ∈ (?P::'a set) ⟶ (∃Z::'a. s ∈ {s::'a. s = Z ∧ init s ∈ P' Z} ∧ Q ⊆ (?Q::'a set) ∧ A ⊆ (?A::'a set))⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) block_exn (init::'a ⇒ 'a) (bdy::('a, 'b, 'c) com) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) prefer 2 (*top goal: ‹∀s::'a::type. s ∈ (P::'a::type set) ⟶ (∃Z::'a::type. s ∈ {s::'a::type. s = Z ∧ (init::'a::type ⇒ 'a::type) s ∈ (P'::'a::type ⇒ 'a::type set) Z} ∧ (Q::'a::type set) ⊆ Q ∧ (A::'a::type set) ⊆ A)› and 1 goal remains*) using adapt (*‹P ⊆ {s. init s ∈ P' s}›*) (*goals: 1. ‹∀s::'a. s ∈ (P::'a set) ⟶ (∃Z::'a. s ∈ {s::'a. s = Z ∧ (init::'a ⇒ 'a) s ∈ (P'::'a ⇒ 'a set) Z} ∧ (Q::'a set) ⊆ Q ∧ (A::'a set) ⊆ A)› 2. ‹∀Z::'a. (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ {s::'a. s = Z ∧ (init::'a ⇒ 'a) s ∈ (P'::'a ⇒ 'a set) Z} block_exn init (bdy::('a, 'b, 'c) com) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)› discuss goal 1*) apply blast (*discuss goal 2*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} block_exn init bdy return result_exn c Q,A›*) apply (unfold block_exn_def (*‹block_exn ?init ?bdy ?return ?result_exn ?c = DynCom (λs. Seq (Catch (Seq (Basic ?init) ?bdy) (Seq (Basic (λt. ?result_exn (?return s t) t)) Throw)) (DynCom (λt. Seq (Basic (?return s)) (?c s t))))›*)) (*goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} block_exn init bdy return result_exn c Q,A›*) apply (rule HoareTotalDef.DynCom (*‹∀s∈?P. ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c s ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} DynCom (λs. Seq (Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return s t) t)) Throw)) (DynCom (λt. Seq (Basic (return s)) (c s t)))) Q,A›*) apply (rule ballI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a∈?A. ?P x›*)) (*goal: ‹⋀Z::'a. ∀s::'a∈{s::'a. s = Z ∧ (init::'a ⇒ 'a) s ∈ (P'::'a ⇒ 'a set) Z}. (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ {s::'a. s = Z ∧ init s ∈ P' Z} Seq (Catch (Seq (Basic init) (bdy::('a, 'b, 'c) com)) (Seq (Basic (λt::'a. (result_exn::'a ⇒ 'a ⇒ 'a) ((return::'a ⇒ 'a ⇒ 'a) s t) t)) Throw)) (DynCom (λt::'a. Seq (Basic (return s)) ((c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) s t))) (Q::'a set),(A::'a set)›*) apply clarsimp (*goal: ‹⋀Z s. s ∈ {s. s = Z ∧ init s ∈ P' Z} ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} Seq (Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return s t) t)) Throw)) (DynCom (λt. Seq (Basic (return s)) (c s t))) Q,A›*) apply (rule_tac R="{t. return Z t ∈ R Z t}" in SeqSwap (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c2.0 ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c1.0 ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› 2. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return Z t) t)) Throw) {t. return Z t ∈ R Z t},A› discuss goal 1*) apply (rule_tac P'="λZ'. {t. t=Z' ∧ return Z t ∈ R Z t}" and Q'="λZ'. Q" and A'="λZ'. A" in conseq (*‹⟦∀Z::?'a::type. (?Γ::?'b::type ⇒ (?'c::type, ?'b::type, ?'d::type) com option),(?Θ::(?'c::type set × ?'b::type × ?'c::type set × ?'c::type set) set)⊢⇩t⇘/(?F::?'d::type set)⇙ ((?P'::?'a::type ⇒ ?'c::type set) Z) (?c::(?'c::type, ?'b::type, ?'d::type) com) ((?Q'::?'a::type ⇒ ?'c::type set) Z),((?A'::?'a::type ⇒ ?'c::type set) Z); ∀s::?'c::type. s ∈ (?P::?'c::type set) ⟶ (∃Z::?'a::type. s ∈ ?P' Z ∧ ?Q' Z ⊆ (?Q::?'c::type set) ∧ ?A' Z ⊆ (?A::?'c::type set))⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹⋀Z. init Z ∈ P' Z ⟹ ∀Za. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› 2. ‹⋀Z. init Z ∈ P' Z ⟹ ∀s. s ∈ {t. return Z t ∈ R Z t} ⟶ (∃Za. s ∈ {t. t = Za ∧ return Z t ∈ R Z t} ∧ Q ⊆ Q ∧ A ⊆ A)› discuss goal 1*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*top goal: ‹⋀Z. init Z ∈ P' Z ⟹ ∀Za. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› and 2 goals remain*) apply (rule HoareTotalDef.DynCom (*‹∀s∈?P. ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c s ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*top goal: ‹⋀Z Za. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› and 2 goals remain*) apply clarsimp (*top goal: ‹⋀Z Za. init Z ∈ P' Z ⟹ ∀s∈{t. t = Za ∧ return Z t ∈ R Z t}. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} Seq (Basic (return Z)) (c Z s) Q,A› and 2 goals remain*) apply (rule SeqSwap (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c2.0 ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c1.0 ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z Za. ⟦init Z ∈ P' Z; return Z Za ∈ R Z Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R38 Z Za) c Z Za Q,A› 2. ‹⋀Z Za. ⟦init Z ∈ P' Z; return Z Za ∈ R Z Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} Basic (return Z) (?R38 Z Za),A› discuss goal 1*) apply (rule c [rule_format] (*‹Γ,Θ⊢⇩t⇘/F⇙ (R ?s ?t) c ?s ?t Q,A›*)) (*discuss goal 2*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀Z Za. ⟦init Z ∈ P' Z; return Z Za ∈ R Z Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} Basic (return Z) (R Z Za),A› and 2 goals remain*) apply clarsimp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (rule_tac R="{t. result_exn (return Z t) t ∈ A}" in HoareTotalDef.Catch (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?Q,?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Catch ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} Seq (Basic init) bdy {t. return Z t ∈ R Z t},{t. result_exn (return Z t) t ∈ A}› 2. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. result_exn (return Z t) t ∈ A} Seq (Basic (λt. result_exn (return Z t) t)) Throw {t. return Z t ∈ R Z t},A› discuss goal 1*) apply (rule_tac R="{i. i ∈ P' Z}" in Seq (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?R,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} Basic init {i. i ∈ P' Z},{t. result_exn (return Z t) t ∈ A}› 2. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {i. i ∈ P' Z} bdy {t. return Z t ∈ R Z t},{t. result_exn (return Z t) t ∈ A}› discuss goal 1*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ init s ∈ P' Z} Basic init {i. i ∈ P' Z},{t. result_exn (return Z t) t ∈ A}› and 2 goals remain*) apply clarsimp (*discuss goal 2*) apply simp (*top goal: ‹⋀Z::'a::type. (init::'a::type ⇒ 'a::type) Z ∈ (P'::'a::type ⇒ 'a::type set) Z ⟹ (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ {i::'a::type. i ∈ P' Z} (bdy::('a::type, 'b::type, 'c::type) com) {t::'a::type. (return::'a::type ⇒ 'a::type ⇒ 'a::type) Z t ∈ (R::'a::type ⇒ 'a::type ⇒ 'a::type set) Z t},{t::'a::type. (result_exn::'a::type ⇒ 'a::type ⇒ 'a::type) (return Z t) t ∈ (A::'a::type set)}› and 1 goal remains*) apply (rule bdy [rule_format] (*‹Γ,Θ⊢⇩t⇘/F⇙ (P' ?s) bdy {t. return ?s t ∈ R ?s t},{t. result_exn (return ?s t) t ∈ A}›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule SeqSwap (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?R::?'b set) (?c2.0::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P::?'b set) (?c1.0::(?'b, ?'a, ?'c) com) ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R62 Z) Throw {t. return Z t ∈ R Z t},A› 2. ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. result_exn (return Z t) t ∈ A} Basic (λt. result_exn (return Z t) t) (?R62 Z),A› discuss goal 1*) apply (rule Throw (*‹?Γ,?Θ⊢⇩t⇘/?F⇙ ?A Throw ?Q,?A›*)) (*discuss goal 2*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*goal: ‹⋀Z. init Z ∈ P' Z ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. result_exn (return Z t) t ∈ A} Basic (λt. result_exn (return Z t) t) A,A›*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma Block: assumes adapt: "P ⊆ {s. init s ∈ P' s}" assumes bdy: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. return s t ∈ A}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ P (block init bdy return c) Q,A" using adapt (*‹(P::'a::type set) ⊆ {s::'a::type. (init::'a::type ⇒ 'a::type) s ∈ (P'::'a::type ⇒ 'a::type set) s}›*) bdy (*‹∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. return s t ∈ A}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) unfolding block_def (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P block_exn init bdy return (λs t. s) c Q,A›*) by (rule Block_exn (*‹⟦?P ⊆ {s. ?init s ∈ ?P' s}; ∀s. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' s) ?bdy {t. ?return s t ∈ ?R s t},{t. ?result_exn (?return s t) t ∈ ?A}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P block_exn ?init ?bdy ?return ?result_exn ?c ?Q,?A›*)) lemma BlockSwap: assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes bdy: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. return s t ∈ A}" assumes adapt: "P ⊆ {s. init s ∈ P' s}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (block init bdy return c) Q,A" using adapt (*‹(P::'a::type set) ⊆ {s::'a::type. (init::'a::type ⇒ 'a::type) s ∈ (P'::'a::type ⇒ 'a::type set) s}›*) bdy (*‹∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. return s t ∈ A}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) by (rule Block (*‹⟦?P ⊆ {s. ?init s ∈ ?P' s}; ∀s. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' s) ?bdy {t. ?return s t ∈ ?R s t},{t. ?return s t ∈ ?A}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P block ?init ?bdy ?return ?c ?Q,?A›*)) lemma Block_exnSwap: assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes bdy: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}" assumes adapt: "P ⊆ {s. init s ∈ P' s}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (block_exn init bdy return result_exn c) Q,A" using adapt (*‹P ⊆ {s. init s ∈ P' s}›*) bdy (*‹∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) bdy {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) by (rule Block_exn (*‹⟦?P ⊆ {s. ?init s ∈ ?P' s}; ∀s. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' s) ?bdy {t. ?return s t ∈ ?R s t},{t. ?result_exn (?return s t) t ∈ ?A}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P block_exn ?init ?bdy ?return ?result_exn ?c ?Q,?A›*)) lemma Block_exnSpec: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes bdy: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) bdy (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (block_exn init bdy return result_exn c) Q,A" apply (rule conseq [where P'="λZ. {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}" and Q'="λZ. Q" and A'="λZ. A"] (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} ?c Q,A; ∀s. s ∈ ?P ⟶ (∃Z. s ∈ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} ∧ Q ⊆ ?Q ∧ A ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P block_exn init bdy return result_exn c Q,A›*) prefer 2 (*top goal: ‹∀s. s ∈ P ⟶ (∃Z. s ∈ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} ∧ Q ⊆ Q ∧ A ⊆ A)› and 1 goal remains*) using adapt (*‹(P::'a set) ⊆ {s::'a. ∃Z::'b. (init::'a ⇒ 'a) s ∈ (P'::'b ⇒ 'a set) Z ∧ (∀t::'a. t ∈ (Q'::'b ⇒ 'a set) Z ⟶ (return::'a ⇒ 'a ⇒ 'a) s t ∈ (R::'a ⇒ 'a ⇒ 'a set) s t) ∧ (∀t::'a. t ∈ (A'::'b ⇒ 'a set) Z ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return s t) t ∈ (A::'a set))}›*) (*goals: 1. ‹∀s. s ∈ P ⟶ (∃Z. s ∈ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} ∧ Q ⊆ Q ∧ A ⊆ A)› 2. ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} block_exn init bdy return result_exn c Q,A› discuss goal 1*) apply blast (*discuss goal 2*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} block_exn init bdy return result_exn c Q,A›*) apply (unfold block_exn_def (*‹block_exn ?init ?bdy ?return ?result_exn ?c = DynCom (λs. Seq (Catch (Seq (Basic ?init) ?bdy) (Seq (Basic (λt. ?result_exn (?return s t) t)) Throw)) (DynCom (λt. Seq (Basic (?return s)) (?c s t))))›*)) (*goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} block_exn init bdy return result_exn c Q,A›*) apply (rule HoareTotalDef.DynCom (*‹∀s∈?P. ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c s ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} DynCom (λs. Seq (Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return s t) t)) Throw)) (DynCom (λt. Seq (Basic (return s)) (c s t)))) Q,A›*) apply (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀Z. ∀s∈{s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}. Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} Seq (Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return s t) t)) Throw)) (DynCom (λt. Seq (Basic (return s)) (c s t))) Q,A›*) apply clarsimp (*goal: ‹⋀Z s. s ∈ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} Seq (Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return s t) t)) Throw)) (DynCom (λt. Seq (Basic (return s)) (c s t))) Q,A›*) apply (rule_tac R="{t. return s t ∈ R s t}" in SeqSwap (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c2.0 ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c1.0 ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. return s t ∈ R s t} DynCom (λt. Seq (Basic (return s)) (c s t)) Q,A› 2. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} Catch (Seq (Basic init) bdy) (Seq (Basic (λt. result_exn (return s t) t)) Throw) {t. return s t ∈ R s t},A› discuss goal 1*) apply (rule_tac P'="λZ'. {t. t=Z' ∧ return s t ∈ R s t}" and Q'="λZ'. Q" and A'="λZ'. A" in conseq (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c (?Q' Z),(?A' Z); ∀s. s ∈ ?P ⟶ (∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Z ∧ return s t ∈ R s t} DynCom (λt. Seq (Basic (return s)) (c s t)) Q,A› 2. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ ∀sa. sa ∈ {t. return s t ∈ R s t} ⟶ (∃Z. sa ∈ {t. t = Z ∧ return s t ∈ R s t} ∧ Q ⊆ Q ∧ A ⊆ A)› discuss goal 1*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*top goal: ‹⋀(Z::'b) s::'a. ⟦(init::'a ⇒ 'a) s ∈ (P'::'b ⇒ 'a set) Z; ∀t::'a. t ∈ (Q'::'b ⇒ 'a set) Z ⟶ (return::'a ⇒ 'a ⇒ 'a) s t ∈ (R::'a ⇒ 'a ⇒ 'a set) s t; ∀t::'a. t ∈ (A'::'b ⇒ 'a set) Z ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return s t) t ∈ (A::'a set)⟧ ⟹ ∀Z::'a. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {t::'a. t = Z ∧ return s t ∈ R s t} DynCom (λt::'a. Seq (Basic (return s)) ((c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) s t)) (Q::'a set),A› and 2 goals remain*) apply (rule HoareTotalDef.DynCom (*‹∀s::?'s∈?P::?'s set. (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option),(?Θ::(?'s set × ?'p × ?'s set × ?'s set) set)⊢⇩t⇘/(?F::?'f set)⇙ ?P (?c::?'s ⇒ (?'s, ?'p, ?'f) com) s (?Q::?'s set),(?A::?'s set) ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*top goal: ‹⋀(Z::'b::type) (s::'a::type) Za::'a::type. ⟦(init::'a::type ⇒ 'a::type) s ∈ (P'::'b::type ⇒ 'a::type set) Z; ∀t::'a::type. t ∈ (Q'::'b::type ⇒ 'a::type set) Z ⟶ (return::'a::type ⇒ 'a::type ⇒ 'a::type) s t ∈ (R::'a::type ⇒ 'a::type ⇒ 'a::type set) s t; ∀t::'a::type. t ∈ (A'::'b::type ⇒ 'a::type set) Z ⟶ (result_exn::'a::type ⇒ 'a::type ⇒ 'a::type) (return s t) t ∈ (A::'a::type set)⟧ ⟹ (Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ {t::'a::type. t = Za ∧ return s t ∈ R s t} DynCom (λt::'a::type. Seq (Basic (return s)) ((c::'a::type ⇒ 'a::type ⇒ ('a::type, 'c::type, 'd::type) com) s t)) (Q::'a::type set),A› and 2 goals remain*) apply clarsimp (*top goal: ‹⋀Z s Za. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ ∀sa∈{t. t = Za ∧ return s t ∈ R s t}. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return s t ∈ R s t} Seq (Basic (return s)) (c s sa) Q,A› and 2 goals remain*) apply (rule SeqSwap (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c2.0 ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c1.0 ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z s Za. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A; return s Za ∈ R s Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R165 Z s Za) c s Za Q,A› 2. ‹⋀Z s Za. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A; return s Za ∈ R s Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return s t ∈ R s t} Basic (return s) (?R165 Z s Za),A› discuss goal 1*) apply (rule c [rule_format] (*‹Γ,Θ⊢⇩t⇘/F⇙ (R ?s ?t) c ?s ?t Q,A›*)) (*discuss goal 2*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀Z s Za. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A; return s Za ∈ R s Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return s t ∈ R s t} Basic (return s) (R s Za),A› and 2 goals remain*) apply clarsimp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (rule_tac R="{t. result_exn (return s t) t ∈ A}" in HoareTotalDef.Catch (*‹⟦(?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option),(?Θ::(?'s set × ?'p × ?'s set × ?'s set) set)⊢⇩t⇘/(?F::?'f set)⇙ (?P::?'s set) (?c₁::(?'s, ?'p, ?'f) com) (?Q::?'s set),(?R::?'s set); ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R (?c₂::(?'s, ?'p, ?'f) com) ?Q,(?A::?'s set)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Catch ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⋀(Z::'b::type) s::'a::type. ⟦(init::'a::type ⇒ 'a::type) s ∈ (P'::'b::type ⇒ 'a::type set) Z; ∀t::'a::type. t ∈ (Q'::'b::type ⇒ 'a::type set) Z ⟶ (return::'a::type ⇒ 'a::type ⇒ 'a::type) s t ∈ (R::'a::type ⇒ 'a::type ⇒ 'a::type set) s t; ∀t::'a::type. t ∈ (A'::'b::type ⇒ 'a::type set) Z ⟶ (result_exn::'a::type ⇒ 'a::type ⇒ 'a::type) (return s t) t ∈ (A::'a::type set)⟧ ⟹ (Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ {s::'a::type. init s ∈ P' Z ∧ (∀t::'a::type. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t::'a::type. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} Seq (Basic init) (bdy::('a::type, 'c::type, 'd::type) com) {t::'a::type. return s t ∈ R s t},{t::'a::type. result_exn (return s t) t ∈ A}› 2. ‹⋀(Z::'b::type) s::'a::type. ⟦(init::'a::type ⇒ 'a::type) s ∈ (P'::'b::type ⇒ 'a::type set) Z; ∀t::'a::type. t ∈ (Q'::'b::type ⇒ 'a::type set) Z ⟶ (return::'a::type ⇒ 'a::type ⇒ 'a::type) s t ∈ (R::'a::type ⇒ 'a::type ⇒ 'a::type set) s t; ∀t::'a::type. t ∈ (A'::'b::type ⇒ 'a::type set) Z ⟶ (result_exn::'a::type ⇒ 'a::type ⇒ 'a::type) (return s t) t ∈ (A::'a::type set)⟧ ⟹ (Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ {t::'a::type. result_exn (return s t) t ∈ A} Seq (Basic (λt::'a::type. result_exn (return s t) t)) Throw {t::'a::type. return s t ∈ R s t},A› discuss goal 1*) apply (rule_tac R="{i. i ∈ P' Z}" in Seq (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?R,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} Basic init {i. i ∈ P' Z},{t. result_exn (return s t) t ∈ A}› 2. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {i. i ∈ P' Z} bdy {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}› discuss goal 1*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)} Basic init {i. i ∈ P' Z},{t. result_exn (return s t) t ∈ A}› and 2 goals remain*) apply clarsimp (*discuss goal 2*) apply simp (*top goal: ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {i. i ∈ P' Z} bdy {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}› and 1 goal remains*) apply (rule conseq [OF bdy] (*‹∀s. s ∈ ?P ⟶ (∃Z. s ∈ P' Z ∧ Q' Z ⊆ ?Q ∧ A' Z ⊆ ?A) ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P bdy ?Q,?A›*)) (*top goal: ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z) bdy {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}› and 1 goal remains*) apply clarsimp (*top goal: ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ ∀sa. sa ∈ P' Z ⟶ (∃Z. sa ∈ P' Z ∧ Q' Z ⊆ {t. return s t ∈ R s t} ∧ A' Z ⊆ {t. result_exn (return s t) t ∈ A})› and 1 goal remains*) apply blast (*proven 2 subgoals*) (*discuss goal 2*) apply (rule SeqSwap (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?R::?'b set) (?c2.0::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P::?'b set) (?c1.0::(?'b, ?'a, ?'c) com) ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R221 Z s) Throw {t. return s t ∈ R s t},A› 2. ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. result_exn (return s t) t ∈ A} Basic (λt. result_exn (return s t) t) (?R221 Z s),A› discuss goal 1*) apply (rule Throw (*‹?Γ,?Θ⊢⇩t⇘/?F⇙ ?A Throw ?Q,?A›*)) (*discuss goal 2*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*goal: ‹⋀Z s. ⟦init s ∈ P' Z; ∀t. t ∈ Q' Z ⟶ return s t ∈ R s t; ∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. result_exn (return s t) t ∈ A} Basic (λt. result_exn (return s t) t) A,A›*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma BlockSpec: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes bdy: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) bdy (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (block init bdy return c) Q,A" using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) bdy (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) bdy (Q' Z),(A' Z)›*) unfolding block_def (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P block_exn init bdy return (λs t. s) c Q,A›*) by (rule Block_exnSpec (*‹⟦?P ⊆ {s. ∃Z. ?init s ∈ ?P' Z ∧ (∀t. t ∈ ?Q' Z ⟶ ?return s t ∈ ?R s t) ∧ (∀t. t ∈ ?A' Z ⟶ ?result_exn (?return s t) t ∈ ?A)}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?bdy (?Q' Z),(?A' Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P block_exn ?init ?bdy ?return ?result_exn ?c ?Q,?A›*)) lemma Throw: "P ⊆ A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Throw Q,A" by (rule hoaret.Throw [THEN conseqPre] (*‹?P ⊆ ?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Throw ?Q,?A›*)) lemmas Catch = hoaret.Catch lemma CatchSwap: "⟦Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Catch c₁ c₂ Q,A" apply (rule hoaret.Catch (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?Q,?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Catch ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,?R› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,R⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c₂ Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma raise: "P ⊆ {s. f s ∈ A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P raise f Q,A" apply (simp add: raise_def (*‹raise ?f = Seq (Basic ?f) Throw›*)) (*goal: ‹P ⊆ {s. f s ∈ A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P raise f Q,A›*) apply (rule Seq (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?R,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹(P::'a::type set) ⊆ {s::'a::type. (f::'a::type ⇒ 'a::type) s ∈ (A::'a::type set)} ⟹ (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ P Basic f (?R::'a::type set),A› 2. ‹(P::'a::type set) ⊆ {s::'a::type. (f::'a::type ⇒ 'a::type) s ∈ (A::'a::type set)} ⟹ (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (?R::'a::type set) Throw (Q::'a::type set),A› discuss goal 1*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹(P::'a set) ⊆ {s::'a. (f::'a ⇒ 'a) s ∈ (A::'a set)} ⟹ (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ P Basic f (?R::'a set),A› and 1 goal remains*) apply assumption (*discuss goal 2*) apply (rule Throw (*‹(?P::?'a set) ⊆ (?A::?'a set) ⟹ (?Γ::?'b ⇒ (?'a, ?'b, ?'c) com option),(?Θ::(?'a set × ?'b × ?'a set × ?'a set) set)⊢⇩t⇘/(?F::?'c set)⇙ ?P Throw (?Q::?'a set),?A›*)) (*goal: ‹P ⊆ {s. f s ∈ A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ A Throw Q,A›*) apply (rule subset_refl (*‹(?A::?'a::type set) ⊆ ?A›*)) (*proven 2 subgoals*) . lemma condCatch: "⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,((b ∩ R) ∪ (-b ∩ A));Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P condCatch c₁ b c₂ Q,A" apply (simp add: condCatch_def (*‹condCatch ?c₁ ?b ?c₂ = Catch ?c₁ (Cond ?b ?c₂ Throw)›*)) (*goal: ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A); Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P condCatch c₁ b c₂ Q,A›*) apply (rule Catch (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?Q,?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Catch ?c₁ ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A); Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,?R› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A); Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R Cond b c₂ Throw Q,A› discuss goal 1*) apply assumption (*discuss goal 2*) apply (rule CondSwap (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P1.0::?'b set) (?c1.0::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P2.0::?'b set) (?c2.0::(?'b, ?'a, ?'c) com) ?Q,?A; (?P::?'b set) ⊆ {s::?'b. (s ∈ (?b::?'b set) ⟶ s ∈ ?P1.0) ∧ (s ∉ ?b ⟶ s ∈ ?P2.0)}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A); Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P1.3 c₂ Q,A› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A); Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P2.3 Throw Q,A› 3. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A); Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A⟧ ⟹ b ∩ R ∪ - b ∩ A ⊆ {s. (s ∈ b ⟶ s ∈ ?P1.3) ∧ (s ∉ b ⟶ s ∈ ?P2.3)}› discuss goal 1*) apply assumption (*discuss goal 2*) apply (rule hoaret.Throw (*‹?Γ,?Θ⊢⇩t⇘/?F⇙ ?A Throw ?Q,?A›*)) (*discuss goal 3*) apply blast (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma condCatchSwap: "⟦Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,((b ∩ R) ∪ (-b ∩ A))⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P condCatch c₁ b c₂ Q,A" apply (rule condCatch (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c₁ ?Q,(?b ∩ ?R ∪ - ?b ∩ ?A); ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P condCatch ?c₁ ?b ?c₂ ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ ?R ∪ - b ∩ A)› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ R c₂ Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c₁ Q,(b ∩ R ∪ - b ∩ A)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R c₂ Q,A› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma Proc_exnSpec: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return result_exn c) Q,A" using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}›*) c (*‹∀(s::'a) t::'a. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ ((R::'a ⇒ 'a ⇒ 'a set) s t) (c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) s t (Q::'a set),(A::'a set)›*) p (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)›*) apply (unfold call_exn_def (*‹call_exn ?init ?p ?return ?result_exn ?c = block_exn ?init (Call ?p) ?return ?result_exn ?c›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*) apply (rule Block_exnSpec (*‹⟦?P ⊆ {s. ∃Z. ?init s ∈ ?P' Z ∧ (∀t. t ∈ ?Q' Z ⟶ ?return s t ∈ ?R s t) ∧ (∀t. t ∈ ?A' Z ⟶ ?result_exn (?return s t) t ∈ ?A)}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?bdy (?Q' Z),(?A' Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P block_exn ?init ?bdy ?return ?result_exn ?c ?Q,?A›*)) (*goals: 1. ‹⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}; ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)⟧ ⟹ P ⊆ {s. ∃Z. init s ∈ ?P'3 Z ∧ (∀t. t ∈ ?Q'3 Z ⟶ return s t ∈ ?R3 s t) ∧ (∀t. t ∈ ?A'3 Z ⟶ result_exn (return s t) t ∈ A)}› 2. ‹⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}; ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)⟧ ⟹ ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (?R3 s t) c s t Q,A› 3. ‹⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}; ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)⟧ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (?P'3 Z) Call p (?Q'3 Z),(?A'3 Z)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma ProcSpec: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return c) Q,A" using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) p (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)›*) apply (unfold call_def (*‹call (?init::?'s ⇒ ?'s) (?p::?'p) (?return::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = block ?init (Call ?p) ?return ?c›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*) apply (rule BlockSpec (*‹⟦?P ⊆ {s. ∃Z. ?init s ∈ ?P' Z ∧ (∀t. t ∈ ?Q' Z ⟶ ?return s t ∈ ?R s t) ∧ (∀t. t ∈ ?A' Z ⟶ ?return s t ∈ ?A)}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?bdy (?Q' Z),(?A' Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P block ?init ?bdy ?return ?c ?Q,?A›*)) (*goals: 1. ‹⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}; ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)⟧ ⟹ P ⊆ {s. ∃Z. init s ∈ ?P'3 Z ∧ (∀t. t ∈ ?Q'3 Z ⟶ return s t ∈ ?R3 s t) ∧ (∀t. t ∈ ?A'3 Z ⟶ return s t ∈ A)}› 2. ‹⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}; ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)⟧ ⟹ ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (?R3 s t) c s t Q,A› 3. ‹⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ return s t ∈ A)}; ∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)⟧ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (?P'3 Z) Call p (?Q'3 Z),(?A'3 Z)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma Proc_exnSpec': assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t ∈ Q' Z. return s t ∈ R s t) ∧ (∀t ∈ A' Z. result_exn (return s t) t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return result_exn c) Q,A" apply (rule Proc_exnSpec [OF _ c p] (*‹?P ⊆ {s. ∃Z. ?init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ ?return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ ?result_exn (?return s t) t ∈ A)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P call_exn ?init p ?return ?result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*) apply (insert adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t∈Q' Z. return s t ∈ R s t) ∧ (∀t∈A' Z. result_exn (return s t) t ∈ A)}›*)) (*goal: ‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}›*) apply clarsimp (*goal: ‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t∈Q' Z. return s t ∈ R s t) ∧ (∀t∈A' Z. result_exn (return s t) t ∈ A)} ⟹ P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}›*) apply (drule (1) subsetD (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) (*goal: ‹⋀x. ⟦P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t∈Q' Z. return s t ∈ R s t) ∧ (∀t∈A' Z. result_exn (return s t) t ∈ A)}; x ∈ P⟧ ⟹ ∃Z. init x ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return x t ∈ R x t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return x t) t ∈ A)›*) apply clarsimp (*goal: ‹⋀x. ⟦x ∈ P; x ∈ {s. ∃Z. init s ∈ P' Z ∧ (∀t∈Q' Z. return s t ∈ R s t) ∧ (∀t∈A' Z. result_exn (return s t) t ∈ A)}⟧ ⟹ ∃Z. init x ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return x t ∈ R x t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return x t) t ∈ A)›*) apply (rule_tac x=Z in exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*goal: ‹⋀x Z. ⟦x ∈ P; init x ∈ P' Z; ∀t∈Q' Z. return x t ∈ R x t; ∀t∈A' Z. result_exn (return x t) t ∈ A⟧ ⟹ ∃Z. init x ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return x t ∈ R x t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return x t) t ∈ A)›*) by blast lemma ProcSpec': assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t ∈ Q' Z. return s t ∈ R s t) ∧ (∀t ∈ A' Z. return s t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return c) Q,A" using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t∈Q' Z. return s t ∈ R s t) ∧ (∀t∈A' Z. return s t ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) p (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),(A' Z)›*) unfolding call_call_exn (*goal: ‹(Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ (P::'a set) call_exn (init::'a ⇒ 'a) (p::'c) (return::'a ⇒ 'a ⇒ 'a) (λ(s::'a) t::'a. s) (c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) (Q::'a set),(A::'a set)›*) by (rule Proc_exnSpec' (*‹⟦?P ⊆ {s. ∃Z. ?init s ∈ ?P' Z ∧ (∀t∈?Q' Z. ?return s t ∈ ?R s t) ∧ (∀t∈?A' Z. ?result_exn (?return s t) t ∈ ?A)}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) Call ?p (?Q' Z),(?A' Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P call_exn ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma Proc_exnSpecNoAbrupt: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return result_exn c) Q,A" apply (rule Proc_exnSpec [OF _ c p] (*‹?P ⊆ {s. ∃Z. ?init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ ?return s t ∈ R s t) ∧ (∀t. t ∈ {} ⟶ ?result_exn (?return s t) t ∈ A)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P call_exn ?init p ?return ?result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*) using adapt (*‹(P::'a set) ⊆ {s::'a. ∃Z::'b. (init::'a ⇒ 'a) s ∈ (P'::'b ⇒ 'a set) Z ∧ (∀t::'a. t ∈ (Q'::'b ⇒ 'a set) Z ⟶ (return::'a ⇒ 'a ⇒ 'a) s t ∈ (R::'a ⇒ 'a ⇒ 'a set) s t)}›*) by simp lemma ProcSpecNoAbrupt: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call p (Q' Z),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return c) Q,A" apply (rule ProcSpec [OF _ c p] (*‹?P ⊆ {s. ∃Z. ?init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ ?return s t ∈ R s t) ∧ (∀t. t ∈ {} ⟶ ?return s t ∈ A)} ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P call ?init p ?return c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*) using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t)}›*) by simp lemma FCall: "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return (λs t. c (result t))) Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (fcall init p return result c) Q,A" by (simp add: fcall_def (*‹fcall ?init ?p ?return ?result ?c = call ?init ?p ?return (λs t. ?c (?result t))›*)) lemma ProcRec: assumes deriv_bodies: "∀p∈Procs. ∀σ Z. Γ,Θ∪(⋃q∈Procs. ⋃Z. {(P q Z ∩ {s. ((s,q), σ,p) ∈ r},q,Q q Z,A q Z)}) ⊢⇩t⇘/F⇙ ({σ} ∩ P p Z) (the (Γ p)) (Q p Z),(A p Z)" assumes wf: "wf r" assumes Procs_defined: "Procs ⊆ dom Γ" shows "∀p∈Procs. ∀Z. Γ,Θ⊢⇩t⇘/F⇙(P p Z) Call p (Q p Z),(A p Z)" apply (intro strip (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q› ‹(⋀x. ?P x) ⟹ ∀x. ?P x› ‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹∀p∈Procs. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P p Z) Call p (Q p Z),(A p Z)›*) apply (rule HoareTotalDef.CallRec' [OF _ Procs_defined wf deriv_bodies] (*‹?p ∈ Procs ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P ?p ?Z) Call ?p (Q ?p ?Z),(A ?p ?Z)›*)) (*goal: ‹⋀p Z. p ∈ Procs ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P p Z) Call p (Q p Z),(A p Z)›*) by simp lemma ProcRec': assumes ctxt: "Θ'=(λσ p. Θ∪(⋃q∈Procs. ⋃Z. {(P q Z ∩ {s. ((s,q), σ,p) ∈ r},q,Q q Z,A q Z)}))" assumes deriv_bodies: "∀p∈Procs. ∀σ Z. Γ,Θ' σ p⊢⇩t⇘/F⇙ ({σ} ∩ P p Z) (the (Γ p)) (Q p Z),(A p Z)" assumes wf: "wf r" assumes Procs_defined: "Procs ⊆ dom Γ" shows "∀p∈Procs. ∀Z. Γ,Θ⊢⇩t⇘/F⇙(P p Z) Call p (Q p Z),(A p Z)" using ctxt (*‹Θ' = (λσ p. Θ ∪ (⋃q∈Procs. ⋃Z. {(P q Z ∩ {s. ((s, q), σ, p) ∈ r}, q, Q q Z, A q Z)}))›*) deriv_bodies (*‹∀p∈Procs. ∀σ Z. Γ,Θ' σ p⊢⇩t⇘/F⇙ ({σ} ∩ P p Z) the (Γ p) (Q p Z),(A p Z)›*) apply simp (*goal: ‹∀p∈Procs. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P p Z) Call p (Q p Z),(A p Z)›*) by (erule ProcRec [OF _ wf Procs_defined] (*‹∀p∈Procs. ∀σ Z. Γ,?Θ ∪ (⋃q∈Procs. ⋃Z. {(?P q Z ∩ {s. ((s, q), σ, p) ∈ r}, q, ?Q q Z, ?A q Z)})⊢⇩t⇘/?F⇙ ({σ} ∩ ?P p Z) the (Γ p) (?Q p Z),(?A p Z) ⟹ ∀p∈Procs. ∀Z. Γ,?Θ⊢⇩t⇘/?F⇙ (?P p Z) Call p (?Q p Z),(?A p Z)›*)) lemma ProcRecList: assumes deriv_bodies: "∀p∈set Procs. ∀σ Z. Γ,Θ∪(⋃q∈set Procs. ⋃Z. {(P q Z ∩ {s. ((s,q), σ,p) ∈ r},q,Q q Z,A q Z)}) ⊢⇩t⇘/F⇙ ({σ} ∩ P p Z) (the (Γ p)) (Q p Z),(A p Z)" assumes wf: "wf r" assumes dist: "distinct Procs" assumes Procs_defined: "set Procs ⊆ dom Γ" shows "∀p∈set Procs. ∀Z. Γ,Θ⊢⇩t⇘/F⇙(P p Z) Call p (Q p Z),(A p Z)" using deriv_bodies (*‹∀p∈set Procs. ∀σ Z. Γ,Θ ∪ (⋃q∈set Procs. ⋃Z. {(P q Z ∩ {s. ((s, q), σ, p) ∈ r}, q, Q q Z, A q Z)})⊢⇩t⇘/F⇙ ({σ} ∩ P p Z) the (Γ p) (Q p Z),(A p Z)›*) wf (*‹wf r›*) Procs_defined (*‹set (Procs::'a list) ⊆ dom (Γ::'a ⇒ ('b, 'a, 'd) com option)›*) by (rule ProcRec (*‹⟦∀p∈?Procs. ∀σ Z. ?Γ,?Θ ∪ (⋃q∈?Procs. ⋃Z. {(?P q Z ∩ {s. ((s, q), σ, p) ∈ ?r}, q, ?Q q Z, ?A q Z)})⊢⇩t⇘/?F⇙ ({σ} ∩ ?P p Z) the (?Γ p) (?Q p Z),(?A p Z); wf ?r; ?Procs ⊆ dom ?Γ⟧ ⟹ ∀p∈?Procs. ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P p Z) Call p (?Q p Z),(?A p Z)›*)) lemma ProcRecSpecs: "⟦∀σ. ∀(P,p,Q,A) ∈ Specs. Γ,Θ∪ ((λ(P,q,Q,A). (P ∩ {s. ((s,q),(σ,p)) ∈ r},q,Q,A)) ` Specs) ⊢⇩t⇘/F⇙ ({σ} ∩ P) (the (Γ p)) Q,A; wf r; ∀(P,p,Q,A) ∈ Specs. p ∈ dom Γ⟧ ⟹ ∀(P,p,Q,A) ∈ Specs. Γ,Θ⊢⇩t⇘/F⇙ P (Call p) Q,A" apply (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⟦∀σ. ∀(P, p, Q, A)∈Specs. Γ,Θ ∪ (λ(P, q, Q, A). (P ∩ {s. ((s, q), σ, p) ∈ r}, q, Q, A)) ` Specs⊢⇩t⇘/F⇙ ({σ} ∩ P) the (Γ p) Q,A; wf r; ∀(P, p, Q, A)∈Specs. p ∈ dom Γ⟧ ⟹ ∀(P, p, Q, A)∈Specs. Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A›*) apply (case_tac x) (*goal: ‹⋀x. ⟦∀σ. ∀(P, p, Q, A)∈Specs. Γ,Θ ∪ (λ(P, q, Q, A). (P ∩ {s. ((s, q), σ, p) ∈ r}, q, Q, A)) ` Specs⊢⇩t⇘/F⇙ ({σ} ∩ P) the (Γ p) Q,A; wf r; ∀(P, p, Q, A)∈Specs. p ∈ dom Γ; x ∈ Specs⟧ ⟹ case x of (P, p, Q, A) ⇒ Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A›*) apply (rename_tac x P p Q A) (*goal: ‹⋀x a b c d. ⟦∀σ. ∀(P, p, Q, A)∈Specs. Γ,Θ ∪ (λ(P, q, Q, A). (P ∩ {s. ((s, q), σ, p) ∈ r}, q, Q, A)) ` Specs⊢⇩t⇘/F⇙ ({σ} ∩ P) the (Γ p) Q,A; wf r; ∀(P, p, Q, A)∈Specs. p ∈ dom Γ; x ∈ Specs; x = (a, b, c, d)⟧ ⟹ case x of (P, p, Q, A) ⇒ Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A›*) apply simp (*goal: ‹⋀x P p Q A. ⟦∀σ. ∀(P, p, Q, A)∈Specs. Γ,Θ ∪ (λ(P, q, Q, A). (P ∩ {s. ((s, q), σ, p) ∈ r}, q, Q, A)) ` Specs⊢⇩t⇘/F⇙ ({σ} ∩ P) the (Γ p) Q,A; wf r; ∀(P, p, Q, A)∈Specs. p ∈ dom Γ; x ∈ Specs; x = (P, p, Q, A)⟧ ⟹ case x of (P, p, Q, A) ⇒ Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A›*) apply (rule hoaret.CallRec (*‹⟦(?P::?'s set, ?p::?'p, ?Q::?'s set, ?A::?'s set) ∈ (?Specs::(?'s set × ?'p × ?'s set × ?'s set) set); wf (?r::((?'s × ?'p) × ?'s × ?'p) set); (?Specs_wf::?'p ⇒ ?'s ⇒ (?'s set × ?'p × ?'s set × ?'s set) set) = (λ(p::?'p) σ::?'s. (λ(P::?'s set, q::?'p, Q::?'s set, A::?'s set). (P ∩ {s::?'s. ((s, q), σ, p) ∈ ?r}, q, Q, A)) ` ?Specs); ∀(P::?'s set, p::?'p, Q::?'s set, A::?'s set)∈?Specs. p ∈ dom (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option) ∧ (∀σ::?'s. ?Γ,(?Θ::(?'s set × ?'p × ?'s set × ?'s set) set) ∪ ?Specs_wf p σ⊢⇩t⇘/(?F::?'f set)⇙ ({σ} ∩ P) the (?Γ p) Q,A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Call ?p ?Q,?A›*)) (*goal: ‹⋀x P p Q A. ⟦∀σ. ∀x∈Specs. case x of (P, p, Q, A) ⇒ Γ,Θ ∪ (λx. case x of (P, q, Q, A) ⇒ (P ∩ {s. ((s, q), σ, p) ∈ r}, q, Q, A)) ` Specs⊢⇩t⇘/F⇙ ({σ} ∩ P) the (Γ p) Q,A; wf r; ∀x∈Specs. case x of (P, p, Q, A) ⇒ p ∈ dom Γ; (P, p, Q, A) ∈ Specs; x = (P, p, Q, A)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A›*) by auto lemma ProcRec1: assumes deriv_body: "∀σ Z. Γ,Θ∪(⋃Z. {(P Z ∩ {s. ((s,p), σ,p) ∈ r},p,Q Z,A Z)}) ⊢⇩t⇘/F⇙ ({σ} ∩ P Z) (the (Γ p)) (Q Z),(A Z)" assumes wf: "wf r" assumes p_defined: "p ∈ dom Γ" shows "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)" proof (-) (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)›*) from deriv_body (*‹∀(σ::'a) Z::'b. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set) ∪ (⋃Z::'b. {((P::'b ⇒ 'a set) Z ∩ {s::'a. ((s, p::'c), σ, p) ∈ (r::(('a × 'c) × 'a × 'c) set)}, p, (Q::'b ⇒ 'a set) Z, (A::'b ⇒ 'a set) Z)})⊢⇩t⇘/(F::'d set)⇙ ({σ} ∩ P Z) the (Γ p) (Q Z),(A Z)›*) wf (*‹wf r›*) p_defined (*‹p ∈ dom Γ›*) have "∀p∈{p}. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)" apply - (*goal: ‹∀p::'c∈{p::'c}. ∀Z::'b. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ ((P::'b ⇒ 'a set) Z) Call p ((Q::'b ⇒ 'a set) Z),((A::'b ⇒ 'a set) Z)›*) apply (rule ProcRec [where A="λp. A" and P="λp. P" and Q="λp. Q"] (*‹⟦∀p::?'e1∈?Procs::?'e1 set. ∀(σ::'a) Z::'b. (?Γ::?'e1 ⇒ ('a, ?'e1, ?'d) com option),(?Θ::('a set × ?'e1 × 'a set × 'a set) set) ∪ (⋃q::?'e1∈?Procs. ⋃Z::'b. {((P::'b ⇒ 'a set) Z ∩ {s::'a. ((s, q), σ, p) ∈ (?r::(('a × ?'e1) × 'a × ?'e1) set)}, q, (Q::'b ⇒ 'a set) Z, (A::'b ⇒ 'a set) Z)})⊢⇩t⇘/(?F::?'d set)⇙ ({σ} ∩ P Z) the (?Γ p) (Q Z),(A Z); wf ?r; ?Procs ⊆ dom ?Γ⟧ ⟹ ∀p::?'e1∈?Procs. ∀Z::'b. ?Γ,?Θ⊢⇩t⇘/?F⇙ (P Z) Call p (Q Z),(A Z)›*)) (*goals: 1. ‹⟦∀σ Z. Γ,Θ ∪ (⋃Z. {(P Z ∩ {s. ((s, p), σ, p) ∈ r}, p, Q Z, A Z)})⊢⇩t⇘/F⇙ ({σ} ∩ P Z) the (Γ p) (Q Z),(A Z); wf r; p ∈ dom Γ⟧ ⟹ ∀pa∈{p}. ∀σ Z. Γ,Θ ∪ (⋃q∈{p}. ⋃Z. {(P Z ∩ {s. ((s, q), σ, pa) ∈ ?r3}, q, Q Z, A Z)})⊢⇩t⇘/F⇙ ({σ} ∩ P Z) the (Γ pa) (Q Z),(A Z)› 2. ‹⟦∀σ Z. Γ,Θ ∪ (⋃Z. {(P Z ∩ {s. ((s, p), σ, p) ∈ r}, p, Q Z, A Z)})⊢⇩t⇘/F⇙ ({σ} ∩ P Z) the (Γ p) (Q Z),(A Z); wf r; p ∈ dom Γ⟧ ⟹ wf ?r3› 3. ‹⟦∀σ Z. Γ,Θ ∪ (⋃Z. {(P Z ∩ {s. ((s, p), σ, p) ∈ r}, p, Q Z, A Z)})⊢⇩t⇘/F⇙ ({σ} ∩ P Z) the (Γ p) (Q Z),(A Z); wf r; p ∈ dom Γ⟧ ⟹ {p} ⊆ dom Γ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)›*) by simp qed lemma ProcNoRec1: assumes deriv_body: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) (the (Γ p)) (Q Z),(A Z)" assumes p_defined: "p ∈ dom Γ" shows "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)" proof (-) (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)›*) have "∀σ Z. Γ,Θ⊢⇩t⇘/F⇙ ({σ} ∩ P Z) (the (Γ p)) (Q Z),(A Z)" by (blast intro: conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*) deriv_body [rule_format] (*‹Γ,Θ⊢⇩t⇘/F⇙ (P ?Z) the (Γ p) (Q ?Z),(A ?Z)›*)) with p_defined (*‹p ∈ dom Γ›*) have "∀σ Z. Γ,Θ∪(⋃Z. {(P Z ∩ {s. ((s,p), σ,p) ∈ {}}, p,Q Z,A Z)}) ⊢⇩t⇘/F⇙ ({σ} ∩ P Z) (the (Γ p)) (Q Z),(A Z)" by (blast intro: hoaret_augment_context (*‹⟦(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option),(?Θ::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⊢⇩t⇘/(?F::?'c::type set)⇙ (?P::?'b::type set) (?p::(?'b::type, ?'a::type, ?'c::type) com) (?Q::?'b::type set),(?A::?'b::type set); ?Θ ⊆ (?Θ'::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⟧ ⟹ ?Γ,?Θ'⊢⇩t⇘/?F⇙ ?P ?p ?Q,?A›*)) from this (*‹∀σ Z. Γ,Θ ∪ (⋃Z. {(P Z ∩ {s. ((s, p), σ, p) ∈ {}}, p, Q Z, A Z)})⊢⇩t⇘/F⇙ ({σ} ∩ P Z) the (Γ p) (Q Z),(A Z)›*) show "?thesis" (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) Call p (Q Z),(A Z)›*) apply (rule ProcRec1 (*‹⟦∀σ Z. ?Γ,?Θ ∪ (⋃Z. {(?P Z ∩ {s. ((s, ?p), σ, ?p) ∈ ?r}, ?p, ?Q Z, ?A Z)})⊢⇩t⇘/?F⇙ ({σ} ∩ ?P Z) the (?Γ ?p) (?Q Z),(?A Z); wf ?r; ?p ∈ dom ?Γ⟧ ⟹ ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P Z) Call ?p (?Q Z),(?A Z)›*)) (*goals: 1. ‹wf {}› 2. ‹p ∈ dom Γ› discuss goal 1*) apply ((auto simp add: p_defined (*‹p ∈ dom Γ›*))[1]) (*discuss goal 2*) apply ((auto simp add: p_defined (*‹p ∈ dom Γ›*))[1]) (*proven 2 subgoals*) . qed lemma ProcBody: assumes WP: "P ⊆ P'" assumes deriv_body: "Γ,Θ⊢⇩t⇘/F⇙ P' body Q,A" assumes body: "Γ p = Some body" shows "Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A" apply (rule conseqPre [OF _ WP] (*‹?Γ,?Θ⊢⇩t⇘/?F⇙ P' ?c ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P Call p Q,A›*) apply (rule ProcNoRec1 [rule_format, where P="λZ. P'" and Q="λZ. Q" and A="λZ. A"] (*‹⟦⋀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ P' the (?Γ ?p) Q,A; ?p ∈ dom ?Γ⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ P' Call ?p Q,A›*)) (*goals: 1. ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ P' the (Γ p) Q,A› 2. ‹p ∈ dom Γ› discuss goal 1*) apply ((insert body (*‹Γ p = Some body›*))[1]) (*top goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ P' the (Γ p) Q,A› and 1 goal remains*) apply simp (*top goal: ‹⋀Z. Γ p = Some body ⟹ Γ,Θ⊢⇩t⇘/F⇙ P' the (Γ p) Q,A› and 1 goal remains*) apply (rule hoaret_augment_context [OF deriv_body] (*‹(Θ::('a set × 'b × 'a set × 'a set) set) ⊆ (?Θ'::('a set × 'b × 'a set × 'a set) set) ⟹ (Γ::'b ⇒ ('a, 'b, 'c) com option),?Θ'⊢⇩t⇘/(F::'c set)⇙ (P'::'a set) (body::('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*)) (*top goal: ‹Γ p = Some body ⟹ Γ,Θ⊢⇩t⇘/F⇙ P' body Q,A› and 1 goal remains*) apply blast (*discuss goal 2*) apply ((insert body (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option) (p::'b) = Some (body::('a, 'b, 'c) com)›*))[1]) (*goal: ‹p ∈ dom Γ›*) apply fastforce (*proven 2 subgoals*) . lemma CallBody: assumes adapt: "P ⊆ {s. init s ∈ P' s}" assumes bdy: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) body {t. return s t ∈ R s t},{t. return s t ∈ A}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes body: "Γ p = Some body" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return c) Q,A" apply (unfold call_def (*‹call ?init ?p ?return ?c = block ?init (Call ?p) ?return ?c›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*) apply (rule Block [OF adapt _ c] (*‹∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) ?bdy {t. ?return s t ∈ R s t},{t. ?return s t ∈ A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P block init ?bdy ?return c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P block init (Call p) return c Q,A›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) Call p {t. return s t ∈ R s t},{t. return s t ∈ A}›*) apply (rule ProcBody [where Γ=Γ, OF _ bdy [rule_format] body] (*‹(?P::'a::type set) ⊆ (P'::'a::type ⇒ 'a::type set) (?s1::'a::type) ⟹ (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ?P Call (p::'b::type) {t::'a::type. (return::'a::type ⇒ 'a::type ⇒ 'a::type) ?s1 t ∈ (R::'a::type ⇒ 'a::type ⇒ 'a::type set) ?s1 t},{t::'a::type. return ?s1 t ∈ (A::'a::type set)}›*)) (*goal: ‹⋀s::'a::type. (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ ((P'::'a::type ⇒ 'a::type set) s) Call (p::'b::type) {t::'a::type. (return::'a::type ⇒ 'a::type ⇒ 'a::type) s t ∈ (R::'a::type ⇒ 'a::type ⇒ 'a::type set) s t},{t::'a::type. return s t ∈ (A::'a::type set)}›*) by simp lemma Call_exnBody: assumes adapt: "P ⊆ {s. init s ∈ P' s}" assumes bdy: "∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) body {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes body: "Γ p = Some body" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return result_exn c) Q,A" apply (unfold call_exn_def (*‹call_exn ?init ?p ?return ?result_exn ?c = block_exn ?init (Call ?p) ?return ?result_exn ?c›*)) (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) call_exn (init::'a ⇒ 'a) (p::'b) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) apply (rule Block_exn [OF adapt _ c] (*‹∀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) ?bdy {t. ?return s t ∈ R s t},{t. ?result_exn (?return s t) t ∈ A} ⟹ Γ,Θ⊢⇩t⇘/F⇙ P block_exn init ?bdy ?return ?result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P block_exn init (Call p) return result_exn c Q,A›*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀s::'a. (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ ((P'::'a ⇒ 'a set) s) Call (p::'b) {t::'a. (return::'a ⇒ 'a ⇒ 'a) s t ∈ (R::'a ⇒ 'a ⇒ 'a set) s t},{t::'a. (result_exn::'a ⇒ 'a ⇒ 'a) (return s t) t ∈ (A::'a set)}›*) apply (rule ProcBody [where Γ=Γ, OF _ bdy [rule_format] body] (*‹?P ⊆ P' ?s1 ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P Call p {t. return ?s1 t ∈ R ?s1 t},{t. result_exn (return ?s1 t) t ∈ A}›*)) (*goal: ‹⋀s. Γ,Θ⊢⇩t⇘/F⇙ (P' s) Call p {t. return s t ∈ R s t},{t. result_exn (return s t) t ∈ A}›*) by simp lemmas ProcModifyReturn = HoareTotalProps.ProcModifyReturn lemmas ProcModifyReturnSameFaults = HoareTotalProps.ProcModifyReturnSameFaults lemmas Proc_exnModifyReturn = HoareTotalProps.Proc_exnModifyReturn lemmas Proc_exnModifyReturnSameFaults = HoareTotalProps.Proc_exnModifyReturnSameFaults lemma ProcModifyReturnNoAbr: assumes spec: "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return' c) Q,A" assumes result_conform: "∀s t. t ∈ Modif (init s) ⟶ (return' s t) = (return s t)" assumes modifies_spec: "∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} Call p (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return c) Q,A" apply (rule ProcModifyReturn [OF spec result_conform _ modifies_spec] (*‹∀s t. t ∈ {} ⟶ return' s t = return s t ⟹ Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*) by simp lemma Proc_exnModifyReturnNoAbr: assumes spec: "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return' result_exn c) Q,A" assumes result_conform: "∀s t. t ∈ Modif (init s) ⟶ (return' s t) = (return s t)" assumes modifies_spec: "∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} Call p (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return result_exn c) Q,A" apply (rule Proc_exnModifyReturn [OF spec result_conform _ modifies_spec] (*‹∀s t. t ∈ {} ⟶ result_exn (return' s t) t = result_exn (return s t) t ⟹ Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*) by simp lemma ProcModifyReturnNoAbrSameFaults: assumes spec: "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return' c) Q,A" assumes result_conform: "∀s t. t ∈ Modif (init s) ⟶ (return' s t) = (return s t)" assumes modifies_spec: "∀σ. Γ,Θ⊢⇘/F⇙ {σ} Call p (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call init p return c) Q,A" apply (rule ProcModifyReturnSameFaults [OF spec result_conform _ modifies_spec] (*‹∀s t. t ∈ {} ⟶ return' s t = return s t ⟹ Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call init p return c Q,A›*) by simp lemma Proc_exnModifyReturnNoAbrSameFaults: assumes spec: "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return' result_exn c) Q,A" assumes result_conform: "∀s t. t ∈ Modif (init s) ⟶ (return' s t) = (return s t)" assumes modifies_spec: "∀σ. Γ,Θ⊢⇘/F⇙ {σ} Call p (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (call_exn init p return result_exn c) Q,A" apply (rule Proc_exnModifyReturnSameFaults [OF spec result_conform _ modifies_spec] (*‹∀s t. t ∈ {} ⟶ result_exn (return' s t) t = result_exn (return s t) t ⟹ Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P call_exn init p return result_exn c Q,A›*) by simp lemma DynProc_exn: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ result_exn (return s t) t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀s∈ P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A" apply (rule conseq [where P'="λZ. {s. s=Z ∧ s ∈ P}" and Q'="λZ. Q" and A'="λZ. A"] (*‹⟦∀Z::'a::type. (?Γ::?'b::type ⇒ ('a::type, ?'b::type, ?'d::type) com option),(?Θ::('a::type set × ?'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(?F::?'d::type set)⇙ {s::'a::type. s = Z ∧ s ∈ (P::'a::type set)} (?c::('a::type, ?'b::type, ?'d::type) com) (Q::'a::type set),(A::'a::type set); ∀s::'a::type. s ∈ (?P::'a::type set) ⟶ (∃Z::'a::type. s ∈ {s::'a::type. s = Z ∧ s ∈ P} ∧ Q ⊆ (?Q::'a::type set) ∧ A ⊆ (?A::'a::type set))⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) prefer 2 (*top goal: ‹∀s. s ∈ P ⟶ (∃Z. s ∈ {s. s = Z ∧ s ∈ P} ∧ Q ⊆ Q ∧ A ⊆ A)› and 1 goal remains*) using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ result_exn (return s t) t ∈ A)}›*) apply blast (*top goal: ‹∀s. s ∈ P ⟶ (∃Z. s ∈ {s. s = Z ∧ s ∈ P} ∧ Q ⊆ Q ∧ A ⊆ A)› and 1 goal remains*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goal: ‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} dynCall_exn f UNIV init p return result_exn c Q,A›*) apply (unfold dynCall_exn_def (*‹dynCall_exn (?f::?'f) (?g::?'s set) (?init::?'s ⇒ ?'s) (?p::?'s ⇒ ?'p) (?return::?'s ⇒ ?'s ⇒ ?'s) (?result_exn::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = maybe_guard ?f ?g (DynCom (λs::?'s. call_exn ?init (?p s) ?return ?result_exn ?c))›*) maybe_guard_UNIV (*‹maybe_guard (?f::?'c) UNIV (?c::(?'a, ?'b, ?'c) com) = ?c›*) call_exn_def (*‹call_exn (?init::?'s ⇒ ?'s) (?p::?'p) (?return::?'s ⇒ ?'s ⇒ ?'s) (?result_exn::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = block_exn ?init (Call ?p) ?return ?result_exn ?c›*) block_exn_def (*‹block_exn (?init::?'s ⇒ ?'s) (?bdy::(?'s, ?'p, ?'f) com) (?return::?'s ⇒ ?'s ⇒ ?'s) (?result_exn::?'s ⇒ ?'s ⇒ ?'s) (?c::?'s ⇒ ?'s ⇒ (?'s, ?'p, ?'f) com) = DynCom (λs::?'s. Seq (Catch (Seq (Basic ?init) ?bdy) (Seq (Basic (λt::?'s. ?result_exn (?return s t) t)) Throw)) (DynCom (λt::?'s. Seq (Basic (?return s)) (?c s t))))›*) guards.simps (*‹guards [] (?c::(?'s, ?'p, ?'f) com) = ?c› ‹guards ((?g::?'f × ?'s set) # (?gs::(?'f × ?'s set) list)) (?c::(?'s, ?'p, ?'f) com) = Guard (fst ?g) (snd ?g) (guards ?gs ?c)›*)) (*goal: ‹⋀Z::'a. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {s::'a. s = Z ∧ s ∈ (P::'a set)} dynCall_exn (f::'d) UNIV (init::'a ⇒ 'a) (p::'a ⇒ 'c) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) (Q::'a set),(A::'a set)›*) apply (rule HoareTotalDef.DynCom (*‹∀s∈?P. ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c s ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*goal: ‹⋀Z. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} DynCom (λs. DynCom (λsa. Seq (Catch (Seq (Basic init) (Call (p s))) (Seq (Basic (λt. result_exn (return sa t) t)) Throw)) (DynCom (λt. Seq (Basic (return sa)) (c sa t))))) Q,A›*) apply clarsimp (*goal: ‹⋀Z. ∀s∈{s. s = Z ∧ s ∈ P}. Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} DynCom (λsa. Seq (Catch (Seq (Basic init) (Call (p s))) (Seq (Basic (λt. result_exn (return sa t) t)) Throw)) (DynCom (λt. Seq (Basic (return sa)) (c sa t)))) Q,A›*) apply (rule HoareTotalDef.DynCom (*‹∀s∈?P. ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c s ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*goal: ‹⋀Z. Z ∈ P ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} DynCom (λs. Seq (Catch (Seq (Basic init) (Call (p Z))) (Seq (Basic (λt. result_exn (return s t) t)) Throw)) (DynCom (λt. Seq (Basic (return s)) (c s t)))) Q,A›*) apply clarsimp (*goal: ‹⋀Z::'a. Z ∈ (P::'a set) ⟹ ∀s::'a∈{s::'a. s = Z ∧ s ∈ P}. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {s::'a. s = Z ∧ s ∈ P} Seq (Catch (Seq (Basic (init::'a ⇒ 'a)) (Call ((p::'a ⇒ 'c) Z))) (Seq (Basic (λt::'a. (result_exn::'a ⇒ 'a ⇒ 'a) ((return::'a ⇒ 'a ⇒ 'a) s t) t)) Throw)) (DynCom (λt::'a. Seq (Basic (return s)) ((c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) s t))) (Q::'a set),(A::'a set)›*) apply (frule in_mono [rule_format, OF adapt] (*‹?x ∈ P ⟹ ?x ∈ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ result_exn (return s t) t ∈ A)}›*)) (*goal: ‹⋀Z. Z ∈ P ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} Seq (Catch (Seq (Basic init) (Call (p Z))) (Seq (Basic (λt. result_exn (return Z t) t)) Throw)) (DynCom (λt. Seq (Basic (return Z)) (c Z t))) Q,A›*) apply clarsimp (*goal: ‹⋀Z::'a. ⟦Z ∈ (P::'a set); Z ∈ {s::'a. ∃Z::'b. (init::'a ⇒ 'a) s ∈ (P'::'a ⇒ 'b ⇒ 'a set) s Z ∧ (∀t::'a. t ∈ (Q'::'a ⇒ 'b ⇒ 'a set) s Z ⟶ (return::'a ⇒ 'a ⇒ 'a) s t ∈ (R::'a ⇒ 'a ⇒ 'a set) s t) ∧ (∀t::'a. t ∈ (A'::'a ⇒ 'b ⇒ 'a set) s Z ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return s t) t ∈ (A::'a set))}⟧ ⟹ (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {s::'a. s = Z ∧ s ∈ P} Seq (Catch (Seq (Basic init) (Call ((p::'a ⇒ 'c) Z))) (Seq (Basic (λt::'a. result_exn (return Z t) t)) Throw)) (DynCom (λt::'a. Seq (Basic (return Z)) ((c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) Z t))) (Q::'a set),A›*) apply (rename_tac Z') (*goal: ‹⋀Z Za. ⟦Z ∈ P; init Z ∈ P' Z Za; ∀t. t ∈ Q' Z Za ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Za ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} Seq (Catch (Seq (Basic init) (Call (p Z))) (Seq (Basic (λt. result_exn (return Z t) t)) Throw)) (DynCom (λt. Seq (Basic (return Z)) (c Z t))) Q,A›*) apply (rule_tac R="Q' Z Z'" in Seq (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) (?c₁::(?'b, ?'a, ?'c) com) (?R::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R (?c₂::(?'b, ?'a, ?'c) com) (?Q::?'b set),?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*goal: ‹⋀(Z::'a) Z'::'b. ⟦Z ∈ (P::'a set); (init::'a ⇒ 'a) Z ∈ (P'::'a ⇒ 'b ⇒ 'a set) Z Z'; ∀t::'a. t ∈ (Q'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (return::'a ⇒ 'a ⇒ 'a) Z t ∈ (R::'a ⇒ 'a ⇒ 'a set) Z t; ∀t::'a. t ∈ (A'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return Z t) t ∈ (A::'a set)⟧ ⟹ (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {s::'a. s = Z ∧ s ∈ P} Seq (Catch (Seq (Basic init) (Call ((p::'a ⇒ 'c) Z))) (Seq (Basic (λt::'a. result_exn (return Z t) t)) Throw)) (DynCom (λt::'a. Seq (Basic (return Z)) ((c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) Z t))) (Q::'a set),A›*) apply (rule CatchSwap (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?R::?'b set) (?c₂::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P::?'b set) (?c₁::(?'b, ?'a, ?'c) com) ?Q,?R⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Catch ?c₁ ?c₂ ?Q,?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} Catch (Seq (Basic init) (Call (p Z))) (Seq (Basic (λt. result_exn (return Z t) t)) Throw) (Q' Z Z'),A› and 1 goal remains*) apply (rule SeqSwap (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c2.0 ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c1.0 ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R32 Z Z') Seq (Basic (λt. result_exn (return Z t) t)) Throw (Q' Z Z'),A› and 2 goals remain*) apply (rule Throw (*‹?P ⊆ ?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Throw ?Q,?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R35 Z Z') Throw (Q' Z Z'),A› and 3 goals remain*) apply (rule subset_refl (*‹?A ⊆ ?A›*)) (*top goal: ‹⋀(Z::'a) Z'::'b. ⟦Z ∈ (P::'a set); (init::'a ⇒ 'a) Z ∈ (P'::'a ⇒ 'b ⇒ 'a set) Z Z'; ∀t::'a. t ∈ (Q'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (return::'a ⇒ 'a ⇒ 'a) Z t ∈ (R::'a ⇒ 'a ⇒ 'a set) Z t; ∀t::'a. t ∈ (A'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return Z t) t ∈ (A::'a set)⟧ ⟹ (?R35::'a ⇒ 'b ⇒ 'a set) Z Z' ⊆ A› and 3 goals remain*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R32 Z Z') Basic (λt. result_exn (return Z t) t) A,A› and 2 goals remain*) apply (rule subset_refl (*‹?A ⊆ ?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ ?R32 Z Z' ⊆ {s. result_exn (return Z s) s ∈ A}› and 2 goals remain*) apply (rule_tac R="{i. i ∈ P' Z Z'}" in Seq (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) (?c₁::(?'b, ?'a, ?'c) com) (?R::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R (?c₂::(?'b, ?'a, ?'c) com) (?Q::?'b set),?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c₁ ?c₂ ?Q,?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. s = Z ∧ s ∈ P} Seq (Basic init) (Call (p Z)) (Q' Z Z'),{s. result_exn (return Z s) s ∈ A}› and 1 goal remains*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀(Z::'a) Z'::'b. ⟦Z ∈ (P::'a set); (init::'a ⇒ 'a) Z ∈ (P'::'a ⇒ 'b ⇒ 'a set) Z Z'; ∀t::'a. t ∈ (Q'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (return::'a ⇒ 'a ⇒ 'a) Z t ∈ (R::'a ⇒ 'a ⇒ 'a set) Z t; ∀t::'a. t ∈ (A'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return Z t) t ∈ (A::'a set)⟧ ⟹ (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {s::'a. s = Z ∧ s ∈ P} Basic init {i::'a. i ∈ P' Z Z'},{s::'a. result_exn (return Z s) s ∈ A}› and 2 goals remain*) apply clarsimp (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ {s. s = Z ∧ s ∈ P} ⊆ {s. init s ∈ {i. i ∈ P' Z Z'}}› and 2 goals remain*) apply simp (*top goal: ‹⋀(Z::'a) Z'::'b. ⟦Z ∈ (P::'a set); (init::'a ⇒ 'a) Z ∈ (P'::'a ⇒ 'b ⇒ 'a set) Z Z'; ∀t::'a. t ∈ (Q'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (return::'a ⇒ 'a ⇒ 'a) Z t ∈ (R::'a ⇒ 'a ⇒ 'a set) Z t; ∀t::'a. t ∈ (A'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return Z t) t ∈ (A::'a set)⟧ ⟹ (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {i::'a. i ∈ P' Z Z'} Call ((p::'a ⇒ 'c) Z) (Q' Z Z'),{s::'a. result_exn (return Z s) s ∈ A}› and 1 goal remains*) apply (rule_tac Q'="Q' Z Z'" and A'="A' Z Z'" in conseqPost (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q'::?'b set),(?A'::?'b set); ?Q' ⊆ (?Q::?'b set); ?A' ⊆ (?A::?'b set)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z Z') Call (p Z) (Q' Z Z'),{s. result_exn (return Z s) s ∈ A}› and 1 goal remains*) using p (*‹∀s∈P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)›*) (*goals: 1. ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P' Z Z') Call (p Z) (Q' Z Z'),(A' Z Z')› 2. ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Q' Z Z' ⊆ Q' Z Z'› 3. ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ A' Z Z' ⊆ {s. result_exn (return Z s) s ∈ A}› 4. ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (Q' Z Z') DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply simp (*discuss goal 3*) apply clarsimp (*discuss goal 4*) apply (rule_tac P'="λZ''. {t. t=Z'' ∧ return Z t ∈ R Z t}" and Q'="λZ''. Q" and A'="λZ''. A" in conseq (*‹⟦∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) ?c (?Q' Z),(?A' Z); ∀s. s ∈ ?P ⟶ (∃Z. s ∈ ?P' Z ∧ ?Q' Z ⊆ ?Q ∧ ?A' Z ⊆ ?A)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ ∀Za. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› 2. ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ ∀s. s ∈ Q' Z Z' ⟶ (∃Za. s ∈ {t. t = Za ∧ return Z t ∈ R Z t} ∧ Q ⊆ Q ∧ A ⊆ A)› discuss goal 1*) apply (rule allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*top goal: ‹⋀Z Z'. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ ∀Za. Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› and 1 goal remains*) apply (rule HoareTotalDef.DynCom (*‹∀s::?'s∈?P::?'s set. (?Γ::?'p ⇒ (?'s, ?'p, ?'f) com option),(?Θ::(?'s set × ?'p × ?'s set × ?'s set) set)⊢⇩t⇘/(?F::?'f set)⇙ ?P (?c::?'s ⇒ (?'s, ?'p, ?'f) com) s (?Q::?'s set),(?A::?'s set) ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P DynCom ?c ?Q,?A›*)) (*top goal: ‹⋀Z Z' Za. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} DynCom (λt. Seq (Basic (return Z)) (c Z t)) Q,A› and 1 goal remains*) apply clarsimp (*top goal: ‹⋀(Z::'a) (Z'::'b) Za::'a. ⟦Z ∈ (P::'a set); (init::'a ⇒ 'a) Z ∈ (P'::'a ⇒ 'b ⇒ 'a set) Z Z'; ∀t::'a. t ∈ (Q'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (return::'a ⇒ 'a ⇒ 'a) Z t ∈ (R::'a ⇒ 'a ⇒ 'a set) Z t; ∀t::'a. t ∈ (A'::'a ⇒ 'b ⇒ 'a set) Z Z' ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return Z t) t ∈ (A::'a set)⟧ ⟹ ∀s::'a∈{t::'a. t = Za ∧ return Z t ∈ R Z t}. (Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ {t::'a. t = Za ∧ return Z t ∈ R Z t} Seq (Basic (return Z)) ((c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) Z s) (Q::'a set),A› and 1 goal remains*) apply (rule SeqSwap (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c2.0 ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c1.0 ?R,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Seq ?c1.0 ?c2.0 ?Q,?A›*)) (*goals: 1. ‹⋀Z Z' Za. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A; return Z Za ∈ R Z Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?R68 Z Z' Za) c Z Za Q,A› 2. ‹⋀Z Z' Za. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A; return Z Za ∈ R Z Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} Basic (return Z) (?R68 Z Z' Za),A› discuss goal 1*) apply (rule c [rule_format] (*‹Γ,Θ⊢⇩t⇘/F⇙ (R ?s ?t) c ?s ?t Q,A›*)) (*discuss goal 2*) apply (rule Basic (*‹?P ⊆ {s. ?f s ∈ ?Q} ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Basic ?f ?Q,?A›*)) (*top goal: ‹⋀Z Z' Za. ⟦Z ∈ P; init Z ∈ P' Z Z'; ∀t. t ∈ Q' Z Z' ⟶ return Z t ∈ R Z t; ∀t. t ∈ A' Z Z' ⟶ result_exn (return Z t) t ∈ A; return Z Za ∈ R Z Za⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {t. t = Za ∧ return Z t ∈ R Z t} Basic (return Z) (R Z Za),A› and 1 goal remains*) apply clarsimp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 4 subgoals*) . lemma DynProc_exn_guards_cons: assumes p: "Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A" shows "Γ,Θ⊢⇩t⇘/F⇙ (g ∩ P) dynCall_exn f g init p return result_exn c Q,A" using p (*‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) apply (clarsimp simp add: dynCall_exn_def (*‹dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c = maybe_guard ?f ?g (DynCom (λs. call_exn ?init (?p s) ?return ?result_exn ?c))›*) maybe_guard_def (*‹maybe_guard ?f ?g ?c = (if ?g = UNIV then ?c else Guard ?f ?g ?c)›*)) (*goal: ‹(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ ((g::'b set) ∩ (P::'b set)) dynCall_exn (f::'c) g (init::'b ⇒ 'b) (p::'b ⇒ 'a) (return::'b ⇒ 'b ⇒ 'b) (result_exn::'b ⇒ 'b ⇒ 'b) (c::'b ⇒ 'b ⇒ ('b, 'a, 'c) com) (Q::'b set),(A::'b set)›*) apply (rule Guard (*‹⟦?P ⊆ ?g ∩ ?R; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?R ?c ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Guard ?f ?g ?c ?Q,?A›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P DynCom (λs. call_exn init (p s) return result_exn c) Q,A; g ≠ UNIV⟧ ⟹ g ∩ P ⊆ g ∩ ?R7› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P DynCom (λs. call_exn init (p s) return result_exn c) Q,A; g ≠ UNIV⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?R7 DynCom (λs. call_exn init (p s) return result_exn c) Q,A› discuss goal 1*) apply (rule subset_refl (*‹?A ⊆ ?A›*)) (*discuss goal 2*) apply assumption (*proven 2 subgoals*) . lemma DynProc: assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ return s t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀s∈ P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P dynCall init p return c Q,A" using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ return s t ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) p (*‹∀s∈P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule DynProc_exn (*‹⟦(?P::?'a::type set) ⊆ {s::?'a::type. ∃Z::?'b::type. (?init::?'a::type ⇒ ?'a::type) s ∈ (?P'::?'a::type ⇒ ?'b::type ⇒ ?'a::type set) s Z ∧ (∀t::?'a::type. t ∈ (?Q'::?'a::type ⇒ ?'b::type ⇒ ?'a::type set) s Z ⟶ (?return::?'a::type ⇒ ?'a::type ⇒ ?'a::type) s t ∈ (?R::?'a::type ⇒ ?'a::type ⇒ ?'a::type set) s t) ∧ (∀t::?'a::type. t ∈ (?A'::?'a::type ⇒ ?'b::type ⇒ ?'a::type set) s Z ⟶ (?result_exn::?'a::type ⇒ ?'a::type ⇒ ?'a::type) (?return s t) t ∈ (?A::?'a::type set))}; ∀(s::?'a::type) t::?'a::type. (?Γ::?'c::type ⇒ (?'a::type, ?'c::type, ?'d::type) com option),(?Θ::(?'a::type set × ?'c::type × ?'a::type set × ?'a::type set) set)⊢⇩t⇘/(?F::?'d::type set)⇙ (?R s t) (?c::?'a::type ⇒ ?'a::type ⇒ (?'a::type, ?'c::type, ?'d::type) com) s t (?Q::?'a::type set),?A; ∀s::?'a::type∈?P. ∀Z::?'b::type. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' s Z) Call ((?p::?'a::type ⇒ ?'c::type) s) (?Q' s Z),(?A' s Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn (?f::?'d::type) UNIV ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma DynProc_exn': assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t ∈ Q' s Z. return s t ∈ R s t) ∧ (∀t ∈ A' s Z. result_exn (return s t) t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀s∈ P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A" proof (-) (*goal: ‹(Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ (P::'a set) dynCall_exn (f::'d) UNIV (init::'a ⇒ 'a) (p::'a ⇒ 'c) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) (Q::'a set),(A::'a set)›*) from adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t∈Q' s Z. return s t ∈ R s t) ∧ (∀t∈A' s Z. result_exn (return s t) t ∈ A)}›*) have "P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ result_exn (return s t) t ∈ A)}" by blast from this (*‹P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t. t ∈ Q' s Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' s Z ⟶ result_exn (return s t) t ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) p (*‹∀s∈P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)›*) show "?thesis" (*goal: ‹(Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ (P::'a::type set) dynCall_exn (f::'d::type) UNIV (init::'a::type ⇒ 'a::type) (p::'a::type ⇒ 'c::type) (return::'a::type ⇒ 'a::type ⇒ 'a::type) (result_exn::'a::type ⇒ 'a::type ⇒ 'a::type) (c::'a::type ⇒ 'a::type ⇒ ('a::type, 'c::type, 'd::type) com) (Q::'a::type set),(A::'a::type set)›*) by (rule DynProc_exn (*‹⟦(?P::?'a::type set) ⊆ {s::?'a::type. ∃Z::?'b::type. (?init::?'a::type ⇒ ?'a::type) s ∈ (?P'::?'a::type ⇒ ?'b::type ⇒ ?'a::type set) s Z ∧ (∀t::?'a::type. t ∈ (?Q'::?'a::type ⇒ ?'b::type ⇒ ?'a::type set) s Z ⟶ (?return::?'a::type ⇒ ?'a::type ⇒ ?'a::type) s t ∈ (?R::?'a::type ⇒ ?'a::type ⇒ ?'a::type set) s t) ∧ (∀t::?'a::type. t ∈ (?A'::?'a::type ⇒ ?'b::type ⇒ ?'a::type set) s Z ⟶ (?result_exn::?'a::type ⇒ ?'a::type ⇒ ?'a::type) (?return s t) t ∈ (?A::?'a::type set))}; ∀(s::?'a::type) t::?'a::type. (?Γ::?'c::type ⇒ (?'a::type, ?'c::type, ?'d::type) com option),(?Θ::(?'a::type set × ?'c::type × ?'a::type set × ?'a::type set) set)⊢⇩t⇘/(?F::?'d::type set)⇙ (?R s t) (?c::?'a::type ⇒ ?'a::type ⇒ (?'a::type, ?'c::type, ?'d::type) com) s t (?Q::?'a::type set),?A; ∀s::?'a::type∈?P. ∀Z::?'b::type. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' s Z) Call ((?p::?'a::type ⇒ ?'c::type) s) (?Q' s Z),(?A' s Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn (?f::?'d::type) UNIV ?init ?p ?return ?result_exn ?c ?Q,?A›*)) qed lemma DynProc': assumes adapt: "P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t ∈ Q' s Z. return s t ∈ R s t) ∧ (∀t ∈ A' s Z. return s t ∈ A)}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes p: "∀s∈ P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' s Z) Call (p s) (Q' s Z),(A' s Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P dynCall init p return c Q,A" using adapt (*‹P ⊆ {s. ∃Z. init s ∈ P' s Z ∧ (∀t∈Q' s Z. return s t ∈ R s t) ∧ (∀t∈A' s Z. return s t ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) p (*‹∀s::'a::type∈P::'a::type set. ∀Z::'b::type. (Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ ((P'::'a::type ⇒ 'b::type ⇒ 'a::type set) s Z) Call ((p::'a::type ⇒ 'c::type) s) ((Q'::'a::type ⇒ 'b::type ⇒ 'a::type set) s Z),((A'::'a::type ⇒ 'b::type ⇒ 'a::type set) s Z)›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule DynProc_exn' (*‹⟦?P ⊆ {s. ∃Z. ?init s ∈ ?P' s Z ∧ (∀t∈?Q' s Z. ?return s t ∈ ?R s t) ∧ (∀t∈?A' s Z. ?result_exn (?return s t) t ∈ ?A)}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A; ∀s∈?P. ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' s Z) Call (?p s) (?Q' s Z),(?A' s Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f UNIV ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma DynProc_exnStaticSpec: assumes adapt: "P ⊆ {s. s ∈ S ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ result_exn (return s τ) τ ∈ A))}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes spec: "∀s∈S. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (p s) (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f UNIV init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) from adapt (*‹P ⊆ {s ∈ S. ∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ result_exn (return s τ) τ ∈ A)}›*) have P_S: "P ⊆ S" by blast have "Γ,Θ⊢⇩t⇘/F⇙ (P ∩ S) (dynCall_exn f UNIV init p return result_exn c) Q,A" apply (rule DynProc_exn [where P'="λs Z. P' Z" and Q'="λs Z. Q' Z" and A'="λs Z. A' Z", OF _ c] (*‹⟦?P ⊆ {s. ∃Z. ?init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ ?return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ ?result_exn (?return s t) t ∈ A)}; ∀s∈?P. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (?p s) (Q' Z),(A' Z)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ ?P dynCall_exn ?f UNIV ?init ?p ?return ?result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ (P ∩ S) dynCall_exn f UNIV init p return result_exn c Q,A›*) apply clarsimp (*top goal: ‹P ∩ S ⊆ {s. ∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return s t) t ∈ A)}› and 1 goal remains*) apply (frule in_mono [rule_format, OF adapt] (*‹(?x::'a) ∈ (P::'a set) ⟹ ?x ∈ {s::'a ∈ S::'a set. ∃Z::'b. (init::'a ⇒ 'a) s ∈ (P'::'b ⇒ 'a set) Z ∧ (∀τ::'a. τ ∈ (Q'::'b ⇒ 'a set) Z ⟶ (return::'a ⇒ 'a ⇒ 'a) s τ ∈ (R::'a ⇒ 'a ⇒ 'a set) s τ) ∧ (∀τ::'a. τ ∈ (A'::'b ⇒ 'a set) Z ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) (return s τ) τ ∈ (A::'a set))}›*)) (*top goal: ‹⋀x. ⟦x ∈ P; x ∈ S⟧ ⟹ ∃Z. init x ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return x t ∈ R x t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return x t) t ∈ A)› and 1 goal remains*) apply clarsimp (*top goal: ‹⋀x. ⟦x ∈ P; x ∈ S; x ∈ {s ∈ S. ∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ result_exn (return s τ) τ ∈ A)}⟧ ⟹ ∃Z. init x ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return x t ∈ R x t) ∧ (∀t. t ∈ A' Z ⟶ result_exn (return x t) t ∈ A)› and 1 goal remains*) using spec (*‹∀s∈S. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (p s) (Q' Z),(A' Z)›*) by clarsimp thus "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹(Γ::'c ⇒ ('a, 'c, 'd) com option),(Θ::('a set × 'c × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ (P::'a set) dynCall_exn (f::'d) UNIV (init::'a ⇒ 'a) (p::'a ⇒ 'c) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'c, 'd) com) (Q::'a set),(A::'a set)›*) apply (insert P_S (*‹(P::'a set) ⊆ (S::'a set)›*)) (*goal: ‹(P::'a set) ⊆ P ∩ (S::'a set)›*) by blast qed lemma DynProcStaticSpec: assumes adapt: "P ⊆ {s. s ∈ S ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ return s τ ∈ A))}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes spec: "∀s∈S. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (p s) (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using adapt (*‹P ⊆ {s ∈ S. ∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ return s τ ∈ A)}›*) c (*‹∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) c s t Q,A›*) spec (*‹∀s∈S. ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (p s) (Q' Z),(A' Z)›*) unfolding dynCall_dynCall_exn (*goal: ‹(Γ::'c::type ⇒ ('a::type, 'c::type, 'd::type) com option),(Θ::('a::type set × 'c::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'d::type set)⇙ (P::'a::type set) dynCall_exn undefined UNIV (init::'a::type ⇒ 'a::type) (p::'a::type ⇒ 'c::type) (return::'a::type ⇒ 'a::type ⇒ 'a::type) (λ(s::'a::type) t::'a::type. s) (c::'a::type ⇒ 'a::type ⇒ ('a::type, 'c::type, 'd::type) com) (Q::'a::type set),(A::'a::type set)›*) by (rule DynProc_exnStaticSpec (*‹⟦(?P::?'a set) ⊆ {s::?'a ∈ ?S::?'a set. ∃Z::?'b. (?init::?'a ⇒ ?'a) s ∈ (?P'::?'b ⇒ ?'a set) Z ∧ (∀τ::?'a. τ ∈ (?Q'::?'b ⇒ ?'a set) Z ⟶ (?return::?'a ⇒ ?'a ⇒ ?'a) s τ ∈ (?R::?'a ⇒ ?'a ⇒ ?'a set) s τ) ∧ (∀τ::?'a. τ ∈ (?A'::?'b ⇒ ?'a set) Z ⟶ (?result_exn::?'a ⇒ ?'a ⇒ ?'a) (?return s τ) τ ∈ (?A::?'a set))}; ∀(s::?'a) t::?'a. (?Γ::?'c ⇒ (?'a, ?'c, ?'d) com option),(?Θ::(?'a set × ?'c × ?'a set × ?'a set) set)⊢⇩t⇘/(?F::?'d set)⇙ (?R s t) (?c::?'a ⇒ ?'a ⇒ (?'a, ?'c, ?'d) com) s t (?Q::?'a set),?A; ∀s::?'a∈?S. ∀Z::?'b. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) Call ((?p::?'a ⇒ ?'c) s) (?Q' Z),(?A' Z)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn (?f::?'d) UNIV ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma DynProc_exnProcPar: assumes adapt: "P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ result_exn (return s τ) τ ∈ A))}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes spec: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f UNIV init p return result_exn c) Q,A" apply (rule DynProc_exnStaticSpec [where S="{s. p s = q}",simplified, OF adapt c] (*‹∀s. p s = q ⟶ (∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (?p s) (Q' Z),(A' Z)) ⟹ Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn ?f UNIV init ?p return result_exn c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) using spec (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),(A' Z)›*) by simp lemma DynProcProcPar: assumes adapt: "P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ) ∧ (∀τ. τ ∈ A' Z ⟶ return s τ ∈ A))}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes spec: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),(A' Z)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" apply (rule DynProcStaticSpec [where S="{s. p s = q}",simplified, OF adapt c] (*‹∀s. p s = q ⟶ (∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call (?p s) (Q' Z),(A' Z)) ⟹ Γ,Θ⊢⇩t⇘/F⇙ P dynCall init ?p return c Q,A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall init p return c Q,A›*) using spec (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),(A' Z)›*) by simp lemma DynProc_exnProcParNoAbrupt: assumes adapt: "P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ))}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes spec: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f UNIV init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) have "P ⊆ {s. p s = q ∧ (∃ Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ {} ⟶ result_exn (return s t) t ∈ A))}" (is "P ⊆ ?P'") proof (standard) (*goal: ‹⋀x. x ∈ P ⟹ x ∈ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ {} ⟶ result_exn (return s t) t ∈ A))}›*) fix s assume P: "s∈P" (*‹(s::'a) ∈ (P::'a set)›*) with adapt (*‹P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ))}›*) obtain Z where Pre: "p s = q ∧ init s ∈ P' Z" and adapt_Norm: "∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ" (*goal: ‹(⋀Z. ⟦p s = q ∧ init s ∈ P' Z; ∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ⟧ ⟹ thesis) ⟹ thesis›*) by blast from adapt_Norm (*‹∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ›*) have "∀t. t ∈ Q' Z ⟶ return s t ∈ R s t" by auto then show "s∈?P'" using Pre (*‹p s = q ∧ init s ∈ P' Z›*) by blast qed note P = this (*‹P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀t. t ∈ Q' Z ⟶ return s t ∈ R s t) ∧ (∀t. t ∈ {} ⟶ result_exn (return s t) t ∈ A))}›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) apply - (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) apply (rule DynProc_exnStaticSpec [where S="{s. p s = q}",simplified, OF P c] (*‹∀s::'a. (p::'a ⇒ 'b) s = (q::'b) ⟶ (∀Z::'c. (Γ::'b ⇒ ('a, 'b, 'd) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ ((P'::'c ⇒ 'a set) Z) Call ((?p::'a ⇒ 'b) s) ((Q'::'c ⇒ 'a set) Z),{}) ⟹ Γ,Θ⊢⇩t⇘/F⇙ (P::'a set) dynCall_exn (?f::'d) UNIV (init::'a ⇒ 'a) ?p (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'd) com) (Q::'a set),(A::'a set)›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f UNIV init p return result_exn c Q,A›*) apply (insert spec (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),{}›*)) (*goal: ‹∀s::'a. (p::'a ⇒ 'b) s = (q::'b) ⟶ (∀Z::'c. (Γ::'b ⇒ ('a, 'b, 'd) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ ((P'::'c ⇒ 'a set) Z) Call (p s) ((Q'::'c ⇒ 'a set) Z),{})›*) by auto qed lemma DynProcProcParNoAbrupt: assumes adapt: "P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ))}" assumes c: "∀s t. Γ,Θ⊢⇩t⇘/F⇙ (R s t) (c s t) Q,A" assumes spec: "∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using adapt (*‹P ⊆ {s. p s = q ∧ (∃Z. init s ∈ P' Z ∧ (∀τ. τ ∈ Q' Z ⟶ return s τ ∈ R s τ))}›*) c (*‹∀(s::'a) t::'a. (Γ::'b ⇒ ('a, 'b, 'd) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'d set)⇙ ((R::'a ⇒ 'a ⇒ 'a set) s t) (c::'a ⇒ 'a ⇒ ('a, 'b, 'd) com) s t (Q::'a set),(A::'a set)›*) spec (*‹∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P' Z) Call q (Q' Z),{}›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule DynProc_exnProcParNoAbrupt (*‹⟦?P ⊆ {s. ?p s = ?q ∧ (∃Z. ?init s ∈ ?P' Z ∧ (∀τ. τ ∈ ?Q' Z ⟶ ?return s τ ∈ ?R s τ))}; ∀s t. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?R s t) ?c s t ?Q,?A; ∀Z. ?Γ,?Θ⊢⇩t⇘/?F⇙ (?P' Z) Call ?q (?Q' Z),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f UNIV ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma DynProc_exnModifyReturnNoAbr: assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return' result_exn c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀s ∈ P. ∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} Call (p s) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) from ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) have "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" by iprover then have ret_nrm_modif': "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" by simp have ret_abr_modif': "∀s t. t ∈ {} ⟶ result_exn (return' s t) t = result_exn (return s t) t" by simp from to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return' result_exn c Q,A›*) ret_nrm_modif' (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) ret_abr_modif' (*‹∀(s::'b) t::'b. t ∈ {} ⟶ (result_exn::'b ⇒ 'b ⇒ 'b) ((return'::'b ⇒ 'b ⇒ 'b) s t) t = result_exn ((return::'b ⇒ 'b ⇒ 'b) s t) t›*) modif_clause (*‹∀s::'b∈P::'b set. ∀σ::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇘/UNIV ⇙{σ} Call ((p::'b ⇒ 'a) s) ((Modif::'b ⇒ 'b set) σ),{}›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) by (rule dynProc_exnModifyReturn (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s t. t ∈ ?ModifAbr (?init s) ⟶ ?result_exn (?return' s t) t = ?result_exn (?return s t) t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/UNIV ⇙{σ} Call (?p s) (?Modif σ),(?ModifAbr σ)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) qed lemma DynProcModifyReturnNoAbr: assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return' c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀s ∈ P. ∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} Call (p s) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall init p return' c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) modif_clause (*‹∀s::'b∈P::'b set. ∀σ::'b. (Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇘/UNIV ⇙{σ} Call ((p::'b ⇒ 'a) s) ((Modif::'b ⇒ 'b set) σ),{}›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule DynProc_exnModifyReturnNoAbr (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/UNIV ⇙{σ} Call (?p s) (?Modif σ),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma ProcDyn_exnModifyReturnNoAbrSameFaults: assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return' result_exn c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀s ∈ P. ∀σ. Γ,Θ⊢⇘/F⇙ {σ} (Call (p s)) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) from ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) have "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" by iprover then have ret_nrm_modif': "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" by simp have ret_abr_modif': "∀s t. t ∈ {} ⟶ result_exn (return' s t) t = result_exn (return s t) t" by simp from to_prove (*‹(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'b set) dynCall_exn (f::'c) (g::'b set) (init::'b ⇒ 'b) (p::'b ⇒ 'a) (return'::'b ⇒ 'b ⇒ 'b) (result_exn::'b ⇒ 'b ⇒ 'b) (c::'b ⇒ 'b ⇒ ('b, 'a, 'c) com) (Q::'b set),(A::'b set)›*) ret_nrm_modif' (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) ret_abr_modif' (*‹∀(s::'b::type) t::'b::type. t ∈ {} ⟶ (result_exn::'b::type ⇒ 'b::type ⇒ 'b::type) ((return'::'b::type ⇒ 'b::type ⇒ 'b::type) s t) t = result_exn ((return::'b::type ⇒ 'b::type ⇒ 'b::type) s t) t›*) modif_clause (*‹∀s∈P. ∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call (p s) (Modif σ),{}›*) show "?thesis" (*goal: ‹(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'b set) dynCall_exn (f::'c) (g::'b set) (init::'b ⇒ 'b) (p::'b ⇒ 'a) (return::'b ⇒ 'b ⇒ 'b) (result_exn::'b ⇒ 'b ⇒ 'b) (c::'b ⇒ 'b ⇒ ('b, 'a, 'c) com) (Q::'b set),(A::'b set)›*) by (rule dynProc_exnModifyReturnSameFaults (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s t. t ∈ ?ModifAbr (?init s) ⟶ ?result_exn (?return' s t) t = ?result_exn (?return s t) t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/?F ⇙{σ} Call (?p s) (?Modif σ),(?ModifAbr σ)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) qed lemma ProcDynModifyReturnNoAbrSameFaults: assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return' c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀s ∈ P. ∀σ. Γ,Θ⊢⇘/F⇙ {σ} (Call (p s)) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall init p return' c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) modif_clause (*‹∀s∈P. ∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call (p s) (Modif σ),{}›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule ProcDyn_exnModifyReturnNoAbrSameFaults (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/?F ⇙{σ} Call (?p s) (?Modif σ),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma Proc_exnProcParModifyReturn: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcPar} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall_exn f g init p return' result_exn c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes ret_abr_modif: "∀s t. t ∈ (ModifAbr (init s)) ⟶ result_exn (return' s t) t = result_exn (return s t) t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} (Call q) (Modif σ),(ModifAbr σ)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return result_exn c) Q,A" proof (-) (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) (p::'a ⇒ 'b) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) from to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P' dynCall_exn f g init p return' result_exn c Q,A›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return' result_exn c) Q,A" apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) by blast from this (*‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) ret_abr_modif (*‹∀s t. t ∈ ModifAbr (init s) ⟶ result_exn (return' s t) t = result_exn (return s t) t›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return result_exn c) Q,A" apply (rule dynProc_exnModifyReturn (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s t. t ∈ ?ModifAbr (?init s) ⟶ ?result_exn (?return' s t) t = ?result_exn (?return s t) t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/UNIV ⇙{σ} Call (?p s) (?Modif σ),(?ModifAbr σ)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ ({s::'a. (p::'a ⇒ 'b) s = (q::'b)} ∩ (P'::'a set)) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) p (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) apply (insert modif_clause (*‹∀σ::'a. (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇘/UNIV ⇙{σ} Call (q::'b) ((Modif::'a ⇒ 'a set) σ),((ModifAbr::'a ⇒ 'a set) σ)›*)) (*goal: ‹∀s∈{s. p s = q} ∩ P'. ∀σ. Γ,Θ⊢⇘/UNIV ⇙{σ} Call (p s) (Modif σ),(ModifAbr σ)›*) by auto from this (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ ({s::'a. (p::'a ⇒ 'b) s = (q::'b)} ∩ (P'::'a set)) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) p (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) q (*‹P ⊆ {s. p s = q} ∩ P'›*) show "?thesis" (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) (p::'a ⇒ 'b) (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) by (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) qed lemma ProcProcParModifyReturn: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcPar} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall init p return' c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes ret_abr_modif: "∀s t. t ∈ (ModifAbr (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} (Call q) (Modif σ),(ModifAbr σ)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using q (*‹P ⊆ {s. p s = q} ∩ P'›*) to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P' dynCall init p return' c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) ret_abr_modif (*‹∀s t. t ∈ ModifAbr (init s) ⟶ return' s t = return s t›*) modif_clause (*‹∀σ. Γ,Θ⊢⇘/UNIV ⇙{σ} Call q (Modif σ),(ModifAbr σ)›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule Proc_exnProcParModifyReturn (*‹⟦(?P::?'a set) ⊆ {s::?'a. (?p::?'a ⇒ ?'b) s = (?q::?'b)} ∩ (?P'::?'a set); (?Γ::?'b ⇒ (?'a, ?'b, ?'c) com option),(?Θ::(?'a set × ?'b × ?'a set × ?'a set) set)⊢⇩t⇘/(?F::?'c set)⇙ ?P' dynCall_exn (?f::?'c) (?g::?'a set) (?init::?'a ⇒ ?'a) ?p (?return'::?'a ⇒ ?'a ⇒ ?'a) (?result_exn::?'a ⇒ ?'a ⇒ ?'a) (?c::?'a ⇒ ?'a ⇒ (?'a, ?'b, ?'c) com) (?Q::?'a set),(?A::?'a set); ∀(s::?'a) t::?'a. t ∈ (?Modif::?'a ⇒ ?'a set) (?init s) ⟶ ?return' s t = (?return::?'a ⇒ ?'a ⇒ ?'a) s t; ∀(s::?'a) t::?'a. t ∈ (?ModifAbr::?'a ⇒ ?'a set) (?init s) ⟶ ?result_exn (?return' s t) t = ?result_exn (?return s t) t; ∀σ::?'a. ?Γ,?Θ⊢⇘/UNIV ⇙{σ} Call ?q (?Modif σ),(?ModifAbr σ)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma Proc_exnProcParModifyReturnSameFaults: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcPar} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall_exn f g init p return' result_exn c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes ret_abr_modif: "∀s t. t ∈ (ModifAbr (init s)) ⟶ result_exn (return' s t) t = result_exn (return s t) t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/F⇙ {σ} Call q (Modif σ),(ModifAbr σ)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) from to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P' dynCall_exn f g init p return' result_exn c Q,A›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return' result_exn c) Q,A" apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) by blast from this (*‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) ret_nrm_modif (*‹∀(s::'a) t::'a. t ∈ (Modif::'a ⇒ 'a set) ((init::'a ⇒ 'a) s) ⟶ (return'::'a ⇒ 'a ⇒ 'a) s t = (return::'a ⇒ 'a ⇒ 'a) s t›*) ret_abr_modif (*‹∀(s::'a) t::'a. t ∈ (ModifAbr::'a ⇒ 'a set) ((init::'a ⇒ 'a) s) ⟶ (result_exn::'a ⇒ 'a ⇒ 'a) ((return'::'a ⇒ 'a ⇒ 'a) s t) t = result_exn ((return::'a ⇒ 'a ⇒ 'a) s t) t›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return result_exn c) Q,A" apply (rule dynProc_exnModifyReturnSameFaults (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s t. t ∈ ?ModifAbr (?init s) ⟶ ?result_exn (?return' s t) t = ?result_exn (?return s t) t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/?F ⇙{σ} Call (?p s) (?Modif σ),(?ModifAbr σ)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return result_exn c Q,A›*) apply (insert modif_clause (*‹∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call q (Modif σ),(ModifAbr σ)›*)) (*goal: ‹∀s∈{s. p s = q} ∩ P'. ∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call (p s) (Modif σ),(ModifAbr σ)›*) by auto from this (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ ({s::'a. (p::'a ⇒ 'b) s = (q::'b)} ∩ (P'::'a set)) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) p (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) q (*‹P ⊆ {s. p s = q} ∩ P'›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) by (rule conseqPre (*‹⟦(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option),(?Θ::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⊢⇩t⇘/(?F::?'c::type set)⇙ (?P'::?'b::type set) (?c::(?'b::type, ?'a::type, ?'c::type) com) (?Q::?'b::type set),(?A::?'b::type set); (?P::?'b::type set) ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) qed lemma ProcProcParModifyReturnSameFaults: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcPar} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall init p return' c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes ret_abr_modif: "∀s t. t ∈ (ModifAbr (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/F⇙ {σ} Call q (Modif σ),(ModifAbr σ)" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using q (*‹P ⊆ {s. p s = q} ∩ P'›*) to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P' dynCall init p return' c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) ret_abr_modif (*‹∀(s::'a) t::'a. t ∈ (ModifAbr::'a ⇒ 'a set) ((init::'a ⇒ 'a) s) ⟶ (return'::'a ⇒ 'a ⇒ 'a) s t = (return::'a ⇒ 'a ⇒ 'a) s t›*) modif_clause (*‹∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call q (Modif σ),(ModifAbr σ)›*) unfolding dynCall_dynCall_exn (*goal: ‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) dynCall_exn undefined UNIV (init::'a ⇒ 'a) (p::'a ⇒ 'b) (return::'a ⇒ 'a ⇒ 'a) (λ(s::'a) t::'a. s) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) by (rule Proc_exnProcParModifyReturnSameFaults (*‹⟦?P ⊆ {s. ?p s = ?q} ∩ ?P'; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s t. t ∈ ?ModifAbr (?init s) ⟶ ?result_exn (?return' s t) t = ?result_exn (?return s t) t; ∀σ. ?Γ,?Θ⊢⇘/?F ⇙{σ} Call ?q (?Modif σ),(?ModifAbr σ)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma Proc_exnProcParModifyReturnNoAbr: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcParNoAbrupt} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall_exn f g init p return' result_exn c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} (Call q) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) from to_prove (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P'::'a set) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) (p::'a ⇒ 'b) (return'::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return' result_exn c) Q,A" apply (rule conseqPre (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P'::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); (?P::?'b set) ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) by blast from this (*‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return result_exn c) Q,A" apply (rule DynProc_exnModifyReturnNoAbr (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) dynCall_exn (?f::?'c) (?g::?'b set) (?init::?'b ⇒ ?'b) (?p::?'b ⇒ ?'a) (?return'::?'b ⇒ ?'b ⇒ ?'b) (?result_exn::?'b ⇒ ?'b ⇒ ?'b) (?c::?'b ⇒ ?'b ⇒ (?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ∀(s::?'b) t::?'b. t ∈ (?Modif::?'b ⇒ ?'b set) (?init s) ⟶ ?return' s t = (?return::?'b ⇒ ?'b ⇒ ?'b) s t; ∀s::?'b∈?P. ∀σ::?'b. ?Γ,?Θ⊢⇘/UNIV ⇙{σ} Call (?p s) (?Modif σ),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return result_exn c Q,A›*) apply (insert modif_clause (*‹∀σ. Γ,Θ⊢⇘/UNIV ⇙{σ} Call q (Modif σ),{}›*)) (*goal: ‹∀s∈{s. p s = q} ∩ P'. ∀σ. Γ,Θ⊢⇘/UNIV ⇙{σ} Call (p s) (Modif σ),{}›*) by auto from this (*‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return result_exn c Q,A›*) q (*‹P ⊆ {s. p s = q} ∩ P'›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) by (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) qed lemma ProcProcParModifyReturnNoAbr: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcParNoAbrupt} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall init p return' c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/UNIV⇙ {σ} (Call q) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using q (*‹(P::'a set) ⊆ {s::'a. (p::'a ⇒ 'b) s = (q::'b)} ∩ (P'::'a set)›*) to_prove (*‹(Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (P'::'a::type set) dynCall (init::'a::type ⇒ 'a::type) (p::'a::type ⇒ 'b::type) (return'::'a::type ⇒ 'a::type ⇒ 'a::type) (c::'a::type ⇒ 'a::type ⇒ ('a::type, 'b::type, 'c::type) com) (Q::'a::type set),(A::'a::type set)›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) modif_clause (*‹∀σ. Γ,Θ⊢⇘/UNIV ⇙{σ} Call q (Modif σ),{}›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule Proc_exnProcParModifyReturnNoAbr (*‹⟦?P ⊆ {s. ?p s = ?q} ∩ ?P'; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀σ. ?Γ,?Θ⊢⇘/UNIV ⇙{σ} Call ?q (?Modif σ),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma Proc_exnProcParModifyReturnNoAbrSameFaults: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcParNoAbrupt} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall_exn f g init p return' result_exn c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/F⇙ {σ} (Call q) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall_exn f g init p return result_exn c) Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) from to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P' dynCall_exn f g init p return' result_exn c Q,A›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return' result_exn c) Q,A" apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return' result_exn c Q,A›*) by blast from this (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ ({s::'a. (p::'a ⇒ 'b) s = (q::'b)} ∩ (P'::'a set)) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) p (return'::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) have "Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') (dynCall_exn f g init p return result_exn c) Q,A" apply (rule ProcDyn_exnModifyReturnNoAbrSameFaults (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀s∈?P. ∀σ. ?Γ,?Θ⊢⇘/?F ⇙{σ} Call (?p s) (?Modif σ),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ ({s. p s = q} ∩ P') dynCall_exn f g init p return result_exn c Q,A›*) apply (insert modif_clause (*‹∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call q (Modif σ),{}›*)) (*goal: ‹∀s∈{s. p s = q} ∩ P'. ∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call (p s) (Modif σ),{}›*) by auto from this (*‹(Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ ({s::'a. (p::'a ⇒ 'b) s = (q::'b)} ∩ (P'::'a set)) dynCall_exn (f::'c) (g::'a set) (init::'a ⇒ 'a) p (return::'a ⇒ 'a ⇒ 'a) (result_exn::'a ⇒ 'a ⇒ 'a) (c::'a ⇒ 'a ⇒ ('a, 'b, 'c) com) (Q::'a set),(A::'a set)›*) q (*‹P ⊆ {s. p s = q} ∩ P'›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn f g init p return result_exn c Q,A›*) by (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) qed lemma ProcProcParModifyReturnNoAbrSameFaults: assumes q: "P ⊆ {s. p s = q} ∩ P'" ― ‹@{thm[source] DynProcProcParNoAbrupt} introduces the same constraint as first conjunction in @{term P'}, so the vcg can simplify it.› assumes to_prove: "Γ,Θ⊢⇩t⇘/F⇙ P' (dynCall init p return' c) Q,A" assumes ret_nrm_modif: "∀s t. t ∈ (Modif (init s)) ⟶ return' s t = return s t" assumes modif_clause: "∀σ. Γ,Θ⊢⇘/F⇙ {σ} (Call q) (Modif σ),{}" shows "Γ,Θ⊢⇩t⇘/F⇙ P (dynCall init p return c) Q,A" using q (*‹P ⊆ {s. p s = q} ∩ P'›*) to_prove (*‹Γ,Θ⊢⇩t⇘/F⇙ P' dynCall init p return' c Q,A›*) ret_nrm_modif (*‹∀s t. t ∈ Modif (init s) ⟶ return' s t = return s t›*) modif_clause (*‹∀σ. Γ,Θ⊢⇘/F ⇙{σ} Call q (Modif σ),{}›*) unfolding dynCall_dynCall_exn (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P dynCall_exn undefined UNIV init p return (λs t. s) c Q,A›*) by (rule Proc_exnProcParModifyReturnNoAbrSameFaults (*‹⟦?P ⊆ {s. ?p s = ?q} ∩ ?P'; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' dynCall_exn ?f ?g ?init ?p ?return' ?result_exn ?c ?Q,?A; ∀s t. t ∈ ?Modif (?init s) ⟶ ?return' s t = ?return s t; ∀σ. ?Γ,?Θ⊢⇘/?F ⇙{σ} Call ?q (?Modif σ),{}⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P dynCall_exn ?f ?g ?init ?p ?return ?result_exn ?c ?Q,?A›*)) lemma MergeGuards_iff: "Γ,Θ⊢⇩t⇘/F⇙ P merge_guards c Q,A = Γ,Θ⊢⇩t⇘/F⇙ P c Q,A" by (auto intro: MergeGuardsI (*‹(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set) ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P merge_guards ?c ?Q,?A›*) MergeGuardsD (*‹(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) merge_guards (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set) ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) lemma CombineStrip': assumes deriv: "Γ,Θ⊢⇩t⇘/F⇙ P c' Q,A" assumes deriv_strip_triv: "Γ,{}⊢⇘/{}⇙ P c'' UNIV,UNIV" assumes c'': "c''= mark_guards False (strip_guards (-F) c')" assumes c: "merge_guards c = merge_guards (mark_guards False c')" shows "Γ,Θ⊢⇩t⇘/{}⇙ P c Q,A" proof (-) (*goal: ‹(Γ::'a ⇒ ('b, 'a, bool) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/{}⇙ (P::'b set) (c::('b, 'a, bool) com) (Q::'b set),(A::'b set)›*) from deriv_strip_triv (*‹Γ,{}⊢⇘/{} ⇙P c'' UNIV,UNIV›*) have deriv_strip: "Γ,Θ⊢⇘/{}⇙ P c'' UNIV,UNIV" by (auto intro: hoare_augment_context (*‹⟦?Γ,?Θ⊢⇘/?F ⇙?P ?p ?Q,?A; ?Θ ⊆ ?Θ'⟧ ⟹ ?Γ,?Θ'⊢⇘/?F ⇙?P ?p ?Q,?A›*)) from deriv_strip[simplified c''] (*‹Γ,Θ⊢⇘/{} ⇙P mark_guards False (strip_guards (- F) c') UNIV,UNIV›*) have "Γ,Θ⊢⇘/{}⇙ P (strip_guards (- F) c') UNIV,UNIV" by (rule HoarePartialProps.MarkGuardsD (*‹(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇘/{} ⇙(?P::?'b set) mark_guards (?f::?'c) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set) ⟹ ?Γ,?Θ⊢⇘/{} ⇙?P ?c ?Q,?A›*)) with deriv (*‹Γ,Θ⊢⇩t⇘/F⇙ P c' Q,A›*) have "Γ,Θ⊢⇩t⇘/{}⇙ P c' Q,A" by (rule CombineStrip (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); ?Γ,?Θ⊢⇘/{} ⇙?P strip_guards (- ?F) ?c UNIV,UNIV⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/{}⇙ ?P ?c ?Q,?A›*)) hence "Γ,Θ⊢⇩t⇘/{}⇙ P mark_guards False c' Q,A" by (rule MarkGuardsI (*‹(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/{}⇙ (?P::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set) ⟹ ?Γ,?Θ⊢⇩t⇘/{}⇙ ?P mark_guards (?f::?'c) ?c ?Q,?A›*)) hence "Γ,Θ⊢⇩t⇘/{}⇙ P merge_guards (mark_guards False c') Q,A" by (rule MergeGuardsI (*‹?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P merge_guards ?c ?Q,?A›*)) hence "Γ,Θ⊢⇩t⇘/{}⇙ P merge_guards c Q,A" by (simp add: c (*‹merge_guards c = merge_guards (mark_guards False c')›*)) thus "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/{}⇙ P c Q,A›*) by (rule MergeGuardsD (*‹?Γ,?Θ⊢⇩t⇘/?F⇙ ?P merge_guards ?c ?Q,?A ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) qed lemma CombineStrip'': assumes deriv: "Γ,Θ⊢⇩t⇘/{True}⇙ P c' Q,A" assumes deriv_strip_triv: "Γ,{}⊢⇘/{}⇙ P c'' UNIV,UNIV" assumes c'': "c''= mark_guards False (strip_guards ({False}) c')" assumes c: "merge_guards c = merge_guards (mark_guards False c')" shows "Γ,Θ⊢⇩t⇘/{}⇙ P c Q,A" apply (rule CombineStrip' [OF deriv deriv_strip_triv _ c] (*‹(c''::('b, 'a, bool) com) = mark_guards False (strip_guards (- {True}) (c'::('b, 'a, bool) com)) ⟹ (Γ::'a ⇒ ('b, 'a, bool) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/{}⇙ (P::'b set) (c::('b, 'a, bool) com) (Q::'b set),(A::'b set)›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/{}⇙ P c Q,A›*) apply (insert c'' (*‹c'' = mark_guards False (strip_guards {False} c')›*)) (*goal: ‹c'' = mark_guards False (strip_guards (- {True}) c')›*) apply (subgoal_tac "- {True} = {False}") (*goals: 1. ‹⟦c'' = mark_guards False (strip_guards {False} c'); - {True} = {False}⟧ ⟹ c'' = mark_guards False (strip_guards (- {True}) c')› 2. ‹c'' = mark_guards False (strip_guards {False} c') ⟹ - {True} = {False}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma AsmUN: "(⋃Z. {(P Z, p, Q Z,A Z)}) ⊆ Θ ⟹ ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) (Call p) (Q Z),(A Z)" by (blast intro: hoaret.Asm (*‹(?P, ?p, ?Q, ?A) ∈ ?Θ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Call ?p ?Q,?A›*)) lemma hoaret_to_hoarep': "∀Z. Γ,{}⊢⇩t⇘/F⇙ (P Z) p (Q Z),(A Z) ⟹ ∀Z. Γ,{}⊢⇘/F⇙ (P Z) p (Q Z),(A Z)" by (iprover intro: total_to_partial) lemma augment_context': "⟦Θ ⊆ Θ'; ∀Z. Γ,Θ⊢⇩t⇘/F⇙ (P Z) p (Q Z),(A Z)⟧ ⟹ ∀Z. Γ,Θ'⊢⇩t⇘/F⇙ (P Z) p (Q Z),(A Z)" by (iprover intro: hoaret_augment_context) lemma augment_emptyFaults: "⟦∀Z. Γ,{}⊢⇩t⇘/{}⇙ (P Z) p (Q Z),(A Z)⟧ ⟹ ∀Z. Γ,{}⊢⇩t⇘/F⇙ (P Z) p (Q Z),(A Z)" by (blast intro: augment_Faults (*‹⟦?Γ,{}⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A; ?F ⊆ ?F'⟧ ⟹ ?Γ,{}⊢⇩t⇘/?F'⇙ ?P ?c ?Q,?A›*)) lemma augment_FaultsUNIV: "⟦∀Z. Γ,{}⊢⇩t⇘/F⇙ (P Z) p (Q Z),(A Z)⟧ ⟹ ∀Z. Γ,{}⊢⇩t⇘/UNIV⇙ (P Z) p (Q Z),(A Z)" by (blast intro: augment_Faults (*‹⟦?Γ,{}⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A; ?F ⊆ ?F'⟧ ⟹ ?Γ,{}⊢⇩t⇘/?F'⇙ ?P ?c ?Q,?A›*)) lemma PostConjI [trans]: "⟦Γ,Θ⊢⇩t⇘/F⇙ P c Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c R,B⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c (Q ∩ R),(A ∩ B)" apply (rule PostConjI (*‹⟦(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option),(?Θ::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⊢⇩t⇘/(?F::?'c::type set)⇙ (?P::?'b::type set) (?c::(?'b::type, ?'a::type, ?'c::type) com) (?Q::?'b::type set),(?A::?'b::type set); ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c (?R::?'b::type set),(?B::?'b::type set)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c (?Q ∩ ?R),(?A ∩ ?B)›*)) (*goals: 1. ‹⟦(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set); Γ,Θ⊢⇩t⇘/F⇙ P c (R::'b set),(B::'b set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A› 2. ‹⟦(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set); Γ,Θ⊢⇩t⇘/F⇙ P c (R::'b set),(B::'b set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c R,B› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma PostConjI' : "⟦Γ,Θ⊢⇩t⇘/F⇙ P c Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c R,B⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c (Q ∩ R),(A ∩ B)" apply (rule PostConjI (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?R,?B⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c (?Q ∩ ?R),(?A ∩ ?B)›*)) (*goals: 1. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c R,B⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A› 2. ‹⟦Γ,Θ⊢⇩t⇘/F⇙ P c Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c R,B⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c R,B› discuss goal 1*) apply iprover (*discuss goal 2*) apply iprover (*proven 2 subgoals*) . lemma PostConjE [consumes 1]: assumes conj: "Γ,Θ⊢⇩t⇘/F⇙ P c (Q ∩ R),(A ∩ B)" assumes E: "⟦Γ,Θ⊢⇩t⇘/F⇙ P c Q,A; Γ,Θ⊢⇩t⇘/F⇙ P c R,B⟧ ⟹ S" shows "S" proof (-) (*goal: ‹S›*) from conj (*‹Γ,Θ⊢⇩t⇘/F⇙ P c (Q ∩ R),(A ∩ B)›*) have "Γ,Θ⊢⇩t⇘/F⇙ P c Q,A" apply (rule conseqPost (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q',?A'; ?Q' ⊆ ?Q; ?A' ⊆ ?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹Q ∩ R ⊆ Q› 2. ‹A ∩ B ⊆ A› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover from conj (*‹Γ,Θ⊢⇩t⇘/F⇙ P c (Q ∩ R),(A ∩ B)›*) have "Γ,Θ⊢⇩t⇘/F⇙ P c R,B" apply (rule conseqPost (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q',?A'; ?Q' ⊆ ?Q; ?A' ⊆ ?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹(Q::'b set) ∩ (R::'b set) ⊆ R› 2. ‹(A::'b set) ∩ (B::'b set) ⊆ B› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately show S by (rule E (*‹⟦(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) (Q::'b set),(A::'b set); Γ,Θ⊢⇩t⇘/F⇙ P c (R::'b set),(B::'b set)⟧ ⟹ S::bool›*)) qed subsubsection ‹Rules for Single-Step Proof \label{sec:hoare-isar}› text ‹ We are now ready to introduce a set of Hoare rules to be used in single-step structured proofs in Isabelle/Isar. \medskip Assertions of Hoare Logic may be manipulated in calculational proofs, with the inclusion expressed in terms of sets or predicates. Reversed order is supported as well. › lemma annotateI [trans]: "⟦Γ,Θ⊢⇩t⇘/F⇙ P anno Q,A; c = anno⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A" by simp lemma annotate_normI: assumes deriv_anno: "Γ,Θ⊢⇩t⇘/F⇙P anno Q,A" assumes norm_eq: "normalize c = normalize anno" shows "Γ,Θ⊢⇩t⇘/F⇙P c Q,A" proof (-) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P c Q,A›*) from HoareTotalProps.NormalizeI[OF deriv_anno] (*‹Γ,Θ⊢⇩t⇘/F⇙ P Language.normalize anno Q,A›*) norm_eq (*‹Language.normalize c = Language.normalize anno›*) have "Γ,Θ⊢⇩t⇘/F ⇙P normalize c Q,A" by simp from NormalizeD[OF this] (*‹Γ,Θ⊢⇩t⇘/F⇙ P c Q,A›*) show "?thesis" (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P c Q,A›*) . qed lemma annotateWhile: "⟦Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoG gs b I V c) Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (while gs b c) Q,A" by (simp add: whileAnnoG_def (*‹whileAnnoG ?gs ?b ?I ?V ?c = while ?gs ?b ?c›*)) lemma reannotateWhile: "⟦Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoG gs b I V c) Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (whileAnnoG gs b J V c) Q,A" by (simp add: whileAnnoG_def (*‹whileAnnoG (?gs::(?'f::type × ?'s::type set) list) (?b::?'s::type set) (?I::?'s::type set) (?V::(?'s::type × ?'s::type) set) (?c::(?'s::type, ?'p::type, ?'f::type) com) = while ?gs ?b ?c›*)) lemma reannotateWhileNoGuard: "⟦Γ,Θ⊢⇩t⇘/F⇙ P (whileAnno b I V c) Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (whileAnno b J V c) Q,A" by (simp add: whileAnno_def (*‹whileAnno ?b ?I ?V ?c = While ?b ?c›*)) lemma [trans] : "P' ⊆ P ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P' c Q,A" apply (rule conseqPre (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P' ?c ?Q,?A; ?P ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹⟦(P'::'a set) ⊆ (P::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ P (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ (?P'::'a set) c Q,A› 2. ‹⟦(P'::'a set) ⊆ (P::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ P (c::('a, 'b, 'c) com) (Q::'a set),(A::'a set)⟧ ⟹ P' ⊆ (?P'::'a set)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma [trans]: "Q ⊆ Q' ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c Q',A" apply (rule conseqPost (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q',?A'; ?Q' ⊆ ?Q; ?A' ⊆ ?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goals: 1. ‹⟦(Q::'a set) ⊆ (Q'::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) (c::('a, 'b, 'c) com) Q,(A::'a set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c (?Q'::'a set),(?A'::'a set)› 2. ‹⟦(Q::'a set) ⊆ (Q'::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) (c::('a, 'b, 'c) com) Q,(A::'a set)⟧ ⟹ (?Q'::'a set) ⊆ Q'› 3. ‹⟦(Q::'a set) ⊆ (Q'::'a set); (Γ::'b ⇒ ('a, 'b, 'c) com option),(Θ::('a set × 'b × 'a set × 'a set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'a set) (c::('a, 'b, 'c) com) Q,(A::'a set)⟧ ⟹ (?A'::'a set) ⊆ A› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*proven 3 subgoals*) . lemma [trans]: "Γ,Θ⊢⇩t⇘/F⇙ {s. P s} c Q,A ⟹ (⋀s. P' s ⟶ P s) ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P' s} c Q,A" apply (rule conseqPre (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P'::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); (?P::?'b set) ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦Γ,Θ⊢⇩t⇘/F⇙ {s. P s} c Q,A; ⋀s. P' s ⟶ P s⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P' s} c Q,A›*) by auto lemma [trans]: "(⋀s. P' s ⟶ P s) ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P s} c Q,A ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P' s} c Q,A" apply (rule conseqPre (*‹⟦(?Γ::?'a ⇒ (?'b, ?'a, ?'c) com option),(?Θ::(?'b set × ?'a × ?'b set × ?'b set) set)⊢⇩t⇘/(?F::?'c set)⇙ (?P'::?'b set) (?c::(?'b, ?'a, ?'c) com) (?Q::?'b set),(?A::?'b set); (?P::?'b set) ⊆ ?P'⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦⋀s. P' s ⟶ P s; Γ,Θ⊢⇩t⇘/F⇙ {s. P s} c Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P' s} c Q,A›*) by auto lemma [trans]: "Γ,Θ⊢⇩t⇘/F⇙ P c {s. Q s},A ⟹ (⋀s. Q s ⟶ Q' s) ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c {s. Q' s},A" apply (rule conseqPost (*‹⟦(?Γ::?'a::type ⇒ (?'b::type, ?'a::type, ?'c::type) com option),(?Θ::(?'b::type set × ?'a::type × ?'b::type set × ?'b::type set) set)⊢⇩t⇘/(?F::?'c::type set)⇙ (?P::?'b::type set) (?c::(?'b::type, ?'a::type, ?'c::type) com) (?Q'::?'b::type set),(?A'::?'b::type set); ?Q' ⊆ (?Q::?'b::type set); ?A' ⊆ (?A::?'b::type set)⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦(Γ::'a ⇒ ('b, 'a, 'c) com option),(Θ::('b set × 'a × 'b set × 'b set) set)⊢⇩t⇘/(F::'c set)⇙ (P::'b set) (c::('b, 'a, 'c) com) {s::'b. (Q::'b ⇒ bool) s},(A::'b set); ⋀s::'b. Q s ⟶ (Q'::'b ⇒ bool) s⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c {s::'b. Q' s},A›*) by auto lemma [trans]: "(⋀s. Q s ⟶ Q' s) ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c {s. Q s},A ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c {s. Q' s},A" apply (rule conseqPost (*‹⟦?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q',?A'; ?Q' ⊆ ?Q; ?A' ⊆ ?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P ?c ?Q,?A›*)) (*goal: ‹⟦⋀s::'a::type. (Q::'a::type ⇒ bool) s ⟶ (Q'::'a::type ⇒ bool) s; (Γ::'b::type ⇒ ('a::type, 'b::type, 'c::type) com option),(Θ::('a::type set × 'b::type × 'a::type set × 'a::type set) set)⊢⇩t⇘/(F::'c::type set)⇙ (P::'a::type set) (c::('a::type, 'b::type, 'c::type) com) {s::'a::type. Q s},(A::'a::type set)⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P c {s::'a::type. Q' s},A›*) by auto lemma [intro?]: "Γ,Θ⊢⇩t⇘/F⇙ P Skip P,A" apply (rule Skip (*‹?P ⊆ ?Q ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Skip ?Q,?A›*)) (*goal: ‹Γ,Θ⊢⇩t⇘/F⇙ P Skip P,A›*) by auto lemma CondInt [trans,intro?]: "⟦Γ,Θ⊢⇩t⇘/F⇙ (P ∩ b) c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ (P ∩ - b) c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P (Cond b c1 c2) Q,A" apply (rule Cond (*‹⟦?P ⊆ {s. (s ∈ ?b ⟶ s ∈ ?P₁) ∧ (s ∉ ?b ⟶ s ∈ ?P₂)}; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₁ ?c₁ ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₂ ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b ?c₁ ?c₂ ?Q,?A›*)) (*goal: ‹⟦Γ,Θ⊢⇩t⇘/F⇙ (P ∩ b) c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ (P ∩ - b) c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ P Cond b c1 c2 Q,A›*) by auto lemma CondConj [trans, intro?]: "⟦Γ,Θ⊢⇩t⇘/F⇙ {s. P s ∧ b s} c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ {s. P s ∧ ¬ b s} c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P s} (Cond {s. b s} c1 c2) Q,A" apply (rule Cond (*‹⟦?P ⊆ {s. (s ∈ ?b ⟶ s ∈ ?P₁) ∧ (s ∉ ?b ⟶ s ∈ ?P₂)}; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₁ ?c₁ ?Q,?A; ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P₂ ?c₂ ?Q,?A⟧ ⟹ ?Γ,?Θ⊢⇩t⇘/?F⇙ ?P Cond ?b ?c₁ ?c₂ ?Q,?A›*)) (*goal: ‹⟦Γ,Θ⊢⇩t⇘/F⇙ {s. P s ∧ b s} c1 Q,A; Γ,Θ⊢⇩t⇘/F⇙ {s. P s ∧ ¬ b s} c2 Q,A⟧ ⟹ Γ,Θ⊢⇩t⇘/F⇙ {s. P s} Cond {s. b s} c1 c2 Q,A›*) by auto end
{ "path": "afp-2025-02-12/thys/Simpl/HoareTotal.thy", "repo": "afp-2025-02-12", "sha": "dc9c3756f7740c1107f31cd1c3bdf745e294f07e993365681c53461595d95ca9" }
(* Title: IP_Partition_Preliminaries Authors: Cornelius Diekmann, Max Haslbeck *) (*SetPartitioning.thy Original Author: Max Haslbeck, 2015*) section‹Partition a Set by a Specific Constraint› theory IP_Partition_Preliminaries imports Main begin text‹Will be used for the IP address space partition of a firewall. However, this file is completely generic in terms of sets, it only imports Main. It will be used in @{file ‹../Service_Matrix.thy›}. Core idea: This file partitions @{typ "'a set set"} by some magic condition. Later, we will show that this magic condition implies that all IPs that have been grouped by the magic condition show the same behaviour for a simple firewall.› (* disjoint, ipPartition definitions *) definition disjoint :: "'a set set ⇒ bool" where "disjoint ts ≡ ∀A ∈ ts. ∀B ∈ ts. A ≠ B ⟶ A ∩ B = {}" text_raw‹We will call two partitioned sets \emph{complete} iff @{term "⋃ ss = ⋃ ts"}.› text‹The condition we use to partition a set. If this holds and @{term A} is the set of IP addresses in each rule in a firewall, then @{term B} is a partition of @{term "⋃ A"} where each member has the same behavior w.r.t the firewall ruleset.› text‹@{term A} is the carrier set and @{term B}* should be a partition of @{term "⋃ A"} which fulfills the following condition:› definition ipPartition :: "'a set set ⇒ 'a set set ⇒ bool" where "ipPartition A B ≡ ∀a ∈ A. ∀b ∈ B. a ∩ b = {} ∨ b ⊆ a" definition disjoint_list :: "'a set list ⇒ bool" where "disjoint_list ls ≡ distinct ls ∧ disjoint (set ls)" context begin (*internal*) private fun disjoint_list_rec :: "'a set list ⇒ bool" where "disjoint_list_rec [] = True" | "disjoint_list_rec (x#xs) = (x ∩ ⋃(set xs) = {} ∧ disjoint_list_rec xs)" private lemma disjoint_equi: "disjoint_list_rec ts ⟹ disjoint (set ts)" apply (induction ts) (*goals: 1. ‹disjoint_list_rec [] ⟹ disjoint (set [])› 2. ‹⋀(a::'a set) ts::'a set list. ⟦disjoint_list_rec ts ⟹ disjoint (set ts); disjoint_list_rec (a # ts)⟧ ⟹ disjoint (set (a # ts))› discuss goal 1*) apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*discuss goal 2*) apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⋀a ts. ⟦disjoint_list_rec ts ⟹ disjoint (set ts); disjoint_list_rec (a # ts)⟧ ⟹ disjoint (set (a # ts))›*) apply fast (*proven 2 subgoals*) . private lemma disjoint_list_disjoint_list_rec: "disjoint_list ts ⟹ disjoint_list_rec ts" apply (induction ts) (*goals: 1. ‹disjoint_list [] ⟹ disjoint_list_rec []› 2. ‹⋀a ts. ⟦disjoint_list ts ⟹ disjoint_list_rec ts; disjoint_list (a # ts)⟧ ⟹ disjoint_list_rec (a # ts)› discuss goal 1*) apply (simp add: disjoint_list_def (*‹disjoint_list ?ls ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*discuss goal 2*) apply (simp add: disjoint_list_def (*‹disjoint_list ?ls ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⋀a ts. ⟦disjoint_list ts ⟹ disjoint_list_rec ts; disjoint_list (a # ts)⟧ ⟹ disjoint_list_rec (a # ts)›*) apply fast (*proven 2 subgoals*) . private definition addSubsetSet :: "'a set ⇒ 'a set set ⇒ 'a set set" where "addSubsetSet s ts = insert (s - ⋃ts) (((∩) s) ` ts) ∪ ((λx. x - s) ` ts)" private fun partitioning :: "'a set list ⇒ 'a set set ⇒ 'a set set" where "partitioning [] ts = ts" | "partitioning (s#ss) ts = partitioning ss (addSubsetSet s ts)" text‹simple examples› lemma "partitioning [{1::nat,2},{3,4},{5,6,7},{6},{10}] {} = {{10}, {6}, {5, 7}, {}, {3, 4}, {1, 2}}" by eval lemma "⋃ {{1::nat,2},{3,4},{5,6,7},{6},{10}} = ⋃ (partitioning [{1,2},{3,4},{5,6,7},{6},{10}] {})" by eval lemma "disjoint (partitioning [{1::nat,2},{3,4},{5,6,7},{6},{10}] {})" by eval lemma "ipPartition {{1::nat,2},{3,4},{5,6,7},{6},{10}} (partitioning [{1::nat,2},{3,4},{5,6,7},{6},{10}] {})" by eval lemma "ipPartition A {}" by (simp add: ipPartition_def (*‹ipPartition (?A::?'a::type set set) (?B::?'a::type set set) ≡ ∀a::?'a::type set∈?A. ∀b::?'a::type set∈?B. a ∩ b = {} ∨ b ⊆ a›*)) lemma ipPartitionUnion: "ipPartition As Cs ∧ ipPartition Bs Cs ⟷ ipPartition (As ∪ Bs) Cs" unfolding ipPartition_def (*goal: ‹((∀a::'a::type set∈As::'a::type set set. ∀b::'a::type set∈Cs::'a::type set set. a ∩ b = {} ∨ b ⊆ a) ∧ (∀a::'a::type set∈Bs::'a::type set set. ∀b::'a::type set∈Cs. a ∩ b = {} ∨ b ⊆ a)) = (∀a::'a::type set∈As ∪ Bs. ∀b::'a::type set∈Cs. a ∩ b = {} ∨ b ⊆ a)›*) by fast private lemma disjointAddSubset: "disjoint ts ⟹ disjoint (addSubsetSet a ts)" by (auto simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*) addSubsetSet_def (*‹addSubsetSet ?s ?ts = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx. x - ?s) ` ?ts›*)) private lemma coversallAddSubset:"⋃ (insert a ts) = ⋃ (addSubsetSet a ts)" by (auto simp add: addSubsetSet_def (*‹addSubsetSet ?s ?ts = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx. x - ?s) ` ?ts›*)) private lemma ipPartioningAddSubset0: "disjoint ts ⟹ ipPartition ts (addSubsetSet a ts)" apply (simp add: addSubsetSet_def (*‹addSubsetSet ?s ?ts = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx. x - ?s) ` ?ts›*) ipPartition_def (*‹ipPartition ?A ?B ≡ ∀a∈?A. ∀b∈?B. a ∩ b = {} ∨ b ⊆ a›*)) (*goal: ‹disjoint ts ⟹ ipPartition ts (addSubsetSet a ts)›*) apply safe (*goals: 1. ‹⋀aa x xa. ⟦disjoint ts; aa ∈ ts; x ∈ a; x ∉ ⋃ ts; x ∉ aa; xa ∈ aa; xa ∈ a; xa ∉ ⋃ ts⟧ ⟹ xa ∈ {}› 2. ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ a; x ∈ xa; x ∉ aa; xb ∈ aa; xb ∈ a; xb ∈ xa⟧ ⟹ xb ∈ {}› 3. ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ xa; x ∉ a; x ∉ aa; xb ∈ aa; xb ∈ xa; xb ∉ a⟧ ⟹ xb ∈ {}› discuss goal 1*) apply blast (*discuss goal 2*) apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*top goal: ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ a; x ∈ xa; x ∉ aa; xb ∈ aa; xb ∈ a; xb ∈ xa⟧ ⟹ xb ∈ {}› and 1 goal remains*) apply blast (*discuss goal 3*) apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ xa; x ∉ a; x ∉ aa; xb ∈ aa; xb ∈ xa; xb ∉ a⟧ ⟹ xb ∈ {}›*) apply blast (*proven 3 subgoals*) . private lemma ipPartitioningAddSubset1: "disjoint ts ⟹ ipPartition (insert a ts) (addSubsetSet a ts)" apply (simp add: addSubsetSet_def (*‹addSubsetSet ?s ?ts = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx. x - ?s) ` ?ts›*) ipPartition_def (*‹ipPartition ?A ?B ≡ ∀a∈?A. ∀b∈?B. a ∩ b = {} ∨ b ⊆ a›*)) (*goal: ‹disjoint ts ⟹ ipPartition (insert a ts) (addSubsetSet a ts)›*) apply safe (*goals: 1. ‹⋀aa x xa. ⟦disjoint ts; aa ∈ ts; x ∈ a; x ∉ ⋃ ts; x ∉ aa; xa ∈ aa; xa ∈ a; xa ∉ ⋃ ts⟧ ⟹ xa ∈ {}› 2. ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ a; x ∈ xa; x ∉ aa; xb ∈ aa; xb ∈ a; xb ∈ xa⟧ ⟹ xb ∈ {}› 3. ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ xa; x ∉ a; x ∉ aa; xb ∈ aa; xb ∈ xa; xb ∉ a⟧ ⟹ xb ∈ {}› discuss goal 1*) apply blast (*discuss goal 2*) apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*top goal: ‹⋀aa b x xa xb. ⟦disjoint ts; aa ∈ ts; xa ∈ ts; x ∈ a; x ∈ xa; x ∉ aa; xb ∈ aa; xb ∈ a; xb ∈ xa⟧ ⟹ xb ∈ {}› and 1 goal remains*) apply blast (*discuss goal 3*) apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⋀(aa::'a set) (b::'a set) (x::'a) (xa::'a set) xb::'a. ⟦disjoint (ts::'a set set); aa ∈ ts; xa ∈ ts; x ∈ xa; x ∉ (a::'a set); x ∉ aa; xb ∈ aa; xb ∈ xa; xb ∉ a⟧ ⟹ xb ∈ {}›*) apply blast (*proven 3 subgoals*) . private lemma addSubsetSetI: "s - ⋃ts ∈ addSubsetSet s ts" "t ∈ ts ⟹ s ∩ t ∈ addSubsetSet s ts" "t ∈ ts ⟹ t - s ∈ addSubsetSet s ts" unfolding addSubsetSet_def (*goals: 1. ‹s - ⋃ ts ∈ insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx. x - s) ` ts› 2. ‹t ∈ ts ⟹ s ∩ t ∈ insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx. x - s) ` ts› 3. ‹t ∈ ts ⟹ t - s ∈ insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx. x - s) ` ts›*) (*goals: 1. ‹(s::'a::type set) - ⋃ (ts::'a::type set set) ∈ insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx::'a::type set. x - s) ` ts› 2. ‹(t::'a::type set) ∈ (ts::'a::type set set) ⟹ (s::'a::type set) ∩ t ∈ insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx::'a::type set. x - s) ` ts› 3. ‹(t::'a::type set) ∈ (ts::'a::type set set) ⟹ t - (s::'a::type set) ∈ insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx::'a::type set. x - s) ` ts› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*proven 3 subgoals*) . private lemma addSubsetSetE: assumes "A ∈ addSubsetSet s ts" obtains "A = s - ⋃ts" | T where "T ∈ ts" "A = s ∩ T" | T where "T ∈ ts" "A = T - s" using assms (*‹(A::'a set) ∈ addSubsetSet (s::'a set) (ts::'a set set)›*) unfolding addSubsetSet_def (*goal: ‹⟦A = s - ⋃ ts ⟹ thesis; ⋀T. ⟦T ∈ ts; A = s ∩ T⟧ ⟹ thesis; ⋀T. ⟦T ∈ ts; A = T - s⟧ ⟹ thesis⟧ ⟹ thesis›*) by blast private lemma Union_addSubsetSet: "⋃(addSubsetSet b As) = b ∪ ⋃As" unfolding addSubsetSet_def (*goal: ‹⋃ (insert (b - ⋃ As) ((∩) b ` As) ∪ (λx. x - b) ` As) = b ∪ ⋃ As›*) by auto private lemma addSubsetSetCom: "addSubsetSet a (addSubsetSet b As) = addSubsetSet b (addSubsetSet a As)" proof (-) (*goal: ‹addSubsetSet a (addSubsetSet b As) = addSubsetSet b (addSubsetSet a As)›*) { fix A and a and b assume "A ∈ addSubsetSet a (addSubsetSet b As)" (*‹(A::'a set) ∈ addSubsetSet (a::'a set) (addSubsetSet (b::'a set) (As::'a set set))›*) hence "A ∈ addSubsetSet b (addSubsetSet a As)" apply (rule addSubsetSetE (*‹⟦?A ∈ addSubsetSet ?s ?ts; ?A = ?s - ⋃ ?ts ⟹ ?thesis; ⋀T. ⟦T ∈ ?ts; ?A = ?s ∩ T⟧ ⟹ ?thesis; ⋀T. ⟦T ∈ ?ts; ?A = T - ?s⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹A ∈ addSubsetSet b (addSubsetSet a As)›*) proof (goal_cases) (*goals: 1. ‹A = a - ⋃ (addSubsetSet b As) ⟹ A ∈ addSubsetSet b (addSubsetSet a As)› 2. ‹⋀T. ⟦T ∈ addSubsetSet b As; A = a ∩ T⟧ ⟹ A ∈ addSubsetSet b (addSubsetSet a As)› 3. ‹⋀T. ⟦T ∈ addSubsetSet b As; A = T - a⟧ ⟹ A ∈ addSubsetSet b (addSubsetSet a As)›*) case 1 (*‹(A::'a::type set) = (a::'a::type set) - ⋃ (addSubsetSet (b::'a::type set) (As::'a::type set set))›*) assume "A = a - ⋃(addSubsetSet b As)" (*‹(A::'a set) = (a::'a set) - ⋃ (addSubsetSet (b::'a set) (As::'a set set))›*) hence "A = (a - ⋃As) - b" by (auto simp add: Union_addSubsetSet (*‹⋃ (addSubsetSet (?b::?'a set) (?As::?'a set set)) = ?b ∪ ⋃ ?As›*)) thus "?thesis" (*goal: ‹A ∈ addSubsetSet b (addSubsetSet a As)›*) by (auto intro: addSubsetSetI (*‹?s - ⋃ ?ts ∈ addSubsetSet ?s ?ts› ‹?t ∈ ?ts ⟹ ?s ∩ ?t ∈ addSubsetSet ?s ?ts› ‹?t ∈ ?ts ⟹ ?t - ?s ∈ addSubsetSet ?s ?ts›*)) next (*goals: 1. ‹⋀T. ⟦T ∈ addSubsetSet b As; A = a ∩ T⟧ ⟹ A ∈ addSubsetSet b (addSubsetSet a As)› 2. ‹⋀T. ⟦T ∈ addSubsetSet b As; A = T - a⟧ ⟹ A ∈ addSubsetSet b (addSubsetSet a As)›*) case (2 T) (*‹T ∈ addSubsetSet b As› ‹A = a ∩ T›*) have "A = b ∩ (a - ⋃As) ∨ (∃S∈As. A = b ∩ (a ∩ S)) ∨ (∃S∈As. A = (a ∩ S) - b)" apply (rule addSubsetSetE[OF 2(1)] (*‹⟦T = b - ⋃ As ⟹ ?thesis; ⋀Ta. ⟦Ta ∈ As; T = b ∩ Ta⟧ ⟹ ?thesis; ⋀Ta. ⟦Ta ∈ As; T = Ta - b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹T = b - ⋃ As ⟹ A = b ∩ (a - ⋃ As) ∨ (∃S∈As. A = b ∩ (a ∩ S)) ∨ (∃S∈As. A = a ∩ S - b)› 2. ‹⋀Ta. ⟦Ta ∈ As; T = b ∩ Ta⟧ ⟹ A = b ∩ (a - ⋃ As) ∨ (∃S∈As. A = b ∩ (a ∩ S)) ∨ (∃S∈As. A = a ∩ S - b)› 3. ‹⋀Ta. ⟦Ta ∈ As; T = Ta - b⟧ ⟹ A = b ∩ (a - ⋃ As) ∨ (∃S∈As. A = b ∩ (a ∩ S)) ∨ (∃S∈As. A = a ∩ S - b)› discuss goal 1*) apply ((auto simp: 2( (*‹A = a ∩ T›*) 2))[1]) (*discuss goal 2*) apply ((auto simp: 2( (*‹A = a ∩ T›*) 2))[1]) (*discuss goal 3*) apply ((auto simp: 2( (*‹(A::'a set) = (a::'a set) ∩ (T::'a set)›*) 2))[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹A ∈ addSubsetSet b (addSubsetSet a As)›*) by (blast intro: addSubsetSetI (*‹(?s::?'a set) - ⋃ (?ts::?'a set set) ∈ addSubsetSet ?s ?ts› ‹(?t::?'a set) ∈ (?ts::?'a set set) ⟹ (?s::?'a set) ∩ ?t ∈ addSubsetSet ?s ?ts› ‹(?t::?'a set) ∈ (?ts::?'a set set) ⟹ ?t - (?s::?'a set) ∈ addSubsetSet ?s ?ts›*)) next (*goal: ‹⋀T. ⟦T ∈ addSubsetSet b As; A = T - a⟧ ⟹ A ∈ addSubsetSet b (addSubsetSet a As)›*) case (3 T) (*‹T ∈ addSubsetSet b As› ‹A = T - a›*) have "A = b - ⋃(addSubsetSet a As) ∨ (∃S∈As. A = b ∩ (S - a)) ∨ (∃S∈As. A = (S - a) - b)" apply (rule addSubsetSetE[OF 3(1)] (*‹⟦T = b - ⋃ As ⟹ ?thesis; ⋀Ta. ⟦Ta ∈ As; T = b ∩ Ta⟧ ⟹ ?thesis; ⋀Ta. ⟦Ta ∈ As; T = Ta - b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹T = b - ⋃ As ⟹ A = b - ⋃ (addSubsetSet a As) ∨ (∃S∈As. A = b ∩ (S - a)) ∨ (∃S∈As. A = S - a - b)› 2. ‹⋀Ta. ⟦Ta ∈ As; T = b ∩ Ta⟧ ⟹ A = b - ⋃ (addSubsetSet a As) ∨ (∃S∈As. A = b ∩ (S - a)) ∨ (∃S∈As. A = S - a - b)› 3. ‹⋀Ta. ⟦Ta ∈ As; T = Ta - b⟧ ⟹ A = b - ⋃ (addSubsetSet a As) ∨ (∃S∈As. A = b ∩ (S - a)) ∨ (∃S∈As. A = S - a - b)› discuss goal 1*) apply ((auto simp: 3( (*‹(A::'a set) = (T::'a set) - (a::'a set)›*) 2) Union_addSubsetSet (*‹⋃ (addSubsetSet (?b::?'a set) (?As::?'a set set)) = ?b ∪ ⋃ ?As›*))[1]) (*discuss goal 2*) apply ((auto simp: 3( (*‹A = T - a›*) 2) Union_addSubsetSet (*‹⋃ (addSubsetSet ?b ?As) = ?b ∪ ⋃ ?As›*))[1]) (*discuss goal 3*) apply ((auto simp: 3( (*‹A = T - a›*) 2) Union_addSubsetSet (*‹⋃ (addSubsetSet ?b ?As) = ?b ∪ ⋃ ?As›*))[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹A ∈ addSubsetSet b (addSubsetSet a As)›*) by (blast intro: addSubsetSetI (*‹?s - ⋃ ?ts ∈ addSubsetSet ?s ?ts› ‹?t ∈ ?ts ⟹ ?s ∩ ?t ∈ addSubsetSet ?s ?ts› ‹?t ∈ ?ts ⟹ ?t - ?s ∈ addSubsetSet ?s ?ts›*)) qed } thus "?thesis" (*goal: ‹addSubsetSet a (addSubsetSet b As) = addSubsetSet b (addSubsetSet a As)›*) by blast qed private lemma ipPartitioningAddSubset2: "ipPartition {a} (addSubsetSet a ts)" apply (simp add: addSubsetSet_def (*‹addSubsetSet ?s ?ts = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx. x - ?s) ` ?ts›*) ipPartition_def (*‹ipPartition ?A ?B ≡ ∀a∈?A. ∀b∈?B. a ∩ b = {} ∨ b ⊆ a›*)) (*goal: ‹ipPartition {a} (addSubsetSet a ts)›*) by blast private lemma disjointPartitioning_helper :"disjoint As ⟹ disjoint (partitioning ss As)" proof (induction ss arbitrary: As) (*goals: 1. ‹⋀As. disjoint As ⟹ disjoint (partitioning [] As)› 2. ‹⋀a ss As. ⟦⋀As. disjoint As ⟹ disjoint (partitioning ss As); disjoint As⟧ ⟹ disjoint (partitioning (a # ss) As)›*) case Nil (*‹disjoint As›*) thus "?case" (*goal: ‹disjoint (partitioning [] As)›*) by simp next (*goal: ‹⋀a ss As. ⟦⋀As. disjoint As ⟹ disjoint (partitioning ss As); disjoint As⟧ ⟹ disjoint (partitioning (a # ss) As)›*) case (Cons s ss) (*‹disjoint ?As ⟹ disjoint (partitioning ss ?As)› ‹disjoint As›*) from Cons.prems (*‹disjoint (As::'a set set)›*) disjointAddSubset (*‹disjoint ?ts ⟹ disjoint (addSubsetSet ?a ?ts)›*) have d: "disjoint (addSubsetSet s As)" by fast from Cons.IH (*‹disjoint (?As::'a::type set set) ⟹ disjoint (partitioning (ss::'a::type set list) ?As)›*) d (*‹disjoint (addSubsetSet s As)›*) have "disjoint (partitioning ss (addSubsetSet s As))" . thus "?case" (*goal: ‹disjoint (partitioning (s # ss) As)›*) by simp qed private lemma disjointPartitioning: "disjoint (partitioning ss {})" proof (-) (*goal: ‹disjoint (partitioning ss {})›*) have "disjoint {}" by (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) from this (*‹disjoint {}›*) disjointPartitioning_helper (*‹disjoint ?As ⟹ disjoint (partitioning ?ss ?As)›*) show "?thesis" (*goal: ‹disjoint (partitioning ss {})›*) by fast qed private lemma coversallPartitioning:"⋃ (set ts) = ⋃ (partitioning ts {})" proof (-) (*goal: ‹⋃ (set ts) = ⋃ (partitioning ts {})›*) have "⋃ (set ts ∪ As) = ⋃ (partitioning ts As)" for As apply (induction ts arbitrary: As) (*goals: 1. ‹⋀As. ⋃ (set [] ∪ As) = ⋃ (partitioning [] As)› 2. ‹⋀a ts As. (⋀As. ⋃ (set ts ∪ As) = ⋃ (partitioning ts As)) ⟹ ⋃ (set (a # ts) ∪ As) = ⋃ (partitioning (a # ts) As)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀a ts As. (⋀As. ⋃ (set ts ∪ As) = ⋃ (partitioning ts As)) ⟹ ⋃ (set (a # ts) ∪ As) = ⋃ (partitioning (a # ts) As)›*) apply (metis Union_addSubsetSet (*‹⋃ (addSubsetSet ?b ?As) = ?b ∪ ⋃ ?As›*) sup_left_commute (*‹sup ?x (sup ?y ?z) = sup ?y (sup ?x ?z)›*)) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹⋃ (set ts) = ⋃ (partitioning ts {})›*) by (metis sup_bot.right_neutral (*‹sup ?a bot = ?a›*)) qed private lemma "⋃ As = ⋃ Bs ⟹ ipPartition As Bs ⟹ ipPartition As (addSubsetSet a Bs)" by (auto simp add: ipPartition_def (*‹ipPartition ?A ?B ≡ ∀a∈?A. ∀b∈?B. a ∩ b = {} ∨ b ⊆ a›*) addSubsetSet_def (*‹addSubsetSet ?s ?ts = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx. x - ?s) ` ?ts›*)) private lemma ipPartitionSingleSet: "ipPartition {t} (addSubsetSet t Bs) ⟹ ipPartition {t} (partitioning ts (addSubsetSet t Bs))" apply (induction ts arbitrary: Bs t) (*goals: 1. ‹⋀Bs t. ipPartition {t} (addSubsetSet t Bs) ⟹ ipPartition {t} (partitioning [] (addSubsetSet t Bs))› 2. ‹⋀a ts Bs t. ⟦⋀Bs t. ipPartition {t} (addSubsetSet t Bs) ⟹ ipPartition {t} (partitioning ts (addSubsetSet t Bs)); ipPartition {t} (addSubsetSet t Bs)⟧ ⟹ ipPartition {t} (partitioning (a # ts) (addSubsetSet t Bs))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀a ts Bs t. ⟦⋀Bs t. ipPartition {t} (addSubsetSet t Bs) ⟹ ipPartition {t} (partitioning ts (addSubsetSet t Bs)); ipPartition {t} (addSubsetSet t Bs)⟧ ⟹ ipPartition {t} (partitioning (a # ts) (addSubsetSet t Bs))›*) apply (metis addSubsetSetCom (*‹addSubsetSet ?a (addSubsetSet ?b ?As) = addSubsetSet ?b (addSubsetSet ?a ?As)›*) ipPartitioningAddSubset2 (*‹ipPartition {?a} (addSubsetSet ?a ?ts)›*)) (*proven 2 subgoals*) . private lemma ipPartitioning_helper: "disjoint As ⟹ ipPartition (set ts) (partitioning ts As)" proof (induction ts arbitrary: As) (*goals: 1. ‹⋀As. disjoint As ⟹ ipPartition (set []) (partitioning [] As)› 2. ‹⋀a ts As. ⟦⋀As. disjoint As ⟹ ipPartition (set ts) (partitioning ts As); disjoint As⟧ ⟹ ipPartition (set (a # ts)) (partitioning (a # ts) As)›*) case Nil (*‹disjoint (As::'a set set)›*) thus "?case" (*goal: ‹ipPartition (set []) (partitioning [] (As::'a set set))›*) by (simp add: ipPartition_def (*‹ipPartition ?A ?B ≡ ∀a∈?A. ∀b∈?B. a ∩ b = {} ∨ b ⊆ a›*)) next (*goal: ‹⋀a ts As. ⟦⋀As. disjoint As ⟹ ipPartition (set ts) (partitioning ts As); disjoint As⟧ ⟹ ipPartition (set (a # ts)) (partitioning (a # ts) As)›*) case (Cons t ts) (*‹disjoint ?As ⟹ ipPartition (set ts) (partitioning ts ?As)› ‹disjoint As›*) from Cons.prems (*‹disjoint As›*) ipPartioningAddSubset0 (*‹disjoint ?ts ⟹ ipPartition ?ts (addSubsetSet ?a ?ts)›*) have d: "ipPartition As (addSubsetSet t As)" by blast from Cons.prems (*‹disjoint (As::'a::type set set)›*) Cons.IH (*‹disjoint ?As ⟹ ipPartition (set ts) (partitioning ts ?As)›*) d (*‹ipPartition (As::'a set set) (addSubsetSet (t::'a set) As)›*) disjointAddSubset (*‹disjoint (?ts::?'a set set) ⟹ disjoint (addSubsetSet (?a::?'a set) ?ts)›*) ipPartitioningAddSubset1 (*‹disjoint ?ts ⟹ ipPartition (insert ?a ?ts) (addSubsetSet ?a ?ts)›*) have e: "ipPartition (set ts) (partitioning ts (addSubsetSet t As))" by blast from ipPartitioningAddSubset2 (*‹ipPartition {?a} (addSubsetSet ?a ?ts)›*) Cons.prems (*‹disjoint As›*) have "ipPartition {t} (addSubsetSet t As)" by blast from this (*‹ipPartition {t} (addSubsetSet t As)›*) Cons.prems (*‹disjoint As›*) ipPartitionSingleSet (*‹ipPartition {?t} (addSubsetSet ?t ?Bs) ⟹ ipPartition {?t} (partitioning ?ts (addSubsetSet ?t ?Bs))›*) have f: "ipPartition {t} (partitioning ts (addSubsetSet t As))" by fast have "set (t#ts) = insert t (set ts)" by auto from ipPartitionUnion (*‹(ipPartition ?As ?Cs ∧ ipPartition ?Bs ?Cs) = ipPartition (?As ∪ ?Bs) ?Cs›*) have "⋀ As Bs Cs. ipPartition As Cs ⟹ ipPartition Bs Cs ⟹ ipPartition (As ∪ Bs) Cs" by fast with this (*‹⟦ipPartition ?As ?Cs; ipPartition ?Bs ?Cs⟧ ⟹ ipPartition (?As ∪ ?Bs) ?Cs›*) e (*‹ipPartition (set ts) (partitioning ts (addSubsetSet t As))›*) f (*‹ipPartition {t::'a set} (partitioning (ts::'a set list) (addSubsetSet t (As::'a set set)))›*) have "ipPartition (set (t # ts)) (partitioning ts (addSubsetSet t As))" by fastforce thus "?case" (*goal: ‹ipPartition (set (t # ts)) (partitioning (t # ts) As)›*) by simp qed private lemma ipPartitioning: "ipPartition (set ts) (partitioning ts {})" proof (-) (*goal: ‹ipPartition (set ts) (partitioning ts {})›*) have "disjoint {}" by (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) from this (*‹disjoint {}›*) ipPartitioning_helper (*‹disjoint ?As ⟹ ipPartition (set ?ts) (partitioning ?ts ?As)›*) show "?thesis" (*goal: ‹ipPartition (set ts) (partitioning ts {})›*) by fast qed (* OPTIMIZATION PROOFS *) private lemma inter_dif_help_lemma: "A ∩ B = {} ⟹ B - S = B - (S - A)" by blast private lemma disjoint_list_lem: "disjoint_list ls ⟹ ∀s ∈ set(ls). ∀t ∈ set(ls). s ≠ t ⟶ s ∩ t = {}" proof (induction ls) (*goals: 1. ‹disjoint_list [] ⟹ ∀s∈set []. ∀t∈set []. s ≠ t ⟶ s ∩ t = {}› 2. ‹⋀a ls. ⟦disjoint_list ls ⟹ ∀s∈set ls. ∀t∈set ls. s ≠ t ⟶ s ∩ t = {}; disjoint_list (a # ls)⟧ ⟹ ∀s∈set (a # ls). ∀t∈set (a # ls). s ≠ t ⟶ s ∩ t = {}›*) qed (simp_all add: disjoint_list_def disjoint_def) (*solves the remaining goals: 1. ‹disjoint_list [] ⟹ ∀s∈set []. ∀t∈set []. s ≠ t ⟶ s ∩ t = {}› 2. ‹⋀a ls. ⟦disjoint_list ls ⟹ ∀s∈set ls. ∀t∈set ls. s ≠ t ⟶ s ∩ t = {}; disjoint_list (a # ls)⟧ ⟹ ∀s∈set (a # ls). ∀t∈set (a # ls). s ≠ t ⟶ s ∩ t = {}›*) private lemma disjoint_list_empty: "disjoint_list []" by (simp add: disjoint_list_def (*‹disjoint_list ?ls ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) private lemma disjoint_sublist: "disjoint_list (t#ts) ⟹ disjoint_list ts" proof (induction ts arbitrary: t) (*goals: 1. ‹⋀t. disjoint_list [t] ⟹ disjoint_list []› 2. ‹⋀a ts t. ⟦⋀t. disjoint_list (t # ts) ⟹ disjoint_list ts; disjoint_list (t # a # ts)⟧ ⟹ disjoint_list (a # ts)›*) qed (simp_all add: disjoint_list_empty disjoint_list_def disjoint_def) (*solves the remaining goals: 1. ‹⋀t. disjoint_list [t] ⟹ disjoint_list []› 2. ‹⋀a ts t. ⟦⋀t. disjoint_list (t # ts) ⟹ disjoint_list ts; disjoint_list (t # a # ts)⟧ ⟹ disjoint_list (a # ts)›*) private fun intersection_list :: "'a set ⇒ 'a set list ⇒ 'a set list" where "intersection_list _ [] = []" | "intersection_list s (t#ts) = (s ∩ t)#(intersection_list s ts)" private fun intersection_list_opt :: "'a set ⇒ 'a set list ⇒ 'a set list" where "intersection_list_opt _ [] = []" | "intersection_list_opt s (t#ts) = (s ∩ t)#(intersection_list_opt (s - t) ts)" private lemma disjoint_subset: "disjoint A ⟹ a ∈ A ⟹ b ⊆ a ⟹ disjoint ((A - {a}) ∪ {b})" apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⟦disjoint A; a ∈ A; b ⊆ a⟧ ⟹ disjoint (A - {a} ∪ {b})›*) by blast private lemma disjoint_intersection: "disjoint A ⟹ a ∈ A ⟹ disjoint ({a ∩ b} ∪ (A - {a}))" apply (simp add: disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⟦disjoint A; a ∈ A⟧ ⟹ disjoint ({a ∩ b} ∪ (A - {a}))›*) by blast private lemma intList_equi: "disjoint_list_rec ts ⟹ intersection_list s ts = intersection_list_opt s ts" proof (induction ts) (*goals: 1. ‹disjoint_list_rec [] ⟹ intersection_list s [] = intersection_list_opt s []› 2. ‹⋀a ts. ⟦disjoint_list_rec ts ⟹ intersection_list s ts = intersection_list_opt s ts; disjoint_list_rec (a # ts)⟧ ⟹ intersection_list s (a # ts) = intersection_list_opt s (a # ts)›*) case Nil (*‹disjoint_list_rec []›*) thus "?case" (*goal: ‹intersection_list s [] = intersection_list_opt s []›*) by simp next (*goal: ‹⋀a ts. ⟦disjoint_list_rec ts ⟹ intersection_list s ts = intersection_list_opt s ts; disjoint_list_rec (a # ts)⟧ ⟹ intersection_list s (a # ts) = intersection_list_opt s (a # ts)›*) case (Cons t ts) (*‹disjoint_list_rec ts ⟹ intersection_list s ts = intersection_list_opt s ts› ‹disjoint_list_rec ((t::'a::type set) # (ts::'a::type set list))›*) from Cons.prems (*‹disjoint_list_rec ((t::'a set) # (ts::'a set list))›*) have "intersection_list_opt s ts = intersection_list_opt (s - t) ts" proof (induction ts arbitrary: s t) (*goals: 1. ‹⋀(s::'a set) t::'a set. disjoint_list_rec [t] ⟹ intersection_list_opt s [] = intersection_list_opt (s - t) []› 2. ‹⋀(a::'a set) (ts::'a set list) (s::'a set) t::'a set. ⟦⋀(s::'a set) t::'a set. disjoint_list_rec (t # ts) ⟹ intersection_list_opt s ts = intersection_list_opt (s - t) ts; disjoint_list_rec (t # a # ts)⟧ ⟹ intersection_list_opt s (a # ts) = intersection_list_opt (s - t) (a # ts)›*) case Nil (*‹disjoint_list_rec [t]›*) thus "?case" (*goal: ‹intersection_list_opt s [] = intersection_list_opt (s - t) []›*) by simp next (*goal: ‹⋀(a::'a set) (ts::'a set list) (s::'a set) t::'a set. ⟦⋀(s::'a set) t::'a set. disjoint_list_rec (t # ts) ⟹ intersection_list_opt s ts = intersection_list_opt (s - t) ts; disjoint_list_rec (t # a # ts)⟧ ⟹ intersection_list_opt s (a # ts) = intersection_list_opt (s - t) (a # ts)›*) case Cons (*‹disjoint_list_rec ((?t::'a set) # (ts_::'a set list)) ⟹ intersection_list_opt (?s::'a set) ts_ = intersection_list_opt (?s - ?t) ts_› ‹disjoint_list_rec (t # a_ # ts_)›*) have "∀t ∈ set ts. u ∩ t = {} ⟹ intersection_list_opt s ts = intersection_list_opt (s - u) ts" for u apply (induction ts arbitrary: s u) (*goals: 1. ‹⋀s u. ∀t∈set []. u ∩ t = {} ⟹ intersection_list_opt s [] = intersection_list_opt (s - u) []› 2. ‹⋀a ts s u. ⟦⋀s u. ∀t∈set ts. u ∩ t = {} ⟹ intersection_list_opt s ts = intersection_list_opt (s - u) ts; ∀t∈set (a # ts). u ∩ t = {}⟧ ⟹ intersection_list_opt s (a # ts) = intersection_list_opt (s - u) (a # ts)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀a ts s u. ⟦⋀s u. ∀t∈set ts. u ∩ t = {} ⟹ intersection_list_opt s ts = intersection_list_opt (s - u) ts; ∀t∈set (a # ts). u ∩ t = {}⟧ ⟹ intersection_list_opt s (a # ts) = intersection_list_opt (s - u) (a # ts)›*) apply (metis Diff_Int_distrib2 (*‹((?A::?'a set) - (?B::?'a set)) ∩ (?C::?'a set) = ?A ∩ ?C - ?B ∩ ?C›*) Diff_empty (*‹(?A::?'a set) - {} = ?A›*) Diff_eq (*‹(?A::?'a set) - (?B::?'a set) = ?A ∩ - ?B›*) Un_Diff_Int (*‹(?A::?'a set) - (?B::?'a set) ∪ ?A ∩ ?B = ?A›*) sup_bot.right_neutral (*‹sup (?a::?'a) bot = ?a›*)) (*proven 2 subgoals*) . with Cons (*‹disjoint_list_rec (?t # ts_) ⟹ intersection_list_opt ?s ts_ = intersection_list_opt (?s - ?t) ts_› ‹disjoint_list_rec (t # a_ # ts_)›*) show "?case" (*goal: ‹intersection_list_opt s (a_ # ts_) = intersection_list_opt (s - t) (a_ # ts_)›*) apply simp (*goal: ‹intersection_list_opt s (a_ # ts_) = intersection_list_opt (s - t) (a_ # ts_)›*) by (metis Diff_Int_distrib2 (*‹((?A::?'a::type set) - (?B::?'a::type set)) ∩ (?C::?'a::type set) = ?A ∩ ?C - ?B ∩ ?C›*) Diff_empty (*‹(?A::?'a::type set) - {} = ?A›*) Un_empty (*‹((?A::?'a::type set) ∪ (?B::?'a::type set) = {}) = (?A = {} ∧ ?B = {})›*) inf_sup_distrib1 (*‹inf (?x::?'a::distrib_lattice) (sup (?y::?'a::distrib_lattice) (?z::?'a::distrib_lattice)) = sup (inf ?x ?y) (inf ?x ?z)›*)) qed with Cons (*‹disjoint_list_rec ts ⟹ intersection_list s ts = intersection_list_opt s ts› ‹disjoint_list_rec (t # ts)›*) show "?case" (*goal: ‹intersection_list s (t # ts) = intersection_list_opt s (t # ts)›*) by simp qed private fun difference_list :: "'a set ⇒ 'a set list ⇒ 'a set list" where "difference_list _ [] = []" | "difference_list s (t#ts) = (t - s)#(difference_list s ts)" private fun difference_list_opt :: "'a set ⇒ 'a set list ⇒ 'a set list" where "difference_list_opt _ [] = []" | "difference_list_opt s (t#ts) = (t - s)#(difference_list_opt (s - t) ts)" private lemma difList_equi: "disjoint_list_rec ts ⟹ difference_list s ts = difference_list_opt s ts" proof (induction ts arbitrary: s) (*goals: 1. ‹⋀s. disjoint_list_rec [] ⟹ difference_list s [] = difference_list_opt s []› 2. ‹⋀a ts s. ⟦⋀s. disjoint_list_rec ts ⟹ difference_list s ts = difference_list_opt s ts; disjoint_list_rec (a # ts)⟧ ⟹ difference_list s (a # ts) = difference_list_opt s (a # ts)›*) case Nil (*‹disjoint_list_rec []›*) thus "?case" (*goal: ‹difference_list s [] = difference_list_opt s []›*) by simp next (*goal: ‹⋀a ts s. ⟦⋀s. disjoint_list_rec ts ⟹ difference_list s ts = difference_list_opt s ts; disjoint_list_rec (a # ts)⟧ ⟹ difference_list s (a # ts) = difference_list_opt s (a # ts)›*) case (Cons t ts) (*‹disjoint_list_rec (ts::'a::type set list) ⟹ difference_list (?s::'a::type set) ts = difference_list_opt ?s ts› ‹disjoint_list_rec (t # ts)›*) have difference_list_opt_lem0: "∀t ∈ set(ts). u ∩ t = {} ⟹ difference_list_opt s ts = difference_list_opt (s - u) ts" for u proof (induction ts arbitrary: s u) (*goals: 1. ‹⋀s u. ∀t∈set []. u ∩ t = {} ⟹ difference_list_opt s [] = difference_list_opt (s - u) []› 2. ‹⋀a ts s u. ⟦⋀s u. ∀t∈set ts. u ∩ t = {} ⟹ difference_list_opt s ts = difference_list_opt (s - u) ts; ∀t∈set (a # ts). u ∩ t = {}⟧ ⟹ difference_list_opt s (a # ts) = difference_list_opt (s - u) (a # ts)›*) case Cons (*‹∀t∈set ts_. ?u ∩ t = {} ⟹ difference_list_opt ?s ts_ = difference_list_opt (?s - ?u) ts_› ‹∀t∈set (a_ # ts_). u ∩ t = {}›*) thus "?case" (*goal: ‹difference_list_opt s (a_ # ts_) = difference_list_opt (s - u) (a_ # ts_)›*) apply (simp add: inter_dif_help_lemma (*‹(?A::?'a set) ∩ (?B::?'a set) = {} ⟹ ?B - (?S::?'a set) = ?B - (?S - ?A)›*)) (*goal: ‹difference_list_opt s (a_ # ts_) = difference_list_opt (s - u) (a_ # ts_)›*) by (metis Diff_Int_distrib2 (*‹(?A - ?B) ∩ ?C = ?A ∩ ?C - ?B ∩ ?C›*) Diff_eq (*‹?A - ?B = ?A ∩ - ?B›*) Un_Diff_Int (*‹?A - ?B ∪ ?A ∩ ?B = ?A›*) sup_bot.right_neutral (*‹sup ?a bot = ?a›*)) qed (simp) (*solved the remaining goal: ‹⋀s u. ∀t∈set []. u ∩ t = {} ⟹ difference_list_opt s [] = difference_list_opt (s - u) []›*) have "disjoint_list_rec (t # ts) ⟹ difference_list_opt s ts = difference_list_opt (s - t) ts" proof (induction ts arbitrary: s t) (*goals: 1. ‹⋀s t. disjoint_list_rec [t] ⟹ difference_list_opt s [] = difference_list_opt (s - t) []› 2. ‹⋀a ts s t. ⟦⋀s t. disjoint_list_rec (t # ts) ⟹ difference_list_opt s ts = difference_list_opt (s - t) ts; disjoint_list_rec (t # a # ts)⟧ ⟹ difference_list_opt s (a # ts) = difference_list_opt (s - t) (a # ts)›*) case Cons (*‹disjoint_list_rec (?t # ts_) ⟹ difference_list_opt ?s ts_ = difference_list_opt (?s - ?t) ts_› ‹disjoint_list_rec ((t::'a set) # (a_::'a set) # (ts_::'a set list))›*) thus "?case" (*goal: ‹difference_list_opt (s::'a set) ((a_::'a set) # (ts_::'a set list)) = difference_list_opt (s - (t::'a set)) (a_ # ts_)›*) apply (simp add: difference_list_opt_lem0 (*‹∀t∈set ts. ?u ∩ t = {} ⟹ difference_list_opt sa__ ts = difference_list_opt (sa__ - ?u) ts›*)) (*goal: ‹difference_list_opt (s::'a set) ((a_::'a set) # (ts_::'a set list)) = difference_list_opt (s - (t::'a set)) (a_ # ts_)›*) by (metis Un_empty (*‹(?A ∪ ?B = {}) = (?A = {} ∧ ?B = {})›*) inf_sup_distrib1 (*‹inf ?x (sup ?y ?z) = sup (inf ?x ?y) (inf ?x ?z)›*) inter_dif_help_lemma (*‹?A ∩ ?B = {} ⟹ ?B - ?S = ?B - (?S - ?A)›*)) qed (simp) (*solved the remaining goal: ‹⋀s t. disjoint_list_rec [t] ⟹ difference_list_opt s [] = difference_list_opt (s - t) []›*) with Cons (*‹disjoint_list_rec ts ⟹ difference_list ?s ts = difference_list_opt ?s ts› ‹disjoint_list_rec (t # ts)›*) show "?case" (*goal: ‹difference_list s (t # ts) = difference_list_opt s (t # ts)›*) by simp qed private fun partList0 :: "'a set ⇒ 'a set list ⇒ 'a set list" where "partList0 s [] = []" | "partList0 s (t#ts) = (s ∩ t)#((t - s)#(partList0 s ts))" private lemma partList0_set_equi: "set(partList0 s ts) = (((∩) s) ` (set ts)) ∪ ((λx. x - s) ` (set ts))" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s::'a::type set. set (partList0 s []) = (∩) s ` set [] ∪ (λx::'a::type set. x - s) ` set []› 2. ‹⋀(a::'a::type set) (ts::'a::type set list) s::'a::type set. (⋀s::'a::type set. set (partList0 s ts) = (∩) s ` set ts ∪ (λx::'a::type set. x - s) ` set ts) ⟹ set (partList0 s (a # ts)) = (∩) s ` set (a # ts) ∪ (λx::'a::type set. x - s) ` set (a # ts)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . private lemma partList_sub_equi0: "set(partList0 s ts) = set(difference_list s ts) ∪ set(intersection_list s ts)" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s::'a set. set (partList0 s []) = set (difference_list s []) ∪ set (intersection_list s [])› 2. ‹⋀(a::'a set) (ts::'a set list) s::'a set. (⋀s::'a set. set (partList0 s ts) = set (difference_list s ts) ∪ set (intersection_list s ts)) ⟹ set (partList0 s (a # ts)) = set (difference_list s (a # ts)) ∪ set (intersection_list s (a # ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . private fun partList1 :: "'a set ⇒ 'a set list ⇒ 'a set list" where "partList1 s [] = []" | "partList1 s (t#ts) = (s ∩ t)#((t - s)#(partList1 (s - t) ts))" private lemma partList_sub_equi: "set(partList1 s ts) = set(difference_list_opt s ts) ∪ set(intersection_list_opt s ts)" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s. set (partList1 s []) = set (difference_list_opt s []) ∪ set (intersection_list_opt s [])› 2. ‹⋀a ts s. (⋀s. set (partList1 s ts) = set (difference_list_opt s ts) ∪ set (intersection_list_opt s ts)) ⟹ set (partList1 s (a # ts)) = set (difference_list_opt s (a # ts)) ∪ set (intersection_list_opt s (a # ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . private lemma partList0_partList1_equi: "disjoint_list_rec ts ⟹ set (partList0 s ts) = set (partList1 s ts)" by (simp add: partList_sub_equi (*‹set (partList1 ?s ?ts) = set (difference_list_opt ?s ?ts) ∪ set (intersection_list_opt ?s ?ts)›*) partList_sub_equi0 (*‹set (partList0 ?s ?ts) = set (difference_list ?s ?ts) ∪ set (intersection_list ?s ?ts)›*) intList_equi (*‹disjoint_list_rec ?ts ⟹ intersection_list ?s ?ts = intersection_list_opt ?s ?ts›*) difList_equi (*‹disjoint_list_rec ?ts ⟹ difference_list ?s ?ts = difference_list_opt ?s ?ts›*)) private fun partList2 :: "'a set ⇒ 'a set list ⇒ 'a set list" where "partList2 s [] = []" | "partList2 s (t#ts) = (if s ∩ t = {} then (t#(partList2 (s - t) ts)) else (s ∩ t)#((t - s)#(partList2 (s - t) ts)))" private lemma partList2_empty: "partList2 {} ts = ts" apply (induction ts) (*goals: 1. ‹partList2 {} [] = []› 2. ‹⋀(a::'a::type set) ts::'a::type set list. partList2 {} ts = ts ⟹ partList2 {} (a # ts) = a # ts› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . private lemma partList1_partList2_equi: "set(partList1 s ts) - {{}} = set(partList2 s ts) - {{}}" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s. set (partList1 s []) - {{}} = set (partList2 s []) - {{}}› 2. ‹⋀a ts s. (⋀s. set (partList1 s ts) - {{}} = set (partList2 s ts) - {{}}) ⟹ set (partList1 s (a # ts)) - {{}} = set (partList2 s (a # ts)) - {{}}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . private fun partList3 :: "'a set ⇒ 'a set list ⇒ 'a set list" where "partList3 s [] = []" | "partList3 s (t#ts) = (if s = {} then (t#ts) else (if s ∩ t = {} then (t#(partList3 (s - t) ts)) else (if t - s = {} then (t#(partList3 (s - t) ts)) else (t ∩ s)#((t - s)#(partList3 (s - t) ts)))))" private lemma partList2_partList3_equi: "set(partList2 s ts) - {{}} = set(partList3 s ts) - {{}}" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s::'a::type set. set (partList2 s []) - {{}} = set (partList3 s []) - {{}}› 2. ‹⋀(a::'a::type set) (ts::'a::type set list) s::'a::type set. (⋀s::'a::type set. set (partList2 s ts) - {{}} = set (partList3 s ts) - {{}}) ⟹ set (partList2 s (a # ts)) - {{}} = set (partList3 s (a # ts)) - {{}}› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: partList2_empty (*‹partList2 {} ?ts = ?ts›*)) (*goal: ‹⋀a ts s. (⋀s. set (partList2 s ts) - {{}} = set (partList3 s ts) - {{}}) ⟹ set (partList2 s (a # ts)) - {{}} = set (partList3 s (a # ts)) - {{}}›*) apply blast (*proven 2 subgoals*) . fun partList4 :: "'a set ⇒ 'a set list ⇒ 'a set list" where "partList4 s [] = []" | "partList4 s (t#ts) = (if s = {} then (t#ts) else (if s ∩ t = {} then (t#(partList4 s ts)) else (if t - s = {} then (t#(partList4 (s - t) ts)) else (t ∩ s)#((t - s)#(partList4 (s - t) ts)))))" private lemma partList4: "partList4 s ts = partList3 s ts" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s. partList4 s [] = partList3 s []› 2. ‹⋀a ts s. (⋀s. partList4 s ts = partList3 s ts) ⟹ partList4 s (a # ts) = partList3 s (a # ts)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: Diff_triv (*‹?A ∩ ?B = {} ⟹ ?A - ?B = ?A›*)) (*proven 2 subgoals*) . private lemma partList0_addSubsetSet_equi: "s ⊆ ⋃(set ts) ⟹ addSubsetSet s (set ts) - {{}} = set(partList0 s ts) - {{}}" by (simp add: addSubsetSet_def (*‹addSubsetSet (?s::?'a::type set) (?ts::?'a::type set set) = insert (?s - ⋃ ?ts) ((∩) ?s ` ?ts) ∪ (λx::?'a::type set. x - ?s) ` ?ts›*) partList0_set_equi (*‹set (partList0 (?s::?'a::type set) (?ts::?'a::type set list)) = (∩) ?s ` set ?ts ∪ (λx::?'a::type set. x - ?s) ` set ?ts›*)) private fun partitioning_nontail :: "'a set list ⇒ 'a set set ⇒ 'a set set" where "partitioning_nontail [] ts = ts" | "partitioning_nontail (s#ss) ts = addSubsetSet s (partitioning_nontail ss ts)" private lemma partitioningCom: "addSubsetSet a (partitioning ss ts) = partitioning ss (addSubsetSet a ts)" apply (induction ss arbitrary: a ts) (*goals: 1. ‹⋀a ts. addSubsetSet a (partitioning [] ts) = partitioning [] (addSubsetSet a ts)› 2. ‹⋀a ss aa ts. (⋀a ts. addSubsetSet a (partitioning ss ts) = partitioning ss (addSubsetSet a ts)) ⟹ addSubsetSet aa (partitioning (a # ss) ts) = partitioning (a # ss) (addSubsetSet aa ts)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: addSubsetSetCom (*‹addSubsetSet ?a (addSubsetSet ?b ?As) = addSubsetSet ?b (addSubsetSet ?a ?As)›*)) (*proven 2 subgoals*) . private lemma partitioning_nottail_equi: "partitioning_nontail ss ts = partitioning ss ts" apply (induction ss arbitrary: ts) (*goals: 1. ‹⋀ts. partitioning_nontail [] ts = partitioning [] ts› 2. ‹⋀a ss ts. (⋀ts. partitioning_nontail ss ts = partitioning ss ts) ⟹ partitioning_nontail (a # ss) ts = partitioning (a # ss) ts› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: addSubsetSetCom (*‹addSubsetSet (?a::?'a set) (addSubsetSet (?b::?'a set) (?As::?'a set set)) = addSubsetSet ?b (addSubsetSet ?a ?As)›*) partitioningCom (*‹addSubsetSet (?a::?'a set) (partitioning (?ss::?'a set list) (?ts::?'a set set)) = partitioning ?ss (addSubsetSet ?a ?ts)›*)) (*proven 2 subgoals*) . fun partitioning1 :: "'a set list ⇒ 'a set list ⇒ 'a set list" where "partitioning1 [] ts = ts" | "partitioning1 (s#ss) ts = partList4 s (partitioning1 ss ts)" lemma partList4_empty: "{} ∉ set ts ⟹ {} ∉ set (partList4 s ts)" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s. {} ∉ set [] ⟹ {} ∉ set (partList4 s [])› 2. ‹⋀a ts s. ⟦⋀s. {} ∉ set ts ⟹ {} ∉ set (partList4 s ts); {} ∉ set (a # ts)⟧ ⟹ {} ∉ set (partList4 s (a # ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply auto (*proven 2 subgoals*) . lemma partitioning1_empty0: "{} ∉ set ts ⟹ {} ∉ set (partitioning1 ss ts)" apply (induction ss arbitrary: ts) (*goals: 1. ‹⋀ts. {} ∉ set ts ⟹ {} ∉ set (partitioning1 [] ts)› 2. ‹⋀a ss ts. ⟦⋀ts. {} ∉ set ts ⟹ {} ∉ set (partitioning1 ss ts); {} ∉ set ts⟧ ⟹ {} ∉ set (partitioning1 (a # ss) ts)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: partList4_empty (*‹{} ∉ set ?ts ⟹ {} ∉ set (partList4 ?s ?ts)›*)) (*proven 2 subgoals*) . lemma partitioning1_empty1: "{} ∉ set ts ⟹ set(partitioning1 ss ts) - {{}} = set(partitioning1 ss ts)" by (simp add: partitioning1_empty0 (*‹{} ∉ set (?ts::?'a set list) ⟹ {} ∉ set (partitioning1 (?ss::?'a set list) ?ts)›*)) lemma partList4_subset: "a ⊆ ⋃(set ts) ⟹ a ⊆ ⋃(set (partList4 b ts))" apply (simp add: partList4 (*‹partList4 ?s ?ts = partList3 ?s ?ts›*)) (*goal: ‹a ⊆ ⋃ (set ts) ⟹ a ⊆ ⋃ (set (partList4 b ts))›*) apply (induction ts arbitrary: a b) (*goals: 1. ‹⋀a b. a ⊆ ⋃ (set []) ⟹ a ⊆ ⋃ (set (partList3 b []))› 2. ‹⋀a ts aa b. ⟦⋀a b. a ⊆ ⋃ (set ts) ⟹ a ⊆ ⋃ (set (partList3 b ts)); aa ⊆ ⋃ (set (a # ts))⟧ ⟹ aa ⊆ ⋃ (set (partList3 b (a # ts)))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀(a::'a set) (ts::'a set list) (aa::'a set) b::'a set. ⟦⋀(a::'a set) b::'a set. a ⊆ ⋃ (set ts) ⟹ a ⊆ ⋃ (set (partList3 b ts)); aa ⊆ ⋃ (set (a # ts))⟧ ⟹ aa ⊆ ⋃ (set (partList3 b (a # ts)))›*) apply fast (*proven 2 subgoals*) . private lemma "a ≠ {} ⟹ disjoint_list_rec (a # ts) ⟷ disjoint_list_rec ts ∧ a ∩ ⋃ (set ts) = {}" by auto lemma partList4_complete0: "s ⊆ ⋃(set ts) ⟹ ⋃(set (partList4 s ts)) = ⋃(set ts)" unfolding partList4 (*goal: ‹(s::'a::type set) ⊆ ⋃ (set (ts::'a::type set list)) ⟹ ⋃ (set (partList3 s ts)) = ⋃ (set ts)›*) proof (induction ts arbitrary: s) (*goals: 1. ‹⋀s. s ⊆ ⋃ (set []) ⟹ ⋃ (set (partList3 s [])) = ⋃ (set [])› 2. ‹⋀a ts s. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ ⋃ (set (partList3 s ts)) = ⋃ (set ts); s ⊆ ⋃ (set (a # ts))⟧ ⟹ ⋃ (set (partList3 s (a # ts))) = ⋃ (set (a # ts))›*) case Nil (*‹s ⊆ ⋃ (set [])›*) thus "?case" (*goal: ‹⋃ (set (partList3 (s::'a set) [])) = ⋃ (set [])›*) by simp next (*goal: ‹⋀a ts s. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ ⋃ (set (partList3 s ts)) = ⋃ (set ts); s ⊆ ⋃ (set (a # ts))⟧ ⟹ ⋃ (set (partList3 s (a # ts))) = ⋃ (set (a # ts))›*) case Cons (*‹?s ⊆ ⋃ (set ts_) ⟹ ⋃ (set (partList3 ?s ts_)) = ⋃ (set ts_)› ‹s ⊆ ⋃ (set (a_ # ts_))›*) thus "?case" (*goal: ‹⋃ (set (partList3 (s::'a::type set) ((a_::'a::type set) # (ts_::'a::type set list)))) = ⋃ (set (a_ # ts_))›*) by (simp add: Diff_subset_conv (*‹((?A::?'a set) - (?B::?'a set) ⊆ (?C::?'a set)) = (?A ⊆ ?B ∪ ?C)›*) Un_Diff_Int (*‹(?A::?'a set) - (?B::?'a set) ∪ ?A ∩ ?B = ?A›*) inf_sup_aci( (*‹sup (?x::?'a) (sup (?y::?'a) (?z::?'a)) = sup ?y (sup ?x ?z)›*) 7) sup.commute (*‹sup (?a::?'a) (?b::?'a) = sup ?b ?a›*)) qed private lemma partList4_disjoint: "s ⊆ ⋃(set ts) ⟹ disjoint_list_rec ts ⟹ disjoint_list_rec (partList4 s ts)" apply (induction ts arbitrary: s) (*goal: ‹⟦s ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partList4 s ts)›*) apply (simp; fail) (*top goal: ‹⋀s. ⟦s ⊆ ⋃ (set []); disjoint_list_rec []⟧ ⟹ disjoint_list_rec (partList4 s [])› and 1 goal remains*) apply (simp add: Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*)) (*goal: ‹⋀a ts s. ⟦⋀s. ⟦s ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partList4 s ts); s ⊆ ⋃ (set (a # ts)); disjoint_list_rec (a # ts)⟧ ⟹ disjoint_list_rec (partList4 s (a # ts))›*) apply (rule conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*)) (*goal: ‹⋀a ts s. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ disjoint_list_rec (partList4 s ts); s ⊆ a ∪ ⋃ (set ts); a ∩ ⋃ (set ts) = {} ∧ disjoint_list_rec ts⟧ ⟹ (a ⊆ s ⟶ (s ∩ a = {} ⟶ s ≠ {} ⟶ a ∩ ⋃ (set (partList4 s ts)) = {} ∧ disjoint_list_rec (partList4 s ts)) ∧ (s ∩ a ≠ {} ⟶ s ≠ {} ⟶ a ∩ ⋃ (set (partList4 (s - a) ts)) = {})) ∧ (¬ a ⊆ s ⟶ (s ∩ a = {} ⟶ s ≠ {} ⟶ a ∩ ⋃ (set (partList4 s ts)) = {} ∧ disjoint_list_rec (partList4 s ts)) ∧ (s ∩ a ≠ {} ⟶ s ≠ {} ⟶ a ∩ s ∩ (a - s ∪ ⋃ (set (partList4 (s - a) ts))) = {} ∧ (a - s) ∩ ⋃ (set (partList4 (s - a) ts)) = {}))›*) apply (metis Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*) Int_absorb1 (*‹?B ⊆ ?A ⟹ ?A ∩ ?B = ?B›*) Int_lower2 (*‹?A ∩ ?B ⊆ ?B›*) Un_absorb1 (*‹?A ⊆ ?B ⟹ ?A ∪ ?B = ?B›*) partList4_complete0 (*‹?s ⊆ ⋃ (set ?ts) ⟹ ⋃ (set (partList4 ?s ?ts)) = ⋃ (set ?ts)›*)) (*top goal: ‹⋀a ts s. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ disjoint_list_rec (partList4 s ts); s ⊆ a ∪ ⋃ (set ts); a ∩ ⋃ (set ts) = {} ∧ disjoint_list_rec ts⟧ ⟹ a ⊆ s ⟶ (s ∩ a = {} ⟶ s ≠ {} ⟶ a ∩ ⋃ (set (partList4 s ts)) = {} ∧ disjoint_list_rec (partList4 s ts)) ∧ (s ∩ a ≠ {} ⟶ s ≠ {} ⟶ a ∩ ⋃ (set (partList4 (s - a) ts)) = {})› and 1 goal remains*) apply safe (*goal: ‹⋀a ts s. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ disjoint_list_rec (partList4 s ts); s ⊆ a ∪ ⋃ (set ts); a ∩ ⋃ (set ts) = {} ∧ disjoint_list_rec ts⟧ ⟹ ¬ a ⊆ s ⟶ (s ∩ a = {} ⟶ s ≠ {} ⟶ a ∩ ⋃ (set (partList4 s ts)) = {} ∧ disjoint_list_rec (partList4 s ts)) ∧ (s ∩ a ≠ {} ⟶ s ≠ {} ⟶ a ∩ s ∩ (a - s ∪ ⋃ (set (partList4 (s - a) ts))) = {} ∧ (a - s) ∩ ⋃ (set (partList4 (s - a) ts)) = {})›*) using partList4_complete0 (*‹?s ⊆ ⋃ (set ?ts) ⟹ ⋃ (set (partList4 ?s ?ts)) = ⋃ (set ?ts)›*) apply (metis Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*) Diff_triv (*‹?A ∩ ?B = {} ⟹ ?A - ?B = ?A›*) IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) UnionI (*‹⟦?X ∈ ?C; ?A ∈ ?X⟧ ⟹ ?A ∈ ⋃ ?C›*)) (*top goal: ‹⋀a ts s x xa xb X. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ disjoint_list_rec (partList4 s ts); s ⊆ a ∪ ⋃ (set ts); a ∩ ⋃ (set ts) = {}; disjoint_list_rec ts; x ∈ a; x ∉ s; s ∩ a = {}; xa ∈ s; xa ∉ {}; xb ∈ a; xb ∈ X; X ∈ set (partList4 s ts)⟧ ⟹ xb ∈ {}› and 3 goals remain*) apply (metis Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*) Diff_triv (*‹?A ∩ ?B = {} ⟹ ?A - ?B = ?A›*)) (*top goal: ‹⋀a ts s x xa. ⟦⋀s. s ⊆ ⋃ (set ts) ⟹ disjoint_list_rec (partList4 s ts); s ⊆ a ∪ ⋃ (set ts); a ∩ ⋃ (set ts) = {}; disjoint_list_rec ts; x ∈ a; x ∉ s; s ∩ a = {}; xa ∈ s; xa ∉ {}⟧ ⟹ disjoint_list_rec (partList4 s ts)› and 2 goals remain*) using partList4_complete0 (*‹(?s::?'a::type set) ⊆ ⋃ (set (?ts::?'a::type set list)) ⟹ ⋃ (set (partList4 ?s ?ts)) = ⋃ (set ?ts)›*) by ((metis Diff_subset_conv (*‹(?A - ?B ⊆ ?C) = (?A ⊆ ?B ∪ ?C)›*) IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) UnionI (*‹⟦?X ∈ ?C; ?A ∈ ?X⟧ ⟹ ?A ∈ ⋃ ?C›*))+) lemma union_set_partList4: "⋃(set (partList4 s ts)) = ⋃(set ts)" apply (induction ts arbitrary: s) (*goals: 1. ‹⋀s. ⋃ (set (partList4 s [])) = ⋃ (set [])› 2. ‹⋀a ts s. (⋀s. ⋃ (set (partList4 s ts)) = ⋃ (set ts)) ⟹ ⋃ (set (partList4 s (a # ts))) = ⋃ (set (a # ts))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . private lemma partList4_distinct_hlp: assumes "a ≠ {}" "a ∉ set ts" "disjoint (insert a (set ts))" shows "a ∉ set (partList4 s ts)" proof (-) (*goal: ‹a ∉ set (partList4 s ts)›*) from assms (*‹a ≠ {}› ‹(a::'a::type set) ∉ set (ts::'a::type set list)› ‹disjoint (insert a (set ts))›*) have "¬ a ⊆ ⋃(set ts)" unfolding disjoint_def (*goal: ‹¬ (a::'a::type set) ⊆ ⋃ (set (ts::'a::type set list))›*) by fastforce hence "¬ a ⊆ ⋃(set (partList4 s ts))" using union_set_partList4 (*‹⋃ (set (partList4 (?s::?'a set) (?ts::?'a set list))) = ⋃ (set ?ts)›*) by metis thus "?thesis" (*goal: ‹a ∉ set (partList4 s ts)›*) by blast qed private lemma partList4_distinct: "{} ∉ set ts ⟹ disjoint_list ts ⟹ distinct (partList4 s ts)" proof (induction ts arbitrary: s) (*goals: 1. ‹⋀s. ⟦{} ∉ set []; disjoint_list []⟧ ⟹ distinct (partList4 s [])› 2. ‹⋀a ts s. ⟦⋀s. ⟦{} ∉ set ts; disjoint_list ts⟧ ⟹ distinct (partList4 s ts); {} ∉ set (a # ts); disjoint_list (a # ts)⟧ ⟹ distinct (partList4 s (a # ts))›*) case Nil (*‹{} ∉ set []› ‹disjoint_list []›*) thus "?case" (*goal: ‹distinct (partList4 s [])›*) by simp next (*goal: ‹⋀a ts s. ⟦⋀s. ⟦{} ∉ set ts; disjoint_list ts⟧ ⟹ distinct (partList4 s ts); {} ∉ set (a # ts); disjoint_list (a # ts)⟧ ⟹ distinct (partList4 s (a # ts))›*) case (Cons t ts) (*‹⟦{} ∉ set ts; disjoint_list ts⟧ ⟹ distinct (partList4 ?s ts)› ‹{} ∉ set ((t::'a set) # (ts::'a set list))› ‹disjoint_list ((t::'a set) # (ts::'a set list))›*) have x1: "⋀x xa xb xc. t ∉ set ts ⟹ disjoint (insert t (set ts)) ⟹ xa ∈ t ⟹ xb ∈ s ⟹ xb ∈ t ⟹ xb ∉ {} ⟹ xc ∈ s ⟹ xc ∉ {} ⟹ t ∩ s ∈ set (partList4 (s - t) ts) ⟹ ¬ t ∩ s ⊆ ⋃(set (partList4 (s - t) ts))" apply (simp add: union_set_partList4 (*‹⋃ (set (partList4 ?s ?ts)) = ⋃ (set ?ts)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⋀(x::'b) (xa::'a) (xb::'a) xc::'a. ⟦(t::'a set) ∉ set (ts::'a set list); disjoint (insert t (set ts)); xa ∈ t; xb ∈ (s::'a set); xb ∈ t; xb ∉ {}; xc ∈ s; xc ∉ {}; t ∩ s ∈ set (partList4 (s - t) ts)⟧ ⟹ ¬ t ∩ s ⊆ ⋃ (set (partList4 (s - t) ts))›*) by force have x2: "⋀x xa xb xc. t ∉ set ts ⟹ disjoint (insert t (set ts)) ⟹ x ∈ t ⟹ xa ∈ t ⟹ xa ∉ s ⟹ xb ∈ s ⟹ xc ∈ s ⟹ ¬ t - s ⊆ ⋃(set (partList4 (s - t) ts))" apply (simp add: union_set_partList4 (*‹⋃ (set (partList4 ?s ?ts)) = ⋃ (set ?ts)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*goal: ‹⋀x xa xb xc. ⟦t ∉ set ts; disjoint (insert t (set ts)); x ∈ t; xa ∈ t; xa ∉ s; xb ∈ s; xc ∈ s⟧ ⟹ ¬ t - s ⊆ ⋃ (set (partList4 (s - t) ts))›*) by force from Cons (*‹⟦{} ∉ set ts; disjoint_list ts⟧ ⟹ distinct (partList4 ?s ts)› ‹{} ∉ set ((t::'a set) # (ts::'a set list))› ‹disjoint_list (t # ts)›*) have IH: "distinct (partList4 s ts)" for s using disjoint_sublist (*‹disjoint_list (?t # ?ts) ⟹ disjoint_list ?ts›*) list.set_intros(2) (*‹(?y::?'a) ∈ set (?x22.0::?'a list) ⟹ ?y ∈ set ((?x21.0::?'a) # ?x22.0)›*) by auto from Cons.prems(1,2) (*‹{} ∉ set (t # ts)› ‹disjoint_list (t # ts)›*) IH (*‹distinct (partList4 ?s1 ts)›*) show "?case" (*goal: ‹distinct (partList4 s (t # ts))›*) unfolding disjoint_list_def (*goal: ‹distinct (partList4 s (t # ts))›*) apply simp (*goal: ‹distinct (partList4 s (t # ts))›*) apply safe (*goal: ‹⟦{} ≠ t ∧ {} ∉ set ts; t ∉ set ts ∧ distinct ts ∧ disjoint (insert t (set ts)); ⋀s. distinct (partList4 s ts)⟧ ⟹ (t ⊆ s ⟶ (s ∩ t = {} ⟶ s ≠ {} ⟶ t ∉ set (partList4 s ts)) ∧ (s ∩ t ≠ {} ⟶ s ≠ {} ⟶ t ∉ set (partList4 (s - t) ts))) ∧ (¬ t ⊆ s ⟶ (s ∩ t = {} ⟶ s ≠ {} ⟶ t ∉ set (partList4 s ts)) ∧ (s ∩ t ≠ {} ⟶ s ≠ {} ⟶ t ∩ s ≠ t - s ∧ t ∩ s ∉ set (partList4 (s - t) ts) ∧ t - s ∉ set (partList4 (s - t) ts)))›*) apply (metis partList4_distinct_hlp (*‹⟦?a ≠ {}; ?a ∉ set ?ts; disjoint (insert ?a (set ?ts))⟧ ⟹ ?a ∉ set (partList4 ?s ?ts)›*)) (*top goal: ‹⋀x xa. ⟦⋀s. distinct (partList4 s ts); {} ∉ set ts; t ∉ set ts; distinct ts; disjoint (insert t (set ts)); x ∈ t; x ∉ {}; t ⊆ s; s ∩ t = {}; t ∈ set (partList4 s ts); ¬ False; xa ∈ s⟧ ⟹ xa ∈ {}› and 5 goals remain*) apply (metis partList4_distinct_hlp (*‹⟦(?a::?'a set) ≠ {}; ?a ∉ set (?ts::?'a set list); disjoint (insert ?a (set ?ts))⟧ ⟹ ?a ∉ set (partList4 (?s::?'a set) ?ts)›*)) (*top goal: ‹⋀(x::'a::type) (xa::'a::type) xb::'a::type. ⟦⋀s::'a::type set. distinct (partList4 s (ts::'a::type set list)); {} ∉ set ts; (t::'a::type set) ∉ set ts; distinct ts; disjoint (insert t (set ts)); x ∈ t; x ∉ {}; t ⊆ (s::'a::type set); t ∈ set (partList4 (s - t) ts); ¬ False; xa ∈ s; xa ∈ t; xa ∉ {}; xb ∈ s⟧ ⟹ xb ∈ {}› and 4 goals remain*) apply (metis partList4_distinct_hlp (*‹⟦?a ≠ {}; ?a ∉ set ?ts; disjoint (insert ?a (set ?ts))⟧ ⟹ ?a ∉ set (partList4 ?s ?ts)›*)) (*top goal: ‹⋀x xa xb. ⟦⋀s. distinct (partList4 s ts); {} ∉ set ts; t ∉ set ts; distinct ts; disjoint (insert t (set ts)); x ∈ t; x ∉ {}; xa ∈ t; xa ∉ s; s ∩ t = {}; t ∈ set (partList4 s ts); ¬ False; xb ∈ s⟧ ⟹ xb ∈ {}› and 3 goals remain*) apply blast (*top goal: ‹⋀(x::'a) (xa::'a) (xb::'a) xc::'a. ⟦⋀s::'a set. distinct (partList4 s (ts::'a set list)); {} ∉ set ts; (t::'a set) ∉ set ts; distinct ts; disjoint (insert t (set ts)); x ∈ t; x ∉ {}; xa ∈ t; xa ∉ (s::'a set); xb ∈ s; xb ∈ t; xb ∉ {}; xc ∈ s; xc ∉ {}; t ∩ s = t - s⟧ ⟹ False› and 2 goals remain*) using x1 (*‹⟦t ∉ set ts; disjoint (insert t (set ts)); ?xa ∈ t; ?xb ∈ s; ?xb ∈ t; ?xb ∉ {}; ?xc ∈ s; ?xc ∉ {}; t ∩ s ∈ set (partList4 (s - t) ts)⟧ ⟹ ¬ t ∩ s ⊆ ⋃ (set (partList4 (s - t) ts))›*) apply blast (*top goal: ‹⋀(x::'a) (xa::'a) (xb::'a) xc::'a. ⟦⋀s::'a set. distinct (partList4 s (ts::'a set list)); {} ∉ set ts; (t::'a set) ∉ set ts; distinct ts; disjoint (insert t (set ts)); x ∈ t; x ∉ {}; xa ∈ t; xa ∉ (s::'a set); xb ∈ s; xb ∈ t; xb ∉ {}; xc ∈ s; xc ∉ {}; t ∩ s ∈ set (partList4 (s - t) ts)⟧ ⟹ False› and 1 goal remains*) using x2 (*‹⟦t ∉ set ts; disjoint (insert t (set ts)); ?x1 ∈ t; ?xa1 ∈ t; ?xa1 ∉ s; ?xb1 ∈ s; ?xc1 ∈ s⟧ ⟹ ¬ t - s ⊆ ⋃ (set (partList4 (s - t) ts))›*) by blast qed lemma partList4_disjoint_list: assumes "s ⊆ ⋃(set ts)" "disjoint_list ts" "{} ∉ set ts" shows "disjoint_list (partList4 s ts)" unfolding disjoint_list_def (*goal: ‹distinct (partList4 s ts) ∧ disjoint (set (partList4 s ts))›*) proof (standard) (*goals: 1. ‹distinct (partList4 s ts)› 2. ‹disjoint (set (partList4 s ts))›*) from assms(2,3) (*‹disjoint_list ts› ‹{} ∉ set ts›*) show "distinct (partList4 s ts)" using partList4_distinct (*‹⟦{} ∉ set ?ts; disjoint_list ?ts⟧ ⟹ distinct (partList4 ?s ?ts)›*) disjoint_list_def (*‹disjoint_list (?ls::?'a set list) ≡ distinct ?ls ∧ disjoint (set ?ls)›*) by auto show "disjoint (set (partList4 s ts))" proof (-) (*goal: ‹disjoint (set (partList4 s ts))›*) have disjoint_list_disjoint_list_rec: "disjoint_list ts ⟹ disjoint_list_rec ts" proof (induction ts) (*goals: 1. ‹disjoint_list [] ⟹ disjoint_list_rec []› 2. ‹⋀a ts. ⟦disjoint_list ts ⟹ disjoint_list_rec ts; disjoint_list (a # ts)⟧ ⟹ disjoint_list_rec (a # ts)›*) case Cons (*‹disjoint_list ts_ ⟹ disjoint_list_rec ts_› ‹disjoint_list (a_ # ts_)›*) thus "?case" (*goal: ‹disjoint_list_rec (a_ # ts_)›*) by (auto simp add: disjoint_list_def (*‹disjoint_list (?ls::?'a set list) ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint (?ts::?'a set set) ≡ ∀A::?'a set∈?ts. ∀B::?'a set∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) qed (simp) (*solved the remaining goal: ‹disjoint_list [] ⟹ disjoint_list_rec []›*) with partList4_disjoint (*‹⟦?s ⊆ ⋃ (set ?ts); disjoint_list_rec ?ts⟧ ⟹ disjoint_list_rec (partList4 ?s ?ts)›*) disjoint_equi (*‹disjoint_list_rec ?ts ⟹ disjoint (set ?ts)›*) assms(1,2) (*‹s ⊆ ⋃ (set ts)› ‹disjoint_list ts›*) show "?thesis" (*goal: ‹disjoint (set (partList4 (s::'a set) (ts::'a set list)))›*) by blast qed qed lemma partitioning1_subset: "a ⊆ ⋃ (set ts) ⟹ a ⊆ ⋃ (set (partitioning1 ss ts))" apply (induction ss arbitrary: ts a) (*goals: 1. ‹⋀ts a. a ⊆ ⋃ (set ts) ⟹ a ⊆ ⋃ (set (partitioning1 [] ts))› 2. ‹⋀a ss ts aa. ⟦⋀ts a. a ⊆ ⋃ (set ts) ⟹ a ⊆ ⋃ (set (partitioning1 ss ts)); aa ⊆ ⋃ (set ts)⟧ ⟹ aa ⊆ ⋃ (set (partitioning1 (a # ss) ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: partList4_subset (*‹?a ⊆ ⋃ (set ?ts) ⟹ ?a ⊆ ⋃ (set (partList4 ?b ?ts))›*)) (*proven 2 subgoals*) . lemma partitioning1_disjoint_list: "{} ∉ (set ts) ⟹ ⋃ (set ss) ⊆ ⋃ (set ts) ⟹ disjoint_list ts ⟹ disjoint_list (partitioning1 ss ts)" proof (induction ss) (*goals: 1. ‹⟦{} ∉ set (ts::'a::type set list); ⋃ (set []) ⊆ ⋃ (set ts); disjoint_list ts⟧ ⟹ disjoint_list (partitioning1 [] ts)› 2. ‹⋀(a::'a::type set) ss::'a::type set list. ⟦⟦{} ∉ set (ts::'a::type set list); ⋃ (set ss) ⊆ ⋃ (set ts); disjoint_list ts⟧ ⟹ disjoint_list (partitioning1 ss ts); {} ∉ set ts; ⋃ (set (a # ss)) ⊆ ⋃ (set ts); disjoint_list ts⟧ ⟹ disjoint_list (partitioning1 (a # ss) ts)›*) case Nil (*‹{} ∉ set ts› ‹⋃ (set []) ⊆ ⋃ (set ts)› ‹disjoint_list ts›*) thus "?case" (*goal: ‹disjoint_list (partitioning1 [] (ts::'a set list))›*) by simp next (*goal: ‹⋀a ss. ⟦⟦{} ∉ set ts; ⋃ (set ss) ⊆ ⋃ (set ts); disjoint_list ts⟧ ⟹ disjoint_list (partitioning1 ss ts); {} ∉ set ts; ⋃ (set (a # ss)) ⊆ ⋃ (set ts); disjoint_list ts⟧ ⟹ disjoint_list (partitioning1 (a # ss) ts)›*) case (Cons t ts) (*‹⟦{} ∉ set ts; ⋃ (set ts) ⊆ ⋃ (set ts); disjoint_list ts⟧ ⟹ disjoint_list (partitioning1 ts ts)› ‹{} ∉ set ts› ‹⋃ (set ((t::'a::type set) # (ts::'a::type set list))) ⊆ ⋃ (set (ts::'a::type set list))› ‹disjoint_list ts›*) thus "?case" (*goal: ‹disjoint_list (partitioning1 (t # ts) ts)›*) apply clarsimp (*goal: ‹disjoint_list (partitioning1 ((t::'a set) # (ts::'a set list)) (ts::'a set list))›*) apply (rule partList4_disjoint_list (*‹⟦?s ⊆ ⋃ (set ?ts); disjoint_list ?ts; {} ∉ set ?ts⟧ ⟹ disjoint_list (partList4 ?s ?ts)›*)) (*goal: ‹⟦disjoint_list (partitioning1 ts ts); {} ∉ set ts; disjoint_list ts; t ⊆ ⋃ (set ts); ⋃ (set ts) ⊆ ⋃ (set ts)⟧ ⟹ disjoint_list (partList4 t (partitioning1 ts ts))›*) using partitioning1_subset (*‹?a ⊆ ⋃ (set ?ts) ⟹ ?a ⊆ ⋃ (set (partitioning1 ?ss ?ts))›*) apply metis (*top goal: ‹⟦disjoint_list (partitioning1 ts ts); {} ∉ set ts; disjoint_list ts; t ⊆ ⋃ (set ts); ⋃ (set ts) ⊆ ⋃ (set ts)⟧ ⟹ t ⊆ ⋃ (set (partitioning1 ts ts))› and 2 goals remain*) apply blast (*top goal: ‹⟦disjoint_list (partitioning1 ts ts); {} ∉ set ts; disjoint_list ts; t ⊆ ⋃ (set ts); ⋃ (set ts) ⊆ ⋃ (set ts)⟧ ⟹ disjoint_list (partitioning1 ts ts)› and 1 goal remains*) using partitioning1_empty0 (*‹{} ∉ set ?ts ⟹ {} ∉ set (partitioning1 ?ss ?ts)›*) by metis qed private lemma partitioning1_disjoint: "⋃ (set ss) ⊆ ⋃ (set ts) ⟹ disjoint_list_rec ts ⟹ disjoint_list_rec (partitioning1 ss ts)" proof (induction ss arbitrary: ts) (*goals: 1. ‹⋀ts. ⟦⋃ (set []) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partitioning1 [] ts)› 2. ‹⋀a ss ts. ⟦⋀ts. ⟦⋃ (set ss) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partitioning1 ss ts); ⋃ (set (a # ss)) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partitioning1 (a # ss) ts)›*) qed (simp_all add: partList4_disjoint partitioning1_subset) (*solves the remaining goals: 1. ‹⋀ts. ⟦⋃ (set []) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partitioning1 [] ts)› 2. ‹⋀a ss ts. ⟦⋀ts. ⟦⋃ (set ss) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partitioning1 ss ts); ⋃ (set (a # ss)) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ disjoint_list_rec (partitioning1 (a # ss) ts)›*) private lemma partitioning_equi: "{} ∉ set ts ⟹ disjoint_list_rec ts ⟹ ⋃ (set ss) ⊆ ⋃ (set ts) ⟹ set(partitioning1 ss ts) = partitioning_nontail ss (set ts) - {{}}" proof (induction ss) (*goals: 1. ‹⟦{} ∉ set ts; disjoint_list_rec ts; ⋃ (set []) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 [] ts) = partitioning_nontail [] (set ts) - {{}}› 2. ‹⋀a ss. ⟦⟦{} ∉ set ts; disjoint_list_rec ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 ss ts) = partitioning_nontail ss (set ts) - {{}}; {} ∉ set ts; disjoint_list_rec ts; ⋃ (set (a # ss)) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 (a # ss) ts) = partitioning_nontail (a # ss) (set ts) - {{}}›*) case Nil (*‹{} ∉ set ts› ‹disjoint_list_rec ts› ‹⋃ (set []) ⊆ ⋃ (set ts)›*) thus "?case" (*goal: ‹set (partitioning1 [] ts) = partitioning_nontail [] (set ts) - {{}}›*) by simp next (*goal: ‹⋀a ss. ⟦⟦{} ∉ set ts; disjoint_list_rec ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 ss ts) = partitioning_nontail ss (set ts) - {{}}; {} ∉ set ts; disjoint_list_rec ts; ⋃ (set (a # ss)) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 (a # ss) ts) = partitioning_nontail (a # ss) (set ts) - {{}}›*) case (Cons s ss) (*‹⟦{} ∉ set ts; disjoint_list_rec ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 ss ts) = partitioning_nontail ss (set ts) - {{}}› ‹{} ∉ set ts› ‹disjoint_list_rec ts› ‹⋃ (set (s # ss)) ⊆ ⋃ (set ts)›*) have addSubsetSet_empty: "addSubsetSet s (ts - {{}}) - {{}} = addSubsetSet s ts - {{}}" for s and ts :: "'a set set" unfolding addSubsetSet_def (*goal: ‹insert (s - ⋃ (ts - {{}})) ((∩) s ` (ts - {{}})) ∪ (λx. x - s) ` (ts - {{}}) - {{}} = insert (s - ⋃ ts) ((∩) s ` ts) ∪ (λx. x - s) ` ts - {{}}›*) by blast have r: "disjoint_list_rec ts ⟹ s ⊆ ⋃(set ts) ⟹ addSubsetSet s (set ts) - {{}} = set (partList4 s ts) - {{}}" for ts :: "'a set list" unfolding partList4 (*goal: ‹⟦disjoint_list_rec ts; s ⊆ ⋃ (set ts)⟧ ⟹ addSubsetSet s (set ts) - {{}} = set (partList3 s ts) - {{}}›*) by (simp add: partList0_addSubsetSet_equi (*‹?s ⊆ ⋃ (set ?ts) ⟹ addSubsetSet ?s (set ?ts) - {{}} = set (partList0 ?s ?ts) - {{}}›*) partList0_partList1_equi (*‹disjoint_list_rec ?ts ⟹ set (partList0 ?s ?ts) = set (partList1 ?s ?ts)›*) partList1_partList2_equi (*‹set (partList1 ?s ?ts) - {{}} = set (partList2 ?s ?ts) - {{}}›*) partList2_partList3_equi (*‹set (partList2 ?s ?ts) - {{}} = set (partList3 ?s ?ts) - {{}}›*)) have 1: "disjoint_list_rec (partitioning1 ss ts)" using partitioning1_disjoint (*‹⟦⋃ (set ?ss) ⊆ ⋃ (set ?ts); disjoint_list_rec ?ts⟧ ⟹ disjoint_list_rec (partitioning1 ?ss ?ts)›*) Cons.prems (*‹{} ∉ set ts› ‹disjoint_list_rec ts› ‹⋃ (set (s # ss)) ⊆ ⋃ (set ts)›*) by auto from Cons.prems (*‹{} ∉ set ts› ‹disjoint_list_rec ts› ‹⋃ (set ((s::'a set) # (ss::'a set list))) ⊆ ⋃ (set (ts::'a set list))›*) have 2: "s ⊆ ⋃(set (partitioning1 ss ts))" by (meson Sup_upper (*‹?x ∈ ?A ⟹ ?x ≤ Sup ?A›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1) partitioning1_subset (*‹?a ⊆ ⋃ (set ?ts) ⟹ ?a ⊆ ⋃ (set (partitioning1 ?ss ?ts))›*)) from Cons (*‹⟦{} ∉ set ts; disjoint_list_rec ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ set (partitioning1 ss ts) = partitioning_nontail ss (set ts) - {{}}› ‹{} ∉ set ts› ‹disjoint_list_rec ts› ‹⋃ (set ((s::'a set) # (ss::'a set list))) ⊆ ⋃ (set (ts::'a set list))›*) have IH: "set (partitioning1 ss ts) = partitioning_nontail ss (set ts) - {{}}" by auto with r[OF 1 2] (*‹addSubsetSet s (set (partitioning1 ss ts)) - {{}} = set (partList4 s (partitioning1 ss ts)) - {{}}›*) show "?case" (*goal: ‹set (partitioning1 ((s::'a set) # (ss::'a set list)) (ts::'a set list)) = partitioning_nontail (s # ss) (set ts) - {{}}›*) by (simp add: partList4_empty (*‹{} ∉ set ?ts ⟹ {} ∉ set (partList4 ?s ?ts)›*) addSubsetSet_empty (*‹addSubsetSet ?s (?ts - {{}}) - {{}} = addSubsetSet ?s ?ts - {{}}›*)) qed lemma ipPartitioning_helper_opt: "{} ∉ set ts ⟹ disjoint_list ts ⟹ ⋃ (set ss) ⊆ ⋃ (set ts) ⟹ ipPartition (set ss) (set (partitioning1 ss ts))" apply (drule disjoint_list_disjoint_list_rec (*‹disjoint_list ?ts ⟹ disjoint_list_rec ?ts›*)) (*goal: ‹⟦{} ∉ set ts; disjoint_list ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ ipPartition (set ss) (set (partitioning1 ss ts))›*) apply (simp add: partitioning_equi (*‹⟦{} ∉ set ?ts; disjoint_list_rec ?ts; ⋃ (set ?ss) ⊆ ⋃ (set ?ts)⟧ ⟹ set (partitioning1 ?ss ?ts) = partitioning_nontail ?ss (set ?ts) - {{}}›*) partitioning_nottail_equi (*‹partitioning_nontail ?ss ?ts = partitioning ?ss ?ts›*)) (*goal: ‹⟦{} ∉ set ts; ⋃ (set ss) ⊆ ⋃ (set ts); disjoint_list_rec ts⟧ ⟹ ipPartition (set ss) (set (partitioning1 ss ts))›*) by (meson Diff_subset (*‹?A - ?B ⊆ ?A›*) disjoint_equi (*‹disjoint_list_rec ?ts ⟹ disjoint (set ?ts)›*) ipPartition_def (*‹ipPartition ?A ?B ≡ ∀a∈?A. ∀b∈?B. a ∩ b = {} ∨ b ⊆ a›*) ipPartitioning_helper (*‹disjoint ?As ⟹ ipPartition (set ?ts) (partitioning ?ts ?As)›*) subsetCE (*‹⟦?A ⊆ ?B; ?c ∉ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*)) lemma complete_helper: "{} ∉ set ts ⟹ ⋃ (set ss) ⊆ ⋃ (set ts)⟹ ⋃ (set ts) = ⋃ (set (partitioning1 ss ts))" apply (induction ss arbitrary: ts) (*goals: 1. ‹⋀ts. ⟦{} ∉ set ts; ⋃ (set []) ⊆ ⋃ (set ts)⟧ ⟹ ⋃ (set ts) = ⋃ (set (partitioning1 [] ts))› 2. ‹⋀a ss ts. ⟦⋀ts. ⟦{} ∉ set ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ ⋃ (set ts) = ⋃ (set (partitioning1 ss ts)); {} ∉ set ts; ⋃ (set (a # ss)) ⊆ ⋃ (set ts)⟧ ⟹ ⋃ (set ts) = ⋃ (set (partitioning1 (a # ss) ts))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀a ss ts. ⟦⋀ts. ⟦{} ∉ set ts; ⋃ (set ss) ⊆ ⋃ (set ts)⟧ ⟹ ⋃ (set ts) = ⋃ (set (partitioning1 ss ts)); {} ∉ set ts; ⋃ (set (a # ss)) ⊆ ⋃ (set ts)⟧ ⟹ ⋃ (set ts) = ⋃ (set (partitioning1 (a # ss) ts))›*) apply (metis partList4_complete0 (*‹?s ⊆ ⋃ (set ?ts) ⟹ ⋃ (set (partList4 ?s ?ts)) = ⋃ (set ?ts)›*)) (*proven 2 subgoals*) . lemma "partitioning1 [{1::nat},{2},{}] [{1},{},{2},{3}] = [{1}, {}, {2}, {3}]" by eval lemma partitioning_foldr: "partitioning X B = foldr addSubsetSet X B" apply (induction X) (*goals: 1. ‹partitioning [] (B::'a set set) = foldr addSubsetSet [] B› 2. ‹⋀(a::'a set) X::'a set list. partitioning X (B::'a set set) = foldr addSubsetSet X B ⟹ partitioning (a # X) B = foldr addSubsetSet (a # X) B› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⋀a X. partitioning X B = foldr addSubsetSet X B ⟹ partitioning (a # X) B = foldr addSubsetSet (a # X) B›*) apply (metis partitioningCom (*‹addSubsetSet ?a (partitioning ?ss ?ts) = partitioning ?ss (addSubsetSet ?a ?ts)›*)) (*proven 2 subgoals*) . lemma "ipPartition (set X) (foldr addSubsetSet X {})" apply (subst partitioning_foldr[symmetric] (*‹foldr addSubsetSet ?X ?B = partitioning ?X ?B›*)) (*goal: ‹ipPartition (set X) (foldr addSubsetSet X {})›*) using ipPartitioning (*‹ipPartition (set ?ts) (partitioning ?ts {})›*) by auto lemma "⋃ (set X) = ⋃ (foldr addSubsetSet X {})" apply (subst partitioning_foldr[symmetric] (*‹foldr addSubsetSet ?X ?B = partitioning ?X ?B›*)) (*goal: ‹⋃ (set X) = ⋃ (foldr addSubsetSet X {})›*) by (simp add: coversallPartitioning (*‹⋃ (set ?ts) = ⋃ (partitioning ?ts {})›*)) lemma "partitioning1 X B = foldr partList4 X B" apply (induction X) (*goals: 1. ‹partitioning1 [] (B::'a set list) = foldr partList4 [] B› 2. ‹⋀(a::'a set) X::'a set list. partitioning1 X (B::'a set list) = foldr partList4 X B ⟹ partitioning1 (a # X) B = foldr partList4 (a # X) B› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma "ipPartition (set X) (set (partitioning1 X [UNIV]))" apply (rule ipPartitioning_helper_opt (*‹⟦{} ∉ set ?ts; disjoint_list ?ts; ⋃ (set ?ss) ⊆ ⋃ (set ?ts)⟧ ⟹ ipPartition (set ?ss) (set (partitioning1 ?ss ?ts))›*)) (*goals: 1. ‹{} ∉ set [UNIV]› 2. ‹disjoint_list [UNIV]› 3. ‹⋃ (set X) ⊆ ⋃ (set [UNIV])› discuss goal 1*) apply (simp add: disjoint_list_def (*‹disjoint_list (?ls::?'a set list) ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint (?ts::?'a set set) ≡ ∀A::?'a set∈?ts. ∀B::?'a set∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*discuss goal 2*) apply (simp add: disjoint_list_def (*‹disjoint_list ?ls ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*discuss goal 3*) apply (simp add: disjoint_list_def (*‹disjoint_list ?ls ≡ distinct ?ls ∧ disjoint (set ?ls)›*) disjoint_def (*‹disjoint ?ts ≡ ∀A∈?ts. ∀B∈?ts. A ≠ B ⟶ A ∩ B = {}›*)) (*proven 3 subgoals*) . lemma "(⋃(set (partitioning1 X [UNIV]))) = UNIV" apply (subgoal_tac "UNIV = ⋃ (set (partitioning1 X [UNIV]))") (*goals: 1. ‹UNIV = ⋃ (set (partitioning1 X [UNIV])) ⟹ ⋃ (set (partitioning1 X [UNIV])) = UNIV› 2. ‹UNIV = ⋃ (set (partitioning1 X [UNIV]))› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule complete_helper[where ts="[UNIV]", simplified] (*‹UNIV = ⋃ (set (partitioning1 (?ss::?'b1 set list) [UNIV]))›*)) (*proven 2 subgoals*) . end end
{ "path": "afp-2025-02-12/thys/Simple_Firewall/Common/IP_Partition_Preliminaries.thy", "repo": "afp-2025-02-12", "sha": "b7232d88ea051fb5de502277d1e0ee553b1cf4774a13e52b470d4a18c4b6e8b6" }
(* Title: HOL/Analysis/Metric_Arith.thy Author: Maximilian Schäffeler (port from HOL Light) *) chapter ‹Functional Analysis› section✐‹tag unimportant› ‹A decision procedure for metric spaces› theory Metric_Arith imports HOL.Real_Vector_Spaces begin text✐‹tag unimportant› ‹ A port of the decision procedure ``Formalization of metric spaces in HOL Light'' \<^cite>‹"DBLP:journals/jar/Maggesi18"› for the type class @{class metric_space}, with the ‹Argo› solver as backend. › named_theorems metric_prenex named_theorems metric_nnf named_theorems metric_unfold named_theorems metric_pre_arith lemmas pre_arith_simps = max.bounded_iff max_less_iff_conj le_max_iff_disj less_max_iff_disj simp_thms HOL.eq_commute declare pre_arith_simps [metric_pre_arith] lemmas unfold_simps = Un_iff subset_iff disjoint_iff_not_equal Ball_def Bex_def declare unfold_simps [metric_unfold] declare HOL.nnf_simps(4) [metric_prenex] lemma imp_prenex [metric_prenex]: "⋀P Q. (∃x. P x) ⟶ Q ≡ ∀x. (P x ⟶ Q)" "⋀P Q. P ⟶ (∃x. Q x) ≡ ∃x. (P ⟶ Q x)" "⋀P Q. (∀x. P x) ⟶ Q ≡ ∃x. (P x ⟶ Q)" "⋀P Q. P ⟶ (∀x. Q x) ≡ ∀x. (P ⟶ Q x)" (*goals: 1. ‹⋀P Q. (∃x. P x) ⟶ Q ≡ ∀x. P x ⟶ Q› 2. ‹⋀P Q. P ⟶ (∃x. Q x) ≡ ∃x. P ⟶ Q x› 3. ‹⋀P Q. (∀x. P x) ⟶ Q ≡ ∃x. P x ⟶ Q› 4. ‹⋀P Q. P ⟶ (∀x. Q x) ≡ ∀x. P ⟶ Q x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . lemma ex_prenex [metric_prenex]: "⋀P Q. (∃x. P x) ∧ Q ≡ ∃x. (P x ∧ Q)" "⋀P Q. P ∧ (∃x. Q x) ≡ ∃x. (P ∧ Q x)" "⋀P Q. (∃x. P x) ∨ Q ≡ ∃x. (P x ∨ Q)" "⋀P Q. P ∨ (∃x. Q x) ≡ ∃x. (P ∨ Q x)" "⋀P. ¬(∃x. P x) ≡ ∀x. ¬P x" (*goals: 1. ‹⋀P Q. (∃x. P x) ∧ Q ≡ ∃x. P x ∧ Q› 2. ‹⋀P Q. P ∧ (∃x. Q x) ≡ ∃x. P ∧ Q x› 3. ‹⋀P Q. (∃x. P x) ∨ Q ≡ ∃x. P x ∨ Q› 4. ‹⋀P Q. P ∨ (∃x. Q x) ≡ ∃x. P ∨ Q x› 5. ‹⋀P. ∄x. P x ≡ ∀x. ¬ P x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . lemma all_prenex [metric_prenex]: "⋀P Q. (∀x. P x) ∧ Q ≡ ∀x. (P x ∧ Q)" "⋀P Q. P ∧ (∀x. Q x) ≡ ∀x. (P ∧ Q x)" "⋀P Q. (∀x. P x) ∨ Q ≡ ∀x. (P x ∨ Q)" "⋀P Q. P ∨ (∀x. Q x) ≡ ∀x. (P ∨ Q x)" "⋀P. ¬(∀x. P x) ≡ ∃x. ¬P x" (*goals: 1. ‹⋀P Q. (∀x. P x) ∧ Q ≡ ∀x. P x ∧ Q› 2. ‹⋀P Q. P ∧ (∀x. Q x) ≡ ∀x. P ∧ Q x› 3. ‹⋀P Q. (∀x. P x) ∨ Q ≡ ∀x. P x ∨ Q› 4. ‹⋀P Q. P ∨ (∀x. Q x) ≡ ∀x. P ∨ Q x› 5. ‹⋀P. ¬ (∀x. P x) ≡ ∃x. ¬ P x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . lemma nnf_thms [metric_nnf]: "(¬ (P ∧ Q)) = (¬ P ∨ ¬ Q)" "(¬ (P ∨ Q)) = (¬ P ∧ ¬ Q)" "(P ⟶ Q) = (¬ P ∨ Q)" "(P = Q) ⟷ (P ∨ ¬ Q) ∧ (¬ P ∨ Q)" "(¬ (P = Q)) ⟷ (¬ P ∨ ¬ Q) ∧ (P ∨ Q)" "(¬ ¬ P) = P" (*goals: 1. ‹(¬ (P ∧ Q)) = (¬ P ∨ ¬ Q)› 2. ‹(¬ (P ∨ Q)) = (¬ P ∧ ¬ Q)› 3. ‹(P ⟶ Q) = (¬ P ∨ Q)› 4. ‹(P = Q) = ((P ∨ ¬ Q) ∧ (¬ P ∨ Q))› 5. ‹(P ≠ Q) = ((¬ P ∨ ¬ Q) ∧ (P ∨ Q))› 6. ‹(¬ ¬ P) = P› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*discuss goal 5*) apply blast (*discuss goal 6*) apply blast (*proven 6 subgoals*) . lemmas nnf_simps = nnf_thms linorder_not_less linorder_not_le declare nnf_simps[metric_nnf] lemma ball_insert: "(∀x∈insert a B. P x) = (P a ∧ (∀x∈B. P x))" by blast lemma Sup_insert_insert: fixes a::real shows "Sup (insert a (insert b s)) = Sup (insert (max a b) s)" by (simp add: Sup_real_def (*‹Sup ?X = (LEAST z. ∀x∈?X. x ≤ z)›*)) lemma real_abs_dist: "¦dist x y¦ = dist x y" by simp lemma maxdist_thm [THEN HOL.eq_reflection]: assumes "finite s" "x ∈ s" "y ∈ s" defines "⋀a. f a ≡ ¦dist x a - dist a y¦" shows "dist x y = Sup (f ` s)" proof (-) (*goal: ‹dist (x::'a) (y::'a) = Sup ((f::'a ⇒ real) ` (s::'a set))›*) have "dist x y ≤ Sup (f ` s)" proof (-) (*goal: ‹dist x y ≤ Sup (f ` s)›*) have "finite (f ` s)" by (simp add: ‹finite s›) moreover have "¦dist x y - dist y y¦ ∈ f ` s" by (metis ‹y ∈ s› f_def (*‹f ?a ≡ ¦dist x ?a - dist ?a y¦›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) ultimately show "?thesis" (*goal: ‹dist x y ≤ Sup (f ` s)›*) using le_cSup_finite (*‹⟦finite ?X; ?x ∈ ?X⟧ ⟹ ?x ≤ Sup ?X›*) by simp qed also (*calculation: ‹dist x y ≤ Sup (f ` s)›*) have "Sup (f ` s) ≤ dist x y" using ‹x ∈ s› (*‹x ∈ s›*) cSUP_least[of s f] (*‹⟦s ≠ {}; ⋀x. x ∈ s ⟹ f x ≤ ?M⟧ ⟹ Sup (f ` s) ≤ ?M›*) abs_dist_diff_le (*‹¦dist (?a::?'a) (?b::?'a) - dist ?b (?c::?'a)¦ ≤ dist ?a ?c›*) unfolding f_def (*goal: ‹(SUP a::'a::metric_space∈s::'a::metric_space set. ¦dist (x::'a::metric_space) a - dist a (y::'a::metric_space)¦) ≤ dist x y›*) by blast finally (*calculation: ‹dist x y = Sup (f ` s)›*) show "?thesis" (*goal: ‹dist x y = Sup (f ` s)›*) . qed theorem metric_eq_thm [THEN HOL.eq_reflection]: "x ∈ s ⟹ y ∈ s ⟹ x = y ⟷ (∀a∈s. dist x a = dist y a)" by auto ML_file ‹metric_arith.ML› method_setup metric = ‹ Scan.succeed (SIMPLE_METHOD' o Metric_Arith.metric_arith_tac) › "prove simple linear statements in metric spaces (∀∃⇩p fragment)" end
{ "path": "Isabelle2024/src/HOL/Analysis/Metric_Arith.thy", "repo": "Isabelle2024", "sha": "9c5a357b071cb2313a3c13b0d76d4ef815e730e3fc5a8475b49e2031308f7b07" }
(* Quadratics.thy author: Mike Stannett Date: 4 Jan 2023 *) section ‹ Quadratics › text ‹ This theory shows how to find the roots of a quadratic, assuming that roots exist (AxEField). › theory "Quadratics" imports Functions AxEField begin class Quadratics = Functions + AxEField begin abbreviation quadratic :: "'a ⇒ 'a ⇒ 'a ⇒ ('a ⇒ 'a)" where "quadratic a b c ≡ λ x . a*(sqr x) + b*x + c" abbreviation qroot :: "'a ⇒ 'a ⇒ 'a ⇒ 'a ⇒ bool" where "qroot a b c r ≡ (quadratic a b c) r = 0" abbreviation qroots :: "'a ⇒ 'a ⇒ 'a ⇒ 'a set" where "qroots a b c ≡ { r . qroot a b c r }" abbreviation discriminant :: "'a ⇒ 'a ⇒ 'a ⇒ 'a" where "discriminant a b c ≡ (sqr b) - 4*a*c" abbreviation qcase1 :: "'a ⇒ 'a ⇒ 'a ⇒ bool" where "qcase1 a b c ≡ (a = 0 ∧ b = 0 ∧ c = 0)" abbreviation qcase2 :: "'a ⇒ 'a ⇒ 'a ⇒ bool" where "qcase2 a b c ≡ (a = 0 ∧ b = 0 ∧ c ≠ 0)" abbreviation qcase3 :: "'a ⇒ 'a ⇒ 'a ⇒ bool" where "qcase3 a b c ≡ (a = 0 ∧ b ≠ 0 ∧ (c = 0 ∨ c ≠0))" abbreviation qcase4 :: "'a ⇒ 'a ⇒ 'a ⇒ bool" where "qcase4 a b c ≡ (a ≠ 0 ∧ discriminant a b c < 0)" abbreviation qcase5 :: "'a ⇒ 'a ⇒ 'a ⇒ bool" where "qcase5 a b c ≡ (a ≠ 0 ∧ discriminant a b c = 0)" abbreviation qcase6 :: "'a ⇒ 'a ⇒ 'a ⇒ bool" where "qcase6 a b c ≡ (a ≠ 0 ∧ discriminant a b c > 0)" lemma lemQuadRootCondition: assumes "a ≠ 0" shows "(sqr (2*a*r + b) = discriminant a b c) ⟷ qroot a b c r" proof (-) (*goal: ‹(sqr (2 * a * r + b) = discriminant a b c) = qroot a b c r›*) have "sqr (2*a*r) = (4*a) * (a * sqr r)" using lemSqrMult (*‹sqr (?a * ?b) = sqr ?a * sqr ?b›*) local.numeral_sqr (*‹numeral (Num.sqr ?k) = sqr (numeral ?k)›*) mult_assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*) sqr.simps(1) (*‹Num.sqr num.One = num.One›*) sqr.simps(2) (*‹Num.sqr (num.Bit0 ?n) = num.Bit0 (num.Bit0 (Num.sqr ?n))›*) by metis moreover have "2*(2*a*r)*b = (4*a) * (b*r)" by (metis dbl_def (*‹neg_numeral_class.dbl (?x::'a) = ?x + ?x›*) dbl_simps( (*‹neg_numeral_class.dbl (numeral (?k::num)) = numeral (num.Bit0 ?k)›*) 5) mult.left_commute (*‹(?b::'a) * ((?a::'a) * (?c::'a)) = ?a * (?b * ?c)›*) mult_2 (*‹(2::'a) * (?z::'a) = ?z + ?z›*) mult_2_right (*‹(?z::'a) * (2::'a) = ?z + ?z›*) mult_assoc (*‹(?a::'a) * (?b::'a) * (?c::'a) = ?a * (?b * ?c)›*)) ultimately have s: "sqr (2*a*r) + 2*(2*a*r)*b = (4*a) * ((a * sqr r) + b *r)" by (simp add: local.distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*)) have "sqr(2*a*r + b) = sqr (2*a*r) + 2*(2*a*r)*b + sqr b" using lemSqrSum (*‹sqr (?x + ?y) = sqr ?x + 2 * ?x * ?y + sqr ?y›*) by auto moreover have "… = (4*a) * ((a * sqr r) + b *r) + sqr b" using s (*‹sqr (2 * a * r) + 2 * (2 * a * r) * b = 4 * a * (a * sqr r + b * r)›*) by auto moreover have "… = (4*a) * ((a * sqr r) + b *r + c) - (4*a)*c + sqr b" by (simp add: distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*)) ultimately have eqn1: "sqr(2*a*r + b) = (4*a)*(quadratic a b c r) + (discriminant a b c)" by (simp add: add_diff_eq (*‹?a + (?b - ?c) = ?a + ?b - ?c›*) diff_add_eq (*‹?a - ?b + ?c = ?a + ?c - ?b›*)) { assume "qroot a b c r" (*‹qroot (a::'a) (b::'a) (c::'a) (r::'a)›*) hence "sqr (2*a*r + b) = discriminant a b c" using eqn1 (*‹sqr (2 * a * r + b) = 4 * a * quadratic a b c r + discriminant a b c›*) by simp } hence l2r: "qroot a b c r ⟶ sqr (2*a*r + b) = discriminant a b c" by auto { assume "sqr (2*a*r + b) = discriminant a b c" (*‹sqr ((2::'a) * (a::'a) * (r::'a) + (b::'a)) = discriminant a b (c::'a)›*) hence "0 = (4*a)*(quadratic a b c r)" using eqn1 (*‹sqr (2 * a * r + b) = 4 * a * quadratic a b c r + discriminant a b c›*) by auto hence "qroot a b c r" by (metis assms (*‹a ≠ 0›*) divisors_zero (*‹?a * ?b = 0 ⟹ ?a = 0 ∨ ?b = 0›*) zero_neq_numeral (*‹0 ≠ numeral ?n›*)) } hence "(sqr (2*a*r + b) = discriminant a b c) ⟶ qroot a b c r" by blast thus "?thesis" (*goal: ‹(sqr (2 * a * r + b) = discriminant a b c) = qroot a b c r›*) using l2r (*‹qroot a b c r ⟶ sqr (2 * a * r + b) = discriminant a b c›*) by blast qed lemma lemQuadraticCasesComplete: shows "qcase1 a b c ∨ qcase2 a b c ∨ qcase3 a b c ∨ qcase4 a b c ∨ qcase5 a b c ∨ qcase6 a b c" using not_less_iff_gr_or_eq (*‹(¬ ?x < ?y) = (?y < ?x ∨ ?x = ?y)›*) by blast lemma lemQCase1: assumes "qcase1 a b c" shows "∀ r . qroot a b c r" using assms (*‹qcase1 a b c›*) by simp lemma lemQCase2: assumes "qcase2 a b c" shows "¬ (∃ r . qroot a b c r)" by (simp add: assms (*‹qcase2 a b c›*)) lemma lemQCase3: assumes "qcase3 a b c" shows "qroot a b c r ⟷ r = -c/b" proof (-) (*goal: ‹qroot a b c r = (r = - c / b)›*) have "qroot a b c r ⟶ r = -c/b" proof (-) (*goal: ‹qroot a b c r ⟶ r = - c / b›*) { assume hyp: "qroot a b c r" (*‹qroot (a::'a) (b::'a) (c::'a) (r::'a)›*) hence "b*r + c = 0" using assms (*‹qcase3 a b c›*) by auto hence "b*r = -c" by (simp add: local.eq_neg_iff_add_eq_0 (*‹(?a = - ?b) = (?a + ?b = 0)›*)) hence "r = -c/b" by (metis assms (*‹qcase3 a b c›*) local.nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b / ?a = ?b›*)) } thus "?thesis" (*goal: ‹qroot a b c r ⟶ r = - c / b›*) by auto qed moreover have "r = -c/b ⟶ qroot a b c r" by (simp add: assms (*‹qcase3 a b c›*)) ultimately show "?thesis" (*goal: ‹qroot a b c r = (r = - c / b)›*) by blast qed lemma lemQCase4: assumes "qcase4 a b c" shows "¬ (∃ r . qroot a b c r)" proof (-) (*goal: ‹∄r::'a. qroot (a::'a) (b::'a) (c::'a) r›*) have props: "(a ≠ 0 ∧ discriminant a b c < 0)" using assms (*‹qcase4 a b c›*) by auto { assume hyp: "∃ r . qroot a b c r" (*‹∃r::'a. qroot (a::'a) (b::'a) (c::'a) r›*) then obtain r where r: "qroot a b c r" (*goal: ‹(⋀r. qroot a b c r ⟹ thesis) ⟹ thesis›*) by auto hence "sqr (2 * a * r + b) = discriminant a b c" using props (*‹qcase4 (a::'a) (b::'a) (c::'a)›*) lemQuadRootCondition[of "a" "r" "b" "c"] (*‹a ≠ 0 ⟹ (sqr (2 * a * r + b) = discriminant a b c) = qroot a b c r›*) by auto hence "sqr (2*a*r + b) < 0" using props (*‹qcase4 a b c›*) by auto hence False using lemSquaresPositive (*‹?x ≠ 0 ⟶ 0 < sqr ?x›*) by auto } thus "?thesis" (*goal: ‹∄r::'a. qroot (a::'a) (b::'a) (c::'a) r›*) by auto qed lemma lemQCase5: assumes "qcase5 a b c" shows "qroot a b c r ⟷ r = -b/(2*a)" proof (-) (*goal: ‹qroot a b c r = (r = - b / (2 * a))›*) have "qroot a b c r ⟶ r = -b/(2*a)" proof (-) (*goal: ‹qroot a b c r ⟶ r = - b / (2 * a)›*) { assume hyp: "qroot a b c r" (*‹qroot (a::'a) (b::'a) (c::'a) (r::'a)›*) hence "sqr (2 * a * r + b) = 0" using assms (*‹qcase5 a b c›*) lemQuadRootCondition[of "a" "r" "b" "c"] (*‹a ≠ 0 ⟹ (sqr (2 * a * r + b) = discriminant a b c) = qroot a b c r›*) by auto hence "2*a*r + b = 0" by simp hence "2*a*r = -b" using local.eq_neg_iff_add_eq_0 (*‹(?a = - ?b) = (?a + ?b = 0)›*) by auto moreover have "2*a ≠ 0" using assms (*‹qcase5 a b c›*) by auto ultimately have "r = ((-b)/(2*a))" by (metis local.nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b / ?a = ?b›*)) } thus "?thesis" (*goal: ‹qroot a b c r ⟶ r = - b / (2 * a)›*) by auto qed moreover have "r = -b/(2*a) ⟶ qroot a b c r" proof (-) (*goal: ‹r = - b / (2 * a) ⟶ qroot a b c r›*) { assume hyp: "r = -b/(2*a)" (*‹(r::'a) = - (b::'a) / ((2::'a) * (a::'a))›*) hence "(2*a)*r + b = discriminant a b c" by (simp add: assms (*‹qcase5 a b c›*)) hence "qroot a b c r" using lemQuadRootCondition[of "a" "r" "b" "c"] (*‹a ≠ 0 ⟹ (sqr (2 * a * r + b) = discriminant a b c) = qroot a b c r›*) assms (*‹qcase5 a b c›*) by auto } thus "?thesis" (*goal: ‹r = - b / (2 * a) ⟶ qroot a b c r›*) by auto qed ultimately show "?thesis" (*goal: ‹qroot a b c r = (r = - b / (2 * a))›*) by blast qed lemma lemQCase6: assumes "qcase6 a b c" and "rd = sqrt (discriminant a b c)" and "rp = ((-b) + rd) / (2*a)" and "rm = ((-b) - rd) / (2*a)" shows "(rp ≠ rm) ∧ qroots a b c = { rp, rm }" proof (-) (*goal: ‹rp ≠ rm ∧ qroots a b c = {rp, rm}›*) define d where d: "d = discriminant a b c" have dpos: "d > 0" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹rm = (- b - rd) / (2 * a)›*) d (*‹d = discriminant a b c›*) by auto hence rootd: "hasUniqueRoot d" using AxEField (*‹∀x≥0. hasRoot x›*) lemSqrt[of "d"] (*‹hasRoot (d::'a::type) ⟹ ∃!r::'a::type. (0::'a::type) ≤ r ∧ d = sqr r›*) by auto hence rdprops: "0 ≤ rd ∧ d = sqr rd" using assms(2) (*‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)›*) d (*‹(d::'a::type) = discriminant (a::'a::type) (b::'a::type) (c::'a::type)›*) theI'[of "isNonNegRoot d"] (*‹∃!x. 0 ≤ x ∧ d = sqr x ⟹ 0 ≤ (THE x. 0 ≤ x ∧ d = sqr x) ∧ d = sqr (THE x. 0 ≤ x ∧ d = sqr x)›*) by auto hence rdnot0: "rd ≠ 0" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹(rp::'a::type) = (- (b::'a::type) + (rd::'a::type)) / ((2::'a::type) * (a::'a::type))› ‹rm = (- b - rd) / (2 * a)›*) dpos (*‹0 < d›*) mult_nonneg_nonpos (*‹⟦0 ≤ ?a; ?b ≤ 0⟧ ⟹ ?a * ?b ≤ 0›*) by auto hence rdpos: "rd > 0" using rdprops (*‹(0::'a::type) ≤ (rd::'a::type) ∧ (d::'a::type) = sqr rd›*) by auto define pp where pp: "pp = (-b) + rd" define mm where mm: "mm = (-b) - rd" have "rd ≠ -rd" using rdnot0 (*‹(rd::'a) ≠ (0::'a)›*) by simp hence "pp ≠ mm" using pp (*‹pp = - b + rd›*) mm (*‹mm = - b - rd›*) add_left_imp_eq[of "-b" "rd" "-rd"] (*‹- b + rd = - b + - rd ⟹ rd = - rd›*) by auto moreover have aa: "2*a ≠ 0" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹rm = (- b - rd) / (2 * a)›*) by auto ultimately have "pp/(2*a) ≠ mm/(2*a)" by auto hence conj1: "rp ≠ rm" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹(rp::'a) = (- (b::'a) + (rd::'a)) / ((2::'a) * (a::'a))› ‹(rm::'a) = (- (b::'a) - (rd::'a)) / ((2::'a) * (a::'a))›*) pp (*‹pp = - b + rd›*) mm (*‹(mm::'a) = - (b::'a) - (rd::'a)›*) by simp have conj2: "qroots a b c = {rp, rm}" proof (-) (*goal: ‹qroots (a::'a) (b::'a) (c::'a) = {rp::'a, rm::'a}›*) { fix r assume "r ∈ qroots a b c" (*‹(r::'a) ∈ qroots (a::'a) (b::'a) (c::'a)›*) hence "sqr (2*a*r + b) = d" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹rm = (- b - rd) / (2 * a)›*) lemQuadRootCondition (*‹?a ≠ 0 ⟹ (sqr (2 * ?a * ?r + ?b) = discriminant ?a ?b ?c) = qroot ?a ?b ?c ?r›*) d (*‹(d::'a) = discriminant (a::'a) (b::'a) (c::'a)›*) by auto hence "sqrt d = abs (2*a*r + b)" using lemSqrtOfSquare (*‹?b = sqr ?a ⟹ (THE r. 0 ≤ r ∧ ?b = sqr r) = ¦?a¦›*) by blast moreover have "sqrt d = rd" using d (*‹d = discriminant a b c›*) assms (*‹(a::'a) ≠ (0::'a) ∧ (0::'a) < discriminant a (b::'a) (c::'a)› ‹(rd::'a::type) = (THE r::'a::type. (0::'a::type) ≤ r ∧ discriminant (a::'a::type) (b::'a::type) (c::'a::type) = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹(rm::'a::type) = (- (b::'a::type) - (rd::'a::type)) / ((2::'a::type) * (a::'a::type))›*) by auto ultimately have rdprops: "rd = abs (2*a*r + b)" by auto define v :: 'a where v: "v = 2*a*r + b" hence vnot0: "v ≠ 0" using rdprops (*‹rd = ¦2 * a * r + b¦›*) rdnot0 (*‹rd ≠ 0›*) by simp hence cases: "(v < 0) ∨ (v > 0)" by auto { assume "v < 0" (*‹(v::'a) < (0::'a)›*) hence "2*a*r + b = -rd" using v (*‹v = 2 * a * r + b›*) rdprops (*‹rd = ¦2 * a * r + b¦›*) by (metis local.abs_if (*‹¦?a::'a¦ = (if ?a < (0::'a) then - ?a else ?a)›*) local.minus_minus (*‹- (- (?a::'a)) = ?a›*)) hence "2*a*r = (-b) - rd" by (metis local.add_diff_cancel_right' (*‹?a + ?b - ?b = ?a›*) local.minus_diff_commute (*‹- ?b - ?a = - ?a - ?b›*)) hence "r = rm" using aa (*‹2 * a ≠ 0›*) assms(4) (*‹(rm::'a::type) = (- (b::'a::type) - (rd::'a::type)) / ((2::'a::type) * (a::'a::type))›*) by (metis local.nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b / ?a = ?b›*)) } hence case1: "v < 0 ⟶ r = rm" by auto { assume "v > 0" (*‹(0::'a) < (v::'a)›*) hence "2*a*r + b = rd" using v (*‹(v::'a) = (2::'a) * (a::'a) * (r::'a) + (b::'a)›*) rdprops (*‹rd = ¦2 * a * r + b¦›*) by simp hence "2*a*r = (-b) + rd" by auto hence "r = rp" using aa (*‹2 * a ≠ 0›*) assms(3) (*‹rp = (- b + rd) / (2 * a)›*) by (metis local.nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b / ?a = ?b›*)) } hence "v > 0 ⟶ r = rp" by auto hence "r = rm ∨ r = rp" using case1 (*‹v < 0 ⟶ r = rm›*) cases (*‹(v::'a) < (0::'a) ∨ (0::'a) < v›*) by blast hence "r ∈ { rm, rp }" by blast } hence "∀ r . r ∈ qroots a b c ⟶ r ∈ { rm, rp }" by blast hence l2r: "qroots a b c ⊆ {rm, rp}" by auto have rootm: "qroot a b c rm" proof (-) (*goal: ‹qroot a b c rm›*) have "rm = ((-b) - rd) / (2*a)" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹rm = (- b - rd) / (2 * a)›*) by auto hence "(2*a)*rm = (-b) - rd" using aa (*‹2 * a ≠ 0›*) by simp hence "(2*a)*rm + b = - rd" by (simp add: local.diff_add_eq (*‹?a - ?b + ?c = ?a + ?c - ?b›*)) hence "sqr( (2*a)*rm + b ) = sqr rd" by simp moreover have "… = discriminant a b c" using assms(2) (*‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)›*) rootd (*‹∃!r. 0 ≤ r ∧ d = sqr r›*) d (*‹d = discriminant a b c›*) lemSquareOfSqrt[of "discriminant a b c" "rd"] (*‹⟦hasRoot (discriminant a b c); rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)⟧ ⟹ sqr rd = discriminant a b c›*) by auto ultimately show "?thesis" (*goal: ‹qroot a b c rm›*) using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹rm = (- b - rd) / (2 * a)›*) lemQuadRootCondition[of "a" "rm" "b" "c"] (*‹a ≠ 0 ⟹ (sqr (2 * a * rm + b) = discriminant a b c) = qroot a b c rm›*) by auto qed have rootp: "qroot a b c rp" proof (-) (*goal: ‹qroot a b c rp›*) have "rp = ((-b) + rd) / (2*a)" using assms (*‹a ≠ 0 ∧ 0 < discriminant a b c› ‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)› ‹rp = (- b + rd) / (2 * a)› ‹rm = (- b - rd) / (2 * a)›*) by auto hence "(2*a)*rp = (-b) + rd" using aa (*‹2 * a ≠ 0›*) by simp hence "(2*a)*rp + b = rd" by (simp add: local.diff_add_eq (*‹(?a::'a::type) - (?b::'a::type) + (?c::'a::type) = ?a + ?c - ?b›*)) hence "sqr( (2*a)*rp + b ) = sqr rd" by simp moreover have "… = discriminant a b c" using assms(2) (*‹rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)›*) rootd (*‹∃!r. 0 ≤ r ∧ d = sqr r›*) d (*‹d = discriminant a b c›*) lemSquareOfSqrt[of "discriminant a b c" "rd"] (*‹⟦hasRoot (discriminant a b c); rd = (THE r. 0 ≤ r ∧ discriminant a b c = sqr r)⟧ ⟹ sqr rd = discriminant a b c›*) by auto ultimately show "?thesis" (*goal: ‹qroot (a::'a) (b::'a) (c::'a) (rp::'a)›*) using assms (*‹(a::'a) ≠ (0::'a) ∧ (0::'a) < discriminant a (b::'a) (c::'a)› ‹(rd::'a::type) = (THE r::'a::type. (0::'a::type) ≤ r ∧ discriminant (a::'a::type) (b::'a::type) (c::'a::type) = sqr r)› ‹(rp::'a) = (- (b::'a) + (rd::'a)) / ((2::'a) * (a::'a))› ‹rm = (- b - rd) / (2 * a)›*) lemQuadRootCondition[of "a" "rp" "b" "c"] (*‹a ≠ 0 ⟹ (sqr (2 * a * rp + b) = discriminant a b c) = qroot a b c rp›*) by auto qed hence "{rm, rp} ⊆ qroots a b c" using rootm (*‹qroot a b c rm›*) rootp (*‹qroot a b c rp›*) by auto thus "?thesis" (*goal: ‹qroots a b c = {rp, rm}›*) using l2r (*‹qroots a b c ⊆ {rm, rp}›*) by blast qed thus "?thesis" (*goal: ‹(rp::'a::type) ≠ (rm::'a::type) ∧ qroots (a::'a::type) (b::'a::type) (c::'a::type) = {rp, rm}›*) using conj1 (*‹rp ≠ rm›*) by blast qed lemma lemQuadraticRootCount: assumes "¬(qcase1 a b c)" shows "finite (qroots a b c) ∧ card (qroots a b c) ≤ 2" proof (-) (*goal: ‹finite (qroots a b c) ∧ card (qroots a b c) ≤ 2›*) define d where d: "d = discriminant a b c" have case1: "qcase1 a b c ⟶ ?thesis" using assms (*‹¬ qcase1 a b c›*) by auto moreover have case2: "qcase2 a b c ⟶ ?thesis" using lemQCase2 (*‹qcase2 ?a ?b ?c ⟹ ∄r. qroot ?a ?b ?c r›*) by auto moreover have case3: "qcase3 a b c ⟶ ?thesis" using lemQCase3 (*‹qcase3 ?a ?b ?c ⟹ qroot ?a ?b ?c ?r = (?r = - ?c / ?b)›*) by auto moreover have case4: "qcase4 a b c ⟶ ?thesis" using lemQCase4 (*‹qcase4 ?a ?b ?c ⟹ ∄r. qroot ?a ?b ?c r›*) by auto moreover have case5: "qcase5 a b c ⟶ ?thesis" using lemQCase5 (*‹qcase5 ?a ?b ?c ⟹ qroot ?a ?b ?c ?r = (?r = - ?b / (2 * ?a))›*) by auto moreover have case6: "qcase6 a b c ⟶ ?thesis" using lemQCase6 (*‹⟦(?a::'a) ≠ (0::'a) ∧ (0::'a) < discriminant ?a (?b::'a) (?c::'a); (?rd::'a) = (THE r::'a. (0::'a) ≤ r ∧ discriminant ?a ?b ?c = sqr r); (?rp::'a) = (- ?b + ?rd) / ((2::'a) * ?a); (?rm::'a) = (- ?b - ?rd) / ((2::'a) * ?a)⟧ ⟹ ?rp ≠ ?rm ∧ qroots ?a ?b ?c = {?rp, ?rm}›*) card_2_iff (*‹(card ?S = 2) = (∃x y. ?S = {x, y} ∧ x ≠ y)›*) by auto ultimately show "?thesis" (*goal: ‹finite (qroots a b c) ∧ card (qroots a b c) ≤ 2›*) using lemQuadraticCasesComplete (*‹qcase1 ?a ?b ?c ∨ qcase2 ?a ?b ?c ∨ qcase3 ?a ?b ?c ∨ qcase4 ?a ?b ?c ∨ qcase5 ?a ?b ?c ∨ ?a ≠ 0 ∧ 0 < discriminant ?a ?b ?c›*) by blast qed end (* of class Quadratics *) end (* of theory Quadratics *)
{ "path": "afp-2025-02-12/thys/No_FTL_observers_Gen_Rel/Quadratics.thy", "repo": "afp-2025-02-12", "sha": "be0759ef131711ddd28ea3fc6a9ebe1516d6d0de6664007671d2d78599ec0b73" }
(* Authors: Jose Divasón Sebastiaan Joosten René Thiemann Akihisa Yamada *) theory Code_Abort_Gcd imports "HOL-Computational_Algebra.Polynomial_Factorial" begin text ‹Dummy code-setup for @{const Gcd} and @{const Lcm} in the presence of Container.› definition dummy_Gcd where "dummy_Gcd x = Gcd x" definition dummy_Lcm where "dummy_Lcm x = Lcm x" declare [[code abort: dummy_Gcd]] lemma dummy_Gcd_Lcm: "Gcd x = dummy_Gcd x" "Lcm x = dummy_Lcm x" unfolding dummy_Gcd_def dummy_Lcm_def (*goals: 1. ‹Gcd x = Gcd x› 2. ‹Lcm x = Lcm x›*) (*goals: 1. ‹Gcd x = Gcd x› 2. ‹Lcm x = Lcm x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemmas dummy_Gcd_Lcm_poly [code] = dummy_Gcd_Lcm [where ?'a = "'a :: {factorial_ring_gcd,semiring_gcd_mult_normalize} poly"] lemmas dummy_Gcd_Lcm_int [code] = dummy_Gcd_Lcm [where ?'a = int] lemmas dummy_Gcd_Lcm_nat [code] = dummy_Gcd_Lcm [where ?'a = nat] declare [[code abort: Euclidean_Algorithm.Gcd Euclidean_Algorithm.Lcm]] end
{ "path": "afp-2025-02-12/thys/Berlekamp_Zassenhaus/Code_Abort_Gcd.thy", "repo": "afp-2025-02-12", "sha": "e9819ff9dedaa7518e65c3a87c960d96fe31a96e510f08f5a8f525605a419730" }
section‹The Forcing Theorems› theory Forcing_Theorems imports Cohen_Posets_Relative Forces_Definition Names begin context forcing_data1 begin subsection‹The forcing relation in context› lemma separation_forces : assumes fty: "φ∈formula" and far: "arity(φ)≤length(env)" and envty: "env∈list(M)" shows "separation(##M,λp. (p ⊩ φ env))" using separation_ax (*‹⟦?φ ∈ formula; ?env ∈ list(M); arity(?φ) ≤ 1 +⇩ω length(?env)⟧ ⟹ separation(##M, λx. M, [x] @ ?env ⊨ ?φ)›*) arity_forces (*‹?φ ∈ formula ⟹ arity(forces(?φ)) ≤ 4 +⇩ω arity(?φ)›*) far (*‹arity(φ) ≤ length(env)›*) fty (*‹(φ::i) ∈ formula›*) envty (*‹(env::i) ∈ list(M::i)›*) arity_forces_le (*‹⟦?φ ∈ formula; ?n ∈ ω; arity(?φ) ≤ ?n⟧ ⟹ arity(forces(?φ)) ≤ 4 +⇩ω ?n›*) transitivity[of _ ℙ] (*‹⟦?y ∈ ℙ; ℙ ∈ M⟧ ⟹ ?y ∈ M›*) by simp lemma Collect_forces : assumes "φ∈formula" and "arity(φ)≤length(env)" and "env∈list(M)" shows "{p∈ℙ . p ⊩ φ env} ∈ M" using assms (*‹φ ∈ formula› ‹arity(φ) ≤ length(env)› ‹(env::i) ∈ list(M::i)›*) separation_forces (*‹⟦(?φ::i) ∈ formula; arity(?φ) ≤ length(?env::i); ?env ∈ list(M::i)⟧ ⟹ separation(##M, λp::i. p ⊩ ?φ ?env)›*) separation_closed (*‹⟦separation(##M, ?P); (##M)(?A)⟧ ⟹ (##M)(Collect(?A, ?P))›*) by simp lemma forces_mem_iff_dense_below: "p∈ℙ ⟹ p forces⇩a (t1 ∈ t2) ⟷ dense_below( {q∈ℙ. ∃s. ∃r. r∈ℙ ∧ ⟨s,r⟩ ∈ t2 ∧ q≼r ∧ q forces⇩a (t1 = s)} ,p)" using def_forces_mem[of p t1 t2] (*‹p ∈ ℙ ⟹ p forces⇩a (t1 ∈ t2) ⟷ (∀v∈ℙ. v ≼ p ⟶ (∃q s r. r ∈ ℙ ∧ q ∈ ℙ ∧ q ≼ v ∧ ⟨s, r⟩ ∈ t2 ∧ q ≼ r ∧ q forces⇩a (t1 = s)))›*) by blast subsection‹Kunen 2013, Lemma IV.2.37(a)› lemma strengthening_eq: assumes "p∈ℙ" "r∈ℙ" "r≼p" "p forces⇩a (t1 = t2)" shows "r forces⇩a (t1 = t2)" using assms (*‹p ∈ ℙ› ‹r ∈ ℙ› ‹r ≼ p› ‹p forces⇩a (t1 = t2)›*) def_forces_eq[of _ t1 t2] (*‹?p ∈ ℙ ⟹ ?p forces⇩a (t1 = t2) ⟷ (∀s∈domain(t1) ∪ domain(t2). ∀q. q ∈ ℙ ∧ q ≼ ?p ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2))›*) leq_transD (*‹⟦(?a::i) ≼ (?b::i); ?b ≼ (?c::i); ?a ∈ ℙ; ?b ∈ ℙ; ?c ∈ ℙ⟧ ⟹ ?a ≼ ?c›*) by blast (* Long proof *) (* proof - { fix s q assume "q≼ r" "q∈ℙ" with assms have "q≼p" using leq_preord unfolding preorder_on_def trans_on_def by blast moreover note ‹q∈ℙ› assms moreover assume "s∈domain(t1) ∪ domain(t2)" ultimately have "q forces⇩a ( s ∈ t1) ⟷ q forces⇩a ( s ∈ t2)" using def_forces_eq[of p t1 t2] by simp } with ‹r∈ℙ› show ?thesis using def_forces_eq[of r t1 t2] by blast qed *) subsection‹Kunen 2013, Lemma IV.2.37(a)› lemma strengthening_mem: assumes "p∈ℙ" "r∈ℙ" "r≼p" "p forces⇩a (t1 ∈ t2)" shows "r forces⇩a (t1 ∈ t2)" using assms (*‹p ∈ ℙ› ‹r ∈ ℙ› ‹r ≼ p› ‹p forces⇩a (t1 ∈ t2)›*) forces_mem_iff_dense_below (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 ∈ ?t2.0) ⟷ dense_below({q ∈ ℙ . ∃s r. r ∈ ℙ ∧ ⟨s, r⟩ ∈ ?t2.0 ∧ q ≼ r ∧ q forces⇩a (?t1.0 = s)}, ?p)›*) dense_below_under (*‹⟦dense_below(?D, ?p); ?p ∈ ℙ; ?q ∈ ℙ; ?q ≼ ?p⟧ ⟹ dense_below(?D, ?q)›*) by auto subsection‹Kunen 2013, Lemma IV.2.37(b)› lemma density_mem: assumes "p∈ℙ" shows "p forces⇩a (t1 ∈ t2) ⟷ dense_below({q∈ℙ. q forces⇩a (t1 ∈ t2)},p)" proof (standard) (*goals: 1. ‹p forces⇩a (t1 ∈ t2) ⟹ dense_below({q ∈ ℙ . q forces⇩a (t1 ∈ t2)}, p)› 2. ‹dense_below({q ∈ ℙ . q forces⇩a (t1 ∈ t2)}, p) ⟹ p forces⇩a (t1 ∈ t2)›*) assume "p forces⇩a (t1 ∈ t2)" (*‹(p::i) forces⇩a (t1::i ∈ t2::i)›*) with assms (*‹p ∈ ℙ›*) show "dense_below({q∈ℙ. q forces⇩a (t1 ∈ t2)},p)" using forces_mem_iff_dense_below (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 ∈ ?t2.0) ⟷ dense_below({q ∈ ℙ . ∃s r. r ∈ ℙ ∧ ⟨s, r⟩ ∈ ?t2.0 ∧ q ≼ r ∧ q forces⇩a (?t1.0 = s)}, ?p)›*) strengthening_mem[of p] (*‹⟦p ∈ ℙ; ?r ∈ ℙ; ?r ≼ p; p forces⇩a (?t1.0 ∈ ?t2.0)⟧ ⟹ ?r forces⇩a (?t1.0 ∈ ?t2.0)›*) ideal_dense_below (*‹(⋀q. ⟦q ∈ ℙ; q ≼ ?p⟧ ⟹ q ∈ ?D) ⟹ dense_below(?D, ?p)›*) by auto next (*goal: ‹dense_below({q ∈ ℙ . q forces⇩a (t1 ∈ t2)}, p) ⟹ p forces⇩a (t1 ∈ t2)›*) assume "dense_below({q ∈ ℙ . q forces⇩a ( t1 ∈ t2)}, p)" (*‹dense_below({q::i ∈ ℙ . q forces⇩a (t1::i ∈ t2::i)}, p::i)›*) with assms (*‹p ∈ ℙ›*) have "dense_below({q∈ℙ. dense_below({q'∈ℙ. ∃s r. r ∈ ℙ ∧ ⟨s,r⟩∈t2 ∧ q'≼r ∧ q' forces⇩a (t1 = s)},q) },p)" using forces_mem_iff_dense_below (*‹(?p::i) ∈ ℙ ⟹ ?p forces⇩a (?t1.0::i ∈ ?t2.0::i) ⟷ dense_below({q::i ∈ ℙ . ∃(s::i) r::i. r ∈ ℙ ∧ ⟨s, r⟩ ∈ ?t2.0 ∧ q ≼ r ∧ q forces⇩a (?t1.0 = s)}, ?p)›*) by simp with assms (*‹p ∈ ℙ›*) show "p forces⇩a (t1 ∈ t2)" using dense_below_dense_below (*‹⟦dense_below({q::i ∈ ℙ . dense_below(?D::i, q)}, ?p::i); ?p ∈ ℙ⟧ ⟹ dense_below(?D, ?p)›*) forces_mem_iff_dense_below[of p t1 t2] (*‹p ∈ ℙ ⟹ p forces⇩a (t1 ∈ t2) ⟷ dense_below({q ∈ ℙ . ∃s r. r ∈ ℙ ∧ ⟨s, r⟩ ∈ t2 ∧ q ≼ r ∧ q forces⇩a (t1 = s)}, p)›*) by blast qed lemma aux_density_eq: assumes "dense_below( {q'∈ℙ. ∀q. q∈ℙ ∧ q≼q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)} ,p)" "q forces⇩a (s ∈ t1)" "q∈ℙ" "p∈ℙ" "q≼p" shows "dense_below({r∈ℙ. r forces⇩a (s ∈ t2)},q)" proof (standard) (*goal: ‹⋀qa. ⟦qa ∈ ℙ; qa ≼ q⟧ ⟹ ∃d∈{r ∈ ℙ . r forces⇩a (s ∈ t2)}. d ∈ ℙ ∧ d ≼ qa›*) fix r assume "r∈ℙ" "r≼q" (*‹(r::i) ∈ ℙ› ‹(r::i) ≼ (q::i)›*) moreover from this (*‹r ∈ ℙ› ‹r ≼ q›*) ‹p∈ℙ› (*‹p ∈ ℙ›*) ‹q≼p› (*‹q ≼ p›*) ‹q∈ℙ› (*‹q ∈ ℙ›*) have "r≼p" using leq_transD (*‹⟦?a ≼ ?b; ?b ≼ ?c; ?a ∈ ℙ; ?b ∈ ℙ; ?c ∈ ℙ⟧ ⟹ ?a ≼ ?c›*) by simp moreover note ‹q forces⇩a (s ∈ t1)› (*‹q forces⇩a (s ∈ t1)›*) ‹dense_below(_,p)› (*‹dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}, p)›*) ‹q∈ℙ› (*‹q ∈ ℙ›*) ultimately obtain q1 where "q1≼r" "q1∈ℙ" "q1 forces⇩a (s ∈ t2)" (*goal: ‹(⋀q1. ⟦q1 ≼ r; q1 ∈ ℙ; q1 forces⇩a (s ∈ t2)⟧ ⟹ thesis) ⟹ thesis›*) using strengthening_mem[of q _ s t1] (*‹⟦q ∈ ℙ; ?r ∈ ℙ; ?r ≼ q; q forces⇩a (s ∈ t1)⟧ ⟹ ?r forces⇩a (s ∈ t1)›*) refl_leq (*‹?r ∈ ℙ ⟹ ?r ≼ ?r›*) leq_transD[of _ r q] (*‹⟦?a ≼ r; r ≼ q; ?a ∈ ℙ; r ∈ ℙ; q ∈ ℙ⟧ ⟹ ?a ≼ q›*) by blast then show "∃d∈{r ∈ ℙ . r forces⇩a ( s ∈ t2)}. d ∈ ℙ ∧ d≼ r" by blast qed (* Kunen 2013, Lemma IV.2.37(b) *) lemma density_eq: assumes "p∈ℙ" shows "p forces⇩a (t1 = t2) ⟷ dense_below({q∈ℙ. q forces⇩a (t1 = t2)},p)" proof (standard) (*goals: 1. ‹p forces⇩a (t1 = t2) ⟹ dense_below({q ∈ ℙ . q forces⇩a (t1 = t2)}, p)› 2. ‹dense_below({q ∈ ℙ . q forces⇩a (t1 = t2)}, p) ⟹ p forces⇩a (t1 = t2)›*) assume "p forces⇩a (t1 = t2)" (*‹(p::i) forces⇩a (t1::i = t2::i)›*) with ‹p∈ℙ› (*‹p ∈ ℙ›*) show "dense_below({q∈ℙ. q forces⇩a (t1 = t2)},p)" using strengthening_eq (*‹⟦(?p::i) ∈ ℙ; (?r::i) ∈ ℙ; ?r ≼ ?p; ?p forces⇩a (?t1.0::i = ?t2.0::i)⟧ ⟹ ?r forces⇩a (?t1.0 = ?t2.0)›*) ideal_dense_below (*‹(⋀q. ⟦q ∈ ℙ; q ≼ ?p⟧ ⟹ q ∈ ?D) ⟹ dense_below(?D, ?p)›*) by auto next (*goal: ‹dense_below({q ∈ ℙ . q forces⇩a (t1 = t2)}, p) ⟹ p forces⇩a (t1 = t2)›*) assume "dense_below({q∈ℙ. q forces⇩a (t1 = t2)},p)" (*‹dense_below({q::i ∈ ℙ . q forces⇩a (t1::i = t2::i)}, p::i)›*) { fix s and q let ?D1 = "{q'∈ℙ. ∀s∈domain(t1) ∪ domain(t2). ∀q. q ∈ ℙ ∧ q≼q' ⟶ q forces⇩a (s ∈ t1)⟷q forces⇩a (s ∈ t2)}" let ?D2 = "{q'∈ℙ. ∀q. q∈ℙ ∧ q≼q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}" assume "s∈domain(t1) ∪ domain(t2)" (*‹(s::i) ∈ domain(t1::i) ∪ domain(t2::i)›*) then have "?D1⊆?D2" by blast with ‹dense_below(_,p)› (*‹dense_below({q ∈ ℙ . q forces⇩a (t1 = t2)}, p)›*) have "dense_below({q'∈ℙ. ∀s∈domain(t1) ∪ domain(t2). ∀q. q ∈ ℙ ∧ q≼q' ⟶ q forces⇩a (s ∈ t1)⟷q forces⇩a (s ∈ t2)},p)" using dense_below_cong'[OF ‹p∈ℙ› def_forces_eq [ of _ t1 t2 ]] (*‹(⋀x. x ∈ ℙ ⟹ ?p1(x) ∈ ℙ) ⟹ dense_below({q ∈ ℙ . ?p1(q) forces⇩a (t1 = t2)}, p) ⟷ dense_below({q ∈ ℙ . ∀s∈domain(t1) ∪ domain(t2). ∀qa. qa ∈ ℙ ∧ qa ≼ ?p1(q) ⟶ qa forces⇩a (s ∈ t1) ⟷ qa forces⇩a (s ∈ t2)}, p)›*) by simp with ‹p∈ℙ› (*‹(p::i) ∈ ℙ›*) ‹?D1⊆?D2› (*‹{q' ∈ ℙ . ∀s∈domain(t1) ∪ domain(t2). ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)} ⊆ {q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}›*) have "dense_below({q'∈ℙ. ∀q. q∈ℙ ∧ q≼q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)},p)" using dense_below_mono (*‹⟦?p ∈ ℙ; ?D ⊆ ?D'; dense_below(?D, ?p)⟧ ⟹ dense_below(?D', ?p)›*) by simp moreover from this (*‹dense_below({q'::i ∈ ℙ . ∀q::i. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s::i ∈ t1::i) ⟷ q forces⇩a (s ∈ t2::i)}, p::i)›*) have "dense_below({q'∈ℙ. ∀q. q∈ℙ ∧ q≼q' ⟶ q forces⇩a (s ∈ t2) ⟷ q forces⇩a (s ∈ t1)},p)" by blast moreover assume "q ∈ ℙ" "q≼p" (*‹(q::i) ∈ ℙ› ‹(q::i) ≼ (p::i)›*) moreover note ‹p∈ℙ› (*‹(p::i) ∈ ℙ›*) ultimately have "q forces⇩a (s ∈ t1) ⟹ dense_below({r∈ℙ. r forces⇩a (s ∈ t2)},q)" "q forces⇩a (s ∈ t2) ⟹ dense_below({r∈ℙ. r forces⇩a (s ∈ t1)},q)" using aux_density_eq (*‹⟦dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (?s ∈ ?t1.0) ⟷ q forces⇩a (?s ∈ ?t2.0)}, ?p); ?q forces⇩a (?s ∈ ?t1.0); ?q ∈ ℙ; ?p ∈ ℙ; ?q ≼ ?p⟧ ⟹ dense_below({r ∈ ℙ . r forces⇩a (?s ∈ ?t2.0)}, ?q)›*) apply - (*goals: 1. ‹⟦q forces⇩a (s ∈ t1); dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}, p); dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t2) ⟷ q forces⇩a (s ∈ t1)}, p); q ∈ ℙ; q ≼ p; p ∈ ℙ; ⋀s t1 t2 p q. ⟦dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}, p); q forces⇩a (s ∈ t1); q ∈ ℙ; p ∈ ℙ; q ≼ p⟧ ⟹ dense_below({r ∈ ℙ . r forces⇩a (s ∈ t2)}, q)⟧ ⟹ dense_below({r ∈ ℙ . r forces⇩a (s ∈ t2)}, q)› 2. ‹⟦q forces⇩a (s ∈ t2); dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}, p); dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t2) ⟷ q forces⇩a (s ∈ t1)}, p); q ∈ ℙ; q ≼ p; p ∈ ℙ; ⋀s t1 t2 p q. ⟦dense_below({q' ∈ ℙ . ∀q. q ∈ ℙ ∧ q ≼ q' ⟶ q forces⇩a (s ∈ t1) ⟷ q forces⇩a (s ∈ t2)}, p); q forces⇩a (s ∈ t1); q ∈ ℙ; p ∈ ℙ; q ≼ p⟧ ⟹ dense_below({r ∈ ℙ . r forces⇩a (s ∈ t2)}, q)⟧ ⟹ dense_below({r ∈ ℙ . r forces⇩a (s ∈ t1)}, q)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have "q forces⇩a ( s ∈ t1) ⟷ q forces⇩a ( s ∈ t2)" using density_mem[OF ‹q∈ℙ›] (*‹q forces⇩a (?t1.0 ∈ ?t2.0) ⟷ dense_below({q ∈ ℙ . q forces⇩a (?t1.0 ∈ ?t2.0)}, q)›*) by blast } with ‹p∈ℙ› (*‹p ∈ ℙ›*) show "p forces⇩a (t1 = t2)" using def_forces_eq (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 = ?t2.0) ⟷ (∀s∈domain(?t1.0) ∪ domain(?t2.0). ∀q. q ∈ ℙ ∧ q ≼ ?p ⟶ q forces⇩a (s ∈ ?t1.0) ⟷ q forces⇩a (s ∈ ?t2.0))›*) by blast qed subsection‹Kunen 2013, Lemma IV.2.38› lemma not_forces_neq: assumes "p∈ℙ" shows "p forces⇩a (t1 = t2) ⟷ ¬ (∃q∈ℙ. q≼p ∧ q forces⇩a (t1 ≠ t2))" using assms (*‹(p::i) ∈ ℙ›*) density_eq (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 = ?t2.0) ⟷ dense_below({q ∈ ℙ . q forces⇩a (?t1.0 = ?t2.0)}, ?p)›*) unfolding forces_neq_def (*goal: ‹(p::i) forces⇩a (t1::i = t2::i) ⟷ ¬ (∃q::i∈ℙ. q ≼ p ∧ ¬ (∃qa::i∈ℙ. qa ≼ q ∧ qa forces⇩a (t1 = t2)))›*) by blast lemma not_forces_nmem: assumes "p∈ℙ" shows "p forces⇩a (t1 ∈ t2) ⟷ ¬ (∃q∈ℙ. q≼p ∧ q forces⇩a (t1 ∉ t2))" using assms (*‹p ∈ ℙ›*) density_mem (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 ∈ ?t2.0) ⟷ dense_below({q ∈ ℙ . q forces⇩a (?t1.0 ∈ ?t2.0)}, ?p)›*) unfolding forces_nmem_def (*goal: ‹p forces⇩a (t1 ∈ t2) ⟷ ¬ (∃q∈ℙ. q ≼ p ∧ ¬ (∃qa∈ℙ. qa ≼ q ∧ qa forces⇩a (t1 ∈ t2)))›*) by blast subsection‹The relation of forcing and atomic formulas› lemma Forces_Equal: assumes "p∈ℙ" "t1∈M" "t2∈M" "env∈list(M)" "nth(n,env) = t1" "nth(m,env) = t2" "n∈nat" "m∈nat" shows "(p ⊩ Equal(n,m) env) ⟷ p forces⇩a (t1 = t2)" using assms (*‹p ∈ ℙ› ‹t1 ∈ M› ‹t2 ∈ M› ‹env ∈ list(M)› ‹nth(n, env) = t1› ‹nth(m, env) = t2› ‹n ∈ ω› ‹m ∈ ω›*) sats_forces_Equal (*‹⟦(?a::i) ∈ ω; (?b::i) ∈ ω; (?env::i) ∈ list(M::i); nth(?a, ?env) = (?x::i); nth(?b, ?env) = (?y::i); (?q::i) ∈ M⟧ ⟹ ?q ⊩ ⋅?a = ?b⋅ ?env ⟷ ?q ∈ ℙ ∧ is_forces_eq(?q, ?x, ?y)›*) forces_eq_abs (*‹⟦(?p::i) ∈ (M::i); (?t1.0::i) ∈ M; (?t2.0::i) ∈ M⟧ ⟹ is_forces_eq(?p, ?t1.0, ?t2.0) ⟷ ?p forces⇩a (?t1.0 = ?t2.0)›*) transitivity (*‹⟦?y ∈ ?x; ?x ∈ M⟧ ⟹ ?y ∈ M›*) by simp lemma Forces_Member: assumes "p∈ℙ" "t1∈M" "t2∈M" "env∈list(M)" "nth(n,env) = t1" "nth(m,env) = t2" "n∈nat" "m∈nat" shows "(p ⊩ Member(n,m) env) ⟷ p forces⇩a (t1 ∈ t2)" using assms (*‹p ∈ ℙ› ‹(t1::i) ∈ (M::i)› ‹t2 ∈ M› ‹env ∈ list(M)› ‹nth(n, env) = t1› ‹nth(m, env) = t2› ‹n ∈ ω› ‹(m::i) ∈ ω›*) sats_forces_Member (*‹⟦(?x::i) ∈ ω; (?y::i) ∈ ω; (?env::i) ∈ list(M::i); nth(?x, ?env) = (?xx::i); nth(?y, ?env) = (?yy::i); (?q::i) ∈ M⟧ ⟹ ?q ⊩ ⋅?x ∈ ?y⋅ ?env ⟷ ?q ∈ ℙ ∧ is_forces_mem(?q, ?xx, ?yy)›*) forces_mem_abs (*‹⟦?p ∈ M; ?t1.0 ∈ M; ?t2.0 ∈ M⟧ ⟹ is_forces_mem(?p, ?t1.0, ?t2.0) ⟷ ?p forces⇩a (?t1.0 ∈ ?t2.0)›*) transitivity (*‹⟦?y ∈ ?x; ?x ∈ M⟧ ⟹ ?y ∈ M›*) by simp lemma Forces_Neg: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" shows "(p ⊩ Neg(φ) env) ⟷ ¬(∃q∈M. q∈ℙ ∧ q≼p ∧ (q ⊩ φ env))" using assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula›*) sats_forces_Neg (*‹⟦(?φ::i) ∈ formula; (?env::i) ∈ list(M::i); (?p::i) ∈ M⟧ ⟹ ?p ⊩ ⋅¬?φ⋅ ?env ⟷ ?p ∈ ℙ ∧ ¬ (∃q::i∈M. q ∈ ℙ ∧ is_leq(##M, leq::i, q, ?p) ∧ q ⊩ ?φ ?env)›*) transitivity (*‹⟦?y ∈ ?x; ?x ∈ M⟧ ⟹ ?y ∈ M›*) pair_in_M_iff (*‹(##(M::i))(⟨?a::i, ?b::i⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) leq_abs (*‹⟦?l ∈ M; ?q ∈ M; ?p ∈ M⟧ ⟹ is_leq(##M, ?l, ?q, ?p) ⟷ ⟨?q, ?p⟩ ∈ ?l›*) by simp subsection‹The relation of forcing and connectives› lemma Forces_Nand: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" "ψ∈formula" shows "(p ⊩ Nand(φ,ψ) env) ⟷ ¬(∃q∈M. q∈ℙ ∧ q≼p ∧ (q ⊩ φ env) ∧ (q ⊩ ψ env))" using assms (*‹(p::i) ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula›*) sats_forces_Nand (*‹⟦?φ ∈ formula; ?ψ ∈ formula; ?env ∈ list(M); ?p ∈ M⟧ ⟹ ?p ⊩ ⋅¬(?φ ∧ ?ψ)⋅ ?env ⟷ ?p ∈ ℙ ∧ ¬ (∃q∈M. q ∈ ℙ ∧ is_leq(##M, leq, q, ?p) ∧ q ⊩ ?φ ?env ∧ q ⊩ ?ψ ?env)›*) transitivity (*‹⟦(?y::i) ∈ (?x::i); ?x ∈ (M::i)⟧ ⟹ ?y ∈ M›*) pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) leq_abs (*‹⟦?l ∈ M; ?q ∈ M; ?p ∈ M⟧ ⟹ is_leq(##M, ?l, ?q, ?p) ⟷ ⟨?q, ?p⟩ ∈ ?l›*) by simp lemma Forces_And_aux: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" "ψ∈formula" shows "p ⊩ And(φ,ψ) env ⟷ (∀q∈M. q∈ℙ ∧ q≼p ⟶ (∃r∈M. r∈ℙ ∧ r≼q ∧ (r ⊩ φ env) ∧ (r ⊩ ψ env)))" unfolding And_def (*goal: ‹p ⊩ ⋅¬⋅¬(φ ∧ ψ)⋅⋅ env ⟷ (∀q∈M. q ∈ ℙ ∧ q ≼ p ⟶ (∃r∈M. r ∈ ℙ ∧ r ≼ q ∧ r ⊩ φ env ∧ r ⊩ ψ env))›*) using assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹(ψ::i) ∈ formula›*) Forces_Neg (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ ⋅¬?φ⋅ ?env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env)›*) Forces_Nand (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula; ?ψ ∈ formula⟧ ⟹ ?p ⊩ ⋅¬(?φ ∧ ?ψ)⋅ ?env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env ∧ q ⊩ ?ψ ?env)›*) by (auto simp only:) lemma Forces_And_iff_dense_below: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" "ψ∈formula" shows "(p ⊩ And(φ,ψ) env) ⟷ dense_below({r∈ℙ. (r ⊩ φ env) ∧ (r ⊩ ψ env) },p)" unfolding dense_below_def (*goal: ‹(p::i) ⊩ ⋅φ::i ∧ ψ::i⋅ (env::i) ⟷ (∀pa::i∈ℙ. pa ≼ p ⟶ (∃d::i∈{r::i ∈ ℙ . r ⊩ φ env ∧ r ⊩ ψ env}. d ∈ ℙ ∧ d ≼ pa))›*) using Forces_And_aux (*‹⟦(?p::i) ∈ ℙ; (?env::i) ∈ list(M::i); (?φ::i) ∈ formula; (?ψ::i) ∈ formula⟧ ⟹ ?p ⊩ ⋅?φ ∧ ?ψ⋅ ?env ⟷ (∀q::i∈M. q ∈ ℙ ∧ q ≼ ?p ⟶ (∃r::i∈M. r ∈ ℙ ∧ r ≼ q ∧ r ⊩ ?φ ?env ∧ r ⊩ ?ψ ?env))›*) assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula›*) apply ((auto dest:transitivity[OF _ P_in_M] (*‹?y ∈ ℙ ⟹ ?y ∈ M›*))[1]) (*goal: ‹p ⊩ ⋅φ ∧ ψ⋅ env ⟷ (∀pa∈ℙ. pa ≼ p ⟶ (∃d∈{r ∈ ℙ . r ⊩ φ env ∧ r ⊩ ψ env}. d ∈ ℙ ∧ d ≼ pa))›*) apply ((rename_tac q)[1]) (*goal: ‹⋀q. ⟦⋀p env φ ψ. ⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula⟧ ⟹ (M, Cons(p, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(⋅φ ∧ ψ⋅)) ⟷ (∀q∈M. q ∈ ℙ ∧ q ≼ p ⟶ (∃r∈M. r ∈ ℙ ∧ r ≼ q ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ)))); p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula; ∀pa∈ℙ. pa ≼ p ⟶ (∃d∈ℙ. (M, Cons(d, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(d, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ)) ∧ d ≼ pa); q ∈ M; q ∈ ℙ; q ≼ p⟧ ⟹ ∃r∈M. r ∈ ℙ ∧ r ≼ q ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ))›*) apply ((drule_tac x=q in bspec (*‹⟦∀x∈?A. ?P(x); ?x ∈ ?A⟧ ⟹ ?P(?x)›*))[1]) (*goals: 1. ‹⋀q. ⟦⋀p env φ ψ. ⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula⟧ ⟹ (M, Cons(p, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(⋅φ ∧ ψ⋅)) ⟷ (∀q∈M. q ∈ ℙ ∧ q ≼ p ⟶ (∃r∈M. r ∈ ℙ ∧ r ≼ q ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ)))); p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula; q ∈ M; q ∈ ℙ; q ≼ p⟧ ⟹ q ∈ ℙ› 2. ‹⋀q. ⟦⋀p env φ ψ. ⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula⟧ ⟹ (M, Cons(p, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(⋅φ ∧ ψ⋅)) ⟷ (∀q∈M. q ∈ ℙ ∧ q ≼ p ⟶ (∃r∈M. r ∈ ℙ ∧ r ≼ q ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ)))); p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula; q ∈ M; q ∈ ℙ; q ≼ p; q ≼ p ⟶ (∃d∈ℙ. (M, Cons(d, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(d, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ)) ∧ d ≼ q)⟧ ⟹ ∃r∈M. r ∈ ℙ ∧ r ≼ q ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(φ)) ∧ (M, Cons(r, Cons(ℙ, Cons(leq, Cons(𝟭, env)))) ⊨ forces(ψ))› discuss goal 1*) apply ((auto dest:transitivity[OF _ P_in_M] (*‹?y ∈ ℙ ⟹ ?y ∈ M›*))[1]) (*discuss goal 2*) apply ((auto dest:transitivity[OF _ P_in_M] (*‹?y ∈ ℙ ⟹ ?y ∈ M›*))[1]) (*proven 2 subgoals*) . lemma Forces_Forall: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" shows "(p ⊩ Forall(φ) env) ⟷ (∀x∈M. (p ⊩ φ ([x] @ env)))" using sats_forces_Forall (*‹⟦?φ ∈ formula; ?env ∈ list(M); ?p ∈ M⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ ?p ∈ ℙ ∧ (∀x∈M. ?p ⊩ ?φ [x] @ ?env)›*) assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula›*) transitivity[OF _ P_in_M] (*‹?y ∈ ℙ ⟹ ?y ∈ M›*) by simp (* "x∈val(G,π) ⟹ ∃θ. ∃p∈G. ⟨θ,p⟩∈π ∧ val(G,θ) = x" *) bundle some_rules = elem_of_val_pair [dest] context includes some_rules begin lemma elem_of_valI: "∃θ. ∃p∈ℙ. p∈G ∧ ⟨θ,p⟩∈π ∧ val(G,θ) = x ⟹ x∈val(G,π)" apply (subst def_val (*‹val(?G, ?x) = {z . t ∈ domain(?x), (∃p∈?G. ⟨t, p⟩ ∈ ?x) ∧ z = val(?G, t)}›*)) (*goal: ‹∃θ. ∃p∈ℙ. p ∈ G ∧ ⟨θ, p⟩ ∈ π ∧ val(G, θ) = x ⟹ x ∈ val(G, π)›*) by auto lemma GenExt_iff: "x∈M[G] ⟷ (∃τ∈M. x = val(G,τ))" unfolding GenExt_def (*goal: ‹(x::i) ∈ {val(G::i, τ) . τ::i ∈ (M::i)} ⟷ (∃τ::i∈M. x = val(G, τ))›*) by simp end end context G_generic1 begin subsection‹Kunen 2013, Lemma IV.2.29› lemma generic_inter_dense_below: assumes "D∈M" "dense_below(D,p)" "p∈G" shows "D ∩ G ≠ 0" proof (-) (*goal: ‹D ∩ G ≠ 0›*) let ?D = "{q∈ℙ. p⊥q ∨ q∈D}" have "dense(?D)" proof (standard) (*goal: ‹⋀pa. pa ∈ ℙ ⟹ ∃d∈{q ∈ ℙ . p ⊥ q ∨ q ∈ D}. d ≼ pa›*) fix r assume "r∈ℙ" (*‹(r::i) ∈ ℙ›*) show "∃d∈{q ∈ ℙ . p ⊥ q ∨ q ∈ D}. d ≼ r" proof (cases "p ⊥ r") (*goals: 1. ‹p ⊥ r ⟹ ∃d∈{q ∈ ℙ . p ⊥ q ∨ q ∈ D}. d ≼ r› 2. ‹¬ p ⊥ r ⟹ ∃d∈{q ∈ ℙ . p ⊥ q ∨ q ∈ D}. d ≼ r›*) case True (*‹p ⊥ r›*) with ‹r∈ℙ› (*‹r ∈ ℙ›*) show "?thesis" (*goal: ‹∃d∈{q ∈ ℙ . p ⊥ q ∨ q ∈ D}. d ≼ r›*) using refl_leq[of r] (*‹(r::i) ∈ ℙ ⟹ r ≼ r›*) apply (intro bexI (*‹⟦?P(?x); ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P(x)›*)) (*goals: 1. ‹⟦r ∈ ℙ; p ⊥ r; r ∈ ℙ ⟹ r ≼ r⟧ ⟹ ?d3 ≼ r› 2. ‹⟦r ∈ ℙ; p ⊥ r; r ∈ ℙ ⟹ r ≼ r⟧ ⟹ ?d3 ∈ {q ∈ ℙ . p ⊥ q ∨ q ∈ D}› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . next (*goal: ‹¬ (p::i) ⊥ (r::i) ⟹ ∃d::i∈{q::i ∈ ℙ . p ⊥ q ∨ q ∈ (D::i)}. d ≼ r›*) case False (*‹¬ p ⊥ r›*) then obtain s where "s∈ℙ" "s≼p" "s≼r" (*goal: ‹(⋀s. ⟦s ∈ ℙ; s ≼ p; s ≼ r⟧ ⟹ thesis) ⟹ thesis›*) by blast with assms (*‹D ∈ M› ‹dense_below(D::i, p::i)› ‹p ∈ G›*) ‹r∈ℙ› (*‹r ∈ ℙ›*) show "?thesis" (*goal: ‹∃d∈{q ∈ ℙ . p ⊥ q ∨ q ∈ D}. d ≼ r›*) using dense_belowD[OF assms ( 2 ), of s] (*‹⟦s ∈ ℙ; s ≼ p⟧ ⟹ ∃d∈D. d ∈ ℙ ∧ d ≼ s›*) leq_transD[of _ s r] (*‹⟦(?a::i) ≼ (s::i); s ≼ (r::i); ?a ∈ ℙ; s ∈ ℙ; r ∈ ℙ⟧ ⟹ ?a ≼ r›*) by blast qed qed have "?D⊆ℙ" by auto let ?d_fm = "⋅⋅¬compat_in_fm(1, 2, 3, 0) ⋅ ∨ ⋅0 ∈ 4⋅⋅" from ‹p∈G› (*‹p ∈ G›*) have "p∈M" using G_subset_M (*‹(G::i) ⊆ (M::i)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) by simp moreover have "?d_fm∈formula" by simp moreover have "arity(?d_fm) = 5" by (auto simp add: arity (*‹⟦?φ ∈ formula; ?t ∈ ω; ?f ∈ ω; ?r ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))› ‹⟦?t1.0 ∈ ω; ?t2.0 ∈ ω; ?up ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦?r ∈ ω; ?s ∈ ω; ?t ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 191 facts*)) moreover from ‹D∈M› (*‹D ∈ M›*) ‹p∈M› (*‹p ∈ M›*) have "(M, [q,ℙ,leq,p,D] ⊨ ?d_fm) ⟷ (¬ is_compat_in(##M,ℙ,leq,p,q) ∨ q∈D)" if "q∈M" for q using that (*‹q ∈ M›*) sats_compat_in_fm (*‹⟦?A ∈ ω; ?r ∈ ω; ?p ∈ ω; ?q ∈ ω; ?env ∈ list(?Aa); 0 ∈ ?Aa⟧ ⟹ (?Aa, ?env ⊨ compat_in_fm(?A, ?r, ?p, ?q)) ⟷ is_compat_in(##?Aa, nth(?A, ?env), nth(?r, ?env), nth(?p, ?env), nth(?q, ?env))›*) zero_in_M (*‹0 ∈ M›*) by simp moreover from ‹p∈M› (*‹p ∈ M›*) have "(¬ is_compat_in(##M,ℙ,leq,p,q) ∨ q∈D) ⟷ p⊥q ∨ q∈D" if "q∈M" for q unfolding compat_def (*goal: ‹¬ is_compat_in(##(M::i), ℙ, leq::i, p::i, q::i) ∨ q ∈ (D::i) ⟷ ¬ compat_in(ℙ, leq, p, q) ∨ q ∈ D›*) using that (*‹q ∈ M›*) compat_in_abs (*‹⟦(##M)(?A); (##M)(?r); (##M)(?p); (##M)(?q)⟧ ⟹ is_compat_in(##M, ?A, ?r, ?p, ?q) ⟷ compat_in(?A, ?r, ?p, ?q)›*) by simp ultimately have "?D∈M" using Collect_in_M[of ?d_fm "[ℙ,leq,p,D]"] (*‹⟦⋅⋅¬compat_in_fm(1, 2, 3, 0)⋅ ∨ ⋅0 ∈ 4⋅⋅ ∈ formula; [ℙ, leq, p, D] ∈ list(M); arity(⋅⋅¬compat_in_fm(1, 2, 3, 0)⋅ ∨ ⋅0 ∈ 4⋅⋅) ≤ 1 +⇩ω length([ℙ, leq, p, D]); ?A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, p, D] ⊨ ⋅⋅¬compat_in_fm(1, 2, 3, 0)⋅ ∨ ⋅0 ∈ 4⋅⋅) ⟷ ?Q(x)⟧ ⟹ {y ∈ ?A . ?Q(y)} ∈ M›*) ‹D∈M› (*‹D ∈ M›*) by simp note asm = ‹dense(?D)› (*‹dense({q ∈ ℙ . p ⊥ q ∨ q ∈ D})›*) ‹?D⊆ℙ› (*‹{q ∈ ℙ . p ⊥ q ∨ q ∈ D} ⊆ ℙ›*) ‹?D∈M› (*‹{q ∈ ℙ . p ⊥ q ∨ q ∈ D} ∈ M›*) obtain x where "x∈G" "x∈?D" (*goal: ‹(⋀x::i. ⟦x ∈ (G::i); x ∈ {q::i ∈ ℙ . (p::i) ⊥ q ∨ q ∈ (D::i)}⟧ ⟹ thesis::o) ⟹ thesis›*) using M_generic_denseD[OF asm] (*‹∃q∈G. q ∈ {q ∈ ℙ . p ⊥ q ∨ q ∈ D}›*) by force moreover from this (*‹x ∈ G› ‹x ∈ {q ∈ ℙ . p ⊥ q ∨ q ∈ D}›*) have "x∈D" using M_generic_compatD[OF _ ‹p∈G›, of x] (*‹x ∈ G ⟹ ∃q∈G. q ≼ x ∧ q ≼ p›*) refl_leq (*‹?r ∈ ℙ ⟹ ?r ≼ ?r›*) compatI[of _ p x] (*‹⟦?d ∈ ℙ; ?d ≼ p; ?d ≼ x⟧ ⟹ compat(p, x)›*) by force ultimately show "?thesis" (*goal: ‹D ∩ G ≠ 0›*) by auto qed subsection‹Auxiliary results for Lemma IV.2.40(a)› lemma (in forcing_data1) IV240a_mem_Collect: assumes "π∈M" "τ∈M" shows "{q∈ℙ. ∃σ. ∃r. r∈ℙ ∧ ⟨σ,r⟩ ∈ τ ∧ q≼r ∧ q forces⇩a (π = σ)}∈M" proof (-) (*goal: ‹{q ∈ ℙ . ∃σ r. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ τ ∧ q ≼ r ∧ q forces⇩a (π = σ)} ∈ M›*) let ?rel_pred = "λM x a1 a2 a3 a4. ∃σ[M]. ∃r[M]. ∃σr[M]. r∈a1 ∧ pair(M,σ,r,σr) ∧ σr∈a4 ∧ is_leq(M,a2,x,r) ∧ is_forces_eq'(M,a1,a2,x,a3,σ)" let ?φ = "Exists(Exists(Exists(And(Member(1,4),And(pair_fm(2,1,0), And(Member(0,7),And(is_leq_fm(5,3,1),forces_eq_fm(4,5,3,6,2))))))))" have "σ∈M ∧ r∈M" if "⟨σ, r⟩ ∈ τ" for σ and r using that (*‹⟨σ, r⟩ ∈ τ›*) ‹τ∈M› (*‹(τ::i) ∈ (M::i)›*) pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) transitivity[of "⟨σ,r⟩" τ] (*‹⟦⟨σ::i, r::i⟩ ∈ (τ::i); τ ∈ (M::i)⟧ ⟹ ⟨σ, r⟩ ∈ M›*) by simp then have "?rel_pred(##M,q,ℙ,leq,π,τ) ⟷ (∃σ. ∃r. r∈ℙ ∧ ⟨σ,r⟩ ∈ τ ∧ q≼r ∧ q forces⇩a (π = σ))" if "q∈M" for q unfolding forces_eq_def (*goal: ‹(∃σ[##M]. ∃r[##M]. ∃σr[##M]. r ∈ ℙ ∧ pair(##M, σ, r, σr) ∧ σr ∈ τ ∧ is_leq(##M, leq, q, r) ∧ is_forces_eq(q, π, σ)) ⟷ (∃σ r. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ τ ∧ q ≼ r ∧ forces_eq'(ℙ, leq, q, π, σ))›*) using assms (*‹(π::i) ∈ (M::i)› ‹τ ∈ M›*) that (*‹q ∈ M›*) leq_abs (*‹⟦?l ∈ M; ?q ∈ M; ?p ∈ M⟧ ⟹ is_leq(##M, ?l, ?q, ?p) ⟷ ⟨?q, ?p⟩ ∈ ?l›*) forces_eq'_abs (*‹⟦?p ∈ M; ?t1.0 ∈ M; ?t2.0 ∈ M⟧ ⟹ is_forces_eq(?p, ?t1.0, ?t2.0) ⟷ forces_eq'(ℙ, leq, ?p, ?t1.0, ?t2.0)›*) pair_in_M_iff (*‹(##(M::i))(⟨?a::i, ?b::i⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) by auto moreover have "(M, [q,ℙ,leq,π,τ] ⊨ ?φ) ⟷ ?rel_pred(##M,q,ℙ,leq,π,τ)" if "q∈M" for q using assms (*‹(π::i) ∈ (M::i)› ‹τ ∈ M›*) that (*‹q ∈ M›*) sats_forces_eq_fm (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω; ?env ∈ list(?A)⟧ ⟹ (?A, ?env ⊨ forces_eq_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) ⟷ is_forces_eq'(##?A, nth(?P, ?env), nth(?l, ?env), nth(?p, ?env), nth(?t1.0, ?env), nth(?t2.0, ?env))›*) sats_is_leq_fm (*‹⟦?l ∈ ω; ?q ∈ ω; ?p ∈ ω; ?env ∈ list(?Aa); 0 ∈ ?Aa⟧ ⟹ (?Aa, ?env ⊨ ⋅?q≼⇗?l⇖?p⋅) ⟷ is_leq(##?Aa, nth(?l, ?env), nth(?q, ?env), nth(?p, ?env))›*) zero_in_M (*‹0 ∈ M›*) by simp moreover have "?φ∈formula" by simp moreover have "arity(?φ)=5" using arity_forces_eq_fm (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω⟧ ⟹ arity(forces_eq_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) = succ(?t2.0) ∪ (succ(?p) ∪ (succ(?t1.0) ∪ (succ(?P) ∪ succ(?l))))›*) by (simp add:ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) arity (*‹⟦?φ ∈ formula; ?t ∈ ω; ?f ∈ ω; ?r ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))› ‹⟦?t1.0 ∈ ω; ?t2.0 ∈ ω; ?up ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦?r ∈ ω; ?s ∈ ω; ?t ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 191 facts*)) ultimately show "?thesis" (*goal: ‹{q ∈ ℙ . ∃σ r. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ τ ∧ q ≼ r ∧ q forces⇩a (π = σ)} ∈ M›*) unfolding forces_eq_def (*goal: ‹{q::i ∈ ℙ . ∃(σ::i) r::i. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ (τ::i) ∧ q ≼ r ∧ forces_eq'(ℙ, leq::i, q, π::i, σ)} ∈ (M::i)›*) using assms (*‹(π::i) ∈ (M::i)› ‹(τ::i) ∈ (M::i)›*) Collect_in_M[of ?φ "[ℙ,leq,π,τ]"] (*‹⟦(⋅∃(⋅∃(⋅∃⋅⋅1 ∈ 4⋅ ∧ ⋅⋅⟨2,1⟩ is 0 ⋅ ∧ ⋅⋅0 ∈ 7⋅ ∧ ⋅⋅3≼⇗5⇖1⋅ ∧ forces_eq_fm(4, 5, 3, 6, 2)⋅⋅⋅⋅⋅)⋅)⋅) ∈ formula; [ℙ, leq::i, π::i, τ::i] ∈ list(M::i); arity((⋅∃(⋅∃(⋅∃⋅⋅1 ∈ 4⋅ ∧ ⋅⋅⟨2,1⟩ is 0 ⋅ ∧ ⋅⋅0 ∈ 7⋅ ∧ ⋅⋅3≼⇗5⇖1⋅ ∧ forces_eq_fm(4, 5, 3, 6, 2)⋅⋅⋅⋅⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, π, τ]); (?A::i) ∈ M; ⋀x::i. x ∈ M ⟹ (M, [x] @ [ℙ, leq, π, τ] ⊨ (⋅∃(⋅∃(⋅∃⋅⋅1 ∈ 4⋅ ∧ ⋅⋅⟨2,1⟩ is 0 ⋅ ∧ ⋅⋅0 ∈ 7⋅ ∧ ⋅⋅3≼⇗5⇖1⋅ ∧ forces_eq_fm(4, 5, 3, 6, 2)⋅⋅⋅⋅⋅)⋅)⋅)) ⟷ (?Q::i ⇒ o)(x)⟧ ⟹ {y::i ∈ ?A . ?Q(y)} ∈ M›*) by simp qed (* Lemma IV.2.40(a), membership *) lemma IV240a_mem: assumes "p∈G" "π∈M" "τ∈M" "p forces⇩a (π ∈ τ)" "⋀q σ. q∈ℙ ⟹ q∈G ⟹ σ∈domain(τ) ⟹ q forces⇩a (π = σ) ⟹ val(G,π) = val(G,σ)" (* inductive hypothesis *) shows "val(G,π)∈val(G,τ)" proof (intro elem_of_valI (*‹∃θ. ∃p∈ℙ. p ∈ ?G ∧ ⟨θ, p⟩ ∈ ?π ∧ val(?G, θ) = ?x ⟹ ?x ∈ val(?G, ?π)›*)) (*goal: ‹∃θ::i. ∃p::i∈ℙ. p ∈ (G::i) ∧ ⟨θ, p⟩ ∈ (τ::i) ∧ val(G, θ) = val(G, π::i)›*) let ?D = "{q∈ℙ. ∃σ. ∃r. r∈ℙ ∧ ⟨σ,r⟩ ∈ τ ∧ q≼r ∧ q forces⇩a (π = σ)}" from ‹p∈G› (*‹p ∈ G›*) have "p∈ℙ" by blast moreover note ‹π∈M› (*‹π ∈ M›*) ‹τ∈M› (*‹τ ∈ M›*) ultimately have "?D ∈ M" using IV240a_mem_Collect (*‹⟦?π ∈ M; ?τ ∈ M⟧ ⟹ {q ∈ ℙ . ∃σ r. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ ?τ ∧ q ≼ r ∧ q forces⇩a (?π = σ)} ∈ M›*) by simp moreover from assms (*‹p ∈ G› ‹π ∈ M› ‹τ ∈ M› ‹p forces⇩a (π ∈ τ)› ‹⟦?q ∈ ℙ; ?q ∈ G; ?σ ∈ domain(τ); ?q forces⇩a (π = ?σ)⟧ ⟹ val(G, π) = val(G, ?σ)›*) ‹p∈ℙ› (*‹(p::i) ∈ ℙ›*) have "dense_below(?D,p)" using forces_mem_iff_dense_below (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 ∈ ?t2.0) ⟷ dense_below({q ∈ ℙ . ∃s r. r ∈ ℙ ∧ ⟨s, r⟩ ∈ ?t2.0 ∧ q ≼ r ∧ q forces⇩a (?t1.0 = s)}, ?p)›*) by simp moreover note ‹p∈G› (*‹(p::i) ∈ (G::i)›*) ultimately obtain q where "q∈G" "q∈?D" (*goal: ‹(⋀q. ⟦q ∈ G; q ∈ {q ∈ ℙ . ∃σ r. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ τ ∧ q ≼ r ∧ q forces⇩a (π = σ)}⟧ ⟹ thesis) ⟹ thesis›*) using generic_inter_dense_below[of ?D p] (*‹⟦{q::i ∈ ℙ . ∃(σ::i) r::i. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ (τ::i) ∧ q ≼ r ∧ q forces⇩a (π::i = σ)} ∈ (M::i); dense_below({q::i ∈ ℙ . ∃(σ::i) r::i. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ τ ∧ q ≼ r ∧ q forces⇩a (π = σ)}, p::i); p ∈ (G::i)⟧ ⟹ {q::i ∈ ℙ . ∃(σ::i) r::i. r ∈ ℙ ∧ ⟨σ, r⟩ ∈ τ ∧ q ≼ r ∧ q forces⇩a (π = σ)} ∩ G ≠ 0›*) by blast then obtain σ and r where "r∈ℙ" "⟨σ,r⟩ ∈ τ" "q≼r" "q forces⇩a (π = σ)" (*goal: ‹(⋀r σ. ⟦r ∈ ℙ; ⟨σ, r⟩ ∈ τ; q ≼ r; q forces⇩a (π = σ)⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover from this (*‹r ∈ ℙ› ‹⟨σ, r⟩ ∈ τ› ‹q ≼ r› ‹q forces⇩a (π = σ)›*) ‹q∈G› (*‹q ∈ G›*) assms (*‹p ∈ G› ‹π ∈ M› ‹τ ∈ M› ‹p forces⇩a (π ∈ τ)› ‹⟦?q ∈ ℙ; ?q ∈ G; ?σ ∈ domain(τ); ?q forces⇩a (π = ?σ)⟧ ⟹ val(G, π) = val(G, ?σ)›*) have "r ∈ G" "val(G,π) = val(G,σ)" apply - (*goals: 1. ‹⟦r ∈ ℙ; ⟨σ, r⟩ ∈ τ; q ≼ r; q forces⇩a (π = σ); q ∈ G; p ∈ G; π ∈ M; τ ∈ M; p forces⇩a (π ∈ τ); ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ); q forces⇩a (π = σ)⟧ ⟹ val(G, π) = val(G, σ)⟧ ⟹ r ∈ G› 2. ‹⟦r ∈ ℙ; ⟨σ, r⟩ ∈ τ; q ≼ r; q forces⇩a (π = σ); q ∈ G; p ∈ G; π ∈ M; τ ∈ M; p forces⇩a (π ∈ τ); ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ); q forces⇩a (π = σ)⟧ ⟹ val(G, π) = val(G, σ)⟧ ⟹ val(G, π) = val(G, σ)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately show "∃ σ. ∃p∈ℙ. p ∈ G ∧ ⟨σ, p⟩ ∈ τ ∧ val(G, σ) = val(G, π)" by auto qed (* Example IV.2.36 (next two lemmas) *) lemma refl_forces_eq:"p∈ℙ ⟹ p forces⇩a (x = x)" using def_forces_eq (*‹(?p::i) ∈ ℙ ⟹ ?p forces⇩a (?t1.0::i = ?t2.0::i) ⟷ (∀s::i∈domain(?t1.0) ∪ domain(?t2.0). ∀q::i. q ∈ ℙ ∧ q ≼ ?p ⟶ q forces⇩a (s ∈ ?t1.0) ⟷ q forces⇩a (s ∈ ?t2.0))›*) by simp lemma forces_memI: "⟨σ,r⟩∈τ ⟹ p∈ℙ ⟹ r∈ℙ ⟹ p≼r ⟹ p forces⇩a (σ ∈ τ)" using refl_forces_eq[of _ σ] (*‹?p ∈ ℙ ⟹ ?p forces⇩a (σ = σ)›*) leq_transD (*‹⟦(?a::i) ≼ (?b::i); ?b ≼ (?c::i); ?a ∈ ℙ; ?b ∈ ℙ; ?c ∈ ℙ⟧ ⟹ ?a ≼ ?c›*) refl_leq (*‹?r ∈ ℙ ⟹ ?r ≼ ?r›*) by (blast intro:forces_mem_iff_dense_below[THEN iffD2] (*‹⟦?p1 ∈ ℙ; dense_below({q ∈ ℙ . ∃s r. r ∈ ℙ ∧ ⟨s, r⟩ ∈ ?t2.1 ∧ q ≼ r ∧ q forces⇩a (?t1.1 = s)}, ?p1)⟧ ⟹ ?p1 forces⇩a (?t1.1 ∈ ?t2.1)›*)) (* Lemma IV.2.40(a), equality, first inclusion *) lemma IV240a_eq_1st_incl: includes some_rules assumes "p∈G" "p forces⇩a (τ = θ)" and IH:"⋀q σ. q∈ℙ ⟹ q∈G ⟹ σ∈domain(τ) ∪ domain(θ) ⟹ (q forces⇩a (σ ∈ τ) ⟶ val(G,σ) ∈ val(G,τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G,σ) ∈ val(G,θ))" (* Strong enough for this case: *) (* IH:"⋀q σ. q∈ℙ ⟹ σ∈domain(τ) ⟹ q forces⇩a (σ ∈ θ) ⟹ val(G,σ) ∈ val(G,θ)" *) shows "val(G,τ) ⊆ val(G,θ)" proof (standard) (*goal: ‹⋀x. x ∈ val(G, τ) ⟹ x ∈ val(G, θ)›*) fix x assume "x∈val(G,τ)" (*‹(x::i) ∈ val(G::i, τ::i)›*) then obtain σ and r where "⟨σ,r⟩∈τ" "r∈G" "val(G,σ)=x" (*goal: ‹(⋀σ r. ⟦⟨σ, r⟩ ∈ τ; r ∈ G; val(G, σ) = x⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover from this (*‹⟨σ, r⟩ ∈ τ› ‹r ∈ G› ‹val(G::i, σ::i) = (x::i)›*) ‹p∈G› (*‹(p::i) ∈ (G::i)›*) obtain q where "q∈G" "q≼p" "q≼r" (*goal: ‹(⋀q::i. ⟦q ∈ (G::i); q ≼ (p::i); q ≼ (r::i)⟧ ⟹ thesis::o) ⟹ thesis›*) by force moreover from this (*‹q ∈ G› ‹(q::i) ≼ (p::i)› ‹(q::i) ≼ (r::i)›*) ‹p∈G› (*‹p ∈ G›*) have "q∈ℙ" "p∈ℙ" apply - (*goals: 1. ‹⟦q ∈ G; q ≼ p; q ≼ r; p ∈ G⟧ ⟹ q ∈ ℙ› 2. ‹⟦q ∈ G; q ≼ p; q ≼ r; p ∈ G⟧ ⟹ p ∈ ℙ› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover from calculation (*‹⟨σ, r⟩ ∈ τ› ‹r ∈ G› ‹val(G, σ) = x› ‹(q::i) ∈ (G::i)› ‹q ≼ p› ‹q ≼ r› ‹(q::i) ∈ ℙ› ‹p ∈ ℙ›*) have "q forces⇩a (σ ∈ τ)" using forces_memI (*‹⟦⟨?σ, ?r⟩ ∈ ?τ; ?p ∈ ℙ; ?r ∈ ℙ; ?p ≼ ?r⟧ ⟹ ?p forces⇩a (?σ ∈ ?τ)›*) by auto moreover note ‹p forces⇩a (τ = θ)› (*‹p forces⇩a (τ = θ)›*) ultimately have "q forces⇩a (σ ∈ θ)" using def_forces_eq (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 = ?t2.0) ⟷ (∀s∈domain(?t1.0) ∪ domain(?t2.0). ∀q. q ∈ ℙ ∧ q ≼ ?p ⟶ q forces⇩a (s ∈ ?t1.0) ⟷ q forces⇩a (s ∈ ?t2.0))›*) by auto with ‹q∈ℙ› (*‹q ∈ ℙ›*) ‹q∈G› (*‹q ∈ G›*) IH[of q σ] (*‹⟦(q::i) ∈ ℙ; q ∈ (G::i); (σ::i) ∈ domain(τ::i) ∪ domain(θ::i)⟧ ⟹ (q forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))›*) ‹⟨σ,r⟩∈τ› (*‹⟨σ, r⟩ ∈ τ›*) ‹val(G,σ) = x› (*‹val(G, σ) = x›*) show "x∈val(G,θ)" by blast qed (* Lemma IV.2.40(a), equality, second inclusion--- COℙY-ℙASTE *) lemma IV240a_eq_2nd_incl: includes some_rules assumes "p∈G" "p forces⇩a (τ = θ)" and IH:"⋀q σ. q∈ℙ ⟹ q∈G ⟹ σ∈domain(τ) ∪ domain(θ) ⟹ (q forces⇩a (σ ∈ τ) ⟶ val(G,σ) ∈ val(G,τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G,σ) ∈ val(G,θ))" shows "val(G,θ) ⊆ val(G,τ)" proof (standard) (*goal: ‹⋀x. x ∈ val(G, θ) ⟹ x ∈ val(G, τ)›*) fix x assume "x∈val(G,θ)" (*‹(x::i) ∈ val(G::i, θ::i)›*) then obtain σ and r where "⟨σ,r⟩∈θ" "r∈G" "val(G,σ)=x" (*goal: ‹(⋀(σ::i) r::i. ⟦⟨σ, r⟩ ∈ (θ::i); r ∈ (G::i); val(G, σ) = (x::i)⟧ ⟹ thesis::o) ⟹ thesis›*) by blast moreover from this (*‹⟨σ, r⟩ ∈ θ› ‹r ∈ G› ‹val(G::i, σ::i) = (x::i)›*) ‹p∈G› (*‹p ∈ G›*) obtain q where "q∈G" "q≼p" "q≼r" (*goal: ‹(⋀q::i. ⟦q ∈ (G::i); q ≼ (p::i); q ≼ (r::i)⟧ ⟹ thesis::o) ⟹ thesis›*) by force moreover from this (*‹q ∈ G› ‹q ≼ p› ‹q ≼ r›*) ‹p∈G› (*‹p ∈ G›*) have "q∈ℙ" "p∈ℙ" apply - (*goals: 1. ‹⟦q ∈ G; q ≼ p; q ≼ r; p ∈ G⟧ ⟹ q ∈ ℙ› 2. ‹⟦q ∈ G; q ≼ p; q ≼ r; p ∈ G⟧ ⟹ p ∈ ℙ› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover from calculation (*‹⟨σ::i, r::i⟩ ∈ (θ::i)› ‹r ∈ G› ‹val(G, σ) = x› ‹q ∈ G› ‹q ≼ p› ‹q ≼ r› ‹q ∈ ℙ› ‹p ∈ ℙ›*) have "q forces⇩a (σ ∈ θ)" using forces_memI (*‹⟦⟨?σ, ?r⟩ ∈ ?τ; ?p ∈ ℙ; ?r ∈ ℙ; ?p ≼ ?r⟧ ⟹ ?p forces⇩a (?σ ∈ ?τ)›*) by auto moreover note ‹p forces⇩a (τ = θ)› (*‹p forces⇩a (τ = θ)›*) ultimately have "q forces⇩a (σ ∈ τ)" using def_forces_eq (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 = ?t2.0) ⟷ (∀s∈domain(?t1.0) ∪ domain(?t2.0). ∀q. q ∈ ℙ ∧ q ≼ ?p ⟶ q forces⇩a (s ∈ ?t1.0) ⟷ q forces⇩a (s ∈ ?t2.0))›*) by auto with ‹q∈ℙ› (*‹q ∈ ℙ›*) ‹q∈G› (*‹q ∈ G›*) IH[of q σ] (*‹⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ (q forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))›*) ‹⟨σ,r⟩∈θ› (*‹⟨σ, r⟩ ∈ θ›*) ‹val(G,σ) = x› (*‹val(G, σ) = x›*) show "x∈val(G,τ)" by blast qed (* Lemma IV.2.40(a), equality, second inclusion--- COℙY-ℙASTE *) lemma IV240a_eq: includes some_rules assumes "p∈G" "p forces⇩a (τ = θ)" and IH:"⋀q σ. q∈ℙ ⟹ q∈G ⟹ σ∈domain(τ) ∪ domain(θ) ⟹ (q forces⇩a (σ ∈ τ) ⟶ val(G,σ) ∈ val(G,τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G,σ) ∈ val(G,θ))" shows "val(G,τ) = val(G,θ)" using IV240a_eq_1st_incl[OF assms] (*‹⟦⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ q ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ q ∈ G; ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ val(G, τ) ⊆ val(G, θ)›*) IV240a_eq_2nd_incl[OF assms] (*‹⟦⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ q ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ q ∈ G; ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ val(G, θ) ⊆ val(G, τ)›*) IH (*‹⟦?q ∈ ℙ; ?q ∈ G; ?σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ (?q forces⇩a (?σ ∈ τ) ⟶ val(G, ?σ) ∈ val(G, τ)) ∧ (?q forces⇩a (?σ ∈ θ) ⟶ val(G, ?σ) ∈ val(G, θ))›*) by blast subsection‹Induction on names› lemma (in forcing_data1) core_induction: assumes "⋀τ θ p. p ∈ ℙ ⟹ ⟦⋀q σ. ⟦q∈ℙ ; σ∈domain(θ)⟧ ⟹ Q(0,τ,σ,q)⟧ ⟹ Q(1,τ,θ,p)" "⋀τ θ p. p ∈ ℙ ⟹ ⟦⋀q σ. ⟦q∈ℙ ; σ∈domain(τ) ∪ domain(θ)⟧ ⟹ Q(1,σ,τ,q) ∧ Q(1,σ,θ,q)⟧ ⟹ Q(0,τ,θ,p)" "ft ∈ 2" "p ∈ ℙ" shows "Q(ft,τ,θ,p)" proof (-) (*goal: ‹Q(ft, τ, θ, p)›*) { fix ft and p and τ and θ have "Transset(eclose({τ,θ}))" (is "Transset(?e)") using Transset_eclose (*‹Transset(eclose(?A::i))›*) by simp have "τ ∈ ?e" "θ ∈ ?e" using arg_into_eclose (*‹?c ∈ ?A ⟹ ?c ∈ eclose(?A)›*) apply - (*goals: 1. ‹(⋀c A. c ∈ A ⟹ c ∈ eclose(A)) ⟹ τ ∈ eclose({τ, θ})› 2. ‹(⋀c A. c ∈ A ⟹ c ∈ eclose(A)) ⟹ θ ∈ eclose({τ, θ})› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "ft ∈ 2" "p ∈ ℙ" (*‹(ft::i) ∈ 2› ‹(p::i) ∈ ℙ›*) ultimately have "⟨ft,τ,θ,p⟩∈ 2×?e×?e×ℙ" (is "?a∈2×?e×?e×ℙ") by simp then have "Q(ftype(?a), name1(?a), name2(?a), cond_of(?a))" using core_induction_aux[of ?e ℙ Q ?a, OF ‹Transset(?e)› assms ( 1 , 2 ) ‹?a∈_›] (*‹⟦⋀(τ::i) (θ::i) p::i. ⟦p ∈ ℙ; ⋀(q::i) σ::i. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ (Q::i ⇒ i ⇒ i ⇒ i ⇒ o)(0, τ, σ, q)⟧ ⟹ p ∈ ℙ; ⋀(τ::i) (θ::i) (p::i) (q::i) σ::i. ⟦p ∈ ℙ; ⋀(q::i) σ::i. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ Q(0, τ, σ, q); q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ Q(0, τ, σ, q); ⋀(τ::i) (θ::i) p::i. ⟦p ∈ ℙ; ⋀(q::i) σ::i. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ Q(1, σ, τ, q) ∧ Q(1, σ, θ, q)⟧ ⟹ p ∈ ℙ; ⋀(τ::i) (θ::i) (p::i) (q::i) σ::i. ⟦p ∈ ℙ; ⋀(q::i) σ::i. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ Q(1, σ, τ, q) ∧ Q(1, σ, θ, q); q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ Q(1, σ, τ, q) ∧ Q(1, σ, θ, q)⟧ ⟹ Q(ftype(⟨ft::i, τ::i, θ::i, p::i⟩), name1(⟨ft, τ, θ, p⟩), name2(⟨ft, τ, θ, p⟩), cond_of(⟨ft, τ, θ, p⟩))›*) apply clarify (*goal: ‹Q(ftype(⟨ft, τ, θ, p⟩), name1(⟨ft, τ, θ, p⟩), name2(⟨ft, τ, θ, p⟩), cond_of(⟨ft, τ, θ, p⟩))›*) by blast then have "Q(ft,τ,θ,p)" by (simp add:components_simp (*‹ftype(⟨?f, ?n1.0, ?n2.0, ?c⟩) = ?f› ‹name1(⟨?f, ?n1.0, ?n2.0, ?c⟩) = ?n1.0› ‹name2(⟨?f, ?n1.0, ?n2.0, ?c⟩) = ?n2.0› ‹cond_of(⟨?f, ?n1.0, ?n2.0, ?c⟩) = ?c›*)) } then show "?thesis" (*goal: ‹Q(ft, τ, θ, p)›*) using assms (*‹⟦(?p::i) ∈ ℙ; ⋀(q::i) σ::i. ⟦q ∈ ℙ; σ ∈ domain(?θ::i)⟧ ⟹ (Q::i ⇒ i ⇒ i ⇒ i ⇒ o)(0, ?τ::i, σ, q)⟧ ⟹ Q(1, ?τ, ?θ, ?p)› ‹⟦?p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(?τ) ∪ domain(?θ)⟧ ⟹ Q(1, σ, ?τ, q) ∧ Q(1, σ, ?θ, q)⟧ ⟹ Q(0, ?τ, ?θ, ?p)› ‹ft ∈ 2› ‹p ∈ ℙ›*) by simp qed lemma (in forcing_data1) forces_induction_with_conds: assumes "⋀τ θ p. p ∈ ℙ ⟹ ⟦⋀q σ. ⟦q∈ℙ ; σ∈domain(θ)⟧ ⟹ Q(q,τ,σ)⟧ ⟹ R(p,τ,θ)" "⋀τ θ p. p ∈ ℙ ⟹ ⟦⋀q σ. ⟦q∈ℙ ; σ∈domain(τ) ∪ domain(θ)⟧ ⟹ R(q,σ,τ) ∧ R(q,σ,θ)⟧ ⟹ Q(p,τ,θ)" "p ∈ ℙ" shows "Q(p,τ,θ) ∧ R(p,τ,θ)" proof (-) (*goal: ‹Q(p, τ, θ) ∧ R(p, τ, θ)›*) let ?Q = "λft τ θ p. (ft = 0 ⟶ Q(p,τ,θ)) ∧ (ft = 1 ⟶ R(p,τ,θ))" from assms(1) (*‹⟦?p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(?θ)⟧ ⟹ Q(q, ?τ, σ)⟧ ⟹ R(?p, ?τ, ?θ)›*) have "⋀τ θ p. p ∈ ℙ ⟹ ⟦⋀q σ. ⟦q∈ℙ ; σ∈domain(θ)⟧ ⟹ ?Q(0,τ,σ,q)⟧ ⟹ ?Q(1,τ,θ,p)" by simp moreover from assms(2) (*‹⟦?p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(?τ) ∪ domain(?θ)⟧ ⟹ R(q, σ, ?τ) ∧ R(q, σ, ?θ)⟧ ⟹ Q(?p, ?τ, ?θ)›*) have "⋀τ θ p. p ∈ ℙ ⟹ ⟦⋀q σ. ⟦q∈ℙ ; σ∈domain(τ) ∪ domain(θ)⟧ ⟹ ?Q(1,σ,τ,q) ∧ ?Q(1,σ,θ,q)⟧ ⟹ ?Q(0,τ,θ,p)" by simp moreover note ‹p∈ℙ› (*‹p ∈ ℙ›*) ultimately have "?Q(ft,τ,θ,p)" if "ft∈2" for ft apply (rule core_induction[OF _ _ that, of ?Q] (*‹⟦⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ (0 = 0 ⟶ Q(q, τ, σ)) ∧ (0 = 1 ⟶ R(q, τ, σ))⟧ ⟹ (1 = 0 ⟶ Q(p, τ, θ)) ∧ (1 = 1 ⟶ R(p, τ, θ)); ⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ ((1 = 0 ⟶ Q(q, σ, τ)) ∧ (1 = 1 ⟶ R(q, σ, τ))) ∧ (1 = 0 ⟶ Q(q, σ, θ)) ∧ (1 = 1 ⟶ R(q, σ, θ))⟧ ⟹ (0 = 0 ⟶ Q(p, τ, θ)) ∧ (0 = 1 ⟶ R(p, τ, θ)); ?p ∈ ℙ⟧ ⟹ (ft = 0 ⟶ Q(?p, ?τ, ?θ)) ∧ (ft = 1 ⟶ R(?p, ?τ, ?θ))›*)) (*goals: 1. ‹⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ (0 = 0 ⟶ Q(q, τ, σ)) ∧ (0 = 1 ⟶ R(q, τ, σ))⟧ ⟹ p ∈ ℙ› 2. ‹⋀τ θ p q σ. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ (0 = 0 ⟶ Q(q, τ, σ)) ∧ (0 = 1 ⟶ R(q, τ, σ)); q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ (0 = 0 ⟶ Q(q, τ, σ)) ∧ (0 = 1 ⟶ R(q, τ, σ))› 3. ‹⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ ((1 = 0 ⟶ Q(q, σ, τ)) ∧ (1 = 1 ⟶ R(q, σ, τ))) ∧ (1 = 0 ⟶ Q(q, σ, θ)) ∧ (1 = 1 ⟶ R(q, σ, θ))⟧ ⟹ p ∈ ℙ› 4. ‹⋀τ θ p q σ. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ ((1 = 0 ⟶ Q(q, σ, τ)) ∧ (1 = 1 ⟶ R(q, σ, τ))) ∧ (1 = 0 ⟶ Q(q, σ, θ)) ∧ (1 = 1 ⟶ R(q, σ, θ)); q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ ((1 = 0 ⟶ Q(q, σ, τ)) ∧ (1 = 1 ⟶ R(q, σ, τ))) ∧ (1 = 0 ⟶ Q(q, σ, θ)) ∧ (1 = 1 ⟶ R(q, σ, θ))› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) then show "?thesis" (*goal: ‹Q(p, τ, θ) ∧ R(p, τ, θ)›*) by auto qed lemma (in forcing_data1) forces_induction: assumes "⋀τ θ. ⟦⋀σ. σ∈domain(θ) ⟹ Q(τ,σ)⟧ ⟹ R(τ,θ)" "⋀τ θ. ⟦⋀σ. σ∈domain(τ) ∪ domain(θ) ⟹ R(σ,τ) ∧ R(σ,θ)⟧ ⟹ Q(τ,θ)" shows "Q(τ,θ) ∧ R(τ,θ)" proof (intro forces_induction_with_conds[OF _ _ one_in_P (*‹⟦⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ ?Q(q, τ, σ)⟧ ⟹ ?R(p, τ, θ); ⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ ?R(q, σ, τ) ∧ ?R(q, σ, θ)⟧ ⟹ ?Q(p, τ, θ)⟧ ⟹ ?Q(𝟭, ?τ, ?θ) ∧ ?R(𝟭, ?τ, ?θ)›*) ]) (*goals: 1. ‹⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(θ)⟧ ⟹ Q(τ, σ)⟧ ⟹ R(τ, θ)› 2. ‹⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ R(σ, τ) ∧ R(σ, θ)⟧ ⟹ Q(τ, θ)›*) fix τ and θ and p assume "q ∈ ℙ ⟹ σ ∈ domain(θ) ⟹ Q(τ, σ)" for q and σ (*‹⟦(?q::i) ∈ ℙ; (?σ::i) ∈ domain(θ::i)⟧ ⟹ (Q::i ⇒ i ⇒ o)(τ::i, ?σ)›*) with assms(1) (*‹(⋀σ. σ ∈ domain(?θ) ⟹ Q(?τ, σ)) ⟹ R(?τ, ?θ)›*) show "R(τ,θ)" using one_in_P (*‹𝟭 ∈ ℙ›*) by simp next (*goal: ‹⋀τ θ p. ⟦p ∈ ℙ; ⋀q σ. ⟦q ∈ ℙ; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ R(σ, τ) ∧ R(σ, θ)⟧ ⟹ Q(τ, θ)›*) fix τ and θ and p assume "q ∈ ℙ ⟹ σ ∈ domain(τ) ∪ domain(θ) ⟹ R(σ,τ) ∧ R(σ,θ)" for q and σ (*‹⟦(?q::i) ∈ ℙ; (?σ::i) ∈ domain(τ::i) ∪ domain(θ::i)⟧ ⟹ (R::i ⇒ i ⇒ o)(?σ, τ) ∧ R(?σ, θ)›*) with assms(2) (*‹(⋀σ. σ ∈ domain(?τ) ∪ domain(?θ) ⟹ R(σ, ?τ) ∧ R(σ, ?θ)) ⟹ Q(?τ, ?θ)›*) show "Q(τ,θ)" using one_in_P (*‹𝟭 ∈ ℙ›*) by simp qed subsection‹Lemma IV.2.40(a), in full› lemma IV240a: shows "(τ∈M ⟶ θ∈M ⟶ (∀p∈G. p forces⇩a (τ = θ) ⟶ val(G,τ) = val(G,θ))) ∧ (τ∈M ⟶ θ∈M ⟶ (∀p∈G. p forces⇩a (τ ∈ θ) ⟶ val(G,τ) ∈ val(G,θ)))" (is "?Q(τ,θ) ∧ ?R(τ,θ)") proof (intro forces_induction[of ?Q ?R] (*‹⟦⋀(τ::i) θ::i. (⋀σ::i. σ ∈ domain(θ) ⟹ τ ∈ (M::i) ⟶ σ ∈ M ⟶ (∀p::i∈G::i. p forces⇩a (τ = σ) ⟶ val(G, τ) = val(G, σ))) ⟹ τ ∈ M ⟶ θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (τ ∈ θ) ⟶ val(G, τ) ∈ val(G, θ)); ⋀(τ::i) θ::i. (⋀σ::i. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ (∀p::i∈G. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ)))) ⟹ τ ∈ M ⟶ θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (τ = θ) ⟶ val(G, τ) = val(G, θ))⟧ ⟹ ((?τ::i) ∈ M ⟶ (?θ::i) ∈ M ⟶ (∀p::i∈G. p forces⇩a (?τ = ?θ) ⟶ val(G, ?τ) = val(G, ?θ))) ∧ (?τ ∈ M ⟶ ?θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (?τ ∈ ?θ) ⟶ val(G, ?τ) ∈ val(G, ?θ)))›*) impI (*‹(?P::o ⟹ ?Q::o) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹⋀τ θ. ⟦⋀σ. σ ∈ domain(θ) ⟹ τ ∈ M ⟶ σ ∈ M ⟶ (∀p∈G. p forces⇩a (τ = σ) ⟶ val(G, τ) = val(G, σ)); τ ∈ M; θ ∈ M⟧ ⟹ ∀p∈G. p forces⇩a (τ ∈ θ) ⟶ val(G, τ) ∈ val(G, θ)› 2. ‹⋀τ θ. ⟦⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))); τ ∈ M; θ ∈ M⟧ ⟹ ∀p∈G. p forces⇩a (τ = θ) ⟶ val(G, τ) = val(G, θ)›*) fix τ and θ assume "τ∈M" "θ∈M" "σ∈domain(θ) ⟹ ?Q(τ,σ)" for σ (*‹(τ::i) ∈ (M::i)› ‹(θ::i) ∈ (M::i)› ‹(?σ::i) ∈ domain(θ::i) ⟹ (τ::i) ∈ (M::i) ⟶ ?σ ∈ M ⟶ (∀p::i∈G::i. p forces⇩a (τ = ?σ) ⟶ val(G, τ) = val(G, ?σ))›*) moreover from this (*‹(τ::i) ∈ (M::i)› ‹θ ∈ M› ‹?σ ∈ domain(θ) ⟹ τ ∈ M ⟶ ?σ ∈ M ⟶ (∀p∈G. p forces⇩a (τ = ?σ) ⟶ val(G, τ) = val(G, ?σ))›*) have "σ∈domain(θ) ⟹ q forces⇩a (τ = σ) ⟹ val(G, τ) = val(G, σ)" if "q∈ℙ" "q∈G" for q and σ using that (*‹q ∈ ℙ› ‹(q::i) ∈ (G::i)›*) domain_closed[of θ] (*‹(##M)(θ) ⟹ (##M)(domain(θ))›*) transitivity (*‹⟦?y ∈ ?x; ?x ∈ M⟧ ⟹ ?y ∈ M›*) by auto ultimately show "∀p∈G. p forces⇩a (τ ∈ θ) ⟶ val(G,τ) ∈ val(G,θ)" using IV240a_mem (*‹⟦(?p::i) ∈ (G::i); (?π::i) ∈ (M::i); (?τ::i) ∈ M; ?p forces⇩a (?π ∈ ?τ); ⋀(q::i) σ::i. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(?τ); q forces⇩a (?π = σ)⟧ ⟹ val(G, ?π) = val(G, σ)⟧ ⟹ val(G, ?π) ∈ val(G, ?τ)›*) domain_closed (*‹(##(M::i))(?r::i) ⟹ (##M)(domain(?r))›*) transitivity (*‹⟦?y ∈ ?x; ?x ∈ M⟧ ⟹ ?y ∈ M›*) by simp next (*goal: ‹⋀(τ::i) θ::i. ⟦⋀σ::i. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ (M::i) ⟶ τ ∈ M ⟶ (∀p::i∈G::i. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))); τ ∈ M; θ ∈ M⟧ ⟹ ∀p::i∈G. p forces⇩a (τ = θ) ⟶ val(G, τ) = val(G, θ)›*) fix τ and θ assume "τ∈M" "θ∈M" and d: "σ ∈ domain(τ) ∪ domain(θ) ⟹ ?R(σ,τ) ∧ ?R(σ,θ)" for σ (*‹(τ::i) ∈ (M::i)› ‹(θ::i) ∈ (M::i)› ‹(?σ::i) ∈ domain(τ::i) ∪ domain(θ::i) ⟹ (?σ ∈ (M::i) ⟶ τ ∈ M ⟶ (∀p::i∈G::i. p forces⇩a (?σ ∈ τ) ⟶ val(G, ?σ) ∈ val(G, τ))) ∧ (?σ ∈ M ⟶ θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (?σ ∈ θ) ⟶ val(G, ?σ) ∈ val(G, θ)))›*) moreover from this (*‹τ ∈ M› ‹θ ∈ M› ‹?σ ∈ domain(τ) ∪ domain(θ) ⟹ (?σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (?σ ∈ τ) ⟶ val(G, ?σ) ∈ val(G, τ))) ∧ (?σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (?σ ∈ θ) ⟶ val(G, ?σ) ∈ val(G, θ)))›*) have IH': "(q forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))" if "σ ∈ domain(τ) ∪ domain(θ)" "q∈G" for q and σ proof (-) (*goal: ‹⟦(τ::i) ∈ (M::i); (θ::i) ∈ M; ⋀σ::i. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ (∀p::i∈G::i. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p::i∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ)))⟧ ⟹ ((q::i) forces⇩a (σ::i ∈ τ) ⟶ val(G, σ) ∈ val(G, τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))›*) from d (*‹?σ ∈ domain(τ) ∪ domain(θ) ⟹ (?σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (?σ ∈ τ) ⟶ val(G, ?σ) ∈ val(G, τ))) ∧ (?σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (?σ ∈ θ) ⟶ val(G, ?σ) ∈ val(G, θ)))›*) that (*‹σ ∈ domain(τ) ∪ domain(θ)› ‹q ∈ G›*) have A: "?R(σ,τ)" "?R(σ,θ)" apply - (*goals: 1. ‹⟦⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))); σ ∈ domain(τ) ∪ domain(θ); q ∈ G⟧ ⟹ σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))› 2. ‹⟦⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))); σ ∈ domain(τ) ∪ domain(θ); q ∈ G⟧ ⟹ σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from ‹τ∈_› (*‹τ ∈ M›*) ‹θ∈M› (*‹θ ∈ M›*) ‹q∈G› (*‹q ∈ G›*) ‹σ∈_› (*‹σ ∈ domain(τ) ∪ domain(θ)›*) show "?thesis" (*goal: ‹(q forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ)) ∧ (q forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ))›*) using transitivity[of σ] (*‹⟦σ ∈ ?x; ?x ∈ M⟧ ⟹ σ ∈ M›*) domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) A[rule_format, of q] (*‹⟦σ ∈ M; τ ∈ M; q ∈ G; q forces⇩a (σ ∈ τ)⟧ ⟹ val(G, σ) ∈ val(G, τ)› ‹⟦σ ∈ M; θ ∈ M; q ∈ G; q forces⇩a (σ ∈ θ)⟧ ⟹ val(G, σ) ∈ val(G, θ)›*) by auto qed show "∀p∈G. p forces⇩a (τ = θ) ⟶ val(G,τ) = val(G,θ)" using IV240a_eq[OF _ _ IH'] (*‹⟦?p ∈ G; ?p forces⇩a (τ = θ); ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ σ ∈ domain(τ) ∪ domain(θ); ⋀q σ. ⟦q ∈ ℙ; q ∈ G; σ ∈ domain(τ) ∪ domain(θ)⟧ ⟹ q ∈ G⟧ ⟹ val(G, τ) = val(G, θ)›*) by simp qed subsection‹Lemma IV.2.40(b)› (* Lemma IV.2.40(b), membership *) lemma IV240b_mem: includes some_rules assumes "val(G,π)∈val(G,τ)" "π∈M" "τ∈M" and IH:"⋀σ. σ∈domain(τ) ⟹ val(G,π) = val(G,σ) ⟹ ∃p∈G. p forces⇩a (π = σ)" (* inductive hypothesis *) shows "∃p∈G. p forces⇩a (π ∈ τ)" proof (-) (*goal: ‹∃p∈G. p forces⇩a (π ∈ τ)›*) from ‹val(G,π)∈val(G,τ)› (*‹val(G, π) ∈ val(G, τ)›*) obtain σ and r where "r∈G" "⟨σ,r⟩∈τ" "val(G,π) = val(G,σ)" (*goal: ‹(⋀r σ. ⟦r ∈ G; ⟨σ, r⟩ ∈ τ; val(G, π) = val(G, σ)⟧ ⟹ thesis) ⟹ thesis›*) by auto moreover from this (*‹r ∈ G› ‹⟨σ::i, r::i⟩ ∈ (τ::i)› ‹val(G, π) = val(G, σ)›*) IH (*‹⟦?σ ∈ domain(τ); val(G, π) = val(G, ?σ)⟧ ⟹ ∃p∈G. p forces⇩a (π = ?σ)›*) obtain p' where "p'∈G" "p' forces⇩a (π = σ)" (*goal: ‹(⋀p'::i. ⟦p' ∈ (G::i); p' forces⇩a (π::i = σ::i)⟧ ⟹ thesis::o) ⟹ thesis›*) by blast ultimately obtain p where "p≼r" "p≼p'" "p∈G" "p forces⇩a (π = σ)" (*goal: ‹(⋀p. ⟦p ≼ r; p ≼ p'; p ∈ G; p forces⇩a (π = σ)⟧ ⟹ thesis) ⟹ thesis›*) using M_generic_compatD (*‹⟦?p ∈ G; ?r ∈ G⟧ ⟹ ∃q∈G. q ≼ ?p ∧ q ≼ ?r›*) strengthening_eq[of p'] (*‹⟦p' ∈ ℙ; ?r ∈ ℙ; ?r ≼ p'; p' forces⇩a (?t1.0 = ?t2.0)⟧ ⟹ ?r forces⇩a (?t1.0 = ?t2.0)›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) by auto moreover from calculation (*‹p ≼ r› ‹p ≼ p'› ‹p ∈ G› ‹p forces⇩a (π = σ)›*) have "q forces⇩a (π = σ)" if "q∈ℙ" "q≼p" for q using that (*‹q ∈ ℙ› ‹q ≼ p›*) strengthening_eq (*‹⟦?p ∈ ℙ; ?r ∈ ℙ; ?r ≼ ?p; ?p forces⇩a (?t1.0 = ?t2.0)⟧ ⟹ ?r forces⇩a (?t1.0 = ?t2.0)›*) by blast moreover note ‹⟨σ,r⟩∈τ› (*‹⟨σ, r⟩ ∈ τ›*) ‹r∈G› (*‹(r::i) ∈ (G::i)›*) ultimately have "r∈ℙ ∧ ⟨σ,r⟩ ∈ τ ∧ q≼r ∧ q forces⇩a (π = σ)" if "q∈ℙ" "q≼p" for q using that (*‹q ∈ ℙ› ‹q ≼ p›*) leq_transD[of _ p r] (*‹⟦?a ≼ p; p ≼ r; ?a ∈ ℙ; p ∈ ℙ; r ∈ ℙ⟧ ⟹ ?a ≼ r›*) by blast then have "dense_below({q∈ℙ. ∃s r. r∈ℙ ∧ ⟨s,r⟩ ∈ τ ∧ q≼r ∧ q forces⇩a (π = s)},p)" using refl_leq (*‹(?r::i) ∈ ℙ ⟹ ?r ≼ ?r›*) by blast moreover note ‹p∈G› (*‹p ∈ G›*) moreover from calculation (*‹dense_below({q::i ∈ ℙ . ∃(s::i) r::i. r ∈ ℙ ∧ ⟨s, r⟩ ∈ (τ::i) ∧ q ≼ r ∧ q forces⇩a (π::i = s)}, p::i)› ‹p ∈ G›*) have "p forces⇩a (π ∈ τ)" using forces_mem_iff_dense_below (*‹(?p::i) ∈ ℙ ⟹ ?p forces⇩a (?t1.0::i ∈ ?t2.0::i) ⟷ dense_below({q::i ∈ ℙ . ∃(s::i) r::i. r ∈ ℙ ∧ ⟨s, r⟩ ∈ ?t2.0 ∧ q ≼ r ∧ q forces⇩a (?t1.0 = s)}, ?p)›*) by blast ultimately show "?thesis" (*goal: ‹∃p::i∈G::i. p forces⇩a (π::i ∈ τ::i)›*) by blast qed end ― ‹\<^locale>‹G_generic1›› context forcing_data1 begin lemma Collect_forces_eq_in_M: assumes "τ ∈ M" "θ ∈ M" shows "{p∈ℙ. p forces⇩a (τ = θ)} ∈ M" using assms (*‹τ ∈ M› ‹θ ∈ M›*) Collect_in_M[of "forces_eq_fm(1,2,0,3,4)" "[ℙ,leq,τ,θ]"] (*‹⟦forces_eq_fm(1, 2, 0, 3, 4) ∈ formula; [ℙ, leq, τ, θ] ∈ list(M); arity(forces_eq_fm(1, 2, 0, 3, 4)) ≤ 1 +⇩ω length([ℙ, leq, τ, θ]); ?A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, τ, θ] ⊨ forces_eq_fm(1, 2, 0, 3, 4)) ⟷ ?Q(x)⟧ ⟹ {y ∈ ?A . ?Q(y)} ∈ M›*) arity_forces_eq_fm (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω⟧ ⟹ arity(forces_eq_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) = succ(?t2.0) ∪ (succ(?p) ∪ (succ(?t1.0) ∪ (succ(?P) ∪ succ(?l))))›*) sats_forces_eq_fm (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω; ?env ∈ list(?A)⟧ ⟹ (?A, ?env ⊨ forces_eq_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) ⟷ is_forces_eq'(##?A, nth(?P, ?env), nth(?l, ?env), nth(?p, ?env), nth(?t1.0, ?env), nth(?t2.0, ?env))›*) forces_eq_abs (*‹⟦?p ∈ M; ?t1.0 ∈ M; ?t2.0 ∈ M⟧ ⟹ is_forces_eq(?p, ?t1.0, ?t2.0) ⟷ ?p forces⇩a (?t1.0 = ?t2.0)›*) forces_eq_fm_type (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω⟧ ⟹ forces_eq_fm(?P, ?l, ?p, ?t1.0, ?t2.0) ∈ formula›*) by (simp add: union_abs1 (*‹(?i::i) ≤ (?j::i) ⟹ ?i ∪ ?j = ?j›*) Un_commute (*‹(?A::i) ∪ (?B::i) = ?B ∪ ?A›*)) lemma IV240b_eq_Collects: assumes "τ ∈ M" "θ ∈ M" shows "{p∈ℙ. ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)}∈M" and "{p∈ℙ. ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)}∈M" proof (-) (*goals: 1. ‹{p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M› 2. ‹{p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ∈ M›*) let ?rel_pred = "λM x a1 a2 a3 a4. ∃σ[M]. ∃u[M]. ∃da3[M]. ∃da4[M]. is_domain(M,a3,da3) ∧ is_domain(M,a4,da4) ∧ union(M,da3,da4,u) ∧ σ∈u ∧ is_forces_mem'(M,a1,a2,x,σ,a3) ∧ is_forces_nmem'(M,a1,a2,x,σ,a4)" let ?φ = "Exists(Exists(Exists(Exists(And(domain_fm(7,1),And(domain_fm(8,0), And(union_fm(1,0,2),And(Member(3,2),And(forces_mem_fm(5,6,4,3,7), forces_nmem_fm(5,6,4,3,8))))))))))" have 1: "σ∈M" if "⟨σ,y⟩∈δ" "δ∈M" for σ and δ and y using that (*‹⟨σ::i, y::i⟩ ∈ (δ::i)› ‹(δ::i) ∈ (M::i)›*) pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) transitivity[of "⟨σ,y⟩" δ] (*‹⟦⟨σ, y⟩ ∈ δ; δ ∈ M⟧ ⟹ ⟨σ, y⟩ ∈ M›*) by simp have abs1: "?rel_pred(##M,p,ℙ,leq,τ,θ) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ,leq,p,σ,τ) ∧ forces_nmem'(ℙ,leq,p,σ,θ))" if "p∈M" for p unfolding forces_mem_def forces_nmem_def (*goal: ‹(∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, θ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ, leq, p, σ, τ) ∧ forces_nmem'(ℙ, leq, p, σ, θ))›*) using assms (*‹(τ::i) ∈ (M::i)› ‹θ ∈ M›*) that (*‹p ∈ M›*) forces_mem'_abs (*‹⟦?p ∈ M; ?t1.0 ∈ M; ?t2.0 ∈ M⟧ ⟹ is_forces_mem(?p, ?t1.0, ?t2.0) ⟷ forces_mem'(ℙ, leq, ?p, ?t1.0, ?t2.0)›*) forces_nmem'_abs (*‹⟦?p ∈ M; ?t1.0 ∈ M; ?t2.0 ∈ M⟧ ⟹ is_forces_nmem'(##M, ℙ, leq, ?p, ?t1.0, ?t2.0) ⟷ forces_nmem'(ℙ, leq, ?p, ?t1.0, ?t2.0)›*) domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) by (auto simp add:1[of _ _ τ] (*‹⟦⟨?σ, ?y⟩ ∈ τ; τ ∈ M⟧ ⟹ ?σ ∈ M›*) 1[of _ _ θ] (*‹⟦⟨?σ, ?y⟩ ∈ θ; θ ∈ M⟧ ⟹ ?σ ∈ M›*)) have abs2: "?rel_pred(##M,p,ℙ,leq,θ,τ) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_nmem'(ℙ,leq,p,σ,τ) ∧ forces_mem'(ℙ,leq,p,σ,θ))" if "p∈M" for p unfolding forces_mem_def forces_nmem_def (*goal: ‹(∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, θ, da3) ∧ is_domain(##M, τ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, τ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_nmem'(ℙ, leq, p, σ, τ) ∧ forces_mem'(ℙ, leq, p, σ, θ))›*) using assms (*‹τ ∈ M› ‹θ ∈ M›*) that (*‹(p::i) ∈ (M::i)›*) forces_mem'_abs (*‹⟦(?p::i) ∈ (M::i); (?t1.0::i) ∈ M; (?t2.0::i) ∈ M⟧ ⟹ is_forces_mem(?p, ?t1.0, ?t2.0) ⟷ forces_mem'(ℙ, leq::i, ?p, ?t1.0, ?t2.0)›*) forces_nmem'_abs (*‹⟦?p ∈ M; ?t1.0 ∈ M; ?t2.0 ∈ M⟧ ⟹ is_forces_nmem'(##M, ℙ, leq, ?p, ?t1.0, ?t2.0) ⟷ forces_nmem'(ℙ, leq, ?p, ?t1.0, ?t2.0)›*) domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) by (auto simp add:1[of _ _ τ] (*‹⟦⟨?σ, ?y⟩ ∈ τ; τ ∈ M⟧ ⟹ ?σ ∈ M›*) 1[of _ _ θ] (*‹⟦⟨?σ, ?y⟩ ∈ θ; θ ∈ M⟧ ⟹ ?σ ∈ M›*)) have fsats1: "(M,[p,ℙ,leq,τ,θ] ⊨ ?φ) ⟷ ?rel_pred(##M,p,ℙ,leq,τ,θ)" if "p∈M" for p using that (*‹p ∈ M›*) assms (*‹τ ∈ M› ‹θ ∈ M›*) sats_forces_mem_fm (*‹⟦(?P::i) ∈ ω; (?l::i) ∈ ω; (?p::i) ∈ ω; (?t1.0::i) ∈ ω; (?t2.0::i) ∈ ω; (?env::i) ∈ list(?A::i)⟧ ⟹ (?A, ?env ⊨ forces_mem_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) ⟷ is_forces_mem'(##?A, nth(?P, ?env), nth(?l, ?env), nth(?p, ?env), nth(?t1.0, ?env), nth(?t2.0, ?env))›*) sats_forces_nmem_fm (*‹⟦(?P::i) ∈ ω; (?l::i) ∈ ω; (?p::i) ∈ ω; (?t1.0::i) ∈ ω; (?t2.0::i) ∈ ω; (?env::i) ∈ list(?A::i); 0 ∈ ?A⟧ ⟹ (?A, ?env ⊨ forces_nmem_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) ⟷ is_forces_nmem'(##?A, nth(?P, ?env), nth(?l, ?env), nth(?p, ?env), nth(?t1.0, ?env), nth(?t2.0, ?env))›*) zero_in_M (*‹0 ∈ M›*) domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) by simp have fsats2: "(M,[p,ℙ,leq,θ,τ] ⊨ ?φ) ⟷ ?rel_pred(##M,p,ℙ,leq,θ,τ)" if "p∈M" for p using that (*‹p ∈ M›*) assms (*‹τ ∈ M› ‹(θ::i) ∈ (M::i)›*) sats_forces_mem_fm (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω; ?env ∈ list(?A)⟧ ⟹ (?A, ?env ⊨ forces_mem_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) ⟷ is_forces_mem'(##?A, nth(?P, ?env), nth(?l, ?env), nth(?p, ?env), nth(?t1.0, ?env), nth(?t2.0, ?env))›*) sats_forces_nmem_fm (*‹⟦?P ∈ ω; ?l ∈ ω; ?p ∈ ω; ?t1.0 ∈ ω; ?t2.0 ∈ ω; ?env ∈ list(?A); 0 ∈ ?A⟧ ⟹ (?A, ?env ⊨ forces_nmem_fm(?P, ?l, ?p, ?t1.0, ?t2.0)) ⟷ is_forces_nmem'(##?A, nth(?P, ?env), nth(?l, ?env), nth(?p, ?env), nth(?t1.0, ?env), nth(?t2.0, ?env))›*) zero_in_M (*‹0 ∈ M›*) domain_closed (*‹(##(M::i))(?r::i) ⟹ (##M)(domain(?r))›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) by simp have fty: "?φ∈formula" by simp have farit: "arity(?φ)=5" by (simp add:ord_simp_union (*‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x::i, ?y::i) ≡ if ?x ≤ ?y then ?y else ?x›*) arity (*‹⟦(?φ::i) ∈ formula; (?t::i) ∈ ω; (?f::i) ∈ ω; (?r::i) ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p::i ∧ ?q::i⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p::i ∨ ?q::i⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p::i → ?q::i⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p::i ↔ ?q::i⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p::i⋅)) = pred(arity(?p))› ‹⟦(?t1.0::i) ∈ ω; (?t2.0::i) ∈ ω; (?up::i) ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦(?x::i) ∈ ω; (?y::i) ∈ ω; (?z::i) ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦(?r::i) ∈ ω; (?s::i) ∈ ω; (?t::i) ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦(?r::i) ∈ ω; (?z::i) ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦(?r::i) ∈ ω; (?z::i) ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦(?x::i) ∈ ω; (?y::i) ∈ ω; (?z::i) ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 191 facts*)) show "{p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M" and "{p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ∈ M" unfolding forces_mem_def (*goals: 1. ‹{p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ, leq, p, σ, τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M› 2. ‹{p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ forces_mem'(ℙ, leq, p, σ, θ)} ∈ M›*) using abs1 (*‹?p ∈ M ⟹ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(?p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, ?p, σ, θ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ, leq, ?p, σ, τ) ∧ forces_nmem'(ℙ, leq, ?p, σ, θ))›*) fty (*‹(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula›*) fsats1 (*‹?p ∈ M ⟹ (M, [?p, ℙ, leq, τ, θ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(?p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, ?p, σ, θ))›*) farit (*‹arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) = 5›*) assms (*‹τ ∈ M› ‹(θ::i) ∈ (M::i)›*) forces_nmem (*‹?p forces⇩a (?t1.0 ∉ ?t2.0) ⟷ forces_nmem'(ℙ, leq, ?p, ?t1.0, ?t2.0)›*) Collect_in_M[of ?φ "[ℙ,leq,τ,θ]"] (*‹⟦(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; [ℙ, leq, τ, θ] ∈ list(M); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, τ, θ]); ?A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, τ, θ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ ?Q(x)⟧ ⟹ {y ∈ ?A . ?Q(y)} ∈ M›*) using abs2 (*‹(?p::i) ∈ (M::i) ⟹ (∃σ::i[##M]. ∃u::i[##M]. ∃da3::i[##M]. ∃da4::i[##M]. is_domain(##M, θ::i, da3) ∧ is_domain(##M, τ::i, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(?p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq::i, ?p, σ, τ)) ⟷ (∃σ::i∈domain(τ) ∪ domain(θ). forces_nmem'(ℙ, leq, ?p, σ, τ) ∧ forces_mem'(ℙ, leq, ?p, σ, θ))›*) fty (*‹(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula›*) fsats2 (*‹?p ∈ M ⟹ (M, [?p, ℙ, leq, θ, τ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, θ, da3) ∧ is_domain(##M, τ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(?p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq, ?p, σ, τ))›*) farit (*‹arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) = 5›*) assms (*‹τ ∈ M› ‹θ ∈ M›*) forces_nmem (*‹?p forces⇩a (?t1.0 ∉ ?t2.0) ⟷ forces_nmem'(ℙ, leq, ?p, ?t1.0, ?t2.0)›*) domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) Collect_in_M[of ?φ "[ℙ,leq,θ,τ]"] (*‹⟦(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; [ℙ, leq, θ, τ] ∈ list(M); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, θ, τ]); ?A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, θ, τ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ ?Q(x)⟧ ⟹ {y ∈ ?A . ?Q(y)} ∈ M›*) apply - (*goals: 1. ‹⟦⋀p. p ∈ M ⟹ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, θ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ, leq, p, σ, τ) ∧ forces_nmem'(ℙ, leq, p, σ, θ)); (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; ⋀p. p ∈ M ⟹ (M, [p, ℙ, leq, τ, θ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, θ)); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) = 5; τ ∈ M; θ ∈ M; ⋀p t1 t2. p forces⇩a (t1 ∉ t2) ⟷ forces_nmem'(ℙ, leq, p, t1, t2); ⋀A Q. ⟦(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; [ℙ, leq, τ, θ] ∈ list(M); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, τ, θ]); A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, τ, θ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ Q(x)⟧ ⟹ {y ∈ A . Q(y)} ∈ M; ⋀p. p ∈ M ⟹ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, θ, da3) ∧ is_domain(##M, τ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, τ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_nmem'(ℙ, leq, p, σ, τ) ∧ forces_mem'(ℙ, leq, p, σ, θ)); (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; ⋀p. p ∈ M ⟹ (M, [p, ℙ, leq, θ, τ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, θ, da3) ∧ is_domain(##M, τ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, τ)); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) = 5; τ ∈ M; θ ∈ M; ⋀p t1 t2. p forces⇩a (t1 ∉ t2) ⟷ forces_nmem'(ℙ, leq, p, t1, t2); ⋀r. (##M)(r) ⟹ (##M)(domain(r)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ (##M)(A ∪ B); ⋀A Q. ⟦(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; [ℙ, leq, θ, τ] ∈ list(M); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, θ, τ]); A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, θ, τ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ Q(x)⟧ ⟹ {y ∈ A . Q(y)} ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ, leq, p, σ, τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M› 2. ‹⟦⋀p. p ∈ M ⟹ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, θ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_mem'(ℙ, leq, p, σ, τ) ∧ forces_nmem'(ℙ, leq, p, σ, θ)); (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; ⋀p. p ∈ M ⟹ (M, [p, ℙ, leq, τ, θ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, τ, da3) ∧ is_domain(##M, θ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, τ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, θ)); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) = 5; τ ∈ M; θ ∈ M; ⋀p t1 t2. p forces⇩a (t1 ∉ t2) ⟷ forces_nmem'(ℙ, leq, p, t1, t2); ⋀A Q. ⟦(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; [ℙ, leq, τ, θ] ∈ list(M); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, τ, θ]); A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, τ, θ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ Q(x)⟧ ⟹ {y ∈ A . Q(y)} ∈ M; ⋀p. p ∈ M ⟹ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, θ, da3) ∧ is_domain(##M, τ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, τ)) ⟷ (∃σ∈domain(τ) ∪ domain(θ). forces_nmem'(ℙ, leq, p, σ, τ) ∧ forces_mem'(ℙ, leq, p, σ, θ)); (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; ⋀p. p ∈ M ⟹ (M, [p, ℙ, leq, θ, τ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ (∃σ[##M]. ∃u[##M]. ∃da3[##M]. ∃da4[##M]. is_domain(##M, θ, da3) ∧ is_domain(##M, τ, da4) ∧ union(##M, da3, da4, u) ∧ σ ∈ u ∧ is_forces_mem(p, σ, θ) ∧ is_forces_nmem'(##M, ℙ, leq, p, σ, τ)); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) = 5; τ ∈ M; θ ∈ M; ⋀p t1 t2. p forces⇩a (t1 ∉ t2) ⟷ forces_nmem'(ℙ, leq, p, t1, t2); ⋀r. (##M)(r) ⟹ (##M)(domain(r)); ⋀A B. ⟦(##M)(A); (##M)(B)⟧ ⟹ (##M)(A ∪ B); ⋀A Q. ⟦(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅) ∈ formula; [ℙ, leq, θ, τ] ∈ list(M); arity((⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, θ, τ]); A ∈ M; ⋀x. x ∈ M ⟹ (M, [x] @ [ℙ, leq, θ, τ] ⊨ (⋅∃(⋅∃(⋅∃(⋅∃⋅⋅dom(7) is 1 ⋅ ∧ ⋅⋅dom(8) is 0 ⋅ ∧ ⋅⋅1 ∪ 0 is 2 ⋅ ∧ ⋅⋅3 ∈ 2⋅ ∧ ⋅forces_mem_fm(5, 6, 4, 3, 7) ∧ forces_nmem_fm(5, 6, 4, 3, 8)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)) ⟷ Q(x)⟧ ⟹ {y ∈ A . Q(y)} ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ forces_mem'(ℙ, leq, p, σ, θ)} ∈ M› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed end ― ‹\<^locale>‹forcing_data1›› context G_generic1 begin (* Lemma IV.2.40(b), equality *) lemma IV240b_eq: includes some_rules assumes "val(G,τ) = val(G,θ)" "τ∈M" "θ∈M" and IH:"⋀σ. σ∈domain(τ)∪domain(θ) ⟹ (val(G,σ)∈val(G,τ) ⟶ (∃q∈G. q forces⇩a (σ ∈ τ))) ∧ (val(G,σ)∈val(G,θ) ⟶ (∃q∈G. q forces⇩a (σ ∈ θ)))" (* inductive hypothesis *) shows "∃p∈G. p forces⇩a (τ = θ)" proof (-) (*goal: ‹∃p∈G. p forces⇩a (τ = θ)›*) let ?D1 = "{p∈ℙ. p forces⇩a (τ = θ)}" let ?D2 = "{p∈ℙ. ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)}" let ?D3 = "{p∈ℙ. ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)}" let ?D = "?D1 ∪ ?D2 ∪ ?D3" note assms (*‹val(G, τ) = val(G, θ)› ‹(τ::i) ∈ (M::i)› ‹θ ∈ M› ‹?σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, ?σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ τ))) ∧ (val(G, ?σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ θ)))›*) moreover from this (*‹val(G, τ) = val(G, θ)› ‹τ ∈ M› ‹θ ∈ M› ‹?σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, ?σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ τ))) ∧ (val(G, ?σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ θ)))›*) have "domain(τ) ∪ domain(θ)∈M" (is "?B∈M") using domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) by auto moreover from calculation (*‹val(G, τ) = val(G, θ)› ‹(τ::i) ∈ (M::i)› ‹θ ∈ M› ‹?σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, ?σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ τ))) ∧ (val(G, ?σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ θ)))› ‹domain(τ) ∪ domain(θ) ∈ M›*) have "?D2∈M" and "?D3∈M" using IV240b_eq_Collects (*‹⟦?τ ∈ M; ?θ ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(?τ) ∪ domain(?θ). p forces⇩a (σ ∈ ?τ) ∧ p forces⇩a (σ ∉ ?θ)} ∈ M› ‹⟦?τ ∈ M; ?θ ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(?τ) ∪ domain(?θ). p forces⇩a (σ ∉ ?τ) ∧ p forces⇩a (σ ∈ ?θ)} ∈ M›*) apply - (*goals: 1. ‹⟦val(G, τ) = val(G, θ); τ ∈ M; θ ∈ M; ⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (σ ∈ τ))) ∧ (val(G, σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (σ ∈ θ))); domain(τ) ∪ domain(θ) ∈ M; ⋀τ θ. ⟦τ ∈ M; θ ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M; ⋀τ θ. ⟦τ ∈ M; θ ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M› 2. ‹⟦val(G, τ) = val(G, θ); τ ∈ M; θ ∈ M; ⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (σ ∈ τ))) ∧ (val(G, σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (σ ∈ θ))); domain(τ) ∪ domain(θ) ∈ M; ⋀τ θ. ⟦τ ∈ M; θ ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∈ M; ⋀τ θ. ⟦τ ∈ M; θ ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ∈ M⟧ ⟹ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ∈ M› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . ultimately have "?D∈M" using Collect_forces_eq_in_M (*‹⟦?τ ∈ M; ?θ ∈ M⟧ ⟹ {p ∈ ℙ . p forces⇩a (?τ = ?θ)} ∈ M›*) Un_closed (*‹⟦(##M)(?A); (##M)(?B)⟧ ⟹ (##M)(?A ∪ ?B)›*) by auto moreover have "dense(?D)" proof (standard) (*goal: ‹⋀p::i. p ∈ ℙ ⟹ ∃d::i∈{p::i ∈ ℙ . p forces⇩a (τ::i = θ::i)} ∪ {p::i ∈ ℙ . ∃σ::i∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∪ {p::i ∈ ℙ . ∃σ::i∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)}. d ≼ p›*) fix p assume "p∈ℙ" (*‹(p::i) ∈ ℙ›*) have "∃d∈ℙ. (d forces⇩a (τ = θ) ∨ (∃σ∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∈ τ) ∧ d forces⇩a (σ ∉ θ)) ∨ (∃σ∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∉ τ) ∧ d forces⇩a (σ ∈ θ))) ∧ d ≼ p" proof (cases "p forces⇩a (τ = θ)") (*goals: 1. ‹(p::i) forces⇩a (τ::i = θ::i) ⟹ ∃d::i∈ℙ. (d forces⇩a (τ = θ) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∈ τ) ∧ d forces⇩a (σ ∉ θ)) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∉ τ) ∧ d forces⇩a (σ ∈ θ))) ∧ d ≼ p› 2. ‹¬ (p::i) forces⇩a (τ::i = θ::i) ⟹ ∃d::i∈ℙ. (d forces⇩a (τ = θ) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∈ τ) ∧ d forces⇩a (σ ∉ θ)) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∉ τ) ∧ d forces⇩a (σ ∈ θ))) ∧ d ≼ p›*) case True (*‹(p::i) forces⇩a (τ::i = θ::i)›*) with ‹p∈ℙ› (*‹p ∈ ℙ›*) show "?thesis" (*goal: ‹∃d::i∈ℙ. (d forces⇩a (τ::i = θ::i) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∈ τ) ∧ d forces⇩a (σ ∉ θ)) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∉ τ) ∧ d forces⇩a (σ ∈ θ))) ∧ d ≼ (p::i)›*) using refl_leq (*‹(?r::i) ∈ ℙ ⟹ ?r ≼ ?r›*) by blast next (*goal: ‹¬ p forces⇩a (τ = θ) ⟹ ∃d∈ℙ. (d forces⇩a (τ = θ) ∨ (∃σ∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∈ τ) ∧ d forces⇩a (σ ∉ θ)) ∨ (∃σ∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∉ τ) ∧ d forces⇩a (σ ∈ θ))) ∧ d ≼ p›*) case False (*‹¬ (p::i) forces⇩a (τ::i = θ::i)›*) moreover note ‹p∈ℙ› (*‹(p::i) ∈ ℙ›*) moreover from calculation (*‹¬ p forces⇩a (τ = θ)› ‹p ∈ ℙ›*) obtain σ and q where "σ∈domain(τ)∪domain(θ)" "q∈ℙ" "q≼p" "(q forces⇩a (σ ∈ τ) ∧ ¬ q forces⇩a (σ ∈ θ)) ∨ (¬ q forces⇩a (σ ∈ τ) ∧ q forces⇩a (σ ∈ θ))" (*goal: ‹(⋀σ q. ⟦σ ∈ domain(τ) ∪ domain(θ); q ∈ ℙ; q ≼ p; q forces⇩a (σ ∈ τ) ∧ ¬ q forces⇩a (σ ∈ θ) ∨ ¬ q forces⇩a (σ ∈ τ) ∧ q forces⇩a (σ ∈ θ)⟧ ⟹ thesis) ⟹ thesis›*) using def_forces_eq (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 = ?t2.0) ⟷ (∀s∈domain(?t1.0) ∪ domain(?t2.0). ∀q. q ∈ ℙ ∧ q ≼ ?p ⟶ q forces⇩a (s ∈ ?t1.0) ⟷ q forces⇩a (s ∈ ?t2.0))›*) by blast moreover from this (*‹σ ∈ domain(τ) ∪ domain(θ)› ‹q ∈ ℙ› ‹q ≼ p› ‹q forces⇩a (σ ∈ τ) ∧ ¬ q forces⇩a (σ ∈ θ) ∨ ¬ q forces⇩a (σ ∈ τ) ∧ q forces⇩a (σ ∈ θ)›*) obtain r where "r≼q" "r∈ℙ" "(r forces⇩a (σ ∈ τ) ∧ r forces⇩a (σ ∉ θ)) ∨ (r forces⇩a (σ ∉ τ) ∧ r forces⇩a (σ ∈ θ))" (*goal: ‹(⋀r::i. ⟦r ≼ (q::i); r ∈ ℙ; r forces⇩a (σ::i ∈ τ::i) ∧ r forces⇩a (σ ∉ θ::i) ∨ r forces⇩a (σ ∉ τ) ∧ r forces⇩a (σ ∈ θ)⟧ ⟹ thesis::o) ⟹ thesis›*) using not_forces_nmem (*‹?p ∈ ℙ ⟹ ?p forces⇩a (?t1.0 ∈ ?t2.0) ⟷ ¬ (∃q∈ℙ. q ≼ ?p ∧ q forces⇩a (?t1.0 ∉ ?t2.0))›*) strengthening_mem (*‹⟦?p ∈ ℙ; ?r ∈ ℙ; ?r ≼ ?p; ?p forces⇩a (?t1.0 ∈ ?t2.0)⟧ ⟹ ?r forces⇩a (?t1.0 ∈ ?t2.0)›*) by blast ultimately show "?thesis" (*goal: ‹∃d::i∈ℙ. (d forces⇩a (τ::i = θ::i) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∈ τ) ∧ d forces⇩a (σ ∉ θ)) ∨ (∃σ::i∈domain(τ) ∪ domain(θ). d forces⇩a (σ ∉ τ) ∧ d forces⇩a (σ ∈ θ))) ∧ d ≼ (p::i)›*) using leq_transD (*‹⟦?a ≼ ?b; ?b ≼ ?c; ?a ∈ ℙ; ?b ∈ ℙ; ?c ∈ ℙ⟧ ⟹ ?a ≼ ?c›*) by blast qed then show "∃d∈?D . d ≼ p" by blast qed moreover have "?D ⊆ ℙ" by auto ultimately obtain p where "p∈G" "p∈?D" (*goal: ‹(⋀p. ⟦p ∈ G; p ∈ {p ∈ ℙ . p forces⇩a (τ = θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)}⟧ ⟹ thesis) ⟹ thesis›*) using M_generic_denseD[of ?D] (*‹⟦dense({p ∈ ℙ . p forces⇩a (τ = θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)}); {p ∈ ℙ . p forces⇩a (τ = θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ⊆ ℙ; {p ∈ ℙ . p forces⇩a (τ = θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)} ∈ M⟧ ⟹ ∃q∈G. q ∈ {p ∈ ℙ . p forces⇩a (τ = θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)} ∪ {p ∈ ℙ . ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)}›*) by blast then consider (1)"p forces⇩a (τ = θ)" | (2)"∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)" | (3)"∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)" (*goal: ‹⟦p forces⇩a (τ = θ) ⟹ thesis; ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ) ⟹ thesis; ∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ) ⟹ thesis⟧ ⟹ thesis›*) by blast then show "?thesis" (*goal: ‹∃p∈G. p forces⇩a (τ = θ)›*) proof (cases) (*goals: 1. ‹p forces⇩a (τ = θ) ⟹ ∃p∈G. p forces⇩a (τ = θ)› 2. ‹∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ) ⟹ ∃p∈G. p forces⇩a (τ = θ)› 3. ‹∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ) ⟹ ∃p∈G. p forces⇩a (τ = θ)›*) case 1 (*‹p forces⇩a (τ = θ)›*) with ‹p∈G› (*‹(p::i) ∈ (G::i)›*) show "?thesis" (*goal: ‹∃p::i∈G::i. p forces⇩a (τ::i = θ::i)›*) by blast next (*goals: 1. ‹∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ) ⟹ ∃p∈G. p forces⇩a (τ = θ)› 2. ‹∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ) ⟹ ∃p∈G. p forces⇩a (τ = θ)›*) case 2 (*‹∃σ::i∈domain(τ::i) ∪ domain(θ::i). (p::i) forces⇩a (σ ∈ τ) ∧ p forces⇩a (σ ∉ θ)›*) then obtain σ where "σ∈domain(τ) ∪ domain(θ)" "p forces⇩a (σ ∈ τ)" "p forces⇩a (σ ∉ θ)" (*goal: ‹(⋀σ. ⟦σ ∈ domain(τ) ∪ domain(θ); p forces⇩a (σ ∈ τ); p forces⇩a (σ ∉ θ)⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover from this (*‹(σ::i) ∈ domain(τ::i) ∪ domain(θ::i)› ‹p forces⇩a (σ ∈ τ)› ‹p forces⇩a (σ ∉ θ)›*) ‹p∈G› (*‹p ∈ G›*) assms (*‹val(G, τ) = val(G, θ)› ‹τ ∈ M› ‹θ ∈ M› ‹?σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, ?σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ τ))) ∧ (val(G, ?σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (?σ ∈ θ)))›*) have "val(G,σ)∈val(G,τ)" using IV240a[of σ τ] (*‹(σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (σ = τ) ⟶ val(G, σ) = val(G, τ))) ∧ (σ ∈ M ⟶ τ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ τ) ⟶ val(G, σ) ∈ val(G, τ)))›*) transitivity[OF _ domain_closed [ simplified ]] (*‹⟦?y ∈ domain(?r1); ?r1 ∈ M⟧ ⟹ ?y ∈ M›*) by force moreover note ‹val(G,τ) = _› (*‹val(G, τ) = val(G, θ)›*) ultimately obtain q where "q∈G" "q forces⇩a (σ ∈ θ)" (*goal: ‹(⋀q::i. ⟦q ∈ (G::i); q forces⇩a (σ::i ∈ θ::i)⟧ ⟹ thesis::o) ⟹ thesis›*) using IH[OF ‹σ∈_›] (*‹(val(G::i, σ::i) ∈ val(G, τ::i) ⟶ (∃q::i∈G. q forces⇩a (σ ∈ τ))) ∧ (val(G, σ) ∈ val(G, θ::i) ⟶ (∃q::i∈G. q forces⇩a (σ ∈ θ)))›*) by auto moreover from this (*‹(q::i) ∈ (G::i)› ‹(q::i) forces⇩a (σ::i ∈ θ::i)›*) ‹p∈G› (*‹p ∈ G›*) obtain r where "r∈ℙ" "r≼p" "r≼q" (*goal: ‹(⋀r. ⟦r ∈ ℙ; r ≼ p; r ≼ q⟧ ⟹ thesis) ⟹ thesis›*) by blast ultimately have "r forces⇩a (σ ∈ θ)" using strengthening_mem (*‹⟦?p ∈ ℙ; ?r ∈ ℙ; ?r ≼ ?p; ?p forces⇩a (?t1.0 ∈ ?t2.0)⟧ ⟹ ?r forces⇩a (?t1.0 ∈ ?t2.0)›*) by blast with ‹r≼p› (*‹r ≼ p›*) ‹p forces⇩a (σ ∉ θ)› (*‹p forces⇩a (σ ∉ θ)›*) ‹r∈ℙ› (*‹r ∈ ℙ›*) have False unfolding forces_nmem_def (*goal: ‹False›*) by blast then show "?thesis" (*goal: ‹∃p::i∈G::i. p forces⇩a (τ::i = θ::i)›*) by simp next (*goal: ‹∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ) ⟹ ∃p∈G. p forces⇩a (τ = θ)›*) case 3 (*‹∃σ∈domain(τ) ∪ domain(θ). p forces⇩a (σ ∉ τ) ∧ p forces⇩a (σ ∈ θ)›*) then obtain σ where "σ∈domain(τ) ∪ domain(θ)" "p forces⇩a (σ ∈ θ)" "p forces⇩a (σ ∉ τ)" (*goal: ‹(⋀σ. ⟦σ ∈ domain(τ) ∪ domain(θ); p forces⇩a (σ ∈ θ); p forces⇩a (σ ∉ τ)⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover from this (*‹σ ∈ domain(τ) ∪ domain(θ)› ‹p forces⇩a (σ ∈ θ)› ‹p forces⇩a (σ ∉ τ)›*) ‹p∈G› (*‹p ∈ G›*) assms (*‹val(G::i, τ::i) = val(G, θ::i)› ‹τ ∈ M› ‹θ ∈ M› ‹(?σ::i) ∈ domain(τ::i) ∪ domain(θ::i) ⟹ (val(G::i, ?σ) ∈ val(G, τ) ⟶ (∃q::i∈G. q forces⇩a (?σ ∈ τ))) ∧ (val(G, ?σ) ∈ val(G, θ) ⟶ (∃q::i∈G. q forces⇩a (?σ ∈ θ)))›*) have "val(G,σ)∈val(G,θ)" using IV240a[of σ θ] (*‹(σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (σ = θ) ⟶ val(G, σ) = val(G, θ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ (∀p∈G. p forces⇩a (σ ∈ θ) ⟶ val(G, σ) ∈ val(G, θ)))›*) transitivity[OF _ domain_closed [ simplified ]] (*‹⟦?y ∈ domain(?r1); ?r1 ∈ M⟧ ⟹ ?y ∈ M›*) by force moreover note ‹val(G,τ) = _› (*‹val(G, τ) = val(G, θ)›*) ultimately obtain q where "q∈G" "q forces⇩a (σ ∈ τ)" (*goal: ‹(⋀q. ⟦q ∈ G; q forces⇩a (σ ∈ τ)⟧ ⟹ thesis) ⟹ thesis›*) using IH[OF ‹σ∈_›] (*‹(val(G, σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (σ ∈ τ))) ∧ (val(G, σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (σ ∈ θ)))›*) by auto moreover from this (*‹q ∈ G› ‹q forces⇩a (σ ∈ τ)›*) ‹p∈G› (*‹p ∈ G›*) obtain r where "r∈ℙ" "r≼p" "r≼q" (*goal: ‹(⋀r. ⟦r ∈ ℙ; r ≼ p; r ≼ q⟧ ⟹ thesis) ⟹ thesis›*) by blast ultimately have "r forces⇩a (σ ∈ τ)" using strengthening_mem (*‹⟦?p ∈ ℙ; ?r ∈ ℙ; ?r ≼ ?p; ?p forces⇩a (?t1.0 ∈ ?t2.0)⟧ ⟹ ?r forces⇩a (?t1.0 ∈ ?t2.0)›*) by blast with ‹r≼p› (*‹r ≼ p›*) ‹p forces⇩a (σ ∉ τ)› (*‹p forces⇩a (σ ∉ τ)›*) ‹r∈ℙ› (*‹r ∈ ℙ›*) have False unfolding forces_nmem_def (*goal: ‹False›*) by blast then show "?thesis" (*goal: ‹∃p∈G. p forces⇩a (τ = θ)›*) by simp qed qed (* Lemma IV.2.40(b), full *) lemma IV240b: "(τ∈M⟶θ∈M⟶val(G,τ) = val(G,θ) ⟶ (∃p∈G. p forces⇩a (τ = θ))) ∧ (τ∈M⟶θ∈M⟶val(G,τ) ∈ val(G,θ) ⟶ (∃p∈G. p forces⇩a (τ ∈ θ)))" (is "?Q(τ,θ) ∧ ?R(τ,θ)") proof (intro forces_induction (*‹⟦⋀τ θ. (⋀σ. σ ∈ domain(θ) ⟹ ?Q(τ, σ)) ⟹ ?R(τ, θ); ⋀τ θ. (⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ ?R(σ, τ) ∧ ?R(σ, θ)) ⟹ ?Q(τ, θ)⟧ ⟹ ?Q(?τ, ?θ) ∧ ?R(?τ, ?θ)›*)) (*goals: 1. ‹⋀τ θ. (⋀σ. σ ∈ domain(θ) ⟹ τ ∈ M ⟶ σ ∈ M ⟶ val(G, τ) = val(G, σ) ⟶ (∃p∈G. p forces⇩a (τ = σ))) ⟹ τ ∈ M ⟶ θ ∈ M ⟶ val(G, τ) ∈ val(G, θ) ⟶ (∃p∈G. p forces⇩a (τ ∈ θ))› 2. ‹⋀τ θ. (⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ val(G, σ) ∈ val(G, τ) ⟶ (∃p∈G. p forces⇩a (σ ∈ τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ val(G, σ) ∈ val(G, θ) ⟶ (∃p∈G. p forces⇩a (σ ∈ θ)))) ⟹ τ ∈ M ⟶ θ ∈ M ⟶ val(G, τ) = val(G, θ) ⟶ (∃p∈G. p forces⇩a (τ = θ))›*) fix τ and θ and p assume "σ∈domain(θ) ⟹ ?Q(τ, σ)" for σ (*‹(?σ::i) ∈ domain(θ::i) ⟹ (τ::i) ∈ (M::i) ⟶ ?σ ∈ M ⟶ val(G::i, τ) = val(G, ?σ) ⟶ (∃p::i∈G. p forces⇩a (τ = ?σ))›*) then show "?R(τ, θ)" using IV240b_mem (*‹⟦val(G, ?π) ∈ val(G, ?τ); ?π ∈ M; ?τ ∈ M; ⋀σ. ⟦σ ∈ domain(?τ); val(G, ?π) = val(G, σ)⟧ ⟹ ∃p∈G. p forces⇩a (?π = σ)⟧ ⟹ ∃p∈G. p forces⇩a (?π ∈ ?τ)›*) domain_closed (*‹(##M)(?r) ⟹ (##M)(domain(?r))›*) transitivity (*‹⟦?y ∈ ?x; ?x ∈ M⟧ ⟹ ?y ∈ M›*) by simp next (*goal: ‹⋀τ θ. (⋀σ. σ ∈ domain(τ) ∪ domain(θ) ⟹ (σ ∈ M ⟶ τ ∈ M ⟶ val(G, σ) ∈ val(G, τ) ⟶ (∃p∈G. p forces⇩a (σ ∈ τ))) ∧ (σ ∈ M ⟶ θ ∈ M ⟶ val(G, σ) ∈ val(G, θ) ⟶ (∃p∈G. p forces⇩a (σ ∈ θ)))) ⟹ τ ∈ M ⟶ θ ∈ M ⟶ val(G, τ) = val(G, θ) ⟶ (∃p∈G. p forces⇩a (τ = θ))›*) fix τ and θ and p assume "σ ∈ domain(τ) ∪ domain(θ) ⟹ ?R(σ,τ) ∧ ?R(σ,θ)" for σ (*‹(?σ::i) ∈ domain(τ::i) ∪ domain(θ::i) ⟹ (?σ ∈ (M::i) ⟶ τ ∈ M ⟶ val(G::i, ?σ) ∈ val(G, τ) ⟶ (∃p::i∈G. p forces⇩a (?σ ∈ τ))) ∧ (?σ ∈ M ⟶ θ ∈ M ⟶ val(G, ?σ) ∈ val(G, θ) ⟶ (∃p::i∈G. p forces⇩a (?σ ∈ θ)))›*) moreover from this (*‹(?σ::i) ∈ domain(τ::i) ∪ domain(θ::i) ⟹ (?σ ∈ (M::i) ⟶ τ ∈ M ⟶ val(G::i, ?σ) ∈ val(G, τ) ⟶ (∃p::i∈G. p forces⇩a (?σ ∈ τ))) ∧ (?σ ∈ M ⟶ θ ∈ M ⟶ val(G, ?σ) ∈ val(G, θ) ⟶ (∃p::i∈G. p forces⇩a (?σ ∈ θ)))›*) have IH': "τ∈M ⟹ θ∈M ⟹ σ ∈ domain(τ) ∪ domain(θ) ⟹ (val(G, σ) ∈ val(G, τ) ⟶ (∃q∈G. q forces⇩a (σ ∈ τ))) ∧ (val(G, σ) ∈ val(G, θ) ⟶ (∃q∈G. q forces⇩a (σ ∈ θ)))" for σ using domain_trans[OF trans_M] (*‹⟦?y ∈ M; ?x ∈ domain(?y)⟧ ⟹ ?x ∈ M›*) by blast ultimately show "?Q(τ,θ)" using IV240b_eq (*‹⟦val(G, ?τ) = val(G, ?θ); ?τ ∈ M; ?θ ∈ M; ⋀σ. σ ∈ domain(?τ) ∪ domain(?θ) ⟹ (val(G, σ) ∈ val(G, ?τ) ⟶ (∃q∈G. q forces⇩a (σ ∈ ?τ))) ∧ (val(G, σ) ∈ val(G, ?θ) ⟶ (∃q∈G. q forces⇩a (σ ∈ ?θ)))⟧ ⟹ ∃p∈G. p forces⇩a (?τ = ?θ)›*) by auto qed lemma truth_lemma_mem: assumes "env∈list(M)" "n∈nat" "m∈nat" "n<length(env)" "m<length(env)" shows "(∃p∈G. p ⊩ Member(n,m) env) ⟷ M[G], map(val(G),env) ⊨ Member(n,m)" using assms (*‹env ∈ list(M)› ‹n ∈ ω› ‹m ∈ ω› ‹n < length(env)› ‹m < length(env)›*) IV240a[of "nth(n,env)" "nth(m,env)"] (*‹(nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ (∀p∈G. p forces⇩a (nth(n, env) = nth(m, env)) ⟶ val(G, nth(n, env)) = val(G, nth(m, env)))) ∧ (nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ (∀p∈G. p forces⇩a (nth(n, env) ∈ nth(m, env)) ⟶ val(G, nth(n, env)) ∈ val(G, nth(m, env))))›*) IV240b[of "nth(n,env)" "nth(m,env)"] (*‹(nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ val(G, nth(n, env)) = val(G, nth(m, env)) ⟶ (∃p∈G. p forces⇩a (nth(n, env) = nth(m, env)))) ∧ (nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ val(G, nth(n, env)) ∈ val(G, nth(m, env)) ⟶ (∃p∈G. p forces⇩a (nth(n, env) ∈ nth(m, env))))›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) Forces_Member[of _ "nth(n,env)" "nth(m,env)" env n m] (*‹⟦(?p::i) ∈ ℙ; nth(n::i, env::i) ∈ (M::i); nth(m::i, env) ∈ M; env ∈ list(M); nth(n, env) = nth(n, env); nth(m, env) = nth(m, env); n ∈ ω; m ∈ ω⟧ ⟹ ?p ⊩ ⋅n ∈ m⋅ env ⟷ ?p forces⇩a (nth(n, env) ∈ nth(m, env))›*) map_val_in_MG (*‹?env ∈ list(?M) ⟹ map(val(?G), ?env) ∈ list(?M[?G])›*) by auto lemma truth_lemma_eq: assumes "env∈list(M)" "n∈nat" "m∈nat" "n<length(env)" "m<length(env)" shows "(∃p∈G. p ⊩ Equal(n,m) env) ⟷ M[G], map(val(G),env) ⊨ Equal(n,m)" using assms (*‹env ∈ list(M)› ‹n ∈ ω› ‹m ∈ ω› ‹(n::i) < length(env::i)› ‹m < length(env)›*) IV240a(1)[of "nth(n,env)" "nth(m,env)"] (*‹(nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ (∀p∈G. p forces⇩a (nth(n, env) = nth(m, env)) ⟶ val(G, nth(n, env)) = val(G, nth(m, env)))) ∧ (nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ (∀p∈G. p forces⇩a (nth(n, env) ∈ nth(m, env)) ⟶ val(G, nth(n, env)) ∈ val(G, nth(m, env))))›*) IV240b(1)[of "nth(n,env)" "nth(m,env)"] (*‹(nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ val(G, nth(n, env)) = val(G, nth(m, env)) ⟶ (∃p∈G. p forces⇩a (nth(n, env) = nth(m, env)))) ∧ (nth(n, env) ∈ M ⟶ nth(m, env) ∈ M ⟶ val(G, nth(n, env)) ∈ val(G, nth(m, env)) ⟶ (∃p∈G. p forces⇩a (nth(n, env) ∈ nth(m, env))))›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) Forces_Equal[of _ "nth(n,env)" "nth(m,env)" env n m] (*‹⟦(?p::i) ∈ ℙ; nth(n::i, env::i) ∈ (M::i); nth(m::i, env) ∈ M; env ∈ list(M); nth(n, env) = nth(n, env); nth(m, env) = nth(m, env); n ∈ ω; m ∈ ω⟧ ⟹ ?p ⊩ ⋅n = m⋅ env ⟷ ?p forces⇩a (nth(n, env) = nth(m, env))›*) map_val_in_MG (*‹(?env::i) ∈ list(?M::i) ⟹ map(val(?G::i), ?env) ∈ list(?M[?G])›*) by auto end ― ‹\<^locale>‹G_generic1›› lemma arities_at_aux: assumes "n ∈ nat" "m ∈ nat" "env ∈ list(M)" "succ(n) ∪ succ(m) ≤ length(env)" shows "n < length(env)" "m < length(env)" using assms (*‹n ∈ ω› ‹m ∈ ω› ‹env ∈ list(M)› ‹succ(n) ∪ succ(m) ≤ length(env)›*) succ_leE[OF Un_leD1, of n "succ(m)" "length(env)"] (*‹⟦Ord(succ(n)); Ord(succ(m)); Ord(length(env)); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env)›*) succ_leE[OF Un_leD2, of "succ(n)" m "length(env)"] (*‹⟦Ord(succ(n)); Ord(succ(m)); Ord(length(env)); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)›*) apply - (*goals: 1. ‹⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env); ⟦Ord(succ(n)); Ord(succ(m)); Ord(length(env)); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⟦Ord(succ(n)); Ord(succ(m)); Ord(length(env)); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ n < length(env)› 2. ‹⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env); ⟦Ord(succ(n)); Ord(succ(m)); Ord(length(env)); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⟦Ord(succ(n)); Ord(succ(m)); Ord(length(env)); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ m < length(env)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection‹The Strenghtening Lemma› context forcing_data1 begin lemma strengthening_lemma: assumes "p∈ℙ" "φ∈formula" "r∈ℙ" "r≼p" "env∈list(M)" "arity(φ)≤length(env)" shows "p ⊩ φ env ⟹ r ⊩ φ env" using assms(2-) (*‹φ ∈ formula› ‹r ∈ ℙ› ‹(r::i) ≼ (p::i)› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) proof (induct arbitrary:env) (*goals: 1. ‹⋀x y env. ⟦x ∈ ω; y ∈ ω; p ⊩ ⋅x ∈ y⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅x ∈ y⋅) ≤ length(env)⟧ ⟹ r ⊩ ⋅x ∈ y⋅ env› 2. ‹⋀x y env. ⟦x ∈ ω; y ∈ ω; p ⊩ ⋅x = y⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅x = y⋅) ≤ length(env)⟧ ⟹ r ⊩ ⋅x = y⋅ env› 3. ‹⋀pa q env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; q ∈ formula; ⋀env. ⟦p ⊩ q env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ r ⊩ q env; p ⊩ ⋅¬(pa ∧ q)⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅¬(pa ∧ q)⋅) ≤ length(env)⟧ ⟹ r ⊩ ⋅¬(pa ∧ q)⋅ env› 4. ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; p ⊩ (⋅∀pa⋅) env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ r ⊩ (⋅∀pa⋅) env›*) case (Member n m) (*‹n ∈ ω› ‹m ∈ ω› ‹p ⊩ ⋅n ∈ m⋅ env› ‹r ∈ ℙ› ‹r ≼ p› ‹(env::i) ∈ list(M::i)› ‹arity(⋅n ∈ m⋅) ≤ length(env)›*) then have "n<length(env)" "m<length(env)" using arities_at_aux (*‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?n < length(?env)› ‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?m < length(?env)›*) apply - (*goals: 1. ‹⟦n ∈ ω; m ∈ ω; p ⊩ ⋅n ∈ m⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅n ∈ m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ n < length(env)› 2. ‹⟦n ∈ ω; m ∈ ω; p ⊩ ⋅n ∈ m⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅n ∈ m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ m < length(env)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "env∈list(M)" (*‹(env::i) ∈ list(M::i)›*) moreover note assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹r ∈ ℙ› ‹r ≼ p› ‹(env::i) ∈ list(M::i)› ‹arity(φ) ≤ length(env)›*) Member (*‹n ∈ ω› ‹m ∈ ω› ‹p ⊩ ⋅n ∈ m⋅ env› ‹(r::i) ∈ ℙ› ‹(r::i) ≼ (p::i)› ‹env ∈ list(M)› ‹arity(⋅n ∈ m⋅) ≤ length(env)›*) ultimately show "?case" (*goal: ‹r ⊩ ⋅n ∈ m⋅ env›*) using Forces_Member[of _ "nth(n,env)" "nth(m,env)" env n m] (*‹⟦?p ∈ ℙ; nth(n, env) ∈ M; nth(m, env) ∈ M; env ∈ list(M); nth(n, env) = nth(n, env); nth(m, env) = nth(m, env); n ∈ ω; m ∈ ω⟧ ⟹ ?p ⊩ ⋅n ∈ m⋅ env ⟷ ?p forces⇩a (nth(n, env) ∈ nth(m, env))›*) strengthening_mem[of p r "nth(n,env)" "nth(m,env)"] (*‹⟦p ∈ ℙ; r ∈ ℙ; r ≼ p; p forces⇩a (nth(n, env) ∈ nth(m, env))⟧ ⟹ r forces⇩a (nth(n, env) ∈ nth(m, env))›*) by simp next (*goals: 1. ‹⋀x y env. ⟦x ∈ ω; y ∈ ω; p ⊩ ⋅x = y⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅x = y⋅) ≤ length(env)⟧ ⟹ r ⊩ ⋅x = y⋅ env› 2. ‹⋀pa q env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; q ∈ formula; ⋀env. ⟦p ⊩ q env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ r ⊩ q env; p ⊩ ⋅¬(pa ∧ q)⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅¬(pa ∧ q)⋅) ≤ length(env)⟧ ⟹ r ⊩ ⋅¬(pa ∧ q)⋅ env› 3. ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; p ⊩ (⋅∀pa⋅) env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ r ⊩ (⋅∀pa⋅) env›*) case (Equal n m) (*‹n ∈ ω› ‹m ∈ ω› ‹p ⊩ ⋅n = m⋅ env› ‹r ∈ ℙ› ‹r ≼ p› ‹env ∈ list(M)› ‹arity(⋅n::i = m::i⋅) ≤ length(env::i)›*) then have "n<length(env)" "m<length(env)" using arities_at_aux (*‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?n < length(?env)› ‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?m < length(?env)›*) apply - (*goals: 1. ‹⟦n ∈ ω; m ∈ ω; p ⊩ ⋅n = m⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅n = m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ n < length(env)› 2. ‹⟦n ∈ ω; m ∈ ω; p ⊩ ⋅n = m⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅n = m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ m < length(env)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "env∈list(M)" (*‹(env::i) ∈ list(M::i)›*) moreover note assms (*‹(p::i) ∈ ℙ› ‹φ ∈ formula› ‹r ∈ ℙ› ‹r ≼ p› ‹(env::i) ∈ list(M::i)› ‹arity(φ::i) ≤ length(env::i)›*) Equal (*‹(n::i) ∈ ω› ‹(m::i) ∈ ω› ‹p ⊩ ⋅n = m⋅ env› ‹r ∈ ℙ› ‹r ≼ p› ‹env ∈ list(M)› ‹arity(⋅n = m⋅) ≤ length(env)›*) ultimately show "?case" (*goal: ‹r ⊩ ⋅n = m⋅ env›*) using Forces_Equal[of _ "nth(n,env)" "nth(m,env)" env n m] (*‹⟦?p ∈ ℙ; nth(n, env) ∈ M; nth(m, env) ∈ M; env ∈ list(M); nth(n, env) = nth(n, env); nth(m, env) = nth(m, env); n ∈ ω; m ∈ ω⟧ ⟹ ?p ⊩ ⋅n = m⋅ env ⟷ ?p forces⇩a (nth(n, env) = nth(m, env))›*) strengthening_eq[of p r "nth(n,env)" "nth(m,env)"] (*‹⟦p ∈ ℙ; r ∈ ℙ; r ≼ p; p forces⇩a (nth(n, env) = nth(m, env))⟧ ⟹ r forces⇩a (nth(n, env) = nth(m, env))›*) by simp next (*goals: 1. ‹⋀pa q env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; q ∈ formula; ⋀env. ⟦p ⊩ q env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ r ⊩ q env; p ⊩ ⋅¬(pa ∧ q)⋅ env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(⋅¬(pa ∧ q)⋅) ≤ length(env)⟧ ⟹ r ⊩ ⋅¬(pa ∧ q)⋅ env› 2. ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; p ⊩ (⋅∀pa⋅) env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ r ⊩ (⋅∀pa⋅) env›*) case (Nand φ ψ) (*‹φ ∈ formula› ‹⟦p ⊩ φ ?env; r ∈ ℙ; r ≼ p; ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ r ⊩ φ ?env› ‹ψ ∈ formula› ‹⟦(p::i) ⊩ (ψ::i) (?env::i); (r::i) ∈ ℙ; r ≼ p; ?env ∈ list(M::i); arity(ψ) ≤ length(?env)⟧ ⟹ r ⊩ ψ ?env› ‹p ⊩ ⋅¬(φ ∧ ψ)⋅ env› ‹r ∈ ℙ› ‹r ≼ p› ‹env ∈ list(M)› ‹arity(⋅¬(φ::i ∧ ψ::i)⋅) ≤ length(env::i)›*) with assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹r ∈ ℙ› ‹r ≼ p› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) show "?case" (*goal: ‹r ⊩ ⋅¬(φ ∧ ψ)⋅ env›*) using Forces_Nand (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula; ?ψ ∈ formula⟧ ⟹ ?p ⊩ ⋅¬(?φ ∧ ?ψ)⋅ ?env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env ∧ q ⊩ ?ψ ?env)›*) transitivity[OF _ P_in_M] (*‹?y ∈ ℙ ⟹ ?y ∈ M›*) pair_in_M_iff (*‹(##M)(⟨?a, ?b⟩) ⟷ (##M)(?a) ∧ (##M)(?b)›*) transitivity[OF _ leq_in_M] (*‹?y ∈ leq ⟹ ?y ∈ M›*) leq_transD (*‹⟦?a ≼ ?b; ?b ≼ ?c; ?a ∈ ℙ; ?b ∈ ℙ; ?c ∈ ℙ⟧ ⟹ ?a ≼ ?c›*) by auto next (*goal: ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦p ⊩ pa env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ r ⊩ pa env; p ⊩ (⋅∀pa⋅) env; r ∈ ℙ; r ≼ p; env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ r ⊩ (⋅∀pa⋅) env›*) case (Forall φ) (*‹φ ∈ formula› ‹⟦(p::i) ⊩ (φ::i) (?env::i); (r::i) ∈ ℙ; r ≼ p; ?env ∈ list(M::i); arity(φ) ≤ length(?env)⟧ ⟹ r ⊩ φ ?env› ‹p ⊩ (⋅∀φ⋅) env› ‹(r::i) ∈ ℙ› ‹(r::i) ≼ (p::i)› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) with assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹(r::i) ∈ ℙ› ‹r ≼ p› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) have "p ⊩ φ ([x] @ env)" if "x∈M" for x using that (*‹x ∈ M›*) Forces_Forall (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ (∀x∈M. ?p ⊩ ?φ [x] @ ?env)›*) by simp with Forall (*‹φ ∈ formula› ‹⟦p ⊩ φ ?env; r ∈ ℙ; r ≼ p; ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ r ⊩ φ ?env› ‹p ⊩ (⋅∀φ⋅) env› ‹r ∈ ℙ› ‹r ≼ p› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) have "r ⊩ φ ([x] @ env)" if "x∈M" for x using that (*‹x ∈ M›*) pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) by simp with assms (*‹p ∈ ℙ› ‹(φ::i) ∈ formula› ‹r ∈ ℙ› ‹r ≼ p› ‹(env::i) ∈ list(M::i)› ‹arity(φ::i) ≤ length(env::i)›*) Forall (*‹(φ::i) ∈ formula› ‹⟦p ⊩ φ ?env; r ∈ ℙ; r ≼ p; ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ r ⊩ φ ?env› ‹p ⊩ (⋅∀φ⋅) env› ‹r ∈ ℙ› ‹(r::i) ≼ (p::i)› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) show "?case" (*goal: ‹r ⊩ (⋅∀φ⋅) env›*) using Forces_Forall (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ (∀x∈M. ?p ⊩ ?φ [x] @ ?env)›*) by simp qed subsection‹The Density Lemma› lemma arity_Nand_le: assumes "φ ∈ formula" "ψ ∈ formula" "arity(Nand(φ, ψ)) ≤ length(env)" "env∈list(A)" shows "arity(φ) ≤ length(env)" "arity(ψ) ≤ length(env)" using assms (*‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(⋅¬(φ::i ∧ ψ::i)⋅) ≤ length(env::i)› ‹env ∈ list(A)›*) by (rule_tac Un_leD1 (*‹⟦Ord(?i); Ord(?j); Ord(?k); ?i ∪ ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*), rule_tac [5] Un_leD2 (*‹⟦Ord(?i); Ord(?j); Ord(?k); ?i ∪ ?j ≤ ?k⟧ ⟹ ?j ≤ ?k›*), auto) lemma dense_below_imp_forces: assumes "p∈ℙ" "φ∈formula" "env∈list(M)" "arity(φ)≤length(env)" shows "dense_below({q∈ℙ. (q ⊩ φ env)},p) ⟹ (p ⊩ φ env)" using assms(2-) (*‹(φ::i) ∈ formula› ‹(env::i) ∈ list(M::i)› ‹arity(φ::i) ≤ length(env::i)›*) proof (induct arbitrary:env) (*goals: 1. ‹⋀x y env. ⟦x ∈ ω; y ∈ ω; dense_below({q ∈ ℙ . q ⊩ ⋅x ∈ y⋅ env}, p); env ∈ list(M); arity(⋅x ∈ y⋅) ≤ length(env)⟧ ⟹ p ⊩ ⋅x ∈ y⋅ env› 2. ‹⋀x y env. ⟦x ∈ ω; y ∈ ω; dense_below({q ∈ ℙ . q ⊩ ⋅x = y⋅ env}, p); env ∈ list(M); arity(⋅x = y⋅) ≤ length(env)⟧ ⟹ p ⊩ ⋅x = y⋅ env› 3. ‹⋀pa q env. ⟦pa ∈ formula; ⋀env. ⟦dense_below({q ∈ ℙ . q ⊩ pa env}, p); env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; q ∈ formula; ⋀env. ⟦dense_below({qa ∈ ℙ . qa ⊩ q env}, p); env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ p ⊩ q env; dense_below({qa ∈ ℙ . qa ⊩ ⋅¬(pa ∧ q)⋅ env}, p); env ∈ list(M); arity(⋅¬(pa ∧ q)⋅) ≤ length(env)⟧ ⟹ p ⊩ ⋅¬(pa ∧ q)⋅ env› 4. ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦dense_below({q ∈ ℙ . q ⊩ pa env}, p); env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; dense_below({q ∈ ℙ . q ⊩ (⋅∀pa⋅) env}, p); env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ p ⊩ (⋅∀pa⋅) env›*) case (Member n m) (*‹(n::i) ∈ ω› ‹m ∈ ω› ‹dense_below({q ∈ ℙ . q ⊩ ⋅n ∈ m⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅n ∈ m⋅) ≤ length(env)›*) then have "n<length(env)" "m<length(env)" using arities_at_aux (*‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?n < length(?env)› ‹⟦(?n::i) ∈ ω; (?m::i) ∈ ω; (?env::i) ∈ list(?M::i); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?m < length(?env)›*) apply - (*goals: 1. ‹⟦n ∈ ω; m ∈ ω; dense_below({q ∈ ℙ . q ⊩ ⋅n ∈ m⋅ env}, p); env ∈ list(M); arity(⋅n ∈ m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ n < length(env)› 2. ‹⟦n ∈ ω; m ∈ ω; dense_below({q ∈ ℙ . q ⊩ ⋅n ∈ m⋅ env}, p); env ∈ list(M); arity(⋅n ∈ m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ m < length(env)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "env∈list(M)" (*‹(env::i) ∈ list(M::i)›*) moreover note assms (*‹(p::i) ∈ ℙ› ‹(φ::i) ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) Member (*‹n ∈ ω› ‹m ∈ ω› ‹dense_below({q ∈ ℙ . q ⊩ ⋅n ∈ m⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅n ∈ m⋅) ≤ length(env)›*) ultimately show "?case" (*goal: ‹p ⊩ ⋅n ∈ m⋅ env›*) using Forces_Member[of _ "nth(n,env)" "nth(m,env)" env n m] (*‹⟦?p ∈ ℙ; nth(n, env) ∈ M; nth(m, env) ∈ M; env ∈ list(M); nth(n, env) = nth(n, env); nth(m, env) = nth(m, env); n ∈ ω; m ∈ ω⟧ ⟹ ?p ⊩ ⋅n ∈ m⋅ env ⟷ ?p forces⇩a (nth(n, env) ∈ nth(m, env))›*) density_mem[of p "nth(n,env)" "nth(m,env)"] (*‹p ∈ ℙ ⟹ p forces⇩a (nth(n, env) ∈ nth(m, env)) ⟷ dense_below({q ∈ ℙ . q forces⇩a (nth(n, env) ∈ nth(m, env))}, p)›*) by simp next (*goals: 1. ‹⋀(x::i) (y::i) env::i. ⟦x ∈ ω; y ∈ ω; dense_below({q::i ∈ ℙ . q ⊩ ⋅x = y⋅ env}, p::i); env ∈ list(M::i); arity(⋅x = y⋅) ≤ length(env)⟧ ⟹ p ⊩ ⋅x = y⋅ env› 2. ‹⋀(pa::i) (q::i) env::i. ⟦pa ∈ formula; ⋀env::i. ⟦dense_below({q::i ∈ ℙ . q ⊩ pa env}, p::i); env ∈ list(M::i); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; q ∈ formula; ⋀env::i. ⟦dense_below({qa::i ∈ ℙ . qa ⊩ q env}, p); env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ p ⊩ q env; dense_below({qa::i ∈ ℙ . qa ⊩ ⋅¬(pa ∧ q)⋅ env}, p); env ∈ list(M); arity(⋅¬(pa ∧ q)⋅) ≤ length(env)⟧ ⟹ p ⊩ ⋅¬(pa ∧ q)⋅ env› 3. ‹⋀(pa::i) env::i. ⟦pa ∈ formula; ⋀env::i. ⟦dense_below({q::i ∈ ℙ . q ⊩ pa env}, p::i); env ∈ list(M::i); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; dense_below({q::i ∈ ℙ . q ⊩ (⋅∀pa⋅) env}, p); env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ p ⊩ (⋅∀pa⋅) env›*) case (Equal n m) (*‹(n::i) ∈ ω› ‹m ∈ ω› ‹dense_below({q ∈ ℙ . q ⊩ ⋅n = m⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅n = m⋅) ≤ length(env)›*) then have "n<length(env)" "m<length(env)" using arities_at_aux (*‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?n < length(?env)› ‹⟦(?n::i) ∈ ω; (?m::i) ∈ ω; (?env::i) ∈ list(?M::i); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?m < length(?env)›*) apply - (*goals: 1. ‹⟦n ∈ ω; m ∈ ω; dense_below({q ∈ ℙ . q ⊩ ⋅n = m⋅ env}, p); env ∈ list(M); arity(⋅n = m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ n < length(env)› 2. ‹⟦n ∈ ω; m ∈ ω; dense_below({q ∈ ℙ . q ⊩ ⋅n = m⋅ env}, p); env ∈ list(M); arity(⋅n = m⋅) ≤ length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ n < length(env); ⋀n m env M. ⟦n ∈ ω; m ∈ ω; env ∈ list(M); succ(n) ∪ succ(m) ≤ length(env)⟧ ⟹ m < length(env)⟧ ⟹ m < length(env)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "env∈list(M)" (*‹(env::i) ∈ list(M::i)›*) moreover note assms (*‹(p::i) ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) Equal (*‹n ∈ ω› ‹(m::i) ∈ ω› ‹dense_below({q ∈ ℙ . q ⊩ ⋅n = m⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅n::i = m::i⋅) ≤ length(env::i)›*) ultimately show "?case" (*goal: ‹(p::i) ⊩ ⋅n::i = m::i⋅ (env::i)›*) using Forces_Equal[of _ "nth(n,env)" "nth(m,env)" env n m] (*‹⟦?p ∈ ℙ; nth(n, env) ∈ M; nth(m, env) ∈ M; env ∈ list(M); nth(n, env) = nth(n, env); nth(m, env) = nth(m, env); n ∈ ω; m ∈ ω⟧ ⟹ ?p ⊩ ⋅n = m⋅ env ⟷ ?p forces⇩a (nth(n, env) = nth(m, env))›*) density_eq[of p "nth(n,env)" "nth(m,env)"] (*‹(p::i) ∈ ℙ ⟹ p forces⇩a (nth(n::i, env::i) = nth(m::i, env)) ⟷ dense_below({q::i ∈ ℙ . q forces⇩a (nth(n, env) = nth(m, env))}, p)›*) by simp next (*goals: 1. ‹⋀pa q env. ⟦pa ∈ formula; ⋀env. ⟦dense_below({q ∈ ℙ . q ⊩ pa env}, p); env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; q ∈ formula; ⋀env. ⟦dense_below({qa ∈ ℙ . qa ⊩ q env}, p); env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ p ⊩ q env; dense_below({qa ∈ ℙ . qa ⊩ ⋅¬(pa ∧ q)⋅ env}, p); env ∈ list(M); arity(⋅¬(pa ∧ q)⋅) ≤ length(env)⟧ ⟹ p ⊩ ⋅¬(pa ∧ q)⋅ env› 2. ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦dense_below({q ∈ ℙ . q ⊩ pa env}, p); env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; dense_below({q ∈ ℙ . q ⊩ (⋅∀pa⋅) env}, p); env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ p ⊩ (⋅∀pa⋅) env›*) case (Nand φ ψ) (*‹φ ∈ formula› ‹⟦dense_below({q::i ∈ ℙ . q ⊩ (φ::i) (?env::i)}, p::i); ?env ∈ list(M::i); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹ψ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ ψ ?env}, p); ?env ∈ list(M); arity(ψ) ≤ length(?env)⟧ ⟹ p ⊩ ψ ?env› ‹dense_below({q ∈ ℙ . q ⊩ ⋅¬(φ ∧ ψ)⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅¬(φ ∧ ψ)⋅) ≤ length(env)›*) { fix q assume "q∈M" "q∈ℙ" "q≼ p" "q ⊩ φ env" (*‹(q::i) ∈ (M::i)› ‹(q::i) ∈ ℙ› ‹(q::i) ≼ (p::i)› ‹(q::i) ⊩ (φ::i) (env::i)›*) moreover note Nand (*‹φ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹ψ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ ψ ?env}, p); ?env ∈ list(M); arity(ψ) ≤ length(?env)⟧ ⟹ p ⊩ ψ ?env› ‹dense_below({q ∈ ℙ . q ⊩ ⋅¬(φ ∧ ψ)⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅¬(φ ∧ ψ)⋅) ≤ length(env)›*) moreover from calculation (*‹q ∈ M› ‹(q::i) ∈ ℙ› ‹q ≼ p› ‹q ⊩ φ env› ‹φ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹ψ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ ψ ?env}, p); ?env ∈ list(M); arity(ψ) ≤ length(?env)⟧ ⟹ p ⊩ ψ ?env› ‹dense_below({q ∈ ℙ . q ⊩ ⋅¬(φ ∧ ψ)⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅¬(φ ∧ ψ)⋅) ≤ length(env)›*) obtain d where "d∈ℙ" "d ⊩ Nand(φ, ψ) env" "d≼ q" (*goal: ‹(⋀d. ⟦d ∈ ℙ; d ⊩ ⋅¬(φ ∧ ψ)⋅ env; d ≼ q⟧ ⟹ thesis) ⟹ thesis›*) using dense_belowI (*‹(⋀q. ⟦q ∈ ℙ; q ≼ ?p⟧ ⟹ ∃d∈?D. d ∈ ℙ ∧ d ≼ q) ⟹ dense_below(?D, ?p)›*) by auto moreover from calculation (*‹q ∈ M› ‹q ∈ ℙ› ‹q ≼ p› ‹q ⊩ φ env› ‹(φ::i) ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹ψ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ ψ ?env}, p); ?env ∈ list(M); arity(ψ) ≤ length(?env)⟧ ⟹ p ⊩ ψ ?env› ‹dense_below({q::i ∈ ℙ . q ⊩ ⋅¬(φ::i ∧ ψ::i)⋅ (env::i)}, p::i)› ‹env ∈ list(M)› ‹arity(⋅¬(φ::i ∧ ψ::i)⋅) ≤ length(env::i)› ‹d ∈ ℙ› and more 2 facts*) have "¬(d⊩ ψ env)" if "d ⊩ φ env" using that (*‹(d::i) ⊩ (φ::i) (env::i)›*) Forces_Nand (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula; ?ψ ∈ formula⟧ ⟹ ?p ⊩ ⋅¬(?φ ∧ ?ψ)⋅ ?env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env ∧ q ⊩ ?ψ ?env)›*) refl_leq (*‹?r ∈ ℙ ⟹ ?r ≼ ?r›*) transitivity[OF _ P_in_M, of d] (*‹d ∈ ℙ ⟹ d ∈ M›*) by auto moreover note arity_Nand_le[of φ ψ] (*‹⟦φ ∈ formula; ψ ∈ formula; arity(⋅¬(φ ∧ ψ)⋅) ≤ length(?env); ?env ∈ list(?A)⟧ ⟹ arity(φ) ≤ length(?env)› ‹⟦φ ∈ formula; ψ ∈ formula; arity(⋅¬(φ ∧ ψ)⋅) ≤ length(?env); ?env ∈ list(?A)⟧ ⟹ arity(ψ) ≤ length(?env)›*) moreover from calculation (*‹q ∈ M› ‹q ∈ ℙ› ‹q ≼ p› ‹q ⊩ φ env› ‹φ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹ψ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ ψ ?env}, p); ?env ∈ list(M); arity(ψ) ≤ length(?env)⟧ ⟹ p ⊩ ψ ?env› ‹dense_below({q ∈ ℙ . q ⊩ ⋅¬(φ ∧ ψ)⋅ env}, p)› ‹env ∈ list(M)› ‹arity(⋅¬(φ ∧ ψ)⋅) ≤ length(env)› ‹d ∈ ℙ› and more 5 facts*) have "d ⊩ φ env" using strengthening_lemma[of q φ d env] (*‹⟦q ∈ ℙ; φ ∈ formula; d ∈ ℙ; d ≼ q; env ∈ list(M); arity(φ) ≤ length(env); q ⊩ φ env⟧ ⟹ d ⊩ φ env›*) Un_leD1 (*‹⟦Ord(?i::i); Ord(?j::i); Ord(?k::i); ?i ∪ ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) by auto ultimately have "¬ (q ⊩ ψ env)" using strengthening_lemma[of q ψ d env] (*‹⟦q ∈ ℙ; ψ ∈ formula; d ∈ ℙ; d ≼ q; env ∈ list(M); arity(ψ) ≤ length(env); q ⊩ ψ env⟧ ⟹ d ⊩ ψ env›*) by auto } with ‹p∈ℙ› (*‹(p::i) ∈ ℙ›*) show "?case" (*goal: ‹p ⊩ ⋅¬(φ ∧ ψ)⋅ env›*) using Forces_Nand[symmetric, OF _ Nand ( 6 , 1 , 3 )] (*‹?p ∈ ℙ ⟹ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ φ env ∧ q ⊩ ψ env) ⟷ ?p ⊩ ⋅¬(φ ∧ ψ)⋅ env›*) by blast next (*goal: ‹⋀pa env. ⟦pa ∈ formula; ⋀env. ⟦dense_below({q ∈ ℙ . q ⊩ pa env}, p); env ∈ list(M); arity(pa) ≤ length(env)⟧ ⟹ p ⊩ pa env; dense_below({q ∈ ℙ . q ⊩ (⋅∀pa⋅) env}, p); env ∈ list(M); arity((⋅∀pa⋅)) ≤ length(env)⟧ ⟹ p ⊩ (⋅∀pa⋅) env›*) case (Forall φ) (*‹φ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹dense_below({q ∈ ℙ . q ⊩ (⋅∀φ⋅) env}, p)› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) have "dense_below({q∈ℙ. q ⊩ φ ([a]@env)},p)" if "a∈M" for a proof (standard) (*goal: ‹⋀q. ⟦q ∈ ℙ; q ≼ p⟧ ⟹ ∃d∈{q ∈ ℙ . q ⊩ φ [a] @ env}. d ∈ ℙ ∧ d ≼ q›*) fix r assume "r∈ℙ" "r≼p" (*‹(r::i) ∈ ℙ› ‹(r::i) ≼ (p::i)›*) with ‹dense_below(_,p)› (*‹dense_below({q ∈ ℙ . q ⊩ (⋅∀φ⋅) env}, p)›*) obtain q where "q∈ℙ" "q≼r" "q ⊩ Forall(φ) env" (*goal: ‹(⋀q::i. ⟦q ∈ ℙ; q ≼ (r::i); q ⊩ (⋅∀φ::i⋅) (env::i)⟧ ⟹ thesis::o) ⟹ thesis›*) by blast moreover note Forall (*‹φ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹dense_below({q ∈ ℙ . q ⊩ (⋅∀φ⋅) env}, p)› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) ‹a∈M› (*‹a ∈ M›*) moreover from calculation (*‹q ∈ ℙ› ‹(q::i) ≼ (r::i)› ‹q ⊩ (⋅∀φ⋅) env› ‹φ ∈ formula› ‹⟦dense_below({q ∈ ℙ . q ⊩ φ ?env}, p); ?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹dense_below({q ∈ ℙ . q ⊩ (⋅∀φ⋅) env}, p)› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)› ‹(a::i) ∈ (M::i)›*) have "q ⊩ φ ([a]@env)" using Forces_Forall (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ (∀x∈M. ?p ⊩ ?φ [x] @ ?env)›*) by simp ultimately show "∃d ∈ {q∈ℙ. q ⊩ φ ([a]@env)}. d ∈ ℙ ∧ d≼r" by auto qed moreover note Forall(2)[of "Cons(_,env)"] (*‹⟦dense_below({q::i ∈ ℙ . q ⊩ (φ::i) Cons(?uu3::i, env::i)}, p::i); Cons(?uu3, env) ∈ list(M::i); arity(φ) ≤ length(Cons(?uu3, env))⟧ ⟹ p ⊩ φ Cons(?uu3, env)›*) Forall(1,3-5) (*‹φ ∈ formula› ‹dense_below({q ∈ ℙ . q ⊩ (⋅∀φ⋅) env}, p)› ‹(env::i) ∈ list(M::i)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) ultimately have "p ⊩ φ ([a]@env)" if "a∈M" for a using that (*‹a ∈ M›*) pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) by simp with assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹(env::i) ∈ list(M::i)› ‹arity(φ::i) ≤ length(env::i)›*) Forall (*‹φ ∈ formula› ‹⟦dense_below({q::i ∈ ℙ . q ⊩ (φ::i) (?env::i)}, p::i); ?env ∈ list(M::i); arity(φ) ≤ length(?env)⟧ ⟹ p ⊩ φ ?env› ‹dense_below({q ∈ ℙ . q ⊩ (⋅∀φ⋅) env}, p)› ‹(env::i) ∈ list(M::i)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) show "?case" (*goal: ‹p ⊩ (⋅∀φ⋅) env›*) using Forces_Forall (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ (∀x∈M. ?p ⊩ ?φ [x] @ ?env)›*) by simp qed lemma density_lemma: assumes "p∈ℙ" "φ∈formula" "env∈list(M)" "arity(φ)≤length(env)" shows "p ⊩ φ env ⟷ dense_below({q∈ℙ. (q ⊩ φ env)},p)" proof (standard) (*goals: 1. ‹p ⊩ φ env ⟹ dense_below({q ∈ ℙ . q ⊩ φ env}, p)› 2. ‹dense_below({q ∈ ℙ . q ⊩ φ env}, p) ⟹ p ⊩ φ env›*) assume "dense_below({q∈ℙ. (q ⊩ φ env)},p)" (*‹dense_below({q::i ∈ ℙ . q ⊩ (φ::i) (env::i)}, p::i)›*) with assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) show "(p ⊩ φ env)" using dense_below_imp_forces (*‹⟦?p ∈ ℙ; ?φ ∈ formula; ?env ∈ list(M); arity(?φ) ≤ length(?env); dense_below({q ∈ ℙ . q ⊩ ?φ ?env}, ?p)⟧ ⟹ ?p ⊩ ?φ ?env›*) by simp next (*goal: ‹p ⊩ φ env ⟹ dense_below({q ∈ ℙ . q ⊩ φ env}, p)›*) assume "p ⊩ φ env" (*‹(p::i) ⊩ (φ::i) (env::i)›*) with assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) show "dense_below({q∈ℙ. q ⊩ φ env},p)" using strengthening_lemma (*‹⟦(?p::i) ∈ ℙ; (?φ::i) ∈ formula; (?r::i) ∈ ℙ; ?r ≼ ?p; (?env::i) ∈ list(M::i); arity(?φ) ≤ length(?env); ?p ⊩ ?φ ?env⟧ ⟹ ?r ⊩ ?φ ?env›*) refl_leq (*‹(?r::i) ∈ ℙ ⟹ ?r ≼ ?r›*) by auto qed subsection‹The Truth Lemma› lemma Forces_And: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" "ψ∈formula" "arity(φ) ≤ length(env)" "arity(ψ) ≤ length(env)" shows "p ⊩ And(φ,ψ) env ⟷ (p ⊩ φ env) ∧ (p ⊩ ψ env)" proof (standard) (*goals: 1. ‹p ⊩ ⋅φ ∧ ψ⋅ env ⟹ p ⊩ φ env ∧ p ⊩ ψ env› 2. ‹p ⊩ φ env ∧ p ⊩ ψ env ⟹ p ⊩ ⋅φ ∧ ψ⋅ env›*) assume "p ⊩ And(φ, ψ) env" (*‹(p::i) ⊩ ⋅φ::i ∧ ψ::i⋅ (env::i)›*) with assms (*‹(p::i) ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹(ψ::i) ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)›*) have "dense_below({r ∈ ℙ . (r ⊩ φ env) ∧ (r ⊩ ψ env)}, p)" using Forces_And_iff_dense_below (*‹⟦(?p::i) ∈ ℙ; (?env::i) ∈ list(M::i); (?φ::i) ∈ formula; (?ψ::i) ∈ formula⟧ ⟹ ?p ⊩ ⋅?φ ∧ ?ψ⋅ ?env ⟷ dense_below({r::i ∈ ℙ . r ⊩ ?φ ?env ∧ r ⊩ ?ψ ?env}, ?p)›*) by simp then have "dense_below({r ∈ ℙ . (r ⊩ φ env)}, p)" "dense_below({r ∈ ℙ . (r ⊩ ψ env)}, p)" apply - (*goals: 1. ‹dense_below({r::i ∈ ℙ . r ⊩ (φ::i) (env::i) ∧ r ⊩ (ψ::i) env}, p::i) ⟹ dense_below({r::i ∈ ℙ . r ⊩ φ env}, p)› 2. ‹dense_below({r::i ∈ ℙ . r ⊩ (φ::i) (env::i) ∧ r ⊩ (ψ::i) env}, p::i) ⟹ dense_below({r::i ∈ ℙ . r ⊩ ψ env}, p)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with assms (*‹(p::i) ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹(ψ::i) ∈ formula› ‹arity(φ::i) ≤ length(env::i)› ‹arity(ψ) ≤ length(env)›*) show "(p ⊩ φ env) ∧ (p ⊩ ψ env)" using density_lemma[symmetric] (*‹⟦?p ∈ ℙ; ?φ ∈ formula; ?env ∈ list(M); arity(?φ) ≤ length(?env)⟧ ⟹ dense_below({q ∈ ℙ . q ⊩ ?φ ?env}, ?p) ⟷ ?p ⊩ ?φ ?env›*) by simp next (*goal: ‹(p::i) ⊩ (φ::i) (env::i) ∧ p ⊩ (ψ::i) env ⟹ p ⊩ ⋅φ ∧ ψ⋅ env›*) assume "(p ⊩ φ env) ∧ (p ⊩ ψ env)" (*‹(p::i) ⊩ (φ::i) (env::i) ∧ p ⊩ (ψ::i) env›*) have "dense_below({r ∈ ℙ . (r ⊩ φ env) ∧ (r ⊩ ψ env)}, p)" proof (intro dense_belowI (*‹(⋀q. ⟦q ∈ ℙ; q ≼ ?p⟧ ⟹ ∃d∈?D. d ∈ ℙ ∧ d ≼ q) ⟹ dense_below(?D, ?p)›*) bexI (*‹⟦?P(?x); ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P(x)›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*), assumption) (*goals: 1. ‹⋀q. ⟦q ∈ ℙ; q ≼ p⟧ ⟹ q ≼ q› 2. ‹⋀q. ⟦q ∈ ℙ; q ≼ p⟧ ⟹ q ∈ {r ∈ ℙ . r ⊩ φ env ∧ r ⊩ ψ env}›*) fix q assume "q∈ℙ" "q≼ p" (*‹(q::i) ∈ ℙ› ‹(q::i) ≼ (p::i)›*) with assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹(ψ::i) ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)›*) ‹(p ⊩ φ env) ∧ (p ⊩ ψ env)› (*‹(p::i) ⊩ (φ::i) (env::i) ∧ p ⊩ (ψ::i) env›*) show "q∈{r ∈ ℙ . (r ⊩ φ env) ∧ (r ⊩ ψ env)}" "q≼ q" using strengthening_lemma (*‹⟦?p ∈ ℙ; ?φ ∈ formula; ?r ∈ ℙ; ?r ≼ ?p; ?env ∈ list(M); arity(?φ) ≤ length(?env); ?p ⊩ ?φ ?env⟧ ⟹ ?r ⊩ ?φ ?env›*) refl_leq (*‹(?r::i) ∈ ℙ ⟹ ?r ≼ ?r›*) apply - (*goals: 1. ‹⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(env); arity(ψ) ≤ length(env); p ⊩ φ env ∧ p ⊩ ψ env; q ∈ ℙ; q ≼ p; ⋀p φ r env. ⟦p ∈ ℙ; φ ∈ formula; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(φ) ≤ length(env); p ⊩ φ env⟧ ⟹ r ⊩ φ env; ⋀r. r ∈ ℙ ⟹ r ≼ r⟧ ⟹ q ∈ {r ∈ ℙ . r ⊩ φ env ∧ r ⊩ ψ env}› 2. ‹⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(env); arity(ψ) ≤ length(env); p ⊩ φ env ∧ p ⊩ ψ env; q ∈ ℙ; q ≼ p; ⋀p φ r env. ⟦p ∈ ℙ; φ ∈ formula; r ∈ ℙ; r ≼ p; env ∈ list(M); arity(φ) ≤ length(env); p ⊩ φ env⟧ ⟹ r ⊩ φ env; ⋀r. r ∈ ℙ ⟹ r ≼ r⟧ ⟹ q ≼ q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed with assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(φ::i) ≤ length(env::i)› ‹arity(ψ) ≤ length(env)›*) show "p ⊩ And(φ,ψ) env" using Forces_And_iff_dense_below (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula; ?ψ ∈ formula⟧ ⟹ ?p ⊩ ⋅?φ ∧ ?ψ⋅ ?env ⟷ dense_below({r ∈ ℙ . r ⊩ ?φ ?env ∧ r ⊩ ?ψ ?env}, ?p)›*) by simp qed lemma Forces_Nand_alt: assumes "p∈ℙ" "env ∈ list(M)" "φ∈formula" "ψ∈formula" "arity(φ) ≤ length(env)" "arity(ψ) ≤ length(env)" shows "(p ⊩ Nand(φ,ψ) env) ⟷ (p ⊩ Neg(And(φ,ψ)) env)" using assms (*‹p ∈ ℙ› ‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(φ::i) ≤ length(env::i)› ‹arity(ψ) ≤ length(env)›*) Forces_Nand (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula; ?ψ ∈ formula⟧ ⟹ ?p ⊩ ⋅¬(?φ ∧ ?ψ)⋅ ?env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env ∧ q ⊩ ?ψ ?env)›*) Forces_And (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula; ?ψ ∈ formula; arity(?φ) ≤ length(?env); arity(?ψ) ≤ length(?env)⟧ ⟹ ?p ⊩ ⋅?φ ∧ ?ψ⋅ ?env ⟷ ?p ⊩ ?φ ?env ∧ ?p ⊩ ?ψ ?env›*) Forces_Neg (*‹⟦(?p::i) ∈ ℙ; (?env::i) ∈ list(M::i); (?φ::i) ∈ formula⟧ ⟹ ?p ⊩ ⋅¬?φ⋅ ?env ⟷ ¬ (∃q::i∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env)›*) by auto end context G_generic1 begin lemma truth_lemma_Neg: assumes "φ∈formula" "env∈list(M)" "arity(φ)≤length(env)" and IH: "(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G),env) ⊨ φ" shows "(∃p∈G. p ⊩ Neg(φ) env) ⟷ M[G], map(val(G),env) ⊨ Neg(φ)" proof (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*), elim bexE (*‹⟦∃x::i∈?A::i. (?P::i ⇒ o)(x); ⋀x::i. ⟦x ∈ ?A; ?P(x)⟧ ⟹ ?Q::o⟧ ⟹ ?Q›*), rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goals: 1. ‹⋀p. ⟦p ∈ G; p ⊩ ⋅¬φ⋅ env; satisfies(M[G], ⋅¬φ⋅) ` map(val(G), env) ≠ 1⟧ ⟹ False› 2. ‹M[G], map(val(G), env) ⊨ ⋅¬φ⋅ ⟹ ∃p∈G. p ⊩ ⋅¬φ⋅ env›*) fix p assume "p∈G" "p ⊩ Neg(φ) env" "¬(M[G],map(val(G),env) ⊨ Neg(φ))" (*‹(p::i) ∈ (G::i)› ‹(p::i) ⊩ ⋅¬φ::i⋅ (env::i)› ‹satisfies((M::i)[G::i], ⋅¬φ::i⋅) ` map(val(G), env::i) ≠ 1›*) moreover note assms (*‹(φ::i) ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ›*) moreover from calculation (*‹p ∈ G› ‹(p::i) ⊩ ⋅¬φ::i⋅ (env::i)› ‹satisfies((M::i)[G::i], ⋅¬φ::i⋅) ` map(val(G), env::i) ≠ 1› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ›*) have "M[G], map(val(G),env) ⊨ φ" "p∈ℙ" using map_val_in_MG (*‹?env ∈ list(?M) ⟹ map(val(?G), ?env) ∈ list(?M[?G])›*) apply - (*goals: 1. ‹⟦(p::i) ∈ (G::i); p ⊩ ⋅¬φ::i⋅ (env::i); satisfies((M::i)[G], ⋅¬φ⋅) ` map(val(G), env) ≠ 1; φ ∈ formula; env ∈ list(M); arity(φ) ≤ length(env); (∃p::i∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; ⋀(env::i) (M::i) G::i. env ∈ list(M) ⟹ map(val(G), env) ∈ list(M[G])⟧ ⟹ M[G], map(val(G), env) ⊨ φ› 2. ‹⟦(p::i) ∈ (G::i); p ⊩ ⋅¬φ::i⋅ (env::i); satisfies((M::i)[G], ⋅¬φ⋅) ` map(val(G), env) ≠ 1; φ ∈ formula; env ∈ list(M); arity(φ) ≤ length(env); (∃p::i∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; ⋀(env::i) (M::i) G::i. env ∈ list(M) ⟹ map(val(G), env) ∈ list(M[G])⟧ ⟹ p ∈ ℙ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with IH (*‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ›*) obtain r where "r ⊩ φ env" "r∈G" "r∈ℙ" (*goal: ‹(⋀r. ⟦r ⊩ φ env; r ∈ G; r ∈ ℙ⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover from this (*‹r ⊩ φ env› ‹r ∈ G› ‹r ∈ ℙ›*) ‹p∈G› (*‹(p::i) ∈ (G::i)›*) obtain q where "q≼p" "q≼r" "q∈G" "q∈ℙ" "q∈M" (*goal: ‹(⋀q. ⟦q ≼ p; q ≼ r; q ∈ G; q ∈ ℙ; q ∈ M⟧ ⟹ thesis) ⟹ thesis›*) using transitivity[OF _ P_in_M] (*‹(?y::i) ∈ ℙ ⟹ ?y ∈ (M::i)›*) by blast moreover from calculation (*‹p ∈ G› ‹(p::i) ⊩ ⋅¬φ::i⋅ (env::i)› ‹satisfies(M[G], ⋅¬φ⋅) ` map(val(G), env) ≠ 1› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ› ‹r ⊩ φ env› ‹r ∈ G› ‹r ∈ ℙ› ‹q ≼ p› ‹(q::i) ≼ (r::i)› and more 3 facts*) have "q ⊩ φ env" using strengthening_lemma (*‹⟦?p ∈ ℙ; ?φ ∈ formula; ?r ∈ ℙ; ?r ≼ ?p; ?env ∈ list(M); arity(?φ) ≤ length(?env); ?p ⊩ ?φ ?env⟧ ⟹ ?r ⊩ ?φ ?env›*) by simp with assms (*‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ›*) ‹p ⊩ _ _› (*‹p ⊩ ⋅¬φ⋅ env›*) ‹q≼p› (*‹q ≼ p›*) ‹q∈M› (*‹q ∈ M›*) ‹p∈ℙ› (*‹p ∈ ℙ›*) ‹q∈ℙ› (*‹q ∈ ℙ›*) show False using Forces_Neg (*‹⟦(?p::i) ∈ ℙ; (?env::i) ∈ list(M::i); (?φ::i) ∈ formula⟧ ⟹ ?p ⊩ ⋅¬?φ⋅ ?env ⟷ ¬ (∃q::i∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env)›*) by auto next (*goal: ‹(M::i)[G::i], map(val(G), env::i) ⊨ ⋅¬φ::i⋅ ⟹ ∃p::i∈G. p ⊩ ⋅¬φ⋅ env›*) assume "M[G], map(val(G),env) ⊨ Neg(φ)" (*‹(M::i)[G::i], map(val(G), env::i) ⊨ ⋅¬φ::i⋅›*) with assms (*‹φ ∈ formula› ‹(env::i) ∈ list(M::i)› ‹arity(φ) ≤ length(env)› ‹(∃p::i∈G::i. p ⊩ (φ::i) (env::i)) ⟷ (M::i)[G], map(val(G), env) ⊨ φ›*) have "¬ (M[G], map(val(G),env) ⊨ φ)" using map_val_in_MG (*‹?env ∈ list(?M) ⟹ map(val(?G), ?env) ∈ list(?M[?G])›*) by simp let ?D = "{p∈ℙ. (p ⊩ φ env) ∨ (p ⊩ Neg(φ) env)}" from assms (*‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ›*) have "?D ∈ M" using separation_disj (*‹⟦separation(##M, ?P); separation(##M, ?Q)⟧ ⟹ separation(##M, λz. ?P(z) ∨ ?Q(z))›*) separation_closed (*‹⟦separation(##M, ?P); (##M)(?A)⟧ ⟹ (##M)(Collect(?A, ?P))›*) separation_forces (*‹⟦?φ ∈ formula; arity(?φ) ≤ length(?env); ?env ∈ list(M)⟧ ⟹ separation(##M, λp. p ⊩ ?φ ?env)›*) by simp moreover have "?D ⊆ ℙ" by auto moreover have "dense(?D)" proof (standard) (*goal: ‹⋀p::i. p ∈ ℙ ⟹ ∃d::i∈{p::i ∈ ℙ . p ⊩ (φ::i) (env::i) ∨ p ⊩ ⋅¬φ⋅ env}. d ≼ p›*) fix q assume "q∈ℙ" (*‹(q::i) ∈ ℙ›*) with assms (*‹φ ∈ formula› ‹(env::i) ∈ list(M::i)› ‹arity(φ::i) ≤ length(env::i)› ‹(∃p::i∈G::i. p ⊩ (φ::i) (env::i)) ⟷ (M::i)[G], map(val(G), env) ⊨ φ›*) show "∃d∈{p ∈ ℙ . (p ⊩ φ env) ∨ (p ⊩ Neg(φ) env)}. d≼ q" using refl_leq (*‹?r ∈ ℙ ⟹ ?r ≼ ?r›*) Forces_Neg (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ ⋅¬?φ⋅ ?env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ ?p ∧ q ⊩ ?φ ?env)›*) apply (cases "q ⊩ Neg(φ) env") (*goals: 1. ‹⟦φ ∈ formula; env ∈ list(M); arity(φ) ≤ length(env); (∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; q ∈ ℙ; ⋀r. r ∈ ℙ ⟹ r ≼ r; ⋀p env φ. ⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula⟧ ⟹ p ⊩ ⋅¬φ⋅ env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ p ∧ q ⊩ φ env); q ⊩ ⋅¬φ⋅ env⟧ ⟹ ∃d∈{p ∈ ℙ . p ⊩ φ env ∨ p ⊩ ⋅¬φ⋅ env}. d ≼ q› 2. ‹⟦φ ∈ formula; env ∈ list(M); arity(φ) ≤ length(env); (∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; q ∈ ℙ; ⋀r. r ∈ ℙ ⟹ r ≼ r; ⋀p env φ. ⟦p ∈ ℙ; env ∈ list(M); φ ∈ formula⟧ ⟹ p ⊩ ⋅¬φ⋅ env ⟷ ¬ (∃q∈M. q ∈ ℙ ∧ q ≼ p ∧ q ⊩ φ env); satisfies(M, forces(⋅¬φ⋅)) ` ([q, ℙ, leq, 𝟭] @ env) ≠ 1⟧ ⟹ ∃d∈{p ∈ ℙ . p ⊩ φ env ∨ p ⊩ ⋅¬φ⋅ env}. d ≼ q› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed ultimately obtain p where "p∈G" "(p ⊩ φ env) ∨ (p ⊩ Neg(φ) env)" (*goal: ‹(⋀p. ⟦p ∈ G; p ⊩ φ env ∨ p ⊩ ⋅¬φ⋅ env⟧ ⟹ thesis) ⟹ thesis›*) by blast then consider (1)"p ⊩ φ env" | (2)"p ⊩ Neg(φ) env" (*goal: ‹⟦(p::i) ⊩ (φ::i) (env::i) ⟹ thesis::o; p ⊩ ⋅¬φ⋅ env ⟹ thesis⟧ ⟹ thesis›*) by blast then show "∃p∈G. (p ⊩ Neg(φ) env)" proof (cases) (*goals: 1. ‹p ⊩ φ env ⟹ ∃p∈G. p ⊩ ⋅¬φ⋅ env› 2. ‹p ⊩ ⋅¬φ⋅ env ⟹ ∃p∈G. p ⊩ ⋅¬φ⋅ env›*) case 1 (*‹(p::i) ⊩ (φ::i) (env::i)›*) with ‹¬ (M[G],map(val(G),env) ⊨ φ)› (*‹satisfies((M::i)[G::i], φ::i) ` map(val(G), env::i) ≠ 1›*) ‹p∈G› (*‹(p::i) ∈ (G::i)›*) IH (*‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ›*) show "?thesis" (*goal: ‹∃p∈G. p ⊩ ⋅¬φ⋅ env›*) by blast next (*goal: ‹p ⊩ ⋅¬φ⋅ env ⟹ ∃p∈G. p ⊩ ⋅¬φ⋅ env›*) case 2 (*‹p ⊩ ⋅¬φ⋅ env›*) with ‹p∈G› (*‹p ∈ G›*) show "?thesis" (*goal: ‹∃p::i∈G::i. p ⊩ ⋅¬φ::i⋅ (env::i)›*) by blast qed qed lemma truth_lemma_And: assumes "env∈list(M)" "φ∈formula" "ψ∈formula" "arity(φ)≤length(env)" "arity(ψ) ≤ length(env)" and IH: "(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G),env) ⊨ φ" "(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G),env) ⊨ ψ" shows "(∃p∈G. (p ⊩ And(φ,ψ) env)) ⟷ M[G] , map(val(G),env) ⊨ And(φ,ψ)" using assms (*‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ› ‹(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ›*) map_val_in_MG (*‹?env ∈ list(?M) ⟹ map(val(?G), ?env) ∈ list(?M[?G])›*) Forces_And[OF M_genericD assms ( 1 - 5 )] (*‹?p ∈ G ⟹ ?p ⊩ ⋅φ ∧ ψ⋅ env ⟷ ?p ⊩ φ env ∧ ?p ⊩ ψ env›*) proof (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*), elim bexE (*‹⟦∃x∈?A. ?P(x); ⋀x. ⟦x ∈ ?A; ?P(x)⟧ ⟹ ?Q⟧ ⟹ ?Q›*)) (*goals: 1. ‹⋀p. ⟦env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(env); arity(ψ) ≤ length(env); (∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; (∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ; ⋀env M G. env ∈ list(M) ⟹ map(val(G), env) ∈ list(M[G]); ⋀p. p ∈ G ⟹ p ⊩ ⋅φ ∧ ψ⋅ env ⟷ p ⊩ φ env ∧ p ⊩ ψ env; env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(env); arity(ψ) ≤ length(env); (∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; (∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ; ⋀env M G. env ∈ list(M) ⟹ map(val(G), env) ∈ list(M[G]); ⋀p. p ∈ G ⟹ p ⊩ ⋅φ ∧ ψ⋅ env ⟷ p ⊩ φ env ∧ p ⊩ ψ env; p ∈ G; p ⊩ ⋅φ ∧ ψ⋅ env⟧ ⟹ M[G], map(val(G), env) ⊨ ⋅φ ∧ ψ⋅› 2. ‹⟦env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(env); arity(ψ) ≤ length(env); (∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; (∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ; ⋀env M G. env ∈ list(M) ⟹ map(val(G), env) ∈ list(M[G]); ⋀p. p ∈ G ⟹ p ⊩ ⋅φ ∧ ψ⋅ env ⟷ p ⊩ φ env ∧ p ⊩ ψ env; M[G], map(val(G), env) ⊨ ⋅φ ∧ ψ⋅⟧ ⟹ ∃p∈G. p ⊩ ⋅φ ∧ ψ⋅ env›*) fix p assume "p∈G" "p ⊩ And(φ,ψ) env" (*‹(p::i) ∈ (G::i)› ‹(p::i) ⊩ ⋅φ::i ∧ ψ::i⋅ (env::i)›*) with assms (*‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ::i) ≤ length(env::i)› ‹(∃p::i∈G::i. p ⊩ (φ::i) (env::i)) ⟷ (M::i)[G], map(val(G), env) ⊨ φ› ‹(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ›*) show "M[G], map(val(G),env) ⊨ And(φ,ψ)" using Forces_And[of _ _ φ ψ] (*‹⟦?p ∈ ℙ; ?env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(?env); arity(ψ) ≤ length(?env)⟧ ⟹ ?p ⊩ ⋅φ ∧ ψ⋅ ?env ⟷ ?p ⊩ φ ?env ∧ ?p ⊩ ψ ?env›*) map_val_in_MG (*‹?env ∈ list(?M) ⟹ map(val(?G), ?env) ∈ list(?M[?G])›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) by auto next (*goal: ‹⟦env ∈ list(M); φ ∈ formula; ψ ∈ formula; arity(φ) ≤ length(env); arity(ψ) ≤ length(env); (∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ; (∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ; ⋀env M G. env ∈ list(M) ⟹ map(val(G), env) ∈ list(M[G]); ⋀p. p ∈ G ⟹ p ⊩ ⋅φ ∧ ψ⋅ env ⟷ p ⊩ φ env ∧ p ⊩ ψ env; M[G], map(val(G), env) ⊨ ⋅φ ∧ ψ⋅⟧ ⟹ ∃p∈G. p ⊩ ⋅φ ∧ ψ⋅ env›*) assume "M[G], map(val(G),env) ⊨ And(φ,ψ)" (*‹(M::i)[G::i], map(val(G), env::i) ⊨ ⋅φ::i ∧ ψ::i⋅›*) moreover note assms (*‹env ∈ list(M)› ‹φ ∈ formula› ‹(ψ::i) ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ› ‹(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ›*) moreover from calculation (*‹M[G], map(val(G), env) ⊨ ⋅φ ∧ ψ⋅› ‹env ∈ list(M)› ‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ› ‹(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ›*) obtain q and r where "q ⊩ φ env" "r ⊩ ψ env" "q∈G" "r∈G" "r∈ℙ" "q∈ℙ" (*goal: ‹(⋀q r. ⟦q ⊩ φ env; r ⊩ ψ env; q ∈ G; r ∈ G; r ∈ ℙ; q ∈ ℙ⟧ ⟹ thesis) ⟹ thesis›*) using map_val_in_MG (*‹(?env::i) ∈ list(?M::i) ⟹ map(val(?G::i), ?env) ∈ list(?M[?G])›*) Forces_And[OF M_genericD assms ( 1 - 5 )] (*‹?p ∈ G ⟹ ?p ⊩ ⋅φ ∧ ψ⋅ env ⟷ ?p ⊩ φ env ∧ ?p ⊩ ψ env›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) by auto moreover from calculation (*‹M[G], map(val(G), env) ⊨ ⋅φ ∧ ψ⋅› ‹(env::i) ∈ list(M::i)› ‹φ ∈ formula› ‹ψ ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ› ‹(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ› ‹(q::i) ⊩ (φ::i) (env::i)› ‹r ⊩ ψ env› ‹(q::i) ∈ (G::i)› ‹r ∈ G› and more 2 facts*) obtain p where "p≼q" "p≼r" "p∈G" (*goal: ‹(⋀p. ⟦p ≼ q; p ≼ r; p ∈ G⟧ ⟹ thesis) ⟹ thesis›*) by auto moreover from calculation (*‹M[G], map(val(G), env) ⊨ ⋅φ ∧ ψ⋅› ‹env ∈ list(M)› ‹φ ∈ formula› ‹(ψ::i) ∈ formula› ‹arity(φ) ≤ length(env)› ‹arity(ψ) ≤ length(env)› ‹(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G), env) ⊨ φ› ‹(∃p∈G. p ⊩ ψ env) ⟷ M[G], map(val(G), env) ⊨ ψ› ‹(q::i) ⊩ (φ::i) (env::i)› ‹r ⊩ ψ env› ‹q ∈ G› ‹r ∈ G› and more 5 facts*) have "(p ⊩ φ env) ∧ (p ⊩ ψ env)" using strengthening_lemma[OF M_genericD] (*‹⟦?p ∈ G; ?φ ∈ formula; ?r ∈ ℙ; ?r ≼ ?p; ?env ∈ list(M); arity(?φ) ≤ length(?env); ?p ⊩ ?φ ?env⟧ ⟹ ?r ⊩ ?φ ?env›*) by force ultimately show "∃p∈G. (p ⊩ And(φ,ψ) env)" using Forces_And[OF M_genericD assms ( 1 - 5 )] (*‹(?p::i) ∈ (G::i) ⟹ ?p ⊩ ⋅φ::i ∧ ψ::i⋅ (env::i) ⟷ ?p ⊩ φ env ∧ ?p ⊩ ψ env›*) by auto qed end definition ren_truth_lemma :: "i⇒i" where "ren_truth_lemma(φ) ≡ Exists(Exists(Exists(Exists(Exists( And(Equal(0,5),And(Equal(1,8),And(Equal(2,9),And(Equal(3,10),And(Equal(4,6), iterates(λp. incr_bv(p)`5 , 6, φ)))))))))))" lemma ren_truth_lemma_type[TC] : "φ∈formula ⟹ ren_truth_lemma(φ) ∈formula" unfolding ren_truth_lemma_def (*goal: ‹(φ::i) ∈ formula ⟹ (⋅∃(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅0 = 5⋅ ∧ ⋅⋅1 = 8⋅ ∧ ⋅⋅2 = 9⋅ ∧ ⋅⋅3 = 10⋅ ∧ ⋅⋅4 = 6⋅ ∧ (λp::i. incr_bv(p) ` 5)^6 (φ)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)⋅) ∈ formula›*) by simp lemma arity_ren_truth : assumes "φ∈formula" shows "arity(ren_truth_lemma(φ)) ≤ 6 ∪ succ(arity(φ))" proof - consider (lt) "5 <arity(φ)" | (ge) "¬ 5 < arity(φ)" by auto then show ?thesis proof cases case lt consider (a) "5<arity(φ)+⇩ω5" | (b) "arity(φ)+⇩ω5 ≤ 5" using not_lt_iff_le ‹φ∈_› by force then show ?thesis proof cases case a with ‹φ∈_› lt have "5 < succ(arity(φ))" "5<arity(φ)+⇩ω2" "5<arity(φ)+⇩ω3" "5<arity(φ)+⇩ω4" using succ_ltI by auto with ‹φ∈_› have c:"arity(iterates(λp. incr_bv(p)`5,5,φ)) = 5+⇩ωarity(φ)" (is "arity(?φ') = _") using arity_incr_bv_lemma lt a by simp with ‹φ∈_› have "arity(incr_bv(?φ')`5) = 6+⇩ωarity(φ)" using arity_incr_bv_lemma[of ?φ' 5] a by auto with ‹φ∈_› show ?thesis unfolding ren_truth_lemma_def using pred_Un_distrib union_abs1 Un_assoc[symmetric] a c union_abs2 by (simp add:arity) next case b with ‹φ∈_› lt have "5 < succ(arity(φ))" "5<arity(φ)+⇩ω2" "5<arity(φ)+⇩ω3" "5<arity(φ)+⇩ω4" "5<arity(φ)+⇩ω5" using succ_ltI by auto with ‹φ∈_› have "arity(iterates(λp. incr_bv(p)`5,6,φ)) = 6+⇩ωarity(φ)" (is "arity(?φ') = _") using arity_incr_bv_lemma lt by simp with ‹φ∈_› show ?thesis unfolding ren_truth_lemma_def using pred_Un_distrib union_abs1 Un_assoc[symmetric] union_abs2 by (simp add:arity) qed next case ge with ‹φ∈_› have "arity(φ) ≤ 5" "pred^5(arity(φ)) ≤ 5" using not_lt_iff_le le_trans[OF le_pred] by auto with ‹φ∈_› have "arity(iterates(λp. incr_bv(p)`5,6,φ)) = arity(φ)" "arity(φ)≤6" "pred^5(arity(φ)) ≤ 6" using arity_incr_bv_lemma ge le_trans[OF ‹arity(φ)≤5›] le_trans[OF ‹pred^5(arity(φ))≤5›] by auto with ‹arity(φ) ≤ 5› ‹φ∈_› ‹pred^5(_) ≤ 5› show ?thesis unfolding ren_truth_lemma_def using pred_Un_distrib union_abs1 Un_assoc[symmetric] union_abs2 by (simp add:arity) qed qed lemma sats_ren_truth_lemma: "[q,b,d,a1,a2,a3] @ env ∈ list(M) ⟹ φ ∈ formula ⟹ (M, [q,b,d,a1,a2,a3] @ env ⊨ ren_truth_lemma(φ) ) ⟷ (M, [q,a1,a2,a3,b] @ env ⊨ φ)" unfolding ren_truth_lemma_def (*goal: ‹⟦[q, b, d, a1, a2, a3] @ env ∈ list(M); φ ∈ formula⟧ ⟹ (M, [q, b, d, a1, a2, a3] @ env ⊨ (⋅∃(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅0 = 5⋅ ∧ ⋅⋅1 = 8⋅ ∧ ⋅⋅2 = 9⋅ ∧ ⋅⋅3 = 10⋅ ∧ ⋅⋅4 = 6⋅ ∧ (λp. incr_bv(p) ` 5)^6 (φ)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)⋅)) ⟷ M, [q, a1, a2, a3, b] @ env ⊨ φ›*) apply (insert sats_incr_bv_iff [of _ _ M _ "[q,a1,a2,a3,b]"] (*‹⟦?p ∈ formula; ?env ∈ list(M); ?x ∈ M; [q, a1, a2, a3, b] ∈ list(M)⟧ ⟹ (M, [q, a1, a2, a3, b] @ Cons(?x, ?env) ⊨ incr_bv(?p) ` length([q, a1, a2, a3, b])) ⟷ M, [q, a1, a2, a3, b] @ ?env ⊨ ?p›*)) (*goal: ‹⟦[q, b, d, a1, a2, a3] @ env ∈ list(M); φ ∈ formula⟧ ⟹ (M, [q, b, d, a1, a2, a3] @ env ⊨ (⋅∃(⋅∃(⋅∃(⋅∃(⋅∃⋅⋅0 = 5⋅ ∧ ⋅⋅1 = 8⋅ ∧ ⋅⋅2 = 9⋅ ∧ ⋅⋅3 = 10⋅ ∧ ⋅⋅4 = 6⋅ ∧ (λp. incr_bv(p) ` 5)^6 (φ)⋅⋅⋅⋅⋅⋅)⋅)⋅)⋅)⋅)) ⟷ M, [q, a1, a2, a3, b] @ env ⊨ φ›*) by simp context forcing_data1 begin lemma truth_lemma' : assumes "φ∈formula" "env∈list(M)" "arity(φ) ≤ succ(length(env))" shows "separation(##M,λd. ∃b∈M. ∀q∈ℙ. q≼d ⟶ ¬(q ⊩ φ ([b]@env)))" proof (-) (*goal: ‹separation(##M, λd. ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1)›*) let ?rel_pred = "λM x a1 a2 a3. ∃b∈M. ∀q∈M. q∈a1 ∧ is_leq(##M,a2,q,x) ⟶ ¬(M, [q,a1,a2,a3,b] @ env ⊨ forces(φ))" let ?ψ = "Exists(Forall(Implies(And(Member(0,3),is_leq_fm(4,0,2)), Neg(ren_truth_lemma(forces(φ))))))" have "q∈M" if "q∈ℙ" for q using that (*‹q ∈ ℙ›*) transitivity[OF _ P_in_M] (*‹(?y::i) ∈ ℙ ⟹ ?y ∈ (M::i)›*) by simp then have 1: "∀q∈M. q∈ℙ ∧ R(q) ⟶ Q(q) ⟹ (∀q∈ℙ. R(q) ⟶ Q(q))" for R and Q by auto then have "⟦b ∈ M; ∀q∈M. q ∈ ℙ ∧ q ≼ d ⟶ ¬(q ⊩ φ ([b]@env))⟧ ⟹ ∃c∈M. ∀q∈ℙ. q ≼ d ⟶ ¬(q ⊩ φ ([c]@env))" for b and d by (rule bexI (*‹⟦?P(?x); ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P(x)›*), simp_all) then have "?rel_pred(M,d,ℙ,leq,𝟭) ⟷ (∃b∈M. ∀q∈ℙ. q≼d ⟶ ¬(q ⊩ φ ([b]@env)))" if "d∈M" for d using that (*‹d ∈ M›*) leq_abs (*‹⟦?l ∈ M; ?q ∈ M; ?p ∈ M⟧ ⟹ is_leq(##M, ?l, ?q, ?p) ⟷ ⟨?q, ?p⟩ ∈ ?l›*) assms (*‹φ ∈ formula› ‹(env::i) ∈ list(M::i)› ‹arity(φ) ≤ succ(length(env))›*) by auto moreover have "?ψ∈formula" using assms (*‹φ ∈ formula› ‹(env::i) ∈ list(M::i)› ‹arity(φ::i) ≤ succ(length(env::i))›*) by simp moreover have "(M, [d,ℙ,leq,𝟭]@env ⊨ ?ψ) ⟷ ?rel_pred(M,d,ℙ,leq,𝟭)" if "d∈M" for d using assms (*‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ succ(length(env))›*) that (*‹d ∈ M›*) sats_is_leq_fm (*‹⟦?l ∈ ω; ?q ∈ ω; ?p ∈ ω; ?env ∈ list(?Aa); 0 ∈ ?Aa⟧ ⟹ (?Aa, ?env ⊨ ⋅?q≼⇗?l⇖?p⋅) ⟷ is_leq(##?Aa, nth(?l, ?env), nth(?q, ?env), nth(?p, ?env))›*) sats_ren_truth_lemma (*‹⟦[?q, ?b, ?d, ?a1.0, ?a2.0, ?a3.0] @ ?env ∈ list(?M); ?φ ∈ formula⟧ ⟹ (?M, [?q, ?b, ?d, ?a1.0, ?a2.0, ?a3.0] @ ?env ⊨ ren_truth_lemma(?φ)) ⟷ ?M, [?q, ?a1.0, ?a2.0, ?a3.0, ?b] @ ?env ⊨ ?φ›*) zero_in_M (*‹0 ∈ M›*) by simp moreover have "arity(?ψ) ≤ 4+⇩ωlength(env)" proof (-) (*goal: ‹arity((⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ::i))⋅⋅⋅)⋅)) ≤ 4 +⇩ω length(env::i)›*) have eq: "arity(is_leq_fm(4, 0, 2)) = 5" using arity_is_leq_fm (*‹⟦?l ∈ ω; ?q ∈ ω; ?p ∈ ω⟧ ⟹ arity(⋅?q≼⇗?l⇖?p⋅) = succ(?q) ∪ succ(?p) ∪ succ(?l)›*) succ_Un_distrib (*‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ succ(?i ∪ ?j) = succ(?i) ∪ succ(?j)›*) ord_simp_union (*‹⟦Ord(?i); Ord(?j)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) by simp with ‹φ∈_› (*‹φ ∈ formula›*) have "arity(?ψ) = 3 ∪ (pred^2(arity(ren_truth_lemma(forces(φ)))))" using union_abs1 (*‹?i ≤ ?j ⟹ ?i ∪ ?j = ?j›*) pred_Un_distrib (*‹⟦?i ∈ ω; ?j ∈ ω⟧ ⟹ pred(?i ∪ ?j) = pred(?i) ∪ pred(?j)›*) by (simp add:arity (*‹⟦?φ ∈ formula; ?t ∈ ω; ?f ∈ ω; ?r ∈ ω⟧ ⟹ arity(is_If_fm(?φ, ?t, ?f, ?r)) = arity(?φ) ∪ succ(?t) ∪ succ(?r) ∪ succ(?f)› ‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p → ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))› ‹⟦?t1.0 ∈ ω; ?t2.0 ∈ ω; ?up ∈ ω⟧ ⟹ arity(⋅{?t1.0,?t2.0} is ?up ⋅) = ⋃{succ(?t1.0), succ(?t2.0), succ(?up)}› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅⟨?x,?y⟩ is ?z ⋅) = succ(?x) ∪ succ(?y) ∪ succ(?z)› ‹⟦?r ∈ ω; ?s ∈ ω; ?t ∈ ω⟧ ⟹ arity(⋅?r ∘ ?s is ?t ⋅) = succ(?t) ∪ succ(?s) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅dom(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?r ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅ran(?r) is ?z ⋅) = succ(?z) ∪ succ(?r)› ‹⟦?x ∈ ω; ?y ∈ ω; ?z ∈ ω⟧ ⟹ arity(⋅?x ∪ ?y is ?z ⋅) = succ(?z) ∪ succ(?x) ∪ succ(?y)› and more 191 facts*)) moreover have "... ≤ 3 ∪ (pred(pred(6 ∪ succ(arity(forces(φ))))))" (is "_ ≤ ?r") using ‹φ∈_› (*‹φ ∈ formula›*) Un_le_compat[OF le_refl [ of 3 ]] (*‹⟦Ord(3); ?q ≤ ?r; Ord(3); Ord(3); Ord(?q); Ord(?r)⟧ ⟹ 3 ∪ ?q ≤ 3 ∪ ?r›*) le_imp_subset (*‹?i ≤ ?j ⟹ ?i ⊆ ?j›*) arity_ren_truth[of "forces(φ)"] (*‹forces(φ) ∈ formula ⟹ arity(ren_truth_lemma(forces(φ))) ≤ 6 ∪ succ(arity(forces(φ)))›*) pred_mono (*‹⟦?m ∈ ω; ?n ≤ ?m⟧ ⟹ pred(?n) ≤ pred(?m)›*) by auto finally (*calculation: ‹arity((⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅)) ≤ 3 ∪ pred(pred(6 ∪ succ(arity(forces(φ)))))›*) have "arity(?ψ) ≤ ?r" by simp have i: "?r ≤ 4 ∪ pred(arity(forces(φ)))" using pred_Un_distrib (*‹⟦(?i::i) ∈ ω; (?j::i) ∈ ω⟧ ⟹ pred(?i ∪ ?j) = pred(?i) ∪ pred(?j)›*) pred_succ_eq (*‹pred(succ(?y)) = ?y›*) ‹φ∈_› (*‹φ ∈ formula›*) Un_assoc[symmetric] (*‹(?A::i) ∪ ((?B::i) ∪ (?C::i)) = ?A ∪ ?B ∪ ?C›*) union_abs1 (*‹?i ≤ ?j ⟹ ?i ∪ ?j = ?j›*) by simp have h: "4 ∪ pred(arity(forces(φ))) ≤ 4 ∪ (4+⇩ωlength(env))" using ‹env∈_› (*‹env ∈ list(M)›*) add_commute (*‹?m +⇩ω ?n = ?n +⇩ω ?m›*) ‹φ∈_› (*‹φ ∈ formula›*) Un_le_compat[of 4 4, OF _ pred_mono [ OF _ arity_forces_le [ OF _ _ ‹arity(φ)≤_› ] ]] (*‹⟦4 ≤ 4; 4 +⇩ω succ(length(env)) ∈ ω; φ ∈ formula; succ(length(env)) ∈ ω; Ord(4); Ord(4); Ord(pred(arity(forces(φ)))); Ord(pred(4 +⇩ω succ(length(env))))⟧ ⟹ 4 ∪ pred(arity(forces(φ))) ≤ 4 ∪ pred(4 +⇩ω succ(length(env)))›*) ‹env∈_› (*‹env ∈ list(M)›*) by auto with ‹φ∈_› (*‹φ ∈ formula›*) ‹env∈_› (*‹env ∈ list(M)›*) show "?thesis" (*goal: ‹arity((⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅)) ≤ 4 +⇩ω length(env)›*) using le_trans[OF ‹arity(?ψ) ≤ ?r› le_trans [ OF i h ]] (*‹arity((⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ::i))⋅⋅⋅)⋅)) ≤ 4 ∪ (4 +⇩ω length(env::i))›*) ord_simp_union (*‹⟦Ord(?i::i); Ord(?j::i)⟧ ⟹ ?i ∪ ?j = max(?i, ?j)› ‹⟦Ord(?i); Ord(?j)⟧ ⟹ Ord(max(?i, ?j))› ‹max(?x, ?y) ≡ if ?x ≤ ?y then ?y else ?x›*) by simp qed ultimately show "?thesis" (*goal: ‹separation(##M, λd. ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1)›*) using assms (*‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ::i) ≤ succ(length(env::i))›*) separation_ax[of "?ψ" "[ℙ,leq,𝟭]@env"] (*‹⟦(⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅) ∈ formula; [ℙ, leq, 𝟭] @ env ∈ list(M); arity((⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅)) ≤ 1 +⇩ω length([ℙ, leq, 𝟭] @ env)⟧ ⟹ separation(##M, λx. M, [x] @ [ℙ, leq, 𝟭] @ env ⊨ (⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅))›*) separation_cong[of "##M" "λy. (M, [y,ℙ,leq,𝟭]@env ⊨?ψ)"] (*‹(⋀x. (##M)(x) ⟹ (M, [x, ℙ, leq, 𝟭] @ env ⊨ (⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅)) ⟷ ?P'(x)) ⟹ separation(##M, λx. M, [x, ℙ, leq, 𝟭] @ env ⊨ (⋅∃(⋅∀⋅⋅⋅0 ∈ 3⋅ ∧ ⋅0≼⇗4⇖2⋅⋅ → ⋅¬ren_truth_lemma(forces(φ))⋅⋅⋅)⋅)) ⟷ separation(##M, λx. ?P'(x))›*) by simp qed end context G_generic1 begin lemma truth_lemma: assumes "φ∈formula" "env∈list(M)" "arity(φ)≤length(env)" shows "(∃p∈G. p ⊩ φ env) ⟷ M[G], map(val(G),env) ⊨ φ" using assms (*‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) proof (induct arbitrary:env) (*goals: 1. ‹⋀(x::i) (y::i) env::i. ⟦x ∈ ω; y ∈ ω; env ∈ list(M::i); arity(⋅x ∈ y⋅) ≤ length(env)⟧ ⟹ (∃p::i∈G::i. p ⊩ ⋅x ∈ y⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅x ∈ y⋅› 2. ‹⋀(x::i) (y::i) env::i. ⟦x ∈ ω; y ∈ ω; env ∈ list(M::i); arity(⋅x = y⋅) ≤ length(env)⟧ ⟹ (∃p::i∈G::i. p ⊩ ⋅x = y⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅x = y⋅› 3. ‹⋀(p::i) (q::i) env::i. ⟦p ∈ formula; ⋀env::i. ⟦env ∈ list(M::i); arity(p) ≤ length(env)⟧ ⟹ (∃pa::i∈G::i. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; q ∈ formula; ⋀env::i. ⟦env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ (∃p::i∈G. p ⊩ q env) ⟷ M[G], map(val(G), env) ⊨ q; env ∈ list(M); arity(⋅¬(p ∧ q)⋅) ≤ length(env)⟧ ⟹ (∃pa::i∈G. pa ⊩ ⋅¬(p ∧ q)⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅¬(p ∧ q)⋅› 4. ‹⋀(p::i) env::i. ⟦p ∈ formula; ⋀env::i. ⟦env ∈ list(M::i); arity(p) ≤ length(env)⟧ ⟹ (∃pa::i∈G::i. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; env ∈ list(M); arity((⋅∀p⋅)) ≤ length(env)⟧ ⟹ (∃pa::i∈G. pa ⊩ (⋅∀p⋅) env) ⟷ M[G], map(val(G), env) ⊨ (⋅∀p⋅)›*) case (Member x y) (*‹(x::i) ∈ ω› ‹y ∈ ω› ‹env ∈ list(M)› ‹arity(⋅x ∈ y⋅) ≤ length(env)›*) then show "?case" (*goal: ‹(∃p::i∈G::i. p ⊩ ⋅x::i ∈ y::i⋅ (env::i)) ⟷ (M::i)[G], map(λa::i. val(G, a), env) ⊨ ⋅x ∈ y⋅›*) using truth_lemma_mem[OF ‹env∈list(M)› ‹x∈nat› ‹y∈nat›] (*‹⟦x < length(env); y < length(env)⟧ ⟹ (∃p∈G. p ⊩ ⋅x ∈ y⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅x ∈ y⋅›*) arities_at_aux (*‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?n < length(?env)› ‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?m < length(?env)›*) by simp next (*goals: 1. ‹⋀x y env. ⟦x ∈ ω; y ∈ ω; env ∈ list(M); arity(⋅x = y⋅) ≤ length(env)⟧ ⟹ (∃p∈G. p ⊩ ⋅x = y⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅x = y⋅› 2. ‹⋀p q env. ⟦p ∈ formula; ⋀env. ⟦env ∈ list(M); arity(p) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; q ∈ formula; ⋀env. ⟦env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ (∃p∈G. p ⊩ q env) ⟷ M[G], map(val(G), env) ⊨ q; env ∈ list(M); arity(⋅¬(p ∧ q)⋅) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ ⋅¬(p ∧ q)⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅¬(p ∧ q)⋅› 3. ‹⋀p env. ⟦p ∈ formula; ⋀env. ⟦env ∈ list(M); arity(p) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; env ∈ list(M); arity((⋅∀p⋅)) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ (⋅∀p⋅) env) ⟷ M[G], map(val(G), env) ⊨ (⋅∀p⋅)›*) case (Equal x y) (*‹x ∈ ω› ‹y ∈ ω› ‹env ∈ list(M)› ‹arity(⋅x = y⋅) ≤ length(env)›*) then show "?case" (*goal: ‹(∃p::i∈G::i. p ⊩ ⋅x::i = y::i⋅ (env::i)) ⟷ (M::i)[G], map(λa::i. val(G, a), env) ⊨ ⋅x = y⋅›*) using truth_lemma_eq[OF ‹env∈list(M)› ‹x∈nat› ‹y∈nat›] (*‹⟦x < length(env); y < length(env)⟧ ⟹ (∃p∈G. p ⊩ ⋅x = y⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅x = y⋅›*) arities_at_aux (*‹⟦?n ∈ ω; ?m ∈ ω; ?env ∈ list(?M); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?n < length(?env)› ‹⟦(?n::i) ∈ ω; (?m::i) ∈ ω; (?env::i) ∈ list(?M::i); succ(?n) ∪ succ(?m) ≤ length(?env)⟧ ⟹ ?m < length(?env)›*) by simp next (*goals: 1. ‹⋀p q env. ⟦p ∈ formula; ⋀env. ⟦env ∈ list(M); arity(p) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; q ∈ formula; ⋀env. ⟦env ∈ list(M); arity(q) ≤ length(env)⟧ ⟹ (∃p∈G. p ⊩ q env) ⟷ M[G], map(val(G), env) ⊨ q; env ∈ list(M); arity(⋅¬(p ∧ q)⋅) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ ⋅¬(p ∧ q)⋅ env) ⟷ M[G], map(val(G), env) ⊨ ⋅¬(p ∧ q)⋅› 2. ‹⋀p env. ⟦p ∈ formula; ⋀env. ⟦env ∈ list(M); arity(p) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; env ∈ list(M); arity((⋅∀p⋅)) ≤ length(env)⟧ ⟹ (∃pa∈G. pa ⊩ (⋅∀p⋅) env) ⟷ M[G], map(val(G), env) ⊨ (⋅∀p⋅)›*) case (Nand φ ψ) (*‹φ ∈ formula› ‹⟦(?env::i) ∈ list(M::i); arity(φ::i) ≤ length(?env)⟧ ⟹ (∃p::i∈G::i. p ⊩ φ ?env) ⟷ M[G], map(λa::i. val(G, a), ?env) ⊨ φ› ‹(ψ::i) ∈ formula› ‹⟦?env ∈ list(M); arity(ψ) ≤ length(?env)⟧ ⟹ (∃p∈G. p ⊩ ψ ?env) ⟷ M[G], map(λa. val(G, a), ?env) ⊨ ψ› ‹env ∈ list(M)› ‹arity(⋅¬(φ ∧ ψ)⋅) ≤ length(env)›*) then show "?case" (*goal: ‹(∃p∈G. p ⊩ ⋅¬(φ ∧ ψ)⋅ env) ⟷ M[G], map(λa. val(G, a), env) ⊨ ⋅¬(φ ∧ ψ)⋅›*) using truth_lemma_And (*‹⟦(?env::i) ∈ list(M::i); (?φ::i) ∈ formula; (?ψ::i) ∈ formula; arity(?φ) ≤ length(?env); arity(?ψ) ≤ length(?env); (∃p::i∈G::i. p ⊩ ?φ ?env) ⟷ M[G], map(val(G), ?env) ⊨ ?φ; (∃p::i∈G. p ⊩ ?ψ ?env) ⟷ M[G], map(val(G), ?env) ⊨ ?ψ⟧ ⟹ (∃p::i∈G. p ⊩ ⋅?φ ∧ ?ψ⋅ ?env) ⟷ M[G], map(val(G), ?env) ⊨ ⋅?φ ∧ ?ψ⋅›*) truth_lemma_Neg[of "⋅φ ∧ ψ⋅"] (*‹⟦⋅φ ∧ ψ⋅ ∈ formula; ?env ∈ list(M); arity(⋅φ ∧ ψ⋅) ≤ length(?env); (∃p∈G. p ⊩ ⋅φ ∧ ψ⋅ ?env) ⟷ M[G], map(val(G), ?env) ⊨ ⋅φ ∧ ψ⋅⟧ ⟹ (∃p∈G. p ⊩ ⋅¬⋅φ ∧ ψ⋅⋅ ?env) ⟷ M[G], map(val(G), ?env) ⊨ ⋅¬⋅φ ∧ ψ⋅⋅›*) Forces_Nand_alt (*‹⟦(?p::i) ∈ ℙ; (?env::i) ∈ list(M::i); (?φ::i) ∈ formula; (?ψ::i) ∈ formula; arity(?φ) ≤ length(?env); arity(?ψ) ≤ length(?env)⟧ ⟹ ?p ⊩ ⋅¬(?φ ∧ ?ψ)⋅ ?env ⟷ ?p ⊩ ⋅¬⋅?φ ∧ ?ψ⋅⋅ ?env›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) map_val_in_MG (*‹(?env::i) ∈ list(?M::i) ⟹ map(val(?G::i), ?env) ∈ list(?M[?G])›*) arity_Nand_le[of φ ψ] (*‹⟦(φ::i) ∈ formula; (ψ::i) ∈ formula; arity(⋅¬(φ ∧ ψ)⋅) ≤ length(?env::i); ?env ∈ list(?A::i)⟧ ⟹ arity(φ) ≤ length(?env)› ‹⟦φ ∈ formula; ψ ∈ formula; arity(⋅¬(φ ∧ ψ)⋅) ≤ length(?env); ?env ∈ list(?A)⟧ ⟹ arity(ψ) ≤ length(?env)›*) FOL_arities (*‹arity(⋅?p ∧ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ∨ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p::i → ?q::i⋅) = arity(?p) ∪ arity(?q)› ‹arity(⋅?p ↔ ?q⋅) = arity(?p) ∪ arity(?q)› ‹arity((⋅∃?p⋅)) = pred(arity(?p))›*) by auto next (*goal: ‹⋀(p::i) env::i. ⟦p ∈ formula; ⋀env::i. ⟦env ∈ list(M::i); arity(p) ≤ length(env)⟧ ⟹ (∃pa::i∈G::i. pa ⊩ p env) ⟷ M[G], map(val(G), env) ⊨ p; env ∈ list(M); arity((⋅∀p⋅)) ≤ length(env)⟧ ⟹ (∃pa::i∈G. pa ⊩ (⋅∀p⋅) env) ⟷ M[G], map(val(G), env) ⊨ (⋅∀p⋅)›*) case (Forall φ) (*‹φ ∈ formula› ‹⟦?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ (∃p∈G. p ⊩ φ ?env) ⟷ M[G], map(λa. val(G, a), ?env) ⊨ φ› ‹(env::i) ∈ list(M::i)› ‹arity((⋅∀φ::i⋅)) ≤ length(env::i)›*) then show "?case" (*goal: ‹(∃p∈G. p ⊩ (⋅∀φ⋅) env) ⟷ M[G], map(λa. val(G, a), env) ⊨ (⋅∀φ⋅)›*) proof (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*)) (*goals: 1. ‹⟦φ ∈ formula; ⋀env. ⟦env ∈ list(M); arity(φ) ≤ length(env)⟧ ⟹ (∃p∈G. p ⊩ φ env) ⟷ M[G], map(λa. val(G, a), env) ⊨ φ; env ∈ list(M); arity((⋅∀φ⋅)) ≤ length(env); ∃p∈G. p ⊩ (⋅∀φ⋅) env⟧ ⟹ M[G], map(λa. val(G, a), env) ⊨ (⋅∀φ⋅)› 2. ‹⟦φ ∈ formula; ⋀env. ⟦env ∈ list(M); arity(φ) ≤ length(env)⟧ ⟹ (∃p∈G. p ⊩ φ env) ⟷ M[G], map(λa. val(G, a), env) ⊨ φ; env ∈ list(M); arity((⋅∀φ⋅)) ≤ length(env); M[G], map(λa. val(G, a), env) ⊨ (⋅∀φ⋅)⟧ ⟹ ∃p∈G. p ⊩ (⋅∀φ⋅) env›*) assume "∃p∈G. (p ⊩ Forall(φ) env)" (*‹∃p::i∈G::i. p ⊩ (⋅∀φ::i⋅) (env::i)›*) then obtain p where "p∈G" "p∈M" "p∈ℙ" "p ⊩ Forall(φ) env" (*goal: ‹(⋀p. ⟦p ∈ G; p ∈ M; p ∈ ℙ; p ⊩ (⋅∀φ⋅) env⟧ ⟹ thesis) ⟹ thesis›*) using transitivity[OF _ P_in_M] (*‹(?y::i) ∈ ℙ ⟹ ?y ∈ (M::i)›*) by auto with ‹env∈list(M)› (*‹env ∈ list(M)›*) ‹φ∈formula› (*‹φ ∈ formula›*) have "p ⊩ φ ([x]@env)" if "x∈M" for x using that (*‹x ∈ M›*) Forces_Forall (*‹⟦?p ∈ ℙ; ?env ∈ list(M); ?φ ∈ formula⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ (∀x∈M. ?p ⊩ ?φ [x] @ ?env)›*) by simp with ‹p∈G› (*‹p ∈ G›*) ‹φ∈formula› (*‹φ ∈ formula›*) ‹env∈_› (*‹env ∈ list(M)›*) ‹arity(Forall(φ)) ≤ length(env)› (*‹arity((⋅∀φ::i⋅)) ≤ length(env::i)›*) Forall(2)[of "Cons(_,env)"] (*‹⟦Cons(?uu3, env) ∈ list(M); arity(φ) ≤ length(Cons(?uu3, env))⟧ ⟹ (∃p∈G. p ⊩ φ Cons(?uu3, env)) ⟷ M[G], map(λa. val(G, a), Cons(?uu3, env)) ⊨ φ›*) show "M[G], map(val(G),env) ⊨ Forall(φ)" using pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) map_val_in_MG (*‹?env ∈ list(?M) ⟹ map(val(?G), ?env) ∈ list(?M[?G])›*) by (auto iff:GenExt_iff (*‹?x ∈ M[?G] ⟷ (∃τ∈M. ?x = val(?G, τ))›*)) next (*goal: ‹⟦(φ::i) ∈ formula; ⋀env::i. ⟦env ∈ list(M::i); arity(φ) ≤ length(env)⟧ ⟹ (∃p::i∈G::i. p ⊩ φ env) ⟷ M[G], map(λa::i. val(G, a), env) ⊨ φ; (env::i) ∈ list(M); arity((⋅∀φ⋅)) ≤ length(env); M[G], map(λa::i. val(G, a), env) ⊨ (⋅∀φ⋅)⟧ ⟹ ∃p::i∈G. p ⊩ (⋅∀φ⋅) env›*) assume "M[G], map(val(G),env) ⊨ Forall(φ)" (*‹(M::i)[G::i], map(val(G), env::i) ⊨ (⋅∀φ::i⋅)›*) let ?D1 = "{d∈ℙ. (d ⊩ Forall(φ) env)}" let ?D2 = "{d∈ℙ. ∃b∈M. ∀q∈ℙ. q≼d ⟶ ¬(q ⊩ φ ([b]@env))}" define D where "D ≡ ?D1 ∪ ?D2" note ‹arity(Forall(φ)) ≤ length(env)› (*‹arity((⋅∀φ⋅)) ≤ length(env)›*) ‹φ∈formula› (*‹φ ∈ formula›*) ‹env∈list(M)› (*‹env ∈ list(M)›*) moreover from this (*‹arity((⋅∀φ⋅)) ≤ length(env)› ‹φ ∈ formula› ‹env ∈ list(M)›*) have "arφ": "arity(φ)≤succ(length(env))" using pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) by simp moreover from calculation (*‹arity((⋅∀φ⋅)) ≤ length(env)› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ::i) ≤ succ(length(env::i))›*) have "?D1∈M" using Collect_forces (*‹⟦?φ ∈ formula; arity(?φ) ≤ length(?env); ?env ∈ list(M)⟧ ⟹ {p ∈ ℙ . p ⊩ ?φ ?env} ∈ M›*) by simp moreover from ‹env∈list(M)› (*‹env ∈ list(M)›*) ‹φ∈formula› (*‹φ ∈ formula›*) have "?D2∈M" using truth_lemma'[of φ] (*‹⟦φ ∈ formula; ?env ∈ list(M); arity(φ) ≤ succ(length(?env))⟧ ⟹ separation(##M, λd. ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ ?env) ≠ 1)›*) separation_closed (*‹⟦separation(##M, ?P); (##M)(?A)⟧ ⟹ (##M)(Collect(?A, ?P))›*) "arφ" (*‹arity(φ) ≤ succ(length(env))›*) by simp ultimately have "D∈M" unfolding D_def (*goal: ‹{d ∈ ℙ . d ⊩ (⋅∀φ⋅) env} ∪ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1} ∈ M›*) using Un_closed (*‹⟦(##(M::i))(?A::i); (##M)(?B::i)⟧ ⟹ (##M)(?A ∪ ?B)›*) by simp moreover have "D ⊆ ℙ" unfolding D_def (*goal: ‹{d ∈ ℙ . d ⊩ (⋅∀φ⋅) env} ∪ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1} ⊆ ℙ›*) by auto moreover have "dense(D)" proof (standard) (*goal: ‹⋀p. p ∈ ℙ ⟹ ∃d∈D. d ≼ p›*) fix p assume "p∈ℙ" (*‹(p::i) ∈ ℙ›*) show "∃d∈D. d≼ p" proof (cases "p ⊩ Forall(φ) env") (*goals: 1. ‹p ⊩ (⋅∀φ⋅) env ⟹ ∃d∈D. d ≼ p› 2. ‹satisfies(M, forces((⋅∀φ⋅))) ` ([p, ℙ, leq, 𝟭] @ env) ≠ 1 ⟹ ∃d∈D. d ≼ p›*) case True (*‹(p::i) ⊩ (⋅∀φ::i⋅) (env::i)›*) with ‹p∈ℙ› (*‹(p::i) ∈ ℙ›*) show "?thesis" (*goal: ‹∃d::i∈D::i. d ≼ (p::i)›*) unfolding D_def (*goal: ‹∃d∈{d ∈ ℙ . d ⊩ (⋅∀φ⋅) env} ∪ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1}. d ≼ p›*) using refl_leq (*‹?r ∈ ℙ ⟹ ?r ≼ ?r›*) by blast next (*goal: ‹satisfies(M, forces((⋅∀φ⋅))) ` ([p, ℙ, leq, 𝟭] @ env) ≠ 1 ⟹ ∃d∈D. d ≼ p›*) case False (*‹satisfies(M::i, forces((⋅∀φ::i⋅))) ` ([p::i, ℙ, leq::i, 𝟭] @ (env::i)) ≠ 1›*) with Forall (*‹φ ∈ formula› ‹⟦?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ (∃p∈G. p ⊩ φ ?env) ⟷ M[G], map(λa. val(G, a), ?env) ⊨ φ› ‹(env::i) ∈ list(M::i)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) ‹p∈ℙ› (*‹p ∈ ℙ›*) obtain b where "b∈M" "¬(p ⊩ φ ([b]@env))" (*goal: ‹(⋀b. ⟦b ∈ M; satisfies(M, forces(φ)) ` ([p, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1⟧ ⟹ thesis) ⟹ thesis›*) using Forces_Forall (*‹⟦(?p::i) ∈ ℙ; (?env::i) ∈ list(M::i); (?φ::i) ∈ formula⟧ ⟹ ?p ⊩ (⋅∀?φ⋅) ?env ⟷ (∀x::i∈M. ?p ⊩ ?φ [x] @ ?env)›*) by (msorry) moreover from this (*‹b ∈ M› ‹satisfies(M, forces(φ)) ` ([p, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1›*) ‹p∈ℙ› (*‹p ∈ ℙ›*) Forall (*‹φ ∈ formula› ‹⟦?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ (∃p∈G. p ⊩ φ ?env) ⟷ M[G], map(λa. val(G, a), ?env) ⊨ φ› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) have "¬dense_below({q∈ℙ. q ⊩ φ ([b]@env)},p)" using density_lemma (*‹⟦(?p::i) ∈ ℙ; (?φ::i) ∈ formula; (?env::i) ∈ list(M::i); arity(?φ) ≤ length(?env)⟧ ⟹ ?p ⊩ ?φ ?env ⟷ dense_below({q::i ∈ ℙ . q ⊩ ?φ ?env}, ?p)›*) pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) by auto moreover from this (*‹¬ dense_below({q ∈ ℙ . q ⊩ φ [b] @ env}, p)›*) obtain d where "d≼p" "∀q∈ℙ. q≼d ⟶ ¬(q ⊩ φ ([b] @ env))" "d∈ℙ" (*goal: ‹(⋀d. ⟦d ≼ p; ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1; d ∈ ℙ⟧ ⟹ thesis) ⟹ thesis›*) by blast ultimately show "?thesis" (*goal: ‹∃d∈D. d ≼ p›*) unfolding D_def (*goal: ‹∃d∈{d ∈ ℙ . d ⊩ (⋅∀φ⋅) env} ∪ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1}. d ≼ p›*) by auto qed qed moreover note generic (*‹M_generic(G)›*) ultimately obtain d where "d ∈ D" "d ∈ G" (*goal: ‹(⋀d. ⟦d ∈ D; d ∈ G⟧ ⟹ thesis) ⟹ thesis›*) by blast then consider (1)"d∈?D1" | (2)"d∈?D2" (*goal: ‹⟦d ∈ {d ∈ ℙ . d ⊩ (⋅∀φ⋅) env} ⟹ thesis; d ∈ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1} ⟹ thesis⟧ ⟹ thesis›*) unfolding D_def (*goal: ‹⟦d ∈ {d ∈ ℙ . d ⊩ (⋅∀φ⋅) env} ⟹ thesis; d ∈ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1} ⟹ thesis⟧ ⟹ thesis›*) by blast then show "∃p∈G. (p ⊩ Forall(φ) env)" proof (cases) (*goals: 1. ‹(d::i) ∈ {d::i ∈ ℙ . d ⊩ (⋅∀φ::i⋅) (env::i)} ⟹ ∃p::i∈G::i. p ⊩ (⋅∀φ⋅) env› 2. ‹(d::i) ∈ {d::i ∈ ℙ . ∃b::i∈M::i. ∀q::i∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ::i)) ` ([q, ℙ, leq::i, 𝟭] @ [b] @ (env::i)) ≠ 1} ⟹ ∃p::i∈G::i. p ⊩ (⋅∀φ⋅) env›*) case 1 (*‹d ∈ {d ∈ ℙ . d ⊩ (⋅∀φ⋅) env}›*) with ‹d∈G› (*‹d ∈ G›*) show "?thesis" (*goal: ‹∃p∈G. p ⊩ (⋅∀φ⋅) env›*) by blast next (*goal: ‹d ∈ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1} ⟹ ∃p∈G. p ⊩ (⋅∀φ⋅) env›*) case 2 (*‹d ∈ {d ∈ ℙ . ∃b∈M. ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1}›*) then obtain b where "b∈M" "∀q∈ℙ. q≼d ⟶¬(q ⊩ φ ([b] @ env))" (*goal: ‹(⋀b. ⟦b ∈ M; ∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1⟧ ⟹ thesis) ⟹ thesis›*) by blast moreover from this(1) (*‹b ∈ M›*) ‹M[G], _ ⊨ Forall(φ)› (*‹M[G], map(val(G), env) ⊨ (⋅∀φ⋅)›*) Forall(2)[of "Cons(b,env)"] (*‹⟦Cons(b::i, env::i) ∈ list(M::i); arity(φ::i) ≤ length(Cons(b, env))⟧ ⟹ (∃p::i∈G::i. p ⊩ φ Cons(b, env)) ⟷ M[G], map(λa::i. val(G, a), Cons(b, env)) ⊨ φ›*) Forall(1,3-) (*‹φ ∈ formula› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) obtain p where "p∈G" "p∈ℙ" "p ⊩ φ ([b] @ env)" (*goal: ‹(⋀p. ⟦p ∈ G; p ∈ ℙ; p ⊩ φ [b] @ env⟧ ⟹ thesis) ⟹ thesis›*) using pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) map_val_in_MG (*‹(?env::i) ∈ list(?M::i) ⟹ map(val(?G::i), ?env) ∈ list(?M[?G])›*) M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) by (auto iff:GenExt_iff (*‹?x ∈ M[?G] ⟷ (∃τ∈M. ?x = val(?G, τ))›*)) moreover note ‹d∈G› (*‹d ∈ G›*) ultimately obtain q where "q∈G" "q∈ℙ" "q≼d" "q≼p" (*goal: ‹(⋀q. ⟦q ∈ G; q ∈ ℙ; q ≼ d; q ≼ p⟧ ⟹ thesis) ⟹ thesis›*) using M_genericD (*‹?x ∈ G ⟹ ?x ∈ ℙ›*) by force moreover from this (*‹q ∈ G› ‹q ∈ ℙ› ‹(q::i) ≼ (d::i)› ‹q ≼ p›*) ‹p ⊩ φ ([b] @ env)› (*‹p ⊩ φ [b] @ env›*) Forall (*‹φ ∈ formula› ‹⟦?env ∈ list(M); arity(φ) ≤ length(?env)⟧ ⟹ (∃p∈G. p ⊩ φ ?env) ⟷ M[G], map(λa. val(G, a), ?env) ⊨ φ› ‹env ∈ list(M)› ‹arity((⋅∀φ⋅)) ≤ length(env)›*) ‹b∈M› (*‹b ∈ M›*) ‹p∈ℙ› (*‹p ∈ ℙ›*) have "q ⊩ φ ([b] @ env)" using pred_le2 (*‹⟦?n ∈ ω; ?m ∈ ω; pred(?n) ≤ ?m⟧ ⟹ ?n ≤ succ(?m)›*) strengthening_lemma (*‹⟦?p ∈ ℙ; ?φ ∈ formula; ?r ∈ ℙ; ?r ≼ ?p; ?env ∈ list(M); arity(?φ) ≤ length(?env); ?p ⊩ ?φ ?env⟧ ⟹ ?r ⊩ ?φ ?env›*) by simp moreover note ‹∀q∈ℙ. q≼d ⟶¬(q ⊩ φ ([b] @ env))› (*‹∀q∈ℙ. q ≼ d ⟶ satisfies(M, forces(φ)) ` ([q, ℙ, leq, 𝟭] @ [b] @ env) ≠ 1›*) ultimately show "?thesis" (*goal: ‹∃p∈G. p ⊩ (⋅∀φ⋅) env›*) by simp qed qed qed end context forcing_data1 begin subsection‹The ``Definition of forcing''› lemma definition_of_forcing: assumes "p∈ℙ" "φ∈formula" "env∈list(M)" "arity(φ)≤length(env)" shows "(p ⊩ φ env) ⟷ (∀G. M_generic(G) ∧ p∈G ⟶ M[G], map(val(G),env) ⊨ φ)" proof (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P ⟷ ?Q›*) allI (*‹(⋀x. ?P(x)) ⟹ ∀x. ?P(x)›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*), elim conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⋀G. ⟦p ⊩ φ env; M_generic(G); p ∈ G⟧ ⟹ M[G], map(val(G), env) ⊨ φ› 2. ‹∀G. M_generic(G) ∧ p ∈ G ⟶ M[G], map(val(G), env) ⊨ φ ⟹ p ⊩ φ env›*) fix G assume "(p ⊩ φ env)" "M_generic(G)" "p ∈ G" (*‹(p::i) ⊩ (φ::i) (env::i)› ‹M_generic(G::i)› ‹(p::i) ∈ (G::i)›*) moreover from this (*‹(p::i) ⊩ (φ::i) (env::i)› ‹M_generic(G)› ‹(p::i) ∈ (G::i)›*) interpret G_generic1 "ℙ" leq "𝟭" M enum G apply unfold_locales (*goal: ‹G_generic1(ℙ, leq, 𝟭, M, enum, G)›*) by simp from calculation (*‹p ⊩ φ env› ‹M_generic(G)› ‹p ∈ G›*) assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ::i) ≤ length(env::i)›*) show "M[G], map(val(G),env) ⊨ φ" using truth_lemma[of φ] (*‹⟦(φ::i) ∈ formula; (?env::i) ∈ list(M::i); arity(φ) ≤ length(?env)⟧ ⟹ (∃p::i∈G::i. p ⊩ φ ?env) ⟷ M[G], map(val(G), ?env) ⊨ φ›*) by auto next (*goal: ‹∀G::i. M_generic(G) ∧ (p::i) ∈ G ⟶ (M::i)[G], map(val(G), env::i) ⊨ (φ::i) ⟹ p ⊩ φ env›*) assume 1: "∀G.(M_generic(G)∧ p∈G) ⟶ M[G] , map(val(G),env) ⊨ φ" (*‹∀G::i. M_generic(G) ∧ (p::i) ∈ G ⟶ (M::i)[G], map(val(G), env::i) ⊨ (φ::i)›*) { fix r assume 2: "r∈ℙ" "r≼p" (*‹(r::i) ∈ ℙ› ‹(r::i) ≼ (p::i)›*) then obtain G where "r∈G" "M_generic(G)" (*goal: ‹(⋀G. ⟦r ∈ G; M_generic(G)⟧ ⟹ thesis) ⟹ thesis›*) text‹Here we're using countability (via the existence of generic filters) of \<^term>‹M› as a shortcut.› using generic_filter_existence (*‹?p ∈ ℙ ⟹ ∃G. ?p ∈ G ∧ M_generic(G)›*) by auto moreover from this (*‹(r::i) ∈ (G::i)› ‹M_generic(G::i)›*) interpret G_generic1 "ℙ" leq "𝟭" M enum G apply unfold_locales (*goal: ‹G_generic1(ℙ, leq, 𝟭, M, enum, G)›*) by simp from calculation (*‹r ∈ G› ‹M_generic(G)›*) "2" (*‹r ∈ ℙ› ‹r ≼ p›*) ‹p∈ℙ› (*‹p ∈ ℙ›*) have "p∈G" using filter_leqD (*‹⟦local.filter(?G); ?x ∈ ?G; ?y ∈ ℙ; ?x ≼ ?y⟧ ⟹ ?y ∈ ?G›*) by auto moreover note "1" (*‹∀G. M_generic(G) ∧ p ∈ G ⟶ M[G], map(val(G), env) ⊨ φ›*) ultimately have "M[G], map(val(G),env) ⊨ φ" by simp moreover note assms (*‹(p::i) ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) moreover from calculation (*‹(M::i)[G::i], map(val(G), env::i) ⊨ (φ::i)› ‹p ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) obtain s where "s∈G" "(s ⊩ φ env)" (*goal: ‹(⋀s. ⟦s ∈ G; s ⊩ φ env⟧ ⟹ thesis) ⟹ thesis›*) using truth_lemma[of φ] (*‹⟦(φ::i) ∈ formula; (?env::i) ∈ list(M::i); arity(φ) ≤ length(?env)⟧ ⟹ (∃p::i∈G::i. p ⊩ φ ?env) ⟷ M[G], map(val(G), ?env) ⊨ φ›*) by blast moreover from this (*‹s ∈ G› ‹s ⊩ φ env›*) ‹r∈G› (*‹r ∈ G›*) obtain q where "q∈G" "q≼s" "q≼r" "s∈ℙ" "q∈ℙ" (*goal: ‹(⋀q. ⟦q ∈ G; q ≼ s; q ≼ r; s ∈ ℙ; q ∈ ℙ⟧ ⟹ thesis) ⟹ thesis›*) by blast ultimately have "∃q∈ℙ. q≼r ∧ (q ⊩ φ env)" using strengthening_lemma[of s] (*‹⟦s ∈ ℙ; ?φ ∈ formula; ?r ∈ ℙ; ?r ≼ s; ?env ∈ list(M); arity(?φ) ≤ length(?env); s ⊩ ?φ ?env⟧ ⟹ ?r ⊩ ?φ ?env›*) by auto } then have "dense_below({q∈ℙ. (q ⊩ φ env)},p)" unfolding dense_below_def (*goal: ‹∀pa::i∈ℙ. pa ≼ (p::i) ⟶ (∃d::i∈{q::i ∈ ℙ . q ⊩ (φ::i) (env::i)}. d ∈ ℙ ∧ d ≼ pa)›*) by blast with assms (*‹p ∈ ℙ› ‹φ ∈ formula› ‹env ∈ list(M)› ‹arity(φ) ≤ length(env)›*) show "(p ⊩ φ env)" using density_lemma (*‹⟦?p ∈ ℙ; ?φ ∈ formula; ?env ∈ list(M); arity(?φ) ≤ length(?env)⟧ ⟹ ?p ⊩ ?φ ?env ⟷ dense_below({q ∈ ℙ . q ⊩ ?φ ?env}, ?p)›*) by blast qed lemmas definability = forces_type end ― ‹\<^locale>‹forcing_data1›› end
{ "path": "afp-2025-02-12/thys/Independence_CH/Forcing_Theorems.thy", "repo": "afp-2025-02-12", "sha": "11a9fdc58271bf15777b5f2e2b4334ff7e42331b794d9c6a8f2c1c636241dc5d" }
section ‹Approximation with Affine Forms› theory Affine_Approximation imports "HOL-Decision_Procs.Approximation" "HOL-Library.Monad_Syntax" "HOL-Library.Mapping" Executable_Euclidean_Space Affine_Form Straight_Line_Program begin text ‹\label{sec:approxaffine}› lemma convex_on_imp_above_tangent:― ‹TODO: generalizes @{thm convex_on_imp_above_tangent}› assumes convex: "convex_on A f" and connected: "connected A" assumes c: "c ∈ A" and x : "x ∈ A" assumes deriv: "(f has_field_derivative f') (at c within A)" shows "f x - f c ≥ f' * (x - c)" proof (cases x c rule: linorder_cases (*‹⟦(?x::?'a) < (?y::?'a) ⟹ ?P::bool; ?x = ?y ⟹ ?P; ?y < ?x ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹x < c ⟹ f' * (x - c) ≤ f x - f c› 2. ‹x = c ⟹ f' * (x - c) ≤ f x - f c› 3. ‹c < x ⟹ f' * (x - c) ≤ f x - f c›*) assume xc: "x > c" (*‹(c::real) < (x::real)›*) let ?A' = "{c<..<x}" have subs: "?A' ⊆ A" using xc (*‹c < x›*) x (*‹x ∈ A›*) c (*‹c ∈ A›*) by (simp add: connected (*‹connected A›*) connected_contains_Ioo (*‹⟦connected ?A; ?a ∈ ?A; ?b ∈ ?A⟧ ⟹ {?a<..<?b} ⊆ ?A›*)) have "at c within ?A' ≠ bot" using xc (*‹(c::real) < (x::real)›*) by (simp add: at_within_eq_bot_iff (*‹(at ?c within ?A = bot) = (?c ∉ closure (?A - {?c}))›*)) moreover from deriv (*‹(f has_real_derivative f') (at c within A)›*) have "((λy. (f y - f c) / (y - c)) ⤏ f') (at c within ?A')" unfolding has_field_derivative_iff (*goal: ‹((λy. (f y - f c) / (y - c)) ⤏ f') (at c within {c<..<x})›*) using subs (*‹{c::real<..<x::real} ⊆ (A::real set)›*) by (blast intro: tendsto_mono (*‹⟦?F ≤ ?F'; (?f ⤏ ?l) ?F'⟧ ⟹ (?f ⤏ ?l) ?F›*) at_le (*‹?s ⊆ ?t ⟹ at ?x within ?s ≤ at ?x within ?t›*)) moreover from eventually_at_right_real[OF xc] (*‹∀⇩F xa in at_right c. xa ∈ {c<..<x}›*) have "eventually (λy. (f y - f c) / (y - c) ≤ (f x - f c) / (x - c)) (at_right c)" proof (eventually_elim) (*goal: ‹⋀y. y ∈ {c<..<x} ⟹ (f y - f c) / (y - c) ≤ (f x - f c) / (x - c)›*) fix y assume y: "y ∈ {c<..<x}" (*‹(y::real) ∈ {c::real<..<x::real}›*) with convex (*‹convex_on A f›*) connected (*‹connected A›*) x (*‹(x::real) ∈ (A::real set)›*) c (*‹c ∈ A›*) have "f y ≤ (f x - f c) / (x - c) * (y - c) + f c" using interior_subset[of A] (*‹interior (A::real set) ⊆ A›*) apply (intro convex_onD_Icc' (*‹⟦convex_on {?x..?y} ?f; ?c ∈ {?x..?y}⟧ ⟹ ?f ?c ≤ (?f ?y - ?f ?x) / (?y - ?x) * (?c - ?x) + ?f ?x›*) convex_on_subset[OF convex] (*‹⟦?S ⊆ A; convex ?S⟧ ⟹ convex_on ?S f›*) connected_contains_Icc (*‹⟦connected ?A; ?a ∈ ?A; ?b ∈ ?A⟧ ⟹ {?a..?b} ⊆ ?A›*)) (*goals: 1. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {c<..<x}; interior A ⊆ A⟧ ⟹ connected A› 2. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {c<..<x}; interior A ⊆ A⟧ ⟹ c ∈ A› 3. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {c<..<x}; interior A ⊆ A⟧ ⟹ x ∈ A› 4. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {c<..<x}; interior A ⊆ A⟧ ⟹ convex {c..x}› 5. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {c<..<x}; interior A ⊆ A⟧ ⟹ y ∈ {c..x}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . hence "f y - f c ≤ (f x - f c) / (x - c) * (y - c)" by simp thus "(f y - f c) / (y - c) ≤ (f x - f c) / (x - c)" using y (*‹y ∈ {c<..<x}›*) xc (*‹(c::real) < (x::real)›*) by (simp add: divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*)) qed hence "eventually (λy. (f y - f c) / (y - c) ≤ (f x - f c) / (x - c)) (at c within ?A')" by (simp add: eventually_at_filter (*‹eventually ?P (at ?a within ?s) = (∀⇩F x in nhds ?a. x ≠ ?a ⟶ x ∈ ?s ⟶ ?P x)›*) eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*)) ultimately have "f' ≤ (f x - f c) / (x - c)" by (simp add: tendsto_upperbound (*‹⟦(?f ⤏ ?x) ?F; ∀⇩F i in ?F. ?f i ≤ ?a; ?F ≠ bot⟧ ⟹ ?x ≤ ?a›*)) thus "?thesis" (*goal: ‹f' * (x - c) ≤ f x - f c›*) using xc (*‹c < x›*) by (simp add: field_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 77 facts*)) next (*goals: 1. ‹x < c ⟹ f' * (x - c) ≤ f x - f c› 2. ‹x = c ⟹ f' * (x - c) ≤ f x - f c›*) assume xc: "x < c" (*‹(x::real) < (c::real)›*) let ?A' = "{x<..<c}" have subs: "?A' ⊆ A" using xc (*‹x < c›*) x (*‹x ∈ A›*) c (*‹c ∈ A›*) by (simp add: connected (*‹connected A›*) connected_contains_Ioo (*‹⟦connected ?A; ?a ∈ ?A; ?b ∈ ?A⟧ ⟹ {?a<..<?b} ⊆ ?A›*)) have "at c within ?A' ≠ bot" using xc (*‹x < c›*) by (simp add: at_within_eq_bot_iff (*‹(at (?c::?'a) within (?A::?'a set) = bot) = (?c ∉ closure (?A - {?c}))›*)) moreover from deriv (*‹(f has_real_derivative f') (at c within A)›*) have "((λy. (f y - f c) / (y - c)) ⤏ f') (at c within ?A')" unfolding has_field_derivative_iff (*goal: ‹((λy. (f y - f c) / (y - c)) ⤏ f') (at c within {x<..<c})›*) using subs (*‹{x<..<c} ⊆ A›*) by (blast intro: tendsto_mono (*‹⟦?F ≤ ?F'; (?f ⤏ ?l) ?F'⟧ ⟹ (?f ⤏ ?l) ?F›*) at_le (*‹?s ⊆ ?t ⟹ at ?x within ?s ≤ at ?x within ?t›*)) moreover from eventually_at_left_real[OF xc] (*‹∀⇩F xa in at_left c. xa ∈ {x<..<c}›*) have "eventually (λy. (f y - f c) / (y - c) ≥ (f x - f c) / (x - c)) (at_left c)" proof (eventually_elim) (*goal: ‹⋀y. y ∈ {x<..<c} ⟹ (f x - f c) / (x - c) ≤ (f y - f c) / (y - c)›*) fix y assume y: "y ∈ {x<..<c}" (*‹(y::real) ∈ {x::real<..<c::real}›*) with convex (*‹convex_on A f›*) connected (*‹connected A›*) x (*‹x ∈ A›*) c (*‹c ∈ A›*) have "f y ≤ (f x - f c) / (c - x) * (c - y) + f c" using interior_subset[of A] (*‹interior (A::real set) ⊆ A›*) apply (intro convex_onD_Icc'' (*‹⟦convex_on {?x..?y} ?f; ?c ∈ {?x..?y}⟧ ⟹ ?f ?c ≤ (?f ?x - ?f ?y) / (?y - ?x) * (?y - ?c) + ?f ?y›*) convex_on_subset[OF convex] (*‹⟦?S ⊆ A; convex ?S⟧ ⟹ convex_on ?S f›*) connected_contains_Icc (*‹⟦connected ?A; ?a ∈ ?A; ?b ∈ ?A⟧ ⟹ {?a..?b} ⊆ ?A›*)) (*goals: 1. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {x<..<c}; interior A ⊆ A⟧ ⟹ connected A› 2. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {x<..<c}; interior A ⊆ A⟧ ⟹ x ∈ A› 3. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {x<..<c}; interior A ⊆ A⟧ ⟹ c ∈ A› 4. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {x<..<c}; interior A ⊆ A⟧ ⟹ convex {x..c}› 5. ‹⟦convex_on A f; connected A; x ∈ A; c ∈ A; y ∈ {x<..<c}; interior A ⊆ A⟧ ⟹ y ∈ {x..c}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . hence "f y - f c ≤ (f x - f c) * ((c - y) / (c - x))" by simp also (*calculation: ‹f y - f c ≤ (f x - f c) * ((c - y) / (c - x))›*) have "(c - y) / (c - x) = (y - c) / (x - c)" using y (*‹y ∈ {x<..<c}›*) xc (*‹(x::real) < (c::real)›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*)) finally (*calculation: ‹f y - f c ≤ (f x - f c) * ((y - c) / (x - c))›*) show "(f y - f c) / (y - c) ≥ (f x - f c) / (x - c)" using y (*‹y ∈ {x<..<c}›*) xc (*‹(x::real) < (c::real)›*) by (simp add: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) qed hence "eventually (λy. (f y - f c) / (y - c) ≥ (f x - f c) / (x - c)) (at c within ?A')" by (simp add: eventually_at_filter (*‹eventually ?P (at ?a within ?s) = (∀⇩F x in nhds ?a. x ≠ ?a ⟶ x ∈ ?s ⟶ ?P x)›*) eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*)) ultimately have "f' ≥ (f x - f c) / (x - c)" by (simp add: tendsto_lowerbound (*‹⟦(?f ⤏ ?x) ?F; ∀⇩F i in ?F. ?a ≤ ?f i; ?F ≠ bot⟧ ⟹ ?a ≤ ?x›*)) thus "?thesis" (*goal: ‹f' * (x - c) ≤ f x - f c›*) using xc (*‹(x::real) < (c::real)›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*)) qed (simp_all) (*solved the remaining goal: ‹x = c ⟹ f' * (x - c) ≤ f x - f c›*) text ‹Approximate operations on affine forms.› lemma Affine_notempty[intro, simp]: "Affine X ≠ {}" by (auto simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*)) lemma truncate_up_lt: "x < y ⟹ x < truncate_up prec y" by (rule less_le_trans[OF _ truncate_up] (*‹?x < ?y ⟹ ?x < truncate_up ?prec1 ?y›*)) lemma truncate_up_pos_eq[simp]: "0 < truncate_up p x ⟷ 0 < x" apply (auto simp: truncate_up_lt (*‹?x < ?y ⟹ ?x < truncate_up ?prec ?y›*)) (*goal: ‹(0 < truncate_up p x) = (0 < x)›*) by (metis (poly_guards_query) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) truncate_up_nonpos (*‹?x ≤ 0 ⟹ truncate_up ?prec ?x ≤ 0›*)) lemma inner_scaleR_pdevs_0: "inner_scaleR_pdevs 0 One_pdevs = zero_pdevs" unfolding inner_scaleR_pdevs_def (*goal: ‹unop_pdevs (λx. (0 ∙ x) *⇩R x) One_pdevs = zero_pdevs›*) apply transfer (*goal: ‹unop_pdevs (λx. (0 ∙ x) *⇩R x) One_pdevs = zero_pdevs›*) by (auto simp: unop_pdevs_raw_def (*‹unop_pdevs_raw (?f::?'a ⇒ ?'b) (?x::nat ⇒ ?'a) (?i::nat) = (if ?x ?i = (0::?'a) then 0::?'b else ?f (?x ?i))›*)) lemma Affine_aform_of_point_eq[simp]: "Affine (aform_of_point p) = {p}" by (simp add: Affine_aform_of_ivl (*‹?a ≤ ?b ⟹ Affine (aform_of_ivl ?a ?b) = {?a..?b}›*) aform_of_point_def (*‹aform_of_point ?x = aform_of_ivl ?x ?x›*)) lemma mem_Affine_aform_of_point: "x ∈ Affine (aform_of_point x)" by simp lemma aform_val_aform_of_ivl_innerE: assumes "e ∈ UNIV → {-1 .. 1}" assumes "a ≤ b" "c ∈ Basis" obtains f where "aform_val e (aform_of_ivl a b) ∙ c = aform_val f (aform_of_ivl (a ∙ c) (b ∙ c))" "f ∈ UNIV → {-1 .. 1}" proof (-) (*goal: ‹(⋀f. ⟦aform_val e (aform_of_ivl a b) ∙ c = aform_val f (aform_of_ivl (a ∙ c) (b ∙ c)); f ∈ UNIV → {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) have [simp]: "a ∙ c ≤ b ∙ c" using assms (*‹e ∈ UNIV → {- 1..1}› ‹a ≤ b› ‹(c::'a) ∈ Basis›*) by (auto simp: eucl_le[where 'a='a] (*‹((?x::'a) ≤ (?y::'a)) = (∀i::'a∈Basis. ?x ∙ i ≤ ?y ∙ i)›*)) have "(λx. x ∙ c) ` Affine (aform_of_ivl a b) = Affine (aform_of_ivl (a ∙ c) (b ∙ c))" using assms (*‹e ∈ UNIV → {- 1..1}› ‹a ≤ b› ‹c ∈ Basis›*) by (auto simp: Affine_aform_of_ivl (*‹?a ≤ ?b ⟹ Affine (aform_of_ivl ?a ?b) = {?a..?b}›*) eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) image_eqI[where x="∑i∈Basis. (if i = c then x else a ∙ i) *⇩R i" for x] (*‹⟦?b = ?f (∑i∈Basis. (if i = c then ?x3 else a ∙ i) *⇩R i); (∑i∈Basis. (if i = c then ?x3 else a ∙ i) *⇩R i) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) then obtain f where "aform_val e (aform_of_ivl a b) ∙ c = aform_val f (aform_of_ivl (a ∙ c) (b ∙ c))" "f ∈ UNIV → {-1 .. 1}" (*goal: ‹(⋀f. ⟦aform_val e (aform_of_ivl a b) ∙ c = aform_val f (aform_of_ivl (a ∙ c) (b ∙ c)); f ∈ UNIV → {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹e ∈ UNIV → {- 1..1}› ‹a ≤ b› ‹c ∈ Basis›*) by (force simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*)) thus "?thesis" (*goal: ‹thesis›*) by standard qed lift_definition coord_pdevs::"nat ⇒ real pdevs" is "λn i. if i = n then 1 else 0" by auto lemma pdevs_apply_coord_pdevs [simp]: "pdevs_apply (coord_pdevs i) x = (if x = i then 1 else 0)" apply transfer (*goal: ‹pdevs_apply (coord_pdevs i) x = (if x = i then 1 else 0)›*) by simp lemma degree_coord_pdevs[simp]: "degree (coord_pdevs i) = Suc i" by (auto intro!: degree_eqI (*‹⟦pdevs_apply (?x::?'a pdevs) (?d::nat) ≠ (0::?'a); ⋀j::nat. ?d < j ⟹ pdevs_apply ?x j = (0::?'a)⟧ ⟹ degree ?x = Suc ?d›*)) lemma pdevs_val_coord_pdevs[simp]: "pdevs_val e (coord_pdevs i) = e i" by (auto simp: pdevs_val_sum (*‹pdevs_val (?e::nat ⇒ real) (?X::?'a pdevs) = (∑i::nat<degree ?X. ?e i *⇩R pdevs_apply ?X i)›*) if_distrib (*‹(?f::?'b ⇒ ?'a) (if ?c::bool then ?x::?'b else (?y::?'b)) = (if ?c then ?f ?x else ?f ?y)›*) sum.delta (*‹finite (?S::?'b set) ⟹ (∑k::?'b∈?S. if k = (?a::?'b) then (?b::?'b ⇒ ?'a) k else (0::?'a)) = (if ?a ∈ ?S then ?b ?a else (0::?'a))›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a) = (?u::?'a); ¬ ?c ⟹ (?y::?'a) = (?v::?'a)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) definition "aforms_of_ivls ls us = map (λ(i, (l, u)). ((l + u)/2, scaleR_pdevs ((u - l)/2) (coord_pdevs i))) (zip [0..<length ls] (zip ls us))" lemma aforms_of_ivls: assumes "length ls = length us" "length xs = length ls" assumes "⋀i. i < length xs ⟹ xs ! i ∈ {ls ! i .. us ! i}" shows "xs ∈ Joints (aforms_of_ivls ls us)" proof (-) (*goal: ‹xs ∈ Joints (aforms_of_ivls ls us)›*) { fix i assume "i < length xs" (*‹(i::nat) < length (xs::real list)›*) then have "∃e. e ∈ {-1 .. 1} ∧ xs ! i = (ls ! i + us ! i) / 2 + e * (us ! i - ls ! i) / 2" using assms (*‹length ls = length us› ‹length (xs::real list) = length (ls::real list)› ‹?i < length xs ⟹ xs ! ?i ∈ {ls ! ?i..us ! ?i}›*) by (force intro!: exI[where x="(xs ! i - (ls ! i + us ! i) / 2) / (us ! i - ls ! i) * 2"] (*‹?P ((xs ! i - (ls ! i + us ! i) / 2) / (us ! i - ls ! i) * 2) ⟹ ∃x. ?P x›*) simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) } then obtain e where e: "e i ∈ {-1 .. 1}" "xs ! i = (ls ! i + us ! i) / 2 + e i * (us ! i - ls ! i) / 2" if "i < length xs" for i (*goal: ‹(⋀e. ⟦⋀i. i < length xs ⟹ e i ∈ {- 1..1}; ⋀i. i < length xs ⟹ xs ! i = (ls ! i + us ! i) / 2 + e i * (us ! i - ls ! i) / 2⟧ ⟹ thesis) ⟹ thesis›*) using that (*‹⟦⋀i. i < length xs ⟹ ?e i ∈ {- 1..1}; ⋀i. i < length xs ⟹ xs ! i = (ls ! i + us ! i) / 2 + ?e i * (us ! i - ls ! i) / 2⟧ ⟹ thesis›*) by metis define e' where "e' i = (if i < length xs then e i else 0)" for i show "?thesis" (*goal: ‹xs ∈ Joints (aforms_of_ivls ls us)›*) using e (*‹?i < length xs ⟹ e ?i ∈ {- 1..1}› ‹?i < length xs ⟹ xs ! ?i = (ls ! ?i + us ! ?i) / 2 + e ?i * (us ! ?i - ls ! ?i) / 2›*) assms (*‹length ls = length us› ‹length xs = length ls› ‹?i < length xs ⟹ xs ! ?i ∈ {ls ! ?i..us ! ?i}›*) by (auto simp: aforms_of_ivls_def (*‹aforms_of_ivls ?ls ?us = map2 (λi (l, u). ((l + u) / 2, scaleR_pdevs ((u - l) / 2) (coord_pdevs i))) [0..<length ?ls] (zip ?ls ?us)›*) Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*) e'_def (*‹e' ?i = (if ?i < length xs then e ?i else 0)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) intro!: image_eqI[where x=e'] (*‹⟦?b = ?f e'; e' ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*)) qed subsection ‹Approximate Operations› definition "max_pdev x = fold (λx y. if infnorm (snd x) ≥ infnorm (snd y) then x else y) (list_of_pdevs x) (0, 0)" subsubsection ‹set of generated endpoints› fun points_of_list where "points_of_list x0 [] = [x0]" | "points_of_list x0 ((i, x)#xs) = (points_of_list (x0 + x) xs @ points_of_list (x0 - x) xs)" primrec points_of_aform where "points_of_aform (x, xs) = points_of_list x (list_of_pdevs xs)" subsubsection ‹Approximate total deviation› definition sum_list'::"nat ⇒ 'a list ⇒ 'a::executable_euclidean_space" where "sum_list' p xs = fold (λa b. eucl_truncate_up p (a + b)) xs 0" definition "tdev' p x = sum_list' p (map (abs o snd) (list_of_pdevs x))" lemma eucl_fold_mono: fixes f::"'a::ordered_euclidean_space⇒'a⇒'a" assumes mono: "⋀w x y z. w ≤ x ⟹ y ≤ z ⟹ f w y ≤ f x z" shows "x ≤ y ⟹ fold f xs x ≤ fold f xs y" apply (induct xs arbitrary: x y) (*goals: 1. ‹⋀(x::'a::ordered_euclidean_space) y::'a::ordered_euclidean_space. x ≤ y ⟹ fold (f::'a::ordered_euclidean_space ⇒ 'a::ordered_euclidean_space ⇒ 'a::ordered_euclidean_space) [] x ≤ fold f [] y› 2. ‹⋀(a::'a::ordered_euclidean_space) (xs::'a::ordered_euclidean_space list) (x::'a::ordered_euclidean_space) y::'a::ordered_euclidean_space. ⟦⋀(x::'a::ordered_euclidean_space) y::'a::ordered_euclidean_space. x ≤ y ⟹ fold (f::'a::ordered_euclidean_space ⇒ 'a::ordered_euclidean_space ⇒ 'a::ordered_euclidean_space) xs x ≤ fold f xs y; x ≤ y⟧ ⟹ fold f (a # xs) x ≤ fold f (a # xs) y› discuss goal 1*) apply ((auto simp: mono (*‹⟦?w ≤ ?x; ?y ≤ ?z⟧ ⟹ f ?w ?y ≤ f ?x ?z›*))[1]) (*discuss goal 2*) apply ((auto simp: mono (*‹⟦?w ≤ ?x; ?y ≤ ?z⟧ ⟹ f ?w ?y ≤ f ?x ?z›*))[1]) (*proven 2 subgoals*) . lemma sum_list_add_le_fold_eucl_truncate_up: fixes z::"'a::executable_euclidean_space" shows "sum_list xs + z ≤ fold (λx y. eucl_truncate_up p (x + y)) xs z" proof (induct xs arbitrary: z) (*goals: 1. ‹⋀z. sum_list [] + z ≤ fold (λx y. eucl_truncate_up p (x + y)) [] z› 2. ‹⋀a xs z. (⋀z. sum_list xs + z ≤ fold (λx y. eucl_truncate_up p (x + y)) xs z) ⟹ sum_list (a # xs) + z ≤ fold (λx y. eucl_truncate_up p (x + y)) (a # xs) z›*) case (Cons x xs) (*‹sum_list xs + ?z ≤ fold (λx y. eucl_truncate_up p (x + y)) xs ?z›*) have "sum_list (x # xs) + z = sum_list xs + (z + x)" by simp also (*calculation: ‹sum_list (x # xs) + z = sum_list xs + (z + x)›*) have "… ≤ fold (λx y. eucl_truncate_up p (x + y)) xs (z + x)" using Cons (*‹sum_list xs + ?z ≤ fold (λx y. eucl_truncate_up p (x + y)) xs ?z›*) by simp also (*calculation: ‹sum_list (x # xs) + z ≤ fold (λx y. eucl_truncate_up p (x + y)) xs (z + x)›*) have "… ≤ fold (λx y. eucl_truncate_up p (x + y)) xs (eucl_truncate_up p (x + z))" by (auto intro!: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) eucl_fold_mono (*‹⟦⋀w x y z. ⟦w ≤ x; y ≤ z⟧ ⟹ ?f w y ≤ ?f x z; ?x ≤ ?y⟧ ⟹ fold ?f ?xs ?x ≤ fold ?f ?xs ?y›*) eucl_truncate_up (*‹?x ≤ eucl_truncate_up ?e ?x›*) eucl_truncate_up_mono (*‹?x ≤ ?y ⟹ eucl_truncate_up ?p ?x ≤ eucl_truncate_up ?p ?y›*) simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) finally (*calculation: ‹sum_list (x # xs) + z ≤ fold (λx y. eucl_truncate_up p (x + y)) xs (eucl_truncate_up p (x + z))›*) show "?case" (*goal: ‹sum_list ((x::'a) # (xs::'a list)) + (z::'a) ≤ fold (λ(x::'a) y::'a. eucl_truncate_up (p::nat) (x + y)) (x # xs) z›*) by simp qed (simp) (*solved the remaining goal: ‹⋀z. sum_list [] + z ≤ fold (λx y. eucl_truncate_up p (x + y)) [] z›*) lemma sum_list_le_sum_list': "sum_list xs ≤ sum_list' p xs" unfolding sum_list'_def (*goal: ‹sum_list (xs::'a list) ≤ fold (λ(a::'a) b::'a. eucl_truncate_up (p::nat) (a + b)) xs (0::'a)›*) using sum_list_add_le_fold_eucl_truncate_up[of xs 0] (*‹sum_list xs + 0 ≤ fold (λx y. eucl_truncate_up ?p (x + y)) xs 0›*) by simp lemma sum_list'_sum_list_le: "y ≤ sum_list xs ⟹ y ≤ sum_list' p xs" by (metis sum_list_le_sum_list' (*‹sum_list ?xs ≤ sum_list' ?p ?xs›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) lemma tdev': "tdev x ≤ tdev' p x" unfolding tdev'_def (*goal: ‹tdev x ≤ sum_list' p (map (abs ∘ snd) (list_of_pdevs x))›*) proof (-) (*goal: ‹tdev x ≤ sum_list' p (map (abs ∘ snd) (list_of_pdevs x))›*) have "tdev x = (∑i = 0 ..< degree x. ¦pdevs_apply x i¦)" by (auto intro!: sum.mono_neutral_cong_left (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?h i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?S = sum ?h ?T›*) simp: tdev_def (*‹tdev ?x = (∑i<degree ?x. ¦pdevs_apply ?x i¦)›*)) also (*calculation: ‹tdev x = (∑i = 0..<degree x. ¦pdevs_apply x i¦)›*) have "… = (∑i ← rev [0 ..< degree x]. ¦pdevs_apply x i¦)" by (metis atLeastLessThan_upt (*‹{?i..<?j} = set [?i..<?j]›*) sum_list_rev (*‹sum_list (rev ?xs) = sum_list ?xs›*) rev_map (*‹rev (map ?f ?xs) = map ?f (rev ?xs)›*) sum_set_upt_conv_sum_list_nat (*‹sum ?f (set [?m..<?n]) = sum_list (map ?f [?m..<?n])›*)) also (*calculation: ‹tdev x = (∑i←rev [0..<degree x]. ¦pdevs_apply x i¦)›*) have "… = sum_list (map (λxa. ¦pdevs_apply x xa¦) [xa←rev [0..<degree x] . pdevs_apply x xa ≠ 0])" unfolding filter_map map_map o_def (*goal: ‹(∑i←rev [0..<degree x]. ¦pdevs_apply x i¦) = (∑xa←filter (λxa. pdevs_apply x xa ≠ 0) (rev [0..<degree x]). ¦pdevs_apply x xa¦)›*) apply (subst sum_list_map_filter (*‹(⋀x. ⟦x ∈ set ?xs; ¬ ?P x⟧ ⟹ ?f x = 0) ⟹ sum_list (map ?f (filter ?P ?xs)) = sum_list (map ?f ?xs)›*)) (*goals: 1. ‹⋀xa. ⟦xa ∈ set (rev [0..<degree x]); ¬ pdevs_apply x xa ≠ 0⟧ ⟹ ¦pdevs_apply x xa¦ = 0› 2. ‹(∑i←rev [0..<degree x]. ¦pdevs_apply x i¦) = (∑xa←rev [0..<degree x]. ¦pdevs_apply x xa¦)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹tdev (x::'a pdevs) = (∑xa::nat←filter (λxa::nat. pdevs_apply x xa ≠ (0::'a)) (rev [0::nat..<degree x]). ¦pdevs_apply x xa¦)›*) note sum_list_le_sum_list'[of _ p] (*‹sum_list (?xs::?'a list) ≤ sum_list' (p::nat) ?xs›*) also (*calculation: ‹tdev (x::'a::executable_euclidean_space pdevs) ≤ sum_list' (p::nat) (map (λxa::nat. ¦pdevs_apply x xa¦) (filter (λxa::nat. pdevs_apply x xa ≠ (0::'a::executable_euclidean_space)) (rev [0::nat..<degree x])))›*) have "[xa←rev [0..<degree x] . pdevs_apply x xa ≠ 0] = rev (sorted_list_of_set (pdevs_domain x))" apply (subst rev_is_rev_conv[symmetric] (*‹(?xs = ?ys) = (rev ?xs = rev ?ys)›*)) (*goal: ‹filter (λxa::nat. pdevs_apply (x::'a pdevs) xa ≠ (0::'a)) (rev [0::nat..<degree x]) = rev (sorted_list_of_set (pdevs_domain x))›*) by (auto simp: filter_map (*‹filter (?P::?'a::type ⇒ bool) (map (?f::?'b::type ⇒ ?'a::type) (?xs::?'b::type list)) = map ?f (filter (?P ∘ ?f) ?xs)›*) rev_filter (*‹rev (filter (?P::?'a::type ⇒ bool) (?xs::?'a::type list)) = filter ?P (rev ?xs)›*) intro!: sorted_distinct_set_unique (*‹⟦sorted (?xs::?'a::linorder list); distinct ?xs; sorted (?ys::?'a::linorder list); distinct ?ys; set ?xs = set ?ys⟧ ⟹ ?xs = ?ys›*) sorted_filter[of "λx. x", simplified] (*‹sorted (?xs::?'b1::linorder list) ⟹ sorted (filter (?P::?'b1::linorder ⇒ bool) ?xs)›*) degree_gt (*‹pdevs_apply (?x::?'a::real_vector pdevs) (?j::nat) ≠ (0::?'a::real_vector) ⟹ ?j < degree ?x›*)) finally (*calculation: ‹tdev x ≤ sum_list' p (map (λxa. ¦pdevs_apply x xa¦) (rev (sorted_list_of_set (pdevs_domain x))))›*) show "tdev x ≤ sum_list' p (map (abs ∘ snd) (list_of_pdevs x))" by (auto simp: list_of_pdevs_def (*‹list_of_pdevs ?x = map (λi. (i, pdevs_apply ?x i)) (rev (sorted_list_of_set (pdevs_domain ?x)))›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) rev_map (*‹rev (map ?f ?xs) = map ?f (rev ?xs)›*) filter_map (*‹filter ?P (map ?f ?xs) = map ?f (filter (?P ∘ ?f) ?xs)›*) rev_filter (*‹rev (filter ?P ?xs) = filter ?P (rev ?xs)›*)) qed lemma tdev'_le: "x ≤ tdev y ⟹ x ≤ tdev' p y" by (metis order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*) tdev' (*‹tdev ?x ≤ tdev' ?p ?x›*)) lemmas abs_pdevs_val_le_tdev' = tdev'_le[OF abs_pdevs_val_le_tdev] lemma tdev'_uminus_pdevs[simp]: "tdev' p (uminus_pdevs x) = tdev' p x" by (auto simp: tdev'_def (*‹tdev' (?p::nat) (?x::?'a pdevs) = sum_list' ?p (map (abs ∘ snd) (list_of_pdevs ?x))›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) rev_map (*‹rev (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (rev ?xs)›*) filter_map (*‹filter (?P::?'a ⇒ bool) (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (filter (?P ∘ ?f) ?xs)›*) rev_filter (*‹rev (filter (?P::?'a ⇒ bool) (?xs::?'a list)) = filter ?P (rev ?xs)›*) list_of_pdevs_def (*‹list_of_pdevs (?x::?'a pdevs) = map (λi::nat. (i, pdevs_apply ?x i)) (rev (sorted_list_of_set (pdevs_domain ?x)))›*) pdevs_domain_def (*‹pdevs_domain (?x::?'a pdevs) = {i::nat. pdevs_apply ?x i ≠ (0::?'a)}›*)) abbreviation Radius::"'a::ordered_euclidean_space aform ⇒ 'a" where "Radius X ≡ tdev (snd X)" abbreviation Radius'::"nat⇒'a::executable_euclidean_space aform ⇒ 'a" where "Radius' p X ≡ tdev' p (snd X)" lemma Radius'_uminus_aform[simp]: "Radius' p (uminus_aform X) = Radius' p X" by (auto simp: uminus_aform_def (*‹uminus_aform ?X = (- fst ?X, uminus_pdevs (snd ?X))›*)) subsubsection ‹truncate partial deviations› definition trunc_pdevs_raw::"nat ⇒ (nat ⇒ 'a) ⇒ nat ⇒ 'a::executable_euclidean_space" where "trunc_pdevs_raw p x i = eucl_truncate_down p (x i)" lemma nonzeros_trunc_pdevs_raw: "{i. trunc_pdevs_raw r x i ≠ 0} ⊆ {i. x i ≠ 0}" by (auto simp: trunc_pdevs_raw_def[abs_def] (*‹trunc_pdevs_raw ≡ λ(p::nat) (x::nat ⇒ ?'a::executable_euclidean_space) i::nat. eucl_truncate_down p (x i)›*)) lift_definition trunc_pdevs::"nat ⇒ 'a::executable_euclidean_space pdevs ⇒ 'a pdevs" is trunc_pdevs_raw by (auto intro!: finite_subset[OF nonzeros_trunc_pdevs_raw]) definition trunc_err_pdevs_raw::"nat ⇒ (nat ⇒ 'a) ⇒ nat ⇒ 'a::executable_euclidean_space" where "trunc_err_pdevs_raw p x i = trunc_pdevs_raw p x i - x i" lemma nonzeros_trunc_err_pdevs_raw: "{i. trunc_err_pdevs_raw r x i ≠ 0} ⊆ {i. x i ≠ 0}" by (auto simp: trunc_pdevs_raw_def (*‹trunc_pdevs_raw ?p ?x ?i = eucl_truncate_down ?p (?x ?i)›*) trunc_err_pdevs_raw_def[abs_def] (*‹trunc_err_pdevs_raw ≡ λp x i. trunc_pdevs_raw p x i - x i›*)) lift_definition trunc_err_pdevs::"nat ⇒ 'a::executable_euclidean_space pdevs ⇒ 'a pdevs" is trunc_err_pdevs_raw by (auto intro!: finite_subset[OF nonzeros_trunc_err_pdevs_raw]) term float_plus_down lemma pdevs_apply_trunc_pdevs[simp]: fixes x y::"'a::euclidean_space" shows "pdevs_apply (trunc_pdevs p X) n = eucl_truncate_down p (pdevs_apply X n)" apply transfer (*goal: ‹pdevs_apply (trunc_pdevs p X) n = eucl_truncate_down p (pdevs_apply X n)›*) by (simp add: trunc_pdevs_raw_def (*‹trunc_pdevs_raw ?p ?x ?i = eucl_truncate_down ?p (?x ?i)›*)) lemma pdevs_apply_trunc_err_pdevs[simp]: fixes x y::"'a::euclidean_space" shows "pdevs_apply (trunc_err_pdevs p X) n = eucl_truncate_down p (pdevs_apply X n) - (pdevs_apply X n)" apply transfer (*goal: ‹pdevs_apply (trunc_err_pdevs p X) n = eucl_truncate_down p (pdevs_apply X n) - pdevs_apply X n›*) by (auto simp: trunc_err_pdevs_raw_def (*‹trunc_err_pdevs_raw ?p ?x ?i = trunc_pdevs_raw ?p ?x ?i - ?x ?i›*) trunc_pdevs_raw_def (*‹trunc_pdevs_raw ?p ?x ?i = eucl_truncate_down ?p (?x ?i)›*)) lemma pdevs_val_trunc_pdevs: fixes x y::"'a::euclidean_space" shows "pdevs_val e (trunc_pdevs p X) = pdevs_val e X + pdevs_val e (trunc_err_pdevs p X)" proof (-) (*goal: ‹pdevs_val e (trunc_pdevs p X) = pdevs_val e X + pdevs_val e (trunc_err_pdevs p X)›*) have "pdevs_val e X + pdevs_val e (trunc_err_pdevs p X) = pdevs_val e (add_pdevs X (trunc_err_pdevs p X))" by simp also (*calculation: ‹pdevs_val e X + pdevs_val e (trunc_err_pdevs p X) = pdevs_val e (add_pdevs X (trunc_err_pdevs p X))›*) have "… = pdevs_val e (trunc_pdevs p X)" by (auto simp: pdevs_val_def (*‹pdevs_val (?e::nat ⇒ real) (?x::?'a pdevs) = (∑i::nat. ?e i *⇩R pdevs_apply ?x i)›*) trunc_pdevs_raw_def (*‹trunc_pdevs_raw (?p::nat) (?x::nat ⇒ ?'a) (?i::nat) = eucl_truncate_down ?p (?x ?i)›*) trunc_err_pdevs_raw_def (*‹trunc_err_pdevs_raw (?p::nat) (?x::nat ⇒ ?'a) (?i::nat) = trunc_pdevs_raw ?p ?x ?i - ?x ?i›*)) finally (*calculation: ‹pdevs_val e X + pdevs_val e (trunc_err_pdevs p X) = pdevs_val e (trunc_pdevs p X)›*) show "?thesis" (*goal: ‹pdevs_val e (trunc_pdevs p X) = pdevs_val e X + pdevs_val e (trunc_err_pdevs p X)›*) by simp qed lemma pdevs_val_trunc_err_pdevs: fixes x y::"'a::euclidean_space" shows "pdevs_val e (trunc_err_pdevs p X) = pdevs_val e (trunc_pdevs p X) - pdevs_val e X" by (simp add: pdevs_val_trunc_pdevs (*‹pdevs_val (?e::nat ⇒ real) (trunc_pdevs (?p::nat) (?X::?'b pdevs)) = pdevs_val ?e ?X + pdevs_val ?e (trunc_err_pdevs ?p ?X)›*)) definition truncate_aform::"nat ⇒ 'a aform ⇒ 'a::executable_euclidean_space aform" where "truncate_aform p x = (eucl_truncate_down p (fst x), trunc_pdevs p (snd x))" definition truncate_error_aform::"nat ⇒ 'a aform ⇒ 'a::executable_euclidean_space aform" where "truncate_error_aform p x = (eucl_truncate_down p (fst x) - fst x, trunc_err_pdevs p (snd x))" lemma abs_aform_val_le: assumes "e ∈ UNIV → {- 1..1}" shows "abs (aform_val e X) ≤ eucl_truncate_up p (¦fst X¦ + tdev' p (snd X))" proof (-) (*goal: ‹¦aform_val e X¦ ≤ eucl_truncate_up p (¦fst X¦ + Radius' p X)›*) have "abs (aform_val e X) ≤ ¦fst X¦ + ¦pdevs_val e (snd X)¦" by (auto simp: aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a::real_normed_vector × ?'a::real_normed_vector pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) intro!: abs_triangle_ineq (*‹¦(?a::?'a::ordered_ab_group_add_abs) + (?b::?'a::ordered_ab_group_add_abs)¦ ≤ ¦?a¦ + ¦?b¦›*)) also (*calculation: ‹¦aform_val e X¦ ≤ ¦fst X¦ + ¦pdevs_val e (snd X)¦›*) have "¦pdevs_val e (snd X)¦ ≤ tdev (snd X)" using assms (*‹e ∈ UNIV → {- 1..1}›*) by (rule abs_pdevs_val_le_tdev (*‹?e ∈ UNIV → {- 1..1} ⟹ ¦pdevs_val ?e ?x¦ ≤ tdev ?x›*)) also (*calculation: ‹(⋀(x::'a::executable_euclidean_space) y::'a::executable_euclidean_space. x ≤ y ⟹ ¦fst (X::'a::executable_euclidean_space × 'a::executable_euclidean_space pdevs)¦ + x ≤ ¦fst X¦ + y) ⟹ ¦aform_val (e::nat ⇒ real) X¦ ≤ ¦fst X¦ + Radius X›*) note tdev' (*‹tdev ?x ≤ tdev' ?p ?x›*) also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ ¦fst X¦ + x ≤ ¦fst X¦ + y; ⋀x y. x ≤ y ⟹ ¦fst X¦ + x ≤ ¦fst X¦ + y⟧ ⟹ ¦aform_val e X¦ ≤ ¦fst X¦ + Radius' ?p1 X›*) note eucl_truncate_up (*‹?x ≤ eucl_truncate_up ?e ?x›*) finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ ¦fst X¦ + x ≤ ¦fst X¦ + y; ⋀x y. x ≤ y ⟹ ¦fst X¦ + x ≤ ¦fst X¦ + y⟧ ⟹ ¦aform_val e X¦ ≤ eucl_truncate_up ?e1 (¦fst X¦ + Radius' ?p3 X)›*) show "?thesis" (*goal: ‹¦aform_val e X¦ ≤ eucl_truncate_up p (¦fst X¦ + Radius' p X)›*) by simp qed subsubsection ‹truncation with error bound› definition "trunc_bound_eucl p s = (let d = eucl_truncate_down p s; ed = abs (d - s) in (d, eucl_truncate_up p ed))" lemma trunc_bound_euclE: obtains err where "¦err¦ ≤ snd (trunc_bound_eucl p x)" "fst (trunc_bound_eucl p x) = x + err" proof (atomize_elim) (*goal: ‹∃err. ¦err¦ ≤ snd (trunc_bound_eucl p x) ∧ fst (trunc_bound_eucl p x) = x + err›*) have "fst (trunc_bound_eucl p x) = x + (eucl_truncate_down p x - x)" (is "_ = _ + ?err") by (simp add: trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) moreover have "abs ?err ≤ snd (trunc_bound_eucl p x)" by (simp add: trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eucl_truncate_up (*‹?x ≤ eucl_truncate_up ?e ?x›*)) ultimately show "∃err. ¦err¦ ≤ snd (trunc_bound_eucl p x) ∧ fst (trunc_bound_eucl p x) = x + err" by auto qed definition "trunc_bound_pdevs p x = (trunc_pdevs p x, tdev' p (trunc_err_pdevs p x))" lemma pdevs_apply_fst_trunc_bound_pdevs[simp]: "pdevs_apply (fst (trunc_bound_pdevs p x)) = pdevs_apply (trunc_pdevs p x)" by (simp add: trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*)) lemma trunc_bound_pdevsE: assumes "e ∈ UNIV → {- 1..1}" obtains err where "¦err¦ ≤ snd (trunc_bound_pdevs p x)" "pdevs_val e (fst ((trunc_bound_pdevs p x))) = pdevs_val e x + err" proof (atomize_elim) (*goal: ‹∃err::'a. ¦err¦ ≤ snd (trunc_bound_pdevs (p::nat) (x::'a pdevs)) ∧ pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs p x)) = pdevs_val e x + err›*) have "pdevs_val e (fst (trunc_bound_pdevs p x)) = pdevs_val e x + pdevs_val e (add_pdevs (trunc_pdevs p x) (uminus_pdevs x))" (is "_ = _ + ?err") by (simp add: trunc_bound_pdevs_def (*‹trunc_bound_pdevs (?p::nat) (?x::?'a pdevs) = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*)) moreover have "abs ?err ≤ snd (trunc_bound_pdevs p x)" using assms (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp add: pdevs_val_trunc_pdevs (*‹pdevs_val ?e (trunc_pdevs ?p ?X) = pdevs_val ?e ?X + pdevs_val ?e (trunc_err_pdevs ?p ?X)›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eucl_truncate_up (*‹?x ≤ eucl_truncate_up ?e ?x›*) intro!: order_trans[OF abs_pdevs_val_le_tdev tdev'] (*‹?e2 ∈ UNIV → {- 1..1} ⟹ ¦pdevs_val ?e2 ?x1¦ ≤ tdev' ?p1 ?x1›*)) ultimately show "∃err. ¦err¦ ≤ snd (trunc_bound_pdevs p x) ∧ pdevs_val e (fst ((trunc_bound_pdevs p x))) = pdevs_val e x + err" by auto qed lemma degree_add_pdevs_le: assumes "degree X ≤ n" assumes "degree Y ≤ n" shows "degree (add_pdevs X Y) ≤ n" using assms (*‹degree X ≤ n› ‹degree Y ≤ n›*) by (auto intro!: degree_le (*‹∀j≥?d. pdevs_apply ?x j = 0 ⟹ degree ?x ≤ ?d›*)) lemma truncate_aform_error_aform_cancel: "aform_val e (truncate_aform p z) = aform_val e z + aform_val e (truncate_error_aform p z) " by (simp add: truncate_aform_def (*‹truncate_aform ?p ?x = (eucl_truncate_down ?p (fst ?x), trunc_pdevs ?p (snd ?x))›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) truncate_error_aform_def (*‹truncate_error_aform ?p ?x = (eucl_truncate_down ?p (fst ?x) - fst ?x, trunc_err_pdevs ?p (snd ?x))›*) pdevs_val_trunc_pdevs (*‹pdevs_val ?e (trunc_pdevs ?p ?X) = pdevs_val ?e ?X + pdevs_val ?e (trunc_err_pdevs ?p ?X)›*)) lemma error_absE: assumes "abs err ≤ k" obtains e::real where "err = e * k" "e ∈ {-1 .. 1}" using assms (*‹¦err¦ ≤ k›*) apply atomize_elim (*goal: ‹(⋀e. ⟦err = e * k; e ∈ {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) apply (safe intro!: exI[where x="err / abs k"] (*‹(?P::real ⇒ bool) ((err::real) / ¦k::real¦) ⟹ ∃x::real. ?P x›*) divide_atLeastAtMost_1_absI (*‹¦?x::real¦ ≤ ¦?a::real¦ ⟹ ?x / ?a ∈ {- (1::real)..1::real}›*)) (*goals: 1. ‹¦err¦ ≤ k ⟹ err = err / ¦k¦ * k› 2. ‹¦err¦ ≤ k ⟹ ¦err¦ ≤ ¦¦k¦¦› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma eucl_truncate_up_nonneg_eq_zero_iff: "x ≥ 0 ⟹ eucl_truncate_up p x = 0 ⟷ x = 0" by (metis (poly_guards_query) eq_iff (*‹((?a::?'a) = (?b::?'a)) = (?a ≤ ?b ∧ ?b ≤ ?a)›*) eucl_truncate_up (*‹(?x::?'a) ≤ eucl_truncate_up (?e::nat) ?x›*) eucl_truncate_up_zero (*‹eucl_truncate_up (?p::nat) (0::?'a) = (0::?'a)›*)) lemma aform_val_consume_error: assumes "abs err ≤ abs (pdevs_apply (snd X) n)" shows "aform_val (e(n := 0)) X + err = aform_val (e(n := err/pdevs_apply (snd X) n)) X" using assms (*‹¦err::real¦ ≤ ¦pdevs_apply (snd (X::real × real pdevs)) (n::nat)¦›*) by (auto simp add: aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*)) lemma aform_val_consume_errorE: fixes X::"real aform" assumes "abs err ≤ abs (pdevs_apply (snd X) n)" obtains err' where "aform_val (e(n := 0)) X + err = aform_val (e(n := err')) X" "err' ∈ {-1 .. 1}" apply atomize_elim (*goal: ‹(⋀err'. ⟦aform_val (e(n := 0)) X + err = aform_val (e(n := err')) X; err' ∈ {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) apply (rule aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) assms (*‹¦err¦ ≤ ¦pdevs_apply (snd X) n¦›*) aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) divide_atLeastAtMost_1_absI (*‹¦?x¦ ≤ ¦?a¦ ⟹ ?x / ?a ∈ {- 1..1}›*)) (*goal: ‹∃err'. aform_val (e(n := 0)) X + err = aform_val (e(n := err')) X ∧ err' ∈ {- 1..1}›*) apply (rule aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) assms (*‹¦err¦ ≤ ¦pdevs_apply (snd X) n¦›*) aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) divide_atLeastAtMost_1_absI (*‹¦?x¦ ≤ ¦?a¦ ⟹ ?x / ?a ∈ {- 1..1}›*)) (*goals: 1. ‹aform_val ((e::nat ⇒ real)(n::nat := 0::real)) (X::real × real pdevs) + (err::real) = aform_val (e(n := ?err'2::real)) X› 2. ‹(?err'2::real) ∈ {- (1::real)..1::real}› discuss goal 1*) apply (rule aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) assms (*‹¦err¦ ≤ ¦pdevs_apply (snd X) n¦›*) aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) divide_atLeastAtMost_1_absI (*‹¦?x¦ ≤ ¦?a¦ ⟹ ?x / ?a ∈ {- 1..1}›*)) (*top goal: ‹aform_val (e(n := 0)) X + err = aform_val (e(n := ?err'2)) X› and 1 goal remains*) apply (rule aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) assms (*‹¦err¦ ≤ ¦pdevs_apply (snd X) n¦›*) aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) divide_atLeastAtMost_1_absI (*‹¦?x¦ ≤ ¦?a¦ ⟹ ?x / ?a ∈ {- 1..1}›*)) (*discuss goal 2*) apply (rule aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) assms (*‹¦err¦ ≤ ¦pdevs_apply (snd X) n¦›*) aform_val_consume_error (*‹¦?err¦ ≤ ¦pdevs_apply (snd ?X) ?n¦ ⟹ aform_val (?e(?n := 0)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) divide_atLeastAtMost_1_absI (*‹¦?x¦ ≤ ¦?a¦ ⟹ ?x / ?a ∈ {- 1..1}›*)) (*goal: ‹(err::real) / pdevs_apply (snd (X::real × real pdevs)) (n::nat) ∈ {- (1::real)..1::real}›*) apply (rule aform_val_consume_error (*‹¦?err::real¦ ≤ ¦pdevs_apply (snd (?X::real × real pdevs)) (?n::nat)¦ ⟹ aform_val ((?e::nat ⇒ real)(?n := 0::real)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) assms (*‹¦err::real¦ ≤ ¦pdevs_apply (snd (X::real × real pdevs)) (n::nat)¦›*) aform_val_consume_error (*‹¦?err::real¦ ≤ ¦pdevs_apply (snd (?X::real × real pdevs)) (?n::nat)¦ ⟹ aform_val ((?e::nat ⇒ real)(?n := 0::real)) ?X + ?err = aform_val (?e(?n := ?err / pdevs_apply (snd ?X) ?n)) ?X›*) exI (*‹(?P::?'a::type ⇒ bool) (?x::?'a::type) ⟹ ∃x::?'a::type. ?P x›*) conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*) divide_atLeastAtMost_1_absI (*‹¦?x::real¦ ≤ ¦?a::real¦ ⟹ ?x / ?a ∈ {- (1::real)..1::real}›*)) (*proven 2 subgoals*) . lemma degree_trunc_pdevs_le: assumes "degree X ≤ n" shows "degree (trunc_pdevs p X) ≤ n" using assms (*‹degree X ≤ n›*) by (auto intro!: degree_le (*‹∀j≥?d. pdevs_apply ?x j = 0 ⟹ degree ?x ≤ ?d›*)) lemma pdevs_val_sum_less_degree: "pdevs_val e X = (∑i<d. e i *⇩R pdevs_apply X i)" if "degree X ≤ d" unfolding pdevs_val_pdevs_domain (*goal: ‹(∑i∈pdevs_domain X. e i *⇩R pdevs_apply X i) = (∑i<d. e i *⇩R pdevs_apply X i)›*) apply (rule sum.mono_neutral_cong_left (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?h i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goal: ‹(∑i::nat∈pdevs_domain X. (e::nat ⇒ real) i *⇩R pdevs_apply (X::'a::real_normed_vector pdevs) i) = (∑i::nat<d::nat. e i *⇩R pdevs_apply X i)›*) using that (*‹degree X ≤ d›*) apply - (*goals: 1. ‹degree X ≤ d ⟹ finite {..<d}› 2. ‹degree X ≤ d ⟹ pdevs_domain X ⊆ {..<d}› 3. ‹degree X ≤ d ⟹ ∀i∈{..<d} - pdevs_domain X. e i *⇩R pdevs_apply X i = 0› 4. ‹⋀x. ⟦x ∈ pdevs_domain X; degree X ≤ d⟧ ⟹ e x *⇩R pdevs_apply X x = e x *⇩R pdevs_apply X x› discuss goal 1*) apply force (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*discuss goal 4*) apply force (*proven 4 subgoals*) . subsubsection ‹general affine operation› definition "affine_binop (X::real aform) Y a b c d k = (a * fst X + b * fst Y + c, pdev_upd (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) k d)" lemma pdevs_domain_One_pdevs[simp]: "pdevs_domain (One_pdevs::'a::executable_euclidean_space pdevs) = {0..<DIM('a)}" apply (auto simp: length_Basis_list (*‹length Basis_list = DIM(?'a)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goal: ‹pdevs_domain One_pdevs = {0..<DIM('a)}›*) subgoal for i using nth_Basis_list_in_Basis[of i, where 'a = 'a] (*‹(i::nat) < length Basis_list ⟹ Basis_list ! i ∈ Basis›*) by (auto simp: length_Basis_list (*‹length Basis_list = DIM(?'a)›*)) . lemma pdevs_val_One_pdevs: "pdevs_val e (One_pdevs::'a::executable_euclidean_space pdevs) = (∑i<DIM('a). e i *⇩R Basis_list ! i)" by (auto simp: pdevs_val_pdevs_domain (*‹pdevs_val ?e ?X = (∑i∈pdevs_domain ?X. ?e i *⇩R pdevs_apply ?X i)›*) length_Basis_list (*‹length Basis_list = DIM(?'a)›*) intro!:sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) lemma affine_binop: assumes "degree_aforms [X, Y] ≤ k" shows "aform_val e (affine_binop X Y a b c d k) = a * aform_val e X + b * aform_val e Y + c + e k * d" using assms (*‹degree_aforms [X, Y] ≤ k›*) by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) affine_binop_def (*‹affine_binop ?X ?Y ?a ?b ?c ?d ?k = (?a * fst ?X + ?b * fst ?Y + ?c, pdev_upd (add_pdevs (scaleR_pdevs ?a (snd ?X)) (scaleR_pdevs ?b (snd ?Y))) ?k ?d)›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) pdevs_val_msum_pdevs (*‹degree ?f ≤ ?n ⟹ pdevs_val ?e (msum_pdevs ?n ?f ?g) = pdevs_val ?e ?f + pdevs_val (λi. ?e (i + ?n)) ?g›*) degree_add_pdevs_le (*‹⟦degree ?X ≤ ?n; degree ?Y ≤ ?n⟧ ⟹ degree (add_pdevs ?X ?Y) ≤ ?n›*) pdevs_val_One_pdevs (*‹pdevs_val ?e One_pdevs = (∑i<DIM(?'a). ?e i *⇩R Basis_list ! i)›*) Basis_list_real_def (*‹Basis_list = [1]›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) definition "affine_binop' p (X::real aform) Y a b c d k = (let ― ‹TODO: more round-off operations here?› (r, e1) = trunc_bound_eucl p (a * fst X + b * fst Y + c); (Z, e2) = trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) in (r, pdev_upd Z k (sum_list' p [e1, e2, d])) )" lemma sum_list'_noneg_eq_zero_iff: "sum_list' p xs = 0 ⟷ (∀x∈set xs. x = 0)" if "⋀x. x ∈ set xs ⟹ x ≥ 0" proof (safe) (*goals: 1. ‹⋀x. ⟦sum_list' p xs = 0; x ∈ set xs⟧ ⟹ x = 0› 2. ‹∀x∈set xs. x = 0 ⟹ sum_list' p xs = 0›*) fix x assume x: "sum_list' p xs = 0" "x ∈ set xs" (*‹sum_list' (p::nat) (xs::'a list) = (0::'a)› ‹(x::'a) ∈ set (xs::'a list)›*) from that (*‹?x ∈ set xs ⟹ 0 ≤ ?x›*) have "0 ≤ sum_list xs" by (auto intro!: sum_list_nonneg (*‹(⋀x. x ∈ set ?xs ⟹ 0 ≤ x) ⟹ 0 ≤ sum_list ?xs›*)) with that (*‹?x ∈ set xs ⟹ 0 ≤ ?x›*) x (*‹sum_list' p xs = 0› ‹x ∈ set xs›*) have "sum_list xs = 0" by (metis antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*) sum_list_le_sum_list' (*‹sum_list ?xs ≤ sum_list' ?p ?xs›*)) then have "(∑i<length xs. xs ! i) = 0" by (auto simp: sum_list_sum_nth (*‹sum_list ?xs = sum ((!) ?xs) {0..<length ?xs}›*) atLeast0LessThan (*‹{0..<?n} = {..<?n}›*)) then show "x = 0" using x(2) (*‹(x::'a) ∈ set (xs::'a list)›*) that (*‹?x ∈ set xs ⟹ 0 ≤ ?x›*) apply (subst (asm) sum_nonneg_eq_0_iff (*‹⟦finite ?A; ⋀x. x ∈ ?A ⟹ 0 ≤ ?f x⟧ ⟹ (sum ?f ?A = 0) = (∀x∈?A. ?f x = 0)›*)) (*goals: 1. ‹⟦(x::'a) ∈ set (xs::'a list); ⋀x::'a. x ∈ set xs ⟹ (0::'a) ≤ x⟧ ⟹ finite {..<length xs}› 2. ‹⋀xa::nat. ⟦(x::'a) ∈ set (xs::'a list); ⋀x::'a. x ∈ set xs ⟹ (0::'a) ≤ x; xa ∈ {..<length xs}⟧ ⟹ (0::'a) ≤ xs ! xa› 3. ‹⟦∀x::nat∈{..<length (xs::'a list)}. xs ! x = (0::'a); (x::'a) ∈ set xs; ⋀x::'a. x ∈ set xs ⟹ (0::'a) ≤ x⟧ ⟹ x = (0::'a)› discuss goal 1*) apply ((auto simp: in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*))[1]) (*discuss goal 2*) apply ((auto simp: in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*))[1]) (*discuss goal 3*) apply ((auto simp: in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*))[1]) (*proven 3 subgoals*) . next (*goal: ‹∀x∈set xs. x = 0 ⟹ sum_list' p xs = 0›*) show "∀x∈set xs. x = 0 ⟹ sum_list' p xs = 0" apply (induction xs) (*goals: 1. ‹∀x∈set []. x = 0 ⟹ sum_list' p [] = 0› 2. ‹⋀a xs. ⟦∀x∈set xs. x = 0 ⟹ sum_list' p xs = 0; ∀x∈set (a # xs). x = 0⟧ ⟹ sum_list' p (a # xs) = 0› discuss goal 1*) apply ((auto simp: sum_list'_def (*‹sum_list' (?p::nat) (?xs::?'a list) = fold (λ(a::?'a) b::?'a. eucl_truncate_up ?p (a + b)) ?xs (0::?'a)›*))[1]) (*discuss goal 2*) apply ((auto simp: sum_list'_def (*‹sum_list' ?p ?xs = fold (λa b. eucl_truncate_up ?p (a + b)) ?xs 0›*))[1]) (*proven 2 subgoals*) . qed lemma affine_binop'E: assumes deg: "degree_aforms [X, Y] ≤ k" assumes e: "e ∈ UNIV → {- 1..1}" assumes d: "abs u ≤ d" obtains ek where "a * aform_val e X + b * aform_val e Y + c + u = aform_val (e(k:=ek)) (affine_binop' p X Y a b c d k)" "ek ∈ {-1 .. 1}" proof (-) (*goal: ‹(⋀ek. ⟦a * aform_val e X + b * aform_val e Y + c + u = aform_val (e(k := ek)) (affine_binop' p X Y a b c d k); ek ∈ {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) have "a * aform_val e X + b * aform_val e Y + c + u = (a * fst X + b * fst Y + c) + pdevs_val e (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) + u" (is "_ = ?c + pdevs_val _ ?ps + _") by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) from trunc_bound_euclE[of p ?c] (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_eucl p (a * fst X + b * fst Y + c)); fst (trunc_bound_eucl p (a * fst X + b * fst Y + c)) = a * fst X + b * fst Y + c + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain ec where ec: "abs ec ≤ snd (trunc_bound_eucl p ?c)" "fst (trunc_bound_eucl p ?c) - ec = ?c" (*goal: ‹(⋀ec. ⟦¦ec¦ ≤ snd (trunc_bound_eucl p (a * fst X + b * fst Y + c)); fst (trunc_bound_eucl p (a * fst X + b * fst Y + c)) - ec = a * fst X + b * fst Y + c⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) moreover from trunc_bound_pdevsE[OF e, of p ?ps] (*‹(⋀err::real. ⟦¦err¦ ≤ snd (trunc_bound_pdevs (p::nat) (add_pdevs (scaleR_pdevs (a::real) (snd (X::real × real pdevs))) (scaleR_pdevs (b::real) (snd (Y::real × real pdevs))))); pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))))) = pdevs_val e (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) + err⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain eps where eps: "¦eps¦ ≤ snd (trunc_bound_pdevs p ?ps)" "pdevs_val e (fst (trunc_bound_pdevs p ?ps)) - eps = pdevs_val e ?ps" (*goal: ‹(⋀eps. ⟦¦eps¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))); pdevs_val e (fst (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))))) - eps = pdevs_val e (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) moreover define ek where "ek = (u - ec - eps)/ sum_list' p [snd (trunc_bound_eucl p ?c), snd (trunc_bound_pdevs p ?ps), d]" have "degree (fst (trunc_bound_pdevs p ?ps)) ≤ degree_aforms [X, Y]" by (auto simp: trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) intro!: degree_trunc_pdevs_le (*‹degree ?X ≤ ?n ⟹ degree (trunc_pdevs ?p ?X) ≤ ?n›*) degree_add_pdevs_le (*‹⟦degree ?X ≤ ?n; degree ?Y ≤ ?n⟧ ⟹ degree (add_pdevs ?X ?Y) ≤ ?n›*)) moreover from this (*‹degree (fst (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))))) ≤ degree_aforms [X, Y]›*) have "pdevs_apply (fst (trunc_bound_pdevs p ?ps)) k = 0" using deg (*‹degree_aforms [X, Y] ≤ k›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) by blast ultimately have "a * aform_val e X + b * aform_val e Y + c + u = aform_val (e(k:=ek)) (affine_binop' p X Y a b c d k)" apply (auto simp: affine_binop'_def (*‹affine_binop' (?p::nat) (?X::real × real pdevs) (?Y::real × real pdevs) (?a::real) (?b::real) (?c::real) (?d::real) (?k::nat) = (let (r::real, e1::real) = trunc_bound_eucl ?p (?a * fst ?X + ?b * fst ?Y + ?c); (Z::real pdevs, e2::real) = trunc_bound_pdevs ?p (add_pdevs (scaleR_pdevs ?a (snd ?X)) (scaleR_pdevs ?b (snd ?Y))) in (r, pdev_upd Z ?k (sum_list' ?p [e1, e2, ?d])))›*) algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹a * aform_val e X + b * aform_val e Y + c + u = aform_val (e(k := ek)) (affine_binop' p X Y a b c d k)›*) subgoal for x and y and z apply (cases "sum_list' p [x, z, d] = 0") (*goal: ‹⟦¦ec::real¦ ≤ (x::real); ¦eps::real¦ ≤ (z::real); pdevs_val (e::nat ⇒ real) (y::real pdevs) = eps + ((a::real) * pdevs_val e (snd (X::real × real pdevs)) + (b::real) * pdevs_val e (snd (Y::real × real pdevs))); degree y ≤ degrees [snd X, snd Y]; eucl_truncate_down (p::nat) (a * pdevs_apply (snd X) (k::nat) + b * pdevs_apply (snd Y) k) = (0::real); trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) = (y, z); trunc_bound_eucl p ((c::real) + (a * fst X + b * fst Y)) = (c + (ec + (a * fst X + b * fst Y)), x)⟧ ⟹ (u::real) + e k * pdevs_apply y k = ec + (eps + (ek::real) * sum_list' p [x, z, d::real])›*) subgoal for apply simp (*goal: ‹⟦¦ec¦ ≤ x; ¦eps¦ ≤ z; pdevs_val e y = eps + (a * pdevs_val e (snd X) + b * pdevs_val e (snd Y)); degree y ≤ degrees [snd X, snd Y]; eucl_truncate_down p (a * pdevs_apply (snd X) k + b * pdevs_apply (snd Y) k) = 0; trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) = (y, z); trunc_bound_eucl p (c + (a * fst X + b * fst Y)) = (c + (ec + (a * fst X + b * fst Y)), x); sum_list' p [x, z, d] = 0⟧ ⟹ u + e k * pdevs_apply y k = ec + (eps + ek * sum_list' p [x, z, d])›*) apply (subst (asm) sum_list'_noneg_eq_zero_iff (*‹(⋀x. x ∈ set ?xs ⟹ 0 ≤ x) ⟹ (sum_list' ?p ?xs = 0) = (∀x∈set ?xs. x = 0)›*)) (*goal: ‹⟦¦ec::real¦ ≤ (x::real); ¦eps::real¦ ≤ (z::real); pdevs_val (e::nat ⇒ real) (y::real pdevs) = eps + ((a::real) * pdevs_val e (snd (X::real × real pdevs)) + (b::real) * pdevs_val e (snd (Y::real × real pdevs))); degree y ≤ degrees [snd X, snd Y]; eucl_truncate_down (p::nat) (a * pdevs_apply (snd X) (k::nat) + b * pdevs_apply (snd Y) k) = (0::real); trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) = (y, z); trunc_bound_eucl p ((c::real) + (a * fst X + b * fst Y)) = (c + (ec + (a * fst X + b * fst Y)), x); sum_list' p [x, z, d::real] = (0::real)⟧ ⟹ (u::real) + e k * pdevs_apply y k = ec + eps›*) using d (*‹¦u::real¦ ≤ (d::real)›*) deg (*‹degree_aforms [X, Y] ≤ k›*) apply - (*goals: 1. ‹⋀xa. ⟦¦ec¦ ≤ x; ¦eps¦ ≤ z; pdevs_val e y = eps + (a * pdevs_val e (snd X) + b * pdevs_val e (snd Y)); degree y ≤ degrees [snd X, snd Y]; eucl_truncate_down p (a * pdevs_apply (snd X) k + b * pdevs_apply (snd Y) k) = 0; trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) = (y, z); trunc_bound_eucl p (c + (a * fst X + b * fst Y)) = (c + (ec + (a * fst X + b * fst Y)), x); xa ∈ set [x, z, d]; ¦u¦ ≤ d; degree_aforms [X, Y] ≤ k⟧ ⟹ 0 ≤ xa› 2. ‹⟦¦ec¦ ≤ x; ¦eps¦ ≤ z; pdevs_val e y = eps + (a * pdevs_val e (snd X) + b * pdevs_val e (snd Y)); degree y ≤ degrees [snd X, snd Y]; eucl_truncate_down p (a * pdevs_apply (snd X) k + b * pdevs_apply (snd Y) k) = 0; trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) = (y, z); trunc_bound_eucl p (c + (a * fst X + b * fst Y)) = (c + (ec + (a * fst X + b * fst Y)), x); ∀x∈set [x, z, d]. x = 0; ¦u¦ ≤ d; degree_aforms [X, Y] ≤ k⟧ ⟹ u + e k * pdevs_apply y k = ec + eps› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subgoal for apply (simp add: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) ek_def (*‹ek = (u - ec - eps) / sum_list' p [snd (trunc_bound_eucl p (a * fst X + b * fst Y + c)), snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))), d]›*)) (*goal: ‹⟦¦ec::real¦ ≤ (x::real); ¦eps::real¦ ≤ (z::real); pdevs_val (e::nat ⇒ real) (y::real pdevs) = eps + ((a::real) * pdevs_val e (snd (X::real × real pdevs)) + (b::real) * pdevs_val e (snd (Y::real × real pdevs))); degree y ≤ degrees [snd X, snd Y]; eucl_truncate_down (p::nat) (a * pdevs_apply (snd X) (k::nat) + b * pdevs_apply (snd Y) k) = (0::real); trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))) = (y, z); trunc_bound_eucl p ((c::real) + (a * fst X + b * fst Y)) = (c + (ec + (a * fst X + b * fst Y)), x); sum_list' p [x, z, d::real] ≠ (0::real)⟧ ⟹ (u::real) + e k * pdevs_apply y k = ec + (eps + (ek::real) * sum_list' p [x, z, d])›*) using ‹pdevs_apply (fst (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))))) k = 0› (*‹pdevs_apply (fst (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))))) k = 0›*) by auto . . moreover have "ek ∈ {-1 .. 1}" unfolding ek_def (*goal: ‹(u - ec - eps) / sum_list' p [snd (trunc_bound_eucl p (a * fst X + b * fst Y + c)), snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))), d] ∈ {- 1..1}›*) apply (rule divide_atLeastAtMost_1_absI (*‹¦?x¦ ≤ ¦?a¦ ⟹ ?x / ?a ∈ {- 1..1}›*)) (*goal: ‹(u - ec - eps) / sum_list' p [snd (trunc_bound_eucl p (a * fst X + b * fst Y + c)), snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))), d] ∈ {- 1..1}›*) apply (rule abs_triangle_ineq4[THEN order_trans] (*‹¦?a1¦ + ¦?b1¦ ≤ ?z ⟹ ¦?a1 - ?b1¦ ≤ ?z›*)) (*goal: ‹¦u - ec - eps¦ ≤ ¦sum_list' p [snd (trunc_bound_eucl p (a * fst X + b * fst Y + c)), snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))), d]¦›*) apply (rule order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goal: ‹¦(u::real) - (ec::real)¦ + ¦eps::real¦ ≤ ¦sum_list' (p::nat) [snd (trunc_bound_eucl p ((a::real) * fst (X::real × real pdevs) + (b::real) * fst (Y::real × real pdevs) + (c::real))), snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y)))), d::real]¦›*) apply (rule add_right_mono (*‹?a ≤ ?b ⟹ ?a + ?c ≤ ?b + ?c›*)) (*top goal: ‹¦u - ec¦ + ¦eps¦ ≤ ?y5› and 1 goal remains*) apply (rule abs_triangle_ineq4 (*‹¦?a - ?b¦ ≤ ¦?a¦ + ¦?b¦›*)) (*top goal: ‹¦(u::real) - (ec::real)¦ ≤ (?b8::real)› and 1 goal remains*) using ec(1) (*‹¦ec¦ ≤ snd (trunc_bound_eucl p (a * fst X + b * fst Y + c))›*) eps(1) (*‹¦eps¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (scaleR_pdevs a (snd X)) (scaleR_pdevs b (snd Y))))›*) by (auto simp: sum_list'_def (*‹sum_list' ?p ?xs = fold (λa b. eucl_truncate_up ?p (a + b)) ?xs 0›*) eucl_truncate_up_real_def (*‹eucl_truncate_up ?prec ?b = truncate_up ?prec ?b›*) add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) intro!: order_trans[OF _ abs_ge_self] (*‹?x ≤ ?y ⟹ ?x ≤ ¦?y¦›*) order_trans[OF _ truncate_up_le] (*‹⟦?x ≤ ?y; ?y ≤ ?y1⟧ ⟹ ?x ≤ truncate_up ?prec1 ?y1›*) add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) d (*‹¦u¦ ≤ d›*)) ultimately show "?thesis" (*goal: ‹thesis›*) by standard qed subsubsection ‹Inf/Sup› definition "Inf_aform' p X = eucl_truncate_down p (fst X - tdev' p (snd X))" definition "Sup_aform' p X = eucl_truncate_up p (fst X + tdev' p (snd X))" lemma Inf_aform': shows "Inf_aform' p X ≤ Inf_aform X" unfolding Inf_aform_def Inf_aform'_def (*goal: ‹eucl_truncate_down p (fst X - Radius' p X) ≤ fst X - Radius X›*) by (auto intro!: eucl_truncate_down_le (*‹?x ≤ ?y ⟹ eucl_truncate_down ?w ?x ≤ ?y›*) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) tdev' (*‹tdev ?x ≤ tdev' ?p ?x›*)) lemma Sup_aform': shows "Sup_aform X ≤ Sup_aform' p X" unfolding Sup_aform_def Sup_aform'_def (*goal: ‹fst X + Radius X ≤ eucl_truncate_up p (fst X + Radius' p X)›*) apply (rule eucl_truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ eucl_truncate_up ?e ?y›*) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) tdev' (*‹tdev ?x ≤ tdev' ?p ?x›*)) (*goal: ‹fst X + Radius X ≤ eucl_truncate_up p (fst X + Radius' p X)›*) apply (rule eucl_truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ eucl_truncate_up ?e ?y›*) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) tdev' (*‹tdev ?x ≤ tdev' ?p ?x›*)) (*goal: ‹fst (X::'a × 'a pdevs) + Radius X ≤ fst X + Radius' (p::nat) X›*) by (rule eucl_truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ eucl_truncate_up ?e ?y›*) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) tdev' (*‹tdev ?x ≤ tdev' ?p ?x›*)) lemma Inf_aform_le_Sup_aform[intro]: "Inf_aform X ≤ Sup_aform X" by (simp add: Inf_aform_def (*‹Inf_aform (?X::?'a::ordered_euclidean_space × ?'a::ordered_euclidean_space pdevs) = fst ?X - Radius ?X›*) Sup_aform_def (*‹Sup_aform (?X::?'a::ordered_euclidean_space × ?'a::ordered_euclidean_space pdevs) = fst ?X + Radius ?X›*) algebra_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 34 facts*)) lemma Inf_aform'_le_Sup_aform'[intro]: "Inf_aform' p X ≤ Sup_aform' p X" by (metis Inf_aform' (*‹Inf_aform' ?p ?X ≤ Inf_aform ?X›*) Inf_aform_le_Sup_aform (*‹Inf_aform ?X ≤ Sup_aform ?X›*) Sup_aform' (*‹Sup_aform ?X ≤ Sup_aform' ?p ?X›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) definition "ivls_of_aforms prec = map (λa. Interval' (float_of (Inf_aform' prec a)) (float_of(Sup_aform' prec a)))" lemma assumes "⋀i. e'' i ≤ 1" assumes "⋀i. -1 ≤ e'' i" shows Inf_aform'_le: "Inf_aform' p r ≤ aform_val e'' r" and Sup_aform'_le: "aform_val e'' r ≤ Sup_aform' p r" (*goals: 1. ‹Inf_aform' (p::nat) (r::'a::executable_euclidean_space × 'a::executable_euclidean_space pdevs) ≤ aform_val (e''::nat ⇒ real) r› 2. ‹aform_val (e''::nat ⇒ real) (r::'a::executable_euclidean_space × 'a::executable_euclidean_space pdevs) ≤ Sup_aform' (p::nat) r› discuss goal 1*) apply ((auto intro!: order_trans[OF Inf_aform'] (*‹Inf_aform (?X1::?'a1 × ?'a1 pdevs) ≤ (?z::?'a1) ⟹ Inf_aform' (?p1::nat) ?X1 ≤ ?z›*) order_trans[OF _ Sup_aform'] (*‹(?x::?'a1) ≤ Sup_aform (?X1::?'a1 × ?'a1 pdevs) ⟹ ?x ≤ Sup_aform' (?p1::nat) ?X1›*) Inf_aform (*‹(?e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real} ⟹ Inf_aform (?X::?'a × ?'a pdevs) ≤ aform_val ?e ?X›*) Sup_aform (*‹(?e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real} ⟹ aform_val ?e (?X::?'a × ?'a pdevs) ≤ Sup_aform ?X›*) simp: Affine_def (*‹Affine (?X::?'a × ?'a pdevs) = valuate (λe::nat ⇒ real. aform_val e ?X)›*) valuate_def (*‹valuate (?x::(nat ⇒ real) ⇒ ?'a) = ?x ` (UNIV → {- (1::real)..1::real})›*) intro!: image_eqI[where x=e''] (*‹⟦(?b::?'a) = (?f::(nat ⇒ real) ⇒ ?'a) (e''::nat ⇒ real); e'' ∈ (?A::(nat ⇒ real) set)⟧ ⟹ ?b ∈ ?f ` ?A›*) assms (*‹(e''::nat ⇒ real) (?i::nat) ≤ (1::real)› ‹- (1::real) ≤ (e''::nat ⇒ real) (?i::nat)›*))[1]) (*discuss goal 2*) apply ((auto intro!: order_trans[OF Inf_aform'] (*‹Inf_aform ?X1 ≤ ?z ⟹ Inf_aform' ?p1 ?X1 ≤ ?z›*) order_trans[OF _ Sup_aform'] (*‹?x ≤ Sup_aform ?X1 ⟹ ?x ≤ Sup_aform' ?p1 ?X1›*) Inf_aform (*‹?e ∈ UNIV → {- 1..1} ⟹ Inf_aform ?X ≤ aform_val ?e ?X›*) Sup_aform (*‹?e ∈ UNIV → {- 1..1} ⟹ aform_val ?e ?X ≤ Sup_aform ?X›*) simp: Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*) intro!: image_eqI[where x=e''] (*‹⟦?b = ?f e''; e'' ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) assms (*‹e'' ?i ≤ 1› ‹- 1 ≤ e'' ?i›*))[1]) (*proven 2 subgoals*) . lemma InfSup_aform'_in_float[intro, simp]: "Inf_aform' p X ∈ float" "Sup_aform' p X ∈ float" (*goals: 1. ‹Inf_aform' p X ∈ float› 2. ‹Sup_aform' p X ∈ float› discuss goal 1*) apply ((auto simp: Inf_aform'_def (*‹Inf_aform' (?p::nat) (?X::?'a::executable_euclidean_space × ?'a::executable_euclidean_space pdevs) = eucl_truncate_down ?p (fst ?X - Radius' ?p ?X)›*) eucl_truncate_down_real_def (*‹eucl_truncate_down (?prec::nat) (?b::real) = truncate_down ?prec ?b›*) Sup_aform'_def (*‹Sup_aform' (?p::nat) (?X::?'a::executable_euclidean_space × ?'a::executable_euclidean_space pdevs) = eucl_truncate_up ?p (fst ?X + Radius' ?p ?X)›*) eucl_truncate_up_real_def (*‹eucl_truncate_up (?prec::nat) (?b::real) = truncate_up ?prec ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: Inf_aform'_def (*‹Inf_aform' ?p ?X = eucl_truncate_down ?p (fst ?X - Radius' ?p ?X)›*) eucl_truncate_down_real_def (*‹eucl_truncate_down ?prec ?b = truncate_down ?prec ?b›*) Sup_aform'_def (*‹Sup_aform' ?p ?X = eucl_truncate_up ?p (fst ?X + Radius' ?p ?X)›*) eucl_truncate_up_real_def (*‹eucl_truncate_up ?prec ?b = truncate_up ?prec ?b›*))[1]) (*proven 2 subgoals*) . theorem ivls_of_aforms: "xs ∈ Joints XS ⟹ bounded_by xs (ivls_of_aforms prec XS)" by (auto simp: bounded_by_def (*‹bounded_by ?xs ?vs = (∀i<length ?vs. case ?vs ! i of None ⇒ True | Some ivl ⇒ ?xs ! i ∈⇩r ivl)›*) ivls_of_aforms_def (*‹ivls_of_aforms ?prec = map (λa. Interval' (float_of (Inf_aform' ?prec a)) (float_of (Sup_aform' ?prec a)))›*) Affine_def (*‹Affine ?X = valuate (λe. aform_val e ?X)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) intro!: Inf_aform'_le (*‹⟦⋀i. ?e'' i ≤ 1; ⋀i. - 1 ≤ ?e'' i⟧ ⟹ Inf_aform' ?p ?r ≤ aform_val ?e'' ?r›*) Sup_aform'_le (*‹⟦⋀i. ?e'' i ≤ 1; ⋀i. - 1 ≤ ?e'' i⟧ ⟹ aform_val ?e'' ?r ≤ Sup_aform' ?p ?r›*) dest!: nth_in_AffineI (*‹⟦?xs ∈ Joints ?XS; ?i < length ?XS⟧ ⟹ ?xs ! ?i ∈ Affine (?XS ! ?i)›*) split: Interval'_splits (*‹?P (Interval' ?a ?b) = ((∀ivl. ?a ≤ ?b ⟶ lower ivl = ?a ⟶ upper ivl = ?b ⟶ ?P (Some ivl)) ∧ (¬ ?a ≤ ?b ⟶ ?P None))› ‹?P (Interval' ?a ?b) = (¬ ((∃ivl. ?a ≤ ?b ∧ lower ivl = ?a ∧ upper ivl = ?b ∧ ¬ ?P (Some ivl)) ∨ ¬ ?a ≤ ?b ∧ ¬ ?P None))›*)) definition "isFDERIV_aform prec N xs fas AS = isFDERIV_approx prec N xs fas (ivls_of_aforms prec AS)" theorem isFDERIV_aform: assumes "isFDERIV_aform prec N xs fas AS" assumes "vs ∈ Joints AS" shows "isFDERIV N xs fas vs" apply (rule isFDERIV_approx (*‹⟦bounded_by ?vs ?VS; isFDERIV_approx ?prec ?n ?xs ?fas ?VS⟧ ⟹ isFDERIV ?n ?xs ?fas ?vs›*)) (*goals: 1. ‹bounded_by vs ?VS› 2. ‹isFDERIV_approx ?prec N xs fas ?VS› discuss goal 1*) apply (rule ivls_of_aforms (*‹?xs ∈ Joints ?XS ⟹ bounded_by ?xs (ivls_of_aforms ?prec ?XS)›*)) (*top goal: ‹bounded_by vs ?VS› and 1 goal remains*) apply (rule assms (*‹isFDERIV_aform prec N xs fas AS› ‹vs ∈ Joints AS›*)) (*discuss goal 2*) apply (rule assms[unfolded isFDERIV_aform_def] (*‹isFDERIV_approx prec N xs fas (ivls_of_aforms prec AS)› ‹vs ∈ Joints AS›*)) (*proven 2 subgoals*) . definition "env_len env l = (∀xs ∈ env. length xs = l)" lemma env_len_takeI: "env_len xs d1 ⟹ d1 ≥ d ⟹ env_len (take d ` xs) d" by (auto simp: env_len_def (*‹env_len (?env::?'a list set) (?l::nat) = (∀xs::?'a list∈?env. length xs = ?l)›*)) subsection ‹Min Range approximation› lemma linear_lower: fixes x::real assumes "⋀x. x ∈ {a .. b} ⟹ (f has_field_derivative f' x) (at x within {a .. b})" assumes "⋀x. x ∈ {a .. b} ⟹ f' x ≤ u" assumes "x ∈ {a .. b}" shows "f b + u * (x - b) ≤ f x" proof (-) (*goal: ‹f b + u * (x - b) ≤ f x›*) from assms(2-) (*‹?x ∈ {a..b} ⟹ f' ?x ≤ u› ‹x ∈ {a..b}›*) mvt_very_simple[of x b f "λx. (*) (f' x)", rule_format, OF _ has_derivative_subset [ OF assms ( 1 ) [ simplified has_field_derivative_def ] ]] (*‹⟦(x::real) ≤ (b::real); ⋀xa::real. ⟦x ≤ xa; xa ≤ b⟧ ⟹ xa ∈ {a::real..b}; ⋀xa::real. ⟦x ≤ xa; xa ≤ b⟧ ⟹ {x..b} ⊆ {a..b}⟧ ⟹ ∃xa::real∈{x..b}. (f::real ⇒ real) b - f x = (f'::real ⇒ real) xa * (b - x)›*) obtain y where "y ∈ {x .. b}" "f b - f x = (b - x) * f' y" (*goal: ‹(⋀y. ⟦y ∈ {x..b}; f b - f x = (b - x) * f' y⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) moreover hence "f' y ≤ u" using assms (*‹(?x::real) ∈ {a::real..b::real} ⟹ ((f::real ⇒ real) has_real_derivative (f'::real ⇒ real) ?x) (at ?x within {a..b})› ‹(?x::real) ∈ {a::real..b::real} ⟹ (f'::real ⇒ real) ?x ≤ (u::real)› ‹x ∈ {a..b}›*) by auto ultimately have "f b - f x ≤ (b - x) * u" by (auto intro!: mult_left_mono (*‹⟦(?a::?'a::ordered_semiring) ≤ (?b::?'a::ordered_semiring); (0::?'a::ordered_semiring) ≤ (?c::?'a::ordered_semiring)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) thus "?thesis" (*goal: ‹f b + u * (x - b) ≤ f x›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed lemma linear_lower2: fixes x::real assumes "⋀x. x ∈ {a .. b} ⟹ (f has_field_derivative f' x) (at x within {a .. b})" assumes "⋀x. x ∈ {a .. b} ⟹ l ≤ f' x" assumes "x ∈ {a .. b}" shows "f x ≥ f a + l * (x - a)" proof (-) (*goal: ‹f a + l * (x - a) ≤ f x›*) from assms(2-) (*‹?x ∈ {a..b} ⟹ l ≤ f' ?x› ‹x ∈ {a..b}›*) mvt_very_simple[of a x f "λx. (*) (f' x)", rule_format, OF _ has_derivative_subset [ OF assms ( 1 ) [ simplified has_field_derivative_def ] ]] (*‹⟦a ≤ x; ⋀xa. ⟦a ≤ xa; xa ≤ x⟧ ⟹ xa ∈ {a..b}; ⋀xa. ⟦a ≤ xa; xa ≤ x⟧ ⟹ {a..x} ⊆ {a..b}⟧ ⟹ ∃xa∈{a..x}. f x - f a = f' xa * (x - a)›*) obtain y where "y ∈ {a .. x}" "f x - f a = (x - a) * f' y" (*goal: ‹(⋀y. ⟦y ∈ {a..x}; f x - f a = (x - a) * f' y⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) moreover hence "l ≤ f' y" using assms (*‹?x ∈ {a..b} ⟹ (f has_real_derivative f' ?x) (at ?x within {a..b})› ‹?x ∈ {a..b} ⟹ l ≤ f' ?x› ‹(x::real) ∈ {a::real..b::real}›*) by auto ultimately have "(x - a) * l ≤ f x - f a" by (auto intro!: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) thus "?thesis" (*goal: ‹f a + l * (x - a) ≤ f x›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed lemma linear_upper: fixes x::real assumes "⋀x. x ∈ {a .. b} ⟹ (f has_field_derivative f' x) (at x within {a .. b})" assumes "⋀x. x ∈ {a .. b} ⟹ f' x ≤ u" assumes "x ∈ {a .. b}" shows "f x ≤ f a + u * (x - a)" proof (-) (*goal: ‹f x ≤ f a + u * (x - a)›*) from assms(2-) (*‹?x ∈ {a..b} ⟹ f' ?x ≤ u› ‹x ∈ {a..b}›*) mvt_very_simple[of a x f "λx. (*) (f' x)", rule_format, OF _ has_derivative_subset [ OF assms ( 1 ) [ simplified has_field_derivative_def ] ]] (*‹⟦a ≤ x; ⋀xa. ⟦a ≤ xa; xa ≤ x⟧ ⟹ xa ∈ {a..b}; ⋀xa. ⟦a ≤ xa; xa ≤ x⟧ ⟹ {a..x} ⊆ {a..b}⟧ ⟹ ∃xa∈{a..x}. f x - f a = f' xa * (x - a)›*) obtain y where "y ∈ {a .. x}" "f x - f a = (x - a) * f' y" (*goal: ‹(⋀y. ⟦y ∈ {a..x}; f x - f a = (x - a) * f' y⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: Bex_def (*‹Bex (?A::?'a::type set) (?P::?'a::type ⇒ bool) = (∃x::?'a::type. x ∈ ?A ∧ ?P x)›*) ac_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) moreover hence "f' y ≤ u" using assms (*‹?x ∈ {a..b} ⟹ (f has_real_derivative f' ?x) (at ?x within {a..b})› ‹?x ∈ {a..b} ⟹ f' ?x ≤ u› ‹x ∈ {a..b}›*) by auto ultimately have "(x - a) * u ≥ f x - f a" by (auto intro!: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) thus "?thesis" (*goal: ‹f x ≤ f a + u * (x - a)›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed lemma linear_upper2: fixes x::real assumes "⋀x. x ∈ {a .. b} ⟹ (f has_field_derivative f' x) (at x within {a .. b})" assumes "⋀x. x ∈ {a .. b} ⟹ l ≤ f' x" assumes "x ∈ {a .. b}" shows "f x ≤ f b + l * (x - b)" proof (-) (*goal: ‹(f::real ⇒ real) (x::real) ≤ f (b::real) + (l::real) * (x - b)›*) from assms(2-) (*‹?x ∈ {a..b} ⟹ l ≤ f' ?x› ‹(x::real) ∈ {a::real..b::real}›*) mvt_very_simple[of x b f "λx. (*) (f' x)", rule_format, OF _ has_derivative_subset [ OF assms ( 1 ) [ simplified has_field_derivative_def ] ]] (*‹⟦x ≤ b; ⋀xa. ⟦x ≤ xa; xa ≤ b⟧ ⟹ xa ∈ {a..b}; ⋀xa. ⟦x ≤ xa; xa ≤ b⟧ ⟹ {x..b} ⊆ {a..b}⟧ ⟹ ∃xa∈{x..b}. f b - f x = f' xa * (b - x)›*) obtain y where "y ∈ {x .. b}" "f b - f x = (b - x) * f' y" (*goal: ‹(⋀y. ⟦y ∈ {x..b}; f b - f x = (b - x) * f' y⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) moreover hence "l ≤ f' y" using assms (*‹?x ∈ {a..b} ⟹ (f has_real_derivative f' ?x) (at ?x within {a..b})› ‹?x ∈ {a..b} ⟹ l ≤ f' ?x› ‹(x::real) ∈ {a::real..b::real}›*) by auto ultimately have "f b - f x ≥ (b - x) * l" by (auto intro!: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) thus "?thesis" (*goal: ‹f x ≤ f b + l * (x - b)›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed lemma linear_enclosure: fixes x::real assumes "⋀x. x ∈ {a .. b} ⟹ (f has_field_derivative f' x) (at x within {a .. b})" assumes "⋀x. x ∈ {a .. b} ⟹ f' x ≤ u" assumes "x ∈ {a .. b}" shows "f x ∈ {f b + u * (x - b) .. f a + u * (x - a)}" using linear_lower[OF assms] (*‹⟦⋀x::real. x ∈ {a::real..b::real} ⟹ x ∈ {a..b}; ⋀x::real. x ∈ {a..b} ⟹ x ∈ {a..b}⟧ ⟹ (f::real ⇒ real) b + (u::real) * ((x::real) - b) ≤ f x›*) linear_upper[OF assms] (*‹⟦⋀x. x ∈ {a..b} ⟹ x ∈ {a..b}; ⋀x. x ∈ {a..b} ⟹ x ∈ {a..b}⟧ ⟹ f x ≤ f a + u * (x - a)›*) by auto definition "mid_err ivl = ((lower ivl + upper ivl::float)/2, (upper ivl - lower ivl)/2)" lemma degree_aform_uminus_aform[simp]: "degree_aform (uminus_aform X) = degree_aform X" by (auto simp: uminus_aform_def (*‹uminus_aform (?X::?'a × ?'b pdevs) = (- fst ?X, uminus_pdevs (snd ?X))›*)) subsubsection ‹Addition› definition add_aform::"'a::real_vector aform ⇒ 'a aform ⇒ 'a aform" where "add_aform x y = (fst x + fst y, add_pdevs (snd x) (snd y))" lemma aform_val_add_aform: shows "aform_val e (add_aform X Y) = aform_val e X + aform_val e Y" by (auto simp: add_aform_def (*‹add_aform ?x ?y = (fst ?x + fst ?y, add_pdevs (snd ?x) (snd ?y))›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) type_synonym aform_err = "real aform × real" definition add_aform'::"nat ⇒ aform_err ⇒ aform_err ⇒ aform_err" where "add_aform' p x y = (let z0 = trunc_bound_eucl p (fst (fst x) + fst (fst y)); z = trunc_bound_pdevs p (add_pdevs (snd (fst x)) (snd (fst y))) in ((fst z0, fst z), (sum_list' p [snd z0, snd z, abs (snd x), abs (snd y)])))" abbreviation degree_aform_err::"aform_err ⇒ nat" where "degree_aform_err X ≡ degree_aform (fst X)" lemma degree_aform_err_add_aform': assumes "degree_aform_err x ≤ n" assumes "degree_aform_err y ≤ n" shows "degree_aform_err (add_aform' p x y) ≤ n" using assms (*‹degree_aform_err x ≤ n› ‹degree_aform_err y ≤ n›*) by (auto simp: add_aform'_def (*‹add_aform' (?p::nat) (?x::(real × real pdevs) × real) (?y::(real × real pdevs) × real) = (let z0::real × real = trunc_bound_eucl ?p (fst (fst ?x) + fst (fst ?y)); z::real pdevs × real = trunc_bound_pdevs ?p (add_pdevs (snd (fst ?x)) (snd (fst ?y))) in ((fst z0, fst z), sum_list' ?p [snd z0, snd z, ¦snd ?x¦, ¦snd ?y¦]))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs (?p::nat) (?x::?'a pdevs) = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) intro!: degree_pdev_upd_le (*‹degree (?X::?'a pdevs) ≤ (?n::nat) ⟹ degree (pdev_upd ?X ?n (?x::?'a)) ≤ Suc ?n›*) degree_trunc_pdevs_le (*‹degree (?X::?'a pdevs) ≤ (?n::nat) ⟹ degree (trunc_pdevs (?p::nat) ?X) ≤ ?n›*) degree_add_pdevs_le (*‹⟦degree (?X::?'a pdevs) ≤ (?n::nat); degree (?Y::?'a pdevs) ≤ ?n⟧ ⟹ degree (add_pdevs ?X ?Y) ≤ ?n›*)) definition "aform_err e Xe = {aform_val e (fst Xe) - snd Xe .. aform_val e (fst Xe) + snd Xe::real}" lemma aform_errI: "x ∈ aform_err e Xe" if "abs (x - aform_val e (fst Xe)) ≤ snd Xe" using that (*‹¦x - aform_val e (fst Xe)¦ ≤ snd Xe›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) lemma add_aform': assumes e: "e ∈ UNIV → {- 1..1}" assumes x: "x ∈ aform_err e X" assumes y: "y ∈ aform_err e Y" shows "x + y ∈ aform_err e (add_aform' p X Y)" proof (-) (*goal: ‹x + y ∈ aform_err e (add_aform' p X Y)›*) let ?t1 = "trunc_bound_eucl p (fst (fst X) + fst (fst Y))" from trunc_bound_euclE (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_eucl ?p ?x); fst (trunc_bound_eucl ?p ?x) = ?x + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e1 where abs_e1: "¦e1¦ ≤ snd ?t1" and e1: "fst ?t1 = fst (fst X) + fst (fst Y) + e1" (*goal: ‹(⋀e1. ⟦¦e1¦ ≤ snd (trunc_bound_eucl p (fst (fst X) + fst (fst Y))); fst (trunc_bound_eucl p (fst (fst X) + fst (fst Y))) = fst (fst X) + fst (fst Y) + e1⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?t2 = "trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y)))" from trunc_bound_pdevsE[OF e, of p "add_pdevs (snd (fst X)) (snd (fst Y))"] (*‹(⋀err::real. ⟦¦err¦ ≤ snd (trunc_bound_pdevs (p::nat) (add_pdevs (snd (fst (X::(real × real pdevs) × real))) (snd (fst (Y::(real × real pdevs) × real))))); pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y))))) = pdevs_val e (add_pdevs (snd (fst X)) (snd (fst Y))) + err⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain e2 where abs_e2: "¦e2¦ ≤ snd (?t2)" and e2: "pdevs_val e (fst ?t2) = pdevs_val e (add_pdevs (snd (fst X)) (snd (fst Y))) + e2" (*goal: ‹(⋀e2. ⟦¦e2¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y)))); pdevs_val e (fst (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y))))) = pdevs_val e (add_pdevs (snd (fst X)) (snd (fst Y))) + e2⟧ ⟹ thesis) ⟹ thesis›*) by blast have e_le: "¦e1 + e2 + snd X + snd Y¦ ≤ snd (add_aform' p (X) Y)" apply (auto simp: add_aform'_def (*‹add_aform' ?p ?x ?y = (let z0 = trunc_bound_eucl ?p (fst (fst ?x) + fst (fst ?y)); z = trunc_bound_pdevs ?p (add_pdevs (snd (fst ?x)) (snd (fst ?y))) in ((fst z0, fst z), sum_list' ?p [snd z0, snd z, ¦snd ?x¦, ¦snd ?y¦]))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*goal: ‹¦e1 + e2 + snd X + snd Y¦ ≤ snd (add_aform' p X Y)›*) apply (rule sum_list'_sum_list_le (*‹?y ≤ sum_list ?xs ⟹ ?y ≤ sum_list' ?p ?xs›*)) (*goal: ‹¦e1 + e2 + snd X + snd Y¦ ≤ sum_list' p [snd (trunc_bound_eucl p (fst (fst X) + fst (fst Y))), snd (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y)))), ¦snd X¦, ¦snd Y¦]›*) apply (simp add: add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) (*goal: ‹¦e1 + e2 + snd X + snd Y¦ ≤ sum_list [snd (trunc_bound_eucl p (fst (fst X) + fst (fst Y))), snd (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y)))), ¦snd X¦, ¦snd Y¦]›*) by (intro order.trans[OF abs_triangle_ineq] (*‹¦?a1¦ + ¦?b1¦ ≤ ?c ⟹ ¦?a1 + ?b1¦ ≤ ?c›*) add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) abs_e1 (*‹¦e1¦ ≤ snd (trunc_bound_eucl p (fst (fst X) + fst (fst Y)))›*) abs_e2 (*‹¦e2¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y))))›*) order_refl (*‹?x ≤ ?x›*)) then show "?thesis" (*goal: ‹x + y ∈ aform_err e (add_aform' p X Y)›*) apply (intro aform_errI (*‹¦?x - aform_val ?e (fst ?Xe)¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) (*goal: ‹x + y ∈ aform_err e (add_aform' p X Y)›*) using x (*‹(x::real) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) y (*‹(y::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) abs_e1 (*‹¦e1¦ ≤ snd (trunc_bound_eucl p (fst (fst X) + fst (fst Y)))›*) abs_e2 (*‹¦e2¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (snd (fst X)) (snd (fst Y))))›*) apply (simp add: aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) aform_err_def (*‹aform_err (?e::nat ⇒ real) (?Xe::(real × real pdevs) × real) = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) add_aform_def (*‹add_aform (?x::?'a × ?'a pdevs) (?y::?'a × ?'a pdevs) = (fst ?x + fst ?y, add_pdevs (snd ?x) (snd ?y))›*) add_aform'_def (*‹add_aform' (?p::nat) (?x::(real × real pdevs) × real) (?y::(real × real pdevs) × real) = (let z0::real × real = trunc_bound_eucl ?p (fst (fst ?x) + fst (fst ?y)); z::real pdevs × real = trunc_bound_pdevs ?p (add_pdevs (snd (fst ?x)) (snd (fst ?y))) in ((fst z0, fst z), sum_list' ?p [snd z0, snd z, ¦snd ?x¦, ¦snd ?y¦]))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) e1 (*‹fst (trunc_bound_eucl (p::nat) (fst (fst (X::(real × real pdevs) × real)) + fst (fst (Y::(real × real pdevs) × real)))) = fst (fst X) + fst (fst Y) + (e1::real)›*) e2 (*‹pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs (p::nat) (add_pdevs (snd (fst (X::(real × real pdevs) × real))) (snd (fst (Y::(real × real pdevs) × real)))))) = pdevs_val e (add_pdevs (snd (fst X)) (snd (fst Y))) + (e2::real)›*) assms (*‹(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› ‹(x::real) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)› ‹(y::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*)) (*goal: ‹¦e1 + e2 + snd X + snd Y¦ ≤ snd (add_aform' p X Y) ⟹ ¦x + y - aform_val e (fst (add_aform' p X Y))¦ ≤ snd (add_aform' p X Y)›*) by (auto intro!: order_trans[OF _ sum_list_le_sum_list'] (*‹?x ≤ sum_list ?xs1 ⟹ ?x ≤ sum_list' ?p1 ?xs1›*)) qed subsubsection ‹Scaling› definition aform_scaleR::"real aform ⇒ 'a::real_vector ⇒ 'a aform" where "aform_scaleR x y = (fst x *⇩R y, pdevs_scaleR (snd x) y)" lemma aform_val_scaleR_aform[simp]: shows "aform_val e (aform_scaleR X y) = aform_val e X *⇩R y" by (auto simp: aform_scaleR_def (*‹aform_scaleR ?x ?y = (fst ?x *⇩R ?y, pdevs_scaleR (snd ?x) ?y)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) scaleR_left_distrib (*‹(?a + ?b) *⇩R ?x = ?a *⇩R ?x + ?b *⇩R ?x›*)) subsubsection ‹Multiplication› lemma aform_val_mult_exact: "aform_val e x * aform_val e y = fst x * fst y + pdevs_val e (add_pdevs (scaleR_pdevs (fst y) (snd x)) (scaleR_pdevs (fst x) (snd y))) + (∑i<d. e i *⇩R pdevs_apply (snd x) i)*(∑i<d. e i *⇩R pdevs_apply (snd y) i)" if "degree (snd x) ≤ d" "degree (snd y) ≤ d" using that (*‹degree_aform x ≤ d› ‹degree_aform y ≤ d›*) by (auto simp: pdevs_val_sum_less_degree[where d=d] (*‹degree ?X ≤ d ⟹ pdevs_val ?e ?X = (∑i<d. ?e i *⇩R pdevs_apply ?X i)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) lemma sum_times_bound:― ‹TODO: this gives better bounds for the remainder of multiplication› "(∑i<d. e i * f i::real) * (∑i<d. e i * g i) = (∑i<d. (e i)² * (f i * g i)) + (∑(i, j) | i < j ∧ j < d. (e i * e j) * (f j * g i + f i * g j))" for d::nat proof (-) (*goal: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑i<d. (e i)² * (f i * g i)) + (∑(i, j)∈{(i, j). i < j ∧ j < d}. e i * e j * (f j * g i + f i * g j))›*) have "(∑i<d. e i * f i)*(∑i<d. e i * g i) = (∑(i, j)∈{..<d} × {..<d}. e i * f i * (e j * g j))" unfolding sum_product sum.cartesian_product (*goal: ‹(∑(i, j)∈{..<d} × {..<d}. e i * f i * (e j * g j)) = (∑(i, j)∈{..<d} × {..<d}. e i * f i * (e j * g j))›*) by standard also (*calculation: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑(i, j)∈{..<d} × {..<d}. e i * f i * (e j * g j))›*) have "… = (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i = j}. e i * f i * (e j * g j)) + ((∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i < j}. e i * f i * (e j * g j)) + (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). j < i}. e i * f i * (e j * g j)))" (is "_ = ?a + (?b + ?c)") apply (subst sum.union_disjoint[symmetric] (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g ?A + sum ?g ?B = sum ?g (?A ∪ ?B)›*)) (*goals: 1. ‹finite ({..<d} × {..<d} ∩ {(x, y). x < y})› 2. ‹finite ({..<d} × {..<d} ∩ {(i, j). j < i})› 3. ‹{..<d} × {..<d} ∩ {(x, y). x < y} ∩ ({..<d} × {..<d} ∩ {(i, j). j < i}) = {}› 4. ‹(∑(i, j)∈{..<d} × {..<d}. e i * f i * (e j * g j)) = (∑(i, j)∈{..<d} × {..<d} ∩ {(x, y). x = y}. e i * f i * (e j * g j)) + (∑(i, j)∈{..<d} × {..<d} ∩ {(x, y). x < y} ∪ {..<d} × {..<d} ∩ {(i, j). j < i}. e i * f i * (e j * g j))› discuss goal 1*) apply force (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*discuss goal 4*) apply (subst sum.union_disjoint[symmetric] (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g ?A + sum ?g ?B = sum ?g (?A ∪ ?B)›*)) (*goals: 1. ‹finite ({..<d} × {..<d} ∩ {(x, y). x = y})› 2. ‹finite ({..<d} × {..<d} ∩ {(x, y). x < y} ∪ {..<d} × {..<d} ∩ {(i, j). j < i})› 3. ‹{..<d} × {..<d} ∩ {(x, y). x = y} ∩ ({..<d} × {..<d} ∩ {(x, y). x < y} ∪ {..<d} × {..<d} ∩ {(i, j). j < i}) = {}› 4. ‹(∑(i, j)∈{..<d} × {..<d}. e i * f i * (e j * g j)) = (∑(i, j)∈{..<d} × {..<d} ∩ {(x, y). x = y} ∪ ({..<d} × {..<d} ∩ {(x, y). x < y} ∪ {..<d} × {..<d} ∩ {(i, j). j < i}). e i * f i * (e j * g j))› discuss goal 1*) apply force (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*discuss goal 4*) apply (auto intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*proven 4 subgoals*) (*proven 4 subgoals*) . also (*calculation: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i = j}. e i * f i * (e j * g j)) + ((∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i < j}. e i * f i * (e j * g j)) + (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). j < i}. e i * f i * (e j * g j)))›*) have "?c = (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i < j}. e i * f j * (e j * g i))" apply (rule sum.reindex_cong[of "λ(x, y). (y, x)"] (*‹⟦inj_on (λ(x::?'a1, y::?'b1). (y, x)) (?B::(?'a1 × ?'b1) set); (?A::(?'b1 × ?'a1) set) = (λ(x::?'a1, y::?'b1). (y, x)) ` ?B; ⋀x::?'a1 × ?'b1. x ∈ ?B ⟹ (?g::?'b1 × ?'a1 ⇒ ?'a) (case x of (x::?'a1, y::?'b1) ⇒ (y, x)) = (?h::?'a1 × ?'b1 ⇒ ?'a) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹inj_on (λ(x, y). (y, x)) ({..<d} × {..<d} ∩ {(i, j). i < j})› 2. ‹{..<d} × {..<d} ∩ {(i, j). j < i} = (λ(x, y). (y, x)) ` ({..<d} × {..<d} ∩ {(i, j). i < j})› 3. ‹⋀x. x ∈ {..<d} × {..<d} ∩ {(i, j). i < j} ⟹ (case case x of (x, y) ⇒ (y, x) of (i, j) ⇒ e i * f i * (e j * g j)) = (case x of (i, j) ⇒ e i * f j * (e j * g i))› discuss goal 1*) apply ((auto intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1]) (*discuss goal 2*) apply ((auto intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1]) (*discuss goal 3*) apply ((auto intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑a∈{..<d} × {..<d} ∩ {a. case a of (i, j) ⇒ i = j}. case a of (i, j) ⇒ e i * f i * (e j * g j)) + ((∑a∈{..<d} × {..<d} ∩ {a. case a of (i, j) ⇒ i < j}. case a of (i, j) ⇒ e i * f i * (e j * g j)) + (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i < j}. e i * f j * (e j * g i)))›*) have "?b + … = (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i < j}. (e i * e j) * (f j * g i + f i * g j))" by (auto simp: algebra_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 34 facts*) sum.distrib (*‹(∑x::?'b::type∈(?A::?'b::type set). (?g::?'b::type ⇒ ?'a::comm_monoid_add) x + (?h::?'b::type ⇒ ?'a::comm_monoid_add) x) = sum ?g ?A + sum ?h ?A›*) split_beta' (*‹(λ(x::?'a::type, y::?'b::type). (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x y) = (λx::?'a::type × ?'b::type. ?f (fst x) (snd x))›*)) also (*calculation: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑a∈{..<d} × {..<d} ∩ {a. case a of (i, j) ⇒ i = j}. case a of (i, j) ⇒ e i * f i * (e j * g j)) + (∑(i, j)∈{..<d} × {..<d} ∩ {(i, j). i < j}. e i * e j * (f j * g i + f i * g j))›*) have "… = (∑(i, j) | i < j ∧ j < d. (e i * e j) * (f j * g i + f i * g j))" apply (rule sum.cong (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B ⟹ (?g::?'b::type ⇒ ?'a::comm_monoid_add) x = (?h::?'b::type ⇒ ?'a::comm_monoid_add) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹{..<d} × {..<d} ∩ {(i, j). i < j} = {(i, j). i < j ∧ j < d}› 2. ‹⋀x. x ∈ {(i, j). i < j ∧ j < d} ⟹ (case x of (i, j) ⇒ e i * e j * (f j * g i + f i * g j)) = (case x of (i, j) ⇒ e i * e j * (f j * g i + f i * g j))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑a∈{..<d} × {..<d} ∩ {a. case a of (i, j) ⇒ i = j}. case a of (i, j) ⇒ e i * f i * (e j * g j)) + (∑(i, j)∈{(i, j). i < j ∧ j < d}. e i * e j * (f j * g i + f i * g j))›*) have "?a = (∑i<d. (e i)² * (f i * g i))" apply (rule sum.reindex_cong[of "λi. (i, i)"] (*‹⟦inj_on (λi. (i, i)) ?B; ?A = (λi. (i, i)) ` ?B; ⋀x. x ∈ ?B ⟹ ?g (x, x) = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) (*goals: 1. ‹inj_on (λi::nat. (i, i)) {..<d::nat}› 2. ‹{..<d::nat} × {..<d} ∩ {(i::nat, j::nat). i = j} = (λi::nat. (i, i)) ` {..<d}› 3. ‹⋀x::nat. x ∈ {..<d::nat} ⟹ (case (x, x) of (i::nat, j::nat) ⇒ (e::nat ⇒ real) i * (f::nat ⇒ real) i * (e j * (g::nat ⇒ real) j)) = (e x)² * (f x * g x)› discuss goal 1*) apply ((auto simp: power2_eq_square (*‹?a² = ?a * ?a›*) intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: power2_eq_square (*‹?a² = ?a * ?a›*) intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1]) (*discuss goal 3*) apply ((auto simp: power2_eq_square (*‹?a² = ?a * ?a›*) intro!: inj_onI (*‹(⋀x y. ⟦x ∈ ?A; y ∈ ?A; ?f x = ?f y⟧ ⟹ x = y) ⟹ inj_on ?f ?A›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑i<d. (e i)² * (f i * g i)) + (∑ | case of (i, j) ⇒ i < j ∧ j < d. case of (i, j) ⇒ e i * e j * (f j * g i + f i * g j))›*) show "?thesis" (*goal: ‹(∑i<d. e i * f i) * (∑i<d. e i * g i) = (∑i<d. (e i)² * (f i * g i)) + (∑(i, j)∈{(i, j). i < j ∧ j < d}. e i * e j * (f j * g i + f i * g j))›*) by simp qed definition mult_aform::"aform_err ⇒ aform_err ⇒ aform_err" where "mult_aform x y = ((fst (fst x) * fst (fst y), (add_pdevs (scaleR_pdevs (fst (fst y)) (snd (fst x))) (scaleR_pdevs (fst (fst x)) (snd (fst y))))), (tdev (snd (fst x)) * tdev (snd (fst y)) + abs (snd x) * (abs (fst (fst y)) + Radius (fst y)) + abs (snd y) * (abs (fst (fst x)) + Radius (fst x)) + abs (snd x) * abs (snd y) ))" lemma mult_aformE: fixes X Y::"aform_err" assumes e: "e ∈ UNIV → {- 1..1}" assumes x: "x ∈ aform_err e X" assumes y: "y ∈ aform_err e Y" shows "x * y ∈ aform_err e (mult_aform X Y)" proof (-) (*goal: ‹(x::real) * (y::real) ∈ aform_err (e::nat ⇒ real) (mult_aform (X::(real × real pdevs) × real) (Y::(real × real pdevs) × real))›*) define ex where "ex ≡ x - aform_val e (fst X)" define ey where "ey ≡ y - aform_val e (fst Y)" have [intro, simp]: "¦ex¦ ≤ ¦snd X¦" "¦ey¦ ≤ ¦snd Y¦" using x (*‹x ∈ aform_err e X›*) y (*‹y ∈ aform_err e Y›*) apply - (*goals: 1. ‹⟦x ∈ aform_err e X; y ∈ aform_err e Y⟧ ⟹ ¦ex¦ ≤ ¦snd X¦› 2. ‹⟦x ∈ aform_err e X; y ∈ aform_err e Y⟧ ⟹ ¦ey¦ ≤ ¦snd Y¦› discuss goal 1*) apply ((auto simp: ex_def (*‹ex ≡ x - aform_val e (fst X)›*) ey_def (*‹ey ≡ y - aform_val e (fst Y)›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*))[1]) (*discuss goal 2*) apply ((auto simp: ex_def (*‹ex ≡ x - aform_val e (fst X)›*) ey_def (*‹ey ≡ y - aform_val e (fst Y)›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*))[1]) (*proven 2 subgoals*) . have "x * y = fst (fst X) * fst (fst Y) + fst (fst Y) * pdevs_val e (snd (fst X)) + fst (fst X) * pdevs_val e (snd (fst Y)) + (pdevs_val e (snd (fst X)) * pdevs_val e (snd (fst Y)) + ex * (fst (fst Y) + pdevs_val e (snd (fst Y))) + ey * (fst (fst X) + pdevs_val e (snd (fst X))) + ex * ey)" (is "_ = ?c + ?d + ?e + ?err") by (auto simp: ex_def (*‹ex ≡ x - aform_val e (fst X)›*) ey_def (*‹ey ≡ y - aform_val e (fst Y)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) have abs_err: "abs ?err ≤ snd (mult_aform X Y)" by (auto simp: mult_aform_def (*‹mult_aform ?x ?y = ((fst (fst ?x) * fst (fst ?y), add_pdevs (scaleR_pdevs (fst (fst ?y)) (snd (fst ?x))) (scaleR_pdevs (fst (fst ?x)) (snd (fst ?y)))), Radius (fst ?x) * Radius (fst ?y) + ¦snd ?x¦ * (¦fst (fst ?y)¦ + Radius (fst ?y)) + ¦snd ?y¦ * (¦fst (fst ?x)¦ + Radius (fst ?x)) + ¦snd ?x¦ * ¦snd ?y¦)›*) abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) intro!: abs_triangle_ineq[THEN order_trans] (*‹¦?a1¦ + ¦?b1¦ ≤ ?z ⟹ ¦?a1 + ?b1¦ ≤ ?z›*) add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) abs_pdevs_val_le_tdev (*‹?e ∈ UNIV → {- 1..1} ⟹ ¦pdevs_val ?e ?x¦ ≤ tdev ?x›*) e (*‹e ∈ UNIV → {- 1..1}›*)) show "?thesis" (*goal: ‹x * y ∈ aform_err e (mult_aform X Y)›*) apply (auto simp: intro!: aform_errI (*‹¦(?x::real) - aform_val (?e::nat ⇒ real) (fst (?Xe::(real × real pdevs) × real))¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*) order_trans[OF _ abs_err] (*‹(?x::real) ≤ ¦pdevs_val (e::nat ⇒ real) (snd (fst (X::(real × real pdevs) × real))) * pdevs_val e (snd (fst (Y::(real × real pdevs) × real))) + (ex::real) * (fst (fst Y) + pdevs_val e (snd (fst Y))) + (ey::real) * (fst (fst X) + pdevs_val e (snd (fst X))) + ex * ey¦ ⟹ ?x ≤ snd (mult_aform X Y)›*)) (*goal: ‹(x::real) * (y::real) ∈ aform_err (e::nat ⇒ real) (mult_aform (X::(real × real pdevs) × real) (Y::(real × real pdevs) × real))›*) apply (subst mult_aform_def (*‹mult_aform ?x ?y = ((fst (fst ?x) * fst (fst ?y), add_pdevs (scaleR_pdevs (fst (fst ?y)) (snd (fst ?x))) (scaleR_pdevs (fst (fst ?x)) (snd (fst ?y)))), Radius (fst ?x) * Radius (fst ?y) + ¦snd ?x¦ * (¦fst (fst ?y)¦ + Radius (fst ?y)) + ¦snd ?y¦ * (¦fst (fst ?x)¦ + Radius (fst ?x)) + ¦snd ?x¦ * ¦snd ?y¦)›*)) (*goal: ‹¦x * y - aform_val e (fst (mult_aform X Y))¦ ≤ ¦pdevs_val e (snd (fst X)) * pdevs_val e (snd (fst Y)) + ex * (fst (fst Y) + pdevs_val e (snd (fst Y))) + ey * (fst (fst X) + pdevs_val e (snd (fst X))) + ex * ey¦›*) by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) ex_def (*‹ex ≡ x - aform_val e (fst X)›*) ey_def (*‹ey ≡ y - aform_val e (fst Y)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed definition mult_aform'::"nat ⇒ aform_err ⇒ aform_err ⇒ aform_err" where "mult_aform' p x y = ( let (fx, sx) = x; (fy, sy) = y; ex = abs sx; ey = abs sy; z0 = trunc_bound_eucl p (fst fx * fst fy); u = trunc_bound_pdevs p (scaleR_pdevs (fst fy) (snd fx)); v = trunc_bound_pdevs p (scaleR_pdevs (fst fx) (snd fy)); w = trunc_bound_pdevs p (add_pdevs (fst u) (fst v)); tx = tdev' p (snd fx); ty = tdev' p (snd fy); l = truncate_up p (tx * ty); ee = truncate_up p (ex * ey); e1 = truncate_up p (ex * truncate_up p (abs (fst fy) + ty)); e2 = truncate_up p (ey * truncate_up p (abs (fst fx) + tx)) in ((fst z0, (fst w)), (sum_list' p [ee, e1, e2, l, snd z0, snd u, snd v, snd w])))" lemma aform_errE: "abs (x - aform_val e (fst X)) ≤ snd X" if "x ∈ aform_err e X" using that (*‹x ∈ aform_err e X›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) lemma mult_aform'E: fixes X Y::"aform_err" assumes e: "e ∈ UNIV → {- 1..1}" assumes x: "x ∈ aform_err e X" assumes y: "y ∈ aform_err e Y" shows "x * y ∈ aform_err e (mult_aform' p X Y)" proof (-) (*goal: ‹x * y ∈ aform_err e (mult_aform' p X Y)›*) let ?z0 = "trunc_bound_eucl p (fst (fst X) * fst (fst Y))" from trunc_bound_euclE (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_eucl ?p ?x); fst (trunc_bound_eucl ?p ?x) = ?x + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e1 where abs_e1: "¦e1¦ ≤ snd ?z0" and e1: "fst ?z0 = fst (fst X) * fst (fst Y) + e1" (*goal: ‹(⋀e1::real. ⟦¦e1¦ ≤ snd (trunc_bound_eucl (p::nat) (fst (fst (X::(real × real pdevs) × real)) * fst (fst (Y::(real × real pdevs) × real)))); fst (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) = fst (fst X) * fst (fst Y) + e1⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast let ?u = "trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))" from trunc_bound_pdevsE[OF e] (*‹(⋀err::?'a. ⟦¦err¦ ≤ snd (trunc_bound_pdevs (?p::nat) (?x::?'a pdevs)); pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs ?p ?x)) = pdevs_val e ?x + err⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain e2 where abs_e2: "¦e2¦ ≤ snd (?u)" and e2: "pdevs_val e (fst ?u) = pdevs_val e (scaleR_pdevs (fst (fst Y)) (snd (fst X))) + e2" (*goal: ‹(⋀e2. ⟦¦e2¦ ≤ snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))); pdevs_val e (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) = pdevs_val e (scaleR_pdevs (fst (fst Y)) (snd (fst X))) + e2⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?v = "trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))" from trunc_bound_pdevsE[OF e] (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_pdevs ?p ?x); pdevs_val e (fst (trunc_bound_pdevs ?p ?x)) = pdevs_val e ?x + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e3 where abs_e3: "¦e3¦ ≤ snd (?v)" and e3: "pdevs_val e (fst ?v) = pdevs_val e (scaleR_pdevs (fst (fst X)) (snd (fst Y))) + e3" (*goal: ‹(⋀e3. ⟦¦e3¦ ≤ snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))); pdevs_val e (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))) = pdevs_val e (scaleR_pdevs (fst (fst X)) (snd (fst Y))) + e3⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?w = "trunc_bound_pdevs p (add_pdevs (fst ?u) (fst ?v))" from trunc_bound_pdevsE[OF e] (*‹(⋀err::?'a. ⟦¦err¦ ≤ snd (trunc_bound_pdevs (?p::nat) (?x::?'a pdevs)); pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs ?p ?x)) = pdevs_val e ?x + err⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain e4 where abs_e4: "¦e4¦ ≤ snd (?w)" and e4: "pdevs_val e (fst ?w) = pdevs_val e (add_pdevs (fst ?u) (fst ?v)) + e4" (*goal: ‹(⋀e4. ⟦¦e4¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))); pdevs_val e (fst (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))) = pdevs_val e (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))) + e4⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?tx = "tdev' p (snd (fst X))" and ?ty = "tdev' p (snd (fst Y))" let ?l = "truncate_up p (?tx * ?ty)" let ?ee = "truncate_up p (abs (snd X) * abs (snd Y))" let ?e1 = "truncate_up p (abs (snd X) * truncate_up p (¦fst (fst Y)¦ + ?ty))" let ?e2 = "truncate_up p (abs (snd Y) * truncate_up p (¦fst (fst X)¦ + ?tx))" let ?e0 = "x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X))" let ?err = "?e0 - (e1 + e2 + e3 + e4)" have "abs ?err ≤ abs ?e0 + abs e1 + abs e2 + abs e3 + abs e4" by arith also (*calculation: ‹¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ≤ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X))¦ + ¦e1¦ + ¦e2¦ + ¦e3¦ + ¦e4¦›*) have "… ≤ abs ?e0 + snd ?z0 + snd ?u + snd ?v + snd ?w" unfolding abs_mult (*goal: ‹¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X))¦ + ¦e1¦ + ¦e2¦ + ¦e3¦ + ¦e4¦ ≤ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X))¦ + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))›*) by (auto intro!: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) e (*‹e ∈ UNIV → {- 1..1}›*) abs_pdevs_val_le_tdev' (*‹?e ∈ UNIV → {- 1..1} ⟹ ¦pdevs_val ?e ?y¦ ≤ tdev' ?p ?y›*) abs_ge_zero (*‹0 ≤ ¦?a¦›*) abs_e1 (*‹¦e1¦ ≤ snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y)))›*) abs_e2 (*‹¦e2¦ ≤ snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))›*) abs_e3 (*‹¦e3¦ ≤ snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))›*) abs_e4 (*‹¦e4¦ ≤ snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))›*) intro: tdev'_le (*‹?x ≤ tdev ?y ⟹ ?x ≤ tdev' ?p ?y›*)) also (*calculation: ‹¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ≤ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X))¦ + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))›*) have asdf: "snd (mult_aform X Y) ≤ tdev' p (snd (fst X)) * tdev' p (snd (fst Y)) + ?e1 + ?e2 + ?ee" by (auto simp: mult_aform_def (*‹mult_aform ?x ?y = ((fst (fst ?x) * fst (fst ?y), add_pdevs (scaleR_pdevs (fst (fst ?y)) (snd (fst ?x))) (scaleR_pdevs (fst (fst ?x)) (snd (fst ?y)))), Radius (fst ?x) * Radius (fst ?y) + ¦snd ?x¦ * (¦fst (fst ?y)¦ + Radius (fst ?y)) + ¦snd ?y¦ * (¦fst (fst ?x)¦ + Radius (fst ?x)) + ¦snd ?x¦ * ¦snd ?y¦)›*) intro!: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) order_trans[OF _ tdev'] (*‹?x ≤ tdev ?x1 ⟹ ?x ≤ tdev' ?p1 ?x1›*) truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*)) have "abs ?e0 ≤ ?ee + ?e1 + ?e2 + tdev' p (snd (fst X)) * tdev' p (snd (fst Y))" using mult_aformE[OF e x y, THEN aform_errE, THEN order_trans, OF asdf] (*‹¦x * y - aform_val e (fst (mult_aform X Y))¦ ≤ Radius' p (fst X) * Radius' p (fst Y) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + truncate_up p (¦snd X¦ * ¦snd Y¦)›*) apply (simp add: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) mult_aform_def (*‹mult_aform ?x ?y = ((fst (fst ?x) * fst (fst ?y), add_pdevs (scaleR_pdevs (fst (fst ?y)) (snd (fst ?x))) (scaleR_pdevs (fst (fst ?x)) (snd (fst ?y)))), Radius (fst ?x) * Radius (fst ?y) + ¦snd ?x¦ * (¦fst (fst ?y)¦ + Radius (fst ?y)) + ¦snd ?y¦ * (¦fst (fst ?x)¦ + Radius (fst ?x)) + ¦snd ?x¦ * ¦snd ?y¦)›*)) (*goal: ‹¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X))¦ ≤ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + Radius' p (fst X) * Radius' p (fst Y)›*) by arith also (*calculation: ‹(⋀x y. x ≤ y ⟹ x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))) ⟹ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ≤ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + Radius' p (fst X) * Radius' p (fst Y) + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))›*) have "tdev' p (snd (fst X)) * tdev' p (snd (fst Y)) ≤ ?l" by (auto intro!: truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*)) also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))); ⋀x y. x ≤ y ⟹ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))⟧ ⟹ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ≤ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + truncate_up p (Radius' p (fst X) * Radius' p (fst Y)) + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))›*) have "?ee + ?e1 + ?e2 + ?l + snd ?z0 + snd ?u + snd ?v + snd ?w ≤ sum_list' p [?ee, ?e1, ?e2, ?l, snd ?z0, snd ?u, snd ?v, snd ?w]" apply (rule order_trans[OF _ sum_list_le_sum_list'] (*‹(?x::?'a1::executable_euclidean_space) ≤ sum_list (?xs1::?'a1::executable_euclidean_space list) ⟹ ?x ≤ sum_list' (?p1::nat) ?xs1›*)) (*goal: ‹truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + truncate_up p (Radius' p (fst X) * Radius' p (fst Y)) + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ sum_list' p [truncate_up p (¦snd X¦ * ¦snd Y¦), truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))), truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))), truncate_up p (Radius' p (fst X) * Radius' p (fst Y)), snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))), snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))), snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))), snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))]›*) by simp also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))); ⋀x y. x ≤ y ⟹ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))⟧ ⟹ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ≤ sum_list' p [truncate_up p (¦snd X¦ * ¦snd Y¦), truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))), truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))), truncate_up p (Radius' p (fst X) * Radius' p (fst Y)), snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))), snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))), snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))), snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))]›*) have "… ≤ (snd (mult_aform' p X Y))" by (auto simp: mult_aform'_def (*‹mult_aform' ?p ?x ?y = (let (fx, sx) = ?x; (fy, sy) = ?y; ex = ¦sx¦; ey = ¦sy¦; z0 = trunc_bound_eucl ?p (fst fx * fst fy); u = trunc_bound_pdevs ?p (scaleR_pdevs (fst fy) (snd fx)); v = trunc_bound_pdevs ?p (scaleR_pdevs (fst fx) (snd fy)); w = trunc_bound_pdevs ?p (add_pdevs (fst u) (fst v)); tx = Radius' ?p fx; ty = Radius' ?p fy; l = truncate_up ?p (tx * ty); ee = truncate_up ?p (ex * ey); e1 = truncate_up ?p (ex * truncate_up ?p (¦fst fy¦ + ty)); e2 = truncate_up ?p (ey * truncate_up ?p (¦fst fx¦ + tx)) in ((fst z0, fst w), sum_list' ?p [ee, e1, e2, l, snd z0, snd u, snd v, snd w]))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) assms (*‹e ∈ UNIV → {- 1..1}› ‹x ∈ aform_err e X› ‹y ∈ aform_err e Y›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))); ⋀x y. x ≤ y ⟹ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + x + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))))) ≤ truncate_up p (¦snd X¦ * ¦snd Y¦) + truncate_up p (¦snd X¦ * truncate_up p (¦fst (fst Y)¦ + Radius' p (fst Y))) + truncate_up p (¦snd Y¦ * truncate_up p (¦fst (fst X)¦ + Radius' p (fst X))) + y + snd (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X)))) + snd (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))) + snd (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))⟧ ⟹ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ≤ snd (mult_aform' p X Y)›*) have err_le: "abs ?err ≤ (snd (mult_aform' p X Y))" by arith show "?thesis" (*goal: ‹x * y ∈ aform_err e (mult_aform' p X Y)›*) apply (rule aform_errI[OF order_trans[OF _ err_le]] (*‹¦?x - aform_val ?e (fst (mult_aform' p X Y))¦ ≤ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - (e1 + e2 + e3 + e4)¦ ⟹ ?x ∈ aform_err ?e (mult_aform' p X Y)›*)) (*goal: ‹x * y ∈ aform_err e (mult_aform' p X Y)›*) apply (subst mult_aform'_def (*‹mult_aform' (?p::nat) (?x::(real × real pdevs) × real) (?y::(real × real pdevs) × real) = (let (fx::real × real pdevs, sx::real) = ?x; (fy::real × real pdevs, sy::real) = ?y; ex::real = ¦sx¦; ey::real = ¦sy¦; z0::real × real = trunc_bound_eucl ?p (fst fx * fst fy); u::real pdevs × real = trunc_bound_pdevs ?p (scaleR_pdevs (fst fy) (snd fx)); v::real pdevs × real = trunc_bound_pdevs ?p (scaleR_pdevs (fst fx) (snd fy)); w::real pdevs × real = trunc_bound_pdevs ?p (add_pdevs (fst u) (fst v)); tx::real = Radius' ?p fx; ty::real = Radius' ?p fy; l::real = truncate_up ?p (tx * ty); ee::real = truncate_up ?p (ex * ey); e1::real = truncate_up ?p (ex * truncate_up ?p (¦fst fy¦ + ty)); e2::real = truncate_up ?p (ey * truncate_up ?p (¦fst fx¦ + tx)) in ((fst z0, fst w), sum_list' ?p [ee, e1, e2, l, snd z0, snd u, snd v, snd w]))›*)) (*goal: ‹¦(x::real) * (y::real) - aform_val (e::nat ⇒ real) (fst (mult_aform' (p::nat) (X::(real × real pdevs) × real) (Y::(real × real pdevs) × real)))¦ ≤ ¦x * y - fst (fst X) * fst (fst Y) - fst (fst X) * pdevs_val e (snd (fst Y)) - fst (fst Y) * pdevs_val e (snd (fst X)) - ((e1::real) + (e2::real) + (e3::real) + (e4::real))¦›*) using e1 (*‹fst (trunc_bound_eucl p (fst (fst X) * fst (fst Y))) = fst (fst X) * fst (fst Y) + e1›*) e2 (*‹pdevs_val (e::nat ⇒ real) (fst (trunc_bound_pdevs (p::nat) (scaleR_pdevs (fst (fst (Y::(real × real pdevs) × real))) (snd (fst (X::(real × real pdevs) × real)))))) = pdevs_val e (scaleR_pdevs (fst (fst Y)) (snd (fst X))) + (e2::real)›*) e3 (*‹pdevs_val e (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y))))) = pdevs_val e (scaleR_pdevs (fst (fst X)) (snd (fst Y))) + e3›*) e4 (*‹pdevs_val e (fst (trunc_bound_pdevs p (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))))) = pdevs_val e (add_pdevs (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst Y)) (snd (fst X))))) (fst (trunc_bound_pdevs p (scaleR_pdevs (fst (fst X)) (snd (fst Y)))))) + e4›*) by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) assms (*‹e ∈ UNIV → {- 1..1}› ‹x ∈ aform_err e X› ‹y ∈ aform_err e Y›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) qed lemma degree_aform_mult_aform': assumes "degree_aform_err x ≤ n" assumes "degree_aform_err y ≤ n" shows "degree_aform_err (mult_aform' p x y) ≤ n" using assms (*‹degree_aform_err x ≤ n› ‹degree_aform_err (y::(real × real pdevs) × real) ≤ (n::nat)›*) by (auto simp: mult_aform'_def (*‹mult_aform' ?p ?x ?y = (let (fx, sx) = ?x; (fy, sy) = ?y; ex = ¦sx¦; ey = ¦sy¦; z0 = trunc_bound_eucl ?p (fst fx * fst fy); u = trunc_bound_pdevs ?p (scaleR_pdevs (fst fy) (snd fx)); v = trunc_bound_pdevs ?p (scaleR_pdevs (fst fx) (snd fy)); w = trunc_bound_pdevs ?p (add_pdevs (fst u) (fst v)); tx = Radius' ?p fx; ty = Radius' ?p fy; l = truncate_up ?p (tx * ty); ee = truncate_up ?p (ex * ey); e1 = truncate_up ?p (ex * truncate_up ?p (¦fst fy¦ + ty)); e2 = truncate_up ?p (ey * truncate_up ?p (¦fst fx¦ + tx)) in ((fst z0, fst w), sum_list' ?p [ee, e1, e2, l, snd z0, snd u, snd v, snd w]))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: degree_pdev_upd_le (*‹degree ?X ≤ ?n ⟹ degree (pdev_upd ?X ?n ?x) ≤ Suc ?n›*) degree_trunc_pdevs_le (*‹degree ?X ≤ ?n ⟹ degree (trunc_pdevs ?p ?X) ≤ ?n›*) degree_add_pdevs_le (*‹⟦degree ?X ≤ ?n; degree ?Y ≤ ?n⟧ ⟹ degree (add_pdevs ?X ?Y) ≤ ?n›*)) lemma fixes x a b::real assumes "a > 0" assumes "x ∈ {a ..b}" assumes "- inverse (b*b) ≤ alpha" shows inverse_linear_lower: "inverse b + alpha * (x - b) ≤ inverse x" (is ?lower) and inverse_linear_upper: "inverse x ≤ inverse a + alpha * (x - a)" (is ?upper) proof (-) (*goals: 1. ‹inverse (b::real) + (alpha::real) * ((x::real) - b) ≤ inverse x› 2. ‹inverse (x::real) ≤ inverse (a::real) + (alpha::real) * (x - a)›*) have deriv_inv: "⋀x. x ∈ {a .. b} ⟹ (inverse has_field_derivative - inverse (x*x)) (at x within {a .. b})" using assms (*‹0 < a› ‹x ∈ {a..b}› ‹- inverse (b * b) ≤ alpha›*) by (auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*)) show "?lower" using assms (*‹0 < a› ‹x ∈ {a..b}› ‹- inverse ((b::real) * b) ≤ (alpha::real)›*) apply (intro linear_lower[OF deriv_inv] (*‹⟦⋀x. x ∈ {a..b} ⟹ x ∈ {a..b}; ⋀x. x ∈ {a..b} ⟹ - inverse (x * x) ≤ ?u; ?x ∈ {a..b}⟧ ⟹ inverse b + ?u * (?x - b) ≤ inverse ?x›*)) (*goals: 1. ‹⋀xa. ⟦0 < a; x ∈ {a..b}; - inverse (b * b) ≤ alpha; xa ∈ {a..b}⟧ ⟹ xa ∈ {a..b}› 2. ‹⋀xa. ⟦0 < a; x ∈ {a..b}; - inverse (b * b) ≤ alpha; xa ∈ {a..b}⟧ ⟹ - inverse (xa * xa) ≤ alpha› 3. ‹⟦0 < a; x ∈ {a..b}; - inverse (b * b) ≤ alpha⟧ ⟹ x ∈ {a..b}› discuss goal 1*) apply ((auto simp: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) intro!: order_trans[OF _ assms(3)] (*‹?x ≤ - inverse (b * b) ⟹ ?x ≤ alpha›*))[1]) (*discuss goal 2*) apply ((auto simp: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) intro!: order_trans[OF _ assms(3)] (*‹?x ≤ - inverse (b * b) ⟹ ?x ≤ alpha›*))[1]) (*discuss goal 3*) apply ((auto simp: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) intro!: order_trans[OF _ assms(3)] (*‹?x ≤ - inverse (b * b) ⟹ ?x ≤ alpha›*))[1]) (*proven 3 subgoals*) . show "?upper" using assms (*‹0 < a› ‹x ∈ {a..b}› ‹- inverse (b * b) ≤ alpha›*) apply (intro linear_upper[OF deriv_inv] (*‹⟦⋀x. x ∈ {a..b} ⟹ x ∈ {a..b}; ⋀x. x ∈ {a..b} ⟹ - inverse (x * x) ≤ ?u; ?x ∈ {a..b}⟧ ⟹ inverse ?x ≤ inverse a + ?u * (?x - a)›*)) (*goals: 1. ‹⋀xa. ⟦0 < a; x ∈ {a..b}; - inverse (b * b) ≤ alpha; xa ∈ {a..b}⟧ ⟹ xa ∈ {a..b}› 2. ‹⋀xa. ⟦0 < a; x ∈ {a..b}; - inverse (b * b) ≤ alpha; xa ∈ {a..b}⟧ ⟹ - inverse (xa * xa) ≤ alpha› 3. ‹⟦0 < a; x ∈ {a..b}; - inverse (b * b) ≤ alpha⟧ ⟹ x ∈ {a..b}› discuss goal 1*) apply ((auto simp: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) intro!: order_trans[OF _ assms(3)] (*‹?x ≤ - inverse (b * b) ⟹ ?x ≤ alpha›*))[1]) (*discuss goal 2*) apply ((auto simp: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) intro!: order_trans[OF _ assms(3)] (*‹?x ≤ - inverse (b * b) ⟹ ?x ≤ alpha›*))[1]) (*discuss goal 3*) apply ((auto simp: mult_mono (*‹⟦(?a::?'a::ordered_semiring) ≤ (?b::?'a::ordered_semiring); (?c::?'a::ordered_semiring) ≤ (?d::?'a::ordered_semiring); (0::?'a::ordered_semiring) ≤ ?b; (0::?'a::ordered_semiring) ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) intro!: order_trans[OF _ assms(3)] (*‹(?x::real) ≤ - inverse ((b::real) * b) ⟹ ?x ≤ (alpha::real)›*))[1]) (*proven 3 subgoals*) . qed subsubsection ‹Inverse› definition inverse_aform'::"nat ⇒ real aform ⇒ real aform × real" where "inverse_aform' p X = ( let l = Inf_aform' p X in let u = Sup_aform' p X in let a = min (abs l) (abs u) in let b = max (abs l) (abs u) in let sq = truncate_up p (b * b) in let alpha = - real_divl p 1 sq in let dmax = truncate_up p (real_divr p 1 a - alpha * a) in let dmin = truncate_down p (real_divl p 1 b - alpha * b) in let zeta' = truncate_up p ((dmin + dmax) / 2) in let zeta = if l < 0 then - zeta' else zeta' in let delta = truncate_up p (zeta - dmin) in let res1 = trunc_bound_eucl p (alpha * fst X) in let res2 = trunc_bound_eucl p (fst res1 + zeta) in let zs = trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)) in ((fst res2, fst zs), (sum_list' p [delta, snd res1, snd res2, snd zs])))" lemma inverse_aform'E: fixes X::"real aform" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes Inf_pos: "Inf_aform' p X > 0" assumes "x = aform_val e X" shows "inverse x ∈ aform_err e (inverse_aform' p X)" proof (-) (*goal: ‹inverse x ∈ aform_err e (inverse_aform' p X)›*) define l where "l = Inf_aform' p X" define u where "u = Sup_aform' p X" define a where "a = min (abs l) (abs u)" define b where "b = max (abs l) (abs u)" define sq where "sq = truncate_up p (b * b)" define alpha where "alpha = - (real_divl p 1 sq)" define d_max' where "d_max' = truncate_up p (real_divr p 1 a - alpha * a)" define d_min' where "d_min' = truncate_down p (real_divl p 1 b - alpha * b)" define zeta where "zeta = truncate_up p ((d_min' + d_max') / 2)" define delta where "delta = truncate_up p (zeta - d_min')" note vars = l_def (*‹(l::real) = Inf_aform' (p::nat) (X::real × real pdevs)›*) u_def (*‹u = Sup_aform' p X›*) a_def (*‹a = min ¦l¦ ¦u¦›*) b_def (*‹b = max ¦l¦ ¦u¦›*) sq_def (*‹sq = truncate_up p (b * b)›*) alpha_def (*‹alpha = - real_divl p 1 sq›*) d_max'_def (*‹(d_max'::real) = truncate_up (p::nat) (real_divr p (1::real) (a::real) - (alpha::real) * a)›*) d_min'_def (*‹d_min' = truncate_down p (real_divl p 1 b - alpha * b)›*) zeta_def (*‹zeta = truncate_up p ((d_min' + d_max') / 2)›*) delta_def (*‹delta = truncate_up p (zeta - d_min')›*) let ?x = "aform_val e X" have "0 < l" using assms (*‹e ∈ UNIV → {- 1..1}› ‹(0::real) < Inf_aform' (p::nat) (X::real × real pdevs)› ‹x = aform_val e X›*) by (auto simp add: l_def (*‹l = Inf_aform' p X›*) Inf_aform_def (*‹Inf_aform ?X = fst ?X - Radius ?X›*)) have "l ≤ u" by (auto simp: l_def (*‹l = Inf_aform' p X›*) u_def (*‹u = Sup_aform' p X›*)) hence a_def': "a = l" and b_def': "b = u" and "0 < a" "0 < b" using ‹0 < l› (*‹0 < l›*) apply - (*goals: 1. ‹⟦l ≤ u; 0 < l⟧ ⟹ a = l› 2. ‹⟦l ≤ u; 0 < l⟧ ⟹ b = u› 3. ‹⟦l ≤ u; 0 < l⟧ ⟹ 0 < a› 4. ‹⟦l ≤ u; 0 < l⟧ ⟹ 0 < b› discuss goal 1*) apply (simp add: a_def (*‹a = min ¦l¦ ¦u¦›*) b_def (*‹b = max ¦l¦ ¦u¦›*)) (*discuss goal 2*) apply (simp add: a_def (*‹a = min ¦l¦ ¦u¦›*) b_def (*‹b = max ¦l¦ ¦u¦›*)) (*discuss goal 3*) apply (simp add: a_def (*‹a = min ¦l¦ ¦u¦›*) b_def (*‹b = max ¦l¦ ¦u¦›*)) (*discuss goal 4*) apply (simp add: a_def (*‹(a::real) = min ¦l::real¦ ¦u::real¦›*) b_def (*‹(b::real) = max ¦l::real¦ ¦u::real¦›*)) (*proven 4 subgoals*) . have "0 < ?x" by (rule less_le_trans[OF Inf_pos order.trans[OF Inf_aform' Inf_aform], OF e] (*‹0 < aform_val e X›*)) have "a ≤ ?x" by (metis order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*) Inf_aform (*‹?e ∈ UNIV → {- 1..1} ⟹ Inf_aform ?X ≤ aform_val ?e ?X›*) e (*‹e ∈ UNIV → {- 1..1}›*) Inf_aform' (*‹Inf_aform' ?p ?X ≤ Inf_aform ?X›*) a_def' (*‹a = l›*) l_def (*‹l = Inf_aform' p X›*)) have "?x ≤ b" by (metis order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*) Sup_aform (*‹?e ∈ UNIV → {- 1..1} ⟹ aform_val ?e ?X ≤ Sup_aform ?X›*) e (*‹e ∈ UNIV → {- 1..1}›*) Sup_aform' (*‹Sup_aform ?X ≤ Sup_aform' ?p ?X›*) b_def' (*‹b = u›*) u_def (*‹u = Sup_aform' p X›*)) hence "?x ∈ {?x .. b}" by simp have "- inverse (b * b) ≤ alpha" by (auto simp add: alpha_def (*‹alpha = - real_divl p 1 sq›*) inverse_mult_distrib[symmetric] (*‹inverse ?a * inverse ?b = inverse (?a * ?b)›*) inverse_eq_divide (*‹inverse ?a = 1 / ?a›*) sq_def (*‹sq = truncate_up p (b * b)›*) intro!: order_trans[OF real_divl] (*‹?x1 / ?y1 ≤ ?z ⟹ real_divl ?prec1 ?x1 ?y1 ≤ ?z›*) divide_left_mono (*‹⟦?b ≤ ?a; 0 ≤ ?c; 0 < ?a * ?b⟧ ⟹ ?c / ?a ≤ ?c / ?b›*) truncate_up (*‹?x ≤ truncate_up ?prec ?x›*) mult_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a * ?b›*) ‹0 < b›) { note ‹0 < a› (*‹0 < a›*) moreover have "?x ∈ {a .. b}" using ‹a ≤ ?x› (*‹(a::real) ≤ aform_val (e::nat ⇒ real) (X::real × real pdevs)›*) ‹?x ≤ b› (*‹aform_val e X ≤ b›*) by simp moreover note ‹- inverse (b * b) ≤ alpha› (*‹- inverse (b * b) ≤ alpha›*) ultimately have "inverse ?x ≤ inverse a + alpha * (?x - a)" by (rule inverse_linear_upper (*‹⟦0 < ?a; ?x ∈ {?a..?b}; - inverse (?b * ?b) ≤ ?alpha⟧ ⟹ inverse ?x ≤ inverse ?a + ?alpha * (?x - ?a)›*)) also (*calculation: ‹inverse (aform_val e X) ≤ inverse a + alpha * (aform_val e X - a)›*) have "… = alpha * ?x + (inverse a - alpha * a)" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) also (*calculation: ‹inverse (aform_val e X) ≤ alpha * aform_val e X + (inverse a - alpha * a)›*) have "inverse a - (alpha * a) ≤ (real_divr p 1 a - alpha * a)" by (auto simp: inverse_eq_divide (*‹inverse ?a = 1 / ?a›*) real_divr (*‹?x / ?y ≤ real_divr ?prec ?x ?y›*)) also (*calculation: ‹(⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y) ⟹ inverse (aform_val e X) ≤ alpha * aform_val e X + (real_divr p 1 a - alpha * a)›*) have "… ≤ (truncate_down p (real_divl p 1 b - alpha * b) + (real_divr p 1 a - alpha * a)) / 2 + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2" (is "_ ≤ (truncate_down p ?lb + ?ra) / 2 + (truncate_up p ?ra - truncate_down p ?lb) / 2") by (auto simp add: field_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 77 facts*) intro!: order_trans[OF _ add_left_mono[OF mult_left_mono[OF truncate_up]]] (*‹⟦(?x::real) ≤ (?c1::real) + (?c2::real) * (?a2::real); (0::real) ≤ ?c2⟧ ⟹ ?x ≤ ?c1 + ?c2 * truncate_up (?prec3::nat) ?a2›*)) also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y; ⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y⟧ ⟹ inverse (aform_val e X) ≤ alpha * aform_val e X + ((truncate_down p (real_divl p 1 b - alpha * b) + (real_divr p 1 a - alpha * a)) / 2 + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2)›*) have "(truncate_down p ?lb + ?ra) / 2 ≤ truncate_up p ((truncate_down p ?lb + truncate_up p ?ra) / 2)" apply (intro truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*) divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) truncate_up (*‹?x ≤ truncate_up ?prec ?x›*)) (*goals: 1. ‹real_divr p 1 a - alpha * a ≤ real_divr p 1 a - alpha * a› 2. ‹0 ≤ 2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y; ⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y; ⋀x y. x ≤ y ⟹ alpha * aform_val e X + (x + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2) ≤ alpha * aform_val e X + (y + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2)⟧ ⟹ inverse (aform_val e X) ≤ alpha * aform_val e X + (truncate_up p ((truncate_down p (real_divl p 1 b - alpha * b) + truncate_up p (real_divr p 1 a - alpha * a)) / 2) + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2)›*) have "(truncate_up p ?ra - truncate_down p ?lb) / 2 + truncate_down p ?lb ≤ (truncate_up p ((truncate_down p ?lb + truncate_up p ?ra) / 2))" apply (rule truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*)) (*goal: ‹(truncate_up (p::nat) (real_divr p (1::real) (a::real) - (alpha::real) * a) - truncate_down p (real_divl p (1::real) (b::real) - alpha * b)) / (2::real) + truncate_down p (real_divl p (1::real) b - alpha * b) ≤ truncate_up p ((truncate_down p (real_divl p (1::real) b - alpha * b) + truncate_up p (real_divr p (1::real) a - alpha * a)) / (2::real))›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*)) hence "(truncate_up p ?ra - truncate_down p ?lb) / 2 ≤ truncate_up p (truncate_up p ((truncate_down p ?lb + truncate_up p ?ra) / 2) - truncate_down p ?lb)" apply (intro truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*)) (*goal: ‹(truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2 ≤ truncate_up p (truncate_up p ((truncate_down p (real_divl p 1 b - alpha * b) + truncate_up p (real_divr p 1 a - alpha * a)) / 2) - truncate_down p (real_divl p 1 b - alpha * b))›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*)) finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y; ⋀x y. x ≤ y ⟹ alpha * aform_val e X + x ≤ alpha * aform_val e X + y; ⋀x y. x ≤ y ⟹ alpha * aform_val e X + (x + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2) ≤ alpha * aform_val e X + (y + (truncate_up p (real_divr p 1 a - alpha * a) - truncate_down p (real_divl p 1 b - alpha * b)) / 2); ⋀x y. x ≤ y ⟹ alpha * aform_val e X + (truncate_up p ((truncate_down p (real_divl p 1 b - alpha * b) + truncate_up p (real_divr p 1 a - alpha * a)) / 2) + x) ≤ alpha * aform_val e X + (truncate_up p ((truncate_down p (real_divl p 1 b - alpha * b) + truncate_up p (real_divr p 1 a - alpha * a)) / 2) + y)⟧ ⟹ inverse (aform_val e X) ≤ alpha * aform_val e X + (truncate_up p ((truncate_down p (real_divl p 1 b - alpha * b) + truncate_up p (real_divr p 1 a - alpha * a)) / 2) + truncate_up p (truncate_up p ((truncate_down p (real_divl p 1 b - alpha * b) + truncate_up p (real_divr p 1 a - alpha * a)) / 2) - truncate_down p (real_divl p 1 b - alpha * b)))›*) have "inverse ?x ≤ alpha * ?x + zeta + delta" by (auto simp: zeta_def (*‹(zeta::real) = truncate_up (p::nat) (((d_min'::real) + (d_max'::real)) / (2::real))›*) delta_def (*‹(delta::real) = truncate_up (p::nat) ((zeta::real) - (d_min'::real))›*) d_min'_def (*‹(d_min'::real) = truncate_down (p::nat) (real_divl p (1::real) (b::real) - (alpha::real) * b)›*) d_max'_def (*‹(d_max'::real) = truncate_up (p::nat) (real_divr p (1::real) (a::real) - (alpha::real) * a)›*) right_diff_distrib (*‹(?a::?'a::ring) * ((?b::?'a::ring) - (?c::?'a::ring)) = ?a * ?b - ?a * ?c›*) ac_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) } note upper = this (*‹inverse (aform_val e X) ≤ alpha * aform_val e X + zeta + delta›*) { have "alpha * b + truncate_down p (real_divl p 1 b - alpha * b) ≤ inverse b" apply (rule order_trans[OF add_left_mono[OF truncate_down]] (*‹?c1 + ?b1 ≤ ?z ⟹ ?c1 + truncate_down ?prec2 ?b1 ≤ ?z›*)) (*goal: ‹alpha * b + truncate_down p (real_divl p 1 b - alpha * b) ≤ inverse b›*) by (auto simp: inverse_eq_divide (*‹inverse ?a = 1 / ?a›*) real_divl (*‹real_divl ?prec ?x ?y ≤ ?x / ?y›*)) hence "zeta + alpha * b ≤ delta + inverse b" by (auto simp: zeta_def (*‹zeta = truncate_up p ((d_min' + d_max') / 2)›*) delta_def (*‹delta = truncate_up p (zeta - d_min')›*) d_min'_def (*‹d_min' = truncate_down p (real_divl p 1 b - alpha * b)›*) d_max'_def (*‹d_max' = truncate_up p (real_divr p 1 a - alpha * a)›*) right_diff_distrib (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) intro!: order_trans[OF _ add_right_mono[OF truncate_up]] (*‹?x ≤ ?a1 + ?c1 ⟹ ?x ≤ truncate_up ?prec2 ?a1 + ?c1›*)) hence "alpha * ?x + zeta - delta ≤ inverse b + alpha * (?x - b)" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) also (*calculation: ‹alpha * aform_val e X + zeta - delta ≤ inverse b + alpha * (aform_val e X - b)›*) { note ‹0 < aform_val e X› (*‹0 < aform_val e X›*) moreover note ‹aform_val e X ∈ {aform_val e X .. b}› (*‹aform_val e X ∈ {aform_val e X..b}›*) moreover note ‹- inverse (b * b) ≤ alpha› (*‹- inverse (b * b) ≤ alpha›*) ultimately have "inverse b + alpha * (aform_val e X - b) ≤ inverse (aform_val e X)" by (rule inverse_linear_lower (*‹⟦(0::real) < (?a::real); (?x::real) ∈ {?a..?b::real}; - inverse (?b * ?b) ≤ (?alpha::real)⟧ ⟹ inverse ?b + ?alpha * (?x - ?b) ≤ inverse ?x›*)) } finally (*calculation: ‹(alpha::real) * aform_val (e::nat ⇒ real) (X::real × real pdevs) + (zeta::real) - (delta::real) ≤ inverse (aform_val e X)›*) have "alpha * (aform_val e X) + zeta - delta ≤ inverse (aform_val e X)" . } note lower = this (*‹(alpha::real) * aform_val (e::nat ⇒ real) (X::real × real pdevs) + (zeta::real) - (delta::real) ≤ inverse (aform_val e X)›*) have "inverse (aform_val e X) = alpha * (aform_val e X) + zeta + (inverse (aform_val e X) - alpha * (aform_val e X) - zeta)" (is "_ = _ + ?linerr") by simp also (*calculation: ‹inverse (aform_val e X) = alpha * aform_val e X + zeta + (inverse (aform_val e X) - alpha * aform_val e X - zeta)›*) have "?linerr ∈ {- delta .. delta}" using lower (*‹alpha * aform_val e X + zeta - delta ≤ inverse (aform_val e X)›*) upper (*‹inverse (aform_val e X) ≤ alpha * aform_val e X + zeta + delta›*) by simp hence linerr_le: "abs ?linerr ≤ delta" by auto let ?z0 = "trunc_bound_eucl p (alpha * fst X)" from trunc_bound_euclE (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_eucl ?p ?x); fst (trunc_bound_eucl ?p ?x) = ?x + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e1 where abs_e1: "¦e1¦ ≤ snd ?z0" and e1: "fst ?z0 = alpha * fst X + e1" (*goal: ‹(⋀e1. ⟦¦e1¦ ≤ snd (trunc_bound_eucl p (alpha * fst X)); fst (trunc_bound_eucl p (alpha * fst X)) = alpha * fst X + e1⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?z1 = "trunc_bound_eucl p (fst ?z0 + zeta)" from trunc_bound_euclE (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_eucl ?p ?x); fst (trunc_bound_eucl ?p ?x) = ?x + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e1' where abs_e1': "¦e1'¦ ≤ snd ?z1" and e1': "fst ?z1 = fst ?z0 + zeta + e1'" (*goal: ‹(⋀e1'. ⟦¦e1'¦ ≤ snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + zeta)); fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + zeta)) = fst (trunc_bound_eucl p (alpha * fst X)) + zeta + e1'⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?zs = "trunc_bound_pdevs p (scaleR_pdevs alpha (snd X))" from trunc_bound_pdevsE[OF e] (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_pdevs ?p ?x); pdevs_val e (fst (trunc_bound_pdevs ?p ?x)) = pdevs_val e ?x + err⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e2 where abs_e2: "¦e2¦ ≤ snd (?zs)" and e2: "pdevs_val e (fst ?zs) = pdevs_val e (scaleR_pdevs alpha (snd X)) + e2" (*goal: ‹(⋀e2. ⟦¦e2¦ ≤ snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X))); pdevs_val e (fst (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))) = pdevs_val e (scaleR_pdevs alpha (snd X)) + e2⟧ ⟹ thesis) ⟹ thesis›*) by blast have "alpha * (aform_val e X) + zeta = aform_val e (fst (inverse_aform' p X)) + (- e1 - e1' - e2)" unfolding inverse_aform'_def Let_def vars[symmetric] (*goal: ‹alpha * aform_val e X + zeta = aform_val e (fst ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + (if l < 0 then - zeta else zeta))), fst (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))), sum_list' p [truncate_up p ((if l < 0 then - zeta else zeta) - d_min'), snd (trunc_bound_eucl p (alpha * fst X)), snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + (if l < 0 then - zeta else zeta))), snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))])) + (- e1 - e1' - e2)›*) using ‹0 < l› (*‹0 < l›*) apply (simp add: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) assms (*‹e ∈ UNIV → {- 1..1}› ‹0 < Inf_aform' p X› ‹x = aform_val e X›*) e1' (*‹fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + zeta)) = fst (trunc_bound_eucl p (alpha * fst X)) + zeta + e1'›*)) (*goal: ‹alpha * aform_val e X + zeta = aform_val e (fst ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + (if l < 0 then - zeta else zeta))), fst (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))), sum_list' p [truncate_up p ((if l < 0 then - zeta else zeta) - d_min'), snd (trunc_bound_eucl p (alpha * fst X)), snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + (if l < 0 then - zeta else zeta))), snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))])) + (- e1 - e1' - e2)›*) by (simp add: e1 (*‹fst (trunc_bound_eucl p (alpha * fst X)) = alpha * fst X + e1›*) e2 (*‹pdevs_val e (fst (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))) = pdevs_val e (scaleR_pdevs alpha (snd X)) + e2›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) also (*calculation: ‹inverse (aform_val e X) = aform_val e (fst (inverse_aform' p X)) + (- e1 - e1' - e2) + (inverse (aform_val e X) - alpha * aform_val e X - zeta)›*) let ?err = "(- e1 - e1' - e2 + inverse (aform_val e X) - alpha * aform_val e X - zeta)" { have "abs ?err ≤ abs ?linerr + abs e1 + abs e1' + abs e2" by simp also (*calculation: ‹¦- e1 - e1' - e2 + inverse (aform_val e X) - alpha * aform_val e X - zeta¦ ≤ ¦inverse (aform_val e X) - alpha * aform_val e X - zeta¦ + ¦e1¦ + ¦e1'¦ + ¦e2¦›*) have "… ≤ delta + snd ?z0 + snd ?z1 + snd ?zs" by (blast intro: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) linerr_le (*‹¦inverse (aform_val e X) - alpha * aform_val e X - zeta¦ ≤ delta›*) abs_e1 (*‹¦e1¦ ≤ snd (trunc_bound_eucl p (alpha * fst X))›*) abs_e1' (*‹¦e1'¦ ≤ snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + zeta))›*) abs_e2 (*‹¦e2¦ ≤ snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))›*)) also (*calculation: ‹¦- (e1::real) - (e1'::real) - (e2::real) + inverse (aform_val (e::nat ⇒ real) (X::real × real pdevs)) - (alpha::real) * aform_val e X - (zeta::real)¦ ≤ (delta::real) + snd (trunc_bound_eucl (p::nat) (alpha * fst X)) + snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + zeta)) + snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))›*) have "… ≤ (snd (inverse_aform' p X))" unfolding inverse_aform'_def Let_def vars[symmetric] (*goal: ‹delta + snd (trunc_bound_eucl p (alpha * fst X)) + snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + zeta)) + snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X))) ≤ snd ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + (if l < 0 then - zeta else zeta))), fst (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))), sum_list' p [truncate_up p ((if l < 0 then - zeta else zeta) - d_min'), snd (trunc_bound_eucl p (alpha * fst X)), snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (alpha * fst X)) + (if l < 0 then - zeta else zeta))), snd (trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)))])›*) using ‹0 < l› (*‹0 < l›*) by (auto simp add: inverse_aform'_def (*‹inverse_aform' ?p ?X = (let l = Inf_aform' ?p ?X; u = Sup_aform' ?p ?X; a = min ¦l¦ ¦u¦; b = max ¦l¦ ¦u¦; sq = truncate_up ?p (b * b); alpha = - real_divl ?p 1 sq; dmax = truncate_up ?p (real_divr ?p 1 a - alpha * a); dmin = truncate_down ?p (real_divl ?p 1 b - alpha * b); zeta' = truncate_up ?p ((dmin + dmax) / 2); zeta = if l < 0 then - zeta' else zeta'; delta = truncate_up ?p (zeta - dmin); res1 = trunc_bound_eucl ?p (alpha * fst ?X); res2 = trunc_bound_eucl ?p (fst res1 + zeta); zs = trunc_bound_pdevs ?p (scaleR_pdevs alpha (snd ?X)) in ((fst res2, fst zs), sum_list' ?p [delta, snd res1, snd res2, snd zs]))›*) pdevs_apply_trunc_pdevs (*‹pdevs_apply (trunc_pdevs ?p ?X) ?n = eucl_truncate_down ?p (pdevs_apply ?X ?n)›*) assms (*‹e ∈ UNIV → {- 1..1}› ‹0 < Inf_aform' p X› ‹x = aform_val e X›*) vars[symmetric] (*‹Inf_aform' p X = l› ‹Sup_aform' p X = u› ‹min ¦l¦ ¦u¦ = a› ‹max ¦l¦ ¦u¦ = b› ‹truncate_up p (b * b) = sq› ‹- real_divl p 1 sq = alpha› ‹truncate_up p (real_divr p 1 a - alpha * a) = d_max'› ‹truncate_down p (real_divl p 1 b - alpha * b) = d_min'› ‹truncate_up p ((d_min' + d_max') / 2) = zeta› ‹truncate_up p (zeta - d_min') = delta›*) intro!: order.trans[OF _ sum_list'_sum_list_le] (*‹⟦?a ≤ ?b; ?b ≤ sum_list ?xs1⟧ ⟹ ?a ≤ sum_list' ?p1 ?xs1›*)) finally (*calculation: ‹¦- (e1::real) - (e1'::real) - (e2::real) + inverse (aform_val (e::nat ⇒ real) (X::real × real pdevs)) - (alpha::real) * aform_val e X - (zeta::real)¦ ≤ snd (inverse_aform' (p::nat) X)›*) have "abs ?err ≤ snd (inverse_aform' p X)" by simp } note err_le = this (*‹¦- (e1::real) - (e1'::real) - (e2::real) + inverse (aform_val (e::nat ⇒ real) (X::real × real pdevs)) - (alpha::real) * aform_val e X - (zeta::real)¦ ≤ snd (inverse_aform' (p::nat) X)›*) have "aform_val (e) (fst (inverse_aform' p X)) + (- e1 - e1' - e2) + (inverse (aform_val e X) - alpha * aform_val e X - zeta) = aform_val e (fst (inverse_aform' p X)) + ?err" by simp finally (*calculation: ‹inverse (aform_val e X) = aform_val e (fst (inverse_aform' p X)) + (- e1 - e1' - e2 + inverse (aform_val e X) - alpha * aform_val e X - zeta)›*) show "?thesis" (*goal: ‹inverse x ∈ aform_err e (inverse_aform' p X)›*) apply (intro aform_errI (*‹¦(?x::real) - aform_val (?e::nat ⇒ real) (fst (?Xe::(real × real pdevs) × real))¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) (*goal: ‹inverse x ∈ aform_err e (inverse_aform' p X)›*) using err_le (*‹¦- e1 - e1' - e2 + inverse (aform_val e X) - alpha * aform_val e X - zeta¦ ≤ snd (inverse_aform' p X)›*) by (auto simp: assms (*‹e ∈ UNIV → {- 1..1}› ‹0 < Inf_aform' p X› ‹x = aform_val e X›*)) qed definition "inverse_aform p a = do { let l = Inf_aform' p a; let u = Sup_aform' p a; if (l ≤ 0 ∧ 0 ≤ u) then None else if (l ≤ 0) then (Some (apfst uminus_aform (inverse_aform' p (uminus_aform a)))) else Some (inverse_aform' p a) }" lemma eucl_truncate_up_eq_eucl_truncate_down: "eucl_truncate_up p x = - (eucl_truncate_down p (- x))" by (auto simp: eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*) eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*) truncate_up_eq_truncate_down (*‹truncate_up ?p ?x = - truncate_down ?p (- ?x)›*) sum_negf (*‹(∑x∈?A. - ?f x) = - sum ?f ?A›*)) lemma inverse_aformE: fixes X::"real aform" assumes e: "e ∈ UNIV → {-1 .. 1}" and disj: "Inf_aform' p X > 0 ∨ Sup_aform' p X < 0" obtains Y where "inverse_aform p X = Some Y" "inverse (aform_val e X) ∈ aform_err e Y" proof (-) (*goal: ‹(⋀Y. ⟦inverse_aform p X = Some Y; inverse (aform_val e X) ∈ aform_err e Y⟧ ⟹ thesis) ⟹ thesis›*) { assume neg: "Sup_aform' p X < 0" (*‹Sup_aform' (p::nat) (X::real × real pdevs) < (0::real)›*) from neg (*‹Sup_aform' p X < 0›*) have [simp]: "Inf_aform' p X ≤ 0" by (metis Inf_aform'_le_Sup_aform' (*‹Inf_aform' ?p ?X ≤ Sup_aform' ?p ?X›*) dual_order.strict_trans1 (*‹⟦?b ≤ ?a; ?c < ?b⟧ ⟹ ?c < ?a›*) less_asym (*‹⟦?x < ?y; ¬ ?P ⟹ ?y < ?x⟧ ⟹ ?P›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*)) from neg (*‹Sup_aform' p X < 0›*) disj (*‹0 < Inf_aform' p X ∨ Sup_aform' p X < 0›*) have "0 < Inf_aform' p (uminus_aform X)" by (auto simp: Inf_aform'_def (*‹Inf_aform' ?p ?X = eucl_truncate_down ?p (fst ?X - Radius' ?p ?X)›*) Sup_aform'_def (*‹Sup_aform' ?p ?X = eucl_truncate_up ?p (fst ?X + Radius' ?p ?X)›*) eucl_truncate_up_eq_eucl_truncate_down (*‹eucl_truncate_up ?p ?x = - eucl_truncate_down ?p (- ?x)›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*)) from inverse_aform'E[OF e ( 1 ) this] (*‹?x = aform_val e (uminus_aform X) ⟹ inverse ?x ∈ aform_err e (inverse_aform' p (uminus_aform X))›*) have iin: "inverse (aform_val e (uminus_aform X)) ∈ aform_err e (inverse_aform' p (uminus_aform X))" by simp let ?Y = "apfst uminus_aform (inverse_aform' p (uminus_aform X))" have "inverse_aform p X = Some ?Y" "inverse (aform_val e X) ∈ aform_err e ?Y" using neg (*‹Sup_aform' p X < 0›*) iin (*‹inverse (aform_val e (uminus_aform X)) ∈ aform_err e (inverse_aform' p (uminus_aform X))›*) apply - (*goals: 1. ‹⟦Sup_aform' p X < 0; inverse (aform_val e (uminus_aform X)) ∈ aform_err e (inverse_aform' p (uminus_aform X))⟧ ⟹ inverse_aform p X = Some (apfst uminus_aform (inverse_aform' p (uminus_aform X)))› 2. ‹⟦Sup_aform' p X < 0; inverse (aform_val e (uminus_aform X)) ∈ aform_err e (inverse_aform' p (uminus_aform X))⟧ ⟹ inverse (aform_val e X) ∈ aform_err e (apfst uminus_aform (inverse_aform' p (uminus_aform X)))› discuss goal 1*) apply ((auto simp: inverse_aform_def (*‹inverse_aform ?p ?a = (let l = Inf_aform' ?p ?a; u = Sup_aform' ?p ?a in if l ≤ 0 ∧ 0 ≤ u then None else if l ≤ 0 then Some (apfst uminus_aform (inverse_aform' ?p (uminus_aform ?a))) else Some (inverse_aform' ?p ?a))›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*))[1]) (*discuss goal 2*) apply ((auto simp: inverse_aform_def (*‹inverse_aform ?p ?a = (let l = Inf_aform' ?p ?a; u = Sup_aform' ?p ?a in if l ≤ 0 ∧ 0 ≤ u then None else if l ≤ 0 then Some (apfst uminus_aform (inverse_aform' ?p (uminus_aform ?a))) else Some (inverse_aform' ?p ?a))›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*))[1]) (*proven 2 subgoals*) . then have "?thesis" by standard } moreover { assume pos: "Inf_aform' p X > 0" (*‹(0::real) < Inf_aform' (p::nat) (X::real × real pdevs)›*) from pos (*‹0 < Inf_aform' p X›*) have eq: "inverse_aform p X = Some (inverse_aform' p X)" by (auto simp: inverse_aform_def (*‹inverse_aform ?p ?a = (let l = Inf_aform' ?p ?a; u = Sup_aform' ?p ?a in if l ≤ 0 ∧ 0 ≤ u then None else if l ≤ 0 then Some (apfst uminus_aform (inverse_aform' ?p (uminus_aform ?a))) else Some (inverse_aform' ?p ?a))›*)) moreover from inverse_aform'E[OF e ( 1 ) pos refl] (*‹inverse (aform_val e X) ∈ aform_err e (inverse_aform' p X)›*) have "inverse (aform_val e X) ∈ aform_err e (inverse_aform' p X)" . ultimately have "?thesis" by standard } ultimately show "?thesis" (*goal: ‹thesis›*) using assms (*‹e ∈ UNIV → {- 1..1}› ‹0 < Inf_aform' p X ∨ Sup_aform' p X < 0›*) by auto qed definition aform_err_to_aform::"aform_err ⇒ nat ⇒ real aform" where "aform_err_to_aform X n = (fst (fst X), pdev_upd (snd (fst X)) n (snd X))" lemma aform_err_to_aformE: assumes "x ∈ aform_err e X" assumes deg: "degree_aform_err X ≤ n" obtains err where "x = aform_val (e(n:=err)) (aform_err_to_aform X n)" "-1 ≤ err" "err ≤ 1" proof (-) (*goal: ‹(⋀err. ⟦x = aform_val (e(n := err)) (aform_err_to_aform X n); - 1 ≤ err; err ≤ 1⟧ ⟹ thesis) ⟹ thesis›*) from aform_errE[OF assms ( 1 )] (*‹¦x - aform_val e (fst X)¦ ≤ snd X›*) have "¦x - aform_val e (fst X)¦ ≤ snd X" by auto from error_absE[OF this] (*‹(⋀ea::real. ⟦(x::real) - aform_val (e::nat ⇒ real) (fst (X::(real × real pdevs) × real)) = ea * snd X; ea ∈ {- (1::real)..1::real}⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain err where err: "x - aform_val e (fst X) = err * snd X" "err ∈ {- 1..1}" (*goal: ‹(⋀err. ⟦x - aform_val e (fst X) = err * snd X; err ∈ {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) by auto have "x = aform_val (e(n:=err)) (aform_err_to_aform X n)" "-1 ≤ err" "err ≤ 1" using err (*‹x - aform_val e (fst X) = err * snd X› ‹err ∈ {- 1..1}›*) deg (*‹degree_aform_err X ≤ n›*) apply - (*goals: 1. ‹⟦(x::real) - aform_val (e::nat ⇒ real) (fst (X::(real × real pdevs) × real)) = (err::real) * snd X; err ∈ {- (1::real)..1::real}; degree_aform_err X ≤ (n::nat)⟧ ⟹ x = aform_val (e(n := err)) (aform_err_to_aform X n)› 2. ‹⟦(x::real) - aform_val (e::nat ⇒ real) (fst (X::(real × real pdevs) × real)) = (err::real) * snd X; err ∈ {- (1::real)..1::real}; degree_aform_err X ≤ (n::nat)⟧ ⟹ - (1::real) ≤ err› 3. ‹⟦(x::real) - aform_val (e::nat ⇒ real) (fst (X::(real × real pdevs) × real)) = (err::real) * snd X; err ∈ {- (1::real)..1::real}; degree_aform_err X ≤ (n::nat)⟧ ⟹ err ≤ (1::real)› discuss goal 1*) apply ((auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*))[1]) (*discuss goal 2*) apply ((auto simp: aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) aform_err_to_aform_def (*‹aform_err_to_aform (?X::(real × real pdevs) × real) (?n::nat) = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*))[1]) (*discuss goal 3*) apply ((auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*))[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹thesis›*) by standard qed definition aform_to_aform_err::"real aform ⇒ nat ⇒ aform_err" where "aform_to_aform_err X n = ((fst X, pdev_upd (snd X) n 0), abs (pdevs_apply (snd X) n))" lemma aform_to_aform_err: "aform_val e X ∈ aform_err e (aform_to_aform_err X n)" if "e ∈ UNIV → {-1 .. 1}" proof (-) (*goal: ‹aform_val e X ∈ aform_err e (aform_to_aform_err X n)›*) from that (*‹e ∈ UNIV → {- 1..1}›*) have abs_e[simp]: "⋀i. ¦e i¦ ≤ 1" by (auto simp: abs_real_def (*‹¦?a::real¦ = (if ?a < (0::real) then - ?a else ?a)›*)) have "- e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦" proof (-) (*goal: ‹- e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦›*) have "- e n * pdevs_apply (snd X) n ≤ ¦- e n * pdevs_apply (snd X) n¦" by auto also (*calculation: ‹- (e::nat ⇒ real) (n::nat) * pdevs_apply (snd (X::real × real pdevs)) n ≤ ¦- e n * pdevs_apply (snd X) n¦›*) have "… ≤ abs (pdevs_apply (snd X) n)" using that (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp: abs_mult (*‹¦(?a::?'a) * (?b::?'a)¦ = ¦?a¦ * ¦?b¦›*) intro!: mult_left_le_one_le (*‹⟦(0::?'a) ≤ (?x::?'a); (0::?'a) ≤ (?y::?'a); ?y ≤ (1::?'a)⟧ ⟹ ?y * ?x ≤ ?x›*)) finally (*calculation: ‹- e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦›*) show "?thesis" (*goal: ‹- (e::nat ⇒ real) (n::nat) * pdevs_apply (snd (X::real × real pdevs)) n ≤ ¦pdevs_apply (snd X) n¦›*) . qed moreover have "e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦" proof (-) (*goal: ‹e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦›*) have "e n * pdevs_apply (snd X) n ≤ ¦e n * pdevs_apply (snd X) n¦" by auto also (*calculation: ‹e n * pdevs_apply (snd X) n ≤ ¦e n * pdevs_apply (snd X) n¦›*) have "… ≤ abs (pdevs_apply (snd X) n)" using that (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) intro!: mult_left_le_one_le (*‹⟦0 ≤ ?x; 0 ≤ ?y; ?y ≤ 1⟧ ⟹ ?y * ?x ≤ ?x›*)) finally (*calculation: ‹e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦›*) show "?thesis" (*goal: ‹e n * pdevs_apply (snd X) n ≤ ¦pdevs_apply (snd X) n¦›*) . qed ultimately show "?thesis" (*goal: ‹aform_val e X ∈ aform_err e (aform_to_aform_err X n)›*) by (auto simp: aform_to_aform_err_def (*‹aform_to_aform_err ?X ?n = ((fst ?X, pdev_upd (snd ?X) ?n 0), ¦pdevs_apply (snd ?X) ?n¦)›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) qed definition "acc_err p x e ≡ (fst x, truncate_up p (snd x + e))" definition ivl_err :: "real interval ⇒ (real × real pdevs) × real" where "ivl_err ivl ≡ (((upper ivl + lower ivl)/2, zero_pdevs::real pdevs), (upper ivl - lower ivl) / 2)" lemma inverse_aform: fixes X::"real aform" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes "inverse_aform p X = Some Y" shows "inverse (aform_val e X) ∈ aform_err e Y" proof (-) (*goal: ‹inverse (aform_val (e::nat ⇒ real) (X::real × real pdevs)) ∈ aform_err e (Y::(real × real pdevs) × real)›*) from assms (*‹e ∈ UNIV → {- 1..1}› ‹inverse_aform p X = Some Y›*) have "Inf_aform' p X > 0 ∨ 0 > Sup_aform' p X" by (auto simp: inverse_aform_def (*‹inverse_aform ?p ?a = (let l = Inf_aform' ?p ?a; u = Sup_aform' ?p ?a in if l ≤ 0 ∧ 0 ≤ u then None else if l ≤ 0 then Some (apfst uminus_aform (inverse_aform' ?p (uminus_aform ?a))) else Some (inverse_aform' ?p ?a))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) from inverse_aformE[OF e this] (*‹(⋀Y. ⟦inverse_aform p X = Some Y; inverse (aform_val e X) ∈ aform_err e Y⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain Y where "inverse_aform p X = Some Y" "inverse (aform_val e X) ∈ aform_err e Y" (*goal: ‹(⋀Y::(real × real pdevs) × real. ⟦inverse_aform (p::nat) (X::real × real pdevs) = Some Y; inverse (aform_val (e::nat ⇒ real) X) ∈ aform_err e Y⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto with assms (*‹e ∈ UNIV → {- 1..1}› ‹inverse_aform p X = Some Y›*) show "?thesis" (*goal: ‹inverse (aform_val e X) ∈ aform_err e Y›*) by auto qed lemma aform_err_acc_err_leI: "fx ∈ aform_err e (acc_err p X err)" if "aform_val e (fst X) - (snd X + err) ≤ fx" "fx ≤ aform_val e (fst X) + (snd X + err)" using truncate_up[of "(snd X + err)" p] (*‹snd X + err ≤ truncate_up p (snd X + err)›*) truncate_down[of p "(snd X + err)"] (*‹truncate_down (p::nat) (snd (X::(real × real pdevs) × real) + (err::real)) ≤ snd X + err›*) that (*‹aform_val e (fst X) - (snd X + err) ≤ fx› ‹fx ≤ aform_val e (fst X) + (snd X + err)›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*)) lemma aform_err_acc_errI: "fx ∈ aform_err e (acc_err p X err)" if "fx ∈ aform_err e (fst X, snd X + err)" using truncate_up[of "(snd X + err)" p] (*‹snd X + err ≤ truncate_up p (snd X + err)›*) truncate_down[of p "(snd X + err)"] (*‹truncate_down p (snd X + err) ≤ snd X + err›*) that (*‹(fx::real) ∈ aform_err (e::nat ⇒ real) (fst (X::(real × real pdevs) × real), snd X + (err::real))›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*)) lemma minus_times_le_abs: "- (err * B) ≤ ¦B¦" if "-1 ≤ err" "err ≤ 1" for err::real proof (-) (*goal: ‹- ((err::real) * (B::real)) ≤ ¦B¦›*) have [simp]: "abs err ≤ 1" using that (*‹- (1::real) ≤ (err::real)› ‹err ≤ 1›*) by auto have "- (err * B) ≤ abs (- err * B)" by auto also (*calculation: ‹- (err * B) ≤ ¦- err * B¦›*) have "… ≤ abs B" by (auto simp: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) intro!: mult_left_le_one_le (*‹⟦0 ≤ ?x; 0 ≤ ?y; ?y ≤ 1⟧ ⟹ ?y * ?x ≤ ?x›*)) finally (*calculation: ‹- ((err::real) * (B::real)) ≤ ¦B¦›*) show "?thesis" (*goal: ‹- (err * B) ≤ ¦B¦›*) by simp qed lemma times_le_abs: "err * B ≤ ¦B¦" if "-1 ≤ err" "err ≤ 1" for err::real proof (-) (*goal: ‹(err::real) * (B::real) ≤ ¦B¦›*) have [simp]: "abs err ≤ 1" using that (*‹- 1 ≤ err› ‹(err::real) ≤ (1::real)›*) by auto have "err * B ≤ abs (err * B)" by auto also (*calculation: ‹(err::real) * (B::real) ≤ ¦err * B¦›*) have "… ≤ abs B" by (auto simp: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) intro!: mult_left_le_one_le (*‹⟦0 ≤ ?x; 0 ≤ ?y; ?y ≤ 1⟧ ⟹ ?y * ?x ≤ ?x›*)) finally (*calculation: ‹err * B ≤ ¦B¦›*) show "?thesis" (*goal: ‹err * B ≤ ¦B¦›*) by simp qed lemma aform_err_lemma1: "- 1 ≤ err ⟹ err ≤ 1 ⟹ X1 + (A - e d * B + err * B) - e1 ≤ x ⟹ X1 + (A - e d * B) - truncate_up p (¦B¦ + e1) ≤ x" apply (rule order_trans (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y ≤ (?z::?'a)⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⟦- 1 ≤ err; err ≤ 1; X1 + (A - e d * B + err * B) - e1 ≤ x⟧ ⟹ X1 + (A - e d * B) - truncate_up p (¦B¦ + e1) ≤ ?y› 2. ‹⟦- 1 ≤ err; err ≤ 1; X1 + (A - e d * B + err * B) - e1 ≤ x⟧ ⟹ ?y ≤ x› discuss goal 1*) apply (rule diff_mono (*‹⟦?a ≤ ?b; ?d ≤ ?c⟧ ⟹ ?a - ?c ≤ ?b - ?d›*)) (*goals: 1. ‹⟦- 1 ≤ err; err ≤ 1; X1 + (A - e d * B + err * B) - e1 ≤ x⟧ ⟹ X1 + (A - e d * B) ≤ ?b3› 2. ‹⟦- 1 ≤ err; err ≤ 1; X1 + (A - e d * B + err * B) - e1 ≤ x⟧ ⟹ ?d3 ≤ truncate_up p (¦B¦ + e1)› discuss goal 1*) apply (rule order_refl (*‹?x ≤ ?x›*)) (*discuss goal 2*) apply (rule truncate_up_le[where x="e1 - err * B"] (*‹e1 - err * B ≤ ?y ⟹ e1 - err * B ≤ truncate_up ?prec ?y›*)) (*top goal: ‹⟦- 1 ≤ err; err ≤ 1; X1 + (A - e d * B + err * B) - e1 ≤ x⟧ ⟹ ?d3 ≤ truncate_up p (¦B¦ + e1)› and 1 goal remains*) apply ((auto simp: minus_times_le_abs (*‹⟦- 1 ≤ ?err; ?err ≤ 1⟧ ⟹ - (?err * ?B) ≤ ¦?B¦›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto simp: minus_times_le_abs (*‹⟦- 1 ≤ ?err; ?err ≤ 1⟧ ⟹ - (?err * ?B) ≤ ¦?B¦›*))[1]) (*proven 2 subgoals*) . lemma aform_err_lemma2: "- 1 ≤ err ⟹ err ≤ 1 ⟹ x ≤ X1 + (A - e d * B + err * B) + e1 ⟹ x ≤ X1 + (A - e d * B) + truncate_up p (¦B¦ + e1)" apply (rule order_trans[rotated] (*‹⟦?y ≤ ?z; ?x ≤ ?y⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⟦- (1::real) ≤ (err::real); err ≤ (1::real); (x::real) ≤ (X1::real) + ((A::real) - (e::'a ⇒ real) (d::'a) * (B::real) + err * B) + (e1::real)⟧ ⟹ (?y::real) ≤ X1 + (A - e d * B) + truncate_up (p::nat) (¦B¦ + e1)› 2. ‹⟦- (1::real) ≤ (err::real); err ≤ (1::real); (x::real) ≤ (X1::real) + ((A::real) - (e::'a ⇒ real) (d::'a) * (B::real) + err * B) + (e1::real)⟧ ⟹ x ≤ (?y::real)› discuss goal 1*) apply (rule add_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (?c::?'a) ≤ (?d::?'a)⟧ ⟹ ?a + ?c ≤ ?b + ?d›*)) (*goals: 1. ‹⟦- (1::real) ≤ (err::real); err ≤ (1::real); (x::real) ≤ (X1::real) + ((A::real) - (e::'a ⇒ real) (d::'a) * (B::real) + err * B) + (e1::real)⟧ ⟹ (?a3::real) ≤ X1 + (A - e d * B)› 2. ‹⟦- (1::real) ≤ (err::real); err ≤ (1::real); (x::real) ≤ (X1::real) + ((A::real) - (e::'a ⇒ real) (d::'a) * (B::real) + err * B) + (e1::real)⟧ ⟹ (?c3::real) ≤ truncate_up (p::nat) (¦B¦ + e1)› discuss goal 1*) apply (rule order_refl (*‹(?x::?'a::preorder) ≤ ?x›*)) (*discuss goal 2*) apply (rule truncate_up_le[where x="e1 + err * B"] (*‹e1 + err * B ≤ ?y ⟹ e1 + err * B ≤ truncate_up ?prec ?y›*)) (*top goal: ‹⟦- (1::real) ≤ (err::real); err ≤ (1::real); (x::real) ≤ (X1::real) + ((A::real) - (e::'a ⇒ real) (d::'a) * (B::real) + err * B) + (e1::real)⟧ ⟹ (?c3::real) ≤ truncate_up (p::nat) (¦B¦ + e1)› and 1 goal remains*) apply ((auto simp: times_le_abs (*‹⟦- 1 ≤ ?err; ?err ≤ 1⟧ ⟹ ?err * ?B ≤ ¦?B¦›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto simp: times_le_abs (*‹⟦- 1 ≤ ?err; ?err ≤ 1⟧ ⟹ ?err * ?B ≤ ¦?B¦›*))[1]) (*proven 2 subgoals*) . lemma aform_err_acc_err_aform_to_aform_errI: "x ∈ aform_err e (acc_err p (aform_to_aform_err X1 d) e1)" if "-1 ≤ err" "err ≤ 1" "x ∈ aform_err (e(d := err)) (X1, e1)" using that (*‹- 1 ≤ err› ‹err ≤ 1› ‹x ∈ aform_err (e(d := err)) (X1, e1)›*) by (auto simp: acc_err_def (*‹acc_err (?p::nat) (?x::?'a × real) (?e::real) ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) aform_err_def (*‹aform_err (?e::nat ⇒ real) (?Xe::(real × real pdevs) × real) = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) aform_to_aform_err_def (*‹aform_to_aform_err (?X::real × real pdevs) (?n::nat) = ((fst ?X, pdev_upd (snd ?X) ?n (0::real)), ¦pdevs_apply (snd ?X) ?n¦)›*) aform_err_to_aform_def (*‹aform_err_to_aform (?X::(real × real pdevs) × real) (?n::nat) = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) aform_err_lemma1 (*‹⟦- (1::real) ≤ (?err::real); ?err ≤ (1::real); (?X1.0::real) + ((?A::real) - (?e::?'a ⇒ real) (?d::?'a) * (?B::real) + ?err * ?B) - (?e1.0::real) ≤ (?x::real)⟧ ⟹ ?X1.0 + (?A - ?e ?d * ?B) - truncate_up (?p::nat) (¦?B¦ + ?e1.0) ≤ ?x›*) aform_err_lemma2 (*‹⟦- (1::real) ≤ (?err::real); ?err ≤ (1::real); (?x::real) ≤ (?X1.0::real) + ((?A::real) - (?e::?'a ⇒ real) (?d::?'a) * (?B::real) + ?err * ?B) + (?e1.0::real)⟧ ⟹ ?x ≤ ?X1.0 + (?A - ?e ?d * ?B) + truncate_up (?p::nat) (¦?B¦ + ?e1.0)›*)) definition "map_aform_err I p X = (do { let X0 = aform_err_to_aform X (degree_aform_err X); (X1, e1) ← I X0; Some (acc_err p (aform_to_aform_err X1 (degree_aform_err X)) e1) })" lemma map_aform_err: "i x ∈ aform_err e Y" if I: "⋀e X Y. e ∈ UNIV → {-1 .. 1} ⟹ I X = Some Y ⟹ i (aform_val e X) ∈ aform_err e Y" and e: "e ∈ UNIV → {-1 .. 1}" and Y: "map_aform_err I p X = Some Y" and x: "x ∈ aform_err e X" proof (-) (*goal: ‹i x ∈ aform_err e Y›*) obtain X1 and e1 where X1: "(I (aform_err_to_aform X (degree_aform_err X))) = Some (X1, e1)" and Y: "Y = acc_err p (aform_to_aform_err X1 (degree_aform (fst X))) e1" (*goal: ‹(⋀X1 e1. ⟦I (aform_err_to_aform X (degree_aform_err X)) = Some (X1, e1); Y = acc_err p (aform_to_aform_err X1 (degree_aform_err X)) e1⟧ ⟹ thesis) ⟹ thesis›*) using Y (*‹map_aform_err I p X = Some Y›*) by (auto simp: map_aform_err_def (*‹map_aform_err ?I ?p ?X = (let X0 = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1, e1). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) from aform_err_to_aformE[OF x] (*‹⟦degree_aform_err X ≤ ?n; ⋀err. ⟦x = aform_val (e(?n := err)) (aform_err_to_aform X ?n); - 1 ≤ err; err ≤ 1⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) obtain err where err: "x = aform_val (e(degree_aform_err X := err)) (aform_err_to_aform X (degree_aform_err X)) " (is "_ = aform_val ?e _") and "- 1 ≤ err" "err ≤ 1" (*goal: ‹(⋀err. ⟦x = aform_val (e(degree_aform_err X := err)) (aform_err_to_aform X (degree_aform_err X)); - 1 ≤ err; err ≤ 1⟧ ⟹ thesis) ⟹ thesis›*) by auto then have e': "?e ∈ UNIV → {-1 .. 1}" using e (*‹e ∈ UNIV → {- 1..1}›*) by auto from err (*‹x = aform_val (e(degree_aform_err X := err)) (aform_err_to_aform X (degree_aform_err X))›*) have "i x = i (aform_val (e(degree_aform_err X := err)) (aform_err_to_aform X (degree_aform_err X)))" by simp also (*calculation: ‹i x = i (aform_val (e(degree_aform_err X := err)) (aform_err_to_aform X (degree_aform_err X)))›*) note I[OF e' X1] (*‹i (aform_val (e(degree_aform_err X := err)) (aform_err_to_aform X (degree_aform_err X))) ∈ aform_err (e(degree_aform_err X := err)) (X1, e1)›*) also (*calculation: ‹i x ∈ aform_err (e(degree_aform_err X := err)) (X1, e1)›*) have "aform_err (e(degree_aform_err X := err)) (X1, e1) ⊆ aform_err e Y" apply rule (*goal: ‹aform_err (e(degree_aform_err X := err)) (X1, e1) ⊆ aform_err e Y›*) unfolding Y (*goal: ‹⋀x. x ∈ aform_err (e(degree_aform_err X := err)) (X1, e1) ⟹ x ∈ aform_err e (acc_err p (aform_to_aform_err X1 (degree_aform_err X)) e1)›*) using ‹-1 ≤ err› (*‹- (1::real) ≤ (err::real)›*) ‹err ≤ 1› (*‹err ≤ 1›*) by (rule aform_err_acc_err_aform_to_aform_errI (*‹⟦- 1 ≤ ?err; ?err ≤ 1; ?x ∈ aform_err (?e(?d := ?err)) (?X1.0, ?e1.0)⟧ ⟹ ?x ∈ aform_err ?e (acc_err ?p (aform_to_aform_err ?X1.0 ?d) ?e1.0)›*)) finally (*calculation: ‹i x ∈ aform_err e Y›*) show "?thesis" (*goal: ‹i x ∈ aform_err e Y›*) . qed definition "inverse_aform_err p X = map_aform_err (inverse_aform p) p X" lemma inverse_aform_err: "inverse x ∈ aform_err e Y" if e: "e ∈ UNIV → {-1 .. 1}" and Y: "inverse_aform_err p X = Some Y" and x: "x ∈ aform_err e X" using map_aform_err[OF inverse_aform [ where p = p ] e Y [ unfolded inverse_aform_err_def ] x] (*‹⟦⋀(e::nat ⇒ real) (X::real × real pdevs) Y::(real × real pdevs) × real. ⟦e ∈ UNIV → {- (1::real)..1::real}; inverse_aform (p::nat) X = Some Y⟧ ⟹ e ∈ UNIV → {- (1::real)..1::real}; ⋀(e::nat ⇒ real) (X::real × real pdevs) Y::(real × real pdevs) × real. ⟦e ∈ UNIV → {- (1::real)..1::real}; inverse_aform p X = Some Y⟧ ⟹ inverse_aform p X = Some Y⟧ ⟹ inverse (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) by auto subsection ‹Reduction (Summarization of Coefficients)› text ‹\label{sec:affinesummarize}› definition "pdevs_of_centered_ivl r = (inner_scaleR_pdevs r One_pdevs)" lemma pdevs_of_centered_ivl_eq_pdevs_of_ivl[simp]: "pdevs_of_centered_ivl r = pdevs_of_ivl (-r) r" by (auto simp: pdevs_of_centered_ivl_def (*‹pdevs_of_centered_ivl ?r = inner_scaleR_pdevs ?r One_pdevs›*) pdevs_of_ivl_def (*‹pdevs_of_ivl ?l ?u = scaleR_pdevs (1 / 2) (inner_scaleR_pdevs (?u - ?l) One_pdevs)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) intro!: pdevs_eqI (*‹(⋀i. pdevs_apply ?x i = pdevs_apply ?y i) ⟹ ?x = ?y›*)) lemma filter_pdevs_raw_nonzeros: "{i. filter_pdevs_raw s f i ≠ 0} = {i. f i ≠ 0} ∩ {x. s x (f x)}" by (auto simp: filter_pdevs_raw_def (*‹filter_pdevs_raw ?I ?X = (λi. if ?I i (?X i) then ?X i else 0)›*)) definition summarize_pdevs:: "nat ⇒ (nat ⇒ 'a ⇒ bool) ⇒ nat ⇒ 'a::executable_euclidean_space pdevs ⇒ 'a pdevs" where "summarize_pdevs p I d x = (let t = tdev' p (filter_pdevs (-I) x) in msum_pdevs d (filter_pdevs I x) (pdevs_of_centered_ivl t))" definition summarize_threshold where "summarize_threshold p t x y ⟷ infnorm y ≥ t * infnorm (eucl_truncate_up p (tdev' p x))" lemma error_abs_euclE: fixes err::"'a::ordered_euclidean_space" assumes "abs err ≤ k" obtains e::"'a ⇒ real" where "err = (∑i∈Basis. (e i * (k ∙ i)) *⇩R i)" "e ∈ UNIV → {-1 .. 1}" proof (atomize_elim) (*goal: ‹∃e. err = (∑i∈Basis. (e i * (k ∙ i)) *⇩R i) ∧ e ∈ UNIV → {- 1..1}›*) { fix i :: 'a assume "i ∈ Basis" (*‹(i::'a) ∈ Basis›*) hence "abs (err ∙ i) ≤ (k ∙ i)" using assms (*‹¦err¦ ≤ k›*) by (auto simp add: eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) abs_inner (*‹?i ∈ Basis ⟹ ¦?x¦ ∙ ?i = ¦?x ∙ ?i¦›*)) hence "∃e. (err ∙ i = e * (k ∙ i)) ∧ e ∈ {-1..1}" apply (rule error_absE (*‹⟦¦?err¦ ≤ ?k; ⋀e. ⟦?err = e * ?k; e ∈ {- 1..1}⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹∃e. err ∙ i = e * (k ∙ i) ∧ e ∈ {- 1..1}›*) by auto } then obtain e where e: "⋀i. i ∈ Basis ⟹ err ∙ i = e i * (k ∙ i)" "⋀i. i ∈ Basis ⟹ e i ∈ {-1 .. 1}" (*goal: ‹(⋀e. ⟦⋀i. i ∈ Basis ⟹ err ∙ i = e i * (k ∙ i); ⋀i. i ∈ Basis ⟹ e i ∈ {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) by metis have singleton: "⋀b. b ∈ Basis ⟹ (∑i∈Basis. e i * (k ∙ i) * (if i = b then 1 else 0)) = (∑i∈{b}. e i * (k ∙ i) * (if i = b then 1 else 0))" apply (rule sum.mono_neutral_cong_right (*‹⟦finite ?T; ?S ⊆ ?T; ∀i∈?T - ?S. ?g i = 0; ⋀x. x ∈ ?S ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?T = sum ?h ?S›*)) (*goals: 1. ‹⋀b. b ∈ Basis ⟹ finite Basis› 2. ‹⋀b. b ∈ Basis ⟹ {b} ⊆ Basis› 3. ‹⋀b. b ∈ Basis ⟹ ∀i∈Basis - {b}. e i * (k ∙ i) * (if i = b then 1 else 0) = 0› 4. ‹⋀b x. ⟦b ∈ Basis; x ∈ {b}⟧ ⟹ e x * (k ∙ x) * (if x = b then 1 else 0) = e x * (k ∙ x) * (if x = b then 1 else 0)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . show "∃e::'a⇒real. err = (∑i∈Basis. (e i * (k ∙ i)) *⇩R i) ∧ (e ∈ UNIV → {-1..1})" using e (*‹?i ∈ Basis ⟹ err ∙ ?i = e ?i * (k ∙ ?i)› ‹?i ∈ Basis ⟹ e ?i ∈ {- 1..1}›*) by (auto intro!: exI[where x="λi. if i ∈ Basis then e i else 0"] (*‹?P (λi. if i ∈ Basis then e i else 0) ⟹ ∃x. ?P x›*) euclidean_eqI[where 'a='a] (*‹(⋀b. b ∈ Basis ⟹ ?x ∙ b = ?y ∙ b) ⟹ ?x = ?y›*) simp: inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) singleton (*‹?b ∈ Basis ⟹ (∑i∈Basis. e i * (k ∙ i) * (if i = ?b then 1 else 0)) = (∑i∈{?b}. e i * (k ∙ i) * (if i = ?b then 1 else 0))›*)) qed lemma summarize_pdevsE: fixes x::"'a::executable_euclidean_space pdevs" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes d: "degree x ≤ d" obtains e' where "pdevs_val e x = pdevs_val e' (summarize_pdevs p I d x)" "⋀i. i < d ⟹ e i = e' i" "e' ∈ UNIV → {-1 .. 1}" proof (atomize_elim) (*goal: ‹∃e'::nat ⇒ real. pdevs_val (e::nat ⇒ real) (x::'a pdevs) = pdevs_val e' (summarize_pdevs (p::nat) (I::nat ⇒ 'a ⇒ bool) (d::nat) x) ∧ (∀i<d. e i = e' i) ∧ e' ∈ UNIV → {- (1::real)..1::real}›*) have "pdevs_val e x = (∑i<degree x. e i *⇩R pdevs_apply x i)" by (auto simp add: pdevs_val_sum (*‹pdevs_val (?e::nat ⇒ real) (?X::?'a::real_normed_vector pdevs) = (∑i::nat<degree ?X. ?e i *⇩R pdevs_apply ?X i)›*) intro!: sum.cong (*‹⟦(?A::?'b::type set) = (?B::?'b::type set); ⋀x::?'b::type. x ∈ ?B ⟹ (?g::?'b::type ⇒ ?'a::comm_monoid_add) x = (?h::?'b::type ⇒ ?'a::comm_monoid_add) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) also (*calculation: ‹pdevs_val e x = (∑i<degree x. e i *⇩R pdevs_apply x i)›*) have "… = (∑i ∈ {..<degree x} ∩ {i. I i (pdevs_apply x i)}. e i *⇩R pdevs_apply x i) + (∑i∈ {..<degree x} - {i. I i (pdevs_apply x i)}. e i *⇩R pdevs_apply x i)" (is "_ = ?large + ?small") apply (subst sum.union_disjoint[symmetric] (*‹⟦finite (?A::?'b::type set); finite (?B::?'b::type set); ?A ∩ ?B = {}⟧ ⟹ sum (?g::?'b::type ⇒ ?'a::comm_monoid_add) ?A + sum ?g ?B = sum ?g (?A ∪ ?B)›*)) (*goals: 1. ‹finite ({..<degree (x::'a::executable_euclidean_space pdevs)} ∩ {i::nat. (I::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply x i)})› 2. ‹finite ({..<degree (x::'a::executable_euclidean_space pdevs)} - {i::nat. (I::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply x i)})› 3. ‹{..<degree (x::'a::executable_euclidean_space pdevs)} ∩ {i::nat. (I::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply x i)} ∩ ({..<degree x} - {i::nat. I i (pdevs_apply x i)}) = {}› 4. ‹(∑i::nat<degree x. (e::nat ⇒ real) i *⇩R pdevs_apply (x::'a::executable_euclidean_space pdevs) i) = (∑i::nat∈{..<degree x} ∩ {i::nat. (I::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply x i)} ∪ ({..<degree x} - {i::nat. I i (pdevs_apply x i)}). e i *⇩R pdevs_apply x i)› discuss goal 1*) apply ((auto simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*) intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*discuss goal 2*) apply ((auto simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*) intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*discuss goal 3*) apply ((auto simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*) intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*discuss goal 4*) apply ((auto simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*) intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*proven 4 subgoals*) . also (*calculation: ‹pdevs_val e x = (∑i∈{..<degree x} ∩ {i. I i (pdevs_apply x i)}. e i *⇩R pdevs_apply x i) + (∑i∈{..<degree x} - {i. I i (pdevs_apply x i)}. e i *⇩R pdevs_apply x i)›*) have "?large = pdevs_val e (filter_pdevs I x)" by (simp add: pdevs_val_filter_pdevs (*‹pdevs_val (?e::nat ⇒ real) (filter_pdevs (?I::nat ⇒ ?'a::real_normed_vector ⇒ bool) (?x::?'a::real_normed_vector pdevs)) = (∑i::nat∈{..<degree ?x} ∩ {i::nat. ?I i (pdevs_apply ?x i)}. ?e i *⇩R pdevs_apply ?x i)›*)) also (*calculation: ‹pdevs_val (e::nat ⇒ real) (x::'a pdevs) = pdevs_val e (filter_pdevs (I::nat ⇒ 'a ⇒ bool) x) + (∑i::nat∈{..<degree x} - {i::nat. I i (pdevs_apply x i)}. e i *⇩R pdevs_apply x i)›*) have "?small = pdevs_val e (filter_pdevs (-I) x)" by (simp add: pdevs_val_filter_pdevs (*‹pdevs_val ?e (filter_pdevs ?I ?x) = (∑i∈{..<degree ?x} ∩ {i. ?I i (pdevs_apply ?x i)}. ?e i *⇩R pdevs_apply ?x i)›*) Collect_neg_eq (*‹{x. ¬ ?P x} = - {x. ?P x}›*) Diff_eq (*‹?A - ?B = ?A ∩ - ?B›*)) also (*calculation: ‹pdevs_val e x = pdevs_val e (filter_pdevs I x) + pdevs_val e (filter_pdevs (- I) x)›*) have "abs … ≤ tdev' p (filter_pdevs (-I) x)" (is "abs ?r ≤ ?t") using e (*‹e ∈ UNIV → {- 1..1}›*) by (rule abs_pdevs_val_le_tdev' (*‹?e ∈ UNIV → {- 1..1} ⟹ ¦pdevs_val ?e ?y¦ ≤ tdev' ?p ?y›*)) hence "?r ∈ {-?t .. ?t}" by (metis abs_le_D1 (*‹¦?a¦ ≤ ?b ⟹ ?a ≤ ?b›*) abs_le_D2 (*‹¦?a¦ ≤ ?b ⟹ - ?a ≤ ?b›*) atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) minus_le_iff (*‹(- ?a ≤ ?b) = (- ?b ≤ ?a)›*)) from in_ivl_affine_of_ivlE[OF this] (*‹(⋀ea. ⟦ea ∈ UNIV → {- 1..1}; pdevs_val e (filter_pdevs (- I) x) = aform_val ea (aform_of_ivl (- tdev' p (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x)))⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e2 where "?r = aform_val e2 (aform_of_ivl (- ?t) ?t)" and e2: "e2 ∈ UNIV → {- 1..1}" (*goal: ‹(⋀e2. ⟦pdevs_val e (filter_pdevs (- I) x) = aform_val e2 (aform_of_ivl (- tdev' p (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x))); e2 ∈ UNIV → {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) by metis note this(1) (*‹pdevs_val e (filter_pdevs (- I) x) = aform_val e2 (aform_of_ivl (- tdev' p (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x)))›*) also (*calculation: ‹pdevs_val e x = pdevs_val e (filter_pdevs I x) + aform_val e2 (aform_of_ivl (- tdev' p (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x)))›*) define e' where "e' i = (if i < d then e i else e2 (i - d))" for i hence "aform_val e2 (aform_of_ivl (- ?t) ?t) = pdevs_val (λi. e' (i + d)) (pdevs_of_ivl (- ?t) ?t)" by (auto simp: aform_of_ivl_def (*‹aform_of_ivl ?l ?u = ((?l + ?u) /⇩R 2, pdevs_of_ivl ?l ?u)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) also (*calculation: ‹pdevs_val (e::nat ⇒ real) (x::'a pdevs) = pdevs_val e (filter_pdevs (I::nat ⇒ 'a ⇒ bool) x) + pdevs_val (λi::nat. (e'::nat ⇒ real) (i + (d::nat))) (pdevs_of_ivl (- tdev' (p::nat) (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x)))›*) have "pdevs_val e (filter_pdevs I x) = pdevs_val e' (filter_pdevs I x)" using assms (*‹e ∈ UNIV → {- 1..1}› ‹degree x ≤ d›*) by (auto simp: e'_def (*‹(e'::nat ⇒ real) (?i::nat) = (if ?i < (d::nat) then (e::nat ⇒ real) ?i else (e2::nat ⇒ real) (?i - d))›*) pdevs_val_sum (*‹pdevs_val (?e::nat ⇒ real) (?X::?'a pdevs) = (∑i::nat<degree ?X. ?e i *⇩R pdevs_apply ?X i)›*) intro!: sum.cong (*‹⟦(?A::?'b set) = (?B::?'b set); ⋀x::?'b. x ∈ ?B ⟹ (?g::?'b ⇒ ?'a) x = (?h::?'b ⇒ ?'a) x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) finally (*calculation: ‹pdevs_val e x = pdevs_val e' (filter_pdevs I x) + pdevs_val (λi. e' (i + d)) (pdevs_of_ivl (- tdev' p (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x)))›*) have "pdevs_val e x = pdevs_val e' (filter_pdevs I x) + pdevs_val (λi. e' (i + d)) (pdevs_of_ivl (- ?t) ?t)" . also (*calculation: ‹pdevs_val e x = pdevs_val e' (filter_pdevs I x) + pdevs_val (λi. e' (i + d)) (pdevs_of_ivl (- tdev' p (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x)))›*) note pdevs_val_msum_pdevs[symmetric, OF order_trans [ OF degree_filter_pdevs_le d ]] (*‹pdevs_val ?e (filter_pdevs ?I2 x) + pdevs_val (λi. ?e (i + d)) ?g = pdevs_val ?e (msum_pdevs d (filter_pdevs ?I2 x) ?g)›*) finally (*calculation: ‹pdevs_val (e::nat ⇒ real) (x::'a pdevs) = pdevs_val (e'::nat ⇒ real) (msum_pdevs (d::nat) (filter_pdevs (I::nat ⇒ 'a ⇒ bool) x) (pdevs_of_ivl (- tdev' (p::nat) (filter_pdevs (- I) x)) (tdev' p (filter_pdevs (- I) x))))›*) have "pdevs_val e x = pdevs_val e' (summarize_pdevs p I d x)" by (auto simp: summarize_pdevs_def (*‹summarize_pdevs ?p ?I ?d ?x = (let t = tdev' ?p (filter_pdevs (- ?I) ?x) in msum_pdevs ?d (filter_pdevs ?I ?x) (pdevs_of_centered_ivl t))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) moreover have "e' ∈ UNIV → {-1 .. 1}" using e (*‹e ∈ UNIV → {- 1..1}›*) e2 (*‹e2 ∈ UNIV → {- 1..1}›*) by (auto simp: e'_def (*‹e' ?i = (if ?i < d then e ?i else e2 (?i - d))›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*)) moreover have "∀i < d. e' i = e i" by (auto simp: e'_def (*‹e' ?i = (if ?i < d then e ?i else e2 (?i - d))›*)) ultimately show "∃e'. pdevs_val e x = pdevs_val e' (summarize_pdevs p I d x) ∧ (∀i<d. e i = e' i) ∧ e' ∈ UNIV → {- 1..1}" by auto qed definition "summarize_pdevs_list p I d xs = map (λ(d, x). summarize_pdevs p (λi _. I i (pdevs_applys xs i)) d x) (zip [d..<d + length xs] xs)" lemma filter_pdevs_cong[cong]: assumes "x = y" assumes "⋀i. i ∈ pdevs_domain y ⟹ P i (pdevs_apply x i) = Q i (pdevs_apply y i)" shows "filter_pdevs P x = filter_pdevs Q y" using assms (*‹(x::'a pdevs) = (y::'a pdevs)› ‹(?i::nat) ∈ pdevs_domain (y::'a pdevs) ⟹ (P::nat ⇒ 'a ⇒ bool) ?i (pdevs_apply (x::'a pdevs) ?i) = (Q::nat ⇒ 'a ⇒ bool) ?i (pdevs_apply y ?i)›*) by (force intro!: pdevs_eqI (*‹(⋀i::nat. pdevs_apply (?x::?'a pdevs) i = pdevs_apply (?y::?'a pdevs) i) ⟹ ?x = ?y›*)) lemma summarize_pdevs_cong[cong]: assumes "p = q" "a = c" "b = d" assumes PQ: "⋀i. i ∈ pdevs_domain d ⟹ P i (pdevs_apply b i) = Q i (pdevs_apply d i)" shows "summarize_pdevs p P a b = summarize_pdevs q Q c d" proof (-) (*goal: ‹summarize_pdevs p P a b = summarize_pdevs q Q c d›*) have "(filter_pdevs P b) = filter_pdevs Q d" "(filter_pdevs (λa b. ¬ P a b) b) = filter_pdevs (λa b. ¬ Q a b) d" using assms (*‹p = q› ‹a = c› ‹(b::'a::executable_euclidean_space pdevs) = (d::'a::executable_euclidean_space pdevs)› ‹?i ∈ pdevs_domain d ⟹ P ?i (pdevs_apply b ?i) = Q ?i (pdevs_apply d ?i)›*) apply - (*goals: 1. ‹⟦(p::nat) = (q::nat); (a::nat) = (c::nat); (b::'a::executable_euclidean_space pdevs) = (d::'a::executable_euclidean_space pdevs); ⋀i::nat. i ∈ pdevs_domain d ⟹ (P::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply b i) = (Q::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply d i)⟧ ⟹ filter_pdevs P b = filter_pdevs Q d› 2. ‹⟦(p::nat) = (q::nat); (a::nat) = (c::nat); (b::'a::executable_euclidean_space pdevs) = (d::'a::executable_euclidean_space pdevs); ⋀i::nat. i ∈ pdevs_domain d ⟹ (P::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply b i) = (Q::nat ⇒ 'a::executable_euclidean_space ⇒ bool) i (pdevs_apply d i)⟧ ⟹ filter_pdevs (λ(a::nat) b::'a::executable_euclidean_space. ¬ P a b) b = filter_pdevs (λ(a::nat) b::'a::executable_euclidean_space. ¬ Q a b) d› discuss goal 1*) apply ((auto intro!: filter_pdevs_cong (*‹⟦?x = ?y; ⋀i. i ∈ pdevs_domain ?y ⟹ ?P i (pdevs_apply ?x i) = ?Q i (pdevs_apply ?y i)⟧ ⟹ filter_pdevs ?P ?x = filter_pdevs ?Q ?y›*))[1]) (*discuss goal 2*) apply ((auto intro!: filter_pdevs_cong (*‹⟦?x = ?y; ⋀i. i ∈ pdevs_domain ?y ⟹ ?P i (pdevs_apply ?x i) = ?Q i (pdevs_apply ?y i)⟧ ⟹ filter_pdevs ?P ?x = filter_pdevs ?Q ?y›*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹summarize_pdevs (p::nat) (P::nat ⇒ 'a ⇒ bool) (a::nat) (b::'a pdevs) = summarize_pdevs (q::nat) (Q::nat ⇒ 'a ⇒ bool) (c::nat) (d::'a pdevs)›*) by (auto simp add: assms (*‹p = q› ‹a = c› ‹b = d› ‹?i ∈ pdevs_domain d ⟹ P ?i (pdevs_apply b ?i) = Q ?i (pdevs_apply d ?i)›*) summarize_pdevs_def (*‹summarize_pdevs ?p ?I ?d ?x = (let t = tdev' ?p (filter_pdevs (- ?I) ?x) in msum_pdevs ?d (filter_pdevs ?I ?x) (pdevs_of_centered_ivl t))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) qed lemma lookup_eq_None_iff: "(Mapping.lookup M x = None) = (x ∉ Mapping.keys M)" apply transfer (*goal: ‹(Mapping.lookup M x = None) = (x ∉ Mapping.keys M)›*) by auto lemma lookup_eq_SomeD: "(Mapping.lookup M x = Some y) ⟹ (x ∈ Mapping.keys M)" apply transfer (*goal: ‹Mapping.lookup M x = Some y ⟹ x ∈ Mapping.keys M›*) by auto definition "domain_pdevs xs = (⋃(pdevs_domain ` (set xs)))" definition "pdevs_mapping xs = (let D = sorted_list_of_set (domain_pdevs xs); M = Mapping.tabulate D (pdevs_applys xs); zeroes = replicate (length xs) 0 in Mapping.lookup_default zeroes M)" lemma pdevs_mapping_eq[simp]: "pdevs_mapping xs = pdevs_applys xs" unfolding pdevs_mapping_def pdevs_applys_def (*goal: ‹(let D = sorted_list_of_set (domain_pdevs xs); M = Mapping.tabulate D (λi. map (λx. pdevs_apply x i) xs); zeroes = replicate (length xs) 0 in Mapping.lookup_default zeroes M) = (λi. map (λx. pdevs_apply x i) xs)›*) apply (auto simp: Mapping.lookup_default_def (*‹Mapping.lookup_default ?d ?m ?k = (case Mapping.lookup ?m ?k of None ⇒ ?d | Some v ⇒ v)›*) lookup_eq_None_iff (*‹(Mapping.lookup ?M ?x = None) = (?x ∉ Mapping.keys ?M)›*) domain_pdevs_def (*‹domain_pdevs ?xs = ⋃ (pdevs_domain ` set ?xs)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹(let D = sorted_list_of_set (domain_pdevs xs); M = Mapping.tabulate D (λi. map (λx. pdevs_apply x i) xs); zeroes = replicate (length xs) 0 in Mapping.lookup_default zeroes M) = (λi. map (λx. pdevs_apply x i) xs)›*) subgoal for by (auto intro!: nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*)) subgoal for apply (auto intro!: nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*) dest:) (*goal: ‹Mapping.lookup (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set xs))) (λi. map (λx. pdevs_apply x i) xs)) i_ = Some x2_ ⟹ x2_ = map (λx. pdevs_apply x i_) xs›*) subgoal for apply (frule lookup_eq_SomeD (*‹Mapping.lookup (?M::(?'b, ?'a) mapping) (?x::?'b) = Some (?y::?'a) ⟹ ?x ∈ Mapping.keys ?M›*)) (*goal: ‹Mapping.lookup (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set (xs::'a::zero pdevs list)))) (λi::nat. map (λx::'a::zero pdevs. pdevs_apply x i) xs)) (i_::nat) = Some (x2_::'a::zero list) ⟹ length x2_ = length xs›*) apply auto (*goal: ‹⟦Mapping.lookup (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set xs))) (λi. map (λx. pdevs_apply x i) xs)) i_ = Some x2_; i_ ∈ Mapping.keys (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set xs))) (λi. map (λx. pdevs_apply x i) xs))⟧ ⟹ length x2_ = length xs›*) by (metis distinct_sorted_list_of_set (*‹distinct (sorted_list_of_set ?A)›*) keys_tabulate (*‹Mapping.keys (Mapping.tabulate ?ks ?f) = set ?ks›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) lookup_eq_SomeD (*‹Mapping.lookup ?M ?x = Some ?y ⟹ ?x ∈ Mapping.keys ?M›*) lookup_tabulate (*‹distinct ?xs ⟹ Mapping.lookup (Mapping.tabulate ?xs ?f) ?x = (if ?x ∈ set ?xs then Some (?f ?x) else None)›*) option.inject (*‹(Some ?x2.0 = Some ?y2.0) = (?x2.0 = ?y2.0)›*)) subgoal for apply (frule lookup_eq_SomeD (*‹Mapping.lookup ?M ?x = Some ?y ⟹ ?x ∈ Mapping.keys ?M›*)) (*goal: ‹⟦Mapping.lookup (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set (xs::'a::zero pdevs list)))) (λi::nat. map (λx::'a::zero pdevs. pdevs_apply x i) xs)) (i_::nat) = Some (x2_::'a::zero list); (ia_::nat) < length x2_⟧ ⟹ x2_ ! ia_ = map (λx::'a::zero pdevs. pdevs_apply x i_) xs ! ia_›*) apply (auto simp: map_nth (*‹map ((!) ?xs) [0..<length ?xs] = ?xs›*)) (*goal: ‹⟦Mapping.lookup (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set xs))) (λi. map (λx. pdevs_apply x i) xs)) i_ = Some x2_; ia_ < length x2_; i_ ∈ Mapping.keys (Mapping.tabulate (sorted_list_of_set (⋃ (pdevs_domain ` set xs))) (λi. map (λx. pdevs_apply x i) xs))⟧ ⟹ x2_ ! ia_ = map (λx. pdevs_apply x i_) xs ! ia_›*) by (metis (mono_tags, lifting) keys_tabulate (*‹Mapping.keys (Mapping.tabulate ?ks ?f) = set ?ks›*) lookup_eq_SomeD (*‹Mapping.lookup ?M ?x = Some ?y ⟹ ?x ∈ Mapping.keys ?M›*) lookup_tabulate (*‹distinct ?xs ⟹ Mapping.lookup (Mapping.tabulate ?xs ?f) ?x = (if ?x ∈ set ?xs then Some (?f ?x) else None)›*) option.inject (*‹(Some ?x2.0 = Some ?y2.0) = (?x2.0 = ?y2.0)›*) distinct_sorted_list_of_set (*‹distinct (sorted_list_of_set ?A)›*)) . . lemma compute_summarize_pdevs_list[code]: "summarize_pdevs_list p I d xs = (let M = pdevs_mapping xs in map (λ(x, y). summarize_pdevs p (λi _. I i (M i)) x y) (zip [d..<d + length xs] xs))" unfolding summarize_pdevs_list_def pdevs_mapping_eq (*goal: ‹map2 (summarize_pdevs (p::nat) (λ(i::nat) _::'a::executable_euclidean_space. (I::nat ⇒ 'a::executable_euclidean_space list ⇒ bool) i (pdevs_applys (xs::'a::executable_euclidean_space pdevs list) i))) [d::nat..<d + length xs] xs = (let M::nat ⇒ 'a::executable_euclidean_space list = pdevs_applys xs in map2 (summarize_pdevs p (λ(i::nat) _::'a::executable_euclidean_space. I i (M i))) [d..<d + length xs] xs)›*) by auto lemma in_centered_ivlE: fixes r t::real assumes "r ∈ {-t .. t}" obtains e where "e ∈ {-1 .. 1}" "r = e * t" using assms (*‹r ∈ {- t..t}›*) apply atomize_elim (*goal: ‹(⋀e. ⟦e ∈ {- 1..1}; r = e * t⟧ ⟹ thesis) ⟹ thesis›*) by (auto intro!: exI[where x="r / t"] (*‹?P (r / t) ⟹ ∃x. ?P x›*) simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) lift_definition singleton_pdevs::"'a ⇒ 'a::real_normed_vector pdevs" is "λx i. if i = 0 then x else 0" by auto lemmas [simp] = singleton_pdevs.rep_eq lemma singleton_0[simp]: "singleton_pdevs 0 = zero_pdevs" sorry lemma degree_singleton_pdevs[simp]: "degree (singleton_pdevs x) = (if x = 0 then 0 else Suc 0)" by (auto simp: intro!: degree_eqI (*‹⟦pdevs_apply (?x::?'a pdevs) (?d::nat) ≠ (0::?'a); ⋀j::nat. ?d < j ⟹ pdevs_apply ?x j = (0::?'a)⟧ ⟹ degree ?x = Suc ?d›*)) lemma pdevs_val_singleton_pdevs[simp]: "pdevs_val e (singleton_pdevs x) = e 0 *⇩R x" by (auto simp: pdevs_val_sum (*‹pdevs_val (?e::nat ⇒ real) (?X::?'a pdevs) = (∑i::nat<degree ?X. ?e i *⇩R pdevs_apply ?X i)›*) if_distrib (*‹(?f::?'b ⇒ ?'a) (if ?c::bool then ?x::?'b else (?y::?'b)) = (if ?c then ?f ?x else ?f ?y)›*) sum.delta (*‹finite (?S::?'b set) ⟹ (∑k::?'b∈?S. if k = (?a::?'b) then (?b::?'b ⇒ ?'a) k else (0::?'a)) = (if ?a ∈ ?S then ?b ?a else (0::?'a))›*) cong: if_cong (*‹⟦(?b::bool) = (?c::bool); ?c ⟹ (?x::?'a) = (?u::?'a); ¬ ?c ⟹ (?y::?'a) = (?v::?'a)⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) lemma pdevs_of_ivl_real: fixes a b::real shows "pdevs_of_ivl a b = singleton_pdevs ((b - a) / 2)" by (auto simp: pdevs_of_ivl_def (*‹pdevs_of_ivl ?l ?u = scaleR_pdevs (1 / 2) (inner_scaleR_pdevs (?u - ?l) One_pdevs)›*) Basis_list_real_def (*‹Basis_list = [1]›*) intro!: pdevs_eqI (*‹(⋀i. pdevs_apply ?x i = pdevs_apply ?y i) ⟹ ?x = ?y›*)) lemma summarize_pdevs_listE: fixes X::"real pdevs list" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes d: "degrees X ≤ d" obtains e' where "pdevs_vals e X = pdevs_vals e' (summarize_pdevs_list p I d X)" "⋀i. i < d ⟹ e i = e' i" "e' ∈ UNIV → {-1 .. 1}" proof (-) (*goal: ‹(⋀e'. ⟦pdevs_vals e X = pdevs_vals e' (summarize_pdevs_list p I d X); ⋀i. i < d ⟹ e i = e' i; e' ∈ UNIV → {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) let ?I = "{i. I i (pdevs_applys X i)}" let ?J = "λi x. I i (pdevs_applys X i)" have "pdevs_vals e X = map (λx. ∑i<degree x. e i *⇩R pdevs_apply x i) X" using d (*‹degrees X ≤ d›*) by (auto simp: pdevs_vals_def (*‹pdevs_vals (?e::nat ⇒ real) (?X::?'a pdevs list) = map (pdevs_val ?e) ?X›*) simp del: real_scaleR_def (*‹(?a::real) *⇩R (?x::real) = ?a * ?x›*) intro!: pdevs_val_sum_le (*‹degree (?X::?'a pdevs) ≤ (?d::nat) ⟹ pdevs_val (?e::nat ⇒ real) ?X = (∑i::nat<?d. ?e i *⇩R pdevs_apply ?X i)›*) dest!: degrees_leD (*‹⟦degrees (?X::?'a pdevs list) ≤ (?K::nat); (?x::?'a pdevs) ∈ set ?X⟧ ⟹ degree ?x ≤ ?K›*)) also (*calculation: ‹pdevs_vals e X = map (λx. ∑i<degree x. e i *⇩R pdevs_apply x i) X›*) have "… = map (λx. (∑i∈{..<degree x} ∩ ?I. e i * pdevs_apply x i) + (∑i∈{..<degree x} - ?I. e i * pdevs_apply x i)) X" apply (rule map_cong[OF refl] (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = ?g x) ⟹ map ?f ?xs = map ?g ?xs›*)) (*goal: ‹map (λx. ∑i<degree x. e i *⇩R pdevs_apply x i) X = map (λx. (∑i∈{..<degree x} ∩ {i. I i (pdevs_applys X i)}. e i * pdevs_apply x i) + (∑i∈{..<degree x} - {i. I i (pdevs_applys X i)}. e i * pdevs_apply x i)) X›*) apply (subst sum.union_disjoint[symmetric] (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g ?A + sum ?g ?B = sum ?g (?A ∪ ?B)›*)) (*goals: 1. ‹⋀x. x ∈ set X ⟹ finite ({..<degree x} ∩ {i. I i (pdevs_applys X i)})› 2. ‹⋀x. x ∈ set X ⟹ finite ({..<degree x} - {i. I i (pdevs_applys X i)})› 3. ‹⋀x. x ∈ set X ⟹ {..<degree x} ∩ {i. I i (pdevs_applys X i)} ∩ ({..<degree x} - {i. I i (pdevs_applys X i)}) = {}› 4. ‹⋀x. x ∈ set X ⟹ (∑i<degree x. e i *⇩R pdevs_apply x i) = (∑i∈{..<degree x} ∩ {i. I i (pdevs_applys X i)} ∪ ({..<degree x} - {i. I i (pdevs_applys X i)}). e i * pdevs_apply x i)› discuss goal 1*) apply ((auto intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*discuss goal 2*) apply ((auto intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*discuss goal 3*) apply ((auto intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*discuss goal 4*) apply ((auto intro!: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*))[1]) (*proven 4 subgoals*) . also (*calculation: ‹pdevs_vals e X = map (λx. (∑i∈{..<degree x} ∩ {i. I i (pdevs_applys X i)}. e i * pdevs_apply x i) + (∑i∈{..<degree x} - {i. I i (pdevs_applys X i)}. e i * pdevs_apply x i)) X›*) have "… = map (λx. pdevs_val e (filter_pdevs ?J x) + pdevs_val e (filter_pdevs (-?J) x)) X" (is "_ = map (λx. ?large x + ?small x) _") by (auto simp: pdevs_val_filter_pdevs (*‹pdevs_val ?e (filter_pdevs ?I ?x) = (∑i∈{..<degree ?x} ∩ {i. ?I i (pdevs_apply ?x i)}. ?e i *⇩R pdevs_apply ?x i)›*) Diff_eq (*‹?A - ?B = ?A ∩ - ?B›*) Compl_eq (*‹- ?A = {x. x ∉ ?A}›*)) also (*calculation: ‹pdevs_vals e X = map (λx. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) x)) X›*) have "… = map snd (zip [d..<d + length X] …)" by simp also (*calculation: ‹pdevs_vals e X = map snd (zip [d..<d + length X] (map (λx. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) x)) X))›*) have "… = map (λ(d, x). ?large x + ?small x) (zip [d..<d + length X] X)" (is "_ = map _ ?z") unfolding map_zip_map2 (*goal: ‹map2 (λx y. snd (x, pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) y) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) y))) [d..<d + length X] X = map2 (λd x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) x)) [d..<d + length X] X›*) by simp also (*calculation: ‹pdevs_vals e X = map2 (λd x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) x)) [d..<d + length X] X›*) have "… = map (λ(d', x). ?large x + ?small (snd (?z ! (d' - d)))) ?z" by (auto simp: in_set_zip (*‹(?p ∈ set (zip ?xs ?ys)) = (∃n. ?xs ! n = fst ?p ∧ ?ys ! n = snd ?p ∧ n < length ?xs ∧ n < length ?ys)›*)) also (*calculation: ‹pdevs_vals e X = map2 (λd' x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) [d..<d + length X] X›*) let ?t = "λx. tdev' p (filter_pdevs (-?J) x)" let ?x = "λd'. snd (?z ! (d' - d))" { fix d' assume "d ≤ d'" "d' < d + length X" (*‹(d::nat) ≤ (d'::nat)› ‹(d'::nat) < (d::nat) + length (X::real pdevs list)›*) have "abs (?small (?x d')) ≤ ?t (?x d')" using ‹e ∈ _› (*‹e ∈ UNIV → {- 1..1}›*) by (rule abs_pdevs_val_le_tdev' (*‹(?e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real} ⟹ ¦pdevs_val ?e (?y::?'a pdevs)¦ ≤ tdev' (?p::nat) ?y›*)) then have "?small (?x d') ∈ {-?t (?x d') .. ?t (?x d')}" by auto from in_centered_ivlE[OF this] (*‹(⋀ea. ⟦ea ∈ {- 1..1}; pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = ea * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))⟧ ⟹ ?thesis) ⟹ ?thesis›*) have "∃e∈{-1 .. 1}. ?small (?x d') = e * ?t (?x d')" by blast } then obtain e'' where e'': "e'' d' ∈ {-1 .. 1}" "?small (?x d') = e'' d' * ?t (?x d')" if "d' ∈ {d ..< d + length X}" for d' (*goal: ‹(⋀e''. ⟦⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))⟧ ⟹ thesis) ⟹ thesis›*) apply atomize_elim (*goal: ‹(⋀e''. ⟦⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))⟧ ⟹ thesis) ⟹ thesis›*) unfolding all_conj_distrib[symmetric] imp_conjR[symmetric] (*goal: ‹(⋀d'::nat. ⟦(d::nat) ≤ d'; d' < d + length (X::real pdevs list)⟧ ⟹ ∃ea::real∈{- (1::real)..1::real}. pdevs_val (e::nat ⇒ real) (filter_pdevs (- (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = ea * tdev' (p::nat) (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) ⟹ ∃e''::nat ⇒ real. ∀x::nat. x ∈ {d..<d + length X} ⟶ e'' x ∈ {- (1::real)..1::real} ∧ pdevs_val e (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (x - d)))) = e'' x * tdev' p (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (x - d))))›*) unfolding Ball_def[symmetric] atLeastAtMost_iff[symmetric] (*goal: ‹(⋀d'::nat. ⟦(d::nat) ≤ d'; d' < d + length (X::real pdevs list)⟧ ⟹ ∃ea::real∈{- (1::real)..1::real}. pdevs_val (e::nat ⇒ real) (filter_pdevs (- (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = ea * tdev' (p::nat) (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) ⟹ ∃e''::nat ⇒ real. ∀x::nat∈{d..<d + length X}. e'' x ∈ {- (1::real)..1::real} ∧ pdevs_val e (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (x - d)))) = e'' x * tdev' p (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (x - d))))›*) apply (rule bchoice (*‹∀x∈?S. ∃y. ?Q x y ⟹ ∃f. ∀x∈?S. ?Q x (f x)›*)) (*goal: ‹(⋀d'. ⟦d ≤ d'; d' < d + length X⟧ ⟹ ∃ea∈{- 1..1}. pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = ea * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) ⟹ ∃e''. ∀x∈{d..<d + length X}. e'' x ∈ {- 1..1} ∧ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (x - d)))) = e'' x * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (x - d))))›*) by (auto simp: Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*)) define e' where "e' ≡ λi. if i < d then e i else if i < d + length X then e'' i else 0" have e': "e' d' ∈ {-1 .. 1}" "?small (?x d') = e' d' * ?t (?x d')" if "d' ∈ {d ..< d + length X}" for d' using e'' (*‹(?d'2::nat) ∈ {d::nat..<d + length (X::real pdevs list)} ⟹ (e''::nat ⇒ real) ?d'2 ∈ {- (1::real)..1::real}› ‹?d'2 ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (?d'2 - d)))) = e'' ?d'2 * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (?d'2 - d))))›*) that (*‹d' ∈ {d..<d + length X}›*) apply - (*goals: 1. ‹⟦⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))); d' ∈ {d..<d + length X}⟧ ⟹ e' d' ∈ {- 1..1}› 2. ‹⟦⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))); d' ∈ {d..<d + length X}⟧ ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))› discuss goal 1*) apply ((auto simp: e'_def (*‹e' ≡ λi. if i < d then e i else if i < d + length X then e'' i else 0›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: e'_def (*‹e'::nat ⇒ real ≡ λi::nat. if i < (d::nat) then (e::nat ⇒ real) i else if i < d + length (X::real pdevs list) then (e''::nat ⇒ real) i else (0::real)›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . then have "*": "pdevs_val e (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (?x d')) = e' d' * ?t (?x d')" if "d' ∈ {d ..< d + length X}" for d' using that (*‹d' ∈ {d..<d + length X}›*) by auto have "map (λ(d', x). ?large x + ?small (?x d')) ?z = map (λ(d', x). ?large x + e' d' * ?t (?x d')) ?z" apply (auto simp: in_set_zip (*‹(?p ∈ set (zip ?xs ?ys)) = (∃n. ?xs ! n = fst ?p ∧ ?ys ! n = snd ?p ∧ n < length ?xs ∧ n < length ?ys)›*)) (*goal: ‹map2 (λd' x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) [d..<d + length X] X = map2 (λd' x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + e' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) [d..<d + length X] X›*) subgoal for n using e'(2)[of "d + n"] (*‹d + n ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d + n - d)))) = e' (d + n) * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d + n - d))))›*) by auto . also (*calculation: ‹pdevs_vals e X = map2 (λd' x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + e' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) [d..<d + length X] X›*) have "… = map (λ(d', x). pdevs_val e' (summarize_pdevs p ?J d' x)) (zip [d..<d + length X] X)" apply (auto simp: summarize_pdevs_def (*‹summarize_pdevs ?p ?I ?d ?x = (let t = tdev' ?p (filter_pdevs (- ?I) ?x) in msum_pdevs ?d (filter_pdevs ?I ?x) (pdevs_of_centered_ivl t))›*) pdevs_val_msum_pdevs (*‹degree ?f ≤ ?n ⟹ pdevs_val ?e (msum_pdevs ?n ?f ?g) = pdevs_val ?e ?f + pdevs_val (λi. ?e (i + ?n)) ?g›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) in_set_zip (*‹(?p ∈ set (zip ?xs ?ys)) = (∃n. ?xs ! n = fst ?p ∧ ?ys ! n = snd ?p ∧ n < length ?xs ∧ n < length ?ys)›*)) (*goal: ‹map2 (λd' x. pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) x) + e' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))) [d..<d + length X] X = map2 (λd' x. pdevs_val e' (summarize_pdevs p (λi x. I i (pdevs_applys X i)) d' x)) [d..<d + length X] X›*) apply (subst pdevs_val_msum_pdevs (*‹degree ?f ≤ ?n ⟹ pdevs_val ?e (msum_pdevs ?n ?f ?g) = pdevs_val ?e ?f + pdevs_val (λi. ?e (i + ?n)) ?g›*)) (*goal: ‹⋀n. n < length X ⟹ pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) + e' (d + n) * tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (X ! n)) = pdevs_val e' (msum_pdevs (d + n) (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) (pdevs_of_ivl (- tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (X ! n))) (tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (X ! n)))))›*) using d (*‹degrees X ≤ d›*) apply (auto intro!: degree_filter_pdevs_le[THEN order_trans] (*‹degree (?x1::?'a1 pdevs) ≤ (?z::nat) ⟹ degree (filter_pdevs (?I1::nat ⇒ ?'a1 ⇒ bool) ?x1) ≤ ?z›*)) (*top goal: ‹⋀n. n < length X ⟹ degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d + n› and 1 goal remains*) subgoal for by (auto dest!: degrees_leD (*‹⟦degrees ?X ≤ ?K; ?x ∈ set ?X⟧ ⟹ degree ?x ≤ ?K›*) nth_mem (*‹?n < length ?xs ⟹ ?xs ! ?n ∈ set ?xs›*)) apply (auto simp: pdevs_of_ivl_real (*‹pdevs_of_ivl (?a::real) (?b::real) = singleton_pdevs ((?b - ?a) / (2::real))›*) intro!:) (*goal: ‹⋀n. ⟦n < length X; degrees X ≤ d⟧ ⟹ pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) + e' (d + n) * tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (X ! n)) = pdevs_val e' (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) + pdevs_val (λi. e' (i + (d + n))) (pdevs_of_ivl (- tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (X ! n))) (tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (X ! n))))›*) subgoalpremises prems for proof (-) (*goal: ‹pdevs_val e (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_)) = pdevs_val e' (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_))›*) have "degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d" if "n < length X" for n using d (*‹degrees (X::real pdevs list) ≤ (d::nat)›*) that (*‹(n::nat) < length (X::real pdevs list)›*) apply (intro degree_filter_pdevs_le[THEN order_trans] (*‹degree ?x1 ≤ ?z ⟹ degree (filter_pdevs ?I1 ?x1) ≤ ?z›*)) (*goal: ‹degree (filter_pdevs (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys (X::real pdevs list) i)) (X ! (n::nat))) ≤ (d::nat)›*) by (simp add: degrees_leD (*‹⟦degrees (?X::?'a::real_vector pdevs list) ≤ (?K::nat); (?x::?'a::real_vector pdevs) ∈ set ?X⟧ ⟹ degree ?x ≤ ?K›*)) then show "?thesis" (*goal: ‹pdevs_val (e::nat ⇒ real) (filter_pdevs (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys (X::real pdevs list) i)) (X ! (n_::nat))) = pdevs_val (e'::nat ⇒ real) (filter_pdevs (λ(i::nat) x::real. I i (pdevs_applys X i)) (X ! n_))›*) using prems (*‹n_ < length X› ‹degrees X ≤ d›*) e'' (*‹?d'2 ∈ {d..<d + length X} ⟹ e'' ?d'2 ∈ {- 1..1}› ‹?d'2 ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (?d'2 - d)))) = e'' ?d'2 * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (?d'2 - d))))›*) apply (intro pdevs_val_degree_cong (*‹⟦?b = ?d; ⋀i. i < degree ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*)) (*goals: 1. ‹⟦⋀n. n < length X ⟹ degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d; n_ < length X; degrees X ≤ d; ⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))⟧ ⟹ filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_) = filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_)› 2. ‹⋀i. ⟦⋀n. n < length X ⟹ degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d; n_ < length X; degrees X ≤ d; ⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))); i < degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_))⟧ ⟹ e i = e' i› discuss goal 1*) apply ((auto dest!:)[1]) (*discuss goal 2*) apply ((auto dest!:)[1]) (*goal: ‹⋀i. ⟦⋀n. n < length X ⟹ degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d; n_ < length X; degrees X ≤ d; ⋀d'. d' ∈ {d..<d + length X} ⟹ e'' d' ∈ {- 1..1}; ⋀d'. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))); i < degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_))⟧ ⟹ e i = e' i›*) apply (auto simp: e'_def (*‹e' ≡ λi. if i < d then e i else if i < d + length X then e'' i else 0›*)) (*goals: 1. ‹⋀i. ⟦⋀n. n < length X ⟹ degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d; n_ < length X; degrees X ≤ d; ⋀d'. d ≤ d' ∧ d' < d + length X ⟹ - 1 ≤ e'' d' ∧ e'' d' ≤ 1; ⋀d'. d ≤ d' ∧ d' < d + length X ⟹ pdevs_val e (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (snd (zip [d..<d + length X] X ! (d' - d)))); i < degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_)); i < d + length X; ¬ i < d⟧ ⟹ e i = e'' i› 2. ‹⋀i. ⟦⋀n. n < length X ⟹ degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n)) ≤ d; n_ < length X; degrees X ≤ d; ⋀d'. d ≤ d' ∧ d' < d + length X ⟹ - 1 ≤ e'' d' ∧ e'' d' ≤ 1; ⋀d'. d ≤ d' ∧ d' < d + length X ⟹ pdevs_val e (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' p (filter_pdevs (λa b. ¬ I a (pdevs_applys X a)) (snd (zip [d..<d + length X] X ! (d' - d)))); i < degree (filter_pdevs (λi x. I i (pdevs_applys X i)) (X ! n_)); ¬ i < d + length X⟧ ⟹ e i = 0› discuss goal 1*) apply (meson ‹⋀n. ⟦n < length X; degrees X ≤ d⟧ ⟹ degree (X ! n) ≤ d + n› degree_filter_pdevs_le (*‹degree (filter_pdevs ?I ?x) ≤ degree ?x›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*)) (*discuss goal 2*) apply (meson less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) trans_less_add1 (*‹?i < ?j ⟹ ?i < ?j + ?m›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed . also (*calculation: ‹pdevs_vals (e::nat ⇒ real) (X::real pdevs list) = map2 (λ(d'::nat) x::real pdevs. pdevs_val (e'::nat ⇒ real) (summarize_pdevs (p::nat) (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys X i)) d' x)) [d::nat..<d + length X] X›*) have "… = pdevs_vals e' (summarize_pdevs_list p I d X)" by (auto simp: summarize_pdevs_list_def (*‹summarize_pdevs_list (?p::nat) (?I::nat ⇒ ?'a::executable_euclidean_space list ⇒ bool) (?d::nat) (?xs::?'a::executable_euclidean_space pdevs list) = map2 (summarize_pdevs ?p (λ(i::nat) _::?'a::executable_euclidean_space. ?I i (pdevs_applys ?xs i))) [?d..<?d + length ?xs] ?xs›*) pdevs_vals_def (*‹pdevs_vals (?e::nat ⇒ real) (?X::?'a::real_normed_vector pdevs list) = map (pdevs_val ?e) ?X›*)) finally (*calculation: ‹pdevs_vals (e::nat ⇒ real) (X::real pdevs list) = pdevs_vals (e'::nat ⇒ real) (summarize_pdevs_list (p::nat) (I::nat ⇒ real list ⇒ bool) (d::nat) X)›*) have "pdevs_vals e X = pdevs_vals e' (summarize_pdevs_list p I d X)" . moreover have "(⋀i. i < d ⟹ e i = e' i)" "e' ∈ UNIV → {- 1..1}" using ‹e ∈ _› (*‹e ∈ UNIV → {- 1..1}›*) e'' (*‹?d'2 ∈ {d..<d + length X} ⟹ e'' ?d'2 ∈ {- 1..1}› ‹?d'2 ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (?d'2 - d)))) = e'' ?d'2 * tdev' p (filter_pdevs (- (λi x. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (?d'2 - d))))›*) apply - (*goals: 1. ‹⋀i::nat. ⟦i < (d::nat); (e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}; ⋀d'::nat. d' ∈ {d..<d + length (X::real pdevs list)} ⟹ (e''::nat ⇒ real) d' ∈ {- (1::real)..1::real}; ⋀d'::nat. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' (p::nat) (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))⟧ ⟹ e i = (e'::nat ⇒ real) i› 2. ‹⟦(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}; ⋀d'::nat. d' ∈ {d::nat..<d + length (X::real pdevs list)} ⟹ (e''::nat ⇒ real) d' ∈ {- (1::real)..1::real}; ⋀d'::nat. d' ∈ {d..<d + length X} ⟹ pdevs_val e (filter_pdevs (- (λ(i::nat) x::real. (I::nat ⇒ real list ⇒ bool) i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d)))) = e'' d' * tdev' (p::nat) (filter_pdevs (- (λ(i::nat) x::real. I i (pdevs_applys X i))) (snd (zip [d..<d + length X] X ! (d' - d))))⟧ ⟹ (e'::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› discuss goal 1*) apply ((auto simp: e'_def (*‹e' ≡ λi. if i < d then e i else if i < d + length X then e'' i else 0›*))[1]) (*discuss goal 2*) apply ((auto simp: e'_def (*‹e' ≡ λi. if i < d then e i else if i < d + length X then e'' i else 0›*))[1]) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹thesis›*) by standard qed fun list_ex2 where "list_ex2 P [] xs = False" | "list_ex2 P xs [] = False" | "list_ex2 P (x#xs) (y#ys) = (P x y ∨ list_ex2 P xs ys)" lemma list_ex2_iff: "list_ex2 P xs ys ⟷ (¬list_all2 (-P) (take (length ys) xs) (take (length xs) ys))" apply (induction P xs ys rule: list_ex2.induct (*‹⟦⋀P xs. ?P P [] xs; ⋀P v va. ?P P (v # va) []; ⋀P x xs y ys. ?P P xs ys ⟹ ?P P (x # xs) (y # ys)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀P xs. list_ex2 P [] xs = (¬ list_all2 (- P) (take (length xs) []) (take (length []) xs))› 2. ‹⋀P v va. list_ex2 P (v # va) [] = (¬ list_all2 (- P) (take (length []) (v # va)) (take (length (v # va)) []))› 3. ‹⋀P x xs y ys. list_ex2 P xs ys = (¬ list_all2 (- P) (take (length ys) xs) (take (length xs) ys)) ⟹ list_ex2 P (x # xs) (y # ys) = (¬ list_all2 (- P) (take (length (y # ys)) (x # xs)) (take (length (x # xs)) (y # ys)))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . definition "summarize_aforms p C d (X::real aform list) = (zip (map fst X) (summarize_pdevs_list p (C X) d (map snd X)))" lemma aform_vals_pdevs_vals: "aform_vals e X = map (λ(x, y). x + y) (zip (map fst X) (pdevs_vals e (map snd X)))" sorry lemma summarize_aformsE: fixes X::"real aform list" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes d: "degree_aforms X ≤ d" obtains e' where "aform_vals e X = aform_vals e' (summarize_aforms p C d X)" "⋀i. i < d ⟹ e i = e' i" "e' ∈ UNIV → {-1 .. 1}" proof (-) (*goal: ‹(⋀e'. ⟦aform_vals e X = aform_vals e' (summarize_aforms p C d X); ⋀i. i < d ⟹ e i = e' i; e' ∈ UNIV → {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) define Xs where "Xs = map snd X" have "aform_vals e X = map (λ(x, y). x + y) (zip (map fst X) (pdevs_vals e Xs))" by (auto simp: aform_vals_pdevs_vals (*‹aform_vals ?e ?X = map2 (+) (map fst ?X) (pdevs_vals ?e (map snd ?X))›*) Xs_def (*‹Xs = map snd X›*)) also (*calculation: ‹aform_vals (e::nat ⇒ real) (X::(real × real pdevs) list) = map2 (+) (map fst X) (pdevs_vals e (Xs::real pdevs list))›*) obtain e' where e': "e' ∈ UNIV → {-1 .. 1}" "⋀i. i < d ⟹ e i = e' i" "pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs)" (*goal: ‹(⋀e'. ⟦e' ∈ UNIV → {- 1..1}; ⋀i. i < d ⟹ e i = e' i; pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs)⟧ ⟹ thesis) ⟹ thesis›*) using summarize_pdevs_listE[OF e d, of p "C X"] (*‹(⋀e'. ⟦pdevs_vals e (map snd X) = pdevs_vals e' (summarize_pdevs_list p (C X) d (map snd X)); ⋀i. i < d ⟹ e i = e' i; e' ∈ UNIV → {- 1..1}⟧ ⟹ ?thesis) ⟹ ?thesis›*) by (metis Xs_def (*‹Xs = map snd X›*)) note this(3) (*‹pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs)›*) also (*calculation: ‹aform_vals e X = map2 (+) (map fst X) (pdevs_vals e' (summarize_pdevs_list p (C X) d Xs))›*) have "map (λ(x, y). x + y) (zip (map fst X) …) = aform_vals e' (summarize_aforms p C d X)" unfolding aform_vals_pdevs_vals (*goal: ‹map2 (+) (map fst X) (pdevs_vals e' (summarize_pdevs_list p (C X) d Xs)) = map2 (+) (map fst (summarize_aforms p C d X)) (pdevs_vals e' (map snd (summarize_aforms p C d X)))›*) by (simp add: summarize_aforms_def (*‹summarize_aforms ?p ?C ?d ?X = zip (map fst ?X) (summarize_pdevs_list ?p (?C ?X) ?d (map snd ?X))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) Xs_def (*‹Xs = map snd X›*) summarize_pdevs_list_def (*‹summarize_pdevs_list ?p ?I ?d ?xs = map2 (summarize_pdevs ?p (λi _. ?I i (pdevs_applys ?xs i))) [?d..<?d + length ?xs] ?xs›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) finally (*calculation: ‹aform_vals e X = aform_vals e' (summarize_aforms p C d X)›*) have "aform_vals e X = aform_vals e' (summarize_aforms p C d X)" "⋀i. i < d ⟹ e i = e' i" "e' ∈ UNIV → {-1 .. 1}" using e' (*‹e' ∈ UNIV → {- 1..1}› ‹?i < d ⟹ e ?i = e' ?i› ‹pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs)›*) d (*‹degree_aforms X ≤ d›*) apply - (*goals: 1. ‹⟦aform_vals e X = aform_vals e' (summarize_aforms p C d X); e' ∈ UNIV → {- 1..1}; ⋀i. i < d ⟹ e i = e' i; pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs); degree_aforms X ≤ d⟧ ⟹ aform_vals e X = aform_vals e' (summarize_aforms p C d X)› 2. ‹⋀i. ⟦i < d; aform_vals e X = aform_vals e' (summarize_aforms p C d X); e' ∈ UNIV → {- 1..1}; ⋀i. i < d ⟹ e i = e' i; pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs); degree_aforms X ≤ d⟧ ⟹ e i = e' i› 3. ‹⟦aform_vals e X = aform_vals e' (summarize_aforms p C d X); e' ∈ UNIV → {- 1..1}; ⋀i. i < d ⟹ e i = e' i; pdevs_vals e Xs = pdevs_vals e' (summarize_pdevs_list p (C X) d Xs); degree_aforms X ≤ d⟧ ⟹ e' ∈ UNIV → {- 1..1}› discuss goal 1*) apply ((auto simp: Xs_def (*‹Xs = map snd X›*))[1]) (*discuss goal 2*) apply ((auto simp: Xs_def (*‹Xs = map snd X›*))[1]) (*discuss goal 3*) apply ((auto simp: Xs_def (*‹Xs = map snd X›*))[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹thesis›*) by standard qed text ‹Different reduction strategies:› definition "collect_threshold p ta t (X::real aform list) = (let Xs = map snd X; as = map (λX. max ta (t * tdev' p X)) Xs in (λ(i::nat) xs. list_ex2 (≤) as (map abs xs)))" definition "collect_girard p m (X::real aform list) = (let Xs = map snd X; M = pdevs_mapping Xs; D = domain_pdevs Xs; N = length X in if card D ≤ m then (λ_ _. True) else let Ds = sorted_list_of_set D; ortho_indices = map fst (take (2 * N) (sort_key (λ(i, r). r) (map (λi. let xs = M i in (i, sum_list' p xs - fold max xs 0)) Ds))); _ = () in (λi (xs::real list). i ∈ set ortho_indices))" subsection ‹Splitting with heuristics› definition "abs_pdevs = unop_pdevs abs" definition "abssum_of_pdevs_list X = fold (λa b. (add_pdevs (abs_pdevs a) b)) X zero_pdevs" definition "split_aforms xs i = (let splits = map (λx. split_aform x i) xs in (map fst splits, map snd splits))" definition "split_aforms_largest_uncond X = (let (i, x) = max_pdev (abssum_of_pdevs_list (map snd X)) in split_aforms X i)" definition "Inf_aform_err p Rd = (float_of (truncate_down p (Inf_aform' p (fst Rd) - abs(snd Rd))))" definition "Sup_aform_err p Rd = (float_of (truncate_up p (Sup_aform' p (fst Rd) + abs(snd Rd))))" context includes interval.lifting begin lift_definition ivl_of_aform_err::"nat ⇒ aform_err ⇒ float interval" is "λp Rd. (Inf_aform_err p Rd, Sup_aform_err p Rd)" by (auto simp: aform_err_def Inf_aform_err_def Sup_aform_err_def intro!: truncate_down_le truncate_up_le add_increasing[OF _ Inf_aform'_le_Sup_aform']) lemma lower_ivl_of_aform_err: "lower (ivl_of_aform_err p Rd) = Inf_aform_err p Rd" and upper_ivl_of_aform_err: "upper (ivl_of_aform_err p Rd) = Sup_aform_err p Rd" (*goals: 1. ‹lower (ivl_of_aform_err (p::nat) (Rd::(real × real pdevs) × real)) = Inf_aform_err p Rd› 2. ‹upper (ivl_of_aform_err (p::nat) (Rd::(real × real pdevs) × real)) = Sup_aform_err p Rd› discuss goal 1*) apply transfer (*top goal: ‹lower (ivl_of_aform_err p Rd) = Inf_aform_err p Rd› and 1 goal remains*) apply simp (*discuss goal 2*) apply transfer (*goal: ‹upper (ivl_of_aform_err (p::nat) (Rd::(real × real pdevs) × real)) = Sup_aform_err p Rd›*) apply simp (*proven 2 subgoals*) . end definition approx_un::"nat ⇒ (float interval ⇒ float interval option) ⇒ ((real × real pdevs) × real) option ⇒ ((real × real pdevs) × real) option" where "approx_un p f a = do { rd ← a; ivl ← f (ivl_of_aform_err p rd); Some (ivl_err (real_interval ivl)) }" definition interval_extension1::"(float interval ⇒ (float interval) option) ⇒ (real ⇒ real) ⇒ bool" where "interval_extension1 F f ⟷ (∀ivl ivl'. F ivl = Some ivl' ⟶ (∀x. x ∈⇩r ivl ⟶ f x ∈⇩r ivl'))" lemma interval_extension1D: assumes "interval_extension1 F f" assumes "F ivl = Some ivl'" assumes "x ∈⇩r ivl" shows "f x ∈⇩r ivl'" using assms (*‹interval_extension1 F f› ‹F ivl = Some ivl'› ‹x ∈⇩r ivl›*) by (auto simp: interval_extension1_def (*‹interval_extension1 (?F::float interval ⇒ float interval option) (?f::real ⇒ real) = (∀(ivl::float interval) ivl'::float interval. ?F ivl = Some ivl' ⟶ (∀x::real. x ∈⇩r ivl ⟶ ?f x ∈⇩r ivl'))›*)) lemma approx_un_argE: assumes au: "approx_un p F X = Some Y" obtains X' where "X = Some X'" using assms (*‹approx_un p F X = Some Y›*) by (auto simp: approx_un_def (*‹approx_un ?p ?f ?a = ?a ⤜ (λrd. ?f (ivl_of_aform_err ?p rd) ⤜ (λivl. Some (ivl_err (real_interval ivl))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) lemma degree_aform_independent_from: "degree_aform (independent_from d1 X) ≤ d1 + degree_aform X" by (auto simp: independent_from_def (*‹independent_from ?d ?Y = msum_aform ?d (0, zero_pdevs) ?Y›*) degree_msum_pdevs_le (*‹degree (msum_pdevs ?n ?f ?g) ≤ ?n + degree ?g›*)) lemma degree_aform_of_ivl: fixes a b::"'a::executable_euclidean_space" shows "degree_aform (aform_of_ivl a b) ≤ length (Basis_list::'a list)" by (auto simp: aform_of_ivl_def (*‹aform_of_ivl ?l ?u = ((?l + ?u) /⇩R 2, pdevs_of_ivl ?l ?u)›*) degree_pdevs_of_ivl_le (*‹degree (pdevs_of_ivl ?l ?u) ≤ DIM(?'a)›*)) lemma aform_err_ivl_err[simp]: "aform_err e (ivl_err ivl') = set_of ivl'" by (auto simp: aform_err_def (*‹aform_err (?e::nat ⇒ real) (?Xe::(real × real pdevs) × real) = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) ivl_err_def (*‹ivl_err (?ivl::real interval) ≡ (((upper ?ivl + lower ?ivl) / (2::real), zero_pdevs), (upper ?ivl - lower ?ivl) / (2::real))›*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a::real_normed_vector × ?'a::real_normed_vector pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*) divide_simps (*‹inverse (?a::?'a::division_ring) = (1::?'a::division_ring) / ?a› ‹(?a::?'a::division_ring) + (?b::?'a::division_ring) / (?z::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a::division_ring) / (?z::?'a::division_ring) + (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a::division_ring) / (?z::?'a::division_ring)) + (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a::division_ring) - (?b::?'a::division_ring) / (?z::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a::division_ring) / (?z::?'a::division_ring) - (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a::division_ring) / (?z::?'a::division_ring)) - (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a::division_ring) / (?c::?'a::division_ring) = (?a::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then ?b = ?a * ?c else ?a = (0::?'a::division_ring))› ‹((?a::?'a::division_ring) = (?b::?'a::division_ring) / (?c::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then ?a * ?c = ?b else ?a = (0::?'a::division_ring))› ‹(- ((?b::?'a::division_ring) / (?c::?'a::division_ring)) = (?a::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then - ?b = ?a * ?c else ?a = (0::?'a::division_ring))› ‹((?a::?'a::division_ring) = - ((?b::?'a::division_ring) / (?c::?'a::division_ring))) = (if ?c ≠ (0::?'a::division_ring) then ?a * ?c = - ?b else ?a = (0::?'a::division_ring))› ‹((?a::?'a::linordered_field) ≤ (?b::?'a::linordered_field) / (?c::?'a::linordered_field)) = (if (0::?'a::linordered_field) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a::linordered_field) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a::linordered_field))› and more 13 facts*) set_of_eq (*‹set_of (?x::?'a::preorder interval) = {lower ?x..upper ?x}›*)) lemma Inf_Sup_aform_err: fixes X assumes e: "e ∈ UNIV → {-1 .. 1}" defines "X' ≡ fst X" shows "aform_err e X ⊆ {Inf_aform_err p X .. Sup_aform_err p X}" using Inf_aform[OF e, of X'] (*‹Inf_aform X' ≤ aform_val e X'›*) Sup_aform[OF e, of X'] (*‹aform_val e X' ≤ Sup_aform X'›*) Inf_aform'[of p X'] (*‹Inf_aform' p X' ≤ Inf_aform X'›*) Sup_aform'[of X' p] (*‹Sup_aform X' ≤ Sup_aform' p X'›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) X'_def (*‹X' ≡ fst X›*) Inf_aform_err_def (*‹Inf_aform_err ?p ?Rd = float_of (truncate_down ?p (Inf_aform' ?p (fst ?Rd) - ¦snd ?Rd¦))›*) Sup_aform_err_def (*‹Sup_aform_err ?p ?Rd = float_of (truncate_up ?p (Sup_aform' ?p (fst ?Rd) + ¦snd ?Rd¦))›*) intro!: truncate_down_le (*‹?x ≤ ?y ⟹ truncate_down ?prec ?x ≤ ?y›*) truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*)) lemma ivl_of_aform_err: fixes X assumes e: "e ∈ UNIV → {-1 .. 1}" shows "x ∈ aform_err e X ⟹ x ∈⇩r ivl_of_aform_err p X" using Inf_Sup_aform_err[OF e, of X p] (*‹aform_err e X ⊆ {real_of_float (Inf_aform_err p X)..real_of_float (Sup_aform_err p X)}›*) by (auto simp: set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) lower_ivl_of_aform_err (*‹lower (ivl_of_aform_err ?p ?Rd) = Inf_aform_err ?p ?Rd›*) upper_ivl_of_aform_err (*‹upper (ivl_of_aform_err ?p ?Rd) = Sup_aform_err ?p ?Rd›*)) lemma approx_unE: assumes ie: "interval_extension1 F f" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes au: "approx_un p F X'err = Some Ye" assumes x: "case X'err of None ⇒ True | Some X'err ⇒ x ∈ aform_err e X'err" shows "f x ∈ aform_err e Ye" proof (-) (*goal: ‹f x ∈ aform_err e Ye›*) from au (*‹approx_un (p::nat) (F::float interval ⇒ float interval option) (X'err::((real × real pdevs) × real) option) = Some (Ye::(real × real pdevs) × real)›*) obtain ivl' and X' and err where F: "F (ivl_of_aform_err p (X', err)) = Some (ivl')" and Y: "Ye = ivl_err (real_interval ivl')" and X'err: "X'err = Some (X', err)" (*goal: ‹(⋀X' err ivl'. ⟦F (ivl_of_aform_err p (X', err)) = Some ivl'; Ye = ivl_err (real_interval ivl'); X'err = Some (X', err)⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: approx_un_def (*‹approx_un ?p ?f ?a = ?a ⤜ (λrd. ?f (ivl_of_aform_err ?p rd) ⤜ (λivl. Some (ivl_err (real_interval ivl))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) from x (*‹case X'err of None ⇒ True | Some X'err ⇒ x ∈ aform_err e X'err›*) have "x ∈ aform_err e (X', err)" by (auto simp: X'err (*‹X'err = Some (X', err)›*)) from ivl_of_aform_err[OF e this] (*‹x ∈⇩r ivl_of_aform_err ?p (X', err)›*) have "x ∈⇩r ivl_of_aform_err p (X', err)" . from interval_extension1D[OF ie F this] (*‹f x ∈⇩r ivl'›*) have "f x ∈⇩r ivl'" . also (*calculation: ‹f x ∈⇩r ivl'›*) have "… = aform_err e Ye" unfolding Y aform_err_ivl_err (*goal: ‹set_of (real_interval ivl') = set_of (real_interval ivl')›*) by standard finally (*calculation: ‹f x ∈ aform_err e Ye›*) show "?thesis" (*goal: ‹f x ∈ aform_err e Ye›*) . qed definition "approx_bin p f rd sd = do { ivl ← f (ivl_of_aform_err p rd) (ivl_of_aform_err p sd); Some (ivl_err (real_interval ivl)) }" definition interval_extension2::"(float interval ⇒ float interval ⇒ float interval option) ⇒ (real ⇒ real ⇒ real) ⇒ bool" where "interval_extension2 F f ⟷ (∀ivl1 ivl2 ivl. F ivl1 ivl2 = Some ivl ⟶ (∀x y. x ∈⇩r ivl1 ⟶ y ∈⇩r ivl2 ⟶ f x y ∈⇩r ivl))" lemma interval_extension2D: assumes "interval_extension2 F f" assumes "F ivl1 ivl2 = Some ivl" shows "x ∈⇩r ivl1 ⟹ y ∈⇩r ivl2 ⟹ f x y ∈⇩r ivl" using assms (*‹interval_extension2 F f› ‹(F::float interval ⇒ float interval ⇒ float interval option) (ivl1::float interval) (ivl2::float interval) = Some (ivl::float interval)›*) by (auto simp: interval_extension2_def (*‹interval_extension2 ?F ?f = (∀ivl1 ivl2 ivl. ?F ivl1 ivl2 = Some ivl ⟶ (∀x y. x ∈⇩r ivl1 ⟶ y ∈⇩r ivl2 ⟶ ?f x y ∈⇩r ivl))›*)) lemma approx_binE: assumes ie: "interval_extension2 F f" assumes w: "w ∈ aform_err e (W', errw)" assumes x: "x ∈ aform_err e (X', errx)" assumes ab: "approx_bin p F ((W', errw)) ((X', errx)) = Some Ye" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "f w x ∈ aform_err e Ye" proof (-) (*goal: ‹f w x ∈ aform_err e Ye›*) from ab (*‹approx_bin p F (W', errw) (X', errx) = Some Ye›*) obtain ivl' where F: "F (ivl_of_aform_err p (W', errw)) (ivl_of_aform_err p (X', errx)) = Some ivl'" and Y: "Ye = ivl_err (real_interval ivl')" (*goal: ‹(⋀ivl'. ⟦F (ivl_of_aform_err p (W', errw)) (ivl_of_aform_err p (X', errx)) = Some ivl'; Ye = ivl_err (real_interval ivl')⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: approx_bin_def (*‹approx_bin ?p ?f ?rd ?sd = ?f (ivl_of_aform_err ?p ?rd) (ivl_of_aform_err ?p ?sd) ⤜ (λivl. Some (ivl_err (real_interval ivl)))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) from interval_extension2D[OF ie F ivl_of_aform_err [ OF e , where p = p , OF w ] ivl_of_aform_err [ OF e , where p = p , OF x ]] (*‹(f::real ⇒ real ⇒ real) (w::real) (x::real) ∈⇩r (ivl'::float interval)›*) have "f w x ∈⇩r ivl'" . also (*calculation: ‹(f::real ⇒ real ⇒ real) (w::real) (x::real) ∈⇩r (ivl'::float interval)›*) have "… = aform_err e Ye" unfolding Y aform_err_ivl_err (*goal: ‹set_of (real_interval ivl') = set_of (real_interval ivl')›*) by standard finally (*calculation: ‹(f::real ⇒ real ⇒ real) (w::real) (x::real) ∈ aform_err (e::nat ⇒ real) (Ye::(real × real pdevs) × real)›*) show "?thesis" (*goal: ‹f w x ∈ aform_err e Ye›*) . qed definition "min_aform_err p a1 (a2::aform_err) = (let ivl1 = ivl_of_aform_err p a1; ivl2 = ivl_of_aform_err p a2 in if upper ivl1 < lower ivl2 then a1 else if upper ivl2 < lower ivl1 then a2 else ivl_err (real_interval (min_interval ivl1 ivl2)))" definition "max_aform_err p a1 (a2::aform_err) = (let ivl1 = ivl_of_aform_err p a1; ivl2 = ivl_of_aform_err p a2 in if upper ivl1 < lower ivl2 then a2 else if upper ivl2 < lower ivl1 then a1 else ivl_err (real_interval (max_interval ivl1 ivl2)))" subsection ‹Approximate Min Range - Kind Of Trigonometric Functions› definition affine_unop :: "nat ⇒ real ⇒ real ⇒ real ⇒ aform_err ⇒ aform_err" where "affine_unop p a b d X = (let ((x, xs), xe) = X; (ax, axe) = trunc_bound_eucl p (a * x); (y, ye) = trunc_bound_eucl p (ax + b); (ys, yse) = trunc_bound_pdevs p (scaleR_pdevs a xs) in ((y, ys), sum_list' p [truncate_up p (¦a¦ * xe), axe, ye, yse, d]))" ― ‹TODO: also do binop› lemma aform_err_leI: "y ∈ aform_err e (c, d)" if "y ∈ aform_err e (c, d')" "d' ≤ d" using that (*‹y ∈ aform_err e (c, d')› ‹(d'::real) ≤ (d::real)›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) lemma aform_err_eqI: "y ∈ aform_err e (c, d)" if "y ∈ aform_err e (c, d')" "d' = d" using that (*‹y ∈ aform_err e (c, d')› ‹d' = d›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) lemma sum_list'_append[simp]: "sum_list' p (ds@[d]) = truncate_up p (d + sum_list' p ds)" unfolding sum_list'_def (*goal: ‹fold (λa b. eucl_truncate_up p (a + b)) (ds @ [d]) 0 = truncate_up p (d + fold (λa b. eucl_truncate_up p (a + b)) ds 0)›*) by (simp add: eucl_truncate_up_real_def (*‹eucl_truncate_up ?prec ?b = truncate_up ?prec ?b›*)) lemma aform_err_sum_list': "y ∈ aform_err e (c, sum_list' p ds)" if "y ∈ aform_err e (c, sum_list ds)" using that(1) (*‹y ∈ aform_err e (c, sum_list ds)›*) apply (rule aform_err_leI (*‹⟦?y ∈ aform_err ?e (?c, ?d'); ?d' ≤ ?d⟧ ⟹ ?y ∈ aform_err ?e (?c, ?d)›*)) (*goal: ‹y ∈ aform_err e (c, sum_list' p ds)›*) by (rule sum_list_le_sum_list' (*‹sum_list ?xs ≤ sum_list' ?p ?xs›*)) lemma aform_err_trunc_bound_eucl: "y ∈ aform_err e ((fst (trunc_bound_eucl p X), xs), snd (trunc_bound_eucl p X) + d)" if y: "y ∈ aform_err e ((X, xs), d)" using that (*‹y ∈ aform_err e ((X, xs), d)›*) proof (-) (*goal: ‹y ∈ aform_err e ((X, xs), d) ⟹ y ∈ aform_err e ((fst (trunc_bound_eucl p X), xs), snd (trunc_bound_eucl p X) + d)›*) from aform_errE[OF y] (*‹¦(y::real) - aform_val (e::nat ⇒ real) (fst ((X::real, xs::real pdevs), d::real))¦ ≤ snd ((X, xs), d)›*) have "¦y - aform_val e (X, xs)¦ ≤ d" by auto then show "?thesis" (*goal: ‹y ∈ aform_err e ((fst (trunc_bound_eucl p X), xs), snd (trunc_bound_eucl p X) + d)›*) apply (intro aform_errI (*‹¦?x - aform_val ?e (fst ?Xe)¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) (*goal: ‹y ∈ aform_err e ((fst (trunc_bound_eucl p X), xs), snd (trunc_bound_eucl p X) + d)›*) apply (rule trunc_bound_euclE[of p X] (*‹(⋀err. ⟦¦err¦ ≤ snd (trunc_bound_eucl p X); fst (trunc_bound_eucl p X) = X + err⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹¦(y::real) - aform_val (e::nat ⇒ real) (X::real, xs::real pdevs)¦ ≤ (d::real) ⟹ ¦y - aform_val e (fst ((fst (trunc_bound_eucl (p::nat) X), xs), snd (trunc_bound_eucl p X) + d))¦ ≤ snd ((fst (trunc_bound_eucl p X), xs), snd (trunc_bound_eucl p X) + d)›*) by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) qed lemma trunc_err_pdevsE: assumes "e ∈ UNIV → {-1 .. 1}" obtains err where "¦err¦ ≤ tdev' p (trunc_err_pdevs p xs)" "pdevs_val e (trunc_pdevs p xs) = pdevs_val e xs + err" using trunc_bound_pdevsE[of e p xs] (*‹⟦e ∈ UNIV → {- 1..1}; ⋀err. ⟦¦err¦ ≤ snd (trunc_bound_pdevs p xs); pdevs_val e (fst (trunc_bound_pdevs p xs)) = pdevs_val e xs + err⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by (auto simp: trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) assms (*‹e ∈ UNIV → {- 1..1}›*)) lemma aform_err_trunc_bound_pdevsI: "y ∈ aform_err e ((c, fst (trunc_bound_pdevs p xs)), snd (trunc_bound_pdevs p xs) + d)" if y: "y ∈ aform_err e ((c, xs), d)" and e: "e ∈ UNIV → {-1 .. 1}" using that (*‹y ∈ aform_err e ((c, xs), d)› ‹e ∈ UNIV → {- 1..1}›*) proof (-) (*goal: ‹⟦y ∈ aform_err e ((c, xs), d); e ∈ UNIV → {- 1..1}⟧ ⟹ y ∈ aform_err e ((c, fst (trunc_bound_pdevs p xs)), snd (trunc_bound_pdevs p xs) + d)›*) define exs where "exs = trunc_err_pdevs p xs" from aform_errE[OF y] (*‹¦y - aform_val e (fst ((c, xs), d))¦ ≤ snd ((c, xs), d)›*) have "¦y - aform_val e (c, xs)¦ ≤ d" by auto then show "?thesis" (*goal: ‹y ∈ aform_err e ((c, fst (trunc_bound_pdevs p xs)), snd (trunc_bound_pdevs p xs) + d)›*) apply (intro aform_errI (*‹¦?x - aform_val ?e (fst ?Xe)¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) (*goal: ‹y ∈ aform_err e ((c, fst (trunc_bound_pdevs p xs)), snd (trunc_bound_pdevs p xs) + d)›*) apply (rule trunc_err_pdevsE[OF e, of p xs] (*‹(⋀err. ⟦¦err¦ ≤ tdev' p (trunc_err_pdevs p xs); pdevs_val e (trunc_pdevs p xs) = pdevs_val e xs + err⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹¦(y::real) - aform_val (e::nat ⇒ real) (c::real, xs::real pdevs)¦ ≤ (d::real) ⟹ ¦y - aform_val e (fst ((c, fst (trunc_bound_pdevs (p::nat) xs)), snd (trunc_bound_pdevs p xs) + d))¦ ≤ snd ((c, fst (trunc_bound_pdevs p xs)), snd (trunc_bound_pdevs p xs) + d)›*) by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*)) qed lemma aform_err_addI: "y ∈ aform_err e ((a + b, xs), d)" if "y - b ∈ aform_err e ((a, xs), d)" using that (*‹(y::real) - (b::real) ∈ aform_err (e::nat ⇒ real) ((a::real, xs::real pdevs), d::real)›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) theorem affine_unop: assumes x: "x ∈ aform_err e X" assumes f: "¦f x - (a * x + b)¦ ≤ d" and e: "e ∈ UNIV → {-1 .. 1}" shows "f x ∈ aform_err e (affine_unop p a b d X)" proof (-) (*goal: ‹(f::real ⇒ real) (x::real) ∈ aform_err (e::nat ⇒ real) (affine_unop (p::nat) (a::real) (b::real) (d::real) (X::(real × real pdevs) × real))›*) show "?thesis" (*goal: ‹f x ∈ aform_err e (affine_unop p a b d X)›*) unfolding affine_unop_def Let_def (*goal: ‹f x ∈ aform_err e (case X of (x, xa) ⇒ (case x of (x, xs) ⇒ λxe. case trunc_bound_eucl p (a * x) of (ax, axe) ⇒ case trunc_bound_eucl p (ax + b) of (y, ye) ⇒ case trunc_bound_pdevs p (scaleR_pdevs a xs) of (ys, yse) ⇒ ((y, ys), sum_list' p [truncate_up p (¦a¦ * xe), axe, ye, yse, d])) xa)›*) apply (auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) (*goal: ‹(f::real ⇒ real) (x::real) ∈ aform_err (e::nat ⇒ real) (case X::(real × real pdevs) × real of (x::real × real pdevs, xa::real) ⇒ (case x of (x::real, xs::real pdevs) ⇒ λxe::real. case trunc_bound_eucl (p::nat) ((a::real) * x) of (ax::real, axe::real) ⇒ case trunc_bound_eucl p (ax + (b::real)) of (y::real, ye::real) ⇒ case trunc_bound_pdevs p (scaleR_pdevs a xs) of (ys::real pdevs, yse::real) ⇒ ((y, ys), sum_list' p [truncate_up p (¦a¦ * xe), axe, ye, yse, d::real])) xa)›*) apply (rule aform_err_sum_list' (*‹?y ∈ aform_err ?e (?c, sum_list ?ds) ⟹ ?y ∈ aform_err ?e (?c, sum_list' ?p ?ds)›*)) (*goal: ‹f x ∈ aform_err e ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)), fst (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X))))), sum_list' p [truncate_up p (¦a¦ * snd X), snd (trunc_bound_eucl p (a * fst (fst X))), snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)), snd (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X)))), d])›*) apply simp (*goal: ‹f x ∈ aform_err e ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)), fst (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X))))), sum_list [truncate_up p (¦a¦ * snd X), snd (trunc_bound_eucl p (a * fst (fst X))), snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)), snd (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X)))), d])›*) apply (rule aform_err_eqI (*‹⟦?y ∈ aform_err ?e (?c, ?d'); ?d' = ?d⟧ ⟹ ?y ∈ aform_err ?e (?c, ?d)›*)) (*goal: ‹f x ∈ aform_err e ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)), fst (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X))))), truncate_up p (¦a¦ * snd X) + (snd (trunc_bound_eucl p (a * fst (fst X))) + (snd (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)) + (snd (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X)))) + d))))›*) apply (rule aform_err_trunc_bound_eucl (*‹?y ∈ aform_err ?e ((?X, ?xs), ?d) ⟹ ?y ∈ aform_err ?e ((fst (trunc_bound_eucl ?p ?X), ?xs), snd (trunc_bound_eucl ?p ?X) + ?d)›*)) (*top goal: ‹f x ∈ aform_err e ((fst (trunc_bound_eucl p (fst (trunc_bound_eucl p (a * fst (fst X))) + b)), fst (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X))))), ?d'2)› and 1 goal remains*) apply (rule aform_err_addI (*‹?y - ?b ∈ aform_err ?e ((?a, ?xs), ?d) ⟹ ?y ∈ aform_err ?e ((?a + ?b, ?xs), ?d)›*)) (*top goal: ‹(f::real ⇒ real) (x::real) ∈ aform_err (e::nat ⇒ real) ((fst (trunc_bound_eucl (p::nat) ((a::real) * fst (fst (X::(real × real pdevs) × real)))) + (b::real), fst (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X))))), ?d5::real)› and 1 goal remains*) apply (rule aform_err_trunc_bound_eucl (*‹?y ∈ aform_err ?e ((?X, ?xs), ?d) ⟹ ?y ∈ aform_err ?e ((fst (trunc_bound_eucl ?p ?X), ?xs), snd (trunc_bound_eucl ?p ?X) + ?d)›*)) (*top goal: ‹f x - b ∈ aform_err e ((fst (trunc_bound_eucl p (a * fst (fst X))), fst (trunc_bound_pdevs p (scaleR_pdevs a (snd (fst X))))), ?d5)› and 1 goal remains*) apply (rule aform_err_trunc_bound_pdevsI (*‹⟦?y ∈ aform_err ?e ((?c, ?xs), ?d); ?e ∈ UNIV → {- 1..1}⟧ ⟹ ?y ∈ aform_err ?e ((?c, fst (trunc_bound_pdevs ?p ?xs)), snd (trunc_bound_pdevs ?p ?xs) + ?d)›*)) (*top goal: ‹(f::real ⇒ real) (x::real) - (b::real) ∈ aform_err (e::nat ⇒ real) (((a::real) * fst (fst (X::(real × real pdevs) × real)), fst (trunc_bound_pdevs (p::nat) (scaleR_pdevs a (snd (fst X))))), ?d9::real)› and 1 goal remains*) using e (*‹e ∈ UNIV → {- 1..1}›*) apply auto (*top goal: ‹(f::real ⇒ real) (x::real) - (b::real) ∈ aform_err (e::nat ⇒ real) (((a::real) * fst (fst (X::(real × real pdevs) × real)), scaleR_pdevs a (snd (fst X))), ?d11::real)› and 2 goals remain*) apply (rule aform_errI (*‹¦?x - aform_val ?e (fst ?Xe)¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) (*goal: ‹(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real} ⟹ (f::real ⇒ real) (x::real) - (b::real) ∈ aform_err e (((a::real) * fst (fst (X::(real × real pdevs) × real)), scaleR_pdevs a (snd (fst X))), truncate_up (p::nat) (¦a¦ * snd X) + (d::real))›*) proof (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) (*goal: ‹e ∈ UNIV → {- 1..1} ⟹ ¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ ≤ truncate_up p (¦a¦ * snd X) + d›*) define x' where "x' = (fst (fst X) + pdevs_val e (snd (fst X)))" have x_x': "¦x - x'¦ ≤ snd X" using aform_errE[OF x] (*‹¦(x::real) - aform_val (e::nat ⇒ real) (fst (X::(real × real pdevs) × real))¦ ≤ snd X›*) by (auto simp: x'_def (*‹x' = fst (fst X) + pdevs_val e (snd (fst X))›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) have "¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ = ¦f x - (a * x + b) + a * (x - x')¦" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) x'_def (*‹x' = fst (fst X) + pdevs_val e (snd (fst X))›*)) also (*calculation: ‹¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ = ¦f x - (a * x + b) + a * (x - x')¦›*) have "… ≤ ¦f x - (a * x + b)¦ + ¦a * (x - x')¦" by (rule abs_triangle_ineq (*‹¦?a + ?b¦ ≤ ¦?a¦ + ¦?b¦›*)) also (*calculation: ‹¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ ≤ ¦f x - (a * x + b)¦ + ¦a * (x - x')¦›*) note f (*‹¦f x - (a * x + b)¦ ≤ d›*) also (*calculation: ‹(⋀xa y. xa ≤ y ⟹ xa + ¦a * (x - x')¦ ≤ y + ¦a * (x - x')¦) ⟹ ¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ ≤ d + ¦a * (x - x')¦›*) have "¦a * (x - x')¦ ≤ truncate_up p (¦a¦ * snd X)" apply (rule truncate_up_le (*‹(?x::real) ≤ (?y::real) ⟹ ?x ≤ truncate_up (?prec::nat) ?y›*)) (*goal: ‹¦a * (x - x')¦ ≤ truncate_up p (¦a¦ * snd X)›*) by (auto simp: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) intro!: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) x_x' (*‹¦x - x'¦ ≤ snd X›*)) finally (*calculation: ‹⟦⋀xa y. xa ≤ y ⟹ xa + ¦a * (x - x')¦ ≤ y + ¦a * (x - x')¦; ⋀x y. x ≤ y ⟹ d + x ≤ d + y⟧ ⟹ ¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ ≤ d + truncate_up p (¦a¦ * snd X)›*) show "¦f x - b - (a * fst (fst X) + a * pdevs_val e (snd (fst X)))¦ ≤ truncate_up p (¦a¦ * snd X) + d" by auto qed qed lemma min_range_coeffs_ge: "¦f x - (a * x + b)¦ ≤ d" if l: "l ≤ x" and u: "x ≤ u" and f': "⋀y. y ∈ {l .. u} ⟹ (f has_real_derivative f' y) (at y)" and a: "⋀y. y ∈ {l..u} ⟹ a ≤ f' y" and d: "d ≥ (f u - f l - a * (u - l)) / 2 + ¦(f l + f u - a * (l + u)) / 2 - b¦" for a b d::real proof (rule order_trans[OF _ d]) note f'_at = has_field_derivative_at_within[OF f'] from l u have lu: "x ∈ {l .. u}" and llu: "l ∈ {l .. u}" by simp_all define m where "m = (f l + f u - a * (l + u)) / 2" have "¦f x - (a * x + b)¦ = ¦f x - (a * x + m) + (m - b)¦" by (simp add: algebra_simps) also have "… ≤ ¦f x - (a * x + m)¦ + ¦m - b¦" by (rule abs_triangle_ineq) also have "¦f x - (a * x + m)¦ ≤ (f u - f l - a * (u - l)) / 2" proof (rule abs_leI) have "f x ≥ f l + a * (x - l)" (is "?l ≥ ?r") apply (rule order_trans) prefer 2 apply (rule linear_lower2[OF f'_at, of l u a]) subgoal by assumption subgoal by (rule a) subgoal using lu by (auto intro!: mult_right_mono) subgoal using lu by auto done also have "a * x + m - (f u - f l - a * (u - l)) / 2 ≤ ?r" by (simp add: algebra_simps m_def field_simps) finally (xtrans) show "- (f x - (a * x + m)) ≤ (f u - f l - a * (u - l)) / 2" by (simp add: algebra_simps m_def divide_simps) next have "f x ≤ f u + a * (x - u)" apply (rule order_trans) apply (rule linear_upper2[OF f'_at, of l u a]) subgoal by assumption subgoal by (rule a) subgoal using lu by (auto intro!: mult_right_mono) subgoal using lu by auto done also have "… ≤ a * x + m + (f u - f l - a * (u - l)) / 2" by (simp add: m_def divide_simps algebra_simps) finally show "f x - (a * x + m) ≤ (f u - f l - a * (u - l)) / 2" by (simp add: algebra_simps m_def divide_simps) qed also have "¦m - b¦ = abs ((f l + f u - a * (l + u)) / 2 - b)" unfolding m_def .. finally show "¦f x - (a * x + b)¦ ≤ (f u - f l - a * (u - l)) / 2 + ¦(f l + f u - a * (l + u)) / 2 - b¦" by (simp) qed lemma min_range_coeffs_le: "¦f x - (a * x + b)¦ ≤ d" if l: "l ≤ x" and u: "x ≤ u" and f': "⋀y. y ∈ {l .. u} ⟹ (f has_real_derivative f' y) (at y)" and a: "⋀y. y ∈ {l .. u} ⟹ f' y ≤ a" and d: "d ≥ (f l - f u + a * (u - l)) / 2 + ¦(f l + f u - a * (l + u)) / 2 - b¦" for a b d::real proof (rule order_trans[OF _ d]) note f'_at = has_field_derivative_at_within[OF f'] from l u have lu: "x ∈ {l .. u}" and llu: "l ∈ {l .. u}" by simp_all define m where "m = (f l + f u - a * (l + u)) / 2" have "¦f x - (a * x + b)¦ = ¦f x - (a * x + m) + (m - b)¦" by (simp add: algebra_simps) also have "… ≤ ¦f x - (a * x + m)¦ + ¦m - b¦" by (rule abs_triangle_ineq) also have "¦f x - (a * x + m)¦ ≤ (f l - f u + a * (u - l)) / 2" proof (rule abs_leI) have "f x ≥ f u + a * (x - u)" (is "?l ≥ ?r") apply (rule order_trans) prefer 2 apply (rule linear_lower[OF f'_at, of l u a]) subgoal by assumption subgoal by (rule a) subgoal using lu by (auto intro!: mult_right_mono) subgoal using lu by auto done also have "a * x + m - (f l - f u + a * (u - l)) / 2 ≤ ?r" using lu by (auto simp add: algebra_simps m_def field_simps intro!: mult_left_mono_neg) finally (xtrans) show "- (f x - (a * x + m)) ≤ (f l - f u + a * (u - l)) / 2" by (simp add: algebra_simps m_def divide_simps) next have "f x ≤ f l + a * (x - l)" apply (rule order_trans) apply (rule linear_upper[OF f'_at, of l u a]) subgoal by assumption subgoal by (rule a) subgoal using lu by (auto intro!: mult_right_mono) subgoal using lu by auto done also have "… ≤ a * x + m + (f l - f u + a * (u - l)) / 2" using lu by (auto simp add: algebra_simps m_def field_simps intro!: mult_left_mono_neg) finally show "f x - (a * x + m) ≤ (f l - f u + a * (u - l)) / 2" by (simp add: algebra_simps m_def divide_simps) qed also have "¦m - b¦ = abs ((f l + f u - a * (l + u)) / 2 - b)" unfolding m_def .. finally show "¦f x - (a * x + b)¦ ≤ (f l - f u + a * (u - l)) / 2 + ¦(f l + f u - a * (l + u)) / 2 - b¦" by (simp) qed context includes floatarith_notation begin definition "range_reducer p l = (if l < 0 ∨ l > 2 * lb_pi p then approx p (Pi * (Num (-2)) * (Floor (Num (l * Float 1 (-1)) / Pi))) [] else Some 0)" lemmas approx_emptyD = approx[OF bounded_by_None[of Nil], simplified] lemma range_reducerE: assumes "range_reducer p l = Some ivl" obtains n::int where "n * (2 * pi) ∈⇩r ivl" proof (cases "l ≥ 0 ∧ l ≤ 2 * lb_pi p") (*goals: 1. ‹⟦⋀n. real_of_int n * (2 * pi) ∈⇩r ivl ⟹ thesis; 0 ≤ l ∧ l ≤ 2 * lb_pi p⟧ ⟹ thesis› 2. ‹⟦⋀n. real_of_int n * (2 * pi) ∈⇩r ivl ⟹ thesis; ¬ (0 ≤ l ∧ l ≤ 2 * lb_pi p)⟧ ⟹ thesis›*) case False (*‹¬ (0 ≤ l ∧ l ≤ 2 * lb_pi p)›*) with assms (*‹range_reducer p l = Some ivl›*) have "- ⌊l / (2 * pi)⌋ * (2 * pi) ∈⇩r ivl" by (auto simp: range_reducer_def (*‹range_reducer ?p ?l = (if ?l < 0 ∨ 2 * lb_pi ?p < ?l then approx ?p (Pi * Num (- 2) * Floor (Num (?l * Float 1 (- 1)) / Pi)) [] else Some 0)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) inverse_eq_divide (*‹inverse ?a = 1 / ?a›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) dest!: approx_emptyD (*‹approx ?prec ?arith [] = Some ?ivl ⟹ interpret_floatarith ?arith [] ∈⇩r ?ivl›*)) then show "?thesis" (*goal: ‹thesis›*) by standard next (*goal: ‹⟦⋀n. real_of_int n * (2 * pi) ∈⇩r ivl ⟹ thesis; 0 ≤ l ∧ l ≤ 2 * lb_pi p⟧ ⟹ thesis›*) case True (*‹0 ≤ l ∧ l ≤ 2 * lb_pi p›*) then have "real_of_int 0 * (2 * pi) ∈⇩r ivl" using assms (*‹range_reducer p l = Some ivl›*) by (auto simp: range_reducer_def (*‹range_reducer (?p::nat) (?l::float) = (if ?l < (0::float) ∨ (2::float) * lb_pi ?p < ?l then approx ?p (Pi * Num (- (2::float)) * Floor (Num (?l * Float (1::int) (- (1::int))) / Pi)) [] else Some (0::float interval))›*) zero_in_float_intervalI (*‹(0::real) ∈⇩r (0::float interval)›*)) then show "?thesis" (*goal: ‹thesis›*) by standard qed definition "range_reduce_aform_err p X = do { r ← range_reducer p (lower (ivl_of_aform_err p X)); Some (add_aform' p X (ivl_err (real_interval r))) }" lemma range_reduce_aform_errE: assumes e: "e ∈ UNIV → {-1 .. 1}" assumes x: "x ∈ aform_err e X" assumes "range_reduce_aform_err p X = Some Y" obtains n::int where "x + n * (2 * pi) ∈ aform_err e Y" proof (-) (*goal: ‹(⋀n::int. (x::real) + real_of_int n * ((2::real) * pi) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real) ⟹ thesis::bool) ⟹ thesis›*) from assms (*‹e ∈ UNIV → {- 1..1}› ‹x ∈ aform_err e X› ‹range_reduce_aform_err (p::nat) (X::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)›*) obtain r where x: "x ∈ aform_err e X" and r: "range_reducer p (lower (ivl_of_aform_err p X)) = Some r" and Y: "Y = add_aform' p X (ivl_err (real_interval r))" (*goal: ‹(⋀r::float interval. ⟦(x::real) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real); range_reducer (p::nat) (lower (ivl_of_aform_err p X)) = Some r; (Y::(real × real pdevs) × real) = add_aform' p X (ivl_err (real_interval r))⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: range_reduce_aform_err_def (*‹range_reduce_aform_err ?p ?X = range_reducer ?p (lower (ivl_of_aform_err ?p ?X)) ⤜ (λr. Some (add_aform' ?p ?X (ivl_err (real_interval r))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) from range_reducerE[OF r] (*‹(⋀n. real_of_int n * (2 * pi) ∈⇩r r ⟹ ?thesis) ⟹ ?thesis›*) obtain n :: int where "n * (2 * pi) ∈⇩r r" (*goal: ‹(⋀n. real_of_int n * (2 * pi) ∈⇩r r ⟹ thesis) ⟹ thesis›*) by auto then have "n * (2 * pi) ∈ aform_err e (ivl_err (real_interval r))" by (auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 49 facts*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) intro!: aform_errI (*‹¦?x - aform_val ?e (fst ?Xe)¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) from add_aform'[OF e x this, of p] (*‹(x::real) + real_of_int (n::int) * ((2::real) * pi) ∈ aform_err (e::nat ⇒ real) (add_aform' (p::nat) (X::(real × real pdevs) × real) (ivl_err (real_interval (r::float interval))))›*) have "x + n * (2 * pi) ∈ aform_err e Y" by (auto simp: Y (*‹Y = add_aform' p X (ivl_err (real_interval r))›*)) then show "?thesis" (*goal: ‹thesis›*) by standard qed definition "min_range_mono p F DF l u X = do { let L = Num l; let U = Num u; aivl ← approx p (Min (DF L) (DF U)) []; let a = lower aivl; let A = Num a; bivl ← approx p (Half (F L + F U - A * (L + U))) []; let (b, be) = mid_err bivl; let (B, Be) = (Num (float_of b), Num (float_of be)); divl ← approx p ((Half (F U - F L - A * (U - L))) + Be) []; Some (affine_unop p a b (real_of_float (upper divl)) X) }" lemma min_range_mono: assumes x: "x ∈ aform_err e X" assumes "l ≤ x" "x ≤ u" assumes "min_range_mono p F DF l u X = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes F: "⋀x. x ∈ {real_of_float l .. u} ⟹ interpret_floatarith (F (Num x)) [] = f x" assumes DF: "⋀x. x ∈ {real_of_float l .. u} ⟹ interpret_floatarith (DF (Num x)) [] = f' x" assumes f': "⋀x. x ∈ {real_of_float l .. u} ⟹ (f has_real_derivative f' x) (at x)" assumes f'_le: "⋀x. x ∈ {real_of_float l .. u} ⟹ min (f' l) (f' u) ≤ f' x" shows "f x ∈ aform_err e Y" proof (-) (*goal: ‹(f::real ⇒ real) (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) from assms (*‹(x::real) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)› ‹real_of_float (l::float) ≤ (x::real)› ‹x ≤ real_of_float u› ‹min_range_mono (p::nat) (F::floatarith ⇒ floatarith) (DF::floatarith ⇒ floatarith) (l::float) (u::float) (X::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)› ‹e ∈ UNIV → {- 1..1}› ‹real_of_float (?x::float) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ interpret_floatarith ((F::floatarith ⇒ floatarith) (Num ?x)) [] = (f::real ⇒ real) (real_of_float ?x)› ‹real_of_float ?x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (DF (Num ?x)) [] = f' (real_of_float ?x)› ‹?x ∈ {real_of_float l..real_of_float u} ⟹ (f has_real_derivative f' ?x) (at ?x)› ‹?x ∈ {real_of_float l..real_of_float u} ⟹ min (f' (real_of_float l)) (f' (real_of_float u)) ≤ f' ?x›*) obtain a and b and be and bivl and divl where bivl: "(f l + f u - a * (l + u))/2 ∈⇩r bivl" and Y: "Y = affine_unop p a b (upper divl) X" and du: "(f u - f l - a * (u - l)) / 2 + be ∈⇩r divl" and a: "a ≤ f' l" "a ≤ f' u" and b_def: "b = (lower bivl + upper bivl) / 2" and be_def: "be = (upper bivl - lower bivl) / 2" (*goal: ‹(⋀a bivl b divl be. ⟦(f (real_of_float l) + f (real_of_float u) - real_of_float (a * (l + u))) / 2 ∈⇩r bivl; Y = affine_unop p (real_of_float a) b (real_of_float (upper divl)) X; (f (real_of_float u) - f (real_of_float l) - real_of_float (a * (u - l))) / 2 + be ∈⇩r divl; real_of_float a ≤ f' (real_of_float l); real_of_float a ≤ f' (real_of_float u); b = real_of_float (lower bivl + upper bivl) / 2; be = real_of_float (upper bivl - lower bivl) / 2⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: min_range_mono_def (*‹min_range_mono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Min (?DF L) (?DF U)) [] ⤜ (λaivl. let a = lower aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) simp del: eq_divide_eq_numeral1 (*‹(?a = ?b / numeral ?w) = (if numeral ?w ≠ 0 then ?a * numeral ?w = ?b else ?a = 0)› ‹(?a = ?b / - numeral ?w) = (if - numeral ?w ≠ 0 then ?a * - numeral ?w = ?b else ?a = 0)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) dest!: approx_emptyD (*‹approx ?prec ?arith [] = Some ?ivl ⟹ interpret_floatarith ?arith [] ∈⇩r ?ivl›*)) have diff_le: "real_of_float a ≤ f' y" if "real_of_float l ≤ y" "y ≤ u" for y using f'_le[of y] (*‹y ∈ {real_of_float l..real_of_float u} ⟹ min (f' (real_of_float l)) (f' (real_of_float u)) ≤ f' y›*) that (*‹real_of_float l ≤ y› ‹(y::real) ≤ real_of_float (u::float)›*) a (*‹real_of_float (a::float) ≤ (f'::real ⇒ real) (real_of_float (l::float))› ‹real_of_float a ≤ f' (real_of_float u)›*) by auto have le_be: "¦(f (l) + f (u) - a * (real_of_float l + u)) / 2 - b¦ ≤ be" using bivl (*‹(f (real_of_float l) + f (real_of_float u) - real_of_float (a * (l + u))) / 2 ∈⇩r bivl›*) unfolding b_def be_def (*goal: ‹¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - real_of_float (lower bivl + upper bivl) / 2¦ ≤ real_of_float (upper bivl - lower bivl) / 2›*) by (auto simp: abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*)) have "¦f x - (a * x + b)¦ ≤ upper divl" apply (rule min_range_coeffs_ge (*‹⟦(?l::real) ≤ (?x::real); ?x ≤ (?u::real); ⋀y::real. y ∈ {?l..?u} ⟹ ((?f::real ⇒ real) has_real_derivative (?f'::real ⇒ real) y) (at y); ⋀y::real. y ∈ {?l..?u} ⟹ (?a::real) ≤ ?f' y; (?f ?u - ?f ?l - ?a * (?u - ?l)) / (2::real) + ¦(?f ?l + ?f ?u - ?a * (?l + ?u)) / (2::real) - (?b::real)¦ ≤ (?d::real)⟧ ⟹ ¦?f ?x - (?a * ?x + ?b)¦ ≤ ?d›*)) (*goal: ‹¦f x - (real_of_float a * x + b)¦ ≤ real_of_float (upper divl)›*) apply (rule ‹l ≤ x›) (*top goal: ‹?l ≤ x› and 4 goals remain*) apply (rule ‹x ≤ u›) (*top goal: ‹x ≤ ?u› and 3 goals remain*) apply (rule f' (*‹(?x::real) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ ((f::real ⇒ real) has_real_derivative (f'::real ⇒ real) ?x) (at ?x)›*)) (*top goal: ‹⋀y. y ∈ {real_of_float l..real_of_float u} ⟹ (f has_real_derivative ?f' y) (at y)› and 2 goals remain*) apply assumption (*top goal: ‹⋀y. y ∈ {real_of_float l..real_of_float u} ⟹ y ∈ {real_of_float l..real_of_float u}› and 2 goals remain*) using diff_le (*‹⟦real_of_float l ≤ ?y; ?y ≤ real_of_float u⟧ ⟹ real_of_float a ≤ f' ?y›*) apply force (*top goal: ‹⋀y. y ∈ {real_of_float l..real_of_float u} ⟹ real_of_float a ≤ f' y› and 1 goal remains*) apply (rule order_trans[OF add_mono[OF order_refl]] (*‹⟦?c1 ≤ ?d1; ?a1 + ?d1 ≤ ?z⟧ ⟹ ?a1 + ?c1 ≤ ?z›*)) (*goal: ‹(f (real_of_float u) - f (real_of_float l) - real_of_float a * (real_of_float u - real_of_float l)) / 2 + ¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - b¦ ≤ real_of_float (upper divl)›*) apply (rule le_be (*‹¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - b¦ ≤ be›*)) (*top goal: ‹¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - b¦ ≤ ?d13› and 1 goal remains*) using bivl (*‹(f (real_of_float l) + f (real_of_float u) - real_of_float (a * (l + u))) / 2 ∈⇩r bivl›*) du (*‹((f::real ⇒ real) (real_of_float (u::float)) - f (real_of_float (l::float)) - real_of_float ((a::float) * (u - l))) / (2::real) + (be::real) ∈⇩r (divl::float interval)›*) unfolding b_def[symmetric] be_def[symmetric] (*goal: ‹((f::real ⇒ real) (real_of_float (u::float)) - f (real_of_float (l::float)) - real_of_float (a::float) * (real_of_float u - real_of_float l)) / (2::real) + (be::real) ≤ real_of_float (upper (divl::float interval))›*) by (auto simp: set_of_eq (*‹set_of (?x::?'a::preorder interval) = {lower ?x..upper ?x}›*)) from affine_unop[where f = f and p = p, OF ‹x ∈ _› this e] (*‹f x ∈ aform_err e (affine_unop p (real_of_float a) b (real_of_float (upper divl)) X)›*) have "f x ∈ aform_err e (affine_unop p (real_of_float a) b (upper divl) X)" by (auto simp: Y (*‹Y = affine_unop p (real_of_float a) b (real_of_float (upper divl)) X›*)) then show "?thesis" (*goal: ‹f x ∈ aform_err e Y›*) by (simp add: Y (*‹Y = affine_unop p (real_of_float a) b (real_of_float (upper divl)) X›*) b_def (*‹b = real_of_float (lower bivl + upper bivl) / 2›*)) qed definition "min_range_antimono p F DF l u X = do { let L = Num l; let U = Num u; aivl ← approx p (Max (DF L) (DF U)) []; let a = upper aivl; let A = Num a; bivl ← approx p (Half (F L + F U - A * (L + U))) []; let (b, be) = mid_err bivl; let (B, Be) = (Num (float_of b), Num (float_of be)); divl ← approx p (Add (Half (F L - F U + A * (U - L))) Be) []; Some (affine_unop p a b (real_of_float (upper divl)) X) }" lemma min_range_antimono: assumes x: "x ∈ aform_err e X" assumes "l ≤ x" "x ≤ u" assumes "min_range_antimono p F DF l u X = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes F: "⋀x. x ∈ {real_of_float l .. u} ⟹ interpret_floatarith (F (Num x)) [] = f x" assumes DF: "⋀x. x ∈ {real_of_float l .. u} ⟹ interpret_floatarith (DF (Num x)) [] = f' x" assumes f': "⋀x. x ∈ {real_of_float l .. u} ⟹ (f has_real_derivative f' x) (at x)" assumes f'_le: "⋀x. x ∈ {real_of_float l .. u} ⟹ f' x ≤ max (f' l) (f' u)" shows "f x ∈ aform_err e Y" proof (-) (*goal: ‹f x ∈ aform_err e Y›*) from assms (*‹x ∈ aform_err e X› ‹real_of_float l ≤ x› ‹x ≤ real_of_float u› ‹min_range_antimono (p::nat) (F::floatarith ⇒ floatarith) (DF::floatarith ⇒ floatarith) (l::float) (u::float) (X::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)› ‹(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› ‹real_of_float ?x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (F (Num ?x)) [] = f (real_of_float ?x)› ‹real_of_float (?x::float) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ interpret_floatarith ((DF::floatarith ⇒ floatarith) (Num ?x)) [] = (f'::real ⇒ real) (real_of_float ?x)› ‹(?x::real) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ ((f::real ⇒ real) has_real_derivative (f'::real ⇒ real) ?x) (at ?x)› ‹(?x::real) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ (f'::real ⇒ real) ?x ≤ max (f' (real_of_float l)) (f' (real_of_float u))›*) obtain a and b and be and aivl and bivl and divl where bivl: "(f l + f u - real_of_float a * (l + u)) / 2 ∈⇩r bivl" and Y: "Y = affine_unop p a b (real_of_float (upper divl)) X" and du: "(f l - f u + a * (u - l)) / 2 + be ∈⇩r divl" and a: "f' l ≤ a" "f' u ≤ a" and a_def: "a = upper aivl" and b_def: "b = (lower bivl + upper bivl) / 2" and be_def: "be = (upper bivl - lower bivl) / 2" (*goal: ‹(⋀a bivl b divl be aivl. ⟦(f (real_of_float l) + f (real_of_float u) - real_of_float a * real_of_float (l + u)) / 2 ∈⇩r bivl; Y = affine_unop p (real_of_float a) b (real_of_float (upper divl)) X; (f (real_of_float l) - f (real_of_float u) + real_of_float (a * (u - l))) / 2 + be ∈⇩r divl; f' (real_of_float l) ≤ real_of_float a; f' (real_of_float u) ≤ real_of_float a; a = upper aivl; b = real_of_float (lower bivl + upper bivl) / 2; be = real_of_float (upper bivl - lower bivl) / 2⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) simp del: eq_divide_eq_numeral1 (*‹(?a = ?b / numeral ?w) = (if numeral ?w ≠ 0 then ?a * numeral ?w = ?b else ?a = 0)› ‹(?a = ?b / - numeral ?w) = (if - numeral ?w ≠ 0 then ?a * - numeral ?w = ?b else ?a = 0)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) dest!: approx_emptyD (*‹approx ?prec ?arith [] = Some ?ivl ⟹ interpret_floatarith ?arith [] ∈⇩r ?ivl›*)) have diff_le: "f' y ≤ real_of_float a" if "real_of_float l ≤ y" "y ≤ u" for y using f'_le[of y] (*‹y ∈ {real_of_float l..real_of_float u} ⟹ f' y ≤ max (f' (real_of_float l)) (f' (real_of_float u))›*) that (*‹real_of_float (l::float) ≤ (y::real)› ‹y ≤ real_of_float u›*) a (*‹f' (real_of_float l) ≤ real_of_float a› ‹f' (real_of_float u) ≤ real_of_float a›*) by auto have le_be: "¦(f (l) + f (u) - a * (real_of_float l + u)) / 2 - b¦ ≤ be" using bivl (*‹((f::real ⇒ real) (real_of_float (l::float)) + f (real_of_float (u::float)) - real_of_float (a::float) * real_of_float (l + u)) / (2::real) ∈⇩r (bivl::float interval)›*) unfolding b_def be_def (*goal: ‹¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - real_of_float (lower bivl + upper bivl) / 2¦ ≤ real_of_float (upper bivl - lower bivl) / 2›*) by (auto simp: abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*)) have "¦f x - (a * x + b)¦ ≤ upper divl" apply (rule min_range_coeffs_le (*‹⟦(?l::real) ≤ (?x::real); ?x ≤ (?u::real); ⋀y::real. y ∈ {?l..?u} ⟹ ((?f::real ⇒ real) has_real_derivative (?f'::real ⇒ real) y) (at y); ⋀y::real. y ∈ {?l..?u} ⟹ ?f' y ≤ (?a::real); (?f ?l - ?f ?u + ?a * (?u - ?l)) / (2::real) + ¦(?f ?l + ?f ?u - ?a * (?l + ?u)) / (2::real) - (?b::real)¦ ≤ (?d::real)⟧ ⟹ ¦?f ?x - (?a * ?x + ?b)¦ ≤ ?d›*)) (*goal: ‹¦f x - (real_of_float a * x + b)¦ ≤ real_of_float (upper divl)›*) apply (rule ‹l ≤ x›) (*top goal: ‹?l ≤ x› and 4 goals remain*) apply (rule ‹x ≤ u›) (*top goal: ‹x ≤ ?u› and 3 goals remain*) apply (rule f' (*‹(?x::real) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ ((f::real ⇒ real) has_real_derivative (f'::real ⇒ real) ?x) (at ?x)›*)) (*top goal: ‹⋀y. y ∈ {real_of_float l..real_of_float u} ⟹ (f has_real_derivative ?f' y) (at y)› and 2 goals remain*) apply assumption (*top goal: ‹⋀y. y ∈ {real_of_float l..real_of_float u} ⟹ y ∈ {real_of_float l..real_of_float u}› and 2 goals remain*) using diff_le (*‹⟦real_of_float l ≤ ?y; ?y ≤ real_of_float u⟧ ⟹ f' ?y ≤ real_of_float a›*) apply force (*top goal: ‹⋀y::real. y ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ (f'::real ⇒ real) y ≤ real_of_float (a::float)› and 1 goal remains*) apply (rule order_trans[OF add_mono[OF order_refl]] (*‹⟦?c1 ≤ ?d1; ?a1 + ?d1 ≤ ?z⟧ ⟹ ?a1 + ?c1 ≤ ?z›*)) (*goal: ‹((f::real ⇒ real) (real_of_float (l::float)) - f (real_of_float (u::float)) + real_of_float (a::float) * (real_of_float u - real_of_float l)) / (2::real) + ¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / (2::real) - (b::real)¦ ≤ real_of_float (upper (divl::float interval))›*) apply (rule le_be (*‹¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - b¦ ≤ be›*)) (*top goal: ‹¦(f (real_of_float l) + f (real_of_float u) - real_of_float a * (real_of_float l + real_of_float u)) / 2 - b¦ ≤ ?d13› and 1 goal remains*) using du (*‹(f (real_of_float l) - f (real_of_float u) + real_of_float (a * (u - l))) / 2 + be ∈⇩r divl›*) bivl (*‹(f (real_of_float l) + f (real_of_float u) - real_of_float a * real_of_float (l + u)) / 2 ∈⇩r bivl›*) unfolding b_def[symmetric] be_def[symmetric] (*goal: ‹((f::real ⇒ real) (real_of_float (l::float)) - f (real_of_float (u::float)) + real_of_float (a::float) * (real_of_float u - real_of_float l)) / (2::real) + (be::real) ≤ real_of_float (upper (divl::float interval))›*) by (auto simp: set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*)) from affine_unop[where f = f and p = p, OF ‹x ∈ _› this e] (*‹(f::real ⇒ real) (x::real) ∈ aform_err (e::nat ⇒ real) (affine_unop (p::nat) (real_of_float (a::float)) (b::real) (real_of_float (upper (divl::float interval))) (X::(real × real pdevs) × real))›*) have "f x ∈ aform_err e (affine_unop p (real_of_float a) b (upper divl) X)" by (auto simp: Y (*‹(Y::(real × real pdevs) × real) = affine_unop (p::nat) (real_of_float (a::float)) (b::real) (real_of_float (upper (divl::float interval))) (X::(real × real pdevs) × real)›*)) then show "?thesis" (*goal: ‹f x ∈ aform_err e Y›*) by (simp add: Y (*‹Y = affine_unop p (real_of_float a) b (real_of_float (upper divl)) X›*) b_def (*‹b = real_of_float (lower bivl + upper bivl) / 2›*)) qed definition "cos_aform_err p X = do { X ← range_reduce_aform_err p X; let ivl = ivl_of_aform_err p X; let l = lower ivl; let u = upper ivl; let L = Num l; let U = Num u; if l ≥ 0 ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. (Minus (Sin x))) l u X else if l ≥ ub_pi p ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. (Minus (Sin x))) l u X else do { Some (ivl_err (real_interval (cos_float_interval p ivl))) } }" lemma abs_half_enclosure: fixes r::real assumes "bl ≤ r" "r ≤ bu" shows "¦r - (bl + bu) / 2¦ ≤ (bu - bl) / 2" using assms (*‹bl ≤ r› ‹r ≤ bu›*) by (auto simp: abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) lemma cos_aform_err: assumes x: "x ∈ aform_err e X0" assumes "cos_aform_err p X0 = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "cos x ∈ aform_err e Y" proof (-) (*goal: ‹cos x ∈ aform_err e Y›*) from assms (*‹x ∈ aform_err e X0› ‹cos_aform_err p X0 = Some Y› ‹e ∈ UNIV → {- 1..1}›*) obtain X and ivl and l and u where X: "range_reduce_aform_err p X0 = Some X" and ivl_def: "ivl = ivl_of_aform_err p X" and l_def: "l = lower ivl" and u_def: "u = upper ivl" (*goal: ‹(⋀X ivl l u. ⟦range_reduce_aform_err p X0 = Some X; ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: cos_aform_err_def (*‹cos_aform_err (?p::nat) (?X::(real × real pdevs) × real) = range_reduce_aform_err ?p ?X ⤜ (λX::(real × real pdevs) × real. let ivl::float interval = ivl_of_aform_err ?p X; l::float = lower ivl; u::float = upper ivl; L::floatarith = Num l; U::floatarith = Num u in if (0::float) ≤ l ∧ u ≤ lb_pi ?p then min_range_antimono ?p Cos (λx::floatarith. Minus (Sin x)) l u X else if ub_pi ?p ≤ l ∧ u ≤ (2::float) * lb_pi ?p then min_range_mono ?p Cos (λx::floatarith. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval ?p ivl))))›*) bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*)) from range_reduce_aform_errE[OF e x X] (*‹(⋀n. x + real_of_int n * (2 * pi) ∈ aform_err e X ⟹ ?thesis) ⟹ ?thesis›*) obtain n where xn: "x + real_of_int n * (2 * pi) ∈ aform_err e X" (*goal: ‹(⋀n. x + real_of_int n * (2 * pi) ∈ aform_err e X ⟹ thesis) ⟹ thesis›*) by auto define xn where "xn = x + n * (2 * pi)" with xn (*‹x + real_of_int n * (2 * pi) ∈ aform_err e X›*) have xn: "xn ∈ aform_err e X" by auto from ivl_of_aform_err[OF e xn, of p, folded ivl_def] (*‹xn ∈⇩r ivl›*) have "xn ∈⇩r ivl" . then have lxn: "l ≤ xn" and uxn: "xn ≤ u" apply - (*goals: 1. ‹(xn::real) ∈⇩r (ivl::float interval) ⟹ real_of_float (l::float) ≤ xn› 2. ‹(xn::real) ∈⇩r (ivl::float interval) ⟹ xn ≤ real_of_float (u::float)› discuss goal 1*) apply ((auto simp: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 2*) apply ((auto simp: l_def (*‹(l::float) = lower (ivl::float interval)›*) u_def (*‹(u::float) = upper (ivl::float interval)›*) set_of_eq (*‹set_of (?x::?'a interval) = {lower ?x..upper ?x}›*))[1]) (*proven 2 subgoals*) . consider "l ≥ 0" and "u ≤ lb_pi p" | "l < 0 ∨ u > lb_pi p" and "l ≥ ub_pi p" and "u ≤ 2 * lb_pi p" | "l < 0 ∨ u > lb_pi p" and "l < ub_pi p ∨ u > 2 * lb_pi p" (*goal: ‹⟦⟦0 ≤ l; u ≤ lb_pi p⟧ ⟹ thesis; ⟦l < 0 ∨ lb_pi p < u; ub_pi p ≤ l; u ≤ 2 * lb_pi p⟧ ⟹ thesis; ⟦l < 0 ∨ lb_pi p < u; l < ub_pi p ∨ 2 * lb_pi p < u⟧ ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?thesis" (*goal: ‹cos x ∈ aform_err e Y›*) proof (cases) (*goals: 1. ‹⟦0 ≤ l; u ≤ lb_pi p⟧ ⟹ cos x ∈ aform_err e Y› 2. ‹⟦l < 0 ∨ lb_pi p < u; ub_pi p ≤ l; u ≤ 2 * lb_pi p⟧ ⟹ cos x ∈ aform_err e Y› 3. ‹⟦l < 0 ∨ lb_pi p < u; l < ub_pi p ∨ 2 * lb_pi p < u⟧ ⟹ cos x ∈ aform_err e Y›*) case 1 (*‹0 ≤ l› ‹u ≤ lb_pi p›*) then have min_eq_Some: "min_range_antimono p Cos (λx. Minus (Sin x)) l u X = Some Y" and bounds: "0 ≤ l" "u ≤ (lb_pi p)" using assms(2) (*‹cos_aform_err (p::nat) (X0::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)›*) unfolding cos_aform_err_def X l_def u_def (*goals: 1. ‹min_range_antimono p Cos (λx. Minus (Sin x)) (lower ivl) (upper ivl) X = Some Y› 2. ‹0 ≤ lower ivl› 3. ‹upper ivl ≤ lb_pi p›*) apply - (*goals: 1. ‹⟦0 ≤ lower ivl; upper ivl ≤ lb_pi p; Some X ⤜ (λX. let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. Minus (Sin x)) l u X else if ub_pi p ≤ l ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval p ivl)))) = Some Y⟧ ⟹ min_range_antimono p Cos (λx. Minus (Sin x)) (lower ivl) (upper ivl) X = Some Y› 2. ‹⟦0 ≤ lower ivl; upper ivl ≤ lb_pi p; Some X ⤜ (λX. let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. Minus (Sin x)) l u X else if ub_pi p ≤ l ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval p ivl)))) = Some Y⟧ ⟹ 0 ≤ lower ivl› 3. ‹⟦0 ≤ lower ivl; upper ivl ≤ lb_pi p; Some X ⤜ (λX. let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. Minus (Sin x)) l u X else if ub_pi p ≤ l ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval p ivl)))) = Some Y⟧ ⟹ upper ivl ≤ lb_pi p› discuss goal 1*) apply ((auto simp: X (*‹range_reduce_aform_err p X0 = Some X›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: X (*‹range_reduce_aform_err p X0 = Some X›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 3*) apply ((auto simp: X (*‹range_reduce_aform_err p X0 = Some X›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 3 subgoals*) . have bounds: "0 ≤ l" "u ≤ pi" using bounds (*‹0 ≤ l› ‹u ≤ lb_pi p›*) pi_boundaries[of p] (*‹pi ∈ {real_of_float (lb_pi p)..real_of_float (ub_pi p)}›*) apply - (*goals: 1. ‹⟦0 ≤ l; u ≤ lb_pi p; pi ∈ {real_of_float (lb_pi p)..real_of_float (ub_pi p)}⟧ ⟹ 0 ≤ l› 2. ‹⟦0 ≤ l; u ≤ lb_pi p; pi ∈ {real_of_float (lb_pi p)..real_of_float (ub_pi p)}⟧ ⟹ real_of_float u ≤ pi› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have diff_le: "- sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))" if "real_of_float l ≤ y" "y ≤ real_of_float u" for y proof (-) (*goal: ‹- sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))›*) consider "y ≤ pi / 2" | "y ≥ pi / 2" (*goal: ‹⟦y ≤ pi / 2 ⟹ thesis; pi / 2 ≤ y ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?thesis" (*goal: ‹- sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))›*) proof (cases) (*goals: 1. ‹y ≤ pi / 2 ⟹ - sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))› 2. ‹pi / 2 ≤ y ⟹ - sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))›*) case 1 (*‹y ≤ pi / 2›*) then have "- sin y ≤ - sin l" using that (*‹real_of_float (l::float) ≤ (y::real)› ‹y ≤ real_of_float u›*) bounds (*‹0 ≤ l› ‹real_of_float u ≤ pi›*) by (auto intro!: sin_monotone_2pi_le (*‹⟦- (pi / 2) ≤ ?y; ?y ≤ ?x; ?x ≤ pi / 2⟧ ⟹ sin ?y ≤ sin ?x›*)) then show "?thesis" (*goal: ‹- sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))›*) by auto next (*goal: ‹pi / 2 ≤ y ⟹ - sin y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))›*) case 2 (*‹pi / 2 ≤ y›*) then have "- sin y ≤ - sin u" using that (*‹real_of_float l ≤ y› ‹y ≤ real_of_float u›*) bounds (*‹0 ≤ l› ‹real_of_float u ≤ pi›*) unfolding sin_minus_pi[symmetric] (*goal: ‹sin (y - pi) ≤ sin (real_of_float u - pi)›*) apply (intro sin_monotone_2pi_le (*‹⟦- (pi / 2) ≤ ?y; ?y ≤ ?x; ?x ≤ pi / 2⟧ ⟹ sin ?y ≤ sin ?x›*)) (*goals: 1. ‹⟦pi / 2 ≤ y; real_of_float l ≤ y; y ≤ real_of_float u; 0 ≤ l; real_of_float u ≤ pi⟧ ⟹ - (pi / 2) ≤ y - pi› 2. ‹⟦pi / 2 ≤ y; real_of_float l ≤ y; y ≤ real_of_float u; 0 ≤ l; real_of_float u ≤ pi⟧ ⟹ y - pi ≤ real_of_float u - pi› 3. ‹⟦pi / 2 ≤ y; real_of_float l ≤ y; y ≤ real_of_float u; 0 ≤ l; real_of_float u ≤ pi⟧ ⟹ real_of_float u - pi ≤ pi / 2› discuss goal 1*) apply ((auto intro!:)[1]) (*discuss goal 2*) apply ((auto intro!:)[1]) (*discuss goal 3*) apply ((auto intro!:)[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹- sin (y::real) ≤ max (- sin (real_of_float (l::float))) (- sin (real_of_float (u::float)))›*) by auto qed qed have "cos xn ∈ aform_err e Y" apply (rule min_range_antimono[OF xn lxn uxn min_eq_Some e, where f'="λx. - sin x"] (*‹⟦⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Cos (Num x)) [] = ?f (real_of_float x); ⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Minus (Sin (Num x))) [] = - sin (real_of_float x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ (?f has_real_derivative - sin x) (at x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ - sin x ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))⟧ ⟹ ?f xn ∈ aform_err e Y›*)) (*goal: ‹cos (xn::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) subgoal for by simp subgoal for by simp subgoal for by (auto intro!: derivative_eq_intros (*‹(λx::?'b::real_normed_vector. x) = (?g'::?'b::real_normed_vector ⇒ ?'b::real_normed_vector) ⟹ ((λx::?'b::real_normed_vector. x) has_derivative ?g') (?F::?'b::real_normed_vector filter)› ‹id = (?g'::?'b::real_normed_vector ⇒ ?'b::real_normed_vector) ⟹ (id has_derivative ?g') (?F::?'b::real_normed_vector filter)› ‹(λx::?'a::real_normed_vector. 0::?'b::real_normed_vector) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) ⟹ ((λx::?'a::real_normed_vector. ?f2::?'b::real_normed_vector) has_derivative ?g') (?F::?'a::real_normed_vector filter)› ‹⟦((?g1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?g'1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)⟧ ⟹ ((λx::?'a::real_normed_vector. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a::real_normed_vector ⇒ real) has_derivative (?g'1::?'a::real_normed_vector ⇒ real)) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. ?g'1 x *⇩R (?x1::?'b::real_normed_vector)) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)⟧ ⟹ ((λx::?'a::real_normed_vector. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a::real_normed_vector ⇒ ?'a1::real_normed_algebra) has_derivative (?g'1::?'a::real_normed_vector ⇒ ?'a1::real_normed_algebra)) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. (?x1::?'a1::real_normed_algebra) * ?g'1 x) = (?g'::?'a::real_normed_vector ⇒ ?'a1::real_normed_algebra)⟧ ⟹ ((λx::?'a::real_normed_vector. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a::real_normed_vector ⇒ ?'a1::real_normed_algebra) has_derivative (?g'1::?'a::real_normed_vector ⇒ ?'a1::real_normed_algebra)) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. ?g'1 x * (?y1::?'a1::real_normed_algebra)) = (?g'::?'a::real_normed_vector ⇒ ?'a1::real_normed_algebra)⟧ ⟹ ((λx::?'a::real_normed_vector. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a::real_normed_vector ⇒ real) has_derivative (?g'1::?'a::real_normed_vector ⇒ real)) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. of_real (?g'1 x)) = (?g'::?'a::real_normed_vector ⇒ ?'a1::{real_algebra_1,real_normed_vector})⟧ ⟹ ((λx::?'a::real_normed_vector. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?f'1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) (?F::?'a::real_normed_vector filter); ((?g1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?g'1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) ?F; (λx::?'a::real_normed_vector. ?f'1 x + ?g'1 x) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)⟧ ⟹ ((λx::?'a::real_normed_vector. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1::type. i ∈ (?I1::?'a1::type set) ⟹ ((?f1::?'a1::type ⇒ ?'a::real_normed_vector ⇒ ?'b::real_normed_vector) i has_derivative (?f'1::?'a1::type ⇒ ?'a::real_normed_vector ⇒ ?'b::real_normed_vector) i) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. ∑i::?'a1::type∈?I1. ?f'1 i x) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)⟧ ⟹ ((λx::?'a::real_normed_vector. ∑i::?'a1::type∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?f'1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) (?F::?'a::real_normed_vector filter); (λx::?'a::real_normed_vector. - ?f'1 x) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)⟧ ⟹ ((λx::?'a::real_normed_vector. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?f'1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) (?F::?'a::real_normed_vector filter); ((?g1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?g'1::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)) ?F; (λx::?'a::real_normed_vector. ?f'1 x - ?g'1 x) = (?g'::?'a::real_normed_vector ⇒ ?'b::real_normed_vector)⟧ ⟹ ((λx::?'a::real_normed_vector. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*)) subgoal for apply (rule diff_le (*‹⟦real_of_float (l::float) ≤ (?y::real); ?y ≤ real_of_float (u::float)⟧ ⟹ - sin ?y ≤ max (- sin (real_of_float l)) (- sin (real_of_float u))›*)) (*goals: 1. ‹x_ ∈ {real_of_float l..real_of_float u} ⟹ real_of_float l ≤ x_› 2. ‹x_ ∈ {real_of_float l..real_of_float u} ⟹ x_ ≤ real_of_float u› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . . then show "?thesis" (*goal: ‹cos x ∈ aform_err e Y›*) unfolding xn_def (*goal: ‹cos x ∈ aform_err e Y›*) by simp next (*goals: 1. ‹⟦l < 0 ∨ lb_pi p < u; ub_pi p ≤ l; u ≤ 2 * lb_pi p⟧ ⟹ cos x ∈ aform_err e Y› 2. ‹⟦l < 0 ∨ lb_pi p < u; l < ub_pi p ∨ 2 * lb_pi p < u⟧ ⟹ cos x ∈ aform_err e Y›*) case 2 (*‹l < 0 ∨ lb_pi p < u› ‹ub_pi p ≤ l› ‹(u::float) ≤ (2::float) * lb_pi (p::nat)›*) then have min_eq_Some: "min_range_mono p Cos (λx. Minus (Sin x)) l u X = Some Y" and bounds: "ub_pi p ≤ l" "u ≤ 2 * lb_pi p" using assms(2) (*‹cos_aform_err p X0 = Some Y›*) unfolding cos_aform_err_def X (*goals: 1. ‹min_range_mono p Cos (λx. Minus (Sin x)) l u X = Some Y› 2. ‹ub_pi p ≤ l› 3. ‹u ≤ 2 * lb_pi p›*) apply - (*goals: 1. ‹⟦l < 0 ∨ lb_pi p < u; ub_pi p ≤ l; u ≤ 2 * lb_pi p; Some X ⤜ (λX. let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. Minus (Sin x)) l u X else if ub_pi p ≤ l ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval p ivl)))) = Some Y⟧ ⟹ min_range_mono p Cos (λx. Minus (Sin x)) l u X = Some Y› 2. ‹⟦l < 0 ∨ lb_pi p < u; ub_pi p ≤ l; u ≤ 2 * lb_pi p; Some X ⤜ (λX. let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. Minus (Sin x)) l u X else if ub_pi p ≤ l ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval p ivl)))) = Some Y⟧ ⟹ ub_pi p ≤ l› 3. ‹⟦l < 0 ∨ lb_pi p < u; ub_pi p ≤ l; u ≤ 2 * lb_pi p; Some X ⤜ (λX. let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi p then min_range_antimono p Cos (λx. Minus (Sin x)) l u X else if ub_pi p ≤ l ∧ u ≤ 2 * lb_pi p then min_range_mono p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval p ivl)))) = Some Y⟧ ⟹ u ≤ 2 * lb_pi p› discuss goal 1*) apply ((auto simp: X (*‹range_reduce_aform_err (p::nat) (X0::(real × real pdevs) × real) = Some (X::(real × real pdevs) × real)›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) simp flip: l_def (*‹(l::float) = lower (ivl::float interval)›*) u_def (*‹(u::float) = upper (ivl::float interval)›*) ivl_def (*‹(ivl::float interval) = ivl_of_aform_err (p::nat) (X::(real × real pdevs) × real)›*) split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: X (*‹range_reduce_aform_err p X0 = Some X›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 3*) apply ((auto simp: X (*‹range_reduce_aform_err p X0 = Some X›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 3 subgoals*) . have bounds: "pi ≤ l" "u ≤ 2 * pi" using bounds (*‹ub_pi (p::nat) ≤ (l::float)› ‹u ≤ 2 * lb_pi p›*) pi_boundaries[of p] (*‹pi ∈ {real_of_float (lb_pi (p::nat))..real_of_float (ub_pi p)}›*) apply - (*goals: 1. ‹⟦ub_pi p ≤ l; u ≤ 2 * lb_pi p; pi ∈ {real_of_float (lb_pi p)..real_of_float (ub_pi p)}⟧ ⟹ pi ≤ real_of_float l› 2. ‹⟦ub_pi p ≤ l; u ≤ 2 * lb_pi p; pi ∈ {real_of_float (lb_pi p)..real_of_float (ub_pi p)}⟧ ⟹ real_of_float u ≤ 2 * pi› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have diff_le: "min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin y" if "real_of_float l ≤ y" "y ≤ real_of_float u" for y proof (-) (*goal: ‹min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin y›*) consider "y ≤ 3 * pi / 2" | "y ≥ 3 * pi / 2" (*goal: ‹⟦y ≤ 3 * pi / 2 ⟹ thesis; 3 * pi / 2 ≤ y ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?thesis" (*goal: ‹min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin y›*) proof (cases) (*goals: 1. ‹(y::real) ≤ (3::real) * pi / (2::real) ⟹ min (- sin (real_of_float (l::float))) (- sin (real_of_float (u::float))) ≤ - sin y› 2. ‹(3::real) * pi / (2::real) ≤ (y::real) ⟹ min (- sin (real_of_float (l::float))) (- sin (real_of_float (u::float))) ≤ - sin y›*) case 1 (*‹y ≤ 3 * pi / 2›*) then have "- sin l ≤ - sin y" unfolding sin_minus_pi[symmetric] (*goal: ‹sin (real_of_float (l::float) - pi) ≤ sin ((y::real) - pi)›*) apply (intro sin_monotone_2pi_le (*‹⟦- (pi / 2) ≤ ?y; ?y ≤ ?x; ?x ≤ pi / 2⟧ ⟹ sin ?y ≤ sin ?x›*)) (*goal: ‹sin (real_of_float l - pi) ≤ sin (y - pi)›*) using that (*‹real_of_float l ≤ y› ‹(y::real) ≤ real_of_float (u::float)›*) bounds (*‹pi ≤ real_of_float l› ‹real_of_float (u::float) ≤ (2::real) * pi›*) apply - (*goals: 1. ‹⟦y ≤ 3 * pi / 2; real_of_float l ≤ y; y ≤ real_of_float u; pi ≤ real_of_float l; real_of_float u ≤ 2 * pi⟧ ⟹ - (pi / 2) ≤ real_of_float l - pi› 2. ‹⟦y ≤ 3 * pi / 2; real_of_float l ≤ y; y ≤ real_of_float u; pi ≤ real_of_float l; real_of_float u ≤ 2 * pi⟧ ⟹ real_of_float l - pi ≤ y - pi› 3. ‹⟦y ≤ 3 * pi / 2; real_of_float l ≤ y; y ≤ real_of_float u; pi ≤ real_of_float l; real_of_float u ≤ 2 * pi⟧ ⟹ y - pi ≤ pi / 2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin y›*) by auto next (*goal: ‹(3::real) * pi / (2::real) ≤ (y::real) ⟹ min (- sin (real_of_float (l::float))) (- sin (real_of_float (u::float))) ≤ - sin y›*) case 2 (*‹3 * pi / 2 ≤ y›*) then have "- sin u ≤ - sin y" unfolding sin_2pi_minus[symmetric] (*goal: ‹sin (2 * pi - real_of_float u) ≤ sin (2 * pi - y)›*) using that (*‹real_of_float l ≤ y› ‹y ≤ real_of_float u›*) bounds (*‹pi ≤ real_of_float l› ‹real_of_float u ≤ 2 * pi›*) apply (intro sin_monotone_2pi_le (*‹⟦- (pi / 2) ≤ ?y; ?y ≤ ?x; ?x ≤ pi / 2⟧ ⟹ sin ?y ≤ sin ?x›*)) (*goals: 1. ‹⟦3 * pi / 2 ≤ y; real_of_float l ≤ y; y ≤ real_of_float u; pi ≤ real_of_float l; real_of_float u ≤ 2 * pi⟧ ⟹ - (pi / 2) ≤ 2 * pi - real_of_float u› 2. ‹⟦3 * pi / 2 ≤ y; real_of_float l ≤ y; y ≤ real_of_float u; pi ≤ real_of_float l; real_of_float u ≤ 2 * pi⟧ ⟹ 2 * pi - real_of_float u ≤ 2 * pi - y› 3. ‹⟦3 * pi / 2 ≤ y; real_of_float l ≤ y; y ≤ real_of_float u; pi ≤ real_of_float l; real_of_float u ≤ 2 * pi⟧ ⟹ 2 * pi - y ≤ pi / 2› discuss goal 1*) apply ((auto intro!:)[1]) (*discuss goal 2*) apply ((auto intro!:)[1]) (*discuss goal 3*) apply ((auto intro!:)[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin y›*) by auto qed qed have "cos xn ∈ aform_err e Y" apply (rule min_range_mono[OF xn lxn uxn min_eq_Some e, where f'="λx. - sin x"] (*‹⟦⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Cos (Num x)) [] = ?f (real_of_float x); ⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Minus (Sin (Num x))) [] = - sin (real_of_float x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ (?f has_real_derivative - sin x) (at x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin x⟧ ⟹ ?f xn ∈ aform_err e Y›*)) (*goal: ‹cos xn ∈ aform_err e Y›*) subgoal for by simp subgoal for by simp subgoal for by (auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*)) subgoal for apply (rule diff_le (*‹⟦real_of_float l ≤ ?y; ?y ≤ real_of_float u⟧ ⟹ min (- sin (real_of_float l)) (- sin (real_of_float u)) ≤ - sin ?y›*)) (*goals: 1. ‹(x_::real) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ real_of_float l ≤ x_› 2. ‹(x_::real) ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ x_ ≤ real_of_float u› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . . then show "?thesis" (*goal: ‹cos x ∈ aform_err e Y›*) unfolding xn_def (*goal: ‹cos x ∈ aform_err e Y›*) by simp next (*goal: ‹⟦(l::float) < (0::float) ∨ lb_pi (p::nat) < (u::float); l < ub_pi p ∨ (2::float) * lb_pi p < u⟧ ⟹ cos (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) case 3 (*‹l < 0 ∨ lb_pi p < u› ‹l < ub_pi p ∨ 2 * lb_pi p < u›*) then obtain ivl' where "cos_float_interval p ivl = ivl'" "Y = ivl_err (real_interval ivl')" (*goal: ‹(⋀ivl'. ⟦cos_float_interval p ivl = ivl'; Y = ivl_err (real_interval ivl')⟧ ⟹ thesis) ⟹ thesis›*) using assms(2) (*‹cos_aform_err p X0 = Some Y›*) unfolding cos_aform_err_def X l_def u_def (*goal: ‹(⋀ivl'. ⟦cos_float_interval p ivl = ivl'; Y = ivl_err (real_interval ivl')⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: X (*‹range_reduce_aform_err p X0 = Some X›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) with cos_float_intervalI[OF ‹xn ∈⇩r ivl›, of p] (*‹cos xn ∈⇩r cos_float_interval p ivl›*) show "?thesis" (*goal: ‹cos x ∈ aform_err e Y›*) by (auto simp: xn_def (*‹xn = x + real_of_int n * (2 * pi)›*)) qed qed definition "sqrt_aform_err p X = do { let ivl = ivl_of_aform_err p X; let l = lower ivl; let u = upper ivl; if 0 < l then min_range_mono p Sqrt (λx. Half (Inverse (Sqrt x))) l u X else Some (ivl_err (real_interval (sqrt_float_interval p ivl))) }" lemma sqrt_aform_err: assumes x: "x ∈ aform_err e X" assumes "sqrt_aform_err p X = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "sqrt x ∈ aform_err e Y" proof (-) (*goal: ‹sqrt x ∈ aform_err e Y›*) obtain l and u and ivl where ivl_def: "ivl = ivl_of_aform_err p X" and l_def: "l = lower ivl" and u_def: "u = upper ivl" (*goal: ‹(⋀ivl l u. ⟦ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl⟧ ⟹ thesis) ⟹ thesis›*) by auto from ivl_of_aform_err[OF e x, of p, folded ivl_def] (*‹(x::real) ∈⇩r (ivl::float interval)›*) have ivl: "x ∈⇩r ivl" . then have lx: "l ≤ x" and ux: "x ≤ u" apply - (*goals: 1. ‹x ∈⇩r ivl ⟹ real_of_float l ≤ x› 2. ‹x ∈⇩r ivl ⟹ x ≤ real_of_float u› discuss goal 1*) apply ((auto simp flip: ivl_def (*‹ivl = ivl_of_aform_err p X›*) simp: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 2*) apply ((auto simp flip: ivl_def (*‹ivl = ivl_of_aform_err p X›*) simp: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*proven 2 subgoals*) . consider "l > 0" | "l ≤ 0" (*goal: ‹⟦0 < l ⟹ thesis; l ≤ 0 ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?thesis" (*goal: ‹sqrt x ∈ aform_err e Y›*) proof (cases) (*goals: 1. ‹0 < l ⟹ sqrt x ∈ aform_err e Y› 2. ‹l ≤ 0 ⟹ sqrt x ∈ aform_err e Y›*) case 1 (*‹0 < l›*) then have min_eq_Some: "min_range_mono p Sqrt (λx. Half (Inverse (Sqrt x))) l u X = Some Y" and bounds: "0 < l" using assms(2) (*‹sqrt_aform_err p X = Some Y›*) unfolding sqrt_aform_err_def (*goals: 1. ‹min_range_mono p Sqrt (λx. Half (Inverse (Sqrt x))) l u X = Some Y› 2. ‹0 < l›*) apply - (*goals: 1. ‹⟦0 < l; (let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl in if 0 < l then min_range_mono p Sqrt (λx. Half (Inverse (Sqrt x))) l u X else Some (ivl_err (real_interval (sqrt_float_interval p ivl)))) = Some Y⟧ ⟹ min_range_mono p Sqrt (λx. Half (Inverse (Sqrt x))) l u X = Some Y› 2. ‹⟦0 < l; (let ivl = ivl_of_aform_err p X; l = lower ivl; u = upper ivl in if 0 < l then min_range_mono p Sqrt (λx. Half (Inverse (Sqrt x))) l u X else Some (ivl_err (real_interval (sqrt_float_interval p ivl)))) = Some Y⟧ ⟹ 0 < l› discuss goal 1*) apply ((auto simp: Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) simp flip: l_def (*‹(l::float) = lower (ivl::float interval)›*) u_def (*‹(u::float) = upper (ivl::float interval)›*) ivl_def (*‹(ivl::float interval) = ivl_of_aform_err (p::nat) (X::(real × real pdevs) × real)›*) split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . have "sqrt x ∈ aform_err e Y" apply (rule min_range_mono[OF x lx ux min_eq_Some e, where f'="λx. 1 / (2 * sqrt x)"] (*‹⟦⋀x::float. real_of_float x ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ interpret_floatarith (Sqrt (Num x)) [] = (?f::real ⇒ real) (real_of_float x); ⋀x::float. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Half (Inverse (Sqrt (Num x)))) [] = (1::real) / ((2::real) * sqrt (real_of_float x)); ⋀x::real. x ∈ {real_of_float l..real_of_float u} ⟹ (?f has_real_derivative (1::real) / ((2::real) * sqrt x)) (at x); ⋀x::real. x ∈ {real_of_float l..real_of_float u} ⟹ min ((1::real) / ((2::real) * sqrt (real_of_float l))) ((1::real) / ((2::real) * sqrt (real_of_float u))) ≤ (1::real) / ((2::real) * sqrt x)⟧ ⟹ ?f (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*)) (*goal: ‹sqrt (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) subgoal for by simp subgoal for by (simp add: divide_simps (*‹inverse (?a::?'a::division_ring) = (1::?'a::division_ring) / ?a› ‹(?a::?'a::division_ring) + (?b::?'a::division_ring) / (?z::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a::division_ring) / (?z::?'a::division_ring) + (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a::division_ring) / (?z::?'a::division_ring)) + (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a::division_ring) - (?b::?'a::division_ring) / (?z::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a::division_ring) / (?z::?'a::division_ring) - (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a::division_ring) / (?z::?'a::division_ring)) - (?b::?'a::division_ring) = (if ?z = (0::?'a::division_ring) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a::division_ring) / (?c::?'a::division_ring) = (?a::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then ?b = ?a * ?c else ?a = (0::?'a::division_ring))› ‹((?a::?'a::division_ring) = (?b::?'a::division_ring) / (?c::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then ?a * ?c = ?b else ?a = (0::?'a::division_ring))› ‹(- ((?b::?'a::division_ring) / (?c::?'a::division_ring)) = (?a::?'a::division_ring)) = (if ?c ≠ (0::?'a::division_ring) then - ?b = ?a * ?c else ?a = (0::?'a::division_ring))› ‹((?a::?'a::division_ring) = - ((?b::?'a::division_ring) / (?c::?'a::division_ring))) = (if ?c ≠ (0::?'a::division_ring) then ?a * ?c = - ?b else ?a = (0::?'a::division_ring))› ‹((?a::?'a::linordered_field) ≤ (?b::?'a::linordered_field) / (?c::?'a::linordered_field)) = (if (0::?'a::linordered_field) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a::linordered_field) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a::linordered_field))› and more 13 facts*)) subgoal for using bounds (*‹0 < l›*) by (auto intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*) simp: inverse_eq_divide (*‹inverse (?a::?'a) = (1::?'a) / ?a›*)) subgoal for using ‹l > 0› (*‹0 < l›*) by (auto simp: inverse_eq_divide (*‹inverse ?a = 1 / ?a›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) . then show "?thesis" (*goal: ‹sqrt x ∈ aform_err e Y›*) by simp next (*goal: ‹l ≤ 0 ⟹ sqrt x ∈ aform_err e Y›*) case 2 (*‹l ≤ 0›*) then have "Y = ivl_err (real_interval (sqrt_float_interval p ivl))" using assms(2) (*‹sqrt_aform_err (p::nat) (X::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)›*) unfolding sqrt_aform_err_def (*goal: ‹Y = ivl_err (real_interval (sqrt_float_interval p ivl))›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: ivl_def (*‹ivl = ivl_of_aform_err p X›*) l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) with sqrt_float_intervalI[OF ivl] (*‹sqrt x ∈⇩r sqrt_float_interval ?p ivl›*) show "?thesis" (*goal: ‹sqrt x ∈ aform_err e Y›*) by (auto simp: set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*)) qed qed definition "ln_aform_err p X = do { let ivl = ivl_of_aform_err p X; let l = lower ivl; if 0 < l then min_range_mono p Ln inverse l (upper ivl) X else None }" lemma ln_aform_err: assumes x: "x ∈ aform_err e X" assumes "ln_aform_err p X = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "ln x ∈ aform_err e Y" proof (-) (*goal: ‹ln x ∈ aform_err e Y›*) obtain ivl and l and u where l_def: "l = lower ivl" and u_def: "u = upper ivl" and ivl_def: "ivl = ivl_of_aform_err p X" (*goal: ‹(⋀l ivl u. ⟦l = lower ivl; u = upper ivl; ivl = ivl_of_aform_err p X⟧ ⟹ thesis) ⟹ thesis›*) by auto from ivl_of_aform_err[OF e x, of p, folded ivl_def] (*‹x ∈⇩r ivl›*) have "x ∈⇩r ivl" . then have lx: "l ≤ x" and ux: "x ≤ u" apply - (*goals: 1. ‹x ∈⇩r ivl ⟹ real_of_float l ≤ x› 2. ‹x ∈⇩r ivl ⟹ x ≤ real_of_float u› discuss goal 1*) apply ((auto simp: set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*))[1]) (*discuss goal 2*) apply ((auto simp: set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*))[1]) (*proven 2 subgoals*) . consider "l > 0" | "l ≤ 0" (*goal: ‹⟦0 < l ⟹ thesis; l ≤ 0 ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?thesis" (*goal: ‹ln x ∈ aform_err e Y›*) proof (cases) (*goals: 1. ‹0 < l ⟹ ln x ∈ aform_err e Y› 2. ‹l ≤ 0 ⟹ ln x ∈ aform_err e Y›*) case 1 (*‹0 < l›*) then have min_eq_Some: "min_range_mono p Ln inverse l u X = Some Y" and bounds: "0 < l" using assms(2) (*‹ln_aform_err p X = Some Y›*) unfolding ln_aform_err_def (*goals: 1. ‹min_range_mono p Ln inverse l u X = Some Y› 2. ‹0 < l›*) apply - (*goals: 1. ‹⟦0 < l; (let ivl = ivl_of_aform_err p X; l = lower ivl in if 0 < l then min_range_mono p Ln inverse l (upper ivl) X else None) = Some Y⟧ ⟹ min_range_mono p Ln inverse l u X = Some Y› 2. ‹⟦0 < l; (let ivl = ivl_of_aform_err p X; l = lower ivl in if 0 < l then min_range_mono p Ln inverse l (upper ivl) X else None) = Some Y⟧ ⟹ 0 < l› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: ivl_def (*‹ivl = ivl_of_aform_err p X›*) l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: ivl_def (*‹ivl = ivl_of_aform_err p X›*) l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . have "ln x ∈ aform_err e Y" apply (rule min_range_mono[OF x lx ux min_eq_Some e, where f'=inverse] (*‹⟦⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Ln (Num x)) [] = ?f (real_of_float x); ⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (inverse (Num x)) [] = inverse (real_of_float x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ (?f has_real_derivative inverse x) (at x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ min (inverse (real_of_float l)) (inverse (real_of_float u)) ≤ inverse x⟧ ⟹ ?f x ∈ aform_err e Y›*)) (*goal: ‹ln x ∈ aform_err e Y›*) subgoal for by simp subgoal for by (simp add: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) subgoal for using bounds (*‹(0::float) < (l::float)›*) by (auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*) simp: inverse_eq_divide (*‹inverse ?a = 1 / ?a›*)) subgoal for using ‹l > 0› (*‹0 < l›*) by (auto simp: inverse_eq_divide (*‹inverse ?a = 1 / ?a›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) . then show "?thesis" (*goal: ‹ln x ∈ aform_err e Y›*) by simp next (*goal: ‹l ≤ 0 ⟹ ln x ∈ aform_err e Y›*) case 2 (*‹l ≤ 0›*) then show "?thesis" (*goal: ‹ln x ∈ aform_err e Y›*) using assms (*‹x ∈ aform_err e X› ‹ln_aform_err p X = Some Y› ‹e ∈ UNIV → {- 1..1}›*) by (auto simp: ln_aform_err_def (*‹ln_aform_err ?p ?X = (let ivl = ivl_of_aform_err ?p ?X; l = lower ivl in if 0 < l then min_range_mono ?p Ln inverse l (upper ivl) ?X else None)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) l_def (*‹l = lower ivl›*) ivl_def (*‹ivl = ivl_of_aform_err p X›*)) qed qed definition "exp_aform_err p X = do { let ivl = ivl_of_aform_err p X; min_range_mono p Exp Exp (lower ivl) (upper ivl) X }" lemma exp_aform_err: assumes x: "x ∈ aform_err e X" assumes "exp_aform_err p X = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "exp x ∈ aform_err e Y" proof (-) (*goal: ‹exp x ∈ aform_err e Y›*) obtain l and u and ivl where l_def: "l = lower ivl" and u_def: "u = upper ivl" and ivl_def: "ivl = ivl_of_aform_err p X" (*goal: ‹(⋀l ivl u. ⟦l = lower ivl; u = upper ivl; ivl = ivl_of_aform_err p X⟧ ⟹ thesis) ⟹ thesis›*) by auto from ivl_of_aform_err[OF e x, of p, folded ivl_def] (*‹(x::real) ∈⇩r (ivl::float interval)›*) have "x ∈⇩r ivl" . then have lx: "l ≤ x" and ux: "x ≤ u" apply - (*goals: 1. ‹x ∈⇩r ivl ⟹ real_of_float l ≤ x› 2. ‹x ∈⇩r ivl ⟹ x ≤ real_of_float u› discuss goal 1*) apply ((auto simp: ivl_def (*‹ivl = ivl_of_aform_err p X›*) l_def (*‹l = lower ivl›*) u_def (*‹u = upper ivl›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 2*) apply ((auto simp: ivl_def (*‹(ivl::float interval) = ivl_of_aform_err (p::nat) (X::(real × real pdevs) × real)›*) l_def (*‹(l::float) = lower (ivl::float interval)›*) u_def (*‹(u::float) = upper (ivl::float interval)›*) set_of_eq (*‹set_of (?x::?'a interval) = {lower ?x..upper ?x}›*))[1]) (*proven 2 subgoals*) . have min_eq_Some: "min_range_mono p Exp Exp l u X = Some Y" using assms(2) (*‹exp_aform_err p X = Some Y›*) unfolding exp_aform_err_def (*goal: ‹min_range_mono p Exp Exp l u X = Some Y›*) by (auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) simp flip: ivl_def (*‹ivl = ivl_of_aform_err p X›*) u_def (*‹u = upper ivl›*) l_def (*‹l = lower ivl›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) have "exp x ∈ aform_err e Y" apply (rule min_range_mono[OF x lx ux min_eq_Some e, where f'=exp] (*‹⟦⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Exp (Num x)) [] = ?f (real_of_float x); ⋀x. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith (Exp (Num x)) [] = exp (real_of_float x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ (?f has_real_derivative exp x) (at x); ⋀x. x ∈ {real_of_float l..real_of_float u} ⟹ min (exp (real_of_float l)) (exp (real_of_float u)) ≤ exp x⟧ ⟹ ?f x ∈ aform_err e Y›*)) (*goal: ‹exp x ∈ aform_err e Y›*) subgoal for by simp subgoal for by (simp add: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) subgoal for by (auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*) simp: inverse_eq_divide (*‹inverse ?a = 1 / ?a›*)) subgoal for by (auto simp: inverse_eq_divide (*‹inverse (?a::?'a) = (1::?'a) / ?a›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*)) . then show "?thesis" (*goal: ‹exp (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) by simp qed definition "arctan_aform_err p X = do { let l = Inf_aform_err p X; let u = Sup_aform_err p X; min_range_mono p Arctan (λx. 1 / (Num 1 + x * x)) l u X }" lemma pos_add_nonneg_ne_zero: "a > 0 ⟹ b ≥ 0 ⟹ a + b ≠ 0" for a b::real by arith lemma arctan_aform_err: assumes x: "x ∈ aform_err e X" assumes "arctan_aform_err p X = Some Y" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "arctan x ∈ aform_err e Y" proof (-) (*goal: ‹arctan x ∈ aform_err e Y›*) obtain l and u where l: "l = Inf_aform_err p X" and u: "u = Sup_aform_err p X" (*goal: ‹(⋀l u. ⟦l = Inf_aform_err p X; u = Sup_aform_err p X⟧ ⟹ thesis) ⟹ thesis›*) by auto from x (*‹x ∈ aform_err e X›*) l (*‹l = Inf_aform_err p X›*) u (*‹(u::float) = Sup_aform_err (p::nat) (X::(real × real pdevs) × real)›*) have lx: "l ≤ x" and ux: "x ≤ u" using Inf_Sup_aform_err[OF e, of X p] (*‹aform_err e X ⊆ {real_of_float (Inf_aform_err p X)..real_of_float (Sup_aform_err p X)}›*) apply - (*goals: 1. ‹⟦(x::real) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real); (l::float) = Inf_aform_err (p::nat) X; (u::float) = Sup_aform_err p X; aform_err e X ⊆ {real_of_float (Inf_aform_err p X)..real_of_float (Sup_aform_err p X)}⟧ ⟹ real_of_float l ≤ x› 2. ‹⟦(x::real) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real); (l::float) = Inf_aform_err (p::nat) X; (u::float) = Sup_aform_err p X; aform_err e X ⊆ {real_of_float (Inf_aform_err p X)..real_of_float (Sup_aform_err p X)}⟧ ⟹ x ≤ real_of_float u› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have min_eq_Some: "min_range_mono p Arctan (λx. 1 / (Num 1 + x * x)) l u X = Some Y" using assms(2) (*‹arctan_aform_err p X = Some Y›*) unfolding arctan_aform_err_def l u (*goal: ‹min_range_mono p Arctan (λx. 1 / (Num 1 + x * x)) (Inf_aform_err p X) (Sup_aform_err p X) X = Some Y›*) by (auto simp: l[symmetric] (*‹Inf_aform_err p X = l›*) u[symmetric] (*‹Sup_aform_err p X = u›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) have "arctan x ∈ aform_err e Y" apply (rule min_range_mono[OF x lx ux min_eq_Some e, where f'="λx. inverse (1 + x²)"] (*‹⟦⋀x::float. real_of_float x ∈ {real_of_float (l::float)..real_of_float (u::float)} ⟹ interpret_floatarith (Arctan (Num x)) [] = (?f::real ⇒ real) (real_of_float x); ⋀x::float. real_of_float x ∈ {real_of_float l..real_of_float u} ⟹ interpret_floatarith ((1::floatarith) / (Num (1::float) + Num x * Num x)) [] = inverse ((1::real) + (real_of_float x)²); ⋀x::real. x ∈ {real_of_float l..real_of_float u} ⟹ (?f has_real_derivative inverse ((1::real) + x²)) (at x); ⋀x::real. x ∈ {real_of_float l..real_of_float u} ⟹ min (inverse ((1::real) + (real_of_float l)²)) (inverse ((1::real) + (real_of_float u)²)) ≤ inverse ((1::real) + x²)⟧ ⟹ ?f (x::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*)) (*goal: ‹arctan x ∈ aform_err e Y›*) subgoal for by simp subgoal for by (simp add: power2_eq_square (*‹?a² = ?a * ?a›*) inverse_eq_divide (*‹inverse ?a = 1 / ?a›*)) subgoal for by (auto intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*) simp: inverse_eq_divide (*‹inverse (?a::?'a) = (1::?'a) / ?a›*)) subgoal for x apply (cases "x ≤ 0") (*goal: ‹x ∈ {real_of_float l..real_of_float u} ⟹ min (inverse (1 + (real_of_float l)²)) (inverse (1 + (real_of_float u)²)) ≤ inverse (1 + x²)›*) subgoal for apply (rule min.coboundedI1 (*‹?a ≤ ?c ⟹ min ?a ?b ≤ ?c›*)) (*goal: ‹⟦x ∈ {real_of_float l..real_of_float u}; x ≤ 0⟧ ⟹ min (inverse (1 + (real_of_float l)²)) (inverse (1 + (real_of_float u)²)) ≤ inverse (1 + x²)›*) apply (rule deriv_nonneg_imp_mono[of "real_of_float l" x] (*‹⟦⋀x. x ∈ {real_of_float l..x} ⟹ (?g has_real_derivative ?g' x) (at x); ⋀x. x ∈ {real_of_float l..x} ⟹ 0 ≤ ?g' x; real_of_float l ≤ x⟧ ⟹ ?g (real_of_float l) ≤ ?g x›*)) (*goal: ‹⟦x ∈ {real_of_float l..real_of_float u}; x ≤ 0⟧ ⟹ inverse (1 + (real_of_float l)²) ≤ inverse (1 + x²)›*) by (auto intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 106 facts*) simp: mult_le_0_iff (*‹((?a::?'a) * (?b::?'a) ≤ (0::?'a)) = ((0::?'a) ≤ ?a ∧ ?b ≤ (0::?'a) ∨ ?a ≤ (0::?'a) ∧ (0::?'a) ≤ ?b)›*) pos_add_nonneg_ne_zero (*‹⟦(0::real) < (?a::real); (0::real) ≤ (?b::real)⟧ ⟹ ?a + ?b ≠ (0::real)›*)) subgoal for apply (rule min.coboundedI2 (*‹?b ≤ ?c ⟹ min ?a ?b ≤ ?c›*)) (*goal: ‹⟦x ∈ {real_of_float l..real_of_float u}; ¬ x ≤ 0⟧ ⟹ min (inverse (1 + (real_of_float l)²)) (inverse (1 + (real_of_float u)²)) ≤ inverse (1 + x²)›*) apply (rule le_imp_inverse_le (*‹⟦?a ≤ ?b; 0 < ?a⟧ ⟹ inverse ?b ≤ inverse ?a›*)) (*goals: 1. ‹⟦x ∈ {real_of_float l..real_of_float u}; ¬ x ≤ 0⟧ ⟹ 1 + x² ≤ 1 + (real_of_float u)²› 2. ‹⟦x ∈ {real_of_float l..real_of_float u}; ¬ x ≤ 0⟧ ⟹ 0 < 1 + x²› discuss goal 1*) apply ((auto intro!: power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*) add_pos_nonneg (*‹⟦0 < ?a; 0 ≤ ?b⟧ ⟹ 0 < ?a + ?b›*))[1]) (*discuss goal 2*) apply ((auto intro!: power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*) add_pos_nonneg (*‹⟦0 < ?a; 0 ≤ ?b⟧ ⟹ 0 < ?a + ?b›*))[1]) (*proven 2 subgoals*) . . . then show "?thesis" (*goal: ‹arctan x ∈ aform_err e Y›*) by simp qed subsection ‹Power, TODO: compare with Min-range approximation?!› definition "power_aform_err p (X::aform_err) n = (if n = 0 then ((1, zero_pdevs), 0) else if n = 1 then X else let x0 = float_of (fst (fst X)); xs = snd (fst X); xe = float_of (snd X); C = the (approx p (Num x0 ^⇩e n) []); (c, ce) = mid_err C; NX = the (approx p (Num (of_nat n) * (Num x0 ^⇩e (n - 1))) []); (nx, nxe) = mid_err NX; Y = scaleR_pdevs nx xs; (Y', Y_err) = trunc_bound_pdevs p Y; t = tdev' p xs; Ye = truncate_up p (nxe * t); err = the (approx p (Num (of_nat n) * Num xe * Abs (Num x0) ^⇩e (n - 1) + (Sum⇩e (λk. Num (of_nat (n choose k)) * Abs (Num x0) ^⇩e (n - k) * (Num xe + Num (float_of t)) ^⇩e k) [2..<Suc n])) []); ERR = upper err in ((c, Y'), sum_list' p [ce, Y_err, Ye, real_of_float ERR]))" lemma bounded_by_Nil: "bounded_by [] []" by (auto simp: bounded_by_def (*‹bounded_by (?xs::real list) (?vs::float interval option list) = (∀i<length ?vs. case ?vs ! i of None ⇒ True | Some (ivl::float interval) ⇒ ?xs ! i ∈⇩r ivl)›*)) lemma plain_floatarith_approx: assumes "plain_floatarith 0 f" shows "interpret_floatarith f [] ∈⇩r (the (approx p f []))" proof (-) (*goal: ‹interpret_floatarith f [] ∈⇩r the (approx p f [])›*) from plain_floatarith_approx_not_None[OF assms ( 1 ), of Nil p] (*‹⟦0 ≤ length []; ⋀i. i < 0 ⟹ [] ! i ≠ None⟧ ⟹ approx p f [] ≠ None›*) obtain ivl where "approx p f [] = Some ivl" (*goal: ‹(⋀ivl. approx p f [] = Some ivl ⟹ thesis) ⟹ thesis›*) by auto from this (*‹approx p f [] = Some ivl›*) approx[OF bounded_by_Nil this] (*‹interpret_floatarith f [] ∈⇩r ivl›*) show "?thesis" (*goal: ‹interpret_floatarith f [] ∈⇩r the (approx p f [])›*) by auto qed lemma plain_floatarith_Sum⇩e: "plain_floatarith n (Sum⇩e f xs) ⟷ list_all (λi. plain_floatarith n (f i)) xs" apply (induction xs) (*goals: 1. ‹plain_floatarith n (Sum⇩e f []) = list_all (λi. plain_floatarith n (f i)) []› 2. ‹⋀a xs. plain_floatarith n (Sum⇩e f xs) = list_all (λi. plain_floatarith n (f i)) xs ⟹ plain_floatarith n (Sum⇩e f (a # xs)) = list_all (λi. plain_floatarith n (f i)) (a # xs)› discuss goal 1*) apply ((auto simp: zero_floatarith_def (*‹0 = Num 0›*) plus_floatarith_def (*‹?f + ?g = Add ?f ?g›*))[1]) (*discuss goal 2*) apply ((auto simp: zero_floatarith_def (*‹0 = Num 0›*) plus_floatarith_def (*‹?f + ?g = Add ?f ?g›*))[1]) (*proven 2 subgoals*) . lemma sum_list'_float[simp]: "sum_list' p xs ∈ float" apply (induction xs rule: rev_induct (*‹⟦(?P::?'a::type list ⇒ bool) []; ⋀(x::?'a::type) xs::?'a::type list. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P (?xs::?'a::type list)›*)) (*goals: 1. ‹sum_list' p [] ∈ float› 2. ‹⋀x xs. sum_list' p xs ∈ float ⟹ sum_list' p (xs @ [x]) ∈ float› discuss goal 1*) apply ((auto simp: sum_list'_def (*‹sum_list' (?p::nat) (?xs::?'a::executable_euclidean_space list) = fold (λ(a::?'a::executable_euclidean_space) b::?'a::executable_euclidean_space. eucl_truncate_up ?p (a + b)) ?xs (0::?'a::executable_euclidean_space)›*) eucl_truncate_up_real_def (*‹eucl_truncate_up (?prec::nat) (?b::real) = truncate_up ?prec ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: sum_list'_def (*‹sum_list' ?p ?xs = fold (λa b. eucl_truncate_up ?p (a + b)) ?xs 0›*) eucl_truncate_up_real_def (*‹eucl_truncate_up ?prec ?b = truncate_up ?prec ?b›*))[1]) (*proven 2 subgoals*) . lemma tdev'_float[simp]: "tdev' p xs ∈ float" by (auto simp: tdev'_def (*‹tdev' ?p ?x = sum_list' ?p (map (abs ∘ snd) (list_of_pdevs ?x))›*)) lemma fixes x y::real assumes "abs (x - y) ≤ e" obtains err where "x = y + err" "abs err ≤ e" using assms (*‹¦x - y¦ ≤ e›*) apply atomize_elim (*goal: ‹(⋀err. ⟦x = y + err; ¦err¦ ≤ e⟧ ⟹ thesis) ⟹ thesis›*) apply (rule exI[where x="x - y"] (*‹(?P::real ⇒ bool) ((x::real) - (y::real)) ⟹ ∃x::real. ?P x›*)) (*goal: ‹¦x - y¦ ≤ e ⟹ ∃err. x = y + err ∧ ¦err¦ ≤ e›*) by (auto simp: abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*)) theorem power_aform_err: assumes "x ∈ aform_err e X" assumes floats[simp]: "fst (fst X) ∈ float" "snd X ∈ float" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "x ^ n ∈ aform_err e (power_aform_err p X n)" proof (-) (*goal: ‹x ^ n ∈ aform_err e (power_aform_err p X n)›*) consider "n = 0" | "n = 1" | "n ≥ 2" (*goal: ‹⟦n = 0 ⟹ thesis; n = 1 ⟹ thesis; 2 ≤ n ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?thesis" (*goal: ‹x ^ n ∈ aform_err e (power_aform_err p X n)›*) proof (cases) (*goals: 1. ‹n = 0 ⟹ x ^ n ∈ aform_err e (power_aform_err p X n)› 2. ‹n = 1 ⟹ x ^ n ∈ aform_err e (power_aform_err p X n)› 3. ‹2 ≤ n ⟹ x ^ n ∈ aform_err e (power_aform_err p X n)›*) case 1 (*‹n = 0›*) then show "?thesis" (*goal: ‹x ^ n ∈ aform_err e (power_aform_err p X n)›*) by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) power_aform_err_def (*‹power_aform_err ?p ?X ?n = (if ?n = 0 then ((1, zero_pdevs), 0) else if ?n = 1 then ?X else let x0 = float_of (fst (fst ?X)); xs = snd (fst ?X); xe = float_of (snd ?X); C = the (approx ?p (Power (Num x0) ?n) []); (c, ce) = mid_err C; NX = the (approx ?p (Num (of_nat ?n) * Power (Num x0) (?n - 1)) []); (nx, nxe) = mid_err NX; Y = scaleR_pdevs nx xs; (Y', Y_err) = trunc_bound_pdevs ?p Y; t = tdev' ?p xs; Ye = truncate_up ?p (nxe * t); err = the (approx ?p (Num (of_nat ?n) * Num xe * Power (Abs (Num x0)) (?n - 1) + Sum⇩e (λk. Num (of_nat (?n choose k)) * Power (Abs (Num x0)) (?n - k) * Power (Num xe + Num (float_of t)) k) [2..<Suc ?n]) []); ERR = upper err in ((c, Y'), sum_list' ?p [ce, Y_err, Ye, real_of_float ERR]))›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) next (*goals: 1. ‹n = 1 ⟹ x ^ n ∈ aform_err e (power_aform_err p X n)› 2. ‹2 ≤ n ⟹ x ^ n ∈ aform_err e (power_aform_err p X n)›*) case 2 (*‹n = 1›*) then show "?thesis" (*goal: ‹x ^ n ∈ aform_err e (power_aform_err p X n)›*) using assms (*‹x ∈ aform_err e X› ‹fst (fst X) ∈ float› ‹snd X ∈ float› ‹e ∈ UNIV → {- 1..1}›*) by (auto simp: aform_err_def (*‹aform_err (?e::nat ⇒ real) (?Xe::(real × real pdevs) × real) = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) power_aform_err_def (*‹power_aform_err (?p::nat) (?X::(real × real pdevs) × real) (?n::nat) = (if ?n = (0::nat) then ((1::real, zero_pdevs), 0::real) else if ?n = (1::nat) then ?X else let x0::float = float_of (fst (fst ?X)); xs::real pdevs = snd (fst ?X); xe::float = float_of (snd ?X); C::float interval = the (approx ?p (Power (Num x0) ?n) []); (c::real, ce::real) = mid_err C; NX::float interval = the (approx ?p (Num (of_nat ?n) * Power (Num x0) (?n - (1::nat))) []); (nx::real, nxe::real) = mid_err NX; Y::real pdevs = scaleR_pdevs nx xs; (Y'::real pdevs, Y_err::real) = trunc_bound_pdevs ?p Y; t::real = tdev' ?p xs; Ye::real = truncate_up ?p (nxe * t); err::float interval = the (approx ?p (Num (of_nat ?n) * Num xe * Power (Abs (Num x0)) (?n - (1::nat)) + Sum⇩e (λk::nat. Num (of_nat (?n choose k)) * Power (Abs (Num x0)) (?n - k) * Power (Num xe + Num (float_of t)) k) [2::nat..<Suc ?n]) []); ERR::float = upper err in ((c, Y'), sum_list' ?p [ce, Y_err, Ye, real_of_float ERR]))›*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a::real_normed_vector × ?'a::real_normed_vector pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*)) next (*goal: ‹2 ≤ n ⟹ x ^ n ∈ aform_err e (power_aform_err p X n)›*) case n: 3 (*‹2 ≤ n›*) define x0 where "x0 = (fst (fst X))" define xs where "xs = snd (fst X)" define xe where "xe = (snd X)" have [simp]: "x0 ∈ float" "xe ∈ float" using assms (*‹x ∈ aform_err e X› ‹fst (fst X) ∈ float› ‹snd X ∈ float› ‹(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}›*) (*goals: 1. ‹x0 ∈ float› 2. ‹xe ∈ float› discuss goal 1*) apply ((auto simp: x0_def (*‹x0 = fst (fst X)›*) xe_def (*‹xe = snd X›*))[1]) (*discuss goal 2*) apply ((auto simp: x0_def (*‹(x0::real) = fst (fst (X::(real × real pdevs) × real))›*) xe_def (*‹(xe::real) = snd (X::(real × real pdevs) × real)›*))[1]) (*proven 2 subgoals*) . define xe' where "xe' = x - aform_val e (x0, xs)" from aform_errE[OF assms ( 1 )] (*‹¦x - aform_val e (fst X)¦ ≤ snd X›*) have xe': "¦xe'¦ ≤ xe" by (auto simp: x0_def (*‹x0 = fst (fst X)›*) xs_def (*‹xs = snd (fst X)›*) xe_def (*‹xe = snd X›*) xe'_def (*‹xe' = x - aform_val e (x0, xs)›*)) then have xe_nonneg: "0 ≤ xe" by auto define t where "t = tdev' p xs" have t: "tdev xs ≤ t" "t ∈ float" (*goals: 1. ‹tdev xs ≤ t› 2. ‹t ∈ float› discuss goal 1*) apply ((auto simp add: t_def (*‹t = tdev' p xs›*) tdev'_le (*‹?x ≤ tdev ?y ⟹ ?x ≤ tdev' ?p ?y›*))[1]) (*discuss goal 2*) apply ((auto simp add: t_def (*‹(t::real) = tdev' (p::nat) (xs::real pdevs)›*) tdev'_le (*‹(?x::?'a::executable_euclidean_space) ≤ tdev (?y::?'a::executable_euclidean_space pdevs) ⟹ ?x ≤ tdev' (?p::nat) ?y›*))[1]) (*proven 2 subgoals*) . then have t_nonneg: "0 ≤ t" using tdev_nonneg[of xs] (*‹0 ≤ tdev xs›*) by arith note t_pdevs = abs_pdevs_val_le_tdev[OF e, THEN order_trans, OF t ( 1 )] (*‹¦pdevs_val e xs¦ ≤ t›*) have rewr1: "{..n} = (insert 0 (insert 1 {2..n}))" using n (*‹(2::nat) ≤ (n::nat)›*) by auto have "x = (pdevs_val e xs + xe') + x0" by (simp add: xe'_def (*‹xe' = x - aform_val e (x0, xs)›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) also (*calculation: ‹x = pdevs_val e xs + xe' + x0›*) have "… ^ n = x0 ^ n + n * x0 ^ (n - Suc 0) * pdevs_val e xs + (n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))" (is "_ = _ + ?err") apply (subst binomial_ring (*‹(?a + ?b) ^ ?n = (∑k≤?n. of_nat (?n choose k) * ?a ^ k * ?b ^ (?n - k))›*)) (*goal: ‹(pdevs_val e xs + xe' + x0) ^ n = x0 ^ n + real n * x0 ^ (n - Suc 0) * pdevs_val e xs + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) unfolding rewr1 (*goal: ‹(∑k∈insert 0 (insert 1 {2..n}). real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)) = x0 ^ n + real n * x0 ^ (n - Suc 0) * pdevs_val e xs + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) using n (*‹2 ≤ n›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) also (*calculation: ‹x ^ n = x0 ^ n + real n * x0 ^ (n - Suc 0) * pdevs_val e xs + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) let ?ERR = "(Num (of_nat n) * Num (float_of xe) * Abs (Num (float_of x0)) ^⇩e (n - 1) + (Sum⇩e (λk. Num (of_nat (n choose k)) * Abs (Num (float_of x0)) ^⇩e (n - k) * (Num (float_of xe) + Num (float_of t)) ^⇩e k) [2..<Suc n]))" define err where "err = the (approx p ?ERR [])" define ERR where "ERR = upper err" have ERR: "abs ?err ≤ ERR" proof (-) (*goal: ‹¦real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k))¦ ≤ real_of_float ERR›*) have err_aerr: "abs (?err) ≤ n * xe * abs x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (t + xe) ^ k * abs x0 ^ (n - k))" (is "_ ≤ ?aerr") by (auto simp: abs_mult (*‹¦(?a::?'a::idom_abs_sgn) * (?b::?'a::idom_abs_sgn)¦ = ¦?a¦ * ¦?b¦›*) power_abs (*‹¦(?a::?'a::linordered_idom) ^ (?n::nat)¦ = ¦?a¦ ^ ?n›*) intro!: sum_mono (*‹(⋀i::?'b::type. i ∈ (?K::?'b::type set) ⟹ (?f::?'b::type ⇒ ?'a::ordered_comm_monoid_add) i ≤ (?g::?'b::type ⇒ ?'a::ordered_comm_monoid_add) i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) mult_mono (*‹⟦(?a::?'a::ordered_semiring) ≤ (?b::?'a::ordered_semiring); (?c::?'a::ordered_semiring) ≤ (?d::?'a::ordered_semiring); (0::?'a::ordered_semiring) ≤ ?b; (0::?'a::ordered_semiring) ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) power_mono (*‹⟦(?a::?'a::linordered_semidom) ≤ (?b::?'a::linordered_semidom); (0::?'a::linordered_semidom) ≤ ?a⟧ ⟹ ?a ^ (?n::nat) ≤ ?b ^ ?n›*) xe' (*‹¦xe'::real¦ ≤ (xe::real)›*) mult_nonneg_nonneg (*‹⟦(0::?'a::ordered_semiring_0) ≤ (?a::?'a::ordered_semiring_0); (0::?'a::ordered_semiring_0) ≤ (?b::?'a::ordered_semiring_0)⟧ ⟹ (0::?'a::ordered_semiring_0) ≤ ?a * ?b›*) zero_le_power (*‹(0::?'a::linordered_semidom) ≤ (?a::?'a::linordered_semidom) ⟹ (0::?'a::linordered_semidom) ≤ ?a ^ (?n::nat)›*) t_nonneg (*‹(0::real) ≤ (t::real)›*) xe_nonneg (*‹(0::real) ≤ (xe::real)›*) add_nonneg_nonneg (*‹⟦(0::?'a::ordered_comm_monoid_add) ≤ (?a::?'a::ordered_comm_monoid_add); (0::?'a::ordered_comm_monoid_add) ≤ (?b::?'a::ordered_comm_monoid_add)⟧ ⟹ (0::?'a::ordered_comm_monoid_add) ≤ ?a + ?b›*) sum_abs[THEN order_trans] (*‹(∑i::?'a1::type∈(?A1::?'a1::type set). ¦(?f1::?'a1::type ⇒ ?'b1::ordered_ab_group_add_abs) i¦) ≤ (?z::?'b1::ordered_ab_group_add_abs) ⟹ ¦sum ?f1 ?A1¦ ≤ ?z›*) abs_triangle_ineq[THEN order_trans] (*‹¦?a1::?'a1::ordered_ab_group_add_abs¦ + ¦?b1::?'a1::ordered_ab_group_add_abs¦ ≤ (?z::?'a1::ordered_ab_group_add_abs) ⟹ ¦?a1 + ?b1¦ ≤ ?z›*) add_mono (*‹⟦(?a::?'a::ordered_ab_semigroup_add) ≤ (?b::?'a::ordered_ab_semigroup_add); (?c::?'a::ordered_ab_semigroup_add) ≤ (?d::?'a::ordered_ab_semigroup_add)⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) t_pdevs (*‹¦pdevs_val (e::nat ⇒ real) (xs::real pdevs)¦ ≤ (t::real)›*)) also (*calculation: ‹¦real (n::nat) * (xe'::real) * (x0::real) ^ (n - Suc (0::nat)) + (∑k::nat = 2::nat..n. real (n choose k) * (pdevs_val (e::nat ⇒ real) (xs::real pdevs) + xe') ^ k * x0 ^ (n - k))¦ ≤ real n * (xe::real) * ¦x0¦ ^ (n - Suc (0::nat)) + (∑k::nat = 2::nat..n. real (n choose k) * ((t::real) + xe) ^ k * ¦x0¦ ^ (n - k))›*) have rewr: "{2 .. n} = {2 ..<Suc n}" using n (*‹2 ≤ n›*) by auto have "plain_floatarith 0 ?ERR" by (auto simp add: zero_floatarith_def (*‹0 = Num 0›*) plain_floatarith_Sum⇩e (*‹plain_floatarith ?n (Sum⇩e ?f ?xs) = list_all (λi. plain_floatarith ?n (?f i)) ?xs›*) times_floatarith_def (*‹?f * ?g = Mult ?f ?g›*) plus_floatarith_def (*‹?f + ?g = Add ?f ?g›*) intro!: list_allI (*‹(⋀x. x ∈ set ?xs ⟹ ?P x) ⟹ list_all ?P ?xs›*)) from plain_floatarith_approx[OF this, of p] (*‹interpret_floatarith (Num (of_nat n) * Num (float_of xe) * Power (Abs (Num (float_of x0))) (n - 1) + Sum⇩e (λk. Num (of_nat (n choose k)) * Power (Abs (Num (float_of x0))) (n - k) * Power (Num (float_of xe) + Num (float_of t)) k) [2..<Suc n]) [] ∈⇩r the (approx p (Num (of_nat n) * Num (float_of xe) * Power (Abs (Num (float_of x0))) (n - 1) + Sum⇩e (λk. Num (of_nat (n choose k)) * Power (Abs (Num (float_of x0))) (n - k) * Power (Num (float_of xe) + Num (float_of t)) k) [2..<Suc n]) [])›*) have "ERR ≥ ?aerr" using n (*‹2 ≤ n›*) by (auto simp: set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) err_def (*‹err = the (approx p (Num (of_nat n) * Num (float_of xe) * Power (Abs (Num (float_of x0))) (n - 1) + Sum⇩e (λk. Num (of_nat (n choose k)) * Power (Abs (Num (float_of x0))) (n - k) * Power (Num (float_of xe) + Num (float_of t)) k) [2..<Suc n]) [])›*) ERR_def (*‹ERR = upper err›*) sum_list_distinct_conv_sum_set (*‹distinct ?xs ⟹ sum_list (map ?f ?xs) = sum ?f (set ?xs)›*) rewr (*‹{2..n} = {2..<Suc n}›*) t (*‹tdev xs ≤ t› ‹t ∈ float›*) x0_def (*‹x0 = fst (fst X)›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) finally (*calculation: ‹¦real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k))¦ ≤ real_of_float ERR›*) show "?thesis" (*goal: ‹¦real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k))¦ ≤ real_of_float ERR›*) . qed let ?x0n = "Num (float_of x0) ^⇩e n" define C where "C = the (approx p ?x0n [])" have "plain_floatarith 0 ?x0n" by simp from plain_floatarith_approx[OF this, of p] (*‹interpret_floatarith (Power (Num (float_of x0)) n) [] ∈⇩r the (approx p (Power (Num (float_of x0)) n) [])›*) have C: "x0 ^ n ∈ {lower C .. upper C}" by (auto simp: C_def (*‹C = the (approx p (Power (Num (float_of x0)) n) [])›*) x0_def (*‹x0 = fst (fst X)›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*)) define c where "c = fst (mid_err C)" define ce where "ce = snd (mid_err C)" define ce' where "ce' = x0 ^ n - c" have ce': "abs (ce') ≤ ce" using C (*‹x0 ^ n ∈ {real_of_float (lower C)..real_of_float (upper C)}›*) by (auto simp: ce'_def (*‹(ce'::real) = (x0::real) ^ (n::nat) - (c::real)›*) c_def (*‹(c::real) = fst (mid_err (C::float interval))›*) ce_def (*‹(ce::real) = snd (mid_err (C::float interval))›*) abs_diff_le_iff (*‹(¦(?x::?'a) - (?a::?'a)¦ ≤ (?r::?'a)) = (?a - ?r ≤ ?x ∧ ?x ≤ ?a + ?r)›*) mid_err_def (*‹mid_err (?ivl::float interval) = (real_of_float (lower ?ivl + upper ?ivl) / (2::real), real_of_float (upper ?ivl - lower ?ivl) / (2::real))›*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*)) have "x0 ^ n = c + ce'" by (simp add: ce'_def (*‹ce' = x0 ^ n - c›*)) also (*calculation: ‹x ^ n = c + ce' + real n * x0 ^ (n - Suc 0) * pdevs_val e xs + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) let ?NX = "(Num (of_nat n) * (Num (float_of x0) ^⇩e (n - 1)))" define NX where "NX = the (approx p ?NX [])" have "plain_floatarith 0 ?NX" by (simp add: times_floatarith_def (*‹?f * ?g = Mult ?f ?g›*)) from plain_floatarith_approx[OF this, of p] (*‹interpret_floatarith (Num (of_nat n) * Power (Num (float_of x0)) (n - 1)) [] ∈⇩r the (approx p (Num (of_nat n) * Power (Num (float_of x0)) (n - 1)) [])›*) have NX: "n * x0 ^ (n - 1) ∈ {lower NX .. upper NX}" by (auto simp: NX_def (*‹(NX::float interval) = the (approx (p::nat) (Num (of_nat (n::nat)) * Power (Num (float_of (x0::real))) (n - (1::nat))) [])›*) x0_def (*‹(x0::real) = fst (fst (X::(real × real pdevs) × real))›*) set_of_eq (*‹set_of (?x::?'a interval) = {lower ?x..upper ?x}›*)) define nx where "nx = fst (mid_err NX)" define nxe where "nxe = snd (mid_err NX)" define nx' where "nx' = n * x0 ^ (n - 1) - nx" define Ye where "Ye = truncate_up p (nxe * t)" have Ye: "Ye ≥ nxe * t" by (auto simp: Ye_def (*‹Ye = truncate_up p (nxe * t)›*) truncate_up_le (*‹?x ≤ ?y ⟹ ?x ≤ truncate_up ?prec ?y›*)) have nx: "abs (nx') ≤ nxe" "0 ≤ nxe" using NX (*‹real n * x0 ^ (n - 1) ∈ {real_of_float (lower NX)..real_of_float (upper NX)}›*) apply - (*goals: 1. ‹real (n::nat) * (x0::real) ^ (n - (1::nat)) ∈ {real_of_float (lower (NX::float interval))..real_of_float (upper NX)} ⟹ ¦nx'::real¦ ≤ (nxe::real)› 2. ‹real (n::nat) * (x0::real) ^ (n - (1::nat)) ∈ {real_of_float (lower (NX::float interval))..real_of_float (upper NX)} ⟹ (0::real) ≤ (nxe::real)› discuss goal 1*) apply ((auto simp: nx_def (*‹(nx::real) = fst (mid_err (NX::float interval))›*) nxe_def (*‹(nxe::real) = snd (mid_err (NX::float interval))›*) abs_diff_le_iff (*‹(¦(?x::?'a) - (?a::?'a)¦ ≤ (?r::?'a)) = (?a - ?r ≤ ?x ∧ ?x ≤ ?a + ?r)›*) mid_err_def (*‹mid_err (?ivl::float interval) = (real_of_float (lower ?ivl + upper ?ivl) / (2::real), real_of_float (upper ?ivl - lower ?ivl) / (2::real))›*) divide_simps (*‹inverse (?a::?'a) = (1::?'a) / ?a› ‹(?a::?'a) + (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z + ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (?a + ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) + (?b::?'a) = (if ?z = (0::?'a) then ?b else (- ?a + ?b * ?z) / ?z)› ‹(?a::?'a) - (?b::?'a) / (?z::?'a) = (if ?z = (0::?'a) then ?a else (?a * ?z - ?b) / ?z)› ‹(?a::?'a) / (?z::?'a) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (?a - ?b * ?z) / ?z)› ‹- ((?a::?'a) / (?z::?'a)) - (?b::?'a) = (if ?z = (0::?'a) then - ?b else (- ?a - ?b * ?z) / ?z)› ‹((?b::?'a) / (?c::?'a) = (?a::?'a)) = (if ?c ≠ (0::?'a) then ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = (?b::?'a) / (?c::?'a)) = (if ?c ≠ (0::?'a) then ?a * ?c = ?b else ?a = (0::?'a))› ‹(- ((?b::?'a) / (?c::?'a)) = (?a::?'a)) = (if ?c ≠ (0::?'a) then - ?b = ?a * ?c else ?a = (0::?'a))› ‹((?a::?'a) = - ((?b::?'a) / (?c::?'a))) = (if ?c ≠ (0::?'a) then ?a * ?c = - ?b else ?a = (0::?'a))› ‹((?a::?'a) ≤ (?b::?'a) / (?c::?'a)) = (if (0::?'a) < ?c then ?a * ?c ≤ ?b else if ?c < (0::?'a) then ?b ≤ ?a * ?c else ?a ≤ (0::?'a))› and more 13 facts*) nx'_def (*‹(nx'::real) = real (n::nat) * (x0::real) ^ (n - (1::nat)) - (nx::real)›*))[1]) (*discuss goal 2*) apply ((auto simp: nx_def (*‹nx = fst (mid_err NX)›*) nxe_def (*‹nxe = snd (mid_err NX)›*) abs_diff_le_iff (*‹(¦?x - ?a¦ ≤ ?r) = (?a - ?r ≤ ?x ∧ ?x ≤ ?a + ?r)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*) nx'_def (*‹nx' = real n * x0 ^ (n - 1) - nx›*))[1]) (*proven 2 subgoals*) . have Ye: "abs (nx' * pdevs_val e xs) ≤ Ye" by (auto simp: Ye_def (*‹(Ye::real) = truncate_up (p::nat) ((nxe::real) * (t::real))›*) abs_mult (*‹¦(?a::?'a) * (?b::?'a)¦ = ¦?a¦ * ¦?b¦›*) intro!: truncate_up_le (*‹(?x::real) ≤ (?y::real) ⟹ ?x ≤ truncate_up (?prec::nat) ?y›*) mult_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (?c::?'a) ≤ (?d::?'a); (0::?'a) ≤ ?b; (0::?'a) ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) nx (*‹¦nx'::real¦ ≤ (nxe::real)› ‹(0::real) ≤ (nxe::real)›*) t_pdevs (*‹¦pdevs_val (e::nat ⇒ real) (xs::real pdevs)¦ ≤ (t::real)›*)) have "n * x0 ^ (n - Suc 0) = nx + nx'" by (simp add: nx'_def (*‹nx' = real n * x0 ^ (n - 1) - nx›*)) also (*calculation: ‹x ^ n = c + ce' + (nx + nx') * pdevs_val e xs + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) define Y where "Y = scaleR_pdevs nx xs" have Y: "pdevs_val e Y = nx * pdevs_val e xs" by (simp add: Y_def (*‹Y = scaleR_pdevs nx xs›*)) have "(nx + nx') * pdevs_val e xs = pdevs_val e Y + nx' * pdevs_val e xs" unfolding Y (*goal: ‹((nx::real) + (nx'::real)) * pdevs_val (e::nat ⇒ real) (xs::real pdevs) = nx * pdevs_val e xs + nx' * pdevs_val e xs›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) also (*calculation: ‹x ^ n = c + ce' + (pdevs_val e Y + nx' * pdevs_val e xs) + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) define Y' where "Y' = fst (trunc_bound_pdevs p Y)" define Y_err where "Y_err = snd (trunc_bound_pdevs p Y)" have Y_err: "abs (- pdevs_val e (trunc_err_pdevs p Y)) ≤ Y_err" by (auto simp: Y_err_def (*‹Y_err = snd (trunc_bound_pdevs p Y)›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) abs_pdevs_val_le_tdev' (*‹?e ∈ UNIV → {- 1..1} ⟹ ¦pdevs_val ?e ?y¦ ≤ tdev' ?p ?y›*) e (*‹e ∈ UNIV → {- 1..1}›*)) have "pdevs_val e Y = pdevs_val e Y' + - pdevs_val e (trunc_err_pdevs p Y)" by (simp add: Y'_def (*‹(Y'::real pdevs) = fst (trunc_bound_pdevs (p::nat) (Y::real pdevs))›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs (?p::nat) (?x::?'a pdevs) = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) pdevs_val_trunc_err_pdevs (*‹pdevs_val (?e::nat ⇒ real) (trunc_err_pdevs (?p::nat) (?X::?'b pdevs)) = pdevs_val ?e (trunc_pdevs ?p ?X) - pdevs_val ?e ?X›*)) finally (*calculation: ‹(x::real) ^ (n::nat) = (c::real) + (ce'::real) + (pdevs_val (e::nat ⇒ real) (Y'::real pdevs) + - pdevs_val e (trunc_err_pdevs (p::nat) (Y::real pdevs)) + (nx'::real) * pdevs_val e (xs::real pdevs)) + (real n * (xe'::real) * (x0::real) ^ (n - Suc (0::nat)) + (∑k::nat = 2::nat..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))›*) have "¦x ^ n - aform_val e (c, Y') ¦ = ¦ce' + - pdevs_val e (trunc_err_pdevs p Y) + nx' * pdevs_val e xs + ?err¦" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*)) also (*calculation: ‹¦x ^ n - aform_val e (c, Y')¦ = ¦ce' + - pdevs_val e (trunc_err_pdevs p Y) + nx' * pdevs_val e xs + (real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k)))¦›*) have "… ≤ ce + Y_err + Ye + ERR" by (intro ERR (*‹¦real n * xe' * x0 ^ (n - Suc 0) + (∑k = 2..n. real (n choose k) * (pdevs_val e xs + xe') ^ k * x0 ^ (n - k))¦ ≤ real_of_float ERR›*) abs_triangle_ineq[THEN order_trans] (*‹¦?a1¦ + ¦?b1¦ ≤ ?z ⟹ ¦?a1 + ?b1¦ ≤ ?z›*) add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) ce' (*‹¦ce'¦ ≤ ce›*) Ye (*‹¦nx' * pdevs_val e xs¦ ≤ Ye›*) Y_err (*‹¦- pdevs_val e (trunc_err_pdevs p Y)¦ ≤ Y_err›*)) also (*calculation: ‹¦x ^ n - aform_val e (c, Y')¦ ≤ ce + Y_err + Ye + real_of_float ERR›*) have "… ≤ sum_list' p [ce, Y_err, Ye, real_of_float ERR]" by (auto intro!: sum_list'_sum_list_le (*‹?y ≤ sum_list ?xs ⟹ ?y ≤ sum_list' ?p ?xs›*)) finally (*calculation: ‹¦(x::real) ^ (n::nat) - aform_val (e::nat ⇒ real) (c::real, Y'::real pdevs)¦ ≤ sum_list' (p::nat) [ce::real, Y_err::real, Ye::real, real_of_float (ERR::float)]›*) show "?thesis" (*goal: ‹x ^ n ∈ aform_err e (power_aform_err p X n)›*) using n (*‹2 ≤ n›*) apply (intro aform_errI (*‹¦?x - aform_val ?e (fst ?Xe)¦ ≤ snd ?Xe ⟹ ?x ∈ aform_err ?e ?Xe›*)) (*goal: ‹x ^ n ∈ aform_err e (power_aform_err p X n)›*) by (auto simp: power_aform_err_def (*‹power_aform_err (?p::nat) (?X::(real × real pdevs) × real) (?n::nat) = (if ?n = (0::nat) then ((1::real, zero_pdevs), 0::real) else if ?n = (1::nat) then ?X else let x0::float = float_of (fst (fst ?X)); xs::real pdevs = snd (fst ?X); xe::float = float_of (snd ?X); C::float interval = the (approx ?p (Power (Num x0) ?n) []); (c::real, ce::real) = mid_err C; NX::float interval = the (approx ?p (Num (of_nat ?n) * Power (Num x0) (?n - (1::nat))) []); (nx::real, nxe::real) = mid_err NX; Y::real pdevs = scaleR_pdevs nx xs; (Y'::real pdevs, Y_err::real) = trunc_bound_pdevs ?p Y; t::real = tdev' ?p xs; Ye::real = truncate_up ?p (nxe * t); err::float interval = the (approx ?p (Num (of_nat ?n) * Num xe * Power (Abs (Num x0)) (?n - (1::nat)) + Sum⇩e (λk::nat. Num (of_nat (?n choose k)) * Power (Abs (Num x0)) (?n - k) * Power (Num xe + Num (float_of t)) k) [2::nat..<Suc ?n]) []); ERR::float = upper err in ((c, Y'), sum_list' ?p [ce, Y_err, Ye, real_of_float ERR]))›*) c_def (*‹(c::real) = fst (mid_err (C::float interval))›*) Y'_def (*‹(Y'::real pdevs) = fst (trunc_bound_pdevs (p::nat) (Y::real pdevs))›*) C_def (*‹(C::float interval) = the (approx (p::nat) (Power (Num (float_of (x0::real))) (n::nat)) [])›*) Y_def (*‹(Y::real pdevs) = scaleR_pdevs (nx::real) (xs::real pdevs)›*) ERR_def (*‹(ERR::float) = upper (err::float interval)›*) x0_def (*‹(x0::real) = fst (fst (X::(real × real pdevs) × real))›*) nx_def (*‹(nx::real) = fst (mid_err (NX::float interval))›*) xs_def (*‹(xs::real pdevs) = snd (fst (X::(real × real pdevs) × real))›*) NX_def (*‹(NX::float interval) = the (approx (p::nat) (Num (of_nat (n::nat)) * Power (Num (float_of (x0::real))) (n - (1::nat))) [])›*) ce_def (*‹(ce::real) = snd (mid_err (C::float interval))›*) Y_err_def (*‹(Y_err::real) = snd (trunc_bound_pdevs (p::nat) (Y::real pdevs))›*) Ye_def (*‹(Ye::real) = truncate_up (p::nat) ((nxe::real) * (t::real))›*) xe_def (*‹(xe::real) = snd (X::(real × real pdevs) × real)›*) nxe_def (*‹(nxe::real) = snd (mid_err (NX::float interval))›*) t_def (*‹(t::real) = tdev' (p::nat) (xs::real pdevs)›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) set_of_eq (*‹set_of (?x::?'a interval) = {lower ?x..upper ?x}›*) err_def (*‹(err::float interval) = the (approx (p::nat) (Num (of_nat (n::nat)) * Num (float_of (xe::real)) * Power (Abs (Num (float_of (x0::real)))) (n - (1::nat)) + Sum⇩e (λk::nat. Num (of_nat (n choose k)) * Power (Abs (Num (float_of x0))) (n - k) * Power (Num (float_of xe) + Num (float_of (t::real))) k) [2::nat..<Suc n]) [])›*)) qed qed definition [code_abbrev]: "is_float r ⟷ r ∈ float" lemma [code]: "is_float (real_of_float f) = True" by (auto simp: is_float_def (*‹is_float (?r::real) = (?r ∈ float)›*)) definition "powr_aform_err p X A = ( if Inf_aform_err p X > 0 then do { L ← ln_aform_err p X; exp_aform_err p (mult_aform' p A L) } else approx_bin p (powr_float_interval p) X A)" lemma interval_extension_powr: "interval_extension2 (powr_float_interval p) (powr)" using powr_float_interval_eqI[of p] (*‹⟦powr_float_interval p ?X ?Y = Some ?IVL; ?x ∈⇩r ?X; ?y ∈⇩r ?Y⟧ ⟹ ?x powr ?y ∈⇩r ?IVL›*) by (auto simp: interval_extension2_def (*‹interval_extension2 ?F ?f = (∀ivl1 ivl2 ivl. ?F ivl1 ivl2 = Some ivl ⟶ (∀x y. x ∈⇩r ivl1 ⟶ y ∈⇩r ivl2 ⟶ ?f x y ∈⇩r ivl))›*)) theorem powr_aform_err: assumes x: "x ∈ aform_err e X" assumes a: "a ∈ aform_err e A" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes Y: "powr_aform_err p X A = Some Y" shows "x powr a ∈ aform_err e Y" proof (cases) (*goals: 1. ‹?P ⟹ x powr a ∈ aform_err e Y› 2. ‹¬ ?P ⟹ x powr a ∈ aform_err e Y›*) assume pos: "Inf_aform_err p X > 0" (*‹(0::float) < Inf_aform_err (p::nat) (X::(real × real pdevs) × real)›*) with Inf_Sup_aform_err[OF e, of X p] (*‹aform_err e X ⊆ {real_of_float (Inf_aform_err p X)..real_of_float (Sup_aform_err p X)}›*) x (*‹x ∈ aform_err e X›*) have "x > 0" by auto then have "x powr a = exp (a * ln x)" by (simp add: powr_def (*‹?x powr ?a ≡ if ?x = 0 then 0 else exp (?a * ln ?x)›*)) also (*calculation: ‹x powr a = exp (a * ln x)›*) from pos (*‹(0::float) < Inf_aform_err (p::nat) (X::(real × real pdevs) × real)›*) obtain L where L: "ln_aform_err p X = Some L" and E: "exp_aform_err p (mult_aform' p A L) = Some Y" (*goal: ‹(⋀L. ⟦ln_aform_err p X = Some L; exp_aform_err p (mult_aform' p A L) = Some Y⟧ ⟹ thesis) ⟹ thesis›*) using Y (*‹powr_aform_err p X A = Some Y›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) powr_aform_err_def (*‹powr_aform_err ?p ?X ?A = (if 0 < Inf_aform_err ?p ?X then ln_aform_err ?p ?X ⤜ (λL. exp_aform_err ?p (mult_aform' ?p ?A L)) else approx_bin ?p (powr_float_interval ?p) ?X ?A)›*)) from ln_aform_err[OF x L e] (*‹ln x ∈ aform_err e L›*) have "ln x ∈ aform_err e L" . from mult_aform'E[OF e a this] (*‹a * ln x ∈ aform_err e (mult_aform' ?p A L)›*) have "a * ln x ∈ aform_err e (mult_aform' p A L)" . from exp_aform_err[OF this E e] (*‹exp (a * ln x) ∈ aform_err e Y›*) have "exp (a * ln x) ∈ aform_err e Y" . finally (*calculation: ‹x powr a ∈ aform_err e Y›*) show "?thesis" (*goal: ‹x powr a ∈ aform_err e Y›*) . next (*goal: ‹¬ 0 < Inf_aform_err p X ⟹ x powr a ∈ aform_err e Y›*) from x (*‹x ∈ aform_err e X›*) a (*‹a ∈ aform_err e A›*) have xa: "x ∈ aform_err e (fst X, snd X)" "a ∈ aform_err e (fst A, snd A)" apply - (*goals: 1. ‹⟦x ∈ aform_err e X; a ∈ aform_err e A⟧ ⟹ x ∈ aform_err e (fst X, snd X)› 2. ‹⟦x ∈ aform_err e X; a ∈ aform_err e A⟧ ⟹ a ∈ aform_err e (fst A, snd A)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . assume "¬ Inf_aform_err p X > 0" (*‹¬ (0::float) < Inf_aform_err (p::nat) (X::(real × real pdevs) × real)›*) then have "approx_bin p (powr_float_interval p) (fst X, snd X) (fst A, snd A) = Some Y" using Y (*‹powr_aform_err p X A = Some Y›*) by (auto simp: powr_aform_err_def (*‹powr_aform_err ?p ?X ?A = (if 0 < Inf_aform_err ?p ?X then ln_aform_err ?p ?X ⤜ (λL. exp_aform_err ?p (mult_aform' ?p ?A L)) else approx_bin ?p (powr_float_interval ?p) ?X ?A)›*)) from approx_binE[OF interval_extension_powr xa this e] (*‹(x::real) powr (a::real) ∈ aform_err (e::nat ⇒ real) (Y::(real × real pdevs) × real)›*) show "x powr a ∈ aform_err e Y" . qed fun approx_floatarith :: "nat ⇒ floatarith ⇒ aform_err list ⇒ (aform_err) option" where "approx_floatarith p (Add a b) vs = do { a1 ← approx_floatarith p a vs; a2 ← approx_floatarith p b vs; Some (add_aform' p a1 a2) }" | "approx_floatarith p (Mult a b) vs = do { a1 ← approx_floatarith p a vs; a2 ← approx_floatarith p b vs; Some (mult_aform' p a1 a2) }" | "approx_floatarith p (Inverse a) vs = do { a ← approx_floatarith p a vs; inverse_aform_err p a }" | "approx_floatarith p (Minus a) vs = map_option (apfst uminus_aform) (approx_floatarith p a vs)" | "approx_floatarith p (Num f) vs = Some (num_aform (real_of_float f), 0)" | "approx_floatarith p (Var i) vs = (if i < length vs then Some (vs ! i) else None)" | "approx_floatarith p (Abs a) vs = do { r ← approx_floatarith p a vs; let ivl = ivl_of_aform_err p r; let i = lower ivl; let s = upper ivl; if i > 0 then Some r else if s < 0 then Some (apfst uminus_aform r) else do { Some (ivl_err (real_interval (abs_interval ivl))) } }" | "approx_floatarith p (Min a b) vs = do { a1 ← approx_floatarith p a vs; a2 ← approx_floatarith p b vs; Some (min_aform_err p a1 a2) }" | "approx_floatarith p (Max a b) vs = do { a1 ← approx_floatarith p a vs; a2 ← approx_floatarith p b vs; Some (max_aform_err p a1 a2) }" | "approx_floatarith p (Floor a) vs = approx_un p (λivl. Some (floor_float_interval ivl)) (approx_floatarith p a vs)" | "approx_floatarith p (Cos a) vs = do { a ← approx_floatarith p a vs; cos_aform_err p a }" | "approx_floatarith p Pi vs = Some (ivl_err (real_interval (pi_float_interval p)))" | "approx_floatarith p (Sqrt a) vs = do { a ← approx_floatarith p a vs; sqrt_aform_err p a }" | "approx_floatarith p (Ln a) vs = do { a ← approx_floatarith p a vs; ln_aform_err p a }" | "approx_floatarith p (Arctan a) vs = do { a ← approx_floatarith p a vs; arctan_aform_err p a }" | "approx_floatarith p (Exp a) vs = do { a ← approx_floatarith p a vs; exp_aform_err p a }" | "approx_floatarith p (Power a n) vs = do { ((a, as), e) ← approx_floatarith p a vs; if is_float a ∧ is_float e then Some (power_aform_err p ((a, as), e) n) else None }" | "approx_floatarith p (Powr a b) vs = do { ae1 ← approx_floatarith p a vs; ae2 ← approx_floatarith p b vs; powr_aform_err p ae1 ae2 }" lemma uminus_aform_uminus_aform[simp]: "uminus_aform (uminus_aform z) = (z::'a::real_vector aform)" sorry lemma degree_aform_inverse_aform': "degree_aform X ≤ n ⟹ degree_aform (fst (inverse_aform' p X)) ≤ n" unfolding inverse_aform'_def (*goal: ‹degree_aform (X::real × real pdevs) ≤ (n::nat) ⟹ degree_aform_err (let l::real = Inf_aform' (p::nat) X; u::real = Sup_aform' p X; a::real = min ¦l¦ ¦u¦; b::real = max ¦l¦ ¦u¦; sq::real = truncate_up p (b * b); alpha::real = - real_divl p (1::real) sq; dmax::real = truncate_up p (real_divr p (1::real) a - alpha * a); dmin::real = truncate_down p (real_divl p (1::real) b - alpha * b); zeta'::real = truncate_up p ((dmin + dmax) / (2::real)); zeta::real = if l < (0::real) then - zeta' else zeta'; delta::real = truncate_up p (zeta - dmin); res1::real × real = trunc_bound_eucl p (alpha * fst X); res2::real × real = trunc_bound_eucl p (fst res1 + zeta); zs::real pdevs × real = trunc_bound_pdevs p (scaleR_pdevs alpha (snd X)) in ((fst res2, fst zs), sum_list' p [delta, snd res1, snd res2, snd zs])) ≤ n›*) by (auto simp: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs (?p::nat) (?x::?'a::executable_euclidean_space pdevs) = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) intro!: degree_pdev_upd_le (*‹degree (?X::?'a::real_vector pdevs) ≤ (?n::nat) ⟹ degree (pdev_upd ?X ?n (?x::?'a::real_vector)) ≤ Suc ?n›*) degree_trunc_pdevs_le (*‹degree (?X::?'a::executable_euclidean_space pdevs) ≤ (?n::nat) ⟹ degree (trunc_pdevs (?p::nat) ?X) ≤ ?n›*)) lemma degree_aform_inverse_aform: assumes "inverse_aform p X = Some Y" assumes "degree_aform X ≤ n" shows "degree_aform (fst Y) ≤ n" using assms (*‹inverse_aform p X = Some Y› ‹degree_aform X ≤ n›*) by (auto simp: inverse_aform_def (*‹inverse_aform ?p ?a = (let l = Inf_aform' ?p ?a; u = Sup_aform' ?p ?a in if l ≤ 0 ∧ 0 ≤ u then None else if l ≤ 0 then Some (apfst uminus_aform (inverse_aform' ?p (uminus_aform ?a))) else Some (inverse_aform' ?p ?a))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) degree_aform_inverse_aform' (*‹degree_aform ?X ≤ ?n ⟹ degree_aform_err (inverse_aform' ?p ?X) ≤ ?n›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) lemma degree_aform_ivl_err[simp]: "degree_aform (fst (ivl_err a)) = 0" by (auto simp: ivl_err_def (*‹ivl_err ?ivl ≡ (((upper ?ivl + lower ?ivl) / 2, zero_pdevs), (upper ?ivl - lower ?ivl) / 2)›*)) lemma degree_aform_approx_bin: assumes "approx_bin p ivl X Y = Some Z" assumes "degree_aform (fst X) ≤ m" assumes "degree_aform (fst Y) ≤ m" shows "degree_aform (fst Z) ≤ m" using assms (*‹approx_bin p ivl X Y = Some Z› ‹degree_aform_err X ≤ m› ‹degree_aform_err Y ≤ m›*) by (auto simp: approx_bin_def (*‹approx_bin (?p::nat) (?f::float interval ⇒ float interval ⇒ float interval option) (?rd::(real × real pdevs) × real) (?sd::(real × real pdevs) × real) = ?f (ivl_of_aform_err ?p ?rd) (ivl_of_aform_err ?p ?sd) ⤜ (λivl::float interval. Some (ivl_err (real_interval ivl)))›*) bind_eq_Some_conv (*‹((?f::?'b::type option) ⤜ (?g::?'b::type ⇒ ?'a::type option) = Some (?x::?'a::type)) = (∃y::?'b::type. ?f = Some y ∧ ?g y = Some ?x)›*) Basis_list_real_def (*‹Basis_list = [1::real]›*) intro!: order_trans[OF degree_aform_independent_from] (*‹(?d1.1::nat) + degree_aform (?X1::?'a1::real_vector × ?'a1::real_vector pdevs) ≤ (?z::nat) ⟹ degree_aform (independent_from ?d1.1 ?X1) ≤ ?z›*) order_trans[OF degree_aform_of_ivl] (*‹length Basis_list ≤ (?z::nat) ⟹ degree_aform (aform_of_ivl (?a1::?'a1::executable_euclidean_space) (?b1::?'a1::executable_euclidean_space)) ≤ ?z›*)) lemma degree_aform_approx_un: assumes "approx_un p ivl X = Some Y" assumes "case X of None ⇒ True | Some X ⇒ degree_aform (fst X) ≤ d1" shows "degree_aform (fst Y) ≤ d1" using assms (*‹approx_un p ivl X = Some Y› ‹case X of None ⇒ True | Some X ⇒ degree_aform_err X ≤ d1›*) by (auto simp: approx_un_def (*‹approx_un ?p ?f ?a = ?a ⤜ (λrd. ?f (ivl_of_aform_err ?p rd) ⤜ (λivl. Some (ivl_err (real_interval ivl))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) Basis_list_real_def (*‹Basis_list = [1]›*) intro!: order_trans[OF degree_aform_independent_from] (*‹?d1.1 + degree_aform ?X1 ≤ ?z ⟹ degree_aform (independent_from ?d1.1 ?X1) ≤ ?z›*) order_trans[OF degree_aform_of_ivl] (*‹length Basis_list ≤ ?z ⟹ degree_aform (aform_of_ivl ?a1 ?b1) ≤ ?z›*)) lemma degree_aform_num_aform[simp]: "degree_aform (num_aform x) = 0" by (auto simp: num_aform_def (*‹num_aform ?f = (?f, zero_pdevs)›*)) lemma degree_max_aform: assumes "degree_aform_err x ≤ d" assumes "degree_aform_err y ≤ d" shows "degree_aform_err (max_aform_err p x y) ≤ d" using assms (*‹degree_aform_err x ≤ d› ‹degree_aform_err y ≤ d›*) by (auto simp: max_aform_err_def (*‹max_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a2.0 else if upper ivl2 < lower ivl1 then ?a1.0 else ivl_err (real_interval (max_interval ivl1 ivl2)))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) Basis_list_real_def (*‹Basis_list = [1]›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: order_trans[OF degree_aform_independent_from] (*‹?d1.1 + degree_aform ?X1 ≤ ?z ⟹ degree_aform (independent_from ?d1.1 ?X1) ≤ ?z›*) order_trans[OF degree_aform_of_ivl] (*‹length Basis_list ≤ ?z ⟹ degree_aform (aform_of_ivl ?a1 ?b1) ≤ ?z›*)) lemma degree_min_aform: assumes "degree_aform_err x ≤ d" assumes "degree_aform_err y ≤ d" shows "degree_aform_err ((min_aform_err p x y)) ≤ d" using assms (*‹degree_aform_err x ≤ d› ‹degree_aform_err y ≤ d›*) by (auto simp: min_aform_err_def (*‹min_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a1.0 else if upper ivl2 < lower ivl1 then ?a2.0 else ivl_err (real_interval (min_interval ivl1 ivl2)))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) Basis_list_real_def (*‹Basis_list = [1]›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: order_trans[OF degree_aform_independent_from] (*‹?d1.1 + degree_aform ?X1 ≤ ?z ⟹ degree_aform (independent_from ?d1.1 ?X1) ≤ ?z›*) order_trans[OF degree_aform_of_ivl] (*‹length Basis_list ≤ ?z ⟹ degree_aform (aform_of_ivl ?a1 ?b1) ≤ ?z›*)) lemma degree_aform_acc_err: "degree_aform (fst (acc_err p X e)) ≤ d" if "degree_aform (fst X) ≤ d" using that (*‹degree_aform (fst X) ≤ d›*) by (auto simp: acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*)) lemma degree_pdev_upd_degree: assumes "degree b ≤ Suc n" assumes "degree b ≤ Suc (degree_aform_err X)" assumes "degree_aform_err X ≤ n" shows "degree (pdev_upd b (degree_aform_err X) 0) ≤ n" using assms (*‹degree b ≤ Suc n› ‹degree b ≤ Suc (degree_aform_err X)› ‹degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat)›*) by (auto intro!: degree_le (*‹∀j≥?d. pdevs_apply ?x j = 0 ⟹ degree ?x ≤ ?d›*)) lemma degree_aform_err_inverse_aform_err: assumes "inverse_aform_err p X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹inverse_aform_err p X = Some Y› ‹degree_aform_err X ≤ n›*) apply (auto simp: inverse_aform_err_def (*‹inverse_aform_err (?p::nat) (?X::(real × real pdevs) × real) = map_aform_err (inverse_aform ?p) ?p ?X›*) bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) aform_to_aform_err_def (*‹aform_to_aform_err (?X::real × real pdevs) (?n::nat) = ((fst ?X, pdev_upd (snd ?X) ?n (0::real)), ¦pdevs_apply (snd ?X) ?n¦)›*) acc_err_def (*‹acc_err (?p::nat) (?x::?'a × real) (?e::real) ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) map_aform_err_def (*‹map_aform_err (?I::real × real pdevs ⇒ ((real × real pdevs) × real) option) (?p::nat) (?X::(real × real pdevs) × real) = (let X0::real × real pdevs = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1::real × real pdevs, e1::real). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) aform_err_to_aform_def (*‹aform_err_to_aform (?X::(real × real pdevs) × real) (?n::nat) = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) intro!: degree_aform_acc_err (*‹degree_aform (fst (?X::(?'a × ?'a pdevs) × real)) ≤ (?d::nat) ⟹ degree_aform (fst (acc_err (?p::nat) ?X (?e::real))) ≤ ?d›*)) (*goal: ‹degree_aform_err Y ≤ n›*) apply (rule degree_pdev_upd_degree (*‹⟦degree ?b ≤ Suc ?n; degree ?b ≤ Suc (degree_aform_err ?X); degree_aform_err ?X ≤ ?n⟧ ⟹ degree (pdev_upd ?b (degree_aform_err ?X) 0) ≤ ?n›*)) (*goals: 1. ‹⋀(a::real) (b::real pdevs) ba::real. ⟦degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat); inverse_aform (p::nat) (fst (fst X), pdev_upd (snd (fst X)) (degree_aform_err X) (snd X)) = Some ((a, b), ba); (Y::(real × real pdevs) × real) = ((a, pdev_upd b (degree_aform_err X) (0::real)), truncate_up p (¦pdevs_apply b (degree_aform_err X)¦ + ba))⟧ ⟹ degree b ≤ Suc n› 2. ‹⋀(a::real) (b::real pdevs) ba::real. ⟦degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat); inverse_aform (p::nat) (fst (fst X), pdev_upd (snd (fst X)) (degree_aform_err X) (snd X)) = Some ((a, b), ba); (Y::(real × real pdevs) × real) = ((a, pdev_upd b (degree_aform_err X) (0::real)), truncate_up p (¦pdevs_apply b (degree_aform_err X)¦ + ba))⟧ ⟹ degree b ≤ Suc (degree_aform_err X)› 3. ‹⋀(a::real) (b::real pdevs) ba::real. ⟦degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat); inverse_aform (p::nat) (fst (fst X), pdev_upd (snd (fst X)) (degree_aform_err X) (snd X)) = Some ((a, b), ba); (Y::(real × real pdevs) × real) = ((a, pdev_upd b (degree_aform_err X) (0::real)), truncate_up p (¦pdevs_apply b (degree_aform_err X)¦ + ba))⟧ ⟹ degree_aform_err X ≤ n› discuss goal 1*) apply ((auto dest!: degree_aform_inverse_aform (*‹⟦inverse_aform ?p ?X = Some ?Y; degree_aform ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*))[1]) (*top goal: ‹⋀a b ba. ⟦degree_aform_err X ≤ n; inverse_aform p (fst (fst X), pdev_upd (snd (fst X)) (degree_aform_err X) (snd X)) = Some ((a, b), ba); Y = ((a, pdev_upd b (degree_aform_err X) 0), truncate_up p (¦pdevs_apply b (degree_aform_err X)¦ + ba))⟧ ⟹ degree b ≤ Suc n› and 2 goals remain*) apply (meson degree_pdev_upd_le (*‹degree ?X ≤ ?n ⟹ degree (pdev_upd ?X ?n ?x) ≤ Suc ?n›*) nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*) not_less_eq_eq (*‹(¬ ?m ≤ ?n) = (Suc ?n ≤ ?m)›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*discuss goal 2*) apply ((auto dest!: degree_aform_inverse_aform (*‹⟦inverse_aform (?p::nat) (?X::real × real pdevs) = Some (?Y::(real × real pdevs) × real); degree_aform ?X ≤ (?n::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?n›*))[1]) (*top goal: ‹⋀a b ba. ⟦degree_aform_err X ≤ n; inverse_aform p (fst (fst X), pdev_upd (snd (fst X)) (degree_aform_err X) (snd X)) = Some ((a, b), ba); Y = ((a, pdev_upd b (degree_aform_err X) 0), truncate_up p (¦pdevs_apply b (degree_aform_err X)¦ + ba))⟧ ⟹ degree b ≤ Suc (degree_aform_err X)› and 1 goal remains*) apply (meson degree_pdev_upd_le (*‹degree (?X::?'a::real_vector pdevs) ≤ (?n::nat) ⟹ degree (pdev_upd ?X ?n (?x::?'a::real_vector)) ≤ Suc ?n›*) nat_le_linear (*‹(?m::nat) ≤ (?n::nat) ∨ ?n ≤ ?m›*) not_less_eq_eq (*‹(¬ (?m::nat) ≤ (?n::nat)) = (Suc ?n ≤ ?m)›*) order_trans (*‹⟦(?x::?'a::preorder) ≤ (?y::?'a::preorder); ?y ≤ (?z::?'a::preorder)⟧ ⟹ ?x ≤ ?z›*)) (*discuss goal 3*) apply ((auto dest!: degree_aform_inverse_aform (*‹⟦inverse_aform ?p ?X = Some ?Y; degree_aform ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*))[1]) (*proven 3 subgoals*) . lemma degree_aform_err_affine_unop: "degree_aform_err (affine_unop p a b d X) ≤ n" if "degree_aform_err X ≤ n" using that (*‹degree_aform_err X ≤ n›*) by (auto simp: affine_unop_def (*‹affine_unop ?p ?a ?b ?d ?X = (let ((x, xs), xe) = ?X; (ax, axe) = trunc_bound_eucl ?p (?a * x); (y, ye) = trunc_bound_eucl ?p (ax + ?b); (ys, yse) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs ?p ?x = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) degree_trunc_pdevs_le (*‹degree ?X ≤ ?n ⟹ degree (trunc_pdevs ?p ?X) ≤ ?n›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) lemma degree_aform_err_min_range_mono: assumes "min_range_mono p F D l u X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹min_range_mono p F D l u X = Some Y› ‹degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat)›*) by (auto simp: min_range_mono_def (*‹min_range_mono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Min (?DF L) (?DF U)) [] ⤜ (λaivl. let a = lower aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) aform_to_aform_err_def (*‹aform_to_aform_err ?X ?n = ((fst ?X, pdev_upd (snd ?X) ?n 0), ¦pdevs_apply (snd ?X) ?n¦)›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) map_aform_err_def (*‹map_aform_err ?I ?p ?X = (let X0 = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1, e1). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) range_reduce_aform_err_def (*‹range_reduce_aform_err ?p ?X = range_reducer ?p (lower (ivl_of_aform_err ?p ?X)) ⤜ (λr. Some (add_aform' ?p ?X (ivl_err (real_interval r))))›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: degree_aform_err_affine_unop (*‹degree_aform_err ?X ≤ ?n ⟹ degree_aform_err (affine_unop ?p ?a ?b ?d ?X) ≤ ?n›*)) lemma degree_aform_err_min_range_antimono: assumes "min_range_antimono p F D l u X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹min_range_antimono p F D l u X = Some Y› ‹degree_aform_err X ≤ n›*) by (auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) aform_to_aform_err_def (*‹aform_to_aform_err ?X ?n = ((fst ?X, pdev_upd (snd ?X) ?n 0), ¦pdevs_apply (snd ?X) ?n¦)›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) map_aform_err_def (*‹map_aform_err ?I ?p ?X = (let X0 = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1, e1). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) range_reduce_aform_err_def (*‹range_reduce_aform_err ?p ?X = range_reducer ?p (lower (ivl_of_aform_err ?p ?X)) ⤜ (λr. Some (add_aform' ?p ?X (ivl_err (real_interval r))))›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: degree_aform_err_affine_unop (*‹degree_aform_err ?X ≤ ?n ⟹ degree_aform_err (affine_unop ?p ?a ?b ?d ?X) ≤ ?n›*)) lemma degree_aform_err_cos_aform_err: assumes "cos_aform_err p X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹cos_aform_err (p::nat) (X::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)› ‹degree_aform_err X ≤ n›*) apply (auto simp: cos_aform_err_def (*‹cos_aform_err ?p ?X = range_reduce_aform_err ?p ?X ⤜ (λX. let ivl = ivl_of_aform_err ?p X; l = lower ivl; u = upper ivl; L = Num l; U = Num u in if 0 ≤ l ∧ u ≤ lb_pi ?p then min_range_antimono ?p Cos (λx. Minus (Sin x)) l u X else if ub_pi ?p ≤ l ∧ u ≤ 2 * lb_pi ?p then min_range_mono ?p Cos (λx. Minus (Sin x)) l u X else Some (ivl_err (real_interval (cos_float_interval ?p ivl))))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) aform_to_aform_err_def (*‹aform_to_aform_err ?X ?n = ((fst ?X, pdev_upd (snd ?X) ?n 0), ¦pdevs_apply (snd ?X) ?n¦)›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) map_aform_err_def (*‹map_aform_err ?I ?p ?X = (let X0 = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1, e1). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) range_reduce_aform_err_def (*‹range_reduce_aform_err ?p ?X = range_reducer ?p (lower (ivl_of_aform_err ?p ?X)) ⤜ (λr. Some (add_aform' ?p ?X (ivl_err (real_interval r))))›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*) intro!: degree_aform_err_affine_unop (*‹degree_aform_err ?X ≤ ?n ⟹ degree_aform_err (affine_unop ?p ?a ?b ?d ?X) ≤ ?n›*)) (*goals: 1. ‹⋀y. ⟦degree_aform_err X ≤ n; real_of_float (ub_pi p) ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ 2 * real_of_float (lb_pi p); 0 ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ real_of_float (lb_pi p); range_reducer p (lower (ivl_of_aform_err p X)) = Some y; min_range_antimono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y⟧ ⟹ degree_aform_err Y ≤ n› 2. ‹⋀y. ⟦degree_aform_err X ≤ n; real_of_float (ub_pi p) ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ 2 * real_of_float (lb_pi p); range_reducer p (lower (ivl_of_aform_err p X)) = Some y; min_range_mono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y; ¬ real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ real_of_float (lb_pi p)⟧ ⟹ degree_aform_err Y ≤ n› 3. ‹⋀y. ⟦degree_aform_err X ≤ n; real_of_float (ub_pi p) ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ 2 * real_of_float (lb_pi p); range_reducer p (lower (ivl_of_aform_err p X)) = Some y; min_range_mono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y; ¬ 0 ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y)))))⟧ ⟹ degree_aform_err Y ≤ n› 4. ‹⋀y. ⟦degree_aform_err X ≤ n; real_of_float (ub_pi p) ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ 2 * real_of_float (lb_pi p); min_range_mono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y; range_reducer p (lower (ivl_of_aform_err p X)) = Some y; min_range_antimono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y⟧ ⟹ degree_aform_err Y ≤ n› 5. ‹⋀y. ⟦degree_aform_err X ≤ n; 0 ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ real_of_float (lb_pi p); range_reducer p (lower (ivl_of_aform_err p X)) = Some y; min_range_antimono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y; ¬ real_of_float (ub_pi p) ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y)))))⟧ ⟹ degree_aform_err Y ≤ n› 6. ‹⋀y. ⟦degree_aform_err X ≤ n; 0 ≤ real_of_float (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))); real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ real_of_float (lb_pi p); range_reducer p (lower (ivl_of_aform_err p X)) = Some y; min_range_antimono p Cos (λx. Minus (Sin x)) (lower (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) (add_aform' p X (ivl_err (real_interval y))) = Some Y; ¬ real_of_float (upper (ivl_of_aform_err p (add_aform' p X (ivl_err (real_interval y))))) ≤ 2 * real_of_float (lb_pi p)⟧ ⟹ degree_aform_err Y ≤ n› discuss goal 1*) apply (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_err_min_range_antimono (*‹⟦min_range_antimono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err ?a) = 0›*) zero_le (*‹0 ≤ ?x›*)) (*discuss goal 2*) apply (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_err_min_range_mono (*‹⟦min_range_mono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err ?a) = 0›*) zero_le (*‹0 ≤ ?x›*)) (*discuss goal 3*) apply (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_err_min_range_mono (*‹⟦min_range_mono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err ?a) = 0›*) zero_le (*‹0 ≤ ?x›*)) (*discuss goal 4*) apply (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_err_min_range_antimono (*‹⟦min_range_antimono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err ?a) = 0›*) zero_le (*‹0 ≤ ?x›*)) (*discuss goal 5*) apply (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_err_min_range_antimono (*‹⟦min_range_antimono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err ?a) = 0›*) zero_le (*‹0 ≤ ?x›*)) (*discuss goal 6*) apply (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err (?x::(real × real pdevs) × real) ≤ (?n::nat); degree_aform_err (?y::(real × real pdevs) × real) ≤ ?n⟧ ⟹ degree_aform_err (add_aform' (?p::nat) ?x ?y) ≤ ?n›*) degree_aform_err_min_range_antimono (*‹⟦min_range_antimono (?p::nat) (?F::floatarith ⇒ floatarith) (?D::floatarith ⇒ floatarith) (?l::float) (?u::float) (?X::(real × real pdevs) × real) = Some (?Y::(real × real pdevs) × real); degree_aform_err ?X ≤ (?n::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err (?a::real interval)) = (0::nat)›*) zero_le (*‹(0::?'a::canonically_ordered_monoid_add) ≤ (?x::?'a::canonically_ordered_monoid_add)›*)) (*proven 6 subgoals*) . lemma degree_aform_err_sqrt_aform_err: assumes "sqrt_aform_err p X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹sqrt_aform_err p X = Some Y› ‹degree_aform_err X ≤ n›*) apply (auto simp: sqrt_aform_err_def (*‹sqrt_aform_err ?p ?X = (let ivl = ivl_of_aform_err ?p ?X; l = lower ivl; u = upper ivl in if 0 < l then min_range_mono ?p Sqrt (λx. Half (Inverse (Sqrt x))) l u ?X else Some (ivl_err (real_interval (sqrt_float_interval ?p ivl))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goal: ‹degree_aform_err Y ≤ n›*) by (metis degree_aform_err_min_range_mono (*‹⟦min_range_mono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) lemma degree_aform_err_arctan_aform_err: assumes "arctan_aform_err p X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹arctan_aform_err (p::nat) (X::(real × real pdevs) × real) = Some (Y::(real × real pdevs) × real)› ‹degree_aform_err X ≤ n›*) apply (auto simp: arctan_aform_err_def (*‹arctan_aform_err ?p ?X = (let l = Inf_aform_err ?p ?X; u = Sup_aform_err ?p ?X in min_range_mono ?p Arctan (λx. 1 / (Num 1 + x * x)) l u ?X)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) (*goal: ‹degree_aform_err Y ≤ n›*) by (metis degree_aform_err_min_range_mono (*‹⟦min_range_mono (?p::nat) (?F::floatarith ⇒ floatarith) (?D::floatarith ⇒ floatarith) (?l::float) (?u::float) (?X::(real × real pdevs) × real) = Some (?Y::(real × real pdevs) × real); degree_aform_err ?X ≤ (?n::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) lemma degree_aform_err_exp_aform_err: assumes "exp_aform_err p X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹exp_aform_err p X = Some Y› ‹degree_aform_err X ≤ n›*) apply (auto simp: exp_aform_err_def (*‹exp_aform_err ?p ?X = (let ivl = ivl_of_aform_err ?p ?X in min_range_mono ?p Exp Exp (lower ivl) (upper ivl) ?X)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) (*goal: ‹degree_aform_err (Y::(real × real pdevs) × real) ≤ (n::nat)›*) by (metis degree_aform_err_min_range_mono (*‹⟦min_range_mono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) lemma degree_aform_err_ln_aform_err: assumes "ln_aform_err p X = Some Y" assumes "degree_aform_err X ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹ln_aform_err p X = Some Y› ‹degree_aform_err X ≤ n›*) apply (auto simp: ln_aform_err_def (*‹ln_aform_err ?p ?X = (let ivl = ivl_of_aform_err ?p ?X; l = lower ivl in if 0 < l then min_range_mono ?p Ln inverse l (upper ivl) ?X else None)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goal: ‹degree_aform_err Y ≤ n›*) by (metis degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_err_min_range_mono (*‹⟦min_range_mono ?p ?F ?D ?l ?u ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_ivl_err (*‹degree_aform_err (ivl_err ?a) = 0›*) zero_le (*‹0 ≤ ?x›*)) lemma degree_aform_err_power_aform_err: assumes "degree_aform_err X ≤ n" shows "degree_aform_err (power_aform_err p X m) ≤ n" using assms (*‹degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat)›*) by (auto simp: power_aform_err_def (*‹power_aform_err (?p::nat) (?X::(real × real pdevs) × real) (?n::nat) = (if ?n = (0::nat) then ((1::real, zero_pdevs), 0::real) else if ?n = (1::nat) then ?X else let x0::float = float_of (fst (fst ?X)); xs::real pdevs = snd (fst ?X); xe::float = float_of (snd ?X); C::float interval = the (approx ?p (Power (Num x0) ?n) []); (c::real, ce::real) = mid_err C; NX::float interval = the (approx ?p (Num (of_nat ?n) * Power (Num x0) (?n - (1::nat))) []); (nx::real, nxe::real) = mid_err NX; Y::real pdevs = scaleR_pdevs nx xs; (Y'::real pdevs, Y_err::real) = trunc_bound_pdevs ?p Y; t::real = tdev' ?p xs; Ye::real = truncate_up ?p (nxe * t); err::float interval = the (approx ?p (Num (of_nat ?n) * Num xe * Power (Abs (Num x0)) (?n - (1::nat)) + Sum⇩e (λk::nat. Num (of_nat (?n choose k)) * Power (Abs (Num x0)) (?n - k) * Power (Num xe + Num (float_of t)) k) [2::nat..<Suc ?n]) []); ERR::float = upper err in ((c, Y'), sum_list' ?p [ce, Y_err, Ye, real_of_float ERR]))›*) Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) trunc_bound_pdevs_def (*‹trunc_bound_pdevs (?p::nat) (?x::?'a::executable_euclidean_space pdevs) = (trunc_pdevs ?p ?x, tdev' ?p (trunc_err_pdevs ?p ?x))›*) degree_trunc_pdevs_le (*‹degree (?X::?'a::executable_euclidean_space pdevs) ≤ (?n::nat) ⟹ degree (trunc_pdevs (?p::nat) ?X) ≤ ?n›*) split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∀(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∄(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) lemma degree_aform_err_powr_aform_err: assumes "powr_aform_err p X Z = Some Y" assumes "degree_aform_err X ≤ n" assumes "degree_aform_err Z ≤ n" shows "degree_aform_err Y ≤ n" using assms (*‹powr_aform_err p X Z = Some Y› ‹degree_aform_err X ≤ n› ‹degree_aform_err (Z::(real × real pdevs) × real) ≤ (n::nat)›*) apply (auto simp: powr_aform_err_def (*‹powr_aform_err (?p::nat) (?X::(real × real pdevs) × real) (?A::(real × real pdevs) × real) = (if (0::float) < Inf_aform_err ?p ?X then ln_aform_err ?p ?X ⤜ (λL::(real × real pdevs) × real. exp_aform_err ?p (mult_aform' ?p ?A L)) else approx_bin ?p (powr_float_interval ?p) ?X ?A)›*) bind_eq_Some_conv (*‹((?f::?'b::type option) ⤜ (?g::?'b::type ⇒ ?'a::type option) = Some (?x::?'a::type)) = (∃y::?'b::type. ?f = Some y ∧ ?g y = Some ?x)›*) degree_aform_mult_aform' (*‹⟦degree_aform_err (?x::(real × real pdevs) × real) ≤ (?n::nat); degree_aform_err (?y::(real × real pdevs) × real) ≤ ?n⟧ ⟹ degree_aform_err (mult_aform' (?p::nat) ?x ?y) ≤ ?n›*) dest!: degree_aform_err_ln_aform_err (*‹⟦ln_aform_err (?p::nat) (?X::(real × real pdevs) × real) = Some (?Y::(real × real pdevs) × real); degree_aform_err ?X ≤ (?n::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) degree_aform_err_exp_aform_err (*‹⟦exp_aform_err (?p::nat) (?X::(real × real pdevs) × real) = Some (?Y::(real × real pdevs) × real); degree_aform_err ?X ≤ (?n::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?n›*) split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goals: 1. ‹⋀a b ba. ⟦degree_aform_err X ≤ n; degree_aform_err Z ≤ n; 0 < real_of_float (Inf_aform_err p X); degree_aform_err Y ≤ degree_aform_err (mult_aform' p Z ((a, b), ba)); degree b ≤ n⟧ ⟹ degree_aform_err Y ≤ n› 2. ‹⟦degree_aform_err X ≤ n; degree_aform_err Z ≤ n; ¬ 0 < real_of_float (Inf_aform_err p X); approx_bin p (powr_float_interval p) X Z = Some Y⟧ ⟹ degree_aform_err Y ≤ n› discuss goal 1*) apply (metis degree_aform_mult_aform' (*‹⟦degree_aform_err (?x::(real × real pdevs) × real) ≤ (?n::nat); degree_aform_err (?y::(real × real pdevs) × real) ≤ ?n⟧ ⟹ degree_aform_err (mult_aform' (?p::nat) ?x ?y) ≤ ?n›*) fst_conv (*‹fst (?x1.0::?'a, ?x2.0::?'b) = ?x1.0›*) order_trans (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y ≤ (?z::?'a)⟧ ⟹ ?x ≤ ?z›*) snd_conv (*‹snd (?x1.0::?'aa, ?x2.0::?'a) = ?x2.0›*)) (*discuss goal 2*) apply (rule degree_aform_approx_bin (*‹⟦approx_bin ?p ?ivl ?X ?Y = Some ?Z; degree_aform_err ?X ≤ ?m; degree_aform_err ?Y ≤ ?m⟧ ⟹ degree_aform_err ?Z ≤ ?m›*)) (*goals: 1. ‹⟦degree_aform_err X ≤ n; degree_aform_err Z ≤ n; ¬ 0 < real_of_float (Inf_aform_err p X); approx_bin p (powr_float_interval p) X Z = Some Y⟧ ⟹ approx_bin ?p31 ?ivl31 ?X31 ?Y31 = Some Y› 2. ‹⟦degree_aform_err X ≤ n; degree_aform_err Z ≤ n; ¬ 0 < real_of_float (Inf_aform_err p X); approx_bin p (powr_float_interval p) X Z = Some Y⟧ ⟹ degree_aform_err ?X31 ≤ n› 3. ‹⟦degree_aform_err X ≤ n; degree_aform_err Z ≤ n; ¬ 0 < real_of_float (Inf_aform_err p X); approx_bin p (powr_float_interval p) X Z = Some Y⟧ ⟹ degree_aform_err ?Y31 ≤ n› discuss goal 1*) apply assumption (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma approx_floatarith_degree: assumes "approx_floatarith p ra VS = Some X" assumes "⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d" shows "degree_aform_err X ≤ d" using assms (*‹approx_floatarith p ra VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) proof (induction ra arbitrary: X) (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Add ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Minus ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Mult ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Inverse ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Cos ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Arctan ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 13. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 14. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 15. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 16. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 17. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 18. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Add ra1 ra2) (*‹⟦approx_floatarith p ra1 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹⟦approx_floatarith (p::nat) (ra2::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real); ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Add ra1 ra2) VS = Some X› ‹(?V::(real × real pdevs) × real) ∈ set (VS::((real × real pdevs) × real) list) ⟹ degree_aform_err ?V ≤ (d::nat)›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: degree_aform_err_add_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (add_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_acc_err (*‹degree_aform (fst ?X) ≤ ?d ⟹ degree_aform (fst (acc_err ?p ?X ?e)) ≤ ?d›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Minus ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Mult ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Inverse ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Cos ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Arctan ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 13. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 14. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 15. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 16. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 17. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Minus ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Minus ra) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*)) next (*goals: 1. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Mult ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Inverse ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Cos ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Arctan ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) Pi (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 13. ‹⋀(ra::floatarith) (x2a::nat) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 14. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 15. ‹⋀(x::nat) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Var x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 16. ‹⋀(x::float) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Num x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d›*) case (Mult ra1 ra2) (*‹⟦approx_floatarith p ra1 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹⟦approx_floatarith p ra2 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith (p::nat) (Mult (ra1::floatarith) (ra2::floatarith)) (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)› ‹(?V::(real × real pdevs) × real) ∈ set (VS::((real × real pdevs) × real) list) ⟹ degree_aform_err ?V ≤ (d::nat)›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: degree_aform_mult_aform' (*‹⟦degree_aform_err ?x ≤ ?n; degree_aform_err ?y ≤ ?n⟧ ⟹ degree_aform_err (mult_aform' ?p ?x ?y) ≤ ?n›*) degree_aform_acc_err (*‹degree_aform (fst ?X) ≤ ?d ⟹ degree_aform (fst (acc_err ?p ?X ?e)) ≤ ?d›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Inverse ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Cos ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Arctan ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 13. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 14. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 15. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Inverse ra) (*‹⟦approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real); ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Inverse ra) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_inverse_aform_err (*‹⟦inverse_aform_err (?p::nat) (?X::(real × real pdevs) × real) = Some (?Y::(real × real pdevs) × real); degree_aform_err ?X ≤ (?n::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Cos ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Arctan ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) Pi (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀(ra::floatarith) (x2a::nat) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 13. ‹⋀(x::nat) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Var x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 14. ‹⋀(x::float) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Num x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d›*) case (Cos ra) (*‹⟦approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real); ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith (p::nat) (Cos (ra::floatarith)) (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_cos_aform_err (*‹⟦cos_aform_err ?p ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Arctan ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 13. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Arctan ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Arctan ra) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_arctan_aform_err (*‹⟦arctan_aform_err ?p ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Abs ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 12. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Abs ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Abs ra) VS = Some X› ‹(?V::(real × real pdevs) × real) ∈ set (VS::((real × real pdevs) × real) list) ⟹ degree_aform_err ?V ≤ (d::nat)›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) Basis_list_real_def (*‹Basis_list = [1]›*) intro!: order_trans[OF degree_aform_independent_from] (*‹?d1.1 + degree_aform ?X1 ≤ ?z ⟹ degree_aform (independent_from ?d1.1 ?X1) ≤ ?z›*) order_trans[OF degree_aform_of_ivl] (*‹length Basis_list ≤ ?z ⟹ degree_aform (aform_of_ivl ?a1 ?b1) ≤ ?z›*) degree_aform_acc_err (*‹degree_aform (fst ?X) ≤ ?d ⟹ degree_aform (fst (acc_err ?p ?X ?e)) ≤ ?d›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Max ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 11. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Max ra1 ra2) (*‹⟦approx_floatarith (p::nat) (ra1::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real); ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err ?X ≤ d› ‹⟦approx_floatarith p ra2 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Max ra1 ra2) VS = Some X› ‹(?V::(real × real pdevs) × real) ∈ set (VS::((real × real pdevs) × real) list) ⟹ degree_aform_err ?V ≤ (d::nat)›*) then show "?case" (*goal: ‹degree_aform_err (X::(real × real pdevs) × real) ≤ (d::nat)›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: degree_max_aform (*‹⟦degree_aform_err ?x ≤ ?d; degree_aform_err ?y ≤ ?d⟧ ⟹ degree_aform_err (max_aform_err ?p ?x ?y) ≤ ?d›*) degree_aform_acc_err (*‹degree_aform (fst ?X) ≤ ?d ⟹ degree_aform (fst (acc_err ?p ?X ?e)) ≤ ?d›*)) next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Min ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 10. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Min ra1 ra2) (*‹⟦approx_floatarith (p::nat) (ra1::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real); ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err ?X ≤ d› ‹⟦approx_floatarith p ra2 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Min ra1 ra2) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: degree_min_aform (*‹⟦degree_aform_err (?x::(real × real pdevs) × real) ≤ (?d::nat); degree_aform_err (?y::(real × real pdevs) × real) ≤ ?d⟧ ⟹ degree_aform_err (min_aform_err (?p::nat) ?x ?y) ≤ ?d›*) degree_aform_acc_err (*‹degree_aform (fst (?X::(?'a × ?'a pdevs) × real)) ≤ (?d::nat) ⟹ degree_aform (fst (acc_err (?p::nat) ?X (?e::real))) ≤ ?d›*)) next (*goals: 1. ‹⋀X. ⟦approx_floatarith p Pi VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 9. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case Pi (*‹approx_floatarith p Pi VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err (X::(real × real pdevs) × real) ≤ (d::nat)›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) Basis_list_real_def (*‹Basis_list = [1]›*) intro!: order_trans[OF degree_aform_independent_from] (*‹?d1.1 + degree_aform ?X1 ≤ ?z ⟹ degree_aform (independent_from ?d1.1 ?X1) ≤ ?z›*) order_trans[OF degree_aform_of_ivl] (*‹length Basis_list ≤ ?z ⟹ degree_aform (aform_of_ivl ?a1 ?b1) ≤ ?z›*) degree_aform_acc_err (*‹degree_aform (fst ?X) ≤ ?d ⟹ degree_aform (fst (acc_err ?p ?X ?e)) ≤ ?d›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Sqrt ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 8. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Sqrt ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Sqrt ra) VS = Some X› ‹(?V::(real × real pdevs) × real) ∈ set (VS::((real × real pdevs) × real) list) ⟹ degree_aform_err ?V ≤ (d::nat)›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_sqrt_aform_err (*‹⟦sqrt_aform_err ?p ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Exp ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀(ra1::floatarith) (ra2::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra1 (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; ⋀X::(real × real pdevs) × real. ⟦approx_floatarith p ra2 VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀(ra::floatarith) (x2a::nat) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀(x::nat) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Var x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 7. ‹⋀(x::float) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Num x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d›*) case (Exp ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Exp ra) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err (X::(real × real pdevs) × real) ≤ (d::nat)›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_exp_aform_err (*‹⟦exp_aform_err ?p ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. ⟦approx_floatarith p ra1 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; ⋀X. ⟦approx_floatarith p ra2 VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Powr ra1 ra2) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 6. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Powr ra1 ra2) (*‹⟦approx_floatarith p ra1 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹⟦approx_floatarith p ra2 VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Powr ra1 ra2) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_powr_aform_err (*‹⟦powr_aform_err ?p ?X ?Z = Some ?Y; degree_aform_err ?X ≤ ?n; degree_aform_err ?Z ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Ln ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀ra x2a X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀ra X. ⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 5. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Ln ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith (p::nat) (Ln (ra::floatarith)) (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err (X::(real × real pdevs) × real) ≤ (d::nat)›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro: degree_aform_err_ln_aform_err (*‹⟦ln_aform_err ?p ?X = Some ?Y; degree_aform_err ?X ≤ ?n⟧ ⟹ degree_aform_err ?Y ≤ ?n›*)) next (*goals: 1. ‹⋀(ra::floatarith) (x2a::nat) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Power ra x2a) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀(x::nat) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Var x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 4. ‹⋀(x::float) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Num x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d›*) case (Power ra x2a) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Power ra x2a) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by (auto intro!: degree_aform_err_power_aform_err (*‹degree_aform_err (?X::(real × real pdevs) × real) ≤ (?n::nat) ⟹ degree_aform_err (power_aform_err (?p::nat) ?X (?m::nat)) ≤ ?n›*) simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goals: 1. ‹⋀(ra::floatarith) X::(real × real pdevs) × real. ⟦⋀X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) ra (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀(x::nat) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Var x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d› 3. ‹⋀(x::float) X::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (Num x) (VS::((real × real pdevs) × real) list) = Some X; ⋀V::(real × real pdevs) × real. V ∈ set VS ⟹ degree_aform_err V ≤ (d::nat)⟧ ⟹ degree_aform_err X ≤ d›*) case (Floor ra) (*‹⟦approx_floatarith p ra VS = Some ?X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err ?X ≤ d› ‹approx_floatarith p (Floor ra) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) apply - (*goal: ‹degree_aform_err X ≤ d›*) apply (rule degree_aform_approx_un (*‹⟦approx_un (?p::nat) (?ivl::float interval ⇒ float interval option) (?X::((real × real pdevs) × real) option) = Some (?Y::(real × real pdevs) × real); case ?X of None ⇒ True | Some (X::(real × real pdevs) × real) ⇒ degree_aform_err X ≤ (?d1.0::nat)⟧ ⟹ degree_aform_err ?Y ≤ ?d1.0›*)) (*goal: ‹⟦⋀X. ⟦approx_floatarith p ra VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d; approx_floatarith p (Floor ra) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) by (auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) next (*goals: 1. ‹⋀x X. ⟦approx_floatarith p (Var x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d› 2. ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Var x) (*‹approx_floatarith p (Var x) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) apply (auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goal: ‹degree_aform_err X ≤ d›*) by (use Var.prems(2) nat_le_linear nth_mem order_trans in blast) next (*goal: ‹⋀x X. ⟦approx_floatarith p (Num x) VS = Some X; ⋀V. V ∈ set VS ⟹ degree_aform_err V ≤ d⟧ ⟹ degree_aform_err X ≤ d›*) case (Num x) (*‹approx_floatarith p (Num x) VS = Some X› ‹?V ∈ set VS ⟹ degree_aform_err ?V ≤ d›*) then show "?case" (*goal: ‹degree_aform_err X ≤ d›*) by auto qed definition affine_extension2 where "affine_extension2 fnctn_aff fnctn ⟷ ( ∀d a1 a2 X e2. fnctn_aff d a1 a2 = Some X ⟶ e2 ∈ UNIV → {- 1..1} ⟶ d ≥ degree_aform a1 ⟶ d ≥ degree_aform a2 ⟶ (∃e3 ∈ UNIV → {- 1..1}. (fnctn (aform_val e2 a1) (aform_val e2 a2) = aform_val e3 X ∧ (∀n. n < d ⟶ e3 n = e2 n) ∧ aform_val e2 a1 = aform_val e3 a1 ∧ aform_val e2 a2 = aform_val e3 a2)))" lemma affine_extension2E: assumes "affine_extension2 fnctn_aff fnctn" assumes "fnctn_aff d a1 a2 = Some X" "e ∈ UNIV → {- 1..1}" "d ≥ degree_aform a1" "d ≥ degree_aform a2" obtains e' where "e' ∈ UNIV → {- 1..1}" "fnctn (aform_val e a1) (aform_val e a2) = aform_val e' X" "⋀n. n < d ⟹ e' n = e n" "aform_val e a1 = aform_val e' a1" "aform_val e a2 = aform_val e' a2" using assms (*‹affine_extension2 (fnctn_aff::nat ⇒ 'a::real_normed_vector × 'a::real_normed_vector pdevs ⇒ 'b::real_normed_vector × 'b::real_normed_vector pdevs ⇒ ('c::real_normed_vector × 'c::real_normed_vector pdevs) option) (fnctn::'a::real_normed_vector ⇒ 'b::real_normed_vector ⇒ 'c::real_normed_vector)› ‹fnctn_aff d a1 a2 = Some X› ‹e ∈ UNIV → {- 1..1}› ‹degree_aform a1 ≤ d› ‹degree_aform (a2::'b::real_normed_vector × 'b::real_normed_vector pdevs) ≤ (d::nat)›*) unfolding affine_extension2_def (*goal: ‹(⋀e'. ⟦e' ∈ UNIV → {- 1..1}; fnctn (aform_val e a1) (aform_val e a2) = aform_val e' X; ⋀n. n < d ⟹ e' n = e n; aform_val e a1 = aform_val e' a1; aform_val e a2 = aform_val e' a2⟧ ⟹ thesis) ⟹ thesis›*) by metis lemma aform_err_uminus_aform: "- x ∈ aform_err e (uminus_aform X, ba)" if "e ∈ UNIV → {-1 .. 1}" "x ∈ aform_err e (X, ba)" using that (*‹e ∈ UNIV → {- 1..1}› ‹x ∈ aform_err e (X, ba)›*) by (auto simp: aform_err_def (*‹aform_err (?e::nat ⇒ real) (?Xe::(real × real pdevs) × real) = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) definition "aforms_err e (xs::aform_err list) = listset (map (aform_err e) xs)" lemma aforms_err_Nil[simp]: "aforms_err e [] = {[]}" and aforms_err_Cons: "aforms_err e (x#xs) = set_Cons (aform_err e x) (aforms_err e xs)" (*goals: 1. ‹aforms_err e [] = {[]}› 2. ‹aforms_err e (x # xs) = set_Cons (aform_err e x) (aforms_err e xs)› discuss goal 1*) apply ((auto simp: aforms_err_def (*‹aforms_err (?e::nat ⇒ real) (?xs::((real × real pdevs) × real) list) = listset (map (aform_err ?e) ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: aforms_err_def (*‹aforms_err ?e ?xs = listset (map (aform_err ?e) ?xs)›*))[1]) (*proven 2 subgoals*) . lemma in_set_ConsI: "a#b ∈ set_Cons A B" if "a ∈ A" and "b ∈ B" using that (*‹a ∈ A› ‹(b::'a list) ∈ (B::'a list set)›*) by (auto simp: set_Cons_def (*‹set_Cons (?A::?'a::type set) (?XS::?'a::type list set) = {x # xs |(x::?'a::type) xs::?'a::type list. x ∈ ?A ∧ xs ∈ ?XS}›*)) lemma mem_aforms_err_Cons_iff[simp]: "x#xs ∈ aforms_err e (X#XS) ⟷ x ∈ aform_err e X ∧ xs ∈ aforms_err e XS" by (auto simp: aforms_err_Cons (*‹aforms_err ?e (?x # ?xs) = set_Cons (aform_err ?e ?x) (aforms_err ?e ?xs)›*) set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*)) lemma mem_aforms_err_Cons_iff_Ex_conv: "x ∈ aforms_err e (X#XS) ⟷ (∃y ys. x = y#ys ∧ y ∈ aform_err e X ∧ ys ∈ aforms_err e XS)" by (auto simp: aforms_err_Cons (*‹aforms_err ?e (?x # ?xs) = set_Cons (aform_err ?e ?x) (aforms_err ?e ?xs)›*) set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*)) lemma listset_Cons_mem_conv: "a # vs ∈ listset AVS ⟷ (∃A VS. AVS = A # VS ∧ a ∈ A ∧ vs ∈ listset VS)" apply (induction AVS) (*goals: 1. ‹(a # vs ∈ listset []) = (∃A VS. [] = A # VS ∧ a ∈ A ∧ vs ∈ listset VS)› 2. ‹⋀aa AVS. (a # vs ∈ listset AVS) = (∃A VS. AVS = A # VS ∧ a ∈ A ∧ vs ∈ listset VS) ⟹ (a # vs ∈ listset (aa # AVS)) = (∃A VS. aa # AVS = A # VS ∧ a ∈ A ∧ vs ∈ listset VS)› discuss goal 1*) apply ((auto simp: set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))[1]) (*discuss goal 2*) apply ((auto simp: set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))[1]) (*proven 2 subgoals*) . lemma listset_Nil_mem_conv[simp]: "[] ∈ listset AVS ⟷ AVS = []" apply (induction AVS) (*goals: 1. ‹([] ∈ listset []) = ([] = [])› 2. ‹⋀a AVS. ([] ∈ listset AVS) = (AVS = []) ⟹ ([] ∈ listset (a # AVS)) = (a # AVS = [])› discuss goal 1*) apply ((auto simp: set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))[1]) (*discuss goal 2*) apply ((auto simp: set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))[1]) (*proven 2 subgoals*) . lemma listset_nthD: "vs ∈ listset VS ⟹ i < length vs ⟹ vs ! i ∈ VS ! i" apply (induction vs arbitrary: VS i) (*goals: 1. ‹⋀VS i. ⟦[] ∈ listset VS; i < length []⟧ ⟹ [] ! i ∈ VS ! i› 2. ‹⋀a vs VS i. ⟦⋀VS i. ⟦vs ∈ listset VS; i < length vs⟧ ⟹ vs ! i ∈ VS ! i; a # vs ∈ listset VS; i < length (a # vs)⟧ ⟹ (a # vs) ! i ∈ VS ! i› discuss goal 1*) apply ((auto simp: nth_Cons (*‹(?x # ?xs) ! ?n = (case ?n of 0 ⇒ ?x | Suc k ⇒ ?xs ! k)›*) listset_Cons_mem_conv (*‹(?a # ?vs ∈ listset ?AVS) = (∃A VS. ?AVS = A # VS ∧ ?a ∈ A ∧ ?vs ∈ listset VS)›*) split: nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 2*) apply ((auto simp: nth_Cons (*‹(?x # ?xs) ! ?n = (case ?n of 0 ⇒ ?x | Suc k ⇒ ?xs ! k)›*) listset_Cons_mem_conv (*‹(?a # ?vs ∈ listset ?AVS) = (∃A VS. ?AVS = A # VS ∧ ?a ∈ A ∧ ?vs ∈ listset VS)›*) split: nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*proven 2 subgoals*) . lemma length_listsetD: "vs ∈ listset VS ⟹ length vs = length VS" apply (induction vs arbitrary: VS) (*goals: 1. ‹⋀VS. [] ∈ listset VS ⟹ length [] = length VS› 2. ‹⋀a vs VS. ⟦⋀VS. vs ∈ listset VS ⟹ length vs = length VS; a # vs ∈ listset VS⟧ ⟹ length (a # vs) = length VS› discuss goal 1*) apply ((auto simp: listset_Cons_mem_conv (*‹(?a # ?vs ∈ listset ?AVS) = (∃A VS. ?AVS = A # VS ∧ ?a ∈ A ∧ ?vs ∈ listset VS)›*))[1]) (*discuss goal 2*) apply ((auto simp: listset_Cons_mem_conv (*‹(?a # ?vs ∈ listset ?AVS) = (∃A VS. ?AVS = A # VS ∧ ?a ∈ A ∧ ?vs ∈ listset VS)›*))[1]) (*proven 2 subgoals*) . lemma length_aforms_errD: "vs ∈ aforms_err e VS ⟹ length vs = length VS" by (auto simp: aforms_err_def (*‹aforms_err ?e ?xs = listset (map (aform_err ?e) ?xs)›*) length_listsetD (*‹?vs ∈ listset ?VS ⟹ length ?vs = length ?VS›*)) lemma nth_aforms_errI: "vs ! i ∈ aform_err e (VS ! i)" if "vs ∈ aforms_err e VS" "i < length vs" using that (*‹vs ∈ aforms_err e VS› ‹i < length vs›*) unfolding aforms_err_def (*goal: ‹vs ! i ∈ aform_err e (VS ! i)›*) apply - (*goal: ‹vs ! i ∈ aform_err e (VS ! i)›*) apply (frule listset_nthD (*‹⟦?vs ∈ listset ?VS; ?i < length ?vs⟧ ⟹ ?vs ! ?i ∈ ?VS ! ?i›*)) (*goals: 1. ‹⟦vs ∈ listset (map (aform_err e) VS); i < length vs⟧ ⟹ ?i2 < length vs› 2. ‹⟦vs ∈ listset (map (aform_err e) VS); i < length vs; vs ! ?i2 ∈ map (aform_err e) VS ! ?i2⟧ ⟹ vs ! i ∈ aform_err e (VS ! i)› discuss goal 1*) apply assumption (*discuss goal 2*) apply (auto simp: aforms_err_def (*‹aforms_err ?e ?xs = listset (map (aform_err ?e) ?xs)›*) length_listsetD (*‹?vs ∈ listset ?VS ⟹ length ?vs = length ?VS›*)) (*proven 2 subgoals*) . lemma eucl_truncate_down_float[simp]: "eucl_truncate_down p x ∈ float" by (auto simp: eucl_truncate_down_def (*‹eucl_truncate_down ?q ?b = (∑i∈Basis. truncate_down ?q (?b ∙ i) *⇩R i)›*)) lemma eucl_truncate_up_float[simp]: "eucl_truncate_up p x ∈ float" by (auto simp: eucl_truncate_up_def (*‹eucl_truncate_up ?q ?b = (∑i∈Basis. truncate_up ?q (?b ∙ i) *⇩R i)›*)) lemma trunc_bound_eucl_float[simp]: "fst (trunc_bound_eucl p x) ∈ float" "snd (trunc_bound_eucl p x) ∈ float" (*goals: 1. ‹fst (trunc_bound_eucl p x) ∈ float› 2. ‹snd (trunc_bound_eucl p x) ∈ float› discuss goal 1*) apply ((auto simp: trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 2*) apply ((auto simp: trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*proven 2 subgoals*) . lemma add_aform'_float: "add_aform' p x y = ((a, b), ba) ⟹ a ∈ float" "add_aform' p x y = ((a, b), ba) ⟹ ba ∈ float" (*goals: 1. ‹add_aform' p x y = ((a, b), ba) ⟹ a ∈ float› 2. ‹add_aform' p x y = ((a, b), ba) ⟹ ba ∈ float› discuss goal 1*) apply ((auto simp: add_aform'_def (*‹add_aform' ?p ?x ?y = (let z0 = trunc_bound_eucl ?p (fst (fst ?x) + fst (fst ?y)); z = trunc_bound_pdevs ?p (add_pdevs (snd (fst ?x)) (snd (fst ?y))) in ((fst z0, fst z), sum_list' ?p [snd z0, snd z, ¦snd ?x¦, ¦snd ?y¦]))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*discuss goal 2*) apply ((auto simp: add_aform'_def (*‹add_aform' ?p ?x ?y = (let z0 = trunc_bound_eucl ?p (fst (fst ?x) + fst (fst ?y)); z = trunc_bound_pdevs ?p (add_pdevs (snd (fst ?x)) (snd (fst ?y))) in ((fst z0, fst z), sum_list' ?p [snd z0, snd z, ¦snd ?x¦, ¦snd ?y¦]))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*))[1]) (*proven 2 subgoals*) . lemma uminus_aform_float: "uminus_aform (aa, bb) = (a, b) ⟹ aa ∈ float ⟹ a ∈ float" by (auto simp: uminus_aform_def (*‹uminus_aform ?X = (- fst ?X, uminus_pdevs (snd ?X))›*)) lemma mult_aform'_float: "mult_aform' p x y = ((a, b), ba) ⟹ a ∈ float" "mult_aform' p x y = ((a, b), ba) ⟹ ba ∈ float" (*goals: 1. ‹mult_aform' p x y = ((a, b), ba) ⟹ a ∈ float› 2. ‹mult_aform' p x y = ((a, b), ba) ⟹ ba ∈ float› discuss goal 1*) apply ((auto simp: mult_aform'_def (*‹mult_aform' (?p::nat) (?x::(real × real pdevs) × real) (?y::(real × real pdevs) × real) = (let (fx::real × real pdevs, sx::real) = ?x; (fy::real × real pdevs, sy::real) = ?y; ex::real = ¦sx¦; ey::real = ¦sy¦; z0::real × real = trunc_bound_eucl ?p (fst fx * fst fy); u::real pdevs × real = trunc_bound_pdevs ?p (scaleR_pdevs (fst fy) (snd fx)); v::real pdevs × real = trunc_bound_pdevs ?p (scaleR_pdevs (fst fx) (snd fy)); w::real pdevs × real = trunc_bound_pdevs ?p (add_pdevs (fst u) (fst v)); tx::real = Radius' ?p fx; ty::real = Radius' ?p fy; l::real = truncate_up ?p (tx * ty); ee::real = truncate_up ?p (ex * ey); e1::real = truncate_up ?p (ex * truncate_up ?p (¦fst fy¦ + ty)); e2::real = truncate_up ?p (ey * truncate_up ?p (¦fst fx¦ + tx)) in ((fst z0, fst w), sum_list' ?p [ee, e1, e2, l, snd z0, snd u, snd v, snd w]))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*))[1]) (*discuss goal 2*) apply ((auto simp: mult_aform'_def (*‹mult_aform' ?p ?x ?y = (let (fx, sx) = ?x; (fy, sy) = ?y; ex = ¦sx¦; ey = ¦sy¦; z0 = trunc_bound_eucl ?p (fst fx * fst fy); u = trunc_bound_pdevs ?p (scaleR_pdevs (fst fy) (snd fx)); v = trunc_bound_pdevs ?p (scaleR_pdevs (fst fx) (snd fy)); w = trunc_bound_pdevs ?p (add_pdevs (fst u) (fst v)); tx = Radius' ?p fx; ty = Radius' ?p fy; l = truncate_up ?p (tx * ty); ee = truncate_up ?p (ex * ey); e1 = truncate_up ?p (ex * truncate_up ?p (¦fst fy¦ + ty)); e2 = truncate_up ?p (ey * truncate_up ?p (¦fst fx¦ + tx)) in ((fst z0, fst w), sum_list' ?p [ee, e1, e2, l, snd z0, snd u, snd v, snd w]))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*))[1]) (*proven 2 subgoals*) . lemma inverse_aform'_float: "inverse_aform' p x = ((a, bb), baa) ⟹ a ∈ float" sorry lemma inverse_aform_float: "inverse_aform p x = Some ((a, bb), baa) ⟹ a ∈ float" by (auto simp: inverse_aform_def (*‹inverse_aform (?p::nat) (?a::real × real pdevs) = (let l::real = Inf_aform' ?p ?a; u::real = Sup_aform' ?p ?a in if l ≤ (0::real) ∧ (0::real) ≤ u then None else if l ≤ (0::real) then Some (apfst uminus_aform (inverse_aform' ?p (uminus_aform ?a))) else Some (inverse_aform' ?p ?a))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) apfst_def (*‹apfst (?f::?'a ⇒ ?'c) = map_prod ?f id›*) map_prod_def (*‹map_prod (?f::?'a ⇒ ?'c) (?g::?'b ⇒ ?'d) = (λ(x::?'a, y::?'b). (?f x, ?g y))›*) uminus_aform_def (*‹uminus_aform (?X::?'a × ?'b pdevs) = (- fst ?X, uminus_pdevs (snd ?X))›*) inverse_aform'_float (*‹inverse_aform' (?p::nat) (?x::real × real pdevs) = ((?a::real, ?bb::real pdevs), ?baa::real) ⟹ ?a ∈ float›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) lemma inverse_aform_err_float: "inverse_aform_err p x = Some ((a, b), ba) ⟹ a ∈ float" "inverse_aform_err p x = Some ((a, b), ba) ⟹ ba ∈ float" (*goals: 1. ‹inverse_aform_err p x = Some ((a, b), ba) ⟹ a ∈ float› 2. ‹inverse_aform_err p x = Some ((a, b), ba) ⟹ ba ∈ float› discuss goal 1*) apply ((auto simp: inverse_aform_err_def (*‹inverse_aform_err ?p ?X = map_aform_err (inverse_aform ?p) ?p ?X›*) map_aform_err_def (*‹map_aform_err ?I ?p ?X = (let X0 = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1, e1). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) aform_to_aform_err_def (*‹aform_to_aform_err ?X ?n = ((fst ?X, pdev_upd (snd ?X) ?n 0), ¦pdevs_apply (snd ?X) ?n¦)›*) inverse_aform_float (*‹inverse_aform ?p ?x = Some ((?a, ?bb), ?baa) ⟹ ?a ∈ float›*))[1]) (*discuss goal 2*) apply ((auto simp: inverse_aform_err_def (*‹inverse_aform_err ?p ?X = map_aform_err (inverse_aform ?p) ?p ?X›*) map_aform_err_def (*‹map_aform_err ?I ?p ?X = (let X0 = aform_err_to_aform ?X (degree_aform_err ?X) in ?I X0 ⤜ (λ(X1, e1). Some (acc_err ?p (aform_to_aform_err X1 (degree_aform_err ?X)) e1)))›*) acc_err_def (*‹acc_err ?p ?x ?e ≡ (fst ?x, truncate_up ?p (snd ?x + ?e))›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) aform_to_aform_err_def (*‹aform_to_aform_err ?X ?n = ((fst ?X, pdev_upd (snd ?X) ?n 0), ¦pdevs_apply (snd ?X) ?n¦)›*) inverse_aform_float (*‹inverse_aform ?p ?x = Some ((?a, ?bb), ?baa) ⟹ ?a ∈ float›*))[1]) (*proven 2 subgoals*) . lemma affine_unop_float: "affine_unop p asdf aaa bba h = ((a, b), ba) ⟹ a ∈ float" "affine_unop p asdf aaa bba h = ((a, b), ba) ⟹ ba ∈ float" (*goals: 1. ‹affine_unop p asdf aaa bba h = ((a, b), ba) ⟹ a ∈ float› 2. ‹affine_unop p asdf aaa bba h = ((a, b), ba) ⟹ ba ∈ float› discuss goal 1*) apply ((auto simp: affine_unop_def (*‹affine_unop ?p ?a ?b ?d ?X = (let ((x, xs), xe) = ?X; (ax, axe) = trunc_bound_eucl ?p (?a * x); (y, ye) = trunc_bound_eucl ?p (ax + ?b); (ys, yse) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: affine_unop_def (*‹affine_unop ?p ?a ?b ?d ?X = (let ((x, xs), xe) = ?X; (ax, axe) = trunc_bound_eucl ?p (?a * x); (y, ye) = trunc_bound_eucl ?p (ax + ?b); (ys, yse) = trunc_bound_pdevs ?p (scaleR_pdevs ?a xs) in ((y, ys), sum_list' ?p [truncate_up ?p (¦?a¦ * xe), axe, ye, yse, ?d]))›*) trunc_bound_eucl_def (*‹trunc_bound_eucl ?p ?s = (let d = eucl_truncate_down ?p ?s; ed = ¦d - ?s¦ in (d, eucl_truncate_up ?p ed))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . lemma min_range_antimono_float: "min_range_antimono p f f' i g h = Some ((a, b), ba) ⟹ a ∈ float" "min_range_antimono p f f' i g h = Some ((a, b), ba) ⟹ ba ∈ float" (*goals: 1. ‹min_range_antimono p f f' i g h = Some ((a, b), ba) ⟹ a ∈ float› 2. ‹min_range_antimono p f f' i g h = Some ((a, b), ba) ⟹ ba ∈ float› discuss goal 1*) apply ((auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) affine_unop_float (*‹affine_unop ?p ?asdf ?aaa ?bba ?h = ((?a, ?b), ?ba) ⟹ ?a ∈ float› ‹affine_unop ?p ?asdf ?aaa ?bba ?h = ((?a, ?b), ?ba) ⟹ ?ba ∈ float›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: min_range_antimono_def (*‹min_range_antimono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Max (?DF L) (?DF U)) [] ⤜ (λaivl. let a = upper aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Add (Half (?F L - ?F U + A * (U - L))) Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) affine_unop_float (*‹affine_unop ?p ?asdf ?aaa ?bba ?h = ((?a, ?b), ?ba) ⟹ ?a ∈ float› ‹affine_unop ?p ?asdf ?aaa ?bba ?h = ((?a, ?b), ?ba) ⟹ ?ba ∈ float›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . lemma min_range_mono_float: "min_range_mono p f f' i g h = Some ((a, b), ba) ⟹ a ∈ float" "min_range_mono p f f' i g h = Some ((a, b), ba) ⟹ ba ∈ float" (*goals: 1. ‹min_range_mono p f f' i g h = Some ((a, b), ba) ⟹ a ∈ float› 2. ‹min_range_mono p f f' i g h = Some ((a, b), ba) ⟹ ba ∈ float› discuss goal 1*) apply ((auto simp: min_range_mono_def (*‹min_range_mono ?p ?F ?DF ?l ?u ?X = (let L = Num ?l; U = Num ?u in approx ?p (Min (?DF L) (?DF U)) [] ⤜ (λaivl. let a = lower aivl; A = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl. let (b, be) = mid_err bivl; (B, Be) = (Num (float_of b), Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err ?ivl = (real_of_float (lower ?ivl + upper ?ivl) / 2, real_of_float (upper ?ivl - lower ?ivl) / 2)›*) affine_unop_float (*‹affine_unop ?p ?asdf ?aaa ?bba ?h = ((?a, ?b), ?ba) ⟹ ?a ∈ float› ‹affine_unop ?p ?asdf ?aaa ?bba ?h = ((?a, ?b), ?ba) ⟹ ?ba ∈ float›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: min_range_mono_def (*‹min_range_mono (?p::nat) (?F::floatarith ⇒ floatarith) (?DF::floatarith ⇒ floatarith) (?l::float) (?u::float) (?X::(real × real pdevs) × real) = (let L::floatarith = Num ?l; U::floatarith = Num ?u in approx ?p (Min (?DF L) (?DF U)) [] ⤜ (λaivl::float interval. let a::float = lower aivl; A::floatarith = Num a in approx ?p (Half (?F L + ?F U - A * (L + U))) [] ⤜ (λbivl::float interval. let (b::real, be::real) = mid_err bivl; (B::floatarith, Be::floatarith) = (Num (float_of b), Num (float_of be)) in approx ?p (Half (?F U - ?F L - A * (U - L)) + Be) [] ⤜ (λdivl::float interval. Some (affine_unop ?p (real_of_float a) b (real_of_float (upper divl)) ?X)))))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) mid_err_def (*‹mid_err (?ivl::float interval) = (real_of_float (lower ?ivl + upper ?ivl) / (2::real), real_of_float (upper ?ivl - lower ?ivl) / (2::real))›*) affine_unop_float (*‹affine_unop (?p::nat) (?asdf::real) (?aaa::real) (?bba::real) (?h::(real × real pdevs) × real) = ((?a::real, ?b::real pdevs), ?ba::real) ⟹ ?a ∈ float› ‹affine_unop (?p::nat) (?asdf::real) (?aaa::real) (?bba::real) (?h::(real × real pdevs) × real) = ((?a::real, ?b::real pdevs), ?ba::real) ⟹ ?ba ∈ float›*) split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . lemma in_float_timesI: "a ∈ float" if "b = a * 2" "b ∈ float" proof (-) (*goal: ‹a ∈ float›*) from that (*‹b = a * 2› ‹b ∈ float›*) have "a = b / 2" by simp also (*calculation: ‹a = b / 2›*) have "… ∈ float" using that(2) (*‹b ∈ float›*) by auto finally (*calculation: ‹a ∈ float›*) show "?thesis" (*goal: ‹a ∈ float›*) . qed lemma interval_extension_floor: "interval_extension1 (λivl. Some (floor_float_interval ivl)) floor" by (auto simp: interval_extension1_def (*‹interval_extension1 ?F ?f = (∀ivl ivl'. ?F ivl = Some ivl' ⟶ (∀x. x ∈⇩r ivl ⟶ ?f x ∈⇩r ivl'))›*) floor_float_intervalI (*‹?x ∈⇩r ?X ⟹ real_of_int ⌊?x⌋ ∈⇩r floor_float_interval ?X›*)) lemma approx_floatarith_Elem: assumes "approx_floatarith p ra VS = Some X" assumes e: "e ∈ UNIV → {-1 .. 1}" assumes "vs ∈ aforms_err e VS" shows "interpret_floatarith ra vs ∈ aform_err e X" using assms(1) (*‹approx_floatarith p ra VS = Some X›*) proof (induction ra arbitrary: X) (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Add ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Add ra1 ra2) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Minus ra) VS = Some X⟧ ⟹ interpret_floatarith (Minus ra) vs ∈ aform_err e X› 3. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Mult ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Mult ra1 ra2) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Inverse ra) VS = Some X⟧ ⟹ interpret_floatarith (Inverse ra) vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Cos ra) VS = Some X⟧ ⟹ interpret_floatarith (Cos ra) vs ∈ aform_err e X› 6. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Arctan ra) VS = Some X⟧ ⟹ interpret_floatarith (Arctan ra) vs ∈ aform_err e X› 7. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 8. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 9. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 10. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 11. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 12. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 13. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 14. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 15. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 16. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 17. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 18. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Add ra1 ra2) (*‹approx_floatarith (p::nat) (ra1::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith ra1 (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p ra2 VS = Some ?X ⟹ interpret_floatarith ra2 vs ∈ aform_err e ?X› ‹approx_floatarith p (Add ra1 ra2) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Add ra1 ra2) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: add_aform'[OF e] (*‹⟦?x ∈ aform_err e ?X; ?y ∈ aform_err e ?Y⟧ ⟹ ?x + ?y ∈ aform_err e (add_aform' ?p ?X ?Y)›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Minus ra) VS = Some X⟧ ⟹ interpret_floatarith (Minus ra) vs ∈ aform_err e X› 2. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Mult ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Mult ra1 ra2) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Inverse ra) VS = Some X⟧ ⟹ interpret_floatarith (Inverse ra) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Cos ra) VS = Some X⟧ ⟹ interpret_floatarith (Cos ra) vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Arctan ra) VS = Some X⟧ ⟹ interpret_floatarith (Arctan ra) vs ∈ aform_err e X› 6. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 7. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 8. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 9. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 10. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 11. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 12. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 13. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 14. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 15. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 16. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 17. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Minus ra) (*‹approx_floatarith p ra VS = Some ?X ⟹ interpret_floatarith ra vs ∈ aform_err e ?X› ‹approx_floatarith p (Minus ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Minus (ra::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) by (auto intro!: aform_err_uminus_aform[OF e] (*‹?x ∈ aform_err e (?X, ?ba) ⟹ - ?x ∈ aform_err e (uminus_aform ?X, ?ba)›*)) next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Mult ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Mult ra1 ra2) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Inverse ra) VS = Some X⟧ ⟹ interpret_floatarith (Inverse ra) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Cos ra) VS = Some X⟧ ⟹ interpret_floatarith (Cos ra) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Arctan ra) VS = Some X⟧ ⟹ interpret_floatarith (Arctan ra) vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 6. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 7. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 8. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 9. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 10. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 11. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 12. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 13. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 14. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 15. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 16. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Mult ra1 ra2) (*‹approx_floatarith p ra1 VS = Some ?X ⟹ interpret_floatarith ra1 vs ∈ aform_err e ?X› ‹approx_floatarith p ra2 VS = Some ?X ⟹ interpret_floatarith ra2 vs ∈ aform_err e ?X› ‹approx_floatarith p (Mult ra1 ra2) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Mult (ra1::floatarith) (ra2::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: mult_aform'E[OF e] (*‹⟦?x ∈ aform_err e ?X; ?y ∈ aform_err e ?Y⟧ ⟹ ?x * ?y ∈ aform_err e (mult_aform' ?p ?X ?Y)›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Inverse ra) VS = Some X⟧ ⟹ interpret_floatarith (Inverse ra) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Cos ra) VS = Some X⟧ ⟹ interpret_floatarith (Cos ra) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Arctan ra) VS = Some X⟧ ⟹ interpret_floatarith (Arctan ra) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 5. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 6. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 7. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 8. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 9. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 10. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 11. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 12. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 13. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 14. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 15. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Inverse ra) (*‹approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith ra (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p (Inverse ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Inverse ra) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: inverse_aform_err[OF e] (*‹⟦inverse_aform_err ?p ?X = Some ?Y; ?x ∈ aform_err e ?X⟧ ⟹ inverse ?x ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Cos ra) VS = Some X⟧ ⟹ interpret_floatarith (Cos ra) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Arctan ra) VS = Some X⟧ ⟹ interpret_floatarith (Arctan ra) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 4. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 5. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 6. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 7. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 8. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 9. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 10. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 11. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 12. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 13. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 14. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Cos ra) (*‹approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith ra (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p (Cos ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Cos ra) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: cos_aform_err[OF _ _ e] (*‹⟦(?x::real) ∈ aform_err (e::nat ⇒ real) (?X0.0::(real × real pdevs) × real); cos_aform_err (?p::nat) ?X0.0 = Some (?Y::(real × real pdevs) × real)⟧ ⟹ cos ?x ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Arctan ra) VS = Some X⟧ ⟹ interpret_floatarith (Arctan ra) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 3. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 4. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 5. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 6. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 7. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 8. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 9. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 10. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 11. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 12. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 13. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Arctan ra) (*‹approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith ra (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p (Arctan ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Arctan ra) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: arctan_aform_err[OF _ _ e] (*‹⟦(?x::real) ∈ aform_err (e::nat ⇒ real) (?X::(real × real pdevs) × real); arctan_aform_err (?p::nat) ?X = Some (?Y::(real × real pdevs) × real)⟧ ⟹ arctan ?x ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Abs ra) VS = Some X⟧ ⟹ interpret_floatarith (Abs ra) vs ∈ aform_err e X› 2. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 3. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 4. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 6. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 7. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 8. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 9. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 10. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 11. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 12. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Abs fa) (*‹approx_floatarith (p::nat) (fa::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith fa (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p (Abs fa) VS = Some X›*) from Abs.prems (*‹approx_floatarith p (Abs fa) VS = Some X›*) obtain a where a: "approx_floatarith p fa VS = Some a" (*goal: ‹(⋀a. approx_floatarith p fa VS = Some a ⟹ thesis) ⟹ thesis›*) by (auto simp add: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) bind_eq_Some_conv (*‹((?f::?'b::type option) ⤜ (?g::?'b::type ⇒ ?'a::type option) = Some (?x::?'a::type)) = (∃y::?'b::type. ?f = Some y ∧ ?g y = Some ?x)›*)) from Abs.IH[OF a] (*‹interpret_floatarith fa vs ∈ aform_err e a›*) have mem: "interpret_floatarith fa vs ∈ aform_err e a" by auto then have mem': "-interpret_floatarith fa vs ∈ aform_err e (apfst uminus_aform a)" by (auto simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) let ?i = "lower (ivl_of_aform_err p a)" let ?s = "upper (ivl_of_aform_err p a)" consider "?i > 0" | "?i ≤ 0" and "?s < 0" | "?i ≤ 0" and "?s ≥ 0" (*goal: ‹⟦(0::float) < lower (ivl_of_aform_err (p::nat) (a::(real × real pdevs) × real)) ⟹ thesis::bool; ⟦lower (ivl_of_aform_err p a) ≤ (0::float); upper (ivl_of_aform_err p a) < (0::float)⟧ ⟹ thesis; ⟦lower (ivl_of_aform_err p a) ≤ (0::float); (0::float) ≤ upper (ivl_of_aform_err p a)⟧ ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?case" (*goal: ‹interpret_floatarith (Abs fa) vs ∈ aform_err e X›*) proof (cases) (*goals: 1. ‹(0::float) < lower (ivl_of_aform_err (p::nat) (a::(real × real pdevs) × real)) ⟹ interpret_floatarith (Abs (fa::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)› 2. ‹⟦lower (ivl_of_aform_err (p::nat) (a::(real × real pdevs) × real)) ≤ (0::float); upper (ivl_of_aform_err p a) < (0::float)⟧ ⟹ interpret_floatarith (Abs (fa::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)› 3. ‹⟦lower (ivl_of_aform_err (p::nat) (a::(real × real pdevs) × real)) ≤ (0::float); (0::float) ≤ upper (ivl_of_aform_err p a)⟧ ⟹ interpret_floatarith (Abs (fa::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) case hyps: 1 (*‹0 < lower (ivl_of_aform_err p a)›*) then show "?thesis" (*goal: ‹interpret_floatarith (Abs fa) vs ∈ aform_err e X›*) using Abs.prems (*‹approx_floatarith p (Abs fa) VS = Some X›*) mem (*‹interpret_floatarith (fa::floatarith) (vs::real list) ∈ aform_err (e::nat ⇒ real) (a::(real × real pdevs) × real)›*) ivl_of_aform_err[OF e mem, of p] (*‹interpret_floatarith fa vs ∈⇩r ivl_of_aform_err p a›*) by (auto simp: a (*‹approx_floatarith p fa VS = Some a›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*)) next (*goals: 1. ‹⟦lower (ivl_of_aform_err p a) ≤ 0; upper (ivl_of_aform_err p a) < 0⟧ ⟹ interpret_floatarith (Abs fa) vs ∈ aform_err e X› 2. ‹⟦lower (ivl_of_aform_err p a) ≤ 0; 0 ≤ upper (ivl_of_aform_err p a)⟧ ⟹ interpret_floatarith (Abs fa) vs ∈ aform_err e X›*) case hyps: 2 (*‹lower (ivl_of_aform_err p a) ≤ 0› ‹upper (ivl_of_aform_err (p::nat) (a::(real × real pdevs) × real)) < (0::float)›*) then show "?thesis" (*goal: ‹interpret_floatarith (Abs (fa::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) using Abs.prems (*‹approx_floatarith p (Abs fa) VS = Some X›*) mem (*‹interpret_floatarith fa vs ∈ aform_err e a›*) ivl_of_aform_err[OF e mem, of p] (*‹interpret_floatarith fa vs ∈⇩r ivl_of_aform_err p a›*) ivl_of_aform_err[OF e mem', of p] (*‹- interpret_floatarith (fa::floatarith) (vs::real list) ∈⇩r ivl_of_aform_err (p::nat) (apfst uminus_aform (a::(real × real pdevs) × real))›*) apply (cases a) (*goal: ‹interpret_floatarith (Abs (fa::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) by (auto simp: a (*‹approx_floatarith p fa VS = Some a›*) abs_real_def (*‹¦?a¦ = (if ?a < 0 then - ?a else ?a)›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*) intro!: aform_err_uminus_aform[OF e] (*‹?x ∈ aform_err e (?X, ?ba) ⟹ - ?x ∈ aform_err e (uminus_aform ?X, ?ba)›*)) next (*goal: ‹⟦lower (ivl_of_aform_err (p::nat) (a::(real × real pdevs) × real)) ≤ (0::float); (0::float) ≤ upper (ivl_of_aform_err p a)⟧ ⟹ interpret_floatarith (Abs (fa::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) case hyps: 3 (*‹lower (ivl_of_aform_err p a) ≤ 0› ‹0 ≤ upper (ivl_of_aform_err p a)›*) then show "?thesis" (*goal: ‹interpret_floatarith (Abs fa) vs ∈ aform_err e X›*) using Abs.prems (*‹approx_floatarith p (Abs fa) VS = Some X›*) mem (*‹interpret_floatarith fa vs ∈ aform_err e a›*) ivl_of_aform_err[OF e mem, of p] (*‹interpret_floatarith fa vs ∈⇩r ivl_of_aform_err p a›*) by (auto simp: a (*‹approx_floatarith (p::nat) (fa::floatarith) (VS::((real × real pdevs) × real) list) = Some (a::(real × real pdevs) × real)›*) abs_real_def (*‹¦?a::real¦ = (if ?a < (0::real) then - ?a else ?a)›*) max_def (*‹max (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?b else ?a)›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) set_of_eq (*‹set_of (?x::?'a interval) = {lower ?x..upper ?x}›*)) qed next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Max ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 2. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 3. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 6. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 7. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 8. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 9. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 10. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 11. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Max ra1 ra2) (*‹approx_floatarith p ra1 VS = Some ?X ⟹ interpret_floatarith ra1 vs ∈ aform_err e ?X› ‹approx_floatarith p ra2 VS = Some ?X ⟹ interpret_floatarith ra2 vs ∈ aform_err e ?X› ‹approx_floatarith p (Max ra1 ra2) VS = Some X›*) from Max.prems (*‹approx_floatarith p (Max ra1 ra2) VS = Some X›*) obtain a and b where a: "approx_floatarith p ra1 VS = Some a" and b: "approx_floatarith p ra2 VS = Some b" (*goal: ‹(⋀a b. ⟦approx_floatarith p ra1 VS = Some a; approx_floatarith p ra2 VS = Some b⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) bind_eq_Some_conv (*‹((?f::?'b::type option) ⤜ (?g::?'b::type ⇒ ?'a::type option) = Some (?x::?'a::type)) = (∃y::?'b::type. ?f = Some y ∧ ?g y = Some ?x)›*)) from Max.IH(1)[OF a] (*‹interpret_floatarith (ra1::floatarith) (vs::real list) ∈ aform_err (e::nat ⇒ real) (a::(real × real pdevs) × real)›*) Max.IH(2)[OF b] (*‹interpret_floatarith (ra2::floatarith) (vs::real list) ∈ aform_err (e::nat ⇒ real) (b::(real × real pdevs) × real)›*) have mem: "interpret_floatarith ra1 vs ∈ aform_err e a" "interpret_floatarith ra2 vs ∈ aform_err e b" apply - (*goals: 1. ‹⟦interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b⟧ ⟹ interpret_floatarith ra1 vs ∈ aform_err e a› 2. ‹⟦interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b⟧ ⟹ interpret_floatarith ra2 vs ∈ aform_err e b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?ia = "lower (ivl_of_aform_err p a)" let ?sa = "upper (ivl_of_aform_err p a)" let ?ib = "lower (ivl_of_aform_err p b)" let ?sb = "upper (ivl_of_aform_err p b)" consider "?sa < ?ib" | "?sa ≥ ?ib" and "?sb < ?ia" | "?sa ≥ ?ib" and "?sb ≥ ?ia" (*goal: ‹⟦upper (ivl_of_aform_err p a) < lower (ivl_of_aform_err p b) ⟹ thesis; ⟦lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); upper (ivl_of_aform_err p b) < lower (ivl_of_aform_err p a)⟧ ⟹ thesis; ⟦lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); lower (ivl_of_aform_err p a) ≤ upper (ivl_of_aform_err p b)⟧ ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?case" (*goal: ‹interpret_floatarith (Max (ra1::floatarith) (ra2::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) using Max.prems (*‹approx_floatarith (p::nat) (Max (ra1::floatarith) (ra2::floatarith)) (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)›*) mem (*‹interpret_floatarith ra1 vs ∈ aform_err e a› ‹interpret_floatarith ra2 vs ∈ aform_err e b›*) ivl_of_aform_err[OF e mem ( 1 ), of p] (*‹interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a›*) ivl_of_aform_err[OF e mem ( 2 ), of p] (*‹interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b›*) apply cases (*goals: 1. ‹⟦approx_floatarith p (Max ra1 ra2) VS = Some X; interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b; interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a; interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b; upper (ivl_of_aform_err p a) < lower (ivl_of_aform_err p b)⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 2. ‹⟦approx_floatarith p (Max ra1 ra2) VS = Some X; interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b; interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a; interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b; lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); upper (ivl_of_aform_err p b) < lower (ivl_of_aform_err p a)⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› 3. ‹⟦approx_floatarith p (Max ra1 ra2) VS = Some X; interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b; interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a; interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b; lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); lower (ivl_of_aform_err p a) ≤ upper (ivl_of_aform_err p b)⟧ ⟹ interpret_floatarith (Max ra1 ra2) vs ∈ aform_err e X› discuss goal 1*) apply ((auto simp: a (*‹approx_floatarith p ra1 VS = Some a›*) b (*‹approx_floatarith p ra2 VS = Some b›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) max_aform_err_def (*‹max_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a2.0 else if upper ivl2 < lower ivl1 then ?a1.0 else ivl_err (real_interval (max_interval ivl1 ivl2)))›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 2*) apply ((auto simp: a (*‹approx_floatarith p ra1 VS = Some a›*) b (*‹approx_floatarith p ra2 VS = Some b›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) max_aform_err_def (*‹max_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a2.0 else if upper ivl2 < lower ivl1 then ?a1.0 else ivl_err (real_interval (max_interval ivl1 ivl2)))›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 3*) apply ((auto simp: a (*‹approx_floatarith p ra1 VS = Some a›*) b (*‹approx_floatarith p ra2 VS = Some b›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) max_aform_err_def (*‹max_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a2.0 else if upper ivl2 < lower ivl1 then ?a1.0 else ivl_err (real_interval (max_interval ivl1 ivl2)))›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Min ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 2. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 5. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 6. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 7. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 8. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 9. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 10. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Min ra1 ra2) (*‹approx_floatarith (p::nat) (ra1::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith ra1 (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p ra2 VS = Some ?X ⟹ interpret_floatarith ra2 vs ∈ aform_err e ?X› ‹approx_floatarith p (Min ra1 ra2) VS = Some X›*) from Min.prems (*‹approx_floatarith p (Min ra1 ra2) VS = Some X›*) obtain a and b where a: "approx_floatarith p ra1 VS = Some a" and b: "approx_floatarith p ra2 VS = Some b" (*goal: ‹(⋀a b. ⟦approx_floatarith p ra1 VS = Some a; approx_floatarith p ra2 VS = Some b⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) from Min.IH(1)[OF a] (*‹interpret_floatarith ra1 vs ∈ aform_err e a›*) Min.IH(2)[OF b] (*‹interpret_floatarith ra2 vs ∈ aform_err e b›*) have mem: "interpret_floatarith ra1 vs ∈ aform_err e a" "interpret_floatarith ra2 vs ∈ aform_err e b" apply - (*goals: 1. ‹⟦interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b⟧ ⟹ interpret_floatarith ra1 vs ∈ aform_err e a› 2. ‹⟦interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b⟧ ⟹ interpret_floatarith ra2 vs ∈ aform_err e b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?ia = "lower (ivl_of_aform_err p a)" let ?sa = "upper (ivl_of_aform_err p a)" let ?ib = "lower (ivl_of_aform_err p b)" let ?sb = "upper (ivl_of_aform_err p b)" consider "?sa < ?ib" | "?sa ≥ ?ib" and "?sb < ?ia" | "?sa ≥ ?ib" and "?sb ≥ ?ia" (*goal: ‹⟦upper (ivl_of_aform_err p a) < lower (ivl_of_aform_err p b) ⟹ thesis; ⟦lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); upper (ivl_of_aform_err p b) < lower (ivl_of_aform_err p a)⟧ ⟹ thesis; ⟦lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); lower (ivl_of_aform_err p a) ≤ upper (ivl_of_aform_err p b)⟧ ⟹ thesis⟧ ⟹ thesis›*) by arith then show "?case" (*goal: ‹interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X›*) using Min.prems (*‹approx_floatarith (p::nat) (Min (ra1::floatarith) (ra2::floatarith)) (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)›*) mem (*‹interpret_floatarith ra1 vs ∈ aform_err e a› ‹interpret_floatarith ra2 vs ∈ aform_err e b›*) ivl_of_aform_err[OF e mem ( 1 ), of p] (*‹interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a›*) ivl_of_aform_err[OF e mem ( 2 ), of p] (*‹interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b›*) apply cases (*goals: 1. ‹⟦approx_floatarith p (Min ra1 ra2) VS = Some X; interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b; interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a; interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b; upper (ivl_of_aform_err p a) < lower (ivl_of_aform_err p b)⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 2. ‹⟦approx_floatarith p (Min ra1 ra2) VS = Some X; interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b; interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a; interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b; lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); upper (ivl_of_aform_err p b) < lower (ivl_of_aform_err p a)⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› 3. ‹⟦approx_floatarith p (Min ra1 ra2) VS = Some X; interpret_floatarith ra1 vs ∈ aform_err e a; interpret_floatarith ra2 vs ∈ aform_err e b; interpret_floatarith ra1 vs ∈⇩r ivl_of_aform_err p a; interpret_floatarith ra2 vs ∈⇩r ivl_of_aform_err p b; lower (ivl_of_aform_err p b) ≤ upper (ivl_of_aform_err p a); lower (ivl_of_aform_err p a) ≤ upper (ivl_of_aform_err p b)⟧ ⟹ interpret_floatarith (Min ra1 ra2) vs ∈ aform_err e X› discuss goal 1*) apply ((auto simp: a (*‹approx_floatarith p ra1 VS = Some a›*) b (*‹approx_floatarith p ra2 VS = Some b›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) min_aform_err_def (*‹min_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a1.0 else if upper ivl2 < lower ivl1 then ?a2.0 else ivl_err (real_interval (min_interval ivl1 ivl2)))›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 2*) apply ((auto simp: a (*‹approx_floatarith p ra1 VS = Some a›*) b (*‹approx_floatarith p ra2 VS = Some b›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) min_aform_err_def (*‹min_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a1.0 else if upper ivl2 < lower ivl1 then ?a2.0 else ivl_err (real_interval (min_interval ivl1 ivl2)))›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*discuss goal 3*) apply ((auto simp: a (*‹approx_floatarith p ra1 VS = Some a›*) b (*‹approx_floatarith p ra2 VS = Some b›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) min_aform_err_def (*‹min_aform_err ?p ?a1.0 ?a2.0 = (let ivl1 = ivl_of_aform_err ?p ?a1.0; ivl2 = ivl_of_aform_err ?p ?a2.0 in if upper ivl1 < lower ivl2 then ?a1.0 else if upper ivl2 < lower ivl1 then ?a2.0 else ivl_err (real_interval (min_interval ivl1 ivl2)))›*) set_of_eq (*‹set_of ?x = {lower ?x..upper ?x}›*))[1]) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀X. approx_floatarith p Pi VS = Some X ⟹ interpret_floatarith Pi vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 4. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 6. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 7. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 8. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 9. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case Pi (*‹approx_floatarith (p::nat) Pi (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)›*) then show "?case" (*goal: ‹interpret_floatarith Pi vs ∈ aform_err e X›*) using pi_float_interval (*‹pi ∈⇩r pi_float_interval (?prec::nat)›*) by auto next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Sqrt ra) VS = Some X⟧ ⟹ interpret_floatarith (Sqrt ra) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 3. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 5. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 6. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 7. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 8. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Sqrt ra) (*‹approx_floatarith p ra VS = Some ?X ⟹ interpret_floatarith ra vs ∈ aform_err e ?X› ‹approx_floatarith (p::nat) (Sqrt (ra::floatarith)) (VS::((real × real pdevs) × real) list) = Some (X::(real × real pdevs) × real)›*) then show "?case" (*goal: ‹interpret_floatarith (Sqrt ra) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: sqrt_aform_err[OF _ _ e] (*‹⟦?x ∈ aform_err e ?X; sqrt_aform_err ?p ?X = Some ?Y⟧ ⟹ sqrt ?x ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Exp ra) VS = Some X⟧ ⟹ interpret_floatarith (Exp ra) vs ∈ aform_err e X› 2. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 4. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 5. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 6. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 7. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Exp ra) (*‹approx_floatarith p ra VS = Some ?X ⟹ interpret_floatarith ra vs ∈ aform_err e ?X› ‹approx_floatarith p (Exp ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Exp ra) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: exp_aform_err[OF _ _ e] (*‹⟦?x ∈ aform_err e ?X; exp_aform_err ?p ?X = Some ?Y⟧ ⟹ exp ?x ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra1 ra2 X. ⟦⋀X. approx_floatarith p ra1 VS = Some X ⟹ interpret_floatarith ra1 vs ∈ aform_err e X; ⋀X. approx_floatarith p ra2 VS = Some X ⟹ interpret_floatarith ra2 vs ∈ aform_err e X; approx_floatarith p (Powr ra1 ra2) VS = Some X⟧ ⟹ interpret_floatarith (Powr ra1 ra2) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 3. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 4. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 5. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 6. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Powr ra1 ra2) (*‹approx_floatarith p ra1 VS = Some ?X ⟹ interpret_floatarith ra1 vs ∈ aform_err e ?X› ‹approx_floatarith p ra2 VS = Some ?X ⟹ interpret_floatarith ra2 vs ∈ aform_err e ?X› ‹approx_floatarith p (Powr ra1 ra2) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Powr (ra1::floatarith) (ra2::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) by (auto simp: bind_eq_Some_conv (*‹((?f::?'b::type option) ⤜ (?g::?'b::type ⇒ ?'a::type option) = Some (?x::?'a::type)) = (∃y::?'b::type. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: powr_aform_err[OF _ _ e] (*‹⟦(?x::real) ∈ aform_err (e::nat ⇒ real) (?X::(real × real pdevs) × real); (?a::real) ∈ aform_err e (?A::(real × real pdevs) × real); powr_aform_err (?p::nat) ?X ?A = Some (?Y::(real × real pdevs) × real)⟧ ⟹ ?x powr ?a ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Ln ra) VS = Some X⟧ ⟹ interpret_floatarith (Ln ra) vs ∈ aform_err e X› 2. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 3. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 4. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 5. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Ln ra) (*‹approx_floatarith p ra VS = Some ?X ⟹ interpret_floatarith ra vs ∈ aform_err e ?X› ‹approx_floatarith p (Ln ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Ln (ra::floatarith)) (vs::real list) ∈ aform_err (e::nat ⇒ real) (X::(real × real pdevs) × real)›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: ln_aform_err[OF _ _ e] (*‹⟦?x ∈ aform_err e ?X; ln_aform_err ?p ?X = Some ?Y⟧ ⟹ ln ?x ∈ aform_err e ?Y›*)) next (*goals: 1. ‹⋀ra x2a X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Power ra x2a) VS = Some X⟧ ⟹ interpret_floatarith (Power ra x2a) vs ∈ aform_err e X› 2. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 3. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 4. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Power ra x2a) (*‹approx_floatarith p ra VS = Some ?X ⟹ interpret_floatarith ra vs ∈ aform_err e ?X› ‹approx_floatarith p (Power ra x2a) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Power ra x2a) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) is_float_def (*‹is_float ?r = (?r ∈ float)›*) intro!: power_aform_err[OF _ _ _ e] (*‹⟦?x ∈ aform_err e ?X; fst (fst ?X) ∈ float; snd ?X ∈ float⟧ ⟹ ?x ^ ?n ∈ aform_err e (power_aform_err ?p ?X ?n)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goals: 1. ‹⋀ra X. ⟦⋀X. approx_floatarith p ra VS = Some X ⟹ interpret_floatarith ra vs ∈ aform_err e X; approx_floatarith p (Floor ra) VS = Some X⟧ ⟹ interpret_floatarith (Floor ra) vs ∈ aform_err e X› 2. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 3. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Floor ra) (*‹approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some (?X::(real × real pdevs) × real) ⟹ interpret_floatarith ra (vs::real list) ∈ aform_err (e::nat ⇒ real) ?X› ‹approx_floatarith p (Floor ra) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Floor ra) vs ∈ aform_err e X›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) intro!: approx_unE[OF interval_extension_floor e] (*‹⟦approx_un ?p (λivl. Some (floor_float_interval ivl)) ?X'err = Some ?Ye; case ?X'err of None ⇒ True | Some X'err ⇒ ?x ∈ aform_err e X'err⟧ ⟹ real_of_int ⌊?x⌋ ∈ aform_err e ?Ye›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) next (*goals: 1. ‹⋀x X. approx_floatarith p (Var x) VS = Some X ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X› 2. ‹⋀x X. approx_floatarith p (Num x) VS = Some X ⟹ interpret_floatarith (Num x) vs ∈ aform_err e X›*) case (Var x) (*‹approx_floatarith p (Var x) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Var x) vs ∈ aform_err e X›*) using assms(3) (*‹vs ∈ aforms_err e VS›*) apply - (*goal: ‹interpret_floatarith (Var x) vs ∈ aform_err e X›*) apply (frule length_aforms_errD (*‹?vs ∈ aforms_err ?e ?VS ⟹ length ?vs = length ?VS›*)) (*goal: ‹⟦approx_floatarith p (Var x) VS = Some X; vs ∈ aforms_err e VS⟧ ⟹ interpret_floatarith (Var x) vs ∈ aform_err e X›*) by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp: aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) dest!: nth_aforms_errI[where i=x] (*‹⟦?vs ∈ aforms_err ?e ?VS; x < length ?vs⟧ ⟹ ?vs ! x ∈ aform_err ?e (?VS ! x)›*)) next (*goal: ‹⋀(x::float) X::(real × real pdevs) × real. approx_floatarith (p::nat) (Num x) (VS::((real × real pdevs) × real) list) = Some X ⟹ interpret_floatarith (Num x) (vs::real list) ∈ aform_err (e::nat ⇒ real) X›*) case (Num x) (*‹approx_floatarith p (Num x) VS = Some X›*) then show "?case" (*goal: ‹interpret_floatarith (Num x) vs ∈ aform_err e X›*) by (auto split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp: aform_err_def (*‹aform_err (?e::nat ⇒ real) (?Xe::(real × real pdevs) × real) = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*) num_aform_def (*‹num_aform (?f::?'a) = (?f, zero_pdevs)›*) aform_val_def (*‹aform_val (?e::nat ⇒ real) (?X::?'a × ?'a pdevs) = fst ?X + pdevs_val ?e (snd ?X)›*)) qed primrec approx_floatariths_aformerr :: "nat ⇒ floatarith list ⇒ aform_err list ⇒ aform_err list option" where "approx_floatariths_aformerr _ [] _ = Some []" | "approx_floatariths_aformerr p (a#bs) vs = do { a ← approx_floatarith p a vs; r ← approx_floatariths_aformerr p bs vs; Some (a#r) }" lemma approx_floatariths_Elem: assumes "e ∈ UNIV → {-1 .. 1}" assumes "approx_floatariths_aformerr p ra VS = Some X" assumes "vs ∈ aforms_err e VS" shows "interpret_floatariths ra vs ∈ aforms_err e X" using assms(2) (*‹approx_floatariths_aformerr p ra VS = Some X›*) proof (induction ra arbitrary: X) (*goals: 1. ‹⋀X. approx_floatariths_aformerr p [] VS = Some X ⟹ interpret_floatariths [] vs ∈ aforms_err e X› 2. ‹⋀a ra X. ⟦⋀X. approx_floatariths_aformerr p ra VS = Some X ⟹ interpret_floatariths ra vs ∈ aforms_err e X; approx_floatariths_aformerr p (a # ra) VS = Some X⟧ ⟹ interpret_floatariths (a # ra) vs ∈ aforms_err e X›*) case Nil (*‹approx_floatariths_aformerr p [] VS = Some X›*) then show "?case" (*goal: ‹interpret_floatariths [] (vs::real list) ∈ aforms_err (e::nat ⇒ real) (X::((real × real pdevs) × real) list)›*) by simp next (*goal: ‹⋀a ra X. ⟦⋀X. approx_floatariths_aformerr p ra VS = Some X ⟹ interpret_floatariths ra vs ∈ aforms_err e X; approx_floatariths_aformerr p (a # ra) VS = Some X⟧ ⟹ interpret_floatariths (a # ra) vs ∈ aforms_err e X›*) case (Cons ra ras) (*‹approx_floatariths_aformerr p ras VS = Some ?X ⟹ interpret_floatariths ras vs ∈ aforms_err e ?X› ‹approx_floatariths_aformerr p (ra # ras) VS = Some X›*) from Cons.prems (*‹approx_floatariths_aformerr (p::nat) ((ra::floatarith) # (ras::floatarith list)) (VS::((real × real pdevs) × real) list) = Some (X::((real × real pdevs) × real) list)›*) obtain a and r where a: "approx_floatarith p ra VS = Some a" and r: "approx_floatariths_aformerr p ras VS = Some r" and X: "X = a # r" (*goal: ‹(⋀a r. ⟦approx_floatarith p ra VS = Some a; approx_floatariths_aformerr p ras VS = Some r; X = a # r⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) then show "?case" (*goal: ‹interpret_floatariths (ra # ras) vs ∈ aforms_err e X›*) using assms(1) (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp: X (*‹X = a # r›*) Cons.IH (*‹approx_floatariths_aformerr p ras VS = Some ?X ⟹ interpret_floatariths ras vs ∈ aforms_err e ?X›*) intro!: approx_floatarith_Elem (*‹⟦approx_floatarith ?p ?ra ?VS = Some ?X; ?e ∈ UNIV → {- 1..1}; ?vs ∈ aforms_err ?e ?VS⟧ ⟹ interpret_floatarith ?ra ?vs ∈ aform_err ?e ?X›*) assms (*‹e ∈ UNIV → {- 1..1}› ‹approx_floatariths_aformerr p ra VS = Some X› ‹vs ∈ aforms_err e VS›*)) qed lemma fold_max_mono: fixes x::"'a::linorder" shows "x ≤ y ⟹ fold max zs x ≤ fold max zs y" apply (induct zs arbitrary: x y) (*goals: 1. ‹⋀(x::'a) y::'a. x ≤ y ⟹ fold max [] x ≤ fold max [] y› 2. ‹⋀(a::'a) (zs::'a list) (x::'a) y::'a. ⟦⋀(x::'a) y::'a. x ≤ y ⟹ fold max zs x ≤ fold max zs y; x ≤ y⟧ ⟹ fold max (a # zs) x ≤ fold max (a # zs) y› discuss goal 1*) apply ((auto intro!: Cons (*‹⟦(?x::?'a, ?y::?'b) ∈ (?r::(?'a × ?'b) set); (?xs::?'a list, ?ys::?'b list) ∈ listrel ?r⟧ ⟹ (?x # ?xs, ?y # ?ys) ∈ listrel ?r›*) simp: max_def (*‹max (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 2*) apply ((auto intro!: Cons (*‹⟦(?x, ?y) ∈ ?r; (?xs, ?ys) ∈ listrel ?r⟧ ⟹ (?x # ?xs, ?y # ?ys) ∈ listrel ?r›*) simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*proven 2 subgoals*) . lemma fold_max_le_self: fixes y::"'a::linorder" shows "y ≤ fold max ys y" apply (induct ys) (*goals: 1. ‹y ≤ fold max [] y› 2. ‹⋀a ys. y ≤ fold max ys y ⟹ y ≤ fold max (a # ys) y› discuss goal 1*) apply ((auto intro: order_trans[OF _ fold_max_mono] (*‹⟦(?x::?'a1) ≤ fold max (?zs1::?'a1 list) (?x1::?'a1); ?x1 ≤ (?y1::?'a1)⟧ ⟹ ?x ≤ fold max ?zs1 ?y1›*))[1]) (*discuss goal 2*) apply ((auto intro: order_trans[OF _ fold_max_mono] (*‹⟦?x ≤ fold max ?zs1 ?x1; ?x1 ≤ ?y1⟧ ⟹ ?x ≤ fold max ?zs1 ?y1›*))[1]) (*proven 2 subgoals*) . lemma fold_max_le: fixes x::"'a::linorder" shows "x ∈ set xs ⟹ x ≤ fold max xs z" apply (induct xs arbitrary: x z) (*goals: 1. ‹⋀x z. x ∈ set [] ⟹ x ≤ fold max [] z› 2. ‹⋀a xs x z. ⟦⋀x z. x ∈ set xs ⟹ x ≤ fold max xs z; x ∈ set (a # xs)⟧ ⟹ x ≤ fold max (a # xs) z› discuss goal 1*) apply ((auto intro: order_trans[OF _ fold_max_le_self] (*‹?x ≤ ?y ⟹ ?x ≤ fold max ?ys1 ?y›*))[1]) (*discuss goal 2*) apply ((auto intro: order_trans[OF _ fold_max_le_self] (*‹?x ≤ ?y ⟹ ?x ≤ fold max ?ys1 ?y›*))[1]) (*proven 2 subgoals*) . abbreviation "degree_aforms_err ≡ degrees o map (snd o fst)" definition "aforms_err_to_aforms d xs = (map (λ(d, x). aform_err_to_aform x d) (zip [d..<d + length xs] xs))" lemma aform_vals_empty[simp]: "aform_vals e' [] = []" by (auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*)) lemma aforms_err_to_aforms_Nil[simp]: "(aforms_err_to_aforms n []) = []" by (auto simp: aforms_err_to_aforms_def (*‹aforms_err_to_aforms ?d ?xs = map2 (λd x. aform_err_to_aform x d) [?d..<?d + length ?xs] ?xs›*)) lemma aforms_err_to_aforms_Cons[simp]: "aforms_err_to_aforms n (X # XS) = aform_err_to_aform X n # aforms_err_to_aforms (Suc n) XS" by (auto simp: aforms_err_to_aforms_def (*‹aforms_err_to_aforms ?d ?xs = map2 (λd x. aform_err_to_aform x d) [?d..<?d + length ?xs] ?xs›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) nth_Cons (*‹(?x # ?xs) ! ?n = (case ?n of 0 ⇒ ?x | Suc k ⇒ ?xs ! k)›*) intro!: nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*) split: nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*)) lemma degree_aform_err_to_aform_le: "degree_aform (aform_err_to_aform X n) ≤ max (degree_aform_err X) (Suc n)" by (auto simp: aform_err_to_aform_def (*‹aform_err_to_aform ?X ?n = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) intro!: degree_le (*‹∀j≥?d. pdevs_apply ?x j = 0 ⟹ degree ?x ≤ ?d›*)) lemma less_degree_aform_aform_err_to_aformD: "i < degree_aform (aform_err_to_aform X n) ⟹ i < max (Suc n) (degree_aform_err X)" using degree_aform_err_to_aform_le[of X n] (*‹degree_aform (aform_err_to_aform X n) ≤ max (degree_aform_err X) (Suc n)›*) by auto lemma pdevs_domain_aform_err_to_aform: "pdevs_domain (snd (aform_err_to_aform X n)) = pdevs_domain (snd (fst X)) ∪ (if snd X = 0 then {} else {n})" if "n ≥ degree_aform_err X" using that (*‹degree_aform_err X ≤ n›*) by (auto simp: aform_err_to_aform_def (*‹aform_err_to_aform (?X::(real × real pdevs) × real) (?n::nat) = (fst (fst ?X), pdev_upd (snd (fst ?X)) ?n (snd ?X))›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) lemma length_aforms_err_to_aforms[simp]: "length (aforms_err_to_aforms i XS) = length XS" by (auto simp: aforms_err_to_aforms_def (*‹aforms_err_to_aforms ?d ?xs = map2 (λd x. aform_err_to_aform x d) [?d..<?d + length ?xs] ?xs›*)) lemma aforms_err_to_aforms_ex: assumes X: "x ∈ aforms_err e X" assumes deg: "degree_aforms_err X ≤ n" assumes e: "e ∈ UNIV → {-1 .. 1}" shows "∃e'∈ UNIV → {-1 .. 1}. x = aform_vals e' (aforms_err_to_aforms n X) ∧ (∀i < n. e' i = e i)" using X (*‹x ∈ aforms_err e X›*) deg (*‹degree_aforms_err X ≤ n›*) proof (induction X arbitrary: x n) (*goals: 1. ‹⋀x n. ⟦x ∈ aforms_err e []; degree_aforms_err [] ≤ n⟧ ⟹ ∃e'∈UNIV → {- 1..1}. x = aform_vals e' (aforms_err_to_aforms n []) ∧ (∀i<n. e' i = e i)› 2. ‹⋀a X x n. ⟦⋀x n. ⟦x ∈ aforms_err e X; degree_aforms_err X ≤ n⟧ ⟹ ∃e'∈UNIV → {- 1..1}. x = aform_vals e' (aforms_err_to_aforms n X) ∧ (∀i<n. e' i = e i); x ∈ aforms_err e (a # X); degree_aforms_err (a # X) ≤ n⟧ ⟹ ∃e'∈UNIV → {- 1..1}. x = aform_vals e' (aforms_err_to_aforms n (a # X)) ∧ (∀i<n. e' i = e i)›*) case Nil (*‹x ∈ aforms_err e []› ‹degree_aforms_err [] ≤ (n::nat)›*) then show "?case" (*goal: ‹∃e'∈UNIV → {- 1..1}. x = aform_vals e' (aforms_err_to_aforms n []) ∧ (∀i<n. e' i = e i)›*) using e (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*) intro!: bexI[where x="λi. e i"] (*‹⟦?P e; e ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) next (*goal: ‹⋀(a::(real × real pdevs) × real) (X::((real × real pdevs) × real) list) (x::real list) n::nat. ⟦⋀(x::real list) n::nat. ⟦x ∈ aforms_err (e::nat ⇒ real) X; degree_aforms_err X ≤ n⟧ ⟹ ∃e'::nat ⇒ real∈UNIV → {- (1::real)..1::real}. x = aform_vals e' (aforms_err_to_aforms n X) ∧ (∀i<n. e' i = e i); x ∈ aforms_err e (a # X); degree_aforms_err (a # X) ≤ n⟧ ⟹ ∃e'::nat ⇒ real∈UNIV → {- (1::real)..1::real}. x = aform_vals e' (aforms_err_to_aforms n (a # X)) ∧ (∀i<n. e' i = e i)›*) case (Cons X XS) (*‹⟦?x ∈ aforms_err e XS; degree_aforms_err XS ≤ ?n⟧ ⟹ ∃e'∈UNIV → {- 1..1}. ?x = aform_vals e' (aforms_err_to_aforms ?n XS) ∧ (∀i<?n. e' i = e i)› ‹(x::real list) ∈ aforms_err (e::nat ⇒ real) ((X::(real × real pdevs) × real) # (XS::((real × real pdevs) × real) list))› ‹degree_aforms_err (X # XS) ≤ n›*) from Cons.prems (*‹x ∈ aforms_err e (X # XS)› ‹degree_aforms_err (X # XS) ≤ n›*) obtain y and ys where ys: "degree_aform_err X ≤ n" "degree_aforms_err XS ≤ n" "x = y # ys" "y ∈ aform_err e X" "ys ∈ aforms_err e XS" (*goal: ‹(⋀(y::real) ys::real list. ⟦degree_aform_err (X::(real × real pdevs) × real) ≤ (n::nat); degree_aforms_err (XS::((real × real pdevs) × real) list) ≤ n; (x::real list) = y # ys; y ∈ aform_err (e::nat ⇒ real) X; ys ∈ aforms_err e XS⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: mem_aforms_err_Cons_iff_Ex_conv (*‹(?x ∈ aforms_err ?e (?X # ?XS)) = (∃y ys. ?x = y # ys ∧ y ∈ aform_err ?e ?X ∧ ys ∈ aforms_err ?e ?XS)›*) degrees_def (*‹degrees ?X = Max (insert 0 (degree ` set ?X))›*)) then have "degree_aforms_err XS ≤ Suc n" by auto from Cons.IH[OF ys ( 5 ) this] (*‹∃e'∈UNIV → {- 1..1}. ys = aform_vals e' (aforms_err_to_aforms (Suc n) XS) ∧ (∀i<Suc n. e' i = e i)›*) obtain e' where e': "e'∈UNIV → {- 1..1}" "ys = aform_vals e' (aforms_err_to_aforms (Suc n) XS)" "(∀i<n. e' i = e i)" (*goal: ‹(⋀e'. ⟦e' ∈ UNIV → {- 1..1}; ys = aform_vals e' (aforms_err_to_aforms (Suc n) XS); ∀i<n. e' i = e i⟧ ⟹ thesis) ⟹ thesis›*) by auto from aform_err_to_aformE[OF ys ( 4 , 1 )] (*‹(⋀err. ⟦y = aform_val (e(n := err)) (aform_err_to_aform X n); - 1 ≤ err; err ≤ 1⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain err where err: "y = aform_val (e(n := err)) (aform_err_to_aform X n)" "- 1 ≤ err" "err ≤ 1" (*goal: ‹(⋀err. ⟦y = aform_val (e(n := err)) (aform_err_to_aform X n); - 1 ≤ err; err ≤ 1⟧ ⟹ thesis) ⟹ thesis›*) by auto show "?case" (*goal: ‹∃e'∈UNIV → {- 1..1}. x = aform_vals e' (aforms_err_to_aforms n (X # XS)) ∧ (∀i<n. e' i = e i)›*) proof (safe intro!: bexI[where x="e'(n:=err)"] (*‹⟦?P (e'(n := err)); e'(n := err) ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*), goal_cases) (*goals: 1. ‹x = aform_vals (e'(n := err)) (aforms_err_to_aforms n (X # XS))› 2. ‹⋀i. i < n ⟹ (e'(n := err)) i = e i› 3. ‹⋀x. x ∈ UNIV ⟹ (e'(n := err)) x ∈ {- 1..1}›*) case 1 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹x = aform_vals (e'(n := err)) (aforms_err_to_aforms n (X # XS))›*) unfolding ys e' err (*goal: ‹aform_val (e(n := err)) (aform_err_to_aform X n) # aform_vals e' (aforms_err_to_aforms (Suc n) XS) = aform_vals (e'(n := err)) (aforms_err_to_aforms n (X # XS))›*) apply (auto simp: aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) simp del: pdevs_val_upd (*‹pdevs_val (?e(?n := ?e')) ?X = pdevs_val ?e ?X - ?e ?n * pdevs_apply ?X ?n + ?e' * pdevs_apply ?X ?n›*)) (*goal: ‹aform_val (e(n := err)) (aform_err_to_aform X n) # aform_vals e' (aforms_err_to_aforms (Suc n) XS) = aform_vals (e'(n := err)) (aforms_err_to_aforms n (X # XS))›*) apply (rule pdevs_val_degree_cong (*‹⟦(?b::?'a pdevs) = (?d::?'a pdevs); ⋀i::nat. i < degree ?b ⟹ (?a::nat ⇒ real) i = (?c::nat ⇒ real) i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*)) (*top goal: ‹pdevs_val (e(n := err)) (snd (aform_err_to_aform X n)) = pdevs_val (λa. if a = n then err else e' a) (snd (aform_err_to_aform X n))› and 1 goal remains*) apply simp (*top goal: ‹snd (aform_err_to_aform X n) = snd (aform_err_to_aform X n)› and 2 goals remain*) subgoal for using ys (*‹degree_aform_err X ≤ n› ‹degree_aforms_err XS ≤ n› ‹(x::real list) = (y::real) # (ys::real list)› ‹y ∈ aform_err e X› ‹ys ∈ aforms_err e XS›*) e' (*‹e' ∈ UNIV → {- 1..1}› ‹ys = aform_vals e' (aforms_err_to_aforms (Suc n) XS)› ‹∀i<n. e' i = e i›*) by (auto dest!: less_degree_aform_aform_err_to_aformD (*‹?i < degree_aform (aform_err_to_aform ?X ?n) ⟹ ?i < max (Suc ?n) (degree_aform_err ?X)›*) simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) subgoalpremises prems for a and b proof (-) (*goal: ‹pdevs_val e' b = pdevs_val (λa. if a = n then err else e' a) b›*) have "pdevs_val (λa. if a = n then err else e' a) b = pdevs_val (e'(n:=err)) b" unfolding fun_upd_def (*goal: ‹pdevs_val (λa. if a = n then err else e' a) b = pdevs_val (λx. if x = n then err else e' x) b›*) by simp also (*calculation: ‹pdevs_val (λa. if a = n then err else e' a) b = pdevs_val (e'(n := err)) b›*) have "… = pdevs_val e' b - e' n * pdevs_apply b n + err * pdevs_apply b n" by simp also (*calculation: ‹pdevs_val (λa. if a = n then err else e' a) b = pdevs_val e' b - e' n * pdevs_apply b n + err * pdevs_apply b n›*) from prems (*‹(a::real, b::real pdevs) ∈ set (aforms_err_to_aforms (Suc (n::nat)) (XS::((real × real pdevs) × real) list))›*) obtain i where i: "aforms_err_to_aforms (Suc n) XS ! i = (a, b)" "i < length (aforms_err_to_aforms (Suc n) XS)" (*goal: ‹(⋀i::nat. ⟦aforms_err_to_aforms (Suc (n::nat)) (XS::((real × real pdevs) × real) list) ! i = (a::real, b::real pdevs); i < length (aforms_err_to_aforms (Suc n) XS)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*)) { note i(1)[symmetric] (*‹(a, b) = aforms_err_to_aforms (Suc n) XS ! i›*) also (*calculation: ‹(a, b) = aforms_err_to_aforms (Suc n) XS ! i›*) have "aforms_err_to_aforms (Suc n) XS ! i = aform_err_to_aform (XS ! i) (Suc n + i) " unfolding aforms_err_to_aforms_def (*goal: ‹map2 (λd x. aform_err_to_aform x d) [Suc n..<Suc n + length XS] XS ! i = aform_err_to_aform (XS ! i) (Suc n + i)›*) using i (*‹aforms_err_to_aforms (Suc n) XS ! i = (a, b)› ‹i < length (aforms_err_to_aforms (Suc n) XS)›*) by (simp del: upt_Suc (*‹[?i..<Suc ?j] = (if ?i ≤ ?j then [?i..<?j] @ [?j] else [])›*)) finally (*calculation: ‹(a, b) = aform_err_to_aform (XS ! i) (Suc n + i)›*) have "b = snd (aform_err_to_aform (XS ! i) (Suc n + i))" by (auto simp: prod_eq_iff (*‹((?s::?'a::type × ?'b::type) = (?t::?'a::type × ?'b::type)) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*)) } note b = this (*‹b = snd (aform_err_to_aform (XS ! i) (Suc n + i))›*) have "degree_aform_err (XS ! i) ≤ n" using ys(2) (*‹degree_aforms_err XS ≤ n›*) i (*‹aforms_err_to_aforms (Suc n) XS ! i = (a, b)› ‹i < length (aforms_err_to_aforms (Suc n) XS)›*) by (auto simp: degrees_def (*‹degrees (?X::?'a pdevs list) = Max (insert (0::nat) (degree ` set ?X))›*)) then have "n ∉ pdevs_domain b" unfolding b (*goal: ‹(n::nat) ∉ pdevs_domain (snd (aform_err_to_aform ((XS::((real × real pdevs) × real) list) ! (i::nat)) (Suc n + i)))›*) apply (subst pdevs_domain_aform_err_to_aform (*‹degree_aform_err (?X::(real × real pdevs) × real) ≤ (?n::nat) ⟹ pdevs_domain (snd (aform_err_to_aform ?X ?n)) = pdevs_domain (snd (fst ?X)) ∪ (if snd ?X = (0::real) then {} else {?n})›*)) (*goals: 1. ‹degree_aform_err (XS ! i) ≤ n ⟹ degree_aform_err (XS ! i) ≤ Suc n + i› 2. ‹degree_aform_err (XS ! i) ≤ n ⟹ n ∉ pdevs_domain (snd (fst (XS ! i))) ∪ (if snd (XS ! i) = 0 then {} else {Suc n + i})› discuss goal 1*) apply ((auto intro!: degree (*‹degree ?x ≤ ?j ⟹ pdevs_apply ?x ?j = 0›*))[1]) (*discuss goal 2*) apply ((auto intro!: degree (*‹degree ?x ≤ ?j ⟹ pdevs_apply ?x ?j = 0›*))[1]) (*proven 2 subgoals*) . then have "pdevs_apply b n = 0" by simp finally (*calculation: ‹pdevs_val (λa. if a = n then err else e' a) b = pdevs_val e' b - e' n * 0 + err * 0›*) show "?thesis" (*goal: ‹pdevs_val e' b = pdevs_val (λa. if a = n then err else e' a) b›*) by simp qed . next (*goals: 1. ‹⋀i::nat. i < (n::nat) ⟹ ((e'::nat ⇒ real)(n := err::real)) i = (e::nat ⇒ real) i› 2. ‹⋀x::nat. x ∈ UNIV ⟹ ((e'::nat ⇒ real)(n::nat := err::real)) x ∈ {- (1::real)..1::real}›*) case (2 i) (*‹i < n›*) then show "?case" (*goal: ‹(e'(n := err)) i = e i›*) using e' (*‹(e'::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› ‹ys = aform_vals e' (aforms_err_to_aforms (Suc n) XS)› ‹∀i<n. e' i = e i›*) by auto next (*goal: ‹⋀x. x ∈ UNIV ⟹ (e'(n := err)) x ∈ {- 1..1}›*) case (3 i) (*‹i ∈ UNIV›*) then show "?case" (*goal: ‹(e'(n := err)) i ∈ {- 1..1}›*) using e' (*‹(e'::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› ‹ys = aform_vals e' (aforms_err_to_aforms (Suc n) XS)› ‹∀i<n::nat. (e'::nat ⇒ real) i = (e::nat ⇒ real) i›*) err (*‹y = aform_val (e(n := err)) (aform_err_to_aform X n)› ‹- 1 ≤ err› ‹err ≤ 1›*) by auto qed qed lemma aforms_err_to_aformsE: assumes X: "x ∈ aforms_err e X" assumes deg: "degree_aforms_err X ≤ n" assumes e: "e ∈ UNIV → {-1 .. 1}" obtains e' where "x = aform_vals e' (aforms_err_to_aforms n X)" "e' ∈ UNIV → {-1 .. 1}" "⋀i. i < n ⟹ e' i = e i" using aforms_err_to_aforms_ex[OF X deg e] (*‹∃e'∈UNIV → {- 1..1}. x = aform_vals e' (aforms_err_to_aforms n X) ∧ (∀i<n. e' i = e i)›*) by blast definition "approx_floatariths p ea as = do { let da = (degree_aforms as); let aes = (map (λx. (x, 0)) as); rs ← approx_floatariths_aformerr p ea aes; let d = max da (degree_aforms_err (rs)); Some (aforms_err_to_aforms d rs) }" lemma listset_sings[simp]: "listset (map (λx. {f x}) as) = {map f as}" apply (induction as) (*goals: 1. ‹listset (map (λx::'b. {(f::'b ⇒ 'a) x}) []) = {map f []}› 2. ‹⋀(a::'b) as::'b list. listset (map (λx::'b. {(f::'b ⇒ 'a) x}) as) = {map f as} ⟹ listset (map (λx::'b. {f x}) (a # as)) = {map f (a # as)}› discuss goal 1*) apply ((auto simp: set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))[1]) (*discuss goal 2*) apply ((auto simp: set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*))[1]) (*proven 2 subgoals*) . lemma approx_floatariths_outer: assumes "approx_floatariths p ea as = Some XS" assumes "vs ∈ Joints as" shows "(interpret_floatariths ea vs @ vs) ∈ Joints (XS @ as)" proof (-) (*goal: ‹interpret_floatariths ea vs @ vs ∈ Joints (XS @ as)›*) from assms (*‹approx_floatariths p ea as = Some XS› ‹vs ∈ Joints as›*) obtain da and aes and rs and d where da: "da = degree_aforms as" and aes: "aes = (map (λx. (x, 0)) as)" and rs: "approx_floatariths_aformerr p ea aes = Some rs" and d: "d = max da (degree_aforms_err (rs))" and XS: "aforms_err_to_aforms d rs = XS" (*goal: ‹(⋀da aes rs d. ⟦da = degree_aforms as; aes = map (λx. (x, 0)) as; approx_floatariths_aformerr p ea aes = Some rs; d = max da (degree_aforms_err rs); aforms_err_to_aforms d rs = XS⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: approx_floatariths_def (*‹approx_floatariths (?p::nat) (?ea::floatarith list) (?as::(real × real pdevs) list) = (let da::nat = degree_aforms ?as; aes::((real × real pdevs) × real) list = map (λx::real × real pdevs. (x, 0::real)) ?as in approx_floatariths_aformerr ?p ?ea aes ⤜ (λrs::((real × real pdevs) × real) list. let d::nat = max da (degree_aforms_err rs) in Some (aforms_err_to_aforms d rs)))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) bind_eq_Some_conv (*‹((?f::?'b option) ⤜ (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*)) have abbd: "(a, b) ∈ set as ⟹ degree b ≤ degree_aforms as" for a and b apply (rule degrees_leD[OF order_refl] (*‹(?x::?'a pdevs) ∈ set (?X::?'a pdevs list) ⟹ degree ?x ≤ degrees ?X›*)) (*goal: ‹(a, b) ∈ set as ⟹ degree b ≤ degree_aforms as›*) by force from da (*‹da = degree_aforms as›*) d (*‹(d::nat) = max (da::nat) (degree_aforms_err (rs::((real × real pdevs) × real) list))›*) have i_less: "(a, b) ∈ set as ⟹ i < degree b ⟹ i < min d da" for i and a and b by (auto dest!: abbd (*‹(?a::real, ?b::real pdevs) ∈ set (as::(real × real pdevs) list) ⟹ degree ?b ≤ degree_aforms as›*)) have abbd: "(a, b) ∈ set as ⟹ degree b ≤ degree_aforms as" for a and b apply (rule degrees_leD[OF order_refl] (*‹?x ∈ set ?X ⟹ degree ?x ≤ degrees ?X›*)) (*goal: ‹(a, b) ∈ set as ⟹ degree b ≤ degree_aforms as›*) by force from assms (*‹approx_floatariths (p::nat) (ea::floatarith list) (as::(real × real pdevs) list) = Some (XS::(real × real pdevs) list)› ‹(vs::real list) ∈ Joints (as::(real × real pdevs) list)›*) obtain e' where vs: "vs = (map (aform_val e') as)" and e': "e' ∈ UNIV → {-1 .. 1}" (*goal: ‹(⋀e'::nat ⇒ real. ⟦(vs::real list) = map (aform_val e') (as::(real × real pdevs) list); e' ∈ UNIV → {- (1::real)..1::real}⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*)) note vs (*‹vs = map (aform_val e') as›*) also (*calculation: ‹vs = map (aform_val e') as›*) have vs_aes: "vs ∈ aforms_err e' aes" unfolding aes (*goal: ‹(vs::real list) ∈ aforms_err (e'::nat ⇒ real) (map (λx::real × real pdevs. (x, 0::real)) (as::(real × real pdevs) list))›*) by (auto simp: vs (*‹vs = map (aform_val e') as›*) aforms_err_def (*‹aforms_err ?e ?xs = listset (map (aform_err ?e) ?xs)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) from approx_floatariths_Elem[OF e' rs this] (*‹interpret_floatariths ea vs ∈ aforms_err e' rs›*) have iars: "interpret_floatariths ea (map (aform_val e') as) ∈ aforms_err e' rs" by (auto simp: vs (*‹vs = map (aform_val e') as›*)) have "degree_aforms_err rs ≤ d" by (auto simp: d (*‹d = max da (degree_aforms_err rs)›*) da (*‹da = degree_aforms as›*)) from aforms_err_to_aformsE[OF iars this e'] (*‹(⋀e'a. ⟦interpret_floatariths ea (map (aform_val e') as) = aform_vals e'a (aforms_err_to_aforms d rs); e'a ∈ UNIV → {- 1..1}; ⋀i. i < d ⟹ e'a i = e' i⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e where "interpret_floatariths ea (map (aform_val e') as) = aform_vals e XS" and e: "e ∈ UNIV → {- 1..1}" "⋀i. i < d ⟹ e i = e' i" (*goal: ‹(⋀e. ⟦interpret_floatariths ea (map (aform_val e') as) = aform_vals e XS; e ∈ UNIV → {- 1..1}; ⋀i. i < d ⟹ e i = e' i⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: XS (*‹aforms_err_to_aforms d rs = XS›*)) note this(1) (*‹interpret_floatariths ea (map (aform_val e') as) = aform_vals e XS›*) finally (*calculation: ‹interpret_floatariths ea vs = aform_vals e XS›*) have "interpret_floatariths ea vs = aform_vals e XS" . moreover from e (*‹(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› ‹?i < d ⟹ e ?i = e' ?i›*) have e'_eq: "e' i = e i" if "i < min d da" for i using that (*‹i < min d da›*) by (auto simp: min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) then have "vs = aform_vals e as" by (auto simp: vs (*‹vs = map (aform_val e') as›*) aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) intro!: pdevs_val_degree_cong (*‹⟦?b = ?d; ⋀i. i < degree ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*) e'_eq (*‹?i < min d da ⟹ e' ?i = e ?i›*) i_less (*‹⟦(?a, ?b) ∈ set as; ?i < degree ?b⟧ ⟹ ?i < min d da›*)) ultimately show "?thesis" (*goal: ‹interpret_floatariths ea vs @ vs ∈ Joints (XS @ as)›*) using e(1) (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*) aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) intro!: image_eqI[where x=e] (*‹⟦?b = ?f e; e ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) qed lemma length_eq_NilI: "length [] = length []" and length_eq_ConsI: "length xs = length ys ⟹ length (x#xs) = length (y#ys)" (*goals: 1. ‹length [] = length []› 2. ‹length xs = length ys ⟹ length (x # xs) = length (y # ys)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection ‹Generic operations on Affine Forms in Euclidean Space› lemma pdevs_val_domain_cong: assumes "b = d" assumes "⋀i. i ∈ pdevs_domain b ⟹ a i = c i" shows "pdevs_val a b = pdevs_val c d" using assms (*‹(b::'a::real_normed_vector pdevs) = (d::'a::real_normed_vector pdevs)› ‹?i ∈ pdevs_domain b ⟹ a ?i = c ?i›*) by (auto simp: pdevs_val_pdevs_domain (*‹pdevs_val ?e ?X = (∑i∈pdevs_domain ?X. ?e i *⇩R pdevs_apply ?X i)›*)) lemma fresh_JointsI: assumes "xs ∈ Joints XS" assumes "list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS" assumes "x ∈ Affine X" shows "x#xs ∈ Joints (X#XS)" using assms (*‹xs ∈ Joints XS› ‹list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS› ‹x ∈ Affine X›*) unfolding Joints_def Affine_def valuate_def (*goal: ‹x # xs ∈ (λe. map (aform_val e) (X # XS)) ` (UNIV → {- 1..1})›*) proof (safe) (*goal: ‹⋀e ea. ⟦list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS; e ∈ UNIV → {- 1..1}; xs = map (aform_val e) XS; ea ∈ UNIV → {- 1..1}; x = aform_val ea X⟧ ⟹ aform_val ea X # map (aform_val e) XS ∈ (λe. map (aform_val e) (X # XS)) ` (UNIV → {- 1..1})›*) fix e :: "nat ⇒ real" and e' :: "nat ⇒ real" assume H: "list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS" "e ∈ UNIV → {- 1..1}" "e' ∈ UNIV → {- 1..1}" (*‹list_all (λY::'a × 'a pdevs. pdevs_domain (snd (X::'a × 'a pdevs)) ∩ pdevs_domain (snd Y) = {}) (XS::('a × 'a pdevs) list)› ‹(e::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}› ‹(e'::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}›*) have "⋀a b i. ∀Y∈set XS. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {} ⟹ pdevs_apply b i ≠ 0 ⟹ pdevs_apply (snd X) i ≠ 0 ⟹ (a, b) ∉ set XS" by (metis (poly_guards_query) IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) all_not_in_conv (*‹(∀x. x ∉ ?A) = (?A = {})›*) in_pdevs_domain (*‹(?i ∈ pdevs_domain ?x) = (pdevs_apply ?x ?i ≠ 0)›*) snd_eqD (*‹snd (?x, ?y) = ?a ⟹ ?y = ?a›*)) with H (*‹list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS› ‹e ∈ UNIV → {- 1..1}› ‹(e'::nat ⇒ real) ∈ UNIV → {- (1::real)..1::real}›*) show "aform_val e' X # map (aform_val e) XS ∈ (λe. map (aform_val e) (X # XS)) ` (UNIV → {- 1..1})" apply (intro image_eqI[where x = "λi. if i ∈ pdevs_domain (snd X) then e' i else e i"] (*‹⟦?b = ?f (λi. if i ∈ pdevs_domain (snd X) then e' i else e i); (λi. if i ∈ pdevs_domain (snd X) then e' i else e i) ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*goals: 1. ‹⟦list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS; e ∈ UNIV → {- 1..1}; e' ∈ UNIV → {- 1..1}; ⋀b i a. ⟦∀Y∈set XS. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}; pdevs_apply b i ≠ 0; pdevs_apply (snd X) i ≠ 0⟧ ⟹ (a, b) ∉ set XS⟧ ⟹ aform_val e' X # map (aform_val e) XS = map (aform_val (λi. if i ∈ pdevs_domain (snd X) then e' i else e i)) (X # XS)› 2. ‹⟦list_all (λY. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}) XS; e ∈ UNIV → {- 1..1}; e' ∈ UNIV → {- 1..1}; ⋀b i a. ⟦∀Y∈set XS. pdevs_domain (snd X) ∩ pdevs_domain (snd Y) = {}; pdevs_apply b i ≠ 0; pdevs_apply (snd X) i ≠ 0⟧ ⟹ (a, b) ∉ set XS⟧ ⟹ (λi. if i ∈ pdevs_domain (snd X) then e' i else e i) ∈ UNIV → {- 1..1}› discuss goal 1*) apply ((auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) intro!: pdevs_val_domain_cong (*‹⟦?b = ?d; ⋀i. i ∈ pdevs_domain ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*))[1]) (*discuss goal 2*) apply ((auto simp: aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*) Pi_iff (*‹(?f ∈ Pi ?I ?X) = (∀i∈?I. ?f i ∈ ?X i)›*) intro!: pdevs_val_domain_cong (*‹⟦?b = ?d; ⋀i. i ∈ pdevs_domain ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*))[1]) (*proven 2 subgoals*) . qed primrec approx_slp::"nat ⇒ slp ⇒ aform_err list ⇒ aform_err list option" where "approx_slp p [] xs = Some xs" | "approx_slp p (ea # eas) xs = do { r ← approx_floatarith p ea xs; approx_slp p eas (r#xs) }" lemma Nil_mem_Joints[intro, simp]: "[] ∈ Joints []" by (force simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*)) lemma map_nth_Joints: "xs ∈ Joints XS ⟹ (⋀i. i ∈ set is ⟹ i < length XS) ⟹ map (nth xs) is @ xs ∈ Joints (map (nth XS) is @ XS)" by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*)) lemma map_nth_Joints': "xs ∈ Joints XS ⟹ (⋀i. i ∈ set is ⟹ i < length XS) ⟹ map (nth xs) is ∈ Joints (map (nth XS) is)" apply (rule Joints_appendD2[OF map_nth_Joints] (*‹⟦(?xs::?'a list) ∈ Joints (?XS::(?'a × ?'a pdevs) list); ⋀i::nat. i ∈ set (?is1::nat list) ⟹ i < length ?XS; length (map ((!) ?xs) ?is1) = length (map ((!) ?XS) ?is1)⟧ ⟹ map ((!) ?xs) ?is1 ∈ Joints (map ((!) ?XS) ?is1)›*)) (*goals: 1. ‹⟦xs ∈ Joints XS; ⋀i. i ∈ set is ⟹ i < length XS⟧ ⟹ xs ∈ Joints XS› 2. ‹⋀i. ⟦xs ∈ Joints XS; ⋀i. i ∈ set is ⟹ i < length XS; i ∈ set is⟧ ⟹ i < length XS› 3. ‹⟦xs ∈ Joints XS; ⋀i. i ∈ set is ⟹ i < length XS⟧ ⟹ length (map ((!) xs) is) = length (map ((!) XS) is)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma approx_slp_Elem: assumes e: "e ∈ UNIV → {-1 .. 1}" assumes "vs ∈ aforms_err e VS" assumes "approx_slp p ra VS = Some X" shows "interpret_slp ra vs ∈ aforms_err e X" using assms(2-) (*‹vs ∈ aforms_err e VS› ‹approx_slp (p::nat) (ra::floatarith list) (VS::((real × real pdevs) × real) list) = Some (X::((real × real pdevs) × real) list)›*) proof (induction ra arbitrary: X vs VS) (*goals: 1. ‹⋀X vs VS. ⟦vs ∈ aforms_err e VS; approx_slp p [] VS = Some X⟧ ⟹ interpret_slp [] vs ∈ aforms_err e X› 2. ‹⋀a ra X vs VS. ⟦⋀X vs VS. ⟦vs ∈ aforms_err e VS; approx_slp p ra VS = Some X⟧ ⟹ interpret_slp ra vs ∈ aforms_err e X; vs ∈ aforms_err e VS; approx_slp p (a # ra) VS = Some X⟧ ⟹ interpret_slp (a # ra) vs ∈ aforms_err e X›*) case (Cons ra ras) (*‹⟦(?vs::real list) ∈ aforms_err (e::nat ⇒ real) (?VS::((real × real pdevs) × real) list); approx_slp (p::nat) (ras::floatarith list) ?VS = Some (?X::((real × real pdevs) × real) list)⟧ ⟹ interpret_slp ras ?vs ∈ aforms_err e ?X› ‹(vs::real list) ∈ aforms_err (e::nat ⇒ real) (VS::((real × real pdevs) × real) list)› ‹approx_slp p (ra # ras) VS = Some X›*) from Cons.prems (*‹vs ∈ aforms_err e VS› ‹approx_slp p (ra # ras) VS = Some X›*) obtain a where a: "approx_floatarith p ra VS = Some a" and r: "approx_slp p ras (a # VS) = Some X" (*goal: ‹(⋀a::(real × real pdevs) × real. ⟦approx_floatarith (p::nat) (ra::floatarith) (VS::((real × real pdevs) × real) list) = Some a; approx_slp p (ras::floatarith list) (a # VS) = Some (X::((real × real pdevs) × real) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) from approx_floatarith_Elem[OF a e Cons.prems ( 1 )] (*‹interpret_floatarith ra vs ∈ aform_err e a›*) have "interpret_floatarith ra vs ∈ aform_err e a" by auto then have 1: "interpret_floatarith ra vs#vs ∈ aforms_err e (a#VS)" unfolding mem_aforms_err_Cons_iff (*goal: ‹interpret_floatarith ra vs ∈ aform_err e a ∧ vs ∈ aforms_err e VS›*) using Cons.prems(1) (*‹vs ∈ aforms_err e VS›*) by auto show "?case" (*goal: ‹interpret_slp (ra # ras) vs ∈ aforms_err e X›*) by (auto intro!: Cons.IH (*‹⟦?vs ∈ aforms_err e ?VS; approx_slp p ras ?VS = Some ?X⟧ ⟹ interpret_slp ras ?vs ∈ aforms_err e ?X›*) 1 (*‹interpret_floatarith ra vs # vs ∈ aforms_err e (a # VS)›*) r (*‹approx_slp p ras (a # VS) = Some X›*)) qed (auto) (*solved the remaining goal: ‹⋀X vs VS. ⟦vs ∈ aforms_err e VS; approx_slp p [] VS = Some X⟧ ⟹ interpret_slp [] vs ∈ aforms_err e X›*) definition "approx_slp_outer p n slp XS = do { let d = degree_aforms XS; let XSe = (map (λx. (x, 0)) XS); rs ← approx_slp p slp XSe; let rs' = take n rs; let d' = max d (degree_aforms_err rs'); Some (aforms_err_to_aforms d' rs') }" lemma take_in_listsetI: "xs ∈ listset XS ⟹ take n xs ∈ listset (take n XS)" apply (induction XS arbitrary: xs n) (*goals: 1. ‹⋀xs n. xs ∈ listset [] ⟹ take n xs ∈ listset (take n [])› 2. ‹⋀a XS xs n. ⟦⋀xs n. xs ∈ listset XS ⟹ take n xs ∈ listset (take n XS); xs ∈ listset (a # XS)⟧ ⟹ take n xs ∈ listset (take n (a # XS))› discuss goal 1*) apply ((auto simp: take_Cons (*‹take ?n (?x # ?xs) = (case ?n of 0 ⇒ [] | Suc m ⇒ ?x # take m ?xs)›*) listset_Cons_mem_conv (*‹(?a # ?vs ∈ listset ?AVS) = (∃A VS. ?AVS = A # VS ∧ ?a ∈ A ∧ ?vs ∈ listset VS)›*) set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*) split: nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 2*) apply ((auto simp: take_Cons (*‹take ?n (?x # ?xs) = (case ?n of 0 ⇒ [] | Suc m ⇒ ?x # take m ?xs)›*) listset_Cons_mem_conv (*‹(?a # ?vs ∈ listset ?AVS) = (∃A VS. ?AVS = A # VS ∧ ?a ∈ A ∧ ?vs ∈ listset VS)›*) set_Cons_def (*‹set_Cons ?A ?XS = {x # xs |x xs. x ∈ ?A ∧ xs ∈ ?XS}›*) split: nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*proven 2 subgoals*) . lemma take_in_aforms_errI: "take n xs ∈ aforms_err e (take n XS)" if "xs ∈ aforms_err e XS" using that (*‹(xs::real list) ∈ aforms_err (e::nat ⇒ real) (XS::((real × real pdevs) × real) list)›*) by (auto simp: aforms_err_def (*‹aforms_err (?e::nat ⇒ real) (?xs::((real × real pdevs) × real) list) = listset (map (aform_err ?e) ?xs)›*) take_map[symmetric] (*‹map (?f::?'b ⇒ ?'a) (take (?n::nat) (?xs::?'b list)) = take ?n (map ?f ?xs)›*) intro!: take_in_listsetI (*‹(?xs::?'a list) ∈ listset (?XS::?'a set list) ⟹ take (?n::nat) ?xs ∈ listset (take ?n ?XS)›*)) theorem approx_slp_outer: assumes "approx_slp_outer p n slp XS = Some RS" assumes slp: "slp = slp_of_fas fas" "n = length fas" assumes "xs ∈ Joints XS" shows "interpret_floatariths fas xs @ xs ∈ Joints (RS @ XS)" proof (-) (*goal: ‹interpret_floatariths fas xs @ xs ∈ Joints (RS @ XS)›*) from assms (*‹approx_slp_outer p n slp XS = Some RS› ‹slp = slp_of_fas fas› ‹(n::nat) = length (fas::floatarith list)› ‹(xs::real list) ∈ Joints (XS::(real × real pdevs) list)›*) obtain d and XSe and rs and rs' and d' where d: "d = degree_aforms XS" and XSe: "XSe = (map (λx. (x, 0)) XS)" and rs: "approx_slp p (slp_of_fas fas) XSe = Some rs" and rs': "rs' = take (length fas) rs" and d': "d' = max d (degree_aforms_err rs')" and RS: "aforms_err_to_aforms d' rs' = RS" (*goal: ‹(⋀d XSe rs rs' d'. ⟦d = degree_aforms XS; XSe = map (λx. (x, 0)) XS; approx_slp p (slp_of_fas fas) XSe = Some rs; rs' = take (length fas) rs; d' = max d (degree_aforms_err rs'); aforms_err_to_aforms d' rs' = RS⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: approx_slp_outer_def (*‹approx_slp_outer ?p ?n ?slp ?XS = (let d = degree_aforms ?XS; XSe = map (λx. (x, 0)) ?XS in approx_slp ?p ?slp XSe ⤜ (λrs. let rs' = take ?n rs; d' = max d (degree_aforms_err rs') in Some (aforms_err_to_aforms d' rs')))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) have abbd: "(a, b) ∈ set XS ⟹ degree b ≤ degree_aforms XS" for a and b apply (rule degrees_leD[OF order_refl] (*‹?x ∈ set ?X ⟹ degree ?x ≤ degrees ?X›*)) (*goal: ‹(a, b) ∈ set XS ⟹ degree b ≤ degree_aforms XS›*) by force from d' (*‹d' = max d (degree_aforms_err rs')›*) d (*‹(d::nat) = degree_aforms (XS::(real × real pdevs) list)›*) have i_less: "(a, b) ∈ set XS ⟹ i < degree b ⟹ i < min d d'" for i and a and b by (auto dest!: abbd (*‹(?a, ?b) ∈ set XS ⟹ degree ?b ≤ degree_aforms XS›*)) from assms (*‹approx_slp_outer (p::nat) (n::nat) (slp::floatarith list) (XS::(real × real pdevs) list) = Some (RS::(real × real pdevs) list)› ‹slp = slp_of_fas fas› ‹n = length fas› ‹xs ∈ Joints XS›*) obtain e' where vs: "xs = (map (aform_val e') XS)" and e': "e' ∈ UNIV → {-1 .. 1}" (*goal: ‹(⋀e'. ⟦xs = map (aform_val e') XS; e' ∈ UNIV → {- 1..1}⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*)) from d (*‹d = degree_aforms XS›*) have d: "V ∈ set XS ⟹ degree_aform V ≤ d" for V by (auto intro!: degrees_leD (*‹⟦degrees ?X ≤ ?K; ?x ∈ set ?X⟧ ⟹ degree ?x ≤ ?K›*)) have xs_XSe: "xs ∈ aforms_err e' XSe" by (auto simp: vs (*‹xs = map (aform_val e') XS›*) aforms_err_def (*‹aforms_err ?e ?xs = listset (map (aform_err ?e) ?xs)›*) XSe (*‹XSe = map (λx. (x, 0)) XS›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) aform_err_def (*‹aform_err ?e ?Xe = {aform_val ?e (fst ?Xe) - snd ?Xe..aform_val ?e (fst ?Xe) + snd ?Xe}›*)) from approx_slp_Elem[OF e' xs_XSe rs] (*‹interpret_slp (slp_of_fas fas) xs ∈ aforms_err e' rs›*) have aforms_err: "interpret_slp (slp_of_fas fas) xs ∈ aforms_err e' rs" . have "interpret_floatariths fas xs = take (length fas) (interpret_slp (slp_of_fas fas) xs)" using assms (*‹approx_slp_outer p n slp XS = Some RS› ‹slp = slp_of_fas fas› ‹n = length fas› ‹xs ∈ Joints XS›*) by (simp add: slp_of_fas (*‹take (length ?fas) (interpret_slp (slp_of_fas ?fas) ?xs) = interpret_floatariths ?fas ?xs›*)) also (*calculation: ‹interpret_floatariths fas xs = take (length fas) (interpret_slp (slp_of_fas fas) xs)›*) from aforms_err (*‹interpret_slp (slp_of_fas fas) xs ∈ aforms_err e' rs›*) have "take (length fas) (interpret_slp (slp_of_fas fas) xs) ∈ aforms_err e' rs'" unfolding rs' (*goal: ‹take (length (fas::floatarith list)) (interpret_slp (slp_of_fas fas) (xs::real list)) ∈ aforms_err (e'::nat ⇒ real) (take (length fas) (rs::((real × real pdevs) × real) list))›*) by (auto simp: take_map (*‹take ?n (map ?f ?xs) = map ?f (take ?n ?xs)›*) intro!: take_in_aforms_errI (*‹?xs ∈ aforms_err ?e ?XS ⟹ take ?n ?xs ∈ aforms_err ?e (take ?n ?XS)›*)) finally (*calculation: ‹interpret_floatariths (fas::floatarith list) (xs::real list) ∈ aforms_err (e'::nat ⇒ real) (rs'::((real × real pdevs) × real) list)›*) have ier: "interpret_floatariths fas xs ∈ aforms_err e' rs'" . have "degree_aforms_err rs' ≤ d'" using d' (*‹d' = max d (degree_aforms_err rs')›*) by auto from aforms_err_to_aformsE[OF ier this e'] (*‹(⋀e'a. ⟦interpret_floatariths fas xs = aform_vals e'a (aforms_err_to_aforms d' rs'); e'a ∈ UNIV → {- 1..1}; ⋀i. i < d' ⟹ e'a i = e' i⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e where "interpret_floatariths fas xs = aform_vals e RS" and e: "e ∈ UNIV → {- 1..1}" "⋀i. i < d' ⟹ e i = e' i" (*goal: ‹(⋀e. ⟦interpret_floatariths fas xs = aform_vals e RS; e ∈ UNIV → {- 1..1}; ⋀i. i < d' ⟹ e i = e' i⟧ ⟹ thesis) ⟹ thesis›*) unfolding RS (*goal: ‹(⋀e. ⟦interpret_floatariths fas xs = aform_vals e RS; e ∈ UNIV → {- 1..1}; ⋀i. i < d' ⟹ e i = e' i⟧ ⟹ thesis) ⟹ thesis›*) by auto moreover from e (*‹e ∈ UNIV → {- 1..1}› ‹(?i::nat) < (d'::nat) ⟹ (e::nat ⇒ real) ?i = (e'::nat ⇒ real) ?i›*) have e'_eq: "e' i = e i" if "i < min d d'" for i using that (*‹i < min d d'›*) by (auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) then have "xs = aform_vals e XS" by (auto simp: vs (*‹xs = map (aform_val e') XS›*) aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) aform_val_def (*‹aform_val ?e ?X = fst ?X + pdevs_val ?e (snd ?X)›*) intro!: pdevs_val_degree_cong (*‹⟦?b = ?d; ⋀i. i < degree ?b ⟹ ?a i = ?c i⟧ ⟹ pdevs_val ?a ?b = pdevs_val ?c ?d›*) e'_eq (*‹?i < min d d' ⟹ e' ?i = e ?i›*) i_less (*‹⟦(?a, ?b) ∈ set XS; ?i < degree ?b⟧ ⟹ ?i < min d d'›*)) ultimately show "?thesis" (*goal: ‹interpret_floatariths fas xs @ xs ∈ Joints (RS @ XS)›*) using e(1) (*‹e ∈ UNIV → {- 1..1}›*) by (auto simp: Joints_def (*‹Joints ?XS = valuate (λe. map (aform_val e) ?XS)›*) valuate_def (*‹valuate ?x = ?x ` (UNIV → {- 1..1})›*) aform_vals_def (*‹aform_vals ?e ?X = map (aform_val ?e) ?X›*) intro!: image_eqI[where x=e] (*‹⟦?b = ?f e; e ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) qed theorem approx_slp_outer_plain: assumes "approx_slp_outer p n slp XS = Some RS" assumes slp: "slp = slp_of_fas fas" "n = length fas" assumes "xs ∈ Joints XS" shows "interpret_floatariths fas xs ∈ Joints RS" proof (-) (*goal: ‹interpret_floatariths fas xs ∈ Joints RS›*) have "length fas = length RS" proof (-) (*goal: ‹length fas = length RS›*) have f1: "length xs = length XS" using Joints_imp_length_eq (*‹?xs ∈ Joints ?XS ⟹ length ?xs = length ?XS›*) assms(4) (*‹(xs::real list) ∈ Joints (XS::(real × real pdevs) list)›*) by blast have "interpret_floatariths fas xs @ xs ∈ Joints (RS @ XS)" using approx_slp_outer (*‹⟦approx_slp_outer ?p ?n ?slp ?XS = Some ?RS; ?slp = slp_of_fas ?fas; ?n = length ?fas; ?xs ∈ Joints ?XS⟧ ⟹ interpret_floatariths ?fas ?xs @ ?xs ∈ Joints (?RS @ ?XS)›*) assms(1) (*‹approx_slp_outer p n slp XS = Some RS›*) assms(2) (*‹slp = slp_of_fas fas›*) assms(3) (*‹n = length fas›*) assms(4) (*‹xs ∈ Joints XS›*) by blast then show "?thesis" (*goal: ‹length fas = length RS›*) using f1 (*‹length xs = length XS›*) Joints_imp_length_eq (*‹(?xs::?'a list) ∈ Joints (?XS::(?'a × ?'a pdevs) list) ⟹ length ?xs = length ?XS›*) by fastforce qed with Joints_appendD2[OF approx_slp_outer [ OF assms ]] (*‹length (interpret_floatariths (fas::floatarith list) (xs::real list)) = length (RS::(real × real pdevs) list) ⟹ interpret_floatariths fas xs ∈ Joints RS›*) show "?thesis" (*goal: ‹interpret_floatariths (fas::floatarith list) (xs::real list) ∈ Joints (RS::(real × real pdevs) list)›*) by simp qed end end
{ "path": "afp-2025-02-12/thys/Affine_Arithmetic/Affine_Approximation.thy", "repo": "afp-2025-02-12", "sha": "e51370634063d1ce60df748d0ba0392d6ce683eaa10bb4ad7c8ad56260142d8a" }
theory Term_Utils imports "HOL-Library.Finite_Map" "HOL-Library.Monad_Syntax" "HOL-Library.State_Monad" begin fun map2 where "map2 f (x # xs) (y # ys) = f x y # map2 f xs ys" | "map2 _ _ _ = []" lemma map2_elemE: assumes "z ∈ set (map2 f xs ys)" obtains x y where "x ∈ set xs" "y ∈ set ys" "z = f x y" using assms (*‹z ∈ set (Term_Utils.map2 f xs ys)›*) apply (induct f xs ys rule: map2.induct (*‹⟦⋀f x xs y ys. ?P f xs ys ⟹ ?P f (x # xs) (y # ys); ⋀uu_ uw_. ?P uu_ [] uw_; ⋀uu_ uv_. ?P uu_ uv_ []⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀(f::'b ⇒ 'c ⇒ 'a) (x::'b) (xs::'b list) (y::'c) ys::'c list. ⟦⟦⋀(x::'b) y::'c. ⟦x ∈ set xs; y ∈ set ys; (z::'a) = f x y⟧ ⟹ thesis::bool; z ∈ set (Term_Utils.map2 f xs ys)⟧ ⟹ thesis; ⋀(xa::'b) ya::'c. ⟦xa ∈ set (x # xs); ya ∈ set (y # ys); z = f xa ya⟧ ⟹ thesis; z ∈ set (Term_Utils.map2 f (x # xs) (y # ys))⟧ ⟹ thesis› 2. ‹⋀(uu_::'b ⇒ 'c ⇒ 'a) uw_::'c list. ⟦⋀(x::'b) y::'c. ⟦x ∈ set []; y ∈ set uw_; (z::'a) = uu_ x y⟧ ⟹ thesis::bool; z ∈ set (Term_Utils.map2 uu_ [] uw_)⟧ ⟹ thesis› 3. ‹⋀(uu_::'b ⇒ 'c ⇒ 'a) uv_::'b list. ⟦⋀(x::'b) y::'c. ⟦x ∈ set uv_; y ∈ set []; (z::'a) = uu_ x y⟧ ⟹ thesis::bool; z ∈ set (Term_Utils.map2 uu_ uv_ [])⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma map2_elemE1: assumes "length xs = length ys" "x ∈ set xs" obtains y where "y ∈ set ys" "f x y ∈ set (map2 f xs ys)" using assms (*‹length xs = length ys› ‹x ∈ set xs›*) apply (induct xs ys rule: list_induct2 (*‹⟦length ?xs = length ?ys; ?P [] []; ⋀x xs y ys. ⟦length xs = length ys; ?P xs ys⟧ ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?xs ?ys›*)) (*goals: 1. ‹⟦⋀y. ⟦y ∈ set []; f x y ∈ set (Term_Utils.map2 f [] [])⟧ ⟹ thesis; x ∈ set []⟧ ⟹ thesis› 2. ‹⋀xa xs y ys. ⟦length xs = length ys; ⟦⋀y. ⟦y ∈ set ys; f x y ∈ set (Term_Utils.map2 f xs ys)⟧ ⟹ thesis; x ∈ set xs⟧ ⟹ thesis; ⋀ya. ⟦ya ∈ set (y # ys); f x ya ∈ set (Term_Utils.map2 f (xa # xs) (y # ys))⟧ ⟹ thesis; x ∈ set (xa # xs)⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma map2_elemE2: assumes "length xs = length ys" "y ∈ set ys" obtains x where "x ∈ set xs" "f x y ∈ set (map2 f xs ys)" using assms (*‹length (xs::'a list) = length (ys::'b list)› ‹y ∈ set ys›*) apply (induct xs ys rule: list_induct2 (*‹⟦length ?xs = length ?ys; ?P [] []; ⋀x xs y ys. ⟦length xs = length ys; ?P xs ys⟧ ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?xs ?ys›*)) (*goals: 1. ‹⟦⋀x. ⟦x ∈ set []; f x y ∈ set (Term_Utils.map2 f [] [])⟧ ⟹ thesis; y ∈ set []⟧ ⟹ thesis› 2. ‹⋀x xs ya ys. ⟦length xs = length ys; ⟦⋀x. ⟦x ∈ set xs; f x y ∈ set (Term_Utils.map2 f xs ys)⟧ ⟹ thesis; y ∈ set ys⟧ ⟹ thesis; ⋀xa. ⟦xa ∈ set (x # xs); f xa y ∈ set (Term_Utils.map2 f (x # xs) (ya # ys))⟧ ⟹ thesis; y ∈ set (ya # ys)⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma map2_cong[fundef_cong]: assumes "xs1 = xs2" "ys1 = ys2" assumes fg: "⋀x y. x ∈ set xs1 ⟹ y ∈ set ys1 ⟹ f x y = g x y" shows "map2 f xs1 ys1 = map2 g xs2 ys2" proof (-) (*goal: ‹Term_Utils.map2 (f::'a ⇒ 'b ⇒ 'c) (xs1::'a list) (ys1::'b list) = Term_Utils.map2 (g::'a ⇒ 'b ⇒ 'c) (xs2::'a list) (ys2::'b list)›*) have "map2 f xs1 ys1 = map2 g xs1 ys1" using fg (*‹⟦(?x::'a) ∈ set (xs1::'a list); (?y::'b) ∈ set (ys1::'b list)⟧ ⟹ (f::'a ⇒ 'b ⇒ 'c) ?x ?y = (g::'a ⇒ 'b ⇒ 'c) ?x ?y›*) apply (induction f xs1 ys1 rule: map2.induct (*‹⟦⋀(f::?'a ⇒ ?'b ⇒ ?'c) (x::?'a) (xs::?'a list) (y::?'b) ys::?'b list. (?P::(?'a ⇒ ?'b ⇒ ?'c) ⇒ ?'a list ⇒ ?'b list ⇒ bool) f xs ys ⟹ ?P f (x # xs) (y # ys); ⋀(uu_::?'a ⇒ ?'b ⇒ ?'c) uw_::?'b list. ?P uu_ [] uw_; ⋀(uu_::?'a ⇒ ?'b ⇒ ?'c) uv_::?'a list. ?P uu_ uv_ []⟧ ⟹ ?P (?a0.0::?'a ⇒ ?'b ⇒ ?'c) (?a1.0::?'a list) (?a2.0::?'b list)›*)) (*goals: 1. ‹⋀f x xs y ys. ⟦(⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ f x y = g x y) ⟹ Term_Utils.map2 f xs ys = Term_Utils.map2 g xs ys; ⋀xa ya. ⟦xa ∈ set (x # xs); ya ∈ set (y # ys)⟧ ⟹ f xa ya = g xa ya⟧ ⟹ Term_Utils.map2 f (x # xs) (y # ys) = Term_Utils.map2 g (x # xs) (y # ys)› 2. ‹⋀uu_ uw_. (⋀x y. ⟦x ∈ set []; y ∈ set uw_⟧ ⟹ uu_ x y = g x y) ⟹ Term_Utils.map2 uu_ [] uw_ = Term_Utils.map2 g [] uw_› 3. ‹⋀uu_ uv_. (⋀x y. ⟦x ∈ set uv_; y ∈ set []⟧ ⟹ uu_ x y = g x y) ⟹ Term_Utils.map2 uu_ uv_ [] = Term_Utils.map2 g uv_ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with assms (*‹xs1 = xs2› ‹ys1 = ys2› ‹⟦(?x::'a) ∈ set (xs1::'a list); (?y::'b) ∈ set (ys1::'b list)⟧ ⟹ (f::'a ⇒ 'b ⇒ 'c) ?x ?y = (g::'a ⇒ 'b ⇒ 'c) ?x ?y›*) show "?thesis" (*goal: ‹Term_Utils.map2 (f::'a ⇒ 'b ⇒ 'c) (xs1::'a list) (ys1::'b list) = Term_Utils.map2 (g::'a ⇒ 'b ⇒ 'c) (xs2::'a list) (ys2::'b list)›*) by simp qed lemma option_bindE: assumes "x ⤜ f = Some a" obtains x' where "x = Some x'" "f x' = Some a" using assms (*‹x ⤜ f = Some a›*) apply (cases x) (*goals: 1. ‹⟦⋀x'. ⟦x = Some x'; f x' = Some a⟧ ⟹ thesis; x ⤜ f = Some a; x = None⟧ ⟹ thesis› 2. ‹⋀aa. ⟦⋀x'. ⟦x = Some x'; f x' = Some a⟧ ⟹ thesis; x ⤜ f = Some a; x = Some aa⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma rel_option_bind[intro]: assumes "rel_option R x y" "⋀a b. R a b ⟹ rel_option R (f a) (g b)" shows "rel_option R (x ⤜ f) (y ⤜ g)" using assms(1) (*‹rel_option R x y›*) proof (cases rule: option.rel_cases (*‹⟦rel_option ?R ?a ?b; ⟦?a = None; ?b = None⟧ ⟹ ?thesis; ⋀x y. ⟦?a = Some x; ?b = Some y; ?R x y⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦(x::'a::type option) = None; (y::'b::type option) = None⟧ ⟹ rel_option (R::'a::type ⇒ 'b::type ⇒ bool) (x ⤜ (f::'a::type ⇒ 'a::type option)) (y ⤜ (g::'b::type ⇒ 'b::type option))› 2. ‹⋀(xa::'a::type) ya::'b::type. ⟦(x::'a::type option) = Some xa; (y::'b::type option) = Some ya; (R::'a::type ⇒ 'b::type ⇒ bool) xa ya⟧ ⟹ rel_option R (x ⤜ (f::'a::type ⇒ 'a::type option)) (y ⤜ (g::'b::type ⇒ 'b::type option))›*) case None (*‹x = None› ‹y = None›*) thus "?thesis" (*goal: ‹rel_option R (x ⤜ f) (y ⤜ g)›*) by simp next (*goal: ‹⋀xa ya. ⟦x = Some xa; y = Some ya; R xa ya⟧ ⟹ rel_option R (x ⤜ f) (y ⤜ g)›*) case (Some a b) (*‹x = Some a› ‹y = Some b› ‹R a b›*) thus "?thesis" (*goal: ‹rel_option (R::'a::type ⇒ 'b::type ⇒ bool) ((x::'a::type option) ⤜ (f::'a::type ⇒ 'a::type option)) ((y::'b::type option) ⤜ (g::'b::type ⇒ 'b::type option))›*) using assms(2) (*‹R ?a ?b ⟹ rel_option R (f ?a) (g ?b)›*) by simp qed lemma list_split: assumes "n < length xs" obtains xs₁ xs₂ where "xs = xs₁ @ xs₂" "n = length xs₂" "0 < length xs₁" proof (standard) (*goals: 1. ‹(⋀(xs₁::'a::type list) xs₂::'a::type list. ⟦(xs::'a::type list) = xs₁ @ xs₂; (n::nat) = length xs₂; (0::nat) < length xs₁⟧ ⟹ thesis::bool) ⟹ xs = (?xs₁2::'a::type list) @ (?xs₂2::'a::type list)› 2. ‹(⋀(xs₁::'a::type list) xs₂::'a::type list. ⟦(xs::'a::type list) = xs₁ @ xs₂; (n::nat) = length xs₂; (0::nat) < length xs₁⟧ ⟹ thesis::bool) ⟹ n = length (?xs₂2::'a::type list)› 3. ‹(⋀(xs₁::'a::type list) xs₂::'a::type list. ⟦(xs::'a::type list) = xs₁ @ xs₂; (n::nat) = length xs₂; (0::nat) < length xs₁⟧ ⟹ thesis::bool) ⟹ (0::nat) < length (?xs₁2::'a::type list)›*) let ?xs₁ = "take (length xs - n) xs" let ?xs₂ = "drop (length xs - n) xs" show "xs = ?xs₁ @ ?xs₂" by simp show "n = length ?xs₂" "0 < length ?xs₁" using assms (*‹n < length xs›*) apply - (*goals: 1. ‹n < length xs ⟹ n = length (drop (length xs - n) xs)› 2. ‹n < length xs ⟹ 0 < length (take (length xs - n) xs)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed context includes fset.lifting begin lemma ffUnion_alt_def: "x |∈| ffUnion A ⟷ fBex A (λX. x |∈| X)" apply transfer (*goal: ‹(x |∈| ffUnion A) = (∃X|∈|A. x |∈| X)›*) by blast lemma funion_image_bind_eq: "ffUnion (f |`| M) = fbind M f" apply transfer (*goal: ‹ffUnion (f |`| M) = fbind M f›*) by auto lemma fbind_funion: "fbind (M |∪| N) f = fbind M f |∪| fbind N f" apply transfer' (*goal: ‹fbind (M |∪| N) f = fbind M f |∪| fbind N f›*) by auto lemma ffUnion_least: "fBall A (λX. X |⊆| C) ⟹ ffUnion A |⊆| C" apply transfer (*goal: ‹∀X::'a fset|∈|A::'a fset fset. X |⊆| (C::'a fset) ⟹ ffUnion A |⊆| C›*) by blast lemma fbind_iff: "x |∈| fbind S f ⟷ (∃s. x |∈| f s ∧ s |∈| S)" apply transfer' (*goal: ‹(x |∈| fbind S f) = (∃s. x |∈| f s ∧ s |∈| S)›*) by auto lemma fBall_pred_weaken: "(⋀x. x |∈| M ⟹ P x ⟹ Q x) ⟹ fBall M P ⟹ fBall M Q" by auto end lemma fmmap_fmupd[simp]: "fmmap f (fmupd k v m) = fmupd k (f v) (fmmap f m)" apply (rule fmap_ext (*‹(⋀x. fmlookup ?m x = fmlookup ?n x) ⟹ ?m = ?n›*)) (*goal: ‹fmmap (f::'c::type ⇒ 'b::type) (fmupd (k::'a::type) (v::'c::type) (m::('a::type, 'c::type) fmap)) = fmupd k (f v) (fmmap f m)›*) by auto definition fmlookup_default :: "('a, 'b) fmap ⇒ ('a ⇒ 'b) ⇒ 'a ⇒ 'b" where "fmlookup_default m f x = (case fmlookup m x of None ⇒ f x | Some b ⇒ b)" end
{ "path": "afp-2025-02-12/thys/Higher_Order_Terms/Term_Utils.thy", "repo": "afp-2025-02-12", "sha": "ad10c446a10fafa5950d35277ab6f6f375503b0d37bcd643811900e20737523d" }
section ‹\isaheader{Set Interface}› theory Intf_Set imports Refine_Monadic.Refine_Monadic begin consts i_set :: "interface ⇒ interface" lemmas [autoref_rel_intf] = REL_INTFI[of set_rel i_set] definition [simp]: "op_set_delete x s ≡ s - {x}" definition [simp]: "op_set_isEmpty s ≡ s = {}" definition [simp]: "op_set_isSng s ≡ card s = 1" definition [simp]: "op_set_size_abort m s ≡ min m (card s)" definition [simp]: "op_set_disjoint a b ≡ a∩b={}" definition [simp]: "op_set_filter P s ≡ {x∈s. P x}" definition [simp]: "op_set_sel P s ≡ SPEC (λx. x∈s ∧ P x)" definition [simp]: "op_set_pick s ≡ SPEC (λx. x∈s)" definition [simp]: "op_set_to_sorted_list ordR s ≡ SPEC (λl. set l = s ∧ distinct l ∧ sorted_wrt ordR l)" definition [simp]: "op_set_to_list s ≡ SPEC (λl. set l = s ∧ distinct l)" definition [simp]: "op_set_cart x y ≡ x × y" (* TODO: Do op_set_pick_remove (like op_map_pick_remove) *) context begin interpretation autoref_syn . lemma [autoref_op_pat]: fixes s a b :: "'a set" and x::'a and P :: "'a ⇒ bool" shows "s - {x} ≡ op_set_delete$x$s" "s = {} ≡ op_set_isEmpty$s" "{}=s ≡ op_set_isEmpty$s" "card s = 1 ≡ op_set_isSng$s" "∃x. s={x} ≡ op_set_isSng$s" "∃x. {x}=s ≡ op_set_isSng$s" "min m (card s) ≡ op_set_size_abort$m$s" "min (card s) m ≡ op_set_size_abort$m$s" "a∩b={} ≡ op_set_disjoint$a$b" "{x∈s. P x} ≡ op_set_filter$P$s" "SPEC (λx. x∈s ∧ P x) ≡ op_set_sel$P$s" "SPEC (λx. P x ∧ x∈s) ≡ op_set_sel$P$s" "SPEC (λx. x∈s) ≡ op_set_pick$s" (*goals: 1. ‹s - {x} ≡ op_set_delete $ x $ s› 2. ‹s = {} ≡ op_set_isEmpty $ s› 3. ‹{} = s ≡ op_set_isEmpty $ s› 4. ‹card s = 1 ≡ op_set_isSng $ s› 5. ‹∃x. s = {x} ≡ op_set_isSng $ s› 6. ‹∃x. {x} = s ≡ op_set_isSng $ s› 7. ‹min m (card s) ≡ op_set_size_abort $ m $ s› 8. ‹min (card s) m ≡ op_set_size_abort $ m $ s› 9. ‹a ∩ b = {} ≡ op_set_disjoint $ a $ b› 10. ‹{x ∈ s. P x} ≡ op_set_filter $ P $ s› 11. ‹SPEC (λx. x ∈ s ∧ P x) ≡ op_set_sel $ P $ s› 12. ‹SPEC (λx. P x ∧ x ∈ s) ≡ op_set_sel $ P $ s› 13. ‹SPEC (λx. x ∈ s) ≡ op_set_pick $ s› discuss goal 1*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 2*) apply ((auto intro!: eq_reflection (*‹(?x::?'a) = (?y::?'a) ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card (?A::?'a set) = Suc (?k::nat)) = (∃(b::?'a) B::?'a set. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = (0::nat) ⟶ B = {}))›*))[1]) (*discuss goal 3*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 4*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 5*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 6*) apply ((auto intro!: eq_reflection (*‹(?x::?'a::type) = (?y::?'a::type) ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card (?A::?'a::type set) = Suc (?k::nat)) = (∃(b::?'a::type) B::?'a::type set. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = (0::nat) ⟶ B = {}))›*))[1]) (*discuss goal 7*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 8*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 9*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 10*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 11*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 12*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*discuss goal 13*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*))[1]) (*proven 13 subgoals*) . lemma [autoref_op_pat]: "a × b ≡ op_set_cart a b" by (auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*) simp: card_Suc_eq (*‹(card ?A = Suc ?k) = (∃b B. ?A = insert b B ∧ b ∉ B ∧ card B = ?k ∧ (?k = 0 ⟶ B = {}))›*)) lemma [autoref_op_pat]: "SPEC (λ(u,v). (u,v)∈s) ≡ op_set_pick$s" "SPEC (λ(u,v). P u v ∧ (u,v)∈s) ≡ op_set_sel$(case_prod P)$s" "SPEC (λ(u,v). (u,v)∈s ∧ P u v) ≡ op_set_sel$(case_prod P)$s" (*goals: 1. ‹SPEC (λ(u, v). (u, v) ∈ s) ≡ op_set_pick $ s› 2. ‹SPEC (λ(u, v). P u v ∧ (u, v) ∈ s) ≡ op_set_sel $ (λ(x, y). P x y) $ s› 3. ‹SPEC (λ(u, v). (u, v) ∈ s ∧ P u v) ≡ op_set_sel $ (λ(x, y). P x y) $ s› discuss goal 1*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 2*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 3*) apply ((auto intro!: eq_reflection (*‹(?x::?'a) = (?y::?'a) ⟹ ?x ≡ ?y›*))[1]) (*proven 3 subgoals*) . lemma [autoref_op_pat]: "SPEC (λl. set l = s ∧ distinct l ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. set l = s ∧ sorted_wrt ordR l ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. distinct l ∧ set l = s ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. distinct l ∧ sorted_wrt ordR l ∧ set l = s) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. sorted_wrt ordR l ∧ distinct l ∧ set l = s) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. sorted_wrt ordR l ∧ set l = s ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. s = set l ∧ distinct l ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. s = set l ∧ sorted_wrt ordR l ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. distinct l ∧ s = set l ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. distinct l ∧ sorted_wrt ordR l ∧ s = set l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. sorted_wrt ordR l ∧ distinct l ∧ s = set l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. sorted_wrt ordR l ∧ s = set l ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR)$s" "SPEC (λl. set l = s ∧ distinct l) ≡ op_set_to_list$s" "SPEC (λl. distinct l ∧ set l = s) ≡ op_set_to_list$s" "SPEC (λl. s = set l ∧ distinct l) ≡ op_set_to_list$s" "SPEC (λl. distinct l ∧ s = set l) ≡ op_set_to_list$s" (*goals: 1. ‹SPEC (λl. set l = s ∧ distinct l ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR) $ s› 2. ‹SPEC (λl. set l = s ∧ sorted_wrt ordR l ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR) $ s› 3. ‹SPEC (λl. distinct l ∧ set l = s ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR) $ s› 4. ‹SPEC (λl. distinct l ∧ sorted_wrt ordR l ∧ set l = s) ≡ OP (op_set_to_sorted_list ordR) $ s› 5. ‹SPEC (λl. sorted_wrt ordR l ∧ distinct l ∧ set l = s) ≡ OP (op_set_to_sorted_list ordR) $ s› 6. ‹SPEC (λl. sorted_wrt ordR l ∧ set l = s ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR) $ s› 7. ‹SPEC (λl. s = set l ∧ distinct l ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR) $ s› 8. ‹SPEC (λl. s = set l ∧ sorted_wrt ordR l ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR) $ s› 9. ‹SPEC (λl. distinct l ∧ s = set l ∧ sorted_wrt ordR l) ≡ OP (op_set_to_sorted_list ordR) $ s› 10. ‹SPEC (λl. distinct l ∧ sorted_wrt ordR l ∧ s = set l) ≡ OP (op_set_to_sorted_list ordR) $ s› 11. ‹SPEC (λl. sorted_wrt ordR l ∧ distinct l ∧ s = set l) ≡ OP (op_set_to_sorted_list ordR) $ s› 12. ‹SPEC (λl. sorted_wrt ordR l ∧ s = set l ∧ distinct l) ≡ OP (op_set_to_sorted_list ordR) $ s› 13. ‹SPEC (λl. set l = s ∧ distinct l) ≡ op_set_to_list $ s› 14. ‹SPEC (λl. distinct l ∧ set l = s) ≡ op_set_to_list $ s› 15. ‹SPEC (λl. s = set l ∧ distinct l) ≡ op_set_to_list $ s› 16. ‹SPEC (λl. distinct l ∧ s = set l) ≡ op_set_to_list $ s› discuss goal 1*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 2*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 3*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 4*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 5*) apply ((auto intro!: eq_reflection (*‹(?x::?'a) = (?y::?'a) ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 6*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 7*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 8*) apply ((auto intro!: eq_reflection (*‹(?x::?'a) = (?y::?'a) ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 9*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 10*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 11*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 12*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 13*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 14*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 15*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*discuss goal 16*) apply ((auto intro!: eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*))[1]) (*proven 16 subgoals*) . end lemma [autoref_itype]: "{} ::⇩i ⟨I⟩⇩ii_set" "insert ::⇩i I →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "op_set_delete ::⇩i I →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "(∈) ::⇩i I →⇩i ⟨I⟩⇩ii_set →⇩i i_bool" "op_set_isEmpty ::⇩i ⟨I⟩⇩ii_set →⇩i i_bool" "op_set_isSng ::⇩i ⟨I⟩⇩ii_set →⇩i i_bool" "(∪) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "(∩) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "((-) :: 'a set ⇒ 'a set ⇒ 'a set) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "((=) :: 'a set ⇒ 'a set ⇒ bool) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i i_bool" "(⊆) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i i_bool" "op_set_disjoint ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i i_bool" "Ball ::⇩i ⟨I⟩⇩ii_set →⇩i (I →⇩i i_bool) →⇩i i_bool" "Bex ::⇩i ⟨I⟩⇩ii_set →⇩i (I →⇩i i_bool) →⇩i i_bool" "op_set_filter ::⇩i (I →⇩i i_bool) →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "card ::⇩i ⟨I⟩⇩ii_set →⇩i i_nat" "op_set_size_abort ::⇩i i_nat →⇩i ⟨I⟩⇩ii_set →⇩i i_nat" "set ::⇩i ⟨I⟩⇩ii_list →⇩i ⟨I⟩⇩ii_set" "op_set_sel ::⇩i (I →⇩i i_bool) →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_nres" "op_set_pick ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_nres" "Sigma ::⇩i ⟨Ia⟩⇩ii_set →⇩i (Ia →⇩i ⟨Ib⟩⇩ii_set) →⇩i ⟨⟨Ia,Ib⟩⇩ii_prod⟩⇩ii_set" "(`) ::⇩i (Ia→⇩iIb) →⇩i ⟨Ia⟩⇩ii_set →⇩i ⟨Ib⟩⇩ii_set" "op_set_cart ::⇩i ⟨Ix⟩⇩iIsx →⇩i ⟨Iy⟩⇩iIsy →⇩i ⟨⟨Ix, Iy⟩⇩ii_prod⟩⇩iIsp" "Union ::⇩i ⟨⟨I⟩⇩ii_set⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set" "atLeastLessThan ::⇩i i_nat →⇩i i_nat →⇩i ⟨i_nat⟩⇩ii_set" (*goals: 1. ‹{} ::⇩i ⟨I⟩⇩ii_set› 2. ‹insert ::⇩i I →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 3. ‹op_set_delete ::⇩i I →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 4. ‹(∈) ::⇩i I →⇩i ⟨I⟩⇩ii_set →⇩i i_bool› 5. ‹op_set_isEmpty ::⇩i ⟨I⟩⇩ii_set →⇩i i_bool› 6. ‹op_set_isSng ::⇩i ⟨I⟩⇩ii_set →⇩i i_bool› 7. ‹(∪) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 8. ‹(∩) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 9. ‹(-) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 10. ‹(=) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i i_bool› 11. ‹(⊆) ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i i_bool› 12. ‹op_set_disjoint ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set →⇩i i_bool› 13. ‹Ball ::⇩i ⟨I⟩⇩ii_set →⇩i (I →⇩i i_bool) →⇩i i_bool› 14. ‹Bex ::⇩i ⟨I⟩⇩ii_set →⇩i (I →⇩i i_bool) →⇩i i_bool› 15. ‹op_set_filter ::⇩i (I →⇩i i_bool) →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 16. ‹card ::⇩i ⟨I⟩⇩ii_set →⇩i i_nat› 17. ‹op_set_size_abort ::⇩i i_nat →⇩i ⟨I⟩⇩ii_set →⇩i i_nat› 18. ‹set ::⇩i ⟨I⟩⇩ii_list →⇩i ⟨I⟩⇩ii_set› 19. ‹op_set_sel ::⇩i (I →⇩i i_bool) →⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_nres› 20. ‹op_set_pick ::⇩i ⟨I⟩⇩ii_set →⇩i ⟨I⟩⇩ii_nres› 21. ‹Sigma ::⇩i ⟨Ia⟩⇩ii_set →⇩i (Ia →⇩i ⟨Ib⟩⇩ii_set) →⇩i ⟨⟨Ia, Ib⟩⇩ii_prod⟩⇩ii_set› 22. ‹(`) ::⇩i (Ia →⇩i Ib) →⇩i ⟨Ia⟩⇩ii_set →⇩i ⟨Ib⟩⇩ii_set› 23. ‹op_set_cart ::⇩i ⟨Ix⟩⇩iIsx →⇩i ⟨Iy⟩⇩iIsy →⇩i ⟨⟨Ix, Iy⟩⇩ii_prod⟩⇩iIsp› 24. ‹⋃ ::⇩i ⟨⟨I⟩⇩ii_set⟩⇩ii_set →⇩i ⟨I⟩⇩ii_set› 25. ‹atLeastLessThan ::⇩i i_nat →⇩i i_nat →⇩i ⟨i_nat⟩⇩ii_set› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*discuss goal 7*) apply simp (*discuss goal 8*) apply simp (*discuss goal 9*) apply simp (*discuss goal 10*) apply simp (*discuss goal 11*) apply simp (*discuss goal 12*) apply simp (*discuss goal 13*) apply simp (*discuss goal 14*) apply simp (*discuss goal 15*) apply simp (*discuss goal 16*) apply simp (*discuss goal 17*) apply simp (*discuss goal 18*) apply simp (*discuss goal 19*) apply simp (*discuss goal 20*) apply simp (*discuss goal 21*) apply simp (*discuss goal 22*) apply simp (*discuss goal 23*) apply simp (*discuss goal 24*) apply simp (*discuss goal 25*) apply simp (*proven 25 subgoals*) . lemma hom_set1[autoref_hom]: "CONSTRAINT {} (⟨R⟩Rs)" "CONSTRAINT insert (R→⟨R⟩Rs→⟨R⟩Rs)" "CONSTRAINT (∈) (R→⟨R⟩Rs→Id)" "CONSTRAINT (∪) (⟨R⟩Rs→⟨R⟩Rs→⟨R⟩Rs)" "CONSTRAINT (∩) (⟨R⟩Rs→⟨R⟩Rs→⟨R⟩Rs)" "CONSTRAINT (-) (⟨R⟩Rs→⟨R⟩Rs→⟨R⟩Rs)" "CONSTRAINT (=) (⟨R⟩Rs→⟨R⟩Rs→Id)" "CONSTRAINT (⊆) (⟨R⟩Rs→⟨R⟩Rs→Id)" "CONSTRAINT Ball (⟨R⟩Rs→(R→Id)→Id)" "CONSTRAINT Bex (⟨R⟩Rs→(R→Id)→Id)" "CONSTRAINT card (⟨R⟩Rs→Id)" "CONSTRAINT set (⟨R⟩Rl→⟨R⟩Rs)" "CONSTRAINT (`) ((Ra→Rb) → ⟨Ra⟩Rs→⟨Rb⟩Rs)" "CONSTRAINT Union (⟨⟨R⟩Ri⟩Ro → ⟨R⟩Ri)" (*goals: 1. ‹CONSTRAINT {} (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set))› 2. ‹CONSTRAINT insert ((R::('c::type × 'a::type) set) → ⟨R⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨R⟩Rs)› 3. ‹CONSTRAINT (∈) ((R::('c::type × 'a::type) set) → ⟨R⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → bool_rel)› 4. ‹CONSTRAINT (∪) (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨R⟩Rs → ⟨R⟩Rs)› 5. ‹CONSTRAINT (∩) (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨R⟩Rs → ⟨R⟩Rs)› 6. ‹CONSTRAINT (-) (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨R⟩Rs → ⟨R⟩Rs)› 7. ‹CONSTRAINT (=) (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨R⟩Rs → bool_rel)› 8. ‹CONSTRAINT (⊆) (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨R⟩Rs → bool_rel)› 9. ‹CONSTRAINT Ball (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → (R → bool_rel) → bool_rel)› 10. ‹CONSTRAINT Bex (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → (R → bool_rel) → bool_rel)› 11. ‹CONSTRAINT card (⟨R::('c::type × 'a::type) set⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → nat_rel)› 12. ‹CONSTRAINT set (⟨R::('c::type × 'a::type) set⟩(Rl::('c::type × 'a::type) set ⇒ ('d::type × 'a::type list) set) → ⟨R⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set))› 13. ‹CONSTRAINT (`) (((Ra::('c::type × 'a::type) set) → (Rb::('c::type × 'a::type) set)) → ⟨Ra⟩(Rs::('c::type × 'a::type) set ⇒ ('b::type × 'a::type set) set) → ⟨Rb⟩Rs)› 14. ‹CONSTRAINT ⋃ (⟨⟨R::('c::type × 'a::type) set⟩(Ri::('c::type × 'a::type) set ⇒ ('g::type × 'e::type set) set)⟩(Ro::('g::type × 'e::type set) set ⇒ ('f::type × 'e::type set set) set) → ⟨R⟩Ri)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*discuss goal 7*) apply simp (*discuss goal 8*) apply simp (*discuss goal 9*) apply simp (*discuss goal 10*) apply simp (*discuss goal 11*) apply simp (*discuss goal 12*) apply simp (*discuss goal 13*) apply simp (*discuss goal 14*) apply simp (*proven 14 subgoals*) . lemma hom_set2[autoref_hom]: "CONSTRAINT op_set_delete (R→⟨R⟩Rs→⟨R⟩Rs)" "CONSTRAINT op_set_isEmpty (⟨R⟩Rs→Id)" "CONSTRAINT op_set_isSng (⟨R⟩Rs→Id)" "CONSTRAINT op_set_size_abort (Id→⟨R⟩Rs→Id)" "CONSTRAINT op_set_disjoint (⟨R⟩Rs→⟨R⟩Rs→Id)" "CONSTRAINT op_set_filter ((R→Id)→⟨R⟩Rs→⟨R⟩Rs)" "CONSTRAINT op_set_sel ((R → Id)→⟨R⟩Rs→⟨R⟩Rn)" "CONSTRAINT op_set_pick (⟨R⟩Rs→⟨R⟩Rn)" (*goals: 1. ‹CONSTRAINT op_set_delete (R → ⟨R⟩Rs → ⟨R⟩Rs)› 2. ‹CONSTRAINT op_set_isEmpty (⟨R⟩Rs → bool_rel)› 3. ‹CONSTRAINT op_set_isSng (⟨R⟩Rs → bool_rel)› 4. ‹CONSTRAINT op_set_size_abort (nat_rel → ⟨R⟩Rs → nat_rel)› 5. ‹CONSTRAINT op_set_disjoint (⟨R⟩Rs → ⟨R⟩Rs → bool_rel)› 6. ‹CONSTRAINT op_set_filter ((R → bool_rel) → ⟨R⟩Rs → ⟨R⟩Rs)› 7. ‹CONSTRAINT op_set_sel ((R → bool_rel) → ⟨R⟩Rs → ⟨R⟩Rn)› 8. ‹CONSTRAINT op_set_pick (⟨R⟩Rs → ⟨R⟩Rn)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*discuss goal 7*) apply simp (*discuss goal 8*) apply simp (*proven 8 subgoals*) . lemma hom_set_Sigma[autoref_hom]: "CONSTRAINT Sigma (⟨Ra⟩Rs → (Ra → ⟨Rb⟩Rs) → ⟨⟨Ra,Rb⟩prod_rel⟩Rs2)" by simp definition "finite_set_rel R ≡ Range R ⊆ Collect (finite)" lemma finite_set_rel_trigger: "finite_set_rel R ⟹ finite_set_rel R" . declaration ‹Tagged_Solver.add_triggers "Relators.relator_props_solver" @{thms finite_set_rel_trigger}› end
{ "path": "afp-2025-02-12/thys/Collections/GenCF/Intf/Intf_Set.thy", "repo": "afp-2025-02-12", "sha": "144d1aeddcbc2628434c26f1a95bde8391d1ab89495e07fb745558d4d4f8b9d0" }
chapter ‹Abstract Formulation of Tarski's Theorems› text ‹We prove Tarski's proof-theoretic and semantic theorems about the non-definability and respectively non-expressiveness (in the standard model) of truth› (*<*) theory Tarski imports Goedel_Formula Standard_Model_More begin (*>*) section ‹Non-Definability of Truth› context Goedel_Form begin context fixes T :: 'fmla assumes T[simp,intro!]: "T ∈ fmla" and Fvars_T[simp]: "Fvars T = {xx}" and prv_T: "⋀φ. φ ∈ fmla ⟹ Fvars φ = {} ⟹ prv (eqv (subst T ⟨φ⟩ xx) φ)" begin definition φT :: 'fmla where "φT ≡ diag (neg T)" lemma φT[simp,intro!]: "φT ∈ fmla" and Fvars_φT[simp]: "Fvars φT = {}" unfolding "φT_def" PP_def (*goals: 1. ‹diag (neg T) ∈ fmla› 2. ‹Fvars (diag (neg T)) = {}›*) (*goals: 1. ‹diag (neg T) ∈ fmla› 2. ‹Fvars (diag (neg T)) = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma bprv_φT_eqv: "bprv (eqv φT (neg (subst T ⟨φT⟩ xx)))" unfolding "φT_def" (*goal: ‹bprv (eqv (diag (neg T)) (neg (subst T ⟨diag (neg T)⟩ xx)))›*) using bprv_diag_eqv[of "neg T"] (*‹⟦neg T ∈ fmla; Fvars (neg T) = {xx}⟧ ⟹ bprv (eqv (diag (neg T)) (subst (neg T) ⟨diag (neg T)⟩ xx))›*) by simp lemma prv_φT_eqv: "prv (eqv φT (neg (subst T ⟨φT⟩ xx)))" using d_dwf.bprv_prv'[OF _ bprv_φT_eqv, simplified] (*‹prv (eqv φT (neg (subst T ⟨φT⟩ xx)))›*) . lemma φT_prv_fls: "prv fls" using prv_eqv_eqv_neg_prv_fls2[OF _ _ prv_T [ OF φT Fvars_φT ] prv_φT_eqv] (*‹⟦subst T ⟨φT⟩ xx ∈ fmla; φT ∈ fmla⟧ ⟹ prv fls›*) by auto end ― ‹context› theorem Tarski_proof_theoretic: assumes "T ∈ fmla" "Fvars T = {xx}" and "⋀φ. φ ∈ fmla ⟹ Fvars φ = {} ⟹ prv (eqv (subst T ⟨φ⟩ xx) φ)" shows "¬ consistent" using "φT_prv_fls"[OF assms] (*‹⟦⋀φ. ⟦φ ∈ fmla; Fvars φ = {}⟧ ⟹ φ ∈ fmla; ⋀φ. ⟦φ ∈ fmla; Fvars φ = {}⟧ ⟹ Fvars φ = {}⟧ ⟹ prv fls›*) consistent_def (*‹consistent ≡ ¬ prv fls›*) by auto end ― ‹context @{locale Goedel_Form}› section ‹Non-Expressiveness of Truth› text ‹This follows as a corollary of the syntactic version, after taking prv to be isTrue on sentences.Indeed, this is a virtue of our abstract treatment of provability: We don't work with a particular predicate, but with any predicate that is closed under some rules --- which could as well be a semantic notion of truth (for sentences).› locale Goedel_Form_prv_eq_isTrue = Goedel_Form var trm fmla Var num FvarsT substT Fvars subst eql cnj imp all exi fls prv bprv enc P S for var :: "'var set" and trm :: "'trm set" and fmla :: "'fmla set" and Var num FvarsT substT Fvars subst and eql cnj imp all exi and fls and prv bprv and enc ("⟨_⟩") and S and P + fixes isTrue :: "'fmla ⇒ bool" assumes prv_eq_isTrue: "⋀ φ. φ ∈ fmla ⟹ Fvars φ = {} ⟹ prv φ = isTrue φ" begin theorem Tarski_semantic: assumes 0: "T ∈ fmla" "Fvars T = {xx}" and 1: "⋀φ. φ ∈ fmla ⟹ Fvars φ = {} ⟹ isTrue (eqv (subst T ⟨φ⟩ xx) φ)" shows "¬ consistent" using assms (*‹T ∈ fmla› ‹Fvars T = {xx}› ‹⟦(?φ::'fmla) ∈ (fmla::'fmla set); (Fvars::'fmla ⇒ 'var set) ?φ = {}⟧ ⟹ (isTrue::'fmla ⇒ bool) (eqv ((subst::'fmla ⇒ 'trm ⇒ 'var ⇒ 'fmla) (T::'fmla) ⟨?φ⟩ xx) ?φ)›*) prv_eq_isTrue[of "eqv (subst T ⟨_⟩ xx) _"] (*‹⟦eqv ((subst::'fmla::type ⇒ 'trm::type ⇒ 'var::type ⇒ 'fmla::type) (T::'fmla::type) ⟨?uu3::'fmla::type⟩ xx) (?uua3::'fmla::type) ∈ (fmla::'fmla::type set); (Fvars::'fmla::type ⇒ 'var::type set) (eqv (subst T ⟨?uu3⟩ xx) ?uua3) = {}⟧ ⟹ (prv::'fmla::type ⇒ bool) (eqv (subst T ⟨?uu3⟩ xx) ?uua3) = (isTrue::'fmla::type ⇒ bool) (eqv (subst T ⟨?uu3⟩ xx) ?uua3)›*) apply (intro Tarski_proof_theoretic[OF 0] (*‹(⋀φ. ⟦φ ∈ fmla; Fvars φ = {}⟧ ⟹ prv (eqv (subst T ⟨φ⟩ xx) φ)) ⟹ ¬ consistent›*)) (*goal: ‹¬ consistent›*) by auto text ‹NB: To instantiate the semantic version of Tarski's theorem for a truth predicate isTruth on sentences, one needs to extend it to a predicate "prv" on formulas and verify that "prv" satisfies the rules of intuitionistic logic.› end ― ‹context @{locale Goedel_Form_prv_eq_isTrue}› (*<*) end (*>*)
{ "path": "afp-2025-02-12/thys/Goedel_Incompleteness/Tarski.thy", "repo": "afp-2025-02-12", "sha": "0ffc6b54b3f0ba91cd95e679af909d91b2f11b1f7a96c89e56ab2fcbcf8df3ed" }
(* Author: Lukas Bulwahn <lukas.bulwahn-at-gmail.com> *) section ‹Cardinality of Partial Equivalence Relations› theory Card_Partial_Equiv_Relations imports Card_Equiv_Relations begin subsection ‹Definition of Partial Equivalence Relation› definition partial_equiv :: "'a set ⇒ ('a × 'a) set ⇒ bool" where "partial_equiv A R = (R ⊆ A × A ∧ sym R ∧ trans R)" lemma partial_equivI: assumes "R ⊆ A × A" "sym R" "trans R" shows "partial_equiv A R" using assms (*‹R ⊆ A × A› ‹sym R› ‹trans R›*) unfolding partial_equiv_def (*goal: ‹R ⊆ A × A ∧ sym R ∧ trans R›*) by auto lemma partial_equiv_iff: shows "partial_equiv A R ⟷ (∃A' ⊆ A. equiv A' R)" proof (standard) (*goals: 1. ‹partial_equiv A R ⟹ ∃A'⊆A. equiv A' R› 2. ‹∃A'⊆A. equiv A' R ⟹ partial_equiv A R›*) assume "partial_equiv A R" (*‹partial_equiv (A::'a set) (R::('a × 'a) set)›*) from ‹partial_equiv A R› (*‹partial_equiv (A::'a set) (R::('a × 'a) set)›*) have "R `` A ⊆ A" unfolding partial_equiv_def (*goal: ‹R `` A ⊆ A›*) by blast moreover have "equiv (R `` A) R" proof (rule equivI (*‹⟦refl_on ?A ?r; sym ?r; trans ?r⟧ ⟹ equiv ?A ?r›*)) (*goals: 1. ‹refl_on (R `` A) R› 2. ‹sym R› 3. ‹trans R›*) from ‹partial_equiv A R› (*‹partial_equiv (A::'a set) (R::('a × 'a) set)›*) show "sym R" unfolding partial_equiv_def (*goal: ‹sym (R::('a × 'a) set)›*) by blast from ‹partial_equiv A R› (*‹partial_equiv A R›*) show "trans R" unfolding partial_equiv_def (*goal: ‹trans R›*) by blast show "refl_on (R `` A) R" proof (rule refl_onI (*‹⟦?r ⊆ ?A × ?A; ⋀x. x ∈ ?A ⟹ (x, x) ∈ ?r⟧ ⟹ refl_on ?A ?r›*)) (*goals: 1. ‹R ⊆ R `` A × R `` A› 2. ‹⋀x. x ∈ R `` A ⟹ (x, x) ∈ R›*) show "R ⊆ R `` A × R `` A" proof (standard) (*goal: ‹⋀x::'a × 'a. x ∈ (R::('a × 'a) set) ⟹ x ∈ R `` (A::'a set) × R `` A›*) fix p assume "p ∈ R" (*‹(p::'a × 'a) ∈ (R::('a × 'a) set)›*) obtain x and y where "p = (x, y)" (*goal: ‹(⋀x y. p = (x, y) ⟹ thesis) ⟹ thesis›*) by fastforce moreover have "x ∈ R `` A" using ‹p ∈ R› (*‹p ∈ R›*) ‹p = (x, y)› (*‹p = (x, y)›*) ‹partial_equiv A R› (*‹partial_equiv A R›*) partial_equiv_def (*‹partial_equiv ?A ?R = (?R ⊆ ?A × ?A ∧ sym ?R ∧ trans ?R)›*) sym_def (*‹sym ?r = (∀x y. (x, y) ∈ ?r ⟶ (y, x) ∈ ?r)›*) by fastforce moreover have "y ∈ R `` A" using ‹p ∈ R› (*‹p ∈ R›*) ‹p = (x, y)› (*‹p = (x, y)›*) ‹R `` A ⊆ A› (*‹R `` A ⊆ A›*) ‹x ∈ R `` A› (*‹x ∈ R `` A›*) by blast ultimately show "p ∈ R `` A × R `` A" by auto qed next (*goal: ‹⋀x. x ∈ R `` A ⟹ (x, x) ∈ R›*) fix y assume "y ∈ R `` A" (*‹(y::'a) ∈ (R::('a × 'a) set) `` (A::'a set)›*) from this (*‹y ∈ R `` A›*) obtain x where "(x, y) ∈ R" (*goal: ‹(⋀x. (x, y) ∈ R ⟹ thesis) ⟹ thesis›*) by auto from ‹(x, y) ∈ R› (*‹(x, y) ∈ R›*) have "(y, x) ∈ R" using ‹sym R› (*‹sym R›*) by (meson symE (*‹⟦sym ?r; (?b, ?a) ∈ ?r; (?a, ?b) ∈ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*)) from ‹(x, y) ∈ R› (*‹(x, y) ∈ R›*) ‹(y, x) ∈ R› (*‹(y, x) ∈ R›*) show "(y, y) ∈ R" using ‹trans R› (*‹trans R›*) by (meson transE (*‹⟦trans (?r::(?'a × ?'a) set); (?x::?'a, ?y::?'a) ∈ ?r; (?y, ?z::?'a) ∈ ?r; (?x, ?z) ∈ ?r ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) qed qed ultimately show "∃A'⊆A. equiv A' R" by blast next (*goal: ‹∃A'⊆A. equiv A' R ⟹ partial_equiv A R›*) assume "∃A'⊆A. equiv A' R" (*‹∃A'⊆A::'a set. equiv A' (R::('a × 'a) set)›*) from this (*‹∃A'⊆A. equiv A' R›*) obtain A' where "A' ⊆ A" and "equiv A' R" (*goal: ‹(⋀A'::'a set. ⟦A' ⊆ (A::'a set); equiv A' (R::('a × 'a) set)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast show "partial_equiv A R" proof (rule partial_equivI (*‹⟦?R ⊆ ?A × ?A; sym ?R; trans ?R⟧ ⟹ partial_equiv ?A ?R›*)) (*goals: 1. ‹R ⊆ A × A› 2. ‹sym R› 3. ‹trans R›*) from ‹equiv A' R› (*‹equiv A' R›*) ‹A' ⊆ A› (*‹A' ⊆ A›*) show "R ⊆ A × A" using equiv_class_eq_iff (*‹equiv ?A ?r ⟹ ((?x, ?y) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*) by fastforce from ‹equiv A' R› (*‹equiv A' R›*) show "sym R" using equivE (*‹⟦equiv ?A ?r; ⟦refl_on ?A ?r; sym ?r; trans ?r⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast from ‹equiv A' R› (*‹equiv A' R›*) show "trans R" using equivE (*‹⟦equiv ?A ?r; ⟦refl_on ?A ?r; sym ?r; trans ?r⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast qed qed subsection ‹Construction of all Partial Equivalence Relations for a Given Set› definition all_partial_equivs_on :: "'a set ⇒ (('a × 'a) set) set" where "all_partial_equivs_on A = do { k ← {0..card A}; A' ← {A'. A' ⊆ A ∧ card A' = k}; {R. equiv A' R} }" lemma all_partial_equivs_on: assumes "finite A" shows "all_partial_equivs_on A = {R. partial_equiv A R}" proof (standard) (*goals: 1. ‹all_partial_equivs_on A ⊆ {R. partial_equiv A R}› 2. ‹{R. partial_equiv A R} ⊆ all_partial_equivs_on A›*) show "all_partial_equivs_on A ⊆ {R. partial_equiv A R}" proof (standard) (*goal: ‹⋀x. x ∈ all_partial_equivs_on A ⟹ x ∈ {R. partial_equiv A R}›*) fix R assume "R ∈ all_partial_equivs_on A" (*‹(R::('a × 'a) set) ∈ all_partial_equivs_on (A::'a set)›*) from this (*‹(R::('a × 'a) set) ∈ all_partial_equivs_on (A::'a set)›*) obtain A' where "A' ⊆ A" and "equiv A' R" (*goal: ‹(⋀A'. ⟦A' ⊆ A; equiv A' R⟧ ⟹ thesis) ⟹ thesis›*) unfolding all_partial_equivs_on_def (*goal: ‹(⋀A'. ⟦A' ⊆ A; equiv A' R⟧ ⟹ thesis) ⟹ thesis›*) by auto from this (*‹A' ⊆ A› ‹equiv A' R›*) have "partial_equiv A R" using partial_equiv_iff (*‹partial_equiv ?A ?R = (∃A'⊆?A. equiv A' ?R)›*) by blast from this (*‹partial_equiv (A::'a set) (R::('a × 'a) set)›*) show "R ∈ {R. partial_equiv A R}" by standard qed next (*goal: ‹{R. partial_equiv A R} ⊆ all_partial_equivs_on A›*) show "{R. partial_equiv A R} ⊆ all_partial_equivs_on A" proof (standard) (*goal: ‹⋀x. x ∈ {R. partial_equiv A R} ⟹ x ∈ all_partial_equivs_on A›*) fix R assume "R ∈ {R. partial_equiv A R}" (*‹(R::('a × 'a) set) ∈ {R::('a × 'a) set. partial_equiv (A::'a set) R}›*) from this (*‹R ∈ {R. partial_equiv A R}›*) obtain A' where "A' ⊆ A" and "equiv A' R" (*goal: ‹(⋀A'. ⟦A' ⊆ A; equiv A' R⟧ ⟹ thesis) ⟹ thesis›*) using partial_equiv_iff (*‹partial_equiv ?A ?R = (∃A'⊆?A. equiv A' ?R)›*) by (metis mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) moreover have "card A' ∈ {0..card A}" using ‹A' ⊆ A› (*‹(A'::'a set) ⊆ (A::'a set)›*) ‹finite A› (*‹finite A›*) by (simp add: card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*)) ultimately show "R ∈ all_partial_equivs_on A" unfolding all_partial_equivs_on_def (*goal: ‹R ∈ {0..card A} ⤜ (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. Collect (equiv A')))›*) by (auto simp del: atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*)) qed qed subsection ‹Injectivity of the Set Construction› lemma equiv_inject: assumes "equiv A R" "equiv B R" shows "A = B" proof (-) (*goal: ‹A = B›*) from assms (*‹equiv (A::'a set) (R::('a × 'a) set)› ‹equiv (B::'a set) (R::('a × 'a) set)›*) have "R ⊆ A × A" "R ⊆ B × B" apply - (*goals: 1. ‹⟦equiv A R; equiv B R⟧ ⟹ R ⊆ A × A› 2. ‹⟦equiv A R; equiv B R⟧ ⟹ R ⊆ B × B› discuss goal 1*) apply (simp add: equiv_type (*‹equiv ?A ?r ⟹ ?r ⊆ ?A × ?A›*)) (*discuss goal 2*) apply (simp add: equiv_type (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ ?r ⊆ ?A × ?A›*)) (*proven 2 subgoals*) . moreover from assms (*‹equiv (A::'a::type set) (R::('a::type × 'a::type) set)› ‹equiv B R›*) have "∀x∈A. (x, x) ∈ R" "∀x∈B. (x, x) ∈ R" apply - (*goals: 1. ‹⟦equiv A R; equiv B R⟧ ⟹ ∀x∈A. (x, x) ∈ R› 2. ‹⟦equiv A R; equiv B R⟧ ⟹ ∀x∈B. (x, x) ∈ R› discuss goal 1*) apply (simp add: eq_equiv_class (*‹⟦(?r::(?'a × ?'a) set) `` {?a::?'a} = ?r `` {?b::?'a}; equiv (?A::?'a set) ?r; ?b ∈ ?A⟧ ⟹ (?a, ?b) ∈ ?r›*)) (*discuss goal 2*) apply (simp add: eq_equiv_class (*‹⟦?r `` {?a} = ?r `` {?b}; equiv ?A ?r; ?b ∈ ?A⟧ ⟹ (?a, ?b) ∈ ?r›*)) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹A = B›*) using mem_Sigma_iff (*‹((?a, ?b) ∈ Sigma ?A ?B) = (?a ∈ ?A ∧ ?b ∈ ?B ?a)›*) subset_antisym (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) by blast qed lemma injectivity: assumes "(A' ⊆ A ∧ card A' = k) ∧ (A'' ⊆ A ∧ card A'' = k')" assumes "equiv A' R ∧ equiv A'' R'" assumes "R = R'" shows "A' = A''" "k = k'" proof (-) (*goals: 1. ‹A' = A''› 2. ‹k = k'›*) from ‹R = R'› (*‹R = R'›*) assms(2) (*‹equiv A' R ∧ equiv A'' R'›*) show "A' = A''" using equiv_inject (*‹⟦equiv ?A ?R; equiv ?B ?R⟧ ⟹ ?A = ?B›*) by fast from this (*‹A' = A''›*) assms(1) (*‹(A' ⊆ A ∧ card A' = k) ∧ A'' ⊆ A ∧ card A'' = k'›*) show "k = k'" by simp qed subsection ‹Cardinality Theorem of Partial Equivalence Relations› theorem card_partial_equiv: assumes "finite A" shows "card {R. partial_equiv A R} = Bell (card A + 1)" proof (-) (*goal: ‹card {R. partial_equiv A R} = Bell (card A + 1)›*) let ?expr = "do { k ← {0..card A}; A' ← {A'. A' ⊆ A ∧ card A' = k}; {R. equiv A' R} }" have "card {R. partial_equiv A R} = card (all_partial_equivs_on A)" using ‹finite A› (*‹finite A›*) by (simp add: all_partial_equivs_on (*‹finite ?A ⟹ all_partial_equivs_on ?A = {R. partial_equiv ?A R}›*)) also (*calculation: ‹card {R. partial_equiv A R} = card (all_partial_equivs_on A)›*) have "card (all_partial_equivs_on A) = card ?expr" unfolding all_partial_equivs_on_def (*goal: ‹card ({0..card A} ⤜ (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. Collect (equiv A')))) = card ({0..card A} ⤜ (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})))›*) by standard also (*calculation: ‹card {R::('a × 'a) set. partial_equiv (A::'a set) R} = card ({0::nat..card A} ⤜ (λk::nat. {A'::'a set. A' ⊆ A ∧ card A' = k} ⤜ (λA'::'a set. {R::('a × 'a) set. equiv A' R})))›*) have "card ?expr = (∑k = 0..card A. (card A choose k) * Bell k)" proof (-) (*goal: ‹card ({0..card A} ⤜ (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R}))) = (∑k = 0..card A. (card A choose k) * Bell k)›*) let ?S ⤜ ?comp = "?expr" { fix k assume k: "k ∈ {..card A}" (*‹(k::nat) ∈ {..card (A::'a set)}›*) let ?expr = "?comp k" let ?S ⤜ ?comp = "?expr" have "finite ?S" using ‹finite A› (*‹finite A›*) by simp moreover { fix A' assume A': "A' ∈ {A'. A' ⊆ A ∧ card A' = k}" (*‹(A'::'a set) ∈ {A'::'a set. A' ⊆ (A::'a set) ∧ card A' = (k::nat)}›*) from this (*‹A' ∈ {A'. A' ⊆ A ∧ card A' = k}›*) have "A' ⊆ A" and "card A' = k" apply - (*goals: 1. ‹A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ A' ⊆ A› 2. ‹A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ card A' = k› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?expr = "?comp A'" have "finite A'" using ‹finite A› (*‹finite (A::'a::type set)›*) ‹A' ⊆ A› (*‹A' ⊆ A›*) by (simp add: finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) have "card ?expr = Bell k" using ‹finite A› (*‹finite A›*) ‹finite A'› (*‹finite A'›*) ‹A' ⊆ A› (*‹A' ⊆ A›*) ‹card A' = k› (*‹card (A'::'a set) = (k::nat)›*) by (simp add: card_equiv_rel_eq_Bell (*‹finite ?A ⟹ card {R. equiv ?A R} = Bell (card ?A)›*)) moreover have "finite ?expr" using ‹finite A'› (*‹finite A'›*) by (simp add: finite_equiv (*‹finite ?A ⟹ finite {R. equiv ?A R}›*)) ultimately have "finite ?expr ∧ card ?expr = Bell k" by blast } note inner = this (*‹?A'2 ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv ?A'2 R} ∧ card {R. equiv ?A'2 R} = Bell k›*) moreover have "disjoint_family_on ?comp ?S" by (injectivity_solver rule: injectivity(1)) moreover have "card ?S = card A choose k" using ‹finite A› (*‹finite A›*) by (simp add: n_subsets (*‹finite ?A ⟹ card {B. B ⊆ ?A ∧ card B = ?k} = card ?A choose ?k›*)) ultimately have "card ?expr = (card A choose k) * Bell k" (is "_ = ?formula") apply (subst card_bind_constant (*‹⟦finite (?S::?'a::type set); ∀X::?'a::type∈?S. finite ((?f::?'a::type ⇒ ?'b::type set) X); disjoint_family_on ?f ?S; ⋀x::?'a::type. x ∈ ?S ⟹ card (?f x) = (?k::nat)⟧ ⟹ card (?S ⤜ ?f) = card ?S * ?k›*)) (*goals: 1. ‹⟦finite {A'. A' ⊆ A ∧ card A' = k}; ⋀A'. A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv A' R} ∧ card {R. equiv A' R} = Bell k; disjoint_family_on (λA'. {R. equiv A' R}) {A'. A' ⊆ A ∧ card A' = k}; card {A'. A' ⊆ A ∧ card A' = k} = card A choose k⟧ ⟹ finite {A'. A' ⊆ A ∧ card A' = k}› 2. ‹⟦finite {A'. A' ⊆ A ∧ card A' = k}; ⋀A'. A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv A' R} ∧ card {R. equiv A' R} = Bell k; disjoint_family_on (λA'. {R. equiv A' R}) {A'. A' ⊆ A ∧ card A' = k}; card {A'. A' ⊆ A ∧ card A' = k} = card A choose k⟧ ⟹ ∀X∈{A'. A' ⊆ A ∧ card A' = k}. finite (Collect (equiv X))› 3. ‹⟦finite {A'. A' ⊆ A ∧ card A' = k}; ⋀A'. A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv A' R} ∧ card {R. equiv A' R} = Bell k; disjoint_family_on (λA'. {R. equiv A' R}) {A'. A' ⊆ A ∧ card A' = k}; card {A'. A' ⊆ A ∧ card A' = k} = card A choose k⟧ ⟹ disjoint_family_on (λA'. Collect (equiv A')) {A'. A' ⊆ A ∧ card A' = k}› 4. ‹⋀x. ⟦finite {A'. A' ⊆ A ∧ card A' = k}; ⋀A'. A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv A' R} ∧ card {R. equiv A' R} = Bell k; disjoint_family_on (λA'. {R. equiv A' R}) {A'. A' ⊆ A ∧ card A' = k}; card {A'. A' ⊆ A ∧ card A' = k} = card A choose k; x ∈ {A'. A' ⊆ A ∧ card A' = k}⟧ ⟹ card (Collect (equiv x)) = ?k7› 5. ‹⟦finite {A'. A' ⊆ A ∧ card A' = k}; ⋀A'. A' ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv A' R} ∧ card {R. equiv A' R} = Bell k; disjoint_family_on (λA'. {R. equiv A' R}) {A'. A' ⊆ A ∧ card A' = k}; card {A'. A' ⊆ A ∧ card A' = k} = card A choose k⟧ ⟹ card {A'. A' ⊆ A ∧ card A' = k} * ?k7 = (card A choose k) * Bell k› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . moreover have "finite ?expr" using ‹finite ?S› (*‹finite {A'. A' ⊆ A ∧ card A' = k}›*) inner (*‹?A'2 ∈ {A'. A' ⊆ A ∧ card A' = k} ⟹ finite {R. equiv ?A'2 R} ∧ card {R. equiv ?A'2 R} = Bell k›*) by (auto intro!: finite_bind (*‹⟦finite ?S; ∀x∈?S. finite (?f x)⟧ ⟹ finite (?S ⤜ ?f)›*)) ultimately have "finite ?expr ∧ card ?expr = ?formula" by blast } moreover have "finite ?S" by simp moreover have "disjoint_family_on ?comp ?S" by (injectivity_solver rule: injectivity(2)) ultimately show "card ?expr = (∑k = 0..card A. (card A choose k) * Bell k)" apply (subst card_bind (*‹⟦finite ?S; ∀X∈?S. finite (?f X); disjoint_family_on ?f ?S⟧ ⟹ card (?S ⤜ ?f) = (∑x∈?S. card (?f x))›*)) (*goals: 1. ‹⟦⋀k. k ∈ {..card A} ⟹ finite ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) ∧ card ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) = (card A choose k) * Bell k; finite {0..card A}; disjoint_family_on (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) {0..card A}⟧ ⟹ finite {0..card A}› 2. ‹⟦⋀k. k ∈ {..card A} ⟹ finite ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) ∧ card ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) = (card A choose k) * Bell k; finite {0..card A}; disjoint_family_on (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) {0..card A}⟧ ⟹ ∀X∈{0..card A}. finite ({A'. A' ⊆ A ∧ card A' = X} ⤜ (λA'. Collect (equiv A')))› 3. ‹⟦⋀k. k ∈ {..card A} ⟹ finite ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) ∧ card ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) = (card A choose k) * Bell k; finite {0..card A}; disjoint_family_on (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) {0..card A}⟧ ⟹ disjoint_family_on (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. Collect (equiv A'))) {0..card A}› 4. ‹⟦⋀k. k ∈ {..card A} ⟹ finite ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) ∧ card ({A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) = (card A choose k) * Bell k; finite {0..card A}; disjoint_family_on (λk. {A'. A' ⊆ A ∧ card A' = k} ⤜ (λA'. {R. equiv A' R})) {0..card A}⟧ ⟹ (∑x = 0..card A. card ({A'. A' ⊆ A ∧ card A' = x} ⤜ (λA'. Collect (equiv A')))) = (∑k = 0..card A. (card A choose k) * Bell k)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed also (*calculation: ‹card {R. partial_equiv A R} = (∑k = 0..card A. (card A choose k) * Bell k)›*) have "… = (∑k≤card A. (card A choose k) * Bell k)" by (auto intro: sum.cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?g x = ?h x⟧ ⟹ sum ?g ?A = sum ?h ?B›*)) also (*calculation: ‹card {R::('a::type × 'a::type) set. partial_equiv (A::'a::type set) R} = (∑k::nat≤card A. (card A choose k) * Bell k)›*) have "… = Bell (card A + 1)" using Bell_recursive_eq (*‹Bell (?n + 1) = (∑k≤?n. (?n choose k) * Bell k)›*) by simp finally (*calculation: ‹card {R. partial_equiv A R} = Bell (card A + 1)›*) show "?thesis" (*goal: ‹card {R. partial_equiv A R} = Bell (card A + 1)›*) . qed end
{ "path": "afp-2025-02-12/thys/Card_Equiv_Relations/Card_Partial_Equiv_Relations.thy", "repo": "afp-2025-02-12", "sha": "44fd04d99b06c6e0c5fb9514813cdd7237b5fa23fe3b7f276a783455b4ebf0ad" }
(* Title: Quantic Nuclei and Conuclei Author: Georg Struth Maintainer: Georg Struth <g.struth@sheffield.ac.uk> *) section ‹Quantic Nuclei and Conuclei› theory Quantic_Nuclei_Conuclei imports Quantale_Models begin text ‹Quantic nuclei and conuclei are an important part of the structure theory of quantales. I formalise the basics, following Rosenthal's book~\<^cite>‹"Rosenthal90"›. In the structure theorems, I collect all parts of the proof, but do not present the theorems in compact form due to difficulties to speak about subalgebras and homomorphic images without explicit carrier sets. Nuclei also arise in the context of complete Heyting algebras, frames and locales~\<^cite>‹"Johnstone82"›. Their formalisation seems an interesting future task.› subsection ‹Nuclei› definition nucleus :: "('a::quantale ⇒ 'a::quantale) ⇒ bool" where "nucleus f = (clop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)))" lemma nuc_lax: "nucleus f ⟹ f x ⋅ f y ≤ f (x ⋅ y)" by (simp add: nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) definition unucleus :: "('a::unital_quantale ⇒ 'a::unital_quantale) ⇒ bool" where "unucleus f = (nucleus f ∧ 1 ≤ f 1)" lemma "nucleus f ⟹ f ⊥ = ⊥" (*nitpick*) oops lemma "conucleus f ⟹ f ⊤ = ⊤" (*nitpick*) oops lemma nuc_prop1: "nucleus f ⟹ f (x ⋅ y) = f (x ⋅ f y)" apply (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹nucleus f ⟹ f (x ⋅ y) ≤ f (x ⋅ f y)› 2. ‹nucleus f ⟹ f (x ⋅ f y) ≤ f (x ⋅ y)› discuss goal 1*) apply (simp add: clop_extensive_var (*‹clop (?f::?'a::order ⇒ ?'a::order) ⟹ (?x::?'a::order) ≤ ?f ?x›*) clop_iso_var (*‹⟦clop (?f::?'a::order ⇒ ?'a::order); (?x::?'a::order) ≤ (?y::?'a::order)⟧ ⟹ ?f ?x ≤ ?f ?y›*) nucleus_def (*‹nucleus (?f::?'a::quantale ⇒ ?'a::quantale) = (clop ?f ∧ (∀(x::?'a::quantale) y::?'a::quantale. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) psrpq.mult_isol (*‹(?x::?'a::pre_quantale) ≤ (?y::?'a::pre_quantale) ⟹ (?z::?'a::pre_quantale) ⋅ ?x ≤ ?z ⋅ ?y›*)) (*discuss goal 2*) apply (metis clop_alt (*‹clop ?f = (∀x y. (x ≤ ?f y) = (?f x ≤ ?f y))›*) clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) psrpq.mult_isol_var (*‹⟦?u ≤ ?x; ?v ≤ ?y⟧ ⟹ ?u ⋅ ?v ≤ ?x ⋅ ?y›*)) (*proven 2 subgoals*) . lemma nuc_prop2: "nucleus f ⟹ f (x ⋅ y) = f (f x ⋅ y)" apply (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹nucleus f ⟹ f (x ⋅ y) ≤ f (f x ⋅ y)› 2. ‹nucleus f ⟹ f (f x ⋅ y) ≤ f (x ⋅ y)› discuss goal 1*) apply (simp add: clop_extensive_var (*‹clop (?f::?'a ⇒ ?'a) ⟹ (?x::?'a) ≤ ?f ?x›*) clop_iso_var (*‹⟦clop (?f::?'a ⇒ ?'a); (?x::?'a) ≤ (?y::?'a)⟧ ⟹ ?f ?x ≤ ?f ?y›*) nsrnq.mult_isor (*‹(?x::?'a) ≤ (?y::?'a) ⟹ ?x ⋅ (?z::?'a) ≤ ?y ⋅ ?z›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) (*discuss goal 2*) apply (metis (mono_tags, opaque_lifting) clop_alt (*‹clop ?f = (∀x y. (x ≤ ?f y) = (?f x ≤ ?f y))›*) nuc_prop1 (*‹nucleus ?f ⟹ ?f (?x ⋅ ?y) = ?f (?x ⋅ ?f ?y)›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) (*proven 2 subgoals*) . lemma nuc_comp_prop: "nucleus f ⟹ f (f x ⋅ f y) = f (x ⋅ y)" using nuc_prop1 (*‹nucleus (?f::?'a ⇒ ?'a) ⟹ ?f ((?x::?'a) ⋅ (?y::?'a)) = ?f (?x ⋅ ?f ?y)›*) nuc_prop2 (*‹nucleus (?f::?'a ⇒ ?'a) ⟹ ?f ((?x::?'a) ⋅ (?y::?'a)) = ?f (?f ?x ⋅ ?y)›*) by force lemma nucleus_alt_def1: "nucleus f ⟹ f x → f y = x → f y" proof (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹nucleus f ⟹ f x → f y ≤ x → f y› 2. ‹nucleus f ⟹ x → f y ≤ f x → f y›*) assume h: "nucleus f" (*‹nucleus (f::'a ⇒ 'a)›*) hence "x ≤ f x" by (simp add: clop_def (*‹clop (?f::?'a ⇒ ?'a) = (id ≤ ?f ∧ mono ?f ∧ ?f ∘ ?f ≤ ?f)›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) clop_extensive_var (*‹clop (?f::?'a ⇒ ?'a) ⟹ (?x::?'a) ≤ ?f ?x›*)) thus "f x → f y ≤ x → f y" by (simp add: bres_anti (*‹?x ≤ ?y ⟹ ?y → ?z ≤ ?x → ?z›*)) have "f x ⋅ (x → f y) ≤ f x ⋅ f (x → f y)" using clop_extensive_var (*‹clop (?f::?'a ⇒ ?'a) ⟹ (?x::?'a) ≤ ?f ?x›*) h (*‹nucleus f›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) proto_pre_quantale_class.mult_isol (*‹?x ≤ ?y ⟹ ?z ⋅ ?x ≤ ?z ⋅ ?y›*) by blast also (*calculation: ‹f x ⋅ (x → f y) ≤ f x ⋅ f (x → f y)›*) have "... ≤ f (x ⋅ (x → f y))" by (simp add: h (*‹nucleus f›*) nuc_lax (*‹nucleus ?f ⟹ ?f ?x ⋅ ?f ?y ≤ ?f (?x ⋅ ?y)›*)) also (*calculation: ‹f x ⋅ (x → f y) ≤ f (x ⋅ (x → f y))›*) have "... ≤ f (f y)" using h (*‹nucleus f›*) by (simp add: bres_canc1 (*‹?x ⋅ (?x → ?y) ≤ ?y›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) clop_iso_var (*‹⟦clop ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*)) finally (*calculation: ‹f x ⋅ (x → f y) ≤ f (f y)›*) have "f x ⋅ (x → f y) ≤ f y" using h (*‹nucleus (f::'a::quantale ⇒ 'a::quantale)›*) by (metis clop_alt (*‹clop ?f = (∀x y. (x ≤ ?f y) = (?f x ≤ ?f y))›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) order_refl (*‹?x ≤ ?x›*)) thus "x → f y ≤ f x → f y" by (simp add: bres_galois_imp (*‹?x ⋅ ?y ≤ ?z ⟹ ?y ≤ ?x → ?z›*)) qed lemma nucleus_alt_def2: "nucleus f ⟹ f y ← f x = f y ← x" proof (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹nucleus (f::'a ⇒ 'a) ⟹ f (y::'a) ← f (x::'a) ≤ f y ← x› 2. ‹nucleus (f::'a ⇒ 'a) ⟹ f (y::'a) ← (x::'a) ≤ f y ← f x›*) assume h: "nucleus f" (*‹nucleus (f::'a ⇒ 'a)›*) hence "x ≤ f x" by (simp add: clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) thus "f y ← f x ≤ f y ← x" by (simp add: fres_anti (*‹(?x::?'a) ≤ (?y::?'a) ⟹ (?z::?'a) ← ?y ≤ ?z ← ?x›*)) have "(f y ← x) ⋅ f x ≤ f (f y ← x) ⋅ f x" using clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) h (*‹nucleus f›*) nsrnq.mult_isor (*‹?x ≤ ?y ⟹ ?x ⋅ ?z ≤ ?y ⋅ ?z›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) by blast also (*calculation: ‹(f y ← x) ⋅ f x ≤ f (f y ← x) ⋅ f x›*) have "... ≤ f ((f y ← x) ⋅ x)" by (simp add: h (*‹nucleus f›*) nuc_lax (*‹nucleus ?f ⟹ ?f ?x ⋅ ?f ?y ≤ ?f (?x ⋅ ?y)›*)) also (*calculation: ‹(f y ← x) ⋅ f x ≤ f ((f y ← x) ⋅ x)›*) have "... ≤ f (f y)" using clop_iso_var (*‹⟦clop (?f::?'a::order ⇒ ?'a::order); (?x::?'a::order) ≤ (?y::?'a::order)⟧ ⟹ ?f ?x ≤ ?f ?y›*) fres_canc1 (*‹(?y ← ?x) ⋅ ?x ≤ ?y›*) h (*‹nucleus f›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) by blast finally (*calculation: ‹(f y ← x) ⋅ f x ≤ f (f y)›*) have "(f y ← x) ⋅ f x ≤ f y" using h (*‹nucleus (f::'a ⇒ 'a)›*) by (metis clop_alt (*‹clop ?f = (∀x y. (x ≤ ?f y) = (?f x ≤ ?f y))›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) order_refl (*‹?x ≤ ?x›*)) thus "f y ← x ≤ f y ← f x" by (simp add: fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*)) qed lemma nucleus_alt_def3: fixes f :: "'a::unital_quantale ⇒ 'a" shows "∀x y. f x → f y = x → f y ⟹ ∀x y. f y ← f x = f y ← x ⟹ nucleus f" proof (-) (*goal: ‹⟦∀(x::'a) y::'a. (f::'a ⇒ 'a) x → f y = x → f y; ∀(x::'a) y::'a. f y ← f x = f y ← x⟧ ⟹ nucleus f›*) assume h1: "∀x y. f x → f y = x → f y" and h2: "∀x y. f y ← f x = f y ← x" (*‹∀(x::'a) y::'a. (f::'a ⇒ 'a) x → f y = x → f y› ‹∀(x::'a) y::'a. (f::'a ⇒ 'a) y ← f x = f y ← x›*) hence ext: "∀x. x ≤ f x" by (metis (full_types) fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*) fres_one (*‹1 ≤ ?x ← ?x›*) mult.left_neutral (*‹1 ⋅ ?a = ?a›*)) have iso: "∀x y. x ≤ y ⟶ f x ≤ f y" by (metis (full_types) bres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?y ≤ ?x → ?z)›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) h1 (*‹∀x y. f x → f y = x → f y›*) ext (*‹∀x. x ≤ f x›*) nsrnqo.mult_oner (*‹?x ⋅ 1 = ?x›*)) have trans: "∀x. f (f x) ≤ f x" by (metis fres_canc2 (*‹?y ≤ ?y ⋅ ?x ← ?x›*) fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*) h2 (*‹∀x y. f y ← f x = f y ← x›*) nsrnqo.mult_onel (*‹1 ⋅ ?x = ?x›*)) have lax: "∀x y. f x ⋅ f y ≤ f (x ⋅ y)" by (metis h1 (*‹∀x y. f x → f y = x → f y›*) h2 (*‹∀x y. f y ← f x = f y ← x›*) bres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?y ≤ ?x → ?z)›*) ext (*‹∀x. x ≤ f x›*) fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*)) show "?thesis" (*goal: ‹nucleus f›*) by (simp add: clop_def (*‹clop ?f = (id ≤ ?f ∧ mono ?f ∧ ?f ∘ ?f ≤ ?f)›*) iso (*‹∀x y. x ≤ y ⟶ f x ≤ f y›*) lax (*‹∀x y. f x ⋅ f y ≤ f (x ⋅ y)›*) le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*) ext (*‹∀x. x ≤ f x›*) trans (*‹∀x. f (f x) ≤ f x›*) monoI (*‹(⋀x y. x ≤ y ⟹ ?f x ≤ ?f y) ⟹ mono ?f›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) qed lemma nucleus_alt_def: fixes f :: "'a::unital_quantale ⇒ 'a" shows "nucleus f = (∀ x y. f x → f y = x → f y ∧ f y ← f x = f y ← x)" using nucleus_alt_def1 (*‹nucleus ?f ⟹ ?f ?x → ?f ?y = ?x → ?f ?y›*) nucleus_alt_def2 (*‹nucleus (?f::?'a ⇒ ?'a) ⟹ ?f (?y::?'a) ← ?f (?x::?'a) = ?f ?y ← ?x›*) nucleus_alt_def3 (*‹⟦∀x y. ?f x → ?f y = x → ?f y; ∀x y. ?f y ← ?f x = ?f y ← x⟧ ⟹ nucleus ?f›*) by blast lemma nucleus_alt_def_cor1: "nucleus f ⟹ f (x → y) ≤ x → f y" by (metis bres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?y ≤ ?x → ?z)›*) bres_iso (*‹?x ≤ ?y ⟹ ?z → ?x ≤ ?z → ?y›*) clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*) nucleus_alt_def2 (*‹nucleus ?f ⟹ ?f ?y ← ?f ?x = ?f ?y ← ?x›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) lemma nucleus_alt_def_cor2: "nucleus f ⟹ f (y ← x) ≤ f y ← x" by (metis bres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?y ≤ ?x → ?z)›*) clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*) fres_iso (*‹?x ≤ ?y ⟹ ?x ← ?z ≤ ?y ← ?z›*) nucleus_alt_def1 (*‹nucleus ?f ⟹ ?f ?x → ?f ?y = ?x → ?f ?y›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) lemma nucleus_ab_unital: fixes f :: "'a::ab_unital_quantale ⇒ 'a" shows "nucleus f = (∀x y. f x → f y = x → f y)" by (simp add: bres_fres_eq (*‹?x → ?y = ?y ← ?x›*) nucleus_alt_def (*‹nucleus ?f = (∀x y. ?f x → ?f y = x → ?f y ∧ ?f y ← ?f x = ?f y ← x)›*)) lemma nuc_comp_assoc: "nucleus f ⟹ f (x ⋅ f (y ⋅ z)) = f (f (x ⋅ y) ⋅ z)" by (metis mult.assoc (*‹?a ⋅ ?b ⋅ ?c = ?a ⋅ (?b ⋅ ?c)›*) nuc_prop1 (*‹nucleus ?f ⟹ ?f (?x ⋅ ?y) = ?f (?x ⋅ ?f ?y)›*) nuc_prop2 (*‹nucleus ?f ⟹ ?f (?x ⋅ ?y) = ?f (?f ?x ⋅ ?y)›*)) lemma nuc_Sup_closed: "nucleus f ⟹ f ∘ Sup ∘ (`) f = (f ∘ Sup)" apply (simp add: nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹nucleus f ⟹ f ∘ Sup ∘ (`) f = f ∘ Sup›*) apply safe (*goal: ‹clop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ ∀x. f (⨆ (f ` x)) = f (⨆ x)›*) apply (rule antisym (*‹⟦(?a::?'a) ≤ (?b::?'a); ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⋀x. ⟦clop f; ∀x y. f x ⋅ f y ≤ f (x ⋅ y)⟧ ⟹ f (⨆ (f ` x)) ≤ f (⨆ x)› 2. ‹⋀x. ⟦clop f; ∀x y. f x ⋅ f y ≤ f (x ⋅ y)⟧ ⟹ f (⨆ x) ≤ f (⨆ (f ` x))› discuss goal 1*) apply (meson SUP_least (*‹(⋀i. i ∈ ?A ⟹ ?f i ≤ ?u) ⟹ ⨆ (?f ` ?A) ≤ ?u›*) Sup_upper (*‹?x ∈ ?A ⟹ ?x ≤ ⨆ ?A›*) clop_alt (*‹clop ?f = (∀x y. (x ≤ ?f y) = (?f x ≤ ?f y))›*) clop_def (*‹clop ?f = (id ≤ ?f ∧ mono ?f ∧ ?f ∘ ?f ≤ ?f)›*) monoD (*‹⟦mono ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*)) (*discuss goal 2*) apply (simp add: SUP_upper2 (*‹⟦?i ∈ ?A; ?u ≤ ?f ?i⟧ ⟹ ?u ≤ ⨆ (?f ` ?A)›*) Sup_le_iff (*‹(⨆ ?A ≤ ?b) = (∀a∈?A. a ≤ ?b)›*) clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) clop_iso_var (*‹⟦clop ?f; ?x ≤ ?y⟧ ⟹ ?f ?x ≤ ?f ?y›*)) (*proven 2 subgoals*) . lemma nuc_Sup_closed_var: "nucleus f ⟹ f (⨆x ∈ X. f x) = f (⨆X)" by (metis nuc_Sup_closed (*‹nucleus ?f ⟹ ?f ∘ Sup ∘ (`) ?f = ?f ∘ Sup›*) o_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*)) lemma nuc_Inf_closed: "nucleus f ⟹ Sup_closed_set (Fix f)" (* nitpick *) oops lemma nuc_Inf_closed: "nucleus f ⟹ Inf_closed_set (Fix f)" by (simp add: clop_Inf_closed (*‹clop ?f ⟹ Inf_closed_set (Fix ?f)›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) lemma nuc_comp_distl: "nucleus f ⟹ f (x ⋅ f (⨆Y)) = f (⨆y ∈ Y. f (x ⋅ y))" by (metis Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) nuc_Sup_closed_var (*‹nucleus ?f ⟹ ?f (⨆ (?f ` ?X)) = ?f (⨆ ?X)›*) nuc_prop1 (*‹nucleus ?f ⟹ ?f (?x ⋅ ?y) = ?f (?x ⋅ ?f ?y)›*)) lemma nuc_comp_distr: "nucleus f ⟹ f (f (⨆X) ⋅ y) = f (⨆x ∈ X. f (x ⋅ y))" by (metis image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) nuc_Sup_closed_var (*‹nucleus ?f ⟹ ?f (⨆ (?f ` ?X)) = ?f (⨆ ?X)›*) nuc_prop2 (*‹nucleus ?f ⟹ ?f (?x ⋅ ?y) = ?f (?f ?x ⋅ ?y)›*)) lemma "nucleus f ⟹ f (x ⋅ y) = f x ⋅ f y" (*nitpick*) oops lemma nuc_bres_closed: "nucleus f ⟹ f (f x → f y) = f x → f y" unfolding nucleus_def (*goal: ‹clop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ f (f x → f y) = f x → f y›*) apply clarsimp (*goal: ‹clop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ f (f x → f y) = f x → f y›*) by (smt clop_closure (*‹clop (?f::?'a ⇒ ?'a) ⟹ ((?x::?'a) ∈ range ?f) = (?f ?x = ?x)›*) clop_extensive_var (*‹clop (?f::?'a ⇒ ?'a) ⟹ (?x::?'a) ≤ ?f ?x›*) nucleus_alt_def_cor1 (*‹nucleus (?f::?'a ⇒ ?'a) ⟹ ?f ((?x::?'a) → (?y::?'a)) ≤ ?x → ?f ?y›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) order_class.order.antisym (*‹⟦(?a::?'a) ≤ (?b::?'a); ?b ≤ ?a⟧ ⟹ ?a = ?b›*) rangeI (*‹(?f::?'b ⇒ ?'a) (?x::?'b) ∈ range ?f›*)) lemma "nucleus f ⟹ f (x → y) = f x → f y" (*nitpick*) sorry lemma nuc_fres_closed: "nucleus f ⟹ f (f x ← f y) = f x ← f y" unfolding nucleus_def (*goal: ‹clop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ f (f x ← f y) = f x ← f y›*) apply clarsimp (*goal: ‹clop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ f (f x ← f y) = f x ← f y›*) by (smt clop_closure (*‹clop (?f::?'a ⇒ ?'a) ⟹ ((?x::?'a) ∈ range ?f) = (?f ?x = ?x)›*) clop_extensive_var (*‹clop (?f::?'a ⇒ ?'a) ⟹ (?x::?'a) ≤ ?f ?x›*) eq_iff (*‹((?a::?'a) = (?b::?'a)) = (?a ≤ ?b ∧ ?b ≤ ?a)›*) nucleus_alt_def_cor2 (*‹nucleus (?f::?'a ⇒ ?'a) ⟹ ?f ((?y::?'a) ← (?x::?'a)) ≤ ?f ?y ← ?x›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) rangeI (*‹(?f::?'b ⇒ ?'a) (?x::?'b) ∈ range ?f›*)) lemma nuc_fres_closed: "nucleus f ⟹ f (x ← y) = f x ← f y" (*nitpick*) oops lemma nuc_inf_closed: "nucleus f ⟹ inf_closed_set (Fix f)" by (simp add: Inf_inf_closed (*‹Inf_closed_set ?X ⟹ inf_closed_set ?X›*) nuc_Inf_closed (*‹nucleus ?f ⟹ Inf_closed_set (Fix ?f)›*)) lemma nuc_inf_closed_var: "nucleus f ⟹ f (f x ⊓ f y) = f x ⊓ f y" by (smt antisym_conv (*‹?y ≤ ?x ⟹ (?x ≤ ?y) = (?x = ?y)›*) clop_alt (*‹clop ?f = (∀x y. (x ≤ ?f y) = (?f x ≤ ?f y))›*) clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) inf_le2 (*‹?x ⊓ ?y ≤ ?y›*) inf_sup_ord( (*‹?x ⊓ ?y ≤ ?x›*) 1) le_inf_iff (*‹(?x ≤ ?y ⊓ ?z) = (?x ≤ ?y ∧ ?x ≤ ?z)›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) text ‹Taken together these facts show that, for $f:Q\to Q$, $f[Q]$ forms a quantale with composition $f\, (-\cdot -)$ and sup $f\, (\bigsqcup -)$, and that $f:Q\to f[Q]$ is a quantale morphism. This is the first part of Theorem 3.1.1 in Rosenthal's book.› class quantale_with_nuc = quantale + cl_op + assumes cl_op_nuc: "cl_op x ⋅ cl_op y ≤ cl_op (x ⋅ y)" begin subclass clattice_with_clop.. end class unital_quantale_with_nuc = quantale_with_nuc + unital_quantale + assumes one_nuc: "1 ≤ cl_op 1" lemma nucleus_cl_op: "nucleus (cl_op::'a::quantale_with_nuc ⇒ 'a)" by (simp add: cl_op_class.clop_iso (*‹?x ≤ ?y ⟹ cl_op ?x ≤ cl_op ?y›*) cl_op_nuc (*‹cl_op ?x ⋅ cl_op ?y ≤ cl_op (?x ⋅ ?y)›*) clop_def (*‹clop ?f = (id ≤ ?f ∧ mono ?f ∧ ?f ∘ ?f ≤ ?f)›*) clop_ext (*‹?x ≤ cl_op ?x›*) le_funI (*‹(⋀x. ?f x ≤ ?g x) ⟹ ?f ≤ ?g›*) monoI (*‹(⋀x y. x ≤ y ⟹ ?f x ≤ ?f y) ⟹ mono ?f›*) nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) lemma unucleus_cl_op: "unucleus (cl_op::'a::unital_quantale_with_nuc ⇒ 'a)" by (simp add: nucleus_cl_op (*‹nucleus cl_op›*) one_nuc (*‹1 ≤ cl_op 1›*) unucleus_def (*‹unucleus ?f = (nucleus ?f ∧ 1 ≤ ?f 1)›*)) instantiation cl_op_im :: (quantale_with_nuc) quantale begin lift_definition times_cl_op_im :: "'a::quantale_with_nuc cl_op_im ⇒ 'a cl_op_im ⇒ 'a cl_op_im" is "λx y. cl_op (x ⋅ y)" by simp instance by (intro_classes; transfer, auto simp: nuc_comp_assoc nuc_comp_distr nucleus_cl_op nuc_comp_distl) end instantiation cl_op_im :: (unital_quantale_with_nuc) unital_quantale begin lift_definition one_cl_op_im :: "'a::unital_quantale_with_nuc cl_op_im" is "cl_op 1" by simp instance by (intro_classes; transfer) (metis clop_closure nsrnqo.mult_onel nuc_prop2 nucleus_cl_op nucleus_def nsrnqo.mult_oner nuc_prop1)+ end text ‹The usefulness of these theorems remains unclear; it seems difficult to make them collaborate with concrete nuclei.› lemma nuc_hom: "Abs_cl_op_im ∘ cl_op ∈ quantale_homset" unfolding quantale_homset_iff comp_def fun_eq_iff (*goal: ‹(∀x y. Abs_cl_op_im (cl_op (x ⋅ y)) = Abs_cl_op_im (cl_op x) ⋅ Abs_cl_op_im (cl_op y)) ∧ (∀x. Abs_cl_op_im (cl_op (⨆ x)) = (⨆x∈x. Abs_cl_op_im (cl_op x)))›*) apply safe (*goal: ‹(∀x y. Abs_cl_op_im (cl_op (x ⋅ y)) = Abs_cl_op_im (cl_op x) ⋅ Abs_cl_op_im (cl_op y)) ∧ (∀x. Abs_cl_op_im (cl_op (⨆ x)) = (⨆x∈x. Abs_cl_op_im (cl_op x)))›*) apply (metis (no_types, lifting) Abs_cl_op_im_inverse (*‹?y ∈ range cl_op ⟹ Rep_cl_op_im (Abs_cl_op_im ?y) = ?y›*) Rep_cl_op_im_inverse (*‹Abs_cl_op_im (Rep_cl_op_im ?x) = ?x›*) nuc_comp_prop (*‹nucleus ?f ⟹ ?f (?f ?x ⋅ ?f ?y) = ?f (?x ⋅ ?y)›*) nucleus_cl_op (*‹nucleus cl_op›*) rangeI (*‹?f ?x ∈ range ?f›*) times_cl_op_im.rep_eq (*‹Rep_cl_op_im (?x ⋅ ?xa) = cl_op (Rep_cl_op_im ?x ⋅ Rep_cl_op_im ?xa)›*)) (*top goal: ‹⋀(x::'a) y::'a. Abs_cl_op_im (cl_op (x ⋅ y)) = Abs_cl_op_im (cl_op x) ⋅ Abs_cl_op_im (cl_op y)› and 1 goal remains*) unfolding Sup_cl_op_im_def (*goal: ‹⋀x. Abs_cl_op_im (cl_op (⨆ x)) = map_fun ((`) Rep_cl_op_im) Abs_cl_op_im (λX. cl_op (⨆ X)) ((λx. Abs_cl_op_im (cl_op x)) ` x)›*) by (smt Abs_cl_op_im_inverse (*‹?y ∈ range cl_op ⟹ Rep_cl_op_im (Abs_cl_op_im ?y) = ?y›*) SUP_cong (*‹⟦?A = ?B; ⋀x. x ∈ ?B ⟹ ?C x = ?D x⟧ ⟹ ⨆ (?C ` ?A) = ⨆ (?D ` ?B)›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) map_fun_apply (*‹map_fun ?f ?g ?h ?x = ?g (?h (?f ?x))›*) nuc_Sup_closed_var (*‹nucleus ?f ⟹ ?f (⨆ (?f ` ?X)) = ?f (⨆ ?X)›*) nucleus_cl_op (*‹nucleus cl_op›*) rangeI (*‹?f ?x ∈ range ?f›*)) text ‹This finishes the first statement of Theorem 3.1.1. The second part follows. It states that for every surjective quantale homomorphism there is a nucleus such that the range of the nucleus is isomorphic to the range of the surjection.› lemma quant_morph_nuc: fixes f :: "'a::quantale_with_dual ⇒ 'b::quantale_with_dual" assumes "f ∈ quantale_homset" shows "nucleus ((radj f) ∘ f)" proof (-) (*goal: ‹nucleus (radj f ∘ f)›*) let ?φ = "(radj f) ∘ f" have adj: "f ⊣ (radj f)" by (simp add: assms (*‹f ∈ quantale_homset›*) quantale_hom_radj (*‹?f ∈ quantale_homset ⟹ ?f ⊣ radj ?f›*)) hence a: "clop ?φ" by (simp add: clop_adj (*‹?f ⊣ ?g ⟹ clop (?g ∘ ?f)›*)) { fix x and y have "f (?φ x ⋅ ?φ y) = (f ∘ ?φ) x ⋅ (f ∘ ?φ) y" by (metis assms (*‹f ∈ quantale_homset›*) comp_eq_dest_lhs (*‹?a ∘ ?b = ?c ⟹ ?a (?b ?v) = ?c ?v›*) quantale_homset_iff (*‹(?f ∈ quantale_homset) = (comp_pres ?f ∧ Sup_pres ?f)›*)) also (*calculation: ‹f ((radj f ∘ f) x ⋅ (radj f ∘ f) y) = (f ∘ (radj f ∘ f)) x ⋅ (f ∘ (radj f ∘ f)) y›*) have "... = f x ⋅ f y" by (simp add: adj (*‹f ⊣ radj f›*) adj_cancel_eq1 (*‹?f ⊣ ?g ⟹ ?f ∘ ?g ∘ ?f = ?f›*) fun.map_comp (*‹?g ∘ (?f ∘ ?v) = ?g ∘ ?f ∘ ?v›*)) also (*calculation: ‹f ((radj f ∘ f) x ⋅ (radj f ∘ f) y) = f x ⋅ f y›*) have "... = f (x ⋅ y)" by (metis assms (*‹f ∈ quantale_homset›*) quantale_homset_iff (*‹(?f ∈ quantale_homset) = (comp_pres ?f ∧ Sup_pres ?f)›*)) finally (*calculation: ‹(f::'a ⇒ 'b) ((radj f ∘ f) (x::'a) ⋅ (radj f ∘ f) (y::'a)) = f (x ⋅ y)›*) have "?φ x ⋅ ?φ y ≤ ?φ (x ⋅ y)" by (metis adj (*‹f ⊣ radj f›*) adj_def (*‹?f ⊣ ?g = (∀x y. (?f x ≤ y) = (x ≤ ?g y))›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) order_refl (*‹?x ≤ ?x›*)) } thus "?thesis" (*goal: ‹nucleus (radj f ∘ f)›*) by (simp add: a (*‹clop (radj (f::'a ⇒ 'b) ∘ f)›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) qed lemma surj_quantale_hom_bij_on: fixes f :: "'a::quantale_with_dual ⇒ 'b::quantale_with_dual" assumes "surj f" and "f ∈ quantale_homset" shows "bij_betw f (range (radj f ∘ f)) UNIV" using assms (*‹top_pres ((`) f)› ‹f ∈ quantale_homset›*) quantale_homset_iff (*‹((?f::?'a::quantale ⇒ ?'b::quantale) ∈ quantale_homset) = (comp_pres ?f ∧ Sup_pres ?f)›*) surj_Sup_pres_bij_on (*‹⟦top_pres ((`) ?f); Sup_pres ?f⟧ ⟹ bij_betw ?f (range (radj ?f ∘ ?f)) UNIV›*) by blast text ‹This establishes the bijection, extending a similar fact about closure operators and complete lattices (surj-Sup-pres-bij). It remains to show that $f$ is a quantale morphism, that is, it preserves Sups and compositions of closed elements with operations defined as in the previous instantiation statement. Sup-preservation holds already for closure operators on complete lattices (surj-Sup-pres-iso). Hence it remains to prove preservation of compositions.› lemma surj_comp_pres_iso: fixes f :: "'a::quantale_with_dual ⇒ 'b::quantale_with_dual" assumes "f ∈ quantale_homset" shows "f ((radj f ∘ f) (x ⋅ y)) = f x ⋅ f y" proof (-) (*goal: ‹f ((radj f ∘ f) (x ⋅ y)) = f x ⋅ f y›*) have "f ⊣ (radj f)" by (simp add: assms (*‹f ∈ quantale_homset›*) quantale_hom_radj (*‹?f ∈ quantale_homset ⟹ ?f ⊣ radj ?f›*)) hence "f ((radj f ∘ f) (x ⋅ y)) = f (x ⋅ y)" by (metis adj_cancel_eq1 (*‹(?f::?'a ⇒ ?'b) ⊣ (?g::?'b ⇒ ?'a) ⟹ ?f ∘ ?g ∘ ?f = ?f›*) comp_eq_dest_lhs (*‹(?a::?'c ⇒ ?'b) ∘ (?b::?'a ⇒ ?'c) = (?c::?'a ⇒ ?'b) ⟹ ?a (?b (?v::?'a)) = ?c ?v›*)) thus "?thesis" (*goal: ‹(f::'a::quantale_with_dual ⇒ 'b::quantale_with_dual) ((radj f ∘ f) ((x::'a::quantale_with_dual) ⋅ (y::'a::quantale_with_dual))) = f x ⋅ f y›*) using assms (*‹f ∈ quantale_homset›*) quantale_homset_iff (*‹(?f ∈ quantale_homset) = (comp_pres ?f ∧ Sup_pres ?f)›*) by auto qed text ‹This establishes the quantale isomorphism and finishes the proof of Theorem 3.1.1.› text ‹Next I prove Theorem 3.1.2 in Rosenthal's book. nuc-Inf-closed shows that $\mathit{Fix}\, f$ is Inf-closed. Hence the two following lemmas show one direction.› lemma nuc_bres_pres: "nucleus f ⟹ y ∈ Fix f ⟹ x → y ∈ Fix f" proof (-) (*goal: ‹⟦nucleus f; y ∈ Fix f⟧ ⟹ x → y ∈ Fix f›*) assume a1: "nucleus f" (*‹nucleus (f::'a ⇒ 'a)›*) assume a2: "y ∈ Fix f" (*‹(y::'a) ∈ Fix (f::'a ⇒ 'a)›*) have "clop f" using a1 (*‹nucleus (f::'a ⇒ 'a)›*) by (simp add: nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) thus "?thesis" (*goal: ‹x → y ∈ Fix f›*) using a2 (*‹y ∈ Fix f›*) a1 (*‹nucleus (f::'a::quantale ⇒ 'a::quantale)›*) by (metis clop_Fix_range (*‹clop (?f::?'a::order ⇒ ?'a::order) ⟹ Fix ?f = range ?f›*) clop_closure (*‹clop (?f::?'a::order ⇒ ?'a::order) ⟹ ((?x::?'a::order) ∈ range ?f) = (?f ?x = ?x)›*) clop_extensive_var (*‹clop (?f::?'a::order ⇒ ?'a::order) ⟹ (?x::?'a::order) ≤ ?f ?x›*) dual_order.antisym (*‹⟦(?b::?'a::order) ≤ (?a::?'a::order); ?a ≤ ?b⟧ ⟹ ?a = ?b›*) nucleus_alt_def_cor1 (*‹nucleus (?f::?'a::quantale ⇒ ?'a::quantale) ⟹ ?f ((?x::?'a::quantale) → (?y::?'a::quantale)) ≤ ?x → ?f ?y›*)) qed lemma nuc_fres_pres: "nucleus f ⟹ y ∈ Fix f ⟹ y ← x ∈ Fix f" proof (-) (*goal: ‹⟦nucleus f; y ∈ Fix f⟧ ⟹ y ← x ∈ Fix f›*) assume a1: "nucleus f" (*‹nucleus (f::'a ⇒ 'a)›*) assume a2: "y ∈ Fix f" (*‹(y::'a) ∈ Fix (f::'a ⇒ 'a)›*) have "clop f" using a1 (*‹nucleus f›*) by (simp add: nucleus_def (*‹nucleus ?f = (clop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) thus "?thesis" (*goal: ‹y ← x ∈ Fix f›*) using a2 (*‹(y::'a) ∈ Fix (f::'a ⇒ 'a)›*) a1 (*‹nucleus (f::'a ⇒ 'a)›*) by (metis antisym_conv (*‹?y ≤ ?x ⟹ (?x ≤ ?y) = (?x = ?y)›*) clop_Fix_range (*‹clop ?f ⟹ Fix ?f = range ?f›*) clop_closure (*‹clop ?f ⟹ (?x ∈ range ?f) = (?f ?x = ?x)›*) clop_extensive_var (*‹clop ?f ⟹ ?x ≤ ?f ?x›*) nucleus_alt_def_cor2 (*‹nucleus ?f ⟹ ?f (?y ← ?x) ≤ ?f ?y ← ?x›*)) qed lemma lax_aux: fixes X :: "'a::quantale set" assumes "∀x.∀y ∈ X. x → y ∈ X" and "∀x. ∀y ∈ X. y ← x ∈ X" shows "⨅{z ∈ X. x ≤ z} ⋅ ⨅{z ∈ X. y ≤ z} ≤ ⨅{z ∈ X. x ⋅ y ≤ z}" proof (-) (*goal: ‹⨅ {z::'a::quantale ∈ X::'a::quantale set. (x::'a::quantale) ≤ z} ⋅ ⨅ {z::'a::quantale ∈ X. (y::'a::quantale) ≤ z} ≤ ⨅ {z::'a::quantale ∈ X. x ⋅ y ≤ z}›*) let ?φ = "λx. ⨅{w ∈ X. x ≤ w}" { fix z assume a: "x ⋅ y ≤ z" and b: "z ∈ X" (*‹(x::'a) ⋅ (y::'a) ≤ (z::'a)› ‹(z::'a) ∈ (X::'a set)›*) hence c: "x ≤ z ← y" by (simp add: fres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?x ≤ ?z ← ?y)›*)) hence "z ← y ∈ X" by (simp add: assms( (*‹∀x::'a. ∀y::'a∈X::'a set. y ← x ∈ X›*) 2) b (*‹(z::'a) ∈ (X::'a set)›*)) hence "?φ x ≤ z ← y" by (simp add: Inf_lower (*‹(?x::?'a::complete_lattice) ∈ (?A::?'a::complete_lattice set) ⟹ ⨅ ?A ≤ ?x›*) c (*‹(x::'a::quantale) ≤ (z::'a::quantale) ← (y::'a::quantale)›*)) hence d: "y ≤ ?φ x → z" by (simp add: bres_galois_imp (*‹(?x::?'a) ⋅ (?y::?'a) ≤ (?z::?'a) ⟹ ?y ≤ ?x → ?z›*) fres_galois (*‹((?x::?'a) ⋅ (?y::?'a) ≤ (?z::?'a)) = (?x ≤ ?z ← ?y)›*)) hence "?φ x → z ∈ X" by (simp add: assms( (*‹∀x. ∀y∈X. x → y ∈ X›*) 1) b (*‹z ∈ X›*)) hence "?φ x ⋅ ?φ y ≤ z" by (simp add: Inf_lower (*‹?x ∈ ?A ⟹ ⨅ ?A ≤ ?x›*) d (*‹y ≤ ⨅ {w ∈ X. x ≤ w} → z›*) bres_galois (*‹(?x ⋅ ?y ≤ ?z) = (?y ≤ ?x → ?z)›*)) } thus "?thesis" (*goal: ‹⨅ {z::'a ∈ X::'a set. (x::'a) ≤ z} ⋅ ⨅ {z::'a ∈ X. (y::'a) ≤ z} ≤ ⨅ {z::'a ∈ X. x ⋅ y ≤ z}›*) by (simp add: le_Inf_iff (*‹(?b ≤ ⨅ ?A) = (∀a∈?A. ?b ≤ a)›*)) qed lemma Inf_closed_res_nuc: fixes X :: "'a::quantale set" assumes "Inf_closed_set X" and "∀x. ∀y ∈ X. x → y ∈ X" and "∀x. ∀y ∈ X. y ← x ∈ X" shows "nucleus (λy. ⨅{x ∈ X. y ≤ x})" unfolding nucleus_def (*goal: ‹clop (λy. ⨅ {x ∈ X. y ≤ x}) ∧ (∀x y. ⨅ {xa ∈ X. x ≤ xa} ⋅ ⨅ {x ∈ X. y ≤ x} ≤ ⨅ {xa ∈ X. x ⋅ y ≤ xa})›*) by (simp add: Inf_closed_clop (*‹Inf_closed_set (?X::?'a set) ⟹ clop (λy::?'a. ⨅ {x::?'a ∈ ?X. y ≤ x})›*) assms (*‹Inf_closed_set (X::'a set)› ‹∀x::'a. ∀y::'a∈X::'a set. x → y ∈ X› ‹∀x::'a. ∀y::'a∈X::'a set. y ← x ∈ X›*) lax_aux (*‹⟦∀x::?'a. ∀y::?'a∈?X::?'a set. x → y ∈ ?X; ∀x::?'a. ∀y::?'a∈?X. y ← x ∈ ?X⟧ ⟹ ⨅ {z::?'a ∈ ?X. (?x::?'a) ≤ z} ⋅ ⨅ {z::?'a ∈ ?X. (?y::?'a) ≤ z} ≤ ⨅ {z::?'a ∈ ?X. ?x ⋅ ?y ≤ z}›*)) lemma Inf_closed_res_Fix: fixes X :: "'a::quantale set" assumes "Inf_closed_set X" and "∀x. ∀y ∈ X. x → y ∈ X" and "∀x. ∀y ∈ X. y ← x ∈ X" shows "X = Fix (λy. ⨅{x ∈ X. y ≤ x})" unfolding Fix_def (*goal: ‹X = {x. ⨅ {xa ∈ X. x ≤ xa} = x}›*) apply safe (*goals: 1. ‹⋀x::'a. x ∈ (X::'a set) ⟹ ⨅ {xa::'a ∈ X. x ≤ xa} = x› 2. ‹⋀x::'a. ⨅ {xa::'a ∈ X::'a set. x ≤ xa} = x ⟹ x ∈ X› discuss goal 1*) apply (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⋀x::'a. x ∈ (X::'a set) ⟹ ⨅ {xa::'a ∈ X. x ≤ xa} ≤ x› 2. ‹⋀x::'a. x ∈ (X::'a set) ⟹ x ≤ ⨅ {xa::'a ∈ X. x ≤ xa}› discuss goal 1*) apply (simp add: Inf_lower (*‹?x ∈ ?A ⟹ ⨅ ?A ≤ ?x›*) le_Inf_iff (*‹(?b ≤ ⨅ ?A) = (∀a∈?A. ?b ≤ a)›*)) (*discuss goal 2*) apply (simp add: Inf_lower (*‹?x ∈ ?A ⟹ ⨅ ?A ≤ ?x›*) le_Inf_iff (*‹(?b ≤ ⨅ ?A) = (∀a∈?A. ?b ≤ a)›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (metis (no_types, lifting) Inf_closed_set_def (*‹Inf_closed_set ?X = (∀Y⊆?X. ⨅ Y ∈ ?X)›*) assms( (*‹Inf_closed_set X›*) 1) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*proven 2 subgoals*) . text ‹This finishes the proof of Theorem 3.1.2› subsection ‹A Representation Theorem› text ‹The final proofs for nuclei lead to Rosenthal's representation theorem for quantales (Theorem 3.1.2).› lemma down_set_lax_morph: "(↓ ∘ Sup) (X::'a::quantale set) ⋅ (↓ ∘ Sup) Y ⊆ (↓ ∘ Sup) (X ⋅ Y)" proof (-) (*goal: ‹(↓ ∘ Sup) X ⋅ (↓ ∘ Sup) Y ⊆ (↓ ∘ Sup) (X ⋅ Y)›*) have "⨆((↓ ∘ Sup) X ⋅ (↓ ∘ Sup) Y) = ⨆(X ⋅ Y)" by (smt Sup_downset_adj (*‹Sup ⊣ ↓›*) adj_cancel_eq1 (*‹?f ⊣ ?g ⟹ ?f ∘ ?g ∘ ?f = ?f›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) comp_dist_mix (*‹⨆ ?X ⋅ ⨆ ?Y = ⨆ (?X ⋅ ?Y)›*)) thus "?thesis" (*goal: ‹(↓ ∘ Sup) (X::'a::quantale set) ⋅ (↓ ∘ Sup) (Y::'a::quantale set) ⊆ (↓ ∘ Sup) (X ⋅ Y)›*) by (simp add: Sup_downset_adj_var (*‹(⨆ ?X ≤ ?y) = (?X ⊆ ↓ ?y)›*) eq_iff (*‹(?a = ?b) = (?a ≤ ?b ∧ ?b ≤ ?a)›*)) qed lemma downset_Sup_nuc: "nucleus (↓ ∘ (Sup::'a::quantale set ⇒ 'a))" using Sup_downset_adj (*‹Sup ⊣ ↓›*) clop_adj (*‹?f ⊣ ?g ⟹ clop (?g ∘ ?f)›*) down_set_lax_morph (*‹(↓ ∘ Sup) ?X ⋅ (↓ ∘ Sup) ?Y ⊆ (↓ ∘ Sup) (?X ⋅ ?Y)›*) nucleus_def (*‹nucleus (?f::?'a ⇒ ?'a) = (clop ?f ∧ (∀(x::?'a) y::?'a. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*) by blast lemma downset_surj: "surj_on ↓ (range (↓ ∘ Sup))" using surj_on_def (*‹surj_on ?f ?Y = (∀y∈?Y. ∃x. y = ?f x)›*) by fastforce text ‹In addition, $\downarrow$ is injective by Lemma downset-inj. Hence it is a bijection between the quantale and the powerset quantale. It remains to show that $\downarrow$ is a quantale morphism.› lemma downset_Sup_pres_var: "↓ (⨆X) = (↓ ∘ Sup) (⇓ (X::'a::quantale set))" unfolding comp_def downset_prop downset_set_def (*goal: ‹{y. y ≤ ⨆ X} = {y. y ≤ ⨆ {y. Bex X ((≤) y)}}›*) apply safe (*goals: 1. ‹⋀x. x ≤ ⨆ X ⟹ x ≤ ⨆ {y. Bex X ((≤) y)}› 2. ‹⋀x. x ≤ ⨆ {y. Bex X ((≤) y)} ⟹ x ≤ ⨆ X› discuss goal 1*) apply (smt Sup_subset_mono (*‹?A ⊆ ?B ⟹ ⨆ ?A ≤ ⨆ ?B›*) dual_order.refl (*‹?a ≤ ?a›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) order_subst1 (*‹⟦?a ≤ ?f ?b; ?b ≤ ?c; ⋀x y. x ≤ y ⟹ ?f x ≤ ?f y⟧ ⟹ ?a ≤ ?f ?c›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) (*discuss goal 2*) apply (smt Sup_mono (*‹(⋀a. a ∈ ?A ⟹ ∃b∈?B. a ≤ b) ⟹ ⨆ ?A ≤ ⨆ ?B›*) le_iff_inf (*‹(?x ≤ ?y) = (?x ⊓ ?y = ?x)›*) le_infI2 (*‹?b ≤ ?x ⟹ ?a ⊓ ?b ≤ ?x›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) (*proven 2 subgoals*) . lemma downset_Sup_pres: "↓ (⨆X) = (↓ ∘ Sup) (⋃ (↓ ` (X::'a::quantale set)))" by (metis downset_Sup_pres_var (*‹↓ (⨆ ?X) = (↓ ∘ Sup) (⇓ ?X)›*) downset_set_prop_var (*‹⇓ ?X = ⋃ (↓ ` ?X)›*)) lemma downset_comp_pres: "↓ ((x::'a::quantale) ⋅ y) = (↓ ∘ Sup) (↓x ⋅ ↓y)" sorry text ‹This finishes the proof of Theorem 3.1.2.› subsection ‹Conuclei› definition conucleus :: "('a::quantale ⇒ 'a::quantale) ⇒ bool" where "conucleus f = (coclop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)))" lemma conuc_lax: "conucleus f ⟹ f x ⋅ f y ≤ f (x ⋅ y)" by (simp add: conucleus_def (*‹conucleus ?f = (coclop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) definition uconucleus :: "('a::unital_quantale ⇒ 'a::unital_quantale) ⇒ bool" where "uconucleus f = (conucleus f ∧ f 1 ≤ 1)" text ‹Next I prove Theorem 3.1.3.› lemma conuc_Sup_closed: "conucleus f ⟹ f ∘ Sup ∘ (`) f = Sup ∘ (`) f" unfolding conucleus_def fun_eq_iff comp_def (*goal: ‹coclop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ ∀x. f (⨆ (f ` x)) = ⨆ (f ` x)›*) by (smt coclop_coextensive_var (*‹coclop ?f ⟹ ?f ?x ≤ ?x›*) coclop_idem (*‹coclop ?f ⟹ ?f ∘ ?f = ?f›*) coclop_iso (*‹coclop ?f ⟹ mono ?f›*) image_comp (*‹?f ` ?g ` ?r = (?f ∘ ?g) ` ?r›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*) le_iff_sup (*‹(?x ≤ ?y) = (?x ⊔ ?y = ?y)›*) mono_SUP (*‹mono ?f ⟹ (⨆x∈?I. ?f (?A x)) ≤ ?f (⨆ (?A ` ?I))›*) sup.orderE (*‹⟦?b ≤ ?a; ?a = ?a ⊔ ?b ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma conuc_comp_closed: "conucleus f ⟹ f (f x ⋅ f y) = f x ⋅ f y" unfolding conucleus_def (*goal: ‹coclop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ f (f x ⋅ f y) = f x ⋅ f y›*) by (metis antisym_conv (*‹?y ≤ ?x ⟹ (?x ≤ ?y) = (?x = ?y)›*) coclop_coextensive_var (*‹coclop ?f ⟹ ?f ?x ≤ ?x›*) coclop_idem_var (*‹coclop ?f ⟹ ?f (?f ?x) = ?f ?x›*)) text ‹The sets of fixpoints of conuclei are closed under Sups and composition; hence they form subquantales.› lemma conuc_Sup_qclosed: "conucleus f ⟹ Sup_closed_set (Fix f) ∧ comp_closed_set (Fix f)" apply safe (*goal: ‹conucleus f ⟹ Sup_closed_set (Fix f) ∧ comp_closed_set (Fix f)›*) apply (simp add: coclop_Sup_closed (*‹coclop ?f ⟹ Sup_closed_set (Fix ?f)›*) conucleus_def (*‹conucleus ?f = (coclop ?f ∧ (∀x y. ?f x ⋅ ?f y ≤ ?f (x ⋅ y)))›*)) (*top goal: ‹conucleus f ⟹ Sup_closed_set (Fix f)› and 1 goal remains*) unfolding conucleus_def comp_closed_set_def (*goal: ‹coclop f ∧ (∀x y. f x ⋅ f y ≤ f (x ⋅ y)) ⟹ ∀x∈Fix f. ∀y∈Fix f. x ⋅ y ∈ Fix f›*) by (metis coclop_coclosure (*‹coclop ?f ⟹ (?f ?x = ?x) = (?x ∈ range ?f)›*) coclop_coclosure_set (*‹coclop ?f ⟹ range ?f = Fix ?f›*) coclop_coextensive_var (*‹coclop ?f ⟹ ?f ?x ≤ ?x›*) dual_order.antisym (*‹⟦?b ≤ ?a; ?a ≤ ?b⟧ ⟹ ?a = ?b›*)) text ‹This shows that the subset $\mathit{Fix} f$ of a quantale, for conucleus $f$, is closed under Sups and composition. It is therefore a subquantale. $f:f[Q]\to Q$ is an embedding. As before, this could be shown by formalising a type class of quantales with a conucleus operation, converting the range of the conucleus into a type and providing a sublocale proof. First, this would require showing that the coclosed elements of a complete lattice form a complete sublattice. Relative to the proofs for closure operators and nuclei there is nothing to be learned. I provide this proof in the section on left-sided elements, where the conucleus can be expressed within the language of quantales.› text ‹The second part of Theorem 3.1.3 states that every subquantale of a given quantale is equal to $\mathit{Fix} f$ for some conucleus $f$.› lemma lax_aux2: fixes X :: "'a::quantale set" assumes "Sup_closed_set X" and "comp_closed_set X" shows "⨆{z ∈ X. z ≤ x} ⋅ ⨆{z ∈ X. z ≤ y} ≤ ⨆{z ∈ X. z ≤ x ⋅ y}" proof (-) (*goal: ‹⨆ {z ∈ X. z ≤ x} ⋅ ⨆ {z ∈ X. z ≤ y} ≤ ⨆ {z ∈ X. z ≤ x ⋅ y}›*) let ?φ = "λx. ⨆{z ∈ X. z ≤ x}" have "?φ x ⋅ ?φ y = ⨆{⨆{v ⋅ w |v. v ∈ X ∧ v ≤ x} |w. w ∈ X ∧ w ≤ y}" by (simp add: Sup_distr (*‹⨆ ?X ⋅ ?y = (⨆x∈?X. x ⋅ ?y)›*) Sup_distl (*‹?x ⋅ ⨆ ?Y = ⨆ ((⋅) ?x ` ?Y)›*) setcompr_eq_image (*‹{?f x |x. ?P x} = ?f ` {x. ?P x}›*)) also (*calculation: ‹⨆ {z ∈ X. z ≤ x} ⋅ ⨆ {z ∈ X. z ≤ y} = ⨆ {⨆ {v ⋅ w |v. v ∈ X ∧ v ≤ x} |w. w ∈ X ∧ w ≤ y}›*) have "... = ⨆{v ⋅ w |v w. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y}" apply (rule antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⨆ {⨆ {v ⋅ w |v. v ∈ X ∧ v ≤ x} |w. w ∈ X ∧ w ≤ y} ≤ ⨆ {v ⋅ w |v w. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y}› 2. ‹⨆ {v ⋅ w |v w. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y} ≤ ⨆ {⨆ {v ⋅ w |v. v ∈ X ∧ v ≤ x} |w. w ∈ X ∧ w ≤ y}› discuss goal 1*) apply (rule Sup_least (*‹(⋀x. x ∈ ?A ⟹ x ≤ ?z) ⟹ ⨆ ?A ≤ ?z›*)) (*top goal: ‹⨆ {⨆ {v ⋅ w |v. v ∈ X ∧ v ≤ x} |w. w ∈ X ∧ w ≤ y} ≤ ⨆ {v ⋅ w |v w. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y}› and 1 goal remains*) apply clarsimp (*top goal: ‹⋀xa::'a. xa ∈ {⨆ {v ⋅ w |v::'a. v ∈ (X::'a set) ∧ v ≤ (x::'a)} |w::'a. w ∈ X ∧ w ≤ (y::'a)} ⟹ xa ≤ ⨆ {v ⋅ w |(v::'a) w::'a. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y}› and 1 goal remains*) apply (smt Collect_mono_iff (*‹(Collect (?P::?'a ⇒ bool) ⊆ Collect (?Q::?'a ⇒ bool)) = (∀x::?'a. ?P x ⟶ ?Q x)›*) Sup_subset_mono (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ ⨆ ?A ≤ ⨆ ?B›*)) (*discuss goal 2*) apply (rule Sup_least (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ≤ (?z::?'a)) ⟹ ⨆ ?A ≤ ?z›*)) (*goal: ‹⨆ {v ⋅ w |(v::'a::quantale) w::'a::quantale. v ∈ (X::'a::quantale set) ∧ v ≤ (x::'a::quantale) ∧ w ∈ X ∧ w ≤ (y::'a::quantale)} ≤ ⨆ {⨆ {v ⋅ w |v::'a::quantale. v ∈ X ∧ v ≤ x} |w::'a::quantale. w ∈ X ∧ w ≤ y}›*) apply clarsimp (*goal: ‹⋀xa. xa ∈ {v ⋅ w |v w. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y} ⟹ xa ≤ ⨆ {⨆ {v ⋅ w |v. v ∈ X ∧ v ≤ x} |w. w ∈ X ∧ w ≤ y}›*) apply (smt Sup_upper2 (*‹⟦(?u::?'a) ∈ (?A::?'a set); (?v::?'a) ≤ ?u⟧ ⟹ ?v ≤ ⨆ ?A›*) eq_iff (*‹((?a::?'a) = (?b::?'a)) = (?a ≤ ?b ∧ ?b ≤ ?a)›*) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*)) (*proven 2 subgoals*) . also (*calculation: ‹⨆ {z ∈ X. z ≤ x} ⋅ ⨆ {z ∈ X. z ≤ y} = ⨆ {v ⋅ w |v w. v ∈ X ∧ v ≤ x ∧ w ∈ X ∧ w ≤ y}›*) have "... ≤ ?φ (x ⋅ y)" by (smt Collect_mono_iff (*‹(Collect ?P ⊆ Collect ?Q) = (∀x. ?P x ⟶ ?Q x)›*) Sup_subset_mono (*‹?A ⊆ ?B ⟹ ⨆ ?A ≤ ⨆ ?B›*) assms( (*‹comp_closed_set X›*) 2) comp_closed_set_def (*‹comp_closed_set ?X = (∀x∈?X. ∀y∈?X. x ⋅ y ∈ ?X)›*) psrpq.mult_isol_var (*‹⟦?u ≤ ?x; ?v ≤ ?y⟧ ⟹ ?u ⋅ ?v ≤ ?x ⋅ ?y›*)) finally (*calculation: ‹⨆ {z ∈ X. z ≤ x} ⋅ ⨆ {z ∈ X. z ≤ y} ≤ ⨆ {z ∈ X. z ≤ x ⋅ y}›*) show "?thesis" (*goal: ‹⨆ {z ∈ X. z ≤ x} ⋅ ⨆ {z ∈ X. z ≤ y} ≤ ⨆ {z ∈ X. z ≤ x ⋅ y}›*) by force qed lemma subquantale_conucleus: fixes X :: "'a::quantale set" assumes "Sup_closed_set X" and "comp_closed_set X" shows "conucleus (λx. ⨆{y ∈ X. y ≤ x})" unfolding conucleus_def (*goal: ‹coclop (λx. ⨆ {y ∈ X. y ≤ x}) ∧ (∀x y. ⨆ {y ∈ X. y ≤ x} ⋅ ⨆ {ya ∈ X. ya ≤ y} ≤ ⨆ {ya ∈ X. ya ≤ x ⋅ y})›*) by (msorry) lemma subquantale_Fix: fixes X :: "'a::quantale set" assumes "Sup_closed_set X" and "comp_closed_set X" shows "X = Fix (λx. ⨆{y ∈ X. y ≤ x})" unfolding Fix_def (*goal: ‹X = {x. ⨆ {y ∈ X. y ≤ x} = x}›*) apply safe (*goals: 1. ‹⋀x. x ∈ X ⟹ ⨆ {y ∈ X. y ≤ x} = x› 2. ‹⋀x. ⨆ {y ∈ X. y ≤ x} = x ⟹ x ∈ X› discuss goal 1*) apply (metis (mono_tags, lifting) Sup_least (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ≤ (?z::?'a)) ⟹ ⨆ ?A ≤ ?z›*) Sup_upper (*‹(?x::?'a) ∈ (?A::?'a set) ⟹ ?x ≤ ⨆ ?A›*) antisym (*‹⟦(?a::?'a) ≤ (?b::?'a); ?b ≤ ?a⟧ ⟹ ?a = ?b›*) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) order_refl (*‹(?x::?'a) ≤ ?x›*)) (*discuss goal 2*) apply (metis (no_types, lifting) Sup_closed_set_def (*‹Sup_closed_set (?X::?'a set) = (∀Y⊆?X. ⨆ Y ∈ ?X)›*) assms( (*‹Sup_closed_set (X::'a set)›*) 1) mem_Collect_eq (*‹((?a::?'a) ∈ Collect (?P::?'a ⇒ bool)) = ?P ?a›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) (*proven 2 subgoals*) . text ‹This finishes the proof of Theorem 3.1.3› end
{ "path": "afp-2025-02-12/thys/Quantales/Quantic_Nuclei_Conuclei.thy", "repo": "afp-2025-02-12", "sha": "697b91033aa6759adb26115b2984cbc6af07448aff585863036b62d6b90018c1" }
(* Title: Isabelle Collections Library Author: Andreas Lochbihler <andreas dot lochbihler at kit.edu> Maintainer: Andreas Lochbihler <andreas dot lochbihler at kit.edu> *) section ‹\isaheader{Implementation of a trie with explicit invariants}› theory Trie_Impl imports "../../Lib/Assoc_List" Trie.Trie begin subsection ‹Interuptible iterator› fun iteratei_postfixed :: "'key list ⇒ ('key, 'val) trie ⇒ ('key list × 'val, 'σ) set_iterator" where "iteratei_postfixed ks (Trie vo ts) c f σ = (if c σ then foldli ts c (λ(k, t) σ. iteratei_postfixed (k # ks) t c f σ) (case vo of None ⇒ σ | Some v ⇒ f (ks, v) σ) else σ)" definition iteratei :: "('key, 'val) trie ⇒ ('key list × 'val, 'σ) set_iterator" where "iteratei t c f σ = iteratei_postfixed [] t c f σ" lemma iteratei_postfixed_interrupt: "¬ c σ ⟹ iteratei_postfixed ks t c f σ = σ" apply (cases t) (*goal: ‹¬ c σ ⟹ iteratei_postfixed ks t c f σ = σ›*) by simp lemma iteratei_interrupt: "¬ c σ ⟹ iteratei t c f σ = σ" unfolding iteratei_def (*goal: ‹¬ c σ ⟹ iteratei_postfixed [] t c f σ = σ›*) by (simp add: iteratei_postfixed_interrupt (*‹¬ ?c ?σ ⟹ iteratei_postfixed ?ks ?t ?c ?f ?σ = ?σ›*)) lemma iteratei_postfixed_alt_def : "iteratei_postfixed ks ((Trie vo ts)::('key, 'val) trie) = (set_iterator_union (case_option set_iterator_emp (λv. set_iterator_sng (ks, v)) vo) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t')) ))" proof (-) (*goal: ‹iteratei_postfixed ks (Trie vo ts) = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t')))›*) have aux: "⋀c f. (λ(k, t). iteratei_postfixed (k # ks) t c f) = (λa. iteratei_postfixed (fst a # ks) (snd a) c f)" by auto show "?thesis" (*goal: ‹iteratei_postfixed ks (Trie vo ts) = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t')))›*) apply (rule ext (*‹(⋀x::?'a::type. (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x) ⟹ ?f = ?g›*)) (*goal: ‹iteratei_postfixed ks (Trie vo ts) = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t')))›*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀x. iteratei_postfixed ks (Trie vo ts) x = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t'))) x›*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀x xa. iteratei_postfixed ks (Trie vo ts) x xa = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t'))) x xa›*) apply (rename_tac c f σ) (*goal: ‹⋀x xa xb. iteratei_postfixed ks (Trie vo ts) x xa xb = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k, t'). iteratei_postfixed (k # ks) t'))) x xa xb›*) apply (simp add: set_iterator_product_def (*‹set_iterator_product ?it_a ?it_b ≡ λc f. ?it_a c (λa. ?it_b a c (λb. f (a, b)))›*) set_iterator_image_filter_def (*‹set_iterator_image_filter ?g ?it ≡ λc f. ?it c (λx σ. case ?g x of None ⇒ σ | Some x' ⇒ f x' σ)›*) set_iterator_union_def (*‹set_iterator_union ?it_a ?it_b ≡ λc f σ0. ?it_b c f (?it_a c f σ0)›*) set_iterator_sng_def (*‹set_iterator_sng ?x ?c ?f ?σ0.0 = (if ?c ?σ0.0 then ?f ?x ?σ0.0 else ?σ0.0)›*) set_iterator_image_alt_def (*‹set_iterator_image ?g ?it = (λc f. ?it c (λx. f (?g x)))›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) set_iterator_emp_def (*‹set_iterator_emp ?c ?f ?σ0.0 = ?σ0.0›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*goal: ‹⋀(c::'a ⇒ bool) (f::'key list × 'val ⇒ 'a ⇒ 'a) σ::'a. iteratei_postfixed (ks::'key list) (Trie (vo::'val option) (ts::('key × ('key, 'val) trie) list)) c f σ = set_iterator_union (case vo of None ⇒ set_iterator_emp | Some (v::'val) ⇒ set_iterator_sng (ks, v)) (set_iterator_image snd (set_iterator_product (foldli ts) (λ(k::'key, t'::('key, 'val) trie). iteratei_postfixed (k # ks) t'))) c f σ›*) by (simp add: aux (*‹(λ(k, t). iteratei_postfixed (k # ks) t ?c ?f) = (λa. iteratei_postfixed (fst a # ks) (snd a) ?c ?f)›*)) qed lemma iteratei_postfixed_correct : assumes invar: "invar_trie (t :: ('key, 'val) trie)" shows "set_iterator ((iteratei_postfixed ks0 t)::('key list × 'val, 'σ) set_iterator) ((λksv. (rev (fst ksv) @ ks0, (snd ksv))) ` (map_to_set (lookup_trie t)))" using invar (*‹invar_trie (t::('key, 'val) trie)›*) proof (induct t arbitrary: ks0) (*goal: ‹⋀(vo::'val::type option) (kvs::('key::type × ('key::type, 'val::type) trie) list) ks0::'key::type list. ⟦⋀(k::'key::type) (t::('key::type, 'val::type) trie) ks0::'key::type list. ⟦(k, t) ∈ set kvs; invar_trie t⟧ ⟹ set_iterator (iteratei_postfixed ks0 t) ((λksv::'key::type list × 'val::type. (rev (fst ksv) @ ks0, snd ksv)) ` map_to_set (lookup_trie t)); invar_trie (Trie vo kvs)⟧ ⟹ set_iterator (iteratei_postfixed ks0 (Trie vo kvs)) ((λksv::'key::type list × 'val::type. (rev (fst ksv) @ ks0, snd ksv)) ` map_to_set (lookup_trie (Trie vo kvs)))›*) case (Trie vo kvs) (*‹⟦(?k, ?t) ∈ set kvs; invar_trie ?t⟧ ⟹ set_iterator (iteratei_postfixed ?ks0.0 ?t) ((λksv. (rev (fst ksv) @ ?ks0.0, snd ksv)) ` map_to_set (lookup_trie ?t))› ‹invar_trie (Trie vo kvs)›*) note ind_hyp = Trie(1) (*‹⟦(?k::'key::type, ?t::('key::type, 'val::type) trie) ∈ set (kvs::('key::type × ('key::type, 'val::type) trie) list); invar_trie ?t⟧ ⟹ set_iterator (iteratei_postfixed (?ks0.0::'key::type list) ?t) ((λksv::'key::type list × 'val::type. (rev (fst ksv) @ ?ks0.0, snd ksv)) ` map_to_set (lookup_trie ?t))›*) note invar = Trie(2) (*‹invar_trie (Trie (vo::'val::type option) (kvs::('key::type × ('key::type, 'val::type) trie) list))›*) from invar (*‹invar_trie (Trie (vo::'val::type option) (kvs::('key::type × ('key::type, 'val::type) trie) list))›*) have dist_fst_kvs: "distinct (map fst kvs)" and dist_kvs: "distinct kvs" and invar_child: "⋀k t. (k, t) ∈ set kvs ⟹ invar_trie t" apply - (*goals: 1. ‹invar_trie (Trie vo kvs) ⟹ distinct (map fst kvs)› 2. ‹invar_trie (Trie vo kvs) ⟹ distinct kvs› 3. ‹⋀k t. ⟦(k, t) ∈ set kvs; invar_trie (Trie vo kvs)⟧ ⟹ invar_trie t› discuss goal 1*) apply (simp add: Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*) distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*)) (*discuss goal 2*) apply (simp add: Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*) distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*)) (*discuss goal 3*) apply (simp add: Ball_def (*‹Ball (?A::?'a set) (?P::?'a ⇒ bool) = (∀x::?'a. x ∈ ?A ⟶ ?P x)›*) distinct_map (*‹distinct (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*)) (*proven 3 subgoals*) . define it_vo :: "('key list × 'val, 'σ) set_iterator" where "it_vo = (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks0, v))" define vo_S where "vo_S = (case vo of None ⇒ {} | Some v ⇒ {(ks0, v)})" have it_vo_OK: "set_iterator it_vo vo_S" unfolding it_vo_def vo_S_def (*goal: ‹set_iterator (case vo of None ⇒ set_iterator_emp | Some v ⇒ set_iterator_sng (ks0, v)) (case vo of None ⇒ {} | Some v ⇒ {(ks0, v)})›*) by (simp split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*) add: set_iterator_emp_correct (*‹set_iterator set_iterator_emp {}›*) set_iterator_sng_correct (*‹set_iterator (set_iterator_sng ?x) {?x}›*)) define it_prod :: "(('key × ('key, 'val) trie) × 'key list × 'val, 'σ) set_iterator" where "it_prod = set_iterator_product (foldli kvs) (λ(k, y). iteratei_postfixed (k # ks0) y)" define it_prod_S where "it_prod_S = (SIGMA kt:set kvs. (λksv. (rev (fst ksv) @ ((fst kt) # ks0), snd ksv)) ` map_to_set (lookup_trie (snd kt)))" have it_prod_OK: "set_iterator it_prod it_prod_S" proof (-) (*goal: ‹set_iterator it_prod it_prod_S›*) from set_iterator_foldli_correct[OF dist_kvs] (*‹set_iterator (foldli kvs) (set kvs)›*) have it_foldli: "set_iterator (foldli kvs) (set kvs)" . { fix kt assume kt_in: "kt ∈ set kvs" (*‹(kt::'key × ('key, 'val) trie) ∈ set (kvs::('key × ('key, 'val) trie) list)›*) hence k_t_in: "(fst kt, snd kt) ∈ set kvs" by simp note ind_hyp[OF k_t_in, OF invar_child [ OF k_t_in ], of "fst kt # ks0"] (*‹set_iterator (iteratei_postfixed (fst kt # ks0) (snd kt)) ((λksv. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)))›*) } note it_child = this (*‹?kt3 ∈ set kvs ⟹ set_iterator (iteratei_postfixed (fst ?kt3 # ks0) (snd ?kt3)) ((λksv. (rev (fst ksv) @ fst ?kt3 # ks0, snd ksv)) ` map_to_set (lookup_trie (snd ?kt3)))›*) show "?thesis" (*goal: ‹set_iterator it_prod it_prod_S›*) unfolding it_prod_def it_prod_S_def (*goal: ‹set_iterator (set_iterator_product (foldli kvs) (λ(k, y). iteratei_postfixed (k # ks0) y)) (SIGMA kt:set kvs. (λksv. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)))›*) apply (rule set_iterator_product_correct [OF it_foldli] (*‹(⋀a. a ∈ set kvs ⟹ set_iterator (?it_b a) (?S_b a)) ⟹ set_iterator (set_iterator_product (foldli kvs) ?it_b) (Sigma (set kvs) ?S_b)›*)) (*goal: ‹set_iterator (set_iterator_product (foldli kvs) (λ(k, y). iteratei_postfixed (k # ks0) y)) (SIGMA kt:set kvs. (λksv. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)))›*) apply (insert it_child (*‹?kt3 ∈ set kvs ⟹ set_iterator (iteratei_postfixed (fst ?kt3 # ks0) (snd ?kt3)) ((λksv. (rev (fst ksv) @ fst ?kt3 # ks0, snd ksv)) ` map_to_set (lookup_trie (snd ?kt3)))›*)) (*goal: ‹⋀a::'key × ('key, 'val) trie. a ∈ set (kvs::('key × ('key, 'val) trie) list) ⟹ set_iterator (case a of (k::'key, x::('key, 'val) trie) ⇒ iteratei_postfixed (k # (ks0::'key list)) x) ((λksv::'key list × 'val. (rev (fst ksv) @ fst a # ks0, snd ksv)) ` map_to_set (lookup_trie (snd a)))›*) by (simp add: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*)) qed have it_image_OK: "set_iterator (set_iterator_image snd it_prod) (snd ` it_prod_S)" proof (rule set_iterator_image_correct[OF it_prod_OK] (*‹⟦inj_on (?g::('key × ('key, 'val) trie) × 'key list × 'val ⇒ ?'c) (it_prod_S::(('key × ('key, 'val) trie) × 'key list × 'val) set); (?S'::?'c set) = ?g ` it_prod_S⟧ ⟹ set_iterator (set_iterator_image ?g (it_prod::('σ ⇒ bool) ⇒ (('key × ('key, 'val) trie) × 'key list × 'val ⇒ 'σ ⇒ 'σ) ⇒ 'σ ⇒ 'σ)) ?S'›*)) (*goals: 1. ‹inj_on snd it_prod_S› 2. ‹snd ` it_prod_S = snd ` it_prod_S›*) from dist_fst_kvs (*‹distinct (map fst kvs)›*) have "⋀k v1 v2. (k, v1) ∈ set kvs ⟹ (k, v2) ∈ set kvs ⟹ v1 = v2" apply (induct kvs) (*goals: 1. ‹⋀k v1 v2. ⟦(k, v1) ∈ set []; (k, v2) ∈ set []; distinct (map fst [])⟧ ⟹ v1 = v2› 2. ‹⋀a kvs k v1 v2. ⟦⋀k v1 v2. ⟦(k, v1) ∈ set kvs; (k, v2) ∈ set kvs; distinct (map fst kvs)⟧ ⟹ v1 = v2; (k, v1) ∈ set (a # kvs); (k, v2) ∈ set (a # kvs); distinct (map fst (a # kvs))⟧ ⟹ v1 = v2› discuss goal 1*) apply ((auto simp add: image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*))[1]) (*discuss goal 2*) apply ((auto simp add: image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*))[1]) (*proven 2 subgoals*) . thus "inj_on snd it_prod_S" unfolding inj_on_def it_prod_S_def (*goal: ‹∀x∈SIGMA kt:set kvs. (λksv. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)). ∀y∈SIGMA kt:set kvs. (λksv. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)). snd x = snd y ⟶ x = y›*) apply (simp add: image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*) map_to_set_def (*‹map_to_set ?m = {(k, v). ?m k = Some v}›*)) (*goal: ‹∀x::('key × ('key, 'val) trie) × 'key list × 'val∈SIGMA kt::'key × ('key, 'val) trie:set (kvs::('key × ('key, 'val) trie) list). (λksv::'key list × 'val. (rev (fst ksv) @ fst kt # (ks0::'key list), snd ksv)) ` map_to_set (lookup_trie (snd kt)). ∀y::('key × ('key, 'val) trie) × 'key list × 'val∈SIGMA kt::'key × ('key, 'val) trie:set kvs. (λksv::'key list × 'val. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)). snd x = snd y ⟶ x = y›*) by auto qed (auto) (*solved the remaining goal: ‹snd ` it_prod_S = snd ` it_prod_S›*) have it_all_OK: "set_iterator ((iteratei_postfixed ks0 (Trie vo kvs)):: ('key list × 'val, 'σ) set_iterator) (vo_S ∪ snd ` it_prod_S)" unfolding iteratei_postfixed_alt_def it_vo_def[symmetric] it_prod_def[symmetric] (*goal: ‹set_iterator (set_iterator_union (it_vo::('σ::type ⇒ bool) ⇒ ('key::type list × 'val::type ⇒ 'σ::type ⇒ 'σ::type) ⇒ 'σ::type ⇒ 'σ::type) (set_iterator_image snd (it_prod::('σ::type ⇒ bool) ⇒ (('key::type × ('key::type, 'val::type) trie) × 'key::type list × 'val::type ⇒ 'σ::type ⇒ 'σ::type) ⇒ 'σ::type ⇒ 'σ::type))) ((vo_S::('key::type list × 'val::type) set) ∪ snd ` (it_prod_S::(('key::type × ('key::type, 'val::type) trie) × 'key::type list × 'val::type) set))›*) proof (rule set_iterator_union_correct [OF it_vo_OK it_image_OK] (*‹vo_S ∩ snd ` it_prod_S = {} ⟹ set_iterator (set_iterator_union it_vo (set_iterator_image snd it_prod)) (vo_S ∪ snd ` it_prod_S)›*)) (*goal: ‹vo_S ∩ snd ` it_prod_S = {}›*) show "vo_S ∩ snd ` it_prod_S = {}" unfolding vo_S_def it_prod_S_def (*goal: ‹(case vo::'val::type option of None ⇒ {} | Some (v::'val::type) ⇒ {(ks0::'key::type list, v)}) ∩ snd ` (SIGMA kt::'key::type × ('key::type, 'val::type) trie:set (kvs::('key::type × ('key::type, 'val::type) trie) list). (λksv::'key::type list × 'val::type. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt))) = {}›*) by (simp split: option.split (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*) add: set_eq_iff (*‹((?A::?'a set) = (?B::?'a set)) = (∀x::?'a. (x ∈ ?A) = (x ∈ ?B))›*) image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*)) qed have it_set_rewr: "((λksv. (rev (fst ksv) @ ks0, snd ksv)) ` map_to_set (lookup_trie (Trie vo kvs))) = (vo_S ∪ snd ` it_prod_S)" (is "?ls = ?rs") apply (simp add: map_to_set_def (*‹map_to_set ?m = {(k, v). ?m k = Some v}›*) lookup_eq_Some_iff[OF invar] (*‹(lookup_trie (Trie vo kvs) ?ks = Some ?v) = (?ks = [] ∧ vo = Some ?v ∨ (∃k t ks'. ?ks = k # ks' ∧ (k, t) ∈ set kvs ∧ lookup_trie t ks' = Some ?v))›*) set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) vo_S_def (*‹vo_S = (case vo of None ⇒ {} | Some v ⇒ {(ks0, v)})›*) it_prod_S_def (*‹it_prod_S = (SIGMA kt:set kvs. (λksv. (rev (fst ksv) @ fst kt # ks0, snd ksv)) ` map_to_set (lookup_trie (snd kt)))›*) Ball_def (*‹Ball ?A ?P = (∀x. x ∈ ?A ⟶ ?P x)›*) Bex_def (*‹Bex ?A ?P = (∃x. x ∈ ?A ∧ ?P x)›*)) (*goal: ‹(λksv. (rev (fst ksv) @ ks0, snd ksv)) ` map_to_set (lookup_trie (Trie vo kvs)) = vo_S ∪ snd ` it_prod_S›*) apply (simp split: option.split (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))›*) del: ex_simps (*‹(∃x. ?P x ∧ ?Q) = ((∃x. ?P x) ∧ ?Q)› ‹(∃x. ?P ∧ ?Q x) = (?P ∧ (∃x. ?Q x))› ‹(∃x. ?P x ∨ ?Q) = ((∃x. ?P x) ∨ ?Q)› ‹(∃x. ?P ∨ ?Q x) = (?P ∨ (∃x. ?Q x))› ‹(∃x. ?P x ⟶ ?Q) = ((∀x. ?P x) ⟶ ?Q)› ‹(∃x. ?P ⟶ ?Q x) = (?P ⟶ (∃x. ?Q x))›*) add: ex_simps[symmetric] (*‹((∃x. ?P x) ∧ ?Q) = (∃x. ?P x ∧ ?Q)› ‹(?P ∧ (∃x. ?Q x)) = (∃x. ?P ∧ ?Q x)› ‹((∃x. ?P x) ∨ ?Q) = (∃x. ?P x ∨ ?Q)› ‹(?P ∨ (∃x. ?Q x)) = (∃x. ?P ∨ ?Q x)› ‹((∀x. ?P x) ⟶ ?Q) = (∃x. ?P x ⟶ ?Q)› ‹(?P ⟶ (∃x. ?Q x)) = (∃x. ?P ⟶ ?Q x)›*)) (*goal: ‹∀a b. (∃aa. (aa = [] ∧ vo = Some b ∨ (∃k t ks'. aa = k # ks' ∧ (k, t) ∈ set kvs ∧ lookup_trie t ks' = Some b)) ∧ a = rev aa @ ks0) = ((a, b) ∈ (case vo of None ⇒ {} | Some v ⇒ {(ks0, v)}) ∨ (∃aa ba. (aa, ba) ∈ set kvs ∧ (∃ab. lookup_trie ba ab = Some b ∧ a = rev ab @ aa # ks0)))›*) apply (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹⋀x2 a b. ⟦vo = Some x2; ∃aa k t ks'. (aa = [] ∧ x2 = b ∨ aa = k # ks' ∧ (k, t) ∈ set kvs ∧ lookup_trie t ks' = Some b) ∧ a = rev aa @ ks0⟧ ⟹ ∃aa ba ab. a = ks0 ∧ b = x2 ∨ (aa, ba) ∈ set kvs ∧ lookup_trie ba ab = Some b ∧ a = rev ab @ aa # ks0› 2. ‹⋀x2 a b. ⟦vo = Some x2; ∃aa ba ab. a = ks0 ∧ b = x2 ∨ (aa, ba) ∈ set kvs ∧ lookup_trie ba ab = Some b ∧ a = rev ab @ aa # ks0⟧ ⟹ ∃aa k t ks'. (aa = [] ∧ x2 = b ∨ aa = k # ks' ∧ (k, t) ∈ set kvs ∧ lookup_trie t ks' = Some b) ∧ a = rev aa @ ks0› discuss goal 1*) apply auto (*discuss goal 2*) apply (metis append_Cons (*‹((?x::?'a) # (?xs::?'a list)) @ (?ys::?'a list) = ?x # ?xs @ ?ys›*) append_Nil (*‹[] @ (?ys::?'a list) = ?ys›*) append_assoc (*‹((?xs::?'a list) @ (?ys::?'a list)) @ (?zs::?'a list) = ?xs @ ?ys @ ?zs›*) rev.simps (*‹rev [] = []› ‹rev ((?x::?'a) # (?xs::?'a list)) = rev ?xs @ [?x]›*)) (*proven 2 subgoals*) . show "?case" (*goal: ‹set_iterator (iteratei_postfixed ks0 (Trie vo kvs)) ((λksv. (rev (fst ksv) @ ks0, snd ksv)) ` map_to_set (lookup_trie (Trie vo kvs)))›*) unfolding it_set_rewr (*goal: ‹set_iterator (iteratei_postfixed ks0 (Trie vo kvs)) (vo_S ∪ snd ` it_prod_S)›*) using it_all_OK (*‹set_iterator (iteratei_postfixed (ks0::'key list) (Trie (vo::'val option) (kvs::('key × ('key, 'val) trie) list))) ((vo_S::('key list × 'val) set) ∪ snd ` (it_prod_S::(('key × ('key, 'val) trie) × 'key list × 'val) set))›*) by fast qed definition trie_reverse_key where "trie_reverse_key ksv = (rev (fst ksv), (snd ksv))" lemma trie_reverse_key_alt_def[code] : "trie_reverse_key (ks, v) = (rev ks, v)" unfolding trie_reverse_key_def (*goal: ‹(rev (fst (ks, v)), snd (ks, v)) = (rev ks, v)›*) by auto lemma trie_reverse_key_reverse[simp] : "trie_reverse_key (trie_reverse_key ksv) = ksv" by (simp add: trie_reverse_key_def (*‹trie_reverse_key ?ksv = (rev (fst ?ksv), snd ?ksv)›*)) lemma trie_iteratei_correct: assumes invar: "invar_trie (t :: ('key, 'val) trie)" shows "set_iterator ((iteratei t)::('key list × 'val, 'σ) set_iterator) (trie_reverse_key ` (map_to_set (lookup_trie t)))" unfolding trie_reverse_key_def[abs_def] iteratei_def[abs_def] (*goal: ‹set_iterator (iteratei_postfixed [] (t::('key, 'val) trie)) ((λksv::'key list × 'val. (rev (fst ksv), snd ksv)) ` map_to_set (lookup_trie t))›*) using iteratei_postfixed_correct[OF invar, of "[]"] (*‹set_iterator (iteratei_postfixed [] t) ((λksv. (rev (fst ksv) @ [], snd ksv)) ` map_to_set (lookup_trie t))›*) by simp hide_const (open) iteratei hide_type (open) trie end
{ "path": "afp-2025-02-12/thys/Collections/ICF/impl/Trie_Impl.thy", "repo": "afp-2025-02-12", "sha": "4c2d10b194b913ac9b9fde882c760116f4157d5c79a479bf6cd73f05a1fdfd7a" }
section ‹Ordered Euclidean Space› theory Ordered_Euclidean_Space imports Convex_Euclidean_Space Abstract_Limits "HOL-Library.Product_Order" begin text ‹An ordering on euclidean spaces that will allow us to talk about intervals› class ordered_euclidean_space = ord + inf + sup + abs + Inf + Sup + euclidean_space + assumes eucl_le: "x ≤ y ⟷ (∀i∈Basis. x ∙ i ≤ y ∙ i)" assumes eucl_less_le_not_le: "x < y ⟷ x ≤ y ∧ ¬ y ≤ x" assumes eucl_inf: "inf x y = (∑i∈Basis. inf (x ∙ i) (y ∙ i) *⇩R i)" assumes eucl_sup: "sup x y = (∑i∈Basis. sup (x ∙ i) (y ∙ i) *⇩R i)" assumes eucl_Inf: "Inf X = (∑i∈Basis. (INF x∈X. x ∙ i) *⇩R i)" assumes eucl_Sup: "Sup X = (∑i∈Basis. (SUP x∈X. x ∙ i) *⇩R i)" assumes eucl_abs: "¦x¦ = (∑i∈Basis. ¦x ∙ i¦ *⇩R i)" begin subclass order by standard (auto simp: eucl_le eucl_less_le_not_le intro!: euclidean_eqI antisym intro: order.trans) subclass ordered_ab_group_add_abs by standard (auto simp: eucl_le inner_add_left eucl_abs abs_leI) subclass ordered_real_vector by standard (auto simp: eucl_le intro!: mult_left_mono mult_right_mono) subclass lattice by standard (auto simp: eucl_inf eucl_sup eucl_le) subclass distrib_lattice by standard (auto simp: eucl_inf eucl_sup sup_inf_distrib1 intro!: euclidean_eqI) subclass conditionally_complete_lattice proof fix z::'a and X::"'a set" assume "X ≠ {}" hence "⋀i. (λx. x ∙ i) ` X ≠ {}" by simp thus "(⋀x. x ∈ X ⟹ z ≤ x) ⟹ z ≤ Inf X" "(⋀x. x ∈ X ⟹ x ≤ z) ⟹ Sup X ≤ z" by (auto simp: eucl_Inf eucl_Sup eucl_le intro!: cInf_greatest cSup_least) qed (force intro!: cInf_lower cSup_upper simp: bdd_below_def bdd_above_def preorder_class.bdd_below_def preorder_class.bdd_above_def eucl_Inf eucl_Sup eucl_le)+ lemma inner_Basis_inf_left: "i ∈ Basis ⟹ inf x y ∙ i = inf (x ∙ i) (y ∙ i)" and inner_Basis_sup_left: "i ∈ Basis ⟹ sup x y ∙ i = sup (x ∙ i) (y ∙ i)" (*goals: 1. ‹i ∈ Basis ⟹ inf x y ∙ i = inf (x ∙ i) (y ∙ i)› 2. ‹i ∈ Basis ⟹ sup x y ∙ i = sup (x ∙ i) (y ∙ i)› discuss goal 1*) apply (simp add: eucl_inf (*‹inf ?x ?y = (∑i∈Basis. inf (?x ∙ i) (?y ∙ i) *⇩R i)›*) eucl_sup (*‹sup ?x ?y = (∑i∈Basis. sup (?x ∙ i) (?y ∙ i) *⇩R i)›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) (*discuss goal 2*) apply (simp add: eucl_inf (*‹inf ?x ?y = (∑i∈Basis. inf (?x ∙ i) (?y ∙ i) *⇩R i)›*) eucl_sup (*‹sup ?x ?y = (∑i∈Basis. sup (?x ∙ i) (?y ∙ i) *⇩R i)›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) (*proven 2 subgoals*) . lemma inner_Basis_INF_left: "i ∈ Basis ⟹ (INF x∈X. f x) ∙ i = (INF x∈X. f x ∙ i)" and inner_Basis_SUP_left: "i ∈ Basis ⟹ (SUP x∈X. f x) ∙ i = (SUP x∈X. f x ∙ i)" using eucl_Sup[of "f ` X"] (*‹Sup ((f::'b::type ⇒ 'a::type) ` (X::'b::type set)) = (∑i::'a::type∈Basis. (SUP x::'a::type∈f ` X. x ∙ i) *⇩R i)›*) eucl_Inf[of "f ` X"] (*‹Inf ((f::'b ⇒ 'a) ` (X::'b set)) = (∑i::'a∈Basis. (INF x::'a∈f ` X. x ∙ i) *⇩R i)›*) apply - (*goals: 1. ‹⟦i ∈ Basis; Sup (f ` X) = (∑i∈Basis. (SUP x∈f ` X. x ∙ i) *⇩R i); Inf (f ` X) = (∑i∈Basis. (INF x∈f ` X. x ∙ i) *⇩R i)⟧ ⟹ Inf (f ` X) ∙ i = (INF x∈X. f x ∙ i)› 2. ‹⟦i ∈ Basis; Sup (f ` X) = (∑i∈Basis. (SUP x∈f ` X. x ∙ i) *⇩R i); Inf (f ` X) = (∑i∈Basis. (INF x∈f ` X. x ∙ i) *⇩R i)⟧ ⟹ Sup (f ` X) ∙ i = (SUP x∈X. f x ∙ i)› discuss goal 1*) apply (simp add: image_comp (*‹?f ` ?g ` ?r = (?f ∘ ?g) ` ?r›*)) (*discuss goal 2*) apply (simp add: image_comp (*‹?f ` ?g ` ?r = (?f ∘ ?g) ` ?r›*)) (*proven 2 subgoals*) . lemma abs_inner: "i ∈ Basis ⟹ ¦x¦ ∙ i = ¦x ∙ i¦" by (auto simp: eucl_abs (*‹¦?x::'a::type¦ = (∑i::'a::type∈Basis. ¦?x ∙ i¦ *⇩R i)›*)) lemma abs_scaleR: "¦a *⇩R b¦ = ¦a¦ *⇩R ¦b¦" by (auto simp: eucl_abs (*‹¦?x¦ = (∑i∈Basis. ¦?x ∙ i¦ *⇩R i)›*) abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) intro!: euclidean_eqI (*‹(⋀b. b ∈ Basis ⟹ ?x ∙ b = ?y ∙ b) ⟹ ?x = ?y›*)) lemma interval_inner_leI: assumes "x ∈ {a .. b}" "0 ≤ i" shows "a∙i ≤ x∙i" "x∙i ≤ b∙i" using assms (*‹x ∈ {a..b}› ‹(0::'a::type) ≤ (i::'a::type)›*) unfolding euclidean_inner[of a i] euclidean_inner[of x i] euclidean_inner[of b i] (*goals: 1. ‹(∑b∈Basis. a ∙ b * (i ∙ b)) ≤ (∑b∈Basis. x ∙ b * (i ∙ b))› 2. ‹(∑b∈Basis. x ∙ b * (i ∙ b)) ≤ (∑ba∈Basis. b ∙ ba * (i ∙ ba))›*) apply - (*goals: 1. ‹⟦x ∈ {a..b}; 0 ≤ i⟧ ⟹ (∑b∈Basis. a ∙ b * (i ∙ b)) ≤ (∑b∈Basis. x ∙ b * (i ∙ b))› 2. ‹⟦x ∈ {a..b}; 0 ≤ i⟧ ⟹ (∑b∈Basis. x ∙ b * (i ∙ b)) ≤ (∑ba∈Basis. b ∙ ba * (i ∙ ba))› discuss goal 1*) apply ((auto intro!: ordered_comm_monoid_add_class.sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) simp: eucl_le (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*))[1]) (*discuss goal 2*) apply ((auto intro!: ordered_comm_monoid_add_class.sum_mono (*‹(⋀i. i ∈ ?K ⟹ ?f i ≤ ?g i) ⟹ sum ?f ?K ≤ sum ?g ?K›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) simp: eucl_le (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*))[1]) (*proven 2 subgoals*) . lemma inner_nonneg_nonneg: shows "0 ≤ a ⟹ 0 ≤ b ⟹ 0 ≤ a ∙ b" using interval_inner_leI[of a 0 a b] (*‹⟦(a::'a) ∈ {0::'a..a}; (0::'a) ≤ (b::'a)⟧ ⟹ (0::'a) ∙ b ≤ a ∙ b› ‹⟦a ∈ {0..a}; 0 ≤ b⟧ ⟹ a ∙ b ≤ a ∙ b›*) by auto lemma inner_Basis_mono: shows "a ≤ b ⟹ c ∈ Basis ⟹ a ∙ c ≤ b ∙ c" by (simp add: eucl_le (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*)) lemma Basis_nonneg[intro, simp]: "i ∈ Basis ⟹ 0 ≤ i" by (auto simp: eucl_le (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*)) lemma Sup_eq_maximum_componentwise: fixes s::"'a set" assumes i: "⋀b. b ∈ Basis ⟹ X ∙ b = i b ∙ b" assumes sup: "⋀b x. b ∈ Basis ⟹ x ∈ s ⟹ x ∙ b ≤ X ∙ b" assumes i_s: "⋀b. b ∈ Basis ⟹ (i b ∙ b) ∈ (λx. x ∙ b) ` s" shows "Sup s = X" using assms (*‹(?b1::'a) ∈ Basis ⟹ (X::'a) ∙ ?b1 = (i::'a ⇒ 'a) ?b1 ∙ ?b1› ‹⟦?b1 ∈ Basis; ?x1 ∈ s⟧ ⟹ ?x1 ∙ ?b1 ≤ X ∙ ?b1› ‹?b1 ∈ Basis ⟹ i ?b1 ∙ ?b1 ∈ (λx. x ∙ ?b1) ` s›*) unfolding eucl_Sup euclidean_representation_sum (*goal: ‹∀i∈Basis. (SUP x∈s. x ∙ i) = X ∙ i›*) by (auto intro!: conditionally_complete_lattice_class.cSup_eq_maximum (*‹⟦?z ∈ ?X; ⋀x. x ∈ ?X ⟹ x ≤ ?z⟧ ⟹ Sup ?X = ?z›*)) lemma Inf_eq_minimum_componentwise: assumes i: "⋀b. b ∈ Basis ⟹ X ∙ b = i b ∙ b" assumes sup: "⋀b x. b ∈ Basis ⟹ x ∈ s ⟹ X ∙ b ≤ x ∙ b" assumes i_s: "⋀b. b ∈ Basis ⟹ (i b ∙ b) ∈ (λx. x ∙ b) ` s" shows "Inf s = X" using assms (*‹?b1 ∈ Basis ⟹ X ∙ ?b1 = i ?b1 ∙ ?b1› ‹⟦?b1 ∈ Basis; ?x1 ∈ s⟧ ⟹ X ∙ ?b1 ≤ ?x1 ∙ ?b1› ‹(?b1::'a) ∈ Basis ⟹ (i::'a ⇒ 'a) ?b1 ∙ ?b1 ∈ (λx::'a. x ∙ ?b1) ` (s::'a set)›*) unfolding eucl_Inf euclidean_representation_sum (*goal: ‹∀i∈Basis. (INF x∈s. x ∙ i) = X ∙ i›*) by (auto intro!: conditionally_complete_lattice_class.cInf_eq_minimum (*‹⟦(?z::?'a) ∈ (?X::?'a set); ⋀x::?'a. x ∈ ?X ⟹ ?z ≤ x⟧ ⟹ Inf ?X = ?z›*)) end proposition compact_attains_Inf_componentwise: fixes b::"'a::ordered_euclidean_space" assumes "b ∈ Basis" assumes "X ≠ {}" "compact X" obtains x where "x ∈ X" "x ∙ b = Inf X ∙ b" "⋀y. y ∈ X ⟹ x ∙ b ≤ y ∙ b" proof (atomize_elim) (*goal: ‹∃x. x ∈ X ∧ x ∙ b = Inf X ∙ b ∧ (∀y. y ∈ X ⟶ x ∙ b ≤ y ∙ b)›*) let ?proj = "(λx. x ∙ b) ` X" from assms (*‹b ∈ Basis› ‹X ≠ {}› ‹compact X›*) have "compact ?proj" "?proj ≠ {}" apply - (*goals: 1. ‹⟦(b::'a::ordered_euclidean_space) ∈ Basis; (X::'a::ordered_euclidean_space set) ≠ {}; compact X⟧ ⟹ compact ((λx::'a::ordered_euclidean_space. x ∙ b) ` X)› 2. ‹⟦(b::'a::ordered_euclidean_space) ∈ Basis; (X::'a::ordered_euclidean_space set) ≠ {}; compact X⟧ ⟹ (λx::'a::ordered_euclidean_space. x ∙ b) ` X ≠ {}› discuss goal 1*) apply ((auto intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 176 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 176 facts*))[1]) (*proven 2 subgoals*) . from compact_attains_inf[OF this] (*‹∃s::real∈(λx::'a. x ∙ (b::'a)) ` (X::'a set). ∀t::real∈(λx::'a. x ∙ b) ` X. s ≤ t›*) obtain s and x where s: "s∈(λx. x ∙ b) ` X" "⋀t. t∈(λx. x ∙ b) ` X ⟹ s ≤ t" and x: "x ∈ X" "s = x ∙ b" "⋀y. y ∈ X ⟹ x ∙ b ≤ y ∙ b" (*goal: ‹(⋀s x. ⟦s ∈ (λx. x ∙ b) ` X; ⋀t. t ∈ (λx. x ∙ b) ` X ⟹ s ≤ t; x ∈ X; s = x ∙ b; ⋀y. y ∈ X ⟹ x ∙ b ≤ y ∙ b⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "Inf ?proj = x ∙ b" by (auto intro!: conditionally_complete_lattice_class.cInf_eq_minimum (*‹⟦?z ∈ ?X; ⋀x. x ∈ ?X ⟹ ?z ≤ x⟧ ⟹ Inf ?X = ?z›*)) hence "x ∙ b = Inf X ∙ b" by (auto simp: eucl_Inf (*‹Inf ?X = (∑i∈Basis. (INF x∈?X. x ∙ i) *⇩R i)›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) ‹b ∈ Basis› cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) with x (*‹x ∈ X› ‹s = x ∙ b› ‹?y ∈ X ⟹ x ∙ b ≤ ?y ∙ b›*) show "∃x. x ∈ X ∧ x ∙ b = Inf X ∙ b ∧ (∀y. y ∈ X ⟶ x ∙ b ≤ y ∙ b)" by blast qed proposition compact_attains_Sup_componentwise: fixes b::"'a::ordered_euclidean_space" assumes "b ∈ Basis" assumes "X ≠ {}" "compact X" obtains x where "x ∈ X" "x ∙ b = Sup X ∙ b" "⋀y. y ∈ X ⟹ y ∙ b ≤ x ∙ b" proof (atomize_elim) (*goal: ‹∃x. x ∈ X ∧ x ∙ b = Sup X ∙ b ∧ (∀y. y ∈ X ⟶ y ∙ b ≤ x ∙ b)›*) let ?proj = "(λx. x ∙ b) ` X" from assms (*‹b ∈ Basis› ‹X ≠ {}› ‹compact X›*) have "compact ?proj" "?proj ≠ {}" apply - (*goals: 1. ‹⟦(b::'a) ∈ Basis; (X::'a set) ≠ {}; compact X⟧ ⟹ compact ((λx::'a. x ∙ b) ` X)› 2. ‹⟦(b::'a) ∈ Basis; (X::'a set) ≠ {}; compact X⟧ ⟹ (λx::'a. x ∙ b) ` X ≠ {}› discuss goal 1*) apply ((auto intro!: compact_continuous_image (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 176 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 176 facts*))[1]) (*proven 2 subgoals*) . from compact_attains_sup[OF this] (*‹∃s∈(λx. x ∙ b) ` X. ∀t∈(λx. x ∙ b) ` X. t ≤ s›*) obtain s and x where s: "s∈(λx. x ∙ b) ` X" "⋀t. t∈(λx. x ∙ b) ` X ⟹ t ≤ s" and x: "x ∈ X" "s = x ∙ b" "⋀y. y ∈ X ⟹ y ∙ b ≤ x ∙ b" (*goal: ‹(⋀s x. ⟦s ∈ (λx. x ∙ b) ` X; ⋀t. t ∈ (λx. x ∙ b) ` X ⟹ t ≤ s; x ∈ X; s = x ∙ b; ⋀y. y ∈ X ⟹ y ∙ b ≤ x ∙ b⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "Sup ?proj = x ∙ b" by (auto intro!: cSup_eq_maximum (*‹⟦?z ∈ ?X; ⋀x. x ∈ ?X ⟹ x ≤ ?z⟧ ⟹ Sup ?X = ?z›*)) hence "x ∙ b = Sup X ∙ b" by (auto simp: eucl_Sup[where 'a='a] (*‹Sup ?X = (∑i∈Basis. (SUP x∈?X. x ∙ i) *⇩R i)›*) inner_sum_left (*‹sum ?f ?A ∙ ?y = (∑x∈?A. ?f x ∙ ?y)›*) inner_Basis (*‹⟦?u ∈ Basis; ?v ∈ Basis⟧ ⟹ ?u ∙ ?v = (if ?u = ?v then 1 else 0)›*) if_distrib (*‹?f (if ?c then ?x else ?y) = (if ?c then ?f ?x else ?f ?y)›*) ‹b ∈ Basis› cong: if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*)) with x (*‹x ∈ X› ‹s = x ∙ b› ‹(?y::'a) ∈ (X::'a set) ⟹ ?y ∙ (b::'a) ≤ (x::'a) ∙ b›*) show "∃x. x ∈ X ∧ x ∙ b = Sup X ∙ b ∧ (∀y. y ∈ X ⟶ y ∙ b ≤ x ∙ b)" by blast qed lemma tendsto_sup[tendsto_intros]: fixes X :: "'a ⇒ 'b::ordered_euclidean_space" assumes "(X ⤏ x) net" "(Y ⤏ y) net" shows "((λi. sup (X i) (Y i)) ⤏ sup x y) net" unfolding sup_max eucl_sup (*goal: ‹((λi. ∑ia∈Basis. max (X i ∙ ia) (Y i ∙ ia) *⇩R ia) ⤏ (∑i∈Basis. max (x ∙ i) (y ∙ i) *⇩R i)) net›*) by (intro assms (*‹(X ⤏ x) net› ‹(Y ⤏ y) net›*) tendsto_intros (*‹((λx. x) ⤏ ?a) (at ?a within ?s)› ‹((λx. ?k) ⤏ ?k) ?F› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. max (?X x) (?Y x)) ⤏ max ?x ?y) ?net› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. min (?X x) (?Y x)) ⤏ min ?x ?y) ?net› ‹?k ≠ ?L ⟹ ¬ (λx. ?k) ─?a→ ?L› ‹(?f ⤏ ?a) ?F ⟹ ((λx. fst (?f x)) ⤏ fst ?a) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. snd (?f x)) ⤏ snd ?a) ?F› ‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. (?f x, ?g x)) ⤏ (?a, ?b)) ?F› ‹(λn. 1 / of_nat n) ⇢ 0› ‹⟦(?f ⤏ ?l) ?F; (?g ⤏ ?m) ?F⟧ ⟹ ((λx. dist (?f x) (?g x)) ⤏ dist ?l ?m) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. norm (?f x)) ⤏ norm ?a) ?F› ‹(?f ⤏ ?l) ?F ⟹ ((λx. ¦?f x¦) ⤏ ¦?l¦) ?F› and more 49 facts*)) lemma tendsto_inf[tendsto_intros]: fixes X :: "'a ⇒ 'b::ordered_euclidean_space" assumes "(X ⤏ x) net" "(Y ⤏ y) net" shows "((λi. inf (X i) (Y i)) ⤏ inf x y) net" unfolding inf_min eucl_inf (*goal: ‹((λi. ∑ia∈Basis. min (X i ∙ ia) (Y i ∙ ia) *⇩R ia) ⤏ (∑i∈Basis. min (x ∙ i) (y ∙ i) *⇩R i)) net›*) by (intro assms (*‹((X::'a ⇒ 'b) ⤏ (x::'b)) (net::'a filter)› ‹((Y::'a ⇒ 'b) ⤏ (y::'b)) (net::'a filter)›*) tendsto_intros (*‹((λx::?'a. x) ⤏ (?a::?'a)) (at ?a within (?s::?'a set))› ‹((λx::?'b. ?k::?'a) ⤏ ?k) (?F::?'b filter)› ‹⟦((?X::?'b ⇒ ?'a) ⤏ (?x::?'a)) (?net::?'b filter); ((?Y::?'b ⇒ ?'a) ⤏ (?y::?'a)) ?net⟧ ⟹ ((λx::?'b. max (?X x) (?Y x)) ⤏ max ?x ?y) ?net› ‹⟦((?X::?'b ⇒ ?'a) ⤏ (?x::?'a)) (?net::?'b filter); ((?Y::?'b ⇒ ?'a) ⤏ (?y::?'a)) ?net⟧ ⟹ ((λx::?'b. min (?X x) (?Y x)) ⤏ min ?x ?y) ?net› ‹(?k::?'b) ≠ (?L::?'b) ⟹ ¬ (λx::?'a. ?k) ─?a::?'a→ ?L› ‹((?f::?'a ⇒ ?'b × ?'c) ⤏ (?a::?'b × ?'c)) (?F::?'a filter) ⟹ ((λx::?'a. fst (?f x)) ⤏ fst ?a) ?F› ‹((?f::?'a ⇒ ?'b × ?'c) ⤏ (?a::?'b × ?'c)) (?F::?'a filter) ⟹ ((λx::?'a. snd (?f x)) ⤏ snd ?a) ?F› ‹⟦((?f::?'a ⇒ ?'b) ⤏ (?a::?'b)) (?F::?'a filter); ((?g::?'a ⇒ ?'c) ⤏ (?b::?'c)) ?F⟧ ⟹ ((λx::?'a. (?f x, ?g x)) ⤏ (?a, ?b)) ?F› ‹(λn::nat. (1::?'a) / of_nat n) ⇢ (0::?'a)› ‹⟦((?f::?'b ⇒ ?'a) ⤏ (?l::?'a)) (?F::?'b filter); ((?g::?'b ⇒ ?'a) ⤏ (?m::?'a)) ?F⟧ ⟹ ((λx::?'b. dist (?f x) (?g x)) ⤏ dist ?l ?m) ?F› ‹((?f::?'a ⇒ ?'b) ⤏ (?a::?'b)) (?F::?'a filter) ⟹ ((λx::?'a. norm (?f x)) ⤏ norm ?a) ?F› ‹((?f::?'a ⇒ real) ⤏ (?l::real)) (?F::?'a filter) ⟹ ((λx::?'a. ¦?f x¦) ⤏ ¦?l¦) ?F› and more 50 facts*)) lemma tendsto_Inf[tendsto_intros]: fixes f :: "'a ⇒ 'b ⇒ 'c::ordered_euclidean_space" assumes "finite K" "⋀i. i ∈ K ⟹ ((λx. f x i) ⤏ l i) F" shows "((λx. Inf (f x ` K)) ⤏ Inf (l ` K)) F" using assms (*‹finite (K::'b set)› ‹(?i::'b) ∈ (K::'b set) ⟹ ((λx::'a. (f::'a ⇒ 'b ⇒ 'c) x ?i) ⤏ (l::'b ⇒ 'c) ?i) (F::'a filter)›*) apply (induction K rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹(⋀i. i ∈ {} ⟹ ((λx. f x i) ⤏ l i) F) ⟹ ((λx. Inf (f x ` {})) ⤏ Inf (l ` {})) F› 2. ‹⋀x Fa. ⟦finite Fa; x ∉ Fa; (⋀i. i ∈ Fa ⟹ ((λx. f x i) ⤏ l i) F) ⟹ ((λx. Inf (f x ` Fa)) ⤏ Inf (l ` Fa)) F; ⋀i. i ∈ insert x Fa ⟹ ((λx. f x i) ⤏ l i) F⟧ ⟹ ((λxa. Inf (f xa ` insert x Fa)) ⤏ Inf (l ` insert x Fa)) F› discuss goal 1*) apply ((auto simp: cInf_insert_If (*‹bdd_below ?X ⟹ Inf (insert ?a ?X) = (if ?X = {} then ?a else inf ?a (Inf ?X))›*) tendsto_inf (*‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λi. inf (?X i) (?Y i)) ⤏ inf ?x ?y) ?net›*))[1]) (*discuss goal 2*) apply ((auto simp: cInf_insert_If (*‹bdd_below (?X::?'a set) ⟹ Inf (insert (?a::?'a) ?X) = (if ?X = {} then ?a else inf ?a (Inf ?X))›*) tendsto_inf (*‹⟦((?X::?'a ⇒ ?'b) ⤏ (?x::?'b)) (?net::?'a filter); ((?Y::?'a ⇒ ?'b) ⤏ (?y::?'b)) ?net⟧ ⟹ ((λi::?'a. inf (?X i) (?Y i)) ⤏ inf ?x ?y) ?net›*))[1]) (*proven 2 subgoals*) . lemma tendsto_Sup[tendsto_intros]: fixes f :: "'a ⇒ 'b ⇒ 'c::ordered_euclidean_space" assumes "finite K" "⋀i. i ∈ K ⟹ ((λx. f x i) ⤏ l i) F" shows "((λx. Sup (f x ` K)) ⤏ Sup (l ` K)) F" using assms (*‹finite K› ‹?i ∈ K ⟹ ((λx. f x ?i) ⤏ l ?i) F›*) apply (induction K rule: finite_induct (*‹⟦finite (?F::?'a::type set); (?P::?'a::type set ⇒ bool) {}; ⋀(x::?'a::type) F::?'a::type set. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹(⋀i. i ∈ {} ⟹ ((λx. f x i) ⤏ l i) F) ⟹ ((λx. Sup (f x ` {})) ⤏ Sup (l ` {})) F› 2. ‹⋀x Fa. ⟦finite Fa; x ∉ Fa; (⋀i. i ∈ Fa ⟹ ((λx. f x i) ⤏ l i) F) ⟹ ((λx. Sup (f x ` Fa)) ⤏ Sup (l ` Fa)) F; ⋀i. i ∈ insert x Fa ⟹ ((λx. f x i) ⤏ l i) F⟧ ⟹ ((λxa. Sup (f xa ` insert x Fa)) ⤏ Sup (l ` insert x Fa)) F› discuss goal 1*) apply ((auto simp: cSup_insert_If (*‹bdd_above ?X ⟹ Sup (insert ?a ?X) = (if ?X = {} then ?a else sup ?a (Sup ?X))›*) tendsto_sup (*‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λi. sup (?X i) (?Y i)) ⤏ sup ?x ?y) ?net›*))[1]) (*discuss goal 2*) apply ((auto simp: cSup_insert_If (*‹bdd_above ?X ⟹ Sup (insert ?a ?X) = (if ?X = {} then ?a else sup ?a (Sup ?X))›*) tendsto_sup (*‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λi. sup (?X i) (?Y i)) ⤏ sup ?x ?y) ?net›*))[1]) (*proven 2 subgoals*) . lemma continuous_map_Inf [continuous_intros]: fixes f :: "'a ⇒ 'b ⇒ 'c::ordered_euclidean_space" assumes "finite K" "⋀i. i ∈ K ⟹ continuous_map X euclidean (λx. f x i)" shows "continuous_map X euclidean (λx. INF i∈K. f x i)" using assms (*‹finite (K::'b::type set)› ‹(?i::'b) ∈ (K::'b set) ⟹ continuous_map (X::'a topology) euclidean (λx::'a. (f::'a ⇒ 'b ⇒ 'c) x ?i)›*) by (simp add: continuous_map_atin (*‹continuous_map ?X ?Y ?f = (∀x∈topspace ?X. limitin ?Y ?f (?f x) (atin ?X x))›*) tendsto_Inf (*‹⟦finite ?K; ⋀i. i ∈ ?K ⟹ ((λx. ?f x i) ⤏ ?l i) ?F⟧ ⟹ ((λx. Inf (?f x ` ?K)) ⤏ Inf (?l ` ?K)) ?F›*)) lemma continuous_map_Sup [continuous_intros]: fixes f :: "'a ⇒ 'b ⇒ 'c::ordered_euclidean_space" assumes "finite K" "⋀i. i ∈ K ⟹ continuous_map X euclidean (λx. f x i)" shows "continuous_map X euclidean (λx. SUP i∈K. f x i)" using assms (*‹finite K› ‹?i ∈ K ⟹ continuous_map X euclidean (λx. f x ?i)›*) by (simp add: continuous_map_atin (*‹continuous_map ?X ?Y ?f = (∀x∈topspace ?X. limitin ?Y ?f (?f x) (atin ?X x))›*) tendsto_Sup (*‹⟦finite ?K; ⋀i. i ∈ ?K ⟹ ((λx. ?f x i) ⤏ ?l i) ?F⟧ ⟹ ((λx. Sup (?f x ` ?K)) ⤏ Sup (?l ` ?K)) ?F›*)) lemma tendsto_componentwise_max: assumes f: "(f ⤏ l) F" and g: "(g ⤏ m) F" shows "((λx. (∑i∈Basis. max (f x ∙ i) (g x ∙ i) *⇩R i)) ⤏ (∑i∈Basis. max (l ∙ i) (m ∙ i) *⇩R i)) F" by (intro tendsto_intros (*‹((λx::?'a::topological_space. x) ⤏ (?a::?'a::topological_space)) (at ?a within (?s::?'a::topological_space set))› ‹((λx::?'b::type. ?k::?'a::topological_space) ⤏ ?k) (?F::?'b::type filter)› ‹⟦((?X::?'b::type ⇒ ?'a::linorder_topology) ⤏ (?x::?'a::linorder_topology)) (?net::?'b::type filter); ((?Y::?'b::type ⇒ ?'a::linorder_topology) ⤏ (?y::?'a::linorder_topology)) ?net⟧ ⟹ ((λx::?'b::type. max (?X x) (?Y x)) ⤏ max ?x ?y) ?net› ‹⟦((?X::?'b::type ⇒ ?'a::linorder_topology) ⤏ (?x::?'a::linorder_topology)) (?net::?'b::type filter); ((?Y::?'b::type ⇒ ?'a::linorder_topology) ⤏ (?y::?'a::linorder_topology)) ?net⟧ ⟹ ((λx::?'b::type. min (?X x) (?Y x)) ⤏ min ?x ?y) ?net› ‹(?k::?'b::t2_space) ≠ (?L::?'b::t2_space) ⟹ ¬ (λx::?'a::perfect_space. ?k) ─?a::?'a::perfect_space→ ?L› ‹((?f::?'a::type ⇒ ?'b::topological_space × ?'c::topological_space) ⤏ (?a::?'b::topological_space × ?'c::topological_space)) (?F::?'a::type filter) ⟹ ((λx::?'a::type. fst (?f x)) ⤏ fst ?a) ?F› ‹((?f::?'a::type ⇒ ?'b::topological_space × ?'c::topological_space) ⤏ (?a::?'b::topological_space × ?'c::topological_space)) (?F::?'a::type filter) ⟹ ((λx::?'a::type. snd (?f x)) ⤏ snd ?a) ?F› ‹⟦((?f::?'a::type ⇒ ?'b::topological_space) ⤏ (?a::?'b::topological_space)) (?F::?'a::type filter); ((?g::?'a::type ⇒ ?'c::topological_space) ⤏ (?b::?'c::topological_space)) ?F⟧ ⟹ ((λx::?'a::type. (?f x, ?g x)) ⤏ (?a, ?b)) ?F› ‹(λn::nat. (1::?'a::real_normed_field) / of_nat n) ⇢ (0::?'a::real_normed_field)› ‹⟦((?f::?'b::type ⇒ ?'a::metric_space) ⤏ (?l::?'a::metric_space)) (?F::?'b::type filter); ((?g::?'b::type ⇒ ?'a::metric_space) ⤏ (?m::?'a::metric_space)) ?F⟧ ⟹ ((λx::?'b::type. dist (?f x) (?g x)) ⤏ dist ?l ?m) ?F› ‹((?f::?'a::type ⇒ ?'b::real_normed_vector) ⤏ (?a::?'b::real_normed_vector)) (?F::?'a::type filter) ⟹ ((λx::?'a::type. norm (?f x)) ⤏ norm ?a) ?F› ‹((?f::?'a::type ⇒ real) ⤏ (?l::real)) (?F::?'a::type filter) ⟹ ((λx::?'a::type. ¦?f x¦) ⤏ ¦?l¦) ?F› and more 53 facts*) assms (*‹((f::'a::type ⇒ 'b::euclidean_space) ⤏ (l::'b::euclidean_space)) (F::'a::type filter)› ‹((g::'a::type ⇒ 'b::euclidean_space) ⤏ (m::'b::euclidean_space)) (F::'a::type filter)›*)) lemma tendsto_componentwise_min: assumes f: "(f ⤏ l) F" and g: "(g ⤏ m) F" shows "((λx. (∑i∈Basis. min (f x ∙ i) (g x ∙ i) *⇩R i)) ⤏ (∑i∈Basis. min (l ∙ i) (m ∙ i) *⇩R i)) F" by (intro tendsto_intros (*‹((λx. x) ⤏ ?a) (at ?a within ?s)› ‹((λx. ?k) ⤏ ?k) ?F› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. max (?X x) (?Y x)) ⤏ max ?x ?y) ?net› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. min (?X x) (?Y x)) ⤏ min ?x ?y) ?net› ‹?k ≠ ?L ⟹ ¬ (λx. ?k) ─?a→ ?L› ‹(?f ⤏ ?a) ?F ⟹ ((λx. fst (?f x)) ⤏ fst ?a) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. snd (?f x)) ⤏ snd ?a) ?F› ‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. (?f x, ?g x)) ⤏ (?a, ?b)) ?F› ‹(λn. 1 / of_nat n) ⇢ 0› ‹⟦(?f ⤏ ?l) ?F; (?g ⤏ ?m) ?F⟧ ⟹ ((λx. dist (?f x) (?g x)) ⤏ dist ?l ?m) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. norm (?f x)) ⤏ norm ?a) ?F› ‹(?f ⤏ ?l) ?F ⟹ ((λx. ¦?f x¦) ⤏ ¦?l¦) ?F› and more 53 facts*) assms (*‹(f ⤏ l) F› ‹(g ⤏ m) F›*)) instance real :: ordered_euclidean_space by standard auto lemma in_Basis_prod_iff: fixes i::"'a::euclidean_space*'b::euclidean_space" shows "i ∈ Basis ⟷ fst i = 0 ∧ snd i ∈ Basis ∨ snd i = 0 ∧ fst i ∈ Basis" apply (cases i) (*goal: ‹(i ∈ Basis) = (fst i = 0 ∧ snd i ∈ Basis ∨ snd i = 0 ∧ fst i ∈ Basis)›*) by (auto simp: Basis_prod_def (*‹Basis = (λu. (u, 0)) ` Basis ∪ Pair 0 ` Basis›*)) instantiation✐‹tag unimportant› prod :: (abs, abs) abs begin definition "¦x¦ = (¦fst x¦, ¦snd x¦)" instance .. end instance prod :: (ordered_euclidean_space, ordered_euclidean_space) ordered_euclidean_space by standard (auto intro!: add_mono simp add: euclidean_representation_sum' Ball_def inner_prod_def in_Basis_prod_iff inner_Basis_inf_left inner_Basis_sup_left inner_Basis_INF_left Inf_prod_def inner_Basis_SUP_left Sup_prod_def less_prod_def less_eq_prod_def eucl_le[where 'a='a] eucl_le[where 'a='b] abs_prod_def abs_inner) text‹Instantiation for intervals on ‹ordered_euclidean_space›› proposition fixes a :: "'a::ordered_euclidean_space" shows cbox_interval: "cbox a b = {a..b}" and interval_cbox: "{a..b} = cbox a b" and eucl_le_atMost: "{x. ∀i∈Basis. x ∙ i <= a ∙ i} = {..a}" and eucl_le_atLeast: "{x. ∀i∈Basis. a ∙ i <= x ∙ i} = {a..}" (*goals: 1. ‹cbox a b = {a..b}› 2. ‹{a..b} = cbox a b› 3. ‹{x. ∀i∈Basis. x ∙ i ≤ a ∙ i} = {..a}› 4. ‹{x. ∀i∈Basis. a ∙ i ≤ x ∙ i} = {a..}› discuss goal 1*) apply ((auto simp: eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) eucl_less_def (*‹eucl_less ?a ?b = (∀i∈Basis. ?a ∙ i < ?b ∙ i)›*) box_def (*‹box ?a ?b = {x. ∀i∈Basis. ?a ∙ i < x ∙ i ∧ x ∙ i < ?b ∙ i}›*) cbox_def (*‹cbox ?a ?b = {x. ∀i∈Basis. ?a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ ?b ∙ i}›*))[1]) (*discuss goal 2*) apply ((auto simp: eucl_le[where 'a='a] (*‹((?x::'a) ≤ (?y::'a)) = (∀i::'a∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) eucl_less_def (*‹eucl_less (?a::?'a) (?b::?'a) = (∀i::?'a∈Basis. ?a ∙ i < ?b ∙ i)›*) box_def (*‹box (?a::?'a) (?b::?'a) = {x::?'a. ∀i::?'a∈Basis. ?a ∙ i < x ∙ i ∧ x ∙ i < ?b ∙ i}›*) cbox_def (*‹cbox (?a::?'a) (?b::?'a) = {x::?'a. ∀i::?'a∈Basis. ?a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ ?b ∙ i}›*))[1]) (*discuss goal 3*) apply ((auto simp: eucl_le[where 'a='a] (*‹((?x::'a) ≤ (?y::'a)) = (∀i::'a∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) eucl_less_def (*‹eucl_less (?a::?'a) (?b::?'a) = (∀i::?'a∈Basis. ?a ∙ i < ?b ∙ i)›*) box_def (*‹box (?a::?'a) (?b::?'a) = {x::?'a. ∀i::?'a∈Basis. ?a ∙ i < x ∙ i ∧ x ∙ i < ?b ∙ i}›*) cbox_def (*‹cbox (?a::?'a) (?b::?'a) = {x::?'a. ∀i::?'a∈Basis. ?a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ ?b ∙ i}›*))[1]) (*discuss goal 4*) apply ((auto simp: eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*) eucl_less_def (*‹eucl_less ?a ?b = (∀i∈Basis. ?a ∙ i < ?b ∙ i)›*) box_def (*‹box ?a ?b = {x. ∀i∈Basis. ?a ∙ i < x ∙ i ∧ x ∙ i < ?b ∙ i}›*) cbox_def (*‹cbox ?a ?b = {x. ∀i∈Basis. ?a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ ?b ∙ i}›*))[1]) (*proven 4 subgoals*) . lemma sums_vec_nth : assumes "f sums a" shows "(λx. f x $ i) sums a $ i" using assms (*‹(f::nat ⇒ ('a, 'b) vec) sums (a::('a, 'b) vec)›*) unfolding sums_def (*goal: ‹(λn. ∑x<n. f x $ i) ⇢ a $ i›*) by (auto dest: tendsto_vec_nth [where i=i] (*‹((?f::?'a::type ⇒ (?'b::topological_space, 'b::finite) vec) ⤏ (?a::(?'b::topological_space, 'b::finite) vec)) (?net::?'a::type filter) ⟹ ((λx::?'a::type. ?f x $ (i::'b::finite)) ⤏ ?a $ i) ?net›*)) lemma summable_vec_nth : assumes "summable f" shows "summable (λx. f x $ i)" using assms (*‹summable (f::nat ⇒ ('a, 'b) vec)›*) unfolding summable_def (*goal: ‹Ex ((sums) (λx. f x $ i))›*) by (blast intro: sums_vec_nth (*‹?f sums ?a ⟹ (λx. ?f x $ ?i) sums ?a $ ?i›*)) lemma closed_eucl_atLeastAtMost[simp, intro]: fixes a :: "'a::ordered_euclidean_space" shows "closed {a..b}" by (simp add: cbox_interval[symmetric] (*‹{?a..?b} = cbox ?a ?b›*) closed_cbox (*‹closed (cbox ?a ?b)›*)) lemma closed_eucl_atMost[simp, intro]: fixes a :: "'a::ordered_euclidean_space" shows "closed {..a}" by (simp add: closed_interval_left (*‹closed {x. ∀i∈Basis. x ∙ i ≤ ?b ∙ i}›*) eucl_le_atMost[symmetric] (*‹{..?a} = {x. ∀i∈Basis. x ∙ i ≤ ?a ∙ i}›*)) lemma closed_eucl_atLeast[simp, intro]: fixes a :: "'a::ordered_euclidean_space" shows "closed {a..}" by (simp add: closed_interval_right (*‹closed {x. ∀i∈Basis. ?a ∙ i ≤ x ∙ i}›*) eucl_le_atLeast[symmetric] (*‹{?a..} = {x. ∀i∈Basis. ?a ∙ i ≤ x ∙ i}›*)) lemma bounded_closed_interval [simp]: fixes a :: "'a::ordered_euclidean_space" shows "bounded {a .. b}" using bounded_cbox[of a b] (*‹bounded (cbox a b)›*) by (metis interval_cbox (*‹{?a..?b} = cbox ?a ?b›*)) lemma convex_closed_interval [simp]: fixes a :: "'a::ordered_euclidean_space" shows "convex {a .. b}" using convex_box[of a b] (*‹convex (cbox a b)› ‹convex (box a b)›*) by (metis interval_cbox (*‹{?a..?b} = cbox ?a ?b›*)) lemma image_smult_interval:"(λx. m *⇩R (x::_::ordered_euclidean_space)) ` {a .. b} = (if {a .. b} = {} then {} else if 0 ≤ m then {m *⇩R a .. m *⇩R b} else {m *⇩R b .. m *⇩R a})" using image_smult_cbox[of m a b] (*‹(*⇩R) m ` cbox a b = (if cbox a b = {} then {} else if 0 ≤ m then cbox (m *⇩R a) (m *⇩R b) else cbox (m *⇩R b) (m *⇩R a))›*) by (simp add: cbox_interval (*‹cbox (?a::?'a) (?b::?'a) = {?a..?b}›*)) lemma [simp]: fixes a b::"'a::ordered_euclidean_space" shows is_interval_ic: "is_interval {..a}" and is_interval_ci: "is_interval {a..}" and is_interval_cc: "is_interval {b..a}" (*goals: 1. ‹is_interval {..a}› 2. ‹is_interval {a..}› 3. ‹is_interval {b..a}› discuss goal 1*) apply (force simp: is_interval_def (*‹is_interval ?s = (∀a∈?s. ∀b∈?s. ∀x. (∀i∈Basis. a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ b ∙ i ∨ b ∙ i ≤ x ∙ i ∧ x ∙ i ≤ a ∙ i) ⟶ x ∈ ?s)›*) eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*)) (*discuss goal 2*) apply (force simp: is_interval_def (*‹is_interval ?s = (∀a∈?s. ∀b∈?s. ∀x. (∀i∈Basis. a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ b ∙ i ∨ b ∙ i ≤ x ∙ i ∧ x ∙ i ≤ a ∙ i) ⟶ x ∈ ?s)›*) eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*)) (*discuss goal 3*) apply (force simp: is_interval_def (*‹is_interval ?s = (∀a∈?s. ∀b∈?s. ∀x. (∀i∈Basis. a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ b ∙ i ∨ b ∙ i ≤ x ∙ i ∧ x ∙ i ≤ a ∙ i) ⟶ x ∈ ?s)›*) eucl_le[where 'a='a] (*‹(?x ≤ ?y) = (∀i∈Basis. ?x ∙ i ≤ ?y ∙ i)›*)) (*proven 3 subgoals*) . lemma connected_interval [simp]: fixes a b::"'a::ordered_euclidean_space" shows "connected {a..b}" using is_interval_cc (*‹is_interval {?b::?'a::ordered_euclidean_space..?a::?'a::ordered_euclidean_space}›*) is_interval_connected (*‹is_interval ?S ⟹ connected ?S›*) by blast lemma compact_interval [simp]: fixes a b::"'a::ordered_euclidean_space" shows "compact {a .. b}" by (metis compact_cbox (*‹compact (cbox ?a ?b)›*) interval_cbox (*‹{?a..?b} = cbox ?a ?b›*)) no_notation eucl_less (infix "<e" 50) lemma One_nonneg: "0 ≤ (∑Basis::'a::ordered_euclidean_space)" by (auto intro: sum_nonneg (*‹(⋀x. x ∈ ?A ⟹ 0 ≤ ?f x) ⟹ 0 ≤ sum ?f ?A›*)) lemma fixes a b::"'a::ordered_euclidean_space" shows bdd_above_cbox[intro, simp]: "bdd_above (cbox a b)" and bdd_below_cbox[intro, simp]: "bdd_below (cbox a b)" and bdd_above_box[intro, simp]: "bdd_above (box a b)" and bdd_below_box[intro, simp]: "bdd_below (box a b)" unfolding atomize_conj (*goal: ‹(bdd_above (cbox a b) ∧ bdd_below (cbox a b)) ∧ bdd_above (box a b) ∧ bdd_below (box a b)›*) by (metis bdd_above_Icc (*‹bdd_above {?a..?b}›*) bdd_above_mono (*‹⟦bdd_above ?B; ?A ⊆ ?B⟧ ⟹ bdd_above ?A›*) bdd_below_Icc (*‹bdd_below {?a..?b}›*) bdd_below_mono (*‹⟦bdd_below ?B; ?A ⊆ ?B⟧ ⟹ bdd_below ?A›*) bounded_box (*‹bounded (box ?a ?b)›*) bounded_subset_cbox_symmetric (*‹⟦bounded ?S; ⋀a. ?S ⊆ cbox (- a) a ⟹ ?thesis⟧ ⟹ ?thesis›*) interval_cbox (*‹{?a..?b} = cbox ?a ?b›*)) instantiation vec :: (ordered_euclidean_space, finite) ordered_euclidean_space begin definition✐‹tag important› "inf x y = (χ i. inf (x $ i) (y $ i))" definition✐‹tag important› "sup x y = (χ i. sup (x $ i) (y $ i))" definition✐‹tag important› "Inf X = (χ i. (INF x∈X. x $ i))" definition✐‹tag important› "Sup X = (χ i. (SUP x∈X. x $ i))" definition✐‹tag important› "¦x¦ = (χ i. ¦x $ i¦)" instance apply standard unfolding euclidean_representation_sum' apply (auto simp: less_eq_vec_def inf_vec_def sup_vec_def Inf_vec_def Sup_vec_def inner_axis Basis_vec_def inner_Basis_inf_left inner_Basis_sup_left inner_Basis_INF_left inner_Basis_SUP_left eucl_le[where 'a='a] less_le_not_le abs_vec_def abs_inner) done end end
{ "path": "Isabelle2024/src/HOL/Analysis/Ordered_Euclidean_Space.thy", "repo": "Isabelle2024", "sha": "ca609472e56406b7a14c4553e2c23c2368ed6cb12888de7909e79638572ec2a7" }
theory Compress imports Kyber_spec Mod_Plus_Minus Abs_Qr "HOL-Analysis.Finite_Cartesian_Product" begin lemma prime_half: assumes "prime (p::int)" "p > 2" shows "⌈p / 2⌉ > ⌊p / 2⌋" proof (-) (*goal: ‹⌊real_of_int p / 2⌋ < ⌈real_of_int p / 2⌉›*) have "odd p" using prime_odd_int[OF assms] (*‹odd p›*) . then have "⌈p / 2⌉ > p/2" by (smt (verit, best) cos_npi_int (*‹cos (pi * real_of_int ?n) = (if even ?n then 1 else - 1)›*) cos_zero_iff_int (*‹(cos ?x = 0) = (∃i. odd i ∧ ?x = real_of_int i * (pi / 2))›*) le_of_int_ceiling (*‹?x ≤ of_int ⌈?x⌉›*) mult.commute (*‹?a * ?b = ?b * ?a›*) times_divide_eq_right (*‹?a * (?b / ?c) = ?a * ?b / ?c›*)) then have "⌊p / 2⌋ < p/2" by (meson floor_less_iff (*‹(⌊?x::?'a::floor_ceiling⌋ < (?z::int)) = (?x < of_int ?z)›*) less_ceiling_iff (*‹((?z::int) < ⌈?x::?'a::floor_ceiling⌉) = (of_int ?z < ?x)›*)) then show "?thesis" (*goal: ‹⌊real_of_int p / 2⌋ < ⌈real_of_int p / 2⌉›*) using ‹⌈p / 2⌉ > p/2› (*‹real_of_int p / 2 < real_of_int ⌈real_of_int p / 2⌉›*) by auto qed lemma ceiling_int: "⌈of_int a + b⌉ = a + ⌈b⌉" unfolding ceiling_def (*goal: ‹- ⌊- (of_int (a::int) + (b::'a))⌋ = a + - ⌊- b⌋›*) by (simp add: add.commute (*‹?a + ?b = ?b + ?a›*)) lemma deg_Poly': assumes "Poly xs ≠ 0" shows "degree (Poly xs) ≤ length xs - 1" proof (induct xs) (*goals: 1. ‹degree (Poly []) ≤ length [] - 1› 2. ‹⋀a xs. degree (Poly xs) ≤ length xs - 1 ⟹ degree (Poly (a # xs)) ≤ length (a # xs) - 1›*) case (Cons a xs) (*‹degree (Poly xs) ≤ length xs - 1›*) then show "?case" (*goal: ‹degree (Poly (a # xs)) ≤ length (a # xs) - 1›*) apply simp (*goal: ‹degree (Poly (a # xs)) ≤ length (a # xs) - 1›*) by (metis Poly.simps( (*‹Poly [] = 0›*) 1) Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*) Suc_pred (*‹0 < ?n ⟹ Suc (?n - Suc 0) = ?n›*) le_imp_less_Suc (*‹?m ≤ ?n ⟹ ?m < Suc ?n›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*)) qed (simp) (*solved the remaining goal: ‹degree (Poly []) ≤ length [] - 1›*) context kyber_spec begin section ‹Compress and Decompress Functions› text ‹Properties of the ‹mod+-› function.› lemma two_mid_lt_q: "2 * ⌊real_of_int q/2⌋ < q" using oddE[OF prime_odd_int [ OF q_prime q_gt_two ]] (*‹(⋀b. q = 2 * b + 1 ⟹ ?thesis) ⟹ ?thesis›*) by fastforce lemma mod_plus_minus_range_q: assumes "y ∈ {-⌊q/2⌋..⌊q/2⌋}" shows "y mod+- q = y" using assms (*‹y ∈ {- ⌊real_of_int q / 2⌋..⌊real_of_int q / 2⌋}›*) mod_plus_minus_rangeE (*‹⟦?y ∈ {- ⌊real_of_int ?b / 2⌋..⌊real_of_int ?b / 2⌋}; odd ?b; 0 < ?b⟧ ⟹ ?y = ?y mod+- ?b›*) q_gt_zero (*‹0 < q›*) q_odd (*‹odd q›*) by presburger text ‹Compression only works for $x \in \mathbb{Z}_q$ and outputs an integer in $\{0,\dots, 2^d-1\}$ , where $d$ is a positive integer with $d < \rceil\log_2 (q)\lceil$. For compression we omit the least important bits. Decompression rescales to the modulus q.› definition compress :: "nat ⇒ int ⇒ int" where "compress d x = round (real_of_int (2^d * x) / real_of_int q) mod (2^d)" definition decompress :: "nat ⇒ int ⇒ int" where "decompress d x = round (real_of_int q * real_of_int x / real_of_int 2^d)" lemma compress_zero: "compress d 0 = 0" unfolding compress_def (*goal: ‹round (real_of_int (2 ^ d * 0) / real_of_int q) mod 2 ^ d = 0›*) by auto lemma compress_less: ‹compress d x < 2 ^ d› by (simp add: compress_def (*‹compress ?d ?x = round (real_of_int (2 ^ ?d * ?x) / real_of_int q) mod 2 ^ ?d›*)) lemma decompress_zero: "decompress d 0 = 0" unfolding decompress_def (*goal: ‹round (real_of_int (q::int) * real_of_int (0::int) / real_of_int (2::int) ^ (d::nat)) = (0::int)›*) by auto text ‹Properties of the exponent $d$.› lemma d_lt_logq: assumes "of_nat d < ⌈(log 2 q)::real⌉" shows "d< log 2 q" using assms (*‹int d < ⌈log 2 (real_of_int q)⌉›*) by linarith lemma twod_lt_q: assumes "of_nat d < ⌈(log 2 q)::real⌉" shows "2 powr (real d) < of_int q" using assms (*‹int d < ⌈log 2 (real_of_int q)⌉›*) less_log_iff[of 2 q d] (*‹⟦1 < 2; 0 < real_of_int q⟧ ⟹ (real d < log 2 (real_of_int q)) = (2 powr real d < real_of_int q)›*) d_lt_logq (*‹int ?d < ⌈log 2 (real_of_int q)⌉ ⟹ real ?d < log 2 (real_of_int q)›*) q_gt_zero (*‹0 < q›*) by auto lemma break_point_gt_q_div_two: assumes "of_nat d < ⌈(log 2 q)::real⌉" shows "⌈q-(q/(2*2^d))⌉ > ⌊q/2⌋" proof (-) (*goal: ‹⌊real_of_int q / 2⌋ < ⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉›*) have "1/((2::real)^d) ≤ (1::real)" using one_le_power[of 2 d] (*‹(1::?'b1) ≤ (2::?'b1) ⟹ (1::?'b1) ≤ (2::?'b1) ^ (d::nat)›*) by simp have "⌈q-(q/(2*2^d))⌉ ≥ q-(q/2)* (1/(2^d))" by simp moreover have "q-(q/2)* (1/(2^d)) ≥ q - q/2" using ‹1/((2::real)^d) ≤ (1::real)› (*‹(1::real) / (2::real) ^ (d::nat) ≤ (1::real)›*) by (smt (z3) calculation (*‹real_of_int q - real_of_int q / 2 * (1 / 2 ^ d) ≤ real_of_int ⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉›*) divide_le_eq (*‹(?b / ?c ≤ ?a) = (if 0 < ?c then ?b ≤ ?a * ?c else if ?c < 0 then ?a * ?c ≤ ?b else 0 ≤ ?a)›*) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) divide_self_if (*‹?a / ?a = (if ?a = 0 then 0 else 1)›*) mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) of_int_nonneg (*‹0 ≤ ?z ⟹ 0 ≤ of_int ?z›*) times_divide_eq_right (*‹?a * (?b / ?c) = ?a * ?b / ?c›*) q_gt_zero (*‹0 < q›*)) ultimately have "⌈q-(q/(2*2^d))⌉ ≥ ⌈q/2⌉ " by linarith moreover have "⌈q/2⌉ > ⌊q/2⌋" using prime_half[OF q_prime q_gt_two] (*‹⌊real_of_int q / 2⌋ < ⌈real_of_int q / 2⌉›*) . ultimately show "?thesis" (*goal: ‹⌊real_of_int (q::int) / (2::real)⌋ < ⌈real_of_int q - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉›*) by auto qed lemma decompress_zero_unique: assumes "decompress d s = 0" "s ∈ {0..2^d - 1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "s = 0" proof (-) (*goal: ‹s = 0›*) let ?x = "real_of_int q * real_of_int s / real_of_int 2^d + 1/2" have "0 ≤ ?x ∧ ?x < 1" using assms(1) (*‹decompress d s = 0›*) unfolding decompress_def round_def (*goal: ‹0 ≤ real_of_int q * real_of_int s / real_of_int 2 ^ d + 1 / 2 ∧ real_of_int q * real_of_int s / real_of_int 2 ^ d + 1 / 2 < 1›*) using floor_correct[of ?x] (*‹real_of_int ⌊real_of_int q * real_of_int s / real_of_int 2 ^ d + 1 / 2⌋ ≤ real_of_int q * real_of_int s / real_of_int 2 ^ d + 1 / 2 ∧ real_of_int q * real_of_int s / real_of_int 2 ^ d + 1 / 2 < real_of_int (⌊real_of_int q * real_of_int s / real_of_int 2 ^ d + 1 / 2⌋ + 1)›*) by auto then have "real_of_int q * real_of_int s / real_of_int 2^d < 1/2" by linarith moreover have "real_of_int q / real_of_int 2^d > 1" using twod_lt_q[OF assms ( 3 )] (*‹2 powr real d < real_of_int q›*) by (simp add: powr_realpow (*‹0 < ?x ⟹ ?x powr real ?n = ?x ^ ?n›*)) ultimately have "real_of_int s < 1/2" by (smt (verit, best) divide_less_eq_1_pos (*‹0 < ?a ⟹ (?b / ?a < 1) = (?b < ?a)›*) field_sum_of_halves (*‹?x / 2 + ?x / 2 = ?x›*) pos_divide_less_eq (*‹0 < ?c ⟹ (?b / ?c < ?a) = (?b < ?a * ?c)›*) times_divide_eq_left (*‹?b / ?c * ?a = ?b * ?a / ?c›*)) then show "?thesis" (*goal: ‹s = 0›*) using assms(2) (*‹s ∈ {0..2 ^ d - 1}›*) by auto qed text ‹Range of compress and decompress functions› lemma range_compress: assumes "x∈{0..q-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "compress d x ∈ {0..2^d - 1}" using compress_def (*‹compress ?d ?x = round (real_of_int (2 ^ ?d * ?x) / real_of_int q) mod 2 ^ ?d›*) by auto lemma range_decompress: assumes "x∈{0..2^d - 1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "decompress d x ∈ {0..q-1}" using decompress_def (*‹decompress (?d::nat) (?x::int) = round (real_of_int (q::int) * real_of_int ?x / real_of_int (2::int) ^ ?d)›*) assms (*‹(x::int) ∈ {0::int..(2::int) ^ (d::nat) - (1::int)}› ‹int d < ⌈log 2 (real_of_int q)⌉›*) proof (auto, goal_cases) (*goals: 1. ‹⟦⋀d x. decompress d x = round (real_of_int q * real_of_int x / 2 ^ d); int d < ⌈log 2 (real_of_int q)⌉; 0 ≤ x; x < 2 ^ d⟧ ⟹ 0 ≤ round (real_of_int q * real_of_int x / 2 ^ d)› 2. ‹⟦⋀d x. decompress d x = round (real_of_int q * real_of_int x / 2 ^ d); int d < ⌈log 2 (real_of_int q)⌉; 0 ≤ x; x < 2 ^ d⟧ ⟹ round (real_of_int q * real_of_int x / 2 ^ d) < q›*) case 1 (*‹decompress ?d ?x = round (real_of_int q * real_of_int ?x / 2 ^ ?d)› ‹int d < ⌈log 2 (real_of_int q)⌉› ‹0 ≤ x› ‹x < 2 ^ d›*) then show "?case" (*goal: ‹0 ≤ round (real_of_int q * real_of_int x / 2 ^ d)›*) by (smt (verit, best) divide_eq_0_iff (*‹((?a::?'a) / (?b::?'a) = (0::?'a)) = (?a = (0::?'a) ∨ ?b = (0::?'a))›*) divide_numeral_1 (*‹(?a::?'a) / Numeral1 = ?a›*) less_divide_eq_1_pos (*‹(0::?'a) < (?a::?'a) ⟹ ((1::?'a) < (?b::?'a) / ?a) = (?a < ?b)›*) mult_of_int_commute (*‹of_int (?x::int) * (?y::?'a) = ?y * of_int ?x›*) nonzero_mult_div_cancel_right (*‹(?b::?'a) ≠ (0::?'a) ⟹ (?a::?'a) * ?b div ?b = ?a›*) of_int_eq_0_iff (*‹(of_int (?z::int) = (0::?'a)) = (?z = (0::int))›*) of_int_less_1_iff (*‹(of_int (?z::int) < (1::?'a)) = (?z < (1::int))›*) powr_realpow (*‹(0::real) < (?x::real) ⟹ ?x powr real (?n::nat) = ?x ^ ?n›*) q_gt_zero (*‹(0::int) < (q::int)›*) q_nonzero (*‹(q::int) ≠ (0::int)›*) round_0 (*‹round (0::?'a) = (0::int)›*) round_mono (*‹(?x::?'a) ≤ (?y::?'a) ⟹ round ?x ≤ round ?y›*) twod_lt_q (*‹int (?d::nat) < ⌈log (2::real) (real_of_int (q::int))⌉ ⟹ (2::real) powr real ?d < real_of_int q›*) zero_less_power (*‹(0::?'a) < (?a::?'a) ⟹ (0::?'a) < ?a ^ (?n::nat)›*)) next (*goal: ‹⟦⋀d x. decompress d x = round (real_of_int q * real_of_int x / 2 ^ d); int d < ⌈log 2 (real_of_int q)⌉; 0 ≤ x; x < 2 ^ d⟧ ⟹ round (real_of_int q * real_of_int x / 2 ^ d) < q›*) case 2 (*‹decompress ?d ?x = round (real_of_int q * real_of_int ?x / 2 ^ ?d)› ‹int d < ⌈log 2 (real_of_int q)⌉› ‹0 ≤ x› ‹x < 2 ^ d›*) have "real_of_int q/2^d > 1" using twod_lt_q[OF assms ( 2 )] (*‹2 powr real d < real_of_int q›*) by (simp add: powr_realpow (*‹0 < ?x ⟹ ?x powr real ?n = ?x ^ ?n›*)) then have log: "real_of_int q - real_of_int q/2^d ≤ q-1" by simp have "x ≤ 2^d-1" using assms(1) (*‹x ∈ {0..2 ^ d - 1}›*) by simp then have "real_of_int x ≤ 2^d - 1" by (simp add: int_less_real_le (*‹(?n < ?m) = (real_of_int ?n + 1 ≤ real_of_int ?m)›*)) then have "real_of_int q * real_of_int x / 2^d ≤ real_of_int q * (2^d-1) / 2^d" by (smt (verit, best) divide_strict_right_mono (*‹⟦?a < ?b; 0 < ?c⟧ ⟹ ?a / ?c < ?b / ?c›*) mult_less_cancel_left_pos (*‹0 < ?c ⟹ (?c * ?a < ?c * ?b) = (?a < ?b)›*) of_int_pos (*‹0 < ?z ⟹ 0 < of_int ?z›*) q_gt_zero (*‹0 < q›*) zero_less_power (*‹0 < ?a ⟹ 0 < ?a ^ ?n›*)) also (*calculation: ‹real_of_int q * real_of_int x / 2 ^ d ≤ real_of_int q * (2 ^ d - 1) / 2 ^ d›*) have "… = real_of_int q * 2^d /2^d - real_of_int q/2^d" by (simp add: diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*) right_diff_distrib (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) finally (*calculation: ‹real_of_int q * real_of_int x / 2 ^ d ≤ real_of_int q * 2 ^ d / 2 ^ d - real_of_int q / 2 ^ d›*) have "real_of_int q * real_of_int x / 2^d ≤ real_of_int q - real_of_int q/2^d" by simp then have "round (real_of_int q * real_of_int x / 2^d) ≤ round (real_of_int q - real_of_int q/2^d)" using round_mono (*‹?x ≤ ?y ⟹ round ?x ≤ round ?y›*) by blast also (*calculation: ‹round (real_of_int q * real_of_int x / 2 ^ d) ≤ round (real_of_int q - real_of_int q / 2 ^ d)›*) have "… ≤ q - 1" using log (*‹real_of_int (q::int) - real_of_int q / (2::real) ^ (d::nat) ≤ real_of_int (q - (1::int))›*) by (metis round_mono (*‹?x ≤ ?y ⟹ round ?x ≤ round ?y›*) round_of_int (*‹round (of_int ?n) = ?n›*)) finally (*calculation: ‹round (real_of_int q * real_of_int x / 2 ^ d) ≤ q - 1›*) show "?case" (*goal: ‹round (real_of_int (q::int) * real_of_int (x::int) / (2::real) ^ (d::nat)) < q›*) by auto qed text ‹Compression is a function qrom $\mathbb{Z} / q\mathbb{Z}$ to $\mathbb{Z} / (2^d)\mathbb{Z}$.› lemma compress_in_range: assumes "x∈{0..⌈q-(q/(2*2^d))⌉-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "round (real_of_int (2^d * x) / real_of_int q) < 2^d " proof (-) (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) < 2 ^ d›*) have "(2::int)^d ≠ 0" by simp have "real_of_int x < real_of_int q - real_of_int q / (2 * 2^d)" using assms(1) (*‹x ∈ {0..⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉ - 1}›*) less_ceiling_iff (*‹(?z < ⌈?x⌉) = (of_int ?z < ?x)›*) by auto then have "2^d * real_of_int x / real_of_int q < 2^d * (real_of_int q - real_of_int q / (2 * 2^d)) / real_of_int q" by (simp add: divide_strict_right_mono (*‹⟦?a < ?b; 0 < ?c⟧ ⟹ ?a / ?c < ?b / ?c›*) q_gt_zero (*‹0 < q›*)) also (*calculation: ‹2 ^ d * real_of_int x / real_of_int q < 2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q›*) have "… = 2^d * ((real_of_int q / real_of_int q) - (real_of_int q / real_of_int q) / (2 * 2^d))" by (simp add:algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 33 facts*) diff_divide_distrib (*‹((?a::?'a) - (?b::?'a)) / (?c::?'a) = ?a / ?c - ?b / ?c›*)) also (*calculation: ‹2 ^ d * real_of_int x / real_of_int q < 2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d))›*) have "… = 2^d * (1 - 1/(2*2^d))" using q_nonzero (*‹q ≠ 0›*) by simp also (*calculation: ‹(2::real) ^ (d::nat) * real_of_int (x::int) / real_of_int (q::int) < (2::real) ^ d * ((1::real) - (1::real) / ((2::real) * (2::real) ^ d))›*) have "… = 2^d - 1/2" using ‹2^d ≠ 0› (*‹2 ^ d ≠ 0›*) by (simp add: right_diff_distrib' (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) finally (*calculation: ‹2 ^ d * real_of_int x / real_of_int q < 2 ^ d - 1 / 2›*) have "2^d * real_of_int x / real_of_int q < 2^d - (1::real)/(2::real)" by auto then show "?thesis" (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) < 2 ^ d›*) unfolding round_def (*goal: ‹⌊real_of_int (2 ^ d * x) / real_of_int q + 1 / 2⌋ < 2 ^ d›*) using floor_less_iff (*‹(⌊?x⌋ < ?z) = (?x < of_int ?z)›*) by fastforce qed text ‹When does the modulo operation in the compression function change the output? Only when ‹x ≥ ⌈q-(q / (2*2^d))⌉›. Then we can determine that the compress function maps to zero. This is why we need the ‹mod+-› in the definition of Compression. Otherwise the error bound would not hold.› lemma compress_no_mod: assumes "x∈{0..⌈q-(q / (2*2^d))⌉-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "compress d x = round (real_of_int (2^d * x) / real_of_int q)" unfolding compress_def (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) mod 2 ^ d = round (real_of_int (2 ^ d * x) / real_of_int q)›*) using compress_in_range[OF assms] (*‹round (real_of_int (2 ^ d * x) / real_of_int q) < 2 ^ d›*) assms(1) (*‹x ∈ {0..⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉ - 1}›*) q_gt_zero (*‹(0::int) < (q::int)›*) by (smt (z3) atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) mod_pos_pos_trivial (*‹⟦0 ≤ ?k; ?k < ?l⟧ ⟹ ?k mod ?l = ?k›*) mult_less_cancel_left_pos (*‹0 < ?c ⟹ (?c * ?a < ?c * ?b) = (?a < ?b)›*) of_int_nonneg (*‹0 ≤ ?z ⟹ 0 ≤ of_int ?z›*) of_nat_0_less_iff (*‹(0 < of_nat ?n) = (0 < ?n)›*) right_diff_distrib' (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) round_0 (*‹round 0 = 0›*) round_mono (*‹?x ≤ ?y ⟹ round ?x ≤ round ?y›*) zero_less_power (*‹0 < ?a ⟹ 0 < ?a ^ ?n›*)) lemma compress_2d: assumes "x∈{⌈q-(q/(2*2^d))⌉..q-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "round (real_of_int (2^d * x) / real_of_int q) = 2^d " using assms (*‹x ∈ {⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉..q - 1}› ‹int d < ⌈log 2 (real_of_int q)⌉›*) proof (-) (*goal: ‹⟦(x::int) ∈ {⌈real_of_int (q::int) - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉..q - (1::int)}; int d < ⌈log (2::real) (real_of_int q)⌉⟧ ⟹ round (real_of_int ((2::int) ^ d * x) / real_of_int q) = (2::int) ^ d›*) have "(2::int)^d ≠ 0" by simp have "round (real_of_int (2^d * x) / real_of_int q) ≥ 2^d" proof (-) (*goal: ‹(2::int) ^ (d::nat) ≤ round (real_of_int ((2::int) ^ d * (x::int)) / real_of_int (q::int))›*) have "real_of_int x ≥ real_of_int q - real_of_int q / (2 * 2^d)" using assms(1) (*‹(x::int) ∈ {⌈real_of_int (q::int) - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉..q - (1::int)}›*) ceiling_le_iff (*‹(⌈?x⌉ ≤ ?z) = (?x ≤ of_int ?z)›*) by auto then have "2^d * real_of_int x / real_of_int q ≥ 2^d * (real_of_int q - real_of_int q / (2 * 2^d)) / real_of_int q" using q_gt_zero (*‹0 < q›*) by (simp add: divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*)) also (*calculation: ‹2 ^ d * (real_of_int q - real_of_int q / (2 * 2 ^ d)) / real_of_int q ≤ 2 ^ d * real_of_int x / real_of_int q›*) have "2^d * (real_of_int q - real_of_int q / (2 * 2^d)) / real_of_int q = 2^d * ((real_of_int q / real_of_int q) - (real_of_int q / real_of_int q) / (2 * 2^d))" by (simp add:algebra_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 33 facts*) diff_divide_distrib (*‹((?a::?'a::division_ring) - (?b::?'a::division_ring)) / (?c::?'a::division_ring) = ?a / ?c - ?b / ?c›*)) also (*calculation: ‹2 ^ d * (real_of_int q / real_of_int q - real_of_int q / real_of_int q / (2 * 2 ^ d)) ≤ 2 ^ d * real_of_int x / real_of_int q›*) have "… = 2^d * (1 - 1/(2*2^d))" using q_nonzero (*‹q ≠ 0›*) by simp also (*calculation: ‹2 ^ d * (1 - 1 / (2 * 2 ^ d)) ≤ 2 ^ d * real_of_int x / real_of_int q›*) have "… = 2^d - 1/2" using ‹2^d ≠ 0› (*‹2 ^ d ≠ 0›*) by (simp add: right_diff_distrib' (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*)) finally (*calculation: ‹2 ^ d - 1 / 2 ≤ 2 ^ d * real_of_int x / real_of_int q›*) have "2^d * real_of_int x / real_of_int q ≥ 2^d - (1::real)/(2::real)" by auto then show "?thesis" (*goal: ‹2 ^ d ≤ round (real_of_int (2 ^ d * x) / real_of_int q)›*) unfolding round_def (*goal: ‹2 ^ d ≤ ⌊real_of_int (2 ^ d * x) / real_of_int q + 1 / 2⌋›*) using le_floor_iff (*‹(?z ≤ ⌊?x⌋) = (of_int ?z ≤ ?x)›*) by force qed moreover have "round (real_of_int (2^d * x) / real_of_int q) ≤ 2^d" proof (-) (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) ≤ 2 ^ d›*) have "d < log 2 q" using assms(2) (*‹int d < ⌈log 2 (real_of_int q)⌉›*) by linarith then have "2 powr (real d) < of_int q" using less_log_iff[of 2 q d] (*‹⟦(1::real) < (2::real); (0::real) < real_of_int (q::int)⟧ ⟹ (real (d::nat) < log (2::real) (real_of_int q)) = ((2::real) powr real d < real_of_int q)›*) q_gt_zero (*‹0 < q›*) by auto have "x < q" using assms(1) (*‹x ∈ {⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉..q - 1}›*) by auto then have "real_of_int x/ real_of_int q < 1" by (simp add: q_gt_zero (*‹(0::int) < (q::int)›*)) then have "real_of_int (2^d * x) / real_of_int q < real_of_int (2^d)" apply auto (*goal: ‹real_of_int (2 ^ d * x) / real_of_int q < real_of_int (2 ^ d)›*) by (smt (verit, best) divide_less_eq_1_pos (*‹0 < ?a ⟹ (?b / ?a < 1) = (?b < ?a)›*) nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b div ?a = ?b›*) times_divide_eq_right (*‹?a * (?b / ?c) = ?a * ?b / ?c›*) zero_less_power (*‹0 < ?a ⟹ 0 < ?a ^ ?n›*)) then show "?thesis" (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) ≤ 2 ^ d›*) unfolding round_def (*goal: ‹⌊real_of_int (2 ^ d * x) / real_of_int q + 1 / 2⌋ ≤ 2 ^ d›*) by linarith qed ultimately show "?thesis" (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d›*) by auto qed lemma compress_mod: assumes "x∈{⌈q-(q/(2*2^d))⌉..q-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "compress d x = 0" unfolding compress_def (*goal: ‹round (real_of_int (2 ^ d * x) / real_of_int q) mod 2 ^ d = 0›*) using compress_2d[OF assms] (*‹round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d›*) by simp text ‹Error after compression and decompression of data. To prove the error bound, we distinguish the cases where the ‹mod+-› is relevant or not.› text ‹First let us look at the error bound for no ‹mod+-› reduction.› lemma decompress_compress_no_mod: assumes "x∈{0..⌈q-(q/(2*2^d))⌉-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "abs (decompress d (compress d x) - x) ≤ round ( real_of_int q / real_of_int (2^(d+1)))" proof (-) (*goal: ‹¦decompress (d::nat) (compress d (x::int)) - x¦ ≤ round (real_of_int (q::int) / real_of_int ((2::int) ^ (d + (1::nat))))›*) have "abs (decompress d (compress d x) - x) = abs (real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2^d) * (real_of_int (2^d * x) / real_of_int q))" using q_gt_zero (*‹0 < q›*) by force also (*calculation: ‹real_of_int ¦decompress d (compress d x) - x¦ = ¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * (real_of_int (2 ^ d * x) / real_of_int q)¦›*) have "… ≤ abs (real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2^d) * real_of_int (compress d x)) + abs (real_of_int q / real_of_int (2^d) * real_of_int (compress d x) - real_of_int q / real_of_int (2^d) * real_of_int (2^d) / real_of_int q * x)" using abs_triangle_ineq[of "real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2^d) * real_of_int (compress d x)" "real_of_int q / real_of_int (2^d) * real_of_int (compress d x) - real_of_int q / real_of_int (2^d) * real_of_int (2^d) / real_of_int q * real_of_int x"] (*‹¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x) + (real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x) - real_of_int q / real_of_int (2 ^ d) * real_of_int (2 ^ d) / real_of_int q * real_of_int x)¦ ≤ ¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x)¦ + ¦real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x) - real_of_int q / real_of_int (2 ^ d) * real_of_int (2 ^ d) / real_of_int q * real_of_int x¦›*) by auto also (*calculation: ‹real_of_int ¦decompress d (compress d x) - x¦ ≤ ¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x)¦ + ¦real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x) - real_of_int q / real_of_int (2 ^ d) * real_of_int (2 ^ d) / real_of_int q * real_of_int x¦›*) have "… ≤ 1/2 + abs (real_of_int q / real_of_int (2^d) * (real_of_int (compress d x) - real_of_int (2^d) / real_of_int q * real_of_int x))" proof (-) (*goal: ‹¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x)¦ + ¦real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x) - real_of_int q / real_of_int (2 ^ d) * real_of_int (2 ^ d) / real_of_int q * real_of_int x¦ ≤ 1 / 2 + ¦real_of_int q / real_of_int (2 ^ d) * (real_of_int (compress d x) - real_of_int (2 ^ d) / real_of_int q * real_of_int x)¦›*) have part_one: "abs (real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2^d) * real_of_int (compress d x)) ≤ 1/2" unfolding decompress_def (*goal: ‹¦real_of_int (round (real_of_int q * real_of_int (compress d x) / real_of_int 2 ^ d)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x)¦ ≤ 1 / 2›*) using of_int_round_abs_le[of "real_of_int q * real_of_int (compress d x) / real_of_int 2^d"] (*‹¦real_of_int (round (real_of_int q * real_of_int (compress d x) / real_of_int 2 ^ d)) - real_of_int q * real_of_int (compress d x) / real_of_int 2 ^ d¦ ≤ 1 / 2›*) by simp have "real_of_int q * real_of_int (compress d x) / 2^d - real_of_int x = real_of_int q * (real_of_int (compress d x) - 2^d * real_of_int x / real_of_int q) / 2^d" by (smt (verit, best) divide_cancel_right (*‹(?a / ?c = ?b / ?c) = (?c = 0 ∨ ?a = ?b)›*) nonzero_mult_div_cancel_left (*‹?a ≠ 0 ⟹ ?a * ?b div ?a = ?b›*) of_int_eq_0_iff (*‹(of_int ?z = 0) = (?z = 0)›*) q_nonzero (*‹q ≠ 0›*) right_diff_distrib (*‹?a * (?b - ?c) = ?a * ?b - ?a * ?c›*) times_divide_eq_left (*‹?b / ?c * ?a = ?b * ?a / ?c›*) zero_less_power (*‹0 < ?a ⟹ 0 < ?a ^ ?n›*)) then have part_two: "abs (real_of_int q / real_of_int (2^d) * real_of_int (compress d x) - real_of_int q / real_of_int (2^d) * real_of_int (2^d) / real_of_int q * x) = abs (real_of_int q / real_of_int (2^d) * (real_of_int (compress d x) - real_of_int (2^d) / real_of_int q * x)) " by auto show "?thesis" (*goal: ‹¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x)¦ + ¦real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x) - real_of_int q / real_of_int (2 ^ d) * real_of_int (2 ^ d) / real_of_int q * real_of_int x¦ ≤ 1 / 2 + ¦real_of_int q / real_of_int (2 ^ d) * (real_of_int (compress d x) - real_of_int (2 ^ d) / real_of_int q * real_of_int x)¦›*) using part_one (*‹¦real_of_int (decompress d (compress d x)) - real_of_int q / real_of_int (2 ^ d) * real_of_int (compress d x)¦ ≤ 1 / 2›*) part_two (*‹¦real_of_int (q::int) / real_of_int ((2::int) ^ (d::nat)) * real_of_int (compress d (x::int)) - real_of_int q / real_of_int ((2::int) ^ d) * real_of_int ((2::int) ^ d) / real_of_int q * real_of_int x¦ = ¦real_of_int q / real_of_int ((2::int) ^ d) * (real_of_int (compress d x) - real_of_int ((2::int) ^ d) / real_of_int q * real_of_int x)¦›*) by auto qed also (*calculation: ‹real_of_int ¦decompress d (compress d x) - x¦ ≤ 1 / 2 + ¦real_of_int q / real_of_int (2 ^ d) * (real_of_int (compress d x) - real_of_int (2 ^ d) / real_of_int q * real_of_int x)¦›*) have "… = 1/2 + (real_of_int q / real_of_int (2^d)) * abs (real_of_int (compress d x) - real_of_int (2^d) / real_of_int q * real_of_int x)" apply (subst abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*)) (*goal: ‹1 / 2 + ¦real_of_int q / real_of_int (2 ^ d) * (real_of_int (compress d x) - real_of_int (2 ^ d) / real_of_int q * real_of_int x)¦ = 1 / 2 + real_of_int q / real_of_int (2 ^ d) * ¦real_of_int (compress d x) - real_of_int (2 ^ d) / real_of_int q * real_of_int x¦›*) by (smt (verit, best) assms( (*‹int d < ⌈log 2 (real_of_int q)⌉›*) 2) less_divide_eq_1_pos (*‹0 < ?a ⟹ (1 < ?b / ?a) = (?a < ?b)›*) of_int_add (*‹of_int (?w + ?z) = of_int ?w + of_int ?z›*) of_int_hom.hom_one (*‹of_int 1 = 1›*) of_int_power (*‹of_int (?z ^ ?n) = of_int ?z ^ ?n›*) powr_realpow (*‹0 < ?x ⟹ ?x powr real ?n = ?x ^ ?n›*) twod_lt_q (*‹int ?d < ⌈log 2 (real_of_int q)⌉ ⟹ 2 powr real ?d < real_of_int q›*) zero_less_power (*‹0 < ?a ⟹ 0 < ?a ^ ?n›*)) also (*calculation: ‹real_of_int ¦decompress d (compress d x) - x¦ ≤ 1 / 2 + real_of_int q / real_of_int (2 ^ d) * ¦real_of_int (compress d x) - real_of_int (2 ^ d) / real_of_int q * real_of_int x¦›*) have "… ≤ 1/2 + (real_of_int q / real_of_int (2^d)) * (1/2) " using compress_no_mod[OF assms] (*‹compress d x = round (real_of_int (2 ^ d * x) / real_of_int q)›*) using of_int_round_abs_le[of "real_of_int (2^d) * real_of_int x / real_of_int q"] (*‹¦real_of_int (round (real_of_int ((2::int) ^ (d::nat)) * real_of_int (x::int) / real_of_int (q::int))) - real_of_int ((2::int) ^ d) * real_of_int x / real_of_int q¦ ≤ (1::real) / (2::real)›*) by (smt (verit, ccfv_SIG) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) left_diff_distrib (*‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c›*) mult_less_cancel_left_pos (*‹0 < ?c ⟹ (?c * ?a < ?c * ?b) = (?a < ?b)›*) of_int_mult (*‹of_int (?w * ?z) = of_int ?w * of_int ?z›*) of_int_nonneg (*‹0 ≤ ?z ⟹ 0 ≤ of_int ?z›*) q_gt_zero (*‹0 < q›*) times_divide_eq_left (*‹?b / ?c * ?a = ?b * ?a / ?c›*) zero_le_power (*‹0 ≤ ?a ⟹ 0 ≤ ?a ^ ?n›*)) finally (*calculation: ‹real_of_int ¦decompress d (compress d x) - x¦ ≤ 1 / 2 + real_of_int q / real_of_int (2 ^ d) * (1 / 2)›*) have "real_of_int (abs (decompress d (compress d x) - x)) ≤ real_of_int q / real_of_int (2*2^d) + 1/2" by simp then show "?thesis" (*goal: ‹¦decompress d (compress d x) - x¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) unfolding round_def (*goal: ‹¦decompress d (compress d x) - x¦ ≤ ⌊real_of_int q / real_of_int (2 ^ (d + 1)) + 1 / 2⌋›*) using le_floor_iff (*‹(?z ≤ ⌊?x⌋) = (of_int ?z ≤ ?x)›*) by fastforce qed lemma no_mod_plus_minus: assumes "abs y ≤ round ( real_of_int q / real_of_int (2^(d+1)))" "d>0" shows "abs y = abs (y mod+- q)" proof (-) (*goal: ‹¦y::int¦ = ¦y mod+- (q::int)¦›*) have "round (real_of_int q / real_of_int (2^(d+1))) ≤ ⌊q/2⌋" unfolding round_def (*goal: ‹⌊real_of_int (q::int) / real_of_int ((2::int) ^ ((d::nat) + (1::nat))) + (1::real) / (2::real)⌋ ≤ ⌊real_of_int q / (2::real)⌋›*) proof (-) (*goal: ‹⌊real_of_int q / real_of_int (2 ^ (d + 1)) + 1 / 2⌋ ≤ ⌊real_of_int q / 2⌋›*) have "real_of_int q/real_of_int (2^d) ≤ real_of_int q/2" using ‹d>0› (*‹0 < d›*) proof (-) (*goal: ‹0 < d ⟹ real_of_int q / real_of_int (2 ^ d) ≤ real_of_int q / 2›*) have "1 / real_of_int (2^d) ≤ 1/2" using ‹d>0› (*‹0 < d›*) inverse_of_nat_le[of 2 "2^d"] (*‹⟦2 ≤ 2 ^ d; 2 ≠ 0⟧ ⟹ 1 / of_nat (2 ^ d) ≤ 1 / of_nat 2›*) by (simp add: self_le_power (*‹⟦(1::?'a) ≤ (?a::?'a); (0::nat) < (?n::nat)⟧ ⟹ ?a ≤ ?a ^ ?n›*)) then show "?thesis" (*goal: ‹real_of_int q / real_of_int (2 ^ d) ≤ real_of_int q / 2›*) using q_gt_zero (*‹0 < q›*) by (smt (verit, best) frac_less2 (*‹⟦0 < ?x; ?x ≤ ?y; 0 < ?w; ?w < ?z⟧ ⟹ ?x / ?z < ?y / ?w›*) of_int_le_0_iff (*‹(of_int ?z ≤ 0) = (?z ≤ 0)›*) zero_less_power (*‹0 < ?a ⟹ 0 < ?a ^ ?n›*)) qed moreover have "real_of_int q/2 + 1 ≤ real_of_int q" using q_gt_two (*‹2 < q›*) by auto ultimately have "real_of_int q / real_of_int (2^d) + 1 ≤ real_of_int q" by linarith then have fact: "real_of_int q / real_of_int (2 ^ (d + 1)) + 1/2 ≤ real_of_int q/2" by auto then show "⌊real_of_int q / real_of_int (2 ^ (d + 1)) + 1/2⌋ ≤ ⌊real_of_int q/2⌋" using floor_mono[OF fact] (*‹⌊real_of_int (q::int) / real_of_int ((2::int) ^ ((d::nat) + (1::nat))) + (1::real) / (2::real)⌋ ≤ ⌊real_of_int q / (2::real)⌋›*) by auto qed then have "abs y ≤ ⌊q/2⌋" using assms (*‹¦y¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))› ‹0 < d›*) by auto then show "?thesis" (*goal: ‹¦y¦ = ¦y mod+- q¦›*) using mod_plus_minus_range_odd[OF q_gt_zero q_odd] (*‹?y mod+- q ∈ {- ⌊real_of_int q / 2⌋..⌊real_of_int q / 2⌋}›*) by (smt (verit, del_insts) mod_plus_minus_def (*‹?m mod+- ?b = (if ⌊real_of_int ?b / 2⌋ < ?m mod ?b then ?m mod ?b - ?b else ?m mod ?b)›*) mod_pos_pos_trivial (*‹⟦0 ≤ ?k; ?k < ?l⟧ ⟹ ?k mod ?l = ?k›*) neg_mod_plus_minus (*‹⟦odd ?b; 0 < ?b⟧ ⟹ - ?x mod+- ?b = - (?x mod+- ?b)›*) q_odd (*‹odd q›*) two_mid_lt_q (*‹2 * ⌊real_of_int q / 2⌋ < q›*)) qed lemma decompress_compress_no_mod_plus_minus: assumes "x∈{0..⌈q-(q/(2*2^d))⌉-1}" "of_nat d < ⌈(log 2 q)::real⌉" "d>0" shows "abs ((decompress d (compress d x) - x) mod+- q) ≤ round ( real_of_int q / real_of_int (2^(d+1)))" proof (-) (*goal: ‹¦(decompress d (compress d x) - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) have "abs ((decompress d (compress d x) - x) mod+- q) = abs ((decompress d (compress d x) - x)) " using no_mod_plus_minus[OF decompress_compress_no_mod [ OF assms ( 1 ) assms ( 2 ) ] assms ( 3 )] (*‹¦decompress d (compress d x) - x¦ = ¦(decompress d (compress d x) - x) mod+- q¦›*) by auto then show "?thesis" (*goal: ‹¦(decompress d (compress d x) - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) using decompress_compress_no_mod[OF assms ( 1 ) assms ( 2 )] (*‹¦decompress d (compress d x) - x¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) by auto qed text ‹Now lets look at what happens when the ‹mod+-› reduction comes into action.› lemma decompress_compress_mod: assumes "x∈{⌈q-(q/(2*2^d))⌉..q-1}" "of_nat d < ⌈(log 2 q)::real⌉" shows "abs ((decompress d (compress d x) - x) mod+- q) ≤ round ( real_of_int q / real_of_int (2^(d+1)))" proof (-) (*goal: ‹¦(decompress (d::nat) (compress d (x::int)) - x) mod+- (q::int)¦ ≤ round (real_of_int q / real_of_int ((2::int) ^ (d + (1::nat))))›*) have "(decompress d (compress d x) - x) = - x" using compress_mod[OF assms] (*‹compress (d::nat) (x::int) = (0::int)›*) unfolding decompress_def (*goal: ‹round (real_of_int q * real_of_int (compress d x) / real_of_int 2 ^ d) - x = - x›*) by auto moreover have "-x mod+- q = -x+q" proof (-) (*goal: ‹- x mod+- q = - x + q›*) have range_x: "x ∈ {⌊real_of_int q / 2⌋<..q - 1}" using assms(1) (*‹x ∈ {⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉..q - 1}›*) break_point_gt_q_div_two[OF assms ( 2 )] (*‹⌊real_of_int (q::int) / (2::real)⌋ < ⌈real_of_int q - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉›*) by auto then have "*": "- x ∈ {-q + 1..< -⌊real_of_int q / 2⌋}" by auto have "**": "-x + q ∈{0..<q-⌊real_of_int q / 2⌋}" using "*" (*‹- x ∈ {- q + 1..<- ⌊real_of_int q / 2⌋}›*) by auto have "-x + q ∈{0..<q}" proof (subst atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*)) (*goal: ‹(0::int) ≤ - (x::int) + (q::int) ∧ - x + q < q›*) have "q-⌊real_of_int q / 2⌋ ≤ q" using q_gt_zero (*‹0 < q›*) by auto moreover have "0 ≤ - x + q ∧ - x + q < q-⌊real_of_int q / 2⌋" using "**" (*‹- x + q ∈ {0..<q - ⌊real_of_int q / 2⌋}›*) by auto ultimately show "0 ≤ - x + q ∧ - x + q < q" by linarith qed then have rew: "-x mod q = -x + q" using mod_rangeE (*‹?a ∈ {0..<?b} ⟹ ?a = ?a mod ?b›*) by fastforce have "-x mod q < q - ⌊real_of_int q / 2⌋" using "**" (*‹- x + q ∈ {0..<q - ⌊real_of_int q / 2⌋}›*) apply (subst rew (*‹- x mod q = - x + q›*)) (*goal: ‹- x mod q < q - ⌊real_of_int q / 2⌋›*) by (auto simp add: * (*‹- x ∈ {- q + 1..<- ⌊real_of_int q / 2⌋}›*) range_x (*‹x ∈ {⌊real_of_int q / 2⌋<..q - 1}›*)) then have "⌊real_of_int q / 2⌋ ≥ - x mod q" by linarith then show "?thesis" (*goal: ‹- x mod+- q = - x + q›*) unfolding mod_plus_minus_def (*goal: ‹(if ⌊real_of_int q / 2⌋ < - x mod q then - x mod q - q else - x mod q) = - x + q›*) using rew (*‹- x mod q = - x + q›*) by auto qed moreover have "abs (q - x) ≤ round ( real_of_int q / real_of_int (2^(d+1)))" proof (-) (*goal: ‹¦q - x¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) have "abs (q-x) = q-x" using assms(1) (*‹x ∈ {⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉..q - 1}›*) by auto also (*calculation: ‹¦q - x¦ = q - x›*) have "… ≤ q - ⌈q - q/(2*2^d)⌉" using assms(1) (*‹x ∈ {⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉..q - 1}›*) by simp also (*calculation: ‹¦q - x¦ ≤ q - ⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉›*) have "… = - ⌈- q/(2*2^d)⌉" using ceiling_int[of q "- q/(2*2^d)"] (*‹⌈real_of_int q + real_of_int (- q) / (2 * 2 ^ d)⌉ = q + ⌈real_of_int (- q) / (2 * 2 ^ d)⌉›*) by auto also (*calculation: ‹¦q - x¦ ≤ - ⌈real_of_int (- q) / (2 * 2 ^ d)⌉›*) have "… = ⌊q/(2*2^d)⌋" by (simp add: ceiling_def (*‹⌈?x::?'a::floor_ceiling⌉ = - ⌊- ?x⌋›*)) also (*calculation: ‹¦q - x¦ ≤ ⌊real_of_int q / (2 * 2 ^ d)⌋›*) have "… ≤ round (q/(2*2^d))" using floor_le_round (*‹⌊?x::?'a⌋ ≤ round ?x›*) by blast finally (*calculation: ‹¦q - x¦ ≤ round (real_of_int q / (2 * 2 ^ d))›*) have "abs (q-x) ≤ round (q/(2^(d+1)))" by auto then show "?thesis" (*goal: ‹¦q - x¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) by auto qed ultimately show "?thesis" (*goal: ‹¦(decompress d (compress d x) - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) by auto qed text ‹Together, we can determine the general error bound on decompression of compression of the data. This error needs to be small enough not to disturb the encryption and decryption process.› lemma decompress_compress: assumes "x∈{0..<q}" "of_nat d < ⌈(log 2 q)::real⌉" "d>0" shows "let x' = decompress d (compress d x) in abs ((x' - x) mod+- q) ≤ round ( real_of_int q / real_of_int (2^(d+1)) )" proof (cases "x<⌈q-(q/(2*2^d))⌉") (*goals: 1. ‹(x::int) < ⌈real_of_int (q::int) - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉ ⟹ let x'::int = decompress d (compress d x) in ¦(x' - x) mod+- q¦ ≤ round (real_of_int q / real_of_int ((2::int) ^ (d + (1::nat))))› 2. ‹¬ (x::int) < ⌈real_of_int (q::int) - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉ ⟹ let x'::int = decompress d (compress d x) in ¦(x' - x) mod+- q¦ ≤ round (real_of_int q / real_of_int ((2::int) ^ (d + (1::nat))))›*) case True (*‹x < ⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉›*) then have range_x: "x∈{0..⌈q-(q/(2*2^d))⌉-1}" using assms(1) (*‹x ∈ {0..<q}›*) by auto show "?thesis" (*goal: ‹let x'::int = decompress (d::nat) (compress d (x::int)) in ¦(x' - x) mod+- (q::int)¦ ≤ round (real_of_int q / real_of_int ((2::int) ^ (d + (1::nat))))›*) unfolding Let_def (*goal: ‹¦(decompress d (compress d x) - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) using decompress_compress_no_mod_plus_minus[OF range_x assms ( 2 ) assms ( 3 )] (*‹¦(decompress d (compress d x) - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) by auto next (*goal: ‹¬ x < ⌈real_of_int q - real_of_int q / (2 * 2 ^ d)⌉ ⟹ let x' = decompress d (compress d x) in ¦(x' - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) case False (*‹¬ (x::int) < ⌈real_of_int (q::int) - real_of_int q / ((2::real) * (2::real) ^ (d::nat))⌉›*) then have range_x: "x∈{⌈q-(q/(2*2^d))⌉..q-1}" using assms(1) (*‹x ∈ {0..<q}›*) by auto show "?thesis" (*goal: ‹let x' = decompress d (compress d x) in ¦(x' - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) unfolding Let_def (*goal: ‹¦(decompress d (compress d x) - x) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) using decompress_compress_mod[OF range_x assms ( 2 )] (*‹¦(decompress (d::nat) (compress d (x::int)) - x) mod+- (q::int)¦ ≤ round (real_of_int q / real_of_int ((2::int) ^ (d + (1::nat))))›*) by auto qed text ‹We have now defined compression only on integers (ie ‹{0..<q}›, corresponding to ‹ℤ_q›). We need to extend this notion to the ring ‹ℤ_q[X]/(X^n+1)›. Here, a compressed polynomial is the compression on every coefficient.› text ‹ How to channel through the types \begin{itemize} \item ‹to_qr :: 'a mod_ring poly ⇒ 'a qr› \item ‹Poly :: 'a mod_ring list ⇒ 'a mod_ring poly› \item ‹map of_int_mod_ring :: int list ⇒ 'a mod_ring list› \item ‹map compress :: int list ⇒ int list› \item ‹map to_int_mod_ring :: 'a mod_ring list ⇒ int list› \item ‹coeffs :: 'a mod_ring poly ⇒ 'a mod_ring list› \item ‹of_qr :: 'a qr ⇒ 'a mod_ring poly› \end{itemize} › definition compress_poly :: "nat ⇒ 'a qr ⇒ 'a qr" where "compress_poly d = to_qr ∘ Poly ∘ (map of_int_mod_ring) ∘ (map (compress d)) ∘ (map to_int_mod_ring) ∘ coeffs ∘ of_qr" definition decompress_poly :: "nat ⇒ 'a qr ⇒ 'a qr" where "decompress_poly d = to_qr ∘ Poly ∘ (map of_int_mod_ring) ∘ (map (decompress d)) ∘ (map to_int_mod_ring) ∘ coeffs ∘ of_qr" text ‹Lemmas for compression error for polynomials. Lemma telescope to go qrom module level down to integer coefficients and back up again.› lemma of_int_mod_ring_eq_0: "((of_int_mod_ring x :: 'a mod_ring) = 0) ⟷ (x mod q = 0)" by (metis CARD_a (*‹int CARD('a) = q›*) mod_0 (*‹0 mod ?a = 0›*) of_int_code( (*‹of_int 0 = 0›*) 2) of_int_mod_ring.abs_eq (*‹of_int_mod_ring ?x = Abs_mod_ring (?x mod int CARD(?'a))›*) of_int_mod_ring.rep_eq (*‹Rep_mod_ring (of_int_mod_ring ?x) = ?x mod int CARD(?'a)›*) of_int_of_int_mod_ring (*‹of_int = of_int_mod_ring›*)) lemma dropWhile_mod_ring: "dropWhile ((=)0) (map of_int_mod_ring xs :: 'a mod_ring list) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) xs)" proof (induct xs) (*goals: 1. ‹dropWhile ((=) 0) (map of_int_mod_ring []) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) [])› 2. ‹⋀a xs. dropWhile ((=) 0) (map of_int_mod_ring xs) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) xs) ⟹ dropWhile ((=) 0) (map of_int_mod_ring (a # xs)) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) (a # xs))›*) case (Cons x xs) (*‹dropWhile ((=) 0) (map of_int_mod_ring xs) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) xs)›*) have "dropWhile ((=) 0) (map of_int_mod_ring (x # xs)) = dropWhile ((=) 0) ((of_int_mod_ring x :: 'a mod_ring) # (map of_int_mod_ring xs))" by auto also (*calculation: ‹dropWhile ((=) 0) (map of_int_mod_ring (x # xs)) = dropWhile ((=) 0) (of_int_mod_ring x # map of_int_mod_ring xs)›*) have "… = (if 0 = (of_int_mod_ring x :: 'a mod_ring) then dropWhile ((=) 0) (map of_int_mod_ring xs) else map of_int_mod_ring (x # xs))" unfolding dropWhile.simps(2)[of "((=) 0)" "of_int_mod_ring x :: 'a mod_ring" "map of_int_mod_ring xs"] (*goal: ‹(if 0 = of_int_mod_ring x then dropWhile ((=) 0) (map of_int_mod_ring xs) else of_int_mod_ring x # map of_int_mod_ring xs) = (if 0 = of_int_mod_ring x then dropWhile ((=) 0) (map of_int_mod_ring xs) else map of_int_mod_ring (x # xs))›*) by auto also (*calculation: ‹dropWhile ((=) 0) (map of_int_mod_ring (x # xs)) = (if 0 = of_int_mod_ring x then dropWhile ((=) 0) (map of_int_mod_ring xs) else map of_int_mod_ring (x # xs))›*) have "… = (if x mod q = 0 then map of_int_mod_ring (dropWhile (λx. x mod q = 0) xs) else map of_int_mod_ring (x # xs))" using of_int_mod_ring_eq_0 (*‹(of_int_mod_ring ?x = 0) = (?x mod q = 0)›*) unfolding Cons.hyps (*goal: ‹(if 0 = of_int_mod_ring x then map of_int_mod_ring (dropWhile (λx. x mod q = 0) xs) else map of_int_mod_ring (x # xs)) = (if x mod q = 0 then map of_int_mod_ring (dropWhile (λx. x mod q = 0) xs) else map of_int_mod_ring (x # xs))›*) by auto also (*calculation: ‹dropWhile ((=) (0::'a mod_ring)) (map of_int_mod_ring ((x::int) # (xs::int list))) = (if x mod (q::int) = (0::int) then map of_int_mod_ring (dropWhile (λx::int. x mod q = (0::int)) xs) else map of_int_mod_ring (x # xs))›*) have "… = map of_int_mod_ring (dropWhile (λx. x mod q = 0) (x # xs))" unfolding dropWhile.simps(2) (*goal: ‹(if (x::int) mod (q::int) = (0::int) then map of_int_mod_ring (dropWhile (λx::int. x mod q = (0::int)) (xs::int list)) else map of_int_mod_ring (x # xs)) = map of_int_mod_ring (if x mod q = (0::int) then dropWhile (λx::int. x mod q = (0::int)) xs else x # xs)›*) by auto finally (*calculation: ‹dropWhile ((=) 0) (map of_int_mod_ring (x # xs)) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) (x # xs))›*) show "?case" (*goal: ‹dropWhile ((=) 0) (map of_int_mod_ring (x # xs)) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) (x # xs))›*) by blast qed (simp) (*solved the remaining goal: ‹dropWhile ((=) 0) (map of_int_mod_ring []) = map of_int_mod_ring (dropWhile (λx. x mod q = 0) [])›*) lemma strip_while_mod_ring: "(strip_while ((=) 0) (map of_int_mod_ring xs :: 'a mod_ring list)) = map of_int_mod_ring (strip_while (λx. x mod q = 0) xs)" unfolding strip_while_def comp_def rev_map dropWhile_mod_ring (*goal: ‹map of_int_mod_ring (rev (dropWhile (λx::int. x mod (q::int) = (0::int)) (rev (xs::int list)))) = map of_int_mod_ring (rev (dropWhile (λx::int. x mod q = (0::int)) (rev xs)))›*) by auto lemma of_qr_to_qr_Poly: assumes "length (xs :: int list) < Suc (nat n)" "xs ≠ []" shows "of_qr (to_qr (Poly (map (of_int_mod_ring :: int ⇒ 'a mod_ring) xs))) = Poly (map (of_int_mod_ring :: int ⇒ 'a mod_ring) xs)" (is "_ = ?Poly") proof (-) (*goal: ‹of_qr (to_qr (Poly (map of_int_mod_ring xs))) = Poly (map of_int_mod_ring xs)›*) have deg: "degree (?Poly) < n" using deg_Poly'[of "map of_int_mod_ring xs"] (*‹Poly (map of_int_mod_ring xs) ≠ 0 ⟹ degree (Poly (map of_int_mod_ring xs)) ≤ length (map of_int_mod_ring xs) - 1›*) assms (*‹length (xs::int list) < Suc (nat (n::int))› ‹xs ≠ []›*) by (smt (verit, del_insts) One_nat_def (*‹1 = Suc 0›*) Suc_pred (*‹0 < ?n ⟹ Suc (?n - Suc 0) = ?n›*) degree_0 (*‹degree 0 = 0›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*) order_less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) zless_nat_eq_int_zless (*‹(?m < nat ?z) = (int ?m < ?z)›*)) then show "?thesis" (*goal: ‹of_qr (to_qr (Poly (map of_int_mod_ring (xs::int list)))) = Poly (map of_int_mod_ring xs)›*) using of_qr_to_qr[of "?Poly"] (*‹of_qr (to_qr (Poly (map of_int_mod_ring xs))) = Poly (map of_int_mod_ring xs) mod qr_poly›*) deg_mod_qr_poly[of "?Poly"] (*‹degree (Poly (map of_int_mod_ring xs)) < deg_qr TYPE('a) ⟹ Poly (map of_int_mod_ring xs) mod qr_poly = Poly (map of_int_mod_ring xs)›*) deg_qr_n (*‹int (deg_qr TYPE('a)) = n›*) by (smt (verit, best) of_nat_less_imp_less (*‹of_nat (?m::nat) < of_nat (?n::nat) ⟹ ?m < ?n›*)) qed lemma telescope_stripped: assumes "length (xs :: int list) < Suc (nat n)" "strip_while (λx. x mod q = 0) xs = xs" "set xs ⊆ {0..<q}" shows "(map to_int_mod_ring) (coeffs (of_qr (to_qr (Poly (map (of_int_mod_ring :: int ⇒ 'a mod_ring) xs))))) = xs" proof (cases "xs = []") (*goals: 1. ‹xs = [] ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = xs› 2. ‹xs ≠ [] ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = xs›*) case False (*‹xs ≠ []›*) have ge_zero: "0≤x" and lt_q: "x < int CARD ('a)" if "x∈set xs" for x using assms(3) (*‹set (xs::int list) ⊆ {0::int..<q::int}›*) CARD_a (*‹int CARD('a) = q›*) atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) that (*‹x ∈ set xs›*) apply - (*goals: 1. ‹⟦set xs ⊆ {0..<q}; int CARD('a) = q; ⋀i l u. (i ∈ {l..<u}) = (l ≤ i ∧ i < u); x ∈ set xs⟧ ⟹ 0 ≤ x› 2. ‹⟦set xs ⊆ {0..<q}; int CARD('a) = q; ⋀i l u. (i ∈ {l..<u}) = (l ≤ i ∧ i < u); x ∈ set xs⟧ ⟹ x < int CARD('a)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have to_int_of_int: "map (to_int_mod_ring ∘ (of_int_mod_ring :: int ⇒ 'a mod_ring)) xs = xs" using to_int_mod_ring_of_int_mod_ring[OF ge_zero lt_q] (*‹⟦?x ∈ set xs; ?x ∈ set xs⟧ ⟹ to_int_mod_ring (of_int_mod_ring ?x) = ?x›*) by (simp add: map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*)) show "?thesis" (*goal: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = xs›*) using assms(2) (*‹strip_while (λx. x mod q = 0) xs = xs›*) of_qr_to_qr_Poly[OF assms ( 1 ) False] (*‹of_qr (to_qr (Poly (map of_int_mod_ring (xs::int list)))) = Poly (map of_int_mod_ring xs)›*) by (auto simp add: to_int_of_int (*‹map (to_int_mod_ring ∘ of_int_mod_ring) (xs::int list) = xs›*) strip_while_mod_ring (*‹strip_while ((=) (0::'a mod_ring)) (map of_int_mod_ring (?xs::int list)) = map of_int_mod_ring (strip_while (λx::int. x mod (q::int) = (0::int)) ?xs)›*)) qed (simp) (*solved the remaining goal: ‹xs = [] ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = xs›*) lemma map_to_of_mod_ring: assumes "set xs ⊆ {0..<q}" shows "map (to_int_mod_ring ∘ (of_int_mod_ring :: int ⇒ 'a mod_ring)) xs = xs" using assms (*‹set xs ⊆ {0..<q}›*) apply (induct xs) (*goals: 1. ‹set [] ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) [] = []› 2. ‹⋀a xs. ⟦set xs ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) xs = xs; set (a # xs) ⊆ {0..<q}⟧ ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (a # xs) = a # xs› discuss goal 1*) apply (simp add: CARD_a (*‹int CARD('a) = q›*)) (*discuss goal 2*) apply (simp add: CARD_a (*‹int CARD('a) = (q::int)›*)) (*proven 2 subgoals*) . lemma telescope: assumes "length (xs :: int list) < Suc (nat n)" "set xs ⊆ {0..<q}" shows "(map to_int_mod_ring) (coeffs (of_qr (to_qr (Poly (map (of_int_mod_ring :: int ⇒ 'a mod_ring) xs))))) = strip_while (λx. x mod q = 0) xs" proof (cases "xs = strip_while (λx. x mod q = 0) xs") (*goals: 1. ‹xs = strip_while (λx. x mod q = 0) xs ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = strip_while (λx. x mod q = 0) xs› 2. ‹xs ≠ strip_while (λx. x mod q = 0) xs ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = strip_while (λx. x mod q = 0) xs›*) case True (*‹xs = strip_while (λx. x mod q = 0) xs›*) then show "?thesis" (*goal: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring (xs::int list)))))) = strip_while (λx::int. x mod (q::int) = (0::int)) xs›*) using telescope_stripped (*‹⟦length ?xs < Suc (nat n); strip_while (λx. x mod q = 0) ?xs = ?xs; set ?xs ⊆ {0..<q}⟧ ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring ?xs))))) = ?xs›*) assms (*‹length xs < Suc (nat n)› ‹set xs ⊆ {0..<q}›*) by auto next (*goal: ‹xs ≠ strip_while (λx. x mod q = 0) xs ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = strip_while (λx. x mod q = 0) xs›*) case False (*‹(xs::int list) ≠ strip_while (λx::int. x mod (q::int) = (0::int)) xs›*) let ?of_int = "(map (of_int_mod_ring :: int ⇒ 'a mod_ring) xs)" have "xs ≠ []" using False (*‹xs ≠ strip_while (λx. x mod q = 0) xs›*) by auto then have "(map to_int_mod_ring) (coeffs (of_qr (to_qr (Poly ?of_int)))) = (map to_int_mod_ring) (coeffs (Poly ?of_int))" using of_qr_to_qr_Poly[OF assms ( 1 )] (*‹xs ≠ [] ⟹ of_qr (to_qr (Poly (map of_int_mod_ring xs))) = Poly (map of_int_mod_ring xs)›*) by auto also (*calculation: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = map to_int_mod_ring (coeffs (Poly (map of_int_mod_ring xs)))›*) have "… = (map to_int_mod_ring) (strip_while ((=) 0) ?of_int)" by auto also (*calculation: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = map to_int_mod_ring (strip_while ((=) 0) (map of_int_mod_ring xs))›*) have "… = map (to_int_mod_ring ∘ (of_int_mod_ring :: int ⇒ 'a mod_ring)) (strip_while (λx. x mod q = 0) xs)" using strip_while_mod_ring (*‹strip_while ((=) 0) (map of_int_mod_ring ?xs) = map of_int_mod_ring (strip_while (λx. x mod q = 0) ?xs)›*) by auto also (*calculation: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) xs)›*) have "… = strip_while (λx. x mod q = 0) xs" using assms(2) (*‹set xs ⊆ {0..<q}›*) proof (induct xs rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹set [] ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) []) = strip_while (λx. x mod q = 0) []› 2. ‹⋀x xs. ⟦set xs ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) xs) = strip_while (λx. x mod q = 0) xs; set (xs @ [x]) ⊆ {0..<q}⟧ ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) (xs @ [x])) = strip_while (λx. x mod q = 0) (xs @ [x])›*) case (snoc y ys) (*‹set ys ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) ys) = strip_while (λx. x mod q = 0) ys› ‹set (ys @ [y]) ⊆ {0..<q}›*) let ?to_of_mod_ring = "to_int_mod_ring ∘ (of_int_mod_ring :: int ⇒ 'a mod_ring)" have "map ?to_of_mod_ring (strip_while (λx. x mod q = 0) (ys @ [y])) = (if y mod q = 0 then map ?to_of_mod_ring (strip_while (λx. x mod q = 0) ys) else map ?to_of_mod_ring ys @ [?to_of_mod_ring y])" apply (subst strip_while_snoc (*‹strip_while ?P (?xs @ [?x]) = (if ?P ?x then strip_while ?P ?xs else ?xs @ [?x])›*)) (*goal: ‹map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) (ys @ [y])) = (if y mod q = 0 then map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) ys) else map (to_int_mod_ring ∘ of_int_mod_ring) ys @ [(to_int_mod_ring ∘ of_int_mod_ring) y])›*) by auto also (*calculation: ‹map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) (ys @ [y])) = (if y mod q = 0 then map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) ys) else map (to_int_mod_ring ∘ of_int_mod_ring) ys @ [(to_int_mod_ring ∘ of_int_mod_ring) y])›*) have "… = (if y mod q = 0 then strip_while (λx. x mod q = 0) ys else map ?to_of_mod_ring ys @ [?to_of_mod_ring y])" using snoc (*‹set ys ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) ys) = strip_while (λx. x mod q = 0) ys› ‹set (ys @ [y]) ⊆ {0..<q}›*) by fastforce also (*calculation: ‹map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) (ys @ [y])) = (if y mod q = 0 then strip_while (λx. x mod q = 0) ys else map (to_int_mod_ring ∘ of_int_mod_ring) ys @ [(to_int_mod_ring ∘ of_int_mod_ring) y])›*) have "… = (if y mod q = 0 then strip_while (λx. x mod q = 0) ys else ys @ [y])" using map_to_of_mod_ring[OF snoc ( 2 )] (*‹map (to_int_mod_ring ∘ of_int_mod_ring) (ys @ [y]) = ys @ [y]›*) by auto also (*calculation: ‹map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) (ys @ [y])) = (if y mod q = 0 then strip_while (λx. x mod q = 0) ys else ys @ [y])›*) have "… = strip_while (λx. x mod q = 0) (ys @ [y])" by auto finally (*calculation: ‹map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) (ys @ [y])) = strip_while (λx. x mod q = 0) (ys @ [y])›*) show "?case" (*goal: ‹map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx::int. x mod (q::int) = (0::int)) ((ys::int list) @ [y::int])) = strip_while (λx::int. x mod q = (0::int)) (ys @ [y])›*) . qed (simp) (*solved the remaining goal: ‹set [] ⊆ {0..<q} ⟹ map (to_int_mod_ring ∘ of_int_mod_ring) (strip_while (λx. x mod q = 0) []) = strip_while (λx. x mod q = 0) []›*) finally (*calculation: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring xs))))) = strip_while (λx. x mod q = 0) xs›*) show "?thesis" (*goal: ‹map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring (xs::int list)))))) = strip_while (λx::int. x mod (q::int) = (0::int)) xs›*) by auto qed lemma length_coeffs_of_qr: "length (coeffs (of_qr (x ::'a qr))) < Suc (nat n)" proof (cases "x=0") (*goals: 1. ‹x = 0 ⟹ length (coeffs (of_qr x)) < Suc (nat n)› 2. ‹x ≠ 0 ⟹ length (coeffs (of_qr x)) < Suc (nat n)›*) case False (*‹x ≠ 0›*) then have "of_qr x ≠ 0" by simp then show "?thesis" (*goal: ‹length (coeffs (of_qr x)) < Suc (nat n)›*) using length_coeffs_degree[of "of_qr x"] (*‹of_qr x ≠ 0 ⟹ length (coeffs (of_qr x)) = Suc (degree (of_qr x))›*) deg_of_qr[of x] (*‹degree (of_qr x) < deg_qr TYPE('a)›*) using deg_qr_n (*‹int (deg_qr TYPE('a::qr_spec)) = (n::int)›*) by fastforce qed (auto simp add: n_gt_zero (*‹0 < n›*)) (*solved the remaining goal: ‹x = 0 ⟹ length (coeffs (of_qr x)) < Suc (nat n)›*) end lemma strip_while_change: assumes "⋀x. P x ⟶ S x" "⋀x. (¬ P x) ⟶ (¬ S x)" shows "strip_while P xs = strip_while S xs" proof (induct xs rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹strip_while P [] = strip_while S []› 2. ‹⋀x xs. strip_while P xs = strip_while S xs ⟹ strip_while P (xs @ [x]) = strip_while S (xs @ [x])›*) case (snoc x xs) (*‹strip_while P xs = strip_while S xs›*) have "P x = S x" using assms[of x] (*‹P x ⟶ S x› ‹¬ P x ⟶ ¬ S x›*) by blast then show "?case" (*goal: ‹strip_while P (xs @ [x]) = strip_while S (xs @ [x])›*) by (simp add: snoc.hyps (*‹strip_while P xs = strip_while S xs›*)) qed (simp) (*solved the remaining goal: ‹strip_while P [] = strip_while S []›*) lemma strip_while_change_subset: assumes "set xs ⊆ s" "∀x∈s. P x ⟶ S x" "∀x∈s. (¬ P x) ⟶ (¬ S x)" shows "strip_while P xs = strip_while S xs" using assms(1) (*‹set xs ⊆ s›*) proof (induct xs rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹set [] ⊆ (s::'a::type set) ⟹ strip_while (P::'a::type ⇒ bool) [] = strip_while (S::'a::type ⇒ bool) []› 2. ‹⋀(x::'a::type) xs::'a::type list. ⟦set xs ⊆ (s::'a::type set) ⟹ strip_while (P::'a::type ⇒ bool) xs = strip_while (S::'a::type ⇒ bool) xs; set (xs @ [x]) ⊆ s⟧ ⟹ strip_while P (xs @ [x]) = strip_while S (xs @ [x])›*) case (snoc x xs) (*‹set xs ⊆ s ⟹ strip_while P xs = strip_while S xs› ‹set (xs @ [x]) ⊆ s›*) have "x∈s" using snoc(2) (*‹set (xs @ [x]) ⊆ s›*) by simp then have "P x ⟶ S x" and "(¬ P x) ⟶ (¬ S x)" using assms(2) (*‹∀x∈s. P x ⟶ S x›*) assms(3) (*‹∀x::'a::type∈s::'a::type set. ¬ (P::'a::type ⇒ bool) x ⟶ ¬ (S::'a::type ⇒ bool) x›*) apply - (*goals: 1. ‹⟦x ∈ s; ∀x∈s. P x ⟶ S x; ∀x∈s. ¬ P x ⟶ ¬ S x⟧ ⟹ P x ⟶ S x› 2. ‹⟦x ∈ s; ∀x∈s. P x ⟶ S x; ∀x∈s. ¬ P x ⟶ ¬ S x⟧ ⟹ ¬ P x ⟶ ¬ S x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "P x = S x" by blast then show "?case" (*goal: ‹strip_while P (xs @ [x]) = strip_while S (xs @ [x])›*) using snoc.hyps (*‹set xs ⊆ s ⟹ strip_while P xs = strip_while S xs›*) snoc.prems (*‹set ((xs::'a list) @ [x::'a]) ⊆ (s::'a set)›*) by auto qed (simp) (*solved the remaining goal: ‹set [] ⊆ s ⟹ strip_while P [] = strip_while S []›*) text ‹Estimate for decompress compress for polynomials. Using the inequality for integers, chain it up to the level of polynomials.› context kyber_spec begin lemma decompress_compress_poly: assumes "of_nat d < ⌈(log 2 q)::real⌉" "d>0" shows "let x' = decompress_poly d (compress_poly d x) in abs_infty_poly (x - x') ≤ round ( real_of_int q / real_of_int (2^(d+1)) )" proof (-) (*goal: ‹let x' = decompress_poly d (compress_poly d x) in abs_infty_poly (x - x') ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) let ?x' = "decompress_poly d (compress_poly d x)" have "abs_infty_q (poly.coeff (of_qr (x - ?x')) xa) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))" for xa proof (-) (*goal: ‹abs_infty_q (poly.coeff (of_qr (x - decompress_poly d (compress_poly d x))) xa) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) let ?telescope = "(λxs. (map to_int_mod_ring) (coeffs (of_qr (to_qr (Poly (map (of_int_mod_ring :: int ⇒ 'a mod_ring) xs))))))" define compress_x where "compress_x = map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))" let ?to_Poly = "(λa. Poly (map ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d) a))" have "abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (?to_Poly (?telescope compress_x)))) xa ) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (?to_Poly (strip_while (λx. x = 0) compress_x)))) xa )" proof (cases "x = 0") (*goals: 1. ‹x = 0 ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))))) xa)› 2. ‹x ≠ 0 ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))))) xa)›*) case True (*‹x = 0›*) then have "compress_x = []" unfolding compress_x_def (*goal: ‹map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x)) = []›*) by auto then show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr (x::'a qr)) (xa::nat) - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring (compress_x::int list))))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx::int. x = (0::int)) compress_x))))) xa)›*) by simp next (*goal: ‹x ≠ 0 ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))))) xa)›*) case False (*‹(x::'a qr) ≠ (0::'a qr)›*) then have nonempty: "compress_x ≠ []" unfolding compress_x_def (*goal: ‹map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x)) ≠ []›*) by simp have "length compress_x < Suc (nat n)" by (auto simp add: compress_x_def (*‹compress_x = map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))›*) length_coeffs_of_qr (*‹length (coeffs (of_qr ?x)) < Suc (nat n)›*)) moreover have "set compress_x ⊆ {0..<q}" proof (-) (*goal: ‹set compress_x ⊆ {0..<q}›*) have to: "to_int_mod_ring (s::'a mod_ring) ∈ {0..q - 1}" for s using to_int_mod_ring_range (*‹range to_int_mod_ring = {0..<q}›*) by auto have "compress d (to_int_mod_ring (s::'a mod_ring)) ∈ {0..<q}" for s using range_compress[OF to assms ( 1 ), of s] (*‹compress d (to_int_mod_ring s) ∈ {0..2 ^ d - 1}›*) twod_lt_q[OF assms ( 1 )] (*‹2 powr real d < real_of_int q›*) by (simp add: powr_realpow (*‹0 < ?x ⟹ ?x powr real ?n = ?x ^ ?n›*)) then show "?thesis" (*goal: ‹set compress_x ⊆ {0..<q}›*) unfolding compress_x_def (*goal: ‹set (map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))) ⊆ {0..<q}›*) by auto qed ultimately have "?telescope compress_x = strip_while (λx. x mod q = 0) compress_x" apply (intro telescope[of "compress_x"] (*‹⟦length compress_x < Suc (nat n); set compress_x ⊆ {0..<q}⟧ ⟹ map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x))))) = strip_while (λx. x mod q = 0) compress_x›*)) (*goals: 1. ‹⟦length compress_x < Suc (nat n); set compress_x ⊆ {0..<q}⟧ ⟹ length compress_x < Suc (nat n)› 2. ‹⟦length compress_x < Suc (nat n); set compress_x ⊆ {0..<q}⟧ ⟹ set compress_x ⊆ {0..<q}› discuss goal 1*) apply simp (*discuss goal 2*) . (*proven 2 subgoals*) moreover have "strip_while (λx. x mod q = 0) compress_x = strip_while (λx. x = 0) compress_x" proof (-) (*goal: ‹strip_while (λx. x mod q = 0) compress_x = strip_while (λx. x = 0) compress_x›*) have "compress d s = 0" if "compress d s mod q = 0" for s proof (-) (*goal: ‹compress d s = 0›*) from ‹int d < ⌈log 2 (real_of_int q)⌉› (*‹int d < ⌈log 2 (real_of_int q)⌉›*) twod_lt_q[of d] (*‹int d < ⌈log 2 (real_of_int q)⌉ ⟹ 2 powr real d < real_of_int q›*) have "2 ^ d < q" by (simp add: powr_realpow (*‹0 < ?x ⟹ ?x powr real ?n = ?x ^ ?n›*)) with compress_less[of d s] (*‹compress (d::nat) (s::int) < (2::int) ^ d›*) have "compress d s < q" by simp then have "compress d s = compress d s mod q" by (simp add: compress_def (*‹compress (?d::nat) (?x::int) = round (real_of_int ((2::int) ^ ?d * ?x) / real_of_int (q::int)) mod (2::int) ^ ?d›*)) with that (*‹compress d s mod q = 0›*) show "?thesis" (*goal: ‹compress d s = 0›*) by simp qed then have right: "⋀s. compress d s mod q = 0 ⟶ compress d s = 0" by simp have "¬ (compress d s = 0)" if "¬ (compress d s mod q = 0)" for s using twod_lt_q (*‹int (?d::nat) < ⌈log (2::real) (real_of_int (q::int))⌉ ⟹ (2::real) powr real ?d < real_of_int q›*) compress_def (*‹compress (?d::nat) (?x::int) = round (real_of_int ((2::int) ^ ?d * ?x) / real_of_int (q::int)) mod (2::int) ^ ?d›*) that (*‹compress d s mod q ≠ 0›*) by force then have left: "⋀s. ¬ (compress d s mod q = 0) ⟶ ¬ (compress d s = 0)" by simp have "strip_while (λx. x mod q = 0) compress_x = strip_while (λx. x mod q = 0) (map (compress d) (map to_int_mod_ring (coeffs (of_qr x))))" (is "_ = strip_while (λx. x mod q = 0) (map (compress d) ?rest)") unfolding compress_x_def (*goal: ‹strip_while (λx. x mod q = 0) (map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))) = strip_while (λx. x mod q = 0) (map (compress d) (map to_int_mod_ring (coeffs (of_qr x))))›*) by simp also (*calculation: ‹strip_while (λx. x mod q = 0) compress_x = strip_while (λx. x mod q = 0) (map (compress d) (map to_int_mod_ring (coeffs (of_qr x))))›*) have "… = map (compress d) (strip_while ((λy. y mod q = 0) ∘ compress d) (map to_int_mod_ring (coeffs (of_qr x))))" using strip_while_map[of "λy. y mod q = 0" "compress d"] (*‹strip_while (λy::int. y mod (q::int) = (0::int)) (map (compress (d::nat)) (?xs::int list)) = map (compress d) (strip_while ((λy::int. y mod q = (0::int)) ∘ compress d) ?xs)›*) by blast also (*calculation: ‹strip_while (λx. x mod q = 0) compress_x = map (compress d) (strip_while ((λy. y mod q = 0) ∘ compress d) (map to_int_mod_ring (coeffs (of_qr x))))›*) have "… = map (compress d) (strip_while ((λy. y = 0) ∘ compress d) (map to_int_mod_ring (coeffs (of_qr x))))" by (smt (verit, best) comp_eq_dest_lhs (*‹?a ∘ ?b = ?c ⟹ ?a (?b ?v) = ?c ?v›*) left (*‹compress d ?s mod q ≠ 0 ⟶ compress d ?s ≠ 0›*) right (*‹compress d ?s mod q = 0 ⟶ compress d ?s = 0›*) strip_while_change (*‹⟦⋀x. ?P x ⟶ ?S x; ⋀x. ¬ ?P x ⟶ ¬ ?S x⟧ ⟹ strip_while ?P ?xs = strip_while ?S ?xs›*)) also (*calculation: ‹strip_while (λx. x mod q = 0) compress_x = map (compress d) (strip_while ((λy. y = 0) ∘ compress d) (map to_int_mod_ring (coeffs (of_qr x))))›*) have "… = strip_while (λx. x = 0) (map (compress d) ?rest)" using strip_while_map[of "λy. y = 0" "compress d", symmetric] (*‹map (compress d) (strip_while ((λy. y = 0) ∘ compress d) ?xs) = strip_while (λy. y = 0) (map (compress d) ?xs)›*) by blast finally (*calculation: ‹strip_while (λx. x mod q = 0) compress_x = strip_while (λx. x = 0) (map (compress d) (map to_int_mod_ring (coeffs (of_qr x))))›*) show "?thesis" (*goal: ‹strip_while (λx. x mod q = 0) compress_x = strip_while (λx. x = 0) compress_x›*) unfolding compress_x_def (*goal: ‹strip_while (λx::int. x mod (q::int) = (0::int)) (map (compress (d::nat) ∘ to_int_mod_ring) (coeffs (of_qr (x::'a::qr_spec qr)))) = strip_while (λx::int. x = (0::int)) (map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x)))›*) by auto qed ultimately show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))))) xa)›*) by auto qed also (*calculation: ‹abs_infty_q (poly.coeff (of_qr (x::'a qr)) (xa::nat) - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring (compress_x::int list))))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx::int. x = (0::int)) compress_x))))) xa)›*) have "… = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (?to_Poly (strip_while (λx. x = 0) compress_x)) xa)" proof (cases "?to_Poly (strip_while (λx. x = 0) compress_x) = 0") (*goals: 1. ‹Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x)) = 0 ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))) xa)› 2. ‹Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x)) ≠ 0 ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))) xa)›*) case False (*‹Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x)) ≠ 0›*) have "degree (?to_Poly (strip_while (λx. x = 0) compress_x)) ≤ length (map ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d) (strip_while (λx. x = 0) compress_x)) - 1" using deg_Poly'[OF False] (*‹degree (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (strip_while (λx::int. x = (0::int)) (compress_x::int list)))) ≤ length (map (of_int_mod_ring ∘ decompress d) (strip_while (λx::int. x = (0::int)) compress_x)) - (1::nat)›*) . moreover have "length (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x)) ≤ length (coeffs (of_qr x))" unfolding compress_x_def (*goal: ‹length (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) (map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))))) ≤ length (coeffs (of_qr x))›*) by (metis length_map (*‹length (map ?f ?xs) = length ?xs›*) length_strip_while_le (*‹length (strip_while ?P ?xs) ≤ length ?xs›*)) moreover have "length (coeffs (of_qr x)) - 1 < deg_qr TYPE('a)" using deg_of_qr (*‹degree (of_qr (?x::?'a qr)) < deg_qr TYPE(?'a)›*) degree_eq_length_coeffs (*‹degree ?p = length (coeffs ?p) - 1›*) by metis ultimately have deg: "degree (?to_Poly (strip_while (λx. x = 0) compress_x)) < deg_qr TYPE('a)" by auto show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr (x::'a qr)) (xa::nat) - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (strip_while (λx::int. x = (0::int)) (compress_x::int list)))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx::int. x = (0::int)) compress_x))) xa)›*) using of_qr_to_qr' (*‹degree ?x < deg_qr TYPE(?'a) ⟹ of_qr (to_qr ?x) = ?x›*) by (simp add: of_qr_to_qr'[OF deg] (*‹of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x)))) = Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))›*)) qed (simp) (*solved the remaining goal: ‹Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (strip_while (λx::int. x = (0::int)) (compress_x::int list))) = (0::'a mod_ring poly) ⟹ abs_infty_q (poly.coeff (of_qr (x::'a qr)) (xa::nat) - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx::int. x = (0::int)) compress_x))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx::int. x = (0::int)) compress_x))) xa)›*) also (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))) xa)›*) have "… = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x = 0) (map (decompress d) compress_x)))) xa )" proof (-) (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x = 0) (map (decompress d) compress_x)))) xa)›*) have "s = 0" if "decompress d s = 0" "s ∈ {0..2^d - 1}" for s using decompress_zero_unique[OF that assms ( 1 )] (*‹s = 0›*) . then have right: "∀s ∈ {0..2^d-1}. decompress d s = 0 ⟶ s = 0" by simp have left: "∀ s ∈ {0..2^d-1}. decompress d s ≠ 0 ⟶ s ≠ 0" using decompress_zero[of d] (*‹decompress d 0 = 0›*) by auto have compress_x_range: "set compress_x ⊆ {0..2^d - 1}" unfolding compress_x_def compress_def (*goal: ‹set (map ((λx::int. round (real_of_int ((2::int) ^ (d::nat) * x) / real_of_int (q::int)) mod (2::int) ^ d) ∘ to_int_mod_ring) (coeffs (of_qr (x::'a qr)))) ⊆ {0::int..(2::int) ^ d - (1::int)}›*) by auto have "map (decompress d) (strip_while (λx. x = 0) compress_x) = map (decompress d) (strip_while (λx. decompress d x = 0) compress_x)" using strip_while_change_subset[OF compress_x_range right left] (*‹strip_while (λs. decompress d s = 0) compress_x = strip_while (λs. s = 0) compress_x›*) by auto also (*calculation: ‹map (decompress d) (strip_while (λx. x = 0) compress_x) = map (decompress d) (strip_while (λx. decompress d x = 0) compress_x)›*) have "… = strip_while (λx. x = 0) (map (decompress d) compress_x)" proof (-) (*goal: ‹map (decompress d) (strip_while (λx. decompress d x = 0) compress_x) = strip_while (λx. x = 0) (map (decompress d) compress_x)›*) have "(λx. x = 0) ∘ decompress d = (λx. decompress d x = 0)" using comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) by blast then show "?thesis" (*goal: ‹map (decompress (d::nat)) (strip_while (λx::int. decompress d x = (0::int)) (compress_x::int list)) = strip_while (λx::int. x = (0::int)) (map (decompress d) compress_x)›*) using strip_while_map[symmetric, of "decompress d" "λx. x=0" compress_x] (*‹map (decompress d) (strip_while ((λx. x = 0) ∘ decompress d) compress_x) = strip_while (λx. x = 0) (map (decompress d) compress_x)›*) by auto qed finally (*calculation: ‹map (decompress d) (strip_while (λx. x = 0) compress_x) = strip_while (λx. x = 0) (map (decompress d) compress_x)›*) have "map (decompress d) (strip_while (λx. x = 0) compress_x) = strip_while (λx. x = 0) (map (decompress d) compress_x)" by auto then show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) (strip_while (λx. x = 0) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x = 0) (map (decompress d) compress_x)))) xa)›*) by (metis map_map (*‹map (?f::?'b ⇒ ?'a) (map (?g::?'c ⇒ ?'b) (?xs::?'c list)) = map (?f ∘ ?g) ?xs›*)) qed also (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x = 0) (map (decompress d) compress_x)))) xa)›*) have "… = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x mod q = 0) (map (decompress d) compress_x)))) xa )" proof (-) (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x = 0) (map (decompress d) compress_x)))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x mod q = 0) (map (decompress d) compress_x)))) xa)›*) have range: "set (map (decompress d) compress_x) ⊆ {0..<q}" unfolding compress_x_def compress_def (*goal: ‹set (map (decompress d) (map ((λx. round (real_of_int (2 ^ d * x) / real_of_int q) mod 2 ^ d) ∘ to_int_mod_ring) (coeffs (of_qr x)))) ⊆ {0..<q}›*) using range_decompress[OF _ assms ( 1 )] (*‹?x ∈ {0..2 ^ d - 1} ⟹ decompress d ?x ∈ {0..q - 1}›*) by auto have right: " ∀x∈{0..<q}. x = 0 ⟶ x mod q = 0" by auto have left: "∀x∈{0..<q}. ¬ x = 0 ⟶ ¬ x mod q = 0" by auto have "strip_while (λx. x = 0) (map (decompress d) compress_x) = strip_while (λx. x mod q = 0) (map (decompress d) compress_x)" using strip_while_change_subset[OF range right left] (*‹strip_while (λx. x = 0) (map (decompress d) compress_x) = strip_while (λx. x mod q = 0) (map (decompress d) compress_x)›*) by auto then show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x = 0) (map (decompress d) compress_x)))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x mod q = 0) (map (decompress d) compress_x)))) xa)›*) by auto qed also (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (strip_while (λx. x mod q = 0) (map (decompress d) compress_x)))) xa)›*) have "… = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa )" by (metis Poly_coeffs (*‹Poly (coeffs ?p) = ?p›*) coeffs_Poly (*‹coeffs (Poly ?as) = strip_while ((=) 0) ?as›*) strip_while_mod_ring (*‹strip_while ((=) 0) (map of_int_mod_ring ?xs) = map of_int_mod_ring (strip_while (λx. x mod q = 0) ?xs)›*)) also (*calculation: ‹abs_infty_q (poly.coeff (of_qr (x::'a::qr_spec qr)) (xa::nat) - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring (compress_x::int list))))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa)›*) have "… = abs_infty_q (poly.coeff (of_qr x) xa - ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))" using coeffs_Poly (*‹coeffs (Poly ?as) = strip_while ((=) 0) ?as›*) proof (cases "xa < length (coeffs (?to_Poly compress_x))") (*goals: 1. ‹⟦⋀as. coeffs (Poly as) = strip_while ((=) 0) as; xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))⟧ ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))› 2. ‹⟦⋀as. coeffs (Poly as) = strip_while ((=) 0) as; ¬ xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))⟧ ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))›*) case True (*‹(xa::nat) < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (compress_x::int list))))›*) have "poly.coeff (?to_Poly compress_x) xa = coeffs (?to_Poly compress_x) ! xa" using nth_coeffs_coeff[OF True] (*‹coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) ! xa = poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa›*) by simp also (*calculation: ‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa = coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) ! xa›*) have "… = strip_while ((=) 0) (map ( (of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d) compress_x) ! xa" using coeffs_Poly (*‹coeffs (Poly (?as::?'a list)) = strip_while ((=) (0::?'a)) ?as›*) by auto also (*calculation: ‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa = strip_while ((=) 0) (map (of_int_mod_ring ∘ decompress d) compress_x) ! xa›*) have "… = (map ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d) compress_x) ! xa" using True (*‹xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))›*) by (metis coeffs_Poly (*‹coeffs (Poly ?as) = strip_while ((=) 0) ?as›*) nth_strip_while (*‹?n < length (strip_while ?P ?xs) ⟹ strip_while ?P ?xs ! ?n = ?xs ! ?n›*)) also (*calculation: ‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa = map (of_int_mod_ring ∘ decompress d) compress_x ! xa›*) have "… = ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (coeffs (of_qr x) ! xa)" unfolding compress_x_def (*goal: ‹map (of_int_mod_ring ∘ decompress (d::nat)) (map (compress d ∘ to_int_mod_ring) (coeffs (of_qr (x::'a::qr_spec qr)))) ! (xa::nat) = (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (coeffs (of_qr x) ! xa)›*) by (smt (z3) True (*‹xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))›*) coeffs_Poly (*‹coeffs (Poly ?as) = strip_while ((=) 0) ?as›*) compress_x_def (*‹compress_x = map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) length_strip_while_le (*‹length (strip_while ?P ?xs) ≤ length ?xs›*) map_map (*‹map ?f (map ?g ?xs) = map (?f ∘ ?g) ?xs›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) nth_map (*‹?n < length ?xs ⟹ map ?f ?xs ! ?n = ?f (?xs ! ?n)›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) also (*calculation: ‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa = (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (coeffs (of_qr x) ! xa)›*) have "… = ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa)" by (metis (no_types, lifting) True (*‹xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))›*) coeffs_Poly (*‹coeffs (Poly ?as) = strip_while ((=) 0) ?as›*) compress_x_def (*‹compress_x = map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x))›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) length_strip_while_le (*‹length (strip_while ?P ?xs) ≤ length ?xs›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) nth_coeffs_coeff (*‹?i < length (coeffs ?f) ⟹ coeffs ?f ! ?i = poly.coeff ?f ?i›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) finally (*calculation: ‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa = (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa)›*) have no_coeff: "poly.coeff (?to_Poly compress_x) xa = ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa)" by auto show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))›*) unfolding compress_x_def (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) (map (compress d ∘ to_int_mod_ring) (coeffs (of_qr x)))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))›*) by (metis compress_x_def (*‹(compress_x::int list) = map (compress (d::nat) ∘ to_int_mod_ring) (coeffs (of_qr (x::'a qr)))›*) map_map (*‹map (?f::?'b ⇒ ?'a) (map (?g::?'c ⇒ ?'b) (?xs::?'c list)) = map (?f ∘ ?g) ?xs›*) no_coeff (*‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress (d::nat)) (compress_x::int list))) (xa::nat) = (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr (x::'a qr)) xa)›*)) next (*goal: ‹⟦⋀as. coeffs (Poly as) = strip_while ((=) 0) as; ¬ xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))⟧ ⟹ abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))›*) case False (*‹¬ xa < length (coeffs (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)))›*) then have "poly.coeff (?to_Poly compress_x) xa = 0" by (metis Poly_coeffs (*‹Poly (coeffs (?p::?'a poly)) = ?p›*) coeff_Poly_eq (*‹poly.coeff (Poly (?xs::?'a list)) = nth_default (0::?'a) ?xs›*) nth_default_def (*‹nth_default (?dflt::?'a) (?xs::?'a list) (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?dflt)›*)) moreover have "((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) = 0" proof (cases "poly.coeff (of_qr x) xa = 0") (*goals: 1. ‹poly.coeff (of_qr x) xa = 0 ⟹ (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) = 0› 2. ‹poly.coeff (of_qr x) xa ≠ 0 ⟹ (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) = 0›*) case True (*‹poly.coeff (of_qr x) xa = 0›*) then show "?thesis" (*goal: ‹(of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) = 0›*) using compress_zero (*‹compress ?d 0 = 0›*) decompress_zero (*‹decompress ?d 0 = 0›*) by auto next (*goal: ‹poly.coeff (of_qr x) xa ≠ 0 ⟹ (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) = 0›*) case False (*‹poly.coeff (of_qr x) xa ≠ 0›*) then show "?thesis" (*goal: ‹(of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) = 0›*) proof (subst ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*), goal_cases) (*goals: 1. ‹⟦poly.coeff (of_qr x) xa ≠ 0; (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) ≠ 0⟧ ⟹ False› 2. ‹poly.coeff (of_qr x) xa ≠ 0 ⟹ True›*) case 1 (*‹poly.coeff (of_qr x) xa ≠ 0› ‹(of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) ≠ 0›*) then have "poly.coeff (?to_Poly compress_x) xa ≠ 0" apply (subst coeff_Poly (*‹poly.coeff (Poly ?xs) ?i = nth_default 0 ?xs ?i›*)) (*goal: ‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa ≠ 0›*) by (metis (no_types, lifting) comp_apply (*‹((?f::?'b ⇒ ?'a) ∘ (?g::?'c ⇒ ?'b)) (?x::?'c) = ?f (?g ?x)›*) compress_x_def (*‹(compress_x::int list) = map (compress (d::nat) ∘ to_int_mod_ring) (coeffs (of_qr (x::'a qr)))›*) compress_zero (*‹compress (?d::nat) (0::int) = (0::int)›*) decompress_zero (*‹decompress (?d::nat) (0::int) = (0::int)›*) map_map (*‹map (?f::?'b ⇒ ?'a) (map (?g::?'c ⇒ ?'b) (?xs::?'c list)) = map (?f ∘ ?g) ?xs›*) nth_default_coeffs_eq (*‹nth_default (0::?'a) (coeffs (?p::?'a poly)) = poly.coeff ?p›*) nth_default_map_eq (*‹(?f::?'b ⇒ ?'a) (?dflt'::?'b) = (?dflt::?'a) ⟹ nth_default ?dflt (map ?f (?xs::?'b list)) (?n::nat) = ?f (nth_default ?dflt' ?xs ?n)›*) of_int_mod_ring_hom.hom_zero (*‹of_int_mod_ring (0::int) = (0::?'a mod_ring)›*) to_int_mod_ring_hom.hom_zero (*‹to_int_mod_ring (0::?'a mod_ring) = (0::int)›*)) then show "?case" (*goal: ‹False›*) using ‹poly.coeff (?to_Poly compress_x) xa = 0› (*‹poly.coeff (Poly (map (of_int_mod_ring ∘ decompress d) compress_x)) xa = 0›*) by auto qed (auto) (*solved the remaining goal: ‹poly.coeff (of_qr x) xa ≠ 0 ⟹ True›*) qed ultimately show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (Poly (map of_int_mod_ring (map (decompress d) compress_x))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))›*) by auto qed also (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q (poly.coeff (of_qr x) xa - (of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa))›*) have "… = abs_infty_q ( ((of_int_mod_ring :: int ⇒ 'a mod_ring) ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - poly.coeff (of_qr x) xa)" using abs_infty_q_minus (*‹abs_infty_q (- ?x) = abs_infty_q ?x›*) by (metis minus_diff_eq (*‹- ((?a::?'a) - (?b::?'a)) = ?b - ?a›*)) also (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = abs_infty_q ((of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - poly.coeff (of_qr x) xa)›*) have "… = ¦((decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- q¦" unfolding abs_infty_q_def (*goal: ‹¦to_int_mod_ring ((of_int_mod_ring ∘ decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - poly.coeff (of_qr x) xa) mod+- q¦ = ¦((decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- q¦›*) using to_int_mod_ring_of_int_mod_ring (*‹⟦0 ≤ ?x; ?x < int CARD(?'a)⟧ ⟹ to_int_mod_ring (of_int_mod_ring ?x) = ?x›*) by (smt (verit, best) CARD_a (*‹int CARD('a) = q›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) mod_plus_minus_def (*‹?m mod+- ?b = (if ⌊real_of_int ?b / 2⌋ < ?m mod ?b then ?m mod ?b - ?b else ?m mod ?b)›*) of_int_diff (*‹of_int (?w - ?z) = of_int ?w - of_int ?z›*) of_int_mod_ring.rep_eq (*‹Rep_mod_ring (of_int_mod_ring ?x) = ?x mod int CARD(?'a)›*) of_int_mod_ring_to_int_mod_ring (*‹of_int_mod_ring (to_int_mod_ring ?x) = ?x›*) of_int_of_int_mod_ring (*‹of_int = of_int_mod_ring›*)) also (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) = ¦((decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- q¦›*) have "… ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))" proof (-) (*goal: ‹¦((decompress (d::nat) ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr (x::'a qr)) (xa::nat)) - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- (q::int)¦ ≤ round (real_of_int q / real_of_int ((2::int) ^ (d + (1::nat))))›*) have range_to_int_mod_ring: "to_int_mod_ring (poly.coeff (of_qr x) xa) ∈ {0..<q}" using to_int_mod_ring_range (*‹range to_int_mod_ring = {0::int..<q::int}›*) by auto then show "?thesis" (*goal: ‹¦((decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) unfolding abs_infty_q_def Let_def (*goal: ‹¦((decompress d ∘ compress d ∘ to_int_mod_ring) (poly.coeff (of_qr x) xa) - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) using decompress_compress[OF range_to_int_mod_ring assms] (*‹let x' = decompress d (compress d (to_int_mod_ring (poly.coeff (of_qr x) xa))) in ¦(x' - to_int_mod_ring (poly.coeff (of_qr x) xa)) mod+- q¦ ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) by simp qed finally (*calculation: ‹abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (Poly (map (of_int_mod_ring ∘ decompress d) (map to_int_mod_ring (coeffs (of_qr (to_qr (Poly (map of_int_mod_ring compress_x)))))))))) xa) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) have "abs_infty_q (poly.coeff (of_qr x) xa - poly.coeff (of_qr (to_qr (?to_Poly (?telescope compress_x)))) xa ) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))" by auto then show "?thesis" (*goal: ‹abs_infty_q (poly.coeff (of_qr (x - decompress_poly d (compress_poly d x))) xa) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) unfolding compress_x_def decompress_poly_def compress_poly_def (*goal: ‹abs_infty_q (poly.coeff (of_qr (x - (to_qr ∘ Poly ∘ map of_int_mod_ring ∘ map (decompress d) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) ((to_qr ∘ Poly ∘ map of_int_mod_ring ∘ map (compress d) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) xa) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) by (auto simp add: o_assoc (*‹?f ∘ (?g ∘ ?h) = ?f ∘ ?g ∘ ?h›*)) qed moreover have finite: "finite (range (abs_infty_q ∘ poly.coeff (of_qr (x - ?x'))))" by (metis finite_Max (*‹finite (range (λxa. abs_infty_q (poly.coeff (of_qr ?x) xa)))›*) image_comp (*‹?f ` ?g ` ?r = (?f ∘ ?g) ` ?r›*) image_image (*‹?f ` ?g ` ?A = (λx. ?f (?g x)) ` ?A›*)) ultimately show "?thesis" (*goal: ‹let x'::'a qr = decompress_poly (d::nat) (compress_poly d (x::'a qr)) in abs_infty_poly (x - x') ≤ round (real_of_int (q::int) / real_of_int ((2::int) ^ (d + (1::nat))))›*) unfolding abs_infty_poly_def (*goal: ‹let x' = decompress_poly d (compress_poly d x) in Max (range (abs_infty_q ∘ poly.coeff (of_qr (x - x')))) ≤ round (real_of_int q / real_of_int (2 ^ (d + 1)))›*) using Max_le_iff[OF finite] (*‹range (abs_infty_q ∘ poly.coeff (of_qr (x - decompress_poly d (compress_poly d x)))) ≠ {} ⟹ (Max (range (abs_infty_q ∘ poly.coeff (of_qr (x - decompress_poly d (compress_poly d x))))) ≤ ?x) = (∀a∈range (abs_infty_q ∘ poly.coeff (of_qr (x - decompress_poly d (compress_poly d x)))). a ≤ ?x)›*) by auto qed text ‹More properties of compress and decompress, used for returning message at the end.› lemma compress_1: shows "compress 1 x ∈ {0,1}" unfolding compress_def (*goal: ‹round (real_of_int (2 ^ 1 * x) / real_of_int q) mod 2 ^ 1 ∈ {0, 1}›*) by auto lemma compress_poly_1: shows "∀i. poly.coeff (of_qr (compress_poly 1 x)) i ∈ {0,1}" proof (-) (*goal: ‹∀i::nat. poly.coeff (of_qr (compress_poly (1::nat) (x::'a::qr_spec qr))) i ∈ {0::'a::qr_spec mod_ring, 1::'a::qr_spec mod_ring}›*) have "poly.coeff (of_qr (compress_poly 1 x)) i ∈ {0,1}" for i proof (-) (*goal: ‹poly.coeff (of_qr (compress_poly (1::nat) (x::'a qr))) (i::nat) ∈ {0::'a mod_ring, 1::'a mod_ring}›*) have "set (map (compress 1) ((map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) ⊆ {0,1}" using compress_1 (*‹compress 1 ?x ∈ {0, 1}›*) by auto then have "set ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x) ⊆ {0,1}" (is "set (?compressed_1) ⊆ _") by auto then have "set (map (of_int_mod_ring :: int ⇒ 'a mod_ring) ?compressed_1) ⊆ {0,1}" (is "set (?of_int_compressed_1)⊆_") by (smt (verit, best) imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) of_int_mod_ring_hom.hom_zero (*‹of_int_mod_ring 0 = 0›*) of_int_mod_ring_to_int_mod_ring (*‹of_int_mod_ring (to_int_mod_ring ?x) = ?x›*) set_map (*‹set (map ?f ?xs) = ?f ` set ?xs›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) to_int_mod_ring_hom.hom_one (*‹to_int_mod_ring 1 = 1›*)) then have "nth_default 0 (?of_int_compressed_1) i ∈ {0,1}" by (smt (verit, best) comp_apply (*‹((?f::?'b ⇒ ?'a) ∘ (?g::?'c ⇒ ?'b)) (?x::?'c) = ?f (?g ?x)›*) compress_1 (*‹compress (1::nat) (?x::int) ∈ {0::int, 1::int}›*) compress_zero (*‹compress (?d::nat) (0::int) = (0::int)›*) insert_iff (*‹((?a::?'a) ∈ insert (?b::?'a) (?A::?'a set)) = (?a = ?b ∨ ?a ∈ ?A)›*) nth_default_map_eq (*‹(?f::?'b ⇒ ?'a) (?dflt'::?'b) = (?dflt::?'a) ⟹ nth_default ?dflt (map ?f (?xs::?'b list)) (?n::nat) = ?f (nth_default ?dflt' ?xs ?n)›*) of_int_mod_ring_hom.hom_zero (*‹of_int_mod_ring (0::int) = (0::?'a mod_ring)›*) of_int_mod_ring_to_int_mod_ring (*‹of_int_mod_ring (to_int_mod_ring (?x::?'a mod_ring)) = ?x›*) singleton_iff (*‹((?b::?'a) ∈ {?a::?'a}) = (?b = ?a)›*) to_int_mod_ring_hom.hom_one (*‹to_int_mod_ring (1::?'a mod_ring) = (1::int)›*)) moreover have "Poly (?of_int_compressed_1) = Poly (?of_int_compressed_1) mod qr_poly" proof (-) (*goal: ‹Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) = Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) mod qr_poly›*) have "degree (Poly (?of_int_compressed_1)) < deg_qr TYPE('a)" proof (cases "Poly ?of_int_compressed_1 ≠ 0") (*goals: 1. ‹Poly (map of_int_mod_ring ((map (compress (1::nat)) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) (x::'a qr))) ≠ (0::'a mod_ring poly) ⟹ degree (Poly (map of_int_mod_ring ((map (compress (1::nat)) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < deg_qr TYPE('a)› 2. ‹¬ Poly (map of_int_mod_ring ((map (compress (1::nat)) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) (x::'a qr))) ≠ (0::'a mod_ring poly) ⟹ degree (Poly (map of_int_mod_ring ((map (compress (1::nat)) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < deg_qr TYPE('a)›*) case True (*‹Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) ≠ 0›*) have "degree (Poly ?of_int_compressed_1) ≤ length (map (of_int_mod_ring :: int ⇒ 'a mod_ring) ?compressed_1) - 1" using deg_Poly'[OF True] (*‹degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) ≤ length (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) - 1›*) by simp also (*calculation: ‹degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) ≤ length (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) - 1›*) have "… = length ((coeffs ∘ of_qr) x) - 1" by simp also (*calculation: ‹degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) ≤ length ((coeffs ∘ of_qr) x) - 1›*) have "… < n" unfolding comp_def (*goal: ‹int (length (coeffs (of_qr x)) - 1) < n›*) using length_coeffs_of_qr (*‹length (coeffs (of_qr ?x)) < Suc (nat n)›*) by (metis deg_qr_n (*‹int (deg_qr TYPE('a)) = n›*) deg_of_qr (*‹degree (of_qr ?x) < deg_qr TYPE(?'a)›*) degree_eq_length_coeffs (*‹degree ?p = length (coeffs ?p) - 1›*) nat_int (*‹nat (int ?n) = ?n›*) zless_nat_conj (*‹(nat ?w < nat ?z) = (0 < ?z ∧ ?w < ?z)›*)) finally (*calculation: ‹(⋀xa y. xa < y ⟹ length ((coeffs ∘ of_qr) x) - 1 < length ((coeffs ∘ of_qr) x) - 1) ⟹ degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < length ((coeffs ∘ of_qr) x) - 1›*) have "degree (Poly ?of_int_compressed_1) < n" using True (*‹Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) ≠ 0›*) ‹int (length ((coeffs ∘ of_qr) x) - 1) < n› (*‹int (length ((coeffs ∘ of_qr) x) - 1) < n›*) deg_Poly' (*‹Poly ?xs ≠ 0 ⟹ degree (Poly ?xs) ≤ length ?xs - 1›*) by fastforce then show "?thesis" (*goal: ‹degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < deg_qr TYPE('a)›*) using deg_qr_n (*‹int (deg_qr TYPE('a)) = (n::int)›*) by simp next (*goal: ‹¬ Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) ≠ 0 ⟹ degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < deg_qr TYPE('a)›*) case False (*‹¬ Poly (map of_int_mod_ring ((map (compress (1::nat)) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) (x::'a::qr_spec qr))) ≠ (0::'a::qr_spec mod_ring poly)›*) then show "?thesis" (*goal: ‹degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < deg_qr TYPE('a)›*) using deg_qr_pos (*‹0 < deg_qr TYPE(?'a)›*) by auto qed then show "?thesis" (*goal: ‹Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) = Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) mod qr_poly›*) using deg_mod_qr_poly[of "Poly (?of_int_compressed_1)", symmetric] (*‹degree (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x))) < deg_qr TYPE('a) ⟹ Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) = Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) mod qr_poly›*) by auto qed ultimately show "?thesis" (*goal: ‹poly.coeff (of_qr (compress_poly 1 x)) i ∈ {0, 1}›*) unfolding compress_poly_def comp_def (*goal: ‹poly.coeff (of_qr (to_qr (Poly (map of_int_mod_ring (map (compress 1) (map to_int_mod_ring (coeffs (of_qr x)))))))) i ∈ {0, 1}›*) using of_qr_to_qr[of "Poly (?of_int_compressed_1)"] (*‹of_qr (to_qr (Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)))) = Poly (map of_int_mod_ring ((map (compress 1) ∘ map to_int_mod_ring ∘ coeffs ∘ of_qr) x)) mod qr_poly›*) by auto qed then show "?thesis" (*goal: ‹∀i::nat. poly.coeff (of_qr (compress_poly (1::nat) (x::'a::qr_spec qr))) i ∈ {0::'a::qr_spec mod_ring, 1::'a::qr_spec mod_ring}›*) by auto qed end lemma of_int_mod_ring_mult: "of_int_mod_ring (a*b) = of_int_mod_ring a * of_int_mod_ring b" unfolding of_int_mod_ring_def (*goal: ‹(id ---> Abs_mod_ring) (λx::int. x mod int CARD('a::finite)) ((a::int) * (b::int)) = (id ---> Abs_mod_ring) (λx::int. x mod int CARD('a::finite)) a * (id ---> Abs_mod_ring) (λx::int. x mod int CARD('a::finite)) b›*) by (metis (mono_tags, lifting) Rep_mod_ring_inverse (*‹Abs_mod_ring (Rep_mod_ring ?x) = ?x›*) mod_mult_eq (*‹?a mod ?c * (?b mod ?c) mod ?c = ?a * ?b mod ?c›*) of_int_mod_ring.rep_eq (*‹Rep_mod_ring (of_int_mod_ring ?x) = ?x mod int CARD(?'a)›*) of_int_mod_ring_def (*‹of_int_mod_ring ≡ (id ---> Abs_mod_ring) (λx. x mod int CARD(?'a))›*) times_mod_ring.rep_eq (*‹Rep_mod_ring (?x * ?xa) = Rep_mod_ring ?x * Rep_mod_ring ?xa mod int CARD(?'a)›*)) context kyber_spec begin lemma decompress_1: assumes "a∈{0,1}" shows "decompress 1 a = round(real_of_int q/2) * a" unfolding decompress_def (*goal: ‹round (real_of_int q * real_of_int a / real_of_int 2 ^ 1) = round (real_of_int q / 2) * a›*) using assms (*‹a ∈ {0, 1}›*) by auto lemma decompress_poly_1: assumes "∀i. poly.coeff (of_qr x) i ∈ {0,1}" shows "decompress_poly 1 x = to_module (round((real_of_int q)/2)) * x" proof (-) (*goal: ‹decompress_poly (1::nat) (x::'a qr) = to_module (round (real_of_int (q::int) / (2::real))) * x›*) have "poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_module (round((real_of_int q)/2)) * x)) i" for i proof (-) (*goal: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * x)) i›*) have "set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0,1}" (is "set (?int_coeffs) ⊆ _") proof (-) (*goal: ‹set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}›*) have "set (coeffs (of_qr x)) ⊆ {0,1}" using assms (*‹∀i. poly.coeff (of_qr x) i ∈ {0, 1}›*) by (meson forall_coeffs_conv (*‹?P 0 ⟹ (∀n. ?P (poly.coeff ?p n)) = (∀c∈set (coeffs ?p). ?P c)›*) insert_iff (*‹(?a ∈ insert ?b ?A) = (?a = ?b ∨ ?a ∈ ?A)›*) subset_code( (*‹(set ?xs ⊆ ?B) = (∀x∈set ?xs. x ∈ ?B)›*) 1)) then show "?thesis" (*goal: ‹set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}›*) by auto qed then have "map (decompress 1) (?int_coeffs) = map ((*) (round (real_of_int q/2))) (?int_coeffs)" proof (induct "?int_coeffs") (*goals: 1. ‹⟦[] = map to_int_mod_ring (coeffs (of_qr x)); set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}⟧ ⟹ map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x))) = map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))› 2. ‹⋀a xa. ⟦⟦xa = map to_int_mod_ring (coeffs (of_qr x)); set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}⟧ ⟹ map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x))) = map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x))); a # xa = map to_int_mod_ring (coeffs (of_qr x)); set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}⟧ ⟹ map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x))) = map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))›*) case (Cons a xa) (*‹⟦xa = map to_int_mod_ring (coeffs (of_qr x)); set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}⟧ ⟹ map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x))) = map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))› ‹a # xa = map to_int_mod_ring (coeffs (of_qr x))› ‹set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}›*) then show "?case" (*goal: ‹map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x))) = map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))›*) using decompress_1 (*‹?a ∈ {0, 1} ⟹ decompress 1 ?a = round (real_of_int q / 2) * ?a›*) by (meson map_eq_conv (*‹(map ?f ?xs = map ?g ?xs) = (∀x∈set ?xs. ?f x = ?g x)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) qed (simp) (*solved the remaining goal: ‹⟦[] = map to_int_mod_ring (coeffs (of_qr x)); set (map to_int_mod_ring (coeffs (of_qr x))) ⊆ {0, 1}⟧ ⟹ map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x))) = map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))›*) then have "poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_qr (Poly (map of_int_mod_ring (map (λa. round(real_of_int q/2) * a) (?int_coeffs)))))) i" unfolding decompress_poly_def comp_def (*goal: ‹poly.coeff (of_qr (to_qr (Poly (map of_int_mod_ring (map (decompress 1) (map to_int_mod_ring (coeffs (of_qr x)))))))) i = poly.coeff (of_qr (to_qr (Poly (map of_int_mod_ring (map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))))))) i›*) by presburger also (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_qr (Poly (map of_int_mod_ring (map ((*) (round (real_of_int q / 2))) (map to_int_mod_ring (coeffs (of_qr x)))))))) i›*) have "… = poly.coeff (of_qr (to_qr (Poly (map (λa. of_int_mod_ring ((round(real_of_int q/2)) * a)) (?int_coeffs))))) i" using map_map[of of_int_mod_ring "((*) (round (real_of_int q/2)))"] (*‹map of_int_mod_ring (map ((*) (round (real_of_int (q::int) / (2::real)))) (?xs::int list)) = map (of_int_mod_ring ∘ (*) (round (real_of_int q / (2::real)))) ?xs›*) by (smt (z3) map_eq_conv (*‹(map ?f ?xs = map ?g ?xs) = (∀x∈set ?xs. ?f x = ?g x)›*) o_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*)) also (*calculation: ‹poly.coeff (of_qr (decompress_poly (1::nat) (x::'a qr))) (i::nat) = poly.coeff (of_qr (to_qr (Poly (map (λa::int. of_int_mod_ring (round (real_of_int (q::int) / (2::real)) * a)) (map to_int_mod_ring (coeffs (of_qr x))))))) i›*) have "… = poly.coeff (of_qr (to_qr (Poly (map (λa. of_int_mod_ring (round(real_of_int q/2)) * of_int_mod_ring a) (?int_coeffs))))) i" by (simp add: of_int_mod_ring_mult[of "(round(real_of_int q/2))"] (*‹of_int_mod_ring (round (real_of_int q / 2) * ?b) = of_int_mod_ring (round (real_of_int q / 2)) * of_int_mod_ring ?b›*)) also (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_qr (Poly (map (λa. of_int_mod_ring (round (real_of_int q / 2)) * of_int_mod_ring a) (map to_int_mod_ring (coeffs (of_qr x))))))) i›*) have "… = poly.coeff (of_qr (to_qr (Poly (map (λa. of_int_mod_ring (round(real_of_int q/2)) * a) (map of_int_mod_ring (?int_coeffs)))))) i" using map_map[symmetric, of "(λa. of_int_mod_ring (round (real_of_int q/2)) * a ::'a mod_ring)" "of_int_mod_ring"] (*‹map ((*) (of_int_mod_ring (round (real_of_int q / 2))) ∘ of_int_mod_ring) ?xs = map ((*) (of_int_mod_ring (round (real_of_int q / 2)))) (map of_int_mod_ring ?xs)›*) unfolding comp_def (*goal: ‹poly.coeff (of_qr (to_qr (Poly (map (λa::int. of_int_mod_ring (round (real_of_int (q::int) / (2::real))) * of_int_mod_ring a) (map to_int_mod_ring (coeffs (of_qr (x::'a qr)))))))) (i::nat) = poly.coeff (of_qr (to_qr (Poly (map ((*) (of_int_mod_ring (round (real_of_int q / (2::real))))) (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr x)))))))) i›*) by presburger also (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_qr (Poly (map ((*) (of_int_mod_ring (round (real_of_int q / 2)))) (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr x)))))))) i›*) have "… = poly.coeff (of_qr (to_qr (Polynomial.smult (of_int_mod_ring (round(real_of_int q/2))) (Poly (map of_int_mod_ring (?int_coeffs)))))) i" using smult_Poly[symmetric, of "(of_int_mod_ring (round (real_of_int q/2)))"] (*‹Poly (map ((*) (of_int_mod_ring (round (real_of_int q / 2)))) ?xs) = Polynomial.smult (of_int_mod_ring (round (real_of_int q / 2))) (Poly ?xs)›*) by metis also (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_qr (Polynomial.smult (of_int_mod_ring (round (real_of_int q / 2))) (Poly (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr x)))))))) i›*) have "… = poly.coeff (of_qr ((to_module (round (real_of_int q/2)) * to_qr (Poly (map of_int_mod_ring (?int_coeffs)))))) i" unfolding to_module_def (*goal: ‹poly.coeff (of_qr (to_qr (Polynomial.smult (of_int_mod_ring (round (real_of_int (q::int) / (2::real)))) (Poly (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr (x::'a::qr_spec qr))))))))) (i::nat) = poly.coeff (of_qr (to_qr (Poly [of_int_mod_ring (round (real_of_int q / (2::real)))]) * to_qr (Poly (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr x))))))) i›*) using to_qr_smult_to_module[of "of_int_mod_ring (round (real_of_int q/2))"] (*‹to_qr (Polynomial.smult (of_int_mod_ring (round (real_of_int q / 2))) ?p) = to_qr (Poly [of_int_mod_ring (round (real_of_int q / 2))]) * to_qr ?p›*) by metis also (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr x))))))) i›*) have "… = poly.coeff (of_qr (to_module (round (real_of_int q/2)) * to_qr (Poly (coeffs (of_qr x)))))i" apply (subst map_map[of of_int_mod_ring to_int_mod_ring] (*‹map of_int_mod_ring (map to_int_mod_ring ?xs) = map (of_int_mod_ring ∘ to_int_mod_ring) ?xs›*)) (*goal: ‹poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (map of_int_mod_ring (map to_int_mod_ring (coeffs (of_qr x))))))) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (coeffs (of_qr x))))) i›*) apply (unfold comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) (*goal: ‹poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (map (of_int_mod_ring ∘ to_int_mod_ring) (coeffs (of_qr x)))))) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (coeffs (of_qr x))))) i›*) apply (subst of_int_mod_ring_to_int_mod_ring (*‹of_int_mod_ring (to_int_mod_ring ?x) = ?x›*)) (*goal: ‹poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (map (λx. of_int_mod_ring (to_int_mod_ring x)) (coeffs (of_qr x)))))) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (coeffs (of_qr x))))) i›*) by auto also (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (coeffs (of_qr x))))) i›*) have "… = poly.coeff (of_qr (to_module (round (real_of_int q/2)) * x))i" apply (subst Poly_coeffs (*‹Poly (coeffs ?p) = ?p›*)) (*goal: ‹poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (Poly (coeffs (of_qr x))))) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * x)) i›*) apply (subst to_qr_of_qr (*‹to_qr (of_qr (?x::?'a qr)) = ?x›*)) (*goal: ‹poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * to_qr (of_qr x))) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * x)) i›*) by simp finally (*calculation: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * x)) i›*) show "?thesis" (*goal: ‹poly.coeff (of_qr (decompress_poly 1 x)) i = poly.coeff (of_qr (to_module (round (real_of_int q / 2)) * x)) i›*) by auto qed then have eq: "of_qr (decompress_poly 1 x) = of_qr (to_module (round((real_of_int q)/2)) * x)" by (simp add: poly_eq_iff (*‹(?p = ?q) = (∀n. poly.coeff ?p n = poly.coeff ?q n)›*)) show "?thesis" (*goal: ‹decompress_poly 1 x = to_module (round (real_of_int q / 2)) * x›*) using arg_cong[OF eq, of "to_qr"] (*‹to_qr (of_qr (decompress_poly 1 x)) = to_qr (of_qr (to_module (round (real_of_int q / 2)) * x))›*) to_qr_of_qr[of "decompress_poly 1 x"] (*‹to_qr (of_qr (decompress_poly 1 x)) = decompress_poly 1 x›*) to_qr_of_qr[of "to_module (round (real_of_int q/2)) * x"] (*‹to_qr (of_qr (to_module (round (real_of_int q / 2)) * x)) = to_module (round (real_of_int q / 2)) * x›*) by auto qed end text ‹Compression and decompression for vectors.› definition map_vector :: "('b ⇒ 'c) ⇒ ('b, 'n) vec ⇒ ('c, 'n::finite) vec" where "map_vector f v = (χ i. f (vec_nth v i))" context kyber_spec begin text ‹Compression and decompression of vectors in ‹ℤ_q[X]/(X^n+1)›.› definition compress_vec :: "nat ⇒ ('a qr, 'k) vec ⇒ ('a qr, 'k) vec" where "compress_vec d = map_vector (compress_poly d)" definition decompress_vec :: "nat ⇒ ('a qr, 'k) vec ⇒ ('a qr, 'k) vec" where "decompress_vec d = map_vector (decompress_poly d)" end end
{ "path": "afp-2025-02-12/thys/CRYSTALS-Kyber/Compress.thy", "repo": "afp-2025-02-12", "sha": "c4c76aee167edf0b7ec7fa8ea570c0a77a83fa017a79ca8f72e1366779887310" }
theory Surprise_Paradox imports Incompleteness.Goedel_I Incompleteness.Pseudo_Coding begin text ‹ The Surprise Paradox comes in a few variations, one being the following: \begin{quote} A judge sentences a felon to death by hanging, to be executed at noon the next week, Monday to Friday. As an extra punishment, the judge does not disclose the day of the hanging and promises the felon that it will come at a surprise. The felon, probably a logician, then concludes that he cannot be hanged on Friday, as by then it would not longer be a surprise. Using this fact and similar reasoning, he cannot be hanged on Thursday, and so on. He reaches the conclusion that he cannot be hanged at all, and contently returns to his cell. Wednesday, at noon, the hangman comes to the very surprised felon, and executes him. \end{quote} Obviously, something is wrong here: Does the felon reason wrongly? It looks about right. Or is the judge lying? But his prediction became true! It is an interesting exercise to try to phrase the Surprise Paradox in a rigorous manner, and see this might clarify things. In 1964, Frederic Fitch suggested a formulation that refines the notion of ``surprise'' as ``cannot be proven from the given assumptions'' \<^cite>‹Fitch›. To formulate that, we need propositions that reference their own provability, so just as Fitch builds on Gödel's work, we build on Paulson's formalisation of Gödel's incompleteness theorems in Isabelle \<^cite>‹Incompleteness›. › section ‹Excluded or› text ‹Although the proof goes through with regular disjunction, Fitch phrases the judge's proposition using exclusive or, so we add syntax for that.› abbreviation Xor :: "fm ⇒ fm ⇒ fm" (infix "XOR" 120) where "Xor A B ≡ (A OR B) AND ((Neg A) OR (Neg B))" section ‹Formulas with variables› text ‹ In Paulson's formalisation of terms and formulas, only terms carry variables. This is sufficient for his purposes, because the proposition that is being diagonalised needs itself as a parameter to @{term_type PfP}, which does take a term (which happens to be a quoted formula). In order to stay close to Fitch, we need the diagonalised proposition to occur deeper in a quotation of a few logical conjunctions. Therefore, we build a small theory of formulas with variables (``holed'' formulas). These support substituting a formula for a variable, this substitution commutes with quotation, and closed holed formulas can be converted to regular formulas. In our application, we do not need holes under an quantifier, which greatly simplifies things here. In particular, we can use @{command datatype} and @{command fun}. › datatype hfm = HVar name | HFm fm | HDisj hfm hfm (infixr "HOR" 130) | HNeg hfm abbreviation HImp :: "hfm ⇒ hfm ⇒ hfm" (infixr "HIMP" 125) where "HImp A B ≡ HDisj (HNeg A) B" definition HConj :: "hfm ⇒ hfm ⇒ hfm" (infixr "HAND" 135) where "HConj A B ≡ HNeg (HDisj (HNeg A) (HNeg B))" abbreviation HXor :: "hfm ⇒ hfm ⇒ hfm" (infix "HXOR" 120) where "HXor A B ≡ (A HOR B) HAND (HNeg A HOR HNeg B)" fun subst_hfm :: "hfm ⇒ name ⇒ fm ⇒ hfm" ("_'(_:::=_')" [1000, 0, 0] 200) where "(HVar name)(i:::=x) = (if i = name then HFm x else HVar name)" | "(HDisj A B)(i:::=x) = HDisj (A(i:::=x)) (B(i:::=x))" | "(HNeg A)(i:::=x) = HNeg (A(i:::=x))" | "(HFm A)(i:::=x) = HFm A" lemma subst_hfml_Conj[simp]: "(HConj A B)(i:::=x) = HConj (A(i:::=x)) (B(i:::=x))" unfolding HConj_def (*goal: ‹(HNeg (A HIMP HNeg B))(i:::=x) = HNeg (A(i:::=x) HIMP HNeg (B(i:::=x)))›*) by simp instantiation hfm :: quot begin fun quot_hfm :: "hfm ⇒ tm" where "quot_hfm (HVar name) = (Var name)" | "quot_hfm (HFm A) = «A»" | "quot_hfm (HDisj A B) = HPair (HTuple 3) (HPair (quot_hfm A) (quot_hfm B))" | "quot_hfm (HNeg A) = HPair (HTuple 4) (quot_hfm A)" instance .. end lemma subst_quot_hfm[simp]: "subst i «P» «A» = «A(i:::=P)»" apply (induction A) (*goals: 1. ‹⋀x::name. subst (i::name) «P::fm» «HVar x» = «(HVar x)(i:::=P)»› 2. ‹⋀x::fm. subst (i::name) «P::fm» «HFm x» = «(HFm x)(i:::=P)»› 3. ‹⋀(A1::hfm) A2::hfm. ⟦subst (i::name) «P::fm» «A1» = «A1(i:::=P)»; subst i «P» «A2» = «A2(i:::=P)»⟧ ⟹ subst i «P» «A1 HOR A2» = «(A1 HOR A2)(i:::=P)»› 4. ‹⋀A::hfm. subst (i::name) «P::fm» «A» = «A(i:::=P)» ⟹ subst i «P» «HNeg A» = «(HNeg A)(i:::=P)»› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . fun hfm_to_fm :: "hfm ⇒ fm" where "hfm_to_fm (HVar name) = undefined" | "hfm_to_fm (HFm A) = A" | "hfm_to_fm (HDisj A B) = Disj (hfm_to_fm A) (hfm_to_fm B)" | "hfm_to_fm (HNeg A) = Neg (hfm_to_fm A)" lemma hfm_to_fm_Conj[simp]: "hfm_to_fm (HConj A B) = Conj (hfm_to_fm A) (hfm_to_fm B)" unfolding HConj_def Conj_def (*goal: ‹hfm_to_fm (HNeg (A HIMP HNeg B)) = Neg (hfm_to_fm A IMP Neg (hfm_to_fm B))›*) by simp fun closed_hfm :: "hfm ⇒ bool" where "closed_hfm (HVar name) ⟷ False" | "closed_hfm (HFm A) ⟷ True" | "closed_hfm (HDisj A B) ⟷ closed_hfm A ∧ closed_hfm B" | "closed_hfm (HNeg A) ⟷ closed_hfm A" lemma closed_hfm_Conj[simp]: "closed_hfm (HConj A B) ⟷ closed_hfm A ∧ closed_hfm B" unfolding HConj_def (*goal: ‹closed_hfm (HNeg (A HIMP HNeg B)) = (closed_hfm A ∧ closed_hfm B)›*) by simp lemma quot_closed_hfm[simp]: "closed_hfm A ⟹ «A» = «hfm_to_fm A»" apply (induction A) (*goals: 1. ‹⋀x. closed_hfm (HVar x) ⟹ «HVar x» = «hfm_to_fm (HVar x)»› 2. ‹⋀x. closed_hfm (HFm x) ⟹ «HFm x» = «hfm_to_fm (HFm x)»› 3. ‹⋀A1 A2. ⟦closed_hfm A1 ⟹ «A1» = «hfm_to_fm A1»; closed_hfm A2 ⟹ «A2» = «hfm_to_fm A2»; closed_hfm (A1 HOR A2)⟧ ⟹ «A1 HOR A2» = «hfm_to_fm (A1 HOR A2)»› 4. ‹⋀A. ⟦closed_hfm A ⟹ «A» = «hfm_to_fm A»; closed_hfm (HNeg A)⟧ ⟹ «HNeg A» = «hfm_to_fm (HNeg A)»› discuss goal 1*) apply ((auto simp add: quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*))[1]) (*discuss goal 2*) apply ((auto simp add: quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*))[1]) (*discuss goal 3*) apply ((auto simp add: quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*))[1]) (*discuss goal 4*) apply ((auto simp add: quot_fm_def (*‹«?A::fm» = quot_dbfm (trans_fm [] ?A)›*))[1]) (*proven 4 subgoals*) . declare quot_hfm.simps[simp del] section ‹Fitch's proof› text ‹ For simplicity, Fitch (and we) restrict the week to two days. Propositions ‹Q₁› and ‹Q₂› represent the propositions that the hanging occurs on the first resp.\@ the second day, but these can obviously be any propositions. › context fixes Q₁ :: fm and Q₂ :: fm assumes Q_closed: "supp Q₁ = {}" "supp Q₂ = {}" begin text ‹ In order to define the judge's proposition, which is self-referential, we apply the usual trick of defining a proposition with a variable, and then using Gödel's diagonalisation lemma. › definition H :: fm where "H = Q₁ AND Neg (PfP «HVar X0 HIMP HFm Q₁») XOR Q₂ AND Neg (PfP «HVar X0 HAND HNeg (HFm Q₁) HIMP (HFm Q₂)»)" definition P where "P = (SOME P. {} ⊢ P IFF H(X0 ::= «P»))" lemma P': "{} ⊢ P IFF H(X0 ::= «P»)" proof (-) (*goal: ‹{} ⊢ local.P IFF local.H(X0::=«local.P»)›*) from diagonal[where α = "H" and i = X0] (*‹(⋀δ::fm. ⟦{} ⊢ δ IFF local.H(X0::=«δ»); supp δ = supp local.H - {atom X0}⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain δ where "{} ⊢ δ IFF H(X0 ::= «δ»)" (*goal: ‹(⋀δ::fm. {} ⊢ δ IFF local.H(X0::=«δ») ⟹ thesis::bool) ⟹ thesis›*) . thus "?thesis" (*goal: ‹{} ⊢ local.P IFF local.H(X0::=«local.P»)›*) unfolding P_def (*goal: ‹{} ⊢ (SOME P. {} ⊢ P IFF local.H(X0::=«P»)) IFF local.H(X0::=«SOME P. {} ⊢ P IFF local.H(X0::=«P»)»)›*) by (rule someI (*‹?P ?x ⟹ ?P (Eps ?P)›*)) qed text ‹ From now on, the lemmas are named after their number in Fitch's paper, and correspond to his statements pleasingly closely. › lemma 7: "{} ⊢ P IFF (Q₁ AND Neg (PfP «P IMP Q₁») XOR Q₂ AND Neg (PfP «P AND Neg Q₁ IMP Q₂»))" using P' (*‹{} ⊢ local.P IFF local.H(X0::=«local.P»)›*) unfolding H_def (*goal: ‹{} ⊢ local.P IFF (Q₁ AND Neg (PfP «local.P IMP Q₁») XOR Q₂ AND Neg (PfP «local.P AND Neg Q₁ IMP Q₂»))›*) by (simp add: Q_closed (*‹supp (Q₁::fm) = {}› ‹supp (Q₂::fm) = {}›*) forget_subst_fm[unfolded fresh_def] (*‹atom (?a::name) ∉ supp (?A::fm) ⟹ ?A(?a::=?x::tm) = ?A›*)) lemmas "7_E" = 7[THEN thin0, THEN Iff_MP_left', OF Conj_E, OF thin2] lemmas propositional_calculus = AssumeH Neg_I Imp_I Conj_E Disj_E ExFalso[OF Neg_E] ExFalso[OF rotate2, OF Neg_E] ExFalso[OF rotate3, OF Neg_E] lemma 8: "{} ⊢ (P AND Neg Q₁) IMP Q₂" apply (intro propositional_calculus (*‹insert ?A ?H ⊢ ?A› ‹insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?A2.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?A3.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?A4.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))) ⊢ ?A5.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))) ⊢ ?A6.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 ?H))))))) ⊢ ?A8.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 ?H)))))))) ⊢ ?A9.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 ?H))))))))) ⊢ ?A10.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 (insert ?A11.0 ?H)))))))))) ⊢ ?A11.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 (insert ?A11.0 (insert ?A12.0 ?H))))))))))) ⊢ ?A12.0› and more 7 facts*) "7_E" (*‹insert (Q₁ AND Neg (PfP «local.P IMP Q₁») OR Q₂ AND Neg (PfP «local.P AND Neg Q₁ IMP Q₂»)) ?H ⊢ ?C ⟹ insert local.P ?H ⊢ ?C›*)) (*goal: ‹{} ⊢ local.P AND Neg Q₁ IMP Q₂›*) by (msorry) lemma 10: "{} ⊢ PfP «(P AND Neg Q₁) IMP Q₂»" using "8" (*‹{} ⊢ local.P AND Neg (Q₁::fm) IMP (Q₂::fm)›*) by (rule proved_imp_proved_PfP (*‹{} ⊢ ?α ⟹ {} ⊢ PfP «?α»›*)) lemmas "10_I" = 10[THEN thin0] lemma 11: "{} ⊢ P IMP Q₁" by (intro propositional_calculus (*‹insert ?A ?H ⊢ ?A› ‹insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?A2.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?A3.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?A4.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))) ⊢ ?A5.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))) ⊢ ?A6.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 ?H))))))) ⊢ ?A8.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 ?H)))))))) ⊢ ?A9.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 ?H))))))))) ⊢ ?A10.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 (insert ?A11.0 ?H)))))))))) ⊢ ?A11.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 (insert ?A11.0 (insert ?A12.0 ?H))))))))))) ⊢ ?A12.0› and more 7 facts*) "7_E" (*‹insert (Q₁ AND Neg (PfP «local.P IMP Q₁») OR Q₂ AND Neg (PfP «local.P AND Neg Q₁ IMP Q₂»)) ?H ⊢ ?C ⟹ insert local.P ?H ⊢ ?C›*) "10_I" (*‹?H ⊢ PfP «local.P AND Neg Q₁ IMP Q₂»›*)) lemma 12: "{} ⊢ PfP «P IMP Q₁»" using "11" (*‹{} ⊢ local.P IMP Q₁›*) by (rule proved_imp_proved_PfP (*‹{} ⊢ ?α ⟹ {} ⊢ PfP «?α»›*)) lemmas "12_I" = 12[THEN thin0] lemma 13: "{} ⊢ Neg P" by (intro propositional_calculus (*‹insert ?A ?H ⊢ ?A› ‹insert ?A1.0 (insert ?A2.0 ?H) ⊢ ?A2.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 ?H)) ⊢ ?A3.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 ?H))) ⊢ ?A4.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 ?H)))) ⊢ ?A5.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 ?H))))) ⊢ ?A6.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 ?H)))))) ⊢ ?A7.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 ?H))))))) ⊢ ?A8.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 ?H)))))))) ⊢ ?A9.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 ?H))))))))) ⊢ ?A10.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 (insert ?A11.0 ?H)))))))))) ⊢ ?A11.0› ‹insert ?A1.0 (insert ?A2.0 (insert ?A3.0 (insert ?A4.0 (insert ?A5.0 (insert ?A6.0 (insert ?A7.0 (insert ?A8.0 (insert ?A9.0 (insert ?A10.0 (insert ?A11.0 (insert ?A12.0 ?H))))))))))) ⊢ ?A12.0› and more 7 facts*) "7_E" (*‹insert (Q₁ AND Neg (PfP «local.P IMP Q₁») OR Q₂ AND Neg (PfP «local.P AND Neg Q₁ IMP Q₂»)) ?H ⊢ ?C ⟹ insert local.P ?H ⊢ ?C›*) "10_I" (*‹?H ⊢ PfP «local.P AND Neg Q₁ IMP Q₂»›*) "12_I" (*‹?H ⊢ PfP «local.P IMP Q₁»›*)) end section ‹Substitution, quoting and V-quoting› text ‹In the end, we did not need the lemma at the end of this section, but it may be useful to others.› lemma trans_tm_forgets: "atom ` set is ♯* t ⟹ trans_tm is t = trans_tm [] t" apply (induct t rule: tm.induct (*‹⟦(?P::tm ⇒ bool) Zero; ⋀x::name. ?P (Var x); ⋀(x1::tm) x2a::tm. ⟦?P x1; ?P x2a⟧ ⟹ ?P (Eats x1 x2a)⟧ ⟹ ?P (?tm::tm)›*)) (*goals: 1. ‹atom ` set (is::name list) ♯* Zero ⟹ trans_tm is Zero = trans_tm [] Zero› 2. ‹⋀x::name. atom ` set (is::name list) ♯* Var x ⟹ trans_tm is (Var x) = trans_tm [] (Var x)› 3. ‹⋀(x1::tm) x2a::tm. ⟦atom ` set (is::name list) ♯* x1 ⟹ trans_tm is x1 = trans_tm [] x1; atom ` set is ♯* x2a ⟹ trans_tm is x2a = trans_tm [] x2a; atom ` set is ♯* Eats x1 x2a⟧ ⟹ trans_tm is (Eats x1 x2a) = trans_tm [] (Eats x1 x2a)› discuss goal 1*) apply ((auto simp: lookup_notin (*‹?x ∉ set ?e ⟹ lookup ?e ?n ?x = DBVar ?x›*) fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp: lookup_notin (*‹?x ∉ set ?e ⟹ lookup ?e ?n ?x = DBVar ?x›*) fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*discuss goal 3*) apply ((auto simp: lookup_notin (*‹?x ∉ set ?e ⟹ lookup ?e ?n ?x = DBVar ?x›*) fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*proven 3 subgoals*) . lemma vquot_dbtm_fresh: "atom ` V ♯* t ⟹ vquot_dbtm V t = quot_dbtm t" apply (nominal_induct t rule: dbtm.strong_induct) (*goals: 1. ‹atom ` (V::name set) ♯* DBZero ⟹ vquot_dbtm V DBZero = quot_dbtm DBZero› 2. ‹⋀x::name. atom ` (V::name set) ♯* DBVar x ⟹ vquot_dbtm V (DBVar x) = quot_dbtm (DBVar x)› 3. ‹⋀x::nat. atom ` (V::name set) ♯* DBInd x ⟹ vquot_dbtm V (DBInd x) = quot_dbtm (DBInd x)› 4. ‹⋀(x1::dbtm) x2a::dbtm. ⟦atom ` (V::name set) ♯* x1 ⟹ vquot_dbtm V x1 = quot_dbtm x1; atom ` V ♯* x2a ⟹ vquot_dbtm V x2a = quot_dbtm x2a; atom ` V ♯* DBEats x1 x2a⟧ ⟹ vquot_dbtm V (DBEats x1 x2a) = quot_dbtm (DBEats x1 x2a)› discuss goal 1*) apply ((auto simp add: fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp add: fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*discuss goal 3*) apply ((auto simp add: fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*discuss goal 4*) apply ((auto simp add: fresh_star_def (*‹?as ♯* ?x ≡ ∀a∈?as. a ♯ ?x›*) fresh_at_base (*‹sort_of ?a ≠ sort_of (atom ?b) ⟹ ?a ♯ ?b› ‹?a ♯ ?b = (?a ≠ atom ?b)›*))[1]) (*proven 4 subgoals*) . lemma subst_vquot_dbtm_trans_tm[simp]: "atom i ♯ is ⟹ atom ` set is ♯* t ⟹ subst i «t» (vquot_dbtm {i} (trans_tm is t')) = quot_dbtm (trans_tm is (subst i t t'))" apply (nominal_induct t' avoiding: "is" i t rule: tm.strong_induct) (*goals: 1. ‹⋀(is::name list) (i::name) t::tm. ⟦atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbtm {i} (trans_tm is Zero)) = quot_dbtm (trans_tm is (subst i t Zero))› 2. ‹⋀(x::name) (is::name list) (i::name) t::tm. ⟦atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbtm {i} (trans_tm is (Var x))) = quot_dbtm (trans_tm is (subst i t (Var x)))› 3. ‹⋀(x1::tm) (x2a::tm) (is::name list) (i::name) t::tm. ⟦⋀(b::name list) (ba::name) bb::tm. ⟦atom ba ♯ b; atom ` set b ♯* bb⟧ ⟹ subst ba «bb» (vquot_dbtm {ba} (trans_tm b x1)) = quot_dbtm (trans_tm b (subst ba bb x1)); ⋀(b::name list) (ba::name) bb::tm. ⟦atom ba ♯ b; atom ` set b ♯* bb⟧ ⟹ subst ba «bb» (vquot_dbtm {ba} (trans_tm b x2a)) = quot_dbtm (trans_tm b (subst ba bb x2a)); atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbtm {i} (trans_tm is (Eats x1 x2a))) = quot_dbtm (trans_tm is (subst i t (Eats x1 x2a)))› discuss goal 1*) apply ((auto simp add: quot_tm_def (*‹«?t::tm» = quot_dbtm (trans_tm [] ?t)›*) lookup_notin (*‹(?x::name) ∉ set (?e::name list) ⟹ lookup ?e (?n::nat) ?x = DBVar ?x›*) fresh_imp_notin_env (*‹atom (?name::?'a) ♯ (?e::?'a list) ⟹ ?name ∉ set ?e›*) vquot_dbtm_fresh (*‹atom ` (?V::name set) ♯* (?t::dbtm) ⟹ vquot_dbtm ?V ?t = quot_dbtm ?t›*) lookup_fresh (*‹(?x::atom) ♯ lookup (?e::name list) (?n::nat) (?y::name) = (?y ∈ set ?e ∨ ?x ≠ atom ?y)›*) intro: trans_tm_forgets[symmetric] (*‹atom ` set (?is::name list) ♯* (?t::tm) ⟹ trans_tm [] ?t = trans_tm ?is ?t›*))[1]) (*discuss goal 2*) apply ((auto simp add: quot_tm_def (*‹«?t::tm» = quot_dbtm (trans_tm [] ?t)›*) lookup_notin (*‹(?x::name) ∉ set (?e::name list) ⟹ lookup ?e (?n::nat) ?x = DBVar ?x›*) fresh_imp_notin_env (*‹atom (?name::?'a) ♯ (?e::?'a list) ⟹ ?name ∉ set ?e›*) vquot_dbtm_fresh (*‹atom ` (?V::name set) ♯* (?t::dbtm) ⟹ vquot_dbtm ?V ?t = quot_dbtm ?t›*) lookup_fresh (*‹(?x::atom) ♯ lookup (?e::name list) (?n::nat) (?y::name) = (?y ∈ set ?e ∨ ?x ≠ atom ?y)›*) intro: trans_tm_forgets[symmetric] (*‹atom ` set (?is::name list) ♯* (?t::tm) ⟹ trans_tm [] ?t = trans_tm ?is ?t›*))[1]) (*discuss goal 3*) apply ((auto simp add: quot_tm_def (*‹«?t» = quot_dbtm (trans_tm [] ?t)›*) lookup_notin (*‹?x ∉ set ?e ⟹ lookup ?e ?n ?x = DBVar ?x›*) fresh_imp_notin_env (*‹atom ?name ♯ ?e ⟹ ?name ∉ set ?e›*) vquot_dbtm_fresh (*‹atom ` ?V ♯* ?t ⟹ vquot_dbtm ?V ?t = quot_dbtm ?t›*) lookup_fresh (*‹?x ♯ lookup ?e ?n ?y = (?y ∈ set ?e ∨ ?x ≠ atom ?y)›*) intro: trans_tm_forgets[symmetric] (*‹atom ` set ?is ♯* ?t ⟹ trans_tm [] ?t = trans_tm ?is ?t›*))[1]) (*proven 3 subgoals*) . lemma subst_vquot_dbtm_trans_fm[simp]: "atom i ♯ is ⟹ atom ` set is ♯* t ⟹ subst i «t» (vquot_dbfm {i} (trans_fm is A)) = quot_dbfm (trans_fm is (subst_fm A i t))" apply (nominal_induct A avoiding: "is" i t rule: fm.strong_induct) (*goals: 1. ‹⋀x1 x2 is i t. ⟦atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbfm {i} (trans_fm is (x1 IN x2))) = quot_dbfm (trans_fm is ((x1 IN x2)(i::=t)))› 2. ‹⋀x1 x2 is i t. ⟦atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbfm {i} (trans_fm is (x1 EQ x2))) = quot_dbfm (trans_fm is ((x1 EQ x2)(i::=t)))› 3. ‹⋀x1 x2 is i t. ⟦⋀b ba bb. ⟦atom ba ♯ b; atom ` set b ♯* bb⟧ ⟹ subst ba «bb» (vquot_dbfm {ba} (trans_fm b x1)) = quot_dbfm (trans_fm b (x1(ba::=bb))); ⋀b ba bb. ⟦atom ba ♯ b; atom ` set b ♯* bb⟧ ⟹ subst ba «bb» (vquot_dbfm {ba} (trans_fm b x2)) = quot_dbfm (trans_fm b (x2(ba::=bb))); atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbfm {i} (trans_fm is (x1 OR x2))) = quot_dbfm (trans_fm is ((x1 OR x2)(i::=t)))› 4. ‹⋀x is i t. ⟦⋀b ba bb. ⟦atom ba ♯ b; atom ` set b ♯* bb⟧ ⟹ subst ba «bb» (vquot_dbfm {ba} (trans_fm b x)) = quot_dbfm (trans_fm b (x(ba::=bb))); atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbfm {i} (trans_fm is (Neg x))) = quot_dbfm (trans_fm is ((Neg x)(i::=t)))› 5. ‹⋀x1 x2 is i t. ⟦atom x1 ♯ is; atom x1 ♯ i; atom x1 ♯ t; ⋀b ba bb. ⟦atom ba ♯ b; atom ` set b ♯* bb⟧ ⟹ subst ba «bb» (vquot_dbfm {ba} (trans_fm b x2)) = quot_dbfm (trans_fm b (x2(ba::=bb))); atom i ♯ is; atom ` set is ♯* t⟧ ⟹ subst i «t» (vquot_dbfm {i} (trans_fm is (SyntaxN.Ex x1 x2))) = quot_dbfm (trans_fm is ((SyntaxN.Ex x1 x2)(i::=t)))› discuss goal 1*) apply ((auto simp add: quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp add: quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 3*) apply ((auto simp add: quot_fm_def (*‹«?A::fm» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹(?a::atom) ♯ (?x::?'a) # (?xs::?'a list) = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 4*) apply ((auto simp add: quot_fm_def (*‹«?A::fm» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹(?a::atom) ♯ (?x::?'a) # (?xs::?'a list) = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 5*) apply ((auto simp add: quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*proven 5 subgoals*) . lemma subst_vquot[simp]: "subst i «t» ⌊A⌋{i} = «A(i ::= t)»" apply (nominal_induct A avoiding: i t rule: fm.strong_induct) (*goals: 1. ‹⋀x1 x2 i t. subst i «t» ⌊x1 IN x2⌋{i} = «(x1 IN x2)(i::=t)»› 2. ‹⋀x1 x2 i t. subst i «t» ⌊x1 EQ x2⌋{i} = «(x1 EQ x2)(i::=t)»› 3. ‹⋀x1 x2 i t. ⟦⋀b ba. subst b «ba» ⌊x1⌋{b} = «x1(b::=ba)»; ⋀b ba. subst b «ba» ⌊x2⌋{b} = «x2(b::=ba)»⟧ ⟹ subst i «t» ⌊x1 OR x2⌋{i} = «(x1 OR x2)(i::=t)»› 4. ‹⋀x i t. (⋀b ba. subst b «ba» ⌊x⌋{b} = «x(b::=ba)») ⟹ subst i «t» ⌊Neg x⌋{i} = «(Neg x)(i::=t)»› 5. ‹⋀x1 x2 i t. ⟦atom x1 ♯ i; atom x1 ♯ t; ⋀b ba. subst b «ba» ⌊x2⌋{b} = «x2(b::=ba)»⟧ ⟹ subst i «t» ⌊SyntaxN.Ex x1 x2⌋{i} = «(SyntaxN.Ex x1 x2)(i::=t)»› discuss goal 1*) apply ((auto simp add: vquot_fm_def (*‹⌊?A⌋?V = vquot_dbfm ?V (trans_fm [] ?A)›*) quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp add: vquot_fm_def (*‹⌊?A⌋?V = vquot_dbfm ?V (trans_fm [] ?A)›*) quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 3*) apply ((auto simp add: vquot_fm_def (*‹⌊?A⌋?V = vquot_dbfm ?V (trans_fm [] ?A)›*) quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 4*) apply ((auto simp add: vquot_fm_def (*‹⌊?A::fm⌋(?V::name set) = vquot_dbfm ?V (trans_fm [] ?A)›*) quot_fm_def (*‹«?A::fm» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹(?a::atom) ♯ (?x::?'a::pt) # (?xs::?'a::pt list) = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*discuss goal 5*) apply ((auto simp add: vquot_fm_def (*‹⌊?A⌋?V = vquot_dbfm ?V (trans_fm [] ?A)›*) quot_fm_def (*‹«?A» = quot_dbfm (trans_fm [] ?A)›*) fresh_Cons (*‹?a ♯ ?x # ?xs = (?a ♯ ?x ∧ ?a ♯ ?xs)›*))[1]) (*proven 5 subgoals*) . end
{ "path": "afp-2025-02-12/thys/Surprise_Paradox/Surprise_Paradox.thy", "repo": "afp-2025-02-12", "sha": "d71603a72164c0b9b9ca4322678fa61b079e745c486a9ccad54601d1bab56ff5" }
(* * Copyright (c) 2023 Apple Inc. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause *) theory Asm_Labels imports "AutoCorres2_Main.AutoCorres_Main" begin install_C_file "asm_labels.c" [ghostty="nat"] lemma last_singleton[L1opt]: "last [x] = x" by simp lemma last_cons[L1opt]: "last (x#y#ys) = last (y#ys)" by simp axiomatization where asm_label_skip [L1opt]: "last just_label = CHR '':'' ⟹ L1_spec (asm_spec ti gdata vol just_label (λx s. s) (λs. [])) = L1_skip" text ‹The axiomatic setup of named theorems @{thm L1opt} skips primitive assembler statements that are just labels. This results in those statements being removed already in layer L1› autocorres [ts_rules = nondet, scope = asm_labels] "asm_labels.c" context asm_labels_simpl begin thm asm_labels_body_def thm asm_unsupported_body_def end context l1_definition_asm_labels begin thm l1_def end context l2_definition_asm_labels begin thm l2_def end context ts_definition_asm_labels begin thm ts_def end text ‹Function ‹asm_unsupported› also contains more complex assembler statements. These are not removed. Currently they are propagated up to phase L1. Phase L2 fails as it not handle \<^term>‹L1_spec (asm_spec a b c d e f)› yet.› autocorres [phase=L1, scope = asm_unsupported] "asm_labels.c" context l1_definition_asm_unsupported begin thm l1_def end end
{ "path": "afp-2025-02-12/thys/AutoCorres2/tests/proof-tests/Asm_Labels.thy", "repo": "afp-2025-02-12", "sha": "45d420e40f08a73fc7ec13c4b6df44200f9d3f34128bc0110d5986165c8240a5" }
theory HOL_Extra imports Main begin lemmas UniqI = Uniq_I lemma Uniq_prodI: assumes "⋀x1 y1 x2 y2. P x1 y1 ⟹ P x2 y2 ⟹ (x1, y1) = (x2, y2)" shows "∃⇩≤₁(x, y). P x y" using assms (*‹⟦P ?x1.0 ?y1.0; P ?x2.0 ?y2.0⟧ ⟹ (?x1.0, ?y1.0) = (?x2.0, ?y2.0)›*) by (metis UniqI (*‹(⋀x y. ⟦?P x; ?P y⟧ ⟹ y = x) ⟹ Uniq ?P›*) case_prodE (*‹⟦case ?p of (a, b) ⇒ ?c a b; ⋀x y. ⟦?p = (x, y); ?c x y⟧ ⟹ ?Q⟧ ⟹ ?Q›*)) lemma Uniq_implies_ex1: "∃⇩≤₁x. P x ⟹ P y ⟹ ∃!x. P x" by (iprover intro: ex1I dest: Uniq_D) lemma Uniq_antimono: "Q ≤ P ⟹ Uniq Q ≥ Uniq P" unfolding le_fun_def le_bool_def (*goal: ‹∀x::'a. (Q::'a ⇒ bool) x ⟶ (P::'a ⇒ bool) x ⟹ Uniq P ⟶ Uniq Q›*) apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹∀x::'a. (Q::'a ⇒ bool) x ⟶ (P::'a ⇒ bool) x ⟹ Uniq P ⟶ Uniq Q›*) by (simp only: Uniq_I (*‹(⋀x y. ⟦?P x; ?P y⟧ ⟹ y = x) ⟹ Uniq ?P›*) Uniq_D (*‹⟦Uniq ?P; ?P ?a; ?P ?b⟧ ⟹ ?a = ?b›*)) lemma Uniq_antimono': "(⋀x. Q x ⟹ P x) ⟹ Uniq P ⟹ Uniq Q" by (fact Uniq_antimono[unfolded le_fun_def le_bool_def, rule_format] (*‹⟦⋀x::?'a. (?Q::?'a ⇒ bool) x ⟹ (?P::?'a ⇒ bool) x; Uniq ?P⟧ ⟹ Uniq ?Q›*)) lemma Collect_eq_if_Uniq: "(∃⇩≤₁x. P x) ⟹ {x. P x} = {} ∨ (∃x. {x. P x} = {x})" using Uniq_D (*‹⟦Uniq ?P; ?P ?a; ?P ?b⟧ ⟹ ?a = ?b›*) by fastforce lemma Collect_eq_if_Uniq_prod: "(∃⇩≤₁(x, y). P x y) ⟹ {(x, y). P x y} = {} ∨ (∃x y. {(x, y). P x y} = {(x, y)})" using Collect_eq_if_Uniq (*‹∃⇩≤₁ x. ?P x ⟹ {x. ?P x} = {} ∨ (∃x. {x. ?P x} = {x})›*) by fastforce lemma Ball_Ex_comm: "(∀x ∈ X. ∃f. P (f x) x) ⟹ (∃f. ∀x ∈ X. P (f x) x)" "(∃f. ∀x ∈ X. P (f x) x) ⟹ (∀x ∈ X. ∃f. P (f x) x)" (*goals: 1. ‹∀x∈X. ∃f. P (f x) x ⟹ ∃f. ∀x∈X. P (f x) x› 2. ‹∃f. ∀x∈X. P (f x) x ⟹ ∀x∈X. ∃f. P (f x) x› discuss goal 1*) apply meson (*discuss goal 2*) apply meson (*proven 2 subgoals*) . lemma set_map_id: assumes "x ∈ set X" "f x ∉ set X" "map f X = X" shows False using assms (*‹x ∈ set X› ‹f x ∉ set X› ‹map f X = X›*) apply (induction X) (*goals: 1. ‹⟦(x::'a::type) ∈ set []; (f::'a::type ⇒ 'a::type) x ∉ set []; map f [] = []⟧ ⟹ False› 2. ‹⋀(a::'a::type) X::'a::type list. ⟦⟦(x::'a::type) ∈ set X; (f::'a::type ⇒ 'a::type) x ∉ set X; map f X = X⟧ ⟹ False; x ∈ set (a # X); f x ∉ set (a # X); map f (a # X) = a # X⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . end
{ "path": "afp-2025-02-12/thys/Superposition_Calculus/HOL_Extra.thy", "repo": "afp-2025-02-12", "sha": "1c21c4ee282396949c777a275a01f71ef59c6a92f8c4bc150a5b2948261c9e72" }
theory "Denotational_Semantics" imports Ordinary_Differential_Equations.ODE_Analysis "Lib" "Ids" "Syntax" begin subsection ‹Denotational Semantics› text ‹ The canonical dynamic semantics of dL are given as a denotational semantics. The important definitions for the denotational semantics are states $\nu$, interpretations I and the semantic functions $[[\psi]]I$, $[[\theta]]I\nu$, $[[\alpha]]I$, which are represented by the Isabelle functions \verb|fml_sem|, \verb|dterm_sem| and \verb|prog_sem|, respectively. › subsection ‹States› text ‹We formalize a state S as a pair $(S_V, S_V') : R^n \times R^n $, where $S_V$ assigns values to the program variables and $S_V$' assigns values to their differentials. Function constants are also formalized as having a fixed arity m \verb|(Rvec_dim)| which may differ from n. If a function does not need to have m arguments, any remaining arguments can be uniformly set to 0, which simulates the affect of having functions of less arguments. Most semantic proofs need to reason about states agreeing on variables. We say Vagree A B V if states A and B have the same values on all variables in V, similarly with VSagree A B V for simple states A and B and Iagree I J V for interpretations I and J. › ― ‹Vector of reals of length ‹'a›› type_synonym 'a Rvec = "real^('a::finite)" ― ‹A state specifies one vector of values for unprimed variables ‹x› and a second vector for ‹x'›› type_synonym 'a state = "'a Rvec × 'a Rvec" ― ‹‹'a simple_state› is half a state - either the ‹x›s or the ‹x'›s› type_synonym 'a simple_state = "'a Rvec" definition Vagree :: "'c::finite state ⇒ 'c state ⇒ ('c + 'c) set ⇒ bool" where "Vagree ν ν' V ≡ (∀i. Inl i ∈ V ⟶ fst ν $ i = fst ν' $ i) ∧ (∀i. Inr i ∈ V ⟶ snd ν $ i = snd ν' $ i)" definition VSagree :: "'c::finite simple_state ⇒ 'c simple_state ⇒ 'c set ⇒ bool" where "VSagree ν ν' V ⟷ (∀i ∈ V. (ν $ i) = (ν' $ i))" ― ‹Agreement lemmas› lemma agree_nil:"Vagree ν ω {}" by (auto simp add: Vagree_def (*‹Vagree ?ν ?ν' ?V ≡ (∀i. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*)) lemma agree_supset:"A ⊇ B ⟹ Vagree ν ν' A ⟹ Vagree ν ν' B" by (auto simp add: Vagree_def (*‹Vagree (?ν::(real, ?'c) vec × (real, ?'c) vec) (?ν'::(real, ?'c) vec × (real, ?'c) vec) (?V::(?'c + ?'c) set) ≡ (∀i::?'c. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i::?'c. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*)) lemma VSagree_nil:"VSagree ν ω {}" by (auto simp add: VSagree_def (*‹VSagree (?ν::(real, ?'c) vec) (?ν'::(real, ?'c) vec) (?V::?'c set) = (∀i::?'c∈?V. ?ν $ i = ?ν' $ i)›*)) lemma VSagree_supset:"A ⊇ B ⟹ VSagree ν ν' A ⟹ VSagree ν ν' B" by (auto simp add: VSagree_def (*‹VSagree ?ν ?ν' ?V = (∀i∈?V. ?ν $ i = ?ν' $ i)›*)) lemma VSagree_UNIV_eq:"VSagree A B UNIV ⟹ A = B" unfolding VSagree_def (*goal: ‹∀i∈UNIV. A $ i = B $ i ⟹ A = B›*) by (auto simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) lemma agree_comm:"⋀A B V. Vagree A B V ⟹ Vagree B A V" unfolding Vagree_def (*goal: ‹⋀A B V. (∀i. Inl i ∈ V ⟶ fst A $ i = fst B $ i) ∧ (∀i. Inr i ∈ V ⟶ snd A $ i = snd B $ i) ⟹ (∀i. Inl i ∈ V ⟶ fst B $ i = fst A $ i) ∧ (∀i. Inr i ∈ V ⟶ snd B $ i = snd A $ i)›*) by auto lemma agree_sub:"⋀ν ω A B . A ⊆ B ⟹ Vagree ν ω B ⟹ Vagree ν ω A" unfolding Vagree_def (*goal: ‹⋀ν ω A B. ⟦A ⊆ B; (∀i. Inl i ∈ B ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ B ⟶ snd ν $ i = snd ω $ i)⟧ ⟹ (∀i. Inl i ∈ A ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ A ⟶ snd ν $ i = snd ω $ i)›*) by auto lemma agree_UNIV_eq:"⋀ν ω. Vagree ν ω UNIV ⟹ ν = ω" unfolding Vagree_def (*goal: ‹⋀ν ω. (∀i. Inl i ∈ UNIV ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ UNIV ⟶ snd ν $ i = snd ω $ i) ⟹ ν = ω›*) by (auto simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) lemma agree_UNIV_fst:"⋀ν ω. Vagree ν ω (Inl ` UNIV) ⟹ (fst ν) = (fst ω)" unfolding Vagree_def (*goal: ‹⋀ν ω. (∀i. Inl i ∈ range Inl ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ range Inl ⟶ snd ν $ i = snd ω $ i) ⟹ fst ν = fst ω›*) by (auto simp add: vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) lemma agree_UNIV_snd:"⋀ν ω. Vagree ν ω (Inr ` UNIV) ⟹ (snd ν) = (snd ω)" sorry lemma Vagree_univ:"⋀a b c d. Vagree (a,b) (c,d) UNIV ⟹ a = c ∧ b = d" by (auto simp add: Vagree_def (*‹Vagree ?ν ?ν' ?V ≡ (∀i. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*) vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*)) lemma agree_union:"⋀ν ω A B. Vagree ν ω A ⟹ Vagree ν ω B ⟹ Vagree ν ω (A ∪ B)" unfolding Vagree_def (*goal: ‹⋀ν ω A B. ⟦(∀i. Inl i ∈ A ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ A ⟶ snd ν $ i = snd ω $ i); (∀i. Inl i ∈ B ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ B ⟶ snd ν $ i = snd ω $ i)⟧ ⟹ (∀i. Inl i ∈ A ∪ B ⟶ fst ν $ i = fst ω $ i) ∧ (∀i. Inr i ∈ A ∪ B ⟶ snd ν $ i = snd ω $ i)›*) by (auto simp add: vec_eq_iff (*‹((?x::(?'a, ?'b) vec) = (?y::(?'a, ?'b) vec)) = (∀i::?'b. ?x $ i = ?y $ i)›*)) lemma agree_trans:"Vagree ν μ A ⟹ Vagree μ ω B ⟹ Vagree ν ω (A ∩ B)" sorry lemma agree_refl:"Vagree ν ν A" by (auto simp add: Vagree_def (*‹Vagree (?ν::(real, ?'c) vec × (real, ?'c) vec) (?ν'::(real, ?'c) vec × (real, ?'c) vec) (?V::(?'c + ?'c) set) ≡ (∀i::?'c. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i::?'c. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*)) lemma VSagree_sub:"⋀ν ω A B . A ⊆ B ⟹ VSagree ν ω B ⟹ VSagree ν ω A" unfolding VSagree_def (*goal: ‹⋀ν ω A B. ⟦A ⊆ B; ∀i∈B. ν $ i = ω $ i⟧ ⟹ ∀i∈A. ν $ i = ω $ i›*) by auto lemma VSagree_refl:"VSagree ν ν A" by (auto simp add: VSagree_def (*‹VSagree (?ν::(real, ?'c::finite) vec) (?ν'::(real, ?'c::finite) vec) (?V::?'c::finite set) = (∀i::?'c::finite∈?V. ?ν $ i = ?ν' $ i)›*)) subsection Interpretations text‹ For convenience we pretend interpretations contain an extra field called FunctionFrechet specifying the Frechet derivative \verb|(FunctionFrechet f ν)| : $R^m \rightarrow R$ for every function in every state. The proposition \verb|(is_interp I)| says that such a derivative actually exists and is continuous (i.e. all functions are C1-continuous) without saying what the exact derivative is. The type parameters 'a, 'b, 'c are finite types whose cardinalities indicate the maximum number of functions, contexts, and <everything else defined by the interpretation>, respectively. › record ('a, 'b, 'c) interp = Functions :: "'a ⇒ 'c Rvec ⇒ real" Predicates :: "'c ⇒ 'c Rvec ⇒ bool" Contexts :: "'b ⇒ 'c state set ⇒ 'c state set" Programs :: "'c ⇒ ('c state * 'c state) set" ODEs :: "'c ⇒ 'c simple_state ⇒ 'c simple_state" ODEBV :: "'c ⇒ 'c set" fun FunctionFrechet :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ 'a ⇒ 'c Rvec ⇒ 'c Rvec ⇒ real" where "FunctionFrechet I i = (THE f'. ∀ x. (Functions I i has_derivative f' x) (at x))" ― ‹For an interpretation to be valid, all functions must be differentiable everywhere.› definition is_interp :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ bool" where "is_interp I ≡ ∀x. ∀i. ((FDERIV (Functions I i) x :> (FunctionFrechet I i x)) ∧ continuous_on UNIV (λx. Blinfun (FunctionFrechet I i x)))" lemma is_interpD:"is_interp I ⟹ ∀x. ∀i. (FDERIV (Functions I i) x :> (FunctionFrechet I i x))" unfolding is_interp_def (*goal: ‹∀x i. (Functions I i has_derivative FunctionFrechet I i x) (at x) ∧ continuous_on UNIV (λx. Blinfun (FunctionFrechet I i x)) ⟹ ∀x i. (Functions I i has_derivative FunctionFrechet I i x) (at x)›*) by auto<close> definition Iagree :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a + 'b + 'c) set ⇒ bool" where "Iagree I J V ≡ (∀i∈V. (∀x. i = Inl x ⟶ Functions I x = Functions J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x))" lemma Iagree_Func:"Iagree I J V ⟹ Inl f ∈ V ⟹ Functions I f = Functions J f" unfolding Iagree_def (*goal: ‹⟦∀i∈V. (∀x. i = Inl x ⟶ Functions I x = Functions J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x); Inl f ∈ V⟧ ⟹ Functions I f = Functions J f›*) by auto lemma Iagree_Contexts:"Iagree I J V ⟹ Inr (Inl C) ∈ V ⟹ Contexts I C = Contexts J C" unfolding Iagree_def (*goal: ‹⟦∀i∈V. (∀x. i = Inl x ⟶ Functions I x = Functions J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x); Inr (Inl C) ∈ V⟧ ⟹ Contexts I C = Contexts J C›*) by auto lemma Iagree_Pred:"Iagree I J V ⟹ Inr (Inr p) ∈ V ⟹ Predicates I p = Predicates J p" unfolding Iagree_def (*goal: ‹⟦∀i∈V. (∀x. i = Inl x ⟶ Functions I x = Functions J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x); Inr (Inr p) ∈ V⟧ ⟹ Predicates I p = Predicates J p›*) by auto lemma Iagree_Prog:"Iagree I J V ⟹ Inr (Inr a) ∈ V ⟹ Programs I a = Programs J a" unfolding Iagree_def (*goal: ‹⟦∀i::'a::finite + 'b::finite + 'c::finite∈V::('a::finite + 'b::finite + 'c::finite) set. (∀x::'a::finite. i = Inl x ⟶ Functions (I::('a, 'b, 'c) interp) x = Functions (J::('a, 'b, 'c) interp) x) ∧ (∀x::'b::finite. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x); Inr (Inr (a::'c::finite)) ∈ V⟧ ⟹ Programs I a = Programs J a›*) by auto lemma Iagree_ODE:"Iagree I J V ⟹ Inr (Inr a) ∈ V ⟹ ODEs I a = ODEs J a" unfolding Iagree_def (*goal: ‹⟦∀i::'a::finite + 'b::finite + 'c::finite∈V::('a::finite + 'b::finite + 'c::finite) set. (∀x::'a::finite. i = Inl x ⟶ Functions (I::('a, 'b, 'c) interp) x = Functions (J::('a, 'b, 'c) interp) x) ∧ (∀x::'b::finite. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x::'c::finite. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x); Inr (Inr (a::'c::finite)) ∈ V⟧ ⟹ ODEs I a = ODEs J a›*) by auto lemma Iagree_comm:"⋀A B V. Iagree A B V ⟹ Iagree B A V" unfolding Iagree_def (*goal: ‹⋀A B V. ∀i∈V. (∀x. i = Inl x ⟶ Functions A x = Functions B x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts A x = Contexts B x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates A x = Predicates B x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs A x = Programs B x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs A x = ODEs B x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV A x = ODEBV B x) ⟹ ∀i∈V. (∀x. i = Inl x ⟶ Functions B x = Functions A x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts B x = Contexts A x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates B x = Predicates A x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs B x = Programs A x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs B x = ODEs A x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV B x = ODEBV A x)›*) by auto lemma Iagree_sub:"⋀I J A B . A ⊆ B ⟹ Iagree I J B ⟹ Iagree I J A" unfolding Iagree_def (*goal: ‹⋀I J A B. ⟦A ⊆ B; ∀i∈B. (∀x. i = Inl x ⟶ Functions I x = Functions J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x)⟧ ⟹ ∀i∈A. (∀x. i = Inl x ⟶ Functions I x = Functions J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts I x = Contexts J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates I x = Predicates J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs I x = Programs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs I x = ODEs J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV I x = ODEBV J x)›*) by auto lemma Iagree_refl:"Iagree I I A" by (auto simp add: Iagree_def (*‹Iagree ?I ?J ?V ≡ ∀i∈?V. (∀x. i = Inl x ⟶ Functions ?I x = Functions ?J x) ∧ (∀x. i = Inr (Inl x) ⟶ Contexts ?I x = Contexts ?J x) ∧ (∀x. i = Inr (Inr x) ⟶ Predicates ?I x = Predicates ?J x) ∧ (∀x. i = Inr (Inr x) ⟶ Programs ?I x = Programs ?J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEs ?I x = ODEs ?J x) ∧ (∀x. i = Inr (Inr x) ⟶ ODEBV ?I x = ODEBV ?J x)›*))<close> primrec sterm_sem :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a, 'c) trm ⇒ 'c simple_state ⇒ real" where "sterm_sem I (Var x) v = v $ x" | "sterm_sem I (Function f args) v = Functions I f (χ i. sterm_sem I (args i) v)" | "sterm_sem I (Plus t1 t2) v = sterm_sem I t1 v + sterm_sem I t2 v" | "sterm_sem I (Times t1 t2) v = sterm_sem I t1 v * sterm_sem I t2 v" | "sterm_sem I (Const r) v = r" | "sterm_sem I ($' c) v = undefined" | "sterm_sem I (Differential d) v = undefined" ― ‹‹frechet I θ ν› syntactically computes the frechet derivative of the term ‹θ› in the interpretation› ― ‹‹I› at state ‹ν› (containing only the unprimed variables). The frechet derivative is a› ― ‹linear map from the differential state ‹ν› to reals.› primrec frechet :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a, 'c) trm ⇒ 'c simple_state ⇒ 'c simple_state ⇒ real" where "frechet I (Var x) v = (λv'. v' ∙ axis x 1)" | "frechet I (Function f args) v = (λv'. FunctionFrechet I f (χ i. sterm_sem I (args i) v) (χ i. frechet I (args i) v v'))" | "frechet I (Plus t1 t2) v = (λv'. frechet I t1 v v' + frechet I t2 v v')" | "frechet I (Times t1 t2) v = (λv'. sterm_sem I t1 v * frechet I t2 v v' + frechet I t1 v v' * sterm_sem I t2 v)" | "frechet I (Const r) v = (λv'. 0)" | "frechet I ($' c) v = undefined" | "frechet I (Differential d) v = undefined" definition directional_derivative :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a, 'c) trm ⇒ 'c state ⇒ real" where "directional_derivative I t = (λv. frechet I t (fst v) (snd v))" ― ‹Sem for terms that are allowed to contain differentials.› ― ‹Note there is some duplication with ‹sterm_sem›.› primrec dterm_sem :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a, 'c) trm ⇒ 'c state ⇒ real" where "dterm_sem I (Var x) = (λv. fst v $ x)" | "dterm_sem I (DiffVar x) = (λv. snd v $ x)" | "dterm_sem I (Function f args) = (λv. Functions I f (χ i. dterm_sem I (args i) v))" | "dterm_sem I (Plus t1 t2) = (λv. (dterm_sem I t1 v) + (dterm_sem I t2 v))" | "dterm_sem I (Times t1 t2) = (λv. (dterm_sem I t1 v) * (dterm_sem I t2 v))" | "dterm_sem I (Differential t) = (λv. directional_derivative I t v)" | "dterm_sem I (Const c) = (λv. c)" text‹ The semantics of an ODE is the vector field at a given point. ODE's are all time-independent so no time variable is necessary. Terms on the RHS of an ODE must be differential-free, so depends only on the xs. The safety predicate \texttt{osafe} ensures the domains of ODE1 and ODE2 are disjoint, so vector addition is equivalent to saying "take things defined from ODE1 from ODE1, take things defined by ODE2 from ODE2"› fun ODE_sem:: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a, 'c) ODE ⇒ 'c Rvec ⇒ 'c Rvec" where ODE_sem_OVar:"ODE_sem I (OVar x) = ODEs I x" | ODE_sem_OSing:"ODE_sem I (OSing x θ) = (λν. (χ i. if i = x then sterm_sem I θ ν else 0))" ― ‹Note: Could define using ‹SOME› operator in a way that more closely matches above description,› ― ‹but that gets complicated in the ‹OVar› case because not all variables are bound by the ‹OVar›› | ODE_sem_OProd:"ODE_sem I (OProd ODE1 ODE2) = (λν. ODE_sem I ODE1 ν + ODE_sem I ODE2 ν)" ― ‹The bound variables of an ODE› fun ODE_vars :: "('a,'b,'c) interp ⇒ ('a, 'c) ODE ⇒ 'c set" where "ODE_vars I (OVar c) = ODEBV I c" | "ODE_vars I (OSing x θ) = {x}" | "ODE_vars I (OProd ODE1 ODE2) = ODE_vars I ODE1 ∪ ODE_vars I ODE2" fun semBV ::"('a, 'b,'c) interp ⇒ ('a, 'c) ODE ⇒ ('c + 'c) set" where "semBV I ODE = Inl ` (ODE_vars I ODE) ∪ Inr ` (ODE_vars I ODE)" lemma ODE_vars_lr: fixes x::"'sz" and ODE::"('sf,'sz) ODE" and I::"('sf,'sc,'sz) interp" shows "Inl x ∈ semBV I ODE ⟷ Inr x ∈ semBV I ODE" apply (induction "ODE") (*goals: 1. ‹⋀xa. (Inl x ∈ semBV I (OVar xa)) = (Inr x ∈ semBV I (OVar xa))› 2. ‹⋀x1a x2. (Inl x ∈ semBV I (OSing x1a x2)) = (Inr x ∈ semBV I (OSing x1a x2))› 3. ‹⋀ODE1 ODE2. ⟦(Inl x ∈ semBV I ODE1) = (Inr x ∈ semBV I ODE1); (Inl x ∈ semBV I ODE2) = (Inr x ∈ semBV I ODE2)⟧ ⟹ (Inl x ∈ semBV I (OProd ODE1 ODE2)) = (Inr x ∈ semBV I (OProd ODE1 ODE2))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . fun mk_xode::"('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a::finite, 'c::finite) ODE ⇒ 'c::finite simple_state ⇒ 'c::finite state" where "mk_xode I ODE sol = (sol, ODE_sem I ODE sol)" text‹ Given an initial state $\nu$ and solution to an ODE at some point, construct the resulting state $\omega$. This is defined using the SOME operator because the concrete definition is unwieldy. › definition mk_v::"('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a::finite, 'c::finite) ODE ⇒ 'c::finite state ⇒ 'c::finite simple_state ⇒ 'c::finite state" where "mk_v I ODE ν sol = (THE ω. Vagree ω ν (- semBV I ODE) ∧ Vagree ω (mk_xode I ODE sol) (semBV I ODE))" ― ‹‹repv ν x r› replaces the value of (unprimed) variable ‹x› in the state ‹ν› with r› fun repv :: "'c::finite state ⇒ 'c ⇒ real ⇒ 'c state" where "repv v x r = ((χ y. if x = y then r else vec_nth (fst v) y), snd v)" ― ‹‹repd ν x' r› replaces the value of (primed) variable ‹x'› in the state ‹ν› with ‹r›› fun repd :: "'c::finite state ⇒ 'c ⇒ real ⇒ 'c state" where "repd v x r = (fst v, (χ y. if x = y then r else vec_nth (snd v) y))" ― ‹Semantics for formulas, differential formulas, programs.› fun fml_sem :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a::finite, 'b::finite, 'c::finite) formula ⇒ 'c::finite state set" and prog_sem :: "('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a::finite, 'b::finite, 'c::finite) hp ⇒ ('c::finite state * 'c::finite state) set" where "fml_sem I (Geq t1 t2) = {v. dterm_sem I t1 v ≥ dterm_sem I t2 v}" | "fml_sem I (Prop P terms) = {ν. Predicates I P (χ i. dterm_sem I (terms i) ν)}" | "fml_sem I (Not φ) = {v. v ∉ fml_sem I φ}" | "fml_sem I (And φ ψ) = fml_sem I φ ∩ fml_sem I ψ" | "fml_sem I (Exists x φ) = {v | v r. (repv v x r) ∈ fml_sem I φ}" | "fml_sem I (Diamond α φ) = {ν | ν ω. (ν, ω) ∈ prog_sem I α ∧ ω ∈ fml_sem I φ}" | "fml_sem I (InContext c φ) = Contexts I c (fml_sem I φ)" | "prog_sem I (Pvar p) = Programs I p" | "prog_sem I (Assign x t) = {(ν, ω). ω = repv ν x (dterm_sem I t ν)}" | "prog_sem I (DiffAssign x t) = {(ν, ω). ω = repd ν x (dterm_sem I t ν)}" | "prog_sem I (Test φ) = {(ν, ν) | ν. ν ∈ fml_sem I φ}" | "prog_sem I (Choice α β) = prog_sem I α ∪ prog_sem I β" | "prog_sem I (Sequence α β) = prog_sem I α O prog_sem I β" | "prog_sem I (Loop α) = (prog_sem I α)⇧*" | "prog_sem I (EvolveODE ODE φ) = ({(ν, mk_v I ODE ν (sol t)) | ν sol t. t ≥ 0 ∧ (sol solves_ode (λ_. ODE_sem I ODE)) {0..t} {x. mk_v I ODE ν x ∈ fml_sem I φ} ∧ sol 0 = fst ν})" context ids begin definition valid :: "('sf, 'sc, 'sz) formula ⇒ bool" where "valid φ ≡ (∀ I. ∀ ν. is_interp I ⟶ ν ∈ fml_sem I φ)" end text‹ Because mk\_v is defined with the SOME operator, need to construct a state that satisfies ${\tt Vagree} \omega \nu (- {\tt ODE\_vars\ ODE}) \wedge {\tt Vagree} \omega {\tt (mk\_xode\ I\ ODE\ sol)\ (ODE\_vars\ ODE)})$ to do anything useful › fun concrete_v::"('a::finite, 'b::finite, 'c::finite) interp ⇒ ('a::finite, 'c::finite) ODE ⇒ 'c::finite state ⇒ 'c::finite simple_state ⇒ 'c::finite state" where "concrete_v I ODE ν sol = ((χ i. (if Inl i ∈ semBV I ODE then sol else (fst ν)) $ i), (χ i. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else (snd ν)) $ i))" lemma mk_v_exists:"∃ω. Vagree ω ν (- semBV I ODE) ∧ Vagree ω (mk_xode I ODE sol) (semBV I ODE)" apply (rule exI[where x="(concrete_v I ODE ν sol)"] (*‹(?P::(real, 'a::finite) vec × (real, 'a::finite) vec ⇒ bool) (concrete_v (I::('b, 'c, 'a) interp) (ODE::('b::finite, 'a::finite) ODE) (ν::(real, 'a::finite) vec × (real, 'a::finite) vec) (sol::(real, 'a::finite) vec)) ⟹ ∃x::(real, 'a::finite) vec × (real, 'a::finite) vec. ?P x›*)) (*goal: ‹∃ω::(real, 'a) vec × (real, 'a) vec. Vagree ω (ν::(real, 'a) vec × (real, 'a) vec) (- semBV (I::('b, 'c, 'a) interp) (ODE::('b, 'a) ODE)) ∧ Vagree ω (mk_xode I ODE (sol::(real, 'a) vec)) (semBV I ODE)›*) by (auto simp add: Vagree_def (*‹Vagree ?ν ?ν' ?V ≡ (∀i. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*)) lemma mk_v_agree:"Vagree (mk_v I ODE ν sol) ν (- semBV I ODE) ∧ Vagree (mk_v I ODE ν sol) (mk_xode I ODE sol) (semBV I ODE)" unfolding mk_v_def (*goal: ‹Vagree (THE ω::(real, 'a) vec × (real, 'a) vec. Vagree ω (ν::(real, 'a) vec × (real, 'a) vec) (- semBV (I::('b, 'c, 'a) interp) (ODE::('b, 'a) ODE)) ∧ Vagree ω (mk_xode I ODE (sol::(real, 'a) vec)) (semBV I ODE)) ν (- semBV I ODE) ∧ Vagree (THE ω::(real, 'a) vec × (real, 'a) vec. Vagree ω ν (- semBV I ODE) ∧ Vagree ω (mk_xode I ODE sol) (semBV I ODE)) (mk_xode I ODE sol) (semBV I ODE)›*) apply (rule theI[where a= "((χ i. (if Inl i ∈ semBV I ODE then sol else (fst ν)) $ i), (χ i. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else (snd ν)) $ i))" ] (*‹⟦?P (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i); ⋀x. ?P x ⟹ x = (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i)⟧ ⟹ ?P (THE x. ?P x)›*)) (*goal: ‹Vagree (THE ω::(real, 'a) vec × (real, 'a) vec. Vagree ω (ν::(real, 'a) vec × (real, 'a) vec) (- semBV (I::('b, 'c, 'a) interp) (ODE::('b, 'a) ODE)) ∧ Vagree ω (mk_xode I ODE (sol::(real, 'a) vec)) (semBV I ODE)) ν (- semBV I ODE) ∧ Vagree (THE ω::(real, 'a) vec × (real, 'a) vec. Vagree ω ν (- semBV I ODE) ∧ Vagree ω (mk_xode I ODE sol) (semBV I ODE)) (mk_xode I ODE sol) (semBV I ODE)›*) using exE[OF mk_v_exists, of ν I ODE sol] (*‹(⋀x. Vagree x ν (- semBV I ODE) ∧ Vagree x (mk_xode I ODE sol) (semBV I ODE) ⟹ ?Q) ⟹ ?Q›*) (*goals: 1. ‹Vagree (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i) ν (- semBV I ODE) ∧ Vagree (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i) (mk_xode I ODE sol) (semBV I ODE)› 2. ‹⋀x. Vagree x ν (- semBV I ODE) ∧ Vagree x (mk_xode I ODE sol) (semBV I ODE) ⟹ x = (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i)› discuss goal 1*) apply ((auto simp add: Vagree_def (*‹Vagree ?ν ?ν' ?V ≡ (∀i. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*) vec_eq_iff (*‹(?x = ?y) = (∀i. ?x $ i = ?y $ i)›*))[1]) (*discuss goal 2*) apply ((auto simp add: Vagree_def (*‹Vagree (?ν::(real, ?'c::finite) vec × (real, ?'c::finite) vec) (?ν'::(real, ?'c::finite) vec × (real, ?'c::finite) vec) (?V::(?'c::finite + ?'c::finite) set) ≡ (∀i::?'c::finite. Inl i ∈ ?V ⟶ fst ?ν $ i = fst ?ν' $ i) ∧ (∀i::?'c::finite. Inr i ∈ ?V ⟶ snd ?ν $ i = snd ?ν' $ i)›*) vec_eq_iff (*‹((?x::(?'a::type, ?'b::finite) vec) = (?y::(?'a::type, ?'b::finite) vec)) = (∀i::?'b::finite. ?x $ i = ?y $ i)›*))[1]) (*proven 2 subgoals*) . lemma mk_v_concrete:"mk_v I ODE ν sol = ((χ i. (if Inl i ∈ semBV I ODE then sol else (fst ν)) $ i), (χ i. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else (snd ν)) $ i))" apply (rule agree_UNIV_eq (*‹Vagree (?ν::(real, ?'a) vec × (real, ?'a) vec) (?ω::(real, ?'a) vec × (real, ?'a) vec) UNIV ⟹ ?ν = ?ω›*)) (*goal: ‹mk_v I ODE ν sol = (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i)›*) using mk_v_agree[of I ODE ν sol] (*‹Vagree (mk_v I ODE ν sol) ν (- semBV I ODE) ∧ Vagree (mk_v I ODE ν sol) (mk_xode I ODE sol) (semBV I ODE)›*) unfolding Vagree_def (*goal: ‹(∀i. Inl i ∈ UNIV ⟶ fst (mk_v I ODE ν sol) $ i = fst (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i) $ i) ∧ (∀i. Inr i ∈ UNIV ⟶ snd (mk_v I ODE ν sol) $ i = snd (χi. (if Inl i ∈ semBV I ODE then sol else fst ν) $ i, χi. (if Inr i ∈ semBV I ODE then ODE_sem I ODE sol else snd ν) $ i) $ i)›*) by auto subsection ‹Trivial Simplification Lemmas› text ‹ We often want to pretend the definitions in the semantics are written slightly differently than they are. Since the simplifier has some trouble guessing that these are the right simplifications to do, we write them all out explicitly as lemmas, even though they prove trivially. › lemma svar_case: "sterm_sem I (Var x) = (λv. v $ x)" by auto lemma sconst_case: "sterm_sem I (Const r) = (λv. r)" by auto lemma sfunction_case: "sterm_sem I (Function f args) = (λv. Functions I f (χ i. sterm_sem I (args i) v))" by auto lemma splus_case: "sterm_sem I (Plus t1 t2) = (λv. (sterm_sem I t1 v) + (sterm_sem I t2 v))" by auto lemma stimes_case: "sterm_sem I (Times t1 t2) = (λv. (sterm_sem I t1 v) * (sterm_sem I t2 v))" by auto lemma or_sem [simp]: "fml_sem I (Or φ ψ) = fml_sem I φ ∪ fml_sem I ψ" by (auto simp add: Or_def (*‹(?P || ?Q) = ! (! ?P && ! ?Q)›*)) lemma iff_sem [simp]: "(ν ∈ fml_sem I (A ↔ B)) ⟷ ((ν ∈ fml_sem I A) ⟷ (ν ∈ fml_sem I B))" by (auto simp add: Equiv_def (*‹(?P ↔ ?Q) = (?P && ?Q || ! ?P && ! ?Q)›*)) lemma box_sem [simp]:"fml_sem I (Box α φ) = {ν. ∀ ω. (ν, ω) ∈ prog_sem I α ⟶ ω ∈ fml_sem I φ}" unfolding Box_def fml_sem.simps (*goal: ‹{v. v ∉ {uu_. ∃ν ω. uu_ = ν ∧ (ν, ω) ∈ prog_sem I α ∧ ω ∈ {v. v ∉ fml_sem I φ}}} = {ν. ∀ω. (ν, ω) ∈ prog_sem I α ⟶ ω ∈ fml_sem I φ}›*) using Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) by auto lemma forall_sem [simp]:"fml_sem I (Forall x φ) = {v. ∀r. (repv v x r) ∈ fml_sem I φ}" unfolding Forall_def fml_sem.simps (*goal: ‹{v::(real, 'a) vec × (real, 'a) vec. v ∉ {uu_::(real, 'a) vec × (real, 'a) vec. ∃(v::(real, 'a) vec × (real, 'a) vec) r::real. uu_ = v ∧ repv v (x::'a) r ∈ {v::(real, 'a) vec × (real, 'a) vec. v ∉ fml_sem (I::('b, 'c, 'a) interp) (φ::('b, 'c, 'a) formula)}}} = {v::(real, 'a) vec × (real, 'a) vec. ∀r::real. repv v x r ∈ fml_sem I φ}›*) using Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*) by auto lemma greater_sem[simp]:"fml_sem I (Greater θ θ') = {v. dterm_sem I θ v > dterm_sem I θ' v}" unfolding Greater_def (*goal: ‹fml_sem I (Geq θ θ' && ! (Geq θ' θ)) = {v. dterm_sem I θ' v < dterm_sem I θ v}›*) by auto lemma loop_sem:"prog_sem I (Loop α) = (prog_sem I α)⇧*" by auto lemma impl_sem [simp]: "(ν ∈ fml_sem I (A → B)) = ((ν ∈ fml_sem I A) ⟶ (ν ∈ fml_sem I B))" by (auto simp add: Implies_def (*‹(?P → ?Q) = (?Q || ! ?P)›*)) lemma equals_sem [simp]: "(ν ∈ fml_sem I (Equals θ θ')) = (dterm_sem I θ ν = dterm_sem I θ' ν)" by (auto simp add: Equals_def (*‹Equals ?θ ?θ' = (Geq ?θ ?θ' && Geq ?θ' ?θ)›*)) lemma diamond_sem [simp]: "fml_sem I (Diamond α φ) = {ν. ∃ ω. (ν, ω) ∈ prog_sem I α ∧ ω ∈ fml_sem I φ}" by auto lemma tt_sem [simp]:"fml_sem I TT = UNIV" unfolding TT_def (*goal: ‹fml_sem I (Geq (Const 0) (Const 0)) = UNIV›*) by auto lemma ff_sem [simp]:"fml_sem I FF = {}" unfolding FF_def (*goal: ‹fml_sem I (Geq (Const 0) (Const 1)) = {}›*) by auto lemma iff_to_impl: "((ν ∈ fml_sem I A) ⟷ (ν ∈ fml_sem I B)) ⟷ (((ν ∈ fml_sem I A) ⟶ (ν ∈ fml_sem I B)) ∧ ((ν ∈ fml_sem I B) ⟶ (ν ∈ fml_sem I A)))" by auto fun seq2fml :: "('a,'b,'c) sequent ⇒ ('a,'b,'c) formula" where "seq2fml (ante,succ) = Implies (foldr And ante TT) (foldr Or succ FF)" context ids begin fun seq_sem ::"('sf, 'sc, 'sz) interp ⇒ ('sf, 'sc, 'sz) sequent ⇒ 'sz state set" where "seq_sem I S = fml_sem I (seq2fml S)" lemma and_foldl_sem:"ν ∈ fml_sem I (foldr And Γ TT) ⟹ (⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ)" apply (induction Γ) (*goals: 1. ‹⋀φ. ⟦ν ∈ fml_sem I (foldr (&&) [] TT); List.member [] φ⟧ ⟹ ν ∈ fml_sem I φ› 2. ‹⋀a Γ φ. ⟦⋀φ. ⟦ν ∈ fml_sem I (foldr (&&) Γ TT); List.member Γ φ⟧ ⟹ ν ∈ fml_sem I φ; ν ∈ fml_sem I (foldr (&&) (a # Γ) TT); List.member (a # Γ) φ⟧ ⟹ ν ∈ fml_sem I φ› discuss goal 1*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*discuss goal 2*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*proven 2 subgoals*) . lemma and_foldl_sem_conv:"(⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ) ⟹ ν ∈ fml_sem I (foldr And Γ TT)" apply (induction Γ) (*goals: 1. ‹(⋀φ::('a, 'b, 'c) formula. List.member [] φ ⟹ (ν::(real, 'c) vec × (real, 'c) vec) ∈ fml_sem (I::('a, 'b, 'c) interp) φ) ⟹ ν ∈ fml_sem I (foldr (&&) [] TT)› 2. ‹⋀(a::('a, 'b, 'c) formula) Γ::('a, 'b, 'c) formula list. ⟦(⋀φ::('a, 'b, 'c) formula. List.member Γ φ ⟹ (ν::(real, 'c) vec × (real, 'c) vec) ∈ fml_sem (I::('a, 'b, 'c) interp) φ) ⟹ ν ∈ fml_sem I (foldr (&&) Γ TT); ⋀φ::('a, 'b, 'c) formula. List.member (a # Γ) φ ⟹ ν ∈ fml_sem I φ⟧ ⟹ ν ∈ fml_sem I (foldr (&&) (a # Γ) TT)› discuss goal 1*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*discuss goal 2*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*proven 2 subgoals*) . lemma or_foldl_sem:"List.member Γ φ ⟹ ν ∈ fml_sem I φ ⟹ ν ∈ fml_sem I (foldr Or Γ FF)" apply (induction Γ) (*goals: 1. ‹⟦List.member [] (φ::('a, 'b, 'c) formula); (ν::(real, 'c) vec × (real, 'c) vec) ∈ fml_sem (I::('a, 'b, 'c) interp) φ⟧ ⟹ ν ∈ fml_sem I (foldr (||) [] FF)› 2. ‹⋀(a::('a, 'b, 'c) formula) Γ::('a, 'b, 'c) formula list. ⟦⟦List.member Γ (φ::('a, 'b, 'c) formula); (ν::(real, 'c) vec × (real, 'c) vec) ∈ fml_sem (I::('a, 'b, 'c) interp) φ⟧ ⟹ ν ∈ fml_sem I (foldr (||) Γ FF); List.member (a # Γ) φ; ν ∈ fml_sem I φ⟧ ⟹ ν ∈ fml_sem I (foldr (||) (a # Γ) FF)› discuss goal 1*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*discuss goal 2*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*proven 2 subgoals*) . lemma or_foldl_sem_conv:"ν ∈ fml_sem I (foldr Or Γ FF) ⟹ ∃ φ. ν ∈ fml_sem I φ ∧ List.member Γ φ" apply (induction Γ) (*goals: 1. ‹ν ∈ fml_sem I (foldr (||) [] FF) ⟹ ∃φ. ν ∈ fml_sem I φ ∧ List.member [] φ› 2. ‹⋀a Γ. ⟦ν ∈ fml_sem I (foldr (||) Γ FF) ⟹ ∃φ. ν ∈ fml_sem I φ ∧ List.member Γ φ; ν ∈ fml_sem I (foldr (||) (a # Γ) FF)⟧ ⟹ ∃φ. ν ∈ fml_sem I φ ∧ List.member (a # Γ) φ› discuss goal 1*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*discuss goal 2*) apply ((auto simp add: member_rec (*‹List.member (?x # ?xs) ?y = (?x = ?y ∨ List.member ?xs ?y)› ‹List.member [] ?y = False›*))[1]) (*proven 2 subgoals*) . lemma seq_semI':"(ν ∈ fml_sem I (foldr And Γ TT) ⟹ ν ∈ fml_sem I (foldr Or Δ FF)) ⟹ ν ∈ seq_sem I (Γ,Δ)" sorry lemma seq_semD':"⋀P. ν ∈ seq_sem I (Γ,Δ) ⟹ ((ν ∈ fml_sem I (foldr And Γ TT) ⟹ ν ∈ fml_sem I (foldr Or Δ FF)) ⟹ P) ⟹ P" by simp definition sublist::"'a list ⇒ 'a list ⇒ bool" where "sublist A B ≡ (∀x. List.member A x ⟶ List.member B x)" lemma sublistI:"(⋀x. List.member A x ⟹ List.member B x) ⟹ sublist A B" unfolding sublist_def (*goal: ‹(⋀x. List.member A x ⟹ List.member B x) ⟹ ∀x. List.member A x ⟶ List.member B x›*) by auto lemma Γ_sub_sem:"sublist Γ1 Γ2 ⟹ ν ∈ fml_sem I (foldr And Γ2 TT) ⟹ ν ∈ fml_sem I (foldr And Γ1 TT)" unfolding sublist_def (*goal: ‹⟦∀x::('a, 'b, 'c) formula. List.member (Γ1::('a, 'b, 'c) formula list) x ⟶ List.member (Γ2::('a, 'b, 'c) formula list) x; (ν::(real, 'c) vec × (real, 'c) vec) ∈ fml_sem (I::('a, 'b, 'c) interp) (foldr (&&) Γ2 TT)⟧ ⟹ ν ∈ fml_sem I (foldr (&&) Γ1 TT)›*) by (metis and_foldl_sem (*‹⟦?ν ∈ fml_sem ?I (foldr (&&) ?Γ TT); List.member ?Γ ?φ⟧ ⟹ ?ν ∈ fml_sem ?I ?φ›*) and_foldl_sem_conv (*‹(⋀φ. List.member ?Γ φ ⟹ ?ν ∈ fml_sem ?I φ) ⟹ ?ν ∈ fml_sem ?I (foldr (&&) ?Γ TT)›*)) lemma seq_semI:"List.member Δ ψ ⟹((⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ) ⟹ ν ∈ fml_sem I ψ) ⟹ ν ∈ seq_sem I (Γ,Δ)" apply (rule seq_semI' (*‹(?ν ∈ fml_sem ?I (foldr (&&) ?Γ TT) ⟹ ?ν ∈ fml_sem ?I (foldr (||) ?Δ FF)) ⟹ ?ν ∈ seq_sem ?I (?Γ, ?Δ)›*)) (*goal: ‹⟦List.member Δ ψ; (⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ) ⟹ ν ∈ fml_sem I ψ⟧ ⟹ ν ∈ seq_sem I (Γ, Δ)›*) using and_foldl_sem[of ν I Γ] (*‹⟦(ν::(real, 'sz::{finite,linorder}) vec × (real, 'sz::{finite,linorder}) vec) ∈ fml_sem (I::('sf, 'sc, 'sz) interp) (foldr (&&) (Γ::('sf::finite, 'sc::finite, 'sz::{finite,linorder}) formula list) TT); List.member Γ (?φ::('sf::finite, 'sc::finite, 'sz::{finite,linorder}) formula)⟧ ⟹ ν ∈ fml_sem I ?φ›*) or_foldl_sem (*‹⟦List.member ?Γ ?φ; ?ν ∈ fml_sem ?I ?φ⟧ ⟹ ?ν ∈ fml_sem ?I (foldr (||) ?Γ FF)›*) by blast lemma seq_semD:"ν ∈ seq_sem I (Γ,Δ) ⟹ (⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ) ⟹ ∃φ. (List.member Δ φ) ∧ν ∈ fml_sem I φ " apply (rule seq_semD' (*‹⟦?ν ∈ seq_sem ?I (?Γ, ?Δ); (?ν ∈ fml_sem ?I (foldr (&&) ?Γ TT) ⟹ ?ν ∈ fml_sem ?I (foldr (||) ?Δ FF)) ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹⟦(ν::(real, 'sz) vec × (real, 'sz) vec) ∈ seq_sem (I::('sf, 'sc, 'sz) interp) (Γ::('sf, 'sc, 'sz) formula list, Δ::('sf, 'sc, 'sz) formula list); ⋀φ::('sf, 'sc, 'sz) formula. List.member Γ φ ⟹ ν ∈ fml_sem I φ⟧ ⟹ ∃φ::('sf, 'sc, 'sz) formula. List.member Δ φ ∧ ν ∈ fml_sem I φ›*) using and_foldl_sem_conv (*‹(⋀φ. List.member ?Γ φ ⟹ ?ν ∈ fml_sem ?I φ) ⟹ ?ν ∈ fml_sem ?I (foldr (&&) ?Γ TT)›*) or_foldl_sem_conv (*‹?ν ∈ fml_sem ?I (foldr (||) ?Γ FF) ⟹ ∃φ. ?ν ∈ fml_sem ?I φ ∧ List.member ?Γ φ›*) apply - (*goals: 1. ‹⟦ν ∈ seq_sem I (Γ, Δ); ⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ; ⋀Γ ν I. (⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ) ⟹ ν ∈ fml_sem I (foldr (&&) Γ TT); ⋀ν I Γ. ν ∈ fml_sem I (foldr (||) Γ FF) ⟹ ∃φ. ν ∈ fml_sem I φ ∧ List.member Γ φ⟧ ⟹ ?ν ∈ seq_sem ?I (?Γ, ?Δ)› 2. ‹⟦ν ∈ seq_sem I (Γ, Δ); ⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ; ?ν ∈ fml_sem ?I (foldr (&&) ?Γ TT) ⟹ ?ν ∈ fml_sem ?I (foldr (||) ?Δ FF); ⋀Γ ν I. (⋀φ. List.member Γ φ ⟹ ν ∈ fml_sem I φ) ⟹ ν ∈ fml_sem I (foldr (&&) Γ TT); ⋀ν I Γ. ν ∈ fml_sem I (foldr (||) Γ FF) ⟹ ∃φ. ν ∈ fml_sem I φ ∧ List.member Γ φ⟧ ⟹ ∃φ. List.member Δ φ ∧ ν ∈ fml_sem I φ› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma seq_MP:"ν ∈ seq_sem I (Γ,Δ) ⟹ ν ∈ fml_sem I (foldr And Γ TT) ⟹ ν ∈ fml_sem I (foldr Or Δ FF)" apply (induction Δ) (*goals: 1. ‹⟦ν ∈ seq_sem I (Γ, []); ν ∈ fml_sem I (foldr (&&) Γ TT)⟧ ⟹ ν ∈ fml_sem I (foldr (||) [] FF)› 2. ‹⋀a Δ. ⟦⟦ν ∈ seq_sem I (Γ, Δ); ν ∈ fml_sem I (foldr (&&) Γ TT)⟧ ⟹ ν ∈ fml_sem I (foldr (||) Δ FF); ν ∈ seq_sem I (Γ, a # Δ); ν ∈ fml_sem I (foldr (&&) Γ TT)⟧ ⟹ ν ∈ fml_sem I (foldr (||) (a # Δ) FF)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . definition seq_valid where "seq_valid S ≡ ∀I. is_interp I ⟶ seq_sem I S = UNIV" text‹ Soundness for derived rules is local soundness, i.e. if the premisses are all true in the same interpretation, then the conclusion is also true in that same interpretation. › definition sound :: "('sf, 'sc, 'sz) rule ⇒ bool" where "sound R ⟷ (∀I. is_interp I ⟶ (∀i. i ≥ 0 ⟶ i < length (fst R) ⟶ seq_sem I (nth (fst R) i) = UNIV) ⟶ seq_sem I (snd R) = UNIV)" lemma soundI:"(⋀I. is_interp I ⟹ (⋀i. i ≥ 0 ⟹ i < length SG ⟹ seq_sem I (nth SG i) = UNIV) ⟹ seq_sem I G = UNIV) ⟹ sound (SG,G)" unfolding sound_def (*goal: ‹(⋀I. ⟦is_interp I; ⋀i. ⟦0 ≤ i; i < length SG⟧ ⟹ seq_sem I (SG ! i) = UNIV⟧ ⟹ seq_sem I G = UNIV) ⟹ ∀I. is_interp I ⟶ (∀i≥0. i < length (fst (SG, G)) ⟶ seq_sem I (fst (SG, G) ! i) = UNIV) ⟶ seq_sem I (snd (SG, G)) = UNIV›*) by auto lemma soundI':"(⋀I ν. is_interp I ⟹ (⋀i . i ≥ 0 ⟹ i < length SG ⟹ ν ∈ seq_sem I (nth SG i)) ⟹ ν ∈ seq_sem I G) ⟹ sound (SG,G)" unfolding sound_def (*goal: ‹(⋀I ν. ⟦is_interp I; ⋀i. ⟦0 ≤ i; i < length SG⟧ ⟹ ν ∈ seq_sem I (SG ! i)⟧ ⟹ ν ∈ seq_sem I G) ⟹ ∀I. is_interp I ⟶ (∀i≥0. i < length (fst (SG, G)) ⟶ seq_sem I (fst (SG, G) ! i) = UNIV) ⟶ seq_sem I (snd (SG, G)) = UNIV›*) by auto lemma soundI_mem:"(⋀I. is_interp I ⟹ (⋀φ. List.member SG φ ⟹ seq_sem I φ = UNIV) ⟹ seq_sem I C = UNIV) ⟹ sound (SG,C)" apply (auto simp add: sound_def (*‹sound ?R = (∀I. is_interp I ⟶ (∀i≥0. i < length (fst ?R) ⟶ seq_sem I (fst ?R ! i) = UNIV) ⟶ seq_sem I (snd ?R) = UNIV)›*)) (*goal: ‹(⋀I. ⟦is_interp I; ⋀φ. List.member SG φ ⟹ seq_sem I φ = UNIV⟧ ⟹ seq_sem I C = UNIV) ⟹ sound (SG, C)›*) by (metis in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*) in_set_member (*‹(?x ∈ set ?xs) = List.member ?xs ?x›*) iso_tuple_UNIV_I (*‹?x ∈ UNIV ≡ True›*) seq2fml.simps (*‹seq2fml (?ante, ?succ) = (foldr (&&) ?ante TT → foldr (||) ?succ FF)›*)) lemma soundI_memv:"(⋀I. is_interp I ⟹ (⋀φ ν. List.member SG φ ⟹ ν ∈ seq_sem I φ) ⟹ (⋀ν. ν ∈ seq_sem I C)) ⟹ sound (SG,C)" apply (rule soundI_mem (*‹(⋀I. ⟦is_interp I; ⋀φ. List.member ?SG φ ⟹ seq_sem I φ = UNIV⟧ ⟹ seq_sem I ?C = UNIV) ⟹ sound (?SG, ?C)›*)) (*goal: ‹(⋀I. ⟦is_interp I; ⋀φ ν. List.member SG φ ⟹ ν ∈ seq_sem I φ⟧ ⟹ (⋀ν. ν ∈ seq_sem I C)) ⟹ sound (SG, C)›*) using impl_sem (*‹(?ν ∈ fml_sem ?I (?A → ?B)) = (?ν ∈ fml_sem ?I ?A ⟶ ?ν ∈ fml_sem ?I ?B)›*) by blast lemma soundI_memv':"(⋀I. is_interp I ⟹ (⋀φ ν. List.member SG φ ⟹ ν ∈ seq_sem I φ) ⟹ (⋀ν. ν ∈ seq_sem I C)) ⟹ R = (SG,C) ⟹ sound R" using soundI_mem (*‹(⋀I. ⟦is_interp I; ⋀φ. List.member ?SG φ ⟹ seq_sem I φ = UNIV⟧ ⟹ seq_sem I ?C = UNIV) ⟹ sound (?SG, ?C)›*) using impl_sem (*‹(?ν ∈ fml_sem ?I (?A → ?B)) = (?ν ∈ fml_sem ?I ?A ⟶ ?ν ∈ fml_sem ?I ?B)›*) by blast lemma soundD_mem:"sound (SG,C) ⟹ (⋀I. is_interp I ⟹ (⋀φ. List.member SG φ ⟹ seq_sem I φ = UNIV) ⟹ seq_sem I C = UNIV)" apply (auto simp add: sound_def (*‹sound ?R = (∀I. is_interp I ⟶ (∀i≥0. i < length (fst ?R) ⟶ seq_sem I (fst ?R ! i) = UNIV) ⟶ seq_sem I (snd ?R) = UNIV)›*)) (*goal: ‹sound (SG::(('sf, 'sc, 'sz) formula list × ('sf, 'sc, 'sz) formula list) list, C::('sf, 'sc, 'sz) formula list × ('sf, 'sc, 'sz) formula list) ⟹ (⋀I::('sf, 'sc, 'sz) interp. ⟦is_interp I; ⋀φ::('sf, 'sc, 'sz) formula list × ('sf, 'sc, 'sz) formula list. List.member SG φ ⟹ seq_sem I φ = UNIV⟧ ⟹ seq_sem I C = UNIV)›*) using in_set_conv_nth (*‹((?x::?'a) ∈ set (?xs::?'a list)) = (∃i<length ?xs. ?xs ! i = ?x)›*) in_set_member (*‹(?x ∈ set ?xs) = List.member ?xs ?x›*) iso_tuple_UNIV_I (*‹?x ∈ UNIV ≡ True›*) seq2fml.simps (*‹seq2fml (?ante, ?succ) = (foldr (&&) ?ante TT → foldr (||) ?succ FF)›*) by (metis seq2fml.elims (*‹⟦seq2fml ?x = ?y; ⋀ante succ. ⟦?x = (ante, succ); ?y = (foldr (&&) ante TT → foldr (||) succ FF)⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma soundD_memv:"sound (SG,C) ⟹ (⋀I. is_interp I ⟹ (⋀φ ν. List.member SG φ ⟹ ν ∈ seq_sem I φ) ⟹ (⋀ν. ν ∈ seq_sem I C))" using soundD_mem (*‹⟦sound (?SG, ?C); is_interp ?I; ⋀φ. List.member ?SG φ ⟹ seq_sem ?I φ = UNIV⟧ ⟹ seq_sem ?I ?C = UNIV›*) by (metis UNIV_I (*‹?x ∈ UNIV›*) UNIV_eq_I (*‹(⋀x. x ∈ ?A) ⟹ UNIV = ?A›*)) end end
{ "path": "afp-2025-02-12/thys/Differential_Dynamic_Logic/Denotational_Semantics.thy", "repo": "afp-2025-02-12", "sha": "b238e811c61c69528511b5757719664ccac8879192316d556dbc1c8805448af5" }
theory MLSS_Proc imports MLSS_Realisation MLSS_HF_Extras MLSS_Semantics MLSS_Typing begin section ‹A Decision Procedure for MLSS› text ‹ This theory proves the soundness and completeness of the tableau calculus defined in 🗏‹./MLSS_Calculus.thy› It then lifts those properties to a recursive procedure that applies the rules of the calculus exhaustively. To obtain a decision procedure, we also prove termination. › subsection ‹Basic Definitions› definition "lin_sat b ≡ ∀b'. lexpands b' b ⟶ set b' ⊆ set b" lemma lin_satD: assumes "lin_sat b" assumes "lexpands b' b" assumes "x ∈ set b'" shows "x ∈ set b" using assms (*‹lin_sat b› ‹lexpands b' b› ‹x ∈ set b'›*) unfolding lin_sat_def (*goal: ‹x ∈ set b›*) by auto lemma not_lin_satD: "¬ lin_sat b ⟹ ∃b'. lexpands b' b ∧ set b ⊂ set (b' @ b)" unfolding lin_sat_def (*goal: ‹¬ (∀b'. lexpands b' b ⟶ set b' ⊆ set b) ⟹ ∃b'. lexpands b' b ∧ set b ⊂ set (b' @ b)›*) by auto definition "sat b ≡ lin_sat b ∧ (∄bs'. bexpands bs' b)" lemma satD: assumes "sat b" shows "lin_sat b" "∄bs'. bexpands bs' b" using assms (*‹sat b›*) unfolding sat_def (*goals: 1. ‹lin_sat b› 2. ‹∄bs'. bexpands bs' b›*) apply - (*goals: 1. ‹lin_sat (b::'a pset_atom fm list) ∧ (∄bs'::'a pset_atom fm list set. bexpands bs' b) ⟹ lin_sat b› 2. ‹lin_sat (b::'a pset_atom fm list) ∧ (∄bs'::'a pset_atom fm list set. bexpands bs' b) ⟹ ∄bs'::'a pset_atom fm list set. bexpands bs' b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . definition wits :: "'a branch ⇒ 'a set" where "wits b ≡ vars b - vars (last b)" definition pwits :: "'a branch ⇒ 'a set" where "pwits b ≡ {c ∈ wits b. ∀t ∈ subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}" lemma wits_singleton[simp]: "wits [φ] = {}" unfolding wits_def vars_branch_simps (*goal: ‹vars φ ∪ {} - vars (last [φ]) = {}›*) by simp lemma pwits_singleton[simp]: "pwits [φ] = {}" unfolding pwits_def (*goal: ‹{c ∈ wits [φ]. ∀t∈subterms (last [φ]). AT (Var c =⇩s t) ∉ set [φ] ∧ AT (t =⇩s Var c) ∉ set [φ]} = {}›*) by auto lemma pwitsD: assumes "c ∈ pwits b" shows "c ∈ wits b" "t ∈ subterms (last b) ⟹ AT (Var c =⇩s t) ∉ set b" "t ∈ subterms (last b) ⟹ AT (t =⇩s Var c) ∉ set b" using assms (*‹c ∈ pwits b›*) unfolding pwits_def (*goals: 1. ‹c ∈ wits b› 2. ‹t ∈ subterms (last b) ⟹ AT (Var c =⇩s t) ∉ set b› 3. ‹t ∈ subterms (last b) ⟹ AT (t =⇩s Var c) ∉ set b›*) apply - (*goals: 1. ‹(c::'a) ∈ {c::'a ∈ wits (b::'a pset_atom fm list). ∀t::'a pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b} ⟹ c ∈ wits b› 2. ‹⟦(t::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list)); (c::'a) ∈ {c::'a ∈ wits b. ∀t::'a pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}⟧ ⟹ AT (Var c =⇩s t) ∉ set b› 3. ‹⟦(t::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list)); (c::'a) ∈ {c::'a ∈ wits b. ∀t::'a pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}⟧ ⟹ AT (t =⇩s Var c) ∉ set b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma pwitsI: assumes "c ∈ wits b" assumes "⋀t. t ∈ subterms (last b) ⟹ AT (Var c =⇩s t) ∉ set b" assumes "⋀t. t ∈ subterms (last b) ⟹ AT (t =⇩s Var c) ∉ set b" shows "c ∈ pwits b" using assms (*‹c ∈ wits b› ‹?t ∈ subterms (last b) ⟹ AT (Var c =⇩s ?t) ∉ set b› ‹(?t::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list)) ⟹ AT (?t =⇩s Var (c::'a)) ∉ set b›*) unfolding pwits_def (*goal: ‹c ∈ {c ∈ wits b. ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) by blast lemma finite_wits: "finite (wits b)" unfolding wits_def (*goal: ‹finite (vars b - vars (last b))›*) using finite_vars_branch (*‹finite (vars ?b)›*) by auto lemma finite_pwits: "finite (pwits b)" proof (-) (*goal: ‹finite (pwits b)›*) have "pwits b ⊆ wits b" unfolding pwits_def (*goal: ‹{c::'a ∈ wits (b::'a pset_atom fm list). ∀t::'a pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b} ⊆ wits b›*) by simp then show "?thesis" (*goal: ‹finite (pwits b)›*) using finite_wits (*‹finite (wits ?b)›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast qed lemma lexpands_subterms_branch_eq: "lexpands b' b ⟹ b ≠ [] ⟹ subterms (b' @ b) = subterms b" proof (induction rule: lexpands.induct (*‹⟦lexpands ?x1.0 ?x2.0; ⋀b' b. lexpands_fm b' b ⟹ ?P b' b; ⋀b' b. lexpands_un b' b ⟹ ?P b' b; ⋀b' b. lexpands_int b' b ⟹ ?P b' b; ⋀b' b. lexpands_diff b' b ⟹ ?P b' b; ⋀b' b. lexpands_single b' b ⟹ ?P b' b; ⋀b' b. lexpands_eq b' b ⟹ ?P b' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀b' b. ⟦lexpands_fm b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀b' b. ⟦lexpands_un b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀b' b. ⟦lexpands_int b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 4. ‹⋀b' b. ⟦lexpands_diff b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 5. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 6. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (1 b' b) (*‹lexpands_fm b' b› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) apply (induction rule: lexpands_fm.induct (*‹⟦lexpands_fm ?x1.0 ?x2.0; ⋀p q b. And p q ∈ set b ⟹ ?P [p, q] b; ⋀p q b. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀p b. Neg (Neg p) ∈ set b ⟹ ?P [p] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦And p q ∈ set b; b ≠ []⟧ ⟹ subterms ([p, q] @ b) = subterms b› 2. ‹⋀p q b. ⟦Neg (Or p q) ∈ set b; b ≠ []⟧ ⟹ subterms ([Neg p, Neg q] @ b) = subterms b› 3. ‹⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b; b ≠ []⟧ ⟹ subterms ([q] @ b) = subterms b› 4. ‹⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b; b ≠ []⟧ ⟹ subterms ([p] @ b) = subterms b› 5. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b; b ≠ []⟧ ⟹ subterms ([Neg q] @ b) = subterms b› 6. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b; b ≠ []⟧ ⟹ subterms ([Neg p] @ b) = subterms b› 7. ‹⋀p b. ⟦Neg (Neg p) ∈ set b; b ≠ []⟧ ⟹ subterms ([p] @ b) = subterms b› discuss goal 1*) apply ((auto simp: subterms_branch_def (*‹subterms (?b::?'a::type pset_atom fm list) ≡ ⋃ (subterms ` set ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*))[1]) (*discuss goal 3*) apply ((auto simp: subterms_branch_def (*‹subterms (?b::?'a::type pset_atom fm list) ≡ ⋃ (subterms ` set ?b)›*))[1]) (*discuss goal 4*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*))[1]) (*discuss goal 5*) apply ((auto simp: subterms_branch_def (*‹subterms (?b::?'a pset_atom fm list) ≡ ⋃ (subterms ` set ?b)›*))[1]) (*discuss goal 6*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*))[1]) (*discuss goal 7*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*))[1]) (*proven 7 subgoals*) . next (*goals: 1. ‹⋀b' b. ⟦lexpands_un b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀b' b. ⟦lexpands_int b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀b' b. ⟦lexpands_diff b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 4. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 5. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (2 b' b) (*‹lexpands_un b' b› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) apply (induction rule: lexpands_un.induct (*‹⟦lexpands_un ?x1.0 ?x2.0; ⋀s t1 t2 b. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹subterms (b' @ b) = subterms b›*) using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl] (*‹⟦?b ≠ []; ?t ∈ subterms (last ?b)⟧ ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; ⋀(b::?'a26 pset_atom fm list) t::?'a26 pset_term. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = subterms b› 2. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; ⋀(b::?'a22 pset_atom fm list) t::?'a22 pset_term. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = subterms b› 3. ‹⋀(s::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) t1::'a pset_term. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; ⋀(b::?'a18 pset_atom fm list) t::?'a18 pset_term. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = subterms b› 4. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; b ≠ []; ⋀(b::?'a14 pset_atom fm list) t::?'a14 pset_term. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t2)] @ b) = subterms b› 5. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; ⋀(b::?'a10 pset_atom fm list) t::?'a10 pset_term. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1)] @ b) = subterms b› 6. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; ⋀(b::?'a6 pset_atom fm list) t::?'a6 pset_term. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = subterms b› discuss goal 1*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 6*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_int b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_diff b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_single b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 4. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_eq b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (3 b' b) (*‹lexpands_int b' b› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = subterms b›*) apply (induction rule: lexpands_int.induct (*‹⟦lexpands_int ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹subterms ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = subterms b›*) using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl] (*‹⟦?b ≠ []; ?t ∈ subterms (last ?b)⟧ ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = subterms b› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = subterms b› 3. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = subterms b› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t2)] @ b) = subterms b› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1)] @ b) = subterms b› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = subterms b› discuss goal 1*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦(?s::?'a pset_term) ∈ subterms (?t::?'a pset_term); ?t ∈ subterms (?b::?'a pset_atom fm list)⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AT ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AF ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 6*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_diff b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_single b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_eq b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (4 b' b) (*‹lexpands_diff b' b› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) apply (induction rule: lexpands_diff.induct (*‹⟦lexpands_diff ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹subterms (b' @ b) = subterms b›*) using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl] (*‹⟦?b ≠ []; ?t ∈ subterms (last ?b)⟧ ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = subterms b› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = subterms b› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = subterms b› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t2)] @ b) = subterms b› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AF (s ∈⇩s t1)] @ b) = subterms b› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; ⋀b t. ⟦b ≠ []; t ∈ subterms (last b)⟧ ⟹ t ∈ subterms b⟧ ⟹ subterms ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = subterms b› discuss goal 1*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b::type pset_atom fm) # (?xs::?'b::type pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦(?s::?'a::type pset_term) ∈ subterms (?t::?'a::type pset_term); ?t ∈ subterms (?b::?'a::type pset_atom fm list)⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹(?t1.0::?'a::type pset_term) ⊔⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) ⊔⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) ⊓⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) ⊓⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) -⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) -⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AT ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AF ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b::type pset_atom fm) # (?xs::?'b::type pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦(?s::?'a::type pset_term) ∈ subterms (?t::?'a::type pset_term); ?t ∈ subterms (?b::?'a::type pset_atom fm list)⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹(?t1.0::?'a::type pset_term) ⊔⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) ⊔⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) ⊓⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) ⊓⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) -⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a::type pset_term) -⇩s (?t2.0::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a::type pset_term) ∈ subterms (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AT ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AF ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 6*) apply ((auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*proven 6 subgoals*) . next (*goals: 1. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (5 b' b) (*‹lexpands_single b' b› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) proof (induction rule: lexpands_single.induct (*‹⟦lexpands_single (?x1.0::?'a pset_atom fm list) (?x2.0::?'a pset_atom fm list); ⋀(t1::?'a pset_term) b::?'a pset_atom fm list. Single t1 ∈ subterms (last b) ⟹ (?P::?'a pset_atom fm list ⇒ ?'a pset_atom fm list ⇒ bool) [AT (t1 ∈⇩s Single t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) b::?'a pset_atom fm list. AT (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AT (s =⇩s t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) b::?'a pset_atom fm list. AF (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AF (s =⇩s t1)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀t1 b. ⟦Single t1 ∈ subterms (last b); b ≠ []⟧ ⟹ subterms ([AT (t1 ∈⇩s Single t1)] @ b) = subterms b› 2. ‹⋀s t1 b. ⟦AT (s ∈⇩s Single t1) ∈ set b; b ≠ []⟧ ⟹ subterms ([AT (s =⇩s t1)] @ b) = subterms b› 3. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []⟧ ⟹ subterms ([AF (s =⇩s t1)] @ b) = subterms b›*) case (1 t1 b) (*‹Single t1 ∈ subterms (last b)› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms ([AT (t1 ∈⇩s Single t1)] @ b) = subterms b›*) using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl] (*‹⟦?b ≠ []; ?t ∈ subterms (last ?b)⟧ ⟹ ?t ∈ subterms ?b›*) by (auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) dest: subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*)) qed (auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) intro: subterms_term_subterms_branch_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?b⟧ ⟹ ?s ∈ subterms ?b›*)) (*solves the remaining goals: 1. ‹⋀s t1 b. ⟦AT (s ∈⇩s Single t1) ∈ set b; b ≠ []⟧ ⟹ subterms ([AT (s =⇩s t1)] @ b) = subterms b› 2. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []⟧ ⟹ subterms ([AF (s =⇩s t1)] @ b) = subterms b›*) next (*goal: ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (6 b' b) (*‹lexpands_eq b' b› ‹b ≠ []›*) have "*": "subterms_atom (subst_tlvl t1 t2 a) ⊆ subterms t2 ∪ subterms_atom a" for t1 and t2 and a :: "'a pset_atom" apply (cases "(t1, t2, a)" rule: subst_tlvl.cases (*‹⟦⋀t1 t2 s1 s2. ?x = (t1, t2, s1 ∈⇩s s2) ⟹ ?P; ⋀t1 t2 s1 s2. ?x = (t1, t2, s1 =⇩s s2) ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀t1a t2a s1 s2. (t1, t2, a) = (t1a, t2a, s1 ∈⇩s s2) ⟹ subterms (subst_tlvl t1 t2 a) ⊆ subterms t2 ∪ subterms a› 2. ‹⋀t1a t2a s1 s2. (t1, t2, a) = (t1a, t2a, s1 =⇩s s2) ⟹ subterms (subst_tlvl t1 t2 a) ⊆ subterms t2 ∪ subterms a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from "6" (*‹lexpands_eq b' b› ‹(b::'a pset_atom fm list) ≠ []›*) show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) apply (induction rule: lexpands_eq.induct (*‹⟦lexpands_eq (?x1.0::?'a pset_atom fm list) (?x2.0::?'a pset_atom fm list); ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ (?P::?'a pset_atom fm list ⇒ ?'a pset_atom fm list ⇒ bool) [AT (subst_tlvl t1 t2 l)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t1 t2 l)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t2 t1 l)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t2 t1 l)] b; ⋀(s::?'a pset_term) (t::?'a pset_term) (b::?'a pset_atom fm list) s'::?'a pset_term. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b⟧ ⟹ ?P [AF (s =⇩s s')] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀(t1::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) l::'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []⟧ ⟹ subterms ([AT (subst_tlvl t1 t2 l)] @ b) = subterms b› 2. ‹⋀(t1::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) l::'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []⟧ ⟹ subterms ([AF (subst_tlvl t1 t2 l)] @ b) = subterms b› 3. ‹⋀(t1::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) l::'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []⟧ ⟹ subterms ([AT (subst_tlvl t2 t1 l)] @ b) = subterms b› 4. ‹⋀(t1::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) l::'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []⟧ ⟹ subterms ([AF (subst_tlvl t2 t1 l)] @ b) = subterms b› 5. ‹⋀(s::'a pset_term) (t::'a pset_term) (b::'a pset_atom fm list) s'::'a pset_term. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; b ≠ []⟧ ⟹ subterms ([AF (s =⇩s s')] @ b) = subterms b› discuss goal 1*) apply ((auto simp: subterms_branch_def (*‹subterms (?b::?'a::type pset_atom fm list) ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT (?a::?'a::type pset_atom) ∈ set (?b::?'a::type pset_atom fm list); (?x::?'a::type pset_term) ∈ subterms (?s::?'a::type pset_term); ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) dest!: subsetD[OF *] (*‹(?c::'a::type pset_term) ∈ subterms (subst_tlvl (?t1.1::'a::type pset_term) (?t2.1::'a::type pset_term) (?a1::'a::type pset_atom)) ⟹ ?c ∈ subterms ?t2.1 ∪ subterms ?a1›*))[1]) (*discuss goal 2*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) dest!: subsetD[OF *] (*‹?c ∈ subterms (subst_tlvl ?t1.1 ?t2.1 ?a1) ⟹ ?c ∈ subterms ?t2.1 ∪ subterms ?a1›*))[1]) (*discuss goal 3*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) dest!: subsetD[OF *] (*‹?c ∈ subterms (subst_tlvl ?t1.1 ?t2.1 ?a1) ⟹ ?c ∈ subterms ?t2.1 ∪ subterms ?a1›*))[1]) (*discuss goal 4*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) dest!: subsetD[OF *] (*‹?c ∈ subterms (subst_tlvl ?t1.1 ?t2.1 ?a1) ⟹ ?c ∈ subterms ?t2.1 ∪ subterms ?a1›*))[1]) (*discuss goal 5*) apply ((auto simp: subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) dest!: subsetD[OF *] (*‹?c ∈ subterms (subst_tlvl ?t1.1 ?t2.1 ?a1) ⟹ ?c ∈ subterms ?t2.1 ∪ subterms ?a1›*))[1]) (*proven 5 subgoals*) . qed lemma lexpands_vars_branch_eq: "lexpands b' b ⟹ b ≠ [] ⟹ vars (b' @ b) = vars b" using lexpands_subterms_branch_eq (*‹⟦lexpands ?b' ?b; ?b ≠ []⟧ ⟹ subterms (?b' @ ?b) = subterms ?b›*) subterms_branch_eq_if_vars_branch_eq (*‹subterms ?b1.0 = subterms ?b2.0 ⟹ vars ?b1.0 = vars ?b2.0›*) by metis lemma bexpands_nowit_subterms_branch_eq: "bexpands_nowit bs' b ⟹ b' ∈ bs' ⟹ b ≠ [] ⟹ subterms (b' @ b) = subterms b" proof (induction rule: bexpands_nowit.induct (*‹⟦bexpands_nowit ?x1.0 ?x2.0; ⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b⟧ ⟹ ?P {[p], [Neg p]} b; ⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b⟧ ⟹ ?P {[Neg p], [p]} b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (3 s t1 t2 b) (*‹AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term) ⊔⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹t1 ⊔⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t1) ∉ set b› ‹AF (s ∈⇩s t1) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) by (auto simp: subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*)) next (*goals: 1. ‹⋀(p::'a::type pset_atom fm) (q::'a::type pset_atom fm) b::'a::type pset_atom fm list. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; (b'::'a::type pset_atom fm list) ∈ {[p], [Neg p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀(p::'a::type pset_atom fm) (q::'a::type pset_atom fm) b::'a::type pset_atom fm list. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; (b'::'a::type pset_atom fm list) ∈ {[Neg p], [p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀(s::'a::type pset_term) (t1::'a::type pset_term) (b::'a::type pset_atom fm list) t2::'a::type pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; (b'::'a::type pset_atom fm list) ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 4. ‹⋀(s::'a::type pset_term) (t1::'a::type pset_term) (b::'a::type pset_atom fm list) t2::'a::type pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; (b'::'a::type pset_atom fm list) ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (4 s t1 b t2) (*‹AT (s ∈⇩s t1) ∈ set b› ‹t1 ⊓⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t2) ∉ set b› ‹AF (s ∈⇩s t2) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}› ‹(b::'a pset_atom fm list) ≠ []›*) then show "?case" (*goal: ‹subterms ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = subterms b›*) using subterms_branch_subterms_subterms_fm_trans[OF _ _ "4" ( 2 )] (*‹⟦b ≠ []; ?x ∈ subterms (t1 ⊓⇩s t2)⟧ ⟹ ?x ∈ subterms b›*) by (auto simp: subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*)) next (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 3. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) case (5 s t1 b t2) (*‹AT (s ∈⇩s t1) ∈ set b› ‹(t1::'a::type pset_term) -⇩s (t2::'a::type pset_term) ∈ subterms (last (b::'a::type pset_atom fm list))› ‹AT (s ∈⇩s t2) ∉ set b› ‹AF (s ∈⇩s t2) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}› ‹b ≠ []›*) then show "?case" (*goal: ‹subterms (b' @ b) = subterms b›*) using subterms_branch_subterms_subterms_fm_trans[OF _ _ "5" ( 2 )] (*‹⟦b ≠ []; ?x ∈ subterms (t1 -⇩s t2)⟧ ⟹ ?x ∈ subterms b›*) by (auto simp: subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*)) qed (use subterms_branch_def in ‹(fastforce simp: subterms_branch_simps)+›) (*solves the remaining goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []⟧ ⟹ subterms (b' @ b) = subterms b›*) lemma bexpands_nowit_vars_branch_eq: "bexpands_nowit bs' b ⟹ b' ∈ bs' ⟹ b ≠ [] ⟹ vars (b' @ b) = vars b" using bexpands_nowit_subterms_branch_eq (*‹⟦bexpands_nowit ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []⟧ ⟹ subterms (?b' @ ?b) = subterms ?b›*) subterms_branch_eq_if_vars_branch_eq (*‹subterms ?b1.0 = subterms ?b2.0 ⟹ vars ?b1.0 = vars ?b2.0›*) by metis lemma lexpands_wits_eq: "lexpands b' b ⟹ b ≠ [] ⟹ wits (b' @ b) = wits b" using lexpands_vars_branch_eq (*‹⟦lexpands ?b' ?b; ?b ≠ []⟧ ⟹ vars (?b' @ ?b) = vars ?b›*) unfolding wits_def (*goal: ‹⟦lexpands b' b; b ≠ []⟧ ⟹ vars (b' @ b) - vars (last (b' @ b)) = vars b - vars (last b)›*) by force lemma bexpands_nowit_wits_eq: assumes "bexpands_nowit bs' b" "b' ∈ bs'" "b ≠ []" shows "wits (b' @ b) = wits b" using bexpands_nowit_vars_branch_eq[OF assms] (*‹vars (b' @ b) = vars b›*) assms(3) (*‹b ≠ []›*) unfolding wits_def (*goal: ‹vars (b' @ b) - vars (last (b' @ b)) = vars b - vars (last b)›*) by simp lemma bexpands_wit_vars_branch_eq: assumes "bexpands_wit t1 t2 x bs' b" "b' ∈ bs'" "b ≠ []" shows "vars (b' @ b) = insert x (vars b)" using assms (*‹bexpands_wit t1 t2 x bs' b› ‹b' ∈ bs'› ‹b ≠ []›*) bexpands_witD[OF assms ( 1 )] (*‹bs' = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}› ‹AF ((t1::'a pset_term) =⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹t1 ∈ subterms (last b)› ‹t2 ∈ subterms (last b)› ‹∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b› ‹∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b› ‹¬ urelem (last b) t1› ‹¬ urelem (last b) t2› ‹x ∉ vars b›*) by (auto simp: mem_vars_fm_if_mem_subterms_fm (*‹⟦(?x::?'a) ∈ vars (?s::?'a pset_term); ?s ∈ subterms (?φ::?'a pset_atom fm)⟧ ⟹ ?x ∈ vars ?φ›*) vars_branch_simps (*‹vars [] = {}› ‹vars ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = vars ?x ∪ vars ?xs›*) vars_fm_vars_branchI (*‹⟦(?φ::?'a pset_atom fm) ∈ set (?b::?'a pset_atom fm list); (?x::?'a) ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*)) lemma bexpands_wit_wits_eq: assumes "bexpands_wit t1 t2 x bs' b" "b' ∈ bs'" "b ≠ []" shows "wits (b' @ b) = insert x (wits b)" using assms (*‹bexpands_wit t1 t2 x bs' b› ‹(b'::'a pset_atom fm list) ∈ (bs'::'a pset_atom fm list set)› ‹b ≠ []›*) bexpands_witD[OF assms ( 1 )] (*‹bs' = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}› ‹AF (t1 =⇩s t2) ∈ set b› ‹(t1::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list))› ‹(t2::'a::type pset_term) ∈ subterms (last (b::'a::type pset_atom fm list))› ‹∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b› ‹∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b› ‹¬ urelem (last b) t1› ‹¬ urelem (last b) t2› ‹x ∉ vars b›*) unfolding wits_def (*goal: ‹vars (b' @ b) - vars (last (b' @ b)) = insert x (vars b - vars (last b))›*) by (auto simp: mem_vars_fm_if_mem_subterms_fm (*‹⟦?x ∈ vars ?s; ?s ∈ subterms ?φ⟧ ⟹ ?x ∈ vars ?φ›*) vars_branch_simps (*‹vars [] = {}› ‹vars (?x # ?xs) = vars ?x ∪ vars ?xs›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) lemma lexpands_pwits_subs: assumes "lexpands b' b" "b ≠ []" shows "pwits (b' @ b) ⊆ pwits b" using assms (*‹lexpands (b'::'a::type pset_atom fm list) (b::'a::type pset_atom fm list)› ‹b ≠ []›*) lexpands_wits_eq[OF assms] (*‹wits (b' @ b) = wits b›*) apply (induction rule: lexpands_induct (*‹⟦lexpands (?b'::?'a pset_atom fm list) (?b::?'a pset_atom fm list); ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. And p q ∈ set b ⟹ (?P::?'a pset_atom fm list ⇒ ?'a pset_atom fm list ⇒ bool) [p, q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀(p::?'a pset_atom fm) b::?'a pset_atom fm list. Neg (Neg p) ∈ set b ⟹ ?P [p] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀(s::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) t1::?'a pset_term. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀(s::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) t1::?'a pset_term. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀(s::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) t1::?'a pset_term. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b; ⋀(t1::?'a pset_term) b::?'a pset_atom fm list. Single t1 ∈ subterms (last b) ⟹ ?P [AT (t1 ∈⇩s Single t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) b::?'a pset_atom fm list. AT (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AT (s =⇩s t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) b::?'a pset_atom fm list. AF (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AF (s =⇩s t1)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t1 t2 l)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t1 t2 l)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t2 t1 l)] b; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) l::?'a pset_atom. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t2 t1 l)] b; ⋀(s::?'a pset_term) (t::?'a pset_term) (b::?'a pset_atom fm list) s'::?'a pset_term. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b⟧ ⟹ ?P [AF (s =⇩s s')] b⟧ ⟹ ?P ?b' ?b›*)) (*goals: 1. ‹⋀p q b. ⟦And p q ∈ set b; b ≠ []; wits ([p, q] @ b) = wits b⟧ ⟹ pwits ([p, q] @ b) ⊆ pwits b› 2. ‹⋀p q b. ⟦Neg (Or p q) ∈ set b; b ≠ []; wits ([Neg p, Neg q] @ b) = wits b⟧ ⟹ pwits ([Neg p, Neg q] @ b) ⊆ pwits b› 3. ‹⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b; b ≠ []; wits ([q] @ b) = wits b⟧ ⟹ pwits ([q] @ b) ⊆ pwits b› 4. ‹⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b; b ≠ []; wits ([p] @ b) = wits b⟧ ⟹ pwits ([p] @ b) ⊆ pwits b› 5. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b; b ≠ []; wits ([Neg q] @ b) = wits b⟧ ⟹ pwits ([Neg q] @ b) ⊆ pwits b› 6. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b; b ≠ []; wits ([Neg p] @ b) = wits b⟧ ⟹ pwits ([Neg p] @ b) ⊆ pwits b› 7. ‹⋀p b. ⟦Neg (Neg p) ∈ set b; b ≠ []; wits ([p] @ b) = wits b⟧ ⟹ pwits ([p] @ b) ⊆ pwits b› 8. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; wits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b› 9. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b› 10. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b› 11. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; b ≠ []; wits ([AT (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b› 12. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; wits ([AT (s ∈⇩s t1)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1)] @ b) ⊆ pwits b› 13. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b› 14. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; b ≠ []; wits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) ⊆ pwits b› 15. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b› 16. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b› 17. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; wits ([AF (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t2)] @ b) ⊆ pwits b› 18. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; wits ([AF (s ∈⇩s t1)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b› 19. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b› 20. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; b ≠ []; wits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b› 21. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b› 22. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b› 23. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; wits ([AT (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b› 24. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; wits ([AF (s ∈⇩s t1)] @ b) = wits b⟧ ⟹ pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b› 25. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; wits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = wits b⟧ ⟹ pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b› 26. ‹⋀t1 b. ⟦Single t1 ∈ subterms (last b); b ≠ []; wits ([AT (t1 ∈⇩s Single t1)] @ b) = wits b⟧ ⟹ pwits ([AT (t1 ∈⇩s Single t1)] @ b) ⊆ pwits b› 27. ‹⋀s t1 b. ⟦AT (s ∈⇩s Single t1) ∈ set b; b ≠ []; wits ([AT (s =⇩s t1)] @ b) = wits b⟧ ⟹ pwits ([AT (s =⇩s t1)] @ b) ⊆ pwits b› 28. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []; wits ([AF (s =⇩s t1)] @ b) = wits b⟧ ⟹ pwits ([AF (s =⇩s t1)] @ b) ⊆ pwits b› 29. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []; wits ([AT (subst_tlvl t1 t2 l)] @ b) = wits b⟧ ⟹ pwits ([AT (subst_tlvl t1 t2 l)] @ b) ⊆ pwits b› 30. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []; wits ([AF (subst_tlvl t1 t2 l)] @ b) = wits b⟧ ⟹ pwits ([AF (subst_tlvl t1 t2 l)] @ b) ⊆ pwits b› 31. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []; wits ([AT (subst_tlvl t2 t1 l)] @ b) = wits b⟧ ⟹ pwits ([AT (subst_tlvl t2 t1 l)] @ b) ⊆ pwits b› 32. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []; wits ([AF (subst_tlvl t2 t1 l)] @ b) = wits b⟧ ⟹ pwits ([AF (subst_tlvl t2 t1 l)] @ b) ⊆ pwits b› 33. ‹⋀s t b s'. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; b ≠ []; wits ([AF (s =⇩s s')] @ b) = wits b⟧ ⟹ pwits ([AF (s =⇩s s')] @ b) ⊆ pwits b› discuss goal 1*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 2*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 3*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 4*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 5*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 6*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 7*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 8*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 9*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 10*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 11*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 12*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 13*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 14*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 15*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 16*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 17*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 18*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 19*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 20*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 21*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 22*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 23*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 24*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 25*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 26*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 27*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 28*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 29*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 30*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 31*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a::type pset_atom fm list) ≡ {c::?'a::type ∈ wits ?b. ∀t::?'a::type pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 32*) apply ((auto simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*discuss goal 33*) apply ((auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*))[1]) (*proven 33 subgoals*) . subsubsection ‹‹no_new_subterms›› definition "no_new_subterms b ≡ ∀t ∈ subterms b. t ∉ Var ` wits b ⟶ t ∈ subterms (last b)" lemma no_new_subtermsI: assumes "⋀t. t ∈ subterms b ⟹ t ∉ Var ` wits b ⟹ t ∈ subterms (last b)" shows "no_new_subterms b" using assms (*‹⟦?t ∈ subterms b; ?t ∉ Var ` wits b⟧ ⟹ ?t ∈ subterms (last b)›*) unfolding no_new_subterms_def (*goal: ‹∀t::'a pset_term∈subterms (b::'a pset_atom fm list). t ∉ Var ` wits b ⟶ t ∈ subterms (last b)›*) by blast lemma Var_mem_subterms_branch_and_not_in_wits: assumes "Var v ∈ subterms b" "v ∉ wits b" shows "v ∈ vars (last b)" using assms (*‹Var v ∈ subterms b› ‹v ∉ wits b›*) unfolding wits_def no_new_subterms_def (*goal: ‹v ∈ vars (last b)›*) by (auto simp: image_set_diff[unfolded inj_on_def] (*‹∀x∈UNIV. ∀y∈UNIV. ?f x = ?f y ⟶ x = y ⟹ ?f ` (?A - ?B) = ?f ` ?A - ?f ` ?B›*) image_UN (*‹?f ` ⋃ (?B ` ?A) = (⋃x∈?A. ?f ` ?B x)›*) Un_vars_term_subterms_branch_eq_vars_branch[symmetric] (*‹vars ?b = ⋃ (vars ` subterms ?b)›*)) lemma subterms_branch_cases: assumes "t ∈ subterms b" "t ∉ Var ` wits b" obtains (Empty) n where "t = ∅ n" | (Union) t1 t2 where "t = t1 ⊔⇩s t2" | (Inter) t1 t2 where "t = t1 ⊓⇩s t2" | (Diff) t1 t2 where "t = t1 -⇩s t2" | (Single) t1 where "t = Single t1" | (Var) v where "t = Var v" "v ∈ vars (last b)" proof (cases t) (*goals: 1. ‹⋀x1::nat. ⟦⋀n::nat. (t::'a pset_term) = ∅ n ⟹ thesis::bool; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 -⇩s t2 ⟹ thesis; ⋀t1::'a pset_term. t = Single t1 ⟹ thesis; ⋀v::'a. ⟦t = Var v; v ∈ vars (last (b::'a pset_atom fm list))⟧ ⟹ thesis; t = ∅ x1⟧ ⟹ thesis› 2. ‹⋀x2::'a. ⟦⋀n::nat. (t::'a pset_term) = ∅ n ⟹ thesis::bool; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 -⇩s t2 ⟹ thesis; ⋀t1::'a pset_term. t = Single t1 ⟹ thesis; ⋀v::'a. ⟦t = Var v; v ∈ vars (last (b::'a pset_atom fm list))⟧ ⟹ thesis; t = Var x2⟧ ⟹ thesis› 3. ‹⋀(x31::'a pset_term) x32::'a pset_term. ⟦⋀n::nat. (t::'a pset_term) = ∅ n ⟹ thesis::bool; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 -⇩s t2 ⟹ thesis; ⋀t1::'a pset_term. t = Single t1 ⟹ thesis; ⋀v::'a. ⟦t = Var v; v ∈ vars (last (b::'a pset_atom fm list))⟧ ⟹ thesis; t = x31 ⊔⇩s x32⟧ ⟹ thesis› 4. ‹⋀(x41::'a pset_term) x42::'a pset_term. ⟦⋀n::nat. (t::'a pset_term) = ∅ n ⟹ thesis::bool; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 -⇩s t2 ⟹ thesis; ⋀t1::'a pset_term. t = Single t1 ⟹ thesis; ⋀v::'a. ⟦t = Var v; v ∈ vars (last (b::'a pset_atom fm list))⟧ ⟹ thesis; t = x41 ⊓⇩s x42⟧ ⟹ thesis› 5. ‹⋀(x51::'a pset_term) x52::'a pset_term. ⟦⋀n::nat. (t::'a pset_term) = ∅ n ⟹ thesis::bool; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 -⇩s t2 ⟹ thesis; ⋀t1::'a pset_term. t = Single t1 ⟹ thesis; ⋀v::'a. ⟦t = Var v; v ∈ vars (last (b::'a pset_atom fm list))⟧ ⟹ thesis; t = x51 -⇩s x52⟧ ⟹ thesis› 6. ‹⋀x6::'a pset_term. ⟦⋀n::nat. (t::'a pset_term) = ∅ n ⟹ thesis::bool; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀(t1::'a pset_term) t2::'a pset_term. t = t1 -⇩s t2 ⟹ thesis; ⋀t1::'a pset_term. t = Single t1 ⟹ thesis; ⋀v::'a. ⟦t = Var v; v ∈ vars (last (b::'a pset_atom fm list))⟧ ⟹ thesis; t = Single x6⟧ ⟹ thesis›*) case (Var x) (*‹t = Var x›*) with assms (*‹t ∈ subterms b› ‹t ∉ Var ` wits b›*) have "x ∈ vars (last b)" using Var_mem_subterms_branch_and_not_in_wits (*‹⟦Var ?v ∈ subterms ?b; ?v ∉ wits ?b⟧ ⟹ ?v ∈ vars (last ?b)›*) by (metis imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*)) with Var (*‹t = Var x›*) that (*‹t = ∅ ?n ⟹ thesis› ‹(t::'a pset_term) = (?t1.0::'a pset_term) ⊔⇩s (?t2.0::'a pset_term) ⟹ thesis::bool› ‹(t::'a pset_term) = (?t1.0::'a pset_term) ⊓⇩s (?t2.0::'a pset_term) ⟹ thesis::bool› ‹t = ?t1.0 -⇩s ?t2.0 ⟹ thesis› ‹t = Single ?t1.0 ⟹ thesis› ‹⟦t = Var ?v; ?v ∈ vars (last b)⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹thesis›*) by blast qed (use assms that in auto) (*solves the remaining goals: 1. ‹⋀x1. ⟦⋀n. t = ∅ n ⟹ thesis; ⋀t1 t2. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 -⇩s t2 ⟹ thesis; ⋀t1. t = Single t1 ⟹ thesis; ⋀v. ⟦t = Var v; v ∈ vars (last b)⟧ ⟹ thesis; t = ∅ x1⟧ ⟹ thesis› 2. ‹⋀x31 x32. ⟦⋀n. t = ∅ n ⟹ thesis; ⋀t1 t2. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 -⇩s t2 ⟹ thesis; ⋀t1. t = Single t1 ⟹ thesis; ⋀v. ⟦t = Var v; v ∈ vars (last b)⟧ ⟹ thesis; t = x31 ⊔⇩s x32⟧ ⟹ thesis› 3. ‹⋀x41 x42. ⟦⋀n. t = ∅ n ⟹ thesis; ⋀t1 t2. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 -⇩s t2 ⟹ thesis; ⋀t1. t = Single t1 ⟹ thesis; ⋀v. ⟦t = Var v; v ∈ vars (last b)⟧ ⟹ thesis; t = x41 ⊓⇩s x42⟧ ⟹ thesis› 4. ‹⋀x51 x52. ⟦⋀n. t = ∅ n ⟹ thesis; ⋀t1 t2. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 -⇩s t2 ⟹ thesis; ⋀t1. t = Single t1 ⟹ thesis; ⋀v. ⟦t = Var v; v ∈ vars (last b)⟧ ⟹ thesis; t = x51 -⇩s x52⟧ ⟹ thesis› 5. ‹⋀x6. ⟦⋀n. t = ∅ n ⟹ thesis; ⋀t1 t2. t = t1 ⊔⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 ⊓⇩s t2 ⟹ thesis; ⋀t1 t2. t = t1 -⇩s t2 ⟹ thesis; ⋀t1. t = Single t1 ⟹ thesis; ⋀v. ⟦t = Var v; v ∈ vars (last b)⟧ ⟹ thesis; t = Single x6⟧ ⟹ thesis›*) lemma no_new_subterms_casesI[case_names Empty Union Inter Diff Single]: assumes "⋀n. ∅ n ∈ subterms b ⟹ ∅ n ∈ subterms (last b)" assumes "⋀t1 t2. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b)" assumes "⋀t1 t2. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b)" assumes "⋀t1 t2. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b)" assumes "⋀t. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b)" shows "no_new_subterms b" proof (intro no_new_subtermsI (*‹(⋀t. ⟦t ∈ subterms ?b; t ∉ Var ` wits ?b⟧ ⟹ t ∈ subterms (last ?b)) ⟹ no_new_subterms ?b›*)) (*goal: ‹⋀t. ⟦t ∈ subterms b; t ∉ Var ` wits b⟧ ⟹ t ∈ subterms (last b)›*) fix t assume "t ∈ subterms b" "t ∉ Var ` wits b" (*‹(t::'a pset_term) ∈ subterms (b::'a pset_atom fm list)› ‹(t::'a pset_term) ∉ Var ` wits (b::'a pset_atom fm list)›*) with this (*‹t ∈ subterms b› ‹t ∉ Var ` wits b›*) assms (*‹∅ ?n::nat ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ ?n ∈ subterms (last b)› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms b ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last b)› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms b ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last b)› ‹?t1.0 -⇩s ?t2.0 ∈ subterms b ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last b)› ‹Single ?t ∈ subterms b ⟹ Single ?t ∈ subterms (last b)›*) show "t ∈ subterms (last b)" apply (cases t rule: subterms_branch_cases (*‹⟦?t ∈ subterms ?b; ?t ∉ Var ` wits ?b; ⋀n. ?t = ∅ n ⟹ ?thesis; ⋀t1 t2. ?t = t1 ⊔⇩s t2 ⟹ ?thesis; ⋀t1 t2. ?t = t1 ⊓⇩s t2 ⟹ ?thesis; ⋀t1 t2. ?t = t1 -⇩s t2 ⟹ ?thesis; ⋀t1. ?t = Single t1 ⟹ ?thesis; ⋀v. ⟦?t = Var v; v ∈ vars (last ?b)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀n::nat. ⟦⋀n::nat. ∅ n ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ n ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t::'a pset_term. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b); (t::'a pset_term) ∈ subterms b; t ∉ Var ` wits b; t = ∅ n⟧ ⟹ t ∈ subterms (last b)› 2. ‹⋀(t1::'a pset_term) t2::'a pset_term. ⟦⋀n::nat. ∅ n ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ n ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t::'a pset_term. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b); (t::'a pset_term) ∈ subterms b; t ∉ Var ` wits b; t = t1 ⊔⇩s t2⟧ ⟹ t ∈ subterms (last b)› 3. ‹⋀(t1::'a pset_term) t2::'a pset_term. ⟦⋀n::nat. ∅ n ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ n ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t::'a pset_term. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b); (t::'a pset_term) ∈ subterms b; t ∉ Var ` wits b; t = t1 ⊓⇩s t2⟧ ⟹ t ∈ subterms (last b)› 4. ‹⋀(t1::'a pset_term) t2::'a pset_term. ⟦⋀n::nat. ∅ n ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ n ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t::'a pset_term. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b); (t::'a pset_term) ∈ subterms b; t ∉ Var ` wits b; t = t1 -⇩s t2⟧ ⟹ t ∈ subterms (last b)› 5. ‹⋀t1::'a pset_term. ⟦⋀n::nat. ∅ n ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ n ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t::'a pset_term. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b); (t::'a pset_term) ∈ subterms b; t ∉ Var ` wits b; t = Single t1⟧ ⟹ t ∈ subterms (last b)› 6. ‹⋀v::'a. ⟦⋀n::nat. ∅ n ∈ subterms (b::'a pset_atom fm list) ⟹ ∅ n ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀(t1::'a pset_term) t2::'a pset_term. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t::'a pset_term. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b); (t::'a pset_term) ∈ subterms b; t ∉ Var ` wits b; t = Var v; v ∈ vars (last b)⟧ ⟹ t ∈ subterms (last b)› discuss goal 1*) apply ((auto simp: vars_fm_subs_subterms_fm (*‹?v ∈ vars ?φ ⟹ Var ?v ∈ subterms ?φ›*))[1]) (*discuss goal 2*) apply ((auto simp: vars_fm_subs_subterms_fm (*‹?v ∈ vars ?φ ⟹ Var ?v ∈ subterms ?φ›*))[1]) (*discuss goal 3*) apply ((auto simp: vars_fm_subs_subterms_fm (*‹?v ∈ vars ?φ ⟹ Var ?v ∈ subterms ?φ›*))[1]) (*discuss goal 4*) apply ((auto simp: vars_fm_subs_subterms_fm (*‹?v ∈ vars ?φ ⟹ Var ?v ∈ subterms ?φ›*))[1]) (*discuss goal 5*) apply ((auto simp: vars_fm_subs_subterms_fm (*‹?v ∈ vars ?φ ⟹ Var ?v ∈ subterms ?φ›*))[1]) (*discuss goal 6*) apply ((auto simp: vars_fm_subs_subterms_fm (*‹?v ∈ vars ?φ ⟹ Var ?v ∈ subterms ?φ›*))[1]) (*proven 6 subgoals*) . qed lemma no_new_subtermsD: assumes "no_new_subterms b" shows "⋀n. ∅ n ∈ subterms b ⟹ ∅ n ∈ subterms (last b)" "⋀t1 t2. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b)" "⋀t1 t2. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b)" "⋀t1 t2. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b)" "⋀t. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b)" using assms (*‹no_new_subterms b›*) unfolding no_new_subterms_def (*goals: 1. ‹⋀n. ∅ n ∈ subterms b ⟹ ∅ n ∈ subterms (last b)› 2. ‹⋀t1 t2. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b)› 3. ‹⋀t1 t2. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b)› 4. ‹⋀t1 t2. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b)› 5. ‹⋀t. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b)›*) apply - (*goals: 1. ‹⋀n. ⟦∅ n ∈ subterms b; ∀t∈subterms b. t ∉ Var ` wits b ⟶ t ∈ subterms (last b)⟧ ⟹ ∅ n ∈ subterms (last b)› 2. ‹⋀t1 t2. ⟦t1 ⊔⇩s t2 ∈ subterms b; ∀t∈subterms b. t ∉ Var ` wits b ⟶ t ∈ subterms (last b)⟧ ⟹ t1 ⊔⇩s t2 ∈ subterms (last b)› 3. ‹⋀t1 t2. ⟦t1 ⊓⇩s t2 ∈ subterms b; ∀t∈subterms b. t ∉ Var ` wits b ⟶ t ∈ subterms (last b)⟧ ⟹ t1 ⊓⇩s t2 ∈ subterms (last b)› 4. ‹⋀t1 t2. ⟦t1 -⇩s t2 ∈ subterms b; ∀t∈subterms b. t ∉ Var ` wits b ⟶ t ∈ subterms (last b)⟧ ⟹ t1 -⇩s t2 ∈ subterms (last b)› 5. ‹⋀t. ⟦Single t ∈ subterms b; ∀t∈subterms b. t ∉ Var ` wits b ⟶ t ∈ subterms (last b)⟧ ⟹ Single t ∈ subterms (last b)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma lexpands_no_new_subterms: assumes "lexpands b' b" "b ≠ []" assumes "no_new_subterms b" shows "no_new_subterms (b' @ b)" using assms (*‹lexpands b' b› ‹b ≠ []› ‹no_new_subterms (b::'a pset_atom fm list)›*) unfolding no_new_subterms_def (*goal: ‹∀t∈subterms (b' @ b). t ∉ Var ` wits (b' @ b) ⟶ t ∈ subterms (last (b' @ b))›*) by (simp add: lexpands_wits_eq (*‹⟦lexpands ?b' ?b; ?b ≠ []⟧ ⟹ wits (?b' @ ?b) = wits ?b›*) lexpands_subterms_branch_eq[OF assms(1,2)] (*‹subterms (b' @ b) = subterms b›*)) lemma subterms_branch_subterms_atomI: assumes "Atom l ∈ set b" "t ∈ subterms_atom l" shows "t ∈ subterms_branch b" using assms (*‹AT l ∈ set b› ‹t ∈ subterms l›*) unfolding subterms_branch_def (*goal: ‹t ∈ ⋃ (subterms ` set b)›*) apply (cases l rule: subterms_atom.cases (*‹⟦⋀t1 t2. ?x = t1 ∈⇩s t2 ⟹ ?P; ⋀t1 t2. ?x = t1 =⇩s t2 ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀t1 t2. ⟦AT l ∈ set b; t ∈ subterms l; l = t1 ∈⇩s t2⟧ ⟹ t ∈ ⋃ (subterms ` set b)› 2. ‹⋀t1 t2. ⟦AT l ∈ set b; t ∈ subterms l; l = t1 =⇩s t2⟧ ⟹ t ∈ ⋃ (subterms ` set b)› discuss goal 1*) apply (metis subterms_branch_def (*‹subterms (?b::?'a::type pset_atom fm list) ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT (?a::?'a::type pset_atom) ∈ set (?b::?'a::type pset_atom fm list); (?x::?'a::type pset_term) ∈ subterms (?s::?'a::type pset_term); ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) subterms_refl (*‹(?t::?'a::type pset_term) ∈ subterms ?t›*)) (*discuss goal 2*) apply (metis subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*) subterms_term_subterms_atom_Atom_trans (*‹⟦AT ?a ∈ set ?b; ?x ∈ subterms ?s; ?s ∈ subterms ?a⟧ ⟹ ?x ∈ subterms ?b›*) subterms_refl (*‹?t ∈ subterms ?t›*)) (*proven 2 subgoals*) . lemma bexpands_nowit_no_new_subterms: assumes "bexpands_nowit bs' b" "b' ∈ bs'" "b ≠ []" assumes "no_new_subterms b" shows "no_new_subterms (b' @ b)" using assms (*‹bexpands_nowit bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹no_new_subterms b›*) unfolding no_new_subterms_def (*goal: ‹∀t∈subterms (b' @ b). t ∉ Var ` wits (b' @ b) ⟶ t ∈ subterms (last (b' @ b))›*) by (simp add: bexpands_nowit_wits_eq (*‹⟦bexpands_nowit ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []⟧ ⟹ wits (?b' @ ?b) = wits ?b›*) bexpands_nowit_subterms_branch_eq[OF assms(1,2)] (*‹b ≠ [] ⟹ subterms (b' @ b) = subterms b›*)) lemma bexpands_wit_no_new_subterms: assumes "bexpands_wit t1 t2 x bs' b" "b ≠ []" "b' ∈ bs'" assumes "no_new_subterms b" shows "no_new_subterms (b' @ b)" using assms (*‹bexpands_wit (t1::'a pset_term) (t2::'a pset_term) (x::'a) (bs'::'a pset_atom fm list set) (b::'a pset_atom fm list)› ‹b ≠ []› ‹b' ∈ bs'› ‹no_new_subterms b›*) apply (induction rule: bexpands_wit.induct (*‹⟦bexpands_wit ?t1.0 ?t2.0 ?x ?x1.0 ?x2.0; ⋀b. ⟦AF (?t1.0 =⇩s ?t2.0) ∈ set b; ?t1.0 ∈ subterms (last b); ?t2.0 ∈ subterms (last b); ∄x. AT (x ∈⇩s ?t1.0) ∈ set b ∧ AF (x ∈⇩s ?t2.0) ∈ set b; ∄x. AT (x ∈⇩s ?t2.0) ∈ set b ∧ AF (x ∈⇩s ?t1.0) ∈ set b; ?x ∉ vars b; ¬ urelem (last b) ?t1.0; ¬ urelem (last b) ?t2.0⟧ ⟹ ?P {[AT (Var ?x ∈⇩s ?t1.0), AF (Var ?x ∈⇩s ?t2.0)], [AT (Var ?x ∈⇩s ?t2.0), AF (Var ?x ∈⇩s ?t1.0)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹no_new_subterms (b' @ b)›*) by (auto simp: subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) subterms_term_subterms_atom_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?v⟧ ⟹ ?s ∈ subterms ?v›*) subterms_term_subterms_fm_trans (*‹⟦?s ∈ subterms ?t; ?t ∈ subterms ?φ⟧ ⟹ ?s ∈ subterms ?φ›*) elim: no_new_subtermsD (*‹⟦no_new_subterms ?b; ∅ ?n ∈ subterms ?b⟧ ⟹ ∅ ?n ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 -⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; Single ?t ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) intro!: no_new_subterms_casesI (*‹⟦⋀n. ∅ n ∈ subterms ?b ⟹ ∅ n ∈ subterms (last ?b); ⋀t1 t2. t1 ⊔⇩s t2 ∈ subterms ?b ⟹ t1 ⊔⇩s t2 ∈ subterms (last ?b); ⋀t1 t2. t1 ⊓⇩s t2 ∈ subterms ?b ⟹ t1 ⊓⇩s t2 ∈ subterms (last ?b); ⋀t1 t2. t1 -⇩s t2 ∈ subterms ?b ⟹ t1 -⇩s t2 ∈ subterms (last ?b); ⋀t. Single t ∈ subterms ?b ⟹ Single t ∈ subterms (last ?b)⟧ ⟹ no_new_subterms ?b›*)) lemma bexpands_no_new_subterms: assumes "bexpands bs' b" "b ≠ []" "b' ∈ bs'" assumes "no_new_subterms b" shows "no_new_subterms (b' @ b)" using assms (*‹bexpands bs' b› ‹b ≠ []› ‹(b'::'a::type pset_atom fm list) ∈ (bs'::'a::type pset_atom fm list set)› ‹no_new_subterms b›*) apply (cases rule: bexpands.cases (*‹⟦bexpands (?a1.0::?'a pset_atom fm list set) (?a2.0::?'a pset_atom fm list); ⋀(bs'::?'a pset_atom fm list set) b::?'a pset_atom fm list. ⟦?a1.0 = bs'; ?a2.0 = b; bexpands_nowit bs' b⟧ ⟹ ?P::bool; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (x::?'a) (bs'::?'a pset_atom fm list set) b::?'a pset_atom fm list. ⟦?a1.0 = bs'; ?a2.0 = b; bexpands_wit t1 t2 x bs' b⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹no_new_subterms (b' @ b)›*) using bexpands_nowit_no_new_subterms (*‹⟦bexpands_nowit ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []; no_new_subterms ?b⟧ ⟹ no_new_subterms (?b' @ ?b)›*) bexpands_wit_no_new_subterms (*‹⟦bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b; ?b ≠ []; ?b' ∈ ?bs'; no_new_subterms ?b⟧ ⟹ no_new_subterms (?b' @ ?b)›*) by ((metis)+) lemma expandss_no_new_subterms: assumes "expandss b' b" "b ≠ []" "no_new_subterms b" shows "no_new_subterms b'" using assms (*‹expandss b' b› ‹b ≠ []› ‹no_new_subterms b›*) apply (induction b' b rule: expandss.induct (*‹⟦expandss ?x1.0 ?x2.0; ⋀b. ?P b b; ⋀b3 b2 b1. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1; ⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹no_new_subterms b'›*) using expandss_suffix (*‹expandss ?b1.0 ?b2.0 ⟹ suffix ?b2.0 ?b1.0›*) suffix_bot.extremum_uniqueI (*‹suffix ?a [] ⟹ ?a = []›*) using lexpands_no_new_subterms (*‹⟦lexpands (?b'::?'a::type pset_atom fm list) (?b::?'a::type pset_atom fm list); ?b ≠ []; no_new_subterms ?b⟧ ⟹ no_new_subterms (?b' @ ?b)›*) bexpands_no_new_subterms (*‹⟦bexpands ?bs' ?b; ?b ≠ []; ?b' ∈ ?bs'; no_new_subterms ?b⟧ ⟹ no_new_subterms (?b' @ ?b)›*) apply - (*goals: 1. ‹⋀b::'a pset_atom fm list. ⟦b ≠ []; no_new_subterms b; ⋀(b1::?'a19 pset_atom fm list) b2::?'a19 pset_atom fm list. expandss b1 b2 ⟹ suffix b2 b1; ⋀a::?'a21 list. suffix a [] ⟹ a = []; ⋀(b'::?'a23 pset_atom fm list) b::?'a23 pset_atom fm list. ⟦lexpands b' b; b ≠ []; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b); ⋀(bs'::?'a25 pset_atom fm list set) (b::?'a25 pset_atom fm list) b'::?'a25 pset_atom fm list. ⟦bexpands bs' b; b ≠ []; b' ∈ bs'; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b)⟧ ⟹ no_new_subterms b› 2. ‹⋀(b3::'a pset_atom fm list) (b2::'a pset_atom fm list) b1::'a pset_atom fm list. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ⟦b1 ≠ []; no_new_subterms b1⟧ ⟹ no_new_subterms b2; b1 ≠ []; no_new_subterms b1; ⋀(b1::?'a11 pset_atom fm list) b2::?'a11 pset_atom fm list. expandss b1 b2 ⟹ suffix b2 b1; ⋀a::?'a13 list. suffix a [] ⟹ a = []; ⋀(b'::?'a15 pset_atom fm list) b::?'a15 pset_atom fm list. ⟦lexpands b' b; b ≠ []; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b); ⋀(bs'::?'a17 pset_atom fm list set) (b::?'a17 pset_atom fm list) b'::?'a17 pset_atom fm list. ⟦bexpands bs' b; b ≠ []; b' ∈ bs'; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b)⟧ ⟹ no_new_subterms (b3 @ b2)› 3. ‹⋀(bs::'a pset_atom fm list set) (b2::'a pset_atom fm list) (b3::'a pset_atom fm list) b1::'a pset_atom fm list. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ⟦b1 ≠ []; no_new_subterms b1⟧ ⟹ no_new_subterms b2; b1 ≠ []; no_new_subterms b1; ⋀(b1::?'a3 pset_atom fm list) b2::?'a3 pset_atom fm list. expandss b1 b2 ⟹ suffix b2 b1; ⋀a::?'a5 list. suffix a [] ⟹ a = []; ⋀(b'::?'a7 pset_atom fm list) b::?'a7 pset_atom fm list. ⟦lexpands b' b; b ≠ []; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b); ⋀(bs'::?'a9 pset_atom fm list set) (b::?'a9 pset_atom fm list) b'::?'a9 pset_atom fm list. ⟦bexpands bs' b; b ≠ []; b' ∈ bs'; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b)⟧ ⟹ no_new_subterms (b3 @ b2)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*proven 3 subgoals*) . lemmas subterms_branch_subterms_fm_lastI = subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl] subsubsection ‹‹wits_subterms›› definition wits_subterms :: "'a branch ⇒ 'a pset_term set" where "wits_subterms b ≡ Var ` wits b ∪ subterms (last b)" lemma subterms_branch_eq_if_no_new_subterms: assumes "no_new_subterms b" "b ≠ []" shows "subterms_branch b = wits_subterms b" using assms (*‹no_new_subterms b› ‹b ≠ []›*) no_new_subtermsD[OF assms ( 1 )] (*‹∅ ?n ∈ subterms b ⟹ ∅ ?n ∈ subterms (last b)› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms b ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last b)› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms b ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last b)› ‹?t1.0 -⇩s ?t2.0 ∈ subterms b ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last b)› ‹Single (?t::'a pset_term) ∈ subterms (b::'a pset_atom fm list) ⟹ Single ?t ∈ subterms (last b)›*) proof (-) (*goal: ‹⟦no_new_subterms b; b ≠ []; ⋀n. ∅ n ∈ subterms b ⟹ ∅ n ∈ subterms (last b); ⋀t1 t2. t1 ⊔⇩s t2 ∈ subterms b ⟹ t1 ⊔⇩s t2 ∈ subterms (last b); ⋀t1 t2. t1 ⊓⇩s t2 ∈ subterms b ⟹ t1 ⊓⇩s t2 ∈ subterms (last b); ⋀t1 t2. t1 -⇩s t2 ∈ subterms b ⟹ t1 -⇩s t2 ∈ subterms (last b); ⋀t. Single t ∈ subterms b ⟹ Single t ∈ subterms (last b)⟧ ⟹ subterms b = wits_subterms b›*) note simps = wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) no_new_subterms_def (*‹no_new_subterms ?b ≡ ∀t∈subterms ?b. t ∉ Var ` wits ?b ⟶ t ∈ subterms (last ?b)›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) vars_branch_simps (*‹vars [] = {}› ‹vars (?x # ?xs) = vars ?x ∪ vars ?xs›*) with assms (*‹no_new_subterms b› ‹b ≠ []›*) show "?thesis" (*goal: ‹subterms (b::'a pset_atom fm list) = wits_subterms b›*) by (auto simp: simps (*‹wits (?b::?'a pset_atom fm list) ≡ vars ?b - vars (last ?b)› ‹no_new_subterms (?b::?'a pset_atom fm list) ≡ ∀t::?'a pset_term∈subterms ?b. t ∉ Var ` wits ?b ⟶ t ∈ subterms (last ?b)› ‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)› ‹subterms [] = {}› ‹subterms ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = subterms ?x ∪ subterms ?xs› ‹vars [] = {}› ‹vars ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = vars ?x ∪ vars ?xs›*) vars_fm_subs_subterms_fm (*‹(?v::?'a) ∈ vars (?φ::?'a pset_atom fm) ⟹ Var ?v ∈ subterms ?φ›*) vars_branch_subs_subterms_branch[unfolded image_subset_iff] (*‹∀x::?'a∈vars (?b::?'a pset_atom fm list). Var x ∈ subterms ?b›*) intro: subterms_branch_subterms_fm_lastI (*‹⟦(?b::?'a pset_atom fm list) ≠ []; (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ ?t ∈ subterms ?b›*)) qed lemma wits_subterms_last_disjnt: "Var ` wits b ∩ subterms (last b) = {}" by (auto simp: wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) intro!: mem_vars_fm_if_mem_subterms_fm (*‹⟦?x ∈ vars ?s; ?s ∈ subterms ?φ⟧ ⟹ ?x ∈ vars ?φ›*)) subsection ‹Completeness of the Calculus› subsubsection ‹Proof of Lemma 2› fun is_literal :: "'a fm ⇒ bool" where "is_literal (Atom _) = True" | "is_literal (Neg (Atom _)) = True" | "is_literal _ = False" lemma lexpands_no_wits_if_not_literal: defines "P ≡ (λb. ∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {})" assumes "lexpands b' b" "b ≠ []" assumes "P b" shows "P (b' @ b)" using assms(2-) (*‹lexpands b' b› ‹b ≠ []› ‹P b›*) lexpands_wits_eq[OF assms ( 2 , 3 )] (*‹wits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)) = wits b›*) apply (induction rule: lexpands_induct (*‹⟦lexpands ?b' ?b; ⋀p q b. And p q ∈ set b ⟹ ?P [p, q] b; ⋀p q b. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀p b. Neg (Neg p) ∈ set b ⟹ ?P [p] b; ⋀s t1 t2 b. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b; ⋀t1 b. Single t1 ∈ subterms (last b) ⟹ ?P [AT (t1 ∈⇩s Single t1)] b; ⋀s t1 b. AT (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AT (s =⇩s t1)] b; ⋀s t1 b. AF (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AF (s =⇩s t1)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t1 t2 l)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t1 t2 l)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t2 t1 l)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t2 t1 l)] b; ⋀s t b s'. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b⟧ ⟹ ?P [AF (s =⇩s s')] b⟧ ⟹ ?P ?b' ?b›*)) (*goals: 1. ‹⋀p q b. ⟦And p q ∈ set b; b ≠ []; P b; wits ([p, q] @ b) = wits b⟧ ⟹ P ([p, q] @ b)› 2. ‹⋀p q b. ⟦Neg (Or p q) ∈ set b; b ≠ []; P b; wits ([Neg p, Neg q] @ b) = wits b⟧ ⟹ P ([Neg p, Neg q] @ b)› 3. ‹⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b; b ≠ []; P b; wits ([q] @ b) = wits b⟧ ⟹ P ([q] @ b)› 4. ‹⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b; b ≠ []; P b; wits ([p] @ b) = wits b⟧ ⟹ P ([p] @ b)› 5. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b; b ≠ []; P b; wits ([Neg q] @ b) = wits b⟧ ⟹ P ([Neg q] @ b)› 6. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b; b ≠ []; P b; wits ([Neg p] @ b) = wits b⟧ ⟹ P ([Neg p] @ b)› 7. ‹⋀p b. ⟦Neg (Neg p) ∈ set b; b ≠ []; P b; wits ([p] @ b) = wits b⟧ ⟹ P ([p] @ b)› 8. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; P b; wits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)› 9. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 10. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 11. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; b ≠ []; P b; wits ([AT (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t2)] @ b)› 12. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; P b; wits ([AT (s ∈⇩s t1)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1)] @ b)› 13. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 14. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; b ≠ []; P b; wits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b)› 15. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 16. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 17. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; P b; wits ([AF (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t2)] @ b)› 18. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; P b; wits ([AF (s ∈⇩s t1)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1)] @ b)› 19. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 20. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; b ≠ []; P b; wits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)› 21. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1 -⇩s t2)] @ b)› 22. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1 -⇩s t2)] @ b)› 23. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; P b; wits ([AT (s ∈⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t2)] @ b)› 24. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; P b; wits ([AF (s ∈⇩s t1)] @ b) = wits b⟧ ⟹ P ([AF (s ∈⇩s t1)] @ b)› 25. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; P b; wits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = wits b⟧ ⟹ P ([AT (s ∈⇩s t1 -⇩s t2)] @ b)› 26. ‹⋀t1 b. ⟦Single t1 ∈ subterms (last b); b ≠ []; P b; wits ([AT (t1 ∈⇩s Single t1)] @ b) = wits b⟧ ⟹ P ([AT (t1 ∈⇩s Single t1)] @ b)› 27. ‹⋀s t1 b. ⟦AT (s ∈⇩s Single t1) ∈ set b; b ≠ []; P b; wits ([AT (s =⇩s t1)] @ b) = wits b⟧ ⟹ P ([AT (s =⇩s t1)] @ b)› 28. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []; P b; wits ([AF (s =⇩s t1)] @ b) = wits b⟧ ⟹ P ([AF (s =⇩s t1)] @ b)› 29. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []; P b; wits ([AT (subst_tlvl t1 t2 l)] @ b) = wits b⟧ ⟹ P ([AT (subst_tlvl t1 t2 l)] @ b)› 30. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []; P b; wits ([AF (subst_tlvl t1 t2 l)] @ b) = wits b⟧ ⟹ P ([AF (subst_tlvl t1 t2 l)] @ b)› 31. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []; P b; wits ([AT (subst_tlvl t2 t1 l)] @ b) = wits b⟧ ⟹ P ([AT (subst_tlvl t2 t1 l)] @ b)› 32. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []; P b; wits ([AF (subst_tlvl t2 t1 l)] @ b) = wits b⟧ ⟹ P ([AF (subst_tlvl t2 t1 l)] @ b)› 33. ‹⋀s t b s'. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; b ≠ []; P b; wits ([AF (s =⇩s s')] @ b) = wits b⟧ ⟹ P ([AF (s =⇩s s')] @ b)› discuss goal 1*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 2*) apply ((auto simp: disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 3*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 4*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 5*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 6*) apply ((auto simp: disjoint_iff (*‹((?A::?'a::type set) ∩ (?B::?'a::type set) = {}) = (∀x::?'a::type. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P::'a::type pset_atom fm list ⇒ bool ≡ λb::'a::type pset_atom fm list. ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 7*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 8*) apply ((auto simp: disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 9*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 10*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 11*) apply ((auto simp: disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 12*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 13*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 14*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 15*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 16*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 17*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 18*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 19*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 20*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 21*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 22*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 23*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 24*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 25*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 26*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 27*) apply ((auto simp: disjoint_iff (*‹((?A::?'a::type set) ∩ (?B::?'a::type set) = {}) = (∀x::?'a::type. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P::'a::type pset_atom fm list ⇒ bool ≡ λb::'a::type pset_atom fm list. ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 28*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 29*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 30*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 31*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 32*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*discuss goal 33*) apply ((auto simp: disjoint_iff (*‹((?A::?'a::type set) ∩ (?B::?'a::type set) = {}) = (∀x::?'a::type. x ∈ ?A ⟶ x ∉ ?B)›*) P_def (*‹P::'a::type pset_atom fm list ⇒ bool ≡ λb::'a::type pset_atom fm list. ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*))[1]) (*proven 33 subgoals*) . lemma bexpands_nowit_no_wits_if_not_literal: defines "P ≡ (λb. ∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {})" assumes "bexpands_nowit bs' b" "b' ∈ bs'" "b ≠ []" assumes "P b" shows "P (b' @ b)" using assms(2-) (*‹bexpands_nowit bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹P b›*) apply (induction rule: bexpands_nowit.induct (*‹⟦bexpands_nowit (?x1.0::?'a::type pset_atom fm list set) (?x2.0::?'a::type pset_atom fm list); ⋀(p::?'a::type pset_atom fm) (q::?'a::type pset_atom fm) b::?'a::type pset_atom fm list. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b⟧ ⟹ (?P::?'a::type pset_atom fm list set ⇒ ?'a::type pset_atom fm list ⇒ bool) {[p], [Neg p]} b; ⋀(p::?'a::type pset_atom fm) (q::?'a::type pset_atom fm) b::?'a::type pset_atom fm list. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b⟧ ⟹ ?P {[Neg p], [p]} b; ⋀(s::?'a::type pset_term) (t1::?'a::type pset_term) (t2::?'a::type pset_term) b::?'a::type pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]} b; ⋀(s::?'a::type pset_term) (t1::?'a::type pset_term) (b::?'a::type pset_atom fm list) t2::?'a::type pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b; ⋀(s::?'a::type pset_term) (t1::?'a::type pset_term) (b::?'a::type pset_atom fm list) t2::?'a::type pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 3. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› discuss goal 1*) apply ((auto simp: Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: Int_def (*‹(?A::?'a set) ∩ (?B::?'a set) = {x::?'a ∈ ?A. x ∈ ?B}›*) P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) wits_def (*‹wits (?b::?'a pset_atom fm list) ≡ vars ?b - vars (last ?b)›*) vars_fm_vars_branchI (*‹⟦(?φ::?'a pset_atom fm) ∈ set (?b::?'a pset_atom fm list); (?x::?'a) ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*proven 5 subgoals*) . lemma bexpands_wit_no_wits_if_not_literal: defines "P ≡ (λb. ∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {})" assumes "bexpands_wit t1 t2 x bs' b" "b' ∈ bs'" "b ≠ []" assumes "P b" shows "P (b' @ b)" using assms(2-) (*‹bexpands_wit t1 t2 x bs' b› ‹(b'::'a pset_atom fm list) ∈ (bs'::'a pset_atom fm list set)› ‹b ≠ []› ‹P b›*) apply (induction rule: bexpands_wit.induct (*‹⟦bexpands_wit (?t1.0::?'a pset_term) (?t2.0::?'a pset_term) (?x::?'a) (?x1.0::?'a pset_atom fm list set) (?x2.0::?'a pset_atom fm list); ⋀b::?'a pset_atom fm list. ⟦AF (?t1.0 =⇩s ?t2.0) ∈ set b; ?t1.0 ∈ subterms (last b); ?t2.0 ∈ subterms (last b); ∄x::?'a pset_term. AT (x ∈⇩s ?t1.0) ∈ set b ∧ AF (x ∈⇩s ?t2.0) ∈ set b; ∄x::?'a pset_term. AT (x ∈⇩s ?t2.0) ∈ set b ∧ AF (x ∈⇩s ?t1.0) ∈ set b; ?x ∉ vars b; ¬ urelem (last b) ?t1.0; ¬ urelem (last b) ?t2.0⟧ ⟹ (?P::?'a pset_atom fm list set ⇒ ?'a pset_atom fm list ⇒ bool) {[AT (Var ?x ∈⇩s ?t1.0), AF (Var ?x ∈⇩s ?t2.0)], [AT (Var ?x ∈⇩s ?t2.0), AF (Var ?x ∈⇩s ?t1.0)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹P (b' @ b)›*) by (auto simp: Int_def (*‹?A ∩ ?B = {x ∈ ?A. x ∈ ?B}›*) P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*)) lemma bexpands_no_wits_if_not_literal: defines "P ≡ (λb. ∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {})" assumes "bexpands bs' b" "b' ∈ bs'" "b ≠ []" assumes "P b" shows "P (b' @ b)" using assms(2-) (*‹bexpands bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹P b›*) apply (cases bs' b rule: bexpands_cases (*‹⟦bexpands (?bs::?'a pset_atom fm list set) (?b::?'a pset_atom fm list); bexpands_nowit ?bs ?b ⟹ ?P::bool; ⋀(t1::?'a pset_term) (t2::?'a pset_term) x::?'a. bexpands_wit t1 t2 x ?bs ?b ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹P (b' @ b)›*) using bexpands_wit_no_wits_if_not_literal (*‹⟦bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []; ∀φ∈set ?b. ¬ is_literal φ ⟶ vars φ ∩ wits ?b = {}⟧ ⟹ ∀φ∈set (?b' @ ?b). ¬ is_literal φ ⟶ vars φ ∩ wits (?b' @ ?b) = {}›*) bexpands_nowit_no_wits_if_not_literal (*‹⟦bexpands_nowit ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []; ∀φ∈set ?b. ¬ is_literal φ ⟶ vars φ ∩ wits ?b = {}⟧ ⟹ ∀φ∈set (?b' @ ?b). ¬ is_literal φ ⟶ vars φ ∩ wits (?b' @ ?b) = {}›*) using P_def (*‹P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) apply - (*goals: 1. ‹⟦b' ∈ bs'; b ≠ []; P b; bexpands_nowit bs' b; ⋀t1 t2 x bs' b b'. ⟦bexpands_wit t1 t2 x bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; ⋀bs' b b'. ⟦bexpands_nowit bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ P (b' @ b)› 2. ‹⋀t1 t2 x. ⟦b' ∈ bs'; b ≠ []; P b; bexpands_wit t1 t2 x bs' b; ⋀t1 t2 x bs' b b'. ⟦bexpands_wit t1 t2 x bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; ⋀bs' b b'. ⟦bexpands_nowit bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; P ≡ λb. ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ P (b' @ b)› discuss goal 1*) apply fast (*discuss goal 2*) apply fast (*proven 2 subgoals*) . lemma expandss_no_wits_if_not_literal: defines "P ≡ (λb. ∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {})" assumes "expandss b' b" "b ≠ []" assumes "P b" shows "P b'" using assms(2-) (*‹expandss b' b› ‹(b::'a pset_atom fm list) ≠ []› ‹P b›*) apply (induction rule: expandss.induct (*‹⟦expandss ?x1.0 ?x2.0; ⋀b. ?P b b; ⋀b3 b2 b1. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1; ⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹P b'›*) using lexpands_no_wits_if_not_literal (*‹⟦lexpands ?b' ?b; ?b ≠ []; ∀φ∈set ?b. ¬ is_literal φ ⟶ vars φ ∩ wits ?b = {}⟧ ⟹ ∀φ∈set (?b' @ ?b). ¬ is_literal φ ⟶ vars φ ∩ wits (?b' @ ?b) = {}›*) bexpands_no_wits_if_not_literal (*‹⟦bexpands ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []; ∀φ∈set ?b. ¬ is_literal φ ⟶ vars φ ∩ wits ?b = {}⟧ ⟹ ∀φ∈set (?b' @ ?b). ¬ is_literal φ ⟶ vars φ ∩ wits (?b' @ ?b) = {}›*) apply - (*goals: 1. ‹⋀b. ⟦b ≠ []; P b; ⋀b' b. ⟦lexpands b' b; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; ⋀bs' b b'. ⟦bexpands bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}⟧ ⟹ P b› 2. ‹⋀b3 b2 b1. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ⟦b1 ≠ []; P b1⟧ ⟹ P b2; b1 ≠ []; P b1; ⋀b' b. ⟦lexpands b' b; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; ⋀bs' b b'. ⟦bexpands bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}⟧ ⟹ P (b3 @ b2)› 3. ‹⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ⟦b1 ≠ []; P b1⟧ ⟹ P b2; b1 ≠ []; P b1; ⋀b' b. ⟦lexpands b' b; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}; ⋀bs' b b'. ⟦bexpands bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ ∀φ∈set (b' @ b). ¬ is_literal φ ⟶ vars φ ∩ wits (b' @ b) = {}⟧ ⟹ P (b3 @ b2)› discuss goal 1*) apply ((msorry)[1]) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . lemma lexpands_fm_pwits_eq: assumes "lexpands_fm b' b" "b ≠ []" assumes "∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}" shows "pwits (b' @ b) = pwits b" using assms (*‹lexpands_fm b' b› ‹b ≠ []› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) apply (induction rule: lexpands_fm.induct (*‹⟦lexpands_fm ?x1.0 ?x2.0; ⋀p q b. And p q ∈ set b ⟹ ?P [p, q] b; ⋀p q b. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀p b. Neg (Neg p) ∈ set b ⟹ ?P [p] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀(p::'a pset_atom fm) (q::'a pset_atom fm) b::'a pset_atom fm list. ⟦And p q ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([p, q] @ b) = pwits b› 2. ‹⋀(p::'a pset_atom fm) (q::'a pset_atom fm) b::'a pset_atom fm list. ⟦Neg (Or p q) ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([Neg p, Neg q] @ b) = pwits b› 3. ‹⋀(p::'a pset_atom fm) (q::'a pset_atom fm) b::'a pset_atom fm list. ⟦Or p q ∈ set b; Neg p ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([q] @ b) = pwits b› 4. ‹⋀(p::'a pset_atom fm) (q::'a pset_atom fm) b::'a pset_atom fm list. ⟦Or p q ∈ set b; Neg q ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([p] @ b) = pwits b› 5. ‹⋀(p::'a pset_atom fm) (q::'a pset_atom fm) b::'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; p ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([Neg q] @ b) = pwits b› 6. ‹⋀(p::'a pset_atom fm) (q::'a pset_atom fm) b::'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; q ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([Neg p] @ b) = pwits b› 7. ‹⋀(p::'a pset_atom fm) b::'a pset_atom fm list. ⟦Neg (Neg p) ∈ set b; b ≠ []; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits ([p] @ b) = pwits b› discuss goal 1*) apply (fastforce simp: pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits (?b::?'a pset_atom fm list) ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars (?b::?'a pset_atom fm list) ≡ ⋃ (vars ` set ?b)›*)) (*discuss goal 2*) apply (fastforce simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) (*discuss goal 3*) apply (fastforce simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) (*discuss goal 4*) apply (fastforce simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) (*discuss goal 5*) apply (fastforce simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) (*discuss goal 6*) apply (fastforce simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) (*discuss goal 7*) apply (fastforce simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) vars_branch_def (*‹vars ?b ≡ ⋃ (vars ` set ?b)›*)) (*proven 7 subgoals*) . lemma lexpands_un_pwits_eq: assumes "lexpands_un b' b" "b ≠ []" assumes "∀c ∈ pwits b. ∀t ∈ wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b" shows "pwits (b' @ b) = pwits b" proof (-) (*goal: ‹pwits (b' @ b) = pwits b›*) note lexpands.intros(2)[OF assms ( 1 )] (*‹lexpands b' b›*) note lexpands_wits_eq[OF this ‹b ≠ []›] (*‹wits (b' @ b) = wits b›*) from assms (*‹lexpands_un b' b› ‹b ≠ []› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀t::'a pset_term∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) this (*‹wits (b' @ b) = wits b›*) have "x ∈ pwits (b' @ b)" if "x ∈ pwits b" for x using that (*‹x ∈ pwits b›*) apply (induction rule: lexpands_un.induct (*‹⟦lexpands_un ?x1.0 ?x2.0; ⋀s t1 t2 b. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 4. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t2)] @ b)› 5. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1)] @ b)› 6. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b)› discuss goal 1*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 6*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*proven 6 subgoals*) . with lexpands_pwits_subs[OF ‹lexpands b' b› ‹b ≠ []›] (*‹pwits (b' @ b) ⊆ pwits b›*) show "?thesis" (*goal: ‹pwits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)) = pwits b›*) by auto qed lemma lexpands_int_pwits_eq: assumes "lexpands_int b' b" "b ≠ []" assumes "∀c ∈ pwits b. ∀t ∈ wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b" shows "pwits (b' @ b) = pwits b" proof (-) (*goal: ‹pwits (b' @ b) = pwits b›*) note lexpands.intros(3)[OF assms ( 1 )] (*‹lexpands b' b›*) note lexpands_wits_eq[OF this ‹b ≠ []›] (*‹wits (b' @ b) = wits b›*) from assms (*‹lexpands_int b' b› ‹b ≠ []› ‹∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) this (*‹wits (b' @ b) = wits b›*) have "x ∈ pwits (b' @ b)" if "x ∈ pwits b" for x using that (*‹x ∈ pwits b›*) apply (induction rule: lexpands_int.induct (*‹⟦lexpands_int ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b)› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 3. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t2)] @ b)› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1)] @ b)› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b)› discuss goal 1*) apply ((auto simp: wits_subterms_def (*‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦(?c::?'a) ∈ wits (?b::?'a pset_atom fm list); ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: wits_subterms_def (*‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦(?c::?'a) ∈ wits (?b::?'a pset_atom fm list); ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 6*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*proven 6 subgoals*) . with lexpands_pwits_subs[OF ‹lexpands b' b› ‹b ≠ []›] (*‹pwits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)) ⊆ pwits b›*) show "?thesis" (*goal: ‹pwits (b' @ b) = pwits b›*) by auto qed lemma lexpands_diff_pwits_eq: assumes "lexpands_diff b' b" "b ≠ []" assumes "∀c ∈ pwits b. ∀t ∈ wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b" shows "pwits (b' @ b) = pwits b" proof (-) (*goal: ‹pwits (b' @ b) = pwits b›*) note lexpands.intros(4)[OF assms ( 1 )] (*‹lexpands b' b›*) note lexpands_wits_eq[OF this ‹b ≠ []›] (*‹wits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)) = wits b›*) from assms (*‹lexpands_diff b' b› ‹b ≠ []› ‹∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) this (*‹wits (b' @ b) = wits b›*) have "x ∈ pwits (b' @ b)" if "x ∈ pwits b" for x using that (*‹x ∈ pwits b›*) apply (induction rule: lexpands_diff.induct (*‹⟦lexpands_diff ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b)› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b)› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t2)] @ b)› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AF (s ∈⇩s t1)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AF (s ∈⇩s t1)] @ b)› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; ∀c∈pwits b. ∀t∈wits_subterms b. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b; wits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; x ∈ pwits b⟧ ⟹ x ∈ pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b)› discuss goal 1*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 4*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 5*) apply ((auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*discuss goal 6*) apply ((auto simp: wits_subterms_def (*‹wits_subterms (?b::?'a::type pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*) pwitsD (*‹(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list); (?t::?'a::type pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list); (?t::?'a::type pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*) intro!: pwitsI (*‹⟦(?c::?'a::type) ∈ wits (?b::?'a::type pset_atom fm list); ⋀t::?'a::type pset_term. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t::?'a::type pset_term. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*))[1]) (*proven 6 subgoals*) . with lexpands_pwits_subs[OF ‹lexpands b' b› ‹b ≠ []›] (*‹pwits (b' @ b) ⊆ pwits b›*) show "?thesis" (*goal: ‹pwits (b' @ b) = pwits b›*) by auto qed lemma bexpands_nowit_pwits_eq: assumes "bexpands_nowit bs' b" "b' ∈ bs'" "b ≠ []" assumes "∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}" shows "pwits (b' @ b) = pwits b" using assms (*‹bexpands_nowit bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) proof (-) (*goal: ‹⟦bexpands_nowit bs' b; b' ∈ bs'; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}⟧ ⟹ pwits (b' @ b) = pwits b›*) from assms (*‹bexpands_nowit bs' b› ‹(b'::'a::type pset_atom fm list) ∈ (bs'::'a::type pset_atom fm list set)› ‹b ≠ []› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) have "x ∈ pwits (b' @ b)" if "x ∈ pwits b" for x using that (*‹x ∈ pwits b›*) bexpands_nowit_wits_eq[OF assms ( 1 - 3 )] (*‹wits ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = wits b›*) apply (induction rule: bexpands_nowit.induct (*‹⟦bexpands_nowit (?x1.0::?'a pset_atom fm list set) (?x2.0::?'a pset_atom fm list); ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b⟧ ⟹ (?P::?'a pset_atom fm list set ⇒ ?'a pset_atom fm list ⇒ bool) {[p], [Neg p]} b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b⟧ ⟹ ?P {[Neg p], [p]} b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]} b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ pwits (b' @ b)› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ pwits (b' @ b)› 3. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ pwits (b' @ b)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ pwits (b' @ b)› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ pwits (b' @ b)› discuss goal 1*) apply (intro pwitsI (*‹⟦(?c::?'a) ∈ wits (?b::?'a pset_atom fm list); ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ wits (b' @ b)› 2. ‹⋀p q b t. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (Var x =⇩s t) ∉ set (b' @ b)› 3. ‹⋀p q b t. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (t =⇩s Var x) ∉ set (b' @ b)› discuss goal 1*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 2*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 3*) apply (fastforce simp: pwitsD (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*proven 3 subgoals*) (*discuss goal 2*) apply (intro pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*)) (*goals: 1. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ wits (b' @ b)› 2. ‹⋀p q b t. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (Var x =⇩s t) ∉ set (b' @ b)› 3. ‹⋀p q b t. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (t =⇩s Var x) ∉ set (b' @ b)› discuss goal 1*) apply (fastforce simp: pwitsD (*‹(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list); (?t::?'a::type pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list); (?t::?'a::type pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 2*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 3*) apply (fastforce simp: pwitsD (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*proven 3 subgoals*) (*discuss goal 3*) apply (intro pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ wits (b' @ b)› 2. ‹⋀s t1 t2 b t. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (Var x =⇩s t) ∉ set (b' @ b)› 3. ‹⋀s t1 t2 b t. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (t =⇩s Var x) ∉ set (b' @ b)› discuss goal 1*) apply (fastforce simp: pwitsD (*‹(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list); (?t::?'a::type pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a::type) ∈ pwits (?b::?'a::type pset_atom fm list); (?t::?'a::type pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 2*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 3*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*proven 3 subgoals*) (*discuss goal 4*) apply (intro pwitsI (*‹⟦(?c::?'a) ∈ wits (?b::?'a pset_atom fm list); ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t::?'a pset_term. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*)) (*goals: 1. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ wits (b' @ b)› 2. ‹⋀s t1 b t2 t. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (Var x =⇩s t) ∉ set (b' @ b)› 3. ‹⋀s t1 b t2 t. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (t =⇩s Var x) ∉ set (b' @ b)› discuss goal 1*) apply (fastforce simp: pwitsD (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 2*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 3*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*proven 3 subgoals*) (*discuss goal 5*) apply (intro pwitsI (*‹⟦?c ∈ wits ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (Var ?c =⇩s t) ∉ set ?b; ⋀t. t ∈ subterms (last ?b) ⟹ AT (t =⇩s Var ?c) ∉ set ?b⟧ ⟹ ?c ∈ pwits ?b›*)) (*goals: 1. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b⟧ ⟹ x ∈ wits (b' @ b)› 2. ‹⋀s t1 b t2 t. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (Var x =⇩s t) ∉ set (b' @ b)› 3. ‹⋀s t1 b t2 t. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; x ∈ pwits b; wits (b' @ b) = wits b; t ∈ subterms (last (b' @ b))⟧ ⟹ AT (t =⇩s Var x) ∉ set (b' @ b)› discuss goal 1*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 2*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*discuss goal 3*) apply (fastforce simp: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) (*proven 3 subgoals*) (*proven 5 subgoals*) . moreover from assms (*‹bexpands_nowit bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) have "pwits (b' @ b) ⊆ pwits b" unfolding pwits_def (*goal: ‹{c::'a ∈ wits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)). ∀t::'a pset_term∈subterms (last (b' @ b)). AT (Var c =⇩s t) ∉ set (b' @ b) ∧ AT (t =⇩s Var c) ∉ set (b' @ b)} ⊆ {c::'a ∈ wits b. ∀t::'a pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) using bexpands_nowit_wits_eq (*‹⟦bexpands_nowit (?bs'::?'a pset_atom fm list set) (?b::?'a pset_atom fm list); (?b'::?'a pset_atom fm list) ∈ ?bs'; ?b ≠ []⟧ ⟹ wits (?b' @ ?b) = wits ?b›*) by fastforce ultimately show "?thesis" (*goal: ‹pwits (b' @ b) = pwits b›*) by blast qed lemma bexpands_wit_pwits_eq: assumes "bexpands_wit t1 t2 x bs' b" "b' ∈ bs'" "b ≠ []" shows "pwits (b' @ b) = insert x (pwits b)" using assms(2,3) (*‹b' ∈ bs'› ‹b ≠ []›*) bexpands_witD[OF assms ( 1 )] (*‹bs' = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}› ‹AF (t1 =⇩s t2) ∈ set b› ‹t1 ∈ subterms (last b)› ‹t2 ∈ subterms (last b)› ‹∄x::'a pset_term. AT (x ∈⇩s (t1::'a pset_term)) ∈ set (b::'a pset_atom fm list) ∧ AF (x ∈⇩s (t2::'a pset_term)) ∈ set b› ‹∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b› ‹¬ urelem (last (b::'a pset_atom fm list)) (t1::'a pset_term)› ‹¬ urelem (last b) t2› ‹x ∉ vars b›*) unfolding pwits_def bexpands_wit_wits_eq[OF assms] (*goal: ‹{c ∈ insert x (wits b). ∀t∈subterms (last (b' @ b)). AT (Var c =⇩s t) ∉ set (b' @ b) ∧ AT (t =⇩s Var c) ∉ set (b' @ b)} = insert x {c ∈ wits b. ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) by (auto simp: vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*)) lemma lemma_2_lexpands: defines "P ≡ (λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b)" assumes "lexpands b' b" "b ≠ []" assumes "no_new_subterms b" assumes "∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}" assumes "∀c ∈ pwits b. ∀t ∈ wits_subterms b. P b c t" shows "∀c ∈ pwits (b' @ b). ∀t ∈ wits_subterms (b' @ b). P (b' @ b) c t" using assms(2-6) (*‹lexpands b' b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀t∈wits_subterms b. P b c t›*) using lexpands_wits_eq[OF assms ( 2 , 3 )] (*‹wits (b' @ b) = wits b›*) lexpands_pwits_subs[OF assms ( 2 , 3 )] (*‹pwits (b' @ b) ⊆ pwits b›*) proof (induction rule: lexpands.induct (*‹⟦lexpands ?x1.0 ?x2.0; ⋀b' b. lexpands_fm b' b ⟹ ?P b' b; ⋀b' b. lexpands_un b' b ⟹ ?P b' b; ⋀b' b. lexpands_int b' b ⟹ ?P b' b; ⋀b' b. lexpands_diff b' b ⟹ ?P b' b; ⋀b' b. lexpands_single b' b ⟹ ?P b' b; ⋀b' b. lexpands_eq b' b ⟹ ?P b' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀b' b. ⟦lexpands_fm b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀b' b. ⟦lexpands_un b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀b' b. ⟦lexpands_int b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 4. ‹⋀b' b. ⟦lexpands_diff b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 5. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 6. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (1 b' b) (*‹lexpands_fm b' b› ‹(b::'a pset_atom fm list) ≠ []› ‹no_new_subterms b› ‹∀φ::'a pset_atom fm∈set (b::'a pset_atom fm list). ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) have "P (b' @ b) c t" if "∀φ ∈ set b'. vars φ ∩ wits (b' @ b) = {}" and "c ∈ pwits b" "t ∈ wits_subterms (b' @ b)" for c and t proof (-) (*goal: ‹P (b' @ b) c t›*) from that (*‹∀φ∈set b'. vars φ ∩ wits (b' @ b) = {}› ‹c ∈ pwits b› ‹(t::'a pset_term) ∈ wits_subterms ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list))›*) "1.prems"(5) (*‹wits (b' @ b) = wits b›*) have "∀φ ∈ set b'. φ ≠ AT (Var c =⇩s t) ∧ φ ≠ AT (t =⇩s Var c) ∧ φ ≠ AT (t ∈⇩s Var c)" by (auto simp: pwits_def (*‹pwits ?b ≡ {c ∈ wits ?b. ∀t∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*)) with "1" (*‹lexpands_fm b' b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) that (*‹∀φ∈set b'. vars φ ∩ wits (b' @ b) = {}› ‹(c::'a) ∈ pwits (b::'a pset_atom fm list)› ‹(t::'a pset_term) ∈ wits_subterms ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list))›*) show "?thesis" (*goal: ‹P (b' @ b) c t›*) unfolding P_def wits_subterms_def (*goal: ‹AT (Var c =⇩s t) ∉ set (b' @ b) ∧ AT (t =⇩s Var c) ∉ set (b' @ b) ∧ AT (t ∈⇩s Var c) ∉ set (b' @ b)›*) by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) last_appendR (*‹?ys ≠ [] ⟹ last (?xs @ ?ys) = last ?ys›*) set_append (*‹set (?xs @ ?ys) = set ?xs ∪ set ?ys›*)) qed moreover from "1"(1,4,6) (*‹lexpands_fm b' b› ‹∀φ::'a::type pset_atom fm∈set (b::'a::type pset_atom fm list). ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹wits (b' @ b) = wits b›*) have "∀φ ∈ set b'. vars φ ∩ wits (b' @ b) = {}" apply (induction rule: lexpands_fm.induct (*‹⟦lexpands_fm ?x1.0 ?x2.0; ⋀p q b. And p q ∈ set b ⟹ ?P [p, q] b; ⋀p q b. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀p b. Neg (Neg p) ∈ set b ⟹ ?P [p] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦And p q ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([p, q] @ b) = wits b⟧ ⟹ ∀φ∈set [p, q]. vars φ ∩ wits ([p, q] @ b) = {}› 2. ‹⋀p q b. ⟦Neg (Or p q) ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([Neg p, Neg q] @ b) = wits b⟧ ⟹ ∀φ∈set [Neg p, Neg q]. vars φ ∩ wits ([Neg p, Neg q] @ b) = {}› 3. ‹⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([q] @ b) = wits b⟧ ⟹ ∀φ∈set [q]. vars φ ∩ wits ([q] @ b) = {}› 4. ‹⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([p] @ b) = wits b⟧ ⟹ ∀φ∈set [p]. vars φ ∩ wits ([p] @ b) = {}› 5. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([Neg q] @ b) = wits b⟧ ⟹ ∀φ∈set [Neg q]. vars φ ∩ wits ([Neg q] @ b) = {}› 6. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([Neg p] @ b) = wits b⟧ ⟹ ∀φ∈set [Neg p]. vars φ ∩ wits ([Neg p] @ b) = {}› 7. ‹⋀p b. ⟦Neg (Neg p) ∈ set b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; wits ([p] @ b) = wits b⟧ ⟹ ∀φ∈set [p]. vars φ ∩ wits ([p] @ b) = {}› discuss goal 1*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*discuss goal 2*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*discuss goal 3*) apply ((auto simp: disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*discuss goal 4*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*discuss goal 5*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*discuss goal 6*) apply ((auto simp: disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*discuss goal 7*) apply ((auto simp: disjoint_iff (*‹((?A::?'a::type set) ∩ (?B::?'a::type set) = {}) = (∀x::?'a::type. x ∈ ?A ⟶ x ∉ ?B)›*))[1]) (*proven 7 subgoals*) . ultimately show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) using "1" (*‹lexpands_fm b' b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) lexpands_fm_pwits_eq (*‹⟦lexpands_fm ?b' ?b; ?b ≠ []; ∀φ∈set ?b. ¬ is_literal φ ⟶ vars φ ∩ wits ?b = {}⟧ ⟹ pwits (?b' @ ?b) = pwits ?b›*) by blast next (*goals: 1. ‹⋀b' b. ⟦lexpands_un b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀b' b. ⟦lexpands_int b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀b' b. ⟦lexpands_diff b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 4. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 5. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (2 b' b) (*‹lexpands_un b' b› ‹(b::'a pset_atom fm list) ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) using lexpands_un_pwits_eq[OF "2" ( 1 , 2 , 5 ) [ unfolded P_def ]] (*‹pwits (b' @ b) = pwits b›*) proof (induction rule: lexpands_un.induct (*‹⟦lexpands_un ?x1.0 ?x2.0; ⋀s t1 t2 b. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) c)› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)› 4. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t2)] @ b)) (P ([AT (s ∈⇩s t2)] @ b) c)› 5. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1)] @ b) = wits b; pwits ([AT (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1)] @ b)) (P ([AT (s ∈⇩s t1)] @ b) c)› 6. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)›*) case (4 s t1 t2 b) (*‹AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term) ⊔⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹AF (s ∈⇩s t1) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT ((s::'a pset_term) ∈⇩s (t2::'a pset_term))] @ (b::'a pset_atom fm list)) = wits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) = pwits b›*) then have "t1 ⊔⇩s t2 ∈ subterms b" unfolding subterms_branch_def (*goal: ‹t1 ⊔⇩s t2 ∈ ⋃ (subterms ` set b)›*) by (metis UN_iff (*‹(?b ∈ ⋃ (?B ` ?A)) = (∃x∈?A. ?b ∈ ?B x)›*) UnI2 (*‹?c ∈ ?B ⟹ ?c ∈ ?A ∪ ?B›*) subterms_fm_simps( (*‹subterms (AT ?a) = subterms ?a›*) 1) subterms_atom.simps( (*‹subterms (?t1.0 ∈⇩s ?t2.0) = subterms ?t1.0 ∪ subterms ?t2.0›*) 1) subterms_refl (*‹?t ∈ subterms ?t›*)) with ‹no_new_subterms b› (*‹no_new_subterms (b::'a::type pset_atom fm list)›*) have "t1 ⊔⇩s t2 ∈ subterms (last b)" using no_new_subtermsD (*‹⟦no_new_subterms (?b::?'a pset_atom fm list); ∅ ?n::nat ∈ subterms ?b⟧ ⟹ ∅ ?n ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 -⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; Single ?t ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) by blast then have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹t1 ⊔⇩s t2 ∈ subterms (last b) ⟹ t1 ∉ Var ` wits b› 2. ‹t1 ⊔⇩s t2 ∈ subterms (last b) ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*discuss goal 2*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*proven 2 subgoals*) . with "4" (*‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b› ‹AF (s ∈⇩s t1) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a::type∈pwits (b::'a::type pset_atom fm list). ∀a::'a::type pset_term∈wits_subterms b. (P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c a› ‹wits ([AT (s ∈⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits ([AT (s ∈⇩s t2)] @ b). ∀a∈wits_subterms ([AT (s ∈⇩s t2)] @ b). P ([AT (s ∈⇩s t2)] @ b) c a›*) by (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) pwitsD( (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b›*) 1)) next (*goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) c)› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)› 4. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1)] @ b) = wits b; pwits ([AT (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1)] @ b)) (P ([AT (s ∈⇩s t1)] @ b) c)› 5. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)›*) case (5 s t1 t2 b) (*‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b› ‹AF (s ∈⇩s t2) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t1)] @ b) = wits b› ‹pwits ([AT ((s::'a::type pset_term) ∈⇩s (t1::'a::type pset_term))] @ (b::'a::type pset_atom fm list)) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1)] @ b) = pwits b›*) then have "t1 ⊔⇩s t2 ∈ subterms b" unfolding subterms_branch_def (*goal: ‹t1 ⊔⇩s t2 ∈ ⋃ (subterms ` set b)›*) by (metis UN_iff (*‹((?b::?'a) ∈ ⋃ ((?B::?'b ⇒ ?'a set) ` (?A::?'b set))) = (∃x::?'b∈?A. ?b ∈ ?B x)›*) UnI2 (*‹(?c::?'a) ∈ (?B::?'a set) ⟹ ?c ∈ (?A::?'a set) ∪ ?B›*) subterms_fm_simps( (*‹subterms (AT (?a::?'a pset_atom)) = subterms ?a›*) 1) subterms_atom.simps( (*‹subterms ((?t1.0::?'a pset_term) ∈⇩s (?t2.0::?'a pset_term)) = subterms ?t1.0 ∪ subterms ?t2.0›*) 1) subterms_refl (*‹(?t::?'a pset_term) ∈ subterms ?t›*)) with ‹no_new_subterms b› (*‹no_new_subterms b›*) have "t1 ⊔⇩s t2 ∈ subterms (last b)" using no_new_subtermsD (*‹⟦no_new_subterms ?b; ∅ ?n ∈ subterms ?b⟧ ⟹ ∅ ?n ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 -⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms (?b::?'a pset_atom fm list); Single (?t::?'a pset_term) ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) by blast then have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹t1 ⊔⇩s t2 ∈ subterms (last b) ⟹ t1 ∉ Var ` wits b› 2. ‹t1 ⊔⇩s t2 ∈ subterms (last b) ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits (?b::?'a pset_atom fm list) ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹Single (?t::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t ∈ subterms ?φ›*)) (*discuss goal 2*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*proven 2 subgoals*) . with "5" (*‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b› ‹AF (s ∈⇩s t2) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT ((s::'a::type pset_term) ∈⇩s (t1::'a::type pset_term))] @ (b::'a::type pset_atom fm list)) = wits b› ‹pwits ([AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term))] @ (b::'a pset_atom fm list)) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1)] @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits ([AT (s ∈⇩s t1)] @ b). ∀a∈wits_subterms ([AT (s ∈⇩s t1)] @ b). P ([AT (s ∈⇩s t1)] @ b) c a›*) by (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) pwitsD( (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b›*) 1)) qed (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*)) (*solves the remaining goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) c)› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)› 4. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b) c)›*) next (*goals: 1. ‹⋀b' b. ⟦lexpands_int b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀b' b. ⟦lexpands_diff b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 4. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (3 b' b) (*‹lexpands_int b' b› ‹b ≠ []› ‹no_new_subterms (b::'a pset_atom fm list)› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a::type∈pwits (b::'a::type pset_atom fm list). ∀a::'a::type pset_term∈wits_subterms b. (P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) using lexpands_int_pwits_eq[OF "3" ( 1 , 2 , 5 ) [ unfolded P_def ]] (*‹pwits (b' @ b) = pwits b›*) proof (induction rule: lexpands_int.induct (*‹⟦lexpands_int ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) c)› 2. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)› 3. ‹⋀(s::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) t1::'a pset_term. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)› 4. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t2)] @ b)) (P ([AF (s ∈⇩s t2)] @ b) c)› 5. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1)] @ b) = wits b; pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1)] @ b)) (P ([AF (s ∈⇩s t1)] @ b) c)› 6. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)›*) case (1 s t1 t2 b) (*‹AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b› ‹b ≠ []› ‹no_new_subterms (b::'a pset_atom fm list)› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a› ‹wits ([AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)), AT (s ∈⇩s (t2::'a pset_term))] @ (b::'a pset_atom fm list)) = wits b› ‹pwits ([AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)), AT (s ∈⇩s (t2::'a pset_term))] @ (b::'a pset_atom fm list)) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = pwits b›*) then have "t1 ⊓⇩s t2 ∈ subterms b" unfolding subterms_branch_def (*goal: ‹t1 ⊓⇩s t2 ∈ ⋃ (subterms ` set b)›*) by (metis UN_iff (*‹((?b::?'a) ∈ ⋃ ((?B::?'b ⇒ ?'a set) ` (?A::?'b set))) = (∃x::?'b∈?A. ?b ∈ ?B x)›*) UnI2 (*‹(?c::?'a) ∈ (?B::?'a set) ⟹ ?c ∈ (?A::?'a set) ∪ ?B›*) subterms_fm_simps( (*‹subterms (AT (?a::?'a pset_atom)) = subterms ?a›*) 1) subterms_atom.simps( (*‹subterms ((?t1.0::?'a pset_term) ∈⇩s (?t2.0::?'a pset_term)) = subterms ?t1.0 ∪ subterms ?t2.0›*) 1) subterms_refl (*‹(?t::?'a pset_term) ∈ subterms ?t›*)) with ‹no_new_subterms b› (*‹no_new_subterms b›*) have "t1 ⊓⇩s t2 ∈ subterms (last b)" using no_new_subtermsD (*‹⟦no_new_subterms ?b; ∅ ?n ∈ subterms ?b⟧ ⟹ ∅ ?n ∈ subterms (last ?b)› ‹⟦no_new_subterms (?b::?'a::type pset_atom fm list); (?t1.0::?'a::type pset_term) ⊔⇩s (?t2.0::?'a::type pset_term) ∈ subterms ?b⟧ ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 -⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; Single ?t ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) by blast then have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹(t1::'a pset_term) ⊓⇩s (t2::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list)) ⟹ t1 ∉ Var ` wits b› 2. ‹(t1::'a pset_term) ⊓⇩s (t2::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list)) ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*discuss goal 2*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*proven 2 subgoals*) . with "1" (*‹AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ::'a pset_atom fm∈set (b::'a pset_atom fm list). ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b). ∀a∈wits_subterms ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b). P ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b) c a›*) by (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) pwitsD( (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b›*) 1)) next (*goals: 1. ‹⋀(s::'a::type pset_term) (t1::'a::type pset_term) (b::'a::type pset_atom fm list) t2::'a::type pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a::type∈pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)› 2. ‹⋀(s::'a::type pset_term) (t2::'a::type pset_term) (b::'a::type pset_atom fm list) t1::'a::type pset_term. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a::type∈pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)› 3. ‹⋀(s::'a::type pset_term) (t1::'a::type pset_term) (t2::'a::type pset_term) b::'a::type pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a::type∈pwits ([AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t2)] @ b)) (P ([AF (s ∈⇩s t2)] @ b) c)› 4. ‹⋀(s::'a::type pset_term) (t1::'a::type pset_term) (t2::'a::type pset_term) b::'a::type pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1)] @ b) = wits b; pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c::'a::type∈pwits ([AF (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1)] @ b)) (P ([AF (s ∈⇩s t1)] @ b) c)› 5. ‹⋀(s::'a::type pset_term) (t1::'a::type pset_term) (b::'a::type pset_atom fm list) t2::'a::type pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a::type∈pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)›*) case (6 s t1 b t2) (*‹AT (s ∈⇩s t1) ∈ set b› ‹AT (s ∈⇩s t2) ∈ set b› ‹t1 ⊓⇩s t2 ∈ subterms (last b)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT ((s::'a::type pset_term) ∈⇩s (t1::'a::type pset_term) ⊓⇩s (t2::'a::type pset_term))] @ (b::'a::type pset_atom fm list)) = pwits b›*) then have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹⟦AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)) ∈ set (b::'a pset_atom fm list); AT (s ∈⇩s (t2::'a pset_term)) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a; wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ t1 ∉ Var ` wits b› 2. ‹⟦AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)) ∈ set (b::'a pset_atom fm list); AT (s ∈⇩s (t2::'a pset_term)) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a; wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits (?b::?'a pset_atom fm list) ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹Single (?t::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t ∈ subterms ?φ›*)) (*discuss goal 2*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*proven 2 subgoals*) . with "6" (*‹AT (s ∈⇩s t1) ∈ set b› ‹AT (s ∈⇩s t2) ∈ set b› ‹t1 ⊓⇩s t2 ∈ subterms (last b)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b). ∀a∈wits_subterms ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b). P ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b) c a›*) by (auto simp: wits_subterms_def (*‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool ≡ λ(b::'a pset_atom fm list) (c::'a) t::'a pset_term. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*) pwitsD( (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b›*) 1)) qed (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*)) (*solves the remaining goals: 1. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)› 2. ‹⋀(s::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) t1::'a pset_term. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b) c)› 3. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t2)] @ b)) (P ([AF (s ∈⇩s t2)] @ b) c)› 4. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s ∈⇩s t1)] @ b) = wits b; pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1)] @ b)) (P ([AF (s ∈⇩s t1)] @ b) c)›*) next (*goals: 1. ‹⋀(b'::'a::type pset_atom fm list) b::'a::type pset_atom fm list. ⟦lexpands_diff b' b; b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c::'a::type∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀(b'::'a::type pset_atom fm list) b::'a::type pset_atom fm list. ⟦lexpands_single b' b; b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c::'a::type∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀(b'::'a::type pset_atom fm list) b::'a::type pset_atom fm list. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ::'a::type pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a::type∈pwits b. Ball (wits_subterms b) ((P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c::'a::type∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (4 b' b) (*‹lexpands_diff b' b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) using lexpands_diff_pwits_eq[OF "4" ( 1 , 2 , 5 ) [ unfolded P_def ]] (*‹pwits (b' @ b) = pwits b›*) proof (induction rule: lexpands_diff.induct (*‹⟦lexpands_diff ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) c)› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 -⇩s t2)] @ b) c)› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 -⇩s t2)] @ b) c)› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t2)] @ b)) (P ([AT (s ∈⇩s t2)] @ b) c)› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1)] @ b) = wits b; pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1)] @ b)) (P ([AF (s ∈⇩s t1)] @ b) c)› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 -⇩s t2)] @ b) c)›*) case (1 s t1 t2 b) (*‹AT ((s::'a::type pset_term) ∈⇩s (t1::'a::type pset_term) -⇩s (t2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = pwits b›*) then have "t1 -⇩s t2 ∈ subterms b" unfolding subterms_branch_def (*goal: ‹t1 -⇩s t2 ∈ ⋃ (subterms ` set b)›*) by (metis UN_iff (*‹(?b ∈ ⋃ (?B ` ?A)) = (∃x∈?A. ?b ∈ ?B x)›*) UnI2 (*‹?c ∈ ?B ⟹ ?c ∈ ?A ∪ ?B›*) subterms_fm_simps( (*‹subterms (AT ?a) = subterms ?a›*) 1) subterms_atom.simps( (*‹subterms (?t1.0 ∈⇩s ?t2.0) = subterms ?t1.0 ∪ subterms ?t2.0›*) 1) subterms_refl (*‹?t ∈ subterms ?t›*)) with ‹no_new_subterms b› (*‹no_new_subterms b›*) have "t1 -⇩s t2 ∈ subterms (last b)" using no_new_subtermsD (*‹⟦no_new_subterms ?b; ∅ ?n ∈ subterms ?b⟧ ⟹ ∅ ?n ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 -⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; Single ?t ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) by blast then have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹t1 -⇩s t2 ∈ subterms (last b) ⟹ t1 ∉ Var ` wits b› 2. ‹t1 -⇩s t2 ∈ subterms (last b) ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*discuss goal 2*) apply (meson disjoint_iff (*‹((?A::?'a set) ∩ (?B::?'a set) = {}) = (∀x::?'a. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits (?b::?'a pset_atom fm list) ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t1.0 ∈ subterms ?φ› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t2.0 ∈ subterms ?φ› ‹Single (?t::?'a pset_term) ∈ subterms (?φ::?'a pset_atom fm) ⟹ ?t ∈ subterms ?φ›*)) (*proven 2 subgoals*) . with "1" (*‹AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term) -⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = wits b› ‹pwits ([AT ((s::'a::type pset_term) ∈⇩s (t1::'a::type pset_term)), AF (s ∈⇩s (t2::'a::type pset_term))] @ (b::'a::type pset_atom fm list)) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) = pwits b›*) show "?case" (*goal: ‹∀c::'a∈pwits ([AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)), AF (s ∈⇩s (t2::'a pset_term))] @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈wits_subterms ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b). (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b) c a›*) by (auto simp: wits_subterms_def (*‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool ≡ λ(b::'a pset_atom fm list) (c::'a) t::'a pset_term. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*) dest: pwitsD( (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b›*) 1)) next (*goals: 1. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 -⇩s t2)] @ b) c)› 2. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 -⇩s t2)] @ b) c)› 3. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t2)] @ b)) (P ([AT (s ∈⇩s t2)] @ b) c)› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1)] @ b) = wits b; pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1)] @ b)) (P ([AF (s ∈⇩s t1)] @ b) c)› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 -⇩s t2)] @ b) c)›*) case (4 s t1 t2 b) (*‹AF ((s::'a pset_term) ∈⇩s (t1::'a pset_term) -⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹AT (s ∈⇩s t1) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) = pwits b›*) then have "t1 -⇩s t2 ∈ subterms b" unfolding subterms_branch_def (*goal: ‹(t1::'a pset_term) -⇩s (t2::'a pset_term) ∈ ⋃ (subterms ` set (b::'a pset_atom fm list))›*) by (metis AF_mem_subterms_branchD( (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) 2) subterms_branch_def (*‹subterms ?b ≡ ⋃ (subterms ` set ?b)›*)) with ‹no_new_subterms b› (*‹no_new_subterms b›*) have "t1 -⇩s t2 ∈ subterms (last b)" using no_new_subtermsD (*‹⟦no_new_subterms ?b; ∅ ?n ∈ subterms ?b⟧ ⟹ ∅ ?n ∈ subterms (last ?b)› ‹⟦no_new_subterms (?b::?'a pset_atom fm list); (?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms ?b⟧ ⟹ ?t1.0 ⊔⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 ⊓⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; ?t1.0 -⇩s ?t2.0 ∈ subterms ?b⟧ ⟹ ?t1.0 -⇩s ?t2.0 ∈ subterms (last ?b)› ‹⟦no_new_subterms ?b; Single ?t ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) by blast then have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹t1 -⇩s t2 ∈ subterms (last b) ⟹ t1 ∉ Var ` wits b› 2. ‹t1 -⇩s t2 ∈ subterms (last b) ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*discuss goal 2*) apply (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) (*proven 2 subgoals*) . with "4" (*‹AF ((s::'a pset_term) ∈⇩s (t1::'a pset_term) -⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹AT (s ∈⇩s t1) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s ∈⇩s t2)] @ b) = wits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) ⊆ pwits b› ‹pwits ([AT (s ∈⇩s t2)] @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits ([AT (s ∈⇩s t2)] @ b). ∀a∈wits_subterms ([AT (s ∈⇩s t2)] @ b). P ([AT (s ∈⇩s t2)] @ b) c a›*) by (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms (?x # ?xs) = subterms ?x ∪ subterms ?xs›*) dest: pwitsD( (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b›*) 1)) qed (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*)) (*solves the remaining goals: 1. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 -⇩s t2)] @ b) c)› 2. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AF (s ∈⇩s t1 -⇩s t2)] @ b) c)› 3. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s ∈⇩s t1)] @ b) = wits b; pwits ([AF (s ∈⇩s t1)] @ b) ⊆ pwits b; pwits ([AF (s ∈⇩s t1)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AF (s ∈⇩s t1)] @ b). Ball (wits_subterms ([AF (s ∈⇩s t1)] @ b)) (P ([AF (s ∈⇩s t1)] @ b) c)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = wits b; pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) ⊆ pwits b; pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b) = pwits b⟧ ⟹ ∀c∈pwits ([AT (s ∈⇩s t1 -⇩s t2)] @ b). Ball (wits_subterms ([AT (s ∈⇩s t1 -⇩s t2)] @ b)) (P ([AT (s ∈⇩s t1 -⇩s t2)] @ b) c)›*) next (*goals: 1. ‹⋀b' b. ⟦lexpands_single b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (5 b' b) (*‹lexpands_single b' b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) proof (induction rule: lexpands_single.induct (*‹⟦lexpands_single ?x1.0 ?x2.0; ⋀t1 b. Single t1 ∈ subterms (last b) ⟹ ?P [AT (t1 ∈⇩s Single t1)] b; ⋀s t1 b. AT (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AT (s =⇩s t1)] b; ⋀s t1 b. AF (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AF (s =⇩s t1)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀(t1::'a pset_term) b::'a pset_atom fm list. ⟦Single t1 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AT (t1 ∈⇩s Single t1)] @ b) = wits b; pwits ([AT (t1 ∈⇩s Single t1)] @ b) ⊆ pwits b⟧ ⟹ ∀c::'a∈pwits ([AT (t1 ∈⇩s Single t1)] @ b). Ball (wits_subterms ([AT (t1 ∈⇩s Single t1)] @ b)) (P ([AT (t1 ∈⇩s Single t1)] @ b) c)› 2. ‹⋀(s::'a pset_term) (t1::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s Single t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AT (s =⇩s t1)] @ b) = wits b; pwits ([AT (s =⇩s t1)] @ b) ⊆ pwits b⟧ ⟹ ∀c::'a∈pwits ([AT (s =⇩s t1)] @ b). Ball (wits_subterms ([AT (s =⇩s t1)] @ b)) (P ([AT (s =⇩s t1)] @ b) c)› 3. ‹⋀(s::'a pset_term) (t1::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. Ball (wits_subterms b) ((P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c); wits ([AF (s =⇩s t1)] @ b) = wits b; pwits ([AF (s =⇩s t1)] @ b) ⊆ pwits b⟧ ⟹ ∀c::'a∈pwits ([AF (s =⇩s t1)] @ b). Ball (wits_subterms ([AF (s =⇩s t1)] @ b)) (P ([AF (s =⇩s t1)] @ b) c)›*) case (2 s t b) (*‹AT ((s::'a::type pset_term) ∈⇩s Single (t::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s =⇩s t)] @ b) = wits b› ‹pwits ([AT (s =⇩s t)] @ b) ⊆ pwits b›*) then have "Single t ∈ subterms b" by (auto intro: subterms_branch_subterms_atomI (*‹⟦AT ?l ∈ set ?b; ?t ∈ subterms ?l⟧ ⟹ ?t ∈ subterms ?b›*)) with "2" (*‹AT (s ∈⇩s Single t) ∈ set b› ‹b ≠ []› ‹no_new_subterms (b::'a pset_atom fm list)› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a› ‹wits ([AT (s =⇩s t)] @ b) = wits b› ‹pwits ([AT (s =⇩s t)] @ b) ⊆ pwits b›*) have "t ∈ subterms (last b)" by (metis subterms_fmD( (*‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*) 7) no_new_subtermsD( (*‹⟦no_new_subterms ?b; Single ?t ∈ subterms ?b⟧ ⟹ Single ?t ∈ subterms (last ?b)›*) 5)) then have "∀c ∈ pwits b. Var c ≠ t" unfolding pwits_def wits_def (*goal: ‹∀c∈{c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}. Var c ≠ t›*) using wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) by fastforce with ‹t ∈ subterms (last b)› (*‹t ∈ subterms (last b)›*) show "?case" (*goal: ‹∀c::'a∈pwits ([AT ((s::'a pset_term) =⇩s (t::'a pset_term))] @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈wits_subterms ([AT (s =⇩s t)] @ b). (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) ([AT (s =⇩s t)] @ b) c a›*) using "2" (*‹AT ((s::'a pset_term) ∈⇩s Single (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AT (s =⇩s t)] @ b) = wits b› ‹pwits ([AT (s =⇩s t)] @ b) ⊆ pwits b›*) unfolding P_def (*goal: ‹∀c∈pwits ([AT (s =⇩s t)] @ b). ∀a∈wits_subterms ([AT (s =⇩s t)] @ b). AT (Var c =⇩s a) ∉ set ([AT (s =⇩s t)] @ b) ∧ AT (a =⇩s Var c) ∉ set ([AT (s =⇩s t)] @ b) ∧ AT (a ∈⇩s Var c) ∉ set ([AT (s =⇩s t)] @ b)›*) by (auto simp: wits_subterms_last_disjnt[unfolded disjoint_iff] (*‹∀x. x ∈ Var ` wits ?b ⟶ x ∉ subterms (last ?b)›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) dest: pwitsD( (*‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b›*) 2)) qed (auto simp: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*) P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*)) (*solves the remaining goals: 1. ‹⋀t1 b. ⟦Single t1 ∈ subterms (last b); b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AT (t1 ∈⇩s Single t1)] @ b) = wits b; pwits ([AT (t1 ∈⇩s Single t1)] @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits ([AT (t1 ∈⇩s Single t1)] @ b). Ball (wits_subterms ([AT (t1 ∈⇩s Single t1)] @ b)) (P ([AT (t1 ∈⇩s Single t1)] @ b) c)› 2. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s =⇩s t1)] @ b) = wits b; pwits ([AF (s =⇩s t1)] @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits ([AF (s =⇩s t1)] @ b). Ball (wits_subterms ([AF (s =⇩s t1)] @ b)) (P ([AF (s =⇩s t1)] @ b) c)›*) next (*goal: ‹⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (6 b' b) (*‹lexpands_eq (b'::'a::type pset_atom fm list) (b::'a::type pset_atom fm list)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) then have "no_new_subterms (b' @ b)" "b' @ b ≠ []" using lexpands_no_new_subterms[OF lexpands.intros ( 6 )] (*‹⟦lexpands_eq ?b' ?b; ?b ≠ []; no_new_subterms ?b⟧ ⟹ no_new_subterms (?b' @ ?b)›*) apply - (*goals: 1. ‹⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b; ⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b)⟧ ⟹ no_new_subterms (b' @ b)› 2. ‹⟦lexpands_eq b' b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits (b' @ b) = wits b; pwits (b' @ b) ⊆ pwits b; ⋀b' b. ⟦lexpands_eq b' b; b ≠ []; no_new_subterms b⟧ ⟹ no_new_subterms (b' @ b)⟧ ⟹ b' @ b ≠ []› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . note subterms_branch_eq_if_no_new_subterms[OF this] (*‹subterms (b' @ b) = wits_subterms (b' @ b)›*) with "6" (*‹lexpands_eq b' b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) ⊆ pwits b›*) show "?case" (*goal: ‹∀c::'a∈pwits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈wits_subterms (b' @ b). (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) (b' @ b) c a›*) proof (induction rule: lexpands_eq_induct' (*‹⟦lexpands_eq ?b' ?b; ⋀t1 t2 t1' t2' p l b. ⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l⟧ ⟹ ?P [polarise p (AT (subst_tlvl t1' t2' l))] b; ⋀s t s' b. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b⟧ ⟹ ?P [AF (s =⇩s s')] b⟧ ⟹ ?P ?b' ?b›*)) (*goals: 1. ‹⋀t1 t2 t1' t2' p l b. ⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ ∀c∈pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b). Ball (wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)) (P ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) c)› 2. ‹⋀s t s' b. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s =⇩s s')] @ b) = wits b; pwits ([AF (s =⇩s s')] @ b) ⊆ pwits b; subterms ([AF (s =⇩s s')] @ b) = wits_subterms ([AF (s =⇩s s')] @ b)⟧ ⟹ ∀c∈pwits ([AF (s =⇩s s')] @ b). Ball (wits_subterms ([AF (s =⇩s s')] @ b)) (P ([AF (s =⇩s s')] @ b) c)›*) case (subst t1 t2 t1' t2' p l b) (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise (p::bool) (AT (l::'a pset_atom)) ∈ set (b::'a pset_atom fm list)› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹(t1'::'a pset_term) ∈ tlvl_terms (l::'a pset_atom)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) then have "t1' ∈ subterms b" using AT_eq_subterms_branchD (*‹AT ((?s::?'a::type pset_term) =⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) by blast then show "?case" (*goal: ‹∀c::'a∈pwits ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b). (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) c a›*) unfolding P_def (*goal: ‹∀c∈pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b). ∀a∈wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b). AT (Var c =⇩s a) ∉ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ∧ AT (a =⇩s Var c) ∉ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ∧ AT (a ∈⇩s Var c) ∉ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) proof (safe, goal_cases) (*goals: 1. ‹⋀c x. ⟦t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ False› 2. ‹⋀c x. ⟦t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ False› 3. ‹⋀c x. ⟦t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ False›*) case (1 c x) (*‹t1' ∈ subterms b› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) with subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise p (AT l) ∈ set b› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list)) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) have [simp]: p apply (cases p) (*goals: 1. ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); p⟧ ⟹ p› 2. ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); ¬ p⟧ ⟹ p› discuss goal 1*) apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*discuss goal 2*) apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); ¬ p⟧ ⟹ p›*) apply blast (*proven 2 subgoals*) . from "1" (*‹t1' ∈ subterms b› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise p (AT l) ∈ set b› ‹(t1'::'a pset_term, t2'::'a pset_term) ∈ {(t1::'a pset_term, t2::'a pset_term), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹(b::'a::type pset_atom fm list) ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) have "(Var c =⇩s x) = subst_tlvl t1' t2' l" apply (simp add: P_def (*‹P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool ≡ λ(b::'a pset_atom fm list) (c::'a) t::'a pset_term. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹Var c =⇩s x = subst_tlvl t1' t2' l›*) by blast with "1" (*‹t1' ∈ subterms b› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise p (AT l) ∈ set b› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹(t1'::'a pset_term) ∈ tlvl_terms (l::'a pset_atom)› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) consider (refl)"l = (t1' =⇩s t1')" and "t2' = Var c" and "x = Var c" | (t1'_left)"l = (Var c =⇩s t1')" and "t2' = x" | (t1'_right)"l = (t1' =⇩s x)" and "t2' = Var c" (*goal: ‹⟦⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = Var c =⇩s t1'; t2' = x⟧ ⟹ thesis; ⟦l = t1' =⇩s x; t2' = Var c⟧ ⟹ thesis⟧ ⟹ thesis›*) apply (cases "(t1', t2', l)" rule: subst_tlvl.cases (*‹⟦⋀t1 t2 s1 s2. ?x = (t1, t2, s1 ∈⇩s s2) ⟹ ?P; ⋀t1 t2 s1 s2. ?x = (t1, t2, s1 =⇩s s2) ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀t1a t2a s1 s2. ⟦⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = Var c =⇩s t1'; t2' = x⟧ ⟹ thesis; ⟦l = t1' =⇩s x; t2' = Var c⟧ ⟹ thesis; t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); Var c =⇩s x = subst_tlvl t1' t2' l; (t1', t2', l) = (t1a, t2a, s1 ∈⇩s s2)⟧ ⟹ thesis› 2. ‹⋀t1a t2a s1 s2. ⟦⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = Var c =⇩s t1'; t2' = x⟧ ⟹ thesis; ⟦l = t1' =⇩s x; t2' = Var c⟧ ⟹ thesis; t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (Var c =⇩s x) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); Var c =⇩s x = subst_tlvl t1' t2' l; (t1', t2', l) = (t1a, t2a, s1 =⇩s s2)⟧ ⟹ thesis› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . then show "?case" (*goal: ‹False›*) apply cases (*goals: 1. ‹⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ False› 2. ‹⟦l = Var c =⇩s t1'; t2' = x⟧ ⟹ False› 3. ‹⟦l = t1' =⇩s x; t2' = Var c⟧ ⟹ False› discuss goal 1*) apply ((use 1 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*discuss goal 2*) apply ((use 1 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*discuss goal 3*) apply ((use 1 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀c x. ⟦t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ False› 2. ‹⋀c x. ⟦t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ False›*) case (2 c x) (*‹t1' ∈ subterms b› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹(x::'a pset_term) ∈ wits_subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list))› ‹AT ((x::'a pset_term) =⇩s Var (c::'a)) ∈ set ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list))›*) with subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise p (AT l) ∈ set b› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹(b::'a pset_atom fm list) ≠ []› ‹no_new_subterms (b::'a pset_atom fm list)› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list)) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) have [simp]: p apply (cases p) (*goals: 1. ‹⟦AT ((t1::'a pset_term) =⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list); polarise (p::bool) (AT (l::'a pset_atom)) ∈ set b; (t1'::'a pset_term, t2'::'a pset_term) ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; (c::'a) ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); (x::'a pset_term) ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); p⟧ ⟹ p› 2. ‹⟦AT ((t1::'a pset_term) =⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list); polarise (p::bool) (AT (l::'a pset_atom)) ∈ set b; (t1'::'a pset_term, t2'::'a pset_term) ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ::'a pset_atom fm∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c::'a∈pwits b. ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; (c::'a) ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); (x::'a pset_term) ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); ¬ p⟧ ⟹ p› discuss goal 1*) apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*discuss goal 2*) apply (simp add: P_def (*‹P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool ≡ λ(b::'a pset_atom fm list) (c::'a) t::'a pset_term. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms (?b::?'a pset_atom fm list) ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); ¬ p⟧ ⟹ p›*) apply blast (*proven 2 subgoals*) . from "2" (*‹t1' ∈ subterms b› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹(x::'a pset_term) ∈ wits_subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list))› ‹AT ((x::'a pset_term) =⇩s Var (c::'a)) ∈ set ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list))›*) subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise p (AT l) ∈ set b› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹(b::'a pset_atom fm list) ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list)) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) have "(x =⇩s Var c) = subst_tlvl t1' t2' l" apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹x =⇩s Var c = subst_tlvl t1' t2' l›*) by blast with "2" (*‹t1' ∈ subterms b› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹(x::'a::type pset_term) ∈ wits_subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a::type pset_term) (t2'::'a::type pset_term) (l::'a::type pset_atom)))] @ (b::'a::type pset_atom fm list))› ‹AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise (p::bool) (AT (l::'a pset_atom)) ∈ set (b::'a pset_atom fm list)› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹(b::'a pset_atom fm list) ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a::type pset_term) (t2'::'a::type pset_term) (l::'a::type pset_atom)))] @ (b::'a::type pset_atom fm list)) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) consider (refl)"l = (t1' =⇩s t1')" and "t2' = Var c" and "x = Var c" | (t1_left)"l = (t1' =⇩s Var c)" and "t2' = x" | (t1_right)"l = (x =⇩s t1')" and "t2' = Var c" (*goal: ‹⟦⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = t1' =⇩s Var c; t2' = x⟧ ⟹ thesis; ⟦l = x =⇩s t1'; t2' = Var c⟧ ⟹ thesis⟧ ⟹ thesis›*) apply (cases "(t1', t2', l)" rule: subst_tlvl.cases (*‹⟦⋀t1 t2 s1 s2. ?x = (t1, t2, s1 ∈⇩s s2) ⟹ ?P; ⋀t1 t2 s1 s2. ?x = (t1, t2, s1 =⇩s s2) ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀t1a t2a s1 s2. ⟦⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = t1' =⇩s Var c; t2' = x⟧ ⟹ thesis; ⟦l = x =⇩s t1'; t2' = Var c⟧ ⟹ thesis; t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x =⇩s Var c = subst_tlvl t1' t2' l; (t1', t2', l) = (t1a, t2a, s1 ∈⇩s s2)⟧ ⟹ thesis› 2. ‹⋀t1a t2a s1 s2. ⟦⟦l = t1' =⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = t1' =⇩s Var c; t2' = x⟧ ⟹ thesis; ⟦l = x =⇩s t1'; t2' = Var c⟧ ⟹ thesis; t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x =⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x =⇩s Var c = subst_tlvl t1' t2' l; (t1', t2', l) = (t1a, t2a, s1 =⇩s s2)⟧ ⟹ thesis› discuss goal 1*) apply ((auto split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . then show "?case" (*goal: ‹False›*) apply cases (*goals: 1. ‹⟦(l::'a pset_atom) = (t1'::'a pset_term) =⇩s t1'; (t2'::'a pset_term) = Var (c::'a); (x::'a pset_term) = Var c⟧ ⟹ False› 2. ‹⟦(l::'a pset_atom) = (t1'::'a pset_term) =⇩s Var (c::'a); (t2'::'a pset_term) = (x::'a pset_term)⟧ ⟹ False› 3. ‹⟦(l::'a pset_atom) = (x::'a pset_term) =⇩s (t1'::'a pset_term); (t2'::'a pset_term) = Var (c::'a)⟧ ⟹ False› discuss goal 1*) apply ((use 2 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*discuss goal 2*) apply ((use 2 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*discuss goal 3*) apply ((use 2 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*proven 3 subgoals*) . next (*goal: ‹⋀c x. ⟦t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)⟧ ⟹ False›*) case (3 c x) (*‹t1' ∈ subterms b› ‹(c::'a::type) ∈ pwits ([polarise (p::bool) (AT (subst_tlvl (t1'::'a::type pset_term) (t2'::'a::type pset_term) (l::'a::type pset_atom)))] @ (b::'a::type pset_atom fm list))› ‹x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) with subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise (p::bool) (AT (l::'a pset_atom)) ∈ set (b::'a pset_atom fm list)› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹(b::'a::type pset_atom fm list) ≠ []› ‹no_new_subterms b› ‹∀φ::'a pset_atom fm∈set (b::'a pset_atom fm list). ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list)) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) have [simp]: p apply (cases p) (*goals: 1. ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); p⟧ ⟹ p› 2. ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); ¬ p⟧ ⟹ p› discuss goal 1*) apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*discuss goal 2*) apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); ¬ p⟧ ⟹ p›*) apply blast (*proven 2 subgoals*) . from "3" (*‹(t1'::'a pset_term) ∈ subterms (b::'a pset_atom fm list)› ‹c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)› ‹(x::'a::type pset_term) ∈ wits_subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a::type pset_term) (t2'::'a::type pset_term) (l::'a::type pset_atom)))] @ (b::'a::type pset_atom fm list))› ‹AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise (p::bool) (AT (l::'a pset_atom)) ∈ set (b::'a pset_atom fm list)› ‹(t1'::'a pset_term, t2'::'a pset_term) ∈ {(t1::'a pset_term, t2::'a pset_term), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) have "(x ∈⇩s Var c) = subst_tlvl t1' t2' l" apply (simp add: P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹x ∈⇩s Var c = subst_tlvl t1' t2' l›*) by blast with "3" (*‹t1' ∈ subterms b› ‹(c::'a::type) ∈ pwits ([polarise (p::bool) (AT (subst_tlvl (t1'::'a::type pset_term) (t2'::'a::type pset_term) (l::'a::type pset_atom)))] @ (b::'a::type pset_atom fm list))› ‹(x::'a pset_term) ∈ wits_subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list))› ‹AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) subst (*‹AT (t1 =⇩s t2) ∈ set b› ‹polarise (p::bool) (AT (l::'a pset_atom)) ∈ set (b::'a pset_atom fm list)› ‹(t1', t2') ∈ {(t1, t2), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b› ‹pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b› ‹subterms ([polarise (p::bool) (AT (subst_tlvl (t1'::'a pset_term) (t2'::'a pset_term) (l::'a pset_atom)))] @ (b::'a pset_atom fm list)) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b)›*) consider (refl)"l = (t1' ∈⇩s t1')" and "t2' = Var c" and "x = Var c" | (t1_left)"l = (t1' ∈⇩s Var c)" and "t2' = x" | (t1_right)"l = (x ∈⇩s t1')" and "t2' = Var c" (*goal: ‹⟦⟦(l::'a pset_atom) = (t1'::'a pset_term) ∈⇩s t1'; (t2'::'a pset_term) = Var (c::'a); (x::'a pset_term) = Var c⟧ ⟹ thesis::bool; ⟦l = t1' ∈⇩s Var c; t2' = x⟧ ⟹ thesis; ⟦l = x ∈⇩s t1'; t2' = Var c⟧ ⟹ thesis⟧ ⟹ thesis›*) apply (cases "(t1', t2', l)" rule: subst_tlvl.cases (*‹⟦⋀(t1::?'a pset_term) (t2::?'a pset_term) (s1::?'a pset_term) s2::?'a pset_term. (?x::?'a pset_term × ?'a pset_term × ?'a pset_atom) = (t1, t2, s1 ∈⇩s s2) ⟹ ?P::bool; ⋀(t1::?'a pset_term) (t2::?'a pset_term) (s1::?'a pset_term) s2::?'a pset_term. ?x = (t1, t2, s1 =⇩s s2) ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀t1a t2a s1 s2. ⟦⟦l = t1' ∈⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = t1' ∈⇩s Var c; t2' = x⟧ ⟹ thesis; ⟦l = x ∈⇩s t1'; t2' = Var c⟧ ⟹ thesis; t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈⇩s Var c = subst_tlvl t1' t2' l; (t1', t2', l) = (t1a, t2a, s1 ∈⇩s s2)⟧ ⟹ thesis› 2. ‹⋀t1a t2a s1 s2. ⟦⟦l = t1' ∈⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ thesis; ⟦l = t1' ∈⇩s Var c; t2' = x⟧ ⟹ thesis; ⟦l = x ∈⇩s t1'; t2' = Var c⟧ ⟹ thesis; t1' ∈ subterms b; c ∈ pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈ wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (x ∈⇩s Var c) ∈ set ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈wits_subterms b. P b c a; wits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits b; pwits ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) ⊆ pwits b; subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b) = wits_subterms ([polarise p (AT (subst_tlvl t1' t2' l))] @ b); x ∈⇩s Var c = subst_tlvl t1' t2' l; (t1', t2', l) = (t1a, t2a, s1 =⇩s s2)⟧ ⟹ thesis› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . then show "?case" (*goal: ‹False›*) apply cases (*goals: 1. ‹⟦l = t1' ∈⇩s t1'; t2' = Var c; x = Var c⟧ ⟹ False› 2. ‹⟦l = t1' ∈⇩s Var c; t2' = x⟧ ⟹ False› 3. ‹⟦l = x ∈⇩s t1'; t2' = Var c⟧ ⟹ False› discuss goal 1*) apply ((use 3 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*discuss goal 2*) apply ((use 3 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*discuss goal 3*) apply ((use 3 subst subterms_branch_eq_if_no_new_subterms in ‹(simp add: P_def; blast)+›)[1]) (*proven 3 subgoals*) . qed next (*goal: ‹⋀s t s' b. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); wits ([AF (s =⇩s s')] @ b) = wits b; pwits ([AF (s =⇩s s')] @ b) ⊆ pwits b; subterms ([AF (s =⇩s s')] @ b) = wits_subterms ([AF (s =⇩s s')] @ b)⟧ ⟹ ∀c∈pwits ([AF (s =⇩s s')] @ b). Ball (wits_subterms ([AF (s =⇩s s')] @ b)) (P ([AF (s =⇩s s')] @ b) c)›*) case (neq s t s' b) (*‹AT (s ∈⇩s t) ∈ set b› ‹AF (s' ∈⇩s t) ∈ set b› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹wits ([AF (s =⇩s s')] @ b) = wits b› ‹pwits ([AF (s =⇩s s')] @ b) ⊆ pwits b› ‹subterms ([AF (s =⇩s s')] @ b) = wits_subterms ([AF (s =⇩s s')] @ b)›*) then show "?case" (*goal: ‹∀c::'a∈pwits ([AF ((s::'a pset_term) =⇩s (s'::'a pset_term))] @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈wits_subterms ([AF (s =⇩s s')] @ b). (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) ([AF (s =⇩s s')] @ b) c a›*) using P_def (*‹P ≡ λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b›*) apply (simp add: wits_subterms_def (*‹wits_subterms ?b ≡ Var ` wits ?b ∪ subterms (last ?b)›*)) (*goal: ‹∀c∈pwits ([AF (s =⇩s s')] @ b). ∀a∈wits_subterms ([AF (s =⇩s s')] @ b). P ([AF (s =⇩s s')] @ b) c a›*) by blast qed qed lemma lemma_2_bexpands: defines "P ≡ (λb c t. AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b)" assumes "bexpands bs' b" "b' ∈ bs'" "b ≠ []" assumes "no_new_subterms b" assumes "∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}" assumes "∀c ∈ pwits b. ∀t ∈ wits_subterms b. P b c t" shows "∀c ∈ pwits (b' @ b). ∀t ∈ wits_subterms (b' @ b). P (b' @ b) c t" using assms(2-) (*‹bexpands (bs'::'a pset_atom fm list set) (b::'a pset_atom fm list)› ‹b' ∈ bs'› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀t∈wits_subterms b. P b c t›*) bexpands_no_new_subterms[OF assms ( 2 , 4 , 3 , 5 )] (*‹no_new_subterms (b' @ b)›*) proof (induction rule: bexpands.induct (*‹⟦bexpands ?x1.0 ?x2.0; ⋀bs' b. bexpands_nowit bs' b ⟹ ?P bs' b; ⋀t1 t2 x bs' b. bexpands_wit t1 t2 x bs' b ⟹ ?P bs' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀bs' b. ⟦bexpands_nowit bs' b; b' ∈ bs'; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b)⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀t1 t2 x bs' b. ⟦bexpands_wit t1 t2 x bs' b; b' ∈ bs'; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b)⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (1 bs' b) (*‹bexpands_nowit bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) using bexpands_nowit_wits_eq[OF "1" ( 1 - 3 )] (*‹wits (b' @ b) = wits b›*) bexpands_nowit_pwits_eq[OF "1" ( 1 - 3 , 5 )] (*‹pwits (b' @ b) = pwits b›*) proof (induction rule: bexpands_nowit.induct (*‹⟦bexpands_nowit ?x1.0 ?x2.0; ⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b⟧ ⟹ ?P {[p], [Neg p]} b; ⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b⟧ ⟹ ?P {[Neg p], [p]} b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (1 p q b) (*‹Or p q ∈ set b› ‹p ∉ set b› ‹Neg p ∉ set b› ‹(b'::'a pset_atom fm list) ∈ {[p::'a pset_atom fm], [Neg p]}› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list))› ‹wits (b' @ b) = wits b› ‹pwits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)) = pwits b›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) unfolding P_def wits_subterms_def (*goal: ‹∀c::'a∈pwits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈Var ` wits (b' @ b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) by (fastforce dest: pwitsD (*‹(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list) ⟹ ?c ∈ wits ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦(?c::?'a) ∈ pwits (?b::?'a pset_atom fm list); (?t::?'a pset_term) ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) next (*goals: 1. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (2 p q b) (*‹Neg (And p q) ∈ set b› ‹Neg p ∉ set b› ‹p ∉ set b› ‹(b'::'a pset_atom fm list) ∈ {[Neg (p::'a pset_atom fm)], [p]}› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a::type∈pwits (b::'a::type pset_atom fm list). ∀a::'a::type pset_term∈wits_subterms b. (P::'a::type pset_atom fm list ⇒ 'a::type ⇒ 'a::type pset_term ⇒ bool) b c a› ‹no_new_subterms ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list))› ‹wits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)) = wits b› ‹pwits ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = pwits b›*) then show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) unfolding P_def wits_subterms_def (*goal: ‹∀c∈pwits (b' @ b). ∀a∈Var ` wits (b' @ b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) by (fastforce dest: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) next (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 3. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (3 s t1 t2 b) (*‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b› ‹t1 ⊔⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t1) ∉ set b› ‹AF ((s::'a pset_term) ∈⇩s (t1::'a pset_term)) ∉ set (b::'a pset_atom fm list)› ‹b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)› ‹wits ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list)) = wits b› ‹pwits (b' @ b) = pwits b›*) then have "t1 ∉ Var ` wits b" by (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) with "3" (*‹AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term) ⊔⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹t1 ⊔⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t1) ∉ set b› ‹AF (s ∈⇩s t1) ∉ set b› ‹(b'::'a pset_atom fm list) ∈ {[AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term))], [AF (s ∈⇩s t1)]}› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) unfolding P_def wits_subterms_def (*goal: ‹∀c∈pwits (b' @ b). ∀a∈Var ` wits (b' @ b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) by (fastforce simp: vars_branch_simps (*‹vars [] = {}› ‹vars (?x # ?xs) = vars ?x ∪ vars ?xs›*) dest: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) next (*goals: 1. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (4 s t1 b t2) (*‹AT (s ∈⇩s t1) ∈ set b› ‹t1 ⊓⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t2) ∉ set b› ‹AF (s ∈⇩s t2) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}› ‹b ≠ []› ‹no_new_subterms (b::'a::type pset_atom fm list)› ‹∀φ::'a pset_atom fm∈set (b::'a pset_atom fm list). ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a› ‹no_new_subterms (b' @ b)› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) = pwits b›*) then have "t2 ∉ Var ` wits b" by (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) with "4" (*‹AT (s ∈⇩s t1) ∈ set b› ‹t1 ⊓⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t2) ∉ set b› ‹AF (s ∈⇩s t2) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) unfolding P_def wits_subterms_def (*goal: ‹∀c∈pwits (b' @ b). ∀a∈Var ` wits (b' @ b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) by (fastforce simp: vars_branch_simps (*‹vars [] = {}› ‹vars (?x # ?xs) = vars ?x ∪ vars ?xs›*) dest: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) next (*goal: ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b); wits (b' @ b) = wits b; pwits (b' @ b) = pwits b⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (5 s t1 b t2) (*‹AT (s ∈⇩s t1) ∈ set b› ‹t1 -⇩s t2 ∈ subterms (last b)› ‹AT (s ∈⇩s t2) ∉ set b› ‹AF (s ∈⇩s t2) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) = pwits b›*) then have "t2 ∉ Var ` wits b" by (meson disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*) subterms_fmD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t1.0 ∈ subterms ?φ› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?φ ⟹ ?t2.0 ∈ subterms ?φ› ‹Single ?t ∈ subterms ?φ ⟹ ?t ∈ subterms ?φ›*)) with "5" (*‹AT (s ∈⇩s t1) ∈ set b› ‹t1 -⇩s t2 ∈ subterms (last b)› ‹AT ((s::'a::type pset_term) ∈⇩s (t2::'a::type pset_term)) ∉ set (b::'a::type pset_atom fm list)› ‹AF (s ∈⇩s t2) ∉ set b› ‹b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}› ‹b ≠ []› ‹no_new_subterms (b::'a::type pset_atom fm list)› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)› ‹wits (b' @ b) = wits b› ‹pwits (b' @ b) = pwits b›*) show "?case" (*goal: ‹∀c∈pwits (b' @ b). ∀a∈wits_subterms (b' @ b). P (b' @ b) c a›*) unfolding P_def wits_subterms_def (*goal: ‹∀c∈pwits (b' @ b). ∀a∈Var ` wits (b' @ b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) by (fastforce simp: vars_branch_simps (*‹vars [] = {}› ‹vars (?x # ?xs) = vars ?x ∪ vars ?xs›*) dest: pwitsD (*‹?c ∈ pwits ?b ⟹ ?c ∈ wits ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (Var ?c =⇩s ?t) ∉ set ?b› ‹⟦?c ∈ pwits ?b; ?t ∈ subterms (last ?b)⟧ ⟹ AT (?t =⇩s Var ?c) ∉ set ?b›*)) qed next (*goal: ‹⋀t1 t2 x bs' b. ⟦bexpands_wit t1 t2 x bs' b; b' ∈ bs'; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. Ball (wits_subterms b) (P b c); no_new_subterms (b' @ b)⟧ ⟹ ∀c∈pwits (b' @ b). Ball (wits_subterms (b' @ b)) (P (b' @ b) c)›*) case (2 t1 t2 x bs b) (*‹bexpands_wit t1 t2 x bs b› ‹b' ∈ bs› ‹b ≠ []› ‹no_new_subterms b› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c∈pwits b. ∀a∈wits_subterms b. P b c a› ‹no_new_subterms (b' @ b)›*) from bexpands_witD[OF "2" ( 1 )] (*‹bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}› ‹AF ((t1::'a pset_term) =⇩s (t2::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹(t1::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list))› ‹t2 ∈ subterms (last b)› ‹∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b› ‹∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b› ‹¬ urelem (last b) t1› ‹¬ urelem (last (b::'a pset_atom fm list)) (t2::'a pset_term)› ‹(x::'a) ∉ vars (b::'a pset_atom fm list)›*) have "t1 ∉ Var ` wits b" "t2 ∉ Var ` wits b" apply - (*goals: 1. ‹⟦bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b⟧ ⟹ t1 ∉ Var ` wits b› 2. ‹⟦bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b⟧ ⟹ t2 ∉ Var ` wits b› discuss goal 1*) apply (meson disjoint_iff_not_equal (*‹(?A ∩ ?B = {}) = (∀x∈?A. ∀y∈?B. x ≠ y)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*)) (*discuss goal 2*) apply (meson disjoint_iff_not_equal (*‹(?A ∩ ?B = {}) = (∀x∈?A. ∀y∈?B. x ≠ y)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*)) (*proven 2 subgoals*) . then have not_in_pwits: "t1 ∉ Var ` pwits b" "t2 ∉ Var ` pwits b" unfolding pwits_def (*goals: 1. ‹t1 ∉ Var ` {c ∈ wits b. ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹t2 ∉ Var ` {c ∈ wits b. ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) apply - (*goals: 1. ‹⟦(t1::'a::type pset_term) ∉ Var ` wits (b::'a::type pset_atom fm list); (t2::'a::type pset_term) ∉ Var ` wits b⟧ ⟹ t1 ∉ Var ` {c::'a::type ∈ wits b. ∀t::'a::type pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹⟦(t1::'a::type pset_term) ∉ Var ` wits (b::'a::type pset_atom fm list); (t2::'a::type pset_term) ∉ Var ` wits b⟧ ⟹ t2 ∉ Var ` {c::'a::type ∈ wits b. ∀t::'a::type pset_term∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with bexpands_witD[OF "2" ( 1 )] (*‹bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}› ‹AF (t1 =⇩s t2) ∈ set b› ‹t1 ∈ subterms (last b)› ‹t2 ∈ subterms (last b)› ‹∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b› ‹∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b› ‹¬ urelem (last b) t1› ‹¬ urelem (last b) t2› ‹x ∉ vars b›*) "2"(2-) (*‹(b'::'a pset_atom fm list) ∈ (bs::'a pset_atom fm list set)› ‹b ≠ []› ‹no_new_subterms (b::'a pset_atom fm list)› ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}› ‹∀c::'a∈pwits (b::'a pset_atom fm list). ∀a::'a pset_term∈wits_subterms b. (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) b c a› ‹no_new_subterms (b' @ b)›*) show "?case" (*goal: ‹∀c::'a∈pwits ((b'::'a pset_atom fm list) @ (b::'a pset_atom fm list)). ∀a::'a pset_term∈wits_subterms (b' @ b). (P::'a pset_atom fm list ⇒ 'a ⇒ 'a pset_term ⇒ bool) (b' @ b) c a›*) unfolding P_def wits_subterms_def (*goal: ‹∀c∈pwits (b' @ b). ∀a∈Var ` wits (b' @ b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) unfolding bexpands_wit_pwits_eq[OF "2" ( 1 - 3 )] bexpands_wit_wits_eq[OF "2" ( 1 - 3 )] (*goal: ‹∀c∈insert x (pwits b). ∀a∈Var ` insert x (wits b) ∪ subterms (last (b' @ b)). AT (Var c =⇩s a) ∉ set (b' @ b) ∧ AT (a =⇩s Var c) ∉ set (b' @ b) ∧ AT (a ∈⇩s Var c) ∉ set (b' @ b)›*) apply safe (*goals: 1. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; AT (Var x =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 2. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; AT (Var x =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 3. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; AT (Var x ∈⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 4. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; xaa ∈ wits b; AT (Var x =⇩s Var xaa) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 5. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; xaa ∈ wits b; AT (Var xaa =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 6. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; xaa ∈ wits b; AT (Var xaa ∈⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 7. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; xa ∈ subterms (last ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)); AT (Var x =⇩s xa) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 8. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; xa ∈ subterms (last ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)); AT (xa =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 9. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; xa ∈ subterms (last ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)); AT (xa ∈⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 10. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; AT (Var c =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 11. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; AT (Var x =⇩s Var c) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 12. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; AT (Var x ∈⇩s Var c) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 13. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; xaa ∈ wits b; AT (Var c =⇩s Var xaa) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 14. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; xaa ∈ wits b; AT (Var xaa =⇩s Var c) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 15. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; xaa ∈ wits b; AT (Var xaa ∈⇩s Var c) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 16. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; xa ∈ subterms (last ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)); AT (Var c =⇩s xa) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 17. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; xa ∈ subterms (last ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)); AT (xa =⇩s Var c) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 18. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)]; c ∈ pwits b; xa ∈ subterms (last ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)); AT (xa ∈⇩s Var c) ∈ set ([AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)] @ b)⟧ ⟹ False› 19. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; AT (Var x =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 20. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; AT (Var x =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 21. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; AT (Var x ∈⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 22. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; xaa ∈ wits b; AT (Var x =⇩s Var xaa) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 23. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; xaa ∈ wits b; AT (Var xaa =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 24. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; xaa ∈ wits b; AT (Var xaa ∈⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 25. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; xa ∈ subterms (last ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)); AT (Var x =⇩s xa) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 26. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; xa ∈ subterms (last ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)); AT (xa =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 27. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; xa ∈ subterms (last ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)); AT (xa ∈⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 28. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; AT (Var c =⇩s Var x) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 29. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; AT (Var x =⇩s Var c) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 30. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; AT (Var x ∈⇩s Var c) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 31. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; xaa ∈ wits b; AT (Var c =⇩s Var xaa) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 32. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; xaa ∈ wits b; AT (Var xaa =⇩s Var c) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 33. ‹⋀c xa xaa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; xaa ∈ wits b; AT (Var xaa ∈⇩s Var c) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 34. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; xa ∈ subterms (last ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)); AT (Var c =⇩s xa) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 35. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; xa ∈ subterms (last ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)); AT (xa =⇩s Var c) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› 36. ‹⋀c xa. ⟦AF (t1 =⇩s t2) ∈ set b; t1 ∈ subterms (last b); t2 ∈ subterms (last b); ∄x. AT (x ∈⇩s t1) ∈ set b ∧ AF (x ∈⇩s t2) ∈ set b; ∄x. AT (x ∈⇩s t2) ∈ set b ∧ AF (x ∈⇩s t1) ∈ set b; ¬ urelem (last b) t1; ¬ urelem (last b) t2; x ∉ vars b; b ≠ []; no_new_subterms b; ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}; ∀c∈pwits b. ∀a∈Var ` wits b ∪ subterms (last b). AT (Var c =⇩s a) ∉ set b ∧ AT (a =⇩s Var c) ∉ set b ∧ AT (a ∈⇩s Var c) ∉ set b; no_new_subterms ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b); t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; bs = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}; b' = [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]; c ∈ pwits b; xa ∈ subterms (last ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)); AT (xa ∈⇩s Var c) ∈ set ([AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)] @ b)⟧ ⟹ False› discuss goal 1*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 2*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 3*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list); (x::'a) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 4*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a::type pset_atom fm) ∈ set (b::'a::type pset_atom fm list); (x::'a::type) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 5*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list); (x::'a) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 6*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 7*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 8*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a::type pset_atom fm) ∈ set (b::'a::type pset_atom fm list); (x::'a::type) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 9*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 10*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 11*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 12*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 13*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 14*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 15*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 16*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 17*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 18*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 19*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 20*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 21*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 22*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list); (x::'a) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 23*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 24*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 25*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 26*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 27*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 28*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 29*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 30*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list); (x::'a) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 31*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 32*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 33*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 34*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 35*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦?φ ∈ set b; x ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*discuss goal 36*) apply ((auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b] (*‹⟦(?φ::'a::type pset_atom fm) ∈ set (b::'a::type pset_atom fm list); (x::'a::type) ∈ vars ?φ⟧ ⟹ x ∈ vars b›*))[1]) (*proven 36 subgoals*) . qed lemma subterms_branch_eq_if_wf_branch: assumes "wf_branch b" shows "subterms_branch b = wits_subterms b" proof (-) (*goal: ‹subterms b = wits_subterms b›*) from assms (*‹wf_branch b›*) obtain φ where "expandss b [φ]" (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) unfolding wf_branch_def (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) by blast then have "no_new_subterms [φ]" unfolding no_new_subterms_def wits_def (*goal: ‹∀t∈subterms [φ]. t ∉ Var ` (vars [φ] - vars (last [φ])) ⟶ t ∈ subterms (last [φ])›*) by (simp add: subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*)) with ‹expandss b [φ]› (*‹expandss b [φ]›*) have "no_new_subterms b" using expandss_no_new_subterms (*‹⟦expandss ?b' ?b; ?b ≠ []; no_new_subterms ?b⟧ ⟹ no_new_subterms ?b'›*) by blast with ‹expandss b [φ]› (*‹expandss b [φ]›*) assms (*‹wf_branch b›*) show "?thesis" (*goal: ‹subterms b = wits_subterms b›*) apply (intro subterms_branch_eq_if_no_new_subterms (*‹⟦no_new_subterms ?b; ?b ≠ []⟧ ⟹ subterms ?b = wits_subterms ?b›*)) (*goals: 1. ‹⟦expandss (b::'a::type pset_atom fm list) [φ::'a::type pset_atom fm]; wf_branch b; no_new_subterms b⟧ ⟹ no_new_subterms b› 2. ‹⟦expandss (b::'a::type pset_atom fm list) [φ::'a::type pset_atom fm]; wf_branch b; no_new_subterms b⟧ ⟹ b ≠ []› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed lemma assumes "wf_branch b" shows no_new_subterms_if_wf_branch: "no_new_subterms b" and no_wits_if_not_literal_if_wf_branch: "∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}" proof (-) (*goals: 1. ‹no_new_subterms b› 2. ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) from assms (*‹wf_branch b›*) obtain φ where "expandss b [φ]" (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) unfolding wf_branch_def (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) by blast then have "no_new_subterms [φ]" by (auto simp: no_new_subterms_def (*‹no_new_subterms (?b::?'a pset_atom fm list) ≡ ∀t::?'a pset_term∈subterms ?b. t ∉ Var ` wits ?b ⟶ t ∈ subterms (last ?b)›*) wits_def (*‹wits (?b::?'a pset_atom fm list) ≡ vars ?b - vars (last ?b)›*) vars_branch_simps (*‹vars [] = {}› ‹vars ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = vars ?x ∪ vars ?xs›*) subterms_branch_simps (*‹subterms [] = {}› ‹subterms ((?x::?'b pset_atom fm) # (?xs::?'b pset_atom fm list)) = subterms ?x ∪ subterms ?xs›*)) from expandss_no_new_subterms[OF ‹expandss b [φ]› _ this] (*‹[φ] ≠ [] ⟹ no_new_subterms b›*) show "no_new_subterms b" by simp from expandss_no_wits_if_not_literal[OF ‹expandss b [φ]›] (*‹⟦[φ] ≠ []; ∀φ'∈set [φ]. ¬ is_literal φ' ⟶ vars φ' ∩ wits [φ] = {}⟧ ⟹ ∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}›*) show "∀φ ∈ set b. ¬ is_literal φ ⟶ vars φ ∩ wits b = {}" unfolding wits_def (*goal: ‹∀φ∈set b. ¬ is_literal φ ⟶ vars φ ∩ (vars b - vars (last b)) = {}›*) by simp qed lemma lemma_2: assumes "wf_branch b" assumes "c ∈ pwits b" shows "AT (Var c =⇩s t) ∉ set b" "AT (t =⇩s Var c) ∉ set b" "AT (t ∈⇩s Var c) ∉ set b" proof (-) (*goals: 1. ‹AT (Var c =⇩s t) ∉ set b› 2. ‹AT (t =⇩s Var c) ∉ set b› 3. ‹AT (t ∈⇩s Var c) ∉ set b›*) from ‹wf_branch b› (*‹wf_branch b›*) obtain φ where "expandss b [φ]" (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) using wf_branch_def (*‹wf_branch (?b::?'a pset_atom fm list) ≡ ∃φ::?'a pset_atom fm. expandss ?b [φ]›*) by blast have no_wits_if_not_literal: "∀φ ∈ set b'. ¬ is_literal φ ⟶ vars φ ∩ wits b' = {}" if "expandss b' [φ]" for b' using no_wits_if_not_literal_if_wf_branch (*‹wf_branch ?b ⟹ ∀φ∈set ?b. ¬ is_literal φ ⟶ vars φ ∩ wits ?b = {}›*) that (*‹expandss b' [φ]›*) unfolding wf_branch_def (*goal: ‹∀φ::'a pset_atom fm∈set (b'::'a pset_atom fm list). ¬ is_literal φ ⟶ vars φ ∩ wits b' = {}›*) by blast have no_new_subterms: "no_new_subterms b'" if "expandss b' [φ]" for b' using no_new_subterms_if_wf_branch (*‹wf_branch ?b ⟹ no_new_subterms ?b›*) that (*‹expandss (b'::'a::type pset_atom fm list) [φ::'a::type pset_atom fm]›*) unfolding wf_branch_def (*goal: ‹no_new_subterms (b'::'a::type pset_atom fm list)›*) by blast have "AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b" using ‹expandss b [φ]› (*‹expandss b [φ]›*) assms(2) (*‹(c::'a) ∈ pwits (b::'a pset_atom fm list)›*) proof (induction b "[φ]" arbitrary: c t rule: expandss.induct) (*goals: 1. ‹⋀c t. c ∈ pwits [φ] ⟹ AT (Var c =⇩s t) ∉ set [φ] ∧ AT (t =⇩s Var c) ∉ set [φ] ∧ AT (t ∈⇩s Var c) ∉ set [φ]› 2. ‹⋀b3 b2 c t. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 [φ]; ⋀c t. c ∈ pwits b2 ⟹ AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2; c ∈ pwits (b3 @ b2)⟧ ⟹ AT (Var c =⇩s t) ∉ set (b3 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b3 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b3 @ b2)› 3. ‹⋀bs b2 b3 c t. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 [φ]; ⋀c t. c ∈ pwits b2 ⟹ AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2; c ∈ pwits (b3 @ b2)⟧ ⟹ AT (Var c =⇩s t) ∉ set (b3 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b3 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b3 @ b2)›*) case 1 (*‹c ∈ pwits [φ]›*) then show "?case" (*goal: ‹AT (Var c =⇩s t) ∉ set [φ] ∧ AT (t =⇩s Var c) ∉ set [φ] ∧ AT (t ∈⇩s Var c) ∉ set [φ]›*) by simp next (*goals: 1. ‹⋀(b3::'a::type pset_atom fm list) (b2::'a::type pset_atom fm list) (c::'a::type) t::'a::type pset_term. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 [φ::'a::type pset_atom fm]; ⋀(c::'a::type) t::'a::type pset_term. c ∈ pwits b2 ⟹ AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2; c ∈ pwits (b3 @ b2)⟧ ⟹ AT (Var c =⇩s t) ∉ set (b3 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b3 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b3 @ b2)› 2. ‹⋀(bs::'a::type pset_atom fm list set) (b2::'a::type pset_atom fm list) (b3::'a::type pset_atom fm list) (c::'a::type) t::'a::type pset_term. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 [φ::'a::type pset_atom fm]; ⋀(c::'a::type) t::'a::type pset_term. c ∈ pwits b2 ⟹ AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2; c ∈ pwits (b3 @ b2)⟧ ⟹ AT (Var c =⇩s t) ∉ set (b3 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b3 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b3 @ b2)›*) case (2 b1 b2) (*‹lexpands (b1::'a pset_atom fm list) (b2::'a pset_atom fm list)› ‹set b2 ⊂ set (b1 @ b2)› ‹expandss (b2::'a pset_atom fm list) [φ::'a pset_atom fm]› ‹?c ∈ pwits b2 ⟹ AT (Var ?c =⇩s ?t) ∉ set b2 ∧ AT (?t =⇩s Var ?c) ∉ set b2 ∧ AT (?t ∈⇩s Var ?c) ∉ set b2› ‹c ∈ pwits (b1 @ b2)›*) note lemma_2_lexpands[OF this ( 1 ) _ no_new_subterms [ OF this ( 3 ) ] no_wits_if_not_literal [ OF this ( 3 ) ]] (*‹⟦b2 ≠ []; ∀c∈pwits b2. ∀t∈wits_subterms b2. AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2⟧ ⟹ ∀c∈pwits (b1 @ b2). ∀t∈wits_subterms (b1 @ b2). AT (Var c =⇩s t) ∉ set (b1 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b1 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b1 @ b2)›*) with "2" (*‹lexpands b1 b2› ‹set (b2::'a pset_atom fm list) ⊂ set ((b1::'a pset_atom fm list) @ b2)› ‹expandss b2 [φ]› ‹?c ∈ pwits b2 ⟹ AT (Var ?c =⇩s ?t) ∉ set b2 ∧ AT (?t =⇩s Var ?c) ∉ set b2 ∧ AT (?t ∈⇩s Var ?c) ∉ set b2› ‹c ∈ pwits (b1 @ b2)›*) show "?case" (*goal: ‹AT (Var c =⇩s t) ∉ set (b1 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b1 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b1 @ b2)›*) using wf_branch_def (*‹wf_branch ?b ≡ ∃φ. expandss ?b [φ]›*) wf_branch_not_Nil (*‹wf_branch ?b ⟹ ?b ≠ []›*) subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) by (metis AT_eq_subterms_branchD( (*‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) 1,2) AT_mem_subterms_branchD( (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b›*) 1) expandss.intros( (*‹⟦lexpands ?b3.0 ?b2.0; set ?b2.0 ⊂ set (?b3.0 @ ?b2.0); expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) 2)) next (*goal: ‹⋀bs b2 b3 c t. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 [φ]; ⋀c t. c ∈ pwits b2 ⟹ AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2; c ∈ pwits (b3 @ b2)⟧ ⟹ AT (Var c =⇩s t) ∉ set (b3 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b3 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b3 @ b2)›*) case (3 bs b2 b1) (*‹bexpands bs b2› ‹b1 ∈ bs› ‹expandss b2 [φ]› ‹?c ∈ pwits b2 ⟹ AT (Var ?c =⇩s ?t) ∉ set b2 ∧ AT (?t =⇩s Var ?c) ∉ set b2 ∧ AT (?t ∈⇩s Var ?c) ∉ set b2› ‹c ∈ pwits (b1 @ b2)›*) note lemma_2_bexpands[OF "3" ( 1 ) _ _ no_new_subterms [ OF "3" ( 3 ) ] no_wits_if_not_literal [ OF "3" ( 3 ) ]] (*‹⟦(?b'::'a::type pset_atom fm list) ∈ (bs::'a::type pset_atom fm list set); (b2::'a::type pset_atom fm list) ≠ []; ∀c::'a::type∈pwits b2. ∀t::'a::type pset_term∈wits_subterms b2. AT (Var c =⇩s t) ∉ set b2 ∧ AT (t =⇩s Var c) ∉ set b2 ∧ AT (t ∈⇩s Var c) ∉ set b2⟧ ⟹ ∀c::'a::type∈pwits (?b' @ b2). ∀t::'a::type pset_term∈wits_subterms (?b' @ b2). AT (Var c =⇩s t) ∉ set (?b' @ b2) ∧ AT (t =⇩s Var c) ∉ set (?b' @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (?b' @ b2)›*) with "3" (*‹bexpands (bs::'a::type pset_atom fm list set) (b2::'a::type pset_atom fm list)› ‹(b1::'a pset_atom fm list) ∈ (bs::'a pset_atom fm list set)› ‹expandss b2 [φ]› ‹?c ∈ pwits b2 ⟹ AT (Var ?c =⇩s ?t) ∉ set b2 ∧ AT (?t =⇩s Var ?c) ∉ set b2 ∧ AT (?t ∈⇩s Var ?c) ∉ set b2› ‹(c::'a) ∈ pwits ((b1::'a pset_atom fm list) @ (b2::'a pset_atom fm list))›*) show "?case" (*goal: ‹AT (Var c =⇩s t) ∉ set (b1 @ b2) ∧ AT (t =⇩s Var c) ∉ set (b1 @ b2) ∧ AT (t ∈⇩s Var c) ∉ set (b1 @ b2)›*) using wf_branch_def (*‹wf_branch ?b ≡ ∃φ. expandss ?b [φ]›*) wf_branch_not_Nil (*‹wf_branch ?b ⟹ ?b ≠ []›*) subterms_branch_eq_if_wf_branch (*‹wf_branch (?b::?'a pset_atom fm list) ⟹ subterms ?b = wits_subterms ?b›*) by (metis AT_eq_subterms_branchD( (*‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) 1,2) AT_mem_subterms_branchD( (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b›*) 1) expandss.intros( (*‹⟦bexpands ?bs ?b2.0; ?b3.0 ∈ ?bs; expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) 3)) qed then show "AT (Var c =⇩s t) ∉ set b" "AT (t =⇩s Var c) ∉ set b" "AT (t ∈⇩s Var c) ∉ set b" apply - (*goals: 1. ‹AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b ⟹ AT (Var c =⇩s t) ∉ set b› 2. ‹AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b ⟹ AT (t =⇩s Var c) ∉ set b› 3. ‹AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b ∧ AT (t ∈⇩s Var c) ∉ set b ⟹ AT (t ∈⇩s Var c) ∉ set b› discuss goal 1*) apply ((safe)[1]) (*discuss goal 2*) apply ((safe)[1]) (*discuss goal 3*) apply ((safe)[1]) (*proven 3 subgoals*) . qed subsubsection ‹Urelements› definition "urelems b ≡ {x ∈ subterms b. ∃v. ∀φ ∈ set b. urelem' v φ x}" lemma finite_urelems: "finite (urelems b)" proof (-) (*goal: ‹finite (urelems b)›*) have "urelems b ⊆ subterms b" unfolding urelems_def urelem_def (*goal: ‹{x::'a pset_term ∈ subterms (b::'a pset_atom fm list). ∃v::'a ⇒ nat. ∀φ::'a pset_atom fm∈set b. v ⊢ φ ∧ v ⊢ x : (0::nat)} ⊆ subterms b›*) by blast with finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) finite_subterms_branch (*‹finite (subterms ?b)›*) show "?thesis" (*goal: ‹finite (urelems b)›*) by blast qed lemma urelems_subs_subterms: "urelems b ⊆ subterms b" unfolding urelems_def (*goal: ‹{x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0} ⊆ subterms b›*) by blast lemma is_Var_if_mem_urelems: "t ∈ urelems b ⟹ is_Var t" unfolding urelems_def subterms_branch_def (*goal: ‹t ∈ {x ∈ ⋃ (subterms ` set b). ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0} ⟹ is_Var t›*) using is_Var_if_urelem' (*‹?v ⊢ ?φ ∧ ?v ⊢ ?t : 0 ⟹ is_Var ?t›*) by auto lemma urelems_subs_vars: "urelems b ⊆ Var ` vars b" proof (standard) (*goal: ‹⋀x::'a::type pset_term. x ∈ urelems (b::'a::type pset_atom fm list) ⟹ x ∈ Var ` vars b›*) fix t assume "t ∈ urelems b" (*‹(t::'a pset_term) ∈ urelems (b::'a pset_atom fm list)›*) with urelems_subs_subterms (*‹urelems ?b ⊆ subterms ?b›*) have "t ∈ subterms b" by blast moreover note is_Var_if_mem_urelems[OF ‹t ∈ urelems b›] (*‹is_Var t›*) then obtain x where "t = Var x" (*goal: ‹(⋀x. t = Var x ⟹ thesis) ⟹ thesis›*) by (meson is_Var_def (*‹is_Var (?pset_term::?'a pset_term) = (∃x2::?'a. ?pset_term = Var x2)›*)) ultimately have "x ∈ vars b" unfolding Un_vars_term_subterms_branch_eq_vars_branch[symmetric] (*goal: ‹(x::'a::type) ∈ ⋃ (vars ` subterms (b::'a::type pset_atom fm list))›*) by force with ‹t = Var x› (*‹t = Var x›*) show "t ∈ Var ` vars b" by blast qed lemma types_term_inf: includes Set_member_no_ascii_notation assumes "v1 ⊢ t : l1" "v2 ⊢ t : l2" shows "inf v1 v2 ⊢ t : inf l1 l2" using assms (*‹v1 ⊢ t : l1› ‹(v2::'a ⇒ nat) ⊢ (t::'a pset_term) : (l2::nat)›*) apply (induction t arbitrary: l1 l2) (*goals: 1. ‹⋀x l1 l2. ⟦v1 ⊢ ∅ x : l1; v2 ⊢ ∅ x : l2⟧ ⟹ inf v1 v2 ⊢ ∅ x : inf l1 l2› 2. ‹⋀x l1 l2. ⟦v1 ⊢ Var x : l1; v2 ⊢ Var x : l2⟧ ⟹ inf v1 v2 ⊢ Var x : inf l1 l2› 3. ‹⋀t1 t2 l1 l2. ⟦⋀l1 l2. ⟦v1 ⊢ t1 : l1; v2 ⊢ t1 : l2⟧ ⟹ inf v1 v2 ⊢ t1 : inf l1 l2; ⋀l1 l2. ⟦v1 ⊢ t2 : l1; v2 ⊢ t2 : l2⟧ ⟹ inf v1 v2 ⊢ t2 : inf l1 l2; v1 ⊢ t1 ⊔⇩s t2 : l1; v2 ⊢ t1 ⊔⇩s t2 : l2⟧ ⟹ inf v1 v2 ⊢ t1 ⊔⇩s t2 : inf l1 l2› 4. ‹⋀t1 t2 l1 l2. ⟦⋀l1 l2. ⟦v1 ⊢ t1 : l1; v2 ⊢ t1 : l2⟧ ⟹ inf v1 v2 ⊢ t1 : inf l1 l2; ⋀l1 l2. ⟦v1 ⊢ t2 : l1; v2 ⊢ t2 : l2⟧ ⟹ inf v1 v2 ⊢ t2 : inf l1 l2; v1 ⊢ t1 ⊓⇩s t2 : l1; v2 ⊢ t1 ⊓⇩s t2 : l2⟧ ⟹ inf v1 v2 ⊢ t1 ⊓⇩s t2 : inf l1 l2› 5. ‹⋀t1 t2 l1 l2. ⟦⋀l1 l2. ⟦v1 ⊢ t1 : l1; v2 ⊢ t1 : l2⟧ ⟹ inf v1 v2 ⊢ t1 : inf l1 l2; ⋀l1 l2. ⟦v1 ⊢ t2 : l1; v2 ⊢ t2 : l2⟧ ⟹ inf v1 v2 ⊢ t2 : inf l1 l2; v1 ⊢ t1 -⇩s t2 : l1; v2 ⊢ t1 -⇩s t2 : l2⟧ ⟹ inf v1 v2 ⊢ t1 -⇩s t2 : inf l1 l2› 6. ‹⋀t l1 l2. ⟦⋀l1 l2. ⟦v1 ⊢ t : l1; v2 ⊢ t : l2⟧ ⟹ inf v1 v2 ⊢ t : inf l1 l2; v1 ⊢ Single t : l1; v2 ⊢ Single t : l2⟧ ⟹ inf v1 v2 ⊢ Single t : inf l1 l2› discuss goal 1*) apply ((auto simp: inf_min (*‹inf = min›*) elim!: types_pset_term_cases (*‹⟦?v ⊢ ∅ ?n : ?l; ?l = Suc ?n ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Single ?t : ?l; ⋀l. ⟦?l = Suc l; ?v ⊢ ?t : l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊔⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊓⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s -⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P›*) intro: types_pset_term_intros' (*‹?l = Suc ?n ⟹ ?v ⊢ ∅ ?n : ?l› ‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l› ‹⟦?l ≠ 0; ?v ⊢ ?t : nat.pred ?l⟧ ⟹ ?v ⊢ Single ?t : ?l›*) types_pset_term.intros( (*‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊔⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊓⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s -⇩s ?t : ?l›*) 4-))[1]) (*discuss goal 2*) apply ((auto simp: inf_min (*‹inf = min›*) elim!: types_pset_term_cases (*‹⟦?v ⊢ ∅ ?n : ?l; ?l = Suc ?n ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Single ?t : ?l; ⋀l. ⟦?l = Suc l; ?v ⊢ ?t : l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊔⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊓⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s -⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P›*) intro: types_pset_term_intros' (*‹?l = Suc ?n ⟹ ?v ⊢ ∅ ?n : ?l› ‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l› ‹⟦?l ≠ 0; ?v ⊢ ?t : nat.pred ?l⟧ ⟹ ?v ⊢ Single ?t : ?l›*) types_pset_term.intros( (*‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊔⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊓⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s -⇩s ?t : ?l›*) 4-))[1]) (*discuss goal 3*) apply ((auto simp: inf_min (*‹inf = min›*) elim!: types_pset_term_cases (*‹⟦?v ⊢ ∅ ?n : ?l; ?l = Suc ?n ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Single ?t : ?l; ⋀l. ⟦?l = Suc l; ?v ⊢ ?t : l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊔⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊓⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s -⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P›*) intro: types_pset_term_intros' (*‹?l = Suc ?n ⟹ ?v ⊢ ∅ ?n : ?l› ‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l› ‹⟦?l ≠ 0; ?v ⊢ ?t : nat.pred ?l⟧ ⟹ ?v ⊢ Single ?t : ?l›*) types_pset_term.intros( (*‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊔⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊓⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s -⇩s ?t : ?l›*) 4-))[1]) (*discuss goal 4*) apply ((auto simp: inf_min (*‹inf = min›*) elim!: types_pset_term_cases (*‹⟦?v ⊢ ∅ ?n : ?l; ?l = Suc ?n ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Single ?t : ?l; ⋀l. ⟦?l = Suc l; ?v ⊢ ?t : l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊔⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊓⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s -⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P›*) intro: types_pset_term_intros' (*‹?l = Suc ?n ⟹ ?v ⊢ ∅ ?n : ?l› ‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l› ‹⟦?l ≠ 0; ?v ⊢ ?t : nat.pred ?l⟧ ⟹ ?v ⊢ Single ?t : ?l›*) types_pset_term.intros( (*‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊔⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊓⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s -⇩s ?t : ?l›*) 4-))[1]) (*discuss goal 5*) apply ((auto simp: inf_min (*‹inf = min›*) elim!: types_pset_term_cases (*‹⟦?v ⊢ ∅ ?n : ?l; ?l = Suc ?n ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Single ?t : ?l; ⋀l. ⟦?l = Suc l; ?v ⊢ ?t : l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊔⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊓⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s -⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P›*) intro: types_pset_term_intros' (*‹?l = Suc ?n ⟹ ?v ⊢ ∅ ?n : ?l› ‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l› ‹⟦?l ≠ 0; ?v ⊢ ?t : nat.pred ?l⟧ ⟹ ?v ⊢ Single ?t : ?l›*) types_pset_term.intros( (*‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊔⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊓⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s -⇩s ?t : ?l›*) 4-))[1]) (*discuss goal 6*) apply ((auto simp: inf_min (*‹inf = min›*) elim!: types_pset_term_cases (*‹⟦?v ⊢ ∅ ?n : ?l; ?l = Suc ?n ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ Single ?t : ?l; ⋀l. ⟦?l = Suc l; ?v ⊢ ?t : l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊔⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s ⊓⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P› ‹⟦?v ⊢ ?s -⇩s ?t : ?l; ⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; 0 < ?l⟧ ⟹ ?P⟧ ⟹ ?P›*) intro: types_pset_term_intros' (*‹?l = Suc ?n ⟹ ?v ⊢ ∅ ?n : ?l› ‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l› ‹⟦?l ≠ 0; ?v ⊢ ?t : nat.pred ?l⟧ ⟹ ?v ⊢ Single ?t : ?l›*) types_pset_term.intros( (*‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊔⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s ⊓⇩s ?t : ?l› ‹⟦?v ⊢ ?s : ?l; ?v ⊢ ?t : ?l; ?l ≠ 0⟧ ⟹ ?v ⊢ ?s -⇩s ?t : ?l›*) 4-))[1]) (*proven 6 subgoals*) . lemma types_pset_atom_inf: fixes a :: "'a pset_atom" assumes "v1 ⊢ a" "v2 ⊢ a" shows "inf v1 v2 ⊢ a" using assms (*‹v1 ⊢ a› ‹v2 ⊢ a›*) apply (auto simp: types_pset_atom.simps (*‹(?a1.0 ⊢ ?a2.0) = ((∃v s l t. ?a1.0 = v ∧ ?a2.0 = s =⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : l) ∨ (∃v s l t. ?a1.0 = v ∧ ?a2.0 = s ∈⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : Suc l))›*)) (*goals: 1. ‹⋀l sa la ta. ⟦a = sa =⇩s ta; v1 ⊢ sa : l; v1 ⊢ ta : l; v2 ⊢ sa : la; v2 ⊢ ta : la⟧ ⟹ ∃l. inf v1 v2 ⊢ sa : l ∧ inf v1 v2 ⊢ ta : l› 2. ‹⋀l sa la ta. ⟦∀l. inf v1 v2 ⊢ sa : l ⟶ ¬ inf v1 v2 ⊢ ta : Suc l; a = sa ∈⇩s ta; v1 ⊢ sa : l; v1 ⊢ ta : Suc l; v2 ⊢ sa : la; v2 ⊢ ta : Suc la⟧ ⟹ False› discuss goal 1*) apply (metis inf_min (*‹inf = min›*) min_Suc_Suc (*‹min (Suc (?m::nat)) (Suc (?n::nat)) = Suc (min ?m ?n)›*) types_term_inf (*‹⟦(?v1.0::?'a ⇒ nat) ⊢ (?t::?'a pset_term) : (?l1.0::nat); (?v2.0::?'a ⇒ nat) ⊢ ?t : (?l2.0::nat)⟧ ⟹ inf ?v1.0 ?v2.0 ⊢ ?t : inf ?l1.0 ?l2.0›*)) (*discuss goal 2*) apply (metis inf_min (*‹inf = min›*) min_Suc_Suc (*‹min (Suc ?m) (Suc ?n) = Suc (min ?m ?n)›*) types_term_inf (*‹⟦?v1.0 ⊢ ?t : ?l1.0; ?v2.0 ⊢ ?t : ?l2.0⟧ ⟹ inf ?v1.0 ?v2.0 ⊢ ?t : inf ?l1.0 ?l2.0›*)) (*proven 2 subgoals*) . lemma types_pset_fm_inf: fixes φ :: "'a pset_fm" assumes "v1 ⊢ φ" "v2 ⊢ φ" shows "inf v1 v2 ⊢ φ" using assms (*‹v1 ⊢ φ› ‹v2 ⊢ φ›*) types_pset_atom_inf (*‹⟦?v1.0 ⊢ ?a; ?v2.0 ⊢ ?a⟧ ⟹ inf ?v1.0 ?v2.0 ⊢ ?a›*) unfolding types_pset_fm_def (*goal: ‹∀a∈atoms φ. inf v1 v2 ⊢ a›*) by blast lemma types_urelems: includes Set_member_no_ascii_notation fixes b :: "'a branch" assumes "wf_branch b" "v ⊢ last b" obtains v' where "∀φ ∈ set b. v' ⊢ φ" "∀u ∈ urelems b. v' ⊢ u : 0" proof (-) (*goal: ‹(⋀v'. ⟦∀φ∈set b. v' ⊢ φ; ∀u∈urelems b. v' ⊢ u : 0⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹wf_branch b› ‹(v::'a::type ⇒ nat) ⊢ last (b::'a::type pset_atom fm list)›*) have "expandss b [last b]" unfolding wf_branch_def (*goal: ‹expandss (b::'a pset_atom fm list) [last b]›*) by force define V where "V ≡ {v. (∀φ ∈ set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}" have "V ≠ {}" proof (-) (*goal: ‹V ≠ {}›*) from types_expandss[OF ‹expandss b [last b]›, simplified] (*‹⟦?v ⊢ last b; ⋀v'. ⟦∀x∈vars [last b]. v' x = ?v x; ∀x∈set b. v' ⊢ x⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹v ⊢ last b› (*‹v ⊢ last b›*) obtain v where v: "∀φ ∈ set b. v ⊢ φ" (*goal: ‹(⋀v. ∀φ∈set b. v ⊢ φ ⟹ thesis) ⟹ thesis›*) unfolding vars_branch_simps (*goal: ‹(⋀v. ∀φ∈set b. v ⊢ φ ⟹ thesis) ⟹ thesis›*) by metis define v' where "v' ≡ λx. if x ∈ vars b then v x else 0" have "v' ⊢ φ ⟷ v ⊢ φ" if "φ ∈ set b" for φ :: "'a pset_fm" apply (intro types_pset_fm_if_on_vars_eq (*‹∀x∈vars ?φ. ?v' x = ?v x ⟹ (?v' ⊢ ?φ) = (?v ⊢ ?φ)›*)) (*goal: ‹(v' ⊢ φ) = (v ⊢ φ)›*) using that (*‹φ ∈ set b›*) vars_fm_vars_branchI (*‹⟦(?φ::?'a::type pset_atom fm) ∈ set (?b::?'a::type pset_atom fm list); (?x::?'a::type) ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*) unfolding v'_def (*goal: ‹∀x∈vars φ. (if x ∈ vars b then v x else 0) = v x›*) by metis with v (*‹∀φ∈set b. v ⊢ φ›*) have "∀φ ∈ set b. v' ⊢ φ" by blast then have "v' ∈ V" unfolding V_def v'_def (*goal: ‹(λx. if x ∈ vars b then v x else 0) ∈ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*) by simp then show "?thesis" (*goal: ‹V ≠ {}›*) by blast qed define m_x where "m_x ≡ λx. ARG_MIN (λv. v x) v. v ∈ V" with ‹V ≠ {}› (*‹V ≠ {}›*) have m_x: "∀v ∈ V. m_x x x ≤ v x" "m_x x ∈ V" for x using arg_min_nat_le (*‹?P ?x ⟹ ?m (arg_min ?m ?P) ≤ ?m ?x›*) arg_min_natI (*‹(?P::?'a ⇒ bool) (?k::?'a) ⟹ ?P (arg_min (?m::?'a ⇒ nat) ?P)›*) by ((metis ex_in_conv (*‹(∃x. x ∈ ?A) = (?A ≠ {})›*))+) define M where "M ≡ Finite_Set.fold inf (SOME v. v ∈ V) (m_x ` vars b)" note finite_imageI[where ?h = m_x, OF finite_vars_branch [ of b ]] (*‹finite ((m_x::'a::type ⇒ 'a::type ⇒ nat) ` vars (b::'a::type pset_atom fm list))›*) note M_inf_eq = Inf_fin.eq_fold[symmetric, OF this, of "SOME v. v ∈ V"] (*‹Finite_Set.fold inf (SOME v. v ∈ V) (m_x ` vars b) = ⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` vars b)›*) have M_leq: "M x ≤ v x" if "x ∈ vars b" "v ∈ V" for x and v proof (-) (*goal: ‹M x ≤ v x›*) from that (*‹x ∈ vars b› ‹v ∈ V›*) have "m_x x ∈ m_x ` vars b" by blast then have "M = inf (m_x x) (⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` vars b))" unfolding M_def M_inf_eq (*goal: ‹⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` vars b) = inf (m_x x) (⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` vars b))›*) by (simp add: Inf_fin.in_idem (*‹⟦finite ?A; ?x ∈ ?A⟧ ⟹ inf ?x (⨅⇩f⇩i⇩n ?A) = ⨅⇩f⇩i⇩n ?A›*) finite_vars_branch (*‹finite (vars ?b)›*)) with m_x (*‹∀v∈V. m_x ?x ?x ≤ v ?x› ‹(m_x::'a ⇒ 'a ⇒ nat) (?x::'a) ∈ (V::('a ⇒ nat) set)›*) that (*‹x ∈ vars b› ‹v ∈ V›*) show "?thesis" (*goal: ‹M x ≤ v x›*) by (simp add: inf.coboundedI1 (*‹?a ≤ ?c ⟹ inf ?a ?b ≤ ?c›*)) qed moreover have "M ∈ V" unfolding M_def M_inf_eq (*goal: ‹⨅⇩f⇩i⇩n insert (SOME v::'a ⇒ nat. v ∈ (V::('a ⇒ nat) set)) ((m_x::'a ⇒ 'a ⇒ nat) ` vars (b::'a pset_atom fm list)) ∈ V›*) using finite_vars_branch[of b] (*‹finite (vars b)›*) proof (induction rule: finite_induct (*‹⟦finite ?F; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?F›*)) (*goals: 1. ‹⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` {}) ∈ V› 2. ‹⋀x F. ⟦finite F; x ∉ F; ⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` F) ∈ V⟧ ⟹ ⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` insert x F) ∈ V›*) case empty (*no hyothesis introduced yet*) with ‹V ≠ {}› (*‹(V::('a ⇒ nat) set) ≠ {}›*) show "?case" (*goal: ‹⨅⇩f⇩i⇩n insert (SOME v::'a ⇒ nat. v ∈ (V::('a ⇒ nat) set)) ((m_x::'a ⇒ 'a ⇒ nat) ` {}) ∈ V›*) by (simp add: some_in_eq (*‹((SOME x::?'a. x ∈ (?A::?'a set)) ∈ ?A) = (?A ≠ {})›*)) next (*goal: ‹⋀x F. ⟦finite F; x ∉ F; ⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` F) ∈ V⟧ ⟹ ⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` insert x F) ∈ V›*) case (insert x F) (*‹finite (F::'a set)› ‹x ∉ F› ‹⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` F) ∈ V›*) then have M'_eq: "⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` insert x F) = inf (m_x x) (⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` F))" (is "_ = ?M'") by (simp add: insert_commute (*‹insert (?x::?'a) (insert (?y::?'a) (?A::?'a set)) = insert ?y (insert ?x ?A)›*)) from types_pset_fm_inf (*‹⟦?v1.0 ⊢ ?φ; ?v2.0 ⊢ ?φ⟧ ⟹ inf ?v1.0 ?v2.0 ⊢ ?φ›*) insert (*‹finite (F::'a set)› ‹x ∉ F› ‹⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` F) ∈ V›*) have "∀φ ∈ set b. ?M' ⊢ φ" using V_def (*‹V ≡ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*) m_x(2) (*‹m_x ?x ∈ V›*) by blast moreover have "(inf w v) x = 0" if "x ∉ vars b" "w ∈ V" "v ∈ V" for w and v using that (*‹x ∉ vars b› ‹(w::'a ⇒ nat) ∈ (V::('a ⇒ nat) set)› ‹v ∈ V›*) by (simp add: V_def (*‹V ≡ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*)) with insert.IH (*‹⨅⇩f⇩i⇩n insert (SOME v::'a::type ⇒ nat. v ∈ (V::('a::type ⇒ nat) set)) ((m_x::'a::type ⇒ 'a::type ⇒ nat) ` (F::'a::type set)) ∈ V›*) m_x(2) (*‹m_x ?x ∈ V›*) have "∀x. x ∉ vars b ⟶ ?M' x = 0" by (simp add: V_def (*‹V ≡ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*)) ultimately have "?M' ∈ V" using V_def (*‹V ≡ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*) by blast with M'_eq (*‹⨅⇩f⇩i⇩n insert (SOME v::'a::type ⇒ nat. v ∈ (V::('a::type ⇒ nat) set)) ((m_x::'a::type ⇒ 'a::type ⇒ nat) ` insert (x::'a::type) (F::'a::type set)) = inf (m_x x) (⨅⇩f⇩i⇩n insert (SOME v::'a::type ⇒ nat. v ∈ V) (m_x ` F))›*) show "?case" (*goal: ‹⨅⇩f⇩i⇩n insert (SOME v. v ∈ V) (m_x ` insert x F) ∈ V›*) by metis qed moreover have "M ⊢ u : 0" if "u ∈ urelems b" for u proof (-) (*goal: ‹M ⊢ u : 0›*) from that (*‹(u::'a pset_term) ∈ urelems (b::'a pset_atom fm list)›*) obtain v where v: "∀φ ∈ set b. urelem' v φ u" (*goal: ‹(⋀v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ u : 0 ⟹ thesis) ⟹ thesis›*) unfolding urelems_def (*goal: ‹(⋀v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ u : 0 ⟹ thesis) ⟹ thesis›*) by blast define v' where "v' ≡ λx. if x ∈ vars b then v x else 0" have "v' ⊢ φ ⟷ v ⊢ φ" if "φ ∈ set b" for φ :: "'a pset_fm" apply (intro types_pset_fm_if_on_vars_eq (*‹∀x∈vars ?φ. ?v' x = ?v x ⟹ (?v' ⊢ ?φ) = (?v ⊢ ?φ)›*)) (*goal: ‹(v' ⊢ φ) = (v ⊢ φ)›*) using that (*‹φ ∈ set b›*) vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*) unfolding v'_def (*goal: ‹∀x∈vars φ. (if x ∈ vars b then v x else 0) = v x›*) by metis with v (*‹∀φ∈set b. v ⊢ φ ∧ v ⊢ u : 0›*) have "∀φ ∈ set b. v' ⊢ φ" by blast then have "v' ∈ V" unfolding V_def v'_def (*goal: ‹(λx. if x ∈ vars b then v x else 0) ∈ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*) by auto moreover obtain uv where uv: "u = Var uv" (*goal: ‹(⋀uv. u = Var uv ⟹ thesis) ⟹ thesis›*) using v (*‹∀φ∈set b. v ⊢ φ ∧ v ⊢ u : 0›*) is_Var_if_urelem' (*‹?v ⊢ ?φ ∧ ?v ⊢ ?t : 0 ⟹ is_Var ?t›*) wf_branch_not_Nil[OF ‹wf_branch b›] (*‹b ≠ []›*) by (metis is_Var_def (*‹is_Var ?pset_term = (∃x2. ?pset_term = Var x2)›*) last_in_set (*‹?as ≠ [] ⟹ last ?as ∈ set ?as›*)) then have "v' ⊢ u : 0" using v (*‹∀φ∈set b. v ⊢ φ ∧ v ⊢ u : 0›*) wf_branch_not_Nil[OF ‹wf_branch b›, THEN last_in_set] (*‹last b ∈ set b›*) unfolding v'_def (*goal: ‹(λx. if x ∈ vars b then v x else 0) ⊢ u : 0›*) by (auto elim!: types_pset_term_cases( (*‹⟦?v ⊢ Var ?x : ?l; ?l = ?v ?x ⟹ ?P⟧ ⟹ ?P›*) 2) intro!: types_pset_term_intros'( (*‹?l = ?v ?x ⟹ ?v ⊢ Var ?x : ?l›*) 2)) ultimately show "M ⊢ u : 0" using M_leq[where ?v = v'] (*‹⟦?x ∈ vars b; v' ∈ V⟧ ⟹ M ?x ≤ v' ?x›*) ‹M ∈ V›[unfolded V_def] (*‹M ∈ {v. (∀φ∈set b. v ⊢ φ) ∧ (∀x. x ∉ vars b ⟶ v x = 0)}›*) unfolding uv (*goal: ‹M ⊢ Var uv : 0›*) by (fastforce elim!: types_pset_term_cases( (*‹⟦(?v::?'a ⇒ nat) ⊢ Var (?x::?'a) : (?l::nat); ?l = ?v ?x ⟹ ?P::bool⟧ ⟹ ?P›*) 2) intro!: types_pset_term_intros'( (*‹(?l::nat) = (?v::?'a ⇒ nat) (?x::?'a) ⟹ ?v ⊢ Var ?x : ?l›*) 2)) qed ultimately show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦∀φ::'a pset_atom fm∈set (b::'a pset_atom fm list). (?v'::'a ⇒ nat) ⊢ φ; ∀u::'a pset_term∈urelems b. ?v' ⊢ u : (0::nat)⟧ ⟹ thesis::bool›*) unfolding V_def (*goal: ‹thesis›*) by auto qed lemma mem_urelems_if_urelem_last: assumes "wf_branch b" assumes "urelem (last b) x" "x ∈ subterms (last b)" shows "x ∈ urelems b" proof (-) (*goal: ‹x ∈ urelems b›*) from assms (*‹wf_branch b› ‹urelem (last b) x› ‹x ∈ subterms (last b)›*) have "x ∈ subterms b" unfolding subterms_branch_def (*goal: ‹x ∈ ⋃ (subterms ` set b)›*) by auto moreover note urelem_invar_if_wf_branch[OF assms] (*‹∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0›*) ultimately show "?thesis" (*goal: ‹(x::'a pset_term) ∈ urelems (b::'a pset_atom fm list)›*) unfolding urelems_def urelem_def (*goal: ‹x ∈ {x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0}›*) by blast qed lemma not_urelem_comps_if_compound: assumes "f t1 t2 ∈ subterms b" "f ∈ {(⊓⇩s), (⊔⇩s), (-⇩s)}" shows "t1 ∉ urelems b" "t2 ∉ urelems b" proof (-) (*goals: 1. ‹t1 ∉ urelems b› 2. ‹t2 ∉ urelems b›*) from assms (*‹(f::'a pset_term ⇒ 'a pset_term ⇒ 'a pset_term) (t1::'a pset_term) (t2::'a pset_term) ∈ subterms (b::'a pset_atom fm list)› ‹f ∈ {(⊓⇩s), (⊔⇩s), (-⇩s)}›*) obtain φ where "φ ∈ set b" "f t1 t2 ∈ subterms φ" (*goal: ‹(⋀φ. ⟦φ ∈ set b; f t1 t2 ∈ subterms φ⟧ ⟹ thesis) ⟹ thesis›*) unfolding subterms_branch_def (*goal: ‹(⋀φ. ⟦φ ∈ set b; f t1 t2 ∈ subterms φ⟧ ⟹ thesis) ⟹ thesis›*) by auto note not_urelem_comps_if_compound[of f t1 t2, OF this ( 2 ) assms ( 2 )] (*‹¬ urelem φ t1› ‹¬ urelem φ t2›*) with ‹φ ∈ set b› (*‹φ ∈ set b›*) show "t1 ∉ urelems b" "t2 ∉ urelems b" unfolding urelems_def urelem_def (*goals: 1. ‹t1 ∉ {x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0}› 2. ‹t2 ∉ {x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0}›*) apply - (*goals: 1. ‹⟦φ ∈ set b; ∄v. v ⊢ φ ∧ v ⊢ t1 : 0; ∄v. v ⊢ φ ∧ v ⊢ t2 : 0⟧ ⟹ t1 ∉ {x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0}› 2. ‹⟦φ ∈ set b; ∄v. v ⊢ φ ∧ v ⊢ t1 : 0; ∄v. v ⊢ φ ∧ v ⊢ t2 : 0⟧ ⟹ t2 ∉ {x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed subsubsection ‹Realization of an Open Branch› definition "base_vars b ≡ Var ` pwits b ∪ urelems b" lemma finite_base_vars: "finite (base_vars b)" unfolding base_vars_def finite_Un (*goal: ‹finite (Var ` pwits b) ∧ finite (urelems b)›*) using finite_pwits[THEN finite_imageI] (*‹finite (?h ` pwits ?b1)›*) finite_urelems (*‹finite (urelems ?b)›*) by blast lemma pwits_subs_base_vars: shows "Var ` pwits b ⊆ base_vars b" unfolding base_vars_def (*goal: ‹Var ` pwits (b::'a pset_atom fm list) ⊆ Var ` pwits b ∪ urelems b›*) by blast lemma base_vars_subs_vars: "base_vars b ⊆ Var ` vars b" unfolding base_vars_def pwits_def wits_def (*goal: ‹Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b} ∪ urelems b ⊆ Var ` vars b›*) using urelems_subs_vars (*‹urelems ?b ⊆ Var ` vars ?b›*) by blast definition subterms' :: "'a branch ⇒ 'a pset_term set" where "subterms' b ≡ subterms b - base_vars b" definition bgraph :: "'a branch ⇒ ('a pset_term, 'a pset_term × 'a pset_term) pre_digraph" where "bgraph b ≡ let vs = base_vars b ∪ subterms' b in ⦇ verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd ⦈" lemma base_vars_Un_subterms'_eq_subterms: "base_vars b ∪ subterms' b = subterms b" unfolding subterms'_def (*goal: ‹base_vars b ∪ (subterms b - base_vars b) = subterms b›*) using base_vars_subs_vars (*‹base_vars ?b ⊆ Var ` vars ?b›*) vars_branch_subs_subterms_branch (*‹Var ` vars ?b ⊆ subterms ?b›*) by fastforce lemma finite_base_vars_Un_subterms': "finite (base_vars b ∪ subterms' b)" unfolding base_vars_Un_subterms'_eq_subterms (*goal: ‹finite (subterms b)›*) using finite_subterms_branch (*‹finite (subterms ?b)›*) . lemma verts_bgraph: "verts (bgraph b) = base_vars b ∪ subterms' b" unfolding bgraph_def Let_def (*goal: ‹verts ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ = base_vars b ∪ subterms' b›*) by simp lemma verts_bgraph_eq_subterms: "verts (bgraph b) = subterms b" unfolding verts_bgraph base_vars_Un_subterms'_eq_subterms (*goal: ‹subterms b = subterms b›*) by standard lemma finite_subterms': "finite (subterms' b)" unfolding subterms'_def (*goal: ‹finite (subterms b - base_vars b)›*) using finite_base_vars (*‹finite (base_vars (?b::?'a pset_atom fm list))›*) finite_subterms_branch (*‹finite (subterms ?b)›*) by auto lemma base_vars_subterms'_disjnt: "base_vars b ∩ subterms' b = {}" unfolding subterms'_def (*goal: ‹base_vars b ∩ (subterms b - base_vars b) = {}›*) by fastforce lemma wits_subterms_eq_base_vars_Un_subterms': assumes "wf_branch b" shows "wits_subterms b = base_vars b ∪ subterms' b" unfolding subterms_branch_eq_if_wf_branch[OF assms, symmetric] subterms'_def (*goal: ‹subterms (b::'a::type pset_atom fm list) = base_vars b ∪ (subterms b - base_vars b)›*) using base_vars_subs_vars (*‹base_vars ?b ⊆ Var ` vars ?b›*) vars_branch_subs_subterms_branch (*‹Var ` vars (?b::?'a::type pset_atom fm list) ⊆ subterms ?b›*) by fastforce lemma in_subterms'_if_AT_mem_in_branch: assumes "wf_branch b" assumes "AT (s ∈⇩s t) ∈ set b" shows "s ∈ base_vars b ∪ subterms' b" and "t ∈ base_vars b ∪ subterms' b" using assms (*‹wf_branch b› ‹AT (s ∈⇩s t) ∈ set b›*) using wits_subterms_eq_base_vars_Un_subterms' (*‹wf_branch (?b::?'a pset_atom fm list) ⟹ wits_subterms ?b = base_vars ?b ∪ subterms' ?b›*) AT_mem_subterms_branchD (*‹AT ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AT ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) using subterms_branch_eq_if_wf_branch (*‹wf_branch (?b::?'a::type pset_atom fm list) ⟹ subterms ?b = wits_subterms ?b›*) apply - (*goals: 1. ‹⟦wf_branch b; AT (s ∈⇩s t) ∈ set b; ⋀b. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ s ∈ base_vars b ∪ subterms' b› 2. ‹⟦wf_branch b; AT (s ∈⇩s t) ∈ set b; ⋀b. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ t ∈ base_vars b ∪ subterms' b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma in_subterms'_if_AF_mem_in_branch: assumes "wf_branch b" assumes "AF (s ∈⇩s t) ∈ set b" shows "s ∈ base_vars b ∪ subterms' b" and "t ∈ base_vars b ∪ subterms' b" using assms (*‹wf_branch b› ‹AF ((s::'a pset_term) ∈⇩s (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)›*) using wits_subterms_eq_base_vars_Un_subterms' (*‹wf_branch ?b ⟹ wits_subterms ?b = base_vars ?b ∪ subterms' ?b›*) AF_mem_subterms_branchD (*‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) using subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) apply - (*goals: 1. ‹⟦wf_branch b; AF (s ∈⇩s t) ∈ set b; ⋀b. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ s ∈ base_vars b ∪ subterms' b› 2. ‹⟦wf_branch b; AF (s ∈⇩s t) ∈ set b; ⋀b. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ t ∈ base_vars b ∪ subterms' b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma in_subterms'_if_AT_eq_in_branch: assumes "wf_branch b" assumes "AT (s =⇩s t) ∈ set b" shows "s ∈ base_vars b ∪ subterms' b" and "t ∈ base_vars b ∪ subterms' b" using assms (*‹wf_branch b› ‹AT ((s::'a pset_term) =⇩s (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)›*) using wits_subterms_eq_base_vars_Un_subterms' (*‹wf_branch ?b ⟹ wits_subterms ?b = base_vars ?b ∪ subterms' ?b›*) AT_eq_subterms_branchD (*‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) using subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) apply - (*goals: 1. ‹⟦wf_branch b; AT (s =⇩s t) ∈ set b; ⋀b. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ s ∈ base_vars b ∪ subterms' b› 2. ‹⟦wf_branch b; AT (s =⇩s t) ∈ set b; ⋀b. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ t ∈ base_vars b ∪ subterms' b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma in_subterms'_if_AF_eq_in_branch: assumes "wf_branch b" assumes "AF (s =⇩s t) ∈ set b" shows "s ∈ base_vars b ∪ subterms' b" and "t ∈ base_vars b ∪ subterms' b" using assms (*‹wf_branch (b::'a pset_atom fm list)› ‹AF (s =⇩s t) ∈ set b›*) using wits_subterms_eq_base_vars_Un_subterms' (*‹wf_branch (?b::?'a pset_atom fm list) ⟹ wits_subterms ?b = base_vars ?b ∪ subterms' ?b›*) AF_eq_subterms_branchD (*‹AF (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) using subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) apply - (*goals: 1. ‹⟦wf_branch (b::'a::type pset_atom fm list); AF ((s::'a::type pset_term) =⇩s (t::'a::type pset_term)) ∈ set b; ⋀b::?'a12::type pset_atom fm list. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀(s::?'a14::type pset_term) (t::?'a14::type pset_term) b::?'a14::type pset_atom fm list. AF (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀(s::?'a16::type pset_term) (t::?'a16::type pset_term) b::?'a16::type pset_atom fm list. AF (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b::?'a18::type pset_atom fm list. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ s ∈ base_vars b ∪ subterms' b› 2. ‹⟦wf_branch (b::'a::type pset_atom fm list); AF ((s::'a::type pset_term) =⇩s (t::'a::type pset_term)) ∈ set b; ⋀b::?'a2::type pset_atom fm list. wf_branch b ⟹ wits_subterms b = base_vars b ∪ subterms' b; ⋀(s::?'a4::type pset_term) (t::?'a4::type pset_term) b::?'a4::type pset_atom fm list. AF (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀(s::?'a6::type pset_term) (t::?'a6::type pset_term) b::?'a6::type pset_atom fm list. AF (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b::?'a8::type pset_atom fm list. wf_branch b ⟹ subterms b = wits_subterms b⟧ ⟹ t ∈ base_vars b ∪ subterms' b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma mem_subterms_fm_last_if_mem_subterms_branch: assumes "wf_branch b" assumes "t ∈ subterms b" "¬ is_Var t" shows "t ∈ subterms (last b)" using assms (*‹wf_branch b› ‹t ∈ subterms b› ‹¬ is_Var t›*) unfolding subterms_branch_eq_if_wf_branch[OF ‹wf_branch b›] (*goal: ‹t ∈ subterms (last b)›*) unfolding subterms'_def wits_subterms_def (*goal: ‹t ∈ subterms (last b)›*) by force locale open_branch = fixes b :: "'a branch" assumes wf_branch: "wf_branch b" and bopen: "bopen b" and types: "∃v. v ⊢ last b" and infinite_vars: "infinite (UNIV :: 'a set)" begin sublocale fin_digraph_bgraph: fin_digraph "bgraph b" proof (standard) (*goals: 1. ‹⋀e. e ∈ arcs (bgraph b) ⟹ tail (bgraph b) e ∈ verts (bgraph b)› 2. ‹⋀e. e ∈ arcs (bgraph b) ⟹ head (bgraph b) e ∈ verts (bgraph b)› 3. ‹finite (verts (bgraph b))› 4. ‹finite (arcs (bgraph b))›*) show "finite (verts (bgraph b))" using finite_base_vars (*‹finite (base_vars ?b)›*) finite_subterms' (*‹finite (subterms' ?b)›*) by (auto simp: bgraph_def (*‹bgraph ?b ≡ let vs = base_vars ?b ∪ subterms' ?b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set ?b}, tail = fst, head = snd⦈›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) show "finite (arcs (bgraph b))" using [simproc add : finite_Collect] (*‹TERM _›*) by (auto simp: bgraph_def (*‹bgraph ?b ≡ let vs = base_vars ?b ∪ subterms' ?b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set ?b}, tail = fst, head = snd⦈›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) intro!: finite_vimageI (*‹⟦finite ?F; inj ?h⟧ ⟹ finite (?h -` ?F)›*)) qed (use in_subterms'_if_AT_mem_in_branch[OF wf_branch] in ‹(fastforce simp: bgraph_def Let_def)+›) (*solves the remaining goals: 1. ‹⋀e. e ∈ arcs (bgraph b) ⟹ tail (bgraph b) e ∈ verts (bgraph b)› 2. ‹⋀e. e ∈ arcs (bgraph b) ⟹ head (bgraph b) e ∈ verts (bgraph b)›*) lemma member_seq_if_cas: "fin_digraph_bgraph.cas t1 is t2 ⟹ member_seq t1 (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) is) t2" apply (induction "is" arbitrary: t1 t2) (*goals: 1. ‹⋀t1 t2. fin_digraph_bgraph.cas t1 [] t2 ⟹ member_seq t1 (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) []) t2› 2. ‹⋀a is t1 t2. ⟦⋀t1 t2. fin_digraph_bgraph.cas t1 is t2 ⟹ member_seq t1 (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) is) t2; fin_digraph_bgraph.cas t1 (a # is) t2⟧ ⟹ member_seq t1 (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) (a # is)) t2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma member_cycle_if_cycle: "fin_digraph_bgraph.cycle c ⟹ member_cycle (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) c)" unfolding pre_digraph.cycle_def (*goal: ‹∃u::'a pset_term. fin_digraph_bgraph.awalk u (c::('a pset_term × 'a pset_term) list) u ∧ distinct (tl (fin_digraph_bgraph.awalk_verts u c)) ∧ c ≠ [] ⟹ member_cycle (map (λe::'a pset_term × 'a pset_term. tail (bgraph (b::'a pset_atom fm list)) e ∈⇩s head (bgraph b) e) c)›*) apply (cases c) (*goals: 1. ‹⟦∃u. fin_digraph_bgraph.awalk u c u ∧ distinct (tl (fin_digraph_bgraph.awalk_verts u c)) ∧ c ≠ []; c = []⟧ ⟹ member_cycle (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) c)› 2. ‹⋀a list. ⟦∃u. fin_digraph_bgraph.awalk u c u ∧ distinct (tl (fin_digraph_bgraph.awalk_verts u c)) ∧ c ≠ []; c = a # list⟧ ⟹ member_cycle (map (λe. tail (bgraph b) e ∈⇩s head (bgraph b) e) c)› discuss goal 1*) apply ((auto simp: member_seq_if_cas (*‹fin_digraph_bgraph.cas (?t1.0::'a pset_term) (?is::('a pset_term × 'a pset_term) list) (?t2.0::'a pset_term) ⟹ member_seq ?t1.0 (map (λe::'a pset_term × 'a pset_term. tail (bgraph (b::'a pset_atom fm list)) e ∈⇩s head (bgraph b) e) ?is) ?t2.0›*))[1]) (*discuss goal 2*) apply ((auto simp: member_seq_if_cas (*‹fin_digraph_bgraph.cas (?t1.0::'a pset_term) (?is::('a pset_term × 'a pset_term) list) (?t2.0::'a pset_term) ⟹ member_seq ?t1.0 (map (λe::'a pset_term × 'a pset_term. tail (bgraph (b::'a pset_atom fm list)) e ∈⇩s head (bgraph b) e) ?is) ?t2.0›*))[1]) (*proven 2 subgoals*) . sublocale dag_bgraph: dag "bgraph b" proof (unfold_locales, goal_cases) (*goals: 1. ‹⋀e. e ∈ arcs (bgraph b) ⟹ tail (bgraph b) e ≠ head (bgraph b) e› 2. ‹⋀e1 e2. ⟦e1 ∈ arcs (bgraph b); e2 ∈ arcs (bgraph b); arc_to_ends (bgraph b) e1 = arc_to_ends (bgraph b) e2⟧ ⟹ e1 = e2› 3. ‹¬ Ex fin_digraph_bgraph.cycle›*) case (1 e) (*‹e ∈ arcs (bgraph b)›*) show "?case" (*goal: ‹tail (bgraph b) e ≠ head (bgraph b) e›*) proof (standard) (*goal: ‹tail (bgraph (b::'a pset_atom fm list)) (e::'a pset_term × 'a pset_term) = head (bgraph b) e ⟹ False›*) assume "tail (bgraph b) e = head (bgraph b) e" (*‹tail (bgraph (b::'a pset_atom fm list)) (e::'a pset_term × 'a pset_term) = head (bgraph b) e›*) then obtain t where "AT (t ∈⇩s t) ∈ set b" (*goal: ‹(⋀t. AT (t ∈⇩s t) ∈ set b ⟹ thesis) ⟹ thesis›*) using "1" (*‹e ∈ arcs (bgraph b)›*) unfolding bgraph_def Let_def (*goal: ‹(⋀t::'a pset_term. AT (t ∈⇩s t) ∈ set (b::'a pset_atom fm list) ⟹ thesis::bool) ⟹ thesis›*) by auto then have "member_cycle [(t ∈⇩s t)]" "(t ∈⇩s t) ∈ Atoms (set b)" apply - (*goals: 1. ‹AT (t ∈⇩s t) ∈ set b ⟹ member_cycle [t ∈⇩s t]› 2. ‹AT (t ∈⇩s t) ∈ set b ⟹ t ∈⇩s t ∈ Atoms (set b)› discuss goal 1*) apply ((auto simp: Atoms_def (*‹Atoms ?A ≡ {a |a. AT a ∈ ?A}›*))[1]) (*discuss goal 2*) apply ((auto simp: Atoms_def (*‹Atoms (?A::?'a fm set) ≡ {a |a::?'a. AT a ∈ ?A}›*))[1]) (*proven 2 subgoals*) . then have "bclosed b" using memberCycle (*‹⟦member_cycle ?cs; set ?cs ⊆ Atoms (set ?b)⟧ ⟹ bclosed ?b›*) by (metis empty_iff (*‹(?c ∈ {}) = False›*) empty_set (*‹{} = set []›*) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) with bopen (*‹bopen (b::'a::type pset_atom fm list)›*) show False by blast qed next (*goals: 1. ‹⋀e1 e2. ⟦e1 ∈ arcs (bgraph b); e2 ∈ arcs (bgraph b); arc_to_ends (bgraph b) e1 = arc_to_ends (bgraph b) e2⟧ ⟹ e1 = e2› 2. ‹¬ Ex fin_digraph_bgraph.cycle›*) case (2 e1 e2) (*‹e1 ∈ arcs (bgraph b)› ‹e2 ∈ arcs (bgraph b)› ‹arc_to_ends (bgraph b) e1 = arc_to_ends (bgraph b) e2›*) then show "?case" (*goal: ‹e1 = e2›*) by (auto simp: bgraph_def (*‹bgraph (?b::?'a pset_atom fm list) ≡ let vs::?'a pset_term set = base_vars ?b ∪ subterms' ?b in ⦇verts = vs, arcs = {(s::?'a pset_term, t::?'a pset_term). AT (s ∈⇩s t) ∈ set ?b}, tail = fst, head = snd⦈›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) arc_to_ends_def (*‹arc_to_ends (?G::(?'a, ?'b) pre_digraph) (?e::?'b) ≡ (tail ?G ?e, head ?G ?e)›*)) next (*goal: ‹¬ Ex fin_digraph_bgraph.cycle›*) case 3 (*no hyothesis introduced yet*) show "?case" (*goal: ‹¬ Ex fin_digraph_bgraph.cycle›*) proof (standard) (*goal: ‹Ex fin_digraph_bgraph.cycle ⟹ False›*) assume "∃c. fin_digraph_bgraph.cycle c" (*‹Ex fin_digraph_bgraph.cycle›*) then obtain c where "fin_digraph_bgraph.cycle c" (*goal: ‹(⋀c. fin_digraph_bgraph.cycle c ⟹ thesis) ⟹ thesis›*) by blast then have "member_cycle (map (λe. (tail (bgraph b) e ∈⇩s head (bgraph b) e)) c)" using member_cycle_if_cycle (*‹fin_digraph_bgraph.cycle (?c::('a pset_term × 'a pset_term) list) ⟹ member_cycle (map (λe::'a pset_term × 'a pset_term. tail (bgraph (b::'a pset_atom fm list)) e ∈⇩s head (bgraph b) e) ?c)›*) by blast moreover from ‹fin_digraph_bgraph.cycle c› (*‹fin_digraph_bgraph.cycle (c::('a::type pset_term × 'a::type pset_term) list)›*) have "set c ⊆ arcs (bgraph b)" by (meson fin_digraph_bgraph.cycle_def (*‹fin_digraph_bgraph.cycle ?p ≡ ∃u. fin_digraph_bgraph.awalk u ?p u ∧ distinct (tl (fin_digraph_bgraph.awalk_verts u ?p)) ∧ ?p ≠ []›*) pre_digraph.awalk_def (*‹pre_digraph.awalk ?G ?u ?p ?v ≡ ?u ∈ verts ?G ∧ set ?p ⊆ arcs ?G ∧ pre_digraph.cas ?G ?u ?p ?v›*)) then have "set (map (λe. (tail (bgraph b) e ∈⇩s head (bgraph b) e)) c) ⊆ Atoms (set b)" unfolding bgraph_def Let_def Atoms_def (*goal: ‹set (map (λe. tail ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ e ∈⇩s head ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ e) c) ⊆ {a |a. AT a ∈ set b}›*) by auto ultimately have "bclosed b" using memberCycle (*‹⟦member_cycle (?cs::?'a pset_atom list); set ?cs ⊆ Atoms (set (?b::?'a pset_atom fm list))⟧ ⟹ bclosed ?b›*) by blast with bopen (*‹bopen b›*) show False by blast qed qed definition I :: "'a pset_term ⇒ hf" where "I ≡ SOME f. inj_on f (subterms b) ∧ (∀p. hcard (f p) > 2 * card (base_vars b ∪ subterms' b))" lemma (in -) Ex_set_family: assumes "finite P" shows "∃I. inj_on I P ∧ (∀p. hcard (I p) ≥ n)" proof (-) (*goal: ‹∃I. inj_on I P ∧ (∀p. n ≤ hcard (I p))›*) from ‹finite P› (*‹finite P›*) obtain ip where ip: "bij_betw ip P {..<card P}" (*goal: ‹(⋀ip. bij_betw ip P {..<card P} ⟹ thesis) ⟹ thesis›*) using to_nat_on_finite (*‹finite ?S ⟹ bij_betw (to_nat_on ?S) ?S {..<card ?S}›*) by blast let ?I = "ord_of o ((+) n) o ip" from ip (*‹bij_betw ip P {..<card P}›*) have "inj_on ?I P" by (auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) bij_betw_def (*‹bij_betw ?f ?A ?B = (inj_on ?f ?A ∧ ?f ` ?A = ?B)›*)) moreover have "hcard (?I p) ≥ n" for p by simp ultimately show "?thesis" (*goal: ‹∃I. inj_on I P ∧ (∀p. n ≤ hcard (I p))›*) by auto qed lemma shows inj_on_I: "inj_on I (subterms b)" and card_I: "hcard (I p) > 2 * card (base_vars b ∪ subterms' b)" proof (-) (*goals: 1. ‹inj_on I (subterms b)› 2. ‹2 * card (base_vars b ∪ subterms' b) < hcard (I p)›*) have "∃f. inj_on f (subterms b) ∧ (∀p. hcard (f p) > 2 * card (base_vars b ∪ subterms' b))" using Ex_set_family (*‹finite ?P ⟹ ∃I. inj_on I ?P ∧ (∀p. ?n ≤ hcard (I p))›*) finite_subterms_branch (*‹finite (subterms (?b::?'a::type pset_atom fm list))›*) by (metis less_eq_Suc_le (*‹((?n::nat) < (?m::nat)) = (Suc ?n ≤ ?m)›*)) from someI_ex[OF this] (*‹inj_on (SOME x. inj_on x (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (x p))) (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard ((SOME x. inj_on x (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (x p))) p))›*) show "inj_on I (subterms b)" "hcard (I p) > 2 * card (base_vars b ∪ subterms' b)" unfolding I_def (*goals: 1. ‹inj_on (SOME f. inj_on f (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (f p))) (subterms b)› 2. ‹2 * card (base_vars b ∪ subterms' b) < hcard ((SOME f. inj_on f (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (f p))) p)›*) apply - (*goals: 1. ‹inj_on (SOME x. inj_on x (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (x p))) (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard ((SOME x. inj_on x (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (x p))) p)) ⟹ inj_on (SOME f. inj_on f (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (f p))) (subterms b)› 2. ‹inj_on (SOME x. inj_on x (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (x p))) (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard ((SOME x. inj_on x (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (x p))) p)) ⟹ 2 * card (base_vars b ∪ subterms' b) < hcard ((SOME f. inj_on f (subterms b) ∧ (∀p. 2 * card (base_vars b ∪ subterms' b) < hcard (f p))) p)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . qed lemma shows inj_on_base_vars_I: "inj_on I (base_vars b)" and inj_on_subterms'_I: "inj_on I (subterms' b)" proof (-) (*goals: 1. ‹inj_on I (base_vars b)› 2. ‹inj_on I (subterms' b)›*) from base_vars_Un_subterms'_eq_subterms (*‹base_vars (?b::?'a pset_atom fm list) ∪ subterms' ?b = subterms ?b›*) have "base_vars b ⊆ subterms b" "subterms' b ⊆ subterms b" using wf_branch_not_Nil[OF wf_branch] (*‹b ≠ []›*) apply - (*goals: 1. ‹⟦⋀b::?'a4 pset_atom fm list. base_vars b ∪ subterms' b = subterms b; (b::'a pset_atom fm list) ≠ []⟧ ⟹ base_vars b ⊆ subterms b› 2. ‹⟦⋀b::?'a pset_atom fm list. base_vars b ∪ subterms' b = subterms b; (b::'a pset_atom fm list) ≠ []⟧ ⟹ subterms' b ⊆ subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with inj_on_I (*‹inj_on I (subterms (b::'a pset_atom fm list))›*) show "inj_on I (base_vars b)" "inj_on I (subterms' b)" unfolding inj_on_def (*goals: 1. ‹∀x∈base_vars b. ∀y∈base_vars b. I x = I y ⟶ x = y› 2. ‹∀x∈subterms' b. ∀y∈subterms' b. I x = I y ⟶ x = y›*) apply - (*goals: 1. ‹⟦∀x∈subterms b. ∀y∈subterms b. I x = I y ⟶ x = y; base_vars b ⊆ subterms b; subterms' b ⊆ subterms b⟧ ⟹ ∀x∈base_vars b. ∀y∈base_vars b. I x = I y ⟶ x = y› 2. ‹⟦∀x∈subterms b. ∀y∈subterms b. I x = I y ⟶ x = y; base_vars b ⊆ subterms b; subterms' b ⊆ subterms b⟧ ⟹ ∀x∈subterms' b. ∀y∈subterms' b. I x = I y ⟶ x = y› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . qed definition "eq ≡ symcl ({(s, t). AT (s =⇩s t) ∈ set b}⁼)" lemma refl_eq: "refl eq" unfolding eq_def symcl_def refl_on_def (*goal: ‹{(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼ ⊆ UNIV × UNIV ∧ (∀x∈UNIV. (x, x) ∈ {(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼)›*) by auto lemma trans_eq: assumes "lin_sat b" shows "trans eq" proof (standard) (*goal: ‹⋀x y z. ⟦(x, y) ∈ eq; (y, z) ∈ eq⟧ ⟹ (x, z) ∈ eq›*) fix s and t and u assume assms: "(s, t) ∈ eq" "(t, u) ∈ eq" (*‹(s::'a pset_term, t::'a pset_term) ∈ eq› ‹(t::'a pset_term, u::'a pset_term) ∈ eq›*) have "(s, u) ∈ eq" if "s ≠ t" "t ≠ u" proof (-) (*goal: ‹(s, u) ∈ eq›*) from that (*‹s ≠ t› ‹t ≠ u›*) assms (*‹(s, t) ∈ eq› ‹(t::'a pset_term, u::'a pset_term) ∈ eq›*) have s_t: "AT (s =⇩s t) ∈ set b ∨ AT (t =⇩s s) ∈ set b" and t_u: "AT (t =⇩s u) ∈ set b ∨ AT (u =⇩s t) ∈ set b" unfolding eq_def symcl_def (*goals: 1. ‹AT (s =⇩s t) ∈ set b ∨ AT (t =⇩s s) ∈ set b› 2. ‹AT (t =⇩s u) ∈ set b ∨ AT (u =⇩s t) ∈ set b›*) apply - (*goals: 1. ‹⟦(s::'a::type pset_term) ≠ (t::'a::type pset_term); t ≠ (u::'a::type pset_term); (s, t) ∈ {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set (b::'a::type pset_atom fm list)}⁼ ∪ (λ(a::'a::type pset_term, b::'a::type pset_term). (b, a)) ` {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set b}⁼; (t, u) ∈ {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a::'a::type pset_term, b::'a::type pset_term). (b, a)) ` {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set b}⁼⟧ ⟹ AT (s =⇩s t) ∈ set b ∨ AT (t =⇩s s) ∈ set b› 2. ‹⟦(s::'a::type pset_term) ≠ (t::'a::type pset_term); t ≠ (u::'a::type pset_term); (s, t) ∈ {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set (b::'a::type pset_atom fm list)}⁼ ∪ (λ(a::'a::type pset_term, b::'a::type pset_term). (b, a)) ` {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set b}⁼; (t, u) ∈ {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a::'a::type pset_term, b::'a::type pset_term). (b, a)) ` {(s::'a::type pset_term, t::'a::type pset_term). AT (s =⇩s t) ∈ set b}⁼⟧ ⟹ AT (t =⇩s u) ∈ set b ∨ AT (u =⇩s t) ∈ set b› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . note intros = lexpands_eq.intros(1,3)[THEN lexpands.intros ( 6 ), THEN ‹lin_sat b› [ THEN lin_satD ]] (*‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; ?x ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ ?x ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; ?x ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ ?x ∈ set b›*) note intros' = intros[where ?x = "AT (s =⇩s u)"] (*‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT ((?t1.2::'a::type pset_term) =⇩s (?t2.2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list); AT (?l2::'a::type pset_atom) ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT ((s::'a::type pset_term) =⇩s (u::'a::type pset_term)) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b›*) intros[where ?x = "AT (u =⇩s s)"] (*‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b›*) from s_t (*‹AT (s =⇩s t) ∈ set b ∨ AT (t =⇩s s) ∈ set b›*) t_u (*‹AT (t =⇩s u) ∈ set b ∨ AT (u =⇩s t) ∈ set b›*) that (*‹(s::'a pset_term) ≠ (t::'a pset_term)› ‹t ≠ u›*) have "AT (s =⇩s u) ∈ set b ∨ AT (u =⇩s s) ∈ set b" apply safe (*goals: 1. ‹⟦s ≠ t; t ≠ u; AT (u =⇩s s) ∉ set b; AT (s =⇩s t) ∈ set b; AT (t =⇩s u) ∈ set b⟧ ⟹ AT (s =⇩s u) ∈ set b› 2. ‹⟦s ≠ t; t ≠ u; AT (u =⇩s s) ∉ set b; AT (s =⇩s t) ∈ set b; AT (u =⇩s t) ∈ set b⟧ ⟹ AT (s =⇩s u) ∈ set b› 3. ‹⟦s ≠ t; t ≠ u; AT (u =⇩s s) ∉ set b; AT (t =⇩s s) ∈ set b; AT (t =⇩s u) ∈ set b⟧ ⟹ AT (s =⇩s u) ∈ set b› 4. ‹⟦s ≠ t; t ≠ u; AT (u =⇩s s) ∉ set b; AT (t =⇩s s) ∈ set b; AT (u =⇩s t) ∈ set b⟧ ⟹ AT (s =⇩s u) ∈ set b› discuss goal 1*) apply (simp add: intros' (*‹⟦AT ((?t1.2::'a::type pset_term) =⇩s (?t2.2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list); AT (?l2::'a::type pset_atom) ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT ((s::'a::type pset_term) =⇩s (u::'a::type pset_term)) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT ((?t1.2::'a::type pset_term) =⇩s (?t2.2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list); AT (?l2::'a::type pset_atom) ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT ((s::'a::type pset_term) =⇩s (u::'a::type pset_term)) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT ((?t1.2::'a::type pset_term) =⇩s (?t2.2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list); AT (?l2::'a::type pset_atom) ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT ((u::'a::type pset_term) =⇩s (s::'a::type pset_term)) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b› ‹⟦AT ((?t1.2::'a::type pset_term) =⇩s (?t2.2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list); AT (?l2::'a::type pset_atom) ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT ((u::'a::type pset_term) =⇩s (s::'a::type pset_term)) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b›*)) (*discuss goal 2*) apply (simp add: intros' (*‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b›*)) (*discuss goal 3*) apply (simp add: intros' (*‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b›*)) (*discuss goal 4*) apply (simp add: intros' (*‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (s =⇩s u) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (s =⇩s u) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t1.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t1.2 ?t2.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b› ‹⟦AT (?t1.2 =⇩s ?t2.2) ∈ set b; AT ?l2 ∈ set b; ?t2.2 ∈ tlvl_terms ?l2; AT (u =⇩s s) ∈ set [AT (subst_tlvl ?t2.2 ?t1.2 ?l2)]⟧ ⟹ AT (u =⇩s s) ∈ set b›*)) (*proven 4 subgoals*) . then show "?thesis" (*goal: ‹(s, u) ∈ eq›*) unfolding eq_def symcl_def (*goal: ‹(s, u) ∈ {(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼›*) by auto qed with assms (*‹(s::'a pset_term, t::'a pset_term) ∈ eq› ‹(t, u) ∈ eq›*) show "(s, u) ∈ eq" apply (cases "s ≠ t ∧ t ≠ u") (*goals: 1. ‹⟦(s, t) ∈ eq; (t, u) ∈ eq; ⟦s ≠ t; t ≠ u⟧ ⟹ (s, u) ∈ eq; s ≠ t ∧ t ≠ u⟧ ⟹ (s, u) ∈ eq› 2. ‹⟦(s, t) ∈ eq; (t, u) ∈ eq; ⟦s ≠ t; t ≠ u⟧ ⟹ (s, u) ∈ eq; ¬ (s ≠ t ∧ t ≠ u)⟧ ⟹ (s, u) ∈ eq› discuss goal 1*) apply ((auto simp: eq_def (*‹eq ≡ ({(s, t). AT (s =⇩s t) ∈ set b}⁼)⇧s›*))[1]) (*discuss goal 2*) apply ((auto simp: eq_def (*‹eq ≡ ({(s, t). AT (s =⇩s t) ∈ set b}⁼)⇧s›*))[1]) (*proven 2 subgoals*) . qed lemma sym_eq: "sym eq" unfolding eq_def symcl_def sym_def (*goal: ‹∀x y. (x, y) ∈ {(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼ ⟶ (y, x) ∈ {(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼›*) by auto lemma equiv_eq: "lin_sat b ⟹ equiv UNIV eq" apply (rule equivI (*‹⟦refl_on ?A ?r; sym ?r; trans ?r⟧ ⟹ equiv ?A ?r›*)) (*goal: ‹lin_sat b ⟹ equiv UNIV eq›*) by (use refl_eq trans_eq sym_eq in safe) lemma not_dominated_if_pwits: assumes "x ∈ Var ` pwits b" shows "¬ s →⇘bgraph b⇙ x" proof (-) (*goal: ‹(s, x) ∉ arcs_ends (bgraph b)›*) from assms (*‹x ∈ Var ` pwits b›*) obtain x' where "x = Var x'" "x' ∈ pwits b" (*goal: ‹(⋀x'. ⟦x = Var x'; x' ∈ pwits b⟧ ⟹ thesis) ⟹ thesis›*) by blast from lemma_2(3)[OF wf_branch this ( 2 )] (*‹AT (?t ∈⇩s Var x') ∉ set b›*) this(1) (*‹x = Var x'›*) show "¬ s →⇘bgraph b⇙ x" unfolding arcs_ends_def arc_to_ends_def (*goal: ‹(s, x) ∉ (λe. (tail (bgraph b) e, head (bgraph b) e)) ` arcs (bgraph b)›*) by (auto simp: bgraph_def (*‹bgraph ?b ≡ let vs = base_vars ?b ∪ subterms' ?b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set ?b}, tail = fst, head = snd⦈›*)) qed lemma parents_empty_if_pwits: assumes "x ∈ Var ` pwits b" shows "parents (bgraph b) x = {}" using not_dominated_if_pwits[OF assms] (*‹(?s, x) ∉ arcs_ends (bgraph b)›*) unfolding bgraph_def (*goal: ‹parents (let vs = base_vars b ∪ subterms' b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈) x = {}›*) by simp lemma not_AT_mem_if_urelem: assumes "t ∈ urelems b" shows "AT (s ∈⇩s t) ∉ set b" proof (standard) (*goal: ‹AT (s ∈⇩s t) ∈ set b ⟹ False›*) assume "AT (s ∈⇩s t) ∈ set b" (*‹AT ((s::'a pset_term) ∈⇩s (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)›*) with assms (*‹t ∈ urelems b›*) urelem_invar_if_wf_branch[OF wf_branch] (*‹⟦urelem (last b) ?x; ?x ∈ subterms (last b)⟧ ⟹ ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ ?x : 0›*) have "urelem (AT (s ∈⇩s t)) t" by (meson types (*‹∃v. v ⊢ last b›*) types_urelems (*‹⟦wf_branch ?b; ?v ⊢ last ?b; ⋀v'. ⟦∀φ∈set ?b. v' ⊢ φ; ∀u∈urelems ?b. v' ⊢ u : 0⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) urelem_def (*‹urelem ?φ ?t ≡ ∃v. v ⊢ ?φ ∧ v ⊢ ?t : 0›*) wf_branch (*‹wf_branch b›*)) then show False unfolding urelem_def (*goal: ‹False›*) by (auto dest!: types_fmD (*‹?v ⊢ And ?p ?q ⟹ ?v ⊢ ?p› ‹?v ⊢ And ?p ?q ⟹ ?v ⊢ ?q› ‹?v ⊢ Or ?p ?q ⟹ ?v ⊢ ?p› ‹?v ⊢ Or ?p ?q ⟹ ?v ⊢ ?q› ‹?v ⊢ Neg ?p ⟹ ?v ⊢ ?p› ‹?v ⊢ AT ?a ⟹ ?v ⊢ ?a›*) simp: types_pset_atom.simps (*‹(?a1.0 ⊢ ?a2.0) = ((∃v s l t. ?a1.0 = v ∧ ?a2.0 = s =⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : l) ∨ (∃v s l t. ?a1.0 = v ∧ ?a2.0 = s ∈⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : Suc l))›*) dest: types_term_unique (*‹⟦?v ⊢ ?t : ?l1.0; ?v ⊢ ?t : ?l2.0⟧ ⟹ ?l2.0 = ?l1.0›*)) qed lemma not_dominated_if_urelems: assumes "t ∈ urelems b" shows "¬ s →⇘bgraph b⇙ t" using not_AT_mem_if_urelem[OF assms] (*‹AT (?s ∈⇩s t) ∉ set b›*) unfolding bgraph_def (*goal: ‹(s, t) ∉ arcs_ends (let vs = base_vars b ∪ subterms' b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈)›*) by auto lemma parents_empty_if_urelems: assumes "t ∈ urelems b" shows "parents (bgraph b) t = {}" using not_dominated_if_urelems[OF assms] (*‹(?s, t) ∉ arcs_ends (bgraph b)›*) by simp lemma not_dominated_if_base_vars: assumes "x ∈ base_vars b" shows "¬ s →⇘bgraph b⇙ x" using assms (*‹x ∈ base_vars b›*) not_dominated_if_urelems (*‹?t ∈ urelems b ⟹ (?s, ?t) ∉ arcs_ends (bgraph b)›*) not_dominated_if_pwits (*‹?x ∈ Var ` pwits b ⟹ (?s, ?x) ∉ arcs_ends (bgraph b)›*) unfolding base_vars_def (*goal: ‹(s::'a pset_term, x::'a pset_term) ∉ arcs_ends (bgraph (b::'a pset_atom fm list))›*) by blast lemma parents_empty_if_base_vars: assumes "x ∈ base_vars b" shows "parents (bgraph b) x = {}" using not_dominated_if_base_vars[OF assms] (*‹(?s, x) ∉ arcs_ends (bgraph b)›*) by blast lemma eq_class_subs_subterms: "eq `` {t} ⊆ {t} ∪ subterms b" proof (-) (*goal: ‹eq `` {t} ⊆ {t} ∪ subterms b›*) have "eq - Id ⊆ subterms b × subterms b" by (auto simp: AT_eq_subterms_branchD (*‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) eq_def (*‹eq ≡ ({(s, t). AT (s =⇩s t) ∈ set b}⁼)⇧s›*) symcl_def (*‹?R⇧s = ?R ∪ (λ(a, b). (b, a)) ` ?R›*)) then show "eq `` {t} ⊆ {t} ∪ subterms b" by blast qed lemma finite_eq_class: "finite (eq `` {x})" using eq_class_subs_subterms (*‹eq `` {?t::'a pset_term} ⊆ {?t} ∪ subterms (b::'a pset_atom fm list)›*) finite_subterms_branch (*‹finite (subterms ?b)›*) using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by fastforce lemma finite_I_image_eq_class: "finite (I ` eq `` {x})" using finite_eq_class (*‹finite (eq `` {?x})›*) by blast context begin interpretation realisation "bgraph b" "base_vars b" "subterms' b" I eq proof (unfold_locales) (*goals: 1. ‹base_vars b ∩ subterms' b = {}› 2. ‹verts (bgraph b) = base_vars b ∪ subterms' b› 3. ‹⋀p t. p ∈ base_vars b ⟹ (t, p) ∉ arcs_ends (bgraph b)›*) from base_vars_subterms'_disjnt (*‹base_vars (?b::?'a pset_atom fm list) ∩ subterms' ?b = {}›*) show "base_vars b ∩ subterms' b = {}" . show "verts (bgraph b) = base_vars b ∪ subterms' b" unfolding bgraph_def (*goal: ‹verts (let vs = base_vars b ∪ subterms' b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈) = base_vars b ∪ subterms' b›*) by simp from not_dominated_if_base_vars (*‹?x ∈ base_vars b ⟹ (?s, ?x) ∉ arcs_ends (bgraph b)›*) show "⋀p t. p ∈ base_vars b ⟹ ¬ t →⇘bgraph b⇙ p" . qed lemmas realisation = realisation_axioms lemma card_realisation: "hcard (realise t) ≤ 2 * card (subterms b)" proof (induction t rule: realise.induct (*‹⟦⋀x. ⟦x ∈ base_vars b; ⋀xa. xa ∈ parents (bgraph b) x ⟹ ?P xa⟧ ⟹ ?P x; ⋀t. ⟦t ∈ subterms' b; ⋀x. x ∈ parents (bgraph b) t ⟹ ?P x⟧ ⟹ ?P t; ⋀x. x ∉ base_vars b ∪ subterms' b ⟹ ?P x⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹⋀x. ⟦x ∈ base_vars b; ⋀xa. xa ∈ parents (bgraph b) x ⟹ hcard (realise xa) ≤ 2 * card (subterms b)⟧ ⟹ hcard (realise x) ≤ 2 * card (subterms b)› 2. ‹⋀t. ⟦t ∈ subterms' b; ⋀x. x ∈ parents (bgraph b) t ⟹ hcard (realise x) ≤ 2 * card (subterms b)⟧ ⟹ hcard (realise t) ≤ 2 * card (subterms b)› 3. ‹⋀x. x ∉ base_vars b ∪ subterms' b ⟹ hcard (realise x) ≤ 2 * card (subterms b)›*) case (1 x) (*‹x ∈ base_vars b› ‹?xa1 ∈ parents (bgraph b) x ⟹ hcard (realise ?xa1) ≤ 2 * card (subterms b)›*) then have "hcard (realise x) = card (realise ` parents (bgraph b) x ∪ I ` eq_class x)" using hcard_HF (*‹finite (?A::hf set) ⟹ hcard (HF ?A) = card ?A›*) Zero_hf_def (*‹0 = HF {}›*) parents_empty_if_base_vars (*‹?x ∈ base_vars b ⟹ parents (bgraph b) ?x = {}›*) using finite_I_image_eq_class (*‹finite (I ` eq `` {?x})›*) by force also (*calculation: ‹hcard (realise x) = card (realise ` parents (bgraph b) x ∪ I ` eq `` {x})›*) have "… ≤ card (realise ` parents (bgraph b) x) + card (I ` eq_class x)" using card_Un_le (*‹card (?A ∪ ?B) ≤ card ?A + card ?B›*) by blast also (*calculation: ‹hcard (realise x) ≤ card (realise ` parents (bgraph b) x) + card (I ` eq `` {x})›*) have "… ≤ card (parents (bgraph b) x) + card (eq_class x)" using card_image_le[OF fin_digraph_bgraph.finite_parents] (*‹card ((?f::'a pset_term ⇒ ?'b) ` parents (bgraph (b::'a pset_atom fm list)) (?s1::'a pset_term)) ≤ card (parents (bgraph b) ?s1)›*) using card_image_le[OF finite_eq_class] (*‹card (?f ` eq `` {?x1}) ≤ card (eq `` {?x1})›*) by (metis add_le_mono (*‹⟦(?i::nat) ≤ (?j::nat); (?k::nat) ≤ (?l::nat)⟧ ⟹ ?i + ?k ≤ ?j + ?l›*)) also (*calculation: ‹hcard (realise x) ≤ card (parents (bgraph b) x) + card (eq `` {x})›*) have "… ≤ card (subterms b) + card (eq_class x)" using fin_digraph_bgraph.parents_subs_verts[unfolded verts_bgraph_eq_subterms] (*‹parents (bgraph b) ?s ⊆ subterms b›*) using card_mono[OF finite_subterms_branch] (*‹?A ⊆ subterms ?b1 ⟹ card ?A ≤ card (subterms ?b1)›*) by (simp add: "1.hyps" (*‹x ∈ base_vars b›*) not_dominated_if_base_vars (*‹?x ∈ base_vars b ⟹ (?s, ?x) ∉ arcs_ends (bgraph b)›*)) also (*calculation: ‹hcard (realise x) ≤ card (subterms b) + card (eq `` {x})›*) have "… ≤ card (subterms b) + card ({x} ∪ subterms b)" apply (intro add_le_mono (*‹⟦?i ≤ ?j; ?k ≤ ?l⟧ ⟹ ?i + ?k ≤ ?j + ?l›*) card_mono[where ?B="{x} ∪ subterms b"] (*‹⟦finite ({x} ∪ subterms b); ?A ⊆ {x} ∪ subterms b⟧ ⟹ card ?A ≤ card ({x} ∪ subterms b)›*)) (*goal: ‹card (subterms b) + card (eq `` {x}) ≤ card (subterms b) + card ({x} ∪ subterms b)›*) using eq_class_subs_subterms (*‹eq `` {?t} ⊆ {?t} ∪ subterms b›*) finite_subterms_branch (*‹finite (subterms (?b::?'a pset_atom fm list))›*) apply - (*goals: 1. ‹⟦⋀t. eq `` {t} ⊆ {t} ∪ subterms b; ⋀b. finite (subterms b)⟧ ⟹ card (subterms b) ≤ card (subterms b)› 2. ‹⟦⋀t. eq `` {t} ⊆ {t} ∪ subterms b; ⋀b. finite (subterms b)⟧ ⟹ finite ({x} ∪ subterms b)› 3. ‹⟦⋀t. eq `` {t} ⊆ {t} ∪ subterms b; ⋀b. finite (subterms b)⟧ ⟹ eq `` {x} ⊆ {x} ∪ subterms b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹hcard (realise x) ≤ card (subterms b) + card ({x} ∪ subterms b)›*) have "… ≤ 2 * card (subterms b)" proof (-) (*goal: ‹card (subterms b) + card ({x} ∪ subterms b) ≤ 2 * card (subterms b)›*) from "1" (*‹x ∈ base_vars b› ‹(?xa1::'a pset_term) ∈ parents (bgraph (b::'a pset_atom fm list)) (x::'a pset_term) ⟹ hcard (realise ?xa1) ≤ (2::nat) * card (subterms b)›*) have "x ∈ subterms b" using "1.prems" verts_bgraph (*‹verts (bgraph ?b) = base_vars ?b ∪ subterms' ?b›*) verts_bgraph_eq_subterms (*‹verts (bgraph ?b) = subterms ?b›*) wf_branch_not_Nil[OF wf_branch] (*‹b ≠ []›*) by blast then show "?thesis" (*goal: ‹card (subterms (b::'a pset_atom fm list)) + card ({x::'a pset_term} ∪ subterms b) ≤ (2::nat) * card (subterms b)›*) unfolding mult_2 (*goal: ‹card (subterms b) + card ({x} ∪ subterms b) ≤ card (subterms b) + card (subterms b)›*) by (metis insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*) insert_is_Un (*‹insert ?a ?A = {?a} ∪ ?A›*) order_refl (*‹?x ≤ ?x›*)) qed finally (*calculation: ‹hcard (realise x) ≤ 2 * card (subterms b)›*) show "?case" (*goal: ‹hcard (realise x) ≤ 2 * card (subterms b)›*) . next (*goals: 1. ‹⋀t. ⟦t ∈ subterms' b; ⋀x. x ∈ parents (bgraph b) t ⟹ hcard (realise x) ≤ 2 * card (subterms b)⟧ ⟹ hcard (realise t) ≤ 2 * card (subterms b)› 2. ‹⋀x. x ∉ base_vars b ∪ subterms' b ⟹ hcard (realise x) ≤ 2 * card (subterms b)›*) case (2 t) (*‹(t::'a pset_term) ∈ subterms' (b::'a pset_atom fm list)› ‹?x1 ∈ parents (bgraph b) t ⟹ hcard (realise ?x1) ≤ 2 * card (subterms b)›*) then have "hcard (realise t) = card (realise ` parents (bgraph b) t)" using hcard_HF[OF finite_realisation_parents] (*‹hcard (HF (realise ` parents (bgraph (b::'a pset_atom fm list)) (?t1::'a pset_term))) = card (realise ` parents (bgraph b) ?t1)›*) by simp also (*calculation: ‹hcard (realise t) = card (realise ` parents (bgraph b) t)›*) have "… ≤ card (parents (bgraph b) t)" using card_image_le (*‹finite (?A::?'a::type set) ⟹ card ((?f::?'a::type ⇒ ?'b::type) ` ?A) ≤ card ?A›*) by blast also (*calculation: ‹hcard (realise t) ≤ card (parents (bgraph b) t)›*) have "… ≤ card (subterms b)" using fin_digraph_bgraph.parents_subs_verts (*‹parents (bgraph b) ?s ⊆ verts (bgraph b)›*) wf_branch_not_Nil[OF wf_branch] (*‹b ≠ []›*) unfolding verts_bgraph_eq_subterms (*goal: ‹card (parents (bgraph b) t) ≤ card (subterms b)›*) by (metis card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) fin_digraph_bgraph.finite_verts (*‹finite (verts (bgraph b))›*) verts_bgraph_eq_subterms (*‹verts (bgraph ?b) = subterms ?b›*)) finally (*calculation: ‹hcard (realise t) ≤ card (subterms b)›*) show "?case" (*goal: ‹hcard (realise t) ≤ 2 * card (subterms b)›*) unfolding base_vars_Un_subterms'_eq_subterms (*goal: ‹hcard (realise t) ≤ 2 * card (subterms b)›*) by auto next (*goal: ‹⋀x. x ∉ base_vars b ∪ subterms' b ⟹ hcard (realise x) ≤ 2 * card (subterms b)›*) case (3 t) (*‹t ∉ base_vars b ∪ subterms' b›*) then show "?case" (*goal: ‹hcard (realise (t::'a::type pset_term)) ≤ (2::nat) * card (subterms (b::'a::type pset_atom fm list))›*) by simp qed lemma I_neq_realise: "I x ≠ realise y" proof (-) (*goal: ‹I x ≠ realise y›*) note card_realisation[of y] (*‹hcard (realise y) ≤ 2 * card (subterms b)›*) moreover have "hcard (I x) > 2 * card (subterms b)" using card_I (*‹2 * card (base_vars b ∪ subterms' b) < hcard (I ?p)›*) wf_branch (*‹wf_branch b›*) by (simp add: subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) wits_subterms_eq_base_vars_Un_subterms' (*‹wf_branch ?b ⟹ wits_subterms ?b = base_vars ?b ∪ subterms' ?b›*)) ultimately show "?thesis" (*goal: ‹I x ≠ realise y›*) by (metis linorder_not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*)) qed end sublocale realisation "bgraph b" "base_vars b" "subterms' b" I eq rewrites "(⋀x y. I x ≠ realise y) ≡ Trueprop True" and "⋀P. (True ⟹ P) ≡ Trueprop P" and "⋀P Q. (True ⟹ PROP P ⟹ PROP Q) ≡ (PROP P ⟹ True ⟹ PROP Q)" using realisation (*‹realisation (bgraph b) (base_vars b) (subterms' b)›*) I_neq_realise (*‹I ?x ≠ realisation.realise (bgraph b) (base_vars b) (subterms' b) I eq ?y›*) apply - (*goals: 1. ‹⟦realisation (bgraph b) (base_vars b) (subterms' b); ⋀x y. I x ≠ realisation.realise (bgraph b) (base_vars b) (subterms' b) I eq y⟧ ⟹ realisation (bgraph b) (base_vars b) (subterms' b)› 2. ‹⟦realisation (bgraph b) (base_vars b) (subterms' b); ⋀x y. I x ≠ realisation.realise (bgraph b) (base_vars b) (subterms' b) I eq y⟧ ⟹ (⋀x y. I x ≠ realisation.realise (bgraph b) (base_vars b) (subterms' b) I eq y) ≡ True› 3. ‹⋀P. ⟦realisation (bgraph b) (base_vars b) (subterms' b); ⋀x y. I x ≠ realisation.realise (bgraph b) (base_vars b) (subterms' b) I eq y⟧ ⟹ (True ⟹ P) ≡ P› 4. ‹⋀P Q. ⟦realisation (bgraph b) (base_vars b) (subterms' b); ⋀x y. I x ≠ realisation.realise (bgraph b) (base_vars b) (subterms' b) I eq y⟧ ⟹ (⟦True; PROP P⟧ ⟹ PROP Q) ≡ (⟦PROP P; True⟧ ⟹ PROP Q)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . lemma eq_class_singleton_if_pwits: assumes "x ∈ Var ` pwits b" shows "eq_class x = {x}" proof (-) (*goal: ‹eq `` {x} = {x}›*) from assms (*‹x ∈ Var ` pwits b›*) obtain x' where "x = Var x'" "x' ∈ pwits b" (*goal: ‹(⋀x'. ⟦x = Var x'; x' ∈ pwits b⟧ ⟹ thesis) ⟹ thesis›*) by blast have False if "eq_class x ≠ {x}" proof (-) (*goal: ‹False›*) have "x ∈ eq_class x" by (simp add: eq_def (*‹eq ≡ ({(s, t). AT (s =⇩s t) ∈ set b}⁼)⇧s›*) symcl_def (*‹?R⇧s = ?R ∪ (λ(a, b). (b, a)) ` ?R›*)) with that (*‹eq `` {x::'a pset_term} ≠ {x}›*) obtain y where "y ∈ eq_class x" "y ≠ x" (*goal: ‹(⋀y. ⟦y ∈ eq `` {x}; y ≠ x⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "AT (y =⇩s x) ∈ set b ∨ AT (x =⇩s y) ∈ set b" unfolding eq_def symcl_def (*goal: ‹AT (y =⇩s x) ∈ set b ∨ AT (x =⇩s y) ∈ set b›*) by auto with lemma_2(1,2)[OF wf_branch ‹x' ∈ pwits b›] (*‹AT (Var x' =⇩s ?t) ∉ set b› ‹AT (?t =⇩s Var x') ∉ set b›*) ‹x = Var x'› (*‹x = Var x'›*) show False by blast qed with assms (*‹x ∈ Var ` pwits b›*) show "?thesis" (*goal: ‹eq `` {x} = {x}›*) by blast qed lemma realise_pwits: "x ∈ Var ` pwits b ⟹ realise x = HF {I x}" unfolding realise.simps(1)[OF pwits_subs_base_vars [ THEN subsetD ]] (*goal: ‹x ∈ Var ` pwits b ⟹ HF (realise ` parents (bgraph b) x) ⊔ HF (I ` eq `` {x}) = HF {I x}›*) by (auto simp: eq_class_singleton_if_pwits (*‹?x ∈ Var ` pwits b ⟹ eq `` {?x} = {?x}›*) parents_empty_if_pwits (*‹?x ∈ Var ` pwits b ⟹ parents (bgraph b) ?x = {}›*)) lemma I_in_realise_if_base_vars[simp]: "s ∈ base_vars b ⟹ I s ❙∈ realise s" using refl_eq (*‹refl eq›*) by (simp add: finite_I_image_eq_class (*‹finite (I ` eq `` {?x::'a pset_term})›*) refl_on_def (*‹refl_on (?A::?'a set) (?r::(?'a × ?'a) set) = (?r ⊆ ?A × ?A ∧ (∀x::?'a∈?A. (x, x) ∈ ?r))›*)) lemma realise_neq_if_base_vars_and_subterms': assumes "s ∈ base_vars b" "t ∈ subterms' b" shows "realise s ≠ realise t" proof (-) (*goal: ‹realise (s::'a::type pset_term) ≠ realise (t::'a::type pset_term)›*) from assms (*‹s ∈ base_vars b› ‹t ∈ subterms' b›*) have "I s ❙∉ realise t" using I_neq_realise (*‹I ?x ≠ realise ?y›*) by auto with I_in_realise_if_base_vars (*‹?s ∈ base_vars b ⟹ I ?s ❙∈ realise ?s›*) assms(1) (*‹s ∈ base_vars b›*) show "?thesis" (*goal: ‹realise s ≠ realise t›*) by metis qed lemma AT_mem_branch_wits_subtermsD: assumes "AT (s ∈⇩s t) ∈ set b" shows "s ∈ wits_subterms b" "t ∈ wits_subterms b" using assms (*‹AT (s ∈⇩s t) ∈ set b›*) AT_mem_subterms_branchD (*‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*) subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) wf_branch (*‹wf_branch (b::'a pset_atom fm list)›*) apply - (*goals: 1. ‹⟦AT (s ∈⇩s t) ∈ set b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ s ∈ wits_subterms b› 2. ‹⟦AT (s ∈⇩s t) ∈ set b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ t ∈ wits_subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma AF_mem_branch_wits_subtermsD: assumes "AF (s ∈⇩s t) ∈ set b" shows "s ∈ wits_subterms b" "t ∈ wits_subterms b" using assms (*‹AF (s ∈⇩s t) ∈ set b›*) AF_mem_subterms_branchD (*‹AF ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) subterms_branch_eq_if_wf_branch (*‹wf_branch (?b::?'a pset_atom fm list) ⟹ subterms ?b = wits_subterms ?b›*) wf_branch (*‹wf_branch b›*) apply - (*goals: 1. ‹⟦AF (s ∈⇩s t) ∈ set b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ s ∈ wits_subterms b› 2. ‹⟦AF (s ∈⇩s t) ∈ set b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ t ∈ wits_subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma AT_eq_branch_wits_subtermsD: assumes "AT (s =⇩s t) ∈ set b" shows "s ∈ wits_subterms b" "t ∈ wits_subterms b" using assms (*‹AT (s =⇩s t) ∈ set b›*) AT_eq_subterms_branchD (*‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) wf_branch (*‹wf_branch b›*) apply - (*goals: 1. ‹⟦AT (s =⇩s t) ∈ set b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ s ∈ wits_subterms b› 2. ‹⟦AT (s =⇩s t) ∈ set b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ t ∈ wits_subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma AF_eq_branch_wits_subtermsD: assumes "AF (s =⇩s t) ∈ set b" shows "s ∈ wits_subterms b" "t ∈ wits_subterms b" using assms (*‹AF ((s::'a pset_term) =⇩s (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)›*) AF_eq_subterms_branchD (*‹AF (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) subterms_branch_eq_if_wf_branch (*‹wf_branch ?b ⟹ subterms ?b = wits_subterms ?b›*) wf_branch (*‹wf_branch (b::'a::type pset_atom fm list)›*) apply - (*goals: 1. ‹⟦AF (s =⇩s t) ∈ set b; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ s ∈ wits_subterms b› 2. ‹⟦AF (s =⇩s t) ∈ set b; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ t ∈ subterms b; ⋀b. wf_branch b ⟹ subterms b = wits_subterms b; wf_branch b⟧ ⟹ t ∈ wits_subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . lemma realisation_if_AT_mem: assumes "AT (s ∈⇩s t) ∈ set b" shows "realise s ❙∈ realise t" proof (-) (*goal: ‹realise (s::'a pset_term) ❙∈ realise (t::'a pset_term)›*) from assms (*‹AT (s ∈⇩s t) ∈ set b›*) have "t ∈ base_vars b ∪ subterms' b" using in_subterms'_if_AT_mem_in_branch(2) (*‹⟦wf_branch ?b; AT (?s ∈⇩s ?t) ∈ set ?b⟧ ⟹ ?t ∈ base_vars ?b ∪ subterms' ?b›*) wf_branch (*‹wf_branch b›*) by blast moreover from assms (*‹AT (s ∈⇩s t) ∈ set b›*) have "s →⇘bgraph b⇙ t" unfolding arcs_ends_def arc_to_ends_def (*goal: ‹(s, t) ∈ (λe. (tail (bgraph b) e, head (bgraph b) e)) ` arcs (bgraph b)›*) by (simp add: bgraph_def (*‹bgraph ?b ≡ let vs = base_vars ?b ∪ subterms' ?b in ⦇verts = vs, arcs = {(s, t). AT (s ∈⇩s t) ∈ set ?b}, tail = fst, head = snd⦈›*)) ultimately show "?thesis" (*goal: ‹realise s ❙∈ realise t›*) apply (cases t rule: realise.cases (*‹⟦⋀x. ⟦x ∈ base_vars b; ?x = x⟧ ⟹ ?P; ⋀t. ⟦t ∈ subterms' b; ?x = t⟧ ⟹ ?P; ⋀x. ⟦x ∉ base_vars b ∪ subterms' b; ?x = x⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀x. ⟦t ∈ base_vars b ∪ subterms' b; s →⇘bgraph b⇙ t; x ∈ base_vars b; t = x⟧ ⟹ realise s ❙∈ realise t› 2. ‹⋀ta. ⟦t ∈ base_vars b ∪ subterms' b; s →⇘bgraph b⇙ t; ta ∈ subterms' b; t = ta⟧ ⟹ realise s ❙∈ realise t› 3. ‹⋀x. ⟦t ∈ base_vars b ∪ subterms' b; s →⇘bgraph b⇙ t; x ∉ base_vars b ∪ subterms' b; t = x⟧ ⟹ realise s ❙∈ realise t› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed lemma AT_eq_urelems_subterms'_cases: includes Set_member_no_ascii_notation assumes "AT (s =⇩s t) ∈ set b" obtains (urelems) "s ∈ urelems b" "t ∈ urelems b" | (subterms') "s ∈ subterms' b" "t ∈ subterms' b" proof (-) (*goal: ‹⟦⟦s ∈ urelems b; t ∈ urelems b⟧ ⟹ thesis; ⟦s ∈ subterms' b; t ∈ subterms' b⟧ ⟹ thesis⟧ ⟹ thesis›*) from types (*‹∃v. v ⊢ last b›*) obtain v where "v ⊢ last b" (*goal: ‹(⋀v. v ⊢ last b ⟹ thesis) ⟹ thesis›*) by blast with types_urelems (*‹⟦wf_branch (?b::?'a pset_atom fm list); (?v::?'a ⇒ nat) ⊢ last ?b; ⋀v'::?'a ⇒ nat. ⟦∀φ::?'a pset_atom fm∈set ?b. v' ⊢ φ; ∀u::?'a pset_term∈urelems ?b. v' ⊢ u : (0::nat)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) wf_branch (*‹wf_branch b›*) obtain v' where v': "∀φ ∈ set b. v' ⊢ φ" "∀u ∈ urelems b. v' ⊢ u : 0" (*goal: ‹(⋀v'. ⟦∀φ∈set b. v' ⊢ φ; ∀u∈urelems b. v' ⊢ u : 0⟧ ⟹ thesis) ⟹ thesis›*) by blast with assms (*‹AT (s =⇩s t) ∈ set b›*) have "v' ⊢ AT (s =⇩s t)" by blast then obtain lst where lst: "v' ⊢ s : lst" "v' ⊢ t : lst" (*goal: ‹(⋀lst. ⟦v' ⊢ s : lst; v' ⊢ t : lst⟧ ⟹ thesis) ⟹ thesis›*) by (auto dest!: types_fmD( (*‹?v ⊢ AT ?a ⟹ ?v ⊢ ?a›*) 6) simp: types_pset_atom.simps (*‹(?a1.0 ⊢ ?a2.0) = ((∃v s l t. ?a1.0 = v ∧ ?a2.0 = s =⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : l) ∨ (∃v s l t. ?a1.0 = v ∧ ?a2.0 = s ∈⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : Suc l))›*)) note mem_subterms = AT_eq_subterms_branchD[OF assms] (*‹(s::'a pset_term) ∈ subterms (b::'a pset_atom fm list)› ‹(t::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list)›*) with v' (*‹∀φ∈set b. v' ⊢ φ› ‹∀u::'a pset_term∈urelems (b::'a pset_atom fm list). (v'::'a ⇒ nat) ⊢ u : (0::nat)›*) have "t ∈ urelems b" if "s ∈ urelems b" using that (*‹s ∈ urelems b›*) lst (*‹(v'::'a::type ⇒ nat) ⊢ (s::'a::type pset_term) : (lst::nat)› ‹v' ⊢ t : lst›*) types_term_unique (*‹⟦(?v::?'a ⇒ nat) ⊢ (?t::?'a pset_term) : (?l1.0::nat); ?v ⊢ ?t : (?l2.0::nat)⟧ ⟹ ?l2.0 = ?l1.0›*) urelems_def (*‹urelems ?b ≡ {x ∈ subterms ?b. ∃v. ∀φ∈set ?b. v ⊢ φ ∧ v ⊢ x : 0}›*) by fastforce moreover from assms (*‹AT ((s::'a pset_term) =⇩s (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)›*) have "s ∉ Var ` pwits b" "t ∉ Var ` pwits b" using lemma_2(1,2)[OF wf_branch] (*‹(?c::'a) ∈ pwits (b::'a pset_atom fm list) ⟹ AT (Var ?c =⇩s (?t::'a pset_term)) ∉ set b› ‹(?c::'a::type) ∈ pwits (b::'a::type pset_atom fm list) ⟹ AT ((?t::'a::type pset_term) =⇩s Var ?c) ∉ set b›*) apply - (*goals: 1. ‹⟦AT (s =⇩s t) ∈ set b; ⋀c t. c ∈ pwits b ⟹ AT (Var c =⇩s t) ∉ set b; ⋀c t. c ∈ pwits b ⟹ AT (t =⇩s Var c) ∉ set b⟧ ⟹ s ∉ Var ` pwits b› 2. ‹⟦AT (s =⇩s t) ∈ set b; ⋀c t. c ∈ pwits b ⟹ AT (Var c =⇩s t) ∉ set b; ⋀c t. c ∈ pwits b ⟹ AT (t =⇩s Var c) ∉ set b⟧ ⟹ t ∉ Var ` pwits b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover have "t ∈ subterms' b" if "s ∈ subterms' b" proof (-) (*goal: ‹t ∈ subterms' b›*) have "s ∉ urelems b" using that (*‹s ∈ subterms' b›*) B_T_partition_verts(1) (*‹base_vars b ∩ subterms' b = {}›*) unfolding base_vars_def (*goal: ‹(s::'a pset_term) ∉ urelems (b::'a pset_atom fm list)›*) by blast with v'(1) (*‹∀φ∈set b. v' ⊢ φ›*) mem_subterms(1) (*‹(s::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list)›*) have "¬ v' ⊢ s : 0" using urelems_def (*‹urelems ?b ≡ {x ∈ subterms ?b. ∃v. ∀φ∈set ?b. v ⊢ φ ∧ v ⊢ x : 0}›*) by blast with lst (*‹v' ⊢ s : lst› ‹v' ⊢ t : lst›*) v'(2) (*‹∀u∈urelems b. v' ⊢ u : 0›*) have "t ∉ urelems b" using types_term_unique (*‹⟦?v ⊢ ?t : ?l1.0; ?v ⊢ ?t : ?l2.0⟧ ⟹ ?l2.0 = ?l1.0›*) by metis with ‹t ∉ Var ` pwits b› (*‹t ∉ Var ` pwits b›*) ‹t ∈ subterms b› (*‹t ∈ subterms b›*) show "t ∈ subterms' b" by (simp add: base_vars_def (*‹base_vars (?b::?'a::type pset_atom fm list) ≡ Var ` pwits ?b ∪ urelems ?b›*) subterms'_def (*‹subterms' (?b::?'a::type pset_atom fm list) ≡ subterms ?b - base_vars ?b›*)) qed ultimately show "?thesis" (*goal: ‹thesis›*) using that (*‹⟦s ∈ urelems b; t ∈ urelems b⟧ ⟹ thesis› ‹⟦s ∈ subterms' b; t ∈ subterms' b⟧ ⟹ thesis›*) mem_subterms (*‹(s::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list)› ‹t ∈ subterms b›*) apply (cases "s ∈ subterms' b") (*goals: 1. ‹⟦(s::'a pset_term) ∈ urelems (b::'a pset_atom fm list) ⟹ (t::'a pset_term) ∈ urelems b; s ∉ Var ` pwits b; t ∉ Var ` pwits b; s ∈ subterms' b ⟹ t ∈ subterms' b; ⟦s ∈ urelems b; t ∈ urelems b⟧ ⟹ thesis::bool; ⟦s ∈ subterms' b; t ∈ subterms' b⟧ ⟹ thesis; s ∈ subterms b; t ∈ subterms b; s ∈ subterms' b⟧ ⟹ thesis› 2. ‹⟦(s::'a pset_term) ∈ urelems (b::'a pset_atom fm list) ⟹ (t::'a pset_term) ∈ urelems b; s ∉ Var ` pwits b; t ∉ Var ` pwits b; s ∈ subterms' b ⟹ t ∈ subterms' b; ⟦s ∈ urelems b; t ∈ urelems b⟧ ⟹ thesis::bool; ⟦s ∈ subterms' b; t ∈ subterms' b⟧ ⟹ thesis; s ∈ subterms b; t ∈ subterms b; s ∉ subterms' b⟧ ⟹ thesis› discuss goal 1*) apply ((auto simp: base_vars_def (*‹base_vars ?b ≡ Var ` pwits ?b ∪ urelems ?b›*) subterms'_def (*‹subterms' ?b ≡ subterms ?b - base_vars ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: base_vars_def (*‹base_vars ?b ≡ Var ` pwits ?b ∪ urelems ?b›*) subterms'_def (*‹subterms' ?b ≡ subterms ?b - base_vars ?b›*))[1]) (*proven 2 subgoals*) . qed lemma realisation_if_AT_eq: assumes "lin_sat b" assumes "AT (s =⇩s t) ∈ set b" shows "realise s = realise t" proof (-) (*goal: ‹realise s = realise t›*) from assms(2) (*‹AT ((s::'a::type pset_term) =⇩s (t::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list)›*) show "?thesis" (*goal: ‹realise (s::'a pset_term) = realise (t::'a pset_term)›*) proof (cases rule: AT_eq_urelems_subterms'_cases (*‹⟦AT (?s =⇩s ?t) ∈ set b; ⟦?s ∈ urelems b; ?t ∈ urelems b⟧ ⟹ ?thesis; ⟦?s ∈ subterms' b; ?t ∈ subterms' b⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦s ∈ urelems b; t ∈ urelems b⟧ ⟹ realise s = realise t› 2. ‹⟦s ∈ subterms' b; t ∈ subterms' b⟧ ⟹ realise s = realise t›*) case urelems (*‹s ∈ urelems b› ‹(t::'a pset_term) ∈ urelems (b::'a pset_atom fm list)›*) then have "s ∈ base_vars b" "t ∈ base_vars b" apply - (*goals: 1. ‹⟦(s::'a::type pset_term) ∈ urelems (b::'a::type pset_atom fm list); (t::'a::type pset_term) ∈ urelems b⟧ ⟹ s ∈ base_vars b› 2. ‹⟦(s::'a::type pset_term) ∈ urelems (b::'a::type pset_atom fm list); (t::'a::type pset_term) ∈ urelems b⟧ ⟹ t ∈ base_vars b› discuss goal 1*) apply (simp add: base_vars_def (*‹base_vars (?b::?'a pset_atom fm list) ≡ Var ` pwits ?b ∪ urelems ?b›*)) (*discuss goal 2*) apply (simp add: base_vars_def (*‹base_vars (?b::?'a pset_atom fm list) ≡ Var ` pwits ?b ∪ urelems ?b›*)) (*proven 2 subgoals*) . moreover from assms (*‹lin_sat b› ‹AT (s =⇩s t) ∈ set b›*) have "(s, t) ∈ eq" unfolding eq_def symcl_def (*goal: ‹(s, t) ∈ {(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼›*) by blast then have "I ` eq_class s = I ` eq_class t" using equiv_eq[OF assms ( 1 )] (*‹equiv UNIV eq›*) by (simp add: equiv_class_eq_iff (*‹equiv (?A::?'a set) (?r::(?'a × ?'a) set) ⟹ ((?x::?'a, ?y::?'a) ∈ ?r) = (?r `` {?x} = ?r `` {?y} ∧ ?x ∈ ?A ∧ ?y ∈ ?A)›*)) ultimately show "?thesis" (*goal: ‹realise s = realise t›*) using urelems (*‹s ∈ urelems b› ‹(t::'a pset_term) ∈ urelems (b::'a pset_atom fm list)›*) by (simp add: parents_empty_if_urelems (*‹(?t::'a::type pset_term) ∈ urelems (b::'a::type pset_atom fm list) ⟹ parents (bgraph b) ?t = {}›*)) next (*goal: ‹⟦s ∈ subterms' b; t ∈ subterms' b⟧ ⟹ realise s = realise t›*) case subterms' (*‹s ∈ subterms' b› ‹t ∈ subterms' b›*) have False if "realise s ≠ realise t" proof (-) (*goal: ‹False›*) from that (*‹realise s ≠ realise t›*) have "hfset (realise s) ≠ hfset (realise t)" by (metis HF_hfset (*‹HF (hfset ?a) = ?a›*)) then obtain a and s' and t' where a: "a ∈ realise ` parents (bgraph b) s'" "a ∉ realise ` parents (bgraph b) t'" and s'_t': "s' = s ∧ t' = t ∨ s' = t ∧ t' = s" (*goal: ‹(⋀a s' t'. ⟦a ∈ realise ` parents (bgraph b) s'; a ∉ realise ` parents (bgraph b) t'; s' = s ∧ t' = t ∨ s' = t ∧ t' = s⟧ ⟹ thesis) ⟹ thesis›*) using subterms' (*‹(s::'a::type pset_term) ∈ subterms' (b::'a::type pset_atom fm list)› ‹t ∈ subterms' b›*) apply auto (*goals: 1. ‹⋀xa. ⟦⋀a s' t'. ⟦a ∈ realise ` parents (bgraph b) s'; a ∉ realise ` parents (bgraph b) t'; s' = s ∧ t' = t ∨ s' = t ∧ t' = s⟧ ⟹ False; s ∈ subterms' b; t ∈ subterms' b; ¬ thesis; xa →⇘bgraph b⇙ s⟧ ⟹ realise xa ∈ realise ` parents (bgraph b) t› 2. ‹⋀xa. ⟦⋀a s' t'. ⟦a ∈ realise ` parents (bgraph b) s'; a ∉ realise ` parents (bgraph b) t'; s' = s ∧ t' = t ∨ s' = t ∧ t' = s⟧ ⟹ False; s ∈ subterms' b; t ∈ subterms' b; ¬ thesis; xa →⇘bgraph b⇙ t⟧ ⟹ realise xa ∈ realise ` parents (bgraph b) s› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with subterms' (*‹(s::'a pset_term) ∈ subterms' (b::'a pset_atom fm list)› ‹t ∈ subterms' b›*) have "s' ∈ subterms' b" "t' ∈ subterms' b" apply - (*goals: 1. ‹⟦s ∈ subterms' b; t ∈ subterms' b; a ∈ realise ` parents (bgraph b) s'; a ∉ realise ` parents (bgraph b) t'; s' = s ∧ t' = t ∨ s' = t ∧ t' = s⟧ ⟹ s' ∈ subterms' b› 2. ‹⟦s ∈ subterms' b; t ∈ subterms' b; a ∈ realise ` parents (bgraph b) s'; a ∉ realise ` parents (bgraph b) t'; s' = s ∧ t' = t ∨ s' = t ∧ t' = s⟧ ⟹ t' ∈ subterms' b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with a (*‹a ∈ realise ` parents (bgraph b) s'› ‹a ∉ realise ` parents (bgraph b) t'›*) obtain u where u: "a = realise u" "u →⇘bgraph b⇙ s'" (*goal: ‹(⋀u. ⟦a = realise u; u →⇘bgraph b⇙ s'⟧ ⟹ thesis) ⟹ thesis›*) using subterms' (*‹s ∈ subterms' b› ‹t ∈ subterms' b›*) dominates_if_mem_realisation (*‹⟦realise ?s ❙∈ realise ?t; ⋀s'. ⟦s' →⇘bgraph b⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by auto then have "u ≠ s'" using dag_bgraph.adj_not_same (*‹?a →⇘bgraph b⇙ ?a ⟹ False›*) by blast from u (*‹a = realise u› ‹u →⇘bgraph b⇙ s'›*) have "AT (u ∈⇩s s') ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (u ∈⇩s s') ∈ set b›*) using dag_bgraph.adj_not_same (*‹?a →⇘bgraph b⇙ ?a ⟹ False›*) by auto note lexpands_eq.intros(1,3)[OF assms ( 2 ) this, THEN lexpands.intros ( 6 )] (*‹s ∈ tlvl_terms (u ∈⇩s s') ⟹ lexpands [AT (subst_tlvl s t (u ∈⇩s s'))] b› ‹(t::'a pset_term) ∈ tlvl_terms ((u::'a pset_term) ∈⇩s (s'::'a pset_term)) ⟹ lexpands [AT (subst_tlvl t (s::'a pset_term) (u ∈⇩s s'))] (b::'a pset_atom fm list)›*) with ‹lin_sat b› (*‹lin_sat b›*) s'_t' (*‹s' = s ∧ t' = t ∨ s' = t ∧ t' = s›*) ‹u ≠ s'› (*‹u ≠ s'›*) have "AT (u ∈⇩s t') ∈ set b" unfolding lin_sat_def (*goal: ‹AT (u ∈⇩s t') ∈ set b›*) by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) from realisation_if_AT_mem[OF this] (*‹realise (u::'a::type pset_term) ❙∈ realise (t'::'a::type pset_term)›*) ‹a = realise u› (*‹a = realise u›*) have "a ❙∈ realise t'" by blast with a (*‹a ∈ realise ` parents (bgraph b) s'› ‹a ∉ realise ` parents (bgraph b) t'›*) show False using ‹t' ∈ subterms' b› (*‹t' ∈ subterms' b›*) by simp qed then show "?thesis" (*goal: ‹realise (s::'a pset_term) = realise (t::'a pset_term)›*) by blast qed qed lemma realise_base_vars_if_AF_eq: assumes "sat b" assumes "AF (x =⇩s y) ∈ set b" assumes "x ∈ base_vars b ∨ y ∈ base_vars b" shows "realise x ≠ realise y" proof (cases "x ∈ base_vars b ∧ y ∈ base_vars b") (*goals: 1. ‹x ∈ base_vars b ∧ y ∈ base_vars b ⟹ realise x ≠ realise y› 2. ‹¬ (x ∈ base_vars b ∧ y ∈ base_vars b) ⟹ realise x ≠ realise y›*) case False (*‹¬ (x ∈ base_vars b ∧ y ∈ base_vars b)›*) with assms(3) (*‹(x::'a pset_term) ∈ base_vars (b::'a pset_atom fm list) ∨ (y::'a pset_term) ∈ base_vars b›*) show "?thesis" (*goal: ‹realise x ≠ realise y›*) using realise_neq_if_base_vars_and_subterms' (*‹⟦?s ∈ base_vars b; ?t ∈ subterms' b⟧ ⟹ realise ?s ≠ realise ?t›*) I_in_realise_if_base_vars (*‹?s ∈ base_vars b ⟹ I ?s ❙∈ realise ?s›*) by (metis hempty_iff (*‹(?z = 0) = (∀x. x ❙∉ ?z)›*) realise.elims (*‹⟦realise ?x = ?y; ⋀x. ⟦x ∈ base_vars b; ?x = x⟧ ⟹ True; ⋀x. ⟦x ∈ base_vars b; ?x = x; ?y = HF (realise ` parents (bgraph b) x) ⊔ HF (I ` eq `` {x})⟧ ⟹ ?P; ⋀t. ⟦t ∈ subterms' b; ?x = t⟧ ⟹ True; ⋀t. ⟦t ∈ subterms' b; ?x = t; ?y = HF (realise ` parents (bgraph b) t)⟧ ⟹ ?P; ⋀x. ⟦x ∉ base_vars b ∪ subterms' b; ?x = x⟧ ⟹ True; ⋀x. ⟦x ∉ base_vars b ∪ subterms' b; ?x = x; ?y = 0⟧ ⟹ ?P⟧ ⟹ ?P›*)) next (*goal: ‹x ∈ base_vars b ∧ y ∈ base_vars b ⟹ realise x ≠ realise y›*) case True (*‹(x::'a pset_term) ∈ base_vars (b::'a pset_atom fm list) ∧ (y::'a pset_term) ∈ base_vars b›*) from assms (*‹sat b› ‹AF (x =⇩s y) ∈ set b› ‹x ∈ base_vars b ∨ y ∈ base_vars b›*) bopen (*‹bopen b›*) have "x ≠ y" using neqSelf (*‹AF (?t =⇩s ?t) ∈ set ?b ⟹ bclosed ?b›*) by blast moreover from assms (*‹sat b› ‹AF ((x::'a pset_term) =⇩s (y::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹(x::'a::type pset_term) ∈ base_vars (b::'a::type pset_atom fm list) ∨ (y::'a::type pset_term) ∈ base_vars b›*) bopen (*‹bopen (b::'a::type pset_atom fm list)›*) have "AT (x =⇩s y) ∉ set b" using contr (*‹⟦?φ ∈ set ?b; Neg ?φ ∈ set ?b⟧ ⟹ bclosed ?b›*) by blast moreover have "AT (y =⇩s x) ∉ set b" proof (standard) (*goal: ‹AT (y =⇩s x) ∈ set b ⟹ False›*) assume "AT (y =⇩s x) ∈ set b" (*‹AT ((y::'a pset_term) =⇩s (x::'a pset_term)) ∈ set (b::'a pset_atom fm list)›*) note lexpands_eq.intros(2)[OF this assms ( 2 ), THEN lexpands.intros ( 6 )] (*‹y ∈ tlvl_terms (x =⇩s y) ⟹ lexpands [AF (subst_tlvl y x (x =⇩s y))] b›*) with ‹sat b›[THEN satD ( 1 ), THEN lin_satD] (*‹⟦lexpands ?b' b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set b›*) have "AF (x =⇩s x) ∈ set b" by auto with bopen (*‹bopen b›*) neqSelf (*‹AF (?t =⇩s ?t) ∈ set ?b ⟹ bclosed ?b›*) show False by blast qed ultimately have "(x, y) ∉ eq" unfolding eq_def symcl_def (*goal: ‹(x, y) ∉ {(s, t). AT (s =⇩s t) ∈ set b}⁼ ∪ (λ(a, b). (b, a)) ` {(s, t). AT (s =⇩s t) ∈ set b}⁼›*) by auto then have "x ∉ eq_class y" by (meson Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) symE (*‹⟦sym ?r; (?b, ?a) ∈ ?r; (?a, ?b) ∈ ?r ⟹ ?thesis⟧ ⟹ ?thesis›*) sym_eq (*‹sym eq›*)) then have "I x ∉ I ` eq_class y" using inj_on_I (*‹inj_on I (subterms b)›*) AF_eq_subterms_branchD[OF assms ( 2 )] (*‹x ∈ subterms b› ‹y ∈ subterms b›*) using eq_class_subs_subterms (*‹eq `` {?t} ⊆ {?t} ∪ subterms b›*) inj_onD (*‹⟦inj_on (?f::?'a ⇒ ?'b) (?A::?'a set); ?f (?x::?'a) = ?f (?y::?'a); ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x = ?y›*) by fastforce then have "I ` eq_class x ≠ I ` eq_class y" using refl_eq (*‹refl eq›*) by (metis Image_singleton_iff (*‹(?b ∈ ?r `` {?a}) = ((?a, ?b) ∈ ?r)›*) UNIV_I (*‹?x ∈ UNIV›*) imageI (*‹?x ∈ ?A ⟹ ?f ?x ∈ ?f ` ?A›*) refl_onD (*‹⟦refl_on ?A ?r; ?a ∈ ?A⟧ ⟹ (?a, ?a) ∈ ?r›*)) with ‹x ∈ base_vars b ∧ y ∈ base_vars b› (*‹x ∈ base_vars b ∧ y ∈ base_vars b›*) show "realise x ≠ realise y" using hunion_hempty_left[unfolded Zero_hf_def] (*‹HF {} ⊔ (?A::hf) = ?A›*) using inj_on_HF[THEN inj_onD] (*‹⟦HF ?x = HF ?y; ?x ∈ Collect finite; ?y ∈ Collect finite⟧ ⟹ ?x = ?y›*) finite_I_image_eq_class (*‹finite (I ` eq `` {?x})›*) by (force simp: parents_empty_if_base_vars (*‹?x ∈ base_vars b ⟹ parents (bgraph b) ?x = {}›*)) qed lemma Ex_AT_eq_mem_subterms_last_if_subterms': assumes "t ∈ subterms' b" obtains "t ∈ subterms (last b) - base_vars b" | t' where "t' ∈ subterms (last b) - base_vars b" "AT (t =⇩s t') ∈ set b ∨ AT (t' =⇩s t) ∈ set b" proof(cases "t ∈ subterms (last b) - base_vars b") case False from assms have "t ∈ subterms b" using base_vars_Un_subterms'_eq_subterms by auto with False consider (t_base_vars) "t ∈ base_vars b" | (t_wits) "t ∈ Var ` wits b" using no_new_subterms_if_wf_branch[OF wf_branch] by (meson DiffI no_new_subterms_def) then show ?thesis proof cases case t_wits with ‹t ∈ subterms' b› have "t ∉ Var ` pwits b" unfolding subterms'_def base_vars_def by blast with t_wits obtain t' where t': "t' ∈ subterms (last b)" "AT (t =⇩s t') ∈ set b ∨ AT (t' =⇩s t) ∈ set b" unfolding pwits_def by blast with ‹t ∈ subterms' b› have "t' ∉ base_vars b" using AT_eq_urelems_subterms'_cases B_T_partition_verts(1) by (metis Un_iff base_vars_def disjoint_iff) with t' that show ?thesis by blast qed (use assms[unfolded subterms'_def] in blast) qed lemma realisation_if_AF_eq: assumes "sat b" assumes "AF (t1 =⇩s t2) ∈ set b" shows "realise t1 ≠ realise t2" proof - note AF_eq_branch_wits_subtermsD[OF assms(2)] then consider (t1_base_vars) "t1 ∈ base_vars b" | (t2_base_vars) "t2 ∈ base_vars b" "t1 ∈ base_vars b ∪ subterms' b" | (subterms) "t1 ∈ subterms' b" "t2 ∈ subterms' b" by (metis UnE wf_branch wits_subterms_eq_base_vars_Un_subterms') then show ?thesis proof cases case t1_base_vars with assms show ?thesis using realise_base_vars_if_AF_eq by blast next case t2_base_vars with assms show ?thesis using realise_base_vars_if_AF_eq by blast next case subterms define Δ where "Δ ≡ {(t1, t2) ∈ subterms' b × subterms' b. AF (t1 =⇩s t2) ∈ set b ∧ realise t1 = realise t2}" have "finite Δ" proof - have "Δ ⊆ subterms' b × subterms' b" unfolding Δ_def by auto moreover note finite_cartesian_product[OF finite_subterms' finite_subterms'] ultimately show ?thesis using finite_subset by blast qed let ?h = "λ(t1, t2). min (height t1) (height t2)" have False if "Δ ≠ {}" proof - obtain t1 t2 where t1_t2: "(t1, t2) = arg_min_on ?h Δ" by (metis surj_pair) have "(t1, t2) ∈ Δ" "?h (t1, t2) = Min (?h ` Δ)" proof - from arg_min_if_finite(1)[OF ‹finite Δ› that] t1_t2 show "(t1, t2) ∈ Δ" by metis have "f (arg_min_on f S) = Min (f ` S)" if "finite S" "S ≠ {}" for f :: "('a pset_term × 'a pset_term) ⇒ nat" and S using arg_min_least[OF that] that by (auto intro!: Min_eqI[symmetric] intro: arg_min_if_finite(1)[OF that]) from this[OF ‹finite Δ› that] t1_t2 show "?h (t1, t2) = Min (?h ` Δ)" by auto qed then have *: "t1 ∈ subterms' b" "t2 ∈ subterms' b" "AF (t1 =⇩s t2) ∈ set b" "realise t1 = realise t2" unfolding Δ_def by auto obtain t1' t2' where t1'_t2': "t1' ∈ subterms (last b) - base_vars b" "t2' ∈ subterms (last b) - base_vars b" "AF (t1' =⇩s t2') ∈ set b" "realise t1' = realise t1" "realise t2' = realise t2" proof - note Ex_AT_eq_mem_subterms_last_if_subterms'[OF ‹t1 ∈ subterms' b›] then obtain t1'' where "t1'' ∈ subterms (last b) - base_vars b" "AF (t1'' =⇩s t2) ∈ set b" "realise t1'' = realise t1" proof cases case (2 t1') from bopen neqSelf ‹AF (t1 =⇩s t2) ∈ set b› have "t1 ≠ t2" by blast with 2 ‹sat b›[THEN satD(1), THEN lin_satD] have "AF (t1' =⇩s t2) ∈ set b" using lexpands_eq.intros(2,4)[OF _ ‹AF (t1 =⇩s t2) ∈ set b›, THEN lexpands.intros(6)] by fastforce with that[OF _ this] "2"(1) ‹sat b›[unfolded sat_def] show ?thesis using realisation_if_AT_eq 2 by metis qed (use * that[of t1] in blast) moreover note Ex_AT_eq_mem_subterms_last_if_subterms'[OF ‹t2 ∈ subterms' b›] then obtain t2'' where "t2'' ∈ subterms (last b) - base_vars b" "AF (t1'' =⇩s t2'') ∈ set b" "realise t2'' = realise t2" proof cases case (2 t2') from bopen neqSelf ‹AF (t1'' =⇩s t2) ∈ set b› have "t1'' ≠ t2" by blast with 2 ‹sat b›[THEN satD(1), THEN lin_satD] have "AF (t1'' =⇩s t2') ∈ set b" using lexpands_eq.intros(2,4)[OF _ ‹AF (t1'' =⇩s t2) ∈ set b›, THEN lexpands.intros(6)] by fastforce with that[OF _ this] "2"(1) ‹sat b›[unfolded sat_def] show ?thesis using realisation_if_AT_eq 2 by metis qed (use ‹AF (t1'' =⇩s t2) ∈ set b› that[of t2] in blast) ultimately show ?thesis using that * by metis qed with ‹realise t1 = realise t2› have "(t1', t2') ∈ Δ" unfolding Δ_def subterms'_def by (simp add: AF_eq_subterms_branchD(1,2)) then have t1'_t2'_subterms: "t1' ∈ subterms' b" "t2' ∈ subterms' b" unfolding Δ_def by blast+ from t1'_t2' lemma1_2 "*"(3) have "?h (t1', t2') = ?h (t1, t2)" by (metis in_subterms'_if_AF_eq_in_branch(1,2)[OF wf_branch] case_prod_conv) from mem_urelems_if_urelem_last[OF wf_branch] t1'_t2'(1,2) have not_urelem: "¬ urelem (last b) t1'" "¬ urelem (last b) t2'" unfolding base_vars_def by auto from finite_vars_branch infinite_vars obtain x where "x ∉ vars b" using ex_new_if_finite by blast from bexpands_wit.intros[OF t1'_t2'(3) _ _ _ _ this not_urelem] t1'_t2'(1,2) ‹sat b›[unfolded sat_def] consider s1 where "AT (s1 ∈⇩s t1') ∈ set b" "AF (s1 ∈⇩s t2') ∈ set b" | s2 where "AF (s2 ∈⇩s t1') ∈ set b" "AT (s2 ∈⇩s t2') ∈ set b" using bexpands.intros(2-) by (metis Diff_iff) then show ?thesis proof cases case 1 then have "realise s1 ❙∈ realise t2'" using realisation_if_AT_mem by (metis "*"(4) t1'_t2'(4) t1'_t2'(5)) with 1 t1'_t2'(3,4) obtain s2 where "s2 →⇘bgraph b⇙ t2'" "realise s1 = realise s2" using dominates_if_mem_realisation in_subterms'_if_AT_mem_in_branch(1)[OF wf_branch] by metis then have "AT (s2 ∈⇩s t2') ∈ set b" unfolding bgraph_def Let_def by auto with ‹AF (s1 ∈⇩s t2') ∈ set b› ‹sat b›[THEN satD(1), THEN lin_satD] have "AF (s2 =⇩s s1) ∈ set b" using lexpands_eq.intros(5)[THEN lexpands.intros(6)] by fastforce then have "s1 ≠ s2" using neqSelf bopen by blast from realise_base_vars_if_AF_eq[OF ‹sat b› ‹AF (s2 =⇩s s1) ∈ set b›] ‹realise s1 = realise s2› have "s1 ∈ subterms' b" "s2 ∈ subterms' b" by (metis Un_iff ‹AF (s2 =⇩s s1) ∈ set b› in_subterms'_if_AF_eq_in_branch wf_branch)+ with ‹realise s1 = realise s2› have "(s2, s1) ∈ Δ" unfolding Δ_def using ‹AF (s2 =⇩s s1) ∈ set b› by auto moreover have "realise s1 ❙∈ realise t1'" "realise s2 ❙∈ realise t1'" "realise s1 ❙∈ realise t2'" "realise s2 ❙∈ realise t2'" using ‹realise s1 ❙∈ realise t2'› ‹realise s1 = realise s2› using "*"(4) t1'_t2'(4,5) by auto with lemma1_3 have "?h (s2, s1) < ?h (t1', t2')" using ‹s1 ∈ subterms' b› ‹s2 ∈ subterms' b› t1'_t2'_subterms by (auto simp: min_def) ultimately show ?thesis using arg_min_least[OF ‹finite Δ› ‹Δ ≠ {}›] using ‹(t1', t2') ∈ Δ› ‹?h (t1', t2') = ?h (t1, t2)› t1_t2 by (metis (mono_tags, lifting) le_antisym le_eq_less_or_eq nat_neq_iff) next case 2 then have "realise s2 ❙∈ realise t1'" using realisation_if_AT_mem by (metis "*"(4) t1'_t2'(4) t1'_t2'(5)) with 2 t1'_t2'(3,4) obtain s1 where "s1 →⇘bgraph b⇙ t1'" "realise s1 = realise s2" using dominates_if_mem_realisation by metis then have "AT (s1 ∈⇩s t1') ∈ set b" unfolding bgraph_def Let_def by auto with ‹AF (s2 ∈⇩s t1') ∈ set b› ‹sat b›[unfolded sat_def] have "AF (s1 =⇩s s2) ∈ set b" using lexpands_eq.intros(5)[THEN lexpands.intros(6)] using lin_satD by fastforce then have "s1 ≠ s2" using neqSelf bopen by blast from realise_base_vars_if_AF_eq[OF ‹sat b› ‹AF (s1 =⇩s s2) ∈ set b›] ‹realise s1 = realise s2› have "s1 ∈ subterms' b" "s2 ∈ subterms' b" by (metis Un_iff ‹AF (s1 =⇩s s2) ∈ set b› in_subterms'_if_AF_eq_in_branch wf_branch)+ with ‹realise s1 = realise s2› have "(s1, s2) ∈ Δ" unfolding Δ_def using ‹AF (s1 =⇩s s2) ∈ set b› by auto moreover have "realise s1 ❙∈ realise t1'" "realise s2 ❙∈ realise t1'" "realise s1 ❙∈ realise t2'" "realise s2 ❙∈ realise t2'" using ‹realise s2 ❙∈ realise t1'› ‹realise s1 = realise s2› using "*"(4) t1'_t2'(4,5) by auto with lemma1_3 have "?h (s1, s2) < ?h (t1', t2')" using ‹s1 ∈ subterms' b› ‹s2 ∈ subterms' b› t1'_t2'_subterms by (auto simp: min_def) ultimately show ?thesis using arg_min_least[OF ‹finite Δ› ‹Δ ≠ {}›] using ‹(t1', t2') ∈ Δ› ‹?h (t1', t2') = ?h (t1, t2)› t1_t2 by (metis (mono_tags, lifting) le_antisym le_eq_less_or_eq nat_neq_iff) qed qed with assms subterms show ?thesis unfolding Δ_def by blast qed qed lemma realisation_if_AF_mem: assumes "sat b" assumes "AF (s ∈⇩s t) ∈ set b" shows "realise s ❙∉ realise t" proof (standard) (*goal: ‹realise (s::'a pset_term) ❙∈ realise (t::'a pset_term) ⟹ False›*) assume "realise s ❙∈ realise t" (*‹realise (s::'a pset_term) ❙∈ realise (t::'a pset_term)›*) from assms (*‹sat (b::'a::type pset_atom fm list)› ‹AF (s ∈⇩s t) ∈ set b›*) have "s ∈ base_vars b ∪ subterms' b" "t ∈ base_vars b ∪ subterms' b" using in_subterms'_if_AF_mem_in_branch[OF wf_branch] (*‹AF (?s ∈⇩s ?t) ∈ set b ⟹ ?s ∈ base_vars b ∪ subterms' b› ‹AF ((?s::'a pset_term) ∈⇩s (?t::'a pset_term)) ∈ set (b::'a pset_atom fm list) ⟹ ?t ∈ base_vars b ∪ subterms' b›*) apply - (*goals: 1. ‹⟦sat b; AF (s ∈⇩s t) ∈ set b; ⋀s t. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ base_vars b ∪ subterms' b; ⋀s t. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ base_vars b ∪ subterms' b⟧ ⟹ s ∈ base_vars b ∪ subterms' b› 2. ‹⟦sat b; AF (s ∈⇩s t) ∈ set b; ⋀s t. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ base_vars b ∪ subterms' b; ⋀s t. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ base_vars b ∪ subterms' b⟧ ⟹ t ∈ base_vars b ∪ subterms' b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . from dominates_if_mem_realisation[OF ‹realise s ❙∈ realise t›] (*‹(⋀s'. ⟦s' →⇘bgraph b⇙ t; realise s = realise s'⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain s' where "s' →⇘bgraph b⇙ t" "realise s = realise s'" (*goal: ‹(⋀s'. ⟦s' →⇘bgraph b⇙ t; realise s = realise s'⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "AT (s' ∈⇩s t) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (s' ∈⇩s t) ∈ set b›*) by auto with assms (*‹sat (b::'a pset_atom fm list)› ‹AF ((s::'a::type pset_term) ∈⇩s (t::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list)›*) lexpands_eq.intros(5)[THEN lexpands.intros ( 6 )] (*‹⟦AT (?s1 ∈⇩s ?t1) ∈ set ?b; AF (?s'1 ∈⇩s ?t1) ∈ set ?b⟧ ⟹ lexpands [AF (?s1 =⇩s ?s'1)] ?b›*) have "AF (s' =⇩s s) ∈ set b" unfolding sat_def (*goal: ‹AF (s' =⇩s s) ∈ set b›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) by fastforce from realisation_if_AF_eq[OF ‹sat b› this] (*‹realise (s'::'a pset_term) ≠ realise (s::'a pset_term)›*) ‹realise s = realise s'› (*‹realise s = realise s'›*) show False by simp qed lemma realisation_Empty: "realise (∅ n) = 0" proof (-) (*goal: ‹realise ∅ n::nat = (0::hf)›*) from bopen (*‹bopen b›*) have "AT (s ∈⇩s ∅ n) ∉ set b" for s using bclosed.intros (*‹⟦(?φ::?'a pset_atom fm) ∈ set (?b::?'a pset_atom fm list); Neg ?φ ∈ set ?b⟧ ⟹ bclosed ?b› ‹AT (?t ∈⇩s ∅ ?n) ∈ set ?b ⟹ bclosed ?b› ‹AF ((?t::?'a::type pset_term) =⇩s ?t) ∈ set (?b::?'a::type pset_atom fm list) ⟹ bclosed ?b› ‹⟦member_cycle ?cs; set ?cs ⊆ Atoms (set ?b)⟧ ⟹ bclosed ?b›*) by blast then have "parents (bgraph b) (∅ n) = {}" unfolding bgraph_def Let_def (*goal: ‹parents ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ ∅ n = {}›*) by auto moreover have "(∅ n) ∉ base_vars b" proof (-) (*goal: ‹∅ n ∉ base_vars b›*) have "(∅ n) ∉ Var ` pwits b" using pwits_def (*‹pwits (?b::?'a pset_atom fm list) ≡ {c::?'a ∈ wits ?b. ∀t::?'a pset_term∈subterms (last ?b). AT (Var c =⇩s t) ∉ set ?b ∧ AT (t =⇩s Var c) ∉ set ?b}›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*) by blast moreover have "(∅ n) ∉ urelems b" unfolding urelems_def (*goal: ‹∅ n ∉ {x ∈ subterms b. ∃v. ∀φ∈set b. v ⊢ φ ∧ v ⊢ x : 0}›*) using wf_branch[THEN wf_branch_not_Nil] (*‹b ≠ []›*) last_in_set (*‹(?as::?'a::type list) ≠ [] ⟹ last ?as ∈ set ?as›*) using is_Var_if_urelem' (*‹(?v::?'a::type ⇒ nat) ⊢ (?φ::?'a::type pset_atom fm) ∧ ?v ⊢ (?t::?'a::type pset_term) : (0::nat) ⟹ is_Var ?t›*) by fastforce ultimately show "?thesis" (*goal: ‹∅ n ∉ base_vars b›*) unfolding base_vars_def (*goal: ‹∅ n ∉ Var ` pwits b ∪ urelems b›*) by blast qed then have "(∅ n) ∈ subterms' b ∨ (∅ n) ∉ verts (bgraph b)" by (simp add: verts_bgraph (*‹verts (bgraph (?b::?'a pset_atom fm list)) = base_vars ?b ∪ subterms' ?b›*)) ultimately show "realise (∅ n) = 0" by (auto simp: verts_bgraph (*‹verts (bgraph ?b) = base_vars ?b ∪ subterms' ?b›*)) qed lemma realisation_Union: assumes "sat b" assumes "t1 ⊔⇩s t2 ∈ subterms b" shows "realise (t1 ⊔⇩s t2) = realise t1 ⊔ realise t2" using assms (*‹sat b› ‹(t1::'a pset_term) ⊔⇩s (t2::'a pset_term) ∈ subterms (b::'a pset_atom fm list)›*) proof (-) (*goal: ‹⟦sat b; t1 ⊔⇩s t2 ∈ subterms b⟧ ⟹ realise (t1 ⊔⇩s t2) = realise t1 ⊔ realise t2›*) from assms (*‹sat b› ‹t1 ⊔⇩s t2 ∈ subterms b›*) have mem_subterms_last: "t1 ⊔⇩s t2 ∈ subterms (last b)" using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch] (*‹⟦?t ∈ subterms b; ¬ is_Var ?t⟧ ⟹ ?t ∈ subterms (last b)›*) by simp note not_urelem_comps_if_compound[where ?f = "(⊔⇩s)", OF assms ( 2 ), simplified] (*‹t1 ∉ urelems b› ‹t2 ∉ urelems b›*) moreover note subterms_fmD(1,2)[OF mem_subterms_last] (*‹t1 ∈ subterms (last b)› ‹t2 ∈ subterms (last b)›*) then have "t1 ∉ Var ` pwits b" "t2 ∉ Var ` pwits b" unfolding pwits_def wits_def (*goals: 1. ‹t1 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹t2 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) using pset_term.set_intros(1) (*‹?x2.0 ∈ vars (Var ?x2.0)›*) mem_vars_fm_if_mem_subterms_fm (*‹⟦?x ∈ vars ?s; ?s ∈ subterms ?φ⟧ ⟹ ?x ∈ vars ?φ›*) apply - (*goals: 1. ‹⟦t1 ∈ subterms (last b); t2 ∈ subterms (last b); ⋀x2. x2 ∈ vars (Var x2); ⋀x s φ. ⟦x ∈ vars s; s ∈ subterms φ⟧ ⟹ x ∈ vars φ⟧ ⟹ t1 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹⟦t1 ∈ subterms (last b); t2 ∈ subterms (last b); ⋀x2. x2 ∈ vars (Var x2); ⋀x s φ. ⟦x ∈ vars s; s ∈ subterms φ⟧ ⟹ x ∈ vars φ⟧ ⟹ t2 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . ultimately have "t1 ∈ subterms' b" "t2 ∈ subterms' b" unfolding subterms'_def base_vars_def (*goals: 1. ‹t1 ∈ subterms b - (Var ` pwits b ∪ urelems b)› 2. ‹t2 ∈ subterms b - (Var ` pwits b ∪ urelems b)›*) using assms(2) (*‹(t1::'a pset_term) ⊔⇩s (t2::'a pset_term) ∈ subterms (b::'a pset_atom fm list)›*) apply - (*goals: 1. ‹⟦t1 ∉ urelems b; t2 ∉ urelems b; t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; t1 ⊔⇩s t2 ∈ subterms b⟧ ⟹ t1 ∈ subterms b - (Var ` pwits b ∪ urelems b)› 2. ‹⟦t1 ∉ urelems b; t2 ∉ urelems b; t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; t1 ⊔⇩s t2 ∈ subterms b⟧ ⟹ t2 ∈ subterms b - (Var ` pwits b ∪ urelems b)› discuss goal 1*) apply ((auto dest: subterms_branchD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 2*) apply ((auto dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*proven 2 subgoals*) . from assms(2) (*‹t1 ⊔⇩s t2 ∈ subterms b›*) have "t1 ⊔⇩s t2 ∈ subterms' b" using base_vars_subs_vars (*‹base_vars ?b ⊆ Var ` vars ?b›*) base_vars_Un_subterms'_eq_subterms (*‹base_vars (?b::?'a pset_atom fm list) ∪ subterms' ?b = subterms ?b›*) by blast have "realise (t1 ⊔⇩s t2) ≤ realise t1 ⊔ realise t2" proof (standard) (*goal: ‹⋀x. x ❙∈ realise (t1 ⊔⇩s t2) ⟹ x ❙∈ realise t1 ⊔ realise t2›*) fix e assume "e ❙∈ realise (t1 ⊔⇩s t2)" (*‹(e::hf) ❙∈ realise ((t1::'a pset_term) ⊔⇩s (t2::'a pset_term))›*) then obtain s where s: "e = realise s" "s →⇘bgraph b⇙ (t1 ⊔⇩s t2)" (*goal: ‹(⋀s. ⟦e = realise s; s →⇘bgraph b⇙ t1 ⊔⇩s t2⟧ ⟹ thesis) ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise ?s ❙∈ realise ?t; ⋀s'. ⟦s' →⇘bgraph b⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹t1 ⊔⇩s t2 ∈ subterms' b› (*‹t1 ⊔⇩s t2 ∈ subterms' b›*) by auto then have "AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b›*) by auto with ‹sat b› (*‹sat b›*) consider "AT (s ∈⇩s t1) ∈ set b" | "AF (s ∈⇩s t1) ∈ set b" (*goal: ‹⟦AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)) ∈ set (b::'a pset_atom fm list) ⟹ thesis::bool; AF (s ∈⇩s t1) ∈ set b ⟹ thesis⟧ ⟹ thesis›*) unfolding sat_def (*goal: ‹⟦AT (s ∈⇩s t1) ∈ set b ⟹ thesis; AF (s ∈⇩s t1) ∈ set b ⟹ thesis⟧ ⟹ thesis›*) using bexpands_nowit.intros(3)[OF _ mem_subterms_last, THEN bexpands.intros ( 1 )] (*‹⟦AT (?s1 ∈⇩s t1 ⊔⇩s t2) ∈ set b; AT (?s1 ∈⇩s t1) ∉ set b; AF (?s1 ∈⇩s t1) ∉ set b⟧ ⟹ bexpands {[AT (?s1 ∈⇩s t1)], [AF (?s1 ∈⇩s t1)]} b›*) by blast then show "e ❙∈ realise t1 ⊔ realise t2" proof (cases) (*goals: 1. ‹AT (s ∈⇩s t1) ∈ set b ⟹ e ❙∈ realise t1 ⊔ realise t2› 2. ‹AF (s ∈⇩s t1) ∈ set b ⟹ e ❙∈ realise t1 ⊔ realise t2›*) case 1 (*‹AT (s ∈⇩s t1) ∈ set b›*) with s (*‹(e::hf) = realise (s::'a::type pset_term)› ‹(s::'a pset_term) →⇘bgraph (b::'a pset_atom fm list)⇙ (t1::'a pset_term) ⊔⇩s (t2::'a pset_term)›*) show "?thesis" (*goal: ‹e ❙∈ realise t1 ⊔ realise t2›*) using realisation_if_AT_mem (*‹AT (?s ∈⇩s ?t) ∈ set b ⟹ realise ?s ❙∈ realise ?t›*) by auto next (*goal: ‹AF (s ∈⇩s t1) ∈ set b ⟹ e ❙∈ realise t1 ⊔ realise t2›*) case 2 (*‹AF (s ∈⇩s t1) ∈ set b›*) from ‹sat b› (*‹sat b›*) lexpands_un.intros(4)[OF ‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b› this] (*‹lexpands_un [AT ((s::'a pset_term) ∈⇩s (t2::'a pset_term))] (b::'a pset_atom fm list)›*) have "AT (s ∈⇩s t2) ∈ set b" unfolding sat_def (*goal: ‹AT ((s::'a::type pset_term) ∈⇩s (t2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list)›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) lexpands.intros(2) (*‹lexpands_un (?b'::?'a::type pset_atom fm list) (?b::?'a::type pset_atom fm list) ⟹ lexpands ?b' ?b›*) by force with s (*‹e = realise s› ‹s →⇘bgraph b⇙ t1 ⊔⇩s t2›*) show "?thesis" (*goal: ‹(e::hf) ❙∈ realise (t1::'a pset_term) ⊔ realise (t2::'a pset_term)›*) using realisation_if_AT_mem (*‹AT ((?s::'a::type pset_term) ∈⇩s (?t::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list) ⟹ realise ?s ❙∈ realise ?t›*) by auto qed qed moreover have "realise t1 ⊔ realise t2 ≤ realise (t1 ⊔⇩s t2)" proof (standard) (*goal: ‹⋀x. x ❙∈ realise t1 ⊔ realise t2 ⟹ x ❙∈ realise (t1 ⊔⇩s t2)›*) fix e assume "e ❙∈ realise t1 ⊔ realise t2" (*‹(e::hf) ❙∈ realise (t1::'a pset_term) ⊔ realise (t2::'a pset_term)›*) with ‹t1 ∈ subterms' b› (*‹t1 ∈ subterms' b›*) ‹t2 ∈ subterms' b› (*‹t2 ∈ subterms' b›*) consider s1 where "e = realise s1" and "s1 →⇘bgraph b⇙ t1" | s2 where "e = realise s2" and "s2 →⇘bgraph b⇙ t2" (*goal: ‹⟦⋀s1. ⟦e = realise s1; s1 →⇘bgraph b⇙ t1⟧ ⟹ thesis; ⋀s2. ⟦e = realise s2; s2 →⇘bgraph b⇙ t2⟧ ⟹ thesis⟧ ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise (?s::'a pset_term) ❙∈ realise (?t::'a pset_term); ⋀s'::'a pset_term. ⟦s' →⇘bgraph (b::'a pset_atom fm list)⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) by force then show "e ❙∈ realise (t1 ⊔⇩s t2)" proof (cases) (*goals: 1. ‹⋀s1. ⟦e = realise s1; s1 →⇘bgraph b⇙ t1⟧ ⟹ e ❙∈ realise (t1 ⊔⇩s t2)› 2. ‹⋀s2. ⟦e = realise s2; s2 →⇘bgraph b⇙ t2⟧ ⟹ e ❙∈ realise (t1 ⊔⇩s t2)›*) case 1 (*‹e = realise s1_› ‹s1_ →⇘bgraph b⇙ t1›*) then have "AT (s1 ∈⇩s t1) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (s1 ∈⇩s t1) ∈ set b›*) by (msorry) from ‹sat b› (*‹sat (b::'a pset_atom fm list)›*) lexpands_un.intros(2)[OF this mem_subterms_last, THEN lexpands.intros ( 2 )] (*‹lexpands [AT (s1 ∈⇩s t1 ⊔⇩s t2)] b›*) have "AT (s1 ∈⇩s t1 ⊔⇩s t2) ∈ set b" unfolding sat_def (*goal: ‹AT (s1 ∈⇩s t1 ⊔⇩s t2) ∈ set b›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) by force with "1" (*‹(e::hf) = realise (s1_::'a pset_term)› ‹s1_ →⇘bgraph b⇙ t1›*) realisation_if_AT_mem[OF this] (*‹realise (s1::'a::type pset_term) ❙∈ realise ((t1::'a::type pset_term) ⊔⇩s (t2::'a::type pset_term))›*) show "?thesis" (*goal: ‹e ❙∈ realise (t1 ⊔⇩s t2)›*) by (msorry) next (*goal: ‹⋀s2::'a::type pset_term. ⟦(e::hf) = realise s2; s2 →⇘bgraph (b::'a::type pset_atom fm list)⇙ (t2::'a::type pset_term)⟧ ⟹ e ❙∈ realise ((t1::'a::type pset_term) ⊔⇩s t2)›*) case 2 (*‹e = realise s2_› ‹s2_ →⇘bgraph b⇙ t2›*) then have "AT (s2 ∈⇩s t2) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (s2 ∈⇩s t2) ∈ set b›*) by (msorry) from ‹sat b› (*‹sat b›*) lexpands_un.intros(3)[OF this mem_subterms_last, THEN lexpands.intros ( 2 )] (*‹lexpands [AT (s2 ∈⇩s t1 ⊔⇩s t2)] b›*) have "AT (s2 ∈⇩s t1 ⊔⇩s t2) ∈ set b" unfolding sat_def (*goal: ‹AT (s2 ∈⇩s t1 ⊔⇩s t2) ∈ set b›*) using lin_satD (*‹⟦lin_sat (?b::?'a pset_atom fm list); lexpands (?b'::?'a pset_atom fm list) ?b; (?x::?'a pset_atom fm) ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) by force with "2" (*‹e = realise s2_› ‹s2_ →⇘bgraph b⇙ t2›*) realisation_if_AT_mem[OF this] (*‹realise s2 ❙∈ realise (t1 ⊔⇩s t2)›*) show "?thesis" (*goal: ‹e ❙∈ realise (t1 ⊔⇩s t2)›*) by (msorry) qed qed ultimately show "?thesis" (*goal: ‹realise (t1 ⊔⇩s t2) = realise t1 ⊔ realise t2›*) by blast qed lemma realisation_Inter: assumes "sat b" assumes "t1 ⊓⇩s t2 ∈ subterms b" shows "realise (t1 ⊓⇩s t2) = realise t1 ⊓ realise t2" using assms (*‹sat b› ‹(t1::'a pset_term) ⊓⇩s (t2::'a pset_term) ∈ subterms (b::'a pset_atom fm list)›*) proof (-) (*goal: ‹⟦sat (b::'a pset_atom fm list); (t1::'a pset_term) ⊓⇩s (t2::'a pset_term) ∈ subterms b⟧ ⟹ realise (t1 ⊓⇩s t2) = realise t1 ⊓ realise t2›*) from assms (*‹sat b› ‹t1 ⊓⇩s t2 ∈ subterms b›*) have mem_subterms_last: "t1 ⊓⇩s t2 ∈ subterms (last b)" using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch] (*‹⟦(?t::'a pset_term) ∈ subterms (b::'a pset_atom fm list); ¬ is_Var ?t⟧ ⟹ ?t ∈ subterms (last b)›*) by simp note not_urelem_comps_if_compound[where ?f = "(⊓⇩s)", OF assms ( 2 ), simplified] (*‹t1 ∉ urelems b› ‹t2 ∉ urelems b›*) moreover note subterms_fmD(3,4)[OF mem_subterms_last] (*‹(t1::'a::type pset_term) ∈ subterms (last (b::'a::type pset_atom fm list))› ‹(t2::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list))›*) then have "t1 ∉ Var ` pwits b" "t2 ∉ Var ` pwits b" unfolding pwits_def wits_def (*goals: 1. ‹t1 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹t2 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) using pset_term.set_intros(1) (*‹?x2.0 ∈ vars (Var ?x2.0)›*) mem_vars_fm_if_mem_subterms_fm (*‹⟦?x ∈ vars ?s; ?s ∈ subterms ?φ⟧ ⟹ ?x ∈ vars ?φ›*) apply - (*goals: 1. ‹⟦t1 ∈ subterms (last b); t2 ∈ subterms (last b); ⋀x2. x2 ∈ vars (Var x2); ⋀x s φ. ⟦x ∈ vars s; s ∈ subterms φ⟧ ⟹ x ∈ vars φ⟧ ⟹ t1 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹⟦t1 ∈ subterms (last b); t2 ∈ subterms (last b); ⋀x2. x2 ∈ vars (Var x2); ⋀x s φ. ⟦x ∈ vars s; s ∈ subterms φ⟧ ⟹ x ∈ vars φ⟧ ⟹ t2 ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . ultimately have t1_t2_subterms': "t1 ∈ subterms' b" "t2 ∈ subterms' b" unfolding subterms'_def base_vars_def (*goals: 1. ‹t1 ∈ subterms b - (Var ` pwits b ∪ urelems b)› 2. ‹t2 ∈ subterms b - (Var ` pwits b ∪ urelems b)›*) using assms(2) (*‹t1 ⊓⇩s t2 ∈ subterms b›*) apply - (*goals: 1. ‹⟦t1 ∉ urelems b; t2 ∉ urelems b; t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; t1 ⊓⇩s t2 ∈ subterms b⟧ ⟹ t1 ∈ subterms b - (Var ` pwits b ∪ urelems b)› 2. ‹⟦t1 ∉ urelems b; t2 ∉ urelems b; t1 ∉ Var ` pwits b; t2 ∉ Var ` pwits b; t1 ⊓⇩s t2 ∈ subterms b⟧ ⟹ t2 ∈ subterms b - (Var ` pwits b ∪ urelems b)› discuss goal 1*) apply ((auto dest: subterms_branchD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 2*) apply ((auto dest: subterms_branchD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*))[1]) (*proven 2 subgoals*) . from assms(2) (*‹t1 ⊓⇩s t2 ∈ subterms b›*) have "t1 ⊓⇩s t2 ∈ subterms' b" using base_vars_subs_vars (*‹base_vars (?b::?'a pset_atom fm list) ⊆ Var ` vars ?b›*) base_vars_Un_subterms'_eq_subterms (*‹base_vars (?b::?'a pset_atom fm list) ∪ subterms' ?b = subterms ?b›*) by blast have "realise (t1 ⊓⇩s t2) ≤ realise t1 ⊓ realise t2" proof (standard) (*goal: ‹⋀x. x ❙∈ realise (t1 ⊓⇩s t2) ⟹ x ❙∈ realise t1 ⊓ realise t2›*) fix e assume "e ❙∈ realise (t1 ⊓⇩s t2)" (*‹(e::hf) ❙∈ realise ((t1::'a pset_term) ⊓⇩s (t2::'a pset_term))›*) with ‹t1 ⊓⇩s t2 ∈ subterms' b› (*‹t1 ⊓⇩s t2 ∈ subterms' b›*) obtain s where s: "e = realise s" "s →⇘bgraph b⇙ (t1 ⊓⇩s t2)" (*goal: ‹(⋀s. ⟦e = realise s; s →⇘bgraph b⇙ t1 ⊓⇩s t2⟧ ⟹ thesis) ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise ?s ❙∈ realise ?t; ⋀s'. ⟦s' →⇘bgraph b⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by auto then have "AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b›*) by auto with ‹sat b› (*‹sat b›*) lexpands_int.intros(1)[OF this, THEN lexpands.intros ( 3 )] (*‹lexpands [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b›*) have "AT (s ∈⇩s t1) ∈ set b" "AT (s ∈⇩s t2) ∈ set b" unfolding sat_def (*goals: 1. ‹AT (s ∈⇩s t1) ∈ set b› 2. ‹AT (s ∈⇩s t2) ∈ set b›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) apply - (*goals: 1. ‹⟦lin_sat b ∧ (∄bs'. bexpands bs' b); lexpands [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; ⋀b b' x. ⟦lin_sat b; lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b⟧ ⟹ AT (s ∈⇩s t1) ∈ set b› 2. ‹⟦lin_sat b ∧ (∄bs'. bexpands bs' b); lexpands [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; ⋀b b' x. ⟦lin_sat b; lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b⟧ ⟹ AT (s ∈⇩s t2) ∈ set b› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . from this[THEN realisation_if_AT_mem] (*‹realise s ❙∈ realise t1› ‹realise (s::'a pset_term) ❙∈ realise (t2::'a pset_term)›*) s (*‹e = realise s› ‹s →⇘bgraph b⇙ t1 ⊓⇩s t2›*) show "e ❙∈ realise t1 ⊓ realise t2" by auto qed moreover have "realise t1 ⊓ realise t2 ≤ realise (t1 ⊓⇩s t2)" proof (standard) (*goal: ‹⋀x::hf. x ❙∈ realise (t1::'a pset_term) ⊓ realise (t2::'a pset_term) ⟹ x ❙∈ realise (t1 ⊓⇩s t2)›*) fix e assume "e ❙∈ realise t1 ⊓ realise t2" (*‹(e::hf) ❙∈ realise (t1::'a pset_term) ⊓ realise (t2::'a pset_term)›*) with ‹t1 ∈ subterms' b› (*‹t1 ∈ subterms' b›*) ‹t2 ∈ subterms' b› (*‹t2 ∈ subterms' b›*) obtain s1 and s2 where s1_s2: "e = realise s1" "s1 →⇘bgraph b⇙ t1" "e = realise s2" "s2 →⇘bgraph b⇙ t2" (*goal: ‹(⋀s1 s2. ⟦e = realise s1; s1 →⇘bgraph b⇙ t1; e = realise s2; s2 →⇘bgraph b⇙ t2⟧ ⟹ thesis) ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise ?s ❙∈ realise ?t; ⋀s'. ⟦s' →⇘bgraph b⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) apply auto (*goal: ‹(⋀s1 s2. ⟦e = realise s1; s1 →⇘bgraph b⇙ t1; e = realise s2; s2 →⇘bgraph b⇙ t2⟧ ⟹ thesis) ⟹ thesis›*) by metis then have "AT (s1 ∈⇩s t1) ∈ set b" "AT (s2 ∈⇩s t2) ∈ set b" unfolding bgraph_def Let_def (*goals: 1. ‹AT (s1 ∈⇩s t1) ∈ set b› 2. ‹AT (s2 ∈⇩s t2) ∈ set b›*) apply - (*goals: 1. ‹⟦e = realisation.realise ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ (base_vars b) (subterms' b) I eq s1; s1 →⇘⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈⇙ t1; e = realisation.realise ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ (base_vars b) (subterms' b) I eq s2; s2 →⇘⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈⇙ t2⟧ ⟹ AT (s1 ∈⇩s t1) ∈ set b› 2. ‹⟦e = realisation.realise ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ (base_vars b) (subterms' b) I eq s1; s1 →⇘⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈⇙ t1; e = realisation.realise ⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈ (base_vars b) (subterms' b) I eq s2; s2 →⇘⦇verts = base_vars b ∪ subterms' b, arcs = {(s, t). AT (s ∈⇩s t) ∈ set b}, tail = fst, head = snd⦈⇙ t2⟧ ⟹ AT (s2 ∈⇩s t2) ∈ set b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "AT (s1 ∈⇩s t2) ∈ set b" proof (-) (*goal: ‹AT (s1 ∈⇩s t2) ∈ set b›*) from ‹sat b› (*‹sat (b::'a pset_atom fm list)›*) have "AT (s1 ∈⇩s t2) ∈ set b ∨ AF (s1 ∈⇩s t2) ∈ set b" unfolding sat_def (*goal: ‹AT (s1 ∈⇩s t2) ∈ set b ∨ AF (s1 ∈⇩s t2) ∈ set b›*) using bexpands_nowit.intros(4)[OF ‹AT (s1 ∈⇩s t1) ∈ set b› mem_subterms_last] (*‹⟦AT ((s1::'a pset_term) ∈⇩s (t2::'a pset_term)) ∉ set (b::'a pset_atom fm list); AF (s1 ∈⇩s t2) ∉ set b⟧ ⟹ bexpands_nowit {[AT (s1 ∈⇩s t2)], [AF (s1 ∈⇩s t2)]} b›*) using bexpands.intros(1) (*‹bexpands_nowit (?bs'::?'a::type pset_atom fm list set) (?b::?'a::type pset_atom fm list) ⟹ bexpands ?bs' ?b›*) by blast moreover from ‹sat b› (*‹sat (b::'a pset_atom fm list)›*) s1_s2 (*‹e = realise s1› ‹s1 →⇘bgraph b⇙ t1› ‹e = realise s2› ‹s2 →⇘bgraph b⇙ t2›*) have False if "AF (s1 ∈⇩s t2) ∈ set b" proof (-) (*goal: ‹⟦sat b; e = realise s1; s1 →⇘bgraph b⇙ t1; e = realise s2; s2 →⇘bgraph b⇙ t2⟧ ⟹ False›*) note lexpands_eq.intros(5)[OF ‹AT (s2 ∈⇩s t2) ∈ set b› that, THEN lexpands.intros ( 6 )] (*‹lexpands [AF (s2 =⇩s s1)] b›*) with realisation_if_AF_eq[OF ‹sat b›, of s2 s1] (*‹AF (s2 =⇩s s1) ∈ set b ⟹ realise s2 ≠ realise s1›*) have "realise s2 ≠ realise s1" using ‹sat b› (*‹sat b›*) by (auto simp: sat_def (*‹sat (?b::?'a pset_atom fm list) ≡ lin_sat ?b ∧ (∄bs'::?'a pset_atom fm list set. bexpands bs' ?b)›*) lin_satD (*‹⟦lin_sat (?b::?'a pset_atom fm list); lexpands (?b'::?'a pset_atom fm list) ?b; (?x::?'a pset_atom fm) ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*)) with ‹e = realise s1› (*‹(e::hf) = realise (s1::'a::type pset_term)›*) ‹e = realise s2› (*‹(e::hf) = realise (s2::'a pset_term)›*) show False by simp qed ultimately show "AT (s1 ∈⇩s t2) ∈ set b" by blast qed ultimately have "AT (s1 ∈⇩s t1 ⊓⇩s t2) ∈ set b" using ‹sat b› (*‹sat b›*) lexpands_int.intros(6)[OF _ _ mem_subterms_last, THEN lexpands.intros ( 3 )] (*‹⟦AT ((?s1::'a::type pset_term) ∈⇩s (t1::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list); AT (?s1 ∈⇩s (t2::'a::type pset_term)) ∈ set b⟧ ⟹ lexpands [AT (?s1 ∈⇩s t1 ⊓⇩s t2)] b›*) unfolding sat_def (*goal: ‹AT (s1 ∈⇩s t1 ⊓⇩s t2) ∈ set b›*) by (fastforce simp: lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*)) from realisation_if_AT_mem[OF this] (*‹realise s1 ❙∈ realise (t1 ⊓⇩s t2)›*) show "e ❙∈ realise (t1 ⊓⇩s t2)" unfolding ‹e = realise s1› (*goal: ‹realise s1 ❙∈ realise (t1 ⊓⇩s t2)›*) by simp qed ultimately show "?thesis" (*goal: ‹realise (t1 ⊓⇩s t2) = realise t1 ⊓ realise t2›*) by blast qed lemma realisation_Diff: assumes "sat b" assumes "s -⇩s t ∈ subterms b" shows "realise (s -⇩s t) = realise s - realise t" using assms (*‹sat b› ‹s -⇩s t ∈ subterms b›*) proof (-) (*goal: ‹⟦sat b; s -⇩s t ∈ subterms b⟧ ⟹ realise (s -⇩s t) = realise s - realise t›*) from assms (*‹sat b› ‹s -⇩s t ∈ subterms b›*) have mem_subterms_last: "s -⇩s t ∈ subterms (last b)" using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch] (*‹⟦?t ∈ subterms b; ¬ is_Var ?t⟧ ⟹ ?t ∈ subterms (last b)›*) by simp note not_urelem_comps_if_compound[where ?f = "(-⇩s)", OF assms ( 2 ), simplified] (*‹s ∉ urelems b› ‹t ∉ urelems b›*) moreover note subterms_fmD(5,6)[OF mem_subterms_last] (*‹s ∈ subterms (last b)› ‹t ∈ subterms (last b)›*) then have "s ∉ Var ` pwits b" "t ∉ Var ` pwits b" unfolding pwits_def wits_def (*goals: 1. ‹s ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹t ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}›*) using pset_term.set_intros(1) (*‹(?x2.0::?'a::type) ∈ vars (Var ?x2.0)›*) mem_vars_fm_if_mem_subterms_fm (*‹⟦?x ∈ vars ?s; ?s ∈ subterms ?φ⟧ ⟹ ?x ∈ vars ?φ›*) apply - (*goals: 1. ‹⟦s ∈ subterms (last b); t ∈ subterms (last b); ⋀x2. x2 ∈ vars (Var x2); ⋀x s φ. ⟦x ∈ vars s; s ∈ subterms φ⟧ ⟹ x ∈ vars φ⟧ ⟹ s ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› 2. ‹⟦s ∈ subterms (last b); t ∈ subterms (last b); ⋀x2. x2 ∈ vars (Var x2); ⋀x s φ. ⟦x ∈ vars s; s ∈ subterms φ⟧ ⟹ x ∈ vars φ⟧ ⟹ t ∉ Var ` {c ∈ vars b - vars (last b). ∀t∈subterms (last b). AT (Var c =⇩s t) ∉ set b ∧ AT (t =⇩s Var c) ∉ set b}› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . ultimately have "s ∈ subterms' b" "t ∈ subterms' b" unfolding subterms'_def base_vars_def (*goals: 1. ‹s ∈ subterms b - (Var ` pwits b ∪ urelems b)› 2. ‹t ∈ subterms b - (Var ` pwits b ∪ urelems b)›*) using assms(2) (*‹s -⇩s t ∈ subterms b›*) apply - (*goals: 1. ‹⟦(s::'a pset_term) ∉ urelems (b::'a pset_atom fm list); (t::'a pset_term) ∉ urelems b; s ∉ Var ` pwits b; t ∉ Var ` pwits b; s -⇩s t ∈ subterms b⟧ ⟹ s ∈ subterms b - (Var ` pwits b ∪ urelems b)› 2. ‹⟦(s::'a pset_term) ∉ urelems (b::'a pset_atom fm list); (t::'a pset_term) ∉ urelems b; s ∉ Var ` pwits b; t ∉ Var ` pwits b; s -⇩s t ∈ subterms b⟧ ⟹ t ∈ subterms b - (Var ` pwits b ∪ urelems b)› discuss goal 1*) apply ((auto dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*discuss goal 2*) apply ((auto dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*))[1]) (*proven 2 subgoals*) . from assms(2) (*‹(s::'a pset_term) -⇩s (t::'a pset_term) ∈ subterms (b::'a pset_atom fm list)›*) have "s -⇩s t ∈ subterms' b" using base_vars_subs_vars (*‹base_vars (?b::?'a pset_atom fm list) ⊆ Var ` vars ?b›*) base_vars_Un_subterms'_eq_subterms (*‹base_vars ?b ∪ subterms' ?b = subterms ?b›*) by blast have "realise (s -⇩s t) ≤ realise s - realise t" proof (standard) (*goal: ‹⋀x. x ❙∈ realise (s -⇩s t) ⟹ x ❙∈ realise s - realise t›*) fix e assume "e ❙∈ realise (s -⇩s t)" (*‹(e::hf) ❙∈ realise ((s::'a pset_term) -⇩s (t::'a pset_term))›*) then obtain u where u: "e = realise u" "u →⇘bgraph b⇙ (s -⇩s t)" (*goal: ‹(⋀u. ⟦e = realise u; u →⇘bgraph b⇙ s -⇩s t⟧ ⟹ thesis) ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise ?s ❙∈ realise ?t; ⋀s'. ⟦s' →⇘bgraph b⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹s -⇩s t ∈ subterms' b› (*‹s -⇩s t ∈ subterms' b›*) by auto then have "AT (u ∈⇩s s -⇩s t) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (u ∈⇩s s -⇩s t) ∈ set b›*) by auto with ‹sat b› (*‹sat (b::'a pset_atom fm list)›*) lexpands_diff.intros(1)[OF this, THEN lexpands.intros ( 4 )] (*‹lexpands [AT ((u::'a pset_term) ∈⇩s (s::'a pset_term)), AF (u ∈⇩s (t::'a pset_term))] (b::'a pset_atom fm list)›*) have "AT (u ∈⇩s s) ∈ set b" "AF (u ∈⇩s t) ∈ set b" unfolding sat_def (*goals: 1. ‹AT (u ∈⇩s s) ∈ set b› 2. ‹AF (u ∈⇩s t) ∈ set b›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) apply - (*goals: 1. ‹⟦lin_sat b ∧ (∄bs'. bexpands bs' b); lexpands [AT (u ∈⇩s s), AF (u ∈⇩s t)] b; AT (u ∈⇩s s -⇩s t) ∈ set b; ⋀b b' x. ⟦lin_sat b; lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b⟧ ⟹ AT (u ∈⇩s s) ∈ set b› 2. ‹⟦lin_sat b ∧ (∄bs'. bexpands bs' b); lexpands [AT (u ∈⇩s s), AF (u ∈⇩s t)] b; AT (u ∈⇩s s -⇩s t) ∈ set b; ⋀b b' x. ⟦lin_sat b; lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b⟧ ⟹ AF (u ∈⇩s t) ∈ set b› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . with u (*‹e = realise u› ‹u →⇘bgraph b⇙ s -⇩s t›*) show "e ❙∈ realise s - realise t" using ‹sat b› (*‹sat b›*) realisation_if_AT_mem (*‹AT (?s ∈⇩s ?t) ∈ set b ⟹ realise ?s ❙∈ realise ?t›*) realisation_if_AF_mem (*‹⟦sat b; AF (?s ∈⇩s ?t) ∈ set b⟧ ⟹ realise ?s ❙∉ realise ?t›*) by auto qed moreover have "realise s - realise t ≤ realise (s -⇩s t)" proof (standard) (*goal: ‹⋀x. x ❙∈ realise s - realise t ⟹ x ❙∈ realise (s -⇩s t)›*) fix e assume "e ❙∈ realise s - realise t" (*‹(e::hf) ❙∈ realise (s::'a pset_term) - realise (t::'a pset_term)›*) then obtain u where u: "e = realise u" "u →⇘bgraph b⇙ s" "¬ u →⇘bgraph b⇙ t" (*goal: ‹(⋀u. ⟦e = realise u; u →⇘bgraph b⇙ s; (u, t) ∉ arcs_ends (bgraph b)⟧ ⟹ thesis) ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise ?s ❙∈ realise ?t; ⋀s'. ⟦s' →⇘bgraph b⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) ‹s ∈ subterms' b› (*‹s ∈ subterms' b›*) ‹t ∈ subterms' b› (*‹t ∈ subterms' b›*) by auto then have "AT (u ∈⇩s s) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (u ∈⇩s s) ∈ set b›*) by auto moreover have "AF (u ∈⇩s t) ∈ set b" proof (-) (*goal: ‹AF (u ∈⇩s t) ∈ set b›*) from ‹sat b› (*‹sat b›*) have "AT (u ∈⇩s t) ∈ set b ∨ AF (u ∈⇩s t) ∈ set b" unfolding sat_def (*goal: ‹AT (u ∈⇩s t) ∈ set b ∨ AF (u ∈⇩s t) ∈ set b›*) using bexpands_nowit.intros(5)[OF ‹AT (u ∈⇩s s) ∈ set b› mem_subterms_last] (*‹⟦AT (u ∈⇩s t) ∉ set b; AF (u ∈⇩s t) ∉ set b⟧ ⟹ bexpands_nowit {[AT (u ∈⇩s t)], [AF (u ∈⇩s t)]} b›*) using bexpands.intros(1) (*‹bexpands_nowit ?bs' ?b ⟹ bexpands ?bs' ?b›*) by blast moreover from u(3) (*‹(u::'a pset_term, t::'a pset_term) ∉ arcs_ends (bgraph (b::'a pset_atom fm list))›*) have False if "AT (u ∈⇩s t) ∈ set b" using that (*‹AT (u ∈⇩s t) ∈ set b›*) unfolding Let_def bgraph_def (*goal: ‹False›*) by (auto simp: arcs_ends_def (*‹arcs_ends ?G ≡ arc_to_ends ?G ` arcs ?G›*) arc_to_ends_def (*‹arc_to_ends ?G ?e ≡ (tail ?G ?e, head ?G ?e)›*)) ultimately show "AF (u ∈⇩s t) ∈ set b" by blast qed ultimately have "AT (u ∈⇩s s -⇩s t) ∈ set b" using ‹sat b› (*‹sat b›*) lexpands_diff.intros(6)[OF _ _ mem_subterms_last, THEN lexpands.intros ( 4 )] (*‹⟦AT (?s1 ∈⇩s s) ∈ set b; AF (?s1 ∈⇩s t) ∈ set b⟧ ⟹ lexpands [AT (?s1 ∈⇩s s -⇩s t)] b›*) unfolding sat_def (*goal: ‹AT (u ∈⇩s s -⇩s t) ∈ set b›*) by (fastforce simp: lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*)) from realisation_if_AT_mem[OF this] (*‹realise u ❙∈ realise (s -⇩s t)›*) show "e ❙∈ realise (s -⇩s t)" unfolding ‹e = realise u› (*goal: ‹realise u ❙∈ realise (s -⇩s t)›*) by simp qed ultimately show "?thesis" (*goal: ‹realise (s -⇩s t) = realise s - realise t›*) by blast qed lemma realisation_Single: assumes "sat b" assumes "Single t ∈ subterms b" shows "realise (Single t) = HF {realise t}" using assms (*‹sat b› ‹Single t ∈ subterms b›*) proof (-) (*goal: ‹⟦sat (b::'a pset_atom fm list); Single (t::'a pset_term) ∈ subterms b⟧ ⟹ realise (Single t) = HF {realise t}›*) from assms (*‹sat b› ‹Single (t::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list)›*) have mem_subterms_last: "Single t ∈ subterms (last b)" using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch] (*‹⟦?t ∈ subterms b; ¬ is_Var ?t⟧ ⟹ ?t ∈ subterms (last b)›*) by simp have "Single t ∈ subterms' b" proof (-) (*goal: ‹Single t ∈ subterms' b›*) from urelems_subs_vars (*‹urelems ?b ⊆ Var ` vars ?b›*) have "Single t ∉ base_vars b" unfolding base_vars_def (*goal: ‹Single t ∉ Var ` pwits b ∪ urelems b›*) by blast then show "?thesis" (*goal: ‹Single t ∈ subterms' b›*) by (simp add: assms( (*‹Single (t::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list)›*) 2) subterms'_def (*‹subterms' (?b::?'a::type pset_atom fm list) ≡ subterms ?b - base_vars ?b›*)) qed have "realise (Single t) ≤ HF {realise t}" proof (standard) (*goal: ‹⋀x. x ❙∈ realise (Single t) ⟹ x ❙∈ HF {realise t}›*) fix e assume "e ❙∈ realise (Single t)" (*‹(e::hf) ❙∈ realise (Single (t::'a pset_term))›*) then obtain s where s: "e = realise s" "s →⇘bgraph b⇙ Single t" (*goal: ‹(⋀s. ⟦e = realise s; s →⇘bgraph b⇙ Single t⟧ ⟹ thesis) ⟹ thesis›*) using dominates_if_mem_realisation (*‹⟦realise (?s::'a pset_term) ❙∈ realise (?t::'a pset_term); ⋀s'::'a pset_term. ⟦s' →⇘bgraph (b::'a pset_atom fm list)⇙ ?t; realise ?s = realise s'⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) ‹Single t ∈ subterms' b› (*‹Single (t::'a::type pset_term) ∈ subterms' (b::'a::type pset_atom fm list)›*) by auto then have "AT (s ∈⇩s Single t) ∈ set b" unfolding bgraph_def Let_def (*goal: ‹AT (s ∈⇩s Single t) ∈ set b›*) by auto with ‹sat b› (*‹sat (b::'a pset_atom fm list)›*) lexpands_single.intros(2)[OF this, THEN lexpands.intros ( 5 )] (*‹lexpands [AT ((s::'a::type pset_term) =⇩s (t::'a::type pset_term))] (b::'a::type pset_atom fm list)›*) have "AT (s =⇩s t) ∈ set b" unfolding sat_def (*goal: ‹AT (s =⇩s t) ∈ set b›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) by fastforce with s (*‹e = realise s› ‹s →⇘bgraph b⇙ Single t›*) show "e ❙∈ HF {realise t}" using realisation_if_AT_eq (*‹⟦lin_sat b; AT (?s =⇩s ?t) ∈ set b⟧ ⟹ realise ?s = realise ?t›*) ‹sat b›[unfolded sat_def] (*‹lin_sat b ∧ (∄bs'. bexpands bs' b)›*) by auto qed moreover have "HF {realise t} ≤ realise (Single t)" proof (standard) (*goal: ‹⋀x. x ❙∈ HF {realise t} ⟹ x ❙∈ realise (Single t)›*) fix e assume "e ❙∈ HF {realise t}" (*‹(e::hf) ❙∈ HF {realise (t::'a pset_term)}›*) then have "e = realise t" by simp from lexpands_single.intros(1)[OF mem_subterms_last, THEN lexpands.intros ( 5 )] (*‹lexpands [AT (t ∈⇩s Single t)] b›*) ‹sat b› (*‹sat b›*) have "AT (t ∈⇩s Single t) ∈ set b" unfolding sat_def (*goal: ‹AT (t ∈⇩s Single t) ∈ set b›*) using lin_satD (*‹⟦lin_sat ?b; lexpands ?b' ?b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set ?b›*) by fastforce from realisation_if_AT_mem[OF this] (*‹realise t ❙∈ realise (Single t)›*) ‹e = realise t› (*‹e = realise t›*) show "e ❙∈ realise (Single t)" by simp qed ultimately show "?thesis" (*goal: ‹realise (Single t) = HF {realise t}›*) by blast qed lemmas realisation_simps = realisation_Empty realisation_Union realisation_Inter realisation_Diff realisation_Single end subsubsection ‹Coherence› lemma (in open_branch) I⇩s⇩t_realisation_eq_realisation: assumes "sat b" "t ∈ subterms b" shows "I⇩s⇩t (λx. realise (Var x)) t = realise t" using assms (*‹sat (b::'a::type pset_atom fm list)› ‹t ∈ subterms b›*) apply (induction t) (*goals: 1. ‹⋀x. ⟦sat b; ∅ x ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) ∅ x = realise ∅ x› 2. ‹⋀x. ⟦sat b; Var x ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) (Var x) = realise (Var x)› 3. ‹⋀t1 t2. ⟦⟦sat b; t1 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t1 = realise t1; ⟦sat b; t2 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t2 = realise t2; sat b; t1 ⊔⇩s t2 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) (t1 ⊔⇩s t2) = realise (t1 ⊔⇩s t2)› 4. ‹⋀t1 t2. ⟦⟦sat b; t1 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t1 = realise t1; ⟦sat b; t2 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t2 = realise t2; sat b; t1 ⊓⇩s t2 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) (t1 ⊓⇩s t2) = realise (t1 ⊓⇩s t2)› 5. ‹⋀t1 t2. ⟦⟦sat b; t1 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t1 = realise t1; ⟦sat b; t2 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t2 = realise t2; sat b; t1 -⇩s t2 ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) (t1 -⇩s t2) = realise (t1 -⇩s t2)› 6. ‹⋀t. ⟦⟦sat b; t ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) t = realise t; sat b; Single t ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) (Single t) = realise (Single t)› discuss goal 1*) apply (force simp: realisation_simps (*‹realise ∅ ?n = 0› ‹⟦sat b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊔⇩s ?t2.0) = realise ?t1.0 ⊔ realise ?t2.0› ‹⟦sat b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊓⇩s ?t2.0) = realise ?t1.0 ⊓ realise ?t2.0› ‹⟦sat b; ?s -⇩s ?t ∈ subterms b⟧ ⟹ realise (?s -⇩s ?t) = realise ?s - realise ?t› ‹⟦sat b; Single ?t ∈ subterms b⟧ ⟹ realise (Single ?t) = HF {realise ?t}›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*)) (*discuss goal 2*) apply (force simp: realisation_simps (*‹realise ∅ ?n::nat = (0::hf)› ‹⟦sat (b::'a pset_atom fm list); (?t1.0::'a pset_term) ⊔⇩s (?t2.0::'a pset_term) ∈ subterms b⟧ ⟹ realise (?t1.0 ⊔⇩s ?t2.0) = realise ?t1.0 ⊔ realise ?t2.0› ‹⟦sat (b::'a pset_atom fm list); (?t1.0::'a pset_term) ⊓⇩s (?t2.0::'a pset_term) ∈ subterms b⟧ ⟹ realise (?t1.0 ⊓⇩s ?t2.0) = realise ?t1.0 ⊓ realise ?t2.0› ‹⟦sat (b::'a pset_atom fm list); (?s::'a pset_term) -⇩s (?t::'a pset_term) ∈ subterms b⟧ ⟹ realise (?s -⇩s ?t) = realise ?s - realise ?t› ‹⟦sat (b::'a pset_atom fm list); Single (?t::'a pset_term) ∈ subterms b⟧ ⟹ realise (Single ?t) = HF {realise ?t}›*) dest: subterms_branchD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*)) (*discuss goal 3*) apply (force simp: realisation_simps (*‹realise ∅ ?n = 0› ‹⟦sat b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊔⇩s ?t2.0) = realise ?t1.0 ⊔ realise ?t2.0› ‹⟦sat b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊓⇩s ?t2.0) = realise ?t1.0 ⊓ realise ?t2.0› ‹⟦sat b; ?s -⇩s ?t ∈ subterms b⟧ ⟹ realise (?s -⇩s ?t) = realise ?s - realise ?t› ‹⟦sat b; Single ?t ∈ subterms b⟧ ⟹ realise (Single ?t) = HF {realise ?t}›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*)) (*discuss goal 4*) apply (force simp: realisation_simps (*‹realise ∅ ?n = 0› ‹⟦sat b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊔⇩s ?t2.0) = realise ?t1.0 ⊔ realise ?t2.0› ‹⟦sat b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊓⇩s ?t2.0) = realise ?t1.0 ⊓ realise ?t2.0› ‹⟦sat b; ?s -⇩s ?t ∈ subterms b⟧ ⟹ realise (?s -⇩s ?t) = realise ?s - realise ?t› ‹⟦sat b; Single ?t ∈ subterms b⟧ ⟹ realise (Single ?t) = HF {realise ?t}›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*)) (*discuss goal 5*) apply (force simp: realisation_simps (*‹realise ∅ ?n = 0› ‹⟦sat b; ?t1.0 ⊔⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊔⇩s ?t2.0) = realise ?t1.0 ⊔ realise ?t2.0› ‹⟦sat b; ?t1.0 ⊓⇩s ?t2.0 ∈ subterms b⟧ ⟹ realise (?t1.0 ⊓⇩s ?t2.0) = realise ?t1.0 ⊓ realise ?t2.0› ‹⟦sat b; ?s -⇩s ?t ∈ subterms b⟧ ⟹ realise (?s -⇩s ?t) = realise ?s - realise ?t› ‹⟦sat b; Single ?t ∈ subterms b⟧ ⟹ realise (Single ?t) = HF {realise ?t}›*) dest: subterms_branchD (*‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊔⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 ⊓⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t1.0 ∈ subterms ?b› ‹?t1.0 -⇩s ?t2.0 ∈ subterms ?b ⟹ ?t2.0 ∈ subterms ?b› ‹Single ?t ∈ subterms ?b ⟹ ?t ∈ subterms ?b›*)) (*discuss goal 6*) apply (force simp: realisation_simps (*‹realise ∅ ?n::nat = (0::hf)› ‹⟦sat (b::'a pset_atom fm list); (?t1.0::'a pset_term) ⊔⇩s (?t2.0::'a pset_term) ∈ subterms b⟧ ⟹ realise (?t1.0 ⊔⇩s ?t2.0) = realise ?t1.0 ⊔ realise ?t2.0› ‹⟦sat (b::'a pset_atom fm list); (?t1.0::'a pset_term) ⊓⇩s (?t2.0::'a pset_term) ∈ subterms b⟧ ⟹ realise (?t1.0 ⊓⇩s ?t2.0) = realise ?t1.0 ⊓ realise ?t2.0› ‹⟦sat (b::'a pset_atom fm list); (?s::'a pset_term) -⇩s (?t::'a pset_term) ∈ subterms b⟧ ⟹ realise (?s -⇩s ?t) = realise ?s - realise ?t› ‹⟦sat (b::'a pset_atom fm list); Single (?t::'a pset_term) ∈ subterms b⟧ ⟹ realise (Single ?t) = HF {realise ?t}›*) dest: subterms_branchD (*‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊔⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) ⊓⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t1.0 ∈ subterms ?b› ‹(?t1.0::?'a pset_term) -⇩s (?t2.0::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms ?b› ‹Single (?t::?'a pset_term) ∈ subterms (?b::?'a pset_atom fm list) ⟹ ?t ∈ subterms ?b›*)) (*proven 6 subgoals*) . lemma (in open_branch) coherence: assumes "sat b" "φ ∈ set b" shows "interp I⇩s⇩a (λx. realise (Var x)) φ" using assms (*‹sat b› ‹φ ∈ set b›*) proof (induction "size φ" arbitrary: φ rule: less_induct) (*goal: ‹⋀φ::'a::type pset_atom fm. ⟦⋀φ'::'a::type pset_atom fm. ⟦size φ' < size φ; sat (b::'a::type pset_atom fm list); φ' ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) φ'; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) φ›*) case less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) then show "?case" (*goal: ‹interp I⇩s⇩a (λx::'a. realise (Var x)) (φ::'a pset_atom fm)›*) proof (cases φ) (*goals: 1. ‹⋀x1::'a pset_atom. ⟦⋀φ::'a pset_atom fm. ⟦size φ < size (φ::'a pset_atom fm); sat (b::'a pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ; sat b; φ ∈ set b; φ = AT x1⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ› 2. ‹⋀(x21::'a pset_atom fm) x22::'a pset_atom fm. ⟦⋀φ::'a pset_atom fm. ⟦size φ < size (φ::'a pset_atom fm); sat (b::'a pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ; sat b; φ ∈ set b; φ = And x21 x22⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ› 3. ‹⋀(x31::'a pset_atom fm) x32::'a pset_atom fm. ⟦⋀φ::'a pset_atom fm. ⟦size φ < size (φ::'a pset_atom fm); sat (b::'a pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ; sat b; φ ∈ set b; φ = Or x31 x32⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ› 4. ‹⋀x4::'a pset_atom fm. ⟦⋀φ::'a pset_atom fm. ⟦size φ < size (φ::'a pset_atom fm); sat (b::'a pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ; sat b; φ ∈ set b; φ = Neg x4⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ›*) case (Atom a) (*‹φ = AT a›*) then show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) proof (cases a) (*goals: 1. ‹⋀x11 x12. ⟦φ = AT a; a = x11 ∈⇩s x12⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 2. ‹⋀x21 x22. ⟦φ = AT a; a = x21 =⇩s x22⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (Elem s t) (*‹a = s ∈⇩s t›*) with Atom (*‹(φ::'a pset_atom fm) = AT (a::'a pset_atom)›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) have "s ∈ subterms b" "t ∈ subterms b" using AT_mem_subterms_branchD (*‹AT ((?s::?'a::type pset_term) ∈⇩s (?t::?'a::type pset_term)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AT (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⟦φ = AT a; ⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; a = s ∈⇩s t; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ s ∈ subterms b› 2. ‹⟦φ = AT a; ⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; a = s ∈⇩s t; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AT (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ t ∈ subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with Atom (*‹φ = AT a›*) Elem (*‹(a::'a pset_atom) = (s::'a pset_term) ∈⇩s (t::'a pset_term)›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) using "I⇩s⇩t_realisation_eq_realisation"[OF ‹sat b›] (*‹(?t::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list) ⟹ I⇩s⇩t (λx::'a::type. realise (Var x)) ?t = realise ?t›*) realisation_if_AT_mem (*‹AT (?s ∈⇩s ?t) ∈ set b ⟹ realise ?s ❙∈ realise ?t›*) by auto next (*goal: ‹⋀x21 x22. ⟦φ = AT a; a = x21 =⇩s x22⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (Equal s t) (*‹a = s =⇩s t›*) with Atom (*‹φ = AT a›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat (b::'a pset_atom fm list)› ‹(φ::'a::type pset_atom fm) ∈ set (b::'a::type pset_atom fm list)›*) have "s ∈ subterms b" "t ∈ subterms b" using AT_eq_subterms_branchD (*‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AT (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⟦(φ::'a pset_atom fm) = AT (a::'a pset_atom); ⋀φ::'a pset_atom fm. ⟦size φ < size φ; sat (b::'a pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ; sat b; φ ∈ set b; a = (s::'a pset_term) =⇩s (t::'a pset_term); ⋀(s::?'a18 pset_term) (t::?'a18 pset_term) b::?'a18 pset_atom fm list. AT (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀(s::?'a20 pset_term) (t::?'a20 pset_term) b::?'a20 pset_atom fm list. AT (s =⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ s ∈ subterms b› 2. ‹⟦(φ::'a pset_atom fm) = AT (a::'a pset_atom); ⋀φ::'a pset_atom fm. ⟦size φ < size φ; sat (b::'a pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) φ; sat b; φ ∈ set b; a = (s::'a pset_term) =⇩s (t::'a pset_term); ⋀(s::?'a7 pset_term) (t::?'a7 pset_term) b::?'a7 pset_atom fm list. AT (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀(s::?'a9 pset_term) (t::?'a9 pset_term) b::?'a9 pset_atom fm list. AT (s =⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ t ∈ subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with Atom (*‹φ = AT a›*) Equal (*‹a = s =⇩s t›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) satD(1)[OF ‹sat b›] (*‹lin_sat b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx::'a::type. realise (Var x)) (φ::'a::type pset_atom fm)›*) using "I⇩s⇩t_realisation_eq_realisation"[OF ‹sat b›] (*‹(?t::'a::type pset_term) ∈ subterms (b::'a::type pset_atom fm list) ⟹ I⇩s⇩t (λx::'a::type. realise (Var x)) ?t = realise ?t›*) realisation_if_AT_eq (*‹⟦lin_sat (b::'a::type pset_atom fm list); AT ((?s::'a::type pset_term) =⇩s (?t::'a::type pset_term)) ∈ set b⟧ ⟹ realise ?s = realise ?t›*) by auto qed next (*goals: 1. ‹⋀x21 x22. ⟦⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; φ = And x21 x22⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 2. ‹⋀x31 x32. ⟦⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; φ = Or x31 x32⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 3. ‹⋀x4. ⟦⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; φ = Neg x4⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (And φ1 φ2) (*‹φ = And φ1 φ2›*) with ‹φ ∈ set b› (*‹(φ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list)›*) ‹sat b›[THEN satD ( 1 ), THEN lin_satD] (*‹⟦lexpands (?b'::'a pset_atom fm list) (b::'a pset_atom fm list); (?x::'a pset_atom fm) ∈ set ?b'⟧ ⟹ ?x ∈ set b›*) have "φ1 ∈ set b" "φ2 ∈ set b" using lexpands_fm.intros(1)[THEN lexpands.intros ( 1 )] (*‹And ?p1 ?q1 ∈ set ?b ⟹ lexpands [?p1, ?q1] ?b›*) apply - (*goals: 1. ‹⟦φ ∈ set b; ⋀b' x. ⟦lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b; φ = And φ1 φ2; ⋀p q b. And p q ∈ set b ⟹ lexpands [p, q] b⟧ ⟹ φ1 ∈ set b› 2. ‹⟦φ ∈ set b; ⋀b' x. ⟦lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b; φ = And φ1 φ2; ⋀p q b. And p q ∈ set b ⟹ lexpands [p, q] b⟧ ⟹ φ2 ∈ set b› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . with And (*‹φ = And φ1 φ2›*) less (*‹⟦size (?φ1::'a pset_atom fm) < size (φ::'a pset_atom fm); sat (b::'a pset_atom fm list); ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) by simp next (*goals: 1. ‹⋀x31 x32. ⟦⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; φ = Or x31 x32⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 2. ‹⋀x4. ⟦⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; φ = Neg x4⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (Or φ1 φ2) (*‹φ = Or φ1 φ2›*) with ‹φ ∈ set b› (*‹φ ∈ set b›*) ‹sat b›[THEN satD ( 2 )] (*‹∄bs'. bexpands bs' b›*) have "φ1 ∈ set b ∨ Neg φ1 ∈ set b" using bexpands_nowit.intros(1)[THEN bexpands.intros ( 1 )] (*‹⟦Or ?p1 ?q1 ∈ set ?b; ?p1 ∉ set ?b; Neg ?p1 ∉ set ?b⟧ ⟹ bexpands {[?p1], [Neg ?p1]} ?b›*) by blast with less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat (b::'a pset_atom fm list)› ‹φ ∈ set b›*) Or (*‹φ = Or φ1 φ2›*) ‹sat b›[THEN satD ( 1 ), THEN lin_satD] (*‹⟦lexpands ?b' b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set b›*) have "φ1 ∈ set b ∨ φ2 ∈ set b" using lexpands_fm.intros(3)[THEN lexpands.intros ( 1 )] (*‹⟦Or ?p1 ?q1 ∈ set ?b; Neg ?p1 ∈ set ?b⟧ ⟹ lexpands [?q1] ?b›*) by fastforce with Or (*‹φ = Or φ1 φ2›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) by force next (*goal: ‹⋀x4::'a::type pset_atom fm. ⟦⋀φ::'a::type pset_atom fm. ⟦size φ < size (φ::'a::type pset_atom fm); sat (b::'a::type pset_atom fm list); φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) φ; sat b; φ ∈ set b; φ = Neg x4⟧ ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) φ›*) case (Neg φ') (*‹φ = Neg φ'›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) proof (cases φ') (*goals: 1. ‹⋀x1. φ' = AT x1 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 2. ‹⋀x21 x22. φ' = And x21 x22 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 3. ‹⋀x31 x32. φ' = Or x31 x32 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 4. ‹⋀x4. φ' = Neg x4 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (Atom a) (*‹φ' = AT a›*) then show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) proof (cases a) (*goals: 1. ‹⋀x11 x12. ⟦φ' = AT a; a = x11 ∈⇩s x12⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 2. ‹⋀x21 x22. ⟦φ' = AT a; a = x21 =⇩s x22⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (Elem s t) (*‹a = s ∈⇩s t›*) with Atom (*‹(φ'::'a pset_atom fm) = AT (a::'a pset_atom)›*) Neg (*‹φ = Neg φ'›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) have "s ∈ subterms b" "t ∈ subterms b" using AF_mem_subterms_branchD (*‹AF ((?s::?'a pset_term) ∈⇩s (?t::?'a pset_term)) ∈ set (?b::?'a pset_atom fm list) ⟹ ?s ∈ subterms ?b› ‹AF (?s ∈⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⟦φ' = AT a; φ = Neg φ'; ⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; a = s ∈⇩s t; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ s ∈ subterms b› 2. ‹⟦φ' = AT a; φ = Neg φ'; ⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; a = s ∈⇩s t; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s ∈⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ t ∈ subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with Neg (*‹φ = Neg φ'›*) Atom (*‹φ' = AT a›*) Elem (*‹a = s ∈⇩s t›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) using "I⇩s⇩t_realisation_eq_realisation" (*‹⟦sat b; ?t ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) ?t = realise ?t›*) realisation_if_AF_mem (*‹⟦sat (b::'a pset_atom fm list); AF ((?s::'a pset_term) ∈⇩s (?t::'a pset_term)) ∈ set b⟧ ⟹ realise ?s ❙∉ realise ?t›*) ‹sat b› (*‹sat (b::'a::type pset_atom fm list)›*) by auto next (*goal: ‹⋀(x21::'a pset_term) x22::'a pset_term. ⟦(φ'::'a pset_atom fm) = AT (a::'a pset_atom); a = x21 =⇩s x22⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) (φ::'a pset_atom fm)›*) case (Equal s t) (*‹a = s =⇩s t›*) with Atom (*‹φ' = AT a›*) Neg (*‹φ = Neg φ'›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) have "s ∈ subterms b" "t ∈ subterms b" using AF_eq_subterms_branchD (*‹AF (?s =⇩s ?t) ∈ set ?b ⟹ ?s ∈ subterms ?b› ‹AF (?s =⇩s ?t) ∈ set ?b ⟹ ?t ∈ subterms ?b›*) apply - (*goals: 1. ‹⟦φ' = AT a; φ = Neg φ'; ⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; a = s =⇩s t; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ s ∈ subterms b› 2. ‹⟦φ' = AT a; φ = Neg φ'; ⋀φ. ⟦size φ < size φ; sat b; φ ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ; sat b; φ ∈ set b; a = s =⇩s t; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ s ∈ subterms b; ⋀s t b. AF (s =⇩s t) ∈ set b ⟹ t ∈ subterms b⟧ ⟹ t ∈ subterms b› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . with Neg (*‹φ = Neg φ'›*) Atom (*‹(φ'::'a pset_atom fm) = AT (a::'a pset_atom)›*) Equal (*‹(a::'a pset_atom) = (s::'a pset_term) =⇩s (t::'a pset_term)›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx::'a. realise (Var x)) (φ::'a pset_atom fm)›*) using "I⇩s⇩t_realisation_eq_realisation" (*‹⟦sat b; ?t ∈ subterms b⟧ ⟹ I⇩s⇩t (λx. realise (Var x)) ?t = realise ?t›*) realisation_if_AF_eq (*‹⟦sat b; AF (?t1.0 =⇩s ?t2.0) ∈ set b⟧ ⟹ realise ?t1.0 ≠ realise ?t2.0›*) ‹sat b› (*‹sat b›*) by auto qed next (*goals: 1. ‹⋀x21 x22. φ' = And x21 x22 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 2. ‹⋀x31 x32. φ' = Or x31 x32 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ› 3. ‹⋀x4. φ' = Neg x4 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case (And φ1 φ2) (*‹φ' = And φ1 φ2›*) with Neg (*‹φ = Neg φ'›*) ‹sat b›[THEN satD ( 2 )] (*‹∄bs'. bexpands bs' b›*) less (*‹⟦size (?φ1::'a::type pset_atom fm) < size (φ::'a::type pset_atom fm); sat (b::'a::type pset_atom fm list); ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) have "φ1 ∈ set b ∨ Neg φ1 ∈ set b" using bexpands_nowit.intros(2)[THEN bexpands.intros ( 1 )] (*‹⟦Neg (And ?p1 ?q1) ∈ set ?b; Neg ?p1 ∉ set ?b; ?p1 ∉ set ?b⟧ ⟹ bexpands {[Neg ?p1], [?p1]} ?b›*) by blast with ‹sat b›[THEN satD ( 1 ), THEN lin_satD] (*‹⟦lexpands ?b' b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set b›*) Neg (*‹(φ::'a::type pset_atom fm) = Neg (φ'::'a::type pset_atom fm)›*) And (*‹φ' = And φ1 φ2›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) have "Neg φ2 ∈ set b ∨ Neg φ1 ∈ set b" using lexpands_fm.intros(5)[THEN lexpands.intros ( 1 )] (*‹⟦Neg (And ?p1 ?q1) ∈ set ?b; ?p1 ∈ set ?b⟧ ⟹ lexpands [Neg ?q1] ?b›*) by fastforce with Neg (*‹φ = Neg φ'›*) And (*‹φ' = And φ1 φ2›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) by force next (*goals: 1. ‹⋀(x31::'a::type pset_atom fm) x32::'a::type pset_atom fm. (φ'::'a::type pset_atom fm) = Or x31 x32 ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) (φ::'a::type pset_atom fm)› 2. ‹⋀x4::'a::type pset_atom fm. (φ'::'a::type pset_atom fm) = Neg x4 ⟹ interp I⇩s⇩a (λx::'a::type. realise (Var x)) (φ::'a::type pset_atom fm)›*) case (Or φ1 φ2) (*‹φ' = Or φ1 φ2›*) with ‹φ ∈ set b› (*‹φ ∈ set b›*) Neg (*‹φ = Neg φ'›*) ‹sat b›[THEN satD ( 1 ), THEN lin_satD] (*‹⟦lexpands ?b' b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set b›*) have "Neg φ1 ∈ set b" "Neg φ2 ∈ set b" using lexpands_fm.intros(2)[THEN lexpands.intros ( 1 )] (*‹Neg (Or ?p1 ?q1) ∈ set ?b ⟹ lexpands [Neg ?p1, Neg ?q1] ?b›*) apply - (*goals: 1. ‹⟦φ ∈ set b; φ = Neg φ'; ⋀b' x. ⟦lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b; φ' = Or φ1 φ2; ⋀p q b. Neg (Or p q) ∈ set b ⟹ lexpands [Neg p, Neg q] b⟧ ⟹ Neg φ1 ∈ set b› 2. ‹⟦φ ∈ set b; φ = Neg φ'; ⋀b' x. ⟦lexpands b' b; x ∈ set b'⟧ ⟹ x ∈ set b; φ' = Or φ1 φ2; ⋀p q b. Neg (Or p q) ∈ set b ⟹ lexpands [Neg p, Neg q] b⟧ ⟹ Neg φ2 ∈ set b› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . moreover have "size (Neg φ1) < size φ" "size (Neg φ2) < size φ" using Neg (*‹φ = Neg φ'›*) Or (*‹φ' = Or φ1 φ2›*) apply - (*goals: 1. ‹⟦φ = Neg φ'; φ' = Or φ1 φ2⟧ ⟹ size (Neg φ1) < size φ› 2. ‹⟦φ = Neg φ'; φ' = Or φ1 φ2⟧ ⟹ size (Neg φ2) < size φ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹interp I⇩s⇩a (λx::'a::type. realise (Var x)) (φ::'a::type pset_atom fm)›*) using Neg (*‹φ = Neg φ'›*) Or (*‹φ' = Or φ1 φ2›*) less (*‹⟦size (?φ1::'a pset_atom fm) < size (φ::'a pset_atom fm); sat (b::'a pset_atom fm list); ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx::'a. realise (Var x)) ?φ1› ‹sat b› ‹(φ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list)›*) by force next (*goal: ‹⋀x4. φ' = Neg x4 ⟹ interp I⇩s⇩a (λx. realise (Var x)) φ›*) case Neg': (Neg φ'') (*‹φ' = Neg φ''›*) with ‹φ ∈ set b› (*‹φ ∈ set b›*) Neg (*‹φ = Neg φ'›*) ‹sat b›[THEN satD ( 1 ), THEN lin_satD] (*‹⟦lexpands ?b' b; ?x ∈ set ?b'⟧ ⟹ ?x ∈ set b›*) have "φ'' ∈ set b" using lexpands_fm.intros(7)[THEN lexpands.intros ( 1 )] (*‹Neg (Neg (?p1::?'a::type pset_atom fm)) ∈ set (?b::?'a::type pset_atom fm list) ⟹ lexpands [?p1] ?b›*) by fastforce with Neg (*‹φ = Neg φ'›*) Neg' (*‹φ' = Neg φ''›*) less (*‹⟦size ?φ1 < size φ; sat b; ?φ1 ∈ set b⟧ ⟹ interp I⇩s⇩a (λx. realise (Var x)) ?φ1› ‹sat b› ‹φ ∈ set b›*) show "?thesis" (*goal: ‹interp I⇩s⇩a (λx. realise (Var x)) φ›*) by simp qed qed qed subsection ‹Soundness of the Calculus› subsubsection ‹Soundness of Closedness› lemmas wf_trancl_hmem_rel = wf_trancl[OF wf_hmem_rel] lemma trancl_hmem_rel_not_refl: "(x, x) ∉ hmem_rel⁺" using wf_trancl_hmem_rel (*‹wf (hmem_rel⁺)›*) by simp lemma mem_trancl_elts_rel_if_member_seq: assumes "member_seq s cs t" assumes "cs ≠ []" assumes "∀a ∈ set cs. I⇩s⇩a M a" shows "(I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺" using assms (*‹member_seq s cs t› ‹(cs::'a pset_atom list) ≠ []› ‹∀a::'a pset_atom∈set (cs::'a pset_atom list). I⇩s⇩a (M::'a ⇒ hf) a›*) proof (induction rule: member_seq.induct (*‹⟦⋀(s::?'a pset_term) t::?'a pset_term. (?P::?'a pset_term ⇒ ?'a pset_atom list ⇒ ?'a pset_term ⇒ bool) s [] t; ⋀(s::?'a pset_term) (s'::?'a pset_term) (u::?'a pset_term) (cs::?'a pset_atom list) t::?'a pset_term. ?P u cs t ⟹ ?P s (s' ∈⇩s u # cs) t; ⋀(uu_::?'a pset_term) (vb::?'a pset_term) (vc::?'a pset_term) (va::?'a pset_atom list) uw_::?'a pset_term. ?P uu_ (vb =⇩s vc # va) uw_⟧ ⟹ ?P (?a0.0::?'a pset_term) (?a1.0::?'a pset_atom list) (?a2.0::?'a pset_term)›*)) (*goals: 1. ‹⋀s t. ⟦member_seq s [] t; [] ≠ []; Ball (set []) (I⇩s⇩a M)⟧ ⟹ (I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺› 2. ‹⋀s s' u cs t. ⟦⟦member_seq u cs t; cs ≠ []; Ball (set cs) (I⇩s⇩a M)⟧ ⟹ (I⇩s⇩t M u, I⇩s⇩t M t) ∈ hmem_rel⁺; member_seq s (s' ∈⇩s u # cs) t; s' ∈⇩s u # cs ≠ []; Ball (set (s' ∈⇩s u # cs)) (I⇩s⇩a M)⟧ ⟹ (I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺› 3. ‹⋀uu_ vb vc va uw_. ⟦member_seq uu_ (vb =⇩s vc # va) uw_; vb =⇩s vc # va ≠ []; Ball (set (vb =⇩s vc # va)) (I⇩s⇩a M)⟧ ⟹ (I⇩s⇩t M uu_, I⇩s⇩t M uw_) ∈ hmem_rel⁺›*) case (2 s s' u cs t) (*‹⟦member_seq u cs t; cs ≠ []; ∀a∈set cs. I⇩s⇩a M a⟧ ⟹ (I⇩s⇩t M u, I⇩s⇩t M t) ∈ hmem_rel⁺› ‹member_seq s (s' ∈⇩s u # cs) t› ‹s' ∈⇩s u # cs ≠ []› ‹∀a::'a pset_atom∈set ((s'::'a pset_term) ∈⇩s (u::'a pset_term) # (cs::'a pset_atom list)). I⇩s⇩a (M::'a ⇒ hf) a›*) show "?case" (*goal: ‹(I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺›*) proof (cases cs) (*goals: 1. ‹cs = [] ⟹ (I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺› 2. ‹⋀a list. cs = a # list ⟹ (I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺›*) case Nil (*‹cs = []›*) with "2" (*‹⟦member_seq (u::'a pset_term) (cs::'a pset_atom list) (t::'a pset_term); cs ≠ []; ∀a::'a pset_atom∈set cs. I⇩s⇩a (M::'a ⇒ hf) a⟧ ⟹ (I⇩s⇩t M u, I⇩s⇩t M t) ∈ hmem_rel⁺› ‹member_seq s (s' ∈⇩s u # cs) t› ‹s' ∈⇩s u # cs ≠ []› ‹∀a∈set (s' ∈⇩s u # cs). I⇩s⇩a M a›*) show "?thesis" (*goal: ‹(I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺›*) unfolding hmem_rel_def (*goal: ‹(I⇩s⇩t M s, I⇩s⇩t M t) ∈ ({(x, y). x ❙∈ y}⁺)⁺›*) by auto next (*goal: ‹⋀a list. cs = a # list ⟹ (I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺›*) case (Cons c cs') (*‹(cs::'a pset_atom list) = (c::'a pset_atom) # (cs'::'a pset_atom list)›*) with "2" (*‹⟦member_seq (u::'a pset_term) (cs::'a pset_atom list) (t::'a pset_term); cs ≠ []; ∀a::'a pset_atom∈set cs. I⇩s⇩a (M::'a ⇒ hf) a⟧ ⟹ (I⇩s⇩t M u, I⇩s⇩t M t) ∈ hmem_rel⁺› ‹member_seq (s::'a pset_term) ((s'::'a pset_term) ∈⇩s (u::'a pset_term) # (cs::'a pset_atom list)) (t::'a pset_term)› ‹s' ∈⇩s u # cs ≠ []› ‹∀a∈set (s' ∈⇩s u # cs). I⇩s⇩a M a›*) have "(I⇩s⇩t M u, I⇩s⇩t M t) ∈ hmem_rel⁺" by simp moreover from "2" (*‹⟦member_seq u cs t; cs ≠ []; ∀a∈set cs. I⇩s⇩a M a⟧ ⟹ (I⇩s⇩t M u, I⇩s⇩t M t) ∈ hmem_rel⁺› ‹member_seq s (s' ∈⇩s u # cs) t› ‹s' ∈⇩s u # cs ≠ []› ‹∀a::'a pset_atom∈set ((s'::'a pset_term) ∈⇩s (u::'a pset_term) # (cs::'a pset_atom list)). I⇩s⇩a (M::'a ⇒ hf) a›*) have "I⇩s⇩a M (s ∈⇩s u)" by simp ultimately show "?thesis" (*goal: ‹(I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺›*) unfolding hmem_rel_def (*goal: ‹(I⇩s⇩t (M::'a ⇒ hf) (s::'a pset_term), I⇩s⇩t M (t::'a pset_term)) ∈ ({(x::hf, y::hf). x ❙∈ y}⁺)⁺›*) by (simp add: trancl_into_trancl2 (*‹⟦(?a, ?b) ∈ ?r; (?b, ?c) ∈ ?r⁺⟧ ⟹ (?a, ?c) ∈ ?r⁺›*)) qed qed (simp_all) (*solves the remaining goals: 1. ‹⋀s t. ⟦member_seq s [] t; [] ≠ []; Ball (set []) (I⇩s⇩a M)⟧ ⟹ (I⇩s⇩t M s, I⇩s⇩t M t) ∈ hmem_rel⁺› 2. ‹⋀uu_ vb vc va uw_. ⟦member_seq uu_ (vb =⇩s vc # va) uw_; vb =⇩s vc # va ≠ []; Ball (set (vb =⇩s vc # va)) (I⇩s⇩a M)⟧ ⟹ (I⇩s⇩t M uu_, I⇩s⇩t M uw_) ∈ hmem_rel⁺›*) lemma bclosed_sound: assumes "bclosed b" shows "∃φ ∈ set b. ¬ interp I⇩s⇩a M φ" using assms (*‹bclosed b›*) proof (-) (*goal: ‹bclosed b ⟹ ∃φ∈set b. ¬ interp I⇩s⇩a M φ›*) have False if "∀φ ∈ set b. interp I⇩s⇩a M φ" using assms (*‹bclosed b›*) that (*‹∀φ∈set b. interp I⇩s⇩a M φ›*) proof (induction rule: bclosed.induct (*‹⟦bclosed (?x::?'a pset_atom fm list); ⋀(φ::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦φ ∈ set b; Neg φ ∈ set b⟧ ⟹ (?P::?'a pset_atom fm list ⇒ bool) b; ⋀(t::?'a pset_term) (n::nat) b::?'a pset_atom fm list. AT (t ∈⇩s ∅ n) ∈ set b ⟹ ?P b; ⋀(t::?'a pset_term) b::?'a pset_atom fm list. AF (t =⇩s t) ∈ set b ⟹ ?P b; ⋀(cs::?'a pset_atom list) b::?'a pset_atom fm list. ⟦member_cycle cs; set cs ⊆ Atoms (set b)⟧ ⟹ ?P b⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀φ b. ⟦φ ∈ set b; Neg φ ∈ set b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False› 2. ‹⋀t n b. ⟦AT (t ∈⇩s ∅ n) ∈ set b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False› 3. ‹⋀t b. ⟦AF (t =⇩s t) ∈ set b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False› 4. ‹⋀cs b. ⟦member_cycle cs; set cs ⊆ Atoms (set b); Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False›*) case (memberCycle cs b) (*‹member_cycle cs› ‹set (cs::'a::type pset_atom list) ⊆ Atoms (set (b::'a::type pset_atom fm list))› ‹∀a∈set b. interp I⇩s⇩a M a›*) then have "∀a ∈ set cs. I⇩s⇩a M a" unfolding Atoms_def (*goal: ‹∀a∈set cs. I⇩s⇩a M a›*) by fastforce from memberCycle (*‹member_cycle cs› ‹set cs ⊆ Atoms (set b)› ‹∀a∈set b. interp I⇩s⇩a M a›*) obtain s where "member_seq s cs s" (*goal: ‹(⋀s. member_seq s cs s ⟹ thesis) ⟹ thesis›*) using member_cycle.elims(2) (*‹⟦member_cycle ?x; ⋀s t cs. ⟦?x = s ∈⇩s t # cs; member_seq s (s ∈⇩s t # cs) s⟧ ⟹ ?P⟧ ⟹ ?P›*) by blast with memberCycle (*‹member_cycle cs› ‹set cs ⊆ Atoms (set b)› ‹∀a::'a::type pset_atom fm∈set (b::'a::type pset_atom fm list). interp I⇩s⇩a (M::'a::type ⇒ hf) a›*) ‹∀a ∈ set cs. I⇩s⇩a M a› (*‹∀a∈set cs. I⇩s⇩a M a›*) have "(I⇩s⇩t M s, I⇩s⇩t M s) ∈ hmem_rel⁺" using mem_trancl_elts_rel_if_member_seq (*‹⟦member_seq (?s::?'a pset_term) (?cs::?'a pset_atom list) (?t::?'a pset_term); ?cs ≠ []; ∀a::?'a pset_atom∈set ?cs. I⇩s⇩a (?M::?'a ⇒ hf) a⟧ ⟹ (I⇩s⇩t ?M ?s, I⇩s⇩t ?M ?t) ∈ hmem_rel⁺›*) member_cycle.simps(2) (*‹member_cycle [] = False›*) by blast with trancl_hmem_rel_not_refl (*‹(?x::hf, ?x) ∉ hmem_rel⁺›*) show "?case" (*goal: ‹False›*) by blast qed (use interp.simps(4) in ‹fastforce+›) (*solves the remaining goals: 1. ‹⋀φ b. ⟦φ ∈ set b; Neg φ ∈ set b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False› 2. ‹⋀t n b. ⟦AT (t ∈⇩s ∅ n) ∈ set b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False› 3. ‹⋀t b. ⟦AF (t =⇩s t) ∈ set b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ False›*) then show "?thesis" (*goal: ‹∃φ∈set b. ¬ interp I⇩s⇩a M φ›*) by blast qed lemma types_term_lt_if_member_seq: includes Set_member_no_ascii_notation fixes cs :: "'a pset_atom list" assumes "∀a ∈ set cs. v ⊢ a" assumes "member_seq s cs t" "cs ≠ []" shows "∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt" using assms (*‹∀a∈set cs. v ⊢ a› ‹member_seq (s::'a::type pset_term) (cs::'a::type pset_atom list) (t::'a::type pset_term)› ‹cs ≠ []›*) proof (induction s cs t rule: member_seq.induct (*‹⟦⋀s t. ?P s [] t; ⋀s s' u cs t. ?P u cs t ⟹ ?P s (s' ∈⇩s u # cs) t; ⋀uu_ vb vc va uw_. ?P uu_ (vb =⇩s vc # va) uw_⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀(s::'a pset_term) t::'a pset_term. ⟦Ball (set []) ((⊢) (v::'a ⇒ nat)); member_seq s [] t; [] ≠ []⟧ ⟹ ∃(ls::nat) lt::nat. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt› 2. ‹⋀(s::'a pset_term) (s'::'a pset_term) (u::'a pset_term) (cs::'a pset_atom list) t::'a pset_term. ⟦⟦Ball (set cs) ((⊢) (v::'a ⇒ nat)); member_seq u cs t; cs ≠ []⟧ ⟹ ∃(ls::nat) lt::nat. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt; Ball (set (s' ∈⇩s u # cs)) ((⊢) v); member_seq s (s' ∈⇩s u # cs) t; s' ∈⇩s u # cs ≠ []⟧ ⟹ ∃(ls::nat) lt::nat. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt› 3. ‹⋀(uu_::'a pset_term) (vb::'a pset_term) (vc::'a pset_term) (va::'a pset_atom list) uw_::'a pset_term. ⟦Ball (set (vb =⇩s vc # va)) ((⊢) (v::'a ⇒ nat)); member_seq uu_ (vb =⇩s vc # va) uw_; vb =⇩s vc # va ≠ []⟧ ⟹ ∃(ls::nat) lt::nat. v ⊢ uu_ : ls ∧ v ⊢ uw_ : lt ∧ ls < lt›*) case (2 s s' u cs t) (*‹⟦∀a∈set cs. v ⊢ a; member_seq u cs t; cs ≠ []⟧ ⟹ ∃ls lt. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt› ‹∀a∈set (s' ∈⇩s u # cs). v ⊢ a› ‹member_seq s (s' ∈⇩s u # cs) t› ‹s' ∈⇩s u # cs ≠ []›*) then show "?case" (*goal: ‹∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt›*) proof (cases cs) (*goals: 1. ‹⟦⟦∀a∈set cs. v ⊢ a; member_seq u cs t; cs ≠ []⟧ ⟹ ∃ls lt. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt; ∀a∈set (s' ∈⇩s u # cs). v ⊢ a; member_seq s (s' ∈⇩s u # cs) t; s' ∈⇩s u # cs ≠ []; cs = []⟧ ⟹ ∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt› 2. ‹⋀a list. ⟦⟦∀a∈set cs. v ⊢ a; member_seq u cs t; cs ≠ []⟧ ⟹ ∃ls lt. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt; ∀a∈set (s' ∈⇩s u # cs). v ⊢ a; member_seq s (s' ∈⇩s u # cs) t; s' ∈⇩s u # cs ≠ []; cs = a # list⟧ ⟹ ∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt›*) case (Cons c cs') (*‹cs = c # cs'›*) with "2" (*‹⟦∀a∈set cs. v ⊢ a; member_seq u cs t; cs ≠ []⟧ ⟹ ∃ls lt. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt› ‹∀a∈set (s' ∈⇩s u # cs). v ⊢ a› ‹member_seq s (s' ∈⇩s u # cs) t› ‹s' ∈⇩s u # cs ≠ []›*) obtain lu and lt where "v ⊢ u : lu" "v ⊢ t : lt" "lu < lt" (*goal: ‹(⋀(lu::nat) lt::nat. ⟦(v::'a::type ⇒ nat) ⊢ (u::'a::type pset_term) : lu; v ⊢ (t::'a::type pset_term) : lt; lu < lt⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto moreover from "2" (*‹⟦∀a∈set cs. v ⊢ a; member_seq u cs t; cs ≠ []⟧ ⟹ ∃ls lt. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt› ‹∀a∈set (s' ∈⇩s u # cs). v ⊢ a› ‹member_seq (s::'a pset_term) ((s'::'a pset_term) ∈⇩s (u::'a pset_term) # (cs::'a pset_atom list)) (t::'a pset_term)› ‹s' ∈⇩s u # cs ≠ []›*) obtain ls where "v ⊢ s : ls" "ls < lu" (*goal: ‹(⋀ls. ⟦v ⊢ s : ls; ls < lu⟧ ⟹ thesis) ⟹ thesis›*) using ‹v ⊢ u : lu› (*‹v ⊢ u : lu›*) by (auto simp: types_pset_atom.simps (*‹(?a1.0 ⊢ ?a2.0) = ((∃v s l t. ?a1.0 = v ∧ ?a2.0 = s =⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : l) ∨ (∃v s l t. ?a1.0 = v ∧ ?a2.0 = s ∈⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : Suc l))›*) dest: types_term_unique (*‹⟦?v ⊢ ?t : ?l1.0; ?v ⊢ ?t : ?l2.0⟧ ⟹ ?l2.0 = ?l1.0›*)) ultimately show "?thesis" (*goal: ‹∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt›*) by fastforce qed (fastforce simp: types_pset_atom.simps (*‹(?a1.0 ⊢ ?a2.0) = ((∃v s l t. ?a1.0 = v ∧ ?a2.0 = s =⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : l) ∨ (∃v s l t. ?a1.0 = v ∧ ?a2.0 = s ∈⇩s t ∧ v ⊢ s : l ∧ v ⊢ t : Suc l))›*)) (*solved the remaining goal: ‹⟦⟦∀a∈set cs. v ⊢ a; member_seq u cs t; cs ≠ []⟧ ⟹ ∃ls lt. v ⊢ u : ls ∧ v ⊢ t : lt ∧ ls < lt; ∀a∈set (s' ∈⇩s u # cs). v ⊢ a; member_seq s (s' ∈⇩s u # cs) t; s' ∈⇩s u # cs ≠ []; cs = []⟧ ⟹ ∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt›*) qed (auto) (*solves the remaining goals: 1. ‹⋀s t. ⟦Ball (set []) ((⊢) v); member_seq s [] t; [] ≠ []⟧ ⟹ ∃ls lt. v ⊢ s : ls ∧ v ⊢ t : lt ∧ ls < lt› 2. ‹⋀uu_ vb vc va uw_. ⟦Ball (set (vb =⇩s vc # va)) ((⊢) v); member_seq uu_ (vb =⇩s vc # va) uw_; vb =⇩s vc # va ≠ []⟧ ⟹ ∃ls lt. v ⊢ uu_ : ls ∧ v ⊢ uw_ : lt ∧ ls < lt›*) lemma no_member_cycle_if_types_last: fixes b :: "'a branch" assumes "wf_branch b" assumes "∃v. v ⊢ last b" shows "¬ (member_cycle cs ∧ set cs ⊆ Atoms (set b))" proof presume "member_cycle cs" "set cs ⊆ Atoms (set b)" then obtain s where "member_seq s cs s" "cs ≠ []" using member_cycle.elims(2) by blast moreover from assms obtain v where "∀φ ∈ set b. v ⊢ φ" using types_urelems by blast with ‹set cs ⊆ Atoms (set b)› have "∀a ∈ set cs. v ⊢ a" unfolding Atoms_def by (auto dest!: types_fmD(6)) ultimately show False using types_term_lt_if_member_seq types_term_unique by blast qed simp_all subsubsection ‹Soundness of the Expansion Rules› lemma lexpands_sound: assumes "lexpands b' b" assumes "φ ∈ set b'" assumes "⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ" shows "interp I⇩s⇩a M φ" using assms (*‹lexpands (b'::'a pset_atom fm list) (b::'a pset_atom fm list)› ‹φ ∈ set b'› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) proof (induction rule: lexpands.induct (*‹⟦lexpands (?x1.0::?'a pset_atom fm list) (?x2.0::?'a pset_atom fm list); ⋀(b'::?'a pset_atom fm list) b::?'a pset_atom fm list. lexpands_fm b' b ⟹ (?P::?'a pset_atom fm list ⇒ ?'a pset_atom fm list ⇒ bool) b' b; ⋀(b'::?'a pset_atom fm list) b::?'a pset_atom fm list. lexpands_un b' b ⟹ ?P b' b; ⋀(b'::?'a pset_atom fm list) b::?'a pset_atom fm list. lexpands_int b' b ⟹ ?P b' b; ⋀(b'::?'a pset_atom fm list) b::?'a pset_atom fm list. lexpands_diff b' b ⟹ ?P b' b; ⋀(b'::?'a pset_atom fm list) b::?'a pset_atom fm list. lexpands_single b' b ⟹ ?P b' b; ⋀(b'::?'a pset_atom fm list) b::?'a pset_atom fm list. lexpands_eq b' b ⟹ ?P b' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀b' b. ⟦lexpands_fm b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀b' b. ⟦lexpands_un b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀b' b. ⟦lexpands_int b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀b' b. ⟦lexpands_diff b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀b' b. ⟦lexpands_single b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 6. ‹⋀b' b. ⟦lexpands_eq b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (1 b' b) (*‹lexpands_fm b' b› ‹(φ::'a::type pset_atom fm) ∈ set (b'::'a::type pset_atom fm list)› ‹(?ψ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list) ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ?ψ›*) then show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) apply (induction rule: lexpands_fm.induct (*‹⟦lexpands_fm (?x1.0::?'a pset_atom fm list) (?x2.0::?'a pset_atom fm list); ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. And p q ∈ set b ⟹ (?P::?'a pset_atom fm list ⇒ ?'a pset_atom fm list ⇒ bool) [p, q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀(p::?'a pset_atom fm) (q::?'a pset_atom fm) b::?'a pset_atom fm list. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀(p::?'a pset_atom fm) b::?'a pset_atom fm list. Neg (Neg p) ∈ set b ⟹ ?P [p] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦And p q ∈ set b; φ ∈ set [p, q]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀p q b. ⟦Neg (Or p q) ∈ set b; φ ∈ set [Neg p, Neg q]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b; φ ∈ set [q]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b; φ ∈ set [p]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b; φ ∈ set [Neg q]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 6. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b; φ ∈ set [Neg p]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 7. ‹⋀p b. ⟦Neg (Neg p) ∈ set b; φ ∈ set [p]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› discuss goal 1*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp ?I⇩a ?M (And ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Or ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Neg ?φ) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*discuss goal 2*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp ?I⇩a ?M (And ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Or ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Neg ?φ) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*discuss goal 3*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp ?I⇩a ?M (And ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Or ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Neg ?φ) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*discuss goal 4*) apply (metis empty_iff (*‹((?c::?'a::type) ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp (?I⇩a::?'model::type ⇒ ?'a::type ⇒ bool) (?M::?'model::type) (And (?φ₁::?'a::type fm) (?φ₂::?'a::type fm)) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp (?I⇩a::?'model::type ⇒ ?'a::type ⇒ bool) (?M::?'model::type) (Or (?φ₁::?'a::type fm) (?φ₂::?'a::type fm)) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp (?I⇩a::?'model::type ⇒ ?'a::type ⇒ bool) (?M::?'model::type) (Neg (?φ::?'a::type fm)) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹(?y::?'a::type) ∈ set ((?x::?'a::type) # (?xs::?'a::type list)) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*discuss goal 5*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp ?I⇩a ?M (And ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Or ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Neg ?φ) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*discuss goal 6*) apply (metis empty_iff (*‹(?c ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp ?I⇩a ?M (And ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Or ?φ₁ ?φ₂) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp ?I⇩a ?M (Neg ?φ) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹?y ∈ set (?x # ?xs) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*discuss goal 7*) apply (metis empty_iff (*‹((?c::?'a) ∈ {}) = False›*) empty_set (*‹{} = set []›*) interp.simps( (*‹interp (?I⇩a::?'model ⇒ ?'a ⇒ bool) (?M::?'model) (And (?φ₁::?'a fm) (?φ₂::?'a fm)) = (interp ?I⇩a ?M ?φ₁ ∧ interp ?I⇩a ?M ?φ₂)› ‹interp (?I⇩a::?'model ⇒ ?'a ⇒ bool) (?M::?'model) (Or (?φ₁::?'a fm) (?φ₂::?'a fm)) = (interp ?I⇩a ?M ?φ₁ ∨ interp ?I⇩a ?M ?φ₂)› ‹interp (?I⇩a::?'model ⇒ ?'a ⇒ bool) (?M::?'model) (Neg (?φ::?'a fm)) = (¬ interp ?I⇩a ?M ?φ)›*) 2,3,4) set_ConsD (*‹(?y::?'a) ∈ set ((?x::?'a) # (?xs::?'a list)) ⟹ ?y = ?x ∨ ?y ∈ set ?xs›*)) (*proven 7 subgoals*) . next (*goals: 1. ‹⋀b' b. ⟦lexpands_un b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀b' b. ⟦lexpands_int b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀b' b. ⟦lexpands_diff b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀b' b. ⟦lexpands_single b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀b' b. ⟦lexpands_eq b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (2 b' b) (*‹lexpands_un b' b› ‹φ ∈ set b'› ‹(?ψ::'a::type pset_atom fm) ∈ set (b::'a::type pset_atom fm list) ⟹ interp I⇩s⇩a (M::'a::type ⇒ hf) ?ψ›*) then show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) proof (induction rule: lexpands_un.induct (*‹⟦lexpands_un ?x1.0 ?x2.0; ⋀s t1 t2 b. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; φ ∈ set [AF (s ∈⇩s t1), AF (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; φ ∈ set [AT (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; φ ∈ set [AT (s ∈⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 6. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (4 s t1 t2 branch) (*‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set branch› ‹AF (s ∈⇩s t1) ∈ set branch› ‹φ ∈ set [AT (s ∈⇩s t2)]› ‹?ψ ∈ set branch ⟹ interp I⇩s⇩a M ?ψ›*) with this(1)[THEN this ( 4 )] (*‹interp I⇩s⇩a (M::'a ⇒ hf) (AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term) ⊔⇩s (t2::'a pset_term)))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force next (*goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; φ ∈ set [AF (s ∈⇩s t1), AF (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; φ ∈ set [AT (s ∈⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (5 s t1 t2 branch) (*‹AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set branch› ‹AF (s ∈⇩s t2) ∈ set branch› ‹φ ∈ set [AT (s ∈⇩s t1)]› ‹?ψ ∈ set branch ⟹ interp I⇩s⇩a M ?ψ›*) with this(1)[THEN this ( 4 )] (*‹interp I⇩s⇩a M (AT (s ∈⇩s t1 ⊔⇩s t2))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force qed ((force)+) (*solves the remaining goals: 1. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; φ ∈ set [AF (s ∈⇩s t1), AF (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊔⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) next (*goals: 1. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_int b' b; (φ::'a pset_atom fm) ∈ set b'; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_diff b' b; (φ::'a pset_atom fm) ∈ set b'; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_single b' b; (φ::'a pset_atom fm) ∈ set b'; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_eq b' b; (φ::'a pset_atom fm) ∈ set b'; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (3 b' b) (*‹lexpands_int b' b› ‹φ ∈ set b'› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) then show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) proof (induction rule: lexpands_int.induct (*‹⟦lexpands_int ?x1.0 ?x2.0; ⋀s t1 t2 b. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; φ ∈ set [AT (s ∈⇩s t1), AT (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; φ ∈ set [AF (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; φ ∈ set [AF (s ∈⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (4 s t1 t2 branch) (*‹AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set branch› ‹AT ((s::'a pset_term) ∈⇩s (t1::'a pset_term)) ∈ set (branch::'a pset_atom fm list)› ‹φ ∈ set [AF (s ∈⇩s t2)]› ‹?ψ ∈ set branch ⟹ interp I⇩s⇩a M ?ψ›*) with this(1)[THEN this ( 4 )] (*‹interp I⇩s⇩a M (AF (s ∈⇩s t1 ⊓⇩s t2))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force next (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; φ ∈ set [AT (s ∈⇩s t1), AT (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; φ ∈ set [AF (s ∈⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (5 s t1 t2 branch) (*‹AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set branch› ‹AT (s ∈⇩s t2) ∈ set branch› ‹φ ∈ set [AF (s ∈⇩s t1)]› ‹?ψ ∈ set branch ⟹ interp I⇩s⇩a M ?ψ›*) with this(1)[THEN this ( 4 )] (*‹interp I⇩s⇩a M (AF (s ∈⇩s t1 ⊓⇩s t2))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force qed ((force)+) (*solves the remaining goals: 1. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; (φ::'a pset_atom fm) ∈ set [AT (s ∈⇩s t1), AT (s ∈⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀(s::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) t1::'a pset_term. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AT (s ∈⇩s t1 ⊓⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ›*) next (*goals: 1. ‹⋀b' b. ⟦lexpands_diff b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀b' b. ⟦lexpands_single b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀b' b. ⟦lexpands_eq b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (4 b' b) (*‹lexpands_diff b' b› ‹φ ∈ set b'› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) then show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) proof (induction rule: lexpands_diff.induct (*‹⟦lexpands_diff (?x1.0::?'a pset_atom fm list) (?x2.0::?'a pset_atom fm list); ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ (?P::?'a pset_atom fm list ⇒ ?'a pset_atom fm list ⇒ bool) [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀(s::?'a pset_term) (t2::?'a pset_term) (b::?'a pset_atom fm list) t1::?'a pset_term. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (t2::?'a pset_term) b::?'a pset_atom fm list. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀(s::?'a pset_term) (t1::?'a pset_term) (b::?'a pset_atom fm list) t2::?'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; φ ∈ set [AT (s ∈⇩s t1), AF (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 -⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); φ ∈ set [AF (s ∈⇩s t1 -⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; φ ∈ set [AT (s ∈⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; φ ∈ set [AF (s ∈⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 6. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); φ ∈ set [AT (s ∈⇩s t1 -⇩s t2)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (4 s t1 t2 branch) (*‹AF (s ∈⇩s t1 -⇩s t2) ∈ set branch› ‹AT (s ∈⇩s t1) ∈ set branch› ‹φ ∈ set [AT (s ∈⇩s t2)]› ‹?ψ ∈ set branch ⟹ interp I⇩s⇩a M ?ψ›*) with this(1)[THEN this ( 4 )] (*‹interp I⇩s⇩a M (AF (s ∈⇩s t1 -⇩s t2))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force next (*goals: 1. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; (φ::'a pset_atom fm) ∈ set [AT (s ∈⇩s t1), AF (s ∈⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1 -⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀(s::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) t1::'a pset_term. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1 -⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 5. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AT (s ∈⇩s t1 -⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (5 s t1 t2 branch) (*‹AF ((s::'a pset_term) ∈⇩s (t1::'a pset_term) -⇩s (t2::'a pset_term)) ∈ set (branch::'a pset_atom fm list)› ‹AF (s ∈⇩s t2) ∈ set branch› ‹φ ∈ set [AF (s ∈⇩s t1)]› ‹?ψ ∈ set branch ⟹ interp I⇩s⇩a M ?ψ›*) with this(1)[THEN this ( 4 )] (*‹interp I⇩s⇩a M (AF (s ∈⇩s t1 -⇩s t2))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force qed ((force)+) (*solves the remaining goals: 1. ‹⋀(s::'a pset_term) (t1::'a pset_term) (t2::'a pset_term) b::'a pset_atom fm list. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; (φ::'a pset_atom fm) ∈ set [AT (s ∈⇩s t1), AF (s ∈⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1 -⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀(s::'a pset_term) (t2::'a pset_term) (b::'a pset_atom fm list) t1::'a pset_term. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AF (s ∈⇩s t1 -⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 4. ‹⋀(s::'a pset_term) (t1::'a pset_term) (b::'a pset_atom fm list) t2::'a pset_term. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); (φ::'a pset_atom fm) ∈ set [AT (s ∈⇩s t1 -⇩s t2)]; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ›*) next (*goals: 1. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_single b' b; (φ::'a pset_atom fm) ∈ set b'; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀(b'::'a pset_atom fm list) b::'a pset_atom fm list. ⟦lexpands_eq b' b; (φ::'a pset_atom fm) ∈ set b'; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (5 b' b) (*‹lexpands_single (b'::'a pset_atom fm list) (b::'a pset_atom fm list)› ‹φ ∈ set b'› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) then show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) apply (induction rule: lexpands_single.induct (*‹⟦lexpands_single ?x1.0 ?x2.0; ⋀t1 b. Single t1 ∈ subterms (last b) ⟹ ?P [AT (t1 ∈⇩s Single t1)] b; ⋀s t1 b. AT (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AT (s =⇩s t1)] b; ⋀s t1 b. AF (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AF (s =⇩s t1)] b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀t1 b. ⟦Single t1 ∈ subterms (last b); φ ∈ set [AT (t1 ∈⇩s Single t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t1 b. ⟦AT (s ∈⇩s Single t1) ∈ set b; φ ∈ set [AT (s =⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 3. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; φ ∈ set [AF (s =⇩s t1)]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› discuss goal 1*) apply force (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*proven 3 subgoals*) . next (*goal: ‹⋀b' b. ⟦lexpands_eq b' b; φ ∈ set b'; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (6 b' b) (*‹lexpands_eq b' b› ‹φ ∈ set b'› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) then show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) proof (induction rule: lexpands_eq_induct' (*‹⟦lexpands_eq ?b' ?b; ⋀t1 t2 t1' t2' p l b. ⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l⟧ ⟹ ?P [polarise p (AT (subst_tlvl t1' t2' l))] b; ⋀s t s' b. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b⟧ ⟹ ?P [AF (s =⇩s s')] b⟧ ⟹ ?P ?b' ?b›*)) (*goals: 1. ‹⋀t1 t2 t1' t2' p l b. ⟦AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; φ ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀s t s' b. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; φ ∈ set [AF (s =⇩s s')]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (subst t1 t2 t1' t2' p l b) (*‹AT ((t1::'a::type pset_term) =⇩s (t2::'a::type pset_term)) ∈ set (b::'a::type pset_atom fm list)› ‹polarise p (AT l) ∈ set b› ‹(t1'::'a pset_term, t2'::'a pset_term) ∈ {(t1::'a pset_term, t2::'a pset_term), (t2, t1)}› ‹t1' ∈ tlvl_terms l› ‹φ ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) with this(1,2)[THEN this ( 6 )] (*‹interp I⇩s⇩a (M::'a::type ⇒ hf) (AT ((t1::'a::type pset_term) =⇩s (t2::'a::type pset_term)))› ‹interp I⇩s⇩a M (polarise p (AT l))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) apply (cases l) (*goals: 1. ‹⋀(x11::'a::type pset_term) x12::'a::type pset_term. ⟦interp I⇩s⇩a (M::'a::type ⇒ hf) (AT ((t1::'a::type pset_term) =⇩s (t2::'a::type pset_term))); interp I⇩s⇩a M (polarise (p::bool) (AT (l::'a::type pset_atom))); AT (t1 =⇩s t2) ∈ set (b::'a::type pset_atom fm list); polarise p (AT l) ∈ set b; (t1'::'a::type pset_term, t2'::'a::type pset_term) ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; (φ::'a::type pset_atom fm) ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ::'a::type pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ; l = x11 ∈⇩s x12⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀(x21::'a::type pset_term) x22::'a::type pset_term. ⟦interp I⇩s⇩a (M::'a::type ⇒ hf) (AT ((t1::'a::type pset_term) =⇩s (t2::'a::type pset_term))); interp I⇩s⇩a M (polarise (p::bool) (AT (l::'a::type pset_atom))); AT (t1 =⇩s t2) ∈ set (b::'a::type pset_atom fm list); polarise p (AT l) ∈ set b; (t1'::'a::type pset_term, t2'::'a::type pset_term) ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; (φ::'a::type pset_atom fm) ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ::'a::type pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ; l = x21 =⇩s x22⟧ ⟹ interp I⇩s⇩a M φ› discuss goal 1*) apply (cases p) (*goals: 1. ‹⋀x11 x12. ⟦interp I⇩s⇩a M (AT (t1 =⇩s t2)); interp I⇩s⇩a M (polarise p (AT l)); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; φ ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ; l = x11 ∈⇩s x12; p⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀x11 x12. ⟦interp I⇩s⇩a M (AT (t1 =⇩s t2)); interp I⇩s⇩a M (polarise p (AT l)); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; φ ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ; l = x11 ∈⇩s x12; ¬ p⟧ ⟹ interp I⇩s⇩a M φ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases p) (*goals: 1. ‹⋀x21 x22. ⟦interp I⇩s⇩a M (AT (t1 =⇩s t2)); interp I⇩s⇩a M (polarise p (AT l)); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; φ ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ; l = x21 =⇩s x22; p⟧ ⟹ interp I⇩s⇩a M φ› 2. ‹⋀x21 x22. ⟦interp I⇩s⇩a M (AT (t1 =⇩s t2)); interp I⇩s⇩a M (polarise p (AT l)); AT (t1 =⇩s t2) ∈ set b; polarise p (AT l) ∈ set b; (t1', t2') ∈ {(t1, t2), (t2, t1)}; t1' ∈ tlvl_terms l; φ ∈ set [polarise p (AT (subst_tlvl t1' t2' l))]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ; l = x21 =⇩s x22; ¬ p⟧ ⟹ interp I⇩s⇩a M φ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . next (*goal: ‹⋀s t s' b. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; φ ∈ set [AF (s =⇩s s')]; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ interp I⇩s⇩a M φ›*) case (neq s t s' b) (*‹AT ((s::'a pset_term) ∈⇩s (t::'a pset_term)) ∈ set (b::'a pset_atom fm list)› ‹AF (s' ∈⇩s t) ∈ set b› ‹φ ∈ set [AF (s =⇩s s')]› ‹(?ψ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list) ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ?ψ›*) with this(1,2)[THEN this ( 4 )] (*‹interp I⇩s⇩a M (AT (s ∈⇩s t))› ‹interp I⇩s⇩a M (AF (s' ∈⇩s t))›*) show "?case" (*goal: ‹interp I⇩s⇩a M φ›*) by force qed qed lemma bexpands_nowit_sound: assumes "bexpands_nowit bs' b" assumes "⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ" shows "∃b' ∈ bs'. ∀ψ ∈ set b'. interp I⇩s⇩a M ψ" using assms (*‹bexpands_nowit bs' b› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) apply (induction rule: bexpands_nowit.induct (*‹⟦bexpands_nowit ?x1.0 ?x2.0; ⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b⟧ ⟹ ?P {[p], [Neg p]} b; ⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b⟧ ⟹ ?P {[Neg p], [p]} b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ ∃b'∈{[p], [Neg p]}. Ball (set b') (interp I⇩s⇩a M)› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ ∃b'∈{[Neg p], [p]}. Ball (set b') (interp I⇩s⇩a M)› 3. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ ∃b'∈{[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}. Ball (set b') (interp I⇩s⇩a M)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ ∃b'∈{[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}. Ball (set b') (interp I⇩s⇩a M)› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ ∃b'∈{[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}. Ball (set b') (interp I⇩s⇩a M)› discuss goal 1*) apply force (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*discuss goal 4*) apply force (*discuss goal 5*) apply force (*proven 5 subgoals*) . lemma I⇩s⇩t_upd_eq_if_not_mem_vars_term: assumes "x ∉ vars t" shows "I⇩s⇩t (M(x := y)) t = I⇩s⇩t M t" using assms (*‹(x::'a::type) ∉ vars (t::'a::type pset_term)›*) apply (induction t) (*goals: 1. ‹⋀xa. x ∉ vars ∅ xa ⟹ I⇩s⇩t (M(x := y)) ∅ xa = I⇩s⇩t M ∅ xa› 2. ‹⋀xa. x ∉ vars (Var xa) ⟹ I⇩s⇩t (M(x := y)) (Var xa) = I⇩s⇩t M (Var xa)› 3. ‹⋀t1 t2. ⟦x ∉ vars t1 ⟹ I⇩s⇩t (M(x := y)) t1 = I⇩s⇩t M t1; x ∉ vars t2 ⟹ I⇩s⇩t (M(x := y)) t2 = I⇩s⇩t M t2; x ∉ vars (t1 ⊔⇩s t2)⟧ ⟹ I⇩s⇩t (M(x := y)) (t1 ⊔⇩s t2) = I⇩s⇩t M (t1 ⊔⇩s t2)› 4. ‹⋀t1 t2. ⟦x ∉ vars t1 ⟹ I⇩s⇩t (M(x := y)) t1 = I⇩s⇩t M t1; x ∉ vars t2 ⟹ I⇩s⇩t (M(x := y)) t2 = I⇩s⇩t M t2; x ∉ vars (t1 ⊓⇩s t2)⟧ ⟹ I⇩s⇩t (M(x := y)) (t1 ⊓⇩s t2) = I⇩s⇩t M (t1 ⊓⇩s t2)› 5. ‹⋀t1 t2. ⟦x ∉ vars t1 ⟹ I⇩s⇩t (M(x := y)) t1 = I⇩s⇩t M t1; x ∉ vars t2 ⟹ I⇩s⇩t (M(x := y)) t2 = I⇩s⇩t M t2; x ∉ vars (t1 -⇩s t2)⟧ ⟹ I⇩s⇩t (M(x := y)) (t1 -⇩s t2) = I⇩s⇩t M (t1 -⇩s t2)› 6. ‹⋀t. ⟦x ∉ vars t ⟹ I⇩s⇩t (M(x := y)) t = I⇩s⇩t M t; x ∉ vars (Single t)⟧ ⟹ I⇩s⇩t (M(x := y)) (Single t) = I⇩s⇩t M (Single t)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . lemma I⇩s⇩a_upd_eq_if_not_mem_vars_atom: assumes "x ∉ vars a" shows "I⇩s⇩a (M(x := y)) a = I⇩s⇩a M a" using assms (*‹x ∉ vars a›*) apply (cases a) (*goals: 1. ‹⋀(x11::'a::type pset_term) x12::'a::type pset_term. ⟦(x::'a::type) ∉ vars (a::'a::type pset_atom); a = x11 ∈⇩s x12⟧ ⟹ I⇩s⇩a ((M::'a::type ⇒ hf)(x := y::hf)) a = I⇩s⇩a M a› 2. ‹⋀(x21::'a::type pset_term) x22::'a::type pset_term. ⟦(x::'a::type) ∉ vars (a::'a::type pset_atom); a = x21 =⇩s x22⟧ ⟹ I⇩s⇩a ((M::'a::type ⇒ hf)(x := y::hf)) a = I⇩s⇩a M a› discuss goal 1*) apply ((auto simp: I⇩s⇩t_upd_eq_if_not_mem_vars_term (*‹?x ∉ vars ?t ⟹ I⇩s⇩t (?M(?x := ?y)) ?t = I⇩s⇩t ?M ?t›*))[1]) (*discuss goal 2*) apply ((auto simp: I⇩s⇩t_upd_eq_if_not_mem_vars_term (*‹?x ∉ vars ?t ⟹ I⇩s⇩t (?M(?x := ?y)) ?t = I⇩s⇩t ?M ?t›*))[1]) (*proven 2 subgoals*) . lemma interp_upd_eq_if_not_mem_vars_fm: assumes "x ∉ vars φ" shows "interp I⇩s⇩a (M(x := y)) φ = interp I⇩s⇩a M φ" using assms (*‹x ∉ vars φ›*) apply (induction φ) (*goals: 1. ‹⋀xa. x ∉ vars (AT xa) ⟹ interp I⇩s⇩a (M(x := y)) (AT xa) = interp I⇩s⇩a M (AT xa)› 2. ‹⋀φ1 φ2. ⟦x ∉ vars φ1 ⟹ interp I⇩s⇩a (M(x := y)) φ1 = interp I⇩s⇩a M φ1; x ∉ vars φ2 ⟹ interp I⇩s⇩a (M(x := y)) φ2 = interp I⇩s⇩a M φ2; x ∉ vars (And φ1 φ2)⟧ ⟹ interp I⇩s⇩a (M(x := y)) (And φ1 φ2) = interp I⇩s⇩a M (And φ1 φ2)› 3. ‹⋀φ1 φ2. ⟦x ∉ vars φ1 ⟹ interp I⇩s⇩a (M(x := y)) φ1 = interp I⇩s⇩a M φ1; x ∉ vars φ2 ⟹ interp I⇩s⇩a (M(x := y)) φ2 = interp I⇩s⇩a M φ2; x ∉ vars (Or φ1 φ2)⟧ ⟹ interp I⇩s⇩a (M(x := y)) (Or φ1 φ2) = interp I⇩s⇩a M (Or φ1 φ2)› 4. ‹⋀φ. ⟦x ∉ vars φ ⟹ interp I⇩s⇩a (M(x := y)) φ = interp I⇩s⇩a M φ; x ∉ vars (Neg φ)⟧ ⟹ interp I⇩s⇩a (M(x := y)) (Neg φ) = interp I⇩s⇩a M (Neg φ)› discuss goal 1*) apply ((auto simp: I⇩s⇩a_upd_eq_if_not_mem_vars_atom (*‹?x ∉ vars ?a ⟹ I⇩s⇩a (?M(?x := ?y)) ?a = I⇩s⇩a ?M ?a›*))[1]) (*discuss goal 2*) apply ((auto simp: I⇩s⇩a_upd_eq_if_not_mem_vars_atom (*‹?x ∉ vars ?a ⟹ I⇩s⇩a (?M(?x := ?y)) ?a = I⇩s⇩a ?M ?a›*))[1]) (*discuss goal 3*) apply ((auto simp: I⇩s⇩a_upd_eq_if_not_mem_vars_atom (*‹?x ∉ vars ?a ⟹ I⇩s⇩a (?M(?x := ?y)) ?a = I⇩s⇩a ?M ?a›*))[1]) (*discuss goal 4*) apply ((auto simp: I⇩s⇩a_upd_eq_if_not_mem_vars_atom (*‹(?x::?'a::type) ∉ vars (?a::?'a::type pset_atom) ⟹ I⇩s⇩a ((?M::?'a::type ⇒ hf)(?x := ?y::hf)) ?a = I⇩s⇩a ?M ?a›*))[1]) (*proven 4 subgoals*) . lemma bexpands_wit_sound: assumes "bexpands_wit s t x bs' b" assumes "⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ" shows "∃M. ∃b' ∈ bs'. ∀ψ ∈ set (b' @ b). interp I⇩s⇩a M ψ" using assms (*‹bexpands_wit s t x bs' b› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) proof (induction rule: bexpands_wit.induct (*‹⟦bexpands_wit ?t1.0 ?t2.0 ?x ?x1.0 ?x2.0; ⋀b. ⟦AF (?t1.0 =⇩s ?t2.0) ∈ set b; ?t1.0 ∈ subterms (last b); ?t2.0 ∈ subterms (last b); ∄x. AT (x ∈⇩s ?t1.0) ∈ set b ∧ AF (x ∈⇩s ?t2.0) ∈ set b; ∄x. AT (x ∈⇩s ?t2.0) ∈ set b ∧ AF (x ∈⇩s ?t1.0) ∈ set b; ?x ∉ vars b; ¬ urelem (last b) ?t1.0; ¬ urelem (last b) ?t2.0⟧ ⟹ ?P {[AT (Var ?x ∈⇩s ?t1.0), AF (Var ?x ∈⇩s ?t2.0)], [AT (Var ?x ∈⇩s ?t2.0), AF (Var ?x ∈⇩s ?t1.0)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹⋀b. ⟦AF (s =⇩s t) ∈ set b; s ∈ subterms (last b); t ∈ subterms (last b); ∄x. AT (x ∈⇩s s) ∈ set b ∧ AF (x ∈⇩s t) ∈ set b; ∄x. AT (x ∈⇩s t) ∈ set b ∧ AF (x ∈⇩s s) ∈ set b; x ∉ vars b; ¬ urelem (last b) s; ¬ urelem (last b) t; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ ∃M. ∃b'∈{[AT (Var x ∈⇩s s), AF (Var x ∈⇩s t)], [AT (Var x ∈⇩s t), AF (Var x ∈⇩s s)]}. Ball (set (b' @ b)) (interp I⇩s⇩a M)›*) let ?bs' = "{[AT (Var x ∈⇩s s), AF (Var x ∈⇩s t)], [AT (Var x ∈⇩s t), AF (Var x ∈⇩s s)]}" case (1 b) (*‹AF (s =⇩s t) ∈ set b› ‹s ∈ subterms (last b)› ‹(t::'a::type pset_term) ∈ subterms (last (b::'a::type pset_atom fm list))› ‹∄x. AT (x ∈⇩s s) ∈ set b ∧ AF (x ∈⇩s t) ∈ set b› ‹∄x. AT (x ∈⇩s t) ∈ set b ∧ AF (x ∈⇩s s) ∈ set b› ‹x ∉ vars b› ‹¬ urelem (last b) s› ‹¬ urelem (last b) t› ‹(?ψ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list) ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ?ψ›*) with this(1)[THEN this ( 9 )] (*‹interp I⇩s⇩a M (AF (s =⇩s t))›*) have "I⇩s⇩t M s ≠ I⇩s⇩t M t" by auto then obtain y where y: "y ❙∈ I⇩s⇩t M s ∧ y ❙∉ I⇩s⇩t M t ∨ y ❙∈ I⇩s⇩t M t ∧ y ❙∉ I⇩s⇩t M s" (*goal: ‹(⋀y. y ❙∈ I⇩s⇩t M s ∧ y ❙∉ I⇩s⇩t M t ∨ y ❙∈ I⇩s⇩t M t ∧ y ❙∉ I⇩s⇩t M s ⟹ thesis) ⟹ thesis›*) by auto have "x ∉ vars s" "x ∉ vars t" using "1" (*‹AF (s =⇩s t) ∈ set b› ‹s ∈ subterms (last b)› ‹t ∈ subterms (last b)› ‹∄x. AT (x ∈⇩s s) ∈ set b ∧ AF (x ∈⇩s t) ∈ set b› ‹∄x. AT (x ∈⇩s t) ∈ set b ∧ AF (x ∈⇩s s) ∈ set b› ‹x ∉ vars b› ‹¬ urelem (last b) s› ‹¬ urelem (last b) t› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) apply - (*goals: 1. ‹⟦AF (s =⇩s t) ∈ set b; s ∈ subterms (last b); t ∈ subterms (last b); ∄x. AT (x ∈⇩s s) ∈ set b ∧ AF (x ∈⇩s t) ∈ set b; ∄x. AT (x ∈⇩s t) ∈ set b ∧ AF (x ∈⇩s s) ∈ set b; x ∉ vars b; ¬ urelem (last b) s; ¬ urelem (last b) t; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ x ∉ vars s› 2. ‹⟦AF (s =⇩s t) ∈ set b; s ∈ subterms (last b); t ∈ subterms (last b); ∄x. AT (x ∈⇩s s) ∈ set b ∧ AF (x ∈⇩s t) ∈ set b; ∄x. AT (x ∈⇩s t) ∈ set b ∧ AF (x ∈⇩s s) ∈ set b; x ∉ vars b; ¬ urelem (last b) s; ¬ urelem (last b) t; ⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ⟧ ⟹ x ∉ vars t› discuss goal 1*) apply ((auto simp: vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*))[1]) (*proven 2 subgoals*) . then have "I⇩s⇩t (M(x := y)) s = I⇩s⇩t M s" "I⇩s⇩t (M(x := y)) t = I⇩s⇩t M t" using "I⇩s⇩t_upd_eq_if_not_mem_vars_term" (*‹?x ∉ vars ?t ⟹ I⇩s⇩t (?M(?x := ?y)) ?t = I⇩s⇩t ?M ?t›*) by ((metis)+) then have "∃b' ∈ ?bs'. ∀ψ ∈ set b'. interp I⇩s⇩a (M(x := y)) ψ" using "1" (*‹AF (s =⇩s t) ∈ set b› ‹s ∈ subterms (last b)› ‹(t::'a pset_term) ∈ subterms (last (b::'a pset_atom fm list))› ‹∄x. AT (x ∈⇩s s) ∈ set b ∧ AF (x ∈⇩s t) ∈ set b› ‹∄x. AT (x ∈⇩s t) ∈ set b ∧ AF (x ∈⇩s s) ∈ set b› ‹(x::'a::type) ∉ vars (b::'a::type pset_atom fm list)› ‹¬ urelem (last b) s› ‹¬ urelem (last b) t› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) y (*‹(y::hf) ❙∈ I⇩s⇩t (M::'a ⇒ hf) (s::'a pset_term) ∧ y ❙∉ I⇩s⇩t M (t::'a pset_term) ∨ y ❙∈ I⇩s⇩t M t ∧ y ❙∉ I⇩s⇩t M s›*) by auto moreover have "∀ψ ∈ set b. interp I⇩s⇩a (M(x := y)) ψ" using "1"(9) (*‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) ‹x ∉ vars b› (*‹x ∉ vars b›*) interp_upd_eq_if_not_mem_vars_fm (*‹?x ∉ vars ?φ ⟹ interp I⇩s⇩a (?M(?x := ?y)) ?φ = interp I⇩s⇩a ?M ?φ›*) by (metis vars_fm_vars_branchI (*‹⟦?φ ∈ set ?b; ?x ∈ vars ?φ⟧ ⟹ ?x ∈ vars ?b›*)) ultimately show "?case" (*goal: ‹∃M. ∃b'∈{[AT (Var x ∈⇩s s), AF (Var x ∈⇩s t)], [AT (Var x ∈⇩s t), AF (Var x ∈⇩s s)]}. ∀a∈set (b' @ b). interp I⇩s⇩a M a›*) apply auto (*goals: 1. ‹⟦∀ψ∈set b. interp I⇩s⇩a (M(x := y)) ψ; y ❙∈ I⇩s⇩t (M(x := y)) s; y ❙∉ I⇩s⇩t (M(x := y)) t⟧ ⟹ ∃M. M x ❙∈ I⇩s⇩t M s ∧ M x ❙∉ I⇩s⇩t M t ∧ (∀x∈set b. interp I⇩s⇩a M x) ∨ M x ❙∈ I⇩s⇩t M t ∧ M x ❙∉ I⇩s⇩t M s ∧ (∀x∈set b. interp I⇩s⇩a M x)› 2. ‹⟦∀ψ∈set b. interp I⇩s⇩a (M(x := y)) ψ; y ❙∈ I⇩s⇩t (M(x := y)) t; y ❙∉ I⇩s⇩t (M(x := y)) s⟧ ⟹ ∃M. M x ❙∈ I⇩s⇩t M s ∧ M x ❙∉ I⇩s⇩t M t ∧ (∀x∈set b. interp I⇩s⇩a M x) ∨ M x ❙∈ I⇩s⇩t M t ∧ M x ❙∉ I⇩s⇩t M s ∧ (∀x∈set b. interp I⇩s⇩a M x)› discuss goal 1*) apply (metis fun_upd_same (*‹(?f(?x := ?y)) ?x = ?y›*)) (*discuss goal 2*) apply (metis fun_upd_same (*‹((?f::?'b ⇒ ?'a)(?x::?'b := ?y::?'a)) ?x = ?y›*)) (*proven 2 subgoals*) . qed lemma bexpands_sound: assumes "bexpands bs' b" assumes "⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a M ψ" shows "∃M. ∃b' ∈ bs'. ∀ψ ∈ set (b' @ b). interp I⇩s⇩a M ψ" using assms (*‹bexpands bs' b› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) proof (induction rule: bexpands.induct (*‹⟦bexpands ?x1.0 ?x2.0; ⋀bs' b. bexpands_nowit bs' b ⟹ ?P bs' b; ⋀t1 t2 x bs' b. bexpands_wit t1 t2 x bs' b ⟹ ?P bs' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀(bs'::'a pset_atom fm list set) b::'a pset_atom fm list. ⟦bexpands_nowit bs' b; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ ∃M::'a ⇒ hf. ∃b'::'a pset_atom fm list∈bs'. Ball (set (b' @ b)) (interp I⇩s⇩a M)› 2. ‹⋀(t1::'a pset_term) (t2::'a pset_term) (x::'a) (bs'::'a pset_atom fm list set) b::'a pset_atom fm list. ⟦bexpands_wit t1 t2 x bs' b; ⋀ψ::'a pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ψ⟧ ⟹ ∃M::'a ⇒ hf. ∃b'::'a pset_atom fm list∈bs'. Ball (set (b' @ b)) (interp I⇩s⇩a M)›*) case (1 bs' b) (*‹bexpands_nowit bs' b› ‹(?ψ::'a pset_atom fm) ∈ set (b::'a pset_atom fm list) ⟹ interp I⇩s⇩a (M::'a ⇒ hf) ?ψ›*) with bexpands_nowit_sound[OF this ( 1 )] (*‹(⋀ψ. ψ ∈ set b ⟹ interp I⇩s⇩a ?M ψ) ⟹ ∃b'∈bs'. ∀ψ∈set b'. interp I⇩s⇩a ?M ψ›*) have "∃b' ∈ bs'. ∀ψ ∈ set b'. interp I⇩s⇩a M ψ" by blast with "1" (*‹bexpands_nowit bs' b› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) show "?case" (*goal: ‹∃M::'a ⇒ hf. ∃b'::'a pset_atom fm list∈bs'::'a pset_atom fm list set. ∀a::'a pset_atom fm∈set (b' @ (b::'a pset_atom fm list)). interp I⇩s⇩a M a›*) by auto next (*goal: ‹⋀(t1::'a::type pset_term) (t2::'a::type pset_term) (x::'a::type) (bs'::'a::type pset_atom fm list set) b::'a::type pset_atom fm list. ⟦bexpands_wit t1 t2 x bs' b; ⋀ψ::'a::type pset_atom fm. ψ ∈ set b ⟹ interp I⇩s⇩a (M::'a::type ⇒ hf) ψ⟧ ⟹ ∃M::'a::type ⇒ hf. ∃b'::'a::type pset_atom fm list∈bs'. Ball (set (b' @ b)) (interp I⇩s⇩a M)›*) case (2 t1 t2 x bs b) (*‹bexpands_wit t1 t2 x bs b› ‹?ψ ∈ set b ⟹ interp I⇩s⇩a M ?ψ›*) then show "?case" (*goal: ‹∃M::'a ⇒ hf. ∃b'::'a pset_atom fm list∈bs::'a pset_atom fm list set. ∀a::'a pset_atom fm∈set (b' @ (b::'a pset_atom fm list)). interp I⇩s⇩a M a›*) using bexpands_wit_sound (*‹⟦bexpands_wit ?s ?t ?x ?bs' ?b; ⋀ψ. ψ ∈ set ?b ⟹ interp I⇩s⇩a ?M ψ⟧ ⟹ ∃M. ∃b'∈?bs'. ∀ψ∈set (b' @ ?b). interp I⇩s⇩a M ψ›*) by metis qed subsection ‹Upper Bounding the Cardinality of a Branch› lemma Ex_bexpands_wits_if_in_wits: assumes "wf_branch b" assumes "x ∈ wits b" obtains t1 t2 bs b2 b1 where "expandss b (b2 @ b1)" "bexpands_wit t1 t2 x bs b1" "b2 ∈ bs" "expandss b1 [last b]" "x ∉ wits b1" "wits (b2 @ b1) = insert x (wits b1)" proof (-) (*goal: ‹(⋀b2 b1 t1 t2 bs. ⟦expandss b (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [last b]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹wf_branch b› ‹x ∈ wits b›*) obtain φ where "expandss b [φ]" (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) unfolding wf_branch_def (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) by blast then have "last b = φ" by simp from ‹expandss b [φ]› (*‹expandss b [φ]›*) ‹x ∈ wits b› (*‹x ∈ wits b›*) that (*‹⟦expandss b (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [last b]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹thesis›*) unfolding ‹last b = φ› (*goal: ‹thesis›*) proof (induction b "[φ]" rule: expandss.induct (*‹⟦expandss ?x1.0 ?x2.0; ⋀b. ?P b b; ⋀b3 b2 b1. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1; ⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⟦x ∈ wits [φ]; ⋀b2 b1 t1 t2 bs. ⟦expandss [φ] (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis› 2. ‹⋀b3 b2. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 [φ]; ⟦x ∈ wits b2; ⋀b2a b1 t1 t2 bs. ⟦expandss b2 (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b3 @ b2); ⋀b2a b1 t1 t2 bs. ⟦expandss (b3 @ b2) (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis› 3. ‹⋀bs b2 b3. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 [φ]; ⟦x ∈ wits b2; ⋀b2a b1 t1 t2 bs. ⟦expandss b2 (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b3 @ b2); ⋀b2a b1 t1 t2 bs. ⟦expandss (b3 @ b2) (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis›*) case 1 (*‹(x::'a::type) ∈ wits [φ::'a::type pset_atom fm]› ‹⟦expandss [φ::'a::type pset_atom fm] ((?b2.0::'a::type pset_atom fm list) @ (?b1.0::'a::type pset_atom fm list)); bexpands_wit (?t1.0::'a::type pset_term) (?t2.0::'a::type pset_term) (x::'a::type) (?bs::'a::type pset_atom fm list set) ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis::bool›*) then show "?case" (*goal: ‹thesis::bool›*) by simp next (*goals: 1. ‹⋀b3 b2. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 [φ]; ⟦x ∈ wits b2; ⋀b2a b1 t1 t2 bs. ⟦expandss b2 (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b3 @ b2); ⋀b2a b1 t1 t2 bs. ⟦expandss (b3 @ b2) (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis› 2. ‹⋀bs b2 b3. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 [φ]; ⟦x ∈ wits b2; ⋀b2a b1 t1 t2 bs. ⟦expandss b2 (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b3 @ b2); ⋀b2a b1 t1 t2 bs. ⟦expandss (b3 @ b2) (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis›*) case (2 b2 b1) (*‹lexpands (b2::'a::type pset_atom fm list) (b1::'a::type pset_atom fm list)› ‹set b1 ⊂ set (b2 @ b1)› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss ((b2::'a pset_atom fm list) @ (b1::'a pset_atom fm list)) ((?b2.0::'a pset_atom fm list) @ (?b1.0::'a pset_atom fm list)); bexpands_wit (?t1.0::'a pset_term) (?t2.0::'a pset_term) (x::'a) (?bs::'a pset_atom fm list set) ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ::'a pset_atom fm]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis::bool›*) with expandss_mono (*‹expandss ?ys ?xs ⟹ set ?xs ⊆ set ?ys›*) have "b1 ≠ []" by fastforce with lexpands_wits_eq[OF ‹lexpands b2 b1› this] (*‹wits (b2 @ b1) = wits b1›*) "2" (*‹lexpands b2 b1› ‹set b1 ⊂ set (b2 @ b1)› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) show "?case" (*goal: ‹thesis›*) by (metis (no_types, lifting) expandss.intros( (*‹⟦lexpands ?b3.0 ?b2.0; set ?b2.0 ⊂ set (?b3.0 @ ?b2.0); expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) 2)) next (*goal: ‹⋀(bs::'a pset_atom fm list set) (b2::'a pset_atom fm list) b3::'a pset_atom fm list. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 [φ::'a pset_atom fm]; ⟦(x::'a) ∈ wits b2; ⋀(b2a::'a pset_atom fm list) (b1::'a pset_atom fm list) (t1::'a pset_term) (t2::'a pset_term) bs::'a pset_atom fm list set. ⟦expandss b2 (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis::bool⟧ ⟹ thesis; x ∈ wits (b3 @ b2); ⋀(b2a::'a pset_atom fm list) (b1::'a pset_atom fm list) (t1::'a pset_term) (t2::'a pset_term) bs::'a pset_atom fm list set. ⟦expandss (b3 @ b2) (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis›*) case (3 bs_ b2) (*‹bexpands bs b2_› ‹(b2::'a::type pset_atom fm list) ∈ (bs::'a::type pset_atom fm list set)› ‹expandss b2_ [φ]› ‹⟦x ∈ wits b2_; ⋀b2a b1 t1 t2 bs. ⟦expandss b2_ (b2a @ b1); bexpands_wit t1 t2 x bs b1; b2a ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2a @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b2_)› ‹⟦expandss (b2 @ b2_) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) then show "?case" (*goal: ‹thesis›*) proof (induction rule: bexpands.induct (*‹⟦bexpands ?x1.0 ?x2.0; ⋀bs' b. bexpands_nowit bs' b ⟹ ?P bs' b; ⋀t1 t2 x bs' b. bexpands_wit t1 t2 x bs' b ⟹ ?P bs' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀bs' b. ⟦bexpands_nowit bs' b; b2 ∈ bs'; expandss b [φ]; ⟦x ∈ wits b; ⋀b2 b1 t1 t2 bs. ⟦expandss b (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b2 @ b); ⋀b2 b1 t1 t2 bs. ⟦expandss (b2 @ b) (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis› 2. ‹⋀t1 t2 xa bs' b. ⟦bexpands_wit t1 t2 xa bs' b; b2 ∈ bs'; expandss b [φ]; ⟦x ∈ wits b; ⋀b2 b1 t1 t2 bs. ⟦expandss b (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b2 @ b); ⋀b2 b1 t1 t2 bs. ⟦expandss (b2 @ b) (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis›*) case (1 bs b1) (*‹bexpands_nowit bs b1› ‹b2 ∈ bs› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) with expandss_mono (*‹expandss ?ys ?xs ⟹ set ?xs ⊆ set ?ys›*) have "b1 ≠ []" by fastforce with bexpands_nowit_wits_eq[OF ‹bexpands_nowit bs b1› ‹b2 ∈ bs› this] (*‹wits (b2 @ b1) = wits b1›*) "1" (*‹bexpands_nowit bs b1› ‹b2 ∈ bs› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) show "?case" (*goal: ‹thesis›*) by (metis bexpands.intros( (*‹bexpands_nowit ?bs' ?b ⟹ bexpands ?bs' ?b›*) 1) expandss.intros( (*‹⟦bexpands ?bs ?b2.0; ?b3.0 ∈ ?bs; expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) 3)) next (*goal: ‹⋀t1 t2 xa bs' b. ⟦bexpands_wit t1 t2 xa bs' b; b2 ∈ bs'; expandss b [φ]; ⟦x ∈ wits b; ⋀b2 b1 t1 t2 bs. ⟦expandss b (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis; x ∈ wits (b2 @ b); ⋀b2 b1 t1 t2 bs. ⟦expandss (b2 @ b) (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [φ]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ thesis⟧ ⟹ thesis›*) case (2 t1 t2 y bs b1) (*‹bexpands_wit t1 t2 y bs b1› ‹b2 ∈ bs› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) show "?case" (*goal: ‹thesis::bool›*) proof (cases "x ∈ wits b1") (*goals: 1. ‹x ∈ wits b1 ⟹ thesis› 2. ‹x ∉ wits b1 ⟹ thesis›*) case True (*‹(x::'a) ∈ wits (b1::'a pset_atom fm list)›*) from "2" (*‹bexpands_wit t1 t2 y bs b1› ‹b2 ∈ bs› ‹expandss (b1::'a::type pset_atom fm list) [φ::'a::type pset_atom fm]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹(x::'a) ∈ wits ((b2::'a pset_atom fm list) @ (b1::'a pset_atom fm list))› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) have "expandss (b2 @ b1) b1" using expandss.intros(3)[OF _ "2.prems" ( 1 )] (*‹⟦bexpands (bs::'a pset_atom fm list set) (?b2.0::'a pset_atom fm list); expandss ?b2.0 (?b1.0::'a pset_atom fm list)⟧ ⟹ expandss ((b2::'a pset_atom fm list) @ ?b2.0) ?b1.0›*) bexpands.intros(2)[OF "2.hyps"] (*‹bexpands bs b1›*) by (metis expandss.intros( (*‹expandss ?b ?b›*) 1)) with True (*‹x ∈ wits b1›*) "2" (*‹bexpands_wit t1 t2 y bs b1› ‹b2 ∈ bs› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) show "?thesis" (*goal: ‹thesis›*) using expandss_trans (*‹⟦expandss (?b3.0::?'a::type pset_atom fm list) (?b2.0::?'a::type pset_atom fm list); expandss ?b2.0 (?b1.0::?'a::type pset_atom fm list)⟧ ⟹ expandss ?b3.0 ?b1.0›*) by blast next (*goal: ‹x ∉ wits b1 ⟹ thesis›*) case False (*‹x ∉ wits b1›*) from "2" (*‹bexpands_wit (t1::'a pset_term) (t2::'a pset_term) (y::'a) (bs::'a pset_atom fm list set) (b1::'a pset_atom fm list)› ‹(b2::'a pset_atom fm list) ∈ (bs::'a pset_atom fm list set)› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹x ∈ wits (b2 @ b1)› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) have "b1 ≠ []" using expandss_mono (*‹expandss ?ys ?xs ⟹ set ?xs ⊆ set ?ys›*) by fastforce with bexpands_witD[OF "2" ( 1 )] (*‹bs = {[AT (Var y ∈⇩s t1), AF (Var y ∈⇩s t2)], [AT (Var y ∈⇩s t2), AF (Var y ∈⇩s t1)]}› ‹AF (t1 =⇩s t2) ∈ set b1› ‹t1 ∈ subterms (last b1)› ‹t2 ∈ subterms (last b1)› ‹∄x. AT (x ∈⇩s t1) ∈ set b1 ∧ AF (x ∈⇩s t2) ∈ set b1› ‹∄x. AT (x ∈⇩s t2) ∈ set b1 ∧ AF (x ∈⇩s t1) ∈ set b1› ‹¬ urelem (last b1) t1› ‹¬ urelem (last (b1::'a pset_atom fm list)) (t2::'a pset_term)› ‹y ∉ vars b1›*) "2"(2-) (*‹(b2::'a::type pset_atom fm list) ∈ (bs::'a::type pset_atom fm list set)› ‹expandss (b1::'a::type pset_atom fm list) [φ::'a::type pset_atom fm]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹(x::'a::type) ∈ wits ((b2::'a::type pset_atom fm list) @ (b1::'a::type pset_atom fm list))› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) have "wits (b2 @ b1) = insert y (wits b1)" unfolding wits_def (*goal: ‹vars (b2 @ b1) - vars (last (b2 @ b1)) = insert y (vars b1 - vars (last b1))›*) by (metis "2.hyps" (*‹bexpands_wit t1 t2 y bs b1›*) bexpands_wit_wits_eq (*‹⟦bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b; ?b' ∈ ?bs'; ?b ≠ []⟧ ⟹ wits (?b' @ ?b) = insert ?x (wits ?b)›*) wits_def (*‹wits ?b ≡ vars ?b - vars (last ?b)›*)) moreover from ‹y ∉ vars_branch b1› (*‹y ∉ vars b1›*) have "y ∉ wits b1" unfolding wits_def (*goal: ‹y ∉ vars b1 - vars (last b1)›*) by simp moreover from calculation (*‹wits (b2 @ b1) = insert y (wits b1)› ‹y ∉ wits b1›*) have "y = x" using False (*‹x ∉ wits b1›*) "2" (*‹bexpands_wit t1 t2 y bs b1› ‹b2 ∈ bs› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹(x::'a::type) ∈ wits ((b2::'a::type pset_atom fm list) @ (b1::'a::type pset_atom fm list))› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) by simp ultimately show "?thesis" (*goal: ‹thesis›*) using "2" (*‹bexpands_wit t1 t2 y bs b1› ‹b2 ∈ bs› ‹expandss b1 [φ]› ‹⟦x ∈ wits b1; ⋀b2 b1a t1 t2 bs. ⟦expandss b1 (b2 @ b1a); bexpands_wit t1 t2 x bs b1a; b2 ∈ bs; expandss b1a [φ]; x ∉ wits b1a; wits (b2 @ b1a) = insert x (wits b1a)⟧ ⟹ thesis⟧ ⟹ thesis› ‹(x::'a) ∈ wits ((b2::'a pset_atom fm list) @ (b1::'a pset_atom fm list))› ‹⟦expandss (b2 @ b1) (?b2.0 @ ?b1.0); bexpands_wit ?t1.0 ?t2.0 x ?bs ?b1.0; ?b2.0 ∈ ?bs; expandss ?b1.0 [φ]; x ∉ wits ?b1.0; wits (?b2.0 @ ?b1.0) = insert x (wits ?b1.0)⟧ ⟹ thesis›*) by (metis expandss.intros( (*‹expandss ?b ?b›*) 1)) qed qed qed qed lemma card_wits_ub_if_wf_branch: assumes "wf_branch b" shows "card (wits b) ≤ (card (subterms (last b)))²" proof (-) (*goal: ‹card (wits b) ≤ (card (subterms (last b)))²›*) from assms (*‹wf_branch b›*) obtain φ where "expandss b [φ]" (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) unfolding wf_branch_def (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) by blast with wf_branch_not_Nil[OF assms] (*‹b ≠ []›*) have [simp]: "last b = φ" using expandss_last_eq (*‹⟦expandss ?b' ?b; ?b ≠ []⟧ ⟹ last ?b' = last ?b›*) by force have False if card_gt: "card (wits b) > (card (subterms φ))²" proof (-) (*goal: ‹False›*) define ts where "ts ≡ (λx. SOME t1_t2. ∃bs b2 b1. expandss b (b2 @ b1) ∧ b2 ∈ bs ∧ bexpands_wit (fst t1_t2) (snd t1_t2) x bs b1 ∧ expandss b1 [φ])" from ‹expandss b [φ]› (*‹expandss b [φ]›*) ‹last b = φ› (*‹last b = φ›*) have "*": "∃t1_t2 bs b2 b1. expandss b (b2 @ b1) ∧ b2 ∈ bs ∧ bexpands_wit (fst t1_t2) (snd t1_t2) x bs b1 ∧ expandss b1 [φ]" if "x ∈ wits b" for x using that (*‹x ∈ wits b›*) Ex_bexpands_wits_if_in_wits[OF ‹wf_branch b› that] (*‹(⋀t1 t2 bs b2 b1. ⟦expandss b (b2 @ b1); bexpands_wit t1 t2 x bs b1; b2 ∈ bs; expandss b1 [last b]; x ∉ wits b1; wits (b2 @ b1) = insert x (wits b1)⟧ ⟹ ?thesis) ⟹ ?thesis›*) by (metis fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) have ts_wd: "∃bs b2 b1. expandss b (b2 @ b1) ∧ b2 ∈ bs ∧ bexpands_wit t1 t2 x bs b1 ∧ expandss b1 [φ]" if "ts x = (t1, t2)" "x ∈ wits b" for t1 and t2 and x using exE_some[OF * that ( 1 ) [ THEN eq_reflection , symmetric , unfolded ts_def ], OF that ( 2 )] (*‹∃bs b2 b1. expandss b (b2 @ b1) ∧ b2 ∈ bs ∧ bexpands_wit (fst (t1, t2)) (snd (t1, t2)) x bs b1 ∧ expandss b1 [φ]›*) by simp with ‹last b = φ› (*‹last b = φ›*) ‹expandss b [φ]› (*‹expandss (b::'a::type pset_atom fm list) [φ::'a::type pset_atom fm]›*) have in_subterms_fm: "t1 ∈ subterms φ" "t2 ∈ subterms φ" if "ts x = (t1, t2)" "x ∈ wits b" for t1 and t2 and x using that (*‹ts x = (t1, t2)› ‹(x::'a) ∈ wits (b::'a pset_atom fm list)›*) bexpands_witD (*‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ ?bs' = {[AT (Var ?x ∈⇩s ?t1.0), AF (Var ?x ∈⇩s ?t2.0)], [AT (Var ?x ∈⇩s ?t2.0), AF (Var ?x ∈⇩s ?t1.0)]}› ‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ AF (?t1.0 =⇩s ?t2.0) ∈ set ?b› ‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ ?t1.0 ∈ subterms (last ?b)› ‹bexpands_wit (?t1.0::?'a pset_term) (?t2.0::?'a pset_term) (?x::?'a) (?bs'::?'a pset_atom fm list set) (?b::?'a pset_atom fm list) ⟹ ?t2.0 ∈ subterms (last ?b)› ‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ ∄x. AT (x ∈⇩s ?t1.0) ∈ set ?b ∧ AF (x ∈⇩s ?t2.0) ∈ set ?b› ‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ ∄x. AT (x ∈⇩s ?t2.0) ∈ set ?b ∧ AF (x ∈⇩s ?t1.0) ∈ set ?b› ‹bexpands_wit (?t1.0::?'a::type pset_term) (?t2.0::?'a::type pset_term) (?x::?'a::type) (?bs'::?'a::type pset_atom fm list set) (?b::?'a::type pset_atom fm list) ⟹ ¬ urelem (last ?b) ?t1.0› ‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ ¬ urelem (last ?b) ?t2.0› ‹bexpands_wit ?t1.0 ?t2.0 ?x ?bs' ?b ⟹ ?x ∉ vars ?b›*) by ((metis expandss_last_eq (*‹⟦expandss ?b' ?b; ?b ≠ []⟧ ⟹ last ?b' = last ?b›*) list.discI (*‹?list = ?x21.0 # ?x22.0 ⟹ ?list ≠ []›*))+) have "¬ inj_on ts (wits b)" proof (-) (*goal: ‹¬ inj_on (ts::'a ⇒ 'a pset_term × 'a pset_term) (wits (b::'a pset_atom fm list))›*) from in_subterms_fm (*‹⟦ts ?x = (?t1.0, ?t2.0); ?x ∈ wits b⟧ ⟹ ?t1.0 ∈ subterms φ› ‹⟦(ts::'a ⇒ 'a pset_term × 'a pset_term) (?x::'a) = (?t1.0::'a pset_term, ?t2.0::'a pset_term); ?x ∈ wits (b::'a pset_atom fm list)⟧ ⟹ ?t2.0 ∈ subterms (φ::'a pset_atom fm)›*) have "ts ` wits b ⊆ subterms φ × subterms φ" apply (intro subrelI (*‹(⋀x y. (x, y) ∈ ?r ⟹ (x, y) ∈ ?s) ⟹ ?r ⊆ ?s›*)) (*goal: ‹(ts::'a ⇒ 'a pset_term × 'a pset_term) ` wits (b::'a pset_atom fm list) ⊆ subterms (φ::'a pset_atom fm) × subterms φ›*) by (metis imageE (*‹⟦?b ∈ ?f ` ?A; ⋀x. ⟦?b = ?f x; x ∈ ?A⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) mem_Sigma_iff (*‹((?a, ?b) ∈ Sigma ?A ?B) = (?a ∈ ?A ∧ ?b ∈ ?B ?a)›*)) then have "card (ts ` wits b) ≤ card (subterms φ × subterms φ)" apply (intro card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*)) (*goals: 1. ‹(ts::'a ⇒ 'a pset_term × 'a pset_term) ` wits (b::'a pset_atom fm list) ⊆ subterms (φ::'a pset_atom fm) × subterms φ ⟹ finite (subterms φ × subterms φ)› 2. ‹(ts::'a ⇒ 'a pset_term × 'a pset_term) ` wits (b::'a pset_atom fm list) ⊆ subterms (φ::'a pset_atom fm) × subterms φ ⟹ ts ` wits b ⊆ subterms φ × subterms φ› discuss goal 1*) apply (simp add: finite_subterms_fm (*‹finite (subterms ?φ)›*)) (*discuss goal 2*) apply (simp add: finite_subterms_fm (*‹finite (subterms ?φ)›*)) (*proven 2 subgoals*) . moreover have "card (subterms φ × subterms φ) = (card (subterms φ))²" unfolding card_cartesian_product (*goal: ‹card (subterms φ) * card (subterms φ) = (card (subterms φ))²›*) by algebra ultimately show "¬ inj_on ts (wits b)" using card_gt (*‹(card (subterms φ))² < card (wits b)›*) by (metis card_image (*‹inj_on (?f::?'a::type ⇒ ?'b::type) (?A::?'a::type set) ⟹ card (?f ` ?A) = card ?A›*) linorder_not_less (*‹(¬ (?x::?'a::linorder) < (?y::?'a::linorder)) = (?y ≤ ?x)›*)) qed from ‹¬ inj_on ts (wits b)› (*‹¬ inj_on ts (wits b)›*) obtain x and t1 and t2 and xb1 and xbs2 and xb2 and y and yb1 and ybs2 and yb2 where x_y: "x ≠ y" "x ∈ wits b" "y ∈ wits b" "expandss xb1 [φ]" "bexpands_wit t1 t2 x xbs2 xb1" "xb2 ∈ xbs2" "expandss b (xb2 @ xb1)" "expandss yb1 [φ]" "bexpands_wit t1 t2 y ybs2 yb1" "yb2 ∈ ybs2" "expandss b (yb2 @ yb1)" (*goal: ‹(⋀(x::'a::type) (y::'a::type) (xb1::'a::type pset_atom fm list) (t1::'a::type pset_term) (t2::'a::type pset_term) (xbs2::'a::type pset_atom fm list set) (xb2::'a::type pset_atom fm list) (yb1::'a::type pset_atom fm list) (ybs2::'a::type pset_atom fm list set) yb2::'a::type pset_atom fm list. ⟦x ≠ y; x ∈ wits (b::'a::type pset_atom fm list); y ∈ wits b; expandss xb1 [φ::'a::type pset_atom fm]; bexpands_wit t1 t2 x xbs2 xb1; xb2 ∈ xbs2; expandss b (xb2 @ xb1); expandss yb1 [φ]; bexpands_wit t1 t2 y ybs2 yb1; yb2 ∈ ybs2; expandss b (yb2 @ yb1)⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding inj_on_def (*goal: ‹(⋀x y xb1 t1 t2 xbs2 xb2 yb1 ybs2 yb2. ⟦x ≠ y; x ∈ wits b; y ∈ wits b; expandss xb1 [φ]; bexpands_wit t1 t2 x xbs2 xb1; xb2 ∈ xbs2; expandss b (xb2 @ xb1); expandss yb1 [φ]; bexpands_wit t1 t2 y ybs2 yb1; yb2 ∈ ybs2; expandss b (yb2 @ yb1)⟧ ⟹ thesis) ⟹ thesis›*) by (metis ts_wd (*‹⟦ts ?x = (?t1.0, ?t2.0); ?x ∈ wits b⟧ ⟹ ∃bs b2 b1. expandss b (b2 @ b1) ∧ b2 ∈ bs ∧ bexpands_wit ?t1.0 ?t2.0 ?x bs b1 ∧ expandss b1 [φ]›*) prod.exhaust (*‹(⋀x1 x2. ?y = (x1, x2) ⟹ ?P) ⟹ ?P›*)) have "xb2 ≠ yb2" using x_y(5)[THEN bexpands_witD ( 1 )] (*‹xbs2 = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}›*) x_y(9)[THEN bexpands_witD ( 1 )] (*‹ybs2 = {[AT (Var y ∈⇩s t1), AF (Var y ∈⇩s t2)], [AT (Var y ∈⇩s t2), AF (Var y ∈⇩s t1)]}›*) x_y(1,6,10) (*‹(x::'a) ≠ (y::'a)› ‹xb2 ∈ xbs2› ‹yb2 ∈ ybs2›*) by auto moreover from x_y (*‹x ≠ y› ‹x ∈ wits b› ‹y ∈ wits b› ‹expandss (xb1::'a pset_atom fm list) [φ::'a pset_atom fm]› ‹bexpands_wit t1 t2 x xbs2 xb1› ‹xb2 ∈ xbs2› ‹expandss (b::'a::type pset_atom fm list) ((xb2::'a::type pset_atom fm list) @ (xb1::'a::type pset_atom fm list))› ‹expandss yb1 [φ]› ‹bexpands_wit t1 t2 y ybs2 yb1› ‹yb2 ∈ ybs2› ‹expandss b (yb2 @ yb1)›*) have "suffix (xb2 @ xb1) (yb2 @ yb1) ∨ suffix (yb2 @ yb1) (xb2 @ xb1)" using expandss_suffix (*‹expandss (?b1.0::?'a::type pset_atom fm list) (?b2.0::?'a::type pset_atom fm list) ⟹ suffix ?b2.0 ?b1.0›*) suffix_same_cases (*‹⟦suffix (?xs₁::?'a list) (?ys::?'a list); suffix (?xs₂::?'a list) ?ys⟧ ⟹ suffix ?xs₁ ?xs₂ ∨ suffix ?xs₂ ?xs₁›*) by blast then have "suffix (xb2 @ xb1) yb1 ∨ suffix (yb2 @ yb1) xb1" using x_y(5)[THEN bexpands_witD ( 1 )] (*‹xbs2 = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}›*) x_y(9)[THEN bexpands_witD ( 1 )] (*‹(ybs2::'a pset_atom fm list set) = {[AT (Var (y::'a) ∈⇩s (t1::'a pset_term)), AF (Var y ∈⇩s (t2::'a pset_term))], [AT (Var y ∈⇩s t2), AF (Var y ∈⇩s t1)]}›*) x_y(1,6,10) (*‹(x::'a::type) ≠ (y::'a::type)› ‹(xb2::'a pset_atom fm list) ∈ (xbs2::'a pset_atom fm list set)› ‹yb2 ∈ ybs2›*) by (auto simp: suffix_Cons (*‹suffix ?xs (?y # ?ys) = (?xs = ?y # ?ys ∨ suffix ?xs ?ys)›*)) ultimately show False using bexpands_witD(1,5,6)[OF x_y ( 5 )] (*‹xbs2 = {[AT (Var x ∈⇩s t1), AF (Var x ∈⇩s t2)], [AT (Var x ∈⇩s t2), AF (Var x ∈⇩s t1)]}› ‹∄x. AT (x ∈⇩s t1) ∈ set xb1 ∧ AF (x ∈⇩s t2) ∈ set xb1› ‹∄x. AT (x ∈⇩s t2) ∈ set xb1 ∧ AF (x ∈⇩s t1) ∈ set xb1›*) bexpands_witD(1,5,6)[OF x_y ( 9 )] (*‹ybs2 = {[AT (Var y ∈⇩s t1), AF (Var y ∈⇩s t2)], [AT (Var y ∈⇩s t2), AF (Var y ∈⇩s t1)]}› ‹∄x. AT (x ∈⇩s t1) ∈ set yb1 ∧ AF (x ∈⇩s t2) ∈ set yb1› ‹∄x. AT (x ∈⇩s t2) ∈ set yb1 ∧ AF (x ∈⇩s t1) ∈ set yb1›*) x_y(6,10) (*‹xb2 ∈ xbs2› ‹yb2 ∈ ybs2›*) by (auto dest!: set_mono_suffix (*‹suffix ?xs ?ys ⟹ set ?xs ⊆ set ?ys›*)) qed then show "?thesis" (*goal: ‹card (wits b) ≤ (card (subterms (last b)))²›*) using linorder_not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) ‹last b = φ› (*‹last b = φ›*) by blast qed lemma card_subterms_branch_ub_if_wf_branch: assumes "wf_branch b" shows "card (subterms b) ≤ card (subterms (last b)) + card (wits b)" unfolding subterms_branch_eq_if_wf_branch[OF assms, unfolded wits_subterms_def] (*goal: ‹card (Var ` wits b ∪ subterms (last b)) ≤ card (subterms (last b)) + card (wits b)›*) by (simp add: assms (*‹wf_branch b›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) card_image_le (*‹finite ?A ⟹ card (?f ` ?A) ≤ card ?A›*) finite_wits (*‹finite (wits ?b)›*) finite_subterms_fm (*‹finite (subterms ?φ)›*) wits_subterms_last_disjnt (*‹Var ` wits ?b ∩ subterms (last ?b) = {}›*)) lemma card_literals_branch_if_wf_branch: assumes "wf_branch b" shows "card {a ∈ set b. is_literal a} ≤ 2 * (2 * (card (subterms (last b)) + card (wits b))²)" proof (-) (*goal: ‹card {a ∈ set b. is_literal a} ≤ 2 * (2 * (card (subterms (last b)) + card (wits b))²)›*) have "card {a ∈ set b. is_literal a} ≤ card (pset_atoms_branch b) + card (pset_atoms_branch b)" (is "card ?A ≤ _") proof (-) (*goal: ‹card {a ∈ set b. is_literal a} ≤ card (pset_atoms_branch b) + card (pset_atoms_branch b)›*) have "?A = {AT a |a. AT a ∈ set b} ∪ {AF a |a. AF a ∈ set b}" (is "_ = ?ATs ∪ ?AFs") apply auto (*goal: ‹{a ∈ set b. is_literal a} = {AT a |a. AT a ∈ set b} ∪ {AF a |a. AF a ∈ set b}›*) by (metis is_literal.elims( (*‹⟦is_literal ?x; ⋀uu_. ?x = AT uu_ ⟹ ?P; ⋀uv_. ?x = AF uv_ ⟹ ?P⟧ ⟹ ?P›*) 2)) moreover have "?ATs ⊆ AT ` pset_atoms_branch b" "?AFs ⊆ AF ` pset_atoms_branch b" (*goals: 1. ‹{AT a |a::'a pset_atom. AT a ∈ set (b::'a pset_atom fm list)} ⊆ AT ` pset_atoms_branch b› 2. ‹{AF a |a::'a pset_atom. AF a ∈ set (b::'a pset_atom fm list)} ⊆ AF ` pset_atoms_branch b› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) . moreover from calculation (*‹{a::'a pset_atom fm ∈ set (b::'a pset_atom fm list). is_literal a} = {AT a |a::'a pset_atom. AT a ∈ set b} ∪ {AF a |a::'a pset_atom. AF a ∈ set b}› ‹{AT a |a. AT a ∈ set b} ⊆ AT ` pset_atoms_branch b› ‹{AF a |a::'a pset_atom. AF a ∈ set (b::'a pset_atom fm list)} ⊆ AF ` pset_atoms_branch b›*) have "finite ?ATs" "finite ?AFs" apply - (*goals: 1. ‹⟦{a ∈ set b. is_literal a} = {AT a |a. AT a ∈ set b} ∪ {AF a |a. AF a ∈ set b}; {AT a |a. AT a ∈ set b} ⊆ AT ` pset_atoms_branch b; {AF a |a. AF a ∈ set b} ⊆ AF ` pset_atoms_branch b⟧ ⟹ finite {AT a |a. AT a ∈ set b}› 2. ‹⟦{a ∈ set b. is_literal a} = {AT a |a. AT a ∈ set b} ∪ {AF a |a. AF a ∈ set b}; {AT a |a. AT a ∈ set b} ⊆ AT ` pset_atoms_branch b; {AF a |a. AF a ∈ set b} ⊆ AF ` pset_atoms_branch b⟧ ⟹ finite {AF a |a. AF a ∈ set b}› discuss goal 1*) apply (simp add: finite_surj[OF finite_pset_atoms_branch] (*‹(?B::?'b::type set) ⊆ (?f::?'a::type ⇒ ?'b::type) ` pset_atoms_branch (?b1::?'a::type fm list) ⟹ finite ?B›*)) (*discuss goal 2*) apply (simp add: finite_surj[OF finite_pset_atoms_branch] (*‹?B ⊆ ?f ` pset_atoms_branch ?b1 ⟹ finite ?B›*)) (*proven 2 subgoals*) . moreover have "?ATs ∩ ?AFs = {}" by auto ultimately show "?thesis" (*goal: ‹card {a ∈ set b. is_literal a} ≤ card (pset_atoms_branch b) + card (pset_atoms_branch b)›*) by (simp add: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) finite_pset_atoms_branch (*‹finite (pset_atoms_branch ?b)›*) surj_card_le (*‹⟦finite ?A; ?B ⊆ ?f ` ?A⟧ ⟹ card ?B ≤ card ?A›*)) qed then have "card ?A ≤ 2 * card (pset_atoms_branch b)" by simp moreover have "atoms φ ⊆ case_prod Elem ` (subterms φ × subterms φ) ∪ case_prod Equal ` (subterms φ × subterms φ)" for φ :: "'a pset_fm" proof (induction φ) (*goals: 1. ‹⋀x. atoms (AT x) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (AT x) × subterms (AT x)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (AT x) × subterms (AT x))› 2. ‹⋀φ1 φ2. ⟦atoms φ1 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ1 × subterms φ1) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ1 × subterms φ1); atoms φ2 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ2 × subterms φ2) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ2 × subterms φ2)⟧ ⟹ atoms (And φ1 φ2) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (And φ1 φ2) × subterms (And φ1 φ2)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (And φ1 φ2) × subterms (And φ1 φ2))› 3. ‹⋀φ1 φ2. ⟦atoms φ1 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ1 × subterms φ1) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ1 × subterms φ1); atoms φ2 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ2 × subterms φ2) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ2 × subterms φ2)⟧ ⟹ atoms (Or φ1 φ2) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (Or φ1 φ2) × subterms (Or φ1 φ2)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (Or φ1 φ2) × subterms (Or φ1 φ2))› 4. ‹⋀φ. atoms φ ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ × subterms φ) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ × subterms φ) ⟹ atoms (Neg φ) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (Neg φ) × subterms (Neg φ)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (Neg φ) × subterms (Neg φ))›*) case (Atom x) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹atoms (AT x) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (AT x) × subterms (AT x)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (AT x) × subterms (AT x))›*) apply (cases x) (*goals: 1. ‹⋀x11 x12. x = x11 ∈⇩s x12 ⟹ atoms (AT x) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (AT x) × subterms (AT x)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (AT x) × subterms (AT x))› 2. ‹⋀x21 x22. x = x21 =⇩s x22 ⟹ atoms (AT x) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (AT x) × subterms (AT x)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (AT x) × subterms (AT x))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (auto) (*solves the remaining goals: 1. ‹⋀φ1 φ2. ⟦atoms φ1 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ1 × subterms φ1) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ1 × subterms φ1); atoms φ2 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ2 × subterms φ2) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ2 × subterms φ2)⟧ ⟹ atoms (And φ1 φ2) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (And φ1 φ2) × subterms (And φ1 φ2)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (And φ1 φ2) × subterms (And φ1 φ2))› 2. ‹⋀φ1 φ2. ⟦atoms φ1 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ1 × subterms φ1) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ1 × subterms φ1); atoms φ2 ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ2 × subterms φ2) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ2 × subterms φ2)⟧ ⟹ atoms (Or φ1 φ2) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (Or φ1 φ2) × subterms (Or φ1 φ2)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (Or φ1 φ2) × subterms (Or φ1 φ2))› 3. ‹⋀φ. atoms φ ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms φ × subterms φ) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms φ × subterms φ) ⟹ atoms (Neg φ) ⊆ (λa. case a of (a, b) ⇒ a ∈⇩s b) ` (subterms (Neg φ) × subterms (Neg φ)) ∪ (λa. case a of (a, b) ⇒ a =⇩s b) ` (subterms (Neg φ) × subterms (Neg φ))›*) then have "pset_atoms_branch b ⊆ case_prod Elem ` (subterms b × subterms b) ∪ case_prod Equal ` (subterms b × subterms b)" (is "_ ⊆ ?Els ∪ ?Eqs") unfolding subterms_branch_def (*goal: ‹pset_atoms_branch b ⊆ (λ(x, y). x ∈⇩s y) ` (⋃ (subterms ` set b) × ⋃ (subterms ` set b)) ∪ (λ(x, y). x =⇩s y) ` (⋃ (subterms ` set b) × ⋃ (subterms ` set b))›*) by force have "card (pset_atoms_branch b) ≤ (card (subterms b))² + (card (subterms b))²" proof (-) (*goal: ‹card (pset_atoms_branch b) ≤ (card (subterms b))² + (card (subterms b))²›*) from finite_subterms_branch (*‹finite (subterms ?b)›*) have "finite (subterms b × subterms b)" using finite_cartesian_product (*‹⟦finite ?A; finite ?B⟧ ⟹ finite (?A × ?B)›*) by auto then have "finite ?Els" "finite ?Eqs" apply - (*goals: 1. ‹finite (subterms b × subterms b) ⟹ finite ((λ(x, y). x ∈⇩s y) ` (subterms b × subterms b))› 2. ‹finite (subterms b × subterms b) ⟹ finite ((λ(x, y). x =⇩s y) ` (subterms b × subterms b))› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . moreover have "inj_on (case_prod Elem) A" "inj_on (case_prod Equal) A" for A :: "('a pset_term × 'a pset_term) set" unfolding inj_on_def (*goals: 1. ‹∀x∈A. ∀y∈A. (case x of (x, xa) ⇒ x ∈⇩s xa) = (case y of (x, xa) ⇒ x ∈⇩s xa) ⟶ x = y› 2. ‹∀x∈A. ∀y∈A. (case x of (x, xa) ⇒ x =⇩s xa) = (case y of (x, xa) ⇒ x =⇩s xa) ⟶ x = y›*) (*goals: 1. ‹∀x∈A. ∀y∈A. (case x of (x, xa) ⇒ x ∈⇩s xa) = (case y of (x, xa) ⇒ x ∈⇩s xa) ⟶ x = y› 2. ‹∀x∈A. ∀y∈A. (case x of (x, xa) ⇒ x =⇩s xa) = (case y of (x, xa) ⇒ x =⇩s xa) ⟶ x = y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately have "card ?Els = (card (subterms b))²" "card ?Eqs = (card (subterms b))²" using card_image[where ?A = "subterms b × subterms b"] (*‹inj_on ?f (subterms b × subterms b) ⟹ card (?f ` (subterms b × subterms b)) = card (subterms b × subterms b)›*) card_cartesian_product (*‹card (?A × ?B) = card ?A * card ?B›*) unfolding power2_eq_square (*goals: 1. ‹card ((λ(x, y). x ∈⇩s y) ` (subterms b × subterms b)) = card (subterms b) * card (subterms b)› 2. ‹card ((λ(x, y). x =⇩s y) ` (subterms b × subterms b)) = card (subterms b) * card (subterms b)›*) by ((metis)+) with card_mono[OF _ ‹pset_atoms_branch b ⊆ ?Els ∪ ?Eqs›] (*‹finite ((λ(x, y). x ∈⇩s y) ` (subterms b × subterms b) ∪ (λ(x, y). x =⇩s y) ` (subterms b × subterms b)) ⟹ card (pset_atoms_branch b) ≤ card ((λ(x, y). x ∈⇩s y) ` (subterms b × subterms b) ∪ (λ(x, y). x =⇩s y) ` (subterms b × subterms b))›*) show "?thesis" (*goal: ‹card (pset_atoms_branch b) ≤ (card (subterms b))² + (card (subterms b))²›*) using ‹finite ?Els› (*‹finite ((λ(x::'a pset_term, y::'a pset_term). x ∈⇩s y) ` (subterms (b::'a pset_atom fm list) × subterms b))›*) ‹finite ?Eqs› (*‹finite ((λ(x, y). x =⇩s y) ` (subterms b × subterms b))›*) by (metis card_Un_le (*‹card ((?A::?'a set) ∪ (?B::?'a set)) ≤ card ?A + card ?B›*) finite_UnI (*‹⟦finite (?F::?'a set); finite (?G::?'a set)⟧ ⟹ finite (?F ∪ ?G)›*) sup.boundedE (*‹⟦sup (?b::?'a) (?c::?'a) ≤ (?a::?'a); ⟦?b ≤ ?a; ?c ≤ ?a⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) sup_absorb2 (*‹(?x::?'a) ≤ (?y::?'a) ⟹ sup ?x ?y = ?y›*)) qed then have "card (pset_atoms_branch b) ≤ 2 * (card (subterms b))²" by simp ultimately show "?thesis" (*goal: ‹card {a ∈ set b. is_literal a} ≤ 2 * (2 * (card (subterms (last b)) + card (wits b))²)›*) using card_subterms_branch_ub_if_wf_branch[OF assms] (*‹card (subterms b) ≤ card (subterms (last b)) + card (wits b)›*) by (meson dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) mult_le_mono2 (*‹?i ≤ ?j ⟹ ?k * ?i ≤ ?k * ?j›*) power2_nat_le_eq_le (*‹(?m² ≤ ?n²) = (?m ≤ ?n)›*)) qed lemma lexpands_not_literal_mem_subfms_last: defines "P ≡ (λb. ∀ψ ∈ set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b))" assumes "lexpands b' b" "b ≠ []" assumes "P b" shows "P (b' @ b)" using assms(2-) (*‹lexpands b' b› ‹b ≠ []› ‹P b›*) apply (induction b' b rule: lexpands_induct (*‹⟦lexpands ?b' ?b; ⋀p q b. And p q ∈ set b ⟹ ?P [p, q] b; ⋀p q b. Neg (Or p q) ∈ set b ⟹ ?P [Neg p, Neg q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b⟧ ⟹ ?P [q] b; ⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b⟧ ⟹ ?P [p] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b⟧ ⟹ ?P [Neg q] b; ⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b⟧ ⟹ ?P [Neg p] b; ⋀p b. Neg (Neg p) ∈ set b ⟹ ?P [p] b; ⋀s t1 t2 b. AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b ⟹ ?P [AF (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊔⇩s t2)] b; ⋀s t1 t2 b. AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AT (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 ⊓⇩s t2)] b; ⋀s t1 t2 b. AT (s ∈⇩s t1 -⇩s t2) ∈ set b ⟹ ?P [AT (s ∈⇩s t1), AF (s ∈⇩s t2)] b; ⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AF (s ∈⇩s t1 -⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b⟧ ⟹ ?P [AT (s ∈⇩s t2)] b; ⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b⟧ ⟹ ?P [AF (s ∈⇩s t1)] b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b)⟧ ⟹ ?P [AT (s ∈⇩s t1 -⇩s t2)] b; ⋀t1 b. Single t1 ∈ subterms (last b) ⟹ ?P [AT (t1 ∈⇩s Single t1)] b; ⋀s t1 b. AT (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AT (s =⇩s t1)] b; ⋀s t1 b. AF (s ∈⇩s Single t1) ∈ set b ⟹ ?P [AF (s =⇩s t1)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t1 t2 l)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t1 t2 l)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AT (subst_tlvl t2 t1 l)] b; ⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l⟧ ⟹ ?P [AF (subst_tlvl t2 t1 l)] b; ⋀s t b s'. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b⟧ ⟹ ?P [AF (s =⇩s s')] b⟧ ⟹ ?P ?b' ?b›*)) (*goals: 1. ‹⋀p q b. ⟦And p q ∈ set b; b ≠ []; P b⟧ ⟹ P ([p, q] @ b)› 2. ‹⋀p q b. ⟦Neg (Or p q) ∈ set b; b ≠ []; P b⟧ ⟹ P ([Neg p, Neg q] @ b)› 3. ‹⋀p q b. ⟦Or p q ∈ set b; Neg p ∈ set b; b ≠ []; P b⟧ ⟹ P ([q] @ b)› 4. ‹⋀p q b. ⟦Or p q ∈ set b; Neg q ∈ set b; b ≠ []; P b⟧ ⟹ P ([p] @ b)› 5. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; p ∈ set b; b ≠ []; P b⟧ ⟹ P ([Neg q] @ b)› 6. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; q ∈ set b; b ≠ []; P b⟧ ⟹ P ([Neg p] @ b)› 7. ‹⋀p b. ⟦Neg (Neg p) ∈ set b; b ≠ []; P b⟧ ⟹ P ([p] @ b)› 8. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)› 9. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 10. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 11. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t1) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t2)] @ b)› 12. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1)] @ b)› 13. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1 ⊔⇩s t2)] @ b)› 14. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1), AT (s ∈⇩s t2)] @ b)› 15. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 16. ‹⋀s t2 b t1. ⟦AF (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 17. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t2)] @ b)› 18. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 ⊓⇩s t2) ∈ set b; AT (s ∈⇩s t2) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1)] @ b)› 19. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AT (s ∈⇩s t2) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1 ⊓⇩s t2)] @ b)› 20. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 -⇩s t2) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1), AF (s ∈⇩s t2)] @ b)› 21. ‹⋀s t1 b t2. ⟦AF (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1 -⇩s t2)] @ b)› 22. ‹⋀s t2 b t1. ⟦AT (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1 -⇩s t2)] @ b)› 23. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AT (s ∈⇩s t1) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t2)] @ b)› 24. ‹⋀s t1 t2 b. ⟦AF (s ∈⇩s t1 -⇩s t2) ∈ set b; AF (s ∈⇩s t2) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AF (s ∈⇩s t1)] @ b)› 25. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; AF (s ∈⇩s t2) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AT (s ∈⇩s t1 -⇩s t2)] @ b)› 26. ‹⋀t1 b. ⟦Single t1 ∈ subterms (last b); b ≠ []; P b⟧ ⟹ P ([AT (t1 ∈⇩s Single t1)] @ b)› 27. ‹⋀s t1 b. ⟦AT (s ∈⇩s Single t1) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AT (s =⇩s t1)] @ b)› 28. ‹⋀s t1 b. ⟦AF (s ∈⇩s Single t1) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AF (s =⇩s t1)] @ b)› 29. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []; P b⟧ ⟹ P ([AT (subst_tlvl t1 t2 l)] @ b)› 30. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t1 ∈ tlvl_terms l; b ≠ []; P b⟧ ⟹ P ([AF (subst_tlvl t1 t2 l)] @ b)› 31. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AT l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []; P b⟧ ⟹ P ([AT (subst_tlvl t2 t1 l)] @ b)› 32. ‹⋀t1 t2 b l. ⟦AT (t1 =⇩s t2) ∈ set b; AF l ∈ set b; t2 ∈ tlvl_terms l; b ≠ []; P b⟧ ⟹ P ([AF (subst_tlvl t2 t1 l)] @ b)› 33. ‹⋀s t b s'. ⟦AT (s ∈⇩s t) ∈ set b; AF (s' ∈⇩s t) ∈ set b; b ≠ []; P b⟧ ⟹ P ([AF (s =⇩s s')] @ b)› discuss goal 1*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 2*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 3*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 4*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 5*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 6*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 7*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 8*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 9*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 10*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 11*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 12*) apply (fastforce simp: P_def (*‹P::'a::type pset_atom fm list ⇒ bool ≡ λb::'a::type pset_atom fm list. ∀ψ::'a::type pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 13*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 14*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 15*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 16*) apply (fastforce simp: P_def (*‹P::'a::type pset_atom fm list ⇒ bool ≡ λb::'a::type pset_atom fm list. ∀ψ::'a::type pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a::type fm) (?q::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a::type fm) ∈ subfms (?φ::?'a::type fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 17*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 18*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 19*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 20*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 21*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 22*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 23*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 24*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 25*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 26*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 27*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 28*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 29*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 30*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 31*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 32*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 33*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*proven 33 subgoals*) . lemma bexpands_not_literal_mem_subfms_last: defines "P ≡ (λb. ∀ψ ∈ set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b))" assumes "bexpands bs b" "b' ∈ bs" "b ≠ []" assumes "P b" shows "P (b' @ b)" using assms(2-) (*‹bexpands bs b› ‹b' ∈ bs› ‹(b::'a::type pset_atom fm list) ≠ []› ‹P b›*) proof (induction bs b rule: bexpands.induct (*‹⟦bexpands ?x1.0 ?x2.0; ⋀bs' b. bexpands_nowit bs' b ⟹ ?P bs' b; ⋀t1 t2 x bs' b. bexpands_wit t1 t2 x bs' b ⟹ ?P bs' b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀bs' b. ⟦bexpands_nowit bs' b; b' ∈ bs'; b ≠ []; P b⟧ ⟹ P (b' @ b)› 2. ‹⋀t1 t2 x bs' b. ⟦bexpands_wit t1 t2 x bs' b; b' ∈ bs'; b ≠ []; P b⟧ ⟹ P (b' @ b)›*) case (1 bs' b) (*‹bexpands_nowit bs' b› ‹(b'::'a::type pset_atom fm list) ∈ (bs'::'a::type pset_atom fm list set)› ‹b ≠ []› ‹(P::'a::type pset_atom fm list ⇒ bool) (b::'a::type pset_atom fm list)›*) then show "?case" (*goal: ‹P (b' @ b)›*) apply (induction rule: bexpands_nowit.induct (*‹⟦bexpands_nowit ?x1.0 ?x2.0; ⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b⟧ ⟹ ?P {[p], [Neg p]} b; ⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b⟧ ⟹ ?P {[Neg p], [p]} b; ⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b; ⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b⟧ ⟹ ?P {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀p q b. ⟦Or p q ∈ set b; p ∉ set b; Neg p ∉ set b; b' ∈ {[p], [Neg p]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 2. ‹⋀p q b. ⟦Neg (And p q) ∈ set b; Neg p ∉ set b; p ∉ set b; b' ∈ {[Neg p], [p]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 3. ‹⋀s t1 t2 b. ⟦AT (s ∈⇩s t1 ⊔⇩s t2) ∈ set b; t1 ⊔⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t1) ∉ set b; AF (s ∈⇩s t1) ∉ set b; b' ∈ {[AT (s ∈⇩s t1)], [AF (s ∈⇩s t1)]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 4. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 ⊓⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› 5. ‹⋀s t1 b t2. ⟦AT (s ∈⇩s t1) ∈ set b; t1 -⇩s t2 ∈ subterms (last b); AT (s ∈⇩s t2) ∉ set b; AF (s ∈⇩s t2) ∉ set b; b' ∈ {[AT (s ∈⇩s t2)], [AF (s ∈⇩s t2)]}; b ≠ []; P b⟧ ⟹ P (b' @ b)› discuss goal 1*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 2*) apply (fastforce simp: P_def (*‹P::'a pset_atom fm list ⇒ bool ≡ λb::'a pset_atom fm list. ∀ψ::'a pset_atom fm∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹And (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ› ‹Or (?p::?'a fm) (?q::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?q ∈ subfms ?φ› ‹Neg (?p::?'a fm) ∈ subfms (?φ::?'a fm) ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 3*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 4*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*discuss goal 5*) apply (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) (*proven 5 subgoals*) . next (*goal: ‹⋀(t1::'a pset_term) (t2::'a pset_term) (x::'a) (bs'::'a pset_atom fm list set) b::'a pset_atom fm list. ⟦bexpands_wit t1 t2 x bs' b; (b'::'a pset_atom fm list) ∈ bs'; b ≠ []; (P::'a pset_atom fm list ⇒ bool) b⟧ ⟹ P (b' @ b)›*) case (2 t1 t2 x bs' b) (*‹bexpands_wit t1 t2 x bs' b› ‹b' ∈ bs'› ‹b ≠ []› ‹P b›*) then show "?case" (*goal: ‹P (b' @ b)›*) apply (induction rule: bexpands_wit.induct (*‹⟦bexpands_wit ?t1.0 ?t2.0 ?x ?x1.0 ?x2.0; ⋀b. ⟦AF (?t1.0 =⇩s ?t2.0) ∈ set b; ?t1.0 ∈ subterms (last b); ?t2.0 ∈ subterms (last b); ∄x. AT (x ∈⇩s ?t1.0) ∈ set b ∧ AF (x ∈⇩s ?t2.0) ∈ set b; ∄x. AT (x ∈⇩s ?t2.0) ∈ set b ∧ AF (x ∈⇩s ?t1.0) ∈ set b; ?x ∉ vars b; ¬ urelem (last b) ?t1.0; ¬ urelem (last b) ?t2.0⟧ ⟹ ?P {[AT (Var ?x ∈⇩s ?t1.0), AF (Var ?x ∈⇩s ?t2.0)], [AT (Var ?x ∈⇩s ?t2.0), AF (Var ?x ∈⇩s ?t1.0)]} b⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goal: ‹(P::'a::type pset_atom fm list ⇒ bool) ((b'::'a::type pset_atom fm list) @ (b::'a::type pset_atom fm list))›*) by (fastforce simp: P_def (*‹P ≡ λb. ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) dest: subfmsD (*‹And ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹And ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ› ‹Or ?p ?q ∈ subfms ?φ ⟹ ?q ∈ subfms ?φ› ‹Neg ?p ∈ subfms ?φ ⟹ ?p ∈ subfms ?φ›*)) qed lemma expandss_not_literal_mem_subfms_last: defines "P ≡ (λb. ∀ψ ∈ set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b))" assumes "expandss b' b" "b ≠ []" assumes "P b" shows "P b'" using assms(2-) (*‹expandss (b'::'a pset_atom fm list) (b::'a pset_atom fm list)› ‹b ≠ []› ‹P b›*) proof (induction b' b rule: expandss.induct (*‹⟦expandss ?x1.0 ?x2.0; ⋀b. ?P b b; ⋀b3 b2 b1. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1; ⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ?P b2 b1⟧ ⟹ ?P (b3 @ b2) b1⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀b. ⟦b ≠ []; P b⟧ ⟹ P b› 2. ‹⋀b3 b2 b1. ⟦lexpands b3 b2; set b2 ⊂ set (b3 @ b2); expandss b2 b1; ⟦b1 ≠ []; P b1⟧ ⟹ P b2; b1 ≠ []; P b1⟧ ⟹ P (b3 @ b2)› 3. ‹⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ⟦b1 ≠ []; P b1⟧ ⟹ P b2; b1 ≠ []; P b1⟧ ⟹ P (b3 @ b2)›*) case (2 b3 b2 b1) (*‹lexpands (b3::'a pset_atom fm list) (b2::'a pset_atom fm list)› ‹set b2 ⊂ set (b3 @ b2)› ‹expandss b2 b1› ‹⟦(b1::'a::type pset_atom fm list) ≠ []; (P::'a::type pset_atom fm list ⇒ bool) b1⟧ ⟹ P (b2::'a::type pset_atom fm list)› ‹b1 ≠ []› ‹P b1›*) then have "b2 ≠ []" using expandss_suffix (*‹expandss (?b1.0::?'a pset_atom fm list) (?b2.0::?'a pset_atom fm list) ⟹ suffix ?b2.0 ?b1.0›*) suffix_bot.extremum_uniqueI (*‹suffix ?a [] ⟹ ?a = []›*) by blast with "2" (*‹lexpands (b3::'a::type pset_atom fm list) (b2::'a::type pset_atom fm list)› ‹set b2 ⊂ set (b3 @ b2)› ‹expandss b2 b1› ‹⟦(b1::'a pset_atom fm list) ≠ []; (P::'a pset_atom fm list ⇒ bool) b1⟧ ⟹ P (b2::'a pset_atom fm list)› ‹(b1::'a::type pset_atom fm list) ≠ []› ‹P b1›*) show "?case" (*goal: ‹P (b3 @ b2)›*) using lexpands_not_literal_mem_subfms_last (*‹⟦lexpands ?b' ?b; ?b ≠ []; ∀ψ∈set ?b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last ?b) ∨ ψ ∈ Neg ` subfms (last ?b)⟧ ⟹ ∀ψ∈set (?b' @ ?b). ¬ is_literal ψ ⟶ ψ ∈ subfms (last (?b' @ ?b)) ∨ ψ ∈ Neg ` subfms (last (?b' @ ?b))›*) unfolding P_def (*goal: ‹∀ψ∈set (b3 @ b2). ¬ is_literal ψ ⟶ ψ ∈ subfms (last (b3 @ b2)) ∨ ψ ∈ Neg ` subfms (last (b3 @ b2))›*) by blast next (*goals: 1. ‹⋀b. ⟦b ≠ []; P b⟧ ⟹ P b› 2. ‹⋀bs b2 b3 b1. ⟦bexpands bs b2; b3 ∈ bs; expandss b2 b1; ⟦b1 ≠ []; P b1⟧ ⟹ P b2; b1 ≠ []; P b1⟧ ⟹ P (b3 @ b2)›*) case (3 bs b2 b3 b1) (*‹bexpands (bs::'a::type pset_atom fm list set) (b2::'a::type pset_atom fm list)› ‹b3 ∈ bs› ‹expandss (b2::'a pset_atom fm list) (b1::'a pset_atom fm list)› ‹⟦b1 ≠ []; P b1⟧ ⟹ P b2› ‹(b1::'a pset_atom fm list) ≠ []› ‹(P::'a pset_atom fm list ⇒ bool) (b1::'a pset_atom fm list)›*) then have "b2 ≠ []" using expandss_suffix (*‹expandss ?b1.0 ?b2.0 ⟹ suffix ?b2.0 ?b1.0›*) suffix_bot.extremum_uniqueI (*‹suffix ?a [] ⟹ ?a = []›*) by blast with "3" (*‹bexpands bs b2› ‹b3 ∈ bs› ‹expandss (b2::'a::type pset_atom fm list) (b1::'a::type pset_atom fm list)› ‹⟦b1 ≠ []; P b1⟧ ⟹ P b2› ‹(b1::'a pset_atom fm list) ≠ []› ‹P b1›*) show "?case" (*goal: ‹P (b3 @ b2)›*) using bexpands_not_literal_mem_subfms_last (*‹⟦bexpands ?bs ?b; ?b' ∈ ?bs; ?b ≠ []; ∀ψ∈set ?b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last ?b) ∨ ψ ∈ Neg ` subfms (last ?b)⟧ ⟹ ∀ψ∈set (?b' @ ?b). ¬ is_literal ψ ⟶ ψ ∈ subfms (last (?b' @ ?b)) ∨ ψ ∈ Neg ` subfms (last (?b' @ ?b))›*) unfolding P_def (*goal: ‹∀ψ::'a pset_atom fm∈set ((b3::'a pset_atom fm list) @ (b2::'a pset_atom fm list)). ¬ is_literal ψ ⟶ ψ ∈ subfms (last (b3 @ b2)) ∨ ψ ∈ Neg ` subfms (last (b3 @ b2))›*) by blast qed (simp) (*solved the remaining goal: ‹⋀b. ⟦b ≠ []; P b⟧ ⟹ P b›*) lemma card_not_literal_branch_if_wf_branch: assumes "wf_branch b" shows "card {φ ∈ set b. ¬ is_literal φ} ≤ 2 * card (subfms (last b))" proof (-) (*goal: ‹card {φ ∈ set b. ¬ is_literal φ} ≤ 2 * card (subfms (last b))›*) from assms (*‹wf_branch b›*) obtain φ where "expandss b [φ]" (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) unfolding wf_branch_def (*goal: ‹(⋀φ. expandss b [φ] ⟹ thesis) ⟹ thesis›*) by blast then have [simp]: "last b = φ" by simp have "{ψ ∈ set b. ¬ is_literal ψ} ⊆ subfms φ ∪ Neg ` subfms φ" using expandss_not_literal_mem_subfms_last[OF ‹expandss b [φ]›] (*‹⟦[φ] ≠ []; ∀ψ∈set [φ]. ¬ is_literal ψ ⟶ ψ ∈ subfms (last [φ]) ∨ ψ ∈ Neg ` subfms (last [φ])⟧ ⟹ ∀ψ∈set b. ¬ is_literal ψ ⟶ ψ ∈ subfms (last b) ∨ ψ ∈ Neg ` subfms (last b)›*) by auto from card_mono[OF _ this] (*‹finite (subfms φ ∪ Neg ` subfms φ) ⟹ card {ψ ∈ set b. ¬ is_literal ψ} ≤ card (subfms φ ∪ Neg ` subfms φ)›*) have "card {ψ ∈ set b. ¬ is_literal ψ} ≤ card (subfms φ ∪ Neg ` subfms φ)" using finite_subfms (*‹finite (subfms ?φ)›*) finite_imageI (*‹finite ?F ⟹ finite (?h ` ?F)›*) by fast also (*calculation: ‹card {ψ ∈ set b. ¬ is_literal ψ} ≤ card (subfms φ ∪ Neg ` subfms φ)›*) have "… ≤ card (subfms φ) + card (Neg ` subfms φ)" using card_Un_le (*‹card ((?A::?'a set) ∪ (?B::?'a set)) ≤ card ?A + card ?B›*) by blast also (*calculation: ‹card {ψ::'a pset_atom fm ∈ set (b::'a pset_atom fm list). ¬ is_literal ψ} ≤ card (subfms (φ::'a pset_atom fm)) + card (Neg ` subfms φ)›*) have "… ≤ 2 * card (subfms φ)" unfolding mult_2 (*goal: ‹card (subfms φ) + card (Neg ` subfms φ) ≤ card (subfms φ) + card (subfms φ)›*) by (simp add: card_image_le (*‹finite ?A ⟹ card (?f ` ?A) ≤ card ?A›*) finite_subfms (*‹finite (subfms ?φ)›*)) finally (*calculation: ‹card {ψ ∈ set b. ¬ is_literal ψ} ≤ 2 * card (subfms φ)›*) show "?thesis" (*goal: ‹card {φ ∈ set b. ¬ is_literal φ} ≤ 2 * card (subfms (last b))›*) by simp qed lemma card_wf_branch_ub: assumes "wf_branch b" shows "card (set b) ≤ 2 * card (subfms (last b)) + 16 * (card (subterms (last b)))^4" proof (-) (*goal: ‹card (set b) ≤ 2 * card (subfms (last b)) + 16 * card (subterms (last b)) ^ 4›*) let ?csts = "card (subterms (last b))" have "set b = {ψ ∈ set b. ¬ is_literal ψ} ∪ {ψ ∈ set b. is_literal ψ}" by auto then have "card (set b) = card ({ψ ∈ set b. ¬ is_literal ψ}) + card ({ψ ∈ set b. is_literal ψ})" using card_Un_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ card (?A ∪ ?B) = card ?A + card ?B›*) finite_Un (*‹finite ((?F::?'a set) ∪ (?G::?'a set)) = (finite ?F ∧ finite ?G)›*) by (metis (no_types, lifting) List.finite_set (*‹finite (set ?xs)›*) disjoint_iff (*‹(?A ∩ ?B = {}) = (∀x. x ∈ ?A ⟶ x ∉ ?B)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*)) also (*calculation: ‹card (set b) = card {ψ ∈ set b. ¬ is_literal ψ} + card {ψ ∈ set b. is_literal ψ}›*) have "… ≤ 2 * card (subfms (last b)) + 4 * (?csts + card (wits b))²" using assms (*‹wf_branch b›*) card_literals_branch_if_wf_branch (*‹wf_branch ?b ⟹ card {a ∈ set ?b. is_literal a} ≤ 2 * (2 * (card (subterms (last ?b)) + card (wits ?b))²)›*) card_not_literal_branch_if_wf_branch (*‹wf_branch ?b ⟹ card {φ ∈ set ?b. ¬ is_literal φ} ≤ 2 * card (subfms (last ?b))›*) by fastforce also (*calculation: ‹card (set b) ≤ 2 * card (subfms (last b)) + 4 * (card (subterms (last b)) + card (wits b))²›*) have "… ≤ 2 * card (subfms (last b)) + 4 * (?csts + ?csts²)²" using assms (*‹wf_branch b›*) card_wits_ub_if_wf_branch (*‹wf_branch (?b::?'a pset_atom fm list) ⟹ card (wits ?b) ≤ (card (subterms (last ?b)))²›*) by auto also (*calculation: ‹card (set b) ≤ 2 * card (subfms (last b)) + 4 * (card (subterms (last b)) + (card (subterms (last b)))²)²›*) have "… ≤ 2 * card (subfms (last b)) + 16 * ?csts^4" proof (-) (*goal: ‹2 * card (subfms (last b)) + 4 * (card (subterms (last b)) + (card (subterms (last b)))²)² ≤ 2 * card (subfms (last b)) + 16 * card (subterms (last b)) ^ 4›*) have "1 ≤ ?csts" using finite_subterms_fm[THEN card_0_eq] (*‹(card (subterms ?φ1) = 0) = (subterms ?φ1 = {})›*) by (auto intro: Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*)) then have "(?csts + ?csts²)² = ?csts² + 2 * ?csts^3 + ?csts^4" by algebra also (*calculation: ‹(card (subterms (last b)) + (card (subterms (last b)))²)² = (card (subterms (last b)))² + 2 * card (subterms (last b)) ^ 3 + card (subterms (last b)) ^ 4›*) have "… ≤ ?csts² + 2 * ?csts^4 + ?csts^4" using power_increasing[OF _ ‹1 ≤ ?csts›] (*‹?n ≤ ?N ⟹ card (subterms (last b)) ^ ?n ≤ card (subterms (last b)) ^ ?N›*) by simp also (*calculation: ‹(card (subterms (last b)) + (card (subterms (last b)))²)² ≤ (card (subterms (last b)))² + 2 * card (subterms (last b)) ^ 4 + card (subterms (last b)) ^ 4›*) have "… ≤ ?csts^4 + 2 * ?csts^4 + ?csts^4" using power_increasing[OF _ ‹1 ≤ ?csts›] (*‹?n ≤ ?N ⟹ card (subterms (last b)) ^ ?n ≤ card (subterms (last b)) ^ ?N›*) by simp also (*calculation: ‹(card (subterms (last b)) + (card (subterms (last b)))²)² ≤ card (subterms (last b)) ^ 4 + 2 * card (subterms (last b)) ^ 4 + card (subterms (last b)) ^ 4›*) have "… ≤ 4 * ?csts^4" by simp finally (*calculation: ‹(card (subterms (last b)) + (card (subterms (last b)))²)² ≤ 4 * card (subterms (last b)) ^ 4›*) show "?thesis" (*goal: ‹2 * card (subfms (last b)) + 4 * (card (subterms (last b)) + (card (subterms (last b)))²)² ≤ 2 * card (subfms (last b)) + 16 * card (subterms (last b)) ^ 4›*) by simp qed finally (*calculation: ‹card (set (b::'a::type pset_atom fm list)) ≤ (2::nat) * card (subfms (last b)) + (16::nat) * card (subterms (last b)) ^ (4::nat)›*) show "?thesis" (*goal: ‹card (set b) ≤ 2 * card (subfms (last b)) + 16 * card (subterms (last b)) ^ 4›*) . qed subsection ‹The Decision Procedure› locale mlss_proc = fixes lexpand :: "'a branch ⇒ 'a branch" assumes lexpands_lexpand: "¬ lin_sat b ⟹ lexpands (lexpand b) b ∧ set b ⊂ set (lexpand b @ b)" fixes bexpand :: "'a branch ⇒ 'a branch set" assumes bexpands_bexpand: "¬ sat b ⟹ lin_sat b ⟹ bexpands (bexpand b) b" begin function (domintros) mlss_proc_branch :: "'a branch ⇒ bool" where "¬ lin_sat b ⟹ mlss_proc_branch b = mlss_proc_branch (lexpand b @ b)" | "⟦ lin_sat b; bclosed b ⟧ ⟹ mlss_proc_branch b = True" | "⟦ ¬ sat b; bopen b; lin_sat b ⟧ ⟹ mlss_proc_branch b = (∀b' ∈ bexpand b. mlss_proc_branch (b' @ b))" | "⟦ lin_sat b; sat b ⟧ ⟹ mlss_proc_branch b = bclosed b" by auto lemma mlss_proc_branch_dom_if_wf_branch: assumes "wf_branch b" shows "mlss_proc_branch_dom b" proof (-) (*goal: ‹mlss_proc_branch_dom (b::'a pset_atom fm list)›*) define card_ub :: "'a branch ⇒ nat" where "card_ub ≡ λb. 2 * card (subfms (last b)) + 16 * (card (subterms (last b)))^4" from assms (*‹wf_branch b›*) show "?thesis" (*goal: ‹mlss_proc_branch_dom b›*) proof (induction "card_ub b - card (set b)" arbitrary: b rule: less_induct) (*goal: ‹⋀b. ⟦⋀ba. ⟦card_ub ba - card (set ba) < card_ub b - card (set b); wf_branch ba⟧ ⟹ mlss_proc_branch_dom ba; wf_branch b⟧ ⟹ mlss_proc_branch_dom b›*) case less (*‹⟦card_ub ?b - card (set ?b) < card_ub b - card (set b); wf_branch ?b⟧ ⟹ mlss_proc_branch_dom ?b› ‹wf_branch b›*) have less': "mlss_proc_branch_dom b'" if "set b ⊂ set b'" "expandss b' b" for b' proof (-) (*goal: ‹mlss_proc_branch_dom (b'::'a pset_atom fm list)›*) note expandss_last_eq[OF ‹expandss b' b› wf_branch_not_Nil [ OF ‹wf_branch b› ]] (*‹last b' = last b›*) then have "card_ub b' = card_ub b" unfolding card_ub_def (*goal: ‹2 * card (subfms (last b')) + 16 * card (subterms (last b')) ^ 4 = 2 * card (subfms (last b)) + 16 * card (subterms (last b)) ^ 4›*) by simp moreover from that (*‹set b ⊂ set b'› ‹expandss b' b›*) ‹wf_branch b› (*‹wf_branch b›*) have "wf_branch b'" by (meson expandss_trans (*‹⟦expandss (?b3.0::?'a pset_atom fm list) (?b2.0::?'a pset_atom fm list); expandss ?b2.0 (?b1.0::?'a pset_atom fm list)⟧ ⟹ expandss ?b3.0 ?b1.0›*) wf_branch_def (*‹wf_branch (?b::?'a pset_atom fm list) ≡ ∃φ::?'a pset_atom fm. expandss ?b [φ]›*)) ultimately have "mlss_proc_branch_dom b'" if "card (set b') > card (set b)" using less(1)[OF _ ‹wf_branch b'›] (*‹card_ub b' - card (set b') < card_ub b - card (set b) ⟹ mlss_proc_branch_dom b'›*) card_wf_branch_ub (*‹wf_branch ?b ⟹ card (set ?b) ≤ 2 * card (subfms (last ?b)) + 16 * card (subterms (last ?b)) ^ 4›*) that (*‹card (set b) < card (set b')›*) by (metis (no_types, lifting) card_ub_def (*‹card_ub ≡ λb. 2 * card (subfms (last b)) + 16 * card (subterms (last b)) ^ 4›*) diff_less_mono2 (*‹⟦?m < ?n; ?m < ?l⟧ ⟹ ?l - ?n < ?l - ?m›*) order_less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*)) with that (*‹set (b::'a::type pset_atom fm list) ⊂ set (b'::'a::type pset_atom fm list)› ‹expandss b' b›*) show "?thesis" (*goal: ‹mlss_proc_branch_dom b'›*) by (simp add: psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*)) qed then show "?case" (*goal: ‹mlss_proc_branch_dom b›*) proof (cases "sat b") (*goals: 1. ‹⟦⋀b'. ⟦set b ⊂ set b'; expandss b' b⟧ ⟹ mlss_proc_branch_dom b'; sat b⟧ ⟹ mlss_proc_branch_dom b› 2. ‹⟦⋀b'. ⟦set b ⊂ set b'; expandss b' b⟧ ⟹ mlss_proc_branch_dom b'; ¬ sat b⟧ ⟹ mlss_proc_branch_dom b›*) case False (*‹¬ sat b›*) then consider b' where "¬ lin_sat b" and "lexpands b' b" and "set b ⊂ set (b' @ b)" | bs' where "lin_sat b" and "¬ sat b" and "bexpands bs' b" and "bs' ≠ {}" and "∀b' ∈ bs'. set b ⊂ set (b' @ b)" (*goal: ‹⟦⋀b'. ⟦¬ lin_sat b; lexpands b' b; set b ⊂ set (b' @ b)⟧ ⟹ thesis; ⋀bs'. ⟦lin_sat b; ¬ sat b; bexpands bs' b; bs' ≠ {}; ∀b'∈bs'. set b ⊂ set (b' @ b)⟧ ⟹ thesis⟧ ⟹ thesis›*) unfolding sat_def lin_sat_def (*goal: ‹⟦⋀b'::'a pset_atom fm list. ⟦¬ (∀b'::'a pset_atom fm list. lexpands b' (b::'a pset_atom fm list) ⟶ set b' ⊆ set b); lexpands b' b; set b ⊂ set (b' @ b)⟧ ⟹ thesis::bool; ⋀bs'::'a pset_atom fm list set. ⟦∀b'::'a pset_atom fm list. lexpands b' b ⟶ set b' ⊆ set b; ¬ ((∀b'::'a pset_atom fm list. lexpands b' b ⟶ set b' ⊆ set b) ∧ (∄bs'::'a pset_atom fm list set. bexpands bs' b)); bexpands bs' b; bs' ≠ {}; ∀b'::'a pset_atom fm list∈bs'. set b ⊂ set (b' @ b)⟧ ⟹ thesis⟧ ⟹ thesis›*) using bexpands_strict_mono (*‹⟦bexpands ?bs' ?b; ?b' ∈ ?bs'⟧ ⟹ set ?b ⊂ set (?b' @ ?b)›*) bexpands_nonempty (*‹bexpands ?bs' ?b ⟹ ?bs' ≠ {}›*) by (metis (no_types, opaque_lifting) inf_sup_aci( (*‹sup ?x ?y = sup ?y ?x›*) 5) psubsetI (*‹⟦?A ⊆ ?B; ?A ≠ ?B⟧ ⟹ ?A ⊂ ?B›*) set_append (*‹set (?xs @ ?ys) = set ?xs ∪ set ?ys›*) sup_ge1 (*‹?x ≤ sup ?x ?y›*)) then show "?thesis" (*goal: ‹mlss_proc_branch_dom b›*) proof (cases) (*goals: 1. ‹⋀b'. ⟦¬ lin_sat b; lexpands b' b; set b ⊂ set (b' @ b)⟧ ⟹ mlss_proc_branch_dom b› 2. ‹⋀bs'. ⟦lin_sat b; ¬ sat b; bexpands bs' b; bs' ≠ {}; ∀b'∈bs'. set b ⊂ set (b' @ b)⟧ ⟹ mlss_proc_branch_dom b›*) case 1 (*‹¬ lin_sat (b::'a pset_atom fm list)› ‹lexpands b'_ b› ‹set b ⊂ set (b'_ @ b)›*) with less' (*‹⟦set b ⊂ set ?b'; expandss ?b' b⟧ ⟹ mlss_proc_branch_dom ?b'›*) show "?thesis" (*goal: ‹mlss_proc_branch_dom b›*) using mlss_proc_branch.domintros(1) (*‹⟦¬ lin_sat ?b ⟹ mlss_proc_branch_dom (lexpand ?b @ ?b); ¬ lin_sat ?b⟧ ⟹ mlss_proc_branch_dom ?b›*) by (metis expandss.intros( (*‹expandss ?b ?b› ‹⟦lexpands ?b3.0 ?b2.0; set ?b2.0 ⊂ set (?b3.0 @ ?b2.0); expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) 1,2) lexpands_lexpand (*‹¬ lin_sat ?b ⟹ lexpands (lexpand ?b) ?b ∧ set ?b ⊂ set (lexpand ?b @ ?b)›*)) next (*goal: ‹⋀bs'::'a::type pset_atom fm list set. ⟦lin_sat (b::'a::type pset_atom fm list); ¬ sat b; bexpands bs' b; bs' ≠ {}; ∀b'::'a::type pset_atom fm list∈bs'. set b ⊂ set (b' @ b)⟧ ⟹ mlss_proc_branch_dom b›*) case 2 (*‹lin_sat b› ‹¬ sat (b::'a pset_atom fm list)› ‹bexpands bs'_ b› ‹(bs'_::'a pset_atom fm list set) ≠ {}› ‹∀b'::'a pset_atom fm list∈bs'_::'a pset_atom fm list set. set (b::'a pset_atom fm list) ⊂ set (b' @ b)›*) then show "?thesis" (*goal: ‹mlss_proc_branch_dom b›*) using less' (*‹⟦set b ⊂ set ?b'; expandss ?b' b⟧ ⟹ mlss_proc_branch_dom ?b'›*) bexpands_bexpand (*‹⟦¬ sat ?b; lin_sat ?b⟧ ⟹ bexpands (bexpand ?b) ?b›*) mlss_proc_branch.domintros(2,3) (*‹⟦lin_sat ?b; bclosed ?b⟧ ⟹ mlss_proc_branch_dom ?b› ‹⟦⋀x::'a pset_atom fm list. ⟦¬ sat (?b::'a pset_atom fm list); bopen ?b; lin_sat ?b; x ∈ (bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) ?b⟧ ⟹ mlss_proc_branch_dom (x @ ?b); ¬ sat ?b; bopen ?b; lin_sat ?b⟧ ⟹ mlss_proc_branch_dom ?b›*) by (metis bexpands_strict_mono (*‹⟦bexpands (?bs'::?'a pset_atom fm list set) (?b::?'a pset_atom fm list); (?b'::?'a pset_atom fm list) ∈ ?bs'⟧ ⟹ set ?b ⊂ set (?b' @ ?b)›*) expandss.intros( (*‹expandss (?b::?'a pset_atom fm list) ?b› ‹⟦bexpands (?bs::?'a pset_atom fm list set) (?b2.0::?'a pset_atom fm list); (?b3.0::?'a pset_atom fm list) ∈ ?bs; expandss ?b2.0 (?b1.0::?'a pset_atom fm list)⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) 1,3)) qed qed (use mlss_proc_branch.domintros(4) sat_def in metis) (*solved the remaining goal: ‹⟦⋀b'. ⟦set b ⊂ set b'; expandss b' b⟧ ⟹ mlss_proc_branch_dom b'; sat b⟧ ⟹ mlss_proc_branch_dom b›*) qed qed definition mlss_proc :: "'a pset_fm ⇒ bool" where "mlss_proc φ ≡ mlss_proc_branch [φ]" lemma mlss_proc_branch_complete: fixes b :: "'a branch" assumes "wf_branch b" "∃v. v ⊢ last b" assumes "¬ mlss_proc_branch b" assumes "infinite (UNIV :: 'a set)" shows "∃M. interp I⇩s⇩a M (last b)" proof (-) (*goal: ‹∃M. interp I⇩s⇩a M (last b)›*) from mlss_proc_branch_dom_if_wf_branch[OF assms ( 1 )] (*‹mlss_proc_branch_dom b›*) assms(1,2,3) (*‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch (b::'a::type pset_atom fm list)›*) show "?thesis" (*goal: ‹∃M. interp I⇩s⇩a M (last b)›*) proof (induction rule: mlss_proc_branch.pinduct (*‹⟦mlss_proc_branch_dom ?a0.0; ⋀b. ⟦mlss_proc_branch_dom b; ¬ lin_sat b; ?P (lexpand b @ b)⟧ ⟹ ?P b; ⋀b. ⟦mlss_proc_branch_dom b; lin_sat b; bclosed b⟧ ⟹ ?P b; ⋀b. ⟦mlss_proc_branch_dom b; ¬ sat b; bopen b; lin_sat b; ⋀x. x ∈ bexpand b ⟹ ?P (x @ b)⟧ ⟹ ?P b; ⋀b. ⟦mlss_proc_branch_dom b; lin_sat b; sat b⟧ ⟹ ?P b⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹⋀b::'a pset_atom fm list. ⟦mlss_proc_branch_dom b; ¬ lin_sat b; ⟦wf_branch ((lexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list) b @ b); ∃v::'a ⇒ nat. v ⊢ last (lexpand b @ b); ¬ mlss_proc_branch (lexpand b @ b)⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last (lexpand b @ b)); wf_branch b; ∃v::'a ⇒ nat. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last b)› 2. ‹⋀b::'a pset_atom fm list. ⟦mlss_proc_branch_dom b; lin_sat b; bclosed b; wf_branch b; ∃v::'a ⇒ nat. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last b)› 3. ‹⋀b::'a pset_atom fm list. ⟦mlss_proc_branch_dom b; ¬ sat b; bopen b; lin_sat b; ⋀x::'a pset_atom fm list. ⟦x ∈ (bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) b; wf_branch (x @ b); ∃v::'a ⇒ nat. v ⊢ last (x @ b); ¬ mlss_proc_branch (x @ b)⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last (x @ b)); wf_branch b; ∃v::'a ⇒ nat. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last b)› 4. ‹⋀b::'a pset_atom fm list. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; wf_branch b; ∃v::'a ⇒ nat. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last b)›*) case (1 b) (*‹mlss_proc_branch_dom b› ‹¬ lin_sat b› ‹⟦wf_branch ((lexpand::'a::type pset_atom fm list ⇒ 'a::type pset_atom fm list) (b::'a::type pset_atom fm list) @ b); ∃v::'a::type ⇒ nat. v ⊢ last (lexpand b @ b); ¬ mlss_proc_branch (lexpand b @ b)⟧ ⟹ ∃M::'a::type ⇒ hf. interp I⇩s⇩a M (last (lexpand b @ b))› ‹wf_branch (b::'a pset_atom fm list)› ‹∃v::'a::type ⇒ nat. v ⊢ last (b::'a::type pset_atom fm list)› ‹¬ mlss_proc_branch (b::'a::type pset_atom fm list)›*) let ?b' = "lexpand b" from "1" (*‹mlss_proc_branch_dom b› ‹¬ lin_sat (b::'a pset_atom fm list)› ‹⟦wf_branch ((lexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list) (b::'a pset_atom fm list) @ b); ∃v::'a ⇒ nat. v ⊢ last (lexpand b @ b); ¬ mlss_proc_branch (lexpand b @ b)⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last (lexpand b @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) lexpands_lexpand (*‹¬ lin_sat ?b ⟹ lexpands (lexpand ?b) ?b ∧ set ?b ⊂ set (lexpand ?b @ ?b)›*) have "wf_branch (?b' @ b)" using wf_branch_lexpands (*‹⟦wf_branch (?b::?'a pset_atom fm list); lexpands (?b'::?'a pset_atom fm list) ?b; set ?b ⊂ set (?b' @ ?b)⟧ ⟹ wf_branch (?b' @ ?b)›*) by blast moreover from "1" (*‹mlss_proc_branch_dom (b::'a pset_atom fm list)› ‹¬ lin_sat b› ‹⟦wf_branch (lexpand b @ b); ∃v. v ⊢ last (lexpand b @ b); ¬ mlss_proc_branch (lexpand b @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (lexpand b @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) lexpands_lexpand (*‹¬ lin_sat ?b ⟹ lexpands (lexpand ?b) ?b ∧ set ?b ⊂ set (lexpand ?b @ ?b)›*) have "¬ mlss_proc_branch (?b' @ b)" by (simp add: mlss_proc_branch.psimps (*‹⟦¬ lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = mlss_proc_branch (lexpand ?b @ ?b)› ‹⟦lin_sat ?b; bclosed ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = True› ‹⟦¬ sat ?b; bopen ?b; lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = (∀b'∈bexpand ?b. mlss_proc_branch (b' @ ?b))› ‹⟦lin_sat ?b; sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = bclosed ?b›*)) ultimately obtain M where "interp I⇩s⇩a M (last (?b' @ b))" (*goal: ‹(⋀M. interp I⇩s⇩a M (last (lexpand b @ b)) ⟹ thesis) ⟹ thesis›*) using "1" (*‹mlss_proc_branch_dom b› ‹¬ lin_sat (b::'a pset_atom fm list)› ‹⟦wf_branch ((lexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list) (b::'a pset_atom fm list) @ b); ∃v::'a ⇒ nat. v ⊢ last (lexpand b @ b); ¬ mlss_proc_branch (lexpand b @ b)⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last (lexpand b @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) by auto with "1" (*‹mlss_proc_branch_dom b› ‹¬ lin_sat b› ‹⟦wf_branch (lexpand b @ b); ∃v. v ⊢ last (lexpand b @ b); ¬ mlss_proc_branch (lexpand b @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (lexpand b @ b))› ‹wf_branch b› ‹∃v::'a ⇒ nat. v ⊢ last (b::'a pset_atom fm list)› ‹¬ mlss_proc_branch (b::'a::type pset_atom fm list)›*) show "?case" (*goal: ‹∃M. interp I⇩s⇩a M (last b)›*) using wf_branch_not_Nil (*‹wf_branch ?b ⟹ ?b ≠ []›*) by auto next (*goals: 1. ‹⋀b. ⟦mlss_proc_branch_dom b; lin_sat b; bclosed b; wf_branch b; ∃v. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M. interp I⇩s⇩a M (last b)› 2. ‹⋀b. ⟦mlss_proc_branch_dom b; ¬ sat b; bopen b; lin_sat b; ⋀x. ⟦x ∈ bexpand b; wf_branch (x @ b); ∃v. v ⊢ last (x @ b); ¬ mlss_proc_branch (x @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (x @ b)); wf_branch b; ∃v. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M. interp I⇩s⇩a M (last b)› 3. ‹⋀b. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; wf_branch b; ∃v. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M. interp I⇩s⇩a M (last b)›*) case (2 b) (*‹mlss_proc_branch_dom b› ‹lin_sat b› ‹bclosed b› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) then show "?case" (*goal: ‹∃M. interp I⇩s⇩a M (last b)›*) by (simp add: mlss_proc_branch.psimps (*‹⟦¬ lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = mlss_proc_branch (lexpand ?b @ ?b)› ‹⟦lin_sat ?b; bclosed ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = True› ‹⟦¬ sat ?b; bopen ?b; lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = (∀b'∈bexpand ?b. mlss_proc_branch (b' @ ?b))› ‹⟦lin_sat ?b; sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = bclosed ?b›*)) next (*goals: 1. ‹⋀b::'a::type pset_atom fm list. ⟦mlss_proc_branch_dom b; ¬ sat b; bopen b; lin_sat b; ⋀x::'a::type pset_atom fm list. ⟦x ∈ (bexpand::'a::type pset_atom fm list ⇒ 'a::type pset_atom fm list set) b; wf_branch (x @ b); ∃v::'a::type ⇒ nat. v ⊢ last (x @ b); ¬ mlss_proc_branch (x @ b)⟧ ⟹ ∃M::'a::type ⇒ hf. interp I⇩s⇩a M (last (x @ b)); wf_branch b; ∃v::'a::type ⇒ nat. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M::'a::type ⇒ hf. interp I⇩s⇩a M (last b)› 2. ‹⋀b::'a::type pset_atom fm list. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; wf_branch b; ∃v::'a::type ⇒ nat. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M::'a::type ⇒ hf. interp I⇩s⇩a M (last b)›*) case (3 b) (*‹mlss_proc_branch_dom b› ‹¬ sat b› ‹bopen (b::'a pset_atom fm list)› ‹lin_sat b› ‹⟦?x ∈ bexpand b; wf_branch (?x @ b); ∃v. v ⊢ last (?x @ b); ¬ mlss_proc_branch (?x @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (?x @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) let ?bs' = "bexpand b" from "3" (*‹mlss_proc_branch_dom b› ‹¬ sat b› ‹bopen b› ‹lin_sat b› ‹⟦?x ∈ bexpand b; wf_branch (?x @ b); ∃v. v ⊢ last (?x @ b); ¬ mlss_proc_branch (?x @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (?x @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) bexpands_bexpand (*‹⟦¬ sat ?b; lin_sat ?b⟧ ⟹ bexpands (bexpand ?b) ?b›*) obtain b' where b': "b' ∈ ?bs'" "¬ mlss_proc_branch (b' @ b)" (*goal: ‹(⋀b'. ⟦b' ∈ bexpand b; ¬ mlss_proc_branch (b' @ b)⟧ ⟹ thesis) ⟹ thesis›*) using mlss_proc_branch.psimps(3) (*‹⟦¬ sat ?b; bopen ?b; lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = (∀b'∈bexpand ?b. mlss_proc_branch (b' @ ?b))›*) by metis with "3" (*‹mlss_proc_branch_dom (b::'a::type pset_atom fm list)› ‹¬ sat (b::'a::type pset_atom fm list)› ‹bopen b› ‹lin_sat b› ‹⟦?x ∈ bexpand b; wf_branch (?x @ b); ∃v. v ⊢ last (?x @ b); ¬ mlss_proc_branch (?x @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (?x @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) bexpands_bexpand (*‹⟦¬ sat ?b; lin_sat ?b⟧ ⟹ bexpands (bexpand ?b) ?b›*) have "wf_branch (b' @ b)" using wf_branch_expandss[OF ‹wf_branch b› expandss.intros ( 3 )] (*‹⟦bexpands ?bs1 ?b2.1; ?b3.1 ∈ ?bs1; expandss ?b2.1 b⟧ ⟹ wf_branch (?b3.1 @ ?b2.1)›*) using expandss.intros(1) (*‹expandss ?b ?b›*) by blast with "3" (*‹mlss_proc_branch_dom b› ‹¬ sat b› ‹bopen b› ‹lin_sat b› ‹⟦(?x::'a pset_atom fm list) ∈ (bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) (b::'a pset_atom fm list); wf_branch (?x @ b); ∃v::'a ⇒ nat. v ⊢ last (?x @ b); ¬ mlss_proc_branch (?x @ b)⟧ ⟹ ∃M::'a ⇒ hf. interp I⇩s⇩a M (last (?x @ b))› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch (b::'a pset_atom fm list)›*) b' (*‹b' ∈ bexpand b› ‹¬ mlss_proc_branch (b' @ b)›*) obtain M where "interp I⇩s⇩a M (last (b' @ b))" (*goal: ‹(⋀M. interp I⇩s⇩a M (last (b' @ b)) ⟹ thesis) ⟹ thesis›*) by auto with "3" (*‹mlss_proc_branch_dom (b::'a pset_atom fm list)› ‹¬ sat b› ‹bopen b› ‹lin_sat b› ‹⟦?x ∈ bexpand b; wf_branch (?x @ b); ∃v. v ⊢ last (?x @ b); ¬ mlss_proc_branch (?x @ b)⟧ ⟹ ∃M. interp I⇩s⇩a M (last (?x @ b))› ‹wf_branch b› ‹∃v::'a ⇒ nat. v ⊢ last (b::'a pset_atom fm list)› ‹¬ mlss_proc_branch b›*) show "?case" (*goal: ‹∃M. interp I⇩s⇩a M (last b)›*) by auto next (*goal: ‹⋀b. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; wf_branch b; ∃v. v ⊢ last b; ¬ mlss_proc_branch b⟧ ⟹ ∃M. interp I⇩s⇩a M (last b)›*) case (4 b) (*‹mlss_proc_branch_dom b› ‹lin_sat b› ‹sat (b::'a::type pset_atom fm list)› ‹wf_branch b› ‹∃v. v ⊢ last b› ‹¬ mlss_proc_branch b›*) then have "bopen b" by (simp add: mlss_proc_branch.psimps (*‹⟦¬ lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = mlss_proc_branch (lexpand ?b @ ?b)› ‹⟦lin_sat ?b; bclosed ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = True› ‹⟦¬ sat ?b; bopen ?b; lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = (∀b'∈bexpand ?b. mlss_proc_branch (b' @ ?b))› ‹⟦lin_sat ?b; sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = bclosed ?b›*)) interpret open_branch b using ‹wf_branch b› (*‹wf_branch b›*) ‹∃v. v ⊢ last b› (*‹∃v. v ⊢ last b›*) ‹bopen b› (*‹bopen b›*) ‹infinite UNIV› (*‹infinite UNIV›*) apply unfold_locales (*goals: 1. ‹⟦wf_branch b; ∃v. v ⊢ last b; bopen b; infinite UNIV⟧ ⟹ wf_branch b› 2. ‹⟦wf_branch b; ∃v. v ⊢ last b; bopen b; infinite UNIV⟧ ⟹ bopen b› 3. ‹⟦wf_branch b; ∃v. v ⊢ last b; bopen b; infinite UNIV⟧ ⟹ ∃v. v ⊢ last b› 4. ‹⟦wf_branch b; ∃v. v ⊢ last b; bopen b; infinite UNIV⟧ ⟹ infinite UNIV› discuss goal 1*) apply assumption (*discuss goal 2*) apply assumption (*discuss goal 3*) apply assumption (*discuss goal 4*) apply assumption (*proven 4 subgoals*) . from coherence[OF ‹sat b› last_in_set] (*‹b ≠ [] ⟹ interp I⇩s⇩a (λx. realise (Var x)) (last b)›*) show "?case" (*goal: ‹∃M. interp I⇩s⇩a M (last b)›*) using wf_branch (*‹wf_branch b›*) wf_branch_not_Nil (*‹wf_branch (?b::?'a pset_atom fm list) ⟹ ?b ≠ []›*) by blast qed qed lemma mlss_proc_branch_sound: assumes "wf_branch b" assumes "∀ψ ∈ set b. interp I⇩s⇩a M ψ" shows "¬ mlss_proc_branch b" proof (standard) (*goal: ‹mlss_proc_branch b ⟹ False›*) assume "mlss_proc_branch b" (*‹mlss_proc_branch (b::'a pset_atom fm list)›*) with mlss_proc_branch_dom_if_wf_branch[OF ‹wf_branch b›] (*‹mlss_proc_branch_dom b›*) have "∃b'. expandss b' b ∧ (∃M. ∀ψ ∈ set b'. interp I⇩s⇩a M ψ) ∧ bclosed b'" using assms (*‹wf_branch b› ‹∀ψ∈set b. interp I⇩s⇩a M ψ›*) proof (induction arbitrary: M rule: mlss_proc_branch.pinduct) (*goals: 1. ‹⋀b M. ⟦mlss_proc_branch_dom b; ¬ lin_sat b; ⋀M. ⟦mlss_proc_branch (lexpand b @ b); wf_branch (lexpand b @ b); Ball (set (lexpand b @ b)) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' (lexpand b @ b) ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' b ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'› 2. ‹⋀b M. ⟦mlss_proc_branch_dom b; lin_sat b; bclosed b; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' b ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'› 3. ‹⋀b M. ⟦mlss_proc_branch_dom b; ¬ sat b; bopen b; lin_sat b; ⋀x M. ⟦x ∈ bexpand b; mlss_proc_branch (x @ b); wf_branch (x @ b); Ball (set (x @ b)) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' (x @ b) ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' b ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'› 4. ‹⋀b M. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' b ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'›*) case (1 b) (*‹mlss_proc_branch_dom b› ‹¬ lin_sat b› ‹⟦mlss_proc_branch (lexpand b @ b); wf_branch (lexpand b @ b); ∀a∈set (lexpand b @ b). interp I⇩s⇩a ?M a⟧ ⟹ ∃b'. expandss b' (lexpand b @ b) ∧ (∃M. ∀a∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) let ?b' = "lexpand b" from "1" (*‹mlss_proc_branch_dom b› ‹¬ lin_sat b› ‹⟦mlss_proc_branch (lexpand b @ b); wf_branch (lexpand b @ b); ∀a∈set (lexpand b @ b). interp I⇩s⇩a ?M a⟧ ⟹ ∃b'. expandss b' (lexpand b @ b) ∧ (∃M. ∀a∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch (b::'a pset_atom fm list)› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) lexpands_lexpand (*‹¬ lin_sat ?b ⟹ lexpands (lexpand ?b) ?b ∧ set ?b ⊂ set (lexpand ?b @ ?b)›*) ‹wf_branch b› (*‹wf_branch b›*) have "wf_branch (?b' @ b)" using wf_branch_lexpands (*‹⟦wf_branch ?b; lexpands ?b' ?b; set ?b ⊂ set (?b' @ ?b)⟧ ⟹ wf_branch (?b' @ ?b)›*) by metis with "1" (*‹mlss_proc_branch_dom b› ‹¬ lin_sat b› ‹⟦mlss_proc_branch (lexpand b @ b); wf_branch (lexpand b @ b); ∀a∈set (lexpand b @ b). interp I⇩s⇩a ?M a⟧ ⟹ ∃b'. expandss b' (lexpand b @ b) ∧ (∃M. ∀a∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) lexpands_sound (*‹⟦lexpands ?b' ?b; ?φ ∈ set ?b'; ⋀ψ. ψ ∈ set ?b ⟹ interp I⇩s⇩a ?M ψ⟧ ⟹ interp I⇩s⇩a ?M ?φ›*) lexpands_lexpand (*‹¬ lin_sat (?b::'a pset_atom fm list) ⟹ lexpands ((lexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list) ?b) ?b ∧ set ?b ⊂ set (lexpand ?b @ ?b)›*) obtain b'' where "expandss b'' (?b' @ b)" "∃M. ∀ψ ∈ set b''. interp I⇩s⇩a M ψ" "bclosed b''" (*goal: ‹(⋀b''. ⟦expandss b'' (lexpand b @ b); ∃M. ∀ψ∈set b''. interp I⇩s⇩a M ψ; bclosed b''⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce simp: mlss_proc_branch.psimps (*‹⟦¬ lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = mlss_proc_branch (lexpand ?b @ ?b)› ‹⟦lin_sat ?b; bclosed ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = True› ‹⟦¬ sat ?b; bopen ?b; lin_sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = (∀b'∈bexpand ?b. mlss_proc_branch (b' @ ?b))› ‹⟦lin_sat ?b; sat ?b; mlss_proc_branch_dom ?b⟧ ⟹ mlss_proc_branch ?b = bclosed ?b›*)) with "1" (*‹mlss_proc_branch_dom b› ‹¬ lin_sat b› ‹⟦mlss_proc_branch (lexpand b @ b); wf_branch (lexpand b @ b); ∀a∈set (lexpand b @ b). interp I⇩s⇩a ?M a⟧ ⟹ ∃b'. expandss b' (lexpand b @ b) ∧ (∃M. ∀a∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) lexpands_lexpand (*‹¬ lin_sat (?b::'a pset_atom fm list) ⟹ lexpands ((lexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list) ?b) ?b ∧ set ?b ⊂ set (lexpand ?b @ ?b)›*) show "?case" (*goal: ‹∃b'::'a pset_atom fm list. expandss b' (b::'a pset_atom fm list) ∧ (∃M::'a ⇒ hf. ∀a::'a pset_atom fm∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'›*) using expandss_trans (*‹⟦expandss ?b3.0 ?b2.0; expandss ?b2.0 ?b1.0⟧ ⟹ expandss ?b3.0 ?b1.0›*) expandss.intros(1,2) (*‹expandss ?b ?b› ‹⟦lexpands ?b3.0 ?b2.0; set ?b2.0 ⊂ set (?b3.0 @ ?b2.0); expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) by meson next (*goals: 1. ‹⋀(b::'a pset_atom fm list) M::'a ⇒ hf. ⟦mlss_proc_branch_dom b; lin_sat b; bclosed b; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'::'a pset_atom fm list. expandss b' b ∧ (∃M::'a ⇒ hf. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'› 2. ‹⋀(b::'a pset_atom fm list) M::'a ⇒ hf. ⟦mlss_proc_branch_dom b; ¬ sat b; bopen b; lin_sat b; ⋀(x::'a pset_atom fm list) M::'a ⇒ hf. ⟦x ∈ (bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) b; mlss_proc_branch (x @ b); wf_branch (x @ b); Ball (set (x @ b)) (interp I⇩s⇩a M)⟧ ⟹ ∃b'::'a pset_atom fm list. expandss b' (x @ b) ∧ (∃M::'a ⇒ hf. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'::'a pset_atom fm list. expandss b' b ∧ (∃M::'a ⇒ hf. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'› 3. ‹⋀(b::'a pset_atom fm list) M::'a ⇒ hf. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'::'a pset_atom fm list. expandss b' b ∧ (∃M::'a ⇒ hf. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'›*) case (3 b) (*‹mlss_proc_branch_dom b› ‹¬ sat b› ‹bopen b› ‹lin_sat b› ‹⟦?x ∈ bexpand b; mlss_proc_branch (?x @ b); wf_branch (?x @ b); ∀a∈set (?x @ b). interp I⇩s⇩a ?M a⟧ ⟹ ∃b'. expandss b' (?x @ b) ∧ (∃M. ∀a∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) let ?bs' = "bexpand b" from "3" (*‹mlss_proc_branch_dom b› ‹¬ sat b› ‹bopen (b::'a pset_atom fm list)› ‹lin_sat b› ‹⟦(?x::'a::type pset_atom fm list) ∈ (bexpand::'a::type pset_atom fm list ⇒ 'a::type pset_atom fm list set) (b::'a::type pset_atom fm list); mlss_proc_branch (?x @ b); wf_branch (?x @ b); ∀a::'a::type pset_atom fm∈set (?x @ b). interp I⇩s⇩a (?M::'a::type ⇒ hf) a⟧ ⟹ ∃b'::'a::type pset_atom fm list. expandss b' (?x @ b) ∧ (∃M::'a::type ⇒ hf. ∀a::'a::type pset_atom fm∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) ‹wf_branch b› (*‹wf_branch b›*) bexpands_bexpand (*‹⟦¬ sat ?b; lin_sat ?b⟧ ⟹ bexpands (bexpand ?b) ?b›*) have wf_branch_b': "wf_branch (b' @ b)" if "b' ∈ ?bs'" for b' using that (*‹b' ∈ bexpand b›*) expandss.intros(3) (*‹⟦bexpands ?bs ?b2.0; ?b3.0 ∈ ?bs; expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) wf_branch_def (*‹wf_branch ?b ≡ ∃φ. expandss ?b [φ]›*) by metis from bexpands_sound (*‹⟦bexpands (?bs'::?'a::type pset_atom fm list set) (?b::?'a::type pset_atom fm list); ⋀ψ::?'a::type pset_atom fm. ψ ∈ set ?b ⟹ interp I⇩s⇩a (?M::?'a::type ⇒ hf) ψ⟧ ⟹ ∃M::?'a::type ⇒ hf. ∃b'::?'a::type pset_atom fm list∈?bs'. ∀ψ::?'a::type pset_atom fm∈set (b' @ ?b). interp I⇩s⇩a M ψ›*) bexpands_bexpand (*‹⟦¬ sat ?b; lin_sat ?b⟧ ⟹ bexpands (bexpand ?b) ?b›*) "3" (*‹mlss_proc_branch_dom b› ‹¬ sat b› ‹bopen (b::'a pset_atom fm list)› ‹lin_sat b› ‹⟦(?x::'a pset_atom fm list) ∈ (bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) (b::'a pset_atom fm list); mlss_proc_branch (?x @ b); wf_branch (?x @ b); ∀a::'a pset_atom fm∈set (?x @ b). interp I⇩s⇩a (?M::'a ⇒ hf) a⟧ ⟹ ∃b'::'a pset_atom fm list. expandss b' (?x @ b) ∧ (∃M::'a ⇒ hf. ∀a::'a pset_atom fm∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) obtain M' and b' where "b' ∈ ?bs'" "∀ψ ∈ set (b' @ b). interp I⇩s⇩a M' ψ" (*goal: ‹(⋀(b'::'a::type pset_atom fm list) M'::'a::type ⇒ hf. ⟦b' ∈ (bexpand::'a::type pset_atom fm list ⇒ 'a::type pset_atom fm list set) (b::'a::type pset_atom fm list); ∀ψ::'a::type pset_atom fm∈set (b' @ b). interp I⇩s⇩a M' ψ⟧ ⟹ thesis::bool) ⟹ thesis›*) by metis with "3.IH" (*‹⟦?x ∈ bexpand b; mlss_proc_branch (?x @ b); wf_branch (?x @ b); ∀a∈set (?x @ b). interp I⇩s⇩a ?M a⟧ ⟹ ∃b'. expandss b' (?x @ b) ∧ (∃M. ∀a∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'›*) ‹mlss_proc_branch b› (*‹mlss_proc_branch b›*) wf_branch_b' (*‹?b' ∈ bexpand b ⟹ wf_branch (?b' @ b)›*) obtain b'' where "b' ∈ ?bs'" "expandss b'' (b' @ b)" "∃M. ∀ψ ∈ set b''. interp I⇩s⇩a M ψ" "bclosed b''" (*goal: ‹(⋀b''. ⟦b' ∈ bexpand b; expandss b'' (b' @ b); ∃M. ∀ψ∈set b''. interp I⇩s⇩a M ψ; bclosed b''⟧ ⟹ thesis) ⟹ thesis›*) using mlss_proc_branch.psimps(3)[OF "3.hyps" ( 2 - 4 , 1 )] (*‹mlss_proc_branch (b::'a pset_atom fm list) = (∀b'::'a pset_atom fm list∈(bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) b. mlss_proc_branch (b' @ b))›*) by blast with "3" (*‹mlss_proc_branch_dom (b::'a pset_atom fm list)› ‹¬ sat b› ‹bopen b› ‹lin_sat b› ‹⟦(?x::'a pset_atom fm list) ∈ (bexpand::'a pset_atom fm list ⇒ 'a pset_atom fm list set) (b::'a pset_atom fm list); mlss_proc_branch (?x @ b); wf_branch (?x @ b); ∀a::'a pset_atom fm∈set (?x @ b). interp I⇩s⇩a (?M::'a ⇒ hf) a⟧ ⟹ ∃b'::'a pset_atom fm list. expandss b' (?x @ b) ∧ (∃M::'a ⇒ hf. ∀a::'a pset_atom fm∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'› ‹mlss_proc_branch b› ‹wf_branch b› ‹∀a∈set b. interp I⇩s⇩a M a›*) bexpands_bexpand (*‹⟦¬ sat ?b; lin_sat ?b⟧ ⟹ bexpands (bexpand ?b) ?b›*) show "?case" (*goal: ‹∃b'::'a pset_atom fm list. expandss b' (b::'a pset_atom fm list) ∧ (∃M::'a ⇒ hf. ∀a::'a pset_atom fm∈set b'. interp I⇩s⇩a M a) ∧ bclosed b'›*) using expandss_trans (*‹⟦expandss ?b3.0 ?b2.0; expandss ?b2.0 ?b1.0⟧ ⟹ expandss ?b3.0 ?b1.0›*) expandss.intros(1,3) (*‹expandss ?b ?b› ‹⟦bexpands ?bs ?b2.0; ?b3.0 ∈ ?bs; expandss ?b2.0 ?b1.0⟧ ⟹ expandss (?b3.0 @ ?b2.0) ?b1.0›*) by metis qed (use expandss.intros(1) mlss_proc_branch.psimps(4) in ‹blast+›) (*solves the remaining goals: 1. ‹⋀b M. ⟦mlss_proc_branch_dom b; lin_sat b; bclosed b; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' b ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'› 2. ‹⋀b M. ⟦mlss_proc_branch_dom b; lin_sat b; sat b; mlss_proc_branch b; wf_branch b; Ball (set b) (interp I⇩s⇩a M)⟧ ⟹ ∃b'. expandss b' b ∧ (∃M. Ball (set b') (interp I⇩s⇩a M)) ∧ bclosed b'›*) with bclosed_sound (*‹bclosed ?b ⟹ ∃φ∈set ?b. ¬ interp I⇩s⇩a ?M φ›*) show False by blast qed theorem mlss_proc_complete: fixes φ :: "'a pset_fm" assumes "¬ mlss_proc φ" assumes "∃v. v ⊢ φ" assumes "infinite (UNIV :: 'a set)" shows "∃M. interp I⇩s⇩a M φ" using assms (*‹¬ local.mlss_proc (φ::'a::type pset_atom fm)› ‹∃v. v ⊢ φ› ‹infinite UNIV›*) mlss_proc_branch_complete[of "[φ]"] (*‹⟦wf_branch [φ]; ∃v. v ⊢ last [φ]; ¬ mlss_proc_branch [φ]; infinite UNIV⟧ ⟹ ∃M. interp I⇩s⇩a M (last [φ])›*) unfolding mlss_proc_def (*goal: ‹∃M. interp I⇩s⇩a M φ›*) by simp theorem mlss_proc_sound: assumes "interp I⇩s⇩a M φ" shows "¬ mlss_proc φ" using assms (*‹interp I⇩s⇩a M φ›*) mlss_proc_branch_sound[of "[φ]"] (*‹⟦wf_branch [φ::'a::type pset_atom fm]; ∀ψ::'a::type pset_atom fm∈set [φ]. interp I⇩s⇩a (?M::'a::type ⇒ hf) ψ⟧ ⟹ ¬ mlss_proc_branch [φ]›*) unfolding mlss_proc_def (*goal: ‹¬ mlss_proc_branch [φ]›*) by simp end end
{ "path": "afp-2025-02-12/thys/MLSS_Decision_Proc/MLSS_Proc.thy", "repo": "afp-2025-02-12", "sha": "fcc80b61f629027fa6669a91561b552bbe3c13773a9e70c26c48f31cd801e841" }
chapter ‹Dynamic Slicing› section ‹Dynamic Program Dependence Graph› theory DynPDG imports "../Basic/DynDataDependence" "../Basic/CFGExit_wf" "../Basic/DynStandardControlDependence" "../Basic/DynWeakControlDependence" begin subsection ‹The dynamic PDG› locale DynPDG = CFGExit_wf sourcenode targetnode kind valid_edge Entry Def Use state_val Exit for sourcenode :: "'edge ⇒ 'node" and targetnode :: "'edge ⇒ 'node" and kind :: "'edge ⇒ 'state edge_kind" and valid_edge :: "'edge ⇒ bool" and Entry :: "'node" ("'('_Entry'_')") and Def :: "'node ⇒ 'var set" and Use :: "'node ⇒ 'var set" and state_val :: "'state ⇒ 'var ⇒ 'val" and Exit :: "'node" ("'('_Exit'_')") + fixes dyn_control_dependence :: "'node ⇒ 'node ⇒ 'edge list ⇒ bool" ("_ controls _ via _" [51,0,0]) assumes Exit_not_dyn_control_dependent:"n controls n' via as ⟹ n' ≠ (_Exit_)" assumes dyn_control_dependence_path: "n controls n' via as ⟹ n -as→* n' ∧ as ≠ []" begin inductive cdep_edge :: "'node ⇒ 'edge list ⇒ 'node ⇒ bool" ("_ -_→⇩c⇩d _" [51,0,0] 80) and ddep_edge :: "'node ⇒ 'var ⇒ 'edge list ⇒ 'node ⇒ bool" ("_ -'{_'}_→⇩d⇩d _" [51,0,0,0] 80) and DynPDG_edge :: "'node ⇒ 'var option ⇒ 'edge list ⇒ 'node ⇒ bool" where ― ‹Syntax› "n -as→⇩c⇩d n' == DynPDG_edge n None as n'" | "n -{V}as→⇩d⇩d n' == DynPDG_edge n (Some V) as n'" ― ‹Rules› | DynPDG_cdep_edge: "n controls n' via as ⟹ n -as→⇩c⇩d n'" | DynPDG_ddep_edge: "n influences V in n' via as ⟹ n -{V}as→⇩d⇩d n'" inductive DynPDG_path :: "'node ⇒ 'edge list ⇒ 'node ⇒ bool" ("_ -_→⇩d* _" [51,0,0] 80) where DynPDG_path_Nil: "valid_node n ⟹ n -[]→⇩d* n" | DynPDG_path_Append_cdep: "⟦n -as→⇩d* n''; n'' -as'→⇩c⇩d n'⟧ ⟹ n -as@as'→⇩d* n'" | DynPDG_path_Append_ddep: "⟦n -as→⇩d* n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ n -as@as'→⇩d* n'" lemma DynPDG_empty_path_eq_nodes:"n -[]→⇩d* n' ⟹ n = n'" apply - (*goal: ‹n -[]→⇩d* n' ⟹ n = n'›*) apply (erule DynPDG_path.cases (*‹⟦(?a1.0::'node) -?a2.0::'edge list→⇩d* ?a3.0::'node; ⋀n::'node. ⟦?a1.0 = n; ?a2.0 = []; ?a3.0 = n; valid_node n⟧ ⟹ ?P::bool; ⋀(n::'node) (as::'edge list) (n''::'node) (as'::'edge list) n'::'node. ⟦?a1.0 = n; ?a2.0 = as @ as'; ?a3.0 = n'; n -as→⇩d* n''; n'' -as'→⇩c⇩d n'⟧ ⟹ ?P; ⋀(n::'node) (as::'edge list) (n''::'node) (V::'var) (as'::'edge list) n'::'node. ⟦?a1.0 = n; ?a2.0 = as @ as'; ?a3.0 = n'; n -as→⇩d* n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀na. ⟦n = na; [] = []; n' = na; valid_node na⟧ ⟹ n = n'› 2. ‹⋀na as n'' as' n'a. ⟦n = na; [] = as @ as'; n' = n'a; na -as→⇩d* n''; n'' -as'→⇩c⇩d n'a⟧ ⟹ n = n'› 3. ‹⋀na as n'' V as' n'a. ⟦n = na; [] = as @ as'; n' = n'a; na -as→⇩d* n''; n'' -{V}as'→⇩d⇩d n'a⟧ ⟹ n = n'› discuss goal 1*) apply simp (*discuss goal 2*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:dyn_control_dependence_path (*‹?n controls ?n' via ?as ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*))[1]) (*discuss goal 3*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge (?a1.0::'node::type) (?a2.0::'var::type option) (?a3.0::'edge::type list) (?a4.0::'node::type); ⋀(n::'node::type) (n'::'node::type) as::'edge::type list. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P::bool; ⋀(n::'node::type) (V::'var::type) (n'::'node::type) as::'edge::type list. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:dyn_control_dependence_path (*‹(?n::'node::type) controls ?n'::'node::type via ?as::'edge::type list ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*))[1]) (*goal: ‹⋀na as n'' V as' n'a. ⟦n = na; [] = as @ as'; n' = n'a; na -as→⇩d* n''; n'' -{V}as'→⇩d⇩d n'a⟧ ⟹ n = n'›*) apply (auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*)) (*proven 3 subgoals*) . lemma DynPDG_path_cdep:"n -as→⇩c⇩d n' ⟹ n -as→⇩d* n'" apply (subgoal_tac "n -[]@as→⇩d* n'") (*goals: 1. ‹⟦n -as→⇩c⇩d n'; n -[] @ as→⇩d* n'⟧ ⟹ n -as→⇩d* n'› 2. ‹n -as→⇩c⇩d n' ⟹ n -[] @ as→⇩d* n'› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule DynPDG_path_Append_cdep (*‹⟦?n -?as→⇩d* ?n''; ?n'' -?as'→⇩c⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) (*goals: 1. ‹n -as→⇩c⇩d n' ⟹ n -[]→⇩d* ?n''1› 2. ‹n -as→⇩c⇩d n' ⟹ ?n''1 -as→⇩c⇩d n'› discuss goal 1*) apply (rule DynPDG_path_Nil (*‹valid_node ?n ⟹ ?n -[]→⇩d* ?n›*)) (*top goal: ‹n -as→⇩c⇩d n' ⟹ n -[]→⇩d* ?n''1› and 1 goal remains*) apply ((auto elim!:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:dyn_control_dependence_path (*‹?n controls ?n' via ?as ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*) path_valid_node (*‹?n -?as→* ?n' ⟹ valid_node ?n› ‹?n -?as→* ?n' ⟹ valid_node ?n'›*))[1]) (*discuss goal 2*) apply ((auto elim!:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:dyn_control_dependence_path (*‹?n controls ?n' via ?as ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*) path_valid_node (*‹?n -?as→* ?n' ⟹ valid_node ?n› ‹?n -?as→* ?n' ⟹ valid_node ?n'›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma DynPDG_path_ddep:"n -{V}as→⇩d⇩d n' ⟹ n -as→⇩d* n'" apply (subgoal_tac "n -[]@as→⇩d* n'") (*goals: 1. ‹⟦n -{V}as→⇩d⇩d n'; n -[] @ as→⇩d* n'⟧ ⟹ n -as→⇩d* n'› 2. ‹n -{V}as→⇩d⇩d n' ⟹ n -[] @ as→⇩d* n'› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule DynPDG_path_Append_ddep (*‹⟦?n -?as→⇩d* ?n''; ?n'' -{?V}?as'→⇩d⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) (*goals: 1. ‹n -{V}as→⇩d⇩d n' ⟹ n -[]→⇩d* ?n''1› 2. ‹n -{V}as→⇩d⇩d n' ⟹ ?n''1 -{?V1}as→⇩d⇩d n'› discuss goal 1*) apply (rule DynPDG_path_Nil (*‹valid_node (?n::'node) ⟹ ?n -[]→⇩d* ?n›*)) (*top goal: ‹n -{V}as→⇩d⇩d n' ⟹ n -[]→⇩d* ?n''1› and 1 goal remains*) apply ((auto elim!:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:path_valid_node (*‹?n -?as→* ?n' ⟹ valid_node ?n› ‹?n -?as→* ?n' ⟹ valid_node ?n'›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*discuss goal 2*) apply ((auto elim!:DynPDG_edge.cases (*‹⟦DynPDG_edge (?a1.0::'node) (?a2.0::'var option) (?a3.0::'edge list) (?a4.0::'node); ⋀(n::'node) (n'::'node) as::'edge list. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P::bool; ⋀(n::'node) (V::'var) (n'::'node) as::'edge list. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:path_valid_node (*‹(?n::'node) -?as::'edge list→* ?n'::'node ⟹ valid_node ?n› ‹(?n::'node) -?as::'edge list→* ?n'::'node ⟹ valid_node ?n'›*) simp:dyn_data_dependence_def (*‹(?n::'node) influences ?V::'var in ?n'::'node via ?as::'edge list ≡ ?V ∈ (Def::'node ⇒ 'var set) ?n ∧ ?V ∈ (Use::'node ⇒ 'var set) ?n' ∧ ?n -?as→* ?n' ∧ (∃(a'::'edge) as'::'edge list. ?as = a' # as' ∧ (∀n''::'node∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma DynPDG_path_Append: "⟦n'' -as'→⇩d* n'; n -as→⇩d* n''⟧ ⟹ n -as@as'→⇩d* n'" apply (induct rule:DynPDG_path.induct (*‹⟦?x1.0 -?x2.0→⇩d* ?x3.0; ⋀n. valid_node n ⟹ ?P n [] n; ⋀n as n'' as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -as'→⇩c⇩d n'⟧ ⟹ ?P n (as @ as') n'; ⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ ?P n (as @ as') n'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀na. ⟦valid_node na; n -as→⇩d* na⟧ ⟹ n -as @ []→⇩d* na› 2. ‹⋀na asa n'' as' n'. ⟦na -asa→⇩d* n''; n -as→⇩d* na ⟹ n -as @ asa→⇩d* n''; n'' -as'→⇩c⇩d n'; n -as→⇩d* na⟧ ⟹ n -as @ asa @ as'→⇩d* n'› 3. ‹⋀na asa n'' V as' n'. ⟦na -asa→⇩d* n''; n -as→⇩d* na ⟹ n -as @ asa→⇩d* n''; n'' -{V}as'→⇩d⇩d n'; n -as→⇩d* na⟧ ⟹ n -as @ asa @ as'→⇩d* n'› discuss goal 1*) apply ((auto intro:DynPDG_path.intros (*‹valid_node ?n ⟹ ?n -[]→⇩d* ?n› ‹⟦?n -?as→⇩d* ?n''; ?n'' -?as'→⇩c⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'› ‹⟦?n -?as→⇩d* ?n''; ?n'' -{?V}?as'→⇩d⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*))[1]) (*discuss goal 2*) apply ((auto intro:DynPDG_path.intros (*‹valid_node ?n ⟹ ?n -[]→⇩d* ?n› ‹⟦?n -?as→⇩d* ?n''; ?n'' -?as'→⇩c⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'› ‹⟦?n -?as→⇩d* ?n''; ?n'' -{?V}?as'→⇩d⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*))[1]) (*top goal: ‹⋀na asa n'' as' n'. ⟦na -asa→⇩d* n''; n -as→⇩d* na ⟹ n -as @ asa→⇩d* n''; n'' -as'→⇩c⇩d n'; n -as→⇩d* na⟧ ⟹ n -as @ asa @ as'→⇩d* n'› and 1 goal remains*) apply (rotate_tac 1) (*top goal: ‹⋀na asa n'' as' n'. ⟦na -asa→⇩d* n''; n -as @ asa→⇩d* n''; n'' -as'→⇩c⇩d n'; n -as→⇩d* na⟧ ⟹ n -as @ asa @ as'→⇩d* n'› and 1 goal remains*) apply (drule DynPDG_path_Append_cdep (*‹⟦?n -?as→⇩d* ?n''; ?n'' -?as'→⇩c⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) (*goals: 1. ‹⋀na asa n'' as' n'. ⟦n'' -as'→⇩c⇩d n'; n -as→⇩d* na; na -asa→⇩d* n''⟧ ⟹ n'' -?as'7 na asa n'' as' n'→⇩c⇩d ?n'7 na asa n'' as' n'› 2. ‹⋀na asa n'' as' n'. ⟦n'' -as'→⇩c⇩d n'; n -as→⇩d* na; na -asa→⇩d* n''; n -(as @ asa) @ ?as'7 na asa n'' as' n'→⇩d* ?n'7 na asa n'' as' n'⟧ ⟹ n -as @ asa @ as'→⇩d* n'› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 3*) apply ((auto intro:DynPDG_path.intros (*‹valid_node ?n ⟹ ?n -[]→⇩d* ?n› ‹⟦?n -?as→⇩d* ?n''; ?n'' -?as'→⇩c⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'› ‹⟦?n -?as→⇩d* ?n''; ?n'' -{?V}?as'→⇩d⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*))[1]) (*goal: ‹⋀na asa n'' V as' n'. ⟦na -asa→⇩d* n''; n -as→⇩d* na ⟹ n -as @ asa→⇩d* n''; n'' -{V}as'→⇩d⇩d n'; n -as→⇩d* na⟧ ⟹ n -as @ asa @ as'→⇩d* n'›*) apply (rotate_tac 1) (*goal: ‹⋀na asa n'' V as' n'. ⟦na -asa→⇩d* n''; n -as @ asa→⇩d* n''; n'' -{V}as'→⇩d⇩d n'; n -as→⇩d* na⟧ ⟹ n -as @ asa @ as'→⇩d* n'›*) apply (drule DynPDG_path_Append_ddep (*‹⟦?n -?as→⇩d* ?n''; ?n'' -{?V}?as'→⇩d⇩d ?n'⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) (*goals: 1. ‹⋀na asa n'' V as' n'. ⟦n'' -{V}as'→⇩d⇩d n'; n -as→⇩d* na; na -asa→⇩d* n''⟧ ⟹ n'' -{?V12 na asa n'' V as' n'}?as'12 na asa n'' V as' n'→⇩d⇩d ?n'12 na asa n'' V as' n'› 2. ‹⋀na asa n'' V as' n'. ⟦n'' -{V}as'→⇩d⇩d n'; n -as→⇩d* na; na -asa→⇩d* n''; n -(as @ asa) @ ?as'12 na asa n'' V as' n'→⇩d* ?n'12 na asa n'' V as' n'⟧ ⟹ n -as @ asa @ as'→⇩d* n'› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 3 subgoals*) . lemma DynPDG_path_Exit:"⟦n -as→⇩d* n'; n' = (_Exit_)⟧ ⟹ n = (_Exit_)" apply (induct rule:DynPDG_path.induct (*‹⟦?x1.0 -?x2.0→⇩d* ?x3.0; ⋀n. valid_node n ⟹ ?P n [] n; ⋀n as n'' as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -as'→⇩c⇩d n'⟧ ⟹ ?P n (as @ as') n'; ⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ ?P n (as @ as') n'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀n::'node::type. ⟦valid_node n; n = (_Exit_)⟧ ⟹ n = (_Exit_)› 2. ‹⋀(n::'node::type) (as::'edge::type list) (n''::'node::type) (as'::'edge::type list) n'::'node::type. ⟦n -as→⇩d* n''; n'' = (_Exit_) ⟹ n = (_Exit_); n'' -as'→⇩c⇩d n'; n' = (_Exit_)⟧ ⟹ n = (_Exit_)› 3. ‹⋀(n::'node::type) (as::'edge::type list) (n''::'node::type) (V::'var::type) (as'::'edge::type list) n'::'node::type. ⟦n -as→⇩d* n''; n'' = (_Exit_) ⟹ n = (_Exit_); n'' -{V}as'→⇩d⇩d n'; n' = (_Exit_)⟧ ⟹ n = (_Exit_)› discuss goal 1*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:Exit_not_dyn_control_dependent (*‹?n controls ?n' via ?as ⟹ ?n' ≠ (_Exit_)›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*discuss goal 2*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:Exit_not_dyn_control_dependent (*‹?n controls ?n' via ?as ⟹ ?n' ≠ (_Exit_)›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*discuss goal 3*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:Exit_not_dyn_control_dependent (*‹?n controls ?n' via ?as ⟹ ?n' ≠ (_Exit_)›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*proven 3 subgoals*) . lemma DynPDG_path_not_inner: "⟦n -as→⇩d* n'; ¬ inner_node n'⟧ ⟹ n = n'" proof (induct rule:DynPDG_path.induct (*‹⟦?x1.0 -?x2.0→⇩d* ?x3.0; ⋀n. valid_node n ⟹ ?P n [] n; ⋀n as n'' as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -as'→⇩c⇩d n'⟧ ⟹ ?P n (as @ as') n'; ⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ ?P n (as @ as') n'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀n. ⟦valid_node n; ¬ inner_node n⟧ ⟹ n = n› 2. ‹⋀n as n'' as' n'. ⟦n -as→⇩d* n''; ¬ inner_node n'' ⟹ n = n''; n'' -as'→⇩c⇩d n'; ¬ inner_node n'⟧ ⟹ n = n'› 3. ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ¬ inner_node n'' ⟹ n = n''; n'' -{V}as'→⇩d⇩d n'; ¬ inner_node n'⟧ ⟹ n = n'›*) case (DynPDG_path_Nil n) (*‹valid_node n› ‹¬ inner_node n›*) thus "?case" (*goal: ‹n = n›*) by simp next (*goals: 1. ‹⋀n as n'' as' n'. ⟦n -as→⇩d* n''; ¬ inner_node n'' ⟹ n = n''; n'' -as'→⇩c⇩d n'; ¬ inner_node n'⟧ ⟹ n = n'› 2. ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ¬ inner_node n'' ⟹ n = n''; n'' -{V}as'→⇩d⇩d n'; ¬ inner_node n'⟧ ⟹ n = n'›*) case (DynPDG_path_Append_cdep n as n'' as' n') (*‹(n::'node) -as::'edge list→⇩d* n''::'node› ‹¬ inner_node n'' ⟹ n = n''› ‹n'' -as'→⇩c⇩d n'› ‹¬ inner_node n'›*) from ‹n'' -as'→⇩c⇩d n'› (*‹n'' -as'→⇩c⇩d n'›*) ‹¬ inner_node n'› (*‹¬ inner_node n'›*) have False apply - (*goal: ‹False›*) apply (erule DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀n n' as. ⟦¬ inner_node n'; n'' = n; None = None; as' = as; n' = n'; n controls n' via as⟧ ⟹ False› 2. ‹⋀n V n' as. ⟦¬ inner_node n'; n'' = n; None = Some V; as' = as; n' = n'; n influences V in n' via as⟧ ⟹ False› discuss goal 1*) apply ((auto simp:inner_node_def (*‹inner_node ?n ≡ valid_node ?n ∧ ?n ≠ (_Entry_) ∧ ?n ≠ (_Exit_)›*))[1]) (*goals: 1. ‹⟦n'' controls n' via as'; ¬ valid_node n'⟧ ⟹ False› 2. ‹⟦n'' controls (_Entry_) via as'; n' = (_Entry_)⟧ ⟹ False› 3. ‹⟦n'' controls (_Exit_) via as'; n' = (_Exit_)⟧ ⟹ False› discuss goal 1*) apply (fastforce dest:dyn_control_dependence_path (*‹?n controls ?n' via ?as ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*) path_valid_node (*‹?n -?as→* ?n' ⟹ valid_node ?n› ‹?n -?as→* ?n' ⟹ valid_node ?n'›*)) (*discuss goal 2*) apply (fastforce dest:dyn_control_dependence_path (*‹?n controls ?n' via ?as ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*) path_valid_node (*‹?n -?as→* ?n' ⟹ valid_node ?n› ‹?n -?as→* ?n' ⟹ valid_node ?n'›*)) (*discuss goal 3*) apply (fastforce dest:Exit_not_dyn_control_dependent (*‹(?n::'node::type) controls ?n'::'node::type via ?as::'edge::type list ⟹ ?n' ≠ (_Exit_)›*)) (*proven 3 subgoals*) (*discuss goal 2*) apply ((auto simp:inner_node_def (*‹inner_node ?n ≡ valid_node ?n ∧ ?n ≠ (_Entry_) ∧ ?n ≠ (_Exit_)›*))[1]) (*proven 2 subgoals*) . thus "?case" (*goal: ‹(n::'node::type) = (n'::'node::type)›*) by simp next (*goal: ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ¬ inner_node n'' ⟹ n = n''; n'' -{V}as'→⇩d⇩d n'; ¬ inner_node n'⟧ ⟹ n = n'›*) case (DynPDG_path_Append_ddep n as n'' V as' n') (*‹n -as→⇩d* n''› ‹¬ inner_node (n''::'node) ⟹ (n::'node) = n''› ‹n'' -{V}as'→⇩d⇩d n'› ‹¬ inner_node (n'::'node)›*) from ‹n'' -{V}as'→⇩d⇩d n'› (*‹n'' -{V}as'→⇩d⇩d n'›*) ‹¬ inner_node n'› (*‹¬ inner_node (n'::'node)›*) have False apply - (*goal: ‹False›*) apply (erule DynPDG_edge.cases (*‹⟦DynPDG_edge (?a1.0::'node::type) (?a2.0::'var::type option) (?a3.0::'edge::type list) (?a4.0::'node::type); ⋀(n::'node::type) (n'::'node::type) as::'edge::type list. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P::bool; ⋀(n::'node::type) (V::'var::type) (n'::'node::type) as::'edge::type list. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀n n' as. ⟦¬ inner_node n'; n'' = n; Some V = None; as' = as; n' = n'; n controls n' via as⟧ ⟹ False› 2. ‹⋀n Va n' as. ⟦¬ inner_node n'; n'' = n; Some V = Some Va; as' = as; n' = n'; n influences Va in n' via as⟧ ⟹ False› discuss goal 1*) apply ((auto dest:path_valid_node (*‹(?n::'node::type) -?as::'edge::type list→* ?n'::'node::type ⟹ valid_node ?n› ‹(?n::'node::type) -?as::'edge::type list→* ?n'::'node::type ⟹ valid_node ?n'›*) simp:inner_node_def (*‹inner_node (?n::'node::type) ≡ valid_node ?n ∧ ?n ≠ (_Entry_) ∧ ?n ≠ (_Exit_)›*) dyn_data_dependence_def (*‹(?n::'node::type) influences ?V::'var::type in ?n'::'node::type via ?as::'edge::type list ≡ ?V ∈ (Def::'node::type ⇒ 'var::type set) ?n ∧ ?V ∈ (Use::'node::type ⇒ 'var::type set) ?n' ∧ ?n -?as→* ?n' ∧ (∃(a'::'edge::type) as'::'edge::type list. ?as = a' # as' ∧ (∀n''::'node::type∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*discuss goal 2*) apply ((auto dest:path_valid_node (*‹(?n::'node) -?as::'edge list→* ?n'::'node ⟹ valid_node ?n› ‹(?n::'node) -?as::'edge list→* ?n'::'node ⟹ valid_node ?n'›*) simp:inner_node_def (*‹inner_node (?n::'node) ≡ valid_node ?n ∧ ?n ≠ (_Entry_) ∧ ?n ≠ (_Exit_)›*) dyn_data_dependence_def (*‹(?n::'node) influences ?V::'var in ?n'::'node via ?as::'edge list ≡ ?V ∈ (Def::'node ⇒ 'var set) ?n ∧ ?V ∈ (Use::'node ⇒ 'var set) ?n' ∧ ?n -?as→* ?n' ∧ (∃(a'::'edge) as'::'edge list. ?as = a' # as' ∧ (∀n''::'node∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*proven 2 subgoals*) . thus "?case" (*goal: ‹n = n'›*) by simp qed lemma DynPDG_cdep_edge_CFG_path: assumes "n -as→⇩c⇩d n'" shows "n -as→* n'" and "as ≠ []" using ‹n -as→⇩c⇩d n'› (*‹n -as→⇩c⇩d n'›*) apply - (*goals: 1. ‹(n::'node::type) -as::'edge::type list→⇩c⇩d n'::'node::type ⟹ n -as→* n'› 2. ‹(n::'node::type) -as::'edge::type list→⇩c⇩d n'::'node::type ⟹ as ≠ []› discuss goal 1*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge (?a1.0::'node::type) (?a2.0::'var::type option) (?a3.0::'edge::type list) (?a4.0::'node::type); ⋀(n::'node::type) (n'::'node::type) as::'edge::type list. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P::bool; ⋀(n::'node::type) (V::'var::type) (n'::'node::type) as::'edge::type list. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:dyn_control_dependence_path (*‹(?n::'node::type) controls ?n'::'node::type via ?as::'edge::type list ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*))[1]) (*discuss goal 2*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) dest:dyn_control_dependence_path (*‹?n controls ?n' via ?as ⟹ ?n -?as→* ?n' ∧ ?as ≠ []›*))[1]) (*proven 2 subgoals*) . lemma DynPDG_ddep_edge_CFG_path: assumes "n -{V}as→⇩d⇩d n'" shows "n -as→* n'" and "as ≠ []" using ‹n -{V}as→⇩d⇩d n'› (*‹(n::'node) -{V::'var}as::'edge list→⇩d⇩d n'::'node›*) apply - (*goals: 1. ‹n -{V}as→⇩d⇩d n' ⟹ n -as→* n'› 2. ‹n -{V}as→⇩d⇩d n' ⟹ as ≠ []› discuss goal 1*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge (?a1.0::'node) (?a2.0::'var option) (?a3.0::'edge list) (?a4.0::'node); ⋀(n::'node) (n'::'node) as::'edge list. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P::bool; ⋀(n::'node) (V::'var) (n'::'node) as::'edge list. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:dyn_data_dependence_def (*‹(?n::'node) influences ?V::'var in ?n'::'node via ?as::'edge list ≡ ?V ∈ (Def::'node ⇒ 'var set) ?n ∧ ?V ∈ (Use::'node ⇒ 'var set) ?n' ∧ ?n -?as→* ?n' ∧ (∃(a'::'edge) as'::'edge list. ?as = a' # as' ∧ (∀n''::'node∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*discuss goal 2*) apply ((auto elim:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*))[1]) (*proven 2 subgoals*) . lemma DynPDG_path_CFG_path: "n -as→⇩d* n' ⟹ n -as→* n'" proof (induct rule:DynPDG_path.induct (*‹⟦(?x1.0::'node::type) -?x2.0::'edge::type list→⇩d* ?x3.0::'node::type; ⋀n::'node::type. valid_node n ⟹ (?P::'node::type ⇒ 'edge::type list ⇒ 'node::type ⇒ bool) n [] n; ⋀(n::'node::type) (as::'edge::type list) (n''::'node::type) (as'::'edge::type list) n'::'node::type. ⟦n -as→⇩d* n''; ?P n as n''; n'' -as'→⇩c⇩d n'⟧ ⟹ ?P n (as @ as') n'; ⋀(n::'node::type) (as::'edge::type list) (n''::'node::type) (V::'var::type) (as'::'edge::type list) n'::'node::type. ⟦n -as→⇩d* n''; ?P n as n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ ?P n (as @ as') n'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀n. valid_node n ⟹ n -[]→* n› 2. ‹⋀n as n'' as' n'. ⟦n -as→⇩d* n''; n -as→* n''; n'' -as'→⇩c⇩d n'⟧ ⟹ n -as @ as'→* n'› 3. ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; n -as→* n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ n -as @ as'→* n'›*) case DynPDG_path_Nil (*‹valid_node n_›*) thus "?case" (*goal: ‹n_ -[]→* n_›*) by (rule empty_path (*‹valid_node ?n ⟹ ?n -[]→* ?n›*)) next (*goals: 1. ‹⋀(n::'node::type) (as::'edge::type list) (n''::'node::type) (as'::'edge::type list) n'::'node::type. ⟦n -as→⇩d* n''; n -as→* n''; n'' -as'→⇩c⇩d n'⟧ ⟹ n -as @ as'→* n'› 2. ‹⋀(n::'node::type) (as::'edge::type list) (n''::'node::type) (V::'var::type) (as'::'edge::type list) n'::'node::type. ⟦n -as→⇩d* n''; n -as→* n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ n -as @ as'→* n'›*) case (DynPDG_path_Append_cdep n as n'' as' n') (*‹n -as→⇩d* n''› ‹n -as→* n''› ‹n'' -as'→⇩c⇩d n'›*) from ‹n'' -as'→⇩c⇩d n'› (*‹n'' -as'→⇩c⇩d n'›*) have "n'' -as'→* n'" by (rule DynPDG_cdep_edge_CFG_path( (*‹?n -?as→⇩c⇩d ?n' ⟹ ?n -?as→* ?n'›*) 1)) with ‹n -as→* n''› (*‹(n::'node) -as::'edge list→* n''::'node›*) show "?case" (*goal: ‹n -as @ as'→* n'›*) by (rule path_Append (*‹⟦(?n::'node::type) -?as::'edge::type list→* ?n''::'node::type; ?n'' -?as'::'edge::type list→* ?n'::'node::type⟧ ⟹ ?n -?as @ ?as'→* ?n'›*)) next (*goal: ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; n -as→* n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ n -as @ as'→* n'›*) case (DynPDG_path_Append_ddep n as n'' V as' n') (*‹n -as→⇩d* n''› ‹n -as→* n''› ‹n'' -{V}as'→⇩d⇩d n'›*) from ‹n'' -{V}as'→⇩d⇩d n'› (*‹(n''::'node::type) -{V::'var::type}as'::'edge::type list→⇩d⇩d n'::'node::type›*) have "n'' -as'→* n'" by (rule DynPDG_ddep_edge_CFG_path( (*‹?n -{?V}?as→⇩d⇩d ?n' ⟹ ?n -?as→* ?n'›*) 1)) with ‹n -as→* n''› (*‹n -as→* n''›*) show "?case" (*goal: ‹n -as @ as'→* n'›*) by (rule path_Append (*‹⟦?n -?as→* ?n''; ?n'' -?as'→* ?n'⟧ ⟹ ?n -?as @ ?as'→* ?n'›*)) qed lemma DynPDG_path_split: "n -as→⇩d* n' ⟹ (as = [] ∧ n = n') ∨ (∃n'' asx asx'. (n -asx→⇩c⇩d n'') ∧ (n'' -asx'→⇩d* n') ∧ (as = asx@asx')) ∨ (∃n'' V asx asx'. (n -{V}asx→⇩d⇩d n'') ∧ (n'' -asx'→⇩d* n') ∧ (as = asx@asx'))" proof (induct rule:DynPDG_path.induct (*‹⟦?x1.0 -?x2.0→⇩d* ?x3.0; ⋀n. valid_node n ⟹ ?P n [] n; ⋀n as n'' as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -as'→⇩c⇩d n'⟧ ⟹ ?P n (as @ as') n'; ⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; ?P n as n''; n'' -{V}as'→⇩d⇩d n'⟧ ⟹ ?P n (as @ as') n'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀n. valid_node n ⟹ [] = [] ∧ n = n ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n ∧ [] = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n ∧ [] = asx @ asx')› 2. ‹⋀n as n'' as' n'. ⟦n -as→⇩d* n''; as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx'); n'' -as'→⇩c⇩d n'⟧ ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')› 3. ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx'); n'' -{V}as'→⇩d⇩d n'⟧ ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) case (DynPDG_path_Nil n) (*‹valid_node n›*) thus "?case" (*goal: ‹[] = [] ∧ n = n ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n ∧ [] = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n ∧ [] = asx @ asx')›*) by auto next (*goals: 1. ‹⋀n as n'' as' n'. ⟦n -as→⇩d* n''; as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx'); n'' -as'→⇩c⇩d n'⟧ ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')› 2. ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx'); n'' -{V}as'→⇩d⇩d n'⟧ ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) case (DynPDG_path_Append_cdep n as n'' as' n') (*‹n -as→⇩d* n''› ‹as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx')› ‹n'' -as'→⇩c⇩d n'›*) note IH = ‹as = [] ∧ n = n'' ∨ (∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx')› (*‹(as::'edge list) = [] ∧ (n::'node) = (n''::'node) ∨ (∃(nx::'node) (asx::'edge list) asx'::'edge list. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃(nx::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx')›*) from IH (*‹as = [] ∧ n = n'' ∨ (∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx')›*) show "?case" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) proof (standard) (*goals: 1. ‹(as::'edge list) = [] ∧ (n::'node) = (n''::'node) ⟹ as @ (as'::'edge list) = [] ∧ n = (n'::'node) ∨ (∃(n''::'node) (asx::'edge list) asx'::'edge list. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃(n''::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')› 2. ‹(∃(nx::'node) (asx::'edge list) asx'::'edge list. (n::'node) -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx') ∨ (∃(nx::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ⟹ as @ (as'::'edge list) = [] ∧ n = (n'::'node) ∨ (∃(n''::'node) (asx::'edge list) asx'::'edge list. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃(n''::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "as = [] ∧ n = n''" (*‹(as::'edge list) = [] ∧ (n::'node) = (n''::'node)›*) with ‹n'' -as'→⇩c⇩d n'› (*‹n'' -as'→⇩c⇩d n'›*) have "valid_node n'" by (fastforce intro:path_valid_node( (*‹(?n::'node) -?as::'edge list→* ?n'::'node ⟹ valid_node ?n'›*) 2) DynPDG_path_CFG_path (*‹(?n::'node) -?as::'edge list→⇩d* ?n'::'node ⟹ ?n -?as→* ?n'›*) DynPDG_path_cdep (*‹(?n::'node) -?as::'edge list→⇩c⇩d ?n'::'node ⟹ ?n -?as→⇩d* ?n'›*)) with ‹as = [] ∧ n = n''› (*‹as = [] ∧ n = n''›*) ‹n'' -as'→⇩c⇩d n'› (*‹n'' -as'→⇩c⇩d n'›*) have "∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as@as' = asx@asx'" by (auto intro:DynPDG_path_Nil (*‹valid_node (?n::'node) ⟹ ?n -[]→⇩d* ?n›*)) thus "?thesis" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) by simp next (*goal: ‹(∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "(∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx')" (*‹(∃(nx::'node) (asx::'edge list) asx'::'edge list. (n::'node) -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx') ∨ (∃(nx::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx')›*) thus "?thesis" (*goal: ‹(as::'edge list) @ (as'::'edge list) = [] ∧ (n::'node) = (n'::'node) ∨ (∃(n''::'node) (asx::'edge list) asx'::'edge list. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃(n''::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) proof (standard) (*goals: 1. ‹∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')› 2. ‹∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx'" (*‹∃(nx::'node) (asx::'edge list) asx'::'edge list. (n::'node) -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx'›*) then obtain nx and asx and asx' where "n -asx→⇩c⇩d nx" and "nx -asx'→⇩d* n''" and "as = asx@asx'" (*goal: ‹(⋀asx nx asx'. ⟦n -asx→⇩c⇩d nx; nx -asx'→⇩d* n''; as = asx @ asx'⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹n'' -as'→⇩c⇩d n'› (*‹n'' -as'→⇩c⇩d n'›*) have "n'' -as'→⇩d* n'" by (rule DynPDG_path_cdep (*‹?n -?as→⇩c⇩d ?n' ⟹ ?n -?as→⇩d* ?n'›*)) with ‹nx -asx'→⇩d* n''› (*‹nx -asx'→⇩d* n''›*) have "nx -asx'@as'→⇩d* n'" by (fastforce intro:DynPDG_path_Append (*‹⟦?n'' -?as'→⇩d* ?n'; ?n -?as→⇩d* ?n''⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) with ‹n -asx→⇩c⇩d nx› (*‹(n::'node) -asx::'edge list→⇩c⇩d nx::'node›*) ‹as = asx@asx'› (*‹as = asx @ asx'›*) have "∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as@as' = asx@asx'" by auto thus "?thesis" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) by simp next (*goal: ‹∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx'" (*‹∃(nx::'node) (V::'var) (asx::'edge list) asx'::'edge list. (n::'node) -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx'›*) then obtain nx and V and asx and asx' where "n -{V}asx→⇩d⇩d nx" and "nx -asx'→⇩d* n''" and "as = asx@asx'" (*goal: ‹(⋀V asx nx asx'. ⟦n -{V}asx→⇩d⇩d nx; nx -asx'→⇩d* n''; as = asx @ asx'⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹n'' -as'→⇩c⇩d n'› (*‹n'' -as'→⇩c⇩d n'›*) have "n'' -as'→⇩d* n'" by (rule DynPDG_path_cdep (*‹?n -?as→⇩c⇩d ?n' ⟹ ?n -?as→⇩d* ?n'›*)) with ‹nx -asx'→⇩d* n''› (*‹nx -asx'→⇩d* n''›*) have "nx -asx'@as'→⇩d* n'" by (fastforce intro:DynPDG_path_Append (*‹⟦?n'' -?as'→⇩d* ?n'; ?n -?as→⇩d* ?n''⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) with ‹n -{V}asx→⇩d⇩d nx› (*‹n -{V}asx→⇩d⇩d nx›*) ‹as = asx@asx'› (*‹as = asx @ asx'›*) have "∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as@as' = asx@asx'" by auto thus "?thesis" (*goal: ‹(as::'edge list) @ (as'::'edge list) = [] ∧ (n::'node) = (n'::'node) ∨ (∃(n''::'node) (asx::'edge list) asx'::'edge list. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃(n''::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) by simp qed qed next (*goal: ‹⋀n as n'' V as' n'. ⟦n -as→⇩d* n''; as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx'); n'' -{V}as'→⇩d⇩d n'⟧ ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) case (DynPDG_path_Append_ddep n as n'' V as' n') (*‹(n::'node) -as::'edge list→⇩d* n''::'node› ‹as = [] ∧ n = n'' ∨ (∃n''a asx asx'. n -asx→⇩c⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃n''a V asx asx'. n -{V}asx→⇩d⇩d n''a ∧ n''a -asx'→⇩d* n'' ∧ as = asx @ asx')› ‹n'' -{V}as'→⇩d⇩d n'›*) note IH = ‹as = [] ∧ n = n'' ∨ (∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx')› (*‹as = [] ∧ n = n'' ∨ (∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx')›*) from IH (*‹as = [] ∧ n = n'' ∨ (∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx')›*) show "?case" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) proof (standard) (*goals: 1. ‹as = [] ∧ n = n'' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')› 2. ‹(∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "as = [] ∧ n = n''" (*‹(as::'edge list) = [] ∧ (n::'node) = (n''::'node)›*) with ‹n'' -{V}as'→⇩d⇩d n'› (*‹n'' -{V}as'→⇩d⇩d n'›*) have "valid_node n'" by (fastforce intro:path_valid_node( (*‹?n -?as→* ?n' ⟹ valid_node ?n'›*) 2) DynPDG_path_CFG_path (*‹?n -?as→⇩d* ?n' ⟹ ?n -?as→* ?n'›*) DynPDG_path_ddep (*‹?n -{?V}?as→⇩d⇩d ?n' ⟹ ?n -?as→⇩d* ?n'›*)) with ‹as = [] ∧ n = n''› (*‹(as::'edge list) = [] ∧ (n::'node) = (n''::'node)›*) ‹n'' -{V}as'→⇩d⇩d n'› (*‹n'' -{V}as'→⇩d⇩d n'›*) have "∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as@as' = asx@asx'" by (fastforce intro:DynPDG_path_Nil (*‹valid_node ?n ⟹ ?n -[]→⇩d* ?n›*)) thus "?thesis" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) by simp next (*goal: ‹(∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx') ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "(∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx') ∨ (∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx')" (*‹(∃(nx::'node) (asx::'edge list) asx'::'edge list. (n::'node) -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx') ∨ (∃(nx::'node) (V::'var) (asx::'edge list) asx'::'edge list. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx')›*) thus "?thesis" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) proof (standard) (*goals: 1. ‹∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')› 2. ‹∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "∃nx asx asx'. n -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx'" (*‹∃(nx::'node) (asx::'edge list) asx'::'edge list. (n::'node) -asx→⇩c⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx'›*) then obtain nx and asx and asx' where "n -asx→⇩c⇩d nx" and "nx -asx'→⇩d* n''" and "as = asx@asx'" (*goal: ‹(⋀asx nx asx'. ⟦n -asx→⇩c⇩d nx; nx -asx'→⇩d* n''; as = asx @ asx'⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹n'' -{V}as'→⇩d⇩d n'› (*‹n'' -{V}as'→⇩d⇩d n'›*) have "n'' -as'→⇩d* n'" by (rule DynPDG_path_ddep (*‹?n -{?V}?as→⇩d⇩d ?n' ⟹ ?n -?as→⇩d* ?n'›*)) with ‹nx -asx'→⇩d* n''› (*‹(nx::'node) -asx'::'edge list→⇩d* n''::'node›*) have "nx -asx'@as'→⇩d* n'" by (fastforce intro:DynPDG_path_Append (*‹⟦?n'' -?as'→⇩d* ?n'; ?n -?as→⇩d* ?n''⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) with ‹n -asx→⇩c⇩d nx› (*‹n -asx→⇩c⇩d nx›*) ‹as = asx@asx'› (*‹(as::'edge list) = (asx::'edge list) @ (asx'::'edge list)›*) have "∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as@as' = asx@asx'" by auto thus "?thesis" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) by simp next (*goal: ‹∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx @ asx' ⟹ as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) assume "∃nx V asx asx'. n -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n'' ∧ as = asx@asx'" (*‹∃(nx::'node) (V::'var) (asx::'edge list) asx'::'edge list. (n::'node) -{V}asx→⇩d⇩d nx ∧ nx -asx'→⇩d* n''::'node ∧ (as::'edge list) = asx @ asx'›*) then obtain nx and V' and asx and asx' where "n -{V'}asx→⇩d⇩d nx" and "nx -asx'→⇩d* n''" and "as = asx@asx'" (*goal: ‹(⋀V' asx nx asx'. ⟦n -{V'}asx→⇩d⇩d nx; nx -asx'→⇩d* n''; as = asx @ asx'⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹n'' -{V}as'→⇩d⇩d n'› (*‹(n''::'node) -{V::'var}as'::'edge list→⇩d⇩d n'::'node›*) have "n'' -as'→⇩d* n'" by (rule DynPDG_path_ddep (*‹(?n::'node) -{?V::'var}?as::'edge list→⇩d⇩d ?n'::'node ⟹ ?n -?as→⇩d* ?n'›*)) with ‹nx -asx'→⇩d* n''› (*‹nx -asx'→⇩d* n''›*) have "nx -asx'@as'→⇩d* n'" by (fastforce intro:DynPDG_path_Append (*‹⟦?n'' -?as'→⇩d* ?n'; ?n -?as→⇩d* ?n''⟧ ⟹ ?n -?as @ ?as'→⇩d* ?n'›*)) with ‹n -{V'}asx→⇩d⇩d nx› (*‹n -{V'}asx→⇩d⇩d nx›*) ‹as = asx@asx'› (*‹as = asx @ asx'›*) have "∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as@as' = asx@asx'" by auto thus "?thesis" (*goal: ‹as @ as' = [] ∧ n = n' ∨ (∃n'' asx asx'. n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx') ∨ (∃n'' V asx asx'. n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* n' ∧ as @ as' = asx @ asx')›*) by simp qed qed qed lemma DynPDG_path_rev_cases [consumes 1, case_names DynPDG_path_Nil DynPDG_path_cdep_Append DynPDG_path_ddep_Append]: "⟦n -as→⇩d* n'; ⟦as = []; n = n'⟧ ⟹ Q; ⋀n'' asx asx'. ⟦n -asx→⇩c⇩d n''; n'' -asx'→⇩d* n'; as = asx@asx'⟧ ⟹ Q; ⋀V n'' asx asx'. ⟦n -{V}asx→⇩d⇩d n''; n'' -asx'→⇩d* n'; as = asx@asx'⟧ ⟹ Q⟧ ⟹ Q" by (blast dest:DynPDG_path_split (*‹?n -?as→⇩d* ?n' ⟹ ?as = [] ∧ ?n = ?n' ∨ (∃n'' asx asx'. ?n -asx→⇩c⇩d n'' ∧ n'' -asx'→⇩d* ?n' ∧ ?as = asx @ asx') ∨ (∃n'' V asx asx'. ?n -{V}asx→⇩d⇩d n'' ∧ n'' -asx'→⇩d* ?n' ∧ ?as = asx @ asx')›*)) lemma DynPDG_ddep_edge_no_shorter_ddep_edge: assumes ddep:"n -{V}as→⇩d⇩d n'" shows "∀as' a as''. tl as = as'@a#as'' ⟶ ¬ sourcenode a -{V}a#as''→⇩d⇩d n'" proof (-) (*goal: ‹∀as' a as''. tl as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n'›*) from ddep (*‹n -{V}as→⇩d⇩d n'›*) have influence: "n influences V in n' via as" by (auto elim!:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*)) then obtain a and asx where as: "as = a#asx" and notin: "n ∉ set (sourcenodes asx)" (*goal: ‹(⋀a asx. ⟦as = a # asx; n ∉ set (sourcenodes asx)⟧ ⟹ thesis) ⟹ thesis›*) by (auto dest:dyn_influence_source_notin_tl_edges (*‹?n influences ?V in ?n' via ?a # ?as ⟹ ?n ∉ set (sourcenodes ?as)›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*)) from influence (*‹n influences V in n' via as›*) as (*‹as = a # asx›*) have imp: "∀nx ∈ set (sourcenodes asx). V ∉ Def nx" by (auto simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*)) { fix as' and a' and as'' assume eq: "tl as = as'@a'#as''" and ddep': "sourcenode a' -{V}a'#as''→⇩d⇩d n'" (*‹tl (as::'edge list) = (as'::'edge list) @ (a'::'edge) # (as''::'edge list)› ‹(sourcenode::'edge ⇒ 'node) (a'::'edge) -{V::'var}a' # (as''::'edge list)→⇩d⇩d n'::'node›*) from eq (*‹tl (as::'edge list) = (as'::'edge list) @ (a'::'edge) # (as''::'edge list)›*) as (*‹as = a # asx›*) notin (*‹n ∉ set (sourcenodes asx)›*) have noteq: "sourcenode a' ≠ n" by (auto simp:sourcenodes_def (*‹sourcenodes ?xs ≡ map sourcenode ?xs›*)) from ddep' (*‹(sourcenode::'edge ⇒ 'node) (a'::'edge) -{V::'var}a' # (as''::'edge list)→⇩d⇩d n'::'node›*) have "V ∈ Def (sourcenode a')" by (auto elim!:DynPDG_edge.cases (*‹⟦DynPDG_edge ?a1.0 ?a2.0 ?a3.0 ?a4.0; ⋀n n' as. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P; ⋀n V n' as. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*) simp:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*)) with eq (*‹tl as = as' @ a' # as''›*) as (*‹as = a # asx›*) noteq (*‹sourcenode a' ≠ n›*) imp (*‹∀nx∈set (sourcenodes asx). V ∉ Def nx›*) have False by (auto simp:sourcenodes_def (*‹sourcenodes ?xs ≡ map sourcenode ?xs›*)) } thus "?thesis" (*goal: ‹∀as' a as''. tl as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n'›*) by blast qed lemma no_ddep_same_state: assumes path:"n -as→* n'" and Uses:"V ∈ Use n'" and preds:"preds (kinds as) s" and no_dep:"∀as' a as''. as = as'@a#as'' ⟶ ¬ sourcenode a -{V}a#as''→⇩d⇩d n'" shows "state_val (transfers (kinds as) s) V = state_val s V" proof (-) (*goal: ‹state_val (transfers (kinds as) s) V = state_val s V›*) { fix n'' assume inset: "n'' ∈ set (sourcenodes as)" and Defs: "V ∈ Def n''" (*‹(n''::'node) ∈ set (sourcenodes (as::'edge list))› ‹(V::'var) ∈ (Def::'node ⇒ 'var set) (n''::'node)›*) hence "∃nx ∈ set (sourcenodes as). V ∈ Def nx" by auto then obtain nx and ns' and ns'' where nodes: "sourcenodes as = ns'@nx#ns''" and Defs': "V ∈ Def nx" and notDef: "∀nx' ∈ set ns''. V ∉ Def nx'" (*goal: ‹(⋀ns' nx ns''. ⟦sourcenodes as = ns' @ nx # ns''; V ∈ Def nx; ∀nx'∈set ns''. V ∉ Def nx'⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce elim!:rightmost_element_property (*‹⟦∃x∈set ?xs. ?P x; ⋀ys x' zs. ⟦?xs = ys @ x' # zs; ?P x'; ∀z∈set zs. ¬ ?P z⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) from nodes (*‹sourcenodes as = ns' @ nx # ns''›*) obtain as' and a and as'' where as'': "sourcenodes as'' = ns''" and as: "as=as'@a#as''" and source: "sourcenode a = nx" (*goal: ‹(⋀(as''::'edge list) (as'::'edge list) a::'edge. ⟦sourcenodes as'' = (ns''::'node list); (as::'edge list) = as' @ a # as''; (sourcenode::'edge ⇒ 'node) a = (nx::'node)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (fastforce elim:map_append_append_maps (*‹⟦map (?f::?'b ⇒ ?'a) (?xs::?'b list) = (?ys::?'a list) @ (?zs::?'a list); ⋀(xs'::?'b list) xs''::?'b list. ⟦map ?f xs' = ?ys; map ?f xs'' = ?zs; ?xs = xs' @ xs''⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) simp:sourcenodes_def (*‹sourcenodes (?xs::'edge list) ≡ map (sourcenode::'edge ⇒ 'node) ?xs›*)) from as (*‹as = as' @ a # as''›*) path (*‹(n::'node::type) -as::'edge::type list→* n'::'node::type›*) have path': "sourcenode a -a#as''→* n'" by (fastforce dest:path_split_second (*‹(?n::'node::type) -(?as::'edge::type list) @ (?a::'edge::type) # (?as'::'edge::type list)→* ?n'::'node::type ⟹ (sourcenode::'edge::type ⇒ 'node::type) ?a -?a # ?as'→* ?n'›*)) from notDef (*‹∀nx'∈set ns''. V ∉ Def nx'›*) as'' (*‹sourcenodes as'' = ns''›*) source (*‹sourcenode a = nx›*) have "∀n'' ∈ set (sourcenodes as''). V ∉ Def n''" by (auto simp:sourcenodes_def (*‹sourcenodes (?xs::'edge::type list) ≡ map (sourcenode::'edge::type ⇒ 'node::type) ?xs›*)) with path' (*‹sourcenode a -a # as''→* n'›*) Defs' (*‹V ∈ Def nx›*) Uses (*‹(V::'var) ∈ (Use::'node ⇒ 'var set) (n'::'node)›*) source (*‹sourcenode a = nx›*) have influence: "nx influences V in n' via (a#as'')" by (simp add:dyn_data_dependence_def (*‹?n influences ?V in ?n' via ?as ≡ ?V ∈ Def ?n ∧ ?V ∈ Use ?n' ∧ ?n -?as→* ?n' ∧ (∃a' as'. ?as = a' # as' ∧ (∀n''∈set (sourcenodes as'). ?V ∉ Def n''))›*)) hence "nx ∉ set (sourcenodes as'')" by (rule dyn_influence_source_notin_tl_edges (*‹(?n::'node) influences ?V::'var in ?n'::'node via (?a::'edge) # (?as::'edge list) ⟹ ?n ∉ set (sourcenodes ?as)›*)) with influence (*‹nx influences V in n' via a # as''›*) source (*‹sourcenode a = nx›*) have "∃asx a'. sourcenode a' -{V}a'#asx→⇩d⇩d n' ∧ sourcenode a' = nx ∧ (∃asx'. a#as'' = asx'@a'#asx)" by (fastforce intro:DynPDG_ddep_edge (*‹?n influences ?V in ?n' via ?as ⟹ ?n -{?V}?as→⇩d⇩d ?n'›*)) with nodes (*‹sourcenodes as = ns' @ nx # ns''›*) no_dep (*‹∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n'›*) as (*‹as = as' @ a # as''›*) have False by (auto simp:sourcenodes_def (*‹sourcenodes ?xs ≡ map sourcenode ?xs›*)) } hence "∀n ∈ set (sourcenodes as). V ∉ Def n" by auto with wf (*‹wf {(x, y). x < y}›*) path (*‹n -as→* n'›*) preds (*‹preds (kinds as) s›*) show "?thesis" (*goal: ‹state_val (transfers (kinds as) s) V = state_val s V›*) by (fastforce intro:CFG_path_no_Def_equal (*‹⟦?n -?as→* ?n'; ∀n∈set (sourcenodes ?as). ?V ∉ Def n; preds (kinds ?as) ?s⟧ ⟹ state_val (transfers (kinds ?as) ?s) ?V = state_val ?s ?V›*)) qed lemma DynPDG_ddep_edge_only_first_edge: "⟦n -{V}a#as→⇩d⇩d n'; preds (kinds (a#as)) s⟧ ⟹ state_val (transfers (kinds (a#as)) s) V = state_val (transfer (kind a) s) V" apply - (*goal: ‹⟦n -{V}a # as→⇩d⇩d n'; preds (kinds (a # as)) s⟧ ⟹ state_val (transfers (kinds (a # as)) s) V = state_val (transfer (kind a) s) V›*) apply (erule DynPDG_edge.cases (*‹⟦DynPDG_edge (?a1.0::'node) (?a2.0::'var option) (?a3.0::'edge list) (?a4.0::'node); ⋀(n::'node) (n'::'node) as::'edge list. ⟦?a1.0 = n; ?a2.0 = None; ?a3.0 = as; ?a4.0 = n'; n controls n' via as⟧ ⟹ ?P::bool; ⋀(n::'node) (V::'var) (n'::'node) as::'edge list. ⟦?a1.0 = n; ?a2.0 = Some V; ?a3.0 = as; ?a4.0 = n'; n influences V in n' via as⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀na n'a asa. ⟦preds (kinds (a # as)) s; n = na; Some V = None; a # as = asa; n' = n'a; na controls n'a via asa⟧ ⟹ state_val (transfers (kinds (a # as)) s) V = state_val (transfer (kind a) s) V› 2. ‹⋀na Va n'a asa. ⟦preds (kinds (a # as)) s; n = na; Some V = Some Va; a # as = asa; n' = n'a; na influences Va in n'a via asa⟧ ⟹ state_val (transfers (kinds (a # as)) s) V = state_val (transfer (kind a) s) V› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀(na::'node) (Va::'var) (n'a::'node) asa::'edge list. ⟦preds (kinds ((a::'edge) # (as::'edge list))) (s::'state); (n::'node) = na; Some (V::'var) = Some Va; a # as = asa; (n'::'node) = n'a; na influences Va in n'a via asa⟧ ⟹ (state_val::'state ⇒ 'var ⇒ 'val) (transfers (kinds (a # as)) s) V = state_val (transfer ((kind::'edge ⇒ 'state edge_kind) a) s) V›*) apply (frule dyn_influence_Cons_source (*‹?n influences ?V in ?n' via ?a # ?as ⟹ sourcenode ?a = ?n›*)) (*goal: ‹⟦preds (kinds (a # as)) s; n influences V in n' via a # as⟧ ⟹ state_val (transfers (kinds (a # as)) s) V = state_val (transfer (kind a) s) V›*) apply (frule dyn_influence_source_notin_tl_edges (*‹?n influences ?V in ?n' via ?a # ?as ⟹ ?n ∉ set (sourcenodes ?as)›*)) (*goal: ‹⟦preds (kinds (a # as)) s; n influences V in n' via a # as; sourcenode a = n⟧ ⟹ state_val (transfers (kinds (a # as)) s) V = state_val (transfer (kind a) s) V›*) by (erule dyn_influence_only_first_edge (*‹⟦?n influences ?V in ?n' via ?a # ?as; preds (kinds (?a # ?as)) ?s⟧ ⟹ state_val (transfers (kinds (?a # ?as)) ?s) ?V = state_val (transfer (kind ?a) ?s) ?V›*)) (*proven 2 subgoals*) lemma Use_value_change_implies_DynPDG_ddep_edge: assumes "n -as→* n'" and "V ∈ Use n'" and "preds (kinds as) s" and "preds (kinds as) s'" and "state_val s V = state_val s' V" and "state_val (transfers (kinds as) s) V ≠ state_val (transfers (kinds as) s') V" obtains as' a as'' where "as = as'@a#as''" and "sourcenode a -{V}a#as''→⇩d⇩d n'" and "state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as'@[a])) s) V" and "state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as'@[a])) s') V" proof (atomize_elim) (*goal: ‹∃as' a as''. as = as' @ a # as'' ∧ sourcenode a -{V}a # as''→⇩d⇩d n' ∧ state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as' @ [a])) s') V›*) show "∃as' a as''. as = as'@a#as'' ∧ sourcenode a -{V}a#as''→⇩d⇩d n' ∧ state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as'@[a])) s) V ∧ state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as'@[a])) s') V" proof (cases "∀as' a as''. as = as'@a#as'' ⟶ ¬ sourcenode a -{V}a#as''→⇩d⇩d n'") (*goals: 1. ‹∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n' ⟹ ∃as' a as''. as = as' @ a # as'' ∧ sourcenode a -{V}a # as''→⇩d⇩d n' ∧ state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as' @ [a])) s') V› 2. ‹¬ (∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n') ⟹ ∃as' a as''. as = as' @ a # as'' ∧ sourcenode a -{V}a # as''→⇩d⇩d n' ∧ state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as' @ [a])) s') V›*) case True (*‹∀(as'::'edge::type list) (a::'edge::type) as''::'edge::type list. (as::'edge::type list) = as' @ a # as'' ⟶ ¬ (sourcenode::'edge::type ⇒ 'node::type) a -{V::'var::type}a # as''→⇩d⇩d n'::'node::type›*) with ‹n -as→* n'› (*‹n -as→* n'›*) ‹V ∈ Use n'› (*‹V ∈ Use n'›*) ‹preds (kinds as) s› (*‹preds (kinds as) s›*) ‹preds (kinds as) s'› (*‹preds (kinds as) s'›*) have "state_val (transfers (kinds as) s) V = state_val s V" and "state_val (transfers (kinds as) s') V = state_val s' V" apply - (*goals: 1. ‹⟦n -as→* n'; V ∈ Use n'; preds (kinds as) s; preds (kinds as) s'; ∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n'⟧ ⟹ state_val (transfers (kinds as) s) V = state_val s V› 2. ‹⟦n -as→* n'; V ∈ Use n'; preds (kinds as) s; preds (kinds as) s'; ∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n'⟧ ⟹ state_val (transfers (kinds as) s') V = state_val s' V› discuss goal 1*) apply ((auto intro:no_ddep_same_state (*‹⟦?n -?as→* ?n'; ?V ∈ Use ?n'; preds (kinds ?as) ?s; ∀as' a as''. ?as = as' @ a # as'' ⟶ ¬ sourcenode a -{?V}a # as''→⇩d⇩d ?n'⟧ ⟹ state_val (transfers (kinds ?as) ?s) ?V = state_val ?s ?V›*))[1]) (*discuss goal 2*) apply ((auto intro:no_ddep_same_state (*‹⟦(?n::'node) -?as::'edge list→* ?n'::'node; (?V::'var) ∈ (Use::'node ⇒ 'var set) ?n'; preds (kinds ?as) (?s::'state); ∀(as'::'edge list) (a::'edge) as''::'edge list. ?as = as' @ a # as'' ⟶ ¬ (sourcenode::'edge ⇒ 'node) a -{?V}a # as''→⇩d⇩d ?n'⟧ ⟹ (state_val::'state ⇒ 'var ⇒ 'val) (transfers (kinds ?as) ?s) ?V = state_val ?s ?V›*))[1]) (*proven 2 subgoals*) . with ‹state_val s V = state_val s' V› (*‹state_val s V = state_val s' V›*) ‹state_val (transfers (kinds as) s) V ≠ state_val (transfers (kinds as) s') V› (*‹(state_val::'state ⇒ 'var ⇒ 'val) (transfers (kinds (as::'edge list)) (s::'state)) (V::'var) ≠ state_val (transfers (kinds as) (s'::'state)) V›*) show "?thesis" (*goal: ‹∃(as'::'edge list) (a::'edge) as''::'edge list. (as::'edge list) = as' @ a # as'' ∧ (sourcenode::'edge ⇒ 'node) a -{V::'var}a # as''→⇩d⇩d n'::'node ∧ (state_val::'state ⇒ 'var ⇒ 'val) (transfers (kinds as) (s::'state)) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) (s'::'state)) V = state_val (transfers (kinds (as' @ [a])) s') V›*) by simp next (*goal: ‹¬ (∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n') ⟹ ∃as' a as''. as = as' @ a # as'' ∧ sourcenode a -{V}a # as''→⇩d⇩d n' ∧ state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as' @ [a])) s') V›*) case False (*‹¬ (∀as' a as''. as = as' @ a # as'' ⟶ ¬ sourcenode a -{V}a # as''→⇩d⇩d n')›*) then obtain as' and a and as'' where [simp]: "as = as'@a#as''" and "sourcenode a -{V}a#as''→⇩d⇩d n'" (*goal: ‹(⋀as' a as''. ⟦as = as' @ a # as''; sourcenode a -{V}a # as''→⇩d⇩d n'⟧ ⟹ thesis) ⟹ thesis›*) by auto from ‹preds (kinds as) s› (*‹preds (kinds as) s›*) have "preds (kinds (a#as'')) (transfers (kinds as') s)" by (simp add:kinds_def (*‹kinds ?xs ≡ map kind ?xs›*) preds_split (*‹preds (?ets @ ?ets') ?s = (preds ?ets ?s ∧ preds ?ets' (transfers ?ets ?s))›*)) with ‹sourcenode a -{V}a#as''→⇩d⇩d n'› (*‹sourcenode a -{V}a # as''→⇩d⇩d n'›*) have all: "state_val (transfers (kinds (a#as'')) (transfers (kinds as') s)) V = state_val (transfer (kind a) (transfers (kinds as') s)) V" by (auto dest!:DynPDG_ddep_edge_only_first_edge (*‹⟦?n -{?V}?a # ?as→⇩d⇩d ?n'; preds (kinds (?a # ?as)) ?s⟧ ⟹ state_val (transfers (kinds (?a # ?as)) ?s) ?V = state_val (transfer (kind ?a) ?s) ?V›*)) from ‹preds (kinds as) s'› (*‹preds (kinds as) s'›*) have "preds (kinds (a#as'')) (transfers (kinds as') s')" by (simp add:kinds_def (*‹kinds ?xs ≡ map kind ?xs›*) preds_split (*‹preds (?ets @ ?ets') ?s = (preds ?ets ?s ∧ preds ?ets' (transfers ?ets ?s))›*)) with ‹sourcenode a -{V}a#as''→⇩d⇩d n'› (*‹sourcenode a -{V}a # as''→⇩d⇩d n'›*) have all': "state_val (transfers (kinds (a#as'')) (transfers (kinds as') s')) V = state_val (transfer (kind a) (transfers (kinds as') s')) V" by (auto dest!:DynPDG_ddep_edge_only_first_edge (*‹⟦?n -{?V}?a # ?as→⇩d⇩d ?n'; preds (kinds (?a # ?as)) ?s⟧ ⟹ state_val (transfers (kinds (?a # ?as)) ?s) ?V = state_val (transfer (kind ?a) ?s) ?V›*)) hence eq: "⋀s. transfers (kinds as) s = transfers (kinds (a#as'')) (transfers (kinds as') s)" by (simp add:transfers_split[THEN sym] (*‹transfers ?ets'1 (transfers ?ets1 ?s1) = transfers (?ets1 @ ?ets'1) ?s1›*) kinds_def (*‹kinds ?xs ≡ map kind ?xs›*)) with all (*‹state_val (transfers (kinds (a # as'')) (transfers (kinds as') s)) V = state_val (transfer (kind a) (transfers (kinds as') s)) V›*) have "state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as'@[a])) s) V" by (simp add:transfers_split (*‹transfers ((?ets::?'a::type edge_kind list) @ (?ets'::?'a::type edge_kind list)) (?s::?'a::type) = transfers ?ets' (transfers ?ets ?s)›*) kinds_def (*‹kinds (?xs::'edge::type list) ≡ map (kind::'edge::type ⇒ 'state::type edge_kind) ?xs›*)) moreover from eq (*‹transfers (kinds as) ?s = transfers (kinds (a # as'')) (transfers (kinds as') ?s)›*) all' (*‹state_val (transfers (kinds (a # as'')) (transfers (kinds as') s')) V = state_val (transfer (kind a) (transfers (kinds as') s')) V›*) have "state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as'@[a])) s') V" by (simp add:transfers_split (*‹transfers (?ets @ ?ets') ?s = transfers ?ets' (transfers ?ets ?s)›*) kinds_def (*‹kinds ?xs ≡ map kind ?xs›*)) ultimately show "?thesis" (*goal: ‹∃(as'::'edge list) (a::'edge) as''::'edge list. (as::'edge list) = as' @ a # as'' ∧ (sourcenode::'edge ⇒ 'node) a -{V::'var}a # as''→⇩d⇩d n'::'node ∧ (state_val::'state ⇒ 'var ⇒ 'val) (transfers (kinds as) (s::'state)) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) (s'::'state)) V = state_val (transfers (kinds (as' @ [a])) s') V›*) using ‹sourcenode a -{V}a#as''→⇩d⇩d n'› (*‹(sourcenode::'edge::type ⇒ 'node::type) (a::'edge::type) -{V::'var::type}a # (as''::'edge::type list)→⇩d⇩d n'::'node::type›*) apply simp (*goal: ‹∃as' a as''. as = as' @ a # as'' ∧ sourcenode a -{V}a # as''→⇩d⇩d n' ∧ state_val (transfers (kinds as) s) V = state_val (transfers (kinds (as' @ [a])) s) V ∧ state_val (transfers (kinds as) s') V = state_val (transfers (kinds (as' @ [a])) s') V›*) by blast qed qed end subsection ‹Instantiate dynamic PDG› subsubsection ‹Standard control dependence› locale DynStandardControlDependencePDG = Postdomination sourcenode targetnode kind valid_edge Entry Exit + CFGExit_wf sourcenode targetnode kind valid_edge Entry Def Use state_val Exit for sourcenode :: "'edge ⇒ 'node" and targetnode :: "'edge ⇒ 'node" and kind :: "'edge ⇒ 'state edge_kind" and valid_edge :: "'edge ⇒ bool" and Entry :: "'node" ("'('_Entry'_')") and Def :: "'node ⇒ 'var set" and Use :: "'node ⇒ 'var set" and state_val :: "'state ⇒ 'var ⇒ 'val" and Exit :: "'node" ("'('_Exit'_')") begin lemma DynPDG_scd: "DynPDG sourcenode targetnode kind valid_edge (_Entry_) Def Use state_val (_Exit_) dyn_standard_control_dependence" proof (unfold_locales) (*goals: 1. ‹⋀n n' as. n controls⇩s n' via as ⟹ n' ≠ (_Exit_)› 2. ‹⋀n n' as. n controls⇩s n' via as ⟹ n -as→* n' ∧ as ≠ []›*) fix n and n' and as assume "n controls⇩s n' via as" (*‹(n::'node) controls⇩s n'::'node via as::'edge list›*) show "n' ≠ (_Exit_)" proof (standard) (*goal: ‹n' = (_Exit_) ⟹ False›*) assume "n' = (_Exit_)" (*‹(n'::'node) = (_Exit_)›*) with ‹n controls⇩s n' via as› (*‹n controls⇩s n' via as›*) show False by (fastforce intro:Exit_not_dyn_standard_control_dependent (*‹?n controls⇩s (_Exit_) via ?as ⟹ False›*)) qed next (*goal: ‹⋀n n' as. n controls⇩s n' via as ⟹ n -as→* n' ∧ as ≠ []›*) fix n and n' and as assume "n controls⇩s n' via as" (*‹(n::'node) controls⇩s n'::'node via as::'edge list›*) thus "n -as→* n' ∧ as ≠ []" by (fastforce simp:dyn_standard_control_dependence_def (*‹?n controls⇩s ?n' via ?as ≡ ∃a a' as'. ?as = a # as' ∧ ?n' ∉ set (sourcenodes ?as) ∧ ?n -?as→* ?n' ∧ ?n' postdominates targetnode a ∧ valid_edge a' ∧ sourcenode a' = ?n ∧ ¬ ?n' postdominates targetnode a'›*)) qed end subsubsection ‹Weak control dependence› locale DynWeakControlDependencePDG = StrongPostdomination sourcenode targetnode kind valid_edge Entry Exit + CFGExit_wf sourcenode targetnode kind valid_edge Entry Def Use state_val Exit for sourcenode :: "'edge ⇒ 'node" and targetnode :: "'edge ⇒ 'node" and kind :: "'edge ⇒ 'state edge_kind" and valid_edge :: "'edge ⇒ bool" and Entry :: "'node" ("'('_Entry'_')") and Def :: "'node ⇒ 'var set" and Use :: "'node ⇒ 'var set" and state_val :: "'state ⇒ 'var ⇒ 'val" and Exit :: "'node" ("'('_Exit'_')") begin lemma DynPDG_wcd: "DynPDG sourcenode targetnode kind valid_edge (_Entry_) Def Use state_val (_Exit_) dyn_weak_control_dependence" sorry end subsection ‹Data slice› definition (in CFG) empty_control_dependence :: "'node ⇒ 'node ⇒ 'edge list ⇒ bool" where "empty_control_dependence n n' as ≡ False" lemma (in CFGExit_wf) DynPDG_scd: "DynPDG sourcenode targetnode kind valid_edge (_Entry_) Def Use state_val (_Exit_) empty_control_dependence" proof (unfold_locales) (*goals: 1. ‹⋀n n' as. empty_control_dependence n n' as ⟹ n' ≠ (_Exit_)› 2. ‹⋀n n' as. empty_control_dependence n n' as ⟹ n -as→* n' ∧ as ≠ []›*) fix n and n' and as assume "empty_control_dependence n n' as" (*‹empty_control_dependence (n::'node) (n'::'node) (as::'edge list)›*) thus "n' ≠ (_Exit_)" by (simp add:empty_control_dependence_def (*‹empty_control_dependence (?n::'node) (?n'::'node) (?as::'edge list) ≡ False›*)) next (*goal: ‹⋀n n' as. empty_control_dependence n n' as ⟹ n -as→* n' ∧ as ≠ []›*) fix n and n' and as assume "empty_control_dependence n n' as" (*‹empty_control_dependence (n::'node) (n'::'node) (as::'edge list)›*) thus "n -as→* n' ∧ as ≠ []" by (simp add:empty_control_dependence_def (*‹empty_control_dependence ?n ?n' ?as ≡ False›*)) qed end
{ "path": "afp-2025-02-12/thys/Slicing/Dynamic/DynPDG.thy", "repo": "afp-2025-02-12", "sha": "0ff5532cd951c378c41c80b9cbe127d7b1ab6d3b45a8308de209c5f058839e21" }
(* Title: CoreC++ Author: Daniel Wasserrab Maintainer: Daniel Wasserrab <wasserra at fmi.uni-passau.de> Based on the Jinja theory Common/Decl.thy by David von Oheimb *) section ‹Class Declarations and Programs› theory Decl imports Expr begin type_synonym fdecl = "vname × ty" ― ‹field declaration› type_synonym "method" = "ty list × ty × (vname list × expr)" ― ‹arg.\ types, return type, params, body› type_synonym mdecl = "mname × method" ― ‹method declaration› type_synonym "class" = "base list × fdecl list × mdecl list" ― ‹class = superclasses, fields, methods› type_synonym cdecl = "cname × class" ― ‹classa declaration› type_synonym prog = "cdecl list" ― ‹program› translations (type) "fdecl" <= (type) "vname × ty" (type) "mdecl" <= (type) "mname × ty list × ty × (vname list × expr)" (type) "class" <= (type) "cname × fdecl list × mdecl list" (type) "cdecl" <= (type) "cname × class" (type) "prog " <= (type) "cdecl list" definition "class" :: "prog ⇒ cname ⇀ class" where "class ≡ map_of" definition is_class :: "prog ⇒ cname ⇒ bool" where "is_class P C ≡ class P C ≠ None" definition baseClasses :: "base list ⇒ cname set" where "baseClasses Bs ≡ set ((map getbase) Bs)" definition RepBases :: "base list ⇒ cname set" where "RepBases Bs ≡ set ((map getbase) (filter isRepBase Bs))" definition SharedBases :: "base list ⇒ cname set" where "SharedBases Bs ≡ set ((map getbase) (filter isShBase Bs))" lemma not_getbase_repeats: "D ∉ set (map getbase xs) ⟹ Repeats D ∉ set xs" apply (induct rule: list.induct (*‹⟦?P []; ⋀x1 x2. ?P x2 ⟹ ?P (x1 # x2)⟧ ⟹ ?P ?list›*)) (*goals: 1. ‹D ∉ set (map getbase []) ⟹ Repeats D ∉ set []› 2. ‹⋀x1 x2. ⟦D ∉ set (map getbase x2) ⟹ Repeats D ∉ set x2; D ∉ set (map getbase (x1 # x2))⟧ ⟹ Repeats D ∉ set (x1 # x2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma not_getbase_shares: "D ∉ set (map getbase xs) ⟹ Shares D ∉ set xs" apply (induct rule: list.induct (*‹⟦(?P::?'a::type list ⇒ bool) []; ⋀(x1::?'a::type) x2::?'a::type list. ?P x2 ⟹ ?P (x1 # x2)⟧ ⟹ ?P (?list::?'a::type list)›*)) (*goals: 1. ‹D ∉ set (map getbase []) ⟹ Shares D ∉ set []› 2. ‹⋀x1 x2. ⟦D ∉ set (map getbase x2) ⟹ Shares D ∉ set x2; D ∉ set (map getbase (x1 # x2))⟧ ⟹ Shares D ∉ set (x1 # x2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma RepBaseclass_isBaseclass: "⟦class P C = Some(Bs,fs,ms); Repeats D ∈ set Bs⟧ ⟹ D ∈ baseClasses Bs" apply (simp add:baseClasses_def (*‹baseClasses ?Bs ≡ set (map getbase ?Bs)›*)) (*goal: ‹⟦class (P::(char list × base list × (char list × ty) list × (char list × ty list × ty × char list list × expr) list) list) (C::char list) = ⌊(Bs::base list, fs::(char list × ty) list, ms::(char list × ty list × ty × char list list × expr) list)⌋; Repeats (D::char list) ∈ set Bs⟧ ⟹ D ∈ baseClasses Bs›*) apply (induct rule: list.induct (*‹⟦(?P::?'a list ⇒ bool) []; ⋀(x1::?'a) x2::?'a list. ?P x2 ⟹ ?P (x1 # x2)⟧ ⟹ ?P (?list::?'a list)›*)) (*goals: 1. ‹⟦class P C = ⌊([], fs, ms)⌋; Repeats D ∈ set []⟧ ⟹ D ∈ getbase ` set []› 2. ‹⋀x1 x2. ⟦⟦class P C = ⌊(x2, fs, ms)⌋; Repeats D ∈ set x2⟧ ⟹ D ∈ getbase ` set x2; class P C = ⌊(x1 # x2, fs, ms)⌋; Repeats D ∈ set (x1 # x2)⟧ ⟹ D ∈ getbase ` set (x1 # x2)› discuss goal 1*) apply ((auto simp:not_getbase_repeats (*‹(?D::char list) ∉ set (map getbase (?xs::base list)) ⟹ Repeats ?D ∉ set ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp:not_getbase_repeats (*‹?D ∉ set (map getbase ?xs) ⟹ Repeats ?D ∉ set ?xs›*))[1]) (*proven 2 subgoals*) . lemma ShBaseclass_isBaseclass: "⟦class P C = Some(Bs,fs,ms); Shares D ∈ set Bs⟧ ⟹ D ∈ baseClasses Bs" apply (simp add:baseClasses_def (*‹baseClasses ?Bs ≡ set (map getbase ?Bs)›*)) (*goal: ‹⟦class P C = ⌊(Bs, fs, ms)⌋; Shares D ∈ set Bs⟧ ⟹ D ∈ baseClasses Bs›*) apply (induct rule: list.induct (*‹⟦?P []; ⋀x1 x2. ?P x2 ⟹ ?P (x1 # x2)⟧ ⟹ ?P ?list›*)) (*goals: 1. ‹⟦class P C = ⌊([], fs, ms)⌋; Shares D ∈ set []⟧ ⟹ D ∈ getbase ` set []› 2. ‹⋀x1 x2. ⟦⟦class P C = ⌊(x2, fs, ms)⌋; Shares D ∈ set x2⟧ ⟹ D ∈ getbase ` set x2; class P C = ⌊(x1 # x2, fs, ms)⌋; Shares D ∈ set (x1 # x2)⟧ ⟹ D ∈ getbase ` set (x1 # x2)› discuss goal 1*) apply ((auto simp:not_getbase_shares (*‹?D ∉ set (map getbase ?xs) ⟹ Shares ?D ∉ set ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp:not_getbase_shares (*‹(?D::char list) ∉ set (map getbase (?xs::base list)) ⟹ Shares ?D ∉ set ?xs›*))[1]) (*proven 2 subgoals*) . lemma base_repeats_or_shares: "⟦B ∈ set Bs; D = getbase B⟧ ⟹ Repeats D ∈ set Bs ∨ Shares D ∈ set Bs" apply (induct B rule:base.induct (*‹⟦⋀x. ?P (Repeats x); ⋀x. ?P (Shares x)⟧ ⟹ ?P ?base›*)) (*goals: 1. ‹⋀x. ⟦Repeats x ∈ set Bs; D = getbase (Repeats x)⟧ ⟹ Repeats D ∈ set Bs ∨ Shares D ∈ set Bs› 2. ‹⋀x. ⟦Shares x ∈ set Bs; D = getbase (Shares x)⟧ ⟹ Repeats D ∈ set Bs ∨ Shares D ∈ set Bs› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma baseClasses_repeats_or_shares: "D ∈ baseClasses Bs ⟹ Repeats D ∈ set Bs ∨ Shares D ∈ set Bs" by (auto elim!:bexE (*‹⟦∃x∈?A. ?P x; ⋀x. ⟦x ∈ ?A; ?P x⟧ ⟹ ?Q⟧ ⟹ ?Q›*) base_repeats_or_shares (*‹⟦?B ∈ set ?Bs; ?D = getbase ?B⟧ ⟹ Repeats ?D ∈ set ?Bs ∨ Shares ?D ∈ set ?Bs›*) simp add:baseClasses_def (*‹baseClasses ?Bs ≡ set (map getbase ?Bs)›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*)) lemma finite_is_class: "finite {C. is_class P C}" apply (unfold is_class_def (*‹is_class ?P ?C ≡ class ?P ?C ≠ None›*) class_def (*‹class ≡ map_of›*)) (*goal: ‹finite {C::char list. is_class (P::(char list × base list × (char list × ty) list × (char list × ty list × ty × char list list × expr) list) list) C}›*) apply (fold dom_def) (*goal: ‹finite {C::char list. map_of (P::(char list × base list × (char list × ty) list × (char list × ty list × ty × char list list × expr) list) list) C ≠ None}›*) by (rule finite_dom_map_of (*‹finite (dom (map_of ?l))›*)) lemma finite_baseClasses: "class P C = Some(Bs,fs,ms) ⟹ finite (baseClasses Bs)" apply (unfold is_class_def (*‹is_class (?P::(char list × base list × (char list × ty) list × (char list × ty list × ty × char list list × expr) list) list) (?C::char list) ≡ class ?P ?C ≠ None›*) class_def (*‹class ≡ map_of›*) baseClasses_def (*‹baseClasses (?Bs::base list) ≡ set (map getbase ?Bs)›*)) (*goal: ‹class P C = ⌊(Bs, fs, ms)⌋ ⟹ finite (baseClasses Bs)›*) by clarsimp definition is_type :: "prog ⇒ ty ⇒ bool" where "is_type P T ≡ (case T of Void ⇒ True | Boolean ⇒ True | Integer ⇒ True | NT ⇒ True | Class C ⇒ is_class P C)" lemma is_type_simps [simp]: "is_type P Void ∧ is_type P Boolean ∧ is_type P Integer ∧ is_type P NT ∧ is_type P (Class C) = is_class P C" by (simp add:is_type_def (*‹is_type ?P ?T ≡ case ?T of Class C ⇒ is_class ?P C | _ ⇒ True›*)) abbreviation "types P == Collect (CONST is_type P)" lemma typeof_lit_is_type: "typeof v = Some T ⟹ is_type P T" apply (induct v) (*goals: 1. ‹typeof Unit = ⌊T⌋ ⟹ is_type P T› 2. ‹typeof Null = ⌊T⌋ ⟹ is_type P T› 3. ‹⋀x. typeof (Bool x) = ⌊T⌋ ⟹ is_type P T› 4. ‹⋀x. typeof (Intg x) = ⌊T⌋ ⟹ is_type P T› 5. ‹⋀x. typeof (Ref x) = ⌊T⌋ ⟹ is_type P T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . end
{ "path": "afp-2025-02-12/thys/CoreC++/Decl.thy", "repo": "afp-2025-02-12", "sha": "644d391cbbf730bb8d8f37b73818b9d44de841ded1ce12fb4efde11b33d1afef" }
(* Copyright 2021 (C) Mihails Milehins *) section‹‹Hom›-functor› theory CZH_ECAT_Hom imports CZH_ECAT_Set CZH_ECAT_PCategory begin subsection‹‹hom›-function› text‹ The ‹hom›-function is a part of the definition of the ‹Hom›-functor, as presented in \<^cite>‹"noauthor_nlab_nodate"›\footnote{\url{ https://ncatlab.org/nlab/show/hom-functor }}. › definition cf_hom :: "V ⇒ V ⇒ V" where "cf_hom ℭ f = [ ( λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇vpfst f⦈) (ℭ⦇Dom⦈⦇vpsnd f⦈). vpsnd f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ vpfst f ), Hom ℭ (ℭ⦇Cod⦈⦇vpfst f⦈) (ℭ⦇Dom⦈⦇vpsnd f⦈), Hom ℭ (ℭ⦇Dom⦈⦇vpfst f⦈) (ℭ⦇Cod⦈⦇vpsnd f⦈) ]⇩∘" text‹Components.› lemma cf_hom_components: shows "cf_hom ℭ f⦇ArrVal⦈ = ( λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇vpfst f⦈) (ℭ⦇Dom⦈⦇vpsnd f⦈). vpsnd f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ vpfst f )" and "cf_hom ℭ f⦇ArrDom⦈ = Hom ℭ (ℭ⦇Cod⦈⦇vpfst f⦈) (ℭ⦇Dom⦈⦇vpsnd f⦈)" and "cf_hom ℭ f⦇ArrCod⦈ = Hom ℭ (ℭ⦇Dom⦈⦇vpfst f⦈) (ℭ⦇Cod⦈⦇vpsnd f⦈)" unfolding cf_hom_def arr_field_simps (*goals: 1. ‹[λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)]⇩∘⦇[]⇩∘⦈ = (λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈)› 2. ‹[λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)]⇩∘⦇1⇩ℕ⦈ = Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈)› 3. ‹[λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)]⇩∘⦇2⇩ℕ⦈ = Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)›*) (*goals: 1. ‹[λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)]⇩∘⦇[]⇩∘⦈ = (λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈)› 2. ‹[λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)]⇩∘⦇1⇩ℕ⦈ = Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈)› 3. ‹[λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈). f⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ f⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇f⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)]⇩∘⦇2⇩ℕ⦈ = Hom ℭ (ℭ⦇Dom⦈⦇f⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇f⦇1⇩ℕ⦈⦈)› discuss goal 1*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 2*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 3*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*proven 3 subgoals*) . subsubsection‹Arrow value› mk_VLambda cf_hom_components(1) |vsv cf_hom_ArrVal_vsv[cat_cs_intros]| lemma cf_hom_ArrVal_vdomain[cat_cs_simps]: assumes "g : a ↦⇘op_cat ℭ⇙ b" and "f : a' ↦⇘ℭ⇙ b'" shows "𝒟⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈) = Hom ℭ a a'" using assms (*‹g : a ↦⇘op_cat ℭ⇙ b› ‹f : a' ↦⇘ℭ⇙ b'›*) unfolding cf_hom_components (*goal: ‹𝒟⇩∘ (λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇[g, f]⇩∘⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇[g, f]⇩∘⦇1⇩ℕ⦈⦈). [g, f]⇩∘⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ [g, f]⇩∘⦇[]⇩∘⦈) = Hom ℭ a a'›*) by (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*) cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 38 facts*) cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 254 facts*)) lemma cf_hom_ArrVal_app[cat_cs_simps]: assumes "g : c ↦⇘op_cat ℭ⇙ d" and "q : c ↦⇘ℭ⇙ c'" and "f : c' ↦⇘ℭ⇙ d'" shows "cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈⦇q⦈ = f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ g" using assms (*‹(g::V) : (c::V) ↦⇘op_cat (ℭ::V)⇙ (d::V)› ‹q : c ↦⇘ℭ⇙ c'› ‹f : c' ↦⇘ℭ⇙ d'›*) unfolding cf_hom_components (*goal: ‹(λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇[g, f]⇩∘⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇[g, f]⇩∘⦇1⇩ℕ⦈⦈). [g, f]⇩∘⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ [g, f]⇩∘⦇[]⇩∘⦈)⦇q⦈ = f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ g›*) by (simp add: nat_omega_simps (*‹(?a::nat)⇩ℕ + (?b::nat)⇩ℕ = (?a + ?b)⇩ℕ› ‹(?a::nat)⇩ℕ * (?b::nat)⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ ((?a::nat)⇩ℕ) = Suc ?a⇩ℕ› ‹(?m::nat)⇩ℕ ⊕ (?n::nat)⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc ((?a::nat)⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = (1::nat)⇩ℕ› ‹(1::V) = (1::nat)⇩ℕ›*) cat_op_simps (*‹op_cat (?ℭ::V)⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat (?ℭ::V)⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat (?ℭ::V)⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat (?ℭ::V)⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat (?ℭ::V)⦇CId⦈ = ?ℭ⦇CId⦈› ‹(?f::V) : (?b::V) ↦⇘op_cat (?ℭ::V)⇙ (?a::V) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat (?ℭ::V)) (?a::V) (?b::V) = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat (?ℭ::V)) (?a::V) = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat (?ℭ::V)) (?a::V) = obj_initial ?ℭ ?a› ‹obj_null (op_cat (?ℭ::V)) (?a::V) = obj_null ?ℭ ?a› ‹category (?α::V) (?ℭ::V) ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?g::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 38 facts*) cat_cs_simps (*‹category (?α::V) (?ℭ::V) ⟹ vcard ?ℭ = (6::nat)⇩ℕ› ‹category (?α::V) (?ℭ::V) ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V)⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹(?f::V) : ↦⇩i⇩d⇩e⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category (?α::V) (?ℭ::V); (?h::V) : (?c::V) ↦⇘?ℭ⇙ (?d::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ ?c; (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V)⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 255 facts*)) lemma (in category) cf_hom_ArrVal_vrange: assumes "g : a ↦⇘op_cat ℭ⇙ b" and "f : a' ↦⇘ℭ⇙ b'" shows "ℛ⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈) ⊆⇩∘ Hom ℭ b b'" proof (intro vsubsetI (*‹(⋀x. x ∈⇩∘ ?A ⟹ x ∈⇩∘ ?B) ⟹ ?A ⊆⇩∘ ?B›*)) (*goal: ‹⋀x. x ∈⇩∘ ℛ⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈) ⟹ x ∈⇩∘ Hom ℭ b b'›*) interpret gf: vsv "cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈" unfolding cf_hom_components (*goal: ‹vsv (λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇[g, f]⇩∘⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇[g, f]⇩∘⦇1⇩ℕ⦈⦈). [g, f]⇩∘⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ [g, f]⇩∘⦇[]⇩∘⦈)›*) by auto fix y assume "y ∈⇩∘ ℛ⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈)" (*‹(y::V) ∈⇩∘ ℛ⇩∘ (cf_hom (ℭ::V) [g::V, f::V]⇩∘⦇ArrVal⦈)›*) then obtain q where y_def: "y = cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈⦇q⦈" and "q ∈⇩∘ 𝒟⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈)" (*goal: ‹(⋀q. ⟦y = cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈⦇q⦈; q ∈⇩∘ 𝒟⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈)⟧ ⟹ thesis) ⟹ thesis›*) by (metis gf.vrange_atD (*‹?b ∈⇩∘ ℛ⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈) ⟹ ∃a∈elts (𝒟⇩∘ (cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈)). cf_hom ℭ [g, f]⇩∘⦇ArrVal⦈⦇a⦈ = ?b›*)) then have q: "q : a ↦⇘ℭ⇙ a'" unfolding cf_hom_ArrVal_vdomain[OF assms] (*goal: ‹q : a ↦⇘ℭ⇙ a'›*) by simp from assms (*‹g : a ↦⇘op_cat ℭ⇙ b› ‹f : a' ↦⇘ℭ⇙ b'›*) q (*‹q : a ↦⇘ℭ⇙ a'›*) show "y ∈⇩∘ Hom ℭ b b'" unfolding y_def cf_hom_ArrVal_app[OF assms ( 1 ) q assms ( 2 )] cat_op_simps (*goal: ‹f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ g ∈⇩∘ Hom ℭ b b'›*) by (auto intro: cat_cs_intros (*‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) = ?a; (?c::V) = ?a; (?ℭ'::V) = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?f::V) = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ (?g'::V) ?g; is_inverse ?ℭ (?f'::V) ?f; (?f'g'::V) = ?f' ∘⇩A⇘?ℭ⇙ ?g'; (?gf::V) = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V); (?ℭ'::V) = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*)) qed subsubsection‹Arrow domain› lemma (in category) cf_hom_ArrDom: assumes "gf : [c, c']⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ dd'" shows "cf_hom ℭ gf⦇ArrDom⦈ = Hom ℭ c c'" proof (-) (*goal: ‹cf_hom ℭ gf⦇ArrDom⦈ = Hom ℭ c c'›*) from assms (*‹gf : [c, c']⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ dd'›*) obtain g and f and d and d' where "gf = [g, f]⇩∘" and "g : c ↦⇘op_cat ℭ⇙ d" and "f : c' ↦⇘ℭ⇙ d'" (*goal: ‹(⋀g f d d'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ thesis›*) unfolding cf_hom_components (*goal: ‹(⋀g f d d'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ thesis›*) apply (elim cat_prod_2_is_arrE[rotated 2] (*‹⟦?gf : ?ab ↦⇘?𝔄 ×⇩C ?𝔅⇙ ?cd; ⋀g f a b c d. ⟦?gf = [g, f]⇩∘; ?ab = [a, b]⇩∘; ?cd = [c, d]⇩∘; g : a ↦⇘?𝔄⇙ c; f : b ↦⇘?𝔅⇙ d⟧ ⟹ ?thesis; category ?α ?𝔄; category ?α ?𝔅⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀(g::V) (f::V) (a::V) (b::V) (ca::V) d::V. ⟦⋀(g::V) (f::V) (d::V) d'::V. ⟦(gf::V) = [g, f]⇩∘; g : (c::V) ↦⇘op_cat (ℭ::V)⇙ d; f : (c'::V) ↦⇘ℭ⇙ d'⟧ ⟹ thesis::bool; gf = [g, f]⇩∘; [c, c']⇩∘ = [a, b]⇩∘; (dd'::V) = [ca, d]⇩∘; g : a ↦⇘op_cat ℭ⇙ ca; f : b ↦⇘ℭ⇙ d⟧ ⟹ thesis› 2. ‹(⋀(g::V) (f::V) (d::V) d'::V. ⟦(gf::V) = [g, f]⇩∘; g : (c::V) ↦⇘op_cat (ℭ::V)⇙ d; f : (c'::V) ↦⇘ℭ⇙ d'⟧ ⟹ thesis::bool) ⟹ category (?α3::V) (op_cat ℭ)› 3. ‹(⋀(g::V) (f::V) (d::V) d'::V. ⟦(gf::V) = [g, f]⇩∘; g : (c::V) ↦⇘op_cat (ℭ::V)⇙ d; f : (c'::V) ↦⇘ℭ⇙ d'⟧ ⟹ thesis::bool) ⟹ category (?α3::V) ℭ› discuss goal 1*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*discuss goal 2*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*discuss goal 3*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹cf_hom ℭ gf⦇ArrDom⦈ = Hom ℭ c c'›*) unfolding cf_hom_components (*goal: ‹Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈) = Hom ℭ c c'›*) by (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*) cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 50 facts*) cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 264 facts*)) qed lemmas [cat_cs_simps] = category.cf_hom_ArrDom subsubsection‹Arrow codomain› lemma (in category) cf_hom_ArrCod: assumes "gf : cc' ↦⇘op_cat ℭ ×⇩C ℭ⇙ [d, d']⇩∘" shows "cf_hom ℭ gf⦇ArrCod⦈ = Hom ℭ d d'" proof (-) (*goal: ‹cf_hom ℭ gf⦇ArrCod⦈ = Hom ℭ d d'›*) from assms (*‹gf : cc' ↦⇘op_cat ℭ ×⇩C ℭ⇙ [d, d']⇩∘›*) obtain g and f and c and c' where "gf = [g, f]⇩∘" and "g : c ↦⇘op_cat ℭ⇙ d" and "f : c' ↦⇘ℭ⇙ d'" (*goal: ‹(⋀g f c c'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ thesis›*) unfolding cf_hom_components (*goal: ‹(⋀g f c c'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ thesis›*) apply (elim cat_prod_2_is_arrE[rotated 2] (*‹⟦?gf : ?ab ↦⇘?𝔄 ×⇩C ?𝔅⇙ ?cd; ⋀g f a b c d. ⟦?gf = [g, f]⇩∘; ?ab = [a, b]⇩∘; ?cd = [c, d]⇩∘; g : a ↦⇘?𝔄⇙ c; f : b ↦⇘?𝔅⇙ d⟧ ⟹ ?thesis; category ?α ?𝔄; category ?α ?𝔅⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀g f a b c da. ⟦⋀g f c c'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis; gf = [g, f]⇩∘; cc' = [a, b]⇩∘; [d, d']⇩∘ = [c, da]⇩∘; g : a ↦⇘op_cat ℭ⇙ c; f : b ↦⇘ℭ⇙ da⟧ ⟹ thesis› 2. ‹(⋀g f c c'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ category ?α3 (op_cat ℭ)› 3. ‹(⋀g f c c'. ⟦gf = [g, f]⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ category ?α3 ℭ› discuss goal 1*) apply ((auto intro: cat_cs_intros (*‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) = ?a; (?c::V) = ?a; (?ℭ'::V) = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?f::V) = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ (?g'::V) ?g; is_inverse ?ℭ (?f'::V) ?f; (?f'g'::V) = ?f' ∘⇩A⇘?ℭ⇙ ?g'; (?gf::V) = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V); (?ℭ'::V) = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*discuss goal 2*) apply ((auto intro: cat_cs_intros (*‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) = ?a; (?c::V) = ?a; (?ℭ'::V) = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?f::V) = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ (?g'::V) ?g; is_inverse ?ℭ (?f'::V) ?f; (?f'g'::V) = ?f' ∘⇩A⇘?ℭ⇙ ?g'; (?gf::V) = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V); (?ℭ'::V) = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*discuss goal 3*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹cf_hom ℭ gf⦇ArrCod⦈ = Hom ℭ d d'›*) unfolding cf_hom_components (*goal: ‹Hom ℭ (ℭ⦇Dom⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇gf⦇1⇩ℕ⦈⦈) = Hom ℭ d d'›*) by (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*) cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 50 facts*) cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 265 facts*)) qed lemmas [cat_cs_simps] = category.cf_hom_ArrCod subsubsection‹‹hom›-function is an arrow in the category ‹Set›› lemma (in category) cat_cf_hom_ArrRel: assumes "gf : cc' ↦⇘op_cat ℭ ×⇩C ℭ⇙ dd'" shows "arr_Set α (cf_hom ℭ gf)" proof (intro arr_SetI (*‹⟦𝒵 ?α; vfsequence ?T; vsv (?T⦇ArrVal⦈); vcard ?T = 3⇩ℕ; 𝒟⇩∘ (?T⦇ArrVal⦈) = ?T⦇ArrDom⦈; ℛ⇩∘ (?T⦇ArrVal⦈) ⊆⇩∘ ?T⦇ArrCod⦈; ?T⦇ArrDom⦈ ∈⇩∘ Vset ?α; ?T⦇ArrCod⦈ ∈⇩∘ Vset ?α⟧ ⟹ arr_Set ?α ?T›*)) (*goals: 1. ‹𝒵 α› 2. ‹vfsequence (cf_hom ℭ gf)› 3. ‹vsv (cf_hom ℭ gf⦇ArrVal⦈)› 4. ‹vcard (cf_hom ℭ gf) = 3⇩ℕ› 5. ‹𝒟⇩∘ (cf_hom ℭ gf⦇ArrVal⦈) = cf_hom ℭ gf⦇ArrDom⦈› 6. ‹ℛ⇩∘ (cf_hom ℭ gf⦇ArrVal⦈) ⊆⇩∘ cf_hom ℭ gf⦇ArrCod⦈› 7. ‹cf_hom ℭ gf⦇ArrDom⦈ ∈⇩∘ Vset α› 8. ‹cf_hom ℭ gf⦇ArrCod⦈ ∈⇩∘ Vset α›*) from assms (*‹gf : cc' ↦⇘op_cat ℭ ×⇩C ℭ⇙ dd'›*) obtain g and f and c and c' and d and d' where gf_def: "gf = [g, f]⇩∘" and cc'_def: "cc' = [c, c']⇩∘" and dd'_def: "dd' = [d, d']⇩∘" and op_g: "g : c ↦⇘op_cat ℭ⇙ d" and f: "f : c' ↦⇘ℭ⇙ d'" (*goal: ‹(⋀g f c c' d d'. ⟦gf = [g, f]⇩∘; cc' = [c, c']⇩∘; dd' = [d, d']⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ thesis›*) unfolding cf_hom_components (*goal: ‹(⋀g f c c' d d'. ⟦gf = [g, f]⇩∘; cc' = [c, c']⇩∘; dd' = [d, d']⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ thesis›*) apply (elim cat_prod_2_is_arrE[rotated 2] (*‹⟦?gf : ?ab ↦⇘?𝔄 ×⇩C ?𝔅⇙ ?cd; ⋀g f a b c d. ⟦?gf = [g, f]⇩∘; ?ab = [a, b]⇩∘; ?cd = [c, d]⇩∘; g : a ↦⇘?𝔄⇙ c; f : b ↦⇘?𝔅⇙ d⟧ ⟹ ?thesis; category ?α ?𝔄; category ?α ?𝔅⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀g f a b c d. ⟦⋀g f c c' d d'. ⟦gf = [g, f]⇩∘; cc' = [c, c']⇩∘; dd' = [d, d']⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis; gf = [g, f]⇩∘; cc' = [a, b]⇩∘; dd' = [c, d]⇩∘; g : a ↦⇘op_cat ℭ⇙ c; f : b ↦⇘ℭ⇙ d⟧ ⟹ thesis› 2. ‹(⋀g f c c' d d'. ⟦gf = [g, f]⇩∘; cc' = [c, c']⇩∘; dd' = [d, d']⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ category ?α3 (op_cat ℭ)› 3. ‹(⋀g f c c' d d'. ⟦gf = [g, f]⇩∘; cc' = [c, c']⇩∘; dd' = [d, d']⇩∘; g : c ↦⇘op_cat ℭ⇙ d; f : c' ↦⇘ℭ⇙ d'⟧ ⟹ thesis) ⟹ category ?α3 ℭ› discuss goal 1*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*discuss goal 2*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*discuss goal 3*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*))[1]) (*proven 3 subgoals*) . from op_g (*‹g : c ↦⇘op_cat ℭ⇙ d›*) have g: "g : d ↦⇘ℭ⇙ c" unfolding cat_op_simps (*goal: ‹g : d ↦⇘ℭ⇙ c›*) by simp then have [simp]: "ℭ⦇Dom⦈⦇g⦈ = d" "ℭ⦇Cod⦈⦇g⦈ = c" and d: "d ∈⇩∘ ℭ⦇Obj⦈" and c: "c ∈⇩∘ ℭ⦇Obj⦈" apply - (*goals: 1. ‹(g::V) : (d::V) ↦⇘ℭ::V⇙ (c::V) ⟹ ℭ⦇Dom⦈⦇g⦈ = d› 2. ‹(g::V) : (d::V) ↦⇘ℭ::V⇙ (c::V) ⟹ ℭ⦇Cod⦈⦇g⦈ = c› 3. ‹(g::V) : (d::V) ↦⇘ℭ::V⇙ (c::V) ⟹ d ∈⇩∘ ℭ⦇Obj⦈› 4. ‹(g::V) : (d::V) ↦⇘ℭ::V⇙ (c::V) ⟹ c ∈⇩∘ ℭ⦇Obj⦈› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . from f (*‹f : c' ↦⇘ℭ⇙ d'›*) have [simp]: "ℭ⦇Dom⦈⦇f⦈ = c'" "ℭ⦇Cod⦈⦇f⦈ = d'" and c': "c' ∈⇩∘ ℭ⦇Obj⦈" and d': "d' ∈⇩∘ ℭ⦇Obj⦈" apply - (*goals: 1. ‹(f::V) : (c'::V) ↦⇘ℭ::V⇙ (d'::V) ⟹ ℭ⦇Dom⦈⦇f⦈ = c'› 2. ‹(f::V) : (c'::V) ↦⇘ℭ::V⇙ (d'::V) ⟹ ℭ⦇Cod⦈⦇f⦈ = d'› 3. ‹(f::V) : (c'::V) ↦⇘ℭ::V⇙ (d'::V) ⟹ c' ∈⇩∘ ℭ⦇Obj⦈› 4. ‹(f::V) : (c'::V) ↦⇘ℭ::V⇙ (d'::V) ⟹ d' ∈⇩∘ ℭ⦇Obj⦈› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . show "vfsequence (cf_hom ℭ gf)" unfolding cf_hom_def (*goal: ‹vfsequence [λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈). gf⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ gf⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇gf⦇1⇩ℕ⦈⦈)]⇩∘›*) by simp show vsv_hom_fg: "vsv (cf_hom ℭ gf⦇ArrVal⦈)" unfolding cf_hom_components (*goal: ‹vsv (λq::V∈⇩∘Hom (ℭ::V) (ℭ⦇Cod⦈⦇(gf::V)⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇(1::nat)⇩ℕ⦈⦈). gf⦇(1::nat)⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ gf⦇[]⇩∘⦈)›*) by auto show "vcard (cf_hom ℭ gf) = 3⇩ℕ" unfolding cf_hom_def (*goal: ‹vcard [λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈). gf⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ gf⦇[]⇩∘⦈, Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈), Hom ℭ (ℭ⦇Dom⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇gf⦇1⇩ℕ⦈⦈)]⇩∘ = 3⇩ℕ›*) by (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) show [simp]: "𝒟⇩∘ (cf_hom ℭ gf⦇ArrVal⦈) = cf_hom ℭ gf⦇ArrDom⦈" unfolding cf_hom_components (*goal: ‹𝒟⇩∘ (λq∈⇩∘Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈). gf⦇1⇩ℕ⦈ ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ gf⦇[]⇩∘⦈) = Hom ℭ (ℭ⦇Cod⦈⦇gf⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇gf⦇1⇩ℕ⦈⦈)›*) by auto show "ℛ⇩∘ (cf_hom ℭ gf⦇ArrVal⦈) ⊆⇩∘ cf_hom ℭ gf⦇ArrCod⦈" proof (rule vsubsetI (*‹(⋀x. x ∈⇩∘ ?A ⟹ x ∈⇩∘ ?B) ⟹ ?A ⊆⇩∘ ?B›*)) (*goal: ‹⋀x. x ∈⇩∘ ℛ⇩∘ (cf_hom ℭ gf⦇ArrVal⦈) ⟹ x ∈⇩∘ cf_hom ℭ gf⦇ArrCod⦈›*) interpret hom_fg: vsv "cf_hom ℭ gf⦇ArrVal⦈" by (simp add: vsv_hom_fg (*‹vsv (cf_hom (ℭ::V) (gf::V)⦇ArrVal⦈)›*)) fix y assume "y ∈⇩∘ ℛ⇩∘ (cf_hom ℭ gf⦇ArrVal⦈)" (*‹(y::V) ∈⇩∘ ℛ⇩∘ (cf_hom (ℭ::V) (gf::V)⦇ArrVal⦈)›*) then obtain q where y_def: "y = cf_hom ℭ gf⦇ArrVal⦈⦇q⦈" and q: "q ∈⇩∘ 𝒟⇩∘ (cf_hom ℭ gf⦇ArrVal⦈)" (*goal: ‹(⋀q. ⟦y = cf_hom ℭ gf⦇ArrVal⦈⦇q⦈; q ∈⇩∘ 𝒟⇩∘ (cf_hom ℭ gf⦇ArrVal⦈)⟧ ⟹ thesis) ⟹ thesis›*) by (blast dest: hom_fg.vrange_atD (*‹?b ∈⇩∘ ℛ⇩∘ (cf_hom ℭ gf⦇ArrVal⦈) ⟹ ∃a∈elts (𝒟⇩∘ (cf_hom ℭ gf⦇ArrVal⦈)). cf_hom ℭ gf⦇ArrVal⦈⦇a⦈ = ?b›*)) from q (*‹q ∈⇩∘ 𝒟⇩∘ (cf_hom ℭ gf⦇ArrVal⦈)›*) have q: "q : c ↦⇘ℭ⇙ c'" by (simp add: cf_hom_ArrDom[OF assms[unfolded cc'_def]] (*‹cf_hom ℭ gf⦇ArrDom⦈ = Hom ℭ c c'›*)) with g (*‹g : d ↦⇘ℭ⇙ c›*) f (*‹f : c' ↦⇘ℭ⇙ d'›*) have "f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ g : d ↦⇘ℭ⇙ d'" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*)) then show "y ∈⇩∘ cf_hom ℭ gf⦇ArrCod⦈" unfolding cf_hom_ArrCod[OF assms [ unfolded dd'_def ]] (*goal: ‹y ∈⇩∘ Hom ℭ d d'›*) unfolding y_def gf_def cf_hom_ArrVal_app[OF op_g q f] (*goal: ‹f ∘⇩A⇘ℭ⇙ q ∘⇩A⇘ℭ⇙ g ∈⇩∘ Hom ℭ d d'›*) by auto qed from c (*‹c ∈⇩∘ ℭ⦇Obj⦈›*) c' (*‹c' ∈⇩∘ ℭ⦇Obj⦈›*) show "cf_hom ℭ gf⦇ArrDom⦈ ∈⇩∘ Vset α" unfolding cf_hom_components gf_def (*goal: ‹Hom (ℭ::V) (ℭ⦇Cod⦈⦇[g::V, f::V]⇩∘⦇[]⇩∘⦈⦈) (ℭ⦇Dom⦈⦇[g, f]⇩∘⦇(1::nat)⇩ℕ⦈⦈) ∈⇩∘ Vset (α::V)›*) by (auto simp: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*) intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*)) from d (*‹d ∈⇩∘ ℭ⦇Obj⦈›*) d' (*‹(d'::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) show "cf_hom ℭ gf⦇ArrCod⦈ ∈⇩∘ Vset α" unfolding cf_hom_components gf_def (*goal: ‹Hom (ℭ::V) (ℭ⦇Dom⦈⦇[g::V, f::V]⇩∘⦇[]⇩∘⦈⦈) (ℭ⦇Cod⦈⦇[g, f]⇩∘⦇(1::nat)⇩ℕ⦈⦈) ∈⇩∘ Vset (α::V)›*) by (auto simp: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*) intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 118 facts*)) qed (auto) (*solved the remaining goal: ‹𝒵 α›*) lemmas [cat_cs_intros] = category.cat_cf_hom_ArrRel lemma (in category) cat_cf_hom_cat_Set_is_arr: assumes "gf : [a, b]⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ [c, d]⇩∘" shows "cf_hom ℭ gf : Hom ℭ a b ↦⇘cat_Set α⇙ Hom ℭ c d" proof (intro is_arrI (*‹⟦?f ∈⇩∘ ?ℭ⦇Arr⦈; ?ℭ⦇Dom⦈⦇?f⦈ = ?a; ?ℭ⦇Cod⦈⦇?f⦈ = ?b⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?b›*)) (*goals: 1. ‹cf_hom ℭ gf ∈⇩∘ cat_Set α⦇Arr⦈› 2. ‹cat_Set α⦇Dom⦈⦇cf_hom ℭ gf⦈ = Hom ℭ a b› 3. ‹cat_Set α⦇Cod⦈⦇cf_hom ℭ gf⦈ = Hom ℭ c d›*) from assms (*‹(gf::V) : [a::V, b::V]⇩∘ ↦⇘op_cat (ℭ::V) ×⇩C ℭ⇙ [c::V, d::V]⇩∘›*) cat_cf_hom_ArrRel (*‹?gf : ?cc' ↦⇘op_cat ℭ ×⇩C ℭ⇙ ?dd' ⟹ arr_Set α (cf_hom ℭ ?gf)›*) show "cf_hom ℭ gf ∈⇩∘ cat_Set α⦇Arr⦈" unfolding cat_Set_components (*goal: ‹cf_hom ℭ gf ∈⇩∘ ZFC_in_HOL.set (Collect (arr_Set α))›*) by auto with assms (*‹(gf::V) : [a::V, b::V]⇩∘ ↦⇘op_cat (ℭ::V) ×⇩C ℭ⇙ [c::V, d::V]⇩∘›*) show "cat_Set α⦇Dom⦈⦇cf_hom ℭ gf⦈ = Hom ℭ a b" "cat_Set α⦇Cod⦈⦇cf_hom ℭ gf⦈ = Hom ℭ c d" unfolding cat_Set_components (*goals: 1. ‹(λT∈⇩∘ZFC_in_HOL.set (Collect (arr_Set α)). T⦇ArrDom⦈)⦇cf_hom ℭ gf⦈ = Hom ℭ a b› 2. ‹(λT∈⇩∘ZFC_in_HOL.set (Collect (arr_Set α)). T⦇ArrCod⦈)⦇cf_hom ℭ gf⦈ = Hom ℭ c d›*) apply - (*goals: 1. ‹⟦gf : [a, b]⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ [c, d]⇩∘; cf_hom ℭ gf ∈⇩∘ ZFC_in_HOL.set (Collect (arr_Set α))⟧ ⟹ (λT∈⇩∘ZFC_in_HOL.set (Collect (arr_Set α)). T⦇ArrDom⦈)⦇cf_hom ℭ gf⦈ = Hom ℭ a b› 2. ‹⟦gf : [a, b]⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ [c, d]⇩∘; cf_hom ℭ gf ∈⇩∘ ZFC_in_HOL.set (Collect (arr_Set α))⟧ ⟹ (λT∈⇩∘ZFC_in_HOL.set (Collect (arr_Set α)). T⦇ArrCod⦈)⦇cf_hom ℭ gf⦈ = Hom ℭ c d› discuss goal 1*) apply (simp add: cf_hom_ArrDom[OF assms] (*‹cf_hom ℭ gf⦇ArrDom⦈ = Hom ℭ a b›*) cf_hom_ArrCod[OF assms] (*‹cf_hom ℭ gf⦇ArrCod⦈ = Hom ℭ c d›*)) (*discuss goal 2*) apply (simp add: cf_hom_ArrDom[OF assms] (*‹cf_hom (ℭ::V) (gf::V)⦇ArrDom⦈ = Hom ℭ (a::V) (b::V)›*) cf_hom_ArrCod[OF assms] (*‹cf_hom (ℭ::V) (gf::V)⦇ArrCod⦈ = Hom ℭ (c::V) (d::V)›*)) (*proven 2 subgoals*) . qed lemma (in category) cat_cf_hom_cat_Set_is_arr': assumes "gf : [a, b]⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ [c, d]⇩∘" and "𝔄' = Hom ℭ a b" and "𝔅' = Hom ℭ c d" and "ℭ' = cat_Set α" shows "cf_hom ℭ gf : 𝔄' ↦⇘ℭ'⇙ 𝔅'" using assms(1) (*‹gf : [a, b]⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ [c, d]⇩∘›*) unfolding assms(2-4) (*goal: ‹cf_hom ℭ gf : Hom ℭ a b ↦⇘cat_Set α⇙ Hom ℭ c d›*) by (rule cat_cf_hom_cat_Set_is_arr (*‹?gf : [?a, ?b]⇩∘ ↦⇘op_cat ℭ ×⇩C ℭ⇙ [?c, ?d]⇩∘ ⟹ cf_hom ℭ ?gf : Hom ℭ ?a ?b ↦⇘cat_Set α⇙ Hom ℭ ?c ?d›*)) lemmas [cat_cs_intros] = category.cat_cf_hom_cat_Set_is_arr' subsubsection‹Composition› lemma (in category) cat_cf_hom_Comp: assumes "g : b ↦⇘op_cat ℭ⇙ c" and "g' : b' ↦⇘ℭ⇙ c'" and "f : a ↦⇘op_cat ℭ⇙ b" and "f' : a' ↦⇘ℭ⇙ b'" shows "cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘" proof (-) (*goal: ‹cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘›*) interpret Set: category "α" "cat_Set α" by (rule category_cat_Set (*‹category (α::V) (cat_Set α)›*)) from assms(1,3) (*‹(g::V) : (b::V) ↦⇘op_cat (ℭ::V)⇙ (c::V)› ‹f : a ↦⇘op_cat ℭ⇙ b›*) have g: "g : c ↦⇘ℭ⇙ b" and f: "f : b ↦⇘ℭ⇙ a" unfolding cat_op_simps (*goals: 1. ‹g : c ↦⇘ℭ⇙ b› 2. ‹f : b ↦⇘ℭ⇙ a›*) apply - (*goals: 1. ‹⟦g : c ↦⇘ℭ⇙ b; f : b ↦⇘ℭ⇙ a⟧ ⟹ g : c ↦⇘ℭ⇙ b› 2. ‹⟦g : c ↦⇘ℭ⇙ b; f : b ↦⇘ℭ⇙ a⟧ ⟹ f : b ↦⇘ℭ⇙ a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . from assms(2,4) (*‹g' : b' ↦⇘ℭ⇙ c'› ‹f' : a' ↦⇘ℭ⇙ b'›*) g (*‹g : c ↦⇘ℭ⇙ b›*) f (*‹f : b ↦⇘ℭ⇙ a›*) Set.category_axioms (*‹category α (cat_Set α)›*) category_axioms (*‹category α ℭ›*) have gg'_ff': "cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘ : Hom ℭ a a' ↦⇘cat_Set α⇙ Hom ℭ c c'" by (cs_concl cs_shallow cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) then have dom_lhs: "𝒟⇩∘ ((cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrVal⦈) = Hom ℭ a a'" by (cs_concl cs_shallow cs_simp: cat_cs_simps) from assms(2,4) (*‹g' : b' ↦⇘ℭ⇙ c'› ‹f' : a' ↦⇘ℭ⇙ b'›*) g (*‹g : c ↦⇘ℭ⇙ b›*) f (*‹f : b ↦⇘ℭ⇙ a›*) Set.category_axioms (*‹category α (cat_Set α)›*) category_axioms (*‹category (α::V) (ℭ::V)›*) have gf_g'f': "cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘ : Hom ℭ a a' ↦⇘cat_Set α⇙ Hom ℭ c c'" by (cs_concl cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) then have dom_rhs: "𝒟⇩∘ (cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈) = Hom ℭ a a'" by (cs_concl cs_simp: cat_cs_simps) show "?thesis" (*goal: ‹cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘›*) proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α (cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)› 2. ‹arr_Set α (cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘)› 3. ‹(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrVal⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈› 4. ‹(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrDom⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrDom⦈› 5. ‹(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrCod⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrCod⦈›*) from gg'_ff' (*‹cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘ : Hom ℭ a a' ↦⇘cat_Set α⇙ Hom ℭ c c'›*) show arr_Set_gg'_ff': "arr_Set α (cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)" by (auto dest: cat_Set_is_arrD( (*‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ arr_Set ?α ?S›*) 1)) from gf_g'f' (*‹cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘ : Hom ℭ a a' ↦⇘cat_Set α⇙ Hom ℭ c c'›*) show arr_Set_gf_g'f': "arr_Set α (cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘)" by (auto dest: cat_Set_is_arrD( (*‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ arr_Set ?α ?S›*) 1)) show "(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrVal⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ ((cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrVal⦈) = Hom ℭ a a'›*) dom_rhs (*‹𝒟⇩∘ (cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈) = Hom ℭ a a'›*)) (*goals: 1. ‹vsv ((cf_hom (ℭ::V) [g::V, g'::V]⇩∘ ∘⇩A⇘cat_Set (α::V)⇙ cf_hom ℭ [f::V, f'::V]⇩∘)⦇ArrVal⦈)› 2. ‹vsv (cf_hom (ℭ::V) [(g::V) ∘⇩A⇘op_cat ℭ⇙ (f::V), (g'::V) ∘⇩A⇘ℭ⇙ (f'::V)]⇩∘⦇ArrVal⦈)› 3. ‹Hom (ℭ::V) (a::V) (a'::V) = Hom ℭ a a'› 4. ‹⋀aa::V. aa ∈⇩∘ Hom (ℭ::V) (a::V) (a'::V) ⟹ (cf_hom ℭ [g::V, g'::V]⇩∘ ∘⇩A⇘cat_Set (α::V)⇙ cf_hom ℭ [f::V, f'::V]⇩∘)⦇ArrVal⦈⦇aa⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈⦇aa⦈›*) fix q assume "q ∈⇩∘ Hom ℭ a a'" (*‹(q::V) ∈⇩∘ Hom (ℭ::V) (a::V) (a'::V)›*) then have q: "q : a ↦⇘ℭ⇙ a'" by auto from category_axioms (*‹category α ℭ›*) g (*‹g : c ↦⇘ℭ⇙ b›*) f (*‹(f::V) : (b::V) ↦⇘ℭ::V⇙ (a::V)›*) assms(2,4) (*‹(g'::V) : (b'::V) ↦⇘ℭ::V⇙ (c'::V)› ‹f' : a' ↦⇘ℭ⇙ b'›*) q (*‹(q::V) : (a::V) ↦⇘ℭ::V⇙ (a'::V)›*) Set.category_axioms (*‹category α (cat_Set α)›*) show "(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrVal⦈⦇q⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈⦇q⦈" by (cs_concl cs_intro: cat_op_intros cat_cs_intros cat_prod_cs_intros cs_simp: cat_op_simps cat_cs_simps) qed (use arr_Set_gg'_ff' arr_Set_gf_g'f' in auto) (*solves the remaining goals: 1. ‹vsv ((cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrVal⦈)› 2. ‹vsv (cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrVal⦈)› 3. ‹Hom ℭ a a' = Hom ℭ a a'›*) qed ((use gg'_ff' gf_g'f' in ‹cs_concl cs_simp: cat_cs_simps›)+) (*solves the remaining goals: 1. ‹(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrDom⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrDom⦈› 2. ‹(cf_hom ℭ [g, g']⇩∘ ∘⇩A⇘cat_Set α⇙ cf_hom ℭ [f, f']⇩∘)⦇ArrCod⦈ = cf_hom ℭ [g ∘⇩A⇘op_cat ℭ⇙ f, g' ∘⇩A⇘ℭ⇙ f']⇩∘⦇ArrCod⦈›*) qed lemmas [cat_cs_simps] = category.cat_cf_hom_Comp subsubsection‹Identity› lemma (in category) cat_cf_hom_CId: assumes "[c, c']⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" shows "cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈" proof (-) (*goal: ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈›*) interpret Set: category "α" "cat_Set α" by (rule category_cat_Set (*‹category α (cat_Set α)›*)) interpret op_ℭ: category "α" "op_cat ℭ" by (rule category_op (*‹category (α::V) (op_cat (ℭ::V))›*)) from assms (*‹[c, c']⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈›*) have op_c: "c ∈⇩∘ op_cat ℭ⦇Obj⦈" and c': "c' ∈⇩∘ ℭ⦇Obj⦈" apply - (*goals: 1. ‹[c, c']⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈ ⟹ c ∈⇩∘ op_cat ℭ⦇Obj⦈› 2. ‹[c, c']⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈ ⟹ c' ∈⇩∘ ℭ⦇Obj⦈› discuss goal 1*) apply ((auto elim: cat_prod_2_ObjE[rotated 2] (*‹⟦?ab ∈⇩∘ (?𝔄 ×⇩C ?𝔅)⦇Obj⦈; ⋀a b. ⟦?ab = [a, b]⇩∘; a ∈⇩∘ ?𝔄⦇Obj⦈; b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ ?thesis; category ?α ?𝔄; category ?α ?𝔅⟧ ⟹ ?thesis›*) intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 150 facts*))[1]) (*discuss goal 2*) apply ((auto elim: cat_prod_2_ObjE[rotated 2] (*‹⟦?ab ∈⇩∘ (?𝔄 ×⇩C ?𝔅)⦇Obj⦈; ⋀a b. ⟦?ab = [a, b]⇩∘; a ∈⇩∘ ?𝔄⦇Obj⦈; b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ ?thesis; category ?α ?𝔄; category ?α ?𝔅⟧ ⟹ ?thesis›*) intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 150 facts*))[1]) (*proven 2 subgoals*) . then have c: "c ∈⇩∘ ℭ⦇Obj⦈" unfolding cat_op_simps (*goal: ‹c ∈⇩∘ ℭ⦇Obj⦈›*) by simp from c (*‹(c::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) c' (*‹c' ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) Set.category_axioms (*‹category α (cat_Set α)›*) have cf_hom_cc': "cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘ : Hom ℭ c c' ↦⇘cat_Set α⇙ Hom ℭ c c'" by (cs_concl cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) then have dom_lhs: "𝒟⇩∘ (cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrVal⦈) = Hom ℭ c c'" by (cs_concl cs_simp: cat_cs_simps) from c (*‹c ∈⇩∘ ℭ⦇Obj⦈›*) c' (*‹c' ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category (α::V) (ℭ::V)›*) Set.category_axioms (*‹category α (cat_Set α)›*) have CId_cc': "cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈ : Hom ℭ c c' ↦⇘cat_Set α⇙ Hom ℭ c c'" by (cs_concl cs_simp: cat_Set_cs_simps cat_Set_components(1) cs_intro: cat_cs_intros cat_prod_cs_intros) then have dom_rhs: "𝒟⇩∘ (cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrVal⦈) = Hom ℭ c c'" by (cs_concl cs_shallow cs_simp: cat_cs_simps) show "?thesis" (*goal: ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈›*) proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α (cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘)› 2. ‹arr_Set α (cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈)› 3. ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrVal⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrVal⦈› 4. ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrDom⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrDom⦈› 5. ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrCod⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrCod⦈›*) from cf_hom_cc' (*‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘ : Hom ℭ c c' ↦⇘cat_Set α⇙ Hom ℭ c c'›*) show arr_Set_CId_cc': "arr_Set α (cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘)" by (auto dest: cat_Set_is_arrD( (*‹?S : ?A ↦⇘cat_Set ?α⇙ ?B ⟹ arr_Set ?α ?S›*) 1)) from CId_cc' (*‹cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈ : Hom ℭ c c' ↦⇘cat_Set α⇙ Hom ℭ c c'›*) show arr_Set_Hom_cc': "arr_Set α (cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈)" by (auto simp: cat_Set_is_arrD( (*‹(?S::V) : (?A::V) ↦⇘cat_Set (?α::V)⇙ (?B::V) ⟹ arr_Set ?α ?S›*) 1)) show "cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrVal⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (cf_hom (ℭ::V) [ℭ⦇CId⦈⦇(c::V)⦈, ℭ⦇CId⦈⦇(c'::V)⦈]⇩∘⦇ArrVal⦈) = Hom ℭ c c'›*) dom_rhs (*‹𝒟⇩∘ (cat_Set (α::V)⦇CId⦈⦇Hom (ℭ::V) (c::V) (c'::V)⦈⦇ArrVal⦈) = Hom ℭ c c'›*) in_Hom_iff (*‹((?f::V) ∈⇩∘ Hom (?ℭ::V) (?a::V) (?b::V)) = ?f : ?a ↦⇘?ℭ⇙ ?b›*)) (*goals: 1. ‹vsv (cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrVal⦈)› 2. ‹vsv (cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrVal⦈)› 3. ‹Hom ℭ c c' = Hom ℭ c c'› 4. ‹⋀a. a : c ↦⇘ℭ⇙ c' ⟹ cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrVal⦈⦇a⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrVal⦈⦇a⦈›*) fix q assume "q : c ↦⇘ℭ⇙ c'" (*‹(q::V) : (c::V) ↦⇘ℭ::V⇙ (c'::V)›*) with category_axioms (*‹category α ℭ›*) show "cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrVal⦈⦇q⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrVal⦈⦇q⦈" by (cs_concl cs_simp: cat_cs_simps cat_op_simps cat_Set_cs_simps cs_intro: cat_cs_intros) qed (use arr_Set_CId_cc' arr_Set_Hom_cc' in auto) (*solves the remaining goals: 1. ‹vsv (cf_hom (ℭ::V) [ℭ⦇CId⦈⦇(c::V)⦈, ℭ⦇CId⦈⦇(c'::V)⦈]⇩∘⦇ArrVal⦈)› 2. ‹vsv (cat_Set (α::V)⦇CId⦈⦇Hom (ℭ::V) (c::V) (c'::V)⦈⦇ArrVal⦈)› 3. ‹Hom (ℭ::V) (c::V) (c'::V) = Hom ℭ c c'›*) qed ((use cf_hom_cc' CId_cc' in ‹cs_concl cs_simp: cat_cs_simps›)+) (*solves the remaining goals: 1. ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrDom⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrDom⦈› 2. ‹cf_hom ℭ [ℭ⦇CId⦈⦇c⦈, ℭ⦇CId⦈⦇c'⦈]⇩∘⦇ArrCod⦈ = cat_Set α⦇CId⦈⦇Hom ℭ c c'⦈⦇ArrCod⦈›*) qed lemmas [cat_cs_simps] = category.cat_cf_hom_CId subsubsection‹Opposite ‹hom›-function› lemma (in category) cat_op_cat_cf_hom: assumes "g : a ↦⇘ℭ⇙ b" and "g' : a' ↦⇘op_cat ℭ⇙ b'" shows "cf_hom (op_cat ℭ) [g, g']⇩∘ = cf_hom ℭ [g', g]⇩∘" proof (rule arr_Set_eqI[of α] (*‹⟦arr_Set α ?S; arr_Set α ?T; ?S⦇ArrVal⦈ = ?T⦇ArrVal⦈; ?S⦇ArrDom⦈ = ?T⦇ArrDom⦈; ?S⦇ArrCod⦈ = ?T⦇ArrCod⦈⟧ ⟹ ?S = ?T›*)) (*goals: 1. ‹arr_Set α (cf_hom (op_cat ℭ) [g, g']⇩∘)› 2. ‹arr_Set α (cf_hom ℭ [g', g]⇩∘)› 3. ‹cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈› 4. ‹cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrDom⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrDom⦈› 5. ‹cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrCod⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrCod⦈›*) from assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) show "arr_Set α (cf_hom (op_cat ℭ) [g, g']⇩∘)" by (cs_concl cs_shallow cs_simp: cat_op_simps cs_intro: cat_cs_intros cat_prod_cs_intros) from assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) show "arr_Set α (cf_hom ℭ [g', g]⇩∘)" by (cs_concl cs_shallow cs_simp: cat_op_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) from assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) have dom_lhs: "𝒟⇩∘ (cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈) = Hom ℭ a' a" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros) from assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) have dom_rhs: "𝒟⇩∘ (cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈) = Hom ℭ a' a" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros) show "cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold dom_lhs (*‹𝒟⇩∘ (cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈) = Hom ℭ a' a›*) dom_rhs (*‹𝒟⇩∘ (cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈) = Hom ℭ a' a›*) in_Hom_iff (*‹(?f ∈⇩∘ Hom ?ℭ ?a ?b) = ?f : ?a ↦⇘?ℭ⇙ ?b›*)) (*goals: 1. ‹vsv (cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈)› 2. ‹vsv (cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈)› 3. ‹Hom ℭ a' a = Hom ℭ a' a› 4. ‹⋀aa. aa : a' ↦⇘ℭ⇙ a ⟹ cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈⦇aa⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈⦇aa⦈›*) fix f assume "f : a' ↦⇘ℭ⇙ a" (*‹(f::V) : (a'::V) ↦⇘ℭ::V⇙ (a::V)›*) with assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) show "cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈⦇f⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈⦇f⦈" unfolding cat_op_simps (*goal: ‹cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈⦇f⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈⦇f⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros) qed (simp_all add: cf_hom_components) (*solves the remaining goals: 1. ‹vsv (cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrVal⦈)› 2. ‹vsv (cf_hom ℭ [g', g]⇩∘⦇ArrVal⦈)› 3. ‹Hom ℭ a' a = Hom ℭ a' a›*) from category_axioms (*‹category α ℭ›*) assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) show "cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrDom⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrDom⦈" by (cs_concl cs_shallow cs_simp: category.cf_hom_ArrDom cat_op_simps cs_intro: cat_op_intros cat_prod_cs_intros) from category_axioms (*‹category α ℭ›*) assms (*‹g : a ↦⇘ℭ⇙ b› ‹g' : a' ↦⇘op_cat ℭ⇙ b'›*) show "cf_hom (op_cat ℭ) [g, g']⇩∘⦇ArrCod⦈ = cf_hom ℭ [g', g]⇩∘⦇ArrCod⦈" by (cs_concl cs_shallow cs_simp: category.cf_hom_ArrCod cat_op_simps cs_intro: cat_op_intros cat_prod_cs_intros) qed lemmas [cat_cs_simps] = category.cat_op_cat_cf_hom subsection‹‹Hom›-functor› subsubsection‹Definition and elementary properties› text‹ See \<^cite>‹"noauthor_nlab_nodate"›\footnote{\url{ https://ncatlab.org/nlab/show/hom-functor }}. › definition cf_Hom :: "V ⇒ V ⇒ V" (‹Hom⇩O⇩.⇩Cı_'(/-,-/')›) where "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) = [ (λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (vpfst a) (vpsnd a)), (λf∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Arr⦈. cf_hom ℭ f), op_cat ℭ ×⇩C ℭ, cat_Set α ]⇩∘" text‹Components.› lemma cf_Hom_components: shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈ = (λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (vpfst a) (vpsnd a))" and "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈ = (λf∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Arr⦈. cf_hom ℭ f)" and "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇HomDom⦈ = op_cat ℭ ×⇩C ℭ" and "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇HomCod⦈ = cat_Set α" unfolding cf_Hom_def dghm_field_simps (*goals: 1. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇[]⇩∘⦈ = (λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈))› 2. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇1⇩ℕ⦈ = VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ)› 3. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇2⇩ℕ⦈ = op_cat ℭ ×⇩C ℭ› 4. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇3⇩ℕ⦈ = cat_Set α›*) (*goals: 1. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇[]⇩∘⦈ = (λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈))› 2. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇1⇩ℕ⦈ = VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ)› 3. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇2⇩ℕ⦈ = op_cat ℭ ×⇩C ℭ› 4. ‹[λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set α]⇩∘⦇3⇩ℕ⦈ = cat_Set α› discuss goal 1*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 2*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 3*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*discuss goal 4*) apply (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) (*proven 4 subgoals*) . subsubsection‹Object map› mk_VLambda cf_Hom_components(1) |vsv cf_Hom_ObjMap_vsv| lemma cf_Hom_ObjMap_vdomain[cat_cs_simps]: "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) = (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" unfolding cf_Hom_components (*goal: ‹𝒟⇩∘ (λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈)) = (op_cat ℭ ×⇩C ℭ)⦇Obj⦈›*) by simp lemma cf_Hom_ObjMap_app[cat_cs_simps]: assumes "[a, b]⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇a, b⦈⇩∙ = Hom ℭ a b" using assms (*‹[a, b]⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈›*) unfolding cf_Hom_components (*goal: ‹(λa∈⇩∘(op_cat ℭ ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈)) ⦇a, b⦈⇩∙ = Hom ℭ a b›*) by (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) lemma (in category) cf_Hom_ObjMap_vrange: "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈" proof (intro vsubsetI (*‹(⋀x. x ∈⇩∘ ?A ⟹ x ∈⇩∘ ?B) ⟹ ?A ⊆⇩∘ ?B›*)) (*goal: ‹⋀x::V. x ∈⇩∘ ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⦇ObjMap⦈) ⟹ x ∈⇩∘ cat_Set α⦇Obj⦈›*) interpret op_ℭ: category "α" "op_cat ℭ" by (simp add: category_op (*‹category α (op_cat ℭ)›*)) fix y assume "y ∈⇩∘ ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈)" (*‹(y::V) ∈⇩∘ ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⦇ObjMap⦈)›*) then obtain x where y_def: "y = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇x⦈" and x: "x ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" (*goal: ‹(⋀x. ⟦y = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇x⦈; x ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈⟧ ⟹ thesis) ⟹ thesis›*) unfolding cf_Hom_components (*goal: ‹(⋀x::V. ⟦(y::V) = (λa::V∈⇩∘(op_cat (ℭ::V) ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇(1::nat)⇩ℕ⦈))⦇x⦈; x ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto then obtain a and b where x_def: "x = [a, b]⇩∘" and a: "a ∈⇩∘ op_cat ℭ⦇Obj⦈" and b: "b ∈⇩∘ ℭ⦇Obj⦈" (*goal: ‹(⋀a b. ⟦x = [a, b]⇩∘; a ∈⇩∘ op_cat ℭ⦇Obj⦈; b ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis) ⟹ thesis›*) by (elim cat_prod_2_ObjE[OF op_ℭ.category_axioms category_axioms x] (*‹(⋀a b. ⟦x = [a, b]⇩∘; a ∈⇩∘ op_cat ℭ⦇Obj⦈; b ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ ?thesis) ⟹ ?thesis›*)) from a (*‹a ∈⇩∘ op_cat ℭ⦇Obj⦈›*) have a: "a ∈⇩∘ ℭ⦇Obj⦈" unfolding cat_op_simps (*goal: ‹a ∈⇩∘ ℭ⦇Obj⦈›*) by simp from a (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) b (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) show "y ∈⇩∘ cat_Set α⦇Obj⦈" unfolding y_def x_def cf_Hom_ObjMap_app[OF x [ unfolded x_def ]] cat_Set_components (*goal: ‹Hom ℭ a b ∈⇩∘ Vset α›*) by (auto simp: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 135 facts*)) qed subsubsection‹Arrow map› mk_VLambda cf_Hom_components(2) |vsv cf_Hom_ArrMap_vsv| |vdomain cf_Hom_ArrMap_vdomain[cat_cs_simps]| |app cf_Hom_ArrMap_app[cat_cs_simps]| subsubsection‹‹Hom›-functor is a functor› lemma (in category) cat_Hom_is_functor: "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat (ℭ::V) ×⇩C ℭ ↦↦⇩C⇘α::V⇙ cat_Set α›*) interpret Set: category "α" "cat_Set α" by (rule category_cat_Set (*‹category α (cat_Set α)›*)) interpret ℭℭ: category "α" "op_cat ℭ ×⇩C ℭ" by (simp add: category_axioms (*‹category (α::V) (ℭ::V)›*) category_cat_prod_2 (*‹⟦category (?α::V) (?𝔄::V); category ?α (?𝔅::V)⟧ ⟹ category ?α (?𝔄 ×⇩C ?𝔅)›*) category_op (*‹category (α::V) (op_cat (ℭ::V))›*)) interpret op_ℭ: category "α" "op_cat ℭ" by (rule category_op (*‹category α (op_cat ℭ)›*)) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat (ℭ::V) ×⇩C ℭ ↦↦⇩C⇘α::V⇙ cat_Set α›*) proof (intro is_functorI' (*‹⟦𝒵 ?α; vfsequence ?𝔉; category ?α ?𝔄; category ?α ?𝔅; vcard ?𝔉 = 4⇩ℕ; ?𝔉⦇HomDom⦈ = ?𝔄; ?𝔉⦇HomCod⦈ = ?𝔅; vsv (?𝔉⦇ObjMap⦈); vsv (?𝔉⦇ArrMap⦈); 𝒟⇩∘ (?𝔉⦇ObjMap⦈) = ?𝔄⦇Obj⦈; ℛ⇩∘ (?𝔉⦇ObjMap⦈) ⊆⇩∘ ?𝔅⦇Obj⦈; 𝒟⇩∘ (?𝔉⦇ArrMap⦈) = ?𝔄⦇Arr⦈; ⋀a b f. f : a ↦⇘?𝔄⇙ b ⟹ ?𝔉⦇ArrMap⦈⦇f⦈ : ?𝔉⦇ObjMap⦈⦇a⦈ ↦⇘?𝔅⇙ ?𝔉⦇ObjMap⦈⦇b⦈; ⋀b c g a f. ⟦g : b ↦⇘?𝔄⇙ c; f : a ↦⇘?𝔄⇙ b⟧ ⟹ ?𝔉⦇ArrMap⦈⦇g ∘⇩A⇘?𝔄⇙ f⦈ = ?𝔉⦇ArrMap⦈⦇g⦈ ∘⇩A⇘?𝔅⇙ ?𝔉⦇ArrMap⦈⦇f⦈; ⋀c. c ∈⇩∘ ?𝔄⦇Obj⦈ ⟹ ?𝔉⦇ArrMap⦈⦇?𝔄⦇CId⦈⦇c⦈⦈ = ?𝔅⦇CId⦈⦇?𝔉⦇ObjMap⦈⦇c⦈⦈⟧ ⟹ ?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅›*)) (*goals: 1. ‹𝒵 α› 2. ‹vfsequence Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)› 3. ‹category α (op_cat ℭ ×⇩C ℭ)› 4. ‹category α (cat_Set α)› 5. ‹vcard Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) = 4⇩ℕ› 6. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇HomDom⦈ = op_cat ℭ ×⇩C ℭ› 7. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇HomCod⦈ = cat_Set α› 8. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈)› 9. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈)› 10. ‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) = (op_cat ℭ ×⇩C ℭ)⦇Obj⦈› 11. ‹ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈› 12. ‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈) = (op_cat ℭ ×⇩C ℭ)⦇Arr⦈› 13. ‹⋀a b f. f : a ↦⇘op_cat ℭ ×⇩C ℭ⇙ b ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇f⦈ : Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇a⦈ ↦⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇b⦈› 14. ‹⋀b c g a f. ⟦g : b ↦⇘op_cat ℭ ×⇩C ℭ⇙ c; f : a ↦⇘op_cat ℭ ×⇩C ℭ⇙ b⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇g ∘⇩A⇘op_cat ℭ ×⇩C ℭ⇙ f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇g⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇f⦈› 15. ‹⋀c. c ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇(op_cat ℭ ×⇩C ℭ)⦇CId⦈⦇c⦈⦈ = cat_Set α⦇CId⦈⦇Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇c⦈⦈›*) show "vfsequence Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)" unfolding cf_Hom_def (*goal: ‹vfsequence [λa::V∈⇩∘(op_cat (ℭ::V) ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇(1::nat)⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set (α::V)]⇩∘›*) by simp show "op_ℭ_ℭ": "category α (op_cat ℭ ×⇩C ℭ)" by (auto simp: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 165 facts*)) show "vcard Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) = 4⇩ℕ" unfolding cf_Hom_def (*goal: ‹vcard [λa::V∈⇩∘(op_cat (ℭ::V) ×⇩C ℭ)⦇Obj⦈. Hom ℭ (a⦇[]⇩∘⦈) (a⦇(1::nat)⇩ℕ⦈), VLambda ((op_cat ℭ ×⇩C ℭ)⦇Arr⦈) (cf_hom ℭ), op_cat ℭ ×⇩C ℭ, cat_Set (α::V)]⇩∘ = (4::nat)⇩ℕ›*) by (simp add: nat_omega_simps (*‹?a⇩ℕ + ?b⇩ℕ = (?a + ?b)⇩ℕ› ‹?a⇩ℕ * ?b⇩ℕ = (?a * ?b)⇩ℕ› ‹ZFC_in_HOL.succ (?a⇩ℕ) = Suc ?a⇩ℕ› ‹?m⇩ℕ ⊕ ?n⇩ℕ = (?m + ?n)⇩ℕ› ‹csucc (?a⇩ℕ) = ZFC_in_HOL.succ (?a⇩ℕ)› ‹ZFC_in_HOL.succ []⇩∘ = 1⇩ℕ› ‹1 = 1⇩ℕ›*)) show "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈" by (simp add: cf_Hom_ObjMap_vrange (*‹ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*)) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gf⦈ : Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇ab⦈ ↦⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cd⦈" if gf: "gf : ab ↦⇘op_cat ℭ ×⇩C ℭ⇙ cd" for gf and ab and cd unfolding slicing_simps cat_smc_cat_Set[symmetric] (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gf⦈ : Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇ab⦈ ↦⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cd⦈›*) proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gf⦈ : Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇ab⦈ ↦⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cd⦈›*) obtain g and f and a and b and c and d where gf_def: "gf = [g, f]⇩∘" and ab_def: "ab = [a, b]⇩∘" and cd_def: "cd = [c, d]⇩∘" and "g : a ↦⇘op_cat ℭ⇙ c" and f: "f : b ↦⇘ℭ⇙ d" (*goal: ‹(⋀g f a b c d. ⟦gf = [g, f]⇩∘; ab = [a, b]⇩∘; cd = [c, d]⇩∘; g : a ↦⇘op_cat ℭ⇙ c; f : b ↦⇘ℭ⇙ d⟧ ⟹ thesis) ⟹ thesis›*) by (elim cat_prod_2_is_arrE[OF category_op category_axioms gf] (*‹(⋀g f a b c d. ⟦gf = [g, f]⇩∘; ab = [a, b]⇩∘; cd = [c, d]⇩∘; g : a ↦⇘op_cat ℭ⇙ c; f : b ↦⇘ℭ⇙ d⟧ ⟹ ?thesis) ⟹ ?thesis›*)) then have g: "g : c ↦⇘ℭ⇙ a" unfolding cat_op_simps (*goal: ‹g : c ↦⇘ℭ⇙ a›*) by simp from category_axioms (*‹category α ℭ›*) that (*‹(gf::V) : (ab::V) ↦⇘op_cat (ℭ::V) ×⇩C ℭ⇙ (cd::V)›*) g (*‹g : c ↦⇘ℭ⇙ a›*) f (*‹f : b ↦⇘ℭ⇙ d›*) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gf⦈ : Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇ab⦈ ↦⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cd⦈" unfolding gf_def ab_def cd_def (*goal: ‹g ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ f : a ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ b ↦⇘cat_Set α⇙ c ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ d›*) by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) qed show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gg' ∘⇩A⇘op_cat ℭ ×⇩C ℭ⇙ ff'⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gg'⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇ff'⦈" if gg': "gg' : bb' ↦⇘op_cat ℭ ×⇩C ℭ⇙ cc'" and ff': "ff' : aa' ↦⇘op_cat ℭ ×⇩C ℭ⇙ bb'" for gg' and bb' and cc' and ff' and aa' proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gg' ∘⇩A⇘op_cat ℭ ×⇩C ℭ⇙ ff'⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gg'⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇ff'⦈›*) obtain g and g' and b and b' and c and c' where gg'_def: "gg' = [g, g']⇩∘" and bb'_def: "bb' = [b, b']⇩∘" and cc'_def: "cc' = [c, c']⇩∘" and "g : b ↦⇘op_cat ℭ⇙ c" and g': "g' : b' ↦⇘ℭ⇙ c'" (*goal: ‹(⋀g g' b b' c c'. ⟦gg' = [g, g']⇩∘; bb' = [b, b']⇩∘; cc' = [c, c']⇩∘; g : b ↦⇘op_cat ℭ⇙ c; g' : b' ↦⇘ℭ⇙ c'⟧ ⟹ thesis) ⟹ thesis›*) by (elim cat_prod_2_is_arrE[OF category_op category_axioms gg'] (*‹(⋀g f a b c d. ⟦gg' = [g, f]⇩∘; bb' = [a, b]⇩∘; cc' = [c, d]⇩∘; g : a ↦⇘op_cat ℭ⇙ c; f : b ↦⇘ℭ⇙ d⟧ ⟹ ?thesis) ⟹ ?thesis›*)) moreover obtain f and f' and a and a' and b'' and b''' where ff'_def: "ff' = [f, f']⇩∘" and aa'_def: "aa' = [a, a']⇩∘" and "bb' = [b'', b''']⇩∘" and "f : a ↦⇘op_cat ℭ⇙ b''" and "f' : a' ↦⇘ℭ⇙ b'''" (*goal: ‹(⋀f f' a a' b'' b'''. ⟦ff' = [f, f']⇩∘; aa' = [a, a']⇩∘; bb' = [b'', b''']⇩∘; f : a ↦⇘op_cat ℭ⇙ b''; f' : a' ↦⇘ℭ⇙ b'''⟧ ⟹ thesis) ⟹ thesis›*) by (elim cat_prod_2_is_arrE[OF category_op category_axioms ff'] (*‹(⋀g f a b c d. ⟦ff' = [g, f]⇩∘; aa' = [a, b]⇩∘; bb' = [c, d]⇩∘; g : a ↦⇘op_cat ℭ⇙ c; f : b ↦⇘ℭ⇙ d⟧ ⟹ ?thesis) ⟹ ?thesis›*)) ultimately have f: "f : b ↦⇘ℭ⇙ a" and f': "f' : a' ↦⇘ℭ⇙ b'" and g: "g : c ↦⇘ℭ⇙ b" apply - (*goals: 1. ‹⟦gg' = [g, g']⇩∘; bb' = [b, b']⇩∘; cc' = [c, c']⇩∘; g : b ↦⇘op_cat ℭ⇙ c; g' : b' ↦⇘ℭ⇙ c'; ff' = [f, f']⇩∘; aa' = [a, a']⇩∘; bb' = [b'', b''']⇩∘; f : a ↦⇘op_cat ℭ⇙ b''; f' : a' ↦⇘ℭ⇙ b'''⟧ ⟹ f : b ↦⇘ℭ⇙ a› 2. ‹⟦gg' = [g, g']⇩∘; bb' = [b, b']⇩∘; cc' = [c, c']⇩∘; g : b ↦⇘op_cat ℭ⇙ c; g' : b' ↦⇘ℭ⇙ c'; ff' = [f, f']⇩∘; aa' = [a, a']⇩∘; bb' = [b'', b''']⇩∘; f : a ↦⇘op_cat ℭ⇙ b''; f' : a' ↦⇘ℭ⇙ b'''⟧ ⟹ f' : a' ↦⇘ℭ⇙ b'› 3. ‹⟦gg' = [g, g']⇩∘; bb' = [b, b']⇩∘; cc' = [c, c']⇩∘; g : b ↦⇘op_cat ℭ⇙ c; g' : b' ↦⇘ℭ⇙ c'; ff' = [f, f']⇩∘; aa' = [a, a']⇩∘; bb' = [b'', b''']⇩∘; f : a ↦⇘op_cat ℭ⇙ b''; f' : a' ↦⇘ℭ⇙ b'''⟧ ⟹ g : c ↦⇘ℭ⇙ b› discuss goal 1*) apply ((auto simp: cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 86 facts*))[1]) (*discuss goal 2*) apply ((auto simp: cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 86 facts*))[1]) (*discuss goal 3*) apply ((auto simp: cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 86 facts*))[1]) (*proven 3 subgoals*) . from category_axioms (*‹category α ℭ›*) that (*‹gg' : bb' ↦⇘op_cat ℭ ×⇩C ℭ⇙ cc'› ‹(ff'::V) : (aa'::V) ↦⇘op_cat (ℭ::V) ×⇩C ℭ⇙ (bb'::V)›*) g (*‹g : c ↦⇘ℭ⇙ b›*) f (*‹f : b ↦⇘ℭ⇙ a›*) g' (*‹(g'::V) : (b'::V) ↦⇘ℭ::V⇙ (c'::V)›*) f' (*‹(f'::V) : (a'::V) ↦⇘ℭ::V⇙ (b'::V)›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gg' ∘⇩A⇘op_cat ℭ ×⇩C ℭ⇙ ff'⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇gg'⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇ff'⦈›*) unfolding slicing_simps cat_smc_cat_Set[symmetric] gg'_def bb'_def cc'_def ff'_def aa'_def (*goal: ‹Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⦇ArrMap⦈⦇[g::V, g'::V]⇩∘ ∘⇩A⇘op_cat ℭ ×⇩C ℭ⇙ [f::V, f'::V]⇩∘⦈ = g ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ g' ∘⇩A⇘cat_Set α⇙ (f ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ f')›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cat_prod_cs_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇(op_cat ℭ ×⇩C ℭ)⦇CId⦈⦇cc'⦈⦈ = cat_Set α⦇CId⦈⦇Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cc'⦈⦈" if "cc' ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" for cc' proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⦇ArrMap⦈⦇(op_cat ℭ ×⇩C ℭ)⦇CId⦈⦇(cc'::V)⦈⦈ = cat_Set α⦇CId⦈⦇Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cc'⦈⦈›*) from that (*‹cc' ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈›*) obtain c and c' where cc'_def: "cc' = [c, c']⇩∘" and c: "c ∈⇩∘ op_cat ℭ⦇Obj⦈" and c': "c' ∈⇩∘ ℭ⦇Obj⦈" (*goal: ‹(⋀c c'. ⟦cc' = [c, c']⇩∘; c ∈⇩∘ op_cat ℭ⦇Obj⦈; c' ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis) ⟹ thesis›*) apply (elim cat_prod_2_ObjE[rotated 2] (*‹⟦?ab ∈⇩∘ (?𝔄 ×⇩C ?𝔅)⦇Obj⦈; ⋀a b. ⟦?ab = [a, b]⇩∘; a ∈⇩∘ ?𝔄⦇Obj⦈; b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ ?thesis; category ?α ?𝔄; category ?α ?𝔅⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀a b. ⟦⋀c c'. ⟦cc' = [c, c']⇩∘; c ∈⇩∘ op_cat ℭ⦇Obj⦈; c' ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis; cc' = [a, b]⇩∘; a ∈⇩∘ op_cat ℭ⦇Obj⦈; b ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis› 2. ‹(⋀c c'. ⟦cc' = [c, c']⇩∘; c ∈⇩∘ op_cat ℭ⦇Obj⦈; c' ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis) ⟹ category ?α3 (op_cat ℭ)› 3. ‹(⋀c c'. ⟦cc' = [c, c']⇩∘; c ∈⇩∘ op_cat ℭ⦇Obj⦈; c' ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis) ⟹ category ?α3 ℭ› discuss goal 1*) apply ((auto intro: cat_cs_intros (*‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) = ?a; (?c::V) = ?a; (?ℭ'::V) = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?f::V) = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ (?g'::V) ?g; is_inverse ?ℭ (?f'::V) ?f; (?f'g'::V) = ?f' ∘⇩A⇘?ℭ⇙ ?g'; (?gf::V) = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V); (?ℭ'::V) = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 165 facts*))[1]) (*discuss goal 2*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 165 facts*))[1]) (*discuss goal 3*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 165 facts*))[1]) (*proven 3 subgoals*) . then have c: "c ∈⇩∘ ℭ⦇Obj⦈" unfolding cat_op_simps (*goal: ‹c ∈⇩∘ ℭ⦇Obj⦈›*) by simp with c' (*‹c' ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) Set.category_axioms (*‹category α (cat_Set α)›*) that (*‹cc' ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇(op_cat ℭ ×⇩C ℭ)⦇CId⦈⦇cc'⦈⦈ = cat_Set α⦇CId⦈⦇Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇cc'⦈⦈›*) unfolding cc'_def (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇(op_cat ℭ ×⇩C ℭ)⦇CId⦈ ⦇c, c'⦈⇩∙⦈ = cat_Set α⦇CId⦈⦇c ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ c'⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cat_prod_cs_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed qed (auto simp: cf_Hom_components (*‹Hom⇩O⇩.⇩C⇘?α⇙?ℭ(-,-)⦇ObjMap⦈ = (λa∈⇩∘(op_cat ?ℭ ×⇩C ?ℭ)⦇Obj⦈. Hom ?ℭ (a⦇[]⇩∘⦈) (a⦇1⇩ℕ⦈))› ‹Hom⇩O⇩.⇩C⇘?α⇙?ℭ(-,-)⦇ArrMap⦈ = VLambda ((op_cat ?ℭ ×⇩C ?ℭ)⦇Arr⦈) (cf_hom ?ℭ)› ‹Hom⇩O⇩.⇩C⇘?α⇙?ℭ(-,-)⦇HomDom⦈ = op_cat ?ℭ ×⇩C ?ℭ› ‹Hom⇩O⇩.⇩C⇘?α⇙?ℭ(-,-)⦇HomCod⦈ = cat_Set ?α›*) cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 165 facts*)) (*solves the remaining goals: 1. ‹𝒵 α› 2. ‹category α (cat_Set α)› 3. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇HomDom⦈ = op_cat ℭ ×⇩C ℭ› 4. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇HomCod⦈ = cat_Set α› 5. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈)› 6. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈)› 7. ‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈) = (op_cat ℭ ×⇩C ℭ)⦇Obj⦈› 8. ‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈) = (op_cat ℭ ×⇩C ℭ)⦇Arr⦈›*) qed lemma (in category) cat_Hom_is_functor': assumes "β = α" and "𝔄' = op_cat ℭ ×⇩C ℭ" and "𝔅' = cat_Set α" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : 𝔄' ↦↦⇩C⇘β⇙ 𝔅'" unfolding assms (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule cat_Hom_is_functor (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α›*)) lemmas [cat_cs_intros] = category.cat_Hom_is_functor' subsection‹Composition of a ‹Hom›-functor and two functors› subsubsection‹Definition and elementary properties› definition cf_bcomp_Hom :: "V ⇒ V ⇒ V ⇒ V ⇒ V" (‹Hom⇩O⇩.⇩Cı_'(/_-,_-/')›) ―‹The following definition may seem redundant, but it will help to avoid proof duplication later.› where "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-) = cf_cn_cov_bcomp (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)) 𝔉 𝔊" subsubsection‹Object map› lemma cf_bcomp_Hom_ObjMap_vsv: "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ObjMap⦈)" unfolding cf_bcomp_Hom_def (*goal: ‹vsv (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⦇ObjMap⦈)›*) by (rule cf_cn_cov_bcomp_ObjMap_vsv (*‹vsv (cf_cn_cov_bcomp (?𝔖::V) (?𝔉::V) (?𝔊::V)⦇ObjMap⦈)›*)) lemma cf_bcomp_Hom_ObjMap_vdomain[cat_cs_simps]: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ObjMap⦈) = (op_cat 𝔄 ×⇩C 𝔅)⦇Obj⦈" using assms (*‹𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ› ‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_bcomp_Hom_def (*goal: ‹𝒟⇩∘ (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⦇ObjMap⦈) = (op_cat 𝔄 ×⇩C 𝔅)⦇Obj⦈›*) by (rule cf_cn_cov_bcomp_ObjMap_vdomain (*‹⟦?𝔉 : ?𝔅' ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔊 : ?ℭ' ↦↦⇩C⇘?α⇙ ?ℭ⟧ ⟹ 𝒟⇩∘ (cf_cn_cov_bcomp ?𝔖 ?𝔉 ?𝔊⦇ObjMap⦈) = (op_cat ?𝔅' ×⇩C ?ℭ')⦇Obj⦈›*)) lemma cf_bcomp_Hom_ObjMap_app[cat_cs_simps]: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "[a, b]⇩∘ ∈⇩∘ (op_cat 𝔄 ×⇩C 𝔅)⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ObjMap⦈⦇a, b⦈⇩∙ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇𝔉⦇ObjMap⦈⦇a⦈, 𝔊⦇ObjMap⦈⦇b⦈⦈⇩∙" using assms (*‹𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ› ‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹[a, b]⇩∘ ∈⇩∘ (op_cat 𝔄 ×⇩C 𝔅)⦇Obj⦈›*) unfolding cf_bcomp_Hom_def (*goal: ‹a ⊗⇩H⇩M⇩.⇩O⇘cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⇙ b = 𝔉⦇ObjMap⦈⦇a⦈ ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ 𝔊⦇ObjMap⦈⦇b⦈›*) by (rule cf_cn_cov_bcomp_ObjMap_app (*‹⟦?𝔉 : ?𝔅' ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔊 : ?ℭ' ↦↦⇩C⇘?α⇙ ?ℭ; [?a, ?b]⇩∘ ∈⇩∘ (op_cat ?𝔅' ×⇩C ?ℭ')⦇Obj⦈⟧ ⟹ ?a ⊗⇩H⇩M⇩.⇩O⇘cf_cn_cov_bcomp ?𝔖 ?𝔉 ?𝔊⇙ ?b = ?𝔉⦇ObjMap⦈⦇?a⦈ ⊗⇩H⇩M⇩.⇩O⇘?𝔖⇙ ?𝔊⦇ObjMap⦈⦇?b⦈›*)) lemma (in category) cf_bcomp_Hom_ObjMap_vrange: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈" using category_axioms (*‹category α ℭ›*) unfolding cf_bcomp_Hom_def (*goal: ‹ℛ⇩∘ (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*) apply (intro cf_cn_cov_bcomp_ObjMap_vrange[OF assms] (*‹?𝔖 : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ ?𝔇 ⟹ ℛ⇩∘ (cf_cn_cov_bcomp ?𝔖 𝔉 𝔊⦇ObjMap⦈) ⊆⇩∘ ?𝔇⦇Obj⦈›*)) (*goal: ‹ℛ⇩∘ (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) subsubsection‹Arrow map› lemma cf_bcomp_Hom_ArrMap_vsv: "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ArrMap⦈)" unfolding cf_bcomp_Hom_def (*goal: ‹vsv (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-) (𝔉::V) (𝔊::V)⦇ArrMap⦈)›*) by (rule cf_cn_cov_bcomp_ArrMap_vsv (*‹vsv (cf_cn_cov_bcomp ?ℭ ?𝔖 ?𝔉⦇ArrMap⦈)›*)) lemma cf_bcomp_Hom_ArrMap_vdomain[cat_cs_simps]: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ArrMap⦈) = (op_cat 𝔄 ×⇩C 𝔅)⦇Arr⦈" using assms (*‹(𝔉::V) : (𝔄::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)› ‹(𝔊::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)›*) unfolding cf_bcomp_Hom_def (*goal: ‹𝒟⇩∘ (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-) (𝔉::V) (𝔊::V)⦇ArrMap⦈) = (op_cat (𝔄::V) ×⇩C (𝔅::V))⦇Arr⦈›*) by (rule cf_cn_cov_bcomp_ArrMap_vdomain (*‹⟦?𝔉 : ?𝔅' ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔊 : ?ℭ' ↦↦⇩C⇘?α⇙ ?ℭ⟧ ⟹ 𝒟⇩∘ (cf_cn_cov_bcomp ?𝔖 ?𝔉 ?𝔊⦇ArrMap⦈) = (op_cat ?𝔅' ×⇩C ?ℭ')⦇Arr⦈›*)) lemma cf_bcomp_Hom_ArrMap_app[cat_cs_simps]: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "[f, g]⇩∘ ∈⇩∘ (op_cat 𝔄 ×⇩C 𝔅)⦇Arr⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ArrMap⦈⦇f, g⦈⇩∙ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇𝔉⦇ArrMap⦈⦇f⦈, 𝔊⦇ArrMap⦈⦇g⦈⦈⇩∙" using assms (*‹𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ› ‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹[f, g]⇩∘ ∈⇩∘ (op_cat 𝔄 ×⇩C 𝔅)⦇Arr⦈›*) unfolding cf_bcomp_Hom_def (*goal: ‹f ⊗⇩H⇩M⇩.⇩A⇘cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⇙ g = 𝔉⦇ArrMap⦈⦇f⦈ ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ 𝔊⦇ArrMap⦈⦇g⦈›*) by (rule cf_cn_cov_bcomp_ArrMap_app (*‹⟦?𝔉 : ?𝔅' ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔊 : ?ℭ' ↦↦⇩C⇘?α⇙ ?ℭ; [?g, ?f]⇩∘ ∈⇩∘ (op_cat ?𝔅' ×⇩C ?ℭ')⦇Arr⦈⟧ ⟹ ?g ⊗⇩H⇩M⇩.⇩A⇘cf_cn_cov_bcomp ?𝔖 ?𝔉 ?𝔊⇙ ?f = ?𝔉⦇ArrMap⦈⦇?g⦈ ⊗⇩H⇩M⇩.⇩A⇘?𝔖⇙ ?𝔊⦇ArrMap⦈⦇?f⦈›*)) lemma (in category) cf_bcomp_Hom_ArrMap_vrange: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-)⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈" using category_axioms (*‹category α ℭ›*) unfolding cf_bcomp_Hom_def (*goal: ‹ℛ⇩∘ (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-) (𝔉::V) (𝔊::V)⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈›*) apply (intro cf_cn_cov_bcomp_ArrMap_vrange[OF assms] (*‹?𝔖 : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ ?𝔇 ⟹ ℛ⇩∘ (cf_cn_cov_bcomp ?𝔖 𝔉 𝔊⦇ArrMap⦈) ⊆⇩∘ ?𝔇⦇Arr⦈›*)) (*goal: ‹ℛ⇩∘ (cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 𝔊⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) subsubsection‹Composition of a ‹Hom›-functor and two functors is a functor› lemma (in category) cat_cf_bcomp_Hom_is_functor: assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-) : op_cat 𝔄 ×⇩C 𝔅 ↦↦⇩C⇘α⇙ cat_Set α" using assms (*‹𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ› ‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) category_axioms (*‹category α ℭ›*) unfolding cf_bcomp_Hom_def (*goal: ‹cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ::V(-,-) (𝔉::V) (𝔊::V) : op_cat (𝔄::V) ×⇩C (𝔅::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) lemma (in category) cat_cf_bcomp_Hom_is_functor': assumes "𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "β = α" and "𝔄' = op_cat 𝔄 ×⇩C 𝔅" and "𝔅' = cat_Set α" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-) : 𝔄' ↦↦⇩C⇘β⇙ 𝔅'" using assms(1,2) (*‹𝔉 : 𝔄 ↦↦⇩C⇘α⇙ ℭ› ‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding assms(3-5) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,𝔊-) : op_cat 𝔄 ×⇩C 𝔅 ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule cat_cf_bcomp_Hom_is_functor (*‹⟦?𝔉 : ?𝔄 ↦↦⇩C⇘α⇙ ℭ; ?𝔊 : ?𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?𝔉-,?𝔊-) : op_cat ?𝔄 ×⇩C ?𝔅 ↦↦⇩C⇘α⇙ cat_Set α›*)) lemmas [cat_cs_intros] = category.cat_cf_bcomp_Hom_is_functor' subsection‹Composition of a ‹Hom›-functor and a functor› subsubsection‹Definition and elementary properties› text‹See subsection 1.15 in \<^cite>‹"bodo_categories_1970"›.› definition cf_lcomp_Hom :: "V ⇒ V ⇒ V ⇒ V" (‹Hom⇩O⇩.⇩Cı_'(/_-,-/')›) where "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) = cf_cn_cov_lcomp ℭ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)) 𝔉" definition cf_rcomp_Hom :: "V ⇒ V ⇒ V ⇒ V" (‹Hom⇩O⇩.⇩Cı_'(/-,_-/')›) where "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-) = cf_cn_cov_rcomp ℭ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)) 𝔊" subsubsection‹Object map› lemma cf_lcomp_Hom_ObjMap_vsv[cat_cs_intros]: "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ObjMap⦈)" unfolding cf_lcomp_Hom_def (*goal: ‹vsv (cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉⦇ObjMap⦈)›*) by (rule cf_cn_cov_lcomp_ObjMap_vsv (*‹vsv (cf_cn_cov_lcomp ?ℭ ?𝔖 ?𝔉⦇ObjMap⦈)›*)) lemma cf_rcomp_Hom_ObjMap_vsv[cat_cs_intros]: "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈)" unfolding cf_rcomp_Hom_def (*goal: ‹vsv (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ObjMap⦈)›*) by (rule cf_cn_cov_rcomp_ObjMap_vsv (*‹vsv (cf_cn_cov_rcomp ?ℭ ?𝔖 ?𝔉⦇ObjMap⦈)›*)) lemma cf_lcomp_Hom_ObjMap_vdomain[cat_cs_simps]: assumes "category α ℭ" and "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ObjMap⦈) = (op_cat 𝔅 ×⇩C ℭ)⦇Obj⦈" using assms (*‹category α ℭ› ‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cf_lcomp_Hom_def cs_intro: cat_cs_intros) lemma cf_rcomp_Hom_ObjMap_vdomain[cat_cs_simps]: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈) = (op_cat ℭ ×⇩C 𝔅)⦇Obj⦈" using assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cf_rcomp_Hom_def cs_intro: cat_cs_intros) lemma cf_lcomp_Hom_ObjMap_app[cat_cs_simps]: assumes "category α ℭ" and "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "b ∈⇩∘ op_cat 𝔅⦇Obj⦈" and "c ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ObjMap⦈⦇b, c⦈⇩∙ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇𝔉⦇ObjMap⦈⦇b⦈, c⦈⇩∙" using assms (*‹category (α::V) (ℭ::V)› ‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ op_cat 𝔅⦇Obj⦈› ‹c ∈⇩∘ ℭ⦇Obj⦈›*) unfolding cf_lcomp_Hom_def (*goal: ‹(b::V) ⊗⇩H⇩M⇩.⇩O⇘cf_cn_cov_lcomp (ℭ::V) Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,-) (𝔉::V)⇙ (c::V) = 𝔉⦇ObjMap⦈⦇b⦈ ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ c›*) by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_prod_cs_intros) lemma cf_rcomp_Hom_ObjMap_app[cat_cs_simps]: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "c ∈⇩∘ op_cat ℭ⦇Obj⦈" and "b ∈⇩∘ 𝔅⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈⦇c, b⦈⇩∙ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇c, 𝔊⦇ObjMap⦈⦇b⦈⦈⇩∙" using assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹c ∈⇩∘ op_cat ℭ⦇Obj⦈› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cf_rcomp_Hom_def cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) lemma (in category) cat_cf_lcomp_Hom_ObjMap_vrange: assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈" using category_axioms (*‹category α ℭ›*) assms (*‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)›*) unfolding cf_lcomp_Hom_def (*goal: ‹ℛ⇩∘ (cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*) apply - (*goal: ‹ℛ⇩∘ (cf_cn_cov_lcomp (ℭ::V) Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,-) (𝔉::V)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*) apply (intro cf_cn_cov_lcomp_ObjMap_vrange (*‹⟦category ?α ?ℭ; ?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔖 : op_cat ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇⟧ ⟹ ℛ⇩∘ (cf_cn_cov_lcomp ?ℭ ?𝔖 ?𝔉⦇ObjMap⦈) ⊆⇩∘ ?𝔇⦇Obj⦈›*)) (*goals: 1. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ category ?α2 ℭ› 2. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ 𝔉 : ?𝔄2 ↦↦⇩C⇘?α2⇙ ?𝔅2› 3. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ?𝔅2 ×⇩C ℭ ↦↦⇩C⇘?α2⇙ cat_Set α› discuss goal 1*) apply (cs_concl cs_shallow cs_intro: cat_cs_intros) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . lemma (in category) cat_cf_rcomp_Hom_ObjMap_vrange: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈" using category_axioms (*‹category (α::V) (ℭ::V)›*) assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_rcomp_Hom_def (*goal: ‹ℛ⇩∘ (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*) apply - (*goal: ‹ℛ⇩∘ (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ObjMap⦈) ⊆⇩∘ cat_Set α⦇Obj⦈›*) apply (intro cf_cn_cov_rcomp_ObjMap_vrange (*‹⟦category ?α ?𝔅; ?𝔊 : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔖 : op_cat ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇⟧ ⟹ ℛ⇩∘ (cf_cn_cov_rcomp ?𝔅 ?𝔖 ?𝔊⦇ObjMap⦈) ⊆⇩∘ ?𝔇⦇Obj⦈›*)) (*goals: 1. ‹⟦category (α::V) (ℭ::V); (𝔊::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ category (?α2::V) ℭ› 2. ‹⟦category (α::V) (ℭ::V); (𝔊::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ 𝔊 : (?𝔄2::V) ↦↦⇩C⇘?α2::V⇙ (?ℭ2::V)› 3. ‹⟦category (α::V) (ℭ::V); (𝔊::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C (?ℭ2::V) ↦↦⇩C⇘?α2::V⇙ cat_Set α› discuss goal 1*) apply (cs_concl cs_shallow cs_intro: cat_cs_intros) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . subsubsection‹Arrow map› lemma cf_lcomp_Hom_ArrMap_vsv[cat_cs_intros]: "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ArrMap⦈)" unfolding cf_lcomp_Hom_def (*goal: ‹vsv (cf_cn_cov_lcomp (ℭ::V) Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,-) (𝔉::V)⦇ArrMap⦈)›*) by (rule cf_cn_cov_lcomp_ArrMap_vsv (*‹vsv (cf_cn_cov_lcomp ?ℭ ?𝔖 ?𝔉⦇ArrMap⦈)›*)) lemma cf_rcomp_Hom_ArrMap_vsv[cat_cs_intros]: "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈)" unfolding cf_rcomp_Hom_def (*goal: ‹vsv (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ArrMap⦈)›*) by (rule cf_cn_cov_rcomp_ArrMap_vsv (*‹vsv (cf_cn_cov_rcomp ?𝔅 ?𝔖 ?𝔊⦇ArrMap⦈)›*)) lemma cf_lcomp_Hom_ArrMap_vdomain[cat_cs_simps]: assumes "category α ℭ" and "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ArrMap⦈) = (op_cat 𝔅 ×⇩C ℭ)⦇Arr⦈" using assms (*‹category α ℭ› ‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_lcomp_Hom_def (*goal: ‹𝒟⇩∘ (cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉⦇ArrMap⦈) = (op_cat 𝔅 ×⇩C ℭ)⦇Arr⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) lemma cf_rcomp_Hom_ArrMap_vdomain[cat_cs_simps]: assumes "category α ℭ" and "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈) = (op_cat ℭ ×⇩C 𝔅)⦇Arr⦈" using assms (*‹category α ℭ› ‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_rcomp_Hom_def (*goal: ‹𝒟⇩∘ (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ArrMap⦈) = (op_cat ℭ ×⇩C 𝔅)⦇Arr⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps) lemma cf_lcomp_Hom_ArrMap_app[cat_cs_simps]: assumes "category α ℭ" and "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "g : a ↦⇘op_cat 𝔅⇙ b" and "f : a' ↦⇘ℭ⇙ b'" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ArrMap⦈⦇g, f⦈⇩∙ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇𝔉⦇ArrMap⦈⦇g⦈, f⦈⇩∙" using assms (*‹category α ℭ› ‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)› ‹g : a ↦⇘op_cat 𝔅⇙ b› ‹(f::V) : (a'::V) ↦⇘ℭ::V⇙ (b'::V)›*) unfolding cf_lcomp_Hom_def cat_op_simps (*goal: ‹g ⊗⇩H⇩M⇩.⇩A⇘cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉⇙ f = 𝔉⦇ArrMap⦈⦇g⦈ ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ f›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_prod_cs_intros) lemma cf_rcomp_Hom_ArrMap_app[cat_cs_simps]: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "g : a ↦⇘op_cat ℭ⇙ b" and "f : a' ↦⇘𝔅⇙ b'" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈⦇g, f⦈⇩∙ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈⦇g, 𝔊⦇ArrMap⦈⦇f⦈⦈⇩∙" using assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹g : a ↦⇘op_cat ℭ⇙ b› ‹f : a' ↦⇘𝔅⇙ b'›*) by (cs_concl cs_simp: cat_cs_simps cf_rcomp_Hom_def cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) lemma (in category) cf_lcomp_Hom_ArrMap_vrange: assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈" using category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_lcomp_Hom_def (*goal: ‹ℛ⇩∘ (cf_cn_cov_lcomp (ℭ::V) Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,-) (𝔉::V)⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈›*) apply - (*goal: ‹ℛ⇩∘ (cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈›*) apply (intro cf_cn_cov_lcomp_ArrMap_vrange (*‹⟦category ?α ?ℭ; ?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅; ?𝔖 : op_cat ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇⟧ ⟹ ℛ⇩∘ (cf_cn_cov_lcomp ?ℭ ?𝔖 ?𝔉⦇ArrMap⦈) ⊆⇩∘ ?𝔇⦇Arr⦈›*)) (*goals: 1. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ category ?α2 ℭ› 2. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ 𝔉 : ?𝔄2 ↦↦⇩C⇘?α2⇙ ?𝔅2› 3. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ?𝔅2 ×⇩C ℭ ↦↦⇩C⇘?α2⇙ cat_Set α› discuss goal 1*) apply (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . lemma (in category) cf_rcomp_Hom_ArrMap_vrange: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "ℛ⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈" using category_axioms (*‹category α ℭ›*) assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_rcomp_Hom_def (*goal: ‹ℛ⇩∘ (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈›*) apply - (*goal: ‹ℛ⇩∘ (cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⦇ArrMap⦈) ⊆⇩∘ cat_Set α⦇Arr⦈›*) apply (intro cf_cn_cov_rcomp_ArrMap_vrange (*‹⟦category ?α ?𝔅; ?𝔊 : ?𝔄 ↦↦⇩C⇘?α⇙ ?ℭ; ?𝔖 : op_cat ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇⟧ ⟹ ℛ⇩∘ (cf_cn_cov_rcomp ?𝔅 ?𝔖 ?𝔊⦇ArrMap⦈) ⊆⇩∘ ?𝔇⦇Arr⦈›*)) (*goals: 1. ‹⟦category (α::V) (ℭ::V); (𝔊::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ category (?α2::V) ℭ› 2. ‹⟦category (α::V) (ℭ::V); (𝔊::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ 𝔊 : (?𝔄2::V) ↦↦⇩C⇘?α2::V⇙ (?ℭ2::V)› 3. ‹⟦category (α::V) (ℭ::V); (𝔊::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C (?ℭ2::V) ↦↦⇩C⇘?α2::V⇙ cat_Set α› discuss goal 1*) apply (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . subsubsection‹Further properties› lemma cf_bcomp_Hom_cf_lcomp_Hom[cat_cs_simps]: "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,cf_id ℭ-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)" unfolding cf_lcomp_Hom_def cf_cn_cov_lcomp_def cf_bcomp_Hom_def (*goal: ‹cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 (dghm_id ℭ) = cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 (dghm_id ℭ)›*) by standard lemma cf_bcomp_Hom_cf_rcomp_Hom[cat_cs_simps]: "Hom⇩O⇩.⇩C⇘α⇙ℭ(cf_id ℭ-,𝔊-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)" unfolding cf_rcomp_Hom_def cf_cn_cov_rcomp_def cf_bcomp_Hom_def (*goal: ‹cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) (dghm_id ℭ) 𝔊 = cf_cn_cov_bcomp Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) (dghm_id ℭ) 𝔊›*) by standard subsubsection‹Composition of a ‹Hom›-functor and a functor is a functor› lemma (in category) cat_cf_lcomp_Hom_is_functor: assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) : op_cat 𝔅 ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α" using category_axioms (*‹category α ℭ›*) assms (*‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)›*) unfolding cf_lcomp_Hom_def (*goal: ‹cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉 : op_cat 𝔅 ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) apply - (*goal: ‹cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) (𝔉::V) : op_cat (𝔅::V) ×⇩C (ℭ::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) apply (intro cf_cn_cov_lcomp_is_functor (*‹⟦category (?α::V) (?ℭ::V); (?𝔉::V) : (?𝔄::V) ↦↦⇩C⇘?α⇙ (?𝔅::V); (?𝔖::V) : op_cat ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ (?𝔇::V)⟧ ⟹ cf_cn_cov_lcomp ?ℭ ?𝔖 ?𝔉 : op_cat ?𝔄 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇›*)) (*goals: 1. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ category α ℭ› 2. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ (?𝔅2::V)› 3. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat (?𝔅2::V) ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α› discuss goal 1*) apply (cs_concl cs_shallow cs_intro: cat_cs_intros) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . lemma (in category) cat_cf_lcomp_Hom_is_functor': assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "β = α" and "𝔄' = op_cat 𝔅 ×⇩C ℭ" and "𝔅' = cat_Set α" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) : 𝔄' ↦↦⇩C⇘β⇙ 𝔅'" using assms(1) (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding assms(2-4) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) : op_cat 𝔅 ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule cat_cf_lcomp_Hom_is_functor (*‹(?𝔉::V) : (?𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V) ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?𝔉-,-) : op_cat ?𝔅 ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α›*)) lemmas [cat_cs_intros] = category.cat_cf_lcomp_Hom_is_functor' lemma (in category) cat_cf_rcomp_Hom_is_functor: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-) : op_cat ℭ ×⇩C 𝔅 ↦↦⇩C⇘α⇙ cat_Set α" using category_axioms (*‹category α ℭ›*) assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding cf_rcomp_Hom_def (*goal: ‹cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) (𝔊::V) : op_cat (ℭ::V) ×⇩C (𝔅::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) apply - (*goal: ‹cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊 : op_cat ℭ ×⇩C 𝔅 ↦↦⇩C⇘α⇙ cat_Set α›*) apply (intro cf_cn_cov_rcomp_is_functor (*‹⟦category (?α::V) (?𝔅::V); (?𝔊::V) : (?𝔄::V) ↦↦⇩C⇘?α⇙ (?ℭ::V); (?𝔖::V) : op_cat ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ (?𝔇::V)⟧ ⟹ cf_cn_cov_rcomp ?𝔅 ?𝔖 ?𝔊 : op_cat ?𝔅 ×⇩C ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔇›*)) (*goals: 1. ‹⟦category α ℭ; 𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ category α ℭ› 2. ‹⟦category α ℭ; 𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ 𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ?ℭ2› 3. ‹⟦category α ℭ; 𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C ?ℭ2 ↦↦⇩C⇘α⇙ cat_Set α› discuss goal 1*) apply (cs_concl cs_shallow cs_intro: cat_cs_intros cat_op_intros) (*discuss goal 2*) apply ((msorry)[1]) (*discuss goal 3*) apply ((msorry)[1]) (*proven 3 subgoals*) . lemma (in category) cat_cf_rcomp_Hom_is_functor': assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "β = α" and "𝔄' = op_cat ℭ ×⇩C 𝔅" and "𝔅' = cat_Set α" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-) : 𝔄' ↦↦⇩C⇘β⇙ 𝔅'" using assms(1) (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) unfolding assms(2-4) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊::V-) : op_cat (ℭ::V) ×⇩C (𝔅::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) by (rule cat_cf_rcomp_Hom_is_functor (*‹(?𝔊::V) : (?𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V) ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?𝔊-) : op_cat ℭ ×⇩C ?𝔅 ↦↦⇩C⇘α⇙ cat_Set α›*)) lemmas [cat_cs_intros] = category.cat_cf_rcomp_Hom_is_functor' subsubsection‹Flip of a projections of a ‹Hom›-functor› lemma (in category) cat_bifunctor_flip_cf_rcomp_Hom: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "bifunctor_flip (op_cat ℭ) 𝔅 (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)" proof (rule cf_eqI (*‹⟦(?𝔊::V) : (?𝔄::V) ↦↦⇩C⇘?α::V⇙ (?𝔅::V); (?𝔉::V) : (?ℭ::V) ↦↦⇩C⇘?α⇙ (?𝔇::V); ?𝔊⦇ObjMap⦈ = ?𝔉⦇ObjMap⦈; ?𝔊⦇ArrMap⦈ = ?𝔉⦇ArrMap⦈; ?𝔄 = ?ℭ; ?𝔅 = ?𝔇⟧ ⟹ ?𝔊 = ?𝔉›*)) (*goals: 1. ‹bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-) : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅› 2. ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-) : ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇› 3. ‹bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈› 4. ‹bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈› 5. ‹?𝔄 = ?ℭ› 6. ‹?𝔅 = ?𝔇›*) interpret 𝔊: is_functor "α" "𝔅" "ℭ" "𝔊" by (rule assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*)) from category_axioms (*‹category α ℭ›*) assms (*‹(𝔊::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)›*) show bf_Hom: "bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-) : 𝔅 ×⇩C op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_intro: cat_cs_intros) from category_axioms (*‹category α ℭ›*) assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) show op_Hom: "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-) : 𝔅 ×⇩C op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_simp: cat_op_simps cs_intro: cat_cs_intros cat_op_intros) from bf_Hom (*‹bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊::V-) : (𝔅::V) ×⇩C op_cat (ℭ::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) have ObjMap_dom_lhs: "𝒟⇩∘ (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈" by (cs_concl cs_simp: cat_cs_simps) from op_Hom (*‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-) : 𝔅 ×⇩C op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) have ObjMap_dom_rhs: "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈" by (cs_concl cs_simp: cat_cs_simps) from bf_Hom (*‹bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-) : 𝔅 ×⇩C op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) have ArrMap_dom_lhs: "𝒟⇩∘ (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈" by (cs_concl cs_simp: cat_cs_simps) from op_Hom (*‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-) : 𝔅 ×⇩C op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) have ArrMap_dom_rhs: "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈" by (cs_concl cs_simp: cat_cs_simps) show "bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold ObjMap_dom_lhs (*‹𝒟⇩∘ (bifunctor_flip (op_cat (ℭ::V)) (𝔅::V) Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,𝔊::V-)⦇ObjMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈›*) ObjMap_dom_rhs (*‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(op_cf (𝔊::V)-,-)⦇ObjMap⦈) = ((𝔅::V) ×⇩C op_cat ℭ)⦇Obj⦈›*)) (*goals: 1. ‹vsv (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈)› 3. ‹(𝔅 ×⇩C op_cat ℭ)⦇Obj⦈ = (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈› 4. ‹⋀a. a ∈⇩∘ (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈ ⟹ bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈⦇a⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈⦇a⦈›*) fix bc assume "bc ∈⇩∘ (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈" (*‹(bc::V) ∈⇩∘ ((𝔅::V) ×⇩C op_cat (ℭ::V))⦇Obj⦈›*) then obtain b and c where bc_def: "bc = [b, c]⇩∘" and b: "b ∈⇩∘ 𝔅⦇Obj⦈" and c: "c ∈⇩∘ ℭ⦇Obj⦈" (*goal: ‹(⋀b c. ⟦bc = [b, c]⇩∘; b ∈⇩∘ 𝔅⦇Obj⦈; c ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim: cat_prod_2_ObjE[OF 𝔊.HomDom.category_axioms category_op] (*‹⟦?ab ∈⇩∘ (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈; ⋀a b. ⟦?ab = [a, b]⇩∘; a ∈⇩∘ 𝔅⦇Obj⦈; b ∈⇩∘ op_cat ℭ⦇Obj⦈⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) simp: cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 63 facts*)) from category_axioms (*‹category α ℭ›*) assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) b (*‹b ∈⇩∘ 𝔅⦇Obj⦈›*) c (*‹(c::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) show "bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈⦇bc⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈⦇bc⦈" unfolding bc_def (*goal: ‹b ⊗⇩H⇩M⇩.⇩O⇘bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⇙ c = b ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⇙ c›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 151 facts*)) (*solves the remaining goals: 1. ‹vsv (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ObjMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ObjMap⦈)› 3. ‹(𝔅 ×⇩C op_cat ℭ)⦇Obj⦈ = (𝔅 ×⇩C op_cat ℭ)⦇Obj⦈›*) show "bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold ArrMap_dom_lhs (*‹𝒟⇩∘ (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈›*) ArrMap_dom_rhs (*‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈) = (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈›*)) (*goals: 1. ‹vsv (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈)› 3. ‹(𝔅 ×⇩C op_cat ℭ)⦇Arr⦈ = (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈› 4. ‹⋀a. a ∈⇩∘ (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈ ⟹ bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈⦇a⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈⦇a⦈›*) fix gf assume "gf ∈⇩∘ (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈" (*‹(gf::V) ∈⇩∘ ((𝔅::V) ×⇩C op_cat (ℭ::V))⦇Arr⦈›*) then obtain g and f where gf_def: "gf = [g, f]⇩∘" and "g ∈⇩∘ 𝔅⦇Arr⦈" and "f ∈⇩∘ ℭ⦇Arr⦈" (*goal: ‹(⋀g f. ⟦gf = [g, f]⇩∘; g ∈⇩∘ 𝔅⦇Arr⦈; f ∈⇩∘ ℭ⦇Arr⦈⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim: cat_prod_2_ArrE[OF 𝔊.HomDom.category_axioms category_op] (*‹⟦?gf ∈⇩∘ (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈; ⋀g f. ⟦?gf = [g, f]⇩∘; g ∈⇩∘ 𝔅⦇Arr⦈; f ∈⇩∘ op_cat ℭ⦇Arr⦈⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) simp: cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 63 facts*)) then obtain a and b and c and d where g: "g : a ↦⇘𝔅⇙ b" and f: "f : c ↦⇘ℭ⇙ d" (*goal: ‹(⋀a b c d. ⟦g : a ↦⇘𝔅⇙ b; f : c ↦⇘ℭ⇙ d⟧ ⟹ thesis) ⟹ thesis›*) by (auto intro!: is_arrI (*‹⟦?f ∈⇩∘ ?ℭ⦇Arr⦈; ?ℭ⦇Dom⦈⦇?f⦈ = ?a; ?ℭ⦇Cod⦈⦇?f⦈ = ?b⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?b›*)) from category_axioms (*‹category α ℭ›*) assms (*‹𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) g (*‹g : a ↦⇘𝔅⇙ b›*) f (*‹f : c ↦⇘ℭ⇙ d›*) show "bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈⦇gf⦈ = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈⦇gf⦈" unfolding gf_def (*goal: ‹g ⊗⇩H⇩M⇩.⇩A⇘bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⇙ f = g ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⇙ f›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 151 facts*)) (*solves the remaining goals: 1. ‹vsv (bifunctor_flip (op_cat ℭ) 𝔅 Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⦇ArrMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(op_cf 𝔊-,-)⦇ArrMap⦈)› 3. ‹(𝔅 ×⇩C op_cat ℭ)⦇Arr⦈ = (𝔅 ×⇩C op_cat ℭ)⦇Arr⦈›*) qed (auto intro: cat_cs_intros (*‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) = ?a; (?c::V) = ?a; (?ℭ'::V) = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?f::V) = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ (?g'::V) ?g; is_inverse ?ℭ (?f'::V) ?f; (?f'g'::V) = ?f' ∘⇩A⇘?ℭ⇙ ?g'; (?gf::V) = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V); (?ℭ'::V) = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 151 facts*) simp: cat_op_simps (*‹op_cat (?ℭ::V)⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat (?ℭ::V)⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat (?ℭ::V)⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat (?ℭ::V)⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat (?ℭ::V)⦇CId⦈ = ?ℭ⦇CId⦈› ‹(?f::V) : (?b::V) ↦⇘op_cat (?ℭ::V)⇙ (?a::V) = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat (?ℭ::V)) (?a::V) (?b::V) = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat (?ℭ::V)) (?a::V) = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat (?ℭ::V)) (?a::V) = obj_initial ?ℭ ?a› ‹obj_null (op_cat (?ℭ::V)) (?a::V) = obj_null ?ℭ ?a› ‹category (?α::V) (?ℭ::V) ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?g::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 63 facts*)) (*solves the remaining goals: 1. ‹𝔅 ×⇩C op_cat ℭ = 𝔅 ×⇩C op_cat ℭ› 2. ‹cat_Set α = cat_Set α›*) lemmas [cat_cs_simps] = category.cat_bifunctor_flip_cf_rcomp_Hom lemma (in category) cat_bifunctor_flip_cf_lcomp_Hom: assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" shows "bifunctor_flip (op_cat 𝔅) ℭ (Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)" proof (-) (*goal: ‹bifunctor_flip (op_cat 𝔅) ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)›*) interpret 𝔉: is_functor "α" "𝔅" "ℭ" "𝔉" by (rule assms( (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ›*) 1)) note "Hom_𝔉" = category.cat_bifunctor_flip_cf_rcomp_Hom[OF category_op is_functor_op [ OF assms ], unfolded cat_op_simps, symmetric] (*‹⟦(?𝔅::V) = op_cat (𝔅::V); op_cat (ℭ::V) = op_cat ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α::V⇙ℭ(𝔉::V-,-) = bifunctor_flip ℭ ?𝔅 Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)›*) from category_axioms (*‹category α ℭ›*) assms (*‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)›*) show "?thesis" (*goal: ‹bifunctor_flip (op_cat 𝔅) ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)›*) apply (subst Hom_𝔉 (*‹⟦?𝔅 = op_cat 𝔅; op_cat ℭ = op_cat ℭ⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-) = bifunctor_flip ℭ ?𝔅 Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)›*)) (*goals: 1. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ ?𝔅2 = op_cat 𝔅› 2. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ op_cat ℭ = op_cat ℭ› 3. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ⟧ ⟹ bifunctor_flip (op_cat 𝔅) ℭ (bifunctor_flip ℭ ?𝔅2 Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,op_cf 𝔉-)› discuss goal 1*) apply (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) (*discuss goal 2*) apply (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) (*discuss goal 3*) apply (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) (*proven 3 subgoals*) . qed lemmas [cat_cs_simps] = category.cat_bifunctor_flip_cf_lcomp_Hom subsection‹Projections of the ‹Hom›-functor› text‹ The projections of the ‹Hom›-functor coincide with the definitions of the ‹Hom›-functor given in Chapter II-2 in \<^cite>‹"mac_lane_categories_2010"›. They are also exposed in the aforementioned article in nLab \<^cite>‹"noauthor_nlab_nodate"›\footnote{\url{ https://ncatlab.org/nlab/show/hom-functor }}. › subsubsection‹Definitions and elementary properties› definition cf_Hom_snd :: "V ⇒ V ⇒ V ⇒ V" (‹Hom⇩O⇩.⇩Cı_'(/_,-/')›) where "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F" definition cf_Hom_fst :: "V ⇒ V ⇒ V ⇒ V" (‹Hom⇩O⇩.⇩Cı_'(/-,_/')›) where "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(-,b)⇩C⇩F" subsubsection‹Projections of the ‹Hom›-functor are functors› lemma (in category) cat_cf_Hom_snd_is_functor: assumes "a ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) : ℭ ↦↦⇩C⇘α⇙ cat_Set α" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a::V,-) : (ℭ::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) have a: "a ∈⇩∘ op_cat ℭ⦇Obj⦈" unfolding cat_op_simps (*goal: ‹a ∈⇩∘ ℭ⦇Obj⦈›*) by simp have "op_ℭ": "category α (op_cat ℭ)" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 128 facts*)) from "op_ℭ" (*‹category α (op_cat ℭ)›*) category_axioms (*‹category α ℭ›*) cat_Hom_is_functor (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat (ℭ::V) ×⇩C ℭ ↦↦⇩C⇘α::V⇙ cat_Set α›*) a (*‹a ∈⇩∘ op_cat ℭ⦇Obj⦈›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) : ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) unfolding cf_Hom_snd_def (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F : ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule bifunctor_proj_snd_is_functor (*‹⟦category (?α::V) (?𝔄::V); category ?α (?𝔅::V); (?𝔖::V) : ?𝔄 ×⇩C ?𝔅 ↦↦⇩C⇘?α⇙ (?𝔇::V); (?a::V) ∈⇩∘ ?𝔄⦇Obj⦈⟧ ⟹ ?𝔖⇘?𝔄,?𝔅⇙(?a,-)⇩C⇩F : ?𝔅 ↦↦⇩C⇘?α⇙ ?𝔇›*)) qed lemma (in category) cat_cf_Hom_snd_is_functor': assumes "a ∈⇩∘ ℭ⦇Obj⦈" and "β = α" and "ℭ' = ℭ" and "𝔇' = cat_Set α" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) : ℭ' ↦↦⇩C⇘β⇙ 𝔇'" using assms(1) (*‹(a::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) unfolding assms(2-4) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) : ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule cat_cf_Hom_snd_is_functor (*‹(?a::V) ∈⇩∘ (ℭ::V)⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?a,-) : ℭ ↦↦⇩C⇘α::V⇙ cat_Set α›*)) lemmas [cat_cs_intros] = category.cat_cf_Hom_snd_is_functor' lemma (in category) cat_cf_Hom_fst_is_functor: assumes "b ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b::V) : op_cat (ℭ::V) ↦↦⇩C⇘α::V⇙ cat_Set α›*) have "op_ℭ": "category α (op_cat ℭ)" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 129 facts*)) from "op_ℭ" (*‹category α (op_cat ℭ)›*) category_axioms (*‹category α ℭ›*) cat_Hom_is_functor (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) assms (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) unfolding cf_Hom_fst_def (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(-,b)⇩C⇩F : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule bifunctor_proj_fst_is_functor (*‹⟦category (?α::V) (?𝔄::V); category ?α (?𝔅::V); (?𝔖::V) : ?𝔄 ×⇩C ?𝔅 ↦↦⇩C⇘?α⇙ (?𝔇::V); (?b::V) ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ ?𝔖⇘?𝔄,?𝔅⇙(-,?b)⇩C⇩F : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔇›*)) qed lemma (in category) cat_cf_Hom_fst_is_functor': assumes "b ∈⇩∘ ℭ⦇Obj⦈" and "β = α" and "ℭ' = op_cat ℭ" and "𝔇' = cat_Set α" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b) : ℭ' ↦↦⇩C⇘β⇙ 𝔇'" using assms(1) (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) unfolding assms(2-4) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule cat_cf_Hom_fst_is_functor (*‹?b ∈⇩∘ ℭ⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?b) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*)) lemmas [cat_cs_intros] = category.cat_cf_Hom_fst_is_functor' subsubsection‹Object maps› lemma (in category) cat_cf_Hom_snd_ObjMap_vsv[cat_cs_intros]: assumes "a ∈⇩∘ ℭ⦇Obj⦈" shows "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ObjMap⦈)" unfolding cf_Hom_snd_def (*goal: ‹vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F)⦇ObjMap⦈)›*) using category_axioms (*‹category α ℭ›*) assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_intros] = category.cat_cf_Hom_snd_ObjMap_vsv lemma (in category) cat_cf_Hom_fst_ObjMap_vsv[cat_cs_intros]: assumes "b ∈⇩∘ ℭ⦇Obj⦈" shows "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ObjMap⦈)" unfolding cf_Hom_fst_def (*goal: ‹vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(-,b)⇩C⇩F)⦇ObjMap⦈)›*) using category_axioms (*‹category α ℭ›*) assms (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_prod_cs_simps cat_cs_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) lemmas [cat_cs_intros] = category.cat_cf_Hom_fst_ObjMap_vsv lemma (in category) cat_cf_Hom_snd_ObjMap_vdomain[cat_cs_simps]: assumes "a ∈⇩∘ ℭ⦇Obj⦈" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ObjMap⦈) = ℭ⦇Obj⦈" using category_axioms (*‹category α ℭ›*) assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) unfolding cf_Hom_snd_def (*goal: ‹𝒟⇩∘ ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F)⦇ObjMap⦈) = ℭ⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_simps] = category.cat_cf_Hom_snd_ObjMap_vdomain lemma (in category) cat_cf_Hom_fst_ObjMap_vdomain[cat_cs_simps]: assumes "b ∈⇩∘ ℭ⦇Obj⦈" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ObjMap⦈) = op_cat ℭ⦇Obj⦈" using category_axioms (*‹category α ℭ›*) assms (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) unfolding cf_Hom_fst_def (*goal: ‹𝒟⇩∘ ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(-,b)⇩C⇩F)⦇ObjMap⦈) = op_cat ℭ⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_simps] = category.cat_cf_Hom_fst_ObjMap_vdomain lemma (in category) cat_cf_Hom_snd_ObjMap_app[cat_cs_simps]: assumes "a ∈⇩∘ op_cat ℭ⦇Obj⦈" and "b ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ObjMap⦈⦇b⦈ = Hom ℭ a b" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ObjMap⦈⦇b⦈ = Hom ℭ a b›*) from assms (*‹a ∈⇩∘ op_cat ℭ⦇Obj⦈› ‹(b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) have ab: "[a, b]⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" apply (intro cat_prod_2_ObjI (*‹⟦category ?α ?𝔄; category ?α ?𝔅; ?a ∈⇩∘ ?𝔄⦇Obj⦈; ?b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ [?a, ?b]⇩∘ ∈⇩∘ (?𝔄 ×⇩C ?𝔅)⦇Obj⦈›*)) (*goals: 1. ‹⟦(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈; (b::V) ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ category (?α2::V) (op_cat ℭ)› 2. ‹⟦(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈; (b::V) ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ category (?α2::V) ℭ› 3. ‹⟦(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈; (b::V) ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ a ∈⇩∘ op_cat ℭ⦇Obj⦈› 4. ‹⟦(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈; (b::V) ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ b ∈⇩∘ ℭ⦇Obj⦈› discuss goal 1*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*discuss goal 2*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*discuss goal 3*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*discuss goal 4*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*proven 4 subgoals*) . show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(a::V,-)⦇ObjMap⦈⦇(b::V)⦈ = Hom ℭ a b›*) unfolding cf_Hom_snd_def bifunctor_proj_snd_ObjMap_app[OF category_op category_axioms ab] cf_Hom_ObjMap_app[OF ab] (*goal: ‹Hom ℭ a b = Hom ℭ a b›*) by standard qed lemmas [cat_cs_simps] = category.cat_cf_Hom_snd_ObjMap_app lemma (in category) cat_cf_Hom_fst_ObjMap_app[cat_cs_simps]: assumes "b ∈⇩∘ ℭ⦇Obj⦈" and "a ∈⇩∘ op_cat ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ObjMap⦈⦇a⦈ = Hom ℭ a b" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ObjMap⦈⦇a⦈ = Hom ℭ a b›*) from assms (*‹b ∈⇩∘ ℭ⦇Obj⦈› ‹(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈›*) have ab: "[a, b]⇩∘ ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" apply (intro cat_prod_2_ObjI (*‹⟦category ?α ?𝔄; category ?α ?𝔅; ?a ∈⇩∘ ?𝔄⦇Obj⦈; ?b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ [?a, ?b]⇩∘ ∈⇩∘ (?𝔄 ×⇩C ?𝔅)⦇Obj⦈›*)) (*goals: 1. ‹⟦(b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈; (a::V) ∈⇩∘ op_cat ℭ⦇Obj⦈⟧ ⟹ category (?α2::V) (op_cat ℭ)› 2. ‹⟦(b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈; (a::V) ∈⇩∘ op_cat ℭ⦇Obj⦈⟧ ⟹ category (?α2::V) ℭ› 3. ‹⟦(b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈; (a::V) ∈⇩∘ op_cat ℭ⦇Obj⦈⟧ ⟹ a ∈⇩∘ op_cat ℭ⦇Obj⦈› 4. ‹⟦(b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈; (a::V) ∈⇩∘ op_cat ℭ⦇Obj⦈⟧ ⟹ b ∈⇩∘ ℭ⦇Obj⦈› discuss goal 1*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*discuss goal 2*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*discuss goal 3*) apply ((auto intro: cat_cs_intros (*‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) = ?a; (?c::V) = ?a; (?ℭ'::V) = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?f::V) = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?gf::V) = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category (?α::V) (?ℭ::V); (?a::V) ∈⇩∘ ?ℭ⦇Obj⦈; (?b::V) ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; (?ℭ'::V) = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ (?g'::V) ?g; is_inverse ?ℭ (?f'::V) ?f; (?f'g'::V) = ?f' ∘⇩A⇘?ℭ⇙ ?g'; (?gf::V) = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V); (?ℭ'::V) = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*discuss goal 4*) apply ((auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 134 facts*))[1]) (*proven 4 subgoals*) . show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ObjMap⦈⦇a⦈ = Hom ℭ a b›*) unfolding cf_Hom_fst_def bifunctor_proj_fst_ObjMap_app[OF category_op category_axioms ab] cf_Hom_ObjMap_app[OF ab] (*goal: ‹Hom (ℭ::V) (a::V) (b::V) = Hom ℭ a b›*) by standard qed lemmas [cat_cs_simps] = category.cat_cf_Hom_fst_ObjMap_app subsubsection‹Arrow maps› lemma (in category) cat_cf_Hom_snd_ArrMap_vsv[cat_cs_intros]: assumes "a ∈⇩∘ op_cat ℭ⦇Obj⦈" shows "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ArrMap⦈)" unfolding cf_Hom_snd_def (*goal: ‹vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F)⦇ArrMap⦈)›*) using category_axioms (*‹category α ℭ›*) assms (*‹a ∈⇩∘ op_cat ℭ⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: bifunctor_proj_snd_ArrMap_vsv cat_cs_intros cat_op_intros) lemmas [cat_cs_intros] = category.cat_cf_Hom_snd_ArrMap_vsv lemma (in category) cat_cf_Hom_fst_ArrMap_vsv[cat_cs_intros]: assumes "b ∈⇩∘ ℭ⦇Obj⦈" shows "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ArrMap⦈)" unfolding cf_Hom_fst_def (*goal: ‹vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(-,b)⇩C⇩F)⦇ArrMap⦈)›*) using category_axioms (*‹category (α::V) (ℭ::V)›*) assms (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: bifunctor_proj_fst_ArrMap_vsv cat_cs_intros cat_op_intros) lemmas [cat_cs_intros] = category.cat_cf_Hom_fst_ArrMap_vsv lemma (in category) cat_cf_Hom_snd_ArrMap_vdomain[cat_cs_simps]: assumes "a ∈⇩∘ op_cat ℭ⦇Obj⦈" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ArrMap⦈) = ℭ⦇Arr⦈" using category_axioms (*‹category α ℭ›*) assms (*‹a ∈⇩∘ op_cat ℭ⦇Obj⦈›*) unfolding cf_Hom_snd_def (*goal: ‹𝒟⇩∘ ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F)⦇ArrMap⦈) = ℭ⦇Arr⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_simps] = category.cat_cf_Hom_snd_ArrMap_vdomain lemma (in category) cat_cf_Hom_fst_ArrMap_vdomain[cat_cs_simps]: assumes "b ∈⇩∘ ℭ⦇Obj⦈" shows "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ArrMap⦈) = op_cat ℭ⦇Arr⦈" using category_axioms (*‹category α ℭ›*) assms (*‹(b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) unfolding cf_Hom_fst_def (*goal: ‹𝒟⇩∘ ((Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⇘op_cat ℭ,ℭ⇙(-,(b::V))⇩C⇩F)⦇ArrMap⦈) = op_cat ℭ⦇Arr⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_simps] = category.cat_cf_Hom_fst_ArrMap_vdomain lemma (in category) cat_cf_Hom_snd_ArrMap_app[cat_cs_simps]: assumes "a ∈⇩∘ op_cat ℭ⦇Obj⦈" and "f : b ↦⇘ℭ⇙ b'" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ArrMap⦈⦇f⦈ = cf_hom ℭ [op_cat ℭ⦇CId⦈⦇a⦈, f]⇩∘" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ArrMap⦈⦇f⦈ = cf_hom ℭ [op_cat ℭ⦇CId⦈⦇a⦈, f]⇩∘›*) from assms(2) (*‹f : b ↦⇘ℭ⇙ b'›*) have f: "f ∈⇩∘ ℭ⦇Arr⦈" by (simp add: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 138 facts*)) from category_axioms (*‹category (α::V) (ℭ::V)›*) assms (*‹a ∈⇩∘ op_cat ℭ⦇Obj⦈› ‹f : b ↦⇘ℭ⇙ b'›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ArrMap⦈⦇f⦈ = cf_hom ℭ [op_cat ℭ⦇CId⦈⦇a⦈, f]⇩∘›*) unfolding cf_Hom_snd_def bifunctor_proj_snd_ArrMap_app[OF category_op category_axioms assms ( 1 ) f] cat_op_simps (*goal: ‹ℭ⦇CId⦈⦇a⦈ ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ f = cf_hom ℭ [ℭ⦇CId⦈⦇a⦈, f]⇩∘›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed lemmas [cat_cs_simps] = category.cat_cf_Hom_snd_ArrMap_app lemma (in category) cat_cf_Hom_fst_ArrMap_app[cat_cs_simps]: assumes "b ∈⇩∘ ℭ⦇Obj⦈" and "f : a ↦⇘op_cat ℭ⇙ a'" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ArrMap⦈⦇f⦈ = cf_hom ℭ [f, ℭ⦇CId⦈⦇b⦈]⇩∘" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,b::V)⦇ArrMap⦈⦇(f::V)⦈ = cf_hom ℭ [f, ℭ⦇CId⦈⦇b⦈]⇩∘›*) from assms(2) (*‹f : a ↦⇘op_cat ℭ⇙ a'›*) have f: "f ∈⇩∘ op_cat ℭ⦇Arr⦈" by (simp add: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 138 facts*)) with category_axioms (*‹category α ℭ›*) assms (*‹b ∈⇩∘ ℭ⦇Obj⦈› ‹f : a ↦⇘op_cat ℭ⇙ a'›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ArrMap⦈⦇f⦈ = cf_hom ℭ [f, ℭ⦇CId⦈⦇b⦈]⇩∘›*) unfolding cf_Hom_fst_def bifunctor_proj_fst_ArrMap_app[OF category_op category_axioms assms ( 1 ) f] (*goal: ‹(f::V) ⊗⇩H⇩M⇩.⇩A⇘Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⇙ ℭ⦇CId⦈⦇(b::V)⦈ = cf_hom ℭ [f, ℭ⦇CId⦈⦇b⦈]⇩∘›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed lemmas [cat_cs_simps] = category.cat_cf_Hom_fst_ArrMap_app subsubsection‹Opposite ‹Hom›-functor projections› lemma (in category) cat_op_cat_cf_Hom_snd: assumes "a ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)" proof (rule cf_eqI[of α] (*‹⟦(?𝔊::V) : (?𝔄::V) ↦↦⇩C⇘α::V⇙ (?𝔅::V); (?𝔉::V) : (?ℭ::V) ↦↦⇩C⇘α⇙ (?𝔇::V); ?𝔊⦇ObjMap⦈ = ?𝔉⦇ObjMap⦈; ?𝔊⦇ArrMap⦈ = ?𝔉⦇ArrMap⦈; ?𝔄 = ?ℭ; ?𝔅 = ?𝔇⟧ ⟹ ?𝔊 = ?𝔉›*)) (*goals: 1. ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-) : ?𝔄 ↦↦⇩C⇘α⇙ ?𝔅› 2. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a) : ?ℭ ↦↦⇩C⇘α⇙ ?𝔇› 3. ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈› 4. ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈› 5. ‹?𝔄 = ?ℭ› 6. ‹?𝔅 = ?𝔇›*) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) from assms (*‹(a::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) show "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*)) (*goals: 1. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈)› 3. ‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈) = 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈)› 4. ‹⋀aa. aa ∈⇩∘ 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈) ⟹ Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈⦇aa⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈⦇aa⦈›*) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈)" apply (intro is_functor.cf_ObjMap_vsv (*‹?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅 ⟹ vsv (?𝔉⦇ObjMap⦈)›*)) (*goal: ‹vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈)›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈)" apply (intro is_functor.cf_ObjMap_vsv (*‹?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅 ⟹ vsv (?𝔉⦇ObjMap⦈)›*)) (*goal: ‹vsv (Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,a::V)⦇ObjMap⦈)›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈) = 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈)" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) show "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈⦇b⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈⦇b⦈" if "b ∈⇩∘ 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈)" for b proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈⦇b⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈⦇b⦈›*) from that (*‹b ∈⇩∘ 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈)›*) have "b ∈⇩∘ ℭ⦇Obj⦈" by (simp add: category.cat_cf_Hom_snd_ObjMap_vdomain[ OF category_op, unfolded cat_op_simps, OF assms (*‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(a::V,-)⦇ObjMap⦈) = ℭ⦇Obj⦈›*) ]) from category_axioms (*‹category α ℭ›*) assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) this (*‹b ∈⇩∘ ℭ⦇Obj⦈›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ObjMap⦈⦇b⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈⦇b⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_op_intros) qed qed show "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*)) (*goals: 1. ‹vsv (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(a::V,-)⦇ArrMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,a::V)⦇ArrMap⦈)› 3. ‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(a::V,-)⦇ArrMap⦈) = 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈)› 4. ‹⋀aa::V. aa ∈⇩∘ 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(a::V,-)⦇ArrMap⦈) ⟹ Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈⦇aa⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈⦇aa⦈›*) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category (α::V) (ℭ::V)›*) show "vsv (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈)" apply (intro is_functor.cf_ArrMap_vsv (*‹?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅 ⟹ vsv (?𝔉⦇ArrMap⦈)›*)) (*goal: ‹vsv (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(a::V,-)⦇ArrMap⦈)›*) by (cs_concl cs_shallow cs_intro: cat_cs_intros cat_op_intros) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈)" apply (intro is_functor.cf_ArrMap_vsv (*‹?𝔉 : ?𝔄 ↦↦⇩C⇘?α⇙ ?𝔅 ⟹ vsv (?𝔉⦇ArrMap⦈)›*)) (*goal: ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈)›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) show "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈) = 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈)" by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_op_intros) show "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈⦇f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈⦇f⦈" if "f ∈⇩∘ 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈)" for f proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈⦇f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈⦇f⦈›*) from that (*‹f ∈⇩∘ 𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈)›*) have "f ∈⇩∘ ℭ⦇Arr⦈" by (simp add: category.cat_cf_Hom_snd_ArrMap_vdomain[ OF category_op, unfolded cat_op_simps, OF assms (*‹𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(a::V,-)⦇ArrMap⦈) = ℭ⦇Arr⦈›*) ]) then obtain a and b where "f : a ↦⇘ℭ⇙ b" (*goal: ‹(⋀a b. f : a ↦⇘ℭ⇙ b ⟹ thesis) ⟹ thesis›*) by auto from category_axioms (*‹category (α::V) (ℭ::V)›*) assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) this (*‹f : a ↦⇘ℭ⇙ b›*) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(a,-)⦇ArrMap⦈⦇f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ArrMap⦈⦇f⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) qed qed qed (simp_all) (*solves the remaining goals: 1. ‹op_cat (ℭ::V) = op_cat ℭ› 2. ‹cat_Set (α::V) = cat_Set α›*) lemmas [cat_op_simps] = category.cat_op_cat_cf_Hom_snd lemma (in category) cat_op_cat_cf_Hom_fst: assumes "a ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,a) = Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α::V⇙op_cat (ℭ::V)(-,a::V) = Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)›*) from assms (*‹a ∈⇩∘ ℭ⦇Obj⦈›*) have a: "a ∈⇩∘ op_cat ℭ⦇Obj⦈" unfolding cat_op_simps (*goal: ‹a ∈⇩∘ ℭ⦇Obj⦈›*) . have "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙op_cat (op_cat ℭ)(a,-)" unfolding cat_op_simps (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)›*) by standard also (*calculation: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙op_cat (op_cat ℭ)(a,-)›*) have "… = Hom⇩O⇩.⇩C⇘α⇙(op_cat ℭ)(-,a)" unfolding category.cat_op_cat_cf_Hom_snd[OF category_op a] (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,a) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,a)›*) by simp finally (*calculation: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙op_cat ℭ(-,a)›*) show "Hom⇩O⇩.⇩C⇘α⇙(op_cat ℭ)(-,a) = Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)" by simp qed lemmas [cat_op_simps] = category.cat_op_cat_cf_Hom_fst subsubsection‹‹Hom›-functors are injections on objects› lemma (in category) cat_cf_Hom_snd_inj: assumes "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-)" and "a ∈⇩∘ ℭ⦇Obj⦈" and "b ∈⇩∘ ℭ⦇Obj⦈" shows "a = b" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹a ≠ b ⟹ False›*) assume prems: "a ≠ b" (*‹(a::V) ≠ (b::V)›*) from assms(1) (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-)›*) have "Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-)⦇ObjMap⦈⦇b⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-)⦇ObjMap⦈⦇b⦈" by simp then have "Hom ℭ a b = Hom ℭ b b" unfolding cat_cf_Hom_snd_ObjMap_app[unfolded cat_op_simps, OF assms ( 2 , 3 )] cat_cf_Hom_snd_ObjMap_app[unfolded cat_op_simps, OF assms ( 3 , 3 )] (*goal: ‹Hom ℭ a b = Hom ℭ b b›*) by simp with assms (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) = Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-)› ‹a ∈⇩∘ ℭ⦇Obj⦈› ‹b ∈⇩∘ ℭ⦇Obj⦈›*) prems (*‹a ≠ b›*) show False by (force intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 138 facts*)) qed lemma (in category) cat_cf_Hom_fst_inj: assumes "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)" and "a ∈⇩∘ ℭ⦇Obj⦈" and "b ∈⇩∘ ℭ⦇Obj⦈" shows "a = b" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹(a::V) ≠ (b::V) ⟹ False›*) assume prems: "a ≠ b" (*‹(a::V) ≠ (b::V)›*) from assms(1) (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)›*) have "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a)⦇ObjMap⦈⦇b⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b)⦇ObjMap⦈⦇b⦈" by simp then have "Hom ℭ b a = Hom ℭ b b" unfolding cat_cf_Hom_fst_ObjMap_app[unfolded cat_op_simps, OF assms ( 2 , 3 )] cat_cf_Hom_fst_ObjMap_app[unfolded cat_op_simps, OF assms ( 3 , 3 )] (*goal: ‹Hom ℭ b a = Hom ℭ b b›*) by simp with assms (*‹Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,a::V) = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,b::V)› ‹a ∈⇩∘ ℭ⦇Obj⦈› ‹b ∈⇩∘ ℭ⦇Obj⦈›*) prems (*‹a ≠ b›*) show False by (force intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 138 facts*)) qed subsubsection‹‹Hom›-functor is an array bifunctor› lemma (in category) cat_cf_Hom_is_cf_array: ―‹See Chapter II-3 in \cite{mac_lane_categories_2010}.› "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) = cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)" proof (rule cf_eqI[of α] (*‹⟦?𝔊 : ?𝔄 ↦↦⇩C⇘α⇙ ?𝔅; ?𝔉 : ?ℭ ↦↦⇩C⇘α⇙ ?𝔇; ?𝔊⦇ObjMap⦈ = ?𝔉⦇ObjMap⦈; ?𝔊⦇ArrMap⦈ = ?𝔉⦇ArrMap⦈; ?𝔄 = ?ℭ; ?𝔅 = ?𝔇⟧ ⟹ ?𝔊 = ?𝔉›*)) (*goals: 1. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : ?𝔄 ↦↦⇩C⇘α⇙ ?𝔅› 2. ‹cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ) : ?ℭ ↦↦⇩C⇘α⇙ ?𝔇› 3. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈ = cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ObjMap⦈› 4. ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈ = cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ArrMap⦈› 5. ‹?𝔄 = ?ℭ› 6. ‹?𝔅 = ?𝔇›*) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (rule cat_Hom_is_functor (*‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) : op_cat (ℭ::V) ×⇩C ℭ ↦↦⇩C⇘α::V⇙ cat_Set α›*)) have c1: "category α (op_cat ℭ)" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 138 facts*)) have c2: "category α ℭ" by (auto intro: cat_cs_intros (*‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b = ?a; ?c = ?a; ?ℭ' = ?ℭ⟧ ⟹ ?ℭ⦇CId⦈⦇?a⦈ : ?b ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?f = ?ℭ⦇CId⦈⦇?a⦈⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?a› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?gf = [?g, ?f]⇩∘⟧ ⟹ ?gf ∈⇩∘ 𝒟⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?a ∈⇩∘ ?ℭ⦇Obj⦈; ?b ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ Hom ?ℭ ?a ?b ∈⇩∘ Vset ?α› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?a ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?b ∈⇩∘ ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ'⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘?ℭ⇙ ?f : ?a ↦⇘?ℭ⇙ ?c› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b; is_inverse ?ℭ ?g' ?g; is_inverse ?ℭ ?f' ?f; ?f'g' = ?f' ∘⇩A⇘?ℭ⇙ ?g'; ?gf = ?g ∘⇩A⇘?ℭ⇙ ?f⟧ ⟹ is_inverse ?ℭ ?f'g' ?gf› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b; ?ℭ' = ?ℭ⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ : ?b ↦⇩i⇩s⇩o⇘?ℭ'⇙ ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?f ∈⇩∘ ?ℭ⦇Arr⦈› and more 138 facts*)) have c3: "category α (cat_Set α)" by (simp add: category_cat_Set (*‹category α (cat_Set α)›*)) have c4: "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,c) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" if "c ∈⇩∘ ℭ⦇Obj⦈" for c using that (*‹(c::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) by (rule cat_cf_Hom_fst_is_functor (*‹?b ∈⇩∘ ℭ⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?b) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*)) have c5: "Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-) : ℭ ↦↦⇩C⇘α⇙ cat_Set α" if "b ∈⇩∘ op_cat ℭ⦇Obj⦈" for b using that (*‹(b::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈›*) unfolding cat_op_simps (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-) : ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) by (rule cat_cf_Hom_snd_is_functor (*‹?a ∈⇩∘ ℭ⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?a,-) : ℭ ↦↦⇩C⇘α⇙ cat_Set α›*)) have c6: "Hom⇩O⇩.⇩C⇘α⇙ℭ(b,-)⦇ObjMap⦈⦇c⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,c)⦇ObjMap⦈⦇b⦈" if "b ∈⇩∘ op_cat ℭ⦇Obj⦈" and "c ∈⇩∘ ℭ⦇Obj⦈" for b and c using that (*‹(b::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈› ‹c ∈⇩∘ ℭ⦇Obj⦈›*) category_axioms (*‹category α ℭ›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros) have c7: "Hom⇩O⇩.⇩C⇘α⇙ℭ(b',-)⦇ArrMap⦈⦇g⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,c)⦇ArrMap⦈⦇f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,c' )⦇ArrMap⦈⦇f⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(b,- )⦇ArrMap⦈⦇g⦈" if "f : b ↦⇘op_cat ℭ⇙ b'" and "g : c ↦⇘ℭ⇙ c'" for b and c and b' and c' and f and g using that (*‹f : b ↦⇘op_cat ℭ⇙ b'› ‹g : c ↦⇘ℭ⇙ c'›*) category_axioms (*‹category α ℭ›*) unfolding cat_op_simps (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ::V(b'::V,-)⦇ArrMap⦈⦇(g::V)⦈ ∘⇩A⇘cat_Set (α::V)⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,c::V)⦇ArrMap⦈⦇(f::V)⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,c'::V)⦇ArrMap⦈⦇f⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(b::V,-)⦇ArrMap⦈⦇g⦈›*) by (cs_concl cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) let ?cfa = "cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)" note cf_array_specification = cf_array_specification[OF c1 c2 c3 c4 c5 c6 c7, simplified] (*‹cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ) : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α› ‹⟦?b ∈⇩∘ op_cat ℭ⦇Obj⦈; ?c ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ ?b ⊗⇩H⇩M⇩.⇩O⇘cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⇙ ?c = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?c)⦇ObjMap⦈⦇?b⦈› ‹⟦?b ∈⇩∘ op_cat ℭ⦇Obj⦈; ?c ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ ?b ⊗⇩H⇩M⇩.⇩O⇘cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⇙ ?c = Hom⇩O⇩.⇩C⇘α⇙ℭ(?b,-)⦇ObjMap⦈⦇?c⦈› ‹⟦(?f::V) : (?a::V) ↦⇘op_cat (ℭ::V)⇙ (?b::V); (?c::V) ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ ?f ⊗⇩H⇩M⇩.⇩A⇘cf_array (op_cat ℭ) ℭ (cat_Set (α::V)) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⇙ ℭ⦇CId⦈⦇?c⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?c)⦇ArrMap⦈⦇?f⦈› ‹⟦(?g::V) : (?a::V) ↦⇘ℭ::V⇙ (?b::V); (?c::V) ∈⇩∘ op_cat ℭ⦇Obj⦈⟧ ⟹ op_cat ℭ⦇CId⦈⦇?c⦈ ⊗⇩H⇩M⇩.⇩A⇘cf_array (op_cat ℭ) ℭ (cat_Set (α::V)) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⇙ ?g = Hom⇩O⇩.⇩C⇘α⇙ℭ(?c,-)⦇ArrMap⦈⦇?g⦈›*) from c1 (*‹category (α::V) (op_cat (ℭ::V))›*) c2 (*‹category α ℭ›*) c3 (*‹category α (cat_Set α)›*) c4 (*‹?c ∈⇩∘ ℭ⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?c) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α›*) c5 (*‹(?b::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?b,-) : ℭ ↦↦⇩C⇘α::V⇙ cat_Set α›*) c6 (*‹⟦?b ∈⇩∘ op_cat ℭ⦇Obj⦈; ?c ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?b,-)⦇ObjMap⦈⦇?c⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?c)⦇ObjMap⦈⦇?b⦈›*) c7 (*‹⟦?f : ?b ↦⇘op_cat ℭ⇙ ?b'; ?g : ?c ↦⇘ℭ⇙ ?c'⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(?b',-)⦇ArrMap⦈⦇?g⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?c)⦇ArrMap⦈⦇?f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?c')⦇ArrMap⦈⦇?f⦈ ∘⇩A⇘cat_Set α⇙ Hom⇩O⇩.⇩C⇘α⇙ℭ(?b,-)⦇ArrMap⦈⦇?g⦈›*) show "?cfa : op_cat ℭ ×⇩C ℭ ↦↦⇩C⇘α⇙ cat_Set α" apply (rule cf_array_is_functor (*‹⟦category ?α ?𝔅; category ?α ?ℭ; category ?α ?𝔇; ⋀c. c ∈⇩∘ ?ℭ⦇Obj⦈ ⟹ ?𝔉 c : ?𝔅 ↦↦⇩C⇘?α⇙ ?𝔇; ⋀b. b ∈⇩∘ ?𝔅⦇Obj⦈ ⟹ ?𝔊 b : ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇; ⋀b c. ⟦b ∈⇩∘ ?𝔅⦇Obj⦈; c ∈⇩∘ ?ℭ⦇Obj⦈⟧ ⟹ ?𝔊 b⦇ObjMap⦈⦇c⦈ = ?𝔉 c⦇ObjMap⦈⦇b⦈; ⋀b c b' c' f g. ⟦f : b ↦⇘?𝔅⇙ b'; g : c ↦⇘?ℭ⇙ c'⟧ ⟹ ?𝔊 b'⦇ArrMap⦈⦇g⦈ ∘⇩A⇘?𝔇⇙ ?𝔉 c⦇ArrMap⦈⦇f⦈ = ?𝔉 c'⦇ArrMap⦈⦇f⦈ ∘⇩A⇘?𝔇⇙ ?𝔊 b⦇ArrMap⦈⦇g⦈⟧ ⟹ cf_array ?𝔅 ?ℭ ?𝔇 ?𝔉 ?𝔊 : ?𝔅 ×⇩C ?ℭ ↦↦⇩C⇘?α⇙ ?𝔇›*)) (*goals: 1. ‹⋀c. c ∈⇩∘ ℭ⦇Obj⦈ ⟹ c ∈⇩∘ ℭ⦇Obj⦈› 2. ‹⋀b. b ∈⇩∘ op_cat ℭ⦇Obj⦈ ⟹ b ∈⇩∘ op_cat ℭ⦇Obj⦈› 3. ‹⋀b c. ⟦b ∈⇩∘ op_cat ℭ⦇Obj⦈; c ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ b ∈⇩∘ op_cat ℭ⦇Obj⦈› 4. ‹⋀b c. ⟦b ∈⇩∘ op_cat ℭ⦇Obj⦈; c ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ c ∈⇩∘ ℭ⦇Obj⦈› 5. ‹⋀b c b' c' f g. ⟦f : b ↦⇘op_cat ℭ⇙ b'; g : c ↦⇘ℭ⇙ c'⟧ ⟹ f : b ↦⇘op_cat ℭ⇙ b'› 6. ‹⋀b c b' c' f g. ⟦f : b ↦⇘op_cat ℭ⇙ b'; g : c ↦⇘ℭ⇙ c'⟧ ⟹ g : c ↦⇘ℭ⇙ c'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) apply ((assumption)[1]) (*discuss goal 5*) apply ((assumption)[1]) (*discuss goal 6*) . (*proven 6 subgoals*) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈ = ?cfa⦇ObjMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 305 facts*)) (*goals: 1. ‹vsv (Hom⇩O⇩.⇩C⇘α::V⇙ℭ::V(-,-)⦇ObjMap⦈)› 2. ‹vsv (cf_array (op_cat (ℭ::V)) ℭ (cat_Set (α::V)) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ObjMap⦈)› 3. ‹(op_cat (ℭ::V) ×⇩C ℭ)⦇Obj⦈ = (op_cat ℭ ×⇩C ℭ)⦇Obj⦈› 4. ‹⋀a::V. a ∈⇩∘ (op_cat (ℭ::V) ×⇩C ℭ)⦇Obj⦈ ⟹ Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,-)⦇ObjMap⦈⦇a⦈ = cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ObjMap⦈⦇a⦈›*) fix aa' assume "aa' ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈" (*‹(aa'::V) ∈⇩∘ (op_cat (ℭ::V) ×⇩C ℭ)⦇Obj⦈›*) then obtain a and a' where aa'_def: "aa' = [a, a']⇩∘" and a: "a ∈⇩∘ op_cat ℭ⦇Obj⦈" and a': "a' ∈⇩∘ ℭ⦇Obj⦈" (*goal: ‹(⋀a a'. ⟦aa' = [a, a']⇩∘; a ∈⇩∘ op_cat ℭ⦇Obj⦈; a' ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ thesis) ⟹ thesis›*) by (elim cat_prod_2_ObjE[OF c1 c2] (*‹⟦?ab ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Obj⦈; ⋀a b. ⟦?ab = [a, b]⇩∘; a ∈⇩∘ op_cat ℭ⦇Obj⦈; b ∈⇩∘ ℭ⦇Obj⦈⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) from category_axioms (*‹category α ℭ›*) a (*‹(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈›*) a' (*‹(a'::V) ∈⇩∘ (ℭ::V)⦇Obj⦈›*) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈⦇aa'⦈ = ?cfa⦇ObjMap⦈⦇aa'⦈" unfolding aa'_def cf_array_specification(2)[OF a a'] cat_op_simps (*goal: ‹a ⊗⇩H⇩M⇩.⇩O⇘Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇙ a' = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,a')⦇ObjMap⦈⦇a⦈›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_op_intros cat_prod_cs_intros) qed (auto simp: cf_array_ObjMap_vsv (*‹vsv (cf_array ?𝔅 ?ℭ ?𝔇 ?𝔉 ?𝔊⦇ObjMap⦈)›*) cf_Hom_ObjMap_vsv (*‹vsv (Hom⇩O⇩.⇩C⇘?α⇙?ℭ(-,-)⦇ObjMap⦈)›*) cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 305 facts*)) (*solves the remaining goals: 1. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ObjMap⦈)› 2. ‹vsv (cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ObjMap⦈)› 3. ‹(op_cat ℭ ×⇩C ℭ)⦇Obj⦈ = (op_cat ℭ ×⇩C ℭ)⦇Obj⦈›*) show "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈ = ?cfa⦇ArrMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 305 facts*)) (*goals: 1. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈)› 2. ‹vsv (cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ArrMap⦈)› 3. ‹(op_cat ℭ ×⇩C ℭ)⦇Arr⦈ = (op_cat ℭ ×⇩C ℭ)⦇Arr⦈› 4. ‹⋀a. a ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Arr⦈ ⟹ cf_hom ℭ a = cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ArrMap⦈⦇a⦈›*) fix ff' assume "ff' ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Arr⦈" (*‹(ff'::V) ∈⇩∘ (op_cat (ℭ::V) ×⇩C ℭ)⦇Arr⦈›*) then obtain f and f' where ff'_def: "ff' = [f, f']⇩∘" and f: "f ∈⇩∘ op_cat ℭ⦇Arr⦈" and f': "f' ∈⇩∘ ℭ⦇Arr⦈" (*goal: ‹(⋀f f'. ⟦ff' = [f, f']⇩∘; f ∈⇩∘ op_cat ℭ⦇Arr⦈; f' ∈⇩∘ ℭ⦇Arr⦈⟧ ⟹ thesis) ⟹ thesis›*) by (elim cat_prod_2_ArrE[OF c1 c2] (*‹⟦?gf ∈⇩∘ (op_cat ℭ ×⇩C ℭ)⦇Arr⦈; ⋀g f. ⟦?gf = [g, f]⇩∘; g ∈⇩∘ op_cat ℭ⦇Arr⦈; f ∈⇩∘ ℭ⦇Arr⦈⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) then obtain a and b and a' and b' where f: "f : a ↦⇘op_cat ℭ⇙ b" and f': "f' : a' ↦⇘ℭ⇙ b'" (*goal: ‹(⋀a b a' b'. ⟦f : a ↦⇘op_cat ℭ⇙ b; f' : a' ↦⇘ℭ⇙ b'⟧ ⟹ thesis) ⟹ thesis›*) by (blast intro: is_arrI (*‹⟦(?f::V) ∈⇩∘ (?ℭ::V)⦇Arr⦈; ?ℭ⦇Dom⦈⦇?f⦈ = (?a::V); ?ℭ⦇Cod⦈⦇?f⦈ = (?b::V)⟧ ⟹ ?f : ?a ↦⇘?ℭ⇙ ?b›*)) from category_axioms (*‹category (α::V) (ℭ::V)›*) f (*‹f : a ↦⇘op_cat ℭ⇙ b›*) f' (*‹f' : a' ↦⇘ℭ⇙ b'›*) show "cf_hom ℭ ff' = ?cfa⦇ArrMap⦈⦇ff'⦈" unfolding ff'_def cat_op_simps (*goal: ‹cf_hom (ℭ::V) [f::V, f'::V]⇩∘ = f ⊗⇩H⇩M⇩.⇩A⇘cf_array (op_cat ℭ) ℭ (cat_Set (α::V)) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⇙ f'›*) by (cs_concl cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros) qed (auto simp: cf_array_ArrMap_vsv (*‹vsv (cf_array ?𝔅 ?ℭ ?𝔇 ?𝔉 ?𝔊⦇ArrMap⦈)›*) cf_Hom_ArrMap_vsv (*‹vsv (Hom⇩O⇩.⇩C⇘?α⇙?ℭ(-,-)⦇ArrMap⦈)›*) cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 305 facts*)) (*solves the remaining goals: 1. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⦇ArrMap⦈)› 2. ‹vsv (cf_array (op_cat ℭ) ℭ (cat_Set α) (cf_Hom_fst α ℭ) (cf_Hom_snd α ℭ)⦇ArrMap⦈)› 3. ‹(op_cat ℭ ×⇩C ℭ)⦇Arr⦈ = (op_cat ℭ ×⇩C ℭ)⦇Arr⦈›*) qed (simp_all) (*solves the remaining goals: 1. ‹op_cat ℭ ×⇩C ℭ = op_cat ℭ ×⇩C ℭ› 2. ‹cat_Set α = cat_Set α›*) subsubsection‹ Projections of the compositions of a ‹Hom›-functor and a functor are projections of the ‹Hom›-functor › lemma (in category) cat_cf_rcomp_Hom_cf_Hom_snd: assumes "𝔊 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "a ∈⇩∘ ℭ⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔊-)⇘op_cat ℭ,𝔅⇙(a,-)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(a,-) ∘⇩C⇩F 𝔊" using category_axioms (*‹category α ℭ›*) assms (*‹(𝔊::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)› ‹a ∈⇩∘ ℭ⦇Obj⦈›*) unfolding cf_rcomp_Hom_def cf_Hom_snd_def (*goal: ‹cf_cn_cov_rcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔊⇘op_cat ℭ,𝔅⇙(a,-)⇩C⇩F = (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(a,-)⇩C⇩F) ∘⇩D⇩G⇩H⇩M 𝔊›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_simps] = category.cat_cf_rcomp_Hom_cf_Hom_snd lemma (in category) cat_cf_lcomp_Hom_cf_Hom_snd: assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "b ∈⇩∘ 𝔅⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉-,-)⇘op_cat 𝔅,ℭ⇙(b,-)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(𝔉⦇ObjMap⦈⦇b⦈,-)" using category_axioms (*‹category (α::V) (ℭ::V)›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹(b::V) ∈⇩∘ (𝔅::V)⦇Obj⦈›*) unfolding cf_lcomp_Hom_def cf_Hom_snd_def (*goal: ‹cf_cn_cov_lcomp ℭ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-) 𝔉⇘op_cat 𝔅,ℭ⇙(b,-)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,-)⇘op_cat ℭ,ℭ⇙(𝔉⦇ObjMap⦈⦇b⦈,-)⇩C⇩F›*) by (cs_concl cs_shallow cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) lemmas [cat_cs_simps] = category.cat_cf_lcomp_Hom_cf_Hom_snd lemma (in category) cat_cf_rcomp_Hom_cf_Hom_fst: assumes "𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ" and "b ∈⇩∘ 𝔅⦇Obj⦈" shows "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)" proof (-) (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)›*) from category_axioms (*‹category α ℭ›*) assms (*‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) have "H𝔉b": "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_intro: cat_cs_intros) from category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) have "H𝔉b'": "Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈) : op_cat ℭ ↦↦⇩C⇘α⇙ cat_Set α" by (cs_concl cs_intro: cat_cs_intros) from category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) have [cat_cs_simps]: "𝒟⇩∘ ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈) = op_cat ℭ⦇Obj⦈" by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) from category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹(b::V) ∈⇩∘ (𝔅::V)⦇Obj⦈›*) have [cat_cs_simps]: "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈) = op_cat ℭ⦇Obj⦈" by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros) from category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) have [cat_cs_simps]: "𝒟⇩∘ ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈) = op_cat ℭ⦇Arr⦈" by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros) from category_axioms (*‹category α ℭ›*) assms (*‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) have [cat_cs_simps]: "𝒟⇩∘ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈) = op_cat ℭ⦇Arr⦈" by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros) show "?thesis" (*goal: ‹Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)›*) proof (rule cf_eqI[OF H𝔉b H𝔉b'] (*‹⟦(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈; (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈; op_cat ℭ = op_cat ℭ; cat_Set α = cat_Set α⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)›*)) (*goals: 1. ‹(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈› 2. ‹(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈› 3. ‹op_cat ℭ = op_cat ℭ› 4. ‹cat_Set α = cat_Set α›*) show "(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold cat_cs_simps (*‹category (?α::V) (?ℭ::V) ⟹ vcard ?ℭ = (6::nat)⇩ℕ› ‹category (?α::V) (?ℭ::V) ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇘?ℭ⇙ (?b::V)⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?b::V) ↦⇘?ℭ⇙ (?c::V)⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹(?f::V) : ↦⇩i⇩d⇩e⇘?ℭ::V⇙ (?b::V) ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category (?α::V) (?ℭ::V); (?h::V) : (?c::V) ↦⇘?ℭ⇙ (?d::V); (?g::V) : (?b::V) ↦⇘?ℭ⇙ ?c; (?f::V) : (?a::V) ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category (?α::V) (?ℭ::V); (?g::V) : (?b::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?c::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V)⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category (?α::V) (?ℭ::V); (?f::V) : (?a::V) ↦⇩i⇩s⇩o⇘?ℭ⇙ (?b::V)⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹(?f::V) : (?a::V) ↦⇘?ℭ::V⇙ (?b::V) ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 311 facts*)) (*goals: 1. ‹vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈)› 3. ‹op_cat ℭ⦇Obj⦈ = op_cat ℭ⦇Obj⦈› 4. ‹⋀a. a ∈⇩∘ op_cat ℭ⦇Obj⦈ ⟹ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈⦇a⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈⦇a⦈›*) from category_axioms (*‹category (α::V) (ℭ::V)›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) show "vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈)" apply (intro bifunctor_proj_fst_ObjMap_vsv[of α] (*‹⟦category α ?𝔄; category α ?𝔅; ?𝔖 : ?𝔄 ×⇩C ?𝔅 ↦↦⇩C⇘α⇙ ?𝔇; ?b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ vsv ((?𝔖⇘?𝔄,?𝔅⇙(-,?b)⇩C⇩F)⦇ObjMap⦈)›*)) (*goals: 1. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ; (b::V) ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ category α (op_cat ℭ)› 2. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ; (b::V) ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ category α 𝔅› 3. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ; (b::V) ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-) : op_cat ℭ ×⇩C 𝔅 ↦↦⇩C⇘α⇙ (?𝔇3::V)› 4. ‹⟦category (α::V) (ℭ::V); (𝔉::V) : (𝔅::V) ↦↦⇩C⇘α⇙ ℭ; (b::V) ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ b ∈⇩∘ 𝔅⦇Obj⦈› discuss goal 1*) apply (cs_concl cs_intro: cat_cs_intros) (*discuss goal 2*) apply (cs_concl cs_intro: cat_cs_intros) (*discuss goal 3*) apply (cs_concl cs_intro: cat_cs_intros) (*discuss goal 4*) apply (cs_concl cs_intro: cat_cs_intros) (*proven 4 subgoals*) . from assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) show "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈)" apply (intro cat_cf_Hom_fst_ObjMap_vsv (*‹?b ∈⇩∘ ℭ⦇Obj⦈ ⟹ vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,?b)⦇ObjMap⦈)›*)) (*goal: ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈)›*) by (cs_concl cs_intro: cat_cs_intros) fix a assume prems: "a ∈⇩∘ op_cat ℭ⦇Obj⦈" (*‹(a::V) ∈⇩∘ op_cat (ℭ::V)⦇Obj⦈›*) with category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) show "(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ObjMap⦈⦇a⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ObjMap⦈⦇a⦈" by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed (simp) (*solved the remaining goal: ‹op_cat ℭ⦇Obj⦈ = op_cat ℭ⦇Obj⦈›*) show "(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈" proof (rule vsv_eqI (*‹⟦vsv ?r; vsv ?s; 𝒟⇩∘ ?r = 𝒟⇩∘ ?s; ⋀a. a ∈⇩∘ 𝒟⇩∘ ?r ⟹ ?r⦇a⦈ = ?s⦇a⦈⟧ ⟹ ?r = ?s›*), unfold cat_cs_simps (*‹category ?α ?ℭ ⟹ vcard ?ℭ = 6⇩ℕ› ‹category ?α ?ℭ ⟹ 𝒟⇩∘ (?ℭ⦇CId⦈) = ?ℭ⦇Obj⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?ℭ⦇CId⦈⦇?b⦈ ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?ℭ⦇CId⦈⦇?b⦈ = ?f› ‹?f : ↦⇩i⇩d⇩e⇘?ℭ⇙ ?b ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f = ?f› ‹⟦category ?α ?ℭ; ?h : ?c ↦⇘?ℭ⇙ ?d; ?g : ?b ↦⇘?ℭ⇙ ?c; ?f : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?h ∘⇩A⇘?ℭ⇙ ?g ∘⇩A⇘?ℭ⇙ ?f = ?h ∘⇩A⇘?ℭ⇙ (?g ∘⇩A⇘?ℭ⇙ ?f)› ‹⟦category ?α ?ℭ; ?g : ?b ↦⇩i⇩s⇩o⇘?ℭ⇙ ?c; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?g ∘⇩A⇘?ℭ⇙ ?f)¯⇩C⇘?ℭ⇙ = ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?g¯⇩C⇘?ℭ⇙› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f¯⇩C⇘?ℭ⇙ ∘⇩A⇘?ℭ⇙ ?f = ?ℭ⦇CId⦈⦇?a⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ ?f ∘⇩A⇘?ℭ⇙ ?f¯⇩C⇘?ℭ⇙ = ?ℭ⦇CId⦈⦇?b⦈› ‹⟦category ?α ?ℭ; ?f : ?a ↦⇩i⇩s⇩o⇘?ℭ⇙ ?b⟧ ⟹ (?f¯⇩C⇘?ℭ⇙)¯⇩C⇘?ℭ⇙ = ?f› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Dom⦈⦇?f⦈ = ?a› ‹?f : ?a ↦⇘?ℭ⇙ ?b ⟹ ?ℭ⦇Cod⦈⦇?f⦈ = ?b› and more 311 facts*) cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 52 facts*)) (*goals: 1. ‹vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈)› 2. ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈)› 3. ‹ℭ⦇Arr⦈ = ℭ⦇Arr⦈› 4. ‹⋀a. a ∈⇩∘ ℭ⦇Arr⦈ ⟹ (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈⦇a⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈⦇a⦈›*) from category_axioms (*‹category α ℭ›*) assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹(b::V) ∈⇩∘ (𝔅::V)⦇Obj⦈›*) show "vsv ((Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈)" apply (intro bifunctor_proj_fst_ArrMap_vsv[of α] (*‹⟦category α ?𝔄; category α ?𝔅; ?𝔖 : ?𝔄 ×⇩C ?𝔅 ↦↦⇩C⇘α⇙ ?𝔇; ?b ∈⇩∘ ?𝔅⦇Obj⦈⟧ ⟹ vsv ((?𝔖⇘?𝔄,?𝔅⇙(-,?b)⇩C⇩F)⦇ArrMap⦈)›*)) (*goals: 1. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ; b ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ category α (op_cat ℭ)› 2. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ; b ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ category α 𝔅› 3. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ; b ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-) : op_cat ℭ ×⇩C 𝔅 ↦↦⇩C⇘α⇙ ?𝔇3› 4. ‹⟦category α ℭ; 𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ; b ∈⇩∘ 𝔅⦇Obj⦈⟧ ⟹ b ∈⇩∘ 𝔅⦇Obj⦈› discuss goal 1*) apply (cs_concl cs_intro: cat_cs_intros) (*discuss goal 2*) apply (cs_concl cs_intro: cat_cs_intros) (*discuss goal 3*) apply (cs_concl cs_intro: cat_cs_intros) (*discuss goal 4*) apply (cs_concl cs_intro: cat_cs_intros) (*proven 4 subgoals*) . from assms (*‹𝔉 : 𝔅 ↦↦⇩C⇘α⇙ ℭ› ‹(b::V) ∈⇩∘ (𝔅::V)⦇Obj⦈›*) show "vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈)" apply (intro cat_cf_Hom_fst_ArrMap_vsv (*‹(?b::V) ∈⇩∘ (ℭ::V)⦇Obj⦈ ⟹ vsv (Hom⇩O⇩.⇩C⇘α::V⇙ℭ(-,?b)⦇ArrMap⦈)›*)) (*goal: ‹vsv (Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈)›*) by (cs_concl cs_intro: cat_cs_intros) fix f assume "f ∈⇩∘ ℭ⦇Arr⦈" (*‹(f::V) ∈⇩∘ (ℭ::V)⦇Arr⦈›*) then obtain a' and b' where "f : a' ↦⇘ℭ⇙ b'" (*goal: ‹(⋀a' b'. f : a' ↦⇘ℭ⇙ b' ⟹ thesis) ⟹ thesis›*) by (auto simp: cat_op_simps (*‹op_cat ?ℭ⦇Obj⦈ = ?ℭ⦇Obj⦈› ‹op_cat ?ℭ⦇Arr⦈ = ?ℭ⦇Arr⦈› ‹op_cat ?ℭ⦇Dom⦈ = ?ℭ⦇Cod⦈› ‹op_cat ?ℭ⦇Cod⦈ = ?ℭ⦇Dom⦈› ‹op_cat ?ℭ⦇CId⦈ = ?ℭ⦇CId⦈› ‹?f : ?b ↦⇘op_cat ?ℭ⇙ ?a = ?f : ?a ↦⇘?ℭ⇙ ?b› ‹Hom (op_cat ?ℭ) ?a ?b = Hom ?ℭ ?b ?a› ‹obj_initial (op_cat ?ℭ) ?a = obj_terminal ?ℭ ?a› ‹obj_terminal (op_cat ?ℭ) ?a = obj_initial ?ℭ ?a› ‹obj_null (op_cat ?ℭ) ?a = obj_null ?ℭ ?a› ‹category ?α ?ℭ ⟹ ℛ⇩∘ (op_cat ?ℭ⦇Comp⦈) = ℛ⇩∘ (?ℭ⦇Comp⦈)› ‹⟦category ?α ?ℭ; ?f : ?b ↦⇘?ℭ⇙ ?c; ?g : ?a ↦⇘?ℭ⇙ ?b⟧ ⟹ ?g ∘⇩A⇘op_cat ?ℭ⇙ ?f = ?f ∘⇩A⇘?ℭ⇙ ?g› and more 52 facts*)) from category_axioms (*‹category α ℭ›*) assms (*‹(𝔉::V) : (𝔅::V) ↦↦⇩C⇘α::V⇙ (ℭ::V)› ‹b ∈⇩∘ 𝔅⦇Obj⦈›*) this (*‹(f::V) : (a'::V) ↦⇘ℭ::V⇙ (b'::V)›*) show "(Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉-)⇘op_cat ℭ,𝔅⇙(-,b)⇩C⇩F)⦇ArrMap⦈⦇f⦈ = Hom⇩O⇩.⇩C⇘α⇙ℭ(-,𝔉⦇ObjMap⦈⦇b⦈)⦇ArrMap⦈⦇f⦈" by (cs_concl cs_simp: cat_cs_simps cat_op_simps cs_intro: cat_cs_intros cat_op_intros cat_prod_cs_intros) qed (simp) (*solved the remaining goal: ‹ℭ⦇Arr⦈ = ℭ⦇Arr⦈›*) qed (simp_all) (*solves the remaining goals: 1. ‹op_cat ℭ = op_cat ℭ› 2. ‹cat_Set α = cat_Set α›*) qed lemmas [cat_cs_simps] = category.cat_cf_rcomp_Hom_cf_Hom_fst text‹\newpage› end
{ "path": "afp-2025-02-12/thys/CZH_Elementary_Categories/czh_ecategories/CZH_ECAT_Hom.thy", "repo": "afp-2025-02-12", "sha": "d8b48862b8315f6cea38db8363501c4a1b8ffdc6e3e21f3176f9d9424855dd65" }
(* Author: John Harrison, Marco Maggesi, Graziano Gentili, Gianni Ciolli, Valentina Bruno Ported from "hol_light/Multivariate/canal.ml" by L C Paulson (2014) *) section ‹Complex Analysis Basics› text ‹Definitions of analytic and holomorphic functions, limit theorems, complex differentiation› theory Complex_Analysis_Basics imports Derivative "HOL-Library.Nonpos_Ints" Uncountable_Sets begin subsection✐‹tag unimportant›‹General lemmas› lemma nonneg_Reals_cmod_eq_Re: "z ∈ ℝ⇩≥₀ ⟹ norm z = Re z" by (simp add: complex_nonneg_Reals_iff (*‹(?z ∈ ℝ⇩≥₀) = (0 ≤ Re ?z ∧ Im ?z = 0)›*) cmod_eq_Re (*‹Im ?z = 0 ⟹ cmod ?z = ¦Re ?z¦›*)) lemma fact_cancel: fixes c :: "'a::real_field" shows "of_nat (Suc n) * c / (fact (Suc n)) = c / (fact n)" using of_nat_neq_0 (*‹of_nat (Suc (?n::nat)) ≠ (0::?'a)›*) by force lemma vector_derivative_cnj_within: assumes "at x within A ≠ bot" and "f differentiable at x within A" shows "vector_derivative (λz. cnj (f z)) (at x within A) = cnj (vector_derivative f (at x within A))" (is "_ = cnj ?D") proof (-) (*goal: ‹vector_derivative (λz. cnj (f z)) (at x within A) = cnj (vector_derivative f (at x within A))›*) let ?D = "vector_derivative f (at x within A)" from assms (*‹at x within A ≠ bot› ‹f differentiable at x within A›*) have "(f has_vector_derivative ?D) (at x within A)" by (subst (asm) vector_derivative_works (*‹(?f differentiable ?net) = (?f has_vector_derivative vector_derivative ?f ?net) ?net›*)) hence "((λx. cnj (f x)) has_vector_derivative cnj ?D) (at x within A)" by (rule has_vector_derivative_cnj (*‹(?f has_vector_derivative ?f') (at ?z within ?A) ⟹ ((λz. cnj (?f z)) has_vector_derivative cnj ?f') (at ?z within ?A)›*)) thus "?thesis" (*goal: ‹vector_derivative (λz. cnj (f z)) (at x within A) = cnj (vector_derivative f (at x within A))›*) using assms (*‹at x within A ≠ bot› ‹f differentiable at x within A›*) by (auto dest: vector_derivative_within (*‹⟦at ?x within ?S ≠ bot; (?f has_vector_derivative ?y) (at ?x within ?S)⟧ ⟹ vector_derivative ?f (at ?x within ?S) = ?y›*)) qed lemma vector_derivative_cnj: assumes "f differentiable at x" shows "vector_derivative (λz. cnj (f z)) (at x) = cnj (vector_derivative f (at x))" using assms (*‹(f::real ⇒ complex) differentiable at (x::real)›*) apply (intro vector_derivative_cnj_within (*‹⟦at ?x within ?A ≠ bot; ?f differentiable at ?x within ?A⟧ ⟹ vector_derivative (λz. cnj (?f z)) (at ?x within ?A) = cnj (vector_derivative ?f (at ?x within ?A))›*)) (*goals: 1. ‹f differentiable at x ⟹ at x ≠ bot› 2. ‹f differentiable at x ⟹ f differentiable at x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma shows open_halfspace_Re_lt: "open {z. Re(z) < b}" and open_halfspace_Re_gt: "open {z. Re(z) > b}" and closed_halfspace_Re_ge: "closed {z. Re(z) ≥ b}" and closed_halfspace_Re_le: "closed {z. Re(z) ≤ b}" and closed_halfspace_Re_eq: "closed {z. Re(z) = b}" and open_halfspace_Im_lt: "open {z. Im(z) < b}" and open_halfspace_Im_gt: "open {z. Im(z) > b}" and closed_halfspace_Im_ge: "closed {z. Im(z) ≥ b}" and closed_halfspace_Im_le: "closed {z. Im(z) ≤ b}" and closed_halfspace_Im_eq: "closed {z. Im(z) = b}" (*goals: 1. ‹open {z. Re z < b}› 2. ‹open {z. b < Re z}› 3. ‹closed {z. b ≤ Re z}› 4. ‹closed {z. Re z ≤ b}› 5. ‹closed {z. Re z = b}› 6. ‹open {z. Im z < b}› 7. ‹open {z. b < Im z}› 8. ‹closed {z. b ≤ Im z}› 9. ‹closed {z. Im z ≤ b}› 10. ‹closed {z. Im z = b}› discuss goal 1*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*discuss goal 2*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV (?f::?'a ⇒ ?'b); continuous_on UNIV (?g::?'a ⇒ ?'b)⟧ ⟹ open {x::?'a. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV (?f::?'a ⇒ ?'b); continuous_on UNIV (?g::?'a ⇒ ?'b)⟧ ⟹ closed {x::?'a. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV (?f::?'a ⇒ ?'b); continuous_on UNIV (?g::?'a ⇒ ?'b)⟧ ⟹ closed {x::?'a. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on (?s::?'c set) (?g::?'c ⇒ complex) ⟹ continuous_on ?s (λx::?'c. Re (?g x))›*) continuous_on_Im (*‹continuous_on (?s::?'c set) (?g::?'c ⇒ complex) ⟹ continuous_on ?s (λx::?'c. Im (?g x))›*) continuous_on_id (*‹continuous_on (?s::?'a set) (λx::?'a. x)›*) continuous_on_const (*‹continuous_on (?s::?'a set) (λx::?'a. ?c::?'b)›*)) (*discuss goal 3*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*discuss goal 4*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV (?f::?'a::topological_space ⇒ ?'b::linorder_topology); continuous_on UNIV (?g::?'a::topological_space ⇒ ?'b::linorder_topology)⟧ ⟹ open {x::?'a::topological_space. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV (?f::?'a::topological_space ⇒ ?'b::linorder_topology); continuous_on UNIV (?g::?'a::topological_space ⇒ ?'b::linorder_topology)⟧ ⟹ closed {x::?'a::topological_space. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV (?f::?'a::topological_space ⇒ ?'b::t2_space); continuous_on UNIV (?g::?'a::topological_space ⇒ ?'b::t2_space)⟧ ⟹ closed {x::?'a::topological_space. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on (?s::?'c::topological_space set) (?g::?'c::topological_space ⇒ complex) ⟹ continuous_on ?s (λx::?'c::topological_space. Re (?g x))›*) continuous_on_Im (*‹continuous_on (?s::?'c::topological_space set) (?g::?'c::topological_space ⇒ complex) ⟹ continuous_on ?s (λx::?'c::topological_space. Im (?g x))›*) continuous_on_id (*‹continuous_on (?s::?'a::topological_space set) (λx::?'a::topological_space. x)›*) continuous_on_const (*‹continuous_on (?s::?'a::topological_space set) (λx::?'a::topological_space. ?c::?'b::topological_space)›*)) (*discuss goal 5*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV (?f::?'a ⇒ ?'b); continuous_on UNIV (?g::?'a ⇒ ?'b)⟧ ⟹ open {x::?'a. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV (?f::?'a ⇒ ?'b); continuous_on UNIV (?g::?'a ⇒ ?'b)⟧ ⟹ closed {x::?'a. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV (?f::?'a ⇒ ?'b); continuous_on UNIV (?g::?'a ⇒ ?'b)⟧ ⟹ closed {x::?'a. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on (?s::?'c set) (?g::?'c ⇒ complex) ⟹ continuous_on ?s (λx::?'c. Re (?g x))›*) continuous_on_Im (*‹continuous_on (?s::?'c set) (?g::?'c ⇒ complex) ⟹ continuous_on ?s (λx::?'c. Im (?g x))›*) continuous_on_id (*‹continuous_on (?s::?'a set) (λx::?'a. x)›*) continuous_on_const (*‹continuous_on (?s::?'a set) (λx::?'a. ?c::?'b)›*)) (*discuss goal 6*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*discuss goal 7*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*discuss goal 8*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*discuss goal 9*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*discuss goal 10*) apply (intro open_Collect_less (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ open {x. ?f x < ?g x}›*) closed_Collect_le (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x ≤ ?g x}›*) closed_Collect_eq (*‹⟦continuous_on UNIV ?f; continuous_on UNIV ?g⟧ ⟹ closed {x. ?f x = ?g x}›*) continuous_on_Re (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Re (?g x))›*) continuous_on_Im (*‹continuous_on ?s ?g ⟹ continuous_on ?s (λx. Im (?g x))›*) continuous_on_id (*‹continuous_on ?s (λx. x)›*) continuous_on_const (*‹continuous_on ?s (λx. ?c)›*)) (*proven 10 subgoals*) . lemma uncountable_halfspace_Im_gt: "uncountable {z. Im z > c}" proof (-) (*goal: ‹uncountable {z. c < Im z}›*) obtain r where r: "r > 0" "ball ((c + 1) *⇩R 𝗂) r ⊆ {z. Im z > c}" (*goal: ‹(⋀r. ⟦0 < r; ball ((c + 1) *⇩R 𝗂) r ⊆ {z. c < Im z}⟧ ⟹ thesis) ⟹ thesis›*) using open_halfspace_Im_gt[of c] (*‹open {z::complex. (c::real) < Im z}›*) unfolding open_contains_ball (*goal: ‹(⋀r. ⟦0 < r; ball ((c + 1) *⇩R 𝗂) r ⊆ {z. c < Im z}⟧ ⟹ thesis) ⟹ thesis›*) by force then show "?thesis" (*goal: ‹uncountable {z. c < Im z}›*) using countable_subset (*‹⟦?A ⊆ ?B; countable ?B⟧ ⟹ countable ?A›*) uncountable_ball (*‹0 < ?r ⟹ uncountable (ball ?a ?r)›*) by blast qed lemma uncountable_halfspace_Im_lt: "uncountable {z. Im z < c}" proof (-) (*goal: ‹uncountable {z. Im z < c}›*) obtain r where r: "r > 0" "ball ((c - 1) *⇩R 𝗂) r ⊆ {z. Im z < c}" (*goal: ‹(⋀r::real. ⟦(0::real) < r; ball (((c::real) - (1::real)) *⇩R 𝗂) r ⊆ {z::complex. Im z < c}⟧ ⟹ thesis::bool) ⟹ thesis›*) using open_halfspace_Im_lt[of c] (*‹open {z. Im z < c}›*) unfolding open_contains_ball (*goal: ‹(⋀r. ⟦0 < r; ball ((c - 1) *⇩R 𝗂) r ⊆ {z. Im z < c}⟧ ⟹ thesis) ⟹ thesis›*) by force then show "?thesis" (*goal: ‹uncountable {z. Im z < c}›*) using countable_subset (*‹⟦?A ⊆ ?B; countable ?B⟧ ⟹ countable ?A›*) uncountable_ball (*‹0 < ?r ⟹ uncountable (ball ?a ?r)›*) by blast qed lemma uncountable_halfspace_Re_gt: "uncountable {z. Re z > c}" proof (-) (*goal: ‹uncountable {z. c < Re z}›*) obtain r where r: "r > 0" "ball (of_real(c + 1)) r ⊆ {z. Re z > c}" (*goal: ‹(⋀r. ⟦0 < r; ball (complex_of_real (c + 1)) r ⊆ {z. c < Re z}⟧ ⟹ thesis) ⟹ thesis›*) using open_halfspace_Re_gt[of c] (*‹open {z. c < Re z}›*) unfolding open_contains_ball (*goal: ‹(⋀r. ⟦0 < r; ball (complex_of_real (c + 1)) r ⊆ {z. c < Re z}⟧ ⟹ thesis) ⟹ thesis›*) by force then show "?thesis" (*goal: ‹uncountable {z. c < Re z}›*) using countable_subset (*‹⟦?A ⊆ ?B; countable ?B⟧ ⟹ countable ?A›*) uncountable_ball (*‹0 < ?r ⟹ uncountable (ball ?a ?r)›*) by blast qed lemma uncountable_halfspace_Re_lt: "uncountable {z. Re z < c}" proof (-) (*goal: ‹uncountable {z. Re z < c}›*) obtain r where r: "r > 0" "ball (of_real(c - 1)) r ⊆ {z. Re z < c}" (*goal: ‹(⋀r. ⟦0 < r; ball (complex_of_real (c - 1)) r ⊆ {z. Re z < c}⟧ ⟹ thesis) ⟹ thesis›*) using open_halfspace_Re_lt[of c] (*‹open {z. Re z < c}›*) unfolding open_contains_ball (*goal: ‹(⋀r. ⟦0 < r; ball (complex_of_real (c - 1)) r ⊆ {z. Re z < c}⟧ ⟹ thesis) ⟹ thesis›*) by force then show "?thesis" (*goal: ‹uncountable {z. Re z < c}›*) using countable_subset (*‹⟦?A ⊆ ?B; countable ?B⟧ ⟹ countable ?A›*) uncountable_ball (*‹0 < ?r ⟹ uncountable (ball ?a ?r)›*) by blast qed lemma connected_halfspace_Im_gt [intro]: "connected {z. c < Im z}" by (intro convex_connected (*‹convex ?S ⟹ connected ?S›*) convex_halfspace_Im_gt (*‹convex {x. ?b < Im x}›*)) lemma connected_halfspace_Im_lt [intro]: "connected {z. c > Im z}" by (intro convex_connected (*‹convex ?S ⟹ connected ?S›*) convex_halfspace_Im_lt (*‹convex {x. Im x < ?b}›*)) lemma connected_halfspace_Re_gt [intro]: "connected {z. c < Re z}" by (intro convex_connected (*‹convex ?S ⟹ connected ?S›*) convex_halfspace_Re_gt (*‹convex {x. ?b < Re x}›*)) lemma connected_halfspace_Re_lt [intro]: "connected {z. c > Re z}" by (intro convex_connected (*‹convex ?S ⟹ connected ?S›*) convex_halfspace_Re_lt (*‹convex {x. Re x < ?b}›*)) lemma closed_complex_Reals: "closed (ℝ :: complex set)" proof (-) (*goal: ‹closed ℝ›*) have "(ℝ :: complex set) = {z. Im z = 0}" by (auto simp: complex_is_Real_iff (*‹(?z ∈ ℝ) = (Im ?z = 0)›*)) then show "?thesis" (*goal: ‹closed ℝ›*) by (metis closed_halfspace_Im_eq (*‹closed {z. Im z = ?b}›*)) qed lemma closed_Real_halfspace_Re_le: "closed (ℝ ∩ {w. Re w ≤ x})" by (simp add: closed_Int (*‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)›*) closed_complex_Reals (*‹closed ℝ›*) closed_halfspace_Re_le (*‹closed {z. Re z ≤ ?b}›*)) lemma closed_nonpos_Reals_complex [simp]: "closed (ℝ⇩≤₀ :: complex set)" proof (-) (*goal: ‹closed ℝ⇩≤₀›*) have "ℝ⇩≤₀ = ℝ ∩ {z. Re(z) ≤ 0}" using complex_nonpos_Reals_iff (*‹(?z ∈ ℝ⇩≤₀) = (Re ?z ≤ 0 ∧ Im ?z = 0)›*) complex_is_Real_iff (*‹((?z::complex) ∈ ℝ) = (Im ?z = (0::real))›*) by auto then show "?thesis" (*goal: ‹closed ℝ⇩≤₀›*) by (metis closed_Real_halfspace_Re_le (*‹closed (ℝ ∩ {w. Re w ≤ ?x})›*)) qed lemma closed_Real_halfspace_Re_ge: "closed (ℝ ∩ {w. x ≤ Re(w)})" using closed_halfspace_Re_ge (*‹closed {z. ?b ≤ Re z}›*) by (simp add: closed_Int (*‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)›*) closed_complex_Reals (*‹closed ℝ›*)) lemma closed_nonneg_Reals_complex [simp]: "closed (ℝ⇩≥₀ :: complex set)" proof (-) (*goal: ‹closed ℝ⇩≥₀›*) have "ℝ⇩≥₀ = ℝ ∩ {z. Re(z) ≥ 0}" using complex_nonneg_Reals_iff (*‹(?z ∈ ℝ⇩≥₀) = (0 ≤ Re ?z ∧ Im ?z = 0)›*) complex_is_Real_iff (*‹((?z::complex) ∈ ℝ) = (Im ?z = (0::real))›*) by auto then show "?thesis" (*goal: ‹closed ℝ⇩≥₀›*) by (metis closed_Real_halfspace_Re_ge (*‹closed (ℝ ∩ {w. ?x ≤ Re w})›*)) qed lemma closed_real_abs_le: "closed {w ∈ ℝ. ¦Re w¦ ≤ r}" proof (-) (*goal: ‹closed {w ∈ ℝ. ¦Re w¦ ≤ r}›*) have "{w ∈ ℝ. ¦Re w¦ ≤ r} = (ℝ ∩ {w. Re w ≤ r}) ∩ (ℝ ∩ {w. Re w ≥ -r})" by auto then show "closed {w ∈ ℝ. ¦Re w¦ ≤ r}" by (simp add: closed_Int (*‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)›*) closed_Real_halfspace_Re_ge (*‹closed (ℝ ∩ {w. ?x ≤ Re w})›*) closed_Real_halfspace_Re_le (*‹closed (ℝ ∩ {w. Re w ≤ ?x})›*)) qed lemma real_lim: fixes l::complex assumes "(f ⤏ l) F" and "¬ trivial_limit F" and "eventually P F" and "⋀a. P a ⟹ f a ∈ ℝ" shows "l ∈ ℝ" using Lim_in_closed_set[OF closed_complex_Reals] (*‹⟦∀⇩F x::?'b in ?F::?'b filter. (?f::?'b ⇒ complex) x ∈ ℝ; ?F ≠ bot; (?f ⤏ (?l::complex)) ?F⟧ ⟹ ?l ∈ ℝ›*) assms (*‹(f ⤏ l) F› ‹F ≠ bot› ‹eventually P F› ‹P ?a ⟹ f ?a ∈ ℝ›*) by (smt (verit) eventually_mono (*‹⟦eventually (?P::?'a ⇒ bool) (?F::?'a filter); ⋀x::?'a. ?P x ⟹ (?Q::?'a ⇒ bool) x⟧ ⟹ eventually ?Q ?F›*)) lemma real_lim_sequentially: fixes l::complex shows "(f ⤏ l) sequentially ⟹ (∃N. ∀n≥N. f n ∈ ℝ) ⟹ l ∈ ℝ" apply (rule real_lim [where F=sequentially] (*‹⟦?f ⇢ ?l; sequentially ≠ bot; eventually ?P sequentially; ⋀a. ?P a ⟹ ?f a ∈ ℝ⟧ ⟹ ?l ∈ ℝ›*)) (*goals: 1. ‹⟦f ⇢ l; ∃N. ∀n≥N. f n ∈ ℝ⟧ ⟹ ?f ⇢ l› 2. ‹⟦f ⇢ l; ∃N. ∀n≥N. f n ∈ ℝ⟧ ⟹ sequentially ≠ bot› 3. ‹⟦f ⇢ l; ∃N. ∀n≥N. f n ∈ ℝ⟧ ⟹ eventually ?P sequentially› 4. ‹⋀a. ⟦f ⇢ l; ∃N. ∀n≥N. f n ∈ ℝ; ?P a⟧ ⟹ ?f a ∈ ℝ› discuss goal 1*) apply ((auto simp: eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))[1]) (*discuss goal 2*) apply ((auto simp: eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))[1]) (*discuss goal 3*) apply ((auto simp: eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))[1]) (*discuss goal 4*) apply ((auto simp: eventually_sequentially (*‹eventually ?P sequentially = (∃N. ∀n≥N. ?P n)›*))[1]) (*proven 4 subgoals*) . lemma real_series: fixes l::complex shows "f sums l ⟹ (⋀n. f n ∈ ℝ) ⟹ l ∈ ℝ" unfolding sums_def (*goal: ‹⟦(λn::nat. sum (f::nat ⇒ complex) {..<n}) ⇢ (l::complex); ⋀n::nat. f n ∈ ℝ⟧ ⟹ l ∈ ℝ›*) by (metis real_lim_sequentially (*‹⟦?f ⇢ ?l; ∃N. ∀n≥N. ?f n ∈ ℝ⟧ ⟹ ?l ∈ ℝ›*) sum_in_Reals (*‹(⋀i. i ∈ ?s ⟹ ?f i ∈ ℝ) ⟹ sum ?f ?s ∈ ℝ›*)) lemma Lim_null_comparison_Re: assumes "eventually (λx. norm(f x) ≤ Re(g x)) F" "(g ⤏ 0) F" shows "(f ⤏ 0) F" using Lim_null_comparison (*‹⟦∀⇩F x in ?net. norm (?f x) ≤ ?g x; (?g ⤏ 0) ?net⟧ ⟹ (?f ⤏ 0) ?net›*) assms (*‹∀⇩F x in F. norm (f x) ≤ Re (g x)› ‹(g ⤏ 0) F›*) tendsto_Re (*‹((?g::?'c ⇒ complex) ⤏ (?a::complex)) (?F::?'c filter) ⟹ ((λx::?'c. Re (?g x)) ⤏ Re ?a) ?F›*) by fastforce subsection‹Holomorphic functions› definition✐‹tag important› holomorphic_on :: "[complex ⇒ complex, complex set] ⇒ bool" (infixl "(holomorphic'_on)" 50) where "f holomorphic_on s ≡ ∀x∈s. f field_differentiable (at x within s)" named_theorems✐‹tag important› holomorphic_intros "structural introduction rules for holomorphic_on" lemma holomorphic_onI [intro?]: "(⋀x. x ∈ s ⟹ f field_differentiable (at x within s)) ⟹ f holomorphic_on s" by (simp add: holomorphic_on_def (*‹(?f::complex ⇒ complex) holomorphic_on (?s::complex set) ≡ ∀x::complex∈?s. ?f field_differentiable at x within ?s›*)) lemma holomorphic_onD [dest?]: "⟦f holomorphic_on s; x ∈ s⟧ ⟹ f field_differentiable (at x within s)" by (simp add: holomorphic_on_def (*‹(?f::complex ⇒ complex) holomorphic_on (?s::complex set) ≡ ∀x::complex∈?s. ?f field_differentiable at x within ?s›*)) lemma holomorphic_on_imp_differentiable_on: "f holomorphic_on s ⟹ f differentiable_on s" unfolding holomorphic_on_def differentiable_on_def (*goal: ‹∀x∈s. f field_differentiable at x within s ⟹ ∀x∈s. f differentiable at x within s›*) by (simp add: field_differentiable_imp_differentiable (*‹?f field_differentiable ?F ⟹ ?f differentiable ?F›*)) lemma holomorphic_on_imp_differentiable_at: "⟦f holomorphic_on s; open s; x ∈ s⟧ ⟹ f field_differentiable (at x)" using at_within_open (*‹⟦?a ∈ ?S; open ?S⟧ ⟹ at ?a within ?S = at ?a›*) holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*) by fastforce lemma holomorphic_on_empty [holomorphic_intros]: "f holomorphic_on {}" by (simp add: holomorphic_on_def (*‹(?f::complex ⇒ complex) holomorphic_on (?s::complex set) ≡ ∀x::complex∈?s. ?f field_differentiable at x within ?s›*)) lemma holomorphic_on_open: "open s ⟹ f holomorphic_on s ⟷ (∀x ∈ s. ∃f'. DERIV f x :> f')" by (auto simp: holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*) field_differentiable_def (*‹?f field_differentiable ?F ≡ ∃f'. (?f has_field_derivative f') ?F›*) has_field_derivative_def (*‹(?f has_field_derivative ?D) ?F = (?f has_derivative (*) ?D) ?F›*) at_within_open [of _ s] (*‹⟦?a ∈ s; open s⟧ ⟹ at ?a within s = at ?a›*)) lemma holomorphic_on_UN_open: assumes "⋀n. n ∈ I ⟹ f holomorphic_on A n" "⋀n. n ∈ I ⟹ open (A n)" shows "f holomorphic_on (⋃n∈I. A n)" by (metis UN_E (*‹⟦?b ∈ ⋃ (?B ` ?A); ⋀x. ⟦x ∈ ?A; ?b ∈ ?B x⟧ ⟹ ?R⟧ ⟹ ?R›*) assms (*‹?n ∈ I ⟹ f holomorphic_on A ?n› ‹?n ∈ I ⟹ open (A ?n)›*) holomorphic_on_open (*‹open ?s ⟹ (?f holomorphic_on ?s) = (∀x∈?s. ∃f'. (?f has_field_derivative f') (at x))›*) open_UN (*‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))›*)) lemma holomorphic_on_imp_continuous_on: "f holomorphic_on s ⟹ continuous_on s f" using differentiable_imp_continuous_on (*‹(?f::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) differentiable_on (?s::?'a::real_normed_vector set) ⟹ continuous_on ?s ?f›*) holomorphic_on_imp_differentiable_on (*‹(?f::complex ⇒ complex) holomorphic_on (?s::complex set) ⟹ ?f differentiable_on ?s›*) by blast lemma holomorphic_closedin_preimage_constant: assumes "f holomorphic_on D" shows "closedin (top_of_set D) {z∈D. f z = a}" by (simp add: assms (*‹(f::complex ⇒ complex) holomorphic_on (D::complex set)›*) continuous_closedin_preimage_constant (*‹continuous_on (?S::?'c::topological_space set) (?f::?'c::topological_space ⇒ ?'b::t1_space) ⟹ closedin (top_of_set ?S) {x::?'c::topological_space ∈ ?S. ?f x = (?a::?'b::t1_space)}›*) holomorphic_on_imp_continuous_on (*‹(?f::complex ⇒ complex) holomorphic_on (?s::complex set) ⟹ continuous_on ?s ?f›*)) lemma holomorphic_closed_preimage_constant: assumes "f holomorphic_on UNIV" shows "closed {z. f z = a}" using holomorphic_closedin_preimage_constant[OF assms] (*‹closedin (top_of_set UNIV) {z ∈ UNIV. f z = ?a}›*) by simp lemma holomorphic_on_subset [elim]: "f holomorphic_on s ⟹ t ⊆ s ⟹ f holomorphic_on t" unfolding holomorphic_on_def (*goal: ‹⟦∀x::complex∈s::complex set. (f::complex ⇒ complex) field_differentiable at x within s; (t::complex set) ⊆ s⟧ ⟹ ∀x::complex∈t. f field_differentiable at x within t›*) by (metis field_differentiable_within_subset (*‹⟦(?f::?'a ⇒ ?'a) field_differentiable at (?x::?'a) within (?S::?'a set); (?T::?'a set) ⊆ ?S⟧ ⟹ ?f field_differentiable at ?x within ?T›*) subsetD (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); (?c::?'a) ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) lemma holomorphic_transform: "⟦f holomorphic_on s; ⋀x. x ∈ s ⟹ f x = g x⟧ ⟹ g holomorphic_on s" by (metis field_differentiable_transform_within (*‹⟦0 < ?d; ?x ∈ ?S; ⋀x'. ⟦x' ∈ ?S; dist x' ?x < ?d⟧ ⟹ ?f x' = ?g x'; ?f field_differentiable at ?x within ?S⟧ ⟹ ?g field_differentiable at ?x within ?S›*) linordered_field_no_ub (*‹∀x. ∃y. x < y›*) holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*)) lemma holomorphic_cong: "s = t ==> (⋀x. x ∈ s ⟹ f x = g x) ⟹ f holomorphic_on s ⟷ g holomorphic_on t" by (metis holomorphic_transform (*‹⟦?f holomorphic_on ?s; ⋀x. x ∈ ?s ⟹ ?f x = ?g x⟧ ⟹ ?g holomorphic_on ?s›*)) lemma holomorphic_on_linear [simp, holomorphic_intros]: "((*) c) holomorphic_on s" unfolding holomorphic_on_def (*goal: ‹∀x∈s. (*) c field_differentiable at x within s›*) by (metis field_differentiable_linear (*‹(*) ?c field_differentiable ?F›*)) lemma holomorphic_on_const [simp, holomorphic_intros]: "(λz. c) holomorphic_on s" unfolding holomorphic_on_def (*goal: ‹∀x∈s. (λz. c) field_differentiable at x within s›*) by (metis field_differentiable_const (*‹(λz. ?c) field_differentiable ?F›*)) lemma holomorphic_on_ident [simp, holomorphic_intros]: "(λx. x) holomorphic_on s" unfolding holomorphic_on_def (*goal: ‹∀x∈s. (λx. x) field_differentiable at x within s›*) by (metis field_differentiable_ident (*‹(λz. z) field_differentiable ?F›*)) lemma holomorphic_on_id [simp, holomorphic_intros]: "id holomorphic_on s" unfolding id_def (*goal: ‹(λx. x) holomorphic_on s›*) by (rule holomorphic_on_ident (*‹(λx::complex. x) holomorphic_on (?s::complex set)›*)) lemma constant_on_imp_holomorphic_on: assumes "f constant_on A" shows "f holomorphic_on A" by (metis assms (*‹f constant_on A›*) constant_on_def (*‹?f constant_on ?A ≡ ∃y. ∀x∈?A. ?f x = y›*) holomorphic_on_const (*‹(λz. ?c) holomorphic_on ?s›*) holomorphic_transform (*‹⟦?f holomorphic_on ?s; ⋀x. x ∈ ?s ⟹ ?f x = ?g x⟧ ⟹ ?g holomorphic_on ?s›*)) lemma holomorphic_on_compose: "f holomorphic_on s ⟹ g holomorphic_on (f ` s) ⟹ (g ∘ f) holomorphic_on s" using field_differentiable_compose_within[of f _ s g] (*‹⟦(f::complex ⇒ complex) field_differentiable at (?a::complex) within (s::complex set); (g::complex ⇒ complex) field_differentiable at (f ?a) within f ` s⟧ ⟹ g ∘ f field_differentiable at ?a within s›*) by (auto simp: holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*)) lemma holomorphic_on_compose_gen: "f holomorphic_on s ⟹ g holomorphic_on t ⟹ f ` s ⊆ t ⟹ (g ∘ f) holomorphic_on s" by (metis holomorphic_on_compose (*‹⟦?f holomorphic_on ?s; ?g holomorphic_on ?f ` ?s⟧ ⟹ ?g ∘ ?f holomorphic_on ?s›*) holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*)) lemma holomorphic_on_balls_imp_entire: assumes "¬bdd_above A" "⋀r. r ∈ A ⟹ f holomorphic_on ball c r" shows "f holomorphic_on B" proof (rule holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*)) (*goals: 1. ‹f holomorphic_on ?s› 2. ‹B ⊆ ?s›*) show "f holomorphic_on UNIV" unfolding holomorphic_on_def (*goal: ‹∀x∈UNIV. f field_differentiable at x›*) proof (standard) (*goal: ‹⋀x::complex. x ∈ UNIV ⟹ (f::complex ⇒ complex) field_differentiable at x›*) fix z :: complex from ‹¬bdd_above A› (*‹¬ bdd_above A›*) obtain r where r: "r ∈ A" "r > norm (z - c)" (*goal: ‹(⋀r::real. ⟦r ∈ (A::real set); cmod ((z::complex) - (c::complex)) < r⟧ ⟹ thesis::bool) ⟹ thesis›*) by (meson bdd_aboveI (*‹(⋀x. x ∈ ?A ⟹ x ≤ ?M) ⟹ bdd_above ?A›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*)) with assms(2) (*‹(?r::real) ∈ (A::real set) ⟹ (f::complex ⇒ complex) holomorphic_on ball (c::complex) ?r›*) have "f holomorphic_on ball c r" by blast moreover from r (*‹r ∈ A› ‹cmod ((z::complex) - (c::complex)) < (r::real)›*) have "z ∈ ball c r" by (auto simp: dist_norm (*‹dist (?x::?'a) (?y::?'a) = norm (?x - ?y)›*) norm_minus_commute (*‹norm ((?a::?'a) - (?b::?'a)) = norm (?b - ?a)›*)) ultimately show "f field_differentiable at z" by (auto simp: holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*) at_within_open[of _ "ball c r"] (*‹⟦?a ∈ ball c r; open (ball c r)⟧ ⟹ at ?a within ball c r = at ?a›*)) qed qed (auto) (*solved the remaining goal: ‹B ⊆ UNIV›*) lemma holomorphic_on_balls_imp_entire': assumes "⋀r. r > 0 ⟹ f holomorphic_on ball c r" shows "f holomorphic_on B" proof (rule holomorphic_on_balls_imp_entire (*‹⟦¬ bdd_above ?A; ⋀r. r ∈ ?A ⟹ ?f holomorphic_on ball ?c r⟧ ⟹ ?f holomorphic_on ?B›*)) (*goals: 1. ‹¬ bdd_above ?A› 2. ‹⋀r. r ∈ ?A ⟹ f holomorphic_on ball ?c r›*) show "¬bdd_above {(0::real)<..}" unfolding bdd_above_def (*goal: ‹∄M. ∀x∈{0<..}. x ≤ M›*) by (meson greaterThan_iff (*‹((?i::?'a) ∈ {?k::?'a<..}) = (?k < ?i)›*) gt_ex (*‹∃y::?'a. (?x::?'a) < y›*) less_le_not_le (*‹((?x::?'a) < (?y::?'a)) = (?x ≤ ?y ∧ ¬ ?y ≤ ?x)›*) order_le_less_trans (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y < (?z::?'a)⟧ ⟹ ?x < ?z›*)) qed (use assms in auto) (*solved the remaining goal: ‹⋀r. r ∈ {0<..} ⟹ f holomorphic_on ball ?c r›*) lemma holomorphic_on_minus [holomorphic_intros]: "f holomorphic_on A ⟹ (λz. -(f z)) holomorphic_on A" by (metis field_differentiable_minus (*‹?f field_differentiable ?F ⟹ (λz. - ?f z) field_differentiable ?F›*) holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*)) lemma holomorphic_on_add [holomorphic_intros]: "⟦f holomorphic_on A; g holomorphic_on A⟧ ⟹ (λz. f z + g z) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹⟦∀x::complex∈A::complex set. (f::complex ⇒ complex) field_differentiable at x within A; ∀x::complex∈A. (g::complex ⇒ complex) field_differentiable at x within A⟧ ⟹ ∀x::complex∈A. (λz::complex. f z + g z) field_differentiable at x within A›*) by (metis field_differentiable_add (*‹⟦?f field_differentiable ?F; ?g field_differentiable ?F⟧ ⟹ (λz. ?f z + ?g z) field_differentiable ?F›*)) lemma holomorphic_on_diff [holomorphic_intros]: "⟦f holomorphic_on A; g holomorphic_on A⟧ ⟹ (λz. f z - g z) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹⟦∀x∈A. f field_differentiable at x within A; ∀x∈A. g field_differentiable at x within A⟧ ⟹ ∀x∈A. (λz. f z - g z) field_differentiable at x within A›*) by (metis field_differentiable_diff (*‹⟦?f field_differentiable ?F; ?g field_differentiable ?F⟧ ⟹ (λz. ?f z - ?g z) field_differentiable ?F›*)) lemma holomorphic_on_mult [holomorphic_intros]: "⟦f holomorphic_on A; g holomorphic_on A⟧ ⟹ (λz. f z * g z) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹⟦∀x∈A. f field_differentiable at x within A; ∀x∈A. g field_differentiable at x within A⟧ ⟹ ∀x∈A. (λz. f z * g z) field_differentiable at x within A›*) by (metis field_differentiable_mult (*‹⟦?f field_differentiable at ?a within ?S; ?g field_differentiable at ?a within ?S⟧ ⟹ (λz. ?f z * ?g z) field_differentiable at ?a within ?S›*)) lemma holomorphic_on_inverse [holomorphic_intros]: "⟦f holomorphic_on A; ⋀z. z ∈ A ⟹ f z ≠ 0⟧ ⟹ (λz. inverse (f z)) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹⟦∀x∈A. f field_differentiable at x within A; ⋀z. z ∈ A ⟹ f z ≠ 0⟧ ⟹ ∀x∈A. (λz. inverse (f z)) field_differentiable at x within A›*) by (metis field_differentiable_inverse (*‹⟦?f field_differentiable at ?a within ?S; ?f ?a ≠ 0⟧ ⟹ (λz. inverse (?f z)) field_differentiable at ?a within ?S›*)) lemma holomorphic_on_divide [holomorphic_intros]: "⟦f holomorphic_on A; g holomorphic_on A; ⋀z. z ∈ A ⟹ g z ≠ 0⟧ ⟹ (λz. f z / g z) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹⟦∀x∈A. f field_differentiable at x within A; ∀x∈A. g field_differentiable at x within A; ⋀z. z ∈ A ⟹ g z ≠ 0⟧ ⟹ ∀x∈A. (λz. f z / g z) field_differentiable at x within A›*) by (metis field_differentiable_divide (*‹⟦?f field_differentiable at ?a within ?S; ?g field_differentiable at ?a within ?S; ?g ?a ≠ 0⟧ ⟹ (λz. ?f z / ?g z) field_differentiable at ?a within ?S›*)) lemma holomorphic_on_power [holomorphic_intros]: "f holomorphic_on A ⟹ (λz. (f z)^n) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹∀x∈A. f field_differentiable at x within A ⟹ ∀x∈A. (λz. f z ^ n) field_differentiable at x within A›*) by (metis field_differentiable_power (*‹?f field_differentiable at ?a within ?S ⟹ (λz. ?f z ^ ?n) field_differentiable at ?a within ?S›*)) lemma holomorphic_on_power_int [holomorphic_intros]: assumes nz: "n ≥ 0 ∨ (∀x∈A. f x ≠ 0)" and f: "f holomorphic_on A" shows "(λx. f x powi n) holomorphic_on A" proof (cases "n ≥ 0") (*goals: 1. ‹(0::int) ≤ (n::int) ⟹ (λx::complex. (f::complex ⇒ complex) x powi n) holomorphic_on (A::complex set)› 2. ‹¬ (0::int) ≤ (n::int) ⟹ (λx::complex. (f::complex ⇒ complex) x powi n) holomorphic_on (A::complex set)›*) case True (*‹0 ≤ n›*) have "(λx. f x ^ nat n) holomorphic_on A" by (simp add: f (*‹f holomorphic_on A›*) holomorphic_on_power (*‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A›*)) with True (*‹0 ≤ n›*) show "?thesis" (*goal: ‹(λx::complex. (f::complex ⇒ complex) x powi (n::int)) holomorphic_on (A::complex set)›*) by (simp add: power_int_def (*‹(?x::?'a) powi (?n::int) = (if (0::int) ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) next (*goal: ‹¬ 0 ≤ n ⟹ (λx. f x powi n) holomorphic_on A›*) case False (*‹¬ (0::int) ≤ (n::int)›*) hence "(λx. inverse (f x ^ nat (-n))) holomorphic_on A" using nz (*‹0 ≤ n ∨ (∀x∈A. f x ≠ 0)›*) by (auto intro!: holomorphic_intros (*‹(?f::complex ⇒ complex) holomorphic_on {}› ‹(*) (?c::complex) holomorphic_on (?s::complex set)› ‹(λz::complex. ?c::complex) holomorphic_on (?s::complex set)› ‹(λx::complex. x) holomorphic_on (?s::complex set)› ‹id holomorphic_on (?s::complex set)› ‹(?f::complex ⇒ complex) holomorphic_on (?A::complex set) ⟹ (λz::complex. - ?f z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z + ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z - ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z * ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); ⋀z::complex. z ∈ ?A ⟹ ?f z ≠ (0::complex)⟧ ⟹ (λz::complex. inverse (?f z)) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A; ⋀z::complex. z ∈ ?A ⟹ ?g z ≠ (0::complex)⟧ ⟹ (λz::complex. ?f z / ?g z) holomorphic_on ?A› ‹(?f::complex ⇒ complex) holomorphic_on (?A::complex set) ⟹ (λz::complex. ?f z ^ (?n::nat)) holomorphic_on ?A›*) f (*‹(f::complex ⇒ complex) holomorphic_on (A::complex set)›*)) with False (*‹¬ 0 ≤ n›*) show "?thesis" (*goal: ‹(λx. f x powi n) holomorphic_on A›*) by (simp add: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) power_inverse (*‹inverse ?a ^ ?n = inverse (?a ^ ?n)›*)) qed lemma holomorphic_on_sum [holomorphic_intros]: "(⋀i. i ∈ I ⟹ (f i) holomorphic_on A) ⟹ (λx. sum (λi. f i x) I) holomorphic_on A" unfolding holomorphic_on_def (*goal: ‹(⋀i::'a::type. i ∈ (I::'a::type set) ⟹ ∀x::complex∈A::complex set. (f::'a::type ⇒ complex ⇒ complex) i field_differentiable at x within A) ⟹ ∀x::complex∈A. (λx::complex. ∑i::'a::type∈I. f i x) field_differentiable at x within A›*) by (metis field_differentiable_sum (*‹(⋀i. i ∈ ?I ⟹ ?f i field_differentiable ?F) ⟹ (λz. ∑i∈?I. ?f i z) field_differentiable ?F›*)) lemma holomorphic_on_prod [holomorphic_intros]: "(⋀i. i ∈ I ⟹ (f i) holomorphic_on A) ⟹ (λx. prod (λi. f i x) I) holomorphic_on A" apply (induction I rule: infinite_finite_induct (*‹⟦⋀A::?'a set. infinite A ⟹ (?P::?'a set ⇒ bool) A; ?P {}; ⋀(x::?'a) F::?'a set. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P (?A::?'a set)›*)) (*goals: 1. ‹⋀Aa. ⟦infinite Aa; ⋀i. i ∈ Aa ⟹ f i holomorphic_on A⟧ ⟹ (λx. ∏i∈Aa. f i x) holomorphic_on A› 2. ‹(⋀i. i ∈ {} ⟹ f i holomorphic_on A) ⟹ (λx. ∏i∈{}. f i x) holomorphic_on A› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. i ∈ F ⟹ f i holomorphic_on A) ⟹ (λx. ∏i∈F. f i x) holomorphic_on A; ⋀i. i ∈ insert x F ⟹ f i holomorphic_on A⟧ ⟹ (λxa. ∏i∈insert x F. f i xa) holomorphic_on A› discuss goal 1*) apply ((auto intro: holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 2 facts*))[1]) (*discuss goal 2*) apply ((auto intro: holomorphic_intros (*‹(?f::complex ⇒ complex) holomorphic_on {}› ‹(*) (?c::complex) holomorphic_on (?s::complex set)› ‹(λz::complex. ?c::complex) holomorphic_on (?s::complex set)› ‹(λx::complex. x) holomorphic_on (?s::complex set)› ‹id holomorphic_on (?s::complex set)› ‹(?f::complex ⇒ complex) holomorphic_on (?A::complex set) ⟹ (λz::complex. - ?f z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z + ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z - ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z * ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); ⋀z::complex. z ∈ ?A ⟹ ?f z ≠ (0::complex)⟧ ⟹ (λz::complex. inverse (?f z)) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A; ⋀z::complex. z ∈ ?A ⟹ ?g z ≠ (0::complex)⟧ ⟹ (λz::complex. ?f z / ?g z) holomorphic_on ?A› ‹(?f::complex ⇒ complex) holomorphic_on (?A::complex set) ⟹ (λz::complex. ?f z ^ (?n::nat)) holomorphic_on ?A› and more 2 facts*))[1]) (*discuss goal 3*) apply ((auto intro: holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 2 facts*))[1]) (*proven 3 subgoals*) . lemma holomorphic_pochhammer [holomorphic_intros]: "f holomorphic_on A ⟹ (λs. pochhammer (f s) n) holomorphic_on A" apply (induction n) (*goals: 1. ‹f holomorphic_on A ⟹ (λs. pochhammer (f s) 0) holomorphic_on A› 2. ‹⋀n. ⟦f holomorphic_on A ⟹ (λs. pochhammer (f s) n) holomorphic_on A; f holomorphic_on A⟧ ⟹ (λs. pochhammer (f s) (Suc n)) holomorphic_on A› discuss goal 1*) apply ((auto intro!: holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 3 facts*) simp: pochhammer_Suc (*‹pochhammer ?a (Suc ?n) = pochhammer ?a ?n * (?a + of_nat ?n)›*))[1]) (*discuss goal 2*) apply ((auto intro!: holomorphic_intros (*‹(?f::complex ⇒ complex) holomorphic_on {}› ‹(*) (?c::complex) holomorphic_on (?s::complex set)› ‹(λz::complex. ?c::complex) holomorphic_on (?s::complex set)› ‹(λx::complex. x) holomorphic_on (?s::complex set)› ‹id holomorphic_on (?s::complex set)› ‹(?f::complex ⇒ complex) holomorphic_on (?A::complex set) ⟹ (λz::complex. - ?f z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z + ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z - ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A⟧ ⟹ (λz::complex. ?f z * ?g z) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); ⋀z::complex. z ∈ ?A ⟹ ?f z ≠ (0::complex)⟧ ⟹ (λz::complex. inverse (?f z)) holomorphic_on ?A› ‹⟦(?f::complex ⇒ complex) holomorphic_on (?A::complex set); (?g::complex ⇒ complex) holomorphic_on ?A; ⋀z::complex. z ∈ ?A ⟹ ?g z ≠ (0::complex)⟧ ⟹ (λz::complex. ?f z / ?g z) holomorphic_on ?A› ‹(?f::complex ⇒ complex) holomorphic_on (?A::complex set) ⟹ (λz::complex. ?f z ^ (?n::nat)) holomorphic_on ?A› and more 3 facts*) simp: pochhammer_Suc (*‹pochhammer (?a::?'a) (Suc (?n::nat)) = pochhammer ?a ?n * (?a + of_nat ?n)›*))[1]) (*proven 2 subgoals*) . lemma holomorphic_on_scaleR [holomorphic_intros]: "f holomorphic_on A ⟹ (λx. c *⇩R f x) holomorphic_on A" by (auto simp: scaleR_conv_of_real (*‹?r *⇩R ?x = of_real ?r * ?x›*) intro!: holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 4 facts*)) lemma holomorphic_on_Un [holomorphic_intros]: assumes "f holomorphic_on A" "f holomorphic_on B" "open A" "open B" shows "f holomorphic_on (A ∪ B)" by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) assms (*‹f holomorphic_on A› ‹f holomorphic_on B› ‹open A› ‹open B›*) holomorphic_on_open (*‹open ?s ⟹ (?f holomorphic_on ?s) = (∀x∈?s. ∃f'. (?f has_field_derivative f') (at x))›*) open_Un (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)›*)) lemma holomorphic_on_If_Un [holomorphic_intros]: assumes "f holomorphic_on A" "g holomorphic_on B" "open A" "open B" assumes "⋀z. z ∈ A ⟹ z ∈ B ⟹ f z = g z" shows "(λz. if z ∈ A then f z else g z) holomorphic_on (A ∪ B)" (is "?h holomorphic_on _") proof (intro holomorphic_on_Un (*‹⟦?f holomorphic_on ?A; ?f holomorphic_on ?B; open ?A; open ?B⟧ ⟹ ?f holomorphic_on ?A ∪ ?B›*)) (*goals: 1. ‹(λz. if z ∈ A then f z else g z) holomorphic_on A› 2. ‹(λz. if z ∈ A then f z else g z) holomorphic_on B› 3. ‹open A› 4. ‹open B›*) note ‹f holomorphic_on A› (*‹f holomorphic_on A›*) also (*calculation: ‹(f::complex ⇒ complex) holomorphic_on (A::complex set)›*) have "f holomorphic_on A ⟷ ?h holomorphic_on A" apply (intro holomorphic_cong (*‹⟦?s = ?t; ⋀x. x ∈ ?s ⟹ ?f x = ?g x⟧ ⟹ (?f holomorphic_on ?s) = (?g holomorphic_on ?t)›*)) (*goals: 1. ‹A = A› 2. ‹⋀x. x ∈ A ⟹ f x = (if x ∈ A then f x else g x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹(λz. if z ∈ A then f z else g z) holomorphic_on A›*) show "…" . next (*goals: 1. ‹(λz. if z ∈ A then f z else g z) holomorphic_on B› 2. ‹open A› 3. ‹open B›*) note ‹g holomorphic_on B› (*‹g holomorphic_on B›*) also (*calculation: ‹g holomorphic_on B›*) have "g holomorphic_on B ⟷ ?h holomorphic_on B" using assms (*‹f holomorphic_on A› ‹g holomorphic_on B› ‹open A› ‹open B› ‹⟦?z ∈ A; ?z ∈ B⟧ ⟹ f ?z = g ?z›*) apply (intro holomorphic_cong (*‹⟦(?s::complex set) = (?t::complex set); ⋀x::complex. x ∈ ?s ⟹ (?f::complex ⇒ complex) x = (?g::complex ⇒ complex) x⟧ ⟹ (?f holomorphic_on ?s) = (?g holomorphic_on ?t)›*)) (*goals: 1. ‹⟦(f::complex ⇒ complex) holomorphic_on (A::complex set); (g::complex ⇒ complex) holomorphic_on (B::complex set); open A; open B; ⋀z::complex. ⟦z ∈ A; z ∈ B⟧ ⟹ f z = g z⟧ ⟹ B = B› 2. ‹⋀x::complex. ⟦(f::complex ⇒ complex) holomorphic_on (A::complex set); (g::complex ⇒ complex) holomorphic_on (B::complex set); open A; open B; ⋀z::complex. ⟦z ∈ A; z ∈ B⟧ ⟹ f z = g z; x ∈ B⟧ ⟹ g x = (if x ∈ A then f x else g x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹(λz. if z ∈ A then f z else g z) holomorphic_on B›*) show "…" . qed (use assms in auto) (*solves the remaining goals: 1. ‹open (A::complex set)› 2. ‹open (B::complex set)›*) lemma holomorphic_derivI: "⟦f holomorphic_on S; open S; x ∈ S⟧ ⟹ (f has_field_derivative deriv f x) (at x within T)" by (metis DERIV_deriv_iff_field_differentiable (*‹(?f has_field_derivative deriv ?f ?x) (at ?x) = (?f field_differentiable at ?x)›*) at_within_open (*‹⟦?a ∈ ?S; open ?S⟧ ⟹ at ?a within ?S = at ?a›*) holomorphic_on_def (*‹?f holomorphic_on ?s ≡ ∀x∈?s. ?f field_differentiable at x within ?s›*) has_field_derivative_at_within (*‹(?f has_field_derivative ?f') (at ?x) ⟹ (?f has_field_derivative ?f') (at ?x within ?s)›*)) lemma complex_derivative_transform_within_open: "⟦f holomorphic_on s; g holomorphic_on s; open s; z ∈ s; ⋀w. w ∈ s ⟹ f w = g w⟧ ⟹ deriv f z = deriv g z" by (smt (verit) DERIV_imp_deriv (*‹(?f has_field_derivative ?f') (at ?x) ⟹ deriv ?f ?x = ?f'›*) has_field_derivative_transform_within_open (*‹⟦(?f has_field_derivative ?f') (at ?a); open ?S; ?a ∈ ?S; ⋀x. x ∈ ?S ⟹ ?f x = ?g x⟧ ⟹ (?g has_field_derivative ?f') (at ?a)›*) holomorphic_on_open (*‹open ?s ⟹ (?f holomorphic_on ?s) = (∀x∈?s. ∃f'. (?f has_field_derivative f') (at x))›*)) lemma holomorphic_on_compose_cnj_cnj: assumes "f holomorphic_on cnj ` A" "open A" shows "cnj ∘ f ∘ cnj holomorphic_on A" proof (-) (*goal: ‹cnj ∘ f ∘ cnj holomorphic_on A›*) have [simp]: "open (cnj ` A)" unfolding image_cnj_conv_vimage_cnj (*goal: ‹open (cnj -` A)›*) using assms (*‹f holomorphic_on cnj ` A› ‹open A›*) apply (intro open_vimage (*‹⟦open ?s; continuous_on UNIV ?f⟧ ⟹ open (?f -` ?s)›*)) (*goals: 1. ‹⟦f holomorphic_on cnj ` A; open A⟧ ⟹ open A› 2. ‹⟦f holomorphic_on cnj ` A; open A⟧ ⟹ continuous_on UNIV cnj› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹cnj ∘ (f::complex ⇒ complex) ∘ cnj holomorphic_on (A::complex set)›*) using assms (*‹f holomorphic_on cnj ` A› ‹open A›*) unfolding holomorphic_on_def (*goal: ‹∀x∈A. cnj ∘ f ∘ cnj field_differentiable at x within A›*) by (auto intro!: field_differentiable_cnj_cnj (*‹?f field_differentiable at (cnj ?z) ⟹ cnj ∘ ?f ∘ cnj field_differentiable at ?z›*) simp: at_within_open_NO_MATCH (*‹⟦?a ∈ ?s; open ?s; NO_MATCH UNIV ?s⟧ ⟹ at ?a within ?s = at ?a›*)) qed lemma holomorphic_nonconstant: assumes holf: "f holomorphic_on S" and "open S" "ξ ∈ S" "deriv f ξ ≠ 0" shows "¬ f constant_on S" apply (rule nonzero_deriv_nonconstant [of f "deriv f ξ" ξ S] (*‹⟦(f has_field_derivative deriv f ξ) (at ξ); open S; ξ ∈ S; deriv f ξ ≠ 0⟧ ⟹ ¬ f constant_on S›*)) (*goals: 1. ‹((f::complex ⇒ complex) has_field_derivative deriv f (ξ::complex)) (at ξ)› 2. ‹open (S::complex set)› 3. ‹(ξ::complex) ∈ (S::complex set)› 4. ‹deriv (f::complex ⇒ complex) (ξ::complex) ≠ (0::complex)› discuss goal 1*) apply ((use assms in ‹auto simp: holomorphic_derivI›)[1]) (*discuss goal 2*) apply ((use assms in ‹auto simp: holomorphic_derivI›)[1]) (*discuss goal 3*) apply ((use assms in ‹auto simp: holomorphic_derivI›)[1]) (*discuss goal 4*) apply ((use assms in ‹auto simp: holomorphic_derivI›)[1]) (*proven 4 subgoals*) . subsection‹Analyticity on a set› definition✐‹tag important› analytic_on (infixl "(analytic'_on)" 50) where "f analytic_on S ≡ ∀x ∈ S. ∃ε. 0 < ε ∧ f holomorphic_on (ball x ε)" named_theorems✐‹tag important› analytic_intros "introduction rules for proving analyticity" lemma analytic_imp_holomorphic: "f analytic_on S ⟹ f holomorphic_on S" unfolding analytic_on_def holomorphic_on_def (*goal: ‹∀x::complex∈S::complex set. ∃ε>0::real. ∀xa::complex∈ball x ε. (f::complex ⇒ complex) field_differentiable at xa within ball x ε ⟹ ∀x::complex∈S. f field_differentiable at x within S›*) using centre_in_ball (*‹(?x ∈ ball ?x ?e) = (0 < ?e)›*) field_differentiable_at_within (*‹(?f::?'a ⇒ ?'a) field_differentiable at (?x::?'a) ⟹ ?f field_differentiable at ?x within (?S::?'a set)›*) field_differentiable_within_open (*‹⟦?a ∈ ?S; open ?S⟧ ⟹ (?f field_differentiable at ?a within ?S) = (?f field_differentiable at ?a)›*) by blast lemma analytic_on_open: "open S ⟹ f analytic_on S ⟷ f holomorphic_on S" by (meson analytic_imp_holomorphic (*‹?f analytic_on ?S ⟹ ?f holomorphic_on ?S›*) analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*) openE (*‹⟦open ?S; ?x ∈ ?S; ⋀e. ⟦0 < e; ball ?x e ⊆ ?S⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma constant_on_imp_analytic_on: assumes "f constant_on A" "open A" shows "f analytic_on A" by (simp add: analytic_on_open (*‹open ?S ⟹ (?f analytic_on ?S) = (?f holomorphic_on ?S)›*) assms (*‹f constant_on A› ‹open A›*) constant_on_imp_holomorphic_on (*‹?f constant_on ?A ⟹ ?f holomorphic_on ?A›*)) lemma analytic_on_imp_differentiable_at: "f analytic_on S ⟹ x ∈ S ⟹ f field_differentiable (at x)" using analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) holomorphic_on_imp_differentiable_at (*‹⟦(?f::complex ⇒ complex) holomorphic_on (?s::complex set); open ?s; (?x::complex) ∈ ?s⟧ ⟹ ?f field_differentiable at ?x›*) by auto lemma analytic_at_imp_isCont: assumes "f analytic_on {z}" shows "isCont f z" by (meson analytic_on_imp_differentiable_at (*‹⟦?f analytic_on ?S; ?x ∈ ?S⟧ ⟹ ?f field_differentiable at ?x›*) assms (*‹f analytic_on {z}›*) field_differentiable_imp_continuous_at (*‹?f field_differentiable at ?x within ?S ⟹ continuous (at ?x within ?S) ?f›*) insertCI (*‹(?a ∉ ?B ⟹ ?a = ?b) ⟹ ?a ∈ insert ?b ?B›*)) lemma analytic_at_neq_imp_eventually_neq: assumes "f analytic_on {x}" "f x ≠ c" shows "eventually (λy. f y ≠ c) (at x)" using analytic_at_imp_isCont (*‹?f analytic_on {?z} ⟹ isCont ?f ?z›*) assms (*‹f analytic_on {x}› ‹(f::complex ⇒ complex) (x::complex) ≠ (c::complex)›*) isContD (*‹isCont ?f ?x ⟹ ?f ─?x→ ?f ?x›*) tendsto_imp_eventually_ne (*‹⟦(?f ⤏ ?c) ?F; ?c ≠ ?c'⟧ ⟹ ∀⇩F z in ?F. ?f z ≠ ?c'›*) by blast lemma analytic_on_subset: "f analytic_on S ⟹ T ⊆ S ⟹ f analytic_on T" by (auto simp: analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) lemma analytic_on_Un: "f analytic_on (S ∪ T) ⟷ f analytic_on S ∧ f analytic_on T" by (auto simp: analytic_on_def (*‹(?f::complex ⇒ complex) analytic_on (?S::complex set) ≡ ∀x::complex∈?S. ∃ε>0::real. ?f holomorphic_on ball x ε›*)) lemma analytic_on_Union: "f analytic_on (⋃𝒯) ⟷ (∀T ∈ 𝒯. f analytic_on T)" by (auto simp: analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) lemma analytic_on_UN: "f analytic_on (⋃i∈I. S i) ⟷ (∀i∈I. f analytic_on (S i))" by (auto simp: analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) lemma analytic_on_holomorphic: "f analytic_on S ⟷ (∃T. open T ∧ S ⊆ T ∧ f holomorphic_on T)" (is "?lhs = ?rhs") proof (-) (*goal: ‹(f analytic_on S) = (∃T. open T ∧ S ⊆ T ∧ f holomorphic_on T)›*) have "?lhs ⟷ (∃T. open T ∧ S ⊆ T ∧ f analytic_on T)" proof (safe) (*goals: 1. ‹(f::complex ⇒ complex) analytic_on (S::complex set) ⟹ ∃T::complex set. open T ∧ S ⊆ T ∧ f analytic_on T› 2. ‹⋀T::complex set. ⟦open T; (S::complex set) ⊆ T; (f::complex ⇒ complex) analytic_on T⟧ ⟹ f analytic_on S›*) assume "f analytic_on S" (*‹(f::complex ⇒ complex) analytic_on (S::complex set)›*) then have "∀x ∈ ⋃{U. open U ∧ f analytic_on U}. ∃ε>0. f holomorphic_on ball x ε" using analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) by force moreover have "S ⊆ ⋃{U. open U ∧ f analytic_on U}" using ‹f analytic_on S› (*‹f analytic_on S›*) by (smt (verit, best) open_ball (*‹open (ball (?x::?'a::metric_space) (?e::real))›*) Union_iff (*‹((?A::?'a::type) ∈ ⋃ (?C::?'a::type set set)) = (∃X::?'a::type set∈?C. ?A ∈ X)›*) analytic_on_def (*‹(?f::complex ⇒ complex) analytic_on (?S::complex set) ≡ ∀x::complex∈?S. ∃ε>0::real. ?f holomorphic_on ball x ε›*) analytic_on_open (*‹open (?S::complex set) ⟹ ((?f::complex ⇒ complex) analytic_on ?S) = (?f holomorphic_on ?S)›*) centre_in_ball (*‹((?x::?'a::metric_space) ∈ ball ?x (?e::real)) = ((0::real) < ?e)›*) mem_Collect_eq (*‹((?a::?'a::type) ∈ Collect (?P::?'a::type ⇒ bool)) = ?P ?a›*) subsetI (*‹(⋀x::?'a::type. x ∈ (?A::?'a::type set) ⟹ x ∈ (?B::?'a::type set)) ⟹ ?A ⊆ ?B›*)) ultimately show "∃T. open T ∧ S ⊆ T ∧ f analytic_on T" unfolding analytic_on_def (*goal: ‹∃T. open T ∧ S ⊆ T ∧ (∀x∈T. ∃ε>0. f holomorphic_on ball x ε)›*) by (metis (mono_tags, lifting) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) open_Union (*‹∀S∈?K. open S ⟹ open (⋃ ?K)›*)) next (*goal: ‹⋀T::complex set. ⟦open T; (S::complex set) ⊆ T; (f::complex ⇒ complex) analytic_on T⟧ ⟹ f analytic_on S›*) fix T assume "open T" "S ⊆ T" "f analytic_on T" (*‹open (T::complex set)› ‹(S::complex set) ⊆ (T::complex set)› ‹(f::complex ⇒ complex) analytic_on (T::complex set)›*) then show "f analytic_on S" by (metis analytic_on_subset (*‹⟦?f analytic_on ?S; ?T ⊆ ?S⟧ ⟹ ?f analytic_on ?T›*)) qed also (*calculation: ‹(f analytic_on S) = (∃T. open T ∧ S ⊆ T ∧ f analytic_on T)›*) have "… ⟷ ?rhs" by (auto simp: analytic_on_open (*‹open ?S ⟹ (?f analytic_on ?S) = (?f holomorphic_on ?S)›*)) finally (*calculation: ‹(f analytic_on S) = (∃T. open T ∧ S ⊆ T ∧ f holomorphic_on T)›*) show "?thesis" (*goal: ‹((f::complex ⇒ complex) analytic_on (S::complex set)) = (∃T::complex set. open T ∧ S ⊆ T ∧ f holomorphic_on T)›*) . qed lemma analytic_on_linear [analytic_intros,simp]: "((*) c) analytic_on S" by (auto simp add: analytic_on_holomorphic (*‹(?f analytic_on ?S) = (∃T. open T ∧ ?S ⊆ T ∧ ?f holomorphic_on T)›*)) lemma analytic_on_const [analytic_intros,simp]: "(λz. c) analytic_on S" by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) holomorphic_on_const (*‹(λz. ?c) holomorphic_on ?s›*) zero_less_one (*‹0 < 1›*)) lemma analytic_on_ident [analytic_intros,simp]: "(λx. x) analytic_on S" by (simp add: analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) gt_ex (*‹∃y. ?x < y›*)) lemma analytic_on_id [analytic_intros]: "id analytic_on S" unfolding id_def (*goal: ‹(λx. x) analytic_on S›*) by (rule analytic_on_ident (*‹(λx. x) analytic_on ?S›*)) lemma analytic_on_scaleR [analytic_intros]: "f analytic_on A ⟹ (λw. x *⇩R f w) analytic_on A" by (metis analytic_on_holomorphic (*‹(?f analytic_on ?S) = (∃T. open T ∧ ?S ⊆ T ∧ ?f holomorphic_on T)›*) holomorphic_on_scaleR (*‹?f holomorphic_on ?A ⟹ (λx. ?c *⇩R ?f x) holomorphic_on ?A›*)) lemma analytic_on_compose: assumes f: "f analytic_on S" and g: "g analytic_on (f ` S)" shows "(g ∘ f) analytic_on S" unfolding analytic_on_def (*goal: ‹∀x∈S. ∃ε>0. g ∘ f holomorphic_on ball x ε›*) proof (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀x::complex. x ∈ (S::complex set) ⟹ ∃ε>0::real. (g::complex ⇒ complex) ∘ (f::complex ⇒ complex) holomorphic_on ball x ε›*) fix x assume x: "x ∈ S" (*‹(x::complex) ∈ (S::complex set)›*) then obtain e where e: "0 < e" and fh: "f holomorphic_on ball x e" (*goal: ‹(⋀e::real. ⟦(0::real) < e; (f::complex ⇒ complex) holomorphic_on ball (x::complex) e⟧ ⟹ thesis::bool) ⟹ thesis›*) using f (*‹f analytic_on S›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball (f x) e'" (*goal: ‹(⋀e'. ⟦0 < e'; g holomorphic_on ball (f x) e'⟧ ⟹ thesis) ⟹ thesis›*) using g (*‹g analytic_on f ` S›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) g (*‹g analytic_on f ` S›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) x (*‹x ∈ S›*)) have "isCont f x" by (metis analytic_on_imp_differentiable_at (*‹⟦(?f::complex ⇒ complex) analytic_on (?S::complex set); (?x::complex) ∈ ?S⟧ ⟹ ?f field_differentiable at ?x›*) field_differentiable_imp_continuous_at (*‹(?f::?'a ⇒ ?'a) field_differentiable at (?x::?'a) within (?S::?'a set) ⟹ continuous (at ?x within ?S) ?f›*) f (*‹(f::complex ⇒ complex) analytic_on (S::complex set)›*) x (*‹(x::complex) ∈ (S::complex set)›*)) with e' (*‹0 < e'›*) obtain d where d: "0 < d" and fd: "f ` ball x d ⊆ ball (f x) e'" (*goal: ‹(⋀d::real. ⟦(0::real) < d; (f::complex ⇒ complex) ` ball (x::complex) d ⊆ ball (f x) (e'::real)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: continuous_at_ball (*‹isCont ?f ?x = (∀e>0. ∃d>0. ?f ` ball ?x d ⊆ ball (?f ?x) e)›*)) have "g ∘ f holomorphic_on ball x (min d e)" by (meson fd (*‹f ` ball x d ⊆ ball (f x) e'›*) fh (*‹f holomorphic_on ball x e›*) gh (*‹g holomorphic_on ball (f x) e'›*) holomorphic_on_compose_gen (*‹⟦?f holomorphic_on ?s; ?g holomorphic_on ?t; ?f ` ?s ⊆ ?t⟧ ⟹ ?g ∘ ?f holomorphic_on ?s›*) holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*) image_mono (*‹?A ⊆ ?B ⟹ ?f ` ?A ⊆ ?f ` ?B›*) min.cobounded1 (*‹min ?a ?b ≤ ?a›*) min.cobounded2 (*‹min ?a ?b ≤ ?b›*) subset_ball (*‹?d ≤ ?e ⟹ ball ?x ?d ⊆ ball ?x ?e›*)) then show "∃e>0. g ∘ f holomorphic_on ball x e" by (metis d (*‹(0::real) < (d::real)›*) e (*‹(0::real) < (e::real)›*) min_less_iff_conj (*‹((?z::?'a::linorder) < min (?x::?'a::linorder) (?y::?'a::linorder)) = (?z < ?x ∧ ?z < ?y)›*)) qed lemma analytic_on_compose_gen: "f analytic_on S ⟹ g analytic_on T ⟹ (⋀z. z ∈ S ⟹ f z ∈ T) ⟹ g ∘ f analytic_on S" by (metis analytic_on_compose (*‹⟦(?f::complex ⇒ complex) analytic_on (?S::complex set); (?g::complex ⇒ complex) analytic_on ?f ` ?S⟧ ⟹ ?g ∘ ?f analytic_on ?S›*) analytic_on_subset (*‹⟦(?f::complex ⇒ complex) analytic_on (?S::complex set); (?T::complex set) ⊆ ?S⟧ ⟹ ?f analytic_on ?T›*) image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*)) lemma analytic_on_neg [analytic_intros]: "f analytic_on S ⟹ (λz. -(f z)) analytic_on S" by (metis analytic_on_holomorphic (*‹(?f analytic_on ?S) = (∃T. open T ∧ ?S ⊆ T ∧ ?f holomorphic_on T)›*) holomorphic_on_minus (*‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A›*)) lemma analytic_on_add [analytic_intros]: assumes f: "f analytic_on S" and g: "g analytic_on S" shows "(λz. f z + g z) analytic_on S" unfolding analytic_on_def (*goal: ‹∀x∈S. ∃ε>0. (λz. f z + g z) holomorphic_on ball x ε›*) proof (intro ballI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ (?P::?'a ⇒ bool) x) ⟹ ∀x::?'a∈?A. ?P x›*)) (*goal: ‹⋀x. x ∈ S ⟹ ∃ε>0. (λz. f z + g z) holomorphic_on ball x ε›*) fix z assume z: "z ∈ S" (*‹(z::complex) ∈ (S::complex set)›*) then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" (*goal: ‹(⋀e. ⟦0 < e; f holomorphic_on ball z e⟧ ⟹ thesis) ⟹ thesis›*) using f (*‹(f::complex ⇒ complex) analytic_on (S::complex set)›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball z e'" (*goal: ‹(⋀e'::real. ⟦(0::real) < e'; (g::complex ⇒ complex) holomorphic_on ball (z::complex) e'⟧ ⟹ thesis::bool) ⟹ thesis›*) using g (*‹g analytic_on S›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) g (*‹g analytic_on S›*) z (*‹z ∈ S›*)) have "(λz. f z + g z) holomorphic_on ball z (min e e')" by (metis fh (*‹f holomorphic_on ball z e›*) gh (*‹g holomorphic_on ball z e'›*) holomorphic_on_add (*‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A›*) holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*) linorder_linear (*‹?x ≤ ?y ∨ ?y ≤ ?x›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) subset_ball (*‹?d ≤ ?e ⟹ ball ?x ?d ⊆ ball ?x ?e›*)) then show "∃e>0. (λz. f z + g z) holomorphic_on ball z e" by (metis e (*‹0 < e›*) e' (*‹0 < e'›*) min_less_iff_conj (*‹(?z < min ?x ?y) = (?z < ?x ∧ ?z < ?y)›*)) qed lemma analytic_on_mult [analytic_intros]: assumes f: "f analytic_on S" and g: "g analytic_on S" shows "(λz. f z * g z) analytic_on S" unfolding analytic_on_def (*goal: ‹∀x∈S. ∃ε>0. (λz. f z * g z) holomorphic_on ball x ε›*) proof (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀x. x ∈ S ⟹ ∃ε>0. (λz. f z * g z) holomorphic_on ball x ε›*) fix z assume z: "z ∈ S" (*‹(z::complex) ∈ (S::complex set)›*) then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" (*goal: ‹(⋀e::real. ⟦(0::real) < e; (f::complex ⇒ complex) holomorphic_on ball (z::complex) e⟧ ⟹ thesis::bool) ⟹ thesis›*) using f (*‹(f::complex ⇒ complex) analytic_on (S::complex set)›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) obtain e' where e': "0 < e'" and gh: "g holomorphic_on ball z e'" (*goal: ‹(⋀e'::real. ⟦(0::real) < e'; (g::complex ⇒ complex) holomorphic_on ball (z::complex) e'⟧ ⟹ thesis::bool) ⟹ thesis›*) using g (*‹g analytic_on S›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*) g (*‹g analytic_on S›*) z (*‹z ∈ S›*)) have "(λz. f z * g z) holomorphic_on ball z (min e e')" by (metis fh (*‹f holomorphic_on ball z e›*) gh (*‹g holomorphic_on ball z e'›*) holomorphic_on_mult (*‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A›*) holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*) min.absorb_iff2 (*‹(?b ≤ ?a) = (min ?a ?b = ?b)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) subset_ball (*‹?d ≤ ?e ⟹ ball ?x ?d ⊆ ball ?x ?e›*)) then show "∃e>0. (λz. f z * g z) holomorphic_on ball z e" by (metis e (*‹0 < e›*) e' (*‹0 < e'›*) min_less_iff_conj (*‹(?z < min ?x ?y) = (?z < ?x ∧ ?z < ?y)›*)) qed lemma analytic_on_diff [analytic_intros]: assumes f: "f analytic_on S" and g: "g analytic_on S" shows "(λz. f z - g z) analytic_on S" proof (-) (*goal: ‹(λz::complex. (f::complex ⇒ complex) z - (g::complex ⇒ complex) z) analytic_on (S::complex set)›*) have "(λz. - g z) analytic_on S" by (simp add: analytic_on_neg (*‹?f analytic_on ?S ⟹ (λz. - ?f z) analytic_on ?S›*) g (*‹g analytic_on S›*)) then have "(λz. f z + - g z) analytic_on S" using analytic_on_add (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z + ?g z) analytic_on ?S›*) f (*‹(f::complex ⇒ complex) analytic_on (S::complex set)›*) by blast then show "?thesis" (*goal: ‹(λz. f z - g z) analytic_on S›*) by fastforce qed lemma analytic_on_inverse [analytic_intros]: assumes f: "f analytic_on S" and nz: "(⋀z. z ∈ S ⟹ f z ≠ 0)" shows "(λz. inverse (f z)) analytic_on S" unfolding analytic_on_def (*goal: ‹∀x∈S. ∃ε>0. (λz. inverse (f z)) holomorphic_on ball x ε›*) proof (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀x. x ∈ S ⟹ ∃ε>0. (λz. inverse (f z)) holomorphic_on ball x ε›*) fix z assume z: "z ∈ S" (*‹(z::complex) ∈ (S::complex set)›*) then obtain e where e: "0 < e" and fh: "f holomorphic_on ball z e" (*goal: ‹(⋀e. ⟦0 < e; f holomorphic_on ball z e⟧ ⟹ thesis) ⟹ thesis›*) using f (*‹(f::complex ⇒ complex) analytic_on (S::complex set)›*) by (metis analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) have "continuous_on (ball z e) f" by (metis fh (*‹f holomorphic_on ball z e›*) holomorphic_on_imp_continuous_on (*‹?f holomorphic_on ?s ⟹ continuous_on ?s ?f›*)) then obtain e' where e': "0 < e'" and nz': "⋀y. dist z y < e' ⟹ f y ≠ 0" (*goal: ‹(⋀e'. ⟦0 < e'; ⋀y. dist z y < e' ⟹ f y ≠ 0⟧ ⟹ thesis) ⟹ thesis›*) by (metis open_ball (*‹open (ball ?x ?e)›*) centre_in_ball (*‹(?x ∈ ball ?x ?e) = (0 < ?e)›*) continuous_on_open_avoid (*‹⟦continuous_on ?s ?f; open ?s; ?x ∈ ?s; ?f ?x ≠ ?a⟧ ⟹ ∃e>0. ∀y. dist ?x y < e ⟶ ?f y ≠ ?a›*) e (*‹0 < e›*) z (*‹z ∈ S›*) nz (*‹?z ∈ S ⟹ f ?z ≠ 0›*)) have "(λz. inverse (f z)) holomorphic_on ball z (min e e')" using fh (*‹f holomorphic_on ball z e›*) holomorphic_on_inverse (*‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A›*) holomorphic_on_open (*‹open ?s ⟹ (?f holomorphic_on ?s) = (∀x∈?s. ∃f'. (?f has_field_derivative f') (at x))›*) nz' (*‹dist z ?y < e' ⟹ f ?y ≠ 0›*) by fastforce then show "∃e>0. (λz. inverse (f z)) holomorphic_on ball z e" by (metis e (*‹(0::real) < (e::real)›*) e' (*‹(0::real) < (e'::real)›*) min_less_iff_conj (*‹((?z::?'a::linorder) < min (?x::?'a::linorder) (?y::?'a::linorder)) = (?z < ?x ∧ ?z < ?y)›*)) qed lemma analytic_on_divide [analytic_intros]: assumes f: "f analytic_on S" and g: "g analytic_on S" and nz: "(⋀z. z ∈ S ⟹ g z ≠ 0)" shows "(λz. f z / g z) analytic_on S" unfolding divide_inverse (*goal: ‹(λz. f z * inverse (g z)) analytic_on S›*) by (metis analytic_on_inverse (*‹⟦?f analytic_on ?S; ⋀z. z ∈ ?S ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) analytic_on ?S›*) analytic_on_mult (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S›*) f (*‹f analytic_on S›*) g (*‹g analytic_on S›*) nz (*‹?z ∈ S ⟹ g ?z ≠ 0›*)) lemma analytic_on_power [analytic_intros]: "f analytic_on S ⟹ (λz. (f z) ^ n) analytic_on S" apply (induct n) (*goals: 1. ‹f analytic_on S ⟹ (λz. f z ^ 0) analytic_on S› 2. ‹⋀n. ⟦f analytic_on S ⟹ (λz. f z ^ n) analytic_on S; f analytic_on S⟧ ⟹ (λz. f z ^ Suc n) analytic_on S› discuss goal 1*) apply ((auto simp: analytic_on_mult (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: analytic_on_mult (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S›*))[1]) (*proven 2 subgoals*) . lemma analytic_on_power_int [analytic_intros]: assumes nz: "n ≥ 0 ∨ (∀x∈A. f x ≠ 0)" and f: "f analytic_on A" shows "(λx. f x powi n) analytic_on A" proof (cases "n ≥ 0") (*goals: 1. ‹0 ≤ n ⟹ (λx. f x powi n) analytic_on A› 2. ‹¬ 0 ≤ n ⟹ (λx. f x powi n) analytic_on A›*) case True (*‹0 ≤ n›*) have "(λx. f x ^ nat n) analytic_on A" using analytic_on_power (*‹?f analytic_on ?S ⟹ (λz. ?f z ^ ?n) analytic_on ?S›*) f (*‹f analytic_on A›*) by blast with True (*‹0 ≤ n›*) show "?thesis" (*goal: ‹(λx. f x powi n) analytic_on A›*) by (simp add: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*)) next (*goal: ‹¬ 0 ≤ n ⟹ (λx. f x powi n) analytic_on A›*) case False (*‹¬ 0 ≤ n›*) hence "(λx. inverse (f x ^ nat (-n))) analytic_on A" using nz (*‹0 ≤ n ∨ (∀x∈A. f x ≠ 0)›*) by (auto intro!: analytic_intros (*‹(*) ?c analytic_on ?S› ‹(λz. ?c) analytic_on ?S› ‹(λx. x) analytic_on ?S› ‹id analytic_on ?S› ‹?f analytic_on ?A ⟹ (λw. ?x *⇩R ?f w) analytic_on ?A› ‹?f analytic_on ?S ⟹ (λz. - ?f z) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z + ?g z) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z - ?g z) analytic_on ?S› ‹⟦?f analytic_on ?S; ⋀z. z ∈ ?S ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S; ⋀z. z ∈ ?S ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) analytic_on ?S› ‹?f analytic_on ?S ⟹ (λz. ?f z ^ ?n) analytic_on ?S›*) f (*‹f analytic_on A›*)) with False (*‹¬ (0::int) ≤ (n::int)›*) show "?thesis" (*goal: ‹(λx. f x powi n) analytic_on A›*) by (simp add: power_int_def (*‹?x powi ?n = (if 0 ≤ ?n then ?x ^ nat ?n else inverse ?x ^ nat (- ?n))›*) power_inverse (*‹inverse ?a ^ ?n = inverse (?a ^ ?n)›*)) qed lemma analytic_on_sum [analytic_intros]: "(⋀i. i ∈ I ⟹ (f i) analytic_on S) ⟹ (λx. sum (λi. f i x) I) analytic_on S" apply (induct I rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*)) (*goals: 1. ‹⋀A. ⟦infinite A; ⋀i. i ∈ A ⟹ f i analytic_on S⟧ ⟹ (λx. ∑i∈A. f i x) analytic_on S› 2. ‹(⋀i. i ∈ {} ⟹ f i analytic_on S) ⟹ (λx. ∑i∈{}. f i x) analytic_on S› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. i ∈ F ⟹ f i analytic_on S) ⟹ (λx. ∑i∈F. f i x) analytic_on S; ⋀i. i ∈ insert x F ⟹ f i analytic_on S⟧ ⟹ (λxa. ∑i∈insert x F. f i xa) analytic_on S› discuss goal 1*) apply ((auto simp: analytic_on_add (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z + ?g z) analytic_on ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: analytic_on_add (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z + ?g z) analytic_on ?S›*))[1]) (*discuss goal 3*) apply ((auto simp: analytic_on_add (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z + ?g z) analytic_on ?S›*))[1]) (*proven 3 subgoals*) . lemma analytic_on_prod [analytic_intros]: "(⋀i. i ∈ I ⟹ (f i) analytic_on S) ⟹ (λx. prod (λi. f i x) I) analytic_on S" apply (induct I rule: infinite_finite_induct (*‹⟦⋀A::?'a set. infinite A ⟹ (?P::?'a set ⇒ bool) A; ?P {}; ⋀(x::?'a) F::?'a set. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P (?A::?'a set)›*)) (*goals: 1. ‹⋀A. ⟦infinite A; ⋀i. i ∈ A ⟹ f i analytic_on S⟧ ⟹ (λx. ∏i∈A. f i x) analytic_on S› 2. ‹(⋀i. i ∈ {} ⟹ f i analytic_on S) ⟹ (λx. ∏i∈{}. f i x) analytic_on S› 3. ‹⋀x F. ⟦finite F; x ∉ F; (⋀i. i ∈ F ⟹ f i analytic_on S) ⟹ (λx. ∏i∈F. f i x) analytic_on S; ⋀i. i ∈ insert x F ⟹ f i analytic_on S⟧ ⟹ (λxa. ∏i∈insert x F. f i xa) analytic_on S› discuss goal 1*) apply ((auto simp: analytic_on_mult (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S›*))[1]) (*discuss goal 2*) apply ((auto simp: analytic_on_mult (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S›*))[1]) (*discuss goal 3*) apply ((auto simp: analytic_on_mult (*‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S›*))[1]) (*proven 3 subgoals*) . lemma analytic_on_gbinomial [analytic_intros]: "f analytic_on A ⟹ (λw. f w gchoose n) analytic_on A" unfolding gbinomial_prod_rev (*goal: ‹f analytic_on A ⟹ (λw. (∏i = 0..<n. f w - complex_of_nat i) / fact n) analytic_on A›*) apply (intro analytic_intros (*‹(*) ?c analytic_on ?S› ‹(λz. ?c) analytic_on ?S› ‹(λx. x) analytic_on ?S› ‹id analytic_on ?S› ‹?f analytic_on ?A ⟹ (λw. ?x *⇩R ?f w) analytic_on ?A› ‹?f analytic_on ?S ⟹ (λz. - ?f z) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z + ?g z) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z * ?g z) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S⟧ ⟹ (λz. ?f z - ?g z) analytic_on ?S› ‹⟦?f analytic_on ?S; ⋀z. z ∈ ?S ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) analytic_on ?S› ‹⟦?f analytic_on ?S; ?g analytic_on ?S; ⋀z. z ∈ ?S ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) analytic_on ?S› ‹?f analytic_on ?S ⟹ (λz. ?f z ^ ?n) analytic_on ?S› and more 3 facts*)) (*goals: 1. ‹⋀i. ⟦f analytic_on A; i ∈ {0..<n}⟧ ⟹ f analytic_on A› 2. ‹⋀w. ⟦f analytic_on A; w ∈ A⟧ ⟹ fact n ≠ 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma deriv_left_inverse: assumes "f holomorphic_on S" and "g holomorphic_on T" and "open S" and "open T" and "f ` S ⊆ T" and [simp]: "⋀z. z ∈ S ⟹ g (f z) = z" and "w ∈ S" shows "deriv f w * deriv g (f w) = 1" proof (-) (*goal: ‹deriv f w * deriv g (f w) = 1›*) have "deriv f w * deriv g (f w) = deriv g (f w) * deriv f w" by (simp add: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*)) also (*calculation: ‹deriv f w * deriv g (f w) = deriv g (f w) * deriv f w›*) have "… = deriv (g ∘ f) w" using assms (*‹f holomorphic_on S› ‹g holomorphic_on T› ‹open S› ‹open (T::complex set)› ‹f ` S ⊆ T› ‹(?z::complex) ∈ (S::complex set) ⟹ (g::complex ⇒ complex) ((f::complex ⇒ complex) ?z) = ?z› ‹w ∈ S›*) by (metis analytic_on_imp_differentiable_at (*‹⟦?f analytic_on ?S; ?x ∈ ?S⟧ ⟹ ?f field_differentiable at ?x›*) analytic_on_open (*‹open ?S ⟹ (?f analytic_on ?S) = (?f holomorphic_on ?S)›*) deriv_chain (*‹⟦?f field_differentiable at ?x; ?g field_differentiable at (?f ?x)⟧ ⟹ deriv (?g ∘ ?f) ?x = deriv ?g (?f ?x) * deriv ?f ?x›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*)) also (*calculation: ‹deriv f w * deriv g (f w) = deriv (g ∘ f) w›*) have "… = deriv id w" proof (rule complex_derivative_transform_within_open [where s=S] (*‹⟦?f holomorphic_on S; ?g holomorphic_on S; open S; ?z ∈ S; ⋀w. w ∈ S ⟹ ?f w = ?g w⟧ ⟹ deriv ?f ?z = deriv ?g ?z›*)) (*goals: 1. ‹g ∘ f holomorphic_on S› 2. ‹id holomorphic_on S› 3. ‹open S› 4. ‹w ∈ S› 5. ‹⋀w. w ∈ S ⟹ (g ∘ f) w = id w›*) show "g ∘ f holomorphic_on S" apply (rule assms (*‹f holomorphic_on S› ‹g holomorphic_on T› ‹open S› ‹open T› ‹f ` S ⊆ T› ‹?z ∈ S ⟹ g (f ?z) = ?z› ‹w ∈ S›*) holomorphic_on_compose_gen (*‹⟦?f holomorphic_on ?s; ?g holomorphic_on ?t; ?f ` ?s ⊆ ?t⟧ ⟹ ?g ∘ ?f holomorphic_on ?s›*) holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 7 facts*)) (*goals: 1. ‹(f::complex ⇒ complex) holomorphic_on (S::complex set)› 2. ‹(g::complex ⇒ complex) holomorphic_on (?t::complex set)› 3. ‹(f::complex ⇒ complex) ` (S::complex set) ⊆ (?t::complex set)› discuss goal 1*) apply (rule assms (*‹f holomorphic_on S› ‹g holomorphic_on T› ‹open S› ‹open T› ‹f ` S ⊆ T› ‹?z ∈ S ⟹ g (f ?z) = ?z› ‹w ∈ S›*) holomorphic_on_compose_gen (*‹⟦?f holomorphic_on ?s; ?g holomorphic_on ?t; ?f ` ?s ⊆ ?t⟧ ⟹ ?g ∘ ?f holomorphic_on ?s›*) holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 7 facts*)) (*discuss goal 2*) apply (rule assms (*‹f holomorphic_on S› ‹g holomorphic_on T› ‹open S› ‹open T› ‹f ` S ⊆ T› ‹?z ∈ S ⟹ g (f ?z) = ?z› ‹w ∈ S›*) holomorphic_on_compose_gen (*‹⟦?f holomorphic_on ?s; ?g holomorphic_on ?t; ?f ` ?s ⊆ ?t⟧ ⟹ ?g ∘ ?f holomorphic_on ?s›*) holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 7 facts*)) (*discuss goal 3*) apply (rule assms (*‹f holomorphic_on S› ‹g holomorphic_on T› ‹open S› ‹open T› ‹f ` S ⊆ T› ‹?z ∈ S ⟹ g (f ?z) = ?z› ‹w ∈ S›*) holomorphic_on_compose_gen (*‹⟦?f holomorphic_on ?s; ?g holomorphic_on ?t; ?f ` ?s ⊆ ?t⟧ ⟹ ?g ∘ ?f holomorphic_on ?s›*) holomorphic_intros (*‹?f holomorphic_on {}› ‹(*) ?c holomorphic_on ?s› ‹(λz. ?c) holomorphic_on ?s› ‹(λx. x) holomorphic_on ?s› ‹id holomorphic_on ?s› ‹?f holomorphic_on ?A ⟹ (λz. - ?f z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z + ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z - ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A⟧ ⟹ (λz. ?f z * ?g z) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?f z ≠ 0⟧ ⟹ (λz. inverse (?f z)) holomorphic_on ?A› ‹⟦?f holomorphic_on ?A; ?g holomorphic_on ?A; ⋀z. z ∈ ?A ⟹ ?g z ≠ 0⟧ ⟹ (λz. ?f z / ?g z) holomorphic_on ?A› ‹?f holomorphic_on ?A ⟹ (λz. ?f z ^ ?n) holomorphic_on ?A› and more 7 facts*)) (*proven 3 subgoals*) . qed (use assms in auto) (*solves the remaining goals: 1. ‹id holomorphic_on S› 2. ‹open S› 3. ‹w ∈ S› 4. ‹⋀w. w ∈ S ⟹ (g ∘ f) w = id w›*) also (*calculation: ‹deriv f w * deriv g (f w) = deriv id w›*) have "… = 1" by simp finally (*calculation: ‹deriv (f::complex ⇒ complex) (w::complex) * deriv (g::complex ⇒ complex) (f w) = (1::complex)›*) show "?thesis" (*goal: ‹deriv (f::complex ⇒ complex) (w::complex) * deriv (g::complex ⇒ complex) (f w) = (1::complex)›*) . qed subsection✐‹tag unimportant›‹Analyticity at a point› lemma analytic_at_ball: "f analytic_on {z} ⟷ (∃e. 0<e ∧ f holomorphic_on ball z e)" by (metis analytic_on_def (*‹(?f::complex ⇒ complex) analytic_on (?S::complex set) ≡ ∀x::complex∈?S. ∃ε>0::real. ?f holomorphic_on ball x ε›*) singleton_iff (*‹((?b::?'a) ∈ {?a::?'a}) = (?b = ?a)›*)) lemma analytic_at: "f analytic_on {z} ⟷ (∃s. open s ∧ z ∈ s ∧ f holomorphic_on s)" by (metis analytic_on_holomorphic (*‹(?f analytic_on ?S) = (∃T. open T ∧ ?S ⊆ T ∧ ?f holomorphic_on T)›*) empty_subsetI (*‹{} ⊆ ?A›*) insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*)) lemma holomorphic_on_imp_analytic_at: assumes "f holomorphic_on A" "open A" "z ∈ A" shows "f analytic_on {z}" using assms (*‹f holomorphic_on A› ‹open (A::complex set)› ‹z ∈ A›*) by (meson analytic_at (*‹(?f analytic_on {?z}) = (∃s. open s ∧ ?z ∈ s ∧ ?f holomorphic_on s)›*)) lemma analytic_on_analytic_at: "f analytic_on s ⟷ (∀z ∈ s. f analytic_on {z})" by (metis analytic_at_ball (*‹(?f analytic_on {?z}) = (∃e>0. ?f holomorphic_on ball ?z e)›*) analytic_on_def (*‹?f analytic_on ?S ≡ ∀x∈?S. ∃ε>0. ?f holomorphic_on ball x ε›*)) lemma analytic_at_two: "f analytic_on {z} ∧ g analytic_on {z} ⟷ (∃S. open S ∧ z ∈ S ∧ f holomorphic_on S ∧ g holomorphic_on S)" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹f analytic_on {z} ∧ g analytic_on {z} ⟹ ∃S. open S ∧ z ∈ S ∧ f holomorphic_on S ∧ g holomorphic_on S› 2. ‹∃S. open S ∧ z ∈ S ∧ f holomorphic_on S ∧ g holomorphic_on S ⟹ f analytic_on {z} ∧ g analytic_on {z}›*) assume "?lhs" (*‹(f::complex ⇒ complex) analytic_on {z::complex} ∧ (g::complex ⇒ complex) analytic_on {z}›*) then obtain S and T where st: "open S" "z ∈ S" "f holomorphic_on S" "open T" "z ∈ T" "g holomorphic_on T" (*goal: ‹(⋀(S::complex set) T::complex set. ⟦open S; (z::complex) ∈ S; (f::complex ⇒ complex) holomorphic_on S; open T; z ∈ T; (g::complex ⇒ complex) holomorphic_on T⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: analytic_at (*‹(?f analytic_on {?z}) = (∃s. open s ∧ ?z ∈ s ∧ ?f holomorphic_on s)›*)) then show "?rhs" by (metis Int_iff (*‹(?c ∈ ?A ∩ ?B) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) holomorphic_on_subset (*‹⟦?f holomorphic_on ?s; ?t ⊆ ?s⟧ ⟹ ?f holomorphic_on ?t›*) inf_le1 (*‹inf ?x ?y ≤ ?x›*) inf_le2 (*‹inf ?x ?y ≤ ?y›*) open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*)) next (*goal: ‹∃S::complex set. open S ∧ (z::complex) ∈ S ∧ (f::complex ⇒ complex) holomorphic_on S ∧ (g::complex ⇒ complex) holomorphic_on S ⟹ f analytic_on {z} ∧ g analytic_on {z}›*) assume "?rhs" (*‹∃S::complex set. open S ∧ (z::complex) ∈ S ∧ (f::complex ⇒ complex) holomorphic_on S ∧ (g::complex ⇒ complex) holomorphic_on S›*) then show "?lhs" by (force simp add: analytic_at (*‹(?f analytic_on {?z}) = (∃s. open s ∧ ?z ∈ s ∧ ?f holomorphic_on s)›*)) qed subsection✐‹tag unimportant›‹Combining theorems for derivative with ``analytic at'' hypotheses› lemma assumes "f analytic_on {z}" "g analytic_on {z}" shows complex_derivative_add_at: "deriv (λw. f w + g w) z = deriv f z + deriv g z" and complex_derivative_diff_at: "deriv (λw. f w - g w) z = deriv f z - deriv g z" and complex_derivative_mult_at: "deriv (λw. f w * g w) z = f z * deriv g z + deriv f z * g z" proof (-) (*goals: 1. ‹deriv (λw. f w + g w) z = deriv f z + deriv g z› 2. ‹deriv (λw. f w - g w) z = deriv f z - deriv g z› 3. ‹deriv (λw. f w * g w) z = f z * deriv g z + deriv f z * g z›*) show "deriv (λw. f w + g w) z = deriv f z + deriv g z" using analytic_on_imp_differentiable_at (*‹⟦(?f::complex ⇒ complex) analytic_on (?S::complex set); (?x::complex) ∈ ?S⟧ ⟹ ?f field_differentiable at ?x›*) assms (*‹f analytic_on {z}› ‹g analytic_on {z}›*) by auto show "deriv (λw. f w - g w) z = deriv f z - deriv g z" using analytic_on_imp_differentiable_at (*‹⟦?f analytic_on ?S; ?x ∈ ?S⟧ ⟹ ?f field_differentiable at ?x›*) assms (*‹f analytic_on {z}› ‹g analytic_on {z}›*) by force obtain S where "open S" "z ∈ S" "f holomorphic_on S" "g holomorphic_on S" (*goal: ‹(⋀S::complex set. ⟦open S; (z::complex) ∈ S; (f::complex ⇒ complex) holomorphic_on S; (g::complex ⇒ complex) holomorphic_on S⟧ ⟹ thesis::bool) ⟹ thesis›*) using assms (*‹f analytic_on {z}› ‹(g::complex ⇒ complex) analytic_on {z::complex}›*) by (metis analytic_at_two (*‹((?f::complex ⇒ complex) analytic_on {?z::complex} ∧ (?g::complex ⇒ complex) analytic_on {?z}) = (∃S::complex set. open S ∧ ?z ∈ S ∧ ?f holomorphic_on S ∧ ?g holomorphic_on S)›*)) then show "deriv (λw. f w * g w) z = f z * deriv g z + deriv f z * g z" by (simp add: DERIV_imp_deriv [OF DERIV_mult'] (*‹⟦(?f1 has_field_derivative ?D1) (at ?x); (?g1 has_field_derivative ?E1) (at ?x)⟧ ⟹ deriv (λx. ?f1 x * ?g1 x) ?x = ?f1 ?x * ?E1 + ?D1 * ?g1 ?x›*) holomorphic_derivI (*‹⟦?f holomorphic_on ?S; open ?S; ?x ∈ ?S⟧ ⟹ (?f has_field_derivative deriv ?f ?x) (at ?x within ?T)›*)) qed lemma deriv_cmult_at: "f analytic_on {z} ⟹ deriv (λw. c * f w) z = c * deriv f z" by (auto simp: complex_derivative_mult_at (*‹⟦?f analytic_on {?z}; ?g analytic_on {?z}⟧ ⟹ deriv (λw. ?f w * ?g w) ?z = ?f ?z * deriv ?g ?z + deriv ?f ?z * ?g ?z›*)) lemma deriv_cmult_right_at: "f analytic_on {z} ⟹ deriv (λw. f w * c) z = deriv f z * c" by (auto simp: complex_derivative_mult_at (*‹⟦(?f::complex ⇒ complex) analytic_on {?z::complex}; (?g::complex ⇒ complex) analytic_on {?z}⟧ ⟹ deriv (λw::complex. ?f w * ?g w) ?z = ?f ?z * deriv ?g ?z + deriv ?f ?z * ?g ?z›*)) subsection✐‹tag unimportant›‹Complex differentiation of sequences and series› (* TODO: Could probably be simplified using Uniform_Limit *) lemma has_complex_derivative_sequence: fixes S :: "complex set" assumes cvs: "convex S" and df: "⋀n x. x ∈ S ⟹ (f n has_field_derivative f' n x) (at x within S)" and conv: "⋀e. 0 < e ⟹ ∃N. ∀n x. n ≥ N ⟶ x ∈ S ⟶ norm (f' n x - g' x) ≤ e" and "∃x l. x ∈ S ∧ ((λn. f n x) ⤏ l) sequentially" shows "∃g. ∀x ∈ S. ((λn. f n x) ⤏ g x) sequentially ∧ (g has_field_derivative (g' x)) (at x within S)" proof (-) (*goal: ‹∃g. ∀x∈S. (λn. f n x) ⇢ g x ∧ (g has_field_derivative g' x) (at x within S)›*) from assms (*‹convex S› ‹?x ∈ S ⟹ (f ?n has_field_derivative f' ?n ?x) (at ?x within S)› ‹(0::real) < (?e::real) ⟹ ∃N::nat. ∀(n::nat) x::complex. N ≤ n ⟶ x ∈ (S::complex set) ⟶ cmod ((f'::nat ⇒ complex ⇒ complex) n x - (g'::complex ⇒ complex) x) ≤ ?e› ‹∃x l. x ∈ S ∧ (λn. f n x) ⇢ l›*) obtain x and l where x: "x ∈ S" and tf: "((λn. f n x) ⤏ l) sequentially" (*goal: ‹(⋀x l. ⟦x ∈ S; (λn. f n x) ⇢ l⟧ ⟹ thesis) ⟹ thesis›*) by blast show "?thesis" (*goal: ‹∃g. ∀x∈S. (λn. f n x) ⇢ g x ∧ (g has_field_derivative g' x) (at x within S)›*) unfolding has_field_derivative_def (*goal: ‹∃g. ∀x∈S. (λn. f n x) ⇢ g x ∧ (g has_derivative (*) (g' x)) (at x within S)›*) proof (rule has_derivative_sequence [OF cvs _ _ x] (*‹⟦⋀(n::nat) x::complex. x ∈ (S::complex set) ⟹ ((?f::nat ⇒ complex ⇒ ?'b) n has_derivative (?f'::nat ⇒ complex ⇒ complex ⇒ ?'b) n x) (at x within S); ⋀e::real. (0::real) < e ⟹ ∀⇩F n::nat in sequentially. ∀x::complex∈S. ∀h::complex. norm (?f' n x h - (?g'::complex ⇒ complex ⇒ ?'b) x h) ≤ e * cmod h; (λn::nat. ?f n (x::complex)) ⇢ (?l::?'b)⟧ ⟹ ∃g::complex ⇒ ?'b. ∀x::complex∈S. (λn::nat. ?f n x) ⇢ g x ∧ (g has_derivative ?g' x) (at x within S)›*)) (*goals: 1. ‹⋀n x. x ∈ S ⟹ (f n has_derivative ?f' n x) (at x within S)› 2. ‹⋀e. 0 < e ⟹ ∀⇩F n in sequentially. ∀x∈S. ∀h. cmod (?f' n x h - g' x * h) ≤ e * cmod h› 3. ‹(λn. f n x) ⇢ ?l›*) show "(λn. f n x) ⇢ l" by (rule tf (*‹(λn. f n x) ⇢ l›*)) next (*goals: 1. ‹⋀(n::nat) x::complex. x ∈ (S::complex set) ⟹ ((f::nat ⇒ complex ⇒ complex) n has_derivative (?f'::nat ⇒ complex ⇒ complex ⇒ complex) n x) (at x within S)› 2. ‹⋀e::real. (0::real) < e ⟹ ∀⇩F n::nat in sequentially. ∀x::complex∈S::complex set. ∀h::complex. cmod ((?f'::nat ⇒ complex ⇒ complex ⇒ complex) n x h - (g'::complex ⇒ complex) x * h) ≤ e * cmod h›*) have "**": "∃N. ∀n≥N. ∀x∈S. ∀h. cmod (f' n x * h - g' x * h) ≤ ε * cmod h" if "ε > 0" for ε :: real by (metis that (*‹0 < ε›*) left_diff_distrib (*‹(?a - ?b) * ?c = ?a * ?c - ?b * ?c›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) norm_ge_zero (*‹0 ≤ norm ?x›*) norm_mult (*‹norm (?x * ?y) = norm ?x * norm ?y›*) conv (*‹0 < ?e ⟹ ∃N. ∀n x. N ≤ n ⟶ x ∈ S ⟶ cmod (f' n x - g' x) ≤ ?e›*)) show "⋀e. e > 0 ⟹ ∀⇩F n in sequentially. ∀x∈S. ∀h. cmod (f' n x * h - g' x * h) ≤ e * cmod h" unfolding eventually_sequentially (*goal: ‹⋀e. 0 < e ⟹ ∃N. ∀n≥N. ∀x∈S. ∀h. cmod (f' n x * h - g' x * h) ≤ e * cmod h›*) by (blast intro: ** (*‹0 < ?ε ⟹ ∃N. ∀n≥N. ∀x∈S. ∀h. cmod (f' n x * h - g' x * h) ≤ ?ε * cmod h›*)) qed (metis has_field_derivative_def (*‹(?f has_field_derivative ?D) ?F = (?f has_derivative (*) ?D) ?F›*) df (*‹?x ∈ S ⟹ (f ?n has_field_derivative f' ?n ?x) (at ?x within S)›*)) (*solved the remaining goal: ‹⋀n x. x ∈ S ⟹ (f n has_derivative (*) (f' n x)) (at x within S)›*) qed lemma has_complex_derivative_series: fixes S :: "complex set" assumes cvs: "convex S" and df: "⋀n x. x ∈ S ⟹ (f n has_field_derivative f' n x) (at x within S)" and conv: "⋀e. 0 < e ⟹ ∃N. ∀n x. n ≥ N ⟶ x ∈ S ⟶ cmod ((∑i<n. f' i x) - g' x) ≤ e" and "∃x l. x ∈ S ∧ ((λn. f n x) sums l)" shows "∃g. ∀x ∈ S. ((λn. f n x) sums g x) ∧ ((g has_field_derivative g' x) (at x within S))" proof (-) (*goal: ‹∃g. ∀x∈S. (λn. f n x) sums g x ∧ (g has_field_derivative g' x) (at x within S)›*) from assms (*‹convex (S::complex set)› ‹?x ∈ S ⟹ (f ?n has_field_derivative f' ?n ?x) (at ?x within S)› ‹(0::real) < (?e::real) ⟹ ∃N::nat. ∀(n::nat) x::complex. N ≤ n ⟶ x ∈ (S::complex set) ⟶ cmod ((∑i::nat<n. (f'::nat ⇒ complex ⇒ complex) i x) - (g'::complex ⇒ complex) x) ≤ ?e› ‹∃(x::complex) l::complex. x ∈ (S::complex set) ∧ (λn::nat. (f::nat ⇒ complex ⇒ complex) n x) sums l›*) obtain x and l where x: "x ∈ S" and sf: "((λn. f n x) sums l)" (*goal: ‹(⋀x l. ⟦x ∈ S; (λn. f n x) sums l⟧ ⟹ thesis) ⟹ thesis›*) by blast { fix ε :: real assume e: "ε > 0" (*‹(0::real) < (ε::real)›*) then obtain N where N: "∀n x. n ≥ N ⟶ x ∈ S ⟶ cmod ((∑i<n. f' i x) - g' x) ≤ ε" (*goal: ‹(⋀N. ∀n x. N ≤ n ⟶ x ∈ S ⟶ cmod ((∑i<n. f' i x) - g' x) ≤ ε ⟹ thesis) ⟹ thesis›*) by (metis conv (*‹0 < ?e ⟹ ∃N. ∀n x. N ≤ n ⟶ x ∈ S ⟶ cmod ((∑i<n. f' i x) - g' x) ≤ ?e›*)) have "∃N. ∀n≥N. ∀x∈S. ∀h. cmod ((∑i<n. h * f' i x) - g' x * h) ≤ ε * cmod h" apply (rule exI [of _ N] (*‹(?P::nat ⇒ bool) (N::nat) ⟹ ∃x::nat. ?P x›*)) (*goal: ‹∃N. ∀n≥N. ∀x∈S. ∀h. cmod ((∑i<n. h * f' i x) - g' x * h) ≤ ε * cmod h›*) proof (clarify) (*goal: ‹⋀n x h. ⟦N ≤ n; x ∈ S⟧ ⟹ cmod ((∑i<n. h * f' i x) - g' x * h) ≤ ε * cmod h›*) fix n and y and h assume "N ≤ n" "y ∈ S" (*‹(N::nat) ≤ (n::nat)› ‹(y::complex) ∈ (S::complex set)›*) have "cmod h * cmod ((∑i<n. f' i y) - g' y) ≤ cmod h * ε" by (simp add: N (*‹∀n x. N ≤ n ⟶ x ∈ S ⟶ cmod ((∑i<n. f' i x) - g' x) ≤ ε›*) ‹N ≤ n› ‹y ∈ S› mult_le_cancel_left (*‹(?c * ?a ≤ ?c * ?b) = ((0 < ?c ⟶ ?a ≤ ?b) ∧ (?c < 0 ⟶ ?b ≤ ?a))›*)) then show "cmod ((∑i<n. h * f' i y) - g' y * h) ≤ ε * cmod h" by (simp add: norm_mult [symmetric] (*‹norm ?x * norm ?y = norm (?x * ?y)›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) sum_distrib_left (*‹?r * sum ?f ?A = (∑n∈?A. ?r * ?f n)›*)) qed } note "**" = this (*‹0 < ?ε2 ⟹ ∃N. ∀n≥N. ∀x∈S. ∀h. cmod ((∑i<n. h * f' i x) - g' x * h) ≤ ?ε2 * cmod h›*) show "?thesis" (*goal: ‹∃g. ∀x∈S. (λn. f n x) sums g x ∧ (g has_field_derivative g' x) (at x within S)›*) unfolding has_field_derivative_def (*goal: ‹∃g. ∀x∈S. (λn. f n x) sums g x ∧ (g has_derivative (*) (g' x)) (at x within S)›*) proof (rule has_derivative_series [OF cvs _ _ x] (*‹⟦⋀n x. x ∈ S ⟹ (?f n has_derivative ?f' n x) (at x within S); ⋀e. 0 < e ⟹ ∀⇩F n in sequentially. ∀x∈S. ∀h. norm ((∑i<n. ?f' i x h) - ?g' x h) ≤ e * cmod h; (λn. ?f n x) sums ?l⟧ ⟹ ∃g. ∀x∈S. (λn. ?f n x) sums g x ∧ (g has_derivative ?g' x) (at x within S)›*)) (*goals: 1. ‹⋀n x. x ∈ S ⟹ (f n has_derivative ?f' n x) (at x within S)› 2. ‹⋀e. 0 < e ⟹ ∀⇩F n in sequentially. ∀x∈S. ∀h. cmod ((∑i<n. ?f' i x h) - g' x * h) ≤ e * cmod h› 3. ‹(λn. f n x) sums ?l›*) fix n and x assume "x ∈ S" (*‹(x::complex) ∈ (S::complex set)›*) then show "((f n) has_derivative (λz. z * f' n x)) (at x within S)" by (metis df (*‹?x ∈ S ⟹ (f ?n has_field_derivative f' ?n ?x) (at ?x within S)›*) has_field_derivative_def (*‹(?f has_field_derivative ?D) ?F = (?f has_derivative (*) ?D) ?F›*) mult_commute_abs (*‹(λx. x * ?c) = (*) ?c›*)) next (*goals: 1. ‹⋀e::real. (0::real) < e ⟹ ∀⇩F n::nat in sequentially. ∀x::complex∈S::complex set. ∀h::complex. cmod ((∑i::nat<n. h * (f'::nat ⇒ complex ⇒ complex) i x) - (g'::complex ⇒ complex) x * h) ≤ e * cmod h› 2. ‹(λn::nat. (f::nat ⇒ complex ⇒ complex) n (x::complex)) sums (?l::complex)›*) show " ((λn. f n x) sums l)" by (rule sf (*‹(λn. f n x) sums l›*)) next (*goal: ‹⋀e. 0 < e ⟹ ∀⇩F n in sequentially. ∀x∈S. ∀h. cmod ((∑i<n. h * f' i x) - g' x * h) ≤ e * cmod h›*) show "⋀e. e>0 ⟹ ∀⇩F n in sequentially. ∀x∈S. ∀h. cmod ((∑i<n. h * f' i x) - g' x * h) ≤ e * cmod h" unfolding eventually_sequentially (*goal: ‹⋀e::real. (0::real) < e ⟹ ∃N::nat. ∀n≥N. ∀x::complex∈S::complex set. ∀h::complex. cmod ((∑i::nat<n. h * (f'::nat ⇒ complex ⇒ complex) i x) - (g'::complex ⇒ complex) x * h) ≤ e * cmod h›*) by (blast intro: ** (*‹0 < ?ε2 ⟹ ∃N. ∀n≥N. ∀x∈S. ∀h. cmod ((∑i<n. h * f' i x) - g' x * h) ≤ ?ε2 * cmod h›*)) qed qed subsection✐‹tag unimportant› ‹Taylor on Complex Numbers› lemma sum_Suc_reindex: fixes f :: "nat ⇒ 'a::ab_group_add" shows "sum f {0..n} = f 0 - f (Suc n) + sum (λi. f (Suc i)) {0..n}" apply (induct n) (*goals: 1. ‹sum f {0..0} = f 0 - f (Suc 0) + (∑i = 0..0. f (Suc i))› 2. ‹⋀n. sum f {0..n} = f 0 - f (Suc n) + (∑i = 0..n. f (Suc i)) ⟹ sum f {0..Suc n} = f 0 - f (Suc (Suc n)) + (∑i = 0..Suc n. f (Suc i))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma field_Taylor: assumes S: "convex S" and f: "⋀i x. x ∈ S ⟹ i ≤ n ⟹ (f i has_field_derivative f (Suc i) x) (at x within S)" and B: "⋀x. x ∈ S ⟹ norm (f (Suc n) x) ≤ B" and w: "w ∈ S" and z: "z ∈ S" shows "norm(f 0 z - (∑i≤n. f i w * (z-w) ^ i / (fact i))) ≤ B * norm(z - w)^(Suc n) / fact n" proof (-) (*goal: ‹norm (f 0 z - (∑i≤n. f i w * (z - w) ^ i / fact i)) ≤ B * norm (z - w) ^ Suc n / fact n›*) have wzs: "closed_segment w z ⊆ S" using assms (*‹convex S› ‹⟦?x ∈ S; ?i ≤ n⟧ ⟹ (f ?i has_field_derivative f (Suc ?i) ?x) (at ?x within S)› ‹?x ∈ S ⟹ norm (f (Suc n) ?x) ≤ B› ‹w ∈ S› ‹(z::'a) ∈ (S::'a set)›*) by (metis convex_contains_segment (*‹convex ?S = (∀a∈?S. ∀b∈?S. closed_segment a b ⊆ ?S)›*)) { fix u assume "u ∈ closed_segment w z" (*‹(u::'a) ∈ closed_segment (w::'a) (z::'a)›*) then have "u ∈ S" by (metis wzs (*‹closed_segment (w::'a::real_normed_field) (z::'a::real_normed_field) ⊆ (S::'a::real_normed_field set)›*) subsetD (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) have "*": "(∑i≤n. f i u * (- of_nat i * (z-u)^(i - 1)) / (fact i) + f (Suc i) u * (z-u)^i / (fact i)) = f (Suc n) u * (z-u) ^ n / (fact n)" proof (induction n) (*goals: 1. ‹(∑i≤0. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc 0) u * (z - u) ^ 0 / fact 0› 2. ‹⋀n. (∑i≤n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc n) u * (z - u) ^ n / fact n ⟹ (∑i≤Suc n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n)›*) case 0 (*no hyothesis introduced yet*) show "?case" (*goal: ‹(∑i≤0. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc 0) u * (z - u) ^ 0 / fact 0›*) by simp next (*goal: ‹⋀n. (∑i≤n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc n) u * (z - u) ^ n / fact n ⟹ (∑i≤Suc n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n)›*) case (Suc n) (*‹(∑i≤n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc n) u * (z - u) ^ n / fact n›*) have "(∑i≤Suc n. f i u * (- of_nat i * (z-u) ^ (i - 1)) / (fact i) + f (Suc i) u * (z-u) ^ i / (fact i)) = f (Suc n) u * (z-u) ^ n / (fact n) + f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n) / (fact (Suc n)) - f (Suc n) u * ((1 + of_nat n) * (z-u) ^ n) / (fact (Suc n))" using Suc (*‹(∑i≤n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc n) u * (z - u) ^ n / fact n›*) by simp also (*calculation: ‹(∑i≤Suc n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc n) u * (z - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) / fact (Suc n)›*) have "… = f (Suc (Suc n)) u * (z-u) ^ Suc n / (fact (Suc n))" proof (-) (*goal: ‹f (Suc n) u * (z - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) / fact (Suc n) = f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n)›*) have "(fact(Suc n)) * (f(Suc n) u *(z-u) ^ n / (fact n) + f(Suc(Suc n)) u *((z-u) *(z-u) ^ n) / (fact(Suc n)) - f(Suc n) u *((1 + of_nat n) *(z-u) ^ n) / (fact(Suc n))) = ((fact(Suc n)) *(f(Suc n) u *(z-u) ^ n)) / (fact n) + ((fact(Suc n)) *(f(Suc(Suc n)) u *((z-u) *(z-u) ^ n)) / (fact(Suc n))) - ((fact(Suc n)) *(f(Suc n) u *(of_nat(Suc n) *(z-u) ^ n))) / (fact(Suc n))" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) del: fact_Suc (*‹fact (Suc ?n) = of_nat (Suc ?n) * fact ?n›*)) also (*calculation: ‹fact (Suc n) * (f (Suc n) u * (z - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) / fact (Suc n)) = fact (Suc n) * (f (Suc n) u * (z - u) ^ n) / fact n + fact (Suc n) * (f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n)) / fact (Suc n) - fact (Suc n) * (f (Suc n) u * (of_nat (Suc n) * (z - u) ^ n)) / fact (Suc n)›*) have "… = ((fact (Suc n)) * (f (Suc n) u * (z-u) ^ n)) / (fact n) + (f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n)) - (f (Suc n) u * ((1 + of_nat n) * (z-u) ^ n))" by (simp del: fact_Suc (*‹fact (Suc ?n) = of_nat (Suc ?n) * fact ?n›*)) also (*calculation: ‹fact (Suc n) * (f (Suc n) u * (z - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) / fact (Suc n)) = fact (Suc n) * (f (Suc n) u * (z - u) ^ n) / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n)›*) have "… = (of_nat (Suc n) * (f (Suc n) u * (z-u) ^ n)) + (f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n)) - (f (Suc n) u * ((1 + of_nat n) * (z-u) ^ n))" apply (simp only: fact_Suc (*‹fact (Suc (?n::nat)) = of_nat (Suc ?n) * fact ?n›*) of_nat_mult (*‹of_nat ((?m::nat) * (?n::nat)) = of_nat ?m * of_nat ?n›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 31 facts*)) (*goal: ‹fact (Suc n) * (f (Suc n) u * (z - u) ^ n) / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) = of_nat (Suc n) * (f (Suc n) u * (z - u) ^ n) + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n)›*) by simp also (*calculation: ‹fact (Suc (n::nat)) * ((f::nat ⇒ 'a ⇒ 'a) (Suc n) (u::'a) * ((z::'a) - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * (((1::'a) + of_nat n) * (z - u) ^ n) / fact (Suc n)) = of_nat (Suc n) * (f (Suc n) u * (z - u) ^ n) + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) - f (Suc n) u * (((1::'a) + of_nat n) * (z - u) ^ n)›*) have "… = f (Suc (Suc n)) u * ((z-u) * (z-u) ^ n)" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) finally (*calculation: ‹fact (Suc n) * (f (Suc n) u * (z - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) / fact (Suc n)) = f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n)›*) show "?thesis" (*goal: ‹f (Suc n) u * (z - u) ^ n / fact n + f (Suc (Suc n)) u * ((z - u) * (z - u) ^ n) / fact (Suc n) - f (Suc n) u * ((1 + of_nat n) * (z - u) ^ n) / fact (Suc n) = f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n)›*) by (simp add: mult_left_cancel [where c = "(fact (Suc n))", THEN iffD1] (*‹⟦fact (Suc n) ≠ 0; fact (Suc n) * ?a1 = fact (Suc n) * ?b1⟧ ⟹ ?a1 = ?b1›*) del: fact_Suc (*‹fact (Suc ?n) = of_nat (Suc ?n) * fact ?n›*)) qed finally (*calculation: ‹(∑i::nat≤Suc (n::nat). (f::nat ⇒ 'a ⇒ 'a) i (u::'a) * (- of_nat i * ((z::'a) - u) ^ (i - (1::nat))) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n)›*) show "?case" (*goal: ‹(∑i≤Suc n. f i u * (- of_nat i * (z - u) ^ (i - 1)) / fact i + f (Suc i) u * (z - u) ^ i / fact i) = f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n)›*) . qed have "((λv. (∑i≤n. f i v * (z - v)^i / (fact i))) has_field_derivative f (Suc n) u * (z-u) ^ n / (fact n)) (at u within S)" unfolding "*"[symmetric] (*goal: ‹((λv::'a. ∑i::nat≤n::nat. (f::nat ⇒ 'a ⇒ 'a) i v * ((z::'a) - v) ^ i / fact i) has_field_derivative (∑i::nat≤n. f i (u::'a) * (- of_nat i * (z - u) ^ (i - (1::nat))) / fact i + f (Suc i) u * (z - u) ^ i / fact i)) (at u within (S::'a set))›*) by (((rule derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 102 facts*) assms (*‹convex S› ‹⟦?x ∈ S; ?i ≤ n⟧ ⟹ (f ?i has_field_derivative f (Suc ?i) ?x) (at ?x within S)› ‹?x ∈ S ⟹ norm (f (Suc n) ?x) ≤ B› ‹w ∈ S› ‹z ∈ S›*) ‹u ∈ S› refl (*‹?t = ?t›*)) | (auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*)))+) } note sum_deriv = this (*‹(?u2::'a) ∈ closed_segment (w::'a) (z::'a) ⟹ ((λv::'a. ∑i::nat≤n::nat. (f::nat ⇒ 'a ⇒ 'a) i v * (z - v) ^ i / fact i) has_field_derivative f (Suc n) ?u2 * (z - ?u2) ^ n / fact n) (at ?u2 within (S::'a set))›*) { fix u assume u: "u ∈ closed_segment w z" (*‹(u::'a) ∈ closed_segment (w::'a) (z::'a)›*) then have us: "u ∈ S" by (metis wzs (*‹closed_segment w z ⊆ S›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*)) have "norm (f (Suc n) u) * norm (z - u) ^ n ≤ norm (f (Suc n) u) * norm (u - z) ^ n" by (metis norm_minus_commute (*‹norm ((?a::?'a) - (?b::?'a)) = norm (?b - ?a)›*) order_refl (*‹(?x::?'a) ≤ ?x›*)) also (*calculation: ‹norm (f (Suc n) u) * norm (z - u) ^ n ≤ norm (f (Suc n) u) * norm (u - z) ^ n›*) have "… ≤ norm (f (Suc n) u) * norm (z - w) ^ n" by (metis mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) norm_ge_zero (*‹0 ≤ norm ?x›*) power_mono (*‹⟦?a ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?b ^ ?n›*) segment_bound [OF u] (*‹norm (u - w) ≤ norm (z - w)› ‹norm (u - z) ≤ norm (z - w)›*)) also (*calculation: ‹norm (f (Suc n) u) * norm (z - u) ^ n ≤ norm (f (Suc n) u) * norm (z - w) ^ n›*) have "… ≤ B * norm (z - w) ^ n" by (metis norm_ge_zero (*‹(0::real) ≤ norm (?x::?'a)›*) zero_le_power (*‹(0::?'a) ≤ (?a::?'a) ⟹ (0::?'a) ≤ ?a ^ (?n::nat)›*) mult_right_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) B [OF us] (*‹norm ((f::nat ⇒ 'a ⇒ 'a) (Suc (n::nat)) (u::'a)) ≤ (B::real)›*)) finally (*calculation: ‹norm (f (Suc n) u) * norm (z - u) ^ n ≤ B * norm (z - w) ^ n›*) have "norm (f (Suc n) u) * norm (z - u) ^ n ≤ B * norm (z - w) ^ n" . } note cmod_bound = this (*‹?u2 ∈ closed_segment w z ⟹ norm (f (Suc n) ?u2) * norm (z - ?u2) ^ n ≤ B * norm (z - w) ^ n›*) have "(∑i≤n. f i z * (z - z) ^ i / (fact i)) = (∑i≤n. (f i z / (fact i)) * 0 ^ i)" by simp also (*calculation: ‹(∑i≤n. f i z * (z - z) ^ i / fact i) = (∑i≤n. f i z / fact i * 0 ^ i)›*) have "… = f 0 z / (fact 0)" apply (subst sum_zero_power (*‹(∑i∈?A. ?c i * 0 ^ i) = (if finite ?A ∧ 0 ∈ ?A then ?c 0 else 0)›*)) (*goal: ‹(∑i≤n. f i z / fact i * 0 ^ i) = f 0 z / fact 0›*) by simp finally (*calculation: ‹(∑i≤n. f i z * (z - z) ^ i / fact i) = f 0 z / fact 0›*) have "norm (f 0 z - (∑i≤n. f i w * (z - w) ^ i / (fact i))) ≤ norm ((∑i≤n. f i w * (z - w) ^ i / (fact i)) - (∑i≤n. f i z * (z - z) ^ i / (fact i)))" by (simp add: norm_minus_commute (*‹norm (?a - ?b) = norm (?b - ?a)›*)) also (*calculation: ‹norm (f 0 z - (∑i≤n. f i w * (z - w) ^ i / fact i)) ≤ norm ((∑i≤n. f i w * (z - w) ^ i / fact i) - (∑i≤n. f i z * (z - z) ^ i / fact i))›*) have "… ≤ B * norm (z - w) ^ n / (fact n) * norm (w - z)" proof (rule field_differentiable_bound (*‹⟦convex ?S; ⋀z. z ∈ ?S ⟹ (?f has_field_derivative ?f' z) (at z within ?S); ⋀z. z ∈ ?S ⟹ norm (?f' z) ≤ ?B; ?x ∈ ?S; ?y ∈ ?S⟧ ⟹ norm (?f ?x - ?f ?y) ≤ ?B * norm (?x - ?y)›*)) (*goals: 1. ‹convex ?S› 2. ‹⋀za. za ∈ ?S ⟹ ((λa. ∑i≤n. f i a * (z - a) ^ i / fact i) has_field_derivative ?f' za) (at za within ?S)› 3. ‹⋀za. za ∈ ?S ⟹ norm (?f' za) ≤ B * norm (z - w) ^ n / fact n› 4. ‹w ∈ ?S› 5. ‹z ∈ ?S›*) show "⋀x. x ∈ closed_segment w z ⟹ ((λξ. ∑i≤n. f i ξ * (z - ξ) ^ i / fact i) has_field_derivative f (Suc n) x * (z - x) ^ n / fact n) (at x within closed_segment w z)" using DERIV_subset (*‹⟦(?f has_field_derivative ?f') (at ?x within ?s); ?t ⊆ ?s⟧ ⟹ (?f has_field_derivative ?f') (at ?x within ?t)›*) sum_deriv (*‹?u2 ∈ closed_segment w z ⟹ ((λv. ∑i≤n. f i v * (z - v) ^ i / fact i) has_field_derivative f (Suc n) ?u2 * (z - ?u2) ^ n / fact n) (at ?u2 within S)›*) wzs (*‹closed_segment w z ⊆ S›*) by blast qed (auto simp: norm_divide (*‹norm (?a / ?b) = norm ?a / norm ?b›*) norm_mult (*‹norm (?x * ?y) = norm ?x * norm ?y›*) norm_power (*‹norm (?x ^ ?n) = norm ?x ^ ?n›*) divide_le_cancel (*‹(?a / ?c ≤ ?b / ?c) = ((0 < ?c ⟶ ?a ≤ ?b) ∧ (?c < 0 ⟶ ?b ≤ ?a))›*) cmod_bound (*‹?u2 ∈ closed_segment w z ⟹ norm (f (Suc n) ?u2) * norm (z - ?u2) ^ n ≤ B * norm (z - w) ^ n›*)) (*solves the remaining goals: 1. ‹convex (closed_segment (w::'a) (z::'a))› 2. ‹⋀za::'a. za ∈ closed_segment (w::'a) (z::'a) ⟹ norm ((f::nat ⇒ 'a ⇒ 'a) (Suc (n::nat)) za * (z - za) ^ n / fact n) ≤ (B::real) * norm (z - w) ^ n / fact n› 3. ‹(w::'a) ∈ closed_segment w (z::'a)› 4. ‹(z::'a) ∈ closed_segment (w::'a) z›*) also (*calculation: ‹norm (f 0 z - (∑i≤n. f i w * (z - w) ^ i / fact i)) ≤ B * norm (z - w) ^ n / fact n * norm (w - z)›*) have "… ≤ B * norm (z - w) ^ Suc n / (fact n)" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) norm_minus_commute (*‹norm (?a - ?b) = norm (?b - ?a)›*)) finally (*calculation: ‹norm (f 0 z - (∑i≤n. f i w * (z - w) ^ i / fact i)) ≤ B * norm (z - w) ^ Suc n / fact n›*) show "?thesis" (*goal: ‹norm (f 0 z - (∑i≤n. f i w * (z - w) ^ i / fact i)) ≤ B * norm (z - w) ^ Suc n / fact n›*) . qed lemma complex_Taylor: assumes S: "convex S" and f: "⋀i x. x ∈ S ⟹ i ≤ n ⟹ (f i has_field_derivative f (Suc i) x) (at x within S)" and B: "⋀x. x ∈ S ⟹ cmod (f (Suc n) x) ≤ B" and w: "w ∈ S" and z: "z ∈ S" shows "cmod(f 0 z - (∑i≤n. f i w * (z-w) ^ i / (fact i))) ≤ B * cmod(z - w)^(Suc n) / fact n" using assms (*‹convex S› ‹⟦?x ∈ S; ?i ≤ n⟧ ⟹ (f ?i has_field_derivative f (Suc ?i) ?x) (at ?x within S)› ‹?x ∈ S ⟹ cmod (f (Suc n) ?x) ≤ B› ‹w ∈ S› ‹z ∈ S›*) apply (rule field_Taylor (*‹⟦convex ?S; ⋀i x. ⟦x ∈ ?S; i ≤ ?n⟧ ⟹ (?f i has_field_derivative ?f (Suc i) x) (at x within ?S); ⋀x. x ∈ ?S ⟹ norm (?f (Suc ?n) x) ≤ ?B; ?w ∈ ?S; ?z ∈ ?S⟧ ⟹ norm (?f 0 ?z - (∑i≤?n. ?f i ?w * (?z - ?w) ^ i / fact i)) ≤ ?B * norm (?z - ?w) ^ Suc ?n / fact ?n›*)) (*goals: 1. ‹⋀i x. ⟦x ∈ S; i ≤ n⟧ ⟹ x ∈ S› 2. ‹⋀i x. ⟦x ∈ S; i ≤ n⟧ ⟹ i ≤ n› 3. ‹⋀x. x ∈ S ⟹ x ∈ S› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) text‹Something more like the traditional MVT for real components› lemma complex_mvt_line: assumes "⋀u. u ∈ closed_segment w z ⟹ (f has_field_derivative f'(u)) (at u)" shows "∃u. u ∈ closed_segment w z ∧ Re(f z) - Re(f w) = Re(f'(u) * (z - w))" proof (-) (*goal: ‹∃u. u ∈ closed_segment w z ∧ Re (f z) - Re (f w) = Re (f' u * (z - w))›*) define φ where "φ ≡ λt. (1 - t) *⇩R w + t *⇩R z" have twz: "⋀t. φ t = w + t *⇩R (z - w)" by (simp add: φ_def (*‹φ ≡ λt. (1 - t) *⇩R w + t *⇩R z›*) real_vector.scale_left_diff_distrib (*‹(?a - ?b) *⇩R ?x = ?a *⇩R ?x - ?b *⇩R ?x›*) real_vector.scale_right_diff_distrib (*‹?a *⇩R (?x - ?y) = ?a *⇩R ?x - ?a *⇩R ?y›*)) note assms[unfolded has_field_derivative_def, derivative_intros] (*‹?u ∈ closed_segment w z ⟹ (f has_derivative (*) (f' ?u)) (at ?u)›*) have "*": "⋀x. ⟦0 ≤ x; x ≤ 1⟧ ⟹ (Re ∘ f ∘ φ has_derivative Re ∘ (*) (f' (φ x)) ∘ (λt. t *⇩R (z - w))) (at x within {0..1})" unfolding "φ_def" (*goal: ‹⋀x. ⟦0 ≤ x; x ≤ 1⟧ ⟹ (Re ∘ f ∘ (λt. (1 - t) *⇩R w + t *⇩R z) has_derivative Re ∘ (*) (f' ((1 - x) *⇩R w + x *⇩R z)) ∘ (λt. t *⇩R (z - w))) (at x within {0..1})›*) apply (intro derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 103 facts*) has_derivative_at_withinI (*‹(?f has_derivative ?f') (at ?x) ⟹ (?f has_derivative ?f') (at ?x within ?s)›*)) (*goal: ‹⋀x. ⟦0 ≤ x; x ≤ 1⟧ ⟹ (Re ∘ f ∘ (λt. (1 - t) *⇩R w + t *⇩R z) has_derivative Re ∘ (*) (f' ((1 - x) *⇩R w + x *⇩R z)) ∘ (λt. t *⇩R (z - w))) (at x within {0..1})›*) by (auto simp: in_segment (*‹((?x::?'a::real_vector) ∈ closed_segment (?a::?'a::real_vector) (?b::?'a::real_vector)) = (∃u≥0::real. u ≤ (1::real) ∧ ?x = ((1::real) - u) *⇩R ?a + u *⇩R ?b)› ‹((?x::?'a::real_vector) ∈ open_segment (?a::?'a::real_vector) (?b::?'a::real_vector)) = (?a ≠ ?b ∧ (∃u>0::real. u < (1::real) ∧ ?x = ((1::real) - u) *⇩R ?a + u *⇩R ?b))›*) scaleR_right_diff_distrib (*‹(?a::real) *⇩R ((?x::?'a::real_vector) - (?y::?'a::real_vector)) = ?a *⇩R ?x - ?a *⇩R ?y›*)) obtain x where "0<x" "x<1" "(Re ∘ f ∘ φ) 1 - (Re ∘ f ∘ φ) 0 = (Re ∘ (*) (f' (φ x)) ∘ (λt. t *⇩R (z - w))) (1 - 0)" (*goal: ‹(⋀x. ⟦0 < x; x < 1; (Re ∘ f ∘ φ) 1 - (Re ∘ f ∘ φ) 0 = (Re ∘ (*) (f' (φ x)) ∘ (λt. t *⇩R (z - w))) (1 - 0)⟧ ⟹ thesis) ⟹ thesis›*) using mvt_simple[OF zero_less_one *] (*‹⟦⋀x. ⟦0 ≤ x; x ≤ 1⟧ ⟹ 0 ≤ x; ⋀x. ⟦0 ≤ x; x ≤ 1⟧ ⟹ x ≤ 1⟧ ⟹ ∃x∈{0<..<1}. (Re ∘ f ∘ φ) 1 - (Re ∘ f ∘ φ) 0 = (Re ∘ (*) (f' (φ x)) ∘ (λt. t *⇩R (z - w))) (1 - 0)›*) by force then show "?thesis" (*goal: ‹∃u. u ∈ closed_segment w z ∧ Re (f z) - Re (f w) = Re (f' u * (z - w))›*) unfolding "φ_def" (*goal: ‹∃u. u ∈ closed_segment w z ∧ Re (f z) - Re (f w) = Re (f' u * (z - w))›*) by (smt (verit) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) in_segment( (*‹(?x ∈ closed_segment ?a ?b) = (∃u≥0. u ≤ 1 ∧ ?x = (1 - u) *⇩R ?a + u *⇩R ?b)›*) 1) scaleR_left_distrib (*‹(?a + ?b) *⇩R ?x = ?a *⇩R ?x + ?b *⇩R ?x›*) scaleR_one (*‹1 *⇩R ?x = ?x›*) scaleR_zero_left (*‹0 *⇩R ?x = 0›*)) qed lemma complex_Taylor_mvt: assumes "⋀i x. ⟦x ∈ closed_segment w z; i ≤ n⟧ ⟹ ((f i) has_field_derivative f (Suc i) x) (at x)" shows "∃u. u ∈ closed_segment w z ∧ Re (f 0 z) = Re ((∑i = 0..n. f i w * (z - w) ^ i / (fact i)) + (f (Suc n) u * (z-u)^n / (fact n)) * (z - w))" proof (-) (*goal: ‹∃u. u ∈ closed_segment w z ∧ Re (f 0 z) = Re ((∑i = 0..n. f i w * (z - w) ^ i / fact i) + f (Suc n) u * (z - u) ^ n / fact n * (z - w))›*) { fix u assume u: "u ∈ closed_segment w z" (*‹(u::complex) ∈ closed_segment (w::complex) (z::complex)›*) have "(∑i = 0..n. (f (Suc i) u * (z-u) ^ i - of_nat i * (f i u * (z-u) ^ (i - Suc 0))) / (fact i)) = f (Suc 0) u - (f (Suc (Suc n)) u * ((z-u) ^ Suc n) - (of_nat (Suc n)) * (z-u) ^ n * f (Suc n) u) / (fact (Suc n)) + (∑i = 0..n. (f (Suc (Suc i)) u * ((z-u) ^ Suc i) - of_nat (Suc i) * (f (Suc i) u * (z-u) ^ i)) / (fact (Suc i)))" apply (subst sum_Suc_reindex (*‹sum ?f {0..?n} = ?f 0 - ?f (Suc ?n) + (∑i = 0..?n. ?f (Suc i))›*)) (*goal: ‹(∑i = 0..n. (f (Suc i) u * (z - u) ^ i - complex_of_nat i * (f i u * (z - u) ^ (i - Suc 0))) / fact i) = f (Suc 0) u - (f (Suc (Suc n)) u * (z - u) ^ Suc n - complex_of_nat (Suc n) * (z - u) ^ n * f (Suc n) u) / fact (Suc n) + (∑i = 0..n. (f (Suc (Suc i)) u * (z - u) ^ Suc i - complex_of_nat (Suc i) * (f (Suc i) u * (z - u) ^ i)) / fact (Suc i))›*) by simp also (*calculation: ‹(∑i::nat = 0::nat..n::nat. ((f::nat ⇒ complex ⇒ complex) (Suc i) (u::complex) * ((z::complex) - u) ^ i - complex_of_nat i * (f i u * (z - u) ^ (i - Suc (0::nat)))) / fact i) = f (Suc (0::nat)) u - (f (Suc (Suc n)) u * (z - u) ^ Suc n - complex_of_nat (Suc n) * (z - u) ^ n * f (Suc n) u) / fact (Suc n) + (∑i::nat = 0::nat..n. (f (Suc (Suc i)) u * (z - u) ^ Suc i - complex_of_nat (Suc i) * (f (Suc i) u * (z - u) ^ i)) / fact (Suc i))›*) have "… = f (Suc 0) u - (f (Suc (Suc n)) u * ((z-u) ^ Suc n) - (of_nat (Suc n)) * (z-u) ^ n * f (Suc n) u) / (fact (Suc n)) + (∑i = 0..n. f (Suc (Suc i)) u * ((z-u) ^ Suc i) / (fact (Suc i)) - f (Suc i) u * (z-u) ^ i / (fact i))" by (simp only: diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*) fact_cancel (*‹of_nat (Suc ?n) * ?c / fact (Suc ?n) = ?c / fact ?n›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 31 facts*)) also (*calculation: ‹(∑i = 0..n. (f (Suc i) u * (z - u) ^ i - complex_of_nat i * (f i u * (z - u) ^ (i - Suc 0))) / fact i) = f (Suc 0) u - (f (Suc (Suc n)) u * (z - u) ^ Suc n - complex_of_nat (Suc n) * (z - u) ^ n * f (Suc n) u) / fact (Suc n) + (∑i = 0..n. f (Suc (Suc i)) u * (z - u) ^ Suc i / fact (Suc i) - f (Suc i) u * (z - u) ^ i / fact i)›*) have "… = f (Suc 0) u - (f (Suc (Suc n)) u * (z-u) ^ Suc n - of_nat (Suc n) * (z-u) ^ n * f (Suc n) u) / (fact (Suc n)) + f (Suc (Suc n)) u * (z-u) ^ Suc n / (fact (Suc n)) - f (Suc 0) u" apply (subst sum_Suc_diff (*‹?m ≤ Suc ?n ⟹ (∑i = ?m..?n. ?f (Suc i) - ?f i) = ?f (Suc ?n) - ?f ?m›*)) (*goals: 1. ‹0 ≤ Suc n› 2. ‹f (Suc 0) u - (f (Suc (Suc n)) u * (z - u) ^ Suc n - complex_of_nat (Suc n) * (z - u) ^ n * f (Suc n) u) / fact (Suc n) + (f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n) - f (Suc 0) u * (z - u) ^ 0 / fact 0) = f (Suc 0) u - (f (Suc (Suc n)) u * (z - u) ^ Suc n - complex_of_nat (Suc n) * (z - u) ^ n * f (Suc n) u) / fact (Suc n) + f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n) - f (Suc 0) u› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹(∑i = 0..n. (f (Suc i) u * (z - u) ^ i - complex_of_nat i * (f i u * (z - u) ^ (i - Suc 0))) / fact i) = f (Suc 0) u - (f (Suc (Suc n)) u * (z - u) ^ Suc n - complex_of_nat (Suc n) * (z - u) ^ n * f (Suc n) u) / fact (Suc n) + f (Suc (Suc n)) u * (z - u) ^ Suc n / fact (Suc n) - f (Suc 0) u›*) have "… = f (Suc n) u * (z-u) ^ n / (fact n)" by (simp only: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) diff_divide_distrib (*‹(?a - ?b) / ?c = ?a / ?c - ?b / ?c›*) fact_cancel (*‹of_nat (Suc ?n) * ?c / fact (Suc ?n) = ?c / fact ?n›*)) finally (*calculation: ‹(∑i = 0..n. (f (Suc i) u * (z - u) ^ i - complex_of_nat i * (f i u * (z - u) ^ (i - Suc 0))) / fact i) = f (Suc n) u * (z - u) ^ n / fact n›*) have "*": "(∑i = 0..n. (f (Suc i) u * (z - u) ^ i - of_nat i * (f i u * (z-u) ^ (i - Suc 0))) / (fact i)) = f (Suc n) u * (z - u) ^ n / (fact n)" . have "((λu. ∑i = 0..n. f i u * (z - u) ^ i / (fact i)) has_field_derivative f (Suc n) u * (z - u) ^ n / (fact n)) (at u)" unfolding "*"[symmetric] (*goal: ‹((λu. ∑i = 0..n. f i u * (z - u) ^ i / fact i) has_field_derivative (∑i = 0..n. (f (Suc i) u * (z - u) ^ i - complex_of_nat i * (f i u * (z - u) ^ (i - Suc 0))) / fact i)) (at u)›*) by (((rule derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 102 facts*) assms (*‹⟦?x ∈ closed_segment w z; ?i ≤ n⟧ ⟹ (f ?i has_field_derivative f (Suc ?i) ?x) (at ?x)›*) u (*‹u ∈ closed_segment w z›*) refl (*‹?t = ?t›*)) | (auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*)))+) } then show "?thesis" (*goal: ‹∃u. u ∈ closed_segment w z ∧ Re (f 0 z) = Re ((∑i = 0..n. f i w * (z - w) ^ i / fact i) + f (Suc n) u * (z - u) ^ n / fact n * (z - w))›*) apply (cut_tac complex_mvt_line [of w z "λu. ∑i = 0..n. f i u * (z-u) ^ i / (fact i)" "λu. (f (Suc n) u * (z-u)^n / (fact n))"] (*‹(⋀u::complex. u ∈ closed_segment (w::complex) (z::complex) ⟹ ((λu::complex. ∑i::nat = 0::nat..n::nat. (f::nat ⇒ complex ⇒ complex) i u * (z - u) ^ i / fact i) has_field_derivative f (Suc n) u * (z - u) ^ n / fact n) (at u)) ⟹ ∃u::complex. u ∈ closed_segment w z ∧ Re (∑i::nat = 0::nat..n. f i z * (z - z) ^ i / fact i) - Re (∑i::nat = 0::nat..n. f i w * (z - w) ^ i / fact i) = Re (f (Suc n) u * (z - u) ^ n / fact n * (z - w))›*)) (*goals: 1. ‹⟦⋀u. u ∈ closed_segment w z ⟹ ((λu. ∑i = 0..n. f i u * (z - u) ^ i / fact i) has_field_derivative f (Suc n) u * (z - u) ^ n / fact n) (at u); ∃u. u ∈ closed_segment w z ∧ Re (∑i = 0..n. f i z * (z - z) ^ i / fact i) - Re (∑i = 0..n. f i w * (z - w) ^ i / fact i) = Re (f (Suc n) u * (z - u) ^ n / fact n * (z - w))⟧ ⟹ ∃u. u ∈ closed_segment w z ∧ Re (f 0 z) = Re ((∑i = 0..n. f i w * (z - w) ^ i / fact i) + f (Suc n) u * (z - u) ^ n / fact n * (z - w))› 2. ‹⋀u. ⟦⋀u. u ∈ closed_segment w z ⟹ ((λu. ∑i = 0..n. f i u * (z - u) ^ i / fact i) has_field_derivative f (Suc n) u * (z - u) ^ n / fact n) (at u); u ∈ closed_segment w z⟧ ⟹ ((λu. ∑i = 0..n. f i u * (z - u) ^ i / fact i) has_field_derivative f (Suc n) u * (z - u) ^ n / fact n) (at u)› discuss goal 1*) apply ((auto simp add: intro: open_closed_segment (*‹?u ∈ open_segment ?w ?z ⟹ ?u ∈ closed_segment ?w ?z›*))[1]) (*discuss goal 2*) apply ((auto simp add: intro: open_closed_segment (*‹?u ∈ open_segment ?w ?z ⟹ ?u ∈ closed_segment ?w ?z›*))[1]) (*proven 2 subgoals*) . qed end
{ "path": "Isabelle2024/src/HOL/Analysis/Complex_Analysis_Basics.thy", "repo": "Isabelle2024", "sha": "9981d40d1b07aaf2602916250210351d748cea21def2f859c1bc26af28f00402" }
section ‹Definedness› theory Definedness imports Data_List begin text ‹ This is an attempt for a setup for better handling bottom, by a better simp setup, and less breaking the abstractions. › definition defined :: "'a :: pcpo ⇒ bool" where "defined x = (x ≠ ⊥)" lemma defined_bottom [simp]: "¬ defined ⊥" by (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) lemma defined_seq [simp]: "defined x ⟹ seq⋅x⋅y = y" by (simp add: defined_def (*‹defined (?x::?'a) = (?x ≠ ⊥)›*)) consts val :: "'a::type ⇒ 'b::type" ("⟦_⟧") text ‹val for booleans› definition val_Bool :: "tr ⇒ bool" where "val_Bool i = (THE j. i = Def j)" adhoc_overloading val val_Bool lemma defined_Bool_simps [simp]: "defined (Def i)" "defined TT" "defined FF" (*goals: 1. ‹defined (Def i)› 2. ‹defined TT› 3. ‹defined FF› discuss goal 1*) apply (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) (*discuss goal 2*) apply (simp add: defined_def (*‹defined (?x::?'a::pcpo) = (?x ≠ ⊥)›*)) (*discuss goal 3*) apply (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) (*proven 3 subgoals*) . lemma val_Bool_simp1 [simp]: "⟦Def i⟧ = i" by (simp add: val_Bool_def (*‹⟦?i⟧ = (THE j. ?i = Def j)›*) TT_def (*‹TT = Def True›*) FF_def (*‹FF = Def False›*)) lemma val_Bool_simp2 [simp]: "⟦TT⟧ = True" "⟦FF⟧ = False" (*goals: 1. ‹⟦TT⟧ = True› 2. ‹⟦FF⟧ = False› discuss goal 1*) apply (simp add: TT_def (*‹TT = Def True›*) FF_def (*‹FF = Def False›*)) (*discuss goal 2*) apply (simp add: TT_def (*‹TT = Def True›*) FF_def (*‹FF = Def False›*)) (*proven 2 subgoals*) . lemma IF_simps [simp]: "defined b ⟹ ⟦ b ⟧ ⟹ (If b then x else y) = x" "defined b ⟹ ⟦ b ⟧ = False ⟹ (If b then x else y) = y" (*goals: 1. ‹⟦defined (b::tr); ⟦b⟧⟧ ⟹ If b then x::'a else (y::'a) = x› 2. ‹⟦defined (b::tr); ⟦b⟧ = False⟧ ⟹ If b then x::'a else (y::'a) = y› discuss goal 1*) apply (cases b) (*goals: 1. ‹⟦defined b; ⟦b⟧; b = ⊥⟧ ⟹ If b then x else y = x› 2. ‹⟦defined b; ⟦b⟧; b = TT⟧ ⟹ If b then x else y = x› 3. ‹⟦defined b; ⟦b⟧; b = FF⟧ ⟹ If b then x else y = x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*discuss goal 2*) apply simp (*goal: ‹⟦defined b; ⟦b⟧ = False⟧ ⟹ If b then x else y = y›*) apply (cases b) (*goals: 1. ‹⟦defined (b::tr); ¬ ⟦b⟧; b = ⊥⟧ ⟹ If b then x::'a::pcpo else (y::'a::pcpo) = y› 2. ‹⟦defined (b::tr); ¬ ⟦b⟧; b = TT⟧ ⟹ If b then x::'a::pcpo else (y::'a::pcpo) = y› 3. ‹⟦defined (b::tr); ¬ ⟦b⟧; b = FF⟧ ⟹ If b then x::'a::pcpo else (y::'a::pcpo) = y› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . lemma defined_neg [simp]: "defined (neg⋅b) ⟷ defined b" apply (cases b) (*goals: 1. ‹b = ⊥ ⟹ defined (neg⋅b) = defined b› 2. ‹b = TT ⟹ defined (neg⋅b) = defined b› 3. ‹b = FF ⟹ defined (neg⋅b) = defined b› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma val_Bool_neg [simp]: "defined b ⟹ ⟦ neg ⋅ b ⟧ = (¬ ⟦ b ⟧)" apply (cases b) (*goals: 1. ‹⟦defined b; b = ⊥⟧ ⟹ ⟦neg⋅b⟧ = (¬ ⟦b⟧)› 2. ‹⟦defined b; b = TT⟧ ⟹ ⟦neg⋅b⟧ = (¬ ⟦b⟧)› 3. ‹⟦defined b; b = FF⟧ ⟹ ⟦neg⋅b⟧ = (¬ ⟦b⟧)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . text ‹val for integers› definition val_Integer :: "Integer ⇒ int" where "val_Integer i = (THE j. i = MkI⋅j)" adhoc_overloading val val_Integer lemma defined_Integer_simps [simp]: "defined (MkI⋅i)" "defined (0::Integer)" "defined (1::Integer)" (*goals: 1. ‹defined (MkI⋅i)› 2. ‹defined 0› 3. ‹defined 1› discuss goal 1*) apply (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) (*discuss goal 2*) apply (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) (*discuss goal 3*) apply (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) (*proven 3 subgoals*) . lemma defined_numeral [simp]: "defined (numeral x :: Integer)" by (simp add: defined_def (*‹defined ?x = (?x ≠ ⊥)›*)) lemma val_Integer_simps [simp]: "⟦MkI⋅i⟧ = i" "⟦0⟧ = 0" "⟦1⟧ = 1" (*goals: 1. ‹⟦MkI⋅i⟧ = i› 2. ‹⟦0⟧ = 0› 3. ‹⟦1⟧ = 1› discuss goal 1*) apply (simp add: val_Integer_def (*‹⟦?i⟧ = (THE j. ?i = MkI⋅j)›*)) (*discuss goal 2*) apply (simp add: val_Integer_def (*‹⟦?i::Integer⟧ = (THE j::int. ?i = MkI⋅j)›*)) (*discuss goal 3*) apply (simp add: val_Integer_def (*‹⟦?i::Integer⟧ = (THE j::int. ?i = MkI⋅j)›*)) (*proven 3 subgoals*) . lemma val_Integer_numeral [simp]: "⟦ numeral x :: Integer ⟧ = numeral x" by (simp add: val_Integer_def (*‹⟦?i⟧ = (THE j. ?i = MkI⋅j)›*)) lemma val_Integer_to_MkI: "defined i ⟹ i = (MkI ⋅ ⟦ i ⟧)" apply (cases i) (*goals: 1. ‹⟦defined i; i = ⊥⟧ ⟹ i = MkI⋅⟦i⟧› 2. ‹⋀int. ⟦defined i; i = MkI⋅int⟧ ⟹ i = MkI⋅⟦i⟧› discuss goal 1*) apply ((auto simp add: val_Integer_def (*‹⟦?i⟧ = (THE j. ?i = MkI⋅j)›*) defined_def (*‹defined ?x = (?x ≠ ⊥)›*))[1]) (*discuss goal 2*) apply ((auto simp add: val_Integer_def (*‹⟦?i⟧ = (THE j. ?i = MkI⋅j)›*) defined_def (*‹defined ?x = (?x ≠ ⊥)›*))[1]) (*proven 2 subgoals*) . lemma defined_Integer_minus [simp]: "defined i ⟹ defined j ⟹ defined (i - (j::Integer))" apply (cases i) (*goals: 1. ‹⟦defined (i::Integer); defined (j::Integer); i = ⊥⟧ ⟹ defined (i - j)› 2. ‹⋀int::int. ⟦defined (i::Integer); defined (j::Integer); i = MkI⋅int⟧ ⟹ defined (i - j)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀int. ⟦defined i; defined j; i = MkI⋅int⟧ ⟹ defined (i - j)›*) apply (cases j) (*goals: 1. ‹⋀int. ⟦defined j; i = MkI⋅int; j = ⊥⟧ ⟹ defined (MkI⋅int - j)› 2. ‹⋀int inta. ⟦defined j; i = MkI⋅int; j = MkI⋅inta⟧ ⟹ defined (MkI⋅int - j)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma val_Integer_minus [simp]: "defined i ⟹ defined j ⟹ ⟦ i - j ⟧ = ⟦ i ⟧ - ⟦ j ⟧" apply (cases i) (*goals: 1. ‹⟦defined (i::Integer); defined (j::Integer); i = ⊥⟧ ⟹ ⟦i - j⟧ = ⟦i⟧ - ⟦j⟧› 2. ‹⋀int::int. ⟦defined (i::Integer); defined (j::Integer); i = MkI⋅int⟧ ⟹ ⟦i - j⟧ = ⟦i⟧ - ⟦j⟧› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀int::int. ⟦defined (i::Integer); defined (j::Integer); i = MkI⋅int⟧ ⟹ ⟦i - j⟧ = ⟦i⟧ - ⟦j⟧›*) apply (cases j) (*goals: 1. ‹⋀int. ⟦defined j; i = MkI⋅int; j = ⊥⟧ ⟹ ⟦MkI⋅int - j⟧ = int - ⟦j⟧› 2. ‹⋀int inta. ⟦defined j; i = MkI⋅int; j = MkI⋅inta⟧ ⟹ ⟦MkI⋅int - j⟧ = int - ⟦j⟧› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma defined_Integer_plus [simp]: "defined i ⟹ defined j ⟹ defined (i + (j::Integer))" apply (cases i) (*goals: 1. ‹⟦defined (i::Integer); defined (j::Integer); i = ⊥⟧ ⟹ defined (i + j)› 2. ‹⋀int::int. ⟦defined (i::Integer); defined (j::Integer); i = MkI⋅int⟧ ⟹ defined (i + j)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀int. ⟦defined i; defined j; i = MkI⋅int⟧ ⟹ defined (i + j)›*) apply (cases j) (*goals: 1. ‹⋀int. ⟦defined j; i = MkI⋅int; j = ⊥⟧ ⟹ defined (MkI⋅int + j)› 2. ‹⋀int inta. ⟦defined j; i = MkI⋅int; j = MkI⋅inta⟧ ⟹ defined (MkI⋅int + j)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma val_Integer_plus [simp]: "defined i ⟹ defined j ⟹ ⟦ i + j ⟧ = ⟦ i ⟧ + ⟦ j ⟧" apply (cases i) (*goals: 1. ‹⟦defined i; defined j; i = ⊥⟧ ⟹ ⟦i + j⟧ = ⟦i⟧ + ⟦j⟧› 2. ‹⋀int. ⟦defined i; defined j; i = MkI⋅int⟧ ⟹ ⟦i + j⟧ = ⟦i⟧ + ⟦j⟧› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀int. ⟦defined i; defined j; i = MkI⋅int⟧ ⟹ ⟦i + j⟧ = ⟦i⟧ + ⟦j⟧›*) apply (cases j) (*goals: 1. ‹⋀int::int. ⟦defined (j::Integer); (i::Integer) = MkI⋅int; j = ⊥⟧ ⟹ ⟦MkI⋅int + j⟧ = int + ⟦j⟧› 2. ‹⋀(int::int) inta::int. ⟦defined (j::Integer); (i::Integer) = MkI⋅int; j = MkI⋅inta⟧ ⟹ ⟦MkI⋅int + j⟧ = int + ⟦j⟧› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma defined_Integer_eq [simp]: "defined (eq⋅a⋅b) ⟷ defined a ∧ defined (b::Integer)" apply (cases a) (*goals: 1. ‹(a::Integer) = ⊥ ⟹ defined (eq⋅a⋅(b::Integer)) = (defined a ∧ defined b)› 2. ‹⋀int::int. (a::Integer) = MkI⋅int ⟹ defined (eq⋅a⋅(b::Integer)) = (defined a ∧ defined b)› discuss goal 1*) apply simp (*discuss goal 2*) apply (cases b) (*goals: 1. ‹⋀int. ⟦a = MkI⋅int; b = ⊥⟧ ⟹ defined (eq⋅a⋅b) = (defined a ∧ defined b)› 2. ‹⋀int inta. ⟦a = MkI⋅int; b = MkI⋅inta⟧ ⟹ defined (eq⋅a⋅b) = (defined a ∧ defined b)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma val_Integer_eq [simp]: "defined a ⟹ defined b ⟹ ⟦ eq⋅a⋅b ⟧ = (⟦ a ⟧ = (⟦ b ⟧ :: int))" apply (cases a) (*goals: 1. ‹⟦defined (a::Integer); defined (b::Integer); a = ⊥⟧ ⟹ ⟦eq⋅a⋅b⟧ = (⟦a⟧ = ⟦b⟧)› 2. ‹⋀int::int. ⟦defined (a::Integer); defined (b::Integer); a = MkI⋅int⟧ ⟹ ⟦eq⋅a⋅b⟧ = (⟦a⟧ = ⟦b⟧)› discuss goal 1*) apply simp (*discuss goal 2*) apply (cases b) (*goals: 1. ‹⋀int::int. ⟦defined (a::Integer); defined (b::Integer); a = MkI⋅int; b = ⊥⟧ ⟹ ⟦eq⋅a⋅b⟧ = (⟦a⟧ = ⟦b⟧)› 2. ‹⋀(int::int) inta::int. ⟦defined (a::Integer); defined (b::Integer); a = MkI⋅int; b = MkI⋅inta⟧ ⟹ ⟦eq⋅a⋅b⟧ = (⟦a⟧ = ⟦b⟧)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . text ‹Full induction for non-negative integers› lemma nonneg_full_Int_induct [consumes 1, case_names neg Suc]: assumes defined: "defined i" assumes neg: "⋀ i. defined i ⟹ ⟦i⟧ < 0 ⟹ P i" assumes step: "⋀ i. defined i ⟹ 0 ≤ ⟦i⟧ ⟹ (⋀ j. defined j ⟹ ⟦ j ⟧ < ⟦ i ⟧ ⟹ P j) ⟹ P i" shows "P (i::Integer)" proof (cases i) (*goals: 1. ‹i = ⊥ ⟹ P i› 2. ‹⋀int. i = MkI⋅int ⟹ P i›*) case bottom (*‹i = ⊥›*) then have False using defined (*‹defined i›*) by simp then show "?thesis" (*goal: ‹P i›*) by standard next (*goal: ‹⋀int::int. (i::Integer) = MkI⋅int ⟹ (P::Integer ⇒ bool) i›*) case (MkI integer) (*‹i = MkI⋅integer›*) show "?thesis" (*goal: ‹(P::Integer ⇒ bool) (i::Integer)›*) proof (cases integer) (*goals: 1. ‹⋀n::nat. (integer::int) = int n ⟹ (P::Integer ⇒ bool) (i::Integer)› 2. ‹⋀n::nat. (integer::int) = - int (Suc n) ⟹ (P::Integer ⇒ bool) (i::Integer)›*) case neg (*‹(integer::int) = - int (Suc (n_::nat))›*) then show "?thesis" (*goal: ‹P i›*) using assms(2) (*‹⟦defined ?i; ⟦?i⟧ < 0⟧ ⟹ P ?i›*) MkI (*‹i = MkI⋅integer›*) by simp next (*goal: ‹⋀n. integer = int n ⟹ P i›*) case (nonneg nat) (*‹(integer::int) = int (nat::nat)›*) have "P (MkI⋅(int nat))" proof (induction nat rule:full_nat_induct (*‹(⋀n. ∀m. Suc m ≤ n ⟶ ?P m ⟹ ?P n) ⟹ ?P ?n›*)) (*goal: ‹⋀n. ∀m. Suc m ≤ n ⟶ P (MkI⋅(int m)) ⟹ P (MkI⋅(int n))›*) case (1 nat) (*‹∀m. Suc m ≤ nat ⟶ P (MkI⋅(int m))›*) have "defined (MkI⋅(int nat))" by simp moreover have "0 ≤ ⟦ MkI⋅(int nat) ⟧" by simp moreover have "P j" if "defined j" and le: "⟦ j ⟧ < ⟦ MkI⋅(int nat) ⟧" for j :: Integer proof (cases j) (*goals: 1. ‹j = ⊥ ⟹ P j› 2. ‹⋀int. j = MkI⋅int ⟹ P j›*) case bottom (*‹j = ⊥›*) with ‹defined j› (*‹defined j›*) show "?thesis" (*goal: ‹P j›*) by simp next (*goal: ‹⋀int. j = MkI⋅int ⟹ P j›*) case (MkI integer) (*‹j = MkI⋅integer›*) show "?thesis" (*goal: ‹P j›*) proof (cases integer) (*goals: 1. ‹⋀n. integer = int n ⟹ P j› 2. ‹⋀n. integer = - int (Suc n) ⟹ P j›*) case (neg nat) (*‹integer = - int (Suc nat)›*) have "⟦j⟧ < 0" using neg (*‹integer = - int (Suc nat)›*) MkI (*‹j = MkI⋅integer›*) by simp with ‹defined j› (*‹defined j›*) show "?thesis" (*goal: ‹P j›*) by (rule assms( (*‹⟦defined ?i; ⟦?i⟧ < 0⟧ ⟹ P ?i›*) 2)) next (*goal: ‹⋀n. integer = int n ⟹ P j›*) case (nonneg m) (*‹integer = int m›*) have "Suc m ≤ nat" using le (*‹⟦j⟧ < ⟦MkI⋅(int nat)⟧›*) nonneg (*‹integer = int m›*) MkI (*‹(j::Integer) = MkI⋅(integer::int)›*) by simp then have "P (MkI⋅(int m))" by (metis "1.IH" (*‹∀m. Suc m ≤ nat ⟶ P (MkI⋅(int m))›*)) then show "?thesis" (*goal: ‹P j›*) using nonneg (*‹integer = int m›*) MkI (*‹j = MkI⋅integer›*) by simp qed qed ultimately show "?case" (*goal: ‹P (MkI⋅(int nat))›*) apply (rule step (*‹⟦defined ?i; 0 ≤ ⟦?i⟧; ⋀j. ⟦defined j; ⟦j⟧ < ⟦?i⟧⟧ ⟹ P j⟧ ⟹ P ?i›*)) (*goals: 1. ‹⋀j::Integer. ⟦defined j; ⟦j⟧ < ⟦MkI⋅(int (nat::nat))⟧⟧ ⟹ defined j› 2. ‹⋀j::Integer. ⟦defined j; ⟦j⟧ < ⟦MkI⋅(int (nat::nat))⟧⟧ ⟹ ⟦j⟧ < ⟦MkI⋅(int nat)⟧› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) qed then show "?thesis" (*goal: ‹(P::Integer ⇒ bool) (i::Integer)›*) using nonneg (*‹integer = int nat›*) MkI (*‹i = MkI⋅integer›*) by simp qed qed text ‹Some list lemmas re-done with the new setup.› lemma nth_tail: (* TODO: move *) "defined n ⟹ ⟦ n ⟧ ≥ 0 ⟹ tail⋅xs !! n = xs !! (1 + n)" apply (cases xs) (*goals: 1. ‹⟦defined n; 0 ≤ ⟦n⟧; xs = ⊥⟧ ⟹ tail⋅xs !! n = xs !! (1 + n)› 2. ‹⟦defined n; 0 ≤ ⟦n⟧; xs = []⟧ ⟹ tail⋅xs !! n = xs !! (1 + n)› 3. ‹⋀a list. ⟦defined n; 0 ≤ ⟦n⟧; xs = a : list⟧ ⟹ tail⋅xs !! n = xs !! (1 + n)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*goal: ‹⋀a list. ⟦defined n; 0 ≤ ⟦n⟧; xs = a : list⟧ ⟹ tail⋅xs !! n = xs !! (1 + n)›*) apply (cases n) (*goals: 1. ‹⋀(a::'a::domain) list::['a::domain]. ⟦defined (n::Integer); (0::int) ≤ ⟦n⟧; (xs::['a::domain]) = a : list; n = ⊥⟧ ⟹ list !! n = (a : list) !! ((1::Integer) + n)› 2. ‹⋀(a::'a::domain) (list::['a::domain]) int::int. ⟦defined (n::Integer); (0::int) ≤ ⟦n⟧; (xs::['a::domain]) = a : list; n = MkI⋅int⟧ ⟹ list !! n = (a : list) !! ((1::Integer) + n)› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: one_Integer_def (*‹(1::Integer) = MkI⋅(1::int)›*) zero_Integer_def (*‹(0::Integer) = MkI⋅(0::int)›*)) (*proven 2 subgoals*) (*proven 3 subgoals*) . lemma nth_zipWith: (* TODO: move *) assumes f1 [simp]: "⋀y. f⋅⊥⋅y = ⊥" assumes f2 [simp]: "⋀x. f⋅x⋅⊥ = ⊥" shows "zipWith⋅f⋅xs⋅ys !! n = f⋅(xs !! n)⋅(ys !! n)" proof (induct xs arbitrary: ys n) (*goals: 1. ‹adm (λa. ∀x xa. zipWith⋅f⋅a⋅x !! xa = f⋅(a !! xa)⋅(x !! xa))› 2. ‹⋀ys n. zipWith⋅f⋅⊥⋅ys !! n = f⋅(⊥ !! n)⋅(ys !! n)› 3. ‹⋀ys n. zipWith⋅f⋅[]⋅ys !! n = f⋅([] !! n)⋅(ys !! n)› 4. ‹⋀a xs ys n. (⋀ys n. zipWith⋅f⋅xs⋅ys !! n = f⋅(xs !! n)⋅(ys !! n)) ⟹ zipWith⋅f⋅(a : xs)⋅ys !! n = f⋅((a : xs) !! n)⋅(ys !! n)›*) case (Cons x xs ys n) (*‹zipWith⋅f⋅xs⋅?ys !! ?n = f⋅(xs !! ?n)⋅(?ys !! ?n)›*) then show "?case" (*goal: ‹zipWith⋅(f::'c → 'a → 'b)⋅((x::'c) : (xs::['c]))⋅(ys::['a]) !! (n::Integer) = f⋅((x : xs) !! n)⋅(ys !! n)›*) apply (cases ys) (*goals: 1. ‹⟦⋀(ys::['a]) n::Integer. zipWith⋅(f::'c → 'a → 'b)⋅(xs::['c])⋅ys !! n = f⋅(xs !! n)⋅(ys !! n); (ys::['a]) = ⊥⟧ ⟹ zipWith⋅f⋅((x::'c) : xs)⋅ys !! (n::Integer) = f⋅((x : xs) !! n)⋅(ys !! n)› 2. ‹⟦⋀(ys::['a]) n::Integer. zipWith⋅(f::'c → 'a → 'b)⋅(xs::['c])⋅ys !! n = f⋅(xs !! n)⋅(ys !! n); (ys::['a]) = []⟧ ⟹ zipWith⋅f⋅((x::'c) : xs)⋅ys !! (n::Integer) = f⋅((x : xs) !! n)⋅(ys !! n)› 3. ‹⋀(a::'a) list::['a]. ⟦⋀(ys::['a]) n::Integer. zipWith⋅(f::'c → 'a → 'b)⋅(xs::['c])⋅ys !! n = f⋅(xs !! n)⋅(ys !! n); (ys::['a]) = a : list⟧ ⟹ zipWith⋅f⋅((x::'c) : xs)⋅ys !! (n::Integer) = f⋅((x : xs) !! n)⋅(ys !! n)› discuss goal 1*) apply (simp split:nth_Cons_split (*‹(?P::?'a ⇒ bool) (((?x::?'a) : (?xs::[?'a])) !! (?n::Integer)) = ((eq⋅?n⋅(0::Integer) = FF ⟶ ?P ((?x : ?xs) !! ?n)) ∧ (eq⋅?n⋅(0::Integer) = TT ⟶ ?P ((?x : ?xs) !! ?n)) ∧ (?n = ⊥ ⟶ ?P ((?x : ?xs) !! ?n)))›*)) (*discuss goal 2*) apply (simp split:nth_Cons_split (*‹(?P::?'a ⇒ bool) (((?x::?'a) : (?xs::[?'a])) !! (?n::Integer)) = ((eq⋅?n⋅(0::Integer) = FF ⟶ ?P ((?x : ?xs) !! ?n)) ∧ (eq⋅?n⋅(0::Integer) = TT ⟶ ?P ((?x : ?xs) !! ?n)) ∧ (?n = ⊥ ⟶ ?P ((?x : ?xs) !! ?n)))›*)) (*discuss goal 3*) apply (simp split:nth_Cons_split (*‹?P ((?x : ?xs) !! ?n) = ((eq⋅?n⋅0 = FF ⟶ ?P ((?x : ?xs) !! ?n)) ∧ (eq⋅?n⋅0 = TT ⟶ ?P ((?x : ?xs) !! ?n)) ∧ (?n = ⊥ ⟶ ?P ((?x : ?xs) !! ?n)))›*)) (*proven 3 subgoals*) . qed (simp_all) (*solves the remaining goals: 1. ‹adm (λa. ∀x xa. zipWith⋅f⋅a⋅x !! xa = f⋅(a !! xa)⋅(x !! xa))› 2. ‹⋀ys n. zipWith⋅f⋅⊥⋅ys !! n = f⋅(⊥ !! n)⋅(ys !! n)› 3. ‹⋀ys n. zipWith⋅f⋅[]⋅ys !! n = f⋅([] !! n)⋅(ys !! n)›*) lemma nth_neg [simp]: "defined n ⟹ ⟦ n ⟧ < 0 ⟹ nth⋅xs⋅n = ⊥" proof (induction xs arbitrary: n) (*goals: 1. ‹adm (λa. ∀x. defined x ⟶ ⟦x⟧ < 0 ⟶ a !! x = ⊥)› 2. ‹⋀n. ⟦defined n; ⟦n⟧ < 0⟧ ⟹ ⊥ !! n = ⊥› 3. ‹⋀n. ⟦defined n; ⟦n⟧ < 0⟧ ⟹ [] !! n = ⊥› 4. ‹⋀a xs n. ⟦⋀n. ⟦defined n; ⟦n⟧ < 0⟧ ⟹ xs !! n = ⊥; defined n; ⟦n⟧ < 0⟧ ⟹ (a : xs) !! n = ⊥›*) have [simp]: "eq⋅n⋅0 = TT ⟷ (n::Integer) = 0" for n apply (cases n) (*goals: 1. ‹n = ⊥ ⟹ (eq⋅n⋅0 = TT) = (n = 0)› 2. ‹⋀int. n = MkI⋅int ⟹ (eq⋅n⋅0 = TT) = (n = 0)› discuss goal 1*) apply ((auto simp add: zero_Integer_def (*‹0 = MkI⋅0›*))[1]) (*discuss goal 2*) apply ((auto simp add: zero_Integer_def (*‹0 = MkI⋅0›*))[1]) (*proven 2 subgoals*) . case (Cons a xs n) (*‹⟦defined ?n; ⟦?n⟧ < 0⟧ ⟹ xs !! ?n = ⊥› ‹defined n› ‹⟦n⟧ < 0›*) have "eq⋅n⋅0 = FF" using Cons.prems (*‹defined (n::Integer)› ‹⟦n⟧ < 0›*) apply (cases "eq⋅n⋅0") (*goals: 1. ‹⟦defined n; ⟦n⟧ < 0; eq⋅n⋅0 = ⊥⟧ ⟹ eq⋅n⋅0 = FF› 2. ‹⟦defined n; ⟦n⟧ < 0; eq⋅n⋅0 = TT⟧ ⟹ eq⋅n⋅0 = FF› 3. ‹⟦defined n; ⟦n⟧ < 0; eq⋅n⋅0 = FF⟧ ⟹ eq⋅n⋅0 = FF› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then show "?case" (*goal: ‹((a::'a) : (xs::['a])) !! (n::Integer) = ⊥›*) using Cons.prems (*‹defined n› ‹⟦n⟧ < 0›*) by (auto intro: Cons.IH (*‹⟦defined ?n; ⟦?n⟧ < 0⟧ ⟹ xs !! ?n = ⊥›*)) qed (simp_all) (*solves the remaining goals: 1. ‹adm (λa. ∀x. defined x ⟶ ⟦x⟧ < 0 ⟶ a !! x = ⊥)› 2. ‹⋀n. ⟦defined n; ⟦n⟧ < 0⟧ ⟹ ⊥ !! n = ⊥› 3. ‹⋀n. ⟦defined n; ⟦n⟧ < 0⟧ ⟹ [] !! n = ⊥›*) lemma nth_Cons_simp [simp]: "defined n ⟹ ⟦ n ⟧ = 0 ⟹ nth⋅(x : xs)⋅n = x" "defined n ⟹ ⟦ n ⟧ > 0 ⟹ nth⋅(x : xs)⋅n = nth⋅xs⋅(n - 1)" proof (-) (*goals: 1. ‹⟦defined n; ⟦n⟧ = 0⟧ ⟹ (x : xs) !! n = x› 2. ‹⟦defined n; 0 < ⟦n⟧⟧ ⟹ (x : xs) !! n = xs !! (n - 1)›*) assume "defined n" and "⟦ n ⟧ = 0" (*‹defined (n::Integer)› ‹⟦n::Integer⟧ = (0::int)›*) then have "n = 0" apply (cases n) (*goals: 1. ‹⟦defined (n::Integer); ⟦n⟧ = (0::int); n = ⊥⟧ ⟹ n = (0::Integer)› 2. ‹⋀int::int. ⟦defined (n::Integer); ⟦n⟧ = (0::int); n = MkI⋅int⟧ ⟹ n = (0::Integer)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then show "nth⋅(x : xs)⋅n = x" by simp next (*goal: ‹⟦defined n; 0 < ⟦n⟧⟧ ⟹ (x : xs) !! n = xs !! (n - 1)›*) assume "defined n" and "⟦ n ⟧ > 0" (*‹defined (n::Integer)› ‹(0::int) < ⟦n::Integer⟧›*) then have "eq⋅n⋅0 = FF" apply (cases "eq⋅n⋅0") (*goals: 1. ‹⟦defined n; 0 < ⟦n⟧; eq⋅n⋅0 = ⊥⟧ ⟹ eq⋅n⋅0 = FF› 2. ‹⟦defined n; 0 < ⟦n⟧; eq⋅n⋅0 = TT⟧ ⟹ eq⋅n⋅0 = FF› 3. ‹⟦defined n; 0 < ⟦n⟧; eq⋅n⋅0 = FF⟧ ⟹ eq⋅n⋅0 = FF› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . then show "nth⋅(x : xs)⋅n = nth⋅xs⋅(n - 1)" by simp qed end
{ "path": "afp-2025-02-12/thys/HOLCF-Prelude/Definedness.thy", "repo": "afp-2025-02-12", "sha": "02ef78744e492c036c3debca1e6cfb5fcfd98828c1f16c39c59a8f772ab90c05" }
section ‹Shorter Solution› theory Challenge1_short imports "lib/VTcomp" begin text ‹Small specification of textbuffer ADT, and its implementation by a gap buffer. Annotated and elaborated version of just the challenge requirements. › subsection ‹Abstract Specification› datatype 'a textbuffer = BUF ("pos": "nat") ("text": "'a list") ― ‹Note that we do not model the abstract invariant --- pos in range --- here, as it is not strictly required for the challenge spec.› text ‹These are the operations that were specified in the challenge. Note: Isabelle has type inference, so we do not need to specify types. Note: We exploit that, in Isabelle, we have @{lemma "(0::nat)-1=0" by simp}. › primrec move_left where "move_left (BUF p t) = BUF (p-1) t" primrec move_right where "move_right (BUF p t) = BUF (min (length t) (p+1)) t" primrec insert where "insert x (BUF p t) = BUF (p+1) (take p t@x#drop p t)" primrec delete where "delete (BUF p t) = BUF (p-1) (take (p-1) t@drop p t)" subsection ‹Refinement 1: List with Gap› subsection ‹Implementation on List-Level› type_synonym 'a gap_buffer = "nat × nat × 'a list" subsubsection ‹Abstraction Relation› text ‹We define an invariant on the concrete gap-buffer, and its mapping to the abstract model. From these two, we define a relation ‹gap_rel› between concrete and abstract buffers. › definition "gap_α ≡ λ(l,r,buf). BUF l (take l buf @ drop r buf)" definition "gap_invar ≡ λ(l,r,buf). l≤r ∧ r≤length buf" abbreviation "gap_rel ≡ br gap_α gap_invar" subsubsection ‹Left› text ‹For the operations, we insert assertions. These are not required to prove the list-level specification correct (during the proof, they are inferred easily). However, they are required in the subsequent automatic refinement step to arrays, to give our tool the information that all indexes are, indeed, in bounds.› definition "move_left1 ≡ λ(l,r,buf). doN { if l≠0 then doN { ASSERT(r-1<length buf ∧ l-1<length buf); RETURN (l-1,r-1,buf[r-1:=buf!(l-1)]) } else RETURN (l,r,buf) }" lemma move_left1_correct: "(move_left1, RETURN o move_left) ∈ gap_rel → ⟨gap_rel⟩nres_rel" apply clarsimp (*goal: ‹(move_left1, RETURN ∘ move_left) ∈ gap_rel → ⟨gap_rel⟩nres_rel›*) unfolding move_left1_def (*goal: ‹⋀a aa b a'. ((a, aa, b), a') ∈ gap_rel ⟹ (case (a, aa, b) of (l, r, buf) ⇒ if l ≠ 0 then ASSERT (r - 1 < length buf ∧ l - 1 < length buf) ⤜ (λ_. RETURN (l - 1, r - 1, buf[r - 1 := buf ! (l - 1)])) else RETURN (l, r, buf), RETURN (move_left a')) ∈ ⟨gap_rel⟩nres_rel›*) apply refine_vcg (*goals: 1. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ gap_rel; (a, aa, b) = (ab, ba); ba = (ac, bb); ab ≠ 0⟧ ⟹ ac - 1 < length bb› 2. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ gap_rel; (a, aa, b) = (ab, ba); ba = (ac, bb); ab ≠ 0⟧ ⟹ ab - 1 < length bb› 3. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ gap_rel; (a, aa, b) = (ab, ba); ba = (ac, bb); ab ≠ 0; ac - 1 < length bb ∧ ab - 1 < length bb⟧ ⟹ ((ab - 1, ac - 1, bb[ac - 1 := bb ! (ab - 1)]), move_left a') ∈ gap_rel› 4. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ gap_rel; (a, aa, b) = (ab, ba); ba = (ac, bb); ¬ ab ≠ 0⟧ ⟹ ((ab, ac, bb), move_left a') ∈ gap_rel› discuss goal 1*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) gap_α_def (*‹gap_α ≡ λ(l, r, buf). BUF l (take l buf @ drop r buf)›*) gap_invar_def (*‹gap_invar ≡ λ(l, r, buf). l ≤ r ∧ r ≤ length buf›*) move_left1_def (*‹move_left1 ≡ λ(l, r, buf). if l ≠ 0 then ASSERT (r - 1 < length buf ∧ l - 1 < length buf) ⤜ (λ_. RETURN (l - 1, r - 1, buf[r - 1 := buf ! (l - 1)])) else RETURN (l, r, buf)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) gap_α_def (*‹gap_α ≡ λ(l, r, buf). BUF l (take l buf @ drop r buf)›*) gap_invar_def (*‹gap_invar ≡ λ(l, r, buf). l ≤ r ∧ r ≤ length buf›*) move_left1_def (*‹move_left1 ≡ λ(l, r, buf). if l ≠ 0 then ASSERT (r - 1 < length buf ∧ l - 1 < length buf) ⤜ (λ_. RETURN (l - 1, r - 1, buf[r - 1 := buf ! (l - 1)])) else RETURN (l, r, buf)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 3*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) gap_α_def (*‹gap_α ≡ λ(l, r, buf). BUF l (take l buf @ drop r buf)›*) gap_invar_def (*‹gap_invar ≡ λ(l, r, buf). l ≤ r ∧ r ≤ length buf›*) move_left1_def (*‹move_left1 ≡ λ(l, r, buf). if l ≠ 0 then ASSERT (r - 1 < length buf ∧ l - 1 < length buf) ⤜ (λ_. RETURN (l - 1, r - 1, buf[r - 1 := buf ! (l - 1)])) else RETURN (l, r, buf)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*top goal: ‹⋀(a::nat) (aa::nat) (b::'a list) (a'::'a textbuffer) (ab::nat) (ba::nat × 'a list) (ac::nat) bb::'a list. ⟦((a, aa, b), a') ∈ gap_rel; (a, aa, b) = (ab, ba); ba = (ac, bb); ab ≠ (0::nat); ac - (1::nat) < length bb ∧ ab - (1::nat) < length bb⟧ ⟹ ((ab - (1::nat), ac - (1::nat), bb[ac - (1::nat) := bb ! (ab - (1::nat))]), move_left a') ∈ gap_rel› and 1 goal remains*) apply (smt Cons_nth_drop_Suc (*‹?i < length ?xs ⟹ ?xs ! ?i # drop (Suc ?i) ?xs = drop ?i ?xs›*) Suc_pred (*‹0 < ?n ⟹ Suc (?n - Suc 0) = ?n›*) append.assoc (*‹(?a @ ?b) @ ?c = ?a @ ?b @ ?c›*) append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) append_Nil (*‹[] @ ?ys = ?ys›*) diff_Suc_less (*‹0 < ?n ⟹ ?n - Suc ?i < ?n›*) drop_update_cancel (*‹?n < ?m ⟹ drop ?m (?xs[?n := ?x]) = drop ?m ?xs›*) hd_drop_conv_nth (*‹?n < length ?xs ⟹ hd (drop ?n ?xs) = ?xs ! ?n›*) length_list_update (*‹length (?xs[?i := ?x]) = length ?xs›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) nth_list_update_eq (*‹?i < length ?xs ⟹ ?xs[?i := ?x] ! ?i = ?x›*) take_hd_drop (*‹?n < length ?xs ⟹ take ?n ?xs @ [hd (drop ?n ?xs)] = take (Suc ?n) ?xs›*)) (*discuss goal 4*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) gap_α_def (*‹gap_α ≡ λ(l, r, buf). BUF l (take l buf @ drop r buf)›*) gap_invar_def (*‹gap_invar ≡ λ(l, r, buf). l ≤ r ∧ r ≤ length buf›*) move_left1_def (*‹move_left1 ≡ λ(l, r, buf). if l ≠ 0 then ASSERT (r - 1 < length buf ∧ l - 1 < length buf) ⤜ (λ_. RETURN (l - 1, r - 1, buf[r - 1 := buf ! (l - 1)])) else RETURN (l, r, buf)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 4 subgoals*) . subsubsection ‹Right› definition "move_right1 ≡ λ(l,r,buf). doN { if r<length buf then doN { ASSERT (l<length buf); RETURN (l+1,r+1,buf[l:=buf!r]) } else RETURN (l,r,buf) }" lemma move_right1_correct: "(move_right1,RETURN o move_right) ∈ gap_rel → ⟨gap_rel⟩nres_rel" apply clarsimp (*goal: ‹(move_right1, RETURN ∘ move_right) ∈ gap_rel → ⟨gap_rel⟩nres_rel›*) unfolding move_right1_def (*goal: ‹⋀a aa b a'. ((a, aa, b), a') ∈ gap_rel ⟹ (case (a, aa, b) of (l, r, buf) ⇒ if r < length buf then ASSERT (l < length buf) ⤜ (λ_. RETURN (l + 1, r + 1, buf[l := buf ! r])) else RETURN (l, r, buf), RETURN (move_right a')) ∈ ⟨gap_rel⟩nres_rel›*) apply refine_vcg (*goal: ‹⋀a aa b a'. ((a, aa, b), a') ∈ gap_rel ⟹ (case (a, aa, b) of (l, r, buf) ⇒ if r < length buf then ASSERT (l < length buf) ⤜ (λ_. RETURN (l + 1, r + 1, buf[l := buf ! r])) else RETURN (l, r, buf), RETURN (move_right a')) ∈ ⟨gap_rel⟩nres_rel›*) unfolding "gap_α_def" gap_invar_def (*goals: 1. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ac < length bb⟧ ⟹ ab < length bb› 2. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ac < length bb; ab < length bb⟧ ⟹ ((ab + 1, ac + 1, bb[ab := bb ! ac]), move_right a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf)› 3. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ¬ ac < length bb⟧ ⟹ ((ab, ac, bb), move_right a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf)›*) (*goals: 1. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ac < length bb⟧ ⟹ ab < length bb› 2. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ac < length bb; ab < length bb⟧ ⟹ ((ab + 1, ac + 1, bb[ab := bb ! ac]), move_right a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf)› 3. ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ¬ ac < length bb⟧ ⟹ ((ab, ac, bb), move_right a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf)› discuss goal 1*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: in_br_conv (*‹((?c::?'a, ?a::?'b) ∈ br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool)) = (?a = ?α ?c ∧ ?I ?c)›*) split: prod.split (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*top goal: ‹⋀a aa b a' ab ba ac bb. ⟦((a, aa, b), a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ac < length bb; ab < length bb⟧ ⟹ ((ab + 1, ac + 1, bb[ab := bb ! ac]), move_right a') ∈ br (λ(l, r, buf). BUF l (take l buf @ drop r buf)) (λ(l, r, buf). l ≤ r ∧ r ≤ length buf)› and 1 goal remains*) apply (rule nth_equalityI (*‹⟦length ?xs = length ?ys; ⋀i. i < length ?xs ⟹ ?xs ! i = ?ys ! i⟧ ⟹ ?xs = ?ys›*)) (*goals: 1. ‹⋀aa b ab. ⟦ab ≤ aa; aa < length b⟧ ⟹ length (take ab b @ drop aa b) = length ((take (Suc ab) b)[ab := b ! aa] @ drop (Suc aa) b)› 2. ‹⋀aa b ab i. ⟦ab ≤ aa; aa < length b; i < length (take ab b @ drop aa b)⟧ ⟹ (take ab b @ drop aa b) ! i = ((take (Suc ab) b)[ab := b ! aa] @ drop (Suc aa) b) ! i› discuss goal 1*) apply (simp add: Cons_nth_drop_Suc (*‹(?i::nat) < length (?xs::?'a list) ⟹ ?xs ! ?i # drop (Suc ?i) ?xs = drop ?i ?xs›*) take_update_last (*‹(?n::nat) < length (?list::?'a list) ⟹ (take (Suc ?n) ?list)[?n := ?x::?'a] = take ?n ?list @ [?x]›*)) (*discuss goal 2*) apply (simp add: Cons_nth_drop_Suc (*‹(?i::nat) < length (?xs::?'a list) ⟹ ?xs ! ?i # drop (Suc ?i) ?xs = drop ?i ?xs›*) take_update_last (*‹(?n::nat) < length (?list::?'a list) ⟹ (take (Suc ?n) ?list)[?n := ?x::?'a] = take ?n ?list @ [?x]›*)) (*proven 2 subgoals*) (*discuss goal 3*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*proven 3 subgoals*) . subsubsection ‹Insert and Grow› definition "can_insert ≡ λ(l,r,buf). l<r" definition "grow1 K ≡ λ(l,r,buf). doN { let b = op_array_replicate (length buf + K) default; b ← mop_list_blit buf 0 b 0 l; b ← mop_list_blit buf r b (r+K) (length buf - r); RETURN (l,r+K,b) }" ― ‹Note: Most operations have also a variant prefixed with ‹mop›. These are defined in the refinement monad and already contain the assertion of their precondition. The backside is that they cannot be easily used in as part of expressions, e.g., in @{term "buf[l:=buf!r]"}, we would have to explicitly bind each intermediate value: @{term "doN { v ← mop_list_get buf r; mop_list_set buf l v }"}. › lemma grow1_correct[THEN SPEC_trans, refine_vcg]: ― ‹Declares this as a rule to be used by the VCG› assumes "gap_invar gb" shows "grow1 K gb ≤ (SPEC (λgb'. gap_invar gb' ∧ gap_α gb' = gap_α gb ∧ (K>0 ⟶ can_insert gb')))" unfolding grow1_def (*goal: ‹(case gb of (l, r, buf) ⇒ let b = op_array_replicate (length buf + K) default in mop_list_blit buf 0 b 0 l ⤜ (λb. mop_list_blit buf r b (r + K) (length buf - r) ⤜ (λb. RETURN (l, r + K, b)))) ≤ SPEC (λgb'. gap_invar gb' ∧ gap_α gb' = gap_α gb ∧ (0 < K ⟶ can_insert gb'))›*) apply refine_vcg (*goal: ‹(case gb of (l, r, buf) ⇒ let b = op_array_replicate (length buf + K) default in mop_list_blit buf 0 b 0 l ⤜ (λb. mop_list_blit buf r b (r + K) (length buf - r) ⤜ (λb. RETURN (l, r + K, b)))) ≤ SPEC (λgb'. gap_invar gb' ∧ gap_α gb' = gap_α gb ∧ (0 < K ⟶ can_insert gb'))›*) using assms (*‹gap_invar (gb::nat × nat × 'a::default list)›*) unfolding "gap_α_def" gap_invar_def can_insert_def (*goals: 1. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba)⟧ ⟹ 0 + a ≤ length ba› 2. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba)⟧ ⟹ 0 + a ≤ length (op_array_replicate (length ba + K) default)› 3. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba)⟧ ⟹ aa + (length ba - aa) ≤ length ba› 4. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba)⟧ ⟹ aa + K + (length ba - aa) ≤ length (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a)› 5. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba)⟧ ⟹ case (a, aa + K, op_list_blit ba aa (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a) (aa + K) (length ba - aa)) of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf› 6. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba)⟧ ⟹ (case (a, aa + K, op_list_blit ba aa (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a) (aa + K) (length ba - aa)) of (l, r, buf) ⇒ BUF l (take l buf @ drop r buf)) = (case gb of (l, r, buf) ⇒ BUF l (take l buf @ drop r buf))› 7. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); 0 < K⟧ ⟹ case (a, aa + K, op_list_blit ba aa (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a) (aa + K) (length ba - aa)) of (l, r, buf) ⇒ l < r›*) apply - (*goals: 1. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ 0 + a ≤ length ba› 2. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ 0 + a ≤ length (op_array_replicate (length ba + K) default)› 3. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ aa + (length ba - aa) ≤ length ba› 4. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ aa + K + (length ba - aa) ≤ length (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a)› 5. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ case (a, aa + K, op_list_blit ba aa (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a) (aa + K) (length ba - aa)) of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf› 6. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ (case (a, aa + K, op_list_blit ba aa (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a) (aa + K) (length ba - aa)) of (l, r, buf) ⇒ BUF l (take l buf @ drop r buf)) = (case gb of (l, r, buf) ⇒ BUF l (take l buf @ drop r buf))› 7. ‹⋀a b aa ba. ⟦gb = (a, b); b = (aa, ba); 0 < K; case gb of (l, r, buf) ⇒ l ≤ r ∧ r ≤ length buf⟧ ⟹ case (a, aa + K, op_list_blit ba aa (op_list_blit ba 0 (op_array_replicate (length ba + K) default) 0 a) (aa + K) (length ba - aa)) of (l, r, buf) ⇒ l < r› discuss goal 1*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*discuss goal 2*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*discuss goal 3*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*discuss goal 4*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*discuss goal 5*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*discuss goal 6*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*discuss goal 7*) apply ((auto simp: op_list_blit_def (*‹op_list_blit ?src ?si ?dst ?di ?len ≡ take ?di ?dst @ take ?len (drop ?si ?src) @ drop (?di + ?len) ?dst›*))[1]) (*proven 7 subgoals*) . definition "insert1 x ≡ λ(l,r,buf). doN { (l,r,buf) ← if (l=r) then grow1 (length buf+1) (l,r,buf) else RETURN (l,r,buf); ASSERT (l<length buf); RETURN (l+1,r,buf[l:=x]) }" lemma insert1_correct: "(insert1,RETURN oo insert) ∈ Id → gap_rel → ⟨gap_rel⟩nres_rel" apply clarsimp (*goal: ‹(insert1, RETURN ∘∘ Challenge1_short.insert) ∈ Id → gap_rel → ⟨gap_rel⟩nres_rel›*) unfolding insert1_def (*goal: ‹⋀a' aa ab b a'a. ((aa, ab, b), a'a) ∈ gap_rel ⟹ (case (aa, ab, b) of (l, r, buf) ⇒ (if l = r then grow1 (length buf + 1) (l, r, buf) else RETURN (l, r, buf)) ⤜ (λ(l, r, buf). ASSERT (l < length buf) ⤜ (λ_. RETURN (l + 1, r, buf[l := a']))), RETURN (Challenge1_short.insert a' a'a)) ∈ ⟨gap_rel⟩nres_rel›*) apply refine_vcg (*goal: ‹⋀a' aa ab b a'a. ((aa, ab, b), a'a) ∈ gap_rel ⟹ (case (aa, ab, b) of (l, r, buf) ⇒ (if l = r then grow1 (length buf + 1) (l, r, buf) else RETURN (l, r, buf)) ⤜ (λ(l, r, buf). ASSERT (l < length buf) ⤜ (λ_. RETURN (l + 1, r, buf[l := a']))), RETURN (Challenge1_short.insert a' a'a)) ∈ ⟨gap_rel⟩nres_rel›*) unfolding insert_def "gap_α_def" gap_invar_def can_insert_def (*goals: 1. ‹⋀(a'::'a::default) (aa::nat) (ab::nat) (b::'a::default list) (a'a::'a::default textbuffer) (a::nat) (ba::nat × 'a::default list) (ac::nat) bb::'a::default list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a = ac⟧ ⟹ case (a, ac, bb) of (l::nat, r::nat, buf::'a::default list) ⇒ l ≤ r ∧ r ≤ length buf› 2. ‹⋀(a'::'a::default) (aa::nat) (ab::nat) (b::'a::default list) (a'a::'a::default textbuffer) (a::nat) (ba::nat × 'a::default list) (ac::nat) (bb::'a::default list) (x::nat × nat × 'a::default list) (ad::nat) (bc::nat × 'a::default list) (ae::nat) bd::'a::default list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a = ac; (case x of (l::nat, r::nat, buf::'a::default list) ⇒ l ≤ r ∧ r ≤ length buf) ∧ (case x of (l::nat, r::nat, buf::'a::default list) ⇒ BUF l (take l buf @ drop r buf)) = (case (a, ac, bb) of (l::nat, r::nat, buf::'a::default list) ⇒ BUF l (take l buf @ drop r buf)) ∧ ((0::nat) < length bb + (1::nat) ⟶ (case x of (l::nat, r::nat, buf::'a::default list) ⇒ l < r)); x = (ad, bc); bc = (ae, bd)⟧ ⟹ ad < length bd› 3. ‹⋀(a'::'a::default) (aa::nat) (ab::nat) (b::'a::default list) (a'a::'a::default textbuffer) (a::nat) (ba::nat × 'a::default list) (ac::nat) (bb::'a::default list) (x::nat × nat × 'a::default list) (ad::nat) (bc::nat × 'a::default list) (ae::nat) bd::'a::default list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a = ac; (case x of (l::nat, r::nat, buf::'a::default list) ⇒ l ≤ r ∧ r ≤ length buf) ∧ (case x of (l::nat, r::nat, buf::'a::default list) ⇒ BUF l (take l buf @ drop r buf)) = (case (a, ac, bb) of (l::nat, r::nat, buf::'a::default list) ⇒ BUF l (take l buf @ drop r buf)) ∧ ((0::nat) < length bb + (1::nat) ⟶ (case x of (l::nat, r::nat, buf::'a::default list) ⇒ l < r)); x = (ad, bc); bc = (ae, bd); ad < length bd⟧ ⟹ ((ad + (1::nat), ae, bd[ad := a']), rec_textbuffer (λ(p::nat) (t::'a::default list) x::'a::default. BUF (p + (1::nat)) (take p t @ x # drop p t)) a'a a') ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf)› 4. ‹⋀(a'::'a::default) (aa::nat) (ab::nat) (b::'a::default list) (a'a::'a::default textbuffer) (a::nat) (ba::nat × 'a::default list) (ac::nat) (bb::'a::default list) (ad::nat) (bc::nat × 'a::default list) (ae::nat) bd::'a::default list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a ≠ ac; (a, ac, bb) = (ad, bc); bc = (ae, bd)⟧ ⟹ ad < length bd› 5. ‹⋀(a'::'a::default) (aa::nat) (ab::nat) (b::'a::default list) (a'a::'a::default textbuffer) (a::nat) (ba::nat × 'a::default list) (ac::nat) (bb::'a::default list) (ad::nat) (bc::nat × 'a::default list) (ae::nat) bd::'a::default list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a ≠ ac; (a, ac, bb) = (ad, bc); bc = (ae, bd); ad < length bd⟧ ⟹ ((ad + (1::nat), ae, bd[ad := a']), rec_textbuffer (λ(p::nat) (t::'a::default list) x::'a::default. BUF (p + (1::nat)) (take p t @ x # drop p t)) a'a a') ∈ br (λ(l::nat, r::nat, buf::'a::default list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::default list). l ≤ r ∧ r ≤ length buf)›*) (*goals: 1. ‹⋀(a'::'a) (aa::nat) (ab::nat) (b::'a list) (a'a::'a textbuffer) (a::nat) (ba::nat × 'a list) (ac::nat) bb::'a list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a = ac⟧ ⟹ case (a, ac, bb) of (l::nat, r::nat, buf::'a list) ⇒ l ≤ r ∧ r ≤ length buf› 2. ‹⋀(a'::'a) (aa::nat) (ab::nat) (b::'a list) (a'a::'a textbuffer) (a::nat) (ba::nat × 'a list) (ac::nat) (bb::'a list) (x::nat × nat × 'a list) (ad::nat) (bc::nat × 'a list) (ae::nat) bd::'a list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a = ac; (case x of (l::nat, r::nat, buf::'a list) ⇒ l ≤ r ∧ r ≤ length buf) ∧ (case x of (l::nat, r::nat, buf::'a list) ⇒ BUF l (take l buf @ drop r buf)) = (case (a, ac, bb) of (l::nat, r::nat, buf::'a list) ⇒ BUF l (take l buf @ drop r buf)) ∧ ((0::nat) < length bb + (1::nat) ⟶ (case x of (l::nat, r::nat, buf::'a list) ⇒ l < r)); x = (ad, bc); bc = (ae, bd)⟧ ⟹ ad < length bd› 3. ‹⋀(a'::'a) (aa::nat) (ab::nat) (b::'a list) (a'a::'a textbuffer) (a::nat) (ba::nat × 'a list) (ac::nat) (bb::'a list) (x::nat × nat × 'a list) (ad::nat) (bc::nat × 'a list) (ae::nat) bd::'a list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a = ac; (case x of (l::nat, r::nat, buf::'a list) ⇒ l ≤ r ∧ r ≤ length buf) ∧ (case x of (l::nat, r::nat, buf::'a list) ⇒ BUF l (take l buf @ drop r buf)) = (case (a, ac, bb) of (l::nat, r::nat, buf::'a list) ⇒ BUF l (take l buf @ drop r buf)) ∧ ((0::nat) < length bb + (1::nat) ⟶ (case x of (l::nat, r::nat, buf::'a list) ⇒ l < r)); x = (ad, bc); bc = (ae, bd); ad < length bd⟧ ⟹ ((ad + (1::nat), ae, bd[ad := a']), rec_textbuffer (λ(p::nat) (t::'a list) x::'a. BUF (p + (1::nat)) (take p t @ x # drop p t)) a'a a') ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf)› 4. ‹⋀(a'::'a) (aa::nat) (ab::nat) (b::'a list) (a'a::'a textbuffer) (a::nat) (ba::nat × 'a list) (ac::nat) (bb::'a list) (ad::nat) (bc::nat × 'a list) (ae::nat) bd::'a list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a ≠ ac; (a, ac, bb) = (ad, bc); bc = (ae, bd)⟧ ⟹ ad < length bd› 5. ‹⋀(a'::'a) (aa::nat) (ab::nat) (b::'a list) (a'a::'a textbuffer) (a::nat) (ba::nat × 'a list) (ac::nat) (bb::'a list) (ad::nat) (bc::nat × 'a list) (ae::nat) bd::'a list. ⟦((aa, ab, b), a'a) ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (aa, ab, b) = (a, ba); ba = (ac, bb); a ≠ ac; (a, ac, bb) = (ad, bc); bc = (ae, bd); ad < length bd⟧ ⟹ ((ad + (1::nat), ae, bd[ad := a']), rec_textbuffer (λ(p::nat) (t::'a list) x::'a. BUF (p + (1::nat)) (take p t @ x # drop p t)) a'a a') ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf)› discuss goal 1*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) take_update_last (*‹?n < length ?list ⟹ (take (Suc ?n) ?list)[?n := ?x] = take ?n ?list @ [?x]›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) take_update_last (*‹?n < length ?list ⟹ (take (Suc ?n) ?list)[?n := ?x] = take ?n ?list @ [?x]›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*discuss goal 3*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) take_update_last (*‹?n < length ?list ⟹ (take (Suc ?n) ?list)[?n := ?x] = take ?n ?list @ [?x]›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*discuss goal 4*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) take_update_last (*‹?n < length ?list ⟹ (take (Suc ?n) ?list)[?n := ?x] = take ?n ?list @ [?x]›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*discuss goal 5*) apply ((auto simp: in_br_conv (*‹((?c::?'a, ?a::?'b) ∈ br (?α::?'a ⇒ ?'b) (?I::?'a ⇒ bool)) = (?a = ?α ?c ∧ ?I ?c)›*) take_update_last (*‹(?n::nat) < length (?list::?'a list) ⟹ (take (Suc ?n) ?list)[?n := ?x::?'a] = take ?n ?list @ [?x]›*) split: prod.split (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*proven 5 subgoals*) . subsubsection ‹Delete› definition "delete1 ≡ λ(l,r,buf). if l>0 then RETURN (l-1,r,buf) else RETURN (l,r,buf)" lemma delete1_correct: "(delete1,RETURN o delete) ∈ gap_rel → ⟨gap_rel⟩nres_rel" apply clarsimp (*goal: ‹(delete1, RETURN ∘ delete) ∈ gap_rel → ⟨gap_rel⟩nres_rel›*) unfolding delete1_def (*goal: ‹⋀a aa b a'. ((a, aa, b), a') ∈ gap_rel ⟹ (case (a, aa, b) of (l, r, buf) ⇒ if 0 < l then RETURN (l - 1, r, buf) else RETURN (l, r, buf), RETURN (delete a')) ∈ ⟨gap_rel⟩nres_rel›*) apply refine_vcg (*goal: ‹⋀a aa b a'. ((a, aa, b), a') ∈ gap_rel ⟹ (case (a, aa, b) of (l, r, buf) ⇒ if 0 < l then RETURN (l - 1, r, buf) else RETURN (l, r, buf), RETURN (delete a')) ∈ ⟨gap_rel⟩nres_rel›*) unfolding "gap_α_def" gap_invar_def (*goals: 1. ‹⋀(a::nat) (aa::nat) (b::'a::type list) (a'::'a::type textbuffer) (ab::nat) (ba::nat × 'a::type list) (ac::nat) bb::'a::type list. ⟦((a, aa, b), a') ∈ br (λ(l::nat, r::nat, buf::'a::type list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::type list). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); (0::nat) < ab⟧ ⟹ ((ab - (1::nat), ac, bb), delete a') ∈ br (λ(l::nat, r::nat, buf::'a::type list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::type list). l ≤ r ∧ r ≤ length buf)› 2. ‹⋀(a::nat) (aa::nat) (b::'a::type list) (a'::'a::type textbuffer) (ab::nat) (ba::nat × 'a::type list) (ac::nat) bb::'a::type list. ⟦((a, aa, b), a') ∈ br (λ(l::nat, r::nat, buf::'a::type list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::type list). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ¬ (0::nat) < ab⟧ ⟹ ((ab, ac, bb), delete a') ∈ br (λ(l::nat, r::nat, buf::'a::type list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a::type list). l ≤ r ∧ r ≤ length buf)›*) (*goals: 1. ‹⋀(a::nat) (aa::nat) (b::'a list) (a'::'a textbuffer) (ab::nat) (ba::nat × 'a list) (ac::nat) bb::'a list. ⟦((a, aa, b), a') ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); (0::nat) < ab⟧ ⟹ ((ab - (1::nat), ac, bb), delete a') ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf)› 2. ‹⋀(a::nat) (aa::nat) (b::'a list) (a'::'a textbuffer) (ab::nat) (ba::nat × 'a list) (ac::nat) bb::'a list. ⟦((a, aa, b), a') ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf); (a, aa, b) = (ab, ba); ba = (ac, bb); ¬ (0::nat) < ab⟧ ⟹ ((ab, ac, bb), delete a') ∈ br (λ(l::nat, r::nat, buf::'a list). BUF l (take l buf @ drop r buf)) (λ(l::nat, r::nat, buf::'a list). l ≤ r ∧ r ≤ length buf)› discuss goal 1*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) butlast_take (*‹?n ≤ length ?xs ⟹ butlast (take ?n ?xs) = take (?n - 1) ?xs›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto simp: in_br_conv (*‹((?c, ?a) ∈ br ?α ?I) = (?a = ?α ?c ∧ ?I ?c)›*) butlast_take (*‹?n ≤ length ?xs ⟹ butlast (take ?n ?xs) = take (?n - 1) ?xs›*) split: prod.split (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . subsection ‹Imperative Arrays› text ‹The following indicates how we will further refine the gap-buffer: The list will become an array, the indices and the content will not be refined (expressed by @{const nat_assn} and @{const id_assn}). › abbreviation "gap_impl_assn ≡ nat_assn ×⇩a nat_assn ×⇩a array_assn id_assn" sepref_definition move_left_impl is move_left1 :: "gap_impl_assn⇧d→⇩agap_impl_assn" unfolding move_left1_def by sepref sepref_definition move_right_impl is move_right1 :: "gap_impl_assn⇧d→⇩agap_impl_assn" unfolding move_right1_def by sepref sepref_definition insert_impl is "uncurry insert1" :: "id_assn⇧k*⇩agap_impl_assn⇧d→⇩agap_impl_assn" unfolding insert1_def grow1_def by sepref ― ‹We inline @{const grow1} here› sepref_definition delete_impl is delete1 :: "gap_impl_assn⇧d→⇩agap_impl_assn" unfolding delete1_def by sepref text ‹Finally, we combine the two refinement steps, to get overall correctness theorems› definition "gap_assn ≡ hr_comp gap_impl_assn gap_rel" ― ‹@{const hr_comp} is composition of refinement relations› context notes gap_assn_def[symmetric,fcomp_norm_unfold] begin lemmas move_left_impl_correct = move_left_impl.refine[FCOMP move_left1_correct] and move_right_impl_correct = move_right_impl.refine[FCOMP move_right1_correct] and insert_impl_correct = insert_impl.refine[FCOMP insert1_correct] and delete_impl_correct = delete_impl.refine[FCOMP delete1_correct] text ‹Proves: @{thm [display] move_left_impl_correct} @{thm [display] move_right_impl_correct} @{thm [display] insert_impl_correct} @{thm [display] delete_impl_correct} › end subsection ‹Executable Code› text ‹Isabelle/HOL can generate code in various target languages.› export_code move_left_impl move_right_impl insert_impl delete_impl in SML_imp module_name Gap_Buffer in OCaml_imp module_name Gap_Buffer in Haskell module_name Gap_Buffer in Scala module_name Gap_Buffer end
{ "path": "afp-2025-02-12/thys/VerifyThis2018/Challenge1_short.thy", "repo": "afp-2025-02-12", "sha": "5225fafe4715c9bc895c38112e7ee38b731d1e1ccf7a46cddfd4c996a1814e21" }
(* Author: Salomon Sickert License: BSD *) section ‹Translation from LTL to (Deterministic Transitions-Based) Generalised Rabin Automata› theory LTL_Rabin imports Main Mojmir_Rabin Logical_Characterization begin subsection ‹Preliminary Facts› lemma run_af_G_letter_abs_eq_Abs_af_G_letter: "run ↑af⇩G (Abs φ) w i = Abs (run af_G_letter φ w i)" apply (induction i) (*goals: 1. ‹run ↑af⇩G (Abs φ) w 0 = Abs (run af_G_letter φ w 0)› 2. ‹⋀i. run ↑af⇩G (Abs φ) w i = Abs (run af_G_letter φ w i) ⟹ run ↑af⇩G (Abs φ) w (Suc i) = Abs (run af_G_letter φ w (Suc i))› discuss goal 1*) apply simp (*discuss goal 2*) apply (metis af_G_abs.f_foldl_abs.abs_eq (*‹af_G_abs.f_foldl_abs (Abs ?xa) ?x = Abs (af⇩G ?xa ?x)›*) af_G_abs.f_foldl_abs_alt_def (*‹af_G_abs.f_foldl_abs (Abs ?φ) ?w = foldl af_G_abs.f_abs (Abs ?φ) ?w›*) run_foldl (*‹run ?Δ ?q₀ ?w ?i = foldl ?Δ ?q₀ (map ?w [0..<?i])›*) af_G_letter_abs_def (*‹↑af⇩G ≡ af_G_abs.f_abs›*)) (*proven 2 subgoals*) . lemma finite_reach_af: "finite (reach Σ ↑af (Abs φ))" proof (cases "Σ ≠ {}") (*goals: 1. ‹Σ ≠ {} ⟹ finite (reach Σ ↑af (Abs φ))› 2. ‹¬ Σ ≠ {} ⟹ finite (reach Σ ↑af (Abs φ))›*) case True (*‹(Σ::'a set set) ≠ {}›*) thus "?thesis" (*goal: ‹finite (reach Σ ↑af (Abs φ))›*) using af_abs.finite_abs_reach (*‹finite (af_abs.abs_reach (Abs (?φ::?'a ltl)))›*) unfolding af_abs.abs_reach_def reach_foldl_def[OF True] (*goal: ‹finite {foldl ↑af (Abs φ) w |w. set w ⊆ Σ}›*) using finite_subset[of "{foldl ↑af (Abs φ) w |w. set w ⊆ Σ}" "{foldl ↑af(Abs φ) w |w. True}"] (*‹⟦{foldl ↑af (Abs (φ::'a ltl)) w |w::'a set list. set w ⊆ (Σ::'a set set)} ⊆ {foldl ↑af (Abs φ) w |w::'a set list. True}; finite {foldl ↑af (Abs φ) w |w::'a set list. True}⟧ ⟹ finite {foldl ↑af (Abs φ) w |w::'a set list. set w ⊆ Σ}›*) unfolding af_letter_abs_def (*goal: ‹finite {foldl af_abs.f_abs (Abs φ) w |w. set w ⊆ Σ}›*) by blast qed (simp add: reach_def (*‹reach ?Σ ?δ ?q₀ = {run ?δ ?q₀ w n |w n. range w ⊆ ?Σ}›*)) (*solved the remaining goal: ‹¬ Σ ≠ {} ⟹ finite (reach Σ ↑af (Abs φ))›*) lemma ltl_semi_mojmir: assumes "finite Σ" assumes "range w ⊆ Σ" shows "semi_mojmir Σ ↑af⇩G (Abs ψ) w" proof (standard) (*goals: 1. ‹finite (Σ::'a set set)› 2. ‹finite (reach (Σ::'a set set) ↑af⇩G (Abs (ψ::'a ltl)))› 3. ‹range (w::nat ⇒ 'a set) ⊆ (Σ::'a set set)›*) fix ψ have "nonempty_Σ": "Σ ≠ {}" using assms (*‹finite Σ› ‹range w ⊆ Σ›*) by auto show "finite (reach Σ ↑af⇩G (Abs ψ))" (is "finite ?A") using af_G_abs.finite_abs_reach (*‹finite (af_G_abs.abs_reach (Abs (?φ::?'a ltl)))›*) finite_subset[where A = ?A, where B = "lift_ltl_transformer.abs_reach af_G_letter (Abs ψ)"] (*‹⟦reach Σ ↑af⇩G (Abs ψ) ⊆ af_G_abs.abs_reach (Abs ψ); finite (af_G_abs.abs_reach (Abs ψ))⟧ ⟹ finite (reach Σ ↑af⇩G (Abs ψ))›*) unfolding af_G_abs.abs_reach_def af_G_letter_abs_def reach_foldl_def[OF nonempty_Σ] (*goal: ‹finite {foldl af_G_abs.f_abs (Abs ψ) w |w. set w ⊆ Σ}›*) by blast qed (insert assms (*‹finite Σ› ‹range w ⊆ Σ›*), auto) (*solves the remaining goals: 1. ‹finite Σ› 2. ‹range w ⊆ Σ›*) subsection ‹Single Secondary Automaton› locale ltl_FG_to_rabin_def = fixes Σ :: "'a set set" fixes φ :: "'a ltl" fixes 𝒢 :: "'a ltl set" fixes w :: "'a set word" begin sublocale mojmir_to_rabin_def Σ "↑af⇩G" "Abs φ" w "{q. 𝒢 ⊨⇩P Rep q}" . ― ‹Import abbreviations from parent locale to simplify terms› abbreviation "δ⇩R ≡ step" abbreviation "q⇩R ≡ initial" abbreviation "Acc⇩R j ≡ (fail⇩R ∪ merge⇩R j, succeed⇩R j)" abbreviation "max_rank⇩R ≡ max_rank" abbreviation "smallest_accepting_rank⇩R ≡ smallest_accepting_rank" abbreviation "accept⇩R' ≡ accept" abbreviation "𝒮⇩R ≡ 𝒮" lemma Rep_token_run_af: "Rep (token_run x n) ≡⇩P af⇩G φ (w [x → n])" proof (-) (*goal: ‹Rep (token_run x n) ≡⇩P af⇩G φ (w [x → n])›*) have "token_run x n = Abs (af⇩G φ ((suffix x w) [0 → (n - x)]))" apply (simp add: subsequence_def (*‹?w [?i → ?j] ≡ map ?w [?i..<?j]›*) run_foldl (*‹run ?Δ ?q₀ ?w ?i = foldl ?Δ ?q₀ (map ?w [0..<?i])›*)) (*goal: ‹token_run x n = Abs (af⇩G φ (prefix (n - x) (suffix x w)))›*) by (metis af_G_abs.f_foldl_abs.abs_eq (*‹af_G_abs.f_foldl_abs (Abs (?xa::?'a ltl)) (?x::?'a set list) = Abs (af⇩G ?xa ?x)›*) af_G_abs.f_foldl_abs_alt_def (*‹af_G_abs.f_foldl_abs (Abs (?φ::?'a ltl)) (?w::?'a set list) = foldl af_G_abs.f_abs (Abs ?φ) ?w›*) af_G_letter_abs_def (*‹↑af⇩G ≡ af_G_abs.f_abs›*)) hence "Rep (token_run x n) ≡⇩P af⇩G φ ((suffix x w) [0 → (n - x)])" using "ltl⇩P_abs_rep" (*‹Abs (Rep ?φ) = ?φ›*) ltl_prop_equiv_quotient.abs_eq_iff (*‹(Abs ?x = Abs ?y) = ?x ≡⇩P ?y›*) by auto thus "?thesis" (*goal: ‹Rep (token_run x n) ≡⇩P af⇩G φ (w [x → n])›*) unfolding ltl_prop_equiv_def subsequence_shift (*goal: ‹∀𝒜::'a::type ltl set. 𝒜 ⊨⇩P Rep (token_run (x::nat) (n::nat)) = 𝒜 ⊨⇩P af⇩G (φ::'a::type ltl) (w::nat ⇒ 'a::type set [x → n])›*) apply (cases "x ≤ n") (*goals: 1. ‹⟦∀𝒜::'a ltl set. 𝒜 ⊨⇩P Rep (token_run (x::nat) (n::nat)) = 𝒜 ⊨⇩P af⇩G (φ::'a ltl) (w::nat ⇒ 'a set [x + (0::nat) → x + (n - x)]); x ≤ n⟧ ⟹ ∀𝒜::'a ltl set. 𝒜 ⊨⇩P Rep (token_run x n) = 𝒜 ⊨⇩P af⇩G φ (w [x → n])› 2. ‹⟦∀𝒜::'a ltl set. 𝒜 ⊨⇩P Rep (token_run (x::nat) (n::nat)) = 𝒜 ⊨⇩P af⇩G (φ::'a ltl) (w::nat ⇒ 'a set [x + (0::nat) → x + (n - x)]); ¬ x ≤ n⟧ ⟹ ∀𝒜::'a ltl set. 𝒜 ⊨⇩P Rep (token_run x n) = 𝒜 ⊨⇩P af⇩G φ (w [x → n])› discuss goal 1*) apply (simp add: subsequence_def (*‹?w [?i → ?j] ≡ map ?w [?i..<?j]›*)) (*discuss goal 2*) apply (simp add: subsequence_def (*‹?w [?i → ?j] ≡ map ?w [?i..<?j]›*)) (*proven 2 subgoals*) . qed end locale ltl_FG_to_rabin = ltl_FG_to_rabin_def + assumes wellformed_𝒢: "Only_G 𝒢" assumes bounded_w: "range w ⊆ Σ" assumes finite_Σ: "finite Σ" begin sublocale mojmir_to_rabin Σ "↑af⇩G" "Abs φ" w "{q. 𝒢 ⊨⇩P Rep q}" proof (standard) (*goals: 1. ‹finite Σ› 2. ‹finite (reach Σ ↑af⇩G (Abs φ))› 3. ‹range w ⊆ Σ› 4. ‹⋀q ν. q ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ ↑af⇩G q ν ∈ {q. 𝒢 ⊨⇩P Rep q}›*) show "⋀q ν. q ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ ↑af⇩Gq ν ∈ {q. 𝒢 ⊨⇩P Rep q}" using "wellformed_𝒢" (*‹Only_G 𝒢›*) af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) by auto have "nonempty_Σ": "Σ ≠ {}" using bounded_w (*‹range w ⊆ Σ›*) by blast show "finite (reach Σ ↑af⇩G(Abs φ))" (is "finite ?A") using af_G_abs.finite_abs_reach (*‹finite (af_G_abs.abs_reach (Abs ?φ))›*) finite_subset[where A = ?A, where B = "lift_ltl_transformer.abs_reach af_G_letter (Abs φ)"] (*‹⟦reach Σ ↑af⇩G (Abs φ) ⊆ af_G_abs.abs_reach (Abs φ); finite (af_G_abs.abs_reach (Abs φ))⟧ ⟹ finite (reach Σ ↑af⇩G (Abs φ))›*) unfolding af_G_abs.abs_reach_def af_G_letter_abs_def reach_foldl_def[OF nonempty_Σ] (*goal: ‹finite {foldl af_G_abs.f_abs (Abs (φ::'a ltl)) w |w::'a set list. set w ⊆ (Σ::'a set set)}›*) by blast qed (insert finite_Σ (*‹finite Σ›*) bounded_w (*‹range w ⊆ Σ›*)) (*solves the remaining goals: 1. ‹finite Σ› 2. ‹range w ⊆ Σ›*) lemma ltl_to_rabin_correct_exposed': "𝔓⇩∞ φ 𝒢 w ⟷ accept" proof (-) (*goal: ‹𝔓⇩∞ φ 𝒢 w = accept⇩R'›*) { fix i have "(∃j. 𝒢 ⊨⇩P af⇩G φ (map w [i + 0..<i + (j - i)])) = 𝔓 φ 𝒢 w i" apply (auto simp add: subsequence_def (*‹?w::nat ⇒ ?'a::type [?i::nat → ?j::nat] ≡ map ?w [?i..<?j]›*)) (*goal: ‹(∃j. 𝒢 ⊨⇩P af⇩G φ (map w [i + 0..<i + (j - i)])) = 𝔓 φ 𝒢 w i›*) by (metis add_diff_cancel_left' (*‹?a + ?b - ?a = ?b›*) le_Suc_ex (*‹?k ≤ ?l ⟹ ∃n. ?l = ?k + n›*) nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*) upt_conv_Nil (*‹?j ≤ ?i ⟹ [?i..<?j] = []›*)) hence "(∃j. 𝒢 ⊨⇩P af⇩G φ (w [i → j])) ⟷ (∃j. 𝒢 ⊨⇩P run af_G_letter φ (suffix i w) (j-i))" (is "?l ⟷ _") unfolding run_foldl (*goal: ‹𝔓 φ 𝒢 w i = (∃j. 𝒢 ⊨⇩P af⇩G φ (map (suffix i w) [0..<j - i]))›*) using subsequence_shift (*‹suffix ?i ?w [?j → ?k] = ?w [?i + ?j → ?i + ?k]›*) subsequence_def (*‹?w [?i → ?j] ≡ map ?w [?i..<?j]›*) by metis also (*calculation: ‹𝔓 φ 𝒢 w i = (∃j. 𝒢 ⊨⇩P run af_G_letter φ (suffix i w) (j - i))›*) have "… ⟷ (∃j. 𝒢 ⊨⇩P Rep (run ↑af⇩G(Abs φ) (suffix i w) (j-i)))" using Quotient3_ltl_prop_equiv_quotient[THEN Quotient3_rep_abs] (*‹(?r::?'a1 ltl) ≡⇩P ?r ⟹ Rep (Abs ?r) ≡⇩P ?r›*) unfolding ltl_prop_equiv_def run_af_G_letter_abs_eq_Abs_af_G_letter (*goal: ‹(∃j. 𝒢 ⊨⇩P run af_G_letter φ (suffix i w) (j - i)) = (∃j. 𝒢 ⊨⇩P Rep (Abs (run af_G_letter φ (suffix i w) (j - i))))›*) by blast also (*calculation: ‹𝔓 (φ::'a::type ltl) (𝒢::'a::type ltl set) (w::nat ⇒ 'a::type set) (i::nat) = (∃j::nat. 𝒢 ⊨⇩P Rep (run ↑af⇩G (Abs φ) (suffix i w) (j - i)))›*) have "… ⟷ (∃j. token_run i j ∈ {q. 𝒢 ⊨⇩P Rep q})" by simp also (*calculation: ‹𝔓 φ 𝒢 w i = (∃j. token_run i j ∈ {q. 𝒢 ⊨⇩P Rep q})›*) have "… ⟷ token_succeeds i" (is "_ ⟷ ?r") unfolding token_succeeds_def (*goal: ‹(∃j. token_run i j ∈ {q. 𝒢 ⊨⇩P Rep q}) = (∃n. token_run i n ∈ {q. 𝒢 ⊨⇩P Rep q})›*) by auto finally (*calculation: ‹𝔓 φ 𝒢 w i = token_succeeds i›*) have "?l ⟷ ?r" . } thus "?thesis" (*goal: ‹𝔓⇩∞ φ 𝒢 w = accept⇩R'›*) by (simp only: almost_all_eventually_provable_def (*‹𝔓⇩∞ ?φ ?𝒢 ?w ≡ ∀⇩∞i. 𝔓 ?φ ?𝒢 ?w i›*) accept_def (*‹accept⇩R' = Alm_all token_succeeds›*)) qed lemma ltl_to_rabin_correct_exposed: "𝔓⇩∞ φ 𝒢 w ⟷ accept⇩R (δ⇩R, q⇩R, {Acc⇩R i | i. i < max_rank⇩R}) w" unfolding ltl_to_rabin_correct_exposed' mojmir_accept_iff_rabin_accept (*goal: ‹accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w = accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R i, succeed⇩R i) |i. i < max_rank⇩R}) w›*) by standard<close> lemmas max_rank_lowerbound = max_rank_lowerbound lemmas state_rank_step_foldl = state_rank_step_foldl lemmas smallest_accepting_rank_properties = smallest_accepting_rank_properties lemmas wellformed_ℛ = wellformed_ℛ end fun ltl_to_rabin where "ltl_to_rabin Σ φ 𝒢 = (ltl_FG_to_rabin_def.δ⇩R Σ φ, ltl_FG_to_rabin_def.q⇩R φ, {ltl_FG_to_rabin_def.Acc⇩R Σ φ 𝒢 i | i. i < ltl_FG_to_rabin_def.max_rank⇩R Σ φ})" context fixes Σ :: "'a set set" assumes finite_Σ: "finite Σ" begin lemma ltl_to_rabin_correct: assumes "range w ⊆ Σ" shows "w ⊨ F G φ = (∃𝒢 ⊆ ❙G (G φ). G φ ∈ 𝒢 ∧ (∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w))" proof (-) (*goal: ‹w ⊨ F G φ = (∃𝒢⊆❙G (G φ). G φ ∈ 𝒢 ∧ (∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w))›*) have "⋀𝒢 ψ. 𝒢 ⊆ ❙G (G φ) ⟹ G ψ ∈ 𝒢 ⟹ (𝔓⇩∞ ψ 𝒢 w ⟷ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w)" proof (-) (*goal: ‹⋀𝒢 ψ. ⟦𝒢 ⊆ ❙G (G φ); G ψ ∈ 𝒢⟧ ⟹ 𝔓⇩∞ ψ 𝒢 w = accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›*) fix 𝒢 and ψ assume "𝒢 ⊆ ❙G (G φ)" "G ψ ∈ 𝒢" (*‹(𝒢::'a ltl set) ⊆ ❙G (G (φ::'a ltl))› ‹G (ψ::'a ltl) ∈ (𝒢::'a ltl set)›*) then interpret ltl_FG_to_rabin "Σ" "ψ" "𝒢" using "finite_Σ" (*‹finite Σ›*) assms (*‹range w ⊆ Σ›*) G_nested_propos_alt_def (*‹❙G ?φ = nested_propos ?φ ∩ {ψ. ∃x. ψ = G x}›*) apply - (*goal: ‹ltl_FG_to_rabin (Σ::'a set set) (𝒢::'a ltl set) (w::nat ⇒ 'a set)›*) apply ((unfold_locales)[1]) (*goals: 1. ‹⟦𝒢 ⊆ ❙G (G φ); G ψ ∈ 𝒢; finite Σ; range w ⊆ Σ; ⋀φ. ❙G φ = nested_propos φ ∩ {ψ. ∃x. ψ = G x}⟧ ⟹ Only_G 𝒢› 2. ‹⟦𝒢 ⊆ ❙G (G φ); G ψ ∈ 𝒢; finite Σ; range w ⊆ Σ; ⋀φ. ❙G φ = nested_propos φ ∩ {ψ. ∃x. ψ = G x}⟧ ⟹ range w ⊆ Σ› 3. ‹⟦𝒢 ⊆ ❙G (G φ); G ψ ∈ 𝒢; finite Σ; range w ⊆ Σ; ⋀φ. ❙G φ = nested_propos φ ∩ {ψ. ∃x. ψ = G x}⟧ ⟹ finite Σ› discuss goal 1*) apply ((auto)[1]) (*top goal: ‹⟦𝒢 ⊆ ❙G (G φ); G ψ ∈ 𝒢; finite Σ; range w ⊆ Σ; ⋀φ. ❙G φ = nested_propos φ ∩ {ψ. ∃x. ψ = G x}⟧ ⟹ Only_G 𝒢› and 2 goals remain*) apply ((msorry)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "(𝔓⇩∞ ψ 𝒢 w ⟷ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w)" using ltl_to_rabin_correct_exposed (*‹𝔓⇩∞ ψ 𝒢 w = accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R i, succeed⇩R i) |i. i < max_rank⇩R}) w›*) by simp qed thus "?thesis" (*goal: ‹w ⊨ F G φ = (∃𝒢⊆❙G (G φ). G φ ∈ 𝒢 ∧ (∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w))›*) using "𝒢_elements"[of _ "G φ"] (*‹?𝒢 ⊆ ❙G (G φ) ⟹ Only_G ?𝒢›*) "𝒢_finite"[of _ "G φ"] (*‹?𝒢 ⊆ ❙G (G φ) ⟹ finite ?𝒢›*) unfolding ltl_FG_logical_characterization G_nested_propos.simps (*goal: ‹(∃𝒢⊆❙G φ ∪ {G φ}. G φ ∈ 𝒢 ∧ closed 𝒢 w) = (∃𝒢⊆❙G φ ∪ {G φ}. G φ ∈ 𝒢 ∧ (∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w))›*) by meson qed end subsubsection ‹LTL-to-Mojmir Lemmas› lemma ℱ_eq_𝒮: assumes finite_Σ: "finite Σ" assumes bounded_w: "range w ⊆ Σ" assumes "closed 𝒢 w" assumes "G ψ ∈ 𝒢" shows "∀⇩∞j. (∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) ⟷ (∀q. q ∈ (ltl_FG_to_rabin_def.𝒮⇩R Σ ψ 𝒢 w j) ⟶ S ⊨⇩P Rep q))" proof (-) (*goal: ‹∀⇩∞j. ∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q)›*) let ?F = "{q. 𝒢 ⊨⇩P Rep q}" define k where "k = the (threshold ψ w 𝒢)" hence "threshold ψ w 𝒢 = Some k" using assms (*‹finite Σ› ‹range (w::nat ⇒ 'a::type set) ⊆ (Σ::'a::type set set)› ‹closed 𝒢 w› ‹G ψ ∈ 𝒢›*) unfolding threshold.simps index.simps almost_all_eventually_provable_def (*goal: ‹(if ∀⇩∞j. 𝔓 ψ 𝒢 w j then Some (LEAST i. ∀j≥i. 𝔓 ψ 𝒢 w j) else None) = Some k›*) by simp have "Only_G 𝒢" using assms (*‹finite (Σ::'a::type set set)› ‹range w ⊆ Σ› ‹closed 𝒢 w› ‹G ψ ∈ 𝒢›*) G_nested_propos_alt_def (*‹❙G ?φ = nested_propos ?φ ∩ {ψ. ∃x. ψ = G x}›*) by blast then interpret ltl_FG_to_rabin "Σ" "ψ" "𝒢" w using "finite_Σ" (*‹finite Σ›*) bounded_w (*‹range (w::nat ⇒ 'a set) ⊆ (Σ::'a set set)›*) apply unfold_locales (*goals: 1. ‹⟦Only_G 𝒢; finite Σ; range w ⊆ Σ⟧ ⟹ Only_G 𝒢› 2. ‹⟦Only_G 𝒢; finite Σ; range w ⊆ Σ⟧ ⟹ range w ⊆ Σ› 3. ‹⟦Only_G 𝒢; finite Σ; range w ⊆ Σ⟧ ⟹ finite Σ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have accept using ltl_to_rabin_correct_exposed' (*‹𝔓⇩∞ ψ 𝒢 w = accept⇩R'›*) assms (*‹finite Σ› ‹range w ⊆ Σ› ‹closed 𝒢 w› ‹G ψ ∈ 𝒢›*) by blast then obtain i where "smallest_accepting_rank = Some i" (*goal: ‹(⋀i::nat. smallest_accepting_rank⇩R = Some i ⟹ thesis::bool) ⟹ thesis›*) unfolding smallest_accepting_rank_def (*goal: ‹(⋀i. (if accept⇩R' then Some (LEAST i. finite fail ∧ finite (local.merge i) ∧ infinite (succeed i)) else None) = Some i ⟹ thesis) ⟹ thesis›*) by force obtain n₁ where "⋀m q. m ≥ n₁ ⟹ ((∃x ∈ configuration q m. token_succeeds x) ⟶ q ∈ 𝒮 m) ∧ (q ∈ 𝒮 m ⟶ (∀x ∈ configuration q m. token_succeeds x))" (*goal: ‹(⋀n₁. (⋀m q. n₁ ≤ m ⟹ (Bex (configuration q m) token_succeeds ⟶ q ∈ 𝒮⇩R m) ∧ (q ∈ 𝒮⇩R m ⟶ Ball (configuration q m) token_succeeds)) ⟹ thesis) ⟹ thesis›*) using succeeding_states[OF ‹smallest_accepting_rank = Some i›] (*‹∀⇩∞n. ∀q. (Bex (configuration q n) token_succeeds ⟶ q ∈ 𝒮⇩R n) ∧ (q ∈ 𝒮⇩R n ⟶ Ball (configuration q n) token_succeeds)›*) unfolding MOST_nat_le (*goal: ‹(⋀n₁. (⋀m q. n₁ ≤ m ⟹ (Bex (configuration q m) token_succeeds ⟶ q ∈ 𝒮⇩R m) ∧ (q ∈ 𝒮⇩R m ⟶ Ball (configuration q m) token_succeeds)) ⟹ thesis) ⟹ thesis›*) by blast obtain n₂ where "⋀x. x < k ⟹ token_succeeds x ⟹ token_run x n₂ ∈ ?F" (*goal: ‹(⋀n₂. (⋀x. ⟦x < k; token_succeeds x⟧ ⟹ token_run x n₂ ∈ {q. 𝒢 ⊨⇩P Rep q}) ⟹ thesis) ⟹ thesis›*) apply (induction k) (*goals: 1. ‹(⋀n₂. (⋀x. ⟦x < 0; token_succeeds x⟧ ⟹ token_run x n₂ ∈ {q. 𝒢 ⊨⇩P Rep q}) ⟹ thesis) ⟹ thesis› 2. ‹⋀k. ⟦(⋀n₂. (⋀x. ⟦x < k; token_succeeds x⟧ ⟹ token_run x n₂ ∈ {q. 𝒢 ⊨⇩P Rep q}) ⟹ thesis) ⟹ thesis; ⋀n₂. (⋀x. ⟦x < Suc k; token_succeeds x⟧ ⟹ token_run x n₂ ∈ {q. 𝒢 ⊨⇩P Rep q}) ⟹ thesis⟧ ⟹ thesis› discuss goal 1*) apply simp (*discuss goal 2*) apply (metis token_stays_in_final_states (*‹token_run ?x ?n ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ token_run ?x (?n + ?m) ∈ {q. 𝒢 ⊨⇩P Rep q}›*) add.commute (*‹?a + ?b = ?b + ?a›*) le_neq_implies_less (*‹⟦?m ≤ ?n; ?m ≠ ?n⟧ ⟹ ?m < ?n›*) not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) not_less_eq (*‹(¬ ?m < ?n) = (?n < Suc ?m)›*) token_succeeds_def (*‹token_succeeds ?x = (∃n. token_run ?x n ∈ {q. 𝒢 ⊨⇩P Rep q})›*)) (*proven 2 subgoals*) . define n where "n = Max {n₁, n₂, k}" { fix m and q assume "n ≤ m" (*‹(n::nat) ≤ (m::nat)›*) hence "n₁ ≤ m" unfolding n_def (*goal: ‹n₁ ≤ m›*) by simp hence "((∃x ∈ configuration q m. token_succeeds x) ⟶ q ∈ 𝒮 m) ∧ (q ∈ 𝒮 m ⟶ (∀x ∈ configuration q m. token_succeeds x))" using ‹⋀m q. m ≥ n₁ ⟹ ((∃x ∈ configuration q m. token_succeeds x) ⟶ q ∈ 𝒮 m) ∧ (q ∈ 𝒮 m ⟶ (∀x ∈ configuration q m. token_succeeds x))› (*‹n₁ ≤ ?m ⟹ (Bex (configuration ?q ?m) token_succeeds ⟶ ?q ∈ 𝒮⇩R ?m) ∧ (?q ∈ 𝒮⇩R ?m ⟶ Ball (configuration ?q ?m) token_succeeds)›*) by blast } hence n_def_1: "⋀m q. m ≥ n ⟹ ((∃x ∈ configuration q m. token_succeeds x) ⟶ q ∈ 𝒮 m) ∧ (q ∈ 𝒮 m ⟶ (∀x ∈ configuration q m. token_succeeds x))" by presburger have n_def_2: "⋀x m. x < k ⟹ m ≥ n ⟹ token_succeeds x ⟹ token_run x m ∈ ?F" using ‹⋀x. x < k ⟹ token_succeeds x ⟹ token_run x n₂ ∈ ?F› (*‹⟦?x < k; token_succeeds ?x⟧ ⟹ token_run ?x n₂ ∈ {q. 𝒢 ⊨⇩P Rep q}›*) Max.coboundedI[of "{n₁, n₂, k}"] (*‹⟦finite {n₁::nat, n₂::nat, k::nat}; (?a::nat) ∈ {n₁, n₂, k}⟧ ⟹ ?a ≤ Max {n₁, n₂, k}›*) using token_stays_in_final_states[of _ n₂] (*‹token_run ?x n₂ ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ token_run ?x (n₂ + ?m) ∈ {q. 𝒢 ⊨⇩P Rep q}›*) le_Suc_ex (*‹?k ≤ ?l ⟹ ∃n. ?l = ?k + n›*) unfolding n_def (*goal: ‹⋀x m. ⟦x < k; Max {n₁, n₂, k} ≤ m; token_succeeds x⟧ ⟹ token_run x m ∈ {q. 𝒢 ⊨⇩P Rep q}›*) by force { fix S and m assume "n ≤ m" (*‹(n::nat) ≤ (m::nat)›*) hence "k ≤ m" "n ≤ Suc m" using n_def (*‹n = Max {n₁, n₂, k}›*) apply - (*goals: 1. ‹⟦(n::nat) ≤ (m::nat); n = Max {n₁::nat, n₂::nat, k::nat}⟧ ⟹ k ≤ m› 2. ‹⟦(n::nat) ≤ (m::nat); n = Max {n₁::nat, n₂::nat, k::nat}⟧ ⟹ n ≤ Suc m› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . { assume "S ⊨⇩P ℱ ψ w 𝒢 m" "𝒢 ⊆ S" (*‹(S::'a ltl set) ⊨⇩P ℱ (ψ::'a ltl) (w::nat ⇒ 'a set) (𝒢::'a ltl set) (m::nat)› ‹(𝒢::'a ltl set) ⊆ (S::'a ltl set)›*) hence "⋀x. k ≤ x ⟹ x ≤ Suc m ⟹ S ⊨⇩P af⇩G ψ (w [x → m])" unfolding And_prop_entailment "ℱ_def" k_def[symmetric] subsequence_def (*goal: ‹⋀x. ⟦k ≤ x; x ≤ Suc m⟧ ⟹ S ⊨⇩P af⇩G ψ (map w [x..<m])›*) using ‹k ≤ m› (*‹k ≤ m›*) by auto fix q assume "q ∈ 𝒮 m" (*‹(q::'a ltl_prop_equiv_quotient) ∈ 𝒮⇩R (m::nat)›*) have "S ⊨⇩P Rep q" proof (cases "q ∈ ?F") (*goals: 1. ‹q ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ S ⊨⇩P Rep q› 2. ‹q ∉ {q. 𝒢 ⊨⇩P Rep q} ⟹ S ⊨⇩P Rep q›*) case False (*‹q ∉ {q. 𝒢 ⊨⇩P Rep q}›*) moreover from False (*‹(q::'a ltl_prop_equiv_quotient) ∉ {q::'a ltl_prop_equiv_quotient. (𝒢::'a ltl set) ⊨⇩P Rep q}›*) obtain j where "state_rank q m = Some j" and "j ≥ i" (*goal: ‹(⋀j::nat. ⟦state_rank (q::'a ltl_prop_equiv_quotient) (m::nat) = Some j; (i::nat) ≤ j⟧ ⟹ thesis::bool) ⟹ thesis›*) using ‹q ∈ 𝒮 m› (*‹q ∈ 𝒮⇩R m›*) ‹smallest_accepting_rank = Some i› (*‹smallest_accepting_rank⇩R = Some i›*) by force then obtain x where x: "x ∈ configuration q m" "token_run x m = q" (*goal: ‹(⋀x. ⟦x ∈ configuration q m; token_run x m = q⟧ ⟹ thesis) ⟹ thesis›*) by force moreover from x (*‹x ∈ configuration q m› ‹token_run x m = q›*) have "token_succeeds x" using n_def_1[OF ‹n ≤ m›] (*‹(Bex (configuration ?q m) token_succeeds ⟶ ?q ∈ 𝒮⇩R m) ∧ (?q ∈ 𝒮⇩R m ⟶ Ball (configuration ?q m) token_succeeds)›*) ‹q ∈ 𝒮 m› (*‹q ∈ 𝒮⇩R m›*) by blast ultimately have "S ⊨⇩P af⇩G ψ (w [x → m])" using ‹⋀x. k ≤ x ⟹ x ≤ Suc m ⟹ S ⊨⇩P af⇩G ψ (w [x → m])›[of x] (*‹⟦k ≤ x; x ≤ Suc m⟧ ⟹ S ⊨⇩P af⇩G ψ (w [x → m])›*) n_def_2[OF _ ‹n ≤ m›] (*‹⟦?x < k; token_succeeds ?x⟧ ⟹ token_run ?x m ∈ {q. 𝒢 ⊨⇩P Rep q}›*) by fastforce thus "?thesis" (*goal: ‹S ⊨⇩P Rep q›*) using Rep_token_run_af (*‹Rep (token_run ?x ?n) ≡⇩P af⇩G ψ (w [?x → ?n])›*) unfolding ‹token_run x m = q›[symmetric] ltl_prop_equiv_def (*goal: ‹S ⊨⇩P Rep (token_run x m)›*) by simp qed (insert ‹𝒢 ⊆ S›, blast) (*solved the remaining goal: ‹q ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ S ⊨⇩P Rep q›*) } moreover { assume "⋀q. q ∈ 𝒮 m ⟹ S ⊨⇩P Rep q" (*‹(?q::'a ltl_prop_equiv_quotient) ∈ 𝒮⇩R (m::nat) ⟹ (S::'a ltl set) ⊨⇩P Rep ?q›*) hence "⋀q. q ∈ ?F ⟹ S ⊨⇩P Rep q" by simp have "𝒢 ⊆ S" proof (standard) (*goal: ‹⋀x. x ∈ 𝒢 ⟹ x ∈ S›*) fix x assume "x ∈ 𝒢" (*‹(x::'a ltl) ∈ (𝒢::'a ltl set)›*) with ‹Only_G 𝒢› (*‹Only_G 𝒢›*) show "x ∈ S" using ‹⋀q. q ∈ ?F ⟹ S ⊨⇩P Rep q›[of "Abs x"] (*‹Abs x ∈ {q. 𝒢 ⊨⇩P Rep q} ⟹ S ⊨⇩P Rep (Abs x)›*) by auto qed { fix x assume "k ≤ x" "x ≤ m" (*‹(k::nat) ≤ (x::nat)› ‹(x::nat) ≤ (m::nat)›*) define q where "q = token_run x m" hence "token_succeeds x" using threshold_properties[OF ‹threshold ψ w 𝒢 = Some k›] (*‹0 < k ⟹ ¬ 𝒢 ⊨⇩P af⇩G ψ (w [k - 1 → ?k])› ‹k ≤ ?j ⟹ 𝔓 ψ 𝒢 w ?j›*) ‹x ≥ k› (*‹(k::nat) ≤ (x::nat)›*) Rep_token_run_af (*‹Rep (token_run ?x ?n) ≡⇩P af⇩G ψ (w [?x → ?n])›*) unfolding token_succeeds_def ltl_prop_equiv_def (*goal: ‹∃n. token_run x n ∈ {q. 𝒢 ⊨⇩P Rep q}›*) by blast hence "q ∈ 𝒮 m" using n_def_1[OF ‹n ≤ m›, of q] (*‹(Bex (configuration q m) token_succeeds ⟶ q ∈ 𝒮⇩R m) ∧ (q ∈ 𝒮⇩R m ⟶ Ball (configuration q m) token_succeeds)›*) ‹x ≤ m› (*‹x ≤ m›*) unfolding q_def configuration.simps (*goal: ‹token_run x m ∈ 𝒮⇩R m›*) by blast hence "S ⊨⇩P Rep q" by (rule ‹⋀q. q ∈ 𝒮 m ⟹ S ⊨⇩P Rep q›) hence "S ⊨⇩P af⇩G ψ (w [x → m])" using Rep_token_run_af (*‹Rep (token_run ?x ?n) ≡⇩P af⇩G ψ (w [?x → ?n])›*) unfolding q_def ltl_prop_equiv_def (*goal: ‹S ⊨⇩P af⇩G ψ (w [x → m])›*) by simp } hence "∀x ∈ (set (map (λi. af⇩G ψ (w [i → m])) [k..<Suc m])). S ⊨⇩P x" unfolding set_map set_upt (*goal: ‹∀x::'a::type ltl∈(λi::nat. af⇩G (ψ::'a::type ltl) (w::nat ⇒ 'a::type set [i → m::nat])) ` {k::nat..<Suc m}. (S::'a::type ltl set) ⊨⇩P x›*) by fastforce hence "S ⊨⇩P ℱ ψ w 𝒢 m" and "𝒢 ⊆ S" unfolding "ℱ_def" And_prop_entailment[of S] k_def[symmetric] (*goals: 1. ‹Ball (set (map (λi::nat. af⇩G (ψ::'a ltl) (w::nat ⇒ 'a set [i → m::nat])) [k::nat..<Suc m])) ((⊨⇩P) (S::'a ltl set))› 2. ‹(𝒢::'a ltl set) ⊆ (S::'a ltl set)›*) using ‹k ≤ m› (*‹(k::nat) ≤ (m::nat)›*) ‹𝒢 ⊆ S› (*‹(𝒢::'a::type ltl set) ⊆ (S::'a::type ltl set)›*) apply - (*goals: 1. ‹⟦∀x∈set (map (λi. af⇩G ψ (w [i → m])) [k..<Suc m]). S ⊨⇩P x; k ≤ m; 𝒢 ⊆ S⟧ ⟹ Ball (set (map (λi. af⇩G ψ (w [i → m])) [k..<Suc m])) ((⊨⇩P) S)› 2. ‹⟦∀x∈set (map (λi. af⇩G ψ (w [i → m])) [k..<Suc m]). S ⊨⇩P x; k ≤ m; 𝒢 ⊆ S⟧ ⟹ 𝒢 ⊆ S› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . } ultimately have "(S ⊨⇩P ℱ ψ w 𝒢 m ∧ 𝒢 ⊆ S) ⟷ (∀q. q ∈ 𝒮 m ⟶ S ⊨⇩P Rep q)" by blast } thus "?thesis" (*goal: ‹∀⇩∞j. ∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ 𝒮⇩R j ⟶ S ⊨⇩P Rep q)›*) unfolding MOST_nat_le (*goal: ‹∃m::nat. ∀n≥m. ∀S::'a ltl set. (S ⊨⇩P ℱ (ψ::'a ltl) (w::nat ⇒ 'a set) (𝒢::'a ltl set) n ∧ 𝒢 ⊆ S) = (∀q::'a ltl_prop_equiv_quotient. q ∈ 𝒮⇩R n ⟶ S ⊨⇩P Rep q)›*) by blast qed lemma ℱ_eq_𝒮_generalized: assumes finite_Σ: "finite Σ" assumes bounded_w: "range w ⊆ Σ" assumes "closed 𝒢 w" shows "∀⇩∞j. ∀ψ. G ψ ∈ 𝒢 ⟶ (∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) ⟷ (∀q. q ∈ (ltl_FG_to_rabin_def.𝒮⇩R Σ ψ 𝒢) w j ⟶ S ⊨⇩P Rep q))" proof (-) (*goal: ‹∀⇩∞j. ∀ψ. G ψ ∈ 𝒢 ⟶ (∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q))›*) have "Only_G 𝒢" and "finite 𝒢" using assms (*‹finite Σ› ‹range w ⊆ Σ› ‹closed 𝒢 w›*) apply - (*goals: 1. ‹⟦finite Σ; range w ⊆ Σ; closed 𝒢 w⟧ ⟹ Only_G 𝒢› 2. ‹⟦finite Σ; range w ⊆ Σ; closed 𝒢 w⟧ ⟹ finite 𝒢› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . show "?thesis" (*goal: ‹∀⇩∞j. ∀ψ. G ψ ∈ 𝒢 ⟶ (∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q))›*) using almost_all_commutative''[OF ‹finite 𝒢› ‹Only_G 𝒢›] (*‹(⋀x. G x ∈ 𝒢 ⟹ ∀⇩∞i. ?P x i) ⟹ ∀⇩∞i. ∀x. G x ∈ 𝒢 ⟶ ?P x i›*) "ℱ_eq_𝒮"[OF assms] (*‹G ?ψ ∈ 𝒢 ⟹ ∀⇩∞j. ∀S. (S ⊨⇩P ℱ ?ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ?ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q)›*) by simp qed subsection ‹Product of Secondary Automata› context fixes Σ :: "'a set set" begin fun product_initial_state :: "'a set ⇒ ('a ⇒ 'b) ⇒ ('a ⇀ 'b)" ("ι⇩×") where "ι⇩× K q⇩m = (λk. if k ∈ K then Some (q⇩m k) else None)" fun combine_pairs :: "(('a, 'b) transition set × ('a, 'b) transition set) set ⇒ (('a, 'b) transition set × ('a, 'b) transition set set)" where "combine_pairs P = (⋃(fst ` P), snd ` P)" fun combine_pairs' :: "(('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option, 'a set) transition set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option, 'a set) transition set) set ⇒ (('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option, 'a set) transition set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option, 'a set) transition set set)" where "combine_pairs' P = (⋃(fst ` P), snd ` P)" lemma combine_pairs_prop: "(∀P ∈ 𝒫. accepting_pair⇩R δ q₀ P w) = accepting_pair⇩G⇩R δ q₀ (combine_pairs 𝒫) w" by auto lemma combine_pairs2: "combine_pairs 𝒫 ∈ α ⟹ (⋀P. P ∈ 𝒫 ⟹ accepting_pair⇩R δ q₀ P w ) ⟹ accept⇩G⇩R (δ, q₀, α) w" using combine_pairs_prop[of 𝒫 δ q₀ w] (*‹(∀P∈𝒫. accepting_pair⇩R δ q₀ P w) = accepting_pair⇩G⇩R δ q₀ (local.combine_pairs 𝒫) w›*) by fastforce lemma combine_pairs'_prop: "(∀P ∈ 𝒫. accepting_pair⇩R δ q₀ P w) = accepting_pair⇩G⇩R δ q₀ (combine_pairs' 𝒫) w" by auto fun ltl_FG_to_generalized_rabin :: "'a ltl ⇒ ('a ltl ⇀ 'a ltl⇩P ⇀ nat, 'a set) generalized_rabin_automaton" ("𝒫") where "ltl_FG_to_generalized_rabin φ = ( Δ⇩× (λχ. ltl_FG_to_rabin_def.δ⇩R Σ (theG χ)), ι⇩× (❙G (G φ)) (λχ. ltl_FG_to_rabin_def.q⇩R (theG χ)), {combine_pairs' {embed_pair χ (ltl_FG_to_rabin_def.Acc⇩R Σ (theG χ) 𝒢 (π χ)) | χ. χ ∈ 𝒢} | 𝒢 π. 𝒢 ⊆ ❙G (G φ) ∧ G φ ∈ 𝒢 ∧ (∀χ. π χ < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ))})" context assumes finite_Σ: "finite Σ" begin lemma ltl_FG_to_generalized_rabin_wellformed: "finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))" proof (cases "Σ = {}") (*goals: 1. ‹Σ = {} ⟹ finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))› 2. ‹Σ ≠ {} ⟹ finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))›*) case False (*‹Σ ≠ {}›*) have "finite (reach Σ (Δ⇩× (λχ. ltl_FG_to_rabin_def.δ⇩R Σ (theG χ))) (fst (snd (𝒫 φ))))" proof (rule finite_reach_product (*‹⟦finite (dom ?ι⇩m); ⋀x. x ∈ dom ?ι⇩m ⟹ finite (reach ?Σ (?δ⇩m x) (the (?ι⇩m x)))⟧ ⟹ finite (reach ?Σ (Δ⇩× ?δ⇩m) ?ι⇩m)›*), goal_cases) (*goals: 1. ‹finite (dom (fst (snd (𝒫 φ))))› 2. ‹⋀x. x ∈ dom (fst (snd (𝒫 φ))) ⟹ finite (reach Σ (semi_mojmir_def.step Σ ↑af⇩G (Abs (theG x))) (the (fst (snd (𝒫 φ)) x)))›*) case 1 (*no hyothesis introduced yet*) show "?case" (*goal: ‹finite (dom (fst (snd (𝒫 φ))))›*) using G_nested_finite(1) (*‹finite (❙G (?φ::?'a ltl))›*) by (auto simp add: dom_def (*‹dom ?m = {a. ?m a ≠ None}›*) LTL_Rabin.product_initial_state.simps (*‹ι⇩× ?K ?q⇩m = (λk. if k ∈ ?K then Some (?q⇩m k) else None)›*)) next (*goal: ‹⋀x::'a ltl. x ∈ dom (fst (snd (𝒫 (φ::'a ltl)))) ⟹ finite (reach (Σ::'a set set) (semi_mojmir_def.step Σ ↑af⇩G (Abs (theG x))) (the (fst (snd (𝒫 φ)) x)))›*) case (2 x) (*‹x ∈ dom (fst (snd (𝒫 φ)))›*) hence "the (fst (snd (𝒫 φ)) x) = ltl_FG_to_rabin_def.q⇩R (theG x)" by (auto simp add: LTL_Rabin.product_initial_state.simps (*‹ι⇩× (?K::?'a::type set) (?q⇩m::?'a::type ⇒ ?'b::type) = (λk::?'a::type. if k ∈ ?K then Some (?q⇩m k) else None)›*)) thus "?case" (*goal: ‹finite (reach (Σ::'a set set) (semi_mojmir_def.step Σ ↑af⇩G (Abs (theG (x::'a ltl)))) (the (fst (snd (𝒫 (φ::'a ltl))) x)))›*) using "ltl_FG_to_rabin.wellformed_ℛ"[unfolded ltl_FG_to_rabin_def, of "{}" _ Σ "theG x"] (*‹Only_G {} ∧ range (?w::nat ⇒ 'a set) ⊆ (Σ::'a set set) ∧ finite Σ ⟹ finite (reach Σ (semi_mojmir_def.step Σ ↑af⇩G (Abs (theG (x::'a ltl)))) (semi_mojmir_def.initial (Abs (theG x))))›*) "finite_Σ" (*‹finite Σ›*) False (*‹Σ ≠ {}›*) by fastforce qed thus "?thesis" (*goal: ‹finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))›*) by fastforce qed (simp add: reach_def (*‹reach ?Σ ?δ ?q₀ = {run ?δ ?q₀ w n |w n. range w ⊆ ?Σ}›*)) (*solved the remaining goal: ‹Σ = {} ⟹ finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))›*) theorem ltl_FG_to_generalized_rabin_correct: assumes "range w ⊆ Σ" shows "w ⊨ F G φ = accept⇩G⇩R (𝒫 φ) w" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹(w::nat ⇒ 'a set) ⊨ F G (φ::'a ltl) ⟹ accept⇩G⇩R (𝒫 φ) w› 2. ‹accept⇩G⇩R (𝒫 (φ::'a ltl)) (w::nat ⇒ 'a set) ⟹ w ⊨ F G φ›*) define r where "r = run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w" have [intro]: "⋀i. w i ∈ Σ" and "Σ ≠ {}" using assms (*‹range w ⊆ Σ›*) apply - (*goals: 1. ‹⋀i. range w ⊆ Σ ⟹ w i ∈ Σ› 2. ‹range w ⊆ Σ ⟹ Σ ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . { let ?S = "(reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))) ) × Σ × (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))" have "⋀n. r n ∈ ?S" unfolding "run⇩t.simps" run_foldl reach_foldl_def[OF ‹Σ ≠ {}›] r_def (*goal: ‹⋀n::nat. (foldl (fst (𝒫 (φ::'a::type ltl))) (fst (snd (𝒫 φ))) (map (w::nat ⇒ 'a::type set) [0::nat..<n]), w n, foldl (fst (𝒫 φ)) (fst (snd (𝒫 φ))) (map w [0::nat..<Suc n])) ∈ {foldl (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w |w::'a::type set list. set w ⊆ (Σ::'a::type set set)} × Σ × {foldl (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w |w::'a::type set list. set w ⊆ Σ}›*) by fastforce hence "range r ⊆ ?S" and "finite ?S" using ltl_FG_to_generalized_rabin_wellformed (*‹finite (reach (Σ::'a set set) (fst (𝒫 (?φ::'a ltl))) (fst (snd (𝒫 ?φ))))›*) assms (*‹range w ⊆ Σ›*) ‹finite Σ› (*‹finite Σ›*) apply - (*goals: 1. ‹⟦⋀n. r n ∈ reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))) × Σ × reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))); ⋀φ. finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ)))); range w ⊆ Σ; finite Σ⟧ ⟹ range r ⊆ reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))) × Σ × reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ)))› 2. ‹⟦⋀n. r n ∈ reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))) × Σ × reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))); ⋀φ. finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ)))); range w ⊆ Σ; finite Σ⟧ ⟹ finite (reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))) × Σ × reach Σ (fst (𝒫 φ)) (fst (snd (𝒫 φ))))› discuss goal 1*) apply blast (*discuss goal 2*) apply fast (*proven 2 subgoals*) . } hence "finite (range r)" by (blast dest: finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*)) { assume "?lhs" (*‹(w::nat ⇒ 'a set) ⊨ F G (φ::'a ltl)›*) then obtain 𝒢 where "𝒢 ⊆ ❙G (G φ)" and "G φ ∈ 𝒢" and "∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w" (*goal: ‹(⋀𝒢. ⟦𝒢 ⊆ ❙G (G φ); G φ ∈ 𝒢; ∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w⟧ ⟹ thesis) ⟹ thesis›*) unfolding ltl_to_rabin_correct[OF ‹finite Σ› ‹range w ⊆ Σ›] (*goal: ‹(⋀𝒢. ⟦𝒢 ⊆ ❙G (G φ); G φ ∈ 𝒢; ∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w⟧ ⟹ thesis) ⟹ thesis›*) unfolding ltl_to_rabin.simps (*goal: ‹(⋀𝒢::'a ltl set. ⟦𝒢 ⊆ ❙G (G (φ::'a ltl)); G φ ∈ 𝒢; ∀ψ::'a ltl. G ψ ∈ 𝒢 ⟶ accept⇩R (semi_mojmir_def.step (Σ::'a set set) ↑af⇩G (Abs ψ), semi_mojmir_def.initial (Abs ψ), {(mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs ψ) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs ψ) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} i, mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs ψ) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} i) |i::nat. i < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs ψ)}) (w::nat ⇒ 'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto note "𝒢_properties"[OF ‹𝒢 ⊆ ❙G (G φ)›] (*‹finite 𝒢› ‹Only_G 𝒢›*) hence "ltl_FG_to_rabin Σ 𝒢 w" using ‹finite Σ› (*‹finite Σ›*) ‹range w ⊆ Σ› (*‹range w ⊆ Σ›*) unfolding ltl_FG_to_rabin_def (*goal: ‹Only_G 𝒢 ∧ range w ⊆ Σ ∧ finite Σ›*) by auto define π where "π ψ = (if ψ ∈ 𝒢 then the (ltl_FG_to_rabin_def.smallest_accepting_rank⇩R Σ (theG ψ) 𝒢 w) else 0)" for ψ let ?P' = "{❙↿⇩χ (ltl_FG_to_rabin_def.Acc⇩R Σ (theG χ) 𝒢 (π χ)) | χ. χ ∈ 𝒢}" have "∀P ∈ ?P'. accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w" proof (standard) (*goal: ‹⋀P. P ∈ {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ)) |χ. χ ∈ 𝒢} ⟹ accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w›*) fix P assume "P ∈ ?P'" (*‹(P::(('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) ∈ {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R (Σ::'a set set) ↑af⇩G (Abs (theG χ)) {q::'a ltl_prop_equiv_quotient. (𝒢::'a ltl set) ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} ((π::'a ltl ⇒ nat) χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} (π χ)) |χ::'a ltl. χ ∈ 𝒢}›*) then obtain χ where P_def: "P = ❙↿⇩χ (ltl_FG_to_rabin_def.Acc⇩R Σ (theG χ) 𝒢 (π χ))" and "χ ∈ 𝒢" (*goal: ‹(⋀χ. ⟦P = ❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ)); χ ∈ 𝒢⟧ ⟹ thesis) ⟹ thesis›*) by blast hence "∃χ'. χ = G χ'" using ‹𝒢 ⊆ ❙G (G φ)› (*‹𝒢 ⊆ ❙G (G φ)›*) G_nested_propos_alt_def (*‹❙G ?φ = nested_propos ?φ ∩ {ψ. ∃x. ψ = G x}›*) by auto interpret ltl_FG_to_rabin "Σ" "theG χ" "𝒢" w by (insert ‹ltl_FG_to_rabin Σ 𝒢 w›) define r⇩χ where "r⇩χ = run⇩t δ⇩ℛ q⇩ℛ w" moreover have accept and "accept⇩R (δ⇩ℛ, q⇩ℛ, {Acc⇩ℛ j | j. j < max_rank}) w" using ‹χ ∈ 𝒢› (*‹χ ∈ 𝒢›*) ‹∃χ'. χ = G χ'› (*‹∃χ'. χ = G χ'›*) ‹∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w› (*‹∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›*) using mojmir_accept_iff_rabin_accept (*‹accept⇩R' = accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w›*) apply - (*goals: 1. ‹⟦χ ∈ 𝒢; ∃χ'. χ = G χ'; ∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w; accept⇩R' = accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w⟧ ⟹ accept⇩R'› 2. ‹⟦χ ∈ 𝒢; ∃χ'. χ = G χ'; ∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w; accept⇩R' = accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w⟧ ⟹ accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "smallest_accepting_rank⇩ℛ = Some (π χ)" unfolding "π_def" smallest_accepting_rank_def Mojmir_rabin_smallest_accepting_rank[symmetric] (*goal: ‹(if accept⇩R' then Some (LEAST i. finite fail ∧ finite (local.merge i) ∧ infinite (succeed i)) else None) = Some (if χ ∈ 𝒢 then the (if accept⇩R' then Some (LEAST i. finite fail ∧ finite (local.merge i) ∧ infinite (succeed i)) else None) else 0)›*) using ‹χ ∈ 𝒢› (*‹χ ∈ 𝒢›*) by simp hence "accepting_pair⇩R δ⇩ℛ q⇩ℛ (Acc⇩ℛ (π χ)) w" using ‹accept⇩R (δ⇩ℛ, q⇩ℛ, {Acc⇩ℛ j | j. j < max_rank}) w› (*‹accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j::nat. j < max_rank⇩R}) (w::nat ⇒ 'a set)›*) LeastI[of "λi. accepting_pair⇩R δ⇩ℛ q⇩ℛ (Acc⇩ℛ i) w"] (*‹accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R (?k::nat), succeed⇩R ?k) (w::nat ⇒ 'a::type set) ⟹ accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R (LEAST x::nat. accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R x, succeed⇩R x) w), succeed⇩R (LEAST x::nat. accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R x, succeed⇩R x) w)) w›*) by (auto simp add: smallest_accepting_rank⇩ℛ_def (*‹smallest_accepting_rank⇩ℛ ≡ if accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w then Some (LEAST i. accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R i, succeed⇩R i) w) else None›*)) ultimately have "limit r⇩χ ∩ fst (Acc⇩ℛ (π χ)) = {}" and "limit r⇩χ ∩ snd (Acc⇩ℛ (π χ)) ≠ {}" apply - (*goals: 1. ‹⟦r⇩χ = run⇩t δ⇩R q⇩R w; accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) w⟧ ⟹ limit r⇩χ ∩ fst (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) = {}› 2. ‹⟦r⇩χ = run⇩t δ⇩R q⇩R w; accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) w⟧ ⟹ limit r⇩χ ∩ snd (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) ≠ {}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover have 1: "(ι⇩× (❙G (G φ)) (λχ. ltl_FG_to_rabin_def.q⇩R (theG χ))) χ = Some q⇩ℛ" using ‹χ ∈ 𝒢› (*‹(χ::'a::type ltl) ∈ (𝒢::'a::type ltl set)›*) ‹𝒢 ⊆ ❙G (G φ)› (*‹𝒢 ⊆ ❙G (G φ)›*) by (simp add: LTL_Rabin.product_initial_state.simps (*‹ι⇩× ?K ?q⇩m = (λk. if k ∈ ?K then Some (?q⇩m k) else None)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) have 2: "finite (range (run⇩t (Δ⇩× (λχ. ltl_FG_to_rabin_def.δ⇩R Σ (theG χ))) (ι⇩× (❙G (G φ)) (λχ. ltl_FG_to_rabin_def.q⇩R (theG χ))) w))" using ‹finite (range r)›[unfolded r_def] (*‹finite (range (run⇩t (fst (𝒫 (φ::'a ltl))) (fst (snd (𝒫 φ))) (w::nat ⇒ 'a set)))›*) by simp ultimately have "limit r ∩ fst P = {}" and "limit r ∩ snd P ≠ {}" using product_run_embed_limit_finiteness[OF 1 2] (*‹(limit (run⇩t (Δ⇩× (λχ. semi_mojmir_def.step Σ ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G φ)) (λχ. semi_mojmir_def.initial (Abs (theG χ)))) w) ∩ ⋃ (↿⇩χ ` ?S) = {}) = (limit (run⇩t δ⇩R q⇩R w) ∩ ?S = {})›*) unfolding r_def "r⇩χ_def" P_def (*goals: 1. ‹limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ fst (❙↿⇩χ (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ))) = {}› 2. ‹limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ snd (❙↿⇩χ (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ))) ≠ {}›*) apply - (*goals: 1. ‹⟦limit (run⇩t δ⇩R q⇩R (w::nat ⇒ 'a::type set)) ∩ fst (fail⇩R ∪ merge⇩R ((π::'a::type ltl ⇒ nat) (χ::'a::type ltl)), succeed⇩R (π χ)) = {}; limit (run⇩t δ⇩R q⇩R w) ∩ snd (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) ≠ {}; finite (range (run⇩t (Δ⇩× (λχ::'a::type ltl. semi_mojmir_def.step (Σ::'a::type set set) ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G (φ::'a::type ltl))) (λχ::'a::type ltl. semi_mojmir_def.initial (Abs (theG χ)))) w)); ⋀S::(('a::type ltl_prop_equiv_quotient ⇒ nat option) × 'a::type set × ('a::type ltl_prop_equiv_quotient ⇒ nat option)) set. (limit (run⇩t (Δ⇩× (λχ::'a::type ltl. semi_mojmir_def.step Σ ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G φ)) (λχ::'a::type ltl. semi_mojmir_def.initial (Abs (theG χ)))) w) ∩ ⋃ (↿⇩χ ` S) = {}) = (limit (run⇩t δ⇩R q⇩R w) ∩ S = {})⟧ ⟹ limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ fst (❙↿⇩χ (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ))) = {}› 2. ‹⟦limit (run⇩t δ⇩R q⇩R (w::nat ⇒ 'a::type set)) ∩ fst (fail⇩R ∪ merge⇩R ((π::'a::type ltl ⇒ nat) (χ::'a::type ltl)), succeed⇩R (π χ)) = {}; limit (run⇩t δ⇩R q⇩R w) ∩ snd (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) ≠ {}; finite (range (run⇩t (Δ⇩× (λχ::'a::type ltl. semi_mojmir_def.step (Σ::'a::type set set) ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G (φ::'a::type ltl))) (λχ::'a::type ltl. semi_mojmir_def.initial (Abs (theG χ)))) w)); ⋀S::(('a::type ltl_prop_equiv_quotient ⇒ nat option) × 'a::type set × ('a::type ltl_prop_equiv_quotient ⇒ nat option)) set. (limit (run⇩t (Δ⇩× (λχ::'a::type ltl. semi_mojmir_def.step Σ ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G φ)) (λχ::'a::type ltl. semi_mojmir_def.initial (Abs (theG χ)))) w) ∩ ⋃ (↿⇩χ ` S) = {}) = (limit (run⇩t δ⇩R q⇩R w) ∩ S = {})⟧ ⟹ limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ snd (❙↿⇩χ (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ))) ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w" unfolding P_def r_def (*goal: ‹accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) (❙↿⇩χ (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ))) w›*) by simp qed hence "accepting_pair⇩G⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) (combine_pairs' ?P') w" using combine_pairs'_prop (*‹(∀P∈?𝒫. accepting_pair⇩R ?δ ?q₀ P ?w) = accepting_pair⇩G⇩R ?δ ?q₀ (local.combine_pairs' ?𝒫) ?w›*) by blast moreover { fix ψ assume "ψ ∈ 𝒢" (*‹(ψ::'a ltl) ∈ (𝒢::'a ltl set)›*) hence "∃χ. ψ = G χ" using ‹𝒢 ⊆ ❙G (G φ)› (*‹(𝒢::'a ltl set) ⊆ ❙G (G (φ::'a ltl))›*) G_nested_propos_alt_def (*‹❙G ?φ = nested_propos ?φ ∩ {ψ. ∃x. ψ = G x}›*) by auto interpret ltl_FG_to_rabin "Σ" "theG ψ" "𝒢" w by (insert ‹ltl_FG_to_rabin Σ 𝒢 w›) have accept using ‹ψ ∈ 𝒢› (*‹ψ ∈ 𝒢›*) ‹∃χ. ψ = G χ› (*‹∃χ. ψ = G χ›*) ‹∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w› (*‹∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›*) mojmir_accept_iff_rabin_accept (*‹accept⇩R' = accept⇩R (δ⇩R, q⇩R, {(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}) w›*) by auto then obtain i where "smallest_accepting_rank = Some i" (*goal: ‹(⋀i. smallest_accepting_rank⇩R = Some i ⟹ thesis) ⟹ thesis›*) unfolding smallest_accepting_rank_def (*goal: ‹(⋀i. (if accept⇩R' then Some (LEAST i. finite fail ∧ finite (local.merge i) ∧ infinite (succeed i)) else None) = Some i ⟹ thesis) ⟹ thesis›*) by fastforce hence "π ψ < max_rank⇩R" using smallest_accepting_rank_properties (*‹smallest_accepting_rank⇩R = Some ?i ⟹ accept⇩R'› ‹smallest_accepting_rank⇩R = Some ?i ⟹ finite fail› ‹smallest_accepting_rank⇩R = Some ?i ⟹ finite (local.merge ?i)› ‹smallest_accepting_rank⇩R = Some (?i::nat) ⟹ infinite (succeed ?i)› ‹smallest_accepting_rank⇩R = Some ?i ⟹ ∀j<?i. finite (succeed j)› ‹smallest_accepting_rank⇩R = Some ?i ⟹ ?i < max_rank⇩R›*) "π_def" (*‹(π::'a ltl ⇒ nat) (?ψ::'a ltl) = (if ?ψ ∈ (𝒢::'a ltl set) then the (mojmir_def.smallest_accepting_rank (Σ::'a set set) ↑af⇩G (Abs (theG ?ψ)) (w::nat ⇒ 'a set) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q}) else (0::nat))›*) ‹ψ ∈ 𝒢› (*‹ψ ∈ 𝒢›*) by auto } hence "⋀χ. π χ < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ)" unfolding "π_def" (*goal: ‹⋀χ. (if χ ∈ 𝒢 then the (mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG χ)) w {q. 𝒢 ⊨⇩P Rep q}) else 0) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ))›*) using ltl_FG_to_rabin.max_rank_lowerbound[OF ‹ltl_FG_to_rabin Σ 𝒢 w›] (*‹0 < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs ?φ)›*) by force hence "combine_pairs' ?P' ∈ snd (snd (𝒫 φ))" using ‹𝒢 ⊆ ❙G (G φ)› (*‹𝒢 ⊆ ❙G (G φ)›*) ‹G φ ∈ 𝒢› (*‹G φ ∈ 𝒢›*) by auto ultimately show "?rhs" unfolding "accept⇩G⇩R_simp2" ltl_FG_to_generalized_rabin.simps fst_conv snd_conv (*goal: ‹∃P::(('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) × 'a::type set × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) × 'a::type set × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set set∈{local.combine_pairs' {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R (Σ::'a::type set set) ↑af⇩G (Abs (theG χ)) {q::'a::type ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q::'a::type ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q::'a::type ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} (π χ)) |χ::'a::type ltl. χ ∈ 𝒢} |(𝒢::'a::type ltl set) π::'a::type ltl ⇒ nat. 𝒢 ⊆ ❙G (G (φ::'a::type ltl)) ∧ G φ ∈ 𝒢 ∧ (∀χ::'a::type ltl. π χ < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ)))}. accepting_pair⇩G⇩R (Δ⇩× (λχ::'a::type ltl. semi_mojmir_def.step Σ ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G φ)) (λχ::'a::type ltl. semi_mojmir_def.initial (Abs (theG χ)))) P (w::nat ⇒ 'a::type set)›*) by blast } { assume "?rhs" (*‹accept⇩G⇩R (𝒫 (φ::'a ltl)) (w::nat ⇒ 'a set)›*) then obtain 𝒢 and π and P where "P = combine_pairs' {❙↿⇩χ (ltl_FG_to_rabin_def.Acc⇩R Σ (theG χ) 𝒢 (π χ)) | χ. χ ∈ 𝒢}" (is "P = combine_pairs' ?P'") and "accepting_pair⇩G⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w" and "𝒢 ⊆ ❙G (G φ)" and "G φ ∈ 𝒢" and "⋀χ. π χ < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ)" (*goal: ‹(⋀P 𝒢 π. ⟦P = local.combine_pairs' {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ)) |χ. χ ∈ 𝒢}; accepting_pair⇩G⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w; 𝒢 ⊆ ❙G (G φ); G φ ∈ 𝒢; ⋀χ. π χ < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ))⟧ ⟹ thesis) ⟹ thesis›*) unfolding "accept⇩G⇩R_def" (*goal: ‹(⋀(P::(('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set set) (𝒢::'a ltl set) π::'a ltl ⇒ nat. ⟦P = local.combine_pairs' {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R (Σ::'a set set) ↑af⇩G (Abs (theG χ)) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} (π χ)) |χ::'a ltl. χ ∈ 𝒢}; accepting_pair⇩G⇩R (fst (𝒫 (φ::'a ltl))) (fst (snd (𝒫 φ))) P (w::nat ⇒ 'a set); 𝒢 ⊆ ❙G (G φ); G φ ∈ 𝒢; ⋀χ::'a ltl. π χ < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ))⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto moreover hence P'_def: "⋀P. P ∈ ?P' ⟹ accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w" using combine_pairs'_prop (*‹(∀P::(('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) × 'a::type set × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) × 'a::type set × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set∈?𝒫::((('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) × 'a::type set × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) × 'a::type set × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set) set. accepting_pair⇩R (?δ::('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) ⇒ 'a::type set ⇒ 'a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) (?q₀::'a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option) P (?w::nat ⇒ 'a::type set)) = accepting_pair⇩G⇩R ?δ ?q₀ (local.combine_pairs' ?𝒫) ?w›*) by meson note "𝒢_properties"[OF ‹𝒢 ⊆ ❙G (G φ)›] (*‹finite (𝒢::'a::type ltl set)› ‹Only_G 𝒢›*) hence "ltl_FG_to_rabin Σ 𝒢 w" using ‹finite Σ› (*‹finite Σ›*) ‹range w ⊆ Σ› (*‹range w ⊆ Σ›*) unfolding ltl_FG_to_rabin_def (*goal: ‹Only_G 𝒢 ∧ range w ⊆ Σ ∧ finite Σ›*) by auto have "∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w" apply rule (*goal: ‹∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›*) proof (rule) (*goal: ‹⋀ψ. G ψ ∈ 𝒢 ⟹ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›*) fix ψ assume "G ψ ∈ 𝒢" (*‹G (ψ::'a ltl) ∈ (𝒢::'a ltl set)›*) define χ where "χ = G ψ" define P where "P = ❙↿⇩χ (ltl_FG_to_rabin_def.Acc⇩R Σ ψ 𝒢 (π χ))" hence "χ ∈ 𝒢" and "theG χ = ψ" using "χ_def" (*‹(χ::'a::type ltl) = G (ψ::'a::type ltl)›*) ‹G ψ ∈ 𝒢› (*‹G ψ ∈ 𝒢›*) apply - (*goals: 1. ‹⟦P = ❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} (π χ)); χ = G ψ; G ψ ∈ 𝒢⟧ ⟹ χ ∈ 𝒢› 2. ‹⟦P = ❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} (π χ)); χ = G ψ; G ψ ∈ 𝒢⟧ ⟹ theG χ = ψ› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . hence "P ∈ ?P'" unfolding P_def (*goal: ‹❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs ψ) {q. 𝒢 ⊨⇩P Rep q} (π χ)) ∈ {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ)) |χ. χ ∈ 𝒢}›*) by auto hence "accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w" using P'_def (*‹?P10 ∈ {❙↿⇩χ (mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ), mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs (theG χ)) {q. 𝒢 ⊨⇩P Rep q} (π χ)) |χ. χ ∈ 𝒢} ⟹ accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) ?P10 w›*) by blast interpret ltl_FG_to_rabin "Σ" "ψ" "𝒢" w by (insert ‹ltl_FG_to_rabin Σ 𝒢 w›) define r⇩χ where "r⇩χ = run⇩t δ⇩ℛ q⇩ℛ w" have "limit r ∩ fst P = {}" and "limit r ∩ snd P ≠ {}" using ‹accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w› (*‹accepting_pair⇩R (fst (𝒫 φ)) (fst (snd (𝒫 φ))) P w›*) unfolding r_def "accepting_pair⇩R_def" (*goals: 1. ‹limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ fst P = {}› 2. ‹limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ snd P ≠ {}›*) apply - (*goals: 1. ‹limit (run⇩t (fst (𝒫 (φ::'a ltl))) (fst (snd (𝒫 φ))) (w::nat ⇒ 'a set)) ∩ fst (P::(('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) = {} ∧ limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ snd P ≠ {} ⟹ limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ fst P = {}› 2. ‹limit (run⇩t (fst (𝒫 (φ::'a ltl))) (fst (snd (𝒫 φ))) (w::nat ⇒ 'a set)) ∩ fst (P::(('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) = {} ∧ limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ snd P ≠ {} ⟹ limit (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w) ∩ snd P ≠ {}› discuss goal 1*) apply metis (*discuss goal 2*) apply metis (*proven 2 subgoals*) . moreover have 1: "(ι⇩× (❙G (G φ)) (λχ. ltl_FG_to_rabin_def.q⇩R (theG χ))) (G ψ) = Some q⇩ℛ" using ‹G ψ ∈ 𝒢› (*‹G (ψ::'a ltl) ∈ (𝒢::'a ltl set)›*) ‹𝒢 ⊆ ❙G (G φ)› (*‹(𝒢::'a ltl set) ⊆ ❙G (G (φ::'a ltl))›*) by (auto simp add: LTL_Rabin.product_initial_state.simps (*‹ι⇩× ?K ?q⇩m = (λk. if k ∈ ?K then Some (?q⇩m k) else None)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) have 2: "finite (range (run⇩t (Δ⇩× (λχ. ltl_FG_to_rabin_def.δ⇩R Σ (theG χ))) (ι⇩× (❙G (G φ)) (λχ. ltl_FG_to_rabin_def.q⇩R (theG χ))) w))" using ‹finite (range r)›[unfolded r_def] (*‹finite (range (run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w))›*) by simp have "⋀S. limit r ∩ (⋃ (↿⇩χ ` S)) = {} ⟷ limit r⇩χ ∩ S = {}" using product_run_embed_limit_finiteness[OF 1 2] (*‹(limit (run⇩t (Δ⇩× (λχ. semi_mojmir_def.step Σ ↑af⇩G (Abs (theG χ)))) (ι⇩× (❙G (G φ)) (λχ. semi_mojmir_def.initial (Abs (theG χ)))) w) ∩ ⋃ (↿⇩G ψ ` ?S) = {}) = (limit (run⇩t (semi_mojmir_def.step Σ ↑af⇩G (Abs (theG (G ψ)))) q⇩R w) ∩ ?S = {})›*) by (simp add: r_def (*‹r = run⇩t (fst (𝒫 φ)) (fst (snd (𝒫 φ))) w›*) r⇩χ_def (*‹r⇩χ = run⇩t δ⇩R q⇩R w›*) χ_def (*‹χ = G ψ›*)) ultimately have "limit r⇩χ ∩ fst (Acc⇩ℛ (π χ)) = {}" and "limit r⇩χ ∩ snd (Acc⇩ℛ (π χ)) ≠ {}" unfolding P_def fst_conv snd_conv embed_pair.simps (*goals: 1. ‹limit r⇩χ ∩ (fail⇩R ∪ merge⇩R (π χ)) = {}› 2. ‹limit r⇩χ ∩ succeed⇩R (π χ) ≠ {}›*) apply - (*goals: 1. ‹⟦limit r ∩ ⋃ (↿⇩χ ` (fail⇩R ∪ merge⇩R (π χ))) = {}; limit r ∩ ⋃ (↿⇩χ ` succeed⇩R (π χ)) ≠ {}; ⋀S. (limit r ∩ ⋃ (↿⇩χ ` S) = {}) = (limit r⇩χ ∩ S = {})⟧ ⟹ limit r⇩χ ∩ (fail⇩R ∪ merge⇩R (π χ)) = {}› 2. ‹⟦limit r ∩ ⋃ (↿⇩χ ` (fail⇩R ∪ merge⇩R (π χ))) = {}; limit r ∩ ⋃ (↿⇩χ ` succeed⇩R (π χ)) ≠ {}; ⋀S. (limit r ∩ ⋃ (↿⇩χ ` S) = {}) = (limit r⇩χ ∩ S = {})⟧ ⟹ limit r⇩χ ∩ succeed⇩R (π χ) ≠ {}› discuss goal 1*) apply meson (*discuss goal 2*) apply meson (*proven 2 subgoals*) . hence "accepting_pair⇩R δ⇩ℛ q⇩ℛ (Acc⇩ℛ (π χ)) w" unfolding "r⇩χ_def" (*goal: ‹accepting_pair⇩R δ⇩R q⇩R (fail⇩R ∪ merge⇩R (π χ), succeed⇩R (π χ)) w›*) by simp hence "accept⇩R (δ⇩ℛ, q⇩ℛ, {Acc⇩ℛ j | j. j < max_rank}) w" using ‹⋀χ. π χ < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ)› (*‹π ?χ < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG ?χ))›*) ‹theG χ = ψ› (*‹theG χ = ψ›*) unfolding "accept⇩R_simp" "accepting_pair⇩R_def" fst_conv snd_conv (*goal: ‹∃(Fin, Inf)∈{(fail⇩R ∪ merge⇩R j, succeed⇩R j) |j. j < max_rank⇩R}. limit (run⇩t δ⇩R q⇩R w) ∩ Fin = {} ∧ limit (run⇩t δ⇩R q⇩R w) ∩ Inf ≠ {}›*) by blast thus "accept⇩R (ltl_to_rabin Σ ψ 𝒢) w" by simp qed ultimately show "?lhs" unfolding ltl_to_rabin_correct[OF ‹finite Σ› assms] (*goal: ‹∃𝒢⊆❙G (G φ). G φ ∈ 𝒢 ∧ (∀ψ. G ψ ∈ 𝒢 ⟶ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w)›*) by auto } qed end end subsection ‹Automaton Template› ― ‹This locale provides the construction template for all composed constructions.› locale ltl_to_rabin_base_def = fixes δ :: "'a ltl⇩P ⇒ 'a set ⇒ 'a ltl⇩P" fixes δ⇩M :: "'a ltl⇩P ⇒ 'a set ⇒ 'a ltl⇩P" fixes q₀ :: "'a ltl ⇒ 'a ltl⇩P" fixes q₀⇩M :: "'a ltl ⇒ 'a ltl⇩P" fixes M_fin :: "('a ltl ⇀ nat) ⇒ ('a ltl⇩P × ('a ltl ⇀ 'a ltl⇩P ⇀ nat), 'a set) transition set" begin ― ‹Transition Function and Initial State› fun delta where "delta Σ = δ × Δ⇩× (semi_mojmir_def.step Σ δ⇩M o q₀⇩M o theG)" fun initial where "initial φ = (q₀ φ, ι⇩× (❙G φ) (semi_mojmir_def.initial o q₀⇩M o theG))" ― ‹Acceptance Condition› definition max_rank_of where "max_rank_of Σ ψ ≡ semi_mojmir_def.max_rank Σ δ⇩M (q₀⇩M (theG ψ))" fun Acc_fin where "Acc_fin Σ π χ = ⋃(embed_transition_snd ` ⋃(embed_transition χ ` (mojmir_to_rabin_def.fail⇩R Σ δ⇩M (q₀⇩M (theG χ)) {q. dom π ↑⊨⇩P q} ∪ mojmir_to_rabin_def.merge⇩R δ⇩M (q₀⇩M (theG χ)) {q. dom π ↑⊨⇩P q} (the (π χ)))))" fun Acc_inf where "Acc_inf π χ = ⋃(embed_transition_snd ` ⋃(embed_transition χ ` (mojmir_to_rabin_def.succeed⇩R δ⇩M (q₀⇩M (theG χ)) {q. dom π ↑⊨⇩P q} (the (π χ)))))" abbreviation Acc where "Acc Σ π χ ≡ (Acc_fin Σ π χ, Acc_inf π χ)" fun rabin_pairs :: "'a set set ⇒ 'a ltl ⇒ ('a ltl⇩P × ('a ltl ⇀ 'a ltl⇩P ⇀ nat), 'a set) generalized_rabin_condition" where "rabin_pairs Σ φ = {(M_fin π ∪ ⋃{Acc_fin Σ π χ | χ. χ ∈ dom π}, {Acc_inf π χ | χ. χ ∈ dom π}) | π. dom π ⊆ ❙G φ ∧ (∀χ ∈ dom π. the (π χ) < max_rank_of Σ χ)}" fun ltl_to_generalized_rabin :: "'a set set ⇒ 'a ltl ⇒ ('a ltl⇩P × ('a ltl ⇀ 'a ltl⇩P ⇀ nat), 'a set) generalized_rabin_automaton" ("𝒜") where "𝒜 Σ φ = (delta Σ, initial φ, rabin_pairs Σ φ)" end locale ltl_to_rabin_base = ltl_to_rabin_base_def + fixes Σ :: "'a set set" fixes w :: "'a set word" assumes finite_Σ: "finite Σ" assumes bounded_w: "range w ⊆ Σ" assumes M_fin_monotonic: "dom π = dom π' ⟹ (⋀χ. χ ∈ dom π ⟹ the (π χ) ≤ the (π' χ)) ⟹ M_fin π ⊆ M_fin π'" assumes finite_reach': "finite (reach Σ δ (q₀ φ))" assumes mojmir_to_rabin: "Only_G 𝒢 ⟹ mojmir_to_rabin Σ δ⇩M (q₀⇩M ψ) w {q. 𝒢 ↑⊨⇩P q}" begin lemma semi_mojmir: "semi_mojmir Σ δ⇩M (q₀⇩M ψ) w" using mojmir_to_rabin[of "{}"] (*‹Only_G {} ⟹ mojmir_to_rabin Σ δ⇩M (q₀⇩M ?ψ) w {q. {} ↑⊨⇩P q}›*) by (simp add: mojmir_to_rabin_def (*‹mojmir_to_rabin ?Σ ?δ ?q₀ ?w ?F ≡ mojmir ?Σ ?δ ?q₀ ?w ?F›*) mojmir_def (*‹mojmir ?Σ ?δ ?q₀ ?w ?F ≡ semi_mojmir ?Σ ?δ ?q₀ ?w ∧ mojmir_axioms ?δ ?F›*)) lemma finite_reach: "finite (reach Σ (delta Σ) (initial φ))" apply (cases "Σ = {}") (*goals: 1. ‹Σ = {} ⟹ finite (reach Σ (delta Σ) (initial φ))› 2. ‹Σ ≠ {} ⟹ finite (reach Σ (delta Σ) (initial φ))› discuss goal 1*) apply (simp add: reach_def (*‹reach ?Σ ?δ ?q₀ = {run ?δ ?q₀ w n |w n. range w ⊆ ?Σ}›*)) (*discuss goal 2*) apply (simp only: ltl_to_rabin_base_def.initial.simps (*‹ltl_to_rabin_base_def.initial ?q₀ ?q₀⇩M ?φ = (?q₀ ?φ, ι⇩× (❙G ?φ) (semi_mojmir_def.initial ∘ ?q₀⇩M ∘ theG))›*) ltl_to_rabin_base_def.delta.simps (*‹ltl_to_rabin_base_def.delta ?δ ?δ⇩M ?q₀⇩M ?Σ = ?δ × Δ⇩× (semi_mojmir_def.step ?Σ ?δ⇩M ∘ ?q₀⇩M ∘ theG)›*)) (*goal: ‹Σ ≠ {} ⟹ finite (reach Σ (delta Σ) (initial φ))›*) apply (rule finite_reach_simple_product[OF finite_reach' finite_reach_product] (*‹⟦finite (dom ?q₂); ⋀x. x ∈ dom ?q₂ ⟹ finite (reach Σ (?δ⇩m1 x) (the (?q₂ x)))⟧ ⟹ finite (reach Σ δ × Δ⇩× ?δ⇩m1 (q₀ ?φ2, ?q₂))›*)) (*goals: 1. ‹Σ ≠ {} ⟹ finite (dom (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG)))› 2. ‹⋀x. ⟦Σ ≠ {}; x ∈ dom (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG))⟧ ⟹ finite (reach Σ ((semi_mojmir_def.step Σ δ⇩M ∘ q₀⇩M ∘ theG) x) (the (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG) x)))› discuss goal 1*) apply ((insert mojmir_to_rabin[of "{}", unfolded mojmir_to_rabin_def mojmir_def] (*‹Only_G {} ⟹ semi_mojmir Σ δ⇩M (q₀⇩M ?ψ) w ∧ mojmir_axioms δ⇩M (Collect (ltl_prop_entails_abs {}))›*))[1]) (*top goal: ‹Σ ≠ {} ⟹ finite (dom (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG)))› and 1 goal remains*) apply ((auto simp add: dom_def (*‹dom ?m = {a. ?m a ≠ None}›*) intro: G_nested_finite (*‹finite (❙G ?φ)›*) semi_mojmir.wellformed_ℛ (*‹semi_mojmir ?Σ ?δ ?q₀ ?w ⟹ finite (reach ?Σ (semi_mojmir_def.step ?Σ ?δ ?q₀) (semi_mojmir_def.initial ?q₀))›*))[1]) (*discuss goal 2*) apply ((insert mojmir_to_rabin[of "{}", unfolded mojmir_to_rabin_def mojmir_def] (*‹Only_G {} ⟹ semi_mojmir (Σ::'a set set) (δ⇩M::'a ltl_prop_equiv_quotient ⇒ 'a set ⇒ 'a ltl_prop_equiv_quotient) ((q₀⇩M::'a ltl ⇒ 'a ltl_prop_equiv_quotient) (?ψ::'a ltl)) (w::nat ⇒ 'a set) ∧ mojmir_axioms δ⇩M (Collect (ltl_prop_entails_abs {}))›*))[1]) (*goal: ‹⋀x. ⟦Σ ≠ {}; x ∈ dom (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG))⟧ ⟹ finite (reach Σ ((semi_mojmir_def.step Σ δ⇩M ∘ q₀⇩M ∘ theG) x) (the (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG) x)))›*) apply ((auto simp add: dom_def (*‹dom ?m = {a. ?m a ≠ None}›*) intro: G_nested_finite (*‹finite (❙G ?φ)›*) semi_mojmir.wellformed_ℛ (*‹semi_mojmir ?Σ ?δ ?q₀ ?w ⟹ finite (reach ?Σ (semi_mojmir_def.step ?Σ ?δ ?q₀) (semi_mojmir_def.initial ?q₀))›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma run_limit_not_empty: "limit (run⇩t (delta Σ) (initial φ) w) ≠ {}" by (metis emptyE (*‹(?a::?'a) ∈ {} ⟹ ?P::bool›*) finite_Σ (*‹finite (Σ::'a set set)›*) limit_nonemptyE (*‹⟦finite (range (?x::nat ⇒ ?'a)); ⋀x::?'a. x ∈ limit ?x ⟹ ?Q::bool⟧ ⟹ ?Q›*) finite_reach (*‹finite (reach (Σ::'a set set) (delta Σ) (initial (?φ::'a ltl)))›*) bounded_w (*‹range (w::nat ⇒ 'a set) ⊆ (Σ::'a set set)›*) run⇩t_finite (*‹⟦finite (reach (?Σ::?'b set) (?δ::?'a ⇒ ?'b ⇒ ?'a) (?q₀::?'a)); finite ?Σ; range (?w::nat ⇒ ?'b) ⊆ ?Σ⟧ ⟹ finite (range (run⇩t ?δ ?q₀ ?w))›*)) lemma run_properties: fixes φ defines "r ≡ run (delta Σ) (initial φ) w" shows "fst (r i) = foldl δ (q₀ φ) (w [0 → i])" and "⋀χ q. χ ∈ ❙G φ ⟹ the (snd (r i) χ) q = semi_mojmir_def.state_rank Σ δ⇩M (q₀⇩M (theG χ)) w q i" proof (-) (*goals: 1. ‹fst (r i) = foldl δ (q₀ φ) (prefix i w)› 2. ‹⋀χ q. χ ∈ ❙G φ ⟹ the (snd (r i) χ) q = semi_mojmir_def.state_rank Σ δ⇩M (q₀⇩M (theG χ)) w q i›*) have sm: "⋀ψ. semi_mojmir Σ δ⇩M (q₀⇩M ψ) w" using mojmir_to_rabin[of "{}"] (*‹Only_G {} ⟹ mojmir_to_rabin Σ δ⇩M (q₀⇩M ?ψ) w {q. {} ↑⊨⇩P q}›*) unfolding mojmir_to_rabin_def mojmir_def (*goal: ‹⋀ψ. semi_mojmir Σ δ⇩M (q₀⇩M ψ) w›*) by simp have "r i = (foldl δ (q₀ φ) (w [0 → i]), λχ. if χ ∈ ❙G φ then Some (λψ. foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0..< i]) ψ) else None)" proof (induction i) (*goals: 1. ‹(r::nat ⇒ 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) (0::nat) = (foldl (δ::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (φ::'a::type ltl)) (prefix (0::nat) (w::nat ⇒ 'a::type set)), λχ::'a::type ltl. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step (Σ::'a::type set set) (δ⇩M::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀⇩M::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0::nat..<0::nat])) else None)› 2. ‹⋀i::nat. (r::nat ⇒ 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) i = (foldl (δ::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (φ::'a::type ltl)) (prefix i (w::nat ⇒ 'a::type set)), λχ::'a::type ltl. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step (Σ::'a::type set set) (δ⇩M::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀⇩M::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0::nat..<i])) else None) ⟹ r (Suc i) = (foldl δ (q₀ φ) (prefix (Suc i) w), λχ::'a::type ltl. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0::nat..<Suc i])) else None)›*) case (Suc i) (*‹r i = (foldl δ (q₀ φ) (prefix i w), λχ. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0..<i])) else None)›*) show "?case" (*goal: ‹r (Suc i) = (foldl δ (q₀ φ) (prefix (Suc i) w), λχ. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0..<Suc i])) else None)›*) unfolding r_def run_foldl upt_Suc less_eq_nat.simps if_True map_append foldl_append (*goal: ‹foldl (delta Σ) (foldl (delta Σ) (initial φ) (map w [0..<i])) (map w [i]) = (foldl δ (q₀ φ) (prefix (Suc i) w), λχ. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0..<i])) (map w [i])) else None)›*) unfolding Suc[unfolded r_def run_foldl] subsequence_def (*goal: ‹foldl (delta (Σ::'a::type set set)) (foldl (δ::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (φ::'a::type ltl)) (map (w::nat ⇒ 'a::type set) [0::nat..<i::nat]), λχ::'a::type ltl. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ (δ⇩M::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀⇩M::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0::nat..<i])) else None) (map w [i]) = (foldl δ (q₀ φ) (map w [0::nat..<Suc i]), λχ::'a::type ltl. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0::nat..<i])) (map w [i])) else None)›*) by auto qed (auto simp add: subsequence_def (*‹?w::nat ⇒ ?'a [?i::nat → ?j::nat] ≡ map ?w [?i..<?j]›*) r_def (*‹r::nat ⇒ 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) ≡ run (delta (Σ::'a set set)) (initial (φ::'a ltl)) (w::nat ⇒ 'a set)›*)) (*solved the remaining goal: ‹r 0 = (foldl δ (q₀ φ) (prefix 0 w), λχ. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0..<0])) else None)›*) hence state_run: "r i = (foldl δ (q₀ φ) (w [0 → i]), λχ. if χ ∈ ❙G φ then Some (λψ. semi_mojmir_def.state_rank Σ δ⇩M (q₀⇩M (theG χ)) w ψ i) else None)" unfolding semi_mojmir.state_rank_step_foldl[OF sm] r_def (*goal: ‹run (delta Σ) (initial φ) w i = (foldl δ (q₀ φ) (prefix i w), λχ. if χ ∈ ❙G φ then Some (foldl (semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG χ))) (semi_mojmir_def.initial (q₀⇩M (theG χ))) (map w [0..<i])) else None)›*) by simp show "fst (r i) = foldl δ (q₀ φ) (w [0 → i])" using state_run (*‹(r::nat ⇒ 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) (i::nat) = (foldl (δ::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (φ::'a::type ltl)) (prefix i (w::nat ⇒ 'a::type set)), λχ::'a::type ltl. if χ ∈ ❙G φ then Some (λψ::'a::type ltl_prop_equiv_quotient. semi_mojmir_def.state_rank (Σ::'a::type set set) (δ⇩M::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀⇩M::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (theG χ)) w ψ i) else None)›*) by fastforce show "⋀χ q. χ ∈ ❙G φ ⟹ the (snd (r i) χ) q = semi_mojmir_def.state_rank Σ δ⇩M (q₀⇩M (theG χ)) w q i" unfolding state_run (*goal: ‹⋀χ q. χ ∈ ❙G φ ⟹ the (snd (foldl δ (q₀ φ) (prefix i w), λχ. if χ ∈ ❙G φ then Some (λψ. semi_mojmir_def.state_rank Σ δ⇩M (q₀⇩M (theG χ)) w ψ i) else None) χ) q = semi_mojmir_def.state_rank Σ δ⇩M (q₀⇩M (theG χ)) w q i›*) by force qed lemma accept⇩G⇩R_I: assumes "accept⇩G⇩R (𝒜 Σ φ) w" obtains π where "dom π ⊆ ❙G φ" and "⋀χ. χ ∈ dom π ⟹ the (π χ) < max_rank_of Σ χ" and "accepting_pair⇩R (delta Σ) (initial φ) (M_fin π, UNIV) w" and "⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π χ) w" proof (-) (*goal: ‹(⋀π. ⟦dom π ⊆ ❙G φ; ⋀χ. χ ∈ dom π ⟹ the (π χ) < max_rank_of Σ χ; accepting_pair⇩R (delta Σ) (initial φ) (M_fin π, UNIV) w; ⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π χ) w⟧ ⟹ thesis) ⟹ thesis›*) from assms (*‹accept⇩G⇩R (𝒜 Σ φ) w›*) obtain P where "P ∈ rabin_pairs Σ φ" and "accepting_pair⇩G⇩R (delta Σ) (initial φ) P w" (*goal: ‹(⋀P::(('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set set. ⟦P ∈ rabin_pairs (Σ::'a set set) (φ::'a ltl); accepting_pair⇩G⇩R (delta Σ) (initial φ) P (w::nat ⇒ 'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding "accept⇩G⇩R_def" ltl_to_generalized_rabin.simps fst_conv snd_conv (*goal: ‹(⋀P::(('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set set. ⟦P ∈ rabin_pairs (Σ::'a set set) (φ::'a ltl); accepting_pair⇩G⇩R (delta Σ) (initial φ) P (w::nat ⇒ 'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast moreover then obtain π where "dom π ⊆ ❙G φ" and "∀χ ∈ dom π. the (π χ) < max_rank_of Σ χ" and P_def: "P = (M_fin π ∪ ⋃{Acc_fin Σ π χ | χ. χ ∈ dom π}, {Acc_inf π χ | χ. χ ∈ dom π})" (*goal: ‹(⋀π::'a::type ltl ⇒ nat option. ⟦dom π ⊆ ❙G (φ::'a::type ltl); ∀χ::'a::type ltl∈dom π. the (π χ) < max_rank_of (Σ::'a::type set set) χ; (P::(('a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a::type set × 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set × (('a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a::type set × 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set set) = ((M_fin::('a::type ltl ⇒ nat option) ⇒ (('a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a::type set × 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set) π ∪ ⋃ {Acc_fin Σ π χ |χ::'a::type ltl. χ ∈ dom π}, {Acc_inf π χ |χ::'a::type ltl. χ ∈ dom π})⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto have "limit (run⇩t (delta Σ) (initial φ) w) ∩ UNIV ≠ {}" using run_limit_not_empty (*‹limit (run⇩t (delta Σ) (initial ?φ) w) ≠ {}›*) assms (*‹accept⇩G⇩R (𝒜 Σ φ) w›*) by simp ultimately have "accepting_pair⇩R (delta Σ) (initial φ) (M_fin π, UNIV) w" and "⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π χ) w" unfolding P_def "accepting_pair⇩G⇩R_simp" "accepting_pair⇩R_simp" (*goals: 1. ‹limit (run⇩t (delta Σ) (initial φ) w) ∩ M_fin π = {} ∧ limit (run⇩t (delta Σ) (initial φ) w) ∩ UNIV ≠ {}› 2. ‹⋀χ. χ ∈ dom π ⟹ limit (run⇩t (delta Σ) (initial φ) w) ∩ Acc_fin Σ π χ = {} ∧ limit (run⇩t (delta Σ) (initial φ) w) ∩ Acc_inf π χ ≠ {}›*) apply - (*goals: 1. ‹⟦((M_fin::('a ltl ⇒ nat option) ⇒ (('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) (π::'a ltl ⇒ nat option) ∪ ⋃ {Acc_fin (Σ::'a set set) π χ |χ::'a ltl. χ ∈ dom π}, {Acc_inf π χ |χ::'a ltl. χ ∈ dom π}) ∈ rabin_pairs Σ (φ::'a ltl); limit (run⇩t (delta Σ) (initial φ) (w::nat ⇒ 'a set)) ∩ (M_fin π ∪ ⋃ {Acc_fin Σ π χ |χ::'a ltl. χ ∈ dom π}) = {} ∧ (∀I::(('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set∈{Acc_inf π χ |χ::'a ltl. χ ∈ dom π}. limit (run⇩t (delta Σ) (initial φ) w) ∩ I ≠ {}); limit (run⇩t (delta Σ) (initial φ) w) ∩ UNIV ≠ {}⟧ ⟹ limit (run⇩t (delta Σ) (initial φ) w) ∩ M_fin π = {} ∧ limit (run⇩t (delta Σ) (initial φ) w) ∩ UNIV ≠ {}› 2. ‹⋀χ::'a ltl. ⟦χ ∈ dom (π::'a ltl ⇒ nat option); ((M_fin::('a ltl ⇒ nat option) ⇒ (('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) π ∪ ⋃ {Acc_fin (Σ::'a set set) π χ |χ::'a ltl. χ ∈ dom π}, {Acc_inf π χ |χ::'a ltl. χ ∈ dom π}) ∈ rabin_pairs Σ (φ::'a ltl); limit (run⇩t (delta Σ) (initial φ) (w::nat ⇒ 'a set)) ∩ (M_fin π ∪ ⋃ {Acc_fin Σ π χ |χ::'a ltl. χ ∈ dom π}) = {} ∧ (∀I::(('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set∈{Acc_inf π χ |χ::'a ltl. χ ∈ dom π}. limit (run⇩t (delta Σ) (initial φ) w) ∩ I ≠ {}); limit (run⇩t (delta Σ) (initial φ) w) ∩ UNIV ≠ {}⟧ ⟹ limit (run⇩t (delta Σ) (initial φ) w) ∩ Acc_fin Σ π χ = {} ∧ limit (run⇩t (delta Σ) (initial φ) w) ∩ Acc_inf π χ ≠ {}› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹thesis›*) using that (*‹⟦dom (?π7::'a ltl ⇒ nat option) ⊆ ❙G (φ::'a ltl); ⋀χ::'a ltl. χ ∈ dom ?π7 ⟹ the (?π7 χ) < max_rank_of (Σ::'a set set) χ; accepting_pair⇩R (delta Σ) (initial φ) ((M_fin::('a ltl ⇒ nat option) ⇒ (('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) ?π7, UNIV) (w::nat ⇒ 'a set); ⋀χ::'a ltl. χ ∈ dom ?π7 ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ ?π7 χ) w⟧ ⟹ thesis::bool›*) ‹dom π ⊆ ❙G φ› (*‹dom π ⊆ ❙G φ›*) ‹∀χ ∈ dom π. the (π χ) < max_rank_of Σ χ› (*‹∀χ::'a ltl∈dom (π::'a ltl ⇒ nat option). the (π χ) < max_rank_of (Σ::'a set set) χ›*) by blast qed context fixes φ :: "'a ltl" begin context fixes ψ :: "'a ltl" fixes π :: "'a ltl ⇀ nat" assumes "G ψ ∈ dom π" assumes "dom π ⊆ ❙G φ" begin interpretation 𝔐: mojmir_to_rabin Σ δ⇩M "q₀⇩M ψ" w "{q. dom π ↑⊨⇩P q}" by (metis mojmir_to_rabin (*‹Only_G ?𝒢 ⟹ mojmir_to_rabin Σ δ⇩M (q₀⇩M ?ψ) w {q. ?𝒢 ↑⊨⇩P q}›*) ‹dom π ⊆ ❙G φ› 𝒢_elements (*‹?𝒢 ⊆ ❙G ?φ ⟹ Only_G ?𝒢›*)) lemma Acc_property: "accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w ⟷ accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.Acc⇩ℛ (the (π (G ψ)))) w" (is "?Acc = ?Acc⇩ℛ") proof (-) (*goal: ‹accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w = accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the (π (G ψ))), 𝔐.succeed⇩R (the (π (G ψ)))) w›*) define r and r⇩ψ where "r = run⇩t (delta Σ) (initial φ) w" and "r⇩ψ = run⇩t 𝔐.δ⇩ℛ 𝔐.q⇩ℛ w" hence "finite (range r)" using "run⇩t_finite"[OF finite_reach] (*‹⟦finite Σ; range ?w ⊆ Σ⟧ ⟹ finite (range (run⇩t (delta Σ) (initial ?φ1) ?w))›*) bounded_w (*‹range w ⊆ Σ›*) "finite_Σ" (*‹finite (Σ::'a set set)›*) by (blast dest: finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) have "⋀S. limit r⇩ψ ∩ S = {} ⟷ limit r ∩ ⋃(embed_transition_snd ` (⋃ ((embed_transition (G ψ)) ` S))) = {}" proof (-) (*goal: ‹⋀S. (limit r⇩ψ ∩ S = {}) = (limit r ∩ ⋃ (embed_transition_snd ` ⋃ (↿⇩G ψ ` S)) = {})›*) fix S have 1: "snd (initial φ) (G ψ) = Some 𝔐.q⇩ℛ" using ‹G ψ ∈ dom π› (*‹G (ψ::'a ltl) ∈ dom (π::'a ltl ⇒ nat option)›*) ‹dom π ⊆ ❙G φ› (*‹dom π ⊆ ❙G φ›*) by auto have 2: "finite (range (run⇩t (Δ⇩× (semi_mojmir_def.step Σ δ⇩M o q₀⇩M o theG)) (snd (initial φ)) w))" using ‹finite (range r)› (*‹finite (range (r::nat ⇒ ('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)))›*) r_def (*‹(r::nat ⇒ ('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) = run⇩t (delta (Σ::'a set set)) (initial (φ::'a ltl)) (w::nat ⇒ 'a set)›*) comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*) by (auto intro: product_run_finite_snd (*‹finite (range (run⇩t ?δ₁ × ?δ₂ (?q₁, ?q₂) ?w)) ⟹ finite (range (run⇩t ?δ₂ ?q₂ ?w))›*) cong del: image_cong_simp (*‹⟦?M = ?N; ⋀x. x ∈ ?N =simp=> ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*)) show "?thesis S" (*goal: ‹(limit r⇩ψ ∩ S = {}) = (limit r ∩ ⋃ (embed_transition_snd ` ⋃ (↿⇩G ψ ` S)) = {})›*) unfolding r_def "r⇩ψ_def" product_run_embed_limit_finiteness[OF 1 2, unfolded ltl.sel comp_def, symmetric] (*goal: ‹(limit (run⇩t (Δ⇩× (λx. semi_mojmir_def.step Σ δ⇩M (q₀⇩M (theG x)))) (snd (initial φ)) w) ∩ ⋃ (↿⇩G ψ ` S) = {}) = (limit (run⇩t (delta Σ) (initial φ) w) ∩ ⋃ (embed_transition_snd ` ⋃ (↿⇩G ψ ` S)) = {})›*) using product_run_embed_limit_finiteness_snd[OF ‹finite (range r)› [ unfolded r_def delta.simps initial.simps ]] (*‹(limit (run⇩t δ::'a ltl_prop_equiv_quotient ⇒ 'a set ⇒ 'a ltl_prop_equiv_quotient × Δ⇩× (semi_mojmir_def.step (Σ::'a set set) (δ⇩M::'a ltl_prop_equiv_quotient ⇒ 'a set ⇒ 'a ltl_prop_equiv_quotient) ∘ (q₀⇩M::'a ltl ⇒ 'a ltl_prop_equiv_quotient) ∘ theG) ((q₀::'a ltl ⇒ 'a ltl_prop_equiv_quotient) (φ::'a ltl), ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG)) (w::nat ⇒ 'a set)) ∩ ⋃ (embed_transition_snd ` (?S'::(('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option) × 'a set × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set)) = {}) = (limit (run⇩t (Δ⇩× (semi_mojmir_def.step Σ δ⇩M ∘ q₀⇩M ∘ theG)) (ι⇩× (❙G φ) (semi_mojmir_def.initial ∘ q₀⇩M ∘ theG)) w) ∩ ?S' = {})›*) by (auto simp del: simple_product.simps (*‹?δ₁ × ?δ₂ = (λ(q₁, q₂) ν. (?δ₁ q₁ ν, ?δ₂ q₂ ν))›*) product.simps (*‹Δ⇩× ?δ⇩m = (λq ν x. case q x of None ⇒ None | Some y ⇒ Some (?δ⇩m x y ν))›*) product_initial_state.simps (*‹ι⇩× ?K ?q⇩m = (λk. if k ∈ ?K then Some (?q⇩m k) else None)›*) simp add: comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) cong del: SUP_cong_simp (*‹⟦?A = ?B; ⋀x. x ∈ ?B =simp=> ?C x = ?D x⟧ ⟹ Sup (?C ` ?A) = Sup (?D ` ?B)›*)) qed hence "limit r ∩ fst (Acc Σ π (G ψ)) = {} ∧ limit r ∩ snd (Acc Σ π (G ψ)) ≠ {} ⟷ limit r⇩ψ ∩ fst (𝔐.Acc⇩ℛ (the (π (G ψ)))) = {} ∧ limit r⇩ψ ∩ snd (𝔐.Acc⇩ℛ (the (π (G ψ)))) ≠ {}" unfolding fst_conv snd_conv (*goal: ‹(limit r ∩ Acc_fin Σ π (G ψ) = {} ∧ limit r ∩ Acc_inf π (G ψ) ≠ {}) = (limit r⇩ψ ∩ (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the (π (G ψ)))) = {} ∧ limit r⇩ψ ∩ 𝔐.succeed⇩R (the (π (G ψ))) ≠ {})›*) by simp thus "?Acc ⟷ ?Acc⇩ℛ" unfolding "r⇩ψ_def" r_def "accepting_pair⇩R_def" (*goal: ‹(limit (run⇩t (delta (Σ::'a set set)) (initial (φ::'a ltl)) (w::nat ⇒ 'a set)) ∩ fst (Acc Σ (π::'a ltl ⇒ nat option) (G (ψ::'a ltl))) = {} ∧ limit (run⇩t (delta Σ) (initial φ) w) ∩ snd (Acc Σ π (G ψ)) ≠ {}) = (limit (run⇩t 𝔐.δ⇩ℛ 𝔐.q⇩ℛ w) ∩ fst (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the (π (G ψ))), 𝔐.succeed⇩R (the (π (G ψ)))) = {} ∧ limit (run⇩t 𝔐.δ⇩ℛ 𝔐.q⇩ℛ w) ∩ snd (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the (π (G ψ))), 𝔐.succeed⇩R (the (π (G ψ)))) ≠ {})›*) by blast qed lemma Acc_to_rabin_accept: "⟦accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w; the (π (G ψ)) < 𝔐.max_rank⟧ ⟹ accept⇩R 𝔐.ℛ w" unfolding Acc_property (*goal: ‹⟦accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the (π (G ψ))), 𝔐.succeed⇩R (the (π (G ψ)))) w; the (π (G ψ)) < 𝔐.max_rank⟧ ⟹ accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w›*) by auto lemma Acc_to_mojmir_accept: "⟦accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w; the (π (G ψ)) < 𝔐.max_rank⟧ ⟹ 𝔐.accept" using Acc_to_rabin_accept (*‹⟦accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w; the (π (G ψ)) < 𝔐.max_rank⟧ ⟹ accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w›*) unfolding "𝔐.mojmir_accept_iff_rabin_accept" (*goal: ‹⟦accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w; the (π (G ψ)) < 𝔐.max_rank⟧ ⟹ accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w›*) by auto lemma rabin_accept_to_Acc: "⟦accept⇩R 𝔐.ℛ w; π (G ψ) = 𝔐.smallest_accepting_rank⟧ ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w" unfolding Acc_property "𝔐.Mojmir_rabin_smallest_accepting_rank" (*goal: ‹⟦accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w; π (G ψ) = 𝔐.smallest_accepting_rank⇩ℛ⟧ ⟹ accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the (π (G ψ))), 𝔐.succeed⇩R (the (π (G ψ)))) w›*) using "𝔐.smallest_accepting_rank⇩ℛ_properties" (*‹𝔐.smallest_accepting_rank⇩ℛ = Some ?i ⟹ accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R ?i, 𝔐.succeed⇩R ?i) w›*) "𝔐.smallest_accepting_rank⇩ℛ_def" (*‹𝔐.smallest_accepting_rank⇩ℛ ≡ if accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w then Some (LEAST i. accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R i, 𝔐.succeed⇩R i) w) else None›*) by (metis (no_types, lifting) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) lemma mojmir_accept_to_Acc: "⟦𝔐.accept; π (G ψ) = 𝔐.smallest_accepting_rank⟧ ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w" unfolding "𝔐.mojmir_accept_iff_rabin_accept" (*goal: ‹⟦accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w; π (G ψ) = 𝔐.smallest_accepting_rank⟧ ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w›*) by (blast dest: rabin_accept_to_Acc (*‹⟦accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w; π (G ψ) = 𝔐.smallest_accepting_rank⟧ ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ψ)) w›*)) end lemma normalize_π: assumes dom_subset: "dom π ⊆ ❙G φ" assumes "⋀χ. χ ∈ dom π ⟹ the (π χ) < max_rank_of Σ χ" assumes "accepting_pair⇩R (delta Σ) (initial φ) (M_fin π, UNIV) w" assumes "⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π χ) w" obtains π⇩𝒜 where "dom π = dom π⇩𝒜" and "⋀χ. χ ∈ dom π⇩𝒜 ⟹ π⇩𝒜 χ = mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w {q. dom π⇩𝒜 ↑⊨⇩P q}" and "accepting_pair⇩R (delta Σ) (initial φ) (M_fin π⇩𝒜, UNIV) w" and "⋀χ. χ ∈ dom π⇩𝒜 ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π⇩𝒜 χ) w" proof (-) (*goal: ‹(⋀π⇩𝒜::'a::type ltl ⇒ nat option. ⟦dom (π::'a::type ltl ⇒ nat option) = dom π⇩𝒜; ⋀χ::'a::type ltl. χ ∈ dom π⇩𝒜 ⟹ π⇩𝒜 χ = mojmir_def.smallest_accepting_rank (Σ::'a::type set set) (δ⇩M::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀⇩M::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) (theG χ)) (w::nat ⇒ 'a::type set) {q::'a::type ltl_prop_equiv_quotient. dom π⇩𝒜 ↑⊨⇩P q}; accepting_pair⇩R (delta Σ) (initial (φ::'a::type ltl)) ((M_fin::('a::type ltl ⇒ nat option) ⇒ (('a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a::type set × 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) set) π⇩𝒜, UNIV) w; ⋀χ::'a::type ltl. χ ∈ dom π⇩𝒜 ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π⇩𝒜 χ) w⟧ ⟹ thesis::bool) ⟹ thesis›*) define 𝒢 where "𝒢 = dom π" note "𝒢_properties"[OF dom_subset] (*‹finite (dom (π::'a ltl ⇒ nat option))› ‹Only_G (dom π)›*) define π⇩𝒜 where "π⇩𝒜 = (λχ. mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w {q. dom π ↑⊨⇩P q}) |` 𝒢" moreover { fix χ assume "χ ∈ dom π" (*‹(χ::'a ltl) ∈ dom (π::'a ltl ⇒ nat option)›*) interpret 𝔐: mojmir_to_rabin "Σ" "δ⇩M" "q₀⇩M (theG χ)" w "{q. dom π ↑⊨⇩P q}" by (metis mojmir_to_rabin (*‹Only_G ?𝒢 ⟹ mojmir_to_rabin Σ δ⇩M (q₀⇩M ?ψ) w {q. ?𝒢 ↑⊨⇩P q}›*) ‹dom π ⊆ ❙G φ› 𝒢_elements (*‹?𝒢 ⊆ ❙G ?φ ⟹ Only_G ?𝒢›*)) from ‹χ ∈ dom π› (*‹(χ::'a::type ltl) ∈ dom (π::'a::type ltl ⇒ nat option)›*) have "accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π χ) w" using assms(4) (*‹?χ7 ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π ?χ7) w›*) by blast hence "accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.Acc⇩ℛ (the (π χ))) w" by (metis ‹χ ∈ dom π› Acc_property[OF _ dom_subset] (*‹G ?ψ ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π (G ?ψ)) w = accepting_pair⇩R (semi_mojmir_def.step Σ δ⇩M (q₀⇩M ?ψ)) (semi_mojmir_def.initial (q₀⇩M ?ψ)) (mojmir_to_rabin_def.fail⇩R Σ δ⇩M (q₀⇩M ?ψ) {q. dom π ↑⊨⇩P q} ∪ mojmir_to_rabin_def.merge⇩R δ⇩M (q₀⇩M ?ψ) {q. dom π ↑⊨⇩P q} (the (π (G ?ψ))), mojmir_to_rabin_def.succeed⇩R δ⇩M (q₀⇩M ?ψ) {q. dom π ↑⊨⇩P q} (the (π (G ?ψ)))) w›*) ‹Only_G (dom π)› ltl.sel( (*‹theG (G ?x8.0) = ?x8.0›*) 8)) moreover hence "accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {𝔐.Acc⇩ℛ j | j. j < 𝔐.max_rank}) w" using assms(2)[OF ‹χ ∈ dom π›] (*‹the ((π::'a ltl ⇒ nat option) (χ::'a ltl)) < max_rank_of (Σ::'a set set) χ›*) unfolding max_rank_of_def (*goal: ‹accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w›*) by auto ultimately have "the (𝔐.smallest_accepting_rank⇩ℛ) ≤ the (π χ)" and "𝔐.smallest_accepting_rank ≠ None" using Least_le[of _ "the (π χ)"] (*‹?P (the (π χ)) ⟹ (LEAST x. ?P x) ≤ the (π χ)›*) assms(2)[OF ‹χ ∈ dom π›] (*‹the (π χ) < max_rank_of Σ χ›*) "𝔐.mojmir_accept_iff_rabin_accept" (*‹𝔐.accept = accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w›*) option.distinct(1) (*‹None ≠ Some ?x2.0›*) "𝔐.smallest_accepting_rank_def" (*‹𝔐.smallest_accepting_rank ≡ if 𝔐.accept then Some (LEAST i. finite 𝔐.fail ∧ finite (𝔐.merge i) ∧ infinite (𝔐.succeed i)) else None›*) apply - (*goals: 1. ‹⟦accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the ((π::'a::type ltl ⇒ nat option) (χ::'a::type ltl))), 𝔐.succeed⇩R (the (π χ))) (w::nat ⇒ 'a::type set); accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j::nat. j < 𝔐.max_rank}) w; ⋀P::nat ⇒ bool. P (the (π χ)) ⟹ (LEAST x::nat. P x) ≤ the (π χ); the (π χ) < max_rank_of (Σ::'a::type set set) χ; 𝔐.accept = accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j::nat. j < 𝔐.max_rank}) w; ⋀x2::?'a31::type. None ≠ Some x2; 𝔐.smallest_accepting_rank ≡ if 𝔐.accept then Some (LEAST i::nat. finite 𝔐.fail ∧ finite (𝔐.merge i) ∧ infinite (𝔐.succeed i)) else None⟧ ⟹ the 𝔐.smallest_accepting_rank⇩ℛ ≤ the (π χ)› 2. ‹⟦accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R (the ((π::'a::type ltl ⇒ nat option) (χ::'a::type ltl))), 𝔐.succeed⇩R (the (π χ))) (w::nat ⇒ 'a::type set); accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j::nat. j < 𝔐.max_rank}) w; ⋀P::nat ⇒ bool. P (the (π χ)) ⟹ (LEAST x::nat. P x) ≤ the (π χ); the (π χ) < max_rank_of (Σ::'a::type set set) χ; 𝔐.accept = accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j::nat. j < 𝔐.max_rank}) w; ⋀x2::?'a14::type. None ≠ Some x2; 𝔐.smallest_accepting_rank ≡ if 𝔐.accept then Some (LEAST i::nat. finite 𝔐.fail ∧ finite (𝔐.merge i) ∧ infinite (𝔐.succeed i)) else None⟧ ⟹ 𝔐.smallest_accepting_rank ≠ None› discuss goal 1*) apply (simp add: 𝔐.smallest_accepting_rank⇩ℛ_def (*‹𝔐.smallest_accepting_rank⇩ℛ ≡ if accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w then Some (LEAST i. accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R i, 𝔐.succeed⇩R i) w) else None›*)) (*discuss goal 2*) apply (simp add: 𝔐.smallest_accepting_rank⇩ℛ_def (*‹𝔐.smallest_accepting_rank⇩ℛ ≡ if accept⇩R (𝔐.δ⇩ℛ, 𝔐.q⇩ℛ, {(𝔐.fail⇩R ∪ 𝔐.merge⇩R j, 𝔐.succeed⇩R j) |j. j < 𝔐.max_rank}) w then Some (LEAST i. accepting_pair⇩R 𝔐.δ⇩ℛ 𝔐.q⇩ℛ (𝔐.fail⇩R ∪ 𝔐.merge⇩R i, 𝔐.succeed⇩R i) w) else None›*)) (*proven 2 subgoals*) . hence "the (π⇩𝒜 χ) ≤ the (π χ)" and "χ ∈ dom π⇩𝒜" unfolding "π⇩𝒜_def" dom_restrict (*goals: 1. ‹the (((λχ. mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w (Collect (ltl_prop_entails_abs (dom π)))) |` 𝒢) χ) ≤ the (π χ)› 2. ‹χ ∈ dom (λχ. mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w (Collect (ltl_prop_entails_abs (dom π)))) ∩ 𝒢›*) using assms(2) (*‹?χ7 ∈ dom π ⟹ the (π ?χ7) < max_rank_of Σ ?χ7›*) ‹χ ∈ dom π› (*‹χ ∈ dom π›*) apply - (*goals: 1. ‹⟦the 𝔐.smallest_accepting_rank⇩ℛ ≤ the ((π::'a ltl ⇒ nat option) (χ::'a ltl)); 𝔐.smallest_accepting_rank ≠ None; ⋀χ::'a ltl. χ ∈ dom π ⟹ the (π χ) < max_rank_of (Σ::'a set set) χ; χ ∈ dom π⟧ ⟹ the (((λχ::'a ltl. mojmir_def.smallest_accepting_rank Σ (δ⇩M::'a ltl_prop_equiv_quotient ⇒ 'a set ⇒ 'a ltl_prop_equiv_quotient) ((q₀⇩M::'a ltl ⇒ 'a ltl_prop_equiv_quotient) (theG χ)) (w::nat ⇒ 'a set) (Collect (ltl_prop_entails_abs (dom π)))) |` (𝒢::'a ltl set)) χ) ≤ the (π χ)› 2. ‹⟦the 𝔐.smallest_accepting_rank⇩ℛ ≤ the ((π::'a ltl ⇒ nat option) (χ::'a ltl)); 𝔐.smallest_accepting_rank ≠ None; ⋀χ::'a ltl. χ ∈ dom π ⟹ the (π χ) < max_rank_of (Σ::'a set set) χ; χ ∈ dom π⟧ ⟹ χ ∈ dom (λχ::'a ltl. mojmir_def.smallest_accepting_rank Σ (δ⇩M::'a ltl_prop_equiv_quotient ⇒ 'a set ⇒ 'a ltl_prop_equiv_quotient) ((q₀⇩M::'a ltl ⇒ 'a ltl_prop_equiv_quotient) (theG χ)) (w::nat ⇒ 'a set) (Collect (ltl_prop_entails_abs (dom π)))) ∩ (𝒢::'a ltl set)› discuss goal 1*) apply (simp add: 𝔐.Mojmir_rabin_smallest_accepting_rank (*‹𝔐.smallest_accepting_rank = 𝔐.smallest_accepting_rank⇩ℛ›*) 𝒢_def (*‹𝒢 = dom π›*)) (*discuss goal 2*) apply (subst dom_def (*‹dom ?m = {a. ?m a ≠ None}›*)) (*goal: ‹⟦the 𝔐.smallest_accepting_rank⇩ℛ ≤ the (π χ); 𝔐.smallest_accepting_rank ≠ None; ⋀χ. χ ∈ dom π ⟹ the (π χ) < max_rank_of Σ χ; χ ∈ dom π⟧ ⟹ χ ∈ dom (λχ. mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w (Collect (ltl_prop_entails_abs (dom π)))) ∩ 𝒢›*) apply (simp add: 𝒢_def (*‹𝒢 = dom π›*)) (*proven 2 subgoals*) . } hence "dom π = dom π⇩𝒜" unfolding "π⇩𝒜_def" dom_restrict "𝒢_def" (*goal: ‹dom π = dom (λχ. mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w (Collect (ltl_prop_entails_abs (dom π)))) ∩ dom π›*) by auto moreover note "𝒢_properties"[OF dom_subset, unfolded ‹dom π = dom π⇩𝒜›] (*‹finite (dom π⇩𝒜)› ‹Only_G (dom (π⇩𝒜::'a ltl ⇒ nat option))›*) have "M_fin π⇩𝒜 ⊆ M_fin π" using ‹dom π = dom π⇩𝒜› (*‹dom (π::'a ltl ⇒ nat option) = dom (π⇩𝒜::'a ltl ⇒ nat option)›*) by (simp add: M_fin_monotonic (*‹⟦dom ?π = dom ?π'; ⋀χ. χ ∈ dom ?π ⟹ the (?π χ) ≤ the (?π' χ)⟧ ⟹ M_fin ?π ⊆ M_fin ?π'›*) ‹⋀χ. χ ∈ dom π ⟹ the (π⇩𝒜 χ) ≤ the (π χ)›) hence "accepting_pair⇩R (delta Σ) (initial φ) (M_fin π⇩𝒜, UNIV) w" using assms (*‹dom π ⊆ ❙G φ› ‹(?χ7::'a::type ltl) ∈ dom (π::'a::type ltl ⇒ nat option) ⟹ the (π ?χ7) < max_rank_of (Σ::'a::type set set) ?χ7› ‹accepting_pair⇩R (delta Σ) (initial φ) (M_fin π, UNIV) w› ‹?χ7 ∈ dom π ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π ?χ7) w›*) unfolding "accepting_pair⇩R_simp" (*goal: ‹limit (run⇩t (delta (Σ::'a set set)) (initial (φ::'a ltl)) (w::nat ⇒ 'a set)) ∩ (M_fin::('a ltl ⇒ nat option) ⇒ (('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) set) (π⇩𝒜::'a ltl ⇒ nat option) = {} ∧ limit (run⇩t (delta Σ) (initial φ) w) ∩ UNIV ≠ {}›*) by blast moreover { fix χ assume "χ ∈ dom π⇩𝒜" (*‹(χ::'a ltl) ∈ dom (π⇩𝒜::'a ltl ⇒ nat option)›*) hence "χ = G (theG χ)" unfolding ‹dom π = dom π⇩𝒜›[symmetric] ‹Only_G (dom π)› (*goal: ‹χ = G theG χ›*) by (metis ‹Only_G (dom π⇩𝒜)› ‹χ ∈ dom π⇩𝒜› ltl.collapse( (*‹is_LTLGlobal ?ltl ⟹ G theG ?ltl = ?ltl›*) 6) ltl.disc( (*‹is_LTLGlobal (G ?x8.0)›*) 58)) moreover hence "G (theG χ) ∈ dom π⇩𝒜" using ‹χ ∈ dom π⇩𝒜› (*‹χ ∈ dom π⇩𝒜›*) by simp moreover hence X: "mojmir_def.accept δ⇩M (q₀⇩M (theG χ)) w {q. dom π ↑⊨⇩P q}" using assms(1,2,4) (*‹dom π ⊆ ❙G φ› ‹?χ7 ∈ dom π ⟹ the (π ?χ7) < max_rank_of Σ ?χ7› ‹(?χ7::'a::type ltl) ∈ dom (π::'a::type ltl ⇒ nat option) ⟹ accepting_pair⇩R (delta (Σ::'a::type set set)) (initial (φ::'a::type ltl)) (Acc Σ π ?χ7) (w::nat ⇒ 'a::type set)›*) ‹dom π ⊆ ❙G φ› (*‹dom π ⊆ ❙G φ›*) ltl.sel(8) (*‹theG (G ?x8.0) = ?x8.0›*) Acc_to_mojmir_accept (*‹⟦G (?ψ::'a::type ltl) ∈ dom (?π::'a::type ltl ⇒ nat option); dom ?π ⊆ ❙G (φ::'a::type ltl); accepting_pair⇩R (delta (Σ::'a::type set set)) (initial φ) (Acc Σ ?π (G ?ψ)) (w::nat ⇒ 'a::type set); the (?π (G ?ψ)) < semi_mojmir_def.max_rank Σ (δ⇩M::'a::type ltl_prop_equiv_quotient ⇒ 'a::type set ⇒ 'a::type ltl_prop_equiv_quotient) ((q₀⇩M::'a::type ltl ⇒ 'a::type ltl_prop_equiv_quotient) ?ψ)⟧ ⟹ mojmir_def.accept δ⇩M (q₀⇩M ?ψ) w {q::'a::type ltl_prop_equiv_quotient. dom ?π ↑⊨⇩P q}›*) ‹dom π = dom π⇩𝒜› (*‹dom π = dom π⇩𝒜›*) by (metis max_rank_of_def (*‹max_rank_of ?Σ ?ψ ≡ semi_mojmir_def.max_rank ?Σ δ⇩M (q₀⇩M (theG ?ψ))›*)) have Y: "π⇩𝒜 (G theG χ) = mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w {q. dom π⇩𝒜 ↑⊨⇩P q}" using ‹G (theG χ) ∈ dom π⇩𝒜› (*‹G theG χ ∈ dom π⇩𝒜›*) ‹χ = G (theG χ)› (*‹χ = G theG χ›*) "π⇩𝒜_def" (*‹π⇩𝒜 = (λχ. mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w {q. dom π ↑⊨⇩P q}) |` 𝒢›*) ‹dom π = dom π⇩𝒜›[symmetric] (*‹dom (π⇩𝒜::'a ltl ⇒ nat option) = dom (π::'a ltl ⇒ nat option)›*) by simp ultimately have "accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π⇩𝒜 χ) w" using mojmir_accept_to_Acc[OF ‹G (theG χ) ∈ dom π⇩𝒜› ‹dom π ⊆ ❙G φ› [ unfolded ‹dom π = dom π⇩𝒜› ] X [ unfolded ‹dom π = dom π⇩𝒜› ] Y] (*‹accepting_pair⇩R (delta (Σ::'a set set)) (initial (φ::'a ltl)) (Acc Σ (π⇩𝒜::'a ltl ⇒ nat option) (G theG (χ::'a ltl))) (w::nat ⇒ 'a set)›*) by simp } ultimately show "?thesis" (*goal: ‹thesis›*) using that[of π⇩𝒜] (*‹⟦dom π = dom π⇩𝒜; ⋀χ. χ ∈ dom π⇩𝒜 ⟹ π⇩𝒜 χ = mojmir_def.smallest_accepting_rank Σ δ⇩M (q₀⇩M (theG χ)) w {q. dom π⇩𝒜 ↑⊨⇩P q}; accepting_pair⇩R (delta Σ) (initial φ) (M_fin π⇩𝒜, UNIV) w; ⋀χ. χ ∈ dom π⇩𝒜 ⟹ accepting_pair⇩R (delta Σ) (initial φ) (Acc Σ π⇩𝒜 χ) w⟧ ⟹ thesis›*) restrict_in (*‹(?x::?'a) ∈ (?A::?'a set) ⟹ ((?m::?'a ⇒ ?'b option) |` ?A) ?x = ?m ?x›*) unfolding ‹dom π = dom π⇩𝒜› "𝒢_def" (*goal: ‹thesis›*) by (metis (no_types, lifting)) qed end end subsection ‹Generalized Deterministic Rabin Automaton› ― ‹Instantiate Automaton Template› subsubsection ‹Definition› fun M_fin :: "('a ltl ⇀ nat) ⇒ ('a ltl⇩P × ('a ltl ⇀ 'a ltl⇩P ⇀ nat), 'a set) transition set" where "M_fin π = {((φ', m), ν, p). ¬(∀S. (∀χ ∈ dom π. S ↑⊨⇩P Abs χ ∧ (∀q. (∃j ≥ the (π χ). the (m χ) q = Some j) ⟶ S ↑⊨⇩P ↑eval⇩G (dom π) q)) ⟶ S ↑⊨⇩P φ')}" locale ltl_to_rabin_af = ltl_to_rabin_base "↑af" "↑af⇩G" "Abs" "Abs" M_fin begin abbreviation "δ⇩𝒜 ≡ delta" abbreviation "ι⇩𝒜 ≡ initial" abbreviation "Acc⇩𝒜 ≡ Acc" abbreviation "F⇩𝒜 ≡ rabin_pairs" abbreviation "𝒜 ≡ ltl_to_generalized_rabin" subsubsection ‹Correctness Theorem› theorem ltl_to_generalized_rabin_correct: "w ⊨ φ = accept⇩G⇩R (ltl_to_generalized_rabin Σ φ) w" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹w ⊨ φ ⟹ accept⇩G⇩R (𝒜 Σ φ) w› 2. ‹accept⇩G⇩R (𝒜 Σ φ) w ⟹ w ⊨ φ›*) let ?Δ = "δ⇩𝒜 Σ" let ?q₀ = "ι⇩𝒜 φ" let ?F = "F⇩𝒜 Σ φ" define r where "r = run⇩t ?Δ ?q₀ w" have r_alt_def': "⋀i. fst (fst (r i)) = Abs (af φ (w [0 → i]))" using run_properties(1) (*‹fst (run (δ⇩𝒜 Σ) (ι⇩𝒜 ?φ) w ?i) = foldl ↑af (Abs ?φ) (prefix ?i w)›*) unfolding r_def "run⇩t.simps" fst_conv (*goal: ‹⋀i. fst (run (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w i) = Abs (af φ (prefix i w))›*) by (metis af_abs.f_foldl_abs.abs_eq (*‹af_abs.f_foldl_abs (Abs ?xa) ?x = Abs (af ?xa ?x)›*) af_abs.f_foldl_abs_alt_def (*‹af_abs.f_foldl_abs (Abs ?φ) ?w = foldl af_abs.f_abs (Abs ?φ) ?w›*) af_letter_abs_def (*‹↑af ≡ af_abs.f_abs›*)) have r_alt_def'': "⋀χ i q. χ ∈ ❙G φ ⟹ the (snd (fst (r i)) χ) q = semi_mojmir_def.state_rank Σ ↑af⇩G(Abs (theG χ)) w q i" using run_properties(2) (*‹(?χ::'a ltl) ∈ ❙G (?φ::'a ltl) ⟹ the (snd (run (δ⇩𝒜 (Σ::'a set set)) (ι⇩𝒜 ?φ) (w::nat ⇒ 'a set) (?i::nat)) ?χ) (?q::'a ltl_prop_equiv_quotient) = semi_mojmir_def.state_rank Σ ↑af⇩G (Abs (theG ?χ)) w ?q ?i›*) r_def (*‹r = run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w›*) by force have "φ'_def": "⋀i. af φ (w [0 → i]) ≡⇩P Rep (fst (fst (r i)))" by (metis r_alt_def' (*‹fst (fst (r ?i8)) = Abs (af φ (prefix ?i8 w))›*) Quotient3_ltl_prop_equiv_quotient (*‹Quotient3 (≡⇩P) Abs Rep›*) ltl_prop_equiv_quotient.abs_eq_iff (*‹(Abs ?x = Abs ?y) = ?x ≡⇩P ?y›*) Quotient3_abs_rep (*‹Quotient3 ?R ?Abs ?Rep ⟹ ?Abs (?Rep ?a) = ?a›*)) have "finite (range r)" using "run⇩t_finite"[OF finite_reach] (*‹⟦finite Σ; range ?w ⊆ Σ⟧ ⟹ finite (range (run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 ?φ1) ?w))›*) bounded_w (*‹range (w::nat ⇒ 'a set) ⊆ (Σ::'a set set)›*) "finite_Σ" (*‹finite Σ›*) by (simp add: r_def (*‹r = run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w›*)) { assume "?lhs" (*‹(w::nat ⇒ 'a set) ⊨ (φ::'a ltl)›*) then obtain 𝒢 where "𝒢 ⊆ ❙G φ" and "accept⇩M φ 𝒢 w" and "closed 𝒢 w" (*goal: ‹(⋀𝒢. ⟦𝒢 ⊆ ❙G φ; accept⇩M φ 𝒢 w; closed 𝒢 w⟧ ⟹ thesis) ⟹ thesis›*) unfolding ltl_logical_characterization (*goal: ‹(⋀𝒢. ⟦𝒢 ⊆ ❙G φ; accept⇩M φ 𝒢 w; closed 𝒢 w⟧ ⟹ thesis) ⟹ thesis›*) by blast note "𝒢_properties"[OF ‹𝒢 ⊆ ❙G φ›] (*‹finite (𝒢::'a ltl set)› ‹Only_G 𝒢›*) hence "ltl_FG_to_rabin Σ 𝒢 w" using "finite_Σ" (*‹finite Σ›*) bounded_w (*‹range (w::nat ⇒ 'a set) ⊆ (Σ::'a set set)›*) unfolding ltl_FG_to_rabin_def (*goal: ‹Only_G (𝒢::'a ltl set) ∧ range (w::nat ⇒ 'a set) ⊆ (Σ::'a set set) ∧ finite Σ›*) by auto define π where "π χ = (if χ ∈ 𝒢 then (ltl_FG_to_rabin_def.smallest_accepting_rank⇩R Σ (theG χ) 𝒢 w) else None)" for χ have "𝔐_accept": "⋀ψ. G ψ ∈ 𝒢 ⟹ ltl_FG_to_rabin_def.accept⇩R' ψ 𝒢 w" using ‹closed 𝒢 w› (*‹closed (𝒢::'a::type ltl set) (w::nat ⇒ 'a::type set)›*) ‹ltl_FG_to_rabin Σ 𝒢 w› (*‹ltl_FG_to_rabin (Σ::'a set set) (𝒢::'a ltl set) (w::nat ⇒ 'a set)›*) ltl_FG_to_rabin.ltl_to_rabin_correct_exposed' (*‹ltl_FG_to_rabin ?Σ ?𝒢 ?w ⟹ 𝔓⇩∞ ?φ ?𝒢 ?w = mojmir_def.accept ↑af⇩G (Abs ?φ) ?w {q. ?𝒢 ⊨⇩P Rep q}›*) by blast have "⋀ψ. G ψ ∈ 𝒢 ⟹ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w" using ‹closed 𝒢 w› (*‹closed (𝒢::'a::type ltl set) (w::nat ⇒ 'a::type set)›*) unfolding ltl_FG_to_rabin.ltl_to_rabin_correct_exposed[OF ‹ltl_FG_to_rabin Σ 𝒢 w›] (*goal: ‹⋀ψ. G ψ ∈ 𝒢 ⟹ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›*) by simp { fix ψ assume "G ψ ∈ 𝒢" (*‹G (ψ::'a ltl) ∈ (𝒢::'a ltl set)›*) interpret 𝔐: ltl_FG_to_rabin "Σ" "ψ" "𝒢" w by (insert ‹ltl_FG_to_rabin Σ 𝒢 w›) obtain i where "𝔐.smallest_accepting_rank = Some i" (*goal: ‹(⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ thesis) ⟹ thesis›*) using "𝔐_accept"[OF ‹G ψ ∈ 𝒢›] (*‹𝔐.accept⇩R'›*) unfolding "𝔐.smallest_accepting_rank_def" (*goal: ‹(⋀i. (if 𝔐.accept⇩R' then Some (LEAST i. finite 𝔐.fail ∧ finite (𝔐.merge i) ∧ infinite (𝔐.succeed i)) else None) = Some i ⟹ thesis) ⟹ thesis›*) by fastforce hence "the (π (G ψ)) < 𝔐.max_rank" and "π (G ψ) ≠ None" using "𝔐.smallest_accepting_rank_properties" (*‹𝔐.smallest_accepting_rank⇩R = Some (?i::nat) ⟹ 𝔐.accept⇩R'› ‹𝔐.smallest_accepting_rank⇩R = Some ?i ⟹ finite 𝔐.fail› ‹𝔐.smallest_accepting_rank⇩R = Some ?i ⟹ finite (𝔐.merge ?i)› ‹𝔐.smallest_accepting_rank⇩R = Some ?i ⟹ infinite (𝔐.succeed ?i)› ‹𝔐.smallest_accepting_rank⇩R = Some ?i ⟹ ∀j<?i. finite (𝔐.succeed j)› ‹𝔐.smallest_accepting_rank⇩R = Some ?i ⟹ ?i < 𝔐.max_rank⇩R›*) ‹G ψ ∈ 𝒢› (*‹G ψ ∈ 𝒢›*) unfolding "π_def" (*goals: 1. ‹the (if G ψ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG (G ψ))) w {q. 𝒢 ⊨⇩P Rep q} else None) < 𝔐.max_rank⇩R› 2. ‹(if G ψ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG (G ψ))) w {q. 𝒢 ⊨⇩P Rep q} else None) ≠ None›*) apply - (*goals: 1. ‹⟦𝔐.smallest_accepting_rank⇩R = Some i; ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ 𝔐.accept⇩R'; ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ finite 𝔐.fail; ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ finite (𝔐.merge i); ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ infinite (𝔐.succeed i); ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ ∀j<i. finite (𝔐.succeed j); ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ i < 𝔐.max_rank⇩R; G ψ ∈ 𝒢⟧ ⟹ the (if G ψ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG (G ψ))) w {q. 𝒢 ⊨⇩P Rep q} else None) < 𝔐.max_rank⇩R› 2. ‹⟦𝔐.smallest_accepting_rank⇩R = Some i; ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ 𝔐.accept⇩R'; ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ finite 𝔐.fail; ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ finite (𝔐.merge i); ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ infinite (𝔐.succeed i); ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ ∀j<i. finite (𝔐.succeed j); ⋀i. 𝔐.smallest_accepting_rank⇩R = Some i ⟹ i < 𝔐.max_rank⇩R; G ψ ∈ 𝒢⟧ ⟹ (if G ψ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG (G ψ))) w {q. 𝒢 ⊨⇩P Rep q} else None) ≠ None› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . } hence "𝒢 = dom π" and "⋀χ. χ ∈ 𝒢 ⟹ the (π χ) < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ)" using ‹Only_G 𝒢› (*‹Only_G 𝒢›*) "π_def" (*‹π ?χ = (if ?χ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG ?χ)) w {q. 𝒢 ⊨⇩P Rep q} else None)›*) unfolding dom_def (*goals: 1. ‹𝒢 = {a. π a ≠ None}› 2. ‹⋀χ. χ ∈ 𝒢 ⟹ the (π χ) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ))›*) apply - (*goals: 1. ‹⟦⋀ψ. G ψ ∈ 𝒢 ⟹ the (π (G ψ)) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs ψ); ⋀ψ. G ψ ∈ 𝒢 ⟹ π (G ψ) ≠ None; Only_G 𝒢; ⋀χ. π χ = (if χ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG χ)) w {q. 𝒢 ⊨⇩P Rep q} else None)⟧ ⟹ 𝒢 = {a. π a ≠ None}› 2. ‹⋀χ. ⟦χ ∈ 𝒢; ⋀ψ. G ψ ∈ 𝒢 ⟹ the (π (G ψ)) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs ψ); ⋀ψ. G ψ ∈ 𝒢 ⟹ π (G ψ) ≠ None; Only_G 𝒢; ⋀χ. π χ = (if χ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG χ)) w {q. 𝒢 ⊨⇩P Rep q} else None)⟧ ⟹ the (π χ) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "(M_fin π ∪ ⋃{Acc_fin Σ π χ | χ. χ ∈ dom π}, {Acc_inf π χ | χ. χ ∈ dom π}) ∈ ?F" using ‹𝒢 ⊆ ❙G φ› (*‹(𝒢::'a ltl set) ⊆ ❙G (φ::'a ltl)›*) max_rank_of_def (*‹max_rank_of (?Σ::'a set set) (?ψ::'a ltl) ≡ semi_mojmir_def.max_rank ?Σ ↑af⇩G (Abs (theG ?ψ))›*) by auto moreover { have "accepting_pair⇩R ?Δ ?q₀ (M_fin π, UNIV) w" proof (-) (*goal: ‹accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π, UNIV) w›*) obtain i where i_def: "⋀j. j ≥ i ⟹ ∀S. (∀ψ. G ψ ∈ 𝒢 ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)) ⟶ S ⊨⇩P af φ (w [0 → j])" (*goal: ‹(⋀i. (⋀j. i ≤ j ⟹ ∀S. (∀ψ. G ψ ∈ 𝒢 ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)) ⟶ S ⊨⇩P af φ (prefix j w)) ⟹ thesis) ⟹ thesis›*) using ‹accept⇩M φ 𝒢 w› (*‹accept⇩M φ 𝒢 w›*) unfolding MOST_nat_le "accept⇩M_def" (*goal: ‹(⋀i. (⋀j. i ≤ j ⟹ ∀S. (∀ψ. G ψ ∈ 𝒢 ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)) ⟶ S ⊨⇩P af φ (prefix j w)) ⟹ thesis) ⟹ thesis›*) by blast obtain i' where i'_def: "⋀j ψ S. j ≥ i' ⟹ G ψ ∈ 𝒢 ⟹ (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ ltl_FG_to_rabin_def.𝒮⇩R Σ ψ 𝒢 w j ⟶ S ⊨⇩P Rep q)" (*goal: ‹(⋀i'. (⋀j ψ S. ⟦i' ≤ j; G ψ ∈ 𝒢⟧ ⟹ (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q)) ⟹ thesis) ⟹ thesis›*) using "ℱ_eq_𝒮_generalized"[OF finite_Σ bounded_w ‹closed 𝒢 w›] (*‹∀⇩∞j. ∀ψ. G ψ ∈ 𝒢 ⟶ (∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q))›*) unfolding MOST_nat_le (*goal: ‹(⋀i'::nat. (⋀(j::nat) (ψ::'a ltl) S::'a ltl set. ⟦i' ≤ j; G ψ ∈ (𝒢::'a ltl set)⟧ ⟹ (S ⊨⇩P ℱ ψ (w::nat ⇒ 'a set) 𝒢 j ∧ 𝒢 ⊆ S) = (∀q::'a ltl_prop_equiv_quotient. q ∈ mojmir_def.𝒮 (Σ::'a set set) ↑af⇩G (Abs ψ) w {q::'a ltl_prop_equiv_quotient. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q)) ⟹ thesis::bool) ⟹ thesis›*) by presburger have "⋀j. j ≥ max i i' ⟹ r j ∉ M_fin π" proof (-) (*goal: ‹⋀j. max i i' ≤ j ⟹ r j ∉ M_fin π›*) fix j assume "j ≥ max i i'" (*‹max (i::nat) (i'::nat) ≤ (j::nat)›*) let ?φ' = "fst (fst (r j))" let ?m = "snd (fst (r j))" { fix S assume "⋀χ. χ ∈ 𝒢 ⟹ S ↑⊨⇩P Abs χ" (*‹(?χ8::'a ltl) ∈ (𝒢::'a ltl set) ⟹ S::'a ltl set ↑⊨⇩P Abs ?χ8›*) hence assm1: "⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ" using ltl_prop_entails_abs.abs_eq (*‹?xa ↑⊨⇩P Abs ?x = ?xa ⊨⇩P ?x›*) by blast assume "⋀χ. χ ∈ 𝒢 ⟹ ∀q. (∃j ≥ the (π χ). the (?m χ) q = Some j) ⟶ S ↑⊨⇩P ↑eval⇩G 𝒢 q" (*‹(?χ8::'a ltl) ∈ (𝒢::'a ltl set) ⟹ ∀q::'a ltl_prop_equiv_quotient. (∃ja≥the ((π::'a ltl ⇒ nat option) ?χ8). the (snd (fst ((r::nat ⇒ ('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) (j::nat))) ?χ8) q = Some ja) ⟶ S::'a ltl set ↑⊨⇩P ↑eval⇩G 𝒢 q›*) hence assm2: "⋀χ. χ ∈ 𝒢 ⟹ ∀q. (∃j ≥ the (π χ). the (?m χ) q = Some j) ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q)" unfolding ltl_prop_entails_abs.rep_eq "eval⇩G_abs_def" (*goal: ‹⋀χ. χ ∈ 𝒢 ⟹ ∀q. (∃ja≥the (π χ). the (snd (fst (r j)) χ) q = Some ja) ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q)›*) by simp { fix ψ assume "G ψ ∈ 𝒢" (*‹G (ψ::'a ltl) ∈ (𝒢::'a ltl set)›*) hence "G ψ ∈ ❙G φ" and "𝒢 ⊆ S" using ‹𝒢 ⊆ ❙G φ› (*‹𝒢 ⊆ ❙G φ›*) assm1 (*‹?χ8 ∈ 𝒢 ⟹ S ⊨⇩P ?χ8›*) ‹Only_G 𝒢› (*‹Only_G 𝒢›*) apply - (*goals: 1. ‹⟦G (ψ::'a ltl) ∈ (𝒢::'a ltl set); 𝒢 ⊆ ❙G (φ::'a ltl); ⋀χ::'a ltl. χ ∈ 𝒢 ⟹ (S::'a ltl set) ⊨⇩P χ; Only_G 𝒢⟧ ⟹ G ψ ∈ ❙G φ› 2. ‹⟦G (ψ::'a ltl) ∈ (𝒢::'a ltl set); 𝒢 ⊆ ❙G (φ::'a ltl); ⋀χ::'a ltl. χ ∈ 𝒢 ⟹ (S::'a ltl set) ⊨⇩P χ; Only_G 𝒢⟧ ⟹ 𝒢 ⊆ S› discuss goal 1*) apply blast (*discuss goal 2*) apply force (*proven 2 subgoals*) . interpret 𝔐: ltl_FG_to_rabin "Σ" "ψ" "𝒢" w apply unfold_locales (*goals: 1. ‹Only_G 𝒢› 2. ‹range w ⊆ Σ› 3. ‹finite Σ› discuss goal 1*) apply (insert ‹Only_G 𝒢› finite_Σ (*‹finite Σ›*) bounded_w (*‹range w ⊆ Σ›*)) (*top goal: ‹Only_G 𝒢› and 2 goals remain*) apply blast (*discuss goal 2*) apply (insert ‹Only_G 𝒢› finite_Σ (*‹finite Σ›*) bounded_w (*‹range w ⊆ Σ›*)) (*top goal: ‹⟦Only_G 𝒢; finite Σ; range w ⊆ Σ⟧ ⟹ range w ⊆ Σ› and 1 goal remains*) apply blast (*discuss goal 3*) apply (insert ‹Only_G 𝒢› finite_Σ (*‹finite Σ›*) bounded_w (*‹range w ⊆ Σ›*)) (*goal: ‹⟦Only_G 𝒢; finite Σ; range w ⊆ Σ; Only_G 𝒢; finite Σ; range w ⊆ Σ⟧ ⟹ finite Σ›*) apply blast (*proven 3 subgoals*) . have "⋀S. (⋀q. q ∈ 𝔐.𝒮 j ⟹ S ⊨⇩P Rep q) ⟹ S ⊨⇩P ℱ ψ w 𝒢 j" using i'_def (*‹⟦i' ≤ ?j8; G ?ψ8 ∈ 𝒢⟧ ⟹ (?S8 ⊨⇩P ℱ ?ψ8 w 𝒢 ?j8 ∧ 𝒢 ⊆ ?S8) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ?ψ8) w {q. 𝒢 ⊨⇩P Rep q} ?j8 ⟶ ?S8 ⊨⇩P Rep q)›*) ‹G ψ ∈ 𝒢› (*‹G ψ ∈ 𝒢›*) ‹j ≥ max i i'› (*‹max i i' ≤ j›*) max.bounded_iff (*‹(max ?b ?c ≤ ?a) = (?b ≤ ?a ∧ ?c ≤ ?a)›*) by metis hence "⋀S. (⋀q. q ∈ Rep ` 𝔐.𝒮 j ⟹ S ⊨⇩P q) ⟹ S ⊨⇩P ℱ ψ w 𝒢 j" by simp moreover have "𝒮_def": "𝔐.𝒮 j = {q. 𝒢 ⊨⇩P Rep q} ∪ {q . ∃j'. the (π (G ψ)) ≤ j' ∧ the (?m (G ψ)) q = Some j'}" using r_alt_def''[OF ‹G ψ ∈ ❙G φ›, unfolded ltl.sel, of j] (*‹the (snd (fst (r j)) (G ψ)) ?q8 = 𝔐.state_rank ?q8 j›*) ‹G ψ ∈ 𝒢› (*‹G ψ ∈ 𝒢›*) by (simp add: π_def (*‹π ?χ = (if ?χ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG ?χ)) w {q. 𝒢 ⊨⇩P Rep q} else None)›*)) have "⋀q. 𝒢 ⊨⇩P Rep q ⟹ S ⊨⇩P eval⇩G 𝒢 (Rep q)" using ‹𝒢 ⊆ S› (*‹(𝒢::'a ltl set) ⊆ (S::'a ltl set)›*) "eval⇩G_prop_entailment" (*‹?S ⊨⇩P eval⇩G ?S ?φ = ?S ⊨⇩P ?φ›*) by blast hence "⋀q. q ∈ Rep ` 𝔐.𝒮 j ⟹ S ⊨⇩P eval⇩G 𝒢 q" using assm2 (*‹?χ8 ∈ 𝒢 ⟹ ∀q. (∃ja≥the (π ?χ8). the (snd (fst (r j)) ?χ8) q = Some ja) ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q)›*) ‹G ψ ∈ 𝒢› (*‹G (ψ::'a::type ltl) ∈ (𝒢::'a::type ltl set)›*) unfolding "𝒮_def" (*goal: ‹⋀q. q ∈ Rep ` ({q. 𝒢 ⊨⇩P Rep q} ∪ {q. ∃j'≥the (π (G ψ)). the (snd (fst (r j)) (G ψ)) q = Some j'}) ⟹ S ⊨⇩P eval⇩G 𝒢 q›*) by auto ultimately have "S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)" apply (rule eval⇩G_respectfulness_generalized (*‹⟦⋀𝒜. (⋀x. x ∈ ?S ⟹ 𝒜 ⊨⇩P x) ⟹ 𝒜 ⊨⇩P ?y; ⋀x. x ∈ ?S ⟹ ?𝒜 ⊨⇩P eval⇩G ?P x⟧ ⟹ ?𝒜 ⊨⇩P eval⇩G ?P ?y›*)) (*goals: 1. ‹⋀𝒜 q. ⟦⋀x. x ∈ ?S ⟹ 𝒜 ⊨⇩P x; q ∈ Rep ` 𝔐.𝒮⇩R j⟧ ⟹ 𝒜 ⊨⇩P q› 2. ‹⋀x. x ∈ ?S ⟹ x ∈ Rep ` 𝔐.𝒮⇩R j› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) } hence "S ⊨⇩P af φ (w [0 → j])" by (metis max.bounded_iff (*‹(max (?b::?'a) (?c::?'a) ≤ (?a::?'a)) = (?b ≤ ?a ∧ ?c ≤ ?a)›*) i_def (*‹(i::nat) ≤ (?j8::nat) ⟹ ∀S::'a ltl set. (∀ψ::'a ltl. G ψ ∈ (𝒢::'a ltl set) ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ (w::nat ⇒ 'a set) 𝒢 ?j8)) ⟶ S ⊨⇩P af (φ::'a ltl) (prefix ?j8 w)›*) ‹j ≥ max i i'› ‹⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ›) hence "S ⊨⇩P Rep ?φ'" using "φ'_def" (*‹af φ (prefix ?i8 w) ≡⇩P Rep (fst (fst (r ?i8)))›*) ltl_prop_equiv_def (*‹?φ ≡⇩P ?ψ ≡ ∀𝒜. 𝒜 ⊨⇩P ?φ = 𝒜 ⊨⇩P ?ψ›*) by blast hence "S ↑⊨⇩P ?φ'" using ltl_prop_entails_abs.rep_eq (*‹?x::?'a ltl set ↑⊨⇩P ?xa::?'a ltl_prop_equiv_quotient = ?x ⊨⇩P Rep ?xa›*) by blast } thus "r j ∉ M_fin π" using ‹⋀χ. χ ∈ 𝒢 ⟹ the (π χ) < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ)› (*‹?χ ∈ 𝒢 ⟹ the (π ?χ) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG ?χ))›*) ‹𝒢 = dom π› (*‹𝒢 = dom π›*) by fastforce qed hence "range (suffix (max i i') r) ∩ M_fin π = {}" unfolding suffix_def (*goal: ‹range (λn::nat. (r::nat ⇒ ('a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a::type set × 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) (max (i::nat) (i'::nat) + n)) ∩ M_fin (π::'a::type ltl ⇒ nat option) = {}›*) by (blast intro: le_add1 (*‹(?n::nat) ≤ ?n + (?m::nat)›*) elim: rangeE (*‹⟦(?b::?'a) ∈ range (?f::?'b ⇒ ?'a); ⋀x::?'b. ?b = ?f x ⟹ ?P::bool⟧ ⟹ ?P›*)) hence "limit r ∩ M_fin π = {}" using limit_in_range_suffix[of r] (*‹limit r ⊆ range (suffix ?k r)›*) by blast moreover have "limit r ∩ UNIV ≠ {}" using ‹finite (range r)› (*‹finite (range r)›*) apply simp (*goal: ‹limit (r::nat ⇒ ('a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a::type set × 'a::type ltl_prop_equiv_quotient × ('a::type ltl ⇒ ('a::type ltl_prop_equiv_quotient ⇒ nat option) option)) ∩ UNIV ≠ {}›*) by (metis empty_iff (*‹(?c ∈ {}) = False›*) limit_nonemptyE (*‹⟦finite (range ?x); ⋀x. x ∈ limit ?x ⟹ ?Q⟧ ⟹ ?Q›*)) ultimately show "?thesis" (*goal: ‹accepting_pair⇩R (δ⇩𝒜 (Σ::'a set set)) (ι⇩𝒜 (φ::'a ltl)) (M_fin (π::'a ltl ⇒ nat option), UNIV) (w::nat ⇒ 'a set)›*) unfolding r_def "accepting_pair⇩R_simp" (*goal: ‹limit (run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w) ∩ M_fin π = {} ∧ limit (run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w) ∩ UNIV ≠ {}›*) by standard qed moreover have "⋀χ. χ ∈ 𝒢 ⟹ accepting_pair⇩R ?Δ ?q₀ (Acc Σ π χ) w" proof (-) (*goal: ‹⋀χ. χ ∈ 𝒢 ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π χ) w›*) fix χ assume "χ ∈ 𝒢" (*‹(χ::'a ltl) ∈ (𝒢::'a ltl set)›*) then obtain ψ where "χ = G ψ" and "G ψ ∈ 𝒢" (*goal: ‹(⋀ψ. ⟦χ = G ψ; G ψ ∈ 𝒢⟧ ⟹ thesis) ⟹ thesis›*) using ‹Only_G 𝒢› (*‹Only_G 𝒢›*) by fastforce thus "?thesis χ" (*goal: ‹accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π χ) w›*) using ‹⋀ψ. G ψ ∈ 𝒢 ⟹ accept⇩R (ltl_to_rabin Σ ψ 𝒢) w›[OF ‹G ψ ∈ 𝒢›] (*‹accept⇩R (ltl_to_rabin (Σ::'a set set) (ψ::'a ltl) (𝒢::'a ltl set)) (w::nat ⇒ 'a set)›*) using rabin_accept_to_Acc[of ψ π] (*‹⟦G ψ ∈ dom π; dom π ⊆ ❙G ?φ; accept⇩R (semi_mojmir_def.step Σ ↑af⇩G (Abs ψ), semi_mojmir_def.initial (Abs ψ), {(mojmir_to_rabin_def.fail⇩R Σ ↑af⇩G (Abs ψ) {q. dom π ↑⊨⇩P q} ∪ mojmir_to_rabin_def.merge⇩R ↑af⇩G (Abs ψ) {q. dom π ↑⊨⇩P q} j, mojmir_to_rabin_def.succeed⇩R ↑af⇩G (Abs ψ) {q. dom π ↑⊨⇩P q} j) |j. j < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs ψ)}) w; π (G ψ) = mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs ψ) w {q. dom π ↑⊨⇩P q}⟧ ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 ?φ) (Acc⇩𝒜 Σ π (G ψ)) w›*) ‹G ψ ∈ 𝒢› (*‹G ψ ∈ 𝒢›*) ‹𝒢 ⊆ ❙G φ› (*‹𝒢 ⊆ ❙G φ›*) ‹χ ∈ 𝒢› (*‹χ ∈ 𝒢›*) unfolding ltl.sel (*goal: ‹accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π χ) w›*) unfolding ‹χ = G ψ› ‹𝒢 = dom π› (*goal: ‹accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π (G ψ)) w›*) using "π_def" (*‹π ?χ = (if ?χ ∈ 𝒢 then mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG ?χ)) w {q. 𝒢 ⊨⇩P Rep q} else None)›*) ‹𝒢 = dom π› (*‹𝒢 = dom π›*) ltl.sel(8) (*‹theG (G ?x8.0) = ?x8.0›*) unfolding ltl_prop_entails_abs.rep_eq ltl_to_rabin.simps (*goal: ‹accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π (G ψ)) w›*) by (metis (no_types, lifting) Collect_cong (*‹(⋀x. ?P x = ?Q x) ⟹ {x. ?P x} = {x. ?Q x}›*)) qed ultimately have "accepting_pair⇩G⇩R ?Δ ?q₀ (M_fin π ∪ ⋃{Acc_fin Σ π χ | χ. χ ∈ dom π}, {Acc_inf π χ | χ. χ ∈ dom π}) w" unfolding "accepting_pair⇩G⇩R_def" "accepting_pair⇩R_def" fst_conv snd_conv ‹𝒢 = dom π› (*goal: ‹limit (run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w) ∩ (M_fin π ∪ ⋃ {Acc_fin Σ π χ |χ. χ ∈ dom π}) = {} ∧ (∀I∈{Acc_inf π χ |χ. χ ∈ dom π}. limit (run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w) ∩ I ≠ {})›*) by blast } ultimately show "?rhs" unfolding ltl_to_rabin_base_def.ltl_to_generalized_rabin.simps "accept⇩G⇩R_def" fst_conv snd_conv (*goal: ‹∃(Fin, Inf)∈F⇩𝒜 Σ φ. accepting_pair⇩G⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Fin, Inf) w›*) by blast } { assume "?rhs" (*‹accept⇩G⇩R (𝒜 (Σ::'a set set) (φ::'a ltl)) (w::nat ⇒ 'a set)›*) obtain π' where 0: "dom π' ⊆ ❙G φ" and 1: "⋀χ. χ ∈ dom π' ⟹ the (π' χ) < ltl_FG_to_rabin_def.max_rank⇩R Σ (theG χ)" and 2: "accepting_pair⇩R ?Δ ?q₀ (M_fin π', UNIV) w" and 3: "⋀χ. χ ∈ dom π' ⟹ accepting_pair⇩R ?Δ ?q₀ (Acc Σ π' χ) w" (*goal: ‹(⋀π'. ⟦dom π' ⊆ ❙G φ; ⋀χ. χ ∈ dom π' ⟹ the (π' χ) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ)); accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π', UNIV) w; ⋀χ. χ ∈ dom π' ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π' χ) w⟧ ⟹ thesis) ⟹ thesis›*) using "accept⇩G⇩R_I"[OF ‹?rhs›] (*‹(⋀π. ⟦dom π ⊆ ❙G φ; ⋀χ. χ ∈ dom π ⟹ the (π χ) < max_rank_of Σ χ; accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π, UNIV) w; ⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π χ) w⟧ ⟹ ?thesis) ⟹ ?thesis›*) unfolding max_rank_of_def (*goal: ‹(⋀π'. ⟦dom π' ⊆ ❙G φ; ⋀χ. χ ∈ dom π' ⟹ the (π' χ) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG χ)); accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π', UNIV) w; ⋀χ. χ ∈ dom π' ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π' χ) w⟧ ⟹ thesis) ⟹ thesis›*) by blast define 𝒢 where "𝒢 = dom π'" hence "𝒢 ⊆ ❙G φ" using ‹dom π' ⊆ ❙G φ› (*‹dom π' ⊆ ❙G φ›*) by simp moreover note "𝒢_properties"[OF ‹dom π' ⊆ ❙G φ› [ unfolded 𝒢_def [ symmetric ] ]] (*‹finite 𝒢› ‹Only_G 𝒢›*) ultimately have "𝔐_Accept": "⋀χ. χ ∈ 𝒢 ⟹ ltl_FG_to_rabin_def.accept⇩R' (theG χ) 𝒢 w" using Acc_to_mojmir_accept[OF _ 0 3, of "theG _"] (*‹⟦G theG ?uu11 ∈ dom π'; G theG ?uu11 ∈ dom π'; the (π' (G theG ?uu11)) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG ?uu11))⟧ ⟹ mojmir_def.accept ↑af⇩G (Abs (theG ?uu11)) w {q. dom π' ↑⊨⇩P q}›*) "1"[of "G theG _", unfolded ltl.sel] (*‹G theG ?uu11 ∈ dom π' ⟹ the (π' (G theG ?uu11)) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG ?uu11))›*) "𝒢_def" (*‹𝒢 = dom π'›*) unfolding ltl_prop_entails_abs.rep_eq (*goal: ‹⋀χ. χ ∈ 𝒢 ⟹ mojmir_def.accept ↑af⇩G (Abs (theG χ)) w {q. 𝒢 ⊨⇩P Rep q}›*) by (metis (no_types) ltl.sel( (*‹theG (G ?x8.0) = ?x8.0›*) 8)) obtain π where "dom π' = dom π" and "⋀χ. χ ∈ dom π ⟹ π χ = ltl_FG_to_rabin_def.smallest_accepting_rank⇩R Σ (theG χ) (dom π) w" and "accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π, UNIV) w" and "⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc Σ π χ) w" (*goal: ‹(⋀π::'a ltl ⇒ nat option. ⟦dom (π'::'a ltl ⇒ nat option) = dom π; ⋀χ::'a ltl. χ ∈ dom π ⟹ π χ = mojmir_def.smallest_accepting_rank (Σ::'a set set) ↑af⇩G (Abs (theG χ)) (w::nat ⇒ 'a set) {q::'a ltl_prop_equiv_quotient. dom π ⊨⇩P Rep q}; accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 (φ::'a ltl)) (M_fin π, UNIV) w; ⋀χ::'a ltl. χ ∈ dom π ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π χ) w⟧ ⟹ thesis::bool) ⟹ thesis›*) using "normalize_π"[OF 0 _ 2 3] (*‹⟦⋀χ. χ ∈ dom π' ⟹ the (π' χ) < max_rank_of Σ χ; ⋀χ. χ ∈ dom π' ⟹ χ ∈ dom π'; ⋀π⇩𝒜. ⟦dom π' = dom π⇩𝒜; ⋀χ. χ ∈ dom π⇩𝒜 ⟹ π⇩𝒜 χ = mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG χ)) w {q. dom π⇩𝒜 ↑⊨⇩P q}; accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π⇩𝒜, UNIV) w; ⋀χ. χ ∈ dom π⇩𝒜 ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π⇩𝒜 χ) w⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) "1" (*‹?χ8 ∈ dom π' ⟹ the (π' ?χ8) < semi_mojmir_def.max_rank Σ ↑af⇩G (Abs (theG ?χ8))›*) unfolding max_rank_of_def ltl_prop_entails_abs.rep_eq (*goal: ‹(⋀π. ⟦dom π' = dom π; ⋀χ. χ ∈ dom π ⟹ π χ = mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs (theG χ)) w {q. dom π ⊨⇩P Rep q}; accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π, UNIV) w; ⋀χ. χ ∈ dom π ⟹ accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (Acc⇩𝒜 Σ π χ) w⟧ ⟹ thesis) ⟹ thesis›*) by blast have "ltl_FG_to_rabin Σ 𝒢 w" using "finite_Σ" (*‹finite Σ›*) bounded_w (*‹range w ⊆ Σ›*) ‹Only_G 𝒢› (*‹Only_G (𝒢::'a ltl set)›*) unfolding ltl_FG_to_rabin_def (*goal: ‹Only_G 𝒢 ∧ range w ⊆ Σ ∧ finite Σ›*) by auto have "closed 𝒢 w" using "𝔐_Accept" (*‹?χ8 ∈ 𝒢 ⟹ mojmir_def.accept ↑af⇩G (Abs (theG ?χ8)) w {q. 𝒢 ⊨⇩P Rep q}›*) ‹Only_G 𝒢› (*‹Only_G 𝒢›*) ltl.sel(8) (*‹theG (G ?x8.0) = ?x8.0›*) ‹finite 𝒢› (*‹finite 𝒢›*) unfolding ltl_FG_to_rabin.ltl_to_rabin_correct_exposed'[OF ‹ltl_FG_to_rabin Σ 𝒢 w›, symmetric] (*goal: ‹closed 𝒢 w›*) by fastforce moreover have "accept⇩M φ 𝒢 w" proof (-) (*goal: ‹accept⇩M φ 𝒢 w›*) obtain i where i_def: "⋀j. j ≥ i ⟹ r j ∉ M_fin π" (*goal: ‹(⋀i. (⋀j. i ≤ j ⟹ r j ∉ M_fin π) ⟹ thesis) ⟹ thesis›*) using ‹accepting_pair⇩R ?Δ ?q₀ (M_fin π, UNIV) w› (*‹accepting_pair⇩R (δ⇩𝒜 Σ) (ι⇩𝒜 φ) (M_fin π, UNIV) w›*) limit_inter_empty[OF ‹finite (range r)›, of "M_fin π"] (*‹limit r ∩ M_fin π = {} ⟹ ∀⇩∞n. r n ∉ M_fin π›*) unfolding r_def[symmetric] MOST_nat_le "accepting_pair⇩R_def" (*goal: ‹(⋀i. (⋀j. i ≤ j ⟹ r j ∉ M_fin π) ⟹ thesis) ⟹ thesis›*) by auto obtain i' where i'_def: "⋀j ψ S. j ≥ i' ⟹ G ψ ∈ 𝒢 ⟹ (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ ltl_FG_to_rabin_def.𝒮⇩R Σ ψ 𝒢 w j ⟶ S ⊨⇩P Rep q)" (*goal: ‹(⋀i'. (⋀j ψ S. ⟦i' ≤ j; G ψ ∈ 𝒢⟧ ⟹ (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q)) ⟹ thesis) ⟹ thesis›*) using "ℱ_eq_𝒮_generalized"[OF finite_Σ bounded_w ‹closed 𝒢 w›] (*‹∀⇩∞j. ∀ψ. G ψ ∈ 𝒢 ⟶ (∀S. (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q))›*) unfolding MOST_nat_le (*goal: ‹(⋀i'. (⋀j ψ S. ⟦i' ≤ j; G ψ ∈ 𝒢⟧ ⟹ (S ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ S) = (∀q. q ∈ mojmir_def.𝒮 Σ ↑af⇩G (Abs ψ) w {q. 𝒢 ⊨⇩P Rep q} j ⟶ S ⊨⇩P Rep q)) ⟹ thesis) ⟹ thesis›*) by presburger { fix j and S assume "j ≥ max i i'" (*‹max (i::nat) (i'::nat) ≤ (j::nat)›*) hence "j ≥ i" and "j ≥ i'" apply - (*goals: 1. ‹max i i' ≤ j ⟹ i ≤ j› 2. ‹max i i' ≤ j ⟹ i' ≤ j› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . assume "𝒢_def'": "∀ψ. G ψ ∈ 𝒢 ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)" (*‹∀ψ::'a ltl. G ψ ∈ (𝒢::'a ltl set) ⟶ (S::'a ltl set) ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ (w::nat ⇒ 'a set) 𝒢 (j::nat))›*) let ?φ' = "fst (fst (r j))" let ?m = "snd (fst (r j))" have "⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ" using "𝒢_def'" (*‹∀ψ::'a::type ltl. G ψ ∈ (𝒢::'a::type ltl set) ⟶ (S::'a::type ltl set) ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ (w::nat ⇒ 'a::type set) 𝒢 (j::nat))›*) ‹𝒢 ⊆ ❙G φ› (*‹(𝒢::'a ltl set) ⊆ ❙G (φ::'a ltl)›*) unfolding G_nested_propos_alt_def (*goal: ‹⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ›*) by auto moreover { fix χ assume "χ ∈ 𝒢" (*‹(χ::'a ltl) ∈ (𝒢::'a ltl set)›*) then obtain ψ where "χ = G ψ" and "G ψ ∈ 𝒢" (*goal: ‹(⋀ψ. ⟦χ = G ψ; G ψ ∈ 𝒢⟧ ⟹ thesis) ⟹ thesis›*) using ‹Only_G 𝒢› (*‹Only_G (𝒢::'a ltl set)›*) by auto hence "G ψ ∈ ❙G φ" using ‹𝒢 ⊆ ❙G φ› (*‹𝒢 ⊆ ❙G φ›*) by blast interpret 𝔐: ltl_FG_to_rabin "Σ" "ψ" "𝒢" w by (insert ‹ltl_FG_to_rabin Σ 𝒢 w›) { fix q assume "q ∈ 𝔐.𝒮 j" (*‹(q::'a ltl_prop_equiv_quotient) ∈ 𝔐.𝒮⇩R (j::nat)›*) hence "S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)" using "𝒢_def'" (*‹∀ψ::'a::type ltl. G ψ ∈ (𝒢::'a::type ltl set) ⟶ (S::'a::type ltl set) ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ (w::nat ⇒ 'a::type set) 𝒢 (j::nat))›*) ‹G ψ ∈ 𝒢› (*‹G ψ ∈ 𝒢›*) by simp moreover have "S ⊇ 𝒢" using "𝒢_def'" (*‹∀ψ. G ψ ∈ 𝒢 ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 j)›*) ‹Only_G 𝒢› (*‹Only_G 𝒢›*) by auto hence "⋀x. x ∈ 𝒢 ⟹ S ⊨⇩P eval⇩G 𝒢 x" using ‹Only_G 𝒢› (*‹Only_G 𝒢›*) ‹S ⊇ 𝒢› (*‹𝒢 ⊆ S›*) by fastforce moreover { fix S assume "⋀x. x ∈ 𝒢 ∪ {ℱ ψ w 𝒢 j} ⟹ S ⊨⇩P x" (*‹(?x8::'a ltl) ∈ (𝒢::'a ltl set) ∪ {ℱ (ψ::'a ltl) (w::nat ⇒ 'a set) 𝒢 (j::nat)} ⟹ (S::'a ltl set) ⊨⇩P ?x8›*) hence "𝒢 ⊆ S" and "S ⊨⇩P ℱ ψ w 𝒢 j" using ‹Only_G 𝒢› (*‹Only_G 𝒢›*) apply - (*goals: 1. ‹⟦⋀x::'a::type ltl. x ∈ (𝒢::'a::type ltl set) ∪ {ℱ (ψ::'a::type ltl) (w::nat ⇒ 'a::type set) 𝒢 (j::nat)} ⟹ (S::'a::type ltl set) ⊨⇩P x; Only_G 𝒢⟧ ⟹ 𝒢 ⊆ S› 2. ‹⟦⋀x::'a::type ltl. x ∈ (𝒢::'a::type ltl set) ∪ {ℱ (ψ::'a::type ltl) (w::nat ⇒ 'a::type set) 𝒢 (j::nat)} ⟹ (S::'a::type ltl set) ⊨⇩P x; Only_G 𝒢⟧ ⟹ S ⊨⇩P ℱ ψ w 𝒢 j› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . hence "S ⊨⇩P Rep q" using ‹q ∈ ltl_FG_to_rabin_def.𝒮⇩R Σ ψ 𝒢 w j› (*‹q ∈ 𝔐.𝒮⇩R j›*) using i'_def[OF ‹j ≥ i'› ‹G ψ ∈ 𝒢›] (*‹(?S8 ⊨⇩P ℱ ψ w 𝒢 j ∧ 𝒢 ⊆ ?S8) = (∀q. q ∈ 𝔐.𝒮⇩R j ⟶ ?S8 ⊨⇩P Rep q)›*) by blast } ultimately have "S ⊨⇩P eval⇩G 𝒢 (Rep q)" using "eval⇩G_respectfulness_generalized"[of "𝒢 ∪ {ℱ ψ w 𝒢 j}" "Rep q" S 𝒢] (*‹⟦⋀𝒜. (⋀x. x ∈ 𝒢 ∪ {ℱ ψ w 𝒢 j} ⟹ 𝒜 ⊨⇩P x) ⟹ 𝒜 ⊨⇩P Rep q; ⋀x. x ∈ 𝒢 ∪ {ℱ ψ w 𝒢 j} ⟹ S ⊨⇩P eval⇩G 𝒢 x⟧ ⟹ S ⊨⇩P eval⇩G 𝒢 (Rep q)›*) by blast } moreover have "𝔐.𝒮 j = {q. 𝒢 ⊨⇩P Rep q} ∪ {q . ∃j'. the 𝔐.smallest_accepting_rank ≤ j' ∧ the (?m (G ψ)) q = Some j'}" unfolding "𝔐.𝒮.simps" (*goal: ‹{q. 𝒢 ⊨⇩P Rep q} ∪ {q. ∃ja≥the 𝔐.smallest_accepting_rank⇩R. 𝔐.state_rank q j = Some ja} = {q. 𝒢 ⊨⇩P Rep q} ∪ {q. ∃j'≥the 𝔐.smallest_accepting_rank⇩R. the (snd (fst (r j)) (G ψ)) q = Some j'}›*) using run_properties(2)[OF ‹G ψ ∈ ❙G φ›] (*‹the (snd (run (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w ?i) (G ψ)) ?q = semi_mojmir_def.state_rank Σ ↑af⇩G (Abs (theG (G ψ))) w ?q ?i›*) r_def (*‹r = run⇩t (δ⇩𝒜 Σ) (ι⇩𝒜 φ) w›*) by simp ultimately have "⋀q j. j ≥ the (π χ) ⟹ the (?m χ) q = Some j ⟹ S ⊨⇩P eval⇩G 𝒢 (Rep q)" using ‹χ ∈ 𝒢›[unfolded 𝒢_def ‹dom π' = dom π›] (*‹χ ∈ dom π›*) unfolding ‹χ = G ψ› ‹⋀χ. χ ∈ dom π ⟹ π χ = ltl_FG_to_rabin_def.smallest_accepting_rank⇩R Σ (theG χ) (dom π) w›[OF ‹χ ∈ 𝒢› [ unfolded 𝒢_def ‹dom π' = dom π› ], unfolded ‹χ = G ψ›] ltl.sel(8) (*goal: ‹⋀q ja. ⟦the (mojmir_def.smallest_accepting_rank Σ ↑af⇩G (Abs ψ) w {q. dom π ⊨⇩P Rep q}) ≤ ja; the (snd (fst (r j)) (G ψ)) q = Some ja⟧ ⟹ S ⊨⇩P eval⇩G 𝒢 (Rep q)›*) unfolding ‹𝒢 ≡ dom π'›[symmetric] ‹dom π' = dom π›[symmetric] (*goal: ‹⋀q ja. ⟦the 𝔐.smallest_accepting_rank⇩R ≤ ja; the (snd (fst (r j)) (G ψ)) q = Some ja⟧ ⟹ S ⊨⇩P eval⇩G 𝒢 (Rep q)›*) by blast } moreover have "(⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ ∧ (∀q. ∀j' ≥ the (π χ). the (?m χ) q = Some j' ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q))) ⟹ S ⊨⇩P Rep ?φ'" apply (insert i_def[OF ‹j ≥ i›] (*‹r j ∉ M_fin π›*)) (*goal: ‹(⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ ∧ (∀q j'. the (π χ) ≤ j' ⟶ the (snd (fst (r j)) χ) q = Some j' ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q))) ⟹ S ⊨⇩P Rep (fst (fst (r j)))›*) apply (simp add: eval⇩G_abs_def (*‹↑eval⇩G ≡ map_fun id (map_fun Rep Abs) eval⇩G›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) option.case_eq_if (*‹(case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (if ?option = None then ?f1.0 else ?f2.0 (the ?option))›*)) (*goal: ‹⟦⋀χ. χ ∈ 𝒢 ⟹ S ⊨⇩P χ ∧ (∀q j'. the (π χ) ≤ j' ⟶ the (snd (fst (r j)) χ) q = Some j' ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q)); r j ∉ M_fin π⟧ ⟹ S ⊨⇩P Rep (fst (fst (r j)))›*) apply (unfold ‹𝒢 ≡ dom π'›[symmetric] ‹dom π' = dom π›[symmetric]) (*goal: ‹⟦⋀χ::'a ltl. χ ∈ (𝒢::'a ltl set) ⟹ (S::'a ltl set) ⊨⇩P χ ∧ (∀(q::'a ltl_prop_equiv_quotient) j'::nat. the ((π::'a ltl ⇒ nat option) χ) ≤ j' ⟶ the (snd (fst ((r::nat ⇒ ('a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) × 'a set × 'a ltl_prop_equiv_quotient × ('a ltl ⇒ ('a ltl_prop_equiv_quotient ⇒ nat option) option)) (j::nat))) χ) q = Some j' ⟶ S ⊨⇩P eval⇩G 𝒢 (Rep q)); ∀S::'a ltl set. (∃χ::'a ltl∈dom π. S ⊨⇩P χ ⟶ (∃q::'a ltl_prop_equiv_quotient. (∃ja≥the (π χ). the (snd (fst (r j)) χ) q = Some ja) ∧ ¬ S ⊨⇩P eval⇩G (dom π) (Rep q))) ∨ S ⊨⇩P Rep (fst (fst (r j)))⟧ ⟹ S ⊨⇩P Rep (fst (fst (r j)))›*) by meson ultimately have "S ⊨⇩P Rep ?φ'" by fast hence "S ⊨⇩P af φ (w [0 → j])" using "φ'_def" (*‹af φ (prefix ?i8 w) ≡⇩P Rep (fst (fst (r ?i8)))›*) ltl_prop_equiv_def (*‹?φ ≡⇩P ?ψ ≡ ∀𝒜. 𝒜 ⊨⇩P ?φ = 𝒜 ⊨⇩P ?ψ›*) by blast } thus "accept⇩M φ 𝒢 w" unfolding "accept⇩M_def" MOST_nat_le (*goal: ‹∃m. ∀n≥m. ∀S. (∀ψ. G ψ ∈ 𝒢 ⟶ S ⊨⇩P G ψ ∧ S ⊨⇩P eval⇩G 𝒢 (ℱ ψ w 𝒢 n)) ⟶ S ⊨⇩P af φ (prefix n w)›*) by blast qed ultimately show "?lhs" using ‹𝒢 ⊆ ❙G φ› (*‹𝒢 ⊆ ❙G φ›*) ltl_logical_characterization (*‹?w ⊨ ?φ = (∃𝒢⊆❙G ?φ. accept⇩M ?φ 𝒢 ?w ∧ closed 𝒢 ?w)›*) by blast } qed end fun ltl_to_generalized_rabin_af where "ltl_to_generalized_rabin_af Σ φ = ltl_to_rabin_base_def.ltl_to_generalized_rabin ↑af ↑af⇩G Abs Abs M_fin Σ φ" lemma ltl_to_generalized_rabin_af_wellformed: "finite Σ ⟹ range w ⊆ Σ ⟹ ltl_to_rabin_af Σ w" apply unfold_locales (*goals: 1. ‹⟦finite Σ; range w ⊆ Σ⟧ ⟹ finite Σ› 2. ‹⟦finite Σ; range w ⊆ Σ⟧ ⟹ range w ⊆ Σ› 3. ‹⋀π π'. ⟦finite Σ; range w ⊆ Σ; dom π = dom π'; ⋀χ. χ ∈ dom π ⟹ the (π χ) ≤ the (π' χ)⟧ ⟹ M_fin π ⊆ M_fin π'› 4. ‹⋀φ. ⟦finite Σ; range w ⊆ Σ⟧ ⟹ finite (reach Σ ↑af (Abs φ))› 5. ‹⋀𝒢 ψ. ⟦finite Σ; range w ⊆ Σ; Only_G 𝒢⟧ ⟹ finite Σ› 6. ‹⋀𝒢 ψ. ⟦finite Σ; range w ⊆ Σ; Only_G 𝒢⟧ ⟹ finite (reach Σ ↑af⇩G (Abs ψ))› 7. ‹⋀𝒢 ψ. ⟦finite Σ; range w ⊆ Σ; Only_G 𝒢⟧ ⟹ range w ⊆ Σ› 8. ‹⋀𝒢 ψ q ν. ⟦finite Σ; range w ⊆ Σ; Only_G 𝒢; q ∈ {q. 𝒢 ↑⊨⇩P q}⟧ ⟹ ↑af⇩G q ν ∈ {q. 𝒢 ↑⊨⇩P q}› discuss goal 1*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*discuss goal 2*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*discuss goal 3*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*top goal: ‹⋀π π'. ⟦finite Σ; range w ⊆ Σ; dom π = dom π'; ⋀χ. χ ∈ dom π ⟹ the (π χ) ≤ the (π' χ)⟧ ⟹ M_fin π ⊆ M_fin π'› and 5 goals remain*) apply (meson le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) ltl_semi_mojmir[unfolded semi_mojmir_def] (*‹⟦finite ?Σ; range ?w ⊆ ?Σ⟧ ⟹ finite ?Σ ∧ finite (reach ?Σ ↑af⇩G (Abs ?ψ)) ∧ range ?w ⊆ ?Σ›*)) (*discuss goal 4*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*discuss goal 5*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G (?𝒢::?'a::type ltl set); ?𝒢 ⊨⇩P Rep (?φ::?'a::type ltl_prop_equiv_quotient)⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ (?ν::?'a::type set))›*) ltl_prop_entails_abs.rep_eq (*‹?x::?'a::type ltl set ↑⊨⇩P ?xa::?'a::type ltl_prop_equiv_quotient = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach (?Σ::?'a::type set set) ↑af (Abs (?φ::?'a::type ltl)))›*))[1]) (*discuss goal 6*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*top goal: ‹⋀𝒢 ψ. ⟦finite Σ; range w ⊆ Σ; Only_G 𝒢⟧ ⟹ finite (reach Σ ↑af⇩G (Abs ψ))› and 2 goals remain*) apply (meson le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) ltl_semi_mojmir[unfolded semi_mojmir_def] (*‹⟦finite ?Σ; range ?w ⊆ ?Σ⟧ ⟹ finite ?Σ ∧ finite (reach ?Σ ↑af⇩G (Abs ?ψ)) ∧ range ?w ⊆ ?Σ›*)) (*discuss goal 7*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*discuss goal 8*) apply ((auto simp add: af_G_letter_sat_core_lifted (*‹⟦Only_G ?𝒢; ?𝒢 ⊨⇩P Rep ?φ⟧ ⟹ ?𝒢 ⊨⇩P Rep (↑af⇩G ?φ ?ν)›*) ltl_prop_entails_abs.rep_eq (*‹?x ↑⊨⇩P ?xa = ?x ⊨⇩P Rep ?xa›*) intro: finite_reach_af (*‹finite (reach ?Σ ↑af (Abs ?φ))›*))[1]) (*proven 8 subgoals*) . theorem ltl_to_generalized_rabin_af_correct: assumes "finite Σ" assumes "range w ⊆ Σ" shows "w ⊨ φ = accept⇩G⇩R (ltl_to_generalized_rabin_af Σ φ) w" using ltl_to_generalized_rabin_af_wellformed[OF assms, THEN ltl_to_rabin_af.ltl_to_generalized_rabin_correct] (*‹w ⊨ ?φ = accept⇩G⇩R (ltl_to_rabin_base_def.ltl_to_generalized_rabin ↑af ↑af⇩G Abs Abs M_fin Σ ?φ) w›*) by simp thm ltl_to_generalized_rabin_af_correct ltl_FG_to_generalized_rabin_correct end
{ "path": "afp-2025-02-12/thys/LTL_to_DRA/LTL_Rabin.thy", "repo": "afp-2025-02-12", "sha": "0a64bbe3391db559368bbac936b32c5fcc6fd70bb1ee8a6c34197a13302ea19b" }
(* Title: HOL/BNF_Greatest_Fixpoint.thy Author: Dmitriy Traytel, TU Muenchen Author: Lorenz Panny, TU Muenchen Author: Jasmin Blanchette, TU Muenchen Copyright 2012, 2013, 2014 Greatest fixpoint (codatatype) operation on bounded natural functors. *) section ‹Greatest Fixpoint (Codatatype) Operation on Bounded Natural Functors› theory BNF_Greatest_Fixpoint imports BNF_Fixpoint_Base String keywords "codatatype" :: thy_defn and "primcorecursive" :: thy_goal_defn and "primcorec" :: thy_defn begin alias proj = Equiv_Relations.proj lemma one_pointE: "⟦⋀x. s = x ⟹ P⟧ ⟹ P" by simp lemma obj_sumE: "⟦∀x. s = Inl x ⟶ P; ∀x. s = Inr x ⟶ P⟧ ⟹ P" apply (cases s) (*goals: 1. ‹⋀a. ⟦∀x. s = Inl x ⟶ P; ∀x. s = Inr x ⟶ P; s = Inl a⟧ ⟹ P› 2. ‹⋀b. ⟦∀x. s = Inl x ⟶ P; ∀x. s = Inr x ⟶ P; s = Inr b⟧ ⟹ P› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma not_TrueE: "¬ True ⟹ P" apply (erule notE (*‹⟦¬ ?P; ?P⟧ ⟹ ?R›*)) (*goal: ‹¬ True ⟹ P›*) by (rule TrueI (*‹True›*)) lemma neq_eq_eq_contradict: "⟦t ≠ u; s = t; s = u⟧ ⟹ P" by fast lemma converse_Times: "(A × B)¯ = B × A" by fast lemma equiv_proj: assumes e: "equiv A R" and m: "z ∈ R" shows "(proj R ∘ fst) z = (proj R ∘ snd) z" proof (-) (*goal: ‹(proj (R::('a × 'a) set) ∘ fst) (z::'a × 'a) = (proj R ∘ snd) z›*) from m (*‹z ∈ R›*) have z: "(fst z, snd z) ∈ R" by auto with e (*‹equiv A R›*) have "⋀x. (fst z, x) ∈ R ⟹ (snd z, x) ∈ R" "⋀x. (snd z, x) ∈ R ⟹ (fst z, x) ∈ R" unfolding equiv_def sym_def trans_def (*goals: 1. ‹⋀x. (fst z, x) ∈ R ⟹ (snd z, x) ∈ R› 2. ‹⋀x. (snd z, x) ∈ R ⟹ (fst z, x) ∈ R›*) apply - (*goals: 1. ‹⋀x. ⟦(fst z, x) ∈ R; refl_on A R ∧ (∀x y. (x, y) ∈ R ⟶ (y, x) ∈ R) ∧ (∀x y z. (x, y) ∈ R ⟶ (y, z) ∈ R ⟶ (x, z) ∈ R); (fst z, snd z) ∈ R⟧ ⟹ (snd z, x) ∈ R› 2. ‹⋀x. ⟦(snd z, x) ∈ R; refl_on A R ∧ (∀x y. (x, y) ∈ R ⟶ (y, x) ∈ R) ∧ (∀x y z. (x, y) ∈ R ⟶ (y, z) ∈ R ⟶ (x, z) ∈ R); (fst z, snd z) ∈ R⟧ ⟹ (fst z, x) ∈ R› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹(proj (R::('a × 'a) set) ∘ fst) (z::'a × 'a) = (proj R ∘ snd) z›*) unfolding proj_def[abs_def] (*goal: ‹((λx. R `` {x}) ∘ fst) z = ((λx. R `` {x}) ∘ snd) z›*) by auto qed (* Operators: *) definition image2 where "image2 A f g = {(f a, g a) | a. a ∈ A}" lemma Id_on_Gr: "Id_on A = Gr A id" unfolding Id_on_def Gr_def (*goal: ‹(⋃x∈A. {(x, x)}) = {(a, id a) |a. a ∈ A}›*) by auto lemma image2_eqI: "⟦b = f x; c = g x; x ∈ A⟧ ⟹ (b, c) ∈ image2 A f g" unfolding image2_def (*goal: ‹⟦b = f x; c = g x; x ∈ A⟧ ⟹ (b, c) ∈ {(f a, g a) |a. a ∈ A}›*) by auto lemma IdD: "(a, b) ∈ Id ⟹ a = b" by auto lemma image2_Gr: "image2 A f g = (Gr A f)¯ O (Gr A g)" unfolding image2_def Gr_def (*goal: ‹{(f a, g a) |a. a ∈ A} = {(a, f a) |a. a ∈ A}¯ O {(a, g a) |a. a ∈ A}›*) by auto lemma GrD1: "(x, fx) ∈ Gr A f ⟹ x ∈ A" unfolding Gr_def (*goal: ‹(x, fx) ∈ {(a, f a) |a. a ∈ A} ⟹ x ∈ A›*) by simp lemma GrD2: "(x, fx) ∈ Gr A f ⟹ f x = fx" unfolding Gr_def (*goal: ‹(x, fx) ∈ {(a, f a) |a. a ∈ A} ⟹ f x = fx›*) by simp lemma Gr_incl: "Gr A f ⊆ A × B ⟷ f ` A ⊆ B" unfolding Gr_def (*goal: ‹({(a, f a) |a. a ∈ A} ⊆ A × B) = (f ` A ⊆ B)›*) by auto lemma subset_Collect_iff: "B ⊆ A ⟹ (B ⊆ {x ∈ A. P x}) = (∀x ∈ B. P x)" by blast lemma subset_CollectI: "B ⊆ A ⟹ (⋀x. x ∈ B ⟹ Q x ⟹ P x) ⟹ ({x ∈ B. Q x} ⊆ {x ∈ A. P x})" by blast lemma in_rel_Collect_case_prod_eq: "in_rel (Collect (case_prod X)) = X" unfolding fun_eq_iff (*goal: ‹∀x xa. in_rel {(x, y). X x y} x xa = X x xa›*) by auto lemma Collect_case_prod_in_rel_leI: "X ⊆ Y ⟹ X ⊆ Collect (case_prod (in_rel Y))" by auto lemma Collect_case_prod_in_rel_leE: "X ⊆ Collect (case_prod (in_rel Y)) ⟹ (X ⊆ Y ⟹ R) ⟹ R" by force lemma conversep_in_rel: "(in_rel R)¯¯ = in_rel (R¯)" unfolding fun_eq_iff (*goal: ‹∀(x::'a) xa::'b. (in_rel (R::('b × 'a) set))¯¯ x xa = in_rel (R¯) x xa›*) by auto lemma relcompp_in_rel: "in_rel R OO in_rel S = in_rel (R O S)" unfolding fun_eq_iff (*goal: ‹∀x xa. (in_rel R OO in_rel S) x xa = in_rel (R O S) x xa›*) by auto lemma in_rel_Gr: "in_rel (Gr A f) = Grp A f" unfolding Gr_def Grp_def fun_eq_iff (*goal: ‹∀x xa. in_rel {(a, f a) |a. a ∈ A} x xa = (xa = f x ∧ x ∈ A)›*) by auto definition relImage where "relImage R f ≡ {(f a1, f a2) | a1 a2. (a1,a2) ∈ R}" definition relInvImage where "relInvImage A R f ≡ {(a1, a2) | a1 a2. a1 ∈ A ∧ a2 ∈ A ∧ (f a1, f a2) ∈ R}" lemma relImage_Gr: "⟦R ⊆ A × A⟧ ⟹ relImage R f = (Gr A f)¯ O R O Gr A f" unfolding relImage_def Gr_def relcomp_def (*goal: ‹R ⊆ A × A ⟹ {(f a1, f a2) |a1 a2. (a1, a2) ∈ R} = {(x, y). ((λx xa. (x, xa) ∈ {(a, f a) |a. a ∈ A}¯) OO (λx xa. (x, xa) ∈ {(x, y). ((λx xa. (x, xa) ∈ R) OO (λx xa. (x, xa) ∈ {(a, f a) |a. a ∈ A})) x y})) x y}›*) by auto lemma relInvImage_Gr: "⟦R ⊆ B × B⟧ ⟹ relInvImage A R f = Gr A f O R O (Gr A f)¯" unfolding Gr_def relcomp_def image_def relInvImage_def (*goal: ‹R ⊆ B × B ⟹ {(a1, a2) |a1 a2. a1 ∈ A ∧ a2 ∈ A ∧ (f a1, f a2) ∈ R} = {(x, y). ((λx xa. (x, xa) ∈ {(a, f a) |a. a ∈ A}) OO (λx xa. (x, xa) ∈ {(x, y). ((λx xa. (x, xa) ∈ R) OO (λx xa. (x, xa) ∈ {(a, f a) |a. a ∈ A}¯)) x y})) x y}›*) by auto lemma relImage_mono: "R1 ⊆ R2 ⟹ relImage R1 f ⊆ relImage R2 f" unfolding relImage_def (*goal: ‹R1 ⊆ R2 ⟹ {(f a1, f a2) |a1 a2. (a1, a2) ∈ R1} ⊆ {(f a1, f a2) |a1 a2. (a1, a2) ∈ R2}›*) by auto lemma relInvImage_mono: "R1 ⊆ R2 ⟹ relInvImage A R1 f ⊆ relInvImage A R2 f" unfolding relInvImage_def (*goal: ‹R1 ⊆ R2 ⟹ {(a1, a2) |a1 a2. a1 ∈ A ∧ a2 ∈ A ∧ (f a1, f a2) ∈ R1} ⊆ {(a1, a2) |a1 a2. a1 ∈ A ∧ a2 ∈ A ∧ (f a1, f a2) ∈ R2}›*) by auto lemma relInvImage_Id_on: "(⋀a1 a2. f a1 = f a2 ⟷ a1 = a2) ⟹ relInvImage A (Id_on B) f ⊆ Id" unfolding relInvImage_def Id_on_def (*goal: ‹(⋀a1 a2. (f a1 = f a2) = (a1 = a2)) ⟹ {(a1, a2) |a1 a2. a1 ∈ A ∧ a2 ∈ A ∧ (f a1, f a2) ∈ (⋃x∈B. {(x, x)})} ⊆ Id›*) by auto lemma relInvImage_UNIV_relImage: "R ⊆ relInvImage UNIV (relImage R f) f" unfolding relInvImage_def relImage_def (*goal: ‹(R::('a::type × 'a::type) set) ⊆ {(a1, a2) |(a1::'a::type) a2::'a::type. a1 ∈ UNIV ∧ a2 ∈ UNIV ∧ ((f::'a::type ⇒ 'b::type) a1, f a2) ∈ {(f a1, f a2) |(a1::'a::type) a2::'a::type. (a1, a2) ∈ R}}›*) by auto lemma relImage_proj: assumes "equiv A R" shows "relImage R (proj R) ⊆ Id_on (A//R)" unfolding relImage_def Id_on_def (*goal: ‹{(proj R a1, proj R a2) |a1 a2. (a1, a2) ∈ R} ⊆ (⋃x∈A // R. {(x, x)})›*) using proj_iff[OF assms] (*‹{?x, ?y} ⊆ A ⟹ (proj R ?x = proj R ?y) = ((?x, ?y) ∈ R)›*) equiv_class_eq_iff[OF assms] (*‹((?x, ?y) ∈ R) = (R `` {?x} = R `` {?y} ∧ ?x ∈ A ∧ ?y ∈ A)›*) by (auto simp: proj_preserves (*‹?x ∈ ?A ⟹ proj ?r ?x ∈ ?A // ?r›*)) lemma relImage_relInvImage: assumes "R ⊆ f ` A × f ` A" shows "relImage (relInvImage A R f) f = R" using assms (*‹R ⊆ f ` A × f ` A›*) unfolding relImage_def relInvImage_def (*goal: ‹{(f a1, f a2) |a1 a2. (a1, a2) ∈ {(a1, a2) |a1 a2. a1 ∈ A ∧ a2 ∈ A ∧ (f a1, f a2) ∈ R}} = R›*) by fast lemma subst_Pair: "P x y ⟹ a = (x, y) ⟹ P (fst a) (snd a)" by simp lemma fst_diag_id: "(fst ∘ (λx. (x, x))) z = id z" by simp lemma snd_diag_id: "(snd ∘ (λx. (x, x))) z = id z" by simp lemma fst_diag_fst: "fst ∘ ((λx. (x, x)) ∘ fst) = fst" by auto lemma snd_diag_fst: "snd ∘ ((λx. (x, x)) ∘ fst) = fst" by auto lemma fst_diag_snd: "fst ∘ ((λx. (x, x)) ∘ snd) = snd" by auto lemma snd_diag_snd: "snd ∘ ((λx. (x, x)) ∘ snd) = snd" by auto definition Succ where "Succ Kl kl = {k . kl @ [k] ∈ Kl}" definition Shift where "Shift Kl k = {kl. k # kl ∈ Kl}" definition shift where "shift lab k = (λkl. lab (k # kl))" lemma empty_Shift: "⟦[] ∈ Kl; k ∈ Succ Kl []⟧ ⟹ [] ∈ Shift Kl k" unfolding Shift_def Succ_def (*goal: ‹⟦[] ∈ (Kl::'a list set); (k::'a) ∈ {k::'a. [] @ [k] ∈ Kl}⟧ ⟹ [] ∈ {kl::'a list. k # kl ∈ Kl}›*) by simp lemma SuccD: "k ∈ Succ Kl kl ⟹ kl @ [k] ∈ Kl" unfolding Succ_def (*goal: ‹k ∈ {k. kl @ [k] ∈ Kl} ⟹ kl @ [k] ∈ Kl›*) by simp lemmas SuccE = SuccD[elim_format] lemma SuccI: "kl @ [k] ∈ Kl ⟹ k ∈ Succ Kl kl" unfolding Succ_def (*goal: ‹kl @ [k] ∈ Kl ⟹ k ∈ {k. kl @ [k] ∈ Kl}›*) by simp lemma ShiftD: "kl ∈ Shift Kl k ⟹ k # kl ∈ Kl" unfolding Shift_def (*goal: ‹(kl::'a list) ∈ {kl::'a list. (k::'a) # kl ∈ (Kl::'a list set)} ⟹ k # kl ∈ Kl›*) by simp lemma Succ_Shift: "Succ (Shift Kl k) kl = Succ Kl (k # kl)" unfolding Succ_def Shift_def (*goal: ‹{ka. kl @ [ka] ∈ {kl. k # kl ∈ Kl}} = {ka. (k # kl) @ [ka] ∈ Kl}›*) by auto lemma length_Cons: "length (x # xs) = Suc (length xs)" by simp lemma length_append_singleton: "length (xs @ [x]) = Suc (length xs)" by simp (*injection into the field of a cardinal*) definition "toCard_pred A r f ≡ inj_on f A ∧ f ` A ⊆ Field r ∧ Card_order r" definition "toCard A r ≡ SOME f. toCard_pred A r f" lemma ex_toCard_pred: "⟦|A| ≤o r; Card_order r⟧ ⟹ ∃ f. toCard_pred A r f" unfolding toCard_pred_def (*goal: ‹⟦|A| ≤o r; Card_order r⟧ ⟹ ∃f. inj_on f A ∧ f ` A ⊆ Field r ∧ Card_order r›*) using card_of_ordLeq[of A "Field r"] (*‹(∃f. inj_on f A ∧ f ` A ⊆ Field r) = (|A| ≤o |Field r|)›*) ordLeq_ordIso_trans[OF _ card_of_unique [ of "Field r" r ], of "|A|"] (*‹⟦|A::'a set| ≤o (r::('b × 'b) set); Card_order r⟧ ⟹ |A| ≤o |Field r|›*) by blast lemma toCard_pred_toCard: "⟦|A| ≤o r; Card_order r⟧ ⟹ toCard_pred A r (toCard A r)" unfolding toCard_def (*goal: ‹⟦|A| ≤o r; Card_order r⟧ ⟹ toCard_pred A r (SOME f. toCard_pred A r f)›*) using someI_ex[OF ex_toCard_pred] (*‹⟦|?A1| ≤o ?r1; Card_order ?r1⟧ ⟹ toCard_pred ?A1 ?r1 (SOME x. toCard_pred ?A1 ?r1 x)›*) . lemma toCard_inj: "⟦|A| ≤o r; Card_order r; x ∈ A; y ∈ A⟧ ⟹ toCard A r x = toCard A r y ⟷ x = y" using toCard_pred_toCard (*‹⟦|?A| ≤o ?r; Card_order ?r⟧ ⟹ toCard_pred ?A ?r (toCard ?A ?r)›*) unfolding inj_on_def toCard_pred_def (*goal: ‹⟦|A| ≤o r; Card_order r; x ∈ A; y ∈ A⟧ ⟹ (toCard A r x = toCard A r y) = (x = y)›*) by blast definition "fromCard A r k ≡ SOME b. b ∈ A ∧ toCard A r b = k" lemma fromCard_toCard: "⟦|A| ≤o r; Card_order r; b ∈ A⟧ ⟹ fromCard A r (toCard A r b) = b" unfolding fromCard_def (*goal: ‹⟦|A| ≤o r; Card_order r; b ∈ A⟧ ⟹ (SOME ba. ba ∈ A ∧ toCard A r ba = toCard A r b) = b›*) apply (rule some_equality (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ (SOME x. ?P x) = ?a›*)) (*goals: 1. ‹⟦|A| ≤o r; Card_order r; b ∈ A⟧ ⟹ b ∈ A ∧ toCard A r b = toCard A r b› 2. ‹⋀ba. ⟦|A| ≤o r; Card_order r; b ∈ A; ba ∈ A ∧ toCard A r ba = toCard A r b⟧ ⟹ ba = b› discuss goal 1*) apply ((auto simp add: toCard_inj (*‹⟦|?A::?'a set| ≤o (?r::(?'b × ?'b) set); Card_order ?r; (?x::?'a) ∈ ?A; (?y::?'a) ∈ ?A⟧ ⟹ (toCard ?A ?r ?x = toCard ?A ?r ?y) = (?x = ?y)›*))[1]) (*discuss goal 2*) apply ((auto simp add: toCard_inj (*‹⟦|?A| ≤o ?r; Card_order ?r; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ (toCard ?A ?r ?x = toCard ?A ?r ?y) = (?x = ?y)›*))[1]) (*proven 2 subgoals*) . lemma Inl_Field_csum: "a ∈ Field r ⟹ Inl a ∈ Field (r +c s)" unfolding Field_card_of csum_def (*goal: ‹a ∈ Field r ⟹ Inl a ∈ Field r <+> Field s›*) by auto lemma Inr_Field_csum: "a ∈ Field s ⟹ Inr a ∈ Field (r +c s)" unfolding Field_card_of csum_def (*goal: ‹a ∈ Field s ⟹ Inr a ∈ Field r <+> Field s›*) by auto lemma rec_nat_0_imp: "f = rec_nat f1 (λn rec. f2 n rec) ⟹ f 0 = f1" by auto lemma rec_nat_Suc_imp: "f = rec_nat f1 (λn rec. f2 n rec) ⟹ f (Suc n) = f2 n (f n)" by auto lemma rec_list_Nil_imp: "f = rec_list f1 (λx xs rec. f2 x xs rec) ⟹ f [] = f1" by auto lemma rec_list_Cons_imp: "f = rec_list f1 (λx xs rec. f2 x xs rec) ⟹ f (x # xs) = f2 x xs (f xs)" by auto lemma not_arg_cong_Inr: "x ≠ y ⟹ Inr x ≠ Inr y" by simp definition image2p where "image2p f g R = (λx y. ∃x' y'. R x' y' ∧ f x' = x ∧ g y' = y)" lemma image2pI: "R x y ⟹ image2p f g R (f x) (g y)" unfolding image2p_def (*goal: ‹(R::'a ⇒ 'b ⇒ bool) (x::'a) (y::'b) ⟹ ∃(x'::'a) y'::'b. R x' y' ∧ (f::'a ⇒ 'c) x' = f x ∧ (g::'b ⇒ 'd) y' = g y›*) by blast lemma image2pE: "⟦image2p f g R fx gy; (⋀x y. fx = f x ⟹ gy = g y ⟹ R x y ⟹ P)⟧ ⟹ P" unfolding image2p_def (*goal: ‹⟦∃x' y'. R x' y' ∧ f x' = fx ∧ g y' = gy; ⋀x y. ⟦fx = f x; gy = g y; R x y⟧ ⟹ P⟧ ⟹ P›*) by blast lemma rel_fun_iff_geq_image2p: "rel_fun R S f g = (image2p f g R ≤ S)" unfolding rel_fun_def image2p_def (*goal: ‹(∀x y. R x y ⟶ S (f x) (g y)) = ((λx y. ∃x' y'. R x' y' ∧ f x' = x ∧ g y' = y) ≤ S)›*) by auto lemma rel_fun_image2p: "rel_fun R (image2p f g R) f g" unfolding rel_fun_def image2p_def (*goal: ‹∀x y. R x y ⟶ (∃x' y'. R x' y' ∧ f x' = f x ∧ g y' = g y)›*) by auto subsection ‹Equivalence relations, quotients, and Hilbert's choice› lemma equiv_Eps_in: "⟦equiv A r; X ∈ A//r⟧ ⟹ Eps (λx. x ∈ X) ∈ X" apply (rule someI2_ex (*‹⟦∃a. ?P a; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ ?Q (SOME x. ?P x)›*)) (*goal: ‹⟦equiv A r; X ∈ A // r⟧ ⟹ (SOME x. x ∈ X) ∈ X›*) using in_quotient_imp_non_empty (*‹⟦equiv (?A::?'a::type set) (?r::(?'a::type × ?'a::type) set); (?X::?'a::type set) ∈ ?A // ?r⟧ ⟹ ?X ≠ {}›*) (*goals: 1. ‹⟦equiv A r; X ∈ A // r⟧ ⟹ ∃a. a ∈ X› 2. ‹⋀x. ⟦equiv A r; X ∈ A // r; x ∈ X⟧ ⟹ x ∈ X› discuss goal 1*) apply blast (*discuss goal 2*) . (*proven 2 subgoals*) lemma equiv_Eps_preserves: assumes ECH: "equiv A r" and X: "X ∈ A//r" shows "Eps (λx. x ∈ X) ∈ A" apply (rule in_mono[rule_format] (*‹⟦?A ⊆ ?B; ?x ∈ ?A⟧ ⟹ ?x ∈ ?B›*)) (*goal: ‹(SOME x. x ∈ X) ∈ A›*) using assms (*‹equiv (A::'a::type set) (r::('a::type × 'a::type) set)› ‹X ∈ A // r›*) (*goals: 1. ‹?A ⊆ A› 2. ‹(SOME x. x ∈ X) ∈ ?A› discuss goal 1*) apply (rule in_quotient_imp_subset (*‹⟦equiv (?A::?'a::type set) (?r::(?'a::type × ?'a::type) set); (?X::?'a::type set) ∈ ?A // ?r⟧ ⟹ ?X ⊆ ?A›*)) (*discuss goal 2*) apply (rule equiv_Eps_in (*‹⟦equiv (?A::?'a set) (?r::(?'a × ?'a) set); (?X::?'a set) ∈ ?A // ?r⟧ ⟹ (SOME x::?'a. x ∈ ?X) ∈ ?X›*)) (*goals: 1. ‹equiv ?A4 ?r4› 2. ‹X ∈ ?A4 // ?r4› discuss goal 1*) apply (rule assms (*‹equiv A r› ‹X ∈ A // r›*)) (*discuss goal 2*) apply (rule assms (*‹equiv A r› ‹X ∈ A // r›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma proj_Eps: assumes "equiv A r" and "X ∈ A//r" shows "proj r (Eps (λx. x ∈ X)) = X" unfolding proj_def (*goal: ‹r `` {SOME x. x ∈ X} = X›*) proof (auto) (*goals: 1. ‹⋀x. (SOME x. x ∈ X, x) ∈ r ⟹ x ∈ X› 2. ‹⋀x. x ∈ X ⟹ (SOME x. x ∈ X, x) ∈ r›*) fix x assume x: "x ∈ X" (*‹(x::'a) ∈ (X::'a set)›*) thus "(Eps (λx. x ∈ X), x) ∈ r" using assms (*‹equiv A r› ‹X ∈ A // r›*) equiv_Eps_in (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?X›*) in_quotient_imp_in_rel (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r; {?x, ?y} ⊆ ?X⟧ ⟹ (?x, ?y) ∈ ?r›*) by fast next (*goal: ‹⋀x::'a::type. (SOME x::'a::type. x ∈ (X::'a::type set), x) ∈ (r::('a::type × 'a::type) set) ⟹ x ∈ X›*) fix x assume "(Eps (λx. x ∈ X),x) ∈ r" (*‹(SOME x::'a. x ∈ (X::'a set), x::'a) ∈ (r::('a × 'a) set)›*) thus "x ∈ X" using in_quotient_imp_closed[OF assms equiv_Eps_in [ OF assms ]] (*‹(SOME x. x ∈ X, ?y) ∈ r ⟹ ?y ∈ X›*) by fast qed definition univ where "univ f X == f (Eps (λx. x ∈ X))" lemma univ_commute: assumes ECH: "equiv A r" and RES: "f respects r" and x: "x ∈ A" shows "(univ f) (proj r x) = f x" proof (unfold univ_def (*‹univ (?f::?'b ⇒ ?'a) (?X::?'b set) ≡ ?f (SOME x::?'b. x ∈ ?X)›*)) (*goal: ‹f (SOME xa. xa ∈ proj r x) = f x›*) have prj: "proj r x ∈ A//r" using x (*‹x ∈ A›*) proj_preserves (*‹?x ∈ ?A ⟹ proj ?r ?x ∈ ?A // ?r›*) by fast hence "Eps (λy. y ∈ proj r x) ∈ A" using ECH (*‹equiv A r›*) equiv_Eps_preserves (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ (SOME x. x ∈ ?X) ∈ ?A›*) by fast moreover have "proj r (Eps (λy. y ∈ proj r x)) = proj r x" using ECH (*‹equiv A r›*) prj (*‹proj r x ∈ A // r›*) proj_Eps (*‹⟦equiv ?A ?r; ?X ∈ ?A // ?r⟧ ⟹ proj ?r (SOME x. x ∈ ?X) = ?X›*) by fast ultimately have "(x, Eps (λy. y ∈ proj r x)) ∈ r" using x (*‹(x::'a) ∈ (A::'a set)›*) ECH (*‹equiv A r›*) proj_iff (*‹⟦equiv ?A ?r; {?x, ?y} ⊆ ?A⟧ ⟹ (proj ?r ?x = proj ?r ?y) = ((?x, ?y) ∈ ?r)›*) by fast thus "f (Eps (λy. y ∈ proj r x)) = f x" using RES (*‹f respects r›*) unfolding congruent_def (*goal: ‹(f::'a ⇒ 'b) (SOME y::'a. y ∈ proj (r::('a × 'a) set) (x::'a)) = f x›*) by fastforce qed lemma univ_preserves: assumes ECH: "equiv A r" and RES: "f respects r" and PRES: "∀x ∈ A. f x ∈ B" shows "∀X ∈ A//r. univ f X ∈ B" proof (standard) (*goal: ‹⋀X::'a::type set. X ∈ (A::'a::type set) // (r::('a::type × 'a::type) set) ⟹ univ (f::'a::type ⇒ 'b::type) X ∈ (B::'b::type set)›*) fix X assume "X ∈ A//r" (*‹(X::'a set) ∈ (A::'a set) // (r::('a × 'a) set)›*) then obtain x where x: "x ∈ A" and X: "X = proj r x" (*goal: ‹(⋀x. ⟦x ∈ A; X = proj r x⟧ ⟹ thesis) ⟹ thesis›*) using ECH (*‹equiv A r›*) proj_image[of r A] (*‹proj r ` A = A // r›*) by blast hence "univ f X = f x" using ECH (*‹equiv A r›*) RES (*‹f respects r›*) univ_commute (*‹⟦equiv ?A ?r; ?f respects ?r; ?x ∈ ?A⟧ ⟹ univ ?f (proj ?r ?x) = ?f ?x›*) by fastforce thus "univ f X ∈ B" using x (*‹x ∈ A›*) PRES (*‹∀x∈A. f x ∈ B›*) by simp qed lemma card_suc_ordLess_imp_ordLeq: assumes ORD: "Card_order r" "Card_order r'" "card_order r'" and LESS: "r <o card_suc r'" shows "r ≤o r'" proof (-) (*goal: ‹r ≤o r'›*) have "Card_order (card_suc r')" by (rule Card_order_card_suc[OF ORD(3)] (*‹Card_order (card_suc r')›*)) then have "cardSuc r ≤o card_suc r'" using cardSuc_least (*‹⟦Card_order ?r; Card_order ?r'; ?r <o ?r'⟧ ⟹ cardSuc ?r ≤o ?r'›*) ORD (*‹Card_order r› ‹Card_order r'› ‹card_order r'›*) LESS (*‹(r::('a × 'a) set) <o card_suc (r'::('b × 'b) set)›*) by blast then have "cardSuc r ≤o cardSuc r'" using cardSuc_ordIso_card_suc (*‹card_order ?r ⟹ cardSuc ?r =o card_suc ?r›*) ordIso_symmetric (*‹?r =o ?r' ⟹ ?r' =o ?r›*) ordLeq_ordIso_trans (*‹⟦(?r::(?'a::type × ?'a::type) set) ≤o (?r'::(?'b::type × ?'b::type) set); ?r' =o (?r''::(?'c::type × ?'c::type) set)⟧ ⟹ ?r ≤o ?r''›*) ORD(3) (*‹card_order r'›*) by blast then show "?thesis" (*goal: ‹r ≤o r'›*) using cardSuc_mono_ordLeq (*‹⟦Card_order ?r; Card_order ?r'⟧ ⟹ (cardSuc ?r ≤o cardSuc ?r') = (?r ≤o ?r')›*) ORD (*‹Card_order r› ‹Card_order r'› ‹card_order r'›*) by blast qed lemma natLeq_ordLess_cinfinite: "⟦Cinfinite r; card_order r⟧ ⟹ natLeq <o card_suc r" using natLeq_ordLeq_cinfinite (*‹Cinfinite ?r ⟹ natLeq ≤o ?r›*) card_suc_greater (*‹card_order ?r ⟹ ?r <o card_suc ?r›*) ordLeq_ordLess_trans (*‹⟦?r ≤o ?r'; ?r' <o ?r''⟧ ⟹ ?r <o ?r''›*) by blast corollary natLeq_ordLess_cinfinite': "⟦Cinfinite r'; card_order r'; r ≡ card_suc r'⟧ ⟹ natLeq <o r" using natLeq_ordLess_cinfinite (*‹⟦Cinfinite (?r::(?'a × ?'a) set); card_order ?r⟧ ⟹ natLeq <o card_suc ?r›*) by blast ML_file ‹Tools/BNF/bnf_gfp_util.ML› ML_file ‹Tools/BNF/bnf_gfp_tactics.ML› ML_file ‹Tools/BNF/bnf_gfp.ML› ML_file ‹Tools/BNF/bnf_gfp_rec_sugar_tactics.ML› ML_file ‹Tools/BNF/bnf_gfp_rec_sugar.ML› end
{ "path": "Isabelle2024/src/HOL/BNF_Greatest_Fixpoint.thy", "repo": "Isabelle2024", "sha": "7284d915f61bbc371215b018372a6133c05a5fc5f43bddb29f49094db73c8828" }
(* Author: René Thiemann Akihisa Yamada License: BSD *) section ‹Elementary Column Operations› text ‹We define elementary column operations and also combine them with elementary row operations. These combined operations are the basis to perform operations which preserve similarity of matrices. They are applied later on to convert upper triangular matrices into Jordan normal form.› theory Column_Operations imports Gauss_Jordan_Elimination begin definition mat_multcol :: "nat ⇒ 'a :: semiring_1 ⇒ 'a mat ⇒ 'a mat" ("multcol") where "multcol k a A = mat (dim_row A) (dim_col A) (λ (i,j). if k = j then a * A $$ (i,j) else A $$ (i,j))" definition mat_swapcols :: "nat ⇒ nat ⇒ 'a mat ⇒ 'a mat" ("swapcols")where "swapcols k l A = mat (dim_row A) (dim_col A) (λ (i,j). if k = j then A $$ (i,l) else if l = j then A $$ (i,k) else A $$ (i,j))" definition mat_addcol_vec :: "nat ⇒ 'a :: plus vec ⇒ 'a mat ⇒ 'a mat" where "mat_addcol_vec k v A = mat (dim_row A) (dim_col A) (λ (i,j). if k = j then v $ i + A $$ (i,j) else A $$ (i,j))" definition mat_addcol :: "'a :: semiring_1 ⇒ nat ⇒ nat ⇒ 'a mat ⇒ 'a mat" ("addcol") where "addcol a k l A = mat (dim_row A) (dim_col A) (λ (i,j). if k = j then a * A $$ (i,l) + A $$ (i,j) else A $$ (i,j))" lemma index_mat_multcol[simp]: "i < dim_row A ⟹ j < dim_col A ⟹ multcol k a A $$ (i,j) = (if k = j then a * A $$ (i,j) else A $$ (i,j))" "i < dim_row A ⟹ j < dim_col A ⟹ multcol j a A $$ (i,j) = a * A $$ (i,j)" "i < dim_row A ⟹ j < dim_col A ⟹ k ≠ j ⟹ multcol k a A $$ (i,j) = A $$ (i,j)" "dim_row (multcol k a A) = dim_row A" "dim_col (multcol k a A) = dim_col A" unfolding mat_multcol_def (*goals: 1. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j)) $$ (i, j) = (if k = j then a * A $$ (i, j) else A $$ (i, j))› 2. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, ja). if j = ja then a * A $$ (i, ja) else A $$ (i, ja)) $$ (i, j) = a * A $$ (i, j)› 3. ‹⟦i < dim_row A; j < dim_col A; k ≠ j⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j)) $$ (i, j) = A $$ (i, j)› 4. ‹dim_row (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j))) = dim_row A› 5. ‹dim_col (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j))) = dim_col A›*) (*goals: 1. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j)) $$ (i, j) = (if k = j then a * A $$ (i, j) else A $$ (i, j))› 2. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, ja). if j = ja then a * A $$ (i, ja) else A $$ (i, ja)) $$ (i, j) = a * A $$ (i, j)› 3. ‹⟦i < dim_row A; j < dim_col A; k ≠ j⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j)) $$ (i, j) = A $$ (i, j)› 4. ‹dim_row (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j))) = dim_row A› 5. ‹dim_col (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, j) else A $$ (i, j))) = dim_col A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma index_mat_swapcols[simp]: "i < dim_row A ⟹ j < dim_col A ⟹ swapcols k l A $$ (i,j) = (if k = j then A $$ (i,l) else if l = j then A $$ (i,k) else A $$ (i,j))" "dim_row (swapcols k l A) = dim_row A" "dim_col (swapcols k l A) = dim_col A" unfolding mat_swapcols_def (*goals: 1. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j)) $$ (i, j) = (if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j))› 2. ‹dim_row (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j))) = dim_row A› 3. ‹dim_col (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j))) = dim_col A›*) (*goals: 1. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j)) $$ (i, j) = (if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j))› 2. ‹dim_row (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j))) = dim_row A› 3. ‹dim_col (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then A $$ (i, l) else if l = j then A $$ (i, k) else A $$ (i, j))) = dim_col A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma index_mat_addcol[simp]: "i < dim_row A ⟹ j < dim_col A ⟹ addcol a k l A $$ (i,j) = (if k = j then a * A $$ (i,l) + A $$ (i,j) else A $$ (i,j))" "i < dim_row A ⟹ j < dim_col A ⟹ addcol a j l A $$ (i,j) = a * A $$(i,l) + A$$(i,j)" "i < dim_row A ⟹ j < dim_col A ⟹ k ≠ j ⟹ addcol a k l A $$ (i,j) = A $$(i,j)" "dim_row (addcol a k l A) = dim_row A" "dim_col (addcol a k l A) = dim_col A" unfolding mat_addcol_def (*goals: 1. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j)) $$ (i, j) = (if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j))› 2. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, ja). if j = ja then a * A $$ (i, l) + A $$ (i, ja) else A $$ (i, ja)) $$ (i, j) = a * A $$ (i, l) + A $$ (i, j)› 3. ‹⟦i < dim_row A; j < dim_col A; k ≠ j⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j)) $$ (i, j) = A $$ (i, j)› 4. ‹dim_row (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j))) = dim_row A› 5. ‹dim_col (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j))) = dim_col A›*) (*goals: 1. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j)) $$ (i, j) = (if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j))› 2. ‹⟦i < dim_row A; j < dim_col A⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, ja). if j = ja then a * A $$ (i, l) + A $$ (i, ja) else A $$ (i, ja)) $$ (i, j) = a * A $$ (i, l) + A $$ (i, j)› 3. ‹⟦i < dim_row A; j < dim_col A; k ≠ j⟧ ⟹ mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j)) $$ (i, j) = A $$ (i, j)› 4. ‹dim_row (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j))) = dim_row A› 5. ‹dim_col (mat (dim_row A) (dim_col A) (λ(i, j). if k = j then a * A $$ (i, l) + A $$ (i, j) else A $$ (i, j))) = dim_col A› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . text ‹Each column-operation can be seen as a multiplication of an elementary matrix from the right› lemma col_addrow: "l ≠ i ⟹ i < n ⟹ col (addrow_mat n a k l) i = unit_vec n i" "k < n ⟹ l < n ⟹ col (addrow_mat n a k l) l = a ⋅⇩v unit_vec n k + unit_vec n l" (*goals: 1. ‹⟦l ≠ i; i < n⟧ ⟹ col (addrow_mat n a k l) i = unit_vec n i› 2. ‹⟦k < n; l < n⟧ ⟹ col (addrow_mat n a k l) l = a ⋅⇩v unit_vec n k + unit_vec n l› discuss goal 1*) apply (rule eq_vecI (*‹⟦⋀i. i < dim_vec ?w ⟹ ?v $ i = ?w $ i; dim_vec ?v = dim_vec ?w⟧ ⟹ ?v = ?w›*)) (*goals: 1. ‹⋀ia. ⟦l ≠ i; i < n; ia < dim_vec (unit_vec n i)⟧ ⟹ col (addrow_mat n a k l) i $ ia = unit_vec n i $ ia› 2. ‹⟦l ≠ i; i < n⟧ ⟹ dim_vec (col (addrow_mat n a k l) i) = dim_vec (unit_vec n i)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma col_addcol[simp]: "k < dim_col A ⟹ l < dim_col A ⟹ col (addcol a k l A) k = a ⋅⇩v col A l + col A k" apply (rule eq_vecI (*‹⟦⋀i. i < dim_vec ?w ⟹ ?v $ i = ?w $ i; dim_vec ?v = dim_vec ?w⟧ ⟹ ?v = ?w›*)) (*goals: 1. ‹⋀i. ⟦k < dim_col A; l < dim_col A; i < dim_vec (a ⋅⇩v col A l + col A k)⟧ ⟹ col (addcol a k l A) k $ i = (a ⋅⇩v col A l + col A k) $ i› 2. ‹⟦k < dim_col A; l < dim_col A⟧ ⟹ dim_vec (col (addcol a k l A) k) = dim_vec (a ⋅⇩v col A l + col A k)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma addcol_mat: assumes A: "A ∈ carrier_mat nr n" and k: "k < n" shows "addcol (a :: 'a :: comm_semiring_1) l k A = A * addrow_mat n a k l" apply (rule eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀(i::nat) j::nat. ⟦i < dim_row ((A::'a::comm_semiring_1 mat) * addrow_mat (n::nat) (a::'a::comm_semiring_1) (k::nat) (l::nat)); j < dim_col (A * addrow_mat n a k l)⟧ ⟹ addcol a l k A $$ (i, j) = (A * addrow_mat n a k l) $$ (i, j)› 2. ‹dim_row (addcol (a::'a::comm_semiring_1) (l::nat) (k::nat) (A::'a::comm_semiring_1 mat)) = dim_row (A * addrow_mat (n::nat) a k l)› 3. ‹dim_col (addcol (a::'a::comm_semiring_1) (l::nat) (k::nat) (A::'a::comm_semiring_1 mat)) = dim_col (A * addrow_mat (n::nat) a k l)› discuss goal 1*) apply ((insert A (*‹A ∈ carrier_mat nr n›*) k (*‹k < n›*))[1]) (*top goal: ‹⋀(i::nat) j::nat. ⟦i < dim_row ((A::'a mat) * addrow_mat (n::nat) (a::'a) (k::nat) (l::nat)); j < dim_col (A * addrow_mat n a k l)⟧ ⟹ addcol a l k A $$ (i, j) = (A * addrow_mat n a k l) $$ (i, j)› and 2 goals remain*) apply ((auto simp: col_addrow (*‹⟦?l ≠ ?i; ?i < ?n⟧ ⟹ col (addrow_mat ?n ?a ?k ?l) ?i = unit_vec ?n ?i› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (addrow_mat ?n ?a ?k ?l) ?l = ?a ⋅⇩v unit_vec ?n ?k + unit_vec ?n ?l›*) scalar_prod_add_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n; ?v₃ ∈ carrier_vec n⟧ ⟹ ?v₁ ∙ (?v₂ + ?v₃) = ?v₁ ∙ ?v₂ + ?v₁ ∙ ?v₃›*) scalar_prod_smult_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n⟧ ⟹ ?v₁ ∙ (?a ⋅⇩v ?v₂) = ?a * (?v₁ ∙ ?v₂)›*))[1]) (*discuss goal 2*) apply ((insert A (*‹A ∈ carrier_mat nr n›*) k (*‹k < n›*))[1]) (*top goal: ‹dim_row (addcol a l k A) = dim_row (A * addrow_mat n a k l)› and 1 goal remains*) apply ((auto simp: col_addrow (*‹⟦?l ≠ ?i; ?i < ?n⟧ ⟹ col (addrow_mat ?n ?a ?k ?l) ?i = unit_vec ?n ?i› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (addrow_mat ?n ?a ?k ?l) ?l = ?a ⋅⇩v unit_vec ?n ?k + unit_vec ?n ?l›*) scalar_prod_add_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n; ?v₃ ∈ carrier_vec n⟧ ⟹ ?v₁ ∙ (?v₂ + ?v₃) = ?v₁ ∙ ?v₂ + ?v₁ ∙ ?v₃›*) scalar_prod_smult_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n⟧ ⟹ ?v₁ ∙ (?a ⋅⇩v ?v₂) = ?a * (?v₁ ∙ ?v₂)›*))[1]) (*discuss goal 3*) apply ((insert A (*‹A ∈ carrier_mat nr n›*) k (*‹k < n›*))[1]) (*goal: ‹dim_col (addcol a l k A) = dim_col (A * addrow_mat n a k l)›*) apply ((auto simp: col_addrow (*‹⟦?l ≠ ?i; ?i < ?n⟧ ⟹ col (addrow_mat ?n ?a ?k ?l) ?i = unit_vec ?n ?i› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (addrow_mat ?n ?a ?k ?l) ?l = ?a ⋅⇩v unit_vec ?n ?k + unit_vec ?n ?l›*) scalar_prod_add_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n; ?v₃ ∈ carrier_vec n⟧ ⟹ ?v₁ ∙ (?v₂ + ?v₃) = ?v₁ ∙ ?v₂ + ?v₁ ∙ ?v₃›*) scalar_prod_smult_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n⟧ ⟹ ?v₁ ∙ (?a ⋅⇩v ?v₂) = ?a * (?v₁ ∙ ?v₂)›*))[1]) (*proven 3 subgoals*) . lemma col_multrow: "k ≠ i ⟹ i < n ⟹ col (multrow_mat n k a) i = unit_vec n i" "k < n ⟹ col (multrow_mat n k a) k = a ⋅⇩v unit_vec n k" (*goals: 1. ‹⟦k ≠ i; i < n⟧ ⟹ col (multrow_mat n k a) i = unit_vec n i› 2. ‹k < n ⟹ col (multrow_mat n k a) k = a ⋅⇩v unit_vec n k› discuss goal 1*) apply (rule eq_vecI (*‹⟦⋀i. i < dim_vec ?w ⟹ ?v $ i = ?w $ i; dim_vec ?v = dim_vec ?w⟧ ⟹ ?v = ?w›*)) (*goals: 1. ‹⋀ia::nat. ⟦(k::nat) ≠ (i::nat); i < (n::nat); ia < dim_vec (unit_vec n i)⟧ ⟹ col (multrow_mat n k (a::'a)) i $ ia = unit_vec n i $ ia› 2. ‹⟦(k::nat) ≠ (i::nat); i < (n::nat)⟧ ⟹ dim_vec (col (multrow_mat n k (a::'a)) i) = dim_vec (unit_vec n i)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma multcol_mat: assumes A: "(A :: 'a :: comm_ring_1 mat) ∈ carrier_mat nr n" shows "multcol k a A = A * multrow_mat n k a" apply (rule eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀i j. ⟦i < dim_row (A * multrow_mat n k a); j < dim_col (A * multrow_mat n k a)⟧ ⟹ multcol k a A $$ (i, j) = (A * multrow_mat n k a) $$ (i, j)› 2. ‹dim_row (multcol k a A) = dim_row (A * multrow_mat n k a)› 3. ‹dim_col (multcol k a A) = dim_col (A * multrow_mat n k a)› discuss goal 1*) apply ((insert A (*‹A ∈ carrier_mat nr n›*))[1]) (*top goal: ‹⋀i j. ⟦i < dim_row (A * multrow_mat n k a); j < dim_col (A * multrow_mat n k a)⟧ ⟹ multcol k a A $$ (i, j) = (A * multrow_mat n k a) $$ (i, j)› and 2 goals remain*) apply ((auto simp: col_multrow (*‹⟦?k ≠ ?i; ?i < ?n⟧ ⟹ col (multrow_mat ?n ?k ?a) ?i = unit_vec ?n ?i› ‹?k < ?n ⟹ col (multrow_mat ?n ?k ?a) ?k = ?a ⋅⇩v unit_vec ?n ?k›*) smult_scalar_prod_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n⟧ ⟹ (?a ⋅⇩v ?v₁) ∙ ?v₂ = ?a * (?v₁ ∙ ?v₂)›*))[1]) (*discuss goal 2*) apply ((insert A (*‹(A::'a mat) ∈ carrier_mat (nr::nat) (n::nat)›*))[1]) (*top goal: ‹dim_row (multcol k a A) = dim_row (A * multrow_mat n k a)› and 1 goal remains*) apply ((auto simp: col_multrow (*‹⟦?k ≠ ?i; ?i < ?n⟧ ⟹ col (multrow_mat ?n ?k ?a) ?i = unit_vec ?n ?i› ‹?k < ?n ⟹ col (multrow_mat ?n ?k ?a) ?k = ?a ⋅⇩v unit_vec ?n ?k›*) smult_scalar_prod_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n⟧ ⟹ (?a ⋅⇩v ?v₁) ∙ ?v₂ = ?a * (?v₁ ∙ ?v₂)›*))[1]) (*discuss goal 3*) apply ((insert A (*‹A ∈ carrier_mat nr n›*))[1]) (*goal: ‹dim_col (multcol k a A) = dim_col (A * multrow_mat n k a)›*) apply ((auto simp: col_multrow (*‹⟦?k ≠ ?i; ?i < ?n⟧ ⟹ col (multrow_mat ?n ?k ?a) ?i = unit_vec ?n ?i› ‹?k < ?n ⟹ col (multrow_mat ?n ?k ?a) ?k = ?a ⋅⇩v unit_vec ?n ?k›*) smult_scalar_prod_distrib[of _ n] (*‹⟦?v₁ ∈ carrier_vec n; ?v₂ ∈ carrier_vec n⟧ ⟹ (?a ⋅⇩v ?v₁) ∙ ?v₂ = ?a * (?v₁ ∙ ?v₂)›*))[1]) (*proven 3 subgoals*) . lemma col_swaprows: "l < n ⟹ col (swaprows_mat n l l) l = unit_vec n l" "i ≠ k ⟹ i ≠ l ⟹ i < n ⟹ col (swaprows_mat n k l) i = unit_vec n i" "k < n ⟹ l < n ⟹ col (swaprows_mat n k l) l = unit_vec n k" "k < n ⟹ l < n ⟹ col (swaprows_mat n k l) k = unit_vec n l" (*goals: 1. ‹l < n ⟹ col (swaprows_mat n l l) l = unit_vec n l› 2. ‹⟦i ≠ k; i ≠ l; i < n⟧ ⟹ col (swaprows_mat n k l) i = unit_vec n i› 3. ‹⟦k < n; l < n⟧ ⟹ col (swaprows_mat n k l) l = unit_vec n k› 4. ‹⟦k < n; l < n⟧ ⟹ col (swaprows_mat n k l) k = unit_vec n l› discuss goal 1*) apply (rule eq_vecI (*‹⟦⋀i. i < dim_vec ?w ⟹ ?v $ i = ?w $ i; dim_vec ?v = dim_vec ?w⟧ ⟹ ?v = ?w›*)) (*goals: 1. ‹⋀i::nat. ⟦(l::nat) < (n::nat); i < dim_vec (unit_vec n l)⟧ ⟹ col (swaprows_mat n l l) l $ i = unit_vec n l $ i› 2. ‹(l::nat) < (n::nat) ⟹ dim_vec (col (swaprows_mat n l l) l) = dim_vec (unit_vec n l)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemma swapcols_mat: assumes A: "A ∈ carrier_mat nr n" and k: "k < n" "l < n" shows "swapcols k l A = A * swaprows_mat n k l" apply (rule eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀i j. ⟦i < dim_row (A * swaprows_mat n k l); j < dim_col (A * swaprows_mat n k l)⟧ ⟹ swapcols k l A $$ (i, j) = (A * swaprows_mat n k l) $$ (i, j)› 2. ‹dim_row (swapcols k l A) = dim_row (A * swaprows_mat n k l)› 3. ‹dim_col (swapcols k l A) = dim_col (A * swaprows_mat n k l)› discuss goal 1*) apply ((insert A (*‹A ∈ carrier_mat nr n›*) k (*‹k < n› ‹l < n›*))[1]) (*top goal: ‹⋀i j. ⟦i < dim_row (A * swaprows_mat n k l); j < dim_col (A * swaprows_mat n k l)⟧ ⟹ swapcols k l A $$ (i, j) = (A * swaprows_mat n k l) $$ (i, j)› and 2 goals remain*) apply ((auto simp: col_swaprows (*‹?l < ?n ⟹ col (swaprows_mat ?n ?l ?l) ?l = unit_vec ?n ?l› ‹⟦?i ≠ ?k; ?i ≠ ?l; ?i < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?i = unit_vec ?n ?i› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?l = unit_vec ?n ?k› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?k = unit_vec ?n ?l›*))[1]) (*discuss goal 2*) apply ((insert A (*‹A ∈ carrier_mat nr n›*) k (*‹k < n› ‹l < n›*))[1]) (*top goal: ‹dim_row (swapcols k l A) = dim_row (A * swaprows_mat n k l)› and 1 goal remains*) apply ((auto simp: col_swaprows (*‹?l < ?n ⟹ col (swaprows_mat ?n ?l ?l) ?l = unit_vec ?n ?l› ‹⟦?i ≠ ?k; ?i ≠ ?l; ?i < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?i = unit_vec ?n ?i› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?l = unit_vec ?n ?k› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?k = unit_vec ?n ?l›*))[1]) (*discuss goal 3*) apply ((insert A (*‹A ∈ carrier_mat nr n›*) k (*‹k < n› ‹l < n›*))[1]) (*goal: ‹dim_col (swapcols (k::nat) (l::nat) (A::'a mat)) = dim_col (A * swaprows_mat (n::nat) k l)›*) apply ((auto simp: col_swaprows (*‹?l < ?n ⟹ col (swaprows_mat ?n ?l ?l) ?l = unit_vec ?n ?l› ‹⟦?i ≠ ?k; ?i ≠ ?l; ?i < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?i = unit_vec ?n ?i› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?l = unit_vec ?n ?k› ‹⟦?k < ?n; ?l < ?n⟧ ⟹ col (swaprows_mat ?n ?k ?l) ?k = unit_vec ?n ?l›*))[1]) (*proven 3 subgoals*) . text ‹Combining row and column-operations yields similarity transformations.› definition add_col_sub_row :: "'a :: ring_1 ⇒ nat ⇒ nat ⇒ 'a mat ⇒ 'a mat" where "add_col_sub_row a k l A = addrow (- a) k l (addcol a l k A)" definition mult_col_div_row :: "'a :: field ⇒ nat ⇒ 'a mat ⇒ 'a mat" where "mult_col_div_row a k A = multrow k (inverse a) (multcol k a A)" definition swap_cols_rows :: "nat ⇒ nat ⇒ 'a mat ⇒ 'a mat" where "swap_cols_rows k l A = swaprows k l (swapcols k l A)" lemma add_col_sub_row_carrier[simp]: "dim_row (add_col_sub_row a k l A) = dim_row A" "dim_col (add_col_sub_row a k l A) = dim_col A" "A ∈ carrier_mat n n ⟹ add_col_sub_row a k l A ∈ carrier_mat n n" unfolding add_col_sub_row_def carrier_mat_def (*goals: 1. ‹dim_row (addrow (- a) k l (addcol a l k A)) = dim_row A› 2. ‹dim_col (addrow (- a) k l (addcol a l k A)) = dim_col A› 3. ‹A ∈ {m. dim_row m = n ∧ dim_col m = n} ⟹ addrow (- a) k l (addcol a l k A) ∈ {m. dim_row m = n ∧ dim_col m = n}›*) (*goals: 1. ‹dim_row (addrow (- a) k l (addcol a l k A)) = dim_row A› 2. ‹dim_col (addrow (- a) k l (addcol a l k A)) = dim_col A› 3. ‹A ∈ {m. dim_row m = n ∧ dim_col m = n} ⟹ addrow (- a) k l (addcol a l k A) ∈ {m. dim_row m = n ∧ dim_col m = n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma add_col_sub_index_row[simp]: "i < dim_row A ⟹ i < dim_col A ⟹ j < dim_row A ⟹ j < dim_col A ⟹ l < dim_row A ⟹ add_col_sub_row a k l A $$ (i,j) = (if i = k ∧ j = l then A $$ (i, j) + a * A $$ (i, i) - a * a * A $$ (j, i) - a * A $$ (j, j) else if i = k ∧ j ≠ l then A $$ (i, j) - a * A $$ (l, j) else if i ≠ k ∧ j = l then A $$ (i, j) + a * A $$ (i, k) else A $$ (i,j))" unfolding add_col_sub_row_def (*goal: ‹⟦i < dim_row A; i < dim_col A; j < dim_row A; j < dim_col A; l < dim_row A⟧ ⟹ addrow (- a) k l (addcol a l k A) $$ (i, j) = (if i = k ∧ j = l then A $$ (i, j) + a * A $$ (i, i) - a * a * A $$ (j, i) - a * A $$ (j, j) else if i = k ∧ j ≠ l then A $$ (i, j) - a * A $$ (l, j) else if i ≠ k ∧ j = l then A $$ (i, j) + a * A $$ (i, k) else A $$ (i, j))›*) by (auto simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*)) lemma mult_col_div_index_row[simp]: "i < dim_row A ⟹ i < dim_col A ⟹ j < dim_row A ⟹ j < dim_col A ⟹ a ≠ 0 ⟹ mult_col_div_row a k A $$ (i,j) = (if i = k ∧ j ≠ i then inverse a * A $$ (i, j) else if j = k ∧ j ≠ i then a * A $$ (i, j) else A $$ (i,j))" unfolding mult_col_div_row_def (*goal: ‹⟦i < dim_row A; i < dim_col A; j < dim_row A; j < dim_col A; a ≠ 0⟧ ⟹ multrow k (inverse a) (multcol k a A) $$ (i, j) = (if i = k ∧ j ≠ i then inverse a * A $$ (i, j) else if j = k ∧ j ≠ i then a * A $$ (i, j) else A $$ (i, j))›*) by auto lemma mult_col_div_row_carrier[simp]: "dim_row (mult_col_div_row a k A) = dim_row A" "dim_col (mult_col_div_row a k A) = dim_col A" "A ∈ carrier_mat n n ⟹ mult_col_div_row a k A ∈ carrier_mat n n" unfolding mult_col_div_row_def carrier_mat_def (*goals: 1. ‹dim_row (multrow k (inverse a) (multcol k a A)) = dim_row A› 2. ‹dim_col (multrow k (inverse a) (multcol k a A)) = dim_col A› 3. ‹A ∈ {m. dim_row m = n ∧ dim_col m = n} ⟹ multrow k (inverse a) (multcol k a A) ∈ {m. dim_row m = n ∧ dim_col m = n}›*) (*goals: 1. ‹dim_row (multrow (k::nat) (inverse (a::'a)) (multcol k a (A::'a mat))) = dim_row A› 2. ‹dim_col (multrow (k::nat) (inverse (a::'a)) (multcol k a (A::'a mat))) = dim_col A› 3. ‹(A::'a mat) ∈ {m::'a mat. dim_row m = (n::nat) ∧ dim_col m = n} ⟹ multrow (k::nat) (inverse (a::'a)) (multcol k a A) ∈ {m::'a mat. dim_row m = n ∧ dim_col m = n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma swap_cols_rows_carrier[simp]: "dim_row (swap_cols_rows k l A) = dim_row A" "dim_col (swap_cols_rows k l A) = dim_col A" "A ∈ carrier_mat n n ⟹ swap_cols_rows k l A ∈ carrier_mat n n" unfolding swap_cols_rows_def carrier_mat_def (*goals: 1. ‹dim_row (swaprows k l (swapcols k l A)) = dim_row A› 2. ‹dim_col (swaprows k l (swapcols k l A)) = dim_col A› 3. ‹A ∈ {m. dim_row m = n ∧ dim_col m = n} ⟹ swaprows k l (swapcols k l A) ∈ {m. dim_row m = n ∧ dim_col m = n}›*) (*goals: 1. ‹dim_row (swaprows k l (swapcols k l A)) = dim_row A› 2. ‹dim_col (swaprows k l (swapcols k l A)) = dim_col A› 3. ‹A ∈ {m. dim_row m = n ∧ dim_col m = n} ⟹ swaprows k l (swapcols k l A) ∈ {m. dim_row m = n ∧ dim_col m = n}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma swap_cols_rows_index[simp]: "i < dim_row A ⟹ i < dim_col A ⟹ j < dim_row A ⟹ j < dim_col A ⟹ a < dim_row A ⟹ b < dim_row A ⟹ swap_cols_rows a b A $$ (i,j) = A $$ (if i = a then b else if i = b then a else i, if j = a then b else if j = b then a else j)" unfolding swap_cols_rows_def (*goal: ‹⟦i < dim_row A; i < dim_col A; j < dim_row A; j < dim_col A; a < dim_row A; b < dim_row A⟧ ⟹ swaprows a b (swapcols a b A) $$ (i, j) = A $$ (if i = a then b else if i = b then a else i, if j = a then b else if j = b then a else j)›*) by auto lemma add_col_sub_row_similar: assumes A: "A ∈ carrier_mat n n" and kl: "k < n" "l < n" "k ≠ l" shows "similar_mat (add_col_sub_row a k l A) (A :: 'a :: comm_ring_1 mat)" proof (rule similar_matI (*‹⟦{?A, ?B, ?P, ?Q} ⊆ carrier_mat ?n ?n; ?P * ?Q = 1⇩m ?n; ?Q * ?P = 1⇩m ?n; ?A = ?P * ?B * ?Q⟧ ⟹ similar_mat ?A ?B›*)) (*goals: 1. ‹{add_col_sub_row (a::'a) (k::nat) (l::nat) (A::'a mat), A, ?P::'a mat, ?Q::'a mat} ⊆ carrier_mat (?n::nat) ?n› 2. ‹(?P::'a mat) * (?Q::'a mat) = 1⇩m (?n::nat)› 3. ‹(?Q::'a mat) * (?P::'a mat) = 1⇩m (?n::nat)› 4. ‹add_col_sub_row (a::'a) (k::nat) (l::nat) (A::'a mat) = (?P::'a mat) * A * (?Q::'a mat)›*) let ?P = "addrow_mat n (-a) k l" let ?Q = "addrow_mat n a k l" let ?B = "add_col_sub_row a k l A" show carr: "{?B, A, ?P, ?Q} ⊆ carrier_mat n n" using A (*‹A ∈ carrier_mat n n›*) by auto show "?Q * ?P = 1⇩m n" by (rule addrow_mat_inv[OF kl] (*‹addrow_mat n ?a k l * addrow_mat n (- ?a) k l = 1⇩m n›*)) show "?P * ?Q = 1⇩m n" using addrow_mat_inv[OF kl, of "-a"] (*‹addrow_mat n (- a) k l * addrow_mat n (- (- a)) k l = 1⇩m n›*) by simp have col: "addcol a l k A = A * ?Q" by (rule addcol_mat[OF A kl(1)] (*‹addcol ?a ?l k A = A * addrow_mat n ?a k ?l›*)) have "?B = ?P * (A * ?Q)" unfolding add_col_sub_row_def col (*goal: ‹addrow (- (a::'a::comm_ring_1)) (k::nat) (l::nat) ((A::'a::comm_ring_1 mat) * addrow_mat (n::nat) a k l) = addrow_mat n (- a) k l * (A * addrow_mat n a k l)›*) apply (rule addrow_mat[OF _ kl(2), of _ n] (*‹?A ∈ carrier_mat n n ⟹ addrow ?a ?k l ?A = addrow_mat n ?a ?k l * ?A›*)) (*goal: ‹addrow (- a) k l (A * addrow_mat n a k l) = addrow_mat n (- a) k l * (A * addrow_mat n a k l)›*) apply (insert A (*‹A ∈ carrier_mat n n›*)) (*goal: ‹A * addrow_mat n a k l ∈ carrier_mat n n›*) by simp thus "?B = ?P * A * ?Q" using carr (*‹{add_col_sub_row a k l A, A, addrow_mat n (- a) k l, addrow_mat n a k l} ⊆ carrier_mat n n›*) by (simp add: assoc_mult_mat[of _ n n _ n _ n] (*‹⟦(?A::?'a mat) ∈ carrier_mat (n::nat) n; (?B::?'a mat) ∈ carrier_mat n n; (?C::?'a mat) ∈ carrier_mat n n⟧ ⟹ ?A * ?B * ?C = ?A * (?B * ?C)›*)) qed lemma mult_col_div_row_similar: assumes A: "A ∈ carrier_mat n n" and ak: "k < n" "a ≠ 0" shows "similar_mat (mult_col_div_row a k A) A" proof (rule similar_matI (*‹⟦{?A, ?B, ?P, ?Q} ⊆ carrier_mat ?n ?n; ?P * ?Q = 1⇩m ?n; ?Q * ?P = 1⇩m ?n; ?A = ?P * ?B * ?Q⟧ ⟹ similar_mat ?A ?B›*)) (*goals: 1. ‹{mult_col_div_row a k A, A, ?P, ?Q} ⊆ carrier_mat ?n ?n› 2. ‹?P * ?Q = 1⇩m ?n› 3. ‹?Q * ?P = 1⇩m ?n› 4. ‹mult_col_div_row a k A = ?P * A * ?Q›*) let ?P = "multrow_mat n k (inverse a)" let ?Q = "multrow_mat n k a" let ?B = "mult_col_div_row a k A" show carr: "{?B, A, ?P, ?Q} ⊆ carrier_mat n n" using A (*‹(A::'a::field mat) ∈ carrier_mat (n::nat) n›*) by auto show "?Q * ?P = 1⇩m n" by (rule multrow_mat_inv[OF ak] (*‹multrow_mat n k a * multrow_mat n k (inverse a) = 1⇩m n›*)) show "?P * ?Q = 1⇩m n" using multrow_mat_inv[OF ak ( 1 ), of "inverse a"] (*‹inverse a ≠ 0 ⟹ multrow_mat n k (inverse a) * multrow_mat n k (inverse (inverse a)) = 1⇩m n›*) ak(2) (*‹a ≠ 0›*) by simp have col: "multcol k a A = A * ?Q" by (rule multcol_mat[OF A] (*‹multcol ?k ?a A = A * multrow_mat n ?k ?a›*)) have "?B = ?P * (A * ?Q)" unfolding mult_col_div_row_def col (*goal: ‹multrow k (inverse a) (A * multrow_mat n k a) = multrow_mat n k (inverse a) * (A * multrow_mat n k a)›*) apply (rule multrow_mat[of _ n n] (*‹?A ∈ carrier_mat n n ⟹ multrow ?k ?a ?A = multrow_mat n ?k ?a * ?A›*)) (*goal: ‹multrow k (inverse a) (A * multrow_mat n k a) = multrow_mat n k (inverse a) * (A * multrow_mat n k a)›*) apply (insert A (*‹A ∈ carrier_mat n n›*)) (*goal: ‹A * multrow_mat n k a ∈ carrier_mat n n›*) by simp thus "?B = ?P * A * ?Q" using carr (*‹{mult_col_div_row a k A, A, multrow_mat n k (inverse a), multrow_mat n k a} ⊆ carrier_mat n n›*) by (simp add: assoc_mult_mat[of _ n n _ n _ n] (*‹⟦?A ∈ carrier_mat n n; ?B ∈ carrier_mat n n; ?C ∈ carrier_mat n n⟧ ⟹ ?A * ?B * ?C = ?A * (?B * ?C)›*)) qed lemma swap_cols_rows_similar: assumes A: "A ∈ carrier_mat n n" and kl: "k < n" "l < n" shows "similar_mat (swap_cols_rows k l A) A" proof (rule similar_matI (*‹⟦{?A::?'a::semiring_1 mat, ?B::?'a::semiring_1 mat, ?P::?'a::semiring_1 mat, ?Q::?'a::semiring_1 mat} ⊆ carrier_mat (?n::nat) ?n; ?P * ?Q = 1⇩m ?n; ?Q * ?P = 1⇩m ?n; ?A = ?P * ?B * ?Q⟧ ⟹ similar_mat ?A ?B›*)) (*goals: 1. ‹{swap_cols_rows k l A, A, ?P, ?Q} ⊆ carrier_mat ?n ?n› 2. ‹?P * ?Q = 1⇩m ?n› 3. ‹?Q * ?P = 1⇩m ?n› 4. ‹swap_cols_rows k l A = ?P * A * ?Q›*) let ?P = "swaprows_mat n k l" let ?B = "swap_cols_rows k l A" show carr: "{?B, A, ?P, ?P} ⊆ carrier_mat n n" using A (*‹A ∈ carrier_mat n n›*) by auto show "?P * ?P = 1⇩m n" by (rule swaprows_mat_inv[OF kl] (*‹swaprows_mat n k l * swaprows_mat n k l = 1⇩m n›*)) show "?P * ?P = 1⇩m n" by fact have col: "swapcols k l A = A * ?P" by (rule swapcols_mat[OF A kl] (*‹swapcols k l A = A * swaprows_mat n k l›*)) have "?B = ?P * (A * ?P)" unfolding swap_cols_rows_def col (*goal: ‹swaprows k l (A * swaprows_mat n k l) = swaprows_mat n k l * (A * swaprows_mat n k l)›*) apply (rule swaprows_mat[of _ n n (*‹⟦(?A::?'a mat) ∈ carrier_mat (n::nat) n; (?k::nat) < n; (?l::nat) < n⟧ ⟹ swaprows ?k ?l ?A = swaprows_mat n ?k ?l * ?A›*) ]) (*goals: 1. ‹A * swaprows_mat n k l ∈ carrier_mat n n› 2. ‹k < n› 3. ‹l < n› discuss goal 1*) apply ((insert A (*‹A ∈ carrier_mat n n›*) kl (*‹k < n› ‹l < n›*))[1]) (*top goal: ‹A * swaprows_mat n k l ∈ carrier_mat n n› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert A (*‹A ∈ carrier_mat n n›*) kl (*‹k < n› ‹l < n›*))[1]) (*top goal: ‹k < n› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 3*) apply ((insert A (*‹A ∈ carrier_mat n n›*) kl (*‹k < n› ‹l < n›*))[1]) (*goal: ‹l < n›*) apply ((auto)[1]) (*proven 3 subgoals*) . thus "?B = ?P * A * ?P" using carr (*‹{swap_cols_rows k l A, A, swaprows_mat n k l, swaprows_mat n k l} ⊆ carrier_mat n n›*) by (simp add: assoc_mult_mat[of _ n n _ n _ n] (*‹⟦?A ∈ carrier_mat n n; ?B ∈ carrier_mat n n; ?C ∈ carrier_mat n n⟧ ⟹ ?A * ?B * ?C = ?A * (?B * ?C)›*)) qed (* THIS LINE SEPARATES AFP-ENTRY FROM NEWER DEVELOPMENTS *) lemma swapcols_carrier[simp]: "(swapcols l k A ∈ carrier_mat n m) = (A ∈ carrier_mat n m)" unfolding mat_swapcols_def carrier_mat_def (*goal: ‹(mat (dim_row A) (dim_col A) (λ(i, j). if l = j then A $$ (i, k) else if k = j then A $$ (i, l) else A $$ (i, j)) ∈ {ma. dim_row ma = n ∧ dim_col ma = m}) = (A ∈ {ma. dim_row ma = n ∧ dim_col ma = m})›*) by auto fun swap_row_to_front :: "'a mat ⇒ nat ⇒ 'a mat" where "swap_row_to_front A 0 = A" | "swap_row_to_front A (Suc I) = swap_row_to_front (swaprows I (Suc I) A) I" fun swap_col_to_front :: "'a mat ⇒ nat ⇒ 'a mat" where "swap_col_to_front A 0 = A" | "swap_col_to_front A (Suc I) = swap_col_to_front (swapcols I (Suc I) A) I" lemma swap_row_to_front_result: "A ∈ carrier_mat n m ⟹ I < n ⟹ swap_row_to_front A I = mat n m (λ (i,j). if i = 0 then A $$ (I,j) else if i ≤ I then A $$ (i - 1, j) else A $$ (i,j))" proof (induct I arbitrary: A) (*goals: 1. ‹⋀A. ⟦A ∈ carrier_mat n m; 0 < n⟧ ⟹ swap_row_to_front A 0 = mat n m (λ(i, j). if i = 0 then A $$ (0, j) else if i ≤ 0 then A $$ (i - 1, j) else A $$ (i, j))› 2. ‹⋀I A. ⟦⋀A. ⟦A ∈ carrier_mat n m; I < n⟧ ⟹ swap_row_to_front A I = mat n m (λ(i, j). if i = 0 then A $$ (I, j) else if i ≤ I then A $$ (i - 1, j) else A $$ (i, j)); A ∈ carrier_mat n m; Suc I < n⟧ ⟹ swap_row_to_front A (Suc I) = mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j))›*) case 0 (*‹A ∈ carrier_mat n m› ‹0 < n›*) thus "?case" (*goal: ‹swap_row_to_front (A::'a::type mat) (0::nat) = mat (n::nat) (m::nat) (λa::nat × nat. case a of (i::nat, j::nat) ⇒ if i = (0::nat) then A $$ (0::nat, j) else if i ≤ (0::nat) then A $$ (i - (1::nat), j) else A $$ (i, j))›*) apply (intro eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀i j. ⟦A ∈ carrier_mat n m; 0 < n; i < dim_row (mat n m (λa. case a of (i, j) ⇒ if i = 0 then A $$ (0, j) else if i ≤ 0 then A $$ (i - 1, j) else A $$ (i, j))); j < dim_col (mat n m (λa. case a of (i, j) ⇒ if i = 0 then A $$ (0, j) else if i ≤ 0 then A $$ (i - 1, j) else A $$ (i, j)))⟧ ⟹ swap_row_to_front A 0 $$ (i, j) = mat n m (λa. case a of (i, j) ⇒ if i = 0 then A $$ (0, j) else if i ≤ 0 then A $$ (i - 1, j) else A $$ (i, j)) $$ (i, j)› 2. ‹⟦A ∈ carrier_mat n m; 0 < n⟧ ⟹ dim_row (swap_row_to_front A 0) = dim_row (mat n m (λa. case a of (i, j) ⇒ if i = 0 then A $$ (0, j) else if i ≤ 0 then A $$ (i - 1, j) else A $$ (i, j)))› 3. ‹⟦A ∈ carrier_mat n m; 0 < n⟧ ⟹ dim_col (swap_row_to_front A 0) = dim_col (mat n m (λa. case a of (i, j) ⇒ if i = 0 then A $$ (0, j) else if i ≤ 0 then A $$ (i - 1, j) else A $$ (i, j)))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . next (*goal: ‹⋀I A. ⟦⋀A. ⟦A ∈ carrier_mat n m; I < n⟧ ⟹ swap_row_to_front A I = mat n m (λ(i, j). if i = 0 then A $$ (I, j) else if i ≤ I then A $$ (i - 1, j) else A $$ (i, j)); A ∈ carrier_mat n m; Suc I < n⟧ ⟹ swap_row_to_front A (Suc I) = mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j))›*) case (Suc I A) (*‹⟦?A ∈ carrier_mat n m; I < n⟧ ⟹ swap_row_to_front ?A I = mat n m (λa. case a of (i, j) ⇒ if i = 0 then ?A $$ (I, j) else if i ≤ I then ?A $$ (i - 1, j) else ?A $$ (i, j))› ‹A ∈ carrier_mat n m› ‹Suc (I::nat) < (n::nat)›*) from Suc(3) (*‹Suc (I::nat) < (n::nat)›*) have I: "I < n" by auto let ?I = "Suc I" let ?A = "swaprows I ?I A" have AA: "?A ∈ carrier_mat n m" using Suc(2) (*‹A ∈ carrier_mat n m›*) by simp have "swap_row_to_front A (Suc I) = swap_row_to_front ?A I" by simp also (*calculation: ‹swap_row_to_front A (Suc I) = swap_row_to_front (swaprows I (Suc I) A) I›*) have "… = mat n m (λ(i, j). if i = 0 then ?A $$ (I, j) else if i ≤ I then ?A $$ (i - 1, j) else ?A $$ (i, j))" using Suc(1)[OF AA I] (*‹swap_row_to_front (swaprows I (Suc I) A) I = mat n m (λa. case a of (i, j) ⇒ if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))›*) by simp also (*calculation: ‹swap_row_to_front A (Suc I) = mat n m (λ(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))›*) have "… = mat n m (λ(i, j). if i = 0 then A $$ (?I, j) else if i ≤ ?I then A $$ (i - 1, j) else A $$ (i, j))" apply (rule eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀i j. ⟦i < dim_row (mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j))); j < dim_col (mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j)))⟧ ⟹ mat n m (λ(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j)) $$ (i, j) = mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j)) $$ (i, j)› 2. ‹dim_row (mat n m (λ(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))) = dim_row (mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j)))› 3. ‹dim_col (mat n m (λ(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))) = dim_col (mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j)))› discuss goal 1*) apply ((insert I (*‹I < n›*) Suc( (*‹A ∈ carrier_mat n m›*) 2))[1]) (*top goal: ‹⋀(i::nat) j::nat. ⟦i < dim_row (mat (n::nat) (m::nat) (λ(i::nat, j::nat). if i = (0::nat) then (A::'a::type mat) $$ (Suc (I::nat), j) else if i ≤ Suc I then A $$ (i - (1::nat), j) else A $$ (i, j))); j < dim_col (mat n m (λ(i::nat, j::nat). if i = (0::nat) then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - (1::nat), j) else A $$ (i, j)))⟧ ⟹ mat n m (λ(i::nat, j::nat). if i = (0::nat) then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - (1::nat), j) else swaprows I (Suc I) A $$ (i, j)) $$ (i, j) = mat n m (λ(i::nat, j::nat). if i = (0::nat) then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - (1::nat), j) else A $$ (i, j)) $$ (i, j)› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert I (*‹I < n›*) Suc( (*‹A ∈ carrier_mat n m›*) 2))[1]) (*top goal: ‹dim_row (mat n m (λ(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))) = dim_row (mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j)))› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 3*) apply ((insert I (*‹I < n›*) Suc( (*‹A ∈ carrier_mat n m›*) 2))[1]) (*goal: ‹dim_col (mat n m (λ(i, j). if i = 0 then swaprows I (Suc I) A $$ (I, j) else if i ≤ I then swaprows I (Suc I) A $$ (i - 1, j) else swaprows I (Suc I) A $$ (i, j))) = dim_col (mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j)))›*) apply ((auto)[1]) (*proven 3 subgoals*) . finally (*calculation: ‹swap_row_to_front A (Suc I) = mat n m (λ(i, j). if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j))›*) show "?case" (*goal: ‹swap_row_to_front A (Suc I) = mat n m (λa. case a of (i, j) ⇒ if i = 0 then A $$ (Suc I, j) else if i ≤ Suc I then A $$ (i - 1, j) else A $$ (i, j))›*) . qed lemma swap_col_to_front_result: "A ∈ carrier_mat n m ⟹ J < m ⟹ swap_col_to_front A J = mat n m (λ (i,j). if j = 0 then A $$ (i,J) else if j ≤ J then A $$ (i, j-1) else A $$ (i,j))" proof (induct J arbitrary: A) (*goals: 1. ‹⋀A. ⟦A ∈ carrier_mat n m; 0 < m⟧ ⟹ swap_col_to_front A 0 = mat n m (λ(i, j). if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j))› 2. ‹⋀J A. ⟦⋀A. ⟦A ∈ carrier_mat n m; J < m⟧ ⟹ swap_col_to_front A J = mat n m (λ(i, j). if j = 0 then A $$ (i, J) else if j ≤ J then A $$ (i, j - 1) else A $$ (i, j)); A ∈ carrier_mat n m; Suc J < m⟧ ⟹ swap_col_to_front A (Suc J) = mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j))›*) case 0 (*‹A ∈ carrier_mat n m› ‹0 < m›*) thus "?case" (*goal: ‹swap_col_to_front A 0 = mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j))›*) apply (intro eq_matI (*‹⟦⋀(i::nat) j::nat. ⟦i < dim_row (?B::?'a mat); j < dim_col ?B⟧ ⟹ (?A::?'a mat) $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀i j. ⟦A ∈ carrier_mat n m; 0 < m; i < dim_row (mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j))); j < dim_col (mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j)))⟧ ⟹ swap_col_to_front A 0 $$ (i, j) = mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j)) $$ (i, j)› 2. ‹⟦A ∈ carrier_mat n m; 0 < m⟧ ⟹ dim_row (swap_col_to_front A 0) = dim_row (mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j)))› 3. ‹⟦A ∈ carrier_mat n m; 0 < m⟧ ⟹ dim_col (swap_col_to_front A 0) = dim_col (mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, 0) else if j ≤ 0 then A $$ (i, j - 1) else A $$ (i, j)))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . next (*goal: ‹⋀J A. ⟦⋀A. ⟦A ∈ carrier_mat n m; J < m⟧ ⟹ swap_col_to_front A J = mat n m (λ(i, j). if j = 0 then A $$ (i, J) else if j ≤ J then A $$ (i, j - 1) else A $$ (i, j)); A ∈ carrier_mat n m; Suc J < m⟧ ⟹ swap_col_to_front A (Suc J) = mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j))›*) case (Suc J A) (*‹⟦?A ∈ carrier_mat n m; J < m⟧ ⟹ swap_col_to_front ?A J = mat n m (λa. case a of (i, j) ⇒ if j = 0 then ?A $$ (i, J) else if j ≤ J then ?A $$ (i, j - 1) else ?A $$ (i, j))› ‹A ∈ carrier_mat n m› ‹Suc J < m›*) from Suc(3) (*‹Suc J < m›*) have J: "J < m" by auto let ?J = "Suc J" let ?A = "swapcols J ?J A" have AA: "?A ∈ carrier_mat n m" using Suc(2) (*‹A ∈ carrier_mat n m›*) by simp have "swap_col_to_front A (Suc J) = swap_col_to_front ?A J" by simp also (*calculation: ‹swap_col_to_front A (Suc J) = swap_col_to_front (swapcols J (Suc J) A) J›*) have "… = mat n m (λ(i, j). if j = 0 then ?A $$ (i, J) else if j ≤ J then ?A $$ (i, j - 1) else ?A $$ (i, j))" using Suc(1)[OF AA J] (*‹swap_col_to_front (swapcols J (Suc J) A) J = mat n m (λa. case a of (i, j) ⇒ if j = 0 then swapcols J (Suc J) A $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - 1) else swapcols J (Suc J) A $$ (i, j))›*) by simp also (*calculation: ‹swap_col_to_front A (Suc J) = mat n m (λ(i, j). if j = 0 then swapcols J (Suc J) A $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - 1) else swapcols J (Suc J) A $$ (i, j))›*) have "… = mat n m (λ(i, j). if j = 0 then A $$ (i, ?J) else if j ≤ ?J then A $$ (i, j - 1) else A $$ (i, j))" apply (rule eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀(i::nat) j::nat. ⟦i < dim_row (mat (n::nat) (m::nat) (λ(i::nat, j::nat). if j = (0::nat) then (A::'a mat) $$ (i, Suc (J::nat)) else if j ≤ Suc J then A $$ (i, j - (1::nat)) else A $$ (i, j))); j < dim_col (mat n m (λ(i::nat, j::nat). if j = (0::nat) then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - (1::nat)) else A $$ (i, j)))⟧ ⟹ mat n m (λ(i::nat, j::nat). if j = (0::nat) then swapcols J (Suc J) A $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - (1::nat)) else swapcols J (Suc J) A $$ (i, j)) $$ (i, j) = mat n m (λ(i::nat, j::nat). if j = (0::nat) then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - (1::nat)) else A $$ (i, j)) $$ (i, j)› 2. ‹dim_row (mat (n::nat) (m::nat) (λ(i::nat, j::nat). if j = (0::nat) then swapcols (J::nat) (Suc J) (A::'a mat) $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - (1::nat)) else swapcols J (Suc J) A $$ (i, j))) = dim_row (mat n m (λ(i::nat, j::nat). if j = (0::nat) then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - (1::nat)) else A $$ (i, j)))› 3. ‹dim_col (mat (n::nat) (m::nat) (λ(i::nat, j::nat). if j = (0::nat) then swapcols (J::nat) (Suc J) (A::'a mat) $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - (1::nat)) else swapcols J (Suc J) A $$ (i, j))) = dim_col (mat n m (λ(i::nat, j::nat). if j = (0::nat) then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - (1::nat)) else A $$ (i, j)))› discuss goal 1*) apply ((insert J (*‹J < m›*) Suc( (*‹A ∈ carrier_mat n m›*) 2))[1]) (*top goal: ‹⋀i j. ⟦i < dim_row (mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j))); j < dim_col (mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j)))⟧ ⟹ mat n m (λ(i, j). if j = 0 then swapcols J (Suc J) A $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - 1) else swapcols J (Suc J) A $$ (i, j)) $$ (i, j) = mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j)) $$ (i, j)› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert J (*‹J < m›*) Suc( (*‹A ∈ carrier_mat n m›*) 2))[1]) (*top goal: ‹dim_row (mat n m (λ(i, j). if j = 0 then swapcols J (Suc J) A $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - 1) else swapcols J (Suc J) A $$ (i, j))) = dim_row (mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j)))› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 3*) apply ((insert J (*‹(J::nat) < (m::nat)›*) Suc( (*‹(A::'a::type mat) ∈ carrier_mat (n::nat) (m::nat)›*) 2))[1]) (*goal: ‹dim_col (mat n m (λ(i, j). if j = 0 then swapcols J (Suc J) A $$ (i, J) else if j ≤ J then swapcols J (Suc J) A $$ (i, j - 1) else swapcols J (Suc J) A $$ (i, j))) = dim_col (mat n m (λ(i, j). if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j)))›*) apply ((auto)[1]) (*proven 3 subgoals*) . finally (*calculation: ‹swap_col_to_front (A::'a mat) (Suc (J::nat)) = mat (n::nat) (m::nat) (λ(i::nat, j::nat). if j = (0::nat) then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - (1::nat)) else A $$ (i, j))›*) show "?case" (*goal: ‹swap_col_to_front A (Suc J) = mat n m (λa. case a of (i, j) ⇒ if j = 0 then A $$ (i, Suc J) else if j ≤ Suc J then A $$ (i, j - 1) else A $$ (i, j))›*) . qed lemma swapcols_is_transp_swap_rows: assumes A: "A ∈ carrier_mat n m" "k < m" "l < m" shows "swapcols k l A = transpose_mat (swaprows k l (transpose_mat A))" using assms (*‹A ∈ carrier_mat n m› ‹k < m› ‹(l::nat) < (m::nat)›*) apply (intro eq_matI (*‹⟦⋀i j. ⟦i < dim_row ?B; j < dim_col ?B⟧ ⟹ ?A $$ (i, j) = ?B $$ (i, j); dim_row ?A = dim_row ?B; dim_col ?A = dim_col ?B⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀(i::nat) j::nat. ⟦(A::'a::type mat) ∈ carrier_mat (n::nat) (m::nat); (k::nat) < m; (l::nat) < m; i < dim_row (swaprows k l A⇧T)⇧T; j < dim_col (swaprows k l A⇧T)⇧T⟧ ⟹ swapcols k l A $$ (i, j) = (swaprows k l A⇧T)⇧T $$ (i, j)› 2. ‹⟦(A::'a::type mat) ∈ carrier_mat (n::nat) (m::nat); (k::nat) < m; (l::nat) < m⟧ ⟹ dim_row (swapcols k l A) = dim_row (swaprows k l A⇧T)⇧T› 3. ‹⟦(A::'a::type mat) ∈ carrier_mat (n::nat) (m::nat); (k::nat) < m; (l::nat) < m⟧ ⟹ dim_col (swapcols k l A) = dim_col (swaprows k l A⇧T)⇧T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end
{ "path": "afp-2025-02-12/thys/Jordan_Normal_Form/Column_Operations.thy", "repo": "afp-2025-02-12", "sha": "6cf318a626d6376845771b8d34bfdb44d6184f9afbb180438885865bcfc91aa0" }
(* Author: Alexander Bentkamp, Universität des Saarlandes *) section ‹Tensor Addition› theory Tensor_Plus imports Tensor_Subtensor begin (* Problem: typeclass plus only has one zero element. If this is the empty tensor, other zero tensors cannot be of rank 0.*) definition "vec_plus a b = map (λ(x,y). plus x y) (zip a b)" definition plus_base::"'a::semigroup_add tensor ⇒ 'a tensor ⇒ 'a tensor" where "plus_base A B = (tensor_from_vec (dims A) (vec_plus (vec A) (vec B)))" instantiation tensor:: (semigroup_add) plus begin definition plus_def: "A + B = (if (dims A = dims B) then plus_base A B else undefined)" instance .. end lemma plus_dim1[simp]: "dims A = dims B ⟹ dims (A + B) = dims A" unfolding plus_def plus_base_def (*goal: ‹dims (A::'a tensor) = dims (B::'a tensor) ⟹ dims (if dims A = dims B then tensor_from_vec (dims A) (vec_plus (vec A) (vec B)) else undefined) = dims A›*) using dims_tensor (*‹length ?v = prod_list ?d ⟹ dims (tensor_from_vec ?d ?v) = ?d›*) length_vec (*‹length (vec (?A::?'a tensor)) = prod_list (dims ?A)›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) map_fst_zip (*‹length ?xs = length ?ys ⟹ map fst (zip ?xs ?ys) = ?xs›*) vec_plus_def (*‹vec_plus ?a ?b = map2 (+) ?a ?b›*) by (metis (full_types)) lemma plus_dim2[simp]: "dims A = dims B ⟹ dims (A + B) = dims B" using plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*) by metis lemma plus_base: "dims A = dims B ⟹ A + B = plus_base A B" unfolding plus_def (*goal: ‹dims A = dims B ⟹ (if dims A = dims B then plus_base A B else undefined) = plus_base A B›*) by metis lemma fixed_length_sublist_plus: assumes "length xs1 = c * l" "length xs2 = c * l" "i < c" shows "fixed_length_sublist (vec_plus xs1 xs2) l i = vec_plus (fixed_length_sublist xs1 l i) (fixed_length_sublist xs2 l i)" unfolding vec_plus_def fixed_length_sublist_def (*goal: ‹take l (drop (l * i) (map2 (+) xs1 xs2)) = map2 (+) (take l (drop (l * i) xs1)) (take l (drop (l * i) xs2))›*) using drop_map (*‹drop (?n::nat) (map (?f::?'b ⇒ ?'a) (?xs::?'b list)) = map ?f (drop ?n ?xs)›*) drop_zip (*‹drop ?n (zip ?xs ?ys) = zip (drop ?n ?xs) (drop ?n ?ys)›*) take_map (*‹take (?n::nat) (map (?f::?'b::type ⇒ ?'a::type) (?xs::?'b::type list)) = map ?f (take ?n ?xs)›*) take_zip (*‹take (?n::nat) (zip (?xs::?'a::type list) (?ys::?'b::type list)) = zip (take ?n ?xs) (take ?n ?ys)›*) by metis lemma vec_plus[simp]: assumes "dims A = dims B" shows "vec (A+B) = vec_plus (vec A) (vec B)" unfolding plus_def plus_base_def vec_plus_def (*goal: ‹vec (if dims A = dims B then tensor_from_vec (dims A) (map2 (+) (vec A) (vec B)) else undefined) = map2 (+) (vec A) (vec B)›*) using assms (*‹dims (A::'a::semigroup_add tensor) = dims (B::'a::semigroup_add tensor)›*) apply auto (*goal: ‹vec (if dims A = dims B then tensor_from_vec (dims A) (map2 (+) (vec A) (vec B)) else undefined) = map2 (+) (vec A) (vec B)›*) by (metis (no_types, lifting) length_map (*‹length (map ?f ?xs) = length ?xs›*) length_tensor_vec_from_lookup (*‹length (tensor_vec_from_lookup ?ds ?e) = prod_list ?ds›*) map_fst_zip (*‹length ?xs = length ?ys ⟹ map fst (zip ?xs ?ys) = ?xs›*) tensor_lookup (*‹(⋀is. is ⊲ dims ?A ⟹ lookup ?A is = ?e is) ⟹ tensor_from_lookup (dims ?A) ?e = ?A›*) tensor_from_lookup_def (*‹tensor_from_lookup ?ds ?e = tensor_from_vec ?ds (tensor_vec_from_lookup ?ds ?e)›*) vec_tensor (*‹length ?v = prod_list ?d ⟹ vec (tensor_from_vec ?d ?v) = ?v›*)) lemma subtensor_plus: fixes A::"'a::semigroup_add tensor" and B::"'a::semigroup_add tensor" assumes "i < hd (dims A)" and "dims A = dims B" and "dims A ≠ []" shows "subtensor (A + B) i = subtensor A i + subtensor B i" proof (-) (*goal: ‹subtensor (A + B) i = subtensor A i + subtensor B i›*) have "length (vec A) = hd (dims A) * prod_list (tl (dims A))" "length (Tensor.vec B) = hd (dims A) * prod_list (tl (dims A))" using length_vec (*‹length (vec ?A) = prod_list (dims ?A)›*) prod_list.Cons (*‹prod_list (?x # ?xs) = ?x * prod_list ?xs›*) assms (*‹(i::nat) < hd (dims (A::'a::semigroup_add tensor))› ‹dims (A::'a tensor) = dims (B::'a tensor)› ‹dims A ≠ []›*) by ((metis (no_types) list.exhaust_sel (*‹⟦?list = [] ⟹ ?P; ?list = hd ?list # tl ?list ⟹ ?P⟧ ⟹ ?P›*))+) then show "?thesis" (*goal: ‹subtensor (A + B) i = subtensor A i + subtensor B i›*) using Tensor_Plus.vec_plus (*‹dims ?A = dims ?B ⟹ vec (?A + ?B) = vec_plus (vec ?A) (vec ?B)›*) assms (*‹i < hd (dims A)› ‹dims A = dims B› ‹dims A ≠ []›*) fixed_length_sublist_plus (*‹⟦length (?xs1.0::?'a::plus list) = (?c::nat) * (?l::nat); length (?xs2.0::?'a::plus list) = ?c * ?l; (?i::nat) < ?c⟧ ⟹ fixed_length_sublist (vec_plus ?xs1.0 ?xs2.0) ?l ?i = vec_plus (fixed_length_sublist ?xs1.0 ?l ?i) (fixed_length_sublist ?xs2.0 ?l ?i)›*) vec_subtensor (*‹⟦dims ?A ≠ []; ?i < hd (dims ?A)⟧ ⟹ vec (subtensor ?A ?i) = fixed_length_sublist (vec ?A) (prod_list (tl (dims ?A))) ?i›*) tensor_eqI (*‹⟦dims ?A = dims ?B; vec ?A = vec ?B⟧ ⟹ ?A = ?B›*) dims_subtensor (*‹⟦dims ?A ≠ []; ?i < hd (dims ?A)⟧ ⟹ dims (subtensor ?A ?i) = tl (dims ?A)›*) plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*) by fastforce qed lemma lookup_plus[simp]: assumes "dims A = dims B" and "is ⊲ dims A" shows "lookup (A + B) is = lookup A is + lookup B is" using assms (*‹dims A = dims B› ‹(is::nat list) ⊲ dims (A::'a tensor)›*) proof (induction "A+B" arbitrary:A B "is" rule: subtensor_induct) (*goals: 1. ‹⋀A B is. ⟦dims (A + B) = []; dims A = dims B; is ⊲ dims A⟧ ⟹ lookup (A + B) is = lookup A is + lookup B is› 2. ‹⋀A B is. ⟦dims (A + B) ≠ []; ⋀i Aa Ba is. ⟦i < hd (dims (A + B)); subtensor (A + B) i = Aa + Ba; dims Aa = dims Ba; is ⊲ dims Aa⟧ ⟹ lookup (Aa + Ba) is = lookup Aa is + lookup Ba is; dims A = dims B; is ⊲ dims A⟧ ⟹ lookup (A + B) is = lookup A is + lookup B is›*) case (order_0 A B is) (*‹dims (A + B) = []› ‹dims A = dims B› ‹is ⊲ dims A›*) then have "is = []" by auto have 1: "[] ⊲ dims A" using order_0 (*‹dims (A + B) = []› ‹dims A = dims B› ‹(is::nat list) ⊲ dims (A::'a tensor)›*) ‹is = []› (*‹is = []›*) by auto have 2: "[] ⊲ dims B" using order_0 (*‹dims (A + B) = []› ‹dims A = dims B› ‹(is::nat list) ⊲ dims (A::'a tensor)›*) ‹is = []› (*‹is = []›*) by auto have 3: "[] ⊲ dims (A + B)" using order_0 (*‹dims (A + B) = []› ‹dims A = dims B› ‹is ⊲ dims A›*) ‹is = []› (*‹is = []›*) by auto have "length (vec A) = 1" "length (vec B) = 1" (*goals: 1. ‹length (vec A) = 1› 2. ‹length (vec B) = 1› discuss goal 1*) apply (metis length_vec (*‹length (vec ?A) = prod_list (dims ?A)›*) prod_list.Nil (*‹prod_list [] = 1›*) order_0.hyps (*‹dims (A + B) = []›*) order_0.prems( (*‹dims A = dims B›*) 1) plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*)) (*discuss goal 2*) apply (metis length_vec (*‹length (vec ?A) = prod_list (dims ?A)›*) prod_list.Nil (*‹prod_list [] = 1›*) order_0.hyps (*‹dims (A + B) = []›*) order_0.prems( (*‹dims A = dims B›*) 1) plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*)) (*proven 2 subgoals*) . then show "?case" (*goal: ‹lookup (A + B) is = lookup A is + lookup B is›*) unfolding lookup_subtensor[OF 1] lookup_subtensor[OF 2] lookup_subtensor[OF 3] ‹is = []› fold_simps(1) vec_plus[OF order_0.prems ( 1 )] (*goal: ‹hd (vec_plus (vec A) (vec B)) = hd (vec A) + hd (vec B)›*) unfolding vec_plus_def (*goal: ‹hd (map2 (+) (vec A) (vec B)) = hd (vec A) + hd (vec B)›*) using order_0.prems (*‹dims A = dims B› ‹is ⊲ dims A›*) length_map (*‹length (map ?f ?xs) = length ?xs›*) list.map_sel(1) (*‹?a ≠ [] ⟹ hd (map ?f ?a) = ?f (hd ?a)›*) list.size(3) (*‹length [] = 0›*) map_fst_zip (*‹length ?xs = length ?ys ⟹ map fst (zip ?xs ?ys) = ?xs›*) map_snd_zip (*‹length ?xs = length ?ys ⟹ map snd (zip ?xs ?ys) = ?ys›*) order_0.hyps (*‹dims (A + B) = []›*) zero_neq_one (*‹0 ≠ 1›*) case_prod_unfold (*‹case_prod = (λc p. c (fst p) (snd p))›*) length_vec (*‹length (vec ?A) = prod_list (dims ?A)›*) by metis next (*goal: ‹⋀A B is. ⟦dims (A + B) ≠ []; ⋀i Aa Ba is. ⟦i < hd (dims (A + B)); subtensor (A + B) i = Aa + Ba; dims Aa = dims Ba; is ⊲ dims Aa⟧ ⟹ lookup (Aa + Ba) is = lookup Aa is + lookup Ba is; dims A = dims B; is ⊲ dims A⟧ ⟹ lookup (A + B) is = lookup A is + lookup B is›*) case (order_step A B is) (*‹dims (A + B) ≠ []› ‹⟦?i < hd (dims (A + B)); subtensor (A + B) ?i = ?A + ?B; dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is› ‹dims (A::'a tensor) = dims (B::'a tensor)› ‹is ⊲ dims A›*) then obtain i and is' where "is = i # is'" (*goal: ‹(⋀i is'. is = i # is' ⟹ thesis) ⟹ thesis›*) by auto have 1: "is ⊲ dims A" using order_step (*‹dims ((A::'a tensor) + (B::'a tensor)) ≠ []› ‹⟦?i < hd (dims (A + B)); subtensor (A + B) ?i = ?A + ?B; dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is› ‹dims (A::'a tensor) = dims (B::'a tensor)› ‹is ⊲ dims A›*) by auto have 2: "is ⊲ dims B" using order_step (*‹dims (A + B) ≠ []› ‹⟦?i < hd (dims (A + B)); subtensor (A + B) ?i = ?A + ?B; dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is› ‹dims (A::'a tensor) = dims (B::'a tensor)› ‹(is::nat list) ⊲ dims (A::'a tensor)›*) by auto have 3: "is ⊲ dims (A + B)" using order_step (*‹dims (A + B) ≠ []› ‹⟦?i < hd (dims (A + B)); subtensor (A + B) ?i = ?A + ?B; dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is› ‹dims (A::'a tensor) = dims (B::'a tensor)› ‹(is::nat list) ⊲ dims (A::'a tensor)›*) by auto have "lookup (subtensor A i + subtensor B i) is' = lookup (subtensor A i) is' + lookup (subtensor B i) is'" apply (rule order_step.hyps(2)[of i] (*‹⟦i < hd (dims (A + B)); subtensor (A + B) i = ?A + ?B; dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is›*)) (*goal: ‹lookup (subtensor A i + subtensor B i) is' = lookup (subtensor A i) is' + lookup (subtensor B i) is'›*) using ‹is = i # is'› (*‹is = i # is'›*) "3" (*‹is ⊲ dims (A + B)›*) hd_conv_nth (*‹?xs ≠ [] ⟹ hd ?xs = ?xs ! 0›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) nth_Cons_0 (*‹(?x # ?xs) ! 0 = ?x›*) order_step.hyps(1) (*‹dims (A + B) ≠ []›*) valid_index_lt (*‹⟦?is ⊲ ?ds; ?m < length ?ds⟧ ⟹ ?is ! ?m < ?ds ! ?m›*) apply ((auto)[1]) (*top goal: ‹i < hd (dims (A + B))› and 3 goals remain*) apply (metis "2" (*‹(is::nat list) ⊲ dims (B::'a::semigroup_add tensor)›*) ‹is = i # is'› list.inject (*‹((?x21.0::?'a::type) # (?x22.0::?'a::type list) = (?y21.0::?'a::type) # (?y22.0::?'a::type list)) = (?x21.0 = ?y21.0 ∧ ?x22.0 = ?y22.0)›*) list.sel( (*‹hd ((?x21.0::?'a::type) # (?x22.0::?'a::type list)) = ?x21.0›*) 1) list.simps( (*‹(?x21.0::?'a::type) # (?x22.0::?'a::type list) ≠ []›*) 3) order_step.prems( (*‹dims (A::'a::semigroup_add tensor) = dims (B::'a::semigroup_add tensor)›*) 1) subtensor_plus (*‹⟦(?i::nat) < hd (dims (?A::?'a::semigroup_add tensor)); dims ?A = dims (?B::?'a::semigroup_add tensor); dims ?A ≠ []⟧ ⟹ subtensor (?A + ?B) ?i = subtensor ?A ?i + subtensor ?B ?i›*) valid_index.cases (*‹⟦(?a1.0::nat list) ⊲ (?a2.0::nat list); ⟦?a1.0 = []; ?a2.0 = []⟧ ⟹ ?P::bool; ⋀(is::nat list) (ds::nat list) (i::nat) d::nat. ⟦?a1.0 = i # is; ?a2.0 = d # ds; is ⊲ ds; i < d⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*top goal: ‹subtensor (A + B) i = subtensor A i + subtensor B i› and 2 goals remain*) using "1" (*‹is ⊲ dims A›*) ‹is = i # is'› (*‹is = i # is'›*) order_step.prems(1) (*‹dims (A::'a tensor) = dims (B::'a tensor)›*) plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*) apply ((auto)[1]) (*top goal: ‹dims (subtensor (A::'a tensor) (i::nat)) = dims (subtensor (B::'a tensor) i)› and 1 goal remains*) using "1" (*‹is ⊲ dims A›*) ‹is = i # is'› (*‹is = i # is'›*) plus_dim1 (*‹dims (?A::?'a tensor) = dims (?B::?'a tensor) ⟹ dims (?A + ?B) = dims ?A›*) by auto then show "?case" (*goal: ‹lookup ((A::'a tensor) + (B::'a tensor)) (is::nat list) = lookup A is + lookup B is›*) using lookup_subtensor[OF 1] (*‹lookup A is = hd (vec (fold (λi A. subtensor A i) is A))›*) lookup_subtensor[OF 2] (*‹lookup B is = hd (vec (fold (λi A. subtensor A i) is B))›*) lookup_subtensor[OF 3] (*‹lookup (A + B) is = hd (vec (fold (λi A. subtensor A i) is (A + B)))›*) using order_step (*‹dims (A + B) ≠ []› ‹⟦?i < hd (dims (A + B)); subtensor (A + B) ?i = ?A + ?B; dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is› ‹dims A = dims B› ‹is ⊲ dims A›*) ‹is = i # is'› (*‹(is::nat list) = (i::nat) # (is'::nat list)›*) plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*) lookup_subtensor1 (*‹?i # ?is ⊲ dims ?A ⟹ lookup (subtensor ?A ?i) ?is = lookup ?A (?i # ?is)›*) list.sel(1) (*‹hd (?x21.0 # ?x22.0) = ?x21.0›*) subtensor_plus (*‹⟦?i < hd (dims ?A); dims ?A = dims ?B; dims ?A ≠ []⟧ ⟹ subtensor (?A + ?B) ?i = subtensor ?A ?i + subtensor ?B ?i›*) valid_index_dimsE (*‹⟦?is ⊲ dims ?A; ⟦?is = []; dims ?A = []⟧ ⟹ ?P; ⋀is ds i d. ⟦?is = i # is; dims ?A = d # ds; is ⊲ ds; i < d⟧ ⟹ ?P⟧ ⟹ ?P›*) by metis qed lemma plus_assoc: assumes dimsA:"dims A = ds" and dimsB:"dims B = ds" and dimsC:"dims C = ds" shows "(A + B) + C = A + (B + C)" apply (rule tensor_lookup_eqI (*‹⟦dims ?A = dims ?B; ⋀is. is ⊲ dims ?A ⟹ lookup ?A is = lookup ?B is⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹dims (A + B + C) = dims (A + (B + C))› 2. ‹⋀is. is ⊲ dims (A + B + C) ⟹ lookup (A + B + C) is = lookup (A + (B + C)) is› discuss goal 1*) apply (simp add: dimsA (*‹dims A = ds›*) dimsB (*‹dims B = ds›*) dimsC (*‹dims C = ds›*) add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) (*discuss goal 2*) apply (simp add: dimsA (*‹dims A = ds›*) dimsB (*‹dims B = ds›*) dimsC (*‹dims C = ds›*) add.assoc (*‹?a + ?b + ?c = ?a + (?b + ?c)›*)) (*proven 2 subgoals*) . lemma tensor_comm[simp]: fixes A::"'a::ab_semigroup_add tensor" shows "A + B = B + A" proof (cases "dims A = dims B") (*goals: 1. ‹dims A = dims B ⟹ A + B = B + A› 2. ‹dims A ≠ dims B ⟹ A + B = B + A›*) case True (*‹dims A = dims B›*) then show "?thesis" (*goal: ‹A + B = B + A›*) unfolding plus_def plus_base_def (*goal: ‹(if dims A = dims B then tensor_from_vec (dims A) (vec_plus (vec A) (vec B)) else undefined) = (if dims B = dims A then tensor_from_vec (dims B) (vec_plus (vec B) (vec A)) else undefined)›*) using add.commute (*‹?a + ?b = ?b + ?a›*) lookup_plus[OF True] (*‹?is ⊲ dims A ⟹ lookup (A + B) ?is = lookup A ?is + lookup B ?is›*) plus_dim1[OF True] (*‹dims (A + B) = dims A›*) tensor_lookup_eqI[OF True] (*‹(⋀is. is ⊲ dims A ⟹ lookup A is = lookup B is) ⟹ A = B›*) vec_plus[OF True] (*‹vec (A + B) = vec_plus (vec A) (vec B)›*) by (metis lookup_plus (*‹⟦dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is›*) plus_dim1 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?A›*) tensor_lookup_eqI (*‹⟦dims ?A = dims ?B; ⋀is. is ⊲ dims ?A ⟹ lookup ?A is = lookup ?B is⟧ ⟹ ?A = ?B›*) vec_plus (*‹dims ?A = dims ?B ⟹ vec (?A + ?B) = vec_plus (vec ?A) (vec ?B)›*)) next (*goal: ‹dims A ≠ dims B ⟹ A + B = B + A›*) case False (*‹dims A ≠ dims B›*) then show "?thesis" (*goal: ‹(A::'a::ab_semigroup_add tensor) + (B::'a::ab_semigroup_add tensor) = B + A›*) unfolding plus_def plus_base_def (*goal: ‹(if dims A = dims B then tensor_from_vec (dims A) (vec_plus (vec A) (vec B)) else undefined) = (if dims B = dims A then tensor_from_vec (dims B) (vec_plus (vec B) (vec A)) else undefined)›*) by simp qed definition "vec0 n = replicate n 0" definition tensor0::"nat list ⇒ 'a::zero tensor" where "tensor0 d = tensor_from_vec d (vec0 (prod_list d))" lemma dims_tensor0[simp]: "dims (tensor0 d) = d" and vec_tensor0[simp]: "vec (tensor0 d) = vec0 (prod_list d)" unfolding tensor0_def vec0_def (*goals: 1. ‹dims (tensor_from_vec d (replicate (prod_list d) 0)) = d› 2. ‹vec (tensor_from_vec d (replicate (prod_list d) 0)) = replicate (prod_list d) 0›*) (*goals: 1. ‹dims (tensor_from_vec d (replicate (prod_list d) 0)) = d› 2. ‹vec (tensor_from_vec d (replicate (prod_list d) 0)) = replicate (prod_list d) 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma lookup_is_in_vec: "is ⊲ (dims A) ⟹ lookup A is ∈ set (vec A)" proof (induction arbitrary:"is" rule:subtensor_induct) (*goals: 1. ‹⋀(A::'a::type tensor) is::nat list. ⟦dims A = []; is ⊲ dims A⟧ ⟹ lookup A is ∈ set (vec A)› 2. ‹⋀(A::'a::type tensor) is::nat list. ⟦dims A ≠ []; ⋀(i::nat) is::nat list. ⟦i < hd (dims A); is ⊲ dims (subtensor A i)⟧ ⟹ lookup (subtensor A i) is ∈ set (vec (subtensor A i)); is ⊲ dims A⟧ ⟹ lookup A is ∈ set (vec A)›*) case order_0 (*‹dims A_ = []› ‹is ⊲ dims A_›*) then show "?case" (*goal: ‹lookup A_ is ∈ set (vec A_)›*) unfolding lookup_def (*goal: ‹lookup_base (dims A_) (vec A_) is ∈ set (vec A_)›*) using lookup_base_Nil (*‹lookup_base [] ?v [] = hd ?v›*) by (metis length_0_conv (*‹(length (?xs::?'a::type list) = (0::nat)) = (?xs = [])›*) length_vec (*‹length (vec (?A::?'a::type tensor)) = prod_list (dims ?A)›*) list.set_sel( (*‹(?a::?'a::type list) ≠ [] ⟹ hd ?a ∈ set ?a›*) 1) prod_list.Nil (*‹prod_list [] = (1::?'a::monoid_mult)›*) valid_index_length (*‹(?is::nat list) ⊲ (?ds::nat list) ⟹ length ?is = length ?ds›*) zero_neq_one (*‹(0::?'a::zero_neq_one) ≠ (1::?'a::zero_neq_one)›*)) next (*goal: ‹⋀A is. ⟦dims A ≠ []; ⋀i is. ⟦i < hd (dims A); is ⊲ dims (subtensor A i)⟧ ⟹ lookup (subtensor A i) is ∈ set (vec (subtensor A i)); is ⊲ dims A⟧ ⟹ lookup A is ∈ set (vec A)›*) case (order_step A is) (*‹dims (A::'a tensor) ≠ []› ‹⟦(?i::nat) < hd (dims (A::'a::type tensor)); (?is::nat list) ⊲ dims (subtensor A ?i)⟧ ⟹ lookup (subtensor A ?i) ?is ∈ set (vec (subtensor A ?i))› ‹is ⊲ dims A›*) then obtain i and is' where "is = i # is'" (*goal: ‹(⋀i is'. is = i # is' ⟹ thesis) ⟹ thesis›*) using valid_index_dimsE (*‹⟦?is ⊲ dims ?A; ⟦?is = []; dims ?A = []⟧ ⟹ ?P; ⋀is ds i d. ⟦?is = i # is; dims ?A = d # ds; is ⊲ ds; i < d⟧ ⟹ ?P⟧ ⟹ ?P›*) by blast then have 1: "i < hd (dims A)" using dims_def (*‹dims ?A = fst (Rep_tensor ?A)›*) order_step.prems (*‹is ⊲ dims A›*) by auto have 2: "is' ⊲ dims (subtensor A i)" using ‹is = i # is'› (*‹is = i # is'›*) dims_subtensor (*‹⟦dims ?A ≠ []; ?i < hd (dims ?A)⟧ ⟹ dims (subtensor ?A ?i) = tl (dims ?A)›*) order_step.prems (*‹is ⊲ dims A›*) by auto have "lookup A is ∈ set (Tensor.vec (subtensor A i))" using order_step.IH[OF 1 2] (*‹lookup (subtensor A i) is' ∈ set (vec (subtensor A i))›*) lookup_subtensor1 (*‹?i # ?is ⊲ dims ?A ⟹ lookup (subtensor ?A ?i) ?is = lookup ?A (?i # ?is)›*) ‹is = i # is'› (*‹is = i # is'›*) order_step.prems (*‹(is::nat list) ⊲ dims (A::'a::type tensor)›*) by auto then show "?case" (*goal: ‹lookup A is ∈ set (vec A)›*) using vec_subtensor (*‹⟦dims ?A ≠ []; ?i < hd (dims ?A)⟧ ⟹ vec (subtensor ?A ?i) = fixed_length_sublist (vec ?A) (prod_list (tl (dims ?A))) ?i›*) fixed_length_sublist_def (*‹fixed_length_sublist ?xs ?l ?i = take ?l (drop (?l * ?i) ?xs)›*) by (metis "1" (*‹i < hd (dims A)›*) in_set_dropD (*‹?x ∈ set (drop ?n ?xs) ⟹ ?x ∈ set ?xs›*) in_set_takeD (*‹?x ∈ set (take ?n ?xs) ⟹ ?x ∈ set ?xs›*) order_step.hyps (*‹dims A ≠ []›*)) qed lemma lookup_tensor0: assumes "is ⊲ ds" shows "lookup (tensor0 ds) is = 0" proof (-) (*goal: ‹lookup (tensor0 ds) is = 0›*) have "lookup (tensor0 ds) is ∈ set (vec (tensor0 ds))" using lookup_is_in_vec (*‹?is ⊲ dims ?A ⟹ lookup ?A ?is ∈ set (vec ?A)›*) assms (*‹is ⊲ ds›*) by (metis dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*)) moreover have "set (vec (tensor0 ds)) ⊆ {0}" unfolding vec_tensor0 vec0_def (*goal: ‹set (replicate (prod_list (ds::nat list)) (0::'b)) ⊆ {0::'b}›*) by (metis in_set_replicate (*‹(?x ∈ set (replicate ?n ?y)) = (?x = ?y ∧ ?n ≠ 0)›*) singleton_iff (*‹(?b ∈ {?a}) = (?b = ?a)›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) ultimately show "?thesis" (*goal: ‹lookup (tensor0 (ds::nat list)) (is::nat list) = (0::'a)›*) by auto qed lemma fixes A::"'a::monoid_add tensor" shows tensor_add_0_right[simp]: "A + tensor0 (dims A) = A" unfolding plus_def plus_base_def dims_tensor0 (*goal: ‹(if dims (A::'a tensor) = dims A then tensor_from_vec (dims A) (vec_plus (vec A) (vec (tensor0 (dims A)))) else undefined) = A›*) apply simp (*goal: ‹(if dims (A::'a tensor) = dims A then tensor_from_vec (dims A) (vec_plus (vec A) (vec (tensor0 (dims A)))) else undefined) = A›*) apply (rule tensor_lookup_eqI (*‹⟦dims ?A = dims ?B; ⋀is. is ⊲ dims ?A ⟹ lookup ?A is = lookup ?B is⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹dims (tensor_from_vec (dims A) (vec_plus (vec A) (vec0 (prod_list (dims A))))) = dims A› 2. ‹⋀is. is ⊲ dims (tensor_from_vec (dims A) (vec_plus (vec A) (vec0 (prod_list (dims A))))) ⟹ lookup (tensor_from_vec (dims A) (vec_plus (vec A) (vec0 (prod_list (dims A))))) is = lookup A is› discuss goal 1*) apply (metis (no_types, lifting) dims_tensor (*‹length ?v = prod_list ?d ⟹ dims (tensor_from_vec ?d ?v) = ?d›*) dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*) length_vec (*‹length (vec ?A) = prod_list (dims ?A)›*) plus_dim2 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?B›*) vec_plus (*‹dims ?A = dims ?B ⟹ vec (?A + ?B) = vec_plus (vec ?A) (vec ?B)›*) vec_tensor0 (*‹vec (tensor0 ?d) = vec0 (prod_list ?d)›*)) (*discuss goal 2*) apply (metis add.right_neutral (*‹?a + 0 = ?a›*) dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*) lookup_plus (*‹⟦dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is›*) lookup_tensor0 (*‹?is ⊲ ?ds ⟹ lookup (tensor0 ?ds) ?is = 0›*) plus_dim2 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?B›*) tensor_from_vec_simp (*‹tensor_from_vec (dims ?A) (vec ?A) = ?A›*) vec_plus (*‹dims ?A = dims ?B ⟹ vec (?A + ?B) = vec_plus (vec ?A) (vec ?B)›*) vec_tensor0 (*‹vec (tensor0 ?d) = vec0 (prod_list ?d)›*)) (*proven 2 subgoals*) . lemma fixes A::"'a::monoid_add tensor" shows tensor_add_0_left[simp]: "tensor0 (dims A) + A = A" unfolding plus_def plus_base_def dims_tensor0 (*goal: ‹(if dims (A::'a tensor) = dims A then tensor_from_vec (dims A) (vec_plus (vec (tensor0 (dims A))) (vec A)) else undefined) = A›*) apply simp (*goal: ‹(if dims (A::'a tensor) = dims A then tensor_from_vec (dims A) (vec_plus (vec (tensor0 (dims A))) (vec A)) else undefined) = A›*) apply (rule tensor_lookup_eqI (*‹⟦dims ?A = dims ?B; ⋀is. is ⊲ dims ?A ⟹ lookup ?A is = lookup ?B is⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹dims (tensor_from_vec (dims A) (vec_plus (vec0 (prod_list (dims A))) (vec A))) = dims A› 2. ‹⋀is. is ⊲ dims (tensor_from_vec (dims A) (vec_plus (vec0 (prod_list (dims A))) (vec A))) ⟹ lookup (tensor_from_vec (dims A) (vec_plus (vec0 (prod_list (dims A))) (vec A))) is = lookup A is› discuss goal 1*) apply (metis (no_types, lifting) dims_tensor (*‹length ?v = prod_list ?d ⟹ dims (tensor_from_vec ?d ?v) = ?d›*) dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*) length_vec (*‹length (vec ?A) = prod_list (dims ?A)›*) plus_dim2 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?B›*) vec_plus (*‹dims ?A = dims ?B ⟹ vec (?A + ?B) = vec_plus (vec ?A) (vec ?B)›*) vec_tensor0 (*‹vec (tensor0 ?d) = vec0 (prod_list ?d)›*)) (*discuss goal 2*) apply (metis add.left_neutral (*‹0 + ?a = ?a›*) dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*) lookup_plus (*‹⟦dims ?A = dims ?B; ?is ⊲ dims ?A⟧ ⟹ lookup (?A + ?B) ?is = lookup ?A ?is + lookup ?B ?is›*) lookup_tensor0 (*‹?is ⊲ ?ds ⟹ lookup (tensor0 ?ds) ?is = 0›*) plus_dim2 (*‹dims ?A = dims ?B ⟹ dims (?A + ?B) = dims ?B›*) tensor_from_vec_simp (*‹tensor_from_vec (dims ?A) (vec ?A) = ?A›*) vec_plus (*‹dims ?A = dims ?B ⟹ vec (?A + ?B) = vec_plus (vec ?A) (vec ?B)›*) vec_tensor0 (*‹vec (tensor0 ?d) = vec0 (prod_list ?d)›*)) (*proven 2 subgoals*) . definition listsum::"nat list ⇒ 'a::monoid_add tensor list ⇒ 'a tensor" where "listsum ds As = foldr (+) As (tensor0 ds)" definition listsum'::"'a::monoid_add tensor list ⇒ 'a tensor" where "listsum' As = listsum (dims (hd As)) As" lemma listsum_Nil: "listsum ds [] = tensor0 ds" by (simp add: Tensor_Plus.listsum_def (*‹listsum (?ds::nat list) (?As::?'a::monoid_add tensor list) = foldr (+) ?As (tensor0 ?ds)›*)) lemma listsum_one: "listsum (dims A) [A] = A" unfolding listsum_def (*goal: ‹foldr (+) [A] (tensor0 (dims A)) = A›*) by simp lemma listsum_Cons: "listsum ds (A # As) = A + listsum ds As" unfolding listsum_def (*goal: ‹foldr (+) (A # As) (tensor0 ds) = A + foldr (+) As (tensor0 ds)›*) by auto lemma listsum_dims: assumes "⋀A. A∈set As ⟹ dims A = ds" shows "dims (listsum ds As) = ds" using assms (*‹(?A::'a::monoid_add tensor) ∈ set (As::'a::monoid_add tensor list) ⟹ dims ?A = (ds::nat list)›*) proof (induction As) (*goals: 1. ‹(⋀A. A ∈ set [] ⟹ dims A = ds) ⟹ dims (listsum ds []) = ds› 2. ‹⋀a As. ⟦(⋀A. A ∈ set As ⟹ dims A = ds) ⟹ dims (listsum ds As) = ds; ⋀A. A ∈ set (a # As) ⟹ dims A = ds⟧ ⟹ dims (listsum ds (a # As)) = ds›*) case Nil (*‹?A ∈ set [] ⟹ dims ?A = ds›*) then show "?case" (*goal: ‹dims (listsum (ds::nat list) []) = ds›*) by (metis dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*) listsum_Nil (*‹listsum ?ds [] = tensor0 ?ds›*)) next (*goal: ‹⋀a As. ⟦(⋀A. A ∈ set As ⟹ dims A = ds) ⟹ dims (listsum ds As) = ds; ⋀A. A ∈ set (a # As) ⟹ dims A = ds⟧ ⟹ dims (listsum ds (a # As)) = ds›*) case (Cons A As) (*‹(⋀A. A ∈ set As ⟹ dims A = ds) ⟹ dims (listsum ds As) = ds› ‹?A ∈ set (A # As) ⟹ dims ?A = ds›*) then show "?case" (*goal: ‹dims (listsum ds (A # As)) = ds›*) using listsum_Cons (*‹listsum ?ds (?A # ?As) = ?A + listsum ?ds ?As›*) by (metis list.set_intros( (*‹(?x21.0::?'a::type) ∈ set (?x21.0 # (?x22.0::?'a::type list))›*) 1) list.set_intros( (*‹(?y::?'a::type) ∈ set (?x22.0::?'a::type list) ⟹ ?y ∈ set ((?x21.0::?'a::type) # ?x22.0)›*) 2) plus_dim2 (*‹dims (?A::?'a::semigroup_add tensor) = dims (?B::?'a::semigroup_add tensor) ⟹ dims (?A + ?B) = dims ?B›*)) qed lemma subtensor0: assumes "ds ≠ []" and "i<hd ds" shows "subtensor (tensor0 ds) i = tensor0 (tl ds)" proof (rule tensor_lookup_eqI (*‹⟦dims (?A::?'a tensor) = dims (?B::?'a tensor); ⋀is::nat list. is ⊲ dims ?A ⟹ lookup ?A is = lookup ?B is⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹dims (subtensor (tensor0 ds) i) = dims (tensor0 (tl ds))› 2. ‹⋀is. is ⊲ dims (subtensor (tensor0 ds) i) ⟹ lookup (subtensor (tensor0 ds) i) is = lookup (tensor0 (tl ds)) is›*) show 1: "dims (subtensor (tensor0 ds) i) = dims (tensor0 (tl ds))" by (simp add: assms( (*‹ds ≠ []›*) 1) assms( (*‹i < hd ds›*) 2)) fix is assume "is ⊲ dims (subtensor (tensor0 ds) i)" (*‹(is::nat list) ⊲ dims (subtensor (tensor0 (ds::nat list)) (i::nat))›*) then have "i # is ⊲ dims (tensor0 ds)" using assms(1) (*‹ds ≠ []›*) assms(2) (*‹i < hd ds›*) valid_index.Cons (*‹⟦(?is::nat list) ⊲ (?ds::nat list); (?i::nat) < (?d::nat)⟧ ⟹ ?i # ?is ⊲ ?d # ?ds›*) by fastforce then show "lookup (subtensor (tensor0 ds) i) is = lookup (tensor0 (tl ds)) is" using lookup_subtensor1 (*‹?i # ?is ⊲ dims ?A ⟹ lookup (subtensor ?A ?i) ?is = lookup ?A (?i # ?is)›*) "1" (*‹dims (subtensor (tensor0 ds) i) = dims (tensor0 (tl ds))›*) ‹is ⊲ dims (subtensor (tensor0 ds) i)› (*‹is ⊲ dims (subtensor (tensor0 ds) i)›*) dims_tensor0 (*‹dims (tensor0 ?d) = ?d›*) lookup_tensor0 (*‹?is ⊲ ?ds ⟹ lookup (tensor0 ?ds) ?is = 0›*) by metis qed lemma subtensor_listsum: assumes "⋀A. A∈set As ⟹ dims A = ds" and "ds ≠ []" and "i<hd ds" shows "subtensor (listsum ds As) i = listsum (tl ds) (map (λA. subtensor A i) As)" using assms (*‹?A ∈ set As ⟹ dims ?A = ds› ‹(ds::nat list) ≠ []› ‹i < hd ds›*) proof (induction As) (*goals: 1. ‹⟦⋀A. A ∈ set [] ⟹ dims A = ds; ds ≠ []; i < hd ds⟧ ⟹ subtensor (listsum ds []) i = listsum (tl ds) (map (λA. subtensor A i) [])› 2. ‹⋀a As. ⟦⟦⋀A. A ∈ set As ⟹ dims A = ds; ds ≠ []; i < hd ds⟧ ⟹ subtensor (listsum ds As) i = listsum (tl ds) (map (λA. subtensor A i) As); ⋀A. A ∈ set (a # As) ⟹ dims A = ds; ds ≠ []; i < hd ds⟧ ⟹ subtensor (listsum ds (a # As)) i = listsum (tl ds) (map (λA. subtensor A i) (a # As))›*) case Nil (*‹?A ∈ set [] ⟹ dims ?A = ds› ‹ds ≠ []› ‹i < hd ds›*) then show "?case" (*goal: ‹subtensor (listsum ds []) i = listsum (tl ds) (map (λA. subtensor A i) [])›*) using lookup_tensor0 (*‹?is ⊲ ?ds ⟹ lookup (tensor0 ?ds) ?is = 0›*) assms(2) (*‹(ds::nat list) ≠ []›*) assms(3) (*‹i < hd ds›*) subtensor0 (*‹⟦?ds ≠ []; ?i < hd ?ds⟧ ⟹ subtensor (tensor0 ?ds) ?i = tensor0 (tl ?ds)›*) by (auto simp add: listsum_Nil (*‹listsum ?ds [] = tensor0 ?ds›*)) next (*goal: ‹⋀a As. ⟦⟦⋀A. A ∈ set As ⟹ dims A = ds; ds ≠ []; i < hd ds⟧ ⟹ subtensor (listsum ds As) i = listsum (tl ds) (map (λA. subtensor A i) As); ⋀A. A ∈ set (a # As) ⟹ dims A = ds; ds ≠ []; i < hd ds⟧ ⟹ subtensor (listsum ds (a # As)) i = listsum (tl ds) (map (λA. subtensor A i) (a # As))›*) case (Cons A As) (*‹⟦⋀A. A ∈ set As ⟹ dims A = ds; ds ≠ []; i < hd ds⟧ ⟹ subtensor (listsum ds As) i = listsum (tl ds) (map (λA. subtensor A i) As)› ‹(?A::'a tensor) ∈ set ((A::'a tensor) # (As::'a tensor list)) ⟹ dims ?A = (ds::nat list)› ‹ds ≠ []› ‹i < hd ds›*) then show "?case" (*goal: ‹subtensor (listsum ds (A # As)) i = listsum (tl ds) (map (λA. subtensor A i) (A # As))›*) apply (simp add: listsum_Cons (*‹listsum ?ds (?A # ?As) = ?A + listsum ?ds ?As›*)) (*goal: ‹subtensor (listsum ds (A # As)) i = listsum (tl ds) (map (λA. subtensor A i) (A # As))›*) by (metis subtensor_plus (*‹⟦(?i::nat) < hd (dims (?A::?'a tensor)); dims ?A = dims (?B::?'a tensor); dims ?A ≠ []⟧ ⟹ subtensor (?A + ?B) ?i = subtensor ?A ?i + subtensor ?B ?i›*) listsum_dims (*‹(⋀A::?'a tensor. A ∈ set (?As::?'a tensor list) ⟹ dims A = (?ds::nat list)) ⟹ dims (listsum ?ds ?As) = ?ds›*)) qed lemma listsum0: assumes "⋀A. A∈set As ⟹ A = tensor0 ds" shows "listsum ds As = tensor0 ds" using assms (*‹?A ∈ set As ⟹ ?A = tensor0 ds›*) proof (induction As) (*goals: 1. ‹(⋀A::'a tensor. A ∈ set [] ⟹ A = tensor0 (ds::nat list)) ⟹ listsum ds [] = tensor0 ds› 2. ‹⋀(a::'a tensor) As::'a tensor list. ⟦(⋀A::'a tensor. A ∈ set As ⟹ A = tensor0 (ds::nat list)) ⟹ listsum ds As = tensor0 ds; ⋀A::'a tensor. A ∈ set (a # As) ⟹ A = tensor0 ds⟧ ⟹ listsum ds (a # As) = tensor0 ds›*) case Nil (*‹?A ∈ set [] ⟹ ?A = tensor0 ds›*) show "?case" (*goal: ‹listsum (ds::nat list) [] = tensor0 ds›*) by (simp add: listsum_Nil (*‹listsum ?ds [] = tensor0 ?ds›*)) next (*goal: ‹⋀a As. ⟦(⋀A. A ∈ set As ⟹ A = tensor0 ds) ⟹ listsum ds As = tensor0 ds; ⋀A. A ∈ set (a # As) ⟹ A = tensor0 ds⟧ ⟹ listsum ds (a # As) = tensor0 ds›*) case Cons (*‹(⋀A. A ∈ set As_ ⟹ A = tensor0 ds) ⟹ listsum ds As_ = tensor0 ds› ‹?A ∈ set (a_ # As_) ⟹ ?A = tensor0 ds›*) then show "?case" (*goal: ‹listsum ds (a_ # As_) = tensor0 ds›*) using listsum_Cons (*‹listsum (?ds::nat list) ((?A::?'a tensor) # (?As::?'a tensor list)) = ?A + listsum ?ds ?As›*) by (metis dims_tensor0 (*‹dims (tensor0 (?d::nat list)) = ?d›*) list.set_intros( (*‹(?x21.0::?'a::type) ∈ set (?x21.0 # (?x22.0::?'a::type list))›*) 1) set_subset_Cons (*‹set (?xs::?'a::type list) ⊆ set ((?x::?'a::type) # ?xs)›*) subsetCE (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); (?c::?'a::type) ∉ ?A ⟹ ?P::bool; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) tensor_add_0_right (*‹(?A::?'a::monoid_add tensor) + tensor0 (dims ?A) = ?A›*)) qed lemma listsum_all_0_but_one: assumes "⋀i. i≠j ⟹ i<length As ⟹ As!i = tensor0 ds" and "dims (As!j) = ds" and "j < length As" shows "listsum ds As = As!j" using assms (*‹⟦?i ≠ j; ?i < length As⟧ ⟹ As ! ?i = tensor0 ds› ‹dims ((As::'a::monoid_add tensor list) ! (j::nat)) = (ds::nat list)› ‹j < length As›*) proof (induction As arbitrary:j) (*goals: 1. ‹⋀j::nat. ⟦⋀i::nat. ⟦i ≠ j; i < length []⟧ ⟹ [] ! i = tensor0 (ds::nat list); dims ([] ! j) = ds; j < length []⟧ ⟹ listsum ds [] = [] ! j› 2. ‹⋀(a::'a tensor) (As::'a tensor list) j::nat. ⟦⋀j::nat. ⟦⋀i::nat. ⟦i ≠ j; i < length As⟧ ⟹ As ! i = tensor0 (ds::nat list); dims (As ! j) = ds; j < length As⟧ ⟹ listsum ds As = As ! j; ⋀i::nat. ⟦i ≠ j; i < length (a # As)⟧ ⟹ (a # As) ! i = tensor0 ds; dims ((a # As) ! j) = ds; j < length (a # As)⟧ ⟹ listsum ds (a # As) = (a # As) ! j›*) case Nil (*‹⟦?i ≠ j; ?i < length []⟧ ⟹ [] ! ?i = tensor0 ds› ‹dims ([] ! (j::nat)) = (ds::nat list)› ‹(j::nat) < length []›*) then show "?case" (*goal: ‹listsum ds [] = [] ! j›*) by auto next (*goal: ‹⋀a As j. ⟦⋀j. ⟦⋀i. ⟦i ≠ j; i < length As⟧ ⟹ As ! i = tensor0 ds; dims (As ! j) = ds; j < length As⟧ ⟹ listsum ds As = As ! j; ⋀i. ⟦i ≠ j; i < length (a # As)⟧ ⟹ (a # As) ! i = tensor0 ds; dims ((a # As) ! j) = ds; j < length (a # As)⟧ ⟹ listsum ds (a # As) = (a # As) ! j›*) case (Cons A As j) (*‹⟦⋀i. ⟦i ≠ ?j; i < length As⟧ ⟹ As ! i = tensor0 ds; dims (As ! ?j) = ds; ?j < length As⟧ ⟹ listsum ds As = As ! ?j› ‹⟦?i ≠ j; ?i < length (A # As)⟧ ⟹ (A # As) ! ?i = tensor0 ds› ‹dims ((A # As) ! j) = ds› ‹j < length (A # As)›*) then show "?case" (*goal: ‹listsum ds (A # As) = (A # As) ! j›*) proof (cases j) (*goals: 1. ‹⟦⋀j. ⟦⋀i. ⟦i ≠ j; i < length As⟧ ⟹ As ! i = tensor0 ds; dims (As ! j) = ds; j < length As⟧ ⟹ listsum ds As = As ! j; ⋀i. ⟦i ≠ j; i < length (A # As)⟧ ⟹ (A # As) ! i = tensor0 ds; dims ((A # As) ! j) = ds; j < length (A # As); j = 0⟧ ⟹ listsum ds (A # As) = (A # As) ! j› 2. ‹⋀nat. ⟦⋀j. ⟦⋀i. ⟦i ≠ j; i < length As⟧ ⟹ As ! i = tensor0 ds; dims (As ! j) = ds; j < length As⟧ ⟹ listsum ds As = As ! j; ⋀i. ⟦i ≠ j; i < length (A # As)⟧ ⟹ (A # As) ! i = tensor0 ds; dims ((A # As) ! j) = ds; j < length (A # As); j = Suc nat⟧ ⟹ listsum ds (A # As) = (A # As) ! j›*) case 0 (*‹j = 0›*) then have "⋀i. i < length As ⟹ As ! i = tensor0 ds" using Cons (*‹⟦⋀i::nat. ⟦i ≠ (?j::nat); i < length (As::'a tensor list)⟧ ⟹ As ! i = tensor0 (ds::nat list); dims (As ! ?j) = ds; ?j < length As⟧ ⟹ listsum ds As = As ! ?j› ‹⟦?i ≠ j; ?i < length (A # As)⟧ ⟹ (A # As) ! ?i = tensor0 ds› ‹dims ((A # As) ! j) = ds› ‹j < length (A # As)›*) using Suc_less_eq (*‹(Suc ?m < Suc ?n) = (?m < ?n)›*) length_Cons (*‹length (?x # ?xs) = Suc (length ?xs)›*) list.sel(3) (*‹tl (?x21.0 # ?x22.0) = ?x22.0›*) nat.simps(3) (*‹Suc ?x2.0 ≠ 0›*) nth_tl (*‹?n < length (tl ?xs) ⟹ tl ?xs ! ?n = ?xs ! Suc ?n›*) by fastforce then have "listsum ds As = tensor0 ds" using listsum0 (*‹(⋀A. A ∈ set ?As ⟹ A = tensor0 ?ds) ⟹ listsum ?ds ?As = tensor0 ?ds›*) by (metis in_set_conv_nth (*‹(?x ∈ set ?xs) = (∃i<length ?xs. ?xs ! i = ?x)›*)) then show "?thesis" (*goal: ‹listsum ds (A # As) = (A # As) ! j›*) by (metis "0" (*‹j = 0›*) Cons.prems( (*‹dims ((A # As) ! j) = ds›*) 2) listsum_Cons (*‹listsum ?ds (?A # ?As) = ?A + listsum ?ds ?As›*) nth_Cons_0 (*‹(?x # ?xs) ! 0 = ?x›*) tensor_add_0_right (*‹?A + tensor0 (dims ?A) = ?A›*)) next (*goal: ‹⋀nat. ⟦⋀j. ⟦⋀i. ⟦i ≠ j; i < length As⟧ ⟹ As ! i = tensor0 ds; dims (As ! j) = ds; j < length As⟧ ⟹ listsum ds As = As ! j; ⋀i. ⟦i ≠ j; i < length (A # As)⟧ ⟹ (A # As) ! i = tensor0 ds; dims ((A # As) ! j) = ds; j < length (A # As); j = Suc nat⟧ ⟹ listsum ds (A # As) = (A # As) ! j›*) case (Suc j') (*‹(j::nat) = Suc (j'::nat)›*) then have "listsum ds As = As!j'" by (metis (no_types, lifting) Cons.IH (*‹⟦⋀i::nat. ⟦i ≠ (?j::nat); i < length (As::'a::monoid_add tensor list)⟧ ⟹ As ! i = tensor0 (ds::nat list); dims (As ! ?j) = ds; ?j < length As⟧ ⟹ listsum ds As = As ! ?j›*) Cons.prems( (*‹⟦(?i::nat) ≠ (j::nat); ?i < length ((A::'a::monoid_add tensor) # (As::'a::monoid_add tensor list))⟧ ⟹ (A # As) ! ?i = tensor0 (ds::nat list)›*) 1) Cons.prems( (*‹dims (((A::'a::monoid_add tensor) # (As::'a::monoid_add tensor list)) ! (j::nat)) = (ds::nat list)›*) 2) Cons.prems( (*‹(j::nat) < length ((A::'a::monoid_add tensor) # (As::'a::monoid_add tensor list))›*) 3) Suc_less_eq (*‹(Suc (?m::nat) < Suc (?n::nat)) = (?m < ?n)›*) length_Cons (*‹length ((?x::?'a::type) # (?xs::?'a::type list)) = Suc (length ?xs)›*) less_Suc_eq (*‹((?m::nat) < Suc (?n::nat)) = (?m < ?n ∨ ?m = ?n)›*) list.sel( (*‹tl ((?x21.0::?'a::type) # (?x22.0::?'a::type list)) = ?x22.0›*) 3) not_less_eq (*‹(¬ (?m::nat) < (?n::nat)) = (?n < Suc ?m)›*) nth_tl (*‹(?n::nat) < length (tl (?xs::?'a::type list)) ⟹ tl ?xs ! ?n = ?xs ! Suc ?n›*)) then show "?thesis" (*goal: ‹listsum ds (A # As) = (A # As) ! j›*) by (metis Cons.prems( (*‹⟦?i ≠ j; ?i < length (A # As)⟧ ⟹ (A # As) ! ?i = tensor0 ds›*) 1) Cons.prems( (*‹dims ((A # As) ! j) = ds›*) 2) Suc (*‹j = Suc j'›*) length_greater_0_conv (*‹(0 < length ?xs) = (?xs ≠ [])›*) list.simps( (*‹?x21.0 # ?x22.0 ≠ []›*) 3) listsum_Cons (*‹listsum ?ds (?A # ?As) = ?A + listsum ?ds ?As›*) nat.simps( (*‹Suc ?x2.0 ≠ 0›*) 3) nth_Cons_0 (*‹(?x # ?xs) ! 0 = ?x›*) nth_Cons_Suc (*‹(?x # ?xs) ! Suc ?n = ?xs ! ?n›*) tensor_add_0_left (*‹tensor0 (dims ?A) + ?A = ?A›*)) qed qed lemma lookup_listsum: assumes "is ⊲ ds" and "⋀A. A ∈ set As ⟹ dims A = ds" shows "lookup (listsum ds As) is = (∑A←As. lookup A is)" using assms (*‹is ⊲ ds› ‹?A ∈ set As ⟹ dims ?A = ds›*) proof (induction As) (*goals: 1. ‹⟦is ⊲ ds; ⋀A. A ∈ set [] ⟹ dims A = ds⟧ ⟹ lookup (listsum ds []) is = (∑A←[]. lookup A is)› 2. ‹⋀a As. ⟦⟦is ⊲ ds; ⋀A. A ∈ set As ⟹ dims A = ds⟧ ⟹ lookup (listsum ds As) is = (∑A←As. lookup A is); is ⊲ ds; ⋀A. A ∈ set (a # As) ⟹ dims A = ds⟧ ⟹ lookup (listsum ds (a # As)) is = (∑A←a # As. lookup A is)›*) case Nil (*‹is ⊲ ds› ‹?A ∈ set [] ⟹ dims ?A = ds›*) then show "?case" (*goal: ‹lookup (listsum ds []) is = (∑A←[]. lookup A is)›*) by (simp add: assms( (*‹is ⊲ ds›*) 1) listsum_Nil (*‹listsum ?ds [] = tensor0 ?ds›*) lookup_tensor0 (*‹?is ⊲ ?ds ⟹ lookup (tensor0 ?ds) ?is = 0›*)) next (*goal: ‹⋀a As. ⟦⟦is ⊲ ds; ⋀A. A ∈ set As ⟹ dims A = ds⟧ ⟹ lookup (listsum ds As) is = (∑A←As. lookup A is); is ⊲ ds; ⋀A. A ∈ set (a # As) ⟹ dims A = ds⟧ ⟹ lookup (listsum ds (a # As)) is = (∑A←a # As. lookup A is)›*) case (Cons A As) (*‹⟦is ⊲ ds; ⋀A. A ∈ set As ⟹ dims A = ds⟧ ⟹ lookup (listsum ds As) is = (∑A←As. lookup A is)› ‹(is::nat list) ⊲ (ds::nat list)› ‹?A ∈ set (A # As) ⟹ dims ?A = ds›*) then show "?case" (*goal: ‹lookup (listsum ds (A # As)) is = (∑A←A # As. lookup A is)›*) by (simp add: listsum_Cons (*‹listsum ?ds (?A # ?As) = ?A + listsum ?ds ?As›*) list.set_intros (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)› ‹?y ∈ set ?x22.0 ⟹ ?y ∈ set (?x21.0 # ?x22.0)›*) listsum_dims (*‹(⋀A. A ∈ set ?As ⟹ dims A = ?ds) ⟹ dims (listsum ?ds ?As) = ?ds›*)) qed end
{ "path": "afp-2025-02-12/thys/Deep_Learning/Tensor_Plus.thy", "repo": "afp-2025-02-12", "sha": "d9b7854695a8af6b83d52d227bce5adcb5fbb9ba8c861f4f2e87e69a033f456c" }
(* Title: HOL/Algebra/IntRing.thy Author: Stephan Hohe, TU Muenchen Author: Clemens Ballarin *) theory IntRing imports "HOL-Computational_Algebra.Primes" QuotRing Lattice begin section ‹The Ring of Integers› subsection ‹Some properties of \<^typ>‹int›› lemma dvds_eq_abseq: fixes k :: int shows "l dvd k ∧ k dvd l ⟷ ¦l¦ = ¦k¦" by (metis dvd_if_abs_eq (*‹¦?l¦ = ¦?k¦ ⟹ ?l dvd ?k›*) lcm.commute (*‹lcm ?a ?b = lcm ?b ?a›*) lcm_proj1_iff_int (*‹(lcm ?m ?n = ¦?m¦) = (?n dvd ?m)›*)) subsection ‹‹𝒵›: The Set of Integers as Algebraic Structure› abbreviation int_ring :: "int ring" ("𝒵") where "int_ring ≡ ⦇carrier = UNIV, mult = (*), one = 1, zero = 0, add = (+)⦈" lemma int_Zcarr [intro!, simp]: "k ∈ carrier 𝒵" by simp lemma int_is_cring: "cring 𝒵" proof (rule cringI (*‹⟦abelian_group ?R; Group.comm_monoid ?R; ⋀x y z. ⟦x ∈ carrier ?R; y ∈ carrier ?R; z ∈ carrier ?R⟧ ⟹ (x ⊕⇘?R⇙ y) ⊗⇘?R⇙ z = x ⊗⇘?R⇙ z ⊕⇘?R⇙ y ⊗⇘?R⇙ z⟧ ⟹ cring ?R›*)) (*goals: 1. ‹abelian_group 𝒵› 2. ‹Group.comm_monoid 𝒵› 3. ‹⋀x y z. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ (x ⊕⇘𝒵⇙ y) ⊗⇘𝒵⇙ z = x ⊗⇘𝒵⇙ z ⊕⇘𝒵⇙ y ⊗⇘𝒵⇙ z›*) show "abelian_group 𝒵" apply (rule abelian_groupI (*‹⟦⋀x y. ⟦x ∈ carrier ?R; y ∈ carrier ?R⟧ ⟹ x ⊕⇘?R⇙ y ∈ carrier ?R; 𝟬⇘?R⇙ ∈ carrier ?R; ⋀x y z. ⟦x ∈ carrier ?R; y ∈ carrier ?R; z ∈ carrier ?R⟧ ⟹ x ⊕⇘?R⇙ y ⊕⇘?R⇙ z = x ⊕⇘?R⇙ (y ⊕⇘?R⇙ z); ⋀x y. ⟦x ∈ carrier ?R; y ∈ carrier ?R⟧ ⟹ x ⊕⇘?R⇙ y = y ⊕⇘?R⇙ x; ⋀x. x ∈ carrier ?R ⟹ 𝟬⇘?R⇙ ⊕⇘?R⇙ x = x; ⋀x. x ∈ carrier ?R ⟹ ∃y∈carrier ?R. y ⊕⇘?R⇙ x = 𝟬⇘?R⇙⟧ ⟹ abelian_group ?R›*)) (*goals: 1. ‹⋀(x::int) y::int. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y ∈ carrier 𝒵› 2. ‹𝟬⇘𝒵⇙ ∈ carrier 𝒵› 3. ‹⋀(x::int) (y::int) z::int. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y ⊕⇘𝒵⇙ z = x ⊕⇘𝒵⇙ (y ⊕⇘𝒵⇙ z)› 4. ‹⋀(x::int) y::int. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y = y ⊕⇘𝒵⇙ x› 5. ‹⋀x::int. x ∈ carrier 𝒵 ⟹ 𝟬⇘𝒵⇙ ⊕⇘𝒵⇙ x = x› 6. ‹⋀x::int. x ∈ carrier 𝒵 ⟹ ∃y::int∈carrier 𝒵. y ⊕⇘𝒵⇙ x = 𝟬⇘𝒵⇙› discuss goal 1*) apply ((auto intro: left_minus (*‹- (?a::?'a) + ?a = (0::?'a)›*))[1]) (*discuss goal 2*) apply ((auto intro: left_minus (*‹- (?a::?'a::group_add) + ?a = (0::?'a::group_add)›*))[1]) (*discuss goal 3*) apply ((auto intro: left_minus (*‹- ?a + ?a = 0›*))[1]) (*discuss goal 4*) apply ((auto intro: left_minus (*‹- (?a::?'a) + ?a = (0::?'a)›*))[1]) (*discuss goal 5*) apply ((auto intro: left_minus (*‹- ?a + ?a = 0›*))[1]) (*discuss goal 6*) apply ((auto intro: left_minus (*‹- ?a + ?a = 0›*))[1]) (*proven 6 subgoals*) . show "Group.comm_monoid 𝒵" by (simp add: Group.monoid.intro (*‹⟦⋀x y. ⟦x ∈ carrier ?G; y ∈ carrier ?G⟧ ⟹ x ⊗⇘?G⇙ y ∈ carrier ?G; ⋀x y z. ⟦x ∈ carrier ?G; y ∈ carrier ?G; z ∈ carrier ?G⟧ ⟹ x ⊗⇘?G⇙ y ⊗⇘?G⇙ z = x ⊗⇘?G⇙ (y ⊗⇘?G⇙ z); 𝟭⇘?G⇙ ∈ carrier ?G; ⋀x. x ∈ carrier ?G ⟹ 𝟭⇘?G⇙ ⊗⇘?G⇙ x = x; ⋀x. x ∈ carrier ?G ⟹ x ⊗⇘?G⇙ 𝟭⇘?G⇙ = x⟧ ⟹ Group.monoid ?G›*) monoid.monoid_comm_monoidI (*‹⟦Group.monoid ?G; ⋀x y. ⟦x ∈ carrier ?G; y ∈ carrier ?G⟧ ⟹ x ⊗⇘?G⇙ y = y ⊗⇘?G⇙ x⟧ ⟹ Group.comm_monoid ?G›*)) qed (auto simp: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*)) (*solved the remaining goal: ‹⋀x y z. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ (x ⊕⇘𝒵⇙ y) ⊗⇘𝒵⇙ z = x ⊗⇘𝒵⇙ z ⊕⇘𝒵⇙ y ⊗⇘𝒵⇙ z›*) subsection ‹Interpretations› text ‹Since definitions of derived operations are global, their interpretation needs to be done as early as possible --- that is, with as few assumptions as possible.› interpretation int: monoid 𝒵 rewrites "carrier 𝒵 = UNIV" and "mult 𝒵 x y = x * y" and "one 𝒵 = 1" and "pow 𝒵 x n = x^n" proof (-) (*goals: 1. ‹Group.monoid 𝒵› 2. ‹carrier 𝒵 = UNIV› 3. ‹(x::int) ⊗⇘𝒵⇙ (y::int) = x * y› 4. ‹𝟭⇘𝒵⇙ = (1::int)› 5. ‹(x::int) [^]⇘𝒵⇙ (n::nat) = x ^ n›*) show "monoid 𝒵" apply standard (*goals: 1. ‹⋀x y. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊗⇘𝒵⇙ y ∈ carrier 𝒵› 2. ‹⋀x y z. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ x ⊗⇘𝒵⇙ y ⊗⇘𝒵⇙ z = x ⊗⇘𝒵⇙ (y ⊗⇘𝒵⇙ z)› 3. ‹𝟭⇘𝒵⇙ ∈ carrier 𝒵› 4. ‹⋀x. x ∈ carrier 𝒵 ⟹ 𝟭⇘𝒵⇙ ⊗⇘𝒵⇙ x = x› 5. ‹⋀x. x ∈ carrier 𝒵 ⟹ x ⊗⇘𝒵⇙ 𝟭⇘𝒵⇙ = x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . then interpret int: monoid "𝒵" . show "carrier 𝒵 = UNIV" by simp { fix x and y show "mult 𝒵 x y = x * y" by simp } show "one 𝒵 = 1" by simp show "pow 𝒵 x n = x^n" apply (induct n) (*goals: 1. ‹x [^]⇘𝒵⇙ 0 = x ^ 0› 2. ‹⋀n. x [^]⇘𝒵⇙ n = x ^ n ⟹ x [^]⇘𝒵⇙ Suc n = x ^ Suc n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed interpretation int: comm_monoid 𝒵 rewrites "finprod 𝒵 f A = prod f A" proof (-) (*goals: 1. ‹Group.comm_monoid 𝒵› 2. ‹finprod 𝒵 f A = prod f A›*) show "comm_monoid 𝒵" apply standard (*goal: ‹Group.comm_monoid 𝒵›*) by auto then interpret int: comm_monoid "𝒵" . { fix x and y have "mult 𝒵 x y = x * y" by simp } note mult = this (*‹?x2 ⊗⇘𝒵⇙ ?y2 = ?x2 * ?y2›*) have one: "one 𝒵 = 1" by simp show "finprod 𝒵 f A = prod f A" apply (induct A rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*)) (*goals: 1. ‹⋀A::'a set. infinite A ⟹ finprod 𝒵 (f::'a ⇒ int) A = prod f A› 2. ‹finprod 𝒵 (f::'a ⇒ int) {} = prod f {}› 3. ‹⋀(x::'a) F::'a set. ⟦finite F; x ∉ F; finprod 𝒵 (f::'a ⇒ int) F = prod f F⟧ ⟹ finprod 𝒵 f (insert x F) = prod f (insert x F)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed interpretation int: abelian_monoid 𝒵 rewrites int_carrier_eq: "carrier 𝒵 = UNIV" and int_zero_eq: "zero 𝒵 = 0" and int_add_eq: "add 𝒵 x y = x + y" and int_finsum_eq: "finsum 𝒵 f A = sum f A" proof (-) (*goals: 1. ‹abelian_monoid 𝒵› 2. ‹carrier 𝒵 = UNIV› 3. ‹𝟬⇘𝒵⇙ = 0› 4. ‹x ⊕⇘𝒵⇙ y = x + y› 5. ‹finsum 𝒵 f A = sum f A›*) show "abelian_monoid 𝒵" apply standard (*goals: 1. ‹⋀x y. ⟦x ∈ carrier (add_monoid 𝒵); y ∈ carrier (add_monoid 𝒵)⟧ ⟹ x ⊗⇘add_monoid 𝒵⇙ y ∈ carrier (add_monoid 𝒵)› 2. ‹⋀x y z. ⟦x ∈ carrier (add_monoid 𝒵); y ∈ carrier (add_monoid 𝒵); z ∈ carrier (add_monoid 𝒵)⟧ ⟹ x ⊗⇘add_monoid 𝒵⇙ y ⊗⇘add_monoid 𝒵⇙ z = x ⊗⇘add_monoid 𝒵⇙ (y ⊗⇘add_monoid 𝒵⇙ z)› 3. ‹𝟭⇘add_monoid 𝒵⇙ ∈ carrier (add_monoid 𝒵)› 4. ‹⋀x. x ∈ carrier (add_monoid 𝒵) ⟹ 𝟭⇘add_monoid 𝒵⇙ ⊗⇘add_monoid 𝒵⇙ x = x› 5. ‹⋀x. x ∈ carrier (add_monoid 𝒵) ⟹ x ⊗⇘add_monoid 𝒵⇙ 𝟭⇘add_monoid 𝒵⇙ = x› 6. ‹⋀x y. ⟦x ∈ carrier (add_monoid 𝒵); y ∈ carrier (add_monoid 𝒵)⟧ ⟹ x ⊗⇘add_monoid 𝒵⇙ y = y ⊗⇘add_monoid 𝒵⇙ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . then interpret int: abelian_monoid "𝒵" . show "carrier 𝒵 = UNIV" by simp { fix x and y show "add 𝒵 x y = x + y" by simp } note add = this (*‹?xa2 ⊕⇘𝒵⇙ ?ya2 = ?xa2 + ?ya2›*) show zero: "zero 𝒵 = 0" by simp show "finsum 𝒵 f A = sum f A" apply (induct A rule: infinite_finite_induct (*‹⟦⋀A. infinite A ⟹ ?P A; ?P {}; ⋀x F. ⟦finite F; x ∉ F; ?P F⟧ ⟹ ?P (insert x F)⟧ ⟹ ?P ?A›*)) (*goals: 1. ‹⋀A. infinite A ⟹ finsum 𝒵 f A = sum f A› 2. ‹finsum 𝒵 f {} = sum f {}› 3. ‹⋀x F. ⟦finite F; x ∉ F; finsum 𝒵 f F = sum f F⟧ ⟹ finsum 𝒵 f (insert x F) = sum f (insert x F)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed interpretation int: abelian_group 𝒵 (* The equations from the interpretation of abelian_monoid need to be repeated. Since the morphisms through which the abelian structures are interpreted are not the identity, the equations of these interpretations are not inherited. *) (* FIXME *) rewrites "carrier 𝒵 = UNIV" and "zero 𝒵 = 0" and "add 𝒵 x y = x + y" and "finsum 𝒵 f A = sum f A" and int_a_inv_eq: "a_inv 𝒵 x = - x" and int_a_minus_eq: "a_minus 𝒵 x y = x - y" proof (-) (*goals: 1. ‹abelian_group 𝒵› 2. ‹carrier 𝒵 = UNIV› 3. ‹𝟬⇘𝒵⇙ = 0› 4. ‹x ⊕⇘𝒵⇙ y = x + y› 5. ‹finsum 𝒵 f A = sum f A› 6. ‹⊖⇘𝒵⇙ x = - x› 7. ‹x ⊖⇘𝒵⇙ y = x - y›*) show "abelian_group 𝒵" proof (rule abelian_groupI (*‹⟦⋀(x::?'a) y::?'a. ⟦x ∈ carrier (?R::(?'a, ?'b) ring_scheme); y ∈ carrier ?R⟧ ⟹ x ⊕⇘?R⇙ y ∈ carrier ?R; 𝟬⇘?R⇙ ∈ carrier ?R; ⋀(x::?'a) (y::?'a) z::?'a. ⟦x ∈ carrier ?R; y ∈ carrier ?R; z ∈ carrier ?R⟧ ⟹ x ⊕⇘?R⇙ y ⊕⇘?R⇙ z = x ⊕⇘?R⇙ (y ⊕⇘?R⇙ z); ⋀(x::?'a) y::?'a. ⟦x ∈ carrier ?R; y ∈ carrier ?R⟧ ⟹ x ⊕⇘?R⇙ y = y ⊕⇘?R⇙ x; ⋀x::?'a. x ∈ carrier ?R ⟹ 𝟬⇘?R⇙ ⊕⇘?R⇙ x = x; ⋀x::?'a. x ∈ carrier ?R ⟹ ∃y::?'a∈carrier ?R. y ⊕⇘?R⇙ x = 𝟬⇘?R⇙⟧ ⟹ abelian_group ?R›*)) (*goals: 1. ‹⋀x y. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y ∈ carrier 𝒵› 2. ‹𝟬⇘𝒵⇙ ∈ carrier 𝒵› 3. ‹⋀x y z. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y ⊕⇘𝒵⇙ z = x ⊕⇘𝒵⇙ (y ⊕⇘𝒵⇙ z)› 4. ‹⋀x y. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y = y ⊕⇘𝒵⇙ x› 5. ‹⋀x. x ∈ carrier 𝒵 ⟹ 𝟬⇘𝒵⇙ ⊕⇘𝒵⇙ x = x› 6. ‹⋀x. x ∈ carrier 𝒵 ⟹ ∃y∈carrier 𝒵. y ⊕⇘𝒵⇙ x = 𝟬⇘𝒵⇙›*) fix x assume "x ∈ carrier 𝒵" (*‹(x::int) ∈ carrier 𝒵›*) then show "∃y ∈ carrier 𝒵. y ⊕⇘𝒵⇙ x = 𝟬⇘𝒵⇙" apply simp (*goal: ‹∃y∈carrier 𝒵. y ⊕⇘𝒵⇙ x = 𝟬⇘𝒵⇙›*) by arith qed (auto) (*solves the remaining goals: 1. ‹⋀x y. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y ∈ carrier 𝒵› 2. ‹𝟬⇘𝒵⇙ ∈ carrier 𝒵› 3. ‹⋀x y z. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y ⊕⇘𝒵⇙ z = x ⊕⇘𝒵⇙ (y ⊕⇘𝒵⇙ z)› 4. ‹⋀x y. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵⟧ ⟹ x ⊕⇘𝒵⇙ y = y ⊕⇘𝒵⇙ x› 5. ‹⋀x. x ∈ carrier 𝒵 ⟹ 𝟬⇘𝒵⇙ ⊕⇘𝒵⇙ x = x›*) then interpret int: abelian_group "𝒵" . { fix x and y have "add 𝒵 x y = x + y" by simp } note add = this (*‹(?xa2::int) ⊕⇘𝒵⇙ (?ya2::int) = ?xa2 + ?ya2›*) have zero: "zero 𝒵 = 0" by simp { fix x have "add 𝒵 (- x) x = zero 𝒵" by (simp add: add (*‹?xa2 ⊕⇘𝒵⇙ ?ya2 = ?xa2 + ?ya2›*) zero (*‹𝟬⇘𝒵⇙ = 0›*)) then show "a_inv 𝒵 x = - x" by (simp add: int.minus_equality (*‹⟦?y + ?x = 0; ?x ∈ UNIV; ?y ∈ UNIV⟧ ⟹ ⊖⇘𝒵⇙ ?x = ?y›*)) } note a_inv = this (*‹⊖⇘𝒵⇙ ?xa2 = - ?xa2›*) show "a_minus 𝒵 x y = x - y" by (simp add: int.minus_eq (*‹(?x::int) ⊖⇘𝒵⇙ (?y::int) = ?x + ⊖⇘𝒵⇙ ?y›*) add (*‹(?xa2::int) ⊕⇘𝒵⇙ (?ya2::int) = ?xa2 + ?ya2›*) a_inv (*‹⊖⇘𝒵⇙ (?xa2::int) = - ?xa2›*)) qed ((simp add: int_carrier_eq (*‹carrier 𝒵 = UNIV›*) int_zero_eq (*‹𝟬⇘𝒵⇙ = 0›*) int_add_eq (*‹?x ⊕⇘𝒵⇙ ?y = ?x + ?y›*) int_finsum_eq (*‹finsum 𝒵 ?f ?A = sum ?f ?A›*))+) (*solves the remaining goals: 1. ‹carrier 𝒵 = UNIV› 2. ‹𝟬⇘𝒵⇙ = 0› 3. ‹x ⊕⇘𝒵⇙ y = x + y› 4. ‹finsum 𝒵 f A = sum f A›*) interpretation int: "domain" 𝒵 rewrites "carrier 𝒵 = UNIV" and "zero 𝒵 = 0" and "add 𝒵 x y = x + y" and "finsum 𝒵 f A = sum f A" and "a_inv 𝒵 x = - x" and "a_minus 𝒵 x y = x - y" proof (-) (*goals: 1. ‹domain 𝒵› 2. ‹carrier 𝒵 = UNIV› 3. ‹𝟬⇘𝒵⇙ = 0› 4. ‹x ⊕⇘𝒵⇙ y = x + y› 5. ‹finsum 𝒵 f A = sum f A› 6. ‹⊖⇘𝒵⇙ x = - x› 7. ‹x ⊖⇘𝒵⇙ y = x - y›*) show "domain 𝒵" apply unfold_locales (*goals: 1. ‹⋀(x::int) (y::int) z::int. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ (x ⊕⇘𝒵⇙ y) ⊗⇘𝒵⇙ z = x ⊗⇘𝒵⇙ z ⊕⇘𝒵⇙ y ⊗⇘𝒵⇙ z› 2. ‹⋀(x::int) (y::int) z::int. ⟦x ∈ carrier 𝒵; y ∈ carrier 𝒵; z ∈ carrier 𝒵⟧ ⟹ z ⊗⇘𝒵⇙ (x ⊕⇘𝒵⇙ y) = z ⊗⇘𝒵⇙ x ⊕⇘𝒵⇙ z ⊗⇘𝒵⇙ y› 3. ‹𝟭⇘𝒵⇙ ≠ 𝟬⇘𝒵⇙› 4. ‹⋀(a::int) b::int. ⟦a ⊗⇘𝒵⇙ b = 𝟬⇘𝒵⇙; a ∈ carrier 𝒵; b ∈ carrier 𝒵⟧ ⟹ a = 𝟬⇘𝒵⇙ ∨ b = 𝟬⇘𝒵⇙› discuss goal 1*) apply ((auto simp: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*))[1]) (*discuss goal 2*) apply ((auto simp: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*))[1]) (*discuss goal 3*) apply ((auto simp: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*))[1]) (*discuss goal 4*) apply ((auto simp: distrib_right (*‹(?a + ?b) * ?c = ?a * ?c + ?b * ?c›*) distrib_left (*‹?a * (?b + ?c) = ?a * ?b + ?a * ?c›*))[1]) (*proven 4 subgoals*) . qed ((simp add: int_carrier_eq (*‹carrier 𝒵 = UNIV›*) int_zero_eq (*‹𝟬⇘𝒵⇙ = 0›*) int_add_eq (*‹?x ⊕⇘𝒵⇙ ?y = ?x + ?y›*) int_finsum_eq (*‹finsum 𝒵 ?f ?A = sum ?f ?A›*) int_a_inv_eq (*‹⊖⇘𝒵⇙ ?x = - ?x›*) int_a_minus_eq (*‹?x ⊖⇘𝒵⇙ ?y = ?x - ?y›*))+) (*solves the remaining goals: 1. ‹carrier 𝒵 = UNIV› 2. ‹𝟬⇘𝒵⇙ = 0› 3. ‹x ⊕⇘𝒵⇙ y = x + y› 4. ‹finsum 𝒵 f A = sum f A› 5. ‹⊖⇘𝒵⇙ x = - x› 6. ‹x ⊖⇘𝒵⇙ y = x - y›*) text ‹Removal of occurrences of \<^term>‹UNIV› in interpretation result --- experimental.› lemma UNIV: "x ∈ UNIV ⟷ True" "A ⊆ UNIV ⟷ True" "(∀x ∈ UNIV. P x) ⟷ (∀x. P x)" "(∃x ∈ UNIV. P x) ⟷ (∃x. P x)" "(True ⟶ Q) ⟷ Q" "(True ⟹ PROP R) ≡ PROP R" (*goals: 1. ‹(x ∈ UNIV) = True› 2. ‹(A ⊆ UNIV) = True› 3. ‹(∀x∈UNIV. P x) = (∀x. P x)› 4. ‹(∃x∈UNIV. P x) = (∃x. P x)› 5. ‹(True ⟶ Q) = Q› 6. ‹(True ⟹ PROP R) ≡ PROP R› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*proven 6 subgoals*) . interpretation int (* FIXME [unfolded UNIV] *) : partial_order "⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈" rewrites "carrier ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ = UNIV" and "le ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ x y = (x ≤ y)" and "lless ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ x y = (x < y)" proof (-) (*goals: 1. ‹partial_order ⦇carrier = UNIV, eq = (=), le = (≤)⦈› 2. ‹carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈ = UNIV› 3. ‹(x ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y) = (x ≤ y)› 4. ‹(x ⊏⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y) = (x < y)›*) show "partial_order ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈" apply standard (*goals: 1. ‹⋀x. x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈ ⟹ x .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ x› 2. ‹⋀x y. ⟦x .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y; x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ y .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ x› 3. ‹⋀x y z. ⟦x .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y; y .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ z; x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; z ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ x .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ z› 4. ‹⋀x. x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈ ⟹ x ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ x› 5. ‹⋀x y. ⟦x ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y; y ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ x; x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ x .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y› 6. ‹⋀x y z. ⟦x ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y; y ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ z; x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; z ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ x ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ z› 7. ‹⋀x y z w. ⟦x .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y; z .=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ w; x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; z ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; w ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ (x ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ z) = (y ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ w)› 8. ‹(.=⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙) = (=)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*discuss goal 7*) apply simp (*discuss goal 8*) apply simp (*proven 8 subgoals*) . show "carrier ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ = UNIV" by simp show "le ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ x y = (x ≤ y)" by simp show "lless ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ x y = (x < y)" apply (simp add: lless_def (*‹((?x::?'a) ⊏⇘?L::(?'a, ?'b) gorder_scheme⇙ (?y::?'a)) = (?x ⊑⇘?L⇙ ?y ∧ ?x .≠⇘?L⇙ ?y)›*)) (*goal: ‹(x ⊏⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ y) = (x < y)›*) by auto qed interpretation int (* FIXME [unfolded UNIV] *) : lattice "⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈" rewrites "join ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ x y = max x y" and "meet ⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈ x y = min x y" proof (-) (*goals: 1. ‹lattice ⦇carrier = UNIV, eq = (=), le = (≤)⦈› 2. ‹(x::int) ⊔⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ (y::int) = max x y› 3. ‹(x::int) ⊓⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ (y::int) = min x y›*) let ?Z = "⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈" show "lattice ?Z" apply unfold_locales (*goals: 1. ‹⋀x y. ⟦x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ∃s. is_lub ⦇carrier = UNIV, eq = (=), le = (≤)⦈ s {x, y}› 2. ‹⋀x y. ⟦x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ∃s. is_glb ⦇carrier = UNIV, eq = (=), le = (≤)⦈ s {x, y}› discuss goal 1*) apply (simp add: least_def (*‹least ?L ?l ?A = (?A ⊆ carrier ?L ∧ ?l ∈ ?A ∧ (∀x∈?A. ?l ⊑⇘?L⇙ x))›*) Upper_def (*‹Upper ?L ?A = {u. ∀x. x ∈ ?A ∩ carrier ?L ⟶ x ⊑⇘?L⇙ u} ∩ carrier ?L›*) greatest_def (*‹greatest ?L ?g ?A = (?A ⊆ carrier ?L ∧ ?g ∈ ?A ∧ (∀x∈?A. x ⊑⇘?L⇙ ?g))›*) Lower_def (*‹Lower ?L ?A = {l. ∀x. x ∈ ?A ∩ carrier ?L ⟶ l ⊑⇘?L⇙ x} ∩ carrier ?L›*)) (*top goal: ‹⋀x y. ⟦x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ∃s. is_lub ⦇carrier = UNIV, eq = (=), le = (≤)⦈ s {x, y}› and 1 goal remains*) apply arith (*discuss goal 2*) apply (simp add: least_def (*‹least ?L ?l ?A = (?A ⊆ carrier ?L ∧ ?l ∈ ?A ∧ (∀x∈?A. ?l ⊑⇘?L⇙ x))›*) Upper_def (*‹Upper ?L ?A = {u. ∀x. x ∈ ?A ∩ carrier ?L ⟶ x ⊑⇘?L⇙ u} ∩ carrier ?L›*) greatest_def (*‹greatest ?L ?g ?A = (?A ⊆ carrier ?L ∧ ?g ∈ ?A ∧ (∀x∈?A. x ⊑⇘?L⇙ ?g))›*) Lower_def (*‹Lower ?L ?A = {l. ∀x. x ∈ ?A ∩ carrier ?L ⟶ l ⊑⇘?L⇙ x} ∩ carrier ?L›*)) (*goal: ‹⋀x y. ⟦x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ∃s. is_glb ⦇carrier = UNIV, eq = (=), le = (≤)⦈ s {x, y}›*) apply arith (*proven 2 subgoals*) . then interpret int: lattice "?Z" . show "join ?Z x y = max x y" by (metis int.le_iff_meet (*‹⟦?x ∈ UNIV; ?y ∈ UNIV⟧ ⟹ (?x ≤ ?y) = (?x ⊔⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?y = ?y)›*) iso_tuple_UNIV_I (*‹?x ∈ UNIV ≡ True›*) join_comm (*‹?x ⊔⇘?L⇙ ?y = ?y ⊔⇘?L⇙ ?x›*) linear (*‹?x ≤ ?y ∨ ?y ≤ ?x›*) max.absorb_iff2 (*‹(?a ≤ ?b) = (max ?a ?b = ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) show "meet ?Z x y = min x y" using int.meet_le (*‹⟦?z ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?x; ?z ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?y; ?x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; ?y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; ?z ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ?z ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?x ⊓⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?y›*) int.meet_left (*‹⟦?x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; ?y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ?x ⊓⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?y ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?x›*) int.meet_right (*‹⟦?x ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈; ?y ∈ carrier ⦇carrier = UNIV, eq = (=), le = (≤)⦈⟧ ⟹ ?x ⊓⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?y ⊑⇘⦇carrier = UNIV, eq = (=), le = (≤)⦈⇙ ?y›*) by auto qed interpretation int (* [unfolded UNIV] *) : total_order "⦇carrier = UNIV::int set, eq = (=), le = (≤)⦈" apply standard (*goal: ‹total_order ⦇carrier = UNIV, eq = (=), le = (≤)⦈›*) by clarsimp subsection ‹Generated Ideals of ‹𝒵›› lemma int_Idl: "Idl⇘𝒵⇙ {a} = {x * a | x. True}" by (simp add: cgenideal_def (*‹PIdl⇘?R⇙ ?a = {x ⊗⇘?R⇙ ?a |x. x ∈ carrier ?R}›*) int.cgenideal_eq_genideal[symmetric] (*‹?i ∈ UNIV ⟹ Idl⇘𝒵⇙ {?i} = PIdl⇘𝒵⇙ ?i›*)) lemma multiples_principalideal: "principalideal {x * a | x. True } 𝒵" by (metis UNIV_I (*‹(?x::?'a) ∈ UNIV›*) int.cgenideal_eq_genideal (*‹(?i::int) ∈ UNIV ⟹ PIdl⇘𝒵⇙ ?i = Idl⇘𝒵⇙ {?i}›*) int.cgenideal_is_principalideal (*‹(?i::int) ∈ UNIV ⟹ principalideal (PIdl⇘𝒵⇙ ?i) 𝒵›*) int_Idl (*‹Idl⇘𝒵⇙ {?a::int} = {x * ?a |x::int. True}›*)) lemma prime_primeideal: assumes prime: "Factorial_Ring.prime p" shows "primeideal (Idl⇘𝒵⇙ {p}) 𝒵" proof (rule primeidealI (*‹⟦ideal ?I ?R; cring ?R; carrier ?R ≠ ?I; ⋀a b. ⟦a ∈ carrier ?R; b ∈ carrier ?R; a ⊗⇘?R⇙ b ∈ ?I⟧ ⟹ a ∈ ?I ∨ b ∈ ?I⟧ ⟹ primeideal ?I ?R›*)) (*goals: 1. ‹ideal (Idl⇘𝒵⇙ {p}) 𝒵› 2. ‹cring 𝒵› 3. ‹carrier 𝒵 ≠ Idl⇘𝒵⇙ {p}› 4. ‹⋀a b. ⟦a ∈ carrier 𝒵; b ∈ carrier 𝒵; a ⊗⇘𝒵⇙ b ∈ Idl⇘𝒵⇙ {p}⟧ ⟹ a ∈ Idl⇘𝒵⇙ {p} ∨ b ∈ Idl⇘𝒵⇙ {p}›*) show "ideal (Idl⇘𝒵⇙ {p}) 𝒵" apply (rule int.genideal_ideal (*‹?S ⊆ UNIV ⟹ ideal (Idl⇘𝒵⇙ ?S) 𝒵›*)) (*goal: ‹ideal (Idl⇘𝒵⇙ {p}) 𝒵›*) by simp show "cring 𝒵" by (rule int_is_cring (*‹cring 𝒵›*)) have False if "UNIV = {v::int. ∃x. v = x * p}" proof (-) (*goal: ‹False›*) from that (*‹UNIV = {v::int. ∃x::int. v = x * (p::int)}›*) obtain i where "1 = i * p" (*goal: ‹(⋀i. 1 = i * p ⟹ thesis) ⟹ thesis›*) by (blast intro: elim:) then show False using prime (*‹prime p›*) by (auto simp add: abs_mult (*‹¦?a * ?b¦ = ¦?a¦ * ¦?b¦›*) zmult_eq_1_iff (*‹(?m * ?n = 1) = (?m = 1 ∧ ?n = 1 ∨ ?m = - 1 ∧ ?n = - 1)›*)) qed then show "carrier 𝒵 ≠ Idl⇘𝒵⇙ {p}" by (auto simp add: int.cgenideal_eq_genideal[symmetric] (*‹?i ∈ UNIV ⟹ Idl⇘𝒵⇙ {?i} = PIdl⇘𝒵⇙ ?i›*) cgenideal_def (*‹PIdl⇘?R⇙ ?a = {x ⊗⇘?R⇙ ?a |x. x ∈ carrier ?R}›*)) have "p dvd a ∨ p dvd b" if "a * b = x * p" for a and b and x by (simp add: prime (*‹prime p›*) prime_dvd_multD (*‹⟦prime ?p; ?p dvd ?a * ?b⟧ ⟹ ?p dvd ?a ∨ ?p dvd ?b›*) that (*‹a * b = x * p›*)) then show "⋀a b. ⟦a ∈ carrier 𝒵; b ∈ carrier 𝒵; a ⊗⇘𝒵⇙ b ∈ Idl⇘𝒵⇙ {p}⟧ ⟹ a ∈ Idl⇘𝒵⇙ {p} ∨ b ∈ Idl⇘𝒵⇙ {p}" by (auto simp add: int.cgenideal_eq_genideal[symmetric] (*‹?i ∈ UNIV ⟹ Idl⇘𝒵⇙ {?i} = PIdl⇘𝒵⇙ ?i›*) cgenideal_def (*‹PIdl⇘?R⇙ ?a = {x ⊗⇘?R⇙ ?a |x. x ∈ carrier ?R}›*) dvd_def (*‹(?b dvd ?a) = (∃k. ?a = ?b * k)›*) mult.commute (*‹?a * ?b = ?b * ?a›*)) qed subsection ‹Ideals and Divisibility› lemma int_Idl_subset_ideal: "Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} = (k ∈ Idl⇘𝒵⇙ {l})" apply (rule int.Idl_subset_ideal' (*‹⟦?a ∈ UNIV; ?b ∈ UNIV⟧ ⟹ (Idl⇘𝒵⇙ {?a} ⊆ Idl⇘𝒵⇙ {?b}) = (?a ∈ Idl⇘𝒵⇙ {?b})›*)) (*goals: 1. ‹k ∈ UNIV› 2. ‹l ∈ UNIV› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma Idl_subset_eq_dvd: "Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ⟷ l dvd k" apply (subst int_Idl_subset_ideal (*‹(Idl⇘𝒵⇙ {?k::int} ⊆ Idl⇘𝒵⇙ {?l::int}) = (?k ∈ Idl⇘𝒵⇙ {?l})›*)) (*goal: ‹(Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l}) = (l dvd k)›*) by (auto simp: dvd_def (*‹((?b::?'a) dvd (?a::?'a)) = (∃k::?'a. ?a = ?b * k)›*) int_Idl (*‹Idl⇘𝒵⇙ {?a::int} = {x * ?a |x::int. True}›*)) lemma dvds_eq_Idl: "l dvd k ∧ k dvd l ⟷ Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l}" proof (-) (*goal: ‹(l dvd k ∧ k dvd l) = (Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l})›*) have a: "l dvd k ⟷ (Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l})" by (rule Idl_subset_eq_dvd[symmetric] (*‹((?l::int) dvd (?k::int)) = (Idl⇘𝒵⇙ {?k} ⊆ Idl⇘𝒵⇙ {?l})›*)) have b: "k dvd l ⟷ (Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k})" by (rule Idl_subset_eq_dvd[symmetric] (*‹(?l dvd ?k) = (Idl⇘𝒵⇙ {?k} ⊆ Idl⇘𝒵⇙ {?l})›*)) have "l dvd k ∧ k dvd l ⟷ Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ∧ Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k}" apply (subst a (*‹((l::int) dvd (k::int)) = (Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l})›*)) (*goal: ‹(l dvd k ∧ k dvd l) = (Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ∧ Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k})›*) apply (subst b (*‹((k::int) dvd (l::int)) = (Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k})›*)) (*goal: ‹(Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ∧ k dvd l) = (Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ∧ Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k})›*) by simp also (*calculation: ‹(l dvd k ∧ k dvd l) = (Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ∧ Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k})›*) have "Idl⇘𝒵⇙ {k} ⊆ Idl⇘𝒵⇙ {l} ∧ Idl⇘𝒵⇙ {l} ⊆ Idl⇘𝒵⇙ {k} ⟷ Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l}" by blast finally (*calculation: ‹(l dvd k ∧ k dvd l) = (Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l})›*) show "?thesis" (*goal: ‹(l dvd k ∧ k dvd l) = (Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l})›*) . qed lemma Idl_eq_abs: "Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l} ⟷ ¦l¦ = ¦k¦" apply (subst dvds_eq_abseq[symmetric] (*‹(¦?l¦ = ¦?k¦) = (?l dvd ?k ∧ ?k dvd ?l)›*)) (*goal: ‹(Idl⇘𝒵⇙ {k} = Idl⇘𝒵⇙ {l}) = (¦l¦ = ¦k¦)›*) by (rule dvds_eq_Idl[symmetric] (*‹(Idl⇘𝒵⇙ {?k} = Idl⇘𝒵⇙ {?l}) = (?l dvd ?k ∧ ?k dvd ?l)›*)) subsection ‹Ideals and the Modulus› definition ZMod :: "int ⇒ int ⇒ int set" where "ZMod k r = (Idl⇘𝒵⇙ {k}) +>⇘𝒵⇙ r" lemmas ZMod_defs = ZMod_def genideal_def lemma rcos_zfact: assumes kIl: "k ∈ ZMod l r" shows "∃x. k = x * l + r" proof (-) (*goal: ‹∃x::int. (k::int) = x * (l::int) + (r::int)›*) from kIl[unfolded ZMod_def] (*‹k ∈ Idl⇘𝒵⇙ {l} +>⇘𝒵⇙ r›*) have "∃xl∈Idl⇘𝒵⇙ {l}. k = xl + r" by (simp add: a_r_coset_defs (*‹(+>⇘?G⇙) = (#>⇘add_monoid ?G⇙)› ‹?H #>⇘?G⇙ ?a = (⋃h∈?H. {h ⊗⇘?G⇙ ?a})›*)) then obtain xl where xl: "xl ∈ Idl⇘𝒵⇙ {l}" and k: "k = xl + r" (*goal: ‹(⋀xl. ⟦xl ∈ Idl⇘𝒵⇙ {l}; k = xl + r⟧ ⟹ thesis) ⟹ thesis›*) by auto from xl (*‹xl ∈ Idl⇘𝒵⇙ {l}›*) obtain x where "xl = x * l" (*goal: ‹(⋀x::int. (xl::int) = x * (l::int) ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: int_Idl (*‹Idl⇘𝒵⇙ {?a} = {x * ?a |x. True}›*)) with k (*‹k = xl + r›*) have "k = x * l + r" by simp then show "∃x. k = x * l + r" by standard qed lemma ZMod_imp_zmod: assumes zmods: "ZMod m a = ZMod m b" shows "a mod m = b mod m" proof (-) (*goal: ‹a mod m = b mod m›*) interpret ideal "Idl⇘𝒵⇙ {m}" "𝒵" apply (rule int.genideal_ideal (*‹?S ⊆ UNIV ⟹ ideal (Idl⇘𝒵⇙ ?S) 𝒵›*)) (*goal: ‹ideal (Idl⇘𝒵⇙ {m}) 𝒵›*) by fast from zmods (*‹ZMod (m::int) (a::int) = ZMod m (b::int)›*) have "b ∈ ZMod m a" unfolding ZMod_def (*goal: ‹b ∈ Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ a›*) by (simp add: a_repr_independenceD (*‹⟦?y ∈ UNIV; Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ ?x = Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ ?y⟧ ⟹ ?y ∈ Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ ?x›*)) then have "∃x. b = x * m + a" by (rule rcos_zfact (*‹?k ∈ ZMod ?l ?r ⟹ ∃x. ?k = x * ?l + ?r›*)) then obtain x where "b = x * m + a" (*goal: ‹(⋀x. b = x * m + a ⟹ thesis) ⟹ thesis›*) by fast then have "b mod m = (x * m + a) mod m" by simp also (*calculation: ‹(b::int) mod (m::int) = ((x::int) * m + (a::int)) mod m›*) have "… = ((x * m) mod m) + (a mod m)" by (simp add: mod_add_eq (*‹((?a::?'a) mod (?c::?'a) + (?b::?'a) mod ?c) mod ?c = (?a + ?b) mod ?c›*)) also (*calculation: ‹b mod m = x * m mod m + a mod m›*) have "… = a mod m" by simp finally (*calculation: ‹b mod m = a mod m›*) have "b mod m = a mod m" . then show "a mod m = b mod m" by standard qed lemma ZMod_mod: "ZMod m a = ZMod m (a mod m)" proof (-) (*goal: ‹ZMod m a = ZMod m (a mod m)›*) interpret ideal "Idl⇘𝒵⇙ {m}" "𝒵" apply (rule int.genideal_ideal (*‹?S ⊆ UNIV ⟹ ideal (Idl⇘𝒵⇙ ?S) 𝒵›*)) (*goal: ‹ideal (Idl⇘𝒵⇙ {m}) 𝒵›*) by fast show "?thesis" (*goal: ‹ZMod m a = ZMod m (a mod m)›*) unfolding ZMod_def (*goal: ‹Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ a = Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ a mod m›*) apply (rule a_repr_independence'[symmetric] (*‹⟦?y ∈ Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ ?x; ?x ∈ UNIV⟧ ⟹ Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ ?y = Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ ?x›*)) (*goal: ‹Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ a = Idl⇘𝒵⇙ {m} +>⇘𝒵⇙ a mod m›*) proof (simp add: int_Idl (*‹Idl⇘𝒵⇙ {?a} = {x * ?a |x. True}›*) a_r_coset_defs (*‹(+>⇘?G⇙) = (#>⇘add_monoid ?G⇙)› ‹?H #>⇘?G⇙ ?a = (⋃h∈?H. {h ⊗⇘?G⇙ ?a})›*)) (*goals: 1. ‹∃x::int. (∃xa::int. x = xa * (m::int)) ∧ (a::int) = x + a mod m› 2. ‹(a::int) mod (m::int) ∈ UNIV›*) have "a = m * (a div m) + (a mod m)" by (simp add: mult_div_mod_eq [symmetric] (*‹?t = ?b * (?t div ?b) + ?t mod ?b›*)) then have "a = (a div m) * m + (a mod m)" by simp then show "∃h. (∃x. h = x * m) ∧ a = h + a mod m" by fast qed (simp) (*solved the remaining goal: ‹a mod m ∈ UNIV›*) qed lemma zmod_imp_ZMod: assumes modeq: "a mod m = b mod m" shows "ZMod m a = ZMod m b" proof (-) (*goal: ‹ZMod m a = ZMod m b›*) have "ZMod m a = ZMod m (a mod m)" by (rule ZMod_mod (*‹ZMod ?m ?a = ZMod ?m (?a mod ?m)›*)) also (*calculation: ‹ZMod (m::int) (a::int) = ZMod m (a mod m)›*) have "… = ZMod m (b mod m)" by (simp add: modeq[symmetric] (*‹b mod m = a mod m›*)) also (*calculation: ‹ZMod m a = ZMod m (b mod m)›*) have "… = ZMod m b" by (rule ZMod_mod[symmetric] (*‹ZMod ?m (?a mod ?m) = ZMod ?m ?a›*)) finally (*calculation: ‹ZMod (m::int) (a::int) = ZMod m (b::int)›*) show "?thesis" (*goal: ‹ZMod m a = ZMod m b›*) . qed corollary ZMod_eq_mod: "ZMod m a = ZMod m b ⟷ a mod m = b mod m" apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹ZMod m a = ZMod m b ⟹ a mod m = b mod m› 2. ‹a mod m = b mod m ⟹ ZMod m a = ZMod m b› discuss goal 1*) apply (erule ZMod_imp_zmod (*‹ZMod ?m ?a = ZMod ?m ?b ⟹ ?a mod ?m = ?b mod ?m›*)) (*discuss goal 2*) apply (erule zmod_imp_ZMod (*‹?a mod ?m = ?b mod ?m ⟹ ZMod ?m ?a = ZMod ?m ?b›*)) (*proven 2 subgoals*) . subsection ‹Factorization› definition ZFact :: "int ⇒ int set ring" where "ZFact k = 𝒵 Quot (Idl⇘𝒵⇙ {k})" lemmas ZFact_defs = ZFact_def FactRing_def lemma ZFact_is_cring: "cring (ZFact k)" by (simp add: ZFact_def (*‹ZFact ?k = 𝒵 Quot Idl⇘𝒵⇙ {?k}›*) ideal.quotient_is_cring (*‹⟦ideal ?I ?R; cring ?R⟧ ⟹ cring (?R Quot ?I)›*) int.cring_axioms (*‹cring 𝒵›*) int.genideal_ideal (*‹?S ⊆ UNIV ⟹ ideal (Idl⇘𝒵⇙ ?S) 𝒵›*)) lemma ZFact_zero: "carrier (ZFact 0) = (⋃a. {{a}})" by (simp add: ZFact_defs (*‹ZFact ?k = 𝒵 Quot Idl⇘𝒵⇙ {?k}› ‹?R Quot ?I = ⦇carrier = a_rcosets⇘?R⇙ ?I, monoid.mult = rcoset_mult ?R ?I, one = ?I +>⇘?R⇙ 𝟭⇘?R⇙, zero = ?I, add = (<+>⇘?R⇙)⦈›*) A_RCOSETS_defs (*‹a_rcosets⇘?G⇙ ?H = rcosets⇘add_monoid ?G⇙ ?H› ‹rcosets⇘?G⇙ ?H = (⋃a∈carrier ?G. {?H #>⇘?G⇙ a})›*) r_coset_def (*‹?H #>⇘?G⇙ ?a = (⋃h∈?H. {h ⊗⇘?G⇙ ?a})›*) int.genideal_zero (*‹Idl⇘𝒵⇙ {0} = {0}›*)) lemma ZFact_one: "carrier (ZFact 1) = {UNIV}" unfolding ZFact_defs A_RCOSETS_defs r_coset_def ring_record_simps int.genideal_one (*goal: ‹(⋃a. {⋃h. {h + a}}) = {UNIV}›*) proof (standard) (*goals: 1. ‹(⋃a. {⋃h. {h + a}}) ⊆ {UNIV}› 2. ‹{UNIV} ⊆ (⋃a. {⋃h. {h + a}})›*) have "⋀a b::int. ∃x. b = x + a" by presburger then show "(⋃a::int. {⋃h. {h + a}}) ⊆ {UNIV}" by force then show "{UNIV} ⊆ (⋃a::int. {⋃h. {h + a}})" by (metis (no_types, lifting) UNIV_I (*‹(?x::?'a) ∈ UNIV›*) UN_I (*‹⟦(?a::?'a) ∈ (?A::?'a set); (?b::?'b) ∈ (?B::?'a ⇒ ?'b set) ?a⟧ ⟹ ?b ∈ ⋃ (?B ` ?A)›*) singletonD (*‹(?b::?'a) ∈ {?a::?'a} ⟹ ?b = ?a›*) singletonI (*‹(?a::?'a) ∈ {?a}›*) subset_iff (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀t::?'a. t ∈ ?A ⟶ t ∈ ?B)›*)) qed lemma ZFact_prime_is_domain: assumes pprime: "Factorial_Ring.prime p" shows "domain (ZFact p)" by (simp add: ZFact_def (*‹ZFact ?k = 𝒵 Quot Idl⇘𝒵⇙ {?k}›*) pprime (*‹prime p›*) prime_primeideal (*‹prime ?p ⟹ primeideal (Idl⇘𝒵⇙ {?p}) 𝒵›*) primeideal.quotient_is_domain (*‹primeideal ?I ?R ⟹ domain (?R Quot ?I)›*)) end
{ "path": "Isabelle2024/src/HOL/Algebra/IntRing.thy", "repo": "Isabelle2024", "sha": "37e90a404611dc72a5e19645d0245bfd49c18551153f68db4b1551c6adac2936" }
(*********************************************************************************** * Copyright (c) 2016-2018 The University of Sheffield, UK * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * SPDX-License-Identifier: BSD-2-Clause ***********************************************************************************) section‹Node› text‹In this theory, we introduce the monadic method setup for the Node class.› theory NodeMonad imports ObjectMonad "../classes/NodeClass" begin type_synonym ('object_ptr, 'node_ptr, 'Object, 'Node, 'result) dom_prog = "((_) heap, exception, 'result) prog" register_default_tvars "('object_ptr, 'node_ptr, 'Object, 'Node, 'result) dom_prog" global_interpretation l_ptr_kinds_M node_ptr_kinds defines node_ptr_kinds_M = a_ptr_kinds_M . lemmas node_ptr_kinds_M_defs = a_ptr_kinds_M_def lemma node_ptr_kinds_M_eq: assumes "|h ⊢ object_ptr_kinds_M|⇩r = |h' ⊢ object_ptr_kinds_M|⇩r" shows "|h ⊢ node_ptr_kinds_M|⇩r = |h' ⊢ node_ptr_kinds_M|⇩r" using assms (*‹|(h::(_) heap) ⊢ object_ptr_kinds_M|⇩r = |(h'::(_) heap) ⊢ object_ptr_kinds_M|⇩r›*) by (auto simp add: node_ptr_kinds_M_defs (*‹node_ptr_kinds_M = get_heap ⤜ (λh. return (sorted_list_of_set (fset (node_ptr_kinds h))))›*) object_ptr_kinds_M_defs (*‹object_ptr_kinds_M = get_heap ⤜ (λh. return (sorted_list_of_set (fset (object_ptr_kinds h))))›*) node_ptr_kinds_def (*‹node_ptr_kinds ?heap = the |`| cast |`| ffilter is_node_ptr_kind (object_ptr_kinds ?heap)›*)) global_interpretation l_dummy defines get_M⇩N⇩o⇩d⇩e = "l_get_M.a_get_M get⇩N⇩o⇩d⇩e" . lemma get_M_is_l_get_M: "l_get_M get⇩N⇩o⇩d⇩e type_wf node_ptr_kinds" sorry lemmas get_M_defs = get_M⇩N⇩o⇩d⇩e_def[unfolded l_get_M.a_get_M_def[OF get_M_is_l_get_M]] adhoc_overloading get_M get_M⇩N⇩o⇩d⇩e locale l_get_M⇩N⇩o⇩d⇩e_lemmas = l_type_wf⇩N⇩o⇩d⇩e begin sublocale l_get_M⇩O⇩b⇩j⇩e⇩c⇩t_lemmas by unfold_locales interpretation l_get_M get⇩N⇩o⇩d⇩e type_wf node_ptr_kinds apply unfold_locales (*goals: 1. ‹⋀h ptr. ⟦type_wf h; ptr |∈| node_ptr_kinds h⟧ ⟹ get ptr h ≠ None› 2. ‹⋀ptr h. get ptr h ≠ None ⟹ ptr |∈| node_ptr_kinds h› discuss goal 1*) apply (simp add: get⇩N⇩o⇩d⇩e_type_wf (*‹NodeClass.type_wf ?h ⟹ (?node_ptr |∈| node_ptr_kinds ?h) = (get ?node_ptr ?h ≠ None)›*) local.type_wf⇩N⇩o⇩d⇩e (*‹type_wf ?h ⟹ NodeClass.type_wf ?h›*)) (*discuss goal 2*) apply (meson NodeMonad.get_M_is_l_get_M (*‹l_get_M get NodeClass.type_wf node_ptr_kinds›*) l_get_M_def (*‹l_get_M (?get::?'ptr::type ⇒ ?'heap::type ⇒ ?'obj::type option) (?type_wf::?'heap::type ⇒ bool) (?ptr_kinds::?'heap::type ⇒ ?'ptr::type fset) ≡ (∀(h::?'heap::type) ptr::?'ptr::type. ?type_wf h ⟶ ptr |∈| ?ptr_kinds h ⟶ ?get ptr h ≠ None) ∧ (∀(ptr::?'ptr::type) h::?'heap::type. ?get ptr h ≠ None ⟶ ptr |∈| ?ptr_kinds h)›*)) (*proven 2 subgoals*) . lemmas get_M⇩N⇩o⇩d⇩e_ok = get_M_ok[folded get_M⇩N⇩o⇩d⇩e_def] end global_interpretation l_get_M⇩N⇩o⇩d⇩e_lemmas type_wf by unfold_locales lemma node_ptr_kinds_M_reads: "reads (⋃object_ptr. {preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr RObject.nothing)}) node_ptr_kinds_M h h'" using object_ptr_kinds_M_reads (*‹reads (⋃object_ptr. {preserved (get_M object_ptr RObject.nothing)}) object_ptr_kinds_M ?h ?h'›*) apply (simp add: reads_def (*‹reads ?S ?getter ?h ?h' = ((∀P∈?S. reflp P ∧ transp P) ∧ ((∀P∈?S. P ?h ?h') ⟶ preserved ?getter ?h ?h'))›*) node_ptr_kinds_M_defs (*‹node_ptr_kinds_M = get_heap ⤜ (λh. return (sorted_list_of_set (fset (node_ptr_kinds h))))›*) node_ptr_kinds_def (*‹node_ptr_kinds ?heap = the |`| cast |`| ffilter is_node_ptr_kind (object_ptr_kinds ?heap)›*) object_ptr_kinds_M_reads (*‹reads (⋃object_ptr. {preserved (get_M object_ptr RObject.nothing)}) object_ptr_kinds_M ?h ?h'›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*)) (*goal: ‹reads (⋃object_ptr::(_) object_ptr. {preserved (get_M object_ptr RObject.nothing)}) node_ptr_kinds_M (h::(_) heap) (h'::(_) heap)›*) by (smt (verit) object_ptr_kinds_preserved_small (*‹(⋀object_ptr::(_) object_ptr. preserved (get_M object_ptr RObject.nothing) (?h::(_) heap) (?h'::(_) heap)) ⟹ object_ptr_kinds ?h = object_ptr_kinds ?h'›*) preserved_def (*‹preserved (?f::(?'heap::type, ?'e::type, ?'result::type) prog) (?h::?'heap::type) (?h'::?'heap::type) = (∀x::?'result::type. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) unit_all_impI (*‹((?P::unit ⇒ bool) () ⟹ (?Q::unit ⇒ bool) ()) ⟹ ∀x::unit. ?P x ⟶ ?Q x›*)) global_interpretation l_put_M type_wf node_ptr_kinds get⇩N⇩o⇩d⇩e put⇩N⇩o⇩d⇩e rewrites "a_get_M = get_M⇩N⇩o⇩d⇩e" defines put_M⇩N⇩o⇩d⇩e = a_put_M (*goals: 1. ‹l_put_M NodeClass.type_wf node_ptr_kinds get› 2. ‹l_get_M.a_get_M get = get_M› discuss goal 1*) apply (simp add: get_M_is_l_get_M (*‹l_get_M get NodeClass.type_wf node_ptr_kinds›*) l_put_M_def (*‹l_put_M ?type_wf ?ptr_kinds ?get ≡ l_get_M ?get ?type_wf ?ptr_kinds›*)) (*discuss goal 2*) apply (simp add: get_M⇩N⇩o⇩d⇩e_def (*‹get_M ≡ l_get_M.a_get_M get›*)) (*proven 2 subgoals*) . lemmas put_M_defs = a_put_M_def adhoc_overloading put_M put_M⇩N⇩o⇩d⇩e locale l_put_M⇩N⇩o⇩d⇩e_lemmas = l_type_wf⇩N⇩o⇩d⇩e begin sublocale l_put_M⇩O⇩b⇩j⇩e⇩c⇩t_lemmas by unfold_locales interpretation l_put_M type_wf node_ptr_kinds get⇩N⇩o⇩d⇩e put⇩N⇩o⇩d⇩e apply unfold_locales (*goals: 1. ‹⋀h ptr. ⟦type_wf h; ptr |∈| node_ptr_kinds h⟧ ⟹ get ptr h ≠ None› 2. ‹⋀ptr h. get ptr h ≠ None ⟹ ptr |∈| node_ptr_kinds h› discuss goal 1*) apply (simp add: get⇩N⇩o⇩d⇩e_type_wf (*‹NodeClass.type_wf (?h::(_) heap) ⟹ ((?node_ptr::(_) node_ptr) |∈| node_ptr_kinds ?h) = (get ?node_ptr ?h ≠ None)›*) local.type_wf⇩N⇩o⇩d⇩e (*‹(type_wf::(_) heap ⇒ bool) (?h::(_) heap) ⟹ NodeClass.type_wf ?h›*)) (*discuss goal 2*) apply (meson NodeMonad.get_M_is_l_get_M (*‹l_get_M get NodeClass.type_wf node_ptr_kinds›*) l_get_M_def (*‹l_get_M ?get ?type_wf ?ptr_kinds ≡ (∀h ptr. ?type_wf h ⟶ ptr |∈| ?ptr_kinds h ⟶ ?get ptr h ≠ None) ∧ (∀ptr h. ?get ptr h ≠ None ⟶ ptr |∈| ?ptr_kinds h)›*)) (*proven 2 subgoals*) . lemmas put_M⇩N⇩o⇩d⇩e_ok = put_M_ok[folded put_M⇩N⇩o⇩d⇩e_def] end global_interpretation l_put_M⇩N⇩o⇩d⇩e_lemmas type_wf by unfold_locales lemma get_M_Object_preserved1 [simp]: "(⋀x. getter (cast (setter (λ_. v) x)) = getter (cast x)) ⟹ h ⊢ put_M⇩N⇩o⇩d⇩e node_ptr setter v →⇩h h' ⟹ preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr getter) h h'" apply (cases "cast node_ptr = object_ptr") (*goals: 1. ‹⟦⋀x::'a RNode_scheme. (getter::(_) RObject_ext ⇒ 'b) (cast ((setter::('d ⇒ 'd) ⇒ 'a RNode_scheme ⇒ 'a RNode_scheme) (λ_::'d. v::'d) x)) = getter (cast x); (h::(_) heap) ⊢ put_M (node_ptr::(_) node_ptr) setter v →⇩h (h'::(_) heap); cast node_ptr = (object_ptr::(_) object_ptr)⟧ ⟹ preserved (get_M object_ptr getter) h h'› 2. ‹⟦⋀x::'a RNode_scheme. (getter::(_) RObject_ext ⇒ 'b) (cast ((setter::('d ⇒ 'd) ⇒ 'a RNode_scheme ⇒ 'a RNode_scheme) (λ_::'d. v::'d) x)) = getter (cast x); (h::(_) heap) ⊢ put_M (node_ptr::(_) node_ptr) setter v →⇩h (h'::(_) heap); cast node_ptr ≠ (object_ptr::(_) object_ptr)⟧ ⟹ preserved (get_M object_ptr getter) h h'› discuss goal 1*) apply ((auto simp add: put_M_defs (*‹put_M ?ptr ?setter ?v = get_M ?ptr id ⤜ (λobj. get_heap ⤜ (λh. return_heap (put ?ptr (?setter (λ_. ?v) obj) h)))›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) ObjectMonad.get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) get⇩N⇩o⇩d⇩e_def (*‹get ?node_ptr ?h = get (cast ?node_ptr) ?h ⤜ cast›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) put⇩N⇩o⇩d⇩e_def (*‹put ?node_ptr ?node = put (cast ?node_ptr) (cast ?node)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 2*) apply ((auto simp add: put_M_defs (*‹put_M ?ptr ?setter ?v = get_M ?ptr id ⤜ (λobj. get_heap ⤜ (λh. return_heap (put ?ptr (?setter (λ_. ?v) obj) h)))›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) ObjectMonad.get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) get⇩N⇩o⇩d⇩e_def (*‹get ?node_ptr ?h = get (cast ?node_ptr) ?h ⤜ cast›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) put⇩N⇩o⇩d⇩e_def (*‹put ?node_ptr ?node = put (cast ?node_ptr) (cast ?node)›*) bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*proven 2 subgoals*) . lemma get_M_Object_preserved2 [simp]: "cast node_ptr ≠ object_ptr ⟹ h ⊢ put_M⇩N⇩o⇩d⇩e node_ptr setter v →⇩h h' ⟹ preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr getter) h h'" by (auto simp add: put_M_defs (*‹put_M ?ptr ?setter ?v = get_M ?ptr id ⤜ (λobj. get_heap ⤜ (λh. return_heap (put ?ptr (?setter (λ_. ?v) obj) h)))›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) get⇩N⇩o⇩d⇩e_def (*‹get ?node_ptr ?h = get (cast ?node_ptr) ?h ⤜ cast›*) put⇩N⇩o⇩d⇩e_def (*‹put ?node_ptr ?node = put (cast ?node_ptr) (cast ?node)›*) ObjectMonad.get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) dest: get_heap_E (*‹?h ⊢ get_heap →⇩r ?x ⟹ ?x = ?h›*)) lemma get_M_Object_preserved3 [simp]: "h ⊢ put_M⇩N⇩o⇩d⇩e node_ptr setter v →⇩h h' ⟹ (⋀x. getter (cast (setter (λ_. v) x)) = getter (cast x)) ⟹ preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr getter) h h'" apply (cases "cast node_ptr ≠ object_ptr") (*goals: 1. ‹⟦(h::(_) heap) ⊢ put_M (node_ptr::(_) node_ptr) (setter::('e ⇒ 'e) ⇒ 'c RNode_scheme ⇒ 'c RNode_scheme) (v::'e) →⇩h (h'::(_) heap); ⋀x::'c RNode_scheme. (getter::(_) RObject_ext ⇒ 'f) (cast (setter (λ_::'e. v) x)) = getter (cast x); cast node_ptr ≠ (object_ptr::(_) object_ptr)⟧ ⟹ preserved (get_M object_ptr getter) h h'› 2. ‹⟦(h::(_) heap) ⊢ put_M (node_ptr::(_) node_ptr) (setter::('e ⇒ 'e) ⇒ 'c RNode_scheme ⇒ 'c RNode_scheme) (v::'e) →⇩h (h'::(_) heap); ⋀x::'c RNode_scheme. (getter::(_) RObject_ext ⇒ 'f) (cast (setter (λ_::'e. v) x)) = getter (cast x); ¬ cast node_ptr ≠ (object_ptr::(_) object_ptr)⟧ ⟹ preserved (get_M object_ptr getter) h h'› discuss goal 1*) apply ((auto simp add: put_M_defs (*‹put_M ?ptr ?setter ?v = get_M ?ptr id ⤜ (λobj. get_heap ⤜ (λh. return_heap (put ?ptr (?setter (λ_. ?v) obj) h)))›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) get⇩N⇩o⇩d⇩e_def (*‹get ?node_ptr ?h = get (cast ?node_ptr) ?h ⤜ cast›*) put⇩N⇩o⇩d⇩e_def (*‹put ?node_ptr ?node = put (cast ?node_ptr) (cast ?node)›*) ObjectMonad.get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) bind_splits (*‹?P (?m ⤜ ?f) = ((?m = None ⟶ ?P None) ∧ (∀v. ?m = Some v ⟶ ?P (?f v)))› ‹?P (?m ⤜ ?f) = (¬ (?m = None ∧ ¬ ?P None ∨ (∃x. ?m = Some x ∧ ¬ ?P (?f x))))›*) dest: get_heap_E (*‹?h ⊢ get_heap →⇩r ?x ⟹ ?x = ?h›*))[1]) (*discuss goal 2*) apply ((auto simp add: put_M_defs (*‹put_M ?ptr ?setter ?v = get_M ?ptr id ⤜ (λobj. get_heap ⤜ (λh. return_heap (put ?ptr (?setter (λ_. ?v) obj) h)))›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) get⇩N⇩o⇩d⇩e_def (*‹get ?node_ptr ?h = get (cast ?node_ptr) ?h ⤜ cast›*) put⇩N⇩o⇩d⇩e_def (*‹put ?node_ptr ?node = put (cast ?node_ptr) (cast ?node)›*) ObjectMonad.get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) bind_splits (*‹?P (?m ⤜ ?f) = ((?m = None ⟶ ?P None) ∧ (∀v. ?m = Some v ⟶ ?P (?f v)))› ‹?P (?m ⤜ ?f) = (¬ (?m = None ∧ ¬ ?P None ∨ (∃x. ?m = Some x ∧ ¬ ?P (?f x))))›*) dest: get_heap_E (*‹?h ⊢ get_heap →⇩r ?x ⟹ ?x = ?h›*))[1]) (*proven 2 subgoals*) . lemma get_M_Object_preserved4 [simp]: "cast node_ptr ≠ object_ptr ⟹ h ⊢ put_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr setter v →⇩h h' ⟹ preserved (get_M⇩N⇩o⇩d⇩e node_ptr getter) h h'" by (auto simp add: ObjectMonad.put_M_defs (*‹put_M (?ptr::(_) object_ptr) (?setter::(?'v ⇒ ?'v) ⇒ (_) Object ⇒ (_) Object) (?v::?'v) = get_M ?ptr id ⤜ (λobj::(_) Object. get_heap ⤜ (λh::(_) heap. return_heap (put ?ptr (?setter (λ_::?'v. ?v) obj) h)))›*) get_M_defs (*‹get_M ≡ λ(ptr::(_) node_ptr) getter::?'c RNode_scheme ⇒ ?'e. get_heap ⤜ (λh::(_) heap. case get ptr h of None ⇒ error SegmentationFault | Some (res::?'c RNode_scheme) ⇒ return (getter res))›*) get⇩N⇩o⇩d⇩e_def (*‹get (?node_ptr::(_) node_ptr) (?h::(_) heap) = get (cast ?node_ptr) ?h ⤜ cast›*) ObjectMonad.get_M_defs (*‹get_M ≡ λ(ptr::(_) object_ptr) getter::(_) Object ⇒ ?'c. get_heap ⤜ (λh::(_) heap. case get ptr h of None ⇒ error SegmentationFault | Some (res::(_) Object) ⇒ return (getter res))›*) preserved_def (*‹preserved (?f::(?'heap, ?'e, ?'result) prog) (?h::?'heap) (?h'::?'heap) = (∀x::?'result. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) dest: get_heap_E (*‹(?h::?'a) ⊢ get_heap →⇩r (?x::?'a) ⟹ ?x = ?h›*)) subsection‹Modified Heaps› lemma get_node_ptr_simp [simp]: "get⇩N⇩o⇩d⇩e node_ptr (put⇩O⇩b⇩j⇩e⇩c⇩t ptr obj h) = (if ptr = cast node_ptr then cast obj else get node_ptr h)" by (auto simp add: get⇩N⇩o⇩d⇩e_def (*‹get ?node_ptr ?h = get (cast ?node_ptr) ?h ⤜ cast›*)) lemma node_ptr_kinds_simp [simp]: "node_ptr_kinds (put⇩O⇩b⇩j⇩e⇩c⇩t ptr obj h) = node_ptr_kinds h |∪| (if is_node_ptr_kind ptr then {|the (cast ptr)|} else {||})" by (auto simp add: node_ptr_kinds_def (*‹node_ptr_kinds ?heap = the |`| cast |`| ffilter is_node_ptr_kind (object_ptr_kinds ?heap)›*)) lemma type_wf_put_I: assumes "type_wf h" assumes "ObjectClass.type_wf (put⇩O⇩b⇩j⇩e⇩c⇩t ptr obj h)" assumes "is_node_ptr_kind ptr ⟹ is_node_kind obj" shows "type_wf (put⇩O⇩b⇩j⇩e⇩c⇩t ptr obj h)" using assms (*‹NodeClass.type_wf h› ‹ObjectClass.type_wf (put ptr obj h)› ‹is_node_ptr_kind ptr ⟹ is_node_kind obj›*) apply ((auto simp add: type_wf_defs (*‹NodeClass.type_wf ?h = (ObjectClass.type_wf ?h ∧ (∀node_ptr|∈|node_ptr_kinds ?h. get node_ptr ?h ≠ None))›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*goal: ‹NodeClass.type_wf (put ptr obj h)›*) using "cast⇩O⇩b⇩j⇩e⇩c⇩t₂⇩N⇩o⇩d⇩e_none" (*‹(cast ?obj = None) = (∄node. cast node = ?obj)›*) is_node_kind_def (*‹is_node_kind ?ptr = (cast ?ptr ≠ None)›*) apply blast (*top goal: ‹⟦ObjectClass.type_wf (put ptr obj h); is_node_kind obj; ObjectClass.type_wf h; ∀node_ptr|∈|node_ptr_kinds h. ∃y. get node_ptr h = Some y; is_node_ptr_kind ptr⟧ ⟹ ∃y. cast y = obj› and 1 goal remains*) using "cast⇩O⇩b⇩j⇩e⇩c⇩t₂⇩N⇩o⇩d⇩e_none" (*‹(cast (?obj::(_) RObject_ext) = None) = (∄node::?'a RNode_scheme. cast node = ?obj)›*) is_node_kind_def (*‹is_node_kind ?ptr = (cast ?ptr ≠ None)›*) by blast lemma type_wf_put_ptr_not_in_heap_E: assumes "type_wf (put⇩O⇩b⇩j⇩e⇩c⇩t ptr obj h)" assumes "ptr |∉| object_ptr_kinds h" shows "type_wf h" using assms (*‹NodeClass.type_wf (put ptr obj h)› ‹ptr |∉| object_ptr_kinds h›*) by (auto simp add: type_wf_defs (*‹NodeClass.type_wf (?h::(_) heap) = (ObjectClass.type_wf ?h ∧ (∀node_ptr::(_) node_ptr|∈|node_ptr_kinds ?h. get node_ptr ?h ≠ None))›*) elim!: ObjectMonad.type_wf_put_ptr_not_in_heap_E (*‹⟦ObjectClass.type_wf (put (?ptr::(_) object_ptr) (?obj::(_) Object) (?h::(_) heap)); ?ptr |∉| object_ptr_kinds ?h⟧ ⟹ ObjectClass.type_wf ?h›*) split: option.splits (*‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a::type. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a::type. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) lemma type_wf_put_ptr_in_heap_E: assumes "type_wf (put⇩O⇩b⇩j⇩e⇩c⇩t ptr obj h)" assumes "ptr |∈| object_ptr_kinds h" assumes "ObjectClass.type_wf h" assumes "is_node_ptr_kind ptr ⟹ is_node_kind (the (get ptr h))" shows "type_wf h" using assms (*‹NodeClass.type_wf (put ptr obj h)› ‹ptr |∈| object_ptr_kinds h› ‹ObjectClass.type_wf h› ‹is_node_ptr_kind ptr ⟹ is_node_kind (the (get ptr h))›*) apply (auto simp add: type_wf_defs (*‹NodeClass.type_wf ?h = (ObjectClass.type_wf ?h ∧ (∀node_ptr|∈|node_ptr_kinds ?h. get node_ptr ?h ≠ None))›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goal: ‹NodeClass.type_wf h›*) by (metis ObjectClass.get⇩O⇩b⇩j⇩e⇩c⇩t_type_wf (*‹ObjectClass.type_wf (?h::(_) heap) ⟹ ((?object_ptr::(_) object_ptr) |∈| object_ptr_kinds ?h) = (get ?object_ptr ?h ≠ None)›*) bind.bind_lunit (*‹Some (?x::?'a::type) ⤜ (?f::?'a::type ⇒ ?'b::type option) = ?f ?x›*) get⇩N⇩o⇩d⇩e_def (*‹get (?node_ptr::(_) node_ptr) (?h::(_) heap) = get (cast ?node_ptr) ?h ⤜ cast›*) is_node_kind_def (*‹is_node_kind (?ptr::(_) RObject_ext) = (cast ?ptr ≠ None)›*) option.exhaust_sel (*‹⟦(?option::?'a::type option) = None ⟹ ?P::bool; ?option = Some (the ?option) ⟹ ?P⟧ ⟹ ?P›*)) subsection‹Preserving Types› lemma node_ptr_kinds_small: assumes "⋀object_ptr. preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr RObject.nothing) h h'" shows "node_ptr_kinds h = node_ptr_kinds h'" by (simp add: node_ptr_kinds_def (*‹node_ptr_kinds ?heap = the |`| cast |`| ffilter is_node_ptr_kind (object_ptr_kinds ?heap)›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) object_ptr_kinds_preserved_small[OF assms] (*‹object_ptr_kinds h = object_ptr_kinds h'›*)) lemma node_ptr_kinds_preserved: assumes "writes SW setter h h'" assumes "h ⊢ setter →⇩h h'" assumes "⋀h h'. ∀w ∈ SW. h ⊢ w →⇩h h' ⟶ (∀object_ptr. preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr RObject.nothing) h h')" shows "node_ptr_kinds h = node_ptr_kinds h'" using writes_small_big[OF assms] (*‹⟦reflp (λh h'. ∀w∈SW. ?h4 h h' ⊢ w →⇩h ?h'5 h h' ⟶ (∀object_ptr. preserved (get_M object_ptr RObject.nothing) (?h4 h h') (?h'5 h h'))); transp (λh h'. ∀w∈SW. ?h4 h h' ⊢ w →⇩h ?h'5 h h' ⟶ (∀object_ptr. preserved (get_M object_ptr RObject.nothing) (?h4 h h') (?h'5 h h')))⟧ ⟹ ∀w∈SW. ?h4 h h' ⊢ w →⇩h ?h'5 h h' ⟶ (∀object_ptr. preserved (get_M object_ptr RObject.nothing) (?h4 h h') (?h'5 h h'))›*) apply (simp add: reflp_def (*‹reflp ?R = (∀x. ?R x x)›*) transp_def (*‹transp ?R = (∀x y z. ?R x y ⟶ ?R y z ⟶ ?R x z)›*) preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) node_ptr_kinds_def (*‹node_ptr_kinds ?heap = the |`| cast |`| ffilter is_node_ptr_kind (object_ptr_kinds ?heap)›*)) (*goal: ‹node_ptr_kinds h = node_ptr_kinds h'›*) by (metis assms (*‹writes SW setter h h'› ‹h ⊢ setter →⇩h h'› ‹∀w∈SW. ?h ⊢ w →⇩h ?h' ⟶ (∀object_ptr. preserved (get_M object_ptr RObject.nothing) ?h ?h')›*) object_ptr_kinds_preserved (*‹⟦writes ?SW ?setter ?h ?h'; ?h ⊢ ?setter →⇩h ?h'; ⋀h h' w object_ptr. ⟦w ∈ ?SW; h ⊢ w →⇩h h'⟧ ⟹ preserved (get_M object_ptr RObject.nothing) h h'⟧ ⟹ object_ptr_kinds ?h = object_ptr_kinds ?h'›*)) lemma type_wf_preserved_small: assumes "⋀object_ptr. preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr RObject.nothing) h h'" assumes "⋀node_ptr. preserved (get_M⇩N⇩o⇩d⇩e node_ptr RNode.nothing) h h'" shows "type_wf h = type_wf h'" using type_wf_preserved (*‹ObjectClass.type_wf ?h = ObjectClass.type_wf ?h'›*) allI[OF assms ( 2 ), of id, simplified] (*‹∀x. preserved (get_M x RNode.nothing) h h'›*) apply ((auto simp add: type_wf_defs (*‹NodeClass.type_wf ?h = (ObjectClass.type_wf ?h ∧ (∀node_ptr|∈|node_ptr_kinds ?h. get node_ptr ?h ≠ None))›*))[1]) (*goals: 1. ‹⋀node_ptr. ⟦⋀h h'. ObjectClass.type_wf h = ObjectClass.type_wf h'; ∀x. preserved (get_M x RNode.nothing) h h'; ObjectClass.type_wf h; ∀node_ptr|∈|node_ptr_kinds h. ∃y. get node_ptr h = Some y; node_ptr |∈| node_ptr_kinds h'⟧ ⟹ ∃y. get node_ptr h' = Some y› 2. ‹⋀node_ptr. ⟦⋀h h'. ObjectClass.type_wf h = ObjectClass.type_wf h'; ∀x. preserved (get_M x RNode.nothing) h h'; ObjectClass.type_wf h'; ∀node_ptr|∈|node_ptr_kinds h'. ∃y. get node_ptr h' = Some y; node_ptr |∈| node_ptr_kinds h⟧ ⟹ ∃y. get node_ptr h = Some y› discuss goal 1*) apply ((auto simp add: preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) node_ptr_kinds_small[OF assms(1)] (*‹node_ptr_kinds h = node_ptr_kinds h'›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*top goal: ‹⋀node_ptr. ⟦⋀h h'. ObjectClass.type_wf h = ObjectClass.type_wf h'; ∀x. preserved (get_M x RNode.nothing) h h'; ObjectClass.type_wf h; ∀node_ptr|∈|node_ptr_kinds h. ∃y. get node_ptr h = Some y; node_ptr |∈| node_ptr_kinds h'⟧ ⟹ ∃y. get node_ptr h' = Some y› and 1 goal remains*) apply ((metis option.simps( (*‹Some ?x2.0 ≠ None›*) 3))[1]) (*discuss goal 2*) apply ((auto simp add: preserved_def (*‹preserved ?f ?h ?h' = (∀x. ?h ⊢ ?f →⇩r x = ?h' ⊢ ?f →⇩r x)›*) get_M_defs (*‹get_M ≡ λptr getter. get_heap ⤜ (λh. case get ptr h of None ⇒ error SegmentationFault | Some res ⇒ return (getter res))›*) node_ptr_kinds_small[OF assms(1)] (*‹node_ptr_kinds h = node_ptr_kinds h'›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*goal: ‹⋀node_ptr::(_) node_ptr. ⟦⋀(h::(_) heap) h'::(_) heap. ObjectClass.type_wf h = ObjectClass.type_wf h'; ∀x::(_) node_ptr. preserved (get_M x RNode.nothing) (h::(_) heap) (h'::(_) heap); ObjectClass.type_wf h'; ∀node_ptr::(_) node_ptr|∈|node_ptr_kinds h'. ∃y::'c RNode_scheme. get node_ptr h' = Some y; node_ptr |∈| node_ptr_kinds h⟧ ⟹ ∃y::'c RNode_scheme. get node_ptr h = Some y›*) apply ((force)[1]) (*proven 2 subgoals*) . lemma type_wf_preserved: assumes "writes SW setter h h'" assumes "h ⊢ setter →⇩h h'" assumes "⋀h h' w. w ∈ SW ⟹ h ⊢ w →⇩h h' ⟹ ∀object_ptr. preserved (get_M⇩O⇩b⇩j⇩e⇩c⇩t object_ptr RObject.nothing) h h'" assumes "⋀h h' w. w ∈ SW ⟹ h ⊢ w →⇩h h' ⟹ ∀node_ptr. preserved (get_M⇩N⇩o⇩d⇩e node_ptr RNode.nothing) h h'" shows "type_wf h = type_wf h'" proof (-) (*goal: ‹NodeClass.type_wf h = NodeClass.type_wf h'›*) have "⋀h h' w. w ∈ SW ⟹ h ⊢ w →⇩h h' ⟹ type_wf h = type_wf h'" using assms (*‹writes SW setter h h'› ‹h ⊢ setter →⇩h h'› ‹⟦?w ∈ SW; ?h ⊢ ?w →⇩h ?h'⟧ ⟹ ∀object_ptr. preserved (get_M object_ptr RObject.nothing) ?h ?h'› ‹⟦?w ∈ SW; ?h ⊢ ?w →⇩h ?h'⟧ ⟹ ∀node_ptr. preserved (get_M node_ptr RNode.nothing) ?h ?h'›*) type_wf_preserved_small (*‹⟦⋀object_ptr. preserved (get_M object_ptr RObject.nothing) ?h ?h'; ⋀node_ptr. preserved (get_M node_ptr RNode.nothing) ?h ?h'⟧ ⟹ NodeClass.type_wf ?h = NodeClass.type_wf ?h'›*) by fast with assms(1) (*‹writes SW setter h h'›*) assms(2) (*‹h ⊢ setter →⇩h h'›*) show "?thesis" (*goal: ‹NodeClass.type_wf h = NodeClass.type_wf h'›*) apply (rule writes_small_big (*‹⟦writes ?SW ?setter ?h ?h'; ?h ⊢ ?setter →⇩h ?h'; ⋀h h' w. ⟦w ∈ ?SW; h ⊢ w →⇩h h'⟧ ⟹ ?P h h'; reflp ?P; transp ?P⟧ ⟹ ?P ?h ?h'›*)) (*goals: 1. ‹⋀h h' w. ⟦w ∈ SW; h ⊢ w →⇩h h'⟧ ⟹ ?w1 h h' w ∈ SW› 2. ‹⋀h h' w. ⟦w ∈ SW; h ⊢ w →⇩h h'⟧ ⟹ h ⊢ ?w1 h h' w →⇩h h'› 3. ‹reflp (λh h'. NodeClass.type_wf h = NodeClass.type_wf h')› 4. ‹transp (λh h'. NodeClass.type_wf h = NodeClass.type_wf h')› discuss goal 1*) apply ((auto simp add: reflp_def (*‹reflp (?R::?'a ⇒ ?'a ⇒ bool) = (∀x::?'a. ?R x x)›*) transp_def (*‹transp (?R::?'a ⇒ ?'a ⇒ bool) = (∀(x::?'a) (y::?'a) z::?'a. ?R x y ⟶ ?R y z ⟶ ?R x z)›*))[1]) (*discuss goal 2*) apply ((auto simp add: reflp_def (*‹reflp ?R = (∀x. ?R x x)›*) transp_def (*‹transp ?R = (∀x y z. ?R x y ⟶ ?R y z ⟶ ?R x z)›*))[1]) (*discuss goal 3*) apply ((auto simp add: reflp_def (*‹reflp ?R = (∀x. ?R x x)›*) transp_def (*‹transp ?R = (∀x y z. ?R x y ⟶ ?R y z ⟶ ?R x z)›*))[1]) (*discuss goal 4*) apply ((auto simp add: reflp_def (*‹reflp (?R::?'a::type ⇒ ?'a::type ⇒ bool) = (∀x::?'a::type. ?R x x)›*) transp_def (*‹transp (?R::?'a::type ⇒ ?'a::type ⇒ bool) = (∀(x::?'a::type) (y::?'a::type) z::?'a::type. ?R x y ⟶ ?R y z ⟶ ?R x z)›*))[1]) (*proven 4 subgoals*) . qed end
{ "path": "afp-2025-02-12/thys/Core_SC_DOM/common/monads/NodeMonad.thy", "repo": "afp-2025-02-12", "sha": "4f7fa34843edd2b2940288738ea52113ae6d2c8ccb54443c49c37017a672008b" }
section "Quantitative Hoare Logic (due to Carbonneaux)" theory Quant_Hoare imports Big_StepT Complex_Main "HOL-Library.Extended_Nat" begin abbreviation "eq a b == (And (Not (Less a b)) (Not (Less b a)))" type_synonym lvname = string type_synonym assn = "state ⇒ bool" (* time bound *) type_synonym qassn = "state ⇒ enat" (* time bound *) text ‹The support of an assn2› abbreviation state_subst :: "state ⇒ aexp ⇒ vname ⇒ state" ("_[_'/_]" [1000,0,0] 999) where "s[a/x] == s(x := aval a s)" fun emb :: "bool ⇒ enat" ("↑") where "emb False = ∞" | "emb True = 0" subsection "Validity of quantitative Hoare Triple" (* this definition refines the definition of validity of normal Hoare Triple for total correctness *) definition hoare2_valid :: "qassn ⇒ com ⇒ qassn ⇒ bool" ("⊨₂ {(1_)}/ (_)/ {(1_)}" 50) where "⊨₂ {P} c {Q} ⟷ (∀s. P s < ∞ ⟶ (∃t p. ((c,s) ⇒ p ⇓ t) ∧ P s ≥ p + Q t))" subsection "Hoare logic for quantiative reasoning" inductive hoare2 :: "qassn ⇒ com ⇒ qassn ⇒ bool" ("⊢₂ ({(1_)}/ (_)/ {(1_)})" 50) where Skip: "⊢₂ {%s. eSuc (P s)} SKIP {P}" | Assign: "⊢₂ {λs. eSuc (P (s[a/x]))} x::=a { P }" | If: "⟦ ⊢₂ {λs. P s + ↑( bval b s)} c₁ { Q}; ⊢₂ {λs. P s + ↑(¬ bval b s)} c₂ { Q} ⟧ ⟹ ⊢₂ {λs. eSuc (P s)} IF b THEN c₁ ELSE c₂ { Q }" | Seq: "⟦ ⊢₂ { P₁ } c₁ { P₂ }; ⊢₂ {P₂} c₂ { P₃ }⟧ ⟹ ⊢₂ {P₁} c₁;;c₂ {P₃}" | While: "⟦ ⊢₂ { %s. I s + ↑(bval b s) } c { %t. I t + 1 } ⟧ ⟹ ⊢₂ {λs. I s + 1 } WHILE b DO c {λs. I s + ↑(¬ bval b s) }" | conseq: "⟦ ⊢₂ {P}c{Q} ; ⋀s. P s ≤ P' s ; ⋀s. Q' s ≤ Q s ⟧ ⟹ ⊢₂ {P'}c{ Q'}" text ‹derived rules› lemma strengthen_pre: "⟦ ∀s. P s ≤ P' s; ⊢₂ {P} c {Q} ⟧ ⟹ ⊢₂ {P'} c {Q}" using conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*) by blast lemma weaken_post: "⟦ ⊢₂ {P} c {Q}; ∀s. Q s ≥ Q' s ⟧ ⟹ ⊢₂ {P} c {Q'}" sorry lemma Assign': "∀s. P s ≥ eSuc ( Q(s[a/x])) ⟹ ⊢₂ {P} x ::= a {Q}" by (simp add: strengthen_pre[OF _ Assign] (*‹∀s. eSuc (?Q (s[?a1/?x1])) ≤ ?P' s ⟹ ⊢₂ {?P'} ?x1 ::= ?a1 {?Q}›*)) lemma progress: "(c, s) ⇒ p ⇓ t ⟹ p > 0" apply (induct rule: big_step_t.induct (*‹⟦?x1.0::com × (char list ⇒ int) ⇒ ?x2.0::nat ⇓ ?x3.0::char list ⇒ int; ⋀s::char list ⇒ int. (?P::com × (char list ⇒ int) ⇒ nat ⇒ (char list ⇒ int) ⇒ bool) (SKIP, s) (Suc (0::nat)) s; ⋀(x::char list) (a::aexp) s::char list ⇒ int. ?P (x ::= a, s) (Suc (0::nat)) (s[a/x]); ⋀(c1::com) (s1::char list ⇒ int) (x::nat) (s2::char list ⇒ int) (c2::com) (y::nat) (s3::char list ⇒ int) z::nat. ⟦(c1, s1) ⇒ x ⇓ s2; ?P (c1, s1) x s2; (c2, s2) ⇒ y ⇓ s3; ?P (c2, s2) y s3; z = x + y⟧ ⟹ ?P (c1;; c2, s1) z s3; ⋀(b::bexp) (s::char list ⇒ int) (c1::com) (x::nat) (t::char list ⇒ int) (y::nat) c2::com. ⟦bval b s; (c1, s) ⇒ x ⇓ t; ?P (c1, s) x t; y = x + (1::nat)⟧ ⟹ ?P (IF b THEN c1 ELSE c2, s) y t; ⋀(b::bexp) (s::char list ⇒ int) (c2::com) (x::nat) (t::char list ⇒ int) (y::nat) c1::com. ⟦¬ bval b s; (c2, s) ⇒ x ⇓ t; ?P (c2, s) x t; y = x + (1::nat)⟧ ⟹ ?P (IF b THEN c1 ELSE c2, s) y t; ⋀(b::bexp) (s::char list ⇒ int) c::com. ¬ bval b s ⟹ ?P (WHILE b DO c, s) (Suc (0::nat)) s; ⋀(b::bexp) (s1::char list ⇒ int) (c::com) (x::nat) (s2::char list ⇒ int) (y::nat) (s3::char list ⇒ int) z::nat. ⟦bval b s1; (c, s1) ⇒ x ⇓ s2; ?P (c, s1) x s2; (WHILE b DO c, s2) ⇒ y ⇓ s3; ?P (WHILE b DO c, s2) y s3; (1::nat) + x + y = z⟧ ⟹ ?P (WHILE b DO c, s1) z s3⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀s. 0 < Suc 0› 2. ‹⋀x a s. 0 < Suc 0› 3. ‹⋀c1 s1 x s2 c2 y s3 z. ⟦(c1, s1) ⇒ x ⇓ s2; 0 < x; (c2, s2) ⇒ y ⇓ s3; 0 < y; z = x + y⟧ ⟹ 0 < z› 4. ‹⋀b s c1 x t y c2. ⟦bval b s; (c1, s) ⇒ x ⇓ t; 0 < x; y = x + 1⟧ ⟹ 0 < y› 5. ‹⋀b s c2 x t y c1. ⟦¬ bval b s; (c2, s) ⇒ x ⇓ t; 0 < x; y = x + 1⟧ ⟹ 0 < y› 6. ‹⋀b s c. ¬ bval b s ⟹ 0 < Suc 0› 7. ‹⋀b s1 c x s2 y s3 z. ⟦bval b s1; (c, s1) ⇒ x ⇓ s2; 0 < x; (WHILE b DO c, s2) ⇒ y ⇓ s3; 0 < y; 1 + x + y = z⟧ ⟹ 0 < z› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . lemma FalseImplies: "⊢₂ {%s. ∞} c { Q}" apply (induction c arbitrary: Q) (*goal: ‹⊢₂ {λs. ∞} c {Q}›*) apply (auto intro: hoare2.Skip (*‹⊢₂ {λs. eSuc (?P s)} SKIP {?P}›*) hoare2.Assign (*‹⊢₂ {λs. eSuc (?P (s[?a/?x]))} ?x ::= ?a {?P}›*) hoare2.Seq (*‹⟦⊢₂ {?P₁} ?c₁ {?P₂}; ⊢₂ {?P₂} ?c₂ {?P₃}⟧ ⟹ ⊢₂ {?P₁} ?c₁;; ?c₂ {?P₃}›*) hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*top goal: ‹⋀x. ⊢₂ {λs. ∞} SKIP {x}› and 4 goals remain*) subgoal for apply (rule hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goals: 1. ‹⟦⋀x. ⊢₂ {λs. ∞} c1_ {x}; ⋀x. ⊢₂ {λs. ∞} c2_ {x}⟧ ⟹ ⊢₂ {?P} IF x1_ THEN c1_ ELSE c2_ {?Q}› 2. ‹⋀s. ⟦⋀x. ⊢₂ {λs. ∞} c1_ {x}; ⋀x. ⊢₂ {λs. ∞} c2_ {x}⟧ ⟹ ?P s ≤ ∞› 3. ‹⋀s. ⟦⋀x. ⊢₂ {λs. ∞} c1_ {x}; ⋀x. ⊢₂ {λs. ∞} c2_ {x}⟧ ⟹ x_ s ≤ ?Q s› discuss goal 1*) apply (rule hoare2.If[where P="%s. ∞"] (*‹⟦⊢₂ {λs. ∞ + ↑ (bval ?b s)} ?c₁ {?Q}; ⊢₂ {λs. ∞ + ↑ (¬ bval ?b s)} ?c₂ {?Q}⟧ ⟹ ⊢₂ {λs. eSuc ∞} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*)) (*goals: 1. ‹⟦⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c1_::com {x}; ⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c2_::com {x}⟧ ⟹ ⊢₂ {λs::char list ⇒ int. ∞ + ↑ (bval (x1_::bexp) s)} c1_ {?Q::(char list ⇒ int) ⇒ enat}› 2. ‹⟦⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c1_::com {x}; ⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c2_::com {x}⟧ ⟹ ⊢₂ {λs::char list ⇒ int. ∞ + ↑ (¬ bval (x1_::bexp) s)} c2_ {?Q::(char list ⇒ int) ⇒ enat}› discuss goal 1*) apply ((auto intro: hoare2.If (*‹⟦⊢₂ {λs. ?P s + ↑ (bval ?b s)} ?c₁ {?Q}; ⊢₂ {λs. ?P s + ↑ (¬ bval ?b s)} ?c₂ {?Q}⟧ ⟹ ⊢₂ {λs. eSuc (?P s)} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*) hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*))[1]) (*discuss goal 2*) apply ((auto intro: hoare2.If (*‹⟦⊢₂ {λs. ?P s + ↑ (bval ?b s)} ?c₁ {?Q}; ⊢₂ {λs. ?P s + ↑ (¬ bval ?b s)} ?c₂ {?Q}⟧ ⟹ ⊢₂ {λs. eSuc (?P s)} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*) hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*))[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto intro: hoare2.If (*‹⟦⊢₂ {λs. ?P s + ↑ (bval ?b s)} ?c₁ {?Q}; ⊢₂ {λs. ?P s + ↑ (¬ bval ?b s)} ?c₂ {?Q}⟧ ⟹ ⊢₂ {λs. eSuc (?P s)} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*) hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*))[1]) (*discuss goal 3*) apply ((auto intro: hoare2.If (*‹⟦⊢₂ {λs. ?P s + ↑ (bval ?b s)} ?c₁ {?Q}; ⊢₂ {λs. ?P s + ↑ (¬ bval ?b s)} ?c₂ {?Q}⟧ ⟹ ⊢₂ {λs. eSuc (?P s)} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*) hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*))[1]) (*proven 3 subgoals*) . subgoal for apply (rule hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goals: 1. ‹(⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c_::com {x}) ⟹ ⊢₂ {?P::(char list ⇒ int) ⇒ enat} WHILE x1_::bexp DO c_ {?Q::(char list ⇒ int) ⇒ enat}› 2. ‹⋀s::char list ⇒ int. (⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c_::com {x}) ⟹ (?P::(char list ⇒ int) ⇒ enat) s ≤ ∞› 3. ‹⋀s::char list ⇒ int. (⋀x::(char list ⇒ int) ⇒ enat. ⊢₂ {λs::char list ⇒ int. ∞} c_::com {x}) ⟹ (x_::(char list ⇒ int) ⇒ enat) s ≤ (?Q::(char list ⇒ int) ⇒ enat) s› discuss goal 1*) apply (rule hoare2.While[where I="%s. ∞"] (*‹⊢₂ {λs. ∞ + ↑ (bval ?b s)} ?c {λt. ∞ + 1} ⟹ ⊢₂ {λs. ∞ + 1} WHILE ?b DO ?c {λs. ∞ + ↑ (¬ bval ?b s)}›*)) (*top goal: ‹(⋀x. ⊢₂ {λs. ∞} c_ {x}) ⟹ ⊢₂ {?P} WHILE x1_ DO c_ {?Q}› and 2 goals remain*) apply (rule hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goals: 1. ‹(⋀x. ⊢₂ {λs. ∞} c_ {x}) ⟹ ⊢₂ {?P6} c_ {?Q6}› 2. ‹⋀s. (⋀x. ⊢₂ {λs. ∞} c_ {x}) ⟹ ?P6 s ≤ ∞ + ↑ (bval x1_ s)› 3. ‹⋀s. (⋀x. ⊢₂ {λs. ∞} c_ {x}) ⟹ ∞ + 1 ≤ ?Q6 s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . . subsection "Soundness" text‹The soundness theorem:› lemma help1: assumes " enat a + X ≤ Y" "enat b + Z ≤ X" shows "enat (a + b) + Z ≤ Y" using assms (*‹enat a + X ≤ Y› ‹enat b + Z ≤ X›*) by (metis ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) plus_enat_simps( (*‹enat ?m + enat ?n = enat (?m + ?n)›*) 1)) lemma help2': assumes "enat p + INV t ≤ INV s" "0 < p" "INV s = enat n" shows "INV t < INV s" using assms (*‹enat p + INV t ≤ INV s› ‹0 < p› ‹INV s = enat n›*) iadd_le_enat_iff (*‹(?x + ?y ≤ enat ?n) = (∃y' x'. ?x = enat x' ∧ ?y = enat y' ∧ x' + y' ≤ ?n)›*) by auto lemma help2: assumes "enat p + INV t + 1 ≤ INV s" "INV s = enat n" shows "INV t < INV s" using assms (*‹enat p + INV t + 1 ≤ INV s› ‹INV s = enat n›*) le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) not_less_iff_gr_or_eq (*‹(¬ (?x::?'a) < (?y::?'a)) = (?y < ?x ∨ ?x = ?y)›*) by fastforce lemma Seq_sound: assumes "⊨₂ {P1} C1 {P2}" "⊨₂ {P2} C2 {P3}" shows "⊨₂ {P1} C1 ;; C2 {P3}" unfolding hoare2_valid_def (*goal: ‹∀s. P1 s < ∞ ⟶ (∃t p. (C1;; C2, s) ⇒ p ⇓ t ∧ enat p + P3 t ≤ P1 s)›*) proof (safe) (*goal: ‹⋀s::char list ⇒ int. (P1::(char list ⇒ int) ⇒ enat) s < ∞ ⟹ ∃(t::char list ⇒ int) p::nat. ((C1::com);; (C2::com), s) ⇒ p ⇓ t ∧ enat p + (P3::(char list ⇒ int) ⇒ enat) t ≤ P1 s›*) fix s assume ninfP1: "P1 s < ∞" (*‹(P1::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) < ∞›*) with assms(1)[unfolded hoare2_valid_def] (*‹∀s. P1 s < ∞ ⟶ (∃t p. (C1, s) ⇒ p ⇓ t ∧ enat p + P2 t ≤ P1 s)›*) obtain t1 and p1 where 1: "(C1, s) ⇒ p1 ⇓ t1" and q1: "enat p1 + P2 t1 ≤ P1 s" (*goal: ‹(⋀(p1::nat) t1::char list ⇒ int. ⟦(C1::com, s::char list ⇒ int) ⇒ p1 ⇓ t1; enat p1 + (P2::(char list ⇒ int) ⇒ enat) t1 ≤ (P1::(char list ⇒ int) ⇒ enat) s⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast with ninfP1 (*‹P1 s < ∞›*) have ninfP2: "P2 t1 < ∞" using not_le (*‹(¬ (?x::?'a) ≤ (?y::?'a)) = (?y < ?x)›*) by fastforce with assms(2)[unfolded hoare2_valid_def] (*‹∀s. P2 s < ∞ ⟶ (∃t p. (C2, s) ⇒ p ⇓ t ∧ enat p + P3 t ≤ P2 s)›*) obtain t2 and p2 where 2: "(C2, t1) ⇒ p2 ⇓ t2" and q2: "enat p2 + P3 t2 ≤ P2 t1" (*goal: ‹(⋀p2 t2. ⟦(C2, t1) ⇒ p2 ⇓ t2; enat p2 + P3 t2 ≤ P2 t1⟧ ⟹ thesis) ⟹ thesis›*) by blast with ninfP2 (*‹P2 t1 < ∞›*) have ninfP3: "P3 t2 < ∞" using not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) by fastforce from Big_StepT.Seq[OF 1 2] (*‹?z = p1 + p2 ⟹ (C1;; C2, s) ⇒ ?z ⇓ t2›*) have bigstep: "(C1;; C2, s) ⇒ p1 + p2 ⇓ t2" by simp from help1[OF q1 q2] (*‹enat (p1 + p2) + P3 t2 ≤ P1 s›*) have potential: "enat (p1 + p2) + P3 t2 ≤ P1 s" . show "∃t p. (C1;; C2, s) ⇒ p ⇓ t ∧ enat p + P3 t ≤ P1 s " apply (rule exI[where x="t2"] (*‹?P t2 ⟹ ∃x. ?P x›*)) (*goal: ‹∃t p. (C1;; C2, s) ⇒ p ⇓ t ∧ enat p + P3 t ≤ P1 s›*) apply (rule exI[where x="p1 + p2"] (*‹?P (p1 + p2) ⟹ ∃x. ?P x›*)) (*goal: ‹∃p. (C1;; C2, s) ⇒ p ⇓ t2 ∧ enat p + P3 t2 ≤ P1 s›*) using bigstep (*‹(C1;; C2, s) ⇒ p1 + p2 ⇓ t2›*) potential (*‹enat (p1 + p2) + P3 t2 ≤ P1 s›*) by simp qed theorem hoare2_sound: "⊢₂ {P}c{ Q} ⟹ ⊨₂ {P}c{ Q}" proof (induction rule: hoare2.induct (*‹⟦⊢₂ {?x1.0::(char list ⇒ int) ⇒ enat} ?x2.0::com {?x3.0::(char list ⇒ int) ⇒ enat}; ⋀P::(char list ⇒ int) ⇒ enat. (?P::((char list ⇒ int) ⇒ enat) ⇒ com ⇒ ((char list ⇒ int) ⇒ enat) ⇒ bool) (λs::char list ⇒ int. eSuc (P s)) SKIP P; ⋀(P::(char list ⇒ int) ⇒ enat) (a::aexp) x::char list. ?P (λs::char list ⇒ int. eSuc (P (s[a/x]))) (x ::= a) P; ⋀(P::(char list ⇒ int) ⇒ enat) (b::bexp) (c₁::com) (Q::(char list ⇒ int) ⇒ enat) c₂::com. ⟦⊢₂ {λs::char list ⇒ int. P s + ↑ (bval b s)} c₁ {Q}; ?P (λs::char list ⇒ int. P s + ↑ (bval b s)) c₁ Q; ⊢₂ {λs::char list ⇒ int. P s + ↑ (¬ bval b s)} c₂ {Q}; ?P (λs::char list ⇒ int. P s + ↑ (¬ bval b s)) c₂ Q⟧ ⟹ ?P (λs::char list ⇒ int. eSuc (P s)) (IF b THEN c₁ ELSE c₂) Q; ⋀(P₁::(char list ⇒ int) ⇒ enat) (c₁::com) (P₂::(char list ⇒ int) ⇒ enat) (c₂::com) P₃::(char list ⇒ int) ⇒ enat. ⟦⊢₂ {P₁} c₁ {P₂}; ?P P₁ c₁ P₂; ⊢₂ {P₂} c₂ {P₃}; ?P P₂ c₂ P₃⟧ ⟹ ?P P₁ (c₁;; c₂) P₃; ⋀(I::(char list ⇒ int) ⇒ enat) (b::bexp) c::com. ⟦⊢₂ {λs::char list ⇒ int. I s + ↑ (bval b s)} c {λt::char list ⇒ int. I t + (1::enat)}; ?P (λs::char list ⇒ int. I s + ↑ (bval b s)) c (λt::char list ⇒ int. I t + (1::enat))⟧ ⟹ ?P (λs::char list ⇒ int. I s + (1::enat)) (WHILE b DO c) (λs::char list ⇒ int. I s + ↑ (¬ bval b s)); ⋀(P::(char list ⇒ int) ⇒ enat) (c::com) (Q::(char list ⇒ int) ⇒ enat) (P'::(char list ⇒ int) ⇒ enat) Q'::(char list ⇒ int) ⇒ enat. ⟦⊢₂ {P} c {Q}; ?P P c Q; ⋀s::char list ⇒ int. P s ≤ P' s; ⋀s::char list ⇒ int. Q' s ≤ Q s⟧ ⟹ ?P P' c Q'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀P. ⊨₂ {λa. eSuc (P a)} SKIP {P}› 2. ‹⋀P a x. ⊨₂ {λb. eSuc (P (b[a/x]))} x ::= a {P}› 3. ‹⋀P b c₁ Q c₂. ⟦⊢₂ {λs. P s + ↑ (bval b s)} c₁ {Q}; ⊨₂ {λa. P a + ↑ (bval b a)} c₁ {Q}; ⊢₂ {λs. P s + ↑ (¬ bval b s)} c₂ {Q}; ⊨₂ {λa. P a + ↑ (¬ bval b a)} c₂ {Q}⟧ ⟹ ⊨₂ {λa. eSuc (P a)} IF b THEN c₁ ELSE c₂ {Q}› 4. ‹⋀P₁ c₁ P₂ c₂ P₃. ⟦⊢₂ {P₁} c₁ {P₂}; ⊨₂ {P₁} c₁ {P₂}; ⊢₂ {P₂} c₂ {P₃}; ⊨₂ {P₂} c₂ {P₃}⟧ ⟹ ⊨₂ {P₁} c₁;; c₂ {P₃}› 5. ‹⋀I b c. ⟦⊢₂ {λs. I s + ↑ (bval b s)} c {λt. I t + 1}; ⊨₂ {λa. I a + ↑ (bval b a)} c {λa. I a + 1}⟧ ⟹ ⊨₂ {λa. I a + 1} WHILE b DO c {λa. I a + ↑ (¬ bval b a)}› 6. ‹⋀P c Q P' Q'. ⟦⊢₂ {P} c {Q}; ⊨₂ {P} c {Q}; ⋀s. P s ≤ P' s; ⋀s. Q' s ≤ Q s⟧ ⟹ ⊨₂ {P'} c {Q'}›*) case (Skip P) (*no hyothesis introduced yet*) show "?case" (*goal: ‹⊨₂ {λa. eSuc (P a)} SKIP {P}›*) unfolding hoare2_valid_def (*goal: ‹∀s::char list ⇒ int. eSuc ((P::(char list ⇒ int) ⇒ enat) s) < ∞ ⟶ (∃(t::char list ⇒ int) p::nat. (SKIP, s) ⇒ p ⇓ t ∧ enat p + P t ≤ eSuc (P s))›*) apply safe (*goal: ‹∀s. eSuc (P s) < ∞ ⟶ (∃t p. (SKIP, s) ⇒ p ⇓ t ∧ enat p + P t ≤ eSuc (P s))›*) subgoal for s apply (rule exI[where x=s] (*‹?P s ⟹ ∃x. ?P x›*)) (*goal: ‹eSuc (P s) < ∞ ⟹ ∃t p. (SKIP, s) ⇒ p ⇓ t ∧ enat p + P t ≤ eSuc (P s)›*) apply (rule exI[where x="Suc 0"] (*‹?P (Suc 0) ⟹ ∃x. ?P x›*)) (*goal: ‹eSuc (P s) < ∞ ⟹ ∃p. (SKIP, s) ⇒ p ⇓ s ∧ enat p + P s ≤ eSuc (P s)›*) by (auto simp: eSuc_enat_iff (*‹(eSuc ?x = enat ?y) = (∃n. ?y = Suc n ∧ ?x = enat n)›*) eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*)) . next (*goals: 1. ‹⋀P a x. ⊨₂ {λb. eSuc (P (b[a/x]))} x ::= a {P}› 2. ‹⋀P b c₁ Q c₂. ⟦⊢₂ {λs. P s + ↑ (bval b s)} c₁ {Q}; ⊨₂ {λa. P a + ↑ (bval b a)} c₁ {Q}; ⊢₂ {λs. P s + ↑ (¬ bval b s)} c₂ {Q}; ⊨₂ {λa. P a + ↑ (¬ bval b a)} c₂ {Q}⟧ ⟹ ⊨₂ {λa. eSuc (P a)} IF b THEN c₁ ELSE c₂ {Q}› 3. ‹⋀P₁ c₁ P₂ c₂ P₃. ⟦⊢₂ {P₁} c₁ {P₂}; ⊨₂ {P₁} c₁ {P₂}; ⊢₂ {P₂} c₂ {P₃}; ⊨₂ {P₂} c₂ {P₃}⟧ ⟹ ⊨₂ {P₁} c₁;; c₂ {P₃}› 4. ‹⋀I b c. ⟦⊢₂ {λs. I s + ↑ (bval b s)} c {λt. I t + 1}; ⊨₂ {λa. I a + ↑ (bval b a)} c {λa. I a + 1}⟧ ⟹ ⊨₂ {λa. I a + 1} WHILE b DO c {λa. I a + ↑ (¬ bval b a)}› 5. ‹⋀P c Q P' Q'. ⟦⊢₂ {P} c {Q}; ⊨₂ {P} c {Q}; ⋀s. P s ≤ P' s; ⋀s. Q' s ≤ Q s⟧ ⟹ ⊨₂ {P'} c {Q'}›*) case (Assign P a x) (*no hyothesis introduced yet*) show "?case" (*goal: ‹⊨₂ {λb. eSuc (P (b[a/x]))} x ::= a {P}›*) unfolding hoare2_valid_def (*goal: ‹∀s. eSuc (P (s[a/x])) < ∞ ⟶ (∃t p. (x ::= a, s) ⇒ p ⇓ t ∧ enat p + P t ≤ eSuc (P (s[a/x])))›*) apply safe (*goal: ‹∀s. eSuc (P (s[a/x])) < ∞ ⟶ (∃t p. (x ::= a, s) ⇒ p ⇓ t ∧ enat p + P t ≤ eSuc (P (s[a/x])))›*) subgoal for s apply (rule exI[where x="s[a/x]"] (*‹(?P::(char list ⇒ int) ⇒ bool) ((s::char list ⇒ int)[a::aexp/x::char list]) ⟹ ∃x::char list ⇒ int. ?P x›*)) (*goal: ‹eSuc ((P::(char list ⇒ int) ⇒ enat) ((s::char list ⇒ int)[a::aexp/x::char list])) < ∞ ⟹ ∃(t::char list ⇒ int) p::nat. (x ::= a, s) ⇒ p ⇓ t ∧ enat p + P t ≤ eSuc (P (s[a/x]))›*) apply (rule exI[where x="Suc 0"] (*‹?P (Suc 0) ⟹ ∃x. ?P x›*)) (*goal: ‹eSuc (P (s[a/x])) < ∞ ⟹ ∃p. (x ::= a, s) ⇒ p ⇓ s[a/x] ∧ enat p + P (s[a/x]) ≤ eSuc (P (s[a/x]))›*) by (auto simp: eSuc_enat_iff (*‹(eSuc ?x = enat ?y) = (∃n. ?y = Suc n ∧ ?x = enat n)›*) eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*)) . next (*goals: 1. ‹⋀P b c₁ Q c₂. ⟦⊢₂ {λs. P s + ↑ (bval b s)} c₁ {Q}; ⊨₂ {λa. P a + ↑ (bval b a)} c₁ {Q}; ⊢₂ {λs. P s + ↑ (¬ bval b s)} c₂ {Q}; ⊨₂ {λa. P a + ↑ (¬ bval b a)} c₂ {Q}⟧ ⟹ ⊨₂ {λa. eSuc (P a)} IF b THEN c₁ ELSE c₂ {Q}› 2. ‹⋀P₁ c₁ P₂ c₂ P₃. ⟦⊢₂ {P₁} c₁ {P₂}; ⊨₂ {P₁} c₁ {P₂}; ⊢₂ {P₂} c₂ {P₃}; ⊨₂ {P₂} c₂ {P₃}⟧ ⟹ ⊨₂ {P₁} c₁;; c₂ {P₃}› 3. ‹⋀I b c. ⟦⊢₂ {λs. I s + ↑ (bval b s)} c {λt. I t + 1}; ⊨₂ {λa. I a + ↑ (bval b a)} c {λa. I a + 1}⟧ ⟹ ⊨₂ {λa. I a + 1} WHILE b DO c {λa. I a + ↑ (¬ bval b a)}› 4. ‹⋀P c Q P' Q'. ⟦⊢₂ {P} c {Q}; ⊨₂ {P} c {Q}; ⋀s. P s ≤ P' s; ⋀s. Q' s ≤ Q s⟧ ⟹ ⊨₂ {P'} c {Q'}›*) case (Seq P1 C1 P2 C2 P3) (*‹⊢₂ {P1} C1 {P2}› ‹⊢₂ {P2} C2 {P3}› ‹⊨₂ {P1} C1 {P2}› ‹⊨₂ {P2} C2 {P3}›*) thus "?case" (*goal: ‹⊨₂ {P1::(char list ⇒ int) ⇒ enat} (C1::com);; (C2::com) {P3::(char list ⇒ int) ⇒ enat}›*) using Seq_sound (*‹⟦⊨₂ {?P1.0} ?C1.0 {?P2.0}; ⊨₂ {?P2.0} ?C2.0 {?P3.0}⟧ ⟹ ⊨₂ {?P1.0} ?C1.0;; ?C2.0 {?P3.0}›*) by auto next (*goals: 1. ‹⋀P b c₁ Q c₂. ⟦⊢₂ {λs. P s + ↑ (bval b s)} c₁ {Q}; ⊨₂ {λa. P a + ↑ (bval b a)} c₁ {Q}; ⊢₂ {λs. P s + ↑ (¬ bval b s)} c₂ {Q}; ⊨₂ {λa. P a + ↑ (¬ bval b a)} c₂ {Q}⟧ ⟹ ⊨₂ {λa. eSuc (P a)} IF b THEN c₁ ELSE c₂ {Q}› 2. ‹⋀I b c. ⟦⊢₂ {λs. I s + ↑ (bval b s)} c {λt. I t + 1}; ⊨₂ {λa. I a + ↑ (bval b a)} c {λa. I a + 1}⟧ ⟹ ⊨₂ {λa. I a + 1} WHILE b DO c {λa. I a + ↑ (¬ bval b a)}› 3. ‹⋀P c Q P' Q'. ⟦⊢₂ {P} c {Q}; ⊨₂ {P} c {Q}; ⋀s. P s ≤ P' s; ⋀s. Q' s ≤ Q s⟧ ⟹ ⊨₂ {P'} c {Q'}›*) case (If P b c1 Q c2) (*‹⊢₂ {λs. P s + ↑ (bval b s)} c1 {Q}› ‹⊢₂ {λs. P s + ↑ (¬ bval b s)} c2 {Q}› ‹⊨₂ {λa. P a + ↑ (bval b a)} c1 {Q}› ‹⊨₂ {λa. P a + ↑ (¬ bval b a)} c2 {Q}›*) show "?case" (*goal: ‹⊨₂ {λa. eSuc (P a)} IF b THEN c1 ELSE c2 {Q}›*) unfolding hoare2_valid_def (*goal: ‹∀s. eSuc (P s) < ∞ ⟶ (∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s))›*) proof (safe) (*goal: ‹⋀s::char list ⇒ int. eSuc ((P::(char list ⇒ int) ⇒ enat) s) < ∞ ⟹ ∃(t::char list ⇒ int) p::nat. (IF b::bexp THEN c1::com ELSE (c2::com), s) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ eSuc (P s)›*) fix s assume "eSuc (P s) < ∞" (*‹eSuc ((P::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int)) < ∞›*) then have i: "P s < ∞" using enat_ord_simps(4) (*‹(?q < ∞) = (?q ≠ ∞)›*) by fastforce show "∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)" proof (cases "bval b s") (*goals: 1. ‹bval b s ⟹ ∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)› 2. ‹¬ bval b s ⟹ ∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)›*) case True (*‹bval (b::bexp) (s::char list ⇒ int)›*) with i (*‹P s < ∞›*) have "P s + emb (bval b s) < ∞" by simp with If(3)[unfolded hoare2_valid_def] (*‹∀s. P s + ↑ (bval b s) < ∞ ⟶ (∃t p. (c1, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ P s + ↑ (bval b s))›*) obtain p and t where 1: "(c1, s) ⇒ p ⇓ t" and q: "enat p + Q t ≤ P s + emb (bval b s)" (*goal: ‹(⋀p t. ⟦(c1, s) ⇒ p ⇓ t; enat p + Q t ≤ P s + ↑ (bval b s)⟧ ⟹ thesis) ⟹ thesis›*) by blast from Big_StepT.IfTrue[OF True 1] (*‹(?y::nat) = (p::nat) + (1::nat) ⟹ (IF b::bexp THEN c1::com ELSE (?c2.0::com), s::char list ⇒ int) ⇒ ?y ⇓ t::char list ⇒ int›*) have 2: "(IF b THEN c1 ELSE c2, s) ⇒ p + 1 ⇓ t" by simp show "?thesis" (*goal: ‹∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)›*) apply (rule exI[where x=t] (*‹?P t ⟹ ∃x. ?P x›*)) (*goal: ‹∃(t::char list ⇒ int) p::nat. (IF b::bexp THEN c1::com ELSE (c2::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ eSuc ((P::(char list ⇒ int) ⇒ enat) s)›*) apply (rule exI[where x="p+1"] (*‹?P (p + 1) ⟹ ∃x. ?P x›*)) (*goal: ‹∃p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)›*) apply safe (*goal: ‹(IF b::bexp THEN c1::com ELSE (c2::com), s::char list ⇒ int) ⇒ (p::nat) + (1::nat) ⇓ t::char list ⇒ int ∧ enat (p + (1::nat)) + (Q::(char list ⇒ int) ⇒ enat) t ≤ eSuc ((P::(char list ⇒ int) ⇒ enat) s)›*) apply fact (*top goal: ‹(IF b THEN c1 ELSE c2, s) ⇒ p + 1 ⇓ t› and 1 goal remains*) using q (*‹enat p + Q t ≤ P s + ↑ (bval b s)›*) True (*‹bval b s›*) apply simp (*goal: ‹enat (p + 1) + Q t ≤ eSuc (P s)›*) by (metis eSuc_enat (*‹eSuc (enat (?n::nat)) = enat (Suc ?n)›*) eSuc_ile_mono (*‹(eSuc (?n::enat) ≤ eSuc (?m::enat)) = (?n ≤ ?m)›*) iadd_Suc (*‹eSuc (?m::enat) + (?n::enat) = eSuc (?m + ?n)›*)) next (*goal: ‹¬ bval (b::bexp) (s::char list ⇒ int) ⟹ ∃(t::char list ⇒ int) p::nat. (IF b THEN c1::com ELSE (c2::com), s) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ eSuc ((P::(char list ⇒ int) ⇒ enat) s)›*) case False (*‹¬ bval b s›*) with i (*‹P s < ∞›*) have "P s + emb (~ bval b s) < ∞" by simp with If(4)[unfolded hoare2_valid_def] (*‹∀s. P s + ↑ (¬ bval b s) < ∞ ⟶ (∃t p. (c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ P s + ↑ (¬ bval b s))›*) obtain p and t where 1: "(c2, s) ⇒ p ⇓ t" and q: "enat p + Q t ≤ P s + emb (~ bval b s)" (*goal: ‹(⋀p t. ⟦(c2, s) ⇒ p ⇓ t; enat p + Q t ≤ P s + ↑ (¬ bval b s)⟧ ⟹ thesis) ⟹ thesis›*) by blast from Big_StepT.IfFalse[OF False 1] (*‹?y = p + 1 ⟹ (IF b THEN ?c1.0 ELSE c2, s) ⇒ ?y ⇓ t›*) have 2: "(IF b THEN c1 ELSE c2, s) ⇒ p + 1 ⇓ t" by simp show "?thesis" (*goal: ‹∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)›*) apply (rule exI[where x=t] (*‹?P t ⟹ ∃x. ?P x›*)) (*goal: ‹∃t p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)›*) apply (rule exI[where x="p+1"] (*‹?P (p + 1) ⟹ ∃x. ?P x›*)) (*goal: ‹∃p. (IF b THEN c1 ELSE c2, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ eSuc (P s)›*) apply safe (*goal: ‹(IF b THEN c1 ELSE c2, s) ⇒ p + 1 ⇓ t ∧ enat (p + 1) + Q t ≤ eSuc (P s)›*) apply fact (*top goal: ‹(IF b THEN c1 ELSE c2, s) ⇒ p + 1 ⇓ t› and 1 goal remains*) using q (*‹enat (p::nat) + (Q::(char list ⇒ int) ⇒ enat) (t::char list ⇒ int) ≤ (P::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) + ↑ (¬ bval (b::bexp) s)›*) False (*‹¬ bval (b::bexp) (s::char list ⇒ int)›*) apply simp (*goal: ‹enat (p + 1) + Q t ≤ eSuc (P s)›*) by (metis eSuc_enat (*‹eSuc (enat (?n::nat)) = enat (Suc ?n)›*) eSuc_ile_mono (*‹(eSuc (?n::enat) ≤ eSuc (?m::enat)) = (?n ≤ ?m)›*) iadd_Suc (*‹eSuc (?m::enat) + (?n::enat) = eSuc (?m + ?n)›*)) qed qed next (*goals: 1. ‹⋀(I::(char list ⇒ int) ⇒ enat) (b::bexp) c::com. ⟦⊢₂ {λs::char list ⇒ int. I s + ↑ (bval b s)} c {λt::char list ⇒ int. I t + (1::enat)}; ⊨₂ {λa::char list ⇒ int. I a + ↑ (bval b a)} c {λa::char list ⇒ int. I a + (1::enat)}⟧ ⟹ ⊨₂ {λa::char list ⇒ int. I a + (1::enat)} WHILE b DO c {λa::char list ⇒ int. I a + ↑ (¬ bval b a)}› 2. ‹⋀(P::(char list ⇒ int) ⇒ enat) (c::com) (Q::(char list ⇒ int) ⇒ enat) (P'::(char list ⇒ int) ⇒ enat) Q'::(char list ⇒ int) ⇒ enat. ⟦⊢₂ {P} c {Q}; ⊨₂ {P} c {Q}; ⋀s::char list ⇒ int. P s ≤ P' s; ⋀s::char list ⇒ int. Q' s ≤ Q s⟧ ⟹ ⊨₂ {P'} c {Q'}›*) case (conseq P c Q P' Q') (*‹⊢₂ {P} c {Q}› ‹P ?s ≤ P' ?s› ‹Q' ?s ≤ Q ?s› ‹⊨₂ {P} c {Q}›*) show "?case" (*goal: ‹⊨₂ {P'} c {Q'}›*) unfolding hoare2_valid_def (*goal: ‹∀s. P' s < ∞ ⟶ (∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q' t ≤ P' s)›*) proof (safe) (*goal: ‹⋀s::char list ⇒ int. (P'::(char list ⇒ int) ⇒ enat) s < ∞ ⟹ ∃(t::char list ⇒ int) p::nat. (c::com, s) ⇒ p ⇓ t ∧ enat p + (Q'::(char list ⇒ int) ⇒ enat) t ≤ P' s›*) fix s assume "P' s < ∞" (*‹(P'::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) < ∞›*) with conseq(2) (*‹(P::(char list ⇒ int) ⇒ enat) (?s::char list ⇒ int) ≤ (P'::(char list ⇒ int) ⇒ enat) ?s›*) have "P s < ∞" using le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) by blast with conseq(4)[unfolded hoare2_valid_def] (*‹∀s::char list ⇒ int. (P::(char list ⇒ int) ⇒ enat) s < ∞ ⟶ (∃(t::char list ⇒ int) p::nat. (c::com, s) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ P s)›*) obtain p and t where "(c, s) ⇒ p ⇓ t" "enat p + Q t ≤ P s" (*goal: ‹(⋀p t. ⟦(c, s) ⇒ p ⇓ t; enat p + Q t ≤ P s⟧ ⟹ thesis) ⟹ thesis›*) by blast with conseq(2,3) (*‹P ?s ≤ P' ?s› ‹Q' ?s ≤ Q ?s›*) show "∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q' t ≤ P' s" by (meson add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*)) qed next (*goal: ‹⋀I b c. ⟦⊢₂ {λs. I s + ↑ (bval b s)} c {λt. I t + 1}; ⊨₂ {λa. I a + ↑ (bval b a)} c {λa. I a + 1}⟧ ⟹ ⊨₂ {λa. I a + 1} WHILE b DO c {λa. I a + ↑ (¬ bval b a)}›*) case (While INV b c) (*‹⊢₂ {λs. INV s + ↑ (bval b s)} c {λt. INV t + 1}› ‹⊨₂ {λa. INV a + ↑ (bval b a)} c {λa. INV a + 1}›*) from While(2)[unfolded hoare2_valid_def] (*‹∀s. INV s + ↑ (bval b s) < ∞ ⟶ (∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + (INV t + 1) ≤ INV s + ↑ (bval b s))›*) have WH2: "⋀s. INV s + ↑ (bval b s) < ∞ ⟹ (∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + INV t + 1 ≤ INV s + ↑ (bval b s))" by (simp add: add.commute (*‹?a + ?b = ?b + ?a›*) add.left_commute (*‹?b + (?a + ?c) = ?a + (?b + ?c)›*)) show "?case" (*goal: ‹⊨₂ {λa. INV a + 1} WHILE b DO c {λa. INV a + ↑ (¬ bval b a)}›*) unfolding hoare2_valid_def (*goal: ‹∀s::char list ⇒ int. (INV::(char list ⇒ int) ⇒ enat) s + (1::enat) < ∞ ⟶ (∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + (1::enat))›*) proof (safe) (*goal: ‹⋀s. INV s + 1 < ∞ ⟹ ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) fix s assume ninfINV: "INV s + 1 < ∞" (*‹(INV::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) + (1::enat) < ∞›*) then have "INV s < ∞" using enat_ord_simps(4) (*‹(?q < ∞) = (?q ≠ ∞)›*) by fastforce then obtain n where i: "INV s = enat n" (*goal: ‹(⋀n::nat. (INV::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) = enat n ⟹ thesis::bool) ⟹ thesis›*) using not_infinity_eq (*‹(?x ≠ ∞) = (∃i. ?x = enat i)›*) by auto text ‹In order to prove validity, we induct on the value of the Invariant, which is a finite number and decreases in every loop iteration. For each step we show that validity holds.› have "INV s = enat n ⟹ ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + emb (¬ bval b t)) ≤ INV s + 1" proof (induct n arbitrary: s rule: less_induct) (*goal: ‹⋀(x::nat) s::char list ⇒ int. ⟦⋀(y::nat) s::char list ⇒ int. ⟦y < x; (INV::(char list ⇒ int) ⇒ enat) s = enat y⟧ ⟹ ∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + (1::enat); INV s = enat x⟧ ⟹ ∃(t::char list ⇒ int) p::nat. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + (1::enat)›*) case (less n) (*‹⟦?y < n; INV ?s = enat ?y⟧ ⟹ ∃t p. (WHILE b DO c, ?s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV ?s + 1› ‹INV s = enat n›*) show "?case" (*goal: ‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) proof (cases "bval b s") (*goals: 1. ‹bval b s ⟹ ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1› 2. ‹¬ bval b s ⟹ ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) case False (*‹¬ bval b s›*) show "?thesis" (*goal: ‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) using WhileFalse[OF False] (*‹(WHILE b::bexp DO (?c::com), s::char list ⇒ int) ⇒ Suc (0::nat) ⇓ s›*) one_enat_def (*‹(1::enat) = enat (1::nat)›*) by fastforce next (*goal: ‹bval b s ⟹ ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) case True (*‹bval (b::bexp) (s::char list ⇒ int)›*) with less(2) (*‹INV s = enat n›*) WH2 (*‹INV ?s + ↑ (bval b ?s) < ∞ ⟹ ∃t p. (c, ?s) ⇒ p ⇓ t ∧ enat p + INV t + 1 ≤ INV ?s + ↑ (bval b ?s)›*) obtain t and p where o: "(c, s) ⇒ p ⇓ t" and q: "enat p + INV t + 1 ≤ INV s " (*goal: ‹(⋀(p::nat) t::char list ⇒ int. ⟦(c::com, s::char list ⇒ int) ⇒ p ⇓ t; enat p + (INV::(char list ⇒ int) ⇒ enat) t + (1::enat) ≤ INV s⟧ ⟹ thesis::bool) ⟹ thesis›*) by force from q (*‹enat p + INV t + 1 ≤ INV s›*) have g: "INV t < INV s" using help2 (*‹⟦enat ?p + ?INV ?t + 1 ≤ ?INV ?s; ?INV ?s = enat ?n⟧ ⟹ ?INV ?t < ?INV ?s›*) less(2) (*‹INV s = enat n›*) by metis then have ninfINVt: "INV t < ∞" using less(2) (*‹(INV::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) = enat (n::nat)›*) using enat_ord_simps(4) (*‹(?q < ∞) = (?q ≠ ∞)›*) by fastforce then obtain n' where i: "INV t = enat n'" (*goal: ‹(⋀n'. INV t = enat n' ⟹ thesis) ⟹ thesis›*) using not_infinity_eq (*‹(?x ≠ ∞) = (∃i. ?x = enat i)›*) by auto with less(2) (*‹INV s = enat n›*) have ii: "n' < n" using g (*‹INV t < INV s›*) by auto from i (*‹INV t = enat n'›*) ii (*‹n' < n›*) less(1) (*‹⟦?y < n; INV ?s = enat ?y⟧ ⟹ ∃t p. (WHILE b DO c, ?s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV ?s + 1›*) obtain t2 and p2 where o2: "(WHILE b DO c, t) ⇒ p2 ⇓ t2" and q2: "enat p2 + (INV t2 + emb (¬ bval b t2)) ≤ INV t + 1" (*goal: ‹(⋀p2 t2. ⟦(WHILE b DO c, t) ⇒ p2 ⇓ t2; enat p2 + (INV t2 + ↑ (¬ bval b t2)) ≤ INV t + 1⟧ ⟹ thesis) ⟹ thesis›*) by blast have ende: "~ bval b t2" apply (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ bval b t2›*) apply simp (*goal: ‹¬ ¬ bval b t2 ⟹ False›*) using q2 (*‹enat (p2::nat) + ((INV::(char list ⇒ int) ⇒ enat) (t2::char list ⇒ int) + ↑ (¬ bval (b::bexp) t2)) ≤ INV (t::char list ⇒ int) + (1::enat)›*) ninfINVt (*‹INV t < ∞›*) by (simp add: i (*‹INV t = enat n'›*) one_enat_def (*‹1 = enat 1›*)) from WhileTrue[OF True o o2] (*‹1 + p + p2 = ?z ⟹ (WHILE b DO c, s) ⇒ ?z ⇓ t2›*) have BigStep: "(WHILE b DO c, s) ⇒ 1 + p + p2 ⇓ t2" by simp from ende (*‹¬ bval (b::bexp) (t2::char list ⇒ int)›*) q2 (*‹enat (p2::nat) + ((INV::(char list ⇒ int) ⇒ enat) (t2::char list ⇒ int) + ↑ (¬ bval (b::bexp) t2)) ≤ INV (t::char list ⇒ int) + (1::enat)›*) have q2': "enat p2 + INV t2 ≤ INV t + 1" by simp have potentialPreservation: "enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1" proof (-) (*goal: ‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1›*) have "enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) = enat (Suc (p + p2)) + INV t2" using ende (*‹¬ bval b t2›*) by simp also (*calculation: ‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) = enat (Suc (p + p2)) + INV t2›*) have "… = enat (Suc p) + enat p2 + INV t2" by fastforce also (*calculation: ‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) = enat (Suc p) + enat p2 + INV t2›*) have "… ≤ enat (Suc p) + INV t + 1" using q2' (*‹enat p2 + INV t2 ≤ INV t + 1›*) by (metis ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*)) also (*calculation: ‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ enat (Suc p) + INV t + 1›*) have "… ≤ INV s + 1" using q (*‹enat (p::nat) + (INV::(char list ⇒ int) ⇒ enat) (t::char list ⇒ int) + (1::enat) ≤ INV (s::char list ⇒ int)›*) by (metis (no_types, opaque_lifting) add.commute (*‹?a + ?b = ?b + ?a›*) add_left_mono (*‹?a ≤ ?b ⟹ ?c + ?a ≤ ?c + ?b›*) eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*) iadd_Suc (*‹eSuc ?m + ?n = eSuc (?m + ?n)›*) plus_1_eSuc( (*‹1 + ?q = eSuc ?q›*) 1)) finally (*calculation: ‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1›*) show "enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1" . qed show "?thesis" (*goal: ‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) apply (rule exI[where x=t2] (*‹(?P::(char list ⇒ int) ⇒ bool) (t2::char list ⇒ int) ⟹ ∃x::char list ⇒ int. ?P x›*)) (*goal: ‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) apply (rule exI[where x= "1 + p + p2"] (*‹(?P::nat ⇒ bool) ((1::nat) + (p::nat) + (p2::nat)) ⟹ ∃x::nat. ?P x›*)) (*goal: ‹∃p. (WHILE b DO c, s) ⇒ p ⇓ t2 ∧ enat p + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1›*) apply safe (*goals: 1. ‹(WHILE b DO c, s) ⇒ 1 + p + p2 ⇓ t2› 2. ‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1› discuss goal 1*) apply (fact BigStep (*‹(WHILE b DO c, s) ⇒ 1 + p + p2 ⇓ t2›*) potentialPreservation (*‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1›*)) (*discuss goal 2*) apply (fact BigStep (*‹(WHILE b DO c, s) ⇒ 1 + p + p2 ⇓ t2›*) potentialPreservation (*‹enat (1 + p + p2) + (INV t2 + ↑ (¬ bval b t2)) ≤ INV s + 1›*)) (*proven 2 subgoals*) . qed qed from this[OF i] (*‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + ↑ (¬ bval b t)) ≤ INV s + 1›*) show "∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ enat p + (INV t + emb (¬ bval b t)) ≤ INV s + 1" . qed qed subsection "Completeness" (* the WeakestPrePotential *) definition wp2 :: "com ⇒ qassn ⇒ qassn" ("wp₂") where "wp₂ c Q = (λs. (if (∃t p. (c,s) ⇒ p ⇓ t ∧ Q t < ∞) then enat (THE p. ∃t. (c,s) ⇒ p ⇓ t) + Q (THE t. ∃p. (c,s) ⇒ p ⇓ t) else ∞))" lemma wp2_alt: "wp₂ c Q = (λs. (if ↓(c,s) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞))" apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹wp₂ c Q = (λs. if ↓ (c, s) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞)›*) by (auto simp: bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) wp2_def (*‹wp₂ ?c ?Q = (λs. if ∃t p. (?c, s) ⇒ p ⇓ t ∧ ?Q t < ∞ then enat (↓⇩t (?c, s)) + ?Q (↓⇩s (?c, s)) else ∞)›*) split: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) theorem wp2_is_weakestprePotential: "⊨₂ {P}c{Q} ⟷ (∀s. wp₂ c Q s ≤ P s)" sorry lemma wp2_Skip[simp]: "wp₂ SKIP Q = (%s. eSuc (Q s))" apply (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) simp: wp2_def (*‹wp₂ (?c::com) (?Q::(char list ⇒ int) ⇒ enat) = (λs::char list ⇒ int. if ∃(t::char list ⇒ int) p::nat. (?c, s) ⇒ p ⇓ t ∧ ?Q t < ∞ then enat (↓⇩t (?c, s)) + ?Q (↓⇩s (?c, s)) else ∞)›*)) (*goal: ‹wp₂ SKIP (Q::(char list ⇒ int) ⇒ enat) = (λs::char list ⇒ int. eSuc (Q s))›*) prefer 2 (*top goal: ‹⋀s::char list ⇒ int. ∀t::char list ⇒ int. (∀p::nat. ¬ (SKIP, s) ⇒ p ⇓ t) ∨ (Q::(char list ⇒ int) ⇒ enat) t = ∞ ⟹ ∞ = eSuc (Q s)› and 1 goal remains*) apply (simp only: SKIPnot (*‹(¬ (SKIP, ?s) ⇒ ?p ⇓ ?t) = (?s ≠ ?t ∨ ?p ≠ Suc 0)›*)) (*top goal: ‹⋀s. ∀t. (∀p. ¬ (SKIP, s) ⇒ p ⇓ t) ∨ Q t = ∞ ⟹ ∞ = eSuc (Q s)› and 1 goal remains*) apply simp (*top goal: ‹⋀s. ∀t. (∀p. s ≠ t ∨ p ≠ Suc 0) ∨ Q t = ∞ ⟹ ∞ = eSuc (Q s)› and 1 goal remains*) apply (simp only: SKIPp (*‹↓⇩t (SKIP, ?s) = Suc 0›*) SKIPt (*‹↓⇩s (SKIP, ?s) = ?s›*)) (*goal: ‹⋀s i. Q s = enat i ⟹ enat (↓⇩t (SKIP, s)) + Q (↓⇩s (SKIP, s)) = eSuc (enat i)›*) using one_enat_def (*‹1 = enat 1›*) plus_1_eSuc(1) (*‹1 + ?q = eSuc ?q›*) by auto lemma wp2_Assign[simp]: "wp₂ (x ::= e) Q = (λs. eSuc (Q (s(x := aval e s))))" by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) simp: wp2_def (*‹wp₂ ?c ?Q = (λs. if ∃t p. (?c, s) ⇒ p ⇓ t ∧ ?Q t < ∞ then enat (↓⇩t (?c, s)) + ?Q (↓⇩s (?c, s)) else ∞)›*) ASSp (*‹↓⇩t (?x ::= ?e, ?s) = Suc 0›*) ASSt (*‹↓⇩s (?x ::= ?e, ?s) = ?s[?e/?x]›*) ASSnot (*‹(¬ (?x ::= ?e, ?s) ⇒ ?p ⇓ ?t) = (?p ≠ Suc 0 ∨ ?t ≠ ?s[?e/?x])›*) eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*)) lemma wp2_Seq[simp]: "wp₂ (c₁;;c₂) Q = wp₂ c₁ (wp₂ c₂ Q)" unfolding wp2_def (*goal: ‹(λs. if ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (λs. if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) proof (rule, case_tac "∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞", goal_cases) (*goals: 1. ‹⋀s. ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ ⟹ (if ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)› 2. ‹⋀s. ∄t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ ⟹ (if ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) case (1 s) (*‹∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞›*) then obtain u and p where ter: "(c₁;; c₂, s) ⇒ p ⇓ u" and Q: "Q u < ∞" (*goal: ‹(⋀p u. ⟦(c₁;; c₂, s) ⇒ p ⇓ u; Q u < ∞⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain t and p1 and p2 where i: "(c₁ , s) ⇒ p1 ⇓ t" and ii: "(c₂ , t) ⇒ p2 ⇓ u" and p: "p1 + p2 = p" (*goal: ‹(⋀p1 t p2. ⟦(c₁, s) ⇒ p1 ⇓ t; (c₂, t) ⇒ p2 ⇓ u; p1 + p2 = p⟧ ⟹ thesis) ⟹ thesis›*) by blast from bigstepT_the_state[OF i] (*‹↓⇩s (c₁, s) = t›*) have t: "↓⇩s (c₁, s) = t" by blast from bigstepT_the_state[OF ii] (*‹↓⇩s (c₂, t) = u›*) have t2: "↓⇩s (c₂, t) = u" by blast from bigstepT_the_cost[OF i] (*‹↓⇩t (c₁::com, s::char list ⇒ int) = (p1::nat)›*) have firstcost: "↓⇩t (c₁, s) = p1" by blast from bigstepT_the_cost[OF ii] (*‹↓⇩t (c₂, t) = p2›*) have secondcost: "↓⇩t (c₂, t) = p2" by blast have totalcost: "↓⇩t(c₁;; c₂, s) = p1 + p2" using bigstepT_the_cost[OF ter] (*‹↓⇩t (c₁;; c₂, s) = p›*) p (*‹p1 + p2 = p›*) by auto have totalstate: "↓⇩s(c₁;; c₂, s) = u" using bigstepT_the_state[OF ter] (*‹↓⇩s ((c₁::com);; (c₂::com), s::char list ⇒ int) = (u::char list ⇒ int)›*) by auto have c2: "∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞" apply (rule exI[where x= u] (*‹?P u ⟹ ∃x. ?P x›*)) (*goal: ‹∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞›*) apply (rule exI[where x= p2] (*‹(?P::nat ⇒ bool) (p2::nat) ⟹ ∃x::nat. ?P x›*)) (*goal: ‹∃p. (c₂, t) ⇒ p ⇓ u ∧ Q u < ∞›*) apply safe (*goals: 1. ‹(c₂, t) ⇒ p2 ⇓ u› 2. ‹Q u < ∞› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . have C: "∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (THE p. Ex (big_step_t (c₂, t) p)) + Q (THE ta. ∃p. (c₂, t) ⇒ p ⇓ ta) else ∞) < ∞" apply (rule exI[where x=t] (*‹?P t ⟹ ∃x. ?P x›*)) (*goal: ‹∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞›*) apply (rule exI[where x=p1] (*‹(?P::nat ⇒ bool) (p1::nat) ⟹ ∃x::nat. ?P x›*)) (*goal: ‹∃p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞›*) apply safe (*goal: ‹(c₁, s) ⇒ p1 ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞›*) apply fact (*top goal: ‹(c₁, s) ⇒ p1 ⇓ t› and 1 goal remains*) apply (simp only: c2 (*‹∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞›*) if_True (*‹(if True then ?x else ?y) = ?x›*)) (*goal: ‹(if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞›*) using Q (*‹(Q::(char list ⇒ int) ⇒ enat) (u::char list ⇒ int) < ∞›*) bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) ii (*‹(c₂::com, t::char list ⇒ int) ⇒ p2::nat ⇓ u::char list ⇒ int›*) by auto show "?case" (*goal: ‹(if ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) apply (simp only: 1 (*‹∃(t::char list ⇒ int) p::nat. ((c₁::com);; (c₂::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞›*) if_True (*‹(if True then ?x::?'a else (?y::?'a)) = ?x›*) t (*‹↓⇩s (c₁::com, s::char list ⇒ int) = (t::char list ⇒ int)›*) t2 (*‹↓⇩s (c₂::com, t::char list ⇒ int) = (u::char list ⇒ int)›*) c2 (*‹∃(ta::char list ⇒ int) p::nat. (c₂::com, t::char list ⇒ int) ⇒ p ⇓ ta ∧ (Q::(char list ⇒ int) ⇒ enat) ta < ∞›*) C (*‹∃(t::char list ⇒ int) p::nat. (c₁::com, s::char list ⇒ int) ⇒ p ⇓ t ∧ (if ∃(ta::char list ⇒ int) p::nat. (c₂::com, t) ⇒ p ⇓ ta ∧ (Q::(char list ⇒ int) ⇒ enat) ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞›*) totalcost (*‹↓⇩t ((c₁::com);; (c₂::com), s::char list ⇒ int) = (p1::nat) + (p2::nat)›*) totalstate (*‹↓⇩s ((c₁::com);; (c₂::com), s::char list ⇒ int) = (u::char list ⇒ int)›*) firstcost (*‹↓⇩t (c₁::com, s::char list ⇒ int) = (p1::nat)›*) secondcost (*‹↓⇩t (c₂::com, t::char list ⇒ int) = (p2::nat)›*)) (*goal: ‹(if ∃(t::char list ⇒ int) p::nat. ((c₁::com);; (c₂::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃(t::char list ⇒ int) p::nat. (c₁, s) ⇒ p ⇓ t ∧ (if ∃(ta::char list ⇒ int) p::nat. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃(t::char list ⇒ int) p::nat. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) by fastforce next (*goal: ‹⋀s. ∄t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ ⟹ (if ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) case (2 s) (*‹∄t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞›*) show "?case" (*goal: ‹(if ∃t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) apply (simp only: 2 (*‹∄t p. (c₁;; c₂, s) ⇒ p ⇓ t ∧ Q t < ∞›*) if_False (*‹(if False then ?x else ?y) = ?y›*)) (*goal: ‹(if ∃(t::char list ⇒ int) p::nat. ((c₁::com);; (c₂::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ then enat (↓⇩t (c₁;; c₂, s)) + Q (↓⇩s (c₁;; c₂, s)) else ∞) = (if ∃(t::char list ⇒ int) p::nat. (c₁, s) ⇒ p ⇓ t ∧ (if ∃(ta::char list ⇒ int) p::nat. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃(t::char list ⇒ int) p::nat. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) apply auto (*goal: ‹∞ = (if ∃t p. (c₁, s) ⇒ p ⇓ t ∧ (if ∃ta p. (c₂, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (c₂, t)) + Q (↓⇩s (c₂, t)) else ∞) < ∞ then enat (↓⇩t (c₁, s)) + (if ∃t p. (c₂, ↓⇩s (c₁, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (c₂, ↓⇩s (c₁, s))) + Q (↓⇩s (c₂, ↓⇩s (c₁, s))) else ∞) else ∞)›*) using "2" (*‹∄(t::char list ⇒ int) p::nat. ((c₁::com);; (c₂::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞›*) by force qed lemma wp2_If[simp]: "wp₂ (IF b THEN c₁ ELSE c₂) Q = (λs. eSuc (wp₂ (if bval b s then c₁ else c₂) Q s))" apply (auto simp: wp2_def (*‹wp₂ ?c ?Q = (λs. if ∃t p. (?c, s) ⇒ p ⇓ t ∧ ?Q t < ∞ then enat (↓⇩t (?c, s)) + ?Q (↓⇩s (?c, s)) else ∞)›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹wp₂ (IF b THEN c₁ ELSE c₂) Q = (λs. eSuc (wp₂ (if bval b s then c₁ else c₂) Q s))›*) subgoal for x and t and p and i and ta and ia and xa apply (simp only: IfTrue[THEN bigstepT_the_state] (*‹⟦bval (?b1::bexp) (?s::char list ⇒ int); (?c1.1::com, ?s) ⇒ ?x1::nat ⇓ ?s'::char list ⇒ int; (?t::nat) = ?x1 + (1::nat)⟧ ⟹ ↓⇩s (IF ?b1 THEN ?c1.1 ELSE (?c2.1::com), ?s) = ?s'›*)) (*goal: ‹⟦(c₁::com, x::char list ⇒ int) ⇒ p::nat ⇓ t::char list ⇒ int; (Q::(char list ⇒ int) ⇒ enat) t = enat (i::nat); Q (ta::char list ⇒ int) = enat (ia::nat); bval (b::bexp) x; (c₁, x) ⇒ xa::nat ⇓ ta⟧ ⟹ enat (↓⇩t (IF b THEN c₁ ELSE (c₂::com), x)) + Q (↓⇩s (IF b THEN c₁ ELSE c₂, x)) = eSuc (enat (↓⇩t (c₁, x)) + Q (↓⇩s (c₁, x)))›*) apply (simp only: IfTrue[THEN bigstepT_the_cost] (*‹⟦bval ?b1 ?s; (?c1.1, ?s) ⇒ ?x1 ⇓ ?s'; ?t = ?x1 + 1⟧ ⟹ ↓⇩t (IF ?b1 THEN ?c1.1 ELSE ?c2.1, ?s) = ?t›*)) (*goal: ‹⟦(c₁, x) ⇒ p ⇓ t; Q t = enat i; Q ta = enat ia; bval b x; (c₁, x) ⇒ xa ⇓ ta⟧ ⟹ enat (↓⇩t (IF b THEN c₁ ELSE c₂, x)) + enat i = eSuc (enat (↓⇩t (c₁, x)) + Q (↓⇩s (c₁, x)))›*) apply (simp only: bigstepT_the_cost (*‹(?c::com, ?s::char list ⇒ int) ⇒ ?t::nat ⇓ ?s'::char list ⇒ int ⟹ ↓⇩t (?c, ?s) = ?t›*) bigstepT_the_state (*‹(?c::com, ?s::char list ⇒ int) ⇒ ?t::nat ⇓ ?s'::char list ⇒ int ⟹ ↓⇩s (?c, ?s) = ?s'›*)) (*goal: ‹⟦(c₁::com, x::char list ⇒ int) ⇒ p::nat ⇓ t::char list ⇒ int; (Q::(char list ⇒ int) ⇒ enat) t = enat (i::nat); Q (ta::char list ⇒ int) = enat (ia::nat); bval (b::bexp) x; (c₁, x) ⇒ xa::nat ⇓ ta⟧ ⟹ enat (p + (1::nat)) + enat i = eSuc (enat (↓⇩t (c₁, x)) + Q (↓⇩s (c₁, x)))›*) by (simp add: eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*)) apply (simp only: bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) bigstepT_the_cost (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩t (?c, ?s) = ?t›*)) (*top goal: ‹⋀x t p i. ⟦bval b x; (c₁, x) ⇒ p ⇓ t; Q t = enat i; ∀t. (∀p. ¬ (IF b THEN c₁ ELSE c₂, x) ⇒ p ⇓ t) ∨ Q t = ∞⟧ ⟹ ∞ = eSuc (enat (↓⇩t (c₁, x)) + Q (↓⇩s (c₁, x)))› and 2 goals remain*) apply force (*top goal: ‹⋀x t p i. ⟦bval b x; (c₁, x) ⇒ p ⇓ t; Q t = enat i; ∀t. (∀p. ¬ (IF b THEN c₁ ELSE c₂, x) ⇒ p ⇓ t) ∨ Q t = ∞⟧ ⟹ ∞ = eSuc (enat p + enat i)› and 2 goals remain*) apply (simp only: bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) bigstepT_the_cost (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩t (?c, ?s) = ?t›*)) (*top goal: ‹⋀x t p i ta ia xa. ⟦(c₂, x) ⇒ p ⇓ t; Q t = enat i; Q ta = enat ia; ¬ bval b x; (c₂, x) ⇒ xa ⇓ ta⟧ ⟹ enat (↓⇩t (IF b THEN c₁ ELSE c₂, x)) + Q (↓⇩s (IF b THEN c₁ ELSE c₂, x)) = eSuc (enat (↓⇩t (c₂, x)) + Q (↓⇩s (c₂, x)))› and 1 goal remains*) proof (goal_cases) (*goals: 1. ‹⋀x t p i ta ia xa. ⟦(c₂, x) ⇒ p ⇓ t; Q t = enat i; Q ta = enat ia; ¬ bval b x; (c₂, x) ⇒ xa ⇓ ta⟧ ⟹ enat (↓⇩t (IF b THEN c₁ ELSE c₂, x)) + Q (↓⇩s (IF b THEN c₁ ELSE c₂, x)) = eSuc (enat p + enat i)› 2. ‹⋀x t p i. ⟦¬ bval b x; (c₂, x) ⇒ p ⇓ t; Q t = enat i; ∀t. (∀p. ¬ (IF b THEN c₁ ELSE c₂, x) ⇒ p ⇓ t) ∨ Q t = ∞⟧ ⟹ ∞ = eSuc (enat (↓⇩t (c₂, x)) + Q (↓⇩s (c₂, x)))›*) case (1 x t p i ta ia xa) (*‹(c₂, x) ⇒ p ⇓ t› ‹Q t = enat i› ‹Q ta = enat ia› ‹¬ bval (b::bexp) (x::char list ⇒ int)› ‹(c₂, x) ⇒ xa ⇓ ta›*) note f = IfFalse[THEN bigstepT_the_state, of b x c₂ xa ta "Suc xa" c₁, simplified, OF 1 ( 4 ) 1 ( 5 )] (*‹↓⇩s (IF b THEN c₁ ELSE c₂, x) = ta›*) note f2 = IfFalse[THEN bigstepT_the_cost, of b x c₂ xa ta "Suc xa" c₁, simplified, OF 1 ( 4 ) 1 ( 5 )] (*‹↓⇩t (IF b THEN c₁ ELSE c₂, x) = Suc xa›*) note g = bigstep_det[OF 1 ( 1 ) 1 ( 5 )] (*‹p = xa ∧ t = ta›*) show "?case" (*goal: ‹enat (↓⇩t (IF b THEN c₁ ELSE c₂, x)) + Q (↓⇩s (IF b THEN c₁ ELSE c₂, x)) = eSuc (enat p + enat i)›*) apply (simp only: f (*‹↓⇩s (IF b THEN c₁ ELSE c₂, x) = ta›*) f2 (*‹↓⇩t (IF b THEN c₁ ELSE c₂, x) = Suc xa›*)) (*goal: ‹enat (↓⇩t (IF b THEN c₁ ELSE c₂, x)) + Q (↓⇩s (IF b THEN c₁ ELSE c₂, x)) = eSuc (enat p + enat i)›*) using "1" (*‹(c₂, x) ⇒ p ⇓ t› ‹Q t = enat i› ‹Q ta = enat ia› ‹¬ bval b x› ‹(c₂, x) ⇒ xa ⇓ ta›*) g (*‹p = xa ∧ t = ta›*) by (simp add: eSuc_enat (*‹eSuc (enat (?n::nat)) = enat (Suc ?n)›*)) next (*goal: ‹⋀x t p i. ⟦¬ bval b x; (c₂, x) ⇒ p ⇓ t; Q t = enat i; ∀t. (∀p. ¬ (IF b THEN c₁ ELSE c₂, x) ⇒ p ⇓ t) ∨ Q t = ∞⟧ ⟹ ∞ = eSuc (enat (↓⇩t (c₂, x)) + Q (↓⇩s (c₂, x)))›*) case 2 (*‹¬ bval b x_› ‹(c₂, x_) ⇒ p_ ⇓ t_› ‹Q t_ = enat i_› ‹∀t. (∀p. ¬ (IF b THEN c₁ ELSE c₂, x_) ⇒ p ⇓ t) ∨ Q t = ∞›*) then show "?case" (*goal: ‹∞ = eSuc (enat (↓⇩t (c₂, x_)) + Q (↓⇩s (c₂, x_)))›*) apply (simp only: bigstepT_the_state (*‹(?c::com, ?s::char list ⇒ int) ⇒ ?t::nat ⇓ ?s'::char list ⇒ int ⟹ ↓⇩s (?c, ?s) = ?s'›*) bigstepT_the_cost (*‹(?c::com, ?s::char list ⇒ int) ⇒ ?t::nat ⇓ ?s'::char list ⇒ int ⟹ ↓⇩t (?c, ?s) = ?t›*)) (*goal: ‹∞ = eSuc (enat (↓⇩t (c₂::com, x_::char list ⇒ int)) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (c₂, x_)))›*) by force qed lemma assumes b: "bval b s" shows wp2WhileTrue: " wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 ≤ wp₂ (WHILE b DO c) Q s" proof (cases "∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞") (*goals: 1. ‹∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ ⟹ wp₂ c (wp₂ (WHILE b DO c) Q) s + (1::enat) ≤ wp₂ (WHILE b DO c) Q s› 2. ‹∄(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ ⟹ wp₂ c (wp₂ (WHILE b DO c) Q) s + (1::enat) ≤ wp₂ (WHILE b DO c) Q s›*) case True (*‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞›*) then obtain t and p where w: "(WHILE b DO c, s) ⇒ p ⇓ t" and q: "Q t < ∞" (*goal: ‹(⋀p t. ⟦(WHILE b DO c, s) ⇒ p ⇓ t; Q t < ∞⟧ ⟹ thesis) ⟹ thesis›*) by blast from b (*‹bval b s›*) w (*‹(WHILE b DO c, s) ⇒ p ⇓ t›*) obtain p1 and p2 and t1 where c: "(c, s) ⇒ p1 ⇓ t1" and w': "(WHILE b DO c, t1) ⇒ p2 ⇓ t" and sum: "1 + p1 + p2 = p" (*goal: ‹(⋀p1 t1 p2. ⟦(c, s) ⇒ p1 ⇓ t1; (WHILE b DO c, t1) ⇒ p2 ⇓ t; 1 + p1 + p2 = p⟧ ⟹ thesis) ⟹ thesis›*) by auto have g: "∃ta p. (WHILE b DO c, t1) ⇒ p ⇓ ta ∧ Q ta < ∞" apply (rule exI[where x="t"] (*‹?P t ⟹ ∃x. ?P x›*)) (*goal: ‹∃ta p. (WHILE b DO c, t1) ⇒ p ⇓ ta ∧ Q ta < ∞›*) apply (rule exI[where x="p2"] (*‹?P p2 ⟹ ∃x. ?P x›*)) (*goal: ‹∃p. (WHILE b DO c, t1) ⇒ p ⇓ t ∧ Q t < ∞›*) apply safe (*goals: 1. ‹(WHILE b DO c, t1) ⇒ p2 ⇓ t› 2. ‹Q t < ∞› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . have h: "∃t p. (c, s) ⇒ p ⇓ t ∧ (if ∃ta p. (WHILE b DO c, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (THE p. Ex (big_step_t (WHILE b DO c, t) p)) + Q (THE ta. ∃p. (WHILE b DO c, t) ⇒ p ⇓ ta) else ∞) < ∞" apply (rule exI[where x="t1"] (*‹(?P::(char list ⇒ int) ⇒ bool) (t1::char list ⇒ int) ⟹ ∃x::char list ⇒ int. ?P x›*)) (*goal: ‹∃t p. (c, s) ⇒ p ⇓ t ∧ (if ∃ta p. (WHILE b DO c, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (WHILE b DO c, t)) + Q (↓⇩s (WHILE b DO c, t)) else ∞) < ∞›*) apply (rule exI[where x="p1"] (*‹?P p1 ⟹ ∃x. ?P x›*)) (*goal: ‹∃p::nat. (c::com, s::char list ⇒ int) ⇒ p ⇓ t1::char list ⇒ int ∧ (if ∃(ta::char list ⇒ int) p::nat. (WHILE b::bexp DO c, t1) ⇒ p ⇓ ta ∧ (Q::(char list ⇒ int) ⇒ enat) ta < ∞ then enat (↓⇩t (WHILE b DO c, t1)) + Q (↓⇩s (WHILE b DO c, t1)) else ∞) < ∞›*) apply safe (*goal: ‹(c, s) ⇒ p1 ⇓ t1 ∧ (if ∃ta p. (WHILE b DO c, t1) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (WHILE b DO c, t1)) + Q (↓⇩s (WHILE b DO c, t1)) else ∞) < ∞›*) apply fact (*top goal: ‹(c::com, s::char list ⇒ int) ⇒ p1::nat ⇓ t1::char list ⇒ int› and 1 goal remains*) apply (simp only: g (*‹∃ta p. (WHILE b DO c, t1) ⇒ p ⇓ ta ∧ Q ta < ∞›*) if_True (*‹(if True then ?x else ?y) = ?x›*)) (*goal: ‹(if ∃ta p. (WHILE b DO c, t1) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (WHILE b DO c, t1)) + Q (↓⇩s (WHILE b DO c, t1)) else ∞) < ∞›*) using bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) bigstepT_the_cost (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩t (?c, ?s) = ?t›*) w' (*‹(WHILE b DO c, t1) ⇒ p2 ⇓ t›*) q (*‹Q t < ∞›*) by auto have "wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = enat p + Q t" unfolding wp2_def (*goal: ‹(if ∃t p. (c, s) ⇒ p ⇓ t ∧ (if ∃ta p. (WHILE b DO c, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (WHILE b DO c, t)) + Q (↓⇩s (WHILE b DO c, t)) else ∞) < ∞ then enat (↓⇩t (c, s)) + (if ∃t p. (WHILE b DO c, ↓⇩s (c, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + 1 = enat p + Q t›*) apply (simp only: h (*‹∃(t::char list ⇒ int) p::nat. (c::com, s::char list ⇒ int) ⇒ p ⇓ t ∧ (if ∃(ta::char list ⇒ int) p::nat. (WHILE b::bexp DO c, t) ⇒ p ⇓ ta ∧ (Q::(char list ⇒ int) ⇒ enat) ta < ∞ then enat (↓⇩t (WHILE b DO c, t)) + Q (↓⇩s (WHILE b DO c, t)) else ∞) < ∞›*) if_True (*‹(if True then ?x::?'a::type else (?y::?'a::type)) = ?x›*)) (*goal: ‹(if ∃t p. (c, s) ⇒ p ⇓ t ∧ (if ∃ta p. (WHILE b DO c, t) ⇒ p ⇓ ta ∧ Q ta < ∞ then enat (↓⇩t (WHILE b DO c, t)) + Q (↓⇩s (WHILE b DO c, t)) else ∞) < ∞ then enat (↓⇩t (c, s)) + (if ∃t p. (WHILE b DO c, ↓⇩s (c, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + 1 = enat p + Q t›*) apply (simp only: bigstepT_the_state[OF c] (*‹↓⇩s (c, s) = t1›*) bigstepT_the_cost[OF c] (*‹↓⇩t (c, s) = p1›*) g (*‹∃ta p. (WHILE b DO c, t1) ⇒ p ⇓ ta ∧ Q ta < ∞›*) if_True (*‹(if True then ?x else ?y) = ?x›*) bigstepT_the_state[OF w'] (*‹↓⇩s (WHILE b DO c, t1) = t›*) bigstepT_the_cost[OF w'] (*‹↓⇩t (WHILE b DO c, t1) = p2›*)) (*goal: ‹enat (↓⇩t (c, s)) + (if ∃t p. (WHILE b DO c, ↓⇩s (c, s)) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) + 1 = enat p + Q t›*) using sum (*‹1 + p1 + p2 = p›*) by (metis One_nat_def (*‹1 = Suc 0›*) ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1) add.commute (*‹?a + ?b = ?b + ?a›*) add.right_neutral (*‹?a + 0 = ?a›*) eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*) plus_1_eSuc( (*‹?q + 1 = eSuc ?q›*) 2) plus_enat_simps( (*‹enat ?m + enat ?n = enat (?m + ?n)›*) 1)) also (*calculation: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = enat p + Q t›*) have "… = wp₂ (WHILE b DO c) Q s" unfolding wp2_def (*goal: ‹enat p + Q t = (if ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) apply (simp only: True (*‹∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞›*) if_True (*‹(if True then ?x::?'a::type else (?y::?'a::type)) = ?x›*)) (*goal: ‹enat p + Q t = (if ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) using bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) bigstepT_the_cost (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩t (?c, ?s) = ?t›*) w (*‹(WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p::nat ⇓ t::char list ⇒ int›*) by simp finally (*calculation: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s›*) show "?thesis" (*goal: ‹wp₂ (c::com) (wp₂ (WHILE b::bexp DO c) (Q::(char list ⇒ int) ⇒ enat)) (s::char list ⇒ int) + (1::enat) ≤ wp₂ (WHILE b DO c) Q s›*) by simp next (*goal: ‹∄t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞ ⟹ wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 ≤ wp₂ (WHILE b DO c) Q s›*) case False (*‹∄(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞›*) have "wp₂ (WHILE b DO c) Q s = ∞" unfolding wp2_def (*goal: ‹(if ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞) = ∞›*) by (simp only: False (*‹∄t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞›*) if_False (*‹(if False then ?x else ?y) = ?y›*)) then show "?thesis" (*goal: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 ≤ wp₂ (WHILE b DO c) Q s›*) by auto qed lemma assumes b: "bval b s" shows wp2WhileTrue': "wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s" proof (cases "∃p t. (WHILE b DO c, s) ⇒ p ⇓ t") (*goals: 1. ‹↓ (WHILE b DO c, s) ⟹ wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s› 2. ‹¬ ↓ (WHILE b DO c, s) ⟹ wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s›*) case True (*‹↓ (WHILE b::bexp DO (c::com), s::char list ⇒ int)›*) then obtain t and p where w: "(WHILE b DO c, s) ⇒ p ⇓ t" (*goal: ‹(⋀(p::nat) t::char list ⇒ int. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ⟹ thesis::bool) ⟹ thesis›*) by blast from b (*‹bval b s›*) w (*‹(WHILE b DO c, s) ⇒ p ⇓ t›*) obtain p1 and p2 and t1 where c: "(c, s) ⇒ p1 ⇓ t1" and w': "(WHILE b DO c, t1) ⇒ p2 ⇓ t" and sum: "1 + p1 + p2 = p" (*goal: ‹(⋀(p1::nat) (t1::char list ⇒ int) p2::nat. ⟦(c::com, s::char list ⇒ int) ⇒ p1 ⇓ t1; (WHILE b::bexp DO c, t1) ⇒ p2 ⇓ t::char list ⇒ int; (1::nat) + p1 + p2 = (p::nat)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto then have z: "↓ (c, s)" and z2: "↓ (WHILE b DO c, t1)" apply - (*goals: 1. ‹⟦(c, s) ⇒ p1 ⇓ t1; (WHILE b DO c, t1) ⇒ p2 ⇓ t; 1 + p1 + p2 = p⟧ ⟹ ↓ (c, s)› 2. ‹⟦(c, s) ⇒ p1 ⇓ t1; (WHILE b DO c, t1) ⇒ p2 ⇓ t; 1 + p1 + p2 = p⟧ ⟹ ↓ (WHILE b DO c, t1)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = enat p + Q t" unfolding wp2_alt (*goal: ‹(if ↓ (c, s) then enat (↓⇩t (c, s)) + (if ↓ (WHILE b DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + 1 = enat p + Q t›*) apply (simp only: z (*‹↓ (c, s)›*) if_True (*‹(if True then ?x else ?y) = ?x›*)) (*goal: ‹(if ↓ (c, s) then enat (↓⇩t (c, s)) + (if ↓ (WHILE b DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + 1 = enat p + Q t›*) apply (simp only: bigstepT_the_state[OF c] (*‹↓⇩s (c, s) = t1›*) bigstepT_the_cost[OF c] (*‹↓⇩t (c, s) = p1›*) z2 (*‹↓ (WHILE b DO c, t1)›*) if_True (*‹(if True then ?x else ?y) = ?x›*) bigstepT_the_state[OF w'] (*‹↓⇩s (WHILE b DO c, t1) = t›*) bigstepT_the_cost[OF w'] (*‹↓⇩t (WHILE b DO c, t1) = p2›*)) (*goal: ‹enat (↓⇩t (c::com, s::char list ⇒ int)) + (if ↓ (WHILE b::bexp DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) + (1::enat) = enat (p::nat) + Q (t::char list ⇒ int)›*) using sum (*‹1 + p1 + p2 = p›*) by (metis One_nat_def (*‹1 = Suc 0›*) ab_semigroup_add_class.add_ac( (*‹?a + ?b + ?c = ?a + (?b + ?c)›*) 1) add.commute (*‹?a + ?b = ?b + ?a›*) add.right_neutral (*‹?a + 0 = ?a›*) eSuc_enat (*‹eSuc (enat ?n) = enat (Suc ?n)›*) plus_1_eSuc( (*‹?q + 1 = eSuc ?q›*) 2) plus_enat_simps( (*‹enat ?m + enat ?n = enat (?m + ?n)›*) 1)) also (*calculation: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = enat p + Q t›*) have "… = wp₂ (WHILE b DO c) Q s" unfolding wp2_alt (*goal: ‹enat p + Q t = (if ↓ (WHILE b DO c, s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) apply (simp only: True (*‹↓ (WHILE b DO c, s)›*) if_True (*‹(if True then ?x else ?y) = ?x›*)) (*goal: ‹enat (p::nat) + (Q::(char list ⇒ int) ⇒ enat) (t::char list ⇒ int) = (if ↓ (WHILE b::bexp DO (c::com), s::char list ⇒ int) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) using bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) bigstepT_the_cost (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩t (?c, ?s) = ?t›*) w (*‹(WHILE b DO c, s) ⇒ p ⇓ t›*) by simp finally (*calculation: ‹wp₂ (c::com) (wp₂ (WHILE b::bexp DO c) (Q::(char list ⇒ int) ⇒ enat)) (s::char list ⇒ int) + (1::enat) = wp₂ (WHILE b DO c) Q s›*) show "?thesis" (*goal: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s›*) by simp next (*goal: ‹¬ ↓ (WHILE b DO c, s) ⟹ wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s›*) case False (*‹¬ ↓ (WHILE b DO c, s)›*) have "¬ (↓ (WHILE b DO c, ↓⇩s(c,s)) ∧ ↓ (c, s))" proof (rule) (*goal: ‹↓ (WHILE b DO c, ↓⇩s (c, s)) ∧ ↓ (c, s) ⟹ False›*) assume P: "↓ (WHILE b DO c, ↓⇩s (c, s)) ∧ ↓ (c, s)" (*‹↓ (WHILE b::bexp DO (c::com), ↓⇩s (c, s::char list ⇒ int)) ∧ ↓ (c, s)›*) then obtain t and s' where A: "(c,s) ⇒ t ⇓ s'" (*goal: ‹(⋀t s'. (c, s) ⇒ t ⇓ s' ⟹ thesis) ⟹ thesis›*) by blast with A (*‹(c, s) ⇒ t ⇓ s'›*) P (*‹↓ (WHILE b DO c, ↓⇩s (c, s)) ∧ ↓ (c, s)›*) have "↓ (WHILE b DO c, s')" using bigstepT_the_state (*‹(?c::com, ?s::char list ⇒ int) ⇒ ?t::nat ⇓ ?s'::char list ⇒ int ⟹ ↓⇩s (?c, ?s) = ?s'›*) by auto then obtain t' and s'' where B: "(WHILE b DO c,s') ⇒ t' ⇓ s''" (*goal: ‹(⋀t' s''. (WHILE b DO c, s') ⇒ t' ⇓ s'' ⟹ thesis) ⟹ thesis›*) by auto have "(WHILE b DO c, s) ⇒ 1+t+t' ⇓ s''" apply (rule WhileTrue (*‹⟦bval ?b ?s1.0; (?c, ?s1.0) ⇒ ?x ⇓ ?s2.0; (WHILE ?b DO ?c, ?s2.0) ⇒ ?y ⇓ ?s3.0; 1 + ?x + ?y = ?z⟧ ⟹ (WHILE ?b DO ?c, ?s1.0) ⇒ ?z ⇓ ?s3.0›*)) (*goal: ‹(WHILE b DO c, s) ⇒ 1 + t + t' ⇓ s''›*) using b (*‹bval b s›*) A (*‹(c::com, s::char list ⇒ int) ⇒ t::nat ⇓ s'::char list ⇒ int›*) B (*‹(WHILE b DO c, s') ⇒ t' ⇓ s''›*) apply - (*goals: 1. ‹⟦bval (b::bexp) (s::char list ⇒ int); (c::com, s) ⇒ t::nat ⇓ s'::char list ⇒ int; (WHILE b DO c, s') ⇒ t'::nat ⇓ s''::char list ⇒ int⟧ ⟹ bval b s› 2. ‹⟦bval (b::bexp) (s::char list ⇒ int); (c::com, s) ⇒ t::nat ⇓ s'::char list ⇒ int; (WHILE b DO c, s') ⇒ t'::nat ⇓ s''::char list ⇒ int⟧ ⟹ (c, s) ⇒ ?x::nat ⇓ ?s2.0::char list ⇒ int› 3. ‹⟦bval (b::bexp) (s::char list ⇒ int); (c::com, s) ⇒ t::nat ⇓ s'::char list ⇒ int; (WHILE b DO c, s') ⇒ t'::nat ⇓ s''::char list ⇒ int⟧ ⟹ (WHILE b DO c, ?s2.0::char list ⇒ int) ⇒ ?y::nat ⇓ s''› 4. ‹⟦bval (b::bexp) (s::char list ⇒ int); (c::com, s) ⇒ t::nat ⇓ s'::char list ⇒ int; (WHILE b DO c, s') ⇒ t'::nat ⇓ s''::char list ⇒ int⟧ ⟹ (1::nat) + (?x::nat) + (?y::nat) = (1::nat) + t + t'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . then have "↓ (WHILE b DO c, s)" by auto thus False using False (*‹¬ ↓ (WHILE b DO c, s)›*) by auto qed then have "¬↓ (WHILE b DO c, ↓⇩s(c,s)) ∨ ¬↓ (c, s)" by simp then show "?thesis" (*goal: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s›*) apply rule (*goal: ‹wp₂ c (wp₂ (WHILE b DO c) Q) s + 1 = wp₂ (WHILE b DO c) Q s›*) subgoal for unfolding wp2_alt (*goal: ‹¬ ↓ (WHILE b DO c, ↓⇩s (c, s)) ⟹ (if ↓ (c, s) then enat (↓⇩t (c, s)) + (if ↓ (WHILE b DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + 1 = (if ↓ (WHILE b DO c, s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) apply (simp only: if_False (*‹(if False then ?x else ?y) = ?y›*) False (*‹¬ ↓ (WHILE b DO c, s)›*)) (*goal: ‹¬ ↓ (WHILE b DO c, ↓⇩s (c, s)) ⟹ (if ↓ (c, s) then enat (↓⇩t (c, s)) + (if ↓ (WHILE b DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + Q (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + 1 = (if ↓ (WHILE b DO c, s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) by auto subgoal for unfolding wp2_alt (*goal: ‹¬ ↓ (c::com, s::char list ⇒ int) ⟹ (if ↓ (c, s) then enat (↓⇩t (c, s)) + (if ↓ (WHILE b::bexp DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + (1::enat) = (if ↓ (WHILE b DO c, s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) apply (simp only: if_False (*‹(if False then ?x::?'a else (?y::?'a)) = ?y›*) False (*‹¬ ↓ (WHILE b::bexp DO (c::com), s::char list ⇒ int)›*)) (*goal: ‹¬ ↓ (c::com, s::char list ⇒ int) ⟹ (if ↓ (c, s) then enat (↓⇩t (c, s)) + (if ↓ (WHILE b::bexp DO c, ↓⇩s (c, s)) then enat (↓⇩t (WHILE b DO c, ↓⇩s (c, s))) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (WHILE b DO c, ↓⇩s (c, s))) else ∞) else ∞) + (1::enat) = (if ↓ (WHILE b DO c, s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) by auto . qed lemma assumes b: "~ bval b s" shows wp2WhileFalse: " Q s + 1 ≤ wp₂ (WHILE b DO c) Q s" proof (cases "∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞") (*goals: 1. ‹∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ ⟹ Q s + (1::enat) ≤ wp₂ (WHILE b DO c) Q s› 2. ‹∄(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ ⟹ Q s + (1::enat) ≤ wp₂ (WHILE b DO c) Q s›*) case True (*‹∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞›*) with b (*‹¬ bval (b::bexp) (s::char list ⇒ int)›*) obtain t and p where w: "(WHILE b DO c, s) ⇒ p ⇓ t" and "Q t < ∞" (*goal: ‹(⋀p t. ⟦(WHILE b DO c, s) ⇒ p ⇓ t; Q t < ∞⟧ ⟹ thesis) ⟹ thesis›*) by blast with b (*‹¬ bval b s›*) have c: "s=t" "p=Suc 0" apply - (*goals: 1. ‹⟦¬ bval (b::bexp) (s::char list ⇒ int); (WHILE b DO (c::com), s) ⇒ p::nat ⇓ t::char list ⇒ int; (Q::(char list ⇒ int) ⇒ enat) t < ∞⟧ ⟹ s = t› 2. ‹⟦¬ bval (b::bexp) (s::char list ⇒ int); (WHILE b DO (c::com), s) ⇒ p::nat ⇓ t::char list ⇒ int; (Q::(char list ⇒ int) ⇒ enat) t < ∞⟧ ⟹ p = Suc (0::nat)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have " wp₂ (WHILE b DO c) Q s = Q s + 1" unfolding wp2_def (*goal: ‹(if ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞) = Q s + 1›*) apply (simp only: True (*‹∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞›*) if_True (*‹(if True then ?x::?'a else (?y::?'a)) = ?x›*)) (*goal: ‹(if ∃(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞) = Q s + (1::enat)›*) using w (*‹(WHILE b DO c, s) ⇒ p ⇓ t›*) c (*‹(s::char list ⇒ int) = (t::char list ⇒ int)› ‹p = Suc 0›*) bigstepT_the_cost (*‹(?c::com, ?s::char list ⇒ int) ⇒ ?t::nat ⇓ ?s'::char list ⇒ int ⟹ ↓⇩t (?c, ?s) = ?t›*) bigstepT_the_state (*‹(?c, ?s) ⇒ ?t ⇓ ?s' ⟹ ↓⇩s (?c, ?s) = ?s'›*) by (auto simp add: one_enat_def (*‹1 = enat 1›*)) then show "?thesis" (*goal: ‹Q s + 1 ≤ wp₂ (WHILE b DO c) Q s›*) by auto next (*goal: ‹∄(t::char list ⇒ int) p::nat. (WHILE b::bexp DO (c::com), s::char list ⇒ int) ⇒ p ⇓ t ∧ (Q::(char list ⇒ int) ⇒ enat) t < ∞ ⟹ Q s + (1::enat) ≤ wp₂ (WHILE b DO c) Q s›*) case False (*‹∄t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞›*) have "wp₂ (WHILE b DO c) Q s = ∞" unfolding wp2_def (*goal: ‹(if ∃t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞ then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞) = ∞›*) by (simp only: False (*‹∄t p. (WHILE b DO c, s) ⇒ p ⇓ t ∧ Q t < ∞›*) if_False (*‹(if False then ?x else ?y) = ?y›*)) then show "?thesis" (*goal: ‹Q s + 1 ≤ wp₂ (WHILE b DO c) Q s›*) by auto qed lemma thet_WhileFalse: "~ bval b s ⟹ ↓⇩t (WHILE b DO c, s) = 1" sorry lemma thes_WhileFalse: "~ bval b s ⟹ ↓⇩s (WHILE b DO c, s) = s" by auto lemma assumes b: "~ bval b s" shows wp2WhileFalse': "Q s + 1 = wp₂ (WHILE b DO c) Q s" proof (-) (*goal: ‹Q s + 1 = wp₂ (WHILE b DO c) Q s›*) from b (*‹¬ bval (b::bexp) (s::char list ⇒ int)›*) have T: "↓ (WHILE b DO c, s)" by auto show "?thesis" (*goal: ‹Q s + 1 = wp₂ (WHILE b DO c) Q s›*) unfolding wp2_alt (*goal: ‹(Q::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) + (1::enat) = (if ↓ (WHILE b::bexp DO (c::com), s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) using b (*‹¬ bval b s›*) apply (simp only: T (*‹↓ (WHILE b::bexp DO (c::com), s::char list ⇒ int)›*) if_True (*‹(if True then ?x::?'a else (?y::?'a)) = ?x›*)) (*goal: ‹(Q::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) + (1::enat) = (if ↓ (WHILE b::bexp DO (c::com), s) then enat (↓⇩t (WHILE b DO c, s)) + Q (↓⇩s (WHILE b DO c, s)) else ∞)›*) by (simp add: thet_WhileFalse (*‹¬ bval ?b ?s ⟹ ↓⇩t (WHILE ?b DO ?c, ?s) = 1›*) thes_WhileFalse (*‹¬ bval ?b ?s ⟹ ↓⇩s (WHILE ?b DO ?c, ?s) = ?s›*) one_enat_def (*‹1 = enat 1›*)) qed (* note that ≤ is sufficient for the completness proof *) lemma wp2While: "(if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1 = wp₂ (WHILE b DO c) Q s" apply (cases "bval b s") (*goal: ‹(if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1 = wp₂ (WHILE b DO c) Q s›*) using wp2WhileTrue' (*‹bval ?b ?s ⟹ wp₂ ?c (wp₂ (WHILE ?b DO ?c) ?Q) ?s + 1 = wp₂ (WHILE ?b DO ?c) ?Q ?s›*) apply simp (*top goal: ‹bval b s ⟹ (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1 = wp₂ (WHILE b DO c) Q s› and 1 goal remains*) using wp2WhileFalse' (*‹¬ bval ?b ?s ⟹ ?Q ?s + 1 = wp₂ (WHILE ?b DO ?c) ?Q ?s›*) by simp lemma assumes "⋀Q. ⊢₂ {wp₂ c Q} c {Q}" shows "⊢₂ {wp₂ (WHILE b DO c) Q} WHILE b DO c {Q}" proof (-) (*goal: ‹⊢₂ {wp₂ (WHILE b::bexp DO (c::com)) (Q::(char list ⇒ int) ⇒ enat)} WHILE b DO c {Q}›*) let ?I = "%s. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s)" from assms[of "wp₂ (WHILE b DO c) Q"] (*‹⊢₂ {wp₂ (c::com) (wp₂ (WHILE b::bexp DO c) (Q::(char list ⇒ int) ⇒ enat))} c {wp₂ (WHILE b DO c) Q}›*) have A: " ⊢₂ {wp₂ c (wp₂ (WHILE b DO c) Q)} c {wp₂ (WHILE b DO c) Q}" . have B: "⊢₂ {λs. (?I s) + ↑ (bval b s)} c {λt. (?I t) + 1}" apply (rule conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goal: ‹⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (bval b s)} c {λt. (if bval b t then wp₂ c (wp₂ (WHILE b DO c) Q) t else Q t) + 1}›*) apply (rule A (*‹⊢₂ {wp₂ c (wp₂ (WHILE b DO c) Q)} c {wp₂ (WHILE b DO c) Q}›*)) (*top goal: ‹⊢₂ {?P} c {?Q}› and 2 goals remain*) apply simp (*top goal: ‹⋀s::char list ⇒ int. wp₂ (c::com) (wp₂ (WHILE b::bexp DO c) (Q::(char list ⇒ int) ⇒ enat)) s ≤ (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (bval b s)› and 1 goal remains*) using wp2While (*‹(if bval ?b ?s then wp₂ ?c (wp₂ (WHILE ?b DO ?c) ?Q) ?s else ?Q ?s) + 1 = wp₂ (WHILE ?b DO ?c) ?Q ?s›*) by simp from hoare2.While[where I = "?I"] (*‹⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (bval ?b s)} ?c {λt. (if bval b t then wp₂ c (wp₂ (WHILE b DO c) Q) t else Q t) + 1} ⟹ ⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1} WHILE ?b DO ?c {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (¬ bval ?b s)}›*) have C: "⊢₂ {λs. (?I s) + ↑ (bval b s)} c {λt. (?I t) + 1} ⟹ ⊢₂ {λs. (?I s) + 1} WHILE b DO c {λs. (?I s) + ↑ (¬ bval b s)}" by simp from C[OF B] (*‹⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1} WHILE b DO c {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (¬ bval b s)}›*) have D: "⊢₂ {λs. (?I s) + 1} WHILE b DO c {λs. (?I s) + ↑ (¬ bval b s)}" . show "⊢₂ {wp₂ (WHILE b DO c) Q} WHILE b DO c {Q}" apply (rule conseq (*‹⟦⊢₂ {?P::(char list ⇒ int) ⇒ enat} ?c::com {?Q::(char list ⇒ int) ⇒ enat}; ⋀s::char list ⇒ int. ?P s ≤ (?P'::(char list ⇒ int) ⇒ enat) s; ⋀s::char list ⇒ int. (?Q'::(char list ⇒ int) ⇒ enat) s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goal: ‹⊢₂ {wp₂ (WHILE b DO c) Q} WHILE b DO c {Q}›*) apply (rule D (*‹⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1} WHILE b DO c {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (¬ bval b s)}›*)) (*top goal: ‹⊢₂ {?P} WHILE b DO c {?Q}› and 2 goals remain*) using wp2While (*‹(if bval ?b ?s then wp₂ ?c (wp₂ (WHILE ?b DO ?c) ?Q) ?s else ?Q ?s) + 1 = wp₂ (WHILE ?b DO ?c) ?Q ?s›*) (*goals: 1. ‹⋀s. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1 ≤ wp₂ (WHILE b DO c) Q s› 2. ‹⋀s. Q s ≤ (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (¬ bval b s)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed lemma wp2_is_pre: "⊢₂ {wp₂ c Q} c { Q}" proof (induction c arbitrary: Q) (*goals: 1. ‹⋀Q. ⊢₂ {wp₂ SKIP Q} SKIP {Q}› 2. ‹⋀x1 x2 Q. ⊢₂ {wp₂ (x1 ::= x2) Q} x1 ::= x2 {Q}› 3. ‹⋀c1 c2 Q. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (c1;; c2) Q} c1;; c2 {Q}› 4. ‹⋀x1 c1 c2 Q. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 5. ‹⋀x1 c Q. (⋀Q. ⊢₂ {wp₂ c Q} c {Q}) ⟹ ⊢₂ {wp₂ (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case SKIP (*no hyothesis introduced yet*) show "?case" (*goal: ‹⊢₂ {wp₂ SKIP Q} SKIP {Q}›*) by (auto intro: hoare2.Skip (*‹⊢₂ {λs. eSuc (?P s)} SKIP {?P}›*)) next (*goals: 1. ‹⋀(x1::char list) (x2::aexp) Q::(char list ⇒ int) ⇒ enat. ⊢₂ {wp₂ (x1 ::= x2) Q} x1 ::= x2 {Q}› 2. ‹⋀(c1::com) (c2::com) Q::(char list ⇒ int) ⇒ enat. ⟦⋀Q::(char list ⇒ int) ⇒ enat. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q::(char list ⇒ int) ⇒ enat. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (c1;; c2) Q} c1;; c2 {Q}› 3. ‹⋀(x1::bexp) (c1::com) (c2::com) Q::(char list ⇒ int) ⇒ enat. ⟦⋀Q::(char list ⇒ int) ⇒ enat. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q::(char list ⇒ int) ⇒ enat. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 4. ‹⋀(x1::bexp) (c::com) Q::(char list ⇒ int) ⇒ enat. (⋀Q::(char list ⇒ int) ⇒ enat. ⊢₂ {wp₂ c Q} c {Q}) ⟹ ⊢₂ {wp₂ (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case Assign (*no hyothesis introduced yet*) show "?case" (*goal: ‹⊢₂ {wp₂ (x1_ ::= x2_) Q} x1_ ::= x2_ {Q}›*) by (auto intro:hoare2.Assign (*‹⊢₂ {λs. eSuc (?P (s[?a/?x]))} ?x ::= ?a {?P}›*)) next (*goals: 1. ‹⋀c1 c2 Q. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (c1;; c2) Q} c1;; c2 {Q}› 2. ‹⋀x1 c1 c2 Q. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 3. ‹⋀x1 c Q. (⋀Q. ⊢₂ {wp₂ c Q} c {Q}) ⟹ ⊢₂ {wp₂ (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case Seq (*‹⊢₂ {wp₂ c1_ ?Q} c1_ {?Q}› ‹⊢₂ {wp₂ (c2_::com) (?Q::(char list ⇒ int) ⇒ enat)} c2_ {?Q}›*) thus "?case" (*goal: ‹⊢₂ {wp₂ (c1_;; c2_) Q} c1_;; c2_ {Q}›*) by (auto intro:hoare2.Seq (*‹⟦⊢₂ {?P₁} ?c₁ {?P₂}; ⊢₂ {?P₂} ?c₂ {?P₃}⟧ ⟹ ⊢₂ {?P₁} ?c₁;; ?c₂ {?P₃}›*)) next (*goals: 1. ‹⋀x1 c1 c2 Q. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {wp₂ (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 2. ‹⋀x1 c Q. (⋀Q. ⊢₂ {wp₂ c Q} c {Q}) ⟹ ⊢₂ {wp₂ (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case (If x1 c1 c2 Q) (*‹⊢₂ {wp₂ c1 ?Q} c1 {?Q}› ‹⊢₂ {wp₂ (c2::com) (?Q::(char list ⇒ int) ⇒ enat)} c2 {?Q}›*) thus "?case" (*goal: ‹⊢₂ {wp₂ (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}›*) apply (auto intro!: hoare2.If (*‹⟦⊢₂ {λs. ?P s + ↑ (bval ?b s)} ?c₁ {?Q}; ⊢₂ {λs. ?P s + ↑ (¬ bval ?b s)} ?c₂ {?Q}⟧ ⟹ ⊢₂ {λs. eSuc (?P s)} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*)) (*goals: 1. ‹⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {λs. wp₂ (if bval x1 s then c1 else c2) Q s + ↑ (bval x1 s)} c1 {Q}› 2. ‹⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {λs. wp₂ (if bval x1 s then c1 else c2) Q s + ↑ (¬ bval x1 s)} c2 {Q}› discuss goal 1*) apply (rule hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goals: 1. ‹⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {?P5} c1 {?Q5}› 2. ‹⋀s. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ?P5 s ≤ wp₂ (if bval x1 s then c1 else c2) Q s + ↑ (bval x1 s)› 3. ‹⋀s. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ Q s ≤ ?Q5 s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*discuss goal 2*) apply (rule hoare2.conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goals: 1. ‹⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ⊢₂ {?P23} c2 {?Q23}› 2. ‹⋀s. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ ?P23 s ≤ wp₂ (if bval x1 s then c1 else c2) Q s + ↑ (¬ bval x1 s)› 3. ‹⋀s. ⟦⋀Q. ⊢₂ {wp₂ c1 Q} c1 {Q}; ⋀Q. ⊢₂ {wp₂ c2 Q} c2 {Q}⟧ ⟹ Q s ≤ ?Q23 s› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*proven 2 subgoals*) . next (*goal: ‹⋀x1 c Q. (⋀Q. ⊢₂ {wp₂ c Q} c {Q}) ⟹ ⊢₂ {wp₂ (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case (While b c) (*‹⊢₂ {wp₂ c ?Q} c {?Q}›*) show "?case" (*goal: ‹⊢₂ {wp₂ (WHILE b DO c) Q} WHILE b DO c {Q}›*) apply (rule conseq (*‹⟦⊢₂ {?P::(char list ⇒ int) ⇒ enat} ?c::com {?Q::(char list ⇒ int) ⇒ enat}; ⋀s::char list ⇒ int. ?P s ≤ (?P'::(char list ⇒ int) ⇒ enat) s; ⋀s::char list ⇒ int. (?Q'::(char list ⇒ int) ⇒ enat) s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*goal: ‹⊢₂ {wp₂ (WHILE b::bexp DO (c::com)) (Q::(char list ⇒ int) ⇒ enat)} WHILE b DO c {Q}›*) apply (rule hoare2.While[where I="%s. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s)"] (*‹⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (bval ?b s)} ?c {λt. (if bval b t then wp₂ c (wp₂ (WHILE b DO c) Q) t else Q t) + 1} ⟹ ⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + 1} WHILE ?b DO ?c {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (¬ bval ?b s)}›*)) (*top goal: ‹⊢₂ {?P} WHILE b DO c {?Q}› and 2 goals remain*) apply (rule conseq (*‹⟦⊢₂ {?P} ?c {?Q}; ⋀s. ?P s ≤ ?P' s; ⋀s. ?Q' s ≤ ?Q s⟧ ⟹ ⊢₂ {?P'} ?c {?Q'}›*)) (*top goal: ‹⊢₂ {λs. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (bval b s)} c {λt. (if bval b t then wp₂ c (wp₂ (WHILE b DO c) Q) t else Q t) + 1}› and 2 goals remain*) apply (rule While[of "wp₂ (WHILE b DO c) Q"] (*‹⊢₂ {wp₂ c (wp₂ (WHILE b DO c) Q)} c {wp₂ (WHILE b DO c) Q}›*)) (*top goal: ‹⊢₂ {?P6::(char list ⇒ int) ⇒ enat} c::com {?Q6::(char list ⇒ int) ⇒ enat}› and 4 goals remain*) using wp2While (*‹(if bval ?b ?s then wp₂ ?c (wp₂ (WHILE ?b DO ?c) ?Q) ?s else ?Q ?s) + 1 = wp₂ (WHILE ?b DO ?c) ?Q ?s›*) apply - (*goals: 1. ‹⋀s::char list ⇒ int. (⋀(b::bexp) (s::char list ⇒ int) (c::com) Q::(char list ⇒ int) ⇒ enat. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + (1::enat) = wp₂ (WHILE b DO c) Q s) ⟹ wp₂ (c::com) (wp₂ (WHILE b::bexp DO c) (Q::(char list ⇒ int) ⇒ enat)) s ≤ (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (bval b s)› 2. ‹⋀s::char list ⇒ int. (⋀(b::bexp) (s::char list ⇒ int) (c::com) Q::(char list ⇒ int) ⇒ enat. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + (1::enat) = wp₂ (WHILE b DO c) Q s) ⟹ (if bval (b::bexp) s then wp₂ (c::com) (wp₂ (WHILE b DO c) (Q::(char list ⇒ int) ⇒ enat)) s else Q s) + (1::enat) ≤ wp₂ (WHILE b DO c) Q s› 3. ‹⋀s::char list ⇒ int. (⋀(b::bexp) (s::char list ⇒ int) (c::com) Q::(char list ⇒ int) ⇒ enat. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + (1::enat) = wp₂ (WHILE b DO c) Q s) ⟹ (if bval (b::bexp) s then wp₂ (c::com) (wp₂ (WHILE b DO c) (Q::(char list ⇒ int) ⇒ enat)) s else Q s) + (1::enat) ≤ wp₂ (WHILE b DO c) Q s› 4. ‹⋀s::char list ⇒ int. (⋀(b::bexp) (s::char list ⇒ int) (c::com) Q::(char list ⇒ int) ⇒ enat. (if bval b s then wp₂ c (wp₂ (WHILE b DO c) Q) s else Q s) + (1::enat) = wp₂ (WHILE b DO c) Q s) ⟹ (Q::(char list ⇒ int) ⇒ enat) s ≤ (if bval (b::bexp) s then wp₂ (c::com) (wp₂ (WHILE b DO c) Q) s else Q s) + ↑ (¬ bval b s)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed lemma wp2_is_weakestprePotential1: "⊨₂ {P}c{Q} ⟹ (∀s. wp₂ c Q s ≤ P s)" apply (auto simp: hoare2_valid_def (*‹(⊨₂ {?P} ?c {?Q}) = (∀s. ?P s < ∞ ⟶ (∃t p. (?c, s) ⇒ p ⇓ t ∧ enat p + ?Q t ≤ ?P s))›*) wp2_def (*‹wp₂ ?c ?Q = (λs. if ∃t p. (?c, s) ⇒ p ⇓ t ∧ ?Q t < ∞ then enat (↓⇩t (?c, s)) + ?Q (↓⇩s (?c, s)) else ∞)›*)) (*goal: ‹⊨₂ {P} c {Q} ⟹ ∀s. wp₂ c Q s ≤ P s›*) proof (goal_cases) (*goals: 1. ‹⋀(s::char list ⇒ int) (t::char list ⇒ int) (p::nat) i::nat. ⟦∀s::char list ⇒ int. (∃i::nat. (P::(char list ⇒ int) ⇒ enat) s = enat i) ⟶ (∃(t::char list ⇒ int) p::nat. (c::com, s) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ P s); (c, s) ⇒ p ⇓ t; Q t = enat i⟧ ⟹ enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) ≤ P s› 2. ‹⋀s::char list ⇒ int. ⟦∀s::char list ⇒ int. (∃i::nat. (P::(char list ⇒ int) ⇒ enat) s = enat i) ⟶ (∃(t::char list ⇒ int) p::nat. (c::com, s) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ P s); ∀t::char list ⇒ int. (∀p::nat. ¬ (c, s) ⇒ p ⇓ t) ∨ Q t = ∞⟧ ⟹ P s = ∞›*) case (1 s t p i) (*‹∀s. (∃i. P s = enat i) ⟶ (∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ P s)› ‹(c, s) ⇒ p ⇓ t› ‹Q t = enat i›*) show "?case" (*goal: ‹enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) ≤ P s›*) proof (cases "P s < ∞") (*goals: 1. ‹(P::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) < ∞ ⟹ enat (↓⇩t (c::com, s)) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (c, s)) ≤ P s› 2. ‹¬ (P::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) < ∞ ⟹ enat (↓⇩t (c::com, s)) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (c, s)) ≤ P s›*) case True (*‹P s < ∞›*) with "1"(1) (*‹∀s. (∃i. P s = enat i) ⟶ (∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ P s)›*) obtain t and p' where i: "(c, s) ⇒ p' ⇓ t" and ii: "enat p' + Q t ≤ P s" (*goal: ‹(⋀p' t. ⟦(c, s) ⇒ p' ⇓ t; enat p' + Q t ≤ P s⟧ ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹enat (↓⇩t (c::com, s::char list ⇒ int)) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (c, s)) ≤ (P::(char list ⇒ int) ⇒ enat) s›*) by (simp add: bigstepT_the_state[OF i] (*‹↓⇩s (c, s) = t›*) bigstepT_the_cost[OF i] (*‹↓⇩t (c, s) = p'›*) ii (*‹enat p' + Q t ≤ P s›*)) qed (simp) (*solved the remaining goal: ‹¬ (P::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) < ∞ ⟹ enat (↓⇩t (c::com, s)) + (Q::(char list ⇒ int) ⇒ enat) (↓⇩s (c, s)) ≤ P s›*) qed (force) (*solved the remaining goal: ‹⋀s::char list ⇒ int. ⟦∀s::char list ⇒ int. (∃i::nat. (P::(char list ⇒ int) ⇒ enat) s = enat i) ⟶ (∃(t::char list ⇒ int) p::nat. (c::com, s) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ P s); ∀t::char list ⇒ int. (∀p::nat. ¬ (c, s) ⇒ p ⇓ t) ∨ Q t = ∞⟧ ⟹ P s = ∞›*) lemma wp2_is_weakestprePotential2: "(∀s. wp₂ c Q s ≤ P s) ⟹ ⊨₂ {P}c{Q}" apply (auto simp: hoare2_valid_def (*‹(⊨₂ {?P} ?c {?Q}) = (∀s. ?P s < ∞ ⟶ (∃t p. (?c, s) ⇒ p ⇓ t ∧ enat p + ?Q t ≤ ?P s))›*) wp2_def (*‹wp₂ ?c ?Q = (λs. if ∃t p. (?c, s) ⇒ p ⇓ t ∧ ?Q t < ∞ then enat (↓⇩t (?c, s)) + ?Q (↓⇩s (?c, s)) else ∞)›*)) (*goal: ‹∀s::char list ⇒ int. wp₂ (c::com) (Q::(char list ⇒ int) ⇒ enat) s ≤ (P::(char list ⇒ int) ⇒ enat) s ⟹ ⊨₂ {P} c {Q}›*) proof (goal_cases) (*goal: ‹⋀(s::char list ⇒ int) i::nat. ⟦∀s::char list ⇒ int. (if ∃t::char list ⇒ int. (∃p::nat. (c::com, s) ⇒ p ⇓ t) ∧ (∃i::nat. (Q::(char list ⇒ int) ⇒ enat) t = enat i) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞) ≤ (P::(char list ⇒ int) ⇒ enat) s; P s = enat i⟧ ⟹ ∃(t::char list ⇒ int) p::nat. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat i›*) case (1 s i) (*‹∀s::char list ⇒ int. (if ∃t::char list ⇒ int. (∃p::nat. (c::com, s) ⇒ p ⇓ t) ∧ (∃i::nat. (Q::(char list ⇒ int) ⇒ enat) t = enat i) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞) ≤ (P::(char list ⇒ int) ⇒ enat) s› ‹P s = enat i›*) then have A: "(if ∃t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i) then enat (THE p. Ex (big_step_t (c, s) p)) + Q (THE t. ∃p. (c, s) ⇒ p ⇓ t) else ∞) ≤ P s" by fast show "?case" (*goal: ‹∃(t::char list ⇒ int) p::nat. (c::com, s::char list ⇒ int) ⇒ p ⇓ t ∧ enat p + (Q::(char list ⇒ int) ⇒ enat) t ≤ enat (i::nat)›*) proof (cases "∃t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i)") (*goals: 1. ‹∃t::char list ⇒ int. (∃p::nat. (c::com, s::char list ⇒ int) ⇒ p ⇓ t) ∧ (∃i::nat. (Q::(char list ⇒ int) ⇒ enat) t = enat i) ⟹ ∃(t::char list ⇒ int) p::nat. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat (i::nat)› 2. ‹∄t::char list ⇒ int. (∃p::nat. (c::com, s::char list ⇒ int) ⇒ p ⇓ t) ∧ (∃i::nat. (Q::(char list ⇒ int) ⇒ enat) t = enat i) ⟹ ∃(t::char list ⇒ int) p::nat. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat (i::nat)›*) case True (*‹∃t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i)›*) then obtain t and p where i: "(c, s) ⇒ p ⇓ t" (*goal: ‹(⋀p t. (c, s) ⇒ p ⇓ t ⟹ thesis) ⟹ thesis›*) by blast from True (*‹∃t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i)›*) A (*‹(if ∃t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞) ≤ P s›*) have "enat p + Q t ≤ P s" by (simp add: bigstepT_the_cost[OF i] (*‹↓⇩t (c, s) = p›*) bigstepT_the_state[OF i] (*‹↓⇩s (c, s) = t›*)) then have "(c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat i" using "1"(2) (*‹(P::(char list ⇒ int) ⇒ enat) (s::char list ⇒ int) = enat (i::nat)›*) i (*‹(c, s) ⇒ p ⇓ t›*) by simp then show "?thesis" (*goal: ‹∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat i›*) by auto next (*goal: ‹∄t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i) ⟹ ∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat i›*) case False (*‹∄t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i)›*) with A (*‹(if ∃t. (∃p. (c, s) ⇒ p ⇓ t) ∧ (∃i. Q t = enat i) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞) ≤ P s›*) have "P s ≥ ∞" by auto then show "?thesis" (*goal: ‹∃t p. (c, s) ⇒ p ⇓ t ∧ enat p + Q t ≤ enat i›*) using "1" (*‹∀s::char list ⇒ int. (if ∃t::char list ⇒ int. (∃p::nat. (c::com, s) ⇒ p ⇓ t) ∧ (∃i::nat. (Q::(char list ⇒ int) ⇒ enat) t = enat i) then enat (↓⇩t (c, s)) + Q (↓⇩s (c, s)) else ∞) ≤ (P::(char list ⇒ int) ⇒ enat) s› ‹P s = enat i›*) by auto qed qed theorem wp2_is_weakestprePotential: "(∀s. wp₂ c Q s ≤ P s) ⟷ ⊨₂ {P}c{Q}" using wp2_is_weakestprePotential2 (*‹∀s. wp₂ ?c ?Q s ≤ ?P s ⟹ ⊨₂ {?P} ?c {?Q}›*) wp2_is_weakestprePotential1 (*‹⊨₂ {?P::(char list ⇒ int) ⇒ enat} ?c::com {?Q::(char list ⇒ int) ⇒ enat} ⟹ ∀s::char list ⇒ int. wp₂ ?c ?Q s ≤ ?P s›*) by metis theorem hoare2_complete: "⊨₂ {P}c{Q} ⟹ ⊢₂ {P}c{ Q}" apply (rule conseq[OF wp2_is_pre, where Q'=Q and Q=Q, simplified] (*‹(⋀s. wp₂ ?c Q s ≤ ?P' s) ⟹ ⊢₂ {?P'} ?c {Q}›*)) (*goal: ‹⊨₂ {P} c {Q} ⟹ ⊢₂ {P} c {Q}›*) using wp2_is_weakestprePotential1 (*‹⊨₂ {?P} ?c {?Q} ⟹ ∀s. wp₂ ?c ?Q s ≤ ?P s›*) by blast corollary hoare2_sound_complete: " ⊢₂ {P}c{Q} ⟷ ⊨₂ {P}c{ Q}" by (metis hoare2_sound (*‹⊢₂ {?P} ?c {?Q} ⟹ ⊨₂ {?P} ?c {?Q}›*) hoare2_complete (*‹⊨₂ {?P} ?c {?Q} ⟹ ⊢₂ {?P} ?c {?Q}›*)) end
{ "path": "afp-2025-02-12/thys/Hoare_Time/Quant_Hoare.thy", "repo": "afp-2025-02-12", "sha": "c3e83730d85bf46c399a830a496c47d6a07090981c0557d7ea6663030762eaea" }
(* Title: JinjaThreads/BV/JVMDeadlocked.thy Author: Andreas Lochbihler *) section ‹Preservation of deadlock for the JVMs› theory JVMDeadlocked imports BVProgressThreaded begin context JVM_progress begin lemma must_sync_preserved_d: assumes wf: "wf_jvm_prog⇘Φ⇙ P" and ml: "execd_mthr.must_sync P t (xcp, frs) h" and hext: "hext h h'" and hconf': "hconf h'" and cs: "Φ ⊢ t: (xcp, h, frs) √" shows "execd_mthr.must_sync P t (xcp, frs) h'" proof (rule execd_mthr.must_syncI (*‹∃ta x' m' s. execd_mthr.r_syntax ?P ?t ?x ?m ta x' m' ∧ exec_mthr.actions_ok s ?t ta ⟹ execd_mthr.must_sync ?P ?t ?x ?m›*)) (*goal: ‹∃ta x' m' s. execd_mthr.r_syntax P t (xcp, frs) h' ta x' m' ∧ exec_mthr.actions_ok s t ta›*) from ml (*‹execd_mthr.must_sync P t (xcp, frs) h›*) obtain ta and xcp' and frs' and m' where red: "P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', m', frs')" (*goal: ‹(⋀ta xcp' m' frs'. P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', m', frs') ⟹ thesis) ⟹ thesis›*) by (auto elim: execd_mthr.must_syncE (*‹⟦execd_mthr.must_sync (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?x::'addr::addr option × 'addr::addr frame list) (?m::'heap::type); ⋀(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (x'::'addr::addr option × 'addr::addr frame list) (m'::'heap::type) s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set. ⟦execd_mthr.r_syntax ?P ?t ?x ?m ta x' m'; exec_mthr.actions_ok s ?t ta; ?m = shr s⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) then obtain f and Frs where check: "check P (xcp, h, frs)" and exec: "(ta, xcp', m', frs') ∈ exec P t (xcp, h, frs)" and [simp]: "frs = f # Frs" (*goal: ‹(⋀f Frs. ⟦check P (xcp, h, frs); (ta, xcp', m', frs') ∈ exec P t (xcp, h, frs); frs = f # Frs⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim: jvmd_NormalE (*‹⟦?P,?t ⊢ Normal ?σ -?ta-jvmd→ Normal ?σ'; ⋀xcp h f frs. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) from cs (*‹Φ ⊢ t:(xcp, h, frs) √›*) hext (*‹h ⊴ h'›*) hconf' (*‹(hconf::'heap ⇒ bool) (h'::'heap)›*) have cs': "Φ ⊢ t: (xcp, h', frs) √" by (rule correct_state_hext_mono (*‹⟦?Φ ⊢ ?t:(?xcp, ?h, ?frs) √; ?h ⊴ ?h'; hconf ?h'⟧ ⟹ ?Φ ⊢ ?t:(?xcp, ?h', ?frs) √›*)) then obtain ta and σ' where exec: "P,t ⊢ (xcp, h', frs) -ta-jvm→ σ'" (*goal: ‹(⋀ta σ'. P,t ⊢ (xcp, h', frs) -ta-jvm→ σ' ⟹ thesis) ⟹ thesis›*) by (auto dest: progress[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?f # ?frs) √ ⟹ ∃ta σ'. P,?t ⊢ (?xcp, ?h, ?f # ?frs) -ta-jvm→ σ'›*)) hence "P,t ⊢ Normal (xcp, h', frs) -ta-jvmd→ Normal σ'" unfolding welltyped_commute[OF wf cs'] (*goal: ‹P,t ⊢ (xcp, h', frs) -ta-jvm→ σ'›*) . moreover from exec (*‹P,t ⊢ (xcp, h', frs) -ta-jvm→ σ'›*) have "∃s. exec_mthr.actions_ok s t ta" by (rule exec_ta_satisfiable (*‹P,?t ⊢ ?s -?ta-jvm→ ?s' ⟹ ∃s. exec_mthr.actions_ok s ?t ?ta›*)) ultimately show "∃ta x' m' s. mexecd P t ((xcp, frs), h') ta (x', m') ∧ exec_mthr.actions_ok s t ta" apply (cases σ') (*goal: ‹∃ta x' m' s. execd_mthr.r_syntax P t (xcp, frs) h' ta x' m' ∧ exec_mthr.actions_ok s t ta›*) by (fastforce simp del: split_paired_Ex (*‹(∃x. ?P x) = (∃a b. ?P (a, b))›*)) qed lemma can_sync_devreserp_d: assumes wf: "wf_jvm_prog⇘Φ⇙ P" and cl': "execd_mthr.can_sync P t (xcp, frs) h' L" and cs: "Φ ⊢ t: (xcp, h, frs) √" and hext: "hext h h'" and hconf': "hconf h'" shows "∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'" proof (-) (*goal: ‹∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'›*) from cl' (*‹execd_mthr.can_sync P t (xcp, frs) h' L›*) obtain ta and xcp' and frs' and m' where red: "P,t ⊢ Normal (xcp, h', frs) -ta-jvmd→ Normal (xcp', m', frs')" and L: "L = collect_locks ⦃ta⦄⇘l⇙ <+> collect_cond_actions ⦃ta⦄⇘c⇙ <+> collect_interrupts ⦃ta⦄⇘i⇙" (*goal: ‹(⋀ta xcp' m' frs'. ⟦P,t ⊢ Normal (xcp, h', frs) -ta-jvmd→ Normal (xcp', m', frs'); L = collect_waits ta⟧ ⟹ thesis) ⟹ thesis›*) apply - (*goal: ‹(⋀ta xcp' m' frs'. ⟦P,t ⊢ Normal (xcp, h', frs) -ta-jvmd→ Normal (xcp', m', frs'); L = collect_waits ta⟧ ⟹ thesis) ⟹ thesis›*) apply (erule execd_mthr.can_syncE (*‹⟦execd_mthr.can_sync ?P ?t ?x ?m ?LT; ⋀ta x' m'. ⟦execd_mthr.r_syntax ?P ?t ?x ?m ta x' m'; ?LT = collect_waits ta⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⟦⋀ta xcp' m' frs'. ⟦P,t ⊢ Normal (xcp, h', frs) -ta-jvmd→ Normal (xcp', m', frs'); L = collect_waits ta⟧ ⟹ thesis; execd_mthr.can_sync P t (xcp, frs) h' L⟧ ⟹ thesis›*) by auto then obtain f and Frs where check: "check P (xcp, h', frs)" and exec: "(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs)" and [simp]: "frs = f # Frs" (*goal: ‹(⋀f Frs. ⟦check P (xcp, h', frs); (ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); frs = f # Frs⟧ ⟹ thesis) ⟹ thesis›*) by (auto elim: jvmd_NormalE (*‹⟦?P,?t ⊢ Normal ?σ -?ta-jvmd→ Normal ?σ'; ⋀xcp h f frs. ⟦check ?P ?σ; (?ta, ?σ') ∈ exec ?P ?t ?σ; ?σ = (xcp, h, f # frs)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) simp add: finfun_upd_apply (*‹?f(?a $:= ?b) $ ?a' = (if ?a = ?a' then ?b else ?f $ ?a')›*)) obtain stk and loc and C and M and pc where [simp]: "f = (stk, loc, C, M, pc)" (*goal: ‹(⋀stk loc C M pc. f = (stk, loc, C, M, pc) ⟹ thesis) ⟹ thesis›*) apply (cases f) (*goal: ‹(⋀(stk::'addr::addr val list) (loc::'addr::addr val list) (C::String.literal) (M::String.literal) pc::nat. (f::'addr::addr frame) = (stk, loc, C, M, pc) ⟹ thesis::bool) ⟹ thesis›*) by blast from cs (*‹Φ ⊢ t:(xcp, h, frs) √›*) obtain ST and LT and Ts and T and mxs and mxl and ins and xt where hconf: "hconf h" and tconf: "P,h ⊢ t √t" and meth: "P ⊢ C sees M:Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C" and "Φ": "Φ C M ! pc = Some (ST,LT)" and frame: "conf_f P h (ST,LT) ins (stk,loc,C,M,pc)" and frames: "conf_fs P h Φ M (size Ts) T Frs" (*goal: ‹(⋀Ts T mxs mxl ins xt ST LT. ⟦hconf h; P,h ⊢ t √t; P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; Φ C M ! pc = ⌊(ST, LT)⌋; conf_f P h (ST, LT) ins (stk, loc, C, M, pc); conf_fs P h Φ M (length Ts) T Frs⟧ ⟹ thesis) ⟹ thesis›*) by (fastforce simp add: correct_state_def (*‹correct_state ?Φ ?t ≡ λ(xp, h, frs). P,h ⊢ ?t √t ∧ hconf h ∧ preallocated h ∧ (case frs of [] ⇒ True | f # fs ⇒ let (stk, loc, C, M, pc) = f in ∃Ts T mxs mxl₀ is xt τ. P ⊢ C sees M: Ts→T = ⌊(mxs, mxl₀, is, xt)⌋ in C ∧ ?Φ C M ! pc = ⌊τ⌋ ∧ conf_f P h τ is f ∧ conf_fs P h ?Φ M (length Ts) T fs ∧ conf_xcp P h xp (is ! pc))›*) dest: sees_method_fun (*‹⟦?P ⊢ ?C sees ?M: ?TS→?T = ?m in ?D; ?P ⊢ ?C sees ?M: ?TS'→?T' = ?m' in ?D'⟧ ⟹ ?TS' = ?TS ∧ ?T' = ?T ∧ ?m' = ?m ∧ ?D' = ?D›*)) from cs (*‹Φ ⊢ t:(xcp, h, frs) √›*) have "exec P t (xcp, h, f # Frs) ≠ {}" by (auto dest!: progress[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?f # ?frs) √ ⟹ ∃ta σ'. P,?t ⊢ (?xcp, ?h, ?f # ?frs) -ta-jvm→ σ'›*) simp add: exec_1_iff (*‹?P,?t ⊢ ?σ -?ta-jvm→ ?σ' = ((?ta, ?σ') ∈ exec ?P ?t ?σ)›*)) with no_type_error[OF wf cs] (*‹exec_d P t (xcp, h, frs) ≠ TypeError›*) have check': "check P (xcp, h, frs)" by (auto simp add: exec_d_def (*‹exec_d ?P ?t ?σ ≡ if check ?P ?σ then Normal (exec ?P ?t ?σ) else TypeError›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) from wf (*‹wf_jvm_prog⇘Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list⇙ (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog)›*) obtain wfmd where wfp: "wf_prog wfmd P" (*goal: ‹(⋀wfmd. wf_prog wfmd P ⟹ thesis) ⟹ thesis›*) by (auto dest: wt_jvm_progD (*‹wf_jvm_prog⇘?Φ⇙ ?P ⟹ ∃wt. wf_prog wt ?P›*)) from tconf (*‹P,h ⊢ t √t›*) hext (*‹h ⊴ h'›*) have tconf': "P,h' ⊢ t √t" by (rule tconf_hext_mono (*‹⟦(P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(?h::'heap::type) ⊢ (?t::'thread_id::type) √t; ?h ⊴ (?h'::'heap::type)⟧ ⟹ P,?h' ⊢ ?t √t›*)) show "?thesis" (*goal: ‹∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'›*) proof (cases xcp) (*goals: 1. ‹(xcp::'addr option) = None ⟹ ∃L'⊆L::('addr + 'thread_id + 'thread_id) set. execd_mthr.can_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp, frs::'addr frame list) (h::'heap) L'› 2. ‹⋀a::'addr. (xcp::'addr option) = ⌊a⌋ ⟹ ∃L'⊆L::('addr + 'thread_id + 'thread_id) set. execd_mthr.can_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp, frs::'addr frame list) (h::'heap) L'›*) case [simp]: (Some a) (*‹(xcp::'addr::addr option) = ⌊a::'addr::addr⌋›*) with exec (*‹(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs)›*) have [simp]: "m' = h'" by auto from ‹Φ ⊢ t: (xcp, h, frs) √› (*‹Φ ⊢ t:(xcp, h, frs) √›*) obtain D where D: "typeof_addr h a = ⌊Class_type D⌋" (*goal: ‹(⋀D. typeof_addr h a = ⌊Class_type D⌋ ⟹ thesis) ⟹ thesis›*) by (auto simp add: correct_state_def (*‹correct_state (?Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) (?t::'thread_id::type) ≡ λ(xp::'addr::addr option, h::'heap::type, frs::'addr::addr frame list). (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),h ⊢ ?t √t ∧ (hconf::'heap::type ⇒ bool) h ∧ preallocated h ∧ (case frs of [] ⇒ True | (f::'addr::addr frame) # (fs::'addr::addr frame list) ⇒ let (stk::'addr::addr val list, loc::'addr::addr val list, C::String.literal, M::String.literal, pc::nat) = f in ∃(Ts::ty list) (T::ty) (mxs::nat) (mxl₀::nat) (is::'addr::addr instr list) (xt::(nat × nat × String.literal option × nat × nat) list) τ::ty list × ty err list. P ⊢ C sees M: Ts→T = ⌊(mxs, mxl₀, is, xt)⌋ in C ∧ ?Φ C M ! pc = ⌊τ⌋ ∧ conf_f P h τ is f ∧ conf_fs P h ?Φ M (length Ts) T fs ∧ conf_xcp P h xp (is ! pc))›*)) with hext (*‹h ⊴ h'›*) have "cname_of h a = cname_of h' a" by (auto dest: hext_objD (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊Class_type ?C⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊Class_type ?C⌋›*) simp add: cname_of_def (*‹cname_of ?h ?a = the_Class (ty_of_htype (the (typeof_addr ?h ?a)))›*)) with exec (*‹(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs)›*) have "(ta, xcp', h, frs') ∈ exec P t (xcp, h, frs)" by auto moreover from check (*‹check P (xcp, h', frs)›*) D (*‹typeof_addr h a = ⌊Class_type D⌋›*) hext (*‹h ⊴ h'›*) have "check P (xcp, h, frs)" by (auto simp add: check_def (*‹check (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?σ::'addr option × 'heap × 'addr frame list) ≡ let (xcpt::'addr option, h::'heap, frs::'addr frame list) = ?σ in case frs of [] ⇒ True | (stk::'addr val list, loc::'addr val list, C::String.literal, M::String.literal, pc::nat) # (frs'::'addr frame list) ⇒ ?P ⊢ C has M ∧ (let (C'::String.literal, Ts::ty list, T::ty, meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = method ?P C M; (mxs::nat, mxl₀::nat, ins::'addr instr list, xt::(nat × nat × String.literal option × nat × nat) list) = the meth; i::'addr instr = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a::'addr⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) check_xcpt_def (*‹check_xcpt (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?h::'heap) (?n::nat) (?pc::nat) (?xt::(nat × nat × String.literal option × nat × nat) list) (?a::'addr) = (∃C::String.literal. (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h ?a = ⌊Class_type C⌋ ∧ (case match_ex_table ?P C ?pc ?xt of None ⇒ True | ⌊(pc'::nat, d'::nat)⌋ ⇒ d' ≤ ?n))›*) dest: hext_objD (*‹⟦(?h::'heap) ⊴ (?h'::'heap); (typeof_addr::'heap ⇒ 'addr ⇒ htype option) ?h (?a::'addr) = ⌊Class_type (?C::String.literal)⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊Class_type ?C⌋›*)) ultimately have "P,t ⊢ Normal (xcp, h, frs) -ta-jvmd→ Normal (xcp', h, frs')" apply - (*goal: ‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),t::'thread_id ⊢ Normal (xcp::'addr option, h::'heap, frs::'addr frame list) -ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvmd→ Normal (xcp'::'addr option, h, frs'::'addr frame list)›*) apply (rule exec_1_d_NormalI (*‹⟦exec_d (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?σ::'addr::addr option × 'heap::type × 'addr::addr frame list) = Normal (?Σ::(('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action × 'addr::addr option × 'heap::type × 'addr::addr frame list) set); (?tas::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, ?σ'::'addr::addr option × 'heap::type × 'addr::addr frame list) ∈ ?Σ⟧ ⟹ ?P,?t ⊢ Normal ?σ -?tas-jvmd→ Normal ?σ'›*)) (*goals: 1. ‹⟦(ta, xcp', h, frs') ∈ exec P t (xcp, h, frs); check P (xcp, h, frs)⟧ ⟹ exec_d P t (xcp, h, frs) = Normal ?Σ2› 2. ‹⟦(ta, xcp', h, frs') ∈ exec P t (xcp, h, frs); check P (xcp, h, frs)⟧ ⟹ (ta, xcp', h, frs') ∈ ?Σ2› discuss goal 1*) apply (simp only: exec_d_def (*‹exec_d (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?σ::'addr option × 'heap × 'addr frame list) ≡ if check ?P ?σ then Normal (exec ?P ?t ?σ) else TypeError›*) if_True (*‹(if True then ?x::?'a else (?y::?'a)) = ?x›*)) (*discuss goal 2*) . (*proven 2 subgoals*) with L (*‹L = collect_waits ta›*) have "execd_mthr.can_sync P t (xcp, frs) h L" by (auto intro: execd_mthr.can_syncI (*‹⟦execd_mthr.r_syntax ?P ?t ?x ?m ?ta ?x' ?m'; ?LT = collect_waits ?ta⟧ ⟹ execd_mthr.can_sync ?P ?t ?x ?m ?LT›*)) thus "?thesis" (*goal: ‹∃L'⊆L::('addr + 'thread_id + 'thread_id) set. execd_mthr.can_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp::'addr option, frs::'addr frame list) (h::'heap) L'›*) by auto next (*goal: ‹xcp = None ⟹ ∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'›*) case [simp]: None (*‹(xcp::'addr option) = None›*) note [simp] = defs1 (*‹correct_state ?Φ ?t ≡ λ(xp, h, frs). P,h ⊢ ?t √t ∧ hconf h ∧ preallocated h ∧ (case frs of [] ⇒ True | f # fs ⇒ let (stk, loc, C, M, pc) = f in ∃Ts T mxs mxl₀ is xt τ. P ⊢ C sees M: Ts→T = ⌊(mxs, mxl₀, is, xt)⌋ in C ∧ ?Φ C M ! pc = ⌊τ⌋ ∧ conf_f P h τ is f ∧ conf_fs P h ?Φ M (length Ts) T fs ∧ conf_xcp P h xp (is ! pc))› ‹conf_f ?P ?h ≡ λ(ST, LT) is (stk, loc, C, M, pc). ?P,?h ⊢ stk [:≤] ST ∧ ?P,?h ⊢ loc [:≤⇩⊤] LT ∧ pc < length is› ‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::(nat × nat × String.literal option × nat × nat) list ⊢ ?i::?'addr instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹eff ?i ?P ?pc ?et ?t ≡ case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et› ‹norm_eff ?i ?P ?pc ?τ ≡ map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)› ‹app (?i::?'addr::type instr) (?P::?'m::type prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::(ty list × ty err list) option) ≡ case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc)› ‹xcpt_app ?i ?P ?pc ?mxs ?xt ?τ ≡ ∀(f, t, C, h, d)∈set (relevant_entries ?P ?i ?pc ?xt). (case C of None ⇒ True | ⌊C'⌋ ⇒ is_class ?P C') ∧ d ≤ length (fst ?τ) ∧ d < ?mxs›*) list_all2_Cons2 (*‹list_all2 (?P::?'a::type ⇒ ?'b::type ⇒ bool) (?xs::?'a::type list) ((?y::?'b::type) # (?ys::?'b::type list)) = (∃(z::?'a::type) zs::?'a::type list. ?xs = z # zs ∧ ?P z ?y ∧ list_all2 ?P zs ?ys)›*) from frame (*‹conf_f P h (ST, LT) ins (stk, loc, C, M, pc)›*) have ST: "P,h ⊢ stk [:≤] ST" and LT: "P,h ⊢ loc [:≤⇩⊤] LT" and pc: "pc < length ins" apply - (*goals: 1. ‹conf_f P h (ST, LT) ins (stk, loc, C, M, pc) ⟹ P,h ⊢ stk [:≤] ST› 2. ‹conf_f P h (ST, LT) ins (stk, loc, C, M, pc) ⟹ P,h ⊢ loc [:≤⇩⊤] LT› 3. ‹conf_f P h (ST, LT) ins (stk, loc, C, M, pc) ⟹ pc < length ins› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . from wf (*‹wf_jvm_prog⇘Φ⇙ P›*) meth (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ (C::String.literal) sees (M::String.literal): (Ts::ty list)→(T::ty) = ⌊(mxs::nat, mxl::nat, ins::'addr instr list, xt::(nat × nat × String.literal option × nat × nat) list)⌋ in C›*) pc (*‹(pc::nat) < length (ins::'addr instr list)›*) have wt: "P,T,mxs,size ins,xt ⊢ ins!pc,pc :: Φ C M" by (rule wt_jvm_prog_impl_wt_instr (*‹⟦wf_jvm_prog⇘?Φ⇙ ?P; ?P ⊢ ?C sees ?M: ?Ts→?T = ⌊(?mxs, ?mxl₀, ?ins, ?xt)⌋ in ?C; ?pc < length ?ins⟧ ⟹ ?P,?T,?mxs,length ?ins,?xt ⊢ ?ins ! ?pc,?pc :: ?Φ ?C ?M›*)) from ‹Φ ⊢ t: (xcp, h, frs) √› (*‹Φ ⊢ t:(xcp, h, frs) √›*) have "∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'" by (auto dest: progress[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?f # ?frs) √ ⟹ ∃ta σ'. P,?t ⊢ (?xcp, ?h, ?f # ?frs) -ta-jvm→ σ'›*) simp del: correct_state_def (*‹correct_state ?Φ ?t ≡ λ(xp, h, frs). P,h ⊢ ?t √t ∧ hconf h ∧ preallocated h ∧ (case frs of [] ⇒ True | f # fs ⇒ let (stk, loc, C, M, pc) = f in ∃Ts T mxs mxl₀ is xt τ. P ⊢ C sees M: Ts→T = ⌊(mxs, mxl₀, is, xt)⌋ in C ∧ ?Φ C M ! pc = ⌊τ⌋ ∧ conf_f P h τ is f ∧ conf_fs P h ?Φ M (length Ts) T fs ∧ conf_xcp P h xp (is ! pc))›*) split_paired_Ex (*‹(∃x. ?P x) = (∃a b. ?P (a, b))›*)) with exec (*‹(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs)›*) meth (*‹P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C›*) have "∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙" proof (cases "ins ! pc") (*goals: 1. ‹⋀x1. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Load x1⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 2. ‹⋀x2. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Store x2⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 3. ‹⋀x3. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Push x3⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 4. ‹⋀x4. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = New x4⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 5. ‹⋀x5. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = NewArray x5⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 6. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = ALoad⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 7. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = AStore⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 8. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = ALength⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 9. ‹⋀x91 x92. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Getfield x91 x92⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 10. ‹⋀x101 x102. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Putfield x101 x102⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 11. ‹⋀x111 x112. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = CAS x111 x112⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 12. ‹⋀x12. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Checkcast x12⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 13. ‹⋀x13. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Instanceof x13⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 14. ‹⋀x141 x142. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Invoke x141 x142⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 15. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Return⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 16. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Pop⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 17. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Dup⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 18. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Swap⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 19. ‹⋀x19. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = BinOpInstr x19⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 20. ‹⋀x20. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Goto x20⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 21. ‹⋀x21. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = IfFalse x21⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 22. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = ThrowExc⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 23. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = MEnter⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 24. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = MExit⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) case (Invoke M' n) (*‹ins ! pc = Invoke M' n›*) show "?thesis" (*goal: ‹∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) proof (cases "stk ! n = Null") (*goals: 1. ‹stk ! n = Null ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 2. ‹stk ! n ≠ Null ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) case True (*‹stk ! n = Null›*) with Invoke (*‹ins ! pc = Invoke M' n›*) exec (*‹(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, m'::'heap::type, frs'::'addr::addr frame list) ∈ exec (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (xcp::'addr::addr option, h'::'heap::type, frs::'addr::addr frame list)›*) meth (*‹(P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ (C::String.literal) sees (M::String.literal): (Ts::ty list)→(T::ty) = ⌊(mxs::nat, mxl::nat, ins::'addr::addr instr list, xt::(nat × nat × String.literal option × nat × nat) list)⌋ in C›*) show "?thesis" (*goal: ‹∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) by simp next (*goal: ‹stk ! n ≠ Null ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) case False (*‹stk ! n ≠ Null›*) with check (*‹check (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (xcp::'addr::addr option, h'::'heap::type, frs::'addr::addr frame list)›*) meth (*‹P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C›*) obtain a where a: "stk ! n = Addr a" and n: "n < length stk" (*goal: ‹(⋀a::'addr::addr. ⟦(stk::'addr::addr val list) ! (n::nat) = Addr a; n < length stk⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: check_def (*‹check ?P ?σ ≡ let (xcpt, h, frs) = ?σ in case frs of [] ⇒ True | (stk, loc, C, M, pc) # frs' ⇒ ?P ⊢ C has M ∧ (let (C', Ts, T, meth) = method ?P C M; (mxs, mxl₀, ins, xt) = the meth; i = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) is_Ref_def (*‹is_Ref ?v ≡ ?v = Null ∨ is_Addr ?v›*) Invoke (*‹ins ! pc = Invoke M' n›*)) from frame (*‹conf_f P h (ST, LT) ins (stk, loc, C, M, pc)›*) have stk: "P,h ⊢ stk [:≤] ST" by (auto simp add: conf_f_def (*‹conf_f ?P ?h ≡ λ(ST, LT) is (stk, loc, C, M, pc). ?P,?h ⊢ stk [:≤] ST ∧ ?P,?h ⊢ loc [:≤⇩⊤] LT ∧ pc < length is›*)) hence "P,h ⊢ stk ! n :≤ ST ! n" using n (*‹n < length stk›*) by (rule list_all2_nthD (*‹⟦list_all2 ?P ?xs ?ys; ?p < length ?xs⟧ ⟹ ?P (?xs ! ?p) (?ys ! ?p)›*)) with a (*‹stk ! n = Addr a›*) obtain ao and Ta where Ta: "typeof_addr h a = ⌊Ta⌋" (*goal: ‹(⋀Ta. typeof_addr h a = ⌊Ta⌋ ⟹ thesis) ⟹ thesis›*) by (auto simp add: conf_def (*‹?P,?h ⊢ ?v :≤ ?T ≡ ∃T'. typeof⇘?h⇙ ?v = ⌊T'⌋ ∧ ?P ⊢ T' ≤ ?T›*)) from hext (*‹(h::'heap::type) ⊴ (h'::'heap::type)›*) Ta (*‹typeof_addr h a = ⌊Ta⌋›*) have Ta': "typeof_addr h' a = ⌊Ta⌋" by (rule typeof_addr_hext_mono (*‹⟦?h ⊴ ?h'; typeof_addr ?h ?a = ⌊?hT⌋⟧ ⟹ typeof_addr ?h' ?a = ⌊?hT⌋›*)) with check (*‹check P (xcp, h', frs)›*) a (*‹stk ! n = Addr a›*) meth (*‹P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C›*) Invoke (*‹ins ! pc = Invoke M' n›*) False (*‹stk ! n ≠ Null›*) obtain D and Ts' and T' and meth and D' where C: "D = class_type_of Ta" and sees': "P ⊢ D sees M':Ts'→T' = meth in D'" and params: "P,h' ⊢ rev (take n stk) [:≤] Ts'" (*goal: ‹(⋀(D::String.literal) (Ts'::ty list) (T'::ty) (meth::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) option) D'::String.literal. ⟦D = class_type_of (Ta::htype); (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ D sees (M'::String.literal): Ts'→T' = meth in D'; P,(h'::'heap::type) ⊢ rev (take (n::nat) (stk::'addr::addr val list)) [:≤] Ts'⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp add: check_def (*‹check ?P ?σ ≡ let (xcpt, h, frs) = ?σ in case frs of [] ⇒ True | (stk, loc, C, M, pc) # frs' ⇒ ?P ⊢ C has M ∧ (let (C', Ts, T, meth) = method ?P C M; (mxs, mxl₀, ins, xt) = the meth; i = ins ! pc in meth ≠ None ∧ pc < length ins ∧ length stk ≤ mxs ∧ (case xcpt of None ⇒ check_instr i ?P h stk loc C M pc frs' | ⌊a⌋ ⇒ check_xcpt ?P h (length stk) pc xt a))›*) has_method_def (*‹?P ⊢ ?C has ?M ≡ ∃Ts T m D. ?P ⊢ ?C sees ?M: Ts→T = m in D›*)) show "?thesis" (*goal: ‹∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) proof (cases "meth") (*goals: 1. ‹meth = None ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 2. ‹⋀a. meth = ⌊a⌋ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) case Some (*‹meth = ⌊a_⌋›*) with exec (*‹(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, m'::'heap::type, frs'::'addr::addr frame list) ∈ exec (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (xcp::'addr::addr option, h'::'heap::type, frs::'addr::addr frame list)›*) meth (*‹P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C›*) a (*‹stk ! n = Addr a›*) Ta (*‹typeof_addr h a = ⌊Ta⌋›*) Ta' (*‹typeof_addr h' a = ⌊Ta⌋›*) Invoke (*‹ins ! pc = Invoke M' n›*) n (*‹n < length stk›*) sees' (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ (D::String.literal) sees (M'::String.literal): (Ts'::ty list)→(T'::ty) = (meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) in (D'::String.literal)›*) C (*‹(D::String.literal) = class_type_of (Ta::htype)›*) show "?thesis" (*goal: ‹∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) by (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) next (*goal: ‹meth = None ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) case None (*‹(meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) = None›*) with exec (*‹(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, m'::'heap, frs'::'addr frame list) ∈ exec (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp::'addr option, h'::'heap, frs::'addr frame list)›*) meth (*‹P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C›*) a (*‹stk ! n = Addr a›*) Ta (*‹typeof_addr h a = ⌊Ta⌋›*) Ta' (*‹typeof_addr h' a = ⌊Ta⌋›*) Invoke (*‹ins ! pc = Invoke M' n›*) n (*‹n < length stk›*) sees' (*‹P ⊢ D sees M': Ts'→T' = meth in D'›*) C (*‹D = class_type_of Ta›*) obtain ta' and va and h'' where ta': "ta = extTA2JVM P ta'" and va: "(xcp', m', frs') = extRet2JVM n h'' stk loc C M pc Frs va" and exec': "(ta', va, h'') ∈ red_external_aggr P t a M' (rev (take n stk)) h'" (*goal: ‹(⋀ta' h'' va. ⟦ta = extTA2JVM P ta'; (xcp', m', frs') = extRet2JVM n h'' stk loc C M pc Frs va; (ta', va, h'') ∈ red_external_aggr P t a M' (rev (take n stk)) h'⟧ ⟹ thesis) ⟹ thesis›*) by fastforce from va (*‹(xcp', m', frs') = extRet2JVM n h'' stk loc C M pc Frs va›*) have [simp]: "h'' = m'" apply (cases va) (*goals: 1. ‹⋀x1::'addr::addr val. ⟦(xcp'::'addr::addr option, m'::'heap::type, frs'::'addr::addr frame list) = extRet2JVM (n::nat) (h''::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) (C::String.literal) (M::String.literal) (pc::nat) (Frs::'addr::addr frame list) (va::'addr::addr extCallRet); va = RetVal x1⟧ ⟹ h'' = m'› 2. ‹⋀x2::'addr::addr. ⟦(xcp'::'addr::addr option, m'::'heap::type, frs'::'addr::addr frame list) = extRet2JVM (n::nat) (h''::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) (C::String.literal) (M::String.literal) (pc::nat) (Frs::'addr::addr frame list) (va::'addr::addr extCallRet); va = RetExc x2⟧ ⟹ h'' = m'› 3. ‹⟦(xcp'::'addr::addr option, m'::'heap::type, frs'::'addr::addr frame list) = extRet2JVM (n::nat) (h''::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) (C::String.literal) (M::String.literal) (pc::nat) (Frs::'addr::addr frame list) (va::'addr::addr extCallRet); va = RetStaySame⟧ ⟹ h'' = m'› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . note Ta (*‹typeof_addr h a = ⌊Ta⌋›*) moreover from None (*‹meth = None›*) sees' (*‹P ⊢ D sees M': Ts'→T' = meth in D'›*) wfp (*‹wf_prog (wfmd::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ String.literal ⇒ (nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) mdecl ⇒ bool) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog)›*) have "D'∙M'(Ts') :: T'" by (auto intro: sees_wf_native (*‹⟦wf_prog ?wf_md ?P; ?P ⊢ ?C sees ?M: ?Ts→?T = Native in ?D⟧ ⟹ ?D∙?M(?Ts) :: ?T›*)) with C (*‹D = class_type_of Ta›*) sees' (*‹P ⊢ D sees M': Ts'→T' = meth in D'›*) params (*‹P,h' ⊢ rev (take n stk) [:≤] Ts'›*) Ta' (*‹typeof_addr h' a = ⌊Ta⌋›*) None (*‹meth = None›*) have "P,h' ⊢ a∙M'(rev (take n stk)) : T'" by (auto simp add: external_WT'_iff (*‹?P,?h ⊢ ?a∙?M(?vs) : ?U = (∃hT Ts Ts' D. typeof_addr ?h ?a = ⌊hT⌋ ∧ map typeof⇘?h⇙ ?vs = map Some Ts ∧ ?P ⊢ class_type_of hT sees ?M: Ts'→?U = Native in D ∧ ?P ⊢ Ts [≤] Ts')›*) confs_conv_map (*‹(?P,?h ⊢ ?vs [:≤] ?Ts') = (∃Ts. map typeof⇘?h⇙ ?vs = map Some Ts ∧ ?P ⊢ Ts [≤] ?Ts')›*)) with wfp (*‹wf_prog wfmd P›*) exec' (*‹(ta', va, h'') ∈ red_external_aggr P t a M' (rev (take n stk)) h'›*) tconf' (*‹(P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),(h'::'heap::type) ⊢ (t::'thread_id::type) √t›*) have red: "P,t ⊢ ⟨a∙M'(rev (take n stk)), h'⟩ -ta'→ext ⟨va, m'⟩" by (simp add: WT_red_external_list_conv (*‹⟦wf_prog ?wf_md ?P; ?P,?h ⊢ ?a∙?M(?vs) : ?U; ?P,?h ⊢ ?t √t⟧ ⟹ ?P,?t ⊢ ⟨?a∙?M(?vs),?h⟩ -?ta→ext ⟨?va,?h'⟩ = ((?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h)›*)) from stk (*‹P,h ⊢ stk [:≤] ST›*) have "P,h ⊢ take n stk [:≤] take n ST" by (rule list_all2_takeI (*‹list_all2 ?P ?xs ?ys ⟹ list_all2 ?P (take ?n ?xs) (take ?n ?ys)›*)) then obtain Ts where "map typeof⇘h⇙ (take n stk) = map Some Ts" (*goal: ‹(⋀Ts. map typeof⇘h⇙ (take n stk) = map Some Ts ⟹ thesis) ⟹ thesis›*) by (auto simp add: confs_conv_map (*‹(?P,?h ⊢ ?vs [:≤] ?Ts') = (∃Ts. map typeof⇘?h⇙ ?vs = map Some Ts ∧ ?P ⊢ Ts [≤] ?Ts')›*)) hence "map typeof⇘h⇙ (rev (take n stk)) = map Some (rev Ts)" by (simp only: rev_map[symmetric] (*‹map ?f (rev ?xs) = rev (map ?f ?xs)›*)) moreover hence "map typeof⇘h'⇙ (rev (take n stk)) = map Some (rev Ts)" using hext (*‹h ⊴ h'›*) by (rule map_typeof_hext_mono (*‹⟦map typeof⇘?h⇙ ?vs = map Some ?Ts; ?h ⊴ ?h'⟧ ⟹ map typeof⇘?h'⇙ ?vs = map Some ?Ts›*)) with ‹P,h' ⊢ a∙M'(rev (take n stk)) : T'› (*‹P,h' ⊢ a∙M'(rev (take n stk)) : T'›*) ‹D'∙M'(Ts') :: T'› (*‹D'∙M'(Ts') :: T'›*) sees' (*‹P ⊢ D sees M': Ts'→T' = meth in D'›*) C (*‹D = class_type_of Ta›*) Ta' (*‹typeof_addr h' a = ⌊Ta⌋›*) Ta (*‹typeof_addr h a = ⌊Ta⌋›*) have "P ⊢ rev Ts [≤] Ts'" apply cases (*goal: ‹P ⊢ rev Ts [≤] Ts'›*) by (auto dest: sees_method_fun (*‹⟦?P ⊢ ?C sees ?M: ?TS→?T = ?m in ?D; ?P ⊢ ?C sees ?M: ?TS'→?T' = ?m' in ?D'⟧ ⟹ ?TS' = ?TS ∧ ?T' = ?T ∧ ?m' = ?m ∧ ?D' = ?D›*)) ultimately have "P,h ⊢ a∙M'(rev (take n stk)) : T'" using Ta (*‹typeof_addr h a = ⌊Ta⌋›*) C (*‹D = class_type_of Ta›*) sees' (*‹P ⊢ D sees M': Ts'→T' = meth in D'›*) params (*‹P,h' ⊢ rev (take n stk) [:≤] Ts'›*) None (*‹meth = None›*) ‹D'∙M'(Ts') :: T'› (*‹D'∙M'(Ts') :: T'›*) by (auto simp add: external_WT'_iff (*‹?P,?h ⊢ ?a∙?M(?vs) : ?U = (∃hT Ts Ts' D. typeof_addr ?h ?a = ⌊hT⌋ ∧ map typeof⇘?h⇙ ?vs = map Some Ts ∧ ?P ⊢ class_type_of hT sees ?M: Ts'→?U = Native in D ∧ ?P ⊢ Ts [≤] Ts')›*) confs_conv_map (*‹(?P,?h ⊢ ?vs [:≤] ?Ts') = (∃Ts. map typeof⇘?h⇙ ?vs = map Some Ts ∧ ?P ⊢ Ts [≤] ?Ts')›*)) from red_external_wt_hconf_hext[OF wfp red hext this tconf hconf] (*‹∃ta'a va' h'''. P,t ⊢ ⟨a∙M'(rev (take n stk)),h⟩ -ta'a→ext ⟨va',h'''⟩ ∧ collect_locks ⦃ta'⦄⇘l⇙ = collect_locks ⦃ta'a⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ = collect_cond_actions ⦃ta'a⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ = collect_interrupts ⦃ta'a⦄⇘i⇙›*) obtain ta'' and va' and h''' where "P,t ⊢ ⟨a∙M'(rev (take n stk)),h⟩ -ta''→ext ⟨va',h'''⟩" and ta'': "collect_locks ⦃ta''⦄⇘l⇙ = collect_locks ⦃ta'⦄⇘l⇙" "collect_cond_actions ⦃ta''⦄⇘c⇙ = collect_cond_actions ⦃ta'⦄⇘c⇙" "collect_interrupts ⦃ta''⦄⇘i⇙ = collect_interrupts ⦃ta'⦄⇘i⇙" (*goal: ‹(⋀ta'' va' h'''. ⟦P,t ⊢ ⟨a∙M'(rev (take n stk)),h⟩ -ta''→ext ⟨va',h'''⟩; collect_locks ⦃ta''⦄⇘l⇙ = collect_locks ⦃ta'⦄⇘l⇙; collect_cond_actions ⦃ta''⦄⇘c⇙ = collect_cond_actions ⦃ta'⦄⇘c⇙; collect_interrupts ⦃ta''⦄⇘i⇙ = collect_interrupts ⦃ta'⦄⇘i⇙⟧ ⟹ thesis) ⟹ thesis›*) by auto with None (*‹meth = None›*) a (*‹stk ! n = Addr a›*) Ta (*‹typeof_addr h a = ⌊Ta⌋›*) Invoke (*‹(ins::'addr::addr instr list) ! (pc::nat) = Invoke (M'::String.literal) (n::nat)›*) meth (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ (C::String.literal) sees (M::String.literal): (Ts__::ty list)→(T::ty) = ⌊(mxs::nat, mxl::nat, ins::'addr instr list, xt::(nat × nat × String.literal option × nat × nat) list)⌋ in C›*) Ta' (*‹typeof_addr h' a = ⌊Ta⌋›*) n (*‹n < length stk›*) C (*‹(D::String.literal) = class_type_of (Ta::htype)›*) sees' (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ (D::String.literal) sees (M'::String.literal): (Ts'::ty list)→(T'::ty) = (meth::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) option) in (D'::String.literal)›*) have "(extTA2JVM P ta'', extRet2JVM n h''' stk loc C M pc Frs va') ∈ exec P t (xcp, h, frs)" by (force intro: red_external_imp_red_external_aggr (*‹?P,?t ⊢ ⟨?a∙?M(?vs),?h⟩ -?ta→ext ⟨?va,?h'⟩ ⟹ (?ta, ?va, ?h') ∈ red_external_aggr ?P ?t ?a ?M ?vs ?h›*) simp del: split_paired_Ex (*‹(∃x. ?P x) = (∃a b. ?P (a, b))›*)) with ta'' (*‹collect_locks ⦃ta''⦄⇘l⇙ = collect_locks ⦃ta'⦄⇘l⇙› ‹collect_cond_actions ⦃ta''::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action⦄⇘c⇙ = collect_cond_actions ⦃ta'::('addr::addr, 'thread_id::type, 'heap::type) external_thread_action⦄⇘c⇙› ‹collect_interrupts ⦃ta''⦄⇘i⇙ = collect_interrupts ⦃ta'⦄⇘i⇙›*) ta' (*‹ta = extTA2JVM P ta'›*) show "?thesis" (*goal: ‹∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) by (fastforce simp del: split_paired_Ex (*‹(∃x::?'a × ?'b. (?P::?'a × ?'b ⇒ bool) x) = (∃(a::?'a) b::?'b. ?P (a, b))›*)) qed qed qed (auto 4 4 split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) ta_upd_simps (*‹ta_update_locks (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?obs::?'t interrupt_action list × ?'o list) (?lta::lock_action) (?l::?'l) = (?ls(?l $:= ?ls $ ?l @ [?lta]), ?nts, ?js, ?wss, ?obs)› ‹ta_update_NewThread (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?nt::(?'t, ?'x, ?'m) new_thread_action) = (?ls, ?nts @ [?nt], ?js, ?wss, ?is, ?obs)› ‹ta_update_Conditional (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?j::?'t conditional_action) = (?ls, ?nts, ?js @ [?j], ?wss, ?is, ?obs)› ‹ta_update_wait_set (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ws::(?'t, ?'w) wait_set_action) = (?ls, ?nts, ?js, ?wss @ [?ws], ?is, ?obs)› ‹ta_update_interrupt (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?i::?'t interrupt_action) = (?ls, ?nts, ?js, ?wss, ?is @ [?i], ?obs)› ‹ta_update_obs (?ls::?'l lock_actions, ?nts::(?'t, ?'x, ?'m) new_thread_action list, ?js::?'t conditional_action list, ?wss::(?'t, ?'w) wait_set_action list, ?is::?'t interrupt_action list, ?obs::?'o list) (?ob::?'o) = (?ls, ?nts, ?js, ?wss, ?is, ?obs @ [?ob])› ‹FWState.thread_action'_to_thread_action (?la::lock_action, ?l::?'l) (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_locks ?ta ?la ?l› ‹FWState.thread_action'_to_thread_action ?nt::(?'t, ?'x, ?'m) new_thread_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_NewThread ?ta ?nt› ‹FWState.thread_action'_to_thread_action ?ca::?'t conditional_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_Conditional ?ta ?ca› ‹FWState.thread_action'_to_thread_action ?wa::(?'t, ?'w) wait_set_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_wait_set ?ta ?wa› ‹FWState.thread_action'_to_thread_action ?ia::?'t interrupt_action (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_interrupt ?ta ?ia› ‹FWState.thread_action'_to_thread_action ?ob::?'o (?ta::(?'l, ?'t, ?'x, ?'m, ?'w, ?'o) thread_action) = ta_update_obs ?ta ?ob›*) exec_1_iff (*‹(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ (?σ::'addr option × 'heap × 'addr frame list) -?ta::('addr, 'thread_id, 'heap) jvm_thread_action-jvm→ (?σ'::'addr option × 'heap × 'addr frame list) = ((?ta, ?σ') ∈ exec ?P ?t ?σ)›*) intro: rev_image_eqI (*‹⟦(?x::?'a) ∈ (?A::?'a set); (?b::?'b) = (?f::?'a ⇒ ?'b) ?x⟧ ⟹ ?b ∈ ?f ` ?A›*) simp del: split_paired_Ex (*‹(∃x::?'a × ?'b. (?P::?'a × ?'b ⇒ bool) x) = (∃(a::?'a) b::?'b. ?P (a, b))›*)) (*solves the remaining goals: 1. ‹⋀x1. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Load x1⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 2. ‹⋀x2. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Store x2⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 3. ‹⋀x3. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Push x3⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 4. ‹⋀x4. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = New x4⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 5. ‹⋀x5. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = NewArray x5⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 6. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = ALoad⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 7. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = AStore⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 8. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = ALength⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 9. ‹⋀x91 x92. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Getfield x91 x92⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 10. ‹⋀x101 x102. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Putfield x101 x102⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 11. ‹⋀x111 x112. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = CAS x111 x112⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 12. ‹⋀x12. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Checkcast x12⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 13. ‹⋀x13. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Instanceof x13⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 14. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Return⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 15. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Pop⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 16. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Dup⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 17. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Swap⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 18. ‹⋀x19. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = BinOpInstr x19⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 19. ‹⋀x20. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = Goto x20⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 20. ‹⋀x21. ⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = IfFalse x21⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 21. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = ThrowExc⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 22. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = MEnter⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙› 23. ‹⟦(ta, xcp', m', frs') ∈ exec P t (xcp, h', frs); P ⊢ C sees M: Ts→T = ⌊(mxs, mxl, ins, xt)⌋ in C; ∃ta σ'. P,t ⊢ (xcp, h, f # Frs) -ta-jvm→ σ'; ins ! pc = MExit⟧ ⟹ ∃ta' σ'. (ta', σ') ∈ exec P t (xcp, h, frs) ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) with check' (*‹check P (xcp, h, frs)›*) have "∃ta' σ'. P,t ⊢ Normal (xcp, h, frs) -ta'-jvmd→ Normal σ' ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙" apply clarify (*goal: ‹∃ta' σ'. P,t ⊢ Normal (xcp, h, frs) -ta'-jvmd→ Normal σ' ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) apply ((rule exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*))+) (*goal: ‹⋀a aa ab ac ad b ae af ba. ⟦check P (xcp, h, frs); ((a, aa, ab, ac, ad, b), ae, af, ba) ∈ exec P t (xcp, h, frs); collect_locks ⦃(a, aa, ab, ac, ad, b)⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙; collect_cond_actions ⦃(a, aa, ab, ac, ad, b)⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙; collect_interrupts ⦃(a, aa, ab, ac, ad, b)⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙⟧ ⟹ ∃ta' σ'. P,t ⊢ Normal (xcp, h, frs) -ta'-jvmd→ Normal σ' ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙›*) by (rule exec_1_d.exec_1_d_NormalI (*‹⟦exec_d ?P ?t ?σ = Normal ?Σ; (?tas, ?σ') ∈ ?Σ⟧ ⟹ ?P,?t ⊢ Normal ?σ -?tas-jvmd→ Normal ?σ'›*), auto simp add: exec_d_def (*‹exec_d (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?σ::'addr option × 'heap × 'addr frame list) ≡ if check ?P ?σ then Normal (exec ?P ?t ?σ) else TypeError›*)) with L (*‹L = collect_waits ta›*) show "?thesis" (*goal: ‹∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'›*) apply - (*goal: ‹∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'›*) apply (((erule exE (*‹⟦∃x. ?P x; ⋀x. ?P x ⟹ ?Q⟧ ⟹ ?Q›*) conjE (*‹⟦?P ∧ ?Q; ⟦?P; ?Q⟧ ⟹ ?R⟧ ⟹ ?R›*)) | (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)))+) (*goal: ‹⟦L = collect_waits ta; ∃ta' σ'. P,t ⊢ Normal (xcp, h, frs) -ta'-jvmd→ Normal σ' ∧ collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙ ∧ collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙ ∧ collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙⟧ ⟹ ∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) h L'›*) prefer 2 (*top goal: ‹⋀ta' σ'. ⟦L = collect_waits ta; P,t ⊢ Normal (xcp, h, frs) -ta'-jvmd→ Normal σ'; collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙; collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙; collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙⟧ ⟹ execd_mthr.can_sync P t (xcp, frs) h (?L'12 ta' σ')› and 1 goal remains*) apply (rule_tac x'="(fst σ', snd (snd σ'))" and m'="fst (snd σ')" in execd_mthr.can_syncI (*‹⟦execd_mthr.r_syntax ?P ?t ?x ?m ?ta ?x' ?m'; ?LT = collect_waits ?ta⟧ ⟹ execd_mthr.can_sync ?P ?t ?x ?m ?LT›*)) (*top goal: ‹⋀ta' σ'. ⟦L = collect_waits ta; P,t ⊢ Normal (xcp, h, frs) -ta'-jvmd→ Normal σ'; collect_locks ⦃ta'⦄⇘l⇙ ⊆ collect_locks ⦃ta⦄⇘l⇙; collect_cond_actions ⦃ta'⦄⇘c⇙ ⊆ collect_cond_actions ⦃ta⦄⇘c⇙; collect_interrupts ⦃ta'⦄⇘i⇙ ⊆ collect_interrupts ⦃ta⦄⇘i⇙⟧ ⟹ execd_mthr.can_sync P t (xcp, frs) h (?L'12 ta' σ')› and 1 goal remains*) by auto qed qed end context JVM_typesafe begin lemma execd_preserve_deadlocked: assumes wf: "wf_jvm_prog⇘Φ⇙ P" shows "preserve_deadlocked JVM_final (mexecd P) convert_RA (correct_jvm_state Φ)" proof (unfold_locales) (*goals: 1. ‹invariant3p (mexecdT (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog)) (correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list))› 2. ‹⋀(s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t'::'thread_id::type) (ta'::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (s'::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t::'thread_id::type) x::'addr::addr option × 'addr::addr frame list. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; execd_mthr.must_sync P t x (shr s)⟧ ⟹ execd_mthr.must_sync P t x (shr s')› 3. ‹⋀(s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t'::'thread_id::type) (ta'::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (s'::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t::'thread_id::type) (x::'addr::addr option × 'addr::addr frame list) L::('addr::addr + 'thread_id::type + 'thread_id::type) set. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; execd_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. execd_mthr.can_sync P t x (shr s) L'›*) show "invariant3p (mexecdT P) (correct_jvm_state Φ)" by (rule invariant3p_correct_jvm_state_mexecdT[OF wf] (*‹invariant3p (mexecdT P) (correct_jvm_state Φ)›*)) next (*goals: 1. ‹⋀(s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t'::'thread_id::type) (ta'::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (s'::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t::'thread_id::type) x::'addr::addr option × 'addr::addr frame list. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; execd_mthr.must_sync P t x (shr s)⟧ ⟹ execd_mthr.must_sync P t x (shr s')› 2. ‹⋀(s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t'::'thread_id::type) (ta'::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (s'::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t::'thread_id::type) (x::'addr::addr option × 'addr::addr frame list) L::('addr::addr + 'thread_id::type + 'thread_id::type) set. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; execd_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. execd_mthr.can_sync P t x (shr s) L'›*) fix s and t' and ta' and s' and t and x and ln assume s: "s ∈ correct_jvm_state Φ" and red: "P ⊢ s -t'▹ta'→⇘jvmd⇙ s'" and tst: "thr s t = ⌊(x, ln)⌋" and "execd_mthr.must_sync P t x (shr s)" (*‹(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list)› ‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -t'::'thread_id▹ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)› ‹thr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) = ⌊(x::'addr option × 'addr frame list, ln::'addr ⇒f nat)⌋› ‹execd_mthr.must_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (x::'addr option × 'addr frame list) (shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set))›*) moreover obtain xcp and frs where x[simp]: "x = (xcp, frs)" (*goal: ‹(⋀(xcp::'addr option) frs::'addr frame list. (x::'addr option × 'addr frame list) = (xcp, frs) ⟹ thesis::bool) ⟹ thesis›*) apply (cases x) (*goal: ‹(⋀xcp frs. x = (xcp, frs) ⟹ thesis) ⟹ thesis›*) by auto ultimately have ml: "execd_mthr.must_sync P t (xcp, frs) (shr s)" by simp moreover from s (*‹s ∈ correct_jvm_state Φ›*) have cs': "correct_state_ts Φ (thr s) (shr s)" by (simp add: correct_jvm_state_def (*‹correct_jvm_state ?Φ = {s. correct_state_ts ?Φ (thr s) (shr s) ∧ lock_thread_ok (locks s) (thr s)}›*)) with tst (*‹thr s t = ⌊(x, ln)⌋›*) have "Φ ⊢ t: (xcp, shr s, frs) √" by (auto dest: ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) moreover from red (*‹P ⊢ s -t'▹ta'→⇘jvmd⇙ s'›*) have "hext (shr s) (shr s')" by (rule execd_hext (*‹P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s' ⟹ shr ?s ⊴ shr ?s'›*)) moreover from wf (*‹wf_jvm_prog⇘Φ⇙ P›*) red (*‹P ⊢ s -t'▹ta'→⇘jvmd⇙ s'›*) cs' (*‹correct_state_ts Φ (thr s) (shr s)›*) have "correct_state_ts Φ (thr s') (shr s')" by (rule lifting_wf.redT_preserves[OF lifting_wf_correct_state_d] (*‹⟦wf_jvm_prog⇘?Φ1⇙ P; multithreaded_base.redT JVM_final (mexecd P) ?convert_RA ?s (?t, ?ta) ?s'; correct_state_ts ?Φ1 (thr ?s) (shr ?s)⟧ ⟹ correct_state_ts ?Φ1 (thr ?s') (shr ?s')›*)) from red (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -t'::'thread_id▹ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)›*) tst (*‹thr s t = ⌊(x, ln)⌋›*) have "thr s' t ≠ None" apply (cases s) (*goal: ‹thr s' t ≠ None›*) apply (cases s') (*goal: ‹⋀(a::('addr, 'thread_id) locks) (b::('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) (c::'thread_id ⇒ 'addr wait_set_status option) d::'thread_id set. ⟦(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -t'::'thread_id▹ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set); thr s (t::'thread_id) = ⌊(x::'addr option × 'addr frame list, ln::'addr ⇒f nat)⌋; s = (a, b, c, d)⟧ ⟹ thr s' t ≠ None›*) apply (rule notI (*‹(?P ⟹ False) ⟹ ¬ ?P›*)) (*goal: ‹⋀a b c d aa ba ca da. ⟦P ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, ln)⌋; s = (a, b, c, d); s' = (aa, ba, ca, da)⟧ ⟹ thr s' t ≠ None›*) by (auto dest: execd_mthr.redT_thread_not_disappear (*‹⟦?P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s'; thr ?s' ?t' = None⟧ ⟹ thr ?s ?t' = None›*)) with ‹correct_state_ts Φ (thr s') (shr s')› (*‹correct_state_ts Φ (thr s') (shr s')›*) have "hconf (shr s')" by (auto dest: ts_okD (*‹⟦ts_ok (?P::?'b ⇒ ?'c ⇒ ?'d ⇒ bool) (?ts::?'b ⇒ (?'c × ?'a ⇒f nat) option) (?m::?'d); ?ts (?t::?'b) = ⌊(?x::?'c, ?ln::?'a ⇒f nat)⌋⟧ ⟹ ?P ?t ?x ?m›*) simp add: correct_state_def (*‹correct_state (?Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) (?t::'thread_id) ≡ λ(xp::'addr option, h::'heap, frs::'addr frame list). (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),h ⊢ ?t √t ∧ (hconf::'heap ⇒ bool) h ∧ preallocated h ∧ (case frs of [] ⇒ True | (f::'addr frame) # (fs::'addr frame list) ⇒ let (stk::'addr val list, loc::'addr val list, C::String.literal, M::String.literal, pc::nat) = f in ∃(Ts::ty list) (T::ty) (mxs::nat) (mxl₀::nat) (is::'addr instr list) (xt::(nat × nat × String.literal option × nat × nat) list) τ::ty list × ty err list. P ⊢ C sees M: Ts→T = ⌊(mxs, mxl₀, is, xt)⌋ in C ∧ ?Φ C M ! pc = ⌊τ⌋ ∧ conf_f P h τ is f ∧ conf_fs P h ?Φ M (length Ts) T fs ∧ conf_xcp P h xp (is ! pc))›*)) ultimately have "execd_mthr.must_sync P t (xcp, frs) (shr s')" apply - (*goal: ‹execd_mthr.must_sync P t (xcp, frs) (shr s')›*) apply (rule must_sync_preserved_d[OF wf] (*‹⟦execd_mthr.must_sync P ?t (?xcp, ?frs) ?h; ?h ⊴ ?h'; hconf ?h'; Φ ⊢ ?t:(?xcp, ?h, ?frs) √⟧ ⟹ execd_mthr.must_sync P ?t (?xcp, ?frs) ?h'›*)) (*goals: 1. ‹⟦execd_mthr.must_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp::'addr option, frs::'addr frame list) (shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)); (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set); (hconf::'heap ⇒ bool) (shr s')⟧ ⟹ execd_mthr.must_sync P t (xcp, frs) (?h4::'heap)› 2. ‹⟦execd_mthr.must_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp::'addr option, frs::'addr frame list) (shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)); (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set); (hconf::'heap ⇒ bool) (shr s')⟧ ⟹ (?h4::'heap) ⊴ shr s'› 3. ‹⟦execd_mthr.must_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp::'addr option, frs::'addr frame list) (shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)); (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set); (hconf::'heap ⇒ bool) (shr s')⟧ ⟹ hconf (shr s')› 4. ‹⟦execd_mthr.must_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (xcp::'addr option, frs::'addr frame list) (shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)); (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set); (hconf::'heap ⇒ bool) (shr s')⟧ ⟹ Φ ⊢ t:(xcp, ?h4::'heap, frs) √› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) thus "execd_mthr.must_sync P t x (shr s')" by simp next (*goal: ‹⋀s t' ta' s' t x L. ⟦s ∈ correct_jvm_state Φ; P ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; execd_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. execd_mthr.can_sync P t x (shr s) L'›*) fix s and t' and ta' and s' and t and x and ln and L assume s: "s ∈ correct_jvm_state Φ" and red: "P ⊢ s -t'▹ta'→⇘jvmd⇙ s'" and tst: "thr s t = ⌊(x, ln)⌋" and "execd_mthr.can_sync P t x (shr s') L" (*‹(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list)› ‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -t'::'thread_id▹ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)› ‹thr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) = ⌊(x::'addr option × 'addr frame list, ln::'addr ⇒f nat)⌋› ‹execd_mthr.can_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (x::'addr option × 'addr frame list) (shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) (L::('addr + 'thread_id + 'thread_id) set)›*) moreover obtain xcp and frs where x[simp]: "x = (xcp, frs)" (*goal: ‹(⋀xcp frs. x = (xcp, frs) ⟹ thesis) ⟹ thesis›*) apply (cases x) (*goal: ‹(⋀xcp frs. x = (xcp, frs) ⟹ thesis) ⟹ thesis›*) by auto ultimately have ml: "execd_mthr.can_sync P t (xcp, frs) (shr s') L" by simp moreover from s (*‹s ∈ correct_jvm_state Φ›*) have cs': "correct_state_ts Φ (thr s) (shr s)" by (simp add: correct_jvm_state_def (*‹correct_jvm_state ?Φ = {s. correct_state_ts ?Φ (thr s) (shr s) ∧ lock_thread_ok (locks s) (thr s)}›*)) with tst (*‹thr (s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t::'thread_id::type) = ⌊(x::'addr::addr option × 'addr::addr frame list, ln::'addr::addr ⇒f nat)⌋›*) have "Φ ⊢ t: (xcp, shr s, frs) √" by (auto dest: ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) moreover from red (*‹P ⊢ s -t'▹ta'→⇘jvmd⇙ s'›*) have "hext (shr s) (shr s')" by (rule execd_hext (*‹P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s' ⟹ shr ?s ⊴ shr ?s'›*)) moreover from red (*‹P ⊢ s -t'▹ta'→⇘jvmd⇙ s'›*) tst (*‹thr s t = ⌊(x, ln)⌋›*) have "thr s' t ≠ None" apply (cases s) (*goal: ‹thr s' t ≠ None›*) apply (cases s') (*goal: ‹⋀a b c d. ⟦P ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, ln)⌋; s = (a, b, c, d)⟧ ⟹ thr s' t ≠ None›*) apply (rule notI (*‹(?P::bool ⟹ False) ⟹ ¬ ?P›*)) (*goal: ‹⋀a b c d aa ba ca da. ⟦P ⊢ s -t'▹ta'→⇘jvmd⇙ s'; thr s t = ⌊(x, ln)⌋; s = (a, b, c, d); s' = (aa, ba, ca, da)⟧ ⟹ thr s' t ≠ None›*) by (auto dest: execd_mthr.redT_thread_not_disappear (*‹⟦?P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s'; thr ?s' ?t' = None⟧ ⟹ thr ?s ?t' = None›*)) from red (*‹P ⊢ s -t'▹ta'→⇘jvmd⇙ s'›*) cs' (*‹correct_state_ts (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) (thr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) (shr s)›*) have "correct_state_ts Φ (thr s') (shr s')" by (rule lifting_wf.redT_preserves[OF lifting_wf_correct_state_d[OF wf]] (*‹⟦multithreaded_base.redT JVM_final (mexecd P) ?convert_RA ?s (?t, ?ta) ?s'; correct_state_ts Φ (thr ?s) (shr ?s)⟧ ⟹ correct_state_ts Φ (thr ?s') (shr ?s')›*)) with ‹thr s' t ≠ None› (*‹thr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) ≠ None›*) have "hconf (shr s')" by (auto dest: ts_okD (*‹⟦ts_ok (?P::?'b ⇒ ?'c ⇒ ?'d ⇒ bool) (?ts::?'b ⇒ (?'c × ?'a ⇒f nat) option) (?m::?'d); ?ts (?t::?'b) = ⌊(?x::?'c, ?ln::?'a ⇒f nat)⌋⟧ ⟹ ?P ?t ?x ?m›*) simp add: correct_state_def (*‹correct_state (?Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) (?t::'thread_id) ≡ λ(xp::'addr option, h::'heap, frs::'addr frame list). (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),h ⊢ ?t √t ∧ (hconf::'heap ⇒ bool) h ∧ preallocated h ∧ (case frs of [] ⇒ True | (f::'addr frame) # (fs::'addr frame list) ⇒ let (stk::'addr val list, loc::'addr val list, C::String.literal, M::String.literal, pc::nat) = f in ∃(Ts::ty list) (T::ty) (mxs::nat) (mxl₀::nat) (is::'addr instr list) (xt::(nat × nat × String.literal option × nat × nat) list) τ::ty list × ty err list. P ⊢ C sees M: Ts→T = ⌊(mxs, mxl₀, is, xt)⌋ in C ∧ ?Φ C M ! pc = ⌊τ⌋ ∧ conf_f P h τ is f ∧ conf_fs P h ?Φ M (length Ts) T fs ∧ conf_xcp P h xp (is ! pc))›*)) ultimately have "∃L' ⊆ L. execd_mthr.can_sync P t (xcp, frs) (shr s) L'" apply - (*goal: ‹∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) (shr s) L'›*) apply (rule can_sync_devreserp_d[OF wf] (*‹⟦execd_mthr.can_sync P ?t (?xcp, ?frs) ?h' ?L; Φ ⊢ ?t:(?xcp, ?h, ?frs) √; ?h ⊴ ?h'; hconf ?h'⟧ ⟹ ∃L'⊆?L. execd_mthr.can_sync P ?t (?xcp, ?frs) ?h L'›*)) (*goals: 1. ‹⟦execd_mthr.can_sync P t (xcp, frs) (shr s') L; Φ ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr s'; hconf (shr s')⟧ ⟹ execd_mthr.can_sync P t (xcp, frs) ?h'4 L› 2. ‹⟦execd_mthr.can_sync P t (xcp, frs) (shr s') L; Φ ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr s'; hconf (shr s')⟧ ⟹ Φ ⊢ t:(xcp, shr s, frs) √› 3. ‹⟦execd_mthr.can_sync P t (xcp, frs) (shr s') L; Φ ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr s'; hconf (shr s')⟧ ⟹ shr s ⊴ ?h'4› 4. ‹⟦execd_mthr.can_sync P t (xcp, frs) (shr s') L; Φ ⊢ t:(xcp, shr s, frs) √; shr s ⊴ shr s'; hconf (shr s')⟧ ⟹ hconf ?h'4› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) thus "∃L' ⊆ L. execd_mthr.can_sync P t x (shr s) L'" by simp qed end text ‹and now everything again for the aggresive VM› context JVM_heap_conf_base' begin lemma must_lock_d_eq_must_lock: "⟦ wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t: (xcp, h, frs) √ ⟧ ⟹ execd_mthr.must_sync P t (xcp, frs) h = exec_mthr.must_sync P t (xcp, frs) h" apply (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; execd_mthr.must_sync P t (xcp, frs) h⟧ ⟹ exec_mthr.must_sync P t (xcp, frs) h› 2. ‹⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; exec_mthr.must_sync P t (xcp, frs) h⟧ ⟹ execd_mthr.must_sync P t (xcp, frs) h› discuss goal 1*) apply (rule exec_mthr.must_syncI (*‹∃(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (x'::'addr::addr option × 'addr::addr frame list) (m'::'heap::type) s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set. exec_mthr.r_syntax (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?x::'addr::addr option × 'addr::addr frame list) (?m::'heap::type) ta x' m' ∧ exec_mthr.actions_ok s ?t ta ⟹ exec_mthr.must_sync ?P ?t ?x ?m›*)) (*top goal: ‹⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; execd_mthr.must_sync P t (xcp, frs) h⟧ ⟹ exec_mthr.must_sync P t (xcp, frs) h› and 1 goal remains*) apply (erule execd_mthr.must_syncE (*‹⟦execd_mthr.must_sync ?P ?t ?x ?m; ⋀ta x' m' s. ⟦execd_mthr.r_syntax ?P ?t ?x ?m ta x' m'; exec_mthr.actions_ok s ?t ta; ?m = shr s⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*top goal: ‹⟦wf_jvm_prog⇘Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list⇙ (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog); Φ ⊢ t::'thread_id:(xcp::'addr option, h::'heap, frs::'addr frame list) √; execd_mthr.must_sync P t (xcp, frs) h⟧ ⟹ ∃(ta::('addr, 'thread_id, 'heap) jvm_thread_action) (x'::'addr option × 'addr frame list) (m'::'heap) s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set. exec_mthr.r_syntax P t (xcp, frs) h ta x' m' ∧ exec_mthr.actions_ok s t ta› and 1 goal remains*) apply (simp only: mexec_eq_mexecd (*‹⟦wf_jvm_prog⇘?Φ⇙ P; ?Φ ⊢ ?t:(?xcp, ?h, ?frs) √⟧ ⟹ mexec P ?t ((?xcp, ?frs), ?h) = mexecd P ?t ((?xcp, ?frs), ?h)›*)) (*top goal: ‹⋀ta x' m' s. ⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; execd_mthr.r_syntax P t (xcp, frs) h ta x' m'; exec_mthr.actions_ok s t ta; h = shr s⟧ ⟹ ∃ta x' m' s. exec_mthr.r_syntax P t (xcp, frs) h ta x' m' ∧ exec_mthr.actions_ok s t ta› and 1 goal remains*) apply blast (*discuss goal 2*) apply (rule execd_mthr.must_syncI (*‹∃ta x' m' s. execd_mthr.r_syntax ?P ?t ?x ?m ta x' m' ∧ exec_mthr.actions_ok s ?t ta ⟹ execd_mthr.must_sync ?P ?t ?x ?m›*)) (*goal: ‹⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; exec_mthr.must_sync P t (xcp, frs) h⟧ ⟹ execd_mthr.must_sync P t (xcp, frs) h›*) apply (erule exec_mthr.must_syncE (*‹⟦exec_mthr.must_sync ?P ?t ?x ?m; ⋀ta x' m' s. ⟦exec_mthr.r_syntax ?P ?t ?x ?m ta x' m'; exec_mthr.actions_ok s ?t ta; ?m = shr s⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goal: ‹⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; exec_mthr.must_sync P t (xcp, frs) h⟧ ⟹ ∃ta x' m' s. execd_mthr.r_syntax P t (xcp, frs) h ta x' m' ∧ exec_mthr.actions_ok s t ta›*) apply (simp only: mexec_eq_mexecd[symmetric] (*‹⟦wf_jvm_prog⇘?Φ⇙ P; ?Φ ⊢ ?t:(?xcp, ?h, ?frs) √⟧ ⟹ mexecd P ?t ((?xcp, ?frs), ?h) = mexec P ?t ((?xcp, ?frs), ?h)›*)) (*goal: ‹⋀ta x' m' s. ⟦wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t:(xcp, h, frs) √; exec_mthr.r_syntax P t (xcp, frs) h ta x' m'; exec_mthr.actions_ok s t ta; h = shr s⟧ ⟹ ∃ta x' m' s. execd_mthr.r_syntax P t (xcp, frs) h ta x' m' ∧ exec_mthr.actions_ok s t ta›*) apply blast (*proven 2 subgoals*) . lemma can_lock_d_eq_can_lock: "⟦ wf_jvm_prog⇘Φ⇙ P; Φ ⊢ t: (xcp, h, frs) √ ⟧ ⟹ execd_mthr.can_sync P t (xcp, frs) h L = exec_mthr.can_sync P t (xcp, frs) h L" sorry end context JVM_typesafe begin lemma exec_preserve_deadlocked: assumes wf: "wf_jvm_prog⇘Φ⇙ P" shows "preserve_deadlocked JVM_final (mexec P) convert_RA (correct_jvm_state Φ)" proof (-) (*goal: ‹preserve_deadlocked JVM_final (mexec P) convert_RA (correct_jvm_state Φ)›*) interpret preserve_deadlocked JVM_final "mexecd P" convert_RA "correct_jvm_state Φ" apply (rule execd_preserve_deadlocked (*‹wf_jvm_prog⇘?Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list⇙ (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⟹ preserve_deadlocked JVM_final (mexecd P) convert_RA (correct_jvm_state ?Φ)›*)) (*goal: ‹preserve_deadlocked JVM_final (mexecd P) convert_RA (correct_jvm_state Φ)›*) by fact { fix s and t' and ta' and s' and t and x assume s: "s ∈ correct_jvm_state Φ" and red: "P ⊢ s -t'▹ta'→⇘jvm⇙ s'" and tst: "thr s t = ⌊(x, no_wait_locks)⌋" (*‹(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list)› ‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -t'::'thread_id▹ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvm⇙ (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)› ‹thr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) = ⌊(x::'addr option × 'addr frame list, no_wait_locks)⌋›*) obtain xcp and frs where x[simp]: "x = (xcp, frs)" (*goal: ‹(⋀xcp frs. x = (xcp, frs) ⟹ thesis) ⟹ thesis›*) apply (cases x) (*goal: ‹(⋀xcp frs. x = (xcp, frs) ⟹ thesis) ⟹ thesis›*) by auto from s (*‹s ∈ correct_jvm_state Φ›*) have css: "correct_state_ts Φ (thr s) (shr s)" by (simp add: correct_jvm_state_def (*‹correct_jvm_state ?Φ = {s. correct_state_ts ?Φ (thr s) (shr s) ∧ lock_thread_ok (locks s) (thr s)}›*)) with red (*‹P ⊢ s -t'▹ta'→⇘jvm⇙ s'›*) have redd: "P ⊢ s -t'▹ta'→⇘jvmd⇙ s'" by (simp add: mexecT_eq_mexecdT[OF wf] (*‹correct_state_ts Φ (thr ?s) (shr ?s) ⟹ P ⊢ ?s -?t▹?ta→⇘jvm⇙ ?s' = P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s'›*)) from css (*‹correct_state_ts Φ (thr s) (shr s)›*) tst (*‹thr (s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set) (t::'thread_id::type) = ⌊(x::'addr::addr option × 'addr::addr frame list, no_wait_locks)⌋›*) have cst: "Φ ⊢ t: (xcp, shr s, frs) √" by (auto dest: ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) from redd (*‹(P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set -t'::'thread_id▹ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)›*) have cst': "Φ ⊢ t: (xcp, shr s', frs) √" proof (cases rule: execd_mthr.redT_elims (*‹⟦?P ⊢ ?s -?t▹?ta→⇘jvmd⇙ ?s'; ⋀x x' m' ws'. ⟦execd_mthr.r_syntax ?P ?t x (shr ?s) ?ta x' m'; thr ?s ?t = ⌊(x, no_wait_locks)⌋; lock_ok_las (locks ?s) ?t ⦃?ta⦄⇘l⇙; thread_oks (thr ?s) ⦃?ta⦄⇘t⇙; exec_mthr.cond_action_oks ?s ?t ⦃?ta⦄⇘c⇙; wset_actions_ok (wset ?s) ?t ⦃?ta⦄⇘w⇙; interrupt_actions_ok (interrupts ?s) ⦃?ta⦄⇘i⇙; redT_updWs ?t (wset ?s) ⦃?ta⦄⇘w⇙ ws'; ?s' = (redT_updLs (locks ?s) ?t ⦃?ta⦄⇘l⇙, ((redT_updTs (thr ?s) ⦃?ta⦄⇘t⇙)(?t ↦ (x', redT_updLns (locks ?s) ?t no_wait_locks ⦃?ta⦄⇘l⇙)), m'), ws', redT_updIs (interrupts ?s) ⦃?ta⦄⇘i⇙)⟧ ⟹ ?thesis; ⋀x ln n. ⟦thr ?s ?t = ⌊(x, ln)⌋; ?ta = (K$ [], [], [], [], [], convert_RA ln); ¬ waiting (wset ?s ?t); may_acquire_all (locks ?s) ?t ln; 0 < ln $ n; ?s' = (acquire_all (locks ?s) ?t ln, ((thr ?s)(?t ↦ (x, no_wait_locks)), shr ?s), wset ?s, interrupts ?s)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⋀x x' m' ws'. ⟦execd_mthr.r_syntax P t' x (shr s) ta' x' m'; thr s t' = ⌊(x, no_wait_locks)⌋; lock_ok_las (locks s) t' ⦃ta'⦄⇘l⇙; thread_oks (thr s) ⦃ta'⦄⇘t⇙; exec_mthr.cond_action_oks s t' ⦃ta'⦄⇘c⇙; wset_actions_ok (wset s) t' ⦃ta'⦄⇘w⇙; interrupt_actions_ok (interrupts s) ⦃ta'⦄⇘i⇙; redT_updWs t' (wset s) ⦃ta'⦄⇘w⇙ ws'; s' = (redT_updLs (locks s) t' ⦃ta'⦄⇘l⇙, ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ (x', redT_updLns (locks s) t' no_wait_locks ⦃ta'⦄⇘l⇙)), m'), ws', redT_updIs (interrupts s) ⦃ta'⦄⇘i⇙)⟧ ⟹ Φ ⊢ t:(xcp, shr s', frs) √› 2. ‹⋀x ln n. ⟦thr s t' = ⌊(x, ln)⌋; ta' = (K$ [], [], [], [], [], convert_RA ln); ¬ waiting (wset s t'); may_acquire_all (locks s) t' ln; 0 < ln $ n; s' = (acquire_all (locks s) t' ln, ((thr s)(t' ↦ (x, no_wait_locks)), shr s), wset s, interrupts s)⟧ ⟹ Φ ⊢ t:(xcp, shr s', frs) √›*) case acquire (*‹thr s t' = ⌊(x_, ln_)⌋› ‹ta' = (K$ [], [], [], [], [], convert_RA ln_)› ‹¬ waiting (wset s t')› ‹may_acquire_all (locks s) t' ln_› ‹0 < ln_ $ n_› ‹s' = (acquire_all (locks s) t' ln_, ((thr s)(t' ↦ (x_, no_wait_locks)), shr s), wset s, interrupts s)›*) with cst (*‹Φ ⊢ t:(xcp, shr s, frs) √›*) show "?thesis" (*goal: ‹(Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ⊢ t::'thread_id:(xcp::'addr option, shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set), frs::'addr frame list) √›*) by simp next (*goal: ‹⋀x x' m' ws'. ⟦execd_mthr.r_syntax P t' x (shr s) ta' x' m'; thr s t' = ⌊(x, no_wait_locks)⌋; lock_ok_las (locks s) t' ⦃ta'⦄⇘l⇙; thread_oks (thr s) ⦃ta'⦄⇘t⇙; exec_mthr.cond_action_oks s t' ⦃ta'⦄⇘c⇙; wset_actions_ok (wset s) t' ⦃ta'⦄⇘w⇙; interrupt_actions_ok (interrupts s) ⦃ta'⦄⇘i⇙; redT_updWs t' (wset s) ⦃ta'⦄⇘w⇙ ws'; s' = (redT_updLs (locks s) t' ⦃ta'⦄⇘l⇙, ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ (x', redT_updLns (locks s) t' no_wait_locks ⦃ta'⦄⇘l⇙)), m'), ws', redT_updIs (interrupts s) ⦃ta'⦄⇘i⇙)⟧ ⟹ Φ ⊢ t:(xcp, shr s', frs) √›*) case (normal X X' M' ws') (*‹execd_mthr.r_syntax P t' X (shr s) ta' X' M'› ‹thr s t' = ⌊(X, no_wait_locks)⌋› ‹lock_ok_las (locks (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) (t'::'thread_id) ⦃ta'::('addr, 'thread_id, 'heap) jvm_thread_action⦄⇘l⇙› ‹thread_oks (thr s) ⦃ta'⦄⇘t⇙› ‹exec_mthr.cond_action_oks s t' ⦃ta'⦄⇘c⇙› ‹wset_actions_ok (wset s) t' ⦃ta'⦄⇘w⇙› ‹interrupt_actions_ok (interrupts (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) ⦃ta'::('addr, 'thread_id, 'heap) jvm_thread_action⦄⇘i⇙› ‹redT_updWs t' (wset s) ⦃ta'⦄⇘w⇙ ws'› ‹s' = (redT_updLs (locks s) t' ⦃ta'⦄⇘l⇙, ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ (X', redT_updLns (locks s) t' no_wait_locks ⦃ta'⦄⇘l⇙)), M'), ws', redT_updIs (interrupts s) ⦃ta'⦄⇘i⇙)›*) obtain XCP and FRS where X[simp]: "X = (XCP, FRS)" (*goal: ‹(⋀(XCP::'addr option) FRS::'addr frame list. (X::'addr option × 'addr frame list) = (XCP, FRS) ⟹ thesis::bool) ⟹ thesis›*) apply (cases X) (*goal: ‹(⋀XCP FRS. X = (XCP, FRS) ⟹ thesis) ⟹ thesis›*) by auto obtain XCP' and FRS' where X'[simp]: "X' = (XCP', FRS')" (*goal: ‹(⋀(XCP'::'addr option) FRS'::'addr frame list. (X'::'addr option × 'addr frame list) = (XCP', FRS') ⟹ thesis::bool) ⟹ thesis›*) apply (cases X') (*goal: ‹(⋀XCP' FRS'. X' = (XCP', FRS') ⟹ thesis) ⟹ thesis›*) by auto from ‹mexecd P t' (X, shr s) ta' (X', M')› (*‹execd_mthr.r_syntax P t' X (shr s) ta' X' M'›*) have "P,t' ⊢ Normal (XCP, shr s, FRS) -ta'-jvmd→ Normal (XCP', M', FRS')" by simp moreover from ‹thr s t' = ⌊(X, no_wait_locks)⌋› (*‹thr s t' = ⌊(X, no_wait_locks)⌋›*) css (*‹correct_state_ts Φ (thr s) (shr s)›*) have "Φ ⊢ t': (XCP, shr s, FRS) √" by (auto dest: ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) ultimately have "Φ ⊢ t': (XCP, M', FRS) √" apply - (*goal: ‹Φ ⊢ t':(XCP, M', FRS) √›*) apply (rule correct_state_heap_change[OF wf] (*‹⟦P,?t ⊢ Normal (?xcp, ?h, ?frs) -?ta-jvmd→ Normal (?xcp', ?h', ?frs'); Φ ⊢ ?t:(?xcp, ?h, ?frs) √; Φ ⊢ ?t'':(?xcp'', ?h, ?frs'') √⟧ ⟹ Φ ⊢ ?t'':(?xcp'', ?h', ?frs'') √›*)) (*goals: 1. ‹⟦P,t' ⊢ Normal (XCP, shr s, FRS) -ta'-jvmd→ Normal (XCP', M', FRS'); Φ ⊢ t':(XCP, shr s, FRS) √⟧ ⟹ P,?t2 ⊢ Normal (?xcp2, ?h2, ?frs2) -?ta2-jvmd→ Normal (?xcp'2, M', ?frs'2)› 2. ‹⟦P,t' ⊢ Normal (XCP, shr s, FRS) -ta'-jvmd→ Normal (XCP', M', FRS'); Φ ⊢ t':(XCP, shr s, FRS) √⟧ ⟹ Φ ⊢ ?t2:(?xcp2, ?h2, ?frs2) √› 3. ‹⟦P,t' ⊢ Normal (XCP, shr s, FRS) -ta'-jvmd→ Normal (XCP', M', FRS'); Φ ⊢ t':(XCP, shr s, FRS) √⟧ ⟹ Φ ⊢ t':(XCP, ?h2, FRS) √› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) moreover from lifting_wf.redT_updTs_preserves[OF lifting_wf_correct_state_d [ OF wf ] css, OF ‹mexecd P t' (X, shr s) ta' (X', M')› ‹thr s t' = ⌊(X, no_wait_locks)⌋›, of no_wait_locks] (*‹thread_oks (thr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) ⦃ta'::('addr, 'thread_id, 'heap) jvm_thread_action⦄⇘t⇙ ⟹ correct_state_ts (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t'::'thread_id ↦ (X'::'addr option × 'addr frame list, no_wait_locks))) (M'::'heap)›*) ‹thread_oks (thr s) ⦃ta'⦄⇘t⇙› (*‹thread_oks (thr s) ⦃ta'⦄⇘t⇙›*) have "correct_state_ts Φ ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ (X', no_wait_locks))) M'" by simp ultimately have "correct_state_ts Φ (redT_updTs (thr s) ⦃ta'⦄⇘t⇙) M'" using ‹thr s t' = ⌊(X, no_wait_locks)⌋› (*‹thr s t' = ⌊(X, no_wait_locks)⌋›*) ‹thread_oks (thr s) ⦃ta'⦄⇘t⇙› (*‹thread_oks (thr s) ⦃ta'⦄⇘t⇙›*) apply (auto intro!: ts_okI (*‹(⋀t x ln. ?ts t = ⌊(x, ln)⌋ ⟹ ?P t x ?m) ⟹ ts_ok ?P ?ts ?m›*) dest: ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) (*goal: ‹correct_state_ts Φ (redT_updTs (thr s) ⦃ta'⦄⇘t⇙) M'›*) apply (case_tac "t=t'") (*goals: 1. ‹⋀t a b ln. ⟦Φ ⊢ t':(XCP, M', FRS) √; correct_state_ts Φ ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ ((XCP', FRS'), no_wait_locks))) M'; thr s t' = ⌊((XCP, FRS), no_wait_locks)⌋; thread_oks (thr s) ⦃ta'⦄⇘t⇙; redT_updTs (thr s) ⦃ta'⦄⇘t⇙ t = ⌊((a, b), ln)⌋; t = t'⟧ ⟹ Φ ⊢ t:(a, M', b) √› 2. ‹⋀t a b ln. ⟦Φ ⊢ t':(XCP, M', FRS) √; correct_state_ts Φ ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ ((XCP', FRS'), no_wait_locks))) M'; thr s t' = ⌊((XCP, FRS), no_wait_locks)⌋; thread_oks (thr s) ⦃ta'⦄⇘t⇙; redT_updTs (thr s) ⦃ta'⦄⇘t⇙ t = ⌊((a, b), ln)⌋; t ≠ t'⟧ ⟹ Φ ⊢ t:(a, M', b) √› discuss goal 1*) apply (fastforce dest: redT_updTs_Some (*‹⟦?ts ?t = ⌊?xw⌋; thread_oks ?ts ?tas⟧ ⟹ redT_updTs ?ts ?tas ?t = ⌊?xw⌋›*)) (*discuss goal 2*) apply (drule_tac t=t in ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) (*goals: 1. ‹⋀t a b ln. ⟦Φ ⊢ t':(XCP, M', FRS) √; thr s t' = ⌊((XCP, FRS), no_wait_locks)⌋; thread_oks (thr s) ⦃ta'⦄⇘t⇙; redT_updTs (thr s) ⦃ta'⦄⇘t⇙ t = ⌊((a, b), ln)⌋; t ≠ t'⟧ ⟹ ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ ((XCP', FRS'), no_wait_locks))) t = ⌊(?x10 t a b ln, ?ln10 t a b ln)⌋› 2. ‹⋀t a b ln. ⟦Φ ⊢ t':(XCP, M', FRS) √; thr s t' = ⌊((XCP, FRS), no_wait_locks)⌋; thread_oks (thr s) ⦃ta'⦄⇘t⇙; redT_updTs (thr s) ⦃ta'⦄⇘t⇙ t = ⌊((a, b), ln)⌋; t ≠ t'; (case ?x10 t a b ln of (xcp, frstls) ⇒ λh. Φ ⊢ t:(xcp, h, frstls) √) M'⟧ ⟹ Φ ⊢ t:(a, M', b) √› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) (*proven 2 subgoals*) . hence "correct_state_ts Φ (redT_updTs (thr s) ⦃ta'⦄⇘t⇙) (shr s')" using ‹s' = (redT_updLs (locks s) t' ⦃ta'⦄⇘l⇙, ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ (X', redT_updLns (locks s) t' no_wait_locks ⦃ta'⦄⇘l⇙)), M'), ws', redT_updIs (interrupts s) ⦃ta'⦄⇘i⇙)› (*‹(s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) = (redT_updLs (locks (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) (t'::'thread_id) ⦃ta'::('addr, 'thread_id, 'heap) jvm_thread_action⦄⇘l⇙, ((redT_updTs (thr s) ⦃ta'⦄⇘t⇙)(t' ↦ (X'::'addr option × 'addr frame list, redT_updLns (locks s) t' no_wait_locks ⦃ta'⦄⇘l⇙)), M'::'heap), ws'::'thread_id ⇒ 'addr wait_set_status option, redT_updIs (interrupts s) ⦃ta'⦄⇘i⇙)›*) by simp moreover from tst (*‹thr s t = ⌊(x, no_wait_locks)⌋›*) ‹thread_oks (thr s) ⦃ta'⦄⇘t⇙› (*‹thread_oks (thr s) ⦃ta'⦄⇘t⇙›*) have "redT_updTs (thr s) ⦃ta'⦄⇘t⇙ t = ⌊(x, no_wait_locks)⌋" by (auto intro: redT_updTs_Some (*‹⟦?ts ?t = ⌊?xw⌋; thread_oks ?ts ?tas⟧ ⟹ redT_updTs ?ts ?tas ?t = ⌊?xw⌋›*)) ultimately show "?thesis" (*goal: ‹Φ ⊢ t:(xcp, shr s', frs) √›*) by (auto dest: ts_okD (*‹⟦ts_ok ?P ?ts ?m; ?ts ?t = ⌊(?x, ?ln)⌋⟧ ⟹ ?P ?t ?x ?m›*)) qed { assume "exec_mthr.must_sync P t x (shr s)" (*‹exec_mthr.must_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (x::'addr option × 'addr frame list) (shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set))›*) hence ml: "exec_mthr.must_sync P t (xcp, frs) (shr s)" by simp with cst (*‹Φ ⊢ t:(xcp, shr s, frs) √›*) have "execd_mthr.must_sync P t (xcp, frs) (shr s)" by (auto dest: must_lock_d_eq_must_lock[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?frs) √ ⟹ execd_mthr.must_sync P ?t (?xcp, ?frs) ?h = exec_mthr.must_sync P ?t (?xcp, ?frs) ?h›*)) with s (*‹(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list)›*) redd (*‹(P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set -t'::'thread_id::type▹ta'::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action→⇘jvmd⇙ (s'::('addr::addr, 'thread_id::type) locks × (('thread_id::type ⇒ (('addr::addr option × 'addr::addr frame list) × 'addr::addr ⇒f nat) option) × 'heap::type) × ('thread_id::type ⇒ 'addr::addr wait_set_status option) × 'thread_id::type set)›*) tst (*‹thr s t = ⌊(x, no_wait_locks)⌋›*) have "execd_mthr.must_sync P t x (shr s')" unfolding x (*goal: ‹execd_mthr.must_sync P t (xcp, frs) (shr s')›*) by (rule can_lock_preserved (*‹⟦(?s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ ?s -?t'::'thread_id▹?ta'::('addr, 'thread_id, 'heap) jvm_thread_action→⇘jvmd⇙ (?s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set); thr ?s (?t::'thread_id) = ⌊(?x::'addr option × 'addr frame list, no_wait_locks)⌋; execd_mthr.must_sync P ?t ?x (shr ?s)⟧ ⟹ execd_mthr.must_sync P ?t ?x (shr ?s')›*)) with cst' (*‹Φ ⊢ t:(xcp, shr s', frs) √›*) have "exec_mthr.must_sync P t x (shr s')" by (auto dest: must_lock_d_eq_must_lock[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?frs) √ ⟹ execd_mthr.must_sync P ?t (?xcp, ?frs) ?h = exec_mthr.must_sync P ?t (?xcp, ?frs) ?h›*)) } note ml = this (*‹exec_mthr.must_sync P t x (shr s) ⟹ exec_mthr.must_sync P t x (shr s')›*) { fix L assume "exec_mthr.can_sync P t x (shr s') L" (*‹exec_mthr.can_sync (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (x::'addr option × 'addr frame list) (shr (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set)) (L::('addr + 'thread_id + 'thread_id) set)›*) hence cl: "exec_mthr.can_sync P t (xcp, frs) (shr s') L" by simp with cst' (*‹Φ ⊢ t:(xcp, shr s', frs) √›*) have "execd_mthr.can_sync P t (xcp, frs) (shr s') L" by (auto dest: can_lock_d_eq_can_lock[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?frs) √ ⟹ execd_mthr.can_sync P ?t (?xcp, ?frs) ?h ?L = exec_mthr.can_sync P ?t (?xcp, ?frs) ?h ?L›*)) with s (*‹s ∈ correct_jvm_state Φ›*) redd (*‹P ⊢ s -t'▹ta'→⇘jvmd⇙ s'›*) tst (*‹thr s t = ⌊(x, no_wait_locks)⌋›*) have "∃L' ⊆ L. execd_mthr.can_sync P t x (shr s) L'" unfolding x (*goal: ‹∃L'⊆L. execd_mthr.can_sync P t (xcp, frs) (shr s) L'›*) by (rule can_lock_devreserp (*‹⟦?s ∈ correct_jvm_state Φ; P ⊢ ?s -?t'▹?ta'→⇘jvmd⇙ ?s'; thr ?s ?t = ⌊(?x, no_wait_locks)⌋; execd_mthr.can_sync P ?t ?x (shr ?s') ?L⟧ ⟹ ∃L'⊆?L. execd_mthr.can_sync P ?t ?x (shr ?s) L'›*)) then obtain L' where "execd_mthr.can_sync P t x (shr s) L'" and L': "L'⊆ L" (*goal: ‹(⋀L'. ⟦execd_mthr.can_sync P t x (shr s) L'; L' ⊆ L⟧ ⟹ thesis) ⟹ thesis›*) by blast with cst (*‹(Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list) ⊢ t::'thread_id:(xcp::'addr option, shr (s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set), frs::'addr frame list) √›*) have "exec_mthr.can_sync P t x (shr s) L'" by (auto dest: can_lock_d_eq_can_lock[OF wf] (*‹Φ ⊢ ?t:(?xcp, ?h, ?frs) √ ⟹ execd_mthr.can_sync P ?t (?xcp, ?frs) ?h ?L = exec_mthr.can_sync P ?t (?xcp, ?frs) ?h ?L›*)) with L' (*‹L' ⊆ L›*) have "∃L' ⊆ L. exec_mthr.can_sync P t x (shr s) L'" by blast } note this (*‹exec_mthr.can_sync P t x (shr s') ?L17 ⟹ ∃L'⊆?L17. exec_mthr.can_sync P t x (shr s) L'›*) ml (*‹exec_mthr.must_sync P t x (shr s) ⟹ exec_mthr.must_sync P t x (shr s')›*) } moreover have "invariant3p (mexecT P) (correct_jvm_state Φ)" by (rule invariant3p_correct_jvm_state_mexecT[OF wf] (*‹invariant3p (mexecT P) (correct_jvm_state Φ)›*)) ultimately show "?thesis" (*goal: ‹preserve_deadlocked JVM_final (mexec (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog)) convert_RA (correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list))›*) apply unfold_locales (*goals: 1. ‹⟦⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) (x::'addr option × 'addr frame list) L::('addr + 'thread_id + 'thread_id) set. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. exec_mthr.can_sync P t x (shr s) L'; ⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) x::'addr option × 'addr frame list. ⟦s ∈ correct_jvm_state Φ; P ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.must_sync P t x (shr s)⟧ ⟹ exec_mthr.must_sync P t x (shr s'); invariant3p (mexecT P) (correct_jvm_state Φ)⟧ ⟹ invariant3p (mexecT P) (correct_jvm_state Φ)› 2. ‹⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) x::'addr option × 'addr frame list. ⟦⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) (x::'addr option × 'addr frame list) L::('addr + 'thread_id + 'thread_id) set. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. exec_mthr.can_sync P t x (shr s) L'; ⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) x::'addr option × 'addr frame list. ⟦s ∈ correct_jvm_state Φ; P ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.must_sync P t x (shr s)⟧ ⟹ exec_mthr.must_sync P t x (shr s'); invariant3p (mexecT P) (correct_jvm_state Φ); s ∈ correct_jvm_state Φ; P ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.must_sync P t x (shr s)⟧ ⟹ exec_mthr.must_sync P t x (shr s')› 3. ‹⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) (x::'addr option × 'addr frame list) L::('addr + 'thread_id + 'thread_id) set. ⟦⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) (x::'addr option × 'addr frame list) L::('addr + 'thread_id + 'thread_id) set. ⟦s ∈ correct_jvm_state (Φ::String.literal ⇒ String.literal ⇒ (ty list × ty err list) option list); (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. exec_mthr.can_sync P t x (shr s) L'; ⋀(s::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t'::'thread_id) (ta'::('addr, 'thread_id, 'heap) jvm_thread_action) (s'::('addr, 'thread_id) locks × (('thread_id ⇒ (('addr option × 'addr frame list) × 'addr ⇒f nat) option) × 'heap) × ('thread_id ⇒ 'addr wait_set_status option) × 'thread_id set) (t::'thread_id) x::'addr option × 'addr frame list. ⟦s ∈ correct_jvm_state Φ; P ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.must_sync P t x (shr s)⟧ ⟹ exec_mthr.must_sync P t x (shr s'); invariant3p (mexecT P) (correct_jvm_state Φ); s ∈ correct_jvm_state Φ; P ⊢ s -t'▹ta'→⇘jvm⇙ s'; thr s t = ⌊(x, no_wait_locks)⌋; exec_mthr.can_sync P t x (shr s') L⟧ ⟹ ∃L'⊆L. exec_mthr.can_sync P t x (shr s) L'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) qed end end
{ "path": "afp-2025-02-12/thys/JinjaThreads/BV/JVMDeadlocked.thy", "repo": "afp-2025-02-12", "sha": "33a7e0a190061766154fe64d624e3fc98b292fa47001346613329cbe97e7a1ec" }
(*<*) theory Typing imports RCLogic WellformedL begin (*>*) chapter ‹Type System› text ‹The MiniSail type system. We define subtyping judgement first and then typing judgement for the term forms› section ‹Subtyping› text ‹ Subtyping is defined on top of refinement constraint logic (RCL). A subtyping check is converted into an RCL validity check. › inductive subtype :: "Θ ⇒ ℬ ⇒ Γ ⇒ τ ⇒ τ ⇒ bool" ("_ ; _ ; _ ⊢ _ ≲ _" [50, 50, 50] 50) where subtype_baseI: "⟦ atom x ♯ (Θ, ℬ, Γ, z,c,z',c') ; Θ; ℬ; Γ ⊢⇩w⇩f ⦃ z : b | c ⦄; Θ; ℬ; Γ ⊢⇩w⇩f ⦃ z' : b | c' ⦄; Θ; ℬ ; (x,b, c[z::=[x]⇧v]⇩v) #⇩Γ Γ ⊨ c'[z'::=[x]⇧v]⇩v ⟧ ⟹ Θ; ℬ; Γ ⊢ ⦃ z : b | c ⦄ ≲ ⦃ z' : b | c' ⦄" equivariance subtype nominal_inductive subtype avoids subtype_baseI: x proof(goal_cases) case (1 Θ ℬ Γ z b c z' c' x) then show ?case using fresh_star_def 1 by force next case (2 Θ ℬ Γ z b c z' c' x) then show ?case by auto qed inductive_cases subtype_elims: "Θ; ℬ; Γ ⊢ ⦃ z : b | c ⦄ ≲ ⦃ z' : b | c' ⦄" "Θ; ℬ; Γ ⊢ τ₁ ≲ τ₂" section ‹Literals› text ‹The type synthesised has the constraint that z equates to the literal› inductive infer_l :: "l ⇒ τ ⇒ bool" (" ⊢ _ ⇒ _" [50, 50] 50) where infer_trueI: " ⊢ L_true ⇒ ⦃ z : B_bool | [[z]⇧v]⇧c⇧e == [[L_true]⇧v]⇧c⇧e ⦄" | infer_falseI: " ⊢ L_false ⇒ ⦃ z : B_bool | [[z]⇧v]⇧c⇧e == [[L_false]⇧v]⇧c⇧e ⦄" | infer_natI: " ⊢ L_num n ⇒ ⦃ z : B_int | [[z]⇧v]⇧c⇧e == [[L_num n]⇧v]⇧c⇧e ⦄" | infer_unitI: " ⊢ L_unit ⇒ ⦃ z : B_unit | [[z]⇧v]⇧c⇧e == [[L_unit]⇧v]⇧c⇧e ⦄" | infer_bitvecI: " ⊢ L_bitvec bv ⇒ ⦃ z : B_bitvec | [[z]⇧v]⇧c⇧e == [[L_bitvec bv]⇧v]⇧c⇧e ⦄" nominal_inductive infer_l . equivariance infer_l inductive_cases infer_l_elims[elim!]: "⊢ L_true ⇒ τ" "⊢ L_false ⇒ τ" "⊢ L_num n ⇒ τ" "⊢ L_unit ⇒ τ" "⊢ L_bitvec x ⇒ τ" "⊢ l ⇒ τ" lemma infer_l_form2[simp]: shows "∃z. ⊢ l ⇒ (⦃ z : base_for_lit l | [[z]⇧v]⇧c⇧e == [[l]⇧v]⇧c⇧e ⦄)" proof (nominal_induct l rule: l.strong_induct) (*goals: 1. ‹⋀x::int. ∃z::x. ⊢ L_num x ⇒ ⦃ z : base_for_lit (L_num x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_num x ]⇧v ]⇧c⇧e ⦄› 2. ‹∃z::x. ⊢ L_true ⇒ ⦃ z : base_for_lit L_true | [ [ z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› 3. ‹∃z::x. ⊢ L_false ⇒ ⦃ z : base_for_lit L_false | [ [ z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› 4. ‹∃z::x. ⊢ L_unit ⇒ ⦃ z : base_for_lit L_unit | [ [ z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› 5. ‹⋀x::bit list. ∃z::x. ⊢ L_bitvec x ⇒ ⦃ z : base_for_lit (L_bitvec x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_bitvec x ]⇧v ]⇧c⇧e ⦄›*) case (L_num x) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃z. ⊢ L_num x ⇒ ⦃ z : base_for_lit (L_num x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_num x ]⇧v ]⇧c⇧e ⦄›*) using infer_l.intros (*‹ ⊢ L_true ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_false ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_num ?n ⇒ ⦃ ?z : B_int | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_num ?n ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_unit ⇒ ⦃ ?z : B_unit | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_bitvec ?bv ⇒ ⦃ ?z : B_bitvec | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_bitvec ?bv ]⇧v ]⇧c⇧e ⦄›*) base_for_lit.simps (*‹base_for_lit L_true = B_bool› ‹base_for_lit L_false = B_bool› ‹base_for_lit (L_num ?n) = B_int› ‹base_for_lit L_unit = B_unit› ‹base_for_lit (L_bitvec ?v) = B_bitvec›*) has_fresh_z (*‹∃z b c. atom z ♯ ?t ∧ ?τ = ⦃ z : b | c ⦄›*) by metis next (*goals: 1. ‹∃z. ⊢ L_true ⇒ ⦃ z : base_for_lit L_true | [ [ z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› 2. ‹∃z. ⊢ L_false ⇒ ⦃ z : base_for_lit L_false | [ [ z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› 3. ‹∃z. ⊢ L_unit ⇒ ⦃ z : base_for_lit L_unit | [ [ z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› 4. ‹⋀x. ∃z. ⊢ L_bitvec x ⇒ ⦃ z : base_for_lit (L_bitvec x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_bitvec x ]⇧v ]⇧c⇧e ⦄›*) case L_true (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃z. ⊢ L_true ⇒ ⦃ z : base_for_lit L_true | [ [ z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄›*) using infer_l.intros (*‹ ⊢ L_true ⇒ ⦃ (?z::x) : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_false ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_num ?n ⇒ ⦃ ?z : B_int | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_num ?n ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_unit ⇒ ⦃ (?z::x) : B_unit | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_bitvec ?bv ⇒ ⦃ ?z : B_bitvec | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_bitvec ?bv ]⇧v ]⇧c⇧e ⦄›*) base_for_lit.simps (*‹base_for_lit L_true = B_bool› ‹base_for_lit L_false = B_bool› ‹base_for_lit (L_num ?n) = B_int› ‹base_for_lit L_unit = B_unit› ‹base_for_lit (L_bitvec (?v::bit list)) = B_bitvec›*) has_fresh_z (*‹∃z b c. atom z ♯ ?t ∧ ?τ = ⦃ z : b | c ⦄›*) by metis next (*goals: 1. ‹∃z. ⊢ L_false ⇒ ⦃ z : base_for_lit L_false | [ [ z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› 2. ‹∃z. ⊢ L_unit ⇒ ⦃ z : base_for_lit L_unit | [ [ z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› 3. ‹⋀x. ∃z. ⊢ L_bitvec x ⇒ ⦃ z : base_for_lit (L_bitvec x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_bitvec x ]⇧v ]⇧c⇧e ⦄›*) case L_false (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃z::x. ⊢ L_false ⇒ ⦃ z : base_for_lit L_false | [ [ z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄›*) using infer_l.intros (*‹ ⊢ L_true ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_false ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_num ?n ⇒ ⦃ ?z : B_int | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_num ?n ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_unit ⇒ ⦃ ?z : B_unit | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_bitvec ?bv ⇒ ⦃ ?z : B_bitvec | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_bitvec ?bv ]⇧v ]⇧c⇧e ⦄›*) base_for_lit.simps (*‹base_for_lit L_true = B_bool› ‹base_for_lit L_false = B_bool› ‹base_for_lit (L_num (?n::int)) = B_int› ‹base_for_lit L_unit = B_unit› ‹base_for_lit (L_bitvec ?v) = B_bitvec›*) has_fresh_z (*‹∃z b c. atom z ♯ ?t ∧ ?τ = ⦃ z : b | c ⦄›*) by metis next (*goals: 1. ‹∃z. ⊢ L_unit ⇒ ⦃ z : base_for_lit L_unit | [ [ z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› 2. ‹⋀x. ∃z. ⊢ L_bitvec x ⇒ ⦃ z : base_for_lit (L_bitvec x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_bitvec x ]⇧v ]⇧c⇧e ⦄›*) case L_unit (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃z::x. ⊢ L_unit ⇒ ⦃ z : base_for_lit L_unit | [ [ z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄›*) using infer_l.intros (*‹ ⊢ L_true ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_false ⇒ ⦃ (?z::x) : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_num ?n ⇒ ⦃ ?z : B_int | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_num ?n ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_unit ⇒ ⦃ ?z : B_unit | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_bitvec (?bv::bit list) ⇒ ⦃ (?z::x) : B_bitvec | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_bitvec ?bv ]⇧v ]⇧c⇧e ⦄›*) base_for_lit.simps (*‹base_for_lit L_true = B_bool› ‹base_for_lit L_false = B_bool› ‹base_for_lit (L_num ?n) = B_int› ‹base_for_lit L_unit = B_unit› ‹base_for_lit (L_bitvec ?v) = B_bitvec›*) has_fresh_z (*‹∃z b c. atom z ♯ ?t ∧ ?τ = ⦃ z : b | c ⦄›*) by metis next (*goal: ‹⋀x. ∃z. ⊢ L_bitvec x ⇒ ⦃ z : base_for_lit (L_bitvec x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_bitvec x ]⇧v ]⇧c⇧e ⦄›*) case (L_bitvec x) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃z. ⊢ L_bitvec x ⇒ ⦃ z : base_for_lit (L_bitvec x) | [ [ z ]⇧v ]⇧c⇧e == [ [ L_bitvec x ]⇧v ]⇧c⇧e ⦄›*) using infer_l.intros (*‹ ⊢ L_true ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_true ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_false ⇒ ⦃ ?z : B_bool | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_false ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_num ?n ⇒ ⦃ ?z : B_int | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_num ?n ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_unit ⇒ ⦃ ?z : B_unit | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_unit ]⇧v ]⇧c⇧e ⦄› ‹ ⊢ L_bitvec ?bv ⇒ ⦃ ?z : B_bitvec | [ [ ?z ]⇧v ]⇧c⇧e == [ [ L_bitvec ?bv ]⇧v ]⇧c⇧e ⦄›*) base_for_lit.simps (*‹base_for_lit L_true = B_bool› ‹base_for_lit L_false = B_bool› ‹base_for_lit (L_num ?n) = B_int› ‹base_for_lit L_unit = B_unit› ‹base_for_lit (L_bitvec ?v) = B_bitvec›*) has_fresh_z (*‹∃z b c. atom z ♯ ?t ∧ ?τ = ⦃ z : b | c ⦄›*) by metis qed section ‹Values› inductive infer_v :: "Θ ⇒ ℬ ⇒ Γ ⇒ v ⇒ τ ⇒ bool" (" _ ; _ ; _ ⊢ _ ⇒ _" [50, 50, 50] 50) where infer_v_varI: "⟦ Θ; ℬ ⊢⇩w⇩f Γ ; Some (b,c) = lookup Γ x; atom z ♯ x ; atom z ♯ (Θ, ℬ, Γ) ⟧ ⟹ Θ; ℬ; Γ ⊢ [x]⇧v ⇒ ⦃ z : b | [[z]⇧v]⇧c⇧e == [[x]⇧v]⇧c⇧e ⦄" | infer_v_litI: "⟦ Θ; ℬ ⊢⇩w⇩f Γ ; ⊢ l ⇒ τ ⟧ ⟹ Θ; ℬ; Γ ⊢ [l]⇧v ⇒ τ" | infer_v_pairI: "⟦ atom z ♯ (v1, v2); atom z ♯ (Θ, ℬ, Γ) ; Θ; ℬ; Γ ⊢ (v1::v) ⇒ t1 ; Θ; ℬ ; Γ ⊢ (v2::v) ⇒ t2 ⟧ ⟹ Θ; ℬ; Γ ⊢ V_pair v1 v2 ⇒ (⦃ z : B_pair (b_of t1) (b_of t2) | [[z]⇧v]⇧c⇧e == [[v1,v2]⇧v]⇧c⇧e ⦄) " | infer_v_consI: "⟦ AF_typedef s dclist ∈ set Θ; (dc, tc) ∈ set dclist ; Θ; ℬ; Γ ⊢ v ⇒ tv ; Θ; ℬ; Γ ⊢ tv ≲ tc ; atom z ♯ v ; atom z ♯ (Θ, ℬ, Γ) ⟧ ⟹ Θ; ℬ; Γ ⊢ V_cons s dc v ⇒ (⦃ z : B_id s | [[z]⇧v]⇧c⇧e == [ V_cons s dc v ]⇧c⇧e ⦄)" | infer_v_conspI: "⟦ AF_typedef_poly s bv dclist ∈ set Θ; (dc, tc) ∈ set dclist ; Θ; ℬ; Γ ⊢ v ⇒ tv; Θ; ℬ; Γ ⊢ tv ≲ tc[bv::=b]⇩τ⇩b ; atom z ♯ (Θ, ℬ, Γ, v, b); atom bv ♯ (Θ, ℬ, Γ, v, b); Θ; ℬ ⊢⇩w⇩f b ⟧ ⟹ Θ; ℬ; Γ ⊢ V_consp s dc b v ⇒ (⦃ z : B_app s b | [[z]⇧v]⇧c⇧e == (CE_val (V_consp s dc b v)) ⦄)" equivariance infer_v nominal_inductive infer_v avoids infer_v_conspI: bv and z | infer_v_varI: z | infer_v_pairI: z | infer_v_consI: z proof(goal_cases) case (1 Θ ℬ Γ b c x z) hence "atom z ♯ ⦃ z : b | [ [ z ]⇧v ]⇧c⇧e == [ [ x ]⇧v ]⇧c⇧e ⦄" using τ.fresh by simp then show ?case unfolding fresh_star_def using 1 by simp next case (2 Θ ℬ Γ b c x z) then show ?case by auto next case (3 z v1 v2 Θ ℬ Γ t1 t2) hence "atom z ♯ ⦃ z : [ b_of t1 , b_of t2 ]⇧b | [ [ z ]⇧v ]⇧c⇧e == [ [ v1 , v2 ]⇧v ]⇧c⇧e ⦄" using τ.fresh by simp then show ?case unfolding fresh_star_def using 3 by simp next case (4 z v1 v2 Θ ℬ Γ t1 t2) then show ?case by auto next case (5 s dclist Θ dc tc ℬ Γ v tv z) hence "atom z ♯ ⦃ z : B_id s | [ [ z ]⇧v ]⇧c⇧e == [ V_cons s dc v ]⇧c⇧e ⦄" using τ.fresh b.fresh pure_fresh by auto moreover have "atom z ♯ V_cons s dc v" using v.fresh 5 using v.fresh fresh_prodN pure_fresh by metis then show ?case unfolding fresh_star_def using 5 by simp next case (6 s dclist Θ dc tc ℬ Γ v tv z) then show ?case by auto next case (7 s bv dclist Θ dc tc ℬ Γ v tv b z) hence "atom bv ♯ V_consp s dc b v" using v.fresh fresh_prodN pure_fresh by metis moreover then have "atom bv ♯ ⦃ z : B_id s | [ [ z ]⇧v ]⇧c⇧e == [ V_consp s dc b v ]⇧c⇧e ⦄" using τ.fresh ce.fresh v.fresh by auto moreover have "atom z ♯ V_consp s dc b v" using v.fresh fresh_prodN pure_fresh 7 by metis moreover then have "atom z ♯ ⦃ z : B_id s | [ [ z ]⇧v ]⇧c⇧e == [ V_consp s dc b v ]⇧c⇧e ⦄" using τ.fresh ce.fresh v.fresh by auto ultimately show ?case using fresh_star_def 7 by force next case (8 s bv dclist Θ dc tc ℬ Γ v tv b z) then show ?case by auto qed inductive_cases infer_v_elims[elim!]: "Θ; ℬ; Γ ⊢ V_var x ⇒ τ" "Θ; ℬ; Γ ⊢ V_lit l ⇒ τ" "Θ; ℬ; Γ ⊢ V_pair v1 v2 ⇒ τ" "Θ; ℬ; Γ ⊢ V_cons s dc v ⇒ τ" "Θ; ℬ; Γ ⊢ V_pair v1 v2 ⇒ (⦃ z : b | c ⦄) " "Θ; ℬ; Γ ⊢ V_pair v1 v2 ⇒ (⦃ z : [ b1 , b2 ]⇧b | [[z]⇧v]⇧c⇧e == [[v1,v2]⇧v]⇧c⇧e ⦄) " "Θ; ℬ; Γ ⊢ V_consp s dc b v ⇒ τ " inductive check_v :: "Θ ⇒ ℬ ⇒ Γ ⇒ v ⇒ τ ⇒ bool" ("_ ; _ ; _ ⊢ _ ⇐ _" [50, 50, 50] 50) where check_v_subtypeI: "⟦ Θ; ℬ; Γ ⊢ τ1 ≲ τ2; Θ; ℬ; Γ ⊢ v ⇒ τ1 ⟧ ⟹ Θ; ℬ ; Γ ⊢ v ⇐ τ2" equivariance check_v nominal_inductive check_v . inductive_cases check_v_elims[elim!]: "Θ; ℬ ; Γ ⊢ v ⇐ τ" section ‹Expressions› text ‹ Type synthesis for expressions › inductive infer_e :: "Θ ⇒ Φ ⇒ ℬ ⇒ Γ ⇒ Δ ⇒ e ⇒ τ ⇒ bool" ("_ ; _ ; _ ; _ ; _ ⊢ _ ⇒ _" [50, 50, 50,50] 50) where infer_e_valI: "⟦ (Θ; ℬ; Γ ⊢⇩w⇩f Δ) ; (Θ ⊢⇩w⇩f (Φ::Φ)) ; (Θ; ℬ; Γ ⊢ v ⇒ τ) ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (AE_val v) ⇒ τ" | infer_e_plusI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v1 ⇒ ⦃ z1 : B_int | c1 ⦄ ; Θ; ℬ; Γ ⊢ v2 ⇒ ⦃ z2 : B_int | c2 ⦄; atom z3 ♯ (AE_op Plus v1 v2); atom z3 ♯ Γ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_op Plus v1 v2 ⇒ ⦃ z3 : B_int | [[z3]⇧v]⇧c⇧e == (CE_op Plus [v1]⇧c⇧e [v2]⇧c⇧e) ⦄" | infer_e_leqI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v1 ⇒ ⦃ z1 : B_int | c1 ⦄ ; Θ; ℬ; Γ ⊢ v2 ⇒ ⦃ z2 : B_int | c2 ⦄; atom z3 ♯ (AE_op LEq v1 v2); atom z3 ♯ Γ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_op LEq v1 v2 ⇒ ⦃ z3 : B_bool | [[z3]⇧v]⇧c⇧e == (CE_op LEq [v1]⇧c⇧e [v2]⇧c⇧e) ⦄" | infer_e_eqI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v1 ⇒ ⦃ z1 : b | c1 ⦄ ; Θ; ℬ; Γ ⊢ v2 ⇒ ⦃ z2 : b | c2 ⦄; atom z3 ♯ (AE_op Eq v1 v2); atom z3 ♯ Γ ; b ∈ { B_bool, B_int, B_unit } ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_op Eq v1 v2 ⇒ ⦃ z3 : B_bool | [[z3]⇧v]⇧c⇧e == (CE_op Eq [v1]⇧c⇧e [v2]⇧c⇧e) ⦄" | infer_e_appI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Some (AF_fundef f (AF_fun_typ_none (AF_fun_typ x b c τ' s'))) = lookup_fun Φ f; Θ; ℬ; Γ ⊢ v ⇐ ⦃ x : b | c ⦄; atom x ♯ (Θ, Φ, ℬ, Γ, Δ,v , τ); τ'[x::=v]⇩v = τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_app f v ⇒ τ" | infer_e_appPI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ ⊢⇩w⇩f b' ; Some (AF_fundef f (AF_fun_typ_some bv (AF_fun_typ x b c τ' s'))) = lookup_fun Φ f; Θ; ℬ; Γ ⊢ v ⇐ ⦃ x : b[bv::=b']⇩b | c[bv::=b']⇩b ⦄; atom x ♯ Γ; (τ'[bv::=b']⇩b[x::=v]⇩v) = τ ; atom bv ♯ (Θ, Φ, ℬ, Γ, Δ, b', v, τ) ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_appP f b' v ⇒ τ" | infer_e_fstI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v ⇒ ⦃ z' : [b1,b2]⇧b | c ⦄; atom z ♯ AE_fst v ; atom z ♯ Γ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_fst v ⇒ ⦃ z : b1 | [[z]⇧v]⇧c⇧e == ((CE_fst [v]⇧c⇧e)) ⦄" | infer_e_sndI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v ⇒ ⦃ z' : [ b1, b2]⇧b | c ⦄; atom z ♯ AE_snd v ; atom z ♯ Γ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_snd v ⇒ ⦃ z : b2 | [[z]⇧v]⇧c⇧e == ((CE_snd [v]⇧c⇧e)) ⦄" | infer_e_lenI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v ⇒ ⦃ z' : B_bitvec | c ⦄; atom z ♯ AE_len v ; atom z ♯ Γ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_len v ⇒ ⦃ z : B_int | [[z]⇧v]⇧c⇧e == ((CE_len [v]⇧c⇧e)) ⦄" | infer_e_mvarI: "⟦ Θ; ℬ ⊢⇩w⇩f Γ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢⇩w⇩f Δ; (u,τ) ∈ setD Δ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_mvar u ⇒ τ" | infer_e_concatI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ) ; Θ; ℬ; Γ ⊢ v1 ⇒ ⦃ z1 : B_bitvec | c1 ⦄ ; Θ; ℬ; Γ ⊢ v2 ⇒ ⦃ z2 : B_bitvec | c2 ⦄; atom z3 ♯ (AE_concat v1 v2); atom z3 ♯ Γ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AE_concat v1 v2 ⇒ ⦃ z3 : B_bitvec | [[z3]⇧v]⇧c⇧e == (CE_concat [v1]⇧c⇧e [v2]⇧c⇧e) ⦄" | infer_e_splitI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f (Φ::Φ); Θ ; ℬ ; Γ ⊢ v1 ⇒ ⦃ z1 : B_bitvec | c1 ⦄ ; Θ ; ℬ ; Γ ⊢ v2 ⇐ ⦃ z2 : B_int | (CE_op LEq (CE_val (V_lit (L_num 0))) (CE_val (V_var z2))) == (CE_val (V_lit L_true)) AND (CE_op LEq (CE_val (V_var z2)) (CE_len (CE_val (v1)))) == (CE_val (V_lit L_true)) ⦄; atom z1 ♯ (AE_split v1 v2); atom z1 ♯ Γ; atom z2 ♯ (AE_split v1 v2); atom z2 ♯ Γ; atom z3 ♯ (AE_split v1 v2); atom z3 ♯ Γ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (AE_split v1 v2) ⇒ ⦃ z3 : B_pair B_bitvec B_bitvec | ((CE_val v1) == (CE_concat (CE_fst (CE_val (V_var z3))) (CE_snd (CE_val (V_var z3))))) AND (((CE_len (CE_fst (CE_val (V_var z3))))) == (CE_val ( v2))) ⦄" equivariance infer_e nominal_inductive infer_e avoids infer_e_appI: x |infer_e_appPI: bv | infer_e_splitI: z3 and z1 and z2 proof(goal_cases) case (1 Θ ℬ Γ Δ Φ f x b c τ' s' v τ) moreover hence "atom x ♯ [ f v ]⇧e" using fresh_prodN pure_fresh e.fresh by force ultimately show ?case unfolding fresh_star_def using fresh_prodN e.fresh pure_fresh by simp next case (2 Θ ℬ Γ Δ Φ f x b c τ' s' v τ) then show ?case by auto next case (3 Θ ℬ Γ Δ Φ b' f bv x b c τ' s' v τ) moreover hence "atom bv ♯ AE_appP f b' v" using fresh_prodN pure_fresh e.fresh by force ultimately show ?case unfolding fresh_star_def using fresh_prodN e.fresh pure_fresh fresh_Pair by auto next case (4 Θ ℬ Γ Δ Φ b' f bv x b c τ' s' v τ) then show ?case by auto next case (5 Θ ℬ Γ Δ Φ v1 z1 c1 v2 z2 z3) have "atom z3 ♯ ⦃ z3 : [ B_bitvec , B_bitvec ]⇧b | [ v1 ]⇧c⇧e == [ [#1[ [ z3 ]⇧v ]⇧c⇧e]⇧c⇧e @@ [#2[ [ z3 ]⇧v ]⇧c⇧e]⇧c⇧e ]⇧c⇧e AND [| [#1[ [ z3 ]⇧v ]⇧c⇧e]⇧c⇧e |]⇧c⇧e == [ v2 ]⇧c⇧e ⦄" using τ.fresh by simp then show ?case unfolding fresh_star_def fresh_prod7 using wfG_fresh_x2 5 by auto next case (6 Θ ℬ Γ Δ Φ v1 z1 c1 v2 z2 z3) then show ?case by auto qed inductive_cases infer_e_elims[elim!]: "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Plus v1 v2) ⇒ ⦃ z3 : B_int | [[z3]⇧v]⇧c⇧e == (CE_op Plus [v1]⇧c⇧e [v2]⇧c⇧e) ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op LEq v1 v2) ⇒ ⦃ z3 : B_bool | [[z3]⇧v]⇧c⇧e == (CE_op LEq [v1]⇧c⇧e [v2]⇧c⇧e) ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Plus v1 v2) ⇒ ⦃ z3 : B_int | c ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Plus v1 v2) ⇒ ⦃ z3 : b | c ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op LEq v1 v2) ⇒ ⦃ z3 : b | c ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_app f v ) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_val v) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_fst v) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_snd v) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_mvar u) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Plus v1 v2) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op LEq v1 v2) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op LEq v1 v2) ⇒ ⦃ z3 : B_bool | c ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_app f v ) ⇒ τ[x::=v]⇩τ⇩v" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op opp v1 v2) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_len v) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_len v) ⇒ ⦃ z : B_int | [[z]⇧v]⇧c⇧e == ((CE_len [v]⇧c⇧e))⦄ " "Θ; Φ; ℬ; Γ; Δ ⊢ AE_concat v1 v2 ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AE_concat v1 v2 ⇒ (⦃ z : b | c ⦄) " "Θ; Φ; ℬ; Γ; Δ ⊢ AE_concat v1 v2 ⇒ (⦃ z : B_bitvec | [[z]⇧v]⇧c⇧e == (CE_concat [v1]⇧c⇧e [v1]⇧c⇧e) ⦄) " "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_appP f b v ) ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AE_split v1 v2 ⇒ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Eq v1 v2) ⇒ ⦃ z3 : b | c ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Eq v1 v2) ⇒ ⦃ z3 : B_bool | c ⦄" "Θ; Φ; ℬ; Γ; Δ ⊢ (AE_op Eq v1 v2) ⇒ τ" nominal_termination (eqvt) by lexicographic_order section ‹Statements› inductive check_s :: "Θ ⇒ Φ ⇒ ℬ ⇒ Γ ⇒ Δ ⇒ s ⇒ τ ⇒ bool" (" _ ; _ ; _ ; _ ; _ ⊢ _ ⇐ _" [50, 50, 50,50,50] 50) and check_branch_s :: "Θ ⇒ Φ ⇒ ℬ ⇒ Γ ⇒ Δ ⇒ tyid ⇒ string ⇒ τ ⇒ v ⇒ branch_s ⇒ τ ⇒ bool" (" _ ; _ ; _ ; _ ; _ ; _ ; _ ; _ ; _ ⊢ _ ⇐ _" [50, 50, 50,50,50] 50) and check_branch_list :: "Θ ⇒ Φ ⇒ ℬ ⇒ Γ ⇒ Δ ⇒ tyid ⇒ (string * τ) list ⇒ v ⇒ branch_list ⇒ τ ⇒ bool" (" _ ; _ ; _ ; _ ; _ ; _ ; _ ; _ ⊢ _ ⇐ _" [50, 50, 50,50,50] 50) where check_valI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; Θ ⊢⇩w⇩f Φ ; Θ; ℬ; Γ ⊢ v ⇒ τ'; Θ; ℬ; Γ ⊢ τ' ≲ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (AS_val v) ⇐ τ" | check_letI: "⟦ atom x ♯ (Θ, Φ, ℬ, Γ, Δ, e, τ); atom z ♯ (x, Θ, Φ, ℬ, Γ, Δ, e, τ, s); Θ; Φ; ℬ; Γ; Δ ⊢ e ⇒ ⦃ z : b | c ⦄ ; Θ; Φ ; ℬ ; ((x,b,c[z::=V_var x]⇩v)#⇩ΓΓ) ; Δ ⊢ s ⇐ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (AS_let x e s) ⇐ τ" | check_assertI: "⟦ atom x ♯ (Θ, Φ, ℬ, Γ, Δ, c, τ, s); Θ; Φ ; ℬ ; ((x,B_bool,c)#⇩ΓΓ) ; Δ ⊢ s ⇐ τ ; Θ; ℬ; Γ ⊨ c; Θ; ℬ; Γ ⊢⇩w⇩f Δ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (AS_assert c s) ⇐ τ" |check_branch_s_branchI: "⟦ Θ; ℬ; Γ ⊢⇩w⇩f Δ ; ⊢⇩w⇩f Θ ; Θ; ℬ; Γ ⊢⇩w⇩f τ ; Θ ; {||} ; GNil ⊢⇩w⇩f const; atom x ♯ (Θ, Φ, ℬ, Γ, Δ, tid, cons , const, v, τ); Θ; Φ; ℬ; ((x,b_of const, ([v]⇧c⇧e == [ V_cons tid cons [x]⇧v]⇧c⇧e ) AND (c_of const x))#⇩ΓΓ) ; Δ ⊢ s ⇐ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ; tid ; cons ; const ; v ⊢ (AS_branch cons x s) ⇐ τ" |check_branch_list_consI: "⟦ Θ; Φ; ℬ; Γ; Δ; tid; cons; const; v ⊢ cs ⇐ τ ; Θ; Φ; ℬ; Γ; Δ; tid; dclist; v ⊢ css ⇐ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ; tid ; (cons,const)#dclist ; v ⊢ AS_cons cs css ⇐ τ" |check_branch_list_finalI: "⟦ Θ; Φ;ℬ; Γ; Δ; tid ; cons ; const ; v ⊢ cs ⇐ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ; tid ; [(cons,const)] ; v ⊢ AS_final cs ⇐ τ" | check_ifI: "⟦ atom z ♯ (Θ, Φ, ℬ, Γ, Δ, v , s1 , s2 , τ ); (Θ; ℬ; Γ ⊢ v ⇐ (⦃ z : B_bool | TRUE ⦄)) ; Θ; Φ; ℬ; Γ; Δ ⊢ s1 ⇐ (⦃ z : b_of τ | ([v]⇧c⇧e == [[L_true]⇧v]⇧c⇧e) IMP (c_of τ z) ⦄) ; Θ; Φ; ℬ; Γ; Δ ⊢ s2 ⇐ (⦃ z : b_of τ | ([v]⇧c⇧e == [[L_false]⇧v]⇧c⇧e) IMP (c_of τ z) ⦄) ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ IF v THEN s1 ELSE s2 ⇐ τ" | check_let2I: "⟦ atom x ♯ (Θ, Φ, ℬ, G, Δ, t, s1, τ) ; Θ; Φ ; ℬ ; G; Δ ⊢ s1 ⇐ t; Θ; Φ ; ℬ ; ((x,b_of t,c_of t x)#⇩ΓG) ; Δ ⊢ s2 ⇐ τ ⟧ ⟹ Θ; Φ ; ℬ ; G ; Δ ⊢ (LET x : t = s1 IN s2) ⇐ τ" | check_varI: "⟦ atom u ♯ (Θ, Φ, ℬ, Γ, Δ, τ', v, τ) ; Θ; ℬ; Γ ⊢ v ⇐ τ'; Θ; Φ; ℬ; Γ ; ((u,τ') #⇩Δ Δ) ⊢ s ⇐ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (VAR u : τ' = v IN s) ⇐ τ" | check_assignI: "⟦ Θ ⊢⇩w⇩f Φ ; Θ; ℬ; Γ ⊢⇩w⇩f Δ ; (u,τ) ∈ setD Δ ; Θ; ℬ; Γ ⊢ v ⇐ τ; Θ; ℬ; Γ ⊢ (⦃ z : B_unit | TRUE ⦄) ≲ τ' ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ (u ::= v) ⇐ τ'" | check_whileI: "⟦ Θ; Φ; ℬ; Γ; Δ ⊢ s1 ⇐ ⦃ z : B_bool | TRUE ⦄; Θ; Φ; ℬ; Γ; Δ ⊢ s2 ⇐ ⦃ z : B_unit | TRUE ⦄; Θ; ℬ; Γ ⊢ (⦃ z : B_unit | TRUE ⦄) ≲ τ' ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ WHILE s1 DO { s2 } ⇐ τ'" | check_seqI: "⟦ Θ; Φ; ℬ; Γ; Δ ⊢ s1 ⇐ ⦃ z : B_unit | TRUE ⦄; Θ; Φ; ℬ; Γ; Δ ⊢ s2 ⇐ τ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ s1 ;; s2 ⇐ τ" | check_caseI: "⟦ Θ; Φ; ℬ; Γ; Δ; tid ; dclist ; v ⊢ cs ⇐ τ ; (AF_typedef tid dclist ) ∈ set Θ ; Θ; ℬ; Γ ⊢ v ⇐ ⦃ z : B_id tid | TRUE ⦄; ⊢⇩w⇩f Θ ⟧ ⟹ Θ; Φ; ℬ; Γ; Δ ⊢ AS_match v cs ⇐ τ" equivariance check_s text ‹We only need avoidance for cases where a variable is added to a context› nominal_inductive check_s avoids check_letI: x and z | check_branch_s_branchI: x | check_let2I: x | check_varI: u | check_ifI: z | check_assertI: x proof(goal_cases) case (1 x Θ Φ ℬ Γ Δ e τ z s b c) hence "atom x ♯ AS_let x e s" using s_branch_s_branch_list.fresh(2) by auto moreover have "atom z ♯ AS_let x e s" using s_branch_s_branch_list.fresh(2) 1 fresh_prod8 by auto then show ?case using fresh_star_def 1 by force next case (3 x Θ Φ ℬ Γ Δ c τ s) hence "atom x ♯ AS_assert c s" using fresh_prodN s_branch_s_branch_list.fresh pure_fresh by auto then show ?case using fresh_star_def 3 by force next case (5 Θ ℬ Γ Δ τ const x Φ tid cons v s) hence "atom x ♯ AS_branch cons x s" using fresh_prodN s_branch_s_branch_list.fresh pure_fresh by auto then show ?case using fresh_star_def 5 by force next case (7 z Θ Φ ℬ Γ Δ v s1 s2 τ) hence "atom z ♯ AS_if v s1 s2 " using s_branch_s_branch_list.fresh by auto then show ?case using 7 fresh_prodN fresh_star_def by fastforce next case (9 x Θ Φ ℬ G Δ t s1 τ s2) hence "atom x ♯ AS_let2 x t s1 s2" using s_branch_s_branch_list.fresh by auto thus ?case using fresh_star_def 9 by force next case (11 u Θ Φ ℬ Γ Δ τ' v τ s) hence "atom u ♯ AS_var u τ' v s" using s_branch_s_branch_list.fresh by auto then show ?case using fresh_star_def 11 by force qed(auto+) inductive_cases check_s_elims[elim!]: "Θ; Φ; ℬ; Γ; Δ ⊢ AS_val v ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_let x e s ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_if v s1 s2 ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_let2 x t s1 s2 ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_while s1 s2 ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_var u t v s ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_seq s1 s2 ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_assign u v ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_match v cs ⇐ τ" "Θ; Φ; ℬ; Γ; Δ ⊢ AS_assert c s ⇐ τ" inductive_cases check_branch_s_elims[elim!]: "Θ; Φ; ℬ; Γ; Δ; tid ; dclist ; v ⊢ (AS_final cs) ⇐ τ" "Θ; Φ; ℬ; Γ; Δ; tid ; dclist ; v ⊢ (AS_cons cs css) ⇐ τ" "Θ; Φ; ℬ; Γ; Δ; tid ; cons ; const ; v ⊢ (AS_branch dc x s ) ⇐ τ" section ‹Programs› text ‹Type check function bodies› inductive check_funtyp :: "Θ ⇒ Φ ⇒ ℬ ⇒ fun_typ ⇒ bool" ( " _ ; _ ; _ ⊢ _ " ) where check_funtypI: "⟦ atom x ♯ (Θ, Φ, B , b ); Θ; Φ ; B ; ((x,b,c) #⇩Γ GNil) ; []⇩Δ ⊢ s ⇐ τ ⟧ ⟹ Θ; Φ ; B ⊢ (AF_fun_typ x b c τ s)" equivariance check_funtyp nominal_inductive check_funtyp avoids check_funtypI: x proof(goal_cases) case (1 x Θ Φ B b c s τ ) hence "atom x ♯ (AF_fun_typ x b c τ s)" using fun_def.fresh fun_typ_q.fresh fun_typ.fresh by simp then show ?case using fresh_star_def 1 fresh_prodN by fastforce next case (2 Θ Φ x b c s τ f) then show ?case by auto qed inductive check_funtypq :: "Θ ⇒ Φ ⇒ fun_typ_q ⇒ bool" ( " _ ; _ ⊢ _ " ) where check_fundefq_simpleI: "⟦ Θ; Φ ; {||} ⊢ (AF_fun_typ x b c t s) ⟧ ⟹ Θ; Φ ⊢ ((AF_fun_typ_none (AF_fun_typ x b c t s)))" |check_funtypq_polyI: "⟦ atom bv ♯ (Θ, Φ, (AF_fun_typ x b c t s)); Θ; Φ; {|bv|} ⊢ (AF_fun_typ x b c t s) ⟧ ⟹ Θ; Φ ⊢ (AF_fun_typ_some bv (AF_fun_typ x b c t s))" equivariance check_funtypq nominal_inductive check_funtypq avoids check_funtypq_polyI: bv proof(goal_cases) case (1 bv Θ Φ x b c t s ) hence "atom bv ♯ (AF_fun_typ_some bv (AF_fun_typ x b c t s))" using fun_def.fresh fun_typ_q.fresh fun_typ.fresh by simp thus ?case using fresh_star_def 1 fresh_prodN by fastforce next case (2 bv Θ Φ ft ) then show ?case by auto qed inductive check_fundef :: "Θ ⇒ Φ ⇒ fun_def ⇒ bool" ( " _ ; _ ⊢ _ " ) where check_fundefI: "⟦ Θ; Φ ⊢ ft ⟧ ⟹ Θ; Φ ⊢ (AF_fundef f ft)" equivariance check_fundef nominal_inductive check_fundef . text ‹Temporarily remove this simproc as it produces untidy eliminations› declare[[ simproc del: alpha_lst]] inductive_cases check_funtyp_elims[elim!]: "check_funtyp Θ Φ B ft" inductive_cases check_funtypq_elims[elim!]: "check_funtypq Θ Φ (AF_fun_typ_none (AF_fun_typ x b c τ s))" "check_funtypq Θ Φ (AF_fun_typ_some bv (AF_fun_typ x b c τ s))" inductive_cases check_fundef_elims[elim!]: "check_fundef Θ Φ (AF_fundef f ftq)" declare[[ simproc add: alpha_lst]] nominal_function Δ_of :: "var_def list ⇒ Δ" where "Δ_of [] = DNil" | "Δ_of ((AV_def u t v)#vs) = (u,t) #⇩Δ (Δ_of vs)" apply auto using eqvt_def Δ_of_graph_aux_def neq_Nil_conv old.prod.exhaust apply force using eqvt_def Δ_of_graph_aux_def neq_Nil_conv old.prod.exhaust by (metis var_def.strong_exhaust) nominal_termination (eqvt) by lexicographic_order inductive check_prog :: "p ⇒ τ ⇒ bool" ( "⊢ _ ⇐ _") where "⟦ Θ; Φ; {||}; GNil ; Δ_of 𝒢 ⊢ s ⇐ τ ⟧ ⟹ ⊢ (AP_prog Θ Φ 𝒢 s) ⇐ τ" inductive_cases check_prog_elims[elim!]: "⊢ (AP_prog Θ Φ 𝒢 s) ⇐ τ" end
{ "path": "afp-2025-02-12/thys/MiniSail/Typing.thy", "repo": "afp-2025-02-12", "sha": "837a221ac3171df8179ade82528321a4d566359ba0c13cc232bd540ea103f4a0" }
section ‹Deterministic Büchi Automata Combinations› theory DBA_Combine imports DBA DGBA begin global_interpretation degeneralization: automaton_degeneralization_run dgba dgba.alphabet dgba.initial dgba.transition dgba.accepting "λ P w r p. gen infs P (p ## r)" dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" fst id defines degeneralize = degeneralization.degeneralize apply unfold_locales (*goal: ‹automaton_degeneralization_run dgba dgba.alphabet dgba.initial dgba.transition dgba.accepting (λP w r p. gen infs P (p ## r)) dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) fst id›*) by (auto simp flip: sscan_smap (*‹sscan ?f (smap ?g ?xs) ?a = sscan (?f ∘ ?g) ?xs ?a›*)) lemmas degeneralize_language[simp] = degeneralization.degeneralize_language[folded DBA.language_def] lemmas degeneralize_nodes_finite[iff] = degeneralization.degeneralize_nodes_finite[folded DBA.nodes_def] lemmas degeneralize_nodes_card = degeneralization.degeneralize_nodes_card[folded DBA.nodes_def] global_interpretation intersection: automaton_intersection_run dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" dgba.dgba dgba.alphabet dgba.initial dgba.transition dgba.accepting "λ P w r p. gen infs P (p ## r)" "λ c₁ c₂. [c₁ ∘ fst, c₂ ∘ snd]" defines intersect' = intersection.product apply unfold_locales (*goal: ‹automaton_intersection_run dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) dgba dgba.alphabet dgba.initial dgba.transition dgba.accepting (λP w r p. gen infs P (p ## r)) (λc₁ c₂. [c₁ ∘ fst, c₂ ∘ snd])›*) by auto lemmas intersect'_language[simp] = intersection.product_language[folded DGBA.language_def] lemmas intersect'_nodes_finite = intersection.product_nodes_finite[folded DGBA.nodes_def] lemmas intersect'_nodes_card = intersection.product_nodes_card[folded DGBA.nodes_def] global_interpretation union: automaton_union_run dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" "λ c₁ c₂ pq. (c₁ ∘ fst) pq ∨ (c₂ ∘ snd) pq" defines union = union.product apply unfold_locales (*goal: ‹automaton_union_run dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) (λc₁ c₂ pq. (c₁ ∘ fst) pq ∨ (c₂ ∘ snd) pq)›*) by (simp del: comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*)) lemmas union_language = union.product_language lemmas union_nodes_finite = union.product_nodes_finite lemmas union_nodes_card = union.product_nodes_card global_interpretation intersection_list: automaton_intersection_list_run dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" dgba.dgba dgba.alphabet dgba.initial dgba.transition dgba.accepting "λ P w r p. gen infs P (p ## r)" "λ cs. map (λ k pp. (cs ! k) (pp ! k)) [0 ..< length cs]" defines intersect_list' = intersection_list.product apply unfold_locales (*goal: ‹automaton_intersection_list_run dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) dgba dgba.alphabet dgba.initial dgba.transition dgba.accepting (λP w r p. gen infs P (p ## r)) (λcs. map (λk pp. (cs ! k) (pp ! k)) [0..<length cs])›*) by (auto simp: gen_def (*‹gen ?P ?cs ?w ≡ ∀c∈set ?cs. ?P c ?w›*) comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) lemmas intersect_list'_language[simp] = intersection_list.product_language[folded DGBA.language_def] lemmas intersect_list'_nodes_finite = intersection_list.product_nodes_finite[folded DGBA.nodes_def] lemmas intersect_list'_nodes_card = intersection_list.product_nodes_card[folded DGBA.nodes_def] global_interpretation union_list: automaton_union_list_run dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" dba.dba dba.alphabet dba.initial dba.transition dba.accepting "λ P w r p. infs P (p ## r)" "λ cs pp. ∃ k < length cs. (cs ! k) (pp ! k)" defines union_list = union_list.product apply unfold_locales (*goal: ‹automaton_union_list_run dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) dba dba.alphabet dba.initial dba.transition dba.accepting (λP w r p. infs P (p ## r)) (λcs pp. ∃k<length cs. (cs ! k) (pp ! k))›*) by (simp add: comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) lemmas union_list_language = union_list.product_language lemmas union_list_nodes_finite = union_list.product_nodes_finite lemmas union_list_nodes_card = union_list.product_nodes_card (* TODO: these compound definitions are annoying, can we move those into Deterministic theory *) abbreviation intersect where "intersect A B ≡ degeneralize (intersect' A B)" lemma intersect_language[simp]: "DBA.language (intersect A B) = DBA.language A ∩ DBA.language B" by simp lemma intersect_nodes_finite: assumes "finite (DBA.nodes A)" "finite (DBA.nodes B)" shows "finite (DBA.nodes (intersect A B))" using intersect'_nodes_finite (*‹⟦finite (DBA.nodes ?A); finite (DBA.nodes ?B)⟧ ⟹ finite (DGBA.nodes (intersect' ?A ?B))›*) assms (*‹finite (DBA.nodes (A::('b::type, 'a::type) dba))› ‹finite (DBA.nodes B)›*) by simp lemma intersect_nodes_card: assumes "finite (DBA.nodes A)" "finite (DBA.nodes B)" shows "card (DBA.nodes (intersect A B)) ≤ 2 * card (DBA.nodes A) * card (DBA.nodes B)" proof (-) (*goal: ‹card (DBA.nodes (intersect A B)) ≤ 2 * card (DBA.nodes A) * card (DBA.nodes B)›*) have "card (DBA.nodes (intersect A B)) ≤ max 1 (length (dgba.accepting (intersect' A B))) * card (DGBA.nodes (intersect' A B))" using degeneralize_nodes_card (*‹card (DBA.nodes (degeneralize ?A)) ≤ max 1 (length (dgba.accepting ?A)) * card (DGBA.nodes ?A)›*) by this also (*calculation: ‹card (DBA.nodes (intersect A B)) ≤ max 1 (length (dgba.accepting (intersect' A B))) * card (DGBA.nodes (intersect' A B))›*) have "length (dgba.accepting (intersect' A B)) = 2" by simp also (*calculation: ‹card (DBA.nodes (intersect A B)) ≤ max 1 2 * card (DGBA.nodes (intersect' A B))›*) have "card (DGBA.nodes (intersect' A B)) ≤ card (DBA.nodes A) * card (DBA.nodes B)" using intersect'_nodes_card (*‹⟦finite (DBA.nodes ?A); finite (DBA.nodes ?B)⟧ ⟹ card (DGBA.nodes (intersect' ?A ?B)) ≤ card (DBA.nodes ?A) * card (DBA.nodes ?B)›*) assms (*‹finite (DBA.nodes A)› ‹finite (DBA.nodes B)›*) by this finally (*calculation: ‹(⋀x y. x ≤ y ⟹ max 1 2 * x ≤ max 1 2 * y) ⟹ card (DBA.nodes (intersect A B)) ≤ max 1 2 * (card (DBA.nodes A) * card (DBA.nodes B))›*) show "?thesis" (*goal: ‹card (DBA.nodes (intersect A B)) ≤ 2 * card (DBA.nodes A) * card (DBA.nodes B)›*) by simp qed abbreviation intersect_list where "intersect_list AA ≡ degeneralize (intersect_list' AA)" lemma intersect_list_language[simp]: "DBA.language (intersect_list AA) = ⋂ (DBA.language ` set AA)" by simp lemma intersect_list_nodes_finite: assumes "list_all (finite ∘ DBA.nodes) AA" shows "finite (DBA.nodes (intersect_list AA))" using intersect_list'_nodes_finite (*‹list_all (finite ∘ DBA.nodes) ?AA ⟹ finite (DGBA.nodes (intersect_list' ?AA))›*) assms (*‹list_all (finite ∘ DBA.nodes) AA›*) by simp lemma intersect_list_nodes_card: assumes "list_all (finite ∘ DBA.nodes) AA" shows "card (DBA.nodes (intersect_list AA)) ≤ max 1 (length AA) * prod_list (map (card ∘ DBA.nodes) AA)" proof (-) (*goal: ‹card (DBA.nodes (intersect_list AA)) ≤ max 1 (length AA) * prod_list (map (card ∘ DBA.nodes) AA)›*) have "card (DBA.nodes (intersect_list AA)) ≤ max 1 (length (dgba.accepting (intersect_list' AA))) * card (DGBA.nodes (intersect_list' AA))" using degeneralize_nodes_card (*‹card (DBA.nodes (degeneralize ?A)) ≤ max 1 (length (dgba.accepting ?A)) * card (DGBA.nodes ?A)›*) by this also (*calculation: ‹card (DBA.nodes (intersect_list AA)) ≤ max 1 (length (dgba.accepting (intersect_list' AA))) * card (DGBA.nodes (intersect_list' AA))›*) have "length (dgba.accepting (intersect_list' AA)) = length AA" by simp also (*calculation: ‹card (DBA.nodes (intersect_list (AA::('a::type, 'b::type) dba list))) ≤ max (1::nat) (length AA) * card (DGBA.nodes (intersect_list' AA))›*) have "card (DGBA.nodes (intersect_list' AA)) ≤ prod_list (map (card ∘ DBA.nodes) AA)" using intersect_list'_nodes_card (*‹list_all (finite ∘ DBA.nodes) (?AA::(?'a::type, ?'b::type) dba list) ⟹ card (DGBA.nodes (intersect_list' ?AA)) ≤ prod_list (map (card ∘ DBA.nodes) ?AA)›*) assms (*‹list_all (finite ∘ DBA.nodes) AA›*) by this finally (*calculation: ‹(⋀x y. x ≤ y ⟹ max 1 (length AA) * x ≤ max 1 (length AA) * y) ⟹ card (DBA.nodes (intersect_list AA)) ≤ max 1 (length AA) * prod_list (map (card ∘ DBA.nodes) AA)›*) show "?thesis" (*goal: ‹card (DBA.nodes (intersect_list AA)) ≤ max 1 (length AA) * prod_list (map (card ∘ DBA.nodes) AA)›*) by simp qed end
{ "path": "afp-2025-02-12/thys/Transition_Systems_and_Automata/Automata/DBA/DBA_Combine.thy", "repo": "afp-2025-02-12", "sha": "0449d2297bf54018e54c964a6daaf84175b45af063505a8ae7e94f1a3478f5a7" }
(* Author: Tobias Nipkow *) subsubsection "Hoare Logic for Total Correctness With Logical Variables" theory Hoare_Total_EX2 imports Hoare begin text‹This is the standard set of rules that you find in many publications. In the while-rule, a logical variable is needed to remember the pre-value of the variant (an expression that decreases by one with each iteration). In this theory, logical variables are modeled explicitly. A simpler (but not quite as flexible) approach is found in theory ‹Hoare_Total_EX›: pre and post-condition are connected via a universally quantified HOL variable.› type_synonym lvname = string type_synonym assn2 = "(lvname ⇒ nat) ⇒ state ⇒ bool" definition hoare_tvalid :: "assn2 ⇒ com ⇒ assn2 ⇒ bool" ("⊨⇩t {(1_)}/ (_)/ {(1_)}" 50) where "⊨⇩t {P}c{Q} ⟷ (∀l s. P l s ⟶ (∃t. (c,s) ⇒ t ∧ Q l t))" inductive hoaret :: "assn2 ⇒ com ⇒ assn2 ⇒ bool" ("⊢⇩t ({(1_)}/ (_)/ {(1_)})" 50) where Skip: "⊢⇩t {P} SKIP {P}" | Assign: "⊢⇩t {λl s. P l (s[a/x])} x::=a {P}" | Seq: "⟦ ⊢⇩t {P₁} c₁ {P₂}; ⊢⇩t {P₂} c₂ {P₃} ⟧ ⟹ ⊢⇩t {P₁} c₁;;c₂ {P₃}" | If: "⟦ ⊢⇩t {λl s. P l s ∧ bval b s} c₁ {Q}; ⊢⇩t {λl s. P l s ∧ ¬ bval b s} c₂ {Q} ⟧ ⟹ ⊢⇩t {P} IF b THEN c₁ ELSE c₂ {Q}" | While: "⟦ ⊢⇩t {λl. P (l(x := Suc(l(x))))} c {P}; ∀l s. l x > 0 ∧ P l s ⟶ bval b s; ∀l s. l x = 0 ∧ P l s ⟶ ¬ bval b s ⟧ ⟹ ⊢⇩t {λl s. ∃n. P (l(x:=n)) s} WHILE b DO c {λl s. P (l(x := 0)) s}" | conseq: "⟦ ∀l s. P' l s ⟶ P l s; ⊢⇩t {P}c{Q}; ∀l s. Q l s ⟶ Q' l s ⟧ ⟹ ⊢⇩t {P'}c{Q'}" text‹Building in the consequence rule:› lemma strengthen_pre: "⟦ ∀l s. P' l s ⟶ P l s; ⊢⇩t {P} c {Q} ⟧ ⟹ ⊢⇩t {P'} c {Q}" by (metis conseq (*‹⟦∀l s. ?P' l s ⟶ ?P l s; ⊢⇩t {?P} ?c {?Q}; ∀l s. ?Q l s ⟶ ?Q' l s⟧ ⟹ ⊢⇩t {?P'} ?c {?Q'}›*)) lemma weaken_post: "⟦ ⊢⇩t {P} c {Q}; ∀l s. Q l s ⟶ Q' l s ⟧ ⟹ ⊢⇩t {P} c {Q'}" by (metis conseq (*‹⟦∀(l::char list ⇒ nat) s::char list ⇒ int. (?P'::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s; ⊢⇩t {?P} ?c::com {?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}; ∀(l::char list ⇒ nat) s::char list ⇒ int. ?Q l s ⟶ (?Q'::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s⟧ ⟹ ⊢⇩t {?P'} ?c {?Q'}›*)) lemma Assign': "∀l s. P l s ⟶ Q l (s[a/x]) ⟹ ⊢⇩t {P} x ::= a {Q}" by (simp add: strengthen_pre[OF _ Assign] (*‹∀l s. ?P' l s ⟶ ?Q l (s[?a1/?x1]) ⟹ ⊢⇩t {?P'} ?x1 ::= ?a1 {?Q}›*)) text‹The soundness theorem:› theorem hoaret_sound: "⊢⇩t {P}c{Q} ⟹ ⊨⇩t {P}c{Q}" proof (unfold hoare_tvalid_def (*‹(⊨⇩t {?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool} ?c::com {?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}) = (∀(l::char list ⇒ nat) s::char list ⇒ int. ?P l s ⟶ (∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t))›*), induction rule: hoaret.induct (*‹⟦⊢⇩t {?x1.0} ?x2.0 {?x3.0}; ⋀P. ?P P SKIP P; ⋀P a x. ?P (λl s. P l (s[a/x])) (x ::= a) P; ⋀P₁ c₁ P₂ c₂ P₃. ⟦⊢⇩t {P₁} c₁ {P₂}; ?P P₁ c₁ P₂; ⊢⇩t {P₂} c₂ {P₃}; ?P P₂ c₂ P₃⟧ ⟹ ?P P₁ (c₁;; c₂) P₃; ⋀P b c₁ Q c₂. ⟦⊢⇩t {λl s. P l s ∧ bval b s} c₁ {Q}; ?P (λl s. P l s ∧ bval b s) c₁ Q; ⊢⇩t {λl s. P l s ∧ ¬ bval b s} c₂ {Q}; ?P (λl s. P l s ∧ ¬ bval b s) c₂ Q⟧ ⟹ ?P P (IF b THEN c₁ ELSE c₂) Q; ⋀P x c b. ⟦⊢⇩t {λl. P (l(x := Suc (l x)))} c {P}; ?P (λl. P (l(x := Suc (l x)))) c P; ∀l s. 0 < l x ∧ P l s ⟶ bval b s; ∀l s. l x = 0 ∧ P l s ⟶ ¬ bval b s⟧ ⟹ ?P (λl s. ∃n. P (l(x := n)) s) (WHILE b DO c) (λl. P (l(x := 0))); ⋀P' P c Q Q'. ⟦∀l s. P' l s ⟶ P l s; ⊢⇩t {P} c {Q}; ?P P c Q; ∀l s. Q l s ⟶ Q' l s⟧ ⟹ ?P P' c Q'⟧ ⟹ ?P ?x1.0 ?x2.0 ?x3.0›*)) (*goals: 1. ‹⋀P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool. ∀(l::char list ⇒ nat) s::char list ⇒ int. P l s ⟶ (∃t::char list ⇒ int. (SKIP, s) ⇒ t ∧ P l t)› 2. ‹⋀(P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (a::aexp) x::char list. ∀(l::char list ⇒ nat) s::char list ⇒ int. P l (s[a/x]) ⟶ (∃t::char list ⇒ int. (x ::= a, s) ⇒ t ∧ P l t)› 3. ‹⋀(P₁::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (c₁::com) (P₂::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (c₂::com) P₃::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool. ⟦⊢⇩t {P₁} c₁ {P₂}; ∀(l::char list ⇒ nat) s::char list ⇒ int. P₁ l s ⟶ (∃t::char list ⇒ int. (c₁, s) ⇒ t ∧ P₂ l t); ⊢⇩t {P₂} c₂ {P₃}; ∀(l::char list ⇒ nat) s::char list ⇒ int. P₂ l s ⟶ (∃t::char list ⇒ int. (c₂, s) ⇒ t ∧ P₃ l t)⟧ ⟹ ∀(l::char list ⇒ nat) s::char list ⇒ int. P₁ l s ⟶ (∃t::char list ⇒ int. (c₁;; c₂, s) ⇒ t ∧ P₃ l t)› 4. ‹⋀(P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (b::bexp) (c₁::com) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) c₂::com. ⟦⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. P l s ∧ bval b s} c₁ {Q}; ∀(l::char list ⇒ nat) s::char list ⇒ int. P l s ∧ bval b s ⟶ (∃t::char list ⇒ int. (c₁, s) ⇒ t ∧ Q l t); ⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. P l s ∧ ¬ bval b s} c₂ {Q}; ∀(l::char list ⇒ nat) s::char list ⇒ int. P l s ∧ ¬ bval b s ⟶ (∃t::char list ⇒ int. (c₂, s) ⇒ t ∧ Q l t)⟧ ⟹ ∀(l::char list ⇒ nat) s::char list ⇒ int. P l s ⟶ (∃t::char list ⇒ int. (IF b THEN c₁ ELSE c₂, s) ⇒ t ∧ Q l t)› 5. ‹⋀(P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (x::char list) (c::com) b::bexp. ⟦⊢⇩t {λl::char list ⇒ nat. P (l(x := Suc (l x)))} c {P}; ∀(l::char list ⇒ nat) s::char list ⇒ int. P (l(x := Suc (l x))) s ⟶ (∃t::char list ⇒ int. (c, s) ⇒ t ∧ P l t); ∀(l::char list ⇒ nat) s::char list ⇒ int. (0::nat) < l x ∧ P l s ⟶ bval b s; ∀(l::char list ⇒ nat) s::char list ⇒ int. l x = (0::nat) ∧ P l s ⟶ ¬ bval b s⟧ ⟹ ∀(l::char list ⇒ nat) s::char list ⇒ int. (∃n::nat. P (l(x := n)) s) ⟶ (∃t::char list ⇒ int. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0::nat)) t)› 6. ‹⋀(P'::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (c::com) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) Q'::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool. ⟦∀(l::char list ⇒ nat) s::char list ⇒ int. P' l s ⟶ P l s; ⊢⇩t {P} c {Q}; ∀(l::char list ⇒ nat) s::char list ⇒ int. P l s ⟶ (∃t::char list ⇒ int. (c, s) ⇒ t ∧ Q l t); ∀(l::char list ⇒ nat) s::char list ⇒ int. Q l s ⟶ Q' l s⟧ ⟹ ∀(l::char list ⇒ nat) s::char list ⇒ int. P' l s ⟶ (∃t::char list ⇒ int. (c, s) ⇒ t ∧ Q' l t)›*) case (While P x c b) (*‹⊢⇩t {λl. P (l(x := Suc (l x)))} c {P}› ‹∀l s. 0 < l x ∧ P l s ⟶ bval b s› ‹∀(l::char list ⇒ nat) s::char list ⇒ int. l (x::char list) = (0::nat) ∧ (P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ ¬ bval (b::bexp) s› ‹∀l s. P (l(x := Suc (l x))) s ⟶ (∃t. (c, s) ⇒ t ∧ P l t)›*) have "⟦ l x = n; P l s ⟧ ⟹ ∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t" for n and l and s proof (induction "n" arbitrary: l s) (*goals: 1. ‹⋀l s. ⟦l x = 0; P l s⟧ ⟹ ∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t› 2. ‹⋀n l s. ⟦⋀l s. ⟦l x = n; P l s⟧ ⟹ ∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t; l x = Suc n; P l s⟧ ⟹ ∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t›*) case 0 (*‹l x = 0› ‹P l s›*) thus "?case" (*goal: ‹∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t›*) using While.hyps(3) (*‹∀(l::char list ⇒ nat) s::char list ⇒ int. l (x::char list) = (0::nat) ∧ (P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ ¬ bval (b::bexp) s›*) WhileFalse (*‹¬ bval ?b ?s ⟹ (WHILE ?b DO ?c, ?s) ⇒ ?s›*) by (metis fun_upd_triv (*‹?f(?x := ?f ?x) = ?f›*)) next (*goal: ‹⋀n l s. ⟦⋀l s. ⟦l x = n; P l s⟧ ⟹ ∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t; l x = Suc n; P l s⟧ ⟹ ∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t›*) case Suc (*‹⟦?l x = n_; P ?l ?s⟧ ⟹ ∃t. (WHILE b DO c, ?s) ⇒ t ∧ P (?l(x := 0)) t› ‹(l::char list ⇒ nat) (x::char list) = Suc (n_::nat)› ‹P l s›*) thus "?case" (*goal: ‹∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t›*) using While.IH (*‹∀l s. P (l(x := Suc (l x))) s ⟶ (∃t. (c, s) ⇒ t ∧ P l t)›*) While.hyps(2) (*‹∀l s. 0 < l x ∧ P l s ⟶ bval b s›*) WhileTrue (*‹⟦bval (?b::bexp) (?s₁::char list ⇒ int); (?c::com, ?s₁) ⇒ (?s₂::char list ⇒ int); (WHILE ?b DO ?c, ?s₂) ⇒ (?s₃::char list ⇒ int)⟧ ⟹ (WHILE ?b DO ?c, ?s₁) ⇒ ?s₃›*) by (metis fun_upd_same (*‹(?f(?x := ?y)) ?x = ?y›*) fun_upd_triv (*‹?f(?x := ?f ?x) = ?f›*) fun_upd_upd (*‹?f(?x := ?y, ?x := ?z) = ?f(?x := ?z)›*) zero_less_Suc (*‹0 < Suc ?n›*)) qed thus "?case" (*goal: ‹∀l s. (∃n. P (l(x := n)) s) ⟶ (∃t. (WHILE b DO c, s) ⇒ t ∧ P (l(x := 0)) t)›*) by fastforce next (*goals: 1. ‹⋀P. ∀l s. P l s ⟶ (∃t. (SKIP, s) ⇒ t ∧ P l t)› 2. ‹⋀P a x. ∀l s. P l (s[a/x]) ⟶ (∃t. (x ::= a, s) ⇒ t ∧ P l t)› 3. ‹⋀P₁ c₁ P₂ c₂ P₃. ⟦⊢⇩t {P₁} c₁ {P₂}; ∀l s. P₁ l s ⟶ (∃t. (c₁, s) ⇒ t ∧ P₂ l t); ⊢⇩t {P₂} c₂ {P₃}; ∀l s. P₂ l s ⟶ (∃t. (c₂, s) ⇒ t ∧ P₃ l t)⟧ ⟹ ∀l s. P₁ l s ⟶ (∃t. (c₁;; c₂, s) ⇒ t ∧ P₃ l t)› 4. ‹⋀P b c₁ Q c₂. ⟦⊢⇩t {λl s. P l s ∧ bval b s} c₁ {Q}; ∀l s. P l s ∧ bval b s ⟶ (∃t. (c₁, s) ⇒ t ∧ Q l t); ⊢⇩t {λl s. P l s ∧ ¬ bval b s} c₂ {Q}; ∀l s. P l s ∧ ¬ bval b s ⟶ (∃t. (c₂, s) ⇒ t ∧ Q l t)⟧ ⟹ ∀l s. P l s ⟶ (∃t. (IF b THEN c₁ ELSE c₂, s) ⇒ t ∧ Q l t)› 5. ‹⋀P' P c Q Q'. ⟦∀l s. P' l s ⟶ P l s; ⊢⇩t {P} c {Q}; ∀l s. P l s ⟶ (∃t. (c, s) ⇒ t ∧ Q l t); ∀l s. Q l s ⟶ Q' l s⟧ ⟹ ∀l s. P' l s ⟶ (∃t. (c, s) ⇒ t ∧ Q' l t)›*) case If (*‹⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. (P_::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ∧ bval (b_::bexp) s} c₁_::com {Q_::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}› ‹⊢⇩t {λl s. P_ l s ∧ ¬ bval b_ s} c₂_ {Q_}› ‹∀l s. P_ l s ∧ bval b_ s ⟶ (∃t. (c₁_, s) ⇒ t ∧ Q_ l t)› ‹∀l s. P_ l s ∧ ¬ bval b_ s ⟶ (∃t. (c₂_, s) ⇒ t ∧ Q_ l t)›*) thus "?case" (*goal: ‹∀l s. P_ l s ⟶ (∃t. (IF b_ THEN c₁_ ELSE c₂_, s) ⇒ t ∧ Q_ l t)›*) apply auto (*goal: ‹∀l s. P_ l s ⟶ (∃t. (IF b_ THEN c₁_ ELSE c₂_, s) ⇒ t ∧ Q_ l t)›*) by blast qed ((fastforce)+) (*solves the remaining goals: 1. ‹⋀P. ∀l s. P l s ⟶ (∃t. (SKIP, s) ⇒ t ∧ P l t)› 2. ‹⋀P a x. ∀l s. P l (s[a/x]) ⟶ (∃t. (x ::= a, s) ⇒ t ∧ P l t)› 3. ‹⋀P₁ c₁ P₂ c₂ P₃. ⟦⊢⇩t {P₁} c₁ {P₂}; ∀l s. P₁ l s ⟶ (∃t. (c₁, s) ⇒ t ∧ P₂ l t); ⊢⇩t {P₂} c₂ {P₃}; ∀l s. P₂ l s ⟶ (∃t. (c₂, s) ⇒ t ∧ P₃ l t)⟧ ⟹ ∀l s. P₁ l s ⟶ (∃t. (c₁;; c₂, s) ⇒ t ∧ P₃ l t)› 4. ‹⋀P' P c Q Q'. ⟦∀l s. P' l s ⟶ P l s; ⊢⇩t {P} c {Q}; ∀l s. P l s ⟶ (∃t. (c, s) ⇒ t ∧ Q l t); ∀l s. Q l s ⟶ Q' l s⟧ ⟹ ∀l s. P' l s ⟶ (∃t. (c, s) ⇒ t ∧ Q' l t)›*) definition wpt :: "com ⇒ assn2 ⇒ assn2" ("wp⇩t") where "wp⇩t c Q = (λl s. ∃t. (c,s) ⇒ t ∧ Q l t)" lemma [simp]: "wp⇩t SKIP Q = Q" by (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) simp: wpt_def (*‹wp⇩t (?c::com) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = (λ(l::char list ⇒ nat) s::char list ⇒ int. ∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t)›*)) lemma [simp]: "wp⇩t (x ::= e) Q = (λl s. Q l (s(x := aval e s)))" by (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) simp: wpt_def (*‹wp⇩t (?c::com) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = (λ(l::char list ⇒ nat) s::char list ⇒ int. ∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t)›*)) lemma wpt_Seq[simp]: "wp⇩t (c₁;;c₂) Q = wp⇩t c₁ (wp⇩t c₂ Q)" by (auto simp: wpt_def (*‹wp⇩t (?c::com) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = (λ(l::char list ⇒ nat) s::char list ⇒ int. ∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t)›*) fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*)) lemma [simp]: "wp⇩t (IF b THEN c₁ ELSE c₂) Q = (λl s. wp⇩t (if bval b s then c₁ else c₂) Q l s)" by (auto simp: wpt_def (*‹wp⇩t (?c::com) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = (λ(l::char list ⇒ nat) s::char list ⇒ int. ∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t)›*) fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*)) text‹Function ‹wpw› computes the weakest precondition of a While-loop that is unfolded a fixed number of times.› fun wpw :: "bexp ⇒ com ⇒ nat ⇒ assn2 ⇒ assn2" where "wpw b c 0 Q l s = (¬ bval b s ∧ Q l s)" | "wpw b c (Suc n) Q l s = (bval b s ∧ (∃s'. (c,s) ⇒ s' ∧ wpw b c n Q l s'))" lemma WHILE_Its: "(WHILE b DO c,s) ⇒ t ⟹ Q l t ⟹ ∃n. wpw b c n Q l s" proof (induction "WHILE b DO c" s t arbitrary: l rule: big_step_induct) (*goals: 1. ‹⋀(s::char list ⇒ int) l::char list ⇒ nat. ⟦¬ bval (b::bexp) s; (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s⟧ ⟹ ∃n::nat. wpw b (c::com) n Q l s› 2. ‹⋀(s₁::char list ⇒ int) (s₂::char list ⇒ int) (s₃::char list ⇒ int) l::char list ⇒ nat. ⟦bval (b::bexp) s₁; (c::com, s₁) ⇒ s₂; ⋀l::char list ⇒ nat. ⟦c = WHILE b DO c; (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s₂⟧ ⟹ ∃n::nat. wpw b c n Q l s₁; (WHILE b DO c, s₂) ⇒ s₃; ⋀l::char list ⇒ nat. Q l s₃ ⟹ ∃n::nat. wpw b c n Q l s₂; Q l s₃⟧ ⟹ ∃n::nat. wpw b c n Q l s₁›*) case WhileFalse (*‹¬ bval b s_› ‹Q l s_›*) thus "?case" (*goal: ‹∃n::nat. wpw (b::bexp) (c::com) n (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (l::char list ⇒ nat) (s_::char list ⇒ int)›*) using wpw.simps(1) (*‹wpw ?b ?c 0 ?Q ?l ?s = (¬ bval ?b ?s ∧ ?Q ?l ?s)›*) by blast next (*goal: ‹⋀s₁ s₂ s₃ l. ⟦bval b s₁; (c, s₁) ⇒ s₂; ⋀l. ⟦c = WHILE b DO c; Q l s₂⟧ ⟹ ∃n. wpw b c n Q l s₁; (WHILE b DO c, s₂) ⇒ s₃; ⋀l. Q l s₃ ⟹ ∃n. wpw b c n Q l s₂; Q l s₃⟧ ⟹ ∃n. wpw b c n Q l s₁›*) case WhileTrue (*‹bval b s₁_› ‹(c, s₁_) ⇒ s₂_› ‹⟦c = WHILE b DO c; Q ?l s₂_⟧ ⟹ ∃n. wpw b c n Q ?l s₁_› ‹(WHILE b DO c, s₂_) ⇒ s₃_› ‹Q ?l s₃_ ⟹ ∃n. wpw b c n Q ?l s₂_› ‹Q l s₃_›*) show "?case" (*goal: ‹∃n. wpw b c n Q l s₁_›*) using wpw.simps(2) (*‹wpw (?b::bexp) (?c::com) (Suc (?n::nat)) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (?l::char list ⇒ nat) (?s::char list ⇒ int) = (bval ?b ?s ∧ (∃s'::char list ⇒ int. (?c, ?s) ⇒ s' ∧ wpw ?b ?c ?n ?Q ?l s'))›*) WhileTrue(1,2) (*‹bval b s₁_› ‹(c::com, s₁_::char list ⇒ int) ⇒ (s₂_::char list ⇒ int)›*) WhileTrue(5)[OF WhileTrue ( 6 )] (*‹∃n. wpw b c n Q l s₂_›*) by blast qed definition support :: "assn2 ⇒ string set" where "support P = {x. ∃l1 l2 s. (∀y. y ≠ x ⟶ l1 y = l2 y) ∧ P l1 s ≠ P l2 s}" lemma support_wpt: "support (wp⇩t c Q) ⊆ support Q" apply (simp add: support_def (*‹support ?P = {x. ∃l1 l2 s. (∀y. y ≠ x ⟶ l1 y = l2 y) ∧ ?P l1 s ≠ ?P l2 s}›*) wpt_def (*‹wp⇩t ?c ?Q = (λl s. ∃t. (?c, s) ⇒ t ∧ ?Q l t)›*)) (*goal: ‹support (wp⇩t c Q) ⊆ support Q›*) by blast lemma support_wpw0: "support (wpw b c n Q) ⊆ support Q" proof (induction n) (*goals: 1. ‹support (wpw (b::bexp) (c::com) (0::nat) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool)) ⊆ support Q› 2. ‹⋀n::nat. support (wpw (b::bexp) (c::com) n (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool)) ⊆ support Q ⟹ support (wpw b c (Suc n) Q) ⊆ support Q›*) case 0 (*no hyothesis introduced yet*) show "?case" (*goal: ‹support (wpw b c 0 Q) ⊆ support Q›*) apply (simp add: support_def (*‹support (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = {x::char list. ∃(l1::char list ⇒ nat) (l2::char list ⇒ nat) s::char list ⇒ int. (∀y::char list. y ≠ x ⟶ l1 y = l2 y) ∧ ?P l1 s ≠ ?P l2 s}›*)) (*goal: ‹support (wpw (b::bexp) (c::com) (0::nat) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool)) ⊆ support Q›*) by blast next (*goal: ‹⋀n. support (wpw b c n Q) ⊆ support Q ⟹ support (wpw b c (Suc n) Q) ⊆ support Q›*) case Suc (*‹support (wpw b c n_ Q) ⊆ support Q›*) have 1: "support (λl s. A s ∧ B l s) ⊆ support B" for A and B by (auto simp: support_def (*‹support (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = {x::char list. ∃(l1::char list ⇒ nat) (l2::char list ⇒ nat) s::char list ⇒ int. (∀y::char list. y ≠ x ⟶ l1 y = l2 y) ∧ ?P l1 s ≠ ?P l2 s}›*)) have 2: "support (λl s. ∃s'. A s s' ∧ B l s') ⊆ support B" for A and B apply (auto simp: support_def (*‹support ?P = {x. ∃l1 l2 s. (∀y. y ≠ x ⟶ l1 y = l2 y) ∧ ?P l1 s ≠ ?P l2 s}›*)) (*goals: 1. ‹⋀x l1 l2 s s'. ⟦∀y. y ≠ x ⟶ l1 y = l2 y; ∀s'. A s s' ⟶ ¬ B l2 s'; A s s'; B l1 s'⟧ ⟹ ∃l1 l2. (∀y. y ≠ x ⟶ l1 y = l2 y) ∧ (∃s. B l1 s = (¬ B l2 s))› 2. ‹⋀x l1 l2 s s'. ⟦∀y. y ≠ x ⟶ l1 y = l2 y; ∀s'. A s s' ⟶ ¬ B l1 s'; ∀l1 l2. (∃y. y ≠ x ∧ l1 y ≠ l2 y) ∨ (∀s. B l1 s = B l2 s); A s s'; B l2 s'⟧ ⟹ False› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . from Suc (*‹support (wpw b c n_ Q) ⊆ support Q›*) "1" (*‹support (λl s. ?A s ∧ ?B l s) ⊆ support ?B›*) "2" (*‹support (λl s. ∃s'. ?A s s' ∧ ?B l s') ⊆ support ?B›*) show "?case" (*goal: ‹support (wpw (b::bexp) (c::com) (Suc (n_::nat)) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool)) ⊆ support Q›*) apply simp (*goal: ‹support (wpw b c (Suc n_) Q) ⊆ support Q›*) by (meson order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) qed lemma support_wpw_Un: "support (%l. wpw b c (l x) Q l) ⊆ insert x (UN n. support(wpw b c n Q))" using support_wpw0[of b c _ Q] (*‹support (wpw b c ?n Q) ⊆ support Q›*) apply (auto simp add: support_def (*‹support ?P = {x. ∃l1 l2 s. (∀y. y ≠ x ⟶ l1 y = l2 y) ∧ ?P l1 s ≠ ?P l2 s}›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) (*goals: 1. ‹⋀t l1 l2 s. ⟦⋀n. ∀t. (∃l1 l2. (∀y. y ≠ t ⟶ l1 y = l2 y) ∧ (∃s. wpw b c n Q l1 s = (¬ wpw b c n Q l2 s))) ⟶ (∃l1 l2. (∀y. y ≠ t ⟶ l1 y = l2 y) ∧ (∃s. Q l1 s = (¬ Q l2 s))); ∀y. y ≠ t ⟶ l1 y = l2 y; ∀x l1 l2. (∃y. y ≠ t ∧ l1 y ≠ l2 y) ∨ (∀s. wpw b c x Q l1 s = wpw b c x Q l2 s); wpw b c (l1 x) Q l1 s; ¬ wpw b c (l2 x) Q l2 s⟧ ⟹ t = x› 2. ‹⋀t l1 l2 s. ⟦⋀n. ∀t. (∃l1 l2. (∀y. y ≠ t ⟶ l1 y = l2 y) ∧ (∃s. wpw b c n Q l1 s = (¬ wpw b c n Q l2 s))) ⟶ (∃l1 l2. (∀y. y ≠ t ⟶ l1 y = l2 y) ∧ (∃s. Q l1 s = (¬ Q l2 s))); ∀y. y ≠ t ⟶ l1 y = l2 y; ∀x l1 l2. (∃y. y ≠ t ∧ l1 y ≠ l2 y) ∨ (∀s. wpw b c x Q l1 s = wpw b c x Q l2 s); ¬ wpw b c (l2 x) Q l1 s; t ≠ x; wpw b c (l2 x) Q l2 s⟧ ⟹ False› discuss goal 1*) apply metis (*discuss goal 2*) apply metis (*proven 2 subgoals*) . lemma support_wpw: "support (%l. wpw b c (l x) Q l) ⊆ insert x (support Q)" using support_wpw0[of b c _ Q] (*‹support (wpw b c ?n Q) ⊆ support Q›*) support_wpw_Un[of b c _ Q] (*‹support (λl::char list ⇒ nat. wpw (b::bexp) (c::com) (l (?x::char list)) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l) ⊆ insert ?x (⋃n::nat. support (wpw b c n Q))›*) by blast lemma assn2_lupd: "x ∉ support Q ⟹ Q (l(x:=n)) = Q l" apply (simp add: support_def (*‹support ?P = {x. ∃l1 l2 s. (∀y. y ≠ x ⟶ l1 y = l2 y) ∧ ?P l1 s ≠ ?P l2 s}›*) fun_upd_other (*‹?z ≠ ?x ⟹ (?f(?x := ?y)) ?z = ?f ?z›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹x ∉ support Q ⟹ Q (l(x := n)) = Q l›*) by (metis (no_types, lifting) fun_upd_def (*‹(?f::?'a ⇒ ?'b)(?a::?'a := ?b::?'b) = (λx::?'a. if x = ?a then ?b else ?f x)›*)) abbreviation "new Q ≡ SOME x. x ∉ support Q" lemma wpw_lupd: "x ∉ support Q ⟹ wpw b c n Q (l(x := u)) = wpw b c n Q l" apply (induction n) (*goals: 1. ‹x ∉ support Q ⟹ wpw b c 0 Q (l(x := u)) = wpw b c 0 Q l› 2. ‹⋀n. ⟦x ∉ support Q ⟹ wpw b c n Q (l(x := u)) = wpw b c n Q l; x ∉ support Q⟧ ⟹ wpw b c (Suc n) Q (l(x := u)) = wpw b c (Suc n) Q l› discuss goal 1*) apply ((auto simp: assn2_lupd (*‹?x ∉ support ?Q ⟹ ?Q (?l(?x := ?n)) = ?Q ?l›*) fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*))[1]) (*discuss goal 2*) apply ((auto simp: assn2_lupd (*‹(?x::char list) ∉ support (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) ⟹ ?Q ((?l::char list ⇒ nat)(?x := ?n::nat)) = ?Q ?l›*) fun_eq_iff (*‹((?f::?'a ⇒ ?'b) = (?g::?'a ⇒ ?'b)) = (∀x::?'a. ?f x = ?g x)›*))[1]) (*proven 2 subgoals*) . lemma wpt_is_pre: "finite(support Q) ⟹ ⊢⇩t {wp⇩t c Q} c {Q}" proof (induction c arbitrary: Q) (*goals: 1. ‹⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t SKIP Q} SKIP {Q}› 2. ‹⋀x1 x2 Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t (x1 ::= x2) Q} x1 ::= x2 {Q}› 3. ‹⋀c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (c1;; c2) Q} c1;; c2 {Q}› 4. ‹⋀x1 c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 5. ‹⋀x1 c Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c Q} c {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case SKIP (*‹finite (support Q)›*) show "?case" (*goal: ‹⊢⇩t {wp⇩t SKIP Q} SKIP {Q}›*) by (auto intro:hoaret.Skip (*‹⊢⇩t {?P} SKIP {?P}›*)) next (*goals: 1. ‹⋀x1 x2 Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t (x1 ::= x2) Q} x1 ::= x2 {Q}› 2. ‹⋀c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (c1;; c2) Q} c1;; c2 {Q}› 3. ‹⋀x1 c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 4. ‹⋀x1 c Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c Q} c {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case Assign (*‹finite (support Q)›*) show "?case" (*goal: ‹⊢⇩t {wp⇩t (x1_ ::= x2_) Q} x1_ ::= x2_ {Q}›*) by (auto intro:hoaret.Assign (*‹⊢⇩t {λl s. ?P l (s[?a/?x])} ?x ::= ?a {?P}›*)) next (*goals: 1. ‹⋀c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (c1;; c2) Q} c1;; c2 {Q}› 2. ‹⋀x1 c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 3. ‹⋀x1 c Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c Q} c {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case (Seq c1 c2) (*‹finite (support (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool)) ⟹ ⊢⇩t {wp⇩t (c1::com) ?Q} c1 {?Q}› ‹finite (support ?Q) ⟹ ⊢⇩t {wp⇩t c2 ?Q} c2 {?Q}› ‹finite (support (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool))›*) show "?case" (*goal: ‹⊢⇩t {wp⇩t (c1;; c2) Q} c1;; c2 {Q}›*) by (auto intro:hoaret.Seq (*‹⟦⊢⇩t {?P₁} ?c₁ {?P₂}; ⊢⇩t {?P₂} ?c₂ {?P₃}⟧ ⟹ ⊢⇩t {?P₁} ?c₁;; ?c₂ {?P₃}›*) Seq (*‹finite (support ?Q) ⟹ ⊢⇩t {wp⇩t c1 ?Q} c1 {?Q}› ‹finite (support ?Q) ⟹ ⊢⇩t {wp⇩t c2 ?Q} c2 {?Q}› ‹finite (support Q)›*) finite_subset[OF support_wpt] (*‹finite (support ?Q1) ⟹ finite (support (wp⇩t ?c1 ?Q1))›*)) next (*goals: 1. ‹⋀x1 c1 c2 Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c1 Q} c1 {Q}; ⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c2 Q} c2 {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (IF x1 THEN c1 ELSE c2) Q} IF x1 THEN c1 ELSE c2 {Q}› 2. ‹⋀x1 c Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c Q} c {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case If (*‹finite (support ?Q) ⟹ ⊢⇩t {wp⇩t c1_ ?Q} c1_ {?Q}› ‹finite (support ?Q) ⟹ ⊢⇩t {wp⇩t c2_ ?Q} c2_ {?Q}› ‹finite (support Q)›*) thus "?case" (*goal: ‹⊢⇩t {wp⇩t (IF x1_ THEN c1_ ELSE c2_) Q} IF x1_ THEN c1_ ELSE c2_ {Q}›*) by (auto intro:hoaret.If (*‹⟦⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ∧ bval (?b::bexp) s} ?c₁::com {?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}; ⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. ?P l s ∧ ¬ bval ?b s} ?c₂::com {?Q}⟧ ⟹ ⊢⇩t {?P} IF ?b THEN ?c₁ ELSE ?c₂ {?Q}›*) hoaret.conseq (*‹⟦∀(l::char list ⇒ nat) s::char list ⇒ int. (?P'::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s; ⊢⇩t {?P} ?c::com {?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}; ∀(l::char list ⇒ nat) s::char list ⇒ int. ?Q l s ⟶ (?Q'::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s⟧ ⟹ ⊢⇩t {?P'} ?c {?Q'}›*)) next (*goal: ‹⋀x1 c Q. ⟦⋀Q. finite (support Q) ⟹ ⊢⇩t {wp⇩t c Q} c {Q}; finite (support Q)⟧ ⟹ ⊢⇩t {wp⇩t (WHILE x1 DO c) Q} WHILE x1 DO c {Q}›*) case (While b c) (*‹finite (support ?Q) ⟹ ⊢⇩t {wp⇩t c ?Q} c {?Q}› ‹finite (support Q)›*) let ?x = "new Q" have "∃x. x ∉ support Q" using While.prems (*‹finite (support (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool))›*) infinite_UNIV_listI (*‹infinite UNIV›*) using ex_new_if_finite (*‹⟦infinite UNIV; finite ?A⟧ ⟹ ∃a. a ∉ ?A›*) by blast hence [simp]: "?x ∉ support Q" by (rule someI_ex (*‹∃x. ?P x ⟹ ?P (SOME x. ?P x)›*)) let ?w = "WHILE b DO c" have fsup: "finite (support (λl. wpw b c (l x) Q l))" for x using finite_subset[OF support_wpw] (*‹finite (insert ?x1 (support ?Q1)) ⟹ finite (support (λl. wpw ?b1 ?c1 (l ?x1) ?Q1 l))›*) While.prems (*‹finite (support (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool))›*) by simp have c1: "∀l s. wp⇩t ?w Q l s ⟶ (∃n. wpw b c n Q l s)" unfolding wpt_def (*goal: ‹∀l s. (∃t. (WHILE b DO c, s) ⇒ t ∧ Q l t) ⟶ (∃n. wpw b c n Q l s)›*) by (metis WHILE_Its (*‹⟦(WHILE ?b::bexp DO (?c::com), ?s::char list ⇒ int) ⇒ (?t::char list ⇒ int); (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (?l::char list ⇒ nat) ?t⟧ ⟹ ∃n::nat. wpw ?b ?c n ?Q ?l ?s›*)) have c2: "∀l s. l ?x = 0 ∧ wpw b c (l ?x) Q l s ⟶ ¬ bval b s" by (simp cong: conj_cong (*‹⟦(?P::bool) = (?P'::bool); ?P' ⟹ (?Q::bool) = (?Q'::bool)⟧ ⟹ (?P ∧ ?Q) = (?P' ∧ ?Q')›*)) have w2: "∀l s. 0 < l ?x ∧ wpw b c (l ?x) Q l s ⟶ bval b s" by (auto simp: gr0_conv_Suc (*‹((0::nat) < (?n::nat)) = (∃m::nat. ?n = Suc m)›*) cong: conj_cong (*‹⟦(?P::bool) = (?P'::bool); ?P' ⟹ (?Q::bool) = (?Q'::bool)⟧ ⟹ (?P ∧ ?Q) = (?P' ∧ ?Q')›*)) have 1: "∀l s. wpw b c (Suc(l ?x)) Q l s ⟶ (∃t. (c, s) ⇒ t ∧ wpw b c (l ?x) Q l t)" by simp have "*": "⊢⇩t {λl. wpw b c (Suc (l ?x)) Q l} c {λl. wpw b c (l ?x) Q l}" by (rule strengthen_pre[OF 1 While.IH[of "λl. wpw b c (l ?x) Q l", unfolded wpt_def, OF fsup]] (*‹⊢⇩t {λl. wpw b c (Suc (l (new Q))) Q l} c {λa. wpw b c (a (new Q)) Q a}›*)) show "?case" (*goal: ‹⊢⇩t {wp⇩t (WHILE b DO c) Q} WHILE b DO c {Q}›*) apply (rule conseq[OF _ hoaret.While[OF _ w2 c2]] (*‹⟦∀l s. ?P' l s ⟶ (∃n. wpw b c ((l(new Q := n)) (new Q)) Q (l(new Q := n)) s); ⊢⇩t {λl. wpw b c ((l(new Q := Suc (l (new Q)))) (new Q)) Q (l(new Q := Suc (l (new Q))))} ?c1 {λl. wpw b c (l (new Q)) Q l}; ∀l s. wpw b c ((l(new Q := 0)) (new Q)) Q (l(new Q := 0)) s ⟶ ?Q' l s⟧ ⟹ ⊢⇩t {?P'} WHILE b DO ?c1 {?Q'}›*)) (*goals: 1. ‹∀(l::char list ⇒ nat) s::char list ⇒ int. wp⇩t (WHILE b::bexp DO (c::com)) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ (∃n::nat. wpw b c ((l(new Q := n)) (new Q)) Q (l(new Q := n)) s)› 2. ‹⊢⇩t {λl::char list ⇒ nat. wpw (b::bexp) (c::com) ((l(new (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) := Suc (l (new Q)))) (new Q)) Q (l(new Q := Suc (l (new Q))))} c {λl::char list ⇒ nat. wpw b c (l (new Q)) Q l}› 3. ‹∀(l::char list ⇒ nat) s::char list ⇒ int. wpw (b::bexp) (c::com) ((l(new (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) := 0::nat)) (new Q)) Q (l(new Q := 0::nat)) s ⟶ Q l s› discuss goal 1*) apply (simp add: c1 (*‹∀l s. wp⇩t (WHILE b DO c) Q l s ⟶ (∃n. wpw b c n Q l s)›*) * (*‹⊢⇩t {λl. wpw b c (Suc (l (new Q))) Q l} c {λl. wpw b c (l (new Q)) Q l}›*) assn2_lupd (*‹?x ∉ support ?Q ⟹ ?Q (?l(?x := ?n)) = ?Q ?l›*) wpw_lupd (*‹?x ∉ support ?Q ⟹ wpw ?b ?c ?n ?Q (?l(?x := ?u)) = wpw ?b ?c ?n ?Q ?l›*) del: wpw.simps( (*‹wpw ?b ?c (Suc ?n) ?Q ?l ?s = (bval ?b ?s ∧ (∃s'. (?c, ?s) ⇒ s' ∧ wpw ?b ?c ?n ?Q ?l s'))›*) 2)) (*discuss goal 2*) apply (simp add: c1 (*‹∀(l::char list ⇒ nat) s::char list ⇒ int. wp⇩t (WHILE b::bexp DO (c::com)) (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ (∃n::nat. wpw b c n Q l s)›*) * (*‹⊢⇩t {λl::char list ⇒ nat. wpw (b::bexp) (c::com) (Suc (l (new (Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool)))) Q l} c {λl::char list ⇒ nat. wpw b c (l (new Q)) Q l}›*) assn2_lupd (*‹(?x::char list) ∉ support (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) ⟹ ?Q ((?l::char list ⇒ nat)(?x := ?n::nat)) = ?Q ?l›*) wpw_lupd (*‹(?x::char list) ∉ support (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) ⟹ wpw (?b::bexp) (?c::com) (?n::nat) ?Q ((?l::char list ⇒ nat)(?x := ?u::nat)) = wpw ?b ?c ?n ?Q ?l›*) del: wpw.simps( (*‹wpw (?b::bexp) (?c::com) (Suc (?n::nat)) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (?l::char list ⇒ nat) (?s::char list ⇒ int) = (bval ?b ?s ∧ (∃s'::char list ⇒ int. (?c, ?s) ⇒ s' ∧ wpw ?b ?c ?n ?Q ?l s'))›*) 2)) (*discuss goal 3*) apply (simp add: c1 (*‹∀l s. wp⇩t (WHILE b DO c) Q l s ⟶ (∃n. wpw b c n Q l s)›*) * (*‹⊢⇩t {λl. wpw b c (Suc (l (new Q))) Q l} c {λl. wpw b c (l (new Q)) Q l}›*) assn2_lupd (*‹?x ∉ support ?Q ⟹ ?Q (?l(?x := ?n)) = ?Q ?l›*) wpw_lupd (*‹?x ∉ support ?Q ⟹ wpw ?b ?c ?n ?Q (?l(?x := ?u)) = wpw ?b ?c ?n ?Q ?l›*) del: wpw.simps( (*‹wpw ?b ?c (Suc ?n) ?Q ?l ?s = (bval ?b ?s ∧ (∃s'. (?c, ?s) ⇒ s' ∧ wpw ?b ?c ?n ?Q ?l s'))›*) 2)) (*proven 3 subgoals*) . qed theorem hoaret_complete: "finite(support Q) ⟹ ⊨⇩t {P}c{Q} ⟹ ⊢⇩t {P}c{Q}" apply (rule strengthen_pre[OF _ wpt_is_pre] (*‹⟦∀l s. ?P' l s ⟶ wp⇩t ?c ?Q l s; finite (support ?Q)⟧ ⟹ ⊢⇩t {?P'} ?c {?Q}›*)) (*goals: 1. ‹⟦finite (support Q); ⊨⇩t {P} c {Q}⟧ ⟹ ∀l s. P l s ⟶ wp⇩t c Q l s› 2. ‹⟦finite (support Q); ⊨⇩t {P} c {Q}⟧ ⟹ finite (support Q)› discuss goal 1*) apply ((auto simp: hoare_tvalid_def (*‹(⊨⇩t {?P} ?c {?Q}) = (∀l s. ?P l s ⟶ (∃t. (?c, s) ⇒ t ∧ ?Q l t))›*) wpt_def (*‹wp⇩t ?c ?Q = (λl s. ∃t. (?c, s) ⇒ t ∧ ?Q l t)›*))[1]) (*discuss goal 2*) apply ((auto simp: hoare_tvalid_def (*‹(⊨⇩t {?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool} ?c::com {?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}) = (∀(l::char list ⇒ nat) s::char list ⇒ int. ?P l s ⟶ (∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t))›*) wpt_def (*‹wp⇩t (?c::com) (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) = (λ(l::char list ⇒ nat) s::char list ⇒ int. ∃t::char list ⇒ int. (?c, s) ⇒ t ∧ ?Q l t)›*))[1]) (*proven 2 subgoals*) . text ‹Two examples:› lemma "⊢⇩t {λl s. l ''x'' = nat(s ''x'')} WHILE Less (N 0) (V ''x'') DO ''x'' ::= Plus (V ''x'') (N (-1)) {λl s. s ''x'' ≤ 0}" apply (rule conseq (*‹⟦∀l s. ?P' l s ⟶ ?P l s; ⊢⇩t {?P} ?c {?Q}; ∀l s. ?Q l s ⟶ ?Q' l s⟧ ⟹ ⊢⇩t {?P'} ?c {?Q'}›*)) (*goal: ‹⊢⇩t {λl s. l ''x'' = nat (s ''x'')} WHILE Less (N 0) (V ''x'') DO ''x'' ::= Plus (V ''x'') (N (- 1)) {λl s. s ''x'' ≤ 0}›*) prefer 2 (*top goal: ‹⊢⇩t {?P} WHILE Less (N 0) (V ''x'') DO ''x'' ::= Plus (V ''x'') (N (- 1)) {?Q}› and 2 goals remain*) apply (rule While[where P = "λl s. l ''x'' = nat(s ''x'')" and x = "''x''"] (*‹⟦⊢⇩t {λl s. (l(''x'' := Suc (l ''x''))) ''x'' = nat (s ''x'')} ?c {λl s. l ''x'' = nat (s ''x'')}; ∀l s. 0 < l ''x'' ∧ l ''x'' = nat (s ''x'') ⟶ bval ?b s; ∀l s. l ''x'' = 0 ∧ l ''x'' = nat (s ''x'') ⟶ ¬ bval ?b s⟧ ⟹ ⊢⇩t {λl s. ∃n. (l(''x'' := n)) ''x'' = nat (s ''x'')} WHILE ?b DO ?c {λl s. (l(''x'' := 0)) ''x'' = nat (s ''x'')}›*)) (*top goal: ‹⊢⇩t {?P} WHILE Less (N 0) (V ''x'') DO ''x'' ::= Plus (V ''x'') (N (- 1)) {?Q}› and 2 goals remain*) apply (rule Assign' (*‹∀l s. ?P l s ⟶ ?Q l (s[?a/?x]) ⟹ ⊢⇩t {?P} ?x ::= ?a {?Q}›*)) (*top goal: ‹⊢⇩t {λl s. (l(''x'' := Suc (l ''x''))) ''x'' = nat (s ''x'')} ''x'' ::= Plus (V ''x'') (N (- 1)) {λl s. l ''x'' = nat (s ''x'')}› and 4 goals remain*) by auto lemma "⊢⇩t {λl s. l ''x'' = nat(s ''x'')} WHILE Less (N 0) (V ''x'') DO (''x'' ::= Plus (V ''x'') (N (-1));; (''y'' ::= V ''x'';; WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (-1)))) {λl s. s ''x'' ≤ 0}" apply (rule conseq (*‹⟦∀l s. ?P' l s ⟶ ?P l s; ⊢⇩t {?P} ?c {?Q}; ∀l s. ?Q l s ⟶ ?Q' l s⟧ ⟹ ⊢⇩t {?P'} ?c {?Q'}›*)) (*goal: ‹⊢⇩t {λl s. l ''x'' = nat (s ''x'')} WHILE Less (N 0) (V ''x'') DO (''x'' ::= Plus (V ''x'') (N (- 1));; (''y'' ::= V ''x'';; WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- 1)))) {λl s. s ''x'' ≤ 0}›*) prefer 2 (*top goal: ‹⊢⇩t {?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool} WHILE Less (N (0::int)) (V ''x'') DO (''x'' ::= Plus (V ''x'') (N (- (1::int)));; (''y'' ::= V ''x'';; WHILE Less (N (0::int)) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- (1::int))))) {?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool}› and 2 goals remain*) apply (rule While[where P = "λl s. l ''x'' = nat(s ''x'')" and x = "''x''"] (*‹⟦⊢⇩t {λl s. (l(''x'' := Suc (l ''x''))) ''x'' = nat (s ''x'')} ?c {λl s. l ''x'' = nat (s ''x'')}; ∀l s. 0 < l ''x'' ∧ l ''x'' = nat (s ''x'') ⟶ bval ?b s; ∀l s. l ''x'' = 0 ∧ l ''x'' = nat (s ''x'') ⟶ ¬ bval ?b s⟧ ⟹ ⊢⇩t {λl s. ∃n. (l(''x'' := n)) ''x'' = nat (s ''x'')} WHILE ?b DO ?c {λl s. (l(''x'' := 0)) ''x'' = nat (s ''x'')}›*)) (*top goal: ‹⊢⇩t {?P} WHILE Less (N 0) (V ''x'') DO (''x'' ::= Plus (V ''x'') (N (- 1));; (''y'' ::= V ''x'';; WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- 1)))) {?Q}› and 2 goals remain*) defer 1 (*top goal: ‹∀l s. 0 < l ''x'' ∧ l ''x'' = nat (s ''x'') ⟶ bval (Less (N 0) (V ''x'')) s› and 4 goals remain*) apply auto (*top goal: ‹∀(l::char list ⇒ nat) s::char list ⇒ int. (0::nat) < l ''x'' ∧ l ''x'' = nat (s ''x'') ⟶ bval (Less (N (0::int)) (V ''x'')) s› and 4 goals remain*) apply (rule Seq (*‹⟦⊢⇩t {?P₁} ?c₁ {?P₂}; ⊢⇩t {?P₂} ?c₂ {?P₃}⟧ ⟹ ⊢⇩t {?P₁} ?c₁;; ?c₂ {?P₃}›*)) (*goal: ‹⊢⇩t {λl s. Suc (l ''x'') = nat (s ''x'')} ''x'' ::= Plus (V ''x'') (N (- 1));; (''y'' ::= V ''x'';; WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- 1))) {λl s. l ''x'' = nat (s ''x'')}›*) prefer 2 (*top goal: ‹⊢⇩t {?P₂21::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool} ''y'' ::= V ''x'';; WHILE Less (N (0::int)) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- (1::int))) {λ(l::char list ⇒ nat) s::char list ⇒ int. l ''x'' = nat (s ''x'')}› and 1 goal remains*) apply (rule Seq (*‹⟦⊢⇩t {?P₁} ?c₁ {?P₂}; ⊢⇩t {?P₂} ?c₂ {?P₃}⟧ ⟹ ⊢⇩t {?P₁} ?c₁;; ?c₂ {?P₃}›*)) (*top goal: ‹⊢⇩t {?P₂21::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool} ''y'' ::= V ''x'';; WHILE Less (N (0::int)) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- (1::int))) {λ(l::char list ⇒ nat) s::char list ⇒ int. l ''x'' = nat (s ''x'')}› and 1 goal remains*) prefer 2 (*top goal: ‹⊢⇩t {?P₂24} WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- 1)) {λl s. l ''x'' = nat (s ''x'')}› and 2 goals remain*) apply (rule weaken_post (*‹⟦⊢⇩t {?P} ?c {?Q}; ∀l s. ?Q l s ⟶ ?Q' l s⟧ ⟹ ⊢⇩t {?P} ?c {?Q'}›*)) (*top goal: ‹⊢⇩t {?P₂24} WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- 1)) {λl s. l ''x'' = nat (s ''x'')}› and 2 goals remain*) apply (rule_tac P = "λl s. l ''x'' = nat(s ''x'') ∧ l ''y'' = nat(s ''y'')" and x = "''y''" in While (*‹⟦⊢⇩t {λl::char list ⇒ nat. (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) (l(?x::char list := Suc (l ?x)))} ?c::com {?P}; ∀(l::char list ⇒ nat) s::char list ⇒ int. (0::nat) < l ?x ∧ ?P l s ⟶ bval (?b::bexp) s; ∀(l::char list ⇒ nat) s::char list ⇒ int. l ?x = (0::nat) ∧ ?P l s ⟶ ¬ bval ?b s⟧ ⟹ ⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. ∃n::nat. ?P (l(?x := n)) s} WHILE ?b DO ?c {λl::char list ⇒ nat. ?P (l(?x := 0::nat))}›*)) (*top goal: ‹⊢⇩t {?P₂24} WHILE Less (N 0) (V ''y'') DO ''y'' ::= Plus (V ''y'') (N (- 1)) {?Q27}› and 3 goals remain*) apply (rule Assign' (*‹∀l s. ?P l s ⟶ ?Q l (s[?a/?x]) ⟹ ⊢⇩t {?P} ?x ::= ?a {?Q}›*)) (*top goal: ‹⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. (l(''y'' := Suc (l ''y''))) ''x'' = nat (s ''x'') ∧ (l(''y'' := Suc (l ''y''))) ''y'' = nat (s ''y'')} ''y'' ::= Plus (V ''y'') (N (- (1::int))) {λ(l::char list ⇒ nat) s::char list ⇒ int. l ''x'' = nat (s ''x'') ∧ l ''y'' = nat (s ''y'')}› and 5 goals remain*) apply ((auto)[4]) (*top goal: ‹∀l s. (l(''y'' := Suc (l ''y''))) ''x'' = nat (s ''x'') ∧ (l(''y'' := Suc (l ''y''))) ''y'' = nat (s ''y'') ⟶ l ''x'' = nat ((s[Plus (V ''y'') (N (- 1))/''y'']) ''x'') ∧ l ''y'' = nat ((s[Plus (V ''y'') (N (- 1))/''y'']) ''y'')› and 5 goals remain*) apply (rule Assign (*‹⊢⇩t {λl s. ?P l (s[?a/?x])} ?x ::= ?a {?P}›*)) (*top goal: ‹⊢⇩t {?P₂21} ''y'' ::= V ''x'' {λl s. ∃n. (l(''y'' := n)) ''x'' = nat (s ''x'') ∧ (l(''y'' := n)) ''y'' = nat (s ''y'')}› and 1 goal remains*) apply (rule Assign' (*‹∀(l::char list ⇒ nat) s::char list ⇒ int. (?P::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l s ⟶ (?Q::(char list ⇒ nat) ⇒ (char list ⇒ int) ⇒ bool) l (s[?a::aexp/?x::char list]) ⟹ ⊢⇩t {?P} ?x ::= ?a {?Q}›*)) (*goal: ‹⊢⇩t {λ(l::char list ⇒ nat) s::char list ⇒ int. Suc (l ''x'') = nat (s ''x'')} ''x'' ::= Plus (V ''x'') (N (- (1::int))) {λ(l::char list ⇒ nat) s::char list ⇒ int. ∃n::nat. (l(''y'' := n)) ''x'' = nat ((s[V ''x''/''y'']) ''x'') ∧ (l(''y'' := n)) ''y'' = nat ((s[V ''x''/''y'']) ''y'')}›*) by auto end
{ "path": "Isabelle2024/src/HOL/IMP/Hoare_Total_EX2.thy", "repo": "Isabelle2024", "sha": "176becab556574bfea975aef565ae5c1dbbdd9e20210a1d58b6087888f92146b" }
(* Title: WHATandWHERE-Security Authors: Sylvia Grewe, Alexander Lux, Heiko Mantel, Jens Sauer *) theory WHATWHERE_Security imports Strong_Security.Types begin locale WHATWHERE = fixes SR :: "('exp, 'id, 'val, 'com) TLSteps" and E :: "('exp, 'id, 'val) Evalfunction" and pp :: "'com ⇒ nat" and DA :: "('id, 'd::order) DomainAssignment" and lH :: "('d::order, 'exp) lHatches" begin ― ‹define when two states are indistinguishable for an observer on domain d› definition d_equal :: "'d::order ⇒ ('id, 'val) State ⇒ ('id, 'val) State ⇒ bool" where "d_equal d m m' ≡ ∀x. ((DA x) ≤ d ⟶ (m x) = (m' x))" abbreviation d_equal' :: "('id, 'val) State ⇒ 'd::order ⇒ ('id, 'val) State ⇒ bool" ( "(_ =⇘_⇙ _)" ) where "m =⇘d⇙ m' ≡ d_equal d m m'" ― ‹transitivity of d-equality› lemma d_equal_trans: "⟦ m =⇘d⇙ m'; m' =⇘d⇙ m'' ⟧ ⟹ m =⇘d⇙ m''" by (simp add: d_equal_def (*‹?m =⇘?d⇙ ?m' ≡ ∀x. DA x ≤ ?d ⟶ ?m x = ?m' x›*)) abbreviation SRabbr :: "('exp, 'id, 'val, 'com) TLSteps_curry" ("(1⟨_,/_⟩) →⊲_⊳/ (1⟨_,/_⟩)" [0,0,0,0,0] 81) where "⟨c,m⟩ →⊲α⊳ ⟨p,m'⟩ ≡ ((c,m),α,(p,m')) ∈ SR" ― ‹function for obtaining the unique memory (state) after one step for a command and a memory (state)› definition NextMem :: "'com ⇒ ('id, 'val) State ⇒ ('id, 'val) State" ( "⟦_⟧'(_')" ) where "⟦c⟧(m) ≡ (THE m'. (∃p α. ⟨c,m⟩ →⊲α⊳ ⟨p,m'⟩))" ― ‹function getting all escape hatches for some location› definition htchLoc :: "nat ⇒ ('d, 'exp) Hatches" where "htchLoc ι ≡ {(d,e). (d,e,ι) ∈ lH}" ― ‹function for getting all escape hatches for some set of locations› definition htchLocSet :: "nat set ⇒ ('d, 'exp) Hatches" where "htchLocSet PP ≡ ⋃{h. (∃ι ∈ PP. h = htchLoc ι)}" ― ‹predicate for (d,H)-equality› definition dH_equal :: "'d ⇒ ('d, 'exp) Hatches ⇒ ('id, 'val) State ⇒ ('id, 'val) State ⇒ bool" where "dH_equal d H m m' ≡ (m =⇘d⇙ m' ∧ (∀(d',e) ∈ H. (d' ≤ d ⟶ (E e m = E e m'))))" abbreviation dH_equal' :: "('id, 'val) State ⇒ 'd ⇒ ('d, 'exp) Hatches ⇒ ('id, 'val) State ⇒ bool" ( "(_ ∼⇘_,_⇙ _)" ) where "m ∼⇘d,H⇙ m' ≡ dH_equal d H m m'" ― ‹predicate indicating that a command is not a d-declassification command› definition NDC :: "'d ⇒ 'com ⇒ bool" where "NDC d c ≡ (∀m m'. m =⇘d⇙ m' ⟶ ⟦c⟧(m) =⇘d⇙ ⟦c⟧(m'))" ― ‹predicate indicating an 'immediate d-declassification command' for a set of escape hatches› definition IDC :: "'d ⇒ 'com ⇒ ('d, 'exp) Hatches ⇒ bool" where "IDC d c H ≡ (∃m m'. m =⇘d⇙ m' ∧ (¬ ⟦c⟧(m) =⇘d⇙ ⟦c⟧(m'))) ∧ (∀m m'. m ∼⇘d,H⇙ m' ⟶ ⟦c⟧(m) =⇘d⇙ ⟦c⟧(m') )" definition stepResultsinR :: "'com ProgramState ⇒ 'com ProgramState ⇒ 'com Bisimulation_type ⇒ bool" where "stepResultsinR p p' R ≡ (p = None ∧ p' = None) ∨ (∃c c'. (p = Some c ∧ p' = Some c' ∧ ([c],[c']) ∈ R))" definition dhequality_alternative :: "'d ⇒ nat set ⇒ nat ⇒ ('id, 'val) State ⇒ ('id, 'val) State ⇒ bool" where "dhequality_alternative d PP ι m m' ≡ m ∼⇘d,(htchLocSet PP)⇙ m' ∨ (¬ (htchLoc ι) ⊆ (htchLocSet PP))" definition Strong_dlHPP_Bisimulation :: "'d ⇒ nat set ⇒ 'com Bisimulation_type ⇒ bool" where "Strong_dlHPP_Bisimulation d PP R ≡ (sym R) ∧ (trans R) ∧ (∀(V,V') ∈ R. length V = length V') ∧ (∀(V,V') ∈ R. ∀i < length V. ((NDC d (V!i)) ∨ (IDC d (V!i) (htchLoc (pp (V!i)))))) ∧ (∀(V,V') ∈ R. ∀i < length V. ∀m1 m1' m2 α p. ( ⟨V!i,m1⟩ →⊲α⊳ ⟨p,m2⟩ ∧ m1 ∼⇘d,(htchLocSet PP)⇙ m1') ⟶ (∃p' α' m2'. ( ⟨V'!i,m1'⟩ →⊲α'⊳ ⟨p',m2'⟩ ∧ (stepResultsinR p p' R) ∧ (α,α') ∈ R ∧ (dhequality_alternative d PP (pp (V!i)) m2 m2'))))" ― ‹predicate to define when a program is strongly secure› definition WHATWHERE_Secure :: "'com list ⇒ bool" where "WHATWHERE_Secure V ≡ (∀d PP. (∃R. Strong_dlHPP_Bisimulation d PP R ∧ (V,V) ∈ R))" ― ‹auxiliary lemma to obtain central strong (d,lH,PP)-Bisimulation property as Lemma in meta logic (allows instantiating all the variables manually if necessary)› lemma strongdlHPPB_aux: "⋀V V' m1 m1' m2 p i α. ⟦ Strong_dlHPP_Bisimulation d PP R; i < length V; (V,V') ∈ R; ⟨V!i,m1⟩ →⊲α⊳ ⟨p,m2⟩; m1 ∼⇘d,(htchLocSet PP)⇙ m1' ⟧ ⟹ (∃p' α' m2'. ⟨V'!i,m1'⟩ →⊲α'⊳ ⟨p',m2'⟩ ∧ stepResultsinR p p' R ∧ (α,α') ∈ R ∧ (dhequality_alternative d PP (pp (V!i)) m2 m2'))" apply (simp add: Strong_dlHPP_Bisimulation_def (*‹Strong_dlHPP_Bisimulation ?d ?PP ?R ≡ sym ?R ∧ trans ?R ∧ (∀(V, V')∈?R. length V = length V') ∧ (∀(V, V')∈?R. ∀i<length V. NDC ?d (V ! i) ∨ IDC ?d (V ! i) (htchLoc (pp (V ! i)))) ∧ (∀(V, V')∈?R. ∀i<length V. ∀m1 m1' m2 α p. ⟨V ! i,m1⟩ →⊲α⊳ ⟨p,m2⟩ ∧ m1 ∼⇘?d,htchLocSet ?PP⇙ m1' ⟶ (∃p' α' m2'. ⟨V' ! i,m1'⟩ →⊲α'⊳ ⟨p',m2'⟩ ∧ stepResultsinR p p' ?R ∧ (α, α') ∈ ?R ∧ dhequality_alternative ?d ?PP (pp (V ! i)) m2 m2'))›*)) (*goal: ‹⋀V V' m1 m1' m2 p i α. ⟦Strong_dlHPP_Bisimulation d PP R; i < length V; (V, V') ∈ R; ⟨V ! i,m1⟩ →⊲α⊳ ⟨p,m2⟩; m1 ∼⇘d,htchLocSet PP⇙ m1'⟧ ⟹ ∃p' α' m2'. ⟨V' ! i,m1'⟩ →⊲α'⊳ ⟨p',m2'⟩ ∧ stepResultsinR p p' R ∧ (α, α') ∈ R ∧ dhequality_alternative d PP (pp (V ! i)) m2 m2'›*) by fastforce<close> lemma strongdlHPPB_NDCIDCaux: "⋀V V' i. ⟦Strong_dlHPP_Bisimulation d PP R; (V,V') ∈ R; i < length V ⟧ ⟹ (NDC d (V!i) ∨ IDC d (V!i) (htchLoc (pp (V!i))))" apply (simp add: Strong_dlHPP_Bisimulation_def (*‹Strong_dlHPP_Bisimulation (?d::'d) (?PP::nat set) (?R::('com list × 'com list) set) ≡ sym ?R ∧ trans ?R ∧ (∀(V::'com list, V'::'com list)∈?R. length V = length V') ∧ (∀(V::'com list, V'::'com list)∈?R. ∀i<length V. NDC ?d (V ! i) ∨ IDC ?d (V ! i) (htchLoc ((pp::'com ⇒ nat) (V ! i)))) ∧ (∀(V::'com list, V'::'com list)∈?R. ∀i<length V. ∀(m1::'id ⇒ 'val) (m1'::'id ⇒ 'val) (m2::'id ⇒ 'val) (α::'com list) p::'com option. ⟨V ! i,m1⟩ →⊲α⊳ ⟨p,m2⟩ ∧ m1 ∼⇘?d,htchLocSet ?PP⇙ m1' ⟶ (∃(p'::'com option) (α'::'com list) m2'::'id ⇒ 'val. ⟨V' ! i,m1'⟩ →⊲α'⊳ ⟨p',m2'⟩ ∧ stepResultsinR p p' ?R ∧ (α, α') ∈ ?R ∧ dhequality_alternative ?d ?PP (pp (V ! i)) m2 m2'))›*)) (*goal: ‹⋀V V' i. ⟦Strong_dlHPP_Bisimulation d PP R; (V, V') ∈ R; i < length V⟧ ⟹ NDC d (V ! i) ∨ IDC d (V ! i) (htchLoc (pp (V ! i)))›*) by auto lemma WHATWHERE_empty: "WHATWHERE_Secure []" apply (simp add: WHATWHERE_Secure_def (*‹WHATWHERE_Secure ?V ≡ ∀d PP. ∃R. Strong_dlHPP_Bisimulation d PP R ∧ (?V, ?V) ∈ R›*)) (*goal: ‹WHATWHERE_Secure []›*) apply auto (*goal: ‹∀d PP. ∃R. Strong_dlHPP_Bisimulation d PP R ∧ ([], []) ∈ R›*) apply (rule_tac x="{([],[])}" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹⋀(d::'d) PP::nat set. ∃R::('com list × 'com list) set. Strong_dlHPP_Bisimulation d PP R ∧ ([], []) ∈ R›*) by (simp add: Strong_dlHPP_Bisimulation_def (*‹Strong_dlHPP_Bisimulation ?d ?PP ?R ≡ sym ?R ∧ trans ?R ∧ (∀(V, V')∈?R. length V = length V') ∧ (∀(V, V')∈?R. ∀i<length V. NDC ?d (V ! i) ∨ IDC ?d (V ! i) (htchLoc (pp (V ! i)))) ∧ (∀(V, V')∈?R. ∀i<length V. ∀m1 m1' m2 α p. ⟨V ! i,m1⟩ →⊲α⊳ ⟨p,m2⟩ ∧ m1 ∼⇘?d,htchLocSet ?PP⇙ m1' ⟶ (∃p' α' m2'. ⟨V' ! i,m1'⟩ →⊲α'⊳ ⟨p',m2'⟩ ∧ stepResultsinR p p' ?R ∧ (α, α') ∈ ?R ∧ dhequality_alternative ?d ?PP (pp (V ! i)) m2 m2'))›*) sym_def (*‹sym ?r = (∀x y. (x, y) ∈ ?r ⟶ (y, x) ∈ ?r)›*) trans_def (*‹trans ?r = (∀x y z. (x, y) ∈ ?r ⟶ (y, z) ∈ ?r ⟶ (x, z) ∈ ?r)›*)) end end
{ "path": "afp-2025-02-12/thys/WHATandWHERE_Security/WHATWHERE_Security.thy", "repo": "afp-2025-02-12", "sha": "b83acb1d542c98001849165065703382e1157a8762f27d8e30543c315f9497b7" }
(* Auction Theory Toolbox (http://formare.github.io/auctions/) Authors: * Marco B. Caminati http://caminati.co.nr * Manfred Kerber <mnfrd.krbr@gmail.com> * Christoph Lange <math.semantic.web@gmail.com> * Colin Rowat <c.rowat@bham.ac.uk> Dually licenced under * Creative Commons Attribution (CC-BY) 3.0 * ISC License (1-clause BSD License) See LICENSE file for details (Rationale for this dual licence: http://arxiv.org/abs/1107.3212) *) section ‹Locus where a function or a list (of linord type) attains its maximum value› theory Argmax imports Main begin text ‹Structural induction is used in proofs on lists.› lemma structInduct: assumes "P []" and "∀x xs. P (xs) ⟶ P (x#xs)" shows "P l" using assms (*‹P []› ‹∀x xs. P xs ⟶ P (x # xs)›*) list_nonempty_induct (*‹⟦?xs ≠ []; ⋀x. ?P [x]; ⋀x xs. ⟦xs ≠ []; ?P xs⟧ ⟹ ?P (x # xs)⟧ ⟹ ?P ?xs›*) by metis text ‹the subset of elements of a set where a function reaches its maximum› fun argmax :: "('a ⇒ 'b::linorder) ⇒ 'a set ⇒ 'a set" where "argmax f A = { x ∈ A . f x = Max (f ` A) }" (* For reasons we do not understand we have to duplicate the definition as a lemma in order to prove lm16 in CombinatorialAuctions.thy. *) lemma argmaxLemma: "argmax f A = { x ∈ A . f x = Max (f ` A) }" by simp lemma maxLemma: assumes "x ∈ X" "finite X" shows "Max (f`X) >= f x" (is "?L >= ?R") using assms (*‹x ∈ X› ‹finite X›*) by (metis (opaque_lifting, no_types) Max.coboundedI (*‹⟦finite ?A; ?a ∈ ?A⟧ ⟹ ?a ≤ Max ?A›*) finite_imageI (*‹finite ?F ⟹ finite (?h ` ?F)›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) lemma lm01: "argmax f A = A ∩ f -` {Max (f ` A)}" by force lemma lm02: assumes "y ∈ f`A" shows "A ∩ f -` {y} ≠ {}" using assms (*‹y ∈ f ` A›*) by blast lemma argmaxEquivalence: assumes "∀x∈X. f x = g x" shows "argmax f X = argmax g X" using assms (*‹∀x∈X. f x = g x›*) argmaxLemma (*‹argmax ?f ?A = {x ∈ ?A. ?f x = Max (?f ` ?A)}›*) Collect_cong (*‹(⋀x::?'a. (?P::?'a ⇒ bool) x = (?Q::?'a ⇒ bool) x) ⟹ {x::?'a. ?P x} = {x::?'a. ?Q x}›*) image_cong (*‹⟦?M = ?N; ⋀x. x ∈ ?N ⟹ ?f x = ?g x⟧ ⟹ ?f ` ?M = ?g ` ?N›*) by (metis(no_types,lifting)) text ‹The arg max of a function over a non-empty set is non-empty.› corollary argmax_non_empty_iff: assumes "finite X" "X ≠ {}" shows "argmax f X ≠{}" using assms (*‹finite X› ‹(X::'a set) ≠ {}›*) Max_in (*‹⟦finite ?A; ?A ≠ {}⟧ ⟹ Max ?A ∈ ?A›*) finite_imageI (*‹finite ?F ⟹ finite (?h ` ?F)›*) image_is_empty (*‹(?f ` ?A = {}) = (?A = {})›*) lm01 (*‹argmax ?f ?A = ?A ∩ ?f -` {Max (?f ` ?A)}›*) lm02 (*‹?y ∈ ?f ` ?A ⟹ ?A ∩ ?f -` {?y} ≠ {}›*) by (metis(no_types)) text ‹The previous definition of argmax operates on sets. In the following we define a corresponding notion on lists. To this end, we start with defining a filter predicate and are looking for the elements of a list satisfying a given predicate; but, rather than returning them directly, we return the (sorted) list of their indices. This is done, in different ways, by @{term filterpositions} and @{term filterpositions2}.› (* Given a list l, filterpositions yields the indices of its elements which satisfy a given pred P*) definition filterpositions :: "('a => bool) => 'a list => nat list" where "filterpositions P l = map snd (filter (P o fst) (zip l (upt 0 (size l))))" (* That is, you take the list [a0, a1, ..., an] pair with the indices [0, 1, ..., n], i.e., you get [(a0,0), (a1,1), ..., (an,n)] look where the predicate (P o fst) holds and return the list of the corresponding snd elements. *) (* Alternative definition, making use of list comprehension. In the next line the type info is commented out, since the type inference can be left to Isabelle. *) definition filterpositions2 (* :: "('a => bool) => 'a list => nat list" *) where "filterpositions2 P l = [n. n ← [0..<size l], P (l!n)]" definition maxpositions (*:: "'a::linorder list => nat list"*) where "maxpositions l = filterpositions2 (%x . x ≥ Max (set l)) l" lemma lm03: "maxpositions l = [n. n←[0..<size l], l!n ≥ Max(set l)]" unfolding maxpositions_def filterpositions2_def (*goal: ‹concat (map (λn::nat. if Max (set (l::'a list)) ≤ l ! n then [n] else []) [0::nat..<length l]) = concat (map (λn::nat. if Max (set l) ≤ l ! n then [n] else []) [0::nat..<length l])›*) by fastforce (* argmaxList takes a function and a list as arguments and looks for the positions of the elements at which the function applied to the list element is maximal, e.g., for the list [9, 3, 5, 9, 13] and the function `modulo 8', the function applied to the list would give the list [1, 3, 5, 1, 5], that is, argmaxList will return [2, 4]. *) definition argmaxList (*:: "('a => ('b::linorder)) => 'a list => 'a list"*) where "argmaxList f l = map (nth l) (maxpositions (map f l))" (* The following lemmas state some relationships between different representation such as map and list comprehension *) lemma lm04: "[n . n <- l, P n] = [n . n <- l, n ∈ set l, P n]" proof (-) (*goal: ‹concat (map (λn. if P n then [n] else []) l) = concat (map (λn. if n ∈ set l then if P n then [n] else [] else []) l)›*) have "map (λuu. if P uu then [uu] else []) l = map (λuu. if uu ∈ set l then if P uu then [uu] else [] else []) l" by simp thus "concat (map (λn. if P n then [n] else []) l) = concat (map (λn. if n ∈ set l then if P n then [n] else [] else []) l)" by presburger qed lemma lm05: "[n . n <- [0..<m], P n] = [n . n <- [0..<m], n ∈ set [0..<m], P n]" using lm04 (*‹concat (map (λn::?'a::type. if (?P::?'a::type ⇒ bool) n then [n] else []) (?l::?'a::type list)) = concat (map (λn::?'a::type. if n ∈ set ?l then if ?P n then [n] else [] else []) ?l)›*) by fast (* sledgehammer suggested: concat_map_singleton map_ident map_ext by smt*) lemma lm06: fixes f m P shows "(map f [n . n <- [0..<m], P n]) = [ f n . n <- [0..<m], P n]" apply (induct m) (*goals: 1. ‹map f (concat (map (λn. if P n then [n] else []) [0..<0])) = concat (map (λn. if P n then [f n] else []) [0..<0])› 2. ‹⋀m. map f (concat (map (λn. if P n then [n] else []) [0..<m])) = concat (map (λn. if P n then [f n] else []) [0..<m]) ⟹ map f (concat (map (λn. if P n then [n] else []) [0..<Suc m])) = concat (map (λn. if P n then [f n] else []) [0..<Suc m])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . (* Base case stating the property for the empty list *) lemma map_commutes_a: "[f n . n <- [], Q (f n)] = [x <- (map f []). Q x]" by simp (* Step case where the element x is added to the list xs *) lemma map_commutes_b: "∀ x xs. ([f n . n <- xs, Q (f n)] = [x <- (map f xs). Q x] ⟶ [f n . n <- (x#xs), Q (f n)] = [x <- (map f (x#xs)). Q x])" by simp (* General case comprising the two previous cases. *) lemma map_commutes: fixes f::"'a => 'b" fixes Q::"'b => bool" fixes xs::"'a list" shows "[f n . n <- xs, Q (f n)] = [x <- (map f xs). Q x]" using map_commutes_a (*‹concat (map (λn. if ?Q (?f n) then [?f n] else []) []) = filter ?Q (map ?f [])›*) map_commutes_b (*‹∀x xs. concat (map (λn. if ?Q (?f n) then [?f n] else []) xs) = filter ?Q (map ?f xs) ⟶ concat (map (λn. if ?Q (?f n) then [?f n] else []) (x # xs)) = filter ?Q (map ?f (x # xs))›*) structInduct (*‹⟦?P []; ∀x xs. ?P xs ⟶ ?P (x # xs)⟧ ⟹ ?P ?l›*) by fast lemma lm07: fixes f l shows "maxpositions (map f l) = [n . n <- [0..<size l], f (l!n) ≥ Max (f`(set l))]" (is "maxpositions (?fl) = _") (* Pattern matching abbreviation ?fl corresponds to (map f l). Used in the proof, not part of lemma itself *) proof (-) (*goal: ‹maxpositions (map f l) = concat (map (λn. if Max (f ` set l) ≤ f (l ! n) then [n] else []) [0..<length l])›*) have "maxpositions ?fl = [n. n <- [0..<size ?fl], n∈ set[0..<size ?fl], ?fl!n ≥ Max (set ?fl)]" using lm04 (*‹concat (map (λn. if ?P n then [n] else []) ?l) = concat (map (λn. if n ∈ set ?l then if ?P n then [n] else [] else []) ?l)›*) unfolding filterpositions2_def maxpositions_def (*goal: ‹concat (map (λn. if Max (set (map f l)) ≤ map f l ! n then [n] else []) [0..<length (map f l)]) = concat (map (λn. if n ∈ set [0..<length (map f l)] then if Max (set (map f l)) ≤ map f l ! n then [n] else [] else []) [0..<length (map f l)])›*) . also (*calculation: ‹maxpositions (map f l) = concat (map (λn. if n ∈ set [0..<length (map f l)] then if Max (set (map f l)) ≤ map f l ! n then [n] else [] else []) [0..<length (map f l)])›*) have "... = [n . n <- [0..<size l], (n<size l), (?fl!n ≥ Max (set ?fl))]" by simp also (*calculation: ‹maxpositions (map (f::'b::type ⇒ 'a::linorder) (l::'b::type list)) = concat (map (λn::nat. if n < length l then if Max (set (map f l)) ≤ map f l ! n then [n] else [] else []) [0::nat..<length l])›*) have "... = [n . n <- [0..<size l], (n<size l) ∧ (f (l!n) ≥ Max (set ?fl))]" using nth_map (*‹?n < length ?xs ⟹ map ?f ?xs ! ?n = ?f (?xs ! ?n)›*) by (metis (poly_guards_query, opaque_lifting)) also (*calculation: ‹maxpositions (map f l) = concat (map (λn. if n < length l ∧ Max (set (map f l)) ≤ f (l ! n) then [n] else []) [0..<length l])›*) have "... = [n . n <- [0..<size l], (n∈ set [0..<size l]),(f (l!n) ≥ Max (set ?fl))]" using atLeastLessThan_iff (*‹(?i ∈ {?l..<?u}) = (?l ≤ ?i ∧ ?i < ?u)›*) le0 (*‹0 ≤ ?n›*) set_upt (*‹set [?i..<?j] = {?i..<?j}›*) by (metis(no_types)) also (*calculation: ‹maxpositions (map (f::'b ⇒ 'a) (l::'b list)) = concat (map (λn::nat. if n ∈ set [0::nat..<length l] then if Max (set (map f l)) ≤ f (l ! n) then [n] else [] else []) [0::nat..<length l])›*) have "... = [n . n <- [0..<size l], f (l!n) ≥ Max (set ?fl)]" using lm05 (*‹concat (map (λn::nat. if (?P::nat ⇒ bool) n then [n] else []) [0::nat..<?m::nat]) = concat (map (λn::nat. if n ∈ set [0::nat..<?m] then if ?P n then [n] else [] else []) [0::nat..<?m])›*) by presburger finally (*calculation: ‹maxpositions (map f l) = concat (map (λn. if Max (set (map f l)) ≤ f (l ! n) then [n] else []) [0..<length l])›*) show "?thesis" (*goal: ‹maxpositions (map f l) = concat (map (λn. if Max (f ` set l) ≤ f (l ! n) then [n] else []) [0..<length l])›*) by auto qed lemma lm08: fixes f l shows "argmaxList f l = [ l!n . n <- [0..<size l], f (l!n) ≥ Max (f`(set l))]" unfolding lm07 argmaxList_def (*goal: ‹map ((!) l) (concat (map (λn. if Max (f ` set l) ≤ f (l ! n) then [n] else []) [0..<length l])) = concat (map (λn. if Max (f ` set l) ≤ f (l ! n) then [l ! n] else []) [0..<length l])›*) by (metis lm06 (*‹map ?f (concat (map (λn. if ?P n then [n] else []) [0..<?m])) = concat (map (λn. if ?P n then [?f n] else []) [0..<?m])›*)) text‹The theorem expresses that argmaxList is the list of arguments greater equal the Max of the list.› theorem argmaxadequacy: fixes f::"'a => ('b::linorder)" fixes l::"'a list" shows "argmaxList f l = [ x <- l. f x ≥ Max (f`(set l))]" (is "?lh=_") (* pattern match ?lh abbreviates "argmaxList f l" *) proof (-) (*goal: ‹argmaxList f l = filter (λx. Max (f ` set l) ≤ f x) l›*) let ?P = "% y::('b::linorder) . y ≥ Max (f`(set l))" let ?mh = "[nth l n . n <- [0..<size l], ?P (f (nth l n))]" let ?rh = "[ x <- (map (nth l) [0..<size l]). ?P (f x)]" have "?lh = ?mh" using lm08 (*‹argmaxList ?f ?l = concat (map (λn. if Max (?f ` set ?l) ≤ ?f (?l ! n) then [?l ! n] else []) [0..<length ?l])›*) by fast also (*calculation: ‹argmaxList f l = concat (map (λn. if Max (f ` set l) ≤ f (l ! n) then [l ! n] else []) [0..<length l])›*) have "... = ?rh" using map_commutes (*‹concat (map (λn. if ?Q (?f n) then [?f n] else []) ?xs) = filter ?Q (map ?f ?xs)›*) by fast also (*calculation: ‹argmaxList f l = filter (λx. Max (f ` set l) ≤ f x) (map ((!) l) [0..<length l])›*) have "...= [x <- l. ?P (f x)]" using map_nth (*‹map ((!) ?xs) [0..<length ?xs] = ?xs›*) by metis finally (*calculation: ‹argmaxList (f::'a ⇒ 'b) (l::'a list) = filter (λx::'a. Max (f ` set l) ≤ f x) l›*) show "?thesis" (*goal: ‹argmaxList f l = filter (λx. Max (f ` set l) ≤ f x) l›*) by force qed end
{ "path": "afp-2025-02-12/thys/Vickrey_Clarke_Groves/Argmax.thy", "repo": "afp-2025-02-12", "sha": "f33fcaa52d5af2d58f299dab9c21fb919e15f47e53921bb9a8fc0c76c1d03910" }
(* Title: JinjaThreads/Compiler/Execs.thy Author: Andreas Lochbihler *) section ‹JVM Semantics for the delay bisimulation proof from intermediate language to byte code› theory Execs imports JVMTau begin declare match_ex_table_app [simp del] match_ex_table_eq_NoneI [simp del] compxE2_size_convs [simp del] compxE2_stack_xlift_convs [simp del] compxEs2_stack_xlift_convs [simp del] type_synonym ('addr, 'heap) check_instr' = "'addr instr ⇒ 'addr jvm_prog ⇒ 'heap ⇒ 'addr val list ⇒ 'addr val list ⇒ cname ⇒ mname ⇒ pc ⇒ 'addr frame list ⇒ bool" primrec check_instr' :: "('addr, 'heap) check_instr'" where check_instr'_Load: "check_instr' (Load n) P h stk loc C M₀ pc frs = True" | check_instr'_Store: "check_instr' (Store n) P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Push: "check_instr' (Push v) P h stk loc C₀ M₀ pc frs = True" | check_instr'_New: "check_instr' (New C) P h stk loc C₀ M₀ pc frs = True" | check_instr'_NewArray: "check_instr' (NewArray T) P h stk loc C0 M0 pc frs = (0 < length stk)" | check_instr'_ALoad: "check_instr' ALoad P h stk loc C0 M0 pc frs = (1 < length stk)" | check_instr'_AStore: "check_instr' AStore P h stk loc C0 M0 pc frs = (2 < length stk)" | check_instr'_ALength: "check_instr' ALength P h stk loc C0 M0 pc frs = (0 < length stk)" | check_instr'_Getfield: "check_instr' (Getfield F C) P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Putfield: "check_instr' (Putfield F C) P h stk loc C₀ M₀ pc frs = (1 < length stk)" | check_instr'_CAS: "check_instr' (CAS F C) P h stk loc C₀ M₀ pc frs = (2 < length stk)" | check_instr'_Checkcast: "check_instr' (Checkcast T) P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Instanceof: "check_instr' (Instanceof T) P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Invoke: "check_instr' (Invoke M n) P h stk loc C₀ M₀ pc frs = (n < length stk)" | check_instr'_Return: "check_instr' Return P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Pop: "check_instr' Pop P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Dup: "check_instr' Dup P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_Swap: "check_instr' Swap P h stk loc C₀ M₀ pc frs = (1 < length stk)" | check_instr'_BinOpInstr: "check_instr' (BinOpInstr bop) P h stk loc C₀ M₀ pc frs = (1 < length stk)" | check_instr'_IfFalse: "check_instr' (IfFalse b) P h stk loc C₀ M₀ pc frs = (0 < length stk ∧ 0 ≤ int pc+b)" | check_instr'_Goto: "check_instr' (Goto b) P h stk loc C₀ M₀ pc frs = (0 ≤ int pc+b)" | check_instr'_Throw: "check_instr' ThrowExc P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_MEnter: "check_instr' MEnter P h stk loc C₀ M₀ pc frs = (0 < length stk)" | check_instr'_MExit: "check_instr' MExit P h stk loc C₀ M₀ pc frs = (0 < length stk)" definition ci_stk_offer :: "('addr, 'heap) check_instr' ⇒ bool" where "ci_stk_offer ci = (∀ins P h stk stk' loc C M pc frs. ci ins P h stk loc C M pc frs ⟶ ci ins P h (stk @ stk') loc C M pc frs)" lemma ci_stk_offerI: "(⋀ins P h stk stk' loc C M pc frs. ci ins P h stk loc C M pc frs ⟹ ci ins P h (stk @ stk') loc C M pc frs) ⟹ ci_stk_offer ci" unfolding ci_stk_offer_def (*goal: ‹(⋀ins P h stk stk' loc C M pc frs. ci ins P h stk loc C M pc frs ⟹ ci ins P h (stk @ stk') loc C M pc frs) ⟹ ∀ins P h stk stk' loc C M pc frs. ci ins P h stk loc C M pc frs ⟶ ci ins P h (stk @ stk') loc C M pc frs›*) by blast lemma ci_stk_offerD: "⟦ ci_stk_offer ci; ci ins P h stk loc C M pc frs ⟧ ⟹ ci ins P h (stk @ stk') loc C M pc frs" unfolding ci_stk_offer_def (*goal: ‹⟦∀ins P h stk stk' loc C M pc frs. ci ins P h stk loc C M pc frs ⟶ ci ins P h (stk @ stk') loc C M pc frs; ci ins P h stk loc C M pc frs⟧ ⟹ ci ins P h (stk @ stk') loc C M pc frs›*) by blast lemma check_instr'_stk_offer: "ci_stk_offer check_instr'" proof (rule ci_stk_offerI (*‹(⋀(ins::?'a::type instr) (P::(nat × nat × ?'a::type instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::?'b::type) (stk::?'a::type val list) (stk'::?'a::type val list) (loc::?'a::type val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'a::type frame list. (?ci::?'a::type instr ⇒ (nat × nat × ?'a::type instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ ?'b::type ⇒ ?'a::type val list ⇒ ?'a::type val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ ?'a::type frame list ⇒ bool) ins P h stk loc C M pc frs ⟹ ?ci ins P h (stk @ stk') loc C M pc frs) ⟹ ci_stk_offer ?ci›*)) (*goal: ‹⋀ins P h stk stk' loc C M pc frs. check_instr' ins P h stk loc C M pc frs ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs›*) fix ins and P and h and stk and stk' and loc and C and M and pc and frs assume "check_instr' ins P h stk loc C M pc frs" (*‹check_instr' (ins::'c instr) (P::(nat × nat × 'c instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'d) (stk::'c val list) (loc::'c val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'c frame list)›*) thus "check_instr' ins P h (stk @ stk') loc C M pc frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr' ins P h stk loc C M pc frs; ins = Load x1⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 2. ‹⋀x2. ⟦check_instr' ins P h stk loc C M pc frs; ins = Store x2⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 3. ‹⋀x3. ⟦check_instr' ins P h stk loc C M pc frs; ins = Push x3⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 4. ‹⋀x4. ⟦check_instr' ins P h stk loc C M pc frs; ins = New x4⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 5. ‹⋀x5. ⟦check_instr' ins P h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 6. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = ALoad⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 7. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = AStore⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 8. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = ALength⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 9. ‹⋀x91 x92. ⟦check_instr' ins P h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 10. ‹⋀x101 x102. ⟦check_instr' ins P h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 11. ‹⋀x111 x112. ⟦check_instr' ins P h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 12. ‹⋀x12. ⟦check_instr' ins P h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 13. ‹⋀x13. ⟦check_instr' ins P h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 14. ‹⋀x141 x142. ⟦check_instr' ins P h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 15. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Return⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 16. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Pop⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 17. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Dup⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 18. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Swap⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 19. ‹⋀x19. ⟦check_instr' ins P h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 20. ‹⋀x20. ⟦check_instr' ins P h stk loc C M pc frs; ins = Goto x20⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 21. ‹⋀x21. ⟦check_instr' ins P h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 22. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 23. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = MEnter⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› 24. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = MExit⟧ ⟹ check_instr' ins P h (stk @ stk') loc C M pc frs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*discuss goal 15*) apply ((auto)[1]) (*discuss goal 16*) apply ((auto)[1]) (*discuss goal 17*) apply ((auto)[1]) (*discuss goal 18*) apply ((auto)[1]) (*discuss goal 19*) apply ((auto)[1]) (*discuss goal 20*) apply ((auto)[1]) (*discuss goal 21*) apply ((auto)[1]) (*discuss goal 22*) apply ((auto)[1]) (*discuss goal 23*) apply ((auto)[1]) (*discuss goal 24*) apply ((auto)[1]) (*proven 24 subgoals*) . qed context JVM_heap_base begin lemma check_instr_imp_check_instr': "check_instr ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr ins P h stk loc C M pc frs; ins = Load x1⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 2. ‹⋀x2. ⟦check_instr ins P h stk loc C M pc frs; ins = Store x2⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 3. ‹⋀x3. ⟦check_instr ins P h stk loc C M pc frs; ins = Push x3⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 4. ‹⋀x4. ⟦check_instr ins P h stk loc C M pc frs; ins = New x4⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 5. ‹⋀x5. ⟦check_instr ins P h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 6. ‹⟦check_instr ins P h stk loc C M pc frs; ins = ALoad⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 7. ‹⟦check_instr ins P h stk loc C M pc frs; ins = AStore⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 8. ‹⟦check_instr ins P h stk loc C M pc frs; ins = ALength⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 9. ‹⋀x91 x92. ⟦check_instr ins P h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 10. ‹⋀x101 x102. ⟦check_instr ins P h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 11. ‹⋀x111 x112. ⟦check_instr ins P h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 12. ‹⋀x12. ⟦check_instr ins P h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 13. ‹⋀x13. ⟦check_instr ins P h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 14. ‹⋀x141 x142. ⟦check_instr ins P h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 15. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Return⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 16. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Pop⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 17. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Dup⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 18. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Swap⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 19. ‹⋀x19. ⟦check_instr ins P h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 20. ‹⋀x20. ⟦check_instr ins P h stk loc C M pc frs; ins = Goto x20⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 21. ‹⋀x21. ⟦check_instr ins P h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 22. ‹⟦check_instr ins P h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 23. ‹⟦check_instr ins P h stk loc C M pc frs; ins = MEnter⟧ ⟹ check_instr' ins P h stk loc C M pc frs› 24. ‹⟦check_instr ins P h stk loc C M pc frs; ins = MExit⟧ ⟹ check_instr' ins P h stk loc C M pc frs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*discuss goal 15*) apply ((auto)[1]) (*discuss goal 16*) apply ((auto)[1]) (*discuss goal 17*) apply ((auto)[1]) (*discuss goal 18*) apply ((auto)[1]) (*discuss goal 19*) apply ((auto)[1]) (*discuss goal 20*) apply ((auto)[1]) (*discuss goal 21*) apply ((auto)[1]) (*discuss goal 22*) apply ((auto)[1]) (*discuss goal 23*) apply ((auto)[1]) (*discuss goal 24*) apply ((auto)[1]) (*proven 24 subgoals*) . lemma check_instr_stk_offer: "ci_stk_offer check_instr" proof (rule ci_stk_offerI (*‹(⋀ins P h stk stk' loc C M pc frs. ?ci ins P h stk loc C M pc frs ⟹ ?ci ins P h (stk @ stk') loc C M pc frs) ⟹ ci_stk_offer ?ci›*)) (*goal: ‹⋀ins P h stk stk' loc C M pc frs. check_instr ins P h stk loc C M pc frs ⟹ check_instr ins P h (stk @ stk') loc C M pc frs›*) fix ins and P and h and stk and stk' and loc and C and M and pc and frs assume "check_instr ins P h stk loc C M pc frs" (*‹check_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'heap) (stk::'addr val list) (loc::'addr val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'addr frame list)›*) thus "check_instr ins P h (stk @ stk') loc C M pc frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr ins P h stk loc C M pc frs; ins = Load x1⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 2. ‹⋀x2. ⟦check_instr ins P h stk loc C M pc frs; ins = Store x2⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 3. ‹⋀x3. ⟦check_instr ins P h stk loc C M pc frs; ins = Push x3⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 4. ‹⋀x4. ⟦check_instr ins P h stk loc C M pc frs; ins = New x4⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 5. ‹⋀x5. ⟦check_instr ins P h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 6. ‹⟦check_instr ins P h stk loc C M pc frs; ins = ALoad⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 7. ‹⟦check_instr ins P h stk loc C M pc frs; ins = AStore⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 8. ‹⟦check_instr ins P h stk loc C M pc frs; ins = ALength⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 9. ‹⋀x91 x92. ⟦check_instr ins P h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 10. ‹⋀x101 x102. ⟦check_instr ins P h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 11. ‹⋀x111 x112. ⟦check_instr ins P h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 12. ‹⋀x12. ⟦check_instr ins P h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 13. ‹⋀x13. ⟦check_instr ins P h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 14. ‹⋀x141 x142. ⟦check_instr ins P h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 15. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Return⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 16. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Pop⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 17. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Dup⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 18. ‹⟦check_instr ins P h stk loc C M pc frs; ins = Swap⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 19. ‹⋀x19. ⟦check_instr ins P h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 20. ‹⋀x20. ⟦check_instr ins P h stk loc C M pc frs; ins = Goto x20⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 21. ‹⋀x21. ⟦check_instr ins P h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 22. ‹⟦check_instr ins P h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 23. ‹⟦check_instr ins P h stk loc C M pc frs; ins = MEnter⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› 24. ‹⟦check_instr ins P h stk loc C M pc frs; ins = MExit⟧ ⟹ check_instr ins P h (stk @ stk') loc C M pc frs› discuss goal 1*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 2*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 3*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 4*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 5*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 6*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 7*) apply ((auto simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd ((?xs::?'a list) @ (?ys::?'a list)) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) tl_append (*‹tl ((?xs::?'a list) @ (?ys::?'a list)) = (case ?xs of [] ⇒ tl ?ys | (z::?'a) # (zs::?'a list) ⇒ zs @ ?ys)›*) split: list.split (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 8*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 9*) apply ((auto simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd ((?xs::?'a list) @ (?ys::?'a list)) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) tl_append (*‹tl ((?xs::?'a list) @ (?ys::?'a list)) = (case ?xs of [] ⇒ tl ?ys | (z::?'a) # (zs::?'a list) ⇒ zs @ ?ys)›*) split: list.split (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 10*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 11*) apply ((auto simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd ((?xs::?'a list) @ (?ys::?'a list)) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) tl_append (*‹tl ((?xs::?'a list) @ (?ys::?'a list)) = (case ?xs of [] ⇒ tl ?ys | (z::?'a) # (zs::?'a list) ⇒ zs @ ?ys)›*) split: list.split (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 12*) apply ((auto simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd ((?xs::?'a list) @ (?ys::?'a list)) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) tl_append (*‹tl ((?xs::?'a list) @ (?ys::?'a list)) = (case ?xs of [] ⇒ tl ?ys | (z::?'a) # (zs::?'a list) ⇒ zs @ ?ys)›*) split: list.split (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 13*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 14*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 15*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 16*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 17*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 18*) apply ((auto simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd ((?xs::?'a list) @ (?ys::?'a list)) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) tl_append (*‹tl ((?xs::?'a list) @ (?ys::?'a list)) = (case ?xs of [] ⇒ tl ?ys | (z::?'a) # (zs::?'a list) ⇒ zs @ ?ys)›*) split: list.split (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 19*) apply ((auto simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd ((?xs::?'a list) @ (?ys::?'a list)) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) tl_append (*‹tl ((?xs::?'a list) @ (?ys::?'a list)) = (case ?xs of [] ⇒ tl ?ys | (z::?'a) # (zs::?'a list) ⇒ zs @ ?ys)›*) split: list.split (*‹(?P::?'b ⇒ bool) (case ?list::?'a list of [] ⇒ ?f1.0::?'b | (x::?'a) # (xa::?'a list) ⇒ (?f2.0::?'a ⇒ ?'a list ⇒ ?'b) x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀(x21::?'a) x22::?'a list. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 20*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 21*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 22*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 23*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*discuss goal 24*) apply ((auto simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) hd_append (*‹hd (?xs @ ?ys) = (if ?xs = [] then hd ?ys else hd ?xs)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) tl_append (*‹tl (?xs @ ?ys) = (case ?xs of [] ⇒ tl ?ys | z # zs ⇒ zs @ ?ys)›*) split: list.split (*‹?P (case ?list of [] ⇒ ?f1.0 | x # xa ⇒ ?f2.0 x xa) = ((?list = [] ⟶ ?P ?f1.0) ∧ (∀x21 x22. ?list = x21 # x22 ⟶ ?P (?f2.0 x21 x22)))›*))[1]) (*proven 24 subgoals*) . qed end (* TODO: Combine ins_jump_ok and jump_ok *) primrec jump_ok :: "'addr instr list ⇒ nat ⇒ nat ⇒ bool" where "jump_ok [] n n' = True" | "jump_ok (x # xs) n n' = (jump_ok xs (Suc n) n' ∧ (case x of IfFalse m ⇒ - int n ≤ m ∧ m ≤ int (n' + length xs) | Goto m ⇒ - int n ≤ m ∧ m ≤ int (n' + length xs) | _ ⇒ True))" lemma jump_ok_append [simp]: "jump_ok (xs @ xs') n n' ⟷ jump_ok xs n (n' + length xs') ∧ jump_ok xs' (n + length xs) n'" apply (induct xs arbitrary: n) (*goals: 1. ‹⋀n. jump_ok ([] @ xs') n n' = (jump_ok [] n (n' + length xs') ∧ jump_ok xs' (n + length []) n')› 2. ‹⋀a xs n. (⋀n. jump_ok (xs @ xs') n n' = (jump_ok xs n (n' + length xs') ∧ jump_ok xs' (n + length xs) n')) ⟹ jump_ok ((a # xs) @ xs') n n' = (jump_ok (a # xs) n (n' + length xs') ∧ jump_ok xs' (n + length (a # xs)) n')› discuss goal 1*) apply simp (*discuss goal 2*) apply (auto split: instr.split (*‹?P (case ?instr of Load x ⇒ ?f1.0 x | Store x ⇒ ?f2.0 x | Push x ⇒ ?f3.0 x | New x ⇒ ?f4.0 x | NewArray x ⇒ ?f5.0 x | ALoad ⇒ ?f6.0 | AStore ⇒ ?f7.0 | ALength ⇒ ?f8.0 | Getfield x xa ⇒ ?f9.0 x xa | Putfield x xa ⇒ ?f10.0 x xa | CAS x xa ⇒ ?f11.0 x xa | Checkcast x ⇒ ?f12.0 x | Instanceof x ⇒ ?f13.0 x | Invoke x xa ⇒ ?f14.0 x xa | Return ⇒ ?f15.0 | Pop ⇒ ?f16.0 | Dup ⇒ ?f17.0 | Swap ⇒ ?f18.0 | BinOpInstr x ⇒ ?f19.0 x | Goto x ⇒ ?f20.0 x | IfFalse x ⇒ ?f21.0 x | ThrowExc ⇒ ?f22.0 | MEnter ⇒ ?f23.0 | MExit ⇒ ?f24.0) = ((∀x1. ?instr = Load x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?instr = Store x2 ⟶ ?P (?f2.0 x2)) ∧ (∀x3. ?instr = Push x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x4. ?instr = New x4 ⟶ ?P (?f4.0 x4)) ∧ (∀x5. ?instr = NewArray x5 ⟶ ?P (?f5.0 x5)) ∧ (?instr = ALoad ⟶ ?P ?f6.0) ∧ (?instr = AStore ⟶ ?P ?f7.0) ∧ (?instr = ALength ⟶ ?P ?f8.0) ∧ (∀x91 x92. ?instr = Getfield x91 x92 ⟶ ?P (?f9.0 x91 x92)) ∧ (∀x101 x102. ?instr = Putfield x101 x102 ⟶ ?P (?f10.0 x101 x102)) ∧ (∀x111 x112. ?instr = CAS x111 x112 ⟶ ?P (?f11.0 x111 x112)) ∧ (∀x12. ?instr = Checkcast x12 ⟶ ?P (?f12.0 x12)) ∧ (∀x13. ?instr = Instanceof x13 ⟶ ?P (?f13.0 x13)) ∧ (∀x141 x142. ?instr = Invoke x141 x142 ⟶ ?P (?f14.0 x141 x142)) ∧ (?instr = Return ⟶ ?P ?f15.0) ∧ (?instr = Pop ⟶ ?P ?f16.0) ∧ (?instr = Dup ⟶ ?P ?f17.0) ∧ (?instr = Swap ⟶ ?P ?f18.0) ∧ (∀x19. ?instr = BinOpInstr x19 ⟶ ?P (?f19.0 x19)) ∧ (∀x20. ?instr = Goto x20 ⟶ ?P (?f20.0 x20)) ∧ (∀x21. ?instr = IfFalse x21 ⟶ ?P (?f21.0 x21)) ∧ (?instr = ThrowExc ⟶ ?P ?f22.0) ∧ (?instr = MEnter ⟶ ?P ?f23.0) ∧ (?instr = MExit ⟶ ?P ?f24.0))›*)) (*proven 2 subgoals*) . lemma jump_ok_GotoD: "⟦ jump_ok ins n n'; ins ! pc = Goto m; pc < length ins ⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length ins - pc + n')" apply (induct ins arbitrary: n n' pc) (*goals: 1. ‹⋀n n' pc. ⟦jump_ok [] n n'; [] ! pc = Goto m; pc < length []⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length [] - pc + n')› 2. ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = Goto m; pc < length ins⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length ins - pc + n'); jump_ok (a # ins) n n'; (a # ins) ! pc = Goto m; pc < length (a # ins)⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length (a # ins) - pc + n')› discuss goal 1*) apply simp (*discuss goal 2*) apply clarsimp (*goal: ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = Goto m; pc < length ins⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length ins - pc + n'); jump_ok (a # ins) n n'; (a # ins) ! pc = Goto m; pc < length (a # ins)⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length (a # ins) - pc + n')›*) apply (case_tac pc) (*goals: 1. ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = Goto m; pc < length ins⟧ ⟹ - int pc - int n ≤ m ∧ m < int (length ins + n' - pc); (a # ins) ! pc = Goto m; pc < Suc (length ins); jump_ok ins (Suc n) n'; case a of Goto m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | IfFalse m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | _ ⇒ True; pc = 0⟧ ⟹ - int pc - int n ≤ m ∧ m < int (Suc (length ins + n') - pc)› 2. ‹⋀a ins n n' pc nat. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = Goto m; pc < length ins⟧ ⟹ - int pc - int n ≤ m ∧ m < int (length ins + n' - pc); (a # ins) ! pc = Goto m; pc < Suc (length ins); jump_ok ins (Suc n) n'; case a of Goto m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | IfFalse m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | _ ⇒ True; pc = Suc nat⟧ ⟹ - int pc - int n ≤ m ∧ m < int (Suc (length ins + n') - pc)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma jump_ok_IfFalseD: "⟦ jump_ok ins n n'; ins ! pc = IfFalse m; pc < length ins ⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length ins - pc + n')" apply (induct ins arbitrary: n n' pc) (*goals: 1. ‹⋀n n' pc. ⟦jump_ok [] n n'; [] ! pc = IfFalse m; pc < length []⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length [] - pc + n')› 2. ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = IfFalse m; pc < length ins⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length ins - pc + n'); jump_ok (a # ins) n n'; (a # ins) ! pc = IfFalse m; pc < length (a # ins)⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length (a # ins) - pc + n')› discuss goal 1*) apply simp (*discuss goal 2*) apply clarsimp (*goal: ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = IfFalse m; pc < length ins⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length ins - pc + n'); jump_ok (a # ins) n n'; (a # ins) ! pc = IfFalse m; pc < length (a # ins)⟧ ⟹ - int (pc + n) ≤ m ∧ m < int (length (a # ins) - pc + n')›*) apply (case_tac pc) (*goals: 1. ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = IfFalse m; pc < length ins⟧ ⟹ - int pc - int n ≤ m ∧ m < int (length ins + n' - pc); (a # ins) ! pc = IfFalse m; pc < Suc (length ins); jump_ok ins (Suc n) n'; case a of Goto m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | IfFalse m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | _ ⇒ True; pc = 0⟧ ⟹ - int pc - int n ≤ m ∧ m < int (Suc (length ins + n') - pc)› 2. ‹⋀a ins n n' pc nat. ⟦⋀n n' pc. ⟦jump_ok ins n n'; ins ! pc = IfFalse m; pc < length ins⟧ ⟹ - int pc - int n ≤ m ∧ m < int (length ins + n' - pc); (a # ins) ! pc = IfFalse m; pc < Suc (length ins); jump_ok ins (Suc n) n'; case a of Goto m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | IfFalse m ⇒ - int n ≤ m ∧ m ≤ int (n' + length ins) | _ ⇒ True; pc = Suc nat⟧ ⟹ - int pc - int n ≤ m ∧ m < int (Suc (length ins + n') - pc)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma fixes e :: "'addr expr1" and es :: "'addr expr1 list" shows compE2_jump_ok [intro!]: "jump_ok (compE2 e) n (Suc n')" and compEs2_jump_ok [intro!]: "jump_ok (compEs2 es) n (Suc n')" apply (induct e and es arbitrary: n n' and n n' rule: compE2.induct compEs2.induct) (*goals: 1. ‹⋀x n n'. jump_ok (compE2 (new x)) n (Suc n')› 2. ‹⋀x1 x2 n n'. (⋀n n'. jump_ok (compE2 x2) n (Suc n')) ⟹ jump_ok (compE2 (newA x1⌊x2⌉)) n (Suc n')› 3. ‹⋀x1 x2 n n'. (⋀n n'. jump_ok (compE2 x2) n (Suc n')) ⟹ jump_ok (compE2 (Cast x1 x2)) n (Suc n')› 4. ‹⋀x1 x2 n n'. (⋀n n'. jump_ok (compE2 x1) n (Suc n')) ⟹ jump_ok (compE2 (x1 instanceof x2)) n (Suc n')› 5. ‹⋀x n n'. jump_ok (compE2 (Val x)) n (Suc n')› 6. ‹⋀x1 x2 x3 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x3) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1 «x2» x3)) n (Suc n')› 7. ‹⋀x n n'. jump_ok (compE2 (Var x)) n (Suc n')› 8. ‹⋀x1 x2 n n'. (⋀n n'. jump_ok (compE2 x2) n (Suc n')) ⟹ jump_ok (compE2 (x1:=x2)) n (Suc n')› 9. ‹⋀x1 x2 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x2) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1⌊x2⌉)) n (Suc n')› 10. ‹⋀x1 x2 x3 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x2) n (Suc n'); ⋀n n'. jump_ok (compE2 x3) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1⌊x2⌉ := x3)) n (Suc n')› 11. ‹⋀x n n'. (⋀n n'. jump_ok (compE2 x) n (Suc n')) ⟹ jump_ok (compE2 (x∙length)) n (Suc n')› 12. ‹⋀x1 x2 x3 n n'. (⋀n n'. jump_ok (compE2 x1) n (Suc n')) ⟹ jump_ok (compE2 (x1∙x2{x3})) n (Suc n')› 13. ‹⋀x1 x2 x3 x4 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x4) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1∙x2{x3} := x4)) n (Suc n')› 14. ‹⋀x1 x2 x3 x4 x5 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x4) n (Suc n'); ⋀n n'. jump_ok (compE2 x5) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1∙compareAndSwap(x2∙x3, x4, x5))) n (Suc n')› 15. ‹⋀x1 x2 x3 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compEs2 x3) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1∙x2(x3))) n (Suc n')› 16. ‹⋀x1 x2 x3 x4 n n'. (⋀n n'. jump_ok (compE2 x4) n (Suc n')) ⟹ jump_ok (compE2 {x1:x2=x3; x4}) n (Suc n')› 17. ‹⋀x1 x2 x3 n n'. ⟦⋀n n'. jump_ok (compE2 x2) n (Suc n'); ⋀n n'. jump_ok (compE2 x3) n (Suc n')⟧ ⟹ jump_ok (compE2 (sync⇘x1⇙ (x2) x3)) n (Suc n')› 18. ‹⋀x1 x2 x3 n n'. (⋀n n'. jump_ok (compE2 x3) n (Suc n')) ⟹ jump_ok (compE2 (insync⇘x1⇙ (x2) x3)) n (Suc n')› 19. ‹⋀x1 x2 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x2) n (Suc n')⟧ ⟹ jump_ok (compE2 (x1;; x2)) n (Suc n')› 20. ‹⋀x1 x2 x3 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x2) n (Suc n'); ⋀n n'. jump_ok (compE2 x3) n (Suc n')⟧ ⟹ jump_ok (compE2 (if (x1) x2 else x3)) n (Suc n')› 21. ‹⋀x1 x2 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x2) n (Suc n')⟧ ⟹ jump_ok (compE2 (while (x1) x2)) n (Suc n')› 22. ‹⋀x n n'. (⋀n n'. jump_ok (compE2 x) n (Suc n')) ⟹ jump_ok (compE2 (throw x)) n (Suc n')› 23. ‹⋀x1 x2 x3 x4 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compE2 x4) n (Suc n')⟧ ⟹ jump_ok (compE2 (try x1 catch(x2 x3) x4)) n (Suc n')› 24. ‹⋀n n'. jump_ok (compEs2 []) n (Suc n')› 25. ‹⋀x1 x2 n n'. ⟦⋀n n'. jump_ok (compE2 x1) n (Suc n'); ⋀n n'. jump_ok (compEs2 x2) n (Suc n')⟧ ⟹ jump_ok (compEs2 (x1 # x2)) n (Suc n')› discuss goal 1*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 2*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 3*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 4*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 5*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 6*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 7*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 8*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 9*) apply ((auto split: bop.split (*‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | NotEq ⇒ ?f2.0::?'a | LessThan ⇒ ?f3.0::?'a | LessOrEqual ⇒ ?f4.0::?'a | GreaterThan ⇒ ?f5.0::?'a | GreaterOrEqual ⇒ ?f6.0::?'a | Add ⇒ ?f7.0::?'a | Subtract ⇒ ?f8.0::?'a | Mult ⇒ ?f9.0::?'a | Div ⇒ ?f10.0::?'a | Mod ⇒ ?f11.0::?'a | BinAnd ⇒ ?f12.0::?'a | BinOr ⇒ ?f13.0::?'a | BinXor ⇒ ?f14.0::?'a | ShiftLeft ⇒ ?f15.0::?'a | ShiftRightZeros ⇒ ?f16.0::?'a | ShiftRightSigned ⇒ ?f17.0::?'a) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 10*) apply ((auto split: bop.split (*‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | NotEq ⇒ ?f2.0::?'a | LessThan ⇒ ?f3.0::?'a | LessOrEqual ⇒ ?f4.0::?'a | GreaterThan ⇒ ?f5.0::?'a | GreaterOrEqual ⇒ ?f6.0::?'a | Add ⇒ ?f7.0::?'a | Subtract ⇒ ?f8.0::?'a | Mult ⇒ ?f9.0::?'a | Div ⇒ ?f10.0::?'a | Mod ⇒ ?f11.0::?'a | BinAnd ⇒ ?f12.0::?'a | BinOr ⇒ ?f13.0::?'a | BinXor ⇒ ?f14.0::?'a | ShiftLeft ⇒ ?f15.0::?'a | ShiftRightZeros ⇒ ?f16.0::?'a | ShiftRightSigned ⇒ ?f17.0::?'a) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 11*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 12*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 13*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 14*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 15*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 16*) apply ((auto split: bop.split (*‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | NotEq ⇒ ?f2.0::?'a | LessThan ⇒ ?f3.0::?'a | LessOrEqual ⇒ ?f4.0::?'a | GreaterThan ⇒ ?f5.0::?'a | GreaterOrEqual ⇒ ?f6.0::?'a | Add ⇒ ?f7.0::?'a | Subtract ⇒ ?f8.0::?'a | Mult ⇒ ?f9.0::?'a | Div ⇒ ?f10.0::?'a | Mod ⇒ ?f11.0::?'a | BinAnd ⇒ ?f12.0::?'a | BinOr ⇒ ?f13.0::?'a | BinXor ⇒ ?f14.0::?'a | ShiftLeft ⇒ ?f15.0::?'a | ShiftRightZeros ⇒ ?f16.0::?'a | ShiftRightSigned ⇒ ?f17.0::?'a) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 17*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 18*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 19*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 20*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 21*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 22*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 23*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 24*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*discuss goal 25*) apply ((auto split: bop.split (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))›*))[1]) (*proven 25 subgoals*) . lemma fixes e :: "'addr expr1" and es :: "'addr expr1 list" shows compE1_Goto_not_same: "⟦ compE2 e ! pc = Goto i; pc < length (compE2 e) ⟧ ⟹ nat (int pc + i) ≠ pc" and compEs2_Goto_not_same: "⟦ compEs2 es ! pc = Goto i; pc < length (compEs2 es) ⟧ ⟹ nat (int pc + i) ≠ pc" apply(induct e and es arbitrary: pc i and pc i rule: compE2.induct compEs2.induct) apply(auto simp add: nth_Cons nth_append split: if_split_asm bop.split_asm nat.splits) apply fastforce+ done fun ins_jump_ok :: "'addr instr ⇒ nat ⇒ bool" where "ins_jump_ok (Goto m) l = (- (int l) ≤ m)" | "ins_jump_ok (IfFalse m) l = (- (int l) ≤ m)" | "ins_jump_ok _ _ = True" definition wf_ci :: "('addr, 'heap) check_instr' ⇒ bool" where "wf_ci ci ⟷ ci_stk_offer ci ∧ ci ≤ check_instr' ∧ (∀ins P h stk loc C M pc pc' frs. ci ins P h stk loc C M pc frs ⟶ ins_jump_ok ins pc' ⟶ ci ins P h stk loc C M pc' frs)" lemma wf_ciI: "⟦ ci_stk_offer ci; ⋀ins P h stk loc C M pc frs. ci ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs; ⋀ins P h stk loc C M pc pc' frs. ⟦ ci ins P h stk loc C M pc frs; ins_jump_ok ins pc' ⟧ ⟹ ci ins P h stk loc C M pc' frs ⟧ ⟹ wf_ci ci" unfolding wf_ci_def le_fun_def le_bool_def (*goal: ‹⟦ci_stk_offer (ci::'a instr ⇒ (nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ 'b ⇒ 'a val list ⇒ 'a val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ 'a frame list ⇒ bool); ⋀(ins::'a instr) (P::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'b) (stk::'a val list) (loc::'a val list) (C::String.literal) (M::String.literal) (pc::nat) frs::'a frame list. ci ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs; ⋀(ins::'a instr) (P::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'b) (stk::'a val list) (loc::'a val list) (C::String.literal) (M::String.literal) (pc::nat) (pc'::nat) frs::'a frame list. ⟦ci ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ ci ins P h stk loc C M pc' frs⟧ ⟹ ci_stk_offer ci ∧ (∀(x::'a instr) (xa::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (xb::'b) (xc::'a val list) (xd::'a val list) (xe::String.literal) (xf::String.literal) (xg::nat) xh::'a frame list. ci x xa xb xc xd xe xf xg xh ⟶ check_instr' x xa xb xc xd xe xf xg xh) ∧ (∀(ins::'a instr) (P::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'b) (stk::'a val list) (loc::'a val list) (C::String.literal) (M::String.literal) (pc::nat) (pc'::nat) frs::'a frame list. ci ins P h stk loc C M pc frs ⟶ ins_jump_ok ins pc' ⟶ ci ins P h stk loc C M pc' frs)›*) by blast lemma check_instr'_pc: "⟦ check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc' ⟧ ⟹ check_instr' ins P h stk loc C M pc' frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Load x1⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 2. ‹⋀x2. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Store x2⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 3. ‹⋀x3. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Push x3⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 4. ‹⋀x4. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = New x4⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 5. ‹⋀x5. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = NewArray x5⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 6. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = ALoad⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 7. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = AStore⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 8. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = ALength⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 9. ‹⋀x91 x92. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Getfield x91 x92⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 10. ‹⋀x101 x102. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Putfield x101 x102⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 11. ‹⋀x111 x112. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = CAS x111 x112⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 12. ‹⋀x12. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Checkcast x12⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 13. ‹⋀x13. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Instanceof x13⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 14. ‹⋀x141 x142. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Invoke x141 x142⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 15. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Return⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 16. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Pop⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 17. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Dup⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 18. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Swap⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 19. ‹⋀x19. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = BinOpInstr x19⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 20. ‹⋀x20. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Goto x20⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 21. ‹⋀x21. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = IfFalse x21⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 22. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = ThrowExc⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 23. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = MEnter⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 24. ‹⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = MExit⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*discuss goal 15*) apply ((auto)[1]) (*discuss goal 16*) apply ((auto)[1]) (*discuss goal 17*) apply ((auto)[1]) (*discuss goal 18*) apply ((auto)[1]) (*discuss goal 19*) apply ((auto)[1]) (*discuss goal 20*) apply ((auto)[1]) (*discuss goal 21*) apply ((auto)[1]) (*discuss goal 22*) apply ((auto)[1]) (*discuss goal 23*) apply ((auto)[1]) (*discuss goal 24*) apply ((auto)[1]) (*proven 24 subgoals*) . lemma wf_ci_check_instr' [iff]: "wf_ci check_instr'" apply (rule wf_ciI (*‹⟦ci_stk_offer (?ci::?'a instr ⇒ (nat × nat × ?'a instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ ?'b ⇒ ?'a val list ⇒ ?'a val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ ?'a frame list ⇒ bool); ⋀(ins::?'a instr) (P::(nat × nat × ?'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::?'b) (stk::?'a val list) (loc::?'a val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'a frame list. ?ci ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs; ⋀(ins::?'a instr) (P::(nat × nat × ?'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::?'b) (stk::?'a val list) (loc::?'a val list) (C::String.literal) (M::String.literal) (pc::nat) (pc'::nat) frs::?'a frame list. ⟦?ci ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ ?ci ins P h stk loc C M pc' frs⟧ ⟹ wf_ci ?ci›*)) (*goals: 1. ‹ci_stk_offer check_instr'› 2. ‹⋀ins P h stk loc C M pc frs. check_instr' ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs› 3. ‹⋀ins P h stk loc C M pc pc' frs. ⟦check_instr' ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› discuss goal 1*) apply (rule check_instr'_stk_offer (*‹ci_stk_offer check_instr'›*)) (*discuss goal 2*) apply assumption (*discuss goal 3*) apply (erule (1) check_instr'_pc (*‹⟦check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs; ins_jump_ok ?ins ?pc'⟧ ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*)) (*proven 3 subgoals*) . lemma jump_ok_ins_jump_ok: "⟦ jump_ok ins n n'; pc < length ins ⟧ ⟹ ins_jump_ok (ins ! pc) (pc + n)" apply (induct ins arbitrary: n n' pc) (*goals: 1. ‹⋀n n' pc. ⟦jump_ok [] n n'; pc < length []⟧ ⟹ ins_jump_ok ([] ! pc) (pc + n)› 2. ‹⋀a ins n n' pc. ⟦⋀n n' pc. ⟦jump_ok ins n n'; pc < length ins⟧ ⟹ ins_jump_ok (ins ! pc) (pc + n); jump_ok (a # ins) n n'; pc < length (a # ins)⟧ ⟹ ins_jump_ok ((a # ins) ! pc) (pc + n)› discuss goal 1*) apply (fastforce simp add: nth_Cons' (*‹(?x # ?xs) ! ?n = (if ?n = 0 then ?x else ?xs ! (?n - 1))›*) gr0_conv_Suc (*‹(0 < ?n) = (∃m. ?n = Suc m)›*) split: instr.split_asm (*‹?P (case ?instr of Load x ⇒ ?f1.0 x | Store x ⇒ ?f2.0 x | Push x ⇒ ?f3.0 x | New x ⇒ ?f4.0 x | NewArray x ⇒ ?f5.0 x | ALoad ⇒ ?f6.0 | AStore ⇒ ?f7.0 | ALength ⇒ ?f8.0 | Getfield x xa ⇒ ?f9.0 x xa | Putfield x xa ⇒ ?f10.0 x xa | CAS x xa ⇒ ?f11.0 x xa | Checkcast x ⇒ ?f12.0 x | Instanceof x ⇒ ?f13.0 x | Invoke x xa ⇒ ?f14.0 x xa | Return ⇒ ?f15.0 | Pop ⇒ ?f16.0 | Dup ⇒ ?f17.0 | Swap ⇒ ?f18.0 | BinOpInstr x ⇒ ?f19.0 x | Goto x ⇒ ?f20.0 x | IfFalse x ⇒ ?f21.0 x | ThrowExc ⇒ ?f22.0 | MEnter ⇒ ?f23.0 | MExit ⇒ ?f24.0) = (¬ ((∃x1. ?instr = Load x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?instr = Store x2 ∧ ¬ ?P (?f2.0 x2)) ∨ (∃x3. ?instr = Push x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x4. ?instr = New x4 ∧ ¬ ?P (?f4.0 x4)) ∨ (∃x5. ?instr = NewArray x5 ∧ ¬ ?P (?f5.0 x5)) ∨ ?instr = ALoad ∧ ¬ ?P ?f6.0 ∨ ?instr = AStore ∧ ¬ ?P ?f7.0 ∨ ?instr = ALength ∧ ¬ ?P ?f8.0 ∨ (∃x91 x92. ?instr = Getfield x91 x92 ∧ ¬ ?P (?f9.0 x91 x92)) ∨ (∃x101 x102. ?instr = Putfield x101 x102 ∧ ¬ ?P (?f10.0 x101 x102)) ∨ (∃x111 x112. ?instr = CAS x111 x112 ∧ ¬ ?P (?f11.0 x111 x112)) ∨ (∃x12. ?instr = Checkcast x12 ∧ ¬ ?P (?f12.0 x12)) ∨ (∃x13. ?instr = Instanceof x13 ∧ ¬ ?P (?f13.0 x13)) ∨ (∃x141 x142. ?instr = Invoke x141 x142 ∧ ¬ ?P (?f14.0 x141 x142)) ∨ ?instr = Return ∧ ¬ ?P ?f15.0 ∨ ?instr = Pop ∧ ¬ ?P ?f16.0 ∨ ?instr = Dup ∧ ¬ ?P ?f17.0 ∨ ?instr = Swap ∧ ¬ ?P ?f18.0 ∨ (∃x19. ?instr = BinOpInstr x19 ∧ ¬ ?P (?f19.0 x19)) ∨ (∃x20. ?instr = Goto x20 ∧ ¬ ?P (?f20.0 x20)) ∨ (∃x21. ?instr = IfFalse x21 ∧ ¬ ?P (?f21.0 x21)) ∨ ?instr = ThrowExc ∧ ¬ ?P ?f22.0 ∨ ?instr = MEnter ∧ ¬ ?P ?f23.0 ∨ ?instr = MExit ∧ ¬ ?P ?f24.0))›*)) (*discuss goal 2*) apply (fastforce simp add: nth_Cons' (*‹(?x # ?xs) ! ?n = (if ?n = 0 then ?x else ?xs ! (?n - 1))›*) gr0_conv_Suc (*‹(0 < ?n) = (∃m. ?n = Suc m)›*) split: instr.split_asm (*‹?P (case ?instr of Load x ⇒ ?f1.0 x | Store x ⇒ ?f2.0 x | Push x ⇒ ?f3.0 x | New x ⇒ ?f4.0 x | NewArray x ⇒ ?f5.0 x | ALoad ⇒ ?f6.0 | AStore ⇒ ?f7.0 | ALength ⇒ ?f8.0 | Getfield x xa ⇒ ?f9.0 x xa | Putfield x xa ⇒ ?f10.0 x xa | CAS x xa ⇒ ?f11.0 x xa | Checkcast x ⇒ ?f12.0 x | Instanceof x ⇒ ?f13.0 x | Invoke x xa ⇒ ?f14.0 x xa | Return ⇒ ?f15.0 | Pop ⇒ ?f16.0 | Dup ⇒ ?f17.0 | Swap ⇒ ?f18.0 | BinOpInstr x ⇒ ?f19.0 x | Goto x ⇒ ?f20.0 x | IfFalse x ⇒ ?f21.0 x | ThrowExc ⇒ ?f22.0 | MEnter ⇒ ?f23.0 | MExit ⇒ ?f24.0) = (¬ ((∃x1. ?instr = Load x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?instr = Store x2 ∧ ¬ ?P (?f2.0 x2)) ∨ (∃x3. ?instr = Push x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x4. ?instr = New x4 ∧ ¬ ?P (?f4.0 x4)) ∨ (∃x5. ?instr = NewArray x5 ∧ ¬ ?P (?f5.0 x5)) ∨ ?instr = ALoad ∧ ¬ ?P ?f6.0 ∨ ?instr = AStore ∧ ¬ ?P ?f7.0 ∨ ?instr = ALength ∧ ¬ ?P ?f8.0 ∨ (∃x91 x92. ?instr = Getfield x91 x92 ∧ ¬ ?P (?f9.0 x91 x92)) ∨ (∃x101 x102. ?instr = Putfield x101 x102 ∧ ¬ ?P (?f10.0 x101 x102)) ∨ (∃x111 x112. ?instr = CAS x111 x112 ∧ ¬ ?P (?f11.0 x111 x112)) ∨ (∃x12. ?instr = Checkcast x12 ∧ ¬ ?P (?f12.0 x12)) ∨ (∃x13. ?instr = Instanceof x13 ∧ ¬ ?P (?f13.0 x13)) ∨ (∃x141 x142. ?instr = Invoke x141 x142 ∧ ¬ ?P (?f14.0 x141 x142)) ∨ ?instr = Return ∧ ¬ ?P ?f15.0 ∨ ?instr = Pop ∧ ¬ ?P ?f16.0 ∨ ?instr = Dup ∧ ¬ ?P ?f17.0 ∨ ?instr = Swap ∧ ¬ ?P ?f18.0 ∨ (∃x19. ?instr = BinOpInstr x19 ∧ ¬ ?P (?f19.0 x19)) ∨ (∃x20. ?instr = Goto x20 ∧ ¬ ?P (?f20.0 x20)) ∨ (∃x21. ?instr = IfFalse x21 ∧ ¬ ?P (?f21.0 x21)) ∨ ?instr = ThrowExc ∧ ¬ ?P ?f22.0 ∨ ?instr = MEnter ∧ ¬ ?P ?f23.0 ∨ ?instr = MExit ∧ ¬ ?P ?f24.0))›*)) (*proven 2 subgoals*) . context JVM_heap_base begin lemma check_instr_pc: "⟦ check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc' ⟧ ⟹ check_instr ins P h stk loc C M pc' frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Load x1⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 2. ‹⋀x2. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Store x2⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 3. ‹⋀x3. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Push x3⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 4. ‹⋀x4. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = New x4⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 5. ‹⋀x5. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = NewArray x5⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 6. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = ALoad⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 7. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = AStore⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 8. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = ALength⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 9. ‹⋀x91 x92. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Getfield x91 x92⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 10. ‹⋀x101 x102. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Putfield x101 x102⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 11. ‹⋀x111 x112. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = CAS x111 x112⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 12. ‹⋀x12. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Checkcast x12⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 13. ‹⋀x13. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Instanceof x13⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 14. ‹⋀x141 x142. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Invoke x141 x142⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 15. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Return⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 16. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Pop⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 17. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Dup⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 18. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Swap⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 19. ‹⋀x19. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = BinOpInstr x19⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 20. ‹⋀x20. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = Goto x20⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 21. ‹⋀x21. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = IfFalse x21⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 22. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = ThrowExc⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 23. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = MEnter⟧ ⟹ check_instr ins P h stk loc C M pc' frs› 24. ‹⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ins = MExit⟧ ⟹ check_instr ins P h stk loc C M pc' frs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*discuss goal 15*) apply ((auto)[1]) (*discuss goal 16*) apply ((auto)[1]) (*discuss goal 17*) apply ((auto)[1]) (*discuss goal 18*) apply ((auto)[1]) (*discuss goal 19*) apply ((auto)[1]) (*discuss goal 20*) apply ((auto)[1]) (*discuss goal 21*) apply ((auto)[1]) (*discuss goal 22*) apply ((auto)[1]) (*discuss goal 23*) apply ((auto)[1]) (*discuss goal 24*) apply ((auto)[1]) (*proven 24 subgoals*) . lemma wf_ci_check_instr [iff]: "wf_ci check_instr" apply (rule wf_ciI (*‹⟦ci_stk_offer ?ci; ⋀ins P h stk loc C M pc frs. ?ci ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs; ⋀ins P h stk loc C M pc pc' frs. ⟦?ci ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ ?ci ins P h stk loc C M pc' frs⟧ ⟹ wf_ci ?ci›*)) (*goals: 1. ‹ci_stk_offer check_instr› 2. ‹⋀ins P h stk loc C M pc frs. check_instr ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs› 3. ‹⋀ins P h stk loc C M pc pc' frs. ⟦check_instr ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ check_instr ins P h stk loc C M pc' frs› discuss goal 1*) apply (rule check_instr_stk_offer (*‹ci_stk_offer check_instr›*)) (*discuss goal 2*) apply (erule check_instr_imp_check_instr' (*‹check_instr ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs›*)) (*discuss goal 3*) apply (erule (1) check_instr_pc (*‹⟦check_instr (?ins::'addr::addr instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?h::'heap::type) (?stk::'addr::addr val list) (?loc::'addr::addr val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::'addr::addr frame list); ins_jump_ok ?ins (?pc'::nat)⟧ ⟹ check_instr ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*)) (*proven 3 subgoals*) . end lemma wf_ciD1: "wf_ci ci ⟹ ci_stk_offer ci" unfolding wf_ci_def (*goal: ‹ci_stk_offer ci ∧ ci ≤ check_instr' ∧ (∀ins P h stk loc C M pc pc' frs. ci ins P h stk loc C M pc frs ⟶ ins_jump_ok ins pc' ⟶ ci ins P h stk loc C M pc' frs) ⟹ ci_stk_offer ci›*) by blast lemma wf_ciD2: "⟦ wf_ci ci; ci ins P h stk loc C M pc frs ⟧ ⟹ check_instr' ins P h stk loc C M pc frs" unfolding wf_ci_def le_fun_def le_bool_def (*goal: ‹⟦ci_stk_offer (ci::'a instr ⇒ (nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ 'b ⇒ 'a val list ⇒ 'a val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ 'a frame list ⇒ bool) ∧ (∀(x::'a instr) (xa::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (xb::'b) (xc::'a val list) (xd::'a val list) (xe::String.literal) (xf::String.literal) (xg::nat) xh::'a frame list. ci x xa xb xc xd xe xf xg xh ⟶ check_instr' x xa xb xc xd xe xf xg xh) ∧ (∀(ins::'a instr) (P::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'b) (stk::'a val list) (loc::'a val list) (C::String.literal) (M::String.literal) (pc::nat) (pc'::nat) frs::'a frame list. ci ins P h stk loc C M pc frs ⟶ ins_jump_ok ins pc' ⟶ ci ins P h stk loc C M pc' frs); ci (ins::'a instr) (P::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'b) (stk::'a val list) (loc::'a val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'a frame list)⟧ ⟹ check_instr' ins P h stk loc C M pc frs›*) by blast lemma wf_ciD3: "⟦ wf_ci ci; ci ins P h stk loc C M pc frs; ins_jump_ok ins pc' ⟧ ⟹ ci ins P h stk loc C M pc' frs" unfolding wf_ci_def (*goal: ‹⟦ci_stk_offer ci ∧ ci ≤ check_instr' ∧ (∀ins P h stk loc C M pc pc' frs. ci ins P h stk loc C M pc frs ⟶ ins_jump_ok ins pc' ⟶ ci ins P h stk loc C M pc' frs); ci ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ ci ins P h stk loc C M pc' frs›*) by blast lemma check_instr'_ins_jump_ok: "check_instr' ins P h stk loc C M pc frs ⟹ ins_jump_ok ins pc" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr' ins P h stk loc C M pc frs; ins = Load x1⟧ ⟹ ins_jump_ok ins pc› 2. ‹⋀x2. ⟦check_instr' ins P h stk loc C M pc frs; ins = Store x2⟧ ⟹ ins_jump_ok ins pc› 3. ‹⋀x3. ⟦check_instr' ins P h stk loc C M pc frs; ins = Push x3⟧ ⟹ ins_jump_ok ins pc› 4. ‹⋀x4. ⟦check_instr' ins P h stk loc C M pc frs; ins = New x4⟧ ⟹ ins_jump_ok ins pc› 5. ‹⋀x5. ⟦check_instr' ins P h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ ins_jump_ok ins pc› 6. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = ALoad⟧ ⟹ ins_jump_ok ins pc› 7. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = AStore⟧ ⟹ ins_jump_ok ins pc› 8. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = ALength⟧ ⟹ ins_jump_ok ins pc› 9. ‹⋀x91 x92. ⟦check_instr' ins P h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ ins_jump_ok ins pc› 10. ‹⋀x101 x102. ⟦check_instr' ins P h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ ins_jump_ok ins pc› 11. ‹⋀x111 x112. ⟦check_instr' ins P h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ ins_jump_ok ins pc› 12. ‹⋀x12. ⟦check_instr' ins P h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ ins_jump_ok ins pc› 13. ‹⋀x13. ⟦check_instr' ins P h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ ins_jump_ok ins pc› 14. ‹⋀x141 x142. ⟦check_instr' ins P h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ ins_jump_ok ins pc› 15. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Return⟧ ⟹ ins_jump_ok ins pc› 16. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Pop⟧ ⟹ ins_jump_ok ins pc› 17. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Dup⟧ ⟹ ins_jump_ok ins pc› 18. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = Swap⟧ ⟹ ins_jump_ok ins pc› 19. ‹⋀x19. ⟦check_instr' ins P h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ ins_jump_ok ins pc› 20. ‹⋀x20. ⟦check_instr' ins P h stk loc C M pc frs; ins = Goto x20⟧ ⟹ ins_jump_ok ins pc› 21. ‹⋀x21. ⟦check_instr' ins P h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ ins_jump_ok ins pc› 22. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ ins_jump_ok ins pc› 23. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = MEnter⟧ ⟹ ins_jump_ok ins pc› 24. ‹⟦check_instr' ins P h stk loc C M pc frs; ins = MExit⟧ ⟹ ins_jump_ok ins pc› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*discuss goal 15*) apply ((auto)[1]) (*discuss goal 16*) apply ((auto)[1]) (*discuss goal 17*) apply ((auto)[1]) (*discuss goal 18*) apply ((auto)[1]) (*discuss goal 19*) apply ((auto)[1]) (*discuss goal 20*) apply ((auto)[1]) (*discuss goal 21*) apply ((auto)[1]) (*discuss goal 22*) apply ((auto)[1]) (*discuss goal 23*) apply ((auto)[1]) (*discuss goal 24*) apply ((auto)[1]) (*proven 24 subgoals*) . lemma wf_ci_ins_jump_ok: assumes wf: "wf_ci ci" and ci: "ci ins P h stk loc C M pc frs" and pc': "pc ≤ pc'" shows "ins_jump_ok ins pc'" proof (-) (*goal: ‹ins_jump_ok (ins::'a instr) (pc'::nat)›*) from wf (*‹wf_ci (ci::'a::type instr ⇒ (nat × nat × 'a::type instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ 'b::type ⇒ 'a::type val list ⇒ 'a::type val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ 'a::type frame list ⇒ bool)›*) ci (*‹ci ins P h stk loc C M pc frs›*) have "check_instr' ins P h stk loc C M pc frs" by (rule wf_ciD2 (*‹⟦wf_ci ?ci; ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs⟧ ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs›*)) with pc' (*‹pc ≤ pc'›*) have "check_instr' ins P h stk loc C M pc' frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Load x1⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 2. ‹⋀x2. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Store x2⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 3. ‹⋀x3. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Push x3⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 4. ‹⋀x4. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = New x4⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 5. ‹⋀x5. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 6. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = ALoad⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 7. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = AStore⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 8. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = ALength⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 9. ‹⋀x91 x92. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 10. ‹⋀x101 x102. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 11. ‹⋀x111 x112. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 12. ‹⋀x12. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 13. ‹⋀x13. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 14. ‹⋀x141 x142. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 15. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Return⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 16. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Pop⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 17. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Dup⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 18. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Swap⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 19. ‹⋀x19. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 20. ‹⋀x20. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = Goto x20⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 21. ‹⋀x21. ⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 22. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 23. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = MEnter⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› 24. ‹⟦pc ≤ pc'; check_instr' ins P h stk loc C M pc frs; ins = MExit⟧ ⟹ check_instr' ins P h stk loc C M pc' frs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*discuss goal 14*) apply ((auto)[1]) (*discuss goal 15*) apply ((auto)[1]) (*discuss goal 16*) apply ((auto)[1]) (*discuss goal 17*) apply ((auto)[1]) (*discuss goal 18*) apply ((auto)[1]) (*discuss goal 19*) apply ((auto)[1]) (*discuss goal 20*) apply ((auto)[1]) (*discuss goal 21*) apply ((auto)[1]) (*discuss goal 22*) apply ((auto)[1]) (*discuss goal 23*) apply ((auto)[1]) (*discuss goal 24*) apply ((auto)[1]) (*proven 24 subgoals*) . thus "?thesis" (*goal: ‹ins_jump_ok ins pc'›*) by (rule check_instr'_ins_jump_ok (*‹check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ ins_jump_ok ?ins ?pc›*)) qed lemma wf_ciD3': "⟦ wf_ci ci; ci ins P h stk loc C M pc frs; pc ≤ pc' ⟧ ⟹ ci ins P h stk loc C M pc' frs" apply (frule (2) wf_ci_ins_jump_ok (*‹⟦wf_ci ?ci; ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs; ?pc ≤ ?pc'⟧ ⟹ ins_jump_ok ?ins ?pc'›*)) (*goal: ‹⟦wf_ci ci; ci ins P h stk loc C M pc frs; pc ≤ pc'⟧ ⟹ ci ins P h stk loc C M pc' frs›*) by (erule (2) wf_ciD3 (*‹⟦wf_ci (?ci::?'a instr ⇒ (nat × nat × ?'a instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ ?'b ⇒ ?'a val list ⇒ ?'a val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ ?'a frame list ⇒ bool); ?ci (?ins::?'a instr) (?P::(nat × nat × ?'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?h::?'b) (?stk::?'a val list) (?loc::?'a val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::?'a frame list); ins_jump_ok ?ins (?pc'::nat)⟧ ⟹ ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*)) typedef ('addr, 'heap) check_instr = "Collect wf_ci :: ('addr, 'heap) check_instr' set" morphisms ci_app Abs_check_instr by auto lemma ci_app_check_instr' [simp]: "ci_app (Abs_check_instr check_instr') = check_instr'" by (simp add: Abs_check_instr_inverse (*‹?y ∈ Collect wf_ci ⟹ ci_app (Abs_check_instr ?y) = ?y›*)) lemma (in JVM_heap_base) ci_app_check_instr [simp]: "ci_app (Abs_check_instr check_instr) = check_instr" by (simp add: Abs_check_instr_inverse (*‹?y ∈ Collect wf_ci ⟹ ci_app (Abs_check_instr ?y) = ?y›*)) lemma wf_ci_stk_offerD: "ci_app ci ins P h stk loc C M pc frs ⟹ ci_app ci ins P h (stk @ stk') loc C M pc frs" apply(rule ci_stk_offerD[OF wf_ciD1]) back by(rule ci_app [simplified]) lemma wf_ciD2_ci_app: "ci_app ci ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs" apply (cases ci) (*goal: ‹ci_app ci ins P h stk loc C M pc frs ⟹ check_instr' ins P h stk loc C M pc frs›*) apply (simp add: Abs_check_instr_inverse (*‹?y ∈ Collect wf_ci ⟹ ci_app (Abs_check_instr ?y) = ?y›*)) (*goal: ‹⋀y::'a instr ⇒ (nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ 'b ⇒ 'a val list ⇒ 'a val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ 'a frame list ⇒ bool. ⟦ci_app (ci::('a, 'b) check_instr) (ins::'a instr) (P::(nat × nat × 'a instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'b) (stk::'a val list) (loc::'a val list) (C::String.literal) (M::String.literal) (pc::nat) (frs::'a frame list); ci = Abs_check_instr y; y ∈ Collect wf_ci⟧ ⟹ check_instr' ins P h stk loc C M pc frs›*) by (erule (1) wf_ciD2 (*‹⟦wf_ci ?ci; ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs⟧ ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs›*)) lemma wf_ciD3_ci_app: "⟦ ci_app ci ins P h stk loc C M pc frs; ins_jump_ok ins pc' ⟧ ⟹ ci_app ci ins P h stk loc C M pc' frs" apply (cases ci) (*goal: ‹⟦ci_app ci ins P h stk loc C M pc frs; ins_jump_ok ins pc'⟧ ⟹ ci_app ci ins P h stk loc C M pc' frs›*) apply (simp add: Abs_check_instr_inverse (*‹?y ∈ Collect wf_ci ⟹ ci_app (Abs_check_instr ?y) = ?y›*)) (*goal: ‹⋀y. ⟦ci_app ci ins P h stk loc C M pc frs; ins_jump_ok ins pc'; ci = Abs_check_instr y; y ∈ Collect wf_ci⟧ ⟹ ci_app ci ins P h stk loc C M pc' frs›*) by (erule (2) wf_ciD3 (*‹⟦wf_ci ?ci; ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs; ins_jump_ok ?ins ?pc'⟧ ⟹ ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*)) lemma wf_ciD3'_ci_app: "⟦ ci_app ci ins P h stk loc C M pc frs; pc ≤ pc' ⟧ ⟹ ci_app ci ins P h stk loc C M pc' frs" apply (cases ci) (*goal: ‹⟦ci_app ci ins P h stk loc C M pc frs; pc ≤ pc'⟧ ⟹ ci_app ci ins P h stk loc C M pc' frs›*) apply (simp add: Abs_check_instr_inverse (*‹?y ∈ Collect wf_ci ⟹ ci_app (Abs_check_instr ?y) = ?y›*)) (*goal: ‹⋀y. ⟦ci_app ci ins P h stk loc C M pc frs; pc ≤ pc'; ci = Abs_check_instr y; y ∈ Collect wf_ci⟧ ⟹ ci_app ci ins P h stk loc C M pc' frs›*) by (erule (2) wf_ciD3' (*‹⟦wf_ci (?ci::?'a::type instr ⇒ (nat × nat × ?'a::type instr list × (nat × nat × String.literal option × nat × nat) list) prog ⇒ ?'b::type ⇒ ?'a::type val list ⇒ ?'a::type val list ⇒ String.literal ⇒ String.literal ⇒ nat ⇒ ?'a::type frame list ⇒ bool); ?ci (?ins::?'a::type instr) (?P::(nat × nat × ?'a::type instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?h::?'b::type) (?stk::?'a::type val list) (?loc::?'a::type val list) (?C::String.literal) (?M::String.literal) (?pc::nat) (?frs::?'a::type frame list); ?pc ≤ (?pc'::nat)⟧ ⟹ ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*)) context JVM_heap_base begin inductive exec_meth :: "('addr, 'heap) check_instr ⇒ 'addr jvm_prog ⇒ 'addr instr list ⇒ ex_table ⇒ 'thread_id ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr, 'thread_id, 'heap) jvm_thread_action ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" for ci :: "('addr, 'heap) check_instr" and P :: "'addr jvm_prog" and ins :: "'addr instr list" and xt :: "ex_table" and t :: 'thread_id where exec_instr: "⟦ (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc [] ⟧ ⟹ exec_meth ci P ins xt t h (stk, loc, pc, None) ta h' (stk', loc', pc', xcp)" | exec_catch: "⟦ match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋; d ≤ length stk ⟧ ⟹ exec_meth ci P ins xt t h (stk, loc, pc, ⌊xcp⌋) ε h (Addr xcp # drop (size stk - d) stk, loc, pc', None)" lemma exec_meth_instr: "exec_meth ci P ins xt t h (stk, loc, pc, None) ta h' (stk', loc', pc', xcp) ⟷ (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc [] ∧ pc < length ins ∧ ci_app ci (ins ! pc) P h stk loc undefined undefined pc []" by (auto elim: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) intro: exec_instr (*‹⟦(?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc []; ?pc < length ?ins; ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)›*)) lemma exec_meth_xcpt: "exec_meth ci P ins xt t h (stk, loc, pc, ⌊xcp⌋) ta h (stk', loc', pc', xcp') ⟷ (∃d. match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋ ∧ ta = ε ∧ stk' = (Addr xcp # drop (size stk - d) stk) ∧ loc' = loc ∧ xcp' = None ∧ d ≤ length stk)" by (auto elim: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) intro: exec_catch (*‹⟦match_ex_table ?P (cname_of ?h ?xcp) ?pc ?xt = ⌊(?pc', ?d)⌋; ?d ≤ length ?stk⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*)) abbreviation exec_meth_a where "exec_meth_a ≡ exec_meth (Abs_check_instr check_instr')" abbreviation exec_meth_d where "exec_meth_d ≡ exec_meth (Abs_check_instr check_instr)" lemma exec_meth_length_compE2D [dest]: "exec_meth ci P (compE2 e) (compxE2 e 0 d) t h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length (compE2 e)" apply (erule exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀taa xcpa h'a stk' loc' pc' pca ha stka loca. ⟦h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, None); ta = taa; h' = h'a; s' = (stk', loc', pc', xcpa); (taa, xcpa, h'a, [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (compE2 e ! pca) P t ha stka loca undefined undefined pca []; pca < length (compE2 e); ci_app ci (compE2 e ! pca) P ha stka loca undefined undefined pca []⟧ ⟹ pc < length (compE2 e)› 2. ‹⋀ha xcpa pca pc' da stka loca. ⟦h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, ⌊xcpa⌋); ta = ⦃⦄; h' = ha; s' = (Addr xcpa # drop (length stka - da) stka, loca, pc', None); match_ex_table P (cname_of ha xcpa) pca (compxE2 e 0 d) = ⌊(pc', da)⌋; da ≤ length stka⟧ ⟹ pc < length (compE2 e)› discuss goal 1*) apply ((auto dest: match_ex_table_pc_length_compE2 (*‹match_ex_table ?P ?a ?pc (compxE2 ?e ?pc' ?d) = ⌊?pcd⌋ ⟹ ?pc' ≤ ?pc ∧ ?pc < length (compE2 ?e) + ?pc'›*))[1]) (*discuss goal 2*) apply ((auto dest: match_ex_table_pc_length_compE2 (*‹match_ex_table ?P ?a ?pc (compxE2 ?e ?pc' ?d) = ⌊?pcd⌋ ⟹ ?pc' ≤ ?pc ∧ ?pc < length (compE2 ?e) + ?pc'›*))[1]) (*proven 2 subgoals*) . lemma exec_meth_length_compEs2D [dest]: "exec_meth ci P (compEs2 es) (compxEs2 es 0 0) t h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length (compEs2 es)" apply (erule exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀taa xcpa h'a stk' loc' pc' pca ha stka loca. ⟦h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, None); ta = taa; h' = h'a; s' = (stk', loc', pc', xcpa); (taa, xcpa, h'a, [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (compEs2 es ! pca) P t ha stka loca undefined undefined pca []; pca < length (compEs2 es); ci_app ci (compEs2 es ! pca) P ha stka loca undefined undefined pca []⟧ ⟹ pc < length (compEs2 es)› 2. ‹⋀ha xcpa pca pc' d stka loca. ⟦h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, ⌊xcpa⌋); ta = ⦃⦄; h' = ha; s' = (Addr xcpa # drop (length stka - d) stka, loca, pc', None); match_ex_table P (cname_of ha xcpa) pca (compxEs2 es 0 0) = ⌊(pc', d)⌋; d ≤ length stka⟧ ⟹ pc < length (compEs2 es)› discuss goal 1*) apply ((auto dest: match_ex_table_pc_length_compEs2 (*‹match_ex_table ?P ?a ?pc (compxEs2 ?es ?pc' ?d) = ⌊?pcd⌋ ⟹ ?pc' ≤ ?pc ∧ ?pc < length (compEs2 ?es) + ?pc'›*))[1]) (*discuss goal 2*) apply ((auto dest: match_ex_table_pc_length_compEs2 (*‹match_ex_table ?P ?a ?pc (compxEs2 ?es ?pc' ?d) = ⌊?pcd⌋ ⟹ ?pc' ≤ ?pc ∧ ?pc < length (compEs2 ?es) + ?pc'›*))[1]) (*proven 2 subgoals*) . lemma exec_instr_stk_offer: assumes check: "check_instr' (ins ! pc) P h stk loc C M pc frs" and exec: "(ta', xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr (ins ! pc) P t h stk loc C M pc frs" shows "(ta', xcp', h', (stk' @ stk'', loc', C, M, pc') # frs) ∈ exec_instr (ins ! pc) P t h (stk @ stk'') loc C M pc frs" using assms proof(cases "ins ! pc") case (Invoke M n) thus ?thesis using exec check by(auto split: if_split_asm extCallRet.splits split del: if_split simp add: split_beta nth_append min_def extRet2JVM_def) qed(force simp add: nth_append is_Ref_def has_method_def nth_Cons split_beta hd_append tl_append neq_Nil_conv split: list.split if_split_asm nat.splits sum.split_asm)+ lemma exec_meth_stk_offer: assumes exec: "exec_meth ci P ins xt t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_meth ci P ins (stack_xlift (length stk'') xt) t h (stk @ stk'', loc, pc, xcp) ta h' (stk' @ stk'', loc', pc', xcp')" using exec (*‹exec_meth ci P ins xt t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) proof (cases) (*goals: 1. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ exec_meth ci P ins (stack_xlift (length stk'') xt) t h (stk @ stk'', loc, pc, xcp) ta h' (stk' @ stk'', loc', pc', xcp')› 2. ‹⋀xcpa d. ⟦xcp = ⌊xcpa⌋; ta = ⦃⦄; h' = h; stk' = Addr xcpa # drop (length stk - d) stk; loc' = loc; xcp' = None; match_ex_table P (cname_of h xcpa) pc xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ exec_meth ci P ins (stack_xlift (length stk'') xt) t h (stk @ stk'', loc, pc, xcp) ta h' (stk' @ stk'', loc', pc', xcp')›*) case (exec_catch xcp d) (*‹xcp = ⌊xcp⌋› ‹(ta::('addr, 'thread_id, 'heap) jvm_thread_action) = ⦃⦄› ‹h' = h› ‹stk' = Addr xcp # drop (length stk - d) stk› ‹(loc'::'addr::addr val list) = (loc::'addr::addr val list)› ‹xcp' = None› ‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋› ‹(d::nat) ≤ length (stk::'addr val list)›*) from ‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋› (*‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋›*) have "match_ex_table P (cname_of h xcp) pc (stack_xlift (length stk'') xt) = ⌊(pc', length stk'' + d)⌋" by (simp add: match_ex_table_stack_xlift (*‹match_ex_table ?P ?C ?pc ?xt = ⌊(?pc', ?d)⌋ ⟹ match_ex_table ?P ?C ?pc (stack_xlift ?n ?xt) = ⌊(?pc', ?n + ?d)⌋›*)) moreover have "length stk'' + d ≤ length (stk @ stk'')" using ‹d ≤ length stk› (*‹d ≤ length stk›*) by simp ultimately have "exec_meth ci P ins (stack_xlift (length stk'') xt) t h ((stk @ stk''), loc, pc, ⌊xcp⌋) ε h ((Addr xcp # drop (length (stk @ stk'') - (length stk'' + d)) (stk @ stk'')), loc, pc', None)" by (rule exec_meth.exec_catch (*‹⟦match_ex_table (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (cname_of (?h::'heap) (?xcp::'addr)) (?pc::nat) (?xt::(nat × nat × String.literal option × nat × nat) list) = ⌊(?pc'::nat, ?d::nat)⌋; ?d ≤ length (?stk::'addr val list)⟧ ⟹ exec_meth (?ci::('addr, 'heap) check_instr) ?P (?ins::'addr instr list) ?xt (?t::'thread_id) ?h (?stk, ?loc::'addr val list, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*)) with exec_catch (*‹xcp = ⌊xcp⌋› ‹ta = ⦃⦄› ‹h' = h› ‹stk' = Addr xcp # drop (length stk - d) stk› ‹loc' = loc› ‹xcp' = None› ‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋› ‹d ≤ length stk›*) show "?thesis" (*goal: ‹exec_meth ci P ins (stack_xlift (length stk'') xt) t h (stk @ stk'', loc, pc, xcp) ta h' (stk' @ stk'', loc', pc', xcp')›*) by simp next (*goal: ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ exec_meth ci P ins (stack_xlift (length stk'') xt) t h (stk @ stk'', loc, pc, xcp) ta h' (stk' @ stk'', loc', pc', xcp')›*) case exec_instr (*‹xcp = None› ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []› ‹pc < length ins› ‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) note ciins = ‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []› (*‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) hence "ci_app ci (ins ! pc) P h (stk @ stk'') loc undefined undefined pc []" by (rule wf_ci_stk_offerD (*‹ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ ci_app ?ci ?ins ?P ?h (?stk @ ?stk') ?loc ?C ?M ?pc ?frs›*)) moreover from ciins (*‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) have "check_instr' (ins ! pc) P h stk loc undefined undefined pc []" by (rule wf_ciD2_ci_app (*‹ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs›*)) hence "(ta, xcp', h', [(stk' @ stk'', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h (stk @ stk'') loc undefined undefined pc []" using ‹(ta, xcp', h', [(stk', loc', undefined,undefined , pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []› (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []›*) by (rule exec_instr_stk_offer (*‹⟦check_instr' (?ins ! ?pc) ?P ?h ?stk ?loc ?C ?M ?pc ?frs; (?ta', ?xcp', ?h', (?stk', ?loc', ?C, ?M, ?pc') # ?frs) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc ?C ?M ?pc ?frs⟧ ⟹ (?ta', ?xcp', ?h', (?stk' @ ?stk'', ?loc', ?C, ?M, ?pc') # ?frs) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h (?stk @ ?stk'') ?loc ?C ?M ?pc ?frs›*)) ultimately show "?thesis" (*goal: ‹exec_meth ci P ins (stack_xlift (length stk'') xt) t h (stk @ stk'', loc, pc, xcp) ta h' (stk' @ stk'', loc', pc', xcp')›*) using exec_instr (*‹xcp = None› ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []› ‹(pc::nat) < length (ins::'addr::addr instr list)› ‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) by (auto intro: exec_meth.exec_instr (*‹⟦(?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc []; ?pc < length ?ins; ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)›*)) qed lemma exec_meth_append_xt [intro]: "exec_meth ci P ins xt t h s ta h' s' ⟹ exec_meth ci P (ins @ ins') (xt @ xt') t h s ta h' s'" apply (erule exec_meth.cases (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?a1.0::'heap) (?a2.0::'addr val list × 'addr val list × nat × 'addr option) (?a3.0::('addr, 'thread_id, 'heap) jvm_thread_action) (?a4.0::'heap) (?a5.0::'addr val list × 'addr val list × nat × 'addr option); ⋀(ta::('addr, 'thread_id, 'heap) jvm_thread_action) (xcp::'addr option) (h'::'heap) (stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (pc::nat) (h::'heap) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa::bool; ⋀(h::'heap) (xcp::'addr) (pc::nat) (pc'::nat) (d::nat) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀taa xcp h'a stk' loc' pc' pc ha stk loc. ⟦h = ha; s = (stk, loc, pc, None); ta = taa; h' = h'a; s' = (stk', loc', pc', xcp); (taa, xcp, h'a, [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t ha stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P ha stk loc undefined undefined pc []⟧ ⟹ exec_meth ci P (ins @ ins') (xt @ xt') t h s ta h' s'› 2. ‹⋀ha xcp pc pc' d stk loc. ⟦h = ha; s = (stk, loc, pc, ⌊xcp⌋); ta = ⦃⦄; h' = ha; s' = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table P (cname_of ha xcp) pc xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ exec_meth ci P (ins @ ins') (xt @ xt') t h s ta h' s'› discuss goal 1*) apply ((auto)[1]) (*top goal: ‹⋀(taa::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (xcp::'addr::addr option) (h'a::'heap::type) (stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (pc::nat) (ha::'heap::type) (stk::'addr::addr val list) loc::'addr::addr val list. ⟦(h::'heap::type) = ha; (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) = (stk, loc, pc, None); (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) = taa; (h'::'heap::type) = h'a; (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) = (stk', loc', pc', xcp); (taa, xcp, h'a, [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins::'addr::addr instr list) ! pc) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) ha stk loc undefined undefined pc []; pc < length ins; ci_app (ci::('addr::addr, 'heap::type) check_instr) (ins ! pc) P ha stk loc undefined undefined pc []⟧ ⟹ exec_meth ci P (ins @ (ins'::'addr::addr instr list)) ((xt::(nat × nat × String.literal option × nat × nat) list) @ (xt'::(nat × nat × String.literal option × nat × nat) list)) t h s ta h' s'› and 1 goal remains*) apply (rule exec_instr (*‹⟦(?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc []; ?pc < length ?ins; ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)›*)) (*goals: 1. ‹⋀a aa ab ac ad b xcp stk' loc' pc' pc stk loc. ⟦s = (stk, loc, pc, None); ta = (a, aa, ab, ac, ad, b); s' = (stk', loc', pc', xcp); ((a, aa, ab, ac, ad, b), xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ ((a, aa, ab, ac, ad, b), xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []› 2. ‹⋀a aa ab ac ad b xcp stk' loc' pc' pc stk loc. ⟦s = (stk, loc, pc, None); ta = (a, aa, ab, ac, ad, b); s' = (stk', loc', pc', xcp); ((a, aa, ab, ac, ad, b), xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ pc < length (ins @ ins')› 3. ‹⋀a aa ab ac ad b xcp stk' loc' pc' pc stk loc. ⟦s = (stk, loc, pc, None); ta = (a, aa, ab, ac, ad, b); s' = (stk', loc', pc', xcp); ((a, aa, ab, ac, ad, b), xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []› discuss goal 1*) apply (clarsimp simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 2*) apply simp (*discuss goal 3*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*proven 3 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀ha xcp pc pc' d stk loc. ⟦h = ha; s = (stk, loc, pc, ⌊xcp⌋); ta = ⦃⦄; h' = ha; s' = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table P (cname_of ha xcp) pc xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ exec_meth ci P (ins @ ins') (xt @ xt') t h s ta h' s'›*) apply (rule exec_catch (*‹⟦match_ex_table ?P (cname_of ?h ?xcp) ?pc ?xt = ⌊(?pc', ?d)⌋; ?d ≤ length ?stk⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*)) (*goals: 1. ‹⋀xcp pc pc' d stk loc. ⟦s = (stk, loc, pc, ⌊xcp⌋); ta = ⦃⦄; h' = h; s' = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ match_ex_table P (cname_of h xcp) pc (xt @ xt') = ⌊(pc', d)⌋› 2. ‹⋀xcp pc pc' d stk loc. ⟦s = (stk, loc, pc, ⌊xcp⌋); ta = ⦃⦄; h' = h; s' = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ d ≤ length stk› discuss goal 1*) apply simp (*discuss goal 2*) . (*proven 2 subgoals*) (*proven 2 subgoals*) lemma exec_meth_append [intro]: "exec_meth ci P ins xt t h s ta h' s' ⟹ exec_meth ci P (ins @ ins') xt t h s ta h' s'" by (rule exec_meth_append_xt[where xt'="[]", simplified] (*‹exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_meth ?ci ?P (?ins @ (?ins'::'addr instr list)) ?xt ?t ?h ?s ?ta ?h' ?s'›*)) lemma append_exec_meth_xt: assumes exec: "exec_meth ci P ins xt t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" and jump: "jump_ok ins 0 n" and pcs: "pcs xt' ⊆ {0..<length ins'}" shows "exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, (length ins' + pc), xcp) ta h' (stk', loc', (length ins' + pc'), xcp')" using exec (*‹exec_meth ci P ins xt t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) proof (cases) (*goals: 1. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, length ins' + pc, xcp) ta h' (stk', loc', length ins' + pc', xcp')› 2. ‹⋀xcpa d. ⟦xcp = ⌊xcpa⌋; ta = ⦃⦄; h' = h; stk' = Addr xcpa # drop (length stk - d) stk; loc' = loc; xcp' = None; match_ex_table P (cname_of h xcpa) pc xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, length ins' + pc, xcp) ta h' (stk', loc', length ins' + pc', xcp')›*) case (exec_catch xcp d) (*‹xcp = ⌊xcp⌋› ‹ta = ⦃⦄› ‹h' = h› ‹stk' = Addr xcp # drop (length stk - d) stk› ‹loc' = loc› ‹xcp' = None› ‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋› ‹d ≤ length stk›*) from ‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋› (*‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋›*) have "match_ex_table P (cname_of h xcp) (length ins' + pc) (shift (length ins') xt) = ⌊(length ins' + pc', d)⌋" by (simp add: match_ex_table_shift (*‹match_ex_table ?P ?C ?pc ?xt = ⌊(?pc', ?d)⌋ ⟹ match_ex_table ?P ?C (?n + ?pc) (shift ?n ?xt) = ⌊(?n + ?pc', ?d)⌋›*)) moreover from pcs (*‹pcs xt' ⊆ {0..<length ins'}›*) have "length ins' + pc ∉ pcs xt'" by auto ultimately have "match_ex_table P (cname_of h xcp) (length ins' + pc) (xt' @ shift (length ins') xt) = ⌊(length ins' + pc', d)⌋" by (simp add: match_ex_table_append_not_pcs (*‹?pc ∉ pcs ?xt0.0 ⟹ match_ex_table ?P ?C ?pc (?xt0.0 @ ?xt1.0) = match_ex_table ?P ?C ?pc ?xt1.0›*)) with exec_catch (*‹xcp = ⌊xcp⌋› ‹(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) = ⦃⦄› ‹h' = h› ‹(stk'::'addr val list) = Addr (xcp::'addr) # drop (length (stk::'addr val list) - (d::nat)) stk› ‹loc' = loc› ‹xcp' = None› ‹match_ex_table P (cname_of h xcp) pc xt = ⌊(pc', d)⌋› ‹d ≤ length stk›*) show "?thesis" (*goal: ‹exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, length ins' + pc, xcp) ta h' (stk', loc', length ins' + pc', xcp')›*) by (auto dest: exec_meth.exec_catch (*‹⟦match_ex_table ?P (cname_of ?h ?xcp) ?pc ?xt = ⌊(?pc', ?d)⌋; ?d ≤ length ?stk⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*)) next (*goal: ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; pc < length ins; ci_app ci (ins ! pc) P h stk loc undefined undefined pc []⟧ ⟹ exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, length ins' + pc, xcp) ta h' (stk', loc', length ins' + pc', xcp')›*) case exec_instr (*‹(xcp::'addr::addr option) = None› ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []› ‹pc < length ins› ‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) note exec = ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []› (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []›*) hence "(ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []" proof (cases "ins ! pc") (*goals: 1. ‹⋀x1. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Load x1⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 2. ‹⋀x2. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Store x2⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 3. ‹⋀x3. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Push x3⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 4. ‹⋀x4. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = New x4⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 5. ‹⋀x5. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = NewArray x5⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 6. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ALoad⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 7. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = AStore⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 8. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ALength⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 9. ‹⋀x91 x92. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Getfield x91 x92⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 10. ‹⋀x101 x102. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Putfield x101 x102⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 11. ‹⋀x111 x112. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = CAS x111 x112⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 12. ‹⋀x12. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Checkcast x12⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 13. ‹⋀x13. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Instanceof x13⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 14. ‹⋀x141 x142. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Invoke x141 x142⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 15. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Return⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 16. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Pop⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 17. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Dup⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 18. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Swap⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 19. ‹⋀x19. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = BinOpInstr x19⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 20. ‹⋀x20. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Goto x20⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 21. ‹⋀x21. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = IfFalse x21⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 22. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ThrowExc⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 23. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = MEnter⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 24. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = MExit⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) case (Goto i) (*‹(ins::'addr instr list) ! (pc::nat) = Goto (i::int)›*) with jump (*‹jump_ok ins 0 n›*) ‹pc < length ins› (*‹pc < length ins›*) have "- int pc ≤ i" "i < int (length ins - pc + n)" apply - (*goals: 1. ‹⟦jump_ok ins 0 n; pc < length ins; ins ! pc = Goto i⟧ ⟹ - int pc ≤ i› 2. ‹⟦jump_ok ins 0 n; pc < length ins; ins ! pc = Goto i⟧ ⟹ i < int (length ins - pc + n)› discuss goal 1*) apply ((auto dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*))[1]) (*discuss goal 2*) apply ((auto dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*))[1]) (*proven 2 subgoals*) . with exec (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []›*) Goto (*‹ins ! pc = Goto i›*) show "?thesis" (*goal: ‹(ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) by auto next (*goals: 1. ‹⋀x1::nat. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Load x1⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 2. ‹⋀x2::nat. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Store x2⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 3. ‹⋀x3::'addr::addr val. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Push x3⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 4. ‹⋀x4::String.literal. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = New x4⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 5. ‹⋀x5::ty. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = NewArray x5⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 6. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = ALoad⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 7. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = AStore⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 8. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = ALength⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 9. ‹⋀(x91::String.literal) x92::String.literal. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Getfield x91 x92⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 10. ‹⋀(x101::String.literal) x102::String.literal. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Putfield x101 x102⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 11. ‹⋀(x111::String.literal) x112::String.literal. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = CAS x111 x112⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 12. ‹⋀x12::ty. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Checkcast x12⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 13. ‹⋀x13::ty. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Instanceof x13⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 14. ‹⋀(x141::String.literal) x142::nat. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Invoke x141 x142⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 15. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Return⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 16. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Pop⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 17. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Dup⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 18. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = Swap⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 19. ‹⋀x19::bop. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = BinOpInstr x19⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 20. ‹⋀x21::int. ⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = IfFalse x21⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 21. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = ThrowExc⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 22. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = MEnter⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 23. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; ins ! pc = MExit⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length (ins'::'addr::addr instr list) + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) case (IfFalse i) (*‹ins ! pc = IfFalse i›*) with jump (*‹jump_ok ins 0 n›*) ‹pc < length ins› (*‹pc < length ins›*) have "- int pc ≤ i" "i < int (length ins - pc + n)" apply - (*goals: 1. ‹⟦jump_ok (ins::'addr::addr instr list) (0::nat) (n::nat); (pc::nat) < length ins; ins ! pc = IfFalse (i::int)⟧ ⟹ - int pc ≤ i› 2. ‹⟦jump_ok (ins::'addr::addr instr list) (0::nat) (n::nat); (pc::nat) < length ins; ins ! pc = IfFalse (i::int)⟧ ⟹ i < int (length ins - pc + n)› discuss goal 1*) apply ((auto dest: jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*))[1]) (*discuss goal 2*) apply ((auto dest: jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*))[1]) (*proven 2 subgoals*) . with exec (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []›*) IfFalse (*‹ins ! pc = IfFalse i›*) show "?thesis" (*goal: ‹(ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) by auto next (*goals: 1. ‹⋀x1. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Load x1⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 2. ‹⋀x2. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Store x2⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 3. ‹⋀x3. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Push x3⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 4. ‹⋀x4. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = New x4⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 5. ‹⋀x5. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = NewArray x5⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 6. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ALoad⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 7. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = AStore⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 8. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ALength⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 9. ‹⋀x91 x92. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Getfield x91 x92⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 10. ‹⋀x101 x102. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Putfield x101 x102⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 11. ‹⋀x111 x112. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = CAS x111 x112⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 12. ‹⋀x12. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Checkcast x12⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 13. ‹⋀x13. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Instanceof x13⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 14. ‹⋀x141 x142. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Invoke x141 x142⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 15. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Return⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 16. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Pop⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 17. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Dup⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 18. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Swap⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 19. ‹⋀x19. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = BinOpInstr x19⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 20. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ThrowExc⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 21. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = MEnter⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 22. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = MExit⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) case (Invoke M n) (*‹ins ! pc = Invoke M n›*) with exec (*‹(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []›*) show "?thesis" (*goal: ‹(ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) by (auto split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) extCallRet.splits (*‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = ((∀x1::?'addr val. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2::?'addr. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = (¬ ((∃x1::?'addr val. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'addr. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*) simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λ(uu::nat) (uua::?'heap) (uub::?'addr val list) (uuc::?'addr val list) (uud::String.literal) (uue::String.literal) (uuf::nat) (uug::?'addr frame list) uuh::?'addr extCallRet. rec_extCallRet (λ(v::?'addr val) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + (1::nat)) # frs)) (λ(a::?'addr) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λ(n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) qed (auto simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*solves the remaining goals: 1. ‹⋀x1. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Load x1⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 2. ‹⋀x2. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Store x2⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 3. ‹⋀x3. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Push x3⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 4. ‹⋀x4. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = New x4⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 5. ‹⋀x5. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = NewArray x5⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 6. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ALoad⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 7. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = AStore⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 8. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ALength⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 9. ‹⋀x91 x92. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Getfield x91 x92⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 10. ‹⋀x101 x102. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Putfield x101 x102⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 11. ‹⋀x111 x112. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = CAS x111 x112⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 12. ‹⋀x12. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Checkcast x12⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 13. ‹⋀x13. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Instanceof x13⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 14. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Return⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 15. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Pop⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 16. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Dup⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 17. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = Swap⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 18. ‹⋀x19. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = BinOpInstr x19⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 19. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = ThrowExc⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 20. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = MEnter⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []› 21. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []; ins ! pc = MExit⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined (length ins' + pc) []›*) moreover from ‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []› (*‹ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) have "ci_app ci (ins ! pc) P h stk loc undefined undefined (length ins' + pc) []" apply (rule wf_ciD3'_ci_app (*‹⟦ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs; ?pc ≤ ?pc'⟧ ⟹ ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*)) (*goal: ‹ci_app ci (ins ! pc) P h stk loc undefined undefined (length ins' + pc) []›*) by simp ultimately have "exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, (length ins' + pc), None) ta h' (stk', loc', (length ins' + pc'), xcp')" using ‹pc < length ins› (*‹pc < length ins›*) apply - (*goal: ‹exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, length ins' + pc, None) ta h' (stk', loc', length ins' + pc', xcp')›*) apply (rule exec_meth.exec_instr (*‹⟦(?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc []; ?pc < length ?ins; ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)›*)) (*goals: 1. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, length (ins'::'addr::addr instr list) + (pc'::nat))]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined (length ins' + pc) []; ci_app (ci::('addr::addr, 'heap::type) check_instr) (ins ! pc) P h stk loc undefined undefined (length ins' + pc) []; pc < length ins⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, length ins' + pc')]) ∈ exec_instr ((ins' @ ins) ! (length ins' + pc)) P t h stk loc undefined undefined (length ins' + pc) []› 2. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, length (ins'::'addr::addr instr list) + (pc'::nat))]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined (length ins' + pc) []; ci_app (ci::('addr::addr, 'heap::type) check_instr) (ins ! pc) P h stk loc undefined undefined (length ins' + pc) []; pc < length ins⟧ ⟹ length ins' + pc < length (ins' @ ins)› 3. ‹⟦(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, length (ins'::'addr::addr instr list) + (pc'::nat))]) ∈ exec_instr ((ins::'addr::addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined (length ins' + pc) []; ci_app (ci::('addr::addr, 'heap::type) check_instr) (ins ! pc) P h stk loc undefined undefined (length ins' + pc) []; pc < length ins⟧ ⟹ ci_app ci ((ins' @ ins) ! (length ins' + pc)) P h stk loc undefined undefined (length ins' + pc) []› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹exec_meth ci P (ins' @ ins) (xt' @ shift (length ins') xt) t h (stk, loc, length ins' + pc, xcp) ta h' (stk', loc', length ins' + pc', xcp')›*) using exec_instr (*‹xcp = None› ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pc) P t h stk loc undefined undefined pc []› ‹(pc::nat) < length (ins::'addr instr list)› ‹ci_app (ci::('addr, 'heap) check_instr) ((ins::'addr instr list) ! (pc::nat)) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined pc []›*) by auto qed lemma append_exec_meth: assumes exec: "exec_meth ci P ins xt t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" and jump: "jump_ok ins 0 n" shows "exec_meth ci P (ins' @ ins) (shift (length ins') xt) t h (stk, loc, (length ins' + pc), xcp) ta h' (stk', loc', (length ins' + pc'), xcp')" using assms (*‹exec_meth (ci::('addr, 'heap) check_instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (ins::'addr instr list) (xt::(nat × nat × String.literal option × nat × nat) list) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option)› ‹jump_ok ins 0 n›*) by (rule append_exec_meth_xt [where xt'="[]", simplified] (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) lemma exec_meth_take_xt': "⟦ exec_meth ci P (ins @ ins') (xt' @ xt) t h (stk, loc, pc, xcp) ta h' s'; pc < length ins; pc ∉ pcs xt ⟧ ⟹ exec_meth ci P ins xt' t h (stk, loc, pc, xcp) ta h' s'" apply (erule exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀taa xcpa h'a stk' loc' pc' pca ha stka loca. ⟦pc < length ins; pc ∉ pcs xt; h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, None); ta = taa; h' = h'a; s' = (stk', loc', pc', xcpa); (taa, xcpa, h'a, [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pca) P t ha stka loca undefined undefined pca []; pca < length (ins @ ins'); ci_app ci ((ins @ ins') ! pca) P ha stka loca undefined undefined pca []⟧ ⟹ exec_meth ci P ins xt' t h (stk, loc, pc, xcp) ta h' s'› 2. ‹⋀ha xcpa pca pc' d stka loca. ⟦pc < length ins; pc ∉ pcs xt; h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, ⌊xcpa⌋); ta = ⦃⦄; h' = ha; s' = (Addr xcpa # drop (length stka - d) stka, loca, pc', None); match_ex_table P (cname_of ha xcpa) pca (xt' @ xt) = ⌊(pc', d)⌋; d ≤ length stka⟧ ⟹ exec_meth ci P ins xt' t h (stk, loc, pc, xcp) ta h' s'› discuss goal 1*) apply ((auto intro: exec_meth.intros (*‹⟦(?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc []; ?pc < length ?ins; ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)› ‹⟦match_ex_table ?P (cname_of ?h ?xcp) ?pc ?xt = ⌊(?pc', ?d)⌋; ?d ≤ length ?stk⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*) simp add: match_ex_table_append (*‹match_ex_table ?P ?C ?pc (?xt @ ?xt') = (case match_ex_table ?P ?C ?pc ?xt of None ⇒ match_ex_table ?P ?C ?pc ?xt' | ⌊pcd⌋ ⇒ ⌊pcd⌋)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) dest: match_ex_table_pcsD (*‹match_ex_table ?P ?C ?pc ?xt = ⌊(?pc', ?D)⌋ ⟹ ?pc ∈ pcs ?xt›*))[1]) (*discuss goal 2*) apply ((auto intro: exec_meth.intros (*‹⟦(?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, ?xcp::'addr::addr option, ?h'::'heap::type, [(?stk'::'addr::addr val list, ?loc'::'addr::addr val list, undefined, undefined, ?pc'::nat)]) ∈ exec_instr ((?ins::'addr::addr instr list) ! (?pc::nat)) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list) (?loc::'addr::addr val list) undefined undefined ?pc []; ?pc < length ?ins; ci_app (?ci::('addr::addr, 'heap::type) check_instr) (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins (?xt::(nat × nat × String.literal option × nat × nat) list) ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)› ‹⟦match_ex_table (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (cname_of (?h::'heap::type) (?xcp::'addr::addr)) (?pc::nat) (?xt::(nat × nat × String.literal option × nat × nat) list) = ⌊(?pc'::nat, ?d::nat)⌋; ?d ≤ length (?stk::'addr::addr val list)⟧ ⟹ exec_meth (?ci::('addr::addr, 'heap::type) check_instr) ?P (?ins::'addr::addr instr list) ?xt (?t::'thread_id::type) ?h (?stk, ?loc::'addr::addr val list, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*) simp add: match_ex_table_append (*‹match_ex_table (?P::?'a::type prog) (?C::String.literal) (?pc::nat) ((?xt::(nat × nat × String.literal option × nat × nat) list) @ (?xt'::(nat × nat × String.literal option × nat × nat) list)) = (case match_ex_table ?P ?C ?pc ?xt of None ⇒ match_ex_table ?P ?C ?pc ?xt' | ⌊pcd::nat × nat⌋ ⇒ ⌊pcd⌋)›*) nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) dest: match_ex_table_pcsD (*‹match_ex_table (?P::?'a::type prog) (?C::String.literal) (?pc::nat) (?xt::(nat × nat × String.literal option × nat × nat) list) = ⌊(?pc'::nat, ?D::nat)⌋ ⟹ ?pc ∈ pcs ?xt›*))[1]) (*proven 2 subgoals*) . lemma exec_meth_take_xt: "⟦ exec_meth ci P (ins @ ins') (xt' @ shift (length ins) xt) t h (stk, loc, pc, xcp) ta h' s'; pc < length ins ⟧ ⟹ exec_meth ci P ins xt' t h (stk, loc, pc, xcp) ta h' s'" by (auto intro: exec_meth_take_xt' (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt' @ ?xt) ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins; ?pc ∉ pcs ?xt⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_meth_take: "⟦ exec_meth ci P (ins @ ins') xt t h (stk, loc, pc, xcp) ta h' s'; pc < length ins ⟧ ⟹ exec_meth ci P ins xt t h (stk, loc, pc, xcp) ta h' s'" by (auto intro: exec_meth_take_xt[where xt = "[]"] (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) []) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_meth_drop_xt: assumes exec: "exec_meth ci P (ins @ ins') (xt @ shift (length ins) xt') t h (stk, loc, (length ins + pc), xcp) ta h' (stk', loc', pc', xcp')" and xt: "pcs xt ⊆ {..<length ins}" and jump: "jump_ok ins' 0 n" shows "exec_meth ci P ins' xt' t h (stk, loc, pc, xcp) ta h' (stk', loc', (pc' - length ins), xcp')" using exec (*‹exec_meth (ci::('addr::addr, 'heap::type) check_instr) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((ins::'addr::addr instr list) @ (ins'::'addr::addr instr list)) ((xt::(nat × nat × String.literal option × nat × nat) list) @ shift (length ins) (xt'::(nat × nat × String.literal option × nat × nat) list)) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, length ins + (pc::nat), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option)›*) proof (cases rule: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; length ins + pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! (length ins + pc)) P h stk loc undefined undefined (length ins + pc) []⟧ ⟹ exec_meth ci P ins' xt' t h (stk, loc, pc, xcp) ta h' (stk', loc', pc' - length ins, xcp')› 2. ‹⋀xcpa d. ⟦xcp = ⌊xcpa⌋; ta = ⦃⦄; h' = h; stk' = Addr xcpa # drop (length stk - d) stk; loc' = loc; xcp' = None; match_ex_table P (cname_of h xcpa) (length ins + pc) (xt @ shift (length ins) xt') = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ exec_meth ci P ins' xt' t h (stk, loc, pc, xcp) ta h' (stk', loc', pc' - length ins, xcp')›*) case exec_instr (*‹xcp = None› ‹(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, [(stk'::'addr val list, loc'::'addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (length ins + (pc::nat))) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined (length ins + pc) []› ‹length ins + pc < length (ins @ ins')› ‹ci_app (ci::('addr, 'heap) check_instr) (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (length ins + (pc::nat))) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined (length ins + pc) []›*) let ?PC = "length ins + pc" note [simp] = ‹xcp = None› (*‹xcp = None›*) from ‹?PC < length (ins @ ins')› (*‹length ins + pc < length (ins @ ins')›*) have pc: "pc < length ins'" by simp moreover with ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! ?PC) P t h stk loc undefined undefined ?PC []› (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []›*) have "(ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []" apply (cases "ins' ! pc") (*goals: 1. ‹⋀x1. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Load x1⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 2. ‹⋀x2. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Store x2⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 3. ‹⋀x3. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Push x3⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 4. ‹⋀x4. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = New x4⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 5. ‹⋀x5. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = NewArray x5⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 6. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = ALoad⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 7. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = AStore⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 8. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = ALength⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 9. ‹⋀x91 x92. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Getfield x91 x92⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 10. ‹⋀x101 x102. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Putfield x101 x102⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 11. ‹⋀x111 x112. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = CAS x111 x112⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 12. ‹⋀x12. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Checkcast x12⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 13. ‹⋀x13. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Instanceof x13⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 14. ‹⋀x141 x142. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Invoke x141 x142⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 15. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Return⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 16. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Pop⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 17. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Dup⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 18. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Swap⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 19. ‹⋀x19. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = BinOpInstr x19⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 20. ‹⋀x20. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Goto x20⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 21. ‹⋀x21. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = IfFalse x21⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 22. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = ThrowExc⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 23. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = MEnter⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› 24. ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = MExit⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› discuss goal 1*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 2*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 3*) apply (simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 4*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x4::String.literal. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, [(stk'::'addr val list, loc'::'addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (length ins + (pc::nat))) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = New x4⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› and 20 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 5*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x5. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = NewArray x5⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› and 19 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 6*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = ALoad⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› and 18 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 7*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 8*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 9*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x91 x92. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Getfield x91 x92⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› and 15 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 10*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 11*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x111 x112. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = CAS x111 x112⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› and 13 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 12*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 13*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 14*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*top goal: ‹⋀x141 x142. ⟦(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! (length ins + pc)) P t h stk loc undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = Invoke x141 x142⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []› and 10 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 15*) apply (simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 16*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 17*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 18*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 19*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 20*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 21*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 22*) apply (simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 23*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*discuss goal 24*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) (*goal: ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, [(stk'::'addr val list, loc'::'addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (length ins + (pc::nat))) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined (length ins + pc) []; pc < length ins'; ins' ! pc = MExit⟧ ⟹ (ta, xcp', h', [(stk', loc', undefined, undefined, pc' - length ins)]) ∈ exec_instr (ins' ! pc) P t h stk loc undefined undefined pc []›*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*proven 24 subgoals*) . moreover from ‹ci_app ci ((ins @ ins') ! ?PC) P h stk loc undefined undefined ?PC []› (*‹ci_app ci ((ins @ ins') ! (length ins + pc)) P h stk loc undefined undefined (length ins + pc) []›*) jump (*‹jump_ok ins' 0 n›*) pc (*‹(pc::nat) < length (ins'::'addr::addr instr list)›*) have "ci_app ci (ins' ! pc) P h stk loc undefined undefined pc []" by (fastforce elim: wf_ciD3_ci_app (*‹⟦ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs; ins_jump_ok ?ins ?pc'⟧ ⟹ ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc' ?frs›*) dest: jump_ok_ins_jump_ok (*‹⟦jump_ok ?ins ?n ?n'; ?pc < length ?ins⟧ ⟹ ins_jump_ok (?ins ! ?pc) (?pc + ?n)›*)) ultimately show "?thesis" (*goal: ‹exec_meth ci P ins' xt' t h (stk, loc, pc, xcp) ta h' (stk', loc', pc' - length ins, xcp')›*) by (auto intro: exec_meth.intros (*‹⟦(?ta::('addr, 'thread_id, 'heap) jvm_thread_action, ?xcp::'addr option, ?h'::'heap, [(?stk'::'addr val list, ?loc'::'addr val list, undefined, undefined, ?pc'::nat)]) ∈ exec_instr ((?ins::'addr instr list) ! (?pc::nat)) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?h::'heap) (?stk::'addr val list) (?loc::'addr val list) undefined undefined ?pc []; ?pc < length ?ins; ci_app (?ci::('addr, 'heap) check_instr) (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins (?xt::(nat × nat × String.literal option × nat × nat) list) ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)› ‹⟦match_ex_table (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (cname_of (?h::'heap) (?xcp::'addr)) (?pc::nat) (?xt::(nat × nat × String.literal option × nat × nat) list) = ⌊(?pc'::nat, ?d::nat)⌋; ?d ≤ length (?stk::'addr val list)⟧ ⟹ exec_meth (?ci::('addr, 'heap) check_instr) ?P (?ins::'addr instr list) ?xt (?t::'thread_id) ?h (?stk, ?loc::'addr val list, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*)) next (*goal: ‹⋀xcpa d. ⟦xcp = ⌊xcpa⌋; ta = ⦃⦄; h' = h; stk' = Addr xcpa # drop (length stk - d) stk; loc' = loc; xcp' = None; match_ex_table P (cname_of h xcpa) (length ins + pc) (xt @ shift (length ins) xt') = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ exec_meth ci P ins' xt' t h (stk, loc, pc, xcp) ta h' (stk', loc', pc' - length ins, xcp')›*) case (exec_catch XCP D) (*‹xcp = ⌊XCP⌋› ‹ta = ⦃⦄› ‹h' = h› ‹stk' = Addr XCP # drop (length stk - D) stk› ‹loc' = loc› ‹xcp' = None› ‹match_ex_table P (cname_of h XCP) (length ins + pc) (xt @ shift (length ins) xt') = ⌊(pc', D)⌋› ‹D ≤ length stk›*) let ?PC = "length ins + pc" note [simp] = ‹xcp = ⌊XCP⌋› (*‹xcp = ⌊XCP⌋›*) ‹ta = ε› (*‹ta = ⦃⦄›*) ‹h' = h› (*‹h' = h›*) ‹stk' = Addr XCP # drop (length stk - D) stk› (*‹stk' = Addr XCP # drop (length stk - D) stk›*) ‹loc' = loc› (*‹loc' = loc›*) ‹xcp' = None› (*‹(xcp'::'addr option) = None›*) from ‹match_ex_table P (cname_of h XCP) ?PC (xt @ shift (length ins) xt') = ⌊(pc', D)⌋› (*‹match_ex_table (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (cname_of (h::'heap) (XCP::'addr)) (length (ins::'addr instr list) + (pc::nat)) ((xt::(nat × nat × String.literal option × nat × nat) list) @ shift (length ins) (xt'::(nat × nat × String.literal option × nat × nat) list)) = ⌊(pc'::nat, D::nat)⌋›*) xt (*‹pcs (xt::(nat × nat × String.literal option × nat × nat) list) ⊆ {..<length (ins::'addr instr list)}›*) have "match_ex_table P (cname_of h XCP) pc xt' = ⌊(pc' - length ins, D)⌋" by (auto simp add: match_ex_table_append (*‹match_ex_table ?P ?C ?pc (?xt @ ?xt') = (case match_ex_table ?P ?C ?pc ?xt of None ⇒ match_ex_table ?P ?C ?pc ?xt' | ⌊pcd⌋ ⇒ ⌊pcd⌋)›*) dest: match_ex_table_shift_pcD (*‹match_ex_table ?P ?C ?pc (shift ?n ?xt) = ⌊(?pc', ?d)⌋ ⟹ ?n ≤ ?pc ∧ ?n ≤ ?pc' ∧ match_ex_table ?P ?C (?pc - ?n) ?xt = ⌊(?pc' - ?n, ?d)⌋›*) match_ex_table_pcsD (*‹match_ex_table ?P ?C ?pc ?xt = ⌊(?pc', ?D)⌋ ⟹ ?pc ∈ pcs ?xt›*)) with ‹D ≤ length stk› (*‹(D::nat) ≤ length (stk::'addr val list)›*) show "?thesis" (*goal: ‹exec_meth ci P ins' xt' t h (stk, loc, pc, xcp) ta h' (stk', loc', pc' - length ins, xcp')›*) by (auto intro: exec_meth.intros (*‹⟦(?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc []; ?pc < length ?ins; ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp)› ‹⟦match_ex_table ?P (cname_of ?h ?xcp) ?pc ?xt = ⌊(?pc', ?d)⌋; ?d ≤ length ?stk⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ⌊?xcp⌋) ⦃⦄ ?h (Addr ?xcp # drop (length ?stk - ?d) ?stk, ?loc, ?pc', None)›*)) qed lemma exec_meth_drop: "⟦ exec_meth ci P (ins @ ins') (shift (length ins) xt) t h (stk, loc, (length ins + pc), xcp) ta h' (stk', loc', pc', xcp'); jump_ok ins' 0 b ⟧ ⟹ exec_meth ci P ins' xt t h (stk, loc, pc, xcp) ta h' (stk', loc', (pc' - length ins), xcp')" by (auto intro: exec_meth_drop_xt[where xt = "[]"] (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ([] @ shift (length ?ins) ?xt') ?t ?h (?stk, ?loc, length ?ins + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); pcs [] ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) lemma exec_meth_drop_xt_pc: assumes exec: "exec_meth ci P (ins @ ins') (xt @ shift (length ins) xt') t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" and pc: "pc ≥ length ins" and pcs: "pcs xt ⊆ {..<length ins}" and jump: "jump_ok ins' 0 n'" shows "pc' ≥ length ins" using exec (*‹exec_meth ci P (ins @ ins') (xt @ shift (length ins) xt') t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) proof (cases rule: exec_meth.cases (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr::addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id::type) (?a1.0::'heap::type) (?a2.0::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?a3.0::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?a4.0::'heap::type) (?a5.0::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); ⋀(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (xcp::'addr::addr option) (h'::'heap::type) (stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (pc::nat) (h::'heap::type) (stk::'addr::addr val list) loc::'addr::addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa::bool; ⋀(h::'heap::type) (xcp::'addr::addr) (pc::nat) (pc'::nat) (d::nat) (stk::'addr::addr val list) loc::'addr::addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⟦(xcp::'addr option) = None; (ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, [(stk'::'addr val list, loc'::'addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (pc::nat)) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined pc []; pc < length (ins @ ins'); ci_app (ci::('addr, 'heap) check_instr) ((ins @ ins') ! pc) P h stk loc undefined undefined pc []⟧ ⟹ length ins ≤ pc'› 2. ‹⋀(xcpa::'addr) d::nat. ⟦(xcp::'addr option) = ⌊xcpa⌋; (ta::('addr, 'thread_id, 'heap) jvm_thread_action) = ⦃⦄; (h'::'heap) = (h::'heap); (stk'::'addr val list) = Addr xcpa # drop (length (stk::'addr val list) - d) stk; (loc'::'addr val list) = (loc::'addr val list); (xcp'::'addr option) = None; match_ex_table (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (cname_of h xcpa) (pc::nat) ((xt::(nat × nat × String.literal option × nat × nat) list) @ shift (length (ins::'addr instr list)) (xt'::(nat × nat × String.literal option × nat × nat) list)) = ⌊(pc'::nat, d)⌋; d ≤ length stk⟧ ⟹ length ins ≤ pc'›*) case exec_instr (*‹(xcp::'addr option) = None› ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []› ‹pc < length (ins @ ins')› ‹ci_app (ci::('addr, 'heap) check_instr) (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (pc::nat)) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined pc []›*) thus "?thesis" (*goal: ‹length ins ≤ pc'›*) using jump (*‹jump_ok ins' 0 n'›*) pc (*‹length ins ≤ pc›*) apply (cases "ins' ! (pc - length ins)") (*goals: 1. ‹⋀x1. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Load x1⟧ ⟹ length ins ≤ pc'› 2. ‹⋀x2. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Store x2⟧ ⟹ length ins ≤ pc'› 3. ‹⋀x3. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Push x3⟧ ⟹ length ins ≤ pc'› 4. ‹⋀x4. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = New x4⟧ ⟹ length ins ≤ pc'› 5. ‹⋀x5. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = NewArray x5⟧ ⟹ length ins ≤ pc'› 6. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = ALoad⟧ ⟹ length ins ≤ pc'› 7. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = AStore⟧ ⟹ length ins ≤ pc'› 8. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = ALength⟧ ⟹ length ins ≤ pc'› 9. ‹⋀x91 x92. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Getfield x91 x92⟧ ⟹ length ins ≤ pc'› 10. ‹⋀x101 x102. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Putfield x101 x102⟧ ⟹ length ins ≤ pc'› 11. ‹⋀x111 x112. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = CAS x111 x112⟧ ⟹ length ins ≤ pc'› 12. ‹⋀x12. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Checkcast x12⟧ ⟹ length ins ≤ pc'› 13. ‹⋀x13. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Instanceof x13⟧ ⟹ length ins ≤ pc'› 14. ‹⋀x141 x142. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Invoke x141 x142⟧ ⟹ length ins ≤ pc'› 15. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Return⟧ ⟹ length ins ≤ pc'› 16. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Pop⟧ ⟹ length ins ≤ pc'› 17. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Dup⟧ ⟹ length ins ≤ pc'› 18. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Swap⟧ ⟹ length ins ≤ pc'› 19. ‹⋀x19. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = BinOpInstr x19⟧ ⟹ length ins ≤ pc'› 20. ‹⋀x20. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Goto x20⟧ ⟹ length ins ≤ pc'› 21. ‹⋀x21. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = IfFalse x21⟧ ⟹ length ins ≤ pc'› 22. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = ThrowExc⟧ ⟹ length ins ≤ pc'› 23. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = MEnter⟧ ⟹ length ins ≤ pc'› 24. ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = MExit⟧ ⟹ length ins ≤ pc'› discuss goal 1*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 2*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 3*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 4*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x4::String.literal. ⟦(xcp::'addr::addr option) = None; (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr::addr instr list) @ (ins'::'addr::addr instr list)) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; pc < length (ins @ ins'); ci_app (ci::('addr::addr, 'heap::type) check_instr) ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' (0::nat) (n'::nat); length ins ≤ pc; ins' ! (pc - length ins) = New x4⟧ ⟹ length ins ≤ pc'› and 20 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 5*) apply (simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x5. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = NewArray x5⟧ ⟹ length ins ≤ pc'› and 19 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 6*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⟦(xcp::'addr::addr option) = None; (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, xcp'::'addr::addr option, h'::'heap::type, [(stk'::'addr::addr val list, loc'::'addr::addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr::addr instr list) @ (ins'::'addr::addr instr list)) ! (pc::nat)) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list) (loc::'addr::addr val list) undefined undefined pc []; pc < length (ins @ ins'); ci_app (ci::('addr::addr, 'heap::type) check_instr) ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' (0::nat) (n'::nat); length ins ≤ pc; ins' ! (pc - length ins) = ALoad⟧ ⟹ length ins ≤ pc'› and 18 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 7*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 8*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 9*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀(x91::String.literal) x92::String.literal. ⟦(xcp::'addr option) = None; (ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, [(stk'::'addr val list, loc'::'addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (((ins::'addr instr list) @ (ins'::'addr instr list)) ! (pc::nat)) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined pc []; pc < length (ins @ ins'); ci_app (ci::('addr, 'heap) check_instr) ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' (0::nat) (n'::nat); length ins ≤ pc; ins' ! (pc - length ins) = Getfield x91 x92⟧ ⟹ length ins ≤ pc'› and 15 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 10*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 11*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x111 x112. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = CAS x111 x112⟧ ⟹ length ins ≤ pc'› and 13 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 12*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 13*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 14*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x141 x142. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Invoke x141 x142⟧ ⟹ length ins ≤ pc'› and 10 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 15*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 16*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 17*) apply (simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 18*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 19*) apply (simp add: split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c::type ⇒ bool) (case ?sum::?'a::type + ?'b::type of Inl (x::?'a::type) ⇒ (?f1.0::?'a::type ⇒ ?'c::type) x | Inr (x::?'b::type) ⇒ (?f2.0::?'b::type ⇒ ?'c::type) x) = (¬ ((∃x1::?'a::type. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b::type. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 20*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x20. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = Goto x20⟧ ⟹ length ins ≤ pc'› and 4 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 21*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x21. ⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = IfFalse x21⟧ ⟹ length ins ≤ pc'› and 3 goals remain*) apply (force split: extCallRet.splits (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = ((∀x1. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = Goto ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok ?ins ?n ?n'; ?ins ! ?pc = IfFalse ?m; ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*discuss goal 22*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 23*) apply (simp add: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 24*) apply (simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*goal: ‹⟦xcp = None; (ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr ((ins @ ins') ! pc) P t h stk loc undefined undefined pc []; pc < length (ins @ ins'); ci_app ci ((ins @ ins') ! pc) P h stk loc undefined undefined pc []; jump_ok ins' 0 n'; length ins ≤ pc; ins' ! (pc - length ins) = MExit⟧ ⟹ length ins ≤ pc'›*) apply (force split: extCallRet.splits (*‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = ((∀x1::?'addr val. ?extCallRet = RetVal x1 ⟶ ?P (?f1.0 x1)) ∧ (∀x2::?'addr. ?extCallRet = RetExc x2 ⟶ ?P (?f2.0 x2)) ∧ (?extCallRet = RetStaySame ⟶ ?P ?f3.0))› ‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = (¬ ((∃x1::?'addr val. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'addr. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*) extRet2JVM_def (*‹extRet2JVM ≡ λ(uu::nat) (uua::?'heap) (uub::?'addr val list) (uuc::?'addr val list) (uud::String.literal) (uue::String.literal) (uuf::nat) (uug::?'addr frame list) uuh::?'addr extCallRet. rec_extCallRet (λ(v::?'addr val) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + (1::nat)) # frs)) (λ(a::?'addr) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λ(n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*) dest: jump_ok_GotoD (*‹⟦jump_ok (?ins::?'a instr list) (?n::nat) (?n'::nat); ?ins ! (?pc::nat) = Goto (?m::int); ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*) jump_ok_IfFalseD (*‹⟦jump_ok (?ins::?'a instr list) (?n::nat) (?n'::nat); ?ins ! (?pc::nat) = IfFalse (?m::int); ?pc < length ?ins⟧ ⟹ - int (?pc + ?n) ≤ ?m ∧ ?m < int (length ?ins - ?pc + ?n')›*)) (*proven 24 subgoals*) . next (*goal: ‹⋀(xcpa::'addr::addr) d::nat. ⟦(xcp::'addr::addr option) = ⌊xcpa⌋; (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) = ⦃⦄; (h'::'heap::type) = (h::'heap::type); (stk'::'addr::addr val list) = Addr xcpa # drop (length (stk::'addr::addr val list) - d) stk; (loc'::'addr::addr val list) = (loc::'addr::addr val list); (xcp'::'addr::addr option) = None; match_ex_table (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (cname_of h xcpa) (pc::nat) ((xt::(nat × nat × String.literal option × nat × nat) list) @ shift (length (ins::'addr::addr instr list)) (xt'::(nat × nat × String.literal option × nat × nat) list)) = ⌊(pc'::nat, d)⌋; d ≤ length stk⟧ ⟹ length ins ≤ pc'›*) case exec_catch (*‹xcp = ⌊xcp_⌋› ‹ta = ⦃⦄› ‹h' = h› ‹stk' = Addr xcp_ # drop (length stk - d_) stk› ‹loc' = loc› ‹xcp' = None› ‹match_ex_table P (cname_of h xcp_) pc (xt @ shift (length ins) xt') = ⌊(pc', d_)⌋› ‹(d_::nat) ≤ length (stk::'addr::addr val list)›*) thus "?thesis" (*goal: ‹length (ins::'addr::addr instr list) ≤ (pc'::nat)›*) using pcs (*‹pcs xt ⊆ {..<length ins}›*) pc (*‹length ins ≤ pc›*) by (auto dest: match_ex_table_pcsD (*‹match_ex_table ?P ?C ?pc ?xt = ⌊(?pc', ?D)⌋ ⟹ ?pc ∈ pcs ?xt›*) match_ex_table_shift_pcD (*‹match_ex_table ?P ?C ?pc (shift ?n ?xt) = ⌊(?pc', ?d)⌋ ⟹ ?n ≤ ?pc ∧ ?n ≤ ?pc' ∧ match_ex_table ?P ?C (?pc - ?n) ?xt = ⌊(?pc' - ?n, ?d)⌋›*) simp add: match_ex_table_append (*‹match_ex_table ?P ?C ?pc (?xt @ ?xt') = (case match_ex_table ?P ?C ?pc ?xt of None ⇒ match_ex_table ?P ?C ?pc ?xt' | ⌊pcd⌋ ⇒ ⌊pcd⌋)›*)) qed lemmas exec_meth_drop_pc = exec_meth_drop_xt_pc[where xt="[]", simplified] definition exec_move :: "('addr, 'heap) check_instr ⇒ 'addr J1_prog ⇒ 'thread_id ⇒ 'addr expr1 ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr, 'thread_id, 'heap) jvm_thread_action ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "exec_move ci P t e ≡ exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t" definition exec_moves :: "('addr, 'heap) check_instr ⇒ 'addr J1_prog ⇒ 'thread_id ⇒ 'addr expr1 list ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr, 'thread_id, 'heap) jvm_thread_action ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "exec_moves ci P t es ≡ exec_meth ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t" abbreviation exec_move_a where "exec_move_a ≡ exec_move (Abs_check_instr check_instr')" abbreviation exec_move_d where "exec_move_d ≡ exec_move (Abs_check_instr check_instr)" abbreviation exec_moves_a where "exec_moves_a ≡ exec_moves (Abs_check_instr check_instr')" abbreviation exec_moves_d where "exec_moves_d ≡ exec_moves (Abs_check_instr check_instr)" lemma exec_move_newArrayI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (newA T⌊e⌉) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (newA T⌊e⌉)) (compxE2 (newA T⌊e⌉) 0 0) t h s ta h' s'›*) by auto lemma exec_move_newArray: "pc < length (compE2 e) ⟹ exec_move ci P t (newA T⌊e⌉) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (newA T⌊e⌉)) (compxE2 (newA T⌊e⌉) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_CastI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (Cast T e) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (Cast T e)) (compxE2 (Cast T e) 0 0) t h s ta h' s'›*) by auto lemma exec_move_Cast: "pc < length (compE2 e) ⟹ exec_move ci P t (Cast T e) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (Cast T e)) (compxE2 (Cast T e) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_InstanceOfI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e instanceof T) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e instanceof T)) (compxE2 (e instanceof T) 0 0) t h s ta h' s'›*) by auto lemma exec_move_InstanceOf: "pc < length (compE2 e) ⟹ exec_move ci P t (e instanceof T) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (e instanceof T)) (compxE2 (e instanceof T) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_BinOpI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e «bop» e') h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e «bop» e')) (compxE2 (e «bop» e') 0 0) t h s ta h' s'›*) by auto lemma exec_move_BinOp1: "pc < length (compE2 e) ⟹ exec_move ci P t (e «bop» e') h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹(pc::nat) < length (compE2 (e::'addr expr1)) ⟹ exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e «bop::bop» (e'::'addr expr1))) (compxE2 (e «bop» e') (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc, xcp::'addr option) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e (0::nat) (0::nat)) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt' @ shift (length ?ins) ?xt) ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*) simp add: compxE2_size_convs (*‹?n ≠ 0 ⟹ compxE2 ?e ?n ?d = shift ?n (compxE2 ?e 0 ?d)›*)) lemma exec_move_BinOpI2: assumes exec: "exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1 «bop» e2) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" proof (-) (*goal: ‹exec_move ci P t (e1 «bop» e2) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) from exec (*‹exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v]"] (*‹exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) (compE2 (e2::'addr::addr expr1)) (stack_xlift (length [v::'addr::addr val]) (compxE2 e2 (0::nat) (0::nat))) (t::'thread_id::type) (h::'heap::type) ((stk::'addr::addr val list) @ [v], loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) ((stk'::'addr::addr val list) @ [v], loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option)›*) show "?thesis" (*goal: ‹exec_move ci P t (e1 «bop» e2) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) by (fastforce split: bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = NotEq ⟶ ?P ?f2.0) ∧ (?bop = LessThan ⟶ ?P ?f3.0) ∧ (?bop = LessOrEqual ⟶ ?P ?f4.0) ∧ (?bop = GreaterThan ⟶ ?P ?f5.0) ∧ (?bop = GreaterOrEqual ⟶ ?P ?f6.0) ∧ (?bop = Add ⟶ ?P ?f7.0) ∧ (?bop = Subtract ⟶ ?P ?f8.0) ∧ (?bop = Mult ⟶ ?P ?f9.0) ∧ (?bop = Div ⟶ ?P ?f10.0) ∧ (?bop = Mod ⟶ ?P ?f11.0) ∧ (?bop = BinAnd ⟶ ?P ?f12.0) ∧ (?bop = BinOr ⟶ ?P ?f13.0) ∧ (?bop = BinXor ⟶ ?P ?f14.0) ∧ (?bop = ShiftLeft ⟶ ?P ?f15.0) ∧ (?bop = ShiftRightZeros ⟶ ?P ?f16.0) ∧ (?bop = ShiftRightSigned ⟶ ?P ?f17.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | NotEq ⇒ ?f2.0 | LessThan ⇒ ?f3.0 | LessOrEqual ⇒ ?f4.0 | GreaterThan ⇒ ?f5.0 | GreaterOrEqual ⇒ ?f6.0 | Add ⇒ ?f7.0 | Subtract ⇒ ?f8.0 | Mult ⇒ ?f9.0 | Div ⇒ ?f10.0 | Mod ⇒ ?f11.0 | BinAnd ⇒ ?f12.0 | BinOr ⇒ ?f13.0 | BinXor ⇒ ?f14.0 | ShiftLeft ⇒ ?f15.0 | ShiftRightZeros ⇒ ?f16.0 | ShiftRightSigned ⇒ ?f17.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = NotEq ∧ ¬ ?P ?f2.0 ∨ ?bop = LessThan ∧ ¬ ?P ?f3.0 ∨ ?bop = LessOrEqual ∧ ¬ ?P ?f4.0 ∨ ?bop = GreaterThan ∧ ¬ ?P ?f5.0 ∨ ?bop = GreaterOrEqual ∧ ¬ ?P ?f6.0 ∨ ?bop = Add ∧ ¬ ?P ?f7.0 ∨ ?bop = Subtract ∧ ¬ ?P ?f8.0 ∨ ?bop = Mult ∧ ¬ ?P ?f9.0 ∨ ?bop = Div ∧ ¬ ?P ?f10.0 ∨ ?bop = Mod ∧ ¬ ?P ?f11.0 ∨ ?bop = BinAnd ∧ ¬ ?P ?f12.0 ∨ ?bop = BinOr ∧ ¬ ?P ?f13.0 ∨ ?bop = BinXor ∧ ¬ ?P ?f14.0 ∨ ?bop = ShiftLeft ∧ ¬ ?P ?f15.0 ∨ ?bop = ShiftRightZeros ∧ ¬ ?P ?f16.0 ∨ ?bop = ShiftRightSigned ∧ ¬ ?P ?f17.0))›*) intro: append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*) simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) compxE2_size_convs (*‹?n ≠ 0 ⟹ compxE2 ?e ?n ?d = shift ?n (compxE2 ?e 0 ?d)›*) compxE2_stack_xlift_convs (*‹0 < ?d ⟹ compxE2 ?e ?pc ?d = stack_xlift ?d (compxE2 ?e ?pc 0)›*)) qed lemma exec_move_LAssI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (V := e) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (V:=e)) (compxE2 (V:=e) 0 0) t h s ta h' s'›*) by auto lemma exec_move_LAss: "pc < length (compE2 e) ⟹ exec_move ci P t (V := e) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (V:=e)) (compxE2 (V:=e) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_AAccI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e⌊e'⌉) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e⌊e'⌉)) (compxE2 (e⌊e'⌉) 0 0) t h s ta h' s'›*) by auto lemma exec_move_AAcc1: "pc < length (compE2 e) ⟹ exec_move ci P t (e⌊e'⌉) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (e⌊e'⌉)) (compxE2 (e⌊e'⌉) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt' @ shift (length ?ins) ?xt) ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*) simp add: compxE2_size_convs (*‹?n ≠ 0 ⟹ compxE2 ?e ?n ?d = shift ?n (compxE2 ?e 0 ?d)›*)) lemma exec_move_AAccI2: assumes exec: "exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1⌊e2⌉) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" proof (-) (*goal: ‹exec_move ci P t (e1⌊e2⌉) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) from exec (*‹exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v]"] (*‹exec_meth ci (compP2 P) (compE2 e2) (stack_xlift (length [v]) (compxE2 e2 0 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk' @ [v], loc', pc', xcp')›*) show "?thesis" (*goal: ‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e1::'addr expr1)⌊e2::'addr expr1⌉) (h::'heap) ((stk::'addr val list) @ [v::'addr val], loc::'addr val list, length (compE2 e1) + (pc::nat), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) ((stk'::'addr val list) @ [v], loc'::'addr val list, length (compE2 e1) + (pc'::nat), xcp'::'addr option)›*) by (fastforce intro: append_exec_meth_xt (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr::addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option); jump_ok ?ins (0::nat) (?n::nat); pcs (?xt'::(nat × nat × String.literal option × nat × nat) list) ⊆ {0::nat..<length (?ins'::'addr::addr instr list)}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*) simp add: exec_move_def (*‹exec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*) compxE2_size_convs (*‹(?n::nat) ≠ (0::nat) ⟹ compxE2 (?e::?'a::type expr1) ?n (?d::nat) = shift ?n (compxE2 ?e (0::nat) ?d)›*) compxE2_stack_xlift_convs (*‹(0::nat) < (?d::nat) ⟹ compxE2 (?e::?'a::type expr1) (?pc::nat) ?d = stack_xlift ?d (compxE2 ?e ?pc (0::nat))›*)) qed lemma exec_move_AAssI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e⌊e'⌉ := e'') h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e⌊e'⌉ := e'')) (compxE2 (e⌊e'⌉ := e'') 0 0) t h s ta h' s'›*) by auto lemma exec_move_AAss1: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (e⌊e'⌉ := e'') h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" (is "?lhs = ?rhs") proof ((rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))+) (*goals: 1. ‹⋀x xa xb. exec_move ci P t (e⌊e'⌉ := e'') h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb› 2. ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (e⌊e'⌉ := e'') h (stk, loc, pc, xcp) x xa xb›*) fix ta and h' and s' assume "?rhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) thus "?lhs ta h' s'" by (rule exec_move_AAssI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h ?s ?ta ?h' ?s'›*)) next (*goal: ‹⋀(x::('addr, 'thread_id, 'heap) jvm_thread_action) (xa::'heap) xb::'addr val list × 'addr val list × nat × 'addr option. exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e::'addr expr1)⌊(e'::'addr expr1)⌉ := (e''::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb›*) fix ta and h' and s' assume "?lhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e::'addr expr1)⌊(e'::'addr expr1)⌉ := (e''::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) hence "exec_meth ci (compP2 P) (compE2 e @ compE2 e' @ compE2 e'' @ [AStore, Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e)) (compxE2 e' 0 (Suc 0) @ compxE2 e'' (length (compE2 e')) (Suc (Suc 0)))) t h (stk, loc, pc, xcp) ta h' s'" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) thus "?rhs ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e::'addr expr1)) (compxE2 e (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) using pc (*‹pc < length (compE2 e)›*) by (rule exec_meth_take_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt' @ shift (length ?ins) ?xt) ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) qed lemma exec_move_AAssI2: assumes exec: "exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1⌊e2⌉ := e3) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" proof (-) (*goal: ‹exec_move ci P t (e1⌊e2⌉ := e3) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) from exec (*‹exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e2::'addr expr1)) (compxE2 e2 (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option)›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v]", simplified stack_xlift_compxE2, simplified] (*‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 (Suc 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk' @ [v], loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2 @ compE2 e3 @ [AStore, Push Unit]) (compxE2 e2 0 (Suc 0) @ shift (length (compE2 e2)) (compxE2 e3 0 (Suc (Suc 0)))) t h (stk @ [v], loc, pc, xcp) ta h' (stk' @ [v], loc', pc', xcp')" by (rule exec_meth_append_xt (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?ta ?h' ?s' ⟹ exec_meth ?ci ?P (?ins @ ?ins') (?xt @ ?xt') ?t ?h ?s ?ta ?h' ?s'›*)) hence "exec_meth ci (compP2 P) (compE2 e1 @ compE2 e2 @ compE2 e3 @ [AStore, Push Unit]) (compxE2 e1 0 0 @ shift (length (compE2 e1)) (compxE2 e2 0 (Suc 0) @ shift (length (compE2 e2)) (compxE2 e3 0 (Suc (Suc 0))))) t h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option); jump_ok ?ins (0::nat) (?n::nat); pcs (?xt'::(nat × nat × String.literal option × nat × nat) list) ⊆ {0::nat..<length (?ins'::'addr instr list)}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compE2 e2 @ compE2 e3 @ [AStore, Push Unit]) 0 ?n› 2. ‹pcs (compxE2 e1 0 0) ⊆ {0..<length (compE2 e1)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (e1⌊e2⌉ := e3) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) by (auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) qed lemma exec_move_AAssI3: assumes exec: "exec_move ci P t e3 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1⌊e2⌉ := e3) h (stk @ [v', v], loc, length (compE2 e1) + length (compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1) + length (compE2 e2) + pc', xcp')" proof (-) (*goal: ‹exec_move ci P t (e1⌊e2⌉ := e3) h (stk @ [v', v], loc, length (compE2 e1) + length (compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1) + length (compE2 e2) + pc', xcp')›*) from exec (*‹exec_move ci P t e3 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e3) (compxE2 e3 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e3) (compxE2 e3 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v', v]", simplified stack_xlift_compxE2, simplified] (*‹exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) (compE2 (e3::'addr::addr expr1)) (compxE2 e3 (0::nat) (Suc (Suc (0::nat)))) (t::'thread_id::type) (h::'heap::type) ((stk::'addr::addr val list) @ [v'::'addr::addr val, v::'addr::addr val], loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) ((stk'::'addr::addr val list) @ [v', v], loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option)›*) have "exec_meth ci (compP2 P) (compE2 e3 @ [AStore, Push Unit]) (compxE2 e3 0 (Suc (Suc 0))) t h (stk @ [v', v], loc, pc, xcp) ta h' (stk' @ [v', v], loc', pc', xcp')" by (rule exec_meth_append (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?ta ?h' ?s' ⟹ exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h ?s ?ta ?h' ?s'›*)) hence "exec_meth ci (compP2 P) ((compE2 e1 @ compE2 e2) @ compE2 e3 @ [AStore, Push Unit]) ((compxE2 e1 0 0 @ compxE2 e2 (length (compE2 e1)) (Suc 0)) @ shift (length (compE2 e1 @ compE2 e2)) (compxE2 e3 0 (Suc (Suc 0)))) t h (stk @ [v', v], loc, length (compE2 e1 @ compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1 @ compE2 e2) + pc', xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compE2 (e3::'addr expr1) @ [AStore, Push Unit]) (0::nat) (?n::nat)› 2. ‹pcs (compxE2 (e1::'addr expr1) (0::nat) (0::nat) @ compxE2 (e2::'addr expr1) (length (compE2 e1)) (Suc (0::nat))) ⊆ {0::nat..<length (compE2 e1 @ compE2 e2)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (e1⌊e2⌉ := e3) h (stk @ [v', v], loc, length (compE2 e1) + length (compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1) + length (compE2 e2) + pc', xcp')›*) by (auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) qed lemma exec_move_ALengthI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e∙length) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e::'addr expr1)) (compxE2 e (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_meth ci (compP2 P) (compE2 (e∙length)) (compxE2 (e∙length) (0::nat) (0::nat)) t h s ta h' s'›*) by auto lemma exec_move_ALength: "pc < length (compE2 e) ⟹ exec_move ci P t (e∙length) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (e∙length)) (compxE2 (e∙length) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_FAccI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e∙F{D}) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e∙F{D})) (compxE2 (e∙F{D}) 0 0) t h s ta h' s'›*) by auto lemma exec_move_FAcc: "pc < length (compE2 e) ⟹ exec_move ci P t (e∙F{D}) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (e∙F{D})) (compxE2 (e∙F{D}) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_FAssI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e∙F{D} := e') h s ta h' s'" sorry lemma exec_move_FAss1: "pc < length (compE2 e) ⟹ exec_move ci P t (e∙F{D} := e') h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹(pc::nat) < length (compE2 (e::'addr expr1)) ⟹ exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e∙(F::String.literal){(D::String.literal)} := (e'::'addr expr1))) (compxE2 (e∙F{D} := e') (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc, xcp::'addr option) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e (0::nat) (0::nat)) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*) intro: exec_meth_take_xt (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*) simp add: compxE2_size_convs (*‹(?n::nat) ≠ (0::nat) ⟹ compxE2 (?e::?'a expr1) ?n (?d::nat) = shift ?n (compxE2 ?e (0::nat) ?d)›*)) lemma exec_move_FAssI2: assumes exec: "exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1∙F{D} := e2) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" proof (-) (*goal: ‹exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) ((e1::'addr::addr expr1)∙(F::String.literal){(D::String.literal)} := (e2::'addr::addr expr1)) (h::'heap::type) ((stk::'addr::addr val list) @ [v::'addr::addr val], loc::'addr::addr val list, length (compE2 e1) + (pc::nat), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) ((stk'::'addr::addr val list) @ [v], loc'::'addr::addr val list, length (compE2 e1) + (pc'::nat), xcp'::'addr::addr option)›*) from exec (*‹exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v]"] (*‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e2::'addr expr1)) (stack_xlift (length [v::'addr val]) (compxE2 e2 (0::nat) (0::nat))) (t::'thread_id) (h::'heap) ((stk::'addr val list) @ [v], loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) ((stk'::'addr val list) @ [v], loc'::'addr val list, pc'::nat, xcp'::'addr option)›*) show "?thesis" (*goal: ‹exec_move ci P t (e1∙F{D} := e2) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) by (fastforce intro: append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*) simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) compxE2_size_convs (*‹?n ≠ 0 ⟹ compxE2 ?e ?n ?d = shift ?n (compxE2 ?e 0 ?d)›*) compxE2_stack_xlift_convs (*‹0 < ?d ⟹ compxE2 ?e ?pc ?d = stack_xlift ?d (compxE2 ?e ?pc 0)›*)) qed lemma exec_move_CASI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e∙compareAndSwap(D∙F, e', e''))) (compxE2 (e∙compareAndSwap(D∙F, e', e'')) 0 0) t h s ta h' s'›*) by auto lemma exec_move_CAS1: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" (is "?lhs = ?rhs") proof ((rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))+) (*goals: 1. ‹⋀x xa xb. exec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb› 2. ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk, loc, pc, xcp) x xa xb›*) fix ta and h' and s' assume "?rhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) thus "?lhs ta h' s'" by (rule exec_move_CASI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h ?s ?ta ?h' ?s'›*)) next (*goal: ‹⋀x xa xb. exec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb›*) fix ta and h' and s' assume "?lhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e::'addr expr1)∙compareAndSwap((D::String.literal)∙(F::String.literal), (e'::'addr expr1), (e''::'addr expr1))) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) hence "exec_meth ci (compP2 P) (compE2 e @ compE2 e' @ compE2 e'' @ [CAS F D]) (compxE2 e 0 0 @ shift (length (compE2 e)) (compxE2 e' 0 (Suc 0) @ compxE2 e'' (length (compE2 e')) (Suc (Suc 0)))) t h (stk, loc, pc, xcp) ta h' s'" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) thus "?rhs ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e::'addr expr1)) (compxE2 e (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) using pc (*‹(pc::nat) < length (compE2 (e::'addr::addr expr1))›*) by (rule exec_meth_take_xt (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr::addr instr list) @ (?ins'::'addr::addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) qed lemma exec_move_CASI2: assumes exec: "exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1∙compareAndSwap(D∙F, e2, e3)) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" proof (-) (*goal: ‹exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) ((e1::'addr::addr expr1)∙compareAndSwap((D::String.literal)∙(F::String.literal), (e2::'addr::addr expr1), (e3::'addr::addr expr1))) (h::'heap::type) ((stk::'addr::addr val list) @ [v::'addr::addr val], loc::'addr::addr val list, length (compE2 e1) + (pc::nat), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) ((stk'::'addr::addr val list) @ [v], loc'::'addr::addr val list, length (compE2 e1) + (pc'::nat), xcp'::'addr::addr option)›*) from exec (*‹exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v]", simplified stack_xlift_compxE2, simplified] (*‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 (Suc 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk' @ [v], loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e2 @ compE2 e3 @ [CAS F D]) (compxE2 e2 0 (Suc 0) @ shift (length (compE2 e2)) (compxE2 e3 0 (Suc (Suc 0)))) t h (stk @ [v], loc, pc, xcp) ta h' (stk' @ [v], loc', pc', xcp')" by (rule exec_meth_append_xt (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?ta ?h' ?s' ⟹ exec_meth ?ci ?P (?ins @ ?ins') (?xt @ ?xt') ?t ?h ?s ?ta ?h' ?s'›*)) hence "exec_meth ci (compP2 P) (compE2 e1 @ compE2 e2 @ compE2 e3 @ [CAS F D]) (compxE2 e1 0 0 @ shift (length (compE2 e1)) (compxE2 e2 0 (Suc 0) @ shift (length (compE2 e2)) (compxE2 e3 0 (Suc (Suc 0))))) t h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compE2 e2 @ compE2 e3 @ [CAS F D]) 0 ?n› 2. ‹pcs (compxE2 e1 0 0) ⊆ {0..<length (compE2 e1)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (e1∙compareAndSwap(D∙F, e2, e3)) h (stk @ [v], loc, length (compE2 e1) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e1) + pc', xcp')›*) by (auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) qed lemma exec_move_CASI3: assumes exec: "exec_move ci P t e3 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e1∙compareAndSwap(D∙F, e2, e3)) h (stk @ [v', v], loc, length (compE2 e1) + length (compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1) + length (compE2 e2) + pc', xcp')" proof (-) (*goal: ‹exec_move ci P t (e1∙compareAndSwap(D∙F, e2, e3)) h (stk @ [v', v], loc, length (compE2 e1) + length (compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1) + length (compE2 e2) + pc', xcp')›*) from exec (*‹exec_move ci P t e3 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e3) (compxE2 e3 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e3) (compxE2 e3 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v', v]", simplified stack_xlift_compxE2, simplified] (*‹exec_meth ci (compP2 P) (compE2 e3) (compxE2 e3 0 (Suc (Suc 0))) t h (stk @ [v', v], loc, pc, xcp) ta h' (stk' @ [v', v], loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e3 @ [CAS F D]) (compxE2 e3 0 (Suc (Suc 0))) t h (stk @ [v', v], loc, pc, xcp) ta h' (stk' @ [v', v], loc', pc', xcp')" by (rule exec_meth_append (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?ta ?h' ?s' ⟹ exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h ?s ?ta ?h' ?s'›*)) hence "exec_meth ci (compP2 P) ((compE2 e1 @ compE2 e2) @ compE2 e3 @ [CAS F D]) ((compxE2 e1 0 0 @ compxE2 e2 (length (compE2 e1)) (Suc 0)) @ shift (length (compE2 e1 @ compE2 e2)) (compxE2 e3 0 (Suc (Suc 0)))) t h (stk @ [v', v], loc, length (compE2 e1 @ compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1 @ compE2 e2) + pc', xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compE2 e3 @ [CAS F D]) 0 ?n› 2. ‹pcs (compxE2 e1 0 0 @ compxE2 e2 (length (compE2 e1)) (Suc 0)) ⊆ {0..<length (compE2 e1 @ compE2 e2)}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (e1∙compareAndSwap(D∙F, e2, e3)) h (stk @ [v', v], loc, length (compE2 e1) + length (compE2 e2) + pc, xcp) ta h' (stk' @ [v', v], loc', length (compE2 e1) + length (compE2 e2) + pc', xcp')›*) by (auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) qed lemma exec_move_CallI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e∙M(es)) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (e∙M(es))) (compxE2 (e∙M(es)) 0 0) t h s ta h' s'›*) by auto lemma exec_move_Call1: "pc < length (compE2 e) ⟹ exec_move ci P t (e∙M(es)) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹(pc::nat) < length (compE2 (e::'addr::addr expr1)) ⟹ exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) (compE2 (e∙(M::String.literal)(es::'addr::addr expr1 list))) (compxE2 (e∙M(es)) (0::nat) (0::nat)) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc, xcp::'addr::addr option) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e (0::nat) (0::nat)) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt' @ shift (length ?ins) ?xt) ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*) simp add: compxEs2_size_convs (*‹?n ≠ 0 ⟹ compxEs2 ?es ?n ?d = shift ?n (compxEs2 ?es 0 ?d)›*)) lemma exec_move_CallI2: assumes exec: "exec_moves ci P t es h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (e∙M(es)) h (stk @ [v], loc, length (compE2 e) + pc, xcp) ta h' (stk' @ [v], loc', length (compE2 e) + pc', xcp')" proof (-) (*goal: ‹exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) ((e::'addr::addr expr1)∙(M::String.literal)(es::'addr::addr expr1 list)) (h::'heap::type) ((stk::'addr::addr val list) @ [v::'addr::addr val], loc::'addr::addr val list, length (compE2 e) + (pc::nat), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) ((stk'::'addr::addr val list) @ [v], loc'::'addr::addr val list, length (compE2 e) + (pc'::nat), xcp'::'addr::addr option)›*) from exec (*‹exec_moves ci P t es h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_moves_def (*goal: ‹exec_meth ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . from exec_meth_stk_offer[OF this, where stk'' = "[v]"] (*‹exec_meth ci (compP2 P) (compEs2 es) (stack_xlift (length [v]) (compxEs2 es 0 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk' @ [v], loc', pc', xcp')›*) show "?thesis" (*goal: ‹exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) ((e::'addr::addr expr1)∙(M::String.literal)(es::'addr::addr expr1 list)) (h::'heap::type) ((stk::'addr::addr val list) @ [v::'addr::addr val], loc::'addr::addr val list, length (compE2 e) + (pc::nat), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) ((stk'::'addr::addr val list) @ [v], loc'::'addr::addr val list, length (compE2 e) + (pc'::nat), xcp'::'addr::addr option)›*) by (fastforce intro: append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*) simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) compxEs2_size_convs (*‹?n ≠ 0 ⟹ compxEs2 ?es ?n ?d = shift ?n (compxEs2 ?es 0 ?d)›*) compxEs2_stack_xlift_convs (*‹0 < ?d ⟹ compxEs2 ?es ?pc ?d = stack_xlift ?d (compxEs2 ?es ?pc 0)›*)) qed lemma exec_move_BlockNoneI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t {V:T=None; e} h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 {V:T=None; e}) (compxE2 {V:T=None; e} 0 0) t h s ta h' s'›*) by simp lemma exec_move_BlockNone: "exec_move ci P t {V:T=None; e} = exec_move ci P t e" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 {V:T=None; e}) (compxE2 {V:T=None; e} 0 0) t = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t›*) by simp lemma exec_move_BlockSomeI: assumes exec: "exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp')" proof (-) (*goal: ‹exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp')›*) let ?ins = "[Push v, Store V]" from exec (*‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*)) hence "exec_meth ci (compP2 P) (?ins @ compE2 e) (shift (length ?ins) (compxE2 e 0 0)) t h (stk, loc, length ?ins + pc, xcp) ta h' (stk', loc', length ?ins + pc', xcp')" apply (rule append_exec_meth (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option); jump_ok ?ins (0::nat) (?n::nat)⟧ ⟹ exec_meth ?ci ?P ((?ins'::'addr instr list) @ ?ins) (shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goal: ‹exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) ([Push (v::'addr::addr val), Store (V::nat)] @ compE2 (e::'addr::addr expr1)) (shift (length [Push v, Store V]) (compxE2 e (0::nat) (0::nat))) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, length [Push v, Store V] + (pc::nat), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (stk'::'addr::addr val list, loc'::'addr::addr val list, length [Push v, Store V] + (pc'::nat), xcp'::'addr::addr option)›*) by auto thus "?thesis" (*goal: ‹exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp')›*) by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*)) qed lemma exec_move_BlockSome: "exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp') = exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp') ⟹ exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp')›*) assume "?rhs" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option)›*) thus "?lhs" by (rule exec_move_BlockSomeI (*‹exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t {?V:?T=⌊?v⌋; ?e} ?h (?stk, ?loc, Suc (Suc ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc ?pc'), ?xcp')›*)) next (*goal: ‹exec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) ta h' (stk', loc', Suc (Suc pc'), xcp') ⟹ exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) let ?ins = "[Push v, Store V]" assume "?lhs" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) {V::nat:T::ty=⌊v::'addr val⌋; e::'addr expr1} (h::'heap) (stk::'addr val list, loc::'addr val list, Suc (Suc (pc::nat)), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, Suc (Suc (pc'::nat)), xcp'::'addr option)›*) hence "exec_meth ci (compP2 P) (?ins @ compE2 e) (shift (length ?ins) (compxE2 e 0 0)) t h (stk, loc, length ?ins + pc, xcp) ta h' (stk', loc', length ?ins + pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*)) hence "exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', length ?ins + pc' - length ?ins, xcp')" apply (rule exec_meth_drop (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr::addr instr list) @ (?ins'::'addr::addr instr list)) (shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, length ?ins + (?pc::nat), ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option); jump_ok ?ins' (0::nat) (?b::nat)⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', length [Push v, Store V] + pc' - length [Push v, Store V], xcp')›*) by auto thus "?rhs" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) qed lemma exec_move_SyncI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (sync⇘V⇙ (e) e') h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (sync⇘V⇙ (e) e')) (compxE2 (sync⇘V⇙ (e) e') 0 0) t h s ta h' s'›*) by auto lemma exec_move_Sync1: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (sync⇘V⇙ (e) e') h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" (is "?lhs = ?rhs") proof ((rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))+) (*goals: 1. ‹⋀x xa xb. exec_move ci P t (sync⇘V⇙ (e) e') h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb› 2. ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (sync⇘V⇙ (e) e') h (stk, loc, pc, xcp) x xa xb›*) fix ta and h' and s' assume "?lhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (sync⇘(V::nat)⇙ ((e::'addr expr1)) (e'::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) hence "exec_meth ci (compP2 P) (compE2 e @ Dup # Store V # MEnter # compE2 e' @ [Load V, MExit, Goto 4, Load V, MExit, ThrowExc]) (compxE2 e 0 0 @ shift (length (compE2 e)) (compxE2 e' 3 0 @ [(3, 3 + length (compE2 e'), None, 6 + length (compE2 e'), 0)])) t h (stk, loc, pc, xcp) ta h' s'" by (simp add: shift_compxE2 (*‹shift (?pc::nat) (compxE2 (?e::?'addr expr1) (?pc'::nat) (?d::nat)) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 36 facts*) exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*)) thus "?rhs ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' s'›*) using pc (*‹pc < length (compE2 e)›*) by (rule exec_meth_take_xt (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr::addr instr list) @ (?ins'::'addr::addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) qed (rule exec_move_SyncI1 (*‹exec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ exec_move ?ci ?P ?t (sync⇘(?V::nat)⇙ (?e) (?e'::'addr::addr expr1)) ?h ?s ?ta ?h' ?s'›*)) (*solved the remaining goal: ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (sync⇘V⇙ (e) e') h (stk, loc, pc, xcp) x xa xb›*) lemma exec_move_SyncI2: assumes exec: "exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (sync⇘V⇙ (o') e) h (stk, loc, (Suc (Suc (Suc (length (compE2 o') + pc)))), xcp) ta h' (stk', loc', (Suc (Suc (Suc (length (compE2 o') + pc')))), xcp')" proof (-) (*goal: ‹exec_move ci P t (sync⇘V⇙ (o') e) h (stk, loc, Suc (Suc (Suc (length (compE2 o') + pc))), xcp) ta h' (stk', loc', Suc (Suc (Suc (length (compE2 o') + pc'))), xcp')›*) let ?e = "compE2 o' @ [Dup, Store V, MEnter]" let ?e' = "[Load V, MExit, Goto 4, Load V, MExit, ThrowExc]" from exec (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option)›*) have "exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) hence "exec_meth ci (compP2 P) ((?e @ compE2 e) @ ?e') ((compxE2 o' 0 0 @ shift (length ?e) (compxE2 e 0 0)) @ [(length ?e, length ?e + length (compE2 e), None, length ?e + length (compE2 e) + 3, 0)]) t h (stk, loc, (length ?e + pc), xcp) ta h' (stk', loc', (length ?e + pc'), xcp')" apply (rule exec_meth_append_xt[OF append_exec_meth_xt] (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins1::'addr::addr instr list) (?xt1::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id::type) (?h::'heap::type) (?stk1::'addr::addr val list, ?loc1::'addr::addr val list, ?pc1::nat, ?xcp1::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?stk'1::'addr::addr val list, ?loc'1::'addr::addr val list, ?pc'1::nat, ?xcp'1::'addr::addr option); jump_ok ?ins1 (0::nat) (?n1::nat); pcs (?xt'1::(nat × nat × String.literal option × nat × nat) list) ⊆ {0::nat..<length (?ins'1::'addr::addr instr list)}⟧ ⟹ exec_meth ?ci ?P ((?ins'1 @ ?ins1) @ (?ins'::'addr::addr instr list)) ((?xt'1 @ shift (length ?ins'1) ?xt1) @ (?xt'::(nat × nat × String.literal option × nat × nat) list)) ?t ?h (?stk1, ?loc1, length ?ins'1 + ?pc1, ?xcp1) ?ta ?h' (?stk'1, ?loc'1, length ?ins'1 + ?pc'1, ?xcp'1)›*)) (*goals: 1. ‹jump_ok (compE2 e) 0 ?n1› 2. ‹pcs (compxE2 o' 0 0) ⊆ {0..<length (compE2 o' @ [Dup, Store V, MEnter])}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (sync⇘V⇙ (o') e) h (stk, loc, Suc (Suc (Suc (length (compE2 o') + pc))), xcp) ta h' (stk', loc', Suc (Suc (Suc (length (compE2 o') + pc'))), xcp')›*) by (simp add: eval_nat_numeral (*‹Numeral1 = Suc (0::nat)› ‹numeral (num.Bit0 (?n::num)) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 (?n::num)) = Suc (numeral (num.Bit0 ?n))›*) shift_compxE2 (*‹shift (?pc::nat) (compxE2 (?e::?'addr expr1) (?pc'::nat) (?d::nat)) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*)) qed lemma exec_move_SeqI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (e;;e') h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e::'addr expr1)) (compxE2 e (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_meth ci (compP2 P) (compE2 (e;; (e'::'addr expr1))) (compxE2 (e;; e') (0::nat) (0::nat)) t h s ta h' s'›*) by auto lemma exec_move_Seq1: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (e;;e') h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" (is "?lhs = ?rhs") proof ((rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))+) (*goals: 1. ‹⋀x xa xb. exec_move ci P t (e;; e') h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb› 2. ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (e;; e') h (stk, loc, pc, xcp) x xa xb›*) fix ta and h' and s' assume "?lhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e::'addr expr1);; (e'::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) hence "exec_meth ci (compP2 P) (compE2 e @ Pop # compE2 e') (compxE2 e 0 0 @ shift (length (compE2 e)) (compxE2 e' (Suc 0) 0)) t h (stk, loc, pc, xcp) ta h' s'" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*)) thus "?rhs ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' s'›*) using pc (*‹pc < length (compE2 e)›*) by (rule exec_meth_take_xt (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) qed (rule exec_move_SeqI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e;; ?e') ?h ?s ?ta ?h' ?s'›*)) (*solved the remaining goal: ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (e;; e') h (stk, loc, pc, xcp) x xa xb›*) lemma exec_move_SeqI2: assumes exec: "exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc' ,xcp')" shows "exec_move ci P t (e';;e) h (stk, loc, (Suc (length (compE2 e') + pc)), xcp) ta h' (stk', loc', (Suc (length (compE2 e') + pc')), xcp')" proof (-) (*goal: ‹exec_move ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e') + pc'), xcp')›*) from exec (*‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) hence "exec_meth ci (compP2 P) ((compE2 e' @ [Pop]) @ compE2 e) (compxE2 e' 0 0 @ shift (length (compE2 e' @ [Pop])) (compxE2 e 0 0)) t h (stk, loc, (length ((compE2 e') @ [Pop]) + pc), xcp) ta h' (stk', loc', (length ((compE2 e') @ [Pop]) + pc'), xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr::addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option); jump_ok ?ins (0::nat) (?n::nat); pcs (?xt'::(nat × nat × String.literal option × nat × nat) list) ⊆ {0::nat..<length (?ins'::'addr::addr instr list)}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compE2 (e::'addr expr1)) (0::nat) (?n::nat)› 2. ‹pcs (compxE2 (e'::'addr expr1) (0::nat) (0::nat)) ⊆ {0::nat..<length (compE2 e' @ [Pop])}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e') + pc'), xcp')›*) by (simp add: shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) qed lemma exec_move_Seq2: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (e';;e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e') + pc'), xcp') = exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹exec_move ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e') + pc'), xcp') ⟹ exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e') + pc'), xcp')›*) let ?E = "compE2 e' @ [Pop]" assume "?lhs" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e'::'addr expr1);; (e::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, Suc (length (compE2 e') + (pc::nat)), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, Suc (length (compE2 e') + (pc'::nat)), xcp'::'addr option)›*) hence "exec_meth ci (compP2 P) (?E @ compE2 e) (compxE2 e' 0 0 @ shift (length ?E) (compxE2 e 0 0)) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*)) from exec_meth_drop_xt[OF this] (*‹⟦pcs (compxE2 e' 0 0) ⊆ {..<length (compE2 e' @ [Pop])}; jump_ok (compE2 e) 0 ?n⟧ ⟹ exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', length (compE2 e' @ [Pop]) + pc' - length (compE2 e' @ [Pop]), xcp')›*) show "?rhs" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) by fastforce qed (rule exec_move_SeqI2 (*‹exec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option) ⟹ exec_move ?ci ?P ?t ((?e'::'addr::addr expr1);; ?e) ?h (?stk, ?loc, Suc (length (compE2 ?e') + ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (length (compE2 ?e') + ?pc'), ?xcp')›*)) (*solved the remaining goal: ‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e') + pc'), xcp')›*) lemma exec_move_CondI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (if (e) e1 else e2) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (if (e) e1 else e2)) (compxE2 (if (e) e1 else e2) 0 0) t h s ta h' s'›*) by auto lemma exec_move_Cond1: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (if (e) e1 else e2) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" (is "?lhs = ?rhs") proof ((rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))+) (*goals: 1. ‹⋀x xa xb. exec_move ci P t (if (e) e1 else e2) h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb› 2. ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (if (e) e1 else e2) h (stk, loc, pc, xcp) x xa xb›*) let ?E = "IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ Goto (1 + int (length (compE2 e2))) # compE2 e2" let ?xt = "compxE2 e1 (Suc 0) 0 @ compxE2 e2 (Suc (Suc (length (compE2 e1)))) 0" fix ta and h' and s' assume "?lhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (if ((e::'addr expr1)) (e1::'addr expr1) else (e2::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) hence "exec_meth ci (compP2 P) (compE2 e @ ?E) (compxE2 e 0 0 @ shift (length (compE2 e)) ?xt) t h (stk, loc, pc, xcp) ta h' s'" by (simp add: exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*) shift_compxE2 (*‹shift (?pc::nat) (compxE2 (?e::?'addr expr1) (?pc'::nat) (?d::nat)) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) thus "?rhs ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' s'›*) using pc (*‹pc < length (compE2 e)›*) by (rule exec_meth_take_xt (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) qed (rule exec_move_CondI1 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_move ?ci ?P ?t (if (?e) (?e1.0::'addr expr1) else (?e2.0::'addr expr1)) ?h ?s ?ta ?h' ?s'›*)) (*solved the remaining goal: ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (if (e) e1 else e2) h (stk, loc, pc, xcp) x xa xb›*) lemma exec_move_CondI2: assumes exec: "exec_move ci P t e1 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (if (e) e1 else e2) h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', (Suc (length (compE2 e) + pc')), xcp')" proof (-) (*goal: ‹exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')›*) from exec (*‹exec_move ci P t e1 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) hence "exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) @ compE2 e1) @ Goto (1 + int (length (compE2 e2))) # compE2 e2) ((compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))])) (compxE2 e1 0 0)) @ (compxE2 e2 (Suc (Suc (length (compE2 e) + length (compE2 e1)))) 0)) t h (stk, loc, (length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) + pc), xcp) ta h' (stk', loc', (length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) + pc'), xcp')" apply - (*goal: ‹exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) @ compE2 e1) @ Goto (1 + int (length (compE2 e2))) # compE2 e2) ((compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))])) (compxE2 e1 0 0)) @ compxE2 e2 (Suc (Suc (length (compE2 e) + length (compE2 e1)))) 0) t h (stk, loc, length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) + pc', xcp')›*) apply (rule exec_meth_append_xt (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?ta ?h' ?s' ⟹ exec_meth ?ci ?P (?ins @ ?ins') (?xt @ ?xt') ?t ?h ?s ?ta ?h' ?s'›*)) (*goal: ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) @ compE2 e1) @ Goto (1 + int (length (compE2 e2))) # compE2 e2) ((compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))])) (compxE2 e1 0 0)) @ compxE2 e2 (Suc (Suc (length (compE2 e) + length (compE2 e1)))) 0) t h (stk, loc, length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))]) + pc', xcp')›*) apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ jump_ok (compE2 e1) 0 ?n3› 3. ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ pcs (compxE2 e 0 0) ⊆ {0..<length (compE2 e @ [IfFalse (2 + int (length (compE2 e1)))])}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')›*) by (simp add: shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) qed lemma exec_move_Cond2: assumes pc: "pc < length (compE2 e1)" shows "exec_move ci P t (if (e) e1 else e2) h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', (Suc (length (compE2 e) + pc')), xcp') = exec_move ci P t e1 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" (is "?lhs = ?rhs") sorry lemma exec_move_CondI3: assumes exec: "exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')" proof (-) (*goal: ‹exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')›*) let ?E = "compE2 e @ IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ [Goto (1 + int (length (compE2 e2)))]" let ?xt = "compxE2 e 0 0 @ compxE2 e1 (Suc (length (compE2 e))) 0" from exec (*‹exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e2::'addr::addr expr1) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option)›*) have "exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) hence "exec_meth ci (compP2 P) (?E @ compE2 e2) (?xt @ shift (length ?E) (compxE2 e2 0 0)) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compE2 e2) 0 ?n› 2. ‹pcs (compxE2 e 0 0 @ compxE2 e1 (Suc (length (compE2 e))) 0) ⊆ {0..<length (compE2 e @ IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ [Goto (1 + int (length (compE2 e2)))])}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (if ((e::'addr::addr expr1)) (e1::'addr::addr expr1) else (e2::'addr::addr expr1)) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, Suc (Suc (length (compE2 e) + length (compE2 e1) + (pc::nat))), xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (stk'::'addr::addr val list, loc'::'addr::addr val list, Suc (Suc (length (compE2 e) + length (compE2 e1) + (pc'::nat))), xcp'::'addr::addr option)›*) by (simp add: shift_compxE2 (*‹shift (?pc::nat) (compxE2 (?e::?'addr expr1) (?pc'::nat) (?d::nat)) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*)) qed lemma exec_move_Cond3: "exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp') = exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp') ⟹ exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_move ci P t e2 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')›*) let ?E = "compE2 e @ IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ [Goto (1 + int (length (compE2 e2)))]" let ?xt = "compxE2 e 0 0 @ compxE2 e1 (Suc (length (compE2 e))) 0" assume "?lhs" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (if ((e::'addr expr1)) (e1::'addr expr1) else (e2::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, Suc (Suc (length (compE2 e) + length (compE2 e1) + (pc::nat))), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, Suc (Suc (length (compE2 e) + length (compE2 e1) + (pc'::nat))), xcp'::'addr option)›*) hence "exec_meth ci (compP2 P) (?E @ compE2 e2) (?xt @ shift (length ?E) (compxE2 e2 0 0)) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')" by (simp add: shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) thus "?rhs" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) apply - (*goal: ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) apply (drule exec_meth_drop_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt @ shift (length ?ins) ?xt') ?t ?h (?stk, ?loc, length ?ins + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) (*goals: 1. ‹pcs (compxE2 e 0 0 @ compxE2 e1 (Suc (length (compE2 e))) 0) ⊆ {..<length (compE2 e @ IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ [Goto (1 + int (length (compE2 e2)))])}› 2. ‹jump_ok (compE2 e2) 0 ?n1› 3. ‹exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', length (compE2 e @ IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ [Goto (1 + int (length (compE2 e2)))]) + pc' - length (compE2 e @ IfFalse (2 + int (length (compE2 e1))) # compE2 e1 @ [Goto (1 + int (length (compE2 e2)))]), xcp') ⟹ exec_meth ci (compP2 P) (compE2 e2) (compxE2 e2 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed (rule exec_move_CondI3 (*‹exec_move ?ci ?P ?t ?e2.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (if (?e) ?e1.0 else ?e2.0) ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + length (compE2 ?e1.0) + ?pc)), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc (length (compE2 ?e) + length (compE2 ?e1.0) + ?pc')), ?xcp')›*)) (*solved the remaining goal: ‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e2::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option) ⟹ exec_move ci P t (if ((e::'addr expr1)) (e1::'addr expr1) else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')›*) lemma exec_move_WhileI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (while (e) e') h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e::'addr expr1)) (compxE2 e (0::nat) (0::nat)) (t::'thread_id) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_meth ci (compP2 P) (compE2 (while (e) (e'::'addr expr1))) (compxE2 (while (e) e') (0::nat) (0::nat)) t h s ta h' s'›*) by auto lemma (in ab_group_add) uminus_minus_left_commute: "- a - (b + c) = - b - (a + c)" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 24 facts*)) lemma exec_move_While1: assumes pc: "pc < length (compE2 e)" shows "exec_move ci P t (while (e) e') h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" (is "?lhs = ?rhs") proof ((rule ext (*‹(⋀x::?'a::type. (?f::?'a::type ⇒ ?'b::type) x = (?g::?'a::type ⇒ ?'b::type) x) ⟹ ?f = ?g›*) iffI (*‹⟦?P::bool ⟹ ?Q::bool; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*))+) (*goals: 1. ‹⋀x xa xb. exec_move ci P t (while (e) e') h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t e h (stk, loc, pc, xcp) x xa xb› 2. ‹⋀x xa xb. exec_move ci P t e h (stk, loc, pc, xcp) x xa xb ⟹ exec_move ci P t (while (e) e') h (stk, loc, pc, xcp) x xa xb›*) let ?E = "IfFalse (3 + int (length (compE2 e'))) # compE2 e' @ [Pop, Goto (- int (length (compE2 e)) + (-2 - int (length (compE2 e')))), Push Unit]" let ?xt = "compxE2 e' (Suc 0) 0" fix ta and h' and s' assume "?lhs ta h' s'" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (while ((e::'addr expr1)) (e'::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option)›*) then have "exec_meth ci (compP2 P) (compE2 e @ ?E) (compxE2 e 0 0 @ shift (length (compE2 e)) ?xt) t h (stk, loc, pc, xcp) ta h' s'" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*) uminus_minus_left_commute (*‹- ?a - (?b + ?c) = - ?b - (?a + ?c)›*)) thus "?rhs ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' s'›*) using pc (*‹pc < length (compE2 e)›*) by (rule exec_meth_take_xt (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr::addr instr list) @ (?ins'::'addr::addr instr list)) ((?xt'::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) qed (rule exec_move_WhileI1 (*‹exec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?h'::'heap::type) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ exec_move ?ci ?P ?t (while (?e) (?e'::'addr::addr expr1)) ?h ?s ?ta ?h' ?s'›*)) (*solved the remaining goal: ‹⋀(x::('addr, 'thread_id, 'heap) jvm_thread_action) (xa::'heap) xb::'addr val list × 'addr val list × nat × 'addr option. exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) x xa xb ⟹ exec_move ci P t (while (e) (e'::'addr expr1)) h (stk, loc, pc, xcp) x xa xb›*) lemma exec_move_WhileI2: assumes exec: "exec_move ci P t e1 h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (while (e) e1) h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', (Suc (length (compE2 e) + pc')), xcp')" proof (-) (*goal: ‹exec_move ci P t (while (e) e1) h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')›*) let ?E = "compE2 e @ [IfFalse (3 + int (length (compE2 e1)))]" let ?E' = "[Pop, Goto (- int (length (compE2 e)) + (-2 - int (length (compE2 e1)))), Push Unit]" from exec (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e1::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option)›*) have "exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) hence "exec_meth ci (compP2 P) ((?E @ compE2 e1) @ ?E') (compxE2 e 0 0 @ shift (length ?E) (compxE2 e1 0 0)) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')" apply - (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (((compE2 (e::'addr expr1) @ [IfFalse ((3::int) + int (length (compE2 (e1::'addr expr1))))]) @ compE2 e1) @ [Pop, Goto (- int (length (compE2 e)) + (- (2::int) - int (length (compE2 e1)))), Push Unit]) (compxE2 e (0::nat) (0::nat) @ shift (length (compE2 e @ [IfFalse ((3::int) + int (length (compE2 e1)))])) (compxE2 e1 (0::nat) (0::nat))) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, length (compE2 e @ [IfFalse ((3::int) + int (length (compE2 e1)))]) + (pc::nat), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, length (compE2 e @ [IfFalse ((3::int) + int (length (compE2 e1)))]) + (pc'::nat), xcp'::'addr option)›*) apply (rule exec_meth_append (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?ta ?h' ?s' ⟹ exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h ?s ?ta ?h' ?s'›*)) (*goal: ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_meth ci (compP2 P) (((compE2 e @ [IfFalse (3 + int (length (compE2 e1)))]) @ compE2 e1) @ [Pop, Goto (- int (length (compE2 e)) + (- 2 - int (length (compE2 e1)))), Push Unit]) (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e1)))])) (compxE2 e1 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e1)))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e1)))]) + pc', xcp')›*) apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ jump_ok (compE2 e1) 0 ?n3› 3. ‹exec_meth ci (compP2 P) (compE2 e1) (compxE2 e1 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ pcs (compxE2 e 0 0) ⊆ {0..<length (compE2 e @ [IfFalse (3 + int (length (compE2 e1)))])}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (while (e) e1) h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')›*) by (simp add: shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*) uminus_minus_left_commute (*‹- ?a - (?b + ?c) = - ?b - (?a + ?c)›*)) qed lemma exec_move_While2: assumes pc: "pc < length (compE2 e')" shows "exec_move ci P t (while (e) e') h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', (Suc (length (compE2 e) + pc')), xcp') = exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (while ((e::'addr expr1)) (e'::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, Suc (length (compE2 e) + (pc::nat)), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, Suc (length (compE2 e) + (pc'::nat)), xcp'::'addr option) ⟹ exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e'::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option) ⟹ exec_move ci P t (while ((e::'addr expr1)) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')›*) let ?E = "compE2 e @ [IfFalse (3 + int (length (compE2 e')))]" let ?E' = "[Pop, Goto (- int (length (compE2 e)) + (-2 - int (length (compE2 e')))), Push Unit]" assume "?lhs" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (while ((e::'addr expr1)) (e'::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, Suc (length (compE2 e) + (pc::nat)), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, Suc (length (compE2 e) + (pc'::nat)), xcp'::'addr option)›*) hence "exec_meth ci (compP2 P) ((?E @ compE2 e') @ ?E') (compxE2 e 0 0 @ shift (length ?E) (compxE2 e' 0 0)) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*) uminus_minus_left_commute (*‹- ?a - (?b + ?c) = - ?b - (?a + ?c)›*)) thus "?rhs" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) using pc (*‹pc < length (compE2 e')›*) apply - (*goal: ‹exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) (compE2 (e'::'addr::addr expr1)) (compxE2 e' (0::nat) (0::nat)) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option)›*) apply (drule exec_meth_take (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) (*goals: 1. ‹pc < length (compE2 e') ⟹ length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc < length ((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e')› 2. ‹⟦pc < length (compE2 e'); exec_meth ci (compP2 P) ((compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) @ compE2 e') (compxE2 e 0 0 @ shift (length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])) (compxE2 e' 0 0)) t h (stk, loc, length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc', xcp')⟧ ⟹ exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› discuss goal 1*) apply simp (*discuss goal 2*) apply (drule exec_meth_drop_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt @ shift (length ?ins) ?xt') ?t ?h (?stk, ?loc, length ?ins + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) (*goals: 1. ‹pc < length (compE2 e') ⟹ pcs (compxE2 e 0 0) ⊆ {..<length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))])}› 2. ‹pc < length (compE2 e') ⟹ jump_ok (compE2 e') 0 ?n5› 3. ‹⟦pc < length (compE2 e'); exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]) + pc' - length (compE2 e @ [IfFalse (3 + int (length (compE2 e')))]), xcp')⟧ ⟹ exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*proven 2 subgoals*) . qed (rule exec_move_WhileI2 (*‹exec_move ?ci ?P ?t ?e1.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (while (?e) ?e1.0) ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*solved the remaining goal: ‹exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) ta h' (stk', loc', Suc (length (compE2 e) + pc'), xcp')›*) lemma exec_move_ThrowI: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (throw e) h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (throw e)) (compxE2 (throw e) 0 0) t h s ta h' s'›*) by auto lemma exec_move_Throw: "pc < length (compE2 e) ⟹ exec_move ci P t (throw e) h (stk, loc, pc, xcp) = exec_move ci P t e h (stk, loc, pc, xcp)" unfolding exec_move_def (*goal: ‹pc < length (compE2 e) ⟹ exec_meth ci (compP2 P) (compE2 (throw e)) (compxE2 (throw e) 0 0) t h (stk, loc, pc, xcp) = exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp)›*) by (auto intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) intro: exec_meth_take (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) lemma exec_move_TryI1: "exec_move ci P t e h s ta h' s' ⟹ exec_move ci P t (try e catch(C V) e') h s ta h' s'" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h s ta h' s' ⟹ exec_meth ci (compP2 P) (compE2 (try e catch(C V) e')) (compxE2 (try e catch(C V) e') 0 0) t h s ta h' s'›*) by auto lemma exec_move_TryI2: assumes exec: "exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_move ci P t (try e' catch(C V) e) h (stk, loc, Suc (Suc (length (compE2 e') + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e') + pc')), xcp')" proof (-) (*goal: ‹exec_move ci P t (try e' catch(C V) e) h (stk, loc, Suc (Suc (length (compE2 e') + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e') + pc')), xcp')›*) let ?e = "compE2 e' @ [Goto (int(size (compE2 e))+2), Store V]" from exec (*‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) hence "exec_meth ci (compP2 P) ((?e @ compE2 e) @ []) ((compxE2 e' 0 0 @ shift (length ?e) (compxE2 e 0 0)) @ [(0, length (compE2 e'), ⌊C⌋, Suc (length (compE2 e')), 0)]) t h (stk, loc, (length ?e + pc), xcp) ta h' (stk', loc', (length ?e + pc'), xcp')" apply (rule exec_meth_append_xt[OF append_exec_meth_xt] (*‹⟦exec_meth ?ci ?P ?ins1 ?xt1 ?t ?h (?stk1, ?loc1, ?pc1, ?xcp1) ?ta ?h' (?stk'1, ?loc'1, ?pc'1, ?xcp'1); jump_ok ?ins1 0 ?n1; pcs ?xt'1 ⊆ {0..<length ?ins'1}⟧ ⟹ exec_meth ?ci ?P ((?ins'1 @ ?ins1) @ ?ins') ((?xt'1 @ shift (length ?ins'1) ?xt1) @ ?xt') ?t ?h (?stk1, ?loc1, length ?ins'1 + ?pc1, ?xcp1) ?ta ?h' (?stk'1, ?loc'1, length ?ins'1 + ?pc'1, ?xcp'1)›*)) (*goals: 1. ‹jump_ok (compE2 e) 0 ?n1› 2. ‹pcs (compxE2 e' 0 0) ⊆ {0..<length (compE2 e' @ [Goto (int (length (compE2 e)) + 2), Store V])}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_move ci P t (try e' catch(C V) e) h (stk, loc, Suc (Suc (length (compE2 e') + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e') + pc')), xcp')›*) by (simp add: eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) qed lemma exec_move_Try2: "exec_move ci P t (try e catch(C V) e') h (stk, loc, Suc (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + pc')), xcp') = exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" (is "?lhs = ?rhs") proof (standard) (*goals: 1. ‹exec_move ci P t (try e catch(C V) e') h (stk, loc, Suc (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + pc')), xcp') ⟹ exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› 2. ‹exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t (try e catch(C V) e') h (stk, loc, Suc (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + pc')), xcp')›*) let ?E = "compE2 e @ [Goto (int(size (compE2 e'))+2), Store V]" let ?xt = "[(0, length (compE2 e), ⌊C⌋, Suc (length (compE2 e)), 0)]" assume lhs: "?lhs" (*‹exec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (try e::'addr expr1 catch((C::String.literal) (V::nat)) (e'::'addr expr1)) (h::'heap) (stk::'addr val list, loc::'addr val list, Suc (Suc (length (compE2 e) + (pc::nat))), xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, Suc (Suc (length (compE2 e) + (pc'::nat))), xcp'::'addr option)›*) hence pc: "pc < length (compE2 e')" by (fastforce elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) match_ex_table_append (*‹match_ex_table ?P ?C ?pc (?xt @ ?xt') = (case match_ex_table ?P ?C ?pc ?xt of None ⇒ match_ex_table ?P ?C ?pc ?xt' | ⌊pcd⌋ ⇒ ⌊pcd⌋)›*) match_ex_entry (*‹matches_ex_entry ?P ?C ?pc (?start, ?end, ?catch_type, ?handler) = (?start ≤ ?pc ∧ ?pc < ?end ∧ (case ?catch_type of None ⇒ True | ⌊C'⌋ ⇒ ?P ⊢ ?C ≼⇧* C'))›*) dest: match_ex_table_pcsD (*‹match_ex_table ?P ?C ?pc ?xt = ⌊(?pc', ?D)⌋ ⟹ ?pc ∈ pcs ?xt›*)) from lhs (*‹exec_move ci P t (try e catch(C V) e') h (stk, loc, Suc (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + pc')), xcp')›*) have "exec_meth ci (compP2 P) ((?E @ compE2 e') @ []) ((compxE2 e 0 0 @ shift (length ?E) (compxE2 e' 0 0)) @ ?xt) t h (stk, loc, length ?E + pc, xcp) ta h' (stk', loc', length ?E + pc', xcp')" by (simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) shift_compxE2 (*‹shift ?pc (compxE2 ?e ?pc' ?d) = compxE2 ?e (?pc' + ?pc) ?d›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 36 facts*)) thus "?rhs" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) using pc (*‹pc < length (compE2 e')›*) apply - (*goal: ‹exec_meth ci (compP2 P) (compE2 e') (compxE2 e' 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) apply (drule exec_meth_drop_xt[OF exec_meth_take_xt'] (*‹⟦exec_meth ?ci ?P ((?ins @ ?ins') @ ?ins'1) ((?xt @ shift (length ?ins) ?xt') @ ?xt1) ?t ?h (?stk, ?loc, length ?ins + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); length ?ins + ?pc < length (?ins @ ?ins'); length ?ins + ?pc ∉ pcs ?xt1; pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) (*goals: 1. ‹(pc::nat) < length (compE2 (e'::'addr::addr expr1)) ⟹ length (compE2 (e::'addr::addr expr1) @ [Goto (int (length (compE2 e')) + (2::int)), Store (V::nat)]) + pc < length ((compE2 e @ [Goto (int (length (compE2 e')) + (2::int)), Store V]) @ compE2 e')› 2. ‹(pc::nat) < length (compE2 (e'::'addr::addr expr1)) ⟹ length (compE2 (e::'addr::addr expr1) @ [Goto (int (length (compE2 e')) + (2::int)), Store (V::nat)]) + pc ∉ pcs [(0::nat, length (compE2 e), ⌊C::String.literal⌋, Suc (length (compE2 e)), 0::nat)]› 3. ‹(pc::nat) < length (compE2 (e'::'addr::addr expr1)) ⟹ pcs (compxE2 (e::'addr::addr expr1) (0::nat) (0::nat)) ⊆ {..<length (compE2 e @ [Goto (int (length (compE2 e')) + (2::int)), Store (V::nat)])}› 4. ‹(pc::nat) < length (compE2 (e'::'addr::addr expr1)) ⟹ jump_ok (compE2 e') (0::nat) (?n2::nat)› 5. ‹⟦(pc::nat) < length (compE2 (e'::'addr::addr expr1)); exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) (compE2 e') (compxE2 e' (0::nat) (0::nat)) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc, xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (stk'::'addr::addr val list, loc'::'addr::addr val list, length (compE2 (e::'addr::addr expr1) @ [Goto (int (length (compE2 e')) + (2::int)), Store (V::nat)]) + (pc'::nat) - length (compE2 e @ [Goto (int (length (compE2 e')) + (2::int)), Store V]), xcp'::'addr::addr option)⟧ ⟹ exec_meth ci (compP2 P) (compE2 e') (compxE2 e' (0::nat) (0::nat)) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . qed (rule exec_move_TryI2 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ exec_move ?ci ?P ?t (try ?e'::'addr expr1 catch((?C::String.literal) (?V::nat)) ?e) ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e') + ?pc)), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc (length (compE2 ?e') + ?pc')), ?xcp')›*)) (*solved the remaining goal: ‹exec_move ci P t e' h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp') ⟹ exec_move ci P t (try e catch(C V) e') h (stk, loc, Suc (Suc (length (compE2 e) + pc)), xcp) ta h' (stk', loc', Suc (Suc (length (compE2 e) + pc')), xcp')›*) lemma exec_move_raise_xcp_pcD: "exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', Some a) ⟹ pc' = pc" apply (cases "compE2 E ! pc") (*goals: 1. ‹⋀x1. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Load x1⟧ ⟹ pc' = pc› 2. ‹⋀x2. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Store x2⟧ ⟹ pc' = pc› 3. ‹⋀x3. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Push x3⟧ ⟹ pc' = pc› 4. ‹⋀x4. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = New x4⟧ ⟹ pc' = pc› 5. ‹⋀x5. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = NewArray x5⟧ ⟹ pc' = pc› 6. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = ALoad⟧ ⟹ pc' = pc› 7. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = AStore⟧ ⟹ pc' = pc› 8. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = ALength⟧ ⟹ pc' = pc› 9. ‹⋀x91 x92. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Getfield x91 x92⟧ ⟹ pc' = pc› 10. ‹⋀x101 x102. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Putfield x101 x102⟧ ⟹ pc' = pc› 11. ‹⋀x111 x112. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = CAS x111 x112⟧ ⟹ pc' = pc› 12. ‹⋀x12. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Checkcast x12⟧ ⟹ pc' = pc› 13. ‹⋀x13. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Instanceof x13⟧ ⟹ pc' = pc› 14. ‹⋀x141 x142. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Invoke x141 x142⟧ ⟹ pc' = pc› 15. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Return⟧ ⟹ pc' = pc› 16. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Pop⟧ ⟹ pc' = pc› 17. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Dup⟧ ⟹ pc' = pc› 18. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Swap⟧ ⟹ pc' = pc› 19. ‹⋀x19. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = BinOpInstr x19⟧ ⟹ pc' = pc› 20. ‹⋀x20. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Goto x20⟧ ⟹ pc' = pc› 21. ‹⋀x21. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = IfFalse x21⟧ ⟹ pc' = pc› 22. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = ThrowExc⟧ ⟹ pc' = pc› 23. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = MEnter⟧ ⟹ pc' = pc› 24. ‹⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = MExit⟧ ⟹ pc' = pc› discuss goal 1*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 2*) apply ((auto simp add: exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?a1.0::'heap) (?a2.0::'addr val list × 'addr val list × nat × 'addr option) (?a3.0::('addr, 'thread_id, 'heap) jvm_thread_action) (?a4.0::'heap) (?a5.0::'addr val list × 'addr val list × nat × 'addr option); ⋀(ta::('addr, 'thread_id, 'heap) jvm_thread_action) (xcp::'addr option) (h'::'heap) (stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (pc::nat) (h::'heap) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa::bool; ⋀(h::'heap) (xcp::'addr) (pc::nat) (pc'::nat) (d::nat) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 3*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 4*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 5*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 6*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 7*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 8*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 9*) apply ((auto simp add: exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?a1.0::'heap) (?a2.0::'addr val list × 'addr val list × nat × 'addr option) (?a3.0::('addr, 'thread_id, 'heap) jvm_thread_action) (?a4.0::'heap) (?a5.0::'addr val list × 'addr val list × nat × 'addr option); ⋀(ta::('addr, 'thread_id, 'heap) jvm_thread_action) (xcp::'addr option) (h'::'heap) (stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (pc::nat) (h::'heap) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa::bool; ⋀(h::'heap) (xcp::'addr) (pc::nat) (pc'::nat) (d::nat) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 10*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 11*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 12*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 13*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 14*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*top goal: ‹⋀x141 x142. ⟦exec_move ci P t E h (stk, loc, pc, None) ta h' (stk', loc', pc', ⌊a⌋); compE2 E ! pc = Invoke x141 x142⟧ ⟹ pc' = pc› and 10 goals remain*) apply (auto split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) (*discuss goal 15*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 16*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 17*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 18*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 19*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 20*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 21*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 22*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 23*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 24*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim!: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*proven 24 subgoals*) . definition τexec_meth :: "('addr, 'heap) check_instr ⇒ 'addr jvm_prog ⇒ 'addr instr list ⇒ ex_table ⇒ 'thread_id ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "τexec_meth ci P ins xt t h s s' ⟷ exec_meth ci P ins xt t h s ε h s' ∧ (snd (snd (snd s)) = None ⟶ τinstr P h (fst s) (ins ! fst (snd (snd s))))" abbreviation τexec_meth_a where "τexec_meth_a ≡ τexec_meth (Abs_check_instr check_instr')" abbreviation τexec_meth_d where "τexec_meth_d ≡ τexec_meth (Abs_check_instr check_instr)" lemma τexec_methI [intro]: "⟦ exec_meth ci P ins xt t h (stk, loc, pc, xcp) ε h s'; xcp = None ⟹ τinstr P h stk (ins ! pc) ⟧ ⟹ τexec_meth ci P ins xt t h (stk, loc, pc, xcp) s'" by (simp add: τexec_meth_def (*‹τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s' = (exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ⦃⦄ ?h ?s' ∧ (snd (snd (snd ?s)) = None ⟶ τinstr ?P ?h (fst ?s) (?ins ! fst (snd (snd ?s)))))›*)) lemma τexec_methE [elim]: assumes "τexec_meth ci P ins xt t h s s'" obtains stk loc pc xcp where "s = (stk, loc, pc, xcp)" and "exec_meth ci P ins xt t h (stk, loc, pc, xcp) ε h s'" and "xcp = None ⟹ τinstr P h stk (ins ! pc)" using assms (*‹τexec_meth ci P ins xt t h s s'›*) apply (cases s) (*goal: ‹(⋀stk loc pc xcp. ⟦s = (stk, loc, pc, xcp); exec_meth ci P ins xt t h (stk, loc, pc, xcp) ⦃⦄ h s'; xcp = None ⟹ τinstr P h stk (ins ! pc)⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: τexec_meth_def (*‹τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s' = (exec_meth ?ci ?P ?ins ?xt ?t ?h ?s ⦃⦄ ?h ?s' ∧ (snd (snd (snd ?s)) = None ⟶ τinstr ?P ?h (fst ?s) (?ins ! fst (snd (snd ?s)))))›*)) abbreviation τExec_methr :: "('addr, 'heap) check_instr ⇒ 'addr jvm_prog ⇒ 'addr instr list ⇒ ex_table ⇒ 'thread_id ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "τExec_methr ci P ins xt t h == (τexec_meth ci P ins xt t h)^**" abbreviation τExec_metht :: "('addr, 'heap) check_instr ⇒ 'addr jvm_prog ⇒ 'addr instr list ⇒ ex_table ⇒ 'thread_id ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "τExec_metht ci P ins xt t h == (τexec_meth ci P ins xt t h)^++" abbreviation τExec_methr_a where "τExec_methr_a ≡ τExec_methr (Abs_check_instr check_instr')" abbreviation τExec_methr_d where "τExec_methr_d ≡ τExec_methr (Abs_check_instr check_instr)" abbreviation τExec_metht_a where "τExec_metht_a ≡ τExec_metht (Abs_check_instr check_instr')" abbreviation τExec_metht_d where "τExec_metht_d ≡ τExec_metht (Abs_check_instr check_instr)" lemma τExec_methr_refl: "τExec_methr ci P ins xt t h s s" by standard lemma τExec_methr_step': "⟦ τExec_methr ci P ins xt t h s (stk', loc', pc', xcp'); τexec_meth ci P ins xt t h (stk', loc', pc', xcp') s' ⟧ ⟹ τExec_methr ci P ins xt t h s s'" apply (rule rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) (*goals: 1. ‹⟦τExec_methr ci P ins xt t h s (stk', loc', pc', xcp'); τexec_meth ci P ins xt t h (stk', loc', pc', xcp') s'⟧ ⟹ τExec_methr ci P ins xt t h s ?b› 2. ‹⟦τExec_methr ci P ins xt t h s (stk', loc', pc', xcp'); τexec_meth ci P ins xt t h (stk', loc', pc', xcp') s'⟧ ⟹ τexec_meth ci P ins xt t h ?b s'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma τExec_methr_step: "⟦ τExec_methr ci P ins xt t h s (stk', loc', pc', xcp'); exec_meth ci P ins xt t h (stk', loc', pc', xcp') ε h s'; xcp' = None ⟹ τinstr P h stk' (ins ! pc') ⟧ ⟹ τExec_methr ci P ins xt t h s s'" apply (erule τExec_methr_step' (*‹⟦τExec_methr (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr::addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id::type) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option); τexec_meth ?ci ?P ?ins ?xt ?t ?h (?stk', ?loc', ?pc', ?xcp') (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option)⟧ ⟹ τExec_methr ?ci ?P ?ins ?xt ?t ?h ?s ?s'›*)) (*goal: ‹⟦τExec_methr (ci::('addr::addr, 'heap::type) check_instr) (P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (ins::'addr::addr instr list) (xt::(nat × nat × String.literal option × nat × nat) list) (t::'thread_id::type) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option); exec_meth ci P ins xt t h (stk', loc', pc', xcp') ⦃⦄ h (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); xcp' = None ⟹ τinstr P h stk' (ins ! pc')⟧ ⟹ τExec_methr ci P ins xt t h s s'›*) apply (rule τexec_methI (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; ?xcp = None ⟹ τinstr ?P ?h ?stk (?ins ! ?pc)⟧ ⟹ τexec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*)) (*goals: 1. ‹⟦exec_meth ci P ins xt t h (stk', loc', pc', xcp') ⦃⦄ h s'; xcp' = None ⟹ τinstr P h stk' (ins ! pc')⟧ ⟹ exec_meth ci P ins xt t h (stk', loc', pc', xcp') ⦃⦄ h s'› 2. ‹⟦exec_meth ci P ins xt t h (stk', loc', pc', xcp') ⦃⦄ h s'; xcp' = None ⟹ τinstr P h stk' (ins ! pc'); xcp' = None⟧ ⟹ τinstr P h stk' (ins ! pc')› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemmas τExec_methr_intros = τExec_methr_refl τExec_methr_step lemmas τExec_methr1step = τExec_methr_step[OF τExec_methr_refl] lemmas τExec_methr2step = τExec_methr_step[OF τExec_methr_step, OF τExec_methr_refl] lemmas τExec_methr3step = τExec_methr_step[OF τExec_methr_step, OF τExec_methr_step, OF τExec_methr_refl] lemma τExec_methr_cases [consumes 1, case_names refl step]: assumes "τExec_methr ci P ins xt t h s s'" obtains "s = s'" | stk' loc' pc' xcp' where "τExec_methr ci P ins xt t h s (stk', loc', pc', xcp')" "exec_meth ci P ins xt t h (stk', loc', pc', xcp') ε h s'" "xcp' = None ⟹ τinstr P h stk' (ins ! pc')" using assms (*‹τExec_methr ci P ins xt t h s s'›*) apply (rule rtranclp.cases (*‹⟦?r⇧*⇧* ?a1.0 ?a2.0; ⋀a. ⟦?a1.0 = a; ?a2.0 = a⟧ ⟹ ?P; ⋀a b c. ⟦?a1.0 = a; ?a2.0 = c; ?r⇧*⇧* a b; ?r b c⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀a. ⟦s = s' ⟹ thesis; ⋀stk' loc' pc' xcp'. ⟦τExec_methr ci P ins xt t h s (stk', loc', pc', xcp'); exec_meth ci P ins xt t h (stk', loc', pc', xcp') ⦃⦄ h s'; xcp' = None ⟹ τinstr P h stk' (ins ! pc')⟧ ⟹ thesis; s = a; s' = a⟧ ⟹ thesis› 2. ‹⋀a b c. ⟦s = s' ⟹ thesis; ⋀stk' loc' pc' xcp'. ⟦τExec_methr ci P ins xt t h s (stk', loc', pc', xcp'); exec_meth ci P ins xt t h (stk', loc', pc', xcp') ⦃⦄ h s'; xcp' = None ⟹ τinstr P h stk' (ins ! pc')⟧ ⟹ thesis; s = a; s' = c; τExec_methr ci P ins xt t h a b; τexec_meth ci P ins xt t h b c⟧ ⟹ thesis› discuss goal 1*) apply ((auto elim!: τexec_methE (*‹⟦τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s'; ⋀stk loc pc xcp. ⟦?s = (stk, loc, pc, xcp); exec_meth ?ci ?P ?ins ?xt ?t ?h (stk, loc, pc, xcp) ⦃⦄ ?h ?s'; xcp = None ⟹ τinstr ?P ?h stk (?ins ! pc)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*discuss goal 2*) apply ((auto elim!: τexec_methE (*‹⟦τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s'; ⋀stk loc pc xcp. ⟦?s = (stk, loc, pc, xcp); exec_meth ?ci ?P ?ins ?xt ?t ?h (stk, loc, pc, xcp) ⦃⦄ ?h ?s'; xcp = None ⟹ τinstr ?P ?h stk (?ins ! pc)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*))[1]) (*proven 2 subgoals*) . lemma τExec_methr_induct [consumes 1, case_names refl step]: "⟦ τExec_methr ci P ins xt t h s s'; Q s; ⋀stk loc pc xcp s'. ⟦ τExec_methr ci P ins xt t h s (stk, loc, pc, xcp); exec_meth ci P ins xt t h (stk, loc, pc, xcp) ε h s'; xcp = None ⟹ τinstr P h stk (ins ! pc); Q (stk, loc, pc, xcp) ⟧ ⟹ Q s' ⟧ ⟹ Q s'" apply (erule (1) rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goal: ‹⟦τExec_methr ci P ins xt t h s s'; Q s; ⋀stk loc pc xcp s'. ⟦τExec_methr ci P ins xt t h s (stk, loc, pc, xcp); exec_meth ci P ins xt t h (stk, loc, pc, xcp) ⦃⦄ h s'; xcp = None ⟹ τinstr P h stk (ins ! pc); Q (stk, loc, pc, xcp)⟧ ⟹ Q s'⟧ ⟹ Q s'›*) by (blast elim: τexec_methE (*‹⟦τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s'; ⋀stk loc pc xcp. ⟦?s = (stk, loc, pc, xcp); exec_meth ?ci ?P ?ins ?xt ?t ?h (stk, loc, pc, xcp) ⦃⦄ ?h ?s'; xcp = None ⟹ τinstr ?P ?h stk (?ins ! pc)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma τExec_methr_trans: "⟦ τExec_methr ci P ins xt t h s s'; τExec_methr ci P ins xt t h s' s'' ⟧ ⟹ τExec_methr ci P ins xt t h s s''" apply (rule rtranclp_trans (*‹⟦?r⇧*⇧* ?x ?y; ?r⇧*⇧* ?y ?z⟧ ⟹ ?r⇧*⇧* ?x ?z›*)) (*goals: 1. ‹⟦τExec_methr ci P ins xt t h s s'; τExec_methr ci P ins xt t h s' s''⟧ ⟹ τExec_methr ci P ins xt t h s ?y› 2. ‹⟦τExec_methr ci P ins xt t h s s'; τExec_methr ci P ins xt t h s' s''⟧ ⟹ τExec_methr ci P ins xt t h ?y s''› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemmas τExec_meth_induct_split = τExec_methr_induct[split_format (complete), consumes 1, case_names τExec_refl τExec_step] lemma τExec_methr_converse_cases [consumes 1, case_names refl step]: assumes "τExec_methr ci P ins xt t h s s'" obtains "s = s'" | stk loc pc xcp s'' where "s = (stk, loc, pc, xcp)" "exec_meth ci P ins xt t h (stk, loc, pc, xcp) ε h s''" "xcp = None ⟹ τinstr P h stk (ins ! pc)" "τExec_methr ci P ins xt t h s'' s'" using assms (*‹τExec_methr ci P ins xt t h s s'›*) apply (erule converse_rtranclpE (*‹⟦?r⇧*⇧* ?x ?z; ?x = ?z ⟹ ?P; ⋀y. ⟦?r ?x y; ?r⇧*⇧* y ?z⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹⟦s = s' ⟹ thesis; ⋀stk loc pc xcp s''. ⟦s = (stk, loc, pc, xcp); exec_meth ci P ins xt t h (stk, loc, pc, xcp) ⦃⦄ h s''; xcp = None ⟹ τinstr P h stk (ins ! pc); τExec_methr ci P ins xt t h s'' s'⟧ ⟹ thesis⟧ ⟹ thesis›*) by (blast elim: τexec_methE (*‹⟦τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s'; ⋀stk loc pc xcp. ⟦?s = (stk, loc, pc, xcp); exec_meth ?ci ?P ?ins ?xt ?t ?h (stk, loc, pc, xcp) ⦃⦄ ?h ?s'; xcp = None ⟹ τinstr ?P ?h stk (?ins ! pc)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) definition τexec_move :: "('addr, 'heap) check_instr ⇒ 'addr J1_prog ⇒ 'thread_id ⇒ 'addr expr1 ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "τexec_move ci P t e h = (λ(stk, loc, pc, xcp) s'. exec_move ci P t e h (stk, loc, pc, xcp) ε h s' ∧ τmove2 P h stk e pc xcp)" definition τexec_moves :: "('addr, 'heap) check_instr ⇒ 'addr J1_prog ⇒ 'thread_id ⇒ 'addr expr1 list ⇒ 'heap ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ ('addr val list × 'addr val list × pc × 'addr option) ⇒ bool" where "τexec_moves ci P t es h = (λ(stk, loc, pc, xcp) s'. exec_moves ci P t es h (stk, loc, pc, xcp) ε h s' ∧ τmoves2 P h stk es pc xcp)" lemma τexec_moveI: "⟦ exec_move ci P t e h (stk, loc, pc, xcp) ε h s'; τmove2 P h stk e pc xcp ⟧ ⟹ τexec_move ci P t e h (stk, loc, pc, xcp) s'" by (simp add: τexec_move_def (*‹τexec_move ?ci ?P ?t ?e ?h = (λ(stk, loc, pc, xcp) s'. exec_move ?ci ?P ?t ?e ?h (stk, loc, pc, xcp) ⦃⦄ ?h s' ∧ τmove2 ?P ?h stk ?e pc xcp)›*)) lemma τexec_moveE: assumes "τexec_move ci P t e h (stk, loc, pc, xcp) s'" obtains "exec_move ci P t e h (stk, loc, pc, xcp) ε h s'" "τmove2 P h stk e pc xcp" using assms (*‹τexec_move ci P t e h (stk, loc, pc, xcp) s'›*) by (simp add: τexec_move_def (*‹τexec_move ?ci ?P ?t ?e ?h = (λ(stk, loc, pc, xcp) s'. exec_move ?ci ?P ?t ?e ?h (stk, loc, pc, xcp) ⦃⦄ ?h s' ∧ τmove2 ?P ?h stk ?e pc xcp)›*)) lemma τexec_movesI: "⟦ exec_moves ci P t es h (stk, loc, pc, xcp) ε h s'; τmoves2 P h stk es pc xcp ⟧ ⟹ τexec_moves ci P t es h (stk, loc, pc, xcp) s'" by (simp add: τexec_moves_def (*‹τexec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) = (λ(stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) s'::'addr val list × 'addr val list × nat × 'addr option. exec_moves ?ci ?P ?t ?es ?h (stk, loc, pc, xcp) ⦃⦄ ?h s' ∧ τmoves2 ?P ?h stk ?es pc xcp)›*)) lemma τexec_movesE: assumes "τexec_moves ci P t es h (stk, loc, pc, xcp) s'" obtains "exec_moves ci P t es h (stk, loc, pc, xcp) ε h s'" "τmoves2 P h stk es pc xcp" using assms (*‹τexec_moves ci P t es h (stk, loc, pc, xcp) s'›*) by (simp add: τexec_moves_def (*‹τexec_moves ?ci ?P ?t ?es ?h = (λ(stk, loc, pc, xcp) s'. exec_moves ?ci ?P ?t ?es ?h (stk, loc, pc, xcp) ⦃⦄ ?h s' ∧ τmoves2 ?P ?h stk ?es pc xcp)›*)) lemma τexec_move_conv_τexec_meth: "τexec_move ci P t e = τexec_meth ci (compP2 P) (compE2 e) (compxE2 e 0 0) t" by (auto simp add: τexec_move_def (*‹τexec_move ?ci ?P ?t ?e ?h = (λ(stk, loc, pc, xcp) s'. exec_move ?ci ?P ?t ?e ?h (stk, loc, pc, xcp) ⦃⦄ ?h s' ∧ τmove2 ?P ?h stk ?e pc xcp)›*) exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) τmove2_iff (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp = (?pc < length (compE2 ?e) ∧ (?xcp = None ⟶ τinstr ?P ?h ?stk (compE2 ?e ! ?pc)))›*) compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*) intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) τexec_methI (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; ?xcp = None ⟹ τinstr ?P ?h ?stk (?ins ! ?pc)⟧ ⟹ τexec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) elim!: τexec_methE (*‹⟦τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s'; ⋀stk loc pc xcp. ⟦?s = (stk, loc, pc, xcp); exec_meth ?ci ?P ?ins ?xt ?t ?h (stk, loc, pc, xcp) ⦃⦄ ?h ?s'; xcp = None ⟹ τinstr ?P ?h stk (?ins ! pc)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) lemma τexec_moves_conv_τexec_meth: "τexec_moves ci P t es = τexec_meth ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t" by (auto simp add: τexec_moves_def (*‹τexec_moves ?ci ?P ?t ?es ?h = (λ(stk, loc, pc, xcp) s'. exec_moves ?ci ?P ?t ?es ?h (stk, loc, pc, xcp) ⦃⦄ ?h s' ∧ τmoves2 ?P ?h stk ?es pc xcp)›*) exec_moves_def (*‹exec_moves ?ci ?P ?t ?es ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*) τmoves2_iff (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp = (?pc < length (compEs2 ?es) ∧ (?xcp = None ⟶ τinstr ?P ?h ?stk (compEs2 ?es ! ?pc)))›*) compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*) intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) τexec_methI (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; ?xcp = None ⟹ τinstr ?P ?h ?stk (?ins ! ?pc)⟧ ⟹ τexec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) elim!: τexec_methE (*‹⟦τexec_meth ?ci ?P ?ins ?xt ?t ?h ?s ?s'; ⋀stk loc pc xcp. ⟦?s = (stk, loc, pc, xcp); exec_meth ?ci ?P ?ins ?xt ?t ?h (stk, loc, pc, xcp) ⦃⦄ ?h ?s'; xcp = None ⟹ τinstr ?P ?h stk (?ins ! pc)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) abbreviation τExec_mover where "τExec_mover ci P t e h == (τexec_move ci P t e h)^**" abbreviation τExec_movet where "τExec_movet ci P t e h == (τexec_move ci P t e h)^++" abbreviation τExec_mover_a where "τExec_mover_a ≡ τExec_mover (Abs_check_instr check_instr')" abbreviation τExec_mover_d where "τExec_mover_d ≡ τExec_mover (Abs_check_instr check_instr)" abbreviation τExec_movet_a where "τExec_movet_a ≡ τExec_movet (Abs_check_instr check_instr')" abbreviation τExec_movet_d where "τExec_movet_d ≡ τExec_movet (Abs_check_instr check_instr)" abbreviation τExec_movesr where "τExec_movesr ci P t e h == (τexec_moves ci P t e h)^**" abbreviation τExec_movest where "τExec_movest ci P t e h == (τexec_moves ci P t e h)^++" abbreviation τExec_movesr_a where "τExec_movesr_a ≡ τExec_movesr (Abs_check_instr check_instr')" abbreviation τExec_movesr_d where "τExec_movesr_d ≡ τExec_movesr (Abs_check_instr check_instr)" abbreviation τExec_movest_a where "τExec_movest_a ≡ τExec_movest (Abs_check_instr check_instr')" abbreviation τExec_movest_d where "τExec_movest_d ≡ τExec_movest (Abs_check_instr check_instr)" lemma τExecr_refl: "τExec_mover ci P t e h s s" sorry lemma τExecsr_refl: "τExec_movesr ci P t e h s s" by (rule rtranclp.rtrancl_refl (*‹?r⇧*⇧* ?a ?a›*)) lemma τExecr_step: "⟦ τExec_mover ci P t e h s (stk', loc', pc', xcp'); exec_move ci P t e h (stk', loc', pc', xcp') ε h s'; τmove2 P h stk' e pc' xcp' ⟧ ⟹ τExec_mover ci P t e h s s'" apply (rule rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) (*goals: 1. ‹⟦τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option); exec_move ci P t e h (stk', loc', pc', xcp') ⦃⦄ h (s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 P h stk' e pc' xcp'⟧ ⟹ τExec_mover ci P t e h s (?b::'addr val list × 'addr val list × nat × 'addr option)› 2. ‹⟦τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (stk'::'addr val list, loc'::'addr val list, pc'::nat, xcp'::'addr option); exec_move ci P t e h (stk', loc', pc', xcp') ⦃⦄ h (s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 P h stk' e pc' xcp'⟧ ⟹ τexec_move ci P t e h (?b::'addr val list × 'addr val list × nat × 'addr option) s'› discuss goal 1*) apply ((auto elim: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*discuss goal 2*) apply ((auto elim: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*proven 2 subgoals*) . lemma τExecsr_step: "⟦ τExec_movesr ci P t es h s (stk', loc', pc', xcp'); exec_moves ci P t es h (stk', loc', pc', xcp') ε h s'; τmoves2 P h stk' es pc' xcp' ⟧ ⟹ τExec_movesr ci P t es h s s'" apply (rule rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) (*goals: 1. ‹⟦τExec_movesr (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (es::'addr::addr expr1 list) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option); exec_moves ci P t es h (stk', loc', pc', xcp') ⦃⦄ h (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); τmoves2 P h stk' es pc' xcp'⟧ ⟹ τExec_movesr ci P t es h s (?b::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option)› 2. ‹⟦τExec_movesr (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (es::'addr::addr expr1 list) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option); exec_moves ci P t es h (stk', loc', pc', xcp') ⦃⦄ h (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); τmoves2 P h stk' es pc' xcp'⟧ ⟹ τexec_moves ci P t es h (?b::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) s'› discuss goal 1*) apply ((auto elim: τexec_movesI (*‹⟦exec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*discuss goal 2*) apply ((auto elim: τexec_movesI (*‹⟦exec_moves (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?es::'addr::addr expr1 list) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) ⦃⦄ ?h (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*proven 2 subgoals*) . lemma τExect_step: "⟦ τExec_movet ci P t e h s (stk', loc', pc', xcp'); exec_move ci P t e h (stk', loc', pc', xcp') ε h s'; τmove2 P h stk' e pc' xcp' ⟧ ⟹ τExec_movet ci P t e h s s'" apply (rule tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*)) (*goals: 1. ‹⟦τExec_movet ci P t e h s (stk', loc', pc', xcp'); exec_move ci P t e h (stk', loc', pc', xcp') ⦃⦄ h s'; τmove2 P h stk' e pc' xcp'⟧ ⟹ τExec_movet ci P t e h s ?b› 2. ‹⟦τExec_movet ci P t e h s (stk', loc', pc', xcp'); exec_move ci P t e h (stk', loc', pc', xcp') ⦃⦄ h s'; τmove2 P h stk' e pc' xcp'⟧ ⟹ τexec_move ci P t e h ?b s'› discuss goal 1*) apply ((auto intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*discuss goal 2*) apply ((auto intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*proven 2 subgoals*) . lemma τExecst_step: "⟦ τExec_movest ci P t es h s (stk', loc', pc', xcp'); exec_moves ci P t es h (stk', loc', pc', xcp') ε h s'; τmoves2 P h stk' es pc' xcp' ⟧ ⟹ τExec_movest ci P t es h s s'" apply (rule tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*)) (*goals: 1. ‹⟦τExec_movest ci P t es h s (stk', loc', pc', xcp'); exec_moves ci P t es h (stk', loc', pc', xcp') ⦃⦄ h s'; τmoves2 P h stk' es pc' xcp'⟧ ⟹ τExec_movest ci P t es h s ?b› 2. ‹⟦τExec_movest ci P t es h s (stk', loc', pc', xcp'); exec_moves ci P t es h (stk', loc', pc', xcp') ⦃⦄ h s'; τmoves2 P h stk' es pc' xcp'⟧ ⟹ τexec_moves ci P t es h ?b s'› discuss goal 1*) apply ((auto intro: τexec_movesI (*‹⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*discuss goal 2*) apply ((auto intro: τexec_movesI (*‹⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*))[1]) (*proven 2 subgoals*) . lemmas τExecr1step = τExecr_step[OF τExecr_refl] lemmas τExecr2step = τExecr_step[OF τExecr_step, OF τExecr_refl] lemmas τExecr3step = τExecr_step[OF τExecr_step, OF τExecr_step, OF τExecr_refl] lemmas τExecsr1step = τExecsr_step[OF τExecsr_refl] lemmas τExecsr2step = τExecsr_step[OF τExecsr_step, OF τExecsr_refl] lemmas τExecsr3step = τExecsr_step[OF τExecsr_step, OF τExecsr_step, OF τExecsr_refl] lemma τExect1step: "⟦ exec_move ci P t e h s ε h s'; τmove2 P h (fst s) e (fst (snd (snd s))) (snd (snd (snd s))) ⟧ ⟹ τExec_movet ci P t e h s s'" apply (rule tranclp.r_into_trancl (*‹(?r::?'a ⇒ ?'a ⇒ bool) (?a::?'a) (?b::?'a) ⟹ ?r⁺⁺ ?a ?b›*)) (*goal: ‹⟦exec_move ci P t e h s ⦃⦄ h s'; τmove2 P h (fst s) e (fst (snd (snd s))) (snd (snd (snd s)))⟧ ⟹ τExec_movet ci P t e h s s'›*) apply (cases s) (*goal: ‹⟦exec_move ci P t e h s ⦃⦄ h s'; τmove2 P h (fst s) e (fst (snd (snd s))) (snd (snd (snd s)))⟧ ⟹ τexec_move ci P t e h s s'›*) by (auto intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*)) lemmas τExect2step = τExect_step[OF τExect1step] lemmas τExect3step = τExect_step[OF τExect_step, OF τExect1step] lemma τExecst1step: "⟦ exec_moves ci P t es h s ε h s'; τmoves2 P h (fst s) es (fst (snd (snd s))) (snd (snd (snd s))) ⟧ ⟹ τExec_movest ci P t es h s s'" apply (rule tranclp.r_into_trancl (*‹?r ?a ?b ⟹ ?r⁺⁺ ?a ?b›*)) (*goal: ‹⟦exec_moves ci P t es h s ⦃⦄ h s'; τmoves2 P h (fst s) es (fst (snd (snd s))) (snd (snd (snd s)))⟧ ⟹ τExec_movest ci P t es h s s'›*) apply (cases s) (*goal: ‹⟦exec_moves ci P t es h s ⦃⦄ h s'; τmoves2 P h (fst s) es (fst (snd (snd s))) (snd (snd (snd s)))⟧ ⟹ τexec_moves ci P t es h s s'›*) by (auto intro: τexec_movesI (*‹⟦exec_moves (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?es::'addr::addr expr1 list) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) ⦃⦄ ?h (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*)) lemmas τExecst2step = τExecst_step[OF τExecst1step] lemmas τExecst3step = τExecst_step[OF τExecst_step, OF τExecst1step] lemma τExecr_induct [consumes 1, case_names refl step]: assumes major: "τExec_mover ci P t e h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')" and refl: "Q stk loc pc xcp" and step: "⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦ τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); Q stk' loc' pc' xcp' ⟧ ⟹ Q stk'' loc'' pc'' xcp''" shows "Q stk'' loc'' pc'' xcp''" using major (*‹τExec_mover ci P t e h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')›*) refl (*‹Q stk loc pc xcp›*) apply (rule rtranclp_induct4 (*‹⟦?r⇧*⇧* (?ax, ?ay, ?az, ?aw) (?bx, ?by, ?bz, ?bw); ?P ?ax ?ay ?az ?aw; ⋀a aa ab b ac ad ae ba. ⟦?r⇧*⇧* (?ax, ?ay, ?az, ?aw) (a, aa, ab, b); ?r (a, aa, ab, b) (ac, ad, ae, ba); ?P a aa ab b⟧ ⟹ ?P ac ad ae ba⟧ ⟹ ?P ?bx ?by ?bz ?bw›*)) (*goal: ‹Q stk'' loc'' pc'' xcp''›*) apply (rule step (*‹⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20); τexec_move ci P t e h (?stk'20, ?loc'20, ?pc'20, ?xcp'20) (?stk''20, ?loc''20, ?pc''20, ?xcp''20); Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20⟧ ⟹ Q ?stk''20 ?loc''20 ?pc''20 ?xcp''20›*)) (*goals: 1. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_move ci P t e h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ τExec_mover ci P t e h (stk, loc, pc, xcp) (?stk'22 a aa ab b ac ad ae ba, ?loc'22 a aa ab b ac ad ae ba, ?pc'22 a aa ab b ac ad ae ba, ?xcp'22 a aa ab b ac ad ae ba)› 2. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_move ci P t e h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ τexec_move ci P t e h (?stk'22 a aa ab b ac ad ae ba, ?loc'22 a aa ab b ac ad ae ba, ?pc'22 a aa ab b ac ad ae ba, ?xcp'22 a aa ab b ac ad ae ba) (ac, ad, ae, ba)› 3. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_move ci P t e h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ Q (?stk'22 a aa ab b ac ad ae ba) (?loc'22 a aa ab b ac ad ae ba) (?pc'22 a aa ab b ac ad ae ba) (?xcp'22 a aa ab b ac ad ae ba)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma τExecsr_induct [consumes 1, case_names refl step]: assumes major: "τExec_movesr ci P t es h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')" and refl: "Q stk loc pc xcp" and step: "⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦ τExec_movesr ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_moves ci P t es h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); Q stk' loc' pc' xcp' ⟧ ⟹ Q stk'' loc'' pc'' xcp''" shows "Q stk'' loc'' pc'' xcp''" using major (*‹τExec_movesr ci P t es h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')›*) refl (*‹Q stk loc pc xcp›*) apply (rule rtranclp_induct4 (*‹⟦?r⇧*⇧* (?ax, ?ay, ?az, ?aw) (?bx, ?by, ?bz, ?bw); ?P ?ax ?ay ?az ?aw; ⋀a aa ab b ac ad ae ba. ⟦?r⇧*⇧* (?ax, ?ay, ?az, ?aw) (a, aa, ab, b); ?r (a, aa, ab, b) (ac, ad, ae, ba); ?P a aa ab b⟧ ⟹ ?P ac ad ae ba⟧ ⟹ ?P ?bx ?by ?bz ?bw›*)) (*goal: ‹Q stk'' loc'' pc'' xcp''›*) apply (rule step (*‹⟦τExec_movesr ci P t es h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20); τexec_moves ci P t es h (?stk'20, ?loc'20, ?pc'20, ?xcp'20) (?stk''20, ?loc''20, ?pc''20, ?xcp''20); Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20⟧ ⟹ Q ?stk''20 ?loc''20 ?pc''20 ?xcp''20›*)) (*goals: 1. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_movesr ci P t es h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ τExec_movesr ci P t es h (stk, loc, pc, xcp) (?stk'22 a aa ab b ac ad ae ba, ?loc'22 a aa ab b ac ad ae ba, ?pc'22 a aa ab b ac ad ae ba, ?xcp'22 a aa ab b ac ad ae ba)› 2. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_movesr ci P t es h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ τexec_moves ci P t es h (?stk'22 a aa ab b ac ad ae ba, ?loc'22 a aa ab b ac ad ae ba, ?pc'22 a aa ab b ac ad ae ba, ?xcp'22 a aa ab b ac ad ae ba) (ac, ad, ae, ba)› 3. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_movesr ci P t es h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ Q (?stk'22 a aa ab b ac ad ae ba) (?loc'22 a aa ab b ac ad ae ba) (?pc'22 a aa ab b ac ad ae ba) (?xcp'22 a aa ab b ac ad ae ba)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) lemma τExect_induct [consumes 1, case_names base step]: assumes major: "τExec_movet ci P t e h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')" and base: "⋀stk' loc' pc' xcp'. τexec_move ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ Q stk' loc' pc' xcp'" and step: "⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦ τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); Q stk' loc' pc' xcp' ⟧ ⟹ Q stk'' loc'' pc'' xcp''" shows "Q stk'' loc'' pc'' xcp''" using major (*‹τExec_movet ci P t e h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')›*) apply (rule tranclp_induct4 (*‹⟦?r⁺⁺ (?ax, ?ay, ?az, ?aw) (?bx, ?by, ?bz, ?bw); ⋀a aa ab b. ?r (?ax, ?ay, ?az, ?aw) (a, aa, ab, b) ⟹ ?P a aa ab b; ⋀a aa ab b ac ad ae ba. ⟦?r⁺⁺ (?ax, ?ay, ?az, ?aw) (a, aa, ab, b); ?r (a, aa, ab, b) (ac, ad, ae, ba); ?P a aa ab b⟧ ⟹ ?P ac ad ae ba⟧ ⟹ ?P ?bx ?by ?bz ?bw›*)) (*goals: 1. ‹⋀a aa ab b. τexec_move ci P t e h (stk, loc, pc, xcp) (a, aa, ab, b) ⟹ Q a aa ab b› 2. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_movet ci P t e h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_move ci P t e h (a, aa, ab, b) (ac, ad, ae, ba); Q a aa ab b⟧ ⟹ Q ac ad ae ba› discuss goal 1*) apply (erule base (*‹τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (?stk'20::'addr val list, ?loc'20::'addr val list, ?pc'20::nat, ?xcp'20::'addr option) ⟹ (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) ?stk'20 ?loc'20 ?pc'20 ?xcp'20›*) step (*‹⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (?stk'20::'addr val list, ?loc'20::'addr val list, ?pc'20::nat, ?xcp'20::'addr option); τexec_move ci P t e h (?stk'20, ?loc'20, ?pc'20, ?xcp'20) (?stk''20::'addr val list, ?loc''20::'addr val list, ?pc''20::nat, ?xcp''20::'addr option); (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) ?stk'20 ?loc'20 ?pc'20 ?xcp'20⟧ ⟹ Q ?stk''20 ?loc''20 ?pc''20 ?xcp''20›*)) (*discuss goal 2*) apply (erule base (*‹τexec_move ci P t e h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20) ⟹ Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20›*) step (*‹⟦τExec_movet ci P t e h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20); τexec_move ci P t e h (?stk'20, ?loc'20, ?pc'20, ?xcp'20) (?stk''20, ?loc''20, ?pc''20, ?xcp''20); Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20⟧ ⟹ Q ?stk''20 ?loc''20 ?pc''20 ?xcp''20›*)) (*goals: 1. ‹⋀(a::'addr val list) (aa::'addr val list) (ab::nat) (b::'addr option) (ac::'addr val list) (ad::'addr val list) (ae::nat) ba::'addr option. ⟦τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (a, aa, ab, b) (ac, ad, ae, ba); (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) a aa ab b⟧ ⟹ τexec_move ci P t e h (a, aa, ab, b) (ac, ad, ae, ba)› 2. ‹⋀(a::'addr val list) (aa::'addr val list) (ab::nat) (b::'addr option) (ac::'addr val list) (ad::'addr val list) (ae::nat) ba::'addr option. ⟦τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (a, aa, ab, b) (ac, ad, ae, ba); (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) a aa ab b⟧ ⟹ Q a aa ab b› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) (*proven 2 subgoals*) lemma τExecst_induct [consumes 1, case_names base step]: assumes major: "τExec_movest ci P t es h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')" and base: "⋀stk' loc' pc' xcp'. τexec_moves ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ Q stk' loc' pc' xcp'" and step: "⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦ τExec_movest ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_moves ci P t es h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); Q stk' loc' pc' xcp' ⟧ ⟹ Q stk'' loc'' pc'' xcp''" shows "Q stk'' loc'' pc'' xcp''" using major (*‹τExec_movest ci P t es h (stk, loc, pc, xcp) (stk'', loc'', pc'', xcp'')›*) apply (rule tranclp_induct4 (*‹⟦?r⁺⁺ (?ax, ?ay, ?az, ?aw) (?bx, ?by, ?bz, ?bw); ⋀a aa ab b. ?r (?ax, ?ay, ?az, ?aw) (a, aa, ab, b) ⟹ ?P a aa ab b; ⋀a aa ab b ac ad ae ba. ⟦?r⁺⁺ (?ax, ?ay, ?az, ?aw) (a, aa, ab, b); ?r (a, aa, ab, b) (ac, ad, ae, ba); ?P a aa ab b⟧ ⟹ ?P ac ad ae ba⟧ ⟹ ?P ?bx ?by ?bz ?bw›*)) (*goals: 1. ‹⋀(a::'addr val list) (aa::'addr val list) (ab::nat) b::'addr option. τexec_moves (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (a, aa, ab, b) ⟹ (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) a aa ab b› 2. ‹⋀(a::'addr val list) (aa::'addr val list) (ab::nat) (b::'addr option) (ac::'addr val list) (ad::'addr val list) (ae::nat) ba::'addr option. ⟦τExec_movest (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (a, aa, ab, b); τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba); (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) a aa ab b⟧ ⟹ Q ac ad ae ba› discuss goal 1*) apply (erule base (*‹τexec_moves ci P t es h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20) ⟹ Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20›*) step (*‹⟦τExec_movest ci P t es h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20); τexec_moves ci P t es h (?stk'20, ?loc'20, ?pc'20, ?xcp'20) (?stk''20, ?loc''20, ?pc''20, ?xcp''20); Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20⟧ ⟹ Q ?stk''20 ?loc''20 ?pc''20 ?xcp''20›*)) (*discuss goal 2*) apply (erule base (*‹τexec_moves ci P t es h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20) ⟹ Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20›*) step (*‹⟦τExec_movest ci P t es h (stk, loc, pc, xcp) (?stk'20, ?loc'20, ?pc'20, ?xcp'20); τexec_moves ci P t es h (?stk'20, ?loc'20, ?pc'20, ?xcp'20) (?stk''20, ?loc''20, ?pc''20, ?xcp''20); Q ?stk'20 ?loc'20 ?pc'20 ?xcp'20⟧ ⟹ Q ?stk''20 ?loc''20 ?pc''20 ?xcp''20›*)) (*goals: 1. ‹⋀(a::'addr val list) (aa::'addr val list) (ab::nat) (b::'addr option) (ac::'addr val list) (ad::'addr val list) (ae::nat) ba::'addr option. ⟦τexec_moves (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (a, aa, ab, b) (ac, ad, ae, ba); (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) a aa ab b⟧ ⟹ τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba)› 2. ‹⋀(a::'addr val list) (aa::'addr val list) (ab::nat) (b::'addr option) (ac::'addr val list) (ad::'addr val list) (ae::nat) ba::'addr option. ⟦τexec_moves (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (a, aa, ab, b) (ac, ad, ae, ba); (Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) a aa ab b⟧ ⟹ Q a aa ab b› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) (*proven 2 subgoals*) lemma τExec_mover_τExec_methr: "τExec_mover ci P t e = τExec_methr ci (compP2 P) (compE2 e) (compxE2 e 0 0) t" by (simp only: τexec_move_conv_τexec_meth (*‹τexec_move ?ci ?P ?t ?e = τexec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) lemma τExec_movesr_τExec_methr: "τExec_movesr ci P t es = τExec_methr ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t" by (simp only: τexec_moves_conv_τexec_meth (*‹τexec_moves ?ci ?P ?t ?es = τexec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*)) lemma τExec_movet_τExec_metht: "τExec_movet ci P t e = τExec_metht ci (compP2 P) (compE2 e) (compxE2 e 0 0) t" by (simp only: τexec_move_conv_τexec_meth (*‹τexec_move ?ci ?P ?t ?e = τexec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) lemma τExec_movest_τExec_metht: "τExec_movest ci P t es = τExec_metht ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t" by (simp only: τexec_moves_conv_τexec_meth (*‹τexec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) = τexec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es (0::nat) (0::nat)) ?t›*)) lemma τExec_mover_trans: "⟦ τExec_mover ci P t e h s s'; τExec_mover ci P t e h s' s'' ⟧ ⟹ τExec_mover ci P t e h s s''" apply (rule rtranclp_trans (*‹⟦?r⇧*⇧* ?x ?y; ?r⇧*⇧* ?y ?z⟧ ⟹ ?r⇧*⇧* ?x ?z›*)) (*goals: 1. ‹⟦τExec_mover ci P t e h s s'; τExec_mover ci P t e h s' s''⟧ ⟹ τExec_mover ci P t e h s ?y› 2. ‹⟦τExec_mover ci P t e h s s'; τExec_mover ci P t e h s' s''⟧ ⟹ τExec_mover ci P t e h ?y s''› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma τExec_movesr_trans: "⟦ τExec_movesr ci P t es h s s'; τExec_movesr ci P t es h s' s'' ⟧ ⟹ τExec_movesr ci P t es h s s''" apply (rule rtranclp_trans (*‹⟦?r⇧*⇧* ?x ?y; ?r⇧*⇧* ?y ?z⟧ ⟹ ?r⇧*⇧* ?x ?z›*)) (*goals: 1. ‹⟦τExec_movesr (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (s'::'addr val list × 'addr val list × nat × 'addr option); τExec_movesr ci P t es h s' (s''::'addr val list × 'addr val list × nat × 'addr option)⟧ ⟹ τExec_movesr ci P t es h s (?y::'addr val list × 'addr val list × nat × 'addr option)› 2. ‹⟦τExec_movesr (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (s'::'addr val list × 'addr val list × nat × 'addr option); τExec_movesr ci P t es h s' (s''::'addr val list × 'addr val list × nat × 'addr option)⟧ ⟹ τExec_movesr ci P t es h (?y::'addr val list × 'addr val list × nat × 'addr option) s''› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma τExec_movet_trans: "⟦ τExec_movet ci P t e h s s'; τExec_movet ci P t e h s' s'' ⟧ ⟹ τExec_movet ci P t e h s s''" apply (rule tranclp_trans (*‹⟦?r⁺⁺ ?x ?y; ?r⁺⁺ ?y ?z⟧ ⟹ ?r⁺⁺ ?x ?z›*)) (*goals: 1. ‹⟦τExec_movet ci P t e h s s'; τExec_movet ci P t e h s' s''⟧ ⟹ τExec_movet ci P t e h s ?y› 2. ‹⟦τExec_movet ci P t e h s s'; τExec_movet ci P t e h s' s''⟧ ⟹ τExec_movet ci P t e h ?y s''› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma τExec_movest_trans: "⟦ τExec_movest ci P t es h s s'; τExec_movest ci P t es h s' s'' ⟧ ⟹ τExec_movest ci P t es h s s''" apply (rule tranclp_trans (*‹⟦?r⁺⁺ ?x ?y; ?r⁺⁺ ?y ?z⟧ ⟹ ?r⁺⁺ ?x ?z›*)) (*goals: 1. ‹⟦τExec_movest ci P t es h s s'; τExec_movest ci P t es h s' s''⟧ ⟹ τExec_movest ci P t es h s ?y› 2. ‹⟦τExec_movest ci P t es h s s'; τExec_movest ci P t es h s' s''⟧ ⟹ τExec_movest ci P t es h ?y s''› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma τexec_move_into_τexec_moves: "τexec_move ci P t e h s s' ⟹ τexec_moves ci P t (e # es) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_moves ci P t (e # es) h s s'›*) by (auto elim!: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro!: τexec_movesI (*‹⟦exec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) simp add: exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*) exec_moves_def (*‹exec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es (0::nat) (0::nat)) ?t›*) intro: τmoves2Hd (*‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmoves2 ?P ?h ?stk (?e # (?es::'addr expr1 list)) ?pc ?xcp›*)) lemma τExec_mover_τExec_movesr: "τExec_mover ci P t e h s s' ⟹ τExec_movesr ci P t (e # es) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_movesr (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) ((e::'addr::addr expr1) # (es::'addr::addr expr1 list)) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) s› 2. ‹⋀(y::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) z::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option. ⟦τExec_mover (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e::'addr::addr expr1) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) y; τexec_move ci P t e h y z; τExec_movesr ci P t (e # (es::'addr::addr expr1 list)) h s y⟧ ⟹ τExec_movesr ci P t (e # es) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) τexec_move_into_τexec_moves (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?e # ?es) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) τexec_move_into_τexec_moves (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ τexec_moves ?ci ?P ?t (?e # (?es::'addr::addr expr1 list)) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma τExec_movet_τExec_movest: "τExec_movet ci P t e h s s' ⟹ τExec_movest ci P t (e # es) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movest ci P t (e # es) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movest ci P t (e # es) h s y⟧ ⟹ τExec_movest ci P t (e # es) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) τexec_move_into_τexec_moves (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?e # ?es) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) τexec_move_into_τexec_moves (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?e # ?es) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma exec_moves_append: "exec_moves ci P t es h s ta h' s' ⟹ exec_moves ci P t (es @ es') h s ta h' s'" by (auto simp add: exec_moves_def (*‹exec_moves ?ci ?P ?t ?es ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*)) lemma τexec_moves_append: "τexec_moves ci P t es h s s' ⟹ τexec_moves ci P t (es @ es') h s s'" apply (cases s) (*goal: ‹τexec_moves ci P t es h s s' ⟹ τexec_moves ci P t (es @ es') h s s'›*) by (auto elim!: τexec_movesE (*‹⟦τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro!: τexec_movesI (*‹⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) exec_moves_append (*‹exec_moves ?ci ?P ?t ?es ?h ?s ?ta ?h' ?s' ⟹ exec_moves ?ci ?P ?t (?es @ ?es') ?h ?s ?ta ?h' ?s'›*)) lemma τExec_movesr_append [intro]: "τExec_movesr ci P t es h s s' ⟹ τExec_movesr ci P t (es @ es') h s s'" apply (induct rule: rtranclp_induct (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); (?P::?'a::type ⇒ bool) ?a; ⋀(y::?'a::type) z::?'a::type. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_movesr ci P t (es @ es') h s s› 2. ‹⋀y z. ⟦τExec_movesr ci P t es h s y; τexec_moves ci P t es h y z; τExec_movesr ci P t (es @ es') h s y⟧ ⟹ τExec_movesr ci P t (es @ es') h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) τexec_moves_append (*‹τexec_moves ?ci ?P ?t ?es ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?es @ ?es') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) τexec_moves_append (*‹τexec_moves ?ci ?P ?t ?es ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?es @ ?es') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma τExec_movest_append [intro]: "τExec_movest ci P t es h s s' ⟹ τExec_movest ci P t (es @ es') h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_moves ci P t es h s y ⟹ τExec_movest ci P t (es @ es') h s y› 2. ‹⋀y z. ⟦τExec_movest ci P t es h s y; τexec_moves ci P t es h y z; τExec_movest ci P t (es @ es') h s y⟧ ⟹ τExec_movest ci P t (es @ es') h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) τexec_moves_append (*‹τexec_moves ?ci ?P ?t ?es ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?es @ ?es') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) τexec_moves_append (*‹τexec_moves ?ci ?P ?t ?es ?h ?s ?s' ⟹ τexec_moves ?ci ?P ?t (?es @ ?es') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma append_exec_moves: assumes len: "length vs = length es'" and exec: "exec_moves ci P t es h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" shows "exec_moves ci P t (es' @ es) h ((stk @ vs), loc, (length (compEs2 es') + pc), xcp) ta h' ((stk' @ vs), loc', (length (compEs2 es') + pc'), xcp')" proof (-) (*goal: ‹exec_moves ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) ta h' (stk' @ vs, loc', length (compEs2 es') + pc', xcp')›*) from exec (*‹exec_moves ci P t es h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" unfolding exec_moves_def (*goal: ‹exec_meth ci (compP2 P) (compEs2 es) (compxEs2 es 0 0) t h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) . hence "exec_meth ci (compP2 P) (compEs2 es) (stack_xlift (length vs) (compxEs2 es 0 0)) t h ((stk @ vs), loc, pc, xcp) ta h' ((stk' @ vs), loc', pc', xcp')" by (rule exec_meth_stk_offer (*‹exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ exec_meth ?ci ?P ?ins (stack_xlift (length (?stk''::'addr val list)) ?xt) ?t ?h (?stk @ ?stk'', ?loc, ?pc, ?xcp) ?ta ?h' (?stk' @ ?stk'', ?loc', ?pc', ?xcp')›*)) hence "exec_meth ci (compP2 P) (compEs2 es' @ compEs2 es) (compxEs2 es' 0 0 @ shift (length (compEs2 es')) (stack_xlift (length (vs)) (compxEs2 es 0 0))) t h ((stk @ vs), loc, (length (compEs2 es') + pc), xcp) ta h' ((stk' @ vs), loc', (length (compEs2 es') + pc'), xcp')" apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹jump_ok (compEs2 es) 0 ?n› 2. ‹pcs (compxEs2 es' 0 0) ⊆ {0..<length (compEs2 es')}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹exec_moves ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) ta h' (stk' @ vs, loc', length (compEs2 es') + pc', xcp')›*) by (simp add: exec_moves_def (*‹exec_moves ?ci ?P ?t ?es ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*) stack_xlift_compxEs2 (*‹stack_xlift ?n (compxEs2 ?es ?pc ?d) = compxEs2 ?es ?pc (?n + ?d)›*) shift_compxEs2 (*‹shift ?pc (compxEs2 ?es ?pc' ?d) = compxEs2 ?es (?pc' + ?pc) ?d›*) len (*‹length vs = length es'›*)) qed lemma append_τexec_moves: "⟦ length vs = length es'; τexec_moves ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟧ ⟹ τexec_moves ci P t (es' @ es) h ((stk @ vs), loc, (length (compEs2 es') + pc), xcp) ((stk' @ vs), loc', (length (compEs2 es') + pc'), xcp')" by (auto elim!: τexec_movesE (*‹⟦τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_movesI (*‹⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) append_exec_moves (*‹⟦length ?vs = length ?es'; exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp')⟧ ⟹ exec_moves ?ci ?P ?t (?es' @ ?es) ?h (?stk @ ?vs, ?loc, length (compEs2 ?es') + ?pc, ?xcp) ?ta ?h' (?stk' @ ?vs, ?loc', length (compEs2 ?es') + ?pc', ?xcp')›*) τmoves2_stk_append (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp ⟹ τmoves2 ?P ?h (?stk @ ?vs) ?es ?pc ?xcp›*) append_τmoves2 (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?es' @ ?es) (length (compEs2 ?es') + ?pc) ?xcp›*)) lemma append_τExec_movesr: assumes len: "length vs = length es'" shows "τExec_movesr ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movesr ci P t (es' @ es) h ((stk @ vs), loc, (length (compEs2 es') + pc), xcp) ((stk' @ vs), loc', (length (compEs2 es') + pc'), xcp')" apply (induct rule: rtranclp_induct4 (*‹⟦?r⇧*⇧* (?ax, ?ay, ?az, ?aw) (?bx, ?by, ?bz, ?bw); ?P ?ax ?ay ?az ?aw; ⋀a aa ab b ac ad ae ba. ⟦?r⇧*⇧* (?ax, ?ay, ?az, ?aw) (a, aa, ab, b); ?r (a, aa, ab, b) (ac, ad, ae, ba); ?P a aa ab b⟧ ⟹ ?P ac ad ae ba⟧ ⟹ ?P ?bx ?by ?bz ?bw›*)) (*goals: 1. ‹τExec_movesr ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) (stk @ vs, loc, length (compEs2 es') + pc, xcp)› 2. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_movesr ci P t es h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba); τExec_movesr ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) (a @ vs, aa, length (compEs2 es') + ab, b)⟧ ⟹ τExec_movesr ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) (ac @ vs, ad, length (compEs2 es') + ae, ba)› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) append_τexec_moves[OF len] (*‹τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_moves ?ci ?P ?t (es' @ ?es) ?h (?stk @ vs, ?loc, length (compEs2 es') + ?pc, ?xcp) (?stk' @ vs, ?loc', length (compEs2 es') + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) append_τexec_moves[OF len] (*‹τexec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_moves ?ci ?P ?t ((es'::'addr expr1 list) @ ?es) ?h (?stk @ (vs::'addr val list), ?loc, length (compEs2 es') + ?pc, ?xcp) (?stk' @ vs, ?loc', length (compEs2 es') + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma append_τExec_movest: assumes len: "length vs = length es'" shows "τExec_movest ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movest ci P t (es' @ es) h ((stk @ vs), loc, (length (compEs2 es') + pc), xcp) ((stk' @ vs), loc', (length (compEs2 es') + pc'), xcp')" apply (induct rule: tranclp_induct4 (*‹⟦(?r::?'a × ?'b × ?'c × ?'d ⇒ ?'a × ?'b × ?'c × ?'d ⇒ bool)⁺⁺ (?ax::?'a, ?ay::?'b, ?az::?'c, ?aw::?'d) (?bx::?'a, ?by::?'b, ?bz::?'c, ?bw::?'d); ⋀(a::?'a) (aa::?'b) (ab::?'c) b::?'d. ?r (?ax, ?ay, ?az, ?aw) (a, aa, ab, b) ⟹ (?P::?'a ⇒ ?'b ⇒ ?'c ⇒ ?'d ⇒ bool) a aa ab b; ⋀(a::?'a) (aa::?'b) (ab::?'c) (b::?'d) (ac::?'a) (ad::?'b) (ae::?'c) ba::?'d. ⟦?r⁺⁺ (?ax, ?ay, ?az, ?aw) (a, aa, ab, b); ?r (a, aa, ab, b) (ac, ad, ae, ba); ?P a aa ab b⟧ ⟹ ?P ac ad ae ba⟧ ⟹ ?P ?bx ?by ?bz ?bw›*)) (*goals: 1. ‹⋀a aa ab b. τexec_moves ci P t es h (stk, loc, pc, xcp) (a, aa, ab, b) ⟹ τExec_movest ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) (a @ vs, aa, length (compEs2 es') + ab, b)› 2. ‹⋀a aa ab b ac ad ae ba. ⟦τExec_movest ci P t es h (stk, loc, pc, xcp) (a, aa, ab, b); τexec_moves ci P t es h (a, aa, ab, b) (ac, ad, ae, ba); τExec_movest ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) (a @ vs, aa, length (compEs2 es') + ab, b)⟧ ⟹ τExec_movest ci P t (es' @ es) h (stk @ vs, loc, length (compEs2 es') + pc, xcp) (ac @ vs, ad, length (compEs2 es') + ae, ba)› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) append_τexec_moves[OF len] (*‹τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_moves ?ci ?P ?t (es' @ ?es) ?h (?stk @ vs, ?loc, length (compEs2 es') + ?pc, ?xcp) (?stk' @ vs, ?loc', length (compEs2 es') + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) append_τexec_moves[OF len] (*‹τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_moves ?ci ?P ?t (es' @ ?es) ?h (?stk @ vs, ?loc, length (compEs2 es') + ?pc, ?xcp) (?stk' @ vs, ?loc', length (compEs2 es') + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma NewArray_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (newA T⌊e⌉) h s s'" apply (cases s) (*goal: ‹τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ci P t (newA (T::ty)⌊e⌉) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_newArrayI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (newA ?T⌊?e⌉) ?h ?s ?ta ?h' ?s'›*)) lemma Cast_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (Cast T e) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (Cast T e) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CastI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (Cast ?T ?e) ?h ?s ?ta ?h' ?s'›*)) lemma InstanceOf_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e instanceof T) h s s'" apply (cases s) (*goal: ‹τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) (s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ci P t (e instanceof (T::ty)) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_InstanceOfI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e instanceof ?T) ?h ?s ?ta ?h' ?s'›*)) lemma BinOp_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e «bop» e') h s s'" apply (cases s) (*goal: ‹τexec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e::'addr::addr expr1) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ τexec_move ci P t (e «bop::bop» (e'::'addr::addr expr1)) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_BinOpI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e «?bop» ?e') ?h ?s ?ta ?h' ?s'›*)) lemma BinOp_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e «bop» e') h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_BinOpI2 (*‹exec_move ?ci ?P ?t ?e2.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e1.0 «?bop» ?e2.0) ?h (?stk @ [?v], ?loc, length (compE2 ?e1.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v], ?loc', length (compE2 ?e1.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h (?stk @ ?vs) ?e ?pc ?xcp›*)) lemma LAss_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (V := e) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (V:=e) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_LAssI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?V:=?e) ?h ?s ?ta ?h' ?s'›*)) lemma AAcc_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e⌊i⌉) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e⌊i⌉) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_AAccI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e⌊?e'⌉) ?h ?s ?ta ?h' ?s'›*)) lemma AAcc_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e⌊e'⌉) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_AAccI2 (*‹exec_move ?ci ?P ?t ?e2.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e1.0⌊?e2.0⌉) ?h (?stk @ [?v], ?loc, length (compE2 ?e1.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v], ?loc', length (compE2 ?e1.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h (?stk @ ?vs) ?e ?pc ?xcp›*)) lemma AAss_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e⌊i⌉ := e') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e⌊i⌉ := e') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹(?pc::nat) < length (compE2 (?e::'addr expr1)) ⟹ τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ?e ?pc ⌊?xcp::'addr⌋› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (newA (?T::ty)⌊?e⌉) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (Cast (?T::ty) ?e) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Cast (?T::ty) (?e::'addr expr1)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e instanceof (?T::ty)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e::'addr expr1) instanceof (?T::ty)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Val (?v::'addr val)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e1.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop::bop» (?e2.0::'addr expr1)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e2.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?e1.0::'addr expr1) «?bop::bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e1.0::'addr expr1) «?bop::bop» (?e2.0::'addr expr1)) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Var (?V::nat)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?V::nat):=?e) ?pc ?xcp› and more 54 facts*) exec_move_AAssI1 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_move ?ci ?P ?t (?e⌊(?e'::'addr expr1)⌉ := (?e''::'addr expr1)) ?h ?s ?ta ?h' ?s'›*)) lemma AAss_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e⌊e'⌉ := e'') h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_AAssI2 (*‹exec_move ?ci ?P ?t ?e2.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e1.0⌊?e2.0⌉ := ?e3.0) ?h (?stk @ [?v], ?loc, length (compE2 ?e1.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v], ?loc', length (compE2 ?e1.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h (?stk @ ?vs) ?e ?pc ?xcp›*)) lemma AAss_τexecI3: "τexec_move ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e⌊e'⌉ := e'') h ((stk @ [v, v']), loc, (length (compE2 e) + length (compE2 e') + pc), xcp) ((stk' @ [v, v']), loc', (length (compE2 e) + length (compE2 e') + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹(?pc::nat) < length (compE2 (?e::'addr expr1)) ⟹ τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ?e ?pc ⌊?xcp::'addr⌋› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (newA (?T::ty)⌊?e⌉) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (Cast (?T::ty) ?e) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Cast (?T::ty) (?e::'addr expr1)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e instanceof (?T::ty)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e::'addr expr1) instanceof (?T::ty)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Val (?v::'addr val)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e1.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop::bop» (?e2.0::'addr expr1)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e2.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?e1.0::'addr expr1) «?bop::bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e1.0::'addr expr1) «?bop::bop» (?e2.0::'addr expr1)) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Var (?V::nat)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?V::nat):=?e) ?pc ?xcp› and more 54 facts*) exec_move_AAssI3 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e3.0::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ exec_move ?ci ?P ?t ((?e1.0::'addr expr1)⌊(?e2.0::'addr expr1)⌉ := ?e3.0) ?h (?stk @ [?v'::'addr val, ?v::'addr val], ?loc, length (compE2 ?e1.0) + length (compE2 ?e2.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v', ?v], ?loc', length (compE2 ?e1.0) + length (compE2 ?e2.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 (?P::?'a prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h (?stk @ (?vs::'addr val list)) ?e ?pc ?xcp›*)) lemma ALength_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙length) h s s'" apply (cases s) (*goal: ‹τexec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e::'addr::addr expr1) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ τexec_move ci P t (e∙length) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_ALengthI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e∙length) ?h ?s ?ta ?h' ?s'›*)) lemma FAcc_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙F{D}) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙F{D}) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_FAccI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e∙?F{?D}) ?h ?s ?ta ?h' ?s'›*)) lemma FAss_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙F{D} := e') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙F{D} := e') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹(?pc::nat) < length (compE2 (?e::'addr expr1)) ⟹ τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ?e ?pc ⌊?xcp::'addr⌋› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (newA (?T::ty)⌊?e⌉) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (Cast (?T::ty) ?e) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Cast (?T::ty) (?e::'addr expr1)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e instanceof (?T::ty)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e::'addr expr1) instanceof (?T::ty)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Val (?v::'addr val)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e1.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop::bop» (?e2.0::'addr expr1)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e2.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?e1.0::'addr expr1) «?bop::bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e1.0::'addr expr1) «?bop::bop» (?e2.0::'addr expr1)) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Var (?V::nat)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?V::nat):=?e) ?pc ?xcp› and more 54 facts*) exec_move_FAssI1 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_move ?ci ?P ?t (?e∙(?F::String.literal){(?D::String.literal)} := (?e'::'addr expr1)) ?h ?s ?ta ?h' ?s'›*)) lemma FAss_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e∙F{D} := e') h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹(?pc::nat) < length (compE2 (?e::'addr expr1)) ⟹ τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ?e ?pc ⌊?xcp::'addr⌋› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (newA (?T::ty)⌊?e⌉) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (Cast (?T::ty) ?e) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Cast (?T::ty) (?e::'addr expr1)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e instanceof (?T::ty)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e::'addr expr1) instanceof (?T::ty)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Val (?v::'addr val)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e1.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop::bop» (?e2.0::'addr expr1)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e2.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?e1.0::'addr expr1) «?bop::bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e1.0::'addr expr1) «?bop::bop» (?e2.0::'addr expr1)) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Var (?V::nat)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?V::nat):=?e) ?pc ?xcp› and more 54 facts*) exec_move_FAssI2 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e2.0::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ exec_move ?ci ?P ?t ((?e1.0::'addr expr1)∙(?F::String.literal){(?D::String.literal)} := ?e2.0) ?h (?stk @ [?v::'addr val], ?loc, length (compE2 ?e1.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v], ?loc', length (compE2 ?e1.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 (?P::?'a prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h (?stk @ (?vs::'addr val list)) ?e ?pc ?xcp›*)) lemma CAS_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CASI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h ?s ?ta ?h' ?s'›*)) lemma CAS_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CASI2 (*‹exec_move ?ci ?P ?t ?e2.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e1.0∙compareAndSwap(?D∙?F, ?e2.0, ?e3.0)) ?h (?stk @ [?v], ?loc, length (compE2 ?e1.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v], ?loc', length (compE2 ?e1.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h (?stk @ ?vs) ?e ?pc ?xcp›*)) lemma CAS_τexecI3: "τexec_move ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e∙compareAndSwap(D∙F, e', e'')) h ((stk @ [v, v']), loc, (length (compE2 e) + length (compE2 e') + pc), xcp) ((stk' @ [v, v']), loc', (length (compE2 e) + length (compE2 e') + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CASI3 (*‹exec_move ?ci ?P ?t ?e3.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e1.0∙compareAndSwap(?D∙?F, ?e2.0, ?e3.0)) ?h (?stk @ [?v', ?v], ?loc, length (compE2 ?e1.0) + length (compE2 ?e2.0) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v', ?v], ?loc', length (compE2 ?e1.0) + length (compE2 ?e2.0) + ?pc', ?xcp')›*) τmove2_stk_append (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h (?stk @ ?vs) ?e ?pc ?xcp›*)) lemma Call_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙M(es)) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e∙M(es)) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CallI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e∙?M(?es)) ?h ?s ?ta ?h' ?s'›*)) lemma Call_τexecI2: "τexec_moves ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e∙M(es)) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_movesE (*‹⟦τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk ?es ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CallI2 (*‹exec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e∙?M(?es)) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) ?ta ?h' (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*) τmoves2_stk_append (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp ⟹ τmoves2 ?P ?h (?stk @ ?vs) ?es ?pc ?xcp›*)) lemma Block_τexecI_Some: "τexec_move ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk', loc', Suc (Suc pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_BlockSomeI (*‹exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t {?V:?T=⌊?v⌋; ?e} ?h (?stk, ?loc, Suc (Suc ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc ?pc'), ?xcp')›*)) lemma Block_τexecI_None: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t {V:T=None; e} h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t {V:T=None; e} h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_BlockNoneI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t {?V:?T=None; ?e} ?h ?s ?ta ?h' ?s'›*)) lemma Sync_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (sync⇘V⇙ (e) e') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (sync⇘V⇙ (e) e') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_SyncI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h ?s ?ta ?h' ?s'›*)) lemma Insync_τexecI: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk', loc', Suc (Suc (Suc (length (compE2 e) + pc'))), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_SyncI2 (*‹exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (sync⇘?V⇙ (?o') ?e) ?h (?stk, ?loc, Suc (Suc (Suc (length (compE2 ?o') + ?pc))), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc (Suc (length (compE2 ?o') + ?pc'))), ?xcp')›*)) lemma Seq_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e;; e') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (e;; e') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_SeqI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (?e;; ?e') ?h ?s ?ta ?h' ?s'›*)) lemma Seq_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (e;; e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk', loc', Suc (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_SeqI2 (*‹exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (?e';; ?e) ?h (?stk, ?loc, Suc (length (compE2 ?e') + ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (length (compE2 ?e') + ?pc'), ?xcp')›*)) lemma Cond_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (if (e) e' else e'') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (if (e) e' else e'') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹(?pc::nat) < length (compE2 (?e::'addr expr1)) ⟹ τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ?e ?pc ⌊?xcp::'addr⌋› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (newA (?T::ty)⌊?e⌉) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (Cast (?T::ty) ?e) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Cast (?T::ty) (?e::'addr expr1)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e instanceof (?T::ty)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e::'addr expr1) instanceof (?T::ty)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Val (?v::'addr val)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e1.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop::bop» (?e2.0::'addr expr1)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e2.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?e1.0::'addr expr1) «?bop::bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e1.0::'addr expr1) «?bop::bop» (?e2.0::'addr expr1)) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Var (?V::nat)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?V::nat):=?e) ?pc ?xcp› and more 54 facts*) exec_move_CondI1 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ exec_move ?ci ?P ?t (if (?e) (?e1.0::'addr expr1) else (?e2.0::'addr expr1)) ?h ?s ?ta ?h' ?s'›*)) lemma Cond_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (if (e) e' else e'') h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk', loc', Suc (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CondI2 (*‹exec_move ?ci ?P ?t ?e1.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (if (?e) ?e1.0 else ?e2.0) ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) lemma Cond_τexecI3: "τexec_move ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (if (e) e' else e'') h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e') + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e') + pc')), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_CondI3 (*‹exec_move ?ci ?P ?t ?e2.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (if (?e) ?e1.0 else ?e2.0) ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + length (compE2 ?e1.0) + ?pc)), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc (length (compE2 ?e) + length (compE2 ?e1.0) + ?pc')), ?xcp')›*)) lemma While_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (while (e) e') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (while (e) e') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_WhileI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (while (?e) ?e') ?h ?s ?ta ?h' ?s'›*)) lemma While_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (while (e) e') h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk', loc', Suc (length (compE2 e) + pc'), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_WhileI2 (*‹exec_move ?ci ?P ?t ?e1.0 ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp') ⟹ exec_move ?ci ?P ?t (while (?e) ?e1.0) ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) ?ta ?h' (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) lemma Throw_τexecI: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (throw e) h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (throw e) h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_ThrowI (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (throw ?e) ?h ?s ?ta ?h' ?s'›*)) lemma Try_τexecI1: "τexec_move ci P t e h s s' ⟹ τexec_move ci P t (try e catch(C V) e') h s s'" apply (cases s) (*goal: ‹τexec_move ci P t e h s s' ⟹ τexec_move ci P t (try e catch(C V) e') h s s'›*) by (blast elim: τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹?pc < length (compE2 ?e) ⟹ τmove2 ?P ?h ?stk ?e ?pc ⌊?xcp⌋› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (newA ?T⌊?e⌉) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (Cast ?T ?e) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (Cast ?T ?e) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e instanceof ?T) ?pc ?xcp› ‹τmove2 ?P ?h ?stk (?e instanceof ?T) (length (compE2 ?e)) None› ‹τmove2 ?P ?h ?stk (Val ?v) 0 None› ‹τmove2 ?P ?h ?stk ?e1.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) ?pc ?xcp› ‹τmove2 ?P ?h ?stk ?e2.0 ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 ?P ?h ?stk (?e1.0 «?bop» ?e2.0) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 ?P ?h ?stk (Var ?V) 0 None› ‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmove2 ?P ?h ?stk (?V:=?e) ?pc ?xcp› and more 54 facts*) exec_move_TryI1 (*‹exec_move ?ci ?P ?t ?e ?h ?s ?ta ?h' ?s' ⟹ exec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h ?s ?ta ?h' ?s'›*)) lemma Try_τexecI2: "τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τexec_move ci P t (try e catch(C V) e') h (stk, loc, Suc (Suc (length (compE2 e) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 e) + pc')), xcp')" by (blast elim: τexec_moveE (*‹⟦τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option); ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) intro: τexec_moveI (*‹⟦exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) ⦃⦄ ?h (?s'::'addr val list × 'addr val list × nat × 'addr option); τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'›*) τmove2_τmoves2.intros (*‹(?pc::nat) < length (compE2 (?e::'addr expr1)) ⟹ τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ?e ?pc ⌊?xcp::'addr⌋› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (newA (?T::ty)⌊?e⌉) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (Cast (?T::ty) ?e) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Cast (?T::ty) (?e::'addr expr1)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e instanceof (?T::ty)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e::'addr expr1) instanceof (?T::ty)) (length (compE2 ?e)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Val (?v::'addr val)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e1.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk (?e1.0 «?bop::bop» (?e2.0::'addr expr1)) ?pc ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e2.0::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?e1.0::'addr expr1) «?bop::bop» ?e2.0) (length (compE2 ?e1.0) + ?pc) ?xcp› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) ((?e1.0::'addr expr1) «?bop::bop» (?e2.0::'addr expr1)) (length (compE2 ?e1.0) + length (compE2 ?e2.0)) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (Var (?V::nat)) (0::nat) None› ‹τmove2 (?P::?'m prog) (?h::'heap) (?stk::'addr val list) (?e::'addr expr1) (?pc::nat) (?xcp::'addr option) ⟹ τmove2 ?P ?h ?stk ((?V::nat):=?e) ?pc ?xcp› and more 54 facts*) exec_move_TryI2 (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ exec_move ?ci ?P ?t (try ?e'::'addr expr1 catch((?C::String.literal) (?V::nat)) ?e) ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e') + ?pc)), ?xcp) ?ta ?h' (?stk', ?loc', Suc (Suc (length (compE2 ?e') + ?pc')), ?xcp')›*)) lemma NewArray_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (newA T⌊e⌉) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (newA (T::ty)⌊e::'addr expr1⌉) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) s› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_mover ci P t (newA (T::ty)⌊e⌉) h s y⟧ ⟹ τExec_mover ci P t (newA T⌊e⌉) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) NewArray_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (newA ?T⌊?e⌉) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) NewArray_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (newA ?T⌊?e⌉) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Cast_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (Cast T e) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (Cast T e) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (Cast T e) h s y⟧ ⟹ τExec_mover ci P t (Cast T e) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cast_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (Cast ?T ?e) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cast_τexecI (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ τexec_move ?ci ?P ?t (Cast (?T::ty) ?e) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma InstanceOf_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e instanceof T) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (e instanceof T) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (e instanceof T) h s y⟧ ⟹ τExec_mover ci P t (e instanceof T) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) InstanceOf_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e instanceof ?T) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) InstanceOf_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e instanceof ?T) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma BinOp_τExecrI1: "τExec_mover ci P t e1 h s s' ⟹ τExec_mover ci P t (e1 «bop» e2) h s s'" sorry lemma BinOp_τExecrI2: "τExec_mover ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (e «bop» e2) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (e «bop» e2) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk @ [v], loc, length (compE2 e) + pc, xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e2 h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (e «bop» e2) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk' @ [v], loc', length (compE2 e) + pc', xcp')⟧ ⟹ τExec_mover ci P t (e «bop» e2) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk'' @ [v], loc'', length (compE2 e) + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) BinOp_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e «?bop» ?e') ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) BinOp_τexecI2 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e'::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr expr1) «?bop::bop» ?e') ?h (?stk @ [?v::'addr val], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma LAss_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (V := e) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (V:=e) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (V:=e) h s y⟧ ⟹ τExec_mover ci P t (V:=e) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) LAss_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?V:=?e) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) LAss_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?V:=?e) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma AAcc_τExecrI1: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e⌊i⌉) h s s'" apply (induct rule: rtranclp_induct (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); (?P::?'a ⇒ bool) ?a; ⋀(y::?'a) z::?'a. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e::'addr expr1)⌊i::'addr expr1⌉) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) s› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_mover ci P t (e⌊i::'addr expr1⌉) h s y⟧ ⟹ τExec_mover ci P t (e⌊i⌉) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAcc_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAcc_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma AAcc_τExecrI2: "τExec_mover ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (a⌊i⌉) h ((stk @ [v]), loc, (length (compE2 a) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 a) + pc'), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (a⌊i⌉) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk @ [v], loc, length (compE2 a) + pc, xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t i h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (a⌊i⌉) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk' @ [v], loc', length (compE2 a) + pc', xcp')⟧ ⟹ τExec_mover ci P t (a⌊i⌉) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk'' @ [v], loc'', length (compE2 a) + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAcc_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAcc_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma AAss_τExecrI1: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e⌊i⌉ := e') h s s'" apply (induct rule: rtranclp_induct (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); (?P::?'a ⇒ bool) ?a; ⋀(y::?'a) z::?'a. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) ((e::'addr::addr expr1)⌊(i::'addr::addr expr1)⌉ := (e'::'addr::addr expr1)) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) s› 2. ‹⋀(y::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) z::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option. ⟦τExec_mover (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e::'addr::addr expr1) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) y; τexec_move ci P t e h y z; τExec_mover ci P t (e⌊(i::'addr::addr expr1)⌉ := (e'::'addr::addr expr1)) h s y⟧ ⟹ τExec_mover ci P t (e⌊i⌉ := e') h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉ := ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉ := ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma AAss_τExecrI2: "τExec_mover ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (a⌊i⌉ := e) h ((stk @ [v]), loc, (length (compE2 a) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 a) + pc'), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (a⌊i⌉ := e) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk @ [v], loc, length (compE2 a) + pc, xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t i h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (a⌊i⌉ := e) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk' @ [v], loc', length (compE2 a) + pc', xcp')⟧ ⟹ τExec_mover ci P t (a⌊i⌉ := e) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk'' @ [v], loc'', length (compE2 a) + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAss_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAss_τexecI2 (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e'::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr::addr expr1)⌊?e'⌉ := (?e''::'addr::addr expr1)) ?h (?stk @ [?v::'addr::addr val], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma AAss_τExecrI3: "τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (a⌊i⌉ := e) h ((stk @ [v, v']), loc, (length (compE2 a) + length (compE2 i) + pc), xcp) ((stk' @ [v, v']), loc', (length (compE2 a) + length (compE2 i) + pc'), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (a⌊i⌉ := e) h (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp) (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (a⌊i⌉ := e) h (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp) (stk' @ [v, v'], loc', length (compE2 a) + length (compE2 i) + pc', xcp')⟧ ⟹ τExec_mover ci P t (a⌊i⌉ := e) h (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp) (stk'' @ [v, v'], loc'', length (compE2 a) + length (compE2 i) + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAss_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h (?stk @ [?v, ?v'], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) AAss_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h (?stk @ [?v, ?v'], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma ALength_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e∙length) h s s'" apply (induct rule: rtranclp_induct (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); (?P::?'a::type ⇒ bool) ?a; ⋀(y::?'a::type) z::?'a::type. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (e∙length) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (e∙length) h s y⟧ ⟹ τExec_mover ci P t (e∙length) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) ALength_τexecI (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ τexec_move ?ci ?P ?t (?e∙length) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) ALength_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙length) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma FAcc_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e∙F{D}) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (e∙F{D}) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (e∙F{D}) h s y⟧ ⟹ τExec_mover ci P t (e∙F{D}) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) FAcc_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D}) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) FAcc_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D}) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma FAss_τExecrI1: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e∙F{D} := e') h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (e∙F{D} := e') h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (e∙F{D} := e') h s y⟧ ⟹ τExec_mover ci P t (e∙F{D} := e') h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) FAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D} := ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) FAss_τexecI1 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (?e∙(?F::String.literal){(?D::String.literal)} := (?e'::'addr expr1)) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma FAss_τExecrI2: "τExec_mover ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (e∙F{D} := e') h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" sorry lemma CAS_τExecrI1: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h s y⟧ ⟹ τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) CAS_τexecI1 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap((?D::String.literal)∙(?F::String.literal), (?e'::'addr expr1), (?e''::'addr expr1))) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) CAS_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma CAS_τExecrI2: "τExec_mover ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk @ [v], loc, length (compE2 e) + pc, xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e' h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk' @ [v], loc', length (compE2 e) + pc', xcp')⟧ ⟹ τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk'' @ [v], loc'', length (compE2 e) + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) CAS_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) CAS_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma CAS_τExecrI3: "τExec_mover ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h ((stk @ [v, v']), loc, (length (compE2 e) + length (compE2 e') + pc), xcp) ((stk' @ [v, v']), loc', (length (compE2 e) + length (compE2 e') + pc'), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk''::'addr val list, ?loc''::'addr val list, ?pc''::nat, ?xcp''::'addr option); (?Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) ?stk ?loc ?pc ?xcp; ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp) (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e'' h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp) (stk' @ [v, v'], loc', length (compE2 e) + length (compE2 e') + pc', xcp')⟧ ⟹ τExec_mover ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp) (stk'' @ [v, v'], loc'', length (compE2 e) + length (compE2 e') + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) CAS_τexecI3 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e''::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr expr1)∙compareAndSwap((?D::String.literal)∙(?F::String.literal), (?e'::'addr expr1), ?e'')) ?h (?stk @ [?v::'addr val, ?v'::'addr val], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) CAS_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h (?stk @ [?v, ?v'], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma Call_τExecrI1: "τExec_mover ci P t obj h s s' ⟹ τExec_mover ci P t (obj∙M'(es)) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (obj∙M'(es)) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t obj h s y; τexec_move ci P t obj h y z; τExec_mover ci P t (obj∙M'(es)) h s y⟧ ⟹ τExec_mover ci P t (obj∙M'(es)) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Call_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Call_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Call_τExecrI2: "τExec_movesr ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (obj∙M'(es)) h ((stk @ [v]), loc, (length (compE2 obj) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 obj) + pc'), xcp')" apply (induct rule: τExecsr_induct (*‹⟦τExec_movesr (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk''::'addr val list, ?loc''::'addr val list, ?pc''::nat, ?xcp''::'addr option); (?Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) ?stk ?loc ?pc ?xcp; ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_movesr ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_moves ?ci ?P ?t ?es ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((obj::'addr expr1)∙(M'::String.literal)(es::'addr expr1 list)) (h::'heap) ((stk::'addr val list) @ [v::'addr val], loc::'addr val list, length (compE2 obj) + (pc::nat), xcp::'addr option) (stk @ [v], loc, length (compE2 obj) + pc, xcp)› 2. ‹⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_movesr (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (es::'addr expr1 list) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (stk', loc', pc', xcp'); τexec_moves ci P t es h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t ((obj::'addr expr1)∙(M'::String.literal)(es)) h (stk @ [v::'addr val], loc, length (compE2 obj) + pc, xcp) (stk' @ [v], loc', length (compE2 obj) + pc', xcp')⟧ ⟹ τExec_mover ci P t (obj∙M'(es)) h (stk @ [v], loc, length (compE2 obj) + pc, xcp) (stk'' @ [v], loc'', length (compE2 obj) + pc'', xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Call_τexecI2 (*‹τexec_moves (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr expr1)∙(?M::String.literal)(?es)) ?h (?stk @ [?v::'addr val], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Call_τexecI2 (*‹τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma Block_τExecrI_Some: "τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t {V:T=⌊v⌋; e} h (stk, loc, (Suc (Suc pc)), xcp) (stk', loc', (Suc (Suc pc')), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk, loc, Suc (Suc pc), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk', loc', Suc (Suc pc'), xcp')⟧ ⟹ τExec_mover ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk'', loc'', Suc (Suc pc''), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Block_τexecI_Some (*‹τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t {?V:?T=⌊?v⌋; ?e} ?h (?stk, ?loc, Suc (Suc ?pc), ?xcp) (?stk', ?loc', Suc (Suc ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Block_τexecI_Some (*‹τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t {?V:?T=⌊?v⌋; ?e} ?h (?stk, ?loc, Suc (Suc ?pc), ?xcp) (?stk', ?loc', Suc (Suc ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Block_τExecrI_None: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t {V:T=None; e} h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t {V:T=None; e} h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t {V:T=None; e} h s y⟧ ⟹ τExec_mover ci P t {V:T=None; e} h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Block_τexecI_None (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t {?V:?T=None; ?e} ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Block_τexecI_None (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t {?V:?T=None; ?e} ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Sync_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (sync⇘V⇙ (e) e') h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (sync⇘V⇙ (e) e') h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (sync⇘V⇙ (e) e') h s y⟧ ⟹ τExec_mover ci P t (sync⇘V⇙ (e) e') h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Sync_τexecI (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ τexec_move ?ci ?P ?t (sync⇘(?V::nat)⇙ (?e) (?e'::'addr::addr expr1)) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Sync_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Insync_τExecrI: "τExec_mover ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (sync⇘V⇙ (e) e') h (stk, loc, (Suc (Suc (Suc (length (compE2 e) + pc)))), xcp) (stk', loc', (Suc (Suc (Suc (length (compE2 e) + pc')))), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk''::'addr val list, ?loc''::'addr val list, ?pc''::nat, ?xcp''::'addr option); (?Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) ?stk ?loc ?pc ?xcp; ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e' h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk', loc', Suc (Suc (Suc (length (compE2 e) + pc'))), xcp')⟧ ⟹ τExec_mover ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk'', loc'', Suc (Suc (Suc (length (compE2 e) + pc''))), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Insync_τexecI (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h (?stk, ?loc, Suc (Suc (Suc (length (compE2 ?e) + ?pc))), ?xcp) (?stk', ?loc', Suc (Suc (Suc (length (compE2 ?e) + ?pc'))), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Insync_τexecI (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h (?stk, ?loc, Suc (Suc (Suc (length (compE2 ?e) + ?pc))), ?xcp) (?stk', ?loc', Suc (Suc (Suc (length (compE2 ?e) + ?pc'))), ?xcp')›*)) (*proven 2 subgoals*) . lemma Seq_τExecrI1: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (e;;e') h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) ((e::'addr expr1);; (e'::'addr expr1)) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) s› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_mover ci P t (e;; (e'::'addr expr1)) h s y⟧ ⟹ τExec_mover ci P t (e;; e') h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Seq_τexecI1 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (?e;; (?e'::'addr expr1)) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Seq_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e;; ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Seq_τExecrI2: "τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc' ,xcp') ⟹ τExec_mover ci P t (e';;e) h (stk, loc, (Suc (length (compE2 e') + pc)), xcp) (stk', loc', (Suc (length (compE2 e') + pc')), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk''::'addr::addr val list, ?loc''::'addr::addr val list, ?pc''::nat, ?xcp''::'addr::addr option); (?Q::'addr::addr val list ⇒ 'addr::addr val list ⇒ nat ⇒ 'addr::addr option ⇒ bool) ?stk ?loc ?pc ?xcp; ⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (xcp'::'addr::addr option) (stk''::'addr::addr val list) (loc''::'addr::addr val list) (pc''::nat) xcp''::'addr::addr option. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) (stk, loc, Suc (length (compE2 e') + pc), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) (stk', loc', Suc (length (compE2 e') + pc'), xcp')⟧ ⟹ τExec_mover ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) (stk'', loc'', Suc (length (compE2 e') + pc''), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Seq_τexecI2 (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e'::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr::addr expr1);; ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Seq_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e;; ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Cond_τExecrI1: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (if (e) e1 else e2) h s s'" apply (induct rule: rtranclp_induct (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); (?P::?'a ⇒ bool) ?a; ⋀(y::?'a) z::?'a. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (if ((e::'addr expr1)) (e1::'addr expr1) else (e2::'addr expr1)) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) s› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_mover (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_mover ci P t (if (e) (e1::'addr expr1) else (e2::'addr expr1)) h s y⟧ ⟹ τExec_mover ci P t (if (e) e1 else e2) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cond_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cond_τexecI1 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (if (?e) (?e'::'addr expr1) else (?e''::'addr expr1)) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Cond_τExecrI2: "τExec_mover ci P t e1 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) (stk', loc', (Suc (length (compE2 e) + pc')), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk, loc, Suc (length (compE2 e) + pc), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e1 h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e1 h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk', loc', Suc (length (compE2 e) + pc'), xcp')⟧ ⟹ τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk'', loc'', Suc (length (compE2 e) + pc''), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cond_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cond_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Cond_τExecrI3: "τExec_mover ci P t e2 h (stk, loc ,pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, (Suc (Suc (length (compE2 e) + length (compE2 e1) + pc))), xcp) (stk', loc', (Suc (Suc (length (compE2 e) + length (compE2 e1) + pc'))), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk''::'addr val list, ?loc''::'addr val list, ?pc''::nat, ?xcp''::'addr option); (?Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) ?stk ?loc ?pc ?xcp; ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e2 h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')⟧ ⟹ τExec_mover ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) (stk'', loc'', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc'')), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cond_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc')), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Cond_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc')), ?xcp')›*)) (*proven 2 subgoals*) . lemma While_τExecrI1: "τExec_mover ci P t c h s s' ⟹ τExec_mover ci P t (while (c) e) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (while (c) e) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t c h s y; τexec_move ci P t c h y z; τExec_mover ci P t (while (c) e) h s y⟧ ⟹ τExec_mover ci P t (while (c) e) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) While_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (while (?e) ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) While_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (while (?e) ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma While_τExecrI2: "τExec_mover ci P t E h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (while (c) E) h (stk, loc ,(Suc (length (compE2 c) + pc)), xcp) (stk', loc', (Suc (length (compE2 c) + pc')), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (while (c) E) h (stk, loc, Suc (length (compE2 c) + pc), xcp) (stk, loc, Suc (length (compE2 c) + pc), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t E h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t E h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (while (c) E) h (stk, loc, Suc (length (compE2 c) + pc), xcp) (stk', loc', Suc (length (compE2 c) + pc'), xcp')⟧ ⟹ τExec_mover ci P t (while (c) E) h (stk, loc, Suc (length (compE2 c) + pc), xcp) (stk'', loc'', Suc (length (compE2 c) + pc''), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⇧*⇧* (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⇧*⇧* ?a ?c›*) While_τexecI2 (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e'::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option) ⟹ τexec_move ?ci ?P ?t (while ((?e::'addr::addr expr1)) ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) While_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (while (?e) ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Throw_τExecrI: "τExec_mover ci P t e h s s' ⟹ τExec_mover ci P t (throw e) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (throw e) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t e h s y; τexec_move ci P t e h y z; τExec_mover ci P t (throw e) h s y⟧ ⟹ τExec_mover ci P t (throw e) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Throw_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (throw ?e) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Throw_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (throw ?e) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Try_τExecrI1: "τExec_mover ci P t E h s s' ⟹ τExec_mover ci P t (try E catch(C' V) e) h s s'" apply (induct rule: rtranclp_induct (*‹⟦?r⇧*⇧* ?a ?b; ?P ?a; ⋀y z. ⟦?r⇧*⇧* ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹τExec_mover ci P t (try E catch(C' V) e) h s s› 2. ‹⋀y z. ⟦τExec_mover ci P t E h s y; τexec_move ci P t E h y z; τExec_mover ci P t (try E catch(C' V) e) h s y⟧ ⟹ τExec_mover ci P t (try E catch(C' V) e) h s z› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Try_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Try_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Try_τExecrI2: "τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_mover ci P t (try E catch(C' V) e) h (stk, loc, (Suc (Suc (length (compE2 E) + pc))), xcp) (stk', loc', (Suc (Suc (length (compE2 E) + pc'))), xcp')" apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_mover ci P t (try E catch(C' V) e) h (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp) (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp)› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_mover ci P t (try E catch(C' V) e) h (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 E) + pc')), xcp')⟧ ⟹ τExec_mover ci P t (try E catch(C' V) e) h (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp) (stk'', loc'', Suc (Suc (length (compE2 E) + pc'')), xcp'')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Try_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + ?pc')), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) Try_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + ?pc')), ?xcp')›*)) (*proven 2 subgoals*) . lemma NewArray_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (newA T⌊e⌉) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y::'addr val list × 'addr val list × nat × 'addr option. τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y ⟹ τExec_movet ci P t (newA (T::ty)⌊e⌉) h s y› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_movet ci P t (newA (T::ty)⌊e⌉) h s y⟧ ⟹ τExec_movet ci P t (newA T⌊e⌉) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) NewArray_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (newA ?T⌊?e⌉) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) NewArray_τexecI (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (newA (?T::ty)⌊?e⌉) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Cast_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (Cast T e) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y::'addr val list × 'addr val list × nat × 'addr option. τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y ⟹ τExec_movet ci P t (Cast (T::ty) e) h s y› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_movet ci P t (Cast (T::ty) e) h s y⟧ ⟹ τExec_movet ci P t (Cast T e) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cast_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (Cast ?T ?e) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cast_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (Cast ?T ?e) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma InstanceOf_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e instanceof T) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e instanceof T) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e instanceof T) h s y⟧ ⟹ τExec_movet ci P t (e instanceof T) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) InstanceOf_τexecI (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (?e instanceof (?T::ty)) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) InstanceOf_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e instanceof ?T) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma BinOp_τExectI1: "τExec_movet ci P t e1 h s s' ⟹ τExec_movet ci P t (e1 «bop» e2) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e1 h s y ⟹ τExec_movet ci P t (e1 «bop» e2) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e1 h s y; τexec_move ci P t e1 h y z; τExec_movet ci P t (e1 «bop» e2) h s y⟧ ⟹ τExec_movet ci P t (e1 «bop» e2) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) BinOp_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e «?bop» ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) BinOp_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e «?bop» ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma BinOp_τExectI2: "τExec_movet ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e «bop» e2) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e «bop» e2) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk' @ [v], loc', length (compE2 e) + pc', xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e2 h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (e «bop» e2) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk' @ [v], loc', length (compE2 e) + pc', xcp')⟧ ⟹ τExec_movet ci P t (e «bop» e2) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk'' @ [v], loc'', length (compE2 e) + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) BinOp_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e «?bop» ?e') ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⁺⁺ (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⁺⁺ ?a ?c›*) BinOp_τexecI2 (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e'::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr::addr expr1) «?bop::bop» ?e') ?h (?stk @ [?v::'addr::addr val], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma LAss_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (V := e) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option. τexec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e::'addr::addr expr1) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) y ⟹ τExec_movet ci P t ((V::nat):=e) h s y› 2. ‹⋀(y::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) z::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option. ⟦τExec_movet (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (e::'addr::addr expr1) (h::'heap::type) (s::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) y; τexec_move ci P t e h y z; τExec_movet ci P t ((V::nat):=e) h s y⟧ ⟹ τExec_movet ci P t (V:=e) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) LAss_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?V:=?e) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) LAss_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?V:=?e) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma AAcc_τExectI1: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e⌊i⌉) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e⌊i⌉) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e⌊i⌉) h s y⟧ ⟹ τExec_movet ci P t (e⌊i⌉) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAcc_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAcc_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma AAcc_τExectI2: "τExec_movet ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (a⌊i⌉) h ((stk @ [v]), loc, (length (compE2 a) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 a) + pc'), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) xcp'::'addr::addr option. τexec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (i::'addr::addr expr1) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t ((a::'addr::addr expr1)⌊i⌉) h (stk @ [v::'addr::addr val], loc, length (compE2 a) + pc, xcp) (stk' @ [v], loc', length (compE2 a) + pc', xcp')› 2. ‹⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (xcp'::'addr::addr option) (stk''::'addr::addr val list) (loc''::'addr::addr val list) (pc''::nat) xcp''::'addr::addr option. ⟦τExec_movet (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (i::'addr::addr expr1) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (stk', loc', pc', xcp'); τexec_move ci P t i h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t ((a::'addr::addr expr1)⌊i⌉) h (stk @ [v::'addr::addr val], loc, length (compE2 a) + pc, xcp) (stk' @ [v], loc', length (compE2 a) + pc', xcp')⟧ ⟹ τExec_movet ci P t (a⌊i⌉) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk'' @ [v], loc'', length (compE2 a) + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAcc_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAcc_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma AAss_τExectI1: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e⌊i⌉ := e') h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e⌊i⌉ := e') h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e⌊i⌉ := e') h s y⟧ ⟹ τExec_movet ci P t (e⌊i⌉ := e') h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉ := ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e⌊?i⌉ := ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma AAss_τExectI2: "τExec_movet ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (a⌊i⌉ := e) h ((stk @ [v]), loc, (length (compE2 a) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 a) + pc'), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (a⌊i⌉ := e) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk' @ [v], loc', length (compE2 a) + pc', xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t i h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t i h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (a⌊i⌉ := e) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk' @ [v], loc', length (compE2 a) + pc', xcp')⟧ ⟹ τExec_movet ci P t (a⌊i⌉ := e) h (stk @ [v], loc, length (compE2 a) + pc, xcp) (stk'' @ [v], loc'', length (compE2 a) + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAss_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAss_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma AAss_τExectI3: "τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (a⌊i⌉ := e) h ((stk @ [v, v']), loc, (length (compE2 a) + length (compE2 i) + pc), xcp) ((stk' @ [v, v']), loc', (length (compE2 a) + length (compE2 i) + pc'), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (a⌊i⌉ := e) h (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp) (stk' @ [v, v'], loc', length (compE2 a) + length (compE2 i) + pc', xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (a⌊i⌉ := e) h (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp) (stk' @ [v, v'], loc', length (compE2 a) + length (compE2 i) + pc', xcp')⟧ ⟹ τExec_movet ci P t (a⌊i⌉ := e) h (stk @ [v, v'], loc, length (compE2 a) + length (compE2 i) + pc, xcp) (stk'' @ [v, v'], loc'', length (compE2 a) + length (compE2 i) + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAss_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e⌊?e'⌉ := ?e'') ?h (?stk @ [?v, ?v'], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a::type ⇒ ?'a::type ⇒ bool)⁺⁺ (?a::?'a::type) (?b::?'a::type); ?r ?b (?c::?'a::type)⟧ ⟹ ?r⁺⁺ ?a ?c›*) AAss_τexecI3 (*‹τexec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e''::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?pc'::nat, ?xcp'::'addr::addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr::addr expr1)⌊(?e'::'addr::addr expr1)⌉ := ?e'') ?h (?stk @ [?v::'addr::addr val, ?v'::'addr::addr val], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma ALength_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e∙length) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e∙length) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e∙length) h s y⟧ ⟹ τExec_movet ci P t (e∙length) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) ALength_τexecI (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (?e∙length) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) ALength_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙length) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma FAcc_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e∙F{D}) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e∙F{D}) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e∙F{D}) h s y⟧ ⟹ τExec_movet ci P t (e∙F{D}) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) FAcc_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D}) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) FAcc_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D}) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma FAss_τExectI1: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e∙F{D} := e') h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e∙F{D} := e') h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e∙F{D} := e') h s y⟧ ⟹ τExec_movet ci P t (e∙F{D} := e') h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) FAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D} := ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) FAss_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?F{?D} := ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma FAss_τExectI2: "τExec_movet ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e∙F{D} := e') h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" sorry lemma CAS_τExectI1: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h s y⟧ ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) CAS_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) CAS_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma CAS_τExectI2: "τExec_movet ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h ((stk @ [v]), loc, (length (compE2 e) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 e) + pc'), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk''::'addr val list, ?loc''::'addr val list, ?pc''::nat, ?xcp''::'addr option); ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) xcp'::'addr option. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ (?Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) stk' loc' pc' xcp'; ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) xcp'::'addr option. τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e'::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t ((e::'addr expr1)∙compareAndSwap((D::String.literal)∙(F::String.literal), e', (e''::'addr expr1))) h (stk @ [v::'addr val], loc, length (compE2 e) + pc, xcp) (stk' @ [v], loc', length (compE2 e) + pc', xcp')› 2. ‹⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e'::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (stk', loc', pc', xcp'); τexec_move ci P t e' h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t ((e::'addr expr1)∙compareAndSwap((D::String.literal)∙(F::String.literal), e', (e''::'addr expr1))) h (stk @ [v::'addr val], loc, length (compE2 e) + pc, xcp) (stk' @ [v], loc', length (compE2 e) + pc', xcp')⟧ ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v], loc, length (compE2 e) + pc, xcp) (stk'' @ [v], loc'', length (compE2 e) + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) CAS_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) CAS_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma CAS_τExectI3: "τExec_movet ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h ((stk @ [v, v']), loc, (length (compE2 e) + length (compE2 e') + pc), xcp) ((stk' @ [v, v']), loc', (length (compE2 e) + length (compE2 e') + pc'), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp) (stk' @ [v, v'], loc', length (compE2 e) + length (compE2 e') + pc', xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e'' h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e'' h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp) (stk' @ [v, v'], loc', length (compE2 e) + length (compE2 e') + pc', xcp')⟧ ⟹ τExec_movet ci P t (e∙compareAndSwap(D∙F, e', e'')) h (stk @ [v, v'], loc, length (compE2 e) + length (compE2 e') + pc, xcp) (stk'' @ [v, v'], loc'', length (compE2 e) + length (compE2 e') + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) CAS_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙compareAndSwap(?D∙?F, ?e', ?e'')) ?h (?stk @ [?v, ?v'], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) CAS_τexecI3 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e''::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr expr1)∙compareAndSwap((?D::String.literal)∙(?F::String.literal), (?e'::'addr expr1), ?e'')) ?h (?stk @ [?v::'addr val, ?v'::'addr val], ?loc, length (compE2 ?e) + length (compE2 ?e') + ?pc, ?xcp) (?stk' @ [?v, ?v'], ?loc', length (compE2 ?e) + length (compE2 ?e') + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma Call_τExectI1: "τExec_movet ci P t obj h s s' ⟹ τExec_movet ci P t (obj∙M'(es)) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t obj h s y ⟹ τExec_movet ci P t (obj∙M'(es)) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t obj h s y; τexec_move ci P t obj h y z; τExec_movet ci P t (obj∙M'(es)) h s y⟧ ⟹ τExec_movet ci P t (obj∙M'(es)) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Call_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Call_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Call_τExectI2: "τExec_movest ci P t es h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (obj∙M'(es)) h ((stk @ [v]), loc, (length (compE2 obj) + pc), xcp) ((stk' @ [v]), loc', (length (compE2 obj) + pc'), xcp')" apply (induct rule: τExecst_induct (*‹⟦τExec_movest (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?es::'addr expr1 list) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk''::'addr val list, ?loc''::'addr val list, ?pc''::nat, ?xcp''::'addr option); ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) xcp'::'addr option. τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ (?Q::'addr val list ⇒ 'addr val list ⇒ nat ⇒ 'addr option ⇒ bool) stk' loc' pc' xcp'; ⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_movest ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_moves ?ci ?P ?t ?es ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) xcp'::'addr::addr option. τexec_moves (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (es::'addr::addr expr1 list) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t ((obj::'addr::addr expr1)∙(M'::String.literal)(es)) h (stk @ [v::'addr::addr val], loc, length (compE2 obj) + pc, xcp) (stk' @ [v], loc', length (compE2 obj) + pc', xcp')› 2. ‹⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (xcp'::'addr::addr option) (stk''::'addr::addr val list) (loc''::'addr::addr val list) (pc''::nat) xcp''::'addr::addr option. ⟦τExec_movest (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (es::'addr::addr expr1 list) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (stk', loc', pc', xcp'); τexec_moves ci P t es h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t ((obj::'addr::addr expr1)∙(M'::String.literal)(es)) h (stk @ [v::'addr::addr val], loc, length (compE2 obj) + pc, xcp) (stk' @ [v], loc', length (compE2 obj) + pc', xcp')⟧ ⟹ τExec_movet ci P t (obj∙M'(es)) h (stk @ [v], loc, length (compE2 obj) + pc, xcp) (stk'' @ [v], loc'', length (compE2 obj) + pc'', xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Call_τexecI2 (*‹τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Call_τexecI2 (*‹τexec_moves ?ci ?P ?t ?es ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e∙?M(?es)) ?h (?stk @ [?v], ?loc, length (compE2 ?e) + ?pc, ?xcp) (?stk' @ [?v], ?loc', length (compE2 ?e) + ?pc', ?xcp')›*)) (*proven 2 subgoals*) . lemma Block_τExectI_Some: "τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t {V:T=⌊v⌋; e} h (stk, loc, (Suc (Suc pc)), xcp) (stk', loc', (Suc (Suc pc')), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk', loc', Suc (Suc pc'), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk', loc', Suc (Suc pc'), xcp')⟧ ⟹ τExec_movet ci P t {V:T=⌊v⌋; e} h (stk, loc, Suc (Suc pc), xcp) (stk'', loc'', Suc (Suc pc''), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) Block_τexecI_Some (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t {?V::nat:?T::ty=⌊?v::'addr val⌋; ?e} ?h (?stk, ?loc, Suc (Suc ?pc), ?xcp) (?stk', ?loc', Suc (Suc ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Block_τexecI_Some (*‹τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t {?V:?T=⌊?v⌋; ?e} ?h (?stk, ?loc, Suc (Suc ?pc), ?xcp) (?stk', ?loc', Suc (Suc ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Block_τExectI_None: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t {V:T=None; e} h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t {V:T=None; e} h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t {V:T=None; e} h s y⟧ ⟹ τExec_movet ci P t {V:T=None; e} h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Block_τexecI_None (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t {?V:?T=None; ?e} ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Block_τexecI_None (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t {?V:?T=None; ?e} ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Sync_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (sync⇘V⇙ (e) e') h s s'" apply (induct rule: tranclp_induct (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ⋀y::?'a. ?r ?a y ⟹ (?P::?'a ⇒ bool) y; ⋀(y::?'a) z::?'a. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (sync⇘V⇙ (e) e') h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (sync⇘V⇙ (e) e') h s y⟧ ⟹ τExec_movet ci P t (sync⇘V⇙ (e) e') h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Sync_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Sync_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Insync_τExectI: "τExec_movet ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (sync⇘V⇙ (e) e') h (stk, loc, (Suc (Suc (Suc (length (compE2 e) + pc)))), xcp) (stk', loc', (Suc (Suc (Suc (length (compE2 e) + pc')))), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk', loc', Suc (Suc (Suc (length (compE2 e) + pc'))), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e' h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e' h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk', loc', Suc (Suc (Suc (length (compE2 e) + pc'))), xcp')⟧ ⟹ τExec_movet ci P t (sync⇘V⇙ (e) e') h (stk, loc, Suc (Suc (Suc (length (compE2 e) + pc))), xcp) (stk'', loc'', Suc (Suc (Suc (length (compE2 e) + pc''))), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Insync_τexecI (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (sync⇘?V⇙ (?e) ?e') ?h (?stk, ?loc, Suc (Suc (Suc (length (compE2 ?e) + ?pc))), ?xcp) (?stk', ?loc', Suc (Suc (Suc (length (compE2 ?e) + ?pc'))), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) Insync_τexecI (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e'::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t (sync⇘(?V::nat)⇙ ((?e::'addr expr1)) ?e') ?h (?stk, ?loc, Suc (Suc (Suc (length (compE2 ?e) + ?pc))), ?xcp) (?stk', ?loc', Suc (Suc (Suc (length (compE2 ?e) + ?pc'))), ?xcp')›*)) (*proven 2 subgoals*) . lemma Seq_τExectI1: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (e;;e') h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (e;; e') h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (e;; e') h s y⟧ ⟹ τExec_movet ci P t (e;; e') h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Seq_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e;; ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Seq_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (?e;; ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Seq_τExectI2: "τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc' ,xcp') ⟹ τExec_movet ci P t (e';;e) h (stk, loc, (Suc (length (compE2 e') + pc)), xcp) (stk', loc', (Suc (length (compE2 e') + pc')), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) (stk', loc', Suc (length (compE2 e') + pc'), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) (stk', loc', Suc (length (compE2 e') + pc'), xcp')⟧ ⟹ τExec_movet ci P t (e';; e) h (stk, loc, Suc (length (compE2 e') + pc), xcp) (stk'', loc'', Suc (length (compE2 e') + pc''), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) Seq_τexecI2 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e'::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t ((?e::'addr expr1);; ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Seq_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (?e;; ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Cond_τExectI1: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (if (e) e1 else e2) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y::'addr val list × 'addr val list × nat × 'addr option. τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y ⟹ τExec_movet ci P t (if (e) (e1::'addr expr1) else (e2::'addr expr1)) h s y› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (e::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t e h y z; τExec_movet ci P t (if (e) (e1::'addr expr1) else (e2::'addr expr1)) h s y⟧ ⟹ τExec_movet ci P t (if (e) e1 else e2) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cond_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cond_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Cond_τExectI2: "τExec_movet ci P t e1 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, (Suc (length (compE2 e) + pc)), xcp) (stk', loc', (Suc (length (compE2 e) + pc')), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e1 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk', loc', Suc (length (compE2 e) + pc'), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e1 h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e1 h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk', loc', Suc (length (compE2 e) + pc'), xcp')⟧ ⟹ τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, Suc (length (compE2 e) + pc), xcp) (stk'', loc'', Suc (length (compE2 e) + pc''), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cond_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cond_τexecI2 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e'::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_move ?ci ?P ?t (if ((?e::'addr expr1)) ?e' else (?e''::'addr expr1)) ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Cond_τExectI3: "τExec_movet ci P t e2 h (stk, loc ,pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, (Suc (Suc (length (compE2 e) + length (compE2 e1) + pc))), xcp) (stk', loc', (Suc (Suc (length (compE2 e) + length (compE2 e1) + pc'))), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e2 h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e2 h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc')), xcp')⟧ ⟹ τExec_movet ci P t (if (e) e1 else e2) h (stk, loc, Suc (Suc (length (compE2 e) + length (compE2 e1) + pc)), xcp) (stk'', loc'', Suc (Suc (length (compE2 e) + length (compE2 e1) + pc'')), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cond_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc')), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Cond_τexecI3 (*‹τexec_move ?ci ?P ?t ?e'' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (if (?e) ?e' else ?e'') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + length (compE2 ?e') + ?pc')), ?xcp')›*)) (*proven 2 subgoals*) . lemma While_τExectI1: "τExec_movet ci P t c h s s' ⟹ τExec_movet ci P t (while (c) e) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t c h s y ⟹ τExec_movet ci P t (while (c) e) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t c h s y; τexec_move ci P t c h y z; τExec_movet ci P t (while (c) e) h s y⟧ ⟹ τExec_movet ci P t (while (c) e) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) While_τexecI1 (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) (?h::'heap) (?s::'addr val list × 'addr val list × nat × 'addr option) (?s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ τexec_move ?ci ?P ?t (while (?e) (?e'::'addr expr1)) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) While_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (while (?e) ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma While_τExectI2: "τExec_movet ci P t E h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (while (c) E) h (stk, loc ,(Suc (length (compE2 c) + pc)), xcp) (stk', loc', (Suc (length (compE2 c) + pc')), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t E h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (while (c) E) h (stk, loc, Suc (length (compE2 c) + pc), xcp) (stk', loc', Suc (length (compE2 c) + pc'), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t E h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t E h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (while (c) E) h (stk, loc, Suc (length (compE2 c) + pc), xcp) (stk', loc', Suc (length (compE2 c) + pc'), xcp')⟧ ⟹ τExec_movet ci P t (while (c) E) h (stk, loc, Suc (length (compE2 c) + pc), xcp) (stk'', loc'', Suc (length (compE2 c) + pc''), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) While_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (while (?e) ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) While_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (while (?e) ?e') ?h (?stk, ?loc, Suc (length (compE2 ?e) + ?pc), ?xcp) (?stk', ?loc', Suc (length (compE2 ?e) + ?pc'), ?xcp')›*)) (*proven 2 subgoals*) . lemma Throw_τExectI: "τExec_movet ci P t e h s s' ⟹ τExec_movet ci P t (throw e) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y. τexec_move ci P t e h s y ⟹ τExec_movet ci P t (throw e) h s y› 2. ‹⋀y z. ⟦τExec_movet ci P t e h s y; τexec_move ci P t e h y z; τExec_movet ci P t (throw e) h s y⟧ ⟹ τExec_movet ci P t (throw e) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Throw_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (throw ?e) ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Throw_τexecI (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (throw ?e) ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Try_τExectI1: "τExec_movet ci P t E h s s' ⟹ τExec_movet ci P t (try E catch(C' V) e) h s s'" apply (induct rule: tranclp_induct (*‹⟦?r⁺⁺ ?a ?b; ⋀y. ?r ?a y ⟹ ?P y; ⋀y z. ⟦?r⁺⁺ ?a y; ?r y z; ?P y⟧ ⟹ ?P z⟧ ⟹ ?P ?b›*)) (*goals: 1. ‹⋀y::'addr val list × 'addr val list × nat × 'addr option. τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (E::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y ⟹ τExec_movet ci P t (try E catch((C'::String.literal) (V::nat)) (e::'addr expr1)) h s y› 2. ‹⋀(y::'addr val list × 'addr val list × nat × 'addr option) z::'addr val list × 'addr val list × nat × 'addr option. ⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (E::'addr expr1) (h::'heap) (s::'addr val list × 'addr val list × nat × 'addr option) y; τexec_move ci P t E h y z; τExec_movet ci P t (try E catch((C'::String.literal) (V::nat)) (e::'addr expr1)) h s y⟧ ⟹ τExec_movet ci P t (try E catch(C' V) e) h s z› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Try_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h ?s ?s'›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Try_τexecI1 (*‹τexec_move ?ci ?P ?t ?e ?h ?s ?s' ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h ?s ?s'›*)) (*proven 2 subgoals*) . lemma Try_τExectI2: "τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (try E catch(C' V) e) h (stk, loc, (Suc (Suc (length (compE2 E) + pc))), xcp) (stk', loc', (Suc (Suc (length (compE2 E) + pc'))), xcp')" apply (induct rule: τExect_induct (*‹⟦τExec_movet (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) (?h::'heap::type) (?stk::'addr::addr val list, ?loc::'addr::addr val list, ?pc::nat, ?xcp::'addr::addr option) (?stk''::'addr::addr val list, ?loc''::'addr::addr val list, ?pc''::nat, ?xcp''::'addr::addr option); ⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) xcp'::'addr::addr option. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ (?Q::'addr::addr val list ⇒ 'addr::addr val list ⇒ nat ⇒ 'addr::addr option ⇒ bool) stk' loc' pc' xcp'; ⋀(stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (xcp'::'addr::addr option) (stk''::'addr::addr val list) (loc''::'addr::addr val list) (pc''::nat) xcp''::'addr::addr option. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀stk' loc' pc' xcp'. τexec_move ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp') ⟹ τExec_movet ci P t (try E catch(C' V) e) h (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 E) + pc')), xcp')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ci P t e h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t e h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_movet ci P t (try E catch(C' V) e) h (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp) (stk', loc', Suc (Suc (length (compE2 E) + pc')), xcp')⟧ ⟹ τExec_movet ci P t (try E catch(C' V) e) h (stk, loc, Suc (Suc (length (compE2 E) + pc)), xcp) (stk'', loc'', Suc (Suc (length (compE2 E) + pc'')), xcp'')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Try_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + ?pc')), ?xcp')›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) Try_τexecI2 (*‹τexec_move ?ci ?P ?t ?e' ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_move ?ci ?P ?t (try ?e catch(?C ?V) ?e') ?h (?stk, ?loc, Suc (Suc (length (compE2 ?e) + ?pc)), ?xcp) (?stk', ?loc', Suc (Suc (length (compE2 ?e) + ?pc')), ?xcp')›*)) (*proven 2 subgoals*) . lemma τExec_movesr_map_Val: "τExec_movesr_a P t (map Val vs) h ([], xs, 0, None) ((rev vs), xs, (length (compEs2 (map Val vs))), None)" proof (induct vs arbitrary: pc stk Ts rule: rev_induct) (*goals: 1. ‹τExec_movesr_a P t (map Val []) h ([], xs, 0, None) (rev [], xs, length (compEs2 (map Val [])), None)› 2. ‹⋀x xsa. τExec_movesr_a P t (map Val xsa) h ([], xs, 0, None) (rev xsa, xs, length (compEs2 (map Val xsa)), None) ⟹ τExec_movesr_a P t (map Val (xsa @ [x])) h ([], xs, 0, None) (rev (xsa @ [x]), xs, length (compEs2 (map Val (xsa @ [x]))), None)›*) case Nil (*no hyothesis introduced yet*) thus "?case" (*goal: ‹τExec_movesr_a P t (map Val []) h ([], xs, 0, None) (rev [], xs, length (compEs2 (map Val [])), None)›*) by auto next (*goal: ‹⋀x xsa. τExec_movesr_a P t (map Val xsa) h ([], xs, 0, None) (rev xsa, xs, length (compEs2 (map Val xsa)), None) ⟹ τExec_movesr_a P t (map Val (xsa @ [x])) h ([], xs, 0, None) (rev (xsa @ [x]), xs, length (compEs2 (map Val (xsa @ [x]))), None)›*) case (snoc v vs') (*‹τExec_movesr_a P t (map Val vs') h ([], xs, 0, None) (rev vs', xs, length (compEs2 (map Val vs')), None)›*) let ?E = "compEs2 (map Val vs')" from snoc (*‹τExec_movesr_a P t (map Val vs') h ([], xs, 0, None) (rev vs', xs, length (compEs2 (map Val vs')), None)›*) have "τExec_movesr_a P t (map Val (vs' @ [v])) h ([], xs, 0, None) ((rev vs'), xs, (length ?E), None)" by auto also (*calculation: ‹τExec_movesr_a P t (map Val (vs' @ [v])) h ([], xs, 0, None) (rev vs', xs, length (compEs2 (map Val vs')), None)›*) { have "exec_meth_a (compP2 P) (?E @ [Push v]) (compxEs2 (map Val vs') 0 0 @ shift (length ?E) []) t h ((rev vs'), xs, (length ?E + 0), None) ε h ((v # rev vs'), xs, (length ?E + Suc 0), None)" apply - (*goal: ‹exec_meth_a (compP2 P) (compEs2 (map Val vs') @ [Push v]) (compxEs2 (map Val vs') 0 0 @ shift (length (compEs2 (map Val vs'))) []) t h (rev vs', xs, length (compEs2 (map Val vs')) + 0, None) ⦃⦄ h (v # rev vs', xs, length (compEs2 (map Val vs')) + Suc 0, None)›*) apply (rule append_exec_meth_xt (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); jump_ok ?ins 0 ?n; pcs ?xt' ⊆ {0..<length ?ins'}⟧ ⟹ exec_meth ?ci ?P (?ins' @ ?ins) (?xt' @ shift (length ?ins') ?xt) ?t ?h (?stk, ?loc, length ?ins' + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', length ?ins' + ?pc', ?xcp')›*)) (*goals: 1. ‹exec_meth_a (compP2 P) [Push v] [] t h (rev vs', xs, 0, None) ⦃⦄ h (v # rev vs', xs, Suc 0, None)› 2. ‹jump_ok [Push v] 0 ?n› 3. ‹pcs (compxEs2 (map Val vs') 0 0) ⊆ {0..<length (compEs2 (map Val vs'))}› discuss goal 1*) apply ((auto simp add: exec_meth_instr (*‹exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, None) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp::'addr option) = ((?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc [] ∧ ?pc < length ?ins ∧ ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc [])›*))[1]) (*discuss goal 2*) apply ((auto simp add: exec_meth_instr (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp) = ((?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc [] ∧ ?pc < length ?ins ∧ ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc [])›*))[1]) (*discuss goal 3*) apply ((auto simp add: exec_meth_instr (*‹exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, None) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp::'addr option) = ((?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc [] ∧ ?pc < length ?ins ∧ ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc [])›*))[1]) (*proven 3 subgoals*) . moreover have "τmoves2 (compP2 P) h (rev vs') (map Val vs' @ [Val v]) (length (compEs2 (map Val vs')) + 0) None" apply (rule append_τmoves2 (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?es' @ ?es) (length (compEs2 ?es') + ?pc) ?xcp›*) τmoves2Hd (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?e # ?es) ?pc ?xcp›*) τmove2Val (*‹τmove2 ?P ?h ?stk (Val ?v) 0 None›*)) (*goal: ‹τmoves2 (compP2 P) h (rev vs') (map Val vs' @ [Val v]) (length (compEs2 (map Val vs')) + 0) None›*) apply (rule append_τmoves2 (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?es' @ ?es) (length (compEs2 ?es') + ?pc) ?xcp›*) τmoves2Hd (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?e # ?es) ?pc ?xcp›*) τmove2Val (*‹τmove2 ?P ?h ?stk (Val ?v) 0 None›*)) (*goal: ‹τmoves2 (compP2 P) h (rev vs') [Val v] 0 None›*) by (rule append_τmoves2 (*‹τmoves2 ?P ?h ?stk ?es ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?es' @ ?es) (length (compEs2 ?es') + ?pc) ?xcp›*) τmoves2Hd (*‹τmove2 ?P ?h ?stk ?e ?pc ?xcp ⟹ τmoves2 ?P ?h ?stk (?e # ?es) ?pc ?xcp›*) τmove2Val (*‹τmove2 ?P ?h ?stk (Val ?v) 0 None›*)) ultimately have "τExec_movesr_a P t (map Val (vs' @ [v])) h ((rev vs'), xs, (length ?E), None) ((rev (vs' @ [v])), xs, (length (compEs2 (map Val (vs' @ [v])))), None)" apply - (*goal: ‹τExec_movesr_a (P::'addr J1_prog) (t::'thread_id) (map Val ((vs'::'addr val list) @ [v::'addr val])) (h::'heap) (rev vs', xs::'addr val list, length (compEs2 (map Val vs')), None) (rev (vs' @ [v]), xs, length (compEs2 (map Val (vs' @ [v]))), None)›*) apply (rule τExecsr1step (*‹⟦exec_moves ?ci ?P ?t ?es ?h (?stk', ?loc', ?pc', ?xcp') ⦃⦄ ?h ?s'; τmoves2 ?P ?h ?stk' ?es ?pc' ?xcp'⟧ ⟹ τExec_movesr ?ci ?P ?t ?es ?h (?stk', ?loc', ?pc', ?xcp') ?s'›*)) (*goals: 1. ‹⟦exec_meth_a (compP2 P) (compEs2 (map Val vs') @ [Push v]) (compxEs2 (map Val vs') 0 0 @ shift (length (compEs2 (map Val vs'))) []) t h (rev vs', xs, length (compEs2 (map Val vs')) + 0, None) ⦃⦄ h (v # rev vs', xs, length (compEs2 (map Val vs')) + Suc 0, None); τmoves2 (compP2 P) h (rev vs') (map Val vs' @ [Val v]) (length (compEs2 (map Val vs')) + 0) None⟧ ⟹ exec_moves_a P t (map Val (vs' @ [v])) h (rev vs', xs, length (compEs2 (map Val vs')), None) ⦃⦄ h (rev (vs' @ [v]), xs, length (compEs2 (map Val (vs' @ [v]))), None)› 2. ‹⟦exec_meth_a (compP2 P) (compEs2 (map Val vs') @ [Push v]) (compxEs2 (map Val vs') 0 0 @ shift (length (compEs2 (map Val vs'))) []) t h (rev vs', xs, length (compEs2 (map Val vs')) + 0, None) ⦃⦄ h (v # rev vs', xs, length (compEs2 (map Val vs')) + Suc 0, None); τmoves2 (compP2 P) h (rev vs') (map Val vs' @ [Val v]) (length (compEs2 (map Val vs')) + 0) None⟧ ⟹ τmoves2 P h (rev vs') (map Val (vs' @ [v])) (length (compEs2 (map Val vs'))) None› discuss goal 1*) apply ((auto simp add: exec_moves_def (*‹exec_moves ?ci ?P ?t ?es ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*) compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*))[1]) (*discuss goal 2*) apply ((auto simp add: exec_moves_def (*‹exec_moves ?ci ?P ?t ?es ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*) compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*))[1]) (*proven 2 subgoals*) . } finally (*calculation: ‹τExec_movesr_a P t (map Val (vs' @ [v])) h ([], xs, 0, None) (rev (vs' @ [v]), xs, length (compEs2 (map Val (vs' @ [v]))), None)›*) show "?case" (*goal: ‹τExec_movesr_a (P::'addr J1_prog) (t::'thread_id) (map Val ((vs'::'addr val list) @ [v::'addr val])) (h::'heap) ([], xs::'addr val list, 0::nat, None) (rev (vs' @ [v]), xs, length (compEs2 (map Val (vs' @ [v]))), None)›*) . qed lemma τExec_mover_blocks1 [simp]: "τExec_mover ci P t (blocks1 n Ts body) h s s' = τExec_mover ci P t body h s s'" by (simp add: τexec_move_conv_τexec_meth (*‹τexec_move ?ci ?P ?t ?e = τexec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*)) lemma τExec_movet_blocks1 [simp]: "τExec_movet ci P t (blocks1 n Ts body) h s s' = τExec_movet ci P t body h s s'" by (simp add: τexec_move_conv_τexec_meth (*‹τexec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) = τexec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*)) definition τexec_1 :: "'addr jvm_prog ⇒ 'thread_id ⇒ ('addr, 'heap) jvm_state ⇒ ('addr, 'heap) jvm_state ⇒ bool" where "τexec_1 P t σ σ' ⟷ exec_1 P t σ ε σ' ∧ τMove2 P σ" lemma τexec_1I [intro]: "⟦ exec_1 P t σ ε σ'; τMove2 P σ ⟧ ⟹ τexec_1 P t σ σ'" by (simp add: τexec_1_def (*‹τexec_1 ?P ?t ?σ ?σ' = (?P,?t ⊢ ?σ -⦃⦄-jvm→ ?σ' ∧ τMove2 ?P ?σ)›*)) lemma τexec_1E [elim]: assumes "τexec_1 P t σ σ'" obtains "exec_1 P t σ ε σ'" "τMove2 P σ" using assms (*‹τexec_1 P t σ σ'›*) by (auto simp add: τexec_1_def (*‹τexec_1 (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?σ::'addr option × 'heap × 'addr frame list) (?σ'::'addr option × 'heap × 'addr frame list) = (?P,?t ⊢ ?σ -⦃⦄-jvm→ ?σ' ∧ τMove2 ?P ?σ)›*)) abbreviation τExec_1r :: "'addr jvm_prog ⇒ 'thread_id ⇒ ('addr, 'heap) jvm_state ⇒ ('addr, 'heap) jvm_state ⇒ bool" where "τExec_1r P t == (τexec_1 P t)^**" abbreviation τExec_1t :: "'addr jvm_prog ⇒ 'thread_id ⇒ ('addr, 'heap) jvm_state ⇒ ('addr, 'heap) jvm_state ⇒ bool" where "τExec_1t P t == (τexec_1 P t)^++" definition τexec_1_d :: "'addr jvm_prog ⇒ 'thread_id ⇒ ('addr, 'heap) jvm_state ⇒ ('addr, 'heap) jvm_state ⇒ bool" where "τexec_1_d P t σ σ' ⟷ exec_1 P t σ ε σ' ∧ τMove2 P σ ∧ check P σ" lemma τexec_1_dI [intro]: "⟦ exec_1 P t σ ε σ'; check P σ; τMove2 P σ ⟧ ⟹ τexec_1_d P t σ σ'" by (simp add: τexec_1_d_def (*‹τexec_1_d (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?σ::'addr option × 'heap × 'addr frame list) (?σ'::'addr option × 'heap × 'addr frame list) = (?P,?t ⊢ ?σ -⦃⦄-jvm→ ?σ' ∧ τMove2 ?P ?σ ∧ check ?P ?σ)›*)) lemma τexec_1_dE [elim]: assumes "τexec_1_d P t σ σ'" obtains "exec_1 P t σ ε σ'" "check P σ" "τMove2 P σ" using assms (*‹τexec_1_d P t σ σ'›*) by (auto simp add: τexec_1_d_def (*‹τexec_1_d (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id) (?σ::'addr option × 'heap × 'addr frame list) (?σ'::'addr option × 'heap × 'addr frame list) = (?P,?t ⊢ ?σ -⦃⦄-jvm→ ?σ' ∧ τMove2 ?P ?σ ∧ check ?P ?σ)›*)) abbreviation τExec_1_dr :: "'addr jvm_prog ⇒ 'thread_id ⇒ ('addr, 'heap) jvm_state ⇒ ('addr, 'heap) jvm_state ⇒ bool" where "τExec_1_dr P t == (τexec_1_d P t)^**" abbreviation τExec_1_dt :: "'addr jvm_prog ⇒ 'thread_id ⇒ ('addr, 'heap) jvm_state ⇒ ('addr, 'heap) jvm_state ⇒ bool" where "τExec_1_dt P t == (τexec_1_d P t)^++" declare compxE2_size_convs[simp del] compxEs2_size_convs[simp del] declare compxE2_stack_xlift_convs[simp del] compxEs2_stack_xlift_convs[simp del] lemma exec_instr_frs_offer: "(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Load x1⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 2. ‹⋀x2. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Store x2⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 3. ‹⋀x3. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Push x3⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 4. ‹⋀x4. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = New x4⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 5. ‹⋀x5. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 6. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = ALoad⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 7. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = AStore⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 8. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = ALength⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 9. ‹⋀x91 x92. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 10. ‹⋀x101 x102. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 11. ‹⋀x111 x112. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 12. ‹⋀x12. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 13. ‹⋀x13. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 14. ‹⋀x141 x142. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 15. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Return⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 16. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Pop⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 17. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Dup⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 18. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Swap⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 19. ‹⋀x19. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 20. ‹⋀x20. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Goto x20⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 21. ‹⋀x21. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 22. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 23. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = MEnter⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› 24. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = MExit⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› discuss goal 1*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 2*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 3*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 4*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x4. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = New x4⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› and 20 goals remain*) apply (force split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 5*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x5. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› and 19 goals remain*) apply (force split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 6*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 7*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = AStore⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› and 17 goals remain*) apply (force split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 8*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 9*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 10*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 11*) apply (simp add: nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c::type ⇒ bool) (case ?sum::?'a::type + ?'b::type of Inl (x::?'a::type) ⇒ (?f1.0::?'a::type ⇒ ?'c::type) x | Inr (x::?'b::type) ⇒ (?f2.0::?'b::type ⇒ ?'c::type) x) = (¬ ((∃x1::?'a::type. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b::type. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 12*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 13*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 14*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x141 x142. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ (ta, xcp', h', (stk', loc', C, M, pc') # frs @ frs') ∈ exec_instr ins P t h stk loc C M pc (frs @ frs')› and 10 goals remain*) apply (force split: extCallRet.split_asm (*‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = (¬ ((∃x1::?'addr val. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'addr. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λ(uu::nat) (uua::?'heap) (uub::?'addr val list) (uuc::?'addr val list) (uud::String.literal) (uue::String.literal) (uuf::nat) (uug::?'addr frame list) uuh::?'addr extCallRet. rec_extCallRet (λ(v::?'addr val) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + (1::nat)) # frs)) (λ(a::?'addr) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λ(n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 15*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 16*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 17*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 18*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 19*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 20*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 21*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 22*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 23*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 24*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*proven 24 subgoals*) . lemma check_instr_frs_offer: "⟦ check_instr ins P h stk loc C M pc frs; ins ≠ Return ⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Load x1⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 2. ‹⋀x2. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Store x2⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 3. ‹⋀x3. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Push x3⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 4. ‹⋀x4. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = New x4⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 5. ‹⋀x5. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = NewArray x5⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 6. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = ALoad⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 7. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = AStore⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 8. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = ALength⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 9. ‹⋀x91 x92. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Getfield x91 x92⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 10. ‹⋀x101 x102. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Putfield x101 x102⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 11. ‹⋀x111 x112. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = CAS x111 x112⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 12. ‹⋀x12. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Checkcast x12⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 13. ‹⋀x13. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Instanceof x13⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 14. ‹⋀x141 x142. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Invoke x141 x142⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 15. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Return⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 16. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Pop⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 17. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Dup⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 18. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Swap⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 19. ‹⋀x19. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = BinOpInstr x19⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 20. ‹⋀x20. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Goto x20⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 21. ‹⋀x21. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = IfFalse x21⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 22. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = ThrowExc⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 23. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = MEnter⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› 24. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = MExit⟧ ⟹ check_instr ins P h stk loc C M pc (frs @ frs')› discuss goal 1*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 2*) apply (simp split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 3*) apply (simp split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 4*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 5*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 6*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 7*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 8*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 9*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 10*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 11*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 12*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 13*) apply (simp split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 14*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 15*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 16*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 17*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 18*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 19*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 20*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 21*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 22*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 23*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 24*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*proven 24 subgoals*) . lemma exec_instr_CM_change: "(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Load x1⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 2. ‹⋀x2. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Store x2⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 3. ‹⋀x3. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Push x3⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 4. ‹⋀x4. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = New x4⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 5. ‹⋀x5. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 6. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = ALoad⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 7. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = AStore⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 8. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = ALength⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 9. ‹⋀x91 x92. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Getfield x91 x92⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 10. ‹⋀x101 x102. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Putfield x101 x102⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 11. ‹⋀x111 x112. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = CAS x111 x112⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 12. ‹⋀x12. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Checkcast x12⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 13. ‹⋀x13. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Instanceof x13⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 14. ‹⋀x141 x142. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 15. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Return⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 16. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Pop⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 17. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Dup⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 18. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Swap⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 19. ‹⋀x19. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = BinOpInstr x19⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 20. ‹⋀x20. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Goto x20⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 21. ‹⋀x21. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = IfFalse x21⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 22. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = ThrowExc⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 23. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = MEnter⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› 24. ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = MExit⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› discuss goal 1*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 2*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 3*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 4*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x4::String.literal. ⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, (stk'::'addr val list, loc'::'addr val list, C::String.literal, M::String.literal, pc'::nat) # (frs::'addr frame list)) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) C M (pc::nat) frs; ins = New x4⟧ ⟹ (ta, xcp', h', (stk', loc', C'::String.literal, M'::String.literal, pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› and 20 goals remain*) apply (force split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 5*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x5. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = NewArray x5⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› and 19 goals remain*) apply (force split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 6*) apply (simp add: nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹((?xs::?'a::type list) ≠ []) = (∃(y::?'a::type) ys::?'a::type list. ?xs = y # ys)›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c::type ⇒ bool) (case ?sum::?'a::type + ?'b::type of Inl (x::?'a::type) ⇒ (?f1.0::?'a::type ⇒ ?'c::type) x | Inr (x::?'b::type) ⇒ (?f2.0::?'b::type ⇒ ?'c::type) x) = (¬ ((∃x1::?'a::type. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b::type. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 7*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = AStore⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› and 17 goals remain*) apply (force split: extCallRet.split_asm (*‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = (¬ ((∃x1::?'addr val. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'addr. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λ(uu::nat) (uua::?'heap) (uub::?'addr val list) (uuc::?'addr val list) (uud::String.literal) (uue::String.literal) (uuf::nat) (uug::?'addr frame list) uuh::?'addr extCallRet. rec_extCallRet (λ(v::?'addr val) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + (1::nat)) # frs)) (λ(a::?'addr) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λ(n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 8*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 9*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 10*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 11*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 12*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 13*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 14*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⋀x141 x142. ⟦(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr ins P t h stk loc C M pc frs; ins = Invoke x141 x142⟧ ⟹ (ta, xcp', h', (stk', loc', C', M', pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› and 10 goals remain*) apply (force split: extCallRet.split_asm (*‹?P (case ?extCallRet of RetVal x ⇒ ?f1.0 x | RetExc x ⇒ ?f2.0 x | RetStaySame ⇒ ?f3.0) = (¬ ((∃x1. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λuu uua uub uuc uud uue uuf uug uuh. rec_extCallRet (λv n h stk loc C M pc frs. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + 1) # frs)) (λa n h stk loc C M pc frs. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λn h stk loc C M pc frs. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 15*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*top goal: ‹⟦(ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, (stk'::'addr val list, loc'::'addr val list, C::String.literal, M::String.literal, pc'::nat) # (frs::'addr frame list)) ∈ exec_instr (ins::'addr instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) C M (pc::nat) frs; ins = Return⟧ ⟹ (ta, xcp', h', (stk', loc', C'::String.literal, M'::String.literal, pc') # frs) ∈ exec_instr ins P t h stk loc C' M' pc frs› and 9 goals remain*) apply (force split: extCallRet.split_asm (*‹(?P::?'a ⇒ bool) (case ?extCallRet::?'addr extCallRet of RetVal (x::?'addr val) ⇒ (?f1.0::?'addr val ⇒ ?'a) x | RetExc (x::?'addr) ⇒ (?f2.0::?'addr ⇒ ?'a) x | RetStaySame ⇒ ?f3.0::?'a) = (¬ ((∃x1::?'addr val. ?extCallRet = RetVal x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'addr. ?extCallRet = RetExc x2 ∧ ¬ ?P (?f2.0 x2)) ∨ ?extCallRet = RetStaySame ∧ ¬ ?P ?f3.0))›*) simp add: extRet2JVM_def (*‹extRet2JVM ≡ λ(uu::nat) (uua::?'heap) (uub::?'addr val list) (uuc::?'addr val list) (uud::String.literal) (uue::String.literal) (uuf::nat) (uug::?'addr frame list) uuh::?'addr extCallRet. rec_extCallRet (λ(v::?'addr val) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (v # drop (Suc n) stk, loc, C, M, pc + (1::nat)) # frs)) (λ(a::?'addr) (n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (⌊a⌋, h, (stk, loc, C, M, pc) # frs)) (λ(n::nat) (h::?'heap) (stk::?'addr val list) (loc::?'addr val list) (C::String.literal) (M::String.literal) (pc::nat) frs::?'addr frame list. (None, h, (stk, loc, C, M, pc) # frs)) uuh uu uua uub uuc uud uue uuf uug›*)) (*discuss goal 16*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 17*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 18*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 19*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 20*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 21*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 22*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹(?xs ≠ []) = (∃y ys. ?xs = y # ys)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹?P (case ?sum of Inl x ⇒ ?f1.0 x | Inr x ⇒ ?f2.0 x) = (¬ ((∃x1. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 23*) apply (simp add: nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹((?xs::?'a::type list) ≠ []) = (∃(y::?'a::type) ys::?'a::type list. ?xs = y # ys)›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c::type ⇒ bool) (case ?sum::?'a::type + ?'b::type of Inl (x::?'a::type) ⇒ (?f1.0::?'a::type ⇒ ?'c::type) x | Inr (x::?'b::type) ⇒ (?f2.0::?'b::type ⇒ ?'c::type) x) = (¬ ((∃x1::?'a::type. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b::type. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 24*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*) neq_Nil_conv (*‹((?xs::?'a list) ≠ []) = (∃(y::?'a) ys::?'a list. ?xs = y # ys)›*) split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) sum.split_asm (*‹(?P::?'c ⇒ bool) (case ?sum::?'a + ?'b of Inl (x::?'a) ⇒ (?f1.0::?'a ⇒ ?'c) x | Inr (x::?'b) ⇒ (?f2.0::?'b ⇒ ?'c) x) = (¬ ((∃x1::?'a. ?sum = Inl x1 ∧ ¬ ?P (?f1.0 x1)) ∨ (∃x2::?'b. ?sum = Inr x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*proven 24 subgoals*) . lemma check_instr_CM_change: "⟦ check_instr ins P h stk loc C M pc frs; ins ≠ Return ⟧ ⟹ check_instr ins P h stk loc C' M' pc frs" apply (cases ins) (*goals: 1. ‹⋀x1. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Load x1⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 2. ‹⋀x2. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Store x2⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 3. ‹⋀x3. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Push x3⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 4. ‹⋀x4. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = New x4⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 5. ‹⋀x5. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = NewArray x5⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 6. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = ALoad⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 7. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = AStore⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 8. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = ALength⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 9. ‹⋀x91 x92. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Getfield x91 x92⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 10. ‹⋀x101 x102. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Putfield x101 x102⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 11. ‹⋀x111 x112. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = CAS x111 x112⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 12. ‹⋀x12. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Checkcast x12⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 13. ‹⋀x13. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Instanceof x13⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 14. ‹⋀x141 x142. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Invoke x141 x142⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 15. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Return⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 16. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Pop⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 17. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Dup⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 18. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Swap⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 19. ‹⋀x19. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = BinOpInstr x19⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 20. ‹⋀x20. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = Goto x20⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 21. ‹⋀x21. ⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = IfFalse x21⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 22. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = ThrowExc⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 23. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = MEnter⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› 24. ‹⟦check_instr ins P h stk loc C M pc frs; ins ≠ Return; ins = MExit⟧ ⟹ check_instr ins P h stk loc C' M' pc frs› discuss goal 1*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 2*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 3*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 4*) apply (simp split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 5*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 6*) apply (simp split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 7*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 8*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 9*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 10*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 11*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 12*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 13*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 14*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 15*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 16*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 17*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 18*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 19*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 20*) apply (simp split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 21*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 22*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 23*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*discuss goal 24*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*proven 24 subgoals*) . lemma exec_move_exec_1: assumes exec: "exec_move ci P t body h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')" and sees: "P ⊢ C sees M : Ts→T = ⌊body⌋ in D" shows "exec_1 (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs) ta (xcp', h', (stk', loc', C, M, pc') # frs)" using exec (*‹exec_move ci P t body h (stk, loc, pc, xcp) ta h' (stk', loc', pc', xcp')›*) unfolding exec_move_def (*goal: ‹compP2 P,t ⊢ (xcp, h, (stk, loc, C, M, pc) # frs) -ta-jvm→ (xcp', h', (stk', loc', C, M, pc') # frs)›*) proof (cases) (*goals: 1. ‹⟦(xcp::'addr option) = None; (ta::('addr, 'thread_id, 'heap) jvm_thread_action, xcp'::'addr option, h'::'heap, [(stk'::'addr val list, loc'::'addr val list, undefined, undefined, pc'::nat)]) ∈ exec_instr (compE2 (body::'addr expr1) ! (pc::nat)) (compP2 (P::'addr J1_prog)) (t::'thread_id) (h::'heap) (stk::'addr val list) (loc::'addr val list) undefined undefined pc []; pc < length (compE2 body); ci_app (ci::('addr, 'heap) check_instr) (compE2 body ! pc) (compP2 P) h stk loc undefined undefined pc []⟧ ⟹ compP2 P,t ⊢ (xcp, h, (stk, loc, C::String.literal, M::String.literal, pc) # (frs::'addr frame list)) -ta-jvm→ (xcp', h', (stk', loc', C, M, pc') # frs)› 2. ‹⋀(xcpa::'addr) d::nat. ⟦(xcp::'addr option) = ⌊xcpa⌋; (ta::('addr, 'thread_id, 'heap) jvm_thread_action) = ⦃⦄; (h'::'heap) = (h::'heap); (stk'::'addr val list) = Addr xcpa # drop (length (stk::'addr val list) - d) stk; (loc'::'addr val list) = (loc::'addr val list); (xcp'::'addr option) = None; match_ex_table (compP2 (P::'addr J1_prog)) (cname_of h xcpa) (pc::nat) (compxE2 (body::'addr expr1) (0::nat) (0::nat)) = ⌊(pc'::nat, d)⌋; d ≤ length stk⟧ ⟹ compP2 P,t::'thread_id ⊢ (xcp, h, (stk, loc, C::String.literal, M::String.literal, pc) # (frs::'addr frame list)) -ta-jvm→ (xcp', h', (stk', loc', C, M, pc') # frs)›*) case exec_instr (*‹(xcp::'addr::addr option) = None› ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc undefined undefined pc []› ‹pc < length (compE2 body)› ‹ci_app ci (compE2 body ! pc) (compP2 P) h stk loc undefined undefined pc []›*) note [simp] = ‹xcp = None› (*‹(xcp::'addr option) = None›*) and exec = ‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc undefined undefined pc []› (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc undefined undefined pc []›*) from exec (*‹(ta, xcp', h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc undefined undefined pc []›*) have "(ta, xcp', h', [(stk', loc', C, M, pc')]) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc C M pc []" by (rule exec_instr_CM_change (*‹(?ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action, ?xcp'::'addr::addr option, ?h'::'heap::type, (?stk'::'addr::addr val list, ?loc'::'addr::addr val list, ?C::String.literal, ?M::String.literal, ?pc'::nat) # (?frs::'addr::addr frame list)) ∈ exec_instr (?ins::'addr::addr instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?t::'thread_id::type) (?h::'heap::type) (?stk::'addr::addr val list) (?loc::'addr::addr val list) ?C ?M (?pc::nat) ?frs ⟹ (?ta, ?xcp', ?h', (?stk', ?loc', ?C'::String.literal, ?M'::String.literal, ?pc') # ?frs) ∈ exec_instr ?ins ?P ?t ?h ?stk ?loc ?C' ?M' ?pc ?frs›*)) from exec_instr_frs_offer[OF this, of frs] (*‹(ta, xcp', h', (stk', loc', C, M, pc') # [] @ frs) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc C M pc ([] @ frs)›*) have "(ta, xcp', h', (stk', loc', C, M, pc') # frs) ∈ exec_instr (compE2 body ! pc) (compP2 P) t h stk loc C M pc frs" by simp with sees (*‹P ⊢ C sees M: Ts→T = ⌊body⌋ in D›*) ‹pc < length (compE2 body)› (*‹pc < length (compE2 body)›*) show "?thesis" (*goal: ‹compP2 P,t ⊢ (xcp, h, (stk, loc, C, M, pc) # frs) -ta-jvm→ (xcp', h', (stk', loc', C, M, pc') # frs)›*) by (simp add: exec_1_iff (*‹?P,?t ⊢ ?σ -?ta-jvm→ ?σ' = ((?ta, ?σ') ∈ exec ?P ?t ?σ)›*) compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*) compMb2_def (*‹compMb2 ≡ λbody. let ins = compE2 body @ [Return]; xt = compxE2 body 0 0 in (max_stack body, max_vars body, ins, xt)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) next (*goal: ‹⋀xcpa d. ⟦xcp = ⌊xcpa⌋; ta = ⦃⦄; h' = h; stk' = Addr xcpa # drop (length stk - d) stk; loc' = loc; xcp' = None; match_ex_table (compP2 P) (cname_of h xcpa) pc (compxE2 body 0 0) = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ compP2 P,t ⊢ (xcp, h, (stk, loc, C, M, pc) # frs) -ta-jvm→ (xcp', h', (stk', loc', C, M, pc') # frs)›*) case exec_catch (*‹(xcp::'addr option) = ⌊xcp_::'addr⌋› ‹(ta::('addr, 'thread_id, 'heap) jvm_thread_action) = ⦃⦄› ‹(h'::'heap) = (h::'heap)› ‹(stk'::'addr val list) = Addr (xcp_::'addr) # drop (length (stk::'addr val list) - (d_::nat)) stk› ‹loc' = loc› ‹(xcp'::'addr option) = None› ‹match_ex_table (compP2 P) (cname_of h xcp_) pc (compxE2 body 0 0) = ⌊(pc', d_)⌋› ‹(d_::nat) ≤ length (stk::'addr val list)›*) thus "?thesis" (*goal: ‹compP2 P,t ⊢ (xcp, h, (stk, loc, C, M, pc) # frs) -ta-jvm→ (xcp', h', (stk', loc', C, M, pc') # frs)›*) using sees_method_compP[OF sees, of "λC M Ts T. compMb2"] (*‹compP (λ(C::String.literal) (M::String.literal) (Ts::ty list) T::ty. compMb2) (P::'addr::addr J1_prog) ⊢ (C::String.literal) sees (M::String.literal): (Ts::ty list)→(T::ty) = map_option compMb2 ⌊body::'addr::addr expr1⌋ in (D::String.literal)›*) by (simp add: exec_1_iff (*‹?P,?t ⊢ ?σ -?ta-jvm→ ?σ' = ((?ta, ?σ') ∈ exec ?P ?t ?σ)›*) compMb2_def (*‹compMb2 ≡ λbody. let ins = compE2 body @ [Return]; xt = compxE2 body 0 0 in (max_stack body, max_vars body, ins, xt)›*) compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*)) qed lemma τexec_move_τexec_1: assumes exec: "τexec_move ci P t body h (stk, loc, pc, xcp) (stk', loc', pc', xcp')" and sees: "P ⊢ C sees M : Ts→T = ⌊body⌋ in D" shows "τexec_1 (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs) (xcp', h, (stk', loc', C, M, pc') # frs)" proof (rule τexec_1I (*‹⟦(?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog),?t::'thread_id ⊢ (?σ::'addr option × 'heap × 'addr frame list) -⦃⦄-jvm→ (?σ'::'addr option × 'heap × 'addr frame list); τMove2 ?P ?σ⟧ ⟹ τexec_1 ?P ?t ?σ ?σ'›*)) (*goals: 1. ‹compP2 P,t ⊢ (xcp, h, (stk, loc, C, M, pc) # frs) -⦃⦄-jvm→ (xcp', h, (stk', loc', C, M, pc') # frs)› 2. ‹τMove2 (compP2 P) (xcp, h, (stk, loc, C, M, pc) # frs)›*) from exec (*‹τexec_move ci P t body h (stk, loc, pc, xcp) (stk', loc', pc', xcp')›*) obtain exec': "exec_move ci P t body h (stk, loc, pc, xcp) ε h (stk', loc', pc', xcp')" and "τ": "τmove2 P h stk body pc xcp" (*goal: ‹(⟦exec_move (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (body::'addr::addr expr1) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) ⦃⦄ h (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option); τmove2 P h stk body pc xcp⟧ ⟹ thesis::bool) ⟹ thesis›*) by (rule τexec_moveE (*‹⟦τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ?s'; ⟦exec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) ⦃⦄ ?h ?s'; τmove2 ?P ?h ?stk ?e ?pc ?xcp⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) have "exec_1 (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs) ε (xcp', h, (stk', loc', C, M, pc') # frs)" using exec' (*‹exec_move ci P t body h (stk, loc, pc, xcp) ⦃⦄ h (stk', loc', pc', xcp')›*) sees (*‹P ⊢ C sees M: Ts→T = ⌊body⌋ in D›*) by (rule exec_move_exec_1 (*‹⟦exec_move ?ci ?P ?t ?body ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); ?P ⊢ ?C sees ?M: ?Ts→?T = ⌊?body⌋ in ?D⟧ ⟹ compP2 ?P,?t ⊢ (?xcp, ?h, (?stk, ?loc, ?C, ?M, ?pc) # ?frs) -?ta-jvm→ (?xcp', ?h', (?stk', ?loc', ?C, ?M, ?pc') # ?frs)›*)) thus "compP2 P,t ⊢ (xcp, h, (stk, loc, C, M, pc) # frs) -ε-jvm→ (xcp', h, (stk', loc', C, M, pc') # frs)" by auto { fix a assume [simp]: "xcp = ⌊a⌋" (*‹(xcp::'addr option) = ⌊a::'addr⌋›*) from sees_method_compP[OF sees, of "λC M Ts T. compMb2"] (*‹compP (λC M Ts T. compMb2) P ⊢ C sees M: Ts→T = map_option compMb2 ⌊body⌋ in D›*) have "ex_table_of (compP2 P) C M = compxE2 body 0 0" by (simp add: compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*) compMb2_def (*‹compMb2 ≡ λbody. let ins = compE2 body @ [Return]; xt = compxE2 body 0 0 in (max_stack body, max_vars body, ins, xt)›*)) hence "match_ex_table (compP2 P) (cname_of h a) pc (ex_table_of (compP2 P) C M) ≠ None" "pc < length (compE2 body)" using exec' (*‹exec_move ci P t body h (stk, loc, pc, xcp) ⦃⦄ h (stk', loc', pc', xcp')›*) sees (*‹P ⊢ C sees M: Ts→T = ⌊body⌋ in D›*) apply - (*goals: 1. ‹⟦ex_table_of (compP2 P) C M = compxE2 body 0 0; exec_move ci P t body h (stk, loc, pc, xcp) ⦃⦄ h (stk', loc', pc', xcp'); P ⊢ C sees M: Ts→T = ⌊body⌋ in D⟧ ⟹ match_ex_table (compP2 P) (cname_of h a) pc (ex_table_of (compP2 P) C M) ≠ None› 2. ‹⟦ex_table_of (compP2 P) C M = compxE2 body 0 0; exec_move ci P t body h (stk, loc, pc, xcp) ⦃⦄ h (stk', loc', pc', xcp'); P ⊢ C sees M: Ts→T = ⌊body⌋ in D⟧ ⟹ pc < length (compE2 body)› discuss goal 1*) apply ((auto simp add: exec_move_def (*‹exec_move ?ci ?P ?t ?e ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e 0 0) ?t›*) elim: exec_meth.cases (*‹⟦exec_meth ?ci ?P ?ins ?xt ?t ?a1.0 ?a2.0 ?a3.0 ?a4.0 ?a5.0; ⋀ta xcp h' stk' loc' pc' pc h stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa; ⋀h xcp pc pc' d stk loc. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))[1]) (*discuss goal 2*) apply ((auto simp add: exec_move_def (*‹exec_move (?ci::('addr::addr, 'heap::type) check_instr) (?P::'addr::addr J1_prog) (?t::'thread_id::type) (?e::'addr::addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*) elim: exec_meth.cases (*‹⟦exec_meth (?ci::('addr::addr, 'heap::type) check_instr) (?P::(nat × nat × 'addr::addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr::addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id::type) (?a1.0::'heap::type) (?a2.0::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) (?a3.0::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (?a4.0::'heap::type) (?a5.0::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option); ⋀(ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (xcp::'addr::addr option) (h'::'heap::type) (stk'::'addr::addr val list) (loc'::'addr::addr val list) (pc'::nat) (pc::nat) (h::'heap::type) (stk::'addr::addr val list) loc::'addr::addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa::bool; ⋀(h::'heap::type) (xcp::'addr::addr) (pc::nat) (pc'::nat) (d::nat) (stk::'addr::addr val list) loc::'addr::addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*))[1]) (*proven 2 subgoals*) . } with "τ" (*‹τmove2 (P::'addr::addr J1_prog) (h::'heap::type) (stk::'addr::addr val list) (body::'addr::addr expr1) (pc::nat) (xcp::'addr::addr option)›*) sees (*‹P ⊢ C sees M: Ts→T = ⌊body⌋ in D›*) sees_method_compP[OF sees, of "λC M Ts T. compMb2"] (*‹compP (λC M Ts T. compMb2) P ⊢ C sees M: Ts→T = map_option compMb2 ⌊body⌋ in D›*) show "τMove2 (compP2 P) (xcp, h, (stk, loc, C, M, pc) # frs)" unfolding "τMove2_compP2"[OF sees] (*goal: ‹case xcp of None ⇒ τmove2 P h stk body pc xcp ∨ pc = length (compE2 body) | ⌊a⌋ ⇒ pc < Suc (length (compE2 body))›*) by (fastforce simp add: compP2_def (*‹compP2 ≡ compP (λC M Ts T. compMb2)›*) compMb2_def (*‹compMb2 ≡ λbody. let ins = compE2 body @ [Return]; xt = compxE2 body 0 0 in (max_stack body, max_vars body, ins, xt)›*)) qed lemma τExec_mover_τExec_1r: assumes move: "τExec_mover ci P t body h (stk, loc, pc, xcp) (stk', loc', pc', xcp')" and sees: "P ⊢ C sees M : Ts→T = ⌊body⌋ in D" shows "τExec_1r (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs') (xcp', h, (stk', loc', C, M, pc') # frs')" using move (*‹τExec_mover (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (body::'addr::addr expr1) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (stk'::'addr::addr val list, loc'::'addr::addr val list, pc'::nat, xcp'::'addr::addr option)›*) apply (induct rule: τExecr_induct (*‹⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ?Q ?stk ?loc ?pc ?xcp; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹τExec_1r (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs') (xcp, h, (stk, loc, C, M, pc) # frs')› 2. ‹⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_mover ci P t body h (stk, loc, pc, xcp) (stk', loc', pc', xcp'); τexec_move ci P t body h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_1r (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs') (xcp', h, (stk', loc', C, M, pc') # frs')⟧ ⟹ τExec_1r (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs') (xcp'', h, (stk'', loc'', C, M, pc'') # frs')› discuss goal 1*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) τexec_move_τexec_1[OF _ sees] (*‹τexec_move ?ci P ?t body ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_1 (compP2 P) ?t (?xcp, ?h, (?stk, ?loc, C, M, ?pc) # ?frs) (?xcp', ?h, (?stk', ?loc', C, M, ?pc') # ?frs)›*)) (*discuss goal 2*) apply (blast intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*) τexec_move_τexec_1[OF _ sees] (*‹τexec_move ?ci P ?t body ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_1 (compP2 P) ?t (?xcp, ?h, (?stk, ?loc, C, M, ?pc) # ?frs) (?xcp', ?h, (?stk', ?loc', C, M, ?pc') # ?frs)›*)) (*proven 2 subgoals*) . lemma τExec_movet_τExec_1t: assumes move: "τExec_movet ci P t body h (stk, loc, pc, xcp) (stk', loc', pc', xcp')" and sees: "P ⊢ C sees M : Ts→T = ⌊body⌋ in D" shows "τExec_1t (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs') (xcp', h, (stk', loc', C, M, pc') # frs')" using move (*‹τExec_movet ci P t body h (stk, loc, pc, xcp) (stk', loc', pc', xcp')›*) apply (induct rule: τExect_induct (*‹⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (?stk'', ?loc'', ?pc'', ?xcp''); ⋀stk' loc' pc' xcp'. τexec_move ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp') ⟹ ?Q stk' loc' pc' xcp'; ⋀stk' loc' pc' xcp' stk'' loc'' pc'' xcp''. ⟦τExec_movet ?ci ?P ?t ?e ?h (?stk, ?loc, ?pc, ?xcp) (stk', loc', pc', xcp'); τexec_move ?ci ?P ?t ?e ?h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); ?Q stk' loc' pc' xcp'⟧ ⟹ ?Q stk'' loc'' pc'' xcp''⟧ ⟹ ?Q ?stk'' ?loc'' ?pc'' ?xcp''›*)) (*goals: 1. ‹⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) xcp'::'addr option. τexec_move (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (body::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (stk', loc', pc', xcp') ⟹ τExec_1t (compP2 P) t (xcp, h, (stk, loc, C::String.literal, M::String.literal, pc) # (frs'::'addr frame list)) (xcp', h, (stk', loc', C, M, pc') # frs')› 2. ‹⋀(stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (xcp'::'addr option) (stk''::'addr val list) (loc''::'addr val list) (pc''::nat) xcp''::'addr option. ⟦τExec_movet (ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (t::'thread_id) (body::'addr expr1) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (stk', loc', pc', xcp'); τexec_move ci P t body h (stk', loc', pc', xcp') (stk'', loc'', pc'', xcp''); τExec_1t (compP2 P) t (xcp, h, (stk, loc, C::String.literal, M::String.literal, pc) # (frs'::'addr frame list)) (xcp', h, (stk', loc', C, M, pc') # frs')⟧ ⟹ τExec_1t (compP2 P) t (xcp, h, (stk, loc, C, M, pc) # frs') (xcp'', h, (stk'', loc'', C, M, pc'') # frs')› discuss goal 1*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⁺⁺ (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⁺⁺ ?a ?c›*) τexec_move_τexec_1[OF _ sees] (*‹τexec_move (?ci::('addr, 'heap) check_instr) (P::'addr J1_prog) (?t::'thread_id) (body::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option) ⟹ τexec_1 (compP2 P) ?t (?xcp, ?h, (?stk, ?loc, C::String.literal, M::String.literal, ?pc) # (?frs::'addr frame list)) (?xcp', ?h, (?stk', ?loc', C, M, ?pc') # ?frs)›*)) (*discuss goal 2*) apply (blast intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*) τexec_move_τexec_1[OF _ sees] (*‹τexec_move ?ci P ?t body ?h (?stk, ?loc, ?pc, ?xcp) (?stk', ?loc', ?pc', ?xcp') ⟹ τexec_1 (compP2 P) ?t (?xcp, ?h, (?stk, ?loc, C, M, ?pc) # ?frs) (?xcp', ?h, (?stk', ?loc', C, M, ?pc') # ?frs)›*)) (*proven 2 subgoals*) . lemma τExec_1r_rtranclpD: "τExec_1r P t (xcp, h, frs) (xcp', h', frs') ⟹ (λ((xcp, frs), h) ((xcp', frs'), h'). exec_1 P t (xcp, h, frs) ε (xcp', h', frs') ∧ τMove2 P (xcp, h, frs))^** ((xcp, frs), h) ((xcp', frs'), h')" apply (induct rule: rtranclp_induct3 (*‹⟦?r⇧*⇧* (?ax, ?ay, ?az) (?bx, ?by, ?bz); ?P ?ax ?ay ?az; ⋀a aa b ab ac ba. ⟦?r⇧*⇧* (?ax, ?ay, ?az) (a, aa, b); ?r (a, aa, b) (ab, ac, ba); ?P a aa b⟧ ⟹ ?P ab ac ba⟧ ⟹ ?P ?bx ?by ?bz›*)) (*goals: 1. ‹(λa. case a of (a, b) ⇒ (case a of (xcp, frs) ⇒ λh a. case a of (a, b) ⇒ (case a of (xcp', frs') ⇒ λh'. P,t ⊢ (xcp, h, frs) -⦃⦄-jvm→ (xcp', h', frs') ∧ τMove2 P (xcp, h, frs)) b) b)⇧*⇧* ((xcp, frs), h) ((xcp, frs), h)› 2. ‹⋀a aa b ab ac ba. ⟦τExec_1r P t (xcp, h, frs) (a, aa, b); τexec_1 P t (a, aa, b) (ab, ac, ba); (λa. case a of (a, b) ⇒ (case a of (xcp, frs) ⇒ λh a. case a of (a, b) ⇒ (case a of (xcp', frs') ⇒ λh'. P,t ⊢ (xcp, h, frs) -⦃⦄-jvm→ (xcp', h', frs') ∧ τMove2 P (xcp, h, frs)) b) b)⇧*⇧* ((xcp, frs), h) ((a, b), aa)⟧ ⟹ (λa. case a of (a, b) ⇒ (case a of (xcp, frs) ⇒ λh a. case a of (a, b) ⇒ (case a of (xcp', frs') ⇒ λh'. P,t ⊢ (xcp, h, frs) -⦃⦄-jvm→ (xcp', h', frs') ∧ τMove2 P (xcp, h, frs)) b) b)⇧*⇧* ((xcp, frs), h) ((ab, ba), ac)› discuss goal 1*) apply (fastforce intro: rtranclp.rtrancl_into_rtrancl (*‹⟦(?r::?'a ⇒ ?'a ⇒ bool)⇧*⇧* (?a::?'a) (?b::?'a); ?r ?b (?c::?'a)⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) (*discuss goal 2*) apply (fastforce intro: rtranclp.rtrancl_into_rtrancl (*‹⟦?r⇧*⇧* ?a ?b; ?r ?b ?c⟧ ⟹ ?r⇧*⇧* ?a ?c›*)) (*proven 2 subgoals*) . lemma τExec_1t_rtranclpD: "τExec_1t P t (xcp, h, frs) (xcp', h', frs') ⟹ (λ((xcp, frs), h) ((xcp', frs'), h'). exec_1 P t (xcp, h, frs) ε (xcp', h', frs') ∧ τMove2 P (xcp, h, frs))^++ ((xcp, frs), h) ((xcp', frs'), h')" apply (induct rule: tranclp_induct3 (*‹⟦?r⁺⁺ (?ax, ?ay, ?az) (?bx, ?by, ?bz); ⋀a aa b. ?r (?ax, ?ay, ?az) (a, aa, b) ⟹ ?P a aa b; ⋀a aa b ab ac ba. ⟦?r⁺⁺ (?ax, ?ay, ?az) (a, aa, b); ?r (a, aa, b) (ab, ac, ba); ?P a aa b⟧ ⟹ ?P ab ac ba⟧ ⟹ ?P ?bx ?by ?bz›*)) (*goals: 1. ‹⋀a aa b. τexec_1 P t (xcp, h, frs) (a, aa, b) ⟹ (λa. case a of (a, b) ⇒ (case a of (xcp, frs) ⇒ λh a. case a of (a, b) ⇒ (case a of (xcp', frs') ⇒ λh'. P,t ⊢ (xcp, h, frs) -⦃⦄-jvm→ (xcp', h', frs') ∧ τMove2 P (xcp, h, frs)) b) b)⁺⁺ ((xcp, frs), h) ((a, b), aa)› 2. ‹⋀a aa b ab ac ba. ⟦τExec_1t P t (xcp, h, frs) (a, aa, b); τexec_1 P t (a, aa, b) (ab, ac, ba); (λa. case a of (a, b) ⇒ (case a of (xcp, frs) ⇒ λh a. case a of (a, b) ⇒ (case a of (xcp', frs') ⇒ λh'. P,t ⊢ (xcp, h, frs) -⦃⦄-jvm→ (xcp', h', frs') ∧ τMove2 P (xcp, h, frs)) b) b)⁺⁺ ((xcp, frs), h) ((a, b), aa)⟧ ⟹ (λa. case a of (a, b) ⇒ (case a of (xcp, frs) ⇒ λh a. case a of (a, b) ⇒ (case a of (xcp', frs') ⇒ λh'. P,t ⊢ (xcp, h, frs) -⦃⦄-jvm→ (xcp', h', frs') ∧ τMove2 P (xcp, h, frs)) b) b)⁺⁺ ((xcp, frs), h) ((ab, ba), ac)› discuss goal 1*) apply (fastforce intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*)) (*discuss goal 2*) apply (fastforce intro: tranclp.trancl_into_trancl (*‹⟦?r⁺⁺ ?a ?b; ?r ?b ?c⟧ ⟹ ?r⁺⁺ ?a ?c›*)) (*proven 2 subgoals*) . lemma exec_meth_length_compE2_stack_xliftD: "exec_meth ci P (compE2 e) (stack_xlift d (compxE2 e 0 0)) t h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length (compE2 e)" apply (cases s') (*goal: ‹exec_meth (ci::('addr, 'heap) check_instr) (P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (compE2 (e::'addr expr1)) (stack_xlift (d::nat) (compxE2 e (0::nat) (0::nat))) (t::'thread_id) (h::'heap) (stk::'addr val list, loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (s'::'addr val list × 'addr val list × nat × 'addr option) ⟹ pc < length (compE2 e)›*) by (auto simp add: stack_xlift_compxE2 (*‹stack_xlift ?n (compxE2 ?e ?pc ?d) = compxE2 ?e ?pc (?n + ?d)›*)) lemma exec_meth_length_pc_xt_Nil: "exec_meth ci P ins [] t h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length ins" apply (erule exec_meth.cases (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?a1.0::'heap) (?a2.0::'addr val list × 'addr val list × nat × 'addr option) (?a3.0::('addr, 'thread_id, 'heap) jvm_thread_action) (?a4.0::'heap) (?a5.0::'addr val list × 'addr val list × nat × 'addr option); ⋀(ta::('addr, 'thread_id, 'heap) jvm_thread_action) (xcp::'addr option) (h'::'heap) (stk'::'addr val list) (loc'::'addr val list) (pc'::nat) (pc::nat) (h::'heap) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, None); ?a3.0 = ta; ?a4.0 = h'; ?a5.0 = (stk', loc', pc', xcp); (ta, xcp, h', [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (?ins ! pc) ?P ?t h stk loc undefined undefined pc []; pc < length ?ins; ci_app ?ci (?ins ! pc) ?P h stk loc undefined undefined pc []⟧ ⟹ ?Pa::bool; ⋀(h::'heap) (xcp::'addr) (pc::nat) (pc'::nat) (d::nat) (stk::'addr val list) loc::'addr val list. ⟦?a1.0 = h; ?a2.0 = (stk, loc, pc, ⌊xcp⌋); ?a3.0 = ⦃⦄; ?a4.0 = h; ?a5.0 = (Addr xcp # drop (length stk - d) stk, loc, pc', None); match_ex_table ?P (cname_of h xcp) pc ?xt = ⌊(pc', d)⌋; d ≤ length stk⟧ ⟹ ?Pa⟧ ⟹ ?Pa›*)) (*goals: 1. ‹⋀taa xcpa h'a stk' loc' pc' pca ha stka loca. ⟦h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, None); ta = taa; h' = h'a; s' = (stk', loc', pc', xcpa); (taa, xcpa, h'a, [(stk', loc', undefined, undefined, pc')]) ∈ exec_instr (ins ! pca) P t ha stka loca undefined undefined pca []; pca < length ins; ci_app ci (ins ! pca) P ha stka loca undefined undefined pca []⟧ ⟹ pc < length ins› 2. ‹⋀ha xcpa pca pc' d stka loca. ⟦h = ha; (stk, loc, pc, xcp) = (stka, loca, pca, ⌊xcpa⌋); ta = ⦃⦄; h' = ha; s' = (Addr xcpa # drop (length stka - d) stka, loca, pc', None); match_ex_table P (cname_of ha xcpa) pca [] = ⌊(pc', d)⌋; d ≤ length stka⟧ ⟹ pc < length ins› discuss goal 1*) apply ((auto dest: match_ex_table_pc_length_compE2 (*‹match_ex_table (?P::?'a prog) (?a::String.literal) (?pc::nat) (compxE2 (?e::?'b expr1) (?pc'::nat) (?d::nat)) = ⌊?pcd::nat × nat⌋ ⟹ ?pc' ≤ ?pc ∧ ?pc < length (compE2 ?e) + ?pc'›*))[1]) (*discuss goal 2*) apply ((auto dest: match_ex_table_pc_length_compE2 (*‹match_ex_table (?P::?'a prog) (?a::String.literal) (?pc::nat) (compxE2 (?e::?'b expr1) (?pc'::nat) (?d::nat)) = ⌊?pcd::nat × nat⌋ ⟹ ?pc' ≤ ?pc ∧ ?pc < length (compE2 ?e) + ?pc'›*))[1]) (*proven 2 subgoals*) . lemma BinOp_exec2D: assumes exec: "exec_meth ci (compP2 P) (compE2 (e1 «bop» e2)) (compxE2 (e1 «bop» e2) 0 0) t h (stk @ [v1], loc, length (compE2 e1) + pc, xcp) ta h' (stk', loc', pc', xcp')" and pc: "pc < length (compE2 e2)" shows "exec_meth ci (compP2 P) (compE2 e2) (stack_xlift (length [v1]) (compxE2 e2 0 0)) t h (stk @ [v1], loc, pc, xcp) ta h' (stk', loc', pc' - length (compE2 e1), xcp') ∧ pc' ≥ length (compE2 e1)" proof (standard) (*goals: 1. ‹exec_meth (ci::('addr, 'heap) check_instr) (compP2 (P::'addr J1_prog)) (compE2 (e2::'addr expr1)) (stack_xlift (length [v1::'addr val]) (compxE2 e2 (0::nat) (0::nat))) (t::'thread_id) (h::'heap) ((stk::'addr val list) @ [v1], loc::'addr val list, pc::nat, xcp::'addr option) (ta::('addr, 'thread_id, 'heap) jvm_thread_action) (h'::'heap) (stk'::'addr val list, loc'::'addr val list, (pc'::nat) - length (compE2 (e1::'addr expr1)), xcp'::'addr option)› 2. ‹length (compE2 (e1::'addr expr1)) ≤ (pc'::nat)›*) from exec (*‹exec_meth ci (compP2 P) (compE2 (e1 «bop» e2)) (compxE2 (e1 «bop» e2) 0 0) t h (stk @ [v1], loc, length (compE2 e1) + pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) ((compE2 e1 @ compE2 e2) @ [BinOpInstr bop]) (compxE2 e1 0 0 @ shift (length (compE2 e1)) (stack_xlift (length [v1]) (compxE2 e2 0 0))) t h (stk @ [v1], loc, length (compE2 e1) + pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: compxE2_size_convs (*‹?n ≠ 0 ⟹ compxE2 ?e ?n ?d = shift ?n (compxE2 ?e 0 ?d)›*) compxE2_stack_xlift_convs (*‹0 < ?d ⟹ compxE2 ?e ?pc ?d = stack_xlift ?d (compxE2 ?e ?pc 0)›*)) hence exec': "exec_meth ci (compP2 P) (compE2 e1 @ compE2 e2) (compxE2 e1 0 0 @ shift (length (compE2 e1)) (stack_xlift (length [v1]) (compxE2 e2 0 0))) t h (stk @ [v1], loc, length (compE2 e1) + pc, xcp) ta h' (stk', loc', pc', xcp')" apply (rule exec_meth_take (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?s'::'addr val list × 'addr val list × nat × 'addr option); ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) (*goal: ‹exec_meth ci (compP2 P) (compE2 e1 @ compE2 e2) (compxE2 e1 0 0 @ shift (length (compE2 e1)) (stack_xlift (length [v1]) (compxE2 e2 0 0))) t h (stk @ [v1], loc, length (compE2 e1) + pc, xcp) ta h' (stk', loc', pc', xcp')›*) by (simp add: pc (*‹pc < length (compE2 e2)›*)) thus "exec_meth ci (compP2 P) (compE2 e2) (stack_xlift (length [v1]) (compxE2 e2 0 0)) t h (stk @ [v1], loc, pc, xcp) ta h' (stk', loc', pc' - length (compE2 e1), xcp')" apply (rule exec_meth_drop_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt @ shift (length ?ins) ?xt') ?t ?h (?stk, ?loc, length ?ins + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) (*goals: 1. ‹pcs (compxE2 e1 0 0) ⊆ {..<length (compE2 e1)}› 2. ‹jump_ok (compE2 e2) 0 ?n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from exec' (*‹exec_meth ci (compP2 P) (compE2 e1 @ compE2 e2) (compxE2 e1 0 0 @ shift (length (compE2 e1)) (stack_xlift (length [v1]) (compxE2 e2 0 0))) t h (stk @ [v1], loc, length (compE2 e1) + pc, xcp) ta h' (stk', loc', pc', xcp')›*) show "pc' ≥ length (compE2 e1)" apply (rule exec_meth_drop_xt_pc (*‹⟦exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) ((?ins::'addr instr list) @ (?ins'::'addr instr list)) ((?xt::(nat × nat × String.literal option × nat × nat) list) @ shift (length ?ins) (?xt'::(nat × nat × String.literal option × nat × nat) list)) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, ?xcp::'addr option) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?stk'::'addr val list, ?loc'::'addr val list, ?pc'::nat, ?xcp'::'addr option); length ?ins ≤ ?pc; pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' (0::nat) (?n'::nat)⟧ ⟹ length ?ins ≤ ?pc'›*)) (*goals: 1. ‹length (compE2 (e1::'addr expr1)) ≤ length (compE2 e1) + (pc::nat)› 2. ‹pcs (compxE2 (e1::'addr expr1) (0::nat) (0::nat)) ⊆ {..<length (compE2 e1)}› 3. ‹jump_ok (compE2 (e2::'addr expr1)) (0::nat) (?n'::nat)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed lemma Call_execParamD: assumes exec: "exec_meth ci (compP2 P) (compE2 (obj∙M'(ps))) (compxE2 (obj∙M'(ps)) 0 0) t h (stk @ [v], loc, length (compE2 obj) + pc, xcp) ta h' (stk', loc', pc', xcp')" and pc: "pc < length (compEs2 ps)" shows "exec_meth ci (compP2 P) (compEs2 ps) (stack_xlift (length [v]) (compxEs2 ps 0 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk', loc', pc' - length (compE2 obj), xcp') ∧ pc' ≥ length (compE2 obj)" proof (standard) (*goals: 1. ‹exec_meth ci (compP2 P) (compEs2 ps) (stack_xlift (length [v]) (compxEs2 ps 0 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk', loc', pc' - length (compE2 obj), xcp')› 2. ‹length (compE2 obj) ≤ pc'›*) from exec (*‹exec_meth ci (compP2 P) (compE2 (obj∙M'(ps))) (compxE2 (obj∙M'(ps)) 0 0) t h (stk @ [v], loc, length (compE2 obj) + pc, xcp) ta h' (stk', loc', pc', xcp')›*) have "exec_meth ci (compP2 P) ((compE2 obj @ compEs2 ps) @ [Invoke M' (length ps)]) (compxE2 obj 0 0 @ shift (length (compE2 obj)) (stack_xlift (length [v]) (compxEs2 ps 0 0))) t h (stk @ [v], loc, length (compE2 obj) + pc, xcp) ta h' (stk', loc', pc', xcp')" by (simp add: compxEs2_size_convs (*‹?n ≠ 0 ⟹ compxEs2 ?es ?n ?d = shift ?n (compxEs2 ?es 0 ?d)›*) compxEs2_stack_xlift_convs (*‹0 < ?d ⟹ compxEs2 ?es ?pc ?d = stack_xlift ?d (compxEs2 ?es ?pc 0)›*)) hence exec': "exec_meth ci (compP2 P) (compE2 obj @ compEs2 ps) (compxE2 obj 0 0 @ shift (length (compE2 obj)) (stack_xlift (length [v]) (compxEs2 ps 0 0))) t h (stk @ [v], loc, length (compE2 obj) + pc, xcp) ta h' (stk', loc', pc', xcp')" apply (rule exec_meth_take (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'; ?pc < length ?ins⟧ ⟹ exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' ?s'›*)) (*goal: ‹exec_meth ci (compP2 P) (compE2 obj @ compEs2 ps) (compxE2 obj 0 0 @ shift (length (compE2 obj)) (stack_xlift (length [v]) (compxEs2 ps 0 0))) t h (stk @ [v], loc, length (compE2 obj) + pc, xcp) ta h' (stk', loc', pc', xcp')›*) by (simp add: pc (*‹pc < length (compEs2 ps)›*)) thus "exec_meth ci (compP2 P) (compEs2 ps) (stack_xlift (length [v]) (compxEs2 ps 0 0)) t h (stk @ [v], loc, pc, xcp) ta h' (stk', loc', pc' - length (compE2 obj), xcp')" apply (rule exec_meth_drop_xt (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt @ shift (length ?ins) ?xt') ?t ?h (?stk, ?loc, length ?ins + ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n⟧ ⟹ exec_meth ?ci ?P ?ins' ?xt' ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc' - length ?ins, ?xcp')›*)) (*goals: 1. ‹pcs (compxE2 obj 0 0) ⊆ {..<length (compE2 obj)}› 2. ‹jump_ok (compEs2 ps) 0 ?n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from exec' (*‹exec_meth ci (compP2 P) (compE2 obj @ compEs2 ps) (compxE2 obj 0 0 @ shift (length (compE2 obj)) (stack_xlift (length [v]) (compxEs2 ps 0 0))) t h (stk @ [v], loc, length (compE2 obj) + pc, xcp) ta h' (stk', loc', pc', xcp')›*) show "pc' ≥ length (compE2 obj)" apply (rule exec_meth_drop_xt_pc (*‹⟦exec_meth ?ci ?P (?ins @ ?ins') (?xt @ shift (length ?ins) ?xt') ?t ?h (?stk, ?loc, ?pc, ?xcp) ?ta ?h' (?stk', ?loc', ?pc', ?xcp'); length ?ins ≤ ?pc; pcs ?xt ⊆ {..<length ?ins}; jump_ok ?ins' 0 ?n'⟧ ⟹ length ?ins ≤ ?pc'›*)) (*goals: 1. ‹length (compE2 obj) ≤ length (compE2 obj) + pc› 2. ‹pcs (compxE2 obj 0 0) ⊆ {..<length (compE2 obj)}› 3. ‹jump_ok (compEs2 ps) 0 ?n'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . qed lemma exec_move_length_compE2D [dest]: "exec_move ci P t e h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length (compE2 e)" apply (cases s') (*goal: ‹exec_move ci P t e h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length (compE2 e)›*) by (auto simp add: exec_move_def (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?e::'addr expr1) ≡ exec_meth ?ci (compP2 ?P) (compE2 ?e) (compxE2 ?e (0::nat) (0::nat)) ?t›*)) lemma exec_moves_length_compEs2D [dest]: "exec_moves ci P t es h (stk, loc, pc, xcp) ta h' s' ⟹ pc < length (compEs2 es)" apply (cases s') (*goal: ‹exec_moves (ci::('addr::addr, 'heap::type) check_instr) (P::'addr::addr J1_prog) (t::'thread_id::type) (es::'addr::addr expr1 list) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, xcp::'addr::addr option) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (s'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ pc < length (compEs2 es)›*) by (auto simp add: exec_moves_def (*‹exec_moves ?ci ?P ?t ?es ≡ exec_meth ?ci (compP2 ?P) (compEs2 ?es) (compxEs2 ?es 0 0) ?t›*)) lemma exec_meth_ci_appD: "⟦ exec_meth ci P ins xt t h (stk, loc, pc, None) ta h' fr' ⟧ ⟹ ci_app ci (ins ! pc) P h stk loc undefined undefined pc []" apply (cases fr') (*goal: ‹exec_meth ci P ins xt t h (stk, loc, pc, None) ta h' fr' ⟹ ci_app ci (ins ! pc) P h stk loc undefined undefined pc []›*) by (simp add: exec_meth_instr (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' (?stk', ?loc', ?pc', ?xcp) = ((?ta, ?xcp, ?h', [(?stk', ?loc', undefined, undefined, ?pc')]) ∈ exec_instr (?ins ! ?pc) ?P ?t ?h ?stk ?loc undefined undefined ?pc [] ∧ ?pc < length ?ins ∧ ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc [])›*)) lemma exec_move_ci_appD: "exec_move ci P t E h (stk, loc, pc, None) ta h' fr' ⟹ ci_app ci (compE2 E ! pc) (compP2 P) h stk loc undefined undefined pc []" unfolding exec_move_def (*goal: ‹exec_meth ci (compP2 P) (compE2 E) (compxE2 E 0 0) t h (stk, loc, pc, None) ta h' fr' ⟹ ci_app ci (compE2 E ! pc) (compP2 P) h stk loc undefined undefined pc []›*) by (rule exec_meth_ci_appD (*‹exec_meth (?ci::('addr, 'heap) check_instr) (?P::(nat × nat × 'addr instr list × (nat × nat × String.literal option × nat × nat) list) prog) (?ins::'addr instr list) (?xt::(nat × nat × String.literal option × nat × nat) list) (?t::'thread_id) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, None) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?fr'::'addr val list × 'addr val list × nat × 'addr option) ⟹ ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []›*)) lemma exec_moves_ci_appD: "exec_moves ci P t Es h (stk, loc, pc, None) ta h' fr' ⟹ ci_app ci (compEs2 Es ! pc) (compP2 P) h stk loc undefined undefined pc []" unfolding exec_moves_def (*goal: ‹exec_meth (ci::('addr::addr, 'heap::type) check_instr) (compP2 (P::'addr::addr J1_prog)) (compEs2 (Es::'addr::addr expr1 list)) (compxEs2 Es (0::nat) (0::nat)) (t::'thread_id::type) (h::'heap::type) (stk::'addr::addr val list, loc::'addr::addr val list, pc::nat, None) (ta::('addr::addr, 'thread_id::type, 'heap::type) jvm_thread_action) (h'::'heap::type) (fr'::'addr::addr val list × 'addr::addr val list × nat × 'addr::addr option) ⟹ ci_app ci (compEs2 Es ! pc) (compP2 P) h stk loc undefined undefined pc []›*) by (rule exec_meth_ci_appD (*‹exec_meth ?ci ?P ?ins ?xt ?t ?h (?stk, ?loc, ?pc, None) ?ta ?h' ?fr' ⟹ ci_app ?ci (?ins ! ?pc) ?P ?h ?stk ?loc undefined undefined ?pc []›*)) lemma τinstr_stk_append_check: "check_instr' i P h stk loc C M pc frs ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i" apply (cases i) (*goals: 1. ‹⋀x1. ⟦check_instr' i P h stk loc C M pc frs; i = Load x1⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 2. ‹⋀x2. ⟦check_instr' i P h stk loc C M pc frs; i = Store x2⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 3. ‹⋀x3. ⟦check_instr' i P h stk loc C M pc frs; i = Push x3⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 4. ‹⋀x4. ⟦check_instr' i P h stk loc C M pc frs; i = New x4⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 5. ‹⋀x5. ⟦check_instr' i P h stk loc C M pc frs; i = NewArray x5⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 6. ‹⟦check_instr' i P h stk loc C M pc frs; i = ALoad⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 7. ‹⟦check_instr' i P h stk loc C M pc frs; i = AStore⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 8. ‹⟦check_instr' i P h stk loc C M pc frs; i = ALength⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 9. ‹⋀x91 x92. ⟦check_instr' i P h stk loc C M pc frs; i = Getfield x91 x92⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 10. ‹⋀x101 x102. ⟦check_instr' i P h stk loc C M pc frs; i = Putfield x101 x102⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 11. ‹⋀x111 x112. ⟦check_instr' i P h stk loc C M pc frs; i = CAS x111 x112⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 12. ‹⋀x12. ⟦check_instr' i P h stk loc C M pc frs; i = Checkcast x12⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 13. ‹⋀x13. ⟦check_instr' i P h stk loc C M pc frs; i = Instanceof x13⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 14. ‹⋀x141 x142. ⟦check_instr' i P h stk loc C M pc frs; i = Invoke x141 x142⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 15. ‹⟦check_instr' i P h stk loc C M pc frs; i = Return⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 16. ‹⟦check_instr' i P h stk loc C M pc frs; i = Pop⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 17. ‹⟦check_instr' i P h stk loc C M pc frs; i = Dup⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 18. ‹⟦check_instr' i P h stk loc C M pc frs; i = Swap⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 19. ‹⋀x19. ⟦check_instr' i P h stk loc C M pc frs; i = BinOpInstr x19⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 20. ‹⋀x20. ⟦check_instr' i P h stk loc C M pc frs; i = Goto x20⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 21. ‹⋀x21. ⟦check_instr' i P h stk loc C M pc frs; i = IfFalse x21⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 22. ‹⟦check_instr' i P h stk loc C M pc frs; i = ThrowExc⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 23. ‹⟦check_instr' i P h stk loc C M pc frs; i = MEnter⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› 24. ‹⟦check_instr' i P h stk loc C M pc frs; i = MExit⟧ ⟹ τinstr P h (stk @ vs) i = τinstr P h stk i› discuss goal 1*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 2*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 3*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 4*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 5*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 6*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 7*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 8*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 9*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 10*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 11*) apply (simp add: nth_append (*‹((?xs::?'a::type list) @ (?ys::?'a::type list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 12*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 13*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 14*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 15*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 16*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 17*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 18*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 19*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 20*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 21*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 22*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 23*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 24*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*proven 24 subgoals*) . lemma τinstr_stk_drop_exec_move: "exec_move ci P t e h (stk, loc, pc, None) ta h' fr' ⟹ τinstr (compP2 P) h (stk @ vs) (compE2 e ! pc) = τinstr (compP2 P) h stk (compE2 e ! pc)" apply (drule exec_move_ci_appD (*‹exec_move (?ci::('addr, 'heap) check_instr) (?P::'addr J1_prog) (?t::'thread_id) (?E::'addr expr1) (?h::'heap) (?stk::'addr val list, ?loc::'addr val list, ?pc::nat, None) (?ta::('addr, 'thread_id, 'heap) jvm_thread_action) (?h'::'heap) (?fr'::'addr val list × 'addr val list × nat × 'addr option) ⟹ ci_app ?ci (compE2 ?E ! ?pc) (compP2 ?P) ?h ?stk ?loc undefined undefined ?pc []›*)) (*goal: ‹exec_move ci P t e h (stk, loc, pc, None) ta h' fr' ⟹ τinstr (compP2 P) h (stk @ vs) (compE2 e ! pc) = τinstr (compP2 P) h stk (compE2 e ! pc)›*) apply (drule wf_ciD2_ci_app (*‹ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs›*)) (*goal: ‹ci_app ci (compE2 e ! pc) (compP2 P) h stk loc undefined undefined pc [] ⟹ τinstr (compP2 P) h (stk @ vs) (compE2 e ! pc) = τinstr (compP2 P) h stk (compE2 e ! pc)›*) by (erule τinstr_stk_append_check (*‹check_instr' ?i ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ τinstr ?P ?h (?stk @ ?vs) ?i = τinstr ?P ?h ?stk ?i›*)) lemma τinstr_stk_drop_exec_moves: "exec_moves ci P t es h (stk, loc, pc, None) ta h' fr' ⟹ τinstr (compP2 P) h (stk @ vs) (compEs2 es ! pc) = τinstr (compP2 P) h stk (compEs2 es ! pc)" apply (drule exec_moves_ci_appD (*‹exec_moves ?ci ?P ?t ?Es ?h (?stk, ?loc, ?pc, None) ?ta ?h' ?fr' ⟹ ci_app ?ci (compEs2 ?Es ! ?pc) (compP2 ?P) ?h ?stk ?loc undefined undefined ?pc []›*)) (*goal: ‹exec_moves ci P t es h (stk, loc, pc, None) ta h' fr' ⟹ τinstr (compP2 P) h (stk @ vs) (compEs2 es ! pc) = τinstr (compP2 P) h stk (compEs2 es ! pc)›*) apply (drule wf_ciD2_ci_app (*‹ci_app ?ci ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ check_instr' ?ins ?P ?h ?stk ?loc ?C ?M ?pc ?frs›*)) (*goal: ‹ci_app ci (compEs2 es ! pc) (compP2 P) h stk loc undefined undefined pc [] ⟹ τinstr (compP2 P) h (stk @ vs) (compEs2 es ! pc) = τinstr (compP2 P) h stk (compEs2 es ! pc)›*) by (erule τinstr_stk_append_check (*‹check_instr' ?i ?P ?h ?stk ?loc ?C ?M ?pc ?frs ⟹ τinstr ?P ?h (?stk @ ?vs) ?i = τinstr ?P ?h ?stk ?i›*)) end end
{ "path": "afp-2025-02-12/thys/JinjaThreads/Compiler/Execs.thy", "repo": "afp-2025-02-12", "sha": "779b0bc59c54a5d7450d00d4f5380833862409ef6a46e28fec4e38d1a518f36f" }
section ‹Separation of Roots: Sturm› text ‹We adapt the existing theory on Sturm's theorem to work on rational numbers instead of real numbers. The reason is that we want to implement real numbers as real algebraic numbers with the help of Sturm's theorem to separate the roots. To this end, we just copy the definitions of of the algorithms w.r.t. Sturm and let them be executed on rational numbers. We then prove that corresponds to a homomorphism and therefore can transfer the existing soundness results.› theory Sturm_Rat imports Sturm_Sequences.Sturm_Theorem Algebraic_Numbers_Prelim Berlekamp_Zassenhaus.Square_Free_Int_To_Square_Free_GFp begin hide_const (open) UnivPoly.coeff (* TODO: Move *) lemma root_primitive_part [simp]: fixes p :: "'a :: {semiring_gcd, semiring_no_zero_divisors} poly" shows "poly (primitive_part p) x = 0 ⟷ poly p x = 0" proof (cases "p = 0") (*goals: 1. ‹(p::'a poly) = (0::'a poly) ⟹ (poly (primitive_part p) (x::'a) = (0::'a)) = (poly p x = (0::'a))› 2. ‹(p::'a poly) ≠ (0::'a poly) ⟹ (poly (primitive_part p) (x::'a) = (0::'a)) = (poly p x = (0::'a))›*) case True (*‹p = 0›*) then show "?thesis" (*goal: ‹(poly (primitive_part p) x = 0) = (poly p x = 0)›*) by auto next (*goal: ‹p ≠ 0 ⟹ (poly (primitive_part p) x = 0) = (poly p x = 0)›*) case False (*‹p ≠ 0›*) have "poly p x = content p * poly (primitive_part p) x" by (metis content_times_primitive_part (*‹Polynomial.smult (content ?p) (primitive_part ?p) = ?p›*) poly_smult (*‹poly (Polynomial.smult ?a ?p) ?x = ?a * poly ?p ?x›*)) also (*calculation: ‹poly (p::'a::semiring_gcd poly) (x::'a::semiring_gcd) = content p * poly (primitive_part p) x›*) have "… = 0 ⟷ poly (primitive_part p) x = 0" by (simp add: False (*‹p ≠ 0›*)) finally (*calculation: ‹(poly p x = 0) = (poly (primitive_part p) x = 0)›*) show "?thesis" (*goal: ‹(poly (primitive_part p) x = 0) = (poly p x = 0)›*) by auto qed (*TODO: Move*) lemma irreducible_primitive_part: assumes "irreducible p" and "degree p > 0" shows "primitive_part p = p" using irreducible_content[OF assms ( 1 ), unfolded primitive_iff_content_eq_1] (*‹degree p = 0 ∨ content p = 1›*) assms(2) (*‹0 < degree p›*) by (auto simp: primitive_part_def (*‹primitive_part ?p = map_poly (λx. x div content ?p) ?p›*) abs_poly_def (*‹¦?x¦ = (if ?x < 0 then - ?x else ?x)›*)) subsection ‹Interface for Separating Roots› text ‹For a given rational polynomial, we need to know how many real roots are in a given closed interval, and how many real roots are in an interval $(-\infty,r]$.› datatype root_info = Root_Info (l_r: "rat ⇒ rat ⇒ nat") (number_root: "rat ⇒ nat") hide_const (open) l_r hide_const (open) number_root definition count_roots_interval_sf :: "real poly ⇒ (real ⇒ real ⇒ nat) × (real ⇒ nat)" where "count_roots_interval_sf p = (let ps = sturm_squarefree p in ((λ a b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0)), (λ a. sign_changes_neg_inf ps - sign_changes ps a)))" definition count_roots_interval :: "real poly ⇒ (real ⇒ real ⇒ nat) × (real ⇒ nat)" where "count_roots_interval p = (let ps = sturm p in ((λ a b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0)), (λ a. sign_changes_neg_inf ps - sign_changes ps a)))" lemma count_roots_interval_iff: "square_free p ⟹ count_roots_interval p = count_roots_interval_sf p" unfolding count_roots_interval_def count_roots_interval_sf_def sturm_squarefree_def square_free_iff_separable separable_def (*goal: ‹algebraic_semidom_class.coprime p (pderiv p) ⟹ (let ps = sturm p in (λa b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0), λa. sign_changes_neg_inf ps - sign_changes ps a)) = (let ps = sturm (p div gcd p (pderiv p)) in (λa b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0), λa. sign_changes_neg_inf ps - sign_changes ps a))›*) apply (cases "p = 0") (*goals: 1. ‹⟦algebraic_semidom_class.coprime p (pderiv p); p = 0⟧ ⟹ (let ps = sturm p in (λa b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0), λa. sign_changes_neg_inf ps - sign_changes ps a)) = (let ps = sturm (p div gcd p (pderiv p)) in (λa b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0), λa. sign_changes_neg_inf ps - sign_changes ps a))› 2. ‹⟦algebraic_semidom_class.coprime p (pderiv p); p ≠ 0⟧ ⟹ (let ps = sturm p in (λa b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0), λa. sign_changes_neg_inf ps - sign_changes ps a)) = (let ps = sturm (p div gcd p (pderiv p)) in (λa b. sign_changes ps a - sign_changes ps b + (if poly p a = 0 then 1 else 0), λa. sign_changes_neg_inf ps - sign_changes ps a))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma count_roots_interval_sf: assumes p: "p ≠ 0" and cr: "count_roots_interval_sf p = (cr,nr)" shows "a ≤ b ⟹ cr a b = (card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0})" "nr a = card {x. x ≤ a ∧ poly p x = 0}" proof (-) (*goals: 1. ‹a ≤ b ⟹ cr a b = card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0}› 2. ‹nr a = card {x. x ≤ a ∧ poly p x = 0}›*) have id: "a ≤ b ⟹ { x. a ≤ x ∧ x ≤ b ∧ poly p x = 0} = { x. a < x ∧ x ≤ b ∧ poly p x = 0} ∪ (if poly p a = 0 then {a} else {})" (is "_ ⟹ _ = ?R ∪ ?S") using not_less (*‹(¬ ?x < ?y) = (?y ≤ ?x)›*) by force have RS: "finite ?R" "finite ?S" "?R ∩ ?S = {}" using p (*‹p ≠ 0›*) apply - (*goals: 1. ‹p ≠ 0 ⟹ finite {x. a < x ∧ x ≤ b ∧ poly p x = 0}› 2. ‹p ≠ 0 ⟹ finite (if poly p a = 0 then {a} else {})› 3. ‹p ≠ 0 ⟹ {x. a < x ∧ x ≤ b ∧ poly p x = 0} ∩ (if poly p a = 0 then {a} else {}) = {}› discuss goal 1*) apply ((auto simp: poly_roots_finite (*‹?p ≠ 0 ⟹ finite {x. poly ?p x = 0}›*))[1]) (*discuss goal 2*) apply ((auto simp: poly_roots_finite (*‹?p ≠ 0 ⟹ finite {x. poly ?p x = 0}›*))[1]) (*discuss goal 3*) apply ((auto simp: poly_roots_finite (*‹?p ≠ 0 ⟹ finite {x. poly ?p x = 0}›*))[1]) (*proven 3 subgoals*) . show "a ≤ b ⟹ cr a b = (card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0})" "nr a = card {x. x ≤ a ∧ poly p x = 0}" using cr (*‹count_roots_interval_sf p = (cr, nr)›*) unfolding arg_cong[OF id, of card] card_Un_disjoint[OF RS] count_roots_interval_sf_def count_roots_between_correct[symmetric] count_roots_below_correct[symmetric] count_roots_below_def count_roots_between_def Let_def (*goals: 1. ‹(a::real) ≤ (b::real) ⟹ (cr::real ⇒ real ⇒ nat) a b = (if a ≤ b ∧ (p::real poly) ≠ (0::real poly) then sign_changes (sturm_squarefree p) a - sign_changes (sturm_squarefree p) b else (0::nat)) + card (if poly p a = (0::real) then {a} else {})› 2. ‹(nr::real ⇒ nat) (a::real) = (if (p::real poly) = (0::real poly) then 0::nat else sign_changes_neg_inf (sturm_squarefree p) - sign_changes (sturm_squarefree p) a)›*) using p (*‹p ≠ 0›*) apply - (*goals: 1. ‹⟦(a::real) ≤ (b::real); (λ(a::real) b::real. sign_changes (sturm_squarefree (p::real poly)) a - sign_changes (sturm_squarefree p) b + (if poly p a = (0::real) then 1::nat else (0::nat)), λa::real. sign_changes_neg_inf (sturm_squarefree p) - sign_changes (sturm_squarefree p) a) = (cr::real ⇒ real ⇒ nat, nr::real ⇒ nat); p ≠ (0::real poly)⟧ ⟹ cr a b = (if a ≤ b ∧ p ≠ (0::real poly) then sign_changes (sturm_squarefree p) a - sign_changes (sturm_squarefree p) b else (0::nat)) + card (if poly p a = (0::real) then {a} else {})› 2. ‹⟦(λ(a::real) b::real. sign_changes (sturm_squarefree (p::real poly)) a - sign_changes (sturm_squarefree p) b + (if poly p a = (0::real) then 1::nat else (0::nat)), λa::real. sign_changes_neg_inf (sturm_squarefree p) - sign_changes (sturm_squarefree p) a) = (cr::real ⇒ real ⇒ nat, nr::real ⇒ nat); p ≠ (0::real poly)⟧ ⟹ nr (a::real) = (if p = (0::real poly) then 0::nat else sign_changes_neg_inf (sturm_squarefree p) - sign_changes (sturm_squarefree p) a)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma count_roots_interval: assumes cr: "count_roots_interval p = (cr,nr)" and sf: "square_free p" shows "a ≤ b ⟹ cr a b = (card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0})" "nr a = card {x. x ≤ a ∧ poly p x = 0}" using count_roots_interval_sf[OF _ cr [ unfolded count_roots_interval_iff [ OF sf ] ]] (*‹⟦p ≠ 0; ?a ≤ ?b⟧ ⟹ cr ?a ?b = card {x. ?a ≤ x ∧ x ≤ ?b ∧ poly p x = 0}› ‹p ≠ 0 ⟹ nr ?a = card {x. x ≤ ?a ∧ poly p x = 0}›*) sf[unfolded square_free_def] (*‹(p::real poly) ≠ (0::real poly) ∧ (∀q::real poly. (0::nat) < degree q ⟶ ¬ q * q dvd p)›*) apply - (*goals: 1. ‹⟦a ≤ b; ⋀a b. ⟦p ≠ 0; a ≤ b⟧ ⟹ cr a b = card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0}; ⋀a. p ≠ 0 ⟹ nr a = card {x. x ≤ a ∧ poly p x = 0}; p ≠ 0 ∧ (∀q. 0 < degree q ⟶ ¬ q * q dvd p)⟧ ⟹ cr a b = card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0}› 2. ‹⟦⋀a b. ⟦p ≠ 0; a ≤ b⟧ ⟹ cr a b = card {x. a ≤ x ∧ x ≤ b ∧ poly p x = 0}; ⋀a. p ≠ 0 ⟹ nr a = card {x. x ≤ a ∧ poly p x = 0}; p ≠ 0 ∧ (∀q. 0 < degree q ⟶ ¬ q * q dvd p)⟧ ⟹ nr a = card {x. x ≤ a ∧ poly p x = 0}› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . definition root_cond :: "int poly × rat × rat ⇒ real ⇒ bool" where "root_cond plr x = (case plr of (p,l,r) ⇒ of_rat l ≤ x ∧ x ≤ of_rat r ∧ ipoly p x = 0)" definition root_info_cond :: "root_info ⇒ int poly ⇒ bool" where "root_info_cond ri p ≡ (∀ a b. a ≤ b ⟶ root_info.l_r ri a b = card {x. root_cond (p,a,b) x}) ∧ (∀ a. root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ ipoly p x = 0})" lemma root_info_condD: "root_info_cond ri p ⟹ a ≤ b ⟹ root_info.l_r ri a b = card {x. root_cond (p,a,b) x}" "root_info_cond ri p ⟹ root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ ipoly p x = 0}" unfolding root_info_cond_def (*goals: 1. ‹⟦(∀a b. a ≤ b ⟶ root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) ∧ (∀a. root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0}); a ≤ b⟧ ⟹ root_info.l_r ri a b = card {x. root_cond (p, a, b) x}› 2. ‹(∀a b. a ≤ b ⟶ root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) ∧ (∀a. root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0}) ⟹ root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0}›*) (*goals: 1. ‹⟦(∀a b. a ≤ b ⟶ root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) ∧ (∀a. root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0}); a ≤ b⟧ ⟹ root_info.l_r ri a b = card {x. root_cond (p, a, b) x}› 2. ‹(∀a b. a ≤ b ⟶ root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) ∧ (∀a. root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0}) ⟹ root_info.number_root ri a = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . definition count_roots_interval_sf_rat :: "int poly ⇒ root_info" where "count_roots_interval_sf_rat p = (let pp = real_of_int_poly p; (cr,nr) = count_roots_interval_sf pp in Root_Info (λ a b. cr (of_rat a) (of_rat b)) (λ a. nr (of_rat a)))" definition count_roots_interval_rat :: "int poly ⇒ root_info" where [code del]: "count_roots_interval_rat p = (let pp = real_of_int_poly p; (cr,nr) = count_roots_interval pp in Root_Info (λ a b. cr (of_rat a) (of_rat b)) (λ a. nr (of_rat a)))" definition count_roots_rat :: "int poly ⇒ nat" where [code del]: "count_roots_rat p = (count_roots (real_of_int_poly p))" lemma count_roots_interval_sf_rat: assumes p: "p ≠ 0" shows "root_info_cond (count_roots_interval_sf_rat p) p" proof (-) (*goal: ‹root_info_cond (count_roots_interval_sf_rat (p::int poly)) p›*) let ?p = "real_of_int_poly p" let ?r = real_of_rat let ?ri = "count_roots_interval_sf_rat p" from p (*‹p ≠ 0›*) have p: "?p ≠ 0" by auto obtain cr and nr where cr: "count_roots_interval_sf ?p = (cr,nr)" (*goal: ‹(⋀(cr::real ⇒ real ⇒ nat) nr::real ⇒ nat. count_roots_interval_sf (real_of_int_poly (p::int poly)) = (cr, nr) ⟹ thesis::bool) ⟹ thesis›*) by force have "?ri = Root_Info (λa b. cr (?r a) (?r b)) (λa. nr (?r a))" unfolding count_roots_interval_sf_rat_def Let_def cr (*goal: ‹(case (cr, nr) of (cr, nr) ⇒ Root_Info (λa b. cr (real_of_rat a) (real_of_rat b)) (λa. nr (real_of_rat a))) = Root_Info (λa b. cr (real_of_rat a) (real_of_rat b)) (λa. nr (real_of_rat a))›*) by auto hence id: "root_info.l_r ?ri = (λa b. cr (?r a) (?r b))" "root_info.number_root ?ri = (λa. nr (?r a))" apply - (*goals: 1. ‹count_roots_interval_sf_rat p = Root_Info (λa b. cr (real_of_rat a) (real_of_rat b)) (λa. nr (real_of_rat a)) ⟹ root_info.l_r (count_roots_interval_sf_rat p) = (λa b. cr (real_of_rat a) (real_of_rat b))› 2. ‹count_roots_interval_sf_rat p = Root_Info (λa b. cr (real_of_rat a) (real_of_rat b)) (λa. nr (real_of_rat a)) ⟹ root_info.number_root (count_roots_interval_sf_rat p) = (λa. nr (real_of_rat a))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . note cr = count_roots_interval_sf[OF p cr] (*‹(?a::real) ≤ (?b::real) ⟹ (cr::real ⇒ real ⇒ nat) ?a ?b = card {x::real. ?a ≤ x ∧ x ≤ ?b ∧ poly (real_of_int_poly (p::int poly)) x = (0::real)}› ‹nr ?a = card {x. x ≤ ?a ∧ poly (real_of_int_poly p) x = 0}›*) show "?thesis" (*goal: ‹root_info_cond (count_roots_interval_sf_rat p) p›*) unfolding root_info_cond_def id (*goal: ‹(∀a b. a ≤ b ⟶ cr (real_of_rat a) (real_of_rat b) = card {x. root_cond (p, a, b) x}) ∧ (∀a. nr (real_of_rat a) = card {x. x ≤ real_of_rat a ∧ poly (real_of_int_poly p) x = 0})›*) proof (intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*)) (*goals: 1. ‹⋀(a::rat) b::rat. a ≤ b ⟹ (cr::real ⇒ real ⇒ nat) (real_of_rat a) (real_of_rat b) = card {x::real. root_cond (p::int poly, a, b) x}› 2. ‹⋀a::rat. (nr::real ⇒ nat) (real_of_rat a) = card {x::real. x ≤ real_of_rat a ∧ poly (real_of_int_poly (p::int poly)) x = (0::real)}›*) fix a show "nr (?r a) = card {x. x ≤ (?r a) ∧ ipoly p x = 0}" using cr(2)[of "?r a"] (*‹(nr::real ⇒ nat) (real_of_rat (a::rat)) = card {x::real. x ≤ real_of_rat a ∧ poly (real_of_int_poly (p::int poly)) x = (0::real)}›*) by simp next (*goal: ‹⋀a b. a ≤ b ⟹ cr (real_of_rat a) (real_of_rat b) = card {x. root_cond (p, a, b) x}›*) fix a :: rat and b :: rat assume ab: "a ≤ b" (*‹(a::rat) ≤ (b::rat)›*) from ab (*‹a ≤ b›*) have ab: "?r a ≤ ?r b" by (simp add: of_rat_less_eq (*‹(of_rat ?r ≤ of_rat ?s) = (?r ≤ ?s)›*)) from cr(1)[OF this] (*‹(cr::real ⇒ real ⇒ nat) (real_of_rat (a::rat)) (real_of_rat (b::rat)) = card {x::real. real_of_rat a ≤ x ∧ x ≤ real_of_rat b ∧ poly (real_of_int_poly (p::int poly)) x = (0::real)}›*) show "cr (?r a) (?r b) = card (Collect (root_cond (p, a, b)))" unfolding root_cond_def[abs_def] split (*goal: ‹cr (real_of_rat a) (real_of_rat b) = card {x. real_of_rat a ≤ x ∧ x ≤ real_of_rat b ∧ poly (real_of_int_poly p) x = 0}›*) by simp qed qed lemma of_rat_of_int_poly: "map_poly of_rat (of_int_poly p) = of_int_poly p" apply (subst map_poly_map_poly (*‹(?f::?'b ⇒ ?'a) (0::?'b) = (0::?'a) ⟹ map_poly ?f (map_poly (?g::?'c ⇒ ?'b) (?p::?'c poly)) = map_poly (?f ∘ ?g) ?p›*)) (*goals: 1. ‹of_rat (0::rat) = (0::'a::field_char_0)› 2. ‹map_poly (of_rat ∘ rat_of_int) (p::int poly) = of_int_poly p› discuss goal 1*) apply ((auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))[1]) (*discuss goal 2*) apply ((auto simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*))[1]) (*proven 2 subgoals*) . lemma square_free_of_int_poly: assumes "square_free p" shows "square_free (of_int_poly p :: 'a :: {field_gcd, field_char_0} poly)" proof (-) (*goal: ‹square_free (of_int_poly p)›*) have "square_free (map_poly of_rat (of_int_poly p) :: 'a poly)" unfolding of_rat_hom.square_free_map_poly (*goal: ‹square_free (of_int_poly (p::int poly))›*) by (rule square_free_int_rat[OF assms] (*‹square_free (of_int_poly p)›*)) thus "?thesis" (*goal: ‹square_free (of_int_poly p)›*) unfolding of_rat_of_int_poly (*goal: ‹square_free (of_int_poly p)›*) . qed lemma count_roots_interval_rat: assumes sf: "square_free p" shows "root_info_cond (count_roots_interval_rat p) p" proof (-) (*goal: ‹root_info_cond (count_roots_interval_rat (p::int poly)) p›*) from sf (*‹square_free (p::int poly)›*) have sf: "square_free (real_of_int_poly p)" by (rule square_free_of_int_poly (*‹square_free (?p::int poly) ⟹ square_free (of_int_poly ?p)›*)) from sf (*‹square_free (real_of_int_poly p)›*) have p: "p ≠ 0" unfolding square_free_def (*goal: ‹p ≠ 0›*) by auto show "?thesis" (*goal: ‹root_info_cond (count_roots_interval_rat p) p›*) using count_roots_interval_sf_rat[OF p] (*‹root_info_cond (count_roots_interval_sf_rat (p::int poly)) p›*) unfolding count_roots_interval_rat_def count_roots_interval_sf_rat_def Let_def count_roots_interval_iff[OF sf] (*goal: ‹root_info_cond (case count_roots_interval_sf (real_of_int_poly (p::int poly)) of (cr::real ⇒ real ⇒ nat, nr::real ⇒ nat) ⇒ Root_Info (λ(a::rat) b::rat. cr (real_of_rat a) (real_of_rat b)) (λa::rat. nr (real_of_rat a))) p›*) . qed lemma count_roots_rat: "count_roots_rat p = card {x. ipoly p x = (0 :: real)}" unfolding count_roots_rat_def count_roots_correct (*goal: ‹card {x. poly (real_of_int_poly p) x = 0} = card {x. poly (real_of_int_poly p) x = 0}›*) by standard subsection ‹Implementing Sturm on Rational Polynomials› function sturm_aux_rat where "sturm_aux_rat (p :: rat poly) q = (if degree q = 0 then [p,q] else p # sturm_aux_rat q (-(p mod q)))" by (pat_completeness, simp_all) termination by (relation "measure (degree ∘ snd)", simp_all add: o_def degree_mod_less') lemma sturm_aux_rat: "sturm_aux (real_of_rat_poly p) (real_of_rat_poly q) = map real_of_rat_poly (sturm_aux_rat p q)" proof (induct p q rule: sturm_aux_rat.induct (*‹(⋀p q. (degree q ≠ 0 ⟹ ?P q (- (p mod q))) ⟹ ?P p q) ⟹ ?P ?a0.0 ?a1.0›*)) (*goal: ‹⋀(p::rat poly) q::rat poly. (degree q ≠ (0::nat) ⟹ sturm_aux (real_of_rat_poly q) (real_of_rat_poly (- (p mod q))) = map real_of_rat_poly (sturm_aux_rat q (- (p mod q)))) ⟹ sturm_aux (real_of_rat_poly p) (real_of_rat_poly q) = map real_of_rat_poly (sturm_aux_rat p q)›*) case (1 p q) (*‹degree q ≠ 0 ⟹ sturm_aux (real_of_rat_poly q) (real_of_rat_poly (- (p mod q))) = map real_of_rat_poly (sturm_aux_rat q (- (p mod q)))›*) interpret map_poly_inj_idom_hom of_rat by standard note deg = of_int_hom.degree_map_poly_hom (*‹degree (of_int_poly ?p) = degree ?p›*) show "?case" (*goal: ‹sturm_aux (real_of_rat_poly p) (real_of_rat_poly q) = map real_of_rat_poly (sturm_aux_rat p q)›*) unfolding sturm_aux.simps[of "real_of_rat_poly p"] sturm_aux_rat.simps[of p] (*goal: ‹(if degree (real_of_rat_poly q) = 0 then [real_of_rat_poly p, real_of_rat_poly q] else real_of_rat_poly p # sturm_aux (real_of_rat_poly q) (- (real_of_rat_poly p mod real_of_rat_poly q))) = map real_of_rat_poly (if degree q = 0 then [p, q] else p # sturm_aux_rat q (- (p mod q)))›*) using "1" (*‹degree (q::rat poly) ≠ (0::nat) ⟹ sturm_aux (real_of_rat_poly q) (real_of_rat_poly (- ((p::rat poly) mod q))) = map real_of_rat_poly (sturm_aux_rat q (- (p mod q)))›*) apply (cases "degree q = 0") (*goals: 1. ‹⟦degree q ≠ 0 ⟹ sturm_aux (real_of_rat_poly q) (real_of_rat_poly (- (p mod q))) = map real_of_rat_poly (sturm_aux_rat q (- (p mod q))); degree q = 0⟧ ⟹ (if degree (real_of_rat_poly q) = 0 then [real_of_rat_poly p, real_of_rat_poly q] else real_of_rat_poly p # sturm_aux (real_of_rat_poly q) (- (real_of_rat_poly p mod real_of_rat_poly q))) = map real_of_rat_poly (if degree q = 0 then [p, q] else p # sturm_aux_rat q (- (p mod q)))› 2. ‹⟦degree q ≠ 0 ⟹ sturm_aux (real_of_rat_poly q) (real_of_rat_poly (- (p mod q))) = map real_of_rat_poly (sturm_aux_rat q (- (p mod q))); degree q ≠ 0⟧ ⟹ (if degree (real_of_rat_poly q) = 0 then [real_of_rat_poly p, real_of_rat_poly q] else real_of_rat_poly p # sturm_aux (real_of_rat_poly q) (- (real_of_rat_poly p mod real_of_rat_poly q))) = map real_of_rat_poly (if degree q = 0 then [p, q] else p # sturm_aux_rat q (- (p mod q)))› discuss goal 1*) apply (simp add: hom_distribs (*‹of_int (?x + ?y) = of_int ?x + of_int ?y› ‹of_int (sum ?f ?X) = (∑x∈?X. of_int (?f x))› ‹of_int (∑⇩# ?X) = ∑⇩# (image_mset of_int ?X)› ‹of_int (?x * ?y) = of_int ?x * of_int ?y› ‹of_int (?x ^ ?n) = of_int ?x ^ ?n› ‹of_int (- ?x) = - of_int ?x› ‹of_int (?x - ?y) = of_int ?x - of_int ?y› ‹of_int (prod ?f ?X) = (∏x∈?X. of_int (?f x))› ‹of_rat (?x + ?y) = of_rat ?x + of_rat ?y› ‹of_rat (sum ?f ?X) = (∑x∈?X. of_rat (?f x))› ‹of_rat (∑⇩# ?X) = ∑⇩# (image_mset of_rat ?X)› ‹of_rat (?x * ?y) = of_rat ?x * of_rat ?y› and more 144 facts*)) (*discuss goal 2*) apply (simp add: hom_distribs (*‹of_int (?x + ?y) = of_int ?x + of_int ?y› ‹of_int (sum ?f ?X) = (∑x∈?X. of_int (?f x))› ‹of_int (∑⇩# ?X) = ∑⇩# (image_mset of_int ?X)› ‹of_int (?x * ?y) = of_int ?x * of_int ?y› ‹of_int (?x ^ ?n) = of_int ?x ^ ?n› ‹of_int (- ?x) = - of_int ?x› ‹of_int (?x - ?y) = of_int ?x - of_int ?y› ‹of_int (prod ?f ?X) = (∏x∈?X. of_int (?f x))› ‹of_rat (?x + ?y) = of_rat ?x + of_rat ?y› ‹of_rat (sum ?f ?X) = (∑x∈?X. of_rat (?f x))› ‹of_rat (∑⇩# ?X) = ∑⇩# (image_mset of_rat ?X)› ‹of_rat (?x * ?y) = of_rat ?x * of_rat ?y› and more 144 facts*)) (*proven 2 subgoals*) . qed definition sturm_rat where "sturm_rat p = sturm_aux_rat p (pderiv p)" lemma sturm_rat: "sturm (real_of_rat_poly p) = map real_of_rat_poly (sturm_rat p)" unfolding sturm_rat_def sturm_def (*goal: ‹sturm_aux (real_of_rat_poly p) (pderiv (real_of_rat_poly p)) = map real_of_rat_poly (sturm_aux_rat p (pderiv p))›*) apply (fold of_rat_hom.map_poly_pderiv) (*goal: ‹sturm_aux (real_of_rat_poly p) (pderiv (real_of_rat_poly p)) = map real_of_rat_poly (sturm_aux_rat p (pderiv p))›*) unfolding sturm_aux_rat (*goal: ‹map real_of_rat_poly (sturm_aux_rat p (pderiv p)) = map real_of_rat_poly (sturm_aux_rat p (pderiv p))›*) by standard definition poly_number_rootat :: "rat poly ⇒ rat" where "poly_number_rootat p ≡ sgn (coeff p (degree p))" definition poly_neg_number_rootat :: "rat poly ⇒ rat" where "poly_neg_number_rootat p ≡ if even (degree p) then sgn (coeff p (degree p)) else -sgn (coeff p (degree p))" lemma poly_number_rootat: "poly_inf (real_of_rat_poly p) = real_of_rat (poly_number_rootat p)" unfolding poly_inf_def poly_number_rootat_def of_int_hom.degree_map_poly_hom of_rat_hom.coeff_map_poly_hom real_of_rat_sgn (*goal: ‹real_of_rat (sgn (coeff p (degree (real_of_rat_poly p)))) = real_of_rat (sgn (lead_coeff p))›*) by simp lemma poly_neg_number_rootat: "poly_neg_inf (real_of_rat_poly p) = real_of_rat (poly_neg_number_rootat p)" unfolding poly_neg_inf_def poly_neg_number_rootat_def of_int_hom.degree_map_poly_hom of_rat_hom.coeff_map_poly_hom real_of_rat_sgn (*goal: ‹(if even (degree (real_of_rat_poly p)) then real_of_rat (sgn (coeff p (degree (real_of_rat_poly p)))) else - real_of_rat (sgn (coeff p (degree (real_of_rat_poly p))))) = real_of_rat (if even (degree p) then sgn (lead_coeff p) else - sgn (lead_coeff p))›*) by (simp add:hom_distribs (*‹of_int (?x + ?y) = of_int ?x + of_int ?y› ‹of_int (sum ?f ?X) = (∑x∈?X. of_int (?f x))› ‹of_int (∑⇩# ?X) = ∑⇩# (image_mset of_int ?X)› ‹of_int (?x * ?y) = of_int ?x * of_int ?y› ‹of_int (?x ^ ?n) = of_int ?x ^ ?n› ‹of_int (- ?x) = - of_int ?x› ‹of_int (?x - ?y) = of_int ?x - of_int ?y› ‹of_int (prod ?f ?X) = (∏x∈?X. of_int (?f x))› ‹of_rat (?x + ?y) = of_rat ?x + of_rat ?y› ‹of_rat (sum ?f ?X) = (∑x∈?X. of_rat (?f x))› ‹of_rat (∑⇩# ?X) = ∑⇩# (image_mset of_rat ?X)› ‹of_rat (?x * ?y) = of_rat ?x * of_rat ?y› and more 130 facts*)) definition sign_changes_rat where "sign_changes_rat ps (x::rat) = length (remdups_adj (filter (λx. x ≠ 0) (map (λp. sgn (poly p x)) ps))) - 1" definition sign_changes_number_rootat where "sign_changes_number_rootat ps = length (remdups_adj (filter (λx. x ≠ 0) (map poly_number_rootat ps))) - 1" definition sign_changes_neg_number_rootat where "sign_changes_neg_number_rootat ps = length (remdups_adj (filter (λx. x ≠ 0) (map poly_neg_number_rootat ps))) - 1" lemma real_of_rat_list_neq: "list_neq (map real_of_rat xs) 0 = map real_of_rat (list_neq xs 0)" apply (induct xs) (*goals: 1. ‹list_neq (map real_of_rat []) 0 = map real_of_rat (list_neq [] 0)› 2. ‹⋀a xs. list_neq (map real_of_rat xs) 0 = map real_of_rat (list_neq xs 0) ⟹ list_neq (map real_of_rat (a # xs)) 0 = map real_of_rat (list_neq (a # xs) 0)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma real_of_rat_remdups_adj: "remdups_adj (map real_of_rat xs) = map real_of_rat (remdups_adj xs)" apply (induct xs rule: remdups_adj.induct (*‹⟦(?P::?'a::type list ⇒ bool) []; ⋀x::?'a::type. ?P [x]; ⋀(x::?'a::type) (y::?'a::type) xs::?'a::type list. ⟦x = y ⟹ ?P (x # xs); x ≠ y ⟹ ?P (y # xs)⟧ ⟹ ?P (x # y # xs)⟧ ⟹ ?P (?a0.0::?'a::type list)›*)) (*goals: 1. ‹remdups_adj (map real_of_rat []) = map real_of_rat (remdups_adj [])› 2. ‹⋀x. remdups_adj (map real_of_rat [x]) = map real_of_rat (remdups_adj [x])› 3. ‹⋀x y xs. ⟦x = y ⟹ remdups_adj (map real_of_rat (x # xs)) = map real_of_rat (remdups_adj (x # xs)); x ≠ y ⟹ remdups_adj (map real_of_rat (y # xs)) = map real_of_rat (remdups_adj (y # xs))⟧ ⟹ remdups_adj (map real_of_rat (x # y # xs)) = map real_of_rat (remdups_adj (x # y # xs))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma sign_changes_rat: "sign_changes (map real_of_rat_poly ps) (real_of_rat x) = sign_changes_rat ps x" (is "?l = ?r") proof (-) (*goal: ‹sign_changes (map real_of_rat_poly ps) (real_of_rat x) = sign_changes_rat ps x›*) define xs where "xs = list_neq (map (λp. sgn (poly p x)) ps) 0" have "?l = length (remdups_adj (list_neq (map real_of_rat (map (λxa. (sgn (poly xa x))) ps)) 0)) - 1" by (simp add: sign_changes_def (*‹sign_changes ?ps ?x = length (remdups_adj (list_neq (map (λp. sgn (poly p ?x)) ?ps) 0)) - 1›*) real_of_rat_sgn (*‹sgn (real_of_rat ?x) = real_of_rat (sgn ?x)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹sign_changes (map real_of_rat_poly ps) (real_of_rat x) = length (remdups_adj (list_neq (map real_of_rat (map (λxa. sgn (poly xa x)) ps)) 0)) - 1›*) have "… = ?r" unfolding sign_changes_rat_def real_of_rat_list_neq (*goal: ‹length (remdups_adj (map real_of_rat (list_neq (map (λxa. sgn (poly xa x)) ps) 0))) - 1 = length (remdups_adj (list_neq (map (λp. sgn (poly p x)) ps) 0)) - 1›*) unfolding real_of_rat_remdups_adj (*goal: ‹length (map real_of_rat (remdups_adj (list_neq (map (λxa. sgn (poly xa x)) ps) 0))) - 1 = length (remdups_adj (list_neq (map (λp. sgn (poly p x)) ps) 0)) - 1›*) by simp finally (*calculation: ‹sign_changes (map real_of_rat_poly ps) (real_of_rat x) = sign_changes_rat ps x›*) show "?thesis" (*goal: ‹sign_changes (map real_of_rat_poly (ps::rat poly list)) (real_of_rat (x::rat)) = sign_changes_rat ps x›*) . qed lemma sign_changes_neg_number_rootat: "sign_changes_neg_inf (map real_of_rat_poly ps) = sign_changes_neg_number_rootat ps" (is "?l = ?r") proof (-) (*goal: ‹sign_changes_neg_inf (map real_of_rat_poly (ps::rat poly list)) = sign_changes_neg_number_rootat ps›*) have "?l = length (remdups_adj (list_neq (map real_of_rat (map poly_neg_number_rootat ps)) 0)) - 1" by (simp add: sign_changes_neg_inf_def (*‹sign_changes_neg_inf (?ps::?'a poly list) = length (remdups_adj (list_neq (map poly_neg_inf ?ps) (0::?'a))) - (1::nat)›*) o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*) real_of_rat_sgn (*‹sgn (real_of_rat (?x::rat)) = real_of_rat (sgn ?x)›*) poly_neg_number_rootat (*‹poly_neg_inf (real_of_rat_poly (?p::rat poly)) = real_of_rat (poly_neg_number_rootat ?p)›*)) also (*calculation: ‹sign_changes_neg_inf (map real_of_rat_poly ps) = length (remdups_adj (list_neq (map real_of_rat (map poly_neg_number_rootat ps)) 0)) - 1›*) have "… = ?r" unfolding sign_changes_neg_number_rootat_def real_of_rat_list_neq (*goal: ‹length (remdups_adj (map real_of_rat (list_neq (map poly_neg_number_rootat (ps::rat poly list)) (0::rat)))) - (1::nat) = length (remdups_adj (list_neq (map poly_neg_number_rootat ps) (0::rat))) - (1::nat)›*) unfolding real_of_rat_remdups_adj (*goal: ‹length (map real_of_rat (remdups_adj (list_neq (map poly_neg_number_rootat (ps::rat poly list)) (0::rat)))) - (1::nat) = length (remdups_adj (list_neq (map poly_neg_number_rootat ps) (0::rat))) - (1::nat)›*) by simp finally (*calculation: ‹sign_changes_neg_inf (map real_of_rat_poly ps) = sign_changes_neg_number_rootat ps›*) show "?thesis" (*goal: ‹sign_changes_neg_inf (map real_of_rat_poly ps) = sign_changes_neg_number_rootat ps›*) . qed lemma sign_changes_number_rootat: "sign_changes_inf (map real_of_rat_poly ps) = sign_changes_number_rootat ps" (is "?l = ?r") proof (-) (*goal: ‹sign_changes_inf (map real_of_rat_poly ps) = sign_changes_number_rootat ps›*) have "?l = length (remdups_adj (list_neq (map real_of_rat (map poly_number_rootat ps)) 0)) - 1" unfolding sign_changes_inf_def (*goal: ‹length (remdups_adj (list_neq (map poly_inf (map real_of_rat_poly ps)) 0)) - 1 = length (remdups_adj (list_neq (map real_of_rat (map poly_number_rootat ps)) 0)) - 1›*) unfolding map_map o_def real_of_rat_sgn poly_number_rootat (*goal: ‹length (remdups_adj (list_neq (map (λx. real_of_rat (poly_number_rootat x)) ps) 0)) - 1 = length (remdups_adj (list_neq (map (λx. real_of_rat (poly_number_rootat x)) ps) 0)) - 1›*) by standard also (*calculation: ‹sign_changes_inf (map real_of_rat_poly ps) = length (remdups_adj (list_neq (map real_of_rat (map poly_number_rootat ps)) 0)) - 1›*) have "… = ?r" unfolding sign_changes_number_rootat_def real_of_rat_list_neq (*goal: ‹length (remdups_adj (map real_of_rat (list_neq (map poly_number_rootat ps) 0))) - 1 = length (remdups_adj (list_neq (map poly_number_rootat ps) 0)) - 1›*) unfolding real_of_rat_remdups_adj (*goal: ‹length (map real_of_rat (remdups_adj (list_neq (map poly_number_rootat ps) 0))) - 1 = length (remdups_adj (list_neq (map poly_number_rootat ps) 0)) - 1›*) by simp finally (*calculation: ‹sign_changes_inf (map real_of_rat_poly ps) = sign_changes_number_rootat ps›*) show "?thesis" (*goal: ‹sign_changes_inf (map real_of_rat_poly (ps::rat poly list)) = sign_changes_number_rootat ps›*) . qed lemma count_roots_interval_rat_code[code]: "count_roots_interval_rat p = (let rp = map_poly rat_of_int p; ps = sturm_rat rp in Root_Info (λ a b. sign_changes_rat ps a - sign_changes_rat ps b + (if poly rp a = 0 then 1 else 0)) (λ a. sign_changes_neg_number_rootat ps - sign_changes_rat ps a))" unfolding count_roots_interval_rat_def Let_def count_roots_interval_def split of_rat_of_int_poly[symmetric, where 'a = real] sturm_rat sign_changes_rat (*goal: ‹Root_Info (λa b. sign_changes_rat (sturm_rat (of_int_poly p)) a - sign_changes_rat (sturm_rat (of_int_poly p)) b + (if poly (real_of_rat_poly (of_int_poly p)) (real_of_rat a) = 0 then 1 else 0)) (λa. sign_changes_neg_inf (map real_of_rat_poly (sturm_rat (of_int_poly p))) - sign_changes_rat (sturm_rat (of_int_poly p)) a) = Root_Info (λa b. sign_changes_rat (sturm_rat (of_int_poly p)) a - sign_changes_rat (sturm_rat (of_int_poly p)) b + (if ipoly p a = 0 then 1 else 0)) (λa. sign_changes_neg_number_rootat (sturm_rat (of_int_poly p)) - sign_changes_rat (sturm_rat (of_int_poly p)) a)›*) by (simp add: sign_changes_neg_number_rootat (*‹sign_changes_neg_inf (map real_of_rat_poly ?ps) = sign_changes_neg_number_rootat ?ps›*)) lemma count_roots_rat_code[code]: "count_roots_rat p = (let rp = map_poly rat_of_int p in if p = 0 then 0 else let ps = sturm_rat rp in sign_changes_neg_number_rootat ps - sign_changes_number_rootat ps)" unfolding count_roots_rat_def Let_def sturm_rat count_roots_code of_rat_of_int_poly[symmetric, where 'a = real] sign_changes_neg_number_rootat sign_changes_number_rootat (*goal: ‹(if real_of_rat_poly (of_int_poly (p::int poly)) = (0::real poly) then 0::nat else sign_changes_neg_number_rootat (sturm_rat (of_int_poly p)) - sign_changes_number_rootat (sturm_rat (of_int_poly p))) = (if p = (0::int poly) then 0::nat else sign_changes_neg_number_rootat (sturm_rat (of_int_poly p)) - sign_changes_number_rootat (sturm_rat (of_int_poly p)))›*) by simp hide_const (open) count_roots_interval_sf_rat text ‹Finally we provide an even more efficient implementation which avoids the "poly p x = 0" test, but it is restricted to irreducible polynomials.› definition root_info :: "int poly ⇒ root_info" where "root_info p = (if degree p = 1 then (let x = Rat.Fract (- coeff p 0) (coeff p 1) in Root_Info (λ l r. if l ≤ x ∧ x ≤ r then 1 else 0) (λ b. if x ≤ b then 1 else 0)) else (let rp = map_poly rat_of_int p; ps = sturm_rat rp in Root_Info (λ a b. sign_changes_rat ps a - sign_changes_rat ps b) (λ a. sign_changes_neg_number_rootat ps - sign_changes_rat ps a)))" lemma root_info: assumes irr: "irreducible p" and deg: "degree p > 0" shows "root_info_cond (root_info p) p" proof (cases "degree p = 1") (*goals: 1. ‹degree p = 1 ⟹ root_info_cond (root_info p) p› 2. ‹degree p ≠ 1 ⟹ root_info_cond (root_info p) p›*) case deg: True (*‹degree (p::int poly) = (1::nat)›*) from degree1_coeffs[OF this] (*‹∃a b. p = [:b, a:] ∧ a ≠ 0›*) obtain a and b where p: "p = [:b,a:]" and "a ≠ 0" (*goal: ‹(⋀(b::int) a::int. ⟦(p::int poly) = [:b, a:]; a ≠ (0::int)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto from deg (*‹degree p = 1›*) have "degree (real_of_int_poly p) = 1" by simp from roots1[OF this, unfolded roots1_def] (*‹{x. poly (real_of_int_poly p) x = 0} = {- coeff (real_of_int_poly p) 0 / coeff (real_of_int_poly p) 1}›*) p (*‹(p::int poly) = [:b::int, a::int:]›*) have id: "(ipoly p x = 0) = ((x :: real) = - b / a)" for x by auto have idd: "{x. real_of_rat aa ≤ x ∧ x ≤ real_of_rat ba ∧ x = real_of_int (- b) / real_of_int a} = (if real_of_rat aa ≤ real_of_int (- b) / real_of_int a ∧ real_of_int (- b) / real_of_int a ≤ real_of_rat ba then {real_of_int (- b) / real_of_int a} else {})" for aa and ba by auto have iddd: "{x. x ≤ real_of_rat aa ∧ x = real_of_int (- b) / real_of_int a} = (if real_of_int (- b) / real_of_int a ≤ real_of_rat aa then {real_of_int (- b) / real_of_int a} else {})" for aa by auto have id4: "real_of_int x = real_of_rat (rat_of_int x)" for x by simp show "?thesis" (*goal: ‹root_info_cond (root_info p) p›*) unfolding root_info_def deg (*goal: ‹root_info_cond (if 1 = 1 then let x = Rat.Fract (- coeff p 0) (coeff p 1) in Root_Info (λl r. if l ≤ x ∧ x ≤ r then 1 else 0) (λb. if x ≤ b then 1 else 0) else let rp = of_int_poly p; ps = sturm_rat rp in Root_Info (λa b. sign_changes_rat ps a - sign_changes_rat ps b) (λa. sign_changes_neg_number_rootat ps - sign_changes_rat ps a)) p›*) unfolding root_info_cond_def id root_cond_def split (*goal: ‹(∀aa ba. aa ≤ ba ⟶ root_info.l_r (if 1 = 1 then let x = Rat.Fract (- coeff p 0) (coeff p 1) in Root_Info (λl r. if l ≤ x ∧ x ≤ r then 1 else 0) (λb. if x ≤ b then 1 else 0) else let rp = of_int_poly p; ps = sturm_rat rp in Root_Info (λa b. sign_changes_rat ps a - sign_changes_rat ps b) (λa. sign_changes_neg_number_rootat ps - sign_changes_rat ps a)) aa ba = card {x. real_of_rat aa ≤ x ∧ x ≤ real_of_rat ba ∧ x = real_of_int (- b) / real_of_int a}) ∧ (∀aa. root_info.number_root (if 1 = 1 then let x = Rat.Fract (- coeff p 0) (coeff p 1) in Root_Info (λl r. if l ≤ x ∧ x ≤ r then 1 else 0) (λb. if x ≤ b then 1 else 0) else let rp = of_int_poly p; ps = sturm_rat rp in Root_Info (λa b. sign_changes_rat ps a - sign_changes_rat ps b) (λa. sign_changes_neg_number_rootat ps - sign_changes_rat ps a)) aa = card {x. x ≤ real_of_rat aa ∧ x = real_of_int (- b) / real_of_int a})›*) unfolding p Fract_of_int_quotient Let_def idd iddd (*goal: ‹(∀(aa::rat) ba::rat. aa ≤ ba ⟶ root_info.l_r (if (1::nat) = (1::nat) then Root_Info (λ(l::rat) r::rat. if l ≤ rat_of_int (- coeff [:b::int, a::int:] (0::nat)) / rat_of_int (coeff [:b, a:] (1::nat)) ∧ rat_of_int (- coeff [:b, a:] (0::nat)) / rat_of_int (coeff [:b, a:] (1::nat)) ≤ r then 1::nat else (0::nat)) (λba::rat. if rat_of_int (- coeff [:b, a:] (0::nat)) / rat_of_int (coeff [:b, a:] (1::nat)) ≤ ba then 1::nat else (0::nat)) else Root_Info (λ(aa::rat) ba::rat. sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) ba) (λaa::rat. sign_changes_neg_number_rootat (sturm_rat (of_int_poly [:b, a:])) - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa)) aa ba = card (if real_of_rat aa ≤ real_of_int (- b) / real_of_int a ∧ real_of_int (- b) / real_of_int a ≤ real_of_rat ba then {real_of_int (- b) / real_of_int a} else {})) ∧ (∀aa::rat. root_info.number_root (if (1::nat) = (1::nat) then Root_Info (λ(l::rat) r::rat. if l ≤ rat_of_int (- coeff [:b, a:] (0::nat)) / rat_of_int (coeff [:b, a:] (1::nat)) ∧ rat_of_int (- coeff [:b, a:] (0::nat)) / rat_of_int (coeff [:b, a:] (1::nat)) ≤ r then 1::nat else (0::nat)) (λba::rat. if rat_of_int (- coeff [:b, a:] (0::nat)) / rat_of_int (coeff [:b, a:] (1::nat)) ≤ ba then 1::nat else (0::nat)) else Root_Info (λ(aa::rat) ba::rat. sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) ba) (λaa::rat. sign_changes_neg_number_rootat (sturm_rat (of_int_poly [:b, a:])) - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa)) aa = card (if real_of_int (- b) / real_of_int a ≤ real_of_rat aa then {real_of_int (- b) / real_of_int a} else {}))›*) unfolding id4 of_rat_divide[symmetric] of_rat_less_eq (*goal: ‹(∀aa ba. aa ≤ ba ⟶ root_info.l_r (if 1 = 1 then Root_Info (λl r. if l ≤ rat_of_int (- coeff [:b, a:] 0) / rat_of_int (coeff [:b, a:] 1) ∧ rat_of_int (- coeff [:b, a:] 0) / rat_of_int (coeff [:b, a:] 1) ≤ r then 1 else 0) (λba. if rat_of_int (- coeff [:b, a:] 0) / rat_of_int (coeff [:b, a:] 1) ≤ ba then 1 else 0) else Root_Info (λaa ba. sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) ba) (λaa. sign_changes_neg_number_rootat (sturm_rat (of_int_poly [:b, a:])) - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa)) aa ba = card (if aa ≤ rat_of_int (- b) / rat_of_int a ∧ rat_of_int (- b) / rat_of_int a ≤ ba then {real_of_rat (rat_of_int (- b) / rat_of_int a)} else {})) ∧ (∀aa. root_info.number_root (if 1 = 1 then Root_Info (λl r. if l ≤ rat_of_int (- coeff [:b, a:] 0) / rat_of_int (coeff [:b, a:] 1) ∧ rat_of_int (- coeff [:b, a:] 0) / rat_of_int (coeff [:b, a:] 1) ≤ r then 1 else 0) (λba. if rat_of_int (- coeff [:b, a:] 0) / rat_of_int (coeff [:b, a:] 1) ≤ ba then 1 else 0) else Root_Info (λaa ba. sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) ba) (λaa. sign_changes_neg_number_rootat (sturm_rat (of_int_poly [:b, a:])) - sign_changes_rat (sturm_rat (of_int_poly [:b, a:])) aa)) aa = card (if rat_of_int (- b) / rat_of_int a ≤ aa then {real_of_rat (rat_of_int (- b) / rat_of_int a)} else {}))›*) by auto next (*goal: ‹degree p ≠ 1 ⟹ root_info_cond (root_info p) p›*) case False (*‹degree p ≠ 1›*) have irr_d: "irreducible⇩d p" by (simp add: deg (*‹0 < degree p›*) irr (*‹irreducible p›*) irreducible_connect_rev (*‹⟦irreducible ?p; 0 < degree ?p⟧ ⟹ irreducible⇩d ?p›*)) from "irreducible⇩d_int_rat"[OF this] (*‹irreducible⇩d (of_int_poly p)›*) have "irreducible (of_int_poly p :: rat poly)" by auto from irreducible_root_free[OF this] (*‹root_free (of_int_poly p)›*) have idd: "(poly (of_int_poly p) a = 0) = False" for a :: rat unfolding root_free_def (*goal: ‹(ipoly p a = 0) = False›*) using False (*‹degree p ≠ 1›*) by auto have id: "root_info p = count_roots_interval_rat p" unfolding root_info_def if_False count_roots_interval_rat_code Let_def idd (*goal: ‹(if degree (p::int poly) = (1::nat) then Root_Info (λ(l::rat) r::rat. if l ≤ Rat.Fract (- coeff p (0::nat)) (coeff p (1::nat)) ∧ Rat.Fract (- coeff p (0::nat)) (coeff p (1::nat)) ≤ r then 1::nat else (0::nat)) (λb::rat. if Rat.Fract (- coeff p (0::nat)) (coeff p (1::nat)) ≤ b then 1::nat else (0::nat)) else Root_Info (λ(a::rat) b::rat. sign_changes_rat (sturm_rat (of_int_poly p)) a - sign_changes_rat (sturm_rat (of_int_poly p)) b) (λa::rat. sign_changes_neg_number_rootat (sturm_rat (of_int_poly p)) - sign_changes_rat (sturm_rat (of_int_poly p)) a)) = Root_Info (λ(a::rat) b::rat. sign_changes_rat (sturm_rat (of_int_poly p)) a - sign_changes_rat (sturm_rat (of_int_poly p)) b + (0::nat)) (λa::rat. sign_changes_neg_number_rootat (sturm_rat (of_int_poly p)) - sign_changes_rat (sturm_rat (of_int_poly p)) a)›*) using False (*‹degree (p::int poly) ≠ (1::nat)›*) by auto show "?thesis" (*goal: ‹root_info_cond (root_info p) p›*) unfolding id (*goal: ‹root_info_cond (count_roots_interval_rat p) p›*) by (rule count_roots_interval_rat[OF irreducible⇩d_square_free[OF irr_d]] (*‹root_info_cond (count_roots_interval_rat p) p›*)) qed end
{ "path": "afp-2025-02-12/thys/Algebraic_Numbers/Sturm_Rat.thy", "repo": "afp-2025-02-12", "sha": "4ac0aef6c8ab9b9ebf659a4599188a81dbe4f6ec02e8e7d25b5e3c54ca9cdb9d" }
(* File: Interval_Tree.thy Author: Bohua Zhan *) section ‹Interval tree› theory Interval_Tree imports Lists_Ex Interval begin text ‹ Functional version of interval tree. This is an augmented data structure on top of regular binary search trees (see BST.thy). See \<^cite>‹‹Section 14.3› in "cormen2009introduction"› for a reference. › subsection ‹Definition of an interval tree› datatype interval_tree = Tip | Node (lsub: interval_tree) (val: "nat idx_interval") (tmax: nat) (rsub: interval_tree) where "tmax Tip = 0" setup ‹add_resolve_prfstep @{thm interval_tree.distinct(1)}› setup ‹fold add_rewrite_rule @{thms interval_tree.sel}› setup ‹add_forward_prfstep @{thm interval_tree.collapse}› setup ‹add_var_induct_rule @{thm interval_tree.induct}› subsection ‹Inorder traversal, and set of elements of a tree› fun in_traverse :: "interval_tree ⇒ nat idx_interval list" where "in_traverse Tip = []" | "in_traverse (Node l it m r) = in_traverse l @ it # in_traverse r" setup ‹fold add_rewrite_rule @{thms in_traverse.simps}› fun tree_set :: "interval_tree ⇒ nat idx_interval set" where "tree_set Tip = {}" | "tree_set (Node l it m r) = {it} ∪ tree_set l ∪ tree_set r" setup ‹fold add_rewrite_rule @{thms tree_set.simps}› fun tree_sorted :: "interval_tree ⇒ bool" where "tree_sorted Tip = True" | "tree_sorted (Node l it m r) = ((∀x∈tree_set l. x < it) ∧ (∀x∈tree_set r. it < x) ∧ tree_sorted l ∧ tree_sorted r)" setup ‹fold add_rewrite_rule @{thms tree_sorted.simps}› lemma tree_sorted_lr [forward]: "tree_sorted (Node l it m r) ⟹ tree_sorted l ∧ tree_sorted r" by auto2 lemma tree_sortedD1 [forward]: "tree_sorted (Node l it m r) ⟹ x ∈ tree_set l ⟹ x < it" by auto2 lemma tree_sortedD2 [forward]: "tree_sorted (Node l it m r) ⟹ x ∈ tree_set r ⟹ x > it" by auto2 lemma inorder_preserve_set [rewrite]: "tree_set t = set (in_traverse t)" @proof @induct t @qed lemma inorder_sorted [rewrite]: "tree_sorted t ⟷ strict_sorted (in_traverse t)" @proof @induct t @qed text ‹Use definition in terms of in\_traverse from now on.› setup ‹fold del_prfstep_thm (@{thms tree_set.simps} @ @{thms tree_sorted.simps})› subsection ‹Invariant on the maximum› definition max3 :: "nat idx_interval ⇒ nat ⇒ nat ⇒ nat" where [rewrite]: "max3 it b c = max (high (int it)) (max b c)" fun tree_max_inv :: "interval_tree ⇒ bool" where "tree_max_inv Tip = True" | "tree_max_inv (Node l it m r) ⟷ (tree_max_inv l ∧ tree_max_inv r ∧ m = max3 it (tmax l) (tmax r))" setup ‹fold add_rewrite_rule @{thms tree_max_inv.simps}› lemma tree_max_is_max [resolve]: "tree_max_inv t ⟹ it ∈ tree_set t ⟹ high (int it) ≤ tmax t" @proof @induct t @qed lemma tmax_exists [backward]: "tree_max_inv t ⟹ t ≠ Tip ⟹ ∃p∈tree_set t. high (int p) = tmax t" @proof @induct t @with @subgoal "t = Node l it m r" @case "l = Tip" @with @case "r = Tip" @end @case "r = Tip" @endgoal @end @qed text ‹For insertion› lemma max3_insert [rewrite]: "max3 it 0 0 = high (int it)" by auto2 setup ‹del_prfstep_thm @{thm max3_def}› subsection ‹Condition on the values› definition tree_interval_inv :: "interval_tree ⇒ bool" where [rewrite]: "tree_interval_inv t ⟷ (∀p∈tree_set t. is_interval (int p))" definition is_interval_tree :: "interval_tree ⇒ bool" where [rewrite]: "is_interval_tree t ⟷ (tree_sorted t ∧ tree_max_inv t ∧ tree_interval_inv t)" lemma is_interval_tree_lr [forward]: "is_interval_tree (Node l x m r) ⟹ is_interval_tree l ∧ is_interval_tree r" by auto2 subsection ‹Insertion on trees› fun insert :: "nat idx_interval ⇒ interval_tree ⇒ interval_tree" where "insert x Tip = Node Tip x (high (int x)) Tip" | "insert x (Node l y m r) = (if x = y then Node l y m r else if x < y then let l' = insert x l in Node l' y (max3 y (tmax l') (tmax r)) r else let r' = insert x r in Node l y (max3 y (tmax l) (tmax r')) r')" setup ‹fold add_rewrite_rule @{thms insert.simps}› lemma tree_insert_in_traverse [rewrite]: "tree_sorted t ⟹ in_traverse (insert x t) = ordered_insert x (in_traverse t)" @proof @induct t @qed lemma tree_insert_max_inv [forward]: "tree_max_inv t ⟹ tree_max_inv (insert x t)" @proof @induct t @qed text ‹Correctness of insertion.› theorem tree_insert_all_inv [forward]: "is_interval_tree t ⟹ is_interval (int it) ⟹ is_interval_tree (insert it t)" sorry theorem tree_insert_on_set [rewrite]: "tree_sorted t ⟹ tree_set (insert it t) = {it} ∪ tree_set t" by auto2 subsection ‹Deletion on trees› fun del_min :: "interval_tree ⇒ nat idx_interval × interval_tree" where "del_min Tip = undefined" | "del_min (Node lt v m rt) = (if lt = Tip then (v, rt) else let lt' = snd (del_min lt) in (fst (del_min lt), Node lt' v (max3 v (tmax lt') (tmax rt)) rt))" setup ‹add_rewrite_rule @{thm del_min.simps(2)}› setup ‹register_wellform_data ("del_min t", ["t ≠ Tip"])› lemma delete_min_del_hd: "t ≠ Tip ⟹ fst (del_min t) # in_traverse (snd (del_min t)) = in_traverse t" @proof @induct t @qed setup ‹add_forward_prfstep_cond @{thm delete_min_del_hd} [with_term "in_traverse (snd (del_min ?t))"]› lemma delete_min_max_inv [forward_arg]: "tree_max_inv t ⟹ t ≠ Tip ⟹ tree_max_inv (snd (del_min t))" @proof @induct t @qed lemma delete_min_on_set: "t ≠ Tip ⟹ {fst (del_min t)} ∪ tree_set (snd (del_min t)) = tree_set t" by auto2 setup ‹add_forward_prfstep_cond @{thm delete_min_on_set} [with_term "tree_set (snd (del_min ?t))"]› lemma delete_min_interval_inv [forward_arg]: "tree_interval_inv t ⟹ t ≠ Tip ⟹ tree_interval_inv (snd (del_min t))" by auto2 lemma delete_min_all_inv [forward_arg]: "is_interval_tree t ⟹ t ≠ Tip ⟹ is_interval_tree (snd (del_min t))" by auto2 fun delete_elt_tree :: "interval_tree ⇒ interval_tree" where "delete_elt_tree Tip = undefined" | "delete_elt_tree (Node lt x m rt) = (if lt = Tip then rt else if rt = Tip then lt else let x' = fst (del_min rt); rt' = snd (del_min rt); m' = max3 x' (tmax lt) (tmax rt') in Node lt (fst (del_min rt)) m' rt')" setup ‹add_rewrite_rule @{thm delete_elt_tree.simps(2)}› lemma delete_elt_in_traverse [rewrite]: "in_traverse (delete_elt_tree (Node lt x m rt)) = in_traverse lt @ in_traverse rt" by auto2 lemma delete_elt_max_inv [forward_arg]: "tree_max_inv t ⟹ t ≠ Tip ⟹ tree_max_inv (delete_elt_tree t)" by auto2 lemma delete_elt_on_set [rewrite]: "t ≠ Tip ⟹ tree_set (delete_elt_tree (Node lt x m rt)) = tree_set lt ∪ tree_set rt" by auto2 lemma delete_elt_interval_inv [forward_arg]: "tree_interval_inv t ⟹ t ≠ Tip ⟹ tree_interval_inv (delete_elt_tree t)" by auto2 lemma delete_elt_all_inv [forward_arg]: "is_interval_tree t ⟹ t ≠ Tip ⟹ is_interval_tree (delete_elt_tree t)" by auto2 fun delete :: "nat idx_interval ⇒ interval_tree ⇒ interval_tree" where "delete x Tip = Tip" | "delete x (Node l y m r) = (if x = y then delete_elt_tree (Node l y m r) else if x < y then let l' = delete x l; m' = max3 y (tmax l') (tmax r) in Node l' y m' r else let r' = delete x r; m' = max3 y (tmax l) (tmax r') in Node l y m' r')" setup ‹fold add_rewrite_rule @{thms delete.simps}› lemma tree_delete_in_traverse [rewrite]: "tree_sorted t ⟹ in_traverse (delete x t) = remove_elt_list x (in_traverse t)" @proof @induct t @qed lemma tree_delete_max_inv [forward]: "tree_max_inv t ⟹ tree_max_inv (delete x t)" @proof @induct t @qed text ‹Correctness of deletion.› theorem tree_delete_all_inv [forward]: "is_interval_tree t ⟹ is_interval_tree (delete x t)" @proof @have "tree_set (delete x t) ⊆ tree_set t" @qed theorem tree_delete_on_set [rewrite]: "tree_sorted t ⟹ tree_set (delete x t) = tree_set t - {x}" by auto2 subsection ‹Search on interval trees› fun search :: "interval_tree ⇒ nat interval ⇒ bool" where "search Tip x = False" | "search (Node l y m r) x = (if is_overlap (int y) x then True else if l ≠ Tip ∧ tmax l ≥ low x then search l x else search r x)" setup ‹fold add_rewrite_rule @{thms search.simps}› text ‹Correctness of search› theorem search_correct [rewrite]: "is_interval_tree t ⟹ is_interval x ⟹ search t x ⟷ has_overlap (tree_set t) x" @proof @induct t @with @subgoal "t = Node l y m r" @let "t = Node l y m r" @case "is_overlap (int y) x" @case "l ≠ Tip ∧ tmax l ≥ low x" @with @obtain "p∈tree_set l" where "high (int p) = tmax l" @case "is_overlap (int p) x" @end @case "l = Tip" @endgoal @end @qed end
{ "path": "afp-2025-02-12/thys/Auto2_Imperative_HOL/Functional/Interval_Tree.thy", "repo": "afp-2025-02-12", "sha": "ae05855e0022dcd325640fff549666e538418d48753e3e9d0d0934a720a9e35c" }
section ‹Uniform Sampling› text‹Here we prove different one time pad lemmas based on uniform sampling we require throughout our proofs.› theory Uniform_Sampling imports CryptHOL.Cyclic_Group_SPMF "HOL-Number_Theory.Cong" CryptHOL.List_Bits begin text ‹If q is a prime we can sample from the units.› definition sample_uniform_units :: "nat ⇒ nat spmf" where "sample_uniform_units q = spmf_of_set ({..< q} - {0})" lemma set_spmf_sampl_uni_units [simp]: "set_spmf (sample_uniform_units q) = {..< q} - {0}" by (simp add: sample_uniform_units_def (*‹sample_uniform_units ?q = spmf_of_set ({..<?q} - {0})›*)) lemma lossless_sample_uniform_units: assumes "q > 1" shows "lossless_spmf (sample_uniform_units q)" apply (simp add: sample_uniform_units_def (*‹sample_uniform_units ?q = spmf_of_set ({..<?q} - {0})›*)) (*goal: ‹lossless_spmf (sample_uniform_units (q::nat))›*) using assms (*‹1 < q›*) by auto text ‹General lemma for mapping using uniform sampling from units.› lemma one_time_pad_units: assumes inj_on: "inj_on f ({..<q} - {0})" and sur: "f ` ({..<q} - {0}) = ({..<q} - {0})" shows "map_spmf f (sample_uniform_units q) = (sample_uniform_units q)" (is "?lhs = ?rhs") proof (-) (*goal: ‹map_spmf f (sample_uniform_units q) = sample_uniform_units q›*) have rhs: "?rhs = spmf_of_set (({..<q} - {0}))" by (auto simp add: sample_uniform_units_def (*‹sample_uniform_units ?q = spmf_of_set ({..<?q} - {0})›*)) also (*calculation: ‹sample_uniform_units q = spmf_of_set ({..<q} - {0})›*) have "map_spmf(λs. f s) (spmf_of_set ({..<q} - {0})) = spmf_of_set ((λs. f s) ` ({..<q} - {0}))" by (simp add: inj_on (*‹inj_on f ({..<q} - {0})›*)) also (*calculation: ‹map_spmf (f::nat ⇒ nat) (sample_uniform_units (q::nat)) = spmf_of_set (f ` ({..<q} - {0::nat}))›*) have "f ` ({..<q} - {0}) = ({..<q} - {0})" apply (rule endo_inj_surj (*‹⟦finite ?A; ?f ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goals: 1. ‹finite ({..<q} - {0})› 2. ‹f ` ({..<q} - {0}) ⊆ {..<q} - {0}› 3. ‹inj_on f ({..<q} - {0})› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: sur (*‹(f::nat ⇒ nat) ` ({..<q::nat} - {0::nat}) = {..<q} - {0::nat}›*)) (*discuss goal 3*) apply (simp add: inj_on (*‹inj_on (f::nat ⇒ nat) ({..<q::nat} - {0::nat})›*)) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹map_spmf f (sample_uniform_units q) = sample_uniform_units q›*) using rhs (*‹sample_uniform_units q = spmf_of_set ({..<q} - {0})›*) by simp qed text ‹General lemma for mapping using uniform sampling.› lemma one_time_pad: assumes inj_on: "inj_on f {..<q}" and sur: "f ` {..<q} = {..<q}" shows "map_spmf f (sample_uniform q) = (sample_uniform q)" (is "?lhs = ?rhs") proof (-) (*goal: ‹map_spmf (f::nat ⇒ nat) (sample_uniform (q::nat)) = sample_uniform q›*) have rhs: "?rhs = spmf_of_set ({..< q})" by (auto simp add: sample_uniform_def (*‹sample_uniform ?n = spmf_of_set {..<?n}›*)) also (*calculation: ‹sample_uniform q = spmf_of_set {..<q}›*) have "map_spmf(λs. f s) (spmf_of_set {..<q}) = spmf_of_set ((λs. f s) ` {..<q})" by (simp add: inj_on (*‹inj_on f {..<q}›*)) also (*calculation: ‹map_spmf f (sample_uniform q) = spmf_of_set (f ` {..<q})›*) have "f ` {..<q} = {..<q}" apply (rule endo_inj_surj (*‹⟦finite (?A::?'a set); (?f::?'a ⇒ ?'a) ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goals: 1. ‹finite {..<q::nat}› 2. ‹(f::nat ⇒ nat) ` {..<q::nat} ⊆ {..<q}› 3. ‹inj_on (f::nat ⇒ nat) {..<q::nat}› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: sur (*‹f ` {..<q} = {..<q}›*)) (*discuss goal 3*) apply (simp add: inj_on (*‹inj_on f {..<q}›*)) (*proven 3 subgoals*) . ultimately show "?thesis" (*goal: ‹map_spmf f (sample_uniform q) = sample_uniform q›*) using rhs (*‹sample_uniform (q::nat) = spmf_of_set {..<q}›*) by simp qed text ‹The addition map case.› lemma inj_add: assumes x: "x < q" and x': "x' < q" and map: "((y :: nat) + x) mod q = (y + x') mod q" shows "x = x'" proof (-) (*goal: ‹(x::nat) = (x'::nat)›*) have aa: "((y :: nat) + x) mod q = (y + x') mod q ⟹ x mod q = x' mod q" proof (-) (*goal: ‹(y + x) mod q = (y + x') mod q ⟹ x mod q = x' mod q›*) have 4: "((y:: nat) + x) mod q = (y + x') mod q ⟹ [((y:: nat) + x) = (y + x')] (mod q)" by (simp add: cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*)) have 5: "[((y:: nat) + x) = (y + x')] (mod q) ⟹ [x = x'] (mod q)" by (simp add: cong_add_lcancel_nat (*‹[(?a::nat) + (?x::nat) = ?a + (?y::nat)] (mod ?n::nat) = [?x = ?y] (mod ?n)›*)) have 6: "[x = x'] (mod q) ⟹ x mod q = x' mod q" by (simp add: cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*)) then show "?thesis" (*goal: ‹x mod q = x' mod q›*) by (simp add: map (*‹(y + x) mod q = (y + x') mod q›*) 4 (*‹(y + x) mod q = (y + x') mod q ⟹ [y + x = y + x'] (mod q)›*) 5 (*‹[y + x = y + x'] (mod q) ⟹ [x = x'] (mod q)›*) 6 (*‹[x = x'] (mod q) ⟹ x mod q = x' mod q›*)) qed also (*calculation: ‹(y + x) mod q = (y + x') mod q ⟹ x mod q = x' mod q›*) have bb: "x mod q = x' mod q ⟹ x = x'" by (simp add: x (*‹x < q›*) x' (*‹x' < q›*)) ultimately show "?thesis" (*goal: ‹(x::nat) = (x'::nat)›*) by (simp add: map (*‹(y + x) mod q = (y + x') mod q›*)) qed lemma inj_uni_samp_add: "inj_on (λ(b :: nat). (y + b) mod q ) {..<q}" apply (simp add: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*)) (*goal: ‹inj_on (λb. (y + b) mod q) {..<q}›*) by (auto simp only: inj_add (*‹⟦?x < ?q; ?x' < ?q; (?y + ?x) mod ?q = (?y + ?x') mod ?q⟧ ⟹ ?x = ?x'›*)) lemma surj_uni_samp: assumes inj: "inj_on (λ(b :: nat). (y + b) mod q ) {..<q}" shows "(λ(b :: nat). (y + b) mod q) ` {..< q} = {..< q}" apply (rule endo_inj_surj (*‹⟦finite ?A; ?f ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goal: ‹(λb::nat. ((y::nat) + b) mod (q::nat)) ` {..<q} = {..<q}›*) using inj (*‹inj_on (λb. (y + b) mod q) {..<q}›*) apply - (*goals: 1. ‹inj_on (λb. (y + b) mod q) {..<q} ⟹ finite {..<q}› 2. ‹inj_on (λb. (y + b) mod q) {..<q} ⟹ (λb. (y + b) mod q) ` {..<q} ⊆ {..<q}› 3. ‹inj_on (λb. (y + b) mod q) {..<q} ⟹ inj_on (λb. (y + b) mod q) {..<q}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma samp_uni_plus_one_time_pad: shows "map_spmf (λb. (y + b) mod q) (sample_uniform q) = (sample_uniform q)" using inj_uni_samp_add (*‹inj_on (λb. (?y + b) mod ?q) {..<?q}›*) surj_uni_samp (*‹inj_on (λb. (?y + b) mod ?q) {..<?q} ⟹ (λb. (?y + b) mod ?q) ` {..<?q} = {..<?q}›*) one_time_pad (*‹⟦inj_on ?f {..<?q}; ?f ` {..<?q} = {..<?q}⟧ ⟹ map_spmf ?f (sample_uniform ?q) = sample_uniform ?q›*) by simp text ‹The multiplicaton map case.› lemma inj_mult: assumes coprime: "coprime x (q::nat)" and y: "y < q" and y': "y' < q" and map: "x * y mod q = x * y' mod q" shows "y = y'" proof (-) (*goal: ‹y = y'›*) have "x*y mod q = x*y' mod q ⟹ y mod q = y' mod q" proof (-) (*goal: ‹(x::nat) * (y::nat) mod (q::nat) = x * (y'::nat) mod q ⟹ y mod q = y' mod q›*) have "x*y mod q = x*y' mod q ⟹ [x*y = x*y'] (mod q)" by (simp add: cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*)) also (*calculation: ‹(x::nat) * (y::nat) mod (q::nat) = x * (y'::nat) mod q ⟹ [x * y = x * y'] (mod q)›*) have "[x*y = x*y'] (mod q) = [y = y'] (mod q)" by (simp add: cong_mult_lcancel_nat (*‹coprime (?k::nat) (?m::nat) ⟹ [?k * (?a::nat) = ?k * (?b::nat)] (mod ?m) = [?a = ?b] (mod ?m)›*) coprime (*‹coprime (x::nat) (q::nat)›*)) also (*calculation: ‹x * y mod q = x * y' mod q ⟹ [y = y'] (mod q)›*) have "[y = y'] (mod q) ⟹ y mod q = y' mod q" by (simp add: cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*)) ultimately show "?thesis" (*goal: ‹y mod q = y' mod q›*) by (simp add: map (*‹x * y mod q = x * y' mod q›*)) qed also (*calculation: ‹x * y mod q = x * y' mod q ⟹ y mod q = y' mod q›*) have "y mod q = y' mod q ⟹ y = y'" by (simp add: y (*‹y < q›*) y' (*‹y' < q›*)) ultimately show "?thesis" (*goal: ‹(y::nat) = (y'::nat)›*) by (simp add: map (*‹x * y mod q = x * y' mod q›*)) qed lemma inj_on_mult: assumes coprime: "coprime x (q::nat)" shows "inj_on (λ b. x*b mod q) {..<q}" apply (auto simp add: inj_on_def (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) = (∀x::?'a∈?A. ∀y::?'a∈?A. ?f x = ?f y ⟶ x = y)›*)) (*goal: ‹inj_on (λb. x * b mod q) {..<q}›*) using coprime (*‹coprime x q›*) by (simp only: inj_mult (*‹⟦coprime (?x::nat) (?q::nat); (?y::nat) < ?q; (?y'::nat) < ?q; ?x * ?y mod ?q = ?x * ?y' mod ?q⟧ ⟹ ?y = ?y'›*)) lemma surj_on_mult: assumes coprime: "coprime x (q::nat)" and inj: "inj_on (λ b. x*b mod q) {..<q}" shows "(λ b. x*b mod q) ` {..< q} = {..< q}" apply (rule endo_inj_surj (*‹⟦finite ?A; ?f ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goal: ‹(λb. x * b mod q) ` {..<q} = {..<q}›*) using coprime (*‹coprime x q›*) inj (*‹inj_on (λb::nat. (x::nat) * b mod (q::nat)) {..<q}›*) apply - (*goals: 1. ‹⟦coprime x q; inj_on (λb. x * b mod q) {..<q}⟧ ⟹ finite {..<q}› 2. ‹⟦coprime x q; inj_on (λb. x * b mod q) {..<q}⟧ ⟹ (λb. x * b mod q) ` {..<q} ⊆ {..<q}› 3. ‹⟦coprime x q; inj_on (λb. x * b mod q) {..<q}⟧ ⟹ inj_on (λb. x * b mod q) {..<q}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma mult_one_time_pad: assumes coprime: "coprime x q" shows "map_spmf (λ b. x*b mod q) (sample_uniform q) = (sample_uniform q)" using inj_on_mult (*‹coprime ?x ?q ⟹ inj_on (λb. ?x * b mod ?q) {..<?q}›*) surj_on_mult (*‹⟦coprime ?x ?q; inj_on (λb. ?x * b mod ?q) {..<?q}⟧ ⟹ (λb. ?x * b mod ?q) ` {..<?q} = {..<?q}›*) one_time_pad (*‹⟦inj_on ?f {..<?q}; ?f ` {..<?q} = {..<?q}⟧ ⟹ map_spmf ?f (sample_uniform ?q) = sample_uniform ?q›*) coprime (*‹coprime x q›*) by simp text ‹The multiplication map for sampling from units.› lemma inj_on_mult_units: assumes 1: "coprime x (q::nat)" shows "inj_on (λ b. x*b mod q) ({..<q} - {0})" apply (auto simp add: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*)) (*goal: ‹inj_on (λb. x * b mod q) ({..<q} - {0})›*) using "1" (*‹coprime (x::nat) (q::nat)›*) by (simp only: inj_mult (*‹⟦coprime (?x::nat) (?q::nat); (?y::nat) < ?q; (?y'::nat) < ?q; ?x * ?y mod ?q = ?x * ?y' mod ?q⟧ ⟹ ?y = ?y'›*)) lemma surj_on_mult_units: assumes coprime: "coprime x (q::nat)" and inj: "inj_on (λ b. x*b mod q) ({..<q} - {0})" shows "(λ b. x*b mod q) ` ({..<q} - {0}) = ({..<q} - {0})" proof (rule endo_inj_surj (*‹⟦finite ?A; ?f ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goals: 1. ‹finite ({..<q} - {0})› 2. ‹(λb. x * b mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0}› 3. ‹inj_on (λb. x * b mod q) ({..<q} - {0})›*) show "finite ({..<q} - {0})" using coprime (*‹coprime (x::nat) (q::nat)›*) inj (*‹inj_on (λb. x * b mod q) ({..<q} - {0})›*) by simp show "(λb. x * b mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0}" proof (-) (*goal: ‹(λb. x * b mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0}›*) obtain n :: "nat set ⇒ (nat ⇒ nat) ⇒ nat set ⇒ nat" where "∀x0 x1 x2. (∃v3. v3 ∈ x2 ∧ x1 v3 ∉ x0) = (n x0 x1 x2 ∈ x2 ∧ x1 (n x0 x1 x2) ∉ x0)" (*goal: ‹(⋀n::nat set ⇒ (nat ⇒ nat) ⇒ nat set ⇒ nat. ∀(x0::nat set) (x1::nat ⇒ nat) x2::nat set. (∃v3::nat. v3 ∈ x2 ∧ x1 v3 ∉ x0) = (n x0 x1 x2 ∈ x2 ∧ x1 (n x0 x1 x2) ∉ x0) ⟹ thesis::bool) ⟹ thesis›*) by moura then have subset: "∀N f Na. n Na f N ∈ N ∧ f (n Na f N) ∉ Na ∨ f ` N ⊆ Na" by (meson image_subsetI (*‹(⋀x. x ∈ ?A ⟹ ?f x ∈ ?B) ⟹ ?f ` ?A ⊆ ?B›*)) have mem_insert: "x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∉ {..<q} ∨ x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ insert 0 {..<q}" by force have map_eq: "(x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ insert 0 {..<q} - {0}) = (x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ {..<q} - {0})" by simp { assume "x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q = x * 0 mod q" (*‹(x::nat) * (n::nat set ⇒ (nat ⇒ nat) ⇒ nat set ⇒ nat) ({..<q::nat} - {0::nat}) (λn::nat. x * n mod q) ({..<q} - {0::nat}) mod q = x * (0::nat) mod q›*) then have "(0 ≤ q) = (0 = q) ∨ (n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) ∉ {..<q} ∨ n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) ∈ {0}) ∨ n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) ∉ {..<q} - {0} ∨ x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ {..<q} - {0}" by (metis antisym_conv1 (*‹¬ (?x::?'a::order) < (?y::?'a::order) ⟹ (?x ≤ ?y) = (?x = ?y)›*) insertCI (*‹((?a::?'a::type) ∉ (?B::?'a::type set) ⟹ ?a = (?b::?'a::type)) ⟹ ?a ∈ insert ?b ?B›*) lessThan_iff (*‹((?i::?'a::ord) ∈ {..<?k::?'a::ord}) = (?i < ?k)›*) local.coprime (*‹coprime (x::nat) (q::nat)›*) inj_mult (*‹⟦coprime (?x::nat) (?q::nat); (?y::nat) < ?q; (?y'::nat) < ?q; ?x * ?y mod ?q = ?x * ?y' mod ?q⟧ ⟹ ?y = ?y'›*)) } moreover { assume "0 ≠ x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q" (*‹(0::nat) ≠ (x::nat) * (n::nat set ⇒ (nat ⇒ nat) ⇒ nat set ⇒ nat) ({..<q::nat} - {0::nat}) (λn::nat. x * n mod q) ({..<q} - {0::nat}) mod q›*) moreover { assume "x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ insert 0 {..<q} ∧ x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∉ {0}" (*‹(x::nat) * (n::nat set ⇒ (nat ⇒ nat) ⇒ nat set ⇒ nat) ({..<q::nat} - {0::nat}) (λn::nat. x * n mod q) ({..<q} - {0::nat}) mod q ∈ insert (0::nat) {..<q} ∧ x * n ({..<q} - {0::nat}) (λn::nat. x * n mod q) ({..<q} - {0::nat}) mod q ∉ {0::nat}›*) then have "(λn. x * n mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0}" using map_eq (*‹(x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ insert 0 {..<q} - {0}) = (x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ {..<q} - {0})›*) subset (*‹∀N f Na. n Na f N ∈ N ∧ f (n Na f N) ∉ Na ∨ f ` N ⊆ Na›*) by (meson Diff_iff (*‹(?c ∈ ?A - ?B) = (?c ∈ ?A ∧ ?c ∉ ?B)›*)) } ultimately have "(λn. x * n mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0} ∨ (0 ≤ q) = (0 = q)" using mem_insert (*‹x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∉ {..<q} ∨ x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ insert 0 {..<q}›*) by (metis antisym_conv1 (*‹¬ ?x < ?y ⟹ (?x ≤ ?y) = (?x = ?y)›*) lessThan_iff (*‹(?i ∈ {..<?k}) = (?i < ?k)›*) mod_less_divisor (*‹0 < ?n ⟹ ?m mod ?n < ?n›*) singletonD (*‹?b ∈ {?a} ⟹ ?b = ?a›*)) } ultimately have "(λn. x * n mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0} ∨ n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) ∉ {..<q} - {0} ∨ x * n ({..<q} - {0}) (λn. x * n mod q) ({..<q} - {0}) mod q ∈ {..<q} - {0}" by force then show "(λn. x * n mod q) ` ({..<q} - {0}) ⊆ {..<q} - {0}" using subset (*‹∀N f Na. n Na f N ∈ N ∧ f (n Na f N) ∉ Na ∨ f ` N ⊆ Na›*) by meson qed show "inj_on (λb. x * b mod q) ({..<q} - {0})" using assms (*‹coprime x q› ‹inj_on (λb. x * b mod q) ({..<q} - {0})›*) by simp qed lemma mult_one_time_pad_units: assumes coprime: "coprime x q" shows "map_spmf (λ b. x*b mod q) (sample_uniform_units q) = sample_uniform_units q" using inj_on_mult_units (*‹coprime ?x ?q ⟹ inj_on (λb. ?x * b mod ?q) ({..<?q} - {0})›*) surj_on_mult_units (*‹⟦coprime ?x ?q; inj_on (λb. ?x * b mod ?q) ({..<?q} - {0})⟧ ⟹ (λb. ?x * b mod ?q) ` ({..<?q} - {0}) = {..<?q} - {0}›*) one_time_pad_units (*‹⟦inj_on ?f ({..<?q} - {0}); ?f ` ({..<?q} - {0}) = {..<?q} - {0}⟧ ⟹ map_spmf ?f (sample_uniform_units ?q) = sample_uniform_units ?q›*) coprime (*‹coprime (x::nat) (q::nat)›*) by simp text ‹Addition and multiplication map.› lemma samp_uni_add_mult: assumes coprime: "coprime x (q::nat)" and xa: "xa < q" and ya: "ya < q" and map: "(y + x * xa) mod q = (y + x * ya) mod q" shows "xa = ya" proof (-) (*goal: ‹xa = ya›*) have "(y + x * xa) mod q = (y + x * ya) mod q ⟹ xa mod q = ya mod q" proof (-) (*goal: ‹(y + x * xa) mod q = (y + x * ya) mod q ⟹ xa mod q = ya mod q›*) have "(y + x * xa) mod q = (y + x * ya) mod q ⟹ [y + x*xa = y + x *ya] (mod q)" using cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*) by blast also (*calculation: ‹(y + x * xa) mod q = (y + x * ya) mod q ⟹ [y + x * xa = y + x * ya] (mod q)›*) have "[y + x*xa = y + x *ya] (mod q) ⟹ [xa = ya] (mod q)" apply (simp add: cong_add_lcancel_nat (*‹[?a + ?x = ?a + ?y] (mod ?n) = [?x = ?y] (mod ?n)›*)) (*goal: ‹[(y::nat) + (x::nat) * (xa::nat) = y + x * (ya::nat)] (mod q::nat) ⟹ [xa = ya] (mod q)›*) by (simp add: coprime (*‹coprime x q›*) cong_mult_lcancel_nat (*‹coprime ?k ?m ⟹ [?k * ?a = ?k * ?b] (mod ?m) = [?a = ?b] (mod ?m)›*)) ultimately show "?thesis" (*goal: ‹xa mod q = ya mod q›*) by (simp add: cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*) map (*‹(y + x * xa) mod q = (y + x * ya) mod q›*)) qed also (*calculation: ‹(y + x * xa) mod q = (y + x * ya) mod q ⟹ xa mod q = ya mod q›*) have "xa mod q = ya mod q ⟹ xa = ya" by (simp add: xa (*‹xa < q›*) ya (*‹ya < q›*)) ultimately show "?thesis" (*goal: ‹(xa::nat) = (ya::nat)›*) by (simp add: map (*‹(y + x * xa) mod q = (y + x * ya) mod q›*)) qed lemma inj_on_add_mult: assumes coprime: "coprime x (q::nat)" shows "inj_on (λ b. (y + x*b) mod q) {..<q}" apply (auto simp add: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*)) (*goal: ‹inj_on (λb. (y + x * b) mod q) {..<q}›*) using coprime (*‹coprime (x::nat) (q::nat)›*) by (simp only: samp_uni_add_mult (*‹⟦coprime (?x::nat) (?q::nat); (?xa::nat) < ?q; (?ya::nat) < ?q; ((?y::nat) + ?x * ?xa) mod ?q = (?y + ?x * ?ya) mod ?q⟧ ⟹ ?xa = ?ya›*)) lemma surj_on_add_mult: assumes coprime: "coprime x (q::nat)" and inj: "inj_on (λ b. (y + x*b) mod q) {..<q}" shows "(λ b. (y + x*b) mod q) ` {..< q} = {..< q}" apply (rule endo_inj_surj (*‹⟦finite ?A; ?f ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goal: ‹(λb. (y + x * b) mod q) ` {..<q} = {..<q}›*) using coprime (*‹coprime x q›*) inj (*‹inj_on (λb::nat. ((y::nat) + (x::nat) * b) mod (q::nat)) {..<q}›*) apply - (*goals: 1. ‹⟦coprime x q; inj_on (λb. (y + x * b) mod q) {..<q}⟧ ⟹ finite {..<q}› 2. ‹⟦coprime x q; inj_on (λb. (y + x * b) mod q) {..<q}⟧ ⟹ (λb. (y + x * b) mod q) ` {..<q} ⊆ {..<q}› 3. ‹⟦coprime x q; inj_on (λb. (y + x * b) mod q) {..<q}⟧ ⟹ inj_on (λb. (y + x * b) mod q) {..<q}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma add_mult_one_time_pad: assumes coprime: "coprime x q" shows "map_spmf (λ b. (y + x*b) mod q) (sample_uniform q) = (sample_uniform q)" using inj_on_add_mult (*‹coprime (?x::nat) (?q::nat) ⟹ inj_on (λb::nat. ((?y::nat) + ?x * b) mod ?q) {..<?q}›*) surj_on_add_mult (*‹⟦coprime ?x ?q; inj_on (λb. (?y + ?x * b) mod ?q) {..<?q}⟧ ⟹ (λb. (?y + ?x * b) mod ?q) ` {..<?q} = {..<?q}›*) one_time_pad (*‹⟦inj_on ?f {..<?q}; ?f ` {..<?q} = {..<?q}⟧ ⟹ map_spmf ?f (sample_uniform ?q) = sample_uniform ?q›*) coprime (*‹coprime x q›*) by simp text ‹Subtraction Map.› lemma inj_minus: assumes x: "(x :: nat) < q" and ya: "ya < q" and map: "(y + q - x) mod q = (y + q - ya) mod q" shows "x = ya" proof (-) (*goal: ‹x = ya›*) have "(y + q - x) mod q = (y + q - ya) mod q ⟹ x mod q = ya mod q" proof (-) (*goal: ‹(y + q - x) mod q = (y + q - ya) mod q ⟹ x mod q = ya mod q›*) have "(y + q - x) mod q = (y + q - ya) mod q ⟹ [y + q - x = y + q - ya] (mod q)" using cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*) by blast moreover have "[y + q - x = y + q - ya] (mod q) ⟹ [q - x = q - ya] (mod q)" using x (*‹x < q›*) ya (*‹ya < q›*) cong_add_lcancel_nat (*‹[(?a::nat) + (?x::nat) = ?a + (?y::nat)] (mod ?n::nat) = [?x = ?y] (mod ?n)›*) by fastforce moreover have "[y + q - x = y + q - ya] (mod q) ⟹ [q + x = q + ya] (mod q)" by (metis add_diff_inverse_nat (*‹¬ ?m < ?n ⟹ ?n + (?m - ?n) = ?m›*) calculation( (*‹[y + q - x = y + q - ya] (mod q) ⟹ [q - x = q - ya] (mod q)›*) 2) cong_add_lcancel_nat (*‹[?a + ?x = ?a + ?y] (mod ?n) = [?x = ?y] (mod ?n)›*) cong_add_rcancel_nat (*‹[?x + ?a = ?y + ?a] (mod ?n) = [?x = ?y] (mod ?n)›*) cong_sym (*‹[?b = ?c] (mod ?a) ⟹ [?c = ?b] (mod ?a)›*) less_imp_le_nat (*‹?m < ?n ⟹ ?m ≤ ?n›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) x (*‹x < q›*) ya (*‹ya < q›*)) ultimately show "?thesis" (*goal: ‹x mod q = ya mod q›*) by (simp add: cong_def (*‹[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)›*) map (*‹(y + q - x) mod q = (y + q - ya) mod q›*)) qed moreover have "x mod q = ya mod q ⟹ x = ya" by (simp add: x (*‹(x::nat) < (q::nat)›*) ya (*‹(ya::nat) < (q::nat)›*)) ultimately show "?thesis" (*goal: ‹(x::nat) = (ya::nat)›*) by (simp add: map (*‹(y + q - x) mod q = (y + q - ya) mod q›*)) qed lemma inj_on_minus: "inj_on (λ(b :: nat). (y + (q - b)) mod q ) {..<q}" by (auto simp add: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*) inj_minus (*‹⟦?x < ?q; ?ya < ?q; (?y + ?q - ?x) mod ?q = (?y + ?q - ?ya) mod ?q⟧ ⟹ ?x = ?ya›*)) lemma surj_on_minus: assumes inj: "inj_on (λ(b :: nat). (y + (q - b)) mod q ) {..<q}" shows "(λ(b :: nat). (y + (q - b)) mod q) ` {..< q} = {..< q}" apply (rule endo_inj_surj (*‹⟦finite ?A; ?f ` ?A ⊆ ?A; inj_on ?f ?A⟧ ⟹ ?f ` ?A = ?A›*)) (*goal: ‹(λb. (y + (q - b)) mod q) ` {..<q} = {..<q}›*) using inj (*‹inj_on (λb. (y + (q - b)) mod q) {..<q}›*) apply - (*goals: 1. ‹inj_on (λb. (y + (q - b)) mod q) {..<q} ⟹ finite {..<q}› 2. ‹inj_on (λb. (y + (q - b)) mod q) {..<q} ⟹ (λb. (y + (q - b)) mod q) ` {..<q} ⊆ {..<q}› 3. ‹inj_on (λb. (y + (q - b)) mod q) {..<q} ⟹ inj_on (λb. (y + (q - b)) mod q) {..<q}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma samp_uni_minus_one_time_pad: shows "map_spmf(λ b. (y + (q - b)) mod q) (sample_uniform q) = (sample_uniform q)" using inj_on_minus (*‹inj_on (λb::nat. ((?y::nat) + ((?q::nat) - b)) mod ?q) {..<?q}›*) surj_on_minus (*‹inj_on (λb::nat. ((?y::nat) + ((?q::nat) - b)) mod ?q) {..<?q} ⟹ (λb::nat. (?y + (?q - b)) mod ?q) ` {..<?q} = {..<?q}›*) one_time_pad (*‹⟦inj_on (?f::nat ⇒ nat) {..<?q::nat}; ?f ` {..<?q} = {..<?q}⟧ ⟹ map_spmf ?f (sample_uniform ?q) = sample_uniform ?q›*) by simp lemma not_coin_flip: "map_spmf (λ a. ¬ a) coin_spmf = coin_spmf" proof (-) (*goal: ‹map_spmf Not coin_spmf = coin_spmf›*) have "inj_on Not {True, False}" by simp also (*calculation: ‹inj_on Not {True, False}›*) have "Not ` {True, False} = {True, False}" by auto ultimately show "?thesis" (*goal: ‹map_spmf Not coin_spmf = coin_spmf›*) using one_time_pad (*‹⟦inj_on ?f {..<?q}; ?f ` {..<?q} = {..<?q}⟧ ⟹ map_spmf ?f (sample_uniform ?q) = sample_uniform ?q›*) by (simp add: UNIV_bool (*‹UNIV = {False, True}›*)) qed lemma xor_uni_samp: "map_spmf(λ b. y ⊕ b) (coin_spmf) = map_spmf(λ b. b) (coin_spmf)" (is "?lhs = ?rhs") proof (-) (*goal: ‹map_spmf ((⊕) (y::bool)) coin_spmf = map_spmf (λb::bool. b) coin_spmf›*) have rhs: "?rhs = spmf_of_set {True, False}" by (simp add: UNIV_bool (*‹UNIV = {False, True}›*) insert_commute (*‹insert ?x (insert ?y ?A) = insert ?y (insert ?x ?A)›*)) also (*calculation: ‹map_spmf (λb. b) coin_spmf = spmf_of_set {True, False}›*) have "map_spmf(λ b. y ⊕ b) (spmf_of_set {True, False}) = spmf_of_set((λ b. y ⊕ b) ` {True, False})" by (simp add: xor_def (*‹(?x::?'a::{uminus,inf,sup}) ⊕ (?y::?'a::{uminus,inf,sup}) = (?x ⊔ ?y) ⊓ - (?x ⊓ ?y)›*)) also (*calculation: ‹map_spmf ((⊕) y) (map_spmf (λb. b) coin_spmf) = spmf_of_set ((⊕) y ` {True, False})›*) have "(λ b. xor y b) ` {True, False} = {True, False}" using xor_def (*‹?x ⊕ ?y = (?x ⊔ ?y) ⊓ - (?x ⊓ ?y)›*) by auto finally (*calculation: ‹map_spmf ((⊕) y) (map_spmf (λb. b) coin_spmf) = spmf_of_set {True, False}›*) show "?thesis" (*goal: ‹map_spmf ((⊕) y) coin_spmf = map_spmf (λb. b) coin_spmf›*) using rhs (*‹map_spmf (λb. b) coin_spmf = spmf_of_set {True, False}›*) by simp qed end
{ "path": "afp-2025-02-12/thys/Multi_Party_Computation/Uniform_Sampling.thy", "repo": "afp-2025-02-12", "sha": "2f18d971b8fa576ac1645ace748f89ad13249bd8770142644a9c5bb1513d774c" }
(* Title: HOL/Examples/Drinker.thy Author: Makarius *) section ‹The Drinker's Principle› theory Drinker imports Main begin text ‹ Here is another example of classical reasoning: the Drinker's Principle says that for some person, if he is drunk, everybody else is drunk! We first prove a classical part of de-Morgan's law. › lemma de_Morgan: assumes "¬ (∀x. P x)" shows "∃x. ¬ P x" proof (rule classical (*‹(¬ ?P ⟹ ?P) ⟹ ?P›*)) (*goal: ‹∄x. ¬ P x ⟹ ∃x. ¬ P x›*) assume "∄x. ¬ P x" (*‹∄x::'a. ¬ (P::'a ⇒ bool) x›*) have "∀x. P x" proof (standard) (*goal: ‹⋀x. P x›*) fix x show "P x" proof (rule classical (*‹(¬ ?P ⟹ ?P) ⟹ ?P›*)) (*goal: ‹¬ P x ⟹ P x›*) assume "¬ P x" (*‹¬ (P::'a ⇒ bool) (x::'a)›*) then have "∃x. ¬ P x" apply - (*goal: ‹∃x. ¬ P x›*) by standard with ‹∄x. ¬ P x› (*‹∄x. ¬ P x›*) show "?thesis" (*goal: ‹(P::'a ⇒ bool) (x::'a)›*) by contradiction qed qed with ‹¬ (∀x. P x)› (*‹¬ (∀x::'a::type. (P::'a::type ⇒ bool) x)›*) show "?thesis" (*goal: ‹∃x::'a. ¬ (P::'a ⇒ bool) x›*) by contradiction qed theorem Drinker's_Principle: "∃x. drunk x ⟶ (∀x. drunk x)" proof (cases) (*goals: 1. ‹?P::bool ⟹ ∃x::'a. (drunk::'a ⇒ bool) x ⟶ (∀x::'a. drunk x)› 2. ‹¬ (?P::bool) ⟹ ∃x::'a. (drunk::'a ⇒ bool) x ⟶ (∀x::'a. drunk x)›*) assume "∀x. drunk x" (*‹∀x::'a. (drunk::'a ⇒ bool) x›*) then have "drunk a ⟶ (∀x. drunk x)" for a by standard then show "?thesis" (*goal: ‹∃x. drunk x ⟶ (∀x. drunk x)›*) apply - (*goal: ‹∃x. drunk x ⟶ (∀x. drunk x)›*) by standard next (*goal: ‹¬ (∀x. drunk x) ⟹ ∃x. drunk x ⟶ (∀x. drunk x)›*) assume "¬ (∀x. drunk x)" (*‹¬ (∀x::'a. (drunk::'a ⇒ bool) x)›*) then have "∃x. ¬ drunk x" by (rule de_Morgan (*‹¬ (∀x::?'a. (?P::?'a ⇒ bool) x) ⟹ ∃x::?'a. ¬ ?P x›*)) then obtain a where "¬ drunk a" (*goal: ‹(⋀a. ¬ drunk a ⟹ thesis) ⟹ thesis›*) by standard have "drunk a ⟶ (∀x. drunk x)" proof (standard) (*goal: ‹drunk a ⟹ ∀x. drunk x›*) assume "drunk a" (*‹(drunk::'a ⇒ bool) (a::'a)›*) with ‹¬ drunk a› (*‹¬ (drunk::'a ⇒ bool) (a::'a)›*) show "∀x. drunk x" by contradiction qed then show "?thesis" (*goal: ‹∃x. drunk x ⟶ (∀x. drunk x)›*) apply - (*goal: ‹∃x. drunk x ⟶ (∀x. drunk x)›*) by standard qed end
{ "path": "Isabelle2024/src/HOL/Examples/Drinker.thy", "repo": "Isabelle2024", "sha": "f0582d2e662b204a35e5a2c08ac48bdb0811d3fc7ba0b366af76e921094e8865" }
(* Title: Smooth_Vector_Fields Author: Richard Schmoetten <richard.schmoetten@ed.ac.uk>, 2024 Maintainer: Richard Schmoetten <richard.schmoetten@ed.ac.uk> *) section ‹Smooth vector fields› theory Smooth_Vector_Fields imports More_Manifolds begin text ‹Type synonyms for use later: these already follow our later split between defining ``charts'' for the tangent bundle as a product, and talking about vector fields as maps $p \mapsto v \in T_pM$ as well as sections of the tangent bundle $M \to TM$.› type_synonym 'a tangent_bundle = "'a × (('a⇒real)⇒real)" type_synonym 'a vector_field = "'a ⇒ (('a⇒real)⇒real)" subsection ‹(Smooth) vector fields on an (entire) manifold.› text ‹ Since we only get an isomorphism between tangent vectors and directional derivatives in the smooth case of \<^term>‹k = ∞›, we create a locale for infinitely smooth manifolds. › locale smooth_manifold = c_manifold charts ∞ for charts context c_manifold begin subsubsection ‹Charts for the tangent bundle› definition in_TM :: "'a ⇒ (('a⇒real)⇒real) ⇒ bool" where "in_TM p v ≡ p∈carrier ∧ v ∈ tangent_space p" abbreviation "TM ≡ {(p,v). in_TM p v}" lemma in_TM_E [elim]: assumes "in_TM p v" shows "v ∈ tangent_space p" "p∈carrier" using assms (*‹in_TM p v›*) unfolding in_TM_def (*goals: 1. ‹v ∈ tangent_space p› 2. ‹p ∈ carrier›*) apply - (*goals: 1. ‹p ∈ carrier ∧ v ∈ tangent_space p ⟹ v ∈ tangent_space p› 2. ‹p ∈ carrier ∧ v ∈ tangent_space p ⟹ p ∈ carrier› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma TM_PairE [elim]: assumes "(p,v) ∈ TM" shows "v ∈ tangent_space p" "p∈carrier" using assms (*‹(p::'a, v::('a ⇒ real) ⇒ real) ∈ TM›*) unfolding in_TM_def (*goals: 1. ‹v ∈ tangent_space p› 2. ‹p ∈ carrier›*) apply - (*goals: 1. ‹(p::'a, v::('a ⇒ real) ⇒ real) ∈ {(p::'a, v::('a ⇒ real) ⇒ real). p ∈ carrier ∧ v ∈ tangent_space p} ⟹ v ∈ tangent_space p› 2. ‹(p::'a, v::('a ⇒ real) ⇒ real) ∈ {(p::'a, v::('a ⇒ real) ⇒ real). p ∈ carrier ∧ v ∈ tangent_space p} ⟹ p ∈ carrier› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma TM_E [elim]: assumes "x ∈ TM" shows "snd x ∈ tangent_space (fst x)" "fst x ∈ carrier" using assms (*‹x ∈ TM›*) apply - (*goals: 1. ‹x ∈ TM ⟹ snd x ∈ tangent_space (fst x)› 2. ‹x ∈ TM ⟹ fst x ∈ carrier› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹We can construct a chart for \<^term>‹tangent_space p› given a chart around \<^term>‹p›. Notice the appearance of \<^term>‹charts› in the definition, which specifies that we're charting the set \<^term>‹tangent_space p›, \emph{not} \<^term>‹c_manifold.tangent_space (charts_submanifold c) ∞ p›.› definition apply_chart_TM :: "('a,'b)chart ⇒ 'a tangent_bundle ⇒ 'b × 'b" where "apply_chart_TM c ≡ λ(p,v). (c p , c_manifold_point.tangent_chart_fun charts ∞ c p v)" definition inv_chart_TM :: "('a,'b)chart ⇒ ('b × 'b) ⇒ 'a × (('a ⇒ real) ⇒ real)" where "inv_chart_TM c ≡ λ((p::'b),(v::'b)). (inv_chart c p , c_manifold_point.coordinate_vector charts ∞ c (inv_chart c p) v)" definition domain_TM :: "('a,'b) chart ⇒ ('a × (('a ⇒ real) ⇒ real)) set" where "domain_TM c ≡ {(p, v). p ∈ domain c ∧ v ∈ tangent_space p}" definition codomain_TM :: "('a,'b) chart ⇒ ('b×'b) set" where "codomain_TM c ≡ {(p, v). p ∈ codomain c}" definition "restrict_chart_TM S c ≡ apply_chart_TM (restrict_chart S c)" definition "restrict_domain_TM S c ≡ domain_TM (restrict_chart S c)" definition "restrict_codomain_TM S c ≡ codomain_TM (restrict_chart S c)" definition "restrict_inv_chart_TM S c ≡ inv_chart_TM (restrict_chart S c)" subsubsection ‹Proofs about \<^term>‹apply_chart_TM› that mimic the properties of \<^typ>‹('a,'b)chart›.› lemma domain_TM: assumes "c ∈ atlas" shows "domain_TM c ⊆ TM" unfolding domain_TM_def in_TM_def (*goal: ‹{(p, v). p ∈ domain c ∧ v ∈ tangent_space p} ⊆ {(p, v). p ∈ carrier ∧ v ∈ tangent_space p}›*) using assms (*‹c ∈ atlas›*) by auto lemma codomain_TM_alt: "codomain_TM c = codomain c × (UNIV :: 'b set)" unfolding codomain_TM_def (*goal: ‹{(p, v). p ∈ codomain c} = codomain c × UNIV›*) by auto lemma open_codomain_TM: assumes "c ∈ atlas" shows "open (codomain_TM c)" using codomain_TM_alt (*‹codomain_TM ?c = codomain ?c × UNIV›*) open_Times[OF open_codomain open_UNIV] (*‹open (codomain ?c2 × UNIV)›*) by auto end context smooth_manifold begin lemma apply_chart_TM_inverse [simp]: assumes c: "c ∈ atlas" shows "⋀p v. (p,v) ∈ domain_TM c ⟹ inv_chart_TM c (apply_chart_TM c (p,v)) = (p,v)" and "⋀x u. (x,u) ∈ codomain_TM c ⟹ apply_chart_TM c (inv_chart_TM c (x,u)) = (x,u)" proof (-) (*goals: 1. ‹⋀(p::'a::{second_countable_topology,t2_space}) v::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real. (p, v) ∈ domain_TM (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ⟹ inv_chart_TM c (apply_chart_TM c (p, v)) = (p, v)› 2. ‹⋀(x::'b::euclidean_space) u::'b::euclidean_space. (x, u) ∈ codomain_TM (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ⟹ apply_chart_TM c (inv_chart_TM c (x, u)) = (x, u)›*) fix p and v assume "(p,v) ∈ domain_TM c" (*‹(p::'a, v::('a ⇒ real) ⇒ real) ∈ domain_TM (c::('a, 'b) chart)›*) then have asm: "c ∈ atlas" "p ∈ domain c" "v ∈ tangent_space p" using c (*‹c ∈ atlas›*) apply - (*goals: 1. ‹⟦(p::'a, v::('a ⇒ real) ⇒ real) ∈ domain_TM (c::('a, 'b) chart); c ∈ atlas⟧ ⟹ c ∈ atlas› 2. ‹⟦(p::'a, v::('a ⇒ real) ⇒ real) ∈ domain_TM (c::('a, 'b) chart); c ∈ atlas⟧ ⟹ p ∈ domain c› 3. ‹⟦(p::'a, v::('a ⇒ real) ⇒ real) ∈ domain_TM (c::('a, 'b) chart); c ∈ atlas⟧ ⟹ v ∈ tangent_space p› discuss goal 1*) apply ((auto simp add: domain_TM_def (*‹domain_TM ?c ≡ {(p, v). p ∈ domain ?c ∧ v ∈ tangent_space p}›*))[1]) (*discuss goal 2*) apply ((auto simp add: domain_TM_def (*‹domain_TM ?c ≡ {(p, v). p ∈ domain ?c ∧ v ∈ tangent_space p}›*))[1]) (*discuss goal 3*) apply ((auto simp add: domain_TM_def (*‹domain_TM ?c ≡ {(p, v). p ∈ domain ?c ∧ v ∈ tangent_space p}›*))[1]) (*proven 3 subgoals*) . interpret p: c_manifold_point charts "∞" c p using c_manifold_point[OF asm ( 1 , 2 )] (*‹c_manifold_point charts ∞ c p›*) by simp have "v ∈ p.T⇩pM" using asm(3) (*‹v ∈ p.T⇩pM›*) by simp from p.coordinate_vector_inverse(1)[OF _ this] (*‹∞ = ∞ ⟹ v = p.coordinate_vector (∑i∈Basis. p.component_function v i *⇩R i)›*) show "inv_chart_TM c (apply_chart_TM c (p,v)) = (p,v)" by (simp add: inv_chart_TM_def (*‹inv_chart_TM ?c ≡ λ(p, v). (inv_chart ?c p, c_manifold_point.coordinate_vector charts ∞ ?c (inv_chart ?c p) v)›*) apply_chart_TM_def (*‹apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*) p.tangent_chart_fun_def (*‹p.tangent_chart_fun ?v ≡ ∑i∈Basis. p.component_function ?v i *⇩R i›*)) next (*goal: ‹⋀x u. (x, u) ∈ codomain_TM c ⟹ apply_chart_TM c (inv_chart_TM c (x, u)) = (x, u)›*) fix x and u assume "(x,u) ∈ codomain_TM c" (*‹(x::'b, u::'b) ∈ codomain_TM (c::('a, 'b) chart)›*) then have asm: "c ∈ atlas" "x ∈ codomain c" using c (*‹c ∈ atlas›*) apply - (*goals: 1. ‹⟦(x::'b, u::'b) ∈ codomain_TM (c::('a, 'b) chart); c ∈ atlas⟧ ⟹ c ∈ atlas› 2. ‹⟦(x::'b, u::'b) ∈ codomain_TM (c::('a, 'b) chart); c ∈ atlas⟧ ⟹ x ∈ codomain c› discuss goal 1*) apply ((auto simp add: codomain_TM_def (*‹codomain_TM ?c ≡ {(p, v). p ∈ codomain ?c}›*))[1]) (*discuss goal 2*) apply ((auto simp add: codomain_TM_def (*‹codomain_TM ?c ≡ {(p, v). p ∈ codomain ?c}›*))[1]) (*proven 2 subgoals*) . interpret x: c_manifold_point charts "∞" c "inv_chart c x" using c_manifold_point[OF asm ( 1 )] (*‹?p ∈ domain c ⟹ c_manifold_point charts ∞ c ?p›*) by (simp add: asm( (*‹(x::'b) ∈ codomain (c::('a, 'b) chart)›*) 2)) from x.coordinate_vector_inverse(2) (*‹∞ = ∞ ⟹ (?x::'b) = (∑i::'b∈Basis. x.component_function (x.coordinate_vector ?x) i *⇩R i)›*) show "apply_chart_TM c (inv_chart_TM c (x,u)) = (x,u)" by (simp add: inv_chart_TM_def (*‹inv_chart_TM ?c ≡ λ(p, v). (inv_chart ?c p, c_manifold_point.coordinate_vector charts ∞ ?c (inv_chart ?c p) v)›*) apply_chart_TM_def (*‹apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*) x.tangent_chart_fun_def (*‹x.tangent_chart_fun ?v ≡ ∑i∈Basis. x.component_function ?v i *⇩R i›*) asm( (*‹x ∈ codomain c›*) 2)) qed lemma image_domain_TM_eq: assumes "c ∈ atlas" shows "apply_chart_TM c ` domain_TM c = codomain_TM c" proof (-) (*goal: ‹apply_chart_TM c ` domain_TM c = codomain_TM c›*) { fix x :: "'b × 'b" assume x: "x ∈ codomain c × UNIV" (*‹(x::'b × 'b) ∈ codomain (c::('a, 'b) chart) × UNIV›*) obtain y₁ and y₂ where y: "y₁ = inv_chart c (fst x)" "y₂ = c_manifold_point.coordinate_vector charts ∞ c y₁ (snd x)" (*goal: ‹(⋀y₁ y₂. ⟦y₁ = inv_chart c (fst x); y₂ = c_manifold_point.coordinate_vector charts ∞ c y₁ (snd x)⟧ ⟹ thesis) ⟹ thesis›*) by simp have "y₁ ∈ domain c" using y(1) (*‹y₁ = inv_chart c (fst x)›*) x (*‹x ∈ codomain c × UNIV›*) by auto then interpret y₁: c_manifold_point charts "∞" c "y₁" by (simp add: assms( (*‹c ∈ atlas›*) 1) c_manifold_point (*‹⟦?c ∈ atlas; ?p ∈ domain ?c⟧ ⟹ c_manifold_point charts ∞ ?c ?p›*)) have "y₂ ∈ tangent_space y₁" using y(2) (*‹(y₂::('a ⇒ real) ⇒ real) = y₁.coordinate_vector (snd (x::'b × 'b))›*) x (*‹x ∈ codomain c × UNIV›*) assms (*‹c ∈ atlas›*) "y₁.coordinate_vector_surj" (*‹∞ = ∞ ⟹ range y₁.coordinate_vector = y₁.T⇩pM›*) by blast then have "(y₁,y₂) ∈ {(p, v). p ∈ domain c ∧ v ∈ tangent_space p}" using ‹y₁ ∈ domain c› (*‹y₁ ∈ domain c›*) by simp moreover have "fst x = c y₁" "snd x = c_manifold_point.tangent_chart_fun charts ∞ c y₁ y₂" using y (*‹y₁ = inv_chart c (fst x)› ‹y₂ = y₁.coordinate_vector (snd x)›*) x (*‹x ∈ codomain c × UNIV›*) assms (*‹c ∈ atlas›*) "y₁.tangent_chart_fun_inverse"(2) (*‹∞ = ∞ ⟹ ?x = y₁.tangent_chart_fun (y₁.coordinate_vector ?x)›*) apply - (*goals: 1. ‹⟦y₁ = inv_chart c (fst x); y₂ = y₁.coordinate_vector (snd x); x ∈ codomain c × UNIV; c ∈ atlas; ⋀x. ∞ = ∞ ⟹ x = y₁.tangent_chart_fun (y₁.coordinate_vector x)⟧ ⟹ fst x = apply_chart c y₁› 2. ‹⟦y₁ = inv_chart c (fst x); y₂ = y₁.coordinate_vector (snd x); x ∈ codomain c × UNIV; c ∈ atlas; ⋀x. ∞ = ∞ ⟹ x = y₁.tangent_chart_fun (y₁.coordinate_vector x)⟧ ⟹ snd x = y₁.tangent_chart_fun y₂› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately have "x ∈ (λ(p, v). (c p, c_manifold_point.tangent_chart_fun charts ∞ c p v)) ` {(p, v). p ∈ domain c ∧ v ∈ tangent_space p}" by (metis (no_types, lifting) pair_imageI (*‹(?a::?'a, ?b::?'b) ∈ (?A::(?'a × ?'b) set) ⟹ (?f::?'a ⇒ ?'b ⇒ ?'c) ?a ?b ∈ (λ(a::?'a, b::?'b). ?f a b) ` ?A›*) prod.collapse (*‹(fst (?prod::?'a × ?'b), snd ?prod) = ?prod›*)) } thus "?thesis" (*goal: ‹apply_chart_TM c ` domain_TM c = codomain_TM c›*) by (auto simp: apply_chart_TM_def (*‹apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*) domain_TM_def (*‹domain_TM ?c ≡ {(p, v). p ∈ domain ?c ∧ v ∈ tangent_space p}›*) codomain_TM_alt (*‹codomain_TM ?c = codomain ?c × UNIV›*)) qed lemma inv_image_codomain_TM_eq: assumes "c ∈ atlas" shows "inv_chart_TM c ` codomain_TM c = domain_TM c" apply (subst image_domain_TM_eq[OF assms, symmetric] (*‹codomain_TM c = apply_chart_TM c ` domain_TM c›*)) (*goal: ‹inv_chart_TM c ` codomain_TM c = domain_TM c›*) using apply_chart_TM_inverse(1)[OF assms] (*‹(?p, ?v) ∈ domain_TM c ⟹ inv_chart_TM c (apply_chart_TM c (?p, ?v)) = (?p, ?v)›*) by force lemma (in c_manifold) restrict_domain_TM_intersection: shows "restrict_domain_TM (domain c1 ∩ domain c2) c1 = domain_TM c1 ∩ domain_TM c2" unfolding restrict_domain_TM_def (*goal: ‹domain_TM (restrict_chart (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1) = domain_TM c1 ∩ domain_TM c2›*) by (auto simp: domain_TM_def (*‹domain_TM ?c ≡ {(p, v). p ∈ domain ?c ∧ v ∈ tangent_space p}›*) open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*)) lemma (in c_manifold) restrict_domain_TM_intersection': shows "restrict_domain_TM (domain c1 ∩ domain c2) c2 = domain_TM c1 ∩ domain_TM c2" unfolding restrict_domain_TM_def (*goal: ‹domain_TM (restrict_chart (domain c1 ∩ domain c2) c2) = domain_TM c1 ∩ domain_TM c2›*) by (auto simp: domain_TM_def (*‹domain_TM ?c ≡ {(p, v). p ∈ domain ?c ∧ v ∈ tangent_space p}›*) open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*)) lemma (in c_manifold) restrict_domain_TM: assumes "open S" "S ⊆ domain c" shows "restrict_domain_TM S c = {(p, v). p ∈ S ∧ v ∈ tangent_space p}" unfolding restrict_domain_TM_def domain_TM_def (*goal: ‹{(p, v). p ∈ domain (restrict_chart S c) ∧ v ∈ tangent_space p} = {(p, v). p ∈ S ∧ v ∈ tangent_space p}›*) using domain_restrict_chart (*‹open ?S ⟹ domain (restrict_chart ?S ?c) = domain ?c ∩ ?S›*) assms (*‹open (S::'a set)› ‹S ⊆ domain c›*) by auto lemma image_restrict_domain_TM_eq: assumes "c ∈ atlas" shows "restrict_chart_TM S c ` restrict_domain_TM S c = restrict_codomain_TM S c" unfolding restrict_chart_TM_def restrict_domain_TM_def restrict_codomain_TM_def (*goal: ‹apply_chart_TM (restrict_chart S c) ` domain_TM (restrict_chart S c) = codomain_TM (restrict_chart S c)›*) using image_domain_TM_eq (*‹?c ∈ atlas ⟹ apply_chart_TM ?c ` domain_TM ?c = codomain_TM ?c›*) assms (*‹c ∈ atlas›*) restrict_chart_in_atlas (*‹(?c::('a, 'b) chart) ∈ atlas ⟹ restrict_chart (?S::'a set) ?c ∈ atlas›*) by blast lemma inv_image_restrict_codomain_TM_eq: assumes "c ∈ atlas" shows "restrict_inv_chart_TM S c ` restrict_codomain_TM S c = restrict_domain_TM S c" by (metis (no_types, lifting) inv_image_codomain_TM_eq (*‹?c ∈ atlas ⟹ inv_chart_TM ?c ` codomain_TM ?c = domain_TM ?c›*) assms (*‹c ∈ atlas›*) restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) restrict_codomain_TM_def (*‹restrict_codomain_TM ?S ?c ≡ codomain_TM (restrict_chart ?S ?c)›*) restrict_domain_TM_def (*‹restrict_domain_TM ?S ?c ≡ domain_TM (restrict_chart ?S ?c)›*) restrict_inv_chart_TM_def (*‹restrict_inv_chart_TM ?S ?c ≡ inv_chart_TM (restrict_chart ?S ?c)›*)) lemma codomain_restrict_chart_TM[simp]: assumes "c ∈ atlas" "open S" shows "restrict_codomain_TM S c = codomain_TM c ∩ inv_chart_TM c -` {(p, v). p ∈ S ∧ v ∈ tangent_space p}" proof (-) (*goal: ‹restrict_codomain_TM S c = codomain_TM c ∩ inv_chart_TM c -` {(p, v). p ∈ S ∧ v ∈ tangent_space p}›*) { fix a and b and p and v assume asm: "a ∈ codomain c" "inv_chart_TM c (a, b) = (p, v)" (*‹(a::'b) ∈ codomain (c::('a, 'b) chart)› ‹inv_chart_TM (c::('a, 'b) chart) (a::'b, b::'b) = (p::'a, v::('a ⇒ real) ⇒ real)›*) interpret p: c_manifold_point charts "∞" c "inv_chart c a" using asm(1) (*‹a ∈ codomain c›*) assms (*‹c ∈ atlas› ‹open S›*) c_manifold_point[OF assms ( 1 ), of "inv_chart c a" for a] (*‹inv_chart c ?aa5 ∈ domain c ⟹ c_manifold_point charts ∞ c (inv_chart c ?aa5)›*) by blast have "p.coordinate_vector b ∈ tangent_space (inv_chart c a)" using bij_betwE[OF p.coordinate_vector_bij] (*‹∞ = ∞ ⟹ ∀a∈UNIV. p.coordinate_vector a ∈ p.T⇩pM›*) by simp then have "inv_chart c a ∈ S ⟹ v ∈ tangent_space p" and "inv_chart c a ∈ S ⟹ p ∈ S" and "⟦p∈S; v ∈ tangent_space p⟧ ⟹ inv_chart c a ∈ S" subgoal for using inv_chart_TM_def (*‹inv_chart_TM (?c::('a, 'b) chart) ≡ λ(p::'b, v::'b). (inv_chart ?c p, c_manifold_point.coordinate_vector (charts::('a, 'b) chart set) ∞ ?c (inv_chart ?c p) v)›*) inv_image_codomain_TM_eq[OF assms ( 1 )] (*‹inv_chart_TM (c::('a, 'b) chart) ` p.sub_ψ.sub.codomain_TM c = domain_TM c›*) asm (*‹a ∈ codomain c› ‹inv_chart_TM (c::('a, 'b) chart) (a::'b, b::'b) = (p::'a, v::('a ⇒ real) ⇒ real)›*) by auto subgoal for using asm(2) (*‹inv_chart_TM c (a, b) = (p, v)›*) by (auto simp add: assms( (*‹open S›*) 2) inv_chart_TM_def (*‹inv_chart_TM ?c ≡ λ(p, v). (inv_chart ?c p, c_manifold_point.coordinate_vector charts ∞ ?c (inv_chart ?c p) v)›*)) subgoal for using asm(2) (*‹inv_chart_TM c (a, b) = (p, v)›*) c_manifold.inv_chart_TM_def[OF c_manifold_axioms] (*‹inv_chart_TM ?c ≡ λ(p, v). (inv_chart ?c p, c_manifold_point.coordinate_vector charts ∞ ?c (inv_chart ?c p) v)›*) by simp . } thus "?thesis" (*goal: ‹restrict_codomain_TM S c = codomain_TM c ∩ inv_chart_TM c -` {(p, v). p ∈ S ∧ v ∈ tangent_space p}›*) by (auto simp add: restrict_codomain_TM_def (*‹restrict_codomain_TM ?S ?c ≡ codomain_TM (restrict_chart ?S ?c)›*) codomain_TM_def (*‹codomain_TM ?c ≡ {(p, v). p ∈ codomain ?c}›*) assms( (*‹open S›*) 2)) qed lemma (in c_manifold) image_subset_TM_eq [simp]: assumes "S ⊆ domain_TM c" shows "apply_chart_TM c ` S ⊆ codomain_TM c" using assms (*‹S ⊆ domain_TM c›*) unfolding apply_chart_TM_def codomain_TM_def domain_TM_def (*goal: ‹(λ(p, v). (apply_chart c p, c_manifold_point.tangent_chart_fun charts ∞ c p v)) ` S ⊆ {(p, v). p ∈ codomain c}›*) by auto lemma (in c_manifold) image_subset_restrict_TM_eq [simp]: assumes "T ⊆ restrict_domain_TM S c" shows "restrict_chart_TM S c ` T ⊆ restrict_codomain_TM S c" using assms (*‹T ⊆ restrict_domain_TM S c›*) unfolding restrict_chart_TM_def restrict_codomain_TM_def restrict_domain_TM_def (*goal: ‹apply_chart_TM (restrict_chart S c) ` T ⊆ codomain_TM (restrict_chart S c)›*) by auto lemma restrict_chart_domain_Int: assumes "c1 ∈ atlas" shows "apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2) = restrict_chart_TM (domain c1 ∩ domain c2) c1 ` (restrict_domain_TM (domain c1 ∩ domain c2) c1)" (is ‹?TM_dom_Int = ?restr_TM_dom›) proof (intro subset_antisym (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); ?B ⊆ ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹apply_chart_TM (c1::('a, 'b) chart) ` (domain_TM c1 ∩ domain_TM (c2::('a, 'b) chart)) ⊆ restrict_chart_TM (domain c1 ∩ domain c2) c1 ` restrict_domain_TM (domain c1 ∩ domain c2) c1› 2. ‹restrict_chart_TM (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1 ` restrict_domain_TM (domain c1 ∩ domain c2) c1 ⊆ apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2)›*) have dom_eq: "domain (restrict_chart (domain c1 ∩ domain c2) c1) = domain c1 ∩ domain c2" using domain_restrict_chart[OF open_domain] (*‹domain (restrict_chart (domain ?c1) ?c) = domain ?c ∩ domain ?c1›*) by (metis inf.left_idem (*‹inf ?a (inf ?a ?b) = inf ?a ?b›*)) { fix x assume "x ∈ (domain_TM c1 ∩ domain_TM c2)" (*‹(x::'a × (('a ⇒ real) ⇒ real)) ∈ domain_TM (c1::('a, 'b) chart) ∩ domain_TM (c2::('a, 'b) chart)›*) then obtain p and v where x: "x = (p,v)" "p ∈ domain c1" "p ∈ domain c2" "v ∈ tangent_space p" (*goal: ‹(⋀p v. ⟦x = (p, v); p ∈ domain c1; p ∈ domain c2; v ∈ tangent_space p⟧ ⟹ thesis) ⟹ thesis›*) unfolding domain_TM_def (*goal: ‹(⋀(p::'a::{second_countable_topology,t2_space}) v::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real. ⟦(x::'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) = (p, v); p ∈ domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart); p ∈ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart); v ∈ tangent_space p⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast interpret p1: c_manifold_point charts "∞" c1 p using c_manifold_point[OF assms ( 1 ) x ( 2 )] (*‹c_manifold_point charts ∞ c1 p›*) by simp interpret p2: c_manifold_point charts "∞" "restrict_chart (domain c1 ∩ domain c2) c1" p using c_manifold_point[OF assms ( 1 ) x ( 2 )] (*‹c_manifold_point charts ∞ c1 p›*) restrict_chart_in_atlas[OF assms ( 1 )] (*‹restrict_chart ?S c1 ∈ atlas›*) domain_restrict_chart[OF open_domain] (*‹domain (restrict_chart (domain ?c1) ?c) = domain ?c ∩ domain ?c1›*) by (metis IntI (*‹⟦(?c::?'a::type) ∈ (?A::?'a::type set); ?c ∈ (?B::?'a::type set)⟧ ⟹ ?c ∈ ?A ∩ ?B›*) c_manifold_point (*‹⟦(?c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∈ atlas; (?p::'a::{second_countable_topology,t2_space}) ∈ domain ?c⟧ ⟹ c_manifold_point (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ ?c ?p›*) p1.p (*‹(p::'a::{second_countable_topology,t2_space}) ∈ domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)›*) x( (*‹(p::'a::{second_countable_topology,t2_space}) ∈ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)›*) 3)) have [simp]: "p2.sub_ψ.sub.restrict_codomain_TM (domain c1 ∩ domain c2) c1 = {(p, v). p ∈ codomain (restrict_chart (domain c1 ∩ domain c2) c1)}" unfolding "p2.sub_ψ.sub.restrict_codomain_TM_def" "p2.sub_ψ.sub.codomain_TM_def" (*goal: ‹{(p, v). p ∈ codomain (restrict_chart (domain c1 ∩ domain c2) c1)} = {(p, v). p ∈ codomain (restrict_chart (domain c1 ∩ domain c2) c1)}›*) by simp have "apply_chart_TM c1 x ∈ ?restr_TM_dom" apply (simp add: x( (*‹x = (p, v)›*) 1) image_restrict_domain_TM_eq[OF assms(1)] (*‹restrict_chart_TM ?S c1 ` restrict_domain_TM ?S c1 = p2.sub_ψ.sub.restrict_codomain_TM ?S c1›*)) (*goal: ‹apply_chart_TM c1 x ∈ restrict_chart_TM (domain c1 ∩ domain c2) c1 ` restrict_domain_TM (domain c1 ∩ domain c2) c1›*) unfolding apply_chart_TM_def (*goal: ‹case case (p, v) of (p, v) ⇒ (apply_chart c1 p, c_manifold_point.tangent_chart_fun charts ∞ c1 p v) of (p, v) ⇒ p ∈ codomain (restrict_chart (domain c1 ∩ domain c2) c1)›*) using "p2.ψp_in" (*‹apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p2.diffeo_ψ.dest.carrier›*) by (auto simp: p1.euclidean_coordinates_eq_iff (*‹∞ = ∞ ⟹ ((∑i∈Basis. ?f i *⇩R p1.coordinate_vector i) = (∑i∈Basis. ?g i *⇩R p1.coordinate_vector i)) = (∀i∈Basis. ?f i = ?g i)›*)) } thus "?TM_dom_Int ⊆ ?restr_TM_dom" by auto { fix x assume "x ∈ restrict_domain_TM (domain c1 ∩ domain c2) c1" (*‹(x::'a × (('a ⇒ real) ⇒ real)) ∈ restrict_domain_TM (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1›*) then obtain p and v where x: "x = (p,v)" "p ∈ domain c1" "p ∈ domain c2" "v ∈ tangent_space p" (*goal: ‹(⋀p v. ⟦x = (p, v); p ∈ domain c1; p ∈ domain c2; v ∈ tangent_space p⟧ ⟹ thesis) ⟹ thesis›*) unfolding restrict_domain_TM_def domain_TM_def (*goal: ‹(⋀p v. ⟦x = (p, v); p ∈ domain c1; p ∈ domain c2; v ∈ tangent_space p⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: dom_eq (*‹domain (restrict_chart (domain c1 ∩ domain c2) c1) = domain c1 ∩ domain c2›*)) interpret p1: c_manifold_point charts "∞" c1 p using c_manifold_point[OF assms ( 1 ) x ( 2 )] (*‹c_manifold_point charts ∞ c1 p›*) by simp interpret p2: c_manifold_point charts "∞" "restrict_chart (domain c1 ∩ domain c2) c1" p using c_manifold_point[OF assms ( 1 ) x ( 2 )] (*‹c_manifold_point charts ∞ c1 p›*) restrict_chart_in_atlas[OF assms ( 1 )] (*‹restrict_chart ?S c1 ∈ atlas›*) domain_restrict_chart[OF open_domain] (*‹domain (restrict_chart (domain ?c1) ?c) = domain ?c ∩ domain ?c1›*) by (metis IntI (*‹⟦(?c::?'a) ∈ (?A::?'a set); ?c ∈ (?B::?'a set)⟧ ⟹ ?c ∈ ?A ∩ ?B›*) c_manifold_point (*‹⟦(?c::('a, 'b) chart) ∈ atlas; (?p::'a) ∈ domain ?c⟧ ⟹ c_manifold_point (charts::('a, 'b) chart set) ∞ ?c ?p›*) p1.p (*‹(p::'a) ∈ domain (c1::('a, 'b) chart)›*) x( (*‹(p::'a) ∈ domain (c2::('a, 'b) chart)›*) 3)) have "restrict_chart_TM (domain c1 ∩ domain c2) c1 x ∈ ?TM_dom_Int" proof (-) (*goal: ‹restrict_chart_TM (domain c1 ∩ domain c2) c1 x ∈ apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2)›*) have "apply_chart c1 p ∈ apply_chart c1 ` (domain c1 ∩ domain c2)" using p1.p (*‹p ∈ domain c1›*) x(3) (*‹p ∈ domain c2›*) by blast moreover have "p2.tangent_chart_fun v ∈ c_manifold_point.tangent_chart_fun charts ∞ c1 p ` {v. v∈tangent_space p}" using p1.coordinate_vector_surj (*‹∞ = ∞ ⟹ range p1.coordinate_vector = p2.T⇩pM›*) p1.tangent_chart_fun_inverse(2) (*‹∞ = ∞ ⟹ (?x::'b) = p1.tangent_chart_fun (p1.coordinate_vector ?x)›*) by fastforce ultimately show "?thesis" (*goal: ‹restrict_chart_TM (domain c1 ∩ domain c2) c1 x ∈ apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2)›*) apply (simp add: apply_chart_TM_def (*‹apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*)) (*goal: ‹restrict_chart_TM (domain c1 ∩ domain c2) c1 x ∈ apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2)›*) apply (simp add: x( (*‹x = (p, v)›*) 1) restrict_chart_TM_def (*‹restrict_chart_TM ?S ?c ≡ apply_chart_TM (restrict_chart ?S ?c)›*)) (*goal: ‹⟦apply_chart (c1::('a, 'b) chart) (p::'a) ∈ apply_chart c1 ` (domain c1 ∩ domain (c2::('a, 'b) chart)); p2.tangent_chart_fun (v::('a ⇒ real) ⇒ real) ∈ p1.tangent_chart_fun ` p2.T⇩pM⟧ ⟹ restrict_chart_TM (domain c1 ∩ domain c2) c1 (x::'a × (('a ⇒ real) ⇒ real)) ∈ (λx::'a × (('a ⇒ real) ⇒ real). case x of (p::'a, v::('a ⇒ real) ⇒ real) ⇒ (apply_chart c1 p, c_manifold_point.tangent_chart_fun (charts::('a, 'b) chart set) ∞ c1 p v)) ` (domain_TM c1 ∩ domain_TM c2)›*) apply (simp add: apply_chart_TM_def (*‹apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*) apply_chart_restrict_chart[of "domain c1 ∩ domain c2" c1] (*‹apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) = apply_chart c1›*)) (*goal: ‹⟦apply_chart c1 p ∈ apply_chart c1 ` (domain c1 ∩ domain c2); p2.tangent_chart_fun v ∈ p1.tangent_chart_fun ` p2.T⇩pM⟧ ⟹ apply_chart_TM (restrict_chart (domain c1 ∩ domain c2) c1) (p, v) ∈ (λx. case x of (p, v) ⇒ (apply_chart c1 p, c_manifold_point.tangent_chart_fun charts ∞ c1 p v)) ` (domain_TM c1 ∩ domain_TM c2)›*) unfolding domain_TM_def (*goal: ‹⟦apply_chart c1 p ∈ apply_chart c1 ` (domain c1 ∩ domain c2); p2.tangent_chart_fun v ∈ p1.tangent_chart_fun ` p2.T⇩pM⟧ ⟹ (apply_chart c1 p, p2.tangent_chart_fun v) ∈ (λx. case x of (p, v) ⇒ (apply_chart c1 p, c_manifold_point.tangent_chart_fun charts ∞ c1 p v)) ` ({(p, v). p ∈ domain c1 ∧ v ∈ tangent_space p} ∩ {(p, v). p ∈ domain c2 ∧ v ∈ tangent_space p})›*) by force qed } thus "?restr_TM_dom ⊆ ?TM_dom_Int" by blast qed lemma open_intersection_TM: assumes "c1 ∈ atlas" shows "open (apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2))" using restrict_chart_domain_Int (*‹?c1.0 ∈ atlas ⟹ apply_chart_TM ?c1.0 ` (domain_TM ?c1.0 ∩ domain_TM ?c2.0) = restrict_chart_TM (domain ?c1.0 ∩ domain ?c2.0) ?c1.0 ` restrict_domain_TM (domain ?c1.0 ∩ domain ?c2.0) ?c1.0›*) image_restrict_domain_TM_eq (*‹?c ∈ atlas ⟹ restrict_chart_TM ?S ?c ` restrict_domain_TM ?S ?c = restrict_codomain_TM ?S ?c›*) restrict_chart_in_atlas (*‹(?c::('a, 'b) chart) ∈ atlas ⟹ restrict_chart (?S::'a set) ?c ∈ atlas›*) assms (*‹c1 ∈ atlas›*) by (auto simp: restrict_codomain_TM_def (*‹restrict_codomain_TM ?S ?c ≡ codomain_TM (restrict_chart ?S ?c)›*) open_codomain_TM (*‹?c ∈ atlas ⟹ open (codomain_TM ?c)›*)) lemma apply_restrict_chart_TM: assumes c: "c ∈ atlas" and S: "open S" "S ⊆ domain c" "x ∈ restrict_domain_TM S c" shows "apply_chart_TM c x = restrict_chart_TM S c x" proof (-) (*goal: ‹apply_chart_TM (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) (x::'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) = restrict_chart_TM (S::'a::{second_countable_topology,t2_space} set) c x›*) { fix p and v assume x: "x = (p,v)" "p ∈ S" "v ∈ tangent_space p" (*‹(x::'a × (('a ⇒ real) ⇒ real)) = (p::'a, v::('a ⇒ real) ⇒ real)› ‹(p::'a) ∈ (S::'a set)› ‹(v::('a ⇒ real) ⇒ real) ∈ tangent_space (p::'a)›*) interpret p1: c_manifold_point charts "∞" c p using c_manifold_point[OF c] (*‹?p ∈ domain c ⟹ c_manifold_point charts ∞ c ?p›*) x(2) (*‹p ∈ S›*) S(2) (*‹S ⊆ domain c›*) by blast interpret p2: c_manifold_point charts "∞" "restrict_chart S c" p apply (rule c_manifold.c_manifold_point (*‹⟦c_manifold ?charts ?k; ?c ∈ c_manifold.atlas ?charts ?k; ?p ∈ domain ?c⟧ ⟹ c_manifold_point ?charts ?k ?c ?p›*), unfold_locales) (*goal: ‹c_manifold_point charts ∞ (restrict_chart S c) p›*) using S(1) (*‹open S›*) x(2) (*‹p ∈ S›*) apply - (*goals: 1. ‹⟦open S; p ∈ S⟧ ⟹ restrict_chart S c ∈ atlas› 2. ‹⟦open S; p ∈ S⟧ ⟹ p ∈ domain (restrict_chart S c)› discuss goal 1*) apply ((auto simp add: restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*))[1]) (*discuss goal 2*) apply ((auto simp add: restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*))[1]) (*proven 2 subgoals*) . have "T⇩pM_eq": "p2.T⇩pM = tangent_space p" by simp have "p1.tangent_chart_fun v = p2.tangent_chart_fun v" unfolding p1.tangent_chart_fun_def p2.tangent_chart_fun_def (*goal: ‹(∑i∈Basis. p1.component_function v i *⇩R i) = (∑i∈Basis. p2.component_function v i *⇩R i)›*) using p1.component_function_restrict_chart[OF x ( 2 ) S ( 1 )] (*‹⟦?v ∈ p2.T⇩pM; ?i ∈ Basis; ∞ = ∞⟧ ⟹ p1.component_function ?v ?i = p2.component_function ?v ?i›*) "T⇩pM_eq" (*‹p2.T⇩pM = p2.T⇩pM›*) x(3) (*‹v ∈ p2.T⇩pM›*) by simp } thus "?thesis" (*goal: ‹apply_chart_TM c x = restrict_chart_TM S c x›*) using S(3) (*‹x ∈ restrict_domain_TM S c›*) restrict_domain_TM[OF S ( 1 , 2 )] (*‹restrict_domain_TM S c = {(p, v). p ∈ S ∧ v ∈ tangent_space p}›*) unfolding restrict_chart_TM_def apply_chart_TM_def (*goal: ‹(case x::'a × (('a ⇒ real) ⇒ real) of (p::'a, v::('a ⇒ real) ⇒ real) ⇒ (apply_chart (c::('a, 'b) chart) p, c_manifold_point.tangent_chart_fun (charts::('a, 'b) chart set) ∞ c p v)) = (case x of (p::'a, v::('a ⇒ real) ⇒ real) ⇒ (apply_chart (restrict_chart (S::'a set) c) p, c_manifold_point.tangent_chart_fun charts ∞ (restrict_chart S c) p v))›*) by auto qed lemma inverse_restrict_chart_TM: assumes c: "c ∈ atlas" and S: "open S" "S ⊆ domain c" "x ∈ restrict_codomain_TM S c" shows "inv_chart_TM c x = restrict_inv_chart_TM S c x" proof (-) (*goal: ‹inv_chart_TM (c::('a, 'b) chart) (x::'b × 'b) = restrict_inv_chart_TM (S::'a set) c x›*) { fix p and v assume x: "x = (p,v)" "p ∈ c`S" (*‹(x::'b × 'b) = (p::'b, v::'b)› ‹(p::'b) ∈ apply_chart (c::('a, 'b) chart) ` (S::'a set)›*) interpret p1: c_manifold_point charts "∞" c "inv_chart c p" using c_manifold_point[OF c] (*‹?p ∈ domain c ⟹ c_manifold_point charts ∞ c ?p›*) x(2) (*‹p ∈ apply_chart c ` S›*) S(2) (*‹S ⊆ domain c›*) by blast have pS: "inv_chart c p ∈ S" using restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) x(2) (*‹p ∈ apply_chart c ` S›*) S(2) (*‹S ⊆ domain c›*) image_domain_eq (*‹apply_chart ?c ` domain ?c = codomain ?c›*) by auto interpret p2: c_manifold_point charts "∞" "restrict_chart S c" "inv_chart c p" apply (rule c_manifold.c_manifold_point (*‹⟦c_manifold ?charts ?k; ?c ∈ c_manifold.atlas ?charts ?k; ?p ∈ domain ?c⟧ ⟹ c_manifold_point ?charts ?k ?c ?p›*), unfold_locales) (*goal: ‹c_manifold_point charts ∞ (restrict_chart S c) (inv_chart c p)›*) using pS (*‹inv_chart c p ∈ S›*) restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) S(1) (*‹open (S::'a set)›*) apply - (*goals: 1. ‹⟦inv_chart c p ∈ S; ⋀c S. c ∈ atlas ⟹ restrict_chart S c ∈ atlas; open S⟧ ⟹ restrict_chart S c ∈ atlas› 2. ‹⟦inv_chart c p ∈ S; ⋀c S. c ∈ atlas ⟹ restrict_chart S c ∈ atlas; open S⟧ ⟹ inv_chart c p ∈ domain (restrict_chart S c)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "p1.coordinate_vector v = p2.coordinate_vector v" using p1.coordinate_vector_restrict_chart[OF pS S ( 1 )] (*‹∞ = ∞ ⟹ p1.coordinate_vector ?i = p2.coordinate_vector ?i›*) using p1.coordinate_vector_def (*‹p1.coordinate_vector = p1.sub_ψ.inclusion.push_forward ∘ p1.differential_inv_chart ∘ p1.dRestr ∘ directional_derivative ∞ (apply_chart c (inv_chart c p))›*) p2.coordinate_vector_def (*‹p2.coordinate_vector = p2.sub_ψ.inclusion.push_forward ∘ p2.differential_inv_chart ∘ p2.dRestr ∘ directional_derivative ∞ (apply_chart (restrict_chart S c) (inv_chart c p))›*) by presburger } thus "?thesis" (*goal: ‹inv_chart_TM c x = restrict_inv_chart_TM S c x›*) using S(3) (*‹(x::'b × 'b) ∈ restrict_codomain_TM (S::'a set) (c::('a, 'b) chart)›*) inv_chart_TM_def (*‹inv_chart_TM ?c ≡ λ(p, v). (inv_chart ?c p, c_manifold_point.coordinate_vector charts ∞ ?c (inv_chart ?c p) v)›*) apply_chart_TM_def (*‹apply_chart_TM (?c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ≡ λ(p::'a::{second_countable_topology,t2_space}, v::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real). (apply_chart ?c p, c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ ?c p v)›*) apply (simp add: codomain_restrict_chart_TM[OF c S(1)] (*‹restrict_codomain_TM S c = codomain_TM c ∩ inv_chart_TM c -` {(p, v). p ∈ S ∧ v ∈ tangent_space p}›*) restrict_inv_chart_TM_def (*‹restrict_inv_chart_TM ?S ?c ≡ inv_chart_TM (restrict_chart ?S ?c)›*)) (*goal: ‹inv_chart_TM c x = restrict_inv_chart_TM S c x›*) using apply_chart_TM_inverse(2)[OF c] (*‹(?x, ?u) ∈ codomain_TM c ⟹ apply_chart_TM c (inv_chart_TM c (?x, ?u)) = (?x, ?u)›*) surj_pair (*‹∃x y. ?p = (x, y)›*) by (smt (verit) case_prod_conv (*‹(case (?a::?'b, ?b::?'c) of (c::?'b, d::?'c) ⇒ (?f::?'b ⇒ ?'c ⇒ ?'a) c d) = ?f ?a ?b›*) image_eqI (*‹⟦(?b::?'a) = (?f::?'b ⇒ ?'a) (?x::?'b); ?x ∈ (?A::?'b set)⟧ ⟹ ?b ∈ ?f ` ?A›*)) qed lemma (in c_manifold_point) dκ_inv_directional_derivative_eq: assumes "k = ∞" shows "dκ¯ (directional_derivative k (ψ p) x) = restrict0 (diffeo_ψ.dest.diff_fun_space) (λf. frechet_derivative f (at (ψ p)) x)" proof (-) (*goal: ‹dκ¯ (directional_derivative (k::enat) (apply_chart (ψ::('a, 'b) chart) (p::'a)) (x::'b)) = restrict0 diffeo_ψ.dest.diff_fun_space (λf::'b ⇒ real. frechet_derivative f (at (apply_chart ψ p)) x)›*) let ?is_ext = "λf f'. f∈diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))" let ?extend = "λf. SOME f'. ?is_ext f f'" obtain extend where extend_def: "extend ≡ ?extend" (*goal: ‹(⋀extend. extend ≡ λf. SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')) ⟹ thesis) ⟹ thesis›*) by blast have extend: "?is_ext f (extend f)" "?is_ext f (?extend f)" if "f∈diffeo_ψ.dest.diff_fun_space" for f proof (-) (*goals: 1. ‹f ∈ diffeo_ψ.dest.diff_fun_space ∧ extend f ∈ manifold_eucl.dest.diff_fun_space ∧ extend f ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend f x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f)))› 2. ‹f ∈ diffeo_ψ.dest.diff_fun_space ∧ (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) ∈ manifold_eucl.dest.diff_fun_space ∧ (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')))) ∧ (∀v∈T⇩ψ⇩pψU. v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) = dκ v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')))) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')))))›*) show "?is_ext f (?extend f)" apply (rule someI_ex[of "λf'. ?is_ext f f'"] (*‹∃x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x)) ⟹ f ∈ diffeo_ψ.dest.diff_fun_space ∧ (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x))) ∈ manifold_eucl.dest.diff_fun_space ∧ (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x))) ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x))) x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x)))) ∧ (∀v∈T⇩ψ⇩pψU. v (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x))) = dκ v (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x)))) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (SOME x. f ∈ diffeo_ψ.dest.diff_fun_space ∧ x ∈ manifold_eucl.dest.diff_fun_space ∧ x ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀xa∈closure N. x xa = f xa) ∧ (∀v∈T⇩ψ⇩pψU. v f = v x) ∧ (∀v∈T⇩ψ⇩pψU. v x = dκ v x) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v x)))))›*)) (*goal: ‹f ∈ diffeo_ψ.dest.diff_fun_space ∧ (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) ∈ manifold_eucl.dest.diff_fun_space ∧ (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')))) ∧ (∀v∈T⇩ψ⇩pψU. v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f'))) = dκ v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')))) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (SOME f'. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v f')))))›*) by (smt (verit) that (*‹f ∈ diffeo_ψ.dest.diff_fun_space›*) extension_lemma_localE2 (*‹⟦?f ∈ diffeo_ψ.dest.diff_fun_space; ⋀N f'. ⟦apply_chart ψ p ∈ N; open N; compact (closure N); closure N ⊆ diffeo_ψ.dest.carrier; f' ∈ manifold_eucl.dest.diff_fun_space; f' ∈ diffeo_ψ.dest.diff_fun_space; ⋀x. x ∈ closure N ⟹ f' x = ?f x; ⋀v. v ∈ T⇩ψ⇩pψU ⟹ v ?f = v f'; ⋀v. v ∈ T⇩ψ⇩pψU ⟹ v f' = dκ v f'; ⋀v. v ∈ T⇩ψ⇩pE ⟹ dκ¯ v ?f = v f'⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) thus "?is_ext f (extend f)" unfolding extend_def (*goal: ‹(f::'b ⇒ real) ∈ diffeo_ψ.dest.diff_fun_space ∧ (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart (ψ::('a, 'b) chart) (p::'a) ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f'))) ∈ manifold_eucl.dest.diff_fun_space ∧ (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f'))) ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f'))) x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f')))) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f'))) = dκ v (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f')))) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v (SOME f'::'b ⇒ real. f ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. f' x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v f')))))›*) by blast qed have "extend ` diffeo_ψ.dest.diff_fun_space ⊆ manifold_eucl.dest.diff_fun_space" using extend (*‹?f4 ∈ diffeo_ψ.dest.diff_fun_space ⟹ ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ extend ?f4 ∈ manifold_eucl.dest.diff_fun_space ∧ extend ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend ?f4 x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v (extend ?f4)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend ?f4) = dκ v (extend ?f4)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v (extend ?f4)))› ‹?f4 ∈ diffeo_ψ.dest.diff_fun_space ⟹ ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f'))) ∈ manifold_eucl.dest.diff_fun_space ∧ (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f'))) ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f'))) x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f')))) ∧ (∀v∈T⇩ψ⇩pψU. v (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f'))) = dκ v (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f')))) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v (SOME f'. ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ f' ∈ manifold_eucl.dest.diff_fun_space ∧ f' ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. f' x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v f') ∧ (∀v∈T⇩ψ⇩pψU. v f' = dκ v f') ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v f')))))›*) by blast have "dκ¯ (directional_derivative k (ψ p) x) f = restrict0 (diffeo_ψ.dest.diff_fun_space) (λf. frechet_derivative f (at (ψ p)) x) f" for f proof (cases "f ∈ diffeo_ψ.dest.diff_fun_space") (*goals: 1. ‹f ∈ diffeo_ψ.dest.diff_fun_space ⟹ dκ¯ (directional_derivative k (apply_chart ψ p) x) f = restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) f› 2. ‹f ∉ diffeo_ψ.dest.diff_fun_space ⟹ dκ¯ (directional_derivative k (apply_chart ψ p) x) f = restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) f›*) case True (*‹f ∈ diffeo_ψ.dest.diff_fun_space›*) have frechet_derivative_extend: "frechet_derivative f (at (ψ p)) x = frechet_derivative (extend f) (at (ψ p)) x" if f: "f∈diffeo_ψ.dest.diff_fun_space" for f proof (-) (*goal: ‹frechet_derivative f (at (apply_chart ψ p)) x = frechet_derivative (extend f) (at (apply_chart ψ p)) x›*) obtain N where N: "ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. (extend f) x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f))" (*goal: ‹(⋀N::'b set. apply_chart (ψ::('a, 'b) chart) (p::'a) ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. (extend::('b ⇒ real) ⇒ 'b ⇒ real) (f::'b ⇒ real) x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v (extend f)) ⟹ thesis::bool) ⟹ thesis›*) using extend(1)[OF f] (*‹f ∈ diffeo_ψ.dest.diff_fun_space ∧ extend f ∈ manifold_eucl.dest.diff_fun_space ∧ extend f ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend f x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f)))›*) by presburger show "?thesis" (*goal: ‹frechet_derivative (f::'b ⇒ real) (at (apply_chart (ψ::('a, 'b) chart) (p::'a))) (x::'b) = frechet_derivative ((extend::('b ⇒ real) ⇒ 'b ⇒ real) f) (at (apply_chart ψ p)) x›*) apply (rule frechet_derivative_transform_within_open_ext[where f=f and g="extend f" and X=N for f] (*‹⟦?fb6 differentiable at ?xa; open N; ?xa ∈ N; ⋀x. x ∈ N ⟹ ?fb6 x = extend ?fb6 x⟧ ⟹ frechet_derivative ?fb6 (at ?xa) ?x = frechet_derivative (extend ?fb6) (at ?xa) ?x›*)) (*goal: ‹frechet_derivative f (at (apply_chart ψ p)) x = frechet_derivative (extend f) (at (apply_chart ψ p)) x›*) using sub_eucl.submanifold_atlasI (*‹(?c::('b::euclidean_space, 'b::euclidean_space) chart) ∈ manifold_eucl.dest.atlas ⟹ restrict_chart (codomain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) ?c ∈ diffeo_ψ.dest.atlas›*) sub_eucl.sub_diff_fun_differentiable_at[OF diffeo_ψ.dest.diff_fun_spaceD [ OF f ], of "restrict_chart (codomain ψ) chart_eucl"] (*‹⟦restrict_chart (codomain ψ) chart_eucl ∈ diffeo_ψ.dest.atlas; ?p ∈ domain (restrict_chart (codomain ψ) chart_eucl); 0 < k⟧ ⟹ f ∘ inv_chart (restrict_chart (codomain ψ) chart_eucl) differentiable at (apply_chart (restrict_chart (codomain ψ) chart_eucl) ?p)›*) apply (simp add: id_def[symmetric] (*‹(λx. x) = id›*) assms (*‹k = ∞›*)) (*top goal: ‹f differentiable at (apply_chart ψ p)› and 3 goals remain*) using N (*‹apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend f x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f))›*) apply - (*goals: 1. ‹apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend f x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f)) ⟹ open N› 2. ‹apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend f x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f)) ⟹ apply_chart ψ p ∈ N› 3. ‹⋀x. ⟦x ∈ N; apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend f x = f x) ∧ (∀v∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v f = v (extend f))⟧ ⟹ f x = extend f x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . qed have "dκ¯ (directional_derivative k (ψ p) x) f = (directional_derivative k (ψ p) x) (extend f)" using assms (*‹k = ∞›*) "eq_T⇩ψ⇩pE_range_inclusion" (*‹T⇩ψ⇩pE = dκ ` T⇩ψ⇩pψU›*) "eq_T⇩ψ⇩pE_range_inclusion2" (*‹k = ∞ ⟹ range (directional_derivative k (apply_chart ψ p)) = dκ ` T⇩ψ⇩pψU›*) extend(1) (*‹?f4 ∈ diffeo_ψ.dest.diff_fun_space ⟹ ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ extend ?f4 ∈ manifold_eucl.dest.diff_fun_space ∧ extend ?f4 ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N. apply_chart ψ p ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x∈closure N. extend ?f4 x = ?f4 x) ∧ (∀v∈T⇩ψ⇩pψU. v ?f4 = v (extend ?f4)) ∧ (∀v∈T⇩ψ⇩pψU. v (extend ?f4) = dκ v (extend ?f4)) ∧ (∀v∈T⇩ψ⇩pE. dκ¯ v ?f4 = v (extend ?f4)))›*) True (*‹(f::'b ⇒ real) ∈ diffeo_ψ.dest.diff_fun_space›*) by blast also (*calculation: ‹dκ¯ (directional_derivative (k::enat) (apply_chart (ψ::('a, 'b) chart) (p::'a)) (x::'b)) (f::'b ⇒ real) = directional_derivative k (apply_chart ψ p) x ((extend::('b ⇒ real) ⇒ 'b ⇒ real) f)›*) have "… = frechet_derivative (extend f) (at (ψ p)) x" unfolding directional_derivative_def (*goal: ‹restrict0 manifold_eucl.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) (extend f) = frechet_derivative (extend f) (at (apply_chart ψ p)) x›*) using extend(1)[OF True] (*‹(f::'b ⇒ real) ∈ diffeo_ψ.dest.diff_fun_space ∧ (extend::('b ⇒ real) ⇒ 'b ⇒ real) f ∈ manifold_eucl.dest.diff_fun_space ∧ extend f ∈ diffeo_ψ.dest.diff_fun_space ∧ (∃N::'b set. apply_chart (ψ::('a, 'b) chart) (p::'a) ∈ N ∧ open N ∧ closure N ⊆ diffeo_ψ.dest.carrier ∧ (∀x::'b∈closure N. extend f x = f x) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v f = v (extend f)) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pψU. v (extend f) = dκ v (extend f)) ∧ (∀v::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ v f = v (extend f)))›*) by simp finally (*calculation: ‹dκ¯ (directional_derivative k (apply_chart ψ p) x) f = frechet_derivative (extend f) (at (apply_chart ψ p)) x›*) show "?thesis" (*goal: ‹dκ¯ (directional_derivative k (apply_chart ψ p) x) f = restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) f›*) using True (*‹f ∈ diffeo_ψ.dest.diff_fun_space›*) frechet_derivative_extend (*‹?f4 ∈ diffeo_ψ.dest.diff_fun_space ⟹ frechet_derivative ?f4 (at (apply_chart ψ p)) x = frechet_derivative (extend ?f4) (at (apply_chart ψ p)) x›*) by simp next (*goal: ‹f ∉ diffeo_ψ.dest.diff_fun_space ⟹ dκ¯ (directional_derivative k (apply_chart ψ p) x) f = restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) f›*) case False (*‹f ∉ diffeo_ψ.dest.diff_fun_space›*) then show "?thesis" (*goal: ‹dκ¯ (directional_derivative (k::enat) (apply_chart (ψ::('a, 'b) chart) (p::'a)) (x::'b)) (f::'b ⇒ real) = restrict0 diffeo_ψ.dest.diff_fun_space (λf::'b ⇒ real. frechet_derivative f (at (apply_chart ψ p)) x) f›*) proof (-) (*goal: ‹f ∉ diffeo_ψ.dest.diff_fun_space ⟹ dκ¯ (directional_derivative k (apply_chart ψ p) x) f = restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) f›*) have RHS_0: "restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (ψ p)) x) f = 0" using restrict0_apply_out[OF False] (*‹restrict0 diffeo_ψ.dest.diff_fun_space ?f f = 0›*) by blast moreover have LHS_0: "dκ¯ (directional_derivative k (ψ p) x) f = 0" using bij_betwE[OF bij_betw_dκ_inv] (*‹∀a::('b ⇒ real) ⇒ real∈T⇩ψ⇩pE. dκ¯ a ∈ T⇩ψ⇩pψU›*) bij_betwE[OF bij_betw_directional_derivative [ OF assms ]] (*‹∀a∈UNIV. directional_derivative k (apply_chart ψ p) a ∈ T⇩ψ⇩pE›*) using "diffeo_ψ.dest.tangent_spaceD" (*‹(?X::('b ⇒ real) ⇒ real) ∈ diffeo_ψ.dest.tangent_space (?p::'b) ⟹ linear_on diffeo_ψ.dest.diff_fun_space UNIV (*⇩R) (*⇩R) ?X› ‹?X ∈ diffeo_ψ.dest.tangent_space ?p ⟹ extensional0 diffeo_ψ.dest.diff_fun_space ?X› ‹⟦?X ∈ diffeo_ψ.dest.tangent_space ?p; ?f ∈ diffeo_ψ.dest.diff_fun_space; ?g ∈ diffeo_ψ.dest.diff_fun_space⟧ ⟹ ?X (?f * ?g) = ?f ?p * ?X ?g + ?g ?p * ?X ?f›*) extensional0_outside[OF False] (*‹extensional0 diffeo_ψ.dest.diff_fun_space (?f::('b ⇒ real) ⇒ ?'b) ⟹ ?f (f::'b ⇒ real) = (0::?'b)›*) by blast ultimately show "?thesis" (*goal: ‹dκ¯ (directional_derivative k (apply_chart ψ p) x) f = restrict0 diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart ψ p)) x) f›*) by simp qed qed thus "?thesis" (*goal: ‹dκ¯ (directional_derivative (k::enat) (apply_chart (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) (p::'a::{second_countable_topology,t2_space})) (x::'b::euclidean_space)) = restrict0 diffeo_ψ.dest.diff_fun_space (λf::'b::euclidean_space ⇒ real. frechet_derivative f (at (apply_chart ψ p)) x)›*) by blast qed lemma smooth_on_compat_charts_TM: assumes "c1 ∈ atlas" "c2 ∈ atlas" shows "smooth_on (c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative ((λy. (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x))" (is ‹smooth_on ?D (λx. frechet_derivative ((λy. ?r2 y ∙ i) ∘ ?r1i) (at (fst x)) (snd x))›) proof (-) (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x))›*) let ?dom_Int = "domain c1 ∩ domain c2" have open_simps[simp]: "open ?dom_Int" "open ?D" (*goals: 1. ‹open (domain c1 ∩ domain c2)› 2. ‹open (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)› discuss goal 1*) apply ((auto simp: open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*) open_Times (*‹⟦open ?S; open ?T⟧ ⟹ open (?S × ?T)›*))[1]) (*discuss goal 2*) apply ((auto simp: open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*) open_Times (*‹⟦open ?S; open ?T⟧ ⟹ open (?S × ?T)›*))[1]) (*proven 2 subgoals*) . have smooth_on_1: "smooth_on (fst`?D) ((λy. ?r2 y ∙ i) ∘ ?r1i)" for i apply simp (*goal: ‹smooth_on (fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)) ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))›*) apply (rule smooth_on_cong'[of _ "c1 ` (domain c1 ∩ domain c2)"] (*‹⟦?k-smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2)) ?f; ?S = apply_chart c1 ` (domain c1 ∩ domain c2)⟧ ⟹ ?k-smooth_on ?S ?f›*)) (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2)) ((λy. apply_chart c2 y ∙ i) ∘ inv_chart c1)›*) apply (rule smooth_on_cong[of _ _ "(λy. c2 (inv_chart c1 y) ∙ i)"] (*‹⟦?k-smooth_on ?S (λy. apply_chart c2 (inv_chart c1 y) ∙ i); open ?S; ⋀x. x ∈ ?S ⟹ ?f x = apply_chart c2 (inv_chart c1 x) ∙ i⟧ ⟹ ?k-smooth_on ?S ?f›*)) (*top goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2)) ((λy. apply_chart c2 y ∙ i) ∘ inv_chart c1)› and 1 goal remains*) apply (rule smooth_on_inner[OF _ smooth_on_const[of _ _ i]] (*‹⟦(?k::enat)-smooth_on (?S::?'d set) (?f::?'d ⇒ 'b); open ?S⟧ ⟹ ?k-smooth_on ?S (λx::?'d. ?f x ∙ (i::'b))›*)) (*top goal: ‹smooth_on (apply_chart (c1::('a, 'b) chart) ` (domain c1 ∩ domain (c2::('a, 'b) chart))) (λy::'b. apply_chart c2 (inv_chart c1 y) ∙ (i::'b))› and 3 goals remain*) using atlas_is_atlas[unfolded smooth_compat_def o_def, OF assms ( 1 , 2 )] (*‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2)) (λx. apply_chart c2 (inv_chart c1 x)) ∧ smooth_on (apply_chart c2 ` (domain c1 ∩ domain c2)) (λx. apply_chart c1 (inv_chart c2 x))›*) apply ((auto)[4]) (*top goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2)) (λx. apply_chart c2 (inv_chart c1 x))› and 4 goals remain*) unfolding restrict_codomain_TM_def codomain_TM_alt (*goal: ‹apply_chart c1 ` (domain c1 ∩ domain c2) = apply_chart c1 ` (domain c1 ∩ domain c2)›*) using image_domain_eq (*‹apply_chart (?c::(?'a, ?'b) chart) ` domain ?c = codomain ?c›*) by fastforce have smooth_on_2: "smooth_on ?D (λx. frechet_derivative ((λy. (?r2 y) ∙ i) ∘ ?r1i) (at (fst x)) v)" for v and i apply (rule smooth_on_compose2[OF derivative_is_smooth, unfolded o_def, where S=UNIV and T="fst`?D"] (*‹⟦smooth_on (fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)) ?f1; smooth_on UNIV ?g; open ?U; open (fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)); ?g ` ?U ⊆ fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV); ?U ⊆ UNIV⟧ ⟹ smooth_on ?U (λx. frechet_derivative ?f1 (at (?g x)) ?v1)›*)) (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) v)›*) using smooth_on_fst (*‹⟦?k-smooth_on ?S ?f; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. fst (?f x))›*) smooth_on_1 (*‹smooth_on (fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)) ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ ?i3) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))›*) apply - (*goals: 1. ‹⟦⋀(k::enat) (S::?'a43::real_normed_vector set) f::?'a43::real_normed_vector ⇒ ?'b43::real_normed_vector × ?'c43::real_normed_vector. ⟦k-smooth_on S f; open S⟧ ⟹ k-smooth_on S (λx::?'a43::real_normed_vector. fst (f x)); ⋀i::'b::euclidean_space. smooth_on (fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))⟧ ⟹ smooth_on (fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ (i::'b::euclidean_space)) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))› 2. ‹⟦⋀(k::enat) (S::?'a36::real_normed_vector set) f::?'a36::real_normed_vector ⇒ ?'b36::real_normed_vector × ?'c36::real_normed_vector. ⟦k-smooth_on S f; open S⟧ ⟹ k-smooth_on S (λx::?'a36::real_normed_vector. fst (f x)); ⋀i::'b::euclidean_space. smooth_on (fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))⟧ ⟹ smooth_on UNIV fst› 3. ‹⟦⋀(k::enat) (S::?'a29::real_normed_vector set) f::?'a29::real_normed_vector ⇒ ?'b29::real_normed_vector × ?'c29::real_normed_vector. ⟦k-smooth_on S f; open S⟧ ⟹ k-smooth_on S (λx::?'a29::real_normed_vector. fst (f x)); ⋀i::'b::euclidean_space. smooth_on (fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))⟧ ⟹ open (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)› 4. ‹⟦⋀(k::enat) (S::?'a22::real_normed_vector set) f::?'a22::real_normed_vector ⇒ ?'b22::real_normed_vector × ?'c22::real_normed_vector. ⟦k-smooth_on S f; open S⟧ ⟹ k-smooth_on S (λx::?'a22::real_normed_vector. fst (f x)); ⋀i::'b::euclidean_space. smooth_on (fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))⟧ ⟹ open (fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV))› 5. ‹⟦⋀(k::enat) (S::?'a15::real_normed_vector set) f::?'a15::real_normed_vector ⇒ ?'b15::real_normed_vector × ?'c15::real_normed_vector. ⟦k-smooth_on S f; open S⟧ ⟹ k-smooth_on S (λx::?'a15::real_normed_vector. fst (f x)); ⋀i::'b::euclidean_space. smooth_on (fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))⟧ ⟹ fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) ⊆ fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)› 6. ‹⟦⋀(k::enat) (S::?'a8::real_normed_vector set) f::?'a8::real_normed_vector ⇒ ?'b8::real_normed_vector × ?'c8::real_normed_vector. ⟦k-smooth_on S f; open S⟧ ⟹ k-smooth_on S (λx::?'a8::real_normed_vector. fst (f x)); ⋀i::'b::euclidean_space. smooth_on (fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV)) ((λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))⟧ ⟹ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV ⊆ UNIV› discuss goal 1*) apply ((auto simp: open_image_fst (*‹open ?S ⟹ open (fst ` ?S)›*))[1]) (*discuss goal 2*) apply ((auto simp: open_image_fst (*‹open ?S ⟹ open (fst ` ?S)›*))[1]) (*discuss goal 3*) apply ((auto simp: open_image_fst (*‹open (?S::(?'a × ?'b) set) ⟹ open (fst ` ?S)›*))[1]) (*discuss goal 4*) apply ((auto simp: open_image_fst (*‹open ?S ⟹ open (fst ` ?S)›*))[1]) (*discuss goal 5*) apply ((auto simp: open_image_fst (*‹open ?S ⟹ open (fst ` ?S)›*))[1]) (*discuss goal 6*) apply ((auto simp: open_image_fst (*‹open ?S ⟹ open (fst ` ?S)›*))[1]) (*proven 6 subgoals*) . have r2_r1i_differentiable: "(λx. ?r2 (?r1i x) ∙ i) differentiable (at (fst p))" if "p ∈ ?D" for i :: 'b and p proof (-) (*goal: ‹(λx::'b. apply_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ (i::'b)) differentiable at (fst (p::'b × 'b))›*) have 1: "open (c1 ` (domain c1 ∩ domain c2))" and 2: "c1 (inv_chart c1 (fst p)) = fst p" and 3: "inv_chart c1 (fst p) ∈ ?dom_Int" using that (*‹p ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV›*) apply - (*goals: 1. ‹p ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV ⟹ open (apply_chart c1 ` (domain c1 ∩ domain c2))› 2. ‹p ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV ⟹ apply_chart c1 (inv_chart c1 (fst p)) = fst p› 3. ‹p ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV ⟹ inv_chart c1 (fst p) ∈ domain c1 ∩ domain c2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . show "?thesis" (*goal: ‹(λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) differentiable at (fst p)›*) using smooth_on_imp_differentiable_on[unfolded differentiable_on_def, OF smooth_on_1] (*‹(0::enat) < ∞ ⟹ ∀x::'b::euclidean_space∈fst ` (apply_chart (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain c1 ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) × UNIV). (λy::'a::{second_countable_topology,t2_space}. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ (?i4::'b::euclidean_space)) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) differentiable at x within fst ` (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)›*) apply (simp add: o_def (*‹(?f::?'b ⇒ ?'c) ∘ (?g::?'a ⇒ ?'b) = (λx::?'a. ?f (?g x))›*)) (*goal: ‹(λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) differentiable at (fst p)›*) by (metis at_within_open (*‹⟦?a ∈ ?S; open ?S⟧ ⟹ at ?a within ?S = at ?a›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) 1 (*‹open (apply_chart c1 ` (domain c1 ∩ domain c2))›*) 2 (*‹apply_chart c1 (inv_chart c1 (fst p)) = fst p›*) 3 (*‹inv_chart c1 (fst p) ∈ domain c1 ∩ domain c2›*)) qed show "?thesis" (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x))›*) unfolding o_def (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative (λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) (at (fst x)) (snd x))›*) apply (rule smooth_on_cong[OF _ _ frechet_derivative_componentwise[OF r2_r1i_differentiable]] (*‹⟦?k-smooth_on ?S (λx. ∑i∈Basis. ?v1 x ∙ i * frechet_derivative (λxa. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) xa) ∙ ?i5 x) (at (fst (?p5 x))) i); open ?S; ⋀x. x ∈ ?S ⟹ ?p5 x ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV⟧ ⟹ ?k-smooth_on ?S (λx. frechet_derivative (λxa. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) xa) ∙ ?i5 x) (at (fst (?p5 x))) (?v1 x))›*)) (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative (λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) (at (fst x)) (snd x))›*) apply (rule smooth_on_sum (*‹⟦⋀i. ⟦i ∈ ?F; finite ?F⟧ ⟹ ?n-smooth_on ?S (?f i); open ?S⟧ ⟹ ?n-smooth_on ?S (λx. ∑i∈?F. ?f i x)›*)) (*top goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. ∑ia∈Basis. snd x ∙ ia * frechet_derivative (λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) (at (fst x)) ia)› and 2 goals remain*) apply (rule smooth_on_times_fun[of ∞ ?D, unfolded times_fun_def] (*‹⟦smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) ?f; smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) ?g; open (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)⟧ ⟹ smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. ?f x * ?g x)›*)) (*top goal: ‹⋀ia. ⟦ia ∈ Basis; finite Basis⟧ ⟹ smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. snd x ∙ ia * frechet_derivative (λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) (at (fst x)) ia)› and 3 goals remain*) subgoal for by (auto intro!: smooth_on_inner (*‹⟦?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. ?f x ∙ ?g x)›*) smooth_on_snd (*‹⟦?k-smooth_on ?S ?f; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. snd (?f x))›*)) subgoal for using smooth_on_2[unfolded o_def] (*‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative (λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ ?i3) (at (fst x)) ?v3)›*) by simp (*goals: 1. ‹⋀i. ⟦i ∈ Basis; finite Basis⟧ ⟹ open (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)› 2. ‹open (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)› 3. ‹open (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV)› 4. ‹⋀x. x ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV ⟹ x ∈ apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . qed<close> lemma atlas_TM: assumes "c1 ∈ atlas" "c2 ∈ atlas" shows "smooth_on ((apply_chart_TM c1) ` (domain_TM c1 ∩ domain_TM c2)) ((apply_chart_TM c2) ∘ (inv_chart_TM c1))" (is ‹smooth_on (?c1 ` (?dom1 ∩ ?dom2)) ((?c2) ∘ (?i1))›) proof (-) (*goal: ‹smooth_on (apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2)) (apply_chart_TM c2 ∘ inv_chart_TM c1)›*) let ?dom_Int = "domain c1 ∩ domain c2" have dom_eq: "?dom1 ∩ ?dom2 = {(p,v). p ∈ domain c1 ∧ p ∈ domain c2 ∧ v ∈ tangent_space p}" unfolding domain_TM_def (*goal: ‹{(p, v). p ∈ domain c1 ∧ v ∈ tangent_space p} ∩ {(p, v). p ∈ domain c2 ∧ v ∈ tangent_space p} = {(p, v). p ∈ domain c1 ∧ p ∈ domain c2 ∧ v ∈ tangent_space p}›*) by auto have open_Int_dom[simp]: "open (domain c1 ∩ domain c2)" by blast have open_image_dom_TM[simp]: "open (apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2))" using assms (*‹c1 ∈ atlas› ‹c2 ∈ atlas›*) open_intersection_TM (*‹?c1.0 ∈ atlas ⟹ open (apply_chart_TM ?c1.0 ` (domain_TM ?c1.0 ∩ domain_TM ?c2.0))›*) by blast have inv_chart_x_in: "(inv_chart c1 x) ∈ domain c1 ∩ domain c2" if "x ∈ c1 ` (domain c1 ∩ domain c2)" for x using that (*‹x ∈ apply_chart c1 ` (domain c1 ∩ domain c2)›*) by force let ?snd_c2i1 = "λ(p, v). c_manifold_point.tangent_chart_fun charts ∞ c2 (inv_chart c1 p) (c_manifold_point.coordinate_vector charts ∞ c1 (inv_chart c1 p) v)" let ?R1i = "restrict_inv_chart_TM (domain c1 ∩ domain c2) c1" and ?R1 = "restrict_chart_TM (domain c1 ∩ domain c2) c1" and ?R2 = "restrict_chart_TM (domain c1 ∩ domain c2) c2" and ?r1 = "restrict_chart ?dom_Int c1" and ?r2 = "restrict_chart ?dom_Int c2" and ?r1i = "inv_chart (restrict_chart ?dom_Int c1)" and ?r2i = "inv_chart (restrict_chart ?dom_Int c2)" show "?thesis" (*goal: ‹smooth_on (apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM c2)) (apply_chart_TM c2 ∘ inv_chart_TM c1)›*) proof (subst restrict_chart_domain_Int[OF assms(1)] (*‹apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM ?c2.0) = restrict_chart_TM (domain c1 ∩ domain ?c2.0) c1 ` restrict_domain_TM (domain c1 ∩ domain ?c2.0) c1›*), subst image_restrict_domain_TM_eq[OF assms(1)] (*‹restrict_chart_TM ?S c1 ` restrict_domain_TM ?S c1 = restrict_codomain_TM ?S c1›*), rule smooth_on_cong (*‹⟦?k-smooth_on ?S ?g; open ?S; ⋀x. x ∈ ?S ⟹ ?f x = ?g x⟧ ⟹ ?k-smooth_on ?S ?f›*)) (*goals: 1. ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) ?g› 2. ‹open (restrict_codomain_TM (domain c1 ∩ domain c2) c1)› 3. ‹⋀x. x ∈ restrict_codomain_TM (domain c1 ∩ domain c2) c1 ⟹ (apply_chart_TM c2 ∘ inv_chart_TM c1) x = ?g x›*) fix x assume x: "x ∈ restrict_codomain_TM (domain c1 ∩ domain c2) c1" (*‹(x::'b × 'b) ∈ restrict_codomain_TM (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1›*) then have y: "(?R1i x) ∈ restrict_domain_TM (domain c1 ∩ domain c2) c2" using inv_image_restrict_codomain_TM_eq[OF assms ( 1 )] (*‹restrict_inv_chart_TM ?S c1 ` restrict_codomain_TM ?S c1 = restrict_domain_TM ?S c1›*) using restrict_domain_TM_intersection (*‹restrict_domain_TM (domain ?c1.0 ∩ domain ?c2.0) ?c1.0 = domain_TM ?c1.0 ∩ domain_TM ?c2.0›*) restrict_domain_TM_intersection' (*‹restrict_domain_TM (domain ?c1.0 ∩ domain ?c2.0) ?c2.0 = domain_TM ?c1.0 ∩ domain_TM ?c2.0›*) by blast show "(apply_chart_TM c2 ∘ inv_chart_TM c1) x = (?R2 ∘ ?R1i) x" using inverse_restrict_chart_TM (*‹⟦(?c::('a, 'b) chart) ∈ atlas; open (?S::'a set); ?S ⊆ domain ?c; (?x::'b × 'b) ∈ restrict_codomain_TM ?S ?c⟧ ⟹ inv_chart_TM ?c ?x = restrict_inv_chart_TM ?S ?c ?x›*) apply_restrict_chart_TM (*‹⟦?c ∈ atlas; open ?S; ?S ⊆ domain ?c; ?x ∈ restrict_domain_TM ?S ?c⟧ ⟹ apply_chart_TM ?c ?x = restrict_chart_TM ?S ?c ?x›*) open_Int_dom (*‹open (domain c1 ∩ domain c2)›*) x (*‹x ∈ restrict_codomain_TM (domain c1 ∩ domain c2) c1›*) y (*‹restrict_inv_chart_TM (domain c1 ∩ domain c2) c1 x ∈ restrict_domain_TM (domain c1 ∩ domain c2) c2›*) assms(1,2) (*‹(c1::('a, 'b) chart) ∈ atlas› ‹c2 ∈ atlas›*) by simp next (*goals: 1. ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1)› 2. ‹open (restrict_codomain_TM (domain c1 ∩ domain c2) c1)›*) show open_restrict_codomain[simp]: "open (restrict_codomain_TM (domain c1 ∩ domain c2) c1)" by (simp add: image_restrict_domain_TM_eq[OF assms(1), symmetric] (*‹restrict_codomain_TM ?S c1 = restrict_chart_TM ?S c1 ` restrict_domain_TM ?S c1›*) restrict_chart_domain_Int[OF assms(1), symmetric] (*‹restrict_chart_TM (domain c1 ∩ domain ?c2.0) c1 ` restrict_domain_TM (domain c1 ∩ domain ?c2.0) c1 = apply_chart_TM c1 ` (domain_TM c1 ∩ domain_TM ?c2.0)›*)) show "smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (?R2 ∘ ?R1i)" proof (rule smooth_on_Pair'[OF open_restrict_codomain] (*‹⟦(?k::enat)-smooth_on (restrict_codomain_TM (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1) (fst ∘ (?f::'b × 'b ⇒ ?'f × ?'g)); ?k-smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (snd ∘ ?f)⟧ ⟹ ?k-smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) ?f›*)) (*goals: 1. ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (fst ∘ (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1))› 2. ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (snd ∘ (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1))›*) have fst_eq: "fst ∘ (?R2 ∘ ?R1i) = ?r2 ∘ ?r1i ∘ fst" unfolding restrict_chart_TM_def restrict_inv_chart_TM_def apply_chart_TM_def inv_chart_TM_def (*goal: ‹fst ∘ ((λ(p, v). (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p, c_manifold_point.tangent_chart_fun charts ∞ (restrict_chart (domain c1 ∩ domain c2) c2) p v)) ∘ (λ(p, v). (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) p, c_manifold_point.coordinate_vector charts ∞ (restrict_chart (domain c1 ∩ domain c2) c1) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) v))) = apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) ∘ fst›*) by auto show "smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (fst ∘ (?R2 ∘ ?R1i))" apply (simp add: fst_eq (*‹fst ∘ (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1) = apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) ∘ fst›*)) (*goal: ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (fst ∘ (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1))›*) apply (rule smooth_on_compose[of _ "c1 ` (domain c1 ∩ domain c2)"] (*‹⟦?k-smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2)) ?f; ?k-smooth_on ?S ?g; open ?S; open (apply_chart c1 ` (domain c1 ∩ domain c2)); ?g ` ?S ⊆ apply_chart c1 ` (domain c1 ∩ domain c2)⟧ ⟹ ?k-smooth_on ?S (?f ∘ ?g)›*)) (*goal: ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (apply_chart c2 ∘ inv_chart c1 ∘ fst)›*) subgoal for using atlas_is_atlas (*‹⟦?a1.0 ∈ atlas; ?a2.0 ∈ atlas⟧ ⟹ ∞-smooth_compat ?a1.0 ?a2.0›*) assms (*‹(c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∈ atlas› ‹(c2::('a, 'b) chart) ∈ atlas›*) smooth_compat_D1 (*‹?k-smooth_compat ?c1.0 ?c2.0 ⟹ ?k-smooth_on (apply_chart ?c1.0 ` (domain ?c1.0 ∩ domain ?c2.0)) (apply_chart ?c2.0 ∘ inv_chart ?c1.0)›*) by blast subgoal for by (auto intro: smooth_on_fst (*‹⟦?k-smooth_on ?S ?f; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. fst (?f x))›*)) subgoal for by simp subgoal for by simp subgoal for unfolding restrict_codomain_TM_def codomain_TM_alt (*goal: ‹fst ` (codomain (restrict_chart (domain c1 ∩ domain c2) c1) × UNIV) ⊆ apply_chart c1 ` (domain c1 ∩ domain c2)›*) using image_domain_eq (*‹apply_chart ?c ` domain ?c = codomain ?c›*) by fastforce . let ?g = "λx. (∑i∈Basis. (frechet_derivative ((λy. (?r2 y) ∙ i) ∘ ?r1i) (at (fst x)) (snd x)) *⇩R i)" have local_simps: "?r2 ∘ ?r1i = (λx. ?r2 (?r1i x))" and [simp]: "domain c2 ∩ (domain c1 ∩ domain c2) = domain c1 ∩ domain c2" (*goals: 1. ‹apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) = (λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x))› 2. ‹domain c2 ∩ (domain c1 ∩ domain c2) = domain c1 ∩ domain c2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have r2_r1i_differentiable: "(λx. ?r2 (?r1i x) ∙ i) differentiable (at (?r1 p))" if "p ∈ ?dom_Int" for i :: 'b and p apply (rule differentiable_compose[of "λx. x ∙ i"] (*‹⟦(λx. x ∙ i) differentiable at (?g ?x); ?g differentiable at ?x within ?s⟧ ⟹ (λx. ?g x ∙ i) differentiable at ?x within ?s›*), simp) (*goal: ‹(λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)›*) apply (subst local_simps(1)[symmetric] (*‹(λx::'b. apply_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x)) = apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)›*)) (*goal: ‹(λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x)) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)›*) apply (rule c_manifold.diff_fun_differentiable_at[of "charts_submanifold ?dom_Int" ∞] (*‹⟦c_manifold (charts_submanifold (domain c1 ∩ domain c2)) ∞; diff_fun ∞ (charts_submanifold (domain c1 ∩ domain c2)) ?f; ?c ∈ c_manifold.atlas (charts_submanifold (domain c1 ∩ domain c2)) ∞; ?p ∈ domain ?c; 0 < ∞⟧ ⟹ ?f ∘ inv_chart ?c differentiable at (apply_chart ?c ?p)›*)) (*goal: ‹apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)›*) subgoal for using atlas_is_atlas (*‹⟦?a1.0 ∈ atlas; ?a2.0 ∈ atlas⟧ ⟹ ∞-smooth_compat ?a1.0 ?a2.0›*) charts_submanifold_def (*‹charts_submanifold ?S = restrict_chart ?S ` charts›*) in_charts_in_atlas (*‹?x ∈ charts ⟹ ?x ∈ atlas›*) restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) apply unfold_locales (*goal: ‹c_manifold (charts_submanifold (domain c1 ∩ domain c2)) ∞›*) by auto subgoal for unfolding diff_fun_def (*goal: ‹diff ∞ (charts_submanifold (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart))) charts_eucl (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2))›*) using diff_apply_chart[of ?r2] (*‹restrict_chart (domain c1 ∩ domain c2) c2 ∈ atlas ⟹ diff ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c2))) charts_eucl (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2))›*) assms(2) (*‹c2 ∈ atlas›*) restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) by simp subgoal for using restrict_chart_in_atlas[OF assms ( 1 )] (*‹restrict_chart ?S c1 ∈ atlas›*) "c_manifold_local.sub_ψ" (*‹c_manifold_local (?charts::(?'a, ?'b) chart set) (?k::enat) (?ψ::(?'a, ?'b) chart) ⟹ ?ψ ∈ c_manifold.atlas (manifold.charts_submanifold ?charts (domain ?ψ)) ?k›*) by (metis c_manifold_point.axioms(1)[OF c_manifold_point] (*‹⟦?ψ ∈ atlas; ?p ∈ domain ?ψ⟧ ⟹ c_manifold_local charts ∞ ?ψ›*) domain_restrict_chart (*‹open ?S ⟹ domain (restrict_chart ?S ?c) = domain ?c ∩ ?S›*) inf.left_idem (*‹inf ?a (inf ?a ?b) = inf ?a ?b›*) open_Int_dom (*‹open (domain c1 ∩ domain c2)›*) that (*‹p ∈ domain c1 ∩ domain c2›*)) using that (*‹p ∈ domain c1 ∩ domain c2›*) apply - (*goals: 1. ‹p ∈ domain c1 ∩ domain c2 ⟹ p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1)› 2. ‹p ∈ domain c1 ∩ domain c2 ⟹ 0 < ∞› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have r2p_deriv: "frechet_derivative (λx. - (?r2 p) ∙ i) (at (?r1 p)) = 0" for i :: 'b and p by auto hence r2p_differentiable: "(λx. - (?r2 p) ∙ i) differentiable (at (?r1 p))" for i :: 'b and p by simp show "smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (snd ∘ (?R2 ∘ ?R1i))" proof (rule smooth_on_cong[of _ _ ?g, OF _ open_restrict_codomain] (*‹⟦?k-smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (λx. ∑i∈Basis. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x) *⇩R i); ⋀x. x ∈ restrict_codomain_TM (domain c1 ∩ domain c2) c1 ⟹ ?f x = (∑i∈Basis. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x) *⇩R i)⟧ ⟹ ?k-smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) ?f›*)) (*goals: 1. ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (λx. ∑i∈Basis. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x) *⇩R i)› 2. ‹⋀x. x ∈ restrict_codomain_TM (domain c1 ∩ domain c2) c1 ⟹ (snd ∘ (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1)) x = (∑i∈Basis. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x) *⇩R i)›*) fix x assume x: "x ∈ restrict_codomain_TM (domain c1 ∩ domain c2) c1" (*‹(x::'b × 'b) ∈ restrict_codomain_TM (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1›*) then obtain x⇩p and x⇩v where Pair_x: "x = (x⇩p,x⇩v)" and "x⇩p": "x⇩p ∈ codomain c1" "x⇩p ∈ inv_chart c1 -` ?dom_Int" (*goal: ‹(⋀x⇩p x⇩v. ⟦x = (x⇩p, x⇩v); x⇩p ∈ codomain c1; x⇩p ∈ inv_chart c1 -` (domain c1 ∩ domain c2)⟧ ⟹ thesis) ⟹ thesis›*) unfolding restrict_codomain_TM_def codomain_TM_alt (*goal: ‹(⋀x⇩p x⇩v. ⟦x = (x⇩p, x⇩v); x⇩p ∈ codomain c1; x⇩p ∈ inv_chart c1 -` (domain c1 ∩ domain c2)⟧ ⟹ thesis) ⟹ thesis›*) using codomain_restrict_chart[OF open_Int_dom, of c1] (*‹codomain (restrict_chart (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1) = codomain c1 ∩ inv_chart c1 -` (domain c1 ∩ domain c2)›*) by blast obtain p where p_def: "p = inv_chart ?r1 x⇩p" and p[simp]: "p ∈ ?dom_Int" (*goal: ‹(⋀p::'a::{second_countable_topology,t2_space}. ⟦p = inv_chart (restrict_chart (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1) (x⇩p::'b::euclidean_space); p ∈ domain c1 ∩ domain c2⟧ ⟹ thesis::bool) ⟹ thesis›*) using "x⇩p"(2) (*‹(x⇩p::'b) ∈ inv_chart (c1::('a, 'b) chart) -` (domain c1 ∩ domain (c2::('a, 'b) chart))›*) by auto interpret p1: c_manifold_point charts "∞" "?r1" p using "x⇩p"(2) (*‹x⇩p ∈ inv_chart c1 -` (domain c1 ∩ domain c2)›*) by (auto intro!: c_manifold_point (*‹⟦?c ∈ atlas; ?p ∈ domain ?c⟧ ⟹ c_manifold_point charts ∞ ?c ?p›*) simp add: restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) assms( (*‹c1 ∈ atlas›*) 1) p_def (*‹p = inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x⇩p›*)) interpret p2: c_manifold_point charts "∞" "?r2" p using "x⇩p"(2) (*‹x⇩p ∈ inv_chart c1 -` (domain c1 ∩ domain c2)›*) by (auto intro!: c_manifold_point (*‹⟦?c ∈ atlas; ?p ∈ domain ?c⟧ ⟹ c_manifold_point charts ∞ ?c ?p›*) simp add: restrict_chart_in_atlas (*‹?c ∈ atlas ⟹ restrict_chart ?S ?c ∈ atlas›*) assms( (*‹c2 ∈ atlas›*) 2) p_def (*‹p = inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x⇩p›*)) let ?v = "p1.coordinate_vector x⇩v" obtain v where v_def: "v = p1.coordinate_vector x⇩v" and v[simp]: "v ∈ tangent_space p" (*goal: ‹(⋀v. ⟦v = p1.coordinate_vector x⇩v; v ∈ p2.T⇩pM⟧ ⟹ thesis) ⟹ thesis›*) using p1.coordinate_vector_surj (*‹∞ = ∞ ⟹ range p1.coordinate_vector = p2.T⇩pM›*) by blast have pvx: "?R1 (p,v) = x" using Pair_x (*‹x = (x⇩p, x⇩v)›*) "x⇩p"(1) (*‹x⇩p ∈ codomain c1›*) p1.tangent_chart_fun_inverse(2) (*‹∞ = ∞ ⟹ ?x = p1.tangent_chart_fun (p1.coordinate_vector ?x)›*) by (auto simp: p_def (*‹p = inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x⇩p›*) v_def (*‹v = p1.coordinate_vector x⇩v›*) restrict_chart_TM_def (*‹restrict_chart_TM ?S ?c ≡ apply_chart_TM (restrict_chart ?S ?c)›*) apply_chart_TM_def (*‹apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*)) have p1_coord_in_Tp2M: "p1.coordinate_vector x⇩v ∈ p2.T⇩pM" using v (*‹v ∈ p2.T⇩pM›*) v_def (*‹(v::('a ⇒ real) ⇒ real) = p1.coordinate_vector (x⇩v::'b)›*) by auto have diff_fun_spaces_eq[simp]: "p2.sub_ψ.sub.diff_fun_space = p1.sub_ψ.sub.diff_fun_space" unfolding "p2.sub_ψ.sub.diff_fun_space_def" "p1.sub_ψ.sub.diff_fun_space_def" (*goal: ‹{f. diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c2))) f ∧ extensional0 p2.sub_ψ.sub.carrier f} = {f. diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f ∧ extensional0 p1.sub_ψ.sub.carrier f}›*) by simp have TpU_eq[simp]: "p2.T⇩pU = p1.T⇩pU" unfolding "p2.sub_ψ.sub.tangent_space_def" "p1.sub_ψ.sub.tangent_space_def" (*goal: ‹{X. p2.sub_ψ.sub.is_derivation X p ∧ extensional0 p2.sub_ψ.sub.diff_fun_space X} = {X. p1.sub_ψ.sub.is_derivation X p ∧ extensional0 p1.sub_ψ.sub.diff_fun_space X}›*) by simp have sub_carriers_eq[simp]: "p2.sub_ψ.sub.carrier = p1.sub_ψ.sub.carrier" unfolding "p2.sub_ψ.sub.carrier_def" "p1.sub_ψ.sub.carrier_def" (*goal: ‹⋃ (domain ` charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c2))) = ⋃ (domain ` charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1)))›*) by simp have in_diff_fun_space: "restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space" for i :: 'b proof (-) (*goal: ‹restrict0 (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) (λx::'a. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a)) ∙ (i::'b)) ∈ p1.sub_ψ.sub.diff_fun_space›*) have "diff_fun ∞ (charts_submanifold ?dom_Int) (λx. (?r2 x - ?r2 p) ∙ i)" proof (rule diff_fun.diff_fun_cong (*‹⟦diff_fun ?k ?charts ?f; ⋀x. x ∈ manifold.carrier ?charts ⟹ ?f x = ?g x⟧ ⟹ diff_fun ?k ?charts ?g›*)) (*goals: 1. ‹diff_fun ∞ (charts_submanifold (domain c1 ∩ domain c2)) ?f› 2. ‹⋀x. x ∈ manifold.carrier (charts_submanifold (domain c1 ∩ domain c2)) ⟹ ?f x = (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i›*) show "diff_fun ∞ (charts_submanifold ?dom_Int) ((λx. x ∙ i) ∘ ((λx. (x - ?r2 p)) ∘ ?r2))" proof (intro diff_fun_compose (*‹⟦diff ?k ?M1.0 ?M2.0 ?f; diff_fun ?k ?M2.0 ?g⟧ ⟹ diff_fun ?k ?M1.0 (?g ∘ ?f)›*) diff_compose (*‹⟦diff ?k ?M1.0 ?M2.0 ?f; diff ?k ?M2.0 ?M3.0 ?g⟧ ⟹ diff ?k ?M1.0 ?M3.0 (?g ∘ ?f)›*)) (*goals: 1. ‹diff ∞ (charts_submanifold (domain c1 ∩ domain c2)) ?M2.1 (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2))› 2. ‹diff ∞ ?M2.1 ?M2.0 (λx. x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p)› 3. ‹diff_fun ∞ ?M2.0 (λx. x ∙ i)›*) have eucl_diff_add_uminus: "diff ∞ charts_eucl charts_eucl (λy. y + - x)" if x: "x ∈ manifold_eucl.carrier" for x :: 'b apply (intro diff_fun_charts_euclI[unfolded diff_fun_def] (*‹?k-smooth_on UNIV ?g ⟹ diff ?k charts_eucl charts_eucl ?g›*)) (*goal: ‹diff ∞ charts_eucl charts_eucl (λy. y + - x)›*) using smooth_on_add[OF smooth_on_id smooth_on_const [ of ∞ UNIV "-x" ]] (*‹open UNIV ⟹ smooth_on UNIV (λx. x + - x)›*) open_UNIV (*‹open UNIV›*) by simp show "diff ∞ (charts_submanifold ?dom_Int) (manifold_eucl.dest.charts_submanifold (codomain ?r2)) ?r2" using "p2.diffeo_ψ.diff_axioms" (*‹diff ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c2))) (manifold_eucl.dest.charts_submanifold (codomain (restrict_chart (domain c1 ∩ domain c2) c2))) (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2))›*) by auto show "diff ∞ (manifold_eucl.dest.charts_submanifold (codomain ?r2)) charts_eucl (λx. x - ?r2 p)" using eucl_diff_add_uminus[of "?r2 p"] (*‹apply_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2) (p::'a) ∈ manifold_eucl.dest.carrier ⟹ diff ∞ charts_eucl charts_eucl (λy::'b. y + - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p)›*) diff.diff_submanifold (*‹⟦diff ?k ?charts1.0 ?charts2.0 ?f; open ?S⟧ ⟹ diff ?k (manifold.charts_submanifold ?charts1.0 ?S) ?charts2.0 ?f›*) p2.sub_eucl.open_submanifold (*‹open (codomain (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2))›*) by auto show "diff_fun ∞ charts_eucl (λx. x ∙ i)" using smooth_on_inner_const (*‹?k-smooth_on UNIV (λx. x ∙ ?j)›*) by (simp add: diff_fun_charts_euclI (*‹?k-smooth_on UNIV ?g ⟹ diff_fun ?k charts_eucl ?g›*)) qed qed (simp) (*solved the remaining goal: ‹⋀x. x ∈ manifold.carrier (charts_submanifold (domain c1 ∩ domain c2)) ⟹ ((λx. x ∙ i) ∘ ((λx. x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∘ apply_chart (restrict_chart (domain c1 ∩ domain c2) c2))) x = (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i›*) moreover have "(?r2 x - ?r2 p) ∙ i = (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i)) x" if "x ∈ manifold.carrier (charts_submanifold ?dom_Int)" for x using "p1.sub_ψ_carrier" (*‹p1.sub_ψ.sub.carrier = domain (restrict_chart (domain c1 ∩ domain c2) c1)›*) that (*‹x ∈ manifold.carrier (charts_submanifold (domain c1 ∩ domain c2))›*) by auto ultimately show "?thesis" (*goal: ‹restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space›*) using "p1.sub_ψ.sub.restrict0_in_fun_space" (*‹diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) ?f ⟹ restrict0 p1.sub_ψ.sub.carrier ?f ∈ p1.sub_ψ.sub.diff_fun_space›*) "p2.sub_ψ_carrier" (*‹p2.sub_ψ.sub.carrier = domain (restrict_chart (domain c1 ∩ domain c2) c2)›*) by auto qed have "p2_comp_p1_coord_x⇩v": "p2.component_function (p1.coordinate_vector x⇩v) i = frechet_derivative ((λy. (?r2 y) ∙ i) ∘ ?r1i) (at (?r1 p)) x⇩v" for i :: 'b proof (-) (*goal: ‹p2.component_function (p1.coordinate_vector x⇩v) i = frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) have 1: "p2.component_function (p1.coordinate_vector x⇩v) i = (p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (?r1 p) x⇩v))) (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i))" proof (-) (*goal: ‹p2.component_function (p1.coordinate_vector x⇩v) i = p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) have "p2.component_function (p1.coordinate_vector x⇩v) i = p2.dRestr2 (p1.coordinate_vector x⇩v) (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i))" using "p2.component_function_apply_in_T⇩pM"[OF p1_coord_in_Tp2M] (*‹p2.component_function (p1.coordinate_vector (x⇩v::'b)) (?i::'b) = p2.dRestr2 (p1.coordinate_vector x⇩v) (restrict0 (domain (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2)) (λx::'a. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a)) ∙ ?i))›*) by (simp add: Int_absorb1 (*‹?B ⊆ ?A ⟹ ?A ∩ ?B = ?B›*)) also (*calculation: ‹p2.component_function (p1.coordinate_vector x⇩v) i = p2.dRestr2 (p1.coordinate_vector x⇩v) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) have "… = p1.dRestr2 (p1.coordinate_vector x⇩v) (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i))" unfolding the_inv_into_def (*goal: ‹restrict0 p2.T⇩pM (λx::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real. THE y::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real. y ∈ p2.T⇩pU ∧ p2.sub_ψ.inclusion.push_forward y = x) (p1.coordinate_vector (x⇩v::'b::euclidean_space)) (restrict0 (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) (λx::'a::{second_countable_topology,t2_space}. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a::{second_countable_topology,t2_space})) ∙ (i::'b::euclidean_space))) = restrict0 p2.T⇩pM (λx::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real. THE y::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real. y ∈ p1.T⇩pU ∧ p1.sub_ψ.inclusion.push_forward y = x) (p1.coordinate_vector x⇩v) (restrict0 (domain c1 ∩ domain c2) (λx::'a::{second_countable_topology,t2_space}. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) by simp also (*calculation: ‹p2.component_function (p1.coordinate_vector (x⇩v::'b::euclidean_space)) (i::'b::euclidean_space) = p1.dRestr2 (p1.coordinate_vector x⇩v) (restrict0 (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) (λx::'a::{second_countable_topology,t2_space}. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a::{second_countable_topology,t2_space})) ∙ i))›*) have "… = (p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (?r1 p) x⇩v))) (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i))" using the_inv_into_f_f[OF bij_betw_imp_inj_on [ OF p1.tangent_submanifold_isomorphism ( 1 ) ]] (*‹?x ∈ p1.T⇩pU ⟹ the_inv_into p1.T⇩pU p1.sub_ψ.inclusion.push_forward (p1.sub_ψ.inclusion.push_forward ?x) = ?x›*) using bij_betwE[OF p1.bij_betw_dψ_inv] (*‹∀a∈p1.T⇩ψ⇩pψU. p1.differential_inv_chart a ∈ p1.T⇩pU›*) bij_betwE[OF p1.bij_betw_dκ_inv] (*‹∀a::('b ⇒ real) ⇒ real∈p1.T⇩ψ⇩pE. p1.dRestr a ∈ p1.T⇩ψ⇩pψU›*) p1_coord_in_Tp2M (*‹p1.coordinate_vector x⇩v ∈ p2.T⇩pM›*) by (auto simp: p1.coordinate_vector_apply (*‹p1.coordinate_vector ?v ≡ p1.sub_ψ.inclusion.push_forward (p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) ?v)))›*)) finally (*calculation: ‹p2.component_function (p1.coordinate_vector x⇩v) i = p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) show "?thesis" (*goal: ‹p2.component_function (p1.coordinate_vector x⇩v) i = p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) . qed also (*calculation: ‹p2.component_function (p1.coordinate_vector x⇩v) i = p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) have "… = frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier ((restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i)) ∘ ?r1i)) (at (?r1 p)) x⇩v" proof (-) (*goal: ‹p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i)) = frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) have "… = (p1.differential_inv_chart (restrict0 (p1.diffeo_ψ.dest.diff_fun_space) (λf. frechet_derivative f (at (?r1 p)) x⇩v))) (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i))" using "p1.dκ_inv_directional_derivative_eq" (*‹∞ = ∞ ⟹ p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) ?x) = restrict0 p1.diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) ?x)›*) by simp also (*calculation: ‹p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i)) = p1.differential_inv_chart (restrict0 p1.diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))›*) have "… = (λg. restrict0 p1.diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (?r1 p)) x⇩v) (restrict0 p1.diffeo_ψ.dest.carrier (g ∘ ?r1i))) (restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i))" unfolding "p1.diffeo_ψ.inv.push_forward_def" (*goal: ‹restrict0 p1.sub_ψ.sub.diff_fun_space (λg. restrict0 p1.diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v) (restrict0 p1.diffeo_ψ.dest.carrier (g ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)))) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i)) = restrict0 p1.diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v) (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)))›*) using in_diff_fun_space (*‹restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ ?i3) ∈ p1.sub_ψ.sub.diff_fun_space›*) by simp also (*calculation: ‹p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i)) = restrict0 p1.diffeo_ψ.dest.diff_fun_space (λf. frechet_derivative f (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v) (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)))›*) have "… = (λf. frechet_derivative f (at (?r1 p)) x⇩v) (restrict0 p1.diffeo_ψ.dest.carrier ((restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i)) ∘ ?r1i))" using in_diff_fun_space (*‹restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ ?i3) ∈ p1.sub_ψ.sub.diff_fun_space›*) "p1.diffeo_ψ.inv.restrict_compose_in_diff_fun_space" (*‹?x ∈ p1.sub_ψ.sub.diff_fun_space ⟹ restrict0 p1.diffeo_ψ.dest.carrier (?x ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) ∈ p1.diffeo_ψ.dest.diff_fun_space›*) by auto finally (*calculation: ‹p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i)) = frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) show "?thesis" (*goal: ‹p1.differential_inv_chart (p1.dRestr (directional_derivative ∞ (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) x⇩v)) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i)) = frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) by simp qed also (*calculation: ‹p2.component_function (p1.coordinate_vector x⇩v) i = frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) have "… = frechet_derivative ((λx. (?r2 x) ∙ i) ∘ ?r1i) (at (?r1 p)) x⇩v" proof (-) (*goal: ‹frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) let ?X = "p1.diffeo_ψ.dest.carrier" have X_eq_codomain_r1[simp]: "p1.diffeo_ψ.dest.carrier = codomain ?r1" using chart_eucl_simps(1) (*‹domain chart_eucl = UNIV›*) manifold.carrier_def (*‹manifold.carrier ?charts = ⋃ (domain ` ?charts)›*) by (metis (no_types, lifting) Int_UNIV_right (*‹?A ∩ UNIV = ?A›*) Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*) ccpo_Sup_singleton (*‹Sup {?x} = ?x›*) image_insert (*‹?f ` insert ?a ?B = insert (?f ?a) (?f ` ?B)›*) image_is_empty (*‹(?f ` ?A = {}) = (?A = {})›*) p1.sub_eucl.carrier_submanifold (*‹p1.diffeo_ψ.dest.carrier = codomain (restrict_chart (domain c1 ∩ domain c2) c1) ∩ manifold_eucl.dest.carrier›*)) have 1: "frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier ((restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i)) ∘ ?r1i)) (at (?r1 p)) = frechet_derivative ((λx. (?r2 x - ?r2 p) ∙ i) ∘ ?r1i) (at (?r1 p))" (is "frechet_derivative ?f⇩L (at _) = frechet_derivative ?f⇩R (at _)") proof (rule frechet_derivative_transform_within_open (*‹⟦(?f::?'a ⇒ ?'b) differentiable at (?x::?'a); open (?X::?'a set); ?x ∈ ?X; ⋀x::?'a. x ∈ ?X ⟹ ?f x = (?g::?'a ⇒ ?'b) x⟧ ⟹ frechet_derivative ?f (at ?x) = frechet_derivative ?g (at ?x)›*)) (*goals: 1. ‹restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) (λx::'a. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a)) ∙ (i::'b)) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)› 2. ‹open (?X::'b set)› 3. ‹apply_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1) (p::'a) ∈ (?X::'b set)› 4. ‹⋀x::'b. x ∈ (?X::'b set) ⟹ restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) (λx::'a. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a)) ∙ (i::'b)) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) x = ((λx::'a. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) x›*) show "?f⇩L x = ?f⇩R x" if "x∈?X" for x using X_eq_codomain_r1 (*‹p1.diffeo_ψ.dest.carrier = codomain (restrict_chart (domain c1 ∩ domain c2) c1)›*) that (*‹x ∈ p1.diffeo_ψ.dest.carrier›*) by simp show "open ?X" by blast show "?r1 p ∈ ?X" using "p1.ψp_in" (*‹apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier›*) by blast let ?f⇩L' = "(restrict0 ?dom_Int (λx. (?r2 x - ?r2 p) ∙ i)) ∘ ?r1i" show "?f⇩L differentiable at (?r1 p)" apply (rule differentiable_transform_within_open[of ?f⇩L' _ _ ?X] (*‹⟦restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) differentiable at ?x within ?t; open p1.diffeo_ψ.dest.carrier; ?x ∈ p1.diffeo_ψ.dest.carrier; ⋀x. x ∈ p1.diffeo_ψ.dest.carrier ⟹ (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) x = ?g x⟧ ⟹ ?g differentiable at ?x within ?t›*)) (*goal: ‹restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)›*) apply (rule p1.sub_ψ.sub_diff_fun_differentiable_at (*‹⟦diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) ?f; ?c ∈ p1.sub_ψ.sub.atlas; ?p ∈ domain ?c; 0 < ∞⟧ ⟹ ?f ∘ inv_chart ?c differentiable at (apply_chart ?c ?p)›*)) (*top goal: ‹restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)› and 3 goals remain*) using "p1.ψp_in" (*‹apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier›*) "p1.diffeo_ψ.dest.open_carrier" (*‹open p1.diffeo_ψ.dest.carrier›*) in_diff_fun_space (*‹restrict0 (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) (λx::'a. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a)) ∙ (?i3::'b)) ∈ p1.sub_ψ.sub.diff_fun_space›*) "p1.sub_ψ" (*‹restrict_chart (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1 ∈ p1.sub_ψ.sub.atlas›*) p1.p (*‹p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1)›*) "p1.sub_ψ.sub.diff_fun_spaceD" (*‹?f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) ?f›*) apply - (*goals: 1. ‹⟦apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i))› 2. ‹⟦apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas› 3. ‹⟦apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1)› 4. ‹⟦apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ 0 < ∞› 5. ‹⟦apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ open p1.diffeo_ψ.dest.carrier› 6. ‹⟦apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier› 7. ‹⋀x. ⟦x ∈ p1.diffeo_ψ.dest.carrier; apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p ∈ p1.diffeo_ψ.dest.carrier; open p1.diffeo_ψ.dest.carrier; ⋀i. restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∈ p1.sub_ψ.sub.diff_fun_space; restrict_chart (domain c1 ∩ domain c2) c1 ∈ p1.sub_ψ.sub.atlas; p ∈ domain (restrict_chart (domain c1 ∩ domain c2) c1); ⋀f. f ∈ p1.sub_ψ.sub.diff_fun_space ⟹ diff_fun ∞ (charts_submanifold (domain (restrict_chart (domain c1 ∩ domain c2) c1))) f⟧ ⟹ (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) x = restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . qed also (*calculation: ‹frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) have 2: "… = frechet_derivative ((λx. (?r2 x) ∙ i) ∘ ?r1i) (at (?r1 p))" proof (-) (*goal: ‹frechet_derivative ((λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) have "frechet_derivative ((λx. (?r2 x - ?r2 p) ∙ i) ∘ ?r1i) (at (?r1 p)) = frechet_derivative ((λx. ?r2 (?r1i x) ∙ i) + (λx. - (?r2 p) ∙ i)) (at (?r1 p))" apply (simp add: plus_fun_def (*‹?f + ?g = (λx. ?f x + ?g x)›*) inner_diff_left (*‹(?x - ?y) ∙ ?z = ?x ∙ ?z - ?y ∙ ?z›*)) (*goal: ‹frechet_derivative ((λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) + (λx. - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p ∙ i)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) by (meson comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*)) also (*calculation: ‹frechet_derivative ((λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) + (λx. - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p ∙ i)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) have "… = frechet_derivative (λx. ?r2 (?r1i x) ∙ i) (at (?r1 p)) + (frechet_derivative (λx. - (?r2 p) ∙ i) (at (?r1 p)))" using r2_r1i_differentiable[OF p] (*‹(λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ ?i3) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)›*) r2p_differentiable (*‹(λx. - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ?p3 ∙ ?i3) differentiable at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) ?p3)›*) by (auto simp: frechet_derivative_plus_fun (*‹⟦(?x::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) differentiable at (?a::?'a::real_normed_vector); (?y::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) differentiable at ?a⟧ ⟹ frechet_derivative (?x + ?y) (at ?a) = frechet_derivative ?x (at ?a) + frechet_derivative ?y (at ?a)›*)) finally (*calculation: ‹frechet_derivative ((λx::'a. (apply_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (p::'a)) ∙ (i::'b)) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative (λx::'b. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x) ∙ i) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) + frechet_derivative (λx::'b. - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p ∙ i) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) show "frechet_derivative ((λx. (?r2 x - ?r2 p) ∙ i) ∘ ?r1i) (at (?r1 p)) = frechet_derivative ((λx. ?r2 x ∙ i) ∘ ?r1i) (at (?r1 p))" using r2p_deriv (*‹frechet_derivative (λx. - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) ?p3 ∙ ?i3) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) ?p3)) = 0›*) apply simp (*goal: ‹frechet_derivative ((λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) by (metis comp_apply (*‹(?f ∘ ?g) ?x = ?f (?g ?x)›*)) qed finally (*calculation: ‹frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) show "?thesis" (*goal: ‹frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) using "1" (*‹frechet_derivative (restrict0 p1.diffeo_ψ.dest.carrier (restrict0 (domain c1 ∩ domain c2) (λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1))) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) = frechet_derivative ((λx. (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x - apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p) ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p))›*) by presburger qed finally (*calculation: ‹p2.component_function (p1.coordinate_vector x⇩v) i = frechet_derivative ((λx. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) x ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) p)) x⇩v›*) show "p2.component_function (p1.coordinate_vector x⇩v) i = frechet_derivative ((λx. (?r2 x) ∙ i) ∘ ?r1i) (at (?r1 p)) x⇩v" . qed have "(snd ∘ (?R2 ∘ ?R1i)) x = (p2.tangent_chart_fun ∘ p1.coordinate_vector) x⇩v" unfolding restrict_chart_TM_def restrict_inv_chart_TM_def (*goal: ‹(snd ∘ (apply_chart_TM (restrict_chart (domain c1 ∩ domain c2) c2) ∘ inv_chart_TM (restrict_chart (domain c1 ∩ domain c2) c1))) x = (p2.tangent_chart_fun ∘ p1.coordinate_vector) x⇩v›*) unfolding apply_chart_TM_def inv_chart_TM_def (*goal: ‹(snd ∘ ((λ(p, v). (apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) p, c_manifold_point.tangent_chart_fun charts ∞ (restrict_chart (domain c1 ∩ domain c2) c2) p v)) ∘ (λ(p, v). (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) p, c_manifold_point.coordinate_vector charts ∞ (restrict_chart (domain c1 ∩ domain c2) c1) (inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) p) v)))) x = (p2.tangent_chart_fun ∘ p1.coordinate_vector) x⇩v›*) by (simp add: Pair_x (*‹(x::'b × 'b) = (x⇩p::'b, x⇩v::'b)›*) p_def (*‹(p::'a) = inv_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1) (x⇩p::'b)›*)) then show "(snd ∘ (?R2 ∘ ?R1i)) x = ?g x" unfolding p2.tangent_chart_fun_def (*goal: ‹(snd ∘ (restrict_chart_TM (domain c1 ∩ domain c2) c2 ∘ restrict_inv_chart_TM (domain c1 ∩ domain c2) c1)) x = (∑i∈Basis. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x) *⇩R i)›*) using "p2_comp_p1_coord_x⇩v" (*‹p2.component_function (p1.coordinate_vector (x⇩v::'b)) (?i3::'b) = frechet_derivative ((λy::'a. apply_chart (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c2) y ∙ ?i3) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (apply_chart (restrict_chart (domain c1 ∩ domain c2) c1) (p::'a))) x⇩v›*) p_def (*‹p = inv_chart (restrict_chart (domain c1 ∩ domain c2) c1) x⇩p›*) p (*‹p ∈ domain c1 ∩ domain c2›*) Pair_x (*‹x = (x⇩p, x⇩v)›*) "x⇩p"(1) (*‹(x⇩p::'b) ∈ codomain (c1::('a, 'b) chart)›*) by auto next (*goal: ‹smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (λx. ∑i∈Basis. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x) *⇩R i)›*) let ?D = "restrict_codomain_TM (domain c1 ∩ domain c2) c1" show "smooth_on ?D ?g" proof (rule smooth_on_sum (*‹⟦⋀i. ⟦i ∈ ?F; finite ?F⟧ ⟹ ?n-smooth_on ?S (?f i); open ?S⟧ ⟹ ?n-smooth_on ?S (λx. ∑i∈?F. ?f i x)›*), rule smooth_on_scaleR (*‹⟦?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. ?f x *⇩R ?g x)›*)) (*goals: 1. ‹⋀i. ⟦i ∈ Basis; finite Basis⟧ ⟹ smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (λx. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x))› 2. ‹⋀i. ⟦i ∈ Basis; finite Basis⟧ ⟹ smooth_on (restrict_codomain_TM (domain c1 ∩ domain c2) c1) (λx. i)› 3. ‹⋀i. ⟦i ∈ Basis; finite Basis⟧ ⟹ open (restrict_codomain_TM (domain c1 ∩ domain c2) c1)› 4. ‹open (restrict_codomain_TM (domain c1 ∩ domain c2) c1)›*) fix i :: 'b assume i: "i∈Basis" (*‹(i::'b) ∈ Basis›*) have D_product: "?D = c1 ` (domain c1 ∩ domain c2) × UNIV" unfolding restrict_codomain_TM_def codomain_TM_def (*goal: ‹{(p, v). p ∈ codomain (restrict_chart (domain c1 ∩ domain c2) c1)} = apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV›*) apply auto (*goal: ‹{(p::'b, v::'b). p ∈ codomain (restrict_chart (domain (c1::('a, 'b) chart) ∩ domain (c2::('a, 'b) chart)) c1)} = apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV›*) by (metis IntI (*‹⟦(?c::?'a::type) ∈ (?A::?'a::type set); ?c ∈ (?B::?'a::type set)⟧ ⟹ ?c ∈ ?A ∩ ?B›*) chart_inverse_inv_chart (*‹(?y::?'b::euclidean_space) ∈ codomain (?c::(?'a::topological_space, ?'b::euclidean_space) chart) ⟹ apply_chart ?c (inv_chart ?c ?y) = ?y›*) imageI (*‹(?x::?'a::type) ∈ (?A::?'a::type set) ⟹ (?f::?'a::type ⇒ ?'b::type) ?x ∈ ?f ` ?A›*) inv_chart_in_domain (*‹(?y::?'b::euclidean_space) ∈ codomain (?c::(?'a::topological_space, ?'b::euclidean_space) chart) ⟹ inv_chart ?c ?y ∈ domain ?c›*)) show "smooth_on ?D (λx. frechet_derivative ((λy. (?r2 y) ∙ i) ∘ ?r1i) (at (fst x)) (snd x))" unfolding D_product (*goal: ‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x))›*) by (rule smooth_on_compat_charts_TM[OF assms] (*‹smooth_on (apply_chart c1 ` (domain c1 ∩ domain c2) × UNIV) (λx. frechet_derivative ((λy. apply_chart (restrict_chart (domain c1 ∩ domain c2) c2) y ∙ ?i) ∘ inv_chart (restrict_chart (domain c1 ∩ domain c2) c1)) (at (fst x)) (snd x))›*)) qed (auto) (*solves the remaining goals: 1. ‹⋀i::'b::euclidean_space. ⟦i ∈ Basis; finite Basis⟧ ⟹ smooth_on (restrict_codomain_TM (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1) (λx::'b::euclidean_space × 'b::euclidean_space. i)› 2. ‹⋀i::'b::euclidean_space. ⟦i ∈ Basis; finite Basis⟧ ⟹ open (restrict_codomain_TM (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1)› 3. ‹open (restrict_codomain_TM (domain (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain (c2::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) c1)›*) qed qed qed qed lemma atlas_TM': assumes "c1 ∈ atlas" "c2 ∈ atlas" shows "smooth_on ((apply_chart_TM c2) ` (domain_TM c1 ∩ domain_TM c2)) ((apply_chart_TM c1) ∘ (inv_chart_TM c2))" using atlas_TM[OF assms ( 2 , 1 )] (*‹smooth_on (apply_chart_TM c2 ` (domain_TM c2 ∩ domain_TM c1)) (apply_chart_TM c1 ∘ inv_chart_TM c2)›*) by (simp add: Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*)) end subsubsection ‹Differentiability of vector fields› context c_manifold begin abbreviation k_diff_from_M_to_TM_at_in :: "enat ⇒ 'a ⇒ ('a,'b)chart ⇒ ('a ⇒ 'a tangent_bundle) ⇒ bool" where "k_diff_from_M_to_TM_at_in k' x c X ≡ x ∈ domain c ∧ X ` domain c ⊆ domain_TM c ∧ k'-smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)" ― ‹Compare this definition to @{thm diff_axioms_def}. It's the same, except the charts for TM aren't of type \<^typ>‹('a,'b)chart›.› definition k_diff_from_M_to_TM (‹_-diff'_from'_M'_to'_TM› [1000]) where diff_from_M_to_TM_def: "k'-diff_from_M_to_TM X ≡ ∀x. x ∈ carrier ⟶ (∃c∈atlas. k_diff_from_M_to_TM_at_in k' x c X)" abbreviation "continuous_from_M_to_TM ≡ 0-diff_from_M_to_TM" abbreviation (in smooth_manifold) "smooth_from_M_to_TM ≡ k_diff_from_M_to_TM ∞" lemma diff_from_M_to_TM_E: assumes "k'-diff_from_M_to_TM X" "x ∈ carrier" obtains c where "c∈atlas" "x ∈ domain c" "X ` domain c ⊆ domain_TM c" "k'-smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)" using assms (*‹k'-diff_from_M_to_TM X› ‹x ∈ carrier›*) unfolding diff_from_M_to_TM_def (*goal: ‹(⋀c. ⟦c ∈ atlas; x ∈ domain c; X ` domain c ⊆ domain_TM c; k'-smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)⟧ ⟹ thesis) ⟹ thesis›*) by auto lemma continuous_from_M_to_TM_D: assumes "continuous_from_M_to_TM X" "x ∈ carrier" obtains c where "c∈atlas" "x ∈ domain c" "X ` domain c ⊆ domain_TM c" "continuous_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)" using assms (*‹continuous_from_M_to_TM X› ‹x ∈ carrier›*) by (meson diff_from_M_to_TM_E (*‹⟦?k'-diff_from_M_to_TM ?X; ?x ∈ carrier; ⋀c. ⟦c ∈ atlas; ?x ∈ domain c; ?X ` domain c ⊆ domain_TM c; ?k'-smooth_on (codomain c) (apply_chart_TM c ∘ ?X ∘ inv_chart c)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) smooth_on_imp_continuous_on (*‹?k-smooth_on ?S ?f ⟹ continuous_on ?S ?f›*) that (*‹⟦?c3 ∈ atlas; x ∈ domain ?c3; X ` domain ?c3 ⊆ domain_TM ?c3; continuous_on (codomain ?c3) (apply_chart_TM ?c3 ∘ X ∘ inv_chart ?c3)⟧ ⟹ thesis›*)) definition section_of_TM_def: "section_of_TM_on S X ≡ ∀p∈S. (X p) ∈ TM ∧ fst (X p) = p" abbreviation "section_of_TM ≡ section_of_TM_on carrier" lemma section_of_TM_subset: assumes "section_of_TM_on S X" "T ⊆ S" shows "section_of_TM_on T X" using assms (*‹section_of_TM_on (S::'a::{second_countable_topology,t2_space} set) (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real))› ‹T ⊆ S›*) unfolding section_of_TM_def (*goal: ‹∀p::'a::{second_countable_topology,t2_space}∈T::'a::{second_countable_topology,t2_space} set. (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) p ∈ TM ∧ fst (X p) = p›*) by force lemma section_domain_TM: assumes "section_of_TM_on (domain c) X" shows "X ` domain c ⊆ domain_TM c" using assms (*‹section_of_TM_on (domain c) X›*) unfolding domain_TM_def section_of_TM_def in_TM_def (*goal: ‹X ` domain c ⊆ {(p, v). p ∈ domain c ∧ v ∈ tangent_space p}›*) by auto lemma section_domain_TM': assumes "section_of_TM X" "c ∈ atlas" shows "X ` domain c ⊆ domain_TM c" using assms (*‹section_of_TM X› ‹c ∈ atlas›*) section_domain_TM (*‹section_of_TM_on (domain ?c) ?X ⟹ ?X ` domain ?c ⊆ domain_TM ?c›*) section_of_TM_subset (*‹⟦section_of_TM_on ?S ?X; ?T ⊆ ?S⟧ ⟹ section_of_TM_on ?T ?X›*) by blast lemma section_vimage_domain_TM: assumes "section_of_TM X" "c∈atlas" shows "carrier ∩ X -` domain_TM c = domain c" using assms (*‹section_of_TM (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real))› ‹c ∈ atlas›*) unfolding domain_TM_def section_of_TM_def in_TM_def (*goal: ‹carrier ∩ (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) -` {(p::'a, v::('a ⇒ real) ⇒ real). p ∈ domain (c::('a, 'b) chart) ∧ v ∈ tangent_space p} = domain c›*) apply simp (*goal: ‹carrier ∩ X -` {(p, v). p ∈ domain c ∧ v ∈ tangent_space p} = domain c›*) by force end context smooth_manifold begin text ‹Show that a smooth/differentiable vector field is smooth in any chart. This would be @{thm diff.diff_chartsD} if we could write $TM$ as a \<^locale>‹c_manifold›; it relies on the compatibility of charts for $TM$ given in @{thm smooth_manifold.atlas_TM}.› lemma diff_from_M_to_TM_chartsD: assumes X: "k_diff_from_M_to_TM k' X" "section_of_TM X" and c: "c ∈ atlas" shows "k'-smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)" proof (-) (*goal: ‹k'-smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)›*) have codom_simp: "codomain c ∩ inv_chart c -` (carrier ∩ X -` domain_TM c) = codomain c" using section_vimage_domain_TM[OF X ( 2 ) c] (*‹carrier ∩ X -` domain_TM c = domain c›*) by (simp add: Int_absorb2 (*‹?A ⊆ ?B ⟹ ?A ∩ ?B = ?A›*) subset_vimage_iff (*‹(?A ⊆ ?f -` ?B) = (∀x∈?A. ?f x ∈ ?B)›*)) { fix y assume "y ∈ codomain c ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)" (*‹(y::'b) ∈ codomain (c::('a, 'b) chart) ∩ inv_chart c -` (carrier ∩ (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) -` domain_TM c)›*) then have y: "X (inv_chart c y) ∈ domain_TM c" "y ∈ codomain c" apply - (*goals: 1. ‹(y::'b::euclidean_space) ∈ codomain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ inv_chart c -` (carrier ∩ (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) -` domain_TM c) ⟹ X (inv_chart c y) ∈ domain_TM c› 2. ‹(y::'b::euclidean_space) ∈ codomain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ inv_chart c -` (carrier ∩ (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) -` domain_TM c) ⟹ y ∈ codomain c› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then obtain x where x: "c x = y" "x ∈ domain c" (*goal: ‹(⋀x. ⟦apply_chart c x = y; x ∈ domain c⟧ ⟹ thesis) ⟹ thesis›*) by force then have "x ∈ carrier" using assms (*‹k_diff_from_M_to_TM k' X› ‹section_of_TM X› ‹c ∈ atlas›*) by force obtain c1 where "c1 ∈ atlas" and fc1: "X ` domain c1 ⊆ domain_TM c1" and xc1: "x ∈ domain c1" and d: "k'-smooth_on (codomain c1) (apply_chart_TM c1 ∘ X ∘ inv_chart c1)" (*goal: ‹(⋀c1::('a, 'b) chart. ⟦c1 ∈ atlas; (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ` domain c1 ⊆ domain_TM c1; (x::'a) ∈ domain c1; (k'::enat)-smooth_on (codomain c1) (apply_chart_TM c1 ∘ X ∘ inv_chart c1)⟧ ⟹ thesis::bool) ⟹ thesis›*) by (meson ‹x ∈ carrier› assms( (*‹k_diff_from_M_to_TM k' X›*) 1) diff_from_M_to_TM_E (*‹⟦k_diff_from_M_to_TM ?k' ?X; ?x ∈ carrier; ⋀c. ⟦c ∈ atlas; ?x ∈ domain c; ?X ` domain c ⊆ domain_TM c; ?k'-smooth_on (codomain c) (apply_chart_TM c ∘ ?X ∘ inv_chart c)⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) have fc1'[simp]: "x ∈ domain c1 ⟹ X x ∈ domain_TM c1" for x using fc1 (*‹X ` domain c1 ⊆ domain_TM c1›*) by auto have r1: "k'-smooth_on (c ` (domain c ∩ domain c1)) (c1 ∘ inv_chart c)" using smooth_compat_D1[OF smooth_compat_le [ OF atlas_is_atlas [ OF c ‹c1 ∈ atlas› ] ]] (*‹?k ≤ ∞ ⟹ ?k-smooth_on (apply_chart c ` (domain c ∩ domain c1)) (apply_chart c1 ∘ inv_chart c)›*) by force have r2: "k'-smooth_on (apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1)) (apply_chart_TM c ∘ inv_chart_TM c1)" apply (rule smooth_on_le[OF atlas_TM'[OF c ‹c1 ∈ atlas›]] (*‹?l ≤ ∞ ⟹ ?l-smooth_on (apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1)) (apply_chart_TM c ∘ inv_chart_TM c1)›*)) (*goal: ‹k'-smooth_on (apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1)) (apply_chart_TM c ∘ inv_chart_TM c1)›*) by simp define T where "T = c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ (X -` domain_TM c))" have simps_1: "(apply_chart_TM c1 ∘ X ∘ inv_chart c1) ` (apply_chart c1 ∘ inv_chart c) ` T = (apply_chart_TM c1 ∘ X ∘ inv_chart c) ` T" if "inv_chart c ` T ⊆ domain c1" for T unfolding image_comp[symmetric] (*goal: ‹apply_chart_TM c1 ` X ` inv_chart c1 ` apply_chart c1 ` inv_chart c ` T = apply_chart_TM c1 ` X ` inv_chart c ` T›*) using that (*‹inv_chart (c::('a, 'b) chart) ` (T::'b set) ⊆ domain (c1::('a, 'b) chart)›*) apply auto (*goal: ‹apply_chart_TM c1 ` X ` inv_chart c1 ` apply_chart c1 ` inv_chart c ` T = apply_chart_TM c1 ` X ` inv_chart c ` T›*) by (smt (verit) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) inv_chart_inverse (*‹?x ∈ domain ?c ⟹ inv_chart ?c (apply_chart ?c ?x) = ?x›*)) have "inv_chart c ` T ⊆ domain c1" by (auto simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) note T_simps = simps_1[OF this] (*‹(apply_chart_TM c1 ∘ X ∘ inv_chart c1) ` (apply_chart c1 ∘ inv_chart c) ` T = (apply_chart_TM c1 ∘ X ∘ inv_chart c) ` T›*) section_vimage_domain_TM[OF X ( 2 ) c] (*‹carrier ∩ X -` domain_TM c = domain c›*) have "open T" by (auto intro!: open_continuous_vimage' (*‹⟦open ?s; continuous_on ?s ?f; open ?B⟧ ⟹ open (?s ∩ ?f -` ?B)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 240 facts*) simp: T_simps( (*‹carrier ∩ X -` domain_TM c = domain c›*) 2) T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) have T_subset: "T ⊆ apply_chart c ` (domain c ∩ domain c1)" by (auto simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) have opens: "open (c1 ` inv_chart c ` T)" "open (apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1))" using T_subset (*‹T ⊆ apply_chart c ` (domain c ∩ domain c1)›*) fc1 (*‹X ` domain c1 ⊆ domain_TM c1›*) ‹open T› (*‹open T›*) ‹inv_chart c ` T ⊆ domain c1› (*‹inv_chart (c::('a, 'b) chart) ` (T::'b set) ⊆ domain (c1::('a, 'b) chart)›*) (*goals: 1. ‹open (apply_chart c1 ` inv_chart c ` T)› 2. ‹open (apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1))› discuss goal 1*) apply blast (*discuss goal 2*) apply (metis Int_commute (*‹?A ∩ ?B = ?B ∩ ?A›*) ‹c1 ∈ atlas› open_intersection_TM (*‹?c1.0 ∈ atlas ⟹ open (apply_chart_TM ?c1.0 ` (domain_TM ?c1.0 ∩ domain_TM ?c2.0))›*)) (*proven 2 subgoals*) . have "k'-smooth_on ((apply_chart c1 ∘ inv_chart c) ` T) (apply_chart_TM c ∘ inv_chart_TM c1 ∘ (apply_chart_TM c1 ∘ X ∘ inv_chart c1))" using r2 (*‹(k'::enat)-smooth_on (apply_chart_TM (c1::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ` (domain_TM (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∩ domain_TM c1)) (apply_chart_TM c ∘ inv_chart_TM c1)›*) d (*‹k'-smooth_on (codomain c1) (apply_chart_TM c1 ∘ X ∘ inv_chart c1)›*) opens (*‹open (apply_chart c1 ` inv_chart c ` T)› ‹open (apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1))›*) unfolding image_comp[symmetric] (*goal: ‹k'-smooth_on (apply_chart c1 ` inv_chart c ` T) (apply_chart_TM c ∘ inv_chart_TM c1 ∘ (apply_chart_TM c1 ∘ X ∘ inv_chart c1))›*) apply (rule smooth_on_compose2 (*‹⟦?k-smooth_on ?T ?f; ?k-smooth_on ?S ?g; open ?U; open ?T; ?g ` ?U ⊆ ?T; ?U ⊆ ?S⟧ ⟹ ?k-smooth_on ?U (?f ∘ ?g)›*)) (*goals: 1. ‹(apply_chart_TM c1 ∘ X ∘ inv_chart c1) ` apply_chart c1 ` inv_chart c ` T ⊆ apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1)› 2. ‹apply_chart c1 ` inv_chart c ` T ⊆ codomain c1› discuss goal 1*) apply ((auto simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*))[1]) (*top goal: ‹(apply_chart_TM c1 ∘ X ∘ inv_chart c1) ` apply_chart c1 ` inv_chart c ` T ⊆ apply_chart_TM c1 ` (domain_TM c ∩ domain_TM c1)› and 1 goal remains*) apply (metis IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) fc1 (*‹X ` domain c1 ⊆ domain_TM c1›*) image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) subset_refl (*‹?A ⊆ ?A›*)) (*discuss goal 2*) apply ((auto simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*))[1]) (*proven 2 subgoals*) . from this (*‹k'-smooth_on ((apply_chart c1 ∘ inv_chart c) ` T) (apply_chart_TM c ∘ inv_chart_TM c1 ∘ (apply_chart_TM c1 ∘ X ∘ inv_chart c1))›*) r1 (*‹k'-smooth_on (apply_chart c ` (domain c ∩ domain c1)) (apply_chart c1 ∘ inv_chart c)›*) ‹open T› (*‹open (T::'b set)›*) opens(1) (*‹open (apply_chart c1 ` inv_chart c ` T)›*) have "k'-smooth_on T ((apply_chart_TM c ∘ inv_chart_TM c1) ∘ (apply_chart_TM c1 ∘ X ∘ inv_chart c1) ∘ (c1 ∘ inv_chart c))" unfolding image_comp[symmetric] (*goal: ‹k'-smooth_on T (apply_chart_TM c ∘ inv_chart_TM c1 ∘ (apply_chart_TM c1 ∘ X ∘ inv_chart c1) ∘ (apply_chart c1 ∘ inv_chart c))›*) apply (rule smooth_on_compose2 (*‹⟦?k-smooth_on ?T ?f; ?k-smooth_on ?S ?g; open ?U; open ?T; ?g ` ?U ⊆ ?T; ?U ⊆ ?S⟧ ⟹ ?k-smooth_on ?U (?f ∘ ?g)›*)) (*goals: 1. ‹(apply_chart c1 ∘ inv_chart c) ` T ⊆ apply_chart c1 ` inv_chart c ` T› 2. ‹T ⊆ apply_chart c ` (domain c ∩ domain c1)› discuss goal 1*) apply (force simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) (*discuss goal 2*) apply (force simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) (*proven 2 subgoals*) . then have "k'-smooth_on T (apply_chart_TM c ∘ X ∘ inv_chart c)" using ‹open T› (*‹open (T::'b set)›*) apply (rule smooth_on_cong (*‹⟦?k-smooth_on ?S ?g; open ?S; ⋀x. x ∈ ?S ⟹ ?f x = ?g x⟧ ⟹ ?k-smooth_on ?S ?f›*)) (*goal: ‹k'-smooth_on T (apply_chart_TM c ∘ X ∘ inv_chart c)›*) using apply_chart_TM_inverse(1)[of c1 "fst (X xa)" "snd (X xa)" for xa] (*‹⟦c1 ∈ atlas; (fst (X ?xa5), snd (X ?xa5)) ∈ domain_TM c1⟧ ⟹ inv_chart_TM c1 (apply_chart_TM c1 (fst (X ?xa5), snd (X ?xa5))) = (fst (X ?xa5), snd (X ?xa5))›*) fc1' (*‹(?x3::'a) ∈ domain (c1::('a, 'b) chart) ⟹ (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ?x3 ∈ domain_TM c1›*) ‹c1 ∈ atlas› (*‹c1 ∈ atlas›*) by (auto simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) moreover have "y ∈ T" using x (*‹apply_chart c x = y› ‹x ∈ domain c›*) xc1 (*‹x ∈ domain c1›*) fc1 (*‹X ` domain c1 ⊆ domain_TM c1›*) y (*‹X (inv_chart c y) ∈ domain_TM c› ‹y ∈ codomain c›*) ‹c1 ∈ atlas› (*‹c1 ∈ atlas›*) by (auto simp: T_def (*‹T = apply_chart c ` (domain c ∩ domain c1) ∩ inv_chart c -` (carrier ∩ X -` domain_TM c)›*)) ultimately have "∃T. y ∈ T ∧ open T ∧ k'-smooth_on T (apply_chart_TM c ∘ X ∘ inv_chart c)" using ‹open T› (*‹open T›*) by metis } thus "?thesis" (*goal: ‹(k'::enat)-smooth_on (codomain (c::('a, 'b) chart)) (apply_chart_TM c ∘ (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ∘ inv_chart c)›*) apply (rule smooth_on_open_subsetsI (*‹(⋀x. x ∈ ?S ⟹ ∃T. x ∈ T ∧ open T ∧ ?k-smooth_on T ?f) ⟹ ?k-smooth_on ?S ?f›*)) (*goal: ‹k'-smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)›*) using codom_simp (*‹codomain c ∩ inv_chart c -` (carrier ∩ X -` domain_TM c) = codomain c›*) by simp qed definition "smooth_section_of_TM X ≡ section_of_TM X ∧ smooth_from_M_to_TM X" abbreviation set_of_smooth_sections_of_TM (‹𝔛›) where "set_of_smooth_sections_of_TM ≡ {X. smooth_section_of_TM X}" lemma in𝔛_E: assumes "X ∈ 𝔛" "p∈carrier" shows "(∃c∈atlas. p ∈ domain c ∧ X ` domain c ⊆ domain_TM c ∧ smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c))" and "snd (X p) ∈ tangent_space p" and "fst (X p) = p" using assms (*‹X ∈ 𝔛› ‹p ∈ carrier›*) TM_E[of "X p" for p] (*‹X ?pa5 ∈ TM ⟹ snd (X ?pa5) ∈ tangent_space (fst (X ?pa5))› ‹X ?pa5 ∈ TM ⟹ fst (X ?pa5) ∈ carrier›*) apply - (*goals: 1. ‹⟦X ∈ 𝔛; p ∈ carrier; ⋀pa. X pa ∈ TM ⟹ snd (X pa) ∈ tangent_space (fst (X pa)); ⋀pa. X pa ∈ TM ⟹ fst (X pa) ∈ carrier⟧ ⟹ ∃c∈atlas. p ∈ domain c ∧ X ` domain c ⊆ domain_TM c ∧ smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)› 2. ‹⟦X ∈ 𝔛; p ∈ carrier; ⋀pa. X pa ∈ TM ⟹ snd (X pa) ∈ tangent_space (fst (X pa)); ⋀pa. X pa ∈ TM ⟹ fst (X pa) ∈ carrier⟧ ⟹ snd (X p) ∈ tangent_space p› 3. ‹⟦X ∈ 𝔛; p ∈ carrier; ⋀pa. X pa ∈ TM ⟹ snd (X pa) ∈ tangent_space (fst (X pa)); ⋀pa. X pa ∈ TM ⟹ fst (X pa) ∈ carrier⟧ ⟹ fst (X p) = p› discuss goal 1*) apply ((auto simp: smooth_section_of_TM_def (*‹smooth_section_of_TM ?X ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) section_of_TM_def (*‹section_of_TM_on ?S ?X ≡ ∀p∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*) diff_from_M_to_TM_def (*‹k_diff_from_M_to_TM ?k' ?X ≡ ∀x. x ∈ carrier ⟶ (∃c∈atlas. x ∈ domain c ∧ ?X ` domain c ⊆ domain_TM c ∧ ?k'-smooth_on (codomain c) (apply_chart_TM c ∘ ?X ∘ inv_chart c))›*))[1]) (*discuss goal 2*) apply ((auto simp: smooth_section_of_TM_def (*‹smooth_section_of_TM (?X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) section_of_TM_def (*‹section_of_TM_on (?S::'a set) (?X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ≡ ∀p::'a∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*) diff_from_M_to_TM_def (*‹k_diff_from_M_to_TM (?k'::enat) (?X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ≡ ∀x::'a. x ∈ carrier ⟶ (∃c::('a, 'b) chart∈atlas. x ∈ domain c ∧ ?X ` domain c ⊆ domain_TM c ∧ ?k'-smooth_on (codomain c) (apply_chart_TM c ∘ ?X ∘ inv_chart c))›*))[1]) (*top goal: ‹⟦X ∈ 𝔛; p ∈ carrier; ⋀pa. X pa ∈ TM ⟹ snd (X pa) ∈ tangent_space (fst (X pa)); ⋀pa. X pa ∈ TM ⟹ fst (X pa) ∈ carrier⟧ ⟹ snd (X p) ∈ tangent_space p› and 1 goal remains*) apply metis (*discuss goal 3*) apply ((auto simp: smooth_section_of_TM_def (*‹smooth_section_of_TM ?X ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) section_of_TM_def (*‹section_of_TM_on ?S ?X ≡ ∀p∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*) diff_from_M_to_TM_def (*‹k_diff_from_M_to_TM ?k' ?X ≡ ∀x. x ∈ carrier ⟶ (∃c∈atlas. x ∈ domain c ∧ ?X ` domain c ⊆ domain_TM c ∧ ?k'-smooth_on (codomain c) (apply_chart_TM c ∘ ?X ∘ inv_chart c))›*))[1]) (*proven 3 subgoals*) . lemma in𝔛_chartsD: assumes "X ∈ 𝔛" "c∈atlas" shows "smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)" using diff_from_M_to_TM_chartsD[of ∞ X c] (*‹⟦smooth_from_M_to_TM (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)); section_of_TM X; (c::('a, 'b) chart) ∈ atlas⟧ ⟹ smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c)›*) assms (*‹(X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ∈ 𝔛› ‹c ∈ atlas›*) smooth_section_of_TM_def (*‹smooth_section_of_TM ?X ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) by auto end text ‹A vector field is smooth if it is smooth as a map $M \to TM$. As a shortcut, we define a smooth vector field as one that is smooth in the chart - this avoids problems with defining a \<^typ>‹('a × (('a ⇒ real) ⇒ real), 'b) chart›. We also introduce a duality of predicates with strongly related meaning: this allows us to consider vector fields as either maps \<^typ>‹'a ⇒ (('a⇒real)⇒real)›, i.e. mapping a point to a vector; or maps \<^typ>‹'a ⇒ ('a × (('a⇒real)⇒real))›, i.e. sections of $TM$ properly speaking.› context c_manifold begin definition rough_vector_field :: "'a vector_field ⇒ bool" where "rough_vector_field X ≡ extensional0 carrier X ∧ (∀p∈carrier. X p ∈ tangent_space p)" lemma rough_vector_fieldE [elim]: assumes "rough_vector_field X" shows "⋀p. X p ∈ tangent_space p" "extensional0 carrier X" using assms (*‹rough_vector_field X›*) apply - (*goals: 1. ‹⋀p. rough_vector_field X ⟹ X p ∈ tangent_space p› 2. ‹rough_vector_field X ⟹ extensional0 carrier X› discuss goal 1*) apply ((auto simp: rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*) extensional0_outside (*‹⟦?x ∉ ?S; extensional0 ?S ?f⟧ ⟹ ?f ?x = 0›*) tangent_space.mem_zero (*‹0 ∈ tangent_space ?p›*))[1]) (*discuss goal 2*) apply ((auto simp: rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*) extensional0_outside (*‹⟦?x ∉ ?S; extensional0 ?S ?f⟧ ⟹ ?f ?x = 0›*) tangent_space.mem_zero (*‹0 ∈ tangent_space ?p›*))[1]) (*proven 2 subgoals*) . lemma rough_vector_field_subset: assumes "rough_vector_field X" "T ⊆ carrier" shows "rough_vector_field (restrict0 T X)" unfolding rough_vector_field_def (*goal: ‹extensional0 carrier (restrict0 T X) ∧ (∀p∈carrier. restrict0 T X p ∈ tangent_space p)›*) using assms (*‹rough_vector_field (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)› ‹(T::'a set) ⊆ carrier›*) rough_vector_fieldE (*‹rough_vector_field (?X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) ⟹ ?X (?p::'a::{second_countable_topology,t2_space}) ∈ tangent_space ?p› ‹rough_vector_field ?X ⟹ extensional0 carrier ?X›*) tangent_space.mem_zero (*‹0 ∈ tangent_space ?p›*) by (metis (no_types, lifting) extensional0_def (*‹extensional0 ?A ?f = (∀x. x ∉ ?A ⟶ ?f x = 0)›*) restrict0_def (*‹restrict0 ?A ?f ?x = (if ?x ∈ ?A then ?f ?x else 0)›*)) end (* c_manifold *) abbreviation (input) vec_field_apply_fun :: "'a vector_field ⇒ ('a⇒real) ⇒ ('a⇒real)" (infix ‹˝› 100) where "vec_field_apply_fun X f ≡ λp. X p f" lemma (in c_manifold) vec_field_apply_fun_cong: assumes X: "rough_vector_field X" and U: "open U" "U ⊆ carrier" "∀x∈U. f x = g x" and f: "f ∈ diff_fun_space" and g: "g ∈ diff_fun_space" shows "∀p∈U. X p f = X p g" using assms (*‹rough_vector_field X› ‹open U› ‹U ⊆ carrier› ‹∀x::'a::{second_countable_topology,t2_space}∈U::'a::{second_countable_topology,t2_space} set. (f::'a::{second_countable_topology,t2_space} ⇒ real) x = (g::'a::{second_countable_topology,t2_space} ⇒ real) x› ‹f ∈ diff_fun_space› ‹g ∈ diff_fun_space›*) by (auto intro: derivation_eq_localI (*‹⟦open ?U; ?p ∈ ?U; ?U ⊆ carrier; ?X ∈ tangent_space ?p; ?f ∈ diff_fun_space; ?g ∈ diff_fun_space; ⋀x. x ∈ ?U ⟹ ?f x = ?g x⟧ ⟹ ?X ?f = ?X ?g›*) simp: rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*)) lemma (in c_manifold) ext0_vec_field_apply_fun: assumes X: "rough_vector_field X" shows "extensional0 diff_fun_space (vec_field_apply_fun X)" using rough_vector_fieldE[OF X] (*‹X ?p ∈ tangent_space ?p› ‹extensional0 carrier (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) unfolding tangent_space_def extensional0_def (*goal: ‹∀x. x ∉ diff_fun_space ⟶ (λp. X p x) = 0›*) by fastforce subsection ‹Smoothness criterion for a vector field in a single chart.› text ‹A smooth vector field is one that is infinitely differentiable when expanded in the charting Euclidean space using @{thm c_manifold_point.coordinate_vector_representation}. This should be the chart that makes each tangent space into a manifold anyway, but the type constraints are tricky to satisfy.› text ‹Since tangent spaces at the same point differ between a manifold and a submanifold, it's important to note that the differentiability condition can be relaxed to only apply to a subset, but the tangent bundle is always the disjoint union of tangent spaces of the \emph{entire} manifold, which implies the chart function for the tangent space is defined in the entire manifold, not a submanifold.› locale smooth_vector_field_local = c_manifold_local charts ∞ ψ for charts ψ + fixes X assumes vector_field: "∀p∈domain ψ. X p ∈ tangent_space p" and smooth_in_chart: "diff_fun ∞ (charts_submanifold (domain ψ)) (λp. (c_manifold_point.tangent_chart_fun charts ∞ ψ p) (X p))" begin lemma rough_vector_field: "rough_vector_field (restrict0 (domain ψ) X)" apply (simp only: rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goal: ‹rough_vector_field (restrict0 (domain ψ) X)›*) using extensional0_def (*‹extensional0 ?A ?f = (∀x. x ∉ ?A ⟶ ?f x = 0)›*) "sub_ψ_carrier" (*‹sub_ψ.sub.carrier = domain ψ›*) apply fastforce (*top goal: ‹extensional0 carrier (restrict0 (domain ψ) X)› and 1 goal remains*) using vector_field (*‹∀p∈domain ψ. X p ∈ tangent_space p›*) by (metis restrict0_apply_in (*‹(?x::?'a) ∈ (?A::?'a set) ⟹ restrict0 ?A (?f::?'a ⇒ ?'b) ?x = ?f ?x›*) restrict0_apply_out (*‹(?x::?'a) ∉ (?A::?'a set) ⟹ restrict0 ?A (?f::?'a ⇒ ?'b) ?x = (0::?'b)›*) tangent_space.mem_zero (*‹(0::('a ⇒ real) ⇒ real) ∈ tangent_space (?p::'a)›*)) end subsubsection ‹Connecting the types \<^typ>‹'a ⇒ ('a⇒real)⇒real› (used for \<^term>‹smooth_vector_field_local›) and \<^typ>‹'a ⇒ 'a×(('a⇒real)⇒real)› (used for \<^term>‹c_manifold.section_of_TM›).› context c_manifold begin lemma fst_apply_chart_TM_id [simp]: "(fst ∘ (apply_chart_TM ψ ∘ X ∘ inv_chart ψ)) x = x" if "section_of_TM_on (domain ψ) X" "ψ∈atlas" "x∈codomain ψ" for x using that (*‹section_of_TM_on (domain ψ) X› ‹ψ ∈ atlas› ‹(x::'b::euclidean_space) ∈ codomain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)›*) by (simp add: case_prod_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) apply_chart_TM_def (*‹apply_chart_TM (?c::('a, 'b) chart) ≡ λ(p::'a, v::('a ⇒ real) ⇒ real). (apply_chart ?c p, c_manifold_point.tangent_chart_fun (charts::('a, 'b) chart set) ∞ ?c p v)›*) section_of_TM_def (*‹section_of_TM_on (?S::'a set) (?X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ≡ ∀p::'a∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*)) text ‹The justification for the definition of \<^locale>‹smooth_vector_field_local› is the lemma below, connecting it to the smoothness requirement used to define the set of smooth sections \<^term>‹𝔛›.› lemma apply_chart_TM_chartX: fixes X :: "('a ⇒ 'a × (('a ⇒ real) ⇒ real))" and c :: "('a, 'b) chart" and chart_X :: "'a ⇒ 'b" defines "chart_X ≡ λp. (c_manifold_point.tangent_chart_fun charts ∞ c p) (snd (X p))" assumes k: "k=∞" and X: "section_of_TM_on (domain c) X" and c: "c ∈ atlas" shows "smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c) ⟷ diff_fun ∞ (charts_submanifold (domain c)) chart_X" (is ‹?smooth_in_chart_TM c X ⟷ ?diff_domain c chart_X›) proof (-) (*goal: ‹smooth_on (codomain c) (apply_chart_TM c ∘ X ∘ inv_chart c) = diff_fun ∞ (charts_submanifold (domain c)) chart_X›*) interpret c: c_manifold_local charts "∞" c using k (*‹k = ∞›*) c (*‹c ∈ atlas›*) pairwise_compat (*‹⟦?c1.0 ∈ charts; ?c2.0 ∈ charts⟧ ⟹ k-smooth_compat ?c1.0 ?c2.0›*) apply unfold_locales (*goals: 1. ‹⋀c1 c2. ⟦k = ∞; c ∈ atlas; ⋀c1 c2. ⟦c1 ∈ charts; c2 ∈ charts⟧ ⟹ k-smooth_compat c1 c2; c1 ∈ charts; c2 ∈ charts⟧ ⟹ ∞-smooth_compat c1 c2› 2. ‹⟦k = ∞; c ∈ atlas; ⋀c1 c2. ⟦c1 ∈ charts; c2 ∈ charts⟧ ⟹ k-smooth_compat c1 c2⟧ ⟹ c ∈ c_manifold.atlas charts ∞› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . have p: "c_manifold_point charts ∞ c p" if "p∈domain c" for p using that (*‹p ∈ domain c›*) apply unfold_locales (*goal: ‹c_manifold_point charts ∞ c p›*) by simp have X_in_TM: "fst (X p) = p" "snd (X p) ∈ tangent_space p" if "p∈domain c" for p using that (*‹p ∈ domain c›*) X (*‹section_of_TM_on (domain c) X›*) "c.ψ" (*‹c ∈ c.atlas›*) in_TM_E(1) (*‹in_TM ?p ?v ⟹ ?v ∈ tangent_space ?p›*) apply - (*goals: 1. ‹⟦p ∈ domain c; section_of_TM_on (domain c) X; c ∈ c.atlas; ⋀p v. in_TM p v ⟹ v ∈ tangent_space p⟧ ⟹ fst (X p) = p› 2. ‹⟦p ∈ domain c; section_of_TM_on (domain c) X; c ∈ c.atlas; ⋀p v. in_TM p v ⟹ v ∈ tangent_space p⟧ ⟹ snd (X p) ∈ tangent_space p› discuss goal 1*) apply ((auto simp: section_of_TM_def (*‹section_of_TM_on ?S ?X ≡ ∀p∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*))[1]) (*discuss goal 2*) apply ((auto simp: section_of_TM_def (*‹section_of_TM_on ?S ?X ≡ ∀p∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*))[1]) (*proven 2 subgoals*) . have chart_X_alt: "chart_X p = (snd ∘ (c.apply_chart_TM c ∘ X)) p" if "p ∈ domain c" for p by (simp add: that (*‹p ∈ domain c›*) chart_X_def (*‹chart_X ≡ λp. c_manifold_point.tangent_chart_fun charts ∞ c p (snd (X p))›*) c.apply_chart_TM_def (*‹c.apply_chart_TM ?c ≡ λ(p, v). (apply_chart ?c p, c_manifold_point.tangent_chart_fun charts ∞ ?c p v)›*) X_in_TM( (*‹?p3 ∈ domain c ⟹ fst (X ?p3) = ?p3›*) 1) split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) have smooth_comp_snd: "smooth_on (codomain c) (snd∘f)" if "smooth_on (codomain c) f" for f :: "'b ⇒ 'b×'b" using open_codomain (*‹open (codomain ?c)›*) that (*‹smooth_on (codomain c) f›*) by (auto intro!: smooth_on_snd (*‹⟦?k-smooth_on ?S ?f; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. snd (?f x))›*) simp: comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) have c_in_sub_atlas: "c ∈ c.sub_ψ.sub.atlas" by (metis c.ψ (*‹c ∈ c.atlas›*) c.atlas_is_atlas (*‹⟦?a1.0 ∈ c.atlas; ?a2.0 ∈ c.atlas⟧ ⟹ ∞-smooth_compat ?a1.0 ?a2.0›*) c.sub_ψ.sub.maximal_atlas (*‹⟦⋀c'. c' ∈ c.sub_ψ.sub.atlas ⟹ ∞-smooth_compat ?c c'; domain ?c ⊆ c.sub_ψ.sub.carrier⟧ ⟹ ?c ∈ c.sub_ψ.sub.atlas›*) c.sub_ψ.submanifold_atlasE (*‹?c ∈ c.sub_ψ.sub.atlas ⟹ ?c ∈ c.atlas›*) c.sub_ψ_carrier (*‹c.sub_ψ.sub.carrier = domain c›*) set_eq_subset (*‹(?A = ?B) = (?A ⊆ ?B ∧ ?B ⊆ ?A)›*)) show "?thesis" (*goal: ‹smooth_on (codomain c) (c.apply_chart_TM c ∘ X ∘ inv_chart c) = diff_fun ∞ (charts_submanifold (domain c)) chart_X›*) proof (standard) (*goals: 1. ‹smooth_on (codomain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) (c.apply_chart_TM c ∘ (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) ∘ inv_chart c) ⟹ diff_fun ∞ (charts_submanifold (domain c)) (chart_X::'a::{second_countable_topology,t2_space} ⇒ 'b::euclidean_space)› 2. ‹diff_fun ∞ (charts_submanifold (domain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart))) (chart_X::'a::{second_countable_topology,t2_space} ⇒ 'b::euclidean_space) ⟹ smooth_on (codomain c) (c.apply_chart_TM c ∘ (X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) ∘ inv_chart c)›*) assume asm: "?smooth_in_chart_TM c X" (*‹smooth_on (codomain (c::('a, 'b) chart)) (c.apply_chart_TM c ∘ (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)) ∘ inv_chart c)›*) have 1: "smooth_on (codomain c) (snd ∘ (c.apply_chart_TM c ∘ X ∘ inv_chart c))" using smooth_comp_snd[OF asm] (*‹smooth_on (codomain c) (snd ∘ (c.apply_chart_TM c ∘ X ∘ inv_chart c))›*) by (simp only: comp_assoc (*‹?f ∘ ?g ∘ ?h = ?f ∘ (?g ∘ ?h)›*)) have 2: "smooth_on (codomain c) ((λx. x) ∘ chart_X ∘ inv_chart c)" by (auto intro!: smooth_on_cong[OF 1] (*‹⟦open (codomain c); ⋀x. x ∈ codomain c ⟹ ?f x = (snd ∘ (c.apply_chart_TM c ∘ X ∘ inv_chart c)) x⟧ ⟹ smooth_on (codomain c) ?f›*) simp: chart_X_alt (*‹?p3 ∈ domain c ⟹ chart_X ?p3 = (snd ∘ (c.apply_chart_TM c ∘ X)) ?p3›*)) { fix x assume "x ∈ domain c" (*‹(x::'a) ∈ domain (c::('a, 'b) chart)›*) then interpret x: c_manifold_point charts "∞" c x using p (*‹?p3 ∈ domain c ⟹ c_manifold_point charts ∞ c ?p3›*) by blast have "∃c1 ∈ c.sub_ψ.sub.atlas. ∃c2 ∈ manifold_eucl.atlas ∞. x ∈ domain c1 ∧ chart_X ` domain c1 ⊆ domain c2 ∧ smooth_on (codomain c1) (apply_chart c2 ∘ chart_X ∘ inv_chart c1)" using "2" (*‹smooth_on (codomain (c::('a, 'b) chart)) ((λx::'b. x) ∘ (chart_X::'a ⇒ 'b) ∘ inv_chart c)›*) c_in_sub_atlas (*‹c ∈ c.sub_ψ.sub.atlas›*) apply (intro bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) (*goal: ‹∃c1∈c.sub_ψ.sub.atlas. ∃c2∈manifold_eucl.atlas ∞. x ∈ domain c1 ∧ chart_X ` domain c1 ⊆ domain c2 ∧ smooth_on (codomain c1) (apply_chart c2 ∘ chart_X ∘ inv_chart c1)›*) by auto } then show "?diff_domain c chart_X" unfolding diff_fun_def diff_def diff_axioms_def (*goal: ‹c_manifolds ∞ (charts_submanifold (domain c)) charts_eucl ∧ (∀x. x ∈ c.sub_ψ.sub.carrier ⟶ (∃c1∈c.sub_ψ.sub.atlas. ∃c2∈manifold_eucl.atlas ∞. x ∈ domain c1 ∧ chart_X ` domain c1 ⊆ domain c2 ∧ smooth_on (codomain c1) (apply_chart c2 ∘ chart_X ∘ inv_chart c1)))›*) using "c.sub_ψ.sub.manifold_eucl.c_manifolds_axioms" (*‹c_manifolds ∞ (charts_submanifold (domain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart))) charts_eucl›*) "c.sub_ψ_carrier" (*‹c.sub_ψ.sub.carrier = domain c›*) by blast next (*goal: ‹diff_fun ∞ (charts_submanifold (domain c)) chart_X ⟹ smooth_on (codomain c) (c.apply_chart_TM c ∘ X ∘ inv_chart c)›*) assume asm: "?diff_domain c chart_X" (*‹diff_fun ∞ (charts_submanifold (domain (c::('a, 'b) chart))) (chart_X::'a ⇒ 'b)›*) interpret asm_df: diff_fun "∞" "charts_submanifold (domain c)" "snd ∘ (c.apply_chart_TM c ∘ X)" using diff_fun.diff_fun_cong[OF asm chart_X_alt] (*‹(⋀x. x ∈ c.sub_ψ.sub.carrier ⟹ x ∈ domain c) ⟹ diff_fun ∞ (charts_submanifold (domain c)) (snd ∘ (c.apply_chart_TM c ∘ X))›*) by fastforce have codomain_c_eq: "codomain c = codomain c ∩ inv_chart c -` (c.sub_ψ.sub.carrier ∩ (snd ∘ (c.apply_chart_TM c ∘ X)) -` domain chart_eucl)" using "c.ψ" (*‹c ∈ c.atlas›*) apply - (*goal: ‹codomain (c::('a, 'b) chart) = codomain c ∩ inv_chart c -` (c.sub_ψ.sub.carrier ∩ (snd ∘ (c.apply_chart_TM c ∘ (X::'a ⇒ 'a × (('a ⇒ real) ⇒ real)))) -` domain chart_eucl)›*) by (msorry) let ?X = "(c.apply_chart_TM c ∘ X ∘ inv_chart c)" let ?X' = "λx. (x, (snd∘?X) x)" have X_eq: "?X x = ?X' x" if "x∈codomain c" for x using c.fst_apply_chart_TM_id (*‹⟦c.section_of_TM_on (domain ?ψ) ?X; ?ψ ∈ c.atlas; ?x ∈ codomain ?ψ⟧ ⟹ (fst ∘ (c.apply_chart_TM ?ψ ∘ ?X ∘ inv_chart ?ψ)) ?x = ?x›*) X (*‹section_of_TM_on (domain c) X›*) k (*‹k = ∞›*) that (*‹x ∈ codomain c›*) by (metis c (*‹(c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∈ atlas›*) comp_apply (*‹((?f::?'b::type ⇒ ?'a::type) ∘ (?g::?'c::type ⇒ ?'b::type)) (?x::?'c::type) = ?f (?g ?x)›*) prod.collapse (*‹(fst (?prod::?'a::type × ?'b::type), snd ?prod) = ?prod›*)) have smooth_on_snd_chart_TM: "smooth_on (codomain c) (snd ∘ ?X)" using asm_df.diff_chartsD[OF c_in_sub_atlas, of chart_eucl] (*‹chart_eucl ∈ manifold_eucl.atlas ∞ ⟹ smooth_on (codomain c ∩ inv_chart c -` (c.sub_ψ.sub.carrier ∩ (snd ∘ (c.apply_chart_TM c ∘ X)) -` domain chart_eucl)) (apply_chart chart_eucl ∘ (snd ∘ (c.apply_chart_TM c ∘ X)) ∘ inv_chart c)›*) codomain_c_eq (*‹codomain c = codomain c ∩ inv_chart c -` (c.sub_ψ.sub.carrier ∩ (snd ∘ (c.apply_chart_TM c ∘ X)) -` domain chart_eucl)›*) by (auto simp add: comp_assoc (*‹?f ∘ ?g ∘ ?h = ?f ∘ (?g ∘ ?h)›*) smooth_on_cong (*‹⟦?k-smooth_on ?S ?g; open ?S; ⋀x. x ∈ ?S ⟹ ?f x = ?g x⟧ ⟹ ?k-smooth_on ?S ?f›*)) show "?smooth_in_chart_TM c X" apply (rule smooth_on_cong[OF _ _ X_eq] (*‹⟦?k-smooth_on ?S (λx. (?x4 x, (snd ∘ (c.apply_chart_TM c ∘ X ∘ inv_chart c)) (?x4 x))); open ?S; ⋀x. x ∈ ?S ⟹ ?x4 x ∈ codomain c⟧ ⟹ ?k-smooth_on ?S (λx. (c.apply_chart_TM c ∘ X ∘ inv_chart c) (?x4 x))›*)) (*goal: ‹smooth_on (codomain c) (c.apply_chart_TM c ∘ X ∘ inv_chart c)›*) using smooth_on_Pair (*‹⟦open ?S; ?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g⟧ ⟹ ?k-smooth_on ?S (λx. (?f x, ?g x))›*) smooth_on_id (*‹?k-smooth_on ?S (λx. x)›*) smooth_on_snd_chart_TM (*‹smooth_on (codomain c) (snd ∘ (c.apply_chart_TM c ∘ X ∘ inv_chart c))›*) (*goals: 1. ‹smooth_on (codomain c) (λx. (x, (snd ∘ (c.apply_chart_TM c ∘ X ∘ inv_chart c)) x))› 2. ‹open (codomain c)› 3. ‹⋀x. x ∈ codomain c ⟹ x ∈ codomain c› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*proven 3 subgoals*) . qed qed end (* c_manifold *) context smooth_vector_field_local begin definition "chart_X ≡ λp. (c_manifold_point.tangent_chart_fun charts ∞ ψ p) (X p)" lemma smooth_in_chart_X [simp]: "diff_fun ∞ (charts_submanifold (domain ψ)) chart_X" unfolding chart_X_def (*goal: ‹diff_fun ∞ (charts_submanifold (domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart))) (λp::'a::{second_countable_topology,t2_space}. c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ ψ p ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p))›*) using smooth_in_chart (*‹diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))›*) by simp lemma apply_chart_TM_chart_X: "smooth_on (codomain ψ) (apply_chart_TM ψ ∘ (λp. (p, X p)) ∘ inv_chart ψ) ⟷ diff_fun ∞ (charts_submanifold (domain ψ)) chart_X" unfolding chart_X_def (*goal: ‹smooth_on (codomain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) (apply_chart_TM ψ ∘ (λp::'a::{second_countable_topology,t2_space}. (p, (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p)) ∘ inv_chart ψ) = diff_fun ∞ (charts_submanifold (domain ψ)) (λp::'a::{second_countable_topology,t2_space}. c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ ψ p (X p))›*) apply (rule apply_chart_TM_chartX[of ψ "λp. (p, X p)", simplified] (*‹section_of_TM_on (domain ψ) (λp. (p, X p)) ⟹ smooth_on (codomain ψ) (apply_chart_TM ψ ∘ (λp. (p, X p)) ∘ inv_chart ψ) = diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))›*)) (*goal: ‹smooth_on (codomain ψ) (apply_chart_TM ψ ∘ (λp. (p, X p)) ∘ inv_chart ψ) = diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))›*) unfolding section_of_TM_def in_TM_def (*goal: ‹∀p∈domain ψ. (p, X p) ∈ {(p, v). p ∈ carrier ∧ v ∈ tangent_space p} ∧ fst (p, X p) = p›*) apply (clarsimp, intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goal: ‹∀p∈domain ψ. (p, X p) ∈ {(p, v). p ∈ carrier ∧ v ∈ tangent_space p} ∧ fst (p, X p) = p›*) using "ψ" (*‹ψ ∈ atlas›*) vector_field (*‹∀p::'a::{second_countable_topology,t2_space}∈domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart). (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p ∈ tangent_space p›*) apply - (*goals: 1. ‹⋀p. ⟦p ∈ domain ψ; ψ ∈ atlas; ∀p∈domain ψ. X p ∈ tangent_space p⟧ ⟹ p ∈ carrier› 2. ‹⋀p. ⟦p ∈ domain ψ; ψ ∈ atlas; ∀p∈domain ψ. X p ∈ tangent_space p⟧ ⟹ X p ∈ tangent_space p› discuss goal 1*) apply blast (*discuss goal 2*) apply auto (*proven 2 subgoals*) . end subsubsection ‹Some theorems about smooth vector fields, locally and globally.› context c_manifold_local begin text ‹It is often convenient to keep a stronger handle on which chart we're (locally) working in. Since the first component of the \<^term>‹apply_chart_TM› is just the identity, we can safely omit it for a lot of our reasoning about smoothness in a chart (see @{thm fst_apply_chart_TM_id} and @{thm apply_chart_TM_chartX}).› definition vector_field_component :: "('a ⇒ (('a ⇒ real) ⇒ real)) ⇒ 'b ⇒ 'a ⇒ real" where "vector_field_component X i ≡ λp. (c_manifold_point.component_function charts k ψ p) (X p) i" definition coordinate_vector_field :: "'b ⇒ ('a ⇒ (('a ⇒ real) ⇒ real))" where "coordinate_vector_field i p ≡ c_manifold_point.coordinate_vector charts k ψ p i" text ‹Eqn. 8.2, page 175, Lee 2012› lemma vector_field_local_representation: assumes k: "k = ∞" and X: "rough_vector_field X" and p: "p∈domain ψ" shows "X p = (∑i∈Basis. (vector_field_component X i p) *⇩R (coordinate_vector_field i p))" unfolding vector_field_component_def coordinate_vector_field_def (*goal: ‹X p = (∑i∈Basis. c_manifold_point.component_function charts k ψ p (X p) i *⇩R c_manifold_point.coordinate_vector charts k ψ p i)›*) apply (rule c_manifold_point.coordinate_vector_representation (*‹⟦c_manifold_point (?charts::(?'a::{second_countable_topology,t2_space}, ?'b::euclidean_space) chart set) (?k::enat) (?ψ::(?'a::{second_countable_topology,t2_space}, ?'b::euclidean_space) chart) (?p::?'a::{second_countable_topology,t2_space}); (?v::(?'a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) ∈ c_manifold.tangent_space ?charts ?k ?p; ?k = ∞⟧ ⟹ ?v = (∑i::?'b::euclidean_space∈Basis. c_manifold_point.component_function ?charts ?k ?ψ ?p ?v i *⇩R c_manifold_point.coordinate_vector ?charts ?k ?ψ ?p i)›*)) (*goal: ‹X p = (∑i∈Basis. c_manifold_point.component_function charts k ψ p (X p) i *⇩R c_manifold_point.coordinate_vector charts k ψ p i)›*) apply unfold_locales (*top goal: ‹c_manifold_point (charts::('a, 'b) chart set) (k::enat) (ψ::('a, 'b) chart) (p::'a)› and 2 goals remain*) subgoal for using p (*‹p ∈ domain ψ›*) rough_vector_fieldE[OF X] (*‹X ?p ∈ tangent_space ?p› ‹extensional0 carrier X›*) "sub_ψ_carrier" (*‹sub_ψ.sub.carrier = domain ψ›*) by blast subgoal for using p (*‹(p::'a) ∈ domain (ψ::('a, 'b) chart)›*) rough_vector_fieldE[OF X] (*‹(X::'a ⇒ ('a ⇒ real) ⇒ real) (?p::'a) ∈ tangent_space ?p› ‹extensional0 carrier X›*) in_carrier_atlasI[OF ψ] (*‹?x ∈ domain ψ ⟹ ?x ∈ carrier›*) by blast by (simp add: k (*‹k = ∞›*)) definition local_coord_at :: "'a ⇒ 'b ⇒ 'a ⇒ real" where "local_coord_at q i ≡ restrict0 (domain ψ) (λy::'a. (ψ y - ψ q) ∙ i)" lemma local_coord_diff_fun: assumes k: "k=∞" and q: "q ∈ domain ψ" shows "local_coord_at q i ∈ sub_ψ.sub.diff_fun_space" proof (-) (*goal: ‹local_coord_at q i ∈ sub_ψ.sub.diff_fun_space›*) note local_simps[simp] = local_coord_at_def (*‹local_coord_at ?q ?i ≡ restrict0 (domain ψ) (λy. (apply_chart ψ y - apply_chart ψ ?q) ∙ ?i)›*) have "diff_fun k (charts_submanifold (domain ψ)) ((λy::'a. (ψ y - ψ q) ∙ i))" apply (rule diff_fun_compose[unfolded o_def, of k _ charts_eucl ψ] (*‹⟦diff k ?M1.0 charts_eucl (apply_chart ψ); diff_fun k charts_eucl ?g⟧ ⟹ diff_fun k ?M1.0 (λx. ?g (apply_chart ψ x))›*)) (*goal: ‹diff_fun k (charts_submanifold (domain ψ)) (λy. (apply_chart ψ y - apply_chart ψ q) ∙ i)›*) using "diff_fun_ψ.diff_axioms" (*‹diff k (charts_submanifold (domain ψ)) charts_eucl (apply_chart ψ)›*) k (*‹k = ∞›*) apply - (*goals: 1. ‹⟦diff k (charts_submanifold (domain ψ)) charts_eucl (apply_chart ψ); k = ∞⟧ ⟹ diff k (charts_submanifold (domain ψ)) charts_eucl (apply_chart ψ)› 2. ‹⟦diff k (charts_submanifold (domain ψ)) charts_eucl (apply_chart ψ); k = ∞⟧ ⟹ diff_fun k charts_eucl (λa. (a - apply_chart ψ q) ∙ i)› discuss goal 1*) apply ((auto intro!: diff_fun_charts_euclI (*‹(?k::enat)-smooth_on UNIV (?g::?'a::euclidean_space ⇒ ?'b::euclidean_space) ⟹ diff_fun ?k charts_eucl ?g›*) smooth_on_inner (*‹⟦(?k::enat)-smooth_on (?S::?'d::real_normed_vector set) (?f::?'d::real_normed_vector ⇒ ?'a::real_inner); ?k-smooth_on ?S (?g::?'d::real_normed_vector ⇒ ?'a::real_inner); open ?S⟧ ⟹ ?k-smooth_on ?S (λx::?'d::real_normed_vector. ?f x ∙ ?g x)›*) smooth_on_minus (*‹⟦(?k::enat)-smooth_on (?S::?'a::real_normed_vector set) (?f::?'a::real_normed_vector ⇒ ?'b::real_normed_vector); ?k-smooth_on ?S (?g::?'a::real_normed_vector ⇒ ?'b::real_normed_vector); open ?S⟧ ⟹ ?k-smooth_on ?S (λx::?'a::real_normed_vector. ?f x - ?g x)›*))[1]) (*discuss goal 2*) apply ((auto intro!: diff_fun_charts_euclI (*‹?k-smooth_on UNIV ?g ⟹ diff_fun ?k charts_eucl ?g›*) smooth_on_inner (*‹⟦?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. ?f x ∙ ?g x)›*) smooth_on_minus (*‹⟦?k-smooth_on ?S ?f; ?k-smooth_on ?S ?g; open ?S⟧ ⟹ ?k-smooth_on ?S (λx. ?f x - ?g x)›*))[1]) (*proven 2 subgoals*) . from diff_fun.diff_fun_cong[OF this] (*‹(⋀x. x ∈ sub_ψ.sub.carrier ⟹ (apply_chart ψ x - apply_chart ψ q) ∙ i = ?g x) ⟹ diff_fun k (charts_submanifold (domain ψ)) ?g›*) q (*‹q ∈ domain ψ›*) have "diff_fun k (charts_submanifold (domain ψ)) (local_coord_at q i)" by simp then show "local_coord_at q i ∈ sub_ψ.sub.diff_fun_space" apply auto (*goal: ‹local_coord_at (q::'a) (i::'b) ∈ sub_ψ.sub.diff_fun_space›*) by (metis restrict0_subset (*‹?B ⊆ ?A ⟹ restrict0 ?A (restrict0 ?B ?f) = restrict0 ?B ?f›*) sub_ψ (*‹ψ ∈ sub_ψ.sub.atlas›*) sub_ψ.sub.domain_atlas_subset_carrier (*‹?c ∈ sub_ψ.sub.atlas ⟹ domain ?c ⊆ sub_ψ.sub.carrier›*) sub_ψ.sub.restrict0_in_fun_space (*‹diff_fun k (charts_submanifold (domain ψ)) ?f ⟹ restrict0 sub_ψ.sub.carrier ?f ∈ sub_ψ.sub.diff_fun_space›*)) qed lemma vector_apply_coord_at: fixes x⇩ψ defines [simp]: "x⇩ψ ≡ local_coord_at" assumes q: "q∈domain ψ" and p:"p∈domain ψ" and X: "X ∈ tangent_space q" and k: "k=∞" shows "(dι¯ q) X (x⇩ψ p i) = (dι¯ q) X (x⇩ψ q i)" proof (-) (*goal: ‹dι¯ q X (x⇩ψ p i) = dι¯ q X (x⇩ψ q i)›*) note local_simps[simp] = local_coord_at_def (*‹local_coord_at ?q ?i ≡ restrict0 (domain ψ) (λy. (apply_chart ψ y - apply_chart ψ ?q) ∙ ?i)›*) have "diff_x⇩ψi'": "x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space" if "q ∈ domain ψ" for i and q using local_coord_diff_fun[OF k that] (*‹local_coord_at q ?i ∈ sub_ψ.sub.diff_fun_space›*) by simp interpret q: c_manifold_point charts k "ψ" q using q (*‹q ∈ domain ψ›*) "ψ" (*‹ψ ∈ atlas›*) apply unfold_locales (*goal: ‹c_manifold_point charts k ψ q›*) by simp let ?x⇩q = "x⇩ψ q" have Xq: "q.dRestr2 X ∈ q.T⇩pU" using bij_betwE[OF q.bij_betw_dι_inv] (*‹∀a∈q.T⇩pM. q.dRestr2 a ∈ q.T⇩pU›*) X (*‹X ∈ q.T⇩pM›*) by simp { fix x' and b assume "x' ∈ domain ψ" (*‹(x'::'a) ∈ domain (ψ::('a, 'b) chart)›*) have Dp_simp: "frechet_derivative ((x⇩ψ p' i) ∘ inv_chart ψ) (at (ψ x')) = frechet_derivative ((λy. y ∙ i)) (at (ψ x'))" for p' proof (-) (*goal: ‹frechet_derivative (x⇩ψ p' i ∘ inv_chart ψ) (at (apply_chart ψ x')) = frechet_derivative (λy. y ∙ i) (at (apply_chart ψ x'))›*) have "frechet_derivative ((x⇩ψ p' i) ∘ inv_chart ψ) (at (ψ x')) = frechet_derivative ((λy. (y - ψ p') ∙ i)) (at (ψ x'))" apply (rule frechet_derivative_transform_within_open[OF _ open_codomain[of ψ], symmetric] (*‹⟦?f differentiable at ?x; ?x ∈ codomain ψ; ⋀x. x ∈ codomain ψ ⟹ ?f x = ?g x⟧ ⟹ frechet_derivative ?g (at ?x) = frechet_derivative ?f (at ?x)›*)) (*goals: 1. ‹(λy. (y - apply_chart ψ p') ∙ i) differentiable at (apply_chart ψ x')› 2. ‹apply_chart ψ x' ∈ codomain ψ› 3. ‹⋀x. x ∈ codomain ψ ⟹ (x - apply_chart ψ p') ∙ i = (x⇩ψ p' i ∘ inv_chart ψ) x› discuss goal 1*) apply (simp add: ‹x' ∈ domain ψ›) (*discuss goal 2*) apply (simp add: ‹x' ∈ domain ψ›) (*discuss goal 3*) apply (simp add: ‹x' ∈ domain ψ›) (*proven 3 subgoals*) . then show "?thesis" (*goal: ‹frechet_derivative ((x⇩ψ::'a ⇒ 'b ⇒ 'a ⇒ real) (p'::'a) (i::'b) ∘ inv_chart (ψ::('a, 'b) chart)) (at (apply_chart ψ (x'::'a))) = frechet_derivative (λy::'b. y ∙ i) (at (apply_chart ψ x'))›*) by (auto simp: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 56 facts*) zero_fun_def (*‹0 = (λx. 0)›*) intro!: frechet_derivative_at[symmetric] (*‹(?f has_derivative ?s) (at ?x) ⟹ frechet_derivative ?f (at ?x) = ?s›*) has_derivative_diff[where g'=0, simplified] (*‹⟦(?f has_derivative ?f') ?F; (?g has_derivative 0) ?F⟧ ⟹ ((λx. ?f x - ?g x) has_derivative ?f') ?F›*) derivative_intros (*‹((λx. x) has_derivative (λx. x)) ?F› ‹(id has_derivative id) ?F› ‹((λx. ?c) has_derivative (λx. 0)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?r *⇩R ?g x) has_derivative (λx. ?r *⇩R ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x *⇩R ?x) has_derivative (λx. ?g' x *⇩R ?x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?x * ?g x) has_derivative (λx. ?x * ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x * ?y) has_derivative (λx. ?g' x * ?y)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. of_real (?g x)) has_derivative (λx. of_real (?g' x))) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x + ?g x) has_derivative (λx. ?f' x + ?g' x)) ?F› ‹(⋀i. i ∈ ?I ⟹ (?f i has_derivative ?f' i) ?F) ⟹ ((λx. ∑i∈?I. ?f i x) has_derivative (λx. ∑i∈?I. ?f' i x)) ?F› ‹(?f has_derivative ?f') ?F ⟹ ((λx. - ?f x) has_derivative (λx. - ?f' x)) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x - ?g x) has_derivative (λx. ?f' x - ?g' x)) ?F› and more 167 facts*)) qed have "frechet_derivative ((x⇩ψ p i) ∘ inv_chart ψ) (at (ψ x')) b = frechet_derivative ((x⇩ψ q i) ∘ inv_chart ψ) (at (ψ x')) b" by (simp only: Dp_simp (*‹frechet_derivative (x⇩ψ ?p'3 i ∘ inv_chart ψ) (at (apply_chart ψ x')) = frechet_derivative (λy. y ∙ i) (at (apply_chart ψ x'))›*)) } note deriv_eq = this (*‹(?x'5::'a::{second_countable_topology,t2_space}) ∈ domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ⟹ frechet_derivative ((x⇩ψ::'a::{second_countable_topology,t2_space} ⇒ 'b::euclidean_space ⇒ 'a::{second_countable_topology,t2_space} ⇒ real) (p::'a::{second_countable_topology,t2_space}) (i::'b::euclidean_space) ∘ inv_chart ψ) (at (apply_chart ψ ?x'5)) (?b5::'b::euclidean_space) = frechet_derivative (x⇩ψ (q::'a::{second_countable_topology,t2_space}) i ∘ inv_chart ψ) (at (apply_chart ψ ?x'5)) ?b5›*) show "?thesis" (*goal: ‹q.dRestr2 X (x⇩ψ p i) = q.dRestr2 X (x⇩ψ q i)›*) apply (rule sub_ψ.sub.derivation_eq_localI'[OF k q _ _ Xq, of ψ] (*‹⟦domain (ψ::('a, 'b) chart) ⊆ domain ψ; ψ ∈ sub_ψ.sub.atlas; (?f::'a ⇒ real) ∈ sub_ψ.sub.diff_fun_space; (?g::'a ⇒ real) ∈ sub_ψ.sub.diff_fun_space; ⋀x::'a. x ∈ domain ψ ⟹ frechet_derivative (?f ∘ inv_chart ψ) (at (apply_chart ψ x)) = frechet_derivative (?g ∘ inv_chart ψ) (at (apply_chart ψ x))⟧ ⟹ q.dRestr2 (X::('a ⇒ real) ⇒ real) ?f = q.dRestr2 X ?g›*)) (*goal: ‹q.dRestr2 X (x⇩ψ p i) = q.dRestr2 X (x⇩ψ q i)›*) using local_coord_diff_fun (*‹⟦k = ∞; ?q ∈ domain ψ⟧ ⟹ local_coord_at ?q ?i ∈ sub_ψ.sub.diff_fun_space›*) "diff_x⇩ψi'" (*‹(?q3::'a) ∈ domain (ψ::('a, 'b) chart) ⟹ (x⇩ψ::'a ⇒ 'b ⇒ 'a ⇒ real) ?q3 (?i3::'b) ∈ sub_ψ.sub.diff_fun_space›*) k (*‹(k::enat) = ∞›*) deriv_eq (*‹?x'5 ∈ domain ψ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ ?x'5)) ?b5 = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ ?x'5)) ?b5›*) "sub_ψ" (*‹ψ ∈ sub_ψ.sub.atlas›*) apply - (*goals: 1. ‹⟦⋀q i. ⟦k = ∞; q ∈ domain ψ⟧ ⟹ local_coord_at q i ∈ sub_ψ.sub.diff_fun_space; ⋀q i. q ∈ domain ψ ⟹ x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space; k = ∞; ⋀x' b. x' ∈ domain ψ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ x')) b = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ x')) b; ψ ∈ sub_ψ.sub.atlas⟧ ⟹ domain ψ ⊆ domain ψ› 2. ‹⟦⋀q i. ⟦k = ∞; q ∈ domain ψ⟧ ⟹ local_coord_at q i ∈ sub_ψ.sub.diff_fun_space; ⋀q i. q ∈ domain ψ ⟹ x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space; k = ∞; ⋀x' b. x' ∈ domain ψ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ x')) b = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ x')) b; ψ ∈ sub_ψ.sub.atlas⟧ ⟹ ψ ∈ sub_ψ.sub.atlas› 3. ‹⟦⋀q i. ⟦k = ∞; q ∈ domain ψ⟧ ⟹ local_coord_at q i ∈ sub_ψ.sub.diff_fun_space; ⋀q i. q ∈ domain ψ ⟹ x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space; k = ∞; ⋀x' b. x' ∈ domain ψ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ x')) b = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ x')) b; ψ ∈ sub_ψ.sub.atlas⟧ ⟹ x⇩ψ p i ∈ sub_ψ.sub.diff_fun_space› 4. ‹⟦⋀q i. ⟦k = ∞; q ∈ domain ψ⟧ ⟹ local_coord_at q i ∈ sub_ψ.sub.diff_fun_space; ⋀q i. q ∈ domain ψ ⟹ x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space; k = ∞; ⋀x' b. x' ∈ domain ψ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ x')) b = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ x')) b; ψ ∈ sub_ψ.sub.atlas⟧ ⟹ x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space› 5. ‹⋀x. ⟦x ∈ domain ψ; ⋀q i. ⟦k = ∞; q ∈ domain ψ⟧ ⟹ local_coord_at q i ∈ sub_ψ.sub.diff_fun_space; ⋀q i. q ∈ domain ψ ⟹ x⇩ψ q i ∈ sub_ψ.sub.diff_fun_space; k = ∞; ⋀x' b. x' ∈ domain ψ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ x')) b = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ x')) b; ψ ∈ sub_ψ.sub.atlas⟧ ⟹ frechet_derivative (x⇩ψ p i ∘ inv_chart ψ) (at (apply_chart ψ x)) = frechet_derivative (x⇩ψ q i ∘ inv_chart ψ) (at (apply_chart ψ x))› discuss goal 1*) apply ((auto simp: p (*‹p ∈ domain ψ›*) sub_ψ.sub.diff_fun_space_def (*‹sub_ψ.sub.diff_fun_space = {f. diff_fun k (charts_submanifold (domain ψ)) f ∧ extensional0 sub_ψ.sub.carrier f}›*))[1]) (*discuss goal 2*) apply ((auto simp: p (*‹p ∈ domain ψ›*) sub_ψ.sub.diff_fun_space_def (*‹sub_ψ.sub.diff_fun_space = {f. diff_fun k (charts_submanifold (domain ψ)) f ∧ extensional0 sub_ψ.sub.carrier f}›*))[1]) (*discuss goal 3*) apply ((auto simp: p (*‹p ∈ domain ψ›*) sub_ψ.sub.diff_fun_space_def (*‹sub_ψ.sub.diff_fun_space = {f. diff_fun k (charts_submanifold (domain ψ)) f ∧ extensional0 sub_ψ.sub.carrier f}›*))[1]) (*discuss goal 4*) apply ((auto simp: p (*‹p ∈ domain ψ›*) sub_ψ.sub.diff_fun_space_def (*‹sub_ψ.sub.diff_fun_space = {f. diff_fun k (charts_submanifold (domain ψ)) f ∧ extensional0 sub_ψ.sub.carrier f}›*))[1]) (*discuss goal 5*) apply ((auto simp: p (*‹p ∈ domain ψ›*) sub_ψ.sub.diff_fun_space_def (*‹sub_ψ.sub.diff_fun_space = {f. diff_fun k (charts_submanifold (domain ψ)) f ∧ extensional0 sub_ψ.sub.carrier f}›*))[1]) (*proven 5 subgoals*) . qed end (*c_manifold_local*) context c_manifold begin abbreviation (input) "real_linear_on S1 S2 ≡ linear_on S1 S2 scaleR scaleR" ― ‹Sometimes we want to apply a vector field meaningfully to a function that is in the \<^term>‹c_manifold.diff_fun_space› of a submanifold (e.g. a single chart). For this to make sense, the function has to be in the correct space, and the submanifold's carrier set has to be open.› definition vec_field_apply_fun_in_at :: "('a vector_field) ⇒ ('a⇒real) ⇒ 'a set ⇒ 'a ⇒ real" where "vec_field_apply_fun_in_at X f U q = restrict0 (tangent_space q) (the_inv_into (c_manifold.tangent_space (charts_submanifold U) k q) (diff.push_forward k (charts_submanifold U) charts (λx. x))) (X q) f" abbreviation vec_field_restr :: "('a vector_field) ⇒ 'a set ⇒ ('a vector_field)" where "vec_field_restr X U q f ≡ restrict0 U (vec_field_apply_fun_in_at X f U) q" notation vec_field_restr (‹_↾_› [60,60]) lemma (in smooth_manifold) vec_field_restr: "(X↾U) p ∈ c_manifold.tangent_space (charts_submanifold U) ∞ p" if "open U" "U ⊆ carrier" "rough_vector_field X" for U X proof (-) (*goal: ‹(X::'a ⇒ ('a ⇒ real) ⇒ real)↾(U::'a set) (p::'a) ∈ c_manifold.tangent_space (charts_submanifold U) ∞ p›*) interpret U: submanifold charts "∞" U apply unfold_locales (*goal: ‹submanifold charts ∞ U›*) by (simp add: that (*‹open U› ‹U ⊆ carrier› ‹rough_vector_field X›*)) have U_simps[simp]: "U.sub.carrier = U" using that (*‹open (U::'a set)› ‹U ⊆ carrier› ‹rough_vector_field X›*) by auto show "?thesis" (*goal: ‹X↾U p ∈ U.sub.tangent_space p›*) apply (cases "p∈U") (*goal: ‹X↾U p ∈ U.sub.tangent_space p›*) subgoal for apply (simp add: vec_field_apply_fun_in_at_def (*‹vec_field_apply_fun_in_at ?X ?f ?U ?q = restrict0 (tangent_space ?q) (the_inv_into (c_manifold.tangent_space (charts_submanifold ?U) ∞ ?q) (diff.push_forward ∞ (charts_submanifold ?U) charts (λx. x))) (?X ?q) ?f›*)) (*goal: ‹p ∈ U ⟹ X↾U p ∈ U.sub.tangent_space p›*) using bij_betwE[OF U.bij_betw_dι_inv] (*‹?p1 ∈ U.sub.carrier ⟹ ∀a∈tangent_space ?p1. restrict0 (tangent_space ?p1) (the_inv_into (U.sub.tangent_space ?p1) U.inclusion.push_forward) a ∈ U.sub.tangent_space ?p1›*) that (*‹open U› ‹U ⊆ carrier› ‹rough_vector_field X›*) rough_vector_fieldE(1) (*‹rough_vector_field ?X ⟹ ?X ?p ∈ tangent_space ?p›*) by auto by (simp add: U.sub.diff_fun_space.linear_zero (*‹linear_on U.sub.diff_fun_space UNIV (*⇩R) (*⇩R) (λx. 0)›*) U.sub.tangent_spaceI (*‹⟦extensional0 U.sub.diff_fun_space ?X; linear_on U.sub.diff_fun_space UNIV (*⇩R) (*⇩R) ?X; ⋀f g. ⟦f ∈ U.sub.diff_fun_space; g ∈ U.sub.diff_fun_space⟧ ⟹ ?X (f * g) = f ?p * ?X g + g ?p * ?X f⟧ ⟹ ?X ∈ U.sub.tangent_space ?p›*) extensional0_def (*‹extensional0 ?A ?f = (∀x. x ∉ ?A ⟶ ?f x = 0)›*)) qed lemma vec_field_apply_fun_alt': assumes "open U" "q∈U" "f ∈ c_manifold.diff_fun_space (charts_submanifold U) k" "rough_vector_field X" shows "vec_field_apply_fun_in_at X f U q = (the_inv_into (c_manifold.tangent_space (charts_submanifold U) k q) (diff.push_forward k (charts_submanifold U) charts (λx. x))) (X q) f" using rough_vector_fieldE(1)[OF assms ( 4 )] (*‹X ?p ∈ tangent_space ?p›*) by (auto simp: vec_field_apply_fun_in_at_def (*‹vec_field_apply_fun_in_at ?X ?f ?U ?q = restrict0 (tangent_space ?q) (the_inv_into (c_manifold.tangent_space (charts_submanifold ?U) k ?q) (diff.push_forward k (charts_submanifold ?U) charts (λx. x))) (?X ?q) ?f›*) assms( (*‹open U› ‹q ∈ U› ‹f ∈ c_manifold.diff_fun_space (charts_submanifold U) k›*) 1-3)) lemma vec_field_apply_fun_alt: assumes "open U" "q∈U" "f ∈ c_manifold.diff_fun_space (charts_submanifold U) k" "rough_vector_field X" shows "vec_field_restr X U q f = (the_inv_into (c_manifold.tangent_space (charts_submanifold U) k q) (diff.push_forward k (charts_submanifold U) charts (λx. x))) (X q) f" using rough_vector_fieldE(1)[OF assms ( 4 )] (*‹(X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) (?p::'a::{second_countable_topology,t2_space}) ∈ tangent_space ?p›*) by (auto simp: vec_field_apply_fun_in_at_def (*‹vec_field_apply_fun_in_at (?X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) (?f::'a::{second_countable_topology,t2_space} ⇒ real) (?U::'a::{second_countable_topology,t2_space} set) (?q::'a::{second_countable_topology,t2_space}) = restrict0 (tangent_space ?q) (the_inv_into (c_manifold.tangent_space (charts_submanifold ?U) (k::enat) ?q) (diff.push_forward k (charts_submanifold ?U) (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) (λx::'a::{second_countable_topology,t2_space}. x))) (?X ?q) ?f›*) assms( (*‹open (U::'a::{second_countable_topology,t2_space} set)› ‹(q::'a::{second_countable_topology,t2_space}) ∈ (U::'a::{second_countable_topology,t2_space} set)› ‹(f::'a::{second_countable_topology,t2_space} ⇒ real) ∈ c_manifold.diff_fun_space (charts_submanifold (U::'a::{second_countable_topology,t2_space} set)) (k::enat)›*) 1-3)) lemma (in submanifold) vec_field_apply_fun_sub: assumes "q∈carrier" "q∈S" "f ∈ sub.diff_fun_space" "rough_vector_field X" shows "vec_field_apply_fun_in_at X f (S∩carrier) q = (the_inv_into (sub.tangent_space q) inclusion.push_forward) (X q) f" using assms (*‹q ∈ carrier› ‹q ∈ S› ‹(f::'a ⇒ real) ∈ sub.diff_fun_space› ‹rough_vector_field X›*) charts_submanifold_Int_carrier (*‹charts_submanifold (S ∩ carrier) = charts_submanifold S›*) sub.open_carrier (*‹open sub.carrier›*) vec_field_apply_fun_alt (*‹⟦open ?U; ?q ∈ ?U; ?f ∈ c_manifold.diff_fun_space (charts_submanifold ?U) k; rough_vector_field ?X⟧ ⟹ ?X↾?U ?q ?f = the_inv_into (c_manifold.tangent_space (charts_submanifold ?U) k ?q) (diff.push_forward k (charts_submanifold ?U) charts (λx. x)) (?X ?q) ?f›*) by auto lemma vec_field_apply_fun_in_open[simp]: "vec_field_apply_fun_in_at X f' U p = X p f" if U: "p ∈ U" "open U" "U ⊆ carrier" and f: "f ∈ diff_fun_space" "f' ∈ c_manifold.diff_fun_space (charts_submanifold U) k" "∀x∈U. f x = f' x" and X: "rough_vector_field X" proof (-) (*goal: ‹vec_field_apply_fun_in_at X f' U p = X p f›*) interpret U: submanifold charts k U using U(2) (*‹open U›*) by unfold_locales show "?thesis" (*goal: ‹vec_field_apply_fun_in_at (X::'a ⇒ ('a ⇒ real) ⇒ real) (f'::'a ⇒ real) (U::'a set) (p::'a) = X p (f::'a ⇒ real)›*) using U.vec_field_apply_fun_sub[OF subsetD [ OF U ( 3 , 1 ) ] U ( 1 ) f ( 2 ) X] (*‹vec_field_apply_fun_in_at (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) (f'::'a::{second_countable_topology,t2_space} ⇒ real) ((U::'a::{second_countable_topology,t2_space} set) ∩ carrier) (p::'a::{second_countable_topology,t2_space}) = the_inv_into (U.sub.tangent_space p) U.inclusion.push_forward (X p) f'›*) U.vector_apply_sub_eq_localI(2) (*‹⟦?p ∈ ?N; U ⊆ carrier; open ?N; ?N ⊆ U; ?f ∈ diff_fun_space; ?f' ∈ U.sub.diff_fun_space; ⋀x. x ∈ ?N ⟹ ?f x = ?f' x; ?v ∈ tangent_space ?p⟧ ⟹ the_inv_into (U.sub.tangent_space ?p) U.inclusion.push_forward ?v ?f' = ?v ?f›*) using rough_vector_fieldE(1)[OF X] (*‹X ?p ∈ tangent_space ?p›*) that(1,3-6) (*‹(p::'a::{second_countable_topology,t2_space}) ∈ (U::'a::{second_countable_topology,t2_space} set)› ‹U ⊆ carrier› ‹f ∈ diff_fun_space› ‹f' ∈ U.sub.diff_fun_space› ‹∀x∈U. f x = f' x›*) by (auto simp: Int_absorb2[OF U(3)] (*‹U ∩ carrier = U›*) U.open_submanifold (*‹open U›*)) qed lemma open_imp_submanifold: "submanifold charts k S" if "open S" using that (*‹open S›*) by unfold_locales lemmas charts_submanifold = submanifold.charts_submanifold[OF open_imp_submanifold] lemma charts_submanifold_Int: "manifold.charts_submanifold (charts_submanifold U) N = charts_submanifold (N ∩ U)" if "open N" "open U" using restrict_chart_restrict_chart[OF that] (*‹restrict_chart (N::'a set) (restrict_chart (U::'a set) (?c::('a, ?'b) chart)) = restrict_chart (N ∩ U) ?c›*) by (auto simp add: image_def (*‹(?f::?'a ⇒ ?'b) ` (?A::?'a set) = {y::?'b. ∃x::?'a∈?A. y = ?f x}›*) manifold.charts_submanifold_def (*‹manifold.charts_submanifold (?charts::(?'a, ?'e) chart set) (?S::?'a set) = restrict_chart ?S ` ?charts›*)) lemma vec_field_apply_fun_in_restrict0[simp]: "vec_field_restr X U p f = vec_field_restr X N p (restrict0 N f)" if U: "open U" "U ⊆ carrier" and N: "p∈N" "N ⊆ U" "open N" and f: "f ∈ c_manifold.diff_fun_space (charts_submanifold U) k" and X: "rough_vector_field X" proof (-) (*goal: ‹X↾U p f = X↾N p (restrict0 N f)›*) let ?f = "restrict0 N f" have f_diff_N: "diff_fun k (charts_submanifold N) f" using diff_fun.diff_fun_submanifold[OF c_manifold.diff_fun_spaceD [ OF charts_submanifold [ OF U ( 1 ) ] ], OF f N ( 3 )] (*‹diff_fun k (manifold.charts_submanifold (charts_submanifold U) N) f›*) by (simp only: charts_submanifold_Int[OF N(3) U(1)] (*‹manifold.charts_submanifold (charts_submanifold (U::'a set)) (N::'a set) = charts_submanifold (N ∩ U)›*) Int_absorb2[OF N(2)] (*‹(N::'a set) ∩ (U::'a set) = N›*)) have f': "?f ∈ c_manifold.diff_fun_space (charts_submanifold N) k" unfolding c_manifold.diff_fun_space_def[OF charts_submanifold [ OF N ( 3 ) ]] (*goal: ‹restrict0 N f ∈ {f. diff_fun k (charts_submanifold N) f ∧ extensional0 (manifold.carrier (charts_submanifold N)) f}›*) apply (safe, rule diff_fun.diff_fun_cong (*‹⟦diff_fun ?k ?charts ?f; ⋀x. x ∈ manifold.carrier ?charts ⟹ ?f x = ?g x⟧ ⟹ diff_fun ?k ?charts ?g›*)) (*goal: ‹restrict0 N f ∈ {f. diff_fun k (charts_submanifold N) f ∧ extensional0 (manifold.carrier (charts_submanifold N)) f}›*) using f_diff_N (*‹diff_fun k (charts_submanifold N) f›*) submanifold.carrier_submanifold[OF open_imp_submanifold [ OF N ( 3 ) ]] (*‹manifold.carrier (charts_submanifold N) = N ∩ carrier›*) apply - (*goals: 1. ‹⟦diff_fun k (charts_submanifold N) f; manifold.carrier (charts_submanifold N) = N ∩ carrier⟧ ⟹ diff_fun k (charts_submanifold N) ?f4› 2. ‹⋀x. ⟦x ∈ manifold.carrier (charts_submanifold N); diff_fun k (charts_submanifold N) f; manifold.carrier (charts_submanifold N) = N ∩ carrier⟧ ⟹ ?f4 x = restrict0 N f x› 3. ‹⟦diff_fun k (charts_submanifold N) f; manifold.carrier (charts_submanifold N) = N ∩ carrier⟧ ⟹ extensional0 (manifold.carrier (charts_submanifold N)) (restrict0 N f)› discuss goal 1*) apply ((auto simp: Int_absorb2[OF subset_trans, OF N(2) U(2)] (*‹N ∩ carrier = N›*))[1]) (*discuss goal 2*) apply ((auto simp: Int_absorb2[OF subset_trans, OF N(2) U(2)] (*‹N ∩ carrier = N›*))[1]) (*discuss goal 3*) apply ((auto simp: Int_absorb2[OF subset_trans, OF N(2) U(2)] (*‹N ∩ carrier = N›*))[1]) (*proven 3 subgoals*) . have p: "p∈U" "p∈carrier" using U (*‹open U› ‹U ⊆ carrier›*) N (*‹p ∈ N› ‹(N::'a::{second_countable_topology,t2_space} set) ⊆ (U::'a::{second_countable_topology,t2_space} set)› ‹open N›*) apply - (*goals: 1. ‹⟦open U; U ⊆ carrier; p ∈ N; N ⊆ U; open N⟧ ⟹ p ∈ U› 2. ‹⟦open U; U ⊆ carrier; p ∈ N; N ⊆ U; open N⟧ ⟹ p ∈ carrier› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have N_carrier[simp]: "manifold.carrier (charts_submanifold N) = N" using submanifold.carrier_submanifold (*‹submanifold ?charts ?k ?S ⟹ manifold.carrier (manifold.charts_submanifold ?charts ?S) = ?S ∩ manifold.carrier ?charts›*) open_imp_submanifold (*‹open ?S ⟹ submanifold charts k ?S›*) N(3) (*‹open N›*) Int_absorb2 (*‹?A ⊆ ?B ⟹ ?A ∩ ?B = ?A›*) N(2) (*‹N ⊆ U›*) U(2) (*‹U ⊆ carrier›*) by (metis subset_trans (*‹⟦(?A::?'a::type set) ⊆ (?B::?'a::type set); ?B ⊆ (?C::?'a::type set)⟧ ⟹ ?A ⊆ ?C›*)) obtain N' where N': "p∈N'" "open N'" "compact (closure N')" "closure N' ⊆ N" (*goal: ‹(⋀N'::'a set. ⟦(p::'a) ∈ N'; open N'; compact (closure N'); closure N' ⊆ (N::'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) using manifold.precompact_neighborhoodE[of p "charts_submanifold N", simplified, OF N ( 1 )] (*‹(⋀C. ⟦p ∈ C; open C; compact (closure C); closure C ⊆ N⟧ ⟹ ?thesis) ⟹ ?thesis›*) by blast from submanifold.extension_lemma_submanifoldE[OF open_imp_submanifold [ OF N ( 3 ) ] f_diff_N closed_closure] (*‹⟦closure (?S1::'a set) ⊆ manifold.carrier (charts_submanifold (N::'a set)); ⋀f'::'a ⇒ real. ⟦diff_fun (k::enat) (charts::('a, 'b) chart set) f'; ⋀x::'a. x ∈ closure ?S1 ⟹ f' x = (f::'a ⇒ real) x; csupport_on carrier f' ∩ carrier ⊆ manifold.carrier (charts_submanifold N)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) this(4) (*‹closure N' ⊆ N›*) obtain g where g: "diff_fun k charts g" "⋀x. x ∈ closure N' ⟹ g x = f x" "csupport_on carrier g ∩ carrier ⊆ N" (*goal: ‹(⋀g::'a::{second_countable_topology,t2_space} ⇒ real. ⟦diff_fun (k::enat) (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) g; ⋀x::'a::{second_countable_topology,t2_space}. x ∈ closure (N'::'a::{second_countable_topology,t2_space} set) ⟹ g x = (f::'a::{second_countable_topology,t2_space} ⇒ real) x; csupport_on carrier g ∩ carrier ⊆ (N::'a::{second_countable_topology,t2_space} set)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto let ?g = "restrict0 carrier g" have diff_g': "diff_fun k charts ?g" "?g ∈ diff_fun_space" subgoal for apply (rule diff_fun.diff_fun_cong[OF g(1)] (*‹(⋀x. x ∈ carrier ⟹ g x = ?g x) ⟹ diff_fun k charts ?g›*)) (*goal: ‹diff_fun k charts (restrict0 carrier g)›*) by simp subgoal for unfolding diff_fun_space_def (*goal: ‹restrict0 carrier g ∈ {f. diff_fun k charts f ∧ extensional0 carrier f}›*) using ‹diff_fun k charts ?g› (*‹diff_fun k charts (restrict0 carrier g)›*) by simp . note [simp] = charts_submanifold_Int[OF N ( 3 ) U ( 1 )] (*‹manifold.charts_submanifold (charts_submanifold U) N = charts_submanifold (N ∩ U)›*) Int_absorb2[OF N ( 2 )] (*‹(N::'a set) ∩ (U::'a set) = N›*) rough_vector_fieldE(1)[OF X] (*‹X ?p ∈ tangent_space ?p›*) vec_field_apply_fun_alt[OF N ( 3 , 1 ) f'] (*‹rough_vector_field ?X ⟹ ?X↾N p (restrict0 N f) = the_inv_into (c_manifold.tangent_space (charts_submanifold N) k p) (diff.push_forward k (charts_submanifold N) charts (λx. x)) (?X p) (restrict0 N f)›*) vec_field_apply_fun_alt[OF U ( 1 ) p ( 1 ) f] (*‹rough_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ⟹ ?X↾(U::'a set) (p::'a) (f::'a ⇒ real) = the_inv_into (c_manifold.tangent_space (charts_submanifold U) (k::enat) p) (diff.push_forward k (charts_submanifold U) (charts::('a, 'b) chart set) (λx::'a. x)) (?X p) f›*) note Xp_eq_localI = submanifold.vector_apply_sub_eq_localI(2)[OF open_imp_submanifold N' ( 1 ) _ N' ( 2 ) subset_trans [ OF closure_subset , OF subset_trans [ OF N' ( 4 ) ] ] diff_g' ( 2 ) _ _ rough_vector_fieldE ( 1 ) [ OF X ]] (*‹⟦open (?S::'a::{second_countable_topology,t2_space} set); ?S ⊆ carrier; (N::'a::{second_countable_topology,t2_space} set) ⊆ ?S; (?f'::'a::{second_countable_topology,t2_space} ⇒ real) ∈ c_manifold.diff_fun_space (charts_submanifold ?S) (k::enat); ⋀x::'a::{second_countable_topology,t2_space}. x ∈ (N'::'a::{second_countable_topology,t2_space} set) ⟹ restrict0 carrier (g::'a::{second_countable_topology,t2_space} ⇒ real) x = ?f' x⟧ ⟹ the_inv_into (c_manifold.tangent_space (charts_submanifold ?S) k (p::'a::{second_countable_topology,t2_space})) (diff.push_forward k (charts_submanifold ?S) (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) (λx::'a::{second_countable_topology,t2_space}. x)) ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p) ?f' = X p (restrict0 carrier g)›*) have f_eq: "restrict0 carrier g x = f x" "restrict0 carrier g x = restrict0 N f x" if "x∈N'" for x proof (-) (*goals: 1. ‹restrict0 carrier g x = f x› 2. ‹restrict0 carrier g x = restrict0 N f x›*) have "x ∈ carrier" "x ∈ N" using that (*‹x ∈ N'›*) N'(4) (*‹closure (N'::'a set) ⊆ (N::'a set)›*) N(2) (*‹N ⊆ U›*) U(2) (*‹U ⊆ carrier›*) apply - (*goals: 1. ‹⟦x ∈ N'; closure N' ⊆ N; N ⊆ U; U ⊆ carrier⟧ ⟹ x ∈ carrier› 2. ‹⟦x ∈ N'; closure N' ⊆ N; N ⊆ U; U ⊆ carrier⟧ ⟹ x ∈ N› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "restrict0 carrier g x = f x" "restrict0 carrier g x = restrict0 N f x" using that (*‹x ∈ N'›*) g(2) (*‹?x3 ∈ closure N' ⟹ g ?x3 = f ?x3›*) apply - (*goals: 1. ‹⟦x ∈ carrier; x ∈ N; x ∈ N'; ⋀x. x ∈ closure N' ⟹ g x = f x⟧ ⟹ restrict0 carrier g x = f x› 2. ‹⟦x ∈ carrier; x ∈ N; x ∈ N'; ⋀x. x ∈ closure N' ⟹ g x = f x⟧ ⟹ restrict0 carrier g x = restrict0 N f x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed show "?thesis" (*goal: ‹(X::'a ⇒ ('a ⇒ real) ⇒ real)↾(U::'a set) (p::'a) (f::'a ⇒ real) = X↾(N::'a set) p (restrict0 N f)›*) using Xp_eq_localI[OF N ( 3 ) subset_trans [ OF N ( 2 ) ], OF U ( 2 ) _ f' f_eq ( 2 )] (*‹⟦N ⊆ N; ⋀x. x ∈ N' ⟹ x ∈ N'⟧ ⟹ the_inv_into (c_manifold.tangent_space (charts_submanifold N) k p) (diff.push_forward k (charts_submanifold N) charts (λx. x)) (X p) (restrict0 N f) = X p (restrict0 carrier g)›*) Xp_eq_localI[OF U N ( 2 ) f f_eq ( 1 )] (*‹(⋀x::'a. x ∈ (N'::'a set) ⟹ x ∈ N') ⟹ the_inv_into (c_manifold.tangent_space (charts_submanifold (U::'a set)) (k::enat) (p::'a)) (diff.push_forward k (charts_submanifold U) (charts::('a, 'b) chart set) (λx::'a. x)) ((X::'a ⇒ ('a ⇒ real) ⇒ real) p) (f::'a ⇒ real) = X p (restrict0 carrier (g::'a ⇒ real))›*) by (simp add: X (*‹rough_vector_field X›*) f' (*‹restrict0 N f ∈ c_manifold.diff_fun_space (charts_submanifold N) k›*) that( (*‹p ∈ N›*) 3) that( (*‹open N›*) 5) vec_field_apply_fun_alt' (*‹⟦open ?U; ?q ∈ ?U; ?f ∈ c_manifold.diff_fun_space (charts_submanifold ?U) k; rough_vector_field ?X⟧ ⟹ vec_field_apply_fun_in_at ?X ?f ?U ?q = the_inv_into (c_manifold.tangent_space (charts_submanifold ?U) k ?q) (diff.push_forward k (charts_submanifold ?U) charts (λx. x)) (?X ?q) ?f›*)) qed lemma (in submanifold) vec_field_apply_fun_in_open[simp]: "vec_field_restr X S p f' = X p f" if S: "S ⊆ carrier" and N: "open N" "N⊆S" "p ∈ N" and f: "f ∈ diff_fun_space" "f' ∈ sub.diff_fun_space" "∀x∈N. f x = f' x" and X: "rough_vector_field X" using vector_apply_sub_eq_localI(2)[OF N ( 3 ) S N ( 1 , 2 ) f ( 1 , 2 )] (*‹⟦⋀x. x ∈ N ⟹ f x = f' x; ?v ∈ tangent_space p⟧ ⟹ the_inv_into (sub.tangent_space p) inclusion.push_forward ?v f' = ?v f›*) that(3,4,6,7,8) (*‹N ⊆ S› ‹(p::'a) ∈ (N::'a set)› ‹f' ∈ sub.diff_fun_space› ‹∀x∈N. f x = f' x› ‹rough_vector_field X›*) by (auto simp: vec_field_apply_fun_alt' (*‹⟦open (?U::'a::{second_countable_topology,t2_space} set); (?q::'a::{second_countable_topology,t2_space}) ∈ ?U; (?f::'a::{second_countable_topology,t2_space} ⇒ real) ∈ c_manifold.diff_fun_space (charts_submanifold ?U) (k::enat); rough_vector_field (?X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)⟧ ⟹ vec_field_apply_fun_in_at ?X ?f ?U ?q = the_inv_into (c_manifold.tangent_space (charts_submanifold ?U) k ?q) (diff.push_forward k (charts_submanifold ?U) (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) (λx::'a::{second_countable_topology,t2_space}. x)) (?X ?q) ?f›*) rough_vector_fieldE( (*‹rough_vector_field (?X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) ⟹ ?X (?p::'a::{second_countable_topology,t2_space}) ∈ tangent_space ?p›*) 1) open_submanifold (*‹open (S::'a::{second_countable_topology,t2_space} set)›*)) lemma (in smooth_manifold) vec_field_apply_fun_in_restrict0': "restrict0 U (X˝f) = X↾U ˝ (restrict0 U f)" if U: "open U" "U ⊆ carrier" and f: "f ∈ diff_fun_space" and X: "rough_vector_field X" for U X f proof (standard) (*goal: ‹⋀p. restrict0 U (λp. X p f) p = X↾U p (restrict0 U f)›*) fix p interpret U: submanifold charts "∞" U apply unfold_locales (*goal: ‹submanifold charts ∞ U›*) by (simp add: U (*‹open U› ‹U ⊆ carrier›*)) have U_simps[simp]: "U.sub.carrier = U" using U (*‹open U› ‹U ⊆ carrier›*) by auto show "restrict0 U (X˝f) p = X↾U p (restrict0 U f)" (is "?LHS = ?RHS") by (metis (mono_tags, lifting) U.open_submanifold (*‹open U›*) X (*‹rough_vector_field X›*) U( (*‹U ⊆ carrier›*) 2) charts_submanifold_carrier (*‹charts_submanifold carrier = charts›*) diff.defined (*‹diff ?k ?charts1.0 ?charts2.0 ?f ⟹ ?f ` manifold.carrier ?charts1.0 ⊆ manifold.carrier ?charts2.0›*) diff_id (*‹diff ∞ charts charts (λx. x)›*) f (*‹f ∈ diff_fun_space›*) image_ident (*‹(λx. x) ` ?Y = ?Y›*) open_carrier (*‹open carrier›*) open_imp_submanifold (*‹open ?S ⟹ submanifold charts ∞ ?S›*) restrict0_def (*‹restrict0 ?A ?f ?x = (if ?x ∈ ?A then ?f ?x else 0)›*) submanifold.vec_field_apply_fun_in_open (*‹⟦submanifold ?charts ?k ?S; ?S ⊆ manifold.carrier ?charts; open ?N; ?N ⊆ ?S; ?p ∈ ?N; ?f ∈ c_manifold.diff_fun_space ?charts ?k; ?f' ∈ c_manifold.diff_fun_space (manifold.charts_submanifold ?charts ?S) ?k; ∀x∈?N. ?f x = ?f' x; c_manifold.rough_vector_field ?charts ?k ?X⟧ ⟹ restrict0 ?S (c_manifold.vec_field_apply_fun_in_at ?charts ?k ?X ?f' ?S) ?p = ?X ?p ?f›*) vec_field_apply_fun_in_restrict0 (*‹⟦open ?U; ?U ⊆ carrier; ?p ∈ ?N; ?N ⊆ ?U; open ?N; ?f ∈ c_manifold.diff_fun_space (charts_submanifold ?U) ∞; rough_vector_field ?X⟧ ⟹ ?X↾?U ?p ?f = ?X↾?N ?p (restrict0 ?N ?f)›*)) qed lemma (in submanifold) vec_field_apply_fun_in_open'[simp]: "vec_field_restr X S p f' = X p f" if S: "p ∈ S" "S ⊆ carrier" and f: "f ∈ diff_fun_space" "f' ∈ sub.diff_fun_space" "∀x∈S. f x = f' x" and X: "rough_vector_field X" using vec_field_apply_fun_in_open[OF S ( 2 ) open_submanifold _ S ( 1 ) f X] (*‹S ⊆ S ⟹ X↾S p f' = X p f›*) by simp lemma (in c_manifold) vec_field_apply_fun_in_chart[simp]: "vec_field_apply_fun_in_at X f (domain c) p = X p f" if p: "p ∈ domain c" and c: "c ∈ atlas" and f: "f ∈ diff_fun_space" "f ∈ c_manifold.diff_fun_space (charts_submanifold (domain c)) k" and X: "rough_vector_field X" using vec_field_apply_fun_in_open (*‹⟦?p ∈ ?U; open ?U; ?U ⊆ carrier; ?f ∈ diff_fun_space; ?f' ∈ c_manifold.diff_fun_space (charts_submanifold ?U) k; ∀x∈?U. ?f x = ?f' x; rough_vector_field ?X⟧ ⟹ vec_field_apply_fun_in_at ?X ?f' ?U ?p = ?X ?p ?f›*) that (*‹p ∈ domain c› ‹c ∈ atlas› ‹f ∈ diff_fun_space› ‹(f::'a ⇒ real) ∈ c_manifold.diff_fun_space (charts_submanifold (domain (c::('a, 'b) chart))) (k::enat)› ‹rough_vector_field X›*) by blast end (*c_manifold*) context c_manifold_local begin lemma vec_field_apply_fun_eq_component: fixes x⇩ψ defines [simp]: "x⇩ψ ≡ local_coord_at" assumes q: "q∈domain ψ" and p:"p∈domain ψ" and X: "rough_vector_field X" and k: "k=∞" shows "vec_field_apply_fun_in_at X (x⇩ψ q i) (domain ψ) q = vector_field_component X i q" proof (-) (*goal: ‹vec_field_apply_fun_in_at X (x⇩ψ q i) (domain ψ) q = vector_field_component X i q›*) note [simp] = local_coord_at_def (*‹local_coord_at ?q ?i ≡ restrict0 (domain ψ) (λy. (apply_chart ψ y - apply_chart ψ ?q) ∙ ?i)›*) "sub_ψ.sub.diff_fun_space_def" (*‹sub_ψ.sub.diff_fun_space = {f. diff_fun k (charts_submanifold (domain ψ)) f ∧ extensional0 sub_ψ.sub.carrier f}›*) vector_field_component_def (*‹vector_field_component ?X ?i ≡ λp. c_manifold_point.component_function charts k ψ p (?X p) ?i›*) interpret q: c_manifold_point charts k "ψ" q using q (*‹q ∈ domain ψ›*) "ψ" (*‹ψ ∈ atlas›*) apply unfold_locales (*goal: ‹c_manifold_point (charts::('a, 'b) chart set) (k::enat) (ψ::('a, 'b) chart) (q::'a)›*) by simp let ?x⇩q = "x⇩ψ q" have Xq: "X q ∈ q.T⇩pM" "q.dRestr2 (X q) ∈ q.T⇩pU" subgoal for using rough_vector_fieldE[OF X] (*‹X ?p ∈ tangent_space ?p› ‹extensional0 carrier X›*) q (*‹q ∈ domain ψ›*) "ψ" (*‹ψ ∈ atlas›*) by blast using bij_betwE[OF q.bij_betw_dι_inv] (*‹∀a∈q.T⇩pM. q.dRestr2 a ∈ q.T⇩pU›*) ‹X q ∈ q.T⇩pM› (*‹X q ∈ q.T⇩pM›*) by simp note 1 = vector_apply_coord_at[OF q p Xq ( 1 ) k] (*‹q.dRestr2 ((X::'a ⇒ ('a ⇒ real) ⇒ real) (q::'a)) (local_coord_at (p::'a) (?i::'b)) = q.dRestr2 (X q) (local_coord_at q ?i)›*) have 2: "q.dRestr2 (X q) (local_coord_at q i) = vector_field_component X i q" using "q.component_function_apply_in_T⇩pM"[OF Xq ( 1 )] (*‹q.component_function (X q) ?i = q.dRestr2 (X q) (restrict0 (domain ψ) (λx. (apply_chart ψ x - apply_chart ψ q) ∙ ?i))›*) by simp show "?thesis" (*goal: ‹vec_field_apply_fun_in_at X (x⇩ψ q i) (domain ψ) q = vector_field_component X i q›*) apply (simp only: 2[symmetric] (*‹vector_field_component X i q = q.dRestr2 (X q) (local_coord_at q i)›*) 1[symmetric] (*‹q.dRestr2 (X q) (local_coord_at q ?i) = q.dRestr2 (X q) (local_coord_at p ?i)›*) restrict0_apply_in[OF Xq(1)] (*‹restrict0 q.T⇩pM ?f (X q) = ?f (X q)›*)) (*goal: ‹vec_field_apply_fun_in_at X (x⇩ψ q i) (domain ψ) q = vector_field_component X i q›*) using vec_field_apply_fun_alt'[OF open_domain q] (*‹⟦?f ∈ sub_ψ.sub.diff_fun_space; rough_vector_field ?X⟧ ⟹ vec_field_apply_fun_in_at ?X ?f (domain ψ) q = the_inv_into q.T⇩pU dι (?X q) ?f›*) local_coord_diff_fun[OF k q] (*‹local_coord_at q ?i ∈ sub_ψ.sub.diff_fun_space›*) X (*‹rough_vector_field X›*) "x⇩ψ_def" (*‹x⇩ψ ≡ local_coord_at›*) by blast qed text ‹Prop 8.1, page 175, Lee 2012. The main difference is that our vector field $X$ here is only a map $M \to snd`TM$, not a section $M to TM$ properly speaking. See also @{thm apply_chart_TM_chartX}.› lemma vector_field_smooth_local_iff: assumes k: "k = ∞" and X: "∀p∈domain ψ. X p ∈ tangent_space p" shows "smooth_vector_field_local charts ψ X ⟷ (∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i))" (is ‹?smooth_vf X ⟷ (∀i∈Basis. ?diff_component X i)›) proof (-) (*goal: ‹smooth_vector_field_local charts ψ X = (∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i))›*) text ‹A bit of house-keeping. Maybe having both \<^term>‹vector_field_component› and \<^term>‹c_manifold_point.tangent_chart_fun› is redundant, or maybe the second statement below could be a simp rule (probably in the opposite direction).› have cpt1: "c_manifold_point charts k ψ a" if "a∈domain ψ" for a apply unfold_locales (*goal: ‹c_manifold_point charts k ψ a›*) by (simp add: sub_ψ (*‹ψ ∈ sub_ψ.sub.atlas›*) that (*‹a ∈ domain ψ›*)) have vfc_tcf: "(∑i∈Basis. vector_field_component X i p *⇩R i) = c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)" if "p ∈ domain ψ" for p using c_manifold_point.tangent_chart_fun_def[of charts k ψ] (*‹c_manifold_point charts k ψ ?p ⟹ c_manifold_point.tangent_chart_fun charts k ψ ?p ?v ≡ ∑i∈Basis. c_manifold_point.component_function charts k ψ ?p ?v i *⇩R i›*) vector_field_component_def (*‹vector_field_component ?X ?i ≡ λp. c_manifold_point.component_function charts k ψ p (?X p) ?i›*) cpt1 (*‹(?a3::'a::{second_countable_topology,t2_space}) ∈ domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ⟹ c_manifold_point (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) (k::enat) ψ ?a3›*) k (*‹k = ∞›*) that (*‹(p::'a) ∈ domain (ψ::('a, 'b) chart)›*) by auto show "?thesis" (*goal: ‹smooth_vector_field_local charts ψ X = (∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i))›*) proof (standard) (*goals: 1. ‹smooth_vector_field_local charts ψ X ⟹ ∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i)› 2. ‹∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i) ⟹ smooth_vector_field_local charts ψ X›*) assume asm: "?smooth_vf X" (*‹smooth_vector_field_local (charts::('a, 'b) chart set) (ψ::('a, 'b) chart) (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) then interpret smooth_X_local: smooth_vector_field_local charts "ψ" X unfolding smooth_vector_field_local_def (*goal: ‹c_manifold_local (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∧ smooth_vector_field_local_axioms charts ψ (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)›*) . text ‹Notice we don't even need our Euclidean representation theorem @{thm vector_field_local_representation}. The crux is that we already know differentiability works well with components: @{thm diff_fun_components_iff}.› have "∀i∈Basis. diff_fun ∞ (charts_submanifold (domain ψ)) (vector_field_component X i)" apply (subst smooth_X_local.sub_ψ.sub.diff_fun_components_iff[of "vector_field_component X", symmetric] (*‹(∀i∈Basis. diff_fun ∞ (charts_submanifold (domain ψ)) (vector_field_component X i)) = diff_fun ∞ (charts_submanifold (domain ψ)) (λx. ∑i∈Basis. vector_field_component X i x *⇩R i)›*)) (*goal: ‹∀i∈Basis. diff_fun ∞ (charts_submanifold (domain ψ)) (vector_field_component X i)›*) using smooth_X_local.smooth_in_chart_X[unfolded smooth_X_local.chart_X_def] (*‹diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))›*) by (auto intro: diff_fun.diff_fun_cong[OF _ vfc_tcf[symmetric]] (*‹⟦diff_fun ?k ?charts (λx. c_manifold_point.tangent_chart_fun charts ∞ ψ (?p1 x) (X (?p1 x))); ⋀x. x ∈ manifold.carrier ?charts ⟹ ?p1 x ∈ domain ψ⟧ ⟹ diff_fun ?k ?charts (λx. ∑i∈Basis. vector_field_component X i (?p1 x) *⇩R i)›*)) then show "∀i∈Basis. ?diff_component X i" using diff_fun_onI[of "domain ψ" "domain ψ" f f for f] (*‹⟦domain ψ ⊆ domain ψ; domain ψ ⊆ carrier; open (domain ψ); diff_fun k (charts_submanifold (domain ψ)) ?f6; ⋀x. x ∈ domain ψ ⟹ ?f6 x = ?f6 x⟧ ⟹ diff_fun_on (domain ψ) ?f6›*) domain_atlas_subset_carrier (*‹?c ∈ atlas ⟹ domain ?c ⊆ carrier›*) k (*‹k = ∞›*) by auto next (*goal: ‹∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i) ⟹ smooth_vector_field_local charts ψ X›*) assume asm: "∀i∈Basis. ?diff_component X i" (*‹∀i::'b∈Basis. diff_fun_on (domain (ψ::('a, 'b) chart)) (vector_field_component (X::'a ⇒ ('a ⇒ real) ⇒ real) i)›*) interpret local_ψ: c_manifold_local charts "∞" "ψ" using c_manifold_local_axioms (*‹c_manifold_local (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) (k::enat) (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)›*) k (*‹k = ∞›*) by auto have 2: "diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))" apply (rule diff_fun.diff_fun_cong[OF _ vfc_tcf] (*‹⟦diff_fun (?k::enat) (?charts::(?'a::{second_countable_topology,t2_space}, ?'c::euclidean_space) chart set) (λx::?'a::{second_countable_topology,t2_space}. ∑i::'b::euclidean_space∈Basis. vector_field_component (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) i ((?p4::?'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space}) x) *⇩R i); ⋀x::?'a::{second_countable_topology,t2_space}. x ∈ manifold.carrier ?charts ⟹ ?p4 x ∈ domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)⟧ ⟹ diff_fun ?k ?charts (λx::?'a::{second_countable_topology,t2_space}. c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ ψ (?p4 x) (X (?p4 x)))›*)) (*goal: ‹diff_fun ∞ (charts_submanifold (domain (ψ::('a, 'b) chart))) (λp::'a. c_manifold_point.tangent_chart_fun (charts::('a, 'b) chart set) ∞ ψ p ((X::'a ⇒ ('a ⇒ real) ⇒ real) p))›*) using "sub_ψ.sub.diff_fun_components_iff"[of "vector_field_component X"] (*‹diff_fun k (charts_submanifold (domain ψ)) (λx. ∑i∈Basis. vector_field_component X i x *⇩R i) = (∀i∈Basis. diff_fun k (charts_submanifold (domain ψ)) (vector_field_component X i))›*) k (*‹k = ∞›*) asm (*‹∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i)›*) diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun k (charts_submanifold ?A) ?f)›*) apply - (*goals: 1. ‹⟦diff_fun (k::enat) (charts_submanifold (domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart))) (λx::'a::{second_countable_topology,t2_space}. ∑i::'b::euclidean_space∈Basis. vector_field_component (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) i x *⇩R i) = (∀i::'b::euclidean_space∈Basis. diff_fun k (charts_submanifold (domain ψ)) (vector_field_component X i)); k = ∞; ∀i::'b::euclidean_space∈Basis. diff_fun_on (domain ψ) (vector_field_component X i); ⋀(A::'a::{second_countable_topology,t2_space} set) f::'a::{second_countable_topology,t2_space} ⇒ ?'c16::euclidean_space. open A ⟹ diff_fun_on A f = (A ⊆ carrier ∧ diff_fun k (charts_submanifold A) f)⟧ ⟹ diff_fun ∞ (charts_submanifold (domain ψ)) (λp::'a::{second_countable_topology,t2_space}. ∑i::'b::euclidean_space∈Basis. vector_field_component X i p *⇩R i)› 2. ‹⋀p::'a::{second_countable_topology,t2_space}. ⟦p ∈ sub_ψ.sub.carrier; diff_fun (k::enat) (charts_submanifold (domain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart))) (λx::'a::{second_countable_topology,t2_space}. ∑i::'b::euclidean_space∈Basis. vector_field_component (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) i x *⇩R i) = (∀i::'b::euclidean_space∈Basis. diff_fun k (charts_submanifold (domain ψ)) (vector_field_component X i)); k = ∞; ∀i::'b::euclidean_space∈Basis. diff_fun_on (domain ψ) (vector_field_component X i); ⋀(A::'a::{second_countable_topology,t2_space} set) f::'a::{second_countable_topology,t2_space} ⇒ ?'c11::euclidean_space. open A ⟹ diff_fun_on A f = (A ⊆ carrier ∧ diff_fun k (charts_submanifold A) f)⟧ ⟹ p ∈ domain ψ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have 1: "smooth_on (codomain ψ) ((λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)) ∘ inv_chart ψ)" if "x ∈ domain ψ" for x apply (rule diff_fun.diff_fun_between_chartsD[of _ "charts_submanifold (domain ψ)"] (*‹⟦diff_fun ?k (charts_submanifold (domain ψ)) ?f; ?c ∈ c_manifold.atlas (charts_submanifold (domain ψ)) ?k; ?x ∈ domain ?c⟧ ⟹ ?k-smooth_on (codomain ?c) (?f ∘ inv_chart ?c)›*)) (*goal: ‹smooth_on (codomain (ψ::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) ((λp::'a::{second_countable_topology,t2_space}. c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ ψ p ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p)) ∘ inv_chart ψ)›*) using "2" (*‹diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))›*) that (*‹x ∈ domain ψ›*) apply - (*goals: 1. ‹⟦diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)); x ∈ domain ψ⟧ ⟹ diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))› 2. ‹⟦diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)); x ∈ domain ψ⟧ ⟹ ψ ∈ local_ψ.sub_ψ.sub.atlas› 3. ‹⟦diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)); x ∈ domain ψ⟧ ⟹ ?x ∈ domain ψ› discuss goal 1*) apply ((auto simp: local_ψ.sub_ψ (*‹(ψ::('a, 'b) chart) ∈ local_ψ.sub_ψ.sub.atlas›*))[1]) (*discuss goal 2*) apply ((auto simp: local_ψ.sub_ψ (*‹ψ ∈ local_ψ.sub_ψ.sub.atlas›*))[1]) (*discuss goal 3*) apply ((auto simp: local_ψ.sub_ψ (*‹ψ ∈ local_ψ.sub_ψ.sub.atlas›*))[1]) (*proven 3 subgoals*) . show "?smooth_vf X" apply unfold_locales (*goal: ‹smooth_vector_field_local (charts::('a, 'b) chart set) (ψ::('a, 'b) chart) (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) using "1" (*‹?x3 ∈ domain ψ ⟹ smooth_on (codomain ψ) ((λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)) ∘ inv_chart ψ)›*) X (*‹∀p∈domain ψ. X p ∈ tangent_space p›*) k (*‹k = ∞›*) apply - (*goals: 1. ‹⟦⋀x. x ∈ domain ψ ⟹ smooth_on (codomain ψ) ((λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)) ∘ inv_chart ψ); ∀p∈domain ψ. X p ∈ tangent_space p; k = ∞⟧ ⟹ ∀p∈domain ψ. X p ∈ local_ψ.tangent_space p› 2. ‹⋀x. ⟦x ∈ sub_ψ.sub.carrier; ⋀x. x ∈ domain ψ ⟹ smooth_on (codomain ψ) ((λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)) ∘ inv_chart ψ); ∀p∈domain ψ. X p ∈ tangent_space p; k = ∞⟧ ⟹ ∃c1∈local_ψ.sub_ψ.sub.atlas. ∃c2∈manifold_eucl.atlas ∞. x ∈ domain c1 ∧ (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)) ` domain c1 ⊆ domain c2 ∧ smooth_on (codomain c1) (apply_chart c2 ∘ (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)) ∘ inv_chart c1)› discuss goal 1*) apply ((auto intro!: bexI[of _ ψ] (*‹⟦?P ψ; ψ ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) bexI[of _ chart_eucl] (*‹⟦?P chart_eucl; chart_eucl ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) simp: local_ψ.sub_ψ (*‹ψ ∈ local_ψ.sub_ψ.sub.atlas›*) id_comp[unfolded id_def] (*‹(λx. x) ∘ ?g = ?g›*))[1]) (*discuss goal 2*) apply ((auto intro!: bexI[of _ ψ] (*‹⟦?P ψ; ψ ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) bexI[of _ chart_eucl] (*‹⟦?P chart_eucl; chart_eucl ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) simp: local_ψ.sub_ψ (*‹ψ ∈ local_ψ.sub_ψ.sub.atlas›*) id_comp[unfolded id_def] (*‹(λx. x) ∘ ?g = ?g›*))[1]) (*proven 2 subgoals*) . qed qed end (* c_manifold_local *) lemma (in smooth_vector_field_local) diff_component': fixes i :: 'b assumes "i ∈ Basis" shows "diff_fun_on (domain ψ) (vector_field_component X i)" using vector_field_smooth_local_iff[OF _ vector_field] (*‹∞ = ∞ ⟹ smooth_vector_field_local charts ψ X = (∀i∈Basis. diff_fun_on (domain ψ) (vector_field_component X i))›*) smooth_vector_field_local_axioms (*‹smooth_vector_field_local charts ψ X›*) assms (*‹i ∈ Basis›*) by auto context smooth_manifold begin text ‹Prop. 8.8 in Lee 2012.› text ‹Do we want extensional0 vector fields? It would make the usual simplification for writing addition and scaling by real numbers. So ‹𝔛› could be a vector space under ‹(+)› and ‹scaleR›? Maybe a double problem: * ⌦‹0::'a⇒('a×(('a⇒real)⇒real))› is ill-defined when \<^typ>‹'a› is not of the sort \<^class>‹zero›. * Also I think the function ‹0› always assigns zero, i.e. for a pair it returns the constant ‹(0,0)›. We would want the zero vector field to be $p \mapsto (p,0)$ instead.› text ‹We will need to use locales anyway if we also want to talk about ‹𝔛› as a module over ‹diff_fun_space›, since that is a set already. - Actually, probably not true, because \<^term>‹extensional0› works out quite neatly.› text ‹A predicate analogous to \<^term>‹smooth_vector_field_local›, but for the entire manifold.› definition smooth_vector_field :: "'a vector_field ⇒ bool" where "smooth_vector_field X ≡ rough_vector_field X ∧ smooth_from_M_to_TM (λp. (p, X p))" lemma smooth_vector_field_alt: "smooth_vector_field X ≡ (λp. (p, X p)) ∈ 𝔛 ∧ extensional0 carrier X" apply (auto simp: smooth_vector_field_def (*‹smooth_vector_field ?X ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp. (p, ?X p))›*) smooth_section_of_TM_def (*‹smooth_section_of_TM ?X ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) section_of_TM_def (*‹section_of_TM_on ?S ?X ≡ ∀p∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*) rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*) in_TM_def (*‹in_TM ?p ?v ≡ ?p ∈ carrier ∧ ?v ∈ tangent_space ?p›*)) (*goal: ‹smooth_vector_field X ≡ (λp. (p, X p)) ∈ 𝔛 ∧ extensional0 carrier X›*) by linarith<close> lemma "smooth_vector_field X ≡ (∀p∈carrier. X p ∈ tangent_space p) ∧ smooth_from_M_to_TM (λp. (p, X p)) ∧ extensional0 carrier X" apply (auto simp: smooth_vector_field_def (*‹smooth_vector_field (?X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp::'a::{second_countable_topology,t2_space}. (p, ?X p))›*) smooth_section_of_TM_def (*‹smooth_section_of_TM (?X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) section_of_TM_def (*‹section_of_TM_on (?S::'a::{second_countable_topology,t2_space} set) (?X::'a::{second_countable_topology,t2_space} ⇒ 'a::{second_countable_topology,t2_space} × (('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)) ≡ ∀p::'a::{second_countable_topology,t2_space}∈?S. ?X p ∈ TM ∧ fst (?X p) = p›*) rough_vector_field_def (*‹rough_vector_field (?X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) ≡ extensional0 carrier ?X ∧ (∀p::'a::{second_countable_topology,t2_space}∈carrier. ?X p ∈ tangent_space p)›*) in_TM_def (*‹in_TM (?p::'a::{second_countable_topology,t2_space}) (?v::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) ≡ ?p ∈ carrier ∧ ?v ∈ tangent_space ?p›*)) (*goal: ‹smooth_vector_field X ≡ (∀p∈carrier. X p ∈ tangent_space p) ∧ smooth_from_M_to_TM (λp. (p, X p)) ∧ extensional0 carrier X›*) by linarith lemma smooth_vector_fieldE [elim]: assumes "smooth_vector_field X" shows "⋀p. X p ∈ tangent_space p" "extensional0 carrier X" "rough_vector_field X" "smooth_from_M_to_TM (λp. (p, X p))" using rough_vector_fieldE (*‹rough_vector_field ?X ⟹ ?X ?p ∈ tangent_space ?p› ‹rough_vector_field ?X ⟹ extensional0 carrier ?X›*) assms (*‹smooth_vector_field X›*) unfolding smooth_vector_field_def (*goals: 1. ‹⋀p. X p ∈ tangent_space p› 2. ‹extensional0 carrier X› 3. ‹rough_vector_field X› 4. ‹smooth_from_M_to_TM (λp. (p, X p))›*) apply - (*goals: 1. ‹⋀p. ⟦⋀X p. rough_vector_field X ⟹ X p ∈ tangent_space p; ⋀X. rough_vector_field X ⟹ extensional0 carrier X; rough_vector_field X ∧ smooth_from_M_to_TM (λp. (p, X p))⟧ ⟹ X p ∈ tangent_space p› 2. ‹⟦⋀X p. rough_vector_field X ⟹ X p ∈ tangent_space p; ⋀X. rough_vector_field X ⟹ extensional0 carrier X; rough_vector_field X ∧ smooth_from_M_to_TM (λp. (p, X p))⟧ ⟹ extensional0 carrier X› 3. ‹⟦⋀X p. rough_vector_field X ⟹ X p ∈ tangent_space p; ⋀X. rough_vector_field X ⟹ extensional0 carrier X; rough_vector_field X ∧ smooth_from_M_to_TM (λp. (p, X p))⟧ ⟹ rough_vector_field X› 4. ‹⟦⋀X p. rough_vector_field X ⟹ X p ∈ tangent_space p; ⋀X. rough_vector_field X ⟹ extensional0 carrier X; rough_vector_field X ∧ smooth_from_M_to_TM (λp. (p, X p))⟧ ⟹ smooth_from_M_to_TM (λp. (p, X p))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemma smooth_vector_field_imp_local: assumes "smooth_vector_field X" "ψ ∈ atlas" shows "smooth_vector_field_local charts ψ X" proof (-) (*goal: ‹smooth_vector_field_local charts ψ X›*) interpret ψ: c_manifold_local charts "∞" "ψ" using assms(2) (*‹(ψ::('a, 'b) chart) ∈ atlas›*) by unfold_locales have 1: "section_of_TM (λp. (p, X p))" using assms(1,2) (*‹smooth_vector_field X› ‹(ψ::('a, 'b) chart) ∈ atlas›*) smooth_section_of_TM_def (*‹smooth_section_of_TM ?X ≡ section_of_TM ?X ∧ smooth_from_M_to_TM ?X›*) smooth_vector_field_alt (*‹smooth_vector_field ?X ≡ (λp. (p, ?X p)) ∈ 𝔛 ∧ extensional0 carrier ?X›*) by blast have 2: "smooth_from_M_to_TM (λp. (p, X p))" using assms(1) (*‹smooth_vector_field X›*) smooth_vector_field_def (*‹smooth_vector_field ?X ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp. (p, ?X p))›*) by auto have vec_field_X: "∀p∈domain ψ. X p ∈ tangent_space p" using assms(1) (*‹smooth_vector_field X›*) by (auto simp: smooth_vector_field_def (*‹smooth_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp::'a. (p, ?X p))›*)) moreover have diff_fun_X: "diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))" using apply_chart_TM_chartX (*‹⟦∞ = ∞; section_of_TM_on (domain ?c) ?X; ?c ∈ atlas⟧ ⟹ smooth_on (codomain ?c) (apply_chart_TM ?c ∘ ?X ∘ inv_chart ?c) = diff_fun ∞ (charts_submanifold (domain ?c)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ?c p (snd (?X p)))›*) diff_from_M_to_TM_chartsD[OF 2 1, of ψ] (*‹ψ ∈ atlas ⟹ smooth_on (codomain ψ) (apply_chart_TM ψ ∘ (λp. (p, X p)) ∘ inv_chart ψ)›*) section_of_TM_subset[OF 1] (*‹(?T::'a::{second_countable_topology,t2_space} set) ⊆ carrier ⟹ section_of_TM_on ?T (λp::'a::{second_countable_topology,t2_space}. (p, (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p))›*) using "ψ.ψ" (*‹ψ ∈ atlas›*) by (simp add: domain_atlas_subset_carrier (*‹(?c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ∈ atlas ⟹ domain ?c ⊆ carrier›*)) ultimately show "?thesis" (*goal: ‹smooth_vector_field_local charts ψ X›*) using "ψ.c_manifold_local_axioms" (*‹c_manifold_local charts ∞ ψ›*) by (auto simp: smooth_vector_field_local_def (*‹smooth_vector_field_local ?charts ?ψ ?X ≡ c_manifold_local ?charts ∞ ?ψ ∧ smooth_vector_field_local_axioms ?charts ?ψ ?X›*) smooth_vector_field_local_axioms_def (*‹smooth_vector_field_local_axioms ?charts ?ψ ?X ≡ (∀p∈domain ?ψ. ?X p ∈ c_manifold.tangent_space ?charts ∞ p) ∧ diff_fun ∞ (manifold.charts_submanifold ?charts (domain ?ψ)) (λp. c_manifold_point.tangent_chart_fun ?charts ∞ ?ψ p (?X p))›*)) qed lemma smooth_vector_field_imp_local': fixes X ψ X⇩ψ defines "X⇩ψ ≡ restrict0 (domain ψ) X" assumes "smooth_vector_field X" "ψ ∈ atlas" shows "smooth_vector_field_local charts ψ X⇩ψ" unfolding smooth_vector_field_local_def smooth_vector_field_local_axioms_def assms(1) (*goal: ‹c_manifold_local charts ∞ ψ ∧ (∀p∈domain ψ. restrict0 (domain ψ) X p ∈ tangent_space p) ∧ diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (restrict0 (domain ψ) X p))›*) using smooth_vector_field_imp_local[OF assms ( 2 - )] (*‹smooth_vector_field_local charts ψ X›*) apply safe (*goal: ‹c_manifold_local charts ∞ ψ ∧ (∀p∈domain ψ. restrict0 (domain ψ) X p ∈ tangent_space p) ∧ diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (restrict0 (domain ψ) X p))›*) subgoal for using smooth_vector_field_local.axioms(1) (*‹smooth_vector_field_local ?charts ?ψ ?X ⟹ c_manifold_local ?charts ∞ ?ψ›*) by blast subgoal for using rough_vector_fieldE(1) (*‹rough_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ⟹ ?X (?p::'a) ∈ tangent_space ?p›*) smooth_vector_field_local.rough_vector_field (*‹smooth_vector_field_local ?charts ?ψ ?X ⟹ c_manifold.rough_vector_field ?charts ∞ (restrict0 (domain ?ψ) ?X)›*) by blast apply (rule diff_fun.diff_fun_cong[of _ _ "(λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p))"] (*‹⟦diff_fun ?k ?charts (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (X p)); ⋀x. x ∈ manifold.carrier ?charts ⟹ c_manifold_point.tangent_chart_fun charts ∞ ψ x (X x) = ?g x⟧ ⟹ diff_fun ?k ?charts ?g›*)) (*goal: ‹smooth_vector_field_local charts ψ X ⟹ diff_fun ∞ (charts_submanifold (domain ψ)) (λp. c_manifold_point.tangent_chart_fun charts ∞ ψ p (restrict0 (domain ψ) X p))›*) subgoal for by (simp add: assms( (*‹smooth_vector_field X› ‹ψ ∈ atlas›*) 2,3) smooth_vector_field_imp_local (*‹⟦smooth_vector_field ?X; ?ψ ∈ atlas⟧ ⟹ smooth_vector_field_local charts ?ψ ?X›*) smooth_vector_field_local.smooth_in_chart (*‹smooth_vector_field_local ?charts ?ψ ?X ⟹ diff_fun ∞ (manifold.charts_submanifold ?charts (domain ?ψ)) (λp. c_manifold_point.tangent_chart_fun ?charts ∞ ?ψ p (?X p))›*)) subgoal for by (metis IntD2 (*‹?c ∈ ?A ∩ ?B ⟹ ?c ∈ ?B›*) inf_sup_aci( (*‹inf ?x ?y = inf ?y ?x›*) 1) open_domain (*‹open (domain ?c)›*) open_imp_submanifold (*‹open ?S ⟹ submanifold charts ∞ ?S›*) restrict0_apply_in (*‹?x ∈ ?A ⟹ restrict0 ?A ?f ?x = ?f ?x›*) submanifold.carrier_submanifold (*‹submanifold ?charts ?k ?S ⟹ manifold.carrier (manifold.charts_submanifold ?charts ?S) = ?S ∩ manifold.carrier ?charts›*)) . lemma smooth_vector_field_if_local: assumes "∀p∈carrier. ∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c X" "extensional0 carrier X" shows "smooth_vector_field X" proof (unfold smooth_vector_field_def (*‹smooth_vector_field ?X ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp. (p, ?X p))›*) diff_from_M_to_TM_def (*‹k_diff_from_M_to_TM ?k' ?X ≡ ∀x. x ∈ carrier ⟶ (∃c∈atlas. x ∈ domain c ∧ ?X ` domain c ⊆ domain_TM c ∧ ?k'-smooth_on (codomain c) (apply_chart_TM c ∘ ?X ∘ inv_chart c))›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goals: 1. ‹rough_vector_field X› 2. ‹⋀x. x ∈ carrier ⟹ ∃c∈atlas. x ∈ domain c ∧ (λp. (p, X p)) ` domain c ⊆ domain_TM c ∧ smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)›*) show vec_field_X: "rough_vector_field X" by (metis assms( (*‹∀p∈carrier. ∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c X› ‹extensional0 carrier X›*) 1,2) rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*) smooth_vector_field_local.vector_field (*‹smooth_vector_field_local ?charts ?ψ ?X ⟹ ∀p∈domain ?ψ. ?X p ∈ c_manifold.tangent_space ?charts ∞ p›*)) fix p assume "p∈carrier" (*‹(p::'a) ∈ carrier›*) then obtain c where c: "c ∈ atlas" and p: "p ∈ domain c" and X: "smooth_vector_field_local charts c X" (*goal: ‹(⋀c. ⟦c ∈ atlas; p ∈ domain c; smooth_vector_field_local charts c X⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹∀p∈carrier. ∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c X›*) by blast interpret X: smooth_vector_field_local charts c X using X (*‹smooth_vector_field_local charts c X›*) . have im_domain: "(λp. (p, X p)) ` domain c ⊆ domain_TM c" using rough_vector_fieldE[OF vec_field_X] (*‹X ?p ∈ tangent_space ?p› ‹extensional0 carrier X›*) in_carrier_atlasI[OF c] (*‹?x ∈ domain c ⟹ ?x ∈ carrier›*) by (auto simp: domain_TM_def (*‹domain_TM (?c::('a, 'b) chart) ≡ {(p::'a, v::('a ⇒ real) ⇒ real). p ∈ domain ?c ∧ v ∈ tangent_space p}›*)) have smooth_X: "smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)" using X.apply_chart_TM_chart_X (*‹smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c) = diff_fun ∞ (charts_submanifold (domain c)) X.chart_X›*) X.smooth_in_chart_X (*‹diff_fun ∞ (charts_submanifold (domain c)) X.chart_X›*) by blast show "∃c∈atlas. p ∈ domain c ∧ (λp. (p, X p)) ` domain c ⊆ domain_TM c ∧ smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)" using c (*‹c ∈ atlas›*) p (*‹p ∈ domain c›*) im_domain (*‹(λp::'a::{second_countable_topology,t2_space}. (p, (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p)) ` domain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ⊆ domain_TM c›*) smooth_X (*‹smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)›*) by blast qed lemma smooth_vector_field_iff_local: assumes "extensional0 carrier X" shows "(∀c∈atlas. smooth_vector_field_local charts c X) ⟷ smooth_vector_field X" using smooth_vector_field_imp_local (*‹⟦smooth_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real); (?ψ::('a, 'b) chart) ∈ atlas⟧ ⟹ smooth_vector_field_local (charts::('a, 'b) chart set) ?ψ ?X›*) smooth_vector_field_if_local (*‹⟦∀p∈carrier. ∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c ?X; extensional0 carrier ?X⟧ ⟹ smooth_vector_field ?X›*) by (meson assms (*‹extensional0 carrier (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) atlasE (*‹⟦(?x::'a) ∈ carrier; ⋀c::('a, 'b) chart. ⟦c ∈ atlas; ?x ∈ domain c⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*))<close> lemma (in smooth_manifold) smooth_vector_field_local: assumes "c ∈ atlas" "∀p∈domain c. X p ∈ tangent_space p" shows "smooth_vector_field_local charts c X ⟷ smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)" (* unfolding smooth_vector_field_local_def smooth_vector_field_local_axioms_def *) (* apply (intro iffI) *) (* using smooth_vector_field_local.apply_chart_TM_chart_X smooth_vector_field_local.intro smooth_vector_field_local.smooth_in_chart_X smooth_vector_field_local_axioms_def apply blast *) (* apply (simp add: assms c_manifold_axioms c_manifold_local.intro c_manifold_local_axioms.intro) *) (* apply (rule c_manifold.diff_funI[OF charts_submanifold, OF open_domain[of c]]) *) (* unfolding apply_chart_TM_def apply (simp add: o_def) *) (* apply (rule bexI[of _ c "c_manifold.atlas (charts_submanifold (domain c)) ∞"]) *) proof (-) (*goal: ‹smooth_vector_field_local (charts::('a, 'b) chart set) (c::('a, 'b) chart) (X::'a ⇒ ('a ⇒ real) ⇒ real) = smooth_on (codomain c) (apply_chart_TM c ∘ (λp::'a. (p, X p)) ∘ inv_chart c)›*) interpret c: submanifold charts "∞" "domain c" using open_domain (*‹open (domain ?c)›*) apply unfold_locales (*goal: ‹submanifold charts ∞ (domain c)›*) by simp let ?c1 = "λx. c (inv_chart c x)" let ?c2 = "λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))" { fix x assume smoothTM: "smooth_on (codomain c) (λx. (?c1 x, ?c2 x))" and x: "x ∈ c.sub.carrier" (*‹smooth_on (codomain (c::('a, 'b) chart)) (λx::'b. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun (charts::('a, 'b) chart set) ∞ c (inv_chart c x) ((X::'a ⇒ ('a ⇒ real) ⇒ real) (inv_chart c x))))› ‹(x::'a) ∈ c.sub.carrier›*) have loc_simp: "snd ∘ (λx. (?c1 x, ?c2 x)) = ?c2" by auto have "x ∈ domain c ∧ c ∈ c.sub.atlas ∧ smooth_on (codomain c) ?c2" using x (*‹(x::'a) ∈ c.sub.carrier›*) apply (simp add: assms( (*‹c ∈ atlas›*) 1) atlas_is_atlas (*‹⟦?a1.0 ∈ atlas; ?a2.0 ∈ atlas⟧ ⟹ ∞-smooth_compat ?a1.0 ?a2.0›*) c.sub.maximal_atlas (*‹⟦⋀c'. c' ∈ c.sub.atlas ⟹ ∞-smooth_compat ?c c'; domain ?c ⊆ c.sub.carrier⟧ ⟹ ?c ∈ c.sub.atlas›*) c.submanifold_atlasE (*‹?c ∈ c.sub.atlas ⟹ ?c ∈ atlas›*) domain_atlas_subset_carrier (*‹?c ∈ atlas ⟹ domain ?c ⊆ carrier›*)) (*goal: ‹x ∈ domain c ∧ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))›*) apply (subst loc_simp[symmetric, unfolded o_def] (*‹(λx::'b::euclidean_space. c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) (inv_chart c x) ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) (inv_chart c x))) = (λx::'b::euclidean_space. snd (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))))›*)) (*goal: ‹x ∈ domain c ∧ x ∈ carrier ⟹ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))›*) apply (rule smooth_on_snd[of ∞, OF _ open_codomain[of c]] (*‹smooth_on (codomain c) ?f ⟹ smooth_on (codomain c) (λx. snd (?f x))›*)) (*goal: ‹x ∈ domain c ∧ x ∈ carrier ⟹ smooth_on (codomain c) (λx. snd (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))))›*) using smoothTM (*‹smooth_on (codomain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)) (λx::'b::euclidean_space. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ c (inv_chart c x) ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) (inv_chart c x))))›*) . } thus "?thesis" (*goal: ‹smooth_vector_field_local charts c X = smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)›*) unfolding smooth_vector_field_local_def smooth_vector_field_local_axioms_def (*goal: ‹(c_manifold_local charts ∞ c ∧ (∀p∈domain c. X p ∈ tangent_space p) ∧ diff_fun ∞ (charts_submanifold (domain c)) (λp. c_manifold_point.tangent_chart_fun charts ∞ c p (X p))) = smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)›*) apply (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goal: ‹(c_manifold_local charts ∞ c ∧ (∀p∈domain c. X p ∈ tangent_space p) ∧ diff_fun ∞ (charts_submanifold (domain c)) (λp. c_manifold_point.tangent_chart_fun charts ∞ c p (X p))) = smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)›*) using smooth_vector_field_local.apply_chart_TM_chart_X (*‹smooth_vector_field_local (?charts::(?'a, ?'b) chart set) (?ψ::(?'a, ?'b) chart) (?X::?'a ⇒ (?'a ⇒ real) ⇒ real) ⟹ smooth_on (codomain ?ψ) (c_manifold.apply_chart_TM ?charts ?ψ ∘ (λp::?'a. (p, ?X p)) ∘ inv_chart ?ψ) = diff_fun ∞ (manifold.charts_submanifold ?charts (domain ?ψ)) (smooth_vector_field_local.chart_X ?charts ?ψ ?X)›*) smooth_vector_field_local.intro (*‹⟦c_manifold_local ?charts ∞ ?ψ; smooth_vector_field_local_axioms ?charts ?ψ ?X⟧ ⟹ smooth_vector_field_local ?charts ?ψ ?X›*) smooth_vector_field_local.smooth_in_chart_X (*‹smooth_vector_field_local ?charts ?ψ ?X ⟹ diff_fun ∞ (manifold.charts_submanifold ?charts (domain ?ψ)) (smooth_vector_field_local.chart_X ?charts ?ψ ?X)›*) smooth_vector_field_local_axioms_def (*‹smooth_vector_field_local_axioms ?charts ?ψ ?X ≡ (∀p∈domain ?ψ. ?X p ∈ c_manifold.tangent_space ?charts ∞ p) ∧ diff_fun ∞ (manifold.charts_submanifold ?charts (domain ?ψ)) (λp. c_manifold_point.tangent_chart_fun ?charts ∞ ?ψ p (?X p))›*) apply blast (*top goal: ‹⟦⋀x::'a. ⟦smooth_on (codomain (c::('a, 'b) chart)) (λx::'b. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun (charts::('a, 'b) chart set) ∞ c (inv_chart c x) ((X::'a ⇒ ('a ⇒ real) ⇒ real) (inv_chart c x)))); x ∈ c.sub.carrier⟧ ⟹ x ∈ domain c ∧ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx::'b. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); c_manifold_local charts ∞ c ∧ (∀p::'a∈domain c. X p ∈ tangent_space p) ∧ diff_fun ∞ (charts_submanifold (domain c)) (λp::'a. c_manifold_point.tangent_chart_fun charts ∞ c p (X p))⟧ ⟹ smooth_on (codomain c) (apply_chart_TM c ∘ (λp::'a. (p, X p)) ∘ inv_chart c)› and 1 goal remains*) apply (simp add: assms (*‹c ∈ atlas› ‹∀p∈domain c. X p ∈ tangent_space p›*) c_manifold_axioms (*‹c_manifold charts ∞›*) c_manifold_local.intro (*‹⟦c_manifold ?charts ?k; c_manifold_local_axioms ?charts ?k ?ψ⟧ ⟹ c_manifold_local ?charts ?k ?ψ›*) c_manifold_local_axioms.intro (*‹?ψ ∈ c_manifold.atlas ?charts ?k ⟹ c_manifold_local_axioms ?charts ?k ?ψ›*)) (*goal: ‹⟦⋀x. ⟦smooth_on (codomain c) (λx. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))); x ∈ c.sub.carrier⟧ ⟹ x ∈ domain c ∧ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)⟧ ⟹ c_manifold_local charts ∞ c ∧ (∀p∈domain c. X p ∈ tangent_space p) ∧ diff_fun ∞ (charts_submanifold (domain c)) (λp. c_manifold_point.tangent_chart_fun charts ∞ c p (X p))›*) apply (rule c_manifold.diff_funI[OF charts_submanifold, OF open_domain[of c]] (*‹(⋀x. x ∈ c.sub.carrier ⟹ ∃c1∈c.sub.atlas. x ∈ domain c1 ∧ smooth_on (codomain c1) (?f ∘ inv_chart c1)) ⟹ diff_fun ∞ (charts_submanifold (domain c)) ?f›*)) (*goal: ‹⟦⋀x. ⟦smooth_on (codomain c) (λx. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))); x ∈ domain c ∧ x ∈ carrier⟧ ⟹ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); smooth_on (codomain c) (apply_chart_TM c ∘ (λp. (p, X p)) ∘ inv_chart c)⟧ ⟹ diff_fun ∞ (charts_submanifold (domain c)) (λp. c_manifold_point.tangent_chart_fun charts ∞ c p (X p))›*) unfolding apply_chart_TM_def (*goal: ‹⋀x. ⟦⋀x. ⟦smooth_on (codomain c) (λx. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))); x ∈ domain c ∧ x ∈ carrier⟧ ⟹ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); smooth_on (codomain c) ((λ(p, v). (apply_chart c p, c_manifold_point.tangent_chart_fun charts ∞ c p v)) ∘ (λp. (p, X p)) ∘ inv_chart c); x ∈ c.sub.carrier⟧ ⟹ ∃c1∈c.sub.atlas. x ∈ domain c1 ∧ smooth_on (codomain c1) ((λp. c_manifold_point.tangent_chart_fun charts ∞ c p (X p)) ∘ inv_chart c1)›*) apply (simp add: o_def (*‹(?f::?'b::type ⇒ ?'c::type) ∘ (?g::?'a::type ⇒ ?'b::type) = (λx::?'a::type. ?f (?g x))›*)) (*goal: ‹⋀x. ⟦⋀x. ⟦smooth_on (codomain c) (λx. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))); x ∈ domain c ∧ x ∈ carrier⟧ ⟹ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); smooth_on (codomain c) ((λ(p, v). (apply_chart c p, c_manifold_point.tangent_chart_fun charts ∞ c p v)) ∘ (λp. (p, X p)) ∘ inv_chart c); x ∈ c.sub.carrier⟧ ⟹ ∃c1∈c.sub.atlas. x ∈ domain c1 ∧ smooth_on (codomain c1) ((λp. c_manifold_point.tangent_chart_fun charts ∞ c p (X p)) ∘ inv_chart c1)›*) apply (rule bexI[of _ c "c_manifold.atlas (charts_submanifold (domain c)) ∞"] (*‹⟦?P c; c ∈ c.sub.atlas⟧ ⟹ ∃x∈c.sub.atlas. ?P x›*)) (*goals: 1. ‹⋀x. ⟦⋀x. x ∈ domain c ∧ x ∈ carrier ⟹ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); smooth_on (codomain c) (λx. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))); x ∈ domain c ∧ x ∈ carrier⟧ ⟹ x ∈ domain c ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))› 2. ‹⋀x. ⟦⋀x. x ∈ domain c ∧ x ∈ carrier ⟹ c ∈ c.sub.atlas ∧ smooth_on (codomain c) (λx. c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x))); smooth_on (codomain c) (λx. (apply_chart c (inv_chart c x), c_manifold_point.tangent_chart_fun charts ∞ c (inv_chart c x) (X (inv_chart c x)))); x ∈ domain c ∧ x ∈ carrier⟧ ⟹ c ∈ c.sub.atlas› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . qed lemma (in c_manifold) diff_fun_deriv_chart': fixes i::'b assumes c:"c∈atlas" and f:"diff_fun_on (domain c) f" and k: "k>0" shows "diff_fun (k-1) (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (c x)) i)" proof (-) (*goal: ‹diff_fun (k - 1) (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)›*) have local_simps[simp]: "k - 1 + 1 = k" using k (*‹0 < k›*) by (metis add.commute (*‹(?a::?'a) + (?b::?'a) = ?b + ?a›*) add_diff_assoc_enat (*‹(?z::enat) ≤ (?y::enat) ⟹ (?x::enat) + (?y - ?z) = ?x + ?y - ?z›*) add_diff_cancel_enat (*‹(?x::enat) ≠ ∞ ⟹ ?x + (?y::enat) - ?x = ?y›*) ileI1 (*‹(?m::enat) < (?n::enat) ⟹ eSuc ?m ≤ ?n›*) infinity_ne_i1 (*‹∞ ≠ (1::enat)›*) one_eSuc (*‹(1::enat) = eSuc (0::enat)›*)) interpret c1: c_manifold_local charts "k-1" c apply unfold_locales (*goals: 1. ‹⋀c1 c2. ⟦c1 ∈ charts; c2 ∈ charts⟧ ⟹ (k - 1)-smooth_compat c1 c2› 2. ‹c ∈ c_manifold.atlas charts (k - 1)› discuss goal 1*) apply (metis c_manifold_def (*‹c_manifold ?charts ?k ≡ ∀c1 c2. c1 ∈ ?charts ⟶ c2 ∈ ?charts ⟶ ?k-smooth_compat c1 c2›*) c_manifold_order_le (*‹?l ≤ k ⟹ c_manifold charts ?l›*) le_iff_add (*‹(?a ≤ ?b) = (∃c. ?b = ?a + c)›*) local_simps (*‹k - 1 + 1 = k›*)) (*discuss goal 2*) apply (metis c (*‹(c::('a, 'b) chart) ∈ atlas›*) in_atlas_order_le (*‹⟦(?l::enat) ≤ (k::enat); (?c::('a, 'b) chart) ∈ atlas⟧ ⟹ ?c ∈ c_manifold.atlas (charts::('a, 'b) chart set) ?l›*) le_iff_add (*‹((?a::?'a) ≤ (?b::?'a)) = (∃c::?'a. ?b = ?a + c)›*) local_simps (*‹(k::enat) - (1::enat) + (1::enat) = k›*)) (*proven 2 subgoals*) . interpret f': diff_fun k "charts_submanifold (domain c)" f using diff_fun_on_open[of "domain c" f] (*‹open (domain c) ⟹ diff_fun_on (domain c) f = (domain c ⊆ carrier ∧ diff_fun k (charts_submanifold (domain c)) f)›*) f (*‹diff_fun_on (domain c) f›*) by simp { fix x and j :: 'b assume x: "x∈domain c" "x∈carrier" (*‹(x::'a) ∈ domain (c::('a, 'b) chart)› ‹(x::'a) ∈ carrier›*) have "(k-1)-smooth_on (codomain c) (λy. frechet_derivative (f ∘ (inv_chart c)) (at y) j)" apply (rule derivative_is_smooth'[of _ "codomain c"] (*‹(?k + 1)-smooth_on (codomain c) ?f ⟹ ?k-smooth_on (codomain c) (λx. frechet_derivative ?f (at x) ?v)›*), simp) (*goal: ‹(k - 1)-smooth_on (codomain c) (λy. frechet_derivative (f ∘ inv_chart c) (at y) j)›*) apply (rule f'.diff_fun_between_chartsD (*‹⟦?c ∈ f'.src.atlas; ?x ∈ domain ?c⟧ ⟹ k-smooth_on (codomain ?c) (f ∘ inv_chart ?c)›*)) (*goal: ‹k-smooth_on (codomain c) (f ∘ inv_chart c)›*) using c (*‹c ∈ atlas›*) "c_manifold_local.sub_ψ" (*‹c_manifold_local ?charts ?k ?ψ ⟹ ?ψ ∈ c_manifold.atlas (manifold.charts_submanifold ?charts (domain ?ψ)) ?k›*) c_manifold_point (*‹⟦?c ∈ atlas; ?p ∈ domain ?c⟧ ⟹ c_manifold_point charts k ?c ?p›*) c_manifold_point.axioms(1) (*‹c_manifold_point (?charts::(?'a, ?'b) chart set) (?k::enat) (?ψ::(?'a, ?'b) chart) (?p::?'a) ⟹ c_manifold_local ?charts ?k ?ψ›*) k (*‹0 < k›*) x(1) (*‹x ∈ domain c›*) apply - (*goals: 1. ‹⟦c ∈ atlas; ⋀charts k ψ. c_manifold_local charts k ψ ⟹ ψ ∈ c_manifold.atlas (manifold.charts_submanifold charts (domain ψ)) k; ⋀c p. ⟦c ∈ atlas; p ∈ domain c⟧ ⟹ c_manifold_point charts k c p; ⋀charts k ψ p. c_manifold_point charts k ψ p ⟹ c_manifold_local charts k ψ; 0 < k; x ∈ domain c⟧ ⟹ c ∈ f'.src.atlas› 2. ‹⟦c ∈ atlas; ⋀charts k ψ. c_manifold_local charts k ψ ⟹ ψ ∈ c_manifold.atlas (manifold.charts_submanifold charts (domain ψ)) k; ⋀c p. ⟦c ∈ atlas; p ∈ domain c⟧ ⟹ c_manifold_point charts k c p; ⋀charts k ψ p. c_manifold_point charts k ψ p ⟹ c_manifold_local charts k ψ; 0 < k; x ∈ domain c⟧ ⟹ ?x2 ∈ domain c› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . then have "(k-1)-smooth_on (codomain c) (λx. frechet_derivative (λx. f (inv_chart c x)) (at (c (inv_chart c x))) j)" by (auto intro: smooth_on_cong (*‹⟦?k-smooth_on ?S ?g; open ?S; ⋀x. x ∈ ?S ⟹ ?f x = ?g x⟧ ⟹ ?k-smooth_on ?S ?f›*) simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) } then show "?thesis" (*goal: ‹diff_fun (k - 1) (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)›*) by (auto intro!: c1.sub_ψ.sub.diff_funI (*‹(⋀x. x ∈ c1.sub_ψ.sub.carrier ⟹ ∃c1∈c1.sub_ψ.sub.atlas. x ∈ domain c1 ∧ (k - 1)-smooth_on (codomain c1) (?f ∘ inv_chart c1)) ⟹ diff_fun (k - 1) (charts_submanifold (domain c)) ?f›*) bexI[of _ c] (*‹⟦?P c; c ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*) simp: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) c1.sub_ψ (*‹c ∈ c1.sub_ψ.sub.atlas›*)) qed lemma diff_fun_deriv_chart: fixes i::'b assumes c:"c∈atlas" and f:"diff_fun_on (domain c) f" shows "diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (c x)) i)" using diff_fun_deriv_chart'[OF assms] (*‹0 < ∞ ⟹ diff_fun (∞ - 1) (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) ?i)›*) by auto lemma (in c_manifolds) diff_localI2: "diff k charts1 charts2 f" if "∀x∈src.carrier. (∃U. diff k (src.charts_submanifold U) charts2 f ∧ open U ∧ x ∈ U)" using diff_localI (*‹⟦⋀x. x ∈ src.carrier ⟹ diff k (src.charts_submanifold (?U x)) charts2 ?f; ⋀x. x ∈ src.carrier ⟹ open (?U x); ⋀x. x ∈ src.carrier ⟹ x ∈ ?U x⟧ ⟹ diff k charts1 charts2 ?f›*) that (*‹∀x::'a∈src.carrier. ∃U::'a set. diff (k::enat) (src.charts_submanifold U) (charts2::('c, 'd) chart set) (f::'a ⇒ 'c) ∧ open U ∧ x ∈ U›*) by metis subsection ‹Smooth vector fields as maps $C^\infty(M) \to C^\infty(M)$.› text ‹Proposition 8.14 in Lee 2012.› lemma vector_field_smooth_iff: assumes X: "rough_vector_field X" shows "smooth_vector_field X ⟷ (∀f∈diff_fun_space. (X ˝ f) ∈ diff_fun_space)" (is ‹?LHS ⟷ ?RHS1›) and "smooth_vector_field X ⟷ (∀U f. open U ∧ U ⊆ carrier ∧ f∈(c_manifold.diff_fun_space (charts_submanifold U) ∞) ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U))" (is ‹?LHS ⟷ ?RHS2›) proof (-) (*goals: 1. ‹smooth_vector_field X = (∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space)› 2. ‹smooth_vector_field X = (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U))›*) text ‹Prove a chain of implications \<^term>‹?LHS ⟶ ?RHS1 ⟶ ?RHS2 ⟶ ?LHS› to conclude both equivalences, following Lee 2012, pp.~180--181.› have "?RHS1" if smooth_X: "?LHS" proof (standard) (*goal: ‹⋀f. f ∈ diff_fun_space ⟹ (λp. X p f) ∈ diff_fun_space›*) fix f assume f: "f ∈ diff_fun_space" (*‹(f::'a ⇒ real) ∈ diff_fun_space›*) { fix p assume p: "p∈carrier" (*‹(p::'a) ∈ carrier›*) obtain c where c: "p ∈ domain c" "c ∈ atlas" (*goal: ‹(⋀c. ⟦p ∈ domain c; c ∈ atlas⟧ ⟹ thesis) ⟹ thesis›*) using atlasE (*‹⟦?x ∈ carrier; ⋀c. ⟦c ∈ atlas; ?x ∈ domain c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) p (*‹p ∈ carrier›*) by blast interpret p: c_manifold_point charts "∞" c p by (simp add: p (*‹(p::'a) ∈ carrier›*) c_manifold_point (*‹⟦(?c::('a, 'b) chart) ∈ atlas; (?p::'a) ∈ domain ?c⟧ ⟹ c_manifold_point (charts::('a, 'b) chart set) ∞ ?c ?p›*) c (*‹(p::'a) ∈ domain (c::('a, 'b) chart)› ‹(c::('a, 'b) chart) ∈ atlas›*)) { fix x assume x: "x ∈ domain c" (*‹(x::'a) ∈ domain (c::('a, 'b) chart)›*) interpret x: c_manifold_point charts "∞" c x by (simp add: x (*‹x ∈ domain c›*) c_manifold_point (*‹⟦?c ∈ atlas; ?p ∈ domain ?c⟧ ⟹ c_manifold_point charts ∞ ?c ?p›*)) have Xxf_1: "X x f = (∑i∈Basis. p.vector_field_component X i x *⇩R p.coordinate_vector_field i x) f" by (simp only: p.vector_field_local_representation[OF _ X x] (*‹∞ = ∞ ⟹ (X::'a ⇒ ('a ⇒ real) ⇒ real) (x::'a) = (∑i::'b∈Basis. p.vector_field_component X i x *⇩R p.coordinate_vector_field i x)›*)) then have Xxf_2: "X x f = (∑i∈Basis. p.vector_field_component X i x *⇩R (frechet_derivative (f ∘ inv_chart c) (at (c x)) i))" using x.coordinate_vector_apply_in[OF _ f] (*‹∞ = ∞ ⟹ x.coordinate_vector ?b f = frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) ?b›*) by (simp add: sum_apply (*‹sum (?f::?'b::type ⇒ ?'c::type ⇒ ?'a::comm_monoid_add) (?X::?'b::type set) (?i::?'c::type) = (∑x::?'b::type∈?X. ?f x ?i)›*) p.coordinate_vector_field_def (*‹p.coordinate_vector_field (?i::'b::euclidean_space) (?p::'a::{second_countable_topology,t2_space}) ≡ c_manifold_point.coordinate_vector (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) ∞ (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart) ?p ?i›*)) } then have Xxf: "X x f = (∑i∈Basis. p.vector_field_component X i x *⇩R frechet_derivative (f ∘ inv_chart c) (at (c x)) i)" if "x ∈ p.sub_ψ.sub.carrier" for x using that (*‹x ∈ p.sub_ψ.sub.carrier›*) by simp have diff_components_X: "(∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i))" using p.vector_field_smooth_local_iff (*‹⟦∞ = ∞; ∀p∈domain c. ?X p ∈ tangent_space p⟧ ⟹ smooth_vector_field_local charts c ?X = (∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component ?X i))›*) rough_vector_field_subset[OF X] (*‹?T ⊆ carrier ⟹ rough_vector_field (restrict0 ?T X)›*) smooth_X (*‹smooth_vector_field X›*) domain_atlas_subset_carrier (*‹(?c::('a, 'b) chart) ∈ atlas ⟹ domain ?c ⊆ carrier›*) "p.ψ" (*‹c ∈ atlas›*) smooth_vector_field_imp_local (*‹⟦smooth_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real); (?ψ::('a, 'b) chart) ∈ atlas⟧ ⟹ smooth_vector_field_local (charts::('a, 'b) chart set) ?ψ ?X›*) by (meson smooth_vector_field_local.diff_component' (*‹⟦smooth_vector_field_local ?charts ?ψ ?X; ?i ∈ Basis⟧ ⟹ c_manifold.diff_fun_on ?charts ∞ (domain ?ψ) (c_manifold_local.vector_field_component ?charts ∞ ?ψ ?X ?i)›*)) have "diff_fun_on (domain c) f" using diff_fun.diff_fun_submanifold[OF diff_fun_spaceD [ OF f ]] (*‹open ?S ⟹ diff_fun ∞ (charts_submanifold ?S) f›*) by (simp add: diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun ∞ (charts_submanifold ?A) ?f)›*) domain_atlas_subset_carrier (*‹?c ∈ atlas ⟹ domain ?c ⊆ carrier›*)) note diff_fun_deriv_chart_f = diff_fun_deriv_chart[OF c ( 2 ) this] (*‹diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) ?i)›*) have diff_Xf: "diff_fun ∞ (charts_submanifold (domain c)) (X˝f)" apply (rule diff_fun.diff_fun_cong[OF _ Xxf[symmetric]] (*‹⟦diff_fun ?k ?charts (λx. ∑i∈Basis. p.vector_field_component X i (?x1 x) *⇩R frechet_derivative (f ∘ inv_chart c) (at (apply_chart c (?x1 x))) i); ⋀x. x ∈ manifold.carrier ?charts ⟹ ?x1 x ∈ p.sub_ψ.sub.carrier⟧ ⟹ diff_fun ?k ?charts (λx. X (?x1 x) f)›*)) (*goal: ‹diff_fun ∞ (charts_submanifold (domain c)) (λp. X p f)›*) apply (rule p.sub_ψ.sub.diff_fun_sum (*‹(⋀i::?'c. i ∈ (?S::?'c set) ⟹ diff_fun ∞ (charts_submanifold (domain (c::('a, 'b) chart))) ((?f::?'c ⇒ 'a ⇒ ?'d) i)) ⟹ diff_fun ∞ (charts_submanifold (domain c)) (λx::'a. ∑i::?'c∈?S. ?f i x)›*)) (*top goal: ‹diff_fun ∞ (charts_submanifold (domain c)) (λp. ∑i∈Basis. p.vector_field_component X i p *⇩R frechet_derivative (f ∘ inv_chart c) (at (apply_chart c p)) i)› and 1 goal remains*) apply (rule p.sub_ψ.sub.diff_fun_scaleR (*‹⟦diff_fun ∞ (charts_submanifold (domain c)) ?a; diff_fun ∞ (charts_submanifold (domain c)) ?b⟧ ⟹ diff_fun ∞ (charts_submanifold (domain c)) (λx. ?a x *⇩R ?b x)›*)) (*top goal: ‹⋀i. i ∈ Basis ⟹ diff_fun ∞ (charts_submanifold (domain c)) (λx. p.vector_field_component X i x *⇩R frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)› and 1 goal remains*) using diff_components_X (*‹∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i)›*) diff_fun_deriv_chart_f (*‹diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) ?i)›*) apply - (*goals: 1. ‹⋀i. ⟦i ∈ Basis; ∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i); ⋀i. diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)⟧ ⟹ diff_fun ∞ (charts_submanifold (domain c)) (p.vector_field_component X i)› 2. ‹⋀i. ⟦i ∈ Basis; ∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i); ⋀i. diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)⟧ ⟹ diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)› 3. ‹⋀p. ⟦p ∈ p.sub_ψ.sub.carrier; ∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i); ⋀i. diff_fun ∞ (charts_submanifold (domain c)) (λx. frechet_derivative (f ∘ inv_chart c) (at (apply_chart c x)) i)⟧ ⟹ p ∈ p.sub_ψ.sub.carrier› discuss goal 1*) apply (simp add: diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun ∞ (charts_submanifold ?A) ?f)›*)) (*discuss goal 2*) apply (simp add: diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun ∞ (charts_submanifold ?A) ?f)›*)) (*discuss goal 3*) apply (simp add: diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun ∞ (charts_submanifold ?A) ?f)›*)) (*proven 3 subgoals*) . have "smooth_on (codomain c) ((X˝f) ∘ inv_chart c)" using diff_Xf (*‹diff_fun ∞ (charts_submanifold (domain c)) (λp. X p f)›*) apply (rule diff_fun.diff_fun_between_chartsD (*‹⟦diff_fun ?k ?charts ?f; ?c ∈ c_manifold.atlas ?charts ?k; ?x ∈ domain ?c⟧ ⟹ ?k-smooth_on (codomain ?c) (?f ∘ inv_chart ?c)›*)) (*goal: ‹smooth_on (codomain c) ((λp. X p f) ∘ inv_chart c)›*) using "p.sub_ψ" (*‹c ∈ p.sub_ψ.sub.atlas›*) c(1) (*‹p ∈ domain c›*) apply - (*goals: 1. ‹⟦c ∈ p.sub_ψ.sub.atlas; p ∈ domain c⟧ ⟹ c ∈ p.sub_ψ.sub.atlas› 2. ‹⟦c ∈ p.sub_ψ.sub.atlas; p ∈ domain c⟧ ⟹ ?x ∈ domain c› discuss goal 1*) apply simp (*discuss goal 2*) apply blast (*proven 2 subgoals*) . hence "∃c1∈atlas. p ∈ domain c1 ∧ ∞-smooth_on (codomain c1) ((X˝f) ∘ inv_chart c1)" using c (*‹(p::'a::{second_countable_topology,t2_space}) ∈ domain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)› ‹c ∈ atlas›*) by blast } moreover have "extensional0 carrier (X ˝ f)" using rough_vector_fieldE(2)[OF X] (*‹extensional0 carrier X›*) by (simp add: extensional0_def (*‹extensional0 ?A ?f = (∀x. x ∉ ?A ⟶ ?f x = 0)›*)) ultimately show "(X ˝ f) ∈ diff_fun_space" unfolding diff_fun_space_def (*goal: ‹(λp::'a. (X::'a ⇒ ('a ⇒ real) ⇒ real) p (f::'a ⇒ real)) ∈ {f::'a ⇒ real. diff_fun ∞ (charts::('a, 'b) chart set) f ∧ extensional0 carrier f}›*) by (auto intro: diff_funI (*‹(⋀x. x ∈ carrier ⟹ ∃c1∈atlas. x ∈ domain c1 ∧ smooth_on (codomain c1) (?f ∘ inv_chart c1)) ⟹ diff_fun ∞ charts ?f›*)) qed moreover have "?RHS2" if "?RHS1" proof (safe) (*goal: ‹⋀(U::'a set) f::'a ⇒ real. ⟦open U; U ⊆ carrier; f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞⟧ ⟹ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at (X::'a ⇒ ('a ⇒ real) ⇒ real) f U)›*) fix U and f assume U: "open U" "U ⊆ carrier" and f: "f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞" (*‹open (U::'a set)› ‹(U::'a set) ⊆ carrier› ‹(f::'a ⇒ real) ∈ c_manifold.diff_fun_space (charts_submanifold (U::'a set)) ∞›*) interpret U: submanifold charts "∞" U using U(1) (*‹open (U::'a::{second_countable_topology,t2_space} set)›*) apply unfold_locales (*goal: ‹submanifold charts ∞ U›*) by simp show "diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U)" proof (intro U.sub.manifold_eucl.diff_localI2 (*‹∀x∈U.sub.carrier. ∃U. diff ∞ (U.sub.charts_submanifold U) charts_eucl ?f ∧ open U ∧ x ∈ U ⟹ diff_fun ∞ (charts_submanifold U) ?f›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀x. x ∈ U.sub.carrier ⟹ ∃Ua. diff ∞ (U.sub.charts_submanifold Ua) charts_eucl (vec_field_apply_fun_in_at X f U) ∧ open Ua ∧ x ∈ Ua›*) fix x assume x: "x ∈ U.sub.carrier" (*‹(x::'a) ∈ U.sub.carrier›*) from U.sub.precompact_neighborhoodE[OF this] (*‹(⋀C. ⟦x ∈ C; open C; compact (closure C); closure C ⊆ U.sub.carrier⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain C where C: "x ∈ C" "open C" "compact (closure C)" "closure C ⊆ U.sub.carrier" (*goal: ‹(⋀C. ⟦x ∈ C; open C; compact (closure C); closure C ⊆ U.sub.carrier⟧ ⟹ thesis) ⟹ thesis›*) . from U.extension_lemma_submanifoldE[OF U.sub.diff_fun_spaceD [ OF f ] closed_closure C ( 4 )] (*‹(⋀f'. ⟦diff_fun ∞ charts f'; ⋀x. x ∈ closure C ⟹ f' x = f x; csupport_on carrier f' ∩ carrier ⊆ U.sub.carrier⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain f' where f': "diff_fun ∞ charts f'" "(⋀x. x ∈ closure C ⟹ f' x = f x)" "csupport_on carrier f' ∩ carrier ⊆ U.sub.carrier" (*goal: ‹(⋀f'. ⟦diff_fun ∞ charts f'; ⋀x. x ∈ closure C ⟹ f' x = f x; csupport_on carrier f' ∩ carrier ⊆ U.sub.carrier⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?f' = "restrict0 U f'" have 1: "?f' ∈ diff_fun_space" unfolding diff_fun_space_def (*goal: ‹restrict0 U f' ∈ {f. diff_fun ∞ charts f ∧ extensional0 carrier f}›*) apply safe (*goal: ‹restrict0 (U::'a::{second_countable_topology,t2_space} set) (f'::'a::{second_countable_topology,t2_space} ⇒ real) ∈ {f::'a::{second_countable_topology,t2_space} ⇒ real. diff_fun ∞ (charts::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart set) f ∧ extensional0 carrier f}›*) subgoal for apply (rule diff_fun.diff_fun_cong[OF f'(1)] (*‹(⋀x. x ∈ carrier ⟹ f' x = ?g x) ⟹ diff_fun ∞ charts ?g›*)) (*goal: ‹diff_fun ∞ charts (restrict0 U f')›*) using f'(2,3) (*‹?x3 ∈ closure C ⟹ f' ?x3 = f ?x3› ‹csupport_on carrier f' ∩ carrier ⊆ U.sub.carrier›*) by (metis (no_types) IntE (*‹⟦?c ∈ ?A ∩ ?B; ⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) IntI (*‹⟦?c ∈ ?A; ?c ∈ ?B⟧ ⟹ ?c ∈ ?A ∩ ?B›*) U.carrier_submanifold (*‹U.sub.carrier = U ∩ carrier›*) not_in_csupportD (*‹⟦?x ∉ csupport_on ?carrier ?φ; ?x ∈ ?carrier⟧ ⟹ ?φ ?x = 0›*) restrict0_def (*‹restrict0 ?A ?f ?x = (if ?x ∈ ?A then ?f ?x else 0)›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) subgoal for using U(2) (*‹U ⊆ carrier›*) extensional0_subset (*‹⟦extensional0 ?B ?f; ?B ⊆ ?A⟧ ⟹ extensional0 ?A ?f›*) by blast . show "∃C. diff ∞ (U.sub.charts_submanifold C) charts_eucl (vec_field_apply_fun_in_at X f U) ∧ open C ∧ x ∈ C" proof (intro exI (*‹?P ?x ⟹ ∃x. ?P x›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹diff ∞ (U.sub.charts_submanifold ?C) charts_eucl (vec_field_apply_fun_in_at X f U)› 2. ‹open ?C› 3. ‹x ∈ ?C›*) have carrier_UsubC[simp]: "manifold.carrier (U.sub.charts_submanifold C) = C" by (metis C( (*‹open C› ‹closure C ⊆ U.sub.carrier›*) 2,4) Int_absorb2 (*‹?A ⊆ ?B ⟹ ?A ∩ ?B = ?A›*) U.sub.open_imp_submanifold (*‹open ?S ⟹ submanifold (charts_submanifold U) ∞ ?S›*) closure_subset (*‹?S ⊆ closure ?S›*) submanifold.carrier_submanifold (*‹submanifold ?charts ?k ?S ⟹ manifold.carrier (manifold.charts_submanifold ?charts ?S) = ?S ∩ manifold.carrier ?charts›*) subset_trans (*‹⟦?A ⊆ ?B; ?B ⊆ ?C⟧ ⟹ ?A ⊆ ?C›*)) have "diff_fun ∞ (U.sub.charts_submanifold C) (vec_field_apply_fun_in_at X f U)" proof (rule diff_fun.diff_fun_cong[where f="X˝?f'"] (*‹⟦diff_fun (?k::enat) (?charts::('a, ?'c) chart set) (λp::'a. (X::'a ⇒ ('a ⇒ real) ⇒ real) p (restrict0 (U::'a set) (f'::'a ⇒ real))); ⋀x::'a. x ∈ manifold.carrier ?charts ⟹ X x (restrict0 U f') = (?g::'a ⇒ real) x⟧ ⟹ diff_fun ?k ?charts ?g›*)) (*goals: 1. ‹diff_fun ∞ (U.sub.charts_submanifold C) (λp. X p (restrict0 U f'))› 2. ‹⋀x. x ∈ manifold.carrier (U.sub.charts_submanifold C) ⟹ X x (restrict0 U f') = vec_field_apply_fun_in_at X f U x›*) have "diff_fun ∞ charts (λp. X p ?f')" using "1" (*‹restrict0 U f' ∈ diff_fun_space›*) that (*‹∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space›*) by (simp add: diff_fun_spaceD (*‹?f ∈ diff_fun_space ⟹ diff_fun ∞ charts ?f›*)) from diff_fun.diff_fun_submanifold[OF this] (*‹open ?S ⟹ diff_fun ∞ (charts_submanifold ?S) (λp. X p (restrict0 U f'))›*) show "diff_fun ∞ (U.sub.charts_submanifold C) (λp. X p ?f')" by (simp add: C( (*‹open (C::'a set)›*) 2) U.open_submanifold (*‹open (U::'a set)›*) charts_submanifold_Int (*‹⟦open (?N::'a set); open (?U::'a set)⟧ ⟹ manifold.charts_submanifold (charts_submanifold ?U) ?N = charts_submanifold (?N ∩ ?U)›*) open_Int (*‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∩ ?T)›*)) show "X x (restrict0 U f') = vec_field_apply_fun_in_at X f U x" if "x ∈ manifold.carrier (U.sub.charts_submanifold C)" for x proof (-) (*goal: ‹X x (restrict0 U f') = vec_field_apply_fun_in_at X f U x›*) have "X p ?f' = vec_field_apply_fun_in_at X f U p" if p: "p∈C" for p using U.vec_field_apply_fun_in_open[OF U ( 2 ) C ( 2 ) _ _ 1 f _ X, symmetric] (*‹⟦(C::'a set) ⊆ (U::'a set); (?p::'a) ∈ C; ∀x::'a∈C. restrict0 U (f'::'a ⇒ real) x = (f::'a ⇒ real) x⟧ ⟹ (X::'a ⇒ ('a ⇒ real) ⇒ real) ?p (restrict0 U f') = X↾U ?p f›*) using C (*‹(x__::'a) ∈ (C::'a set)› ‹open C› ‹compact (closure C)› ‹closure C ⊆ U.sub.carrier›*) p (*‹(p::'a::{second_countable_topology,t2_space}) ∈ (C::'a::{second_countable_topology,t2_space} set)›*) f (*‹f ∈ U.sub.diff_fun_space›*) f'(2) (*‹?x3 ∈ closure C ⟹ f' ?x3 = f ?x3›*) C(4) (*‹closure C ⊆ U.sub.carrier›*) by (auto simp: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) thus "?thesis" (*goal: ‹X x (restrict0 U f') = vec_field_apply_fun_in_at X f U x›*) using that (*‹x ∈ manifold.carrier (U.sub.charts_submanifold C)›*) by simp qed qed thus "diff ∞ (U.sub.charts_submanifold C) charts_eucl (vec_field_apply_fun_in_at X f U)" unfolding diff_fun_def (*goal: ‹diff ∞ (U.sub.charts_submanifold C) charts_eucl (vec_field_apply_fun_in_at X f U)›*) . qed (simp_all add: C(1,2)) (*solves the remaining goals: 1. ‹open C› 2. ‹x ∈ C›*) qed qed moreover have "?LHS" if diff_apply_fun: "?RHS2" proof (intro smooth_vector_field_if_local (*‹⟦∀p∈carrier. ∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c ?X; extensional0 carrier ?X⟧ ⟹ smooth_vector_field ?X›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goals: 1. ‹⋀p. p ∈ carrier ⟹ ∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c X› 2. ‹extensional0 carrier X›*) fix p assume p: "p∈carrier" (*‹(p::'a) ∈ carrier›*) obtain c where c: "c∈atlas" "p∈domain c" (*goal: ‹(⋀c. ⟦c ∈ atlas; p ∈ domain c⟧ ⟹ thesis) ⟹ thesis›*) using p (*‹p ∈ carrier›*) atlasE (*‹⟦?x ∈ carrier; ⋀c. ⟦c ∈ atlas; ?x ∈ domain c⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast then interpret p: c_manifold_point charts "∞" c p using c_manifold_point (*‹⟦?c ∈ atlas; ?p ∈ domain ?c⟧ ⟹ c_manifold_point charts ∞ ?c ?p›*) by blast have vf_smooth_local_iff: "smooth_vector_field_local charts c X" if "(∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i))" using p.vector_field_smooth_local_iff (*‹⟦∞ = ∞; ∀p∈domain c. ?X p ∈ tangent_space p⟧ ⟹ smooth_vector_field_local charts c ?X = (∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component ?X i))›*) rough_vector_field_subset[OF X] (*‹?T ⊆ carrier ⟹ rough_vector_field (restrict0 ?T X)›*) by (meson assms (*‹rough_vector_field X›*) in_carrier_atlasI (*‹⟦?c ∈ atlas; ?x ∈ domain ?c⟧ ⟹ ?x ∈ carrier›*) p.ψ (*‹c ∈ atlas›*) rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*) that (*‹∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i)›*)) have "smooth_vector_field_local charts c X" apply (rule vf_smooth_local_iff (*‹∀i∈Basis. diff_fun_on (domain c) (p.vector_field_component X i) ⟹ smooth_vector_field_local charts c X›*)) (*goal: ‹smooth_vector_field_local (charts::('a, 'b) chart set) (c::('a, 'b) chart) (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) proof (intro ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀i. i ∈ Basis ⟹ diff_fun_on (domain c) (p.vector_field_component X i)›*) fix i :: 'b assume i: "i∈Basis" (*‹(i::'b) ∈ Basis›*) note local_simps[simp] = diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun ∞ (charts_submanifold ?A) ?f)›*) domain_atlas_subset_carrier (*‹?c ∈ atlas ⟹ domain ?c ⊆ carrier›*) define apply_X_in_c_at (X⇩c˝ _ _ [8080] 1000) where [simp]: "apply_X_in_c_at ≡ λf q. vec_field_apply_fun_in_at X f (domain c) q" have "(X↾(domain c)) q (p.local_coord_at p i) = p.vector_field_component X i q" if "q∈domain c" for q proof (-) (*goal: ‹X↾domain c q (p.local_coord_at p i) = p.vector_field_component X i q›*) interpret q: c_manifold_point charts "∞" c q using that (*‹q ∈ domain c›*) c (*‹c ∈ atlas› ‹(p::'a) ∈ domain (c::('a, 'b) chart)›*) apply unfold_locales (*goal: ‹c_manifold_point (charts::('a, 'b) chart set) ∞ (c::('a, 'b) chart) (q::'a)›*) by simp have Xq: "X q ∈ q.T⇩pM" using rough_vector_fieldE[OF X] (*‹X ?p ∈ tangent_space ?p› ‹extensional0 carrier X›*) that (*‹q ∈ domain c›*) c(1) (*‹c ∈ atlas›*) by blast show "?thesis" (*goal: ‹X↾domain c q (p.local_coord_at p i) = p.vector_field_component X i q›*) using vec_field_apply_fun_alt[OF open_domain that] (*‹⟦?f ∈ p.sub_ψ.sub.diff_fun_space; rough_vector_field ?X⟧ ⟹ ?X↾domain c q ?f = the_inv_into q.T⇩pU p.sub_ψ.inclusion.push_forward (?X q) ?f›*) apply (simp add: p.local_coord_diff_fun (*‹⟦∞ = ∞; (?q::'a) ∈ domain (c::('a, 'b) chart)⟧ ⟹ p.local_coord_at ?q (?i::'b) ∈ p.sub_ψ.sub.diff_fun_space›*) X (*‹rough_vector_field (X::'a ⇒ ('a ⇒ real) ⇒ real)›*)) (*goal: ‹X↾domain c q (p.local_coord_at p i) = p.vector_field_component X i q›*) using restrict0_apply_in[OF Xq] (*‹restrict0 q.T⇩pM ?f (X q) = ?f (X q)›*) using p.vector_apply_coord_at (*‹⟦?q ∈ domain c; ?p ∈ domain c; ?X ∈ tangent_space ?q; ∞ = ∞⟧ ⟹ p.differential_inclusion_inv_at ?q ?X (p.local_coord_at ?p ?i) = p.differential_inclusion_inv_at ?q ?X (p.local_coord_at ?q ?i)›*) p.p (*‹(p::'a) ∈ domain (c::('a, 'b) chart)›*) that (*‹(q::'a::{second_countable_topology,t2_space}) ∈ domain (c::('a::{second_countable_topology,t2_space}, 'b::euclidean_space) chart)›*) "q.component_function_apply_in_T⇩pM" (*‹?v ∈ q.T⇩pM ⟹ q.component_function ?v ?i = q.dRestr2 ?v (restrict0 (domain c) (λx. (apply_chart c x - apply_chart c q) ∙ ?i))›*) by (smt (verit, best) Xq (*‹X q ∈ q.T⇩pM›*) assms (*‹rough_vector_field X›*) c_manifold_local.vec_field_apply_fun_eq_component (*‹⟦c_manifold_local ?charts ?k ?ψ; ?q ∈ domain ?ψ; ?p ∈ domain ?ψ; c_manifold.rough_vector_field ?charts ?k ?X; ?k = ∞⟧ ⟹ c_manifold.vec_field_apply_fun_in_at ?charts ?k ?X (c_manifold_local.local_coord_at ?ψ ?q ?i) (domain ?ψ) ?q = c_manifold_local.vector_field_component ?charts ?k ?ψ ?X ?i ?q›*) p.c_manifold_local_axioms (*‹c_manifold_local charts ∞ c›*) p.local_coord_diff_fun (*‹⟦∞ = ∞; ?q ∈ domain c⟧ ⟹ p.local_coord_at ?q ?i ∈ p.sub_ψ.sub.diff_fun_space›*)) qed moreover have "diff_fun_on (domain c) (λq. X⇩c˝ (p.local_coord_at p i) q)" using diff_apply_fun (*‹∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U)›*) by (simp add: p.local_coord_diff_fun (*‹⟦∞ = ∞; ?q ∈ domain c⟧ ⟹ p.local_coord_at ?q ?i ∈ p.sub_ψ.sub.diff_fun_space›*)) ultimately show "diff_fun_on (domain c) (p.vector_field_component X i)" by (simp add: diff_fun_on_def (*‹diff_fun_on (?A::'a::{second_countable_topology,t2_space} set) (?f::'a::{second_countable_topology,t2_space} ⇒ ?'c::euclidean_space) = (∃W::'a::{second_countable_topology,t2_space} set. ?A ⊆ W ∧ W ⊆ carrier ∧ open W ∧ (∃f'::'a::{second_countable_topology,t2_space} ⇒ ?'c::euclidean_space. diff_fun ∞ (charts_submanifold W) f' ∧ (∀x::'a::{second_countable_topology,t2_space}∈?A. ?f x = f' x)))›*)) qed with c (*‹c ∈ atlas› ‹p ∈ domain c›*) show "∃c∈atlas. p ∈ domain c ∧ smooth_vector_field_local charts c X" by blast qed (simp add: assms (*‹rough_vector_field (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) rough_vector_fieldE( (*‹rough_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ⟹ extensional0 carrier ?X›*) 2)) (*solved the remaining goal: ‹extensional0 carrier X›*) ultimately show "?LHS ⟷ ?RHS1" "?LHS ⟷ ?RHS2" apply - (*goals: 1. ‹⟦smooth_vector_field X ⟹ ∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space; ∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space ⟹ ∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U); ∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U) ⟹ smooth_vector_field X⟧ ⟹ smooth_vector_field X = (∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space)› 2. ‹⟦smooth_vector_field X ⟹ ∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space; ∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space ⟹ ∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U); ∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U) ⟹ smooth_vector_field X⟧ ⟹ smooth_vector_field X = (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma vector_field_smooth_iff': fixes C_inf defines "⋀U. C_inf U ≡ c_manifold.diff_fun_space (charts_submanifold U) ∞" assumes X: "rough_vector_field X" shows "smooth_vector_field X ⟷ (∀f∈diff_fun_space. (X ˝ f) ∈ diff_fun_space)" and "smooth_vector_field X ⟷ (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ C_inf U ⟶ diff_fun_on U (X↾U ˝ f))" proof (-) (*goals: 1. ‹smooth_vector_field X = (∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space)› 2. ‹smooth_vector_field X = (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ C_inf U ⟶ diff_fun_on U (λp. X↾U p f))›*) show "smooth_vector_field X = (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ C_inf U ⟶ diff_fun_on U (λp. X↾U p f))" apply (simp add: diff_fun_on_open (*‹open ?A ⟹ diff_fun_on ?A ?f = (?A ⊆ carrier ∧ diff_fun ∞ (charts_submanifold ?A) ?f)›*) assms( (*‹C_inf ?U3 ≡ c_manifold.diff_fun_space (charts_submanifold ?U3) ∞›*) 1)) (*goal: ‹smooth_vector_field X = (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ C_inf U ⟶ diff_fun_on U (λp. X↾U p f))›*) using vector_field_smooth_iff(2)[OF assms ( 2 - )] (*‹smooth_vector_field X = (∀U f. open U ∧ U ⊆ carrier ∧ f ∈ c_manifold.diff_fun_space (charts_submanifold U) ∞ ⟶ diff_fun ∞ (charts_submanifold U) (vec_field_apply_fun_in_at X f U))›*) by (smt (verit, ccfv_SIG) Un_Int_eq( (*‹?T ∩ (?S ∪ ?T) = ?T›*) 4) diff_fun.diff_fun_cong (*‹⟦diff_fun ?k ?charts ?f; ⋀x. x ∈ manifold.carrier ?charts ⟹ ?f x = ?g x⟧ ⟹ diff_fun ?k ?charts ?g›*) open_imp_submanifold (*‹open ?S ⟹ submanifold charts ∞ ?S›*) restrict0_apply_in (*‹?x ∈ ?A ⟹ restrict0 ?A ?f ?x = ?f ?x›*) submanifold.carrier_submanifold (*‹submanifold ?charts ?k ?S ⟹ manifold.carrier (manifold.charts_submanifold ?charts ?S) = ?S ∩ manifold.carrier ?charts›*) sup.order_iff (*‹(?b ≤ ?a) = (?a = sup ?a ?b)›*)) qed (simp add: vector_field_smooth_iff(1)[OF assms(2-)] (*‹smooth_vector_field X = (∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space)›*)) (*solved the remaining goal: ‹smooth_vector_field X = (∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space)›*) lemma smooth_vf_diff_fun_space: assumes X: "smooth_vector_field X" and f: "f∈diff_fun_space" shows "X˝f ∈ diff_fun_space" using vector_field_smooth_iff(1) (*‹rough_vector_field ?X ⟹ smooth_vector_field ?X = (∀f∈diff_fun_space. (λp. ?X p f) ∈ diff_fun_space)›*) smooth_vector_field_def (*‹smooth_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp::'a. (p, ?X p))›*) X (*‹smooth_vector_field X›*) f (*‹f ∈ diff_fun_space›*) rough_vector_fieldE (*‹rough_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ⟹ ?X (?p::'a) ∈ tangent_space ?p› ‹rough_vector_field ?X ⟹ extensional0 carrier ?X›*) by (auto simp: diff_fun_space_def (*‹diff_fun_space = {f. diff_fun ∞ charts f ∧ extensional0 carrier f}›*) extensional0_def (*‹extensional0 ?A ?f = (∀x. x ∉ ?A ⟶ ?f x = 0)›*)) end (* smooth_manifold *) subsection ‹Smooth vector fields are derivations› context c_manifold begin ― ‹Generalising \<^term>‹is_derivation› (which might have been called ‹is_derivation_at›) over the carrier set. Relative to that definition, we also add a condition on the codomain.› definition is_derivation_on :: "(('a⇒real) ⇒ ('a⇒real)) ⇒ bool" where "is_derivation_on D ≡ real_linear_on diff_fun_space diff_fun_space D ∧ (∀f∈diff_fun_space. ∀g∈diff_fun_space. D (f*g) = f*(D g) + g*(D f)) ∧ D ` diff_fun_space ⊆ diff_fun_space" lemma vec_field_linear_on: assumes X: "rough_vector_field X" and b: "b1 ∈ diff_fun_space" "b2 ∈ diff_fun_space" shows "X ˝ (b1+b2) = (X˝b1 + X˝b2)" "X ˝ (r *⇩R b1) = (r *⇩R (X˝b1))" using tangent_space_linear_on[OF rough_vector_fieldE ( 1 ) [ OF X ]] (*‹linear_on diff_fun_space UNIV (*⇩R) (*⇩R) (X ?p)›*) apply - (*goals: 1. ‹(⋀p. linear_on diff_fun_space UNIV (*⇩R) (*⇩R) (X p)) ⟹ (λp. X p (b1 + b2)) = (λp. X p b1) + (λp. X p b2)› 2. ‹(⋀p. linear_on diff_fun_space UNIV (*⇩R) (*⇩R) (X p)) ⟹ (λp. X p (r *⇩R b1)) = r *⇩R (λp. X p b1)› discuss goal 1*) apply ((auto simp: linear_on_def (*‹linear_on ?S1.0 ?S2.0 ?s1.0 ?s2.0 ?f ≡ Linear_Algebra_On.module_hom_on ?S1.0 ?S2.0 ?s1.0 ?s2.0 ?f›*) module_hom_on_def (*‹Linear_Algebra_On.module_hom_on ?S1.0 ?S2.0 ?s1.0 ?s2.0 ?f ≡ Linear_Algebra_On.module_on ?S1.0 ?s1.0 ∧ Linear_Algebra_On.module_on ?S2.0 ?s2.0 ∧ Linear_Algebra_On.module_hom_on_axioms ?S1.0 ?s1.0 ?s2.0 ?f›*) module_hom_on_axioms_def (*‹Linear_Algebra_On.module_hom_on_axioms ?S1.0 ?s1.0 ?s2.0 ?f ≡ (∀b1 b2. b1 ∈ ?S1.0 ⟶ b2 ∈ ?S1.0 ⟶ ?f (b1 + b2) = ?f b1 + ?f b2) ∧ (∀r b. b ∈ ?S1.0 ⟶ ?f (?s1.0 r b) = ?s2.0 r (?f b))›*) assms( (*‹b1 ∈ diff_fun_space› ‹b2 ∈ diff_fun_space›*) 2-))[1]) (*discuss goal 2*) apply ((auto simp: linear_on_def (*‹linear_on ?S1.0 ?S2.0 ?s1.0 ?s2.0 ?f ≡ Linear_Algebra_On.module_hom_on ?S1.0 ?S2.0 ?s1.0 ?s2.0 ?f›*) module_hom_on_def (*‹Linear_Algebra_On.module_hom_on ?S1.0 ?S2.0 ?s1.0 ?s2.0 ?f ≡ Linear_Algebra_On.module_on ?S1.0 ?s1.0 ∧ Linear_Algebra_On.module_on ?S2.0 ?s2.0 ∧ Linear_Algebra_On.module_hom_on_axioms ?S1.0 ?s1.0 ?s2.0 ?f›*) module_hom_on_axioms_def (*‹Linear_Algebra_On.module_hom_on_axioms ?S1.0 ?s1.0 ?s2.0 ?f ≡ (∀b1 b2. b1 ∈ ?S1.0 ⟶ b2 ∈ ?S1.0 ⟶ ?f (b1 + b2) = ?f b1 + ?f b2) ∧ (∀r b. b ∈ ?S1.0 ⟶ ?f (?s1.0 r b) = ?s2.0 r (?f b))›*) assms( (*‹b1 ∈ diff_fun_space› ‹b2 ∈ diff_fun_space›*) 2-))[1]) (*proven 2 subgoals*) . lemma linear_on_vec_field: assumes "rough_vector_field X" shows "real_linear_on diff_fun_space diff_fun_space ((˝) X)" using vec_field_linear_on[OF assms] (*‹⟦(?b1.0::'a ⇒ real) ∈ diff_fun_space; (?b2.0::'a ⇒ real) ∈ diff_fun_space⟧ ⟹ (λp::'a. (X::'a ⇒ ('a ⇒ real) ⇒ real) p (?b1.0 + ?b2.0)) = (λp::'a. X p ?b1.0) + (λp::'a. X p ?b2.0)› ‹⟦?b1.0 ∈ diff_fun_space; ?b2.0 ∈ diff_fun_space⟧ ⟹ (λp. X p (?r *⇩R ?b1.0)) = ?r *⇩R (λp. X p ?b1.0)›*) apply unfold_locales (*goals: 1. ‹⋀b1 b2. ⟦⋀b1 b2. ⟦b1 ∈ diff_fun_space; b2 ∈ diff_fun_space⟧ ⟹ (λp. X p (b1 + b2)) = (λp. X p b1) + (λp. X p b2); ⋀b1 b2 r. ⟦b1 ∈ diff_fun_space; b2 ∈ diff_fun_space⟧ ⟹ (λp. X p (r *⇩R b1)) = r *⇩R (λp. X p b1); b1 ∈ diff_fun_space; b2 ∈ diff_fun_space⟧ ⟹ (λp. X p (b1 + b2)) = (λp. X p b1) + (λp. X p b2)› 2. ‹⋀r b. ⟦⋀b1 b2. ⟦b1 ∈ diff_fun_space; b2 ∈ diff_fun_space⟧ ⟹ (λp. X p (b1 + b2)) = (λp. X p b1) + (λp. X p b2); ⋀b1 b2 r. ⟦b1 ∈ diff_fun_space; b2 ∈ diff_fun_space⟧ ⟹ (λp. X p (r *⇩R b1)) = r *⇩R (λp. X p b1); b ∈ diff_fun_space⟧ ⟹ (λp. X p (r *⇩R b)) = r *⇩R (λp. X p b)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma product_rule_vf: assumes X: "rough_vector_field X" and "f ∈ diff_fun_space" "g ∈ diff_fun_space" shows "X ˝ (f*g) = f * (X ˝ g) + g * (X ˝ f)" using tangent_space_derivation (*‹⟦?X ∈ tangent_space ?p; ?f ∈ diff_fun_space; ?g ∈ diff_fun_space⟧ ⟹ ?X (?f * ?g) = ?f ?p * ?X ?g + ?g ?p * ?X ?f›*) rough_vector_fieldE(1) (*‹rough_vector_field ?X ⟹ ?X ?p ∈ tangent_space ?p›*) assms (*‹rough_vector_field X› ‹f ∈ diff_fun_space› ‹(g::'a ⇒ real) ∈ diff_fun_space›*) by auto end context smooth_manifold begin lemma vector_field_is_derivation: assumes X: "smooth_vector_field X" shows "is_derivation_on (λf. X˝f)" using linear_on_vec_field (*‹rough_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ⟹ linear_on diff_fun_space diff_fun_space (*⇩R) (*⇩R) (λ(f::'a ⇒ real) p::'a. ?X p f)›*) product_rule_vf (*‹⟦rough_vector_field ?X; ?f ∈ diff_fun_space; ?g ∈ diff_fun_space⟧ ⟹ (λp. ?X p (?f * ?g)) = ?f * (λp. ?X p ?g) + ?g * (λp. ?X p ?f)›*) vector_field_smooth_iff(1) (*‹rough_vector_field (?X::'a ⇒ ('a ⇒ real) ⇒ real) ⟹ smooth_vector_field ?X = (∀f::'a ⇒ real∈diff_fun_space. (λp::'a. ?X p f) ∈ diff_fun_space)›*) using smooth_vector_field_def (*‹smooth_vector_field ?X ≡ rough_vector_field ?X ∧ smooth_from_M_to_TM (λp. (p, ?X p))›*) assms (*‹smooth_vector_field (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) unfolding is_derivation_on_def (*goal: ‹linear_on diff_fun_space diff_fun_space (*⇩R) (*⇩R) (λf p. X p f) ∧ (∀f∈diff_fun_space. ∀g∈diff_fun_space. (λp. X p (f * g)) = f * (λp. X p g) + g * (λp. X p f)) ∧ (λf p. X p f) ` diff_fun_space ⊆ diff_fun_space›*) by auto subsection ‹Derivations are smooth vector fields› ― ‹Proposition 8.15 of Lee 2015 (p.~181).› lemma extensional_derivation_is_smooth_vector_field: fixes D :: "('a⇒real) ⇒ ('a⇒real)" and X :: "'a⇒('a⇒real) ⇒ real" defines [simp]: "X ≡ λp. λf. D f p" assumes der_D: "is_derivation_on D" and ext_X: "extensional0 carrier X" and ext_D: "extensional0 diff_fun_space D" shows "smooth_vector_field X" proof (-) (*goal: ‹smooth_vector_field X›*) have rough_vf_X: "rough_vector_field X" proof (unfold rough_vector_field_def (*‹rough_vector_field ?X ≡ extensional0 carrier ?X ∧ (∀p∈carrier. ?X p ∈ tangent_space p)›*) tangent_space_def (*‹tangent_space ?p = {X. is_derivation X ?p ∧ extensional0 diff_fun_space X}›*) is_derivation_def (*‹is_derivation ?X ?p = (linear_on diff_fun_space UNIV (*⇩R) (*⇩R) ?X ∧ (∀f g. f ∈ diff_fun_space ⟶ g ∈ diff_fun_space ⟶ ?X (f * g) = f ?p * ?X g + g ?p * ?X f))›*), safe) (*goals: 1. ‹extensional0 carrier (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real)› 2. ‹⋀p::'a::{second_countable_topology,t2_space}. p ∈ carrier ⟹ linear_on diff_fun_space UNIV (*⇩R) (*⇩R) ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p)› 3. ‹⋀(p::'a::{second_countable_topology,t2_space}) (f::'a::{second_countable_topology,t2_space} ⇒ real) g::'a::{second_countable_topology,t2_space} ⇒ real. ⟦p ∈ carrier; f ∈ diff_fun_space; g ∈ diff_fun_space⟧ ⟹ (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p (f * g) = f p * X p g + g p * X p f› 4. ‹⋀p::'a::{second_countable_topology,t2_space}. p ∈ carrier ⟹ extensional0 diff_fun_space ((X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) p)›*) fix p assume p: "p∈carrier" (*‹(p::'a) ∈ carrier›*) show "extensional0 diff_fun_space (λf. X p f)" apply simp (*goal: ‹extensional0 diff_fun_space (X p)›*) by (metis (mono_tags, lifting) ext_D (*‹extensional0 diff_fun_space D›*) extensional0_def (*‹extensional0 ?A ?f = (∀x. x ∉ ?A ⟶ ?f x = 0)›*) zero_fun_apply (*‹0 ?x = 0›*)) show "real_linear_on diff_fun_space UNIV (λf. X p f)" using der_D[unfolded is_derivation_on_def] (*‹linear_on diff_fun_space diff_fun_space (*⇩R) (*⇩R) D ∧ (∀f∈diff_fun_space. ∀g∈diff_fun_space. D (f * g) = f * D g + g * D f) ∧ D ` diff_fun_space ⊆ diff_fun_space›*) unfolding linear_on_def module_hom_on_def module_hom_on_axioms_def (*goal: ‹Linear_Algebra_On.module_on diff_fun_space (*⇩R) ∧ Linear_Algebra_On.module_on UNIV (*⇩R) ∧ (∀(b1::'a::{second_countable_topology,t2_space} ⇒ real) b2::'a::{second_countable_topology,t2_space} ⇒ real. b1 ∈ diff_fun_space ⟶ b2 ∈ diff_fun_space ⟶ (X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real) (p::'a::{second_countable_topology,t2_space}) (b1 + b2) = X p b1 + X p b2) ∧ (∀(r::real) b::'a::{second_countable_topology,t2_space} ⇒ real. b ∈ diff_fun_space ⟶ X p (r *⇩R b) = r *⇩R X p b)›*) using manifold_eucl.diff_fun_space.m2.module_on_axioms (*‹Linear_Algebra_On.module_on UNIV (*⇩R)›*) by auto fix f and g assume "f ∈ diff_fun_space" "g ∈ diff_fun_space" (*‹(f::'a ⇒ real) ∈ diff_fun_space› ‹(g::'a ⇒ real) ∈ diff_fun_space›*) thus "X p (f * g) = f p * X p g + g p * X p f" using der_D[unfolded is_derivation_on_def] (*‹linear_on diff_fun_space diff_fun_space (*⇩R) (*⇩R) D ∧ (∀f∈diff_fun_space. ∀g∈diff_fun_space. D (f * g) = f * D g + g * D f) ∧ D ` diff_fun_space ⊆ diff_fun_space›*) by simp qed (rule ext_X (*‹extensional0 carrier X›*)) (*solved the remaining goal: ‹extensional0 carrier (X::'a ⇒ ('a ⇒ real) ⇒ real)›*) show "smooth_vector_field X" unfolding vector_field_smooth_iff(1)[OF rough_vf_X] (*goal: ‹∀f∈diff_fun_space. (λp. X p f) ∈ diff_fun_space›*) using der_D[unfolded is_derivation_on_def] (*‹linear_on diff_fun_space diff_fun_space (*⇩R) (*⇩R) (D::('a ⇒ real) ⇒ 'a ⇒ real) ∧ (∀f::'a ⇒ real∈diff_fun_space. ∀g::'a ⇒ real∈diff_fun_space. D (f * g) = f * D g + g * D f) ∧ D ` diff_fun_space ⊆ diff_fun_space›*) diff_fun_spaceD (*‹(?f::'a ⇒ real) ∈ diff_fun_space ⟹ diff_fun ∞ (charts::('a, 'b) chart set) ?f›*) X_def (*‹X::'a::{second_countable_topology,t2_space} ⇒ ('a::{second_countable_topology,t2_space} ⇒ real) ⇒ real ≡ λ(p::'a::{second_countable_topology,t2_space}) f::'a::{second_countable_topology,t2_space} ⇒ real. (D::('a::{second_countable_topology,t2_space} ⇒ real) ⇒ 'a::{second_countable_topology,t2_space} ⇒ real) f p›*) by blast qed lemma extensional_derivation_is_smooth_vector_field': fixes D :: "('a⇒real) ⇒ ('a⇒real)" assumes der_D: "is_derivation_on D" and ext_X: "extensional0 carrier (λp f. D f p)" and ext_D: "extensional0 diff_fun_space D" obtains X where "smooth_vector_field X" and "∀f∈diff_fun_space. D f = X˝f" using extensional_derivation_is_smooth_vector_field[OF assms] (*‹smooth_vector_field (λp f. D f p)›*) by auto theorem smooth_vector_field_iff_derivation: fixes extensional_derivation defines "⋀D. extensional_derivation D ≡ is_derivation_on D ∧ extensional0 carrier (λp f. D f p) ∧ extensional0 diff_fun_space D" shows "smooth_vector_field X ⟹ extensional_derivation (λf. X ˝ f)" and "extensional_derivation D ⟹ smooth_vector_field (λp f. D f p)" unfolding assms(1) (*goals: 1. ‹smooth_vector_field X ⟹ is_derivation_on (λf p. X p f) ∧ extensional0 carrier X ∧ extensional0 diff_fun_space (λf p. X p f)› 2. ‹is_derivation_on D ∧ extensional0 carrier (λp f. D f p) ∧ extensional0 diff_fun_space D ⟹ smooth_vector_field (λp f. D f p)›*) using vector_field_is_derivation (*‹smooth_vector_field ?X ⟹ is_derivation_on (λf p. ?X p f)›*) extensional_derivation_is_smooth_vector_field (*‹⟦is_derivation_on ?D; extensional0 carrier (λp f. ?D f p); extensional0 diff_fun_space ?D⟧ ⟹ smooth_vector_field (λp f. ?D f p)›*) apply - (*goals: 1. ‹⟦smooth_vector_field X; ⋀X. smooth_vector_field X ⟹ is_derivation_on (λf p. X p f); ⋀D. ⟦is_derivation_on D; extensional0 carrier (λp f. D f p); extensional0 diff_fun_space D⟧ ⟹ smooth_vector_field (λp f. D f p)⟧ ⟹ is_derivation_on (λf p. X p f) ∧ extensional0 carrier X ∧ extensional0 diff_fun_space (λf p. X p f)› 2. ‹⟦is_derivation_on D ∧ extensional0 carrier (λp f. D f p) ∧ extensional0 diff_fun_space D; ⋀X. smooth_vector_field X ⟹ is_derivation_on (λf p. X p f); ⋀D. ⟦is_derivation_on D; extensional0 carrier (λp f. D f p); extensional0 diff_fun_space D⟧ ⟹ smooth_vector_field (λp f. D f p)⟧ ⟹ smooth_vector_field (λp f. D f p)› discuss goal 1*) apply (simp add: ext0_vec_field_apply_fun (*‹rough_vector_field ?X ⟹ extensional0 diff_fun_space (λf p. ?X p f)›*) smooth_vector_fieldE( (*‹smooth_vector_field ?X ⟹ extensional0 carrier ?X› ‹smooth_vector_field ?X ⟹ rough_vector_field ?X›*) 2,3)) (*discuss goal 2*) apply (simp add: ext0_vec_field_apply_fun (*‹rough_vector_field ?X ⟹ extensional0 diff_fun_space (λf p. ?X p f)›*) smooth_vector_fieldE( (*‹smooth_vector_field ?X ⟹ extensional0 carrier ?X› ‹smooth_vector_field ?X ⟹ rough_vector_field ?X›*) 2,3)) (*proven 2 subgoals*) . end (* smooth_manifold *) end
{ "path": "afp-2025-02-12/thys/Lie_Groups/Smooth_Vector_Fields.thy", "repo": "afp-2025-02-12", "sha": "1a048a8948e0968a49e71e0c387e66c22394414b55697f1e956f0bf8b89daf10" }
section ‹An Existing FLPSystem› theory FLPExistingSystem imports FLPTheorem begin text ‹ We define an example FLPSystem with some example execution to show that the locales employed are not void. (If they were, the consensus impossibility result would be trivial.) › subsection ‹System definition› datatype proc = p0 | p1 datatype state = s0 | s1 datatype val = v0 | v1 primrec trans :: "proc ⇒ state ⇒ val messageValue ⇒ state" where "trans p s0 v = s1" | "trans p s1 v = s0" primrec sends :: "proc ⇒ state ⇒ val messageValue ⇒ (proc, val) message multiset" where "sends p s0 v = {# <p0, v1> }" | "sends p s1 v = {# <p1, v0> }" definition start :: "proc ⇒ state" where "start p ≡ s0" ― ‹An example execution› definition exec :: "(proc, val, state ) configuration list" where exec_def: "exec ≡ [ ⦇ states = (λp. s0), msgs = ({# <p0, inM True> } ∪# {# <p1, inM True> }) ⦈ ]" lemma ProcUniv: "(UNIV :: proc set) = {p0, p1}" by (metis UNIV_eq_I (*‹(⋀x::?'a::type. x ∈ (?A::?'a::type set)) ⟹ UNIV = ?A›*) insert_iff (*‹((?a::?'a::type) ∈ insert (?b::?'a::type) (?A::?'a::type set)) = (?a = ?b ∨ ?a ∈ ?A)›*) proc.exhaust (*‹⟦(?y::proc) = p0 ⟹ ?P::bool; ?y = p1 ⟹ ?P⟧ ⟹ ?P›*)) subsection ‹Interpretation as FLP Locale› interpretation FLPSys: flpSystem trans sends start proof (standard) (*goals: 1. ‹finite UNIV› 2. ‹(2::nat) ≤ card UNIV› 3. ‹⋀(p::proc) (s::state) m::val messageValue. finite {v::(proc, val) message. v ∈# sends p s m}› 4. ‹⋀(p::proc) (s::state) (m::val messageValue) (p2::proc) v::bool. sends p s m <p2, inM v> = (0::nat)›*) show "finite (UNIV :: proc set)" unfolding ProcUniv (*goal: ‹finite {p0, p1}›*) by simp next (*goals: 1. ‹2 ≤ card UNIV› 2. ‹⋀p s m. finite {v. v ∈# sends p s m}› 3. ‹⋀p s m p2 v. sends p s m <p2, inM v> = 0›*) have "card (UNIV :: proc set) = 2" unfolding ProcUniv (*goal: ‹card {p0, p1} = 2›*) by simp thus "2 ≤ card (UNIV :: proc set)" by simp next (*goals: 1. ‹⋀(p::proc) (s::state) m::val messageValue. finite {v::(proc, val) message. v ∈# sends p s m}› 2. ‹⋀(p::proc) (s::state) (m::val messageValue) (p2::proc) v::bool. sends p s m <p2, inM v> = (0::nat)›*) fix p and s and m have FinExplSends: "finite {<p0, v1>, <p1, v0>}" by auto have "{v. 0 < sends p s m v} ⊆ {<p0, v1>, <p1, v0>}" proof (auto) (*goal: ‹⋀x. ⟦x ≠ <p0, v1>; x ∈# sends p s m⟧ ⟹ x = <p1, v0>›*) fix x assume "x ≠ <p0, v1>" "0 < sends p s m x" (*‹(x::(proc, val) message) ≠ <p0, v1>› ‹x::(proc, val) message ∈# sends (p::proc) (s::state) (m::val messageValue)›*) thus "x = <p1, v0>" by (metis (full_types) neq0_conv (*‹(?n ≠ 0) = (0 < ?n)›*) sends.simps( (*‹sends ?p s0 ?v = {# <p0, v1> }› ‹sends ?p s1 ?v = {# <p1, v0> }›*) 1,2) state.exhaust (*‹⟦?y = s0 ⟹ ?P; ?y = s1 ⟹ ?P⟧ ⟹ ?P›*)) qed thus "finite {v. 0 < sends p s m v}" using FinExplSends (*‹finite {<p0, v1>, <p1, v0>}›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast next (*goal: ‹⋀(p::proc) (s::state) (m::val messageValue) (p2::proc) v::bool. sends p s m <p2, inM v> = (0::nat)›*) fix p and s and m and p2 and v show "sends p s m <p2, inM v> = 0" apply (induct s) (*goals: 1. ‹sends p s0 m <p2, inM v> = 0› 2. ‹sends p s1 m <p2, inM v> = 0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed interpretation FLPExec: execution trans sends start exec "[]" proof (standard) (*goals: 1. ‹1 ≤ length exec› 2. ‹length exec - 1 = length []› 3. ‹FLPSys.initial (hd exec)› 4. ‹⋀i cfg1 cfg2. ⟦i < length exec - 1; cfg1 = exec ! i; cfg2 = exec ! (i + 1)⟧ ⟹ FLPSys.steps cfg1 ([] ! i) cfg2›*) show "1 ≤ length exec" by (simp add:exec_def (*‹exec ≡ [⦇states = λp::proc. s0, msgs = λv::(proc, val) message. (If (<p0, inM True> = v) (1::nat) ∪# If (<p1, inM True> = v) (1::nat)) (0::nat)⦈]›*)) next (*goals: 1. ‹length exec - 1 = length []› 2. ‹FLPSys.initial (hd exec)› 3. ‹⋀i cfg1 cfg2. ⟦i < length exec - 1; cfg1 = exec ! i; cfg2 = exec ! (i + 1)⟧ ⟹ FLPSys.steps cfg1 ([] ! i) cfg2›*) show "length exec - 1 = length []" by (simp add:exec_def (*‹exec ≡ [⦇states = λp. s0, msgs = λv. (If (<p0, inM True> = v) 1 ∪# If (<p1, inM True> = v) 1) 0⦈]›*)) next (*goals: 1. ‹FLPSys.initial (hd exec)› 2. ‹⋀i cfg1 cfg2. ⟦i < length exec - 1; cfg1 = exec ! i; cfg2 = exec ! (i + 1)⟧ ⟹ FLPSys.steps cfg1 ([] ! i) cfg2›*) show "asynchronousSystem.initial start (hd exec)" unfolding asynchronousSystem.initial_def isReceiverOf_def (*goal: ‹(∀p. ∃v. msgs (hd exec) <p, inM v> = 1) ∧ (∀p m1 m2. m1 ∈# msgs (hd exec) ∧ m2 ∈# msgs (hd exec) ∧ rec_message (λp2 v p1. p1 = p2) (λv p1. False) (λp2 v p1. p1 = p2) m1 p ∧ rec_message (λp2 v p1. p1 = p2) (λv p1. False) (λp2 v p1. p1 = p2) m2 p ⟶ m1 = m2) ∧ (∀v. msgs (hd exec) <⊥, outM v> = 0) ∧ (∀p v. msgs (hd exec) <p, v> = 0) ∧ states (hd exec) = start›*) apply (auto simp add: start_def (*‹start ?p ≡ s0›*) exec_def (*‹exec ≡ [⦇states = λp. s0, msgs = λv. (If (<p0, inM True> = v) 1 ∪# If (<p1, inM True> = v) 1) 0⦈]›*)) (*goal: ‹(∀p. ∃v. msgs (hd exec) <p, inM v> = 1) ∧ (∀p m1 m2. m1 ∈# msgs (hd exec) ∧ m2 ∈# msgs (hd exec) ∧ rec_message (λp2 v p1. p1 = p2) (λv p1. False) (λp2 v p1. p1 = p2) m1 p ∧ rec_message (λp2 v p1. p1 = p2) (λv p1. False) (λp2 v p1. p1 = p2) m2 p ⟶ m1 = m2) ∧ (∀v. msgs (hd exec) <⊥, outM v> = 0) ∧ (∀p v. msgs (hd exec) <p, v> = 0) ∧ states (hd exec) = start›*) by (metis proc.exhaust (*‹⟦?y = p0 ⟹ ?P; ?y = p1 ⟹ ?P⟧ ⟹ ?P›*)) next (*goal: ‹⋀i cfg1 cfg2. ⟦i < length exec - 1; cfg1 = exec ! i; cfg2 = exec ! (i + 1)⟧ ⟹ FLPSys.steps cfg1 ([] ! i) cfg2›*) fix i and cfg1 and cfg2 assume "i < length exec - 1" (*‹(i::nat) < length exec - (1::nat)›*) hence False by (simp add:exec_def (*‹exec ≡ [⦇states = λp::proc. s0, msgs = λv::(proc, val) message. (If (<p0, inM True> = v) (1::nat) ∪# If (<p1, inM True> = v) (1::nat)) (0::nat)⦈]›*)) thus "asynchronousSystem.steps FLPExistingSystem.trans sends cfg1 ([] ! i) cfg2" by rule qed end
{ "path": "afp-2025-02-12/thys/FLP/FLPExistingSystem.thy", "repo": "afp-2025-02-12", "sha": "265f754398ca889d2fa1c610f4a3a6492fe3253f212ee82bd2f85ba81731698e" }
theory Graph imports Main begin section‹Rooted Graphs› text ‹In this section, we model rooted graphs and their sub\hyp{}paths and paths. We give a number of lemmas that will help proofs in the following theories, but that are very specific to our approach.› text ‹First, we will need the following simple lemma, which is not graph related, but that will prove useful when we will want to exhibit the last element of a non-empty sequence.› lemma neq_Nil_conv2 : "xs ≠ [] = (∃ x xs'. xs = xs' @ [x])" apply (induct xs rule : rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹([] ≠ []) = (∃x xs'. [] = xs' @ [x])› 2. ‹⋀x xs. (xs ≠ []) = (∃x xs'. xs = xs' @ [x]) ⟹ (xs @ [x] ≠ []) = (∃xa xs'. xs @ [x] = xs' @ [xa])› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subsection ‹Basic Definitions and Properties› subsubsection ‹Edges› text ‹We model edges by a record ‹'v edge› which is parameterized by the type ‹'v› of vertices. This allows us to represent the red part of red-black graphs as well as the black part (i.e. LTS) using extensible records (more on this later). Edges have two components, @{term "src"} and @{term "tgt"}, which respectively give their source and target.› record 'v edge = src :: "'v" tgt :: "'v" subsubsection ‹Rooted graphs› text ‹We model rooted graphs by the record ‹'v rgraph›. It consists of two components: its root and its set of edges.› record 'v rgraph = root :: "'v" edges :: "'v edge set" subsubsection ‹Vertices› text ‹The set of vertices of a rooted graph is made of its root and the endpoints of its edges. Isabelle/HOL provides \emph{extensible records}, i.e.\ it is possible to define records using existing records by adding components. The following definition suppose that @{term "g"} is of type ‹('v,'x) rgraph_scheme›, i.e.\ an object that has at least all the components of a ‹'v rgraph›. The second type parameter ‹'x› stands for the hypothetical type parameters that such an object could have in addition of the type of vertices ‹'v›. Using ‹('v,'x) rgraph_scheme› instead of ‹'v rgraph› allows to reuse the following definition(s) for all type of objects that have at least the components of a rooted graph. For example, we will reuse the following definition to characterize the set of locations of a LTS (see \verb?LTS.thy?).› definition vertices :: "('v,'x) rgraph_scheme ⇒ 'v set" where "vertices g = {root g} ∪ src `edges g ∪ tgt ` edges g" subsubsection ‹Basic properties of rooted graphs› text ‹In the following, we will be only interested in loop free rooted graphs and in what we call \emph{well formed rooted graphs}. A well formed rooted graph is rooted graph that has an empty set of edges or, if this is not the case, has at least one edge whose source is its root.› abbreviation loop_free :: "('v,'x) rgraph_scheme ⇒ bool" where "loop_free g ≡ ∀ e ∈ edges g. src e ≠ tgt e" abbreviation wf_rgraph :: "('v,'x) rgraph_scheme ⇒ bool" where "wf_rgraph g ≡ root g ∈ src ` edges g = (edges g ≠ {})" text ‹Even if we are only interested in this kind of rooted graphs, we will not assume the graphs are loop free or well formed when this is not needed.› subsubsection ‹Out-going edges› text ‹This abbreviation will prove handy in the following.› abbreviation out_edges :: "('v,'x) rgraph_scheme ⇒ 'v ⇒ 'v edge set" where "out_edges g v ≡ {e ∈ edges g. src e = v}" subsection ‹Consistent Edge Sequences, Sub-paths and Paths› subsubsection ‹Consistency of a sequence of edges› text ‹A sequence of edges @{term "es"} is consistent from vertex @{term "v1"} to another vertex @{term "v2"} if @{term "v1 = v2"} if it is empty, or, if it is not empty: \begin{itemize} \item @{term "v1"} is the source of its first element, and \item @{term "v2"} is the target of its last element, and \item the target of each of its elements is the source of its follower. \end{itemize}› fun ces :: "'v ⇒ 'v edge list ⇒ 'v ⇒ bool" where "ces v1 [] v2 = (v1 = v2)" | "ces v1 (e#es) v2 = (src e = v1 ∧ ces (tgt e) es v2)" subsubsection ‹Sub-paths and paths› text ‹Let @{term "g"} be a rooted graph, @{term "es"} a sequence of edges and @{term "v1"} and ‹v2› two vertices. @{term "es"} is a sub-path in @{term "g"} from @{term "v1"} to @{term "v2"} if: \begin{itemize} \item it is consistent from @{term "v1"} to @{term "v2"}, \item @{term "v1"} is a vertex of @{term "g"}, \item all of its elements are edges of @{term "g"}. \end{itemize} The second constraint is needed in the case of the empty sequence: without it, the empty sequence would be a sub-path of @{term "g"} even when @{term "v1"} is not one of its vertices.› definition subpath :: "('v,'x) rgraph_scheme ⇒ 'v ⇒ 'v edge list ⇒ 'v ⇒ bool" where "subpath g v1 es v2 ≡ ces v1 es v2 ∧ v1 ∈ vertices g ∧ set es ⊆ edges g" text ‹Let @{term "es"} be a sub-path of @{term "g"} leading from @{term "v1"} to @{term "v2"}. @{term "v1"} and @{term "v2"} are both vertices of @{term "g"}.› lemma fst_of_sp_is_vert : assumes "subpath g v1 es v2" shows "v1 ∈ vertices g" using assms (*‹subpath g v1 es v2›*) by (simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*)) lemma lst_of_sp_is_vert : assumes "subpath g v1 es v2" shows "v2 ∈ vertices g" using assms (*‹subpath g v1 es v2›*) apply (induction es arbitrary : v1) (*goals: 1. ‹⋀v1::'a::type. subpath (g::('a, 'b) rgraph_scheme) v1 [] (v2::'a::type) ⟹ v2 ∈ vertices g› 2. ‹⋀(a::'a edge) (es::'a edge list) v1::'a::type. ⟦⋀v1::'a::type. subpath (g::('a, 'b) rgraph_scheme) v1 es (v2::'a::type) ⟹ v2 ∈ vertices g; subpath g v1 (a # es) v2⟧ ⟹ v2 ∈ vertices g› discuss goal 1*) apply ((auto simp add: subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*))[1]) (*discuss goal 2*) apply ((auto simp add: subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*))[1]) (*proven 2 subgoals*) . text ‹The empty sequence of edges is a sub-path from @{term "v1"} to @{term "v2"} if and only if they are equal and belong to the graph.› text ‹The empty sequence is a sub-path from the root of any rooted graph.› lemma "subpath g (root g) [] (root g)" by (auto simp add : vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*) subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*)) text ‹In the following, we will not always be interested in the final vertex of a sub-path. We will use the abbreviation @{term "subpath_from"} whenever this final vertex has no importance, and @{term subpath} otherwise.› abbreviation subpath_from :: "('v,'x) rgraph_scheme ⇒ 'v ⇒ 'v edge list ⇒ bool" where "subpath_from g v es ≡ ∃ v'. subpath g v es v'" abbreviation subpaths_from :: "('v,'x) rgraph_scheme ⇒ 'v ⇒ 'v edge list set" where "subpaths_from g v ≡ {es. subpath_from g v es}" text ‹A path is a sub-path starting at the root of the graph.› abbreviation path :: "('v,'x) rgraph_scheme ⇒ 'v edge list ⇒ 'v ⇒ bool" where "path g es v ≡ subpath g (root g) es v" abbreviation paths :: "('a,'b) rgraph_scheme ⇒ 'a edge list set" where "paths g ≡ {es. ∃ v. path g es v}" text ‹The empty sequence is a path of any rooted graph.› lemma "[] ∈ paths g" by (auto simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*)) text ‹Some useful simplification lemmas for @{term "subpath"}.› lemma sp_one : "subpath g v1 [e] v2 = (src e = v1 ∧ e ∈ edges g ∧ tgt e = v2)" by (auto simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*)) lemma sp_Cons : "subpath g v1 (e#es) v2 = (src e = v1 ∧ e ∈ edges g ∧ subpath g (tgt e) es v2)" by (auto simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*)) lemma sp_append_one : "subpath g v1 (es@[e]) v2 = (subpath g v1 es (src e) ∧ e ∈ edges g ∧ tgt e = v2)" apply (induct es arbitrary : v1) (*goals: 1. ‹⋀v1. subpath g v1 ([] @ [e]) v2 = (subpath g v1 [] (src e) ∧ e ∈ edges g ∧ tgt e = v2)› 2. ‹⋀a es v1. (⋀v1. subpath g v1 (es @ [e]) v2 = (subpath g v1 es (src e) ∧ e ∈ edges g ∧ tgt e = v2)) ⟹ subpath g v1 ((a # es) @ [e]) v2 = (subpath g v1 (a # es) (src e) ∧ e ∈ edges g ∧ tgt e = v2)› discuss goal 1*) apply ((auto simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*))[1]) (*discuss goal 2*) apply ((auto simp add : subpath_def (*‹subpath (?g::(?'v, ?'x) rgraph_scheme) (?v1.0::?'v) (?es::?'v edge list) (?v2.0::?'v) ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices (?g::(?'v, ?'x) rgraph_scheme) = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*))[1]) (*proven 2 subgoals*) . lemma sp_append : "subpath g v1 (es1@es2) v2 = (∃ v. subpath g v1 es1 v ∧ subpath g v es2 v2)" apply (induct es1 arbitrary : v1) (*goals: 1. ‹⋀v1. subpath g v1 ([] @ es2) v2 = (∃v. subpath g v1 [] v ∧ subpath g v es2 v2)› 2. ‹⋀a es1 v1. (⋀v1. subpath g v1 (es1 @ es2) v2 = (∃v. subpath g v1 es1 v ∧ subpath g v es2 v2)) ⟹ subpath g v1 ((a # es1) @ es2) v2 = (∃v. subpath g v1 (a # es1) v ∧ subpath g v es2 v2)› discuss goal 1*) apply (simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*)) (*top goal: ‹⋀v1. subpath g v1 ([] @ es2) v2 = (∃v. subpath g v1 [] v ∧ subpath g v es2 v2)› and 1 goal remains*) apply fast (*discuss goal 2*) apply (auto simp add : fst_of_sp_is_vert (*‹subpath ?g ?v1.0 ?es ?v2.0 ⟹ ?v1.0 ∈ vertices ?g›*) sp_Cons (*‹subpath ?g ?v1.0 (?e # ?es) ?v2.0 = (src ?e = ?v1.0 ∧ ?e ∈ edges ?g ∧ subpath ?g (tgt ?e) ?es ?v2.0)›*)) (*proven 2 subgoals*) . text ‹A sub-path leads to a unique vertex.› lemma sp_same_src_imp_same_tgt : assumes "subpath g v es v1" assumes "subpath g v es v2" shows "v1 = v2" using assms (*‹subpath g v es v1› ‹subpath g v es v2›*) apply (induct es arbitrary : v) (*goals: 1. ‹⋀v. ⟦subpath g v [] v1; subpath g v [] v2⟧ ⟹ v1 = v2› 2. ‹⋀a es v. ⟦⋀v. ⟦subpath g v es v1; subpath g v es v2⟧ ⟹ v1 = v2; subpath g v (a # es) v1; subpath g v (a # es) v2⟧ ⟹ v1 = v2› discuss goal 1*) apply ((auto simp add : sp_Cons (*‹subpath ?g ?v1.0 (?e # ?es) ?v2.0 = (src ?e = ?v1.0 ∧ ?e ∈ edges ?g ∧ subpath ?g (tgt ?e) ?es ?v2.0)›*) subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*))[1]) (*discuss goal 2*) apply ((auto simp add : sp_Cons (*‹subpath ?g ?v1.0 (?e # ?es) ?v2.0 = (src ?e = ?v1.0 ∧ ?e ∈ edges ?g ∧ subpath ?g (tgt ?e) ?es ?v2.0)›*) subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*))[1]) (*proven 2 subgoals*) . text ‹In the following, we are interested in the evolution of the set of sub-paths of our symbolic execution graph after symbolic execution of a transition from the LTS representation of the program under analysis. Symbolic execution of a transition results in adding to the graph a new edge whose source is already a vertex of this graph, but not its target. The following lemma describes sub-paths ending in the target of such an edge.› text ‹Let @{term "e"} be an edge whose target has not out-going edges. A sub-path @{term "es"} containing @{term "e"} ends by @{term "e"} and this occurrence of @{term "e"} is unique along @{term "es"}.› lemma sp_through_de_decomp : assumes "out_edges g (tgt e) = {}" assumes "subpath g v1 es v2" assumes "e ∈ set es" shows "∃ es'. es = es' @ [e] ∧ e ∉ set es'" using assms(2,3) (*‹subpath (g::('a, 'b) rgraph_scheme) (v1::'a::type) (es::'a edge list) (v2::'a::type)› ‹e ∈ set es›*) proof (induction es arbitrary : v1) (*goals: 1. ‹⋀v1::'a. ⟦subpath (g::('a, 'b) rgraph_scheme) v1 [] (v2::'a); (e::'a edge) ∈ set []⟧ ⟹ ∃es'::'a edge list. [] = es' @ [e] ∧ e ∉ set es'› 2. ‹⋀(a::'a edge) (es::'a edge list) v1::'a. ⟦⋀v1::'a. ⟦subpath (g::('a, 'b) rgraph_scheme) v1 es (v2::'a); (e::'a edge) ∈ set es⟧ ⟹ ∃es'::'a edge list. es = es' @ [e] ∧ e ∉ set es'; subpath g v1 (a # es) v2; e ∈ set (a # es)⟧ ⟹ ∃es'::'a edge list. a # es = es' @ [e] ∧ e ∉ set es'›*) case Nil (*‹subpath g v1 [] v2› ‹e ∈ set []›*) thus "?case" (*goal: ‹∃es'. [] = es' @ [e] ∧ e ∉ set es'›*) by simp next (*goal: ‹⋀a es v1. ⟦⋀v1. ⟦subpath g v1 es v2; e ∈ set es⟧ ⟹ ∃es'. es = es' @ [e] ∧ e ∉ set es'; subpath g v1 (a # es) v2; e ∈ set (a # es)⟧ ⟹ ∃es'. a # es = es' @ [e] ∧ e ∉ set es'›*) case (Cons e' es) (*‹⟦subpath g ?v1.0 es v2; e ∈ set es⟧ ⟹ ∃es'. es = es' @ [e] ∧ e ∉ set es'› ‹subpath g v1 (e' # es) v2› ‹e ∈ set (e' # es)›*) hence "e = e' ∨ (e ≠ e' ∧ e ∈ set es)" by auto thus "?case" (*goal: ‹∃es'. e' # es = es' @ [e] ∧ e ∉ set es'›*) proof (elim disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*), goal_cases) (*goals: 1. ‹e = e' ⟹ ∃es'. e' # es = es' @ [e] ∧ e ∉ set es'› 2. ‹e ≠ e' ∧ e ∈ set es ⟹ ∃es'. e' # es = es' @ [e] ∧ e ∉ set es'›*) case 1 (*‹e = e'›*) thus "?case" (*goal: ‹∃es'::'a edge list. (e'::'a edge) # (es::'a edge list) = es' @ [e::'a edge] ∧ e ∉ set es'›*) using assms(1) (*‹out_edges (g::('a, 'b) rgraph_scheme) (tgt (e::'a edge)) = {}›*) Cons (*‹⟦subpath g ?v1.0 es v2; e ∈ set es⟧ ⟹ ∃es'. es = es' @ [e] ∧ e ∉ set es'› ‹subpath g v1 (e' # es) v2› ‹e ∈ set (e' # es)›*) apply (rule_tac ?x="[]" in exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*goal: ‹∃es'. e' # es = es' @ [e] ∧ e ∉ set es'›*) apply (cases es) (*goals: 1. ‹⟦e = e'; out_edges g (tgt e) = {}; ⋀v1. ⟦subpath g v1 es v2; e ∈ set es⟧ ⟹ ∃es'. es = es' @ [e] ∧ e ∉ set es'; subpath g v1 (e' # es) v2; e ∈ set (e' # es); es = []⟧ ⟹ e' # es = [] @ [e] ∧ e ∉ set []› 2. ‹⋀a list. ⟦e = e'; out_edges g (tgt e) = {}; ⋀v1. ⟦subpath g v1 es v2; e ∈ set es⟧ ⟹ ∃es'. es = es' @ [e] ∧ e ∉ set es'; subpath g v1 (e' # es) v2; e ∈ set (e' # es); es = a # list⟧ ⟹ e' # es = [] @ [e] ∧ e ∉ set []› discuss goal 1*) apply ((auto simp add: sp_Cons (*‹subpath ?g ?v1.0 (?e # ?es) ?v2.0 = (src ?e = ?v1.0 ∧ ?e ∈ edges ?g ∧ subpath ?g (tgt ?e) ?es ?v2.0)›*))[1]) (*discuss goal 2*) apply ((auto simp add: sp_Cons (*‹subpath ?g ?v1.0 (?e # ?es) ?v2.0 = (src ?e = ?v1.0 ∧ ?e ∈ edges ?g ∧ subpath ?g (tgt ?e) ?es ?v2.0)›*))[1]) (*proven 2 subgoals*) . next (*goal: ‹e ≠ e' ∧ e ∈ set es ⟹ ∃es'. e' # es = es' @ [e] ∧ e ∉ set es'›*) case 2 (*‹e ≠ e' ∧ e ∈ set es›*) thus "?case" (*goal: ‹∃es'. e' # es = es' @ [e] ∧ e ∉ set es'›*) using assms(1) (*‹out_edges g (tgt e) = {}›*) Cons(1)[of "tgt e'"] (*‹⟦subpath (g::('a, 'b) rgraph_scheme) (tgt (e'::'a edge)) (es::'a edge list) (v2::'a::type); (e::'a edge) ∈ set es⟧ ⟹ ∃es'::'a edge list. es = es' @ [e] ∧ e ∉ set es'›*) Cons(2) (*‹subpath g v1 (e' # es) v2›*) by (auto simp add : sp_Cons (*‹subpath ?g ?v1.0 (?e # ?es) ?v2.0 = (src ?e = ?v1.0 ∧ ?e ∈ edges ?g ∧ subpath ?g (tgt ?e) ?es ?v2.0)›*)) qed qed subsection ‹Adding Edges› text ‹This definition and the following lemma are here mainly to ease the definitions and proofs in the next theories.› abbreviation add_edge :: "('v,'x) rgraph_scheme ⇒ 'v edge ⇒ ('v,'x) rgraph_scheme" where "add_edge g e ≡ rgraph.edges_update (λ edges. edges ∪ {e}) g" text ‹Let @{term "es"} be a sub-path from a vertex other than the target of @{term "e"} in the graph obtained from @{term "g"} by the addition of edge @{term "e"}. Moreover, assume that the target of @{term "e"} is not a vertex of @{term "g"}. Then @{term "e"} is an element of @{term "es"}.› lemma sp_ends_in_tgt_imp_mem : assumes "tgt e ∉ vertices g" assumes "v ≠ tgt e" assumes "subpath (add_edge g e) v es (tgt e)" shows "e ∈ set es" proof (-) (*goal: ‹(e::'a edge) ∈ set (es::'a edge list)›*) have "es ≠ []" using assms(2,3) (*‹(v::'a::type) ≠ tgt (e::'a edge)› ‹subpath (add_edge g e) v es (tgt e)›*) by (auto simp add : subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*)) then obtain e' and es' where "es = es' @ [e']" (*goal: ‹(⋀es' e'. es = es' @ [e'] ⟹ thesis) ⟹ thesis›*) apply (simp add : neq_Nil_conv2 (*‹(?xs ≠ []) = (∃x xs'. ?xs = xs' @ [x])›*)) (*goal: ‹(⋀(es'::'a edge list) e'::'a edge. (es::'a edge list) = es' @ [e'] ⟹ thesis::bool) ⟹ thesis›*) by blast thus "?thesis" (*goal: ‹e ∈ set es›*) using assms(1,3) (*‹tgt (e::'a edge) ∉ vertices (g::('a, 'b) rgraph_scheme)› ‹subpath (add_edge g e) v es (tgt e)›*) by (auto simp add : sp_append_one (*‹subpath ?g ?v1.0 (?es @ [?e]) ?v2.0 = (subpath ?g ?v1.0 ?es (src ?e) ∧ ?e ∈ edges ?g ∧ tgt ?e = ?v2.0)›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*) image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*)) qed subsection ‹Trees› text ‹We define trees as rooted-graphs in which there exists a unique path leading to each vertex.› definition is_tree :: "('v,'x) rgraph_scheme ⇒ bool" where "is_tree g ≡ ∀ l ∈ Graph.vertices g. ∃! p. Graph.path g p l" text ‹The empty graph is thus a tree.› lemma empty_graph_is_tree : assumes "edges g = {}" shows "is_tree g" using assms (*‹edges g = {}›*) by (auto simp add : is_tree_def (*‹is_tree ?g ≡ ∀l∈vertices ?g. ∃!p. path ?g p l›*) subpath_def (*‹subpath ?g ?v1.0 ?es ?v2.0 ≡ ces ?v1.0 ?es ?v2.0 ∧ ?v1.0 ∈ vertices ?g ∧ set ?es ⊆ edges ?g›*) vertices_def (*‹vertices ?g = {root ?g} ∪ src ` edges ?g ∪ tgt ` edges ?g›*)) end
{ "path": "afp-2025-02-12/thys/InfPathElimination/Graph.thy", "repo": "afp-2025-02-12", "sha": "1948b8c39e51a8cb3f2df07bf79ee56234cd197c36abd5c7cafbbfbb4b72620a" }
(* File: Median_Of_Medians_Selection.thy Author: Manuel Eberl, TU München The median-of-medians selection algorithm, which runs deterministically in linear time. *) section ‹The Median-of-Medians Selection Algorithm› theory Median_Of_Medians_Selection imports Complex_Main "HOL-Library.Multiset" begin subsection ‹Some facts about lists and multisets› lemma mset_concat: "mset (concat xss) = sum_list (map mset xss)" apply (induction xss) (*goals: 1. ‹mset (concat []) = sum_list (map mset [])› 2. ‹⋀a xss. mset (concat xss) = sum_list (map mset xss) ⟹ mset (concat (a # xss)) = sum_list (map mset (a # xss))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma set_mset_sum_list [simp]: "set_mset (sum_list xs) = (⋃x∈set xs. set_mset x)" apply (induction xs) (*goals: 1. ‹set_mset (sum_list []) = ⋃ (set_mset ` set [])› 2. ‹⋀a xs. set_mset (sum_list xs) = ⋃ (set_mset ` set xs) ⟹ set_mset (sum_list (a # xs)) = ⋃ (set_mset ` set (a # xs))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma filter_mset_image_mset: "filter_mset P (image_mset f A) = image_mset f (filter_mset (λx. P (f x)) A)" apply (induction A) (*goals: 1. ‹filter_mset P (image_mset f {#}) = image_mset f {#x ∈# {#}. P (f x)#}› 2. ‹⋀x A. filter_mset P (image_mset f A) = image_mset f {#x ∈# A. P (f x)#} ⟹ filter_mset P (image_mset f (add_mset x A)) = image_mset f {#x ∈# add_mset x A. P (f x)#}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma filter_mset_sum_list: "filter_mset P (sum_list xs) = sum_list (map (filter_mset P) xs)" apply (induction xs) (*goals: 1. ‹filter_mset P (sum_list []) = sum_list (map (filter_mset P) [])› 2. ‹⋀a xs. filter_mset P (sum_list xs) = sum_list (map (filter_mset P) xs) ⟹ filter_mset P (sum_list (a # xs)) = sum_list (map (filter_mset P) (a # xs))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma sum_mset_mset_mono: assumes "(⋀x. x ∈# A ⟹ f x ⊆# g x)" shows "(∑x∈#A. f x) ⊆# (∑x∈#A. g x)" using assms (*‹(?x::'a) ∈# (A::'a multiset) ⟹ (f::'a ⇒ 'b multiset) ?x ⊆# (g::'a ⇒ 'b multiset) ?x›*) apply (induction A) (*goals: 1. ‹(⋀x::'a::type. x ∈# {#} ⟹ (f::'a::type ⇒ 'b::type multiset) x ⊆# (g::'a::type ⇒ 'b::type multiset) x) ⟹ ∑⇩# (image_mset f {#}) ⊆# ∑⇩# (image_mset g {#})› 2. ‹⋀(x::'a::type) A::'a::type multiset. ⟦(⋀x::'a::type. x ∈# A ⟹ (f::'a::type ⇒ 'b::type multiset) x ⊆# (g::'a::type ⇒ 'b::type multiset) x) ⟹ ∑⇩# (image_mset f A) ⊆# ∑⇩# (image_mset g A); ⋀xa::'a::type. xa ∈# add_mset x A ⟹ f xa ⊆# g xa⟧ ⟹ ∑⇩# (image_mset f (add_mset x A)) ⊆# ∑⇩# (image_mset g (add_mset x A))› discuss goal 1*) apply ((auto intro!: subset_mset.add_mono (*‹⟦?a ⊆# ?b; ?c ⊆# ?d⟧ ⟹ ?a + ?c ⊆# ?b + ?d›*))[1]) (*discuss goal 2*) apply ((auto intro!: subset_mset.add_mono (*‹⟦?a ⊆# ?b; ?c ⊆# ?d⟧ ⟹ ?a + ?c ⊆# ?b + ?d›*))[1]) (*proven 2 subgoals*) . lemma mset_filter_mono: assumes "A ⊆# B" "⋀x. x ∈# A ⟹ P x ⟹ Q x" shows "filter_mset P A ⊆# filter_mset Q B" apply (rule mset_subset_eqI (*‹(⋀a::?'a. count (?A::?'a multiset) a ≤ count (?B::?'a multiset) a) ⟹ ?A ⊆# ?B›*)) (*goal: ‹filter_mset P A ⊆# filter_mset Q B›*) apply (insert assms (*‹A ⊆# B› ‹⟦?x ∈# A; P ?x⟧ ⟹ Q ?x›*)) (*goal: ‹⋀a::'a. count (filter_mset (P::'a ⇒ bool) (A::'a multiset)) a ≤ count (filter_mset (Q::'a ⇒ bool) (B::'a multiset)) a›*) by (auto simp: mset_subset_eq_count (*‹?A ⊆# ?B ⟹ count ?A ?a ≤ count ?B ?a›*) count_eq_zero_iff (*‹(count ?M ?x = 0) = (?x ∉# ?M)›*)) lemma size_mset_sum_mset_distrib: "size (sum_mset A :: 'a multiset) = sum_mset (image_mset size A)" apply (induction A) (*goals: 1. ‹size (∑⇩# {#}) = ∑⇩# (image_mset size {#})› 2. ‹⋀x A. size (∑⇩# A) = ∑⇩# (image_mset size A) ⟹ size (∑⇩# (add_mset x A)) = ∑⇩# (image_mset size (add_mset x A))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma sum_mset_mono: assumes "⋀x. x ∈# A ⟹ f x ≤ (g x :: 'a :: {ordered_ab_semigroup_add,comm_monoid_add})" shows "(∑x∈#A. f x) ≤ (∑x∈#A. g x)" using assms (*‹?x ∈# A ⟹ f ?x ≤ g ?x›*) apply (induction A) (*goals: 1. ‹(⋀x. x ∈# {#} ⟹ f x ≤ g x) ⟹ ∑⇩# (image_mset f {#}) ≤ ∑⇩# (image_mset g {#})› 2. ‹⋀x A. ⟦(⋀x. x ∈# A ⟹ f x ≤ g x) ⟹ ∑⇩# (image_mset f A) ≤ ∑⇩# (image_mset g A); ⋀xa. xa ∈# add_mset x A ⟹ f xa ≤ g xa⟧ ⟹ ∑⇩# (image_mset f (add_mset x A)) ≤ ∑⇩# (image_mset g (add_mset x A))› discuss goal 1*) apply ((auto intro!: add_mono (*‹⟦(?a::?'a::ordered_ab_semigroup_add) ≤ (?b::?'a::ordered_ab_semigroup_add); (?c::?'a::ordered_ab_semigroup_add) ≤ (?d::?'a::ordered_ab_semigroup_add)⟧ ⟹ ?a + ?c ≤ ?b + ?d›*))[1]) (*discuss goal 2*) apply ((auto intro!: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*))[1]) (*proven 2 subgoals*) . lemma filter_mset_is_empty_iff: "filter_mset P A = {#} ⟷ (∀x. x ∈# A ⟶ ¬P x)" by (auto simp: multiset_eq_iff (*‹((?M::?'a multiset) = (?N::?'a multiset)) = (∀a::?'a. count ?M a = count ?N a)›*) count_eq_zero_iff (*‹(count (?M::?'a multiset) (?x::?'a) = (0::nat)) = (?x ∉# ?M)›*)) lemma sorted_filter_less_subset_take: assumes "sorted xs" "i < length xs" shows "{# x ∈# mset xs. x < xs ! i #} ⊆# mset (take i xs)" using assms (*‹sorted xs› ‹i < length xs›*) proof (induction xs arbitrary: i rule: list.induct) (*goals: 1. ‹⋀i::nat. ⟦sorted []; i < length []⟧ ⟹ {#x::'a::linorder ∈# mset []. x < [] ! i#} ⊆# mset (take i [])› 2. ‹⋀(x1::'a::linorder) (x2::'a::linorder list) i::nat. ⟦⋀i::nat. ⟦sorted x2; i < length x2⟧ ⟹ {#x::'a::linorder ∈# mset x2. x < x2 ! i#} ⊆# mset (take i x2); sorted (x1 # x2); i < length (x1 # x2)⟧ ⟹ {#x::'a::linorder ∈# mset (x1 # x2). x < (x1 # x2) ! i#} ⊆# mset (take i (x1 # x2))›*) case (Cons x xs i) (*‹⟦sorted xs; ?i < length xs⟧ ⟹ {#x ∈# mset xs. x < xs ! ?i#} ⊆# mset (take ?i xs)› ‹sorted (x # xs)› ‹i < length (x # xs)›*) show "?case" (*goal: ‹{#xa ∈# mset (x # xs). xa < (x # xs) ! i#} ⊆# mset (take i (x # xs))›*) proof (cases i) (*goals: 1. ‹(i::nat) = (0::nat) ⟹ {#xa::'a::linorder ∈# mset (x # xs). xa < ((x::'a::linorder) # (xs::'a::linorder list)) ! i#} ⊆# mset (take i (x # xs))› 2. ‹⋀nat::nat. (i::nat) = Suc nat ⟹ {#xa::'a::linorder ∈# mset (x # xs). xa < ((x::'a::linorder) # (xs::'a::linorder list)) ! i#} ⊆# mset (take i (x # xs))›*) case 0 (*‹i = 0›*) thus "?thesis" (*goal: ‹{#xa ∈# mset (x # xs). xa < (x # xs) ! i#} ⊆# mset (take i (x # xs))›*) using Cons.prems (*‹sorted (x # xs)› ‹i < length (x # xs)›*) by (auto simp: filter_mset_is_empty_iff (*‹(filter_mset ?P ?A = {#}) = (∀x. x ∈# ?A ⟶ ¬ ?P x)›*)) next (*goal: ‹⋀nat. i = Suc nat ⟹ {#xa ∈# mset (x # xs). xa < (x # xs) ! i#} ⊆# mset (take i (x # xs))›*) case (Suc i') (*‹i = Suc i'›*) have "{#y ∈# mset (x # xs). y < (x # xs) ! i#} ⊆# add_mset x {#y ∈# mset xs. y < xs ! i'#}" using Suc (*‹i = Suc i'›*) Cons.prems (*‹sorted ((x::'a) # (xs::'a list))› ‹i < length (x # xs)›*) by auto also (*calculation: ‹{#y::'a ∈# mset (x # xs). y < ((x::'a) # (xs::'a list)) ! (i::nat)#} ⊆# add_mset x {#y::'a ∈# mset xs. y < xs ! (i'::nat)#}›*) have "… ⊆# add_mset x (mset (take i' xs))" unfolding mset_subset_eq_add_mset_cancel (*goal: ‹{#y ∈# mset xs. y < xs ! i'#} ⊆# mset (take i' xs)›*) using Cons.prems (*‹sorted (x # xs)› ‹i < length (x # xs)›*) Suc (*‹(i::nat) = Suc (i'::nat)›*) apply (intro Cons.IH (*‹⟦sorted xs; ?i < length xs⟧ ⟹ {#x ∈# mset xs. x < xs ! ?i#} ⊆# mset (take ?i xs)›*)) (*goals: 1. ‹⟦sorted ((x::'a) # (xs::'a list)); (i::nat) < length (x # xs); i = Suc (i'::nat)⟧ ⟹ sorted xs› 2. ‹⟦sorted ((x::'a) # (xs::'a list)); (i::nat) < length (x # xs); i = Suc (i'::nat)⟧ ⟹ i' < length xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹{#y ∈# mset (x # xs). y < (x # xs) ! i#} ⊆# add_mset x (mset (take i' xs))›*) have "… = mset (take i (x # xs))" by (simp add: Suc (*‹(i::nat) = Suc (i'::nat)›*)) finally (*calculation: ‹{#y ∈# mset (x # xs). y < (x # xs) ! i#} ⊆# mset (take i (x # xs))›*) show "?thesis" (*goal: ‹{#xa ∈# mset (x # xs). xa < (x # xs) ! i#} ⊆# mset (take i (x # xs))›*) . qed qed (auto) (*solved the remaining goal: ‹⋀i. ⟦sorted []; i < length []⟧ ⟹ {#x ∈# mset []. x < [] ! i#} ⊆# mset (take i [])›*) lemma sorted_filter_greater_subset_drop: assumes "sorted xs" "i < length xs" shows "{# x ∈# mset xs. x > xs ! i #} ⊆# mset (drop (Suc i) xs)" using assms (*‹sorted xs› ‹(i::nat) < length (xs::'a::linorder list)›*) proof (induction xs arbitrary: i rule: list.induct) (*goals: 1. ‹⋀i::nat. ⟦sorted []; i < length []⟧ ⟹ filter_mset ((<) ([] ! i)) (mset []) ⊆# mset (drop (Suc i) [])› 2. ‹⋀(x1::'a) (x2::'a list) i::nat. ⟦⋀i::nat. ⟦sorted x2; i < length x2⟧ ⟹ filter_mset ((<) (x2 ! i)) (mset x2) ⊆# mset (drop (Suc i) x2); sorted (x1 # x2); i < length (x1 # x2)⟧ ⟹ filter_mset ((<) ((x1 # x2) ! i)) (mset (x1 # x2)) ⊆# mset (drop (Suc i) (x1 # x2))›*) case (Cons x xs i) (*‹⟦sorted (xs::'a::linorder list); (?i::nat) < length xs⟧ ⟹ filter_mset ((<) (xs ! ?i)) (mset xs) ⊆# mset (drop (Suc ?i) xs)› ‹sorted (x # xs)› ‹i < length (x # xs)›*) show "?case" (*goal: ‹filter_mset ((<) ((x # xs) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))›*) proof (cases i) (*goals: 1. ‹(i::nat) = (0::nat) ⟹ filter_mset ((<) (((x::'a) # (xs::'a list)) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))› 2. ‹⋀nat::nat. (i::nat) = Suc nat ⟹ filter_mset ((<) (((x::'a) # (xs::'a list)) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))›*) case 0 (*‹i = 0›*) thus "?thesis" (*goal: ‹filter_mset ((<) ((x # xs) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))›*) by (auto simp: sorted_append (*‹sorted (?xs @ ?ys) = (sorted ?xs ∧ sorted ?ys ∧ (∀x∈set ?xs. ∀y∈set ?ys. x ≤ y))›*) filter_mset_is_empty_iff (*‹(filter_mset ?P ?A = {#}) = (∀x. x ∈# ?A ⟶ ¬ ?P x)›*)) next (*goal: ‹⋀nat. i = Suc nat ⟹ filter_mset ((<) ((x # xs) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))›*) case (Suc i') (*‹i = Suc i'›*) have "{#y ∈# mset (x # xs). y > (x # xs) ! i#} ⊆# {#y ∈# mset xs. y > xs ! i'#}" using Suc (*‹(i::nat) = Suc (i'::nat)›*) Cons.prems (*‹sorted (x # xs)› ‹i < length (x # xs)›*) by (auto simp: set_conv_nth (*‹set ?xs = {?xs ! i |i. i < length ?xs}›*)) also (*calculation: ‹filter_mset ((<) ((x # xs) ! i)) (mset (x # xs)) ⊆# filter_mset ((<) (xs ! i')) (mset xs)›*) have "… ⊆# mset (drop (Suc i') xs)" using Cons.prems (*‹sorted (x # xs)› ‹i < length (x # xs)›*) Suc (*‹i = Suc i'›*) apply (intro Cons.IH (*‹⟦sorted (xs::'a list); (?i::nat) < length xs⟧ ⟹ filter_mset ((<) (xs ! ?i)) (mset xs) ⊆# mset (drop (Suc ?i) xs)›*)) (*goals: 1. ‹⟦sorted (x # xs); i < length (x # xs); i = Suc i'⟧ ⟹ sorted xs› 2. ‹⟦sorted (x # xs); i < length (x # xs); i = Suc i'⟧ ⟹ i' < length xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . also (*calculation: ‹filter_mset ((<) ((x # xs) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i') xs)›*) have "… = mset (drop (Suc i) (x # xs))" by (simp add: Suc (*‹i = Suc i'›*)) finally (*calculation: ‹filter_mset ((<) ((x # xs) ! i)) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))›*) show "?thesis" (*goal: ‹filter_mset ((<) (((x::'a) # (xs::'a list)) ! (i::nat))) (mset (x # xs)) ⊆# mset (drop (Suc i) (x # xs))›*) . qed qed (auto) (*solved the remaining goal: ‹⋀i. ⟦sorted []; i < length []⟧ ⟹ filter_mset ((<) ([] ! i)) (mset []) ⊆# mset (drop (Suc i) [])›*) subsection ‹The dual order type› text ‹ The following type is a copy of a given ordered base type, but with the ordering reversed. This will be useful later because we can do some of our reasoning simply by symmetry. › typedef 'a dual_ord = "UNIV :: 'a set" morphisms of_dual_ord to_dual_ord by auto setup_lifting type_definition_dual_ord instantiation dual_ord :: (ord) ord begin lift_definition less_eq_dual_ord :: "'a dual_ord ⇒ 'a dual_ord ⇒ bool" is "λa b :: 'a. a ≥ b" . lift_definition less_dual_ord :: "'a dual_ord ⇒ 'a dual_ord ⇒ bool" is "λa b :: 'a. a > b" . instance .. end instance dual_ord :: (preorder) preorder by standard (transfer; force simp: less_le_not_le intro: order_trans)+ instance dual_ord :: (linorder) linorder by standard (transfer; force simp: not_le)+ subsection ‹Chopping a list into equal-sized sublists› (* TODO: Move to library? *) function chop :: "nat ⇒ 'a list ⇒ 'a list list" where "chop n [] = []" | "chop 0 xs = []" | "n > 0 ⟹ xs ≠ [] ⟹ chop n xs = take n xs # chop n (drop n xs)" by force+ termination by lexicographic_order context includes lifting_syntax begin lemma chop_transfer [transfer_rule]: "((=) ===> list_all2 R ===> list_all2 (list_all2 R)) chop chop" proof (intro rel_funI (*‹(⋀x y. ?A x y ⟹ ?B (?f x) (?g y)) ⟹ (?A ===> ?B) ?f ?g›*)) (*goal: ‹⋀x y xa ya. ⟦x = y; list_all2 R xa ya⟧ ⟹ list_all2 (list_all2 R) (chop x xa) (chop y ya)›*) fix m :: nat and n :: nat and xs :: "'a list" and ys :: "'b list" assume "m = n" "list_all2 R xs ys" (*‹(m::nat) = (n::nat)› ‹list_all2 (R::'a ⇒ 'b ⇒ bool) (xs::'a list) (ys::'b list)›*) from this(2) (*‹list_all2 R xs ys›*) have "list_all2 (list_all2 R) (chop n xs) (chop n ys)" proof (induction n xs arbitrary: ys rule: chop.induct) (*goals: 1. ‹⋀(n::nat) ys::'b list. list_all2 (R::'a ⇒ 'b ⇒ bool) [] ys ⟹ list_all2 (list_all2 R) (chop n []) (chop n ys)› 2. ‹⋀(xs::'a list) ys::'b list. list_all2 (R::'a ⇒ 'b ⇒ bool) xs ys ⟹ list_all2 (list_all2 R) (chop (0::nat) xs) (chop (0::nat) ys)› 3. ‹⋀(n::nat) (xs::'a list) ys::'b list. ⟦(0::nat) < n; xs ≠ []; ⋀ys::'b list. list_all2 (R::'a ⇒ 'b ⇒ bool) (drop n xs) ys ⟹ list_all2 (list_all2 R) (chop n (drop n xs)) (chop n ys); list_all2 R xs ys⟧ ⟹ list_all2 (list_all2 R) (chop n xs) (chop n ys)›*) case (3 n xs ys) (*‹0 < n› ‹xs ≠ []› ‹list_all2 R (drop n xs) ?ys ⟹ list_all2 (list_all2 R) (chop n (drop n xs)) (chop n ?ys)› ‹list_all2 (R::'a ⇒ 'b ⇒ bool) (xs::'a list) (ys::'b list)›*) hence "ys ≠ []" by auto with "3" (*‹0 < n› ‹xs ≠ []› ‹list_all2 R (drop n xs) ?ys ⟹ list_all2 (list_all2 R) (chop n (drop n xs)) (chop n ?ys)› ‹list_all2 R xs ys›*) show "?case" (*goal: ‹list_all2 (list_all2 R) (chop n xs) (chop n ys)›*) by auto qed (auto) (*solves the remaining goals: 1. ‹⋀n ys. list_all2 R [] ys ⟹ list_all2 (list_all2 R) (chop n []) (chop n ys)› 2. ‹⋀xs ys. list_all2 R xs ys ⟹ list_all2 (list_all2 R) (chop 0 xs) (chop 0 ys)›*) with ‹m = n› (*‹(m::nat) = (n::nat)›*) show "list_all2 (list_all2 R) (chop m xs) (chop n ys)" by simp qed end lemma chop_reduce: "chop n xs = (if n = 0 ∨ xs = [] then [] else take n xs # chop n (drop n xs))" apply (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ chop n xs = (if n = 0 ∨ xs = [] then [] else take n xs # chop n (drop n xs))› 2. ‹n ≠ 0 ⟹ chop n xs = (if n = 0 ∨ xs = [] then [] else take n xs # chop n (drop n xs))› discuss goal 1*) apply (cases "xs = []") (*goals: 1. ‹⟦n = 0; xs = []⟧ ⟹ chop n xs = (if n = 0 ∨ xs = [] then [] else take n xs # chop n (drop n xs))› 2. ‹⟦n = 0; xs ≠ []⟧ ⟹ chop n xs = (if n = 0 ∨ xs = [] then [] else take n xs # chop n (drop n xs))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases "xs = []") (*goals: 1. ‹⟦(n::nat) ≠ (0::nat); (xs::'a list) = []⟧ ⟹ chop n xs = (if n = (0::nat) ∨ xs = [] then [] else take n xs # chop n (drop n xs))› 2. ‹⟦(n::nat) ≠ (0::nat); (xs::'a list) ≠ []⟧ ⟹ chop n xs = (if n = (0::nat) ∨ xs = [] then [] else take n xs # chop n (drop n xs))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma concat_chop [simp]: "n > 0 ⟹ concat (chop n xs) = xs" apply (induction n xs rule: chop.induct (*‹⟦⋀n. ?P n []; ⋀xs. ?P 0 xs; ⋀n xs. ⟦0 < n; xs ≠ []; ?P n (drop n xs)⟧ ⟹ ?P n xs⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀n. 0 < n ⟹ concat (chop n []) = []› 2. ‹⋀xs. 0 < 0 ⟹ concat (chop 0 xs) = xs› 3. ‹⋀n xs. ⟦0 < n; xs ≠ []; 0 < n ⟹ concat (chop n (drop n xs)) = drop n xs; 0 < n⟧ ⟹ concat (chop n xs) = xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma chop_elem_not_Nil [simp,dest]: "ys ∈ set (chop n xs) ⟹ ys ≠ []" apply (induction n xs rule: chop.induct (*‹⟦⋀n. ?P n []; ⋀xs. ?P 0 xs; ⋀n xs. ⟦0 < n; xs ≠ []; ?P n (drop n xs)⟧ ⟹ ?P n xs⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀n. ys ∈ set (chop n []) ⟹ ys ≠ []› 2. ‹⋀xs. ys ∈ set (chop 0 xs) ⟹ ys ≠ []› 3. ‹⋀n xs. ⟦0 < n; xs ≠ []; ys ∈ set (chop n (drop n xs)) ⟹ ys ≠ []; ys ∈ set (chop n xs)⟧ ⟹ ys ≠ []› discuss goal 1*) apply ((auto simp: eq_commute[of "[]"] (*‹([] = ?b) = (?b = [])›*))[1]) (*discuss goal 2*) apply ((auto simp: eq_commute[of "[]"] (*‹([] = ?b) = (?b = [])›*))[1]) (*discuss goal 3*) apply ((auto simp: eq_commute[of "[]"] (*‹([] = ?b) = (?b = [])›*))[1]) (*proven 3 subgoals*) . lemma chop_eq_Nil_iff [simp]: "chop n xs = [] ⟷ n = 0 ∨ xs = []" sorry lemma chop_ge_length_eq: "n > 0 ⟹ xs ≠ [] ⟹ n ≥ length xs ⟹ chop n xs = [xs]" by simp lemma length_chop_part_le: "ys ∈ set (chop n xs) ⟹ length ys ≤ n" apply (induction n xs rule: chop.induct (*‹⟦⋀n. ?P n []; ⋀xs. ?P 0 xs; ⋀n xs. ⟦0 < n; xs ≠ []; ?P n (drop n xs)⟧ ⟹ ?P n xs⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀n. ys ∈ set (chop n []) ⟹ length ys ≤ n› 2. ‹⋀xs. ys ∈ set (chop 0 xs) ⟹ length ys ≤ 0› 3. ‹⋀n xs. ⟦0 < n; xs ≠ []; ys ∈ set (chop n (drop n xs)) ⟹ length ys ≤ n; ys ∈ set (chop n xs)⟧ ⟹ length ys ≤ n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma length_nth_chop: assumes "i < length (chop n xs)" shows "length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬n dvd length xs then length xs mod n else n)" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs then length xs mod n else n)› 2. ‹n ≠ 0 ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs then length xs mod n else n)›*) case False (*‹(n::nat) ≠ (0::nat)›*) thus "?thesis" (*goal: ‹length (chop (n::nat) (xs::'a list) ! (i::nat)) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)›*) using assms (*‹i < length (chop n xs)›*) proof (induction n xs arbitrary: i rule: chop.induct) (*goals: 1. ‹⋀(n::nat) i::nat. ⟦n ≠ (0::nat); i < length (chop n [])⟧ ⟹ length (chop n [] ! i) = (if i = length (chop n []) - (1::nat) ∧ ¬ n dvd length [] then length [] mod n else n)› 2. ‹⋀(xs::'a list) i::nat. ⟦(0::nat) ≠ (0::nat); i < length (chop (0::nat) xs)⟧ ⟹ length (chop (0::nat) xs ! i) = (if i = length (chop (0::nat) xs) - (1::nat) ∧ ¬ (0::nat) dvd length xs then length xs mod (0::nat) else (0::nat))› 3. ‹⋀(n::nat) (xs::'a list) i::nat. ⟦(0::nat) < n; xs ≠ []; ⋀i::nat. ⟦n ≠ (0::nat); i < length (chop n (drop n xs))⟧ ⟹ length (chop n (drop n xs) ! i) = (if i = length (chop n (drop n xs)) - (1::nat) ∧ ¬ n dvd length (drop n xs) then length (drop n xs) mod n else n); n ≠ (0::nat); i < length (chop n xs)⟧ ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)›*) case (3 n xs i) (*‹0 < n› ‹(xs::'a list) ≠ []› ‹⟦(n::nat) ≠ (0::nat); (?i::nat) < length (chop n (drop n (xs::'a list)))⟧ ⟹ length (chop n (drop n xs) ! ?i) = (if ?i = length (chop n (drop n xs)) - (1::nat) ∧ ¬ n dvd length (drop n xs) then length (drop n xs) mod n else n)› ‹(n::nat) ≠ (0::nat)› ‹i < length (chop n xs)›*) show "?case" (*goal: ‹length (chop (n::nat) (xs::'a::type list) ! (i::nat)) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)›*) proof (cases i) (*goals: 1. ‹(i::nat) = (0::nat) ⟹ length (chop (n::nat) (xs::'a list) ! i) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)› 2. ‹⋀nat::nat. (i::nat) = Suc nat ⟹ length (chop (n::nat) (xs::'a list) ! i) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)›*) case 0 (*‹i = 0›*) thus "?thesis" (*goal: ‹length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs then length xs mod n else n)›*) using "3.prems" (*‹n ≠ 0› ‹i < length (chop n xs)›*) apply (cases "length xs < n") (*goals: 1. ‹⟦(i::nat) = (0::nat); (n::nat) ≠ (0::nat); i < length (chop n (xs::'a list)); length xs < n⟧ ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)› 2. ‹⟦(i::nat) = (0::nat); (n::nat) ≠ (0::nat); i < length (chop n (xs::'a list)); ¬ length xs < n⟧ ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)› discuss goal 1*) apply ((auto simp: le_Suc_eq (*‹(?m ≤ Suc ?n) = (?m ≤ ?n ∨ ?m = Suc ?n)›*) dest: dvd_imp_le (*‹⟦?k dvd ?n; 0 < ?n⟧ ⟹ ?k ≤ ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: le_Suc_eq (*‹(?m ≤ Suc ?n) = (?m ≤ ?n ∨ ?m = Suc ?n)›*) dest: dvd_imp_le (*‹⟦?k dvd ?n; 0 < ?n⟧ ⟹ ?k ≤ ?n›*))[1]) (*proven 2 subgoals*) . next (*goal: ‹⋀nat. i = Suc nat ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs then length xs mod n else n)›*) case [simp]: (Suc i') (*‹i = Suc i'›*) with "3.prems" (*‹n ≠ 0› ‹i < length (chop n xs)›*) have [simp]: "xs ≠ []" by auto with "3.prems" (*‹n ≠ 0› ‹(i::nat) < length (chop (n::nat) (xs::'a list))›*) have "*": "length xs > n" apply (cases "length xs ≤ n") (*goals: 1. ‹⟦(n::nat) ≠ (0::nat); (i::nat) < length (chop n (xs::'a::type list)); xs ≠ []; length xs ≤ n⟧ ⟹ n < length xs› 2. ‹⟦(n::nat) ≠ (0::nat); (i::nat) < length (chop n (xs::'a::type list)); xs ≠ []; ¬ length xs ≤ n⟧ ⟹ n < length xs› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with "3.prems" (*‹n ≠ 0› ‹(i::nat) < length (chop (n::nat) (xs::'a list))›*) have "chop n xs ! i = chop n (drop n xs) ! i'" by simp also (*calculation: ‹chop n xs ! i = chop n (drop n xs) ! i'›*) have "length … = (if i = length (chop n xs) - 1 ∧ ¬ n dvd (length xs - n) then (length xs - n) mod n else n)" apply (subst "3.IH" (*‹⟦n ≠ 0; ?i < length (chop n (drop n xs))⟧ ⟹ length (chop n (drop n xs) ! ?i) = (if ?i = length (chop n (drop n xs)) - 1 ∧ ¬ n dvd length (drop n xs) then length (drop n xs) mod n else n)›*)) (*goals: 1. ‹n ≠ 0› 2. ‹i' < length (chop n (drop n xs))› 3. ‹(if i' = length (chop n (drop n xs)) - 1 ∧ ¬ n dvd length (drop n xs) then length (drop n xs) mod n else n) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs - n then (length xs - n) mod n else n)› discuss goal 1*) apply ((use Suc "3.prems" in auto)[1]) (*discuss goal 2*) apply ((use Suc "3.prems" in auto)[1]) (*discuss goal 3*) apply ((use Suc "3.prems" in auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs - n then (length xs - n) mod n else n)›*) have "n dvd (length xs - n) ⟷ n dvd length xs" using "*" (*‹n < length xs›*) apply (subst dvd_minus_self (*‹(?m dvd ?n - ?m) = (?n < ?m ∨ ?m dvd ?n)›*)) (*goal: ‹((n::nat) dvd length (xs::'a list) - n) = (n dvd length xs)›*) by auto also (*calculation: ‹length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs then (length xs - n) mod n else n)›*) have "(length xs - n) mod n = length xs mod n" using "*" (*‹n < length xs›*) apply (subst le_mod_geq [symmetric] (*‹?n ≤ ?m ⟹ (?m - ?n) mod ?n = ?m mod ?n›*)) (*goals: 1. ‹n < length xs ⟹ n ≤ length xs› 2. ‹n < length xs ⟹ length xs mod n = length xs mod n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹length (chop (n::nat) (xs::'a list) ! (i::nat)) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)›*) show "?thesis" (*goal: ‹length (chop (n::nat) (xs::'a list) ! (i::nat)) = (if i = length (chop n xs) - (1::nat) ∧ ¬ n dvd length xs then length xs mod n else n)›*) . qed qed (auto) (*solves the remaining goals: 1. ‹⋀(n::nat) i::nat. ⟦n ≠ (0::nat); i < length (chop n [])⟧ ⟹ length (chop n [] ! i) = (if i = length (chop n []) - (1::nat) ∧ ¬ n dvd length [] then length [] mod n else n)› 2. ‹⋀(xs::'a list) i::nat. ⟦(0::nat) ≠ (0::nat); i < length (chop (0::nat) xs)⟧ ⟹ length (chop (0::nat) xs ! i) = (if i = length (chop (0::nat) xs) - (1::nat) ∧ ¬ (0::nat) dvd length xs then length xs mod (0::nat) else (0::nat))›*) qed (insert assms (*‹i < length (chop n xs)›*), auto) (*solved the remaining goal: ‹n = 0 ⟹ length (chop n xs ! i) = (if i = length (chop n xs) - 1 ∧ ¬ n dvd length xs then length xs mod n else n)›*) lemma length_chop: assumes "n > 0" shows "length (chop n xs) = nat ⌈length xs / n⌉" using assms (*‹(0::nat) < (n::nat)›*) proof (induction n xs rule: chop.induct (*‹⟦⋀n. ?P n []; ⋀xs. ?P 0 xs; ⋀n xs. ⟦0 < n; xs ≠ []; ?P n (drop n xs)⟧ ⟹ ?P n xs⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀n. 0 < n ⟹ length (chop n []) = nat ⌈real (length []) / real n⌉› 2. ‹⋀xs. 0 < 0 ⟹ length (chop 0 xs) = nat ⌈real (length xs) / real 0⌉› 3. ‹⋀n xs. ⟦0 < n; xs ≠ []; 0 < n ⟹ length (chop n (drop n xs)) = nat ⌈real (length (drop n xs)) / real n⌉; 0 < n⟧ ⟹ length (chop n xs) = nat ⌈real (length xs) / real n⌉›*) case (3 n xs) (*‹0 < n› ‹xs ≠ []› ‹0 < n ⟹ length (chop n (drop n xs)) = nat ⌈real (length (drop n xs)) / real n⌉› ‹0 < n›*) show "?case" (*goal: ‹length (chop n xs) = nat ⌈real (length xs) / real n⌉›*) proof (cases "length xs ≥ n") (*goals: 1. ‹n ≤ length xs ⟹ length (chop n xs) = nat ⌈real (length xs) / real n⌉› 2. ‹¬ n ≤ length xs ⟹ length (chop n xs) = nat ⌈real (length xs) / real n⌉›*) case False (*‹¬ (n::nat) ≤ length (xs::'a::type list)›*) hence "⌈real (length xs) / real n⌉ = 1" using "3.hyps" (*‹0 < n› ‹xs ≠ []›*) apply (intro ceiling_unique (*‹⟦of_int ?z - 1 < ?x; ?x ≤ of_int ?z⟧ ⟹ ⌈?x⌉ = ?z›*)) (*goals: 1. ‹⟦¬ (n::nat) ≤ length (xs::'a list); (0::nat) < n; xs ≠ []⟧ ⟹ real_of_int (1::int) - (1::real) < real (length xs) / real n› 2. ‹⟦¬ (n::nat) ≤ length (xs::'a list); (0::nat) < n; xs ≠ []⟧ ⟹ real (length xs) / real n ≤ real_of_int (1::int)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . with False (*‹¬ n ≤ length xs›*) show "?thesis" (*goal: ‹length (chop n xs) = nat ⌈real (length xs) / real n⌉›*) using "3.prems" (*‹0 < n›*) "3.hyps" (*‹0 < n› ‹xs ≠ []›*) by (auto simp: chop_ge_length_eq (*‹⟦(0::nat) < (?n::nat); (?xs::?'a::type list) ≠ []; length ?xs ≤ ?n⟧ ⟹ chop ?n ?xs = [?xs]›*) not_le (*‹(¬ (?x::?'a::linorder) ≤ (?y::?'a::linorder)) = (?y < ?x)›*)) next (*goal: ‹n ≤ length xs ⟹ length (chop n xs) = nat ⌈real (length xs) / real n⌉›*) case True (*‹n ≤ length xs›*) hence "real (length xs) = real n + real (length (drop n xs))" by simp also (*calculation: ‹real (length xs) = real n + real (length (drop n xs))›*) have "… / real n = real (length (drop n xs)) / real n + 1" using ‹n > 0› (*‹0 < n›*) by (simp add: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) also (*calculation: ‹real (length xs) / real n = real (length (drop n xs)) / real n + 1›*) have "ceiling … = ceiling (real (length (drop n xs)) / real n) + 1" by simp also (*calculation: ‹⌈real (length xs) / real n⌉ = ⌈real (length (drop n xs)) / real n⌉ + 1›*) have "nat … = nat (ceiling (real (length (drop n xs)) / real n)) + nat 1" apply (intro nat_add_distrib[OF order.trans[OF _ ceiling_mono[of 0]]] (*‹⟦0 ≤ ⌈0⌉; 0 ≤ ?x2; 0 ≤ ?z'⟧ ⟹ nat (⌈?x2⌉ + ?z') = nat ⌈?x2⌉ + nat ?z'›*)) (*goals: 1. ‹0 ≤ ⌈0⌉› 2. ‹0 ≤ real (length (drop n xs)) / real n› 3. ‹0 ≤ 1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . also (*calculation: ‹nat ⌈real (length xs) / real n⌉ = nat ⌈real (length (drop n xs)) / real n⌉ + nat 1›*) have "… = length (chop n xs)" using ‹n > 0› (*‹0 < n›*) "3.hyps" (*‹0 < n› ‹(xs::'a list) ≠ []›*) apply (subst "3.IH" [symmetric] (*‹0 < n ⟹ nat ⌈real (length (drop n xs)) / real n⌉ = length (chop n (drop n xs))›*)) (*goals: 1. ‹⟦0 < n; 0 < n; xs ≠ []⟧ ⟹ 0 < n› 2. ‹⟦0 < n; 0 < n; xs ≠ []⟧ ⟹ length (chop n (drop n xs)) + nat 1 = length (chop n xs)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹nat ⌈real (length (xs::'a list)) / real (n::nat)⌉ = length (chop n xs)›*) show "?thesis" (*goal: ‹length (chop n xs) = nat ⌈real (length xs) / real n⌉›*) by standard qed qed (auto) (*solves the remaining goals: 1. ‹⋀n. 0 < n ⟹ length (chop n []) = nat ⌈real (length []) / real n⌉› 2. ‹⋀xs. 0 < 0 ⟹ length (chop 0 xs) = nat ⌈real (length xs) / real 0⌉›*) lemma sum_msets_chop: "n > 0 ⟹ (∑ys←chop n xs. mset ys) = mset xs" apply (subst mset_concat [symmetric] (*‹sum_list (map mset (?xss::?'a list list)) = mset (concat ?xss)›*)) (*goal: ‹(0::nat) < (n::nat) ⟹ sum_list (map mset (chop n (xs::'a list))) = mset xs›*) by simp lemma UN_sets_chop: "n > 0 ⟹ (⋃ys∈set (chop n xs). set ys) = set xs" by (simp only: set_concat [symmetric] (*‹⋃ (set ` set ?xs) = set (concat ?xs)›*) concat_chop (*‹0 < ?n ⟹ concat (chop ?n ?xs) = ?xs›*)) lemma in_set_chopD [dest]: assumes "x ∈ set ys" "ys ∈ set (chop d xs)" shows "x ∈ set xs" proof (cases "d > 0") (*goals: 1. ‹0 < d ⟹ x ∈ set xs› 2. ‹¬ 0 < d ⟹ x ∈ set xs›*) case True (*‹0 < d›*) thus "?thesis" (*goal: ‹x ∈ set xs›*) apply (subst UN_sets_chop [symmetric] (*‹0 < ?n ⟹ set ?xs = ⋃ (set ` set (chop ?n ?xs))›*)) (*goals: 1. ‹0 < d ⟹ 0 < ?n1› 2. ‹0 < d ⟹ x ∈ ⋃ (set ` set (chop ?n1 xs))› discuss goal 1*) apply ((use assms in auto)[1]) (*discuss goal 2*) apply ((use assms in auto)[1]) (*proven 2 subgoals*) . qed (use assms in auto) (*solved the remaining goal: ‹¬ 0 < d ⟹ x ∈ set xs›*) subsection ‹$k$-th order statistics and medians› text ‹ This returns the $k$-th smallest element of a list. This is also known as the $k$-th order statistic. › definition select :: "nat ⇒ 'a list ⇒ ('a :: linorder)" where "select k xs = sort xs ! k" text ‹ The median of a list, where, for lists of even lengths, the smaller one is favoured: › definition median where "median xs = select ((length xs - 1) div 2) xs" lemma select_in_set [intro,simp]: assumes "k < length xs" shows "select k xs ∈ set xs" sorry lemma median_in_set [intro, simp]: assumes "xs ≠ []" shows "median xs ∈ set xs" proof (-) (*goal: ‹median xs ∈ set xs›*) from assms (*‹(xs::'a list) ≠ []›*) have "length xs > 0" by auto hence "(length xs - 1) div 2 < length xs" by linarith thus "?thesis" (*goal: ‹median xs ∈ set xs›*) by (simp add: median_def (*‹median ?xs = select ((length ?xs - 1) div 2) ?xs›*)) qed text ‹ We show that selection and medians does not depend on the order of the elements: › lemma sort_cong: "mset xs = mset ys ⟹ sort xs = sort ys" apply (rule properties_for_sort (*‹⟦mset ?ys = mset ?xs; sorted ?ys⟧ ⟹ sort ?xs = ?ys›*)) (*goals: 1. ‹mset (xs::'a list) = mset (ys::'a list) ⟹ mset (sort ys) = mset xs› 2. ‹mset (xs::'a list) = mset (ys::'a list) ⟹ sorted (sort ys)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma select_cong: "k = k' ⟹ mset xs = mset xs' ⟹ select k xs = select k' xs'" by (auto simp: select_def (*‹select ?k ?xs = sort ?xs ! ?k›*) dest: sort_cong (*‹mset ?xs = mset ?ys ⟹ sort ?xs = sort ?ys›*)) lemma median_cong: "mset xs = mset xs' ⟹ median xs = median xs'" unfolding median_def (*goal: ‹mset (xs::'a::linorder list) = mset (xs'::'a::linorder list) ⟹ select ((length xs - (1::nat)) div (2::nat)) xs = select ((length xs' - (1::nat)) div (2::nat)) xs'›*) apply (intro select_cong (*‹⟦?k = ?k'; mset ?xs = mset ?xs'⟧ ⟹ select ?k ?xs = select ?k' ?xs'›*)) (*goals: 1. ‹mset xs = mset xs' ⟹ (length xs - 1) div 2 = (length xs' - 1) div 2› 2. ‹mset xs = mset xs' ⟹ mset xs = mset xs'› discuss goal 1*) apply ((auto dest: mset_eq_length (*‹mset (?xs::?'a list) = mset (?ys::?'a list) ⟹ length ?xs = length ?ys›*))[1]) (*discuss goal 2*) apply ((auto dest: mset_eq_length (*‹mset (?xs::?'a list) = mset (?ys::?'a list) ⟹ length ?xs = length ?ys›*))[1]) (*proven 2 subgoals*) . text ‹ Selection distributes over appending lists under certain conditions: › lemma sort_append: assumes "⋀x y. x ∈ set xs ⟹ y ∈ set ys ⟹ x ≤ y" shows "sort (xs @ ys) = sort xs @ sort ys" using assms (*‹⟦(?x::'a::linorder) ∈ set (xs::'a::linorder list); (?y::'a::linorder) ∈ set (ys::'a::linorder list)⟧ ⟹ ?x ≤ ?y›*) apply (intro properties_for_sort (*‹⟦mset ?ys = mset ?xs; sorted ?ys⟧ ⟹ sort ?xs = ?ys›*)) (*goals: 1. ‹(⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ x ≤ y) ⟹ mset (sort xs @ sort ys) = mset (xs @ ys)› 2. ‹(⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ x ≤ y) ⟹ sorted (sort xs @ sort ys)› discuss goal 1*) apply ((auto simp: sorted_append (*‹sorted (?xs @ ?ys) = (sorted ?xs ∧ sorted ?ys ∧ (∀x∈set ?xs. ∀y∈set ?ys. x ≤ y))›*))[1]) (*discuss goal 2*) apply ((auto simp: sorted_append (*‹sorted (?xs @ ?ys) = (sorted ?xs ∧ sorted ?ys ∧ (∀x∈set ?xs. ∀y∈set ?ys. x ≤ y))›*))[1]) (*proven 2 subgoals*) . lemma select_append: assumes "⋀y z. y ∈ set ys ⟹ z ∈ set zs ⟹ y ≤ z" shows "k < length ys ⟹ select k (ys @ zs) = select k ys" "k ∈ {length ys..<length ys + length zs} ⟹ select k (ys @ zs) = select (k - length ys) zs" using assms (*‹⟦?y ∈ set ys; ?z ∈ set zs⟧ ⟹ ?y ≤ ?z›*) apply - (*goals: 1. ‹⟦k < length ys; ⋀y z. ⟦y ∈ set ys; z ∈ set zs⟧ ⟹ y ≤ z⟧ ⟹ select k (ys @ zs) = select k ys› 2. ‹⟦k ∈ {length ys..<length ys + length zs}; ⋀y z. ⟦y ∈ set ys; z ∈ set zs⟧ ⟹ y ≤ z⟧ ⟹ select k (ys @ zs) = select (k - length ys) zs› discuss goal 1*) apply (simp add: select_def (*‹select ?k ?xs = sort ?xs ! ?k›*) sort_append (*‹(⋀x y. ⟦x ∈ set ?xs; y ∈ set ?ys⟧ ⟹ x ≤ y) ⟹ sort (?xs @ ?ys) = sort ?xs @ sort ?ys›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 2*) apply (simp add: select_def (*‹select ?k ?xs = sort ?xs ! ?k›*) sort_append (*‹(⋀x y. ⟦x ∈ set ?xs; y ∈ set ?ys⟧ ⟹ x ≤ y) ⟹ sort (?xs @ ?ys) = sort ?xs @ sort ?ys›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*proven 2 subgoals*) . lemma select_append': assumes "⋀y z. y ∈ set ys ⟹ z ∈ set zs ⟹ y ≤ z" "k < length ys + length zs" shows "select k (ys @ zs) = (if k < length ys then select k ys else select (k - length ys) zs)" using assms (*‹⟦?y ∈ set ys; ?z ∈ set zs⟧ ⟹ ?y ≤ ?z› ‹k < length ys + length zs›*) by (auto intro!: select_append (*‹⟦⋀y z. ⟦y ∈ set ?ys; z ∈ set ?zs⟧ ⟹ y ≤ z; ?k < length ?ys⟧ ⟹ select ?k (?ys @ ?zs) = select ?k ?ys› ‹⟦⋀y z. ⟦y ∈ set ?ys; z ∈ set ?zs⟧ ⟹ y ≤ z; ?k ∈ {length ?ys..<length ?ys + length ?zs}⟧ ⟹ select ?k (?ys @ ?zs) = select (?k - length ?ys) ?zs›*)) text ‹ We can find simple upper bounds for the number of elements that are strictly less than (resp. greater than) the median of a list. › lemma size_less_than_median: "size {#y ∈# mset xs. y < median xs#} ≤ (length xs - 1) div 2" proof (cases "xs = []") (*goals: 1. ‹xs = [] ⟹ size {#y ∈# mset xs. y < median xs#} ≤ (length xs - 1) div 2› 2. ‹xs ≠ [] ⟹ size {#y ∈# mset xs. y < median xs#} ≤ (length xs - 1) div 2›*) case False (*‹xs ≠ []›*) hence "length xs > 0" by simp hence "(length xs - 1) div 2 < length xs" by linarith hence "size {#y ∈# mset (sort xs). y < median xs#} ≤ size (mset (take ((length xs - 1) div 2) (sort xs)))" unfolding median_def select_def (*goal: ‹size {#y ∈# mset (sort xs). y < sort xs ! ((length xs - 1) div 2)#} ≤ size (mset (take ((length xs - 1) div 2) (sort xs)))›*) using False (*‹(xs::'a list) ≠ []›*) apply (intro size_mset_mono (*‹?A ⊆# ?B ⟹ size ?A ≤ size ?B›*) sorted_filter_less_subset_take (*‹⟦sorted ?xs; ?i < length ?xs⟧ ⟹ {#x ∈# mset ?xs. x < ?xs ! ?i#} ⊆# mset (take ?i ?xs)›*)) (*goals: 1. ‹⟦(length xs - 1) div 2 < length xs; xs ≠ []⟧ ⟹ sorted (sort xs)› 2. ‹⟦(length xs - 1) div 2 < length xs; xs ≠ []⟧ ⟹ (length xs - 1) div 2 < length (sort xs)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹size {#y ∈# mset xs. y < median xs#} ≤ (length xs - 1) div 2›*) using False (*‹xs ≠ []›*) by simp qed (auto) (*solved the remaining goal: ‹xs = [] ⟹ size {#y ∈# mset xs. y < median xs#} ≤ (length xs - 1) div 2›*) lemma size_greater_than_median: "size {#y ∈# mset xs. y > median xs#} ≤ length xs div 2" proof (cases "xs = []") (*goals: 1. ‹xs = [] ⟹ size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs div 2› 2. ‹xs ≠ [] ⟹ size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs div 2›*) case False (*‹xs ≠ []›*) hence "length xs > 0" by simp hence "(length xs - 1) div 2 < length xs" by linarith hence "size {#y ∈# mset (sort xs). y > median xs#} ≤ size (mset (drop (Suc ((length xs - 1) div 2)) (sort xs)))" unfolding median_def select_def (*goal: ‹size (filter_mset ((<) (sort xs ! ((length xs - 1) div 2))) (mset (sort xs))) ≤ size (mset (drop (Suc ((length xs - 1) div 2)) (sort xs)))›*) using False (*‹(xs::'a::linorder list) ≠ []›*) apply (intro size_mset_mono (*‹?A ⊆# ?B ⟹ size ?A ≤ size ?B›*) sorted_filter_greater_subset_drop (*‹⟦sorted ?xs; ?i < length ?xs⟧ ⟹ filter_mset ((<) (?xs ! ?i)) (mset ?xs) ⊆# mset (drop (Suc ?i) ?xs)›*)) (*goals: 1. ‹⟦(length xs - 1) div 2 < length xs; xs ≠ []⟧ ⟹ sorted (sort xs)› 2. ‹⟦(length xs - 1) div 2 < length xs; xs ≠ []⟧ ⟹ (length xs - 1) div 2 < length (sort xs)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "size (filter_mset (λy. y > median xs) (mset xs)) ≤ length xs - Suc ((length xs - 1) div 2)" by simp also (*calculation: ‹size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs - Suc ((length xs - 1) div 2)›*) have "… = length xs div 2" by linarith finally (*calculation: ‹size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs div 2›*) show "?thesis" (*goal: ‹size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs div 2›*) . qed (auto) (*solved the remaining goal: ‹xs = [] ⟹ size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs div 2›*) subsection ‹A more liberal notion of medians› text ‹ We now define a more relaxed version of being ``a median'' as opposed to being ``\emph{the} median''. A value is a median if at most half the values in the list are strictly smaller than it and at most half are strictly greater. Note that, by this definition, the median does not even have to be in the list itself. › definition is_median :: "'a :: linorder ⇒ 'a list ⇒ bool" where "is_median x xs ⟷ length (filter (λy. y < x) xs) ≤ length xs div 2 ∧ length (filter (λy. y > x) xs) ≤ length xs div 2" text ‹ We set up some transfer rules for @{const is_median}. In particular, we have a rule that shows that something is a median for a list iff it is a median on that list w.\,r.\,t.\ the dual order, which will later allow us to argue by symmetry. › context includes lifting_syntax begin lemma transfer_is_median [transfer_rule]: assumes [transfer_rule]: "(r ===> r ===> (=)) (<) (<)" shows "(r ===> list_all2 r ===> (=)) is_median is_median" unfolding is_median_def (*goal: ‹(r ===> list_all2 r ===> (=)) (λx xs. length (filter (λy. y < x) xs) ≤ length xs div 2 ∧ length (filter ((<) x) xs) ≤ length xs div 2) (λx xs. length (filter (λy. y < x) xs) ≤ length xs div 2 ∧ length (filter ((<) x) xs) ≤ length xs div 2)›*) by transfer_prover lemma list_all2_eq_fun_conv_map: "list_all2 (λx y. x = f y) xs ys ⟷ xs = map f ys" proof (standard) (*goals: 1. ‹list_all2 (λx y. x = f y) xs ys ⟹ xs = map f ys› 2. ‹xs = map f ys ⟹ list_all2 (λx y. x = f y) xs ys›*) assume "list_all2 (λx y. x = f y) xs ys" (*‹list_all2 (λ(x::'a) y::'b. x = (f::'b ⇒ 'a) y) (xs::'a list) (ys::'b list)›*) thus "xs = map f ys" apply induction (*goals: 1. ‹[] = map f []› 2. ‹⋀x xs y ys. ⟦x = f y; list_all2 (λx y. x = f y) xs ys; xs = map f ys⟧ ⟹ x # xs = map f (y # ys)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goal: ‹xs = map f ys ⟹ list_all2 (λx y. x = f y) xs ys›*) assume "xs = map f ys" (*‹(xs::'a list) = map (f::'b ⇒ 'a) (ys::'b list)›*) moreover have "list_all2 (λx y. x = f y) (map f ys) ys" apply (induction ys) (*goals: 1. ‹list_all2 (λ(x::'a) y::'b. x = (f::'b ⇒ 'a) y) (map f []) []› 2. ‹⋀(a::'b) ys::'b list. list_all2 (λ(x::'a) y::'b. x = (f::'b ⇒ 'a) y) (map f ys) ys ⟹ list_all2 (λ(x::'a) y::'b. x = f y) (map f (a # ys)) (a # ys)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately show "list_all2 (λx y. x = f y) xs ys" by simp qed lemma transfer_is_median_dual_ord [transfer_rule]: "(pcr_dual_ord (=) ===> list_all2 (pcr_dual_ord (=)) ===> (=)) is_median is_median" by (auto simp: pcr_dual_ord_def (*‹pcr_dual_ord ?T ≡ ?T OO cr_dual_ord›*) cr_dual_ord_def (*‹cr_dual_ord ≡ λx y. x = of_dual_ord y›*) OO_def (*‹?R OO ?S = (λx z. ∃y. ?R x y ∧ ?S y z)›*) rel_fun_def (*‹?A ===> ?B = (λf g. ∀x y. ?A x y ⟶ ?B (f x) (g y))›*) is_median_def (*‹is_median ?x ?xs = (length (filter (λy. y < ?x) ?xs) ≤ length ?xs div 2 ∧ length (filter ((<) ?x) ?xs) ≤ length ?xs div 2)›*) list_all2_eq_fun_conv_map (*‹list_all2 (λx y. x = ?f y) ?xs ?ys = (?xs = map ?f ?ys)›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) less_dual_ord.rep_eq (*‹(?x < ?xa) = (of_dual_ord ?xa < of_dual_ord ?x)›*)) end lemma is_median_to_dual_ord_iff [simp]: "is_median (to_dual_ord x) (map to_dual_ord xs) ⟷ is_median x xs" unfolding is_median_def (*goal: ‹(length (filter (λy::'a::linorder dual_ord. y < to_dual_ord (x::'a::linorder)) (map to_dual_ord (xs::'a::linorder list))) ≤ length (map to_dual_ord xs) div (2::nat) ∧ length (filter ((<) (to_dual_ord x)) (map to_dual_ord xs)) ≤ length (map to_dual_ord xs) div (2::nat)) = (length (filter (λy::'a::linorder. y < x) xs) ≤ length xs div (2::nat) ∧ length (filter ((<) x) xs) ≤ length xs div (2::nat))›*) apply transfer (*goal: ‹(length (filter (λy. y < to_dual_ord x) (map to_dual_ord xs)) ≤ length (map to_dual_ord xs) div 2 ∧ length (filter ((<) (to_dual_ord x)) (map to_dual_ord xs)) ≤ length (map to_dual_ord xs) div 2) = (length (filter (λy. y < x) xs) ≤ length xs div 2 ∧ length (filter ((<) x) xs) ≤ length xs div 2)›*) by auto text ‹ The following is an obviously equivalent definition of @{const is_median} in terms of multisets that is occasionally nicer to use. › lemma is_median_altdef: "is_median x xs ⟷ size (filter_mset (λy. y < x) (mset xs)) ≤ length xs div 2 ∧ size (filter_mset (λy. y > x) (mset xs)) ≤ length xs div 2" proof (-) (*goal: ‹is_median (x::'a) (xs::'a list) = (size {#y::'a ∈# mset xs. y < x#} ≤ length xs div (2::nat) ∧ size (filter_mset ((<) x) (mset xs)) ≤ length xs div (2::nat))›*) have "*": "length (filter P xs) = size (filter_mset P (mset xs))" for P and xs :: "'a list" by (simp flip: mset_filter (*‹mset (filter ?P ?xs) = filter_mset ?P (mset ?xs)›*)) show "?thesis" (*goal: ‹is_median x xs = (size {#y ∈# mset xs. y < x#} ≤ length xs div 2 ∧ size (filter_mset ((<) x) (mset xs)) ≤ length xs div 2)›*) by (simp only: is_median_def (*‹is_median (?x::?'a) (?xs::?'a list) = (length (filter (λy::?'a. y < ?x) ?xs) ≤ length ?xs div (2::nat) ∧ length (filter ((<) ?x) ?xs) ≤ length ?xs div (2::nat))›*) * (*‹length (filter (?P::'a ⇒ bool) (?xs::'a list)) = size (filter_mset ?P (mset ?xs))›*)) qed lemma is_median_cong: assumes "x = y" "mset xs = mset ys" shows "is_median x xs ⟷ is_median y ys" unfolding is_median_altdef (*goal: ‹(size {#y ∈# mset xs. y < x#} ≤ length xs div 2 ∧ size (filter_mset ((<) x) (mset xs)) ≤ length xs div 2) = (size {#ya ∈# mset ys. ya < y#} ≤ length ys div 2 ∧ size (filter_mset ((<) y) (mset ys)) ≤ length ys div 2)›*) by (simp only: assms (*‹(x::'a::linorder) = (y::'a::linorder)› ‹mset (xs::'a::linorder list) = mset (ys::'a::linorder list)›*) mset_eq_length[OF assms(2)] (*‹length (xs::'a::linorder list) = length (ys::'a::linorder list)›*)) text ‹ If an element is the median of a list of odd length, we can add any element to the list and the element is still a median. Conversely, if we want to compute a median of a list with even length $n$, we can simply drop one element and reduce the problem to a median of a list of size $n - 1$. › lemma is_median_Cons_odd: assumes "is_median x xs" and "odd (length xs)" shows "is_median x (y # xs)" using assms (*‹is_median (x::'a::linorder) (xs::'a::linorder list)› ‹odd (length xs)›*) by (auto simp: is_median_def (*‹is_median ?x ?xs = (length (filter (λy. y < ?x) ?xs) ≤ length ?xs div 2 ∧ length (filter ((<) ?x) ?xs) ≤ length ?xs div 2)›*)) text ‹ And, of course, \emph{the} median is a median. › lemma is_median_median [simp,intro]: "is_median (median xs) xs" using size_less_than_median[of xs] (*‹size {#y ∈# mset xs. y < median xs#} ≤ (length xs - 1) div 2›*) size_greater_than_median[of xs] (*‹size (filter_mset ((<) (median xs)) (mset xs)) ≤ length xs div 2›*) unfolding is_median_def size_mset[symmetric] mset_filter (*goal: ‹size {#y ∈# mset xs. y < median xs#} ≤ size (mset xs) div 2 ∧ size (filter_mset ((<) (median xs)) (mset xs)) ≤ size (mset xs) div 2›*) by linarith subsection ‹Properties of a median-of-medians› text ‹ We can now bound the number of list elements that can be strictly smaller than a median-of-medians of a chopped-up list (where each part has length $d$ except for the last one, which can also be shorter). The core argument is that at least roughly half of the medians of the sublists are greater or equal to the median-of-medians, and about $\frac{d}{2}$ elements in each such sublist are greater than or equal to their median and thereby also than the median-of-medians. › lemma size_less_than_median_of_medians_strong: fixes xs :: "'a :: linorder list" and d :: nat assumes d: "d > 0" assumes median: "⋀xs. xs ≠ [] ⟹ length xs ≤ d ⟹ is_median (med xs) xs" assumes median': "is_median x (map med (chop d xs))" defines "m ≡ length (chop d xs)" shows "size {#y ∈# mset xs. y < x#} ≤ m * (d div 2) + m div 2 * ((d + 1) div 2)" proof (-) (*goal: ‹size {#y ∈# mset xs. y < x#} ≤ m * (d div 2) + m div 2 * ((d + 1) div 2)›*) define n where [simp]: "n = length xs" define M where "M = mset (map med (chop d xs))" define YS where "YS = mset (chop d xs)" define YS1 where "YS1 = filter_mset (λys. med ys < x) (mset (chop d xs))" define YS2 where "YS2 = filter_mset (λys. ¬(med ys < x)) (mset (chop d xs))" have "size YS1 = size (image_mset med YS1)" by simp also (*calculation: ‹size YS1 = size (image_mset med YS1)›*) have "image_mset med YS1 = {#y ∈# mset (map med (chop d xs)). y < x#}" unfolding YS1_def (*goal: ‹image_mset med {#ys ∈# mset (chop d xs). med ys < x#} = {#y ∈# mset (map med (chop d xs)). y < x#}›*) apply (subst filter_mset_image_mset [symmetric] (*‹image_mset ?f {#x ∈# ?A. ?P (?f x)#} = filter_mset ?P (image_mset ?f ?A)›*)) (*goal: ‹image_mset med {#ys ∈# mset (chop d xs). med ys < x#} = {#y ∈# mset (map med (chop d xs)). y < x#}›*) by simp also (*calculation: ‹size YS1 = size {#y ∈# mset (map med (chop d xs)). y < x#}›*) have "size … ≤ (length (map med (chop d xs))) div 2" using median' (*‹is_median x (map med (chop d xs))›*) unfolding is_median_altdef (*goal: ‹size {#y ∈# mset (map med (chop d xs)). y < x#} ≤ length (map med (chop d xs)) div 2›*) by simp also (*calculation: ‹size YS1 ≤ length (map med (chop d xs)) div 2›*) have "… = m div 2" by (simp add: m_def (*‹m ≡ length (chop d xs)›*)) finally (*calculation: ‹size YS1 ≤ m div 2›*) have size_YS1: "size YS1 ≤ m div 2" . have "m = size (mset (chop d xs))" by (simp add: m_def (*‹m ≡ length (chop d xs)›*)) also (*calculation: ‹m = size (mset (chop d xs))›*) have "mset (chop d xs) = YS1 + YS2" unfolding YS1_def YS2_def (*goal: ‹mset (chop d xs) = {#ys ∈# mset (chop d xs). med ys < x#} + {#ys ∈# mset (chop d xs). ¬ med ys < x#}›*) by (rule multiset_partition (*‹?M = filter_mset ?P ?M + {#x ∈# ?M. ¬ ?P x#}›*)) finally (*calculation: ‹(m::nat) = size ((YS1::'a list multiset) + (YS2::'a list multiset))›*) have m_eq: "m = size YS1 + size YS2" by simp have "{# y ∈# mset xs. y < x#} = {# y ∈# (∑ys←chop d xs. mset ys). y < x#}" using d (*‹0 < d›*) apply (subst sum_msets_chop (*‹0 < ?n ⟹ sum_list (map mset (chop ?n ?xs)) = mset ?xs›*)) (*goals: 1. ‹0 < d ⟹ 0 < d› 2. ‹0 < d ⟹ {#y ∈# mset xs. y < x#} = {#y ∈# mset xs. y < x#}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹{#y ∈# mset xs. y < x#} = {#y ∈# sum_list (map mset (chop d xs)). y < x#}›*) have "… = (∑ys←chop d xs. {#y ∈# mset ys. y < x#})" apply (subst filter_mset_sum_list (*‹filter_mset ?P (sum_list ?xs) = sum_list (map (filter_mset ?P) ?xs)›*)) (*goal: ‹{#y::'a ∈# sum_list (map mset (chop (d::nat) (xs::'a list))). y < (x::'a)#} = (∑ys::'a list←chop d xs. {#y::'a ∈# mset ys. y < x#})›*) by (simp add: o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹{#y ∈# mset xs. y < x#} = (∑ys←chop d xs. {#y ∈# mset ys. y < x#})›*) have "… = (∑ys∈#YS. {#y ∈# mset ys. y < x#})" unfolding YS_def (*goal: ‹(∑ys::'a list←chop (d::nat) (xs::'a list). {#y::'a ∈# mset ys. y < (x::'a)#}) = (∑ys::'a list∈#mset (chop d xs). {#y::'a ∈# mset ys. y < x#})›*) apply (subst sum_mset_sum_list [symmetric] (*‹sum_list ?xs = ∑⇩# (mset ?xs)›*)) (*goal: ‹(∑ys←chop d xs. {#y ∈# mset ys. y < x#}) = (∑ys∈#mset (chop d xs). {#y ∈# mset ys. y < x#})›*) by simp also (*calculation: ‹{#y::'a ∈# mset (xs::'a list). y < (x::'a)#} = (∑ys::'a list∈#(YS::'a list multiset). {#y::'a ∈# mset ys. y < x#})›*) have "YS = YS1 + YS2" by (simp add: YS_def (*‹YS = mset (chop d xs)›*) YS1_def (*‹YS1 = {#ys ∈# mset (chop d xs). med ys < x#}›*) YS2_def (*‹YS2 = {#ys ∈# mset (chop d xs). ¬ med ys < x#}›*) not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*)) also (*calculation: ‹{#y ∈# mset xs. y < x#} = (∑ys∈#YS1 + YS2. {#y ∈# mset ys. y < x#})›*) have "(∑ys∈#…. {#y ∈# mset ys. y < x#}) = (∑ys∈#YS1. {#y ∈# mset ys. y < x#}) + (∑ys∈#YS2. {#y ∈# mset ys. y < x#})" by simp also (*calculation: ‹{#y ∈# mset xs. y < x#} = (∑ys∈#YS1. {#y ∈# mset ys. y < x#}) + (∑ys∈#YS2. {#y ∈# mset ys. y < x#})›*) have "… ⊆# (∑ys∈#YS1. mset ys) + (∑ys∈#YS2. {#y ∈# mset ys. y < med ys#})" apply (intro subset_mset.add_mono (*‹⟦?a ⊆# ?b; ?c ⊆# ?d⟧ ⟹ ?a + ?c ⊆# ?b + ?d›*) sum_mset_mset_mono (*‹(⋀x. x ∈# ?A ⟹ ?f x ⊆# ?g x) ⟹ ∑⇩# (image_mset ?f ?A) ⊆# ∑⇩# (image_mset ?g ?A)›*) mset_filter_mono (*‹⟦?A ⊆# ?B; ⋀x. ⟦x ∈# ?A; ?P x⟧ ⟹ ?Q x⟧ ⟹ filter_mset ?P ?A ⊆# filter_mset ?Q ?B›*)) (*goals: 1. ‹⋀ys. ys ∈# YS1 ⟹ {#y ∈# mset ys. y < x#} ⊆# mset ys› 2. ‹⋀ys. ys ∈# YS2 ⟹ mset ys ⊆# mset ys› 3. ‹⋀ys xa. ⟦ys ∈# YS2; xa ∈# mset ys; xa < x⟧ ⟹ xa < med ys› discuss goal 1*) apply ((auto simp: YS2_def (*‹(YS2::'a list multiset) = {#ys::'a list ∈# mset (chop (d::nat) (xs::'a list)). ¬ (med::'a list ⇒ 'a) ys < (x::'a)#}›*))[1]) (*discuss goal 2*) apply ((auto simp: YS2_def (*‹YS2 = {#ys ∈# mset (chop d xs). ¬ med ys < x#}›*))[1]) (*discuss goal 3*) apply ((auto simp: YS2_def (*‹YS2 = {#ys ∈# mset (chop d xs). ¬ med ys < x#}›*))[1]) (*proven 3 subgoals*) . finally (*calculation: ‹{#y ∈# mset xs. y < x#} ⊆# ∑⇩# (image_mset mset YS1) + (∑ys∈#YS2. {#y ∈# mset ys. y < med ys#})›*) have "{# y ∈# mset xs. y < x #} ⊆# …" . hence "size {# y ∈# mset xs. y < x #} ≤ size …" by (rule size_mset_mono (*‹?A ⊆# ?B ⟹ size ?A ≤ size ?B›*)) also (*calculation: ‹size {#y ∈# mset xs. y < x#} ≤ size (∑⇩# (image_mset mset YS1) + (∑ys∈#YS2. {#y ∈# mset ys. y < med ys#}))›*) have "… = (∑ys∈#YS1. length ys) + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})" by (simp add: size_mset_sum_mset_distrib (*‹size (∑⇩# ?A) = ∑⇩# (image_mset size ?A)›*) multiset.map_comp (*‹image_mset ?g (image_mset ?f ?v) = image_mset (?g ∘ ?f) ?v›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) also (*calculation: ‹size {#y::'a ∈# mset (xs::'a list). y < (x::'a)#} ≤ ∑⇩# (image_mset length (YS1::'a list multiset)) + (∑x::'a list∈#(YS2::'a list multiset). size {#y::'a ∈# mset x. y < (med::'a list ⇒ 'a) x#})›*) have "(∑ys∈#YS1. length ys) ≤ (∑ys∈#YS1. d)" apply (intro sum_mset_mono (*‹(⋀x::?'b. x ∈# (?A::?'b multiset) ⟹ (?f::?'b ⇒ ?'a) x ≤ (?g::?'b ⇒ ?'a) x) ⟹ ∑⇩# (image_mset ?f ?A) ≤ ∑⇩# (image_mset ?g ?A)›*)) (*goal: ‹∑⇩# (image_mset length YS1) ≤ (∑ys∈#YS1. d)›*) by (auto simp: YS1_def (*‹YS1 = {#ys ∈# mset (chop d xs). med ys < x#}›*) length_chop_part_le (*‹?ys ∈ set (chop ?n ?xs) ⟹ length ?ys ≤ ?n›*)) also (*calculation: ‹(⋀x y. x ≤ y ⟹ x + (∑x∈#YS2. size {#y ∈# mset x. y < med x#}) ≤ y + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})) ⟹ size {#y ∈# mset xs. y < x#} ≤ (∑ys∈#YS1. d) + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})›*) have "… = size YS1 * d" by simp also (*calculation: ‹(⋀x y. x ≤ y ⟹ x + (∑x∈#YS2. size {#y ∈# mset x. y < med x#}) ≤ y + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})) ⟹ size {#y ∈# mset xs. y < x#} ≤ size YS1 * d + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})›*) have d: "d = (d div 2) + ((d + 1) div 2)" using d (*‹0 < d›*) by linarith have "size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)" apply (subst d (*‹d = d div 2 + (d + 1) div 2›*)) (*goal: ‹size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*)) also (*calculation: ‹(⋀x y. x ≤ y ⟹ x + (∑x∈#YS2. size {#y ∈# mset x. y < med x#}) ≤ y + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})) ⟹ size {#y ∈# mset xs. y < x#} ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + (∑x∈#YS2. size {#y ∈# mset x. y < med x#})›*) have "(∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}) ≤ (∑ys∈#YS2. length ys div 2)" apply (intro sum_mset_mono (*‹(⋀x. x ∈# ?A ⟹ ?f x ≤ ?g x) ⟹ ∑⇩# (image_mset ?f ?A) ≤ ∑⇩# (image_mset ?g ?A)›*) size_less_than_median (*‹size {#y ∈# mset ?xs. y < median ?xs#} ≤ (length ?xs - 1) div 2›*)) (*goal: ‹(∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}) ≤ (∑ys∈#YS2. length ys div 2)›*) proof (goal_cases) (*goal: ‹⋀ys. ys ∈# YS2 ⟹ size {#y ∈# mset ys. y < med ys#} ≤ length ys div 2›*) case (1 ys) (*‹ys ∈# YS2›*) hence "ys ≠ []" "length ys ≤ d" apply - (*goals: 1. ‹ys ∈# YS2 ⟹ ys ≠ []› 2. ‹ys ∈# YS2 ⟹ length ys ≤ d› discuss goal 1*) apply ((auto simp: YS2_def (*‹YS2 = {#ys ∈# mset (chop d xs). ¬ med ys < x#}›*) length_chop_part_le (*‹?ys ∈ set (chop ?n ?xs) ⟹ length ?ys ≤ ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: YS2_def (*‹YS2 = {#ys ∈# mset (chop d xs). ¬ med ys < x#}›*) length_chop_part_le (*‹?ys ∈ set (chop ?n ?xs) ⟹ length ?ys ≤ ?n›*))[1]) (*proven 2 subgoals*) . from median[OF this] (*‹is_median (med ys) ys›*) show "?case" (*goal: ‹size {#y ∈# mset ys. y < med ys#} ≤ length ys div 2›*) by (auto simp: is_median_altdef (*‹is_median ?x ?xs = (size {#y ∈# mset ?xs. y < ?x#} ≤ length ?xs div 2 ∧ size (filter_mset ((<) ?x) (mset ?xs)) ≤ length ?xs div 2)›*)) qed also (*calculation: ‹⟦⋀ys y. ys ≤ y ⟹ ys + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}) ≤ y + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}); ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y⟧ ⟹ size {#y ∈# mset xs. y < x#} ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + (∑ys∈#YS2. length ys div 2)›*) have "… ≤ (∑ys∈#YS2. d div 2)" apply (intro sum_mset_mono (*‹(⋀x. x ∈# ?A ⟹ ?f x ≤ ?g x) ⟹ ∑⇩# (image_mset ?f ?A) ≤ ∑⇩# (image_mset ?g ?A)›*) div_le_mono (*‹?m ≤ ?n ⟹ ?m div ?k ≤ ?n div ?k›*) diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*)) (*goal: ‹(∑ys∈#YS2. length ys div 2) ≤ (∑ys∈#YS2. d div 2)›*) by (auto simp: YS2_def (*‹(YS2::'a list multiset) = {#ys::'a list ∈# mset (chop (d::nat) (xs::'a list)). ¬ (med::'a list ⇒ 'a) ys < (x::'a)#}›*) dest: length_chop_part_le (*‹(?ys::?'a list) ∈ set (chop (?n::nat) (?xs::?'a list)) ⟹ length ?ys ≤ ?n›*)) also (*calculation: ‹⟦⋀ys y. ys ≤ y ⟹ ys + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}) ≤ y + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}); ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y⟧ ⟹ size {#y ∈# mset xs. y < x#} ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + (∑ys∈#YS2. d div 2)›*) have "… = size YS2 * (d div 2)" by simp also (*calculation: ‹⟦⋀ys y. ys ≤ y ⟹ ys + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}) ≤ y + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}); ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y⟧ ⟹ size {#y ∈# mset xs. y < x#} ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2)›*) have "size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + … = m * (d div 2) + size YS1 * ((d + 1) div 2)" by (simp add: m_eq (*‹m = size YS1 + size YS2›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*)) also (*calculation: ‹⟦⋀ys y. ys ≤ y ⟹ ys + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}) ≤ y + (∑ys∈#YS2. size {#y ∈# mset ys. y < med ys#}); ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; ⋀x y. x ≤ y ⟹ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x ≤ size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y⟧ ⟹ size {#y ∈# mset xs. y < x#} ≤ m * (d div 2) + size YS1 * ((d + 1) div 2)›*) have "size YS1 * ((d + 1) div 2) ≤ (m div 2) * ((d + 1) div 2)" apply (intro mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) size_YS1 (*‹size YS1 ≤ m div 2›*)) (*goal: ‹size YS1 * ((d + 1) div 2) ≤ m div 2 * ((d + 1) div 2)›*) by auto finally (*calculation: ‹⟦⋀(ys::nat) y::nat. ys ≤ y ⟹ ys + (∑ys::'a::linorder list∈#(YS2::'a::linorder list multiset). size {#y::'a::linorder ∈# mset ys. y < (med::'a::linorder list ⇒ 'a::linorder) ys#}) ≤ y + (∑ys::'a::linorder list∈#YS2. size {#y::'a::linorder ∈# mset ys. y < med ys#}); ⋀(x::nat) y::nat. x ≤ y ⟹ size (YS1::'a::linorder list multiset) * ((d::nat) div (2::nat)) + size YS1 * ((d + (1::nat)) div (2::nat)) + x ≤ size YS1 * (d div (2::nat)) + size YS1 * ((d + (1::nat)) div (2::nat)) + y; ⋀(x::nat) y::nat. x ≤ y ⟹ size YS1 * (d div (2::nat)) + size YS1 * ((d + (1::nat)) div (2::nat)) + x ≤ size YS1 * (d div (2::nat)) + size YS1 * ((d + (1::nat)) div (2::nat)) + y; ⋀(x::nat) y::nat. x ≤ y ⟹ (m::nat) * (d div (2::nat)) + x ≤ m * (d div (2::nat)) + y⟧ ⟹ size {#y::'a::linorder ∈# mset (xs::'a::linorder list). y < (x::'a::linorder)#} ≤ m * (d div (2::nat)) + m div (2::nat) * ((d + (1::nat)) div (2::nat))›*) show "size {#y ∈# mset xs. y < x#} ≤ m * (d div 2) + m div 2 * ((d + 1) div 2)" by simp qed text ‹ We now focus on the case of an odd chopping size and make some further estimations to simplify the above result a little bit. › theorem size_less_than_median_of_medians: fixes xs :: "'a :: linorder list" and d :: nat assumes median: "⋀xs. xs ≠ [] ⟹ length xs ≤ Suc (2 * d) ⟹ is_median (med xs) xs" assumes median': "is_median x (map med (chop (Suc (2*d)) xs))" defines "n ≡ length xs" defines "c ≡ (3 * real d + 1) / (2 * (2 * d + 1))" shows "size {#y ∈# mset xs. y < x#} ≤ nat ⌈c * n⌉ + (5 * d) div 2 + 1" proof (cases "xs = []") (*goals: 1. ‹xs = [] ⟹ size {#y ∈# mset xs. y < x#} ≤ nat ⌈c * real n⌉ + 5 * d div 2 + 1› 2. ‹xs ≠ [] ⟹ size {#y ∈# mset xs. y < x#} ≤ nat ⌈c * real n⌉ + 5 * d div 2 + 1›*) case False (*‹xs ≠ []›*) define m where "m = length (chop (Suc (2*d)) xs)" have "real (m div 2) ≤ real (nat ⌈real n / (1 + 2 * real d)⌉) / 2" by (simp add: m_def (*‹m = length (chop (Suc (2 * d)) xs)›*) length_chop (*‹0 < ?n ⟹ length (chop ?n ?xs) = nat ⌈real (length ?xs) / real ?n⌉›*) n_def (*‹n ≡ length xs›*) flip: of_nat_int_ceiling (*‹0 ≤ ?x ⟹ of_nat (nat ⌈?x⌉) = of_int ⌈?x⌉›*)) also (*calculation: ‹real ((m::nat) div (2::nat)) ≤ real (nat ⌈real (n::nat) / ((1::real) + (2::real) * real (d::nat))⌉) / (2::real)›*) have "real (nat ⌈real n / (1 + 2 * real d)⌉) = of_int ⌈real n / (1 + 2 * real d)⌉" apply (intro of_nat_nat (*‹0 ≤ ?z ⟹ of_nat (nat ?z) = of_int ?z›*)) (*goal: ‹real (nat ⌈real n / (1 + 2 * real d)⌉) = real_of_int ⌈real n / (1 + 2 * real d)⌉›*) by (auto simp: divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) also (*calculation: ‹real (m div 2) ≤ real_of_int ⌈real n / (1 + 2 * real d)⌉ / 2›*) have "… / 2 ≤ (real n / (1 + 2 * real d) + 1) / 2" apply (intro divide_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a / ?c ≤ ?b / ?c›*)) (*goals: 1. ‹real_of_int ⌈real n / (1 + 2 * real d)⌉ ≤ real n / (1 + 2 * real d) + 1› 2. ‹0 ≤ 2› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*proven 2 subgoals*) . also (*calculation: ‹real (m div 2) ≤ (real n / (1 + 2 * real d) + 1) / 2›*) have "… = n / (2 * (2 * real d + 1)) + 1 / 2" by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*)) finally (*calculation: ‹real (m div 2) ≤ real n / (2 * (2 * real d + 1)) + 1 / 2›*) have m: "real (m div 2) ≤ …" . have "size {#y ∈# mset xs. y < x#} ≤ d * m + Suc d * (m div 2)" using size_less_than_median_of_medians_strong[of "Suc (2 * d)" med x xs] (*‹⟦0 < Suc (2 * d); ⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * d)⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (Suc (2 * d)) xs))⟧ ⟹ size {#y ∈# mset xs. y < x#} ≤ length (chop (Suc (2 * d)) xs) * (Suc (2 * d) div 2) + length (chop (Suc (2 * d)) xs) div 2 * ((Suc (2 * d) + 1) div 2)›*) assms (*‹⟦?xs ≠ []; length ?xs ≤ Suc (2 * d)⟧ ⟹ is_median (med ?xs) ?xs› ‹is_median x (map med (chop (Suc (2 * d)) xs))› ‹n ≡ length xs› ‹c::real ≡ ((3::real) * real (d::nat) + (1::real)) / real ((2::nat) * ((2::nat) * d + (1::nat)))›*) unfolding m_def (*goal: ‹size {#y ∈# mset xs. y < x#} ≤ d * length (chop (Suc (2 * d)) xs) + Suc d * (length (chop (Suc (2 * d)) xs) div 2)›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*)) also (*calculation: ‹size {#y::'a ∈# mset (xs::'a list). y < (x::'a)#} ≤ (d::nat) * (m::nat) + Suc d * (m div (2::nat))›*) have "… ≤ d * (2 * (m div 2) + 1) + Suc d * (m div 2)" apply (intro add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) (*goals: 1. ‹m ≤ 2 * (m div 2) + 1› 2. ‹0 ≤ d› 3. ‹m div 2 ≤ m div 2› 4. ‹0 ≤ Suc d› discuss goal 1*) apply linarith (*discuss goal 2*) apply linarith (*discuss goal 3*) apply linarith (*discuss goal 4*) apply linarith (*proven 4 subgoals*) . also (*calculation: ‹size {#y ∈# mset xs. y < x#} ≤ d * (2 * (m div 2) + 1) + Suc d * (m div 2)›*) have "… = (3 * d + 1) * (m div 2) + d" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*)) finally (*calculation: ‹size {#y ∈# mset xs. y < x#} ≤ (3 * d + 1) * (m div 2) + d›*) have "real (size {#y ∈# mset xs. y < x#}) ≤ real …" by (subst of_nat_le_iff (*‹(of_nat ?m ≤ of_nat ?n) = (?m ≤ ?n)›*)) also (*calculation: ‹real (size {#y ∈# mset xs. y < x#}) ≤ real ((3 * d + 1) * (m div 2) + d)›*) have "… ≤ (3 * real d + 1) * (n / (2 * (2 * d + 1)) + 1/2) + real d" unfolding of_nat_add of_nat_mult of_nat_1 of_nat_numeral (*goal: ‹(3 * real d + 1) * real (m div 2) + real d ≤ (3 * real d + 1) * (real n / (2 * (2 * real d + 1)) + 1 / 2) + real d›*) apply (intro add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) order.refl (*‹?a ≤ ?a›*) m (*‹real (m div 2) ≤ real n / (2 * (2 * real d + 1)) + 1 / 2›*)) (*goals: 1. ‹0 ≤ 3› 2. ‹0 ≤ real d› 3. ‹0 ≤ 3 * real d + 1› 4. ‹0 ≤ real (m div 2)› discuss goal 1*) apply ((auto simp: m_def (*‹m = length (chop (Suc (2 * d)) xs)›*) length_chop (*‹0 < ?n ⟹ length (chop ?n ?xs) = nat ⌈real (length ?xs) / real ?n⌉›*) n_def (*‹n ≡ length xs›*) add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*))[1]) (*discuss goal 2*) apply ((auto simp: m_def (*‹m = length (chop (Suc (2 * d)) xs)›*) length_chop (*‹0 < ?n ⟹ length (chop ?n ?xs) = nat ⌈real (length ?xs) / real ?n⌉›*) n_def (*‹n ≡ length xs›*) add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*))[1]) (*discuss goal 3*) apply ((auto simp: m_def (*‹m = length (chop (Suc (2 * d)) xs)›*) length_chop (*‹0 < ?n ⟹ length (chop ?n ?xs) = nat ⌈real (length ?xs) / real ?n⌉›*) n_def (*‹n ≡ length xs›*) add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*))[1]) (*discuss goal 4*) apply ((auto simp: m_def (*‹(m::nat) = length (chop (Suc ((2::nat) * (d::nat))) (xs::'a list))›*) length_chop (*‹(0::nat) < (?n::nat) ⟹ length (chop ?n (?xs::?'a list)) = nat ⌈real (length ?xs) / real ?n⌉›*) n_def (*‹n::nat ≡ length (xs::'a list)›*) add_ac (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)›*))[1]) (*proven 4 subgoals*) . also (*calculation: ‹real (size {#y::'a::linorder ∈# mset (xs::'a::linorder list). y < (x::'a::linorder)#}) ≤ ((3::real) * real (d::nat) + (1::real)) * (real (n::nat) / real ((2::nat) * ((2::nat) * d + (1::nat))) + (1::real) / (2::real)) + real d›*) have "… = c * real n + (5 * real d + 1) / 2" by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*) c_def (*‹c ≡ (3 * real d + 1) / real (2 * (2 * d + 1))›*)) also (*calculation: ‹real (size {#y ∈# mset xs. y < x#}) ≤ c * real n + (5 * real d + 1) / 2›*) have "… ≤ real (nat ⌈c * n⌉ + ((5 * d) div 2 + 1))" unfolding of_nat_add (*goal: ‹c * real n + (5 * real d + 1) / 2 ≤ real (nat ⌈c * real n⌉) + (real (5 * d div 2) + real 1)›*) apply (intro add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*)) (*goals: 1. ‹c * real n ≤ real (nat ⌈c * real n⌉)› 2. ‹(5 * real d + 1) / 2 ≤ real (5 * d div 2) + real 1› discuss goal 1*) apply linarith (*discuss goal 2*) apply (simp add: field_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(?a::?'a::cancel_ab_semigroup_add) - (?b::?'a::cancel_ab_semigroup_add) - (?c::?'a::cancel_ab_semigroup_add) = ?a - (?b + ?c)› ‹(?a::?'a::group_add) + ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?b - ?c› ‹((?a::?'a::group_add) - (?b::?'a::group_add) = (?c::?'a::group_add)) = (?a = ?c + ?b)› ‹((?a::?'a::group_add) = (?c::?'a::group_add) - (?b::?'a::group_add)) = (?a + ?b = ?c)› ‹(?a::?'a::group_add) - ((?b::?'a::group_add) - (?c::?'a::group_add)) = ?a + ?c - ?b› ‹(?a::?'a::ab_group_add) - (?b::?'a::ab_group_add) + (?c::?'a::ab_group_add) = ?a + ?c - ?b› and more 69 facts*)) (*proven 2 subgoals*) . finally (*calculation: ‹real (size {#y ∈# mset xs. y < x#}) ≤ real (nat ⌈c * real n⌉ + (5 * d div 2 + 1))›*) show "?thesis" (*goal: ‹size {#y::'a ∈# mset (xs::'a list). y < (x::'a)#} ≤ nat ⌈(c::real) * real (n::nat)⌉ + (5::nat) * (d::nat) div (2::nat) + (1::nat)›*) apply (subst (asm) of_nat_le_iff (*‹(of_nat ?m ≤ of_nat ?n) = (?m ≤ ?n)›*)) (*goal: ‹size {#y ∈# mset xs. y < x#} ≤ nat ⌈c * real n⌉ + 5 * d div 2 + 1›*) by (simp add: add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*)) qed (auto) (*solved the remaining goal: ‹xs = [] ⟹ size {#y ∈# mset xs. y < x#} ≤ nat ⌈c * real n⌉ + 5 * d div 2 + 1›*) text ‹ We get the analogous result for the number of elements that are greater than a median-of-medians by looking at the dual order and using the \emph{transfer} method. › theorem size_greater_than_median_of_medians: fixes xs :: "'a :: linorder list" and d :: nat assumes median: "⋀xs. xs ≠ [] ⟹ length xs ≤ Suc (2 * d) ⟹ is_median (med xs) xs" assumes median': "is_median x (map med (chop (Suc (2*d)) xs))" defines "n ≡ length xs" defines "c ≡ (3 * real d + 1) / (2 * (2 * d + 1))" shows "size {#y ∈# mset xs. y > x#} ≤ nat ⌈c * n⌉ + (5 * d) div 2 + 1" proof (-) (*goal: ‹size (filter_mset ((<) x) (mset xs)) ≤ nat ⌈c * real n⌉ + 5 * d div 2 + 1›*) include lifting_syntax define med' where "med' = (λxs. to_dual_ord (med (map of_dual_ord xs)))" have "xs = map of_dual_ord ys" if "list_all2 cr_dual_ord xs ys" for xs :: "'a list" and ys using that (*‹list_all2 cr_dual_ord xs ys›*) apply induction (*goals: 1. ‹[] = map of_dual_ord []› 2. ‹⋀x xs y ys. ⟦cr_dual_ord x y; list_all2 cr_dual_ord xs ys; xs = map of_dual_ord ys⟧ ⟹ x # xs = map of_dual_ord (y # ys)› discuss goal 1*) apply ((auto simp: cr_dual_ord_def (*‹cr_dual_ord ≡ λx y. x = of_dual_ord y›*))[1]) (*discuss goal 2*) apply ((auto simp: cr_dual_ord_def (*‹cr_dual_ord ≡ λx y. x = of_dual_ord y›*))[1]) (*proven 2 subgoals*) . hence [transfer_rule]: "(list_all2 (pcr_dual_ord (=)) ===> pcr_dual_ord (=)) med med'" by (auto simp: rel_fun_def (*‹?A ===> ?B = (λf g. ∀x y. ?A x y ⟶ ?B (f x) (g y))›*) pcr_dual_ord_def (*‹pcr_dual_ord ?T ≡ ?T OO cr_dual_ord›*) OO_def (*‹?R OO ?S = (λx z. ∃y. ?R x y ∧ ?S y z)›*) med'_def (*‹med' = (λxs. to_dual_ord (med (map of_dual_ord xs)))›*) cr_dual_ord_def (*‹cr_dual_ord ≡ λx y. x = of_dual_ord y›*) dual_ord.to_dual_ord_inverse (*‹?y ∈ UNIV ⟹ of_dual_ord (to_dual_ord ?y) = ?y›*)) have "size {#y ∈# mset xs. y > x#} = length (filter (λy. y > x) xs)" apply (subst size_mset [symmetric] (*‹length ?xs = size (mset ?xs)›*)) (*goal: ‹size (filter_mset ((<) x) (mset xs)) = length (filter ((<) x) xs)›*) by (simp only: mset_filter (*‹mset (filter (?P::?'a ⇒ bool) (?xs::?'a list)) = filter_mset ?P (mset ?xs)›*)) also (*calculation: ‹size (filter_mset ((<) x) (mset xs)) = length (filter ((<) x) xs)›*) have "… = length (map to_dual_ord (filter (λy. y > x) xs))" by simp also (*calculation: ‹size (filter_mset ((<) (x::'a)) (mset (xs::'a list))) = length (map to_dual_ord (filter ((<) x) xs))›*) have "(λy. y > x) = (λy. to_dual_ord y < to_dual_ord x)" apply transfer (*goal: ‹(<) x = (λy. to_dual_ord y < to_dual_ord x)›*) by simp hence "length (map to_dual_ord (filter (λy. y > x) xs)) = length (map to_dual_ord (filter … xs))" by simp also (*calculation: ‹size (filter_mset ((<) x) (mset xs)) = length (map to_dual_ord (filter (λy. to_dual_ord y < to_dual_ord x) xs))›*) have "… = length (filter (λy. y < to_dual_ord x) (map to_dual_ord xs))" unfolding filter_map o_def (*goal: ‹length (map to_dual_ord (filter (λy. to_dual_ord y < to_dual_ord x) xs)) = length (map to_dual_ord (filter (λxa. to_dual_ord xa < to_dual_ord x) xs))›*) by simp also (*calculation: ‹size (filter_mset ((<) (x::'a)) (mset (xs::'a list))) = length (filter (λy::'a dual_ord. y < to_dual_ord x) (map to_dual_ord xs))›*) have "… = size {#y ∈# mset (map to_dual_ord xs). y < to_dual_ord x#}" apply (subst size_mset [symmetric] (*‹length ?xs = size (mset ?xs)›*)) (*goal: ‹length (filter (λy. y < to_dual_ord x) (map to_dual_ord xs)) = size {#y ∈# mset (map to_dual_ord xs). y < to_dual_ord x#}›*) by (simp only: mset_filter (*‹mset (filter ?P ?xs) = filter_mset ?P (mset ?xs)›*)) also (*calculation: ‹size (filter_mset ((<) x) (mset xs)) = size {#y ∈# mset (map to_dual_ord xs). y < to_dual_ord x#}›*) have "… ≤ nat ⌈(3 * real d + 1) / real (2 * (2 * d + 1)) * length (map to_dual_ord xs)⌉ + 5 * d div 2 + 1" proof (intro size_less_than_median_of_medians (*‹⟦⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * ?d)⟧ ⟹ is_median (?med xs) xs; is_median ?x (map ?med (chop (Suc (2 * ?d)) ?xs))⟧ ⟹ size {#y ∈# mset ?xs. y < ?x#} ≤ nat ⌈(3 * real ?d + 1) / real (2 * (2 * ?d + 1)) * real (length ?xs)⌉ + 5 * ?d div 2 + 1›*)) (*goals: 1. ‹⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * d)⟧ ⟹ is_median (?med xs) xs› 2. ‹is_median (to_dual_ord x) (map ?med (chop (Suc (2 * d)) (map to_dual_ord xs)))›*) fix xs :: "'a dual_ord list" assume xs: "xs ≠ []" "length xs ≤ Suc (2 * d)" (*‹(xs::'a dual_ord list) ≠ []› ‹length (xs::'a dual_ord list) ≤ Suc ((2::nat) * (d::nat))›*) from xs (*‹xs ≠ []› ‹length xs ≤ Suc (2 * d)›*) show "is_median (med' xs) xs" apply (transfer fixing: d) (*goal: ‹is_median (med' xs) xs›*) apply (rule median (*‹⟦(?xs::'a list) ≠ []; length ?xs ≤ Suc ((2::nat) * (d::nat))⟧ ⟹ is_median ((med::'a list ⇒ 'a) ?xs) ?xs›*)) (*goals: 1. ‹⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * d)⟧ ⟹ xs ≠ []› 2. ‹⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * d)⟧ ⟹ length xs ≤ Suc (2 * d)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) next (*goal: ‹is_median (to_dual_ord x) (map med' (chop (Suc (2 * d)) (map to_dual_ord xs)))›*) show "is_median (to_dual_ord x) (map med' (chop (Suc (2 * d)) (map to_dual_ord xs)))" apply (transfer fixing: d x xs) (*goal: ‹is_median (to_dual_ord (x::'a)) (map (med'::'a dual_ord list ⇒ 'a dual_ord) (chop (Suc ((2::nat) * (d::nat))) (map to_dual_ord (xs::'a list))))›*) by (use median' in simp_all) qed finally (*calculation: ‹size (filter_mset ((<) (x::'a)) (mset (xs::'a list))) ≤ nat ⌈((3::real) * real (d::nat) + (1::real)) / real ((2::nat) * ((2::nat) * d + (1::nat))) * real (length (map to_dual_ord xs))⌉ + (5::nat) * d div (2::nat) + (1::nat)›*) show "?thesis" (*goal: ‹size (filter_mset ((<) (x::'a)) (mset (xs::'a list))) ≤ nat ⌈(c::real) * real (n::nat)⌉ + (5::nat) * (d::nat) div (2::nat) + (1::nat)›*) by (simp add: n_def (*‹n ≡ length xs›*) c_def (*‹c ≡ (3 * real d + 1) / real (2 * (2 * d + 1))›*)) qed text ‹ The most important case is that of chopping size 5, since that is the most practical one for the median-of-medians selection algorithm. For it, we obtain the following nice and simple bounds: › corollary size_less_greater_median_of_medians_5: fixes xs :: "'a :: linorder list" assumes "⋀xs. xs ≠ [] ⟹ length xs ≤ 5 ⟹ is_median (med xs) xs" assumes "is_median x (map med (chop 5 xs))" shows "length (filter (λy. y < x) xs) ≤ nat ⌈0.7 * length xs⌉ + 6" and "length (filter (λy. y > x) xs) ≤ nat ⌈0.7 * length xs⌉ + 6" using size_less_than_median_of_medians[of 2 med x xs] (*‹⟦⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * 2)⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (Suc (2 * 2)) xs))⟧ ⟹ size {#y ∈# mset xs. y < x#} ≤ nat ⌈(3 * real 2 + 1) / real (2 * (2 * 2 + 1)) * real (length xs)⌉ + 5 * 2 div 2 + 1›*) size_greater_than_median_of_medians[of 2 med x xs] (*‹⟦⋀xs. ⟦xs ≠ []; length xs ≤ Suc (2 * 2)⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (Suc (2 * 2)) xs))⟧ ⟹ size (filter_mset ((<) x) (mset xs)) ≤ nat ⌈(3 * real 2 + 1) / real (2 * (2 * 2 + 1)) * real (length xs)⌉ + 5 * 2 div 2 + 1›*) assms (*‹⟦(?xs::'a list) ≠ []; length ?xs ≤ (5::nat)⟧ ⟹ is_median ((med::'a list ⇒ 'a) ?xs) ?xs› ‹is_median x (map med (chop 5 xs))›*) apply - (*goals: 1. ‹⟦⟦⋀xs::'a list. ⟦xs ≠ []; length xs ≤ Suc ((2::nat) * (2::nat))⟧ ⟹ is_median ((med::'a list ⇒ 'a) xs) xs; is_median (x::'a) (map med (chop (Suc ((2::nat) * (2::nat))) (xs::'a list)))⟧ ⟹ size {#y::'a ∈# mset xs. y < x#} ≤ nat ⌈((3::real) * real (2::nat) + (1::real)) / real ((2::nat) * ((2::nat) * (2::nat) + (1::nat))) * real (length xs)⌉ + (5::nat) * (2::nat) div (2::nat) + (1::nat); ⟦⋀xs::'a list. ⟦xs ≠ []; length xs ≤ Suc ((2::nat) * (2::nat))⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (Suc ((2::nat) * (2::nat))) xs))⟧ ⟹ size (filter_mset ((<) x) (mset xs)) ≤ nat ⌈((3::real) * real (2::nat) + (1::real)) / real ((2::nat) * ((2::nat) * (2::nat) + (1::nat))) * real (length xs)⌉ + (5::nat) * (2::nat) div (2::nat) + (1::nat); ⋀xs::'a list. ⟦xs ≠ []; length xs ≤ (5::nat)⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (5::nat) xs))⟧ ⟹ length (filter (λy::'a. y < x) xs) ≤ nat ⌈(7::real) / (10::real) * real (length xs)⌉ + (6::nat)› 2. ‹⟦⟦⋀xs::'a list. ⟦xs ≠ []; length xs ≤ Suc ((2::nat) * (2::nat))⟧ ⟹ is_median ((med::'a list ⇒ 'a) xs) xs; is_median (x::'a) (map med (chop (Suc ((2::nat) * (2::nat))) (xs::'a list)))⟧ ⟹ size {#y::'a ∈# mset xs. y < x#} ≤ nat ⌈((3::real) * real (2::nat) + (1::real)) / real ((2::nat) * ((2::nat) * (2::nat) + (1::nat))) * real (length xs)⌉ + (5::nat) * (2::nat) div (2::nat) + (1::nat); ⟦⋀xs::'a list. ⟦xs ≠ []; length xs ≤ Suc ((2::nat) * (2::nat))⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (Suc ((2::nat) * (2::nat))) xs))⟧ ⟹ size (filter_mset ((<) x) (mset xs)) ≤ nat ⌈((3::real) * real (2::nat) + (1::real)) / real ((2::nat) * ((2::nat) * (2::nat) + (1::nat))) * real (length xs)⌉ + (5::nat) * (2::nat) div (2::nat) + (1::nat); ⋀xs::'a list. ⟦xs ≠ []; length xs ≤ (5::nat)⟧ ⟹ is_median (med xs) xs; is_median x (map med (chop (5::nat) xs))⟧ ⟹ length (filter ((<) x) xs) ≤ nat ⌈(7::real) / (10::real) * real (length xs)⌉ + (6::nat)› discuss goal 1*) apply (simp add: size_mset [symmetric] (*‹length ?xs = size (mset ?xs)›*) mset_filter (*‹mset (filter ?P ?xs) = filter_mset ?P (mset ?xs)›*) mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*) add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*) del: size_mset (*‹size (mset ?xs) = length ?xs›*)) (*discuss goal 2*) apply (simp add: size_mset [symmetric] (*‹length ?xs = size (mset ?xs)›*) mset_filter (*‹mset (filter ?P ?xs) = filter_mset ?P (mset ?xs)›*) mult_ac (*‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)›*) add_ac (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)›*) del: size_mset (*‹size (mset ?xs) = length ?xs›*)) (*proven 2 subgoals*) . subsection ‹The recursive step› text ‹ We now turn to the actual selection algorithm itself. The following simple reduction lemma illustrates the idea of the algorithm quite well already, but it has the disadvantage that, if one were to use it as a recursive algorithm, it would only work for lists with distinct elements. If the list contains repeated elements, this may not even terminate. The basic idea is that we choose some pivot element, partition the list into elements that are bigger than the pivot and those that are not, and then recurse into one of these (hopefully smaller) lists. › theorem select_rec_partition: assumes "d > 0" "k < length xs" shows "select k xs = ( let (ys, zs) = partition (λy. y ≤ x) xs in if k < length ys then select k ys else select (k - length ys) zs )" (is "_ = ?rhs") proof (-) (*goal: ‹select k xs = (let (ys, zs) = partition (λy. y ≤ x) xs in if k < length ys then select k ys else select (k - length ys) zs)›*) define ys and zs where "ys = filter (λy. y ≤ x) xs" and "zs = filter (λy. ¬(y ≤ x)) xs" have "select k xs = select k (ys @ zs)" apply (intro select_cong (*‹⟦(?k::nat) = (?k'::nat); mset (?xs::?'a list) = mset (?xs'::?'a list)⟧ ⟹ select ?k ?xs = select ?k' ?xs'›*)) (*goals: 1. ‹k = k› 2. ‹mset xs = mset (ys @ zs)› discuss goal 1*) apply (simp add: ys_def (*‹ys = filter (λy. y ≤ x) xs›*) zs_def (*‹zs = filter (λy. ¬ y ≤ x) xs›*)) (*discuss goal 2*) apply (simp add: ys_def (*‹(ys::'b list) = filter (λy::'b. y ≤ (x::'b)) (xs::'b list)›*) zs_def (*‹(zs::'b list) = filter (λy::'b. ¬ y ≤ (x::'b)) (xs::'b list)›*)) (*proven 2 subgoals*) . also (*calculation: ‹select k xs = select k (ys @ zs)›*) have "… = (if k < length ys then select k ys else select (k - length ys) zs)" using assms(2) (*‹k < length xs›*) apply (intro select_append' (*‹⟦⋀y z. ⟦y ∈ set ?ys; z ∈ set ?zs⟧ ⟹ y ≤ z; ?k < length ?ys + length ?zs⟧ ⟹ select ?k (?ys @ ?zs) = (if ?k < length ?ys then select ?k ?ys else select (?k - length ?ys) ?zs)›*)) (*goals: 1. ‹⋀y z. ⟦k < length xs; y ∈ set ys; z ∈ set zs⟧ ⟹ y ≤ z› 2. ‹k < length xs ⟹ k < length ys + length zs› discuss goal 1*) apply ((auto simp: ys_def (*‹ys = filter (λy. y ≤ x) xs›*) zs_def (*‹zs = filter (λy. ¬ y ≤ x) xs›*) sum_length_filter_compl (*‹length (filter ?P ?xs) + length (filter (λx. ¬ ?P x) ?xs) = length ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp: ys_def (*‹ys = filter (λy. y ≤ x) xs›*) zs_def (*‹zs = filter (λy. ¬ y ≤ x) xs›*) sum_length_filter_compl (*‹length (filter ?P ?xs) + length (filter (λx. ¬ ?P x) ?xs) = length ?xs›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹select (k::nat) (xs::'b list) = (if k < length (ys::'b list) then select k ys else select (k - length ys) (zs::'b list))›*) show "?thesis" (*goal: ‹select k xs = (let (ys, zs) = partition (λy. y ≤ x) xs in if k < length ys then select k ys else select (k - length ys) zs)›*) by (simp add: ys_def (*‹ys = filter (λy. y ≤ x) xs›*) zs_def (*‹zs = filter (λy. ¬ y ≤ x) xs›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*)) qed text ‹ The following variant uses a three-way partitioning function instead. This way, the size of the list in the final recursive call decreases by a factor of at least $\frac{3d'+1}{2(2d'+1)}$ by the previous estimates, given that the chopping size is $d = 2d'+1$. For a chopping size of 5, we get a factor of $0.7$. › definition threeway_partition :: "'a ⇒ 'a :: linorder list ⇒ 'a list × 'a list × 'a list" where "threeway_partition x xs = (filter (λy. y < x) xs, filter (λy. y = x) xs, filter (λy. y > x) xs)" lemma threeway_partition_code [code]: "threeway_partition x [] = ([], [], [])" "threeway_partition x (y # ys) = (case threeway_partition x ys of (ls, es, gs) ⇒ if y < x then (y # ls, es, gs) else if x = y then (ls, y # es, gs) else (ls, es, y # gs))" (*goals: 1. ‹threeway_partition x [] = ([], [], [])› 2. ‹threeway_partition x (y # ys) = (case threeway_partition x ys of (ls, es, gs) ⇒ if y < x then (y # ls, es, gs) else if x = y then (ls, y # es, gs) else (ls, es, y # gs))› discuss goal 1*) apply ((auto simp: threeway_partition_def (*‹threeway_partition (?x::?'a::linorder) (?xs::?'a::linorder list) = (filter (λy::?'a::linorder. y < ?x) ?xs, filter (λy::?'a::linorder. y = ?x) ?xs, filter ((<) ?x) ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*))[1]) (*proven 2 subgoals*) . theorem select_rec_threeway_partition: assumes "d > 0" "k < length xs" shows "select k xs = ( let (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = length es in if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs )" (is "_ = ?rhs") proof (-) (*goal: ‹select k xs = (let (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = length es in if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) define ls and es and gs where "ls = filter (λy. y < x) xs" and "es = filter (λy. y = x) xs" and "gs = filter (λy. y > x) xs" define nl and ne where [simp]: "nl = length ls" "ne = length es" have mset_eq: "mset xs = mset ls + mset es + mset gs" unfolding ls_def es_def gs_def (*goal: ‹mset xs = mset (filter (λy. y < x) xs) + mset (filter (λy. y = x) xs) + mset (filter ((<) x) xs)›*) apply (induction xs) (*goals: 1. ‹mset [] = mset (filter (λy. y < x) []) + mset (filter (λy. y = x) []) + mset (filter ((<) x) [])› 2. ‹⋀a xs. mset xs = mset (filter (λy. y < x) xs) + mset (filter (λy. y = x) xs) + mset (filter ((<) x) xs) ⟹ mset (a # xs) = mset (filter (λy. y < x) (a # xs)) + mset (filter (λy. y = x) (a # xs)) + mset (filter ((<) x) (a # xs))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have length_eq: "length xs = length ls + length es + length gs" unfolding ls_def es_def gs_def (*goal: ‹length (xs::'b list) = length (filter (λy::'b. y < (x::'b)) xs) + length (filter (λy::'b. y = x) xs) + length (filter ((<) x) xs)›*) apply (induction xs) (*goals: 1. ‹length [] = length (filter (λy. y < x) []) + length (filter (λy. y = x) []) + length (filter ((<) x) [])› 2. ‹⋀a xs. length xs = length (filter (λy. y < x) xs) + length (filter (λy. y = x) xs) + length (filter ((<) x) xs) ⟹ length (a # xs) = length (filter (λy. y < x) (a # xs)) + length (filter (λy. y = x) (a # xs)) + length (filter ((<) x) (a # xs))› discuss goal 1*) apply ((auto simp del: filter_True (*‹∀x::?'a::type∈set (?xs::?'a::type list). (?P::?'a::type ⇒ bool) x ⟹ filter ?P ?xs = ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp del: filter_True (*‹∀x::?'a::type∈set (?xs::?'a::type list). (?P::?'a::type ⇒ bool) x ⟹ filter ?P ?xs = ?xs›*))[1]) (*proven 2 subgoals*) . have [simp]: "select i es = x" if "i < length es" for i proof (-) (*goal: ‹select i es = x›*) have "select i es ∈ set (sort es)" unfolding select_def (*goal: ‹sort (es::'b list) ! (i::nat) ∈ set (sort es)›*) using that (*‹i < length es›*) apply (intro nth_mem (*‹(?n::nat) < length (?xs::?'a list) ⟹ ?xs ! ?n ∈ set ?xs›*)) (*goal: ‹sort es ! i ∈ set (sort es)›*) by auto hence "select i es ∈ set es" using that (*‹(i::nat) < length (es::'b::linorder list)›*) by (auto simp: select_def (*‹select ?k ?xs = sort ?xs ! ?k›*)) also (*calculation: ‹select (i::nat) (es::'b list) ∈ set es›*) have "set es ⊆ {x}" unfolding es_def (*goal: ‹set (filter (λy. y = x) xs) ⊆ {x}›*) apply (induction es) (*goals: 1. ‹set (filter (λy. y = x) xs) ⊆ {x}› 2. ‹⋀a es. set (filter (λy. y = x) xs) ⊆ {x} ⟹ set (filter (λy. y = x) xs) ⊆ {x}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹select (i::nat) (es::'b list) ∈ {x::'b}›*) show "?thesis" (*goal: ‹select i es = x›*) by simp qed have "select k xs = select k (ls @ (es @ gs))" apply (intro select_cong (*‹⟦?k = ?k'; mset ?xs = mset ?xs'⟧ ⟹ select ?k ?xs = select ?k' ?xs'›*)) (*goals: 1. ‹k = k› 2. ‹mset xs = mset (ls @ es @ gs)› discuss goal 1*) apply (simp add: mset_eq (*‹mset xs = mset ls + mset es + mset gs›*)) (*discuss goal 2*) apply (simp add: mset_eq (*‹mset xs = mset ls + mset es + mset gs›*)) (*proven 2 subgoals*) . also (*calculation: ‹select k xs = select k (ls @ es @ gs)›*) have "… = (if k < nl then select k ls else select (k - nl) (es @ gs))" unfolding nl_ne_def (*goal: ‹select k (ls @ es @ gs) = (if k < length ls then select k ls else select (k - length ls) (es @ gs))›*) using assms (*‹(0::'a::{zero,ord}) < (d::'a::{zero,ord})› ‹k < length xs›*) apply (intro select_append' (*‹⟦⋀y z. ⟦y ∈ set ?ys; z ∈ set ?zs⟧ ⟹ y ≤ z; ?k < length ?ys + length ?zs⟧ ⟹ select ?k (?ys @ ?zs) = (if ?k < length ?ys then select ?k ?ys else select (?k - length ?ys) ?zs)›*)) (*goals: 1. ‹⋀y z. ⟦0 < d; k < length xs; y ∈ set ls; z ∈ set (es @ gs)⟧ ⟹ y ≤ z› 2. ‹⟦0 < d; k < length xs⟧ ⟹ k < length ls + length (es @ gs)› discuss goal 1*) apply ((auto simp: ls_def (*‹(ls::'b list) = filter (λy::'b. y < (x::'b)) (xs::'b list)›*) es_def (*‹(es::'b list) = filter (λy::'b. y = (x::'b)) (xs::'b list)›*) gs_def (*‹(gs::'b list) = filter ((<) (x::'b)) (xs::'b list)›*) length_eq (*‹length (xs::'b list) = length (ls::'b list) + length (es::'b list) + length (gs::'b list)›*))[1]) (*discuss goal 2*) apply ((auto simp: ls_def (*‹(ls::'b list) = filter (λy::'b. y < (x::'b)) (xs::'b list)›*) es_def (*‹(es::'b list) = filter (λy::'b. y = (x::'b)) (xs::'b list)›*) gs_def (*‹(gs::'b list) = filter ((<) (x::'b)) (xs::'b list)›*) length_eq (*‹length (xs::'b list) = length (ls::'b list) + length (es::'b list) + length (gs::'b list)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹select k xs = (if k < nl then select k ls else select (k - nl) (es @ gs))›*) have "… = (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)" (is "?lhs' = ?rhs'") proof (cases "k < nl") (*goals: 1. ‹(k::nat) < (nl::nat) ⟹ (if k < nl then select k (ls::'b list) else select (k - nl) ((es::'b list) @ (gs::'b list))) = (if k < nl then select k ls else if k < nl + (ne::nat) then x::'b else select (k - nl - ne) gs)› 2. ‹¬ (k::nat) < (nl::nat) ⟹ (if k < nl then select k (ls::'b list) else select (k - nl) ((es::'b list) @ (gs::'b list))) = (if k < nl then select k ls else if k < nl + (ne::nat) then x::'b else select (k - nl - ne) gs)›*) case False (*‹¬ k < nl›*) hence "?lhs' = select (k - nl) (es @ gs)" by simp also (*calculation: ‹(if k < nl then select k ls else select (k - nl) (es @ gs)) = select (k - nl) (es @ gs)›*) have "… = (if k - nl < ne then select (k - nl) es else select (k - nl - ne) gs)" unfolding nl_ne_def (*goal: ‹select (k - length ls) (es @ gs) = (if k - length ls < length es then select (k - length ls) es else select (k - length ls - length es) gs)›*) using assms (*‹0 < d› ‹k < length xs›*) False (*‹¬ (k::nat) < (nl::nat)›*) apply (intro select_append' (*‹⟦⋀y z. ⟦y ∈ set ?ys; z ∈ set ?zs⟧ ⟹ y ≤ z; ?k < length ?ys + length ?zs⟧ ⟹ select ?k (?ys @ ?zs) = (if ?k < length ?ys then select ?k ?ys else select (?k - length ?ys) ?zs)›*)) (*goals: 1. ‹⋀y z. ⟦0 < d; k < length xs; ¬ k < nl; y ∈ set es; z ∈ set gs⟧ ⟹ y ≤ z› 2. ‹⟦0 < d; k < length xs; ¬ k < nl⟧ ⟹ k - length ls < length es + length gs› discuss goal 1*) apply ((auto simp: ls_def (*‹ls = filter (λy. y < x) xs›*) es_def (*‹es = filter (λy. y = x) xs›*) gs_def (*‹gs = filter ((<) x) xs›*) length_eq (*‹length xs = length ls + length es + length gs›*))[1]) (*discuss goal 2*) apply ((auto simp: ls_def (*‹(ls::'b::linorder list) = filter (λy::'b::linorder. y < (x::'b::linorder)) (xs::'b::linorder list)›*) es_def (*‹(es::'b::linorder list) = filter (λy::'b::linorder. y = (x::'b::linorder)) (xs::'b::linorder list)›*) gs_def (*‹(gs::'b::linorder list) = filter ((<) (x::'b::linorder)) (xs::'b::linorder list)›*) length_eq (*‹length (xs::'b::linorder list) = length (ls::'b::linorder list) + length (es::'b::linorder list) + length (gs::'b::linorder list)›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹(if k < nl then select k ls else select (k - nl) (es @ gs)) = (if k - nl < ne then select (k - nl) es else select (k - nl - ne) gs)›*) have "… = (if k - nl < ne then x else select (k - nl - ne) gs)" by simp also (*calculation: ‹(if k < nl then select k ls else select (k - nl) (es @ gs)) = (if k - nl < ne then x else select (k - nl - ne) gs)›*) from False (*‹¬ (k::nat) < (nl::nat)›*) have "… = ?rhs'" by auto finally (*calculation: ‹(if (k::nat) < (nl::nat) then select k (ls::'b list) else select (k - nl) ((es::'b list) @ (gs::'b list))) = (if k < nl then select k ls else if k < nl + (ne::nat) then x::'b else select (k - nl - ne) gs)›*) show "?thesis" (*goal: ‹(if k < nl then select k ls else select (k - nl) (es @ gs)) = (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) . qed (simp_all) (*solved the remaining goal: ‹(k::nat) < (nl::nat) ⟹ (if k < nl then select k (ls::'b list) else select (k - nl) ((es::'b list) @ (gs::'b list))) = (if k < nl then select k ls else if k < nl + (ne::nat) then x::'b else select (k - nl - ne) gs)›*) also (*calculation: ‹select k xs = (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) have "… = ?rhs" by (simp add: threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) ls_def (*‹ls = filter (λy. y < x) xs›*) es_def (*‹es = filter (λy. y = x) xs›*) gs_def (*‹gs = filter ((<) x) xs›*)) finally (*calculation: ‹select k xs = (let (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = length es in if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) show "?thesis" (*goal: ‹select k xs = (let (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = length es in if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) . qed text ‹ By the above results, it can be seen quite easily that, in each recursive step, the algorithm takes a list of length $n$, does $O(n)$ work for the chopping, computing the medians of the sublists, and partitioning, and it calls itself recursively with lists of size at most $\lceil 0.2n\rceil$ and $\lceil 0.7n\rceil + 6$, respectively. This means that the runtime of the algorithm is bounded above by the Akra--Bazzi-style recurrence \[T(n) = T(\lceil 0.2n\rceil) + T(\lceil 0.7n\rceil + 6) + O(n)\] which, by the Akra--Bazzi theorem, can be shown to fulfil $T\in \Theta(n)$. However, a proper analysis of this would require an actual execution model and some way of measuring the runtime of the algorithm, which is not what we aim to do here. Additionally, the entire algorithm can be performed in-place in an imperative way, but this because quite tedious. Instead of this, we will now focus on developing the above recursion into an executable functional algorithm. › subsection ‹Medians of lists of length at most 5› text ‹ We now show some basic results about how to efficiently find a median of a list of size at most 5. For length 1 or 2, this is trivial, since we can just pick any element. For length 3 and 4, we need at most three comparisons. For length 5, we need at most six comparisons. This allows us to save some comparisons compared with the naive method of performing insertion sort and then returning the element in the middle. › definition median_3 :: "'a :: linorder ⇒ _" where "median_3 a b c = (if a ≤ b then if b ≤ c then b else max a c else if c ≤ b then b else min a c)" lemma median_3: "median_3 a b c = median [a, b, c]" by (auto simp: median_3_def (*‹median_3 ?a ?b ?c = (if ?a ≤ ?b then if ?b ≤ ?c then ?b else max ?a ?c else if ?c ≤ ?b then ?b else min ?a ?c)›*) median_def (*‹median ?xs = select ((length ?xs - 1) div 2) ?xs›*) select_def (*‹select ?k ?xs = sort ?xs ! ?k›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) definition median_5_aux :: "'a :: linorder ⇒ _" where "median_5_aux x1 x2 x3 x4 x5 = ( if x2 ≤ x3 then if x2 ≤ x4 then min x3 x4 else min x2 x5 else if x4 ≤ x3 then min x3 x5 else min x2 x4)" lemma median_5_aux: assumes "x1 ≤ x2" "x4 ≤ x5" "x1 ≤ x4" shows "median_5_aux x1 x2 x3 x4 x5 = median [x1,x2,x3,x4,x5]" using assms (*‹x1 ≤ x2› ‹x4 ≤ x5› ‹x1 ≤ x4›*) by (auto simp: median_5_aux_def (*‹median_5_aux (?x1.0::?'a) (?x2.0::?'b) (?x3.0::?'b) (?x4.0::?'b) (?x5.0::?'b) = (if ?x2.0 ≤ ?x3.0 then if ?x2.0 ≤ ?x4.0 then min ?x3.0 ?x4.0 else min ?x2.0 ?x5.0 else if ?x4.0 ≤ ?x3.0 then min ?x3.0 ?x5.0 else min ?x2.0 ?x4.0)›*) median_def (*‹median (?xs::?'a list) = select ((length ?xs - (1::nat)) div (2::nat)) ?xs›*) select_def (*‹select (?k::nat) (?xs::?'a list) = sort ?xs ! ?k›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*)) definition median_5 :: "'a :: linorder ⇒ _" where "median_5 a b c d e = ( let (x1, x2) = (if a ≤ b then (a, b) else (b, a)); (x4, x5) = (if d ≤ e then (d, e) else (e, d)) in if x1 ≤ x4 then median_5_aux x1 x2 c x4 x5 else median_5_aux x4 x5 c x1 x2)" lemma median_5: "median_5 a b c d e = median [a, b, c, d, e]" by (auto simp: median_5_def (*‹median_5 ?a ?b ?c ?d ?e = (let (x1, x2) = if ?a ≤ ?b then (?a, ?b) else (?b, ?a); (x4, x5) = if ?d ≤ ?e then (?d, ?e) else (?e, ?d) in if x1 ≤ x4 then median_5_aux x1 x2 ?c x4 x5 else median_5_aux x4 x5 ?c x1 x2)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) median_5_aux (*‹⟦?x1.0 ≤ ?x2.0; ?x4.0 ≤ ?x5.0; ?x1.0 ≤ ?x4.0⟧ ⟹ median_5_aux ?x1.0 ?x2.0 ?x3.0 ?x4.0 ?x5.0 = median [?x1.0, ?x2.0, ?x3.0, ?x4.0, ?x5.0]›*) intro: median_cong (*‹mset ?xs = mset ?xs' ⟹ median ?xs = median ?xs'›*)) fun median_le_5 where "median_le_5 [a] = a" | "median_le_5 [a,b] = a" | "median_le_5 [a,b,c] = median_3 a b c" | "median_le_5 [a,b,c,d] = median_3 a b c" | "median_le_5 [a,b,c,d,e] = median_5 a b c d e" | "median_le_5 _ = undefined" lemma median_5_in_set: "median_5 a b c d e ∈ {a, b, c, d, e}" proof (-) (*goal: ‹median_5 (a::'a) (b::'a) (c::'a) (d::'a) (e::'a) ∈ {a, b, c, d, e}›*) have "median_5 a b c d e ∈ set [a, b, c, d, e]" unfolding median_5 (*goal: ‹median [a, b, c, d, e] ∈ set [a, b, c, d, e]›*) apply (rule median_in_set (*‹(?xs::?'a list) ≠ [] ⟹ median ?xs ∈ set ?xs›*)) (*goal: ‹median [a, b, c, d, e] ∈ set [a, b, c, d, e]›*) by auto thus "?thesis" (*goal: ‹median_5 a b c d e ∈ {a, b, c, d, e}›*) by simp qed lemma median_le_5_in_set: assumes "xs ≠ []" "length xs ≤ 5" shows "median_le_5 xs ∈ set xs" proof (cases xs rule: median_le_5.cases (*‹⟦⋀a. ?x = [a] ⟹ ?P; ⋀a b. ?x = [a, b] ⟹ ?P; ⋀a b c. ?x = [a, b, c] ⟹ ?P; ⋀a b c d. ?x = [a, b, c, d] ⟹ ?P; ⋀a b c d e. ?x = [a, b, c, d, e] ⟹ ?P; ?x = [] ⟹ ?P; ⋀v vb va vc vd ve vg. ?x = v # vb # va # vc # vd # ve # vg ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀a. xs = [a] ⟹ median_le_5 xs ∈ set xs› 2. ‹⋀a b. xs = [a, b] ⟹ median_le_5 xs ∈ set xs› 3. ‹⋀a b c. xs = [a, b, c] ⟹ median_le_5 xs ∈ set xs› 4. ‹⋀a b c d. xs = [a, b, c, d] ⟹ median_le_5 xs ∈ set xs› 5. ‹⋀a b c d e. xs = [a, b, c, d, e] ⟹ median_le_5 xs ∈ set xs› 6. ‹xs = [] ⟹ median_le_5 xs ∈ set xs› 7. ‹⋀v vb va vc vd ve vg. xs = v # vb # va # vc # vd # ve # vg ⟹ median_le_5 xs ∈ set xs›*) case (5 a b c d e) (*‹xs = [a, b, c, d, e]›*) with median_5_in_set[of a b c d e] (*‹median_5 a b c d e ∈ {a, b, c, d, e}›*) show "?thesis" (*goal: ‹median_le_5 xs ∈ set xs›*) by simp qed (insert assms (*‹xs ≠ []› ‹length xs ≤ 5›*), auto simp: median_3_def (*‹median_3 ?a ?b ?c = (if ?a ≤ ?b then if ?b ≤ ?c then ?b else max ?a ?c else if ?c ≤ ?b then ?b else min ?a ?c)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*)) (*solves the remaining goals: 1. ‹⋀a. xs = [a] ⟹ median_le_5 xs ∈ set xs› 2. ‹⋀a b. xs = [a, b] ⟹ median_le_5 xs ∈ set xs› 3. ‹⋀a b c. xs = [a, b, c] ⟹ median_le_5 xs ∈ set xs› 4. ‹⋀a b c d. xs = [a, b, c, d] ⟹ median_le_5 xs ∈ set xs› 5. ‹xs = [] ⟹ median_le_5 xs ∈ set xs› 6. ‹⋀v vb va vc vd ve vg. xs = v # vb # va # vc # vd # ve # vg ⟹ median_le_5 xs ∈ set xs›*) lemma median_le_5: assumes "xs ≠ []" "length xs ≤ 5" shows "is_median (median_le_5 xs) xs" proof (cases xs rule: median_le_5.cases (*‹⟦⋀a::?'a. (?x::?'a list) = [a] ⟹ ?P::bool; ⋀(a::?'a) b::?'a. ?x = [a, b] ⟹ ?P; ⋀(a::?'a) (b::?'a) c::?'a. ?x = [a, b, c] ⟹ ?P; ⋀(a::?'a) (b::?'a) (c::?'a) d::?'a. ?x = [a, b, c, d] ⟹ ?P; ⋀(a::?'a) (b::?'a) (c::?'a) (d::?'a) e::?'a. ?x = [a, b, c, d, e] ⟹ ?P; ?x = [] ⟹ ?P; ⋀(v::?'a) (vb::?'a) (va::?'a) (vc::?'a) (vd::?'a) (ve::?'a) vg::?'a list. ?x = v # vb # va # vc # vd # ve # vg ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⋀a. xs = [a] ⟹ is_median (median_le_5 xs) xs› 2. ‹⋀a b. xs = [a, b] ⟹ is_median (median_le_5 xs) xs› 3. ‹⋀a b c. xs = [a, b, c] ⟹ is_median (median_le_5 xs) xs› 4. ‹⋀a b c d. xs = [a, b, c, d] ⟹ is_median (median_le_5 xs) xs› 5. ‹⋀a b c d e. xs = [a, b, c, d, e] ⟹ is_median (median_le_5 xs) xs› 6. ‹xs = [] ⟹ is_median (median_le_5 xs) xs› 7. ‹⋀v vb va vc vd ve vg. xs = v # vb # va # vc # vd # ve # vg ⟹ is_median (median_le_5 xs) xs›*) case (3 a b c) (*‹xs = [a, b, c]›*) have "is_median (median xs) xs" by simp also (*calculation: ‹is_median (median xs) xs›*) have "median xs = median_3 a b c" by (simp add: median_3 (*‹median_3 ?a ?b ?c = median [?a, ?b, ?c]›*) 3 (*‹xs = [a, b, c]›*)) finally (*calculation: ‹is_median (median_3 (a::'a::linorder) (b::'a::linorder) (c::'a::linorder)) (xs::'a::linorder list)›*) show "?thesis" (*goal: ‹is_median (median_le_5 xs) xs›*) using "3" (*‹(xs::'a::linorder list) = [a::'a::linorder, b::'a::linorder, c::'a::linorder]›*) by simp next (*goals: 1. ‹⋀a. xs = [a] ⟹ is_median (median_le_5 xs) xs› 2. ‹⋀a b. xs = [a, b] ⟹ is_median (median_le_5 xs) xs› 3. ‹⋀a b c d. xs = [a, b, c, d] ⟹ is_median (median_le_5 xs) xs› 4. ‹⋀a b c d e. xs = [a, b, c, d, e] ⟹ is_median (median_le_5 xs) xs› 5. ‹xs = [] ⟹ is_median (median_le_5 xs) xs› 6. ‹⋀v vb va vc vd ve vg. xs = v # vb # va # vc # vd # ve # vg ⟹ is_median (median_le_5 xs) xs›*) case (4 a b c d) (*‹xs = [a, b, c, d]›*) have "is_median (median [a,b,c]) [a,b,c]" by simp also (*calculation: ‹is_median (median [a, b, c]) [a, b, c]›*) have "median [a,b,c] = median_3 a b c" by (simp add: median_3 (*‹median_3 ?a ?b ?c = median [?a, ?b, ?c]›*) 4 (*‹xs = [a, b, c, d]›*)) finally (*calculation: ‹is_median (median_3 a b c) [a, b, c]›*) have "is_median (median_3 a b c) (d # [a,b,c])" apply (rule is_median_Cons_odd (*‹⟦is_median ?x ?xs; odd (length ?xs)⟧ ⟹ is_median ?x (?y # ?xs)›*)) (*goal: ‹is_median (median_3 (a::'a) (b::'a) (c::'a)) [d::'a, a, b, c]›*) by auto also (*calculation: ‹is_median (median_3 (a::'a) (b::'a) (c::'a)) [d::'a, a, b, c]›*) have "?this ⟷ is_median (median_3 a b c) [a,b,c,d]" apply (intro is_median_cong (*‹⟦?x = ?y; mset ?xs = mset ?ys⟧ ⟹ is_median ?x ?xs = is_median ?y ?ys›*)) (*goals: 1. ‹median_3 a b c = median_3 a b c› 2. ‹mset [d, a, b, c] = mset [a, b, c, d]› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹is_median (median_3 a b c) [a, b, c, d]›*) show "?thesis" (*goal: ‹is_median (median_le_5 xs) xs›*) using "4" (*‹xs = [a, b, c, d]›*) by simp next (*goals: 1. ‹⋀a::'a. (xs::'a list) = [a] ⟹ is_median (median_le_5 xs) xs› 2. ‹⋀(a::'a) b::'a. (xs::'a list) = [a, b] ⟹ is_median (median_le_5 xs) xs› 3. ‹⋀(a::'a) (b::'a) (c::'a) (d::'a) e::'a. (xs::'a list) = [a, b, c, d, e] ⟹ is_median (median_le_5 xs) xs› 4. ‹(xs::'a list) = [] ⟹ is_median (median_le_5 xs) xs› 5. ‹⋀(v::'a) (vb::'a) (va::'a) (vc::'a) (vd::'a) (ve::'a) vg::'a list. (xs::'a list) = v # vb # va # vc # vd # ve # vg ⟹ is_median (median_le_5 xs) xs›*) case (5 a b c d e) (*‹(xs::'a::linorder list) = [a::'a::linorder, b::'a::linorder, c::'a::linorder, d::'a::linorder, e::'a::linorder]›*) have "is_median (median xs) xs" by simp also (*calculation: ‹is_median (median (xs::'a list)) xs›*) have "median xs = median_5 a b c d e" by (simp add: median_5 (*‹median_5 (?a::?'a::linorder) (?b::?'a::linorder) (?c::?'a::linorder) (?d::?'a::linorder) (?e::?'a::linorder) = median [?a, ?b, ?c, ?d, ?e]›*) 5 (*‹(xs::'a::linorder list) = [a::'a::linorder, b::'a::linorder, c::'a::linorder, d::'a::linorder, e::'a::linorder]›*)) finally (*calculation: ‹is_median (median_5 a b c d e) xs›*) show "?thesis" (*goal: ‹is_median (median_le_5 xs) xs›*) using "5" (*‹xs = [a, b, c, d, e]›*) by simp qed (insert assms (*‹xs ≠ []› ‹length xs ≤ 5›*), auto simp: is_median_def (*‹is_median ?x ?xs = (length (filter (λy. y < ?x) ?xs) ≤ length ?xs div 2 ∧ length (filter ((<) ?x) ?xs) ≤ length ?xs div 2)›*)) (*solves the remaining goals: 1. ‹⋀a. xs = [a] ⟹ is_median (median_le_5 xs) xs› 2. ‹⋀a b. xs = [a, b] ⟹ is_median (median_le_5 xs) xs› 3. ‹xs = [] ⟹ is_median (median_le_5 xs) xs› 4. ‹⋀v vb va vc vd ve vg. xs = v # vb # va # vc # vd # ve # vg ⟹ is_median (median_le_5 xs) xs›*) subsection ‹Median-of-medians selection algorithm› text ‹ The fast selection function now simply computes the median-of-medians of the chopped-up list as a pivot, partitions the list into with respect to that pivot, and recurses into one of the resulting sublists. › function fast_select where "fast_select k xs = ( if length xs ≤ 20 then sort xs ! k else let x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); (ls, es, gs) = threeway_partition x xs in if k < length ls then fast_select k ls else if k < length ls + length es then x else fast_select (k - length ls - length es) gs )" by auto text ‹ The correctness of this is obvious from the above theorems, but the proof is still somewhat complicated by the fact that termination depends on the correctness of the function. › lemma fast_select_correct_aux: assumes "fast_select_dom (k, xs)" "k < length xs" shows "fast_select k xs = select k xs" using assms (*‹fast_select_dom (k, xs)› ‹k < length xs›*) proof (induction) (*goal: ‹⋀k xs. ⟦fast_select_dom (k, xs); ⟦¬ length xs ≤ 20; ((length xs + 4) div 5 - 1) div 2 < length (map median_le_5 (chop 5 xs))⟧ ⟹ fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)) = select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); ⋀x xa xb y xaa ya. ⟦¬ length xs ≤ 20; x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); xa = threeway_partition x xs; (xb, y) = xa; (xaa, ya) = y; k < length xb; k < length xb⟧ ⟹ fast_select k xb = select k xb; ⋀x xa xb y xaa ya. ⟦¬ length xs ≤ 20; x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); xa = threeway_partition x xs; (xb, y) = xa; (xaa, ya) = y; ¬ k < length xb; ¬ k < length xb + length xaa; k - length xb - length xaa < length ya⟧ ⟹ fast_select (k - length xb - length xaa) ya = select (k - length xb - length xaa) ya; k < length xs⟧ ⟹ fast_select k xs = select k xs›*) case (1 k xs) (*‹fast_select_dom (k, xs)› ‹⟦¬ length xs ≤ 20; ((length xs + 4) div 5 - 1) div 2 < length (map median_le_5 (chop 5 xs))⟧ ⟹ fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)) = select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))› ‹⟦¬ length xs ≤ 20; ?x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); ?xa = threeway_partition ?x xs; (?xb, ?y) = ?xa; (?xaa, ?ya) = ?y; k < length ?xb; k < length ?xb⟧ ⟹ fast_select k ?xb = select k ?xb› ‹⟦¬ length xs ≤ 20; ?x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); ?xa = threeway_partition ?x xs; (?xb, ?y) = ?xa; (?xaa, ?ya) = ?y; ¬ k < length ?xb; ¬ k < length ?xb + length ?xaa; k - length ?xb - length ?xaa < length ?ya⟧ ⟹ fast_select (k - length ?xb - length ?xaa) ?ya = select (k - length ?xb - length ?xaa) ?ya› ‹(k::nat) < length (xs::'a list)›*) show "?case" (*goal: ‹fast_select k xs = select k xs›*) proof (cases "length xs ≤ 20") (*goals: 1. ‹length xs ≤ 20 ⟹ fast_select k xs = select k xs› 2. ‹¬ length xs ≤ 20 ⟹ fast_select k xs = select k xs›*) case True (*‹length xs ≤ 20›*) thus "?thesis" (*goal: ‹fast_select k xs = select k xs›*) using "1.prems" (*‹k < length xs›*) "1.hyps" (*‹fast_select_dom (k, xs)›*) apply (subst fast_select.psimps (*‹fast_select_dom (?k, ?xs) ⟹ fast_select ?k ?xs = (if length ?xs ≤ 20 then sort ?xs ! ?k else let x = fast_select (((length ?xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 ?xs)); (ls, es, gs) = threeway_partition x ?xs in if ?k < length ls then fast_select ?k ls else if ?k < length ls + length es then x else fast_select (?k - length ls - length es) gs)›*)) (*goals: 1. ‹⟦length (xs::'a::linorder list) ≤ (20::nat); (k::nat) < length xs; fast_select_dom (k, xs)⟧ ⟹ fast_select_dom (k, xs)› 2. ‹⟦length (xs::'a::linorder list) ≤ (20::nat); (k::nat) < length xs; fast_select_dom (k, xs)⟧ ⟹ (if length xs ≤ (20::nat) then sort xs ! k else let x::'a::linorder = fast_select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)); (ls::'a::linorder list, es::'a::linorder list, gs::'a::linorder list) = threeway_partition x xs in if k < length ls then fast_select k ls else if k < length ls + length es then x else fast_select (k - length ls - length es) gs) = select k xs› discuss goal 1*) apply ((auto simp: select_def (*‹select ?k ?xs = sort ?xs ! ?k›*))[1]) (*discuss goal 2*) apply ((auto simp: select_def (*‹select ?k ?xs = sort ?xs ! ?k›*))[1]) (*proven 2 subgoals*) . next (*goal: ‹¬ length xs ≤ 20 ⟹ fast_select k xs = select k xs›*) case False (*‹¬ length xs ≤ 20›*) define x where "x = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))" define ls where "ls = filter (λy. y < x) xs" define es where "es = filter (λy. y = x) xs" define gs where "gs = filter (λy. y > x) xs" define nl and ne where "nl = length ls" and "ne = length es" note defs = nl_def (*‹nl = length ls›*) ne_def (*‹ne = length es›*) x_def (*‹x = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))›*) ls_def (*‹ls = filter (λy. y < x) xs›*) es_def (*‹es = filter (λy. y = x) xs›*) gs_def (*‹gs = filter ((<) x) xs›*) have tw: "(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs" unfolding threeway_partition_def defs One_nat_def (*goal: ‹(filter (λy. y < fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))) xs, filter (λy. y = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))) xs, filter ((<) (fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs)))) xs) = (filter (λy. y < fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))) xs, filter (λy. y = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))) xs, filter ((<) (fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs)))) xs)›*) by standard have tw': "(ls, es, gs) = threeway_partition x xs" by (simp add: tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*) x_def (*‹x = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))›*)) have "fast_select k xs = (if k < nl then fast_select k ls else if k < nl + ne then x else fast_select (k - nl - ne) gs)" using "1.hyps" (*‹fast_select_dom (k, xs)›*) False (*‹¬ length xs ≤ 20›*) apply (subst fast_select.psimps (*‹fast_select_dom (?k, ?xs) ⟹ fast_select ?k ?xs = (if length ?xs ≤ 20 then sort ?xs ! ?k else let x = fast_select (((length ?xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 ?xs)); (ls, es, gs) = threeway_partition x ?xs in if ?k < length ls then fast_select ?k ls else if ?k < length ls + length es then x else fast_select (?k - length ls - length es) gs)›*)) (*goals: 1. ‹⟦fast_select_dom (k::nat, xs::'a::linorder list); ¬ length xs ≤ (20::nat)⟧ ⟹ fast_select_dom (k, xs)› 2. ‹⟦fast_select_dom (k::nat, xs::'a::linorder list); ¬ length xs ≤ (20::nat)⟧ ⟹ (if length xs ≤ (20::nat) then sort xs ! k else let x::'a::linorder = fast_select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)); (ls::'a::linorder list, es::'a::linorder list, gs::'a::linorder list) = threeway_partition x xs in if k < length ls then fast_select k ls else if k < length ls + length es then x else fast_select (k - length ls - length es) gs) = (if k < (nl::nat) then fast_select k (ls::'a::linorder list) else if k < nl + (ne::nat) then x::'a::linorder else fast_select (k - nl - ne) (gs::'a::linorder list))› discuss goal 1*) apply (simp add: threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*) defs [symmetric] (*‹length ls = nl› ‹length es = ne› ‹fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs)) = x› ‹filter (λy. y < x) xs = ls› ‹filter (λy. y = x) xs = es› ‹filter ((<) x) xs = gs›*)) (*discuss goal 2*) apply (simp add: threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*) defs [symmetric] (*‹length ls = nl› ‹length es = ne› ‹fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs)) = x› ‹filter (λy. y < x) xs = ls› ‹filter (λy. y = x) xs = es› ‹filter ((<) x) xs = gs›*)) (*proven 2 subgoals*) . also (*calculation: ‹fast_select k xs = (if k < nl then fast_select k ls else if k < nl + ne then x else fast_select (k - nl - ne) gs)›*) have "… = (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)" proof (intro if_cong (*‹⟦?b = ?c; ?c ⟹ ?x = ?u; ¬ ?c ⟹ ?y = ?v⟧ ⟹ (if ?b then ?x else ?y) = (if ?c then ?u else ?v)›*) refl (*‹?t = ?t›*)) (*goals: 1. ‹k < nl ⟹ fast_select k ls = select k ls› 2. ‹⟦¬ k < nl; ¬ k < nl + ne⟧ ⟹ fast_select (k - nl - ne) gs = select (k - nl - ne) gs›*) assume "*": "k < nl" (*‹(k::nat) < (nl::nat)›*) show "fast_select k ls = select k ls" apply (rule 1 (*‹fast_select_dom (k::nat, xs::'a list)› ‹⟦¬ length (xs::'a list) ≤ (20::nat); ((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat) < length (map median_le_5 (chop (5::nat) xs))⟧ ⟹ fast_select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)) = select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs))› ‹⟦¬ length (xs::'a list) ≤ (20::nat); (?x::'a) = fast_select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)); (?xa::'a list × 'a list × 'a list) = threeway_partition ?x xs; (?xb::'a list, ?y::'a list × 'a list) = ?xa; (?xaa::'a list, ?ya::'a list) = ?y; (k::nat) < length ?xb; k < length ?xb⟧ ⟹ fast_select k ?xb = select k ?xb› ‹⟦¬ length (xs::'a list) ≤ (20::nat); (?x::'a) = fast_select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)); (?xa::'a list × 'a list × 'a list) = threeway_partition ?x xs; (?xb::'a list, ?y::'a list × 'a list) = ?xa; (?xaa::'a list, ?ya::'a list) = ?y; ¬ (k::nat) < length ?xb; ¬ k < length ?xb + length ?xaa; k - length ?xb - length ?xaa < length ?ya⟧ ⟹ fast_select (k - length ?xb - length ?xaa) ?ya = select (k - length ?xb - length ?xaa) ?ya› ‹(k::nat) < length (xs::'a list)›*)) (*goals: 1. ‹¬ length xs ≤ 20› 2. ‹?x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))› 3. ‹?xa = threeway_partition ?x xs› 4. ‹(ls, ?y) = ?xa› 5. ‹(?xaa, ?ya) = ?y› 6. ‹k < length ls› 7. ‹k < length ls› discuss goal 1*) apply ((insert * (*‹k < nl›*))[1]) (*top goal: ‹¬ length xs ≤ 20› and 6 goals remain*) apply ((auto simp: False (*‹¬ length xs ≤ 20›*) threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*) ls_def (*‹ls = filter (λy. y < x) xs›*) x_def (*‹x = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))›*) nl_def (*‹nl = length ls›*))[1]) (*discuss goal 2*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 3*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 4*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 5*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 6*) apply ((insert * (*‹k < nl›*))[1]) (*top goal: ‹k < length ls› and 1 goal remains*) apply ((auto simp: False (*‹¬ length xs ≤ 20›*) threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*) ls_def (*‹ls = filter (λy. y < x) xs›*) x_def (*‹x = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))›*) nl_def (*‹nl = length ls›*))[1]) (*discuss goal 7*) apply ((insert * (*‹k < nl›*))[1]) (*goal: ‹(k::nat) < length (ls::'a list)›*) apply ((auto simp: False (*‹¬ length (xs::'a list) ≤ (20::nat)›*) threeway_partition_def (*‹threeway_partition (?x::?'a) (?xs::?'a list) = (filter (λy::?'a. y < ?x) ?xs, filter (λy::?'a. y = ?x) ?xs, filter ((<) ?x) ?xs)›*) ls_def (*‹(ls::'a list) = filter (λy::'a. y < (x::'a)) (xs::'a list)›*) x_def (*‹(x::'a) = fast_select (((length (xs::'a list) + (4::nat)) div (5::nat) - Suc (0::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs))›*) nl_def (*‹(nl::nat) = length (ls::'a list)›*))[1]) (*proven 7 subgoals*) . next (*goal: ‹⟦¬ k < nl; ¬ k < nl + ne⟧ ⟹ fast_select (k - nl - ne) gs = select (k - nl - ne) gs›*) assume "*": "¬k < nl" "¬k < nl + ne" (*‹¬ (k::nat) < (nl::nat)› ‹¬ (k::nat) < (nl::nat) + (ne::nat)›*) have "**": "length xs = length ls + length es + length gs" unfolding ls_def es_def gs_def (*goal: ‹length xs = length (filter (λy. y < x) xs) + length (filter (λy. y = x) xs) + length (filter ((<) x) xs)›*) apply (induction xs) (*goals: 1. ‹length [] = length (filter (λy::'a::linorder. y < (x::'a::linorder)) []) + length (filter (λy::'a::linorder. y = x) []) + length (filter ((<) x) [])› 2. ‹⋀(a::'a::linorder) xs::'a::linorder list. length xs = length (filter (λy::'a::linorder. y < (x::'a::linorder)) xs) + length (filter (λy::'a::linorder. y = x) xs) + length (filter ((<) x) xs) ⟹ length (a # xs) = length (filter (λy::'a::linorder. y < x) (a # xs)) + length (filter (λy::'a::linorder. y = x) (a # xs)) + length (filter ((<) x) (a # xs))› discuss goal 1*) apply ((auto simp del: filter_True (*‹∀x::?'a∈set (?xs::?'a list). (?P::?'a ⇒ bool) x ⟹ filter ?P ?xs = ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp del: filter_True (*‹∀x∈set ?xs. ?P x ⟹ filter ?P ?xs = ?xs›*))[1]) (*proven 2 subgoals*) . show "fast_select (k - nl - ne) gs = select (k - nl - ne) gs" unfolding nl_def ne_def (*goal: ‹fast_select (k - length ls - length es) gs = select (k - length ls - length es) gs›*) apply (rule 1 (*‹fast_select_dom (k, xs)› ‹⟦¬ length xs ≤ 20; ((length xs + 4) div 5 - 1) div 2 < length (map median_le_5 (chop 5 xs))⟧ ⟹ fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)) = select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))› ‹⟦¬ length xs ≤ 20; ?x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); ?xa = threeway_partition ?x xs; (?xb, ?y) = ?xa; (?xaa, ?ya) = ?y; k < length ?xb; k < length ?xb⟧ ⟹ fast_select k ?xb = select k ?xb› ‹⟦¬ length xs ≤ 20; ?x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); ?xa = threeway_partition ?x xs; (?xb, ?y) = ?xa; (?xaa, ?ya) = ?y; ¬ k < length ?xb; ¬ k < length ?xb + length ?xaa; k - length ?xb - length ?xaa < length ?ya⟧ ⟹ fast_select (k - length ?xb - length ?xaa) ?ya = select (k - length ?xb - length ?xaa) ?ya› ‹k < length xs›*)) (*goals: 1. ‹¬ length xs ≤ 20› 2. ‹?x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))› 3. ‹?xa = threeway_partition ?x xs› 4. ‹(ls, ?y) = ?xa› 5. ‹(es, gs) = ?y› 6. ‹¬ k < length ls› 7. ‹¬ k < length ls + length es› 8. ‹k - length ls - length es < length gs› discuss goal 1*) apply ((insert False (*‹¬ length xs ≤ 20›*) * (*‹¬ k < nl› ‹¬ k < nl + ne›*) ** (*‹length xs = length ls + length es + length gs›*) ‹k < length xs›)[1]) (*top goal: ‹¬ length xs ≤ 20› and 7 goals remain*) apply ((auto simp: nl_def (*‹nl = length ls›*) ne_def (*‹ne = length es›*))[1]) (*discuss goal 2*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 3*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 4*) apply (rule refl (*‹?t = ?t›*) tw (*‹(ls, es, gs) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs›*)) (*discuss goal 5*) apply (rule refl (*‹(?t::?'a) = ?t›*) tw (*‹(ls::'a list, es::'a list, gs::'a list) = threeway_partition (fast_select (((length (xs::'a list) + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs))) xs›*)) (*discuss goal 6*) apply ((insert False (*‹¬ length xs ≤ 20›*) * (*‹¬ k < nl› ‹¬ k < nl + ne›*) ** (*‹length xs = length ls + length es + length gs›*) ‹k < length xs›)[1]) (*top goal: ‹¬ k < length ls› and 2 goals remain*) apply ((auto simp: nl_def (*‹(nl::nat) = length (ls::'a list)›*) ne_def (*‹(ne::nat) = length (es::'a list)›*))[1]) (*discuss goal 7*) apply ((insert False (*‹¬ length xs ≤ 20›*) * (*‹¬ k < nl› ‹¬ k < nl + ne›*) ** (*‹length xs = length ls + length es + length gs›*) ‹k < length xs›)[1]) (*top goal: ‹¬ (k::nat) < length (ls::'a list) + length (es::'a list)› and 1 goal remains*) apply ((auto simp: nl_def (*‹(nl::nat) = length (ls::'a::linorder list)›*) ne_def (*‹(ne::nat) = length (es::'a::linorder list)›*))[1]) (*discuss goal 8*) apply ((insert False (*‹¬ length xs ≤ 20›*) * (*‹¬ k < nl› ‹¬ k < nl + ne›*) ** (*‹length xs = length ls + length es + length gs›*) ‹k < length xs›)[1]) (*goal: ‹k - length ls - length es < length gs›*) apply ((auto simp: nl_def (*‹nl = length ls›*) ne_def (*‹ne = length es›*))[1]) (*proven 8 subgoals*) . qed also (*calculation: ‹fast_select k xs = (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) have "… = select k xs" using ‹k < length xs› (*‹(k::nat) < length (xs::'a list)›*) apply (subst (3) select_rec_threeway_partition[of "5::nat" _ _ x] (*‹⟦0 < 5; ?k < length ?xs⟧ ⟹ select ?k ?xs = (let (ls, es, gs) = threeway_partition x ?xs; nl = length ls; ne = length es in if ?k < nl then select ?k ls else if ?k < nl + ne then x else select (?k - nl - ne) gs)›*)) (*goals: 1. ‹k < length xs ⟹ 0 < 5› 2. ‹k < length xs ⟹ k < length xs› 3. ‹k < length xs ⟹ (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs) = (let (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = length es in if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply ((unfold Let_def (*‹Let ?s ?f ≡ ?f ?s›*) nl_def (*‹nl = length ls›*) ne_def (*‹ne = length es›*) ls_def (*‹ls = filter (λy. y < x) xs›*) gs_def (*‹gs = filter ((<) x) xs›*) es_def (*‹es = filter (λy. y = x) xs›*) x_def (*‹x = fast_select (((length xs + 4) div 5 - Suc 0) div 2) (map median_le_5 (chop 5 xs))›*) threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*))[1]) (*goal: ‹k < length xs ⟹ (if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs) = (let (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = length es in if k < nl then select k ls else if k < nl + ne then x else select (k - nl - ne) gs)›*) apply simp (*proven 3 subgoals*) . finally (*calculation: ‹fast_select k xs = select k xs›*) show "?thesis" (*goal: ‹fast_select k xs = select k xs›*) . qed qed text ‹ Termination of the algorithm is reasonably obvious because the lists that are recursed into never contain the pivot (the median-of-medians), while the original list clearly does. The proof is still somewhat technical though. › lemma fast_select_termination: "All fast_select_dom" proof (relation "measure (length ∘ snd)"; (safe)?, goal_cases) (*goals: 1. ‹⋀k xs. ¬ length xs ≤ 20 ⟹ ((((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs)), k, xs) ∈ measure (length ∘ snd)› 2. ‹⋀k xs x a aa b xb ab ba xaa ya. ⟦¬ length xs ≤ 20; (a, aa, b) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs; k < length a; fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))⟧ ⟹ ((k, a), k, xs) ∈ measure (length ∘ snd)› 3. ‹⋀k xs x a aa b xb ab ba xaa ya. ⟦¬ length xs ≤ 20; (a, aa, b) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs; ¬ k < length a; ¬ k < length a + length aa; fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))⟧ ⟹ ((k - length a - length aa, b), k, xs) ∈ measure (length ∘ snd)›*) case (1 k xs) (*‹¬ length xs ≤ 20›*) thus "?case" (*goal: ‹((((length (xs::'a list) + (4::nat)) div (5::nat) - (1::nat)) div (2::nat), map median_le_5 (chop (5::nat) xs)), k::nat, xs) ∈ measure (length ∘ snd)›*) by (auto simp: length_chop (*‹0 < ?n ⟹ length (chop ?n ?xs) = nat ⌈real (length ?xs) / real ?n⌉›*) nat_less_iff (*‹0 ≤ ?w ⟹ (nat ?w < ?m) = (?w < int ?m)›*) ceiling_less_iff (*‹(⌈?x⌉ < ?z) = (?x ≤ of_int ?z - 1)›*)) next (*goals: 1. ‹⋀k xs x a aa b xb ab ba xaa ya. ⟦¬ length xs ≤ 20; (a, aa, b) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs; k < length a; fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))⟧ ⟹ ((k, a), k, xs) ∈ measure (length ∘ snd)› 2. ‹⋀k xs x a aa b xb ab ba xaa ya. ⟦¬ length xs ≤ 20; (a, aa, b) = threeway_partition (fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))) xs; ¬ k < length a; ¬ k < length a + length aa; fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))⟧ ⟹ ((k - length a - length aa, b), k, xs) ∈ measure (length ∘ snd)›*) fix k :: nat and xs :: "'a list" and ls :: "'a list" and es :: "'a list" and gs :: "'a list" define x where "x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))" assume A: "¬ length xs ≤ 20" "(ls, es, gs) = threeway_partition x xs" "fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))" (*‹¬ length (xs::'a list) ≤ (20::nat)› ‹(ls::'a list, es::'a list, gs::'a list) = threeway_partition (x::'a) (xs::'a list)› ‹fast_select_dom (((length (xs::'a list) + (4::nat)) div (5::nat) - (1::nat)) div (2::nat), map median_le_5 (chop (5::nat) xs))›*) from A (*‹¬ length xs ≤ 20› ‹(ls, es, gs) = threeway_partition x xs› ‹fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))›*) have eq: "ls = filter (λy. y < x) xs" "gs = filter (λy. y > x) xs" apply - (*goals: 1. ‹⟦¬ length xs ≤ 20; (ls, es, gs) = threeway_partition x xs; fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))⟧ ⟹ ls = filter (λy. y < x) xs› 2. ‹⟦¬ length xs ≤ 20; (ls, es, gs) = threeway_partition x xs; fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))⟧ ⟹ gs = filter ((<) x) xs› discuss goal 1*) apply (simp add: x_def (*‹x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))›*) threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*)) (*discuss goal 2*) apply (simp add: x_def (*‹x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))›*) threeway_partition_def (*‹threeway_partition ?x ?xs = (filter (λy. y < ?x) ?xs, filter (λy. y = ?x) ?xs, filter ((<) ?x) ?xs)›*)) (*proven 2 subgoals*) . have len: "(length xs + 4) div 5 = nat ⌈length xs / 5⌉" by linarith have less: "(nat ⌈real (length xs) / 5⌉ - Suc 0) div 2 < nat ⌈real (length xs) / 5⌉" using A(1) (*‹¬ length xs ≤ 20›*) by linarith have "x = select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))" using less (*‹(nat ⌈real (length xs) / 5⌉ - Suc 0) div 2 < nat ⌈real (length xs) / 5⌉›*) unfolding x_def (*goal: ‹fast_select (((length (xs::'a::linorder list) + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)) = select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs))›*) apply (intro fast_select_correct_aux (*‹⟦fast_select_dom (?k, ?xs); ?k < length ?xs⟧ ⟹ fast_select ?k ?xs = select ?k ?xs›*) A (*‹¬ length xs ≤ 20› ‹(ls, es, gs) = threeway_partition x xs› ‹fast_select_dom (((length xs + 4) div 5 - 1) div 2, map median_le_5 (chop 5 xs))›*)) (*goal: ‹fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)) = select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))›*) by (auto simp: length_chop (*‹(0::nat) < (?n::nat) ⟹ length (chop ?n (?xs::?'a list)) = nat ⌈real (length ?xs) / real ?n⌉›*) len (*‹(length (xs::'a list) + (4::nat)) div (5::nat) = nat ⌈real (length xs) / (5::real)⌉›*)) also (*calculation: ‹x = select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs))›*) have "… = median (map median_le_5 (chop 5 xs))" by (simp add: median_def (*‹median (?xs::?'a::linorder list) = select ((length ?xs - (1::nat)) div (2::nat)) ?xs›*) len (*‹(length (xs::'a::linorder list) + (4::nat)) div (5::nat) = nat ⌈real (length xs) / (5::real)⌉›*) length_chop (*‹(0::nat) < (?n::nat) ⟹ length (chop ?n (?xs::?'a::type list)) = nat ⌈real (length ?xs) / real ?n⌉›*)) finally (*calculation: ‹x = median (map median_le_5 (chop 5 xs))›*) have x: "x = …" . moreover { have "x ∈ set (map median_le_5 (chop 5 xs))" using A(1) (*‹¬ length (xs::'a list) ≤ (20::nat)›*) unfolding x (*goal: ‹median (map median_le_5 (chop 5 xs)) ∈ set (map median_le_5 (chop 5 xs))›*) apply (intro median_in_set (*‹?xs ≠ [] ⟹ median ?xs ∈ set ?xs›*)) (*goal: ‹median (map median_le_5 (chop (5::nat) (xs::'a list))) ∈ set (map median_le_5 (chop (5::nat) xs))›*) by auto also (*calculation: ‹x ∈ set (map median_le_5 (chop 5 xs))›*) have "… ⊆ (⋃ys∈set (chop 5 xs). {median_le_5 ys})" by auto also (*calculation: ‹x ∈ (⋃ys∈set (chop 5 xs). {median_le_5 ys})›*) have "… ⊆ (⋃ys∈set (chop 5 xs). set ys)" using A(1) (*‹¬ length xs ≤ 20›*) apply (intro UN_mono (*‹⟦?A ⊆ ?B; ⋀x. x ∈ ?A ⟹ ?f x ⊆ ?g x⟧ ⟹ ⋃ (?f ` ?A) ⊆ ⋃ (?g ` ?B)›*)) (*goals: 1. ‹¬ length xs ≤ 20 ⟹ set (chop 5 xs) ⊆ set (chop 5 xs)› 2. ‹⋀ys. ⟦¬ length xs ≤ 20; ys ∈ set (chop 5 xs)⟧ ⟹ {median_le_5 ys} ⊆ set ys› discuss goal 1*) apply ((auto simp: median_le_5_in_set (*‹⟦?xs ≠ []; length ?xs ≤ 5⟧ ⟹ median_le_5 ?xs ∈ set ?xs›*) length_chop_part_le (*‹?ys ∈ set (chop ?n ?xs) ⟹ length ?ys ≤ ?n›*))[1]) (*discuss goal 2*) apply ((auto simp: median_le_5_in_set (*‹⟦?xs ≠ []; length ?xs ≤ 5⟧ ⟹ median_le_5 ?xs ∈ set ?xs›*) length_chop_part_le (*‹?ys ∈ set (chop ?n ?xs) ⟹ length ?ys ≤ ?n›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹x ∈ ⋃ (set ` set (chop 5 xs))›*) have "… = set xs" apply (subst UN_sets_chop (*‹0 < ?n ⟹ ⋃ (set ` set (chop ?n ?xs)) = set ?xs›*)) (*goals: 1. ‹0 < 5› 2. ‹set xs = set xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . finally (*calculation: ‹x ∈ set xs›*) have "x ∈ set xs" . } ultimately show "((k, ls), k, xs) ∈ measure (length ∘ snd)" and "((k - length ls - length es, gs), k, xs) ∈ measure (length ∘ snd)" using A(1) (*‹¬ length (xs::'a::linorder list) ≤ (20::nat)›*) apply - (*goals: 1. ‹⟦x = median (map median_le_5 (chop 5 xs)); x ∈ set xs; ¬ length xs ≤ 20⟧ ⟹ ((k, ls), k, xs) ∈ measure (length ∘ snd)› 2. ‹⟦x = median (map median_le_5 (chop 5 xs)); x ∈ set xs; ¬ length xs ≤ 20⟧ ⟹ ((k - length ls - length es, gs), k, xs) ∈ measure (length ∘ snd)› discuss goal 1*) apply ((auto simp: eq (*‹ls = filter (λy. y < x) xs› ‹gs = filter ((<) x) xs›*) intro!: length_filter_less[of x] (*‹⟦x ∈ set ?xs; ¬ ?P x⟧ ⟹ length (filter ?P ?xs) < length ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp: eq (*‹ls = filter (λy. y < x) xs› ‹gs = filter ((<) x) xs›*) intro!: length_filter_less[of x] (*‹⟦x ∈ set ?xs; ¬ ?P x⟧ ⟹ length (filter ?P ?xs) < length ?xs›*))[1]) (*proven 2 subgoals*) . qed text ‹ We now have all the ingredients to show that @{const fast_select} terminates and does, indeed, compute the $k$-th order statistic. › termination fast_select by (rule fast_select_termination) theorem fast_select_correct: "k < length xs ⟹ fast_select k xs = select k xs" using fast_select_termination (*‹All fast_select_dom›*) apply (intro fast_select_correct_aux (*‹⟦fast_select_dom (?k::nat, ?xs::?'a list); ?k < length ?xs⟧ ⟹ fast_select ?k ?xs = select ?k ?xs›*)) (*goals: 1. ‹⟦k < length xs; All fast_select_dom⟧ ⟹ fast_select_dom (k, xs)› 2. ‹⟦k < length xs; All fast_select_dom⟧ ⟹ k < length xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . text ‹ The following version is then suitable for code export. › lemma fast_select_code [code]: "fast_select k xs = ( if length xs ≤ 20 then fold insort xs [] ! k else let x = fast_select (((length xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 xs)); (ls, es, gs) = threeway_partition x xs; nl = length ls; ne = nl + length es in if k < nl then fast_select k ls else if k < ne then x else fast_select (k - ne) gs )" apply (subst fast_select.simps (*‹fast_select ?k ?xs = (if length ?xs ≤ 20 then sort ?xs ! ?k else let x = fast_select (((length ?xs + 4) div 5 - 1) div 2) (map median_le_5 (chop 5 ?xs)); (ls, es, gs) = threeway_partition x ?xs in if ?k < length ls then fast_select ?k ls else if ?k < length ls + length es then x else fast_select (?k - length ls - length es) gs)›*)) (*goal: ‹fast_select (k::nat) (xs::'a list) = (if length xs ≤ (20::nat) then fold insort xs [] ! k else let x::'a = fast_select (((length xs + (4::nat)) div (5::nat) - (1::nat)) div (2::nat)) (map median_le_5 (chop (5::nat) xs)); (ls::'a list, es::'a list, gs::'a list) = threeway_partition x xs; nl::nat = length ls; ne::nat = nl + length es in if k < nl then fast_select k ls else if k < ne then x else fast_select (k - ne) gs)›*) by (simp only: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 15 facts*) sort_conv_fold (*‹sort ?xs = fold insort ?xs []›*)) lemma select_code [code]: "select k xs = (if k < length xs then fast_select k xs else Code.abort (STR ''Selection index out of bounds.'') (λ_. select k xs))" proof (cases "k < length xs") (*goals: 1. ‹k < length xs ⟹ select k xs = (if k < length xs then fast_select k xs else Code.abort STR ''Selection index out of bounds.'' (λ_. select k xs))› 2. ‹¬ k < length xs ⟹ select k xs = (if k < length xs then fast_select k xs else Code.abort STR ''Selection index out of bounds.'' (λ_. select k xs))›*) case True (*‹k < length xs›*) thus "?thesis" (*goal: ‹select k xs = (if k < length xs then fast_select k xs else Code.abort STR ''Selection index out of bounds.'' (λ_. select k xs))›*) by (simp only: if_True (*‹(if True then ?x else ?y) = ?x›*) fast_select_correct (*‹?k < length ?xs ⟹ fast_select ?k ?xs = select ?k ?xs›*)) qed (simp_all only: Code.abort_def if_False) (*solved the remaining goal: ‹¬ (k::nat) < length (xs::'a list) ⟹ select k xs = (if k < length xs then fast_select k xs else Code.abort STR ''Selection index out of bounds.'' (λ_::unit. select k xs))›*) end
{ "path": "afp-2025-02-12/thys/Median_Of_Medians_Selection/Median_Of_Medians_Selection.thy", "repo": "afp-2025-02-12", "sha": "b1d590a9250f1b82d18f3d97a37a5813ac71077adf6b461c4904109b245b303d" }
theory Background_on_graphs imports Main begin section ‹Special Graph Theoretical Notions› text ‹This theory provides a background on specialized graph notions and properties. We follow the approach by L. Noschinski available in the AFPs. Since not all elements of Noschinski theory are required, we prefer not to import it. The proof are desiccated in several steps since the focus is clarity instead proof automation. › record ('a,'b) pre_digraph = verts :: "'a set" arcs :: "'b set" tail :: "'b ⇒ 'a" head :: "'b ⇒ 'a" definition tails:: "('a,'b) pre_digraph ⇒ 'a set" where "tails G ≡ {tail G e |e. e ∈ arcs G }" definition tails_set :: "('a,'b) pre_digraph ⇒ 'b set ⇒ 'a set" where "tails_set G E ≡ { tail G e |e. e ∈ E ∧ E ⊆ arcs G }" definition heads:: "('a,'b) pre_digraph ⇒ 'a set" where "heads G ≡ { head G e |e. e ∈ arcs G }" definition heads_set:: "('a,'b) pre_digraph ⇒ 'b set ⇒ 'a set" where "heads_set G E ≡ { head G e |e. e ∈ E ∧ E ⊆ arcs G }" (* Incident vertexes *) definition neighbour:: "('a,'b) pre_digraph ⇒ 'a ⇒ 'a ⇒ bool" where "neighbour G v u ≡ ∃e. e∈ (arcs G) ∧ (( head G e = v ∧ tail G e = u) ∨ (head G e = u ∧ tail G e = v))" (* Vertex neighbourhood *) definition neighbourhood:: "('a,'b) pre_digraph ⇒ 'a ⇒ 'a set" where "neighbourhood G v ≡ {u |u. neighbour G u v}" definition bipartite_digraph:: "('a,'b) pre_digraph ⇒ 'a set ⇒ 'a set ⇒ bool" where "bipartite_digraph G X Y ≡ (X ∪ Y = (verts G)) ∧ X ∩ Y = {} ∧ (∀e ∈ (arcs G).(tail G e) ∈ X ⟷ (head G e) ∈ Y)" (* Left to right directed bipartite digraph *) definition dir_bipartite_digraph:: "('a,'b) pre_digraph ⇒ 'a set ⇒ 'a set ⇒ bool" where "dir_bipartite_digraph G X Y ≡ (bipartite_digraph G X Y) ∧ ((tails G = X) ∧ (∀ e1 ∈ arcs G. ∀ e2 ∈ arcs G. e1 = e2 ⟷ head G e1 = head G e2 ∧ tail G e1 = tail G e2))" (* Directed bipartite digraph with finite neighbourhoods of its tails *) definition K_E_bipartite_digraph:: "('a,'b) pre_digraph ⇒ 'a set ⇒ 'a set ⇒ bool" where "K_E_bipartite_digraph G X Y ≡ (dir_bipartite_digraph G X Y) ∧ (∀x∈X. finite (neighbourhood G x))" (* Matchings in directed bipartite digraphs *) definition dirBD_matching:: "('a,'b) pre_digraph ⇒ 'a set ⇒ 'a set ⇒ 'b set ⇒ bool" where "dirBD_matching G X Y E ≡ dir_bipartite_digraph G X Y ∧ (E ⊆ (arcs G)) ∧ (∀ e1∈E. (∀ e2∈ E. e1 ≠ e2 ⟶ ((head G e1) ≠ (head G e2)) ∧ ((tail G e1) ≠ (tail G e2))))" lemma tail_head: assumes "dir_bipartite_digraph G X Y" and "e ∈ arcs G" shows "(tail G e) ∈ X ∧ (head G e) ∈ Y" using assms (*‹dir_bipartite_digraph G X Y› ‹e ∈ arcs G›*) apply (unfold dir_bipartite_digraph_def (*‹dir_bipartite_digraph ?G ?X ?Y ≡ bipartite_digraph ?G ?X ?Y ∧ tails ?G = ?X ∧ (∀e1∈arcs ?G. ∀e2∈arcs ?G. (e1 = e2) = (head ?G e1 = head ?G e2 ∧ tail ?G e1 = tail ?G e2))›*)) (*goal: ‹tail G e ∈ X ∧ head G e ∈ Y›*) apply (unfold bipartite_digraph_def (*‹bipartite_digraph (?G::(?'a, ?'b) pre_digraph) (?X::?'a set) (?Y::?'a set) ≡ ?X ∪ ?Y = verts ?G ∧ ?X ∩ ?Y = {} ∧ (∀e::?'b∈arcs ?G. (tail ?G e ∈ ?X) = (head ?G e ∈ ?Y))›*)) (*goal: ‹⟦bipartite_digraph G X Y ∧ tails G = X ∧ (∀e1∈arcs G. ∀e2∈arcs G. (e1 = e2) = (head G e1 = head G e2 ∧ tail G e1 = tail G e2)); e ∈ arcs G⟧ ⟹ tail G e ∈ X ∧ head G e ∈ Y›*) apply (unfold tails_def (*‹tails ?G ≡ {tail ?G e |e. e ∈ arcs ?G}›*)) (*goal: ‹⟦((X::'a set) ∪ (Y::'a set) = verts (G::('a, 'b) pre_digraph) ∧ X ∩ Y = {} ∧ (∀e::'b∈arcs G. (tail G e ∈ X) = (head G e ∈ Y))) ∧ tails G = X ∧ (∀e1::'b∈arcs G. ∀e2::'b∈arcs G. (e1 = e2) = (head G e1 = head G e2 ∧ tail G e1 = tail G e2)); (e::'b) ∈ arcs G⟧ ⟹ tail G e ∈ X ∧ head G e ∈ Y›*) by auto lemma tail_head1: assumes "dirBD_matching G X Y E" and "e ∈ E" shows "(tail G e) ∈ X ∧ (head G e) ∈ Y" using assms (*‹dirBD_matching G X Y E› ‹e ∈ E›*) tail_head[of G X Y e] (*‹⟦dir_bipartite_digraph G X Y; e ∈ arcs G⟧ ⟹ tail G e ∈ X ∧ head G e ∈ Y›*) apply (unfold dirBD_matching_def (*‹dirBD_matching ?G ?X ?Y ?E ≡ dir_bipartite_digraph ?G ?X ?Y ∧ ?E ⊆ arcs ?G ∧ (∀e1∈?E. ∀e2∈?E. e1 ≠ e2 ⟶ head ?G e1 ≠ head ?G e2 ∧ tail ?G e1 ≠ tail ?G e2)›*)) (*goal: ‹tail G e ∈ X ∧ head G e ∈ Y›*) by auto lemma dirBD_matching_tail_edge_unicity: "dirBD_matching G X Y E ⟶ (∀e1 ∈ E. (∀ e2∈ E. (tail G e1 = tail G e2) ⟶ e1 = e2))" (* Slederhammer proof: by (meson dirBD_matching_def) *) proof (standard) (*goal: ‹dirBD_matching G X Y E ⟹ ∀e1∈E. ∀e2∈E. tail G e1 = tail G e2 ⟶ e1 = e2›*) assume "dirBD_matching G X Y E" (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) thus "∀e1∈E. ∀e2∈E. tail G e1 = tail G e2 ⟶ e1 = e2" apply (unfold dirBD_matching_def (*‹dirBD_matching (?G::(?'a, ?'b) pre_digraph) (?X::?'a set) (?Y::?'a set) (?E::?'b set) ≡ dir_bipartite_digraph ?G ?X ?Y ∧ ?E ⊆ arcs ?G ∧ (∀e1::?'b∈?E. ∀e2::?'b∈?E. e1 ≠ e2 ⟶ head ?G e1 ≠ head ?G e2 ∧ tail ?G e1 ≠ tail ?G e2)›*)) (*goal: ‹∀e1∈E. ∀e2∈E. tail G e1 = tail G e2 ⟶ e1 = e2›*) by auto qed lemma dirBD_matching_head_edge_unicity: "dirBD_matching G X Y E ⟶ (∀e1 ∈ E. (∀ e2∈ E. (head G e1 = head G e2) ⟶ e1 = e2))" (* Slederhammer proof: by (meson dirBD_matching_def) *) proof (standard) (*goal: ‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set) ⟹ ∀e1::'b∈E. ∀e2::'b∈E. head G e1 = head G e2 ⟶ e1 = e2›*) assume "dirBD_matching G X Y E" (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) thus " ∀e1∈E. ∀e2∈E. head G e1 = head G e2 ⟶ e1 = e2" apply (unfold dirBD_matching_def (*‹dirBD_matching ?G ?X ?Y ?E ≡ dir_bipartite_digraph ?G ?X ?Y ∧ ?E ⊆ arcs ?G ∧ (∀e1∈?E. ∀e2∈?E. e1 ≠ e2 ⟶ head ?G e1 ≠ head ?G e2 ∧ tail ?G e1 ≠ tail ?G e2)›*)) (*goal: ‹∀e1∈E. ∀e2∈E. head G e1 = head G e2 ⟶ e1 = e2›*) by auto qed (* Perfect matching (covering tail vertexes) in directed bipartite digraphs *) definition dirBD_perfect_matching:: "('a,'b) pre_digraph ⇒ 'a set ⇒ 'a set ⇒ 'b set ⇒ bool" where "dirBD_perfect_matching G X Y E ≡ dirBD_matching G X Y E ∧ (tails_set G E = X)" lemma Tail_covering_edge_in_Pef_matching: "∀x∈X. dirBD_perfect_matching G X Y E ⟶ (∃e ∈ E. tail G e = x)" proof (standard) (*goal: ‹⋀x. x ∈ X ⟹ dirBD_perfect_matching G X Y E ⟶ (∃e∈E. tail G e = x)›*) fix x assume Hip1: "x ∈ X" (*‹(x::'a) ∈ (X::'a set)›*) show "dirBD_perfect_matching G X Y E ⟶ (∃e∈E. tail G e = x)" proof (standard) (*goal: ‹dirBD_perfect_matching G X Y E ⟹ ∃e∈E. tail G e = x›*) assume "dirBD_perfect_matching G X Y E" (*‹dirBD_perfect_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) hence "x ∈ tails_set G E" using Hip1 (*‹(x::'a) ∈ (X::'a set)›*) apply (unfold dirBD_perfect_matching_def (*‹dirBD_perfect_matching ?G ?X ?Y ?E ≡ dirBD_matching ?G ?X ?Y ?E ∧ tails_set ?G ?E = ?X›*)) (*goal: ‹x ∈ tails_set G E›*) by auto thus "∃e∈E. tail G e = x " apply (unfold tails_set_def (*‹tails_set ?G ?E ≡ {tail ?G e |e. e ∈ ?E ∧ ?E ⊆ arcs ?G}›*)) (*goal: ‹∃e∈E. tail G e = x›*) by auto qed qed lemma Edge_unicity_in_dirBD_P_matching: "∀x∈X. dirBD_perfect_matching G X Y E ⟶ (∃!e ∈ E. tail G e = x)" (* Shorter proof: by (metis Tail_covering_edge_in_Pef_matching dirBD_matching_def dirBD_perfect_matching_def) *) proof (standard) (*goal: ‹⋀x. x ∈ X ⟹ dirBD_perfect_matching G X Y E ⟶ (∃!e. e ∈ E ∧ tail G e = x)›*) fix x assume Hip1: "x ∈ X" (*‹(x::'a) ∈ (X::'a set)›*) show "dirBD_perfect_matching G X Y E ⟶ (∃!e ∈ E. tail G e = x)" proof (standard) (*goal: ‹dirBD_perfect_matching G X Y E ⟹ ∃!e. e ∈ E ∧ tail G e = x›*) assume Hip2: "dirBD_perfect_matching G X Y E" (*‹dirBD_perfect_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) then obtain "∃e. e ∈ E ∧ tail G e = x" (*goal: ‹(∃e. e ∈ E ∧ tail G e = x ⟹ thesis) ⟹ thesis›*) using Hip1 (*‹x ∈ X›*) Tail_covering_edge_in_Pef_matching[of X G Y E] (*‹∀x∈X. dirBD_perfect_matching G X Y E ⟶ (∃e∈E. tail G e = x)›*) by auto then obtain e where e: "e ∈ E ∧ tail G e = x" (*goal: ‹(⋀e. e ∈ E ∧ tail G e = x ⟹ thesis) ⟹ thesis›*) by auto hence a: "e ∈ E ∧ tail G e = x" by auto show "∃!e. e ∈ E ∧ tail G e = x" proof (standard) (*goals: 1. ‹?a ∈ E ∧ tail G ?a = x› 2. ‹⋀e. e ∈ E ∧ tail G e = x ⟹ e = ?a›*) show "e ∈ E ∧ tail G e = x" using a (*‹e ∈ E ∧ tail G e = x›*) by auto next (*goal: ‹⋀ea. ea ∈ E ∧ tail G ea = x ⟹ ea = e›*) fix e1 assume Hip3: "e1 ∈ E ∧ tail G e1 = x" (*‹(e1::'b) ∈ (E::'b set) ∧ tail (G::('a, 'b) pre_digraph) e1 = (x::'a)›*) hence "tail G e = tail G e1 ∧ e ∈ E ∧ e1 ∈ E" using a (*‹e ∈ E ∧ tail G e = x›*) by auto moreover have "dirBD_matching G X Y E" using Hip2 (*‹dirBD_perfect_matching G X Y E›*) apply (unfold dirBD_perfect_matching_def (*‹dirBD_perfect_matching ?G ?X ?Y ?E ≡ dirBD_matching ?G ?X ?Y ?E ∧ tails_set ?G ?E = ?X›*)) (*goal: ‹dirBD_matching G X Y E›*) by auto ultimately show "e1 = e" using Hip2 (*‹dirBD_perfect_matching G X Y E›*) dirBD_matching_tail_edge_unicity[of G X Y E] (*‹dirBD_matching G X Y E ⟶ (∀e1∈E. ∀e2∈E. tail G e1 = tail G e2 ⟶ e1 = e2)›*) by auto qed qed qed definition E_head :: "('a,'b) pre_digraph ⇒ 'b set ⇒ ('a ⇒ 'a)" where "E_head G E = (λx. (THE y. ∃ e. e ∈ E ∧ tail G e = x ∧ head G e = y))" lemma unicity_E_head1: assumes "dirBD_matching G X Y E ∧ e ∈ E ∧ tail G e = x ∧ head G e = y" shows "(∀z.(∃ e. e ∈ E ∧ tail G e = x ∧ head G e = z)⟶ z = y)" using assms (*‹dirBD_matching G X Y E ∧ e ∈ E ∧ tail G e = x ∧ head G e = y›*) dirBD_matching_tail_edge_unicity (*‹dirBD_matching ?G ?X ?Y ?E ⟶ (∀e1∈?E. ∀e2∈?E. tail ?G e1 = tail ?G e2 ⟶ e1 = e2)›*) by blast lemma unicity_E_head2: assumes "dirBD_matching G X Y E ∧ e ∈ E ∧ tail G e = x ∧ head G e = y" shows "(THE a. ∃ e. e ∈ E ∧ tail G e = x ∧ head G e = a) = y" using assms (*‹dirBD_matching G X Y E ∧ e ∈ E ∧ tail G e = x ∧ head G e = y›*) dirBD_matching_tail_edge_unicity (*‹dirBD_matching ?G ?X ?Y ?E ⟶ (∀e1∈?E. ∀e2∈?E. tail ?G e1 = tail ?G e2 ⟶ e1 = e2)›*) by blast lemma unicity_E_head: assumes "dirBD_matching G X Y E ∧ e ∈ E ∧ tail G e = x ∧ head G e = y" shows "(E_head G E) x = y" using assms (*‹dirBD_matching G X Y E ∧ e ∈ E ∧ tail G e = x ∧ head G e = y›*) unicity_E_head2[of G X Y E e x y] (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set) ∧ (e::'b) ∈ E ∧ tail G e = (x::'a) ∧ head G e = (y::'a) ⟹ (THE a::'a. ∃e::'b. e ∈ E ∧ tail G e = x ∧ head G e = a) = y›*) apply (unfold E_head_def (*‹E_head ?G ?E = (λx. THE y. ∃e. e ∈ ?E ∧ tail ?G e = x ∧ head ?G e = y)›*)) (*goal: ‹E_head G E x = y›*) by auto lemma E_head_image : "dirBD_perfect_matching G X Y E ⟶ (e ∈ E ∧ tail G e = x ⟶ (E_head G E) x = head G e)" (* Shorter proof: by (meson dirBD_perfect_matching_def unicity_E_head) *) proof (standard) (*goal: ‹dirBD_perfect_matching G X Y E ⟹ e ∈ E ∧ tail G e = x ⟶ E_head G E x = head G e›*) assume "dirBD_perfect_matching G X Y E" (*‹dirBD_perfect_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) thus "e ∈ E ∧ tail G e = x ⟶ (E_head G E) x = head G e" using dirBD_matching_tail_edge_unicity[of G X Y E] (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a::type set) (Y::'a::type set) (E::'b::type set) ⟶ (∀e1::'b::type∈E. ∀e2::'b::type∈E. tail G e1 = tail G e2 ⟶ e1 = e2)›*) apply (unfold E_head_def (*‹E_head ?G ?E = (λx. THE y. ∃e. e ∈ ?E ∧ tail ?G e = x ∧ head ?G e = y)›*)) (*goal: ‹e ∈ E ∧ tail G e = x ⟶ E_head G E x = head G e›*) apply (unfold dirBD_perfect_matching_def (*‹dirBD_perfect_matching ?G ?X ?Y ?E ≡ dirBD_matching ?G ?X ?Y ?E ∧ tails_set ?G ?E = ?X›*)) (*goal: ‹⟦dirBD_perfect_matching G X Y E; dirBD_matching G X Y E ⟶ (∀e1∈E. ∀e2∈E. tail G e1 = tail G e2 ⟶ e1 = e2)⟧ ⟹ e ∈ E ∧ tail G e = x ⟶ (THE y. ∃e. e ∈ E ∧ tail G e = x ∧ head G e = y) = head G e›*) by blast qed lemma E_head_in_neighbourhood: "dirBD_matching G X Y E ⟶ e ∈ E ⟶ tail G e = x ⟶ (E_head G E) x ∈ neighbourhood G x" (* Shorter proof: by (metis dirBD_matching_def in_mono mem_Collect_eq neighbour_def neighbourhood_def unicity_E_head) *) apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set) ⟶ (e::'b) ∈ E ⟶ tail G e = (x::'a) ⟶ E_head G E x ∈ neighbourhood G x›*) apply (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set) ⟹ (e::'b) ∈ E ⟶ tail G e = (x::'a) ⟶ E_head G E x ∈ neighbourhood G x›*) proof (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⟦dirBD_matching G X Y E; e ∈ E; tail G e = x⟧ ⟹ E_head G E x ∈ neighbourhood G x›*) assume dir_BDm: "dirBD_matching G X Y E" and ed: "e ∈ E" and hd: "tail G e = x" (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)› ‹(e::'b) ∈ (E::'b set)› ‹tail (G::('a, 'b) pre_digraph) (e::'b) = (x::'a)›*) show "E_head G E x ∈ neighbourhood G x" proof (-) (*goal: ‹E_head G E x ∈ neighbourhood G x›*) have "(∃y. y = head G e)" using hd (*‹tail G e = x›*) by auto then obtain y where y: "y = head G e" (*goal: ‹(⋀y. y = head G e ⟹ thesis) ⟹ thesis›*) by auto hence "(E_head G E) x = y" using dir_BDm (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) ed (*‹e ∈ E›*) hd (*‹tail G e = x›*) unicity_E_head[of G X Y E e x y] (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a::type set) (Y::'a::type set) (E::'b::type set) ∧ (e::'b::type) ∈ E ∧ tail G e = (x::'a::type) ∧ head G e = (y::'a::type) ⟹ E_head G E x = y›*) by auto moreover have "e ∈ (arcs G)" using dir_BDm (*‹dirBD_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) ed (*‹e ∈ E›*) apply (unfold dirBD_matching_def (*‹dirBD_matching ?G ?X ?Y ?E ≡ dir_bipartite_digraph ?G ?X ?Y ∧ ?E ⊆ arcs ?G ∧ (∀e1∈?E. ∀e2∈?E. e1 ≠ e2 ⟶ head ?G e1 ≠ head ?G e2 ∧ tail ?G e1 ≠ tail ?G e2)›*)) (*goal: ‹e ∈ arcs G›*) by auto hence "neighbour G y x" using ed (*‹e ∈ E›*) hd (*‹tail (G::('a, 'b) pre_digraph) (e::'b) = (x::'a)›*) y (*‹y = head G e›*) apply (unfold neighbour_def (*‹neighbour ?G ?v ?u ≡ ∃e. e ∈ arcs ?G ∧ (head ?G e = ?v ∧ tail ?G e = ?u ∨ head ?G e = ?u ∧ tail ?G e = ?v)›*)) (*goal: ‹neighbour (G::('a, 'b) pre_digraph) (y::'a) (x::'a)›*) by auto ultimately show "?thesis" (*goal: ‹E_head G E x ∈ neighbourhood G x›*) using hd (*‹tail G e = x›*) ed (*‹e ∈ E›*) apply (unfold neighbourhood_def (*‹neighbourhood ?G ?v ≡ {u |u. neighbour ?G u ?v}›*)) (*goal: ‹E_head G E x ∈ neighbourhood G x›*) by auto qed qed lemma dirBD_matching_inj_on: "dirBD_perfect_matching G X Y E ⟶ inj_on (E_head G E) X" (* A shorter proof: by (smt (verit, best) E_head_image Edge_unicity_in_dirBD_P_matching dirBD_matching_head_edge_unicity dirBD_perfect_matching_def inj_onI) *) proof (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹dirBD_perfect_matching G X Y E ⟹ inj_on (E_head G E) X›*) assume dirBD_pm: "dirBD_perfect_matching G X Y E" (*‹dirBD_perfect_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) show "inj_on (E_head G E) X" proof (unfold inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*)) (*goal: ‹∀x∈X. ∀y∈X. E_head G E x = E_head G E y ⟶ x = y›*) show "∀x∈X. ∀y∈X. E_head G E x = E_head G E y ⟶ x = y" proof (standard) (*goal: ‹⋀x. x ∈ X ⟹ ∀y∈X. E_head G E x = E_head G E y ⟶ x = y›*) fix x assume 1: "x∈ X" (*‹(x::'a) ∈ (X::'a set)›*) show "∀y∈X. E_head G E x = E_head G E y ⟶ x = y" proof (standard) (*goal: ‹⋀y::'a. y ∈ (X::'a set) ⟹ E_head (G::('a, 'b) pre_digraph) (E::'b set) (x::'a) = E_head G E y ⟶ x = y›*) fix y assume 2: "y∈ X" (*‹(y::'a) ∈ (X::'a set)›*) show "E_head G E x = E_head G E y ⟶ x = y" proof (rule impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹E_head G E x = E_head G E y ⟹ x = y›*) assume same_eheads: "E_head G E x = E_head G E y" (*‹E_head (G::('a, 'b) pre_digraph) (E::'b set) (x::'a) = E_head G E (y::'a)›*) show "x=y" proof (-) (*goal: ‹x = y›*) have hex: " (∃!e ∈ E. tail G e = x)" using dirBD_pm (*‹dirBD_perfect_matching G X Y E›*) "1" (*‹x ∈ X›*) Edge_unicity_in_dirBD_P_matching[of X G Y E] (*‹∀x∈X. dirBD_perfect_matching G X Y E ⟶ (∃!e. e ∈ E ∧ tail G e = x)›*) by auto then obtain ex where hex1: "ex ∈ E ∧ tail G ex = x" (*goal: ‹(⋀ex. ex ∈ E ∧ tail G ex = x ⟹ thesis) ⟹ thesis›*) by auto have ey: " (∃!e ∈ E. tail G e = y)" using dirBD_pm (*‹dirBD_perfect_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) "2" (*‹y ∈ X›*) Edge_unicity_in_dirBD_P_matching[of X G Y E] (*‹∀x∈X. dirBD_perfect_matching G X Y E ⟶ (∃!e. e ∈ E ∧ tail G e = x)›*) by auto then obtain ey where hey1: "ey ∈ E ∧ tail G ey = y" (*goal: ‹(⋀ey. ey ∈ E ∧ tail G ey = y ⟹ thesis) ⟹ thesis›*) by auto have ettx: "E_head G E x = head G ex" using dirBD_pm (*‹dirBD_perfect_matching (G::('a, 'b) pre_digraph) (X::'a set) (Y::'a set) (E::'b set)›*) hex1 (*‹(ex::'b::type) ∈ (E::'b::type set) ∧ tail (G::('a, 'b) pre_digraph) ex = (x::'a::type)›*) E_head_image[of G X Y E ex x] (*‹dirBD_perfect_matching G X Y E ⟶ ex ∈ E ∧ tail G ex = x ⟶ E_head G E x = head G ex›*) by auto have etty: "E_head G E y = head G ey" using dirBD_pm (*‹dirBD_perfect_matching G X Y E›*) hey1 (*‹ey ∈ E ∧ tail G ey = y›*) E_head_image[of G X Y E ey y] (*‹dirBD_perfect_matching G X Y E ⟶ ey ∈ E ∧ tail G ey = y ⟶ E_head G E y = head G ey›*) by auto have same_heads: "head G ex = head G ey" using same_eheads (*‹E_head (G::('a, 'b) pre_digraph) (E::'b set) (x::'a) = E_head G E (y::'a)›*) ettx (*‹E_head G E x = head G ex›*) etty (*‹E_head (G::('a, 'b) pre_digraph) (E::'b set) (y::'a) = head G (ey::'b)›*) by auto hence same_edges: "ex = ey" using dirBD_pm (*‹dirBD_perfect_matching G X Y E›*) "1" (*‹x ∈ X›*) "2" (*‹y ∈ X›*) hex1 (*‹(ex::'b) ∈ (E::'b set) ∧ tail (G::('a, 'b) pre_digraph) ex = (x::'a)›*) hey1 (*‹ey ∈ E ∧ tail G ey = y›*) dirBD_matching_head_edge_unicity[of G X Y E] (*‹dirBD_matching G X Y E ⟶ (∀e1∈E. ∀e2∈E. head G e1 = head G e2 ⟶ e1 = e2)›*) apply (unfold dirBD_perfect_matching_def (*‹dirBD_perfect_matching ?G ?X ?Y ?E ≡ dirBD_matching ?G ?X ?Y ?E ∧ tails_set ?G ?E = ?X›*)) (*goal: ‹ex = ey›*) apply (unfold dirBD_matching_def (*‹dirBD_matching ?G ?X ?Y ?E ≡ dir_bipartite_digraph ?G ?X ?Y ∧ ?E ⊆ arcs ?G ∧ (∀e1∈?E. ∀e2∈?E. e1 ≠ e2 ⟶ head ?G e1 ≠ head ?G e2 ∧ tail ?G e1 ≠ tail ?G e2)›*)) (*goal: ‹⟦head (G::('a, 'b) pre_digraph) (ex::'b::type) = head G (ey::'b::type); dirBD_matching G (X::'a::type set) (Y::'a::type set) (E::'b::type set) ∧ tails_set G E = X; (x::'a::type) ∈ X; (y::'a::type) ∈ X; ex ∈ E ∧ tail G ex = x; ey ∈ E ∧ tail G ey = y; dirBD_matching G X Y E ⟶ (∀e1::'b::type∈E. ∀e2::'b::type∈E. head G e1 = head G e2 ⟶ e1 = e2)⟧ ⟹ ex = ey›*) by blast thus "?thesis" (*goal: ‹x = y›*) using same_edges (*‹ex = ey›*) hex1 (*‹ex ∈ E ∧ tail G ex = x›*) hey1 (*‹ey ∈ E ∧ tail G ey = y›*) by auto qed qed qed qed qed qed end
{ "path": "afp-2025-02-12/thys/Prop_Compactness/Background_on_graphs.thy", "repo": "afp-2025-02-12", "sha": "380216724198501b425f8a7bd1e4b7e8463b59a1cca7efbc71066a7a165604c9" }
section "The Schoenhage-Strassen Algorithm" subsection "Representing $\\mathbb{Z}_{2 ^ n}$" theory Z_mod_power_of_2 imports "Karatsuba.Nat_LSBF_TM" "Finite_Fields.Ring_Characteristic" "Karatsuba.Abstract_Representations_2" "HOL-Number_Theory.Number_Theory" begin context cring begin lemma pow_one_imp_unit: "(n::nat) > 0 ⟹ a ∈ carrier R ⟹ a [^] n = 𝟭 ⟹ a ∈ Units R" using gr0_implies_Suc[of n] (*‹0 < n ⟹ ∃m. n = Suc m›*) nat_pow_Suc2[of a] (*‹a ∈ carrier R ⟹ a [^] Suc ?n = a ⊗ a [^] ?n›*) by (metis Units_one_closed (*‹𝟭 ∈ Units R›*) nat_pow_closed (*‹(?x::'a) ∈ carrier R ⟹ ?x [^] (?n::nat) ∈ carrier R›*) unit_factor (*‹⟦(?a::'a) ⊗ (?b::'a) ∈ Units R; ?a ∈ carrier R; ?b ∈ carrier R⟧ ⟹ ?a ∈ Units R›*)) end definition ensure_length where "ensure_length k xs = take k (fill k xs)" lemma ensure_length_correct[simp]: "length (ensure_length k xs) = k" using fill_def (*‹fill ?n ?xs = ?xs @ replicate (?n - length ?xs) False›*) ensure_length_def (*‹ensure_length ?k ?xs = take ?k (fill ?k ?xs)›*) by simp lemma to_nat_ensure_length: "Nat_LSBF.to_nat xs < 2 ^ n ⟹ Nat_LSBF.to_nat (ensure_length n xs) = Nat_LSBF.to_nat xs" by (simp add: to_nat_take (*‹Nat_LSBF.to_nat (take (?k::nat) (?xs::bool list)) = Nat_LSBF.to_nat ?xs mod (2::nat) ^ ?k›*) ensure_length_def (*‹ensure_length (?k::nat) (?xs::bool list) = take ?k (fill ?k ?xs)›*)) locale int_lsbf_mod = fixes k :: nat assumes k_positive: "k > 0" begin abbreviation n where "n ≡ (2::nat) ^ k" definition Zn where "Zn ≡ residue_ring (int n)" lemma n_positive[simp]: "n > 0" by simp sublocale residues n Zn apply unfold_locales (*top goal: ‹residues (int n)› and 1 goal remains*) subgoal for using k_positive (*‹0 < k›*) by simp subgoal for by (rule Zn_def (*‹Zn ≡ residue_ring (int n)›*)) . definition to_residue_ring :: "nat_lsbf ⇒ int" where "to_residue_ring xs = int (Nat_LSBF.to_nat xs) mod int n" lemma to_residue_ring_in_carrier: "to_residue_ring xs ∈ carrier Zn" unfolding to_residue_ring_def res_carrier_eq (*goal: ‹int (Nat_LSBF.to_nat xs) mod int n ∈ {0..int n - 1}›*) by simp definition from_residue_ring :: "int ⇒ nat_lsbf" where "from_residue_ring x = fill k (Nat_LSBF.from_nat (nat x))" definition reduce where "reduce xs = ensure_length k xs" lemma length_reduce: "length (reduce xs) = k" unfolding reduce_def (*goal: ‹length (ensure_length k xs) = k›*) using fill_def (*‹fill ?n ?xs = ?xs @ replicate (?n - length ?xs) False›*) ensure_length_def (*‹ensure_length ?k ?xs = take ?k (fill ?k ?xs)›*) by simp lemma to_nat_reduce: "Nat_LSBF.to_nat (reduce xs) = Nat_LSBF.to_nat xs mod n" proof (cases "length xs ≤ k") (*goals: 1. ‹length xs ≤ k ⟹ Nat_LSBF.to_nat (reduce xs) = Nat_LSBF.to_nat xs mod n› 2. ‹¬ length xs ≤ k ⟹ Nat_LSBF.to_nat (reduce xs) = Nat_LSBF.to_nat xs mod n›*) case True (*‹length xs ≤ k›*) then have "reduce xs = fill k xs" unfolding reduce_def (*goal: ‹ensure_length (k::nat) (xs::bool list) = fill k xs›*) using fill_def (*‹fill ?n ?xs = ?xs @ replicate (?n - length ?xs) False›*) ensure_length_def (*‹ensure_length ?k ?xs = take ?k (fill ?k ?xs)›*) by simp also (*calculation: ‹reduce xs = fill k xs›*) have "... = xs @ (replicate (k - length xs) False)" using fill_def (*‹fill ?n ?xs = ?xs @ replicate (?n - length ?xs) False›*) by simp finally (*calculation: ‹reduce xs = xs @ replicate (k - length xs) False›*) have "Nat_LSBF.to_nat (reduce xs) = Nat_LSBF.to_nat xs" by simp moreover have "Nat_LSBF.to_nat xs ≤ 2 ^ k - 1" using to_nat_length_upper_bound[of xs] (*‹Nat_LSBF.to_nat xs ≤ 2 ^ length xs - 1›*) True (*‹length (xs::bool list) ≤ (k::nat)›*) by (meson diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*) le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) one_le_numeral (*‹1 ≤ numeral ?n›*) power_increasing (*‹⟦?n ≤ ?N; 1 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?a ^ ?N›*)) hence "Nat_LSBF.to_nat xs < 2 ^ k" using Nat.le_diff_conv2 (*‹?k ≤ ?j ⟹ (?i ≤ ?j - ?k) = (?i + ?k ≤ ?j)›*) by auto ultimately show "?thesis" (*goal: ‹Nat_LSBF.to_nat (reduce xs) = Nat_LSBF.to_nat xs mod n›*) by simp next (*goal: ‹¬ length xs ≤ k ⟹ Nat_LSBF.to_nat (reduce xs) = Nat_LSBF.to_nat xs mod n›*) case False (*‹¬ length xs ≤ k›*) then have "length (take k xs) = k" "fill k xs = xs" "xs = (take k xs) @ (drop k xs)" using fill_def (*‹fill ?n ?xs = ?xs @ replicate (?n - length ?xs) False›*) apply - (*goals: 1. ‹⟦¬ length (xs::bool list) ≤ (k::nat); ⋀(n::nat) xs::bool list. fill n xs = xs @ replicate (n - length xs) False⟧ ⟹ length (take k xs) = k› 2. ‹⟦¬ length (xs::bool list) ≤ (k::nat); ⋀(n::nat) xs::bool list. fill n xs = xs @ replicate (n - length xs) False⟧ ⟹ fill k xs = xs› 3. ‹⟦¬ length (xs::bool list) ≤ (k::nat); ⋀(n::nat) xs::bool list. fill n xs = xs @ replicate (n - length xs) False⟧ ⟹ xs = take k xs @ drop k xs› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . then have "Nat_LSBF.to_nat xs = Nat_LSBF.to_nat (take k xs) + n * Nat_LSBF.to_nat (drop k xs)" using to_nat_app[of "take k xs" "drop k xs"] (*‹Nat_LSBF.to_nat (take (k::nat) (xs::bool list) @ drop k xs) = Nat_LSBF.to_nat (take k xs) + (2::nat) ^ length (take k xs) * Nat_LSBF.to_nat (drop k xs)›*) by simp moreover have "Nat_LSBF.to_nat (take k xs) ≤ 2 ^ k - 1" using to_nat_length_upper_bound[of "take k xs"] (*‹Nat_LSBF.to_nat (take k xs) ≤ 2 ^ length (take k xs) - 1›*) ‹length (take k xs) = k› (*‹length (take k xs) = k›*) by simp hence "Nat_LSBF.to_nat (take k xs) < 2 ^ k" using Nat.le_diff_conv2 (*‹?k ≤ ?j ⟹ (?i ≤ ?j - ?k) = (?i + ?k ≤ ?j)›*) by auto ultimately show "?thesis" (*goal: ‹Nat_LSBF.to_nat (reduce (xs::bool list)) = Nat_LSBF.to_nat xs mod n›*) unfolding reduce_def (*goal: ‹Nat_LSBF.to_nat (ensure_length k xs) = Nat_LSBF.to_nat xs mod n›*) using fill_def (*‹fill ?n ?xs = ?xs @ replicate (?n - length ?xs) False›*) ensure_length_def (*‹ensure_length ?k ?xs = take ?k (fill ?k ?xs)›*) by simp qed (*fun to_ZMod where "to_ZMod xs = ZMod n (int (to_nat xs))" *) definition add_mod where "add_mod x y = reduce (add_nat x y)" definition subtract_mod where "subtract_mod xs ys = (if compare_nat xs ys then reduce (subtract_nat ((fill k xs) @ [True]) ys) else subtract_nat xs ys)" lemma to_nat_add_mod: "Nat_LSBF.to_nat (add_mod x y) = (Nat_LSBF.to_nat x + Nat_LSBF.to_nat y) mod n" by (simp only: to_nat_reduce (*‹Nat_LSBF.to_nat (reduce ?xs) = Nat_LSBF.to_nat ?xs mod n›*) add_nat_correct (*‹Nat_LSBF.to_nat (?x +⇩n ?y) = Nat_LSBF.to_nat ?x + Nat_LSBF.to_nat ?y›*) add_mod_def (*‹add_mod ?x ?y = reduce (?x +⇩n ?y)›*)) lemma to_nat_subtract_mod: "length xs ≤ k ⟹ length ys ≤ k ⟹ int (Nat_LSBF.to_nat (subtract_mod xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod n" proof (cases "Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys") (*goals: 1. ‹⟦length (xs::bool list) ≤ (k::nat); length (ys::bool list) ≤ k; Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys⟧ ⟹ int (Nat_LSBF.to_nat (subtract_mod xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod int n› 2. ‹⟦length (xs::bool list) ≤ (k::nat); length (ys::bool list) ≤ k; ¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys⟧ ⟹ int (Nat_LSBF.to_nat (subtract_mod xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod int n›*) case True (*‹Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys›*) assume "length xs ≤ k" (*‹length (xs::bool list) ≤ (k::nat)›*) assume "length ys ≤ k" (*‹length (ys::bool list) ≤ (k::nat)›*) then have "Nat_LSBF.to_nat ys ≤ n - 1" using to_nat_length_upper_bound[of ys] (*‹Nat_LSBF.to_nat (ys::bool list) ≤ (2::nat) ^ length ys - (1::nat)›*) by (meson diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*) le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) one_le_numeral (*‹1 ≤ numeral ?n›*) power_increasing (*‹⟦?n ≤ ?N; 1 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?a ^ ?N›*)) then have "Nat_LSBF.to_nat ys ≤ Nat_LSBF.to_nat xs + n" by simp have "int (Nat_LSBF.to_nat (subtract_nat (fill k xs @ [True]) ys) mod n) = int ((Nat_LSBF.to_nat xs + n - Nat_LSBF.to_nat ys) mod n)" by (simp add: subtract_nat_correct (*‹Nat_LSBF.to_nat (?xs -⇩n ?ys) = Nat_LSBF.to_nat ?xs - Nat_LSBF.to_nat ?ys›*) to_nat_app (*‹Nat_LSBF.to_nat (?xs @ ?ys) = Nat_LSBF.to_nat ?xs + 2 ^ length ?xs * Nat_LSBF.to_nat ?ys›*) length_fill (*‹length ?xs ≤ ?n ⟹ length (fill ?n ?xs) = ?n›*) ‹length xs ≤ k›) also (*calculation: ‹int (Nat_LSBF.to_nat (fill (k::nat) (xs::bool list) @ [True] -⇩n (ys::bool list)) mod n) = int ((Nat_LSBF.to_nat xs + n - Nat_LSBF.to_nat ys) mod n)›*) have "... = (int (Nat_LSBF.to_nat xs + n - Nat_LSBF.to_nat ys)) mod n" using zmod_int (*‹int (?m mod ?n) = int ?m mod int ?n›*) by simp also (*calculation: ‹int (Nat_LSBF.to_nat (fill k xs @ [True] -⇩n ys) mod n) = int (Nat_LSBF.to_nat xs + n - Nat_LSBF.to_nat ys) mod int n›*) have "... = (int (Nat_LSBF.to_nat xs) + int n - int (Nat_LSBF.to_nat ys)) mod n" using ‹Nat_LSBF.to_nat ys ≤ Nat_LSBF.to_nat xs + n› (*‹Nat_LSBF.to_nat ys ≤ Nat_LSBF.to_nat xs + n›*) by (simp add: of_nat_diff (*‹?n ≤ ?m ⟹ of_nat (?m - ?n) = of_nat ?m - of_nat ?n›*)) also (*calculation: ‹int (Nat_LSBF.to_nat (fill k xs @ [True] -⇩n ys) mod n) = (int (Nat_LSBF.to_nat xs) + int n - int (Nat_LSBF.to_nat ys)) mod int n›*) have "... = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod n" by (metis diff_add_eq (*‹?a - ?b + ?c = ?a + ?c - ?b›*) int_ops( (*‹int (numeral ?n) = numeral ?n›*) 3) mod_add_self2 (*‹(?a + ?b) mod ?b = ?a mod ?b›*) of_nat_power (*‹of_nat (?m ^ ?n) = of_nat ?m ^ ?n›*)) finally (*calculation: ‹int (Nat_LSBF.to_nat (fill k xs @ [True] -⇩n ys) mod n) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod int n›*) have "int (Nat_LSBF.to_nat (subtract_nat (fill k xs @ [True]) ys) mod n) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod n" . then show "?thesis" (*goal: ‹int (Nat_LSBF.to_nat (subtract_mod xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod int n›*) by (simp add: subtract_mod_def (*‹subtract_mod ?xs ?ys = (if ?xs ≤⇩n ?ys then reduce (fill k ?xs @ [True] -⇩n ?ys) else ?xs -⇩n ?ys)›*) compare_nat_correct (*‹(?xs ≤⇩n ?ys) = (Nat_LSBF.to_nat ?xs ≤ Nat_LSBF.to_nat ?ys)›*) to_nat_reduce (*‹Nat_LSBF.to_nat (reduce ?xs) = Nat_LSBF.to_nat ?xs mod n›*) True (*‹Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goal: ‹⟦length xs ≤ k; length ys ≤ k; ¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys⟧ ⟹ int (Nat_LSBF.to_nat (subtract_mod xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod int n›*) case False (*‹¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys›*) assume "length xs ≤ k" (*‹length (xs::bool list) ≤ (k::nat)›*) then have "Nat_LSBF.to_nat xs ≤ n - 1" using to_nat_length_upper_bound[of xs] (*‹Nat_LSBF.to_nat (xs::bool list) ≤ (2::nat) ^ length xs - (1::nat)›*) by (meson diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*) le_trans (*‹⟦?i ≤ ?j; ?j ≤ ?k⟧ ⟹ ?i ≤ ?k›*) one_le_numeral (*‹1 ≤ numeral ?n›*) power_increasing (*‹⟦?n ≤ ?N; 1 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?a ^ ?N›*)) assume "length ys ≤ k" (*‹length (ys::bool list) ≤ (k::nat)›*) from False (*‹¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys›*) have "int (Nat_LSBF.to_nat (subtract_nat xs ys)) = int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)" by (simp add: subtract_nat_correct (*‹Nat_LSBF.to_nat (?xs -⇩n ?ys) = Nat_LSBF.to_nat ?xs - Nat_LSBF.to_nat ?ys›*)) moreover have "... ∈ {0..<n}" proof (-) (*goal: ‹int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ∈ {0..<int n}›*) have "int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ≤ int (Nat_LSBF.to_nat xs)" by simp also (*calculation: ‹int (Nat_LSBF.to_nat (xs::bool list)) - int (Nat_LSBF.to_nat (ys::bool list)) ≤ int (Nat_LSBF.to_nat xs)›*) have "... ≤ n - 1" using ‹Nat_LSBF.to_nat xs ≤ n - 1› (*‹Nat_LSBF.to_nat xs ≤ n - 1›*) n_positive (*‹(0::nat) < n›*) by simp also (*calculation: ‹⟦int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ∈ UNIV; int (Nat_LSBF.to_nat xs) ∈ UNIV; int (n - 1) ∈ UNIV⟧ ⟹ int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ≤ int (n - 1)›*) have "... < n" by simp finally (*calculation: ‹⟦int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ∈ UNIV; int (Nat_LSBF.to_nat xs) ∈ UNIV; int (n - 1) ∈ UNIV⟧ ⟹ int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) < int n›*) have "int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) < n" by simp moreover have "int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ≥ 0" using ‹¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys› (*‹¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys›*) by simp ultimately show "?thesis" (*goal: ‹int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys) ∈ {0..<int n}›*) by simp qed ultimately have "int (Nat_LSBF.to_nat (subtract_nat xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod n" by simp then show "?thesis" (*goal: ‹int (Nat_LSBF.to_nat (subtract_mod xs ys)) = (int (Nat_LSBF.to_nat xs) - int (Nat_LSBF.to_nat ys)) mod int n›*) by (simp add: subtract_mod_def (*‹subtract_mod ?xs ?ys = (if ?xs ≤⇩n ?ys then reduce (fill k ?xs @ [True] -⇩n ?ys) else ?xs -⇩n ?ys)›*) compare_nat_correct (*‹(?xs ≤⇩n ?ys) = (Nat_LSBF.to_nat ?xs ≤ Nat_LSBF.to_nat ?ys)›*) to_nat_reduce (*‹Nat_LSBF.to_nat (reduce ?xs) = Nat_LSBF.to_nat ?xs mod n›*) False (*‹¬ Nat_LSBF.to_nat xs ≤ Nat_LSBF.to_nat ys›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) qed lemma length_subtract_mod: "length xs ≤ k ⟹ length ys ≤ k ⟹ length (subtract_mod xs ys) ≤ k" unfolding subtract_mod_def (*goal: ‹⟦length xs ≤ k; length ys ≤ k⟧ ⟹ length (if xs ≤⇩n ys then reduce (fill k xs @ [True] -⇩n ys) else xs -⇩n ys) ≤ k›*) apply (cases "compare_nat xs ys") (*goal: ‹⟦length xs ≤ k; length ys ≤ k⟧ ⟹ length (if xs ≤⇩n ys then reduce (fill k xs @ [True] -⇩n ys) else xs -⇩n ys) ≤ k›*) using subtract_nat_aux[of xs ys] (*‹Nat_LSBF.to_nat (xs -⇩n ys) = Nat_LSBF.to_nat xs - Nat_LSBF.to_nat ys ∧ length (xs -⇩n ys) ≤ max (length xs) (length ys)›*) apply - (*goals: 1. ‹⟦length (xs::bool list) ≤ (k::nat); length (ys::bool list) ≤ k; xs ≤⇩n ys; Nat_LSBF.to_nat (xs -⇩n ys) = Nat_LSBF.to_nat xs - Nat_LSBF.to_nat ys ∧ length (xs -⇩n ys) ≤ max (length xs) (length ys)⟧ ⟹ length (if xs ≤⇩n ys then reduce (fill k xs @ [True] -⇩n ys) else xs -⇩n ys) ≤ k› 2. ‹⟦length (xs::bool list) ≤ (k::nat); length (ys::bool list) ≤ k; ¬ xs ≤⇩n ys; Nat_LSBF.to_nat (xs -⇩n ys) = Nat_LSBF.to_nat xs - Nat_LSBF.to_nat ys ∧ length (xs -⇩n ys) ≤ max (length xs) (length ys)⟧ ⟹ length (if xs ≤⇩n ys then reduce (fill k xs @ [True] -⇩n ys) else xs -⇩n ys) ≤ k› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) reduce_def (*‹reduce ?xs = ensure_length k ?xs›*) ensure_length_def (*‹ensure_length ?k ?xs = take ?k (fill ?k ?xs)›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) reduce_def (*‹reduce ?xs = ensure_length k ?xs›*) ensure_length_def (*‹ensure_length ?k ?xs = take ?k (fill ?k ?xs)›*))[1]) (*proven 2 subgoals*) . lemma add_mod_correct: "to_residue_ring (add_mod x y) = to_residue_ring x ⊕⇘Zn⇙ to_residue_ring y" proof (-) (*goal: ‹to_residue_ring (add_mod (x::bool list) (y::bool list)) = to_residue_ring x ⊕⇘Zn⇙ to_residue_ring y›*) have "to_residue_ring (add_mod x y) = to_residue_ring (reduce (add_nat x y))" unfolding add_mod_def (*goal: ‹to_residue_ring (reduce (x +⇩n y)) = to_residue_ring (reduce (x +⇩n y))›*) by simp also (*calculation: ‹to_residue_ring (add_mod x y) = to_residue_ring (reduce (x +⇩n y))›*) have "... = (Nat_LSBF.to_nat x + Nat_LSBF.to_nat y) mod n" using to_nat_reduce (*‹Nat_LSBF.to_nat (reduce ?xs) = Nat_LSBF.to_nat ?xs mod n›*) add_nat_correct (*‹Nat_LSBF.to_nat (?x +⇩n ?y) = Nat_LSBF.to_nat ?x + Nat_LSBF.to_nat ?y›*) to_residue_ring_def (*‹to_residue_ring ?xs = int (Nat_LSBF.to_nat ?xs) mod int n›*) by simp also (*calculation: ‹to_residue_ring (add_mod x y) = int ((Nat_LSBF.to_nat x + Nat_LSBF.to_nat y) mod n)›*) have "... = (int (Nat_LSBF.to_nat x) mod n + (int (Nat_LSBF.to_nat y) mod n)) mod n" by (simp add: zmod_int (*‹int (?m mod ?n) = int ?m mod int ?n›*) mod_add_eq (*‹(?a mod ?c + ?b mod ?c) mod ?c = (?a + ?b) mod ?c›*)) finally (*calculation: ‹to_residue_ring (add_mod x y) = (int (Nat_LSBF.to_nat x) mod int n + int (Nat_LSBF.to_nat y) mod int n) mod int n›*) show "?thesis" (*goal: ‹to_residue_ring (add_mod (x::bool list) (y::bool list)) = to_residue_ring x ⊕⇘Zn⇙ to_residue_ring y›*) by (simp only: res_add_eq (*‹(?x::int) ⊕⇘Zn⇙ (?y::int) = (?x + ?y) mod int n›*) to_residue_ring_def (*‹to_residue_ring (?xs::bool list) = int (Nat_LSBF.to_nat ?xs) mod int n›*)) qed lemma subtract_mod_correct: assumes "length x ≤ k" assumes "length y ≤ k" assumes "n > 1" shows "to_residue_ring (subtract_mod x y) = to_residue_ring x ⊖⇘Zn⇙ to_residue_ring y" proof (-) (*goal: ‹to_residue_ring (subtract_mod x y) = to_residue_ring x ⊖⇘Zn⇙ to_residue_ring y›*) have "to_residue_ring (subtract_mod x y) = int (Nat_LSBF.to_nat (subtract_mod x y)) mod int n" unfolding to_residue_ring_def (*goal: ‹int (Nat_LSBF.to_nat (subtract_mod x y)) mod int n = int (Nat_LSBF.to_nat (subtract_mod x y)) mod int n›*) by argo also (*calculation: ‹to_residue_ring (subtract_mod x y) = int (Nat_LSBF.to_nat (subtract_mod x y)) mod int n›*) have "... = (int (Nat_LSBF.to_nat x) - (int (Nat_LSBF.to_nat y))) mod int n" by (simp add: to_nat_subtract_mod (*‹⟦length ?xs ≤ k; length ?ys ≤ k⟧ ⟹ int (Nat_LSBF.to_nat (subtract_mod ?xs ?ys)) = (int (Nat_LSBF.to_nat ?xs) - int (Nat_LSBF.to_nat ?ys)) mod int n›*) assms (*‹length x ≤ k› ‹length y ≤ k› ‹1 < n›*)) also (*calculation: ‹to_residue_ring (subtract_mod x y) = (int (Nat_LSBF.to_nat x) - int (Nat_LSBF.to_nat y)) mod int n›*) have "... = (to_residue_ring x + (- to_residue_ring y mod n)) mod n" unfolding diff_conv_add_uminus to_residue_ring_def (*goal: ‹(int (Nat_LSBF.to_nat x) + - int (Nat_LSBF.to_nat y)) mod int n = (int (Nat_LSBF.to_nat x) mod int n + - (int (Nat_LSBF.to_nat y) mod int n) mod int n) mod int n›*) by (simp add: mod_add_eq (*‹(?a mod ?c + ?b mod ?c) mod ?c = (?a + ?b) mod ?c›*) mod_diff_right_eq (*‹(?a - ?b mod ?c) mod ?c = (?a - ?b) mod ?c›*)) also (*calculation: ‹to_residue_ring (subtract_mod x y) = (to_residue_ring x + - to_residue_ring y mod int n) mod int n›*) have "... = (to_residue_ring x + (⊖⇘residue_ring n⇙ (to_residue_ring y mod n))) mod n" apply (intro_cong "[cong_tag_2 (mod), cong_tag_2 (+)]" more: refl) (*goal: ‹(to_residue_ring x + - to_residue_ring y mod int n) mod int n = (to_residue_ring x + ⊖⇘residue_ring (int n)⇙ (to_residue_ring y mod int n)) mod int n›*) using residues.neg_cong[symmetric, of n] (*‹residues (int n) ⟹ - ?x mod int n = ⊖⇘residue_ring (int n)⇙ (?x mod int n)›*) unfolding residues_def (*goal: ‹- to_residue_ring (y::bool list) mod int n = ⊖⇘residue_ring (int n)⇙ (to_residue_ring y mod int n)›*) using ‹n > 1› (*‹(1::nat) < n›*) by (metis int_ops( (*‹int 1 = 1›*) 2) nat_int_comparison( (*‹(?a < ?b) = (int ?a < int ?b)›*) 2)) also (*calculation: ‹to_residue_ring (subtract_mod (x::bool list) (y::bool list)) = (to_residue_ring x + ⊖⇘residue_ring (int n)⇙ (to_residue_ring y mod int n)) mod int n›*) have "... = to_residue_ring x ⊖⇘residue_ring n⇙ (to_residue_ring y mod n)" unfolding a_minus_def (*goal: ‹(to_residue_ring x + ⊖⇘residue_ring (int n)⇙ (to_residue_ring y mod int n)) mod int n = to_residue_ring x ⊕⇘residue_ring (int n)⇙ ⊖⇘residue_ring (int n)⇙ (to_residue_ring y mod int n)›*) by (simp add: residue_ring_def (*‹residue_ring ?m = ⦇carrier = {0..?m - 1}, monoid.mult = λx y. x * y mod ?m, one = 1, zero = 0, add = λx y. (x + y) mod ?m⦈›*)) also (*calculation: ‹to_residue_ring (subtract_mod (x::bool list) (y::bool list)) = to_residue_ring x ⊖⇘residue_ring (int n)⇙ to_residue_ring y mod int n›*) have "to_residue_ring y mod n = to_residue_ring y" using to_residue_ring_def (*‹to_residue_ring ?xs = int (Nat_LSBF.to_nat ?xs) mod int n›*) by simp finally (*calculation: ‹to_residue_ring (subtract_mod x y) = to_residue_ring x ⊖⇘residue_ring (int n)⇙ to_residue_ring y›*) show "?thesis" (*goal: ‹to_residue_ring (subtract_mod x y) = to_residue_ring x ⊖⇘Zn⇙ to_residue_ring y›*) unfolding Zn_def (*goal: ‹to_residue_ring (subtract_mod x y) = to_residue_ring x ⊖⇘residue_ring (int n)⇙ to_residue_ring y›*) . qed lemma length_from_residue_ring: "x < 2 ^ k ⟹ length (from_residue_ring x) = k" proof (-) (*goal: ‹x < 2 ^ k ⟹ length (from_residue_ring x) = k›*) assume "x < 2 ^ k" (*‹(x::int) < (2::int) ^ (k::nat)›*) have "truncated (Nat_LSBF.from_nat (nat x))" using truncate_from_nat (*‹truncated (Nat_LSBF.from_nat ?x)›*) by simp moreover have "Nat_LSBF.to_nat (Nat_LSBF.from_nat (nat x)) = nat x" using nat_lsbf.to_from (*‹Nat_LSBF.to_nat ∘ Nat_LSBF.from_nat = id›*) by simp ultimately have "length (Nat_LSBF.from_nat (nat x)) ≤ k" using ‹x < 2 ^ k› (*‹(x::int) < (2::int) ^ (k::nat)›*) to_nat_length_bound_truncated (*‹⟦truncated ?xs; Nat_LSBF.to_nat ?xs < 2 ^ ?n⟧ ⟹ length ?xs ≤ ?n›*) by simp then show "length (from_residue_ring x) = k" unfolding from_residue_ring_def (*goal: ‹length (fill k (Nat_LSBF.from_nat (nat x))) = k›*) using length_fill (*‹length ?xs ≤ ?n ⟹ length (fill ?n ?xs) = ?n›*) by simp qed interpretation int_lsbf_mod: abstract_representation_2 from_residue_ring to_residue_ring "{0..<int n}" rewrites "int_lsbf_mod.reduce = reduce" and "int_lsbf_mod.representations = {x :: bool list. length x = k}" proof (-) (*goals: 1. ‹abstract_representation_2 from_residue_ring to_residue_ring {0..<int n}› 2. ‹abstract_representation_2.reduce from_residue_ring to_residue_ring = reduce› 3. ‹abstract_representation_2.representations from_residue_ring {0..<int n} = {x. length x = k}›*) show "abstract_representation_2 from_residue_ring to_residue_ring {0..<int n}" apply unfold_locales (*goal: ‹abstract_representation_2 from_residue_ring to_residue_ring {0::int..<int n}›*) unfolding to_residue_ring_def from_residue_ring_def (*goals: 1. ‹⋀x. x ∈ {0..<int n} ⟹ int (Nat_LSBF.to_nat (fill k (Nat_LSBF.from_nat (nat x)))) mod int n = x› 2. ‹⋀y. int (Nat_LSBF.to_nat y) mod int n ∈ {0..<int n}›*) (*goals: 1. ‹⋀x. x ∈ {0..<int n} ⟹ int (Nat_LSBF.to_nat (fill k (Nat_LSBF.from_nat (nat x)))) mod int n = x› 2. ‹⋀y. int (Nat_LSBF.to_nat y) mod int n ∈ {0..<int n}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then interpret int_lsbf_mod: abstract_representation_2 from_residue_ring to_residue_ring "{0..<int n}" . show "int_lsbf_mod.reduce = reduce" unfolding int_lsbf_mod.reduce_def reduce_def (*goal: ‹(λx. from_residue_ring (to_residue_ring x)) = ensure_length k›*) apply (intro ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹(λx. from_residue_ring (to_residue_ring x)) = ensure_length k›*) apply (intro nat_lsbf_eqI (*‹⟦Nat_LSBF.to_nat ?xs = Nat_LSBF.to_nat ?ys; length ?xs = length ?ys⟧ ⟹ ?xs = ?ys›*)) (*goal: ‹⋀x. from_residue_ring (to_residue_ring x) = ensure_length k x›*) subgoal for x unfolding from_residue_ring_def to_nat_fill to_nat_from_nat (*goal: ‹nat (to_residue_ring (x::bool list)) = Nat_LSBF.to_nat (ensure_length (k::nat) x)›*) proof (-) (*goal: ‹nat (to_residue_ring x) = Nat_LSBF.to_nat (ensure_length k x)›*) have "nat (to_residue_ring x) = nat (int (Nat_LSBF.to_nat x) mod int n)" by (simp add: from_residue_ring_def (*‹from_residue_ring (?x::int) = fill (k::nat) (Nat_LSBF.from_nat (nat ?x))›*) to_residue_ring_def (*‹to_residue_ring (?xs::bool list) = int (Nat_LSBF.to_nat ?xs) mod int n›*) ensure_length_def (*‹ensure_length (?k::nat) (?xs::bool list) = take ?k (fill ?k ?xs)›*) to_nat_take (*‹Nat_LSBF.to_nat (take (?k::nat) (?xs::bool list)) = Nat_LSBF.to_nat ?xs mod (2::nat) ^ ?k›*)) also (*calculation: ‹nat (to_residue_ring x) = nat (int (Nat_LSBF.to_nat x) mod int n)›*) have "... = Nat_LSBF.to_nat x mod n" unfolding zmod_int[symmetric] nat_int (*goal: ‹Nat_LSBF.to_nat (x::bool list) mod n = Nat_LSBF.to_nat x mod n›*) by (rule refl (*‹?t = ?t›*)) also (*calculation: ‹nat (to_residue_ring x) = Nat_LSBF.to_nat x mod n›*) have "... = Nat_LSBF.to_nat (ensure_length k x)" unfolding ensure_length_def (*goal: ‹Nat_LSBF.to_nat (x::bool list) mod n = Nat_LSBF.to_nat (take (k::nat) (fill k x))›*) by (simp add: to_nat_take (*‹Nat_LSBF.to_nat (take ?k ?xs) = Nat_LSBF.to_nat ?xs mod 2 ^ ?k›*)) finally (*calculation: ‹nat (to_residue_ring x) = Nat_LSBF.to_nat (ensure_length k x)›*) show "nat (to_residue_ring x) = ..." . qed subgoal for x proof (-) (*goal: ‹length (from_residue_ring (to_residue_ring (x::bool list))) = length (ensure_length (k::nat) x)›*) have "length (from_residue_ring (to_residue_ring x)) = k" apply (intro length_from_residue_ring (*‹?x < 2 ^ k ⟹ length (from_residue_ring ?x) = k›*)) (*goal: ‹length (from_residue_ring (to_residue_ring x)) = k›*) unfolding to_residue_ring_def (*goal: ‹int (Nat_LSBF.to_nat x) mod int n < 2 ^ k›*) using mod_less_divisor[OF n_positive] (*‹(?m::nat) mod n < n›*) by simp then show "?thesis" (*goal: ‹length (from_residue_ring (to_residue_ring (x::bool list))) = length (ensure_length (k::nat) x)›*) by simp qed . show "int_lsbf_mod.representations = {x :: bool list. length x = k}" proof (intro equalityI (*‹⟦?A ⊆ ?B; ?B ⊆ ?A⟧ ⟹ ?A = ?B›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) (*goals: 1. ‹⋀x. x ∈ int_lsbf_mod.representations ⟹ x ∈ {x. length x = k}› 2. ‹⋀x. x ∈ {x. length x = k} ⟹ x ∈ int_lsbf_mod.representations›*) fix x assume "x ∈ int_lsbf_mod.representations" (*‹(x::bool list) ∈ int_lsbf_mod.representations›*) then obtain y where "y < 2 ^ k" "x = from_residue_ring y" (*goal: ‹(⋀y. ⟦y < 2 ^ k; x = from_residue_ring y⟧ ⟹ thesis) ⟹ thesis›*) unfolding int_lsbf_mod.representations_def (*goal: ‹(⋀y. ⟦y < 2 ^ k; x = from_residue_ring y⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "length x = k" by (simp add: length_from_residue_ring (*‹?x < 2 ^ k ⟹ length (from_residue_ring ?x) = k›*)) then show "x ∈ {x. length x = k}" by simp next (*goal: ‹⋀x. x ∈ {x. length x = k} ⟹ x ∈ int_lsbf_mod.representations›*) fix x :: "bool list" assume "x ∈ {x. length x = k}" (*‹(x::bool list) ∈ {x::bool list. length x = (k::nat)}›*) then have "length x = k" by simp have "from_residue_ring (to_residue_ring x) = int_lsbf_mod.reduce x" using int_lsbf_mod.reduce_def (*‹local.int_lsbf_mod.reduce (?x::bool list) ≡ from_residue_ring (to_residue_ring ?x)›*) by simp also (*calculation: ‹from_residue_ring (to_residue_ring x) = local.int_lsbf_mod.reduce x›*) have "... = reduce x" using ‹int_lsbf_mod.reduce = reduce› (*‹local.int_lsbf_mod.reduce = reduce›*) by simp also (*calculation: ‹from_residue_ring (to_residue_ring x) = reduce x›*) have "... = x" using ‹length x = k› (*‹length x = k›*) unfolding reduce_def ensure_length_def fill_def (*goal: ‹take k (x @ replicate (k - length x) False) = x›*) by simp finally (*calculation: ‹from_residue_ring (to_residue_ring x) = x›*) show "x ∈ int_lsbf_mod.representations" unfolding int_lsbf_mod.representations_def (*goal: ‹x ∈ from_residue_ring ` {0..<int n}›*) using int_lsbf_mod.to_type_in_represented_set (*‹to_residue_ring ?y ∈ {0..<int n}›*) by (metis imageI (*‹(?x::?'a) ∈ (?A::?'a set) ⟹ (?f::?'a ⇒ ?'b) ?x ∈ ?f ` ?A›*)) qed qed lemma add_mod_closed: "length (add_mod x y) = k" using int_lsbf_mod.range_reduce (*‹{x. length x = k} = range reduce›*) add_mod_def (*‹add_mod ?x ?y = reduce (?x +⇩n ?y)›*) by blast end end
{ "path": "afp-2025-02-12/thys/Schoenhage_Strassen/Schoenhage_Strassen/Z_mod_power_of_2.thy", "repo": "afp-2025-02-12", "sha": "a668b61b3b0790ec55c99e83a41c0c17e0b357ec017ded6f9e002e64f2c4f3c4" }
(* * May's Theorem, following Sen. * (C)opyright Peter Gammie, peteg42 at gmail.com, commenced October 2008. * License: BSD *) (*<*) theory May imports SCFs begin (*>*) section‹May's Theorem› text ‹May's Theorem \<^cite>‹"May:1952"› provides a characterisation of majority voting in terms of four conditions that appear quite natural for \emph{a priori} unbiased social choice scenarios. It can be seen as a refinement of some earlier work by Arrow \<^cite>‹‹Chapter V.1› in "Arrow:1963"›. The following is a mechanisation of Sen's generalisation \<^cite>‹‹Chapter~5*› in "Sen:70a"›; originally Arrow and May consider only two alternatives, whereas Sen's model maps profiles of full RPRs to a possibly intransitive relation that does at least generate a choice set that satisfies May's conditions.› subsection‹May's Conditions› text ‹The condition of \emph{anonymity} asserts that the individuals' identities are not considered by the choice rule. Rather than talk about permutations we just assert the result of the SCF is the same when the profile is composed with an arbitrary bijection on the set of individuals.› definition anonymous :: "('a, 'i) SCF ⇒ 'a set ⇒ 'i set ⇒ bool" where "anonymous scf A Is ≡ (∀P f x y. profile A Is P ∧ bij_betw f Is Is ∧ x ∈ A ∧ y ∈ A ⟶ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y))" lemma anonymousI[intro]: "(⋀P f x y. ⟦ profile A Is P; bij_betw f Is Is; x ∈ A; y ∈ A ⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y)) ⟹ anonymous scf A Is" unfolding anonymous_def (*goal: ‹(⋀P f x y. ⟦profile A Is P; bij_betw f Is Is; x ∈ A; y ∈ A⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y)) ⟹ ∀P f x y. profile A Is P ∧ bij_betw f Is Is ∧ x ∈ A ∧ y ∈ A ⟶ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y)›*) by simp lemma anonymousD: "⟦ anonymous scf A Is; profile A Is P; bij_betw f Is Is; x ∈ A; y ∈ A ⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y)" unfolding anonymous_def (*goal: ‹⟦∀P f x y. profile A Is P ∧ bij_betw f Is Is ∧ x ∈ A ∧ y ∈ A ⟶ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y); profile A Is P; bij_betw f Is Is; x ∈ A; y ∈ A⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (P ∘ f))⇙≼ y)›*) by simp text ‹Similarly, an SCF is \emph{neutral} if it is insensitive to the identity of the alternatives. This is Sen's characterisation \<^cite>‹‹p72› in "Sen:70a"›.› definition neutral :: "('a, 'i) SCF ⇒ 'a set ⇒ 'i set ⇒ bool" where "neutral scf A Is ≡ (∀P P' x y z w. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ z ∈ A ∧ w ∈ A ∧ (∀i ∈ Is. x ⇘(P i)⇙≼ y ⟷ z ⇘(P' i)⇙≼ w) ∧ (∀i ∈ Is. y ⇘(P i)⇙≼ x ⟷ w ⇘(P' i)⇙≼ z) ⟶ ((x ⇘(scf P)⇙≼ y ⟷ z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x ⟷ w ⇘(scf P')⇙≼ z)))" lemma neutralI[intro]: "(⋀P P' x y z w. ⟦ profile A Is P; profile A Is P'; {x,y,z,w} ⊆ A; ⋀i. i ∈ Is ⟹ x ⇘(P i)⇙≼ y ⟷ z ⇘(P' i)⇙≼ w; ⋀i. i ∈ Is ⟹ y ⇘(P i)⇙≼ x ⟷ w ⇘(P' i)⇙≼ z ⟧ ⟹ ((x ⇘(scf P)⇙≼ y ⟷ z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x ⟷ w ⇘(scf P')⇙≼ z))) ⟹ neutral scf A Is" unfolding neutral_def (*goal: ‹(⋀P P' x y z w. ⟦profile A Is P; profile A Is P'; {x, y, z, w} ⊆ A; ⋀i. i ∈ Is ⟹ (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w); ⋀i. i ∈ Is ⟹ (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x) = (w ⇘(scf P')⇙≼ z)) ⟹ ∀P P' x y z w. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ z ∈ A ∧ w ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w)) ∧ (∀i∈Is. (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)) ⟶ (x ⇘(scf P)⇙≼ y) = (z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x) = (w ⇘(scf P')⇙≼ z)›*) by simp lemma neutralD: "⟦ neutral scf A Is; profile A Is P; profile A Is P'; {x,y,z,w} ⊆ A; ⋀i. i ∈ Is ⟹ x ⇘(P i)⇙≼ y ⟷ z ⇘(P' i)⇙≼ w; ⋀i. i ∈ Is ⟹ y ⇘(P i)⇙≼ x ⟷ w ⇘(P' i)⇙≼ z ⟧ ⟹ (x ⇘(scf P)⇙≼ y ⟷ z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x ⟷ w ⇘(scf P')⇙≼ z)" unfolding neutral_def (*goal: ‹⟦∀P P' x y z w. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ z ∈ A ∧ w ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w)) ∧ (∀i∈Is. (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)) ⟶ (x ⇘(scf P)⇙≼ y) = (z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x) = (w ⇘(scf P')⇙≼ z); profile A Is P; profile A Is P'; {x, y, z, w} ⊆ A; ⋀i. i ∈ Is ⟹ (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w); ⋀i. i ∈ Is ⟹ (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x) = (w ⇘(scf P')⇙≼ z)›*) by simp text ‹Neutrality implies independence of irrelevant alternatives.› lemma neutral_iia: "neutral scf A Is ⟹ iia scf A Is" unfolding neutral_def (*goal: ‹∀P P' x y z w. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ z ∈ A ∧ w ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w)) ∧ (∀i∈Is. (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)) ⟶ (x ⇘(scf P)⇙≼ y) = (z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x) = (w ⇘(scf P')⇙≼ z) ⟹ iia scf A Is›*) apply rule (*goal: ‹∀P P' x y z w. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ z ∈ A ∧ w ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w)) ∧ (∀i∈Is. (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)) ⟶ (x ⇘(scf P)⇙≼ y) = (z ⇘(scf P')⇙≼ w) ∧ (y ⇘(scf P)⇙≼ x) = (w ⇘(scf P')⇙≼ z) ⟹ iia scf A Is›*) by auto text ‹\emph{Positive responsiveness} is a bit like non-manipulability: if one individual improves their opinion of $x$, then the result should shift in favour of $x$.› definition positively_responsive :: "('a, 'i) SCF ⇒ 'a set ⇒ 'i set ⇒ bool" where "positively_responsive scf A Is ≡ (∀P P' x y. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i ∈ Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k ∈ Is. (x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y) ∨ (y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y)) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y)" lemma positively_responsiveI[intro]: assumes I: "⋀P P' x y. ⟦ profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦ i ∈ Is; x ⇘(P i)⇙≺ y ⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦ i ∈ Is; x ⇘(P i)⇙≈ y ⟧ ⟹ x ⇘(P' i)⇙≼ y; ∃k ∈ Is. (x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y) ∨ (y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y); x ⇘(scf P)⇙≼ y ⟧ ⟹ x ⇘(scf P')⇙≺ y" shows "positively_responsive scf A Is" unfolding positively_responsive_def (*goal: ‹∀(P::'a ⇒ ('b × 'b) set) (P'::'a ⇒ ('b × 'b) set) (x::'b) y::'b. profile (A::'b set) (Is::'a set) P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i::'a∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k::'a∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘((scf::('a ⇒ ('b × 'b) set) ⇒ ('b × 'b) set) P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y›*) by (blast intro: I (*‹⟦profile (A::'b set) (Is::'a set) (?P::'a ⇒ ('b × 'b) set); profile A Is (?P'::'a ⇒ ('b × 'b) set); (?x::'b) ∈ A; (?y::'b) ∈ A; ⋀i::'a. ⟦i ∈ Is; ?x ⇘(?P i)⇙≺ ?y⟧ ⟹ ?x ⇘(?P' i)⇙≺ ?y; ⋀i::'a. ⟦i ∈ Is; ?x ⇘(?P i)⇙≈ ?y⟧ ⟹ ?x ⇘(?P' i)⇙≼ ?y; ∃k::'a∈Is. ?x ⇘(?P k)⇙≈ ?y ∧ ?x ⇘(?P' k)⇙≺ ?y ∨ ?y ⇘(?P k)⇙≺ ?x ∧ ?x ⇘(?P' k)⇙≼ ?y; ?x ⇘((scf::('a ⇒ ('b × 'b) set) ⇒ ('b × 'b) set) ?P)⇙≼ ?y⟧ ⟹ ?x ⇘(scf ?P')⇙≺ ?y›*)) lemma positively_responsiveD: "⟦ positively_responsive scf A Is; profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦ i ∈ Is; x ⇘(P i)⇙≺ y ⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦ i ∈ Is; x ⇘(P i)⇙≈ y ⟧ ⟹ x ⇘(P' i)⇙≼ y; ∃k ∈ Is. (x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y) ∨ (y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y); x ⇘(scf P)⇙≼ y ⟧ ⟹ x ⇘(scf P')⇙≺ y" unfolding positively_responsive_def (*goal: ‹⟦∀P P' x y. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y; profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; ∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y; x ⇘(scf P)⇙≼ y⟧ ⟹ x ⇘(scf P')⇙≺ y›*) apply clarsimp (*goal: ‹⟦∀P P' x y. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y; profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; ∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y; x ⇘(scf P)⇙≼ y⟧ ⟹ x ⇘(scf P')⇙≺ y›*) apply (erule allE[where x=P] (*‹⟦∀x. ?P x; ?P P ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀k. ⟦∀P P' x y. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y; profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; x ⇘(scf P)⇙≼ y; k ∈ Is; x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y⟧ ⟹ x ⇘(scf P')⇙≺ y›*) apply (erule allE[where x=P'] (*‹⟦∀x. ?P x; ?P P' ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀k. ⟦profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; x ⇘(scf P)⇙≼ y; k ∈ Is; x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y; ∀P' x y. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y⟧ ⟹ x ⇘(scf P')⇙≺ y›*) apply (erule allE[where x=x] (*‹⟦∀x. ?P x; ?P x ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀k. ⟦profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; x ⇘(scf P)⇙≼ y; k ∈ Is; x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y; ∀x y. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y⟧ ⟹ x ⇘(scf P')⇙≺ y›*) apply (erule allE[where x=y] (*‹⟦∀x. ?P x; ?P y ⟹ ?R⟧ ⟹ ?R›*)) (*goal: ‹⋀k::'a::type. ⟦profile (A::'b::type set) (Is::'a::type set) (P::'a::type ⇒ ('b::type × 'b::type) set); profile A Is (P'::'a::type ⇒ ('b::type × 'b::type) set); (x::'b::type) ∈ A; (y::'b::type) ∈ A; ⋀i::'a::type. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i::'a::type. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; x ⇘((scf::('a::type ⇒ ('b::type × 'b::type) set) ⇒ ('b::type × 'b::type) set) P)⇙≼ y; k ∈ Is; x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y; ∀y::'b::type. profile A Is P ∧ profile A Is P' ∧ x ∈ A ∧ y ∈ A ∧ (∀i::'a::type∈Is. (x ⇘(P i)⇙≺ y ⟶ x ⇘(P' i)⇙≺ y) ∧ (x ⇘(P i)⇙≈ y ⟶ x ⇘(P' i)⇙≼ y)) ∧ (∃k::'a::type∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y) ⟶ x ⇘(scf P)⇙≼ y ⟶ x ⇘(scf P')⇙≺ y⟧ ⟹ x ⇘(scf P')⇙≺ y›*) by auto subsection‹The Method of Majority Decision satisfies May's conditions› text ‹The \emph{method of majority decision} (MMD) says that if the number of individuals who strictly prefer $x$ to $y$ is larger than or equal to those who strictly prefer the converse, then $x\ R\ y$. Note that this definition only makes sense for a finite population.› definition MMD :: "'i set ⇒ ('a, 'i) SCF" where "MMD Is P ≡ { (x, y) . card { i ∈ Is. x ⇘(P i)⇙≺ y } ≥ card { i ∈ Is. y ⇘(P i)⇙≺ x } }" text ‹The first part of May's Theorem establishes that the conditions are consistent, by showing that they are satisfied by MMD.› lemma MMD_l2r: fixes A :: "'a set" and Is :: "'i set" assumes finiteIs: "finite Is" shows "SCF (MMD Is) A Is universal_domain" and "anonymous (MMD Is) A Is" and "neutral (MMD Is) A Is" and "positively_responsive (MMD Is) A Is" proof (-) (*goals: 1. ‹SCF (MMD (Is::'i set)) (A::'a set) Is universal_domain› 2. ‹anonymous (MMD (Is::'i set)) (A::'a set) Is› 3. ‹neutral (MMD (Is::'i set)) (A::'a set) Is› 4. ‹positively_responsive (MMD (Is::'i set)) (A::'a set) Is›*) show "SCF (MMD Is) A Is universal_domain" proof (standard) (*goal: ‹⋀P::'i::type ⇒ ('a::type × 'a::type) set. universal_domain (A::'a::type set) (Is::'i::type set) P ⟹ complete A (MMD Is P)›*) fix P show "complete A (MMD Is P)" apply (rule completeI (*‹(⋀(x::?'a) y::?'a. ⟦x ∈ (?A::?'a set); y ∈ ?A; x ≠ y⟧ ⟹ x ⇘(?r::(?'a × ?'a) set)⇙≼ y ∨ y ⇘?r⇙≼ x) ⟹ complete ?A ?r›*)) (*goal: ‹complete A (MMD Is P)›*) apply (unfold MMD_def (*‹MMD ?Is ?P ≡ {(x, y). card {i ∈ ?Is. y ⇘(?P i)⇙≺ x} ≤ card {i ∈ ?Is. x ⇘(?P i)⇙≺ y}}›*)) (*goal: ‹⋀x y. ⟦x ∈ A; y ∈ A; x ≠ y⟧ ⟹ x ⇘(MMD Is P)⇙≼ y ∨ y ⇘(MMD Is P)⇙≼ x›*) apply simp (*goal: ‹⋀(x::'a) y::'a. ⟦x ∈ (A::'a set); y ∈ A; x ≠ y⟧ ⟹ x ⇘{(x::'a, y::'a). card {i::'i ∈ Is::'i set. y ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ x} ≤ card {i::'i ∈ Is. x ⇘(P i)⇙≺ y}}⇙≼ y ∨ y ⇘{(x::'a, y::'a). card {i::'i ∈ Is. y ⇘(P i)⇙≺ x} ≤ card {i::'i ∈ Is. x ⇘(P i)⇙≺ y}}⇙≼ x›*) by arith qed show "anonymous (MMD Is) A Is" proof (standard) (*goal: ‹⋀P f x y. ⟦profile A Is P; bij_betw f Is Is; x ∈ A; y ∈ A⟧ ⟹ (x ⇘(MMD Is P)⇙≼ y) = (x ⇘(MMD Is (P ∘ f))⇙≼ y)›*) fix P fix x :: 'a and y :: 'a fix f assume bijf: "bij_betw f Is Is" (*‹bij_betw (f::'i ⇒ 'i) (Is::'i set) Is›*) show "(x ⇘(MMD Is P)⇙≼ y) = (x ⇘(MMD Is (P ∘ f))⇙≼ y)" using card_compose_bij[OF bijf, where P = "λi. x ⇘(P i)⇙≺ y"] (*‹card {a ∈ Is. x ⇘(P (f a))⇙≺ y} = card {a ∈ Is. x ⇘(P a)⇙≺ y}›*) card_compose_bij[OF bijf, where P = "λi. y ⇘(P i)⇙≺ x"] (*‹card {a ∈ Is. y ⇘(P (f a))⇙≺ x} = card {a ∈ Is. y ⇘(P a)⇙≺ x}›*) unfolding MMD_def (*goal: ‹((x::'a) ⇘{(x::'a, y::'a). card {i::'i ∈ Is::'i set. y ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ x} ≤ card {i::'i ∈ Is. x ⇘(P i)⇙≺ y}}⇙≼ (y::'a)) = (x ⇘{(x::'a, y::'a). card {i::'i ∈ Is. y ⇘((P ∘ (f::'i ⇒ 'i)) i)⇙≺ x} ≤ card {i::'i ∈ Is. x ⇘((P ∘ f) i)⇙≺ y}}⇙≼ y)›*) by simp qed next (*goals: 1. ‹neutral (MMD Is) A Is› 2. ‹positively_responsive (MMD Is) A Is›*) show "neutral (MMD Is) A Is" proof (standard) (*goal: ‹⋀P P' x y z w. ⟦profile A Is P; profile A Is P'; {x, y, z, w} ⊆ A; ⋀i. i ∈ Is ⟹ (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w); ⋀i. i ∈ Is ⟹ (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)⟧ ⟹ (x ⇘(MMD Is P)⇙≼ y) = (z ⇘(MMD Is P')⇙≼ w) ∧ (y ⇘(MMD Is P)⇙≼ x) = (w ⇘(MMD Is P')⇙≼ z)›*) fix P and P' fix x and y and z and w assume xyzwA: "{x,y,z,w} ⊆ A" (*‹{x::'a, y::'a, z::'a, w::'a} ⊆ (A::'a set)›*) assume xyzw: "⋀i. i ∈ Is ⟹ (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w)" and yxwz: "⋀i. i ∈ Is ⟹ (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)" (*‹(?i::'i) ∈ (Is::'i set) ⟹ ((x::'a) ⇘((P::'i ⇒ ('a × 'a) set) ?i)⇙≼ (y::'a)) = ((z::'a) ⇘((P'::'i ⇒ ('a × 'a) set) ?i)⇙≼ (w::'a))› ‹(?i::'i) ∈ (Is::'i set) ⟹ ((y::'a) ⇘((P::'i ⇒ ('a × 'a) set) ?i)⇙≼ (x::'a)) = ((w::'a) ⇘((P'::'i ⇒ ('a × 'a) set) ?i)⇙≼ (z::'a))›*) from xyzwA (*‹{x, y, z, w} ⊆ A›*) xyzw (*‹?i ∈ Is ⟹ (x ⇘(P ?i)⇙≼ y) = (z ⇘(P' ?i)⇙≼ w)›*) yxwz (*‹?i ∈ Is ⟹ (y ⇘(P ?i)⇙≼ x) = (w ⇘(P' ?i)⇙≼ z)›*) have "{ i ∈ Is. x ⇘(P i)⇙≺ y } = { i ∈ Is. z ⇘(P' i)⇙≺ w }" and "{ i ∈ Is. y ⇘(P i)⇙≺ x } = { i ∈ Is. w ⇘(P' i)⇙≺ z }" unfolding strict_pref_def (*goals: 1. ‹{i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i} = {i ∈ Is. z ⇘(P' i)⇙≼ w ∧ (w, z) ∉ P' i}› 2. ‹{i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} = {i ∈ Is. w ⇘(P' i)⇙≼ z ∧ (z, w) ∉ P' i}›*) apply - (*goals: 1. ‹⟦{x, y, z, w} ⊆ A; ⋀i. i ∈ Is ⟹ (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w); ⋀i. i ∈ Is ⟹ (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)⟧ ⟹ {i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i} = {i ∈ Is. z ⇘(P' i)⇙≼ w ∧ (w, z) ∉ P' i}› 2. ‹⟦{x, y, z, w} ⊆ A; ⋀i. i ∈ Is ⟹ (x ⇘(P i)⇙≼ y) = (z ⇘(P' i)⇙≼ w); ⋀i. i ∈ Is ⟹ (y ⇘(P i)⇙≼ x) = (w ⇘(P' i)⇙≼ z)⟧ ⟹ {i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} = {i ∈ Is. w ⇘(P' i)⇙≼ z ∧ (z, w) ∉ P' i}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "(x ⇘(MMD Is P)⇙≼ y) = (z ⇘(MMD Is P')⇙≼ w) ∧ (y ⇘(MMD Is P)⇙≼ x) = (w ⇘(MMD Is P')⇙≼ z)" unfolding MMD_def (*goal: ‹(x ⇘{(x, y). card {i ∈ Is. y ⇘(P i)⇙≺ x} ≤ card {i ∈ Is. x ⇘(P i)⇙≺ y}}⇙≼ y) = (z ⇘{(x, y). card {i ∈ Is. y ⇘(P' i)⇙≺ x} ≤ card {i ∈ Is. x ⇘(P' i)⇙≺ y}}⇙≼ w) ∧ (y ⇘{(x, y). card {i ∈ Is. y ⇘(P i)⇙≺ x} ≤ card {i ∈ Is. x ⇘(P i)⇙≺ y}}⇙≼ x) = (w ⇘{(x, y). card {i ∈ Is. y ⇘(P' i)⇙≺ x} ≤ card {i ∈ Is. x ⇘(P' i)⇙≺ y}}⇙≼ z)›*) by simp qed next (*goal: ‹positively_responsive (MMD (Is::'i::type set)) (A::'a::type set) Is›*) show "positively_responsive (MMD Is) A Is" proof (standard) (*goal: ‹⋀P P' x y. ⟦profile A Is P; profile A Is P'; x ∈ A; y ∈ A; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y; ∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y; x ⇘(MMD Is P)⇙≼ y⟧ ⟹ x ⇘(MMD Is P')⇙≺ y›*) fix P and P' assume profileP: "profile A Is P" (*‹profile (A::'a set) (Is::'i set) (P::'i ⇒ ('a × 'a) set)›*) fix x and y assume xyA: "x ∈ A" "y ∈ A" (*‹(x::'a) ∈ (A::'a set)› ‹(y::'a) ∈ (A::'a set)›*) assume xPy: "⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≺ y⟧ ⟹ x ⇘(P' i)⇙≺ y" and xIy: "⋀i. ⟦i ∈ Is; x ⇘(P i)⇙≈ y⟧ ⟹ x ⇘(P' i)⇙≼ y" and k: "∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y" and xRSCFy: "x ⇘(MMD Is P)⇙≼ y" (*‹⟦(?i::'i) ∈ (Is::'i set); (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) ?i)⇙≺ (y::'a)⟧ ⟹ x ⇘((P'::'i ⇒ ('a × 'a) set) ?i)⇙≺ y› ‹⟦(?i::'i) ∈ (Is::'i set); (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) ?i)⇙≈ (y::'a)⟧ ⟹ x ⇘((P'::'i ⇒ ('a × 'a) set) ?i)⇙≼ y› ‹∃k::'i∈Is::'i set. (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) k)⇙≈ (y::'a) ∧ x ⇘((P'::'i ⇒ ('a × 'a) set) k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y› ‹(x::'a) ⇘(MMD (Is::'i set) (P::'i ⇒ ('a × 'a) set))⇙≼ (y::'a)›*) from k (*‹∃k∈Is. x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y›*) obtain k where kIs: "k ∈ Is" and kcond: "(x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y) ∨ (y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y)" (*goal: ‹(⋀k::'i. ⟦k ∈ (Is::'i set); (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) k)⇙≈ (y::'a) ∧ x ⇘((P'::'i ⇒ ('a × 'a) set) k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast let ?xPy = "{ i ∈ Is. x ⇘(P i)⇙≺ y }" let ?xP'y = "{ i ∈ Is. x ⇘(P' i)⇙≺ y }" let ?yPx = "{ i ∈ Is. y ⇘(P i)⇙≺ x }" let ?yP'x = "{ i ∈ Is. y ⇘(P' i)⇙≺ x }" from profileP (*‹profile (A::'a set) (Is::'i set) (P::'i ⇒ ('a × 'a) set)›*) xyA (*‹x ∈ A› ‹y ∈ A›*) xPy (*‹⟦?i ∈ Is; x ⇘(P ?i)⇙≺ y⟧ ⟹ x ⇘(P' ?i)⇙≺ y›*) xIy (*‹⟦?i ∈ Is; x ⇘(P ?i)⇙≈ y⟧ ⟹ x ⇘(P' ?i)⇙≼ y›*) have yP'xyPx: "?yP'x ⊆ ?yPx" unfolding strict_pref_def indifferent_pref_def (*goal: ‹{i ∈ Is. y ⇘(P' i)⇙≼ x ∧ (x, y) ∉ P' i} ⊆ {i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i}›*) by (blast dest: rpr_complete (*‹⟦rpr ?A ?r; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x ⇘?r⇙≼ ?y ∨ ?y ⇘?r⇙≼ ?x›*)) with finiteIs (*‹finite Is›*) have yP'xyPxC: "card ?yP'x ≤ card ?yPx" by (blast intro: card_mono (*‹⟦finite ?B; ?A ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) from finiteIs (*‹finite Is›*) xPy (*‹⟦?i ∈ Is; x ⇘(P ?i)⇙≺ y⟧ ⟹ x ⇘(P' ?i)⇙≺ y›*) have xPyxP'yC: "card ?xPy ≤ card ?xP'y" by (blast intro: card_mono (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ card ?A ≤ card ?B›*) finite_subset (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); finite ?B⟧ ⟹ finite ?A›*)) show "x ⇘(MMD Is P')⇙≺ y" proof (standard) (*goals: 1. ‹x ⇘(MMD Is P')⇙≼ y› 2. ‹(y, x) ∉ MMD Is P'›*) from xRSCFy (*‹x ⇘(MMD Is P)⇙≼ y›*) xPyxP'yC (*‹card {i ∈ Is. x ⇘(P i)⇙≺ y} ≤ card {i ∈ Is. x ⇘(P' i)⇙≺ y}›*) yP'xyPxC (*‹card {i ∈ Is. y ⇘(P' i)⇙≺ x} ≤ card {i ∈ Is. y ⇘(P i)⇙≺ x}›*) show "x ⇘(MMD Is P')⇙≼ y" unfolding MMD_def (*goal: ‹x ⇘{(x, y). card {i ∈ Is. y ⇘(P' i)⇙≺ x} ≤ card {i ∈ Is. x ⇘(P' i)⇙≺ y}}⇙≼ y›*) by auto next (*goal: ‹(y::'a, x::'a) ∉ MMD (Is::'i set) (P'::'i ⇒ ('a × 'a) set)›*) { assume xIky: "x ⇘(P k)⇙≈ y" and xP'ky: "x ⇘(P' k)⇙≺ y" (*‹(x::'a) ⇘((P::'i ⇒ ('a × 'a) set) (k::'i))⇙≈ (y::'a)› ‹(x::'a) ⇘((P'::'i ⇒ ('a × 'a) set) (k::'i))⇙≺ (y::'a)›*) have "card ?xPy < card ?xP'y" proof (-) (*goal: ‹card {i ∈ Is. x ⇘(P i)⇙≺ y} < card {i ∈ Is. x ⇘(P' i)⇙≺ y}›*) from xIky (*‹x ⇘(P k)⇙≈ y›*) have knP: "k ∉ ?xPy" unfolding indifferent_pref_def strict_pref_def (*goal: ‹k ∉ {i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i}›*) by blast from kIs (*‹(k::'i) ∈ (Is::'i set)›*) xP'ky (*‹x ⇘(P' k)⇙≺ y›*) have kP': "k ∈ ?xP'y" by simp from finiteIs (*‹finite Is›*) xPy (*‹⟦?i ∈ Is; x ⇘(P ?i)⇙≺ y⟧ ⟹ x ⇘(P' ?i)⇙≺ y›*) knP (*‹k ∉ {i ∈ Is. x ⇘(P i)⇙≺ y}›*) kP' (*‹(k::'i) ∈ {i::'i ∈ Is::'i set. (x::'a) ⇘((P'::'i ⇒ ('a × 'a) set) i)⇙≺ (y::'a)}›*) show "?thesis" (*goal: ‹card {i ∈ Is. x ⇘(P i)⇙≺ y} < card {i ∈ Is. x ⇘(P' i)⇙≺ y}›*) by (blast intro: psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed with xRSCFy (*‹x ⇘(MMD Is P)⇙≼ y›*) yP'xyPxC (*‹card {i::'i::type ∈ Is::'i::type set. (y::'a::type) ⇘((P'::'i::type ⇒ ('a::type × 'a::type) set) i)⇙≺ (x::'a::type)} ≤ card {i::'i::type ∈ Is. y ⇘((P::'i::type ⇒ ('a::type × 'a::type) set) i)⇙≺ x}›*) have "card ?yP'x < card ?xP'y" unfolding MMD_def (*goal: ‹card {i::'i ∈ Is::'i set. (y::'a) ⇘((P'::'i ⇒ ('a × 'a) set) i)⇙≺ (x::'a)} < card {i::'i ∈ Is. x ⇘(P' i)⇙≺ y}›*) by auto } moreover { assume yPkx: "y ⇘(P k)⇙≺ x" and xR'ky: "x ⇘(P' k)⇙≼ y" (*‹(y::'a) ⇘((P::'i ⇒ ('a × 'a) set) (k::'i))⇙≺ (x::'a)› ‹(x::'a) ⇘((P'::'i ⇒ ('a × 'a) set) (k::'i))⇙≼ (y::'a)›*) have "card ?yP'x < card ?yPx" proof (-) (*goal: ‹card {i::'i ∈ Is::'i set. (y::'a) ⇘((P'::'i ⇒ ('a × 'a) set) i)⇙≺ (x::'a)} < card {i::'i ∈ Is. y ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ x}›*) from kIs (*‹(k::'i) ∈ (Is::'i set)›*) yPkx (*‹y ⇘(P k)⇙≺ x›*) have kP: "k ∈ ?yPx" by simp from kIs (*‹k ∈ Is›*) xR'ky (*‹x ⇘(P' k)⇙≼ y›*) have knP': "k ∉ ?yP'x" unfolding strict_pref_def (*goal: ‹k ∉ {i ∈ Is. y ⇘(P' i)⇙≼ x ∧ (x, y) ∉ P' i}›*) by blast from yP'xyPx (*‹{i ∈ Is. y ⇘(P' i)⇙≺ x} ⊆ {i ∈ Is. y ⇘(P i)⇙≺ x}›*) kP (*‹k ∈ {i ∈ Is. y ⇘(P i)⇙≺ x}›*) knP' (*‹k ∉ {i ∈ Is. y ⇘(P' i)⇙≺ x}›*) have "?yP'x ⊂ ?yPx" by blast with finiteIs (*‹finite Is›*) show "?thesis" (*goal: ‹card {i ∈ Is. y ⇘(P' i)⇙≺ x} < card {i ∈ Is. y ⇘(P i)⇙≺ x}›*) by (blast intro: psubset_card_mono (*‹⟦finite ?B; ?A ⊂ ?B⟧ ⟹ card ?A < card ?B›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed with xRSCFy (*‹x ⇘(MMD Is P)⇙≼ y›*) xPyxP'yC (*‹card {i ∈ Is. x ⇘(P i)⇙≺ y} ≤ card {i ∈ Is. x ⇘(P' i)⇙≺ y}›*) have "card ?yP'x < card ?xP'y" unfolding MMD_def (*goal: ‹card {i ∈ Is. y ⇘(P' i)⇙≺ x} < card {i ∈ Is. x ⇘(P' i)⇙≺ y}›*) by auto } moreover note kcond (*‹x ⇘(P k)⇙≈ y ∧ x ⇘(P' k)⇙≺ y ∨ y ⇘(P k)⇙≺ x ∧ x ⇘(P' k)⇙≼ y›*) ultimately show "¬(y ⇘(MMD Is P')⇙≼ x)" unfolding MMD_def (*goal: ‹(y, x) ∉ {(x, y). card {i ∈ Is. y ⇘(P' i)⇙≺ x} ≤ card {i ∈ Is. x ⇘(P' i)⇙≺ y}}›*) by auto qed qed qed subsection‹Everything satisfying May's conditions is the Method of Majority Decision› text‹Now show that MMD is the only SCF that satisfies these conditions.› text ‹Firstly develop some theory about exchanging alternatives $x$ and $y$ in profile $P$.› definition swapAlts :: "'a ⇒ 'a ⇒ 'a ⇒ 'a" where "swapAlts a b u ≡ if u = a then b else if u = b then a else u" lemma swapAlts_in_set_iff: "{a, b} ⊆ A ⟹ swapAlts a b u ∈ A ⟷ u ∈ A" unfolding swapAlts_def (*goal: ‹{a, b} ⊆ A ⟹ ((if u = a then b else if u = b then a else u) ∈ A) = (u ∈ A)›*) by (simp split: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) definition swapAltsP :: "('a, 'i) Profile ⇒ 'a ⇒ 'a ⇒ ('a, 'i) Profile" where "swapAltsP P a b ≡ (λi. { (u, v) . (swapAlts a b u, swapAlts a b v) ∈ P i })" lemma swapAltsP_ab: "a ⇘(P i)⇙≼ b ⟷ b ⇘(swapAltsP P a b i)⇙≼ a" "b ⇘(P i)⇙≼ a ⟷ a ⇘(swapAltsP P a b i)⇙≼ b" unfolding swapAltsP_def swapAlts_def (*goals: 1. ‹(a ⇘(P i)⇙≼ b) = (b ⇘{(u, v). (if u = a then b else if u = b then a else u) ⇘(P i)⇙≼ (if v = a then b else if v = b then a else v)}⇙≼ a)› 2. ‹(b ⇘(P i)⇙≼ a) = (a ⇘{(u, v). (if u = a then b else if u = b then a else u) ⇘(P i)⇙≼ (if v = a then b else if v = b then a else v)}⇙≼ b)›*) (*goals: 1. ‹(a ⇘(P i)⇙≼ b) = (b ⇘{(u, v). (if u = a then b else if u = b then a else u) ⇘(P i)⇙≼ (if v = a then b else if v = b then a else v)}⇙≼ a)› 2. ‹(b ⇘(P i)⇙≼ a) = (a ⇘{(u, v). (if u = a then b else if u = b then a else u) ⇘(P i)⇙≼ (if v = a then b else if v = b then a else v)}⇙≼ b)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma profile_swapAltsP: assumes profileP: "profile A Is P" and abA: "{a,b} ⊆ A" shows "profile A Is (swapAltsP P a b)" proof (rule profileI (*‹⟦⋀i. i ∈ ?Is ⟹ rpr ?A (?P i); ?Is ≠ {}⟧ ⟹ profile ?A ?Is ?P›*)) (*goals: 1. ‹⋀i. i ∈ Is ⟹ rpr A (swapAltsP P a b i)› 2. ‹Is ≠ {}›*) from profileP (*‹profile (A::'a::type set) (Is::'b::type set) (P::'b::type ⇒ ('a::type × 'a::type) set)›*) show "Is ≠ {}" by (rule profile_non_empty (*‹profile ?A ?Is ?P ⟹ ?Is ≠ {}›*)) next (*goal: ‹⋀i. i ∈ Is ⟹ rpr A (swapAltsP P a b i)›*) fix i assume iIs: "i ∈ Is" (*‹(i::'b) ∈ (Is::'b set)›*) show "rpr A (swapAltsP P a b i)" proof (rule rprI (*‹⟦complete ?A ?r; refl_on ?A ?r; trans ?r⟧ ⟹ rpr ?A ?r›*)) (*goals: 1. ‹complete A (swapAltsP P a b i)› 2. ‹refl_on A (swapAltsP P a b i)› 3. ‹trans (swapAltsP P a b i)›*) show "refl_on A (swapAltsP P a b i)" proof (rule refl_onI (*‹⟦(?r::(?'a × ?'a) set) ⊆ (?A::?'a set) × ?A; ⋀x::?'a. x ∈ ?A ⟹ x ⇘?r⇙≼ x⟧ ⟹ refl_on ?A ?r›*)) (*goals: 1. ‹swapAltsP (P::'b ⇒ ('a × 'a) set) (a::'a) (b::'a) (i::'b) ⊆ (A::'a set) × A› 2. ‹⋀x::'a. x ∈ (A::'a set) ⟹ x ⇘(swapAltsP (P::'b ⇒ ('a × 'a) set) (a::'a) (b::'a) (i::'b))⇙≼ x›*) from profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) abA (*‹{a::'a, b::'a} ⊆ (A::'a set)›*) show "swapAltsP P a b i ⊆ A × A" unfolding swapAltsP_def (*goal: ‹{(u, v). swapAlts a b u ⇘(P i)⇙≼ swapAlts a b v} ⊆ A × A›*) by (blast dest: swapAlts_in_set_iff (*‹{?a, ?b} ⊆ ?A ⟹ (swapAlts ?a ?b ?u ∈ ?A) = (?u ∈ ?A)›*)) from profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) abA (*‹{a::'a, b::'a} ⊆ (A::'a set)›*) show "⋀x. x ∈ A ⟹ x ⇘(swapAltsP P a b i)⇙≼ x" unfolding swapAltsP_def swapAlts_def (*goal: ‹⋀x. x ∈ A ⟹ x ⇘{(u, v). (if u = a then b else if u = b then a else u) ⇘(P i)⇙≼ (if v = a then b else if v = b then a else v)}⇙≼ x›*) by auto qed next (*goals: 1. ‹complete A (swapAltsP P a b i)› 2. ‹trans (swapAltsP P a b i)›*) from profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) abA (*‹{a, b} ⊆ A›*) show "complete A (swapAltsP P a b i)" unfolding swapAltsP_def (*goal: ‹complete A {(u, v). swapAlts a b u ⇘(P i)⇙≼ swapAlts a b v}›*) apply - (*goal: ‹complete A {(u, v). swapAlts a b u ⇘(P i)⇙≼ swapAlts a b v}›*) apply (rule completeI (*‹(⋀(x::?'a::type) y::?'a::type. ⟦x ∈ (?A::?'a::type set); y ∈ ?A; x ≠ y⟧ ⟹ x ⇘(?r::(?'a::type × ?'a::type) set)⇙≼ y ∨ y ⇘?r⇙≼ x) ⟹ complete ?A ?r›*)) (*goal: ‹⟦profile A Is P; i ∈ Is; {a, b} ⊆ A⟧ ⟹ complete A {(u, v). swapAlts a b u ⇘(P i)⇙≼ swapAlts a b v}›*) apply simp (*goal: ‹⋀x y. ⟦profile A Is P; i ∈ Is; {a, b} ⊆ A; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ x ⇘{(u, v). swapAlts a b u ⇘(P i)⇙≼ swapAlts a b v}⇙≼ y ∨ y ⇘{(u, v). swapAlts a b u ⇘(P i)⇙≼ swapAlts a b v}⇙≼ x›*) apply (rule rpr_complete[where A=A] (*‹⟦rpr A ?r; ?x ∈ A; ?y ∈ A⟧ ⟹ ?x ⇘?r⇙≼ ?y ∨ ?y ⇘?r⇙≼ ?x›*)) (*goals: 1. ‹⋀x y. ⟦profile A Is P; i ∈ Is; a ∈ A ∧ b ∈ A; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ rpr A (P i)› 2. ‹⋀x y. ⟦profile A Is P; i ∈ Is; a ∈ A ∧ b ∈ A; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ swapAlts a b x ∈ A› 3. ‹⋀x y. ⟦profile A Is P; i ∈ Is; a ∈ A ∧ b ∈ A; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ swapAlts a b y ∈ A› discuss goal 1*) apply ((auto iff: swapAlts_in_set_iff (*‹{?a, ?b} ⊆ ?A ⟹ (swapAlts ?a ?b ?u ∈ ?A) = (?u ∈ ?A)›*))[1]) (*discuss goal 2*) apply ((auto iff: swapAlts_in_set_iff (*‹{?a, ?b} ⊆ ?A ⟹ (swapAlts ?a ?b ?u ∈ ?A) = (?u ∈ ?A)›*))[1]) (*discuss goal 3*) apply ((auto iff: swapAlts_in_set_iff (*‹{?a, ?b} ⊆ ?A ⟹ (swapAlts ?a ?b ?u ∈ ?A) = (?u ∈ ?A)›*))[1]) (*proven 3 subgoals*) . next (*goal: ‹trans (swapAltsP (P::'b::type ⇒ ('a::type × 'a::type) set) (a::'a::type) (b::'a::type) (i::'b::type))›*) from profileP (*‹profile (A::'a set) (Is::'b set) (P::'b ⇒ ('a × 'a) set)›*) iIs (*‹(i::'b) ∈ (Is::'b set)›*) show "trans (swapAltsP P a b i)" unfolding swapAltsP_def (*goal: ‹trans {(u::'a, v::'a). swapAlts (a::'a) (b::'a) u ⇘((P::'b ⇒ ('a × 'a) set) (i::'b))⇙≼ swapAlts a b v}›*) by (blast dest: rpr_le_trans (*‹⟦?x ⇘?r⇙≼ ?y; ?y ⇘?r⇙≼ ?z; rpr ?A ?r⟧ ⟹ ?x ⇘?r⇙≼ ?z›*) intro: transI (*‹(⋀x y z. ⟦x ⇘?r⇙≼ y; y ⇘?r⇙≼ z⟧ ⟹ x ⇘?r⇙≼ z) ⟹ trans ?r›*)) qed qed lemma profile_bij_profile: assumes profileP: "profile A Is P" and bijf: "bij_betw f Is Is" shows "profile A Is (P ∘ f)" using bij_betw_onto[OF bijf] (*‹f ` Is = Is›*) profileP (*‹profile A Is P›*) apply - (*goal: ‹profile A Is (P ∘ f)›*) apply rule (*goals: 1. ‹⋀i. ⟦f ` Is = Is; profile A Is P; i ∈ Is⟧ ⟹ rpr A ((P ∘ f) i)› 2. ‹⟦f ` Is = Is; profile A Is P⟧ ⟹ Is ≠ {}› discuss goal 1*) apply ((auto dest: profile_non_empty (*‹profile ?A ?Is ?P ⟹ ?Is ≠ {}›*))[1]) (*discuss goal 2*) apply ((auto dest: profile_non_empty (*‹profile ?A ?Is ?P ⟹ ?Is ≠ {}›*))[1]) (*proven 2 subgoals*) . text‹The locale keeps the conditions in scope for the next few lemmas. Note how weak the constraints on the sets of alternatives and individuals are; clearly there needs to be at least two alternatives and two individuals for conflict to occur, but it is pleasant that the proof uniformly handles the degenerate cases.› locale May = fixes A :: "'a set" fixes Is :: "'i set" assumes finiteIs: "finite Is" fixes scf :: "('a, 'i) SCF" assumes SCF: "SCF scf A Is universal_domain" and anonymous: "anonymous scf A Is" and neutral: "neutral scf A Is" and positively_responsive: "positively_responsive scf A Is" begin text‹Anonymity implies that, for any pair of alternatives, the social choice rule can only depend on the number of individuals who express any given preference between them. Note we also need @{term "iia"}, implied by neutrality, to restrict attention to alternatives $x$ and $y$.› lemma anonymous_card: assumes profileP: "profile A Is P" and profileP': "profile A Is P'" and xyA: "hasw [x,y] A" and xytally: "card { i ∈ Is. x ⇘(P i)⇙≺ y } = card { i ∈ Is. x ⇘(P' i)⇙≺ y }" and yxtally: "card { i ∈ Is. y ⇘(P i)⇙≺ x } = card { i ∈ Is. y ⇘(P' i)⇙≺ x }" shows "x ⇘(scf P)⇙≼ y ⟷ x ⇘(scf P')⇙≼ y" proof (-) (*goal: ‹(x ⇘(scf P)⇙≼ y) = (x ⇘(scf P')⇙≼ y)›*) let ?xPy = "{ i ∈ Is. x ⇘(P i)⇙≺ y }" let ?xP'y = "{ i ∈ Is. x ⇘(P' i)⇙≺ y }" let ?yPx = "{ i ∈ Is. y ⇘(P i)⇙≺ x }" let ?yP'x = "{ i ∈ Is. y ⇘(P' i)⇙≺ x }" have disjPxy: "(?xPy ∪ ?yPx) - ?xPy = ?yPx" unfolding strict_pref_def (*goal: ‹{i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i} ∪ {i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} - {i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i} = {i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i}›*) by blast have disjP'xy: "(?xP'y ∪ ?yP'x) - ?xP'y = ?yP'x" unfolding strict_pref_def (*goal: ‹{i ∈ Is. x ⇘(P' i)⇙≼ y ∧ (y, x) ∉ P' i} ∪ {i ∈ Is. y ⇘(P' i)⇙≼ x ∧ (x, y) ∉ P' i} - {i ∈ Is. x ⇘(P' i)⇙≼ y ∧ (y, x) ∉ P' i} = {i ∈ Is. y ⇘(P' i)⇙≼ x ∧ (x, y) ∉ P' i}›*) by blast from finiteIs (*‹finite (Is::'i set)›*) xytally (*‹card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(P' i)⇙≺ y}›*) obtain f where bijf: "bij_betw f ?xPy ?xP'y" (*goal: ‹(⋀f. bij_betw f {i ∈ Is. x ⇘(P i)⇙≺ y} {i ∈ Is. x ⇘(P' i)⇙≺ y} ⟹ thesis) ⟹ thesis›*) apply - (*goal: ‹(⋀f. bij_betw f {i ∈ Is. x ⇘(P i)⇙≺ y} {i ∈ Is. x ⇘(P' i)⇙≺ y} ⟹ thesis) ⟹ thesis›*) by (drule card_eq_bij (*‹⟦card (?A::?'a::type set) = card (?B::?'b::type set); finite ?A; finite ?B; ⋀f::?'a::type ⇒ ?'b::type. bij_betw f ?A ?B ⟹ ?thesis::bool⟧ ⟹ ?thesis›*), auto) from finiteIs (*‹finite Is›*) yxtally (*‹card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}›*) obtain g where bijg: "bij_betw g ?yPx ?yP'x" (*goal: ‹(⋀g. bij_betw g {i ∈ Is. y ⇘(P i)⇙≺ x} {i ∈ Is. y ⇘(P' i)⇙≺ x} ⟹ thesis) ⟹ thesis›*) apply - (*goal: ‹(⋀g. bij_betw g {i ∈ Is. y ⇘(P i)⇙≺ x} {i ∈ Is. y ⇘(P' i)⇙≺ x} ⟹ thesis) ⟹ thesis›*) by (drule card_eq_bij (*‹⟦card ?A = card ?B; finite ?A; finite ?B; ⋀f. bij_betw f ?A ?B ⟹ ?thesis⟧ ⟹ ?thesis›*), auto) from bijf (*‹bij_betw (f::'i ⇒ 'i) {i::'i ∈ Is::'i set. (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ (y::'a)} {i::'i ∈ Is. x ⇘((P'::'i ⇒ ('a × 'a) set) i)⇙≺ y}›*) bijg (*‹bij_betw g {i ∈ Is. y ⇘(P i)⇙≺ x} {i ∈ Is. y ⇘(P' i)⇙≺ x}›*) disjPxy (*‹{i::'i::type ∈ Is::'i::type set. (x::'a::type) ⇘((P::'i::type ⇒ ('a::type × 'a::type) set) i)⇙≺ (y::'a::type)} ∪ {i::'i::type ∈ Is. y ⇘(P i)⇙≺ x} - {i::'i::type ∈ Is. x ⇘(P i)⇙≺ y} = {i::'i::type ∈ Is. y ⇘(P i)⇙≺ x}›*) disjP'xy (*‹{i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x} - {i ∈ Is. x ⇘(P' i)⇙≺ y} = {i ∈ Is. y ⇘(P' i)⇙≺ x}›*) obtain h where bijh: "bij_betw h (?xPy ∪ ?yPx) (?xP'y ∪ ?yP'x)" and hf: "⋀j. j ∈ ?xPy ⟹ h j = f j" and hg: "⋀j. j ∈ (?xPy ∪ ?yPx) - ?xPy ⟹ h j = g j" (*goal: ‹(⋀h. ⟦bij_betw h ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}) ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x}); ⋀j. j ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ⟹ h j = f j; ⋀j. j ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} - {i ∈ Is. x ⇘(P i)⇙≺ y} ⟹ h j = g j⟧ ⟹ thesis) ⟹ thesis›*) using bij_combine[where f = f and g = g and A = "?xPy" and B = "?xPy ∪ ?yPx" and C = "?xP'y" and D = "?xP'y ∪ ?yP'x"] (*‹⟦{i ∈ Is. x ⇘(P i)⇙≺ y} ⊆ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}; {i ∈ Is. x ⇘(P' i)⇙≺ y} ⊆ {i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x}; bij_betw f {i ∈ Is. x ⇘(P i)⇙≺ y} {i ∈ Is. x ⇘(P' i)⇙≺ y}; bij_betw g ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} - {i ∈ Is. x ⇘(P i)⇙≺ y}) ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x} - {i ∈ Is. x ⇘(P' i)⇙≺ y}); ⋀h. ⟦bij_betw h ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}) ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x}); ⋀xa. xa ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ⟹ h xa = f xa; ⋀xa. xa ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} - {i ∈ Is. x ⇘(P i)⇙≺ y} ⟹ h xa = g xa⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by auto from bijh (*‹bij_betw h ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}) ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x})›*) finiteIs (*‹finite Is›*) obtain h' where bijh': "bij_betw h' Is Is" and hh': "⋀j. j ∈ (?xPy ∪ ?yPx) ⟹ h' j = h j" and hrest: "⋀j. j ∈ Is - (?xPy ∪ ?yPx) ⟹ h' j ∈ Is - (?xP'y ∪ ?yP'x)" (*goal: ‹(⋀h'. ⟦bij_betw h' Is Is; ⋀j. j ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} ⟹ h' j = h j; ⋀j. j ∈ Is - ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}) ⟹ h' j ∈ Is - ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x})⟧ ⟹ thesis) ⟹ thesis›*) apply - (*goal: ‹(⋀h'. ⟦bij_betw h' Is Is; ⋀j. j ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} ⟹ h' j = h j; ⋀j. j ∈ Is - ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}) ⟹ h' j ∈ Is - ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x})⟧ ⟹ thesis) ⟹ thesis›*) by (drule bij_complete (*‹⟦finite (?C::?'a::type set); (?A::?'a::type set) ⊆ ?C; (?B::?'a::type set) ⊆ ?C; bij_betw (?f::?'a::type ⇒ ?'a::type) ?A ?B; ⋀f'::?'a::type ⇒ ?'a::type. ⟦bij_betw f' ?C ?C; ⋀x::?'a::type. x ∈ ?A ⟹ f' x = ?f x; ⋀x::?'a::type. x ∈ ?C - ?A ⟹ f' x ∈ ?C - ?B⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*), auto) from neutral_iia[OF neutral] (*‹iia scf A Is›*) have "x ⇘(scf (P' ∘ h'))⇙≼ y ⟷ x ⇘(scf P)⇙≼ y" proof (rule iiaE (*‹⟦iia ?swf ?S ?Is; {?x, ?y} ⊆ ?S; ?a ∈ {?x, ?y}; ?b ∈ {?x, ?y}; ⋀i a b. ⟦a ∈ {?x, ?y}; b ∈ {?x, ?y}; i ∈ ?Is⟧ ⟹ (a ⇘(?P' i)⇙≼ b) = (a ⇘(?P i)⇙≼ b); profile ?S ?Is ?P; profile ?S ?Is ?P'⟧ ⟹ (?a ⇘(?swf ?P)⇙≼ ?b) = (?a ⇘(?swf ?P')⇙≼ ?b)›*)) (*goals: 1. ‹{?x, ?y} ⊆ A› 2. ‹x ∈ {?x, ?y}› 3. ‹y ∈ {?x, ?y}› 4. ‹⋀i a b. ⟦a ∈ {?x, ?y}; b ∈ {?x, ?y}; i ∈ Is⟧ ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)› 5. ‹profile A Is (P' ∘ h')› 6. ‹profile A Is P›*) from xyA (*‹hasw [x, y] A›*) show "{x, y} ⊆ A" by simp next (*goals: 1. ‹x ∈ {x, y}› 2. ‹y ∈ {x, y}› 3. ‹⋀i a b. ⟦a ∈ {x, y}; b ∈ {x, y}; i ∈ Is⟧ ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)› 4. ‹profile A Is (P' ∘ h')› 5. ‹profile A Is P›*) fix i assume iIs: "i ∈ Is" (*‹(i::'i) ∈ (Is::'i set)›*) fix a and b assume ab: "a ∈ {x, y}" "b ∈ {x, y}" (*‹(a::'a) ∈ {x::'a, y::'a}› ‹(b::'a) ∈ {x::'a, y::'a}›*) from profileP (*‹profile A Is P›*) iIs (*‹(i::'i) ∈ (Is::'i set)›*) have completePi: "complete A (P i)" by (auto dest: rprD (*‹rpr ?A ?r ⟹ complete ?A ?r ∧ refl_on ?A ?r ∧ trans ?r›*)) from completePi (*‹complete A (P i)›*) xyA (*‹hasw [x::'a, y::'a] (A::'a set)›*) show "(a ⇘(P i)⇙≼ b) ⟷ (a ⇘((P' ∘ h') i)⇙≼ b)" proof (cases rule: complete_exh (*‹⟦complete ?A ?r; hasw [?x, ?y] ?A; ?x ⇘?r⇙≺ ?y ⟹ ?thesis; ?y ⇘?r⇙≺ ?x ⟹ ?thesis; ?x ⇘?r⇙≈ ?y ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹x ⇘(P i)⇙≺ y ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)› 2. ‹y ⇘(P i)⇙≺ x ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)› 3. ‹x ⇘(P i)⇙≈ y ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) case xPy (*‹x ⇘(P i)⇙≺ y›*) with profileP (*‹profile A Is P›*) profileP' (*‹profile A Is P'›*) xyA (*‹hasw [x, y] A›*) iIs (*‹(i::'i) ∈ (Is::'i set)›*) ab (*‹a ∈ {x, y}› ‹b ∈ {x, y}›*) hh' (*‹?j ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} ⟹ h' ?j = h ?j›*) hf (*‹(?j::'i::type) ∈ {i::'i::type ∈ Is::'i::type set. (x::'a::type) ⇘((P::'i::type ⇒ ('a::type × 'a::type) set) i)⇙≺ (y::'a::type)} ⟹ (h::'i::type ⇒ 'i::type) ?j = (f::'i::type ⇒ 'i::type) ?j›*) bijf (*‹bij_betw (f::'i ⇒ 'i) {i::'i ∈ Is::'i set. (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ (y::'a)} {i::'i ∈ Is. x ⇘((P'::'i ⇒ ('a × 'a) set) i)⇙≺ y}›*) show "?thesis" (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) unfolding strict_pref_def bij_betw_def (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) apply simp (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) by blast next (*goals: 1. ‹y ⇘(P i)⇙≺ x ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)› 2. ‹x ⇘(P i)⇙≈ y ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) case yPx (*‹y ⇘(P i)⇙≺ x›*) with profileP (*‹profile A Is P›*) profileP' (*‹profile A Is P'›*) xyA (*‹hasw [x::'a, y::'a] (A::'a set)›*) iIs (*‹(i::'i) ∈ (Is::'i set)›*) ab (*‹a ∈ {x, y}› ‹b ∈ {x, y}›*) hh' (*‹?j ∈ {i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x} ⟹ h' ?j = h ?j›*) hg (*‹(?j::'i::type) ∈ {i::'i::type ∈ Is::'i::type set. (x::'a::type) ⇘((P::'i::type ⇒ ('a::type × 'a::type) set) i)⇙≺ (y::'a::type)} ∪ {i::'i::type ∈ Is. y ⇘(P i)⇙≺ x} - {i::'i::type ∈ Is. x ⇘(P i)⇙≺ y} ⟹ (h::'i::type ⇒ 'i::type) ?j = (g::'i::type ⇒ 'i::type) ?j›*) bijg (*‹bij_betw g {i ∈ Is. y ⇘(P i)⇙≺ x} {i ∈ Is. y ⇘(P' i)⇙≺ x}›*) show "?thesis" (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) unfolding strict_pref_def bij_betw_def (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) apply simp (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) by blast next (*goal: ‹x ⇘(P i)⇙≈ y ⟹ (a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) case xIy (*‹x ⇘(P i)⇙≈ y›*) with profileP (*‹profile (A::'a set) (Is::'i set) (P::'i ⇒ ('a × 'a) set)›*) profileP' (*‹profile A Is P'›*) xyA (*‹hasw [x, y] A›*) iIs (*‹i ∈ Is›*) ab (*‹(a::'a) ∈ {x::'a, y::'a}› ‹(b::'a) ∈ {x::'a, y::'a}›*) hrest[where j = i] (*‹i ∈ Is - ({i ∈ Is. x ⇘(P i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P i)⇙≺ x}) ⟹ h' i ∈ Is - ({i ∈ Is. x ⇘(P' i)⇙≺ y} ∪ {i ∈ Is. y ⇘(P' i)⇙≺ x})›*) show "?thesis" (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) unfolding indifferent_pref_def strict_pref_def bij_betw_def (*goal: ‹((a::'a) ⇘((P::'i ⇒ ('a × 'a) set) (i::'i))⇙≼ (b::'a)) = (a ⇘(((P'::'i ⇒ ('a × 'a) set) ∘ (h'::'i ⇒ 'i)) i)⇙≼ b)›*) apply simp (*goal: ‹(a ⇘(P i)⇙≼ b) = (a ⇘((P' ∘ h') i)⇙≼ b)›*) by (blast dest: rpr_complete (*‹⟦rpr ?A ?r; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x ⇘?r⇙≼ ?y ∨ ?y ⇘?r⇙≼ ?x›*)) qed qed (simp_all add: profileP profile_bij_profile[OF profileP' bijh']) (*solves the remaining goals: 1. ‹x ∈ {x, y}› 2. ‹y ∈ {x, y}› 3. ‹profile A Is (P' ∘ h')› 4. ‹profile A Is P›*) moreover from anonymousD[OF anonymous profileP' bijh'] (*‹⟦(?x::'a::type) ∈ (A::'a::type set); (?y::'a::type) ∈ A⟧ ⟹ (?x ⇘((scf::('i::type ⇒ ('a::type × 'a::type) set) ⇒ ('a::type × 'a::type) set) (P'::'i::type ⇒ ('a::type × 'a::type) set))⇙≼ ?y) = (?x ⇘(scf (P' ∘ (h'::'i::type ⇒ 'i::type)))⇙≼ ?y)›*) xyA (*‹hasw [x, y] A›*) have "x ⇘(scf P')⇙≼ y ⟷ x ⇘(scf (P' ∘ h'))⇙≼ y" by simp ultimately show "?thesis" (*goal: ‹(x ⇘(scf P)⇙≼ y) = (x ⇘(scf P')⇙≼ y)›*) by simp qed text ‹Using the previous result and neutrality, it must be the case that if the tallies are tied for alternatives $x$ and $y$ then the social choice function is indifferent between those two alternatives.› lemma anonymous_neutral_indifference: assumes profileP: "profile A Is P" and xyA: "hasw [x,y] A" and tallyP: "card { i ∈ Is. x ⇘(P i)⇙≺ y } = card { i ∈ Is. y ⇘(P i)⇙≺ x }" shows "x ⇘(scf P)⇙≈ y" proof (-) (*goal: ‹x ⇘(scf P)⇙≈ y›*) from xyA (*‹hasw [x::'a, y::'a] (A::'a set)›*) have symPP': "(x ⇘(scf P)⇙≼ y ⟷ y ⇘(scf (swapAltsP P x y))⇙≼ x) ∧ (y ⇘(scf P)⇙≼ x ⟷ x ⇘(scf (swapAltsP P x y))⇙≼ y)" apply - (*goal: ‹(x ⇘(scf P)⇙≼ y) = (y ⇘(scf (swapAltsP P x y))⇙≼ x) ∧ (y ⇘(scf P)⇙≼ x) = (x ⇘(scf (swapAltsP P x y))⇙≼ y)›*) apply (rule neutralD[OF neutral profileP profile_swapAltsP[OF profileP]] (*‹⟦{?a1, ?b1} ⊆ A; {?x, ?y, ?z, ?w} ⊆ A; ⋀i. i ∈ Is ⟹ (?x ⇘(P i)⇙≼ ?y) = (?z ⇘(swapAltsP P ?a1 ?b1 i)⇙≼ ?w); ⋀i. i ∈ Is ⟹ (?y ⇘(P i)⇙≼ ?x) = (?w ⇘(swapAltsP P ?a1 ?b1 i)⇙≼ ?z)⟧ ⟹ (?x ⇘(scf P)⇙≼ ?y) = (?z ⇘(scf (swapAltsP P ?a1 ?b1))⇙≼ ?w) ∧ (?y ⇘(scf P)⇙≼ ?x) = (?w ⇘(scf (swapAltsP P ?a1 ?b1))⇙≼ ?z)›*)) (*goals: 1. ‹hasw [x, y] A ⟹ {x, y} ⊆ A› 2. ‹hasw [x, y] A ⟹ {x, y, y, x} ⊆ A› 3. ‹⋀i. ⟦hasw [x, y] A; i ∈ Is⟧ ⟹ (x ⇘(P i)⇙≼ y) = (y ⇘(swapAltsP P x y i)⇙≼ x)› 4. ‹⋀i. ⟦hasw [x, y] A; i ∈ Is⟧ ⟹ (y ⇘(P i)⇙≼ x) = (x ⇘(swapAltsP P x y i)⇙≼ y)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*top goal: ‹⋀i. ⟦hasw [x, y] A; i ∈ Is⟧ ⟹ (x ⇘(P i)⇙≼ y) = (y ⇘(swapAltsP P x y i)⇙≼ x)› and 1 goal remains*) apply (rule swapAltsP_ab (*‹(?a ⇘(?P ?i)⇙≼ ?b) = (?b ⇘(swapAltsP ?P ?a ?b ?i)⇙≼ ?a)› ‹(?b ⇘(?P ?i)⇙≼ ?a) = (?a ⇘(swapAltsP ?P ?a ?b ?i)⇙≼ ?b)›*)) (*discuss goal 4*) apply simp (*goal: ‹⋀i. ⟦hasw [x, y] A; i ∈ Is⟧ ⟹ (y ⇘(P i)⇙≼ x) = (x ⇘(swapAltsP P x y i)⇙≼ y)›*) apply (rule swapAltsP_ab (*‹(?a ⇘(?P ?i)⇙≼ ?b) = (?b ⇘(swapAltsP ?P ?a ?b ?i)⇙≼ ?a)› ‹(?b ⇘(?P ?i)⇙≼ ?a) = (?a ⇘(swapAltsP ?P ?a ?b ?i)⇙≼ ?b)›*)) (*proven 4 subgoals*) . from xyA (*‹hasw [x, y] A›*) tallyP (*‹card {i::'i::type ∈ Is::'i::type set. (x::'a::type) ⇘((P::'i::type ⇒ ('a::type × 'a::type) set) i)⇙≺ (y::'a::type)} = card {i::'i::type ∈ Is. y ⇘(P i)⇙≺ x}›*) have "card {i ∈ Is. x ⇘(P i)⇙≺ y} = card { i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y }" and "card {i ∈ Is. y ⇘(P i)⇙≺ x} = card { i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x }" unfolding swapAltsP_def swapAlts_def strict_pref_def (*goals: 1. ‹card {i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i} = card {i ∈ Is. x ⇘{(u, v). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}⇙≼ y ∧ (y, x) ∉ {(u, v). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}}› 2. ‹card {i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} = card {i ∈ Is. y ⇘{(u, v). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}⇙≼ x ∧ (x, y) ∉ {(u, v). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}}›*) apply - (*goals: 1. ‹⟦hasw [x::'a, y::'a] (A::'a set); card {i::'i ∈ Is::'i set. x ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≼ y ∧ (y, x) ∉ P i} = card {i::'i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i}⟧ ⟹ card {i::'i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i} = card {i::'i ∈ Is. x ⇘{(u::'a, v::'a). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}⇙≼ y ∧ (y, x) ∉ {(u::'a, v::'a). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}}› 2. ‹⟦hasw [x::'a, y::'a] (A::'a set); card {i::'i ∈ Is::'i set. x ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≼ y ∧ (y, x) ∉ P i} = card {i::'i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i}⟧ ⟹ card {i::'i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} = card {i::'i ∈ Is. y ⇘{(u::'a, v::'a). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}⇙≼ x ∧ (x, y) ∉ {(u::'a, v::'a). (if u = x then y else if u = y then x else u) ⇘(P i)⇙≼ (if v = x then y else if v = y then x else v)}}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with profileP (*‹profile A Is P›*) xyA (*‹hasw [x, y] A›*) have idPP': "x ⇘(scf P)⇙≼ y ⟷ x ⇘(scf (swapAltsP P x y))⇙≼ y" and "y ⇘(scf P)⇙≼ x ⟷ y ⇘(scf (swapAltsP P x y))⇙≼ x" apply - (*goals: 1. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (swapAltsP P x y))⇙≼ y)› 2. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ (y ⇘(scf P)⇙≼ x) = (y ⇘(scf (swapAltsP P x y))⇙≼ x)› discuss goal 1*) apply - (*top goal: ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(scf (swapAltsP P x y))⇙≼ y)› and 1 goal remains*) apply (rule anonymous_card[OF profileP profile_swapAltsP] (*‹⟦profile A Is ?P1; {?a1, ?b1} ⊆ A; hasw [?x, ?y] A; card {i ∈ Is. ?x ⇘(P i)⇙≺ ?y} = card {i ∈ Is. ?x ⇘(swapAltsP ?P1 ?a1 ?b1 i)⇙≺ ?y}; card {i ∈ Is. ?y ⇘(P i)⇙≺ ?x} = card {i ∈ Is. ?y ⇘(swapAltsP ?P1 ?a1 ?b1 i)⇙≺ ?x}⟧ ⟹ (?x ⇘(scf P)⇙≼ ?y) = (?x ⇘(scf (swapAltsP ?P1 ?a1 ?b1))⇙≼ ?y)›*)) (*goals: 1. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ profile A Is P› 2. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ {x, y} ⊆ A› 3. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ hasw [x, y] A› 4. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}› 5. ‹⟦profile A Is P; hasw [x, y] A; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply clarsimp (*discuss goal 3*) apply clarsimp (*discuss goal 4*) apply clarsimp (*discuss goal 5*) apply clarsimp (*proven 5 subgoals*) (*discuss goal 2*) apply clarsimp (*goal: ‹⟦profile (A::'a::type set) (Is::'i::type set) (P::'i::type ⇒ ('a::type × 'a::type) set); hasw [x::'a::type, y::'a::type] A; card {i::'i::type ∈ Is. x ⇘(P i)⇙≺ y} = card {i::'i::type ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i::'i::type ∈ Is. y ⇘(P i)⇙≺ x} = card {i::'i::type ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}⟧ ⟹ (y ⇘((scf::('i::type ⇒ ('a::type × 'a::type) set) ⇒ ('a::type × 'a::type) set) P)⇙≼ x) = (y ⇘(scf (swapAltsP P x y))⇙≼ x)›*) apply (rule anonymous_card[OF profileP profile_swapAltsP] (*‹⟦profile A Is ?P1; {?a1, ?b1} ⊆ A; hasw [?x, ?y] A; card {i ∈ Is. ?x ⇘(P i)⇙≺ ?y} = card {i ∈ Is. ?x ⇘(swapAltsP ?P1 ?a1 ?b1 i)⇙≺ ?y}; card {i ∈ Is. ?y ⇘(P i)⇙≺ ?x} = card {i ∈ Is. ?y ⇘(swapAltsP ?P1 ?a1 ?b1 i)⇙≺ ?x}⟧ ⟹ (?x ⇘(scf P)⇙≼ ?y) = (?x ⇘(scf (swapAltsP ?P1 ?a1 ?b1))⇙≼ ?y)›*)) (*goals: 1. ‹⟦profile A Is P; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ profile A Is P› 2. ‹⟦profile A Is P; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ {x, y} ⊆ A› 3. ‹⟦profile A Is P; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ hasw [y, x] A› 4. ‹⟦profile A Is P; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}› 5. ‹⟦profile A Is P; card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}; card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(swapAltsP P x y i)⇙≺ x}; x ∈ A; y ∈ A; x ≠ y⟧ ⟹ card {i ∈ Is. x ⇘(P i)⇙≺ y} = card {i ∈ Is. x ⇘(swapAltsP P x y i)⇙≺ y}› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply clarsimp (*discuss goal 3*) apply clarsimp (*discuss goal 4*) apply clarsimp (*discuss goal 5*) apply clarsimp (*proven 5 subgoals*) (*proven 2 subgoals*) . from xyA (*‹hasw [x, y] A›*) SCF_completeD[OF SCF] (*‹universal_domain A Is ?P ⟹ complete A (scf ?P)›*) profileP (*‹profile A Is P›*) symPP' (*‹((x::'a) ⇘((scf::('i ⇒ ('a × 'a) set) ⇒ ('a × 'a) set) (P::'i ⇒ ('a × 'a) set))⇙≼ (y::'a)) = (y ⇘(scf (swapAltsP P x y))⇙≼ x) ∧ (y ⇘(scf P)⇙≼ x) = (x ⇘(scf (swapAltsP P x y))⇙≼ y)›*) idPP' (*‹(x ⇘(scf P)⇙≼ y) = (x ⇘(scf (swapAltsP P x y))⇙≼ y)›*) show "x ⇘(scf P)⇙≈ y" apply simp (*goal: ‹(x::'a) ⇘((scf::('i ⇒ ('a × 'a) set) ⇒ ('a × 'a) set) (P::'i ⇒ ('a × 'a) set))⇙≈ (y::'a)›*) by blast qed text‹Finally, if the tallies are not equal then the social choice function must lean towards the one with the higher count due to positive responsiveness.› lemma positively_responsive_prefer_witness: assumes profileP: "profile A Is P" and xyA: "hasw [x,y] A" and tallyP: "card { i ∈ Is. x ⇘(P i)⇙≺ y } > card { i ∈ Is. y ⇘(P i)⇙≺ x }" obtains P' k where "profile A Is P'" and "⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y" and "⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y" and "k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y" and "card { i ∈ Is. x ⇘(P' i)⇙≺ y } = card { i ∈ Is. y ⇘(P' i)⇙≺ x }" proof (-) (*goal: ‹(⋀P' k. ⟦profile A Is P'; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}⟧ ⟹ thesis) ⟹ thesis›*) from tallyP (*‹card {i ∈ Is. y ⇘(P i)⇙≺ x} < card {i ∈ Is. x ⇘(P i)⇙≺ y}›*) obtain C where tallyP': "card ({ i ∈ Is. x ⇘(P i)⇙≺ y } - C) = card { i ∈ Is. y ⇘(P i)⇙≺ x }" and C: "C ≠ {}" "C ⊆ Is" and CxPy: "C ⊆ { i ∈ Is. x ⇘(P i)⇙≺ y }" (*goal: ‹(⋀C. ⟦card ({i ∈ Is. x ⇘(P i)⇙≺ y} - C) = card {i ∈ Is. y ⇘(P i)⇙≺ x}; C ≠ {}; C ⊆ Is; C ⊆ {i ∈ Is. x ⇘(P i)⇙≺ y}⟧ ⟹ thesis) ⟹ thesis›*) apply - (*goal: ‹(⋀C. ⟦card ({i ∈ Is. x ⇘(P i)⇙≺ y} - C) = card {i ∈ Is. y ⇘(P i)⇙≺ x}; C ≠ {}; C ⊆ Is; C ⊆ {i ∈ Is. x ⇘(P i)⇙≺ y}⟧ ⟹ thesis) ⟹ thesis›*) by (drule card_greater[OF finiteIs] (*‹⟦card {x ∈ Is. ?Q x} < card {x ∈ Is. ?P x}; ⋀C. ⟦card ({x ∈ Is. ?P x} - C) = card {x ∈ Is. ?Q x}; C ≠ {}; C ⊆ {x ∈ Is. ?P x}⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*), auto) let ?P' = "λi. if i ∈ C then P i ∪ { (y, x) } ∪ { (y, u) |u. x ⇘(P i)⇙≼ u } ∪ { (u, x) |u. u ⇘(P i)⇙≼ y } ∪ { (v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y } else P i" have "profile A Is ?P'" proof (standard) (*goals: 1. ‹⋀i. i ∈ Is ⟹ rpr A (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)› 2. ‹Is ≠ {}›*) fix i assume iIs: "i ∈ Is" (*‹(i::'i) ∈ (Is::'i set)›*) show "rpr A (?P' i)" proof (standard) (*goals: 1. ‹complete (A::'a::type set) (if (i::'i::type) ∈ (C::'i::type set) then (P::'i::type ⇒ ('a::type × 'a::type) set) i ∪ {(y::'a::type, x::'a::type)} ∪ {(y, u) |u::'a::type. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a::type. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a::type) v::'a::type. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)› 2. ‹refl_on (A::'a::type set) (if (i::'i::type) ∈ (C::'i::type set) then (P::'i::type ⇒ ('a::type × 'a::type) set) i ∪ {(y::'a::type, x::'a::type)} ∪ {(y, u) |u::'a::type. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a::type. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a::type) v::'a::type. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)› 3. ‹trans (if (i::'i::type) ∈ (C::'i::type set) then (P::'i::type ⇒ ('a::type × 'a::type) set) i ∪ {(y::'a::type, x::'a::type)} ∪ {(y, u) |u::'a::type. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a::type. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a::type) v::'a::type. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) from profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) show "complete A (?P' i)" unfolding complete_def (*goal: ‹∀xa∈A. ∀ya∈A - {xa}. xa ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ ya ∨ ya ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ xa›*) apply simp (*goal: ‹∀xa∈A. ∀ya∈A - {xa}. xa ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ ya ∨ ya ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ xa›*) by (blast dest: rpr_complete (*‹⟦rpr (?A::?'a::type set) (?r::(?'a::type × ?'a::type) set); (?x::?'a::type) ∈ ?A; (?y::?'a::type) ∈ ?A⟧ ⟹ ?x ⇘?r⇙≼ ?y ∨ ?y ⇘?r⇙≼ ?x›*)) from profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) xyA (*‹hasw [x, y] A›*) show "refl_on A (?P' i)" apply - (*goal: ‹refl_on A (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) apply (rule refl_onI (*‹⟦?r ⊆ ?A × ?A; ⋀x. x ∈ ?A ⟹ x ⇘?r⇙≼ x⟧ ⟹ refl_on ?A ?r›*)) (*goals: 1. ‹⟦profile A Is P; i ∈ Is; hasw [x, y] A⟧ ⟹ (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i) ⊆ A × A› 2. ‹⋀xa. ⟦profile A Is P; i ∈ Is; hasw [x, y] A; xa ∈ A⟧ ⟹ xa ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ xa› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "trans (?P' i)" proof (cases "i ∈ C") (*goals: 1. ‹(i::'i) ∈ (C::'i set) ⟹ trans (if i ∈ C then (P::'i ⇒ ('a × 'a) set) i ∪ {(y::'a, x::'a)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)› 2. ‹(i::'i) ∉ (C::'i set) ⟹ trans (if i ∈ C then (P::'i ⇒ ('a × 'a) set) i ∪ {(y::'a, x::'a)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) case False (*‹(i::'i) ∉ (C::'i set)›*) with profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) show "?thesis" (*goal: ‹trans (if (i::'i::type) ∈ (C::'i::type set) then (P::'i::type ⇒ ('a::type × 'a::type) set) i ∪ {(y::'a::type, x::'a::type)} ∪ {(y, u) |u::'a::type. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a::type. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a::type) v::'a::type. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) apply simp (*goal: ‹trans (if (i::'i) ∈ (C::'i set) then (P::'i ⇒ ('a × 'a) set) i ∪ {(y::'a, x::'a)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) by (blast dest: rpr_le_trans (*‹⟦(?x::?'a) ⇘(?r::(?'a × ?'a) set)⇙≼ (?y::?'a); ?y ⇘?r⇙≼ (?z::?'a); rpr (?A::?'a set) ?r⟧ ⟹ ?x ⇘?r⇙≼ ?z›*) intro: transI (*‹(⋀(x::?'a) (y::?'a) z::?'a. ⟦x ⇘(?r::(?'a × ?'a) set)⇙≼ y; y ⇘?r⇙≼ z⟧ ⟹ x ⇘?r⇙≼ z) ⟹ trans ?r›*)) next (*goal: ‹i ∈ C ⟹ trans (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) case True (*‹i ∈ C›*) with profileP (*‹profile A Is P›*) iIs (*‹i ∈ Is›*) C (*‹C ≠ {}› ‹C ⊆ Is›*) CxPy (*‹C ⊆ {i ∈ Is. x ⇘(P i)⇙≺ y}›*) xyA (*‹hasw [x, y] A›*) show "?thesis" (*goal: ‹trans (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) unfolding strict_pref_def (*goal: ‹trans (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) apply - (*goal: ‹trans (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) apply (rule transI (*‹(⋀(x::?'a) (y::?'a) z::?'a. ⟦x ⇘(?r::(?'a × ?'a) set)⇙≼ y; y ⇘?r⇙≼ z⟧ ⟹ x ⇘?r⇙≼ z) ⟹ trans ?r›*)) (*goal: ‹⟦profile A Is P; i ∈ Is; C ≠ {}; C ⊆ Is; C ⊆ {i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i}; hasw [x, y] A; i ∈ C⟧ ⟹ trans (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) apply simp (*goal: ‹⋀(xa::'a) (ya::'a) z::'a. ⟦profile (A::'a set) (Is::'i set) (P::'i ⇒ ('a × 'a) set); (i::'i) ∈ Is; (C::'i set) ≠ {}; C ⊆ Is; C ⊆ {i::'i ∈ Is. (x::'a) ⇘(P i)⇙≼ (y::'a) ∧ (y, x) ∉ P i}; hasw [x, y] A; i ∈ C; xa ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ ya; ya ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ z⟧ ⟹ xa ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ z›*) by (blast dest: rpr_le_trans (*‹⟦?x ⇘?r⇙≼ ?y; ?y ⇘?r⇙≼ ?z; rpr ?A ?r⟧ ⟹ ?x ⇘?r⇙≼ ?z›*) rpr_complete (*‹⟦rpr ?A ?r; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x ⇘?r⇙≼ ?y ∨ ?y ⇘?r⇙≼ ?x›*)) qed qed next (*goal: ‹Is ≠ {}›*) from C (*‹(C::'i::type set) ≠ {}› ‹(C::'i set) ⊆ (Is::'i set)›*) show "Is ≠ {}" by blast qed moreover have "⋀i. ⟦ i ∈ Is; x ⇘(?P' i)⇙≺ y ⟧ ⟹ x ⇘(P i)⇙≺ y" unfolding strict_pref_def (*goal: ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ y ∧ (y, x) ∉ (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⟧ ⟹ x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i›*) by (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) moreover from profileP (*‹profile A Is P›*) C (*‹C ≠ {}› ‹C ⊆ Is›*) xyA (*‹hasw [x::'a::type, y::'a::type] (A::'a::type set)›*) have "⋀i. ⟦i ∈ Is; x ⇘(?P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y" unfolding indifferent_pref_def (*goal: ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ y ∧ y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ x⟧ ⟹ x ⇘(P i)⇙≼ y›*) by (simp split: if_split_asm (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) moreover from C (*‹C ≠ {}› ‹C ⊆ Is›*) CxPy (*‹C ⊆ {i ∈ Is. x ⇘(P i)⇙≺ y}›*) obtain k where kC: "k ∈ C" and xPky: "x ⇘(P k)⇙≺ y" (*goal: ‹(⋀k::'i. ⟦k ∈ (C::'i set); (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) k)⇙≺ (y::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast hence "x ⇘(?P' k)⇙≈ y" by auto with C (*‹C ≠ {}› ‹C ⊆ Is›*) kC (*‹k ∈ C›*) xPky (*‹x ⇘(P k)⇙≺ y›*) have "k ∈ Is ∧ x ⇘(?P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y" by blast moreover have "card { i ∈ Is. x ⇘(?P' i)⇙≺ y } = card { i ∈ Is. y ⇘(?P' i)⇙≺ x }" proof (-) (*goal: ‹card {i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = card {i ∈ Is. y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ x}›*) have "{ i ∈ Is. x ⇘(?P' i)⇙≺ y } = { i ∈ Is. x ⇘(?P' i)⇙≺ y } - C" proof (-) (*goal: ‹{i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = {i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} - C›*) from C (*‹C ≠ {}› ‹(C::'i set) ⊆ (Is::'i set)›*) have "⋀i. ⟦ i ∈ Is; x ⇘(?P' i)⇙≺ y ⟧ ⟹ i ∈ Is - C" unfolding indifferent_pref_def strict_pref_def (*goal: ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ y ∧ (y, x) ∉ (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⟧ ⟹ i ∈ Is - C›*) by auto thus "?thesis" (*goal: ‹{i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = {i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} - C›*) by blast qed also (*calculation: ‹{i::'i::type ∈ Is::'i::type set. (x::'a::type) ⇘(if i ∈ (C::'i::type set) then (P::'i::type ⇒ ('a::type × 'a::type) set) i ∪ {(y::'a::type, x)} ∪ {(y, u) |u::'a::type. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a::type. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a::type) v::'a::type. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = {i::'i::type ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u::'a::type. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a::type. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a::type) v::'a::type. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} - C›*) have "… = { i ∈ Is. x ⇘(P i)⇙≺ y } - C" by auto finally (*calculation: ‹{i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = {i ∈ Is. x ⇘(P i)⇙≺ y} - C›*) have "card { i ∈ Is. x ⇘(?P' i)⇙≺ y } = card ({ i ∈ Is. x ⇘(P i)⇙≺ y } - C)" by simp with tallyP' (*‹card ({i ∈ Is. x ⇘(P i)⇙≺ y} - C) = card {i ∈ Is. y ⇘(P i)⇙≺ x}›*) have "card { i ∈ Is. x ⇘(?P' i)⇙≺ y } = card { i ∈ Is. y ⇘(P i)⇙≺ x }" by simp also (*calculation: ‹card {i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = card {i ∈ Is. y ⇘(P i)⇙≺ x}›*) have "… = card { i ∈ Is. y ⇘(?P' i)⇙≺ x }" (is "card ?lhs = card ?rhs") proof (-) (*goal: ‹card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ x}›*) from profileP (*‹profile A Is P›*) xyA (*‹hasw [x, y] A›*) have "⋀i. ⟦ i ∈ Is; y ⇘(?P' i)⇙≺ x ⟧ ⟹ y ⇘(P i)⇙≺ x" unfolding strict_pref_def (*goal: ‹⋀i. ⟦i ∈ Is; y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ x ∧ (x, y) ∉ (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⟧ ⟹ y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i›*) apply (simp split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) (*goal: ‹⋀i. ⟦i ∈ Is; y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ x ∧ (x, y) ∉ (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⟧ ⟹ y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i›*) by (blast dest: rpr_complete (*‹⟦rpr ?A ?r; ?x ∈ ?A; ?y ∈ ?A⟧ ⟹ ?x ⇘?r⇙≼ ?y ∨ ?y ⇘?r⇙≼ ?x›*)) hence "?rhs ⊆ ?lhs" by blast moreover from profileP (*‹profile (A::'a set) (Is::'i set) (P::'i ⇒ ('a × 'a) set)›*) xyA (*‹hasw [x::'a::type, y::'a::type] (A::'a::type set)›*) have "⋀i. ⟦ i ∈ Is; y ⇘(P i)⇙≺ x ⟧ ⟹ y ⇘(?P' i)⇙≺ x" unfolding strict_pref_def (*goal: ‹⋀i. ⟦i ∈ Is; y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i⟧ ⟹ y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≼ x ∧ (x, y) ∉ (if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)›*) by simp hence "?lhs ⊆ ?rhs" by blast ultimately show "?thesis" (*goal: ‹card {i ∈ Is. y ⇘(P i)⇙≺ x} = card {i ∈ Is. y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ x}›*) by simp qed finally (*calculation: ‹card {i ∈ Is. x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = card {i ∈ Is. y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ x}›*) show "?thesis" (*goal: ‹card {i::'i ∈ Is::'i set. (x::'a) ⇘(if i ∈ (C::'i set) then (P::'i ⇒ ('a × 'a) set) i ∪ {(y::'a, x)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y} = card {i::'i ∈ Is. y ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u::'a. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u::'a. u ⇘(P i)⇙≼ y} ∪ {(v, u) |(u::'a) v::'a. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ x}›*) . qed ultimately show thesis apply standard (*goals: 1. ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y⟧ ⟹ i ∈ Is› 2. ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y⟧ ⟹ x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≺ y› 3. ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≈ y⟧ ⟹ i ∈ Is› 4. ‹⋀i. ⟦i ∈ Is; x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≈ y⟧ ⟹ x ⇘(if i ∈ C then P i ∪ {(y, x)} ∪ {(y, u) |u. x ⇘(P i)⇙≼ u} ∪ {(u, x) |u. u ⇘(P i)⇙≼ y} ∪ {(v, u) |u v. x ⇘(P i)⇙≼ u ∧ v ⇘(P i)⇙≼ y} else P i)⇙≈ y› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) qed lemma positively_responsive_prefer: assumes profileP: "profile A Is P" and xyA: "hasw [x,y] A" and tallyP: "card { i ∈ Is. x ⇘(P i)⇙≺ y } > card { i ∈ Is. y ⇘(P i)⇙≺ x }" shows "x ⇘(scf P)⇙≺ y" proof (-) (*goal: ‹x ⇘(scf P)⇙≺ y›*) from assms (*‹profile A Is P› ‹hasw [x, y] A› ‹card {i ∈ Is. y ⇘(P i)⇙≺ x} < card {i ∈ Is. x ⇘(P i)⇙≺ y}›*) obtain P' and k where profileP': "profile A Is P'" and F: "⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y" and G: "⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y" and pivot: "k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y" and cardP': "card { i ∈ Is. x ⇘(P' i)⇙≺ y } = card { i ∈ Is. y ⇘(P' i)⇙≺ x }" (*goal: ‹(⋀P' k. ⟦profile A Is P'; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}⟧ ⟹ thesis) ⟹ thesis›*) apply - (*goal: ‹(⋀P' k. ⟦profile A Is P'; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}⟧ ⟹ thesis) ⟹ thesis›*) by (drule positively_responsive_prefer_witness (*‹⟦profile A Is ?P; hasw [?x, ?y] A; card {i ∈ Is. ?y ⇘(?P i)⇙≺ ?x} < card {i ∈ Is. ?x ⇘(?P i)⇙≺ ?y}; ⋀P' k. ⟦profile A Is P'; ⋀i. ⟦i ∈ Is; ?x ⇘(P' i)⇙≺ ?y⟧ ⟹ ?x ⇘(?P i)⇙≺ ?y; ⋀i. ⟦i ∈ Is; ?x ⇘(P' i)⇙≈ ?y⟧ ⟹ ?x ⇘(?P i)⇙≼ ?y; k ∈ Is ∧ ?x ⇘(P' k)⇙≈ ?y ∧ ?x ⇘(?P k)⇙≺ ?y; card {i ∈ Is. ?x ⇘(P' i)⇙≺ ?y} = card {i ∈ Is. ?y ⇘(P' i)⇙≺ ?x}⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*), auto) from profileP' (*‹profile (A::'a set) (Is::'i set) (P'::'i ⇒ ('a × 'a) set)›*) xyA (*‹hasw [x, y] A›*) cardP' (*‹card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}›*) have "x ⇘(scf P')⇙≈ y" apply - (*goal: ‹x ⇘(scf P')⇙≈ y›*) apply (rule anonymous_neutral_indifference (*‹⟦profile A Is ?P; hasw [?x, ?y] A; card {i ∈ Is. ?x ⇘(?P i)⇙≺ ?y} = card {i ∈ Is. ?y ⇘(?P i)⇙≺ ?x}⟧ ⟹ ?x ⇘(scf ?P)⇙≈ ?y›*)) (*goals: 1. ‹⟦profile A Is P'; hasw [x, y] A; card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}⟧ ⟹ profile A Is P'› 2. ‹⟦profile A Is P'; hasw [x, y] A; card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}⟧ ⟹ hasw [x, y] A› 3. ‹⟦profile A Is P'; hasw [x, y] A; card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}⟧ ⟹ card {i ∈ Is. x ⇘(P' i)⇙≺ y} = card {i ∈ Is. y ⇘(P' i)⇙≺ x}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . with xyA (*‹hasw [x, y] A›*) F (*‹⟦?i ∈ Is; x ⇘(P' ?i)⇙≺ y⟧ ⟹ x ⇘(P ?i)⇙≺ y›*) G (*‹⟦?i ∈ Is; x ⇘(P' ?i)⇙≈ y⟧ ⟹ x ⇘(P ?i)⇙≼ y›*) pivot (*‹k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y›*) show "?thesis" (*goal: ‹x ⇘(scf P)⇙≺ y›*) apply - (*goal: ‹x ⇘(scf P)⇙≺ y›*) apply (rule positively_responsiveD[OF positively_responsive profileP' profileP] (*‹⟦?x ∈ A; ?y ∈ A; ⋀i. ⟦i ∈ Is; ?x ⇘(P' i)⇙≺ ?y⟧ ⟹ ?x ⇘(P i)⇙≺ ?y; ⋀i. ⟦i ∈ Is; ?x ⇘(P' i)⇙≈ ?y⟧ ⟹ ?x ⇘(P i)⇙≼ ?y; ∃k∈Is. ?x ⇘(P' k)⇙≈ ?y ∧ ?x ⇘(P k)⇙≺ ?y ∨ ?y ⇘(P' k)⇙≺ ?x ∧ ?x ⇘(P k)⇙≼ ?y; ?x ⇘(scf P')⇙≼ ?y⟧ ⟹ ?x ⇘(scf P)⇙≺ ?y›*)) (*goals: 1. ‹⟦hasw [x, y] A; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; x ⇘(scf P')⇙≈ y⟧ ⟹ x ∈ A› 2. ‹⟦hasw [x, y] A; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; x ⇘(scf P')⇙≈ y⟧ ⟹ y ∈ A› 3. ‹⋀i. ⟦hasw [x, y] A; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; x ⇘(scf P')⇙≈ y; i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y› 4. ‹⋀i. ⟦hasw [x, y] A; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; x ⇘(scf P')⇙≈ y; i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y› 5. ‹⟦hasw [x, y] A; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; x ⇘(scf P')⇙≈ y⟧ ⟹ ∃k∈Is. x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y ∨ y ⇘(P' k)⇙≺ x ∧ x ⇘(P k)⇙≼ y› 6. ‹⟦hasw [x, y] A; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≺ y⟧ ⟹ x ⇘(P i)⇙≺ y; ⋀i. ⟦i ∈ Is; x ⇘(P' i)⇙≈ y⟧ ⟹ x ⇘(P i)⇙≼ y; k ∈ Is ∧ x ⇘(P' k)⇙≈ y ∧ x ⇘(P k)⇙≺ y; x ⇘(scf P')⇙≈ y⟧ ⟹ x ⇘(scf P')⇙≼ y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . qed lemma MMD_r2l: assumes profileP: "profile A Is P" and xyA: "hasw [x,y] A" shows "x ⇘(scf P)⇙≼ y ⟷ x ⇘(MMD Is P)⇙≼ y" proof (cases rule: linorder_cases (*‹⟦?x < ?y ⟹ ?P; ?x = ?y ⟹ ?P; ?y < ?x ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹?x < ?y ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)› 2. ‹?x = ?y ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)› 3. ‹?y < ?x ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)›*) assume "card { i ∈ Is. x ⇘(P i)⇙≺ y } = card { i ∈ Is. y ⇘(P i)⇙≺ x }" (*‹card {i::'i ∈ Is::'i set. (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ (y::'a)} = card {i::'i ∈ Is. y ⇘(P i)⇙≺ x}›*) with profileP (*‹profile A Is P›*) xyA (*‹hasw [x, y] A›*) show "?thesis" (*goal: ‹((x::'a::type) ⇘((scf::('i::type ⇒ ('a::type × 'a::type) set) ⇒ ('a::type × 'a::type) set) (P::'i::type ⇒ ('a::type × 'a::type) set))⇙≼ (y::'a::type)) = (x ⇘(MMD (Is::'i::type set) P)⇙≼ y)›*) using anonymous_neutral_indifference (*‹⟦profile A Is ?P; hasw [?x, ?y] A; card {i ∈ Is. ?x ⇘(?P i)⇙≺ ?y} = card {i ∈ Is. ?y ⇘(?P i)⇙≺ ?x}⟧ ⟹ ?x ⇘(scf ?P)⇙≈ ?y›*) unfolding indifferent_pref_def MMD_def (*goal: ‹((x::'a) ⇘((scf::('i ⇒ ('a × 'a) set) ⇒ ('a × 'a) set) (P::'i ⇒ ('a × 'a) set))⇙≼ (y::'a)) = (x ⇘{(x::'a, y::'a). card {i::'i ∈ Is::'i set. y ⇘(P i)⇙≺ x} ≤ card {i::'i ∈ Is. x ⇘(P i)⇙≺ y}}⇙≼ y)›*) by simp next (*goals: 1. ‹card {i ∈ Is. x ⇘(P i)⇙≺ y} < card {i ∈ Is. y ⇘(P i)⇙≺ x} ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)› 2. ‹card {i ∈ Is. y ⇘(P i)⇙≺ x} < card {i ∈ Is. x ⇘(P i)⇙≺ y} ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)›*) assume "card { i ∈ Is. x ⇘(P i)⇙≺ y } > card { i ∈ Is. y ⇘(P i)⇙≺ x }" (*‹card {i::'i ∈ Is::'i set. (y::'a) ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ (x::'a)} < card {i::'i ∈ Is. x ⇘(P i)⇙≺ y}›*) with profileP (*‹profile A Is P›*) xyA (*‹hasw [x::'a, y::'a] (A::'a set)›*) show "?thesis" (*goal: ‹(x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)›*) using positively_responsive_prefer (*‹⟦profile (A::'a set) (Is::'i set) (?P::'i ⇒ ('a × 'a) set); hasw [?x::'a, ?y::'a] A; card {i::'i ∈ Is. ?y ⇘(?P i)⇙≺ ?x} < card {i::'i ∈ Is. ?x ⇘(?P i)⇙≺ ?y}⟧ ⟹ ?x ⇘((scf::('i ⇒ ('a × 'a) set) ⇒ ('a × 'a) set) ?P)⇙≺ ?y›*) unfolding strict_pref_def MMD_def (*goal: ‹((x::'a) ⇘((scf::('i ⇒ ('a × 'a) set) ⇒ ('a × 'a) set) (P::'i ⇒ ('a × 'a) set))⇙≼ (y::'a)) = (x ⇘{(x::'a, y::'a). card {i::'i ∈ Is::'i set. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} ≤ card {i::'i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i}}⇙≼ y)›*) by simp next (*goal: ‹card {i ∈ Is. x ⇘(P i)⇙≺ y} < card {i ∈ Is. y ⇘(P i)⇙≺ x} ⟹ (x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)›*) assume "card { i ∈ Is. x ⇘(P i)⇙≺ y } < card { i ∈ Is. y ⇘(P i)⇙≺ x }" (*‹card {i::'i ∈ Is::'i set. (x::'a) ⇘((P::'i ⇒ ('a × 'a) set) i)⇙≺ (y::'a)} < card {i::'i ∈ Is. y ⇘(P i)⇙≺ x}›*) with profileP (*‹profile (A::'a set) (Is::'i set) (P::'i ⇒ ('a × 'a) set)›*) xyA (*‹hasw [x, y] A›*) show "?thesis" (*goal: ‹(x ⇘(scf P)⇙≼ y) = (x ⇘(MMD Is P)⇙≼ y)›*) using positively_responsive_prefer (*‹⟦profile A Is ?P; hasw [?x, ?y] A; card {i ∈ Is. ?y ⇘(?P i)⇙≺ ?x} < card {i ∈ Is. ?x ⇘(?P i)⇙≺ ?y}⟧ ⟹ ?x ⇘(scf ?P)⇙≺ ?y›*) unfolding strict_pref_def MMD_def (*goal: ‹(x ⇘(scf P)⇙≼ y) = (x ⇘{(x, y). card {i ∈ Is. y ⇘(P i)⇙≼ x ∧ (x, y) ∉ P i} ≤ card {i ∈ Is. x ⇘(P i)⇙≼ y ∧ (y, x) ∉ P i}}⇙≼ y)›*) by clarsimp qed end text‹May's original paper \<^cite>‹"May:1952"› goes on to show that the conditions are independent by exhibiting choice rules that differ from @{term "MMD"} and satisfy the conditions remaining after any particular one is removed. I leave this to future work. May also wrote a later article \<^cite>‹"May:1953"› where he shows that the conditions are completely independent, i.e. for every partition of the conditions into two sets, there is a voting rule that satisfies one and not the other. There are many later papers that characterise MMD with different sets of conditions. › subsection‹The Plurality Rule› text‹Goodin and List \<^cite>‹"GoodinList:2006"› show that May's original result can be generalised to characterise plurality voting. The following shows that this result is a short step from Sen's much earlier generalisation. \emph{Plurality voting} is a choice function that returns the alternative that receives the most votes, or the set of such alternatives in the case of a tie. Profiles are restricted to those where each individual casts a vote in favour of a single alternative.› type_synonym ('a, 'i) SVProfile = "'i ⇒ 'a" definition svprofile :: "'a set ⇒ 'i set ⇒ ('a, 'i) SVProfile ⇒ bool" where "svprofile A Is F ≡ Is ≠ {} ∧ F ` Is ⊆ A" definition plurality_rule :: "'a set ⇒ 'i set ⇒ ('a, 'i) SVProfile ⇒ 'a set" where "plurality_rule A Is F ≡ { x ∈ A . ∀y ∈ A. card { i ∈ Is . F i = x } ≥ card { i ∈ Is . F i = y } }" text‹By translating single-vote profiles into RPRs in the obvious way, the choice function arising from @{term "MMD"} coincides with traditional plurality voting.› definition MMD_plurality_rule :: "'a set ⇒ 'i set ⇒ ('a, 'i) Profile ⇒ 'a set" where "MMD_plurality_rule A Is P ≡ choiceSet A (MMD Is P)" definition single_vote_to_RPR :: "'a set ⇒ 'a ⇒ 'a RPR" where "single_vote_to_RPR A a ≡ { (a, x) |x. x ∈ A } ∪ (A - {a}) × (A - {a})" lemma single_vote_to_RPR_iff: "⟦ a ∈ A; x ∈ A; a ≠ x ⟧ ⟹ (a ⇘(single_vote_to_RPR A b)⇙≺ x) ⟷ (b = a)" unfolding single_vote_to_RPR_def strict_pref_def (*goal: ‹⟦a ∈ A; x ∈ A; a ≠ x⟧ ⟹ (a ⇘({(b, x) |x. x ∈ A} ∪ (A - {b}) × (A - {b}))⇙≼ x ∧ (x, a) ∉ {(b, x) |x. x ∈ A} ∪ (A - {b}) × (A - {b})) = (b = a)›*) by auto lemma plurality_rule_equiv: "plurality_rule A Is F = MMD_plurality_rule A Is (single_vote_to_RPR A ∘ F)" proof (-) (*goal: ‹plurality_rule A Is F = MMD_plurality_rule A Is (single_vote_to_RPR A ∘ F)›*) { fix x and y have "⟦ x ∈ A; y ∈ A ⟧ ⟹ (card {i ∈ Is. F i = y} ≤ card {i ∈ Is. F i = x}) = (card {i ∈ Is. y ⇘(single_vote_to_RPR A (F i))⇙≺ x} ≤ card {i ∈ Is. x ⇘(single_vote_to_RPR A (F i))⇙≺ y})" apply (cases "x=y") (*goals: 1. ‹⟦(x::'a) ∈ (A::'a set); (y::'a) ∈ A; x = y⟧ ⟹ (card {i::'b ∈ Is::'b set. (F::'b ⇒ 'a) i = y} ≤ card {i::'b ∈ Is. F i = x}) = (card {i::'b ∈ Is. y ⇘(single_vote_to_RPR A (F i))⇙≺ x} ≤ card {i::'b ∈ Is. x ⇘(single_vote_to_RPR A (F i))⇙≺ y})› 2. ‹⟦(x::'a) ∈ (A::'a set); (y::'a) ∈ A; x ≠ y⟧ ⟹ (card {i::'b ∈ Is::'b set. (F::'b ⇒ 'a) i = y} ≤ card {i::'b ∈ Is. F i = x}) = (card {i::'b ∈ Is. y ⇘(single_vote_to_RPR A (F i))⇙≺ x} ≤ card {i::'b ∈ Is. x ⇘(single_vote_to_RPR A (F i))⇙≺ y})› discuss goal 1*) apply ((auto iff: single_vote_to_RPR_iff (*‹⟦?a ∈ ?A; ?x ∈ ?A; ?a ≠ ?x⟧ ⟹ (?a ⇘(single_vote_to_RPR ?A ?b)⇙≺ ?x) = (?b = ?a)›*))[1]) (*discuss goal 2*) apply ((auto iff: single_vote_to_RPR_iff (*‹⟦?a ∈ ?A; ?x ∈ ?A; ?a ≠ ?x⟧ ⟹ (?a ⇘(single_vote_to_RPR ?A ?b)⇙≺ ?x) = (?b = ?a)›*))[1]) (*proven 2 subgoals*) . } thus "?thesis" (*goal: ‹plurality_rule A Is F = MMD_plurality_rule A Is (single_vote_to_RPR A ∘ F)›*) unfolding plurality_rule_def MMD_plurality_rule_def choiceSet_def MMD_def (*goal: ‹{x::'a ∈ A::'a set. ∀y::'a∈A. card {i::'b ∈ Is::'b set. (F::'b ⇒ 'a) i = y} ≤ card {i::'b ∈ Is. F i = x}} = {x::'a ∈ A. ∀y::'a∈A. x ⇘{(x::'a, y::'a). card {i::'b ∈ Is. y ⇘((single_vote_to_RPR A ∘ F) i)⇙≺ x} ≤ card {i::'b ∈ Is. x ⇘((single_vote_to_RPR A ∘ F) i)⇙≺ y}}⇙≼ y}›*) by auto qed text‹Thus it is clear that Sen's generalisation of May's result applies to this case as well. Their paper goes on to show how strengthening the anonymity condition gives rise to a characterisation of approval voting that strictly generalises May's original theorem. As this requires some rearrangement of the proof I leave it to future work.› (*<*) end (*>*)
{ "path": "afp-2025-02-12/thys/SenSocialChoice/May.thy", "repo": "afp-2025-02-12", "sha": "1cb4d63e5e8ec664df8f40236c8afcfc65003373be6e619ac9fa91c9afa5ca30" }
(* Title: HOL/Cardinals/Wellorder_Relation.thy Author: Andrei Popescu, TU Muenchen Copyright 2012 Well-order relations. *) section ‹Well-Order Relations› theory Wellorder_Relation imports Wellfounded_More begin context wo_rel begin subsection ‹Auxiliaries› lemma PREORD: "Preorder r" using WELL (*‹Well_order (r::('a::type × 'a::type) set)›*) order_on_defs[of _ r] (*‹preorder_on (?A::'a set) (r::('a × 'a) set) ≡ refl_on ?A r ∧ trans r› ‹partial_order_on ?A r ≡ preorder_on ?A r ∧ antisym r› ‹linear_order_on ?A r ≡ partial_order_on ?A r ∧ total_on ?A r› ‹strict_linear_order_on ?A r ≡ trans r ∧ irrefl r ∧ total_on ?A r› ‹well_order_on ?A r ≡ linear_order_on ?A r ∧ wf (r - Id)›*) by auto lemma PARORD: "Partial_order r" using WELL (*‹Well_order r›*) order_on_defs[of _ r] (*‹preorder_on (?A::'a set) (r::('a × 'a) set) ≡ refl_on ?A r ∧ trans r› ‹partial_order_on (?A::'a set) (r::('a × 'a) set) ≡ preorder_on ?A r ∧ antisym r› ‹linear_order_on ?A r ≡ partial_order_on ?A r ∧ total_on ?A r› ‹strict_linear_order_on (?A::'a set) (r::('a × 'a) set) ≡ trans r ∧ irrefl r ∧ total_on ?A r› ‹well_order_on (?A::'a set) (r::('a × 'a) set) ≡ linear_order_on ?A r ∧ wf (r - Id)›*) by auto lemma cases_Total2: "⋀ phi a b. ⟦{a,b} ≤ Field r; ((a,b) ∈ r - Id ⟹ phi a b); ((b,a) ∈ r - Id ⟹ phi a b); (a = b ⟹ phi a b)⟧ ⟹ phi a b" using TOTALS (*‹∀a∈Field r. ∀b∈Field r. (a, b) ∈ r ∨ (b, a) ∈ r›*) by auto subsection ‹Well-founded induction and recursion adapted to non-strict well-order relations› lemma worec_unique_fixpoint: assumes ADM: "adm_wo H" and fp: "f = H f" shows "f = worec H" proof (-) (*goal: ‹f = worec H›*) have "adm_wf (r - Id) H" unfolding adm_wf_def (*goal: ‹∀(f::'a ⇒ 'b) (g::'a ⇒ 'b) x::'a. (∀z::'a. (z, x) ∈ (r::('a × 'a) set) - Id ⟶ f z = g z) ⟶ (H::('a ⇒ 'b) ⇒ 'a ⇒ 'b) f x = H g x›*) using ADM (*‹adm_wo H›*) adm_wo_def[of H] (*‹adm_wo H ≡ ∀f g x. (∀y∈local.underS x. f y = g y) ⟶ H f x = H g x›*) underS_def[of r] (*‹local.underS ?a ≡ {b. b ≠ ?a ∧ (b, ?a) ∈ r}›*) by auto hence "f = wfrec (r - Id) H" using fp (*‹f = H f›*) WF (*‹wf (r - Id)›*) wfrec_unique_fixpoint[of "r - Id" H] (*‹⟦wf (r - Id); adm_wf (r - Id) H; ?f = H ?f⟧ ⟹ ?f = wfrec (r - Id) H›*) by simp thus "?thesis" (*goal: ‹f = worec H›*) unfolding worec_def (*goal: ‹(f::'a::type ⇒ 'b::type) = wfrec ((r::('a::type × 'a::type) set) - Id) (H::('a::type ⇒ 'b::type) ⇒ 'a::type ⇒ 'b::type)›*) . qed subsubsection ‹Properties of max2› lemma max2_iff: assumes "a ∈ Field r" and "b ∈ Field r" shows "((max2 a b, c) ∈ r) = ((a,c) ∈ r ∧ (b,c) ∈ r)" proof (standard) (*goals: 1. ‹(max2 a b, c) ∈ r ⟹ (a, c) ∈ r ∧ (b, c) ∈ r› 2. ‹(a, c) ∈ r ∧ (b, c) ∈ r ⟹ (max2 a b, c) ∈ r›*) assume "(max2 a b, c) ∈ r" (*‹(max2 (a::'a) (b::'a), c::'a) ∈ (r::('a × 'a) set)›*) thus "(a,c) ∈ r ∧ (b,c) ∈ r" using assms (*‹a ∈ Field r› ‹b ∈ Field r›*) max2_greater[of a b] (*‹⟦a ∈ Field r; b ∈ Field r⟧ ⟹ (a, max2 a b) ∈ r ∧ (b, max2 a b) ∈ r›*) TRANS (*‹trans r›*) trans_def[of r] (*‹trans r = (∀x y z. (x, y) ∈ r ⟶ (y, z) ∈ r ⟶ (x, z) ∈ r)›*) by blast next (*goal: ‹(a::'a, c::'a) ∈ (r::('a × 'a) set) ∧ (b::'a, c) ∈ r ⟹ (max2 a b, c) ∈ r›*) assume "(a,c) ∈ r ∧ (b,c) ∈ r" (*‹(a::'a, c::'a) ∈ (r::('a × 'a) set) ∧ (b::'a, c) ∈ r›*) thus "(max2 a b, c) ∈ r" using assms (*‹(a::'a::type) ∈ Field (r::('a::type × 'a::type) set)› ‹b ∈ Field r›*) max2_among[of a b] (*‹⟦a ∈ Field r; b ∈ Field r⟧ ⟹ max2 a b ∈ {a, b}›*) by auto qed subsubsection ‹Properties of minim› lemma minim_Under: "⟦B ≤ Field r; B ≠ {}⟧ ⟹ minim B ∈ Under B" by (auto simp add: Under_def (*‹Order_Relation.Under ?r ?A ≡ {b ∈ Field ?r. ∀a∈?A. (b, a) ∈ ?r}›*) minim_inField (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ Field r›*) minim_least (*‹⟦?B ⊆ Field r; ?b ∈ ?B⟧ ⟹ (minim ?B, ?b) ∈ r›*)) lemma equals_minim_Under: "⟦B ≤ Field r; a ∈ B; a ∈ Under B⟧ ⟹ a = minim B" by (auto simp add: Under_def (*‹Order_Relation.Under (?r::(?'a × ?'a) set) (?A::?'a set) ≡ {b::?'a ∈ Field ?r. ∀a::?'a∈?A. (b, a) ∈ ?r}›*) equals_minim (*‹⟦(?B::'a set) ⊆ Field (r::('a × 'a) set); (?a::'a) ∈ ?B; ⋀b::'a. b ∈ ?B ⟹ (?a, b) ∈ r⟧ ⟹ ?a = minim ?B›*)) lemma minim_iff_In_Under: assumes SUB: "B ≤ Field r" and NE: "B ≠ {}" shows "(a = minim B) = (a ∈ B ∧ a ∈ Under B)" proof (standard) (*goals: 1. ‹a = minim B ⟹ a ∈ B ∧ a ∈ local.Under B› 2. ‹a ∈ B ∧ a ∈ local.Under B ⟹ a = minim B›*) assume "a = minim B" (*‹(a::'a) = minim (B::'a set)›*) thus "a ∈ B ∧ a ∈ Under B" using assms (*‹B ⊆ Field r› ‹B ≠ {}›*) minim_in (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ ?B›*) minim_Under (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ local.Under ?B›*) by simp next (*goal: ‹a ∈ B ∧ a ∈ local.Under B ⟹ a = minim B›*) assume "a ∈ B ∧ a ∈ Under B" (*‹(a::'a) ∈ (B::'a set) ∧ a ∈ local.Under B›*) thus "a = minim B" using assms (*‹B ⊆ Field r› ‹(B::'a set) ≠ {}›*) equals_minim_Under (*‹⟦?B ⊆ Field r; ?a ∈ ?B; ?a ∈ local.Under ?B⟧ ⟹ ?a = minim ?B›*) by simp qed lemma minim_Under_under: assumes NE: "A ≠ {}" and SUB: "A ≤ Field r" shows "Under A = under (minim A)" proof (-) (*goal: ‹local.Under A = local.under (minim A)›*) have "minim A ∈ A" using assms (*‹(A::'a set) ≠ {}› ‹A ⊆ Field r›*) minim_in (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ ?B›*) by auto then have "Under A ≤ under (minim A)" by (simp add: Under_decr (*‹?A ⊆ ?B ⟹ Order_Relation.Under ?r ?B ⊆ Order_Relation.Under ?r ?A›*) under_Under_singl (*‹Order_Relation.under ?r ?a = Order_Relation.Under ?r {?a}›*)) moreover have "under (minim A) ≤ Under A" by (meson NE (*‹A ≠ {}›*) SUB (*‹A ⊆ Field r›*) TRANS (*‹trans r›*) minim_Under (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ local.Under ?B›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) under_Under_trans (*‹⟦trans ?r; ?a ∈ Order_Relation.under ?r ?b; ?b ∈ Order_Relation.Under ?r ?C⟧ ⟹ ?a ∈ Order_Relation.Under ?r ?C›*)) ultimately show "?thesis" (*goal: ‹local.Under A = local.under (minim A)›*) by blast qed lemma minim_UnderS_underS: assumes NE: "A ≠ {}" and SUB: "A ≤ Field r" shows "UnderS A = underS (minim A)" proof (-) (*goal: ‹local.UnderS A = local.underS (minim A)›*) have "minim A ∈ A" using assms (*‹A ≠ {}› ‹A ⊆ Field r›*) minim_in (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ ?B›*) by auto then have "UnderS A ≤ underS (minim A)" by (simp add: UnderS_decr (*‹(?A::?'a::type set) ⊆ (?B::?'a::type set) ⟹ Order_Relation.UnderS (?r::(?'a::type × ?'a::type) set) ?B ⊆ Order_Relation.UnderS ?r ?A›*) underS_UnderS_singl (*‹Order_Relation.underS (?r::(?'a::type × ?'a::type) set) (?a::?'a::type) = Order_Relation.UnderS ?r {?a}›*)) moreover have "underS (minim A) ≤ UnderS A" by (meson ANTISYM (*‹antisym (r::('a::type × 'a::type) set)›*) NE (*‹(A::'a::type set) ≠ {}›*) SUB (*‹(A::'a::type set) ⊆ Field (r::('a::type × 'a::type) set)›*) TRANS (*‹trans (r::('a::type × 'a::type) set)›*) minim_Under (*‹⟦(?B::'a::type set) ⊆ Field (r::('a::type × 'a::type) set); ?B ≠ {}⟧ ⟹ minim ?B ∈ local.Under ?B›*) subset_eq (*‹((?A::?'a::type set) ⊆ (?B::?'a::type set)) = (∀x::?'a::type∈?A. x ∈ ?B)›*) underS_Under_trans (*‹⟦trans (?r::(?'a::type × ?'a::type) set); antisym ?r; (?a::?'a::type) ∈ Order_Relation.underS ?r (?b::?'a::type); ?b ∈ Order_Relation.Under ?r (?C::?'a::type set)⟧ ⟹ ?a ∈ Order_Relation.UnderS ?r ?C›*)) ultimately show "?thesis" (*goal: ‹local.UnderS A = local.underS (minim A)›*) by blast qed subsubsection ‹Properties of supr› lemma supr_Above: assumes "Above B ≠ {}" shows "supr B ∈ Above B" by (simp add: assms (*‹local.Above B ≠ {}›*) Above_Field (*‹Order_Relation.Above ?r ?A ⊆ Field ?r›*) minim_in (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ ?B›*) supr_def (*‹supr ?A ≡ minim (local.Above ?A)›*)) lemma supr_greater: assumes "Above B ≠ {}" "b ∈ B" shows "(b, supr B) ∈ r" using assms (*‹local.Above (B::'a set) ≠ {}› ‹b ∈ B›*) Above_def (*‹Order_Relation.Above (?r::(?'a × ?'a) set) (?A::?'a set) ≡ {b::?'a ∈ Field ?r. ∀a::?'a∈?A. (a, b) ∈ ?r}›*) supr_Above (*‹local.Above (?B::'a::type set) ≠ {} ⟹ supr ?B ∈ local.Above ?B›*) by fastforce lemma supr_least_Above: assumes "a ∈ Above B" shows "(supr B, a) ∈ r" by (simp add: assms (*‹a ∈ local.Above B›*) Above_Field (*‹Order_Relation.Above ?r ?A ⊆ Field ?r›*) minim_least (*‹⟦?B ⊆ Field r; ?b ∈ ?B⟧ ⟹ (minim ?B, ?b) ∈ r›*) supr_def (*‹supr ?A ≡ minim (local.Above ?A)›*)) lemma supr_least: "⟦B ≤ Field r; a ∈ Field r; (⋀ b. b ∈ B ⟹ (b,a) ∈ r)⟧ ⟹ (supr B, a) ∈ r" by (auto simp add: supr_least_Above (*‹?a ∈ local.Above ?B ⟹ (supr ?B, ?a) ∈ r›*) Above_def (*‹Order_Relation.Above ?r ?A ≡ {b ∈ Field ?r. ∀a∈?A. (a, b) ∈ ?r}›*)) lemma equals_supr_Above: assumes "a ∈ Above B" "⋀ a'. a' ∈ Above B ⟹ (a,a') ∈ r" shows "a = supr B" by (simp add: assms (*‹a ∈ local.Above B› ‹?a'2 ∈ local.Above B ⟹ (a, ?a'2) ∈ r›*) Above_Field (*‹Order_Relation.Above ?r ?A ⊆ Field ?r›*) equals_minim (*‹⟦?B ⊆ Field r; ?a ∈ ?B; ⋀b. b ∈ ?B ⟹ (?a, b) ∈ r⟧ ⟹ ?a = minim ?B›*) supr_def (*‹supr ?A ≡ minim (local.Above ?A)›*)) lemma equals_supr: assumes SUB: "B ≤ Field r" and IN: "a ∈ Field r" and ABV: "⋀ b. b ∈ B ⟹ (b,a) ∈ r" and MINIM: "⋀ a'. ⟦ a' ∈ Field r; ⋀ b. b ∈ B ⟹ (b,a') ∈ r⟧ ⟹ (a,a') ∈ r" shows "a = supr B" proof (-) (*goal: ‹a = supr B›*) have "a ∈ Above B" unfolding Above_def (*goal: ‹a ∈ {b ∈ Field r. ∀a∈B. (a, b) ∈ r}›*) using ABV (*‹?b2 ∈ B ⟹ (?b2, a) ∈ r›*) IN (*‹a ∈ Field r›*) by simp moreover have "⋀ a'. a' ∈ Above B ⟹ (a,a') ∈ r" unfolding Above_def (*goal: ‹⋀a'. a' ∈ {b ∈ Field r. ∀a∈B. (a, b) ∈ r} ⟹ (a, a') ∈ r›*) using MINIM (*‹⟦?a'2 ∈ Field r; ⋀b. b ∈ B ⟹ (b, ?a'2) ∈ r⟧ ⟹ (a, ?a'2) ∈ r›*) by simp ultimately show "?thesis" (*goal: ‹a = supr B›*) using equals_supr_Above (*‹⟦?a ∈ local.Above ?B; ⋀a'. a' ∈ local.Above ?B ⟹ (?a, a') ∈ r⟧ ⟹ ?a = supr ?B›*) SUB (*‹B ⊆ Field r›*) by auto qed lemma supr_inField: assumes "Above B ≠ {}" shows "supr B ∈ Field r" by (simp add: Above_Field (*‹Order_Relation.Above ?r ?A ⊆ Field ?r›*) assms (*‹local.Above B ≠ {}›*) minim_inField (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ Field r›*) supr_def (*‹supr ?A ≡ minim (local.Above ?A)›*)) lemma supr_above_Above: assumes SUB: "B ≤ Field r" and ABOVE: "Above B ≠ {}" shows "Above B = above (supr B)" apply (clarsimp simp: Above_def (*‹Order_Relation.Above ?r ?A ≡ {b ∈ Field ?r. ∀a∈?A. (a, b) ∈ ?r}›*) above_def (*‹Order_Relation.above ?r ?a ≡ {b. (?a, b) ∈ ?r}›*) set_eq_iff (*‹(?A = ?B) = (∀x. (x ∈ ?A) = (x ∈ ?B))›*)) (*goal: ‹local.Above B = local.above (supr B)›*) by (meson ABOVE (*‹local.Above B ≠ {}›*) FieldI2 (*‹(?i, ?j) ∈ ?R ⟹ ?j ∈ Field ?R›*) SUB (*‹B ⊆ Field r›*) TRANS (*‹trans r›*) supr_greater (*‹⟦local.Above ?B ≠ {}; ?b ∈ ?B⟧ ⟹ (?b, supr ?B) ∈ r›*) supr_least (*‹⟦?B ⊆ Field r; ?a ∈ Field r; ⋀b. b ∈ ?B ⟹ (b, ?a) ∈ r⟧ ⟹ (supr ?B, ?a) ∈ r›*) transD (*‹⟦trans ?r; (?x, ?y) ∈ ?r; (?y, ?z) ∈ ?r⟧ ⟹ (?x, ?z) ∈ ?r›*)) lemma supr_under: assumes "a ∈ Field r" shows "a = supr (under a)" proof (-) (*goal: ‹a = supr (local.under a)›*) have "under a ≤ Field r" using under_Field[of r] (*‹local.under ?a ⊆ Field r›*) by auto moreover have "under a ≠ {}" using assms (*‹(a::'a::type) ∈ Field (r::('a::type × 'a::type) set)›*) Refl_under_in[of r] (*‹⟦Refl r; ?a ∈ Field r⟧ ⟹ ?a ∈ local.under ?a›*) REFL (*‹Refl r›*) by auto moreover have "a ∈ Above (under a)" using in_Above_under[of _ r] (*‹?a ∈ Field r ⟹ ?a ∈ local.Above (local.under ?a)›*) assms (*‹a ∈ Field r›*) by auto moreover have "∀a' ∈ Above (under a). (a,a') ∈ r" by (auto simp: Above_def (*‹Order_Relation.Above ?r ?A ≡ {b ∈ Field ?r. ∀a∈?A. (a, b) ∈ ?r}›*) above_def (*‹Order_Relation.above ?r ?a ≡ {b. (?a, b) ∈ ?r}›*) REFL (*‹Refl r›*) Refl_under_in (*‹⟦Refl ?r; ?a ∈ Field ?r⟧ ⟹ ?a ∈ Order_Relation.under ?r ?a›*) assms (*‹a ∈ Field r›*)) ultimately show "?thesis" (*goal: ‹a = supr (local.under a)›*) using equals_supr_Above (*‹⟦?a ∈ local.Above ?B; ⋀a'. a' ∈ local.Above ?B ⟹ (?a, a') ∈ r⟧ ⟹ ?a = supr ?B›*) by auto qed subsubsection ‹Properties of successor› lemma suc_least: "⟦B ≤ Field r; a ∈ Field r; (⋀ b. b ∈ B ⟹ a ≠ b ∧ (b,a) ∈ r)⟧ ⟹ (suc B, a) ∈ r" by (auto simp add: suc_least_AboveS (*‹?a ∈ local.AboveS ?B ⟹ (suc ?B, ?a) ∈ r›*) AboveS_def (*‹Order_Relation.AboveS ?r ?A ≡ {b ∈ Field ?r. ∀a∈?A. b ≠ a ∧ (a, b) ∈ ?r}›*)) lemma equals_suc: assumes SUB: "B ≤ Field r" and IN: "a ∈ Field r" and ABVS: "⋀ b. b ∈ B ⟹ a ≠ b ∧ (b,a) ∈ r" and MINIM: "⋀ a'. ⟦a' ∈ Field r; ⋀ b. b ∈ B ⟹ a' ≠ b ∧ (b,a') ∈ r⟧ ⟹ (a,a') ∈ r" shows "a = suc B" proof (-) (*goal: ‹a = suc B›*) have "a ∈ AboveS B" unfolding AboveS_def (*goal: ‹a ∈ {b ∈ Field r. ∀a∈B. b ≠ a ∧ (a, b) ∈ r}›*) using ABVS (*‹(?b2::'a::type) ∈ (B::'a::type set) ⟹ (a::'a::type) ≠ ?b2 ∧ (?b2, a) ∈ (r::('a::type × 'a::type) set)›*) IN (*‹a ∈ Field r›*) by simp moreover have "⋀ a'. a' ∈ AboveS B ⟹ (a,a') ∈ r" unfolding AboveS_def (*goal: ‹⋀a'. a' ∈ {b ∈ Field r. ∀a∈B. b ≠ a ∧ (a, b) ∈ r} ⟹ (a, a') ∈ r›*) using MINIM (*‹⟦?a'2 ∈ Field r; ⋀b. b ∈ B ⟹ ?a'2 ≠ b ∧ (b, ?a'2) ∈ r⟧ ⟹ (a, ?a'2) ∈ r›*) by simp ultimately show "?thesis" (*goal: ‹a = suc B›*) using equals_suc_AboveS (*‹⟦?B ⊆ Field r; ?a ∈ local.AboveS ?B; ⋀a'. a' ∈ local.AboveS ?B ⟹ (?a, a') ∈ r⟧ ⟹ ?a = suc ?B›*) SUB (*‹(B::'a set) ⊆ Field (r::('a × 'a) set)›*) by auto qed lemma suc_above_AboveS: assumes SUB: "B ≤ Field r" and ABOVE: "AboveS B ≠ {}" shows "AboveS B = above (suc B)" using assms (*‹B ⊆ Field r› ‹local.AboveS B ≠ {}›*) proof (unfold AboveS_def (*‹Order_Relation.AboveS (?r::(?'a × ?'a) set) (?A::?'a set) ≡ {b::?'a ∈ Field ?r. ∀a::?'a∈?A. b ≠ a ∧ (a, b) ∈ ?r}›*) above_def (*‹Order_Relation.above (?r::(?'a × ?'a) set) (?a::?'a) ≡ {b::?'a. (?a, b) ∈ ?r}›*), auto) (*goals: 1. ‹⋀(x::'a) (xa::'a) xb::'a. ⟦(B::'a set) ⊆ Field (r::('a × 'a) set); x ∈ Field r; ∀a::'a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; xb ∈ Field r; ∀a::'a∈B. xb ≠ a ∧ (a, xb) ∈ r⟧ ⟹ (suc B, xb) ∈ r› 2. ‹⋀(x::'a) (xa::'a) xb::'a. ⟦(B::'a set) ⊆ Field (r::('a × 'a) set); x ∈ Field r; ∀a::'a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, xb) ∈ r⟧ ⟹ xb ∈ Field r› 3. ‹⋀(x::'a) (xa::'a) a::'a. ⟦(B::'a set) ⊆ Field (r::('a × 'a) set); x ∈ Field r; ∀a::'a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, a) ∈ r; a ∈ B⟧ ⟹ False› 4. ‹⋀(x::'a) (xa::'a) (xb::'a) a::'a. ⟦(B::'a set) ⊆ Field (r::('a × 'a) set); x ∈ Field r; ∀a::'a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, xb) ∈ r; a ∈ B⟧ ⟹ (a, xb) ∈ r›*) fix a assume "a ∈ Field r" "∀b ∈ B. a ≠ b ∧ (b,a) ∈ r" (*‹(a::'a) ∈ Field (r::('a × 'a) set)› ‹∀b::'a∈B::'a set. (a::'a) ≠ b ∧ (b, a) ∈ (r::('a × 'a) set)›*) with suc_least (*‹⟦?B ⊆ Field r; ?a ∈ Field r; ⋀b. b ∈ ?B ⟹ ?a ≠ b ∧ (b, ?a) ∈ r⟧ ⟹ (suc ?B, ?a) ∈ r›*) assms (*‹(B::'a::type set) ⊆ Field (r::('a::type × 'a::type) set)› ‹local.AboveS B ≠ {}›*) show "(suc B,a) ∈ r" by auto next (*goals: 1. ‹⋀x xa xb. ⟦B ⊆ Field r; x ∈ Field r; ∀a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, xb) ∈ r⟧ ⟹ xb ∈ Field r› 2. ‹⋀x xa a. ⟦B ⊆ Field r; x ∈ Field r; ∀a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, a) ∈ r; a ∈ B⟧ ⟹ False› 3. ‹⋀x xa xb a. ⟦B ⊆ Field r; x ∈ Field r; ∀a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, xb) ∈ r; a ∈ B⟧ ⟹ (a, xb) ∈ r›*) fix b assume "(suc B, b) ∈ r" (*‹(suc (B::'a set), b::'a) ∈ (r::('a × 'a) set)›*) thus "b ∈ Field r" using REFL (*‹Refl r›*) refl_on_def[of _ r] (*‹refl_on ?A r = (r ⊆ ?A × ?A ∧ (∀x∈?A. (x, x) ∈ r))›*) by auto next (*goals: 1. ‹⋀(x::'a) (xa::'a) a::'a. ⟦(B::'a set) ⊆ Field (r::('a × 'a) set); x ∈ Field r; ∀a::'a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, a) ∈ r; a ∈ B⟧ ⟹ False› 2. ‹⋀(x::'a) (xa::'a) (xb::'a) a::'a. ⟦(B::'a set) ⊆ Field (r::('a × 'a) set); x ∈ Field r; ∀a::'a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, xb) ∈ r; a ∈ B⟧ ⟹ (a, xb) ∈ r›*) fix a and b assume 1: "(suc B, b) ∈ r" and 2: "a ∈ B" (*‹(suc (B::'a set), b::'a) ∈ (r::('a × 'a) set)› ‹(a::'a) ∈ (B::'a set)›*) with assms (*‹B ⊆ Field r› ‹local.AboveS B ≠ {}›*) suc_greater[of B a] (*‹⟦(B::'a set) ⊆ Field (r::('a × 'a) set); local.AboveS B ≠ {}; (a::'a) ∈ B⟧ ⟹ suc B ≠ a ∧ (a, suc B) ∈ r›*) have "(a,suc B) ∈ r" by auto thus "(a,b) ∈ r" using "1" (*‹(suc B, b) ∈ r›*) TRANS (*‹trans r›*) trans_def[of r] (*‹trans r = (∀x y z. (x, y) ∈ r ⟶ (y, z) ∈ r ⟶ (x, z) ∈ r)›*) by blast next (*goal: ‹⋀x xa a. ⟦B ⊆ Field r; x ∈ Field r; ∀a∈B. x ≠ a ∧ (a, x) ∈ r; xa ∈ local.AboveS B; (suc B, a) ∈ r; a ∈ B⟧ ⟹ False›*) fix a assume "(suc B, a) ∈ r" and 2: "a ∈ B" (*‹(suc (B::'a set), a::'a) ∈ (r::('a × 'a) set)› ‹(a::'a) ∈ (B::'a set)›*) thus False by (metis ABOVE (*‹local.AboveS B ≠ {}›*) ANTISYM (*‹antisym r›*) SUB (*‹B ⊆ Field r›*) antisymD (*‹⟦antisym ?r; (?x, ?y) ∈ ?r; (?y, ?x) ∈ ?r⟧ ⟹ ?x = ?y›*) suc_greater (*‹⟦?B ⊆ Field r; local.AboveS ?B ≠ {}; ?b ∈ ?B⟧ ⟹ suc ?B ≠ ?b ∧ (?b, suc ?B) ∈ r›*)) qed lemma suc_singl_pred: assumes IN: "a ∈ Field r" and ABOVE_NE: "aboveS a ≠ {}" and REL: "(a',suc {a}) ∈ r" and DIFF: "a' ≠ suc {a}" shows "a' = a ∨ (a',a) ∈ r" proof (-) (*goal: ‹(a'::'a) = (a::'a) ∨ (a', a) ∈ (r::('a × 'a) set)›*) have "*": "suc {a} ∈ Field r ∧ a' ∈ Field r" using WELL (*‹Well_order r›*) REL (*‹(a', suc {a}) ∈ r›*) well_order_on_domain (*‹⟦well_order_on ?A ?r; (?a, ?b) ∈ ?r⟧ ⟹ ?a ∈ ?A ∧ ?b ∈ ?A›*) by metis { assume "**": "a' ≠ a" (*‹(a'::'a) ≠ (a::'a)›*) hence "(a,a') ∈ r ∨ (a',a) ∈ r" using TOTAL (*‹Total r›*) IN (*‹a ∈ Field r›*) "*" (*‹suc {a} ∈ Field r ∧ a' ∈ Field r›*) by (auto simp add: total_on_def (*‹total_on ?A ?r = (∀x∈?A. ∀y∈?A. x ≠ y ⟶ (x, y) ∈ ?r ∨ (y, x) ∈ ?r)›*)) moreover { assume "(a,a') ∈ r" (*‹(a::'a, a'::'a) ∈ (r::('a × 'a) set)›*) with "**" (*‹a' ≠ a›*) "*" (*‹suc {a} ∈ Field r ∧ a' ∈ Field r›*) assms (*‹a ∈ Field r› ‹local.aboveS (a::'a) ≠ {}› ‹(a'::'a::type, suc {a::'a::type}) ∈ (r::('a::type × 'a::type) set)› ‹a' ≠ suc {a}›*) WELL (*‹Well_order r›*) suc_least[of "{a}" a'] (*‹⟦{a} ⊆ Field r; a' ∈ Field r; ⋀b. b ∈ {a} ⟹ a' ≠ b ∧ (b, a') ∈ r⟧ ⟹ (suc {a}, a') ∈ r›*) have "(suc {a},a') ∈ r" by auto with REL (*‹(a', suc {a}) ∈ r›*) DIFF (*‹a' ≠ suc {a}›*) "*" (*‹suc {a} ∈ Field r ∧ a' ∈ Field r›*) ANTISYM (*‹antisym r›*) antisym_def[of r] (*‹antisym r = (∀x y. (x, y) ∈ r ⟶ (y, x) ∈ r ⟶ x = y)›*) have False by simp } ultimately have "(a',a) ∈ r" by blast } thus "?thesis" (*goal: ‹a' = a ∨ (a', a) ∈ r›*) by blast qed lemma under_underS_suc: assumes IN: "a ∈ Field r" and ABV: "aboveS a ≠ {}" shows "underS (suc {a}) = under a" proof (-) (*goal: ‹local.underS (suc {a}) = local.under a›*) have "AboveS {a} ≠ {}" using ABV (*‹local.aboveS a ≠ {}›*) aboveS_AboveS_singl[of r] (*‹local.aboveS ?a = local.AboveS {?a}›*) by auto then have 2: "a ≠ suc {a} ∧ (a,suc {a}) ∈ r" using suc_greater[of "{a}" a] (*‹⟦{a::'a::type} ⊆ Field (r::('a::type × 'a::type) set); local.AboveS {a} ≠ {}; a ∈ {a}⟧ ⟹ suc {a} ≠ a ∧ (a, suc {a}) ∈ r›*) IN (*‹a ∈ Field r›*) by auto have "underS (suc {a}) ≤ under a" using ABV (*‹local.aboveS a ≠ {}›*) IN (*‹(a::'a::type) ∈ Field (r::('a::type × 'a::type) set)›*) REFL (*‹Refl r›*) Refl_under_in (*‹⟦Refl ?r; ?a ∈ Field ?r⟧ ⟹ ?a ∈ Order_Relation.under ?r ?a›*) underS_E (*‹?i ∈ Order_Relation.underS ?R ?j ⟹ ?i ≠ ?j ∧ (?i, ?j) ∈ ?R›*) under_def (*‹Order_Relation.under ?r ?a ≡ {b. (b, ?a) ∈ ?r}›*) wo_rel.suc_singl_pred (*‹⟦wo_rel ?r; ?a ∈ Field ?r; Order_Relation.aboveS ?r ?a ≠ {}; (?a', wo_rel.suc ?r {?a}) ∈ ?r; ?a' ≠ wo_rel.suc ?r {?a}⟧ ⟹ ?a' = ?a ∨ (?a', ?a) ∈ ?r›*) wo_rel_axioms (*‹wo_rel r›*) by fastforce moreover have "under a ≤ underS (suc {a})" by (simp add: "2" (*‹a ≠ suc {a} ∧ (a, suc {a}) ∈ r›*) ANTISYM (*‹antisym r›*) TRANS (*‹trans r›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) underS_I (*‹⟦?i ≠ ?j; (?i, ?j) ∈ ?R⟧ ⟹ ?i ∈ Order_Relation.underS ?R ?j›*) under_underS_trans (*‹⟦trans ?r; antisym ?r; ?a ∈ Order_Relation.under ?r ?b; ?b ∈ Order_Relation.underS ?r ?c⟧ ⟹ ?a ∈ Order_Relation.underS ?r ?c›*)) ultimately show "?thesis" (*goal: ‹local.underS (suc {a}) = local.under a›*) by blast qed subsubsection ‹Properties of order filters› lemma ofilter_Under[simp]: assumes "A ≤ Field r" shows "ofilter(Under A)" apply (clarsimp simp: ofilter_def (*‹local.ofilter ?A ≡ ?A ⊆ Field r ∧ (∀a∈?A. local.under a ⊆ ?A)›*)) (*goal: ‹local.ofilter (local.Under A)›*) by (meson TRANS (*‹trans r›*) Under_Field (*‹Order_Relation.Under ?r ?A ⊆ Field ?r›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) under_Under_trans (*‹⟦trans ?r; ?a ∈ Order_Relation.under ?r ?b; ?b ∈ Order_Relation.Under ?r ?C⟧ ⟹ ?a ∈ Order_Relation.Under ?r ?C›*)) lemma ofilter_UnderS[simp]: assumes "A ≤ Field r" shows "ofilter(UnderS A)" apply (clarsimp simp: ofilter_def (*‹local.ofilter ?A ≡ ?A ⊆ Field r ∧ (∀a∈?A. local.under a ⊆ ?A)›*)) (*goal: ‹local.ofilter (local.UnderS A)›*) by (meson ANTISYM (*‹antisym r›*) TRANS (*‹trans r›*) UnderS_Field (*‹Order_Relation.UnderS ?r ?A ⊆ Field ?r›*) subset_eq (*‹(?A ⊆ ?B) = (∀x∈?A. x ∈ ?B)›*) under_UnderS_trans (*‹⟦trans ?r; antisym ?r; ?a ∈ Order_Relation.under ?r ?b; ?b ∈ Order_Relation.UnderS ?r ?C⟧ ⟹ ?a ∈ Order_Relation.UnderS ?r ?C›*)) lemma ofilter_Int[simp]: "⟦ofilter A; ofilter B⟧ ⟹ ofilter(A Int B)" unfolding ofilter_def (*goal: ‹⟦(A::'a set) ⊆ Field (r::('a × 'a) set) ∧ (∀a::'a∈A. local.under a ⊆ A); (B::'a set) ⊆ Field r ∧ (∀a::'a∈B. local.under a ⊆ B)⟧ ⟹ A ∩ B ⊆ Field r ∧ (∀a::'a∈A ∩ B. local.under a ⊆ A ∩ B)›*) by blast lemma ofilter_Un[simp]: "⟦ofilter A; ofilter B⟧ ⟹ ofilter(A ∪ B)" unfolding ofilter_def (*goal: ‹⟦(A::'a::type set) ⊆ Field (r::('a::type × 'a::type) set) ∧ (∀a::'a::type∈A. local.under a ⊆ A); (B::'a::type set) ⊆ Field r ∧ (∀a::'a::type∈B. local.under a ⊆ B)⟧ ⟹ A ∪ B ⊆ Field r ∧ (∀a::'a::type∈A ∪ B. local.under a ⊆ A ∪ B)›*) by blast lemma ofilter_INTER: "⟦I ≠ {}; ⋀ i. i ∈ I ⟹ ofilter(A i)⟧ ⟹ ofilter (⋂i ∈ I. A i)" unfolding ofilter_def (*goal: ‹⟦I ≠ {}; ⋀i. i ∈ I ⟹ A i ⊆ Field r ∧ (∀a∈A i. local.under a ⊆ A i)⟧ ⟹ ⋂ (A ` I) ⊆ Field r ∧ (∀a∈⋂ (A ` I). local.under a ⊆ ⋂ (A ` I))›*) by blast lemma ofilter_Inter: "⟦S ≠ {}; ⋀ A. A ∈ S ⟹ ofilter A⟧ ⟹ ofilter (⋂S)" unfolding ofilter_def (*goal: ‹⟦S ≠ {}; ⋀A. A ∈ S ⟹ A ⊆ Field r ∧ (∀a∈A. local.under a ⊆ A)⟧ ⟹ ⋂ S ⊆ Field r ∧ (∀a∈⋂ S. local.under a ⊆ ⋂ S)›*) by blast lemma ofilter_Union: "(⋀ A. A ∈ S ⟹ ofilter A) ⟹ ofilter (⋃S)" unfolding ofilter_def (*goal: ‹(⋀A::'a set. A ∈ (S::'a set set) ⟹ A ⊆ Field (r::('a × 'a) set) ∧ (∀a::'a∈A. local.under a ⊆ A)) ⟹ ⋃ S ⊆ Field r ∧ (∀a::'a∈⋃ S. local.under a ⊆ ⋃ S)›*) by blast lemma ofilter_under_Union: "ofilter A ⟹ A = ⋃{under a| a. a ∈ A}" using ofilter_under_UNION[of A] (*‹local.ofilter A ⟹ A = ⋃ (local.under ` A)›*) by auto subsubsection ‹Other properties› lemma Trans_Under_regressive: assumes NE: "A ≠ {}" and SUB: "A ≤ Field r" shows "Under(Under A) ≤ Under A" by (metis INT_E (*‹⟦?b ∈ ⋂ (?B ` ?A); ?b ∈ ?B ?a ⟹ ?R; ?a ∉ ?A ⟹ ?R⟧ ⟹ ?R›*) NE (*‹A ≠ {}›*) REFL (*‹Refl r›*) Refl_under_Under (*‹⟦Refl ?r; ?A ≠ {}⟧ ⟹ Order_Relation.Under ?r ?A = ⋂ (Order_Relation.under ?r ` ?A)›*) SUB (*‹A ⊆ Field r›*) empty_iff (*‹(?c ∈ {}) = False›*) minim_Under (*‹⟦?B ⊆ Field r; ?B ≠ {}⟧ ⟹ minim ?B ∈ local.Under ?B›*) minim_Under_under (*‹⟦?A ≠ {}; ?A ⊆ Field r⟧ ⟹ local.Under ?A = local.under (minim ?A)›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) lemma ofilter_suc_Field: assumes OF: "ofilter A" and NE: "A ≠ Field r" shows "ofilter (A ∪ {suc A})" by (metis NE (*‹A ≠ Field r›*) OF (*‹local.ofilter A›*) REFL (*‹Refl r›*) Refl_under_underS (*‹⟦Refl ?r; ?a ∈ Field ?r⟧ ⟹ Order_Relation.under ?r ?a = Order_Relation.underS ?r ?a ∪ {?a}›*) ofilter_underS_Field (*‹local.ofilter ?A = ((∃a∈Field r. ?A = local.underS a) ∨ ?A = Field r)›*) suc_underS (*‹?a ∈ Field r ⟹ ?a = suc (local.underS ?a)›*) under_ofilter (*‹local.ofilter (local.under ?a)›*)) (* FIXME: needed? *) declare minim_in[simp] minim_inField[simp] minim_least[simp] under_ofilter[simp] underS_ofilter[simp] Field_ofilter[simp] end abbreviation "worec ≡ wo_rel.worec" abbreviation "adm_wo ≡ wo_rel.adm_wo" abbreviation "isMinim ≡ wo_rel.isMinim" abbreviation "minim ≡ wo_rel.minim" abbreviation "max2 ≡ wo_rel.max2" abbreviation "supr ≡ wo_rel.supr" abbreviation "suc ≡ wo_rel.suc" end
{ "path": "Isabelle2024/src/HOL/Cardinals/Wellorder_Relation.thy", "repo": "Isabelle2024", "sha": "96e552021565942cc9db64c2e94948e5afaa841f4dc6d3a91aa7a70eec1a76a7" }
section ‹Flow› theory Flow imports Picard_Lindeloef_Qualitative "HOL-Library.Diagonal_Subsequence" "../Library/Bounded_Linear_Operator" "../Library/Multivariate_Taylor" "../Library/Interval_Integral_HK" begin text ‹TODO: extend theorems for dependence on initial time› subsection ‹simp rules for integrability (TODO: move)› lemma blinfun_ext: "x = y ⟷ (∀i. blinfun_apply x i = blinfun_apply y i)" apply transfer (*goal: ‹(x = y) = (∀i. blinfun_apply x i = blinfun_apply y i)›*) by auto notation id_blinfun ("1⇩L") lemma blinfun_inverse_left: fixes f::"'a::euclidean_space ⇒⇩L 'a" and f' shows "f o⇩L f' = 1⇩L ⟷ f' o⇩L f = 1⇩L" apply transfer (*goal: ‹(f o⇩L f' = 1⇩L) = (f' o⇩L f = 1⇩L)›*) by (auto dest!: bounded_linear.linear (*‹bounded_linear (?f::?'a ⇒ ?'b) ⟹ linear ?f›*) simp: id_def[symmetric] (*‹(λx::?'a. x) = id›*) linear_inverse_left (*‹⟦linear (?f::?'a ⇒ ?'a); linear (?f'::?'a ⇒ ?'a)⟧ ⟹ (?f ∘ ?f' = id) = (?f' ∘ ?f = id)›*)) lemma onorm_zero_blinfun[simp]: "onorm (blinfun_apply 0) = 0" apply transfer (*goal: ‹onorm (blinfun_apply 0) = 0›*) by (simp add: onorm_zero (*‹onorm (λx. 0) = 0›*)) lemma blinfun_compose_1_left[simp]: "x o⇩L 1⇩L = x" and blinfun_compose_1_right[simp]: "1⇩L o⇩L y = y" (*goals: 1. ‹x o⇩L 1⇩L = x› 2. ‹1⇩L o⇩L y = y› discuss goal 1*) apply ((auto intro!: blinfun_eqI (*‹(⋀i::?'a::real_normed_vector. blinfun_apply (?x::?'a::real_normed_vector ⇒⇩L ?'b::real_normed_vector) i = blinfun_apply (?y::?'a::real_normed_vector ⇒⇩L ?'b::real_normed_vector) i) ⟹ ?x = ?y›*))[1]) (*discuss goal 2*) apply ((auto intro!: blinfun_eqI (*‹(⋀i. blinfun_apply ?x i = blinfun_apply ?y i) ⟹ ?x = ?y›*))[1]) (*proven 2 subgoals*) . named_theorems integrable_on_simps lemma integrable_on_refl_ivl[intro, simp]: "g integrable_on {b .. (b::'b::ordered_euclidean_space)}" and integrable_on_refl_closed_segment[intro, simp]: "h integrable_on closed_segment a a" using integrable_on_refl (*‹?f integrable_on cbox ?a ?a›*) apply - (*goals: 1. ‹(⋀(f::?'a2 ⇒ ?'b2) a::?'a2. f integrable_on cbox a a) ⟹ (g::'b ⇒ 'a) integrable_on {b::'b..b}› 2. ‹(⋀(f::?'a ⇒ ?'b) a::?'a. f integrable_on cbox a a) ⟹ (h::'c ⇒ 'd) integrable_on {a::'c--a}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma integrable_const_ivl_closed_segment[intro, simp]: "(λx. c) integrable_on closed_segment a (b::real)" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) lemma integrable_ident_ivl[intro, simp]: "(λx. x) integrable_on closed_segment a (b::real)" and integrable_ident_cbox[intro, simp]: "(λx. x) integrable_on cbox a (b::real)" (*goals: 1. ‹(λx. x) integrable_on {a--b}› 2. ‹(λx. x) integrable_on cbox a b› discuss goal 1*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) ident_integrable_on (*‹(λx. x) integrable_on {?a..?b}›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) ident_integrable_on (*‹(λx. x) integrable_on {?a..?b}›*))[1]) (*proven 2 subgoals*) . lemma content_closed_segment_real: fixes a b::real shows "content (closed_segment a b) = abs (b - a)" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) lemma integral_const_closed_segment: fixes a b::real shows "integral (closed_segment a b) (λx. c) = abs (b - a) *⇩R c" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) content_closed_segment_real (*‹content {?a--?b} = ¦?b - ?a¦›*)) lemmas [integrable_on_simps] = integrable_on_empty ― ‹empty› integrable_on_refl integrable_on_refl_ivl integrable_on_refl_closed_segment ― ‹singleton› integrable_const integrable_const_ivl integrable_const_ivl_closed_segment ― ‹constant› ident_integrable_on integrable_ident_ivl integrable_ident_cbox ― ‹identity› lemma integrable_cmul_real: fixes K::real shows "f integrable_on X ⟹ (λx. K * f x) integrable_on X " unfolding real_scaleR_def[symmetric] (*goal: ‹(f::'a::euclidean_space ⇒ real) integrable_on (X::'a::euclidean_space set) ⟹ (λx::'a::euclidean_space. (K::real) *⇩R f x) integrable_on X›*) by (rule integrable_cmul (*‹?f integrable_on ?S ⟹ (λx. ?c *⇩R ?f x) integrable_on ?S›*)) lemmas [integrable_on_simps] = integrable_0 integrable_neg integrable_cmul integrable_cmul_real integrable_on_cmult_iff integrable_on_cmult_left integrable_on_cmult_right integrable_on_cmult_iff integrable_on_cmult_left_iff integrable_on_cmult_right_iff integrable_on_cdivide_iff integrable_diff integrable_add integrable_sum lemma dist_cancel_add1: "dist (t0 + et) t0 = norm et" by (simp add: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) lemma double_nonneg_le: fixes a::real shows "a * 2 ≤ b ⟹ a ≥ 0 ⟹ a ≤ b" by arith subsection ‹Nonautonomous IVP on maximal existence interval› context ll_on_open_it begin context fixes x0 assumes iv_defined: "t0 ∈ T" "x0 ∈ X" begin lemmas closed_segment_iv_subset_domain = closed_segment_subset_domainI[OF iv_defined(1)] lemma local_unique_solutions: obtains t u L where "0 < t" "0 < u" "cball t0 t ⊆ existence_ivl t0 x0" "cball x0 (2 * u) ⊆ X" "⋀t'. t' ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 (2 * u)) (f t')" "⋀x. x ∈ cball x0 u ⟹ (flow t0 x usolves_ode f from t0) (cball t0 t) (cball x u)" "⋀x. x ∈ cball x0 u ⟹ cball x u ⊆ X" proof (-) (*goal: ‹(⋀(t::real) (u::real) L::real. ⟦(0::real) < t; (0::real) < u; cball (t0::real) t ⊆ existence_ivl t0 (x0::'a); cball x0 ((2::real) * u) ⊆ (X::'a set); ⋀t'::real. t' ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 ((2::real) * u)) ((f::real ⇒ 'a ⇒ 'a) t'); ⋀x::'a. x ∈ cball x0 u ⟹ (flow t0 x usolves_ode f from t0) (cball t0 t) (cball x u); ⋀x::'a. x ∈ cball x0 u ⟹ cball x u ⊆ X⟧ ⟹ thesis::bool) ⟹ thesis›*) from local_unique_solution[OF iv_defined] (*‹(⋀(et::real) (ex::real) (B::real) L::real. ⟦(0::real) < et; (0::real) < ex; cball (t0::real) et ⊆ (T::real set); cball (x0::'a) ex ⊆ (X::'a set); unique_on_cylinder t0 (cball t0 et) x0 ex (f::real ⇒ 'a ⇒ 'a) B L⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain et and ex and B and L where "0 < et" "0 < ex" "cball t0 et ⊆ T" "cball x0 ex ⊆ X" "unique_on_cylinder t0 (cball t0 et) x0 ex f B L" (*goal: ‹(⋀et ex B L. ⟦0 < et; 0 < ex; cball t0 et ⊆ T; cball x0 ex ⊆ X; unique_on_cylinder t0 (cball t0 et) x0 ex f B L⟧ ⟹ thesis) ⟹ thesis›*) by metis then interpret cyl: unique_on_cylinder t0 "cball t0 et" x0 ex "cball x0 ex" f B L apply - (*goals: 1. ‹⟦0 < et; 0 < ex; cball t0 et ⊆ T; cball x0 ex ⊆ X; unique_on_cylinder t0 (cball t0 et) x0 ex f B L⟧ ⟹ unique_on_cylinder t0 (cball t0 et) x0 ex f B L› 2. ‹⟦0 < et; 0 < ex; cball t0 et ⊆ T; cball x0 ex ⊆ X; unique_on_cylinder t0 (cball t0 et) x0 ex f B L⟧ ⟹ cball x0 ex ≡ cball x0 ex› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from cyl.solution_solves_ode (*‹(cyl.solution solves_ode (f::real ⇒ 'a ⇒ 'a)) (cball (t0::real) (et::real)) (cball (x0::'a) (ex::real))›*) order_refl (*‹?x ≤ ?x›*) ‹cball x0 ex ⊆ X› (*‹cball x0 ex ⊆ X›*) have "(cyl.solution solves_ode f) (cball t0 et) X" by (rule solves_ode_on_subset (*‹⟦(?x solves_ode ?f) ?S ?Y; ?T ⊆ ?S; ?Y ⊆ ?X⟧ ⟹ (?x solves_ode ?f) ?T ?X›*)) then have "cball t0 et ⊆ existence_ivl t0 x0" apply (rule existence_ivl_maximal_interval (*‹⟦(?x solves_ode f) ?S X; ?x t0 = ?x0.0; t0 ∈ ?S; is_interval ?S; ?S ⊆ T⟧ ⟹ ?S ⊆ existence_ivl t0 ?x0.0›*)) (*goals: 1. ‹cyl.solution t0 = x0› 2. ‹t0 ∈ cball t0 et› 3. ‹is_interval (cball t0 et)› 4. ‹cball t0 et ⊆ T› discuss goal 1*) apply ((insert ‹cball t0 et ⊆ T› ‹0 < et›)[1]) (*top goal: ‹cyl.solution t0 = x0› and 3 goals remain*) apply ((auto)[1]) (*discuss goal 2*) apply ((insert ‹cball t0 et ⊆ T› ‹0 < et›)[1]) (*top goal: ‹t0 ∈ cball t0 et› and 2 goals remain*) apply ((auto)[1]) (*discuss goal 3*) apply ((insert ‹cball t0 et ⊆ T› ‹0 < et›)[1]) (*top goal: ‹is_interval (cball (t0::real) (et::real))› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 4*) apply ((insert ‹cball t0 et ⊆ T› ‹0 < et›)[1]) (*goal: ‹cball t0 et ⊆ T›*) apply ((auto)[1]) (*proven 4 subgoals*) . have "cball t0 et = {t0 - et .. t0 + et}" using ‹et > 0› (*‹0 < et›*) by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*)) then have cylbounds[simp]: "cyl.tmin = t0 - et" "cyl.tmax = t0 + et" unfolding cyl.tmin_def cyl.tmax_def (*goals: 1. ‹Inf (cball t0 et) = t0 - et› 2. ‹Sup (cball t0 et) = t0 + et›*) using ‹0 < et› (*‹(0::real) < (et::real)›*) apply - (*goals: 1. ‹⟦cball t0 et = {t0 - et..t0 + et}; 0 < et⟧ ⟹ Inf (cball t0 et) = t0 - et› 2. ‹⟦cball t0 et = {t0 - et..t0 + et}; 0 < et⟧ ⟹ Sup (cball t0 et) = t0 + et› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . define et' where "et' ≡ et / 2" define ex' where "ex' ≡ ex / 2" have "et' > 0" "ex' > 0" using ‹0 < et› (*‹0 < et›*) ‹0 < ex› (*‹0 < ex›*) apply - (*goals: 1. ‹⟦(0::real) < (et::real); (0::real) < (ex::real)⟧ ⟹ (0::real) < (et'::real)› 2. ‹⟦(0::real) < (et::real); (0::real) < (ex::real)⟧ ⟹ (0::real) < (ex'::real)› discuss goal 1*) apply ((auto simp: et'_def (*‹et' ≡ et / 2›*) ex'_def (*‹ex' ≡ ex / 2›*))[1]) (*discuss goal 2*) apply ((auto simp: et'_def (*‹et' ≡ et / 2›*) ex'_def (*‹ex' ≡ ex / 2›*))[1]) (*proven 2 subgoals*) . moreover from ‹cball t0 et ⊆ existence_ivl t0 x0› (*‹cball t0 et ⊆ existence_ivl t0 x0›*) have "cball t0 et' ⊆ existence_ivl t0 x0" by (force simp: et'_def (*‹et' ≡ et / 2›*) dest!: double_nonneg_le (*‹⟦?a * 2 ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ≤ ?b›*)) moreover from this (*‹cball t0 et' ⊆ existence_ivl t0 x0›*) have "cball t0 et' ⊆ T" using existence_ivl_subset[of x0] (*‹existence_ivl (t0::real) (x0::'a::{heine_borel,banach}) ⊆ (T::real set)›*) by simp have "cball x0 (2 * ex') ⊆ X" "⋀t'. t' ∈ cball t0 et' ⟹ L-lipschitz_on (cball x0 (2 * ex')) (f t')" using cyl.lipschitz (*‹(?t::real) ∈ cball (t0::real) (et::real) ⟹ (L::real)-lipschitz_on (cball (x0::'a) (ex::real)) ((f::real ⇒ 'a ⇒ 'a) ?t)›*) ‹0 < et› (*‹0 < et›*) ‹cball x0 ex ⊆ X› (*‹cball x0 ex ⊆ X›*) apply - (*goals: 1. ‹⟦⋀t. t ∈ cball t0 et ⟹ L-lipschitz_on (cball x0 ex) (f t); 0 < et; cball x0 ex ⊆ X⟧ ⟹ cball x0 (2 * ex') ⊆ X› 2. ‹⋀t'. ⟦t' ∈ cball t0 et'; ⋀t. t ∈ cball t0 et ⟹ L-lipschitz_on (cball x0 ex) (f t); 0 < et; cball x0 ex ⊆ X⟧ ⟹ L-lipschitz_on (cball x0 (2 * ex')) (f t')› discuss goal 1*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*) intro!:)[1]) (*discuss goal 2*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*) intro!:)[1]) (*proven 2 subgoals*) . moreover { fix x0' :: 'a assume x0': "x0' ∈ cball x0 ex'" (*‹(x0'::'a) ∈ cball (x0::'a) (ex'::real)›*) { fix b assume d: "dist x0' b ≤ ex'" (*‹dist (x0'::'a) (b::'a) ≤ (ex'::real)›*) have "dist x0 b ≤ dist x0 x0' + dist x0' b" by (rule dist_triangle (*‹dist ?x ?z ≤ dist ?x ?y + dist ?y ?z›*)) also (*calculation: ‹dist x0 b ≤ dist x0 x0' + dist x0' b›*) have "… ≤ ex' + ex'" using x0' (*‹x0' ∈ cball x0 ex'›*) d (*‹dist x0' b ≤ ex'›*) by simp also (*calculation: ‹dist x0 b ≤ ex' + ex'›*) have "… ≤ ex" by (simp add: ex'_def (*‹ex' ≡ ex / 2›*)) finally (*calculation: ‹dist x0 b ≤ ex›*) have "dist x0 b ≤ ex" . } note triangle = this (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) have subs1: "cball t0 et' ⊆ cball t0 et" and subs2: "cball x0' ex' ⊆ cball x0 ex" and subs: "cball t0 et' × cball x0' ex' ⊆ cball t0 et × cball x0 ex" using ‹0 < ex› (*‹(0::real) < (ex::real)›*) ‹0 < et› (*‹0 < et›*) x0' (*‹x0' ∈ cball x0 ex'›*) (*goals: 1. ‹cball t0 et' ⊆ cball t0 et› 2. ‹cball x0' ex' ⊆ cball x0 ex› 3. ‹cball t0 et' × cball x0' ex' ⊆ cball t0 et × cball x0 ex› discuss goal 1*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*) triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) dest!: double_nonneg_le (*‹⟦?a * 2 ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ≤ ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*) triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) dest!: double_nonneg_le (*‹⟦?a * 2 ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ≤ ?b›*))[1]) (*discuss goal 3*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*) triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) dest!: double_nonneg_le (*‹⟦?a * 2 ≤ ?b; 0 ≤ ?a⟧ ⟹ ?a ≤ ?b›*))[1]) (*proven 3 subgoals*) . have subset_X: "cball x0' ex' ⊆ X" using ‹cball x0 ex ⊆ X› (*‹cball x0 ex ⊆ X›*) subs2 (*‹cball x0' ex' ⊆ cball x0 ex›*) ‹0 < ex'› (*‹0 < ex'›*) by force then have "x0' ∈ X" using ‹0 < ex'› (*‹0 < ex'›*) by force have x0': "t0 ∈ T" "x0' ∈ X" (*goals: 1. ‹t0 ∈ T› 2. ‹x0' ∈ X› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . have half_intros: "a ≤ ex' ⟹ a ≤ ex" "a ≤ et' ⟹ a ≤ et" and halfdiv_intro: "a * 2 ≤ ex / B ⟹ a ≤ ex' / B" for a using ‹0 < ex› (*‹(0::real) < (ex::real)›*) ‹0 < et› (*‹(0::real) < (et::real)›*) apply - (*goals: 1. ‹⟦a ≤ ex'; 0 < ex; 0 < et⟧ ⟹ a ≤ ex› 2. ‹⟦a ≤ et'; 0 < ex; 0 < et⟧ ⟹ a ≤ et› 3. ‹⟦a * 2 ≤ ex / B; 0 < ex; 0 < et⟧ ⟹ a ≤ ex' / B› discuss goal 1*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*))[1]) (*discuss goal 2*) apply ((auto simp: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*))[1]) (*discuss goal 3*) apply ((auto simp: ex'_def (*‹ex'::real ≡ (ex::real) / (2::real)›*) et'_def (*‹et'::real ≡ (et::real) / (2::real)›*))[1]) (*proven 3 subgoals*) . interpret cyl': solution_in_cylinder t0 "cball t0 et'" x0' ex' f "cball x0' ex'" B using ‹0 < et'› (*‹0 < et'›*) ‹0 < ex'› (*‹0 < ex'›*) ‹0 < et› (*‹(0::real) < (et::real)›*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) cyl.continuous (*‹continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x)›*) subs1 (*‹cball (t0::real) (et'::real) ⊆ cball t0 (et::real)›*) ‹cball t0 et ⊆ T› (*‹cball (t0::real) (et::real) ⊆ (T::real set)›*) (*goals: 1. ‹solution_in_cylinder t0 (cball t0 et') x0' ex' f B› 2. ‹cball x0' ex' ≡ cball x0' ex'› discuss goal 1*) apply unfold_locales (*goals: 1. ‹⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T⟧ ⟹ continuous_on (cball t0 et' × cball x0' ex') (λ(t, x). f t x)› 2. ‹⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T⟧ ⟹ is_interval (cball t0 et')› 3. ‹⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T⟧ ⟹ cball t0 et' ≠ {}› 4. ‹⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T⟧ ⟹ compact (cball t0 et')› 5. ‹⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T⟧ ⟹ t0 ∈ cball t0 et'› 6. ‹⋀x t. ⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T; t ∈ cball t0 et'; x ∈ cball x0' ex'⟧ ⟹ norm (f t x) ≤ B› 7. ‹⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T⟧ ⟹ 0 ≤ ex'› 8. ‹⋀t. ⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T; t ∈ cball t0 et'⟧ ⟹ dist t t0 ≤ ex' / B› discuss goal 1*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist (?t0.0 + ?et) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) order_trans[OF _ cyl.e_bounded] (*‹⟦?x ≤ dist ?t1 t0; ?t1 ∈ cball t0 et⟧ ⟹ ?x ≤ ex / B›*) halfdiv_intro (*‹?a * 2 ≤ ex / B ⟹ ?a ≤ ex' / B›*))[1]) (*discuss goal 2*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist (?t0.0 + ?et) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) order_trans[OF _ cyl.e_bounded] (*‹⟦?x ≤ dist ?t1 t0; ?t1 ∈ cball t0 et⟧ ⟹ ?x ≤ ex / B›*) halfdiv_intro (*‹?a * 2 ≤ ex / B ⟹ ?a ≤ ex' / B›*))[1]) (*discuss goal 3*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist (?t0.0 + ?et) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) order_trans[OF _ cyl.e_bounded] (*‹⟦?x ≤ dist ?t1 t0; ?t1 ∈ cball t0 et⟧ ⟹ ?x ≤ ex / B›*) halfdiv_intro (*‹?a * 2 ≤ ex / B ⟹ ?a ≤ ex' / B›*))[1]) (*discuss goal 4*) apply ((auto simp: split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist ((?t0.0::?'a) + (?et::?'a)) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist (x0'::'a) (?b2::'a) ≤ (ex'::real) ⟹ dist (x0::'a) ?b2 ≤ (ex::real)›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦(?t::real) ∈ cball (t0::real) (et::real); (?x::'a) ∈ cball (x0::'a) (ex::real)⟧ ⟹ norm ((f::real ⇒ 'a ⇒ 'a) ?t ?x) ≤ (B::real)›*) order_trans[OF _ cyl.e_bounded] (*‹⟦(?x::real) ≤ dist (?t1::real) (t0::real); ?t1 ∈ cball t0 (et::real)⟧ ⟹ ?x ≤ (ex::real) / (B::real)›*) halfdiv_intro (*‹(?a::real) * (2::real) ≤ (ex::real) / (B::real) ⟹ ?a ≤ (ex'::real) / B›*))[1]) (*discuss goal 5*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist (?t0.0 + ?et) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) order_trans[OF _ cyl.e_bounded] (*‹⟦?x ≤ dist ?t1 t0; ?t1 ∈ cball t0 et⟧ ⟹ ?x ≤ ex / B›*) halfdiv_intro (*‹?a * 2 ≤ ex / B ⟹ ?a ≤ ex' / B›*))[1]) (*discuss goal 6*) apply ((auto simp: split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist ((?t0.0::?'a) + (?et::?'a)) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist (x0'::'a) (?b2::'a) ≤ (ex'::real) ⟹ dist (x0::'a) ?b2 ≤ (ex::real)›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦(?t::real) ∈ cball (t0::real) (et::real); (?x::'a) ∈ cball (x0::'a) (ex::real)⟧ ⟹ norm ((f::real ⇒ 'a ⇒ 'a) ?t ?x) ≤ (B::real)›*) order_trans[OF _ cyl.e_bounded] (*‹⟦(?x::real) ≤ dist (?t1::real) (t0::real); ?t1 ∈ cball t0 (et::real)⟧ ⟹ ?x ≤ (ex::real) / (B::real)›*) halfdiv_intro (*‹(?a::real) * (2::real) ≤ (ex::real) / (B::real) ⟹ ?a ≤ (ex'::real) / B›*))[1]) (*discuss goal 7*) apply ((auto simp: split_beta' (*‹(λ(x::?'a::type, y::?'b::type). (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x y) = (λx::?'a::type × ?'b::type. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist ((?t0.0::?'a::real_normed_vector) + (?et::?'a::real_normed_vector)) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist (x0'::'a::{heine_borel,banach}) (?b2::'a::{heine_borel,banach}) ≤ (ex'::real) ⟹ dist (x0::'a::{heine_borel,banach}) ?b2 ≤ (ex::real)›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a::topological_space set); open (?T::?'a::topological_space set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. open ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b::type set); ∀x::?'b::type∈?A. open ((?B::?'b::type ⇒ ?'a::topological_space set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. closed ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a::topological_space set∈?K::?'a::topological_space set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦(?t::real) ∈ cball (t0::real) (et::real); (?x::'a::{heine_borel,banach}) ∈ cball (x0::'a::{heine_borel,banach}) (ex::real)⟧ ⟹ norm ((f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) ?t ?x) ≤ (B::real)›*) order_trans[OF _ cyl.e_bounded] (*‹⟦(?x::real) ≤ dist (?t1::real) (t0::real); ?t1 ∈ cball t0 (et::real)⟧ ⟹ ?x ≤ (ex::real) / (B::real)›*) halfdiv_intro (*‹(?a::real) * (2::real) ≤ (ex::real) / (B::real) ⟹ ?a ≤ (ex'::real) / B›*))[1]) (*discuss goal 8*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist (?t0.0 + ?et) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) order_trans[OF _ cyl.e_bounded] (*‹⟦?x ≤ dist ?t1 t0; ?t1 ∈ cball t0 et⟧ ⟹ ?x ≤ ex / B›*) halfdiv_intro (*‹?a * 2 ≤ ex / B ⟹ ?a ≤ ex' / B›*))[1]) (*top goal: ‹⋀t. ⟦0 < et'; 0 < ex'; 0 < et; ⋀t x. ⟦t ∈ cball t0 et; x ∈ cball x0 ex⟧ ⟹ norm (f t x) ≤ B; continuous_on (cball t0 et × cball x0 ex) (λ(t, x). f t x); cball t0 et' ⊆ cball t0 et; cball t0 et ⊆ T; t ∈ cball t0 et'⟧ ⟹ dist t t0 ≤ ex' / B› and 1 goal remains*) apply (simp add: ex'_def (*‹ex' ≡ ex / 2›*) et'_def (*‹et' ≡ et / 2›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) (*proven 8 subgoals*) (*discuss goal 2*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) dist_cancel_add1 (*‹dist (?t0.0 + ?et) ?t0.0 = norm ?et›*) intro!: triangle (*‹dist x0' ?b2 ≤ ex' ⟹ dist x0 ?b2 ≤ ex›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) cyl.norm_f (*‹⟦?t ∈ cball t0 et; ?x ∈ cball x0 ex⟧ ⟹ norm (f ?t ?x) ≤ B›*) order_trans[OF _ cyl.e_bounded] (*‹⟦?x ≤ dist ?t1 t0; ?t1 ∈ cball t0 et⟧ ⟹ ?x ≤ ex / B›*) halfdiv_intro (*‹?a * 2 ≤ ex / B ⟹ ?a ≤ ex' / B›*))[1]) (*proven 2 subgoals*) . interpret cyl': unique_on_cylinder t0 "cball t0 et'" x0' ex' "cball x0' ex'" f B L using cyl.lipschitz[simplified] (*‹dist t0 ?t ≤ et ⟹ L-lipschitz_on (cball x0 ex) (f ?t)›*) subs (*‹cball t0 et' × cball x0' ex' ⊆ cball t0 et × cball x0 ex›*) subs1 (*‹cball t0 et' ⊆ cball t0 et›*) (*goals: 1. ‹unique_on_cylinder t0 (cball t0 et') x0' ex' f B L› 2. ‹cball x0' ex' ≡ cball x0' ex'› discuss goal 1*) apply ((unfold_locales)[1]) (*top goal: ‹unique_on_cylinder t0 (cball t0 et') x0' ex' f B L› and 1 goal remains*) apply ((auto simp: triangle (*‹dist (x0'::'a) (?b2::'a) ≤ (ex'::real) ⟹ dist (x0::'a) ?b2 ≤ (ex::real)›*) intro!: half_intros (*‹(?a::real) ≤ (ex'::real) ⟹ ?a ≤ (ex::real)› ‹(?a::real) ≤ (et'::real) ⟹ ?a ≤ (et::real)›*) lipschitz_on_subset[OF _ subs2] (*‹(?L::real)-lipschitz_on (cball (x0::'a) (ex::real)) (?f::'a ⇒ ?'b) ⟹ ?L-lipschitz_on (cball (x0'::'a) (ex'::real)) ?f›*))[1]) (*discuss goal 2*) apply ((unfold_locales)[1]) (*proven 2 subgoals*) . from cyl'.solution_usolves_ode (*‹(cyl'.solution usolves_ode f from t0) (cball t0 et') (cball x0' ex')›*) have "(flow t0 x0' usolves_ode f from t0) (cball t0 et') (cball x0' ex')" apply (rule usolves_ode_solves_odeI (*‹⟦(?x usolves_ode ?f from ?tx) ?T ?X; (?y solves_ode ?f) ?T ?X; ?y ?tx = ?x ?tx⟧ ⟹ (?y usolves_ode ?f from ?tx) ?T ?X›*)) (*goal: ‹(flow t0 x0' usolves_ode f from t0) (cball t0 et') (cball x0' ex')›*) subgoal for apply (rule cyl'.solves_ode_on_subset_domain[where Y=X] (*‹⟦(?x solves_ode f) ?S X; ?x t0 = x0'; t0 ∈ ?S; is_interval ?S; ?S ⊆ cball t0 et'⟧ ⟹ (?x solves_ode f) ?S (cball x0' ex')›*)) (*goal: ‹(flow t0 x0' solves_ode f) (cball t0 et') (cball x0' ex')›*) subgoal for apply (rule solves_ode_on_subset[where S="existence_ivl t0 x0'" and Y=X] (*‹⟦(?x solves_ode ?f) (existence_ivl t0 x0') X; ?T ⊆ existence_ivl t0 x0'; X ⊆ ?X⟧ ⟹ (?x solves_ode ?f) ?T ?X›*)) (*goal: ‹(flow t0 x0' solves_ode f) (cball t0 et') X›*) subgoal for by (rule flow_solves_ode[OF x0'] (*‹(flow t0 x0' solves_ode f) (existence_ivl t0 x0') X›*)) subgoal for using subs2 (*‹cball x0' ex' ⊆ cball x0 ex›*) ‹cball x0 ex ⊆ X› (*‹cball x0 ex ⊆ X›*) ‹0 < et'› (*‹(0::real) < (et'::real)›*) ‹cball t0 et' ⊆ T› (*‹cball t0 et' ⊆ T›*) apply (intro existence_ivl_maximal_interval[OF solves_ode_on_subset[OF cyl'.solution_solves_ode]] (*‹⟦?S ⊆ cball t0 et'; cball x0' ex' ⊆ X; cyl'.solution t0 = ?x0.0; t0 ∈ ?S; is_interval ?S; ?S ⊆ T⟧ ⟹ ?S ⊆ existence_ivl t0 ?x0.0›*)) (*goals: 1. ‹⟦cball x0' ex' ⊆ cball x0 ex; cball x0 ex ⊆ X; 0 < et'; cball t0 et' ⊆ T⟧ ⟹ cball t0 et' ⊆ cball t0 et'› 2. ‹⟦cball x0' ex' ⊆ cball x0 ex; cball x0 ex ⊆ X; 0 < et'; cball t0 et' ⊆ T⟧ ⟹ cball x0' ex' ⊆ X› 3. ‹⟦cball x0' ex' ⊆ cball x0 ex; cball x0 ex ⊆ X; 0 < et'; cball t0 et' ⊆ T⟧ ⟹ cyl'.solution t0 = x0'› 4. ‹⟦cball x0' ex' ⊆ cball x0 ex; cball x0 ex ⊆ X; 0 < et'; cball t0 et' ⊆ T⟧ ⟹ t0 ∈ cball t0 et'› 5. ‹⟦cball x0' ex' ⊆ cball x0 ex; cball x0 ex ⊆ X; 0 < et'; cball t0 et' ⊆ T⟧ ⟹ is_interval (cball t0 et')› 6. ‹⟦cball x0' ex' ⊆ cball x0 ex; cball x0 ex ⊆ X; 0 < et'; cball t0 et' ⊆ T⟧ ⟹ cball t0 et' ⊆ T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . subgoal for by force . subgoal for by (force simp: ‹x0' ∈ X› iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) subgoal for using ‹0 < et'› (*‹(0::real) < (et'::real)›*) by force subgoal for by force subgoal for by force . subgoal for by (force simp: ‹x0' ∈ X› iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) cyl'.solution_iv (*‹cyl'.solution t0 = x0'›*)) . note this (*‹(flow t0 x0' usolves_ode f from t0) (cball t0 et') (cball x0' ex')›*) subset_X (*‹cball x0' ex' ⊆ X›*) } ultimately show thesis apply standard (*goals: 1. ‹⋀t'. t' ∈ cball t0 et' ⟹ t' ∈ cball t0 et'› 2. ‹⋀x. x ∈ cball x0 ex' ⟹ x ∈ cball x0 ex'› 3. ‹⋀x. x ∈ cball x0 ex' ⟹ x ∈ cball x0 ex'› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) qed lemma Picard_iterate_mem_existence_ivlI: assumes "t ∈ T" assumes "compact C" "x0 ∈ C" "C ⊆ X" assumes "⋀y s. s ∈ {t0 -- t} ⟹ y t0 = x0 ⟹ y ∈ {t0--s} → C ⟹ continuous_on {t0--s} y ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C" shows "t ∈ existence_ivl t0 x0" "⋀s. s ∈ {t0 -- t} ⟹ flow t0 x0 s ∈ C" proof (-) (*goals: 1. ‹t ∈ existence_ivl t0 x0› 2. ‹⋀s. s ∈ {t0--t} ⟹ flow t0 x0 s ∈ C›*) have "{t0 -- t} ⊆ T" by (intro closed_segment_subset_domain (*‹⟦?t0.0 ∈ T; ?t ∈ T⟧ ⟹ {?t0.0--?t} ⊆ T›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) assms (*‹t ∈ T› ‹compact C› ‹x0 ∈ C› ‹C ⊆ X› ‹⟦?s ∈ {t0--t}; ?y t0 = x0; ?y ∈ {t0--?s} → C; continuous_on {t0--?s} ?y⟧ ⟹ x0 + ivl_integral t0 ?s (λt. f t (?y t)) ∈ C›*)) from lipschitz_on_compact[OF compact_segment ‹{t0 -- t} ⊆ T› ‹compact C› ‹C ⊆ X›] (*‹(⋀L. (⋀ta. ta ∈ {t0--t} ⟹ L-lipschitz_on C (f ta)) ⟹ ?thesis) ⟹ ?thesis›*) obtain L where L: "⋀s. s ∈ {t0 -- t} ⟹ L-lipschitz_on C (f s)" (*goal: ‹(⋀L. (⋀s. s ∈ {t0--t} ⟹ L-lipschitz_on C (f s)) ⟹ thesis) ⟹ thesis›*) by metis interpret uc: unique_on_closed t0 "{t0 -- t}" x0 f C L using assms (*‹t ∈ T› ‹compact C› ‹x0 ∈ C› ‹C ⊆ X› ‹⟦?s ∈ {t0--t}; ?y t0 = x0; ?y ∈ {t0--?s} → C; continuous_on {t0--?s} ?y⟧ ⟹ x0 + ivl_integral t0 ?s (λt. f t (?y t)) ∈ C›*) closed_segment_iv_subset_domain (*‹⟦(?t::real) ∈ (T::real set); (?s::real) ∈ {t0::real--?t}⟧ ⟹ ?s ∈ T›*) apply unfold_locales (*goals: 1. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ is_interval {t0--t}› 2. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ {t0--t} ≠ {}› 3. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ compact {t0--t}› 4. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ t0 ∈ {t0--t}› 5. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ x0 ∈ C› 6. ‹⋀(x::real ⇒ 'a::{heine_borel,banach}) ta::real. ⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T; ta ∈ {t0--t}; x t0 = x0; x ∈ {t0--ta} → C; continuous_on {t0--ta} x⟧ ⟹ x t0 + ivl_integral t0 ta (λt::real. f t (x t)) ∈ C› 7. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ continuous_on ({t0--t} × C) (λ(t::real, x::'a::{heine_borel,banach}). f t x)› 8. ‹⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ closed C› 9. ‹⋀ta::real. ⟦(t::real) ∈ (T::real set); compact (C::'a::{heine_borel,banach} set); (x0::'a::{heine_borel,banach}) ∈ C; C ⊆ (X::'a::{heine_borel,banach} set); ⋀(s::real) y::real ⇒ 'a::{heine_borel,banach}. ⟦s ∈ {t0::real--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (y t)) ∈ C; ⋀(t::real) s::real. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T; ta ∈ {t0--t}⟧ ⟹ (L::real)-lipschitz_on C (f ta)› discuss goal 1*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 2*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 3*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 4*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 5*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 6*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 7*) apply ((auto intro!: L (*‹(?s::real) ∈ {t0::real--t::real} ⟹ (L::real)-lipschitz_on (C::'a set) ((f::real ⇒ 'a ⇒ 'a) ?s)›*) compact_imp_closed (*‹compact (?s::?'a set) ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on (?S::?'d set) (?g::?'d ⇒ real); continuous_on ?S (?h::?'d ⇒ 'a); ?g ` ?S ⊆ (T::real set); ?h ` ?S ⊆ (X::'a set)⟧ ⟹ continuous_on ?S (λx::?'d. (f::real ⇒ 'a ⇒ 'a) (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 8*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*discuss goal 9*) apply ((auto intro!: L (*‹?s ∈ {t0--t} ⟹ L-lipschitz_on C (f ?s)›*) compact_imp_closed (*‹compact ?s ⟹ closed ?s›*) ‹compact C› continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ T; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?g x) (?h x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*))[1]) (*proven 9 subgoals*) . have "{t0 -- t} ⊆ existence_ivl t0 x0" using assms (*‹t ∈ T› ‹compact C› ‹x0 ∈ C› ‹C ⊆ X› ‹⟦?s ∈ {t0--t}; ?y t0 = x0; ?y ∈ {t0--?s} → C; continuous_on {t0--?s} ?y⟧ ⟹ x0 + ivl_integral t0 ?s (λt. f t (?y t)) ∈ C›*) closed_segment_iv_subset_domain (*‹⟦?t ∈ T; ?s ∈ {t0--?t}⟧ ⟹ ?s ∈ T›*) apply (intro maximal_existence_flow[OF solves_ode_on_subset[OF uc.solution_solves_ode]] (*‹⟦?K ⊆ {t0--t}; C ⊆ X; uc.solution t0 = ?x0.0; is_interval ?K; t0 ∈ ?K; ?K ⊆ T⟧ ⟹ ?K ⊆ existence_ivl t0 ?x0.0› ‹⟦?K ⊆ {t0--t}; C ⊆ X; uc.solution t0 = ?x0.0; is_interval ?K; t0 ∈ ?K; ?K ⊆ T; ?t ∈ ?K⟧ ⟹ flow t0 ?x0.0 ?t = uc.solution ?t›*)) (*goals: 1. ‹⟦t ∈ T; compact C; x0 ∈ C; C ⊆ X; ⋀s y. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C; ⋀t s. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ {t0--t} ⊆ {t0--t}› 2. ‹⟦t ∈ T; compact C; x0 ∈ C; C ⊆ X; ⋀s y. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C; ⋀t s. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ C ⊆ X› 3. ‹⟦t ∈ T; compact C; x0 ∈ C; C ⊆ X; ⋀s y. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C; ⋀t s. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ uc.solution t0 = x0› 4. ‹⟦t ∈ T; compact C; x0 ∈ C; C ⊆ X; ⋀s y. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C; ⋀t s. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ is_interval {t0--t}› 5. ‹⟦t ∈ T; compact C; x0 ∈ C; C ⊆ X; ⋀s y. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C; ⋀t s. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ t0 ∈ {t0--t}› 6. ‹⟦t ∈ T; compact C; x0 ∈ C; C ⊆ X; ⋀s y. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt. f t (y t)) ∈ C; ⋀t s. ⟦t ∈ T; s ∈ {t0--t}⟧ ⟹ s ∈ T⟧ ⟹ {t0--t} ⊆ T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . thus "t ∈ existence_ivl t0 x0" using assms (*‹t ∈ T› ‹compact C› ‹x0 ∈ C› ‹C ⊆ X› ‹⟦?s ∈ {t0--t}; ?y t0 = x0; ?y ∈ {t0--?s} → C; continuous_on {t0--?s} ?y⟧ ⟹ x0 + ivl_integral t0 ?s (λt. f t (?y t)) ∈ C›*) by auto show "flow t0 x0 s ∈ C" if "s ∈ {t0 -- t}" for s proof (-) (*goal: ‹flow t0 x0 s ∈ C›*) have "flow t0 x0 s = uc.solution s" "uc.solution s ∈ C" using solves_odeD[OF uc.solution_solves_ode] (*‹(uc.solution has_vderiv_on (λt. f t (uc.solution t))) {t0--t}› ‹?t ∈ {t0--t} ⟹ uc.solution ?t ∈ C›*) that (*‹s ∈ {t0--t}›*) assms (*‹t ∈ T› ‹compact (C::'a set)› ‹x0 ∈ C› ‹C ⊆ X› ‹⟦?s ∈ {t0--t}; ?y t0 = x0; ?y ∈ {t0--?s} → C; continuous_on {t0--?s} ?y⟧ ⟹ x0 + ivl_integral t0 ?s (λt. f t (?y t)) ∈ C›*) apply - (*goals: 1. ‹⟦(uc.solution has_vderiv_on (λt::real. (f::real ⇒ 'a ⇒ 'a) t (uc.solution t))) {t0::real--t::real}; ⋀ta::real. ta ∈ {t0--t} ⟹ uc.solution ta ∈ (C::'a set); (s::real) ∈ {t0--t}; t ∈ (T::real set); compact C; (x0::'a) ∈ C; C ⊆ (X::'a set); ⋀(s::real) y::real ⇒ 'a. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. f t (y t)) ∈ C⟧ ⟹ flow t0 x0 s = uc.solution s› 2. ‹⟦(uc.solution has_vderiv_on (λt::real. (f::real ⇒ 'a ⇒ 'a) t (uc.solution t))) {t0::real--t::real}; ⋀ta::real. ta ∈ {t0--t} ⟹ uc.solution ta ∈ (C::'a set); (s::real) ∈ {t0--t}; t ∈ (T::real set); compact C; (x0::'a) ∈ C; C ⊆ (X::'a set); ⋀(s::real) y::real ⇒ 'a. ⟦s ∈ {t0--t}; y t0 = x0; y ∈ {t0--s} → C; continuous_on {t0--s} y⟧ ⟹ x0 + ivl_integral t0 s (λt::real. f t (y t)) ∈ C⟧ ⟹ uc.solution s ∈ C› discuss goal 1*) apply ((auto simp: closed_segment_iv_subset_domain (*‹⟦?t ∈ T; ?s ∈ {t0--?t}⟧ ⟹ ?s ∈ T›*) intro!: maximal_existence_flowI(2)[where K="{t0 -- t}"] (*‹⟦(?x has_vderiv_on (λt. f t (?x t))) {t0--t}; ⋀ta. ta ∈ {t0--t} ⟹ ?x ta ∈ X; ?x t0 = ?x0.0; is_interval {t0--t}; t0 ∈ {t0--t}; {t0--t} ⊆ T; ?t ∈ {t0--t}⟧ ⟹ flow t0 ?x0.0 ?t = ?x ?t›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_iv_subset_domain (*‹⟦(?t::real) ∈ (T::real set); (?s::real) ∈ {t0::real--?t}⟧ ⟹ ?s ∈ T›*) intro!: maximal_existence_flowI(2)[where K="{t0 -- t}"] (*‹⟦((?x::real ⇒ 'a) has_vderiv_on (λt::real. (f::real ⇒ 'a ⇒ 'a) t (?x t))) {t0::real--t::real}; ⋀ta::real. ta ∈ {t0--t} ⟹ ?x ta ∈ (X::'a set); ?x t0 = (?x0.0::'a); is_interval {t0--t}; t0 ∈ {t0--t}; {t0--t} ⊆ (T::real set); (?t::real) ∈ {t0--t}⟧ ⟹ flow t0 ?x0.0 ?t = ?x ?t›*))[1]) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹flow t0 x0 s ∈ C›*) by simp qed qed lemma flow_has_vderiv_on: "(flow t0 x0 has_vderiv_on (λt. f t (flow t0 x0 t))) (existence_ivl t0 x0)" by (rule solves_ode_vderivD[OF flow_solves_ode[OF iv_defined]] (*‹(flow t0 x0 has_vderiv_on (λt. f t (flow t0 x0 t))) (existence_ivl t0 x0)›*)) lemmas flow_has_vderiv_on_compose[derivative_intros] = has_vderiv_on_compose2[OF flow_has_vderiv_on, THEN has_vderiv_on_eq_rhs] end lemma unique_on_intersection: assumes sols: "(x solves_ode f) U X" "(y solves_ode f) V X" assumes iv_mem: "t0 ∈ U" "t0 ∈ V" and subs: "U ⊆ T" "V ⊆ T" assumes ivls: "is_interval U" "is_interval V" assumes iv: "x t0 = y t0" assumes mem: "t ∈ U" "t ∈ V" shows "x t = y t" proof (-) (*goal: ‹x t = y t›*) from maximal_existence_flow(2)[OF sols ( 1 ) refl ivls ( 1 ) iv_mem ( 1 ) subs ( 1 ) mem ( 1 )] (*‹flow t0 (x t0) t = x t›*) maximal_existence_flow(2)[OF sols ( 2 ) iv [ symmetric ] ivls ( 2 ) iv_mem ( 2 ) subs ( 2 ) mem ( 2 )] (*‹flow t0 (x t0) t = y t›*) show "?thesis" (*goal: ‹x t = y t›*) by simp qed lemma unique_solution: assumes sols: "(x solves_ode f) U X" "(y solves_ode f) U X" assumes iv_mem: "t0 ∈ U" and subs: "U ⊆ T" assumes ivls: "is_interval U" assumes iv: "x t0 = y t0" assumes mem: "t ∈ U" shows "x t = y t" by (metis unique_on_intersection (*‹⟦(?x solves_ode f) ?U X; (?y solves_ode f) ?V X; t0 ∈ ?U; t0 ∈ ?V; ?U ⊆ T; ?V ⊆ T; is_interval ?U; is_interval ?V; ?x t0 = ?y t0; ?t ∈ ?U; ?t ∈ ?V⟧ ⟹ ?x ?t = ?y ?t›*) assms (*‹(x solves_ode f) U X› ‹(y solves_ode f) U X› ‹t0 ∈ U› ‹U ⊆ T› ‹is_interval U› ‹x t0 = y t0› ‹t ∈ U›*)) lemma assumes s: "s ∈ existence_ivl t0 x0" assumes t: "t + s ∈ existence_ivl s (flow t0 x0 s)" shows flow_trans: "flow t0 x0 (s + t) = flow s (flow t0 x0 s) (s + t)" and existence_ivl_trans: "s + t ∈ existence_ivl t0 x0" proof (-) (*goals: 1. ‹flow t0 x0 (s + t) = flow s (flow t0 x0 s) (s + t)› 2. ‹s + t ∈ existence_ivl t0 x0›*) note ll_on_open_it_axioms (*‹ll_on_open_it (T::real set) (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) (X::'a::{heine_borel,banach} set)›*) moreover from ll_on_open_it_axioms (*‹ll_on_open_it (T::real set) (f::real ⇒ 'a ⇒ 'a) (X::'a set)›*) have iv_defined: "t0 ∈ T" "x0 ∈ X" and iv_defined': "s ∈ T" "flow t0 x0 s ∈ X" using ll_on_open_it.mem_existence_ivl_iv_defined (*‹⟦ll_on_open_it ?T ?f ?X; ?t ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0⟧ ⟹ ?t0.0 ∈ ?T› ‹⟦ll_on_open_it ?T ?f ?X; ?t ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0⟧ ⟹ ?x0.0 ∈ ?X›*) s (*‹(s::real) ∈ existence_ivl (t0::real) (x0::'a)›*) t (*‹(t::real) + (s::real) ∈ existence_ivl s (flow (t0::real) (x0::'a::{heine_borel,banach}) s)›*) apply - (*goals: 1. ‹⟦ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t0 ∈ T; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s)⟧ ⟹ t0 ∈ T› 2. ‹⟦ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t0 ∈ T; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s)⟧ ⟹ x0 ∈ X› 3. ‹⟦ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t0 ∈ T; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s)⟧ ⟹ s ∈ T› 4. ‹⟦ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t0 ∈ T; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s)⟧ ⟹ flow t0 x0 s ∈ X› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . have "{t0--s} ⊆ existence_ivl t0 x0" by (simp add: s (*‹s ∈ existence_ivl t0 x0›*) segment_subset_existence_ivl (*‹⟦?s ∈ existence_ivl t0 ?x0.0; ?t ∈ existence_ivl t0 ?x0.0⟧ ⟹ {?s--?t} ⊆ existence_ivl t0 ?x0.0›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) have "s ∈ existence_ivl s (flow t0 x0 s)" apply (rule ll_on_open_it.existence_ivl_initial_time (*‹⟦ll_on_open_it ?T ?f ?X; ?t0.0 ∈ ?T; ?x0.0 ∈ ?X⟧ ⟹ ?t0.0 ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0›*)) (*goals: 1. ‹ll_on_open_it T f X› 2. ‹s ∈ T› 3. ‹flow t0 x0 s ∈ X› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*discuss goal 3*) apply fact (*proven 3 subgoals*) . have "{s--t + s} ⊆ existence_ivl s (flow t0 x0 s)" apply (rule ll_on_open_it.segment_subset_existence_ivl (*‹⟦ll_on_open_it ?T ?f ?X; ?s ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0; ?t ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0⟧ ⟹ {?s--?t} ⊆ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0›*)) (*goals: 1. ‹ll_on_open_it T f X› 2. ‹s ∈ existence_ivl s (flow t0 x0 s)› 3. ‹t + s ∈ existence_ivl s (flow t0 x0 s)› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*discuss goal 3*) apply fact (*proven 3 subgoals*) . have unique: "flow t0 x0 u = flow s (flow t0 x0 s) u" if "u ∈ {s--t + s}" "u ∈ {t0--s}" for u using ll_on_open_it_axioms (*‹ll_on_open_it T f X›*) ll_on_open_it.flow_solves_ode[OF ll_on_open_it_axioms iv_defined] (*‹(flow (t0::real) (x0::'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) (existence_ivl t0 x0) (X::'a set)›*) ll_on_open_it.flow_solves_ode[OF ll_on_open_it_axioms iv_defined'] (*‹(flow s (flow t0 x0 s) solves_ode f) (existence_ivl s (flow t0 x0 s)) X›*) s (*‹s ∈ existence_ivl t0 x0›*) apply (rule ll_on_open_it.unique_on_intersection (*‹⟦ll_on_open_it ?T ?f ?X; (?x solves_ode ?f) ?U ?X; (?y solves_ode ?f) ?V ?X; ?t0.0 ∈ ?U; ?t0.0 ∈ ?V; ?U ⊆ ?T; ?V ⊆ ?T; is_interval ?U; is_interval ?V; ?x ?t0.0 = ?y ?t0.0; ?t ∈ ?U; ?t ∈ ?V⟧ ⟹ ?x ?t = ?y ?t›*)) (*goal: ‹flow t0 x0 u = flow s (flow t0 x0 s) u›*) using ‹s ∈ existence_ivl s (flow t0 x0 s)› (*‹s ∈ existence_ivl s (flow t0 x0 s)›*) existence_ivl_subset (*‹existence_ivl t0 ?x0.0 ⊆ T›*) ‹flow t0 x0 s ∈ X› (*‹flow t0 x0 s ∈ X›*) ‹s ∈ T› (*‹s ∈ T›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) s (*‹s ∈ existence_ivl t0 x0›*) t (*‹t + s ∈ existence_ivl s (flow t0 x0 s)›*) ll_on_open_it.in_existence_between_zeroI (*‹⟦ll_on_open_it ?T ?f ?X; ?t ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0; ?s ∈ {?t0.0--?t}⟧ ⟹ ?s ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0›*) that (*‹u ∈ {s--t + s}› ‹u ∈ {t0--s}›*) ll_on_open_it_axioms (*‹ll_on_open_it T f X›*) ll_on_open_it.mem_existence_ivl_subset (*‹⟦ll_on_open_it ?T ?f ?X; ?t ∈ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0⟧ ⟹ ?t ∈ ?T›*) apply - (*goals: 1. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ s ∈ existence_ivl s (flow t0 x0 s)› 2. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ existence_ivl t0 x0 ⊆ T› 3. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ existence_ivl s (flow t0 x0 s) ⊆ T› 4. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ is_interval (existence_ivl t0 x0)› 5. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ is_interval (existence_ivl s (flow t0 x0 s))› 6. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ flow t0 x0 s = flow s (flow t0 x0 s) s› 7. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ u ∈ existence_ivl t0 x0› 8. ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ u ∈ existence_ivl s (flow t0 x0 s)› discuss goal 1*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl t0 ?x0.0)›*))[1]) (*discuss goal 2*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl t0 ?x0.0)›*))[1]) (*discuss goal 3*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl t0 ?x0.0)›*))[1]) (*top goal: ‹⟦s ∈ existence_ivl s (flow t0 x0 s); ⋀x0. existence_ivl t0 x0 ⊆ T; flow t0 x0 s ∈ X; s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; t + s ∈ existence_ivl s (flow t0 x0 s); ⋀T f X t t0 x0 s. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; u ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T f X; ⋀T f X t t0 x0. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ existence_ivl s (flow t0 x0 s) ⊆ T› and 5 goals remain*) apply ((assumption)[1]) (*discuss goal 4*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl t0 ?x0.0)›*))[1]) (*discuss goal 5*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl (t0::real) (?x0.0::'a::{heine_borel,banach}))›*))[1]) (*discuss goal 6*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl t0 ?x0.0)›*))[1]) (*discuss goal 7*) apply ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl (t0::real) (?x0.0::'a))›*))[1]) (*top goal: ‹⟦(s::real) ∈ existence_ivl s (flow (t0::real) (x0::'a) s); ⋀x0::'a. existence_ivl t0 x0 ⊆ (T::real set); flow t0 x0 s ∈ (X::'a set); s ∈ T; t0 ∈ T; x0 ∈ X; s ∈ existence_ivl t0 x0; (t::real) + s ∈ existence_ivl s (flow t0 x0 s); ⋀(T::real set) (f::real ⇒ ?'a36 ⇒ ?'a36) (X::?'a36 set) (t::real) (t0::real) (x0::?'a36) s::real. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ ll_on_open.existence_ivl T f X t0 x0; (u::real) ∈ {s--t + s}; u ∈ {t0--s}; ll_on_open_it T (f::real ⇒ 'a ⇒ 'a) X; ⋀(T::real set) (f::real ⇒ ?'a41 ⇒ ?'a41) (X::?'a41 set) (t::real) (t0::real) x0::?'a41. ⟦ll_on_open_it T f X; t ∈ ll_on_open.existence_ivl T f X t0 x0⟧ ⟹ t ∈ T⟧ ⟹ u ∈ existence_ivl t0 x0› and 1 goal remains*) apply ((assumption)[1]) (*discuss goal 8*) by ((auto simp: is_interval_existence_ivl (*‹is_interval (existence_ivl (t0::real) (?x0.0::'a))›*))[1]) (*proven 8 subgoals*) let ?un = "{t0 -- s} ∪ {s -- t + s}" let ?if = "λt. if t ∈ {t0 -- s} then flow t0 x0 t else flow s (flow t0 x0 s) t" have "(?if solves_ode (λt. if t ∈ {t0 -- s} then f t else f t)) ?un (X ∪ X)" apply (rule connection_solves_ode (*‹⟦(?x solves_ode ?f) ?T ?X; (?y solves_ode ?g) ?S ?Y; closure ?S ∩ closure ?T ⊆ ?T; closure ?S ∩ closure ?T ⊆ ?S; ⋀t. ⟦t ∈ closure ?S; t ∈ closure ?T⟧ ⟹ ?x t = ?y t; ⋀t. ⟦t ∈ closure ?S; t ∈ closure ?T⟧ ⟹ ?f t (?y t) = ?g t (?y t)⟧ ⟹ ((λt. if t ∈ ?T then ?x t else ?y t) solves_ode (λt. if t ∈ ?T then ?f t else ?g t)) (?T ∪ ?S) (?X ∪ ?Y)›*)) (*goal: ‹((λt. if t ∈ {t0--s} then flow t0 x0 t else flow s (flow t0 x0 s) t) solves_ode (λt. if t ∈ {t0--s} then f t else f t)) ({t0--s} ∪ {s--t + s}) (X ∪ X)›*) subgoal for by (rule solves_ode_on_subset[OF flow_solves_ode[OF iv_defined] ‹{t0--s} ⊆ _› order_refl] (*‹(flow t0 x0 solves_ode f) {t0--s} X›*)) subgoal for by (rule solves_ode_on_subset[OF ll_on_open_it.flow_solves_ode[OF ll_on_open_it_axioms iv_defined'] ‹{s--t + s} ⊆ _› order_refl] (*‹(flow s (flow t0 x0 s) solves_ode f) {s--t + s} X›*)) subgoal for by simp subgoal for by simp subgoal for apply (rule unique (*‹⟦?u ∈ {s--t + s}; ?u ∈ {t0--s}⟧ ⟹ flow t0 x0 ?u = flow s (flow t0 x0 s) ?u›*)) (*goals: 1. ‹⟦ta_ ∈ closure {s--t + s}; ta_ ∈ closure {t0--s}⟧ ⟹ ta_ ∈ {s--t + s}› 2. ‹⟦ta_ ∈ closure {s--t + s}; ta_ ∈ closure {t0--s}⟧ ⟹ ta_ ∈ {t0--s}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . subgoal for by simp . then have ifsol: "(?if solves_ode f) ?un X" by simp moreover have "?un ⊆ existence_ivl t0 x0" using existence_ivl_subset[of x0] (*‹existence_ivl (t0::real) (x0::'a) ⊆ (T::real set)›*) ll_on_open_it.existence_ivl_subset[OF ll_on_open_it_axioms, of s "flow t0 x0 s"] (*‹existence_ivl s (flow t0 x0 s) ⊆ T›*) ‹{t0 -- s} ⊆ _› (*‹{t0::real--s::real} ⊆ existence_ivl t0 (x0::'a)›*) ‹{s--t + s} ⊆ _› (*‹{s--t + s} ⊆ existence_ivl s (flow t0 x0 s)›*) apply (intro existence_ivl_maximal_interval[OF ifsol] (*‹⟦(if t0 ∈ {t0--s} then flow t0 x0 t0 else flow s (flow t0 x0 s) t0) = ?x0.0; t0 ∈ {t0--s} ∪ {s--t + s}; is_interval ({t0--s} ∪ {s--t + s}); {t0--s} ∪ {s--t + s} ⊆ T⟧ ⟹ {t0--s} ∪ {s--t + s} ⊆ existence_ivl t0 ?x0.0›*)) (*goals: 1. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ (if t0 ∈ {t0--s} then flow t0 x0 t0 else flow s (flow t0 x0 s) t0) = x0› 2. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ t0 ∈ {t0--s} ∪ {s--t + s}› 3. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ is_interval ({t0--s} ∪ {s--t + s})› 4. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ {t0--s} ∪ {s--t + s} ⊆ T› discuss goal 1*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*))[1]) (*discuss goal 2*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval (?X::real set); is_interval (?Y::real set); ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*))[1]) (*discuss goal 3*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*))[1]) (*discuss goal 4*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*))[1]) (*proven 4 subgoals*) . then show "s + t ∈ existence_ivl t0 x0" by (auto simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*)) have "(flow t0 x0 solves_ode f) ?un X" using ‹{t0--s} ⊆ _› (*‹{t0--s} ⊆ existence_ivl t0 x0›*) ‹{s -- t + s} ⊆ _› (*‹{s--t + s} ⊆ existence_ivl s (flow t0 x0 s)›*) by (intro solves_ode_on_subset[OF flow_solves_ode ‹?un ⊆ _› order_refl] (*‹⟦t0 ∈ T; x0 ∈ X⟧ ⟹ (flow t0 x0 solves_ode f) ({t0--s} ∪ {s--t + s}) X›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) moreover have "s ∈ ?un" by simp ultimately have "?if (s + t) = flow t0 x0 (s + t)" apply (rule ll_on_open_it.unique_solution (*‹⟦ll_on_open_it ?T ?f ?X; (?x solves_ode ?f) ?U ?X; (?y solves_ode ?f) ?U ?X; ?t0.0 ∈ ?U; ?U ⊆ ?T; is_interval ?U; ?x ?t0.0 = ?y ?t0.0; ?t ∈ ?U⟧ ⟹ ?x ?t = ?y ?t›*)) (*goal: ‹(if s + t ∈ {t0--s} then flow t0 x0 (s + t) else flow s (flow t0 x0 s) (s + t)) = flow t0 x0 (s + t)›*) using existence_ivl_subset[of x0] (*‹existence_ivl t0 x0 ⊆ T›*) ll_on_open_it.existence_ivl_subset[OF ll_on_open_it_axioms, of s "flow t0 x0 s"] (*‹existence_ivl s (flow t0 x0 s) ⊆ T›*) ‹{t0 -- s} ⊆ _› (*‹{t0::real--s::real} ⊆ existence_ivl t0 (x0::'a)›*) ‹{s--t + s} ⊆ _› (*‹{s::real--(t::real) + s} ⊆ existence_ivl s (flow (t0::real) (x0::'a::{heine_borel,banach}) s)›*) apply - (*goals: 1. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ {t0--s} ∪ {s--t + s} ⊆ T› 2. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ is_interval ({t0--s} ∪ {s--t + s})› 3. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ (if s ∈ {t0--s} then flow t0 x0 s else flow s (flow t0 x0 s) s) = flow t0 x0 s› 4. ‹⟦existence_ivl t0 x0 ⊆ T; existence_ivl s (flow t0 x0 s) ⊆ T; {t0--s} ⊆ existence_ivl t0 x0; {s--t + s} ⊆ existence_ivl s (flow t0 x0 s)⟧ ⟹ s + t ∈ {t0--s} ∪ {s--t + s}› discuss goal 1*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*) simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*) simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*))[1]) (*discuss goal 3*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*) simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*))[1]) (*discuss goal 4*) apply ((auto intro!: is_real_interval_union (*‹⟦is_interval ?X; is_interval ?Y; ⟦?X ≠ {}; ?Y ≠ {}⟧ ⟹ ?X ∩ ?Y ≠ {}⟧ ⟹ is_interval (?X ∪ ?Y)›*) simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*))[1]) (*proven 4 subgoals*) . with unique[of "s + t"] (*‹⟦s + t ∈ {s--t + s}; s + t ∈ {t0--s}⟧ ⟹ flow t0 x0 (s + t) = flow s (flow t0 x0 s) (s + t)›*) show "flow t0 x0 (s + t) = flow s (flow t0 x0 s) (s + t)" by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp: ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 37 facts*)) qed lemma assumes t: "t ∈ existence_ivl t0 x0" shows flows_reverse: "flow t (flow t0 x0 t) t0 = x0" and existence_ivl_reverse: "t0 ∈ existence_ivl t (flow t0 x0 t)" proof (-) (*goals: 1. ‹flow t (flow t0 x0 t) t0 = x0› 2. ‹t0 ∈ existence_ivl t (flow t0 x0 t)›*) have iv_defined: "t0 ∈ T" "x0 ∈ X" using mem_existence_ivl_iv_defined (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ t0 ∈ T› ‹?t ∈ existence_ivl t0 ?x0.0 ⟹ ?x0.0 ∈ X›*) t (*‹(t::real) ∈ existence_ivl (t0::real) (x0::'a)›*) apply - (*goals: 1. ‹⟦⋀t x0. t ∈ existence_ivl t0 x0 ⟹ t0 ∈ T; ⋀t x0. t ∈ existence_ivl t0 x0 ⟹ x0 ∈ X; t ∈ existence_ivl t0 x0⟧ ⟹ t0 ∈ T› 2. ‹⟦⋀t x0. t ∈ existence_ivl t0 x0 ⟹ t0 ∈ T; ⋀t x0. t ∈ existence_ivl t0 x0 ⟹ x0 ∈ X; t ∈ existence_ivl t0 x0⟧ ⟹ x0 ∈ X› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . show "t0 ∈ existence_ivl t (flow t0 x0 t)" using assms (*‹t ∈ existence_ivl t0 x0›*) by (metis (no_types, opaque_lifting) closed_segment_commute (*‹{?a--?b} = {?b--?a}›*) closed_segment_subset_interval (*‹⟦is_interval ?T; ?a ∈ ?T; ?b ∈ ?T⟧ ⟹ {?a--?b} ⊆ ?T›*) ends_in_segment( (*‹?b ∈ {?a--?b}›*) 2) general.csol( (*‹?t ∈ existence_ivl ?t0.0 ?x0.0 ⟹ {?t0.0--?t} ⊆ T› ‹?t ∈ existence_ivl ?t0.0 ?x0.0 ⟹ csol ?t0.0 ?x0.0 ?t ?t0.0 = ?x0.0› ‹?t ∈ existence_ivl ?t0.0 ?x0.0 ⟹ (csol ?t0.0 ?x0.0 ?t solves_ode f) {?t0.0--?t} X›*) 2-4) general.existence_ivl_maximal_segment (*‹⟦(?x solves_ode f) {?t0.0--?t} X; ?x ?t0.0 = ?x0.0; {?t0.0--?t} ⊆ T⟧ ⟹ ?t ∈ existence_ivl ?t0.0 ?x0.0›*) general.is_interval_existence_ivl (*‹is_interval (existence_ivl ?t0.0 ?x0.0)›*) is_interval_closed_segment_1 (*‹is_interval {?a--?b}›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) ll_on_open_it.equals_flowI (*‹⟦ll_on_open_it ?T ?f ?X; ?t0.0 ∈ ?T'; is_interval ?T'; ?T' ⊆ ll_on_open.existence_ivl ?T ?f ?X ?t0.0 ?x0.0; (?z solves_ode ?f) ?T' ?X; ?z ?t0.0 = ll_on_open.flow ?T ?f ?X ?t0.0 ?x0.0 ?t0.0; ?t ∈ ?T'⟧ ⟹ ?z ?t = ll_on_open.flow ?T ?f ?X ?t0.0 ?x0.0 ?t›*) local.existence_ivl_initial_time (*‹⟦t0 ∈ T; ?x0.0 ∈ X⟧ ⟹ t0 ∈ existence_ivl t0 ?x0.0›*) local.flow_initial_time (*‹⟦t0 ∈ T; ?x0.0 ∈ X⟧ ⟹ flow t0 ?x0.0 t0 = ?x0.0›*) local.ll_on_open_it_axioms (*‹ll_on_open_it T f X›*)) then have "flow t (flow t0 x0 t) (t + (t0 - t)) = flow t0 x0 (t + (t0 - t))" apply (intro flow_trans[symmetric] (*‹⟦?s ∈ existence_ivl t0 ?x0.0; ?t + ?s ∈ existence_ivl ?s (flow t0 ?x0.0 ?s)⟧ ⟹ flow ?s (flow t0 ?x0.0 ?s) (?s + ?t) = flow t0 ?x0.0 (?s + ?t)›*)) (*goals: 1. ‹(t0::real) ∈ existence_ivl (t::real) (flow t0 (x0::'a) t) ⟹ t ∈ existence_ivl t0 x0› 2. ‹(t0::real) ∈ existence_ivl (t::real) (flow t0 (x0::'a) t) ⟹ t0 - t + t ∈ existence_ivl t (flow t0 x0 t)› discuss goal 1*) apply ((auto simp: t (*‹(t::real) ∈ existence_ivl (t0::real) (x0::'a::{heine_borel,banach})›*) iv_defined (*‹(t0::real) ∈ (T::real set)› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*))[1]) (*discuss goal 2*) apply ((auto simp: t (*‹t ∈ existence_ivl t0 x0›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*proven 2 subgoals*) . then show "flow t (flow t0 x0 t) t0 = x0" by (simp add: iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) qed lemma flow_has_derivative: assumes "t ∈ existence_ivl t0 x0" shows "(flow t0 x0 has_derivative (λi. i *⇩R f t (flow t0 x0 t))) (at t)" proof (-) (*goal: ‹(flow t0 x0 has_derivative (λi. i *⇩R f t (flow t0 x0 t))) (at t)›*) have "(flow t0 x0 has_derivative (λi. i *⇩R f t (flow t0 x0 t))) (at t within existence_ivl t0 x0)" using flow_has_vderiv_on (*‹⟦t0 ∈ T; ?x0.0 ∈ X⟧ ⟹ (flow t0 ?x0.0 has_vderiv_on (λt. f t (flow t0 ?x0.0 t))) (existence_ivl t0 ?x0.0)›*) by (auto simp: has_vderiv_on_def (*‹(?f has_vderiv_on ?f') ?S = (∀x∈?S. (?f has_vector_derivative ?f' x) (at x within ?S))›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) assms (*‹t ∈ existence_ivl t0 x0›*) mem_existence_ivl_iv_defined[OF assms] (*‹t0 ∈ T› ‹x0 ∈ X›*)) then show "?thesis" (*goal: ‹(flow t0 x0 has_derivative (λi. i *⇩R f t (flow t0 x0 t))) (at t)›*) by (simp add: at_within_open[OF assms open_existence_ivl] (*‹at t within existence_ivl t0 x0 = at t›*)) qed lemma flow_has_vector_derivative: assumes "t ∈ existence_ivl t0 x0" shows "(flow t0 x0 has_vector_derivative f t (flow t0 x0 t)) (at t)" using flow_has_derivative[OF assms] (*‹(flow t0 x0 has_derivative (λi. i *⇩R f t (flow t0 x0 t))) (at t)›*) by (simp add: has_vector_derivative_def (*‹((?f::real ⇒ ?'b) has_vector_derivative (?f'::?'b)) (?net::real filter) = (?f has_derivative (λx::real. x *⇩R ?f')) ?net›*)) lemma flow_has_vector_derivative_at_0: assumes"t ∈ existence_ivl t0 x0" shows "((λh. flow t0 x0 (t + h)) has_vector_derivative f t (flow t0 x0 t)) (at 0)" sorry lemma assumes "t ∈ existence_ivl t0 x0" shows closed_segment_subset_existence_ivl: "closed_segment t0 t ⊆ existence_ivl t0 x0" and ivl_subset_existence_ivl: "{t0 .. t} ⊆ existence_ivl t0 x0" and ivl_subset_existence_ivl': "{t .. t0} ⊆ existence_ivl t0 x0" using assms (*‹t ∈ existence_ivl t0 x0›*) in_existence_between_zeroI (*‹⟦?t ∈ existence_ivl t0 ?x0.0; ?s ∈ {t0--?t}⟧ ⟹ ?s ∈ existence_ivl t0 ?x0.0›*) apply - (*goals: 1. ‹⟦t ∈ existence_ivl t0 x0; ⋀t x0 s. ⟦t ∈ existence_ivl t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ existence_ivl t0 x0⟧ ⟹ {t0--t} ⊆ existence_ivl t0 x0› 2. ‹⟦t ∈ existence_ivl t0 x0; ⋀t x0 s. ⟦t ∈ existence_ivl t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ existence_ivl t0 x0⟧ ⟹ {t0..t} ⊆ existence_ivl t0 x0› 3. ‹⟦t ∈ existence_ivl t0 x0; ⋀t x0 s. ⟦t ∈ existence_ivl t0 x0; s ∈ {t0--t}⟧ ⟹ s ∈ existence_ivl t0 x0⟧ ⟹ {t..t0} ⊆ existence_ivl t0 x0› discuss goal 1*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 3*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*proven 3 subgoals*) . lemma flow_fixed_point: assumes t: "t ∈ existence_ivl t0 x0" shows "flow t0 x0 t = x0 + ivl_integral t0 t (λt. f t (flow t0 x0 t))" proof (-) (*goal: ‹flow t0 x0 t = x0 + ivl_integral t0 t (λt. f t (flow t0 x0 t))›*) have "(flow t0 x0 has_vderiv_on (λs. f s (flow t0 x0 s))) {t0 -- t}" using closed_segment_subset_existence_ivl[OF t] (*‹{t0--t} ⊆ existence_ivl t0 x0›*) by (auto intro!: has_vector_derivative_at_within (*‹(?f has_vector_derivative ?f') (at ?x) ⟹ (?f has_vector_derivative ?f') (at ?x within ?S)›*) flow_has_vector_derivative (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ (flow t0 ?x0.0 has_vector_derivative f ?t (flow t0 ?x0.0 ?t)) (at ?t)›*) simp: has_vderiv_on_def (*‹(?f has_vderiv_on ?f') ?S = (∀x∈?S. (?f has_vector_derivative ?f' x) (at x within ?S))›*)) from fundamental_theorem_of_calculus_ivl_integral[OF this] (*‹((λs. f s (flow t0 x0 s)) has_ivl_integral flow t0 x0 t - flow t0 x0 t0) t0 t›*) have "((λt. f t (flow t0 x0 t)) has_ivl_integral flow t0 x0 t - x0) t0 t" by (simp add: mem_existence_ivl_iv_defined[OF assms] (*‹t0 ∈ T› ‹x0 ∈ X›*)) from this[THEN ivl_integral_unique] (*‹ivl_integral t0 t (λt. f t (flow t0 x0 t)) = flow t0 x0 t - x0›*) show "?thesis" (*goal: ‹flow t0 x0 t = x0 + ivl_integral t0 t (λt. f t (flow t0 x0 t))›*) by simp qed lemma flow_continuous: "t ∈ existence_ivl t0 x0 ⟹ continuous (at t) (flow t0 x0)" by (metis has_derivative_continuous (*‹(?f has_derivative ?f') (at ?x within ?s) ⟹ continuous (at ?x within ?s) ?f›*) flow_has_derivative (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ (flow t0 ?x0.0 has_derivative (λi. i *⇩R f ?t (flow t0 ?x0.0 ?t))) (at ?t)›*)) lemma flow_tendsto: "t ∈ existence_ivl t0 x0 ⟹ (ts ⤏ t) F ⟹ ((λs. flow t0 x0 (ts s)) ⤏ flow t0 x0 t) F" apply (rule isCont_tendsto_compose[OF flow_continuous] (*‹⟦?l ∈ existence_ivl t0 ?x0.1; (?f ⤏ ?l) ?F⟧ ⟹ ((λx. flow t0 ?x0.1 (?f x)) ⤏ flow t0 ?x0.1 ?l) ?F›*)) (*goals: 1. ‹⟦t ∈ existence_ivl t0 x0; (ts ⤏ t) F⟧ ⟹ t ∈ existence_ivl t0 x0› 2. ‹⟦t ∈ existence_ivl t0 x0; (ts ⤏ t) F⟧ ⟹ (ts ⤏ t) F› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) lemma flow_continuous_on: "continuous_on (existence_ivl t0 x0) (flow t0 x0)" by (auto intro!: flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*)) lemma flow_continuous_on_intro: "continuous_on s g ⟹ (⋀xa. xa ∈ s ⟹ g xa ∈ existence_ivl t0 x0) ⟹ continuous_on s (λxa. flow t0 x0 (g xa))" by (auto intro!: continuous_on_compose2[OF flow_continuous_on] (*‹⟦continuous_on ?s ?f; ?f ` ?s ⊆ existence_ivl t0 ?x0.1⟧ ⟹ continuous_on ?s (λx. flow t0 ?x0.1 (?f x))›*)) lemma f_flow_continuous: assumes "t ∈ existence_ivl t0 x0" shows "isCont (λt. f t (flow t0 x0 t)) t" apply (rule continuous_on_interior (*‹⟦continuous_on ?S ?f; ?x ∈ interior ?S⟧ ⟹ isCont ?f ?x›*)) (*goal: ‹isCont (λt. f t (flow t0 x0 t)) t›*) by (insert existence_ivl_subset (*‹existence_ivl (t0::real) (?x0.0::'a::{heine_borel,banach}) ⊆ (T::real set)›*) assms (*‹(t::real) ∈ existence_ivl (t0::real) (x0::'a::{heine_borel,banach})›*), auto intro!: flow_in_domain (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t ∈ X›*) flow_continuous_on (*‹continuous_on (existence_ivl t0 ?x0.0) (flow t0 ?x0.0)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: interior_open (*‹open ?S ⟹ interior ?S = ?S›*) open_existence_ivl (*‹open (existence_ivl t0 ?x0.0)›*)) lemma exponential_initial_condition: assumes y0: "t ∈ existence_ivl t0 y0" assumes z0: "t ∈ existence_ivl t0 z0" assumes "Y ⊆ X" assumes remain: "⋀s. s ∈ closed_segment t0 t ⟹ flow t0 y0 s ∈ Y" "⋀s. s ∈ closed_segment t0 t ⟹ flow t0 z0 s ∈ Y" assumes lipschitz: "⋀s. s ∈ closed_segment t0 t ⟹ K-lipschitz_on Y (f s)" shows "norm (flow t0 y0 t - flow t0 z0 t) ≤ norm (y0 - z0) * exp ((K + 1) * abs (t - t0))" proof (cases) (*goals: 1. ‹?P ⟹ norm (flow t0 y0 t - flow t0 z0 t) ≤ norm (y0 - z0) * exp ((K + 1) * ¦t - t0¦)› 2. ‹¬ ?P ⟹ norm (flow t0 y0 t - flow t0 z0 t) ≤ norm (y0 - z0) * exp ((K + 1) * ¦t - t0¦)›*) assume "y0 = z0" (*‹(y0::'a) = (z0::'a)›*) thus "?thesis" (*goal: ‹norm (flow (t0::real) (y0::'a) (t::real) - flow t0 (z0::'a) t) ≤ norm (y0 - z0) * exp (((K::real) + (1::real)) * ¦t - t0¦)›*) by simp next (*goal: ‹y0 ≠ z0 ⟹ norm (flow t0 y0 t - flow t0 z0 t) ≤ norm (y0 - z0) * exp ((K + 1) * ¦t - t0¦)›*) assume ne: "y0 ≠ z0" (*‹(y0::'a) ≠ (z0::'a)›*) define K' where "K' ≡ K + 1" from lipschitz (*‹?s ∈ {t0--t} ⟹ K-lipschitz_on Y (f ?s)›*) have "K'-lipschitz_on Y (f s)" if "s ∈ {t0 -- t}" for s using that (*‹s ∈ {t0--t}›*) by (auto simp: lipschitz_on_def (*‹?C-lipschitz_on ?U ?f = (0 ≤ ?C ∧ (∀x∈?U. ∀y∈?U. dist (?f x) (?f y) ≤ ?C * dist x y))›*) K'_def (*‹K' ≡ K + 1›*) intro!: order_trans[OF _ mult_right_mono[of K "K + 1"]] (*‹⟦?x ≤ K * ?c1; K ≤ K + 1; 0 ≤ ?c1⟧ ⟹ ?x ≤ (K + 1) * ?c1›*)) from mem_existence_ivl_iv_defined[OF y0] (*‹t0 ∈ T› ‹y0 ∈ X›*) mem_existence_ivl_iv_defined[OF z0] (*‹t0 ∈ T› ‹z0 ∈ X›*) have "t0 ∈ T" and inX: "y0 ∈ X" "z0 ∈ X" apply - (*goals: 1. ‹⟦(t0::real) ∈ (T::real set); (y0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); t0 ∈ T; (z0::'a::{heine_borel,banach}) ∈ X⟧ ⟹ t0 ∈ T› 2. ‹⟦(t0::real) ∈ (T::real set); (y0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); t0 ∈ T; (z0::'a::{heine_borel,banach}) ∈ X⟧ ⟹ y0 ∈ X› 3. ‹⟦(t0::real) ∈ (T::real set); (y0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); t0 ∈ T; (z0::'a::{heine_borel,banach}) ∈ X⟧ ⟹ z0 ∈ X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . from remain[of t0] (*‹t0 ∈ {t0--t} ⟹ flow t0 y0 t0 ∈ Y› ‹t0 ∈ {t0--t} ⟹ flow t0 z0 t0 ∈ Y›*) inX (*‹y0 ∈ X› ‹z0 ∈ X›*) ‹t0 ∈ T › (*‹t0 ∈ T›*) have "y0 ∈ Y" "z0 ∈ Y" apply - (*goals: 1. ‹⟦t0 ∈ {t0--t} ⟹ flow t0 y0 t0 ∈ Y; t0 ∈ {t0--t} ⟹ flow t0 z0 t0 ∈ Y; y0 ∈ X; z0 ∈ X; t0 ∈ T⟧ ⟹ y0 ∈ Y› 2. ‹⟦t0 ∈ {t0--t} ⟹ flow t0 y0 t0 ∈ Y; t0 ∈ {t0--t} ⟹ flow t0 z0 t0 ∈ Y; y0 ∈ X; z0 ∈ X; t0 ∈ T⟧ ⟹ z0 ∈ Y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . define v where "v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)" { fix s assume s: "s ∈ {t0 -- t}" (*‹(s::real) ∈ {t0::real--t::real}›*) with s (*‹s ∈ {t0--t}›*) closed_segment_subset_existence_ivl[OF y0] (*‹{t0--t} ⊆ existence_ivl t0 y0›*) closed_segment_subset_existence_ivl[OF z0] (*‹{t0--t} ⊆ existence_ivl t0 z0›*) have y0': "s ∈ existence_ivl t0 y0" and z0': "s ∈ existence_ivl t0 z0" apply - (*goals: 1. ‹⟦s ∈ {t0--t}; {t0--t} ⊆ existence_ivl t0 y0; {t0--t} ⊆ existence_ivl t0 z0; s ∈ {t0--t}⟧ ⟹ s ∈ existence_ivl t0 y0› 2. ‹⟦s ∈ {t0--t}; {t0--t} ⊆ existence_ivl t0 y0; {t0--t} ⊆ existence_ivl t0 z0; s ∈ {t0--t}⟧ ⟹ s ∈ existence_ivl t0 z0› discuss goal 1*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*proven 2 subgoals*) . have integrable: "(λt. f t (flow t0 y0 t)) integrable_on {t0--s}" "(λt. f t (flow t0 z0 t)) integrable_on {t0--s}" using closed_segment_subset_existence_ivl[OF y0'] (*‹{t0::real--s::real} ⊆ existence_ivl t0 (y0::'a)›*) closed_segment_subset_existence_ivl[OF z0'] (*‹{t0--s} ⊆ existence_ivl t0 z0›*) ‹y0 ∈ X› (*‹y0 ∈ X›*) ‹z0 ∈ X› (*‹z0 ∈ X›*) ‹t0 ∈ T› (*‹t0 ∈ T›*) apply - (*goals: 1. ‹⟦{t0::real--s::real} ⊆ existence_ivl t0 (y0::'a); {t0--s} ⊆ existence_ivl t0 (z0::'a); y0 ∈ (X::'a set); z0 ∈ X; t0 ∈ (T::real set)⟧ ⟹ (λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow t0 y0 t)) integrable_on {t0--s}› 2. ‹⟦{t0::real--s::real} ⊆ existence_ivl t0 (y0::'a); {t0--s} ⊆ existence_ivl t0 (z0::'a); y0 ∈ (X::'a set); z0 ∈ X; t0 ∈ (T::real set)⟧ ⟹ (λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow t0 z0 t)) integrable_on {t0--s}› discuss goal 1*) apply ((auto intro!: continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*))[1]) (*proven 2 subgoals*) . hence int: "flow t0 y0 s - flow t0 z0 s = y0 - z0 + ivl_integral t0 s (λt. f t (flow t0 y0 t) - f t (flow t0 z0 t))" unfolding v_def (*goal: ‹flow t0 y0 s - flow t0 z0 s = y0 - z0 + ivl_integral t0 s (λt. f t (flow t0 y0 t) - f t (flow t0 z0 t))›*) using flow_fixed_point[OF y0'] (*‹flow t0 y0 s = y0 + ivl_integral t0 s (λt. f t (flow t0 y0 t))›*) flow_fixed_point[OF z0'] (*‹flow t0 z0 s = z0 + ivl_integral t0 s (λt. f t (flow t0 z0 t))›*) s (*‹(s::real) ∈ {t0::real--t::real}›*) by (auto simp: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) ivl_integral_diff (*‹⟦(?f::real ⇒ ?'a) integrable_on {?s::real--?t::real}; (?g::real ⇒ ?'a) integrable_on {?s--?t}⟧ ⟹ ivl_integral ?s ?t (λx::real. ?f x - ?g x) = ivl_integral ?s ?t ?f - ivl_integral ?s ?t ?g›*)) have "v s ≤ v t0 + K' * integral {t0 -- s} (λt. v t)" using closed_segment_subset_existence_ivl[OF y0'] (*‹{t0--s} ⊆ existence_ivl t0 y0›*) closed_segment_subset_existence_ivl[OF z0'] (*‹{t0--s} ⊆ existence_ivl t0 z0›*) s (*‹s ∈ {t0--t}›*) using closed_segment_closed_segment_subset[OF _ _ s, of _ t0, simplified] (*‹?s ∈ {t0--s} ⟹ ?s ∈ {t0--t}›*) apply (subst integral_mult (*‹?f integrable_on ?X ⟹ ?K * integral ?X ?f = integral ?X (λx. ?K * ?f x)›*)) (*goals: 1. ‹⟦{t0--s} ⊆ existence_ivl t0 y0; {t0--s} ⊆ existence_ivl t0 z0; s ∈ {t0--t}; ⋀sa. sa ∈ {t0--s} ⟹ sa ∈ {t0--t}⟧ ⟹ v integrable_on {t0--s}› 2. ‹⟦{t0--s} ⊆ existence_ivl t0 y0; {t0--s} ⊆ existence_ivl t0 z0; s ∈ {t0--t}; ⋀sa. sa ∈ {t0--s} ⟹ sa ∈ {t0--t}⟧ ⟹ v s ≤ v t0 + integral {t0--s} (λx. K' * v x)› discuss goal 1*) apply ((auto simp: integral_mult (*‹?f integrable_on ?X ⟹ ?K * integral ?X ?f = integral ?X (λx. ?K * ?f x)›*) v_def (*‹v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)›*) int (*‹flow t0 y0 s - flow t0 z0 s = y0 - z0 + ivl_integral t0 s (λt. f t (flow t0 y0 t) - f t (flow t0 z0 t))›*) inX (*‹y0 ∈ X› ‹z0 ∈ X›*) ‹t0 ∈ T› simp del: Henstock_Kurzweil_Integration.integral_mult_right (*‹integral ?S (λx. ?c * ?f x) = ?c * integral ?S ?f›*) intro!: norm_triangle_le (*‹norm ?x + norm ?y ≤ ?e ⟹ norm (?x + ?y) ≤ ?e›*) ivl_integral_norm_bound_integral (*‹⟦?f integrable_on {?a--?b}; ?g integrable_on {?a--?b}; ⋀x. x ∈ {?a--?b} ⟹ norm (?f x) ≤ ?g x⟧ ⟹ norm (ivl_integral ?a ?b ?f) ≤ integral {?a--?b} ?g›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) lipschitz_on_normD[OF ‹_ ⟹ K'-lipschitz_on _ _›] (*‹⟦?s1 ∈ {t0--t}; ?x ∈ Y; ?y ∈ Y⟧ ⟹ norm (f ?s1 ?x - f ?s1 ?y) ≤ K' * norm (?x - ?y)›*) remain (*‹?s ∈ {t0--t} ⟹ flow t0 y0 ?s ∈ Y› ‹?s ∈ {t0--t} ⟹ flow t0 z0 ?s ∈ Y›*))[1]) (*discuss goal 2*) apply ((auto simp: integral_mult (*‹?f integrable_on ?X ⟹ ?K * integral ?X ?f = integral ?X (λx. ?K * ?f x)›*) v_def (*‹v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)›*) int (*‹flow t0 y0 s - flow t0 z0 s = y0 - z0 + ivl_integral t0 s (λt. f t (flow t0 y0 t) - f t (flow t0 z0 t))›*) inX (*‹y0 ∈ X› ‹z0 ∈ X›*) ‹t0 ∈ T› simp del: Henstock_Kurzweil_Integration.integral_mult_right (*‹integral ?S (λx. ?c * ?f x) = ?c * integral ?S ?f›*) intro!: norm_triangle_le (*‹norm ?x + norm ?y ≤ ?e ⟹ norm (?x + ?y) ≤ ?e›*) ivl_integral_norm_bound_integral (*‹⟦?f integrable_on {?a--?b}; ?g integrable_on {?a--?b}; ⋀x. x ∈ {?a--?b} ⟹ norm (?f x) ≤ ?g x⟧ ⟹ norm (ivl_integral ?a ?b ?f) ≤ integral {?a--?b} ?g›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) lipschitz_on_normD[OF ‹_ ⟹ K'-lipschitz_on _ _›] (*‹⟦?s1 ∈ {t0--t}; ?x ∈ Y; ?y ∈ Y⟧ ⟹ norm (f ?s1 ?x - f ?s1 ?y) ≤ K' * norm (?x - ?y)›*) remain (*‹?s ∈ {t0--t} ⟹ flow t0 y0 ?s ∈ Y› ‹?s ∈ {t0--t} ⟹ flow t0 z0 ?s ∈ Y›*))[1]) (*proven 2 subgoals*) . } note le = this (*‹(?s2::real) ∈ {t0::real--t::real} ⟹ (v::real ⇒ real) ?s2 ≤ v t0 + (K'::real) * integral {t0--?s2} v›*) have cont: "continuous_on {t0 -- t} v" using closed_segment_subset_existence_ivl[OF y0] (*‹{t0::real--t::real} ⊆ existence_ivl t0 (y0::'a::{heine_borel,banach})›*) closed_segment_subset_existence_ivl[OF z0] (*‹{t0::real--t::real} ⊆ existence_ivl t0 (z0::'a)›*) inX (*‹y0 ∈ X› ‹z0 ∈ X›*) by (auto simp: v_def (*‹v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)›*) ‹t0 ∈ T› intro!: continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*)) have nonneg: "⋀t. v t ≥ 0" by (auto simp: v_def (*‹v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)›*)) from ne (*‹y0 ≠ z0›*) have pos: "v t0 > 0" by (auto simp: v_def (*‹v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)›*) ‹t0 ∈ T› inX (*‹y0 ∈ X› ‹z0 ∈ X›*)) have lippos: "K' > 0" proof (-) (*goal: ‹0 < K'›*) have "0 ≤ dist (f t0 y0) (f t0 z0)" by simp also (*calculation: ‹0 ≤ dist (f t0 y0) (f t0 z0)›*) from lipschitz_onD[OF lipschitz ‹y0 ∈ Y› ‹z0 ∈ Y›, of t0] (*‹t0 ∈ {t0--t} ⟹ dist (f t0 y0) (f t0 z0) ≤ K * dist y0 z0›*) ne (*‹y0 ≠ z0›*) have "… ≤ K * dist y0 z0" by simp finally (*calculation: ‹0 ≤ K * dist y0 z0›*) have "0 ≤ K" by (metis dist_le_zero_iff (*‹(dist ?x ?y ≤ 0) = (?x = ?y)›*) ne (*‹y0 ≠ z0›*) zero_le_mult_iff (*‹(0 ≤ ?a * ?b) = (0 ≤ ?a ∧ 0 ≤ ?b ∨ ?a ≤ 0 ∧ ?b ≤ 0)›*)) thus "?thesis" (*goal: ‹0 < K'›*) by (simp add: K'_def (*‹K' ≡ K + 1›*)) qed from le (*‹?s2 ∈ {t0--t} ⟹ v ?s2 ≤ v t0 + K' * integral {t0--?s2} v›*) cont (*‹continuous_on {t0::real--t::real} (v::real ⇒ real)›*) nonneg (*‹0 ≤ v ?t›*) pos (*‹0 < v t0›*) ‹0 < K'› (*‹0 < K'›*) have "v t ≤ v t0 * exp (K' * abs (t - t0))" apply (rule gronwall_general_segment (*‹⟦⋀t. t ∈ {?a--?b} ⟹ ?g t ≤ ?C + ?K * integral {?a--t} ?g; continuous_on {?a--?b} ?g; ⋀t. t ∈ {?a--?b} ⟹ 0 ≤ ?g t; 0 < ?C; 0 < ?K; ?t ∈ {?a--?b}⟧ ⟹ ?g ?t ≤ ?C * exp (?K * ¦?t - ?a¦)›*)) (*goals: 1. ‹⋀ta::real. ta ∈ {t0::real--t::real} ⟹ ta ∈ {t0--t}› 2. ‹(t::real) ∈ {t0::real--t}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹norm (flow t0 y0 t - flow t0 z0 t) ≤ norm (y0 - z0) * exp ((K + 1) * ¦t - t0¦)›*) by (simp add: v_def (*‹v ≡ λt. norm (flow t0 y0 t - flow t0 z0 t)›*) K'_def (*‹K' ≡ K + 1›*) ‹t0 ∈ T› inX (*‹y0 ∈ X› ‹z0 ∈ X›*)) qed lemma existence_ivl_cballs: assumes iv_defined: "t0 ∈ T" "x0 ∈ X" obtains t u L where "⋀y. y ∈ cball x0 u ⟹ cball t0 t ⊆ existence_ivl t0 y" "⋀s y. y ∈ cball x0 u ⟹ s ∈ cball t0 t ⟹ flow t0 y s ∈ cball y u" "L-lipschitz_on (cball t0 t×cball x0 u) (λ(t, x). flow t0 x t)" "⋀y. y ∈ cball x0 u ⟹ cball y u ⊆ X" "0 < t" "0 < u" proof (-) (*goal: ‹(⋀u t L. ⟦⋀y. y ∈ cball x0 u ⟹ cball t0 t ⊆ existence_ivl t0 y; ⋀s y. ⟦y ∈ cball x0 u; s ∈ cball t0 t⟧ ⟹ flow t0 y s ∈ cball y u; L-lipschitz_on (cball t0 t × cball x0 u) (λ(t, x). flow t0 x t); ⋀y. y ∈ cball x0 u ⟹ cball y u ⊆ X; 0 < t; 0 < u⟧ ⟹ thesis) ⟹ thesis›*) note iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) from local_unique_solutions[OF this] (*‹(⋀t u L. ⟦0 < t; 0 < u; cball t0 t ⊆ existence_ivl t0 x0; cball x0 (2 * u) ⊆ X; ⋀t'. t' ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 (2 * u)) (f t'); ⋀x. x ∈ cball x0 u ⟹ (flow t0 x usolves_ode f from t0) (cball t0 t) (cball x u); ⋀x. x ∈ cball x0 u ⟹ cball x u ⊆ X⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain t and u and L where tu: "0 < t" "0 < u" and subsT: "cball t0 t ⊆ existence_ivl t0 x0" and subs': "cball x0 (2 * u) ⊆ X" and lipschitz: "⋀s. s ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 (2*u)) (f s)" and usol: "⋀y. y ∈ cball x0 u ⟹ (flow t0 y usolves_ode f from t0) (cball t0 t) (cball y u)" and subs: "⋀y. y ∈ cball x0 u ⟹ cball y u ⊆ X" (*goal: ‹(⋀t u L. ⟦0 < t; 0 < u; cball t0 t ⊆ existence_ivl t0 x0; cball x0 (2 * u) ⊆ X; ⋀s. s ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 (2 * u)) (f s); ⋀y. y ∈ cball x0 u ⟹ (flow t0 y usolves_ode f from t0) (cball t0 t) (cball y u); ⋀y. y ∈ cball x0 u ⟹ cball y u ⊆ X⟧ ⟹ thesis) ⟹ thesis›*) by metis { fix y assume y: "y ∈ cball x0 u" (*‹(y::'a) ∈ cball (x0::'a) (u::real)›*) from subs[OF y] (*‹cball y u ⊆ X›*) ‹0 < u› (*‹(0::real) < (u::real)›*) have "y ∈ X" by auto note iv' = ‹t0 ∈ T› (*‹t0 ∈ T›*) ‹y ∈ X› (*‹y ∈ X›*) from usol[OF y, THEN usolves_odeD ( 1 )] (*‹(flow (t0::real) (y::'a) solves_ode (f::real ⇒ 'a ⇒ 'a)) (cball t0 (t::real)) (cball y (u::real))›*) have sol1: "(flow t0 y solves_ode f) (cball t0 t) (cball y u)" . from sol1 (*‹(flow t0 y solves_ode f) (cball t0 t) (cball y u)›*) order_refl (*‹?x ≤ ?x›*) subs[OF y] (*‹cball y u ⊆ X›*) have sol: "(flow t0 y solves_ode f) (cball t0 t) X" by (rule solves_ode_on_subset (*‹⟦(?x solves_ode ?f) ?S ?Y; ?T ⊆ ?S; ?Y ⊆ ?X⟧ ⟹ (?x solves_ode ?f) ?T ?X›*)) note "*" = maximal_existence_flow[OF sol flow_initial_time is_interval_cball_1 _ order_trans [ OF subsT existence_ivl_subset ], unfolded centre_in_cball, OF iv' less_imp_le [ OF ‹0 < t› ]] (*‹cball t0 t ⊆ existence_ivl t0 y› ‹?t ∈ cball t0 t ⟹ flow t0 y ?t = flow t0 y ?t›*) have eivl: "cball t0 t ⊆ existence_ivl t0 y" by (rule * (*‹cball t0 t ⊆ existence_ivl t0 y› ‹?t ∈ cball t0 t ⟹ flow t0 y ?t = flow t0 y ?t›*)) have "flow t0 y s ∈ cball y u" if "s ∈ cball t0 t" for s by (rule solves_odeD(2)[OF sol1 that] (*‹flow t0 y s ∈ cball y u›*)) note eivl (*‹cball t0 t ⊆ existence_ivl t0 y›*) this (*‹?s ∈ cball t0 t ⟹ flow t0 y ?s ∈ cball y u›*) } note "*" = this (*‹(?y3::'a) ∈ cball (x0::'a) (u::real) ⟹ cball (t0::real) (t::real) ⊆ existence_ivl t0 ?y3› ‹⟦?y3 ∈ cball x0 u; ?s ∈ cball t0 t⟧ ⟹ flow t0 ?y3 ?s ∈ cball ?y3 u›*) note "*" (*‹(?y3::'a) ∈ cball (x0::'a) (u::real) ⟹ cball (t0::real) (t::real) ⊆ existence_ivl t0 ?y3› ‹⟦?y3 ∈ cball x0 u; ?s ∈ cball t0 t⟧ ⟹ flow t0 ?y3 ?s ∈ cball ?y3 u›*) moreover have cont_on_f_flow: "⋀x1 S. S ⊆ cball t0 t ⟹ x1 ∈ cball x0 u ⟹ continuous_on S (λt. f t (flow t0 x1 t))" using subs[of x0] (*‹(x0::'a::{heine_borel,banach}) ∈ cball x0 (u::real) ⟹ cball x0 u ⊆ (X::'a::{heine_borel,banach} set)›*) ‹u > 0› (*‹0 < u›*) "*"(1) (*‹?y3 ∈ cball x0 u ⟹ cball t0 t ⊆ existence_ivl t0 ?y3›*) iv_defined (*‹t0 ∈ T› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*) by (auto intro!: continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*)) have "bounded ((λ(t, x). f t x) ` (cball t0 t × cball x0 (2 * u)))" using subs' (*‹cball x0 (2 * u) ⊆ X›*) subsT (*‹cball t0 t ⊆ existence_ivl t0 x0›*) existence_ivl_subset[of x0] (*‹existence_ivl (t0::real) (x0::'a) ⊆ (T::real set)›*) by (auto intro!: compact_imp_bounded (*‹compact ?U ⟹ bounded ?U›*) compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) compact_Times (*‹⟦compact ?S; compact ?T⟧ ⟹ compact (?S × ?T)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) then obtain B where B: "⋀s y. s ∈ cball t0 t ⟹ y ∈ cball x0 (2 * u) ⟹ norm (f s y) ≤ B" "B > 0" (*goal: ‹(⋀B. ⟦⋀s y. ⟦s ∈ cball t0 t; y ∈ cball x0 (2 * u)⟧ ⟹ norm (f s y) ≤ B; 0 < B⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: bounded_pos (*‹bounded ?S = (∃b>0. ∀x∈?S. norm x ≤ b)›*) cball_def (*‹cball ?x ?e = {y. dist ?x y ≤ ?e}›*)) have flow_in_cball: "flow t0 x1 s ∈ cball x0 (2 * u)" if s: "s ∈ cball t0 t" and x1: "x1 ∈ cball x0 u" for s :: real and x1 proof (-) (*goal: ‹flow (t0::real) (x1::'a) (s::real) ∈ cball (x0::'a) ((2::real) * (u::real))›*) from "*"(2)[OF x1 s] (*‹flow t0 x1 s ∈ cball x1 u›*) have "flow t0 x1 s ∈ cball x1 u" . also (*calculation: ‹flow t0 x1 s ∈ cball x1 u›*) have "… ⊆ cball x0 (2 * u)" using x1 (*‹x1 ∈ cball x0 u›*) by (auto intro!: dist_triangle_le[OF add_mono, of _ x1 u _ u, simplified] (*‹⟦dist ?x x1 ≤ u; dist ?y x1 ≤ u⟧ ⟹ dist ?x ?y ≤ 2 * u›*) simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) finally (*calculation: ‹flow t0 x1 s ∈ cball x0 (2 * u)›*) show "?thesis" (*goal: ‹flow t0 x1 s ∈ cball x0 (2 * u)›*) . qed have "(B + exp ((L + 1) * ¦t¦))-lipschitz_on (cball t0 t×cball x0 u) (λ(t, x). flow t0 x t)" proof (rule lipschitz_onI (*‹⟦⋀(x::?'a) y::?'a. ⟦x ∈ (?X::?'a set); y ∈ ?X⟧ ⟹ dist ((?f::?'a ⇒ ?'b) x) (?f y) ≤ (?L::real) * dist x y; (0::real) ≤ ?L⟧ ⟹ ?L-lipschitz_on ?X ?f›*), safe) (*goals: 1. ‹⋀a b aa ba. ⟦a ∈ cball t0 t; b ∈ cball x0 u; aa ∈ cball t0 t; ba ∈ cball x0 u⟧ ⟹ dist (flow t0 b a) (flow t0 ba aa) ≤ (B + exp ((L + 1) * ¦t¦)) * dist (a, b) (aa, ba)› 2. ‹0 ≤ B + exp ((L + 1) * ¦t¦)›*) fix t1 :: real and t2 :: real and x1 and x2 assume t1: "t1 ∈ cball t0 t" and t2: "t2 ∈ cball t0 t" and x1: "x1 ∈ cball x0 u" and x2: "x2 ∈ cball x0 u" (*‹(t1::real) ∈ cball (t0::real) (t::real)› ‹(t2::real) ∈ cball (t0::real) (t::real)› ‹(x1::'a) ∈ cball (x0::'a) (u::real)› ‹(x2::'a) ∈ cball (x0::'a) (u::real)›*) have t1_ex: "t1 ∈ existence_ivl t0 x1" and t2_ex: "t2 ∈ existence_ivl t0 x1" "t2 ∈ existence_ivl t0 x2" and "x1 ∈ cball x0 (2*u)" "x2 ∈ cball x0 (2*u)" using "*"(1)[OF x1] (*‹cball t0 t ⊆ existence_ivl t0 x1›*) "*"(1)[OF x2] (*‹cball t0 t ⊆ existence_ivl t0 x2›*) t1 (*‹t1 ∈ cball t0 t›*) t2 (*‹(t2::real) ∈ cball (t0::real) (t::real)›*) x1 (*‹x1 ∈ cball x0 u›*) x2 (*‹x2 ∈ cball x0 u›*) tu (*‹(0::real) < (t::real)› ‹0 < u›*) apply - (*goals: 1. ‹⟦cball t0 t ⊆ existence_ivl t0 x1; cball t0 t ⊆ existence_ivl t0 x2; t1 ∈ cball t0 t; t2 ∈ cball t0 t; x1 ∈ cball x0 u; x2 ∈ cball x0 u; 0 < t; 0 < u⟧ ⟹ t1 ∈ existence_ivl t0 x1› 2. ‹⟦cball t0 t ⊆ existence_ivl t0 x1; cball t0 t ⊆ existence_ivl t0 x2; t1 ∈ cball t0 t; t2 ∈ cball t0 t; x1 ∈ cball x0 u; x2 ∈ cball x0 u; 0 < t; 0 < u⟧ ⟹ t2 ∈ existence_ivl t0 x1› 3. ‹⟦cball t0 t ⊆ existence_ivl t0 x1; cball t0 t ⊆ existence_ivl t0 x2; t1 ∈ cball t0 t; t2 ∈ cball t0 t; x1 ∈ cball x0 u; x2 ∈ cball x0 u; 0 < t; 0 < u⟧ ⟹ t2 ∈ existence_ivl t0 x2› 4. ‹⟦cball t0 t ⊆ existence_ivl t0 x1; cball t0 t ⊆ existence_ivl t0 x2; t1 ∈ cball t0 t; t2 ∈ cball t0 t; x1 ∈ cball x0 u; x2 ∈ cball x0 u; 0 < t; 0 < u⟧ ⟹ x1 ∈ cball x0 (2 * u)› 5. ‹⟦cball t0 t ⊆ existence_ivl t0 x1; cball t0 t ⊆ existence_ivl t0 x2; t1 ∈ cball t0 t; t2 ∈ cball t0 t; x1 ∈ cball x0 u; x2 ∈ cball x0 u; 0 < t; 0 < u⟧ ⟹ x2 ∈ cball x0 (2 * u)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . have "dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + dist (flow t0 x1 t2) (flow t0 x2 t2)" by (rule dist_triangle (*‹dist ?x ?z ≤ dist ?x ?y + dist ?y ?z›*)) also (*calculation: ‹dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + dist (flow t0 x1 t2) (flow t0 x2 t2)›*) have "dist (flow t0 x1 t2) (flow t0 x2 t2) ≤ dist x1 x2 * exp ((L + 1) * ¦t2 - t0¦)" unfolding dist_norm (*goal: ‹norm (flow t0 x1 t2 - flow t0 x2 t2) ≤ norm (x1 - x2) * exp ((L + 1) * ¦t2 - t0¦)›*) proof (rule exponential_initial_condition[where Y = "cball x0 (2 * u)"] (*‹⟦?t ∈ existence_ivl t0 ?y0.0; ?t ∈ existence_ivl t0 ?z0.0; cball x0 (2 * u) ⊆ X; ⋀s. s ∈ {t0--?t} ⟹ flow t0 ?y0.0 s ∈ cball x0 (2 * u); ⋀s. s ∈ {t0--?t} ⟹ flow t0 ?z0.0 s ∈ cball x0 (2 * u); ⋀s. s ∈ {t0--?t} ⟹ ?K-lipschitz_on (cball x0 (2 * u)) (f s)⟧ ⟹ norm (flow t0 ?y0.0 ?t - flow t0 ?z0.0 ?t) ≤ norm (?y0.0 - ?z0.0) * exp ((?K + 1) * ¦?t - t0¦)›*)) (*goals: 1. ‹(t2::real) ∈ existence_ivl (t0::real) (x1::'a)› 2. ‹(t2::real) ∈ existence_ivl (t0::real) (x2::'a)› 3. ‹cball (x0::'a) ((2::real) * (u::real)) ⊆ (X::'a set)› 4. ‹⋀s::real. s ∈ {t0::real--t2::real} ⟹ flow t0 (x1::'a) s ∈ cball (x0::'a) ((2::real) * (u::real))› 5. ‹⋀s::real. s ∈ {t0::real--t2::real} ⟹ flow t0 (x2::'a) s ∈ cball (x0::'a) ((2::real) * (u::real))› 6. ‹⋀s::real. s ∈ {t0::real--t2::real} ⟹ (L::real)-lipschitz_on (cball (x0::'a) ((2::real) * (u::real))) ((f::real ⇒ 'a ⇒ 'a) s)›*) fix s assume "s ∈ closed_segment t0 t2" (*‹(s::real) ∈ {t0::real--t2::real}›*) hence s: "s ∈ cball t0 t" using t2 (*‹t2 ∈ cball t0 t›*) by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) show "flow t0 x1 s ∈ cball x0 (2 * u)" by (rule flow_in_cball[OF s x1] (*‹flow t0 x1 s ∈ cball x0 (2 * u)›*)) show "flow t0 x2 s ∈ cball x0 (2 * u)" by (rule flow_in_cball[OF s x2] (*‹flow t0 x2 s ∈ cball x0 (2 * u)›*)) show "L-lipschitz_on (cball x0 (2 * u)) (f s)" if "s ∈ closed_segment t0 t2" for s using that (*‹s ∈ {t0--t2}›*) centre_in_cball (*‹(?x ∈ cball ?x ?e) = (0 ≤ ?e)›*) convex_contains_segment (*‹convex (?S::?'a set) = (∀a::?'a∈?S. ∀b::?'a∈?S. {a--b} ⊆ ?S)›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) t2 (*‹t2 ∈ cball t0 t›*) tu(1) (*‹0 < t›*) by (blast intro!: lipschitz (*‹?s ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 (2 * u)) (f ?s)›*)) qed ((fact)+) (*solves the remaining goals: 1. ‹t2 ∈ existence_ivl t0 x1› 2. ‹t2 ∈ existence_ivl t0 x2› 3. ‹cball x0 (2 * u) ⊆ X›*) also (*calculation: ‹(⋀x y. x ≤ y ⟹ dist (flow t0 x1 t1) (flow t0 x1 t2) + x ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + y) ⟹ dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + dist x1 x2 * exp ((L + 1) * ¦t2 - t0¦)›*) have "… ≤ dist x1 x2 * exp ((L + 1) * ¦t¦)" using ‹u > 0› (*‹(0::real) < (u::real)›*) t2 (*‹t2 ∈ cball t0 t›*) by (auto intro!: mult_left_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) add_nonneg_nonneg (*‹⟦(0::?'a) ≤ (?a::?'a); (0::?'a) ≤ (?b::?'a)⟧ ⟹ (0::?'a) ≤ ?a + ?b›*) lipschitz[THEN lipschitz_on_nonneg] (*‹(?s1::real) ∈ cball (t0::real) (t::real) ⟹ (0::real) ≤ (L::real)›*) simp: cball_eq_empty (*‹(cball (?x::?'a) (?e::real) = {}) = (?e < (0::real))›*) cball_eq_sing' (*‹(cball (?x::?'a) (?e::real) = {?y::?'a}) = (?e = (0::real) ∧ ?x = ?y)›*) dist_real_def (*‹dist (?x::real) (?y::real) = ¦?x - ?y¦›*)) also (*calculation: ‹⟦⋀x y. x ≤ y ⟹ dist (flow t0 x1 t1) (flow t0 x1 t2) + x ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + y; ⋀x y. x ≤ y ⟹ dist (flow t0 x1 t1) (flow t0 x1 t2) + x ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + y⟧ ⟹ dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + dist x1 x2 * exp ((L + 1) * ¦t¦)›*) have "x1 ∈ X" using x1 (*‹(x1::'a) ∈ cball (x0::'a) (u::real)›*) subs[of x0] (*‹x0 ∈ cball x0 u ⟹ cball x0 u ⊆ X›*) ‹u > 0› (*‹0 < u›*) by auto have "*": "¦t0 - t1¦ ≤ t ⟹ x ∈ {t0--t1} ⟹ ¦t0 - x¦ ≤ t" "¦t0 - t2¦ ≤ t ⟹ x ∈ {t0--t2} ⟹ ¦t0 - x¦ ≤ t" "¦t0 - t1¦ ≤ t ⟹ ¦t0 - t2¦ ≤ t ⟹ x ∈ {t1--t2} ⟹ ¦t0 - x¦ ≤ t" for x using t1 (*‹t1 ∈ cball t0 t›*) t2 (*‹t2 ∈ cball t0 t›*) t1_ex (*‹(t1::real) ∈ existence_ivl (t0::real) (x1::'a)›*) x1 (*‹x1 ∈ cball x0 u›*) flow_in_cball[OF _ x1] (*‹?s ∈ cball t0 t ⟹ flow t0 x1 ?s ∈ cball x0 (2 * u)›*) (*goals: 1. ‹⟦¦t0 - t1¦ ≤ t; x ∈ {t0--t1}⟧ ⟹ ¦t0 - x¦ ≤ t› 2. ‹⟦¦t0 - t2¦ ≤ t; x ∈ {t0--t2}⟧ ⟹ ¦t0 - x¦ ≤ t› 3. ‹⟦¦t0 - t1¦ ≤ t; ¦t0 - t2¦ ≤ t; x ∈ {t1--t2}⟧ ⟹ ¦t0 - x¦ ≤ t› discuss goal 1*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 3*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 3 subgoals*) . have integrable: "(λt. f t (flow t0 x1 t)) integrable_on {t0--t1}" "(λt. f t (flow t0 x1 t)) integrable_on {t0--t2}" "(λt. f t (flow t0 x1 t)) integrable_on {t1--t2}" using t1 (*‹(t1::real) ∈ cball (t0::real) (t::real)›*) t2 (*‹t2 ∈ cball t0 t›*) t1_ex (*‹t1 ∈ existence_ivl t0 x1›*) x1 (*‹x1 ∈ cball x0 u›*) flow_in_cball[OF _ x1] (*‹?s ∈ cball t0 t ⟹ flow t0 x1 ?s ∈ cball x0 (2 * u)›*) apply - (*goals: 1. ‹⟦(t1::real) ∈ cball (t0::real) (t::real); (t2::real) ∈ cball t0 t; t1 ∈ existence_ivl t0 (x1::'a::{heine_borel,banach}); x1 ∈ cball (x0::'a::{heine_borel,banach}) (u::real); ⋀s::real. s ∈ cball t0 t ⟹ flow t0 x1 s ∈ cball x0 ((2::real) * u)⟧ ⟹ (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (flow t0 x1 t)) integrable_on {t0--t1}› 2. ‹⟦(t1::real) ∈ cball (t0::real) (t::real); (t2::real) ∈ cball t0 t; t1 ∈ existence_ivl t0 (x1::'a::{heine_borel,banach}); x1 ∈ cball (x0::'a::{heine_borel,banach}) (u::real); ⋀s::real. s ∈ cball t0 t ⟹ flow t0 x1 s ∈ cball x0 ((2::real) * u)⟧ ⟹ (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (flow t0 x1 t)) integrable_on {t0--t2}› 3. ‹⟦(t1::real) ∈ cball (t0::real) (t::real); (t2::real) ∈ cball t0 t; t1 ∈ existence_ivl t0 (x1::'a::{heine_borel,banach}); x1 ∈ cball (x0::'a::{heine_borel,banach}) (u::real); ⋀s::real. s ∈ cball t0 t ⟹ flow t0 x1 s ∈ cball x0 ((2::real) * u)⟧ ⟹ (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (flow t0 x1 t)) integrable_on {t1--t2}› discuss goal 1*) apply ((auto intro!: order_trans[OF integral_bound[where B=B]] (*‹⟦?a1 ≤ ?b1; continuous_on {?a1..?b1} ?f1; ⋀t. t ∈ {?a1..?b1} ⟹ norm (?f1 t) ≤ B; B * (?b1 - ?a1) ≤ ?z⟧ ⟹ norm (integral {?a1..?b1} ?f1) ≤ ?z›*) cont_on_f_flow (*‹⟦?S ⊆ cball t0 t; ?x1.0 ∈ cball x0 u⟧ ⟹ continuous_on ?S (λt. f t (flow t0 ?x1.0 t))›*) B (*‹⟦?s ∈ cball t0 t; ?y ∈ cball x0 (2 * u)⟧ ⟹ norm (f ?s ?y) ≤ B› ‹0 < B›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*) intro: * (*‹⟦¦t0 - t1¦ ≤ t; ?x ∈ {t0--t1}⟧ ⟹ ¦t0 - ?x¦ ≤ t› ‹⟦¦t0 - t2¦ ≤ t; ?x ∈ {t0--t2}⟧ ⟹ ¦t0 - ?x¦ ≤ t› ‹⟦¦t0 - t1¦ ≤ t; ¦t0 - t2¦ ≤ t; ?x ∈ {t1--t2}⟧ ⟹ ¦t0 - ?x¦ ≤ t›*) simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*) integral_minus_sets' (*‹⟦?a ≤ ?c; ?b ≤ ?c; ?f integrable_on {min ?a ?b..?c}⟧ ⟹ integral {?a..?c} ?f - integral {?b..?c} ?f = (if ?a ≤ ?b then integral {?a..?b} ?f else - integral {?b..?a} ?f)›*))[1]) (*discuss goal 2*) apply ((auto intro!: order_trans[OF integral_bound[where B=B]] (*‹⟦(?a1::real) ≤ (?b1::real); continuous_on {?a1..?b1} (?f1::real ⇒ ?'a1); ⋀t::real. t ∈ {?a1..?b1} ⟹ norm (?f1 t) ≤ (B::real); B * (?b1 - ?a1) ≤ (?z::real)⟧ ⟹ norm (integral {?a1..?b1} ?f1) ≤ ?z›*) cont_on_f_flow (*‹⟦(?S::real set) ⊆ cball (t0::real) (t::real); (?x1.0::'a) ∈ cball (x0::'a) (u::real)⟧ ⟹ continuous_on ?S (λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow t0 ?x1.0 t))›*) B (*‹⟦(?s::real) ∈ cball (t0::real) (t::real); (?y::'a) ∈ cball (x0::'a) ((2::real) * (u::real))⟧ ⟹ norm ((f::real ⇒ 'a ⇒ 'a) ?s ?y) ≤ (B::real)› ‹(0::real) < (B::real)›*) integrable_continuous_closed_segment (*‹continuous_on {?a::real--?b::real} (?f::real ⇒ ?'a) ⟹ ?f integrable_on {?a--?b}›*) intro: * (*‹⟦¦(t0::real) - (t1::real)¦ ≤ (t::real); (?x::real) ∈ {t0--t1}⟧ ⟹ ¦t0 - ?x¦ ≤ t› ‹⟦¦(t0::real) - (t2::real)¦ ≤ (t::real); (?x::real) ∈ {t0--t2}⟧ ⟹ ¦t0 - ?x¦ ≤ t› ‹⟦¦(t0::real) - (t1::real)¦ ≤ (t::real); ¦t0 - (t2::real)¦ ≤ t; (?x::real) ∈ {t1--t2}⟧ ⟹ ¦t0 - ?x¦ ≤ t›*) simp: dist_real_def (*‹dist (?x::real) (?y::real) = ¦?x - ?y¦›*) integral_minus_sets' (*‹⟦(?a::real) ≤ (?c::real); (?b::real) ≤ ?c; (?f::real ⇒ ?'a) integrable_on {min ?a ?b..?c}⟧ ⟹ integral {?a..?c} ?f - integral {?b..?c} ?f = (if ?a ≤ ?b then integral {?a..?b} ?f else - integral {?b..?a} ?f)›*))[1]) (*discuss goal 3*) apply ((auto intro!: order_trans[OF integral_bound[where B=B]] (*‹⟦?a1 ≤ ?b1; continuous_on {?a1..?b1} ?f1; ⋀t. t ∈ {?a1..?b1} ⟹ norm (?f1 t) ≤ B; B * (?b1 - ?a1) ≤ ?z⟧ ⟹ norm (integral {?a1..?b1} ?f1) ≤ ?z›*) cont_on_f_flow (*‹⟦?S ⊆ cball t0 t; ?x1.0 ∈ cball x0 u⟧ ⟹ continuous_on ?S (λt. f t (flow t0 ?x1.0 t))›*) B (*‹⟦?s ∈ cball t0 t; ?y ∈ cball x0 (2 * u)⟧ ⟹ norm (f ?s ?y) ≤ B› ‹0 < B›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*) intro: * (*‹⟦¦t0 - t1¦ ≤ t; ?x ∈ {t0--t1}⟧ ⟹ ¦t0 - ?x¦ ≤ t› ‹⟦¦t0 - t2¦ ≤ t; ?x ∈ {t0--t2}⟧ ⟹ ¦t0 - ?x¦ ≤ t› ‹⟦¦t0 - t1¦ ≤ t; ¦t0 - t2¦ ≤ t; ?x ∈ {t1--t2}⟧ ⟹ ¦t0 - ?x¦ ≤ t›*) simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*) integral_minus_sets' (*‹⟦?a ≤ ?c; ?b ≤ ?c; ?f integrable_on {min ?a ?b..?c}⟧ ⟹ integral {?a..?c} ?f - integral {?b..?c} ?f = (if ?a ≤ ?b then integral {?a..?b} ?f else - integral {?b..?a} ?f)›*))[1]) (*proven 3 subgoals*) . have "*": "¦t0 - t1¦ ≤ t ⟹ ¦t0 - t2¦ ≤ t ⟹ s ∈ {t1--t2} ⟹ ¦t0 - s¦ ≤ t" for s by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) note [simp] = t1_ex (*‹t1 ∈ existence_ivl t0 x1›*) t2_ex (*‹t2 ∈ existence_ivl t0 x1› ‹t2 ∈ existence_ivl t0 x2›*) ‹x1 ∈ X› (*‹(x1::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*) integrable (*‹(λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow (t0::real) (x1::'a) t)) integrable_on {t0--t1::real}› ‹(λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow (t0::real) (x1::'a) t)) integrable_on {t0--t2::real}› ‹(λt. f t (flow t0 x1 t)) integrable_on {t1--t2}›*) have "dist (flow t0 x1 t1) (flow t0 x1 t2) ≤ dist t1 t2 * B" using t1 (*‹t1 ∈ cball t0 t›*) t2 (*‹t2 ∈ cball t0 t›*) x1 (*‹(x1::'a) ∈ cball (x0::'a) (u::real)›*) flow_in_cball[OF _ x1] (*‹?s ∈ cball t0 t ⟹ flow t0 x1 ?s ∈ cball x0 (2 * u)›*) ‹t0 ∈ T› (*‹t0 ∈ T›*) ivl_integral_combine[of "λt. f t (flow t0 x1 t)" t2 t0 t1] (*‹⟦(λt. f t (flow t0 x1 t)) integrable_on {t2--t0}; (λt. f t (flow t0 x1 t)) integrable_on {t0--t1}; (λt. f t (flow t0 x1 t)) integrable_on {t2--t1}⟧ ⟹ ivl_integral t2 t0 (λt. f t (flow t0 x1 t)) + ivl_integral t0 t1 (λt. f t (flow t0 x1 t)) = ivl_integral t2 t1 (λt. f t (flow t0 x1 t))›*) ivl_integral_combine[of "λt. f t (flow t0 x1 t)" t1 t0 t2] (*‹⟦(λt. f t (flow t0 x1 t)) integrable_on {t1--t0}; (λt. f t (flow t0 x1 t)) integrable_on {t0--t2}; (λt. f t (flow t0 x1 t)) integrable_on {t1--t2}⟧ ⟹ ivl_integral t1 t0 (λt. f t (flow t0 x1 t)) + ivl_integral t0 t2 (λt. f t (flow t0 x1 t)) = ivl_integral t1 t2 (λt. f t (flow t0 x1 t))›*) by (auto simp: flow_fixed_point (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t = ?x0.0 + ivl_integral t0 ?t (λt. f t (flow t0 ?x0.0 t))›*) dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*) add.commute (*‹?a + ?b = ?b + ?a›*) closed_segment_commute (*‹{?a--?b} = {?b--?a}›*) norm_minus_commute (*‹norm (?a - ?b) = norm (?b - ?a)›*) ivl_integral_minus_sets' (*‹⟦?f integrable_on {?a--?c}; ?f integrable_on {?b--?c}; ?f integrable_on {?a--?b}⟧ ⟹ ivl_integral ?a ?c ?f - ivl_integral ?b ?c ?f = ivl_integral ?a ?b ?f›*) ivl_integral_minus_sets (*‹⟦?f integrable_on {?c--?a}; ?f integrable_on {?c--?b}; ?f integrable_on {?a--?b}⟧ ⟹ ivl_integral ?c ?a ?f - ivl_integral ?c ?b ?f = ivl_integral ?b ?a ?f›*) intro!: order_trans[OF ivl_integral_bound[where B=B]] (*‹⟦continuous_on {?a1--?b1} ?f1; ⋀t. t ∈ {?a1--?b1} ⟹ norm (?f1 t) ≤ B; B * ¦?b1 - ?a1¦ ≤ ?z⟧ ⟹ norm (ivl_integral ?a1 ?b1 ?f1) ≤ ?z›*) cont_on_f_flow (*‹⟦?S ⊆ cball t0 t; ?x1.0 ∈ cball x0 u⟧ ⟹ continuous_on ?S (λt. f t (flow t0 ?x1.0 t))›*) B (*‹⟦?s ∈ cball t0 t; ?y ∈ cball x0 (2 * u)⟧ ⟹ norm (f ?s ?y) ≤ B› ‹0 < B›*) dest: * (*‹⟦¦t0 - t1¦ ≤ t; ¦t0 - t2¦ ≤ t; ?s ∈ {t1--t2}⟧ ⟹ ¦t0 - ?s¦ ≤ t›*)) finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ dist (flow t0 x1 t1) (flow t0 x1 t2) + x ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + y; ⋀x y. x ≤ y ⟹ dist (flow t0 x1 t1) (flow t0 x1 t2) + x ≤ dist (flow t0 x1 t1) (flow t0 x1 t2) + y; ⋀x y. x ≤ y ⟹ x + dist x1 x2 * exp ((L + 1) * ¦t¦) ≤ y + dist x1 x2 * exp ((L + 1) * ¦t¦)⟧ ⟹ dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist t1 t2 * B + dist x1 x2 * exp ((L + 1) * ¦t¦)›*) have "dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist t1 t2 * B + dist x1 x2 * exp ((L + 1) * ¦t¦)" by arith also (*calculation: ‹dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist t1 t2 * B + dist x1 x2 * exp ((L + 1) * ¦t¦)›*) have "… ≤ dist (t1, x1) (t2, x2) * B + dist (t1, x1) (t2, x2) * exp ((L + 1) * ¦t¦)" using ‹B > 0› (*‹0 < B›*) by (auto intro!: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) simp: dist_prod_def (*‹dist ?x ?y = sqrt ((dist (fst ?x) (fst ?y))² + (dist (snd ?x) (snd ?y))²)›*)) finally (*calculation: ‹dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ dist (t1, x1) (t2, x2) * B + dist (t1, x1) (t2, x2) * exp ((L + 1) * ¦t¦)›*) show "dist (flow t0 x1 t1) (flow t0 x2 t2) ≤ (B + exp ((L + 1) * ¦t¦)) * dist (t1, x1) (t2, x2)" by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed (simp add: ‹0 < B› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*)) (*solved the remaining goal: ‹0 ≤ B + exp ((L + 1) * ¦t¦)›*) ultimately show thesis using subs (*‹?y ∈ cball x0 u ⟹ cball ?y u ⊆ X›*) tu (*‹0 < t› ‹0 < u›*) apply standard (*goals: 1. ‹⋀y. y ∈ cball x0 u ⟹ y ∈ cball x0 u› 2. ‹⋀s y. ⟦y ∈ cball x0 u; s ∈ cball t0 t⟧ ⟹ y ∈ cball x0 u› 3. ‹⋀s y. ⟦y ∈ cball x0 u; s ∈ cball t0 t⟧ ⟹ s ∈ cball t0 t› 4. ‹⋀y. y ∈ cball x0 u ⟹ y ∈ cball x0 u› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) qed context fixes x0 assumes iv_defined: "t0 ∈ T" "x0 ∈ X" begin lemma existence_ivl_notempty: "existence_ivl t0 x0 ≠ {}" using existence_ivl_initial_time (*‹⟦t0 ∈ T; ?x0.0 ∈ X⟧ ⟹ t0 ∈ existence_ivl t0 ?x0.0›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) by auto lemma initial_time_bounds: shows "bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0)" (is "?a ⟹ _") and "bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0" (is "?b ⟹ _") proof (-) (*goals: 1. ‹bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0)› 2. ‹bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0›*) from local_unique_solutions[OF iv_defined] (*‹(⋀t u L. ⟦0 < t; 0 < u; cball t0 t ⊆ existence_ivl t0 x0; cball x0 (2 * u) ⊆ X; ⋀t'. t' ∈ cball t0 t ⟹ L-lipschitz_on (cball x0 (2 * u)) (f t'); ⋀x. x ∈ cball x0 u ⟹ (flow t0 x usolves_ode f from t0) (cball t0 t) (cball x u); ⋀x. x ∈ cball x0 u ⟹ cball x u ⊆ X⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain te where te: "te > 0" "cball t0 te ⊆ existence_ivl t0 x0" (*goal: ‹(⋀te::real. ⟦(0::real) < te; cball (t0::real) te ⊆ existence_ivl t0 (x0::'a)⟧ ⟹ thesis::bool) ⟹ thesis›*) by metis then show "t0 < Sup (existence_ivl t0 x0)" if bdd: "bdd_above (existence_ivl t0 x0)" using less_cSup_iff[OF existence_ivl_notempty bdd, of t0] (*‹(t0 < Sup (existence_ivl t0 x0)) = (∃x∈existence_ivl t0 x0. t0 < x)›*) iv_defined (*‹(t0::real) ∈ (T::real set)› ‹x0 ∈ X›*) by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*) intro!: bexI[where x="t0 + te"] (*‹⟦?P (t0 + te); t0 + te ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) from te (*‹0 < te› ‹cball t0 te ⊆ existence_ivl t0 x0›*) show "Inf (existence_ivl t0 x0) < t0" if bdd: "bdd_below (existence_ivl t0 x0)" unfolding cInf_less_iff[OF existence_ivl_notempty bdd, of t0] (*goal: ‹∃x∈existence_ivl t0 x0. x < t0›*) by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) intro!: bexI[where x="t0 - te"] (*‹⟦?P (t0 - te); t0 - te ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*)) qed lemma flow_leaves_compact_ivl_right: assumes bdd: "bdd_above (existence_ivl t0 x0)" defines "b ≡ Sup (existence_ivl t0 x0)" assumes "b ∈ T" assumes "compact K" assumes "K ⊆ X" obtains t where "t ≥ t0" "t ∈ existence_ivl t0 x0" "flow t0 x0 t ∉ K" apply atomize_elim (*goal: ‹(⋀t. ⟦t0 ≤ t; t ∈ existence_ivl t0 x0; flow t0 x0 t ∉ K⟧ ⟹ thesis) ⟹ thesis›*) apply (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹∃t≥t0. t ∈ existence_ivl t0 x0 ∧ flow t0 x0 t ∉ K›*) proof (auto) (*goal: ‹∀t. t ∈ existence_ivl t0 x0 ⟶ t0 ≤ t ⟶ flow t0 x0 t ∈ K ⟹ False›*) note iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) note ne = existence_ivl_notempty (*‹existence_ivl t0 x0 ≠ {}›*) assume K[rule_format]: "∀t. t ∈ existence_ivl t0 x0 ⟶ t0 ≤ t ⟶ flow t0 x0 t ∈ K" (*‹⟦(?t::real) ∈ existence_ivl (t0::real) (x0::'a); t0 ≤ ?t⟧ ⟹ flow t0 x0 ?t ∈ (K::'a set)›*) have b_upper: "t ≤ b" if "t ∈ existence_ivl t0 x0" for t unfolding b_def (*goal: ‹(t::real) ≤ Sup (existence_ivl (t0::real) (x0::'a))›*) by (rule cSup_upper[OF that bdd] (*‹t ≤ Sup (existence_ivl t0 x0)›*)) have less_b_iff: "y < b ⟷ (∃x∈existence_ivl t0 x0. y < x)" for y unfolding b_def less_cSup_iff[OF ne bdd] (*goal: ‹Bex (existence_ivl (t0::real) (x0::'a)) ((<) (y::real)) = (∃x::real∈existence_ivl t0 x0. y < x)›*) by standard have "t0 ≤ b" by (simp add: iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) b_upper (*‹?t ∈ existence_ivl t0 x0 ⟹ ?t ≤ b›*)) then have geI: "t ∈ {t0--<b} ⟹ t0 ≤ t" for t by (auto simp: half_open_segment_real (*‹{?a--<?b} = (if ?a ≤ ?b then {?a..<?b} else {?b<..?a})›*)) have subset: "{t0 --< b} ⊆ existence_ivl t0 x0" using ‹t0 ≤ b› (*‹t0 ≤ b›*) in_existence_between_zeroI (*‹⟦?t ∈ existence_ivl t0 ?x0.0; ?s ∈ {t0--?t}⟧ ⟹ ?s ∈ existence_ivl t0 ?x0.0›*) by (auto simp: half_open_segment_real (*‹{?a::real--<?b::real} = (if ?a ≤ ?b then {?a..<?b} else {?b<..?a})›*) iv_defined (*‹(t0::real) ∈ (T::real set)› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*) less_b_iff (*‹((?y::real) < (b::real)) = (∃x::real∈existence_ivl (t0::real) (x0::'a::{heine_borel,banach}). ?y < x)›*)) have sol: "(flow t0 x0 solves_ode f) {t0 --< b} K" apply (rule solves_odeI (*‹⟦((?y::real ⇒ ?'a) has_vderiv_on (λt::real. (?f::real ⇒ ?'a ⇒ ?'a) t (?y t))) (?T::real set); ⋀t::real. t ∈ ?T ⟹ ?y t ∈ (?X::?'a set)⟧ ⟹ (?y solves_ode ?f) ?T ?X›*)) (*goal: ‹(flow t0 x0 solves_ode f) {t0--<b} K›*) apply (rule has_vderiv_on_subset[OF solves_odeD(1)[OF flow_solves_ode] subset] (*‹⟦(t0::real) ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)⟧ ⟹ (flow t0 x0 has_vderiv_on (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (flow t0 x0 t))) {t0--<b::real}›*)) (*top goal: ‹(flow t0 x0 has_vderiv_on (λt. f t (flow t0 x0 t))) {t0--<b}› and 1 goal remains*) using subset (*‹{t0::real--<b::real} ⊆ existence_ivl t0 (x0::'a)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) apply - (*goals: 1. ‹⟦{t0--<b} ⊆ existence_ivl t0 x0; t0 ∈ T; x0 ∈ X⟧ ⟹ t0 ∈ T› 2. ‹⟦{t0--<b} ⊆ existence_ivl t0 x0; t0 ∈ T; x0 ∈ X⟧ ⟹ x0 ∈ X› 3. ‹⋀t. ⟦t ∈ {t0--<b}; {t0--<b} ⊆ existence_ivl t0 x0; t0 ∈ T; x0 ∈ X⟧ ⟹ flow t0 x0 t ∈ K› discuss goal 1*) apply ((auto intro!: K (*‹⟦?t ∈ existence_ivl t0 x0; t0 ≤ ?t⟧ ⟹ flow t0 x0 ?t ∈ K›*) geI (*‹?t ∈ {t0--<b} ⟹ t0 ≤ ?t›*))[1]) (*discuss goal 2*) apply ((auto intro!: K (*‹⟦?t ∈ existence_ivl t0 x0; t0 ≤ ?t⟧ ⟹ flow t0 x0 ?t ∈ K›*) geI (*‹?t ∈ {t0--<b} ⟹ t0 ≤ ?t›*))[1]) (*discuss goal 3*) apply ((auto intro!: K (*‹⟦?t ∈ existence_ivl t0 x0; t0 ≤ ?t⟧ ⟹ flow t0 x0 ?t ∈ K›*) geI (*‹?t ∈ {t0--<b} ⟹ t0 ≤ ?t›*))[1]) (*proven 3 subgoals*) . have cont: "continuous_on ({t0--b} × K) (λ(t, x). f t x)" using ‹K ⊆ X› (*‹K ⊆ X›*) closed_segment_subset_domainI[OF iv_defined ( 1 ) ‹b ∈ T›] (*‹(?s::real) ∈ {t0::real--b::real} ⟹ ?s ∈ (T::real set)›*) by (auto simp: split_beta (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*)) from initial_time_bounds(1)[OF bdd] (*‹t0 < Sup (existence_ivl t0 x0)›*) have "t0 ≠ b" by (simp add: b_def (*‹b ≡ Sup (existence_ivl t0 x0)›*)) from solves_ode_half_open_segment_continuation[OF sol cont ‹compact K› ‹t0 ≠ b›] (*‹(⋀l. ⟦(flow t0 x0 ⤏ l) (at b within {t0--<b}); ((λt. if t = b then l else flow t0 x0 t) solves_ode f) {t0--b} K⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain l where lim: "(flow t0 x0 ⤏ l) (at b within {t0--<b})" and limsol: "((λt. if t = b then l else flow t0 x0 t) solves_ode f) {t0--b} K" (*goal: ‹(⋀l. ⟦(flow t0 x0 ⤏ l) (at b within {t0--<b}); ((λt. if t = b then l else flow t0 x0 t) solves_ode f) {t0--b} K⟧ ⟹ thesis) ⟹ thesis›*) . have "b ∈ existence_ivl t0 x0" using ‹t0 ≠ b› (*‹t0 ≠ b›*) closed_segment_subset_domainI[OF ‹t0 ∈ T› ‹b ∈ T›] (*‹?s ∈ {t0--b} ⟹ ?s ∈ T›*) apply (intro existence_ivl_maximal_segment[OF solves_ode_on_subset[OF limsol order_refl ‹K ⊆ X›]] (*‹⟦(if t0 = b then l else flow t0 x0 t0) = ?x0.0; {t0--b} ⊆ T⟧ ⟹ b ∈ existence_ivl t0 ?x0.0›*)) (*goals: 1. ‹⟦t0 ≠ b; ⋀s. s ∈ {t0--b} ⟹ s ∈ T⟧ ⟹ (if t0 = b then l else flow t0 x0 t0) = x0› 2. ‹⟦t0 ≠ b; ⋀s. s ∈ {t0--b} ⟹ s ∈ T⟧ ⟹ {t0--b} ⊆ T› discuss goal 1*) apply ((auto simp: iv_defined (*‹(t0::real) ∈ (T::real set)› ‹(x0::'a) ∈ (X::'a set)›*))[1]) (*discuss goal 2*) apply ((auto simp: iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*proven 2 subgoals*) . have "flow t0 x0 b ∈ X" by (simp add: ‹b ∈ existence_ivl t0 x0› flow_in_domain (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t ∈ X›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) from ll_on_open_it.local_unique_solutions[OF ll_on_open_it_axioms ‹b ∈ T› ‹flow t0 x0 b ∈ X›] (*‹(⋀(t::real) (u::real) L::real. ⟦(0::real) < t; (0::real) < u; cball (b::real) t ⊆ existence_ivl b (flow (t0::real) (x0::'a) b); cball (flow t0 x0 b) ((2::real) * u) ⊆ (X::'a set); ⋀t'::real. t' ∈ cball b t ⟹ L-lipschitz_on (cball (flow t0 x0 b) ((2::real) * u)) ((f::real ⇒ 'a ⇒ 'a) t'); ⋀x::'a. x ∈ cball (flow t0 x0 b) u ⟹ (flow b x usolves_ode f from b) (cball b t) (cball x u); ⋀x::'a. x ∈ cball (flow t0 x0 b) u ⟹ cball x u ⊆ X⟧ ⟹ ?thesis::bool) ⟹ ?thesis›*) obtain e where "e > 0" "cball b e ⊆ existence_ivl b (flow t0 x0 b)" (*goal: ‹(⋀e::real. ⟦(0::real) < e; cball (b::real) e ⊆ existence_ivl b (flow (t0::real) (x0::'a) b)⟧ ⟹ thesis::bool) ⟹ thesis›*) by metis then have "e + b ∈ existence_ivl b (flow t0 x0 b)" by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*)) from existence_ivl_trans[OF ‹b ∈ existence_ivl t0 x0› ‹e + b ∈ existence_ivl _ _›] (*‹b + e ∈ existence_ivl t0 x0›*) have "b + e ∈ existence_ivl t0 x0" . from b_upper[OF this] (*‹b + e ≤ b›*) ‹e > 0› (*‹0 < e›*) show False by simp qed lemma flow_leaves_compact_ivl_left: assumes bdd: "bdd_below (existence_ivl t0 x0)" defines "b ≡ Inf (existence_ivl t0 x0)" assumes "b ∈ T" assumes "compact K" assumes "K ⊆ X" obtains t where "t ≤ t0" "t ∈ existence_ivl t0 x0" "flow t0 x0 t ∉ K" proof (-) (*goal: ‹(⋀t::real. ⟦t ≤ (t0::real); t ∈ existence_ivl t0 (x0::'a); flow t0 x0 t ∉ (K::'a set)⟧ ⟹ thesis::bool) ⟹ thesis›*) interpret rev: ll_on_open "(preflect t0 ` T)" "(λt. - f (preflect t0 t))" X by standard from antimono_preflect (*‹antimono (preflect ?t0.0)›*) bdd (*‹bdd_below (existence_ivl t0 x0)›*) have bdd_rev: "bdd_above (rev.existence_ivl t0 x0)" unfolding rev_existence_ivl_eq (*goal: ‹bdd_above (preflect (t0::real) ` existence_ivl t0 (x0::'a))›*) by (rule bdd_above_image_antimono (*‹⟦antimono (?f::?'a ⇒ ?'b); bdd_below (?A::?'a set)⟧ ⟹ bdd_above (?f ` ?A)›*)) note ne = existence_ivl_notempty (*‹existence_ivl t0 x0 ≠ {}›*) have "Sup (rev.existence_ivl t0 x0) = preflect t0 b" using continuous_at_Inf_antimono[OF antimono_preflect _ ne bdd] (*‹continuous (at_right (Inf (existence_ivl (t0::real) (x0::'a)))) (preflect (?t0.2::real)) ⟹ preflect ?t0.2 (Inf (existence_ivl t0 x0)) = Sup (preflect ?t0.2 ` existence_ivl t0 x0)›*) by (simp add: continuous_preflect (*‹continuous (at ?a within ?A) (preflect ?t0.0)›*) b_def (*‹b ≡ Inf (existence_ivl t0 x0)›*) rev_existence_ivl_eq (*‹rev.existence_ivl t0 ?x0.0 = preflect t0 ` existence_ivl t0 ?x0.0›*)) then have Sup_mem: "Sup (rev.existence_ivl t0 x0) ∈ preflect t0 ` T" using ‹b ∈ T› (*‹b ∈ T›*) by auto have rev_iv: "t0 ∈ preflect t0 ` T" "x0 ∈ X" using iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) apply - (*goals: 1. ‹⟦(t0::real) ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)⟧ ⟹ t0 ∈ preflect t0 ` T› 2. ‹⟦(t0::real) ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)⟧ ⟹ x0 ∈ X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from rev.flow_leaves_compact_ivl_right[OF rev_iv bdd_rev Sup_mem ‹compact K› ‹K ⊆ X›] (*‹(⋀t. ⟦t0 ≤ t; t ∈ rev.existence_ivl t0 x0; rev.flow t0 x0 t ∉ K⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain t where "t0 ≤ t" "t ∈ rev.existence_ivl t0 x0" "rev.flow t0 x0 t ∉ K" (*goal: ‹(⋀t. ⟦t0 ≤ t; t ∈ rev.existence_ivl t0 x0; rev.flow t0 x0 t ∉ K⟧ ⟹ thesis) ⟹ thesis›*) . then have "preflect t0 t ≤ t0" "preflect t0 t ∈ existence_ivl t0 x0" "flow t0 x0 (preflect t0 t) ∉ K" apply - (*goals: 1. ‹⟦t0 ≤ t; t ∈ rev.existence_ivl t0 x0; rev.flow t0 x0 t ∉ K⟧ ⟹ preflect t0 t ≤ t0› 2. ‹⟦t0 ≤ t; t ∈ rev.existence_ivl t0 x0; rev.flow t0 x0 t ∉ K⟧ ⟹ preflect t0 t ∈ existence_ivl t0 x0› 3. ‹⟦t0 ≤ t; t ∈ rev.existence_ivl t0 x0; rev.flow t0 x0 t ∉ K⟧ ⟹ flow t0 x0 (preflect t0 t) ∉ K› discuss goal 1*) apply ((auto simp: rev_existence_ivl_eq (*‹rev.existence_ivl t0 ?x0.0 = preflect t0 ` existence_ivl t0 ?x0.0›*) rev_flow_eq (*‹?t ∈ ll_on_open.existence_ivl (preflect ?t0.0 ` T) (λt. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ⟹ ll_on_open.flow (preflect ?t0.0 ` T) (λt. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ?t = flow ?t0.0 ?x0.0 (preflect ?t0.0 ?t)›*))[1]) (*discuss goal 2*) apply ((auto simp: rev_existence_ivl_eq (*‹rev.existence_ivl t0 ?x0.0 = preflect t0 ` existence_ivl t0 ?x0.0›*) rev_flow_eq (*‹?t ∈ ll_on_open.existence_ivl (preflect ?t0.0 ` T) (λt. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ⟹ ll_on_open.flow (preflect ?t0.0 ` T) (λt. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ?t = flow ?t0.0 ?x0.0 (preflect ?t0.0 ?t)›*))[1]) (*discuss goal 3*) apply ((auto simp: rev_existence_ivl_eq (*‹rev.existence_ivl (t0::real) (?x0.0::'a) = preflect t0 ` existence_ivl t0 ?x0.0›*) rev_flow_eq (*‹(?t::real) ∈ ll_on_open.existence_ivl (preflect (?t0.0::real) ` (T::real set)) (λt::real. - (f::real ⇒ 'a ⇒ 'a) (preflect ?t0.0 t)) (X::'a set) ?t0.0 (?x0.0::'a) ⟹ ll_on_open.flow (preflect ?t0.0 ` T) (λt::real. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ?t = flow ?t0.0 ?x0.0 (preflect ?t0.0 ?t)›*))[1]) (*proven 3 subgoals*) . thus "?thesis" (*goal: ‹thesis›*) by standard qed lemma sup_existence_maximal: assumes "⋀t. t0 ≤ t ⟹ t ∈ existence_ivl t0 x0 ⟹ flow t0 x0 t ∈ K" assumes "compact K" "K ⊆ X" assumes "bdd_above (existence_ivl t0 x0)" shows "Sup (existence_ivl t0 x0) ∉ T" using flow_leaves_compact_ivl_right[of K] (*‹⟦bdd_above (existence_ivl t0 x0); Sup (existence_ivl t0 x0) ∈ T; compact K; K ⊆ X; ⋀t. ⟦t0 ≤ t; t ∈ existence_ivl t0 x0; flow t0 x0 t ∉ K⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹⟦t0 ≤ ?t; ?t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 ?t ∈ K› ‹compact K› ‹K ⊆ X› ‹bdd_above (existence_ivl t0 x0)›*) by force lemma inf_existence_minimal: assumes "⋀t. t ≤ t0 ⟹ t ∈ existence_ivl t0 x0 ⟹ flow t0 x0 t ∈ K" assumes "compact K" "K ⊆ X" assumes "bdd_below (existence_ivl t0 x0)" shows "Inf (existence_ivl t0 x0) ∉ T" using flow_leaves_compact_ivl_left[of K] (*‹⟦bdd_below (existence_ivl t0 x0); Inf (existence_ivl t0 x0) ∈ T; compact K; K ⊆ X; ⋀t. ⟦t ≤ t0; t ∈ existence_ivl t0 x0; flow t0 x0 t ∉ K⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) assms (*‹⟦?t ≤ t0; ?t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 ?t ∈ K› ‹compact K› ‹(K::'a set) ⊆ (X::'a set)› ‹bdd_below (existence_ivl t0 x0)›*) by force end lemma subset_mem_compact_implies_subset_existence_interval: assumes ivl: "t0 ∈ T'" "is_interval T'" "T' ⊆ T" assumes iv_defined: "x0 ∈ X" assumes mem_compact: "⋀t. t ∈ T' ⟹ t ∈ existence_ivl t0 x0 ⟹ flow t0 x0 t ∈ K" assumes K: "compact K" "K ⊆ X" shows "T' ⊆ existence_ivl t0 x0" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ (T'::real set) ⊆ existence_ivl (t0::real) (x0::'a) ⟹ False›*) assume "¬ T' ⊆ existence_ivl t0 x0" (*‹¬ (T'::real set) ⊆ existence_ivl (t0::real) (x0::'a)›*) then obtain t' where t': "t' ∉ existence_ivl t0 x0" "t' ∈ T'" (*goal: ‹(⋀t'. ⟦t' ∉ existence_ivl t0 x0; t' ∈ T'⟧ ⟹ thesis) ⟹ thesis›*) by auto from assms (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T› ‹x0 ∈ X› ‹⟦?t ∈ T'; ?t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 ?t ∈ K› ‹compact (K::'a::{heine_borel,banach} set)› ‹K ⊆ X›*) have iv_defined: "t0 ∈ T" "x0 ∈ X" apply - (*goals: 1. ‹⟦t0 ∈ T'; is_interval T'; T' ⊆ T; x0 ∈ X; ⋀t. ⟦t ∈ T'; t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 t ∈ K; compact K; K ⊆ X⟧ ⟹ t0 ∈ T› 2. ‹⟦t0 ∈ T'; is_interval T'; T' ⊆ T; x0 ∈ X; ⋀t. ⟦t ∈ T'; t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 t ∈ K; compact K; K ⊆ X⟧ ⟹ x0 ∈ X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show False proof (cases rule: not_in_connected_cases[OF connected_existence_ivl t'(1) existence_ivl_notempty[OF iv_defined]] (*‹⟦⟦bdd_above (existence_ivl t0 x0); ⋀y. y ∈ existence_ivl t0 x0 ⟹ y ≤ t'⟧ ⟹ ?thesis; ⟦bdd_below (existence_ivl t0 x0); ⋀y. y ∈ existence_ivl t0 x0 ⟹ t' ≤ y⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦bdd_above (existence_ivl (t0::real) (x0::'a)); ⋀y::real. y ∈ existence_ivl t0 x0 ⟹ y ≤ (t'::real)⟧ ⟹ False› 2. ‹⟦bdd_below (existence_ivl (t0::real) (x0::'a)); ⋀y::real. y ∈ existence_ivl t0 x0 ⟹ (t'::real) ≤ y⟧ ⟹ False›*) assume bdd: "bdd_below (existence_ivl t0 x0)" (*‹bdd_below (existence_ivl (t0::real) (x0::'a))›*) assume t'_lower: "t' ≤ y" if "y ∈ existence_ivl t0 x0" for y (*‹(?y::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ (t'::real) ≤ ?y›*) have i: "Inf (existence_ivl t0 x0) ∈ T'" using initial_time_bounds[OF iv_defined] (*‹bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0)› ‹bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0›*) iv_defined (*‹t0 ∈ T› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*) apply - (*goal: ‹Inf (existence_ivl (t0::real) (x0::'a)) ∈ (T'::real set)›*) apply (rule mem_is_intervalI[of _ t' t0] (*‹⟦is_interval ?S; t' ∈ ?S; t0 ∈ ?S; ⋀i. i ∈ Basis ⟹ t' ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ t0 ∙ i ∨ t0 ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ t' ∙ i⟧ ⟹ ?x ∈ ?S›*)) (*goals: 1. ‹⟦bdd_above (existence_ivl (t0::real) (x0::'a)) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0; t0 ∈ (T::real set); x0 ∈ (X::'a set)⟧ ⟹ is_interval (T'::real set)› 2. ‹⟦bdd_above (existence_ivl (t0::real) (x0::'a)) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0; t0 ∈ (T::real set); x0 ∈ (X::'a set)⟧ ⟹ (t'::real) ∈ (T'::real set)› 3. ‹⟦bdd_above (existence_ivl (t0::real) (x0::'a)) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0; t0 ∈ (T::real set); x0 ∈ (X::'a set)⟧ ⟹ t0 ∈ (T'::real set)› 4. ‹⋀i::real. ⟦bdd_above (existence_ivl (t0::real) (x0::'a)) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0; t0 ∈ (T::real set); x0 ∈ (X::'a set); i ∈ Basis⟧ ⟹ (t'::real) ∙ i ≤ Inf (existence_ivl t0 x0) ∙ i ∧ Inf (existence_ivl t0 x0) ∙ i ≤ t0 ∙ i ∨ t0 ∙ i ≤ Inf (existence_ivl t0 x0) ∙ i ∧ Inf (existence_ivl t0 x0) ∙ i ≤ t' ∙ i› discuss goal 1*) apply ((auto simp: ivl (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T›*) t' (*‹t' ∉ existence_ivl t0 x0› ‹t' ∈ T'›*) bdd (*‹bdd_below (existence_ivl t0 x0)›*) intro!: t'_lower (*‹?y ∈ existence_ivl t0 x0 ⟹ t' ≤ ?y›*) cInf_greatest[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x. x ∈ existence_ivl t0 x0 ⟹ ?z ≤ x) ⟹ ?z ≤ Inf (existence_ivl t0 x0)›*))[1]) (*discuss goal 2*) apply ((auto simp: ivl (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T›*) t' (*‹t' ∉ existence_ivl t0 x0› ‹t' ∈ T'›*) bdd (*‹bdd_below (existence_ivl t0 x0)›*) intro!: t'_lower (*‹?y ∈ existence_ivl t0 x0 ⟹ t' ≤ ?y›*) cInf_greatest[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x. x ∈ existence_ivl t0 x0 ⟹ ?z ≤ x) ⟹ ?z ≤ Inf (existence_ivl t0 x0)›*))[1]) (*discuss goal 3*) apply ((auto simp: ivl (*‹(t0::real) ∈ (T'::real set)› ‹is_interval (T'::real set)› ‹(T'::real set) ⊆ (T::real set)›*) t' (*‹(t'::real) ∉ existence_ivl (t0::real) (x0::'a)› ‹(t'::real) ∈ (T'::real set)›*) bdd (*‹bdd_below (existence_ivl (t0::real) (x0::'a))›*) intro!: t'_lower (*‹(?y::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ (t'::real) ≤ ?y›*) cInf_greatest[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x::real. x ∈ existence_ivl (t0::real) (x0::'a) ⟹ (?z::real) ≤ x) ⟹ ?z ≤ Inf (existence_ivl t0 x0)›*))[1]) (*discuss goal 4*) apply ((auto simp: ivl (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T›*) t' (*‹t' ∉ existence_ivl t0 x0› ‹t' ∈ T'›*) bdd (*‹bdd_below (existence_ivl t0 x0)›*) intro!: t'_lower (*‹?y ∈ existence_ivl t0 x0 ⟹ t' ≤ ?y›*) cInf_greatest[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x. x ∈ existence_ivl t0 x0 ⟹ ?z ≤ x) ⟹ ?z ≤ Inf (existence_ivl t0 x0)›*))[1]) (*proven 4 subgoals*) . have "*": "t ∈ T'" if "t ≤ t0" "t ∈ existence_ivl t0 x0" for t apply (rule mem_is_intervalI[OF ‹is_interval T'› i ‹t0 ∈ T'›] (*‹(⋀i::real. i ∈ Basis ⟹ Inf (existence_ivl (t0::real) (x0::'a::{heine_borel,banach})) ∙ i ≤ (?x::real) ∙ i ∧ ?x ∙ i ≤ t0 ∙ i ∨ t0 ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ Inf (existence_ivl t0 x0) ∙ i) ⟹ ?x ∈ (T'::real set)›*)) (*goal: ‹t ∈ T'›*) by (auto intro!: cInf_lower (*‹⟦(?x::?'a) ∈ (?X::?'a set); bdd_below ?X⟧ ⟹ Inf ?X ≤ ?x›*) that (*‹(t::real) ≤ (t0::real)› ‹(t::real) ∈ existence_ivl (t0::real) (x0::'a)›*) bdd (*‹bdd_below (existence_ivl (t0::real) (x0::'a))›*)) from inf_existence_minimal[OF iv_defined mem_compact K bdd, OF *] (*‹⟦⋀t. ⟦t ≤ t0; t ∈ existence_ivl t0 x0⟧ ⟹ t ≤ t0; ⋀t. ⟦t ≤ t0; t ∈ existence_ivl t0 x0⟧ ⟹ t ∈ existence_ivl t0 x0; ⋀t. ⟦t ≤ t0; t ∈ existence_ivl t0 x0⟧ ⟹ t ∈ existence_ivl t0 x0⟧ ⟹ Inf (existence_ivl t0 x0) ∉ T›*) show False using i (*‹Inf (existence_ivl t0 x0) ∈ T'›*) ivl (*‹(t0::real) ∈ (T'::real set)› ‹is_interval T'› ‹T' ⊆ T›*) by auto next (*goal: ‹⟦bdd_above (existence_ivl t0 x0); ⋀y. y ∈ existence_ivl t0 x0 ⟹ y ≤ t'⟧ ⟹ False›*) assume bdd: "bdd_above (existence_ivl t0 x0)" (*‹bdd_above (existence_ivl (t0::real) (x0::'a))›*) assume t'_upper: "y ≤ t'" if "y ∈ existence_ivl t0 x0" for y (*‹(?y::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ ?y ≤ (t'::real)›*) have s: "Sup (existence_ivl t0 x0) ∈ T'" using initial_time_bounds[OF iv_defined] (*‹bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0)› ‹bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0›*) apply - (*goal: ‹Sup (existence_ivl (t0::real) (x0::'a)) ∈ (T'::real set)›*) apply (rule mem_is_intervalI[of _ t0 t'] (*‹⟦is_interval ?S; t0 ∈ ?S; t' ∈ ?S; ⋀i. i ∈ Basis ⟹ t0 ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ t' ∙ i ∨ t' ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ t0 ∙ i⟧ ⟹ ?x ∈ ?S›*)) (*goals: 1. ‹⟦bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0⟧ ⟹ is_interval T'› 2. ‹⟦bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0⟧ ⟹ t0 ∈ T'› 3. ‹⟦bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0⟧ ⟹ t' ∈ T'› 4. ‹⋀i. ⟦bdd_above (existence_ivl t0 x0) ⟹ t0 < Sup (existence_ivl t0 x0); bdd_below (existence_ivl t0 x0) ⟹ Inf (existence_ivl t0 x0) < t0; i ∈ Basis⟧ ⟹ t0 ∙ i ≤ Sup (existence_ivl t0 x0) ∙ i ∧ Sup (existence_ivl t0 x0) ∙ i ≤ t' ∙ i ∨ t' ∙ i ≤ Sup (existence_ivl t0 x0) ∙ i ∧ Sup (existence_ivl t0 x0) ∙ i ≤ t0 ∙ i› discuss goal 1*) apply ((auto simp: ivl (*‹(t0::real) ∈ (T'::real set)› ‹is_interval (T'::real set)› ‹(T'::real set) ⊆ (T::real set)›*) t' (*‹(t'::real) ∉ existence_ivl (t0::real) (x0::'a::{heine_borel,banach})› ‹(t'::real) ∈ (T'::real set)›*) bdd (*‹bdd_above (existence_ivl (t0::real) (x0::'a::{heine_borel,banach}))›*) intro!: t'_upper (*‹(?y::real) ∈ existence_ivl (t0::real) (x0::'a::{heine_borel,banach}) ⟹ ?y ≤ (t'::real)›*) cSup_least[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x::real. x ∈ existence_ivl (t0::real) (x0::'a::{heine_borel,banach}) ⟹ x ≤ (?z::real)) ⟹ Sup (existence_ivl t0 x0) ≤ ?z›*))[1]) (*discuss goal 2*) apply ((auto simp: ivl (*‹(t0::real) ∈ (T'::real set)› ‹is_interval (T'::real set)› ‹(T'::real set) ⊆ (T::real set)›*) t' (*‹(t'::real) ∉ existence_ivl (t0::real) (x0::'a)› ‹(t'::real) ∈ (T'::real set)›*) bdd (*‹bdd_above (existence_ivl (t0::real) (x0::'a))›*) intro!: t'_upper (*‹(?y::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ ?y ≤ (t'::real)›*) cSup_least[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x::real. x ∈ existence_ivl (t0::real) (x0::'a) ⟹ x ≤ (?z::real)) ⟹ Sup (existence_ivl t0 x0) ≤ ?z›*))[1]) (*discuss goal 3*) apply ((auto simp: ivl (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T›*) t' (*‹t' ∉ existence_ivl t0 x0› ‹t' ∈ T'›*) bdd (*‹bdd_above (existence_ivl t0 x0)›*) intro!: t'_upper (*‹?y ∈ existence_ivl t0 x0 ⟹ ?y ≤ t'›*) cSup_least[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x. x ∈ existence_ivl t0 x0 ⟹ x ≤ ?z) ⟹ Sup (existence_ivl t0 x0) ≤ ?z›*))[1]) (*discuss goal 4*) apply ((auto simp: ivl (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T›*) t' (*‹t' ∉ existence_ivl t0 x0› ‹t' ∈ T'›*) bdd (*‹bdd_above (existence_ivl t0 x0)›*) intro!: t'_upper (*‹?y ∈ existence_ivl t0 x0 ⟹ ?y ≤ t'›*) cSup_least[OF existence_ivl_notempty[OF iv_defined]] (*‹(⋀x. x ∈ existence_ivl t0 x0 ⟹ x ≤ ?z) ⟹ Sup (existence_ivl t0 x0) ≤ ?z›*))[1]) (*proven 4 subgoals*) . have "*": "t ∈ T'" if "t0 ≤ t" "t ∈ existence_ivl t0 x0" for t apply (rule mem_is_intervalI[OF ‹is_interval T'› ‹t0 ∈ T'› s] (*‹(⋀i. i ∈ Basis ⟹ t0 ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ Sup (existence_ivl t0 x0) ∙ i ∨ Sup (existence_ivl t0 x0) ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ t0 ∙ i) ⟹ ?x ∈ T'›*)) (*goal: ‹t ∈ T'›*) by (auto intro!: cSup_upper (*‹⟦?x ∈ ?X; bdd_above ?X⟧ ⟹ ?x ≤ Sup ?X›*) that (*‹t0 ≤ t› ‹t ∈ existence_ivl t0 x0›*) bdd (*‹bdd_above (existence_ivl t0 x0)›*)) from sup_existence_maximal[OF iv_defined mem_compact K bdd, OF *] (*‹⟦⋀t. ⟦t0 ≤ t; t ∈ existence_ivl t0 x0⟧ ⟹ t0 ≤ t; ⋀t. ⟦t0 ≤ t; t ∈ existence_ivl t0 x0⟧ ⟹ t ∈ existence_ivl t0 x0; ⋀t. ⟦t0 ≤ t; t ∈ existence_ivl t0 x0⟧ ⟹ t ∈ existence_ivl t0 x0⟧ ⟹ Sup (existence_ivl t0 x0) ∉ T›*) show False using s (*‹Sup (existence_ivl t0 x0) ∈ T'›*) ivl (*‹t0 ∈ T'› ‹is_interval T'› ‹T' ⊆ T›*) by auto qed qed lemma mem_compact_implies_subset_existence_interval: assumes iv_defined: "t0 ∈ T" "x0 ∈ X" assumes mem_compact: "⋀t. t ∈ T ⟹ t ∈ existence_ivl t0 x0 ⟹ flow t0 x0 t ∈ K" assumes K: "compact K" "K ⊆ X" shows "T ⊆ existence_ivl t0 x0" apply (rule subset_mem_compact_implies_subset_existence_interval (*‹⟦t0 ∈ ?T'; is_interval ?T'; ?T' ⊆ T; ?x0.0 ∈ X; ⋀t. ⟦t ∈ ?T'; t ∈ existence_ivl t0 ?x0.0⟧ ⟹ flow t0 ?x0.0 t ∈ ?K; compact ?K; ?K ⊆ X⟧ ⟹ ?T' ⊆ existence_ivl t0 ?x0.0›*)) (*goals: 1. ‹t0 ∈ T› 2. ‹is_interval T› 3. ‹T ⊆ T› 4. ‹x0 ∈ X› 5. ‹⋀t. ⟦t ∈ T; t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 t ∈ ?K› 6. ‹compact ?K› 7. ‹?K ⊆ X› discuss goal 1*) apply fact (*discuss goal 2*) apply (rule order_refl (*‹?x ≤ ?x›*) interval (*‹is_interval T›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) (*discuss goal 3*) apply (rule order_refl (*‹?x ≤ ?x›*) interval (*‹is_interval T›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) (*discuss goal 4*) apply fact (*discuss goal 5*) apply fact (*discuss goal 6*) apply fact (*discuss goal 7*) apply fact (*proven 7 subgoals*) . lemma global_right_existence_ivl_explicit: assumes "b ≥ t0" assumes b: "b ∈ existence_ivl t0 x0" obtains d K where "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {t0 .. b} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" proof (-) (*goal: ‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {t0..b}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) note iv_defined = mem_existence_ivl_iv_defined[OF b] (*‹t0 ∈ T› ‹x0 ∈ X›*) define seg where "seg ≡ (λt. flow t0 x0 t) ` (closed_segment t0 b)" have [simp]: "x0 ∈ seg" by (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) intro!: image_eqI[where x=t0] (*‹⟦?b = ?f t0; t0 ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) have "seg ≠ {}" by (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) moreover have "compact seg" using iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) b (*‹b ∈ existence_ivl t0 x0›*) apply (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*)) (*goals: 1. ‹⋀x. ⟦t0 ∈ T; x0 ∈ X; b ∈ existence_ivl t0 x0; t0 ≤ x; x ≤ b⟧ ⟹ x ∈ existence_ivl t0 x0› 2. ‹⋀x. ⟦t0 ∈ T; x0 ∈ X; b ∈ existence_ivl t0 x0; ¬ t0 ≤ b; b ≤ x; x ≤ t0⟧ ⟹ x ∈ existence_ivl t0 x0› discuss goal 1*) apply (metis (erased, opaque_lifting) atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) closed_segment_subset_existence_ivl (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ {t0--?t} ⊆ existence_ivl t0 ?x0.0›*) contra_subsetD (*‹⟦?A ⊆ ?B; ?c ∉ ?B⟧ ⟹ ?c ∉ ?A›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) (*discuss goal 2*) apply (metis (erased, opaque_lifting) atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) closed_segment_subset_existence_ivl (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ {t0--?t} ⊆ existence_ivl t0 ?x0.0›*) contra_subsetD (*‹⟦?A ⊆ ?B; ?c ∉ ?B⟧ ⟹ ?c ∉ ?A›*) order.trans (*‹⟦?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?a ≤ ?c›*)) (*proven 2 subgoals*) . moreover note open_domain(2) (*‹open (X::'a set)›*) moreover have "seg ⊆ X" using closed_segment_subset_existence_ivl (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ {t0--?t} ⊆ existence_ivl t0 ?x0.0›*) b (*‹b ∈ existence_ivl t0 x0›*) by (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) intro!: flow_in_domain (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t ∈ X›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*)) ultimately obtain e where e: "0 < e" "{x. infdist x seg ≤ e} ⊆ X" (*goal: ‹(⋀e. ⟦0 < e; {x. infdist x seg ≤ e} ⊆ X⟧ ⟹ thesis) ⟹ thesis›*) thm compact_in_open_separated by (rule compact_in_open_separated (*‹⟦?A ≠ {}; compact ?A; open ?B; ?A ⊆ ?B; ⋀e. ⟦0 < e; {x. infdist x ?A ≤ e} ⊆ ?B⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*)) define A where "A ≡ {x. infdist x seg ≤ e}" have "A ⊆ X" using e (*‹0 < e› ‹{x. infdist x seg ≤ e} ⊆ X›*) by (simp add: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*)) have mem_existence_ivlI: "⋀s. t0 ≤ s ⟹ s ≤ b ⟹ s ∈ existence_ivl t0 x0" apply (rule in_existence_between_zeroI[OF b] (*‹?s ∈ {t0--b} ⟹ ?s ∈ existence_ivl t0 x0›*)) (*goal: ‹⋀s. ⟦t0 ≤ s; s ≤ b⟧ ⟹ s ∈ existence_ivl t0 x0›*) by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) have "compact A" unfolding A_def (*goal: ‹compact {x. infdist x seg ≤ e}›*) apply (rule compact_infdist_le (*‹⟦(?A::?'a::heine_borel set) ≠ {}; compact ?A; (0::real) < (?e::real)⟧ ⟹ compact {x::?'a::heine_borel. infdist x ?A ≤ ?e}›*)) (*goals: 1. ‹seg ≠ {}› 2. ‹compact seg› 3. ‹0 < e› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*discuss goal 3*) apply fact (*proven 3 subgoals*) . have "compact {t0 .. b}" "{t0 .. b} ⊆ T" subgoal for by simp subgoal for using mem_existence_ivlI (*‹⟦t0 ≤ ?s; ?s ≤ b⟧ ⟹ ?s ∈ existence_ivl t0 x0›*) mem_existence_ivl_subset[of _ x0] (*‹(?t::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ ?t ∈ (T::real set)›*) iv_defined (*‹(t0::real) ∈ (T::real set)› ‹x0 ∈ X›*) b (*‹b ∈ existence_ivl t0 x0›*) ivl_subset_existence_ivl (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ {t0..?t} ⊆ existence_ivl t0 ?x0.0›*) by blast . from lipschitz_on_compact[OF this ‹compact A› ‹A ⊆ X›] (*‹(⋀L. (⋀t. t ∈ {t0..b} ⟹ L-lipschitz_on A (f t)) ⟹ ?thesis) ⟹ ?thesis›*) obtain K' where K': "⋀t. t ∈ {t0 .. b} ⟹ K'-lipschitz_on A (f t)" (*goal: ‹(⋀K'. (⋀t. t ∈ {t0..b} ⟹ K'-lipschitz_on A (f t)) ⟹ thesis) ⟹ thesis›*) by metis define K where "K ≡ K' + 1" have "0 < K" "0 ≤ K" using assms (*‹(t0::real) ≤ (b::real)› ‹b ∈ existence_ivl t0 x0›*) lipschitz_on_nonneg[OF K', of t0] (*‹t0 ∈ {t0..b} ⟹ 0 ≤ K'›*) apply - (*goals: 1. ‹⟦(t0::real) ≤ (b::real); b ∈ existence_ivl t0 (x0::'a); t0 ∈ {t0..b} ⟹ (0::real) ≤ (K'::real)⟧ ⟹ (0::real) < (K::real)› 2. ‹⟦(t0::real) ≤ (b::real); b ∈ existence_ivl t0 (x0::'a); t0 ∈ {t0..b} ⟹ (0::real) ≤ (K'::real)⟧ ⟹ (0::real) ≤ (K::real)› discuss goal 1*) apply ((auto simp: K_def (*‹K ≡ K' + 1›*))[1]) (*discuss goal 2*) apply ((auto simp: K_def (*‹K ≡ K' + 1›*))[1]) (*proven 2 subgoals*) . have K: "⋀t. t ∈ {t0 .. b} ⟹ K-lipschitz_on A (f t)" unfolding K_def (*goal: ‹⋀t::real. t ∈ {t0::real..b::real} ⟹ ((K'::real) + (1::real))-lipschitz_on (A::'a::{heine_borel,banach} set) ((f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t)›*) using ‹_ ⟹ lipschitz_on K' A _› (*‹(?t::real) ∈ {t0::real..b::real} ⟹ (K'::real)-lipschitz_on (A::'a::{heine_borel,banach} set) ((f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) ?t)›*) apply (rule lipschitz_on_mono (*‹⟦(?M::real)-lipschitz_on (?E::?'a set) (?f::?'a ⇒ ?'b); (?D::?'a set) ⊆ ?E; ?M ≤ (?L::real)⟧ ⟹ ?L-lipschitz_on ?D ?f›*)) (*goals: 1. ‹⋀t::real. t ∈ {t0::real..b::real} ⟹ t ∈ {t0..b}› 2. ‹⋀t::real. t ∈ {t0::real..b::real} ⟹ (A::'a::{heine_borel,banach} set) ⊆ A› 3. ‹⋀t::real. t ∈ {t0::real..b::real} ⟹ (K'::real) ≤ K' + (1::real)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have [simp]: "x0 ∈ A" using ‹0 < e› (*‹0 < e›*) by (auto simp: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*)) define d where "d ≡ min e (e * exp (-K * (b - t0)))" hence d: "0 < d" "d ≤ e" "d ≤ e * exp (-K * (b - t0))" using e (*‹0 < e› ‹{x. infdist x seg ≤ e} ⊆ X›*) apply - (*goals: 1. ‹⟦d ≡ min e (e * exp (- K * (b - t0))); 0 < e; {x. infdist x seg ≤ e} ⊆ X⟧ ⟹ 0 < d› 2. ‹⟦d ≡ min e (e * exp (- K * (b - t0))); 0 < e; {x. infdist x seg ≤ e} ⊆ X⟧ ⟹ d ≤ e› 3. ‹⟦d ≡ min e (e * exp (- K * (b - t0))); 0 < e; {x. infdist x seg ≤ e} ⊆ X⟧ ⟹ d ≤ e * exp (- K * (b - t0))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have d_times_exp_le: "d * exp (K * (t - t0)) ≤ e" if "t0 ≤ t" "t ≤ b" for t proof (-) (*goal: ‹d * exp (K * (t - t0)) ≤ e›*) from that (*‹t0 ≤ t› ‹t ≤ b›*) have "d * exp (K * (t - t0)) ≤ d * exp (K * (b - t0))" using ‹0 ≤ K› (*‹0 ≤ K›*) ‹0 < d› (*‹0 < d›*) by (auto intro!: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) also (*calculation: ‹d * exp (K * (t - t0)) ≤ d * exp (K * (b - t0))›*) have "d * exp (K * (b - t0)) ≤ e" using d (*‹(0::real) < (d::real)› ‹d ≤ e› ‹d ≤ e * exp (- K * (b - t0))›*) by (auto simp: exp_minus (*‹exp (- ?x) = inverse (exp ?x)›*) divide_simps (*‹inverse ?a = 1 / ?a› ‹?a + ?b / ?z = (if ?z = 0 then ?a else (?a * ?z + ?b) / ?z)› ‹?a / ?z + ?b = (if ?z = 0 then ?b else (?a + ?b * ?z) / ?z)› ‹- (?a / ?z) + ?b = (if ?z = 0 then ?b else (- ?a + ?b * ?z) / ?z)› ‹?a - ?b / ?z = (if ?z = 0 then ?a else (?a * ?z - ?b) / ?z)› ‹?a / ?z - ?b = (if ?z = 0 then - ?b else (?a - ?b * ?z) / ?z)› ‹- (?a / ?z) - ?b = (if ?z = 0 then - ?b else (- ?a - ?b * ?z) / ?z)› ‹(?b / ?c = ?a) = (if ?c ≠ 0 then ?b = ?a * ?c else ?a = 0)› ‹(?a = ?b / ?c) = (if ?c ≠ 0 then ?a * ?c = ?b else ?a = 0)› ‹(- (?b / ?c) = ?a) = (if ?c ≠ 0 then - ?b = ?a * ?c else ?a = 0)› ‹(?a = - (?b / ?c)) = (if ?c ≠ 0 then ?a * ?c = - ?b else ?a = 0)› ‹(?a ≤ ?b / ?c) = (if 0 < ?c then ?a * ?c ≤ ?b else if ?c < 0 then ?b ≤ ?a * ?c else ?a ≤ 0)› and more 13 facts*)) finally (*calculation: ‹(d::real) * exp ((K::real) * ((t::real) - (t0::real))) ≤ (e::real)›*) show "?thesis" (*goal: ‹(d::real) * exp ((K::real) * ((t::real) - (t0::real))) ≤ (e::real)›*) . qed have "ball x0 d ⊆ X" using d (*‹0 < d› ‹d ≤ e› ‹d ≤ e * exp (- K * (b - t0))›*) ‹A ⊆ X› (*‹A ⊆ X›*) by (auto simp: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*) intro!: infdist_le2[where a=x0] (*‹⟦x0 ∈ ?A; dist ?x x0 ≤ ?d⟧ ⟹ infdist ?x ?A ≤ ?d›*)) note iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) { fix y assume y: "y ∈ ball x0 d" (*‹(y::'a) ∈ ball (x0::'a) (d::real)›*) hence "y ∈ A" using d (*‹(0::real) < (d::real)› ‹d ≤ e› ‹(d::real) ≤ (e::real) * exp (- (K::real) * ((b::real) - (t0::real)))›*) by (auto simp: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*) intro!: infdist_le2[where a=x0] (*‹⟦x0 ∈ ?A; dist ?x x0 ≤ ?d⟧ ⟹ infdist ?x ?A ≤ ?d›*)) hence "y ∈ X" using ‹A ⊆ X› (*‹A ⊆ X›*) by auto note y_iv = ‹t0 ∈ T› (*‹(t0::real) ∈ (T::real set)›*) ‹y ∈ X› (*‹y ∈ X›*) have in_A: "flow t0 y t ∈ A" if t: "t0 ≤ t" "t ∈ existence_ivl t0 y" "t ≤ b" for t proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹flow (t0::real) (y::'a::{heine_borel,banach}) (t::real) ∉ (A::'a::{heine_borel,banach} set) ⟹ False›*) assume flow_out: "flow t0 y t ∉ A" (*‹flow (t0::real) (y::'a) (t::real) ∉ (A::'a set)›*) obtain t' where t': "t0 ≤ t'" "t' ≤ t" "⋀t. t ∈ {t0 .. t'} ⟹ flow t0 x0 t ∈ A" "infdist (flow t0 y t') seg ≥ e" "⋀t. t ∈ {t0 .. t'} ⟹ flow t0 y t ∈ A" (*goal: ‹(⋀t'. ⟦t0 ≤ t'; t' ≤ t; ⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A; e ≤ infdist (flow t0 y t') seg; ⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A⟧ ⟹ thesis) ⟹ thesis›*) proof (-) (*goal: ‹(⋀t'. ⟦t0 ≤ t'; t' ≤ t; ⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A; e ≤ infdist (flow t0 y t') seg; ⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A⟧ ⟹ thesis) ⟹ thesis›*) let ?out = "((λt. infdist (flow t0 y t) seg) -` {e..}) ∩ {t0..t}" have "compact ?out" unfolding compact_eq_bounded_closed (*goal: ‹bounded ((λt. infdist (flow t0 y t) seg) -` {e..} ∩ {t0..t}) ∧ closed ((λt. infdist (flow t0 y t) seg) -` {e..} ∩ {t0..t})›*) proof (safe) (*goals: 1. ‹bounded ((λt::real. infdist (flow (t0::real) (y::'a) t) (seg::'a set)) -` {e::real..} ∩ {t0..t::real})› 2. ‹closed ((λt::real. infdist (flow (t0::real) (y::'a) t) (seg::'a set)) -` {e::real..} ∩ {t0..t::real})›*) show "bounded ?out" by (auto intro!: bounded_closed_interval (*‹bounded {?a..?b}›*)) have "continuous_on {t0 .. t} ((λt. infdist (flow t0 y t) seg))" using closed_segment_subset_existence_ivl (*‹(?t::real) ∈ existence_ivl (t0::real) (?x0.0::'a) ⟹ {t0--?t} ⊆ existence_ivl t0 ?x0.0›*) t (*‹t0 ≤ t› ‹(t::real) ∈ existence_ivl (t0::real) (y::'a)› ‹(t::real) ≤ (b::real)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) by (force intro!: continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) thus "closed ?out" by (simp add: continuous_on_closed_vimage (*‹closed ?s ⟹ continuous_on ?s ?f = (∀B. closed B ⟶ closed (?f -` B ∩ ?s))›*)) qed moreover have "t ∈ (λt. infdist (flow t0 y t) seg) -` {e..} ∩ {t0..t}" using flow_out (*‹flow t0 y t ∉ A›*) ‹t0 ≤ t› (*‹t0 ≤ t›*) by (auto simp: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*)) hence "?out ≠ {}" by blast ultimately have "∃s∈?out. ∀t∈?out. s ≤ t" by (rule compact_attains_inf (*‹⟦compact ?S; ?S ≠ {}⟧ ⟹ ∃s∈?S. ∀t∈?S. s ≤ t›*)) then obtain t' where t': "⋀s. e ≤ infdist (flow t0 y s) seg ⟹ t0 ≤ s ⟹ s ≤ t ⟹ t' ≤ s" "e ≤ infdist (flow t0 y t') seg" "t0 ≤ t'" "t' ≤ t" (*goal: ‹(⋀t'. ⟦⋀s. ⟦e ≤ infdist (flow t0 y s) seg; t0 ≤ s; s ≤ t⟧ ⟹ t' ≤ s; e ≤ infdist (flow t0 y t') seg; t0 ≤ t'; t' ≤ t⟧ ⟹ thesis) ⟹ thesis›*) apply (auto simp: vimage_def (*‹(?f::?'a ⇒ ?'b) -` (?B::?'b set) ≡ {x::?'a. ?f x ∈ ?B}›*) Ball_def (*‹Ball (?A::?'a set) (?P::?'a ⇒ bool) = (∀x::?'a. x ∈ ?A ⟶ ?P x)›*)) (*goal: ‹(⋀t'. ⟦⋀s. ⟦e ≤ infdist (flow t0 y s) seg; t0 ≤ s; s ≤ t⟧ ⟹ t' ≤ s; e ≤ infdist (flow t0 y t') seg; t0 ≤ t'; t' ≤ t⟧ ⟹ thesis) ⟹ thesis›*) by metis have flow_in: "flow t0 x0 s ∈ A" if s: "s ∈ {t0 .. t'}" for s proof (-) (*goal: ‹flow t0 x0 s ∈ A›*) from s (*‹(s::real) ∈ {t0::real..t'::real}›*) have "s ∈ closed_segment t0 b" using ‹t ≤ b› (*‹t ≤ b›*) t' (*‹⟦e ≤ infdist (flow t0 y ?s) seg; t0 ≤ ?s; ?s ≤ t⟧ ⟹ t' ≤ ?s› ‹e ≤ infdist (flow t0 y t') seg› ‹t0 ≤ t'› ‹t' ≤ t›*) by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) then show "?thesis" (*goal: ‹flow t0 x0 s ∈ A›*) using s (*‹s ∈ {t0..t'}›*) ‹e > 0› (*‹0 < e›*) by (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*)) qed have "flow t0 y t' ∈ A" if "t' = t0" using y (*‹y ∈ ball x0 d›*) d (*‹0 < d› ‹(d::real) ≤ (e::real)› ‹(d::real) ≤ (e::real) * exp (- (K::real) * ((b::real) - (t0::real)))›*) iv_defined (*‹(t0::real) ∈ (T::real set)› ‹x0 ∈ X›*) that (*‹(t'::real) = (t0::real)›*) by (auto simp: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) ‹y ∈ X› infdist_le2[where a=x0] (*‹⟦x0 ∈ ?A; dist ?x x0 ≤ ?d⟧ ⟹ infdist ?x ?A ≤ ?d›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) moreover have "flow t0 y s ∈ A" if s: "s ∈ {t0 ..< t'}" for s proof (-) (*goal: ‹flow (t0::real) (y::'a) (s::real) ∈ (A::'a set)›*) from s (*‹s ∈ {t0..<t'}›*) have "s ∈ closed_segment t0 b" using ‹t ≤ b› (*‹t ≤ b›*) t' (*‹⟦e ≤ infdist (flow t0 y ?s) seg; t0 ≤ ?s; ?s ≤ t⟧ ⟹ t' ≤ ?s› ‹e ≤ infdist (flow t0 y t') seg› ‹t0 ≤ t'› ‹t' ≤ t›*) by (auto simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) from t'(1)[of s] (*‹⟦e ≤ infdist (flow t0 y s) seg; t0 ≤ s; s ≤ t⟧ ⟹ t' ≤ s›*) have "t' > s ⟹ t0 ≤ s ⟹ s ≤ t ⟹ e > infdist (flow t0 y s) seg" by force then show "?thesis" (*goal: ‹flow (t0::real) (y::'a) (s::real) ∈ (A::'a set)›*) using s (*‹s ∈ {t0..<t'}›*) t' (*‹⟦e ≤ infdist (flow t0 y ?s) seg; t0 ≤ ?s; ?s ≤ t⟧ ⟹ t' ≤ ?s› ‹e ≤ infdist (flow t0 y t') seg› ‹t0 ≤ t'› ‹t' ≤ t›*) ‹e > 0› (*‹0 < e›*) by (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*)) qed moreover note left_of_in = this (*‹(?s::real) ∈ {t0::real..<t'::real} ⟹ flow t0 (y::'a::{heine_borel,banach}) ?s ∈ (A::'a::{heine_borel,banach} set)›*) have "closed A" using ‹compact A› (*‹compact (A::'a set)›*) by (auto simp: compact_eq_bounded_closed (*‹compact ?S = (bounded ?S ∧ closed ?S)›*)) have "((λs. flow t0 y s) ⤏ flow t0 y t') (at_left t')" using closed_segment_subset_existence_ivl[OF t ( 2 )] (*‹{t0--t} ⊆ existence_ivl t0 y›*) t' (*‹⟦e ≤ infdist (flow t0 y ?s) seg; t0 ≤ ?s; ?s ≤ t⟧ ⟹ t' ≤ ?s› ‹e ≤ infdist (flow t0 y t') seg› ‹t0 ≤ t'› ‹t' ≤ t›*) ‹y ∈ X› (*‹y ∈ X›*) iv_defined (*‹(t0::real) ∈ (T::real set)› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*) apply (intro flow_tendsto (*‹⟦?t ∈ existence_ivl t0 ?x0.0; (?ts ⤏ ?t) ?F⟧ ⟹ ((λs. flow t0 ?x0.0 (?ts s)) ⤏ flow t0 ?x0.0 ?t) ?F›*)) (*goals: 1. ‹⟦{t0--t} ⊆ existence_ivl t0 y; ⋀s. ⟦e ≤ infdist (flow t0 y s) seg; t0 ≤ s; s ≤ t⟧ ⟹ t' ≤ s; e ≤ infdist (flow t0 y t') seg; t0 ≤ t'; t' ≤ t; y ∈ X; t0 ∈ T; x0 ∈ X⟧ ⟹ t' ∈ existence_ivl t0 y› 2. ‹⟦{t0--t} ⊆ existence_ivl t0 y; ⋀s. ⟦e ≤ infdist (flow t0 y s) seg; t0 ≤ s; s ≤ t⟧ ⟹ t' ≤ s; e ≤ infdist (flow t0 y t') seg; t0 ≤ t'; t' ≤ t; y ∈ X; t0 ∈ T; x0 ∈ X⟧ ⟹ ((λs. s) ⤏ t') (at_left t')› discuss goal 1*) apply ((auto intro!: tendsto_intros (*‹((λx. x) ⤏ ?a) (at ?a within ?s)› ‹((λx. ?k) ⤏ ?k) ?F› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. max (?X x) (?Y x)) ⤏ max ?x ?y) ?net› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. min (?X x) (?Y x)) ⤏ min ?x ?y) ?net› ‹?k ≠ ?L ⟹ ¬ (λx. ?k) ─?a→ ?L› ‹(?f ⤏ ?a) ?F ⟹ ((λx. fst (?f x)) ⤏ fst ?a) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. snd (?f x)) ⤏ snd ?a) ?F› ‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. (?f x, ?g x)) ⤏ (?a, ?b)) ?F› ‹(λn. 1 / of_nat n) ⇢ 0› ‹⟦(?f ⤏ ?l) ?F; (?g ⤏ ?m) ?F⟧ ⟹ ((λx. dist (?f x) (?g x)) ⤏ dist ?l ?m) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. norm (?f x)) ⤏ norm ?a) ?F› ‹(?f ⤏ ?l) ?F ⟹ ((λx. ¦?f x¦) ⤏ ¦?l¦) ?F› and more 109 facts*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 2*) apply ((auto intro!: tendsto_intros (*‹((λx. x) ⤏ ?a) (at ?a within ?s)› ‹((λx. ?k) ⤏ ?k) ?F› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. max (?X x) (?Y x)) ⤏ max ?x ?y) ?net› ‹⟦(?X ⤏ ?x) ?net; (?Y ⤏ ?y) ?net⟧ ⟹ ((λx. min (?X x) (?Y x)) ⤏ min ?x ?y) ?net› ‹?k ≠ ?L ⟹ ¬ (λx. ?k) ─?a→ ?L› ‹(?f ⤏ ?a) ?F ⟹ ((λx. fst (?f x)) ⤏ fst ?a) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. snd (?f x)) ⤏ snd ?a) ?F› ‹⟦(?f ⤏ ?a) ?F; (?g ⤏ ?b) ?F⟧ ⟹ ((λx. (?f x, ?g x)) ⤏ (?a, ?b)) ?F› ‹(λn. 1 / of_nat n) ⇢ 0› ‹⟦(?f ⤏ ?l) ?F; (?g ⤏ ?m) ?F⟧ ⟹ ((λx. dist (?f x) (?g x)) ⤏ dist ?l ?m) ?F› ‹(?f ⤏ ?a) ?F ⟹ ((λx. norm (?f x)) ⤏ norm ?a) ?F› ‹(?f ⤏ ?l) ?F ⟹ ((λx. ¦?f x¦) ⤏ ¦?l¦) ?F› and more 109 facts*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*proven 2 subgoals*) . with ‹closed A› (*‹closed A›*) "_" (*‹PROP ?psi ⟹ PROP ?psi›*) "_" (*‹PROP ?psi::prop ⟹ PROP ?psi›*) have "t' ≠ t0 ⟹ flow t0 y t' ∈ A" proof (rule Lim_in_closed_set (*‹⟦closed ?S; ∀⇩F x in ?F. ?f x ∈ ?S; ?F ≠ bot; (?f ⤏ ?l) ?F⟧ ⟹ ?l ∈ ?S›*)) (*goals: 1. ‹(t'::real) ≠ (t0::real) ⟹ ∀⇩F x::real in at_left t'. flow t0 (y::'a) x ∈ (A::'a set)› 2. ‹(t'::real) ≠ (t0::real) ⟹ at_left t' ≠ bot›*) assume "t' ≠ t0" (*‹(t'::real) ≠ (t0::real)›*) hence "t' > t0" using t' (*‹⟦e ≤ infdist (flow t0 y ?s) seg; t0 ≤ ?s; ?s ≤ t⟧ ⟹ t' ≤ ?s› ‹e ≤ infdist (flow t0 y t') seg› ‹(t0::real) ≤ (t'::real)› ‹(t'::real) ≤ (t::real)›*) by auto hence "eventually (λx. x ≥ t0) (at_left t')" by (metis eventually_at_left (*‹?y < ?x ⟹ eventually ?P (at_left ?x) = (∃b<?x. ∀y>b. y < ?x ⟶ ?P y)›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*)) thus "eventually (λx. flow t0 y x ∈ A) (at_left t')" unfolding eventually_at_filter (*goal: ‹∀⇩F x in nhds t'. x ≠ t' ⟶ x ∈ {..<t'} ⟶ flow t0 y x ∈ A›*) apply eventually_elim (*goal: ‹∀⇩F x in nhds t'. x ≠ t' ⟶ x ∈ {..<t'} ⟶ flow t0 y x ∈ A›*) by (auto intro!: left_of_in (*‹?s ∈ {t0..<t'} ⟹ flow t0 y ?s ∈ A›*)) qed (simp) (*solved the remaining goal: ‹t' ≠ t0 ⟹ at_left t' ≠ bot›*) ultimately have flow_y_in: "s ∈ {t0 .. t'} ⟹ flow t0 y s ∈ A" for s apply (cases "s = t'") (*goals: 1. ‹⟦s ∈ {t0..t'}; t' = t0 ⟹ flow t0 y t' ∈ A; ⋀s. s ∈ {t0..<t'} ⟹ flow t0 y s ∈ A; t' ≠ t0 ⟹ flow t0 y t' ∈ A; s = t'⟧ ⟹ flow t0 y s ∈ A› 2. ‹⟦s ∈ {t0..t'}; t' = t0 ⟹ flow t0 y t' ∈ A; ⋀s. s ∈ {t0..<t'} ⟹ flow t0 y s ∈ A; t' ≠ t0 ⟹ flow t0 y t' ∈ A; s ≠ t'⟧ ⟹ flow t0 y s ∈ A› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . have "t0 ≤ t'" "t' ≤ t" "⋀t. t ∈ {t0 .. t'} ⟹ flow t0 x0 t ∈ A" "infdist (flow t0 y t') seg ≥ e" "⋀t. t ∈ {t0 .. t'} ⟹ flow t0 y t ∈ A" (*goals: 1. ‹t0 ≤ t'› 2. ‹t' ≤ t› 3. ‹⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A› 4. ‹e ≤ infdist (flow t0 y t') seg› 5. ‹⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*discuss goal 3*) apply ((auto intro!: flow_in (*‹?s ∈ {t0..t'} ⟹ flow t0 x0 ?s ∈ A›*) flow_y_in (*‹?s ∈ {t0..t'} ⟹ flow t0 y ?s ∈ A›*))[1]) (*discuss goal 4*) apply fact (*discuss goal 5*) apply ((auto intro!: flow_in (*‹?s ∈ {t0..t'} ⟹ flow t0 x0 ?s ∈ A›*) flow_y_in (*‹?s ∈ {t0..t'} ⟹ flow t0 y ?s ∈ A›*))[1]) (*proven 5 subgoals*) . thus "?thesis" (*goal: ‹thesis›*) apply standard (*goals: 1. ‹⋀t::real. t ∈ {t0::real..t'::real} ⟹ t ∈ {t0..t'}› 2. ‹⋀t::real. t ∈ {t0::real..t'::real} ⟹ t ∈ {t0..t'}› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) qed { fix s assume s: "s ∈ {t0 .. t'}" (*‹(s::real) ∈ {t0::real..t'::real}›*) hence "t0 ≤ s" by simp have "s ≤ b" using t (*‹t0 ≤ t› ‹t ∈ existence_ivl t0 y› ‹t ≤ b›*) t' (*‹t0 ≤ t'› ‹t' ≤ t› ‹?t ∈ {t0..t'} ⟹ flow t0 x0 ?t ∈ A› ‹(e::real) ≤ infdist (flow (t0::real) (y::'a) (t'::real)) (seg::'a set)› ‹?t ∈ {t0..t'} ⟹ flow t0 y ?t ∈ A›*) s (*‹s ∈ {t0..t'}›*) b (*‹b ∈ existence_ivl t0 x0›*) by auto hence sx0: "s ∈ existence_ivl t0 x0" by (simp add: ‹t0 ≤ s› mem_existence_ivlI (*‹⟦t0 ≤ ?s; ?s ≤ b⟧ ⟹ ?s ∈ existence_ivl t0 x0›*)) have sy: "s ∈ existence_ivl t0 y" by (meson atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) contra_subsetD (*‹⟦?A ⊆ ?B; ?c ∉ ?B⟧ ⟹ ?c ∉ ?A›*) s (*‹s ∈ {t0..t'}›*) t'( (*‹t0 ≤ t'›*) 1) t'( (*‹t' ≤ t›*) 2) that( (*‹t ∈ existence_ivl t0 y›*) 2) ivl_subset_existence_ivl (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ {t0..?t} ⊆ existence_ivl t0 ?x0.0›*)) have int: "flow t0 y s - flow t0 x0 s = y - x0 + (integral {t0 .. s} (λt. f t (flow t0 y t)) - integral {t0 .. s} (λt. f t (flow t0 x0 t)))" using iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) s (*‹s ∈ {t0..t'}›*) unfolding flow_fixed_point[OF sx0] flow_fixed_point[OF sy] (*goal: ‹y + ivl_integral t0 s (λt. f t (flow t0 y t)) - (x0 + ivl_integral t0 s (λt. f t (flow t0 x0 t))) = y - x0 + (integral {t0..s} (λt. f t (flow t0 y t)) - integral {t0..s} (λt. f t (flow t0 x0 t)))›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) ivl_integral_def (*‹ivl_integral ?a ?b ?f = integral {?a..?b} ?f - integral {?b..?a} ?f›*)) have "norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + norm (integral {t0 .. s} (λt. f t (flow t0 y t)) - integral {t0 .. s} (λt. f t (flow t0 x0 t)))" unfolding int (*goal: ‹norm (y - x0 + (integral {t0..s} (λt. f t (flow t0 y t)) - integral {t0..s} (λt. f t (flow t0 x0 t)))) ≤ norm (y - x0) + norm (integral {t0..s} (λt. f t (flow t0 y t)) - integral {t0..s} (λt. f t (flow t0 x0 t)))›*) by (rule norm_triangle_ineq (*‹norm (?x + ?y) ≤ norm ?x + norm ?y›*)) also (*calculation: ‹norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + norm (integral {t0..s} (λt. f t (flow t0 y t)) - integral {t0..s} (λt. f t (flow t0 x0 t)))›*) have "norm (integral {t0 .. s} (λt. f t (flow t0 y t)) - integral {t0 .. s} (λt. f t (flow t0 x0 t))) = norm (integral {t0 .. s} (λt. f t (flow t0 y t) - f t (flow t0 x0 t)))" using closed_segment_subset_existence_ivl[of s x0] (*‹s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0›*) sx0 (*‹(s::real) ∈ existence_ivl (t0::real) (x0::'a)›*) closed_segment_subset_existence_ivl[of s y] (*‹(s::real) ∈ existence_ivl (t0::real) (y::'a) ⟹ {t0--s} ⊆ existence_ivl t0 y›*) sy (*‹s ∈ existence_ivl t0 y›*) apply (subst Henstock_Kurzweil_Integration.integral_diff (*‹⟦(?f::?'a ⇒ ?'b) integrable_on (?S::?'a set); (?g::?'a ⇒ ?'b) integrable_on ?S⟧ ⟹ integral ?S (λx::?'a. ?f x - ?g x) = integral ?S ?f - integral ?S ?g›*)) (*goals: 1. ‹⟦s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ (λt. f t (flow t0 y t)) integrable_on {t0..s}› 2. ‹⟦s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ (λt. f t (flow t0 x0 t)) integrable_on {t0..s}› 3. ‹⟦s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ norm (integral {t0..s} (λt. f t (flow t0 y t)) - integral {t0..s} (λt. f t (flow t0 x0 t))) = norm (integral {t0..s} (λt. f t (flow t0 y t)) - integral {t0..s} (λt. f t (flow t0 x0 t)))› discuss goal 1*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 2*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 3*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + norm (integral {t0..s} (λt. f t (flow t0 y t) - f t (flow t0 x0 t)))›*) have "… ≤ (integral {t0 .. s} (λt. norm (f t (flow t0 y t) - f t (flow t0 x0 t))))" using closed_segment_subset_existence_ivl[of s x0] (*‹(s::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ {t0--s} ⊆ existence_ivl t0 x0›*) sx0 (*‹s ∈ existence_ivl t0 x0›*) closed_segment_subset_existence_ivl[of s y] (*‹s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y›*) sy (*‹s ∈ existence_ivl t0 y›*) apply (intro integral_norm_bound_integral (*‹⟦?f integrable_on ?S; ?g integrable_on ?S; ⋀x. x ∈ ?S ⟹ norm (?f x) ≤ ?g x⟧ ⟹ norm (integral ?S ?f) ≤ integral ?S ?g›*)) (*goals: 1. ‹⟦(s::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 (y::'a) ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ (λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow t0 y t) - f t (flow t0 x0 t)) integrable_on {t0..s}› 2. ‹⟦(s::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 (y::'a) ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ (λt::real. norm ((f::real ⇒ 'a ⇒ 'a) t (flow t0 y t) - f t (flow t0 x0 t))) integrable_on {t0..s}› 3. ‹⋀x::real. ⟦(s::real) ∈ existence_ivl (t0::real) (x0::'a) ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 (y::'a) ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y; x ∈ {t0..s}⟧ ⟹ norm ((f::real ⇒ 'a ⇒ 'a) x (flow t0 y x) - f x (flow t0 x0 x)) ≤ norm (f x (flow t0 y x) - f x (flow t0 x0 x))› discuss goal 1*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x::?'a∈?s::?'a set. isCont (?f::?'a ⇒ ?'b) x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹(?t::real) ∈ existence_ivl (t0::real) (?x0.0::'a) ⟹ isCont (λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow t0 ?x0.0 t)) ?t›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 2*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 3*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹(⋀x ya. x ≤ ya ⟹ norm (y - x0) + x ≤ norm (y - x0) + ya) ⟹ norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + integral {t0..s} (λt. norm (f t (flow t0 y t) - f t (flow t0 x0 t)))›*) have "… ≤ (integral {t0 .. s} (λt. K * norm ((flow t0 y t) - (flow t0 x0 t))))" using closed_segment_subset_existence_ivl[of s x0] (*‹s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0›*) sx0 (*‹s ∈ existence_ivl t0 x0›*) closed_segment_subset_existence_ivl[of s y] (*‹s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y›*) sy (*‹s ∈ existence_ivl t0 y›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) s (*‹s ∈ {t0..t'}›*) t'(3,5) (*‹?t ∈ {t0..t'} ⟹ flow t0 x0 ?t ∈ A› ‹?t ∈ {t0..t'} ⟹ flow t0 y ?t ∈ A›*) ‹s ≤ b› (*‹s ≤ b›*) by (auto simp del: Henstock_Kurzweil_Integration.integral_mult_right (*‹integral (?S::?'b set) (λx::?'b. (?c::?'a) * (?f::?'b ⇒ ?'a) x) = ?c * integral ?S ?f›*) intro!: integral_le (*‹⟦(?f::?'n ⇒ real) integrable_on (?S::?'n set); (?g::?'n ⇒ real) integrable_on ?S; ⋀x::?'n. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ integral ?S ?f ≤ integral ?S ?g›*) integrable_continuous_real (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x::?'a∈?s::?'a set. isCont (?f::?'a ⇒ ?'b) x ⟹ continuous_on ?s ?f›*) lipschitz_on_normD[OF K] (*‹⟦(?t1::real) ∈ {t0::real..b::real}; (?x::'a) ∈ (A::'a set); (?y::'a) ∈ A⟧ ⟹ norm ((f::real ⇒ 'a ⇒ 'a) ?t1 ?x - f ?t1 ?y) ≤ (K::real) * norm (?x - ?y)›*) flow_continuous (*‹(?t::real) ∈ existence_ivl (t0::real) (?x0.0::'a) ⟹ isCont (flow t0 ?x0.0) ?t›*) f_flow_continuous (*‹(?t::real) ∈ existence_ivl (t0::real) (?x0.0::'a) ⟹ isCont (λt::real. (f::real ⇒ 'a ⇒ 'a) t (flow t0 ?x0.0 t)) ?t›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) also (*calculation: ‹⟦⋀x ya. x ≤ ya ⟹ norm (y - x0) + x ≤ norm (y - x0) + ya; ⋀x ya. x ≤ ya ⟹ norm (y - x0) + x ≤ norm (y - x0) + ya⟧ ⟹ norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + integral {t0..s} (λt. K * norm (flow t0 y t - flow t0 x0 t))›*) have "… = K * integral {t0 .. s} (λt. norm (flow t0 y t - flow t0 x0 t))" using closed_segment_subset_existence_ivl[of s x0] (*‹s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0›*) sx0 (*‹(s::real) ∈ existence_ivl (t0::real) (x0::'a)›*) closed_segment_subset_existence_ivl[of s y] (*‹s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y›*) sy (*‹s ∈ existence_ivl t0 y›*) apply (subst integral_mult (*‹(?f::?'a ⇒ real) integrable_on (?X::?'a set) ⟹ (?K::real) * integral ?X ?f = integral ?X (λx::?'a. ?K * ?f x)›*)) (*goals: 1. ‹⟦s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ (λt. norm (flow t0 y t - flow t0 x0 t)) integrable_on {t0..s}› 2. ‹⟦s ∈ existence_ivl t0 x0 ⟹ {t0--s} ⊆ existence_ivl t0 x0; s ∈ existence_ivl t0 x0; s ∈ existence_ivl t0 y ⟹ {t0--s} ⊆ existence_ivl t0 y; s ∈ existence_ivl t0 y⟧ ⟹ integral {t0..s} (λt. K * norm (flow t0 y t - flow t0 x0 t)) = integral {t0..s} (λx. K * norm (flow t0 y x - flow t0 x0 x))› discuss goal 1*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) lipschitz_on_normD[OF K] (*‹⟦?t1 ∈ {t0..b}; ?x ∈ A; ?y ∈ A⟧ ⟹ norm (f ?t1 ?x - f ?t1 ?y) ≤ K * norm (?x - ?y)›*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*discuss goal 2*) apply ((auto intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*) lipschitz_on_normD[OF K] (*‹⟦?t1 ∈ {t0..b}; ?x ∈ A; ?y ∈ A⟧ ⟹ norm (f ?t1 ?x - f ?t1 ?y) ≤ K * norm (?x - ?y)›*) flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (flow t0 ?x0.0) ?t›*) f_flow_continuous (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ isCont (λt. f t (flow t0 ?x0.0 t)) ?t›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*))[1]) (*proven 2 subgoals*) . finally (*calculation: ‹⟦⋀x ya. x ≤ ya ⟹ norm (y - x0) + x ≤ norm (y - x0) + ya; ⋀x ya. x ≤ ya ⟹ norm (y - x0) + x ≤ norm (y - x0) + ya⟧ ⟹ norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + K * integral {t0..s} (λt. norm (flow t0 y t - flow t0 x0 t))›*) have norm: "norm (flow t0 y s - flow t0 x0 s) ≤ norm (y - x0) + K * integral {t0 .. s} (λt. norm (flow t0 y t - flow t0 x0 t))" by arith note norm (*‹norm (flow (t0::real) (y::'a) (s::real) - flow t0 (x0::'a) s) ≤ norm (y - x0) + (K::real) * integral {t0..s} (λt::real. norm (flow t0 y t - flow t0 x0 t))›*) ‹s ≤ b› (*‹s ≤ b›*) sx0 (*‹(s::real) ∈ existence_ivl (t0::real) (x0::'a::{heine_borel,banach})›*) sy (*‹(s::real) ∈ existence_ivl (t0::real) (y::'a)›*) } note norm_le = this (*‹?s2 ∈ {t0..t'} ⟹ norm (flow t0 y ?s2 - flow t0 x0 ?s2) ≤ norm (y - x0) + K * integral {t0..?s2} (λt. norm (flow t0 y t - flow t0 x0 t))› ‹?s2 ∈ {t0..t'} ⟹ ?s2 ≤ b› ‹?s2 ∈ {t0..t'} ⟹ ?s2 ∈ existence_ivl t0 x0› ‹?s2 ∈ {t0..t'} ⟹ ?s2 ∈ existence_ivl t0 y›*) from norm_le(2) (*‹?s2 ∈ {t0..t'} ⟹ ?s2 ≤ b›*) t' (*‹(t0::real) ≤ (t'::real)› ‹t' ≤ t› ‹?t ∈ {t0..t'} ⟹ flow t0 x0 ?t ∈ A› ‹e ≤ infdist (flow t0 y t') seg› ‹?t ∈ {t0..t'} ⟹ flow t0 y ?t ∈ A›*) have "t' ∈ closed_segment t0 b" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*)) hence "infdist (flow t0 y t') seg ≤ dist (flow t0 y t') (flow t0 x0 t')" by (auto simp: seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*) infdist_le (*‹?a ∈ ?A ⟹ infdist ?x ?A ≤ dist ?x ?a›*)) also (*calculation: ‹infdist (flow t0 y t') seg ≤ dist (flow t0 y t') (flow t0 x0 t')›*) have "… ≤ norm (flow t0 y t' - flow t0 x0 t')" by (simp add: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) also (*calculation: ‹infdist (flow t0 y t') seg ≤ norm (flow t0 y t' - flow t0 x0 t')›*) have "… ≤ norm (y - x0) * exp (K * ¦t' - t0¦)" unfolding K_def (*goal: ‹norm (flow t0 y t' - flow t0 x0 t') ≤ norm (y - x0) * exp ((K' + 1) * ¦t' - t0¦)›*) apply (rule exponential_initial_condition[OF _ _ _ _ _ K'] (*‹⟦?t ∈ existence_ivl t0 ?y0.0; ?t ∈ existence_ivl t0 ?z0.0; A ⊆ X; ⋀s. s ∈ {t0--?t} ⟹ flow t0 ?y0.0 s ∈ A; ⋀s. s ∈ {t0--?t} ⟹ flow t0 ?z0.0 s ∈ A; ⋀s. s ∈ {t0--?t} ⟹ s ∈ {t0..b}⟧ ⟹ norm (flow t0 ?y0.0 ?t - flow t0 ?z0.0 ?t) ≤ norm (?y0.0 - ?z0.0) * exp ((K' + 1) * ¦?t - t0¦)›*)) (*goal: ‹norm (flow t0 y t' - flow t0 x0 t') ≤ norm (y - x0) * exp ((K' + 1) * ¦t' - t0¦)›*) subgoal for by (metis atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) local.norm_le( (*‹?s2 ∈ {t0..t'} ⟹ ?s2 ∈ existence_ivl t0 y›*) 4) order_refl (*‹?x ≤ ?x›*) t'( (*‹t0 ≤ t'›*) 1)) subgoal for by (metis atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) local.norm_le( (*‹?s2 ∈ {t0..t'} ⟹ ?s2 ∈ existence_ivl t0 x0›*) 3) order_refl (*‹?x ≤ ?x›*) t'( (*‹t0 ≤ t'›*) 1)) subgoal for using e (*‹(0::real) < (e::real)› ‹{x. infdist x seg ≤ e} ⊆ X›*) by (simp add: A_def (*‹A ≡ {x. infdist x seg ≤ e}›*)) subgoal for by (metis closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) t'( (*‹(t0::real) ≤ (t'::real)› ‹(?t::real) ∈ {t0::real..t'::real} ⟹ flow t0 (y::'a) ?t ∈ (A::'a set)›*) 1,5)) subgoal for by (metis closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) t'( (*‹t0 ≤ t'› ‹?t ∈ {t0..t'} ⟹ flow t0 x0 ?t ∈ A›*) 1,3)) subgoal for by (simp add: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) local.norm_le( (*‹?s2 ∈ {t0..t'} ⟹ ?s2 ≤ b›*) 2) t'( (*‹t0 ≤ t'›*) 1)) . also (*calculation: ‹infdist (flow (t0::real) (y::'a) (t'::real)) (seg::'a set) ≤ norm (y - (x0::'a)) * exp ((K::real) * ¦t' - t0¦)›*) have "… < d * exp (K * (t - t0))" using y (*‹y ∈ ball x0 d›*) d (*‹(0::real) < (d::real)› ‹d ≤ e› ‹d ≤ e * exp (- K * (b - t0))›*) t' (*‹t0 ≤ t'› ‹t' ≤ t› ‹?t ∈ {t0..t'} ⟹ flow t0 x0 ?t ∈ A› ‹e ≤ infdist (flow t0 y t') seg› ‹?t ∈ {t0..t'} ⟹ flow t0 y ?t ∈ A›*) t (*‹t0 ≤ t› ‹t ∈ existence_ivl t0 y› ‹(t::real) ≤ (b::real)›*) apply (intro mult_less_le_imp_less (*‹⟦?a < ?b; ?c ≤ ?d; 0 ≤ ?a; 0 < ?c⟧ ⟹ ?a * ?c < ?b * ?d›*)) (*goals: 1. ‹⟦y ∈ ball x0 d; 0 < d; d ≤ e; d ≤ e * exp (- K * (b - t0)); t0 ≤ t'; t' ≤ t; ⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A; e ≤ infdist (flow t0 y t') seg; ⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A; t0 ≤ t; t ∈ existence_ivl t0 y; t ≤ b⟧ ⟹ norm (y - x0) < d› 2. ‹⟦y ∈ ball x0 d; 0 < d; d ≤ e; d ≤ e * exp (- K * (b - t0)); t0 ≤ t'; t' ≤ t; ⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A; e ≤ infdist (flow t0 y t') seg; ⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A; t0 ≤ t; t ∈ existence_ivl t0 y; t ≤ b⟧ ⟹ exp (K * ¦t' - t0¦) ≤ exp (K * (t - t0))› 3. ‹⟦y ∈ ball x0 d; 0 < d; d ≤ e; d ≤ e * exp (- K * (b - t0)); t0 ≤ t'; t' ≤ t; ⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A; e ≤ infdist (flow t0 y t') seg; ⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A; t0 ≤ t; t ∈ existence_ivl t0 y; t ≤ b⟧ ⟹ 0 ≤ norm (y - x0)› 4. ‹⟦y ∈ ball x0 d; 0 < d; d ≤ e; d ≤ e * exp (- K * (b - t0)); t0 ≤ t'; t' ≤ t; ⋀t. t ∈ {t0..t'} ⟹ flow t0 x0 t ∈ A; e ≤ infdist (flow t0 y t') seg; ⋀t. t ∈ {t0..t'} ⟹ flow t0 y t ∈ A; t0 ≤ t; t ∈ existence_ivl t0 y; t ≤ b⟧ ⟹ 0 < exp (K * ¦t' - t0¦)› discuss goal 1*) apply ((auto simp: dist_norm[symmetric] (*‹norm (?x - ?y) = dist ?x ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) ‹0 ≤ K›)[1]) (*discuss goal 2*) apply ((auto simp: dist_norm[symmetric] (*‹norm (?x - ?y) = dist ?x ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) ‹0 ≤ K›)[1]) (*discuss goal 3*) apply ((auto simp: dist_norm[symmetric] (*‹norm (?x - ?y) = dist ?x ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) ‹0 ≤ K›)[1]) (*discuss goal 4*) apply ((auto simp: dist_norm[symmetric] (*‹norm (?x - ?y) = dist ?x ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) ‹0 ≤ K›)[1]) (*proven 4 subgoals*) . also (*calculation: ‹infdist (flow t0 y t') seg < d * exp (K * (t - t0))›*) have "… ≤ e" apply (rule d_times_exp_le (*‹⟦t0 ≤ ?t; ?t ≤ b⟧ ⟹ d * exp (K * (?t - t0)) ≤ e›*)) (*goals: 1. ‹t0 ≤ t› 2. ‹t ≤ b› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . finally (*calculation: ‹infdist (flow t0 y t') seg < e›*) have "infdist (flow t0 y t') seg < e" . with ‹infdist (flow t0 y t') seg ≥ e› (*‹e ≤ infdist (flow t0 y t') seg›*) show False by (auto simp: frontier_def (*‹frontier (?S::?'a set) = closure ?S - interior ?S›*)) qed have "{t0..b} ⊆ existence_ivl t0 y" apply (rule subset_mem_compact_implies_subset_existence_interval[OF _ is_interval_cc ‹{t0..b} ⊆ T› ‹y ∈ X› in_A ‹compact A› ‹A ⊆ X›] (*‹⟦t0 ∈ {t0..b}; ⋀t. ⟦t ∈ {t0..b}; t ∈ existence_ivl t0 y⟧ ⟹ t0 ≤ t; ⋀t. ⟦t ∈ {t0..b}; t ∈ existence_ivl t0 y⟧ ⟹ t ∈ existence_ivl t0 y; ⋀t. ⟦t ∈ {t0..b}; t ∈ existence_ivl t0 y⟧ ⟹ t ≤ b⟧ ⟹ {t0..b} ⊆ existence_ivl t0 y›*)) (*goals: 1. ‹(t0::real) ∈ {t0..b::real}› 2. ‹⋀t::real. ⟦t ∈ {t0::real..b::real}; t ∈ existence_ivl t0 (y::'a::{heine_borel,banach})⟧ ⟹ t0 ≤ t› 3. ‹⋀t::real. ⟦t ∈ {t0::real..b::real}; t ∈ existence_ivl t0 (y::'a::{heine_borel,banach})⟧ ⟹ t ∈ existence_ivl t0 y› 4. ‹⋀t::real. ⟦t ∈ {t0::real..b::real}; t ∈ existence_ivl t0 (y::'a::{heine_borel,banach})⟧ ⟹ t ≤ b› discuss goal 1*) apply ((auto simp: ‹t0 ≤ b›)[1]) (*discuss goal 2*) apply ((auto simp: ‹t0 ≤ b›)[1]) (*discuss goal 3*) apply ((auto simp: ‹t0 ≤ b›)[1]) (*discuss goal 4*) apply ((auto simp: ‹t0 ≤ b›)[1]) (*proven 4 subgoals*) . with ‹t0 ≤ b› (*‹t0 ≤ b›*) have b_in: "b ∈ existence_ivl t0 y" by force { fix t assume t: "t ∈ {t0 .. b}" (*‹(t::real) ∈ {t0::real..b::real}›*) also (*calculation: ‹t ∈ {t0..b}›*) have "{t0 .. b} = {t0 -- b}" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) assms (*‹t0 ≤ b› ‹b ∈ existence_ivl t0 x0›*)) also (*calculation: ‹t ∈ {t0--b}›*) note closed_segment_subset_existence_ivl[OF b_in] (*‹{t0--b} ⊆ existence_ivl t0 y›*) finally (*calculation: ‹t ∈ existence_ivl t0 y›*) have t_in: "t ∈ existence_ivl t0 y" . note t (*‹t ∈ {t0..b}›*) also (*calculation: ‹(t::real) ∈ {t0::real..b::real}›*) note ‹{t0 .. b} = {t0 -- b}› (*‹{t0::real..b::real} = {t0--b}›*) also (*calculation: ‹t ∈ {t0--b}›*) note closed_segment_subset_existence_ivl[OF assms ( 2 )] (*‹{t0--b} ⊆ existence_ivl t0 x0›*) finally (*calculation: ‹t ∈ existence_ivl t0 x0›*) have t_in': "t ∈ existence_ivl t0 x0" . have "norm (flow t0 y t - flow t0 x0 t) ≤ norm (y - x0) * exp (K * ¦t - t0¦)" unfolding K_def (*goal: ‹norm (flow t0 y t - flow t0 x0 t) ≤ norm (y - x0) * exp ((K' + 1) * ¦t - t0¦)›*) using t (*‹t ∈ {t0..b}›*) closed_segment_subset_existence_ivl[OF b_in] (*‹{t0--b} ⊆ existence_ivl t0 y›*) ‹0 < e› (*‹0 < e›*) apply (intro in_A (*‹⟦(t0::real) ≤ (?t::real); ?t ∈ existence_ivl t0 (y::'a); ?t ≤ (b::real)⟧ ⟹ flow t0 y ?t ∈ (A::'a set)›*) exponential_initial_condition[OF t_in t_in' ‹A ⊆ X› _ _ K'] (*‹⟦⋀s::real. s ∈ {t0::real--t::real} ⟹ flow t0 (y::'a) s ∈ (A::'a set); ⋀s::real. s ∈ {t0--t} ⟹ flow t0 (x0::'a) s ∈ A; ⋀s::real. s ∈ {t0--t} ⟹ s ∈ {t0..b::real}⟧ ⟹ norm (flow t0 y t - flow t0 x0 t) ≤ norm (y - x0) * exp (((K'::real) + (1::real)) * ¦t - t0¦)›*)) (*goals: 1. ‹⋀s. ⟦t ∈ {t0..b}; {t0--b} ⊆ existence_ivl t0 y; 0 < e; s ∈ {t0--t}⟧ ⟹ t0 ≤ s› 2. ‹⋀s. ⟦t ∈ {t0..b}; {t0--b} ⊆ existence_ivl t0 y; 0 < e; s ∈ {t0--t}⟧ ⟹ s ∈ existence_ivl t0 y› 3. ‹⋀s. ⟦t ∈ {t0..b}; {t0--b} ⊆ existence_ivl t0 y; 0 < e; s ∈ {t0--t}⟧ ⟹ s ≤ b› 4. ‹⋀s. ⟦t ∈ {t0..b}; {t0--b} ⊆ existence_ivl t0 y; 0 < e; s ∈ {t0--t}⟧ ⟹ flow t0 x0 s ∈ A› 5. ‹⋀s. ⟦t ∈ {t0..b}; {t0--b} ⊆ existence_ivl t0 y; 0 < e; s ∈ {t0--t}⟧ ⟹ s ∈ {t0..b}› discuss goal 1*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*))[1]) (*discuss goal 3*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*))[1]) (*discuss goal 4*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*))[1]) (*discuss goal 5*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) A_def (*‹A ≡ {x. infdist x seg ≤ e}›*) seg_def (*‹seg ≡ flow t0 x0 ` {t0--b}›*))[1]) (*proven 5 subgoals*) . hence "dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)" by (auto simp: dist_norm[symmetric] (*‹norm ((?x::?'a::dist_norm) - (?y::?'a::dist_norm)) = dist ?x ?y›*) dist_commute (*‹dist (?x::?'a::metric_space) (?y::?'a::metric_space) = dist ?y ?x›*)) } note b_in (*‹b ∈ existence_ivl t0 y›*) this (*‹?t2 ∈ {t0..b} ⟹ dist (flow t0 x0 ?t2) (flow t0 y ?t2) ≤ dist x0 y * exp (K * ¦?t2 - t0¦)›*) } from ‹d > 0› (*‹0 < d›*) ‹K > 0› (*‹0 < K›*) ‹ball x0 d ⊆ X› (*‹ball x0 d ⊆ X›*) this (*‹(?y5::'a::{heine_borel,banach}) ∈ ball (x0::'a::{heine_borel,banach}) (d::real) ⟹ (b::real) ∈ existence_ivl (t0::real) ?y5› ‹⟦(?y5::'a) ∈ ball (x0::'a) (d::real); (?t2::real) ∈ {t0::real..b::real}⟧ ⟹ dist (flow t0 x0 ?t2) (flow t0 ?y5 ?t2) ≤ dist x0 ?y5 * exp ((K::real) * ¦?t2 - t0¦)›*) show "?thesis" (*goal: ‹thesis›*) apply standard (*goals: 1. ‹⋀y::'a::{heine_borel,banach}. y ∈ ball (x0::'a::{heine_borel,banach}) (d::real) ⟹ y ∈ ball x0 d› 2. ‹⋀(t::real) y::'a::{heine_borel,banach}. ⟦y ∈ ball (x0::'a::{heine_borel,banach}) (d::real); t ∈ {t0::real..b::real}⟧ ⟹ y ∈ ball x0 d› 3. ‹⋀(t::real) y::'a::{heine_borel,banach}. ⟦y ∈ ball (x0::'a::{heine_borel,banach}) (d::real); t ∈ {t0::real..b::real}⟧ ⟹ t ∈ {t0..b}› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) qed lemma global_left_existence_ivl_explicit: assumes "b ≤ t0" assumes b: "b ∈ existence_ivl t0 x0" assumes iv_defined: "t0 ∈ T" "x0 ∈ X" obtains d K where "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {b .. t0} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" proof (-) (*goal: ‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {b..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) interpret rev: ll_on_open "(preflect t0 ` T)" "(λt. - f (preflect t0 t))" X by standard have t0': "t0 ∈ preflect t0 ` T" "x0 ∈ X" (*goals: 1. ‹t0 ∈ preflect t0 ` T› 2. ‹x0 ∈ X› discuss goal 1*) apply ((auto intro!: iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*discuss goal 2*) apply ((auto intro!: iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*proven 2 subgoals*) . from assms (*‹b ≤ t0› ‹b ∈ existence_ivl t0 x0› ‹t0 ∈ T› ‹x0 ∈ X›*) have "preflect t0 b ≥ t0" "preflect t0 b ∈ rev.existence_ivl t0 x0" apply - (*goals: 1. ‹⟦b ≤ t0; b ∈ existence_ivl t0 x0; t0 ∈ T; x0 ∈ X⟧ ⟹ t0 ≤ preflect t0 b› 2. ‹⟦b ≤ t0; b ∈ existence_ivl t0 x0; t0 ∈ T; x0 ∈ X⟧ ⟹ preflect t0 b ∈ rev.existence_ivl t0 x0› discuss goal 1*) apply ((auto simp: rev_existence_ivl_eq (*‹rev.existence_ivl t0 ?x0.0 = preflect t0 ` existence_ivl t0 ?x0.0›*))[1]) (*discuss goal 2*) apply ((auto simp: rev_existence_ivl_eq (*‹rev.existence_ivl t0 ?x0.0 = preflect t0 ` existence_ivl t0 ?x0.0›*))[1]) (*proven 2 subgoals*) . from rev.global_right_existence_ivl_explicit[OF this] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain d and K where dK: "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {t0 .. preflect t0 b} ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" (*goal: ‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: rev_flow_eq (*‹?t ∈ ll_on_open.existence_ivl (preflect ?t0.0 ` T) (λt. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ⟹ ll_on_open.flow (preflect ?t0.0 ` T) (λt. - f (preflect ?t0.0 t)) X ?t0.0 ?x0.0 ?t = flow ?t0.0 ?x0.0 (preflect ?t0.0 ?t)›*) ‹x0 ∈ X›) have ex_ivlI: "dist x0 y < d ⟹ t ∈ existence_ivl t0 y" if "b ≤ t" "t ≤ t0" for t and y using that (*‹(b::real) ≤ (t::real)› ‹t ≤ t0›*) dK(4)[of y] (*‹y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y›*) dK(3) (*‹ball x0 d ⊆ X›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) by (auto simp: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) rev_existence_ivl_eq[of (*‹rev.existence_ivl t0 ?x0.0 = preflect t0 ` existence_ivl t0 ?x0.0›*) ] closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) in_existence_between_zeroI (*‹⟦?t ∈ existence_ivl t0 ?x0.0; ?s ∈ {t0--?t}⟧ ⟹ ?s ∈ existence_ivl t0 ?x0.0›*)) have "b ∈ existence_ivl t0 y" if "dist x0 y < d" for y using that (*‹dist x0 y < d›*) dK (*‹0 < d› ‹(0::real) < (K::real)› ‹ball x0 d ⊆ X› ‹(?y::'a) ∈ ball (x0::'a) (d::real) ⟹ preflect (t0::real) (b::real) ∈ rev.existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 d; ?t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 ?t) (rev.flow t0 ?y ?t) ≤ dist x0 ?y * exp (K * ¦?t - t0¦)›*) apply (subst existence_ivl_eq_rev (*‹existence_ivl t0 ?x0.0 = preflect t0 ` rev.existence_ivl t0 ?x0.0›*)) (*goal: ‹b ∈ existence_ivl t0 y›*) by (auto simp: iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) intro!: image_eqI[where x="preflect t0 b"] (*‹⟦?b = ?f (preflect t0 b); preflect t0 b ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) with dK (*‹(0::real) < (d::real)› ‹0 < K› ‹ball x0 d ⊆ X› ‹?y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 d; ?t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 ?t) (rev.flow t0 ?y ?t) ≤ dist x0 ?y * exp (K * ¦?t - t0¦)›*) have "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {b .. t0} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" apply - (*goals: 1. ‹⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦); ⋀y. dist x0 y < d ⟹ b ∈ existence_ivl t0 y⟧ ⟹ 0 < d› 2. ‹⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦); ⋀y. dist x0 y < d ⟹ b ∈ existence_ivl t0 y⟧ ⟹ 0 < K› 3. ‹⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦); ⋀y. dist x0 y < d ⟹ b ∈ existence_ivl t0 y⟧ ⟹ ball x0 d ⊆ X› 4. ‹⋀y. ⟦y ∈ ball x0 d; 0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦); ⋀y. dist x0 y < d ⟹ b ∈ existence_ivl t0 y⟧ ⟹ b ∈ existence_ivl t0 y› 5. ‹⋀t y. ⟦y ∈ ball x0 d; t ∈ {b..t0}; 0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ preflect t0 b ∈ rev.existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 d; t ∈ {t0..preflect t0 b}⟧ ⟹ dist (rev.flow t0 x0 t) (rev.flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦); ⋀y. dist x0 y < d ⟹ b ∈ existence_ivl t0 y⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)› discuss goal 1*) apply ((auto simp: flow_eq_rev (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ preflect t0 ?t ∈ rev.existence_ivl t0 ?x0.0› ‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t = rev.flow t0 ?x0.0 (preflect t0 ?t)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) ex_ivlI (*‹⟦b ≤ ?t; ?t ≤ t0; dist x0 ?y < d⟧ ⟹ ?t ∈ existence_ivl t0 ?y›*) ‹x0 ∈ X› subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) intro!: order_trans[OF dK(5)] (*‹⟦?y1 ∈ ball x0 d; ?t1 ∈ {t0..preflect t0 b}; dist x0 ?y1 * exp (K * ¦?t1 - t0¦) ≤ ?z⟧ ⟹ dist (rev.flow t0 x0 ?t1) (rev.flow t0 ?y1 ?t1) ≤ ?z›*) image_eqI[where x="preflect t0 b"] (*‹⟦?b = ?f (preflect t0 b); preflect t0 b ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: flow_eq_rev (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ preflect t0 ?t ∈ rev.existence_ivl t0 ?x0.0› ‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t = rev.flow t0 ?x0.0 (preflect t0 ?t)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) ex_ivlI (*‹⟦b ≤ ?t; ?t ≤ t0; dist x0 ?y < d⟧ ⟹ ?t ∈ existence_ivl t0 ?y›*) ‹x0 ∈ X› subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) intro!: order_trans[OF dK(5)] (*‹⟦?y1 ∈ ball x0 d; ?t1 ∈ {t0..preflect t0 b}; dist x0 ?y1 * exp (K * ¦?t1 - t0¦) ≤ ?z⟧ ⟹ dist (rev.flow t0 x0 ?t1) (rev.flow t0 ?y1 ?t1) ≤ ?z›*) image_eqI[where x="preflect t0 b"] (*‹⟦?b = ?f (preflect t0 b); preflect t0 b ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*discuss goal 3*) apply ((auto simp: flow_eq_rev (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ preflect t0 ?t ∈ rev.existence_ivl t0 ?x0.0› ‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t = rev.flow t0 ?x0.0 (preflect t0 ?t)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) ex_ivlI (*‹⟦b ≤ ?t; ?t ≤ t0; dist x0 ?y < d⟧ ⟹ ?t ∈ existence_ivl t0 ?y›*) ‹x0 ∈ X› subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) intro!: order_trans[OF dK(5)] (*‹⟦?y1 ∈ ball x0 d; ?t1 ∈ {t0..preflect t0 b}; dist x0 ?y1 * exp (K * ¦?t1 - t0¦) ≤ ?z⟧ ⟹ dist (rev.flow t0 x0 ?t1) (rev.flow t0 ?y1 ?t1) ≤ ?z›*) image_eqI[where x="preflect t0 b"] (*‹⟦?b = ?f (preflect t0 b); preflect t0 b ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*discuss goal 4*) apply ((auto simp: flow_eq_rev (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ preflect t0 ?t ∈ rev.existence_ivl t0 ?x0.0› ‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t = rev.flow t0 ?x0.0 (preflect t0 ?t)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) ex_ivlI (*‹⟦b ≤ ?t; ?t ≤ t0; dist x0 ?y < d⟧ ⟹ ?t ∈ existence_ivl t0 ?y›*) ‹x0 ∈ X› subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) intro!: order_trans[OF dK(5)] (*‹⟦?y1 ∈ ball x0 d; ?t1 ∈ {t0..preflect t0 b}; dist x0 ?y1 * exp (K * ¦?t1 - t0¦) ≤ ?z⟧ ⟹ dist (rev.flow t0 x0 ?t1) (rev.flow t0 ?y1 ?t1) ≤ ?z›*) image_eqI[where x="preflect t0 b"] (*‹⟦?b = ?f (preflect t0 b); preflect t0 b ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*discuss goal 5*) apply ((auto simp: flow_eq_rev (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ preflect t0 ?t ∈ rev.existence_ivl t0 ?x0.0› ‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t = rev.flow t0 ?x0.0 (preflect t0 ?t)›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) ex_ivlI (*‹⟦b ≤ ?t; ?t ≤ t0; dist x0 ?y < d⟧ ⟹ ?t ∈ existence_ivl t0 ?y›*) ‹x0 ∈ X› subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) intro!: order_trans[OF dK(5)] (*‹⟦?y1 ∈ ball x0 d; ?t1 ∈ {t0..preflect t0 b}; dist x0 ?y1 * exp (K * ¦?t1 - t0¦) ≤ ?z⟧ ⟹ dist (rev.flow t0 x0 ?t1) (rev.flow t0 ?y1 ?t1) ≤ ?z›*) image_eqI[where x="preflect t0 b"] (*‹⟦?b = ?f (preflect t0 b); preflect t0 b ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*proven 5 subgoals*) . then show "?thesis" (*goal: ‹thesis::bool›*) apply standard (*goals: 1. ‹⋀y. y ∈ ball x0 d ⟹ y ∈ ball x0 d› 2. ‹⋀t y. ⟦y ∈ ball x0 d; t ∈ {b..t0}⟧ ⟹ y ∈ ball x0 d› 3. ‹⋀t y. ⟦y ∈ ball x0 d; t ∈ {b..t0}⟧ ⟹ t ∈ {b..t0}› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) qed lemma global_existence_ivl_explicit: assumes a: "a ∈ existence_ivl t0 x0" assumes b: "b ∈ existence_ivl t0 x0" assumes le: "a ≤ b" obtains d K where "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y" "⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {a .. b} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" proof (-) (*goal: ‹(⋀(d::real) K::real. ⟦(0::real) < d; (0::real) < K; ball (x0::'a::{heine_borel,banach}) d ⊆ (X::'a::{heine_borel,banach} set); ⋀y::'a::{heine_borel,banach}. y ∈ ball x0 d ⟹ (a::real) ∈ existence_ivl (t0::real) y; ⋀y::'a::{heine_borel,banach}. y ∈ ball x0 d ⟹ (b::real) ∈ existence_ivl t0 y; ⋀(t::real) y::'a::{heine_borel,banach}. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis::bool) ⟹ thesis›*) note iv_defined = mem_existence_ivl_iv_defined[OF a] (*‹t0 ∈ T› ‹(x0::'a) ∈ (X::'a set)›*) define r where "r ≡ Max {t0, a, b}" define l where "l ≡ Min {t0, a, b}" have r: "r ≥ t0" "r ∈ existence_ivl t0 x0" using a (*‹a ∈ existence_ivl t0 x0›*) b (*‹b ∈ existence_ivl t0 x0›*) apply - (*goals: 1. ‹⟦a ∈ existence_ivl t0 x0; b ∈ existence_ivl t0 x0⟧ ⟹ t0 ≤ r› 2. ‹⟦a ∈ existence_ivl t0 x0; b ∈ existence_ivl t0 x0⟧ ⟹ r ∈ existence_ivl t0 x0› discuss goal 1*) apply ((auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) r_def (*‹r ≡ Max {t0, a, b}›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*discuss goal 2*) apply ((auto simp: max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) r_def (*‹r ≡ Max {t0, a, b}›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*proven 2 subgoals*) . obtain dr and Kr where right: "0 < dr" "0 < Kr" "ball x0 dr ⊆ X" "⋀y. y ∈ ball x0 dr ⟹ r ∈ existence_ivl t0 y" "⋀y t. y ∈ ball x0 dr ⟹ t ∈ {t0..r} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * ¦t - t0¦)" (*goal: ‹(⋀(dr::real) Kr::real. ⟦(0::real) < dr; (0::real) < Kr; ball (x0::'a) dr ⊆ (X::'a set); ⋀y::'a. y ∈ ball x0 dr ⟹ (r::real) ∈ existence_ivl (t0::real) y; ⋀(y::'a) t::real. ⟦y ∈ ball x0 dr; t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * ¦t - t0¦)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (rule global_right_existence_ivl_explicit[OF r] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ r ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹(⋀(dr::real) Kr::real. ⟦(0::real) < dr; (0::real) < Kr; ball (x0::'a) dr ⊆ (X::'a set); ⋀y::'a. y ∈ ball x0 dr ⟹ (r::real) ∈ existence_ivl (t0::real) y; ⋀(y::'a) t::real. ⟦y ∈ ball x0 dr; t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * ¦t - t0¦)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast have l: "l ≤ t0" "l ∈ existence_ivl t0 x0" using a (*‹a ∈ existence_ivl t0 x0›*) b (*‹(b::real) ∈ existence_ivl (t0::real) (x0::'a)›*) apply - (*goals: 1. ‹⟦a ∈ existence_ivl t0 x0; b ∈ existence_ivl t0 x0⟧ ⟹ l ≤ t0› 2. ‹⟦a ∈ existence_ivl t0 x0; b ∈ existence_ivl t0 x0⟧ ⟹ l ∈ existence_ivl t0 x0› discuss goal 1*) apply ((auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) l_def (*‹l ≡ Min {t0, a, b}›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*discuss goal 2*) apply ((auto simp: min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) l_def (*‹l ≡ Min {t0, a, b}›*) iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*))[1]) (*proven 2 subgoals*) . obtain dl and Kl where left: "0 < dl" "0 < Kl" "ball x0 dl ⊆ X" "⋀y. y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 y" "⋀y t. y ∈ ball x0 dl ⟹ t ∈ {l .. t0} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦)" (*goal: ‹(⋀dl Kl. ⟦0 < dl; 0 < Kl; ball x0 dl ⊆ X; ⋀y. y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dl; t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) apply (rule global_left_existence_ivl_explicit[OF l iv_defined] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ l ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹(⋀dl Kl. ⟦0 < dl; 0 < Kl; ball x0 dl ⊆ X; ⋀y. y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dl; t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) by blast define d where "d ≡ min dr dl" define K where "K ≡ max Kr Kl" note iv_defined (*‹t0 ∈ T› ‹x0 ∈ X›*) have "0 < d" "0 < K" "ball x0 d ⊆ X" using left (*‹(0::real) < (dl::real)› ‹(0::real) < (Kl::real)› ‹ball x0 dl ⊆ X› ‹(?y::'a::{heine_borel,banach}) ∈ ball (x0::'a::{heine_borel,banach}) (dl::real) ⟹ (l::real) ∈ existence_ivl (t0::real) ?y› ‹⟦(?y::'a::{heine_borel,banach}) ∈ ball (x0::'a::{heine_borel,banach}) (dl::real); (?t::real) ∈ {l::real..t0::real}⟧ ⟹ dist (flow t0 x0 ?t) (flow t0 ?y ?t) ≤ dist x0 ?y * exp ((Kl::real) * ¦?t - t0¦)›*) right (*‹0 < dr› ‹0 < Kr› ‹ball x0 dr ⊆ X› ‹?y ∈ ball x0 dr ⟹ r ∈ existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 dr; ?t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 ?t) (flow t0 ?y ?t) ≤ dist x0 ?y * exp (Kr * ¦?t - t0¦)›*) apply - (*goals: 1. ‹⟦0 < dl; 0 < Kl; ball x0 dl ⊆ X; ⋀y. y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dl; t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦); 0 < dr; 0 < Kr; ball x0 dr ⊆ X; ⋀y. y ∈ ball x0 dr ⟹ r ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dr; t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * ¦t - t0¦)⟧ ⟹ 0 < d› 2. ‹⟦0 < dl; 0 < Kl; ball x0 dl ⊆ X; ⋀y. y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dl; t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦); 0 < dr; 0 < Kr; ball x0 dr ⊆ X; ⋀y. y ∈ ball x0 dr ⟹ r ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dr; t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * ¦t - t0¦)⟧ ⟹ 0 < K› 3. ‹⟦0 < dl; 0 < Kl; ball x0 dl ⊆ X; ⋀y. y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dl; t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦); 0 < dr; 0 < Kr; ball x0 dr ⊆ X; ⋀y. y ∈ ball x0 dr ⟹ r ∈ existence_ivl t0 y; ⋀y t. ⟦y ∈ ball x0 dr; t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * ¦t - t0¦)⟧ ⟹ ball x0 d ⊆ X› discuss goal 1*) apply ((auto simp: d_def (*‹d::real ≡ min (dr::real) (dl::real)›*) K_def (*‹K::real ≡ max (Kr::real) (Kl::real)›*))[1]) (*discuss goal 2*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) K_def (*‹K ≡ max Kr Kl›*))[1]) (*discuss goal 3*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) K_def (*‹K ≡ max Kr Kl›*))[1]) (*proven 3 subgoals*) . moreover { fix y assume y: "y ∈ ball x0 d" (*‹(y::'a) ∈ ball (x0::'a) (d::real)›*) hence "y ∈ X" using ‹ball x0 d ⊆ X› (*‹ball x0 d ⊆ X›*) by auto from y (*‹y ∈ ball x0 d›*) closed_segment_subset_existence_ivl[OF left ( 4 ), of y] (*‹y ∈ ball x0 dl ⟹ {t0--l} ⊆ existence_ivl t0 y›*) closed_segment_subset_existence_ivl[OF right ( 4 ), of y] (*‹y ∈ ball x0 dr ⟹ {t0--r} ⊆ existence_ivl t0 y›*) have "a ∈ existence_ivl t0 y" "b ∈ existence_ivl t0 y" apply - (*goals: 1. ‹⟦y ∈ ball x0 d; y ∈ ball x0 dl ⟹ {t0--l} ⊆ existence_ivl t0 y; y ∈ ball x0 dr ⟹ {t0--r} ⊆ existence_ivl t0 y⟧ ⟹ a ∈ existence_ivl t0 y› 2. ‹⟦y ∈ ball x0 d; y ∈ ball x0 dl ⟹ {t0--l} ⊆ existence_ivl t0 y; y ∈ ball x0 dr ⟹ {t0--r} ⊆ existence_ivl t0 y⟧ ⟹ b ∈ existence_ivl t0 y› discuss goal 1*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) l_def (*‹l ≡ Min {t0, a, b}›*) r_def (*‹r ≡ Max {t0, a, b}›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: d_def (*‹d::real ≡ min (dr::real) (dl::real)›*) l_def (*‹l::real ≡ Min {t0::real, a::real, b::real}›*) r_def (*‹r::real ≡ Max {t0::real, a::real, b::real}›*) min_def (*‹min (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max (?a::?'a::ord) (?b::?'a::ord) = (if ?a ≤ ?b then ?b else ?a)›*) closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_split_asm (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . } moreover { fix t and y assume y: "y ∈ ball x0 d" and t: "t ∈ {a .. b}" (*‹(y::'a) ∈ ball (x0::'a) (d::real)› ‹(t::real) ∈ {a::real..b::real}›*) from y (*‹y ∈ ball x0 d›*) have "y ∈ X" using ‹ball x0 d ⊆ X› (*‹ball x0 d ⊆ X›*) by auto have "dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" proof (cases) (*goals: 1. ‹?P::bool ⟹ dist (flow (t0::real) (x0::'a) (t::real)) (flow t0 (y::'a) t) ≤ dist x0 y * exp ((K::real) * ¦t - t0¦)› 2. ‹¬ (?P::bool) ⟹ dist (flow (t0::real) (x0::'a) (t::real)) (flow t0 (y::'a) t) ≤ dist x0 y * exp ((K::real) * ¦t - t0¦)›*) assume "t ≥ t0" (*‹(t0::real) ≤ (t::real)›*) hence "dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kr * abs (t - t0))" using y (*‹y ∈ ball x0 d›*) t (*‹(t::real) ∈ {a::real..b::real}›*) apply (intro right (*‹0 < dr› ‹0 < Kr› ‹ball x0 dr ⊆ X› ‹?y ∈ ball x0 dr ⟹ r ∈ existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 dr; ?t ∈ {t0..r}⟧ ⟹ dist (flow t0 x0 ?t) (flow t0 ?y ?t) ≤ dist x0 ?y * exp (Kr * ¦?t - t0¦)›*)) (*goals: 1. ‹⟦(t0::real) ≤ (t::real); (y::'a) ∈ ball (x0::'a) (d::real); t ∈ {a::real..b::real}⟧ ⟹ y ∈ ball x0 (dr::real)› 2. ‹⟦(t0::real) ≤ (t::real); (y::'a) ∈ ball (x0::'a) (d::real); t ∈ {a::real..b::real}⟧ ⟹ t ∈ {t0..r::real}› discuss goal 1*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) r_def (*‹r ≡ Max {t0, a, b}›*))[1]) (*discuss goal 2*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) r_def (*‹r ≡ Max {t0, a, b}›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹dist (flow (t0::real) (x0::'a) (t::real)) (flow t0 (y::'a) t) ≤ dist x0 y * exp ((Kr::real) * ¦t - t0¦)›*) have "exp (Kr * abs (t - t0)) ≤ exp (K * abs (t - t0))" by (auto simp: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) K_def (*‹K ≡ max Kr Kl›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*)) finally (*calculation: ‹(⋀x ya. x ≤ ya ⟹ dist x0 y * x ≤ dist x0 y * ya) ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)›*) show "?thesis" (*goal: ‹dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)›*) by (simp add: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) next (*goal: ‹¬ (t0::real) ≤ (t::real) ⟹ dist (flow t0 (x0::'a::{heine_borel,banach}) t) (flow t0 (y::'a::{heine_borel,banach}) t) ≤ dist x0 y * exp ((K::real) * ¦t - t0¦)›*) assume "¬t ≥ t0" (*‹¬ (t0::real) ≤ (t::real)›*) hence "dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * abs (t - t0))" using y (*‹y ∈ ball x0 d›*) t (*‹t ∈ {a..b}›*) apply (intro left (*‹0 < dl› ‹0 < Kl› ‹ball x0 dl ⊆ X› ‹?y ∈ ball x0 dl ⟹ l ∈ existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 dl; ?t ∈ {l..t0}⟧ ⟹ dist (flow t0 x0 ?t) (flow t0 ?y ?t) ≤ dist x0 ?y * exp (Kl * ¦?t - t0¦)›*)) (*goals: 1. ‹⟦¬ t0 ≤ t; y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ y ∈ ball x0 dl› 2. ‹⟦¬ t0 ≤ t; y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ t ∈ {l..t0}› discuss goal 1*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) l_def (*‹l ≡ Min {t0, a, b}›*))[1]) (*discuss goal 2*) apply ((auto simp: d_def (*‹d ≡ min dr dl›*) l_def (*‹l ≡ Min {t0, a, b}›*))[1]) (*proven 2 subgoals*) . also (*calculation: ‹dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (Kl * ¦t - t0¦)›*) have "exp (Kl * abs (t - t0)) ≤ exp (K * abs (t - t0))" by (auto simp: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) K_def (*‹K ≡ max Kr Kl›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*)) finally (*calculation: ‹(⋀x ya. x ≤ ya ⟹ dist x0 y * x ≤ dist x0 y * ya) ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)›*) show "?thesis" (*goal: ‹dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)›*) by (simp add: mult_left_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?c * ?a ≤ ?c * ?b›*)) qed } ultimately show "?thesis" (*goal: ‹thesis›*) apply standard (*goals: 1. ‹⋀y. y ∈ ball x0 d ⟹ y ∈ ball x0 d› 2. ‹⋀y. y ∈ ball x0 d ⟹ y ∈ ball x0 d› 3. ‹⋀t y. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ y ∈ ball x0 d› 4. ‹⋀t y. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ t ∈ {a..b}› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) apply ((assumption)[1]) (*discuss goal 4*) . (*proven 4 subgoals*) qed lemma eventually_exponential_separation: assumes a: "a ∈ existence_ivl t0 x0" assumes b: "b ∈ existence_ivl t0 x0" assumes le: "a ≤ b" obtains K where "K > 0" "∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)" proof (-) (*goal: ‹(⋀K::real. ⟦(0::real) < K; ∀⇩F y::'a in at x0. ∀t::real∈{a::real..b::real}. dist (flow (t0::real) (x0::'a) t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis::bool) ⟹ thesis›*) from global_existence_ivl_explicit[OF assms] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y; ⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain d and K where "*": "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y" "⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {a .. b} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" (*goal: ‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y; ⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) by auto note ‹K > 0› (*‹(0::real) < (K::real)›*) moreover have "eventually (λy. y ∈ ball x0 d) (at x0)" using ‹d > 0›[THEN eventually_at_ball] (*‹∀⇩F t in at ?z within ?A. t ∈ ball ?z d ∧ t ∈ ?A›*) apply eventually_elim (*goal: ‹∀⇩F y in at x0. y ∈ ball x0 d›*) by simp hence "eventually (λy. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)) (at x0)" apply eventually_elim (*goal: ‹∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)›*) by (safe intro!: * (*‹0 < d› ‹0 < K› ‹ball x0 d ⊆ X› ‹?y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 ?y› ‹?y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 d; ?t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 ?t) (flow t0 ?y ?t) ≤ dist x0 ?y * exp (K * ¦?t - t0¦)›*)) ultimately show "?thesis" (*goal: ‹thesis›*) by standard qed lemma eventually_mem_existence_ivl: assumes b: "b ∈ existence_ivl t0 x0" shows "∀⇩F x in at x0. b ∈ existence_ivl t0 x" proof (-) (*goal: ‹∀⇩F x in at x0. b ∈ existence_ivl t0 x›*) from mem_existence_ivl_iv_defined[OF b] (*‹t0 ∈ T› ‹x0 ∈ X›*) have iv_defined: "t0 ∈ T" "x0 ∈ X" apply - (*goals: 1. ‹⟦t0 ∈ T; x0 ∈ X⟧ ⟹ t0 ∈ T› 2. ‹⟦t0 ∈ T; x0 ∈ X⟧ ⟹ x0 ∈ X› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . note eiit = existence_ivl_initial_time[OF iv_defined] (*‹t0 ∈ existence_ivl t0 x0›*) { fix a and b assume assms: "a ∈ existence_ivl t0 x0" "b ∈ existence_ivl t0 x0" "a ≤ b" (*‹(a::real) ∈ existence_ivl (t0::real) (x0::'a)› ‹(b::real) ∈ existence_ivl (t0::real) (x0::'a)› ‹(a::real) ≤ (b::real)›*) from global_existence_ivl_explicit[OF assms] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y; ⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain d and K where "*": "d > 0" "K > 0" "ball x0 d ⊆ X" "⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y" "⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y" "⋀t y. y ∈ ball x0 d ⟹ t ∈ {a .. b} ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * abs (t - t0))" (*goal: ‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 y; ⋀y. y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) by auto have "eventually (λy. y ∈ ball x0 d) (at x0)" using ‹d > 0›[THEN eventually_at_ball] (*‹∀⇩F t in at ?z within ?A. t ∈ ball ?z d ∧ t ∈ ?A›*) apply eventually_elim (*goal: ‹∀⇩F y in at x0. y ∈ ball x0 d›*) by simp then have "∀⇩F x in at x0. a ∈ existence_ivl t0 x ∧ b ∈ existence_ivl t0 x" apply eventually_elim (*goal: ‹∀⇩F x::'a in at (x0::'a). (a::real) ∈ existence_ivl (t0::real) x ∧ (b::real) ∈ existence_ivl t0 x›*) by (auto intro!: * (*‹0 < d› ‹0 < K› ‹ball x0 d ⊆ X› ‹?y ∈ ball x0 d ⟹ a ∈ existence_ivl t0 ?y› ‹?y ∈ ball x0 d ⟹ b ∈ existence_ivl t0 ?y› ‹⟦?y ∈ ball x0 d; ?t ∈ {a..b}⟧ ⟹ dist (flow t0 x0 ?t) (flow t0 ?y ?t) ≤ dist x0 ?y * exp (K * ¦?t - t0¦)›*)) } from this[OF b eiit] (*‹b ≤ t0 ⟹ ∀⇩F x in at x0. b ∈ existence_ivl t0 x ∧ t0 ∈ existence_ivl t0 x›*) this[OF eiit b] (*‹(t0::real) ≤ (b::real) ⟹ ∀⇩F x::'a in at (x0::'a). t0 ∈ existence_ivl t0 x ∧ b ∈ existence_ivl t0 x›*) show "?thesis" (*goal: ‹∀⇩F x::'a in at (x0::'a). (b::real) ∈ existence_ivl (t0::real) x›*) apply (cases "t0 ≤ b") (*goals: 1. ‹⟦b ≤ t0 ⟹ ∀⇩F x in at x0. b ∈ existence_ivl t0 x ∧ t0 ∈ existence_ivl t0 x; t0 ≤ b ⟹ ∀⇩F x in at x0. t0 ∈ existence_ivl t0 x ∧ b ∈ existence_ivl t0 x; t0 ≤ b⟧ ⟹ ∀⇩F x in at x0. b ∈ existence_ivl t0 x› 2. ‹⟦b ≤ t0 ⟹ ∀⇩F x in at x0. b ∈ existence_ivl t0 x ∧ t0 ∈ existence_ivl t0 x; t0 ≤ b ⟹ ∀⇩F x in at x0. t0 ∈ existence_ivl t0 x ∧ b ∈ existence_ivl t0 x; ¬ t0 ≤ b⟧ ⟹ ∀⇩F x in at x0. b ∈ existence_ivl t0 x› discuss goal 1*) apply ((auto simp: eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*))[1]) (*discuss goal 2*) apply ((auto simp: eventually_mono (*‹⟦eventually ?P ?F; ⋀x. ?P x ⟹ ?Q x⟧ ⟹ eventually ?Q ?F›*))[1]) (*proven 2 subgoals*) . qed lemma uniform_limit_flow: assumes a: "a ∈ existence_ivl t0 x0" assumes b: "b ∈ existence_ivl t0 x0" assumes le: "a ≤ b" shows "uniform_limit {a .. b} (flow t0) (flow t0 x0) (at x0)" proof (rule uniform_limitI (*‹(⋀e::real. (0::real) < e ⟹ ∀⇩F n::?'a::type in ?F::?'a::type filter. ∀x::?'b::type∈?S::?'b::type set. dist ((?f::?'a::type ⇒ ?'b::type ⇒ ?'c::metric_space) n x) ((?l::?'b::type ⇒ ?'c::metric_space) x) < e) ⟹ uniform_limit ?S ?f ?l ?F›*)) (*goal: ‹⋀e. 0 < e ⟹ ∀⇩F n in at x0. ∀x∈{a..b}. dist (flow t0 n x) (flow t0 x0 x) < e›*) fix e :: real assume "0 < e" (*‹(0::real) < (e::real)›*) from eventually_exponential_separation[OF assms] (*‹(⋀K. ⟦0 < K; ∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain K where "0 < K" "∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)" (*goal: ‹(⋀K. ⟦0 < K; ∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)⟧ ⟹ thesis) ⟹ thesis›*) by auto note this(2) (*‹∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 x0 t) (flow t0 y t) ≤ dist x0 y * exp (K * ¦t - t0¦)›*) moreover let ?m = "max (abs (b - t0)) (abs (a - t0))" have "eventually (λy. ∀t∈{a..b}. dist x0 y * exp (K * ¦t - t0¦) ≤ dist x0 y * exp (K * ?m)) (at x0)" using ‹a ≤ b› (*‹a ≤ b›*) ‹0 < K› (*‹(0::real) < (K::real)›*) by (auto intro!: mult_left_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?c * ?a ≤ ?c * ?b›*) always_eventually (*‹∀x::?'a. (?P::?'a ⇒ bool) x ⟹ eventually ?P (?F::?'a filter)›*)) moreover have "eventually (λy. dist x0 y * exp (K * ?m) < e) (at x0)" using ‹0 < e› (*‹0 < e›*) by (auto intro!: order_tendstoD (*‹⟦((?f::?'b ⇒ ?'a) ⤏ (?y::?'a)) (?F::?'b filter); (?a::?'a) < ?y⟧ ⟹ ∀⇩F x::?'b in ?F. ?a < ?f x› ‹⟦((?f::?'b ⇒ ?'a) ⤏ (?y::?'a)) (?F::?'b filter); ?y < (?a::?'a)⟧ ⟹ ∀⇩F x::?'b in ?F. ?f x < ?a›*) tendsto_eq_intros (*‹(?x::?'a) = (?y::?'a) ⟹ ((λx::?'a. x) ⤏ ?y) (at ?x within (?s1::?'a set))› ‹(?x::?'a) = (?y::?'a) ⟹ ((λx::?'b. ?x) ⤏ ?y) (?F::?'b filter)› ‹⟦((?X1::?'b ⇒ ?'a1) ⤏ (?x1::?'a1)) (?F::?'b filter); ((?Y1::?'b ⇒ ?'a1) ⤏ (?y1::?'a1)) ?F; max ?x1 ?y1 = (?y::?'a1)⟧ ⟹ ((λx::?'b. max (?X1 x) (?Y1 x)) ⤏ ?y) ?F› ‹⟦((?X1::?'b ⇒ ?'a1) ⤏ (?x1::?'a1)) (?F::?'b filter); ((?Y1::?'b ⇒ ?'a1) ⤏ (?y1::?'a1)) ?F; min ?x1 ?y1 = (?y::?'a1)⟧ ⟹ ((λx::?'b. min (?X1 x) (?Y1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b ⇒ ?'a × ?'c1) ⤏ (?a1::?'a × ?'c1)) (?F::?'b filter); fst ?a1 = (?y::?'a)⟧ ⟹ ((λx::?'b. fst (?f1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b ⇒ ?'b1 × ?'a) ⤏ (?a1::?'b1 × ?'a)) (?F::?'b filter); snd ?a1 = (?y::?'a)⟧ ⟹ ((λx::?'b. snd (?f1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b ⇒ ?'b1) ⤏ (?a1::?'b1)) (?F::?'b filter); ((?g1::?'b ⇒ ?'c1) ⤏ (?b1::?'c1)) ?F; (?a1, ?b1) = (?y::?'b1 × ?'c1)⟧ ⟹ ((λx::?'b. (?f1 x, ?g1 x)) ⤏ ?y) ?F› ‹(0::?'a1) = (?y::?'a1) ⟹ (λn::nat. (1::?'a1) / of_nat n) ⇢ ?y› ‹⟦((?f1::?'b ⇒ ?'a1) ⤏ (?l1::?'a1)) (?F::?'b filter); ((?g1::?'b ⇒ ?'a1) ⤏ (?m1::?'a1)) ?F; dist ?l1 ?m1 = (?y::real)⟧ ⟹ ((λx::?'b. dist (?f1 x) (?g1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b ⇒ ?'b1) ⤏ (?a1::?'b1)) (?F::?'b filter); norm ?a1 = (?y::real)⟧ ⟹ ((λx::?'b. norm (?f1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b ⇒ real) ⤏ (?l1::real)) (?F::?'b filter); ¦?l1¦ = (?y::real)⟧ ⟹ ((λx::?'b. ¦?f1 x¦) ⤏ ?y) ?F› ‹⟦((?f1::?'b ⇒ ?'a1) ⤏ (?a1::?'a1)) (?F::?'b filter); ((?g1::?'b ⇒ ?'a1) ⤏ (?b1::?'a1)) ?F; ?a1 + ?b1 = (?y::?'a1)⟧ ⟹ ((λx::?'b. ?f1 x + ?g1 x) ⤏ ?y) ?F› and more 99 facts*)) ultimately show "eventually (λy. ∀t∈{a..b}. dist (flow t0 y t) (flow t0 x0 t) < e) (at x0)" apply eventually_elim (*goal: ‹∀⇩F y in at x0. ∀t∈{a..b}. dist (flow t0 y t) (flow t0 x0 t) < e›*) by (force simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) qed lemma eventually_at_fst: assumes "eventually P (at (fst x))" assumes "P (fst x)" shows "eventually (λh. P (fst h)) (at x)" using assms (*‹eventually P (at (fst x))› ‹P (fst x)›*) unfolding eventually_at_topological (*goal: ‹∃S. open S ∧ x ∈ S ∧ (∀xa∈S. xa ≠ x ⟶ xa ∈ UNIV ⟶ P (fst xa))›*) by (metis open_vimage_fst (*‹open ?S ⟹ open (fst -` ?S)›*) rangeI (*‹?f ?x ∈ range ?f›*) range_fst (*‹surj fst›*) vimageE (*‹⟦?a ∈ ?f -` ?B; ⋀x. ⟦?f ?a = x; x ∈ ?B⟧ ⟹ ?P⟧ ⟹ ?P›*) vimageI (*‹⟦?f ?a = ?b; ?b ∈ ?B⟧ ⟹ ?a ∈ ?f -` ?B›*)) lemma eventually_at_snd: assumes "eventually P (at (snd x))" assumes "P (snd x)" shows "eventually (λh. P (snd h)) (at x)" sorry lemma shows open_state_space: "open (Sigma X (existence_ivl t0))" and flow_continuous_on_state_space: "continuous_on (Sigma X (existence_ivl t0)) (λ(x, t). flow t0 x t)" proof (safe intro!: topological_space_class.openI (*‹(⋀x::?'a. x ∈ (?S::?'a set) ⟹ ∃T::?'a set. open T ∧ x ∈ T ∧ T ⊆ ?S) ⟹ open ?S›*) continuous_at_imp_continuous_on (*‹∀x::?'a∈?s::?'a set. isCont (?f::?'a ⇒ ?'b) x ⟹ continuous_on ?s ?f›*)) (*goals: 1. ‹⋀a b. ⟦a ∈ X; b ∈ existence_ivl t0 a⟧ ⟹ ∃T. open T ∧ (a, b) ∈ T ∧ T ⊆ Sigma X (existence_ivl t0)› 2. ‹⋀a b. ⟦a ∈ X; b ∈ existence_ivl t0 a⟧ ⟹ isCont (λ(x, y). flow t0 x y) (a, b)›*) fix t and x assume "x ∈ X" and t: "t ∈ existence_ivl t0 x" (*‹(x::'a) ∈ (X::'a set)› ‹(t::real) ∈ existence_ivl (t0::real) (x::'a)›*) have iv_defined: "t0 ∈ T" "x ∈ X" using mem_existence_ivl_iv_defined[OF t] (*‹(t0::real) ∈ (T::real set)› ‹x ∈ X›*) apply - (*goals: 1. ‹⟦(t0::real) ∈ (T::real set); (x::'a) ∈ (X::'a set)⟧ ⟹ t0 ∈ T› 2. ‹⟦(t0::real) ∈ (T::real set); (x::'a) ∈ (X::'a set)⟧ ⟹ x ∈ X› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . from ‹x ∈ X› (*‹(x::'a) ∈ (X::'a set)›*) t (*‹t ∈ existence_ivl t0 x›*) open_existence_ivl (*‹open (existence_ivl t0 ?x0.0)›*) obtain e where e: "e > 0" "cball t e ⊆ existence_ivl t0 x" (*goal: ‹(⋀e. ⟦0 < e; cball t e ⊆ existence_ivl t0 x⟧ ⟹ thesis) ⟹ thesis›*) by (metis open_contains_cball (*‹open ?S = (∀x∈?S. ∃e>0. cball x e ⊆ ?S)›*)) hence ivl: "t - e ∈ existence_ivl t0 x" "t + e ∈ existence_ivl t0 x" "t - e ≤ t + e" apply - (*goals: 1. ‹⟦0 < e; cball t e ⊆ existence_ivl t0 x⟧ ⟹ t - e ∈ existence_ivl t0 x› 2. ‹⟦0 < e; cball t e ⊆ existence_ivl t0 x⟧ ⟹ t + e ∈ existence_ivl t0 x› 3. ‹⟦0 < e; cball t e ⊆ existence_ivl t0 x⟧ ⟹ t - e ≤ t + e› discuss goal 1*) apply ((auto simp: cball_def (*‹cball ?x ?e = {y. dist ?x y ≤ ?e}›*) dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*))[1]) (*discuss goal 2*) apply ((auto simp: cball_def (*‹cball ?x ?e = {y. dist ?x y ≤ ?e}›*) dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*))[1]) (*discuss goal 3*) apply ((auto simp: cball_def (*‹cball (?x::?'a::metric_space) (?e::real) = {y::?'a::metric_space. dist ?x y ≤ ?e}›*) dist_real_def (*‹dist (?x::real) (?y::real) = ¦?x - ?y¦›*))[1]) (*proven 3 subgoals*) . obtain d and K where dK: "0 < d" "0 < K" "ball x d ⊆ X" "⋀y. y ∈ ball x d ⟹ t - e ∈ existence_ivl t0 y" "⋀y. y ∈ ball x d ⟹ t + e ∈ existence_ivl t0 y" "⋀y s. y ∈ ball x d ⟹ s ∈ {t - e..t + e} ⟹ dist (flow t0 x s) (flow t0 y s) ≤ dist x y * exp (K * ¦s - t0¦)" (*goal: ‹(⋀(d::real) K::real. ⟦(0::real) < d; (0::real) < K; ball (x::'a) d ⊆ (X::'a set); ⋀y::'a. y ∈ ball x d ⟹ (t::real) - (e::real) ∈ existence_ivl (t0::real) y; ⋀y::'a. y ∈ ball x d ⟹ t + e ∈ existence_ivl t0 y; ⋀(y::'a) s::real. ⟦y ∈ ball x d; s ∈ {t - e..t + e}⟧ ⟹ dist (flow t0 x s) (flow t0 y s) ≤ dist x y * exp (K * ¦s - t0¦)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (rule global_existence_ivl_explicit[OF ivl] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x d ⊆ X; ⋀y. y ∈ ball x d ⟹ t - e ∈ existence_ivl t0 y; ⋀y. y ∈ ball x d ⟹ t + e ∈ existence_ivl t0 y; ⋀ta y. ⟦y ∈ ball x d; ta ∈ {t - e..t + e}⟧ ⟹ dist (flow t0 x ta) (flow t0 y ta) ≤ dist x y * exp (K * ¦ta - t0¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*)) (*goal: ‹(⋀(d::real) K::real. ⟦(0::real) < d; (0::real) < K; ball (x::'a) d ⊆ (X::'a set); ⋀y::'a. y ∈ ball x d ⟹ (t::real) - (e::real) ∈ existence_ivl (t0::real) y; ⋀y::'a. y ∈ ball x d ⟹ t + e ∈ existence_ivl t0 y; ⋀(y::'a) s::real. ⟦y ∈ ball x d; s ∈ {t - e..t + e}⟧ ⟹ dist (flow t0 x s) (flow t0 y s) ≤ dist x y * exp (K * ¦s - t0¦)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast let ?T = "ball x d × ball t e" have "open ?T" by (auto intro!: open_Times (*‹⟦open ?S; open ?T⟧ ⟹ open (?S × ?T)›*)) moreover have "(x, t) ∈ ?T" by (auto simp: dK (*‹(0::real) < (d::real)› ‹(0::real) < (K::real)› ‹ball (x::'a) (d::real) ⊆ (X::'a set)› ‹(?y::'a) ∈ ball (x::'a) (d::real) ⟹ (t::real) - (e::real) ∈ existence_ivl (t0::real) ?y› ‹(?y::'a) ∈ ball (x::'a) (d::real) ⟹ (t::real) + (e::real) ∈ existence_ivl (t0::real) ?y› ‹⟦(?y::'a) ∈ ball (x::'a) (d::real); (?s::real) ∈ {(t::real) - (e::real)..t + e}⟧ ⟹ dist (flow (t0::real) x ?s) (flow t0 ?y ?s) ≤ dist x ?y * exp ((K::real) * ¦?s - t0¦)›*) ‹0 < e›) moreover have "?T ⊆ Sigma X (existence_ivl t0)" proof (safe) (*goals: 1. ‹⋀a b. ⟦a ∈ ball x d; b ∈ ball t e⟧ ⟹ a ∈ X› 2. ‹⋀a b. ⟦a ∈ ball x d; b ∈ ball t e⟧ ⟹ b ∈ existence_ivl t0 a›*) fix s and y assume y: "y ∈ ball x d" and s: "s ∈ ball t e" (*‹(y::'a) ∈ ball (x::'a) (d::real)› ‹(s::real) ∈ ball (t::real) (e::real)›*) with ‹ball x d ⊆ X› (*‹ball x d ⊆ X›*) show "y ∈ X" by auto have "ball t e ⊆ closed_segment t0 (t - e) ∪ closed_segment t0 (t + e)" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*)) with ‹y ∈ X› (*‹y ∈ X›*) s (*‹s ∈ ball t e›*) closed_segment_subset_existence_ivl[OF dK ( 4 ) [ OF y ]] (*‹{t0--t - e} ⊆ existence_ivl t0 y›*) closed_segment_subset_existence_ivl[OF dK ( 5 ) [ OF y ]] (*‹{t0--t + e} ⊆ existence_ivl t0 y›*) show "s ∈ existence_ivl t0 y" by auto qed ultimately show "∃T. open T ∧ (x, t) ∈ T ∧ T ⊆ Sigma X (existence_ivl t0)" by blast have "**": "∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < 2 * eps" if "eps > 0" for eps :: real proof (-) (*goal: ‹∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < 2 * eps›*) have "∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) = norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t))" by auto moreover have "∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t)) ≤ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + norm (flow t0 x (t + snd s) - flow t0 x t)" apply eventually_elim (*goal: ‹∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t)) ≤ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + norm (flow t0 x (t + snd s) - flow t0 x t)›*) by (rule norm_triangle_ineq (*‹norm (?x + ?y) ≤ norm ?x + norm ?y›*)) moreover have "∀⇩F s in at 0. t + snd s ∈ ball t e" by (auto simp: dist_real_def (*‹dist (?x::real) (?y::real) = ¦?x - ?y¦›*) intro!: order_tendstoD[OF _ ‹0 < e›] (*‹((?f::?'b::type ⇒ real) ⤏ (e::real)) (?F::?'b::type filter) ⟹ ∀⇩F x::?'b::type in ?F. (0::real) < ?f x› ‹((?f::?'b::type ⇒ real) ⤏ (0::real)) (?F::?'b::type filter) ⟹ ∀⇩F x::?'b::type in ?F. ?f x < (e::real)›*) intro!: tendsto_eq_intros (*‹(?x::?'a::topological_space) = (?y::?'a::topological_space) ⟹ ((λx::?'a::topological_space. x) ⤏ ?y) (at ?x within (?s1::?'a::topological_space set))› ‹(?x::?'a::topological_space) = (?y::?'a::topological_space) ⟹ ((λx::?'b::type. ?x) ⤏ ?y) (?F::?'b::type filter)› ‹⟦((?X1::?'b::type ⇒ ?'a1::linorder_topology) ⤏ (?x1::?'a1::linorder_topology)) (?F::?'b::type filter); ((?Y1::?'b::type ⇒ ?'a1::linorder_topology) ⤏ (?y1::?'a1::linorder_topology)) ?F; max ?x1 ?y1 = (?y::?'a1::linorder_topology)⟧ ⟹ ((λx::?'b::type. max (?X1 x) (?Y1 x)) ⤏ ?y) ?F› ‹⟦((?X1::?'b::type ⇒ ?'a1::linorder_topology) ⤏ (?x1::?'a1::linorder_topology)) (?F::?'b::type filter); ((?Y1::?'b::type ⇒ ?'a1::linorder_topology) ⤏ (?y1::?'a1::linorder_topology)) ?F; min ?x1 ?y1 = (?y::?'a1::linorder_topology)⟧ ⟹ ((λx::?'b::type. min (?X1 x) (?Y1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b::type ⇒ ?'a::topological_space × ?'c1::topological_space) ⤏ (?a1::?'a::topological_space × ?'c1::topological_space)) (?F::?'b::type filter); fst ?a1 = (?y::?'a::topological_space)⟧ ⟹ ((λx::?'b::type. fst (?f1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b::type ⇒ ?'b1::topological_space × ?'a::topological_space) ⤏ (?a1::?'b1::topological_space × ?'a::topological_space)) (?F::?'b::type filter); snd ?a1 = (?y::?'a::topological_space)⟧ ⟹ ((λx::?'b::type. snd (?f1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b::type ⇒ ?'b1::topological_space) ⤏ (?a1::?'b1::topological_space)) (?F::?'b::type filter); ((?g1::?'b::type ⇒ ?'c1::topological_space) ⤏ (?b1::?'c1::topological_space)) ?F; (?a1, ?b1) = (?y::?'b1::topological_space × ?'c1::topological_space)⟧ ⟹ ((λx::?'b::type. (?f1 x, ?g1 x)) ⤏ ?y) ?F› ‹(0::?'a1::real_normed_field) = (?y::?'a1::real_normed_field) ⟹ (λn::nat. (1::?'a1::real_normed_field) / of_nat n) ⇢ ?y› ‹⟦((?f1::?'b::type ⇒ ?'a1::metric_space) ⤏ (?l1::?'a1::metric_space)) (?F::?'b::type filter); ((?g1::?'b::type ⇒ ?'a1::metric_space) ⤏ (?m1::?'a1::metric_space)) ?F; dist ?l1 ?m1 = (?y::real)⟧ ⟹ ((λx::?'b::type. dist (?f1 x) (?g1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b::type ⇒ ?'b1::real_normed_vector) ⤏ (?a1::?'b1::real_normed_vector)) (?F::?'b::type filter); norm ?a1 = (?y::real)⟧ ⟹ ((λx::?'b::type. norm (?f1 x)) ⤏ ?y) ?F› ‹⟦((?f1::?'b::type ⇒ real) ⤏ (?l1::real)) (?F::?'b::type filter); ¦?l1¦ = (?y::real)⟧ ⟹ ((λx::?'b::type. ¦?f1 x¦) ⤏ ?y) ?F› ‹⟦((?f1::?'b::type ⇒ ?'a1::topological_monoid_add) ⤏ (?a1::?'a1::topological_monoid_add)) (?F::?'b::type filter); ((?g1::?'b::type ⇒ ?'a1::topological_monoid_add) ⤏ (?b1::?'a1::topological_monoid_add)) ?F; ?a1 + ?b1 = (?y::?'a1::topological_monoid_add)⟧ ⟹ ((λx::?'b::type. ?f1 x + ?g1 x) ⤏ ?y) ?F› and more 99 facts*)) moreover from uniform_limit_flow[OF ivl, THEN uniform_limitD, OF ‹eps > 0›] (*‹∀⇩F n::'a::{heine_borel,banach} in at x. ∀xa::real∈{(t::real) - (e::real)..t + e}. dist (flow (t0::real) n xa) (flow t0 (x::'a::{heine_borel,banach}) xa) < (eps::real)›*) have "∀⇩F (h::(_ )) in at (fst (0::'a*real)). ∀t∈{t - e..t + e}. dist (flow t0 x t) (flow t0 (x + h) t) < eps" apply (subst (asm) at_to_0 (*‹at ?a = filtermap (λx. x + ?a) (at 0)›*)) (*goal: ‹∀⇩F h in at (fst 0). ∀t∈{t - e..t + e}. dist (flow t0 x t) (flow t0 (x + h) t) < eps›*) by (auto simp: eventually_filtermap (*‹eventually (?P::?'a::type ⇒ bool) (filtermap (?f::?'b::type ⇒ ?'a::type) (?F::?'b::type filter)) = (∀⇩F x::?'b::type in ?F. ?P (?f x))›*) dist_commute (*‹dist (?x::?'a::metric_space) (?y::?'a::metric_space) = dist ?y ?x›*) ac_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 37 facts*)) hence "∀⇩F (h::(_ * real)) in at 0. ∀t∈{t - e..t + e}. dist (flow t0 x t) (flow t0 (x + fst h) t) < eps" apply (rule eventually_at_fst (*‹⟦eventually ?P (at (fst ?x)); ?P (fst ?x)⟧ ⟹ ∀⇩F h in at ?x. ?P (fst h)›*)) (*goal: ‹∀⇩F h in at 0. ∀t∈{t - e..t + e}. dist (flow t0 x t) (flow t0 (x + fst h) t) < eps›*) by (simp add: ‹eps > 0›) moreover have "∀⇩F h in at (snd (0::'a * _)). norm (flow t0 x (t + h) - flow t0 x t) < eps" using flow_continuous[OF t, unfolded isCont_def, THEN tendstoD, OF ‹eps > 0›] (*‹∀⇩F xa in at t. dist (flow t0 x xa) (flow t0 x t) < eps›*) apply (subst (asm) at_to_0 (*‹at (?a::?'a) = filtermap (λx::?'a. x + ?a) (at (0::?'a))›*)) (*goal: ‹∀⇩F h in at (snd 0). norm (flow t0 x (t + h) - flow t0 x t) < eps›*) by (auto simp: eventually_filtermap (*‹eventually (?P::?'a ⇒ bool) (filtermap (?f::?'b ⇒ ?'a) (?F::?'b filter)) = (∀⇩F x::?'b in ?F. ?P (?f x))›*) dist_norm (*‹dist (?x::?'a) (?y::?'a) = norm (?x - ?y)›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 37 facts*)) hence "∀⇩F h::('a * _) in at 0. norm (flow t0 x (t + snd h) - flow t0 x t) < eps" apply (rule eventually_at_snd (*‹⟦eventually ?P (at (snd ?x)); ?P (snd ?x)⟧ ⟹ ∀⇩F h in at ?x. ?P (snd h)›*)) (*goal: ‹∀⇩F h in at 0. norm (flow t0 x (t + snd h) - flow t0 x t) < eps›*) by (simp add: ‹eps > 0›) ultimately show "?thesis" (*goal: ‹∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < 2 * eps›*) proof (eventually_elim) (*goal: ‹⋀s. ⟦norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) = norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t)); norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t)) ≤ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + norm (flow t0 x (t + snd s) - flow t0 x t); t + snd s ∈ ball t e; ∀t∈{t - e..t + e}. dist (flow t0 x t) (flow t0 (x + fst s) t) < eps; norm (flow t0 x (t + snd s) - flow t0 x t) < eps⟧ ⟹ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < 2 * eps›*) case (elim s) (*‹norm (flow (t0::real) ((x::'a::{heine_borel,banach}) + fst (s::'a::{heine_borel,banach} × real)) ((t::real) + snd s) - flow t0 x t) = norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t))› ‹norm (flow (t0::real) ((x::'a) + fst (s::'a × real)) ((t::real) + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t)) ≤ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + norm (flow t0 x (t + snd s) - flow t0 x t)› ‹t + snd s ∈ ball t e› ‹∀t∈{t - e..t + e}. dist (flow t0 x t) (flow t0 (x + fst s) t) < eps› ‹norm (flow (t0::real) (x::'a::{heine_borel,banach}) ((t::real) + snd (s::'a::{heine_borel,banach} × real)) - flow t0 x t) < (eps::real)›*) note elim(1) (*‹norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) = norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t))›*) also (*calculation: ‹norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) = norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t))›*) note elim(2) (*‹norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s) + (flow t0 x (t + snd s) - flow t0 x t)) ≤ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + norm (flow t0 x (t + snd s) - flow t0 x t)›*) also (*calculation: ‹norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) ≤ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + norm (flow t0 x (t + snd s) - flow t0 x t)›*) note elim(5) (*‹norm (flow t0 x (t + snd s) - flow t0 x t) < eps›*) also (*calculation: ‹(⋀xa y. xa < y ⟹ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + xa < norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + y) ⟹ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + eps›*) from elim(3) (*‹t + snd s ∈ ball t e›*) have "t + snd s ∈ {t - e..t + e}" by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*) algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) from elim(4)[rule_format, OF this] (*‹dist (flow t0 x (t + snd s)) (flow t0 (x + fst s) (t + snd s)) < eps›*) have "norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) < eps" by (auto simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*) dist_norm[symmetric] (*‹norm (?x - ?y) = dist ?x ?y›*)) finally (*calculation: ‹⟦⋀xa y. xa < y ⟹ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + xa < norm (flow t0 (x + fst s) (t + snd s) - flow t0 x (t + snd s)) + y; ⋀x y. x < y ⟹ x + eps < y + eps⟧ ⟹ norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < eps + eps›*) show "?case" (*goal: ‹norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < 2 * eps›*) by simp qed qed have "*": "∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < eps" if "eps > 0" for eps :: real proof (-) (*goal: ‹∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < eps›*) from that (*‹0 < eps›*) have "eps / 2 > 0" by simp from "**"[OF this] (*‹∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < 2 * (eps / 2)›*) show "?thesis" (*goal: ‹∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < eps›*) by auto qed show "isCont (λ(x, y). flow t0 x y) (x, t)" unfolding isCont_iff (*goal: ‹(λh. case (x, t) + h of (x, xa) ⇒ flow t0 x xa) ─0→ (case (x, t) of (x, xa) ⇒ flow t0 x xa)›*) apply (rule LIM_zero_cancel (*‹((λx::?'a. (?f::?'a ⇒ ?'b) x - (?l::?'b)) ⤏ (0::?'b)) (?F::?'a filter) ⟹ (?f ⤏ ?l) ?F›*)) (*goal: ‹(λh::'a × real. case (x::'a, t::real) + h of (x::'a, xa::real) ⇒ flow (t0::real) x xa) ─0::'a × real→ (case (x, t) of (x::'a, xa::real) ⇒ flow t0 x xa)›*) by (auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) norm_conv_dist[symmetric] (*‹dist ?x 0 = norm ?x›*) intro!: tendstoI (*‹(⋀e. 0 < e ⟹ ∀⇩F x in ?F. dist (?f x) ?l < e) ⟹ (?f ⤏ ?l) ?F›*) * (*‹0 < ?eps ⟹ ∀⇩F s in at 0. norm (flow t0 (x + fst s) (t + snd s) - flow t0 x t) < ?eps›*)) qed lemmas flow_continuous_on_compose[continuous_intros] = continuous_on_compose_Pair[OF flow_continuous_on_state_space] lemma flow_isCont_state_space: "t ∈ existence_ivl t0 x0 ⟹ isCont (λ(x, t). flow t0 x t) (x0, t)" using flow_continuous_on_state_space[of] (*‹continuous_on (Sigma X (existence_ivl t0)) (λ(x, t). flow t0 x t)›*) mem_existence_ivl_iv_defined[of t x0] (*‹t ∈ existence_ivl t0 x0 ⟹ t0 ∈ T› ‹t ∈ existence_ivl t0 x0 ⟹ x0 ∈ X›*) using continuous_on_eq_continuous_at (*‹open ?s ⟹ continuous_on ?s ?f = (∀x∈?s. isCont ?f x)›*) open_state_space (*‹open (Sigma X (existence_ivl t0))›*) by fastforce lemma flow_absolutely_integrable_on[integrable_on_simps]: assumes "s ∈ existence_ivl t0 x0" shows "(λx. norm (flow t0 x0 x)) integrable_on closed_segment t0 s" using assms (*‹s ∈ existence_ivl t0 x0›*) by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) intro!: integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*) intro: in_existence_between_zeroI (*‹⟦?t ∈ existence_ivl t0 ?x0.0; ?s ∈ {t0--?t}⟧ ⟹ ?s ∈ existence_ivl t0 ?x0.0›*)) lemma existence_ivl_eq_domain: assumes iv_defined: "t0 ∈ T" "x0 ∈ X" assumes bnd: "⋀tm tM t x. tm ∈ T ⟹ tM ∈ T ⟹ ∃M. ∃L. ∀t ∈ {tm .. tM}. ∀x ∈ X. norm (f t x) ≤ M + L * norm x" assumes "is_interval T" "X = UNIV" shows "existence_ivl t0 x0 = T" proof (-) (*goal: ‹existence_ivl t0 x0 = T›*) from assms (*‹t0 ∈ T› ‹x0 ∈ X› ‹⟦?tm ∈ T; ?tM ∈ T⟧ ⟹ ∃M L. ∀t∈{?tm..?tM}. ∀x∈X. norm (f t x) ≤ M + L * norm x› ‹is_interval (T::real set)› ‹X = UNIV›*) have XI: "x ∈ X" for x by auto { fix tm and tM assume tm: "tm ∈ T" and tM: "tM ∈ T" and tmtM: "tm ≤ t0" "t0 ≤ tM" (*‹(tm::real) ∈ (T::real set)› ‹(tM::real) ∈ (T::real set)› ‹(tm::real) ≤ (t0::real)› ‹(t0::real) ≤ (tM::real)›*) from bnd[OF tm tM] (*‹∃M L. ∀t∈{tm..tM}. ∀x∈X. norm (f t x) ≤ M + L * norm x›*) obtain M' and L' where bnd': "⋀x t. x ∈ X ⟹ tm ≤ t ⟹ t ≤ tM ⟹ norm (f t x) ≤ M' + L' * norm x" (*goal: ‹(⋀M' L'. (⋀x t. ⟦x ∈ X; tm ≤ t; t ≤ tM⟧ ⟹ norm (f t x) ≤ M' + L' * norm x) ⟹ thesis) ⟹ thesis›*) by force define M where "M ≡ norm M' + 1" define L where "L ≡ norm L' + 1" have bnd: "⋀x t. x ∈ X ⟹ tm ≤ t ⟹ t ≤ tM ⟹ norm (f t x) ≤ M + L * norm x" by (auto simp: M_def (*‹M ≡ norm M' + 1›*) L_def (*‹L ≡ norm L' + 1›*) intro!: bnd'[THEN order_trans] (*‹⟦?x1 ∈ X; tm ≤ ?t1; ?t1 ≤ tM; M' + L' * norm ?x1 ≤ ?z⟧ ⟹ norm (f ?t1 ?x1) ≤ ?z›*) add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*)) have "M > 0" "L > 0" (*goals: 1. ‹(0::real) < (M::real)› 2. ‹(0::real) < (L::real)› discuss goal 1*) apply ((auto simp: L_def (*‹L ≡ norm L' + 1›*) M_def (*‹M ≡ norm M' + 1›*))[1]) (*discuss goal 2*) apply ((auto simp: L_def (*‹L ≡ norm L' + 1›*) M_def (*‹M ≡ norm M' + 1›*))[1]) (*proven 2 subgoals*) . let ?r = "(norm x0 + ¦tm - tM¦ * M + 1) * exp (L * ¦tm - tM¦)" define K where "K ≡ cball (0::'a) ?r" have K: "compact K" "K ⊆ X" (*goals: 1. ‹compact K› 2. ‹K ⊆ X› discuss goal 1*) apply ((auto simp: K_def (*‹K ≡ cball 0 ((norm x0 + ¦tm - tM¦ * M + 1) * exp (L * ¦tm - tM¦))›*) ‹X = UNIV›)[1]) (*discuss goal 2*) apply ((auto simp: K_def (*‹K ≡ cball 0 ((norm x0 + ¦tm - tM¦ * M + 1) * exp (L * ¦tm - tM¦))›*) ‹X = UNIV›)[1]) (*proven 2 subgoals*) . { fix t assume t: "t ∈ existence_ivl t0 x0" and le: "tm ≤ t" "t ≤ tM" (*‹(t::real) ∈ existence_ivl (t0::real) (x0::'a)› ‹(tm::real) ≤ (t::real)› ‹(t::real) ≤ (tM::real)›*) { fix s assume sc: "s ∈ closed_segment t0 t" (*‹(s::real) ∈ {t0::real--t::real}›*) then have s: "s ∈ existence_ivl t0 x0" and le: "tm ≤ s" "s ≤ tM" using t (*‹t ∈ existence_ivl t0 x0›*) le (*‹tm ≤ t› ‹t ≤ tM›*) sc (*‹s ∈ {t0--t}›*) using closed_segment_subset_existence_ivl (*‹(?t::real) ∈ existence_ivl (t0::real) (?x0.0::'a) ⟹ {t0--?t} ⊆ existence_ivl t0 ?x0.0›*) apply - (*top goal: ‹s ∈ existence_ivl t0 x0› and 2 goals remain*) subgoal for by force subgoal for by (metis (full_types) atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) tmtM( (*‹tm ≤ t0›*) 1)) subgoal for by (metis (full_types) atLeastAtMost_iff (*‹((?i::?'a) ∈ {?l::?'a..?u::?'a}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) order_trans (*‹⟦(?x::?'a) ≤ (?y::?'a); ?y ≤ (?z::?'a)⟧ ⟹ ?x ≤ ?z›*) tmtM( (*‹(t0::real) ≤ (tM::real)›*) 2)) . from sc (*‹s ∈ {t0--t}›*) have nle: "norm (t0 - s) ≤ norm (t0 - t)" by (auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) from flow_fixed_point[OF s] (*‹flow (t0::real) (x0::'a::{heine_borel,banach}) (s::real) = x0 + ivl_integral t0 s (λt::real. (f::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) t (flow t0 x0 t))›*) have "norm (flow t0 x0 s) ≤ norm x0 + integral (closed_segment t0 s) (λt. M + L * norm (flow t0 x0 t))" using tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) using closed_segment_subset_existence_ivl[OF s] (*‹{t0--s} ⊆ existence_ivl t0 x0›*) le (*‹tm ≤ s› ‹(s::real) ≤ (tM::real)›*) apply (auto simp: intro!: norm_triangle_le (*‹norm ?x + norm ?y ≤ ?e ⟹ norm (?x + ?y) ≤ ?e›*) norm_triangle_ineq4[THEN order.trans] (*‹norm ?a1 + norm ?b1 ≤ ?c ⟹ norm (?a1 - ?b1) ≤ ?c›*) ivl_integral_norm_bound_integral (*‹⟦?f integrable_on {?a--?b}; ?g integrable_on {?a--?b}; ⋀x. x ∈ {?a--?b} ⟹ norm (?f x) ≤ ?g x⟧ ⟹ norm (ivl_integral ?a ?b ?f) ≤ integral {?a--?b} ?g›*) bnd (*‹⟦?x ∈ X; tm ≤ ?t; ?t ≤ tM⟧ ⟹ norm (f ?t ?x) ≤ M + L * norm ?x›*) integrable_continuous_closed_segment (*‹continuous_on {?a--?b} ?f ⟹ ?f integrable_on {?a--?b}›*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) continuous_on_subset[OF flow_continuous_on] (*‹?t ⊆ existence_ivl t0 ?x0.1 ⟹ continuous_on ?t (flow t0 ?x0.1)›*) flow_in_domain (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ flow t0 ?x0.0 ?t ∈ X›*) mem_existence_ivl_subset (*‹?t ∈ existence_ivl t0 ?x0.0 ⟹ ?t ∈ T›*)) (*goals: 1. ‹⋀xa. ⟦flow t0 x0 s = x0 + ivl_integral t0 s (λt. f t (flow t0 x0 t)); tm ≤ t0; t0 ≤ tM; {t0--s} ⊆ existence_ivl t0 x0; tm ≤ s; s ≤ tM; xa ∈ {t0--s}⟧ ⟹ xa ∈ existence_ivl t0 (?x0.16 xa)› 2. ‹⋀xa. ⟦flow t0 x0 s = x0 + ivl_integral t0 s (λt. f t (flow t0 x0 t)); tm ≤ t0; t0 ≤ tM; {t0--s} ⊆ existence_ivl t0 x0; tm ≤ s; s ≤ tM; xa ∈ {t0--s}⟧ ⟹ xa ∈ existence_ivl t0 x0› 3. ‹⋀x. ⟦flow t0 x0 s = x0 + ivl_integral t0 s (λt. f t (flow t0 x0 t)); tm ≤ t0; t0 ≤ tM; {t0--s} ⊆ existence_ivl t0 x0; tm ≤ s; s ≤ tM; x ∈ {t0--s}⟧ ⟹ x ∈ existence_ivl t0 x0› 4. ‹⋀x. ⟦flow t0 x0 s = x0 + ivl_integral t0 s (λt. f t (flow t0 x0 t)); tm ≤ t0; t0 ≤ tM; {t0--s} ⊆ existence_ivl t0 x0; tm ≤ s; s ≤ tM; x ∈ {t0--s}⟧ ⟹ tm ≤ x› 5. ‹⋀x. ⟦flow t0 x0 s = x0 + ivl_integral t0 s (λt. f t (flow t0 x0 t)); tm ≤ t0; t0 ≤ tM; {t0--s} ⊆ existence_ivl t0 x0; tm ≤ s; s ≤ tM; x ∈ {t0--s}⟧ ⟹ x ≤ tM› discuss goal 1*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 3*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a::real--?b::real} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 4*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 5*) apply ((auto simp: closed_segment_eq_real_ivl (*‹{?a--?b} = (if ?a ≤ ?b then {?a..?b} else {?b..?a})›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 5 subgoals*) . also (*calculation: ‹norm (flow t0 x0 s) ≤ norm x0 + integral {t0--s} (λt. M + L * norm (flow t0 x0 t))›*) have "… = norm x0 + norm (t0 - s) * M + L * integral (closed_segment t0 s) (λt. norm (flow t0 x0 t))" by (simp add: integral_add (*‹⟦(?f::?'a ⇒ ?'b) integrable_on (?S::?'a set); (?g::?'a ⇒ ?'b) integrable_on ?S⟧ ⟹ integral ?S (λx::?'a. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) integrable_on_simps (*‹(?f::?'a ⇒ ?'b) integrable_on {}› ‹(?f::?'a ⇒ ?'b) integrable_on cbox (?a::?'a) ?a› ‹(?g::?'b ⇒ ?'a) integrable_on {?b::?'b..?b}› ‹(?h::?'c ⇒ ?'d) integrable_on {?a::?'c--?a}› ‹(λx::?'a. ?c::?'b) integrable_on cbox (?a::?'a) (?b::?'a)› ‹(λx::?'a. ?c::?'b) integrable_on {?a::?'a..?b::?'a}› ‹(λx::real. ?c::?'a) integrable_on {?a::real--?b::real}› ‹(λx::real. x) integrable_on {?a::real..?b::real}› ‹(λx::real. x) integrable_on {?a::real--?b::real}› ‹(λx::real. x) integrable_on cbox (?a::real) (?b::real)› ‹(λx::?'a. 0::?'b) integrable_on (?S::?'a set)› ‹(?f::?'a ⇒ ?'b) integrable_on (?S::?'a set) ⟹ (λx::?'a. - ?f x) integrable_on ?S› and more 12 facts*) ‹s ∈ existence_ivl _ _› integral_const_closed_segment (*‹integral {?a::real--?b::real} (λx::real. ?c::?'a) = ¦?b - ?a¦ *⇩R ?c›*) abs_minus_commute (*‹¦(?a::?'a) - (?b::?'a)¦ = ¦?b - ?a¦›*)) also (*calculation: ‹norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - s) * M + L * integral {t0--s} (λt. norm (flow t0 x0 t))›*) have "norm (t0 - s) * M ≤ norm (t0 - t) * M " using nle (*‹norm ((t0::real) - (s::real)) ≤ norm (t0 - (t::real))›*) ‹M > 0› (*‹0 < M›*) by auto also (*calculation: ‹(⋀x y. x ≤ y ⟹ norm x0 + x + L * integral {t0--s} (λt. norm (flow t0 x0 t)) ≤ norm x0 + y + L * integral {t0--s} (λt. norm (flow t0 x0 t))) ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + L * integral {t0--s} (λt. norm (flow t0 x0 t))›*) have "… ≤ … + 1" by simp finally (*calculation: ‹⟦⋀x y. x ≤ y ⟹ norm x0 + x + L * integral {t0--s} (λt. norm (flow t0 x0 t)) ≤ norm x0 + y + L * integral {t0--s} (λt. norm (flow t0 x0 t)); ⋀x y. x ≤ y ⟹ norm x0 + x + L * integral {t0--s} (λt. norm (flow t0 x0 t)) ≤ norm x0 + y + L * integral {t0--s} (λt. norm (flow t0 x0 t))⟧ ⟹ norm (flow t0 x0 s) ≤ norm x0 + (norm (t0 - t) * M + 1) + L * integral {t0--s} (λt. norm (flow t0 x0 t))›*) have "norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral (closed_segment t0 s) (λt. norm (flow t0 x0 t))" by simp } then have "norm (flow t0 x0 t) ≤ (norm x0 + norm (t0 - t) * M + 1) * exp (L * ¦t - t0¦)" using closed_segment_subset_existence_ivl[OF t] (*‹{t0--t} ⊆ existence_ivl t0 x0›*) apply (intro gronwall_more_general_segment[where a=t0 and b = t and t = t] (*‹⟦⋀ta. ta ∈ {t0--t} ⟹ ?g ta ≤ ?C + ?K * integral {?c--ta} ?g; continuous_on {t0--t} ?g; ⋀ta. ta ∈ {t0--t} ⟹ 0 ≤ ?g ta; 0 < ?C; 0 < ?K; t ∈ {t0--t}; ?c ∈ {t0--t}⟧ ⟹ ?g t ≤ ?C * exp (?K * ¦t - ?c¦)›*)) (*goals: 1. ‹⋀ta. ⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0; ta ∈ {t0--t}⟧ ⟹ norm (flow t0 x0 ta) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--ta} (λa. norm (flow t0 x0 a))› 2. ‹⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0⟧ ⟹ continuous_on {t0--t} (λa. norm (flow t0 x0 a))› 3. ‹⋀ta. ⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0; ta ∈ {t0--t}⟧ ⟹ 0 ≤ norm (flow t0 x0 ta)› 4. ‹⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0⟧ ⟹ 0 < norm x0 + norm (t0 - t) * M + 1› 5. ‹⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0⟧ ⟹ 0 < L› 6. ‹⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0⟧ ⟹ t ∈ {t0--t}› 7. ‹⟦⋀s. s ∈ {t0--t} ⟹ norm (flow t0 x0 s) ≤ norm x0 + norm (t0 - t) * M + 1 + L * integral {t0--s} (λt. norm (flow t0 x0 t)); {t0--t} ⊆ existence_ivl t0 x0⟧ ⟹ t0 ∈ {t0--t}› discuss goal 1*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*))[1]) (*discuss goal 2*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*))[1]) (*discuss goal 3*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*))[1]) (*discuss goal 4*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*))[1]) (*discuss goal 5*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹(?x::?'a) < (?y::?'a) ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦(0::?'a) ≤ (?a::?'a); (0::?'a) < (?b::?'a)⟧ ⟹ (0::?'a) < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦(0::?'a) ≤ (?a::?'a); (0::?'a) ≤ (?b::?'a)⟧ ⟹ (0::?'a) ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦(0::?'a) ≤ (?a::?'a); (0::?'a) ≤ (?b::?'a)⟧ ⟹ (0::?'a) ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on (?s::?'b set) (?g::?'b ⇒ real); ⋀xa::?'b. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl (t0::real) (?x0.0::'a)⟧ ⟹ continuous_on ?s (λxa::?'b. flow t0 ?x0.0 (?g xa))›*))[1]) (*discuss goal 6*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*))[1]) (*discuss goal 7*) apply ((auto simp: ‹0 < L› ‹0 < M› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) intro!: add_nonneg_pos (*‹⟦0 ≤ ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) mult_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a * ?b›*) add_nonneg_nonneg (*‹⟦0 ≤ ?a; 0 ≤ ?b⟧ ⟹ 0 ≤ ?a + ?b›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 276 facts*) flow_continuous_on_intro (*‹⟦continuous_on ?s ?g; ⋀xa. xa ∈ ?s ⟹ ?g xa ∈ existence_ivl t0 ?x0.0⟧ ⟹ continuous_on ?s (λxa. flow t0 ?x0.0 (?g xa))›*))[1]) (*proven 7 subgoals*) . also (*calculation: ‹norm (flow t0 x0 t) ≤ (norm x0 + norm (t0 - t) * M + 1) * exp (L * ¦t - t0¦)›*) have "… ≤ ?r" using le (*‹(tm::real) ≤ (t::real)› ‹(t::real) ≤ (tM::real)›*) tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) by (auto simp: less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) ‹0 < M› ‹0 < L› abs_minus_commute (*‹¦?a - ?b¦ = ¦?b - ?a¦›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*)) finally (*calculation: ‹norm (flow t0 x0 t) ≤ (norm x0 + ¦tm - tM¦ * M + 1) * exp (L * ¦tm - tM¦)›*) have "flow t0 x0 t ∈ K" by (simp add: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*) K_def (*‹K ≡ cball 0 ((norm x0 + ¦tm - tM¦ * M + 1) * exp (L * ¦tm - tM¦))›*)) } note flow_compact = this (*‹⟦?t2 ∈ existence_ivl t0 x0; tm ≤ ?t2; ?t2 ≤ tM⟧ ⟹ flow t0 x0 ?t2 ∈ K›*) have "{tm..tM} ⊆ existence_ivl t0 x0" using tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) tm (*‹tm ∈ T›*) ‹x0 ∈ X› (*‹x0 ∈ X›*) ‹compact K› (*‹compact K›*) ‹K ⊆ X› (*‹(K::'a set) ⊆ (X::'a set)›*) mem_is_intervalI[OF ‹is_interval T› ‹tm ∈ T› ‹tM ∈ T›] (*‹(⋀i. i ∈ Basis ⟹ tm ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ ?x ∙ i ∧ ?x ∙ i ≤ tm ∙ i) ⟹ ?x ∈ T›*) apply (intro subset_mem_compact_implies_subset_existence_interval[OF _ _ _ _flow_compact] (*‹⟦(t0::real) ∈ (?T'::real set); is_interval ?T'; ?T' ⊆ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); ⋀t::real. ⟦t ∈ ?T'; t ∈ existence_ivl t0 x0⟧ ⟹ t ∈ existence_ivl t0 x0; ⋀t::real. ⟦t ∈ ?T'; t ∈ existence_ivl t0 x0⟧ ⟹ (tm::real) ≤ t; ⋀t::real. ⟦t ∈ ?T'; t ∈ existence_ivl t0 x0⟧ ⟹ t ≤ (tM::real); compact (K::'a::{heine_borel,banach} set); K ⊆ X⟧ ⟹ ?T' ⊆ existence_ivl t0 x0›*)) (*goals: 1. ‹⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T⟧ ⟹ t0 ∈ {tm..tM}› 2. ‹⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T⟧ ⟹ is_interval {tm..tM}› 3. ‹⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T⟧ ⟹ {tm..tM} ⊆ T› 4. ‹⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T⟧ ⟹ x0 ∈ X› 5. ‹⋀t::real. ⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T; t ∈ {tm..tM}; t ∈ existence_ivl t0 x0⟧ ⟹ t ∈ existence_ivl t0 x0› 6. ‹⋀t::real. ⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T; t ∈ {tm..tM}; t ∈ existence_ivl t0 x0⟧ ⟹ tm ≤ t› 7. ‹⋀t::real. ⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T; t ∈ {tm..tM}; t ∈ existence_ivl t0 x0⟧ ⟹ t ≤ tM› 8. ‹⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T⟧ ⟹ compact K› 9. ‹⟦(tm::real) ≤ (t0::real); t0 ≤ (tM::real); tm ∈ (T::real set); (x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set); compact (K::'a::{heine_borel,banach} set); K ⊆ X; ⋀x::real. (⋀i::real. i ∈ Basis ⟹ tm ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tM ∙ i ∨ tM ∙ i ≤ x ∙ i ∧ x ∙ i ≤ tm ∙ i) ⟹ x ∈ T⟧ ⟹ K ⊆ X› discuss goal 1*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 2*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 3*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 4*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 5*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 6*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 7*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 8*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*discuss goal 9*) apply ((auto simp: tmtM (*‹tm ≤ t0› ‹t0 ≤ tM›*) is_interval_cc (*‹is_interval {?b..?a}›*))[1]) (*proven 9 subgoals*) . } note bnds = this (*‹⟦?tm2 ∈ T; ?tM2 ∈ T; ?tm2 ≤ t0; t0 ≤ ?tM2⟧ ⟹ {?tm2..?tM2} ⊆ existence_ivl t0 x0›*) show "existence_ivl t0 x0 = T" proof (safe) (*goals: 1. ‹⋀x::real. x ∈ existence_ivl (t0::real) (x0::'a) ⟹ x ∈ (T::real set)› 2. ‹⋀x::real. x ∈ (T::real set) ⟹ x ∈ existence_ivl (t0::real) (x0::'a)›*) fix x assume x: "x ∈ T" (*‹(x::real) ∈ (T::real set)›*) from bnds[OF x iv_defined ( 1 )] (*‹⟦x ≤ t0; t0 ≤ t0⟧ ⟹ {x..t0} ⊆ existence_ivl t0 x0›*) bnds[OF iv_defined ( 1 ) x] (*‹⟦t0 ≤ t0; t0 ≤ x⟧ ⟹ {t0..x} ⊆ existence_ivl t0 x0›*) show "x ∈ existence_ivl t0 x0" apply (cases "x ≤ t0") (*goals: 1. ‹⟦⟦(x::real) ≤ (t0::real); t0 ≤ t0⟧ ⟹ {x..t0} ⊆ existence_ivl t0 (x0::'a); ⟦t0 ≤ t0; t0 ≤ x⟧ ⟹ {t0..x} ⊆ existence_ivl t0 x0; x ≤ t0⟧ ⟹ x ∈ existence_ivl t0 x0› 2. ‹⟦⟦(x::real) ≤ (t0::real); t0 ≤ t0⟧ ⟹ {x..t0} ⊆ existence_ivl t0 (x0::'a); ⟦t0 ≤ t0; t0 ≤ x⟧ ⟹ {t0..x} ⊆ existence_ivl t0 x0; ¬ x ≤ t0⟧ ⟹ x ∈ existence_ivl t0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (insert existence_ivl_subset (*‹existence_ivl (t0::real) (?x0.0::'a) ⊆ (T::real set)›*), fastforce) (*solved the remaining goal: ‹⋀x. x ∈ existence_ivl t0 x0 ⟹ x ∈ T›*) qed lemma flow_unique: assumes "t ∈ existence_ivl t0 x0" assumes "phi t0 = x0" assumes "⋀t. t ∈ existence_ivl t0 x0 ⟹ (phi has_vector_derivative f t (phi t)) (at t)" assumes "⋀t. t ∈ existence_ivl t0 x0 ⟹ phi t ∈ X" shows "flow t0 x0 t = phi t" apply (rule maximal_existence_flow[where K="existence_ivl t0 x0"] (*‹⟦(?x solves_ode f) (existence_ivl t0 x0) X; ?x t0 = ?x0.0; is_interval (existence_ivl t0 x0); t0 ∈ existence_ivl t0 x0; existence_ivl t0 x0 ⊆ T⟧ ⟹ existence_ivl t0 x0 ⊆ existence_ivl t0 ?x0.0› ‹⟦(?x solves_ode f) (existence_ivl t0 x0) X; ?x t0 = ?x0.0; is_interval (existence_ivl t0 x0); t0 ∈ existence_ivl t0 x0; existence_ivl t0 x0 ⊆ T; ?t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 ?x0.0 ?t = ?x ?t›*)) (*goal: ‹flow t0 x0 t = phi t›*) subgoal for by (auto intro!: solves_odeI (*‹⟦(?y has_vderiv_on (λt. ?f t (?y t))) ?T; ⋀t. t ∈ ?T ⟹ ?y t ∈ ?X⟧ ⟹ (?y solves_ode ?f) ?T ?X›*) simp: has_vderiv_on_def (*‹(?f has_vderiv_on ?f') ?S = (∀x∈?S. (?f has_vector_derivative ?f' x) (at x within ?S))›*) assms (*‹t ∈ existence_ivl t0 x0› ‹phi t0 = x0› ‹?t ∈ existence_ivl t0 x0 ⟹ (phi has_vector_derivative f ?t (phi ?t)) (at ?t)› ‹?t ∈ existence_ivl t0 x0 ⟹ phi ?t ∈ X›*) at_within_open[OF _ open_existence_ivl] (*‹?a ∈ existence_ivl t0 ?x0.1 ⟹ at ?a within existence_ivl t0 ?x0.1 = at ?a›*)) subgoal for by fact subgoal for by simp subgoal for using mem_existence_ivl_iv_defined[OF ‹t ∈ existence_ivl t0 x0›] (*‹t0 ∈ T› ‹x0 ∈ X›*) by simp subgoal for by (simp add: existence_ivl_subset (*‹existence_ivl t0 ?x0.0 ⊆ T›*)) subgoal for by fact . lemma flow_unique_on: assumes "t ∈ existence_ivl t0 x0" assumes "phi t0 = x0" assumes "(phi has_vderiv_on (λt. f t (phi t))) (existence_ivl t0 x0)" assumes "⋀t. t ∈ existence_ivl t0 x0 ⟹ phi t ∈ X" shows "flow t0 x0 t = phi t" using flow_unique[where phi = phi, OF assms ( 1 , 2 ) _ assms ( 4 )] (*‹⟦⋀t. t ∈ existence_ivl t0 x0 ⟹ (phi has_vector_derivative f t (phi t)) (at t); ⋀t. t ∈ existence_ivl t0 x0 ⟹ t ∈ existence_ivl t0 x0⟧ ⟹ flow t0 x0 t = phi t›*) assms(3) (*‹(phi has_vderiv_on (λt. f t (phi t))) (existence_ivl t0 x0)›*) by (auto simp: has_vderiv_on_open (*‹open (?T::real set) ⟹ ((?f::real ⇒ ?'a) has_vderiv_on (?f'::real ⇒ ?'a)) ?T = (∀t::real∈?T. (?f has_vector_derivative ?f' t) (at t))›*)) end ― ‹@{thm local_lipschitz}› locale two_ll_on_open = F: ll_on_open T1 F X + G: ll_on_open T2 G X for F T1 G T2 X J x0 + fixes e::real and K assumes t0_in_J: "0 ∈ J" assumes J_subset: "J ⊆ F.existence_ivl 0 x0" assumes J_ivl: "is_interval J" assumes F_lipschitz: "⋀t. t ∈ J ⟹ K-lipschitz_on X (F t)" assumes K_pos: "0 < K" assumes F_G_norm_ineq: "⋀t x. t ∈ J ⟹ x ∈ X ⟹ norm (F t x - G t x) < e" begin context begin lemma F_iv_defined: "0 ∈ T1" "x0 ∈ X" subgoal for using F.existence_ivl_initial_time_iff (*‹(?t0.0 ∈ F.existence_ivl ?t0.0 ?x0.0) = (?t0.0 ∈ T1 ∧ ?x0.0 ∈ X)›*) J_subset (*‹J ⊆ F.existence_ivl 0 x0›*) t0_in_J (*‹0 ∈ J›*) by blast subgoal for using F.mem_existence_ivl_iv_defined(2) (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ ?x0.0 ∈ X›*) J_subset (*‹J ⊆ F.existence_ivl 0 x0›*) t0_in_J (*‹0 ∈ J›*) by blast . lemma e_pos: "0 < e" using le_less_trans[OF norm_ge_zero F_G_norm_ineq [ OF t0_in_J F_iv_defined ( 2 ) ]] (*‹0 < e›*) by assumption qualified definition "flow0 t = F.flow 0 x0 t" qualified definition "Y t = G.flow 0 x0 t" lemma norm_X_Y_bound: shows "∀t ∈ J ∩ G.existence_ivl 0 x0. norm (flow0 t - Y t) ≤ e / K * (exp(K * ¦t¦) - 1)" proof (safe) (*goal: ‹⋀t. ⟦t ∈ J; t ∈ G.existence_ivl 0 x0⟧ ⟹ norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)›*) fix t assume "t ∈ J" (*‹(t::real) ∈ (J::real set)›*) assume tG: "t ∈ G.existence_ivl 0 x0" (*‹(t::real) ∈ G.existence_ivl (0::real) (x0::'a)›*) have "0 ∈ J" by (simp add: t0_in_J (*‹0 ∈ J›*)) let ?u = "λt. norm (flow0 t - Y t)" show "norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)" proof (cases "0 ≤ t") (*goals: 1. ‹0 ≤ t ⟹ norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)› 2. ‹¬ 0 ≤ t ⟹ norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)›*) assume "0 ≤ t" (*‹(0::real) ≤ (t::real)›*) hence [simp]: "¦t¦ = t" by simp have t0_t_in_J: "{0..t} ⊆ J" using ‹t ∈ J› (*‹t ∈ J›*) ‹0 ∈ J› (*‹0 ∈ J›*) J_ivl (*‹is_interval J›*) using mem_is_interval_1_I (*‹⟦is_interval ?S; ?a ∈ ?S; ?c ∈ ?S; ?a ≤ ?b; ?b ≤ ?c⟧ ⟹ ?b ∈ ?S›*) atLeastAtMost_iff (*‹((?i::?'a::ord) ∈ {?l::?'a::ord..?u::?'a::ord}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*) by blast note F_G_flow_cont[continuous_intros] = continuous_on_subset[OF F.flow_continuous_on] (*‹?t ⊆ F.existence_ivl ?t0.1 ?x0.1 ⟹ continuous_on ?t (F.flow ?t0.1 ?x0.1)›*) continuous_on_subset[OF G.flow_continuous_on] (*‹(?t::real set) ⊆ G.existence_ivl (?t0.1::real) (?x0.1::'a::{heine_borel,banach}) ⟹ continuous_on ?t (G.flow ?t0.1 ?x0.1)›*) have "?u t + e/K ≤ e/K * exp(K * t)" proof (rule gronwall[where g="λt. ?u t + e/K", OF _ _ _ _ K_pos ‹0 ≤ t› order.refl] (*‹⟦⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ norm (flow0 ta - Y ta) + e / K ≤ ?C + K * integral {0..ta} (λs. norm (flow0 s - Y s) + e / K); continuous_on {0..t} (λt. norm (flow0 t - Y t) + e / K); ⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K; 0 < ?C⟧ ⟹ norm (flow0 t - Y t) + e / K ≤ ?C * exp (K * t)›*)) (*goals: 1. ‹⋀ta::real. ⟦(0::real) ≤ ta; ta ≤ (t::real)⟧ ⟹ norm (flow0 ta - Y ta) + (e::real) / (K::real) ≤ e / K + K * integral {0::real..ta} (λs::real. norm (flow0 s - Y s) + e / K)› 2. ‹continuous_on {0::real..t::real} (λt::real. norm (flow0 t - Y t) + (e::real) / (K::real))› 3. ‹⋀ta::real. ⟦(0::real) ≤ ta; ta ≤ (t::real)⟧ ⟹ (0::real) ≤ norm (flow0 ta - Y ta) + (e::real) / (K::real)› 4. ‹(0::real) < (e::real) / (K::real)›*) fix s assume "0 ≤ s" "s ≤ t" (*‹(0::real) ≤ (s::real)› ‹(s::real) ≤ (t::real)›*) hence "{0..s} ⊆ J" using t0_t_in_J (*‹{0..t} ⊆ J›*) by auto hence t0_s_in_existence: "{0..s} ⊆ F.existence_ivl 0 x0" "{0..s} ⊆ G.existence_ivl 0 x0" using J_subset (*‹J ⊆ F.existence_ivl 0 x0›*) tG (*‹t ∈ G.existence_ivl 0 x0›*) ‹0 ≤ s› (*‹0 ≤ s›*) ‹s ≤ t› (*‹s ≤ t›*) G.ivl_subset_existence_ivl[OF tG] (*‹{0..t} ⊆ G.existence_ivl 0 x0›*) apply - (*goals: 1. ‹⟦{0..s} ⊆ J; J ⊆ F.existence_ivl 0 x0; t ∈ G.existence_ivl 0 x0; 0 ≤ s; s ≤ t; {0..t} ⊆ G.existence_ivl 0 x0⟧ ⟹ {0..s} ⊆ F.existence_ivl 0 x0› 2. ‹⟦{0..s} ⊆ J; J ⊆ F.existence_ivl 0 x0; t ∈ G.existence_ivl 0 x0; 0 ≤ s; s ≤ t; {0..t} ⊆ G.existence_ivl 0 x0⟧ ⟹ {0..s} ⊆ G.existence_ivl 0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence s_in_existence: "s ∈ F.existence_ivl 0 x0" "s ∈ G.existence_ivl 0 x0" using ‹0 ≤ s› (*‹0 ≤ s›*) apply - (*goals: 1. ‹⟦{0..s} ⊆ F.existence_ivl 0 x0; {0..s} ⊆ G.existence_ivl 0 x0; 0 ≤ s⟧ ⟹ s ∈ F.existence_ivl 0 x0› 2. ‹⟦{0..s} ⊆ F.existence_ivl 0 x0; {0..s} ⊆ G.existence_ivl 0 x0; 0 ≤ s⟧ ⟹ s ∈ G.existence_ivl 0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . note cont_statements[continuous_intros] = F_iv_defined (*‹0 ∈ T1› ‹(x0::'a) ∈ (X::'a set)›*) F.flow_in_domain (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ F.flow ?t0.0 ?x0.0 ?t ∈ X›*) G.flow_in_domain (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) F.mem_existence_ivl_subset (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T1›*) G.mem_existence_ivl_subset (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T2›*) have [integrable_on_simps]: "continuous_on {0..s} (λs. F s (F.flow 0 x0 s))" "continuous_on {0..s} (λs. G s (G.flow 0 x0 s))" "continuous_on {0..s} (λs. F s (G.flow 0 x0 s))" "continuous_on {0..s} (λs. G s (F.flow 0 x0 s))" using t0_s_in_existence (*‹{0..s} ⊆ F.existence_ivl 0 x0› ‹{0::real..s::real} ⊆ G.existence_ivl (0::real) (x0::'a)›*) apply - (*goals: 1. ‹⟦{0..s} ⊆ F.existence_ivl 0 x0; {0..s} ⊆ G.existence_ivl 0 x0⟧ ⟹ continuous_on {0..s} (λs. F s (F.flow 0 x0 s))› 2. ‹⟦{0..s} ⊆ F.existence_ivl 0 x0; {0..s} ⊆ G.existence_ivl 0 x0⟧ ⟹ continuous_on {0..s} (λs. G s (G.flow 0 x0 s))› 3. ‹⟦{0..s} ⊆ F.existence_ivl 0 x0; {0..s} ⊆ G.existence_ivl 0 x0⟧ ⟹ continuous_on {0..s} (λs. F s (G.flow 0 x0 s))› 4. ‹⟦{0..s} ⊆ F.existence_ivl 0 x0; {0..s} ⊆ G.existence_ivl 0 x0⟧ ⟹ continuous_on {0..s} (λs. G s (F.flow 0 x0 s))› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) integrable_continuous_real (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ ?f integrable_on {?a..?b}›*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*))[1]) (*discuss goal 4*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*))[1]) (*proven 4 subgoals*) . have "flow0 s - Y s = integral {0..s} (λs. F s (flow0 s) - G s (Y s))" using ‹0 ≤ s› (*‹0 ≤ s›*) by (simp add: flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) Henstock_Kurzweil_Integration.integral_diff (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x - ?g x) = integral ?S ?f - integral ?S ?g›*) integrable_on_simps (*‹?f integrable_on {}› ‹?f integrable_on cbox ?a ?a› ‹?g integrable_on {?b..?b}› ‹?h integrable_on {?a--?a}› ‹(λx. ?c) integrable_on cbox ?a ?b› ‹(λx. ?c) integrable_on {?a..?b}› ‹(λx. ?c) integrable_on {?a--?b}› ‹(λx. x) integrable_on {?a..?b}› ‹(λx. x) integrable_on {?a--?b}› ‹(λx. x) integrable_on cbox ?a ?b› ‹(λx. 0) integrable_on ?S› ‹?f integrable_on ?S ⟹ (λx. - ?f x) integrable_on ?S› and more 17 facts*) ivl_integral_def (*‹ivl_integral ?a ?b ?f = integral {?a..?b} ?f - integral {?b..?a} ?f›*) F.flow_fixed_point[OF s_in_existence(1)] (*‹F.flow 0 x0 s = x0 + ivl_integral 0 s (λt. F t (F.flow 0 x0 t))›*) G.flow_fixed_point[OF s_in_existence(2)] (*‹G.flow 0 x0 s = x0 + ivl_integral 0 s (λt. G t (G.flow 0 x0 t))›*)) also (*calculation: ‹flow0 s - Y s = integral {0..s} (λs. F s (flow0 s) - G s (Y s))›*) have "... = integral {0..s} (λs. (F s (flow0 s) - F s (Y s)) + (F s (Y s) - G s (Y s)))" by simp also (*calculation: ‹flow0 (s::real) - Y s = integral {0::real..s} (λs::real. (F::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) s (flow0 s) - F s (Y s) + (F s (Y s) - (G::real ⇒ 'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach}) s (Y s)))›*) have "... = integral {0..s} (λs. F s (flow0 s) - F s (Y s)) + integral {0..s} (λs. F s (Y s) - G s (Y s))" by (simp add: Henstock_Kurzweil_Integration.integral_diff (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x - ?g x) = integral ?S ?f - integral ?S ?g›*) Henstock_Kurzweil_Integration.integral_add (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) integrable_on_simps (*‹?f integrable_on {}› ‹?f integrable_on cbox ?a ?a› ‹?g integrable_on {?b..?b}› ‹?h integrable_on {?a--?a}› ‹(λx. ?c) integrable_on cbox ?a ?b› ‹(λx. ?c) integrable_on {?a..?b}› ‹(λx. ?c) integrable_on {?a--?b}› ‹(λx. x) integrable_on {?a..?b}› ‹(λx. x) integrable_on {?a--?b}› ‹(λx. x) integrable_on cbox ?a ?b› ‹(λx. 0) integrable_on ?S› ‹?f integrable_on ?S ⟹ (λx. - ?f x) integrable_on ?S› and more 17 facts*)) finally (*calculation: ‹flow0 s - Y s = integral {0..s} (λs. F s (flow0 s) - F s (Y s)) + integral {0..s} (λs. F s (Y s) - G s (Y s))›*) have "?u s ≤ norm (integral {0..s} (λs. F s (flow0 s) - F s (Y s))) + norm (integral {0..s} (λs. F s (Y s) - G s (Y s)))" by (simp add: norm_triangle_ineq (*‹norm (?x + ?y) ≤ norm ?x + norm ?y›*)) also (*calculation: ‹norm (flow0 s - Y s) ≤ norm (integral {0..s} (λs. F s (flow0 s) - F s (Y s))) + norm (integral {0..s} (λs. F s (Y s) - G s (Y s)))›*) have "... ≤ integral {0..s} (λs. norm (F s (flow0 s) - F s (Y s))) + integral {0..s} (λs. norm (F s (Y s) - G s (Y s)))" using t0_s_in_existence (*‹{0..s} ⊆ F.existence_ivl 0 x0› ‹{0..s} ⊆ G.existence_ivl 0 x0›*) by (auto simp add: flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) intro!: add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) continuous_on_imp_absolutely_integrable_on (*‹continuous_on {?a..?b} ?f ⟹ norm (integral {?a..?b} ?f) ≤ integral {?a..?b} (λx. norm (?f x))›*)) also (*calculation: ‹norm (flow0 s - Y s) ≤ integral {0..s} (λs. norm (F s (flow0 s) - F s (Y s))) + integral {0..s} (λs. norm (F s (Y s) - G s (Y s)))›*) have "... ≤ integral {0..s} (λs. K * ?u s) + integral {0..s} (λs. e)" proof (rule add_mono[OF integral_le integral_le] (*‹⟦(?f2::?'n2 ⇒ real) integrable_on (?S2::?'n2 set); (?g2::?'n2 ⇒ real) integrable_on ?S2; ⋀x::?'n2. x ∈ ?S2 ⟹ ?f2 x ≤ ?g2 x; (?f1::?'n1 ⇒ real) integrable_on (?S1::?'n1 set); (?g1::?'n1 ⇒ real) integrable_on ?S1; ⋀x::?'n1. x ∈ ?S1 ⟹ ?f1 x ≤ ?g1 x⟧ ⟹ integral ?S2 ?f2 + integral ?S1 ?f1 ≤ integral ?S2 ?g2 + integral ?S1 ?g1›*)) (*goals: 1. ‹(λs. norm (F s (flow0 s) - F s (Y s))) integrable_on {0..s}› 2. ‹(λs. K * norm (flow0 s - Y s)) integrable_on {0..s}› 3. ‹⋀x. x ∈ {0..s} ⟹ norm (F x (flow0 x) - F x (Y x)) ≤ K * norm (flow0 x - Y x)› 4. ‹(λs. norm (F s (Y s) - G s (Y s))) integrable_on {0..s}› 5. ‹(λs. e) integrable_on {0..s}› 6. ‹⋀x. x ∈ {0..s} ⟹ norm (F x (Y x) - G x (Y x)) ≤ e›*) show "norm (F x (flow0 x) - F x (Y x)) ≤ K * norm (flow0 x - Y x)" if "x ∈ {0..s}" for x using F_lipschitz[unfolded lipschitz_on_def, THEN conjunct2] (*‹?t1 ∈ J ⟹ ∀x∈X. ∀y∈X. dist (F ?t1 x) (F ?t1 y) ≤ K * dist x y›*) that (*‹x ∈ {0..s}›*) cont_statements(1,2,4) (*‹0 ∈ T1› ‹x0 ∈ X› ‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) t0_s_in_existence (*‹{0..s} ⊆ F.existence_ivl 0 x0› ‹{0..s} ⊆ G.existence_ivl 0 x0›*) F_iv_defined (*‹0 ∈ T1› ‹x0 ∈ X›*) by (metis F_lipschitz (*‹?t ∈ J ⟹ K-lipschitz_on X (F ?t)›*) flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) ‹{0..s} ⊆ J› lipschitz_on_normD (*‹⟦?L-lipschitz_on ?X ?f; ?x ∈ ?X; ?y ∈ ?X⟧ ⟹ norm (?f ?x - ?f ?y) ≤ ?L * norm (?x - ?y)›*) F.flow_in_domain (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ F.flow ?t0.0 ?x0.0 ?t ∈ X›*) G.flow_in_domain (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) subsetCE (*‹⟦?A ⊆ ?B; ?c ∉ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*)) show "⋀x. x ∈ {0..s} ⟹ norm (F x (Y x) - G x (Y x)) ≤ e" using F_G_norm_ineq (*‹⟦?t ∈ J; ?x ∈ X⟧ ⟹ norm (F ?t ?x - G ?t ?x) < e›*) cont_statements(2,3) (*‹x0 ∈ X› ‹(?t::real) ∈ F.existence_ivl (?t0.0::real) (?x0.0::'a) ⟹ F.flow ?t0.0 ?x0.0 ?t ∈ (X::'a set)›*) t0_s_in_existence (*‹{0..s} ⊆ F.existence_ivl 0 x0› ‹{0::real..s::real} ⊆ G.existence_ivl (0::real) (x0::'a::{heine_borel,banach})›*) using Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) ‹{0..s} ⊆ J› (*‹{0..s} ⊆ J›*) cont_statements(5) (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T1›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) G.flow_in_domain (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) by (metis eucl_less_le_not_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ¬ ?y ≤ ?x)›*)) qed (simp_all add: t0_s_in_existence continuous_intros integrable_on_simps flow0_def Y_def) (*solves the remaining goals: 1. ‹(λs. norm (F s (flow0 s) - F s (Y s))) integrable_on {0..s}› 2. ‹(λs. K * norm (flow0 s - Y s)) integrable_on {0..s}› 3. ‹(λs. norm (F s (Y s) - G s (Y s))) integrable_on {0..s}› 4. ‹(λs. e) integrable_on {0..s}›*) also (*calculation: ‹norm (flow0 s - Y s) ≤ integral {0..s} (λs. K * norm (flow0 s - Y s)) + integral {0..s} (λs. e)›*) have "... = K * integral {0..s} (λs. ?u s + e / K)" using K_pos (*‹0 < K›*) t0_s_in_existence (*‹{0..s} ⊆ F.existence_ivl 0 x0› ‹{0..s} ⊆ G.existence_ivl 0 x0›*) by (simp add: algebra_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 34 facts*) Henstock_Kurzweil_Integration.integral_add (*‹⟦(?f::?'a ⇒ ?'b) integrable_on (?S::?'a set); (?g::?'a ⇒ ?'b) integrable_on ?S⟧ ⟹ integral ?S (λx::?'a. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) flow0_def (*‹flow0 (?t::real) = F.flow (0::real) (x0::'a) ?t›*) Y_def (*‹Y (?t::real) = G.flow (0::real) (x0::'a) ?t›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) continuous_on_imp_absolutely_integrable_on (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ norm (integral {?a..?b} ?f) ≤ integral {?a..?b} (λx::real. norm (?f x))›*)) finally (*calculation: ‹norm (flow0 s - Y s) ≤ K * integral {0..s} (λs. norm (flow0 s - Y s) + e / K)›*) show "?u s + e / K ≤ e / K + K * integral {0..s} (λs. ?u s + e / K)" by simp next (*goals: 1. ‹continuous_on {0..t} (λt. norm (flow0 t - Y t) + e / K)› 2. ‹⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K› 3. ‹0 < e / K›*) show "continuous_on {0..t} (λt. norm (flow0 t - Y t) + e / K)" using t0_t_in_J (*‹{0..t} ⊆ J›*) J_subset (*‹J ⊆ F.existence_ivl 0 x0›*) G.ivl_subset_existence_ivl[OF tG] (*‹{0..t} ⊆ G.existence_ivl 0 x0›*) by (auto simp add: flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 280 facts*)) next (*goals: 1. ‹⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K› 2. ‹0 < e / K›*) fix s assume "0 ≤ s" "s ≤ t" (*‹(0::real) ≤ (s::real)› ‹(s::real) ≤ (t::real)›*) show "0 ≤ norm (flow0 s - Y s) + e / K" using e_pos (*‹0 < e›*) K_pos (*‹0 < K›*) by simp next (*goal: ‹(0::real) < (e::real) / (K::real)›*) show "0 < e / K" using e_pos (*‹0 < e›*) K_pos (*‹0 < K›*) by simp qed thus "?thesis" (*goal: ‹norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) next (*goal: ‹¬ 0 ≤ t ⟹ norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)›*) assume "¬0 ≤ t" (*‹¬ (0::real) ≤ (t::real)›*) hence "t ≤ 0" by simp hence [simp]: "¦t¦ = -t" by simp have t0_t_in_J: "{t..0} ⊆ J" using ‹t ∈ J› (*‹t ∈ J›*) ‹0 ∈ J› (*‹0 ∈ J›*) J_ivl (*‹is_interval J›*) ‹¬ 0 ≤ t› (*‹¬ 0 ≤ t›*) atMostAtLeast_subset_convex (*‹⟦convex (?C::real set); (?x::real) ∈ ?C; (?y::real) ∈ ?C; ?x < ?y⟧ ⟹ {?x..?y} ⊆ ?C›*) is_interval_convex_1 (*‹is_interval ?S = convex ?S›*) by auto note F_G_flow_cont[continuous_intros] = continuous_on_subset[OF F.flow_continuous_on] (*‹?t ⊆ F.existence_ivl ?t0.1 ?x0.1 ⟹ continuous_on ?t (F.flow ?t0.1 ?x0.1)›*) continuous_on_subset[OF G.flow_continuous_on] (*‹?t ⊆ G.existence_ivl ?t0.1 ?x0.1 ⟹ continuous_on ?t (G.flow ?t0.1 ?x0.1)›*) have "?u t + e/K ≤ e/K * exp(- K * t)" proof (rule gronwall_left[where g="λt. ?u t + e/K", OF _ _ _ _ K_pos order.refl ‹t ≤ 0›] (*‹⟦⋀ta. ⟦t ≤ ta; ta ≤ 0⟧ ⟹ norm (flow0 ta - Y ta) + e / K ≤ ?C + K * integral {ta..0} (λs. norm (flow0 s - Y s) + e / K); continuous_on {t..0} (λt. norm (flow0 t - Y t) + e / K); ⋀ta. ⟦t ≤ ta; ta ≤ 0⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K; 0 < ?C⟧ ⟹ norm (flow0 t - Y t) + e / K ≤ ?C * exp (- K * t)›*)) (*goals: 1. ‹⋀ta. ⟦t ≤ ta; ta ≤ 0⟧ ⟹ norm (flow0 ta - Y ta) + e / K ≤ e / K + K * integral {ta..0} (λs. norm (flow0 s - Y s) + e / K)› 2. ‹continuous_on {t..0} (λt. norm (flow0 t - Y t) + e / K)› 3. ‹⋀ta. ⟦t ≤ ta; ta ≤ 0⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K› 4. ‹0 < e / K›*) fix s assume "t ≤ s" "s ≤ 0" (*‹(t::real) ≤ (s::real)› ‹(s::real) ≤ (0::real)›*) hence "{s..0} ⊆ J" using t0_t_in_J (*‹{t..0} ⊆ J›*) by auto hence t0_s_in_existence: "{s..0} ⊆ F.existence_ivl 0 x0" "{s..0} ⊆ G.existence_ivl 0 x0" using J_subset (*‹(J::real set) ⊆ F.existence_ivl (0::real) (x0::'a)›*) G.ivl_subset_existence_ivl'[OF tG] (*‹{t..0} ⊆ G.existence_ivl 0 x0›*) ‹s ≤ 0› (*‹(s::real) ≤ (0::real)›*) ‹t ≤ s› (*‹t ≤ s›*) apply - (*goals: 1. ‹⟦{s..0} ⊆ J; J ⊆ F.existence_ivl 0 x0; {t..0} ⊆ G.existence_ivl 0 x0; s ≤ 0; t ≤ s⟧ ⟹ {s..0} ⊆ F.existence_ivl 0 x0› 2. ‹⟦{s..0} ⊆ J; J ⊆ F.existence_ivl 0 x0; {t..0} ⊆ G.existence_ivl 0 x0; s ≤ 0; t ≤ s⟧ ⟹ {s..0} ⊆ G.existence_ivl 0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence s_in_existence: "s ∈ F.existence_ivl 0 x0" "s ∈ G.existence_ivl 0 x0" using ‹s ≤ 0› (*‹s ≤ 0›*) apply - (*goals: 1. ‹⟦{s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0; s ≤ 0⟧ ⟹ s ∈ F.existence_ivl 0 x0› 2. ‹⟦{s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0; s ≤ 0⟧ ⟹ s ∈ G.existence_ivl 0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . note cont_statements[continuous_intros] = F_iv_defined (*‹0 ∈ T1› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)›*) F.flow_in_domain (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ F.flow ?t0.0 ?x0.0 ?t ∈ X›*) G.flow_in_domain (*‹(?t::real) ∈ G.existence_ivl (?t0.0::real) (?x0.0::'a) ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ (X::'a set)›*) F.mem_existence_ivl_subset (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T1›*) G.mem_existence_ivl_subset (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T2›*) then have [continuous_intros]: "{s..0} ⊆ T1" "{s..0} ⊆ T2" "F.flow 0 x0 ` {s..0} ⊆ X" "G.flow 0 x0 ` {s..0} ⊆ X" "s ≤ x ⟹ x ≤ 0 ⟹ x ∈ F.existence_ivl 0 x0" "s ≤ x ⟹ x ≤ 0 ⟹ x ∈ G.existence_ivl 0 x0" for x using t0_s_in_existence (*‹{s::real..0::real} ⊆ F.existence_ivl (0::real) (x0::'a)› ‹{s::real..0::real} ⊆ G.existence_ivl (0::real) (x0::'a)›*) apply - (*goals: 1. ‹⟦0 ∈ T1; x0 ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ F.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ G.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ t ∈ T1; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ t ∈ T2; {s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ {s..0} ⊆ T1› 2. ‹⟦0 ∈ T1; x0 ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ F.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ G.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ t ∈ T1; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ t ∈ T2; {s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ {s..0} ⊆ T2› 3. ‹⟦0 ∈ T1; x0 ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ F.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ G.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ t ∈ T1; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ t ∈ T2; {s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ F.flow 0 x0 ` {s..0} ⊆ X› 4. ‹⟦0 ∈ T1; x0 ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ F.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ G.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ t ∈ T1; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ t ∈ T2; {s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ G.flow 0 x0 ` {s..0} ⊆ X› 5. ‹⟦s ≤ x; x ≤ 0; 0 ∈ T1; x0 ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ F.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ G.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ t ∈ T1; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ t ∈ T2; {s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ x ∈ F.existence_ivl 0 x0› 6. ‹⟦s ≤ x; x ≤ 0; 0 ∈ T1; x0 ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ F.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ G.flow t0 x0 t ∈ X; ⋀t t0 x0. t ∈ F.existence_ivl t0 x0 ⟹ t ∈ T1; ⋀t t0 x0. t ∈ G.existence_ivl t0 x0 ⟹ t ∈ T2; {s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ x ∈ G.existence_ivl 0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . have "flow0 s - Y s = - integral {s..0} (λs. F s (flow0 s) - G s (Y s))" using t0_s_in_existence (*‹{s..0} ⊆ F.existence_ivl 0 x0› ‹{s..0} ⊆ G.existence_ivl 0 x0›*) ‹s ≤ 0› (*‹(s::real) ≤ (0::real)›*) by (simp add: flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) ivl_integral_def (*‹ivl_integral ?a ?b ?f = integral {?a..?b} ?f - integral {?b..?a} ?f›*) F.flow_fixed_point[OF s_in_existence(1)] (*‹F.flow 0 x0 s = x0 + ivl_integral 0 s (λt. F t (F.flow 0 x0 t))›*) G.flow_fixed_point[OF s_in_existence(2)] (*‹G.flow 0 x0 s = x0 + ivl_integral 0 s (λt. G t (G.flow 0 x0 t))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) integrable_on_simps (*‹?f integrable_on {}› ‹?f integrable_on cbox ?a ?a› ‹?g integrable_on {?b..?b}› ‹?h integrable_on {?a--?a}› ‹(λx. ?c) integrable_on cbox ?a ?b› ‹(λx. ?c) integrable_on {?a..?b}› ‹(λx. ?c) integrable_on {?a--?b}› ‹(λx. x) integrable_on {?a..?b}› ‹(λx. x) integrable_on {?a--?b}› ‹(λx. x) integrable_on cbox ?a ?b› ‹(λx. 0) integrable_on ?S› ‹?f integrable_on ?S ⟹ (λx. - ?f x) integrable_on ?S› and more 13 facts*) Henstock_Kurzweil_Integration.integral_diff (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x - ?g x) = integral ?S ?f - integral ?S ?g›*)) also (*calculation: ‹flow0 s - Y s = - integral {s..0} (λs. F s (flow0 s) - G s (Y s))›*) have "... = - integral {s..0} (λs. (F s (flow0 s) - F s (Y s)) + (F s (Y s) - G s (Y s)))" by simp also (*calculation: ‹flow0 s - Y s = - integral {s..0} (λs. F s (flow0 s) - F s (Y s) + (F s (Y s) - G s (Y s)))›*) have "... = - (integral {s..0} (λs. F s (flow0 s) - F s (Y s)) + integral {s..0} (λs. F s (Y s) - G s (Y s)))" using t0_s_in_existence (*‹{s..0} ⊆ F.existence_ivl 0 x0› ‹{s..0} ⊆ G.existence_ivl 0 x0›*) apply (subst Henstock_Kurzweil_Integration.integral_add (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*)) (*goals: 1. ‹⟦{s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ (λs. F s (flow0 s) - F s (Y s)) integrable_on {s..0}› 2. ‹⟦{s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ (λs. F s (Y s) - G s (Y s)) integrable_on {s..0}› 3. ‹⟦{s..0} ⊆ F.existence_ivl 0 x0; {s..0} ⊆ G.existence_ivl 0 x0⟧ ⟹ - (integral {s..0} (λs. F s (flow0 s) - F s (Y s)) + integral {s..0} (λs. F s (Y s) - G s (Y s))) = - (integral {s..0} (λs. F s (flow0 s) - F s (Y s)) + integral {s..0} (λs. F s (Y s) - G s (Y s)))› discuss goal 1*) apply (simp add: integral_add (*‹⟦(?f::?'a ⇒ ?'b) integrable_on (?S::?'a set); (?g::?'a ⇒ ?'b) integrable_on ?S⟧ ⟹ integral ?S (λx::?'a. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) flow0_def (*‹flow0 (?t::real) = F.flow (0::real) (x0::'a) ?t›*) Y_def (*‹Y (?t::real) = G.flow (0::real) (x0::'a) ?t›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) integrable_on_simps (*‹(?f::?'a ⇒ ?'b) integrable_on {}› ‹(?f::?'a ⇒ ?'b) integrable_on cbox (?a::?'a) ?a› ‹(?g::?'b ⇒ ?'a) integrable_on {?b::?'b..?b}› ‹(?h::?'c ⇒ ?'d) integrable_on {?a::?'c--?a}› ‹(λx::?'a. ?c::?'b) integrable_on cbox (?a::?'a) (?b::?'a)› ‹(λx::?'a. ?c::?'b) integrable_on {?a::?'a..?b::?'a}› ‹(λx::real. ?c::?'a) integrable_on {?a::real--?b::real}› ‹(λx::real. x) integrable_on {?a::real..?b::real}› ‹(λx::real. x) integrable_on {?a::real--?b::real}› ‹(λx::real. x) integrable_on cbox (?a::real) (?b::real)› ‹(λx::?'a. 0::?'b) integrable_on (?S::?'a set)› ‹(?f::?'a ⇒ ?'b) integrable_on (?S::?'a set) ⟹ (λx::?'a. - ?f x) integrable_on ?S› and more 13 facts*)) (*discuss goal 2*) apply (simp add: integral_add (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) integrable_on_simps (*‹?f integrable_on {}› ‹?f integrable_on cbox ?a ?a› ‹?g integrable_on {?b..?b}› ‹?h integrable_on {?a--?a}› ‹(λx. ?c) integrable_on cbox ?a ?b› ‹(λx. ?c) integrable_on {?a..?b}› ‹(λx. ?c) integrable_on {?a--?b}› ‹(λx. x) integrable_on {?a..?b}› ‹(λx. x) integrable_on {?a--?b}› ‹(λx. x) integrable_on cbox ?a ?b› ‹(λx. 0) integrable_on ?S› ‹?f integrable_on ?S ⟹ (λx. - ?f x) integrable_on ?S› and more 13 facts*)) (*discuss goal 3*) apply (simp add: integral_add (*‹⟦(?f::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on (?S::?'a::euclidean_space set); (?g::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on ?S⟧ ⟹ integral ?S (λx::?'a::euclidean_space. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) flow0_def (*‹flow0 (?t::real) = F.flow (0::real) (x0::'a::{heine_borel,banach}) ?t›*) Y_def (*‹Y (?t::real) = G.flow (0::real) (x0::'a::{heine_borel,banach}) ?t›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a::topological_space set); open (?T::?'a::topological_space set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. open ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b::type set); ∀x::?'b::type∈?A. open ((?B::?'b::type ⇒ ?'a::topological_space set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. closed ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a::topological_space set∈?K::?'a::topological_space set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) integrable_on_simps (*‹(?f::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on {}› ‹(?f::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on cbox (?a::?'a::euclidean_space) ?a› ‹(?g::?'b::ordered_euclidean_space ⇒ ?'a::real_normed_vector) integrable_on {?b::?'b::ordered_euclidean_space..?b}› ‹(?h::?'c::euclidean_space ⇒ ?'d::real_normed_vector) integrable_on {?a::?'c::euclidean_space--?a}› ‹(λx::?'a::euclidean_space. ?c::?'b::real_normed_vector) integrable_on cbox (?a::?'a::euclidean_space) (?b::?'a::euclidean_space)› ‹(λx::?'a::ordered_euclidean_space. ?c::?'b::real_normed_vector) integrable_on {?a::?'a::ordered_euclidean_space..?b::?'a::ordered_euclidean_space}› ‹(λx::real. ?c::?'a::real_normed_vector) integrable_on {?a::real--?b::real}› ‹(λx::real. x) integrable_on {?a::real..?b::real}› ‹(λx::real. x) integrable_on {?a::real--?b::real}› ‹(λx::real. x) integrable_on cbox (?a::real) (?b::real)› ‹(λx::?'a::euclidean_space. 0::?'b::real_normed_vector) integrable_on (?S::?'a::euclidean_space set)› ‹(?f::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on (?S::?'a::euclidean_space set) ⟹ (λx::?'a::euclidean_space. - ?f x) integrable_on ?S› and more 13 facts*)) (*proven 3 subgoals*) . finally (*calculation: ‹flow0 s - Y s = - (integral {s..0} (λs. F s (flow0 s) - F s (Y s)) + integral {s..0} (λs. F s (Y s) - G s (Y s)))›*) have "?u s ≤ norm (integral {s..0} (λs. F s (flow0 s) - F s (Y s))) + norm (integral {s..0} (λs. F s (Y s) - G s (Y s)))" by (metis (no_types, lifting) norm_minus_cancel (*‹norm (- ?x) = norm ?x›*) norm_triangle_ineq (*‹norm (?x + ?y) ≤ norm ?x + norm ?y›*)) also (*calculation: ‹norm (flow0 (s::real) - Y s) ≤ norm (integral {s..0::real} (λs::real. (F::real ⇒ 'a ⇒ 'a) s (flow0 s) - F s (Y s))) + norm (integral {s..0::real} (λs::real. F s (Y s) - (G::real ⇒ 'a ⇒ 'a) s (Y s)))›*) have "... ≤ integral {s..0} (λs. norm (F s (flow0 s) - F s (Y s))) + integral {s..0} (λs. norm (F s (Y s) - G s (Y s)))" using t0_s_in_existence (*‹{s..0} ⊆ F.existence_ivl 0 x0› ‹{s..0} ⊆ G.existence_ivl 0 x0›*) by (auto simp add: flow0_def (*‹flow0 (?t::real) = F.flow (0::real) (x0::'a) ?t›*) Y_def (*‹Y (?t::real) = G.flow (0::real) (x0::'a) ?t›*) intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) continuous_on_imp_absolutely_integrable_on (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ norm (integral {?a..?b} ?f) ≤ integral {?a..?b} (λx::real. norm (?f x))›*) add_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (?c::?'a) ≤ (?d::?'a)⟧ ⟹ ?a + ?c ≤ ?b + ?d›*)) also (*calculation: ‹norm (flow0 (s::real) - Y s) ≤ integral {s..0::real} (λs::real. norm ((F::real ⇒ 'a ⇒ 'a) s (flow0 s) - F s (Y s))) + integral {s..0::real} (λs::real. norm (F s (Y s) - (G::real ⇒ 'a ⇒ 'a) s (Y s)))›*) have "... ≤ integral {s..0} (λs. K * ?u s) + integral {s..0} (λs. e)" proof (rule add_mono[OF integral_le integral_le] (*‹⟦(?f2::?'n2 ⇒ real) integrable_on (?S2::?'n2 set); (?g2::?'n2 ⇒ real) integrable_on ?S2; ⋀x::?'n2. x ∈ ?S2 ⟹ ?f2 x ≤ ?g2 x; (?f1::?'n1 ⇒ real) integrable_on (?S1::?'n1 set); (?g1::?'n1 ⇒ real) integrable_on ?S1; ⋀x::?'n1. x ∈ ?S1 ⟹ ?f1 x ≤ ?g1 x⟧ ⟹ integral ?S2 ?f2 + integral ?S1 ?f1 ≤ integral ?S2 ?g2 + integral ?S1 ?g1›*)) (*goals: 1. ‹(λs. norm (F s (flow0 s) - F s (Y s))) integrable_on {s..0}› 2. ‹(λs. K * norm (flow0 s - Y s)) integrable_on {s..0}› 3. ‹⋀x. x ∈ {s..0} ⟹ norm (F x (flow0 x) - F x (Y x)) ≤ K * norm (flow0 x - Y x)› 4. ‹(λs. norm (F s (Y s) - G s (Y s))) integrable_on {s..0}› 5. ‹(λs. e) integrable_on {s..0}› 6. ‹⋀x. x ∈ {s..0} ⟹ norm (F x (Y x) - G x (Y x)) ≤ e›*) show "norm (F x (flow0 x) - F x (Y x)) ≤ K * norm (flow0 x - Y x)" if "x∈{s..0}" for x using F_lipschitz[unfolded lipschitz_on_def, THEN conjunct2] (*‹?t1 ∈ J ⟹ ∀x∈X. ∀y∈X. dist (F ?t1 x) (F ?t1 y) ≤ K * dist x y›*) cont_statements(1,2,4) (*‹0 ∈ T1› ‹(x0::'a::{heine_borel,banach}) ∈ (X::'a::{heine_borel,banach} set)› ‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) that (*‹x ∈ {s..0}›*) t0_s_in_existence (*‹{s::real..0::real} ⊆ F.existence_ivl (0::real) (x0::'a)› ‹{s..0} ⊆ G.existence_ivl 0 x0›*) F_iv_defined (*‹(0::real) ∈ (T1::real set)› ‹x0 ∈ X›*) by (metis F_lipschitz (*‹?t ∈ J ⟹ K-lipschitz_on X (F ?t)›*) flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) ‹{s..0} ⊆ J› lipschitz_on_normD (*‹⟦?L-lipschitz_on ?X ?f; ?x ∈ ?X; ?y ∈ ?X⟧ ⟹ norm (?f ?x - ?f ?y) ≤ ?L * norm (?x - ?y)›*) F.flow_in_domain (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ F.flow ?t0.0 ?x0.0 ?t ∈ X›*) G.flow_in_domain (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) subsetCE (*‹⟦?A ⊆ ?B; ?c ∉ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*)) show "⋀x. x ∈ {s..0} ⟹ norm (F x (Y x) - G x (Y x)) ≤ e" using F_G_norm_ineq (*‹⟦(?t::real) ∈ (J::real set); (?x::'a) ∈ (X::'a set)⟧ ⟹ norm ((F::real ⇒ 'a ⇒ 'a) ?t ?x - (G::real ⇒ 'a ⇒ 'a) ?t ?x) < (e::real)›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) ‹{s..0} ⊆ J› (*‹{s..0} ⊆ J›*) cont_statements(5) (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T1›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*) t0_s_in_existence(2) (*‹{s..0} ⊆ G.existence_ivl 0 x0›*) using Y_def (*‹Y (?t::real) = G.flow (0::real) (x0::'a) ?t›*) ‹{s..0} ⊆ J› (*‹{s..0} ⊆ J›*) cont_statements(5) (*‹?t ∈ F.existence_ivl ?t0.0 ?x0.0 ⟹ ?t ∈ T1›*) subset_iff (*‹((?A::?'a set) ⊆ (?B::?'a set)) = (∀t::?'a. t ∈ ?A ⟶ t ∈ ?B)›*) G.flow_in_domain (*‹?t ∈ G.existence_ivl ?t0.0 ?x0.0 ⟹ G.flow ?t0.0 ?x0.0 ?t ∈ X›*) by (metis eucl_less_le_not_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ¬ ?y ≤ ?x)›*)) qed (simp_all add: t0_s_in_existence continuous_intros integrable_on_simps flow0_def Y_def) (*solves the remaining goals: 1. ‹(λs. norm (F s (flow0 s) - F s (Y s))) integrable_on {s..0}› 2. ‹(λs. K * norm (flow0 s - Y s)) integrable_on {s..0}› 3. ‹(λs. norm (F s (Y s) - G s (Y s))) integrable_on {s..0}› 4. ‹(λs. e) integrable_on {s..0}›*) also (*calculation: ‹norm (flow0 (s::real) - Y s) ≤ integral {s..0::real} (λs::real. (K::real) * norm (flow0 s - Y s)) + integral {s..0::real} (λs::real. e::real)›*) have "... = K * integral {s..0} (λs. ?u s + e / K)" using K_pos (*‹0 < K›*) t0_s_in_existence (*‹{s..0} ⊆ F.existence_ivl 0 x0› ‹{s..0} ⊆ G.existence_ivl 0 x0›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*) Henstock_Kurzweil_Integration.integral_add (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*) t0_s_in_existence (*‹{s..0} ⊆ F.existence_ivl 0 x0› ‹{s..0} ⊆ G.existence_ivl 0 x0›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) integrable_on_simps (*‹?f integrable_on {}› ‹?f integrable_on cbox ?a ?a› ‹?g integrable_on {?b..?b}› ‹?h integrable_on {?a--?a}› ‹(λx. ?c) integrable_on cbox ?a ?b› ‹(λx. ?c) integrable_on {?a..?b}› ‹(λx. ?c) integrable_on {?a--?b}› ‹(λx. x) integrable_on {?a..?b}› ‹(λx. x) integrable_on {?a--?b}› ‹(λx. x) integrable_on cbox ?a ?b› ‹(λx. 0) integrable_on ?S› ‹?f integrable_on ?S ⟹ (λx. - ?f x) integrable_on ?S› and more 13 facts*) flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*)) finally (*calculation: ‹norm (flow0 s - Y s) ≤ K * integral {s..0} (λs. norm (flow0 s - Y s) + e / K)›*) show "?u s + e / K ≤ e / K + K * integral {s..0} (λs. ?u s + e / K)" by simp next (*goals: 1. ‹continuous_on {t..0} (λt. norm (flow0 t - Y t) + e / K)› 2. ‹⋀ta. ⟦t ≤ ta; ta ≤ 0⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K› 3. ‹0 < e / K›*) show "continuous_on {t..0} (λt. norm (flow0 t - Y t) + e / K)" using t0_t_in_J (*‹{t..0} ⊆ J›*) J_subset (*‹J ⊆ F.existence_ivl 0 x0›*) G.ivl_subset_existence_ivl'[OF tG] (*‹{t..0} ⊆ G.existence_ivl 0 x0›*) F_iv_defined (*‹0 ∈ T1› ‹(x0::'a) ∈ (X::'a set)›*) by (auto simp add: flow0_def (*‹flow0 ?t = F.flow 0 x0 ?t›*) Y_def (*‹Y ?t = G.flow 0 x0 ?t›*) intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 280 facts*)) next (*goals: 1. ‹⋀ta. ⟦t ≤ ta; ta ≤ 0⟧ ⟹ 0 ≤ norm (flow0 ta - Y ta) + e / K› 2. ‹0 < e / K›*) fix s assume "t ≤ s" "s ≤ 0" (*‹(t::real) ≤ (s::real)› ‹(s::real) ≤ (0::real)›*) show "0 ≤ norm (flow0 s - Y s) + e / K" using e_pos (*‹0 < e›*) K_pos (*‹0 < K›*) by simp next (*goal: ‹0 < e / K›*) show "0 < e / K" using e_pos (*‹0 < e›*) K_pos (*‹(0::real) < (K::real)›*) by simp qed thus "?thesis" (*goal: ‹norm (flow0 t - Y t) ≤ e / K * (exp (K * ¦t¦) - 1)›*) by (simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 34 facts*)) qed qed end end locale auto_ll_on_open = fixes f::"'a::{banach, heine_borel} ⇒ 'a" and X assumes auto_local_lipschitz: "local_lipschitz UNIV X (λ_::real. f)" assumes auto_open_domain[intro!, simp]: "open X" begin text ‹autonomous flow and existence interval › definition "flow0 x0 t = ll_on_open.flow UNIV (λ_. f) X 0 x0 t" definition "existence_ivl0 x0 = ll_on_open.existence_ivl UNIV (λ_. f) X 0 x0" sublocale ll_on_open_it UNIV "λ_. f" X 0 rewrites "flow = (λt0 x0 t. flow0 x0 (t - t0))" and "existence_ivl = (λt0 x0. (+) t0 ` existence_ivl0 x0)" and "(+) 0 = (λx::real. x)" and "s - 0 = s" and "(λx. x) ` S = S" and "s ∈ (+) t ` S ⟷ s - t ∈ (S::real set)" and "P (s + t - s) = P (t::real)"― ‹TODO: why does just the equation not work?› and "P (t + s - s) = P t"― ‹TODO: why does just the equation not work?› proof (-) (*goals: 1. ‹ll_on_open_it UNIV (λ_. f) X› 2. ‹ll_on_open.flow UNIV (λ_. f) X = (λt0 x0 t. flow0 x0 (t - t0))› 3. ‹ll_on_open.existence_ivl UNIV (λ_. f) X = (λt0 x0. (+) t0 ` existence_ivl0 x0)› 4. ‹(+) 0 = (λx. x)› 5. ‹s - 0 = s› 6. ‹(λx. x) ` S = S› 7. ‹(s ∈ (+) t ` S) = (s - t ∈ S)› 8. ‹P (s + t - s) = P t› 9. ‹P (t + s - s) = P t›*) interpret ll_on_open UNIV "λ_. f" X apply unfold_locales (*goals: 1. ‹is_interval UNIV› 2. ‹local_lipschitz UNIV X (λ_. f)› 3. ‹⋀x. x ∈ X ⟹ continuous_on UNIV (λt. f x)› 4. ‹open UNIV› 5. ‹open X› discuss goal 1*) apply ((auto intro!: continuous_on_const (*‹continuous_on ?s (λx. ?c)›*) auto_local_lipschitz (*‹local_lipschitz UNIV X (λ_. f)›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_on_const (*‹continuous_on ?s (λx. ?c)›*) auto_local_lipschitz (*‹local_lipschitz UNIV X (λ_. f)›*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_on_const (*‹continuous_on ?s (λx. ?c)›*) auto_local_lipschitz (*‹local_lipschitz UNIV X (λ_. f)›*))[1]) (*discuss goal 4*) apply ((auto intro!: continuous_on_const (*‹continuous_on (?s::?'a::topological_space set) (λx::?'a::topological_space. ?c::?'b::topological_space)›*) auto_local_lipschitz (*‹local_lipschitz UNIV (X::'a::{heine_borel,banach} set) (λ_::real. f::'a::{heine_borel,banach} ⇒ 'a::{heine_borel,banach})›*))[1]) (*discuss goal 5*) apply ((auto intro!: continuous_on_const (*‹continuous_on ?s (λx. ?c)›*) auto_local_lipschitz (*‹local_lipschitz UNIV X (λ_. f)›*))[1]) (*proven 5 subgoals*) . show "ll_on_open_it UNIV (λ_. f) X" by standard show "(+) 0 = (λx::real. x)" "(λx. x) ` S = S" "s - 0 = s" "P (t + s - s) = P t" "P (s + t - s) = P (t::real)" (*goals: 1. ‹(+) 0 = (λx. x)› 2. ‹(λx. x) ` S = S› 3. ‹s - 0 = s› 4. ‹P (t + s - s) = P t› 5. ‹P (s + t - s) = P t› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . show "flow = (λt0 x0 t. flow0 x0 (t - t0))" unfolding flow0_def (*goal: ‹flow = (λ(t0::real) (x0::'a) t::real. flow (0::real) x0 (t - t0))›*) by (metis flow_def (*‹flow (?t0.0::real) (?x0.0::'a) = (λt::real. if t ∈ existence_ivl ?t0.0 ?x0.0 then csol ?t0.0 ?x0.0 t t else (0::'a))›*) flow_shift_autonomous1 (*‹⟦(?t::real) ∈ existence_ivl (?s::real) (?x::'a); ?x ∈ (X::'a set); ⋀(s::real) (t::real) x::'a. x ∈ X ⟹ (f::'a ⇒ 'a) x = f x; UNIV = UNIV⟧ ⟹ flow ?s ?x ?t = flow (0::real) ?x (?t - ?s)›*) flow_shift_autonomous2 (*‹⟦(?t::real) - (?s::real) ∈ existence_ivl (0::real) (?x::'a); ?x ∈ (X::'a set); ⋀(s::real) (t::real) x::'a. x ∈ X ⟹ (f::'a ⇒ 'a) x = f x; UNIV = UNIV⟧ ⟹ flow ?s ?x ?t = flow (0::real) ?x (?t - ?s)›*) mem_existence_ivl_iv_defined( (*‹(?t::real) ∈ existence_ivl (?t0.0::real) (?x0.0::'a) ⟹ ?x0.0 ∈ (X::'a set)›*) 2)) show "existence_ivl = (λt0 x0. (+) t0 ` existence_ivl0 x0)" unfolding existence_ivl0_def (*goal: ‹existence_ivl = (λ(t0::real) x0::'a. (+) t0 ` existence_ivl (0::real) x0)›*) apply (safe intro!: ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹existence_ivl = (λt0 x0. (+) t0 ` existence_ivl 0 x0)›*) subgoal for using image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) mem_existence_ivl_shift_autonomous1 (*‹⟦?t ∈ existence_ivl ?s ?x; ?x ∈ X; ⋀s t x. x ∈ X ⟹ f x = f x; UNIV = UNIV⟧ ⟹ ?t - ?s ∈ existence_ivl 0 ?x›*) by fastforce subgoalpremises prems for t0 and x0 and x and s proof (-) (*goal: ‹t0 + s ∈ existence_ivl t0 x0›*) have f2: "∀x1 x2. (x2::real) - x1 = - 1 * x1 + x2" by auto have "- 1 * t0 + (t0 + s) = s" by auto then show "?thesis" (*goal: ‹t0 + s ∈ existence_ivl t0 x0›*) using f2 (*‹∀x1 x2. x2 - x1 = - 1 * x1 + x2›*) prems (*‹(s::real) ∈ existence_ivl (0::real) (x0::'a::{heine_borel,banach})›*) mem_existence_ivl_iv_defined(2) (*‹?t ∈ existence_ivl ?t0.0 ?x0.0 ⟹ ?x0.0 ∈ X›*) mem_existence_ivl_shift_autonomous2 (*‹⟦?t - ?s ∈ existence_ivl 0 ?x; ?x ∈ X; ⋀s t x. x ∈ X ⟹ f x = f x; UNIV = UNIV⟧ ⟹ ?t ∈ existence_ivl ?s ?x›*) by presburger qed . show "(s ∈ (+) t ` S) = (s - t ∈ S)" by force qed<close> lemma existence_ivl_zero: "x0 ∈ X ⟹ 0 ∈ existence_ivl0 x0" by simp lemmas [continuous_intros del] = continuous_on_f lemmas continuous_on_f_comp[continuous_intros] = continuous_on_f[OF continuous_on_const _ subset_UNIV] lemma flow_in_compact_right_existence: assumes "⋀t. 0 ≤ t ⟹ t ∈ existence_ivl0 x ⟹ flow0 x t ∈ K" assumes "compact K" "K ⊆ X" assumes "x ∈ X" "t ≥ 0" shows "t ∈ existence_ivl0 x" proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹(t::real) ∉ existence_ivl0 (x::'a::{heine_borel,banach}) ⟹ False›*) assume "t ∉ existence_ivl0 x" (*‹(t::real) ∉ existence_ivl0 (x::'a)›*) have "bdd_above (existence_ivl0 x)" apply (rule bdd_above_is_intervalI[OF is_interval_existence_ivl ‹0 ≤ t› existence_ivl_zero] (*‹⟦?x0.1 ∈ X; t ∉ existence_ivl0 ?x0.1⟧ ⟹ bdd_above (existence_ivl0 ?x0.1)›*)) (*goals: 1. ‹(x::'a) ∈ (X::'a set)› 2. ‹(t::real) ∉ existence_ivl0 (x::'a)› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . from sup_existence_maximal[OF UNIV_I ‹x ∈ X› assms ( 1 - 3 ) this] (*‹⟦⋀t::real. ⟦(0::real) ≤ t; t ∈ existence_ivl0 (x::'a::{heine_borel,banach})⟧ ⟹ (0::real) ≤ t; ⋀t::real. ⟦(0::real) ≤ t; t ∈ existence_ivl0 x⟧ ⟹ t ∈ existence_ivl0 x⟧ ⟹ Sup (existence_ivl0 x) ∉ UNIV›*) show False by auto qed lemma flow_in_compact_left_existence: assumes "⋀t. t ≤ 0 ⟹ t ∈ existence_ivl0 x ⟹ flow0 x t ∈ K" assumes "compact K" "K ⊆ X" assumes "x ∈ X" "t ≤ 0" shows "t ∈ existence_ivl0 x" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹t ∉ existence_ivl0 x ⟹ False›*) assume "t ∉ existence_ivl0 x" (*‹(t::real) ∉ existence_ivl0 (x::'a)›*) have "bdd_below (existence_ivl0 x)" apply (rule bdd_below_is_intervalI[OF is_interval_existence_ivl ‹t ≤ 0› _ existence_ivl_zero] (*‹⟦t ∉ existence_ivl0 ?x0.1; ?x0.1 ∈ X⟧ ⟹ bdd_below (existence_ivl0 ?x0.1)›*)) (*goals: 1. ‹t ∉ existence_ivl0 x› 2. ‹x ∈ X› discuss goal 1*) apply fact (*discuss goal 2*) apply fact (*proven 2 subgoals*) . from inf_existence_minimal[OF UNIV_I ‹x ∈ X› assms ( 1 - 3 ) this] (*‹⟦⋀t::real. ⟦t ≤ (0::real); t ∈ existence_ivl0 (x::'a::{heine_borel,banach})⟧ ⟹ t ≤ (0::real); ⋀t::real. ⟦t ≤ (0::real); t ∈ existence_ivl0 x⟧ ⟹ t ∈ existence_ivl0 x⟧ ⟹ Inf (existence_ivl0 x) ∉ UNIV›*) show False by auto qed end locale compact_continuously_diff = derivative_on_prod T X f "λ(t, x). f' x o⇩L snd_blinfun" for T X and f::"real ⇒ 'a::{banach,perfect_space,heine_borel} ⇒ 'a" and f'::"'a ⇒ ('a, 'a) blinfun" + assumes compact_domain: "compact X" assumes convex: "convex X" assumes nonempty_domains: "T ≠ {}" "X ≠ {}" assumes continuous_derivative: "continuous_on X f'" begin lemma ex_onorm_bound: "∃B. ∀x ∈ X. norm (f' x) ≤ B" proof (-) (*goal: ‹∃B. ∀x∈X. norm (f' x) ≤ B›*) from "_" (*‹PROP ?psi ⟹ PROP ?psi›*) compact_domain (*‹compact (X::'a::{heine_borel,banach,perfect_space} set)›*) have "compact (f' ` X)" by (intro compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_derivative (*‹continuous_on X f'›*)) hence "bounded (f' ` X)" by (rule compact_imp_bounded (*‹compact (?U::?'a set) ⟹ bounded ?U›*)) thus "?thesis" (*goal: ‹∃B. ∀x∈X. norm (f' x) ≤ B›*) by (auto simp add: bounded_iff (*‹bounded ?S = (∃a. ∀x∈?S. norm x ≤ a)›*) cball_def (*‹cball ?x ?e = {y. dist ?x y ≤ ?e}›*) norm_blinfun.rep_eq (*‹norm ?x = onorm (blinfun_apply ?x)›*)) qed definition "onorm_bound = (SOME B. ∀x ∈ X. norm (f' x) ≤ B)" lemma onorm_bound: assumes "x ∈ X" shows "norm (f' x) ≤ onorm_bound" unfolding onorm_bound_def (*goal: ‹norm (f' x) ≤ (SOME B. ∀x∈X. norm (f' x) ≤ B)›*) using someI_ex[OF ex_onorm_bound] (*‹∀x::'a::{heine_borel,banach,perfect_space}∈X::'a::{heine_borel,banach,perfect_space} set. norm ((f'::'a::{heine_borel,banach,perfect_space} ⇒ 'a::{heine_borel,banach,perfect_space} ⇒⇩L 'a::{heine_borel,banach,perfect_space}) x) ≤ (SOME x::real. ∀xa::'a::{heine_borel,banach,perfect_space}∈X. norm (f' xa) ≤ x)›*) assms (*‹x ∈ X›*) by blast sublocale closed_domain X using compact_domain (*‹compact X›*) apply unfold_locales (*goal: ‹closed_domain (X::'a set)›*) by (rule compact_imp_closed (*‹compact ?s ⟹ closed ?s›*)) sublocale global_lipschitz T X f onorm_bound proof (unfold_locales, rule lipschitz_onI (*‹⟦⋀x y. ⟦x ∈ ?X; y ∈ ?X⟧ ⟹ dist (?f x) (?f y) ≤ ?L * dist x y; 0 ≤ ?L⟧ ⟹ ?L-lipschitz_on ?X ?f›*)) (*goals: 1. ‹⋀t x y. ⟦t ∈ T; x ∈ X; y ∈ X⟧ ⟹ dist (f t x) (f t y) ≤ onorm_bound * dist x y› 2. ‹⋀t. t ∈ T ⟹ 0 ≤ onorm_bound›*) fix t and z and y assume "t ∈ T" "y ∈ X" "z ∈ X" (*‹(t::real) ∈ (T::real set)› ‹(y::'a) ∈ (X::'a set)› ‹(z::'a) ∈ (X::'a set)›*) then have "norm (f t y - f t z) ≤ onorm_bound * norm (y - z)" using onorm_bound (*‹?x ∈ X ⟹ norm (f' ?x) ≤ onorm_bound›*) apply (intro differentiable_bound[where f'=f', OF convex] (*‹⟦⋀x. x ∈ X ⟹ (?f has_derivative blinfun_apply (f' x)) (at x within X); ⋀x. x ∈ X ⟹ onorm (blinfun_apply (f' x)) ≤ ?B; ?x ∈ X; ?y ∈ X⟧ ⟹ norm (?f ?x - ?f ?y) ≤ ?B * norm (?x - ?y)›*)) (*goals: 1. ‹⋀x. ⟦t ∈ T; y ∈ X; z ∈ X; ⋀x. x ∈ X ⟹ norm (f' x) ≤ onorm_bound; x ∈ X⟧ ⟹ (f t has_derivative blinfun_apply (f' x)) (at x within X)› 2. ‹⋀x. ⟦t ∈ T; y ∈ X; z ∈ X; ⋀x. x ∈ X ⟹ norm (f' x) ≤ onorm_bound; x ∈ X⟧ ⟹ onorm (blinfun_apply (f' x)) ≤ onorm_bound› 3. ‹⟦t ∈ T; y ∈ X; z ∈ X; ⋀x. x ∈ X ⟹ norm (f' x) ≤ onorm_bound⟧ ⟹ y ∈ X› 4. ‹⟦t ∈ T; y ∈ X; z ∈ X; ⋀x. x ∈ X ⟹ norm (f' x) ≤ onorm_bound⟧ ⟹ z ∈ X› discuss goal 1*) apply ((auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) simp: norm_blinfun.rep_eq (*‹norm ?x = onorm (blinfun_apply ?x)›*))[1]) (*discuss goal 2*) apply ((auto intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) simp: norm_blinfun.rep_eq (*‹norm (?x::?'a ⇒⇩L ?'b) = onorm (blinfun_apply ?x)›*))[1]) (*discuss goal 3*) apply ((auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) simp: norm_blinfun.rep_eq (*‹norm ?x = onorm (blinfun_apply ?x)›*))[1]) (*discuss goal 4*) apply ((auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) simp: norm_blinfun.rep_eq (*‹norm ?x = onorm (blinfun_apply ?x)›*))[1]) (*proven 4 subgoals*) . thus "dist (f t y) (f t z) ≤ onorm_bound * dist y z" by (auto simp: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*) norm_Pair (*‹norm (?a, ?b) = sqrt ((norm ?a)² + (norm ?b)²)›*)) next (*goal: ‹⋀t. t ∈ T ⟹ 0 ≤ onorm_bound›*) from nonempty_domains (*‹T ≠ {}› ‹X ≠ {}›*) obtain x where x: "x ∈ X" (*goal: ‹(⋀x. x ∈ X ⟹ thesis) ⟹ thesis›*) by auto show "0 ≤ onorm_bound" using dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) local.onorm_bound (*‹?x ∈ X ⟹ norm (f' ?x) ≤ onorm_bound›*) norm_ge_zero (*‹0 ≤ norm ?x›*) x (*‹x ∈ X›*) by blast qed end ― ‹@{thm compact_domain}› locale unique_on_compact_continuously_diff = self_mapping + compact_interval T + compact_continuously_diff T X f begin sublocale unique_on_closed t0 T x0 f X onorm_bound apply unfold_locales (*goal: ‹unique_on_closed t0 T x0 f X onorm_bound›*) by (auto intro!: f' (*‹(?tx::real × 'a::{heine_borel,banach,perfect_space}) ∈ (T::real set) × (X::'a::{heine_borel,banach,perfect_space} set) ⟹ ((λ(t::real, x::'a::{heine_borel,banach,perfect_space}). (f::real ⇒ 'a::{heine_borel,banach,perfect_space} ⇒ 'a::{heine_borel,banach,perfect_space}) t x) has_derivative blinfun_apply (case ?tx of (t::real, x::'a::{heine_borel,banach,perfect_space}) ⇒ (f'::'a::{heine_borel,banach,perfect_space} ⇒ 'a::{heine_borel,banach,perfect_space} ⇒⇩L 'a::{heine_borel,banach,perfect_space}) x o⇩L snd_blinfun)) (at ?tx within T × X)›*) has_derivative_continuous_on (*‹(⋀x::?'a::real_normed_vector. x ∈ (?s::?'a::real_normed_vector set) ⟹ ((?f::?'a::real_normed_vector ⇒ ?'b::real_normed_vector) has_derivative (?f'::?'a::real_normed_vector ⇒ ?'a::real_normed_vector ⇒ ?'b::real_normed_vector) x) (at x within ?s)) ⟹ continuous_on ?s ?f›*)) end locale c1_on_open = fixes f::"'a::{banach, perfect_space, heine_borel} ⇒ 'a" and f' X assumes open_dom[simp]: "open X" assumes derivative_rhs: "⋀x. x ∈ X ⟹ (f has_derivative blinfun_apply (f' x)) (at x)" assumes continuous_derivative: "continuous_on X f'" begin lemmas continuous_derivative_comp[continuous_intros] = continuous_on_compose2[OF continuous_derivative] lemma derivative_tendsto[tendsto_intros]: assumes [tendsto_intros]: "(g ⤏ l) F" and "l ∈ X" shows "((λx. f' (g x)) ⤏ f' l) F" using continuous_derivative[simplified continuous_on] (*‹∀x∈X. (f' ⤏ f' x) (at x within X)›*) assms (*‹(g ⤏ l) F› ‹l ∈ X›*) by (auto simp: at_within_open[OF _ open_dom] (*‹?a ∈ X ⟹ at ?a within X = at ?a›*) intro!: tendsto_eq_intros (*‹?x = ?y ⟹ ((λx. x) ⤏ ?y) (at ?x within ?s1)› ‹?x = ?y ⟹ ((λx. ?x) ⤏ ?y) ?F› ‹⟦(?X1 ⤏ ?x1) ?F; (?Y1 ⤏ ?y1) ?F; max ?x1 ?y1 = ?y⟧ ⟹ ((λx. max (?X1 x) (?Y1 x)) ⤏ ?y) ?F› ‹⟦(?X1 ⤏ ?x1) ?F; (?Y1 ⤏ ?y1) ?F; min ?x1 ?y1 = ?y⟧ ⟹ ((λx. min (?X1 x) (?Y1 x)) ⤏ ?y) ?F› ‹⟦(?f1 ⤏ ?a1) ?F; fst ?a1 = ?y⟧ ⟹ ((λx. fst (?f1 x)) ⤏ ?y) ?F› ‹⟦(?f1 ⤏ ?a1) ?F; snd ?a1 = ?y⟧ ⟹ ((λx. snd (?f1 x)) ⤏ ?y) ?F› ‹⟦(?f1 ⤏ ?a1) ?F; (?g1 ⤏ ?b1) ?F; (?a1, ?b1) = ?y⟧ ⟹ ((λx. (?f1 x, ?g1 x)) ⤏ ?y) ?F› ‹0 = ?y ⟹ (λn. 1 / of_nat n) ⇢ ?y› ‹⟦(?f1 ⤏ ?l1) ?F; (?g1 ⤏ ?m1) ?F; dist ?l1 ?m1 = ?y⟧ ⟹ ((λx. dist (?f1 x) (?g1 x)) ⤏ ?y) ?F› ‹⟦(?f1 ⤏ ?a1) ?F; norm ?a1 = ?y⟧ ⟹ ((λx. norm (?f1 x)) ⤏ ?y) ?F› ‹⟦(?f1 ⤏ ?l1) ?F; ¦?l1¦ = ?y⟧ ⟹ ((λx. ¦?f1 x¦) ⤏ ?y) ?F› ‹⟦(?f1 ⤏ ?a1) ?F; (?g1 ⤏ ?b1) ?F; ?a1 + ?b1 = ?y⟧ ⟹ ((λx. ?f1 x + ?g1 x) ⤏ ?y) ?F› and more 100 facts*) intro: tendsto_compose (*‹⟦?g ─?l→ ?g ?l; (?f ⤏ ?l) ?F⟧ ⟹ ((λx. ?g (?f x)) ⤏ ?g ?l) ?F›*)) lemma c1_on_open_rev[intro, simp]: "c1_on_open (-f) (-f') X" using derivative_rhs (*‹?x ∈ X ⟹ (f has_derivative blinfun_apply (f' ?x)) (at ?x)›*) continuous_derivative (*‹continuous_on X f'›*) apply unfold_locales (*goals: 1. ‹⟦⋀x. x ∈ X ⟹ (f has_derivative blinfun_apply (f' x)) (at x); continuous_on X f'⟧ ⟹ open X› 2. ‹⋀x. ⟦⋀x. x ∈ X ⟹ (f has_derivative blinfun_apply (f' x)) (at x); continuous_on X f'; x ∈ X⟧ ⟹ (- f has_derivative blinfun_apply ((- f') x)) (at x)› 3. ‹⟦⋀x. x ∈ X ⟹ (f has_derivative blinfun_apply (f' x)) (at x); continuous_on X f'⟧ ⟹ continuous_on X (- f')› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 135 facts*) simp: fun_Compl_def (*‹- ?A = (λx. - ?A x)›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 135 facts*) simp: fun_Compl_def (*‹- ?A = (λx. - ?A x)›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 135 facts*) simp: fun_Compl_def (*‹- ?A = (λx. - ?A x)›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*proven 3 subgoals*) . lemma derivative_rhs_compose[derivative_intros]: "((g has_derivative g') (at x within s)) ⟹ g x ∈ X ⟹ ((λx. f (g x)) has_derivative (λxa. blinfun_apply (f' (g x)) (g' xa))) (at x within s)" by (metis has_derivative_compose[of g g' x s f "f' (g x)"] (*‹⟦(g has_derivative g') (at x within s); (f has_derivative blinfun_apply (f' (g x))) (at (g x))⟧ ⟹ ((λx. f (g x)) has_derivative (λxa. blinfun_apply (f' (g x)) (g' xa))) (at x within s)›*) derivative_rhs (*‹?x ∈ X ⟹ (f has_derivative blinfun_apply (f' ?x)) (at ?x)›*)) sublocale auto_ll_on_open proof (standard, rule local_lipschitzI (*‹(⋀(t::?'a) x::?'b. ⟦t ∈ (?T::?'a set); x ∈ (?X::?'b set)⟧ ⟹ ∃u>0::real. ∃L::real. ∀t::?'a∈cball t u ∩ ?T. L-lipschitz_on (cball x u ∩ ?X) ((?f::?'a ⇒ ?'b ⇒ ?'c) t)) ⟹ local_lipschitz ?T ?X ?f›*)) (*goals: 1. ‹⋀t x. ⟦t ∈ UNIV; x ∈ X⟧ ⟹ ∃u>0. ∃L. ∀t∈cball t u ∩ UNIV. L-lipschitz_on (cball x u ∩ X) f› 2. ‹open X›*) fix x and t :: real assume "x ∈ X" (*‹(x::'a) ∈ (X::'a set)›*) with open_contains_cball[of "UNIV::real set"] (*‹open UNIV = (∀x∈UNIV. ∃e>0. cball x e ⊆ UNIV)›*) open_UNIV (*‹open UNIV›*) open_contains_cball[of X] (*‹open X = (∀x∈X. ∃e>0. cball x e ⊆ X)›*) open_dom (*‹open X›*) obtain u and v where uv: "cball t u ⊆ UNIV" "cball x v ⊆ X" "u > 0" "v > 0" (*goal: ‹(⋀u v. ⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v⟧ ⟹ thesis) ⟹ thesis›*) by blast let ?T = "cball t u" and ?X = "cball x v" have "bounded ?X" by simp have "compact (cball x v)" by simp interpret compact_continuously_diff "?T" "?X" "λ_. f" f' using uv (*‹cball t u ⊆ UNIV› ‹cball x v ⊆ X› ‹0 < u› ‹0 < v›*) apply unfold_locales (*goals: 1. ‹⋀tx. ⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v; tx ∈ cball t u × cball x v⟧ ⟹ ((λ(t, x). f x) has_derivative blinfun_apply (case tx of (t, x) ⇒ f' x o⇩L snd_blinfun)) (at tx within cball t u × cball x v)› 2. ‹⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v⟧ ⟹ compact (cball x v)› 3. ‹⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v⟧ ⟹ convex (cball x v)› 4. ‹⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v⟧ ⟹ cball t u ≠ {}› 5. ‹⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v⟧ ⟹ cball x v ≠ {}› 6. ‹⟦cball t u ⊆ UNIV; cball x v ⊆ X; 0 < u; 0 < v⟧ ⟹ continuous_on (cball x v) f'› discuss goal 1*) apply ((auto simp: convex_cball (*‹convex (cball ?x ?e)›*) cball_eq_empty (*‹(cball ?x ?e = {}) = (?e < 0)›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) continuous_on_compose2[OF continuous_derivative] (*‹⟦continuous_on ?s ?f; ?f ` ?s ⊆ X⟧ ⟹ continuous_on ?s (λx. f' (?f x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*))[1]) (*discuss goal 2*) apply ((auto simp: convex_cball (*‹convex (cball (?x::?'a) (?e::real))›*) cball_eq_empty (*‹(cball (?x::?'a) (?e::real) = {}) = (?e < (0::real))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) continuous_on_compose2[OF continuous_derivative] (*‹⟦continuous_on (?s::?'c set) (?f::?'c ⇒ 'a); ?f ` ?s ⊆ (X::'a set)⟧ ⟹ continuous_on ?s (λx::?'c. (f'::'a ⇒ 'a ⇒⇩L 'a) (?f x))›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*))[1]) (*discuss goal 3*) apply ((auto simp: convex_cball (*‹convex (cball ?x ?e)›*) cball_eq_empty (*‹(cball ?x ?e = {}) = (?e < 0)›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) continuous_on_compose2[OF continuous_derivative] (*‹⟦continuous_on ?s ?f; ?f ` ?s ⊆ X⟧ ⟹ continuous_on ?s (λx. f' (?f x))›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*))[1]) (*discuss goal 4*) apply ((auto simp: convex_cball (*‹convex (cball (?x::?'a) (?e::real))›*) cball_eq_empty (*‹(cball (?x::?'a) (?e::real) = {}) = (?e < (0::real))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) continuous_on_compose2[OF continuous_derivative] (*‹⟦continuous_on (?s::?'c set) (?f::?'c ⇒ 'a); ?f ` ?s ⊆ (X::'a set)⟧ ⟹ continuous_on ?s (λx::?'c. (f'::'a ⇒ 'a ⇒⇩L 'a) (?f x))›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*))[1]) (*discuss goal 5*) apply ((auto simp: convex_cball (*‹convex (cball (?x::?'a) (?e::real))›*) cball_eq_empty (*‹(cball (?x::?'a) (?e::real) = {}) = (?e < (0::real))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) continuous_on_compose2[OF continuous_derivative] (*‹⟦continuous_on (?s::?'c set) (?f::?'c ⇒ 'a); ?f ` ?s ⊆ (X::'a set)⟧ ⟹ continuous_on ?s (λx::?'c. (f'::'a ⇒ 'a ⇒⇩L 'a) (?f x))›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*))[1]) (*discuss goal 6*) apply ((auto simp: convex_cball (*‹convex (cball (?x::?'a) (?e::real))›*) cball_eq_empty (*‹(cball (?x::?'a) (?e::real) = {}) = (?e < (0::real))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) intro!: derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) continuous_on_compose2[OF continuous_derivative] (*‹⟦continuous_on (?s::?'c set) (?f::?'c ⇒ 'a); ?f ` ?s ⊆ (X::'a set)⟧ ⟹ continuous_on ?s (λx::?'c. (f'::'a ⇒ 'a ⇒⇩L 'a) (?f x))›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*))[1]) (*proven 6 subgoals*) . have "onorm_bound-lipschitz_on ?X f" using lipschitz[of t] (*‹(t::real) ∈ cball t (u::real) ⟹ onorm_bound-lipschitz_on (cball (x::'a) (v::real)) (f::'a ⇒ 'a)›*) uv (*‹cball (t::real) (u::real) ⊆ UNIV› ‹cball x v ⊆ X› ‹0 < u› ‹0 < v›*) by auto thus "∃u>0. ∃L. ∀t ∈ cball t u ∩ UNIV. L-lipschitz_on (cball x u ∩ X) f" apply (intro exI[where x=v] (*‹?P v ⟹ ∃x. ?P x›*)) (*goal: ‹∃u>0. ∃L. ∀t∈cball t u ∩ UNIV. L-lipschitz_on (cball x u ∩ X) f›*) by (auto intro!: exI[where x=onorm_bound] (*‹(?P::real ⇒ bool) onorm_bound ⟹ ∃x::real. ?P x›*) ‹0 < v› simp: Int_absorb2 (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ ?A ∩ ?B = ?A›*) uv (*‹cball (t::real) (u::real) ⊆ UNIV› ‹cball (x::'a) (v::real) ⊆ (X::'a set)› ‹(0::real) < (u::real)› ‹(0::real) < (v::real)›*)) qed (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 275 facts*)) (*solved the remaining goal: ‹open X›*) end ― ‹@{thm derivative_rhs}› locale c1_on_open_euclidean = c1_on_open f f' X for f::"'a::euclidean_space ⇒ _" and f' X begin lemma c1_on_open_euclidean_anchor: True by standard definition "vareq x0 t = f' (flow0 x0 t)" interpretation var: ll_on_open "existence_ivl0 x0" "vareq x0" UNIV apply standard (*goal: ‹ll_on_open (existence_ivl0 x0) (λx. blinfun_apply (vareq x0 x)) UNIV›*) apply (auto intro!: c1_implies_local_lipschitz[where f' = "λ(t, x). vareq x0 t"] (*‹⟦⋀t x. ⟦t ∈ ?T; x ∈ ?X⟧ ⟹ (?f t has_derivative blinfun_apply (case (t, x) of (t, x) ⇒ vareq x0 t)) (at x); continuous_on (?T × ?X) (λ(t, x). vareq x0 t); open ?T; open ?X⟧ ⟹ local_lipschitz ?T ?X ?f›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 278 facts*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*) vareq_def (*‹vareq ?x0.0 ?t = f' (flow0 ?x0.0 ?t)›*)) (*top goal: ‹is_interval (existence_ivl0 x0)› and 4 goals remain*) using local.mem_existence_ivl_iv_defined(2) (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ ?x0.0 ∈ X›*) apply blast (*top goal: ‹⋀a. a ∈ existence_ivl0 x0 ⟹ x0 ∈ X› and 3 goals remain*) using local.existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*) local.mem_existence_ivl_iv_defined(2) (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ ?x0.0 ∈ X›*) apply blast (*top goal: ‹⋀a. a ∈ existence_ivl0 x0 ⟹ flow0 x0 a ∈ X› and 2 goals remain*) using local.mem_existence_ivl_iv_defined(2) (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ ?x0.0 ∈ X›*) apply blast (*top goal: ‹⋀xa::real. xa ∈ existence_ivl0 (x0::'a) ⟹ x0 ∈ (X::'a set)› and 1 goal remains*) using local.existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*) local.mem_existence_ivl_iv_defined(2) (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a::euclidean_space) ⟹ ?x0.0 ∈ (X::'a::euclidean_space set)›*) by blast context begin lemma continuous_on_A[continuous_intros]: assumes "continuous_on S a" assumes "continuous_on S b" assumes "⋀s. s ∈ S ⟹ a s ∈ X" assumes "⋀s. s ∈ S ⟹ b s ∈ existence_ivl0 (a s)" shows "continuous_on S (λs. vareq (a s) (b s))" proof (-) (*goal: ‹continuous_on (S::'b::topological_space set) (λs::'b::topological_space. vareq ((a::'b::topological_space ⇒ 'a::euclidean_space) s) ((b::'b::topological_space ⇒ real) s))›*) have "continuous_on S (λx. f' (flow0 (a x) (b x)))" by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 280 facts*) assms (*‹continuous_on S a› ‹continuous_on S b› ‹?s ∈ S ⟹ a ?s ∈ X› ‹?s ∈ S ⟹ b ?s ∈ existence_ivl0 (a ?s)›*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*)) then show "?thesis" (*goal: ‹continuous_on S (λs. vareq (a s) (b s))›*) apply (rule continuous_on_eq (*‹⟦continuous_on (?S::?'a set) (?f::?'a ⇒ ?'b); ⋀x::?'a. x ∈ ?S ⟹ ?f x = (?g::?'a ⇒ ?'b) x⟧ ⟹ continuous_on ?S ?g›*)) (*goal: ‹continuous_on S (λs. vareq (a s) (b s))›*) by (auto simp: assms (*‹continuous_on S a› ‹continuous_on S b› ‹?s ∈ S ⟹ a ?s ∈ X› ‹?s ∈ S ⟹ b ?s ∈ existence_ivl0 (a ?s)›*) vareq_def (*‹vareq ?x0.0 ?t = f' (flow0 ?x0.0 ?t)›*)) qed lemmas [intro] = mem_existence_ivl_iv_defined context fixes x0::'a begin lemma flow0_defined: "xa ∈ existence_ivl0 x0 ⟹ flow0 x0 xa ∈ X" by (auto simp: flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*)) lemma continuous_on_flow0: "continuous_on (existence_ivl0 x0) (flow0 x0)" by (auto simp: intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 281 facts*)) lemmas continuous_on_flow0_comp[continuous_intros] = continuous_on_compose2[OF continuous_on_flow0] lemma varexivl_eq_exivl: assumes "t ∈ existence_ivl0 x0" shows "var.existence_ivl x0 t a = existence_ivl0 x0" sorry definition "vector_Dflow u0 t ≡ var.flow x0 0 u0 t" qualified abbreviation "Y z t ≡ flow0 (x0 + z) t" text ‹Linearity of the solution to the variational equation. TODO: generalize this and some other things for arbitrary linear ODEs› lemma vector_Dflow_linear: assumes "t ∈ existence_ivl0 x0" shows "vector_Dflow (α *⇩R a + β *⇩R b) t = α *⇩R vector_Dflow a t + β *⇩R vector_Dflow b t" proof (-) (*goal: ‹vector_Dflow (α *⇩R a + β *⇩R b) t = α *⇩R vector_Dflow a t + β *⇩R vector_Dflow b t›*) note mem_existence_ivl_iv_defined[OF assms, intro, simp] (*‹(0::real) ∈ UNIV› ‹x0 ∈ X›*) have "((λc. α *⇩R var.flow x0 0 a c + β *⇩R var.flow x0 0 b c) solves_ode (λx. vareq x0 x)) (existence_ivl0 x0) UNIV" by (auto intro!: derivative_intros (*‹((λx. x) has_derivative (λx. x)) ?F› ‹(id has_derivative id) ?F› ‹((λx. ?c) has_derivative (λx. 0)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?r *⇩R ?g x) has_derivative (λx. ?r *⇩R ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x *⇩R ?x) has_derivative (λx. ?g' x *⇩R ?x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?x * ?g x) has_derivative (λx. ?x * ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x * ?y) has_derivative (λx. ?g' x * ?y)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. of_real (?g x)) has_derivative (λx. of_real (?g' x))) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x + ?g x) has_derivative (λx. ?f' x + ?g' x)) ?F› ‹(⋀i. i ∈ ?I ⟹ (?f i has_derivative ?f' i) ?F) ⟹ ((λx. ∑i∈?I. ?f i x) has_derivative (λx. ∑i∈?I. ?f' i x)) ?F› ‹(?f has_derivative ?f') ?F ⟹ ((λx. - ?f x) has_derivative (λx. - ?f' x)) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x - ?g x) has_derivative (λx. ?f' x - ?g' x)) ?F› and more 209 facts*) var.flow_has_vector_derivative (*‹?t ∈ var.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ (var.flow ?x0a ?t0.0 ?x0.0 has_vector_derivative blinfun_apply (vareq ?x0a ?t) (var.flow ?x0a ?t0.0 ?x0.0 ?t)) (at ?t)›*) solves_odeI (*‹⟦(?y has_vderiv_on (λt. ?f t (?y t))) ?T; ⋀t. t ∈ ?T ⟹ ?y t ∈ ?X⟧ ⟹ (?y solves_ode ?f) ?T ?X›*) simp: blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*) varexivl_eq_exivl (*‹?t ∈ existence_ivl0 x0 ⟹ var.existence_ivl x0 ?t ?a = existence_ivl0 x0›*) vareq_def[symmetric] (*‹f' (flow0 ?x0.0 ?t) = vareq ?x0.0 ?t›*)) moreover have "α *⇩R var.flow x0 0 a 0 + β *⇩R var.flow x0 0 b 0 = α *⇩R a + β *⇩R b" by simp moreover note is_interval_existence_ivl[of x0] (*‹is_interval (existence_ivl0 x0)›*) ultimately show "?thesis" (*goal: ‹vector_Dflow (α *⇩R a + β *⇩R b) t = α *⇩R vector_Dflow a t + β *⇩R vector_Dflow b t›*) unfolding vareq_def[symmetric] vector_Dflow_def (*goal: ‹var.flow (x0::'a::euclidean_space) (0::real) ((α::real) *⇩R (a::'a::euclidean_space) + (β::real) *⇩R (b::'a::euclidean_space)) (t::real) = α *⇩R var.flow x0 (0::real) a t + β *⇩R var.flow x0 (0::real) b t›*) apply (rule var.maximal_existence_flow (*‹⟦(?x solves_ode (λx. blinfun_apply (vareq ?x0a x))) ?K UNIV; ?x ?t0.0 = ?x0.0; is_interval ?K; ?t0.0 ∈ ?K; ?K ⊆ existence_ivl0 ?x0a⟧ ⟹ ?K ⊆ var.existence_ivl ?x0a ?t0.0 ?x0.0› ‹⟦(?x solves_ode (λx. blinfun_apply (vareq ?x0a x))) ?K UNIV; ?x ?t0.0 = ?x0.0; is_interval ?K; ?t0.0 ∈ ?K; ?K ⊆ existence_ivl0 ?x0a; ?t ∈ ?K⟧ ⟹ var.flow ?x0a ?t0.0 ?x0.0 ?t = ?x ?t›*)) (*goals: 1. ‹0 ∈ existence_ivl0 x0› 2. ‹existence_ivl0 x0 ⊆ existence_ivl0 x0› 3. ‹t ∈ existence_ivl0 x0› discuss goal 1*) apply ((auto simp: assms (*‹t ∈ existence_ivl0 x0›*))[1]) (*discuss goal 2*) apply ((auto simp: assms (*‹t ∈ existence_ivl0 x0›*))[1]) (*discuss goal 3*) apply ((auto simp: assms (*‹t ∈ existence_ivl0 x0›*))[1]) (*proven 3 subgoals*) . qed lemma linear_vector_Dflow: assumes "t ∈ existence_ivl0 x0" shows "linear (λz. vector_Dflow z t)" using vector_Dflow_linear[OF assms, of 1 _ 1] (*‹vector_Dflow (1 *⇩R ?a + 1 *⇩R ?b) t = 1 *⇩R vector_Dflow ?a t + 1 *⇩R vector_Dflow ?b t›*) vector_Dflow_linear[OF assms, of _ _ 0] (*‹vector_Dflow (?α *⇩R ?a + 0 *⇩R ?b) t = ?α *⇩R vector_Dflow ?a t + 0 *⇩R vector_Dflow ?b t›*) by (auto intro!: linearI (*‹⟦⋀b1 b2. ?f (b1 + b2) = ?f b1 + ?f b2; ⋀r b. ?f (r *⇩R b) = r *⇩R ?f b⟧ ⟹ linear ?f›*)) lemma bounded_linear_vector_Dflow: assumes "t ∈ existence_ivl0 x0" shows "bounded_linear (λz. vector_Dflow z t)" by (simp add: linear_linear (*‹bounded_linear ?f = linear ?f›*) linear_vector_Dflow (*‹?t ∈ existence_ivl0 x0 ⟹ linear (λz. vector_Dflow z ?t)›*) assms (*‹t ∈ existence_ivl0 x0›*)) lemma vector_Dflow_continuous_on_time: "x0 ∈ X ⟹ continuous_on (existence_ivl0 x0) (λt. vector_Dflow z t)" using var.flow_continuous_on[of x0 0 z] (*‹continuous_on (var.existence_ivl x0 0 z) (var.flow x0 0 z)›*) varexivl_eq_exivl (*‹?t ∈ existence_ivl0 x0 ⟹ var.existence_ivl x0 ?t ?a = existence_ivl0 x0›*) unfolding vector_Dflow_def (*goal: ‹x0 ∈ X ⟹ continuous_on (existence_ivl0 x0) (var.flow x0 0 z)›*) by (auto simp:) proposition proposition_17_6_weak: ― ‹from "Differential Equations, Dynamical Systems, and an Introduction to Chaos", Hirsch/Smale/Devaney› assumes "t ∈ existence_ivl0 x0" shows "(λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─ x0 → 0" proof (-) (*goal: ‹(λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0›*) note x0_def = mem_existence_ivl_iv_defined[OF assms] (*‹(0::real) ∈ UNIV› ‹x0 ∈ X›*) have "0 ∈ existence_ivl0 x0" by (simp add: x0_def (*‹0 ∈ UNIV› ‹x0 ∈ X›*)) text ‹Find some ‹J ⊆ existence_ivl0 x0› with ‹0 ∈ J› and ‹t ∈ J›.› define t0 where "t0 ≡ min 0 t" define t1 where "t1 ≡ max 0 t" define J where "J ≡ {t0..t1}" have "t0 ≤ 0" "0 ≤ t1" "0 ∈ J" "J ≠ {}" "t ∈ J" "compact J" and J_in_existence: "J ⊆ existence_ivl0 x0" using ivl_subset_existence_ivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {0..?t} ⊆ existence_ivl0 ?x0.0›*) ivl_subset_existence_ivl' (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {?t..0} ⊆ existence_ivl0 ?x0.0›*) x0_def (*‹0 ∈ UNIV› ‹(x0::'a::euclidean_space) ∈ (X::'a::euclidean_space set)›*) assms (*‹t ∈ existence_ivl0 x0›*) apply - (*goals: 1. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ t0 ≤ 0› 2. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ 0 ≤ t1› 3. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ 0 ∈ J› 4. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ J ≠ {}› 5. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ t ∈ J› 6. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ compact J› 7. ‹⟦⋀t x0. t ∈ existence_ivl0 x0 ⟹ {0..t} ⊆ existence_ivl0 x0; ⋀t x0. t ∈ existence_ivl0 x0 ⟹ {t..0} ⊆ existence_ivl0 x0; 0 ∈ UNIV; x0 ∈ X; t ∈ existence_ivl0 x0⟧ ⟹ J ⊆ existence_ivl0 x0› discuss goal 1*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 2*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 3*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 4*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 5*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 6*) apply ((auto simp add: J_def (*‹J::real set ≡ {t0::real..t1::real}›*) t0_def (*‹t0::real ≡ min (0::real) (t::real)›*) t1_def (*‹t1::real ≡ max (0::real) (t::real)›*) min_def (*‹min (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max (?a::?'a) (?b::?'a) = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*discuss goal 7*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*) max_def (*‹max ?a ?b = (if ?a ≤ ?b then ?b else ?a)›*))[1]) (*proven 7 subgoals*) . { fix z and S assume assms: "x0 + z ∈ X" "S ⊆ existence_ivl0 (x0 + z)" (*‹(x0::'a) + (z::'a) ∈ (X::'a set)› ‹(S::real set) ⊆ existence_ivl0 ((x0::'a) + (z::'a))›*) have "continuous_on S (Y z)" using flow_continuous_on (*‹continuous_on (existence_ivl0 ?x0.0) (flow0 ?x0.0)›*) assms(1) (*‹(x0::'a::euclidean_space) + (z::'a::euclidean_space) ∈ (X::'a::euclidean_space set)›*) apply (intro continuous_on_subset[OF _ assms(2)] (*‹continuous_on (existence_ivl0 (x0 + z)) ?f ⟹ continuous_on S ?f›*)) (*goal: ‹continuous_on (S::real set) (Y (z::'a::euclidean_space))›*) by (simp add:) } note [continuous_intros] = this (*‹⟦(x0::'a::euclidean_space) + (?z2::'a::euclidean_space) ∈ (X::'a::euclidean_space set); (?S2::real set) ⊆ existence_ivl0 (x0 + ?z2)⟧ ⟹ continuous_on ?S2 (Y ?z2)›*) integrable_continuous_real (*‹continuous_on {?a..?b} ?f ⟹ ?f integrable_on {?a..?b}›*) blinfun.continuous_on (*‹⟦continuous_on ?s ?f; continuous_on ?s ?g⟧ ⟹ continuous_on ?s (λx. blinfun_apply (?f x) (?g x))›*) have U_continuous[continuous_intros]: "⋀z. continuous_on J (vector_Dflow z)" by (rule continuous_on_subset[OF vector_Dflow_continuous_on_time[OF ‹x0 ∈ X›] J_in_existence] (*‹continuous_on J (vector_Dflow ?z1)›*)) from ‹t ∈ J› (*‹(t::real) ∈ (J::real set)›*) have "t0 ≤ t" and "t ≤ t1" and "t0 ≤ t1" and "t0 ∈ existence_ivl0 x0" and "t ∈ existence_ivl0 x0" and "t1 ∈ existence_ivl0 x0" using J_def (*‹J ≡ {t0..t1}›*) J_in_existence (*‹J ⊆ existence_ivl0 x0›*) apply - (*goals: 1. ‹⟦(t::real) ∈ (J::real set); J ≡ {t0::real..t1::real}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ t0 ≤ t› 2. ‹⟦(t::real) ∈ (J::real set); J ≡ {t0::real..t1::real}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ t ≤ t1› 3. ‹⟦(t::real) ∈ (J::real set); J ≡ {t0::real..t1::real}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ t0 ≤ t1› 4. ‹⟦(t::real) ∈ (J::real set); J ≡ {t0::real..t1::real}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ t0 ∈ existence_ivl0 x0› 5. ‹⟦(t::real) ∈ (J::real set); J ≡ {t0::real..t1::real}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ t ∈ existence_ivl0 x0› 6. ‹⟦(t::real) ∈ (J::real set); J ≡ {t0::real..t1::real}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ t1 ∈ existence_ivl0 x0› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . from global_existence_ivl_explicit[OF ‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0› ‹t0 ≤ t1›] (*‹(⋀d K. ⟦0 < d; 0 < K; ball x0 d ⊆ X; ⋀y. y ∈ ball x0 d ⟹ t0 ∈ existence_ivl0 y; ⋀y. y ∈ ball x0 d ⟹ t1 ∈ existence_ivl0 y; ⋀t y. ⟦y ∈ ball x0 d; t ∈ {t0..t1}⟧ ⟹ dist (flow0 x0 t) (flow0 y t) ≤ dist x0 y * exp (K * ¦t¦)⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain u and K where uK_def: "0 < u" "0 < K" "ball x0 u ⊆ X" "⋀y. y ∈ ball x0 u ⟹ t0 ∈ existence_ivl0 y" "⋀y. y ∈ ball x0 u ⟹ t1 ∈ existence_ivl0 y" "⋀t y. y ∈ ball x0 u ⟹ t ∈ J ⟹ dist (flow0 x0 t) (Y (y - x0) t) ≤ dist x0 y * exp (K * ¦t¦)" (*goal: ‹(⋀u K. ⟦0 < u; 0 < K; ball x0 u ⊆ X; ⋀y. y ∈ ball x0 u ⟹ t0 ∈ existence_ivl0 y; ⋀y. y ∈ ball x0 u ⟹ t1 ∈ existence_ivl0 y; ⋀t y. ⟦y ∈ ball x0 u; t ∈ J⟧ ⟹ dist (flow0 x0 t) (Y (y - x0) t) ≤ dist x0 y * exp (K * ¦t¦)⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp add: J_def (*‹J::real set ≡ {t0::real..t1::real}›*)) have J_in_existence_ivl: "⋀y. y ∈ ball x0 u ⟹ J ⊆ existence_ivl0 y" unfolding J_def (*goal: ‹⋀y. y ∈ ball x0 u ⟹ {t0..t1} ⊆ existence_ivl0 y›*) using uK_def (*‹0 < u› ‹0 < K› ‹ball x0 u ⊆ X› ‹?y ∈ ball x0 u ⟹ t0 ∈ existence_ivl0 ?y› ‹?y ∈ ball x0 u ⟹ t1 ∈ existence_ivl0 ?y› ‹⟦(?y::'a) ∈ ball (x0::'a) (u::real); (?t::real) ∈ (J::real set)⟧ ⟹ dist (flow0 x0 ?t) (Y (?y - x0) ?t) ≤ dist x0 ?y * exp ((K::real) * ¦?t¦)›*) by (simp add: real_Icc_closed_segment (*‹?a ≤ ?b ⟹ {?a..?b} = {?a--?b}›*) segment_subset_existence_ivl (*‹⟦?s ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 ?x0.0⟧ ⟹ {?s--?t} ⊆ existence_ivl0 ?x0.0›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*)) have ball_in_X: "⋀z. z ∈ ball 0 u ⟹ x0 + z ∈ X" using uK_def(3) (*‹ball x0 u ⊆ X›*) by (auto simp: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) have flow0_J_props: "flow0 x0 ` J ≠ {}" "compact (flow0 x0 ` J)" "flow0 x0` J ⊆ X" using ‹t0 ≤ t1› (*‹t0 ≤ t1›*) using J_def(1) (*‹J ≡ {t0..t1}›*) J_in_existence (*‹(J::real set) ⊆ existence_ivl0 (x0::'a)›*) apply - (*goals: 1. ‹⟦(t0::real) ≤ (t1::real); J::real set ≡ {t0..t1}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ flow0 x0 ` J ≠ {}› 2. ‹⟦(t0::real) ≤ (t1::real); J::real set ≡ {t0..t1}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ compact (flow0 x0 ` J)› 3. ‹⟦(t0::real) ≤ (t1::real); J::real set ≡ {t0..t1}; J ⊆ existence_ivl0 (x0::'a)⟧ ⟹ flow0 x0 ` J ⊆ (X::'a set)› discuss goal 1*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*))[1]) (*discuss goal 2*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*))[1]) (*discuss goal 3*) apply ((auto simp add: J_def (*‹J::real set ≡ {t0::real..t1::real}›*) intro!: compact_continuous_image (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); compact ?s⟧ ⟹ compact (?f ` ?s)›*) continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) flow_in_domain (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 ?x0.0 ?t ∈ (X::'a set)›*))[1]) (*proven 3 subgoals*) . have [continuous_intros]: "continuous_on J (λs. f' (flow0 x0 s))" using J_in_existence (*‹J ⊆ existence_ivl0 x0›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) simp:) text ‹ Show the thesis via cases ‹t = 0›, ‹0 < t› and ‹t < 0›. › show "?thesis" (*goal: ‹(λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0›*) proof (cases "t = 0") (*goals: 1. ‹t = 0 ⟹ (λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0› 2. ‹t ≠ 0 ⟹ (λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0›*) assume "t = 0" (*‹(t::real) = (0::real)›*) show "?thesis" (*goal: ‹(λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0›*) unfolding ‹t = 0› Lim_at (*goal: ‹∀e>0::real. ∃d>0::real. ∀x::'a. (0::real) < dist x (x0::'a) ∧ dist x x0 < d ⟶ dist ((Y (x - x0) (0::real) - flow0 x0 (0::real) - vector_Dflow (x - x0) (0::real)) /⇩R norm (x - x0)) (0::'a) < e›*) apply (simp add: dist_norm[of _ 0] (*‹dist ?x 0 = norm (?x - 0)›*) del: zero_less_dist_iff (*‹(0 < dist ?x ?y) = (?x ≠ ?y)›*)) (*goal: ‹∀e>0. ∃d>0. ∀x. 0 < dist x x0 ∧ dist x x0 < d ⟶ dist ((Y (x - x0) 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) /⇩R norm (x - x0)) 0 < e›*) apply safe (*goal: ‹∀e>0. ∃d>0. ∀x. x ≠ x0 ∧ dist x x0 < d ⟶ inverse (norm (x - x0)) * norm (flow0 x 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) < e›*) apply (rule exI (*‹(?P::?'a ⇒ bool) (?x::?'a) ⟹ ∃x::?'a. ?P x›*)) (*goal: ‹⋀e. 0 < e ⟹ ∃d>0. ∀x. x ≠ x0 ∧ dist x x0 < d ⟶ inverse (norm (x - x0)) * norm (flow0 x 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) < e›*) apply (rule conjI[OF ‹0 < u›] (*‹?Q ⟹ 0 < u ∧ ?Q›*)) (*goal: ‹⋀e. 0 < e ⟹ 0 < ?d7 e ∧ (∀x. x ≠ x0 ∧ dist x x0 < ?d7 e ⟶ inverse (norm (x - x0)) * norm (flow0 x 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) < e)›*) proof (safe) (*goal: ‹⋀e x. ⟦0 < e; x ≠ x0; dist x x0 < u⟧ ⟹ inverse (norm (x - x0)) * norm (flow0 x 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) < e›*) fix e :: real and x assume "0 < e" "dist x x0 < u" (*‹(0::real) < (e::real)› ‹dist (x::'a) (x0::'a) < (u::real)›*) hence "x ∈ X" using uK_def(3) (*‹ball x0 u ⊆ X›*) by (auto simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) hence "inverse (norm (x - x0)) * norm (Y (x - x0) 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) = 0" using x0_def (*‹(0::real) ∈ UNIV› ‹x0 ∈ X›*) by (simp add: vector_Dflow_def (*‹vector_Dflow ?u0.0 ?t ≡ var.flow x0 0 ?u0.0 ?t›*)) thus "inverse (norm (x - x0)) * norm (flow0 x 0 - flow0 x0 0 - vector_Dflow (x - x0) 0) < e" using ‹0 < e› (*‹0 < e›*) by auto qed next (*goal: ‹t ≠ 0 ⟹ (λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0›*) assume "t ≠ 0" (*‹(t::real) ≠ (0::real)›*) show "?thesis" (*goal: ‹(λy::'a. (Y (y - (x0::'a)) (t::real) - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ (0::'a)›*) apply (unfold Lim_at (*‹?f ─?a→ ?l = (∀e>0. ∃d>0. ∀x. 0 < dist x ?a ∧ dist x ?a < d ⟶ dist (?f x) ?l < e)›*)) (*goal: ‹(λy. (Y (y - x0) t - flow0 x0 t - vector_Dflow (y - x0) t) /⇩R norm (y - x0)) ─x0→ 0›*) proof (safe) (*goal: ‹⋀e::real. (0::real) < e ⟹ ∃d>0::real. ∀x::'a. (0::real) < dist x (x0::'a) ∧ dist x x0 < d ⟶ dist ((Y (x - x0) (t::real) - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) (0::'a) < e›*) fix e :: real assume "0 < e" (*‹(0::real) < (e::real)›*) then obtain e' where "0 < e'" "e' < e" (*goal: ‹(⋀e'. ⟦0 < e'; e' < e⟧ ⟹ thesis) ⟹ thesis›*) using dense (*‹(?x::?'a) < (?y::?'a) ⟹ ∃z>?x. z < ?y›*) by auto obtain N where N_ge_SupS: "Sup { norm (f' (flow0 x0 s)) |s. s ∈ J } ≤ N" (is "Sup ?S ≤ N") and N_gr_0: "0 < N" (*goal: ‹(⋀N. ⟦Sup {norm (f' (flow0 x0 s)) |s. s ∈ J} ≤ N; 0 < N⟧ ⟹ thesis) ⟹ thesis›*) by (meson le_cases (*‹⟦?x ≤ ?y ⟹ ?P; ?y ≤ ?x ⟹ ?P⟧ ⟹ ?P›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) linordered_field_no_ub (*‹∀x. ∃y. x < y›*)) have N_ineq: "⋀s. s ∈ J ⟹ norm (f' (flow0 x0 s)) ≤ N" proof (-) (*goal: ‹⋀s::real. s ∈ (J::real set) ⟹ norm ((f'::'a ⇒ 'a ⇒⇩L 'a) (flow0 (x0::'a) s)) ≤ (N::real)›*) fix s assume "s ∈ J" (*‹(s::real) ∈ (J::real set)›*) have "?S = (norm o f' o flow0 x0) ` J" by auto moreover have "continuous_on J (norm o f' o flow0 x0)" using J_in_existence (*‹J ⊆ existence_ivl0 x0›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 287 facts*)) ultimately have "∃a b. ?S = {a..b} ∧ a ≤ b" using continuous_image_closed_interval[OF ‹t0 ≤ t1›] (*‹continuous_on {t0..t1} ?f ⟹ ∃c d. ?f ` {t0..t1} = {c..d} ∧ c ≤ d›*) by (simp add: J_def (*‹J ≡ {t0..t1}›*)) then obtain a and b where "?S = {a..b}" and "a ≤ b" (*goal: ‹(⋀a b. ⟦{norm (f' (flow0 x0 s)) |s. s ∈ J} = {a..b}; a ≤ b⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "bdd_above ?S" by simp from ‹s ∈ J› (*‹s ∈ J›*) cSup_upper[OF _ this] (*‹?x ∈ {norm (f' (flow0 x0 s)) |s. s ∈ J} ⟹ ?x ≤ Sup {norm (f' (flow0 x0 s)) |s. s ∈ J}›*) have "norm (f' (flow0 x0 s)) ≤ Sup ?S" by auto thus "norm (f' (flow0 x0 s)) ≤ N" using N_ge_SupS (*‹Sup {norm ((f'::'a ⇒ 'a ⇒⇩L 'a) (flow0 (x0::'a) s)) |s::real. s ∈ (J::real set)} ≤ (N::real)›*) by simp qed text ‹ Define a small region around ‹flow0 ` J›, that is a subset of the domain ‹X›. › from compact_in_open_separated[OF flow0_J_props ( 1 , 2 ) auto_open_domain flow0_J_props ( 3 )] (*‹(⋀e. ⟦0 < e; {x. infdist x (flow0 x0 ` J) ≤ e} ⊆ X⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain e_domain where e_domain_def: "0 < e_domain" "{x. infdist x (flow0 x0 ` J) ≤ e_domain} ⊆ X" (*goal: ‹(⋀e_domain. ⟦0 < e_domain; {x. infdist x (flow0 x0 ` J) ≤ e_domain} ⊆ X⟧ ⟹ thesis) ⟹ thesis›*) by auto define G where "G ≡ {x∈X. infdist x (flow0 x0 ` J) < e_domain}" have G_vimage: "G = ((λx. infdist x (flow0 x0 ` J)) -` {..<e_domain}) ∩ X" by (auto simp: G_def (*‹G ≡ {x ∈ X. infdist x (flow0 x0 ` J) < e_domain}›*)) have "open G" "G ⊆ X" unfolding G_vimage (*goals: 1. ‹open ((λx. infdist x (flow0 x0 ` J)) -` {..<e_domain} ∩ X)› 2. ‹(λx. infdist x (flow0 x0 ` J)) -` {..<e_domain} ∩ X ⊆ X›*) (*goals: 1. ‹open ((λx::'a. infdist x (flow0 (x0::'a) ` (J::real set))) -` {..<e_domain::real} ∩ (X::'a set))› 2. ‹(λx::'a. infdist x (flow0 (x0::'a) ` (J::real set))) -` {..<e_domain::real} ∩ (X::'a set) ⊆ X› discuss goal 1*) apply ((auto intro!: open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*) open_vimage (*‹⟦open ?s; continuous_on UNIV ?f⟧ ⟹ open (?f -` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 287 facts*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*))[1]) (*discuss goal 2*) apply ((auto intro!: open_Int (*‹⟦open ?S; open ?T⟧ ⟹ open (?S ∩ ?T)›*) open_vimage (*‹⟦open ?s; continuous_on UNIV ?f⟧ ⟹ open (?f -` ?s)›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 287 facts*) continuous_at_imp_continuous_on (*‹∀x∈?s. isCont ?f x ⟹ continuous_on ?s ?f›*))[1]) (*proven 2 subgoals*) . text ‹Define a compact subset H of G. Inside H, we can guarantee an upper bound on the Taylor remainder.› define e_domain2 where "e_domain2 ≡ e_domain / 2" have "e_domain2 > 0" "e_domain2 < e_domain" using ‹e_domain > 0› (*‹0 < e_domain›*) apply - (*goals: 1. ‹0 < e_domain ⟹ 0 < e_domain2› 2. ‹0 < e_domain ⟹ e_domain2 < e_domain› discuss goal 1*) apply (simp add: e_domain2_def (*‹e_domain2 ≡ e_domain / 2›*)) (*discuss goal 2*) apply (simp add: e_domain2_def (*‹e_domain2 ≡ e_domain / 2›*)) (*proven 2 subgoals*) . define H where "H ≡ {x. infdist x (flow0 x0 ` J) ≤ e_domain2}" have H_props: "H ≠ {}" "compact H" "H ⊆ G" proof (-) (*goals: 1. ‹(H::'a set) ≠ {}› 2. ‹compact (H::'a set)› 3. ‹(H::'a set) ⊆ (G::'a set)›*) have "x0 ∈ flow0 x0 ` J" unfolding image_iff (*goal: ‹∃x::real∈J::real set. (x0::'a) = flow0 x0 x›*) using ‹0 ∈ J› (*‹0 ∈ J›*) x0_def (*‹(0::real) ∈ UNIV› ‹(x0::'a) ∈ (X::'a set)›*) by force hence "x0 ∈ H" using ‹0 < e_domain2› (*‹0 < e_domain2›*) by (simp add: H_def (*‹H::'a::euclidean_space set ≡ {x::'a::euclidean_space. infdist x (flow0 (x0::'a::euclidean_space) ` (J::real set)) ≤ (e_domain2::real)}›*) x0_def (*‹(0::real) ∈ UNIV› ‹(x0::'a::euclidean_space) ∈ (X::'a::euclidean_space set)›*)) thus "H ≠ {}" by auto next (*goals: 1. ‹compact (H::'a::euclidean_space set)› 2. ‹(H::'a::euclidean_space set) ⊆ (G::'a::euclidean_space set)›*) show "compact H" unfolding H_def (*goal: ‹compact {x. infdist x (flow0 x0 ` J) ≤ e_domain2}›*) using ‹0 < e_domain2› (*‹0 < e_domain2›*) flow0_J_props (*‹flow0 x0 ` J ≠ {}› ‹compact (flow0 (x0::'a::euclidean_space) ` (J::real set))› ‹flow0 (x0::'a::euclidean_space) ` (J::real set) ⊆ (X::'a::euclidean_space set)›*) apply (intro compact_infdist_le (*‹⟦?A ≠ {}; compact ?A; 0 < ?e⟧ ⟹ compact {x. infdist x ?A ≤ ?e}›*)) (*goals: 1. ‹⟦(0::real) < (e_domain2::real); flow0 (x0::'a) ` (J::real set) ≠ {}; compact (flow0 x0 ` J); flow0 x0 ` J ⊆ (X::'a set)⟧ ⟹ flow0 x0 ` J ≠ {}› 2. ‹⟦(0::real) < (e_domain2::real); flow0 (x0::'a) ` (J::real set) ≠ {}; compact (flow0 x0 ` J); flow0 x0 ` J ⊆ (X::'a set)⟧ ⟹ compact (flow0 x0 ` J)› 3. ‹⟦(0::real) < (e_domain2::real); flow0 (x0::'a) ` (J::real set) ≠ {}; compact (flow0 x0 ` J); flow0 x0 ` J ⊆ (X::'a set)⟧ ⟹ (0::real) < e_domain2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . next (*goal: ‹H ⊆ G›*) show "H ⊆ G" proof (standard) (*goal: ‹⋀x. x ∈ H ⟹ x ∈ G›*) fix x assume "x ∈ H" (*‹(x::'a) ∈ (H::'a set)›*) then have "*": "infdist x (flow0 x0 ` J) < e_domain" using ‹0 < e_domain› (*‹(0::real) < (e_domain::real)›*) by (simp add: H_def (*‹H ≡ {x. infdist x (flow0 x0 ` J) ≤ e_domain2}›*) e_domain2_def (*‹e_domain2 ≡ e_domain / 2›*)) then have "x ∈ X" using e_domain_def(2) (*‹{x. infdist x (flow0 x0 ` J) ≤ e_domain} ⊆ X›*) by auto with "*" (*‹infdist x (flow0 x0 ` J) < e_domain›*) show "x ∈ G" unfolding G_def (*goal: ‹(x::'a) ∈ {x::'a ∈ X::'a set. infdist x (flow0 (x0::'a) ` (J::real set)) < (e_domain::real)}›*) by auto qed qed have f'_cont_on_G: "(⋀x. x ∈ G ⟹ isCont f' x)" using continuous_on_interior[OF continuous_on_subset [ OF continuous_derivative ‹G ⊆ X› ]] (*‹?x ∈ interior G ⟹ isCont f' ?x›*) by (simp add: interior_open[OF ‹open G›] (*‹interior G = G›*)) define e1 where "e1 ≡ e' / (¦t¦ * exp (K * ¦t¦) * exp (N * ¦t¦))" have "0 < ¦t¦" using ‹t ≠ 0› (*‹t ≠ 0›*) by simp hence "0 < e1" using ‹0 < e'› (*‹0 < e'›*) by (simp add: e1_def (*‹e1::real ≡ (e'::real) / (¦t::real¦ * exp ((K::real) * ¦t¦) * exp ((N::real) * ¦t¦))›*)) text ‹ Taylor expansion of f on set G. › from uniform_explicit_remainder_Taylor_1[where f = f and f' = f', OF derivative_rhs [ OF subsetD [ OF ‹G ⊆ X› ] ] f'_cont_on_G ‹open G› H_props ‹0 < e1›] (*‹⟦⋀x::'a. x ∈ (G::'a set) ⟹ x ∈ G; ⋀x::'a. x ∈ G ⟹ x ∈ G; ⋀(d::real) R::'a ⇒ 'a ⇒ 'a. ⟦(0::real) < d; ⋀(x::'a) z::'a. (f::'a ⇒ 'a) z = f x + blinfun_apply ((f'::'a ⇒ 'a ⇒⇩L 'a) x) (z - x) + R x z; ⋀(x::'a) y::'a. ⟦x ∈ (H::'a set); y ∈ H; dist x y < d⟧ ⟹ norm (R x y) ≤ (e1::real) * dist x y; continuous_on (G × G) (λ(a::'a, b::'a). R a b)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*) obtain d_Taylor and R where Taylor_expansion: "0 < d_Taylor" "⋀x z. f z = f x + (f' x) (z - x) + R x z" "⋀x y. x ∈ H ⟹ y ∈ H ⟹ dist x y < d_Taylor ⟹ norm (R x y) ≤ e1 * dist x y" "continuous_on (G × G) (λ(a, b). R a b)" (*goal: ‹(⋀(d_Taylor::real) R::'a ⇒ 'a ⇒ 'a. ⟦(0::real) < d_Taylor; ⋀(x::'a) z::'a. (f::'a ⇒ 'a) z = f x + blinfun_apply ((f'::'a ⇒ 'a ⇒⇩L 'a) x) (z - x) + R x z; ⋀(x::'a) y::'a. ⟦x ∈ (H::'a set); y ∈ H; dist x y < d_Taylor⟧ ⟹ norm (R x y) ≤ (e1::real) * dist x y; continuous_on ((G::'a set) × G) (λ(a::'a, b::'a). R a b)⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto text ‹ Find d, such that solutions are always at least ‹min (e_domain/2) d_Taylor› apart, i.e. always in H. This later gives us the bound on the remainder. › have "0 < min (e_domain/2) d_Taylor" using ‹0 < d_Taylor› (*‹0 < d_Taylor›*) ‹0 < e_domain› (*‹0 < e_domain›*) by auto from uniform_limit_flow[OF ‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0› ‹t0 ≤ t1›, THEN uniform_limitD, OF this, unfolded eventually_at] (*‹∃d>0. ∀x∈UNIV. x ≠ x0 ∧ dist x x0 < d ⟶ (∀xa∈{t0..t1}. dist (flow0 x xa) (flow0 x0 xa) < min (e_domain / 2) d_Taylor)›*) obtain d_ivl where d_ivl_def: "0 < d_ivl" "⋀x. 0 < dist x x0 ⟹ dist x x0 < d_ivl ⟹ (∀t∈J. dist (flow0 x0 t) (Y (x - x0) t) < min (e_domain / 2) d_Taylor)" (*goal: ‹(⋀d_ivl. ⟦0 < d_ivl; ⋀x. ⟦0 < dist x x0; dist x x0 < d_ivl⟧ ⟹ ∀t∈J. dist (flow0 x0 t) (Y (x - x0) t) < min (e_domain / 2) d_Taylor⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*) J_def (*‹J ≡ {t0..t1}›*)) define d where "d ≡ min u d_ivl" have "0 < d" using ‹0 < u› (*‹(0::real) < (u::real)›*) ‹0 < d_ivl› (*‹0 < d_ivl›*) by (simp add: d_def (*‹d ≡ min u d_ivl›*)) hence "d ≤ u" "d ≤ d_ivl" (*goals: 1. ‹(d::real) ≤ (u::real)› 2. ‹(d::real) ≤ (d_ivl::real)› discuss goal 1*) apply ((auto simp: d_def (*‹d ≡ min u d_ivl›*))[1]) (*discuss goal 2*) apply ((auto simp: d_def (*‹d ≡ min u d_ivl›*))[1]) (*proven 2 subgoals*) . text ‹ Therefore, any flow0 starting in ‹ball x0 d› will be in G. › have Y_in_G: "⋀y. y ∈ ball x0 d ⟹ (λs. Y (y - x0) s) ` J ⊆ G" proof (standard) (*goal: ‹⋀y x. ⟦y ∈ ball x0 d; x ∈ Y (y - x0) ` J⟧ ⟹ x ∈ G›*) fix x and y assume assms: "y ∈ ball x0 d" "x ∈ (λs. Y (y - x0) s) ` J" (*‹(y::'a) ∈ ball (x0::'a) (d::real)› ‹(x::'a) ∈ Y ((y::'a) - (x0::'a)) ` (J::real set)›*) show "x ∈ G" proof (cases) (*goals: 1. ‹?P::bool ⟹ (x::'a) ∈ (G::'a set)› 2. ‹¬ (?P::bool) ⟹ (x::'a) ∈ (G::'a set)›*) assume "y = x0" (*‹(y::'a) = (x0::'a)›*) from assms(2) (*‹(x::'a) ∈ Y ((y::'a) - (x0::'a)) ` (J::real set)›*) have "x ∈ flow0 x0 ` J" by (simp add: ‹y = x0›) thus "x ∈ G" using ‹0 < e_domain› (*‹0 < e_domain›*) ‹flow0 x0 ` J ⊆ X› (*‹flow0 x0 ` J ⊆ X›*) by (auto simp: G_def (*‹G ≡ {x ∈ X. infdist x (flow0 x0 ` J) < e_domain}›*)) next (*goal: ‹y ≠ x0 ⟹ x ∈ G›*) assume "y ≠ x0" (*‹(y::'a) ≠ (x0::'a)›*) hence "0 < dist y x0" by (simp add: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) from d_ivl_def(2)[OF this] (*‹dist y x0 < d_ivl ⟹ ∀t∈J. dist (flow0 x0 t) (Y (y - x0) t) < min (e_domain / 2) d_Taylor›*) ‹d ≤ d_ivl› (*‹d ≤ d_ivl›*) ‹0 < e_domain› (*‹0 < e_domain›*) assms(1) (*‹y ∈ ball x0 d›*) have dist_flow0_Y: "⋀t. t ∈ J ⟹ dist (flow0 x0 t) (Y (y - x0) t) < e_domain" by (auto simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) from assms(2) (*‹(x::'a::euclidean_space) ∈ Y ((y::'a::euclidean_space) - (x0::'a::euclidean_space)) ` (J::real set)›*) obtain t where t_def: "t ∈ J" "x = Y (y - x0) t" (*goal: ‹(⋀t. ⟦t ∈ J; x = Y (y - x0) t⟧ ⟹ thesis) ⟹ thesis›*) by auto have "x ∈ X" unfolding t_def(2) (*goal: ‹Y (y - x0) t ∈ X›*) using uK_def(3) (*‹ball (x0::'a) (u::real) ⊆ (X::'a set)›*) assms(1) (*‹y ∈ ball x0 d›*) ‹d ≤ u› (*‹(d::real) ≤ (u::real)›*) subsetD[OF J_in_existence_ivl t_def ( 1 )] (*‹?y1 ∈ ball x0 u ⟹ t ∈ existence_ivl0 ?y1›*) by (auto simp: intro!: flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*)) have "flow0 x0 t ∈ flow0 x0 ` J" using t_def (*‹t ∈ J› ‹(x::'a) = Y ((y::'a) - (x0::'a)) (t::real)›*) by auto from dist_flow0_Y[OF t_def ( 1 )] (*‹dist (flow0 (x0::'a) (t::real)) (Y ((y::'a) - x0) t) < (e_domain::real)›*) have "dist x (flow0 x0 t) < e_domain" by (simp add: t_def( (*‹x = Y (y - x0) t›*) 2) dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) from le_less_trans[OF infdist_le [ OF ‹flow0 x0 t ∈ flow0 x0 ` J› ] this] (*‹infdist x (flow0 x0 ` J) < e_domain›*) ‹x ∈ X› (*‹(x::'a) ∈ (X::'a set)›*) show "x ∈ G" by (auto simp: G_def (*‹G ≡ {x ∈ X. infdist x (flow0 x0 ` J) < e_domain}›*)) qed qed from this[of x0] (*‹x0 ∈ ball x0 d ⟹ Y (x0 - x0) ` J ⊆ G›*) ‹0 < d› (*‹0 < d›*) have X_in_G: "flow0 x0 ` J ⊆ G" by simp show "∃d>0. ∀x. 0 < dist x x0 ∧ dist x x0 < d ⟶ dist ((Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) 0 < e" apply (rule exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃d>0. ∀x. 0 < dist x x0 ∧ dist x x0 < d ⟶ dist ((Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) 0 < e›*) apply (rule conjI[OF ‹0 < d›] (*‹?Q ⟹ 0 < d ∧ ?Q›*)) (*goal: ‹0 < ?d ∧ (∀x. 0 < dist x x0 ∧ dist x x0 < ?d ⟶ dist ((Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) 0 < e)›*) apply safe (*goal: ‹∀x::'a. (0::real) < dist x (x0::'a) ∧ dist x x0 < (d::real) ⟶ dist ((Y (x - x0) (t::real) - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) (0::'a) < (e::real)›*) proof (unfold norm_conv_dist[symmetric] (*‹dist (?x::?'a) (0::?'a) = norm ?x›*)) (*goal: ‹⋀x. ⟦0 < dist x x0; dist x x0 < d⟧ ⟹ norm ((Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) < e›*) fix x assume x_x0_dist: "0 < dist x x0" "dist x x0 < d" (*‹(0::real) < dist (x::'a) (x0::'a)› ‹dist (x::'a) (x0::'a) < (d::real)›*) hence x_in_ball': "x ∈ ball x0 d" by (simp add: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) hence x_in_ball: "x ∈ ball x0 u" using ‹d ≤ u› (*‹d ≤ u›*) by simp text ‹ First, some prerequisites. › from x_in_ball (*‹x ∈ ball x0 u›*) have z_in_ball: "x - x0 ∈ ball 0 u" using ‹0 < u› (*‹0 < u›*) by (simp add: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) hence [continuous_intros]: "dist x0 x < u" by (auto simp: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) from J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) have J_in_existence_ivl_x: "J ⊆ existence_ivl0 x" . from ball_in_X[OF z_in_ball] (*‹(x0::'a) + ((x::'a) - x0) ∈ (X::'a set)›*) have x_in_X[continuous_intros]: "x ∈ X" by simp text ‹ On all of ‹J›, we can find upper bounds for the distance of ‹flow0› and ‹Y›. › have dist_flow0_Y: "⋀s. s ∈ J ⟹ dist (flow0 x0 s) (Y (x - x0) s) ≤ dist x0 x * exp (K * ¦t¦)" using t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) uK_def(2) (*‹0 < K›*) apply (intro order_trans[OF uK_def(6)[OF x_in_ball] mult_left_mono] (*‹⟦?t2 ∈ J; exp (K * ¦?t2¦) ≤ ?b1; 0 ≤ dist x0 x⟧ ⟹ dist (flow0 x0 ?t2) (Y (x - x0) ?t2) ≤ dist x0 x * ?b1›*)) (*goals: 1. ‹⋀s::real. ⟦s ∈ (J::real set); t0::real ≡ min (0::real) (t::real); t1::real ≡ max (0::real) t; (0::real) < (K::real)⟧ ⟹ s ∈ J› 2. ‹⋀s::real. ⟦s ∈ (J::real set); t0::real ≡ min (0::real) (t::real); t1::real ≡ max (0::real) t; (0::real) < (K::real)⟧ ⟹ exp (K * ¦s¦) ≤ exp (K * ¦t¦)› 3. ‹⋀s::real. ⟦s ∈ (J::real set); t0::real ≡ min (0::real) (t::real); t1::real ≡ max (0::real) t; (0::real) < (K::real)⟧ ⟹ (0::real) ≤ dist (x0::'a) (x::'a)› discuss goal 1*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*))[1]) (*discuss goal 2*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*))[1]) (*discuss goal 3*) apply ((auto simp add: J_def (*‹J ≡ {t0..t1}›*) intro!: mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*))[1]) (*proven 3 subgoals*) . from d_ivl_def (*‹0 < d_ivl› ‹⟦0 < dist ?x x0; dist ?x x0 < d_ivl⟧ ⟹ ∀t∈J. dist (flow0 x0 t) (Y (?x - x0) t) < min (e_domain / 2) d_Taylor›*) x_x0_dist (*‹0 < dist x x0› ‹dist x x0 < d›*) ‹d ≤ d_ivl› (*‹d ≤ d_ivl›*) have dist_flow0_Y2: "⋀t. t ∈ J ⟹ dist (flow0 x0 t) (Y (x - x0) t) < min (e_domain2) d_Taylor" by (auto simp: e_domain2_def (*‹e_domain2 ≡ e_domain / 2›*)) let ?g = "λt. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t)" let ?C = "¦t¦ * dist x0 x * exp (K * ¦t¦) * e1" text ‹ Find an upper bound to ‹?g›, i.e. show that ‹?g s ≤ ?C + N * integral {a..b} ?g› for ‹{a..b} = {0..s}› or ‹{a..b} = {s..0}› for some ‹s ∈ J›. We can then apply Grönwall's inequality to obtain a true bound for ‹?g›. › have g_bound: "?g s ≤ ?C + N * integral {a..b} ?g" if s_def: "s ∈ {a..b}" and J'_def: "{a..b} ⊆ J" and ab_cases: "(a = 0 ∧ b = s) ∨ (a = s ∧ b = 0)" for s and a and b proof (-) (*goal: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 + N * integral {a..b} (λt. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t))›*) from that (*‹(s::real) ∈ {a::real..b::real}› ‹{a::real..b::real} ⊆ (J::real set)› ‹a = 0 ∧ b = s ∨ a = s ∧ b = 0›*) have "s ∈ J" by auto have s_in_existence_ivl_x0: "s ∈ existence_ivl0 x0" using J_in_existence (*‹J ⊆ existence_ivl0 x0›*) ‹s ∈ J› (*‹s ∈ J›*) by auto have s_in_existence_ivl: "⋀y. y ∈ ball x0 u ⟹ s ∈ existence_ivl0 y" using J_in_existence_ivl (*‹?y ∈ ball x0 u ⟹ J ⊆ existence_ivl0 ?y›*) ‹s ∈ J› (*‹s ∈ J›*) by auto have s_in_existence_ivl2: "⋀z. z ∈ ball 0 u ⟹ s ∈ existence_ivl0 (x0 + z)" using s_in_existence_ivl (*‹(?y::'a) ∈ ball (x0::'a) (u::real) ⟹ (s::real) ∈ existence_ivl0 ?y›*) by (simp add: dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*)) text ‹Prove continuities beforehand.› note continuous_on_0_s[continuous_intros] = continuous_on_subset[OF _ ‹{a..b} ⊆ J›] (*‹continuous_on (J::real set) (?f::real ⇒ ?'b) ⟹ continuous_on {a::real..b::real} ?f›*) have [continuous_intros]: "continuous_on J (flow0 x0)" using J_in_existence (*‹J ⊆ existence_ivl0 x0›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*) simp:) { fix z and S assume assms: "x0 + z ∈ X" "S ⊆ existence_ivl0 (x0 + z)" (*‹(x0::'a) + (z::'a) ∈ (X::'a set)› ‹(S::real set) ⊆ existence_ivl0 ((x0::'a) + (z::'a))›*) have "continuous_on S (λs. f (Y z s))" proof (rule continuous_on_subset[OF _ assms(2)] (*‹continuous_on (existence_ivl0 ((x0::'a) + (z::'a))) (?f::real ⇒ ?'b) ⟹ continuous_on (S::real set) ?f›*)) (*goal: ‹continuous_on (existence_ivl0 (x0 + z)) (λs. f (Y z s))›*) show "continuous_on (existence_ivl0 (x0 + z)) (λs. f (Y z s))" using assms (*‹x0 + z ∈ X› ‹S ⊆ existence_ivl0 (x0 + z)›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 291 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) flow_continuous_on (*‹continuous_on (existence_ivl0 ?x0.0) (flow0 ?x0.0)›*) simp:) qed } note [continuous_intros] = this (*‹⟦x0 + ?z2 ∈ X; ?S2 ⊆ existence_ivl0 (x0 + ?z2)⟧ ⟹ continuous_on ?S2 (λs. f (Y ?z2 s))›*) have [continuous_intros]: "continuous_on J (λs. f (flow0 x0 s))" apply (rule continuous_on_subset[OF _ J_in_existence] (*‹continuous_on (existence_ivl0 x0) ?f ⟹ continuous_on J ?f›*)) (*goal: ‹continuous_on J (λs. f (flow0 x0 s))›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 292 facts*) flow_continuous_on (*‹continuous_on (existence_ivl0 (?x0.0::'a)) (flow0 ?x0.0)›*) flow_in_domain (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 ?x0.0 ?t ∈ (X::'a set)›*) simp: x0_def (*‹(0::real) ∈ UNIV› ‹(x0::'a) ∈ (X::'a set)›*)) have [continuous_intros]: "⋀z. continuous_on J (λs. f' (flow0 x0 s) (vector_Dflow z s))" proof (-) (*goal: ‹⋀z. continuous_on J (λs. blinfun_apply (f' (flow0 x0 s)) (vector_Dflow z s))›*) fix z have a1: "continuous_on J (flow0 x0)" by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 293 facts*)) have a2: "(λs. (flow0 x0 s, vector_Dflow z s)) ` J ⊆ (flow0 x0 ` J) × ((λs. vector_Dflow z s) ` J)" by auto have a3: "continuous_on ((λs. (flow0 x0 s, vector_Dflow z s)) ` J) (λ(x, u). f' x u)" using assms (*‹t ∈ existence_ivl0 x0›*) flow0_J_props (*‹flow0 x0 ` J ≠ {}› ‹compact (flow0 x0 ` J)› ‹flow0 x0 ` J ⊆ X›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 293 facts*) simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) from continuous_on_compose[OF continuous_on_Pair [ OF a1 U_continuous ] a3] (*‹continuous_on J ((λ(x, u). blinfun_apply (f' x) u) ∘ (λs. (flow0 x0 s, vector_Dflow z s)))›*) show "continuous_on J (λs. f' (flow0 x0 s) (vector_Dflow z s))" by simp qed have [continuous_intros]: "continuous_on J (λs. R (flow0 x0 s) (Y (x - x0) s))" using J_in_existence (*‹J ⊆ existence_ivl0 x0›*) J_in_existence_ivl[OF x_in_ball] (*‹(J::real set) ⊆ existence_ivl0 (x::'a)›*) X_in_G (*‹flow0 (x0::'a::euclidean_space) ` (J::real set) ⊆ (G::'a::euclidean_space set)›*) ‹{a..b} ⊆ J› (*‹{a..b} ⊆ J›*) Y_in_G (*‹(?y::'a) ∈ ball (x0::'a) (d::real) ⟹ Y (?y - x0) ` (J::real set) ⊆ (G::'a set)›*) x_x0_dist (*‹0 < dist x x0› ‹dist x x0 < d›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 294 facts*) continuous_on_compose_Pair[OF Taylor_expansion(4)] (*‹⟦continuous_on ?C ?g; continuous_on ?C ?h; ⋀c. c ∈ ?C ⟹ ?g c ∈ G; ⋀c. c ∈ ?C ⟹ ?h c ∈ G⟧ ⟹ continuous_on ?C (λc. R (?g c) (?h c))›*) simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*) subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) hence [continuous_intros]: "(λs. R (flow0 x0 s) (Y (x - x0) s)) integrable_on J" unfolding J_def (*goal: ‹(λs. R (flow0 x0 s) (Y (x - x0) s)) integrable_on {t0..t1}›*) by (rule integrable_continuous_real (*‹continuous_on {?a::real..?b::real} (?f::real ⇒ ?'a) ⟹ ?f integrable_on {?a..?b}›*)) have i1: "integral {a..b} (λs. f (flow0 x s)) - integral {a..b} (λs. f (flow0 x0 s)) = integral {a..b} (λs. f (flow0 x s) - f (flow0 x0 s))" using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) apply (intro Henstock_Kurzweil_Integration.integral_diff[symmetric] (*‹⟦?f integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S ?f - integral ?S ?g = integral ?S (λx. ?f x - ?g x)›*)) (*goals: 1. ‹(J::real set) ⊆ existence_ivl0 (x::'a) ⟹ (λs::real. (f::'a ⇒ 'a) (flow0 x s)) integrable_on {a::real..b::real}› 2. ‹(J::real set) ⊆ existence_ivl0 (x::'a) ⟹ (λs::real. (f::'a ⇒ 'a) (flow0 (x0::'a) s)) integrable_on {a::real..b::real}› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*))[1]) (*proven 2 subgoals*) . have i2: "integral {a..b} (λs. f (flow0 x s) - f (flow0 x0 s) - (f' (flow0 x0 s)) (vector_Dflow (x - x0) s)) = integral {a..b} (λs. f (flow0 x s) - f (flow0 x0 s)) - integral {a..b} (λs. f' (flow0 x0 s) (vector_Dflow (x - x0) s))" using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) apply (intro Henstock_Kurzweil_Integration.integral_diff[OF Henstock_Kurzweil_Integration.integrable_diff] (*‹⟦?f1 integrable_on ?S; ?g1 integrable_on ?S; ?g integrable_on ?S⟧ ⟹ integral ?S (λx. ?f1 x - ?g1 x - ?g x) = integral ?S (λx. ?f1 x - ?g1 x) - integral ?S ?g›*)) (*goals: 1. ‹J ⊆ existence_ivl0 x ⟹ (λxa. f (flow0 x xa)) integrable_on {a..b}› 2. ‹J ⊆ existence_ivl0 x ⟹ (λx. f (flow0 x0 x)) integrable_on {a..b}› 3. ‹J ⊆ existence_ivl0 x ⟹ (λxa. blinfun_apply (f' (flow0 x0 xa)) (vector_Dflow (x - x0) xa)) integrable_on {a..b}› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*))[1]) (*proven 3 subgoals*) . from ab_cases (*‹(a::real) = (0::real) ∧ (b::real) = (s::real) ∨ a = s ∧ b = (0::real)›*) have "?g s = norm (integral {a..b} (λs'. f (Y (x - x0) s')) - integral {a..b} (λs'. f (flow0 x0 s')) - integral {a..b} (λs'. (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))" proof (safe) (*goals: 1. ‹⟦b = s; a = 0⟧ ⟹ norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {0..s} (λs'. f (Y (x - x0) s')) - integral {0..s} (λs'. f (flow0 x0 s')) - integral {0..s} (λs'. blinfun_apply (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))› 2. ‹⟦b = 0; a = s⟧ ⟹ norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {s..0} (λs'. f (Y (x - x0) s')) - integral {s..0} (λs'. f (flow0 x0 s')) - integral {s..0} (λs'. blinfun_apply (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))›*) assume "a = 0" "b = s" (*‹(a::real) = (0::real)› ‹(b::real) = (s::real)›*) hence "0 ≤ s" using ‹s ∈ {a..b}› (*‹s ∈ {a..b}›*) by simp text‹ Integral equations for flow0, Y and U. › have flow0_integral_eq: "flow0 x0 s = x0 + ivl_integral 0 s (λs. f (flow0 x0 s))" by (rule flow_fixed_point[OF s_in_existence_ivl_x0] (*‹flow0 (x0::'a::euclidean_space) (s::real) = x0 + ivl_integral (0::real) s (λt::real. (f::'a::euclidean_space ⇒ 'a::euclidean_space) (flow0 x0 t))›*)) have Y_integral_eq: "flow0 x s = x0 + (x - x0) + ivl_integral 0 s (λs. f (Y (x - x0) s))" using flow_fixed_point (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t = ?x0.0 + ivl_integral 0 ?t (λt. f (flow0 ?x0.0 t))›*) ‹0 ≤ s› (*‹0 ≤ s›*) s_in_existence_ivl2[OF z_in_ball] (*‹s ∈ existence_ivl0 (x0 + (x - x0))›*) ball_in_X[OF z_in_ball] (*‹x0 + (x - x0) ∈ X›*) by (simp add:) have U_integral_eq: "vector_Dflow (x - x0) s = (x - x0) + ivl_integral 0 s (λs. vareq x0 s (vector_Dflow (x - x0) s))" unfolding vector_Dflow_def (*goal: ‹var.flow x0 0 (x - x0) s = x - x0 + ivl_integral 0 s (λs. blinfun_apply (vareq x0 s) (var.flow x0 0 (x - x0) s))›*) apply (rule var.flow_fixed_point (*‹?t ∈ var.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ var.flow ?x0a ?t0.0 ?x0.0 ?t = ?x0.0 + ivl_integral ?t0.0 ?t (λt. blinfun_apply (vareq ?x0a t) (var.flow ?x0a ?t0.0 ?x0.0 t))›*)) (*goal: ‹var.flow (x0::'a) (0::real) ((x::'a) - x0) (s::real) = x - x0 + ivl_integral (0::real) s (λs::real. blinfun_apply (vareq x0 s) (var.flow x0 (0::real) (x - x0) s))›*) by (auto simp: ‹0 ≤ s› x0_def (*‹0 ∈ UNIV› ‹x0 ∈ X›*) varexivl_eq_exivl (*‹?t ∈ existence_ivl0 x0 ⟹ var.existence_ivl x0 ?t ?a = existence_ivl0 x0›*) s_in_existence_ivl_x0 (*‹s ∈ existence_ivl0 x0›*)) show "?g s = norm (integral {0..s} (λs'. f (Y (x - x0) s')) - integral {0..s} (λs'. f (flow0 x0 s')) - integral {0..s} (λs'. blinfun_apply (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))" using ‹0 ≤ s› (*‹0 ≤ s›*) unfolding vareq_def[symmetric] (*goal: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {0..s} (λs'. f (Y (x - x0) s')) - integral {0..s} (λs'. f (flow0 x0 s')) - integral {0..s} (λs'. blinfun_apply (vareq x0 s') (vector_Dflow (x - x0) s')))›*) by (simp add: flow0_integral_eq (*‹flow0 (x0::'a) (s::real) = x0 + ivl_integral (0::real) s (λs::real. (f::'a ⇒ 'a) (flow0 x0 s))›*) Y_integral_eq (*‹flow0 (x::'a) (s::real) = (x0::'a) + (x - x0) + ivl_integral (0::real) s (λs::real. (f::'a ⇒ 'a) (Y (x - x0) s))›*) U_integral_eq (*‹vector_Dflow ((x::'a) - (x0::'a)) (s::real) = x - x0 + ivl_integral (0::real) s (λs::real. blinfun_apply (vareq x0 s) (vector_Dflow (x - x0) s))›*) ivl_integral_def (*‹ivl_integral (?a::real) (?b::real) (?f::real ⇒ ?'a) = integral {?a..?b} ?f - integral {?b..?a} ?f›*)) next (*goal: ‹⟦(b::real) = (0::real); (a::real) = (s::real)⟧ ⟹ norm (Y ((x::'a::euclidean_space) - (x0::'a::euclidean_space)) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {s..0::real} (λs'::real. (f::'a::euclidean_space ⇒ 'a::euclidean_space) (Y (x - x0) s')) - integral {s..0::real} (λs'::real. f (flow0 x0 s')) - integral {s..0::real} (λs'::real. blinfun_apply ((f'::'a::euclidean_space ⇒ 'a::euclidean_space ⇒⇩L 'a::euclidean_space) (flow0 x0 s')) (vector_Dflow (x - x0) s')))›*) assume "a = s" "b = 0" (*‹(a::real) = (s::real)› ‹(b::real) = (0::real)›*) hence "s ≤ 0" using ‹s ∈ {a..b}› (*‹s ∈ {a..b}›*) by simp have flow0_integral_eq_left: "flow0 x0 s = x0 + ivl_integral 0 s (λs. f (flow0 x0 s))" by (rule flow_fixed_point[OF s_in_existence_ivl_x0] (*‹flow0 x0 s = x0 + ivl_integral 0 s (λt. f (flow0 x0 t))›*)) have Y_integral_eq_left: "Y (x - x0) s = x0 + (x - x0) + ivl_integral 0 s (λs. f (Y (x - x0) s))" using flow_fixed_point (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t = ?x0.0 + ivl_integral 0 ?t (λt. f (flow0 ?x0.0 t))›*) ‹s ≤ 0› (*‹s ≤ 0›*) s_in_existence_ivl2[OF z_in_ball] (*‹s ∈ existence_ivl0 (x0 + (x - x0))›*) ball_in_X[OF z_in_ball] (*‹x0 + (x - x0) ∈ X›*) by simp have U_integral_eq_left: "vector_Dflow (x - x0) s = (x - x0) + ivl_integral 0 s (λs. vareq x0 s (vector_Dflow (x - x0) s))" unfolding vector_Dflow_def (*goal: ‹var.flow x0 0 (x - x0) s = x - x0 + ivl_integral 0 s (λs. blinfun_apply (vareq x0 s) (var.flow x0 0 (x - x0) s))›*) apply (rule var.flow_fixed_point (*‹?t ∈ var.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ var.flow ?x0a ?t0.0 ?x0.0 ?t = ?x0.0 + ivl_integral ?t0.0 ?t (λt. blinfun_apply (vareq ?x0a t) (var.flow ?x0a ?t0.0 ?x0.0 t))›*)) (*goal: ‹var.flow x0 0 (x - x0) s = x - x0 + ivl_integral 0 s (λs. blinfun_apply (vareq x0 s) (var.flow x0 0 (x - x0) s))›*) by (auto simp: ‹s ≤ 0› x0_def (*‹(0::real) ∈ UNIV› ‹(x0::'a::euclidean_space) ∈ (X::'a::euclidean_space set)›*) varexivl_eq_exivl (*‹(?t::real) ∈ existence_ivl0 (x0::'a::euclidean_space) ⟹ var.existence_ivl x0 ?t (?a::'a::euclidean_space) = existence_ivl0 x0›*) s_in_existence_ivl_x0 (*‹(s::real) ∈ existence_ivl0 (x0::'a::euclidean_space)›*)) have "?g s = norm (- integral {s..0} (λs'. f (Y (x - x0) s')) + integral {s..0} (λs'. f (flow0 x0 s')) + integral {s..0} (λs'. vareq x0 s' (vector_Dflow (x - x0) s')))" unfolding flow0_integral_eq_left Y_integral_eq_left U_integral_eq_left (*goal: ‹norm (x0 + (x - x0) + ivl_integral 0 s (λs. f (Y (x - x0) s)) - (x0 + ivl_integral 0 s (λs. f (flow0 x0 s))) - (x - x0 + ivl_integral 0 s (λs. blinfun_apply (vareq x0 s) (vector_Dflow (x - x0) s)))) = norm (- integral {s..0} (λs'. f (Y (x - x0) s')) + integral {s..0} (λs'. f (flow0 x0 s')) + integral {s..0} (λs'. blinfun_apply (vareq x0 s') (vector_Dflow (x - x0) s')))›*) using ‹s ≤ 0› (*‹(s::real) ≤ (0::real)›*) by (simp add: ivl_integral_def (*‹ivl_integral ?a ?b ?f = integral {?a..?b} ?f - integral {?b..?a} ?f›*)) also (*calculation: ‹norm (Y ((x::'a::euclidean_space) - (x0::'a::euclidean_space)) (s::real) - flow0 x0 s - vector_Dflow (x - x0) s) = norm (- integral {s..0::real} (λs'::real. (f::'a::euclidean_space ⇒ 'a::euclidean_space) (Y (x - x0) s')) + integral {s..0::real} (λs'::real. f (flow0 x0 s')) + integral {s..0::real} (λs'::real. blinfun_apply (vareq x0 s') (vector_Dflow (x - x0) s')))›*) have "... = norm (integral {s..0} (λs'. f (Y (x - x0) s')) - integral {s..0} (λs'. f (flow0 x0 s')) - integral {s..0} (λs'. vareq x0 s' (vector_Dflow (x - x0) s')))" apply (subst norm_minus_cancel[symmetric] (*‹norm ?x = norm (- ?x)›*)) (*goal: ‹norm (- integral {s..0} (λs'. f (Y (x - x0) s')) + integral {s..0} (λs'. f (flow0 x0 s')) + integral {s..0} (λs'. blinfun_apply (vareq x0 s') (vector_Dflow (x - x0) s'))) = norm (integral {s..0} (λs'. f (Y (x - x0) s')) - integral {s..0} (λs'. f (flow0 x0 s')) - integral {s..0} (λs'. blinfun_apply (vareq x0 s') (vector_Dflow (x - x0) s')))›*) by simp finally (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {s..0} (λs'. f (Y (x - x0) s')) - integral {s..0} (λs'. f (flow0 x0 s')) - integral {s..0} (λs'. blinfun_apply (vareq x0 s') (vector_Dflow (x - x0) s')))›*) show "?g s = norm (integral {s..0} (λs'. f (Y (x - x0) s')) - integral {s..0} (λs'. f (flow0 x0 s')) - integral {s..0} (λs'. blinfun_apply (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))" unfolding vareq_def (*goal: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {s..0} (λs'. f (Y (x - x0) s')) - integral {s..0} (λs'. f (flow0 x0 s')) - integral {s..0} (λs'. blinfun_apply (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))›*) . qed also (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {a..b} (λs'. f (Y (x - x0) s')) - integral {a..b} (λs'. f (flow0 x0 s')) - integral {a..b} (λs'. blinfun_apply (f' (flow0 x0 s')) (vector_Dflow (x - x0) s')))›*) have "... = norm (integral {a..b} (λs. f (Y (x - x0) s) - f (flow0 x0 s) - (f' (flow0 x0 s)) (vector_Dflow (x - x0) s)))" by (simp add: i1 (*‹integral {a..b} (λs. f (flow0 x s)) - integral {a..b} (λs. f (flow0 x0 s)) = integral {a..b} (λs. f (flow0 x s) - f (flow0 x0 s))›*) i2 (*‹integral {a..b} (λs. f (flow0 x s) - f (flow0 x0 s) - blinfun_apply (f' (flow0 x0 s)) (vector_Dflow (x - x0) s)) = integral {a..b} (λs. f (flow0 x s) - f (flow0 x0 s)) - integral {a..b} (λs. blinfun_apply (f' (flow0 x0 s)) (vector_Dflow (x - x0) s))›*)) also (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) = norm (integral {a..b} (λs. f (Y (x - x0) s) - f (flow0 x0 s) - blinfun_apply (f' (flow0 x0 s)) (vector_Dflow (x - x0) s)))›*) have "... ≤ integral {a..b} (λs. norm (f (Y (x - x0) s) - f (flow0 x0 s) - f' (flow0 x0 s) (vector_Dflow (x - x0) s)))" using x_in_X (*‹x ∈ X›*) J_in_existence_ivl_x (*‹J ⊆ existence_ivl0 x›*) J_in_existence (*‹J ⊆ existence_ivl0 x0›*) ‹{a..b} ⊆ J› (*‹{a..b} ⊆ J›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) continuous_on_imp_absolutely_integrable_on (*‹continuous_on {?a..?b} ?f ⟹ norm (integral {?a..?b} ?f) ≤ integral {?a..?b} (λx. norm (?f x))›*) existence_ivl_reverse (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ 0 - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*)) also (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) ≤ integral {a..b} (λs. norm (f (Y (x - x0) s) - f (flow0 x0 s) - blinfun_apply (f' (flow0 x0 s)) (vector_Dflow (x - x0) s)))›*) have "... = integral {a..b} (λs. norm (f' (flow0 x0 s) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) + R (flow0 x0 s) (Y (x - x0) s)))" proof (safe intro!: integral_spike[OF negligible_empty, simplified] (*‹(⋀x. x ∈ ?T ⟹ ?g x = ?f x) ⟹ integral ?T ?f = integral ?T ?g›*) arg_cong[where f=norm] (*‹?x = ?y ⟹ norm ?x = norm ?y›*)) (*goal: ‹⋀xa. xa ∈ {a..b} ⟹ blinfun_apply (f' (flow0 x0 xa)) (Y (x - x0) xa - flow0 x0 xa - vector_Dflow (x - x0) xa) + R (flow0 x0 xa) (Y (x - x0) xa) = f (Y (x - x0) xa) - f (flow0 x0 xa) - blinfun_apply (f' (flow0 x0 xa)) (vector_Dflow (x - x0) xa)›*) fix s' assume "s' ∈ {a..b}" (*‹(s'::real) ∈ {a::real..b::real}›*) show "f' (flow0 x0 s') (Y (x - x0) s' - flow0 x0 s' - vector_Dflow (x - x0) s') + R (flow0 x0 s') (Y (x - x0) s') = f (Y (x - x0) s') - f (flow0 x0 s') - f' (flow0 x0 s') (vector_Dflow (x - x0) s')" by (simp add: blinfun.diff_right (*‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'›*) Taylor_expansion(2)[of "flow0 x s'" "flow0 x0 s'"] (*‹f (flow0 x s') = f (flow0 x0 s') + blinfun_apply (f' (flow0 x0 s')) (flow0 x s' - flow0 x0 s') + R (flow0 x0 s') (flow0 x s')›*)) qed also (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) ≤ integral {a..b} (λs. norm (blinfun_apply (f' (flow0 x0 s)) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) + R (flow0 x0 s) (Y (x - x0) s)))›*) have "... ≤ integral {a..b} (λs. norm (f' (flow0 x0 s) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s)) + norm (R (flow0 x0 s) (Y (x - x0) s)))" using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) norm_triangle_ineq (*‹norm (?x + ?y) ≤ norm ?x + norm ?y›*) using ‹continuous_on J (λs. R (flow0 x0 s) (Y (x - x0) s))› (*‹continuous_on J (λs. R (flow0 x0 s) (Y (x - x0) s))›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) integral_le (*‹⟦?f integrable_on ?S; ?g integrable_on ?S; ⋀x. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ integral ?S ?f ≤ integral ?S ?g›*)) also (*calculation: ‹norm (Y ((x::'a) - (x0::'a)) (s::real) - flow0 x0 s - vector_Dflow (x - x0) s) ≤ integral {a::real..b::real} (λs::real. norm (blinfun_apply ((f'::'a ⇒ 'a ⇒⇩L 'a) (flow0 x0 s)) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s)) + norm ((R::'a ⇒ 'a ⇒ 'a) (flow0 x0 s) (Y (x - x0) s)))›*) have "... = integral {a..b} (λs. norm (f' (flow0 x0 s) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))) + integral {a..b} (λs. norm (R (flow0 x0 s) (Y (x - x0) s)))" using J_in_existence_ivl[OF x_in_ball] (*‹(J::real set) ⊆ existence_ivl0 (x::'a)›*) using ‹continuous_on J (λs. R (flow0 x0 s) (Y (x - x0) s))› (*‹continuous_on J (λs. R (flow0 x0 s) (Y (x - x0) s))›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a::topological_space set); open (?T::?'a::topological_space set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. open ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b::type set); ∀x::?'b::type∈?A. open ((?B::?'b::type ⇒ ?'a::topological_space set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. closed ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a::topological_space set∈?K::?'a::topological_space set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) Henstock_Kurzweil_Integration.integral_add (*‹⟦(?f::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on (?S::?'a::euclidean_space set); (?g::?'a::euclidean_space ⇒ ?'b::real_normed_vector) integrable_on ?S⟧ ⟹ integral ?S (λx::?'a::euclidean_space. ?f x + ?g x) = integral ?S ?f + integral ?S ?g›*)) also (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) ≤ integral {a..b} (λs. norm (blinfun_apply (f' (flow0 x0 s)) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))) + integral {a..b} (λs. norm (R (flow0 x0 s) (Y (x - x0) s)))›*) have "... ≤ N * integral {a..b} ?g + ?C" (is "?l1 + ?r1 ≤ _") proof (rule add_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a + ?c ≤ ?b + ?d›*)) (*goals: 1. ‹integral {a::real..b::real} (λs::real. norm (blinfun_apply ((f'::'a::euclidean_space ⇒ 'a::euclidean_space ⇒⇩L 'a::euclidean_space) (flow0 (x0::'a::euclidean_space) s)) (Y ((x::'a::euclidean_space) - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))) ≤ (N::real) * integral {a..b} (λt::real. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t))› 2. ‹integral {a::real..b::real} (λs::real. norm ((R::'a::euclidean_space ⇒ 'a::euclidean_space ⇒ 'a::euclidean_space) (flow0 (x0::'a::euclidean_space) s) (Y ((x::'a::euclidean_space) - x0) s))) ≤ ¦t::real¦ * dist x0 x * exp ((K::real) * ¦t¦) * (e1::real)›*) have "?l1 ≤ integral {a..b} (λs. norm (f' (flow0 x0 s)) * norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))" using norm_blinfun (*‹norm (blinfun_apply ?f ?x) ≤ norm ?f * norm ?x›*) J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) integral_le (*‹⟦?f integrable_on ?S; ?g integrable_on ?S; ⋀x. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ integral ?S ?f ≤ integral ?S ?g›*)) also (*calculation: ‹integral {a..b} (λs. norm (blinfun_apply (f' (flow0 x0 s)) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))) ≤ integral {a..b} (λs. norm (f' (flow0 x0 s)) * norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))›*) have "... ≤ integral {a..b} (λs. N * norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))" using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) N_ineq[OF ‹{a..b} ⊆ J› [ THEN subsetD ]] (*‹?s ∈ {a..b} ⟹ norm (f' (flow0 x0 ?s)) ≤ N›*) apply (intro integral_le (*‹⟦?f integrable_on ?S; ?g integrable_on ?S; ⋀x. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ integral ?S ?f ≤ integral ?S ?g›*)) (*goals: 1. ‹⟦J ⊆ existence_ivl0 x; ⋀s. s ∈ {a..b} ⟹ norm (f' (flow0 x0 s)) ≤ N⟧ ⟹ (λs. norm (f' (flow0 x0 s)) * norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s)) integrable_on {a..b}› 2. ‹⟦J ⊆ existence_ivl0 x; ⋀s. s ∈ {a..b} ⟹ norm (f' (flow0 x0 s)) ≤ N⟧ ⟹ (λs. N * norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s)) integrable_on {a..b}› 3. ‹⋀xa. ⟦J ⊆ existence_ivl0 x; ⋀s. s ∈ {a..b} ⟹ norm (f' (flow0 x0 s)) ≤ N; xa ∈ {a..b}⟧ ⟹ norm (f' (flow0 x0 xa)) * norm (Y (x - x0) xa - flow0 x0 xa - vector_Dflow (x - x0) xa) ≤ N * norm (Y (x - x0) xa - flow0 x0 xa - vector_Dflow (x - x0) xa)› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹integral {a::real..b::real} (λs::real. norm (blinfun_apply ((f'::'a ⇒ 'a ⇒⇩L 'a) (flow0 (x0::'a) s)) (Y ((x::'a) - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))) ≤ integral {a..b} (λs::real. (N::real) * norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))›*) have "... = N * integral {a..b} (λs. norm ((Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s)))" unfolding real_scaleR_def[symmetric] (*goal: ‹integral {a..b} (λs. N *⇩R norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s)) = N *⇩R integral {a..b} (λs. norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))›*) by (rule integral_cmul (*‹integral (?S::?'b::euclidean_space set) (λx::?'b::euclidean_space. (?c::real) *⇩R (?f::?'b::euclidean_space ⇒ ?'a::real_normed_vector) x) = ?c *⇩R integral ?S ?f›*)) finally (*calculation: ‹integral {a..b} (λs. norm (blinfun_apply (f' (flow0 x0 s)) (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))) ≤ N * integral {a..b} (λs. norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s))›*) show "?l1 ≤ N * integral {a..b} ?g" . next (*goal: ‹integral {a..b} (λs. norm (R (flow0 x0 s) (Y (x - x0) s))) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1›*) have "?r1 ≤ integral {a..b} (λs. e1 * dist (flow0 x0 s) (Y (x - x0) s))" using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) ‹0 < e_domain› (*‹0 < e_domain›*) dist_flow0_Y2 (*‹?t ∈ J ⟹ dist (flow0 x0 ?t) (Y (x - x0) ?t) < min e_domain2 d_Taylor›*) ‹0 < e_domain2› (*‹0 < e_domain2›*) apply (intro integral_le (*‹⟦?f integrable_on ?S; ?g integrable_on ?S; ⋀x. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ integral ?S ?f ≤ integral ?S ?g›*)) (*goals: 1. ‹⟦J ⊆ existence_ivl0 x; 0 < e_domain; ⋀t. t ∈ J ⟹ dist (flow0 x0 t) (Y (x - x0) t) < min e_domain2 d_Taylor; 0 < e_domain2⟧ ⟹ (λs. norm (R (flow0 x0 s) (Y (x - x0) s))) integrable_on {a..b}› 2. ‹⟦J ⊆ existence_ivl0 x; 0 < e_domain; ⋀t. t ∈ J ⟹ dist (flow0 x0 t) (Y (x - x0) t) < min e_domain2 d_Taylor; 0 < e_domain2⟧ ⟹ (λs. e1 * dist (flow0 x0 s) (Y (x - x0) s)) integrable_on {a..b}› 3. ‹⋀xa. ⟦J ⊆ existence_ivl0 x; 0 < e_domain; ⋀t. t ∈ J ⟹ dist (flow0 x0 t) (Y (x - x0) t) < min e_domain2 d_Taylor; 0 < e_domain2; xa ∈ {a..b}⟧ ⟹ norm (R (flow0 x0 xa) (Y (x - x0) xa)) ≤ e1 * dist (flow0 x0 xa) (Y (x - x0) xa)› discuss goal 1*) apply (force intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) Taylor_expansion( (*‹⟦?x ∈ H; ?y ∈ H; dist ?x ?y < d_Taylor⟧ ⟹ norm (R ?x ?y) ≤ e1 * dist ?x ?y›*) 3) order_trans[OF infdist_le] (*‹⟦?a1 ∈ ?A1; dist ?x1 ?a1 ≤ ?z⟧ ⟹ infdist ?x1 ?A1 ≤ ?z›*) dest!: ‹{a..b} ⊆ J›[THEN subsetD] intro: less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*) H_def (*‹H ≡ {x. infdist x (flow0 x0 ` J) ≤ e_domain2}›*)) (*discuss goal 2*) apply (force intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) Taylor_expansion( (*‹⟦(?x::'a) ∈ (H::'a set); (?y::'a) ∈ H; dist ?x ?y < (d_Taylor::real)⟧ ⟹ norm ((R::'a ⇒ 'a ⇒ 'a) ?x ?y) ≤ (e1::real) * dist ?x ?y›*) 3) order_trans[OF infdist_le] (*‹⟦(?a1::?'a1) ∈ (?A1::?'a1 set); dist (?x1::?'a1) ?a1 ≤ (?z::real)⟧ ⟹ infdist ?x1 ?A1 ≤ ?z›*) dest!: ‹{a..b} ⊆ J›[THEN subsetD] intro: less_imp_le (*‹(?x::?'a) < (?y::?'a) ⟹ ?x ≤ ?y›*) simp: dist_commute (*‹dist (?x::?'a) (?y::?'a) = dist ?y ?x›*) H_def (*‹H::'a set ≡ {x::'a. infdist x (flow0 (x0::'a) ` (J::real set)) ≤ (e_domain2::real)}›*)) (*discuss goal 3*) apply (force intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*) Taylor_expansion( (*‹⟦?x ∈ H; ?y ∈ H; dist ?x ?y < d_Taylor⟧ ⟹ norm (R ?x ?y) ≤ e1 * dist ?x ?y›*) 3) order_trans[OF infdist_le] (*‹⟦?a1 ∈ ?A1; dist ?x1 ?a1 ≤ ?z⟧ ⟹ infdist ?x1 ?A1 ≤ ?z›*) dest!: ‹{a..b} ⊆ J›[THEN subsetD] intro: less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*) H_def (*‹H ≡ {x. infdist x (flow0 x0 ` J) ≤ e_domain2}›*)) (*proven 3 subgoals*) . also (*calculation: ‹integral {a..b} (λs. norm (R (flow0 x0 s) (Y (x - x0) s))) ≤ integral {a..b} (λs. e1 * dist (flow0 x0 s) (Y (x - x0) s))›*) have "... ≤ integral {a..b} (λs. e1 * (dist x0 x * exp (K * ¦t¦)))" apply (rule integral_le (*‹⟦?f integrable_on ?S; ?g integrable_on ?S; ⋀x. x ∈ ?S ⟹ ?f x ≤ ?g x⟧ ⟹ integral ?S ?f ≤ integral ?S ?g›*)) (*goal: ‹integral {a..b} (λs. e1 * dist (flow0 x0 s) (Y (x - x0) s)) ≤ integral {a..b} (λs. e1 * (dist x0 x * exp (K * ¦t¦)))›*) subgoal for using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) by (force intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 296 facts*)) subgoal for by force subgoal for by (force dest!: ‹{a..b} ⊆ J›[THEN subsetD] intro!: less_imp_le[OF ‹0 < e1›] (*‹0 ≤ e1›*) mult_left_mono[OF dist_flow0_Y] (*‹⟦?s1 ∈ J; 0 ≤ ?c⟧ ⟹ ?c * dist (flow0 x0 ?s1) (Y (x - x0) ?s1) ≤ ?c * (dist x0 x * exp (K * ¦t¦))›*)) . also (*calculation: ‹integral {a..b} (λs. norm (R (flow0 x0 s) (Y (x - x0) s))) ≤ integral {a..b} (λs. e1 * (dist x0 x * exp (K * ¦t¦)))›*) have "... ≤ ?C" using ‹s ∈ J› (*‹s ∈ J›*) x_x0_dist (*‹0 < dist x x0› ‹dist x x0 < d›*) ‹0 < e1› (*‹0 < e1›*) ‹{a..b} ⊆ J› (*‹{a..b} ⊆ J›*) ‹0 < ¦t¦› (*‹0 < ¦t¦›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*) by (auto simp: integral_const_real (*‹integral {?a..?b} (λx. ?c) = content {?a..?b} *⇩R ?c›*) J_def( (*‹J ≡ {t0..t1}›*) 1)) finally (*calculation: ‹integral {a..b} (λs. norm (R (flow0 x0 s) (Y (x - x0) s))) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1›*) show "?r1 ≤ ?C" . qed finally (*calculation: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) ≤ N * integral {a..b} (λt. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t)) + ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1›*) show "?thesis" (*goal: ‹norm (Y (x - x0) s - flow0 x0 s - vector_Dflow (x - x0) s) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 + N * integral {a..b} (λt. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t))›*) by simp qed have g_continuous: "continuous_on J ?g" using J_in_existence_ivl[OF x_in_ball] (*‹J ⊆ existence_ivl0 x›*) J_in_existence (*‹J ⊆ existence_ivl0 x0›*) using J_def(1) (*‹J::real set ≡ {t0::real..t1::real}›*) U_continuous (*‹continuous_on J (vector_Dflow ?z)›*) by (auto simp: J_def (*‹J ≡ {t0..t1}›*) intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 289 facts*)) note [continuous_intros] = continuous_on_subset[OF g_continuous] (*‹(?t::real set) ⊆ (J::real set) ⟹ continuous_on ?t (λt::real. norm (Y ((x::'a) - (x0::'a)) t - flow0 x0 t - vector_Dflow (x - x0) t))›*) have C_gr_zero: "0 < ?C" using ‹0 < ¦t¦› (*‹0 < ¦t¦›*) ‹0 < e1› (*‹(0::real) < (e1::real)›*) x_x0_dist(1) (*‹0 < dist x x0›*) by (simp add: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) have "0 ≤ t ∨ t ≤ 0" by auto then have "?g t ≤ ?C * exp (N * ¦t¦)" proof (standard) (*goals: 1. ‹0 ≤ t ⟹ norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * ¦t¦)› 2. ‹t ≤ 0 ⟹ norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * ¦t¦)›*) assume "0 ≤ t" (*‹(0::real) ≤ (t::real)›*) moreover have "continuous_on {0..t} (vector_Dflow (x - x0))" using U_continuous (*‹continuous_on (J::real set) (vector_Dflow (?z::'a::euclidean_space))›*) apply (rule continuous_on_subset (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); (?t::?'a set) ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹continuous_on {0::real..t::real} (vector_Dflow ((x::'a) - (x0::'a)))›*) by (auto simp: J_def (*‹J::real set ≡ {t0::real..t1::real}›*) t0_def (*‹t0::real ≡ min (0::real) (t::real)›*) t1_def (*‹t1::real ≡ max (0::real) (t::real)›*)) then have "norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * t)" using ‹t ∈ J› (*‹t ∈ J›*) J_def (*‹J ≡ {t0..t1}›*) ‹t0 ≤ 0› (*‹t0 ≤ 0›*) J_in_existence (*‹J ⊆ existence_ivl0 x0›*) J_in_existence_ivl_x (*‹(J::real set) ⊆ existence_ivl0 (x::'a)›*) apply - (*goal: ‹norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * t)›*) apply (intro gronwall[OF g_bound _ _ C_gr_zero ‹0 < N› ‹0 ≤ t› order.refl] (*‹⟦⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ ta ∈ {0..ta}; ⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ {0..ta} ⊆ J; ⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ 0 = 0 ∧ ta = ta ∨ 0 = ta ∧ ta = 0; continuous_on {0..t} (λt. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t)); ⋀ta. ⟦0 ≤ ta; ta ≤ t⟧ ⟹ 0 ≤ norm (Y (x - x0) ta - flow0 x0 ta - vector_Dflow (x - x0) ta)⟧ ⟹ norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * t)›*)) (*goals: 1. ‹⋀ta. ⟦continuous_on {0..t} (vector_Dflow (x - x0)); t ∈ J; J ≡ {t0..t1}; t0 ≤ 0; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; 0 ≤ ta; ta ≤ t⟧ ⟹ ta ∈ {0..ta}› 2. ‹⋀ta. ⟦continuous_on {0..t} (vector_Dflow (x - x0)); t ∈ J; J ≡ {t0..t1}; t0 ≤ 0; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; 0 ≤ ta; ta ≤ t⟧ ⟹ {0..ta} ⊆ J› 3. ‹⋀ta. ⟦continuous_on {0..t} (vector_Dflow (x - x0)); t ∈ J; J ≡ {t0..t1}; t0 ≤ 0; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; 0 ≤ ta; ta ≤ t⟧ ⟹ 0 = 0 ∧ ta = ta ∨ 0 = ta ∧ ta = 0› 4. ‹⟦continuous_on {0..t} (vector_Dflow (x - x0)); t ∈ J; J ≡ {t0..t1}; t0 ≤ 0; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x⟧ ⟹ continuous_on {0..t} (λt. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t))› 5. ‹⋀ta. ⟦continuous_on {0..t} (vector_Dflow (x - x0)); t ∈ J; J ≡ {t0..t1}; t0 ≤ 0; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; 0 ≤ ta; ta ≤ t⟧ ⟹ 0 ≤ norm (Y (x - x0) ta - flow0 x0 ta - vector_Dflow (x - x0) ta)› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*) simp:)[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a::topological_space set); open (?T::?'a::topological_space set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. open ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b::type set); ∀x::?'b::type∈?A. open ((?B::?'b::type ⇒ ?'a::topological_space set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. closed ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a::topological_space set∈?K::?'a::topological_space set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*) simp:)[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*) simp:)[1]) (*discuss goal 4*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*) simp:)[1]) (*discuss goal 5*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*) simp:)[1]) (*proven 5 subgoals*) . ultimately show "?thesis" (*goal: ‹norm (Y ((x::'a) - (x0::'a)) (t::real) - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp ((K::real) * ¦t¦) * (e1::real) * exp ((N::real) * ¦t¦)›*) by simp next (*goal: ‹t ≤ 0 ⟹ norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * ¦t¦)›*) assume "t ≤ 0" (*‹(t::real) ≤ (0::real)›*) moreover have "continuous_on {t .. 0} (vector_Dflow (x - x0))" using U_continuous (*‹continuous_on J (vector_Dflow ?z)›*) apply (rule continuous_on_subset (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); (?t::?'a set) ⊆ ?s⟧ ⟹ continuous_on ?t ?f›*)) (*goal: ‹continuous_on {t::real..0::real} (vector_Dflow ((x::'a) - (x0::'a)))›*) by (auto simp: J_def (*‹J ≡ {t0..t1}›*) t0_def (*‹t0 ≡ min 0 t›*) t1_def (*‹t1 ≡ max 0 t›*)) then have "norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (- N * t)" using ‹t ∈ J› (*‹t ∈ J›*) J_def (*‹J ≡ {t0..t1}›*) ‹0 ≤ t1› (*‹0 ≤ t1›*) J_in_existence (*‹J ⊆ existence_ivl0 x0›*) J_in_existence_ivl_x (*‹J ⊆ existence_ivl0 x›*) apply (intro gronwall_left[OF g_bound _ _ C_gr_zero ‹0 < N› order.refl ‹t ≤ 0›] (*‹⟦⋀ta::real. ⟦(t::real) ≤ ta; ta ≤ (0::real)⟧ ⟹ ta ∈ {ta..0::real}; ⋀ta::real. ⟦t ≤ ta; ta ≤ (0::real)⟧ ⟹ {ta..0::real} ⊆ (J::real set); ⋀ta::real. ⟦t ≤ ta; ta ≤ (0::real)⟧ ⟹ ta = (0::real) ∧ (0::real) = ta ∨ ta = ta ∧ (0::real) = (0::real); continuous_on {t..0::real} (λt::real. norm (Y ((x::'a) - (x0::'a)) t - flow0 x0 t - vector_Dflow (x - x0) t)); ⋀ta::real. ⟦t ≤ ta; ta ≤ (0::real)⟧ ⟹ (0::real) ≤ norm (Y (x - x0) ta - flow0 x0 ta - vector_Dflow (x - x0) ta)⟧ ⟹ norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp ((K::real) * ¦t¦) * (e1::real) * exp (- (N::real) * t)›*)) (*goals: 1. ‹⋀ta::real. ⟦continuous_on {t::real..0::real} (vector_Dflow ((x::'a) - (x0::'a))); t ∈ (J::real set); J ≡ {t0::real..t1::real}; (0::real) ≤ t1; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; t ≤ ta; ta ≤ (0::real)⟧ ⟹ ta ∈ {ta..0::real}› 2. ‹⋀ta::real. ⟦continuous_on {t::real..0::real} (vector_Dflow ((x::'a) - (x0::'a))); t ∈ (J::real set); J ≡ {t0::real..t1::real}; (0::real) ≤ t1; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; t ≤ ta; ta ≤ (0::real)⟧ ⟹ {ta..0::real} ⊆ J› 3. ‹⋀ta::real. ⟦continuous_on {t::real..0::real} (vector_Dflow ((x::'a) - (x0::'a))); t ∈ (J::real set); J ≡ {t0::real..t1::real}; (0::real) ≤ t1; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; t ≤ ta; ta ≤ (0::real)⟧ ⟹ ta = (0::real) ∧ (0::real) = ta ∨ ta = ta ∧ (0::real) = (0::real)› 4. ‹⟦continuous_on {t::real..0::real} (vector_Dflow ((x::'a) - (x0::'a))); t ∈ (J::real set); J ≡ {t0::real..t1::real}; (0::real) ≤ t1; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x⟧ ⟹ continuous_on {t..0::real} (λt::real. norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t))› 5. ‹⋀ta::real. ⟦continuous_on {t::real..0::real} (vector_Dflow ((x::'a) - (x0::'a))); t ∈ (J::real set); J ≡ {t0::real..t1::real}; (0::real) ≤ t1; J ⊆ existence_ivl0 x0; J ⊆ existence_ivl0 x; t ≤ ta; ta ≤ (0::real)⟧ ⟹ (0::real) ≤ norm (Y (x - x0) ta - flow0 x0 ta - vector_Dflow (x - x0) ta)› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*))[1]) (*discuss goal 4*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*))[1]) (*discuss goal 5*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 290 facts*))[1]) (*proven 5 subgoals*) . ultimately show "?thesis" (*goal: ‹norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * ¦t¦)›*) by simp qed also (*calculation: ‹norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ ¦t¦ * dist x0 x * exp (K * ¦t¦) * e1 * exp (N * ¦t¦)›*) have "... = dist x x0 * (¦t¦ * exp (K * ¦t¦) * e1 * exp (N * ¦t¦))" by (auto simp: dist_commute (*‹dist ?x ?y = dist ?y ?x›*)) also (*calculation: ‹norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) ≤ dist x x0 * (¦t¦ * exp (K * ¦t¦) * e1 * exp (N * ¦t¦))›*) have "... < norm (x - x0) * e" unfolding e1_def (*goal: ‹dist x x0 * (¦t¦ * exp (K * ¦t¦) * (e' / (¦t¦ * exp (K * ¦t¦) * exp (N * ¦t¦))) * exp (N * ¦t¦)) < norm (x - x0) * e›*) using ‹e' < e› (*‹e' < e›*) ‹0 < ¦t¦› (*‹0 < ¦t¦›*) ‹0 < e1› (*‹0 < e1›*) x_x0_dist(1) (*‹0 < dist x x0›*) by (simp add: dist_norm (*‹dist (?x::?'a::dist_norm) (?y::?'a::dist_norm) = norm (?x - ?y)›*)) finally (*calculation: ‹norm (Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) < norm (x - x0) * e›*) show "norm ((Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) < e" apply simp (*goal: ‹norm ((Y (x - x0) t - flow0 x0 t - vector_Dflow (x - x0) t) /⇩R norm (x - x0)) < e›*) by (metis x_x0_dist( (*‹0 < dist x x0›*) 1) dist_norm (*‹dist ?x ?y = norm (?x - ?y)›*) divide_inverse (*‹?a / ?b = ?a * inverse ?b›*) mult.commute (*‹?a * ?b = ?b * ?a›*) pos_divide_less_eq (*‹0 < ?c ⟹ (?b / ?c < ?a) = (?b < ?a * ?c)›*)) qed qed qed qed lemma local_lipschitz_A: "OT ⊆ existence_ivl0 x0 ⟹ local_lipschitz OT (OS::('a ⇒⇩L 'a) set) (λt. (o⇩L) (vareq x0 t))" apply (rule local_lipschitz_subset[OF _ _ subset_UNIV, where T="existence_ivl0 x0"] (*‹⟦local_lipschitz (existence_ivl0 x0) UNIV ?f; ?S ⊆ existence_ivl0 x0⟧ ⟹ local_lipschitz ?S ?Y ?f›*)) (*goals: 1. ‹OT ⊆ existence_ivl0 x0 ⟹ local_lipschitz (existence_ivl0 x0) UNIV (λt. (o⇩L) (vareq x0 t))› 2. ‹OT ⊆ existence_ivl0 x0 ⟹ OT ⊆ existence_ivl0 x0› discuss goal 1*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) vareq_def (*‹vareq ?x0.0 ?t = f' (flow0 ?x0.0 ?t)›*) intro!: c1_implies_local_lipschitz[where f'="λ(t, x). comp3 (f' (flow0 x0 t))"] (*‹⟦⋀t x. ⟦t ∈ ?T; x ∈ ?X⟧ ⟹ (?f t has_derivative blinfun_apply (case (t, x) of (t, x) ⇒ comp3 (f' (flow0 x0 t)))) (at x); continuous_on (?T × ?X) (λ(t, x). comp3 (f' (flow0 x0 t))); open ?T; open ?X⟧ ⟹ local_lipschitz ?T ?X ?f›*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) blinfun_eqI (*‹(⋀i. blinfun_apply ?x i = blinfun_apply ?y i) ⟹ ?x = ?y›*) ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 282 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*))[1]) (*discuss goal 2*) apply ((auto simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) vareq_def (*‹vareq ?x0.0 ?t = f' (flow0 ?x0.0 ?t)›*) intro!: c1_implies_local_lipschitz[where f'="λ(t, x). comp3 (f' (flow0 x0 t))"] (*‹⟦⋀t x. ⟦t ∈ ?T; x ∈ ?X⟧ ⟹ (?f t has_derivative blinfun_apply (case (t, x) of (t, x) ⇒ comp3 (f' (flow0 x0 t)))) (at x); continuous_on (?T × ?X) (λ(t, x). comp3 (f' (flow0 x0 t))); open ?T; open ?X⟧ ⟹ local_lipschitz ?T ?X ?f›*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) blinfun_eqI (*‹(⋀i. blinfun_apply ?x i = blinfun_apply ?y i) ⟹ ?x = ?y›*) ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*) continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 282 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*))[1]) (*proven 2 subgoals*) . lemma total_derivative_ll_on_open: "ll_on_open (existence_ivl0 x0) (λt. blinfun_compose (vareq x0 t)) (UNIV::('a ⇒⇩L 'a) set)" apply standard (*goals: 1. ‹local_lipschitz (existence_ivl0 x0) UNIV (λt. (o⇩L) (vareq x0 t))› 2. ‹⋀x. x ∈ UNIV ⟹ continuous_on (existence_ivl0 x0) (λt. vareq x0 t o⇩L x)› 3. ‹open (existence_ivl0 x0)› 4. ‹open UNIV› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 282 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 x0) ?OS (λt. (o⇩L) (vareq x0 t))›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a::topological_space set); open (?T::?'a::topological_space set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. open ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b::type set); ∀x::?'b::type∈?A. open ((?B::?'b::type ⇒ ?'a::topological_space set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a::topological_space set); closed (?T::?'a::topological_space set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b::type∈?A::?'b::type set. closed ((?B::?'b::type ⇒ ?'a::topological_space set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a::topological_space set∈?K::?'a::topological_space set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a::topological_space set set); ∀T::?'a::topological_space set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 282 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 (x0::'a::euclidean_space)) (?OS::('a::euclidean_space ⇒⇩L 'a::euclidean_space) set) (λt::real. (o⇩L) (vareq x0 t))›*))[1]) (*discuss goal 3*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 282 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 x0) ?OS (λt. (o⇩L) (vareq x0 t))›*))[1]) (*discuss goal 4*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 282 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 x0) ?OS (λt. (o⇩L) (vareq x0 t))›*))[1]) (*proven 4 subgoals*) . end end sublocale mvar: ll_on_open "existence_ivl0 x0" "λt. blinfun_compose (vareq x0 t)" "UNIV::('a ⇒⇩L 'a) set" for x0 by (rule total_derivative_ll_on_open (*‹ll_on_open (existence_ivl0 (?x0.0::'a)) (λt::real. (o⇩L) (vareq ?x0.0 t)) UNIV›*)) lemma mvar_existence_ivl_eq_existence_ivl[simp]:― ‹TODO: unify with @{thm varexivl_eq_exivl}› assumes "t ∈ existence_ivl0 x0" shows "mvar.existence_ivl x0 t = (λ_. existence_ivl0 x0)" proof (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*), rule mvar.existence_ivl_eq_domain (*‹⟦?t0.0 ∈ existence_ivl0 ?x0a; ?x0.0 ∈ UNIV; ⋀tm tM t x. ⟦tm ∈ existence_ivl0 ?x0a; tM ∈ existence_ivl0 ?x0a⟧ ⟹ ∃M L. ∀t∈{tm..tM}. ∀x∈UNIV. norm (vareq ?x0a t o⇩L x) ≤ M + L * norm x; is_interval (existence_ivl0 ?x0a); UNIV = UNIV⟧ ⟹ mvar.existence_ivl ?x0a ?t0.0 ?x0.0 = existence_ivl0 ?x0a›*)) (*goals: 1. ‹⋀_. t ∈ existence_ivl0 x0› 2. ‹⋀uu_. uu_ ∈ UNIV› 3. ‹⋀_ tm tM t x. ⟦tm ∈ existence_ivl0 x0; tM ∈ existence_ivl0 x0⟧ ⟹ ∃M L. ∀t∈{tm..tM}. ∀x∈UNIV. norm (vareq x0 t o⇩L x) ≤ M + L * norm x› 4. ‹⋀_. is_interval (existence_ivl0 x0)› 5. ‹⋀_. UNIV = UNIV›*) fix s and t and x assume s: "s ∈ existence_ivl0 x0" and t: "t ∈ existence_ivl0 x0" (*‹(s::real) ∈ existence_ivl0 (x0::'a)› ‹(t::real) ∈ existence_ivl0 (x0::'a)›*) then have "{s .. t} ⊆ existence_ivl0 x0" by (meson atLeastAtMost_iff (*‹(?i ∈ {?l..?u}) = (?l ≤ ?i ∧ ?i ≤ ?u)›*) is_interval_1 (*‹is_interval ?s = (∀a∈?s. ∀b∈?s. ∀x. a ≤ x ∧ x ≤ b ⟶ x ∈ ?s)›*) is_interval_existence_ivl (*‹is_interval (existence_ivl0 ?x0.0)›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) then have "continuous_on {s .. t} (vareq x0)" by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*)) then have "compact (vareq x0 ` {s .. t})" using compact_Icc (*‹compact {?a..?b}›*) by (rule compact_continuous_image (*‹⟦continuous_on (?s::?'a set) (?f::?'a ⇒ ?'b); compact ?s⟧ ⟹ compact (?f ` ?s)›*)) then obtain B where B: "⋀u. u ∈ {s .. t} ⟹ norm (vareq x0 u) ≤ B" (*goal: ‹(⋀B. (⋀u. u ∈ {s..t} ⟹ norm (vareq x0 u) ≤ B) ⟹ thesis) ⟹ thesis›*) by (force dest!: compact_imp_bounded (*‹compact ?U ⟹ bounded ?U›*) simp: bounded_iff (*‹bounded ?S = (∃a. ∀x∈?S. norm x ≤ a)›*)) show "∃M L. ∀t∈{s .. t}. ∀x∈UNIV. norm (vareq x0 t o⇩L x) ≤ M + L * norm x" unfolding o_def (*goal: ‹∃M L. ∀t∈{s..t}. ∀x∈UNIV. norm (vareq x0 t o⇩L x) ≤ M + L * norm x›*) apply (rule exI[where x=0] (*‹?P 0 ⟹ ∃x. ?P x›*)) (*goal: ‹∃(M::real) L::real. ∀t::real∈{s::real..t::real}. ∀x::'b ⇒⇩L 'a∈UNIV. norm (vareq (x0::'a) t o⇩L x) ≤ M + L * norm x›*) apply (rule exI[where x=B] (*‹?P B ⟹ ∃x. ?P x›*)) (*goal: ‹∃L::real. ∀t::real∈{s::real..t::real}. ∀x::'b ⇒⇩L 'a∈UNIV. norm (vareq (x0::'a) t o⇩L x) ≤ (0::real) + L * norm x›*) by (auto intro!: order_trans[OF norm_blinfun_compose] (*‹norm ?f1 * norm ?g1 ≤ ?z ⟹ norm (?f1 o⇩L ?g1) ≤ ?z›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) B (*‹?u ∈ {s..t} ⟹ norm (vareq x0 ?u) ≤ B›*)) qed (auto intro: assms (*‹t ∈ existence_ivl0 x0›*)) (*solves the remaining goals: 1. ‹⋀_. t ∈ existence_ivl0 x0› 2. ‹⋀uu_. uu_ ∈ UNIV› 3. ‹⋀_. is_interval (existence_ivl0 x0)› 4. ‹⋀_. UNIV = UNIV›*) lemma assumes "t ∈ existence_ivl0 x0" shows "continuous_on (UNIV × existence_ivl0 x0) (λ(x, ta). mvar.flow x0 t x ta)" proof (-) (*goal: ‹continuous_on (UNIV × existence_ivl0 x0) (λ(x, ta). mvar.flow x0 t x ta)›*) from mvar.flow_continuous_on_state_space[of x0 t, unfolded mvar_existence_ivl_eq_existence_ivl [ OF assms ]] (*‹continuous_on (UNIV × existence_ivl0 x0) (λ(x, ta). mvar.flow x0 t x ta)›*) show "continuous_on (UNIV × existence_ivl0 x0) (λ(x, ta). mvar.flow x0 t x ta)" . qed definition "Dflow x0 = mvar.flow x0 0 id_blinfun" lemma var_eq_mvar: assumes "t0 ∈ existence_ivl0 x0" assumes "t ∈ existence_ivl0 x0" shows "var.flow x0 t0 i t = mvar.flow x0 t0 id_blinfun t i" apply (rule var.flow_unique (*‹⟦?t ∈ var.existence_ivl ?x0a ?t0.0 ?x0.0; ?phi ?t0.0 = ?x0.0; ⋀t. t ∈ var.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ (?phi has_vector_derivative blinfun_apply (vareq ?x0a t) (?phi t)) (at t); ⋀t. t ∈ var.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ ?phi t ∈ UNIV⟧ ⟹ var.flow ?x0a ?t0.0 ?x0.0 ?t = ?phi ?t›*)) (*goals: 1. ‹t ∈ var.existence_ivl x0 t0 i› 2. ‹blinfun_apply (mvar.flow x0 t0 1⇩L t0) i = i› 3. ‹⋀t. t ∈ var.existence_ivl x0 t0 i ⟹ ((λa. blinfun_apply (mvar.flow x0 t0 1⇩L a) i) has_vector_derivative blinfun_apply (vareq x0 t) (blinfun_apply (mvar.flow x0 t0 1⇩L t) i)) (at t)› 4. ‹⋀t. t ∈ var.existence_ivl x0 t0 i ⟹ blinfun_apply (mvar.flow x0 t0 1⇩L t) i ∈ UNIV› discuss goal 1*) apply ((auto intro!: assms (*‹t0 ∈ existence_ivl0 x0› ‹t ∈ existence_ivl0 x0›*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) mvar.flow_has_derivative (*‹?t ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ (mvar.flow ?x0a ?t0.0 ?x0.0 has_derivative (λi. i *⇩R (vareq ?x0a ?t o⇩L mvar.flow ?x0a ?t0.0 ?x0.0 ?t))) (at ?t)›*) simp: varexivl_eq_exivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ var.existence_ivl ?x0.0 ?t ?a = existence_ivl0 ?x0.0›*) assms (*‹t0 ∈ existence_ivl0 x0› ‹t ∈ existence_ivl0 x0›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*discuss goal 2*) apply ((auto intro!: assms (*‹(t0::real) ∈ existence_ivl0 (x0::'a)› ‹(t::real) ∈ existence_ivl0 (x0::'a)›*) derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) mvar.flow_has_derivative (*‹(?t::real) ∈ mvar.existence_ivl (?x0a::'a) (?t0.0::real) (?x0.0::'a ⇒⇩L 'a) ⟹ (mvar.flow ?x0a ?t0.0 ?x0.0 has_derivative (λi::real. i *⇩R (vareq ?x0a ?t o⇩L mvar.flow ?x0a ?t0.0 ?x0.0 ?t))) (at ?t)›*) simp: varexivl_eq_exivl (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ var.existence_ivl ?x0.0 ?t (?a::'a) = existence_ivl0 ?x0.0›*) assms (*‹(t0::real) ∈ existence_ivl0 (x0::'a)› ‹(t::real) ∈ existence_ivl0 (x0::'a)›*) has_vector_derivative_def (*‹((?f::real ⇒ ?'b) has_vector_derivative (?f'::?'b)) (?net::real filter) = (?f has_derivative (λx::real. x *⇩R ?f')) ?net›*) blinfun.bilinear_simps (*‹blinfun_apply ((?a::?'a ⇒⇩L ?'b) + (?a'::?'a ⇒⇩L ?'b)) (?b::?'a) = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply (?a::?'a ⇒⇩L ?'b) ((?b::?'a) + (?b'::?'a)) = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply ((?a::?'a ⇒⇩L ?'b) - (?a'::?'a ⇒⇩L ?'b)) (?b::?'a) = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply (?a::?'a ⇒⇩L ?'b) ((?b::?'a) - (?b'::?'a)) = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- (?a::?'a ⇒⇩L ?'b)) (?b::?'a) = - blinfun_apply ?a ?b› ‹blinfun_apply (?a::?'a ⇒⇩L ?'b) (- (?b::?'a)) = - blinfun_apply ?a ?b› ‹blinfun_apply ((?r::real) *⇩R (?a::?'a ⇒⇩L ?'b)) (?b::?'a) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply (?a::?'a ⇒⇩L ?'b) ((?r::real) *⇩R (?b::?'a)) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply (0::?'a ⇒⇩L ?'b) (?b::?'a) = (0::?'b)› ‹blinfun_apply (?a::?'a ⇒⇩L ?'b) (0::?'a) = (0::?'b)› ‹blinfun_apply (sum (?g::?'d ⇒ ?'a ⇒⇩L ?'b) (?S::?'d set)) (?x::?'a) = (∑i::?'d∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply (?x::?'a ⇒⇩L ?'b) (sum (?g::?'d ⇒ ?'a) (?S::?'d set)) = (∑i::?'d∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*discuss goal 3*) apply ((auto intro!: assms (*‹t0 ∈ existence_ivl0 x0› ‹t ∈ existence_ivl0 x0›*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) mvar.flow_has_derivative (*‹?t ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ (mvar.flow ?x0a ?t0.0 ?x0.0 has_derivative (λi. i *⇩R (vareq ?x0a ?t o⇩L mvar.flow ?x0a ?t0.0 ?x0.0 ?t))) (at ?t)›*) simp: varexivl_eq_exivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ var.existence_ivl ?x0.0 ?t ?a = existence_ivl0 ?x0.0›*) assms (*‹t0 ∈ existence_ivl0 x0› ‹t ∈ existence_ivl0 x0›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*discuss goal 4*) apply ((auto intro!: assms (*‹t0 ∈ existence_ivl0 x0› ‹t ∈ existence_ivl0 x0›*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) mvar.flow_has_derivative (*‹?t ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ (mvar.flow ?x0a ?t0.0 ?x0.0 has_derivative (λi. i *⇩R (vareq ?x0a ?t o⇩L mvar.flow ?x0a ?t0.0 ?x0.0 ?t))) (at ?t)›*) simp: varexivl_eq_exivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ var.existence_ivl ?x0.0 ?t ?a = existence_ivl0 ?x0.0›*) assms (*‹t0 ∈ existence_ivl0 x0› ‹t ∈ existence_ivl0 x0›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*))[1]) (*proven 4 subgoals*) . lemma Dflow_zero[simp]: "x ∈ X ⟹ Dflow x 0 = 1⇩L" unfolding Dflow_def (*goal: ‹(x::'a) ∈ (X::'a set) ⟹ mvar.flow x (0::real) 1⇩L (0::real) = 1⇩L›*) apply (subst mvar.flow_initial_time (*‹⟦?t0.0 ∈ existence_ivl0 ?x0a; ?x0.0 ∈ UNIV⟧ ⟹ mvar.flow ?x0a ?t0.0 ?x0.0 ?t0.0 = ?x0.0›*)) (*goals: 1. ‹(x::'a::euclidean_space) ∈ (X::'a::euclidean_space set) ⟹ (0::real) ∈ existence_ivl0 x› 2. ‹(x::'a::euclidean_space) ∈ (X::'a::euclidean_space set) ⟹ 1⇩L ∈ UNIV› 3. ‹(x::'a::euclidean_space) ∈ (X::'a::euclidean_space set) ⟹ 1⇩L = 1⇩L› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . subsection ‹Differentiability of the flow0› text ‹ ‹U t›, i.e. the solution of the variational equation, is the space derivative at the initial value ‹x0›. › lemma flow_dx_derivative: assumes "t ∈ existence_ivl0 x0" shows "((λx0. flow0 x0 t) has_derivative (λz. vector_Dflow x0 z t)) (at x0)" unfolding has_derivative_at2 (*goal: ‹bounded_linear (λz. vector_Dflow x0 z t) ∧ (λy. (1 / norm (y - x0)) *⇩R (flow0 y t - (flow0 x0 t + vector_Dflow x0 (y - x0) t))) ─x0→ 0›*) using assms (*‹t ∈ existence_ivl0 x0›*) apply (intro iffD1[OF LIM_equal proposition_17_6_weak[OF assms]] (*‹∀x. x ≠ x0 ⟶ (local.Y x0 (x - x0) t - flow0 x0 t - vector_Dflow x0 (x - x0) t) /⇩R norm (x - x0) = ?g2 x ⟹ ?g2 ─x0→ 0›*) conjI[OF bounded_linear_vector_Dflow[OF assms]] (*‹?Q ⟹ bounded_linear (λz. vector_Dflow x0 z t) ∧ ?Q›*)) (*goal: ‹bounded_linear (λz. vector_Dflow x0 z t) ∧ (λy. (1 / norm (y - x0)) *⇩R (flow0 y t - (flow0 x0 t + vector_Dflow x0 (y - x0) t))) ─x0→ 0›*) by (simp add: diff_diff_add (*‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)›*) inverse_eq_divide (*‹inverse (?a::?'a) = (1::?'a) / ?a›*)) lemma flow_dx_derivative_blinfun: assumes "t ∈ existence_ivl0 x0" shows "((λx. flow0 x t) has_derivative Blinfun (λz. vector_Dflow x0 z t)) (at x0)" by (rule has_derivative_Blinfun[OF flow_dx_derivative[OF assms]] (*‹((λx0::'a. flow0 x0 (t::real)) has_derivative blinfun_apply (Blinfun (λz::'a. vector_Dflow (x0::'a) z t))) (at x0)›*)) definition "flowderiv x0 t = comp12 (Dflow x0 t) (blinfun_scaleR_left (f (flow0 x0 t)))" lemma flowderiv_eq: "flowderiv x0 t (ξ₁, ξ₂) = (Dflow x0 t) ξ₁ + ξ₂ *⇩R f (flow0 x0 t)" by (auto simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*)) lemma W_continuous_on: "continuous_on (Sigma X existence_ivl0) (λ(x0, t). Dflow x0 t)" ― ‹TODO: somewhere here is hidden continuity wrt rhs of ODE, extract it!› unfolding continuous_on split_beta' (*goal: ‹∀x∈Sigma X existence_ivl0. ((λx. Dflow (fst x) (snd x)) ⤏ Dflow (fst x) (snd x)) (at x within Sigma X existence_ivl0)›*) proof (safe intro!: tendstoI (*‹(⋀e::real. (0::real) < e ⟹ ∀⇩F x::?'b in ?F::?'b filter. dist ((?f::?'b ⇒ ?'a) x) (?l::?'a) < e) ⟹ (?f ⤏ ?l) ?F›*)) (*goal: ‹⋀(a::'a) (b::real) e::real. ⟦(0::real) < e; a ∈ (X::'a set); b ∈ existence_ivl0 a⟧ ⟹ ∀⇩F x::'a × real in at (a, b) within Sigma X existence_ivl0. dist (Dflow (fst x) (snd x)) (Dflow (fst (a, b)) (snd (a, b))) < e›*) fix e' :: real and t and x assume x: "x ∈ X" and tx: "t ∈ existence_ivl0 x" and e': "e' > 0" (*‹(x::'a) ∈ (X::'a set)› ‹(t::real) ∈ existence_ivl0 (x::'a)› ‹(0::real) < (e'::real)›*) let ?S = "Sigma X existence_ivl0" have "(x, t) ∈ ?S" using x (*‹x ∈ X›*) tx (*‹t ∈ existence_ivl0 x›*) by auto from open_prod_elim[OF open_state_space this] (*‹(⋀A B. ⟦open A; open B; (x, t) ∈ A × B; A × B ⊆ Sigma X existence_ivl0⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain OX and OT where OXOT: "open OX" "open OT" "(x, t) ∈ OX × OT" "OX × OT ⊆ ?S" (*goal: ‹(⋀OX OT. ⟦open OX; open OT; (x, t) ∈ OX × OT; OX × OT ⊆ Sigma X existence_ivl0⟧ ⟹ thesis) ⟹ thesis›*) by blast then obtain dx and dt where dx: "dx > 0" "cball x dx ⊆ OX" and dt: "dt > 0" "cball t dt ⊆ OT" (*goal: ‹(⋀dx dt. ⟦0 < dx; cball x dx ⊆ OX; 0 < dt; cball t dt ⊆ OT⟧ ⟹ thesis) ⟹ thesis›*) by (force simp: open_contains_cball (*‹open ?S = (∀x∈?S. ∃e>0. cball x e ⊆ ?S)›*)) from OXOT (*‹open OX› ‹open OT› ‹(x, t) ∈ OX × OT› ‹OX × OT ⊆ Sigma X existence_ivl0›*) dt (*‹(0::real) < (dt::real)› ‹cball t dt ⊆ OT›*) dx (*‹0 < dx› ‹cball x dx ⊆ OX›*) have "cball t dt ⊆ existence_ivl0 x" "cball x dx ⊆ X" apply (auto simp: subset_iff (*‹(?A ⊆ ?B) = (∀t. t ∈ ?A ⟶ t ∈ ?B)›*)) (*top goal: ‹cball (t::real) (dt::real) ⊆ existence_ivl0 (x::'a::euclidean_space)› and 1 goal remains*) subgoal for ta apply (drule spec[where x=ta] (*‹∀x::'a. (?P::'a ⇒ bool) x ⟹ ?P (ta::'a)›*)) (*goal: ‹⟦open OX; open OT; ∀a b. a ∈ OX ∧ b ∈ OT ⟶ a ∈ X ∧ b ∈ existence_ivl0 a; 0 < dt; ∀ta. dist t ta ≤ dt ⟶ ta ∈ OT; 0 < dx; ∀t. dist x t ≤ dx ⟶ t ∈ OX; dist x ta ≤ dx⟧ ⟹ ta ∈ X›*) apply (drule spec[where x=t] (*‹∀x. ?P x ⟹ ?P t›*)) (*goal: ‹⟦open OX; open OT; 0 < dt; ∀ta. dist t ta ≤ dt ⟶ ta ∈ OT; 0 < dx; ∀t. dist x t ≤ dx ⟶ t ∈ OX; dist x ta ≤ dx; ∀b. ta ∈ OX ∧ b ∈ OT ⟶ ta ∈ X ∧ b ∈ existence_ivl0 ta⟧ ⟹ ta ∈ X›*) apply (drule spec[where x=t] (*‹∀x. ?P x ⟹ ?P t›*)) (*goal: ‹⟦open OX; open OT; 0 < dt; 0 < dx; ∀t. dist x t ≤ dx ⟶ t ∈ OX; dist x ta ≤ dx; ∀b. ta ∈ OX ∧ b ∈ OT ⟶ ta ∈ X ∧ b ∈ existence_ivl0 ta; dist t t ≤ dt ⟶ t ∈ OT⟧ ⟹ ta ∈ X›*) by auto . have one_exivl: "mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)" by (rule mvar_existence_ivl_eq_existence_ivl[OF existence_ivl_zero[OF ‹x ∈ X›]] (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*)) have "*": "closed ({t .. 0} ∪ {0 .. t})" "{t .. 0} ∪ {0 .. t} ≠ {}" (*goals: 1. ‹closed ({t..0} ∪ {0..t})› 2. ‹{t..0} ∪ {0..t} ≠ {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?T = "{t .. 0} ∪ {0 .. t} ∪ cball t dt" have "compact ?T" by (auto intro!: compact_Un (*‹⟦compact ?S; compact ?T⟧ ⟹ compact (?S ∪ ?T)›*)) have "?T ⊆ existence_ivl0 x" by (intro Un_least (*‹⟦?A ⊆ ?C; ?B ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) ivl_subset_existence_ivl' (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {?t..0} ⊆ existence_ivl0 ?x0.0›*) ivl_subset_existence_ivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {0..?t} ⊆ existence_ivl0 ?x0.0›*) ‹x ∈ X› ‹t ∈ existence_ivl0 x› ‹cball t dt ⊆ existence_ivl0 x›) have "compact (mvar.flow x 0 id_blinfun ` ?T)" using ‹?T ⊆ _› (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x›*) ‹x ∈ X› (*‹x ∈ X›*) mvar_existence_ivl_eq_existence_ivl[OF existence_ivl_zero [ OF ‹x ∈ X› ]] (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*) by (auto intro!: ‹0 < dx› compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) ‹compact ?T› continuous_on_subset[OF mvar.flow_continuous_on] (*‹?t ⊆ mvar.existence_ivl ?x0a1 ?t0.1 ?x0.1 ⟹ continuous_on ?t (mvar.flow ?x0a1 ?t0.1 ?x0.1)›*)) let ?line = "mvar.flow x 0 id_blinfun ` ?T" let ?X = "{x. infdist x ?line ≤ dx}" have "compact ?X" using ‹?T ⊆ _› (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x›*) ‹x ∈ X› (*‹x ∈ X›*) mvar_existence_ivl_eq_existence_ivl[OF existence_ivl_zero [ OF ‹x ∈ X› ]] (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*) by (auto intro!: compact_infdist_le (*‹⟦?A ≠ {}; compact ?A; 0 < ?e⟧ ⟹ compact {x. infdist x ?A ≤ ?e}›*) ‹0 < dx› compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) compact_Un (*‹⟦compact ?S; compact ?T⟧ ⟹ compact (?S ∪ ?T)›*) continuous_on_subset[OF mvar.flow_continuous_on (*‹?t ⊆ mvar.existence_ivl ?x0a1 ?t0.1 ?x0.1 ⟹ continuous_on ?t (mvar.flow ?x0a1 ?t0.1 ?x0.1)›*) ]) from mvar.local_lipschitz (*‹local_lipschitz (existence_ivl0 ?x0.0) UNIV (λt. (o⇩L) (vareq ?x0.0 t))›*) ‹?T ⊆ _› (*‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ existence_ivl0 (x::'a)›*) have llc: "local_lipschitz ?T ?X (λt. (o⇩L) (vareq x t))" apply (rule local_lipschitz_subset (*‹⟦local_lipschitz ?T ?X ?f; ?S ⊆ ?T; ?Y ⊆ ?X⟧ ⟹ local_lipschitz ?S ?Y ?f›*)) (*goal: ‹local_lipschitz ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) {xa::'a ⇒⇩L 'a. infdist xa (mvar.flow (x::'a) (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt)) ≤ (dx::real)} (λt::real. (o⇩L) (vareq x t))›*) by auto have cont: "⋀xa. xa ∈ ?X ⟹ continuous_on ?T (λt. vareq x t o⇩L xa)" using ‹?T ⊆ _› (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*) ‹x ∈ X›) from local_lipschitz_compact_implies_lipschitz[OF llc ‹compact ?X› ‹compact ?T› cont] (*‹⟦⋀xa. xa ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx} ⟹ xa ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}; ⋀L. (⋀ta. ta ∈ {t..0} ∪ {0..t} ∪ cball t dt ⟹ L-lipschitz_on {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx} ((o⇩L) (vareq x ta))) ⟹ ?thesis⟧ ⟹ ?thesis›*) obtain K' where K': "⋀ta. ta ∈ ?T ⟹ K'-lipschitz_on ?X ((o⇩L) (vareq x ta))" (*goal: ‹(⋀K'::real. (⋀ta::real. ta ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⟹ K'-lipschitz_on {xa::'a ⇒⇩L 'a. infdist xa (mvar.flow (x::'a) (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt)) ≤ (dx::real)} ((o⇩L) (vareq x ta))) ⟹ thesis::bool) ⟹ thesis›*) by blast define K where "K ≡ abs K' + 1" have "K > 0" by (simp add: K_def (*‹K ≡ ¦K'¦ + 1›*)) have K: "⋀ta. ta ∈ ?T ⟹ K-lipschitz_on ?X ((o⇩L) (vareq x ta))" by (auto intro!: lipschitz_onI (*‹⟦⋀x y. ⟦x ∈ ?X; y ∈ ?X⟧ ⟹ dist (?f x) (?f y) ≤ ?L * dist x y; 0 ≤ ?L⟧ ⟹ ?L-lipschitz_on ?X ?f›*) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) order_trans[OF lipschitz_onD[OF K']] (*‹⟦?ta2 ∈ {t..0} ∪ {0..t} ∪ cball t dt; ?x1 ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}; ?y1 ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}; K' * dist ?x1 ?y1 ≤ ?z⟧ ⟹ dist (vareq x ?ta2 o⇩L ?x1) (vareq x ?ta2 o⇩L ?y1) ≤ ?z›*) simp: K_def (*‹K ≡ ¦K'¦ + 1›*)) have ex_ivlI: "⋀y. y ∈ cball x dx ⟹ ?T ⊆ existence_ivl0 y" using dx (*‹(0::real) < (dx::real)› ‹cball (x::'a) (dx::real) ⊆ (OX::'a set)›*) dt (*‹0 < dt› ‹cball t dt ⊆ OT›*) OXOT (*‹open OX› ‹open OT› ‹(x::'a, t::real) ∈ (OX::'a set) × (OT::real set)› ‹OX × OT ⊆ Sigma X existence_ivl0›*) apply (intro Un_least (*‹⟦?A ⊆ ?C; ?B ⊆ ?C⟧ ⟹ ?A ∪ ?B ⊆ ?C›*) ivl_subset_existence_ivl' (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {?t..0} ⊆ existence_ivl0 ?x0.0›*) ivl_subset_existence_ivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {0..?t} ⊆ existence_ivl0 ?x0.0›*)) (*goals: 1. ‹⋀y. ⟦y ∈ cball x dx; 0 < dx; cball x dx ⊆ OX; 0 < dt; cball t dt ⊆ OT; open OX; open OT; (x, t) ∈ OX × OT; OX × OT ⊆ Sigma X existence_ivl0⟧ ⟹ t ∈ existence_ivl0 y› 2. ‹⋀y. ⟦y ∈ cball x dx; 0 < dx; cball x dx ⊆ OX; 0 < dt; cball t dt ⊆ OT; open OX; open OT; (x, t) ∈ OX × OT; OX × OT ⊆ Sigma X existence_ivl0⟧ ⟹ t ∈ existence_ivl0 y› 3. ‹⋀y. ⟦y ∈ cball x dx; 0 < dx; cball x dx ⊆ OX; 0 < dt; cball t dt ⊆ OT; open OX; open OT; (x, t) ∈ OX × OT; OX × OT ⊆ Sigma X existence_ivl0⟧ ⟹ cball t dt ⊆ existence_ivl0 y› discuss goal 1*) apply force (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*proven 3 subgoals*) . have cont: "continuous_on ((?T × ?X) × cball x dx) (λ((ta, xa), y). (vareq y ta o⇩L xa))" using ‹cball x dx ⊆ X› (*‹cball x dx ⊆ X›*) ex_ivlI (*‹?y ∈ cball x dx ⟹ {t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 ?y›*) by (force intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*) simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) have "mvar.flow x 0 id_blinfun t ∈ mvar.flow x 0 id_blinfun ` ({t..0} ∪ {0..t} ∪ cball t dt)" by auto then have mem: "(t, mvar.flow x 0 id_blinfun t, x) ∈ ?T × ?X × cball x dx" by (auto simp: ‹0 < dx› less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*)) define e where "e ≡ min e' (dx / 2) / 2" have "e > 0" using ‹e' > 0› (*‹0 < e'›*) by (auto simp: e_def (*‹e ≡ min e' (dx / 2) / 2›*) ‹0 < dx›) define d where "d ≡ e * K / (exp (K * (abs t + abs dt + 1)) - 1)" have "d > 0" by (auto simp: d_def (*‹d::real ≡ (e::real) * (K::real) / (exp (K * (¦t::real¦ + ¦dt::real¦ + (1::real))) - (1::real))›*) intro!: mult_pos_pos (*‹⟦(0::?'a::linordered_semiring_strict) < (?a::?'a::linordered_semiring_strict); (0::?'a::linordered_semiring_strict) < (?b::?'a::linordered_semiring_strict)⟧ ⟹ (0::?'a::linordered_semiring_strict) < ?a * ?b›*) divide_pos_pos (*‹⟦(0::?'a::linordered_field) < (?x::?'a::linordered_field); (0::?'a::linordered_field) < (?y::?'a::linordered_field)⟧ ⟹ (0::?'a::linordered_field) < ?x / ?y›*) ‹0 < e› ‹K > 0›) have cmpct: "compact ((?T × ?X) × cball x dx)" "compact (?T × ?X)" using ‹compact ?T› (*‹compact ({t..0} ∪ {0..t} ∪ cball t dt)›*) ‹compact ?X› (*‹compact {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}›*) apply - (*goals: 1. ‹⟦compact ({t..0} ∪ {0..t} ∪ cball t dt); compact {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}⟧ ⟹ compact ((({t..0} ∪ {0..t} ∪ cball t dt) × {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}) × cball x dx)› 2. ‹⟦compact ({t..0} ∪ {0..t} ∪ cball t dt); compact {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}⟧ ⟹ compact (({t..0} ∪ {0..t} ∪ cball t dt) × {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx})› discuss goal 1*) apply ((auto intro!: compact_cball (*‹compact (cball ?x ?e)›*) compact_Times (*‹⟦compact ?S; compact ?T⟧ ⟹ compact (?S × ?T)›*))[1]) (*discuss goal 2*) apply ((auto intro!: compact_cball (*‹compact (cball (?x::?'a::heine_borel) (?e::real))›*) compact_Times (*‹⟦compact (?S::?'a::topological_space set); compact (?T::?'b::topological_space set)⟧ ⟹ compact (?S × ?T)›*))[1]) (*proven 2 subgoals*) . have compact_line: "compact ?line" using ‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x› (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x›*) one_exivl (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*) by (force intro!: compact_continuous_image (*‹⟦continuous_on ?s ?f; compact ?s⟧ ⟹ compact (?f ` ?s)›*) ‹compact ?T› continuous_on_subset[OF mvar.flow_continuous_on] (*‹?t ⊆ mvar.existence_ivl ?x0a1 ?t0.1 ?x0.1 ⟹ continuous_on ?t (mvar.flow ?x0a1 ?t0.1 ?x0.1)›*) simp: ‹x ∈ X›) from compact_uniformly_continuous[OF cont cmpct ( 1 ), unfolded uniformly_continuous_on_def, rule_format, OF ‹0 < d›] (*‹∃da>0::real. ∀xa::(real × 'a::euclidean_space ⇒⇩L 'a::euclidean_space) × 'a::euclidean_space∈(({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) × {xa::'a::euclidean_space ⇒⇩L 'a::euclidean_space. infdist xa (mvar.flow (x::'a::euclidean_space) (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt)) ≤ (dx::real)}) × cball x dx. ∀x'::(real × 'a::euclidean_space ⇒⇩L 'a::euclidean_space) × 'a::euclidean_space∈(({t..0::real} ∪ {0::real..t} ∪ cball t dt) × {xa::'a::euclidean_space ⇒⇩L 'a::euclidean_space. infdist xa (mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt)) ≤ dx}) × cball x dx. dist x' xa < da ⟶ dist (case x' of (x::real × 'a::euclidean_space ⇒⇩L 'a::euclidean_space, xa::'a::euclidean_space) ⇒ (case x of (ta::real, xa::'a::euclidean_space ⇒⇩L 'a::euclidean_space) ⇒ λy::'a::euclidean_space. vareq y ta o⇩L xa) xa) (case xa of (x::real × 'a::euclidean_space ⇒⇩L 'a::euclidean_space, xa::'a::euclidean_space) ⇒ (case x of (ta::real, xa::'a::euclidean_space ⇒⇩L 'a::euclidean_space) ⇒ λy::'a::euclidean_space. vareq y ta o⇩L xa) xa) < (d::real)›*) obtain d' where d': "d' > 0" "⋀ta xa xa' y. ta ∈ ?T ⟹ xa ∈ ?X ⟹ xa'∈cball x dx ⟹ y∈cball x dx ⟹ dist xa' y < d' ⟹ dist (vareq xa' ta o⇩L xa) (vareq y ta o⇩L xa) < d" (*goal: ‹(⋀d'. ⟦0 < d'; ⋀ta xa xa' y. ⟦ta ∈ {t..0} ∪ {0..t} ∪ cball t dt; xa ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}; xa' ∈ cball x dx; y ∈ cball x dx; dist xa' y < d'⟧ ⟹ dist (vareq xa' ta o⇩L xa) (vareq y ta o⇩L xa) < d⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: dist_prod_def (*‹dist ?x ?y = sqrt ((dist (fst ?x) (fst ?y))² + (dist (snd ?x) (snd ?y))²)›*)) { fix y assume dxy: "dist x y < d'" (*‹dist (x::'a) (y::'a) < (d'::real)›*) assume "y ∈ cball x dx" (*‹(y::'a) ∈ cball (x::'a) (dx::real)›*) then have "y ∈ X" using dx (*‹(0::real) < (dx::real)› ‹cball x dx ⊆ OX›*) dt (*‹0 < dt› ‹cball t dt ⊆ OT›*) OXOT (*‹open OX› ‹open (OT::real set)› ‹(x, t) ∈ OX × OT› ‹OX × OT ⊆ Sigma X existence_ivl0›*) by force have two_exivl: "mvar.existence_ivl y 0 = (λ_. existence_ivl0 y)" by (rule mvar_existence_ivl_eq_existence_ivl[OF existence_ivl_zero[OF ‹y ∈ X›]] (*‹mvar.existence_ivl y 0 = (λ_. existence_ivl0 y)›*)) let ?X' = "⋃x ∈ ?line. ball x dx" have "open ?X'" by auto have "?X' ⊆ ?X" by (auto intro!: infdist_le2 (*‹⟦(?a::?'a) ∈ (?A::?'a set); dist (?x::?'a) ?a ≤ (?d::real)⟧ ⟹ infdist ?x ?A ≤ ?d›*) simp: dist_commute (*‹dist (?x::?'a) (?y::?'a) = dist ?y ?x›*)) interpret oneR: ll_on_open "existence_ivl0 x" "(λt. (o⇩L) (vareq x t))" "?X'" apply standard (*goals: 1. ‹local_lipschitz (existence_ivl0 x) (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx) (λt. (o⇩L) (vareq x t))› 2. ‹⋀xa. xa ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx) ⟹ continuous_on (existence_ivl0 x) (λt. vareq x t o⇩L xa)› 3. ‹open (existence_ivl0 x)› 4. ‹open (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)› discuss goal 1*) apply ((auto intro!: ‹x ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*discuss goal 2*) apply ((auto intro!: ‹x ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*discuss goal 3*) apply ((auto intro!: ‹x ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*discuss goal 4*) apply ((auto intro!: ‹x ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 284 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*proven 4 subgoals*) . interpret twoR: ll_on_open "existence_ivl0 y" "(λt. (o⇩L) (vareq y t))" "?X'" apply standard (*goals: 1. ‹local_lipschitz (existence_ivl0 y) (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx) (λt. (o⇩L) (vareq y t))› 2. ‹⋀xa. xa ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx) ⟹ continuous_on (existence_ivl0 y) (λt. vareq y t o⇩L xa)› 3. ‹open (existence_ivl0 y)› 4. ‹open (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)› discuss goal 1*) apply ((auto intro!: ‹y ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*discuss goal 2*) apply ((auto intro!: ‹y ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*discuss goal 3*) apply ((auto intro!: ‹y ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*discuss goal 4*) apply ((auto intro!: ‹y ∈ X› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 286 facts*) local_lipschitz_A[OF order_refl] (*‹local_lipschitz (existence_ivl0 ?x0.0) ?OS (λt. (o⇩L) (vareq ?x0.0 t))›*))[1]) (*proven 4 subgoals*) . interpret both: two_ll_on_open "(λt. (o⇩L) (vareq x t))" "existence_ivl0 x" "(λt. (o⇩L) (vareq y t))" "existence_ivl0 y" "?X'" "?T" id_blinfun d K proof (unfold_locales) (*goals: 1. ‹(0::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)› 2. ‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ oneR.existence_ivl (0::real) 1⇩L› 3. ‹is_interval ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real))› 4. ‹⋀ta::real. ta ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⟹ (K::real)-lipschitz_on (⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). ball x (dx::real)) ((o⇩L) (vareq x ta))› 5. ‹(0::real) < (K::real)› 6. ‹⋀(ta::real) xa::'a ⇒⇩L 'a. ⟦ta ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real); xa ∈ (⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). ball x (dx::real))⟧ ⟹ norm ((vareq x ta o⇩L xa) - (vareq (y::'a) ta o⇩L xa)) < (d::real)›*) show "0 < K" by (simp add: ‹0 < K›) show iv_defined: "0 ∈ {t..0} ∪ {0..t} ∪ cball t dt" by auto show "is_interval ({t..0} ∪ {0..t} ∪ cball t dt)" by (auto simp: is_interval_def (*‹is_interval ?s = (∀a∈?s. ∀b∈?s. ∀x. (∀i∈Basis. a ∙ i ≤ x ∙ i ∧ x ∙ i ≤ b ∙ i ∨ b ∙ i ≤ x ∙ i ∧ x ∙ i ≤ a ∙ i) ⟶ x ∈ ?s)›*) dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*)) show "{t..0} ∪ {0..t} ∪ cball t dt ⊆ oneR.existence_ivl 0 id_blinfun" apply (rule oneR.maximal_existence_flow[where x="mvar.flow x 0 id_blinfun"] (*‹⟦(mvar.flow x 0 1⇩L solves_ode (λt. (o⇩L) (vareq x t))) ?K (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx); mvar.flow x 0 1⇩L ?t0.0 = ?x0.0; is_interval ?K; ?t0.0 ∈ ?K; ?K ⊆ existence_ivl0 x⟧ ⟹ ?K ⊆ oneR.existence_ivl ?t0.0 ?x0.0› ‹⟦(mvar.flow x 0 1⇩L solves_ode (λt. (o⇩L) (vareq x t))) ?K (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx); mvar.flow x 0 1⇩L ?t0.0 = ?x0.0; is_interval ?K; ?t0.0 ∈ ?K; ?K ⊆ existence_ivl0 x; ?t ∈ ?K⟧ ⟹ oneR.flow ?t0.0 ?x0.0 ?t = mvar.flow x 0 1⇩L ?t›*)) (*goal: ‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ oneR.existence_ivl 0 1⇩L›*) subgoal for apply (rule solves_odeI (*‹⟦(?y has_vderiv_on (λt. ?f t (?y t))) ?T; ⋀t. t ∈ ?T ⟹ ?y t ∈ ?X⟧ ⟹ (?y solves_ode ?f) ?T ?X›*)) (*goal: ‹(mvar.flow (x::'a) (0::real) 1⇩L solves_ode (λt::real. (o⇩L) (vareq x t))) ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) (⋃x::'a ⇒⇩L 'a∈mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). ball x (dx::real))›*) apply (rule has_vderiv_on_subset[OF solves_odeD(1)[OF mvar.flow_solves_ode[of 0 x id_blinfun]]] (*‹⟦0 ∈ existence_ivl0 x; 1⇩L ∈ UNIV; ?T ⊆ mvar.existence_ivl x 0 1⇩L⟧ ⟹ (mvar.flow x 0 1⇩L has_vderiv_on (λt. vareq x t o⇩L mvar.flow x 0 1⇩L t)) ?T›*)) (*top goal: ‹(mvar.flow x 0 1⇩L has_vderiv_on (λt. vareq x t o⇩L mvar.flow x 0 1⇩L t)) ({t..0} ∪ {0..t} ∪ cball t dt)› and 1 goal remains*) subgoal for using ‹x ∈ X› (*‹(x::'a) ∈ (X::'a set)›*) ‹?T ⊆ _› (*‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ existence_ivl0 (x::'a)›*) ‹0 < dx› (*‹0 < dx›*) by simp subgoal for by simp subgoal for by (simp add: ‹cball t dt ⊆ existence_ivl0 x› ivl_subset_existence_ivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {0..?t} ⊆ existence_ivl0 ?x0.0›*) ivl_subset_existence_ivl' (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {?t..0} ⊆ existence_ivl0 ?x0.0›*) one_exivl (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*) tx (*‹t ∈ existence_ivl0 x›*)) subgoal for using dx (*‹0 < dx› ‹cball x dx ⊆ OX›*) by (msorry) . subgoal for by (simp add: ‹x ∈ X›) subgoal for by fact subgoal for using iv_defined (*‹0 ∈ {t..0} ∪ {0..t} ∪ cball t dt›*) by blast subgoal for using ‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x› (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x›*) by blast . fix s assume s: "s ∈ ?T" (*‹(s::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)›*) then show "K-lipschitz_on ?X' ((o⇩L) (vareq x s))" apply (intro lipschitz_on_subset[OF K ‹?X' ⊆ ?X›] (*‹?ta1 ∈ {t..0} ∪ {0..t} ∪ cball t dt ⟹ K-lipschitz_on (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx) ((o⇩L) (vareq x ?ta1))›*)) (*goal: ‹(K::real)-lipschitz_on (⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)). ball x (dx::real)) ((o⇩L) (vareq x (s::real)))›*) by auto fix j assume j: "j ∈ ?X'" (*‹(j::'a ⇒⇩L 'a) ∈ (⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)). ball x (dx::real))›*) show "norm ((vareq x s o⇩L j) - (vareq y s o⇩L j)) < d" unfolding dist_norm[symmetric] (*goal: ‹dist (vareq x s o⇩L j) (vareq y s o⇩L j) < d›*) apply (rule d' (*‹0 < d'› ‹⟦?ta ∈ {t..0} ∪ {0..t} ∪ cball t dt; ?xa ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ dx}; ?xa' ∈ cball x dx; ?y ∈ cball x dx; dist ?xa' ?y < d'⟧ ⟹ dist (vareq ?xa' ?ta o⇩L ?xa) (vareq ?y ?ta o⇩L ?xa) < d›*)) (*goal: ‹dist (vareq x s o⇩L j) (vareq y s o⇩L j) < d›*) subgoal for by (rule s (*‹s ∈ {t..0} ∪ {0..t} ∪ cball t dt›*)) subgoal for using ‹?X' ⊆ ?X› (*‹(⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)). ball x (dx::real)) ⊆ {xa::'a ⇒⇩L 'a. infdist xa (mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt)) ≤ dx}›*) j (*‹j ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) by standard subgoal for using ‹dx > 0› (*‹0 < dx›*) by simp subgoal for using ‹y ∈ cball x dx› (*‹(y::'a::euclidean_space) ∈ cball (x::'a::euclidean_space) (dx::real)›*) by simp subgoal for using dxy (*‹dist x y < d'›*) by simp . qed have less_e: "norm (Dflow x s - both.Y s) < e" if s: "s ∈ ?T ∩ twoR.existence_ivl 0 id_blinfun" for s proof (-) (*goal: ‹norm (Dflow x s - both.Y s) < e›*) from s (*‹s ∈ ({t..0} ∪ {0..t} ∪ cball t dt) ∩ twoR.existence_ivl 0 1⇩L›*) have s_less: "¦s¦ < ¦t¦ + ¦dt¦ + 1" by (auto simp: dist_real_def (*‹dist ?x ?y = ¦?x - ?y¦›*)) note both.norm_X_Y_bound[rule_format, OF s] (*‹norm (both.flow0 s - both.Y s) ≤ d / K * (exp (K * ¦s¦) - 1)›*) also (*calculation: ‹norm (both.flow0 s - both.Y s) ≤ d / K * (exp (K * ¦s¦) - 1)›*) have "d / K * (exp (K * ¦s¦) - 1) = e * ((exp (K * ¦s¦) - 1) / (exp (K * (¦t¦ + ¦dt¦ + 1)) - 1))" by (simp add: d_def (*‹d ≡ e * K / (exp (K * (¦t¦ + ¦dt¦ + 1)) - 1)›*)) also (*calculation: ‹norm (both.flow0 s - both.Y s) ≤ e * ((exp (K * ¦s¦) - 1) / (exp (K * (¦t¦ + ¦dt¦ + 1)) - 1))›*) have "… < e * 1" apply (rule mult_strict_left_mono[OF _ ‹0 < e›] (*‹?a < ?b ⟹ e * ?a < e * ?b›*)) (*goal: ‹e * ((exp (K * ¦s¦) - 1) / (exp (K * (¦t¦ + ¦dt¦ + 1)) - 1)) < e * 1›*) by (simp add: add_nonneg_pos (*‹⟦(0::?'a::ordered_comm_monoid_add) ≤ (?a::?'a::ordered_comm_monoid_add); (0::?'a::ordered_comm_monoid_add) < (?b::?'a::ordered_comm_monoid_add)⟧ ⟹ (0::?'a::ordered_comm_monoid_add) < ?a + ?b›*) ‹0 < K› ‹0 < e› s_less (*‹¦s::real¦ < ¦t::real¦ + ¦dt::real¦ + (1::real)›*)) also (*calculation: ‹norm (both.flow0 s - both.Y s) < e * 1›*) have "… = e" by simp also (*calculation: ‹norm (both.flow0 (s::real) - both.Y s) < (e::real)›*) from s (*‹s ∈ ({t..0} ∪ {0..t} ∪ cball t dt) ∩ twoR.existence_ivl 0 1⇩L›*) have s: "s ∈ ?T" by simp have "both.flow0 s = Dflow x s" unfolding both.flow0_def Dflow_def (*goal: ‹oneR.flow (0::real) 1⇩L (s::real) = mvar.flow (x::'a) (0::real) 1⇩L s›*) apply (rule oneR.maximal_existence_flow[where K="?T"] (*‹⟦((?x::real ⇒ 'a ⇒⇩L 'a) solves_ode (λt::real. (o⇩L) (vareq (x::'a) t))) ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) (⋃x::'a ⇒⇩L 'a∈mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). ball x (dx::real)); ?x (?t0.0::real) = (?x0.0::'a ⇒⇩L 'a); is_interval ({t..0::real} ∪ {0::real..t} ∪ cball t dt); ?t0.0 ∈ {t..0::real} ∪ {0::real..t} ∪ cball t dt; {t..0::real} ∪ {0::real..t} ∪ cball t dt ⊆ existence_ivl0 x⟧ ⟹ {t..0::real} ∪ {0::real..t} ∪ cball t dt ⊆ oneR.existence_ivl ?t0.0 ?x0.0› ‹⟦((?x::real ⇒ 'a ⇒⇩L 'a) solves_ode (λt::real. (o⇩L) (vareq (x::'a) t))) ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) (⋃x::'a ⇒⇩L 'a∈mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). ball x (dx::real)); ?x (?t0.0::real) = (?x0.0::'a ⇒⇩L 'a); is_interval ({t..0::real} ∪ {0::real..t} ∪ cball t dt); ?t0.0 ∈ {t..0::real} ∪ {0::real..t} ∪ cball t dt; {t..0::real} ∪ {0::real..t} ∪ cball t dt ⊆ existence_ivl0 x; (?t::real) ∈ {t..0::real} ∪ {0::real..t} ∪ cball t dt⟧ ⟹ oneR.flow ?t0.0 ?x0.0 ?t = ?x ?t›*)) (*goal: ‹oneR.flow 0 1⇩L s = mvar.flow x 0 1⇩L s›*) subgoal for apply (rule solves_odeI (*‹⟦(?y has_vderiv_on (λt. ?f t (?y t))) ?T; ⋀t. t ∈ ?T ⟹ ?y t ∈ ?X⟧ ⟹ (?y solves_ode ?f) ?T ?X›*)) (*goal: ‹(mvar.flow x 0 1⇩L solves_ode (λt. (o⇩L) (vareq x t))) ({t..0} ∪ {0..t} ∪ cball t dt) (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) apply (rule has_vderiv_on_subset[OF solves_odeD(1)[OF mvar.flow_solves_ode[of 0 x id_blinfun]]] (*‹⟦(0::real) ∈ existence_ivl0 (x::'a::euclidean_space); 1⇩L ∈ UNIV; (?T::real set) ⊆ mvar.existence_ivl x (0::real) 1⇩L⟧ ⟹ (mvar.flow x (0::real) 1⇩L has_vderiv_on (λt::real. vareq x t o⇩L mvar.flow x (0::real) 1⇩L t)) ?T›*)) (*top goal: ‹(mvar.flow x 0 1⇩L has_vderiv_on (λt. vareq x t o⇩L mvar.flow x 0 1⇩L t)) ({t..0} ∪ {0..t} ∪ cball t dt)› and 1 goal remains*) subgoal for using ‹x ∈ X› (*‹x ∈ X›*) ‹0 < dx› (*‹0 < dx›*) by simp subgoal for by simp subgoal for by (simp add: ‹cball t dt ⊆ existence_ivl0 x› ivl_subset_existence_ivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {0..?t} ⊆ existence_ivl0 ?x0.0›*) ivl_subset_existence_ivl' (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ {?t..0} ⊆ existence_ivl0 ?x0.0›*) one_exivl (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*) tx (*‹t ∈ existence_ivl0 x›*)) subgoal for using dx (*‹0 < dx› ‹cball x dx ⊆ OX›*) by (msorry) . subgoal for by (simp add: ‹x ∈ X›) subgoal for by (rule both.J_ivl (*‹is_interval ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real))›*)) subgoal for using both.t0_in_J (*‹(0::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)›*) by blast subgoal for using ‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x› (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 x›*) by blast subgoal for using s (*‹s ∈ {t..0} ∪ {0..t} ∪ cball t dt›*) by blast . finally (*calculation: ‹norm (Dflow x s - both.Y s) < e›*) show "?thesis" (*goal: ‹norm (Dflow (x::'a::euclidean_space) (s::real) - both.Y s) < (e::real)›*) . qed have "e < dx" using ‹dx > 0› (*‹0 < dx›*) by (auto simp: e_def (*‹e ≡ min e' (dx / 2) / 2›*)) let ?i = "{y. infdist y (mvar.flow x 0 id_blinfun ` ?T) ≤ e}" have 1: "?i ⊆ (⋃x∈mvar.flow x 0 id_blinfun ` ?T. ball x dx)" proof (-) (*goal: ‹{y. infdist y (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e} ⊆ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) have cl: "closed ?line" "?line ≠ {}" using compact_line (*‹compact (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt))›*) apply - (*goals: 1. ‹compact (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ⟹ closed (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt))› 2. ‹compact (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ⟹ mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt) ≠ {}› discuss goal 1*) apply ((auto simp: compact_imp_closed (*‹compact ?s ⟹ closed ?s›*))[1]) (*discuss goal 2*) apply ((auto simp: compact_imp_closed (*‹compact ?s ⟹ closed ?s›*))[1]) (*proven 2 subgoals*) . have "?i ⊆ (⋃y∈mvar.flow x 0 id_blinfun ` ?T. cball y e)" proof (safe) (*goal: ‹⋀xa::'a ⇒⇩L 'a. infdist xa (mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real))) ≤ (e::real) ⟹ xa ∈ (⋃y::'a ⇒⇩L 'a∈mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). cball y e)›*) fix x assume H: "infdist x ?line ≤ e" (*‹infdist (x::'a ⇒⇩L 'a) (mvar.flow (x__::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real))) ≤ (e::real)›*) from infdist_attains_inf[OF cl, of x] (*‹(⋀xb. ⟦xb ∈ mvar.flow x__ 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt); infdist x (mvar.flow x__ 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) = dist x xb⟧ ⟹ ?thesis) ⟹ ?thesis›*) obtain y where "y ∈ ?line" "infdist x ?line = dist x y" (*goal: ‹(⋀y. ⟦y ∈ mvar.flow x__ 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt); infdist x (mvar.flow x__ 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) = dist x y⟧ ⟹ thesis) ⟹ thesis›*) by auto then show "x ∈ (⋃x∈?line. cball x e)" using H (*‹infdist x (mvar.flow x__ 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e›*) by (auto simp: dist_commute (*‹dist (?x::?'a::metric_space) (?y::?'a::metric_space) = dist ?y ?x›*)) qed also (*calculation: ‹{y::'a::euclidean_space ⇒⇩L 'a::euclidean_space. infdist y (mvar.flow (x::'a::euclidean_space) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real))) ≤ (e::real)} ⊆ (⋃y::'a::euclidean_space ⇒⇩L 'a::euclidean_space∈mvar.flow x (0::real) 1⇩L ` ({t..0::real} ∪ {0::real..t} ∪ cball t dt). cball y e)›*) have "… ⊆ (⋃x∈?line. ball x dx)" using ‹e < dx› (*‹(e::real) < (dx::real)›*) by auto finally (*calculation: ‹{y. infdist y (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e} ⊆ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) show "?thesis" (*goal: ‹{y. infdist y (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e} ⊆ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) . qed have 2: "twoR.flow 0 id_blinfun s ∈ ?i" if "s ∈ ?T" "s ∈ twoR.existence_ivl 0 id_blinfun" for s proof (-) (*goal: ‹twoR.flow 0 1⇩L s ∈ {y. infdist y (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e}›*) from that (*‹s ∈ {t..0} ∪ {0..t} ∪ cball t dt› ‹s ∈ twoR.existence_ivl 0 1⇩L›*) have sT: "s ∈ ?T ∩ twoR.existence_ivl 0 id_blinfun" by force from less_e[OF this] (*‹norm (Dflow x s - both.Y s) < e›*) have "dist (twoR.flow 0 id_blinfun s) (mvar.flow x 0 id_blinfun s) ≤ e" unfolding Dflow_def both.Y_def dist_commute dist_norm (*goal: ‹norm (mvar.flow (x::'a) (0::real) 1⇩L (s::real) - twoR.flow (0::real) 1⇩L s) ≤ (e::real)›*) by simp then show "?thesis" (*goal: ‹twoR.flow (0::real) 1⇩L (s::real) ∈ {y::'a ⇒⇩L 'a. infdist y (mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real))) ≤ (e::real)}›*) using sT (*‹(s::real) ∈ ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) ∩ twoR.existence_ivl (0::real) 1⇩L›*) by (force intro: infdist_le2 (*‹⟦?a ∈ ?A; dist ?x ?a ≤ ?d⟧ ⟹ infdist ?x ?A ≤ ?d›*)) qed have T_subset: "?T ⊆ twoR.existence_ivl 0 id_blinfun" apply (rule twoR.subset_mem_compact_implies_subset_existence_interval[ where K="{x. infdist x ?line ≤ e}"] (*‹⟦?t0.0 ∈ ?T'; is_interval ?T'; ?T' ⊆ existence_ivl0 y; ?x0.0 ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx); ⋀ta. ⟦ta ∈ ?T'; ta ∈ twoR.existence_ivl ?t0.0 ?x0.0⟧ ⟹ twoR.flow ?t0.0 ?x0.0 ta ∈ {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e}; compact {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e}; {xa. infdist xa (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e} ⊆ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)⟧ ⟹ ?T' ⊆ twoR.existence_ivl ?t0.0 ?x0.0›*)) (*goal: ‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ twoR.existence_ivl (0::real) 1⇩L›*) subgoal for using ‹0 < dt› (*‹0 < dt›*) by force subgoal for by (rule both.J_ivl (*‹is_interval ({t..0} ∪ {0..t} ∪ cball t dt)›*)) subgoal for using ‹y ∈ cball x dx› (*‹y ∈ cball x dx›*) ex_ivlI (*‹?y ∈ cball x dx ⟹ {t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 ?y›*) by blast subgoal for using both.F_iv_defined(2) (*‹1⇩L ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) by blast subgoal for apply (rule 2 (*‹⟦?s ∈ {t..0} ∪ {0..t} ∪ cball t dt; ?s ∈ twoR.existence_ivl 0 1⇩L⟧ ⟹ twoR.flow 0 1⇩L ?s ∈ {y. infdist y (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e}›*)) (*goals: 1. ‹⟦ta_ ∈ {t..0} ∪ {0..t} ∪ cball t dt; ta_ ∈ twoR.existence_ivl 0 1⇩L⟧ ⟹ ta_ ∈ {t..0} ∪ {0..t} ∪ cball t dt› 2. ‹⟦ta_ ∈ {t..0} ∪ {0..t} ∪ cball t dt; ta_ ∈ twoR.existence_ivl 0 1⇩L⟧ ⟹ ta_ ∈ twoR.existence_ivl 0 1⇩L› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) subgoal for using ‹dt > 0› (*‹0 < dt›*) apply (intro compact_infdist_le (*‹⟦?A ≠ {}; compact ?A; 0 < ?e⟧ ⟹ compact {x. infdist x ?A ≤ ?e}›*)) (*goals: 1. ‹0 < dt ⟹ mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt) ≠ {}› 2. ‹0 < dt ⟹ compact (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt))› 3. ‹0 < dt ⟹ 0 < e› discuss goal 1*) apply ((auto intro!: compact_line (*‹compact (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt))›*) ‹0 < e›)[1]) (*discuss goal 2*) apply ((auto intro!: compact_line (*‹compact (mvar.flow (x::'a::euclidean_space) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)))›*) ‹0 < e›)[1]) (*discuss goal 3*) apply ((auto intro!: compact_line (*‹compact (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt))›*) ‹0 < e›)[1]) (*proven 3 subgoals*) . subgoal for by (rule 1 (*‹{y. infdist y (mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt)) ≤ e} ⊆ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*)) . also (*calculation: ‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ twoR.existence_ivl (0::real) 1⇩L›*) have "twoR.existence_ivl 0 id_blinfun ⊆ existence_ivl0 y" by (rule twoR.existence_ivl_subset (*‹twoR.existence_ivl ?t0.0 ?x0.0 ⊆ existence_ivl0 y›*)) finally (*calculation: ‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 y›*) have "?T ⊆ existence_ivl0 y" . have "norm (Dflow x s - Dflow y s) < e" if s: "s ∈ ?T" for s proof (-) (*goal: ‹norm (Dflow x s - Dflow y s) < e›*) from s (*‹s ∈ {t..0} ∪ {0..t} ∪ cball t dt›*) have "s ∈ ?T ∩ twoR.existence_ivl 0 id_blinfun" using T_subset (*‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ twoR.existence_ivl 0 1⇩L›*) by force from less_e[OF this] (*‹norm (Dflow x s - both.Y s) < e›*) have "norm (Dflow x s - both.Y s) < e" . also (*calculation: ‹norm (Dflow (x::'a::euclidean_space) (s::real) - both.Y s) < (e::real)›*) have "mvar.flow y 0 id_blinfun s = twoR.flow 0 id_blinfun s" apply (rule mvar.maximal_existence_flow[where K="?T"] (*‹⟦((?x::real ⇒ 'a::euclidean_space ⇒⇩L 'a::euclidean_space) solves_ode (λt::real. (o⇩L) (vareq (?x0a::'a::euclidean_space) t))) ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) UNIV; ?x (?t0.0::real) = (?x0.0::'a::euclidean_space ⇒⇩L 'a::euclidean_space); is_interval ({t..0::real} ∪ {0::real..t} ∪ cball t dt); ?t0.0 ∈ {t..0::real} ∪ {0::real..t} ∪ cball t dt; {t..0::real} ∪ {0::real..t} ∪ cball t dt ⊆ existence_ivl0 ?x0a⟧ ⟹ {t..0::real} ∪ {0::real..t} ∪ cball t dt ⊆ mvar.existence_ivl ?x0a ?t0.0 ?x0.0› ‹⟦((?x::real ⇒ 'a::euclidean_space ⇒⇩L 'a::euclidean_space) solves_ode (λt::real. (o⇩L) (vareq (?x0a::'a::euclidean_space) t))) ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) UNIV; ?x (?t0.0::real) = (?x0.0::'a::euclidean_space ⇒⇩L 'a::euclidean_space); is_interval ({t..0::real} ∪ {0::real..t} ∪ cball t dt); ?t0.0 ∈ {t..0::real} ∪ {0::real..t} ∪ cball t dt; {t..0::real} ∪ {0::real..t} ∪ cball t dt ⊆ existence_ivl0 ?x0a; (?t::real) ∈ {t..0::real} ∪ {0::real..t} ∪ cball t dt⟧ ⟹ mvar.flow ?x0a ?t0.0 ?x0.0 ?t = ?x ?t›*)) (*goal: ‹mvar.flow y 0 1⇩L s = twoR.flow 0 1⇩L s›*) subgoal for apply (rule solves_odeI (*‹⟦((?y::real ⇒ ?'a) has_vderiv_on (λt::real. (?f::real ⇒ ?'a ⇒ ?'a) t (?y t))) (?T::real set); ⋀t::real. t ∈ ?T ⟹ ?y t ∈ (?X::?'a set)⟧ ⟹ (?y solves_ode ?f) ?T ?X›*)) (*goal: ‹(twoR.flow (0::real) 1⇩L solves_ode (λt::real. (o⇩L) (vareq (y::'a) t))) ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)) UNIV›*) apply (rule has_vderiv_on_subset[OF solves_odeD(1)[OF twoR.flow_solves_ode[of 0 id_blinfun]]] (*‹⟦(0::real) ∈ existence_ivl0 (y::'a); 1⇩L ∈ (⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)). ball x (dx::real)); (?T::real set) ⊆ twoR.existence_ivl (0::real) 1⇩L⟧ ⟹ (twoR.flow (0::real) 1⇩L has_vderiv_on (λt::real. vareq y t o⇩L twoR.flow (0::real) 1⇩L t)) ?T›*)) (*top goal: ‹(twoR.flow 0 1⇩L has_vderiv_on (λt. vareq y t o⇩L twoR.flow 0 1⇩L t)) ({t..0} ∪ {0..t} ∪ cball t dt)› and 1 goal remains*) subgoal for using ‹y ∈ X› (*‹y ∈ X›*) by simp subgoal for using both.F_iv_defined(2) (*‹1⇩L ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) by blast subgoal for using T_subset (*‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ twoR.existence_ivl (0::real) 1⇩L›*) by blast subgoal for by simp . subgoal for using ‹y ∈ X› (*‹(y::'a) ∈ (X::'a set)›*) auto_ll_on_open.existence_ivl_zero (*‹⟦auto_ll_on_open (?f::?'a ⇒ ?'a) (?X::?'a set); (?x0.0::?'a) ∈ ?X⟧ ⟹ (0::real) ∈ auto_ll_on_open.existence_ivl0 ?f ?X ?x0.0›*) auto_ll_on_open_axioms (*‹auto_ll_on_open f X›*) both.F_iv_defined(2) (*‹1⇩L ∈ (⋃x∈mvar.flow x 0 1⇩L ` ({t..0} ∪ {0..t} ∪ cball t dt). ball x dx)›*) twoR.flow_initial_time (*‹⟦(?t0.0::real) ∈ existence_ivl0 (y::'a); (?x0.0::'a ⇒⇩L 'a) ∈ (⋃x::'a ⇒⇩L 'a∈mvar.flow (x::'a) (0::real) 1⇩L ` ({t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)). ball x (dx::real))⟧ ⟹ twoR.flow ?t0.0 ?x0.0 ?t0.0 = ?x0.0›*) by blast subgoal for by (rule both.J_ivl (*‹is_interval ({t..0} ∪ {0..t} ∪ cball t dt)›*)) subgoal for using both.t0_in_J (*‹0 ∈ {t..0} ∪ {0..t} ∪ cball t dt›*) by blast subgoal for using ‹{t..0} ∪ {0..t} ∪ cball t dt ⊆ existence_ivl0 y› (*‹{t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real) ⊆ existence_ivl0 (y::'a)›*) by blast subgoal for using s (*‹(s::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)›*) by blast . then have "both.Y s = Dflow y s" unfolding both.Y_def Dflow_def (*goal: ‹twoR.flow 0 1⇩L s = mvar.flow y 0 1⇩L s›*) by simp finally (*calculation: ‹norm (Dflow x s - Dflow y s) < e›*) show "?thesis" (*goal: ‹norm (Dflow x s - Dflow y s) < e›*) . qed } note cont_data = this (*‹⟦dist x ?y3 < d'; ?y3 ∈ cball x dx; ?s ∈ {t..0} ∪ {0..t} ∪ cball t dt⟧ ⟹ norm (Dflow x ?s - Dflow ?y3 ?s) < e›*) have "∀⇩F (y, s) in at (x, t) within ?S. dist x y < d'" unfolding at_within_open[OF ‹(x, t) ∈ ?S› open_state_space] UNIV_Times_UNIV[symmetric] (*goal: ‹∀⇩F (y, s) in at (x, t) within UNIV × UNIV. dist x y < d'›*) using ‹d' > 0› (*‹0 < d'›*) apply (intro eventually_at_Pair_within_TimesI1 (*‹⟦eventually ?P (at ?x within ?X); ?P ?x⟧ ⟹ ∀⇩F (x', y') in at (?x, ?y) within ?X × ?Y. ?P x'›*)) (*goals: 1. ‹(0::real) < (d'::real) ⟹ ∀⇩F y::'a in at x. dist (x::'a) y < d'› 2. ‹(0::real) < (d'::real) ⟹ dist (x::'a) x < d'› discuss goal 1*) apply ((auto simp: eventually_at (*‹eventually ?P (at ?a within ?S) = (∃d>0. ∀x∈?S. x ≠ ?a ∧ dist x ?a < d ⟶ ?P x)›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: eventually_at (*‹eventually (?P::?'a ⇒ bool) (at (?a::?'a) within (?S::?'a set)) = (∃d>0::real. ∀x::?'a∈?S. x ≠ ?a ∧ dist x ?a < d ⟶ ?P x)›*) less_imp_le (*‹(?x::?'a) < (?y::?'a) ⟹ ?x ≤ ?y›*) dist_commute (*‹dist (?x::?'a) (?y::?'a) = dist ?y ?x›*))[1]) (*proven 2 subgoals*) . moreover have "∀⇩F (y, s) in at (x, t) within ?S. y ∈ cball x dx" unfolding at_within_open[OF ‹(x, t) ∈ ?S› open_state_space] UNIV_Times_UNIV[symmetric] (*goal: ‹∀⇩F (y, s) in at (x, t) within UNIV × UNIV. y ∈ cball x dx›*) using ‹dx > 0› (*‹0 < dx›*) apply (intro eventually_at_Pair_within_TimesI1 (*‹⟦eventually (?P::?'a ⇒ bool) (at (?x::?'a) within (?X::?'a set)); ?P ?x⟧ ⟹ ∀⇩F (x'::?'a, y'::?'b) in at (?x, ?y::?'b) within ?X × (?Y::?'b set). ?P x'›*)) (*goals: 1. ‹0 < dx ⟹ ∀⇩F y in at x. y ∈ cball x dx› 2. ‹0 < dx ⟹ x ∈ cball x dx› discuss goal 1*) apply ((auto simp: eventually_at (*‹eventually (?P::?'a ⇒ bool) (at (?a::?'a) within (?S::?'a set)) = (∃d>0::real. ∀x::?'a∈?S. x ≠ ?a ∧ dist x ?a < d ⟶ ?P x)›*) less_imp_le (*‹(?x::?'a) < (?y::?'a) ⟹ ?x ≤ ?y›*) dist_commute (*‹dist (?x::?'a) (?y::?'a) = dist ?y ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: eventually_at (*‹eventually ?P (at ?a within ?S) = (∃d>0. ∀x∈?S. x ≠ ?a ∧ dist x ?a < d ⟶ ?P x)›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*))[1]) (*proven 2 subgoals*) . moreover have "∀⇩F (y, s) in at (x, t) within ?S. s ∈ ?T" unfolding at_within_open[OF ‹(x, t) ∈ ?S› open_state_space] UNIV_Times_UNIV[symmetric] (*goal: ‹∀⇩F (y, s) in at (x, t) within UNIV × UNIV. s ∈ {t..0} ∪ {0..t} ∪ cball t dt›*) using ‹dt > 0› (*‹0 < dt›*) apply (intro eventually_at_Pair_within_TimesI2 (*‹⟦eventually ?P (at ?y within ?Y); ?P ?y⟧ ⟹ ∀⇩F (x', y') in at (?x, ?y) within ?X × ?Y. ?P y'›*)) (*goals: 1. ‹0 < dt ⟹ ∀⇩F s in at t. s ∈ {t..0} ∪ {0..t} ∪ cball t dt› 2. ‹0 < dt ⟹ t ∈ {t..0} ∪ {0..t} ∪ cball t dt› discuss goal 1*) apply ((auto simp: eventually_at (*‹eventually ?P (at ?a within ?S) = (∃d>0. ∀x∈?S. x ≠ ?a ∧ dist x ?a < d ⟶ ?P x)›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*))[1]) (*discuss goal 2*) apply ((auto simp: eventually_at (*‹eventually ?P (at ?a within ?S) = (∃d>0. ∀x∈?S. x ≠ ?a ∧ dist x ?a < d ⟶ ?P x)›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*) dist_commute (*‹dist ?x ?y = dist ?y ?x›*))[1]) (*proven 2 subgoals*) . moreover have "0 ∈ existence_ivl0 x" by (simp add: ‹x ∈ X›) have "∀⇩F y in at t within existence_ivl0 x. dist (mvar.flow x 0 id_blinfun y) (mvar.flow x 0 id_blinfun t) < e" using mvar.flow_continuous_on[of x 0 id_blinfun] (*‹continuous_on (mvar.existence_ivl x 0 1⇩L) (mvar.flow x 0 1⇩L)›*) using ‹0 < e› (*‹0 < e›*) tx (*‹t ∈ existence_ivl0 x›*) by (auto simp add: continuous_on (*‹continuous_on ?s ?f = (∀x∈?s. (?f ⤏ ?f x) (at x within ?s))›*) one_exivl (*‹mvar.existence_ivl x 0 = (λ_. existence_ivl0 x)›*) dest!: tendstoD (*‹⟦(?f ⤏ ?l) ?F; 0 < ?e⟧ ⟹ ∀⇩F x in ?F. dist (?f x) ?l < ?e›*)) then have "∀⇩F (y, s) in at (x, t) within ?S. dist (Dflow x s) (Dflow x t) < e" using ‹0 < e› (*‹(0::real) < (e::real)›*) unfolding at_within_open[OF ‹(x, t) ∈ ?S› open_state_space] UNIV_Times_UNIV[symmetric] Dflow_def (*goal: ‹∀⇩F (y, s) in at (x, t) within UNIV × UNIV. dist (mvar.flow x 0 1⇩L s) (mvar.flow x 0 1⇩L t) < e›*) apply (intro eventually_at_Pair_within_TimesI2 (*‹⟦eventually ?P (at ?y within ?Y); ?P ?y⟧ ⟹ ∀⇩F (x', y') in at (?x, ?y) within ?X × ?Y. ?P y'›*)) (*goals: 1. ‹⟦∀⇩F y in at t within existence_ivl0 x. dist (mvar.flow x 0 1⇩L y) (mvar.flow x 0 1⇩L t) < e; 0 < e⟧ ⟹ ∀⇩F s in at t. dist (mvar.flow x 0 1⇩L s) (mvar.flow x 0 1⇩L t) < e› 2. ‹⟦∀⇩F y in at t within existence_ivl0 x. dist (mvar.flow x 0 1⇩L y) (mvar.flow x 0 1⇩L t) < e; 0 < e⟧ ⟹ dist (mvar.flow x 0 1⇩L t) (mvar.flow x 0 1⇩L t) < e› discuss goal 1*) apply ((auto simp: at_within_open[OF tx open_existence_ivl] (*‹at (t::real) within existence_ivl0 (x::'a) = at t›*))[1]) (*discuss goal 2*) apply ((auto simp: at_within_open[OF tx open_existence_ivl] (*‹at t within existence_ivl0 x = at t›*))[1]) (*proven 2 subgoals*) . ultimately have "∀⇩F (y, s) in at (x, t) within ?S. dist (Dflow y s) (Dflow x t) < e'" apply eventually_elim (*goal: ‹∀⇩F (y, s) in at (x, t) within Sigma X existence_ivl0. dist (Dflow y s) (Dflow x t) < e'›*) apply (safe del: UnE (*‹⟦?c ∈ ?A ∪ ?B; ?c ∈ ?A ⟹ ?P; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*)) (*goal: ‹⋀xa::'a × real. ⟦case xa of (y::'a, s::real) ⇒ dist (x::'a) y < (d'::real); case xa of (y::'a, s::real) ⇒ y ∈ cball x (dx::real); case xa of (y::'a, s::real) ⇒ s ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real); case xa of (y::'a, s::real) ⇒ dist (Dflow x s) (Dflow x t) < (e::real)⟧ ⟹ case xa of (y::'a, s::real) ⇒ dist (Dflow y s) (Dflow x t) < (e'::real)›*) proof (goal_cases) (*goal: ‹⋀(a::'a) b::real. ⟦dist (x::'a) a < (d'::real); a ∈ cball x (dx::real); b ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real); dist (Dflow x b) (Dflow x t) < (e::real)⟧ ⟹ dist (Dflow a b) (Dflow x t) < (e'::real)›*) case (1 y s) (*‹dist x y < d'› ‹y ∈ cball x dx› ‹(s::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)› ‹dist (Dflow x s) (Dflow x t) < e›*) have "dist (Dflow y s) (Dflow x t) ≤ dist (Dflow y s) (Dflow x s) + dist (Dflow x s) (Dflow x t)" by (rule dist_triangle (*‹dist (?x::?'a) (?z::?'a) ≤ dist ?x (?y::?'a) + dist ?y ?z›*)) also (*calculation: ‹dist (Dflow (y::'a) (s::real)) (Dflow (x::'a) (t::real)) ≤ dist (Dflow y s) (Dflow x s) + dist (Dflow x s) (Dflow x t)›*) have "dist (Dflow x s) (Dflow x t) < e" by (rule 1 (*‹dist (x::'a) (y::'a) < (d'::real)› ‹(y::'a) ∈ cball (x::'a) (dx::real)› ‹(s::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)› ‹dist (Dflow (x::'a) (s::real)) (Dflow x (t::real)) < (e::real)›*)) also (*calculation: ‹(⋀xa ya. xa < ya ⟹ dist (Dflow y s) (Dflow x s) + xa < dist (Dflow y s) (Dflow x s) + ya) ⟹ dist (Dflow y s) (Dflow x t) < dist (Dflow y s) (Dflow x s) + e›*) have "dist (Dflow y s) (Dflow x s) < e" unfolding dist_norm norm_minus_commute (*goal: ‹norm (Dflow x s - Dflow y s) < e›*) using "1" (*‹dist x y < d'› ‹y ∈ cball x dx› ‹(s::real) ∈ {t::real..0::real} ∪ {0::real..t} ∪ cball t (dt::real)› ‹dist (Dflow (x::'a) (s::real)) (Dflow x (t::real)) < (e::real)›*) apply (intro cont_data (*‹⟦dist x ?y3 < d'; ?y3 ∈ cball x dx; ?s ∈ {t..0} ∪ {0..t} ∪ cball t dt⟧ ⟹ norm (Dflow x ?s - Dflow ?y3 ?s) < e›*)) (*goals: 1. ‹⟦dist x y < d'; y ∈ cball x dx; s ∈ {t..0} ∪ {0..t} ∪ cball t dt; dist (Dflow x s) (Dflow x t) < e⟧ ⟹ dist x y < d'› 2. ‹⟦dist x y < d'; y ∈ cball x dx; s ∈ {t..0} ∪ {0..t} ∪ cball t dt; dist (Dflow x s) (Dflow x t) < e⟧ ⟹ y ∈ cball x dx› 3. ‹⟦dist x y < d'; y ∈ cball x dx; s ∈ {t..0} ∪ {0..t} ∪ cball t dt; dist (Dflow x s) (Dflow x t) < e⟧ ⟹ s ∈ {t..0} ∪ {0..t} ∪ cball t dt› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*) also (*calculation: ‹⟦⋀xa ya. xa < ya ⟹ dist (Dflow y s) (Dflow x s) + xa < dist (Dflow y s) (Dflow x s) + ya; ⋀x y. x < y ⟹ x + e < y + e⟧ ⟹ dist (Dflow y s) (Dflow x t) < e + e›*) have "e + e ≤ e'" by (simp add: e_def (*‹e ≡ min e' (dx / 2) / 2›*)) finally (*calculation: ‹⟦⋀xa ya. xa < ya ⟹ dist (Dflow y s) (Dflow x s) + xa < dist (Dflow y s) (Dflow x s) + ya; ⋀x y. x < y ⟹ x + e < y + e⟧ ⟹ dist (Dflow y s) (Dflow x t) < e'›*) show "dist (Dflow y s) (Dflow x t) < e'" by arith qed then show "∀⇩F ys in at (x, t) within ?S. dist (Dflow (fst ys) (snd ys)) (Dflow (fst (x, t)) (snd (x, t))) < e'" by (simp add: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) qed lemma W_continuous_on_comp[continuous_intros]: assumes h: "continuous_on S h" and g: "continuous_on S g" shows "(⋀s. s ∈ S ⟹ h s ∈ X) ⟹ (⋀s. s ∈ S ⟹ g s ∈ existence_ivl0 (h s)) ⟹ continuous_on S (λs. Dflow (h s) (g s))" using continuous_on_compose[OF continuous_on_Pair [ OF h g ] continuous_on_subset [ OF W_continuous_on ]] (*‹(λx. (h x, g x)) ` S ⊆ Sigma X existence_ivl0 ⟹ continuous_on S ((λ(x, y). Dflow x y) ∘ (λx. (h x, g x)))›*) by auto lemma f_flow_continuous_on: "continuous_on (Sigma X existence_ivl0) (λ(x0, t). f (flow0 x0 t))" using flow_continuous_on_state_space (*‹continuous_on (Sigma (X::'a set) existence_ivl0) (λ(x::'a, y::real). flow0 x y)›*) by (auto intro!: continuous_on_f (*‹⟦continuous_on ?S ?g; continuous_on ?S ?h; ?g ` ?S ⊆ UNIV; ?h ` ?S ⊆ X⟧ ⟹ continuous_on ?S (λx. f (?h x))›*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) simp: split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*)) lemma flow_has_space_derivative: assumes "t ∈ existence_ivl0 x0" shows "((λx0. flow0 x0 t) has_derivative Dflow x0 t) (at x0)" apply (rule flow_dx_derivative_blinfun[THEN has_derivative_eq_rhs] (*‹⟦?t1 ∈ existence_ivl0 ?x0.1; blinfun_apply (Blinfun (λz. vector_Dflow ?x0.1 z ?t1)) = ?g'⟧ ⟹ ((λx. flow0 x ?t1) has_derivative ?g') (at ?x0.1)›*)) (*goals: 1. ‹t ∈ existence_ivl0 x0› 2. ‹blinfun_apply (Blinfun (λz. vector_Dflow x0 z t)) = blinfun_apply (Dflow x0 t)› discuss goal 1*) apply (simp add: var_eq_mvar (*‹⟦?t0.0 ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 ?x0.0⟧ ⟹ var.flow ?x0.0 ?t0.0 ?i ?t = blinfun_apply (mvar.flow ?x0.0 ?t0.0 1⇩L ?t) ?i›*) assms (*‹t ∈ existence_ivl0 x0›*) blinfun.blinfun_apply_inverse (*‹Blinfun (blinfun_apply ?x) = ?x›*) Dflow_def (*‹Dflow ?x0.0 = mvar.flow ?x0.0 0 1⇩L›*) vector_Dflow_def (*‹vector_Dflow ?x0.0 ?u0.0 ?t ≡ var.flow ?x0.0 0 ?u0.0 ?t›*) mem_existence_ivl_iv_defined[OF assms] (*‹0 ∈ UNIV› ‹x0 ∈ X›*)) (*discuss goal 2*) apply (simp add: var_eq_mvar (*‹⟦?t0.0 ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 ?x0.0⟧ ⟹ var.flow ?x0.0 ?t0.0 ?i ?t = blinfun_apply (mvar.flow ?x0.0 ?t0.0 1⇩L ?t) ?i›*) assms (*‹t ∈ existence_ivl0 x0›*) blinfun.blinfun_apply_inverse (*‹Blinfun (blinfun_apply ?x) = ?x›*) Dflow_def (*‹Dflow ?x0.0 = mvar.flow ?x0.0 0 1⇩L›*) vector_Dflow_def (*‹vector_Dflow ?x0.0 ?u0.0 ?t ≡ var.flow ?x0.0 0 ?u0.0 ?t›*) mem_existence_ivl_iv_defined[OF assms] (*‹0 ∈ UNIV› ‹x0 ∈ X›*)) (*proven 2 subgoals*) . lemma flow_has_flowderiv: assumes "t ∈ existence_ivl0 x0" shows "((λ(x0, t). flow0 x0 t) has_derivative flowderiv x0 t) (at (x0, t) within S)" proof (-) (*goal: ‹((λ(x::'a, y::real). flow0 x y) has_derivative blinfun_apply (flowderiv (x0::'a) (t::real))) (at (x0, t) within (S::('a × real) set))›*) have Sigma: "(x0, t) ∈ Sigma X existence_ivl0" using assms (*‹t ∈ existence_ivl0 x0›*) by auto from open_state_space (*‹open (Sigma X existence_ivl0)›*) assms (*‹t ∈ existence_ivl0 x0›*) obtain e' where e': "e' > 0" "ball (x0, t) e' ⊆ Sigma X existence_ivl0" (*goal: ‹(⋀e'. ⟦0 < e'; ball (x0, t) e' ⊆ Sigma X existence_ivl0⟧ ⟹ thesis) ⟹ thesis›*) by (force simp: open_contains_ball (*‹open ?S = (∀x∈?S. ∃e>0. ball x e ⊆ ?S)›*)) define e where "e = e' / sqrt 2" have "0 < e" using e' (*‹0 < e'› ‹ball (x0, t) e' ⊆ Sigma X existence_ivl0›*) by (auto simp: e_def (*‹e = e' / sqrt 2›*)) have "ball x0 e × ball t e ⊆ ball (x0, t) e'" by (auto simp: dist_prod_def (*‹dist ?x ?y = sqrt ((dist (fst ?x) (fst ?y))² + (dist (snd ?x) (snd ?y))²)›*) real_sqrt_sum_squares_less (*‹⟦¦?x¦ < ?u / sqrt 2; ¦?y¦ < ?u / sqrt 2⟧ ⟹ sqrt (?x² + ?y²) < ?u›*) e_def (*‹e = e' / sqrt 2›*)) also (*calculation: ‹ball x0 e × ball t e ⊆ ball (x0, t) e'›*) note e'(2) (*‹ball (x0, t) e' ⊆ Sigma X existence_ivl0›*) finally (*calculation: ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0›*) have subs: "ball x0 e × ball t e ⊆ Sigma X existence_ivl0" . have d1: "((λx0. flow0 x0 s) has_derivative blinfun_apply (Dflow y s)) (at y within ball x0 e)" if "y ∈ ball x0 e" "s ∈ ball t e" for y and s using subs (*‹ball (x0::'a) (e::real) × ball (t::real) e ⊆ Sigma (X::'a set) existence_ivl0›*) that (*‹(y::'a::euclidean_space) ∈ ball (x0::'a::euclidean_space) (e::real)› ‹(s::real) ∈ ball (t::real) (e::real)›*) apply (subst at_within_open (*‹⟦(?a::?'a) ∈ (?S::?'a set); open ?S⟧ ⟹ at ?a within ?S = at ?a›*)) (*goals: 1. ‹⟦ball x0 e × ball t e ⊆ Sigma X existence_ivl0; y ∈ ball x0 e; s ∈ ball t e⟧ ⟹ y ∈ ball x0 e› 2. ‹⟦ball x0 e × ball t e ⊆ Sigma X existence_ivl0; y ∈ ball x0 e; s ∈ ball t e⟧ ⟹ open (ball x0 e)› 3. ‹⟦ball x0 e × ball t e ⊆ Sigma X existence_ivl0; y ∈ ball x0 e; s ∈ ball t e⟧ ⟹ ((λx0. flow0 x0 s) has_derivative blinfun_apply (Dflow y s)) (at y)› discuss goal 1*) apply (force intro!: flow_has_space_derivative (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ ((λx0::'a. flow0 x0 ?t) has_derivative blinfun_apply (Dflow ?x0.0 ?t)) (at ?x0.0)›*)) (*discuss goal 2*) apply (force intro!: flow_has_space_derivative (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ ((λx0. flow0 x0 ?t) has_derivative blinfun_apply (Dflow ?x0.0 ?t)) (at ?x0.0)›*)) (*discuss goal 3*) apply (force intro!: flow_has_space_derivative (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ ((λx0. flow0 x0 ?t) has_derivative blinfun_apply (Dflow ?x0.0 ?t)) (at ?x0.0)›*)) (*proven 3 subgoals*) . have d2: "(flow0 y has_derivative blinfun_apply (blinfun_scaleR_left (f (flow0 y s)))) (at s within ball t e)" if "y ∈ ball x0 e" "s ∈ ball t e" for y and s using subs (*‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0›*) that (*‹y ∈ ball x0 e› ‹s ∈ ball t e›*) unfolding has_vector_derivative_eq_has_derivative_blinfun[symmetric] (*goal: ‹(flow0 y has_vector_derivative f (flow0 y s)) (at s within ball t e)›*) apply (subst at_within_open (*‹⟦(?a::?'a) ∈ (?S::?'a set); open ?S⟧ ⟹ at ?a within ?S = at ?a›*)) (*goals: 1. ‹⟦ball (x0::'a::euclidean_space) (e::real) × ball (t::real) e ⊆ Sigma (X::'a::euclidean_space set) existence_ivl0; (y::'a::euclidean_space) ∈ ball x0 e; (s::real) ∈ ball t e⟧ ⟹ s ∈ ball t e› 2. ‹⟦ball (x0::'a::euclidean_space) (e::real) × ball (t::real) e ⊆ Sigma (X::'a::euclidean_space set) existence_ivl0; (y::'a::euclidean_space) ∈ ball x0 e; (s::real) ∈ ball t e⟧ ⟹ open (ball t e)› 3. ‹⟦ball (x0::'a::euclidean_space) (e::real) × ball (t::real) e ⊆ Sigma (X::'a::euclidean_space set) existence_ivl0; (y::'a::euclidean_space) ∈ ball x0 e; (s::real) ∈ ball t e⟧ ⟹ (flow0 y has_vector_derivative (f::'a::euclidean_space ⇒ 'a::euclidean_space) (flow0 y s)) (at s)› discuss goal 1*) apply (force intro!: flow_has_vector_derivative (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ (flow0 ?x0.0 has_vector_derivative f (flow0 ?x0.0 ?t)) (at ?t)›*)) (*discuss goal 2*) apply (force intro!: flow_has_vector_derivative (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ (flow0 ?x0.0 has_vector_derivative f (flow0 ?x0.0 ?t)) (at ?t)›*)) (*discuss goal 3*) apply (force intro!: flow_has_vector_derivative (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ (flow0 ?x0.0 has_vector_derivative f (flow0 ?x0.0 ?t)) (at ?t)›*)) (*proven 3 subgoals*) . have "((λ(x0, t). flow0 x0 t) has_derivative flowderiv x0 t) (at (x0, t) within ball x0 e × ball t e)" using subs (*‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0›*) unfolding UNIV_Times_UNIV[symmetric] (*goal: ‹((λ(x, y). flow0 x y) has_derivative blinfun_apply (flowderiv x0 t)) (at (x0, t) within ball x0 e × ball t e)›*) apply (intro has_derivative_partialsI[OF d1 d2, THEN has_derivative_eq_rhs] (*‹⟦(?x1::'a) ∈ ball (x0::'a) (e::real); (?y1::real) ∈ ball (t::real) e; ⋀(x::'a) y::real. ⟦x ∈ ball x0 e; y ∈ ball t e⟧ ⟹ x ∈ ball x0 e; ⋀(x::'a) y::real. ⟦x ∈ ball x0 e; y ∈ ball t e⟧ ⟹ y ∈ ball t e; continuous (at (?x1, ?y1) within ball x0 e × ball t e) (λ(x::'a, y::real). blinfun_scaleR_left ((f::'a ⇒ 'a) (flow0 x y))); ?y1 ∈ ball t e; convex (ball t e); (λ(tx::'a, ty::real). blinfun_apply (Dflow ?x1 ?y1) tx + blinfun_apply (blinfun_scaleR_left (f (flow0 ?x1 ?y1))) ty) = (?g'::'a × real ⇒ 'a)⟧ ⟹ ((λ(x::'a, y::real). flow0 x y) has_derivative ?g') (at (?x1, ?y1) within ball x0 e × ball t e)›*)) (*goals: 1. ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0 ⟹ x0 ∈ ball x0 e› 2. ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0 ⟹ t ∈ ball t e› 3. ‹⋀x0a ta. ⟦ball x0 e × ball t e ⊆ Sigma X existence_ivl0; x0a ∈ ball x0 e; ta ∈ ball t e⟧ ⟹ x0a ∈ ball x0 e› 4. ‹⋀x0a ta. ⟦ball x0 e × ball t e ⊆ Sigma X existence_ivl0; x0a ∈ ball x0 e; ta ∈ ball t e⟧ ⟹ ta ∈ ball t e› 5. ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0 ⟹ continuous (at (x0, t) within ball x0 e × ball t e) (λ(x0, t). blinfun_scaleR_left (f (flow0 x0 t)))› 6. ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0 ⟹ t ∈ ball t e› 7. ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0 ⟹ convex (ball t e)› 8. ‹ball x0 e × ball t e ⊆ Sigma X existence_ivl0 ⟹ (λ(tx, ty). blinfun_apply (Dflow x0 t) tx + blinfun_apply (blinfun_scaleR_left (f (flow0 x0 t))) ty) = blinfun_apply (flowderiv x0 t)› discuss goal 1*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 ?x0.0 ?t ∈ (X::'a set)›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma (X::'a set) existence_ivl0) (?f::'a × real ⇒ ?'b); (?t::('a × real) set) ⊆ Sigma X existence_ivl0; (?x::'a × real) ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹(t::real) ∈ existence_ivl0 (x0::'a)›*) simp: flowderiv_def (*‹flowderiv (?x0.0::'a) (?t::real) = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left ((f::'a ⇒ 'a) (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) flow0_defined (*‹(?xa::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 ?x0.0 ?xa ∈ (X::'a set)›*) assms (*‹(t::real) ∈ existence_ivl0 (x0::'a)›*) mem_ball (*‹((?y::?'a) ∈ ball (?x::?'a) (?e::real)) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 2*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma X existence_ivl0) ?f; ?t ⊆ Sigma X existence_ivl0; ?x ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹t ∈ existence_ivl0 x0›*) simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) flow0_defined (*‹?xa ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?xa ∈ X›*) assms (*‹t ∈ existence_ivl0 x0›*) mem_ball (*‹(?y ∈ ball ?x ?e) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 3*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma X existence_ivl0) ?f; ?t ⊆ Sigma X existence_ivl0; ?x ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹t ∈ existence_ivl0 x0›*) simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) flow0_defined (*‹?xa ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?xa ∈ X›*) assms (*‹t ∈ existence_ivl0 x0›*) mem_ball (*‹(?y ∈ ball ?x ?e) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 4*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma X existence_ivl0) ?f; ?t ⊆ Sigma X existence_ivl0; ?x ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹t ∈ existence_ivl0 x0›*) simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) flow0_defined (*‹?xa ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?xa ∈ X›*) assms (*‹t ∈ existence_ivl0 x0›*) mem_ball (*‹(?y ∈ ball ?x ?e) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 5*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma X existence_ivl0) ?f; ?t ⊆ Sigma X existence_ivl0; ?x ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹t ∈ existence_ivl0 x0›*) simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) flow0_defined (*‹?xa ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?xa ∈ X›*) assms (*‹t ∈ existence_ivl0 x0›*) mem_ball (*‹(?y ∈ ball ?x ?e) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 6*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 ?x0.0 ?t ∈ (X::'a set)›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma (X::'a set) existence_ivl0) (?f::'a × real ⇒ ?'b); (?t::('a × real) set) ⊆ Sigma X existence_ivl0; (?x::'a × real) ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹(t::real) ∈ existence_ivl0 (x0::'a)›*) simp: flowderiv_def (*‹flowderiv (?x0.0::'a) (?t::real) = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left ((f::'a ⇒ 'a) (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x::?'a, y::?'b). (?f::?'a ⇒ ?'b ⇒ ?'c) x y) = (λx::?'a × ?'b. ?f (fst x) (snd x))›*) flow0_defined (*‹(?xa::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 ?x0.0 ?xa ∈ (X::'a set)›*) assms (*‹(t::real) ∈ existence_ivl0 (x0::'a)›*) mem_ball (*‹((?y::?'a) ∈ ball (?x::?'a) (?e::real)) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 7*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma X existence_ivl0) ?f; ?t ⊆ Sigma X existence_ivl0; ?x ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹t ∈ existence_ivl0 x0›*) simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) flow0_defined (*‹?xa ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?xa ∈ X›*) assms (*‹t ∈ existence_ivl0 x0›*) mem_ball (*‹(?y ∈ ball ?x ?e) = (dist ?x ?y < ?e)›*))[1]) (*discuss goal 8*) apply ((auto intro!: ‹0 < e› continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*) continuous_on_imp_continuous_within[where s="Sigma X existence_ivl0"] (*‹⟦continuous_on (Sigma X existence_ivl0) ?f; ?t ⊆ Sigma X existence_ivl0; ?x ∈ Sigma X existence_ivl0⟧ ⟹ continuous (at ?x within ?t) ?f›*) assms (*‹t ∈ existence_ivl0 x0›*) simp: flowderiv_def (*‹flowderiv ?x0.0 ?t = comp12 (Dflow ?x0.0 ?t) (blinfun_scaleR_left (f (flow0 ?x0.0 ?t)))›*) split_beta' (*‹(λ(x, y). ?f x y) = (λx. ?f (fst x) (snd x))›*) flow0_defined (*‹?xa ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?xa ∈ X›*) assms (*‹t ∈ existence_ivl0 x0›*) mem_ball (*‹(?y ∈ ball ?x ?e) = (dist ?x ?y < ?e)›*))[1]) (*proven 8 subgoals*) . then have "((λ(x0, t). flow0 x0 t) has_derivative flowderiv x0 t) (at (x0, t) within Sigma X existence_ivl0)" by (auto simp: at_within_open[OF _ open_state_space] (*‹?a ∈ Sigma X existence_ivl0 ⟹ at ?a within Sigma X existence_ivl0 = at ?a›*) at_within_open[OF _ open_Times] (*‹⟦?a ∈ ?S1 × ?T1; open ?S1; open ?T1⟧ ⟹ at ?a within ?S1 × ?T1 = at ?a›*) assms (*‹t ∈ existence_ivl0 x0›*) ‹0 < e› mem_existence_ivl_iv_defined[OF assms] (*‹0 ∈ UNIV› ‹x0 ∈ X›*)) then show "?thesis" (*goal: ‹((λ(x::'a::euclidean_space, y::real). flow0 x y) has_derivative blinfun_apply (flowderiv (x0::'a::euclidean_space) (t::real))) (at (x0, t) within (S::('a::euclidean_space × real) set))›*) unfolding at_within_open[OF Sigma open_state_space] (*goal: ‹((λ(x, y). flow0 x y) has_derivative blinfun_apply (flowderiv x0 t)) (at (x0, t) within S)›*) by (rule has_derivative_at_withinI (*‹(?f has_derivative ?f') (at ?x) ⟹ (?f has_derivative ?f') (at ?x within ?s)›*)) qed lemma flow0_comp_has_derivative: assumes h: "h s ∈ existence_ivl0 (g s)" assumes [derivative_intros]: "(g has_derivative g') (at s within S)" assumes [derivative_intros]: "(h has_derivative h') (at s within S)" shows "((λx. flow0 (g x) (h x)) has_derivative (λx. blinfun_apply (flowderiv (g s) (h s)) (g' x, h' x))) (at s within S)" apply (rule has_derivative_compose[where f="λx. (g x, h x)" and s=S, OF _ flow_has_flowderiv[OF h], simplified] (*‹((λx. (g x, h x)) has_derivative ?f') (at s within S) ⟹ ((λx. flow0 (g x) (h x)) has_derivative (λx. blinfun_apply (flowderiv (g s) (h s)) (?f' x))) (at s within S)›*)) (*goal: ‹((λx. flow0 (g x) (h x)) has_derivative (λx. blinfun_apply (flowderiv (g s) (h s)) (g' x, h' x))) (at s within S)›*) by (auto intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 138 facts*)) lemma flowderiv_continuous_on: "continuous_on (Sigma X existence_ivl0) (λ(x0, t). flowderiv x0 t)" unfolding flowderiv_def split_beta' (*goal: ‹continuous_on (Sigma X existence_ivl0) (λx. comp12 (Dflow (fst x) (snd x)) (blinfun_scaleR_left (f (flow0 (fst x) (snd x)))))›*) apply (subst blinfun_of_matrix_works[where f="comp12 (Dflow (fst x) (snd x)) (blinfun_scaleR_left (f (flow0 (fst x) (snd x))))" for x, symmetric] (*‹comp12 (Dflow (fst ?x) (snd ?x)) (blinfun_scaleR_left (f (flow0 (fst ?x) (snd ?x)))) = blinfun_of_matrix (λi j. blinfun_apply (comp12 (Dflow (fst ?x) (snd ?x)) (blinfun_scaleR_left (f (flow0 (fst ?x) (snd ?x))))) j ∙ i)›*)) (*goal: ‹continuous_on (Sigma X existence_ivl0) (λx. comp12 (Dflow (fst x) (snd x)) (blinfun_scaleR_left (f (flow0 (fst x) (snd x)))))›*) by (auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) flow_in_domain (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ flow0 ?x0.0 ?t ∈ X›*)) lemma flowderiv_continuous_on_comp[continuous_intros]: assumes "continuous_on S x" assumes "continuous_on S t" assumes "⋀s. s ∈ S ⟹ x s ∈ X" "⋀s. s ∈ S ⟹ t s ∈ existence_ivl0 (x s)" shows "continuous_on S (λxa. flowderiv (x xa) (t xa))" apply (rule continuous_on_compose2[OF flowderiv_continuous_on, where f="λs. (x s, t s)", unfolded split_beta' fst_conv snd_conv] (*‹⟦continuous_on (?s::'b set) (λs::'b. ((x::'b ⇒ 'a) s, (t::'b ⇒ real) s)); (λs::'b. (x s, t s)) ` ?s ⊆ Sigma (X::'a set) existence_ivl0⟧ ⟹ continuous_on ?s (λxa::'b. flowderiv (x xa) (t xa))›*)) (*goals: 1. ‹continuous_on S (λs. (x s, t s))› 2. ‹(λs. (x s, t s)) ` S ⊆ Sigma X existence_ivl0› discuss goal 1*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open ?S; open ?T⟧ ⟹ open (?S ∪ ?T)› ‹∀x∈?A. open (?B x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite ?S; ∀T∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite ?A; ∀x∈?A. open (?B x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed ?S; closed ?T⟧ ⟹ closed (?S ∩ ?T)› ‹∀x∈?A. closed (?B x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S∈?K. closed S ⟹ closed (⋂ ?K)› ‹⟦finite ?S; ∀T∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) assms (*‹continuous_on S x› ‹continuous_on S t› ‹?s ∈ S ⟹ x ?s ∈ X› ‹?s ∈ S ⟹ t ?s ∈ existence_ivl0 (x ?s)›*))[1]) (*discuss goal 2*) apply ((auto intro!: continuous_intros (*‹open {}› ‹⟦open (?S::?'a set); open (?T::?'a set)⟧ ⟹ open (?S ∪ ?T)› ‹∀x::?'b∈?A::?'b set. open ((?B::?'b ⇒ ?'a set) x) ⟹ open (⋃ (?B ` ?A))› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. open T⟧ ⟹ open (⋂ ?S)› ‹⟦finite (?A::?'b set); ∀x::?'b∈?A. open ((?B::?'b ⇒ ?'a set) x)⟧ ⟹ open (⋂ (?B ` ?A))› ‹closed {}› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∪ ?T)› ‹closed UNIV› ‹⟦closed (?S::?'a set); closed (?T::?'a set)⟧ ⟹ closed (?S ∩ ?T)› ‹∀x::?'b∈?A::?'b set. closed ((?B::?'b ⇒ ?'a set) x) ⟹ closed (⋂ (?B ` ?A))› ‹∀S::?'a set∈?K::?'a set set. closed S ⟹ closed (⋂ ?K)› ‹⟦finite (?S::?'a set set); ∀T::?'a set∈?S. closed T⟧ ⟹ closed (⋃ ?S)› and more 285 facts*) assms (*‹continuous_on (S::'b set) (x::'b ⇒ 'a)› ‹continuous_on (S::'b set) (t::'b ⇒ real)› ‹(?s::'b) ∈ (S::'b set) ⟹ (x::'b ⇒ 'a) ?s ∈ (X::'a set)› ‹(?s::'b) ∈ (S::'b set) ⟹ (t::'b ⇒ real) ?s ∈ existence_ivl0 ((x::'b ⇒ 'a) ?s)›*))[1]) (*proven 2 subgoals*) . lemmas [intro] = flow_in_domain lemma vareq_trans: "t0 ∈ existence_ivl0 x0 ⟹ t ∈ existence_ivl0 (flow0 x0 t0) ⟹ vareq (flow0 x0 t0) t = vareq x0 (t0 + t)" by (auto simp: vareq_def (*‹vareq ?x0.0 ?t = f' (flow0 ?x0.0 ?t)›*) flow_trans (*‹⟦?s ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ flow0 ?x0.0 (?s + ?t) = flow0 (flow0 ?x0.0 ?s) ?t›*)) lemma diff_existence_ivl_trans: "t0 ∈ existence_ivl0 x0 ⟹ t ∈ existence_ivl0 x0 ⟹ t - t0 ∈ existence_ivl0 (flow0 x0 t0)" for t by (metis (no_types, opaque_lifting) add.left_neutral (*‹(0::?'a) + (?a::?'a) = ?a›*) diff_add_eq (*‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b›*) local.existence_ivl_reverse (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ (0::real) - ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t)›*) local.existence_ivl_trans (*‹⟦(?s::real) ∈ existence_ivl0 (?x0.0::'a); (?t::real) ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*) local.flows_reverse (*‹(?t::real) ∈ existence_ivl0 (?x0.0::'a) ⟹ flow0 (flow0 ?x0.0 ?t) ((0::real) - ?t) = ?x0.0›*)) lemma has_vderiv_on_blinfun_compose_right[derivative_intros]: assumes "(g has_vderiv_on g') T" assumes "⋀x. x ∈ T ⟹ gd' x = g' x o⇩L d" shows "((λx. g x o⇩L d) has_vderiv_on gd') T" using assms (*‹((g::real ⇒ 'b ⇒⇩L 'c) has_vderiv_on (g'::real ⇒ 'b ⇒⇩L 'c)) (T::real set)› ‹(?x::real) ∈ (T::real set) ⟹ (gd'::real ⇒ 'd ⇒⇩L 'c) ?x = (g'::real ⇒ 'b ⇒⇩L 'c) ?x o⇩L (d::'d ⇒⇩L 'b)›*) by (auto simp: has_vderiv_on_def (*‹(?f has_vderiv_on ?f') ?S = (∀x∈?S. (?f has_vector_derivative ?f' x) (at x within ?S))›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) blinfun_ext (*‹(?x = ?y) = (∀i. blinfun_apply ?x i = blinfun_apply ?y i)›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*) intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) lemma has_vderiv_on_blinfun_compose_left[derivative_intros]: assumes "(g has_vderiv_on g') T" assumes "⋀x. x ∈ T ⟹ gd' x = d o⇩L g' x" shows "((λx. d o⇩L g x) has_vderiv_on gd') T" using assms (*‹(g has_vderiv_on g') T› ‹?x ∈ T ⟹ gd' ?x = d o⇩L g' ?x›*) by (auto simp: has_vderiv_on_def (*‹(?f has_vderiv_on ?f') ?S = (∀x∈?S. (?f has_vector_derivative ?f' x) (at x within ?S))›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) blinfun_ext (*‹(?x = ?y) = (∀i. blinfun_apply ?x i = blinfun_apply ?y i)›*) blinfun.bilinear_simps (*‹blinfun_apply (?a + ?a') ?b = blinfun_apply ?a ?b + blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b + ?b') = blinfun_apply ?a ?b + blinfun_apply ?a ?b'› ‹blinfun_apply (?a - ?a') ?b = blinfun_apply ?a ?b - blinfun_apply ?a' ?b› ‹blinfun_apply ?a (?b - ?b') = blinfun_apply ?a ?b - blinfun_apply ?a ?b'› ‹blinfun_apply (- ?a) ?b = - blinfun_apply ?a ?b› ‹blinfun_apply ?a (- ?b) = - blinfun_apply ?a ?b› ‹blinfun_apply (?r *⇩R ?a) ?b = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply ?a (?r *⇩R ?b) = ?r *⇩R blinfun_apply ?a ?b› ‹blinfun_apply 0 ?b = 0› ‹blinfun_apply ?a 0 = 0› ‹blinfun_apply (sum ?g ?S) ?x = (∑i∈?S. blinfun_apply (?g i) ?x)› ‹blinfun_apply ?x (sum ?g ?S) = (∑i∈?S. blinfun_apply ?x (?g i))› and more 12 facts*) intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) lemma mvar_flow_shift: assumes "t0 ∈ existence_ivl0 x0" "t1 ∈ existence_ivl0 x0" shows "mvar.flow x0 t0 d t1 = Dflow (flow0 x0 t0) (t1 - t0) o⇩L d" proof (-) (*goal: ‹mvar.flow (x0::'a::euclidean_space) (t0::real) (d::'a::euclidean_space ⇒⇩L 'a::euclidean_space) (t1::real) = Dflow (flow0 x0 t0) (t1 - t0) o⇩L d›*) have "mvar.flow x0 t0 d t1 = mvar.flow x0 t0 d (t0 + (t1 - t0))" by simp also (*calculation: ‹mvar.flow x0 t0 d t1 = mvar.flow x0 t0 d (t0 + (t1 - t0))›*) have "… = mvar.flow x0 t0 (mvar.flow x0 t0 d t0) t1" apply (subst mvar.flow_trans (*‹⟦?s ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0; ?t + ?s ∈ mvar.existence_ivl ?x0a ?s (mvar.flow ?x0a ?t0.0 ?x0.0 ?s)⟧ ⟹ mvar.flow ?x0a ?t0.0 ?x0.0 (?s + ?t) = mvar.flow ?x0a ?s (mvar.flow ?x0a ?t0.0 ?x0.0 ?s) (?s + ?t)›*)) (*goals: 1. ‹t0 ∈ mvar.existence_ivl x0 t0 d› 2. ‹t1 - t0 + t0 ∈ mvar.existence_ivl x0 t0 (mvar.flow x0 t0 d t0)› 3. ‹mvar.flow x0 t0 (mvar.flow x0 t0 d t0) (t0 + (t1 - t0)) = mvar.flow x0 t0 (mvar.flow x0 t0 d t0) t1› discuss goal 1*) apply ((auto simp add: assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*))[1]) (*discuss goal 2*) apply ((auto simp add: assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*))[1]) (*discuss goal 3*) apply ((auto simp add: assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*))[1]) (*proven 3 subgoals*) . also (*calculation: ‹mvar.flow x0 t0 d t1 = mvar.flow x0 t0 (mvar.flow x0 t0 d t0) t1›*) have "… = Dflow (flow0 x0 t0) (t1 - t0) o⇩L d" apply (rule mvar.flow_unique_on (*‹⟦?t ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0; ?phi ?t0.0 = ?x0.0; (?phi has_vderiv_on (λt. vareq ?x0a t o⇩L ?phi t)) (mvar.existence_ivl ?x0a ?t0.0 ?x0.0); ⋀t. t ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0 ⟹ ?phi t ∈ UNIV⟧ ⟹ mvar.flow ?x0a ?t0.0 ?x0.0 ?t = ?phi ?t›*)) (*goals: 1. ‹t1 ∈ mvar.existence_ivl x0 t0 (mvar.flow x0 t0 d t0)› 2. ‹Dflow (flow0 x0 t0) (t0 - t0) o⇩L d = mvar.flow x0 t0 d t0› 3. ‹((λa. Dflow (flow0 x0 t0) (a - t0) o⇩L d) has_vderiv_on (λt. vareq x0 t o⇩L (Dflow (flow0 x0 t0) (t - t0) o⇩L d))) (mvar.existence_ivl x0 t0 (mvar.flow x0 t0 d t0))› 4. ‹⋀t. t ∈ mvar.existence_ivl x0 t0 (mvar.flow x0 t0 d t0) ⟹ Dflow (flow0 x0 t0) (t - t0) o⇩L d ∈ UNIV› discuss goal 1*) apply ((auto simp add: assms (*‹(t0::real) ∈ existence_ivl0 (x0::'a)› ‹(t1::real) ∈ existence_ivl0 (x0::'a)›*) mvar.flow_initial_time_if (*‹mvar.flow (?x0a::'a) (?t0.0::real) (?x0.0::'a ⇒⇩L 'a) ?t0.0 = (if ?t0.0 ∈ existence_ivl0 ?x0a ∧ ?x0.0 ∈ UNIV then ?x0.0 else (0::'a ⇒⇩L 'a))›*) blinfun_ext (*‹((?x::?'a ⇒⇩L ?'b) = (?y::?'a ⇒⇩L ?'b)) = (∀i::?'a. blinfun_apply ?x i = blinfun_apply ?y i)›*) Dflow_def (*‹Dflow (?x0.0::'a) = mvar.flow ?x0.0 (0::real) 1⇩L›*) intro!: derivative_intros (*‹((λx::?'a. x) has_derivative (λx::?'a. x)) (?F::?'a filter)› ‹(id has_derivative id) (?F::?'a filter)› ‹((λx::?'a. ?c::?'b) has_derivative (λx::?'a. 0::?'b)) (?F::?'a filter)› ‹((?g::?'c ⇒ ?'b) has_derivative (?g'::?'c ⇒ ?'b)) (?F::?'c filter) ⟹ ((λx::?'c. (?r::real) *⇩R ?g x) has_derivative (λx::?'c. ?r *⇩R ?g' x)) ?F› ‹((?g::?'c ⇒ real) has_derivative (?g'::?'c ⇒ real)) (?F::?'c filter) ⟹ ((λx::?'c. ?g x *⇩R (?x::?'b)) has_derivative (λx::?'c. ?g' x *⇩R ?x)) ?F› ‹((?g::?'c ⇒ ?'a) has_derivative (?g'::?'c ⇒ ?'a)) (?F::?'c filter) ⟹ ((λx::?'c. (?x::?'a) * ?g x) has_derivative (λx::?'c. ?x * ?g' x)) ?F› ‹((?g::?'c ⇒ ?'a) has_derivative (?g'::?'c ⇒ ?'a)) (?F::?'c filter) ⟹ ((λx::?'c. ?g x * (?y::?'a)) has_derivative (λx::?'c. ?g' x * ?y)) ?F› ‹((?g::?'c ⇒ real) has_derivative (?g'::?'c ⇒ real)) (?F::?'c filter) ⟹ ((λx::?'c. of_real (?g x)) has_derivative (λx::?'c. of_real (?g' x))) ?F› ‹⟦((?f::?'a ⇒ ?'b) has_derivative (?f'::?'a ⇒ ?'b)) (?F::?'a filter); ((?g::?'a ⇒ ?'b) has_derivative (?g'::?'a ⇒ ?'b)) ?F⟧ ⟹ ((λx::?'a. ?f x + ?g x) has_derivative (λx::?'a. ?f' x + ?g' x)) ?F› ‹(⋀i::?'a. i ∈ (?I::?'a set) ⟹ ((?f::?'a ⇒ ?'b ⇒ ?'c) i has_derivative (?f'::?'a ⇒ ?'b ⇒ ?'c) i) (?F::?'b filter)) ⟹ ((λx::?'b. ∑i::?'a∈?I. ?f i x) has_derivative (λx::?'b. ∑i::?'a∈?I. ?f' i x)) ?F› ‹((?f::?'a ⇒ ?'b) has_derivative (?f'::?'a ⇒ ?'b)) (?F::?'a filter) ⟹ ((λx::?'a. - ?f x) has_derivative (λx::?'a. - ?f' x)) ?F› ‹⟦((?f::?'a ⇒ ?'b) has_derivative (?f'::?'a ⇒ ?'b)) (?F::?'a filter); ((?g::?'a ⇒ ?'b) has_derivative (?g'::?'a ⇒ ?'b)) ?F⟧ ⟹ ((λx::?'a. ?f x - ?g x) has_derivative (λx::?'a. ?f' x - ?g' x)) ?F› and more 212 facts*) derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*))[1]) (*discuss goal 2*) apply ((auto simp add: assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*) mvar.flow_initial_time_if (*‹mvar.flow ?x0a ?t0.0 ?x0.0 ?t0.0 = (if ?t0.0 ∈ existence_ivl0 ?x0a ∧ ?x0.0 ∈ UNIV then ?x0.0 else 0)›*) blinfun_ext (*‹(?x = ?y) = (∀i. blinfun_apply ?x i = blinfun_apply ?y i)›*) Dflow_def (*‹Dflow ?x0.0 = mvar.flow ?x0.0 0 1⇩L›*) intro!: derivative_intros (*‹((λx. x) has_derivative (λx. x)) ?F› ‹(id has_derivative id) ?F› ‹((λx. ?c) has_derivative (λx. 0)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?r *⇩R ?g x) has_derivative (λx. ?r *⇩R ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x *⇩R ?x) has_derivative (λx. ?g' x *⇩R ?x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?x * ?g x) has_derivative (λx. ?x * ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x * ?y) has_derivative (λx. ?g' x * ?y)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. of_real (?g x)) has_derivative (λx. of_real (?g' x))) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x + ?g x) has_derivative (λx. ?f' x + ?g' x)) ?F› ‹(⋀i. i ∈ ?I ⟹ (?f i has_derivative ?f' i) ?F) ⟹ ((λx. ∑i∈?I. ?f i x) has_derivative (λx. ∑i∈?I. ?f' i x)) ?F› ‹(?f has_derivative ?f') ?F ⟹ ((λx. - ?f x) has_derivative (λx. - ?f' x)) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x - ?g x) has_derivative (λx. ?f' x - ?g' x)) ?F› and more 212 facts*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*))[1]) (*discuss goal 3*) apply ((auto simp add: assms (*‹(t0::real) ∈ existence_ivl0 (x0::'a)› ‹(t1::real) ∈ existence_ivl0 (x0::'a)›*) mvar.flow_initial_time_if (*‹mvar.flow (?x0a::'a) (?t0.0::real) (?x0.0::'a ⇒⇩L 'a) ?t0.0 = (if ?t0.0 ∈ existence_ivl0 ?x0a ∧ ?x0.0 ∈ UNIV then ?x0.0 else (0::'a ⇒⇩L 'a))›*) blinfun_ext (*‹((?x::?'a ⇒⇩L ?'b) = (?y::?'a ⇒⇩L ?'b)) = (∀i::?'a. blinfun_apply ?x i = blinfun_apply ?y i)›*) Dflow_def (*‹Dflow (?x0.0::'a) = mvar.flow ?x0.0 (0::real) 1⇩L›*) intro!: derivative_intros (*‹((λx::?'a. x) has_derivative (λx::?'a. x)) (?F::?'a filter)› ‹(id has_derivative id) (?F::?'a filter)› ‹((λx::?'a. ?c::?'b) has_derivative (λx::?'a. 0::?'b)) (?F::?'a filter)› ‹((?g::?'c ⇒ ?'b) has_derivative (?g'::?'c ⇒ ?'b)) (?F::?'c filter) ⟹ ((λx::?'c. (?r::real) *⇩R ?g x) has_derivative (λx::?'c. ?r *⇩R ?g' x)) ?F› ‹((?g::?'c ⇒ real) has_derivative (?g'::?'c ⇒ real)) (?F::?'c filter) ⟹ ((λx::?'c. ?g x *⇩R (?x::?'b)) has_derivative (λx::?'c. ?g' x *⇩R ?x)) ?F› ‹((?g::?'c ⇒ ?'a) has_derivative (?g'::?'c ⇒ ?'a)) (?F::?'c filter) ⟹ ((λx::?'c. (?x::?'a) * ?g x) has_derivative (λx::?'c. ?x * ?g' x)) ?F› ‹((?g::?'c ⇒ ?'a) has_derivative (?g'::?'c ⇒ ?'a)) (?F::?'c filter) ⟹ ((λx::?'c. ?g x * (?y::?'a)) has_derivative (λx::?'c. ?g' x * ?y)) ?F› ‹((?g::?'c ⇒ real) has_derivative (?g'::?'c ⇒ real)) (?F::?'c filter) ⟹ ((λx::?'c. of_real (?g x)) has_derivative (λx::?'c. of_real (?g' x))) ?F› ‹⟦((?f::?'a ⇒ ?'b) has_derivative (?f'::?'a ⇒ ?'b)) (?F::?'a filter); ((?g::?'a ⇒ ?'b) has_derivative (?g'::?'a ⇒ ?'b)) ?F⟧ ⟹ ((λx::?'a. ?f x + ?g x) has_derivative (λx::?'a. ?f' x + ?g' x)) ?F› ‹(⋀i::?'a. i ∈ (?I::?'a set) ⟹ ((?f::?'a ⇒ ?'b ⇒ ?'c) i has_derivative (?f'::?'a ⇒ ?'b ⇒ ?'c) i) (?F::?'b filter)) ⟹ ((λx::?'b. ∑i::?'a∈?I. ?f i x) has_derivative (λx::?'b. ∑i::?'a∈?I. ?f' i x)) ?F› ‹((?f::?'a ⇒ ?'b) has_derivative (?f'::?'a ⇒ ?'b)) (?F::?'a filter) ⟹ ((λx::?'a. - ?f x) has_derivative (λx::?'a. - ?f' x)) ?F› ‹⟦((?f::?'a ⇒ ?'b) has_derivative (?f'::?'a ⇒ ?'b)) (?F::?'a filter); ((?g::?'a ⇒ ?'b) has_derivative (?g'::?'a ⇒ ?'b)) ?F⟧ ⟹ ((λx::?'a. ?f x - ?g x) has_derivative (λx::?'a. ?f' x - ?g' x)) ?F› and more 212 facts*) derivative_eq_intros (*‹(λx::?'b. x) = (?g'::?'b ⇒ ?'b) ⟹ ((λx::?'b. x) has_derivative ?g') (?F::?'b filter)› ‹id = (?g'::?'b ⇒ ?'b) ⟹ (id has_derivative ?g') (?F::?'b filter)› ‹(λx::?'a. 0::?'b) = (?g'::?'a ⇒ ?'b) ⟹ ((λx::?'a. ?f2::?'b) has_derivative ?g') (?F::?'a filter)› ‹⟦((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. (?r1::real) *⇩R ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. ?g'1 x *⇩R (?x1::?'b)) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. (?x1::?'a1) * ?g'1 x) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ ?'a1) has_derivative (?g'1::?'a ⇒ ?'a1)) (?F::?'a filter); (λx::?'a. ?g'1 x * (?y1::?'a1)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦((?g1::?'a ⇒ real) has_derivative (?g'1::?'a ⇒ real)) (?F::?'a filter); (λx::?'a. of_real (?g'1 x)) = (?g'::?'a ⇒ ?'a1)⟧ ⟹ ((λx::?'a. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x + ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i::?'a1. i ∈ (?I1::?'a1 set) ⟹ ((?f1::?'a1 ⇒ ?'a ⇒ ?'b) i has_derivative (?f'1::?'a1 ⇒ ?'a ⇒ ?'b) i) (?F::?'a filter); (λx::?'a. ∑i::?'a1∈?I1. ?f'1 i x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ∑i::?'a1∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); (λx::?'a. - ?f'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. - ?f1 x) has_derivative ?g') ?F› ‹⟦((?f1::?'a ⇒ ?'b) has_derivative (?f'1::?'a ⇒ ?'b)) (?F::?'a filter); ((?g1::?'a ⇒ ?'b) has_derivative (?g'1::?'a ⇒ ?'b)) ?F; (λx::?'a. ?f'1 x - ?g'1 x) = (?g'::?'a ⇒ ?'b)⟧ ⟹ ((λx::?'a. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*))[1]) (*goals: 1. ‹flow0 x0 t0 ∈ X› 2. ‹⋀t. t ∈ existence_ivl0 x0 ⟹ t - t0 ∈ mvar.existence_ivl (flow0 x0 t0) 0 1⇩L› 3. ‹⋀x i. x ∈ existence_ivl0 x0 ⟹ blinfun_apply (vareq x0 x) (blinfun_apply (mvar.flow (flow0 x0 t0) 0 1⇩L (x - t0)) (blinfun_apply d i)) = blinfun_apply (vareq (flow0 x0 t0) (x - t0)) (blinfun_apply (mvar.flow (flow0 x0 t0) 0 1⇩L (x - t0)) (blinfun_apply d i))› discuss goal 1*) apply ((auto simp: assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*) has_vderiv_on_open (*‹open ?T ⟹ (?f has_vderiv_on ?f') ?T = (∀t∈?T. (?f has_vector_derivative ?f' t) (at t))›*) has_vector_derivative_def (*‹(?f has_vector_derivative ?f') ?net = (?f has_derivative (λx. x *⇩R ?f')) ?net›*) intro!: derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*) blinfun_eqI (*‹(⋀i. blinfun_apply ?x i = blinfun_apply ?y i) ⟹ ?x = ?y›*))[1]) (*discuss goal 2*) apply ((subst mvar_existence_ivl_eq_existence_ivl (*‹?t ∈ existence_ivl0 ?x0.0 ⟹ mvar.existence_ivl ?x0.0 ?t = (λ_. existence_ivl0 ?x0.0)›*))[1]) (*goals: 1. ‹⋀t. t ∈ existence_ivl0 x0 ⟹ 0 ∈ existence_ivl0 (flow0 x0 t0)› 2. ‹⋀t. t ∈ existence_ivl0 x0 ⟹ t - t0 ∈ existence_ivl0 (flow0 x0 t0)› discuss goal 1*) apply ((auto simp add: vareq_trans (*‹⟦?t0.0 ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 (flow0 ?x0.0 ?t0.0)⟧ ⟹ vareq (flow0 ?x0.0 ?t0.0) ?t = vareq ?x0.0 (?t0.0 + ?t)›*) assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*) diff_existence_ivl_trans (*‹⟦?t0.0 ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 ?x0.0⟧ ⟹ ?t - ?t0.0 ∈ existence_ivl0 (flow0 ?x0.0 ?t0.0)›*))[1]) (*discuss goal 2*) apply ((auto simp add: vareq_trans (*‹⟦(?t0.0::real) ∈ existence_ivl0 (?x0.0::'a); (?t::real) ∈ existence_ivl0 (flow0 ?x0.0 ?t0.0)⟧ ⟹ vareq (flow0 ?x0.0 ?t0.0) ?t = vareq ?x0.0 (?t0.0 + ?t)›*) assms (*‹(t0::real) ∈ existence_ivl0 (x0::'a)› ‹(t1::real) ∈ existence_ivl0 (x0::'a)›*) diff_existence_ivl_trans (*‹⟦(?t0.0::real) ∈ existence_ivl0 (?x0.0::'a); (?t::real) ∈ existence_ivl0 ?x0.0⟧ ⟹ ?t - ?t0.0 ∈ existence_ivl0 (flow0 ?x0.0 ?t0.0)›*))[1]) (*proven 2 subgoals*) (*discuss goal 3*) apply ((auto simp add: vareq_trans (*‹⟦(?t0.0::real) ∈ existence_ivl0 (?x0.0::'a::euclidean_space); (?t::real) ∈ existence_ivl0 (flow0 ?x0.0 ?t0.0)⟧ ⟹ vareq (flow0 ?x0.0 ?t0.0) ?t = vareq ?x0.0 (?t0.0 + ?t)›*) assms (*‹(t0::real) ∈ existence_ivl0 (x0::'a::euclidean_space)› ‹(t1::real) ∈ existence_ivl0 (x0::'a::euclidean_space)›*) diff_existence_ivl_trans (*‹⟦(?t0.0::real) ∈ existence_ivl0 (?x0.0::'a::euclidean_space); (?t::real) ∈ existence_ivl0 ?x0.0⟧ ⟹ ?t - ?t0.0 ∈ existence_ivl0 (flow0 ?x0.0 ?t0.0)›*))[1]) (*proven 3 subgoals*) (*discuss goal 4*) apply ((auto simp add: assms (*‹t0 ∈ existence_ivl0 x0› ‹t1 ∈ existence_ivl0 x0›*) mvar.flow_initial_time_if (*‹mvar.flow ?x0a ?t0.0 ?x0.0 ?t0.0 = (if ?t0.0 ∈ existence_ivl0 ?x0a ∧ ?x0.0 ∈ UNIV then ?x0.0 else 0)›*) blinfun_ext (*‹(?x = ?y) = (∀i. blinfun_apply ?x i = blinfun_apply ?y i)›*) Dflow_def (*‹Dflow ?x0.0 = mvar.flow ?x0.0 0 1⇩L›*) intro!: derivative_intros (*‹((λx. x) has_derivative (λx. x)) ?F› ‹(id has_derivative id) ?F› ‹((λx. ?c) has_derivative (λx. 0)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?r *⇩R ?g x) has_derivative (λx. ?r *⇩R ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x *⇩R ?x) has_derivative (λx. ?g' x *⇩R ?x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?x * ?g x) has_derivative (λx. ?x * ?g' x)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. ?g x * ?y) has_derivative (λx. ?g' x * ?y)) ?F› ‹(?g has_derivative ?g') ?F ⟹ ((λx. of_real (?g x)) has_derivative (λx. of_real (?g' x))) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x + ?g x) has_derivative (λx. ?f' x + ?g' x)) ?F› ‹(⋀i. i ∈ ?I ⟹ (?f i has_derivative ?f' i) ?F) ⟹ ((λx. ∑i∈?I. ?f i x) has_derivative (λx. ∑i∈?I. ?f' i x)) ?F› ‹(?f has_derivative ?f') ?F ⟹ ((λx. - ?f x) has_derivative (λx. - ?f' x)) ?F› ‹⟦(?f has_derivative ?f') ?F; (?g has_derivative ?g') ?F⟧ ⟹ ((λx. ?f x - ?g x) has_derivative (λx. ?f' x - ?g' x)) ?F› and more 212 facts*) derivative_eq_intros (*‹(λx. x) = ?g' ⟹ ((λx. x) has_derivative ?g') ?F› ‹id = ?g' ⟹ (id has_derivative ?g') ?F› ‹(λx. 0) = ?g' ⟹ ((λx. ?f2) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?r1 *⇩R ?g'1 x) = ?g'⟧ ⟹ ((λx. ?r1 *⇩R ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x *⇩R ?x1) = ?g'⟧ ⟹ ((λx. ?g1 x *⇩R ?x1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?x1 * ?g'1 x) = ?g'⟧ ⟹ ((λx. ?x1 * ?g1 x) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. ?g'1 x * ?y1) = ?g'⟧ ⟹ ((λx. ?g1 x * ?y1) has_derivative ?g') ?F› ‹⟦(?g1 has_derivative ?g'1) ?F; (λx. of_real (?g'1 x)) = ?g'⟧ ⟹ ((λx. of_real (?g1 x)) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x + ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x + ?g1 x) has_derivative ?g') ?F› ‹⟦⋀i. i ∈ ?I1 ⟹ (?f1 i has_derivative ?f'1 i) ?F; (λx. ∑i∈?I1. ?f'1 i x) = ?g'⟧ ⟹ ((λx. ∑i∈?I1. ?f1 i x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (λx. - ?f'1 x) = ?g'⟧ ⟹ ((λx. - ?f1 x) has_derivative ?g') ?F› ‹⟦(?f1 has_derivative ?f'1) ?F; (?g1 has_derivative ?g'1) ?F; (λx. ?f'1 x - ?g'1 x) = ?g'⟧ ⟹ ((λx. ?f1 x - ?g1 x) has_derivative ?g') ?F› and more 136 facts*))[1]) (*proven 4 subgoals*) . finally (*calculation: ‹mvar.flow x0 t0 d t1 = Dflow (flow0 x0 t0) (t1 - t0) o⇩L d›*) show "?thesis" (*goal: ‹mvar.flow (x0::'a::euclidean_space) (t0::real) (d::'a::euclidean_space ⇒⇩L 'a::euclidean_space) (t1::real) = Dflow (flow0 x0 t0) (t1 - t0) o⇩L d›*) . qed lemma Dflow_trans: assumes "h ∈ existence_ivl0 x0" assumes "i ∈ existence_ivl0 (flow0 x0 h)" shows "Dflow x0 (h + i) = Dflow (flow0 x0 h) i o⇩L (Dflow x0 h)" proof (-) (*goal: ‹Dflow x0 (h + i) = Dflow (flow0 x0 h) i o⇩L Dflow x0 h›*) have [intro, simp]: "h + i ∈ existence_ivl0 x0" "i + h ∈ existence_ivl0 x0" "x0 ∈ X" using assms (*‹h ∈ existence_ivl0 x0› ‹i ∈ existence_ivl0 (flow0 x0 h)›*) apply - (*goals: 1. ‹⟦h ∈ existence_ivl0 x0; i ∈ existence_ivl0 (flow0 x0 h)⟧ ⟹ h + i ∈ existence_ivl0 x0› 2. ‹⟦h ∈ existence_ivl0 x0; i ∈ existence_ivl0 (flow0 x0 h)⟧ ⟹ i + h ∈ existence_ivl0 x0› 3. ‹⟦h ∈ existence_ivl0 x0; i ∈ existence_ivl0 (flow0 x0 h)⟧ ⟹ x0 ∈ X› discuss goal 1*) apply ((auto simp add: add.commute (*‹(?a::?'a) + (?b::?'a) = ?b + ?a›*) existence_ivl_trans (*‹⟦(?s::real) ∈ existence_ivl0 (?x0.0::'a); (?t::real) ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*))[1]) (*discuss goal 2*) apply ((auto simp add: add.commute (*‹?a + ?b = ?b + ?a›*) existence_ivl_trans (*‹⟦?s ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*))[1]) (*discuss goal 3*) apply ((auto simp add: add.commute (*‹?a + ?b = ?b + ?a›*) existence_ivl_trans (*‹⟦?s ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*))[1]) (*proven 3 subgoals*) . show "?thesis" (*goal: ‹Dflow x0 (h + i) = Dflow (flow0 x0 h) i o⇩L Dflow x0 h›*) unfolding Dflow_def (*goal: ‹mvar.flow x0 0 1⇩L (h + i) = mvar.flow (flow0 x0 h) 0 1⇩L i o⇩L mvar.flow x0 0 1⇩L h›*) apply (subst mvar.flow_trans[where s=h and t=i] (*‹⟦h ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0; i + h ∈ mvar.existence_ivl ?x0a h (mvar.flow ?x0a ?t0.0 ?x0.0 h)⟧ ⟹ mvar.flow ?x0a ?t0.0 ?x0.0 (h + i) = mvar.flow ?x0a h (mvar.flow ?x0a ?t0.0 ?x0.0 h) (h + i)›*)) (*goal: ‹mvar.flow x0 0 1⇩L (h + i) = mvar.flow (flow0 x0 h) 0 1⇩L i o⇩L mvar.flow x0 0 1⇩L h›*) subgoal for by (auto simp: assms (*‹h ∈ existence_ivl0 x0› ‹i ∈ existence_ivl0 (flow0 x0 h)›*)) subgoal for by (auto simp: assms (*‹h ∈ existence_ivl0 x0› ‹i ∈ existence_ivl0 (flow0 x0 h)›*)) apply (subst mvar_flow_shift (*‹⟦?t0.0 ∈ existence_ivl0 ?x0.0; ?t1.0 ∈ existence_ivl0 ?x0.0⟧ ⟹ mvar.flow ?x0.0 ?t0.0 ?d ?t1.0 = Dflow (flow0 ?x0.0 ?t0.0) (?t1.0 - ?t0.0) o⇩L ?d›*)) (*goal: ‹mvar.flow x0 h (mvar.flow x0 0 1⇩L h) (h + i) = mvar.flow (flow0 x0 h) 0 1⇩L i o⇩L mvar.flow x0 0 1⇩L h›*) apply (auto simp: assms (*‹h ∈ existence_ivl0 x0› ‹i ∈ existence_ivl0 (flow0 x0 h)›*) Dflow_def (*‹Dflow ?x0.0 = mvar.flow ?x0.0 0 1⇩L›*)) (*top goal: ‹0 ∈ existence_ivl0 x0› and 2 goals remain*) by (msorry) qed lemma Dflow_trans_apply: assumes "h ∈ existence_ivl0 x0" assumes "i ∈ existence_ivl0 (flow0 x0 h)" shows "Dflow x0 (h + i) d0 = Dflow (flow0 x0 h) i (Dflow x0 h d0)" proof (-) (*goal: ‹blinfun_apply (Dflow x0 (h + i)) d0 = blinfun_apply (Dflow (flow0 x0 h) i) (blinfun_apply (Dflow x0 h) d0)›*) have [intro, simp]: "h + i ∈ existence_ivl0 x0" "i + h ∈ existence_ivl0 x0" "x0 ∈ X" using assms (*‹h ∈ existence_ivl0 x0› ‹i ∈ existence_ivl0 (flow0 x0 h)›*) apply - (*goals: 1. ‹⟦h ∈ existence_ivl0 x0; i ∈ existence_ivl0 (flow0 x0 h)⟧ ⟹ h + i ∈ existence_ivl0 x0› 2. ‹⟦h ∈ existence_ivl0 x0; i ∈ existence_ivl0 (flow0 x0 h)⟧ ⟹ i + h ∈ existence_ivl0 x0› 3. ‹⟦h ∈ existence_ivl0 x0; i ∈ existence_ivl0 (flow0 x0 h)⟧ ⟹ x0 ∈ X› discuss goal 1*) apply ((auto simp add: add.commute (*‹?a + ?b = ?b + ?a›*) existence_ivl_trans (*‹⟦?s ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*))[1]) (*discuss goal 2*) apply ((auto simp add: add.commute (*‹?a + ?b = ?b + ?a›*) existence_ivl_trans (*‹⟦?s ∈ existence_ivl0 ?x0.0; ?t ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*))[1]) (*discuss goal 3*) apply ((auto simp add: add.commute (*‹(?a::?'a) + (?b::?'a) = ?b + ?a›*) existence_ivl_trans (*‹⟦(?s::real) ∈ existence_ivl0 (?x0.0::'a); (?t::real) ∈ existence_ivl0 (flow0 ?x0.0 ?s)⟧ ⟹ ?s + ?t ∈ existence_ivl0 ?x0.0›*))[1]) (*proven 3 subgoals*) . show "?thesis" (*goal: ‹blinfun_apply (Dflow x0 (h + i)) d0 = blinfun_apply (Dflow (flow0 x0 h) i) (blinfun_apply (Dflow x0 h) d0)›*) unfolding Dflow_def (*goal: ‹blinfun_apply (mvar.flow (x0::'a) (0::real) 1⇩L ((h::real) + (i::real))) (d0::'a) = blinfun_apply (mvar.flow (flow0 x0 h) (0::real) 1⇩L i) (blinfun_apply (mvar.flow x0 (0::real) 1⇩L h) d0)›*) apply (subst mvar.flow_trans[where s=h and t=i] (*‹⟦h ∈ mvar.existence_ivl ?x0a ?t0.0 ?x0.0; i + h ∈ mvar.existence_ivl ?x0a h (mvar.flow ?x0a ?t0.0 ?x0.0 h)⟧ ⟹ mvar.flow ?x0a ?t0.0 ?x0.0 (h + i) = mvar.flow ?x0a h (mvar.flow ?x0a ?t0.0 ?x0.0 h) (h + i)›*)) (*goal: ‹blinfun_apply (mvar.flow x0 0 1⇩L (h + i)) d0 = blinfun_apply (mvar.flow (flow0 x0 h) 0 1⇩L i) (blinfun_apply (mvar.flow x0 0 1⇩L h) d0)›*) subgoal for by (auto simp: assms (*‹(h::real) ∈ existence_ivl0 (x0::'a)› ‹(i::real) ∈ existence_ivl0 (flow0 (x0::'a) (h::real))›*)) subgoal for by (auto simp: assms (*‹h ∈ existence_ivl0 x0› ‹i ∈ existence_ivl0 (flow0 x0 h)›*)) apply (subst mvar_flow_shift (*‹⟦?t0.0 ∈ existence_ivl0 ?x0.0; ?t1.0 ∈ existence_ivl0 ?x0.0⟧ ⟹ mvar.flow ?x0.0 ?t0.0 ?d ?t1.0 = Dflow (flow0 ?x0.0 ?t0.0) (?t1.0 - ?t0.0) o⇩L ?d›*)) (*goal: ‹blinfun_apply (mvar.flow (x0::'a) (h::real) (mvar.flow x0 (0::real) 1⇩L h) (h + (i::real))) (d0::'a) = blinfun_apply (mvar.flow (flow0 x0 h) (0::real) 1⇩L i) (blinfun_apply (mvar.flow x0 (0::real) 1⇩L h) d0)›*) apply (auto simp: assms (*‹(h::real) ∈ existence_ivl0 (x0::'a)› ‹(i::real) ∈ existence_ivl0 (flow0 (x0::'a) (h::real))›*) Dflow_def (*‹Dflow (?x0.0::'a) = mvar.flow ?x0.0 (0::real) 1⇩L›*)) (*top goal: ‹(0::real) ∈ existence_ivl0 (x0::'a)› and 2 goals remain*) by (msorry) qed end ― ‹@{thm c1_on_open_euclidean_anchor}› end
{ "path": "afp-2025-02-12/thys/Ordinary_Differential_Equations/IVP/Flow.thy", "repo": "afp-2025-02-12", "sha": "cc34fb89e5b3699ecb9ca92beb73b9af4f66dbd286f73e450b50c71d9869825c" }
section ‹LIM is a proper subset of BC\label{s:lim_bc}› theory LIM_BC imports Lemma_R begin text ‹The proper inclusion of LIM in BC has been proved by Barzdin~\<^cite>‹"b-ttlsf-74"› (see also Case and Smith~\<^cite>‹"cs-cicmii-83"›). The proof constructs a class $V \in \mathrm{BC} - \mathrm{LIM}$ by diagonalization against all LIM strategies. Exploiting Lemma~R for LIM, we can assume that all such strategies are total functions. From the effective version of this lemma we derive a numbering @{term "σ ∈ ℛ²"} such that for all $U \in \mathrm{LIM}$ there is an $i$ with $U\in \mathrm{LIM}_\varphi(\sigma_i)$. The idea behind $V$ is for every $i$ to construct a class $V_i$ of cardinality one or two such that $V_i \notin \mathrm{LIM}_\varphi(\sigma_i)$. It then follows that the union $V := \bigcup_i V_i$ cannot be learned by any $\sigma_i$ and thus $V \notin \mathrm{LIM}$. At the same time, the construction ensures that the functions in $V$ are ``predictable enough'' to be learnable in the BC sense. At the core is a process that maintains a state $(b, k)$ of a list $b$ of numbers and an index $k < |b|$ into this list. We imagine $b$ to be the prefix of the function being constructed, except for position $k$ where we imagine $b$ to have a ``gap''; that is, $b_k$ is not defined yet. Technically, we will always have $b_k = 0$, so $b$ also represents the prefix after the ``gap is filled'' with 0, whereas $b_{k:=1}$ represents the prefix where the gap is filled with 1. For every $i \in \mathbb{N}$, the process starts in state $(i0, 1)$ and computes the next state from a given state $(b,k)$ as follows: \begin{enumerate} \item if $ \sigma_i(b_{<k}) \neq \sigma_i(b)$ then the next state is $(b0, |b|)$, \item else if $\sigma_i(b_{<k}) \neq \sigma_i(b_{k:=1})$ then the next state is $(b_{k:=1}0, |b|)$, \item else the next state is $(b0, k)$. \end{enumerate} In other words, if $\sigma_i$ changes its hypothesis when the gap in $b$ is filled with 0 or 1, then the process fills the gap with 0 or 1, respectively, and appends a gap to $b$. If, however, a hypothesis change cannot be enforced at this point, the process appends a 0 to $b$ and leaves the gap alone. Now there are two cases: \begin{itemize} \item[Case 1.] Every gap gets filled eventually. Then the process generates increasing prefixes of a total function $\tau_i$, on which $\sigma_i$ changes its hypothesis infinitely often. We set $V_i := \{\tau_i\}$, and have $V_i \notin \mathrm{LIM}_\varphi(\sigma_i)$. \item[Case 2.] Some gap never gets filled. That means a state $(b, k)$ is reached such that $\sigma_i(b0^t) = \sigma_i(b_{k:=1}0^t) = \sigma_i(b_{<k})$ for all $t$. Then the process describes a function $\tau_i = b_{<k}\uparrow0^\infty$, where the value at the gap $k$ is undefined. Replacing the value at $k$ by 0 and 1 yields two functions $\tau_i^{(0)} = b0^\infty$ and $\tau_i^{(1)} = b_{k:=1}0^\infty$, which differ only at $k$ and on which $\sigma_i$ converges to the same hypothesis. Thus $\sigma_i$ does not learn the class $V_i := \{\tau_i^{(0)}, \tau_i^{(1)}\}$ in the limit. \end{itemize} Both cases combined imply $V \notin \mathrm{LIM}$. A BC strategy $S$ for $V = \bigcup_i V_i$ works as follows. Let $f\in V$. On input $f^n$ the strategy outputs a Gödel number of the function \[ g_n(x) = \left\{\begin{array}{ll} f(x) & \mbox{if } x \leq n,\\ \tau_{f(0)}(x) & \mbox{otherwise}. \end{array}\right. \] By definition of $V$, $f$ is generated by the process running for $i = f(0)$. If $f(0)$ leads to Case~1 then $f = \tau_{f(0)}$, and $g_n$ equals $f$ for all $n$. If $f(0)$ leads to Case~2 with a forever unfilled gap at $k$, then $g_n$ will be equal to the correct one of $\tau_i^{(0)}$ or $\tau_i^{(1)}$ for all $n \geq k$. Intuitively, the prefix received by $S$ eventually grows long enough to reveal the value $f(k)$. In both cases $S$ converges to $f$, but it outputs a different Gödel number for every $f^n$ because $g_n$ contains the ``hard-coded'' values $f(0),\dots,f(n)$. Therefore $S$ is a BC strategy but not a LIM strategy for $V$.› subsection ‹Enumerating enough total strategies› text ‹For the construction of $\sigma$ we need the function @{term r_limr} from the effective version of Lemma~R for LIM.› definition "r_sigma ≡ Cn 2 r_phi [Cn 2 r_limr [Id 2 0], Id 2 1]" lemma r_sigma_recfn: "recfn 2 r_sigma" unfolding r_sigma_def (*goal: ‹recfn 2 (Cn 2 r_phi [Cn 2 r_limr [recf.Id 2 0], recf.Id 2 1])›*) using r_limr_recfn (*‹recfn 1 r_limr›*) by simp lemma r_sigma: "eval r_sigma [i, x] = φ (the (eval r_limr [i])) x" unfolding r_sigma_def phi_def (*goal: ‹eval (Cn 2 r_phi [Cn 2 r_limr [recf.Id 2 0], recf.Id 2 1]) [i, x] = eval r_phi [the (eval r_limr [i]), x]›*) using r_sigma_recfn (*‹recfn 2 r_sigma›*) r_limr_total (*‹Partial_Recursive.total r_limr›*) r_limr_recfn (*‹recfn 1 r_limr›*) by simp lemma r_sigma_total: "total r_sigma" using r_sigma (*‹eval r_sigma [?i::nat, ?x::nat] = φ (the (eval r_limr [?i])) ?x›*) r_limr (*‹φ (the (eval r_limr [?i])) ∈ ℛ› ‹learn_lim ?ψ ?U (φ ?i) ⟹ learn_lim ?ψ ?U (φ (the (eval r_limr [?i])))›*) r_sigma_recfn (*‹recfn 2 r_sigma›*) totalI2[of r_sigma] (*‹⟦recfn (2::nat) r_sigma; ⋀(x::nat) y::nat. eval r_sigma [x, y] ↓⟧ ⟹ Partial_Recursive.total r_sigma›*) by simp abbreviation sigma :: partial2 ("σ") where "σ i x ≡ eval r_sigma [i, x]" lemma sigma: "σ i = φ (the (eval r_limr [i]))" using r_sigma (*‹σ ?i ?x = φ (the (eval r_limr [?i])) ?x›*) by simp text ‹The numbering @{term σ} does indeed enumerate enough total strategies for every LIM learning problem.› lemma learn_lim_sigma: assumes "learn_lim ψ U (φ i)" shows "learn_lim ψ U (σ i)" sorry subsection ‹The diagonalization process› text ‹The following function represents the process described above. It computes the next state from a given state $(b, k)$.› definition "r_next ≡ Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], r_pdec1], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], r_pdec2], Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_update [r_pdec1, r_pdec2, r_const 1], Z], Cn 1 r_length [r_pdec1]]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], Cn 1 r_length [r_pdec1]]]" lemma r_next_recfn: "recfn 1 r_next" unfolding r_next_def (*goal: ‹recfn 1 (Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], r_pdec1], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], r_pdec2], Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_update [r_pdec1, r_pdec2, r_const 1], Z], Cn 1 r_length [r_pdec1]]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], Cn 1 r_length [r_pdec1]]])›*) using r_sigma_recfn (*‹recfn 2 r_sigma›*) by simp text ‹The three conditions distinguished in @{term r_next} correspond to Steps 1, 2, and 3 of the process: hypothesis change when the gap is filled with 0; hypothesis change when the gap is filled with 1; or no hypothesis change either way.› abbreviation "change_on_0 b k ≡ σ (e_hd b) b ≠ σ (e_hd b) (e_take k b)" abbreviation "change_on_1 b k ≡ σ (e_hd b) b = σ (e_hd b) (e_take k b) ∧ σ (e_hd b) (e_update b k 1) ≠ σ (e_hd b) (e_take k b)" abbreviation "change_on_neither b k ≡ σ (e_hd b) b = σ (e_hd b) (e_take k b) ∧ σ (e_hd b) (e_update b k 1) = σ (e_hd b) (e_take k b)" lemma change_conditions: obtains (on_0) "change_on_0 b k" | (on_1) "change_on_1 b k" | (neither) "change_on_neither b k" by auto lemma r_next: assumes "arg = prod_encode (b, k)" shows "change_on_0 b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b)" and "change_on_1 b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b)" and "change_on_neither b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k)" proof (-) (*goals: 1. ‹change_on_0 b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b)› 2. ‹change_on_1 b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b)› 3. ‹change_on_neither b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k)›*) let ?bhd = "Cn 1 r_hd [r_pdec1]" let ?bup = "Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]" let ?bk = "Cn 1 r_take [r_pdec2, r_pdec1]" let ?bap = "Cn 1 r_snoc [r_pdec1, Z]" let ?len = "Cn 1 r_length [r_pdec1]" let ?thenthen = "Cn 1 r_prod_encode [?bap, r_pdec2]" let ?thenelse = "Cn 1 r_prod_encode [Cn 1 r_snoc [?bup, Z], ?len]" let ?else = "Cn 1 r_prod_encode [?bap, ?len]" have bhd: "eval ?bhd [arg] ↓= e_hd b" using assms (*‹arg = prod_encode (b, k)›*) by simp have bup: "eval ?bup [arg] ↓= e_update b k 1" using assms (*‹arg = prod_encode (b, k)›*) by simp have bk: "eval ?bk [arg] ↓= e_take k b" using assms (*‹arg = prod_encode (b, k)›*) by simp have bap: "eval ?bap [arg] ↓= e_snoc b 0" using assms (*‹arg = prod_encode (b, k)›*) by simp have len: "eval ?len [arg] ↓= e_length b" using assms (*‹arg = prod_encode (b, k)›*) by simp have else_: "eval ?else [arg] ↓= prod_encode (e_snoc b 0, e_length b)" using bap (*‹eval (Cn 1 r_snoc [r_pdec1, Z]) [arg] ↓= e_snoc b 0›*) len (*‹eval (Cn 1 r_length [r_pdec1]) [arg] ↓= e_length b›*) by simp have thenthen: "eval ?thenthen [arg] ↓= prod_encode (e_snoc b 0, k)" using bap (*‹eval (Cn 1 r_snoc [r_pdec1, Z]) [arg] ↓= e_snoc b 0›*) assms (*‹(arg::nat) = prod_encode (b::nat, k::nat)›*) by simp have thenelse: "eval ?thenelse [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b)" using bup (*‹eval (Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]) [arg] ↓= e_update b k 1›*) len (*‹eval (Cn 1 r_length [r_pdec1]) [arg] ↓= e_length b›*) by simp have then_: "eval (Cn 1 r_ifeq [Cn 1 r_sigma [?bhd, ?bup], Cn 1 r_sigma [?bhd, ?bk], ?thenthen, ?thenelse]) [arg] ↓= (if the (σ (e_hd b) (e_update b k 1)) = the (σ (e_hd b) (e_take k b)) then prod_encode (e_snoc b 0, k) else prod_encode (e_snoc (e_update b k 1) 0, e_length b))" (is "eval ?then [arg] ↓= ?then_eval") using bhd (*‹eval (Cn 1 r_hd [r_pdec1]) [arg] ↓= e_hd b›*) bup (*‹eval (Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]) [arg] ↓= e_update b k 1›*) bk (*‹eval (Cn (1::nat) r_take [r_pdec2, r_pdec1]) [arg::nat] ↓= e_take (k::nat) (b::nat)›*) thenthen (*‹eval (Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], r_pdec2]) [arg] ↓= prod_encode (e_snoc b 0, k)›*) thenelse (*‹eval (Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_update [r_pdec1, r_pdec2, r_const 1], Z], Cn 1 r_length [r_pdec1]]) [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b)›*) r_sigma (*‹σ (?i::nat) (?x::nat) = φ (the (eval r_limr [?i])) ?x›*) r_sigma_recfn (*‹recfn 2 r_sigma›*) r_limr (*‹φ (the (eval r_limr [?i])) ∈ ℛ› ‹learn_lim ?ψ ?U (φ ?i) ⟹ learn_lim ?ψ ?U (φ (the (eval r_limr [?i])))›*) R1_imp_total1 (*‹?f ∈ ℛ ⟹ total1 ?f›*) by simp have "*": "eval r_next [arg] ↓= (if the (σ (e_hd b) b) = the (σ (e_hd b) (e_take k b)) then ?then_eval else prod_encode (e_snoc b 0, e_length b))" unfolding r_next_def (*goal: ‹eval (Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], r_pdec1], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], r_pdec2], Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_update [r_pdec1, r_pdec2, r_const 1], Z], Cn 1 r_length [r_pdec1]]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], Cn 1 r_length [r_pdec1]]]) [arg] ↓= (if the (σ (e_hd b) b) = the (σ (e_hd b) (e_take k b)) then if the (σ (e_hd b) (e_update b k 1)) = the (σ (e_hd b) (e_take k b)) then prod_encode (e_snoc b 0, k) else prod_encode (e_snoc (e_update b k 1) 0, e_length b) else prod_encode (e_snoc b 0, e_length b))›*) using bhd (*‹eval (Cn 1 r_hd [r_pdec1]) [arg] ↓= e_hd b›*) bk (*‹eval (Cn 1 r_take [r_pdec2, r_pdec1]) [arg] ↓= e_take k b›*) then_ (*‹eval (Cn 1 r_ifeq [Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_update [r_pdec1, r_pdec2, r_const 1]], Cn 1 r_sigma [Cn 1 r_hd [r_pdec1], Cn 1 r_take [r_pdec2, r_pdec1]], Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], r_pdec2], Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_update [r_pdec1, r_pdec2, r_const 1], Z], Cn 1 r_length [r_pdec1]]]) [arg] ↓= (if the (σ (e_hd b) (e_update b k 1)) = the (σ (e_hd b) (e_take k b)) then prod_encode (e_snoc b 0, k) else prod_encode (e_snoc (e_update b k 1) 0, e_length b))›*) else_ (*‹eval (Cn 1 r_prod_encode [Cn 1 r_snoc [r_pdec1, Z], Cn 1 r_length [r_pdec1]]) [arg] ↓= prod_encode (e_snoc b 0, e_length b)›*) r_sigma (*‹σ ?i ?x = φ (the (eval r_limr [?i])) ?x›*) r_sigma_recfn (*‹recfn 2 r_sigma›*) r_limr (*‹φ (the (eval r_limr [?i])) ∈ ℛ› ‹learn_lim ?ψ ?U (φ ?i) ⟹ learn_lim ?ψ ?U (φ (the (eval r_limr [?i])))›*) R1_imp_total1 (*‹?f ∈ ℛ ⟹ total1 ?f›*) assms (*‹arg = prod_encode (b, k)›*) by simp have r_sigma_neq: "eval r_sigma [x₁, y₁] ≠ eval r_sigma [x₂, y₂] ⟷ the (eval r_sigma [x₁, y₁]) ≠ the (eval r_sigma [x₂, y₂])" for x₁ and y₁ and x₂ and y₂ using r_sigma (*‹σ (?i::nat) (?x::nat) = φ (the (eval r_limr [?i])) ?x›*) r_limr (*‹φ (the (eval r_limr [?i])) ∈ ℛ› ‹learn_lim ?ψ ?U (φ ?i) ⟹ learn_lim ?ψ ?U (φ (the (eval r_limr [?i])))›*) totalE[OF r_sigma_total r_sigma_recfn] (*‹length ?xs = 2 ⟹ eval r_sigma ?xs ↓›*) r_sigma_recfn (*‹recfn 2 r_sigma›*) r_sigma_total (*‹Partial_Recursive.total r_sigma›*) by (metis One_nat_def (*‹1 = Suc 0›*) Suc_1 (*‹Suc 1 = 2›*) length_Cons (*‹length (?x # ?xs) = Suc (length ?xs)›*) list.size( (*‹length [] = 0›*) 3) option.expand (*‹⟦(?option = None) = (?option' = None); ⟦?option ≠ None; ?option' ≠ None⟧ ⟹ the ?option = the ?option'⟧ ⟹ ?option = ?option'›*)) { assume "change_on_0 b k" (*‹change_on_0 (b::nat) (k::nat)›*) then show "eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b)" using "*" (*‹eval r_next [arg] ↓= (if the (σ (e_hd b) b) = the (σ (e_hd b) (e_take k b)) then if the (σ (e_hd b) (e_update b k 1)) = the (σ (e_hd b) (e_take k b)) then prod_encode (e_snoc b 0, k) else prod_encode (e_snoc (e_update b k 1) 0, e_length b) else prod_encode (e_snoc b 0, e_length b))›*) r_sigma_neq (*‹(σ (?x₁::nat) (?y₁::nat) ≠ σ (?x₂::nat) (?y₂::nat)) = (the (σ ?x₁ ?y₁) ≠ the (σ ?x₂ ?y₂))›*) by simp next (*goals: 1. ‹change_on_1 b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b)› 2. ‹change_on_neither b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k)›*) assume "change_on_1 b k" (*‹change_on_1 (b::nat) (k::nat)›*) then show "eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b)" using "*" (*‹eval r_next [arg::nat] ↓= (if the (σ (e_hd (b::nat)) b) = the (σ (e_hd b) (e_take (k::nat) b)) then if the (σ (e_hd b) (e_update b k (1::nat))) = the (σ (e_hd b) (e_take k b)) then prod_encode (e_snoc b (0::nat), k) else prod_encode (e_snoc (e_update b k (1::nat)) (0::nat), e_length b) else prod_encode (e_snoc b (0::nat), e_length b))›*) r_sigma_neq (*‹(σ ?x₁ ?y₁ ≠ σ ?x₂ ?y₂) = (the (σ ?x₁ ?y₁) ≠ the (σ ?x₂ ?y₂))›*) by simp next (*goal: ‹change_on_neither b k ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k)›*) assume "change_on_neither b k" (*‹change_on_neither (b::nat) (k::nat)›*) then show "eval r_next [arg] ↓= prod_encode (e_snoc b 0, k)" using "*" (*‹eval r_next [arg] ↓= (if the (σ (e_hd b) b) = the (σ (e_hd b) (e_take k b)) then if the (σ (e_hd b) (e_update b k 1)) = the (σ (e_hd b) (e_take k b)) then prod_encode (e_snoc b 0, k) else prod_encode (e_snoc (e_update b k 1) 0, e_length b) else prod_encode (e_snoc b 0, e_length b))›*) r_sigma_neq (*‹(σ (?x₁::nat) (?y₁::nat) ≠ σ (?x₂::nat) (?y₂::nat)) = (the (σ ?x₁ ?y₁) ≠ the (σ ?x₂ ?y₂))›*) by simp } qed lemma r_next_total: "total r_next" proof (rule totalI1 (*‹⟦recfn (1::nat) (?f::recf); ⋀x::nat. eval ?f [x] ↓⟧ ⟹ Partial_Recursive.total ?f›*)) (*goals: 1. ‹recfn 1 r_next› 2. ‹⋀x. eval r_next [x] ↓›*) show "recfn 1 r_next" using r_next_recfn (*‹recfn 1 r_next›*) by simp show "eval r_next [x] ↓" for x proof (-) (*goal: ‹eval r_next [x] ↓›*) obtain b and k where "x = prod_encode (b, k)" (*goal: ‹(⋀b k. x = prod_encode (b, k) ⟹ thesis) ⟹ thesis›*) using prod_encode_pdec'[of x] (*‹prod_encode (pdec1' x, pdec2' x) = x›*) by metis then show "?thesis" (*goal: ‹eval r_next [x] ↓›*) using r_next (*‹⟦?arg = prod_encode (?b, ?k); change_on_0 ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc ?b 0, e_length ?b)› ‹⟦(?arg::nat) = prod_encode (?b::nat, ?k::nat); change_on_1 ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc (e_update ?b ?k (1::nat)) (0::nat), e_length ?b)› ‹⟦(?arg::nat) = prod_encode (?b::nat, ?k::nat); change_on_neither ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc ?b (0::nat), ?k)›*) by fast qed qed text ‹The next function computes the state of the process after any number of iterations.› definition "r_state ≡ Pr 1 (Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_singleton_encode [Id 1 0], Z], r_const 1]) (Cn 3 r_next [Id 3 1])" lemma r_state_recfn: "recfn 2 r_state" unfolding r_state_def (*goal: ‹recfn (2::nat) (Pr (1::nat) (Cn (1::nat) r_prod_encode [Cn (1::nat) r_snoc [Cn (1::nat) r_singleton_encode [recf.Id (1::nat) (0::nat)], Z], r_const (1::nat)]) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]))›*) using r_next_recfn (*‹recfn 1 r_next›*) by simp lemma r_state_at_0: "eval r_state [0, i] ↓= prod_encode (list_encode [i, 0], 1)" proof (-) (*goal: ‹eval r_state [0, i] ↓= prod_encode (Partial_Recursive.list_encode [i, 0], 1)›*) let ?f = "Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_singleton_encode [Id 1 0], Z], r_const 1]" have "eval r_state [0, i] = eval ?f [i]" unfolding r_state_def (*goal: ‹eval (Pr (1::nat) (Cn (1::nat) r_prod_encode [Cn (1::nat) r_snoc [Cn (1::nat) r_singleton_encode [recf.Id (1::nat) (0::nat)], Z], r_const (1::nat)]) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)])) [0::nat, i::nat] = eval (Cn (1::nat) r_prod_encode [Cn (1::nat) r_snoc [Cn (1::nat) r_singleton_encode [recf.Id (1::nat) (0::nat)], Z], r_const (1::nat)]) [i]›*) using r_next_recfn (*‹recfn 1 r_next›*) by simp also (*calculation: ‹eval r_state [0, i] = eval (Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_singleton_encode [recf.Id 1 0], Z], r_const 1]) [i]›*) have "... ↓= prod_encode (list_encode [i, 0], 1)" by (simp add: list_decode_singleton (*‹Partial_Recursive.list_decode (singleton_encode (?x::nat)) = [?x]›*)) finally (*calculation: ‹eval r_state [0, i] ↓= prod_encode (Partial_Recursive.list_encode [i, 0], 1)›*) show "?thesis" (*goal: ‹eval r_state [0, i] ↓= prod_encode (Partial_Recursive.list_encode [i, 0], 1)›*) . qed lemma r_state_total: "total r_state" unfolding r_state_def (*goal: ‹Partial_Recursive.total (Pr 1 (Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_singleton_encode [recf.Id 1 0], Z], r_const 1]) (Cn 3 r_next [recf.Id 3 1]))›*) using r_next_recfn (*‹recfn 1 r_next›*) totalE[OF r_next_total r_next_recfn] (*‹length ?xs = 1 ⟹ eval r_next ?xs ↓›*) totalI3[of "Cn 3 r_next [Id 3 1]"] (*‹⟦recfn (3::nat) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]); ⋀(x::nat) (y::nat) z::nat. eval (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]) [x, y, z] ↓⟧ ⟹ Partial_Recursive.total (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)])›*) apply (intro Pr_total (*‹⟦Partial_Recursive.total (?f::recf); Partial_Recursive.total (?g::recf); recfn (Suc (?n::nat)) (Pr ?n ?f ?g)⟧ ⟹ Partial_Recursive.total (Pr ?n ?f ?g)›*)) (*goals: 1. ‹⟦recfn (1::nat) r_next; ⋀xs::nat list. length xs = (1::nat) ⟹ eval r_next xs ↓; ⟦recfn (3::nat) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]); ⋀(x::nat) (y::nat) z::nat. eval (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]) [x, y, z] ↓⟧ ⟹ Partial_Recursive.total (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)])⟧ ⟹ Partial_Recursive.total (Cn (1::nat) r_prod_encode [Cn (1::nat) r_snoc [Cn (1::nat) r_singleton_encode [recf.Id (1::nat) (0::nat)], Z], r_const (1::nat)])› 2. ‹⟦recfn (1::nat) r_next; ⋀xs::nat list. length xs = (1::nat) ⟹ eval r_next xs ↓; ⟦recfn (3::nat) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]); ⋀(x::nat) (y::nat) z::nat. eval (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]) [x, y, z] ↓⟧ ⟹ Partial_Recursive.total (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)])⟧ ⟹ Partial_Recursive.total (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)])› 3. ‹⟦recfn (1::nat) r_next; ⋀xs::nat list. length xs = (1::nat) ⟹ eval r_next xs ↓; ⟦recfn (3::nat) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]); ⋀(x::nat) (y::nat) z::nat. eval (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]) [x, y, z] ↓⟧ ⟹ Partial_Recursive.total (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)])⟧ ⟹ recfn (Suc (1::nat)) (Pr (1::nat) (Cn (1::nat) r_prod_encode [Cn (1::nat) r_snoc [Cn (1::nat) r_singleton_encode [recf.Id (1::nat) (0::nat)], Z], r_const (1::nat)]) (Cn (3::nat) r_next [recf.Id (3::nat) (1::nat)]))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . text ‹We call the components of a state $(b, k)$ the \emph{block} $b$ and the \emph{gap} $k$.› definition block :: "nat ⇒ nat ⇒ nat" where "block i t ≡ pdec1 (the (eval r_state [t, i]))" definition gap :: "nat ⇒ nat ⇒ nat" where "gap i t ≡ pdec2 (the (eval r_state [t, i]))" lemma state_at_0: "block i 0 = list_encode [i, 0]" "gap i 0 = 1" unfolding block_def gap_def r_state_at_0 (*goals: 1. ‹pdec1 (the (Some (prod_encode (Partial_Recursive.list_encode [i, 0], 1)))) = Partial_Recursive.list_encode [i, 0]› 2. ‹pdec2 (the (Some (prod_encode (Partial_Recursive.list_encode [i, 0], 1)))) = 1›*) (*goals: 1. ‹pdec1 (the (Some (prod_encode (Partial_Recursive.list_encode [i::nat, 0::nat], 1::nat)))) = Partial_Recursive.list_encode [i, 0::nat]› 2. ‹pdec2 (the (Some (prod_encode (Partial_Recursive.list_encode [i::nat, 0::nat], 1::nat)))) = (1::nat)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . text ‹Some lemmas describing the behavior of blocks and gaps in one iteration of the process:› lemma state_Suc: assumes "b = block i t" and "k = gap i t" shows "block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)]))" and "gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))" proof (-) (*goals: 1. ‹block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)]))› 2. ‹gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))›*) have "eval r_state [Suc t, i] = eval (Cn 3 r_next [Id 3 1]) [t, the (eval r_state [t, i]), i]" using r_state_recfn (*‹recfn 2 r_state›*) r_next_recfn (*‹recfn 1 r_next›*) totalE[OF r_state_total r_state_recfn, of "[t, i]"] (*‹length [t, i] = 2 ⟹ eval r_state [t, i] ↓›*) by (simp add: r_state_def (*‹r_state ≡ Pr 1 (Cn 1 r_prod_encode [Cn 1 r_snoc [Cn 1 r_singleton_encode [recf.Id 1 0], Z], r_const 1]) (Cn 3 r_next [recf.Id 3 1])›*)) also (*calculation: ‹eval r_state [Suc t, i] = eval (Cn 3 r_next [recf.Id 3 1]) [t, the (eval r_state [t, i]), i]›*) have "... = eval r_next [the (eval r_state [t, i])]" using r_next_recfn (*‹recfn (1::nat) r_next›*) by simp also (*calculation: ‹eval r_state [Suc (t::nat), i::nat] = eval r_next [the (eval r_state [t, i])]›*) have "... = eval r_next [prod_encode (b, k)]" using assms (*‹b = block i t› ‹(k::nat) = gap (i::nat) (t::nat)›*) block_def (*‹block ?i ?t ≡ pdec1 (the (eval r_state [?t, ?i]))›*) gap_def (*‹gap ?i ?t ≡ pdec2 (the (eval r_state [?t, ?i]))›*) by simp finally (*calculation: ‹eval r_state [Suc t, i] = eval r_next [prod_encode (b, k)]›*) have "eval r_state [Suc t, i] = eval r_next [prod_encode (b, k)]" . then show "block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)]))" "gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))" apply - (*goals: 1. ‹eval r_state [Suc t, i] = eval r_next [prod_encode (b, k)] ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)]))› 2. ‹eval r_state [Suc t, i] = eval r_next [prod_encode (b, k)] ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))› discuss goal 1*) apply (simp add: block_def (*‹block ?i ?t ≡ pdec1 (the (eval r_state [?t, ?i]))›*)) (*discuss goal 2*) apply (simp add: gap_def (*‹gap (?i::nat) (?t::nat) ≡ pdec2 (the (eval r_state [?t, ?i]))›*)) (*proven 2 subgoals*) . qed lemma gap_Suc: assumes "b = block i t" and "k = gap i t" shows "change_on_0 b k ⟹ gap i (Suc t) = e_length b" and "change_on_1 b k ⟹ gap i (Suc t) = e_length b" and "change_on_neither b k⟹ gap i (Suc t) = k" using assms (*‹b = block i t› ‹k = gap i t›*) r_next (*‹⟦?arg = prod_encode (?b, ?k); change_on_0 ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc ?b 0, e_length ?b)› ‹⟦(?arg::nat) = prod_encode (?b::nat, ?k::nat); change_on_1 ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc (e_update ?b ?k (1::nat)) (0::nat), e_length ?b)› ‹⟦?arg = prod_encode (?b, ?k); change_on_neither ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc ?b 0, ?k)›*) state_Suc (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t⟧ ⟹ block ?i (Suc ?t) = pdec1 (the (eval r_next [prod_encode (?b, ?k)]))› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t⟧ ⟹ gap ?i (Suc ?t) = pdec2 (the (eval r_next [prod_encode (?b, ?k)]))›*) apply - (*goals: 1. ‹⟦change_on_0 b k; b = block i t; k = gap i t; ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_0 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_1 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_neither b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)])); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))⟧ ⟹ gap i (Suc t) = e_length b› 2. ‹⟦change_on_1 b k; b = block i t; k = gap i t; ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_0 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_1 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_neither b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)])); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))⟧ ⟹ gap i (Suc t) = e_length b› 3. ‹⟦change_on_neither b k; b = block i t; k = gap i t; ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_0 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_1 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_neither b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)])); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))⟧ ⟹ gap i (Suc t) = k› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma block_Suc: assumes "b = block i t" and "k = gap i t" shows "change_on_0 b k ⟹ block i (Suc t) = e_snoc b 0" and "change_on_1 b k ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0" and "change_on_neither b k⟹ block i (Suc t) = e_snoc b 0" using assms (*‹b = block i t› ‹(k::nat) = gap (i::nat) (t::nat)›*) r_next (*‹⟦?arg = prod_encode (?b, ?k); change_on_0 ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc ?b 0, e_length ?b)› ‹⟦?arg = prod_encode (?b, ?k); change_on_1 ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc (e_update ?b ?k 1) 0, e_length ?b)› ‹⟦(?arg::nat) = prod_encode (?b::nat, ?k::nat); change_on_neither ?b ?k⟧ ⟹ eval r_next [?arg] ↓= prod_encode (e_snoc ?b (0::nat), ?k)›*) state_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t⟧ ⟹ block ?i (Suc ?t) = pdec1 (the (eval r_next [prod_encode (?b, ?k)]))› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t⟧ ⟹ gap ?i (Suc ?t) = pdec2 (the (eval r_next [prod_encode (?b, ?k)]))›*) apply - (*goals: 1. ‹⟦change_on_0 b k; b = block i t; k = gap i t; ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_0 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_1 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_neither b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)])); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))⟧ ⟹ block i (Suc t) = e_snoc b 0› 2. ‹⟦change_on_1 b k; b = block i t; k = gap i t; ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_0 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_1 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_neither b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)])); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))⟧ ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0› 3. ‹⟦change_on_neither b k; b = block i t; k = gap i t; ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_0 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_1 b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc (e_update b k 1) 0, e_length b); ⋀arg b k. ⟦arg = prod_encode (b, k); change_on_neither b k⟧ ⟹ eval r_next [arg] ↓= prod_encode (e_snoc b 0, k); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ block i (Suc t) = pdec1 (the (eval r_next [prod_encode (b, k)])); ⋀b i t k. ⟦b = block i t; k = gap i t⟧ ⟹ gap i (Suc t) = pdec2 (the (eval r_next [prod_encode (b, k)]))⟧ ⟹ block i (Suc t) = e_snoc b 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . text ‹Non-gap positions in the block remain unchanged after an iteration.› lemma block_stable: assumes "j < e_length (block i t)" and "j ≠ gap i t" shows "e_nth (block i t) j = e_nth (block i (Suc t)) j" proof (-) (*goal: ‹e_nth (block i t) j = e_nth (block i (Suc t)) j›*) from change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block i t) (gap i t) ⟹ ?thesis; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "?thesis" (*goal: ‹e_nth (block i t) j = e_nth (block i (Suc t)) j›*) using assms (*‹j < e_length (block i t)› ‹(j::nat) ≠ gap (i::nat) (t::nat)›*) block_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k (1::nat)) (0::nat)› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) gap_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*) apply cases (*goals: 1. ‹⟦j < e_length (block i t); j ≠ gap i t; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ block i (Suc t) = e_snoc b 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ block i (Suc t) = e_snoc b 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ gap i (Suc t) = k; change_on_0 (block i t) (gap i t)⟧ ⟹ e_nth (block i t) j = e_nth (block i (Suc t)) j› 2. ‹⟦j < e_length (block i t); j ≠ gap i t; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ block i (Suc t) = e_snoc b 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ block i (Suc t) = e_snoc b 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ gap i (Suc t) = k; change_on_1 (block i t) (gap i t)⟧ ⟹ e_nth (block i t) j = e_nth (block i (Suc t)) j› 3. ‹⟦j < e_length (block i t); j ≠ gap i t; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ block i (Suc t) = e_snoc b 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ block i (Suc t) = e_snoc b 0; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ gap i (Suc t) = k; change_on_neither (block i t) (gap i t)⟧ ⟹ e_nth (block i t) j = e_nth (block i (Suc t)) j› discuss goal 1*) apply (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 2*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*discuss goal 3*) apply (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) (*proven 3 subgoals*) . qed text ‹Next are some properties of @{term block} and @{term gap}.› lemma gap_in_block: "gap i t < e_length (block i t)" proof (induction t) (*goals: 1. ‹gap (i::nat) (0::nat) < e_length (block i (0::nat))› 2. ‹⋀t::nat. gap (i::nat) t < e_length (block i t) ⟹ gap i (Suc t) < e_length (block i (Suc t))›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹gap i 0 < e_length (block i 0)›*) by (simp add: state_at_0 (*‹block ?i 0 = Partial_Recursive.list_encode [?i, 0]› ‹gap ?i 0 = 1›*)) next (*goal: ‹⋀t. gap i t < e_length (block i t) ⟹ gap i (Suc t) < e_length (block i (Suc t))›*) case (Suc t) (*‹gap i t < e_length (block i t)›*) with change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block (i::nat) (t::nat)) (gap i t) ⟹ ?thesis::bool; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "?case" (*goal: ‹gap (i::nat) (Suc (t::nat)) < e_length (block i (Suc t))›*) proof (cases) (*goals: 1. ‹⟦gap i t < e_length (block i t); change_on_0 (block i t) (gap i t)⟧ ⟹ gap i (Suc t) < e_length (block i (Suc t))› 2. ‹⟦gap i t < e_length (block i t); change_on_1 (block i t) (gap i t)⟧ ⟹ gap i (Suc t) < e_length (block i (Suc t))› 3. ‹⟦gap i t < e_length (block i t); change_on_neither (block i t) (gap i t)⟧ ⟹ gap i (Suc t) < e_length (block i (Suc t))›*) case on_0 (*‹change_on_0 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹gap i (Suc t) < e_length (block i (Suc t))›*) by (simp add: block_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) 1) gap_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) 1)) next (*goals: 1. ‹⟦gap i t < e_length (block i t); change_on_1 (block i t) (gap i t)⟧ ⟹ gap i (Suc t) < e_length (block i (Suc t))› 2. ‹⟦gap i t < e_length (block i t); change_on_neither (block i t) (gap i t)⟧ ⟹ gap i (Suc t) < e_length (block i (Suc t))›*) case on_1 (*‹change_on_1 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹gap (i::nat) (Suc (t::nat)) < e_length (block i (Suc t))›*) by (simp add: block_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0›*) 2) gap_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) 2)) next (*goal: ‹⟦gap i t < e_length (block i t); change_on_neither (block i t) (gap i t)⟧ ⟹ gap i (Suc t) < e_length (block i (Suc t))›*) case neither (*‹change_on_neither (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹gap (i::nat) (Suc (t::nat)) < e_length (block i (Suc t))›*) using Suc.IH (*‹gap i t < e_length (block i t)›*) block_Suc(3) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) gap_Suc(3) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*) by force qed qed lemma length_block: "e_length (block i t) = Suc (Suc t)" proof (induction t) (*goals: 1. ‹e_length (block i 0) = Suc (Suc 0)› 2. ‹⋀t. e_length (block i t) = Suc (Suc t) ⟹ e_length (block i (Suc t)) = Suc (Suc (Suc t))›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹e_length (block (i::nat) (0::nat)) = Suc (Suc (0::nat))›*) by (simp add: state_at_0 (*‹block ?i 0 = Partial_Recursive.list_encode [?i, 0]› ‹gap ?i 0 = 1›*)) next (*goal: ‹⋀t. e_length (block i t) = Suc (Suc t) ⟹ e_length (block i (Suc t)) = Suc (Suc (Suc t))›*) case (Suc t) (*‹e_length (block i t) = Suc (Suc t)›*) with change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block i t) (gap i t) ⟹ ?thesis; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "?case" (*goal: ‹e_length (block i (Suc t)) = Suc (Suc (Suc t))›*) apply cases (*goals: 1. ‹⟦e_length (block i t) = Suc (Suc t); change_on_0 (block i t) (gap i t)⟧ ⟹ e_length (block i (Suc t)) = Suc (Suc (Suc t))› 2. ‹⟦e_length (block i t) = Suc (Suc t); change_on_1 (block i t) (gap i t)⟧ ⟹ e_length (block i (Suc t)) = Suc (Suc (Suc t))› 3. ‹⟦e_length (block i t) = Suc (Suc t); change_on_neither (block i t) (gap i t)⟧ ⟹ e_length (block i (Suc t)) = Suc (Suc (Suc t))› discuss goal 1*) apply (simp add: block_Suc (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k (1::nat)) (0::nat)› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)›*) gap_Suc (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*)) (*discuss goal 2*) apply (simp add: block_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) gap_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*)) (*discuss goal 3*) apply (simp add: block_Suc (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k (1::nat)) (0::nat)› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)›*) gap_Suc (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*)) (*proven 3 subgoals*) . qed lemma gap_gr0: "gap i t > 0" proof (induction t) (*goals: 1. ‹(0::nat) < gap (i::nat) (0::nat)› 2. ‹⋀t::nat. (0::nat) < gap (i::nat) t ⟹ (0::nat) < gap i (Suc t)›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹0 < gap i 0›*) by (simp add: state_at_0 (*‹block (?i::nat) (0::nat) = Partial_Recursive.list_encode [?i, 0::nat]› ‹gap (?i::nat) (0::nat) = (1::nat)›*)) next (*goal: ‹⋀t. 0 < gap i t ⟹ 0 < gap i (Suc t)›*) case (Suc t) (*‹0 < gap i t›*) with change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block i t) (gap i t) ⟹ ?thesis; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "?case" (*goal: ‹0 < gap i (Suc t)›*) using length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) apply cases (*goals: 1. ‹⟦0 < gap i t; ⋀i t. e_length (block i t) = Suc (Suc t); change_on_0 (block i t) (gap i t)⟧ ⟹ 0 < gap i (Suc t)› 2. ‹⟦0 < gap i t; ⋀i t. e_length (block i t) = Suc (Suc t); change_on_1 (block i t) (gap i t)⟧ ⟹ 0 < gap i (Suc t)› 3. ‹⟦0 < gap i t; ⋀i t. e_length (block i t) = Suc (Suc t); change_on_neither (block i t) (gap i t)⟧ ⟹ 0 < gap i (Suc t)› discuss goal 1*) apply (simp add: block_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) gap_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*)) (*discuss goal 2*) apply (simp add: block_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) gap_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*)) (*discuss goal 3*) apply (simp add: block_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) gap_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*)) (*proven 3 subgoals*) . qed lemma hd_block: "e_hd (block i t) = i" proof (induction t) (*goals: 1. ‹e_hd (block i 0) = i› 2. ‹⋀t. e_hd (block i t) = i ⟹ e_hd (block i (Suc t)) = i›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹e_hd (block i 0) = i›*) by (simp add: state_at_0 (*‹block ?i 0 = Partial_Recursive.list_encode [?i, 0]› ‹gap ?i 0 = 1›*)) next (*goal: ‹⋀t. e_hd (block i t) = i ⟹ e_hd (block i (Suc t)) = i›*) case (Suc t) (*‹e_hd (block (i::nat) (t::nat)) = i›*) from change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block (i::nat) (t::nat)) (gap i t) ⟹ ?thesis::bool; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "?case" (*goal: ‹e_hd (block (i::nat) (Suc (t::nat))) = i›*) proof (cases) (*goals: 1. ‹change_on_0 (block i t) (gap i t) ⟹ e_hd (block i (Suc t)) = i› 2. ‹change_on_1 (block i t) (gap i t) ⟹ e_hd (block i (Suc t)) = i› 3. ‹change_on_neither (block i t) (gap i t) ⟹ e_hd (block i (Suc t)) = i›*) case on_0 (*‹change_on_0 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹e_hd (block i (Suc t)) = i›*) using Suc (*‹e_hd (block i t) = i›*) block_Suc(1) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by (metis e_hd_snoc (*‹0 < e_length ?b ⟹ e_hd (e_snoc ?b ?x) = e_hd ?b›*) gap_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) 1) gap_gr0 (*‹0 < gap ?i ?t›*)) next (*goals: 1. ‹change_on_1 (block i t) (gap i t) ⟹ e_hd (block i (Suc t)) = i› 2. ‹change_on_neither (block i t) (gap i t) ⟹ e_hd (block i (Suc t)) = i›*) case on_1 (*‹change_on_1 (block i t) (gap i t)›*) let ?b = "block i t" and ?k = "gap i t" have "?k > 0" using gap_gr0 (*‹0 < gap ?i ?t›*) Suc (*‹e_hd (block (i::nat) (t::nat)) = i›*) by simp then have "e_nth (e_update ?b ?k 1) 0 = e_nth ?b 0" by simp then have "*": "e_hd (e_update ?b ?k 1) = e_hd ?b" using e_hd_nth0 (*‹e_hd ?e = e_nth ?e 0›*) gap_Suc(2)[of _ i t] (*‹⟦?b = block i t; ?k = gap i t; change_on_1 ?b ?k⟧ ⟹ gap i (Suc t) = e_length ?b›*) gap_gr0 (*‹0 < gap ?i ?t›*) on_1 (*‹change_on_1 (block i t) (gap i t)›*) by (metis e_length_update (*‹e_length (e_update ?b ?k ?v) = e_length ?b›*)) from on_1 (*‹change_on_1 (block i t) (gap i t)›*) have "block i (Suc t) = e_snoc (e_update ?b ?k 1) 0" by (simp add: block_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0›*) 2)) then show "?thesis" (*goal: ‹e_hd (block i (Suc t)) = i›*) using e_hd_0 (*‹e_hd (0::nat) = (0::nat)›*) e_hd_snoc (*‹0 < e_length ?b ⟹ e_hd (e_snoc ?b ?x) = e_hd ?b›*) Suc (*‹e_hd (block i t) = i›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) ‹?k > 0› (*‹0 < gap i t›*) "*" (*‹e_hd (e_update (block i t) (gap i t) 1) = e_hd (block i t)›*) by (metis e_length_update (*‹e_length (e_update ?b ?k ?v) = e_length ?b›*) gap_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) 2) gap_gr0 (*‹0 < gap ?i ?t›*) on_1 (*‹change_on_1 (block i t) (gap i t)›*)) next (*goal: ‹change_on_neither (block i t) (gap i t) ⟹ e_hd (block i (Suc t)) = i›*) case neither (*‹change_on_neither (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹e_hd (block i (Suc t)) = i›*) by (metis Suc (*‹e_hd (block i t) = i›*) block_stable (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ e_nth (block ?i ?t) ?j = e_nth (block ?i (Suc ?t)) ?j›*) e_hd_nth0 (*‹e_hd ?e = e_nth ?e 0›*) gap_gr0 (*‹0 < gap ?i ?t›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) not_gr0 (*‹(¬ 0 < ?n) = (?n = 0)›*) zero_less_Suc (*‹0 < Suc ?n›*)) qed qed text ‹Formally, a block always ends in zero, even if it ends in a gap.› lemma last_block: "e_nth (block i t) (gap i t) = 0" proof (induction t) (*goals: 1. ‹e_nth (block i 0) (gap i 0) = 0› 2. ‹⋀t. e_nth (block i t) (gap i t) = 0 ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = 0›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹e_nth (block i 0) (gap i 0) = 0›*) by (simp add: state_at_0 (*‹block (?i::nat) (0::nat) = Partial_Recursive.list_encode [?i, 0::nat]› ‹gap (?i::nat) (0::nat) = (1::nat)›*)) next (*goal: ‹⋀t. e_nth (block i t) (gap i t) = 0 ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = 0›*) case (Suc t) (*‹e_nth (block (i::nat) (t::nat)) (gap i t) = (0::nat)›*) from change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block i t) (gap i t) ⟹ ?thesis; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "?case" (*goal: ‹e_nth (block (i::nat) (Suc (t::nat))) (gap i (Suc t)) = (0::nat)›*) proof (cases) (*goals: 1. ‹change_on_0 (block (i::nat) (t::nat)) (gap i t) ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = (0::nat)› 2. ‹change_on_1 (block (i::nat) (t::nat)) (gap i t) ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = (0::nat)› 3. ‹change_on_neither (block (i::nat) (t::nat)) (gap i t) ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = (0::nat)›*) case on_0 (*‹change_on_0 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹e_nth (block (i::nat) (Suc (t::nat))) (gap i (Suc t)) = (0::nat)›*) using Suc (*‹e_nth (block i t) (gap i t) = 0›*) by (simp add: block_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)›*) 1) gap_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) 1)) next (*goals: 1. ‹change_on_1 (block (i::nat) (t::nat)) (gap i t) ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = (0::nat)› 2. ‹change_on_neither (block (i::nat) (t::nat)) (gap i t) ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = (0::nat)›*) case on_1 (*‹change_on_1 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹e_nth (block i (Suc t)) (gap i (Suc t)) = 0›*) using Suc (*‹e_nth (block i t) (gap i t) = 0›*) by (simp add: block_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k 1) 0›*) 2) gap_Suc( (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) 2) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) next (*goal: ‹change_on_neither (block i t) (gap i t) ⟹ e_nth (block i (Suc t)) (gap i (Suc t)) = 0›*) case neither (*‹change_on_neither (block i t) (gap i t)›*) then have "block i (Suc t) = e_snoc (block i t) 0" "gap i (Suc t) = gap i t" apply - (*goals: 1. ‹change_on_neither (block i t) (gap i t) ⟹ block i (Suc t) = e_snoc (block i t) 0› 2. ‹change_on_neither (block i t) (gap i t) ⟹ gap i (Suc t) = gap i t› discuss goal 1*) apply (simp add: gap_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*) 3) block_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)›*) 3)) (*discuss goal 2*) apply (simp add: gap_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*) 3) block_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b (0::nat)›*) 3)) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹e_nth (block i (Suc t)) (gap i (Suc t)) = 0›*) using Suc (*‹e_nth (block i t) (gap i t) = 0›*) gap_in_block (*‹gap (?i::nat) (?t::nat) < e_length (block ?i ?t)›*) by (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) qed qed lemma gap_le_Suc: "gap i t ≤ gap i (Suc t)" using change_conditions[of "block i t" "gap i t"] (*‹⟦change_on_0 (block i t) (gap i t) ⟹ ?thesis; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) gap_Suc (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b› ‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*) gap_in_block (*‹gap ?i ?t < e_length (block ?i ?t)›*) less_imp_le[of "gap i t" "e_length (block i t)"] (*‹gap i t < e_length (block i t) ⟹ gap i t ≤ e_length (block i t)›*) apply cases (*goals: 1. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ gap i (Suc t) = k; ⋀i t. gap i t < e_length (block i t); gap i t < e_length (block i t) ⟹ gap i t ≤ e_length (block i t); change_on_0 (block i t) (gap i t)⟧ ⟹ gap i t ≤ gap i (Suc t)› 2. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ gap i (Suc t) = k; ⋀i t. gap i t < e_length (block i t); gap i t < e_length (block i t) ⟹ gap i t ≤ e_length (block i t); change_on_1 (block i t) (gap i t)⟧ ⟹ gap i t ≤ gap i (Suc t)› 3. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_neither b k⟧ ⟹ gap i (Suc t) = k; ⋀i t. gap i t < e_length (block i t); gap i t < e_length (block i t) ⟹ gap i t ≤ e_length (block i t); change_on_neither (block i t) (gap i t)⟧ ⟹ gap i t ≤ gap i (Suc t)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . lemma gap_monotone: assumes "t₁ ≤ t₂" shows "gap i t₁ ≤ gap i t₂" proof (-) (*goal: ‹gap i t₁ ≤ gap i t₂›*) have "gap i t₁ ≤ gap i (t₁ + j)" for j proof (induction j) (*goals: 1. ‹gap i t₁ ≤ gap i (t₁ + 0)› 2. ‹⋀j. gap i t₁ ≤ gap i (t₁ + j) ⟹ gap i t₁ ≤ gap i (t₁ + Suc j)›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹gap i t₁ ≤ gap i (t₁ + 0)›*) by simp next (*goal: ‹⋀j. gap i t₁ ≤ gap i (t₁ + j) ⟹ gap i t₁ ≤ gap i (t₁ + Suc j)›*) case (Suc j) (*‹gap i t₁ ≤ gap i (t₁ + j)›*) then show "?case" (*goal: ‹gap i t₁ ≤ gap i (t₁ + Suc j)›*) using gap_le_Suc (*‹gap ?i ?t ≤ gap ?i (Suc ?t)›*) dual_order.trans (*‹⟦?b ≤ ?a; ?c ≤ ?b⟧ ⟹ ?c ≤ ?a›*) by fastforce qed then show "?thesis" (*goal: ‹gap (i::nat) (t₁::nat) ≤ gap i (t₂::nat)›*) using assms (*‹(t₁::nat) ≤ (t₂::nat)›*) le_Suc_ex (*‹?k ≤ ?l ⟹ ∃n. ?l = ?k + n›*) by blast qed text ‹We need some lemmas relating the shape of the next state to the hypothesis change conditions in Steps 1, 2, and 3.› lemma state_change_on_neither: assumes "gap i (Suc t) = gap i t" shows "change_on_neither (block i t) (gap i t)" and "block i (Suc t) = e_snoc (block i t) 0" proof (-) (*goals: 1. ‹change_on_neither (block i t) (gap i t)› 2. ‹block i (Suc t) = e_snoc (block i t) 0›*) let ?b = "block i t" and ?k = "gap i t" have "?k < e_length ?b" using gap_in_block (*‹gap ?i ?t < e_length (block ?i ?t)›*) by simp from change_conditions[of ?b ?k] (*‹⟦change_on_0 (block i t) (gap i t) ⟹ ?thesis; change_on_1 (block i t) (gap i t) ⟹ ?thesis; change_on_neither (block i t) (gap i t) ⟹ ?thesis⟧ ⟹ ?thesis›*) show "change_on_neither (block i t) (gap i t)" proof (cases) (*goals: 1. ‹change_on_0 (block i t) (gap i t) ⟹ change_on_neither (block i t) (gap i t)› 2. ‹change_on_1 (block i t) (gap i t) ⟹ change_on_neither (block i t) (gap i t)› 3. ‹change_on_neither (block i t) (gap i t) ⟹ change_on_neither (block i t) (gap i t)›*) case on_0 (*‹change_on_0 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹change_on_neither (block i t) (gap i t)›*) using ‹?k < e_length ?b› (*‹gap i t < e_length (block i t)›*) assms (*‹gap i (Suc t) = gap i t›*) gap_Suc(1) (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) by auto next (*goals: 1. ‹change_on_1 (block i t) (gap i t) ⟹ change_on_neither (block i t) (gap i t)› 2. ‹change_on_neither (block i t) (gap i t) ⟹ change_on_neither (block i t) (gap i t)›*) case on_1 (*‹change_on_1 (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹change_on_neither (block i t) (gap i t)›*) using assms (*‹gap i (Suc t) = gap i t›*) gap_Suc(2) (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) by auto next (*goal: ‹change_on_neither (block i t) (gap i t) ⟹ change_on_neither (block i t) (gap i t)›*) case neither (*‹change_on_neither (block i t) (gap i t)›*) then show "?thesis" (*goal: ‹change_on_neither (block i t) (gap i t)›*) by simp qed then show "block i (Suc t) = e_snoc (block i t) 0" using block_Suc(3) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) by simp qed lemma state_change_on_either: assumes "gap i (Suc t) ≠ gap i t" shows "¬ change_on_neither (block i t) (gap i t)" and "gap i (Suc t) = e_length (block i t)" proof (-) (*goals: 1. ‹¬ change_on_neither (block (i::nat) (t::nat)) (gap i t)› 2. ‹gap (i::nat) (Suc (t::nat)) = e_length (block i t)›*) let ?b = "block i t" and ?k = "gap i t" show "¬ change_on_neither (block i t) (gap i t)" proof (standard) (*goal: ‹change_on_neither (block i t) (gap i t) ⟹ False›*) assume "change_on_neither (block i t) (gap i t)" (*‹change_on_neither (block (i::nat) (t::nat)) (gap i t)›*) then have "gap i (Suc t) = ?k" by (simp add: gap_Suc( (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_neither ?b ?k⟧ ⟹ gap ?i (Suc ?t) = ?k›*) 3)) with assms (*‹gap (i::nat) (Suc (t::nat)) ≠ gap i t›*) show False by simp qed then show "gap i (Suc t) = e_length (block i t)" using gap_Suc(1) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) gap_Suc(2) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) by blast qed text ‹Next up is the definition of $\tau$. In every iteration the process determines $\tau_i(x)$ for some $x$ either by appending 0 to the current block $b$, or by filling the current gap $k$. In the former case, the value is determined for $x = |b|$, in the latter for $x = k$.› text ‹For $i$ and $x$ the function @{term r_dettime} computes in which iteration the process for $i$ determines the value $\tau_i(x)$. This is the first iteration in which the block is long enough to contain position $x$ and in which $x$ is not the gap. If $\tau_i(x)$ is never determined, because Case~2 is reached with $k = x$, then @{term r_dettime} diverges.› abbreviation determined :: "nat ⇒ nat ⇒ bool" where "determined i x ≡ ∃t. x < e_length (block i t) ∧ x ≠ gap i t" lemma determined_0: "determined i 0" using gap_gr0[of i 0] (*‹0 < gap i 0›*) gap_in_block[of i 0] (*‹gap i 0 < e_length (block i 0)›*) by force definition "r_dettime ≡ Mn 2 (Cn 3 r_and [Cn 3 r_less [Id 3 2, Cn 3 r_length [Cn 3 r_pdec1 [Cn 3 r_state [Id 3 0, Id 3 1]]]], Cn 3 r_neq [Id 3 2, Cn 3 r_pdec2 [Cn 3 r_state [Id 3 0, Id 3 1]]]])" lemma r_dettime_recfn: "recfn 2 r_dettime" unfolding r_dettime_def (*goal: ‹recfn 2 (Mn 2 (Cn 3 r_and [Cn 3 r_less [recf.Id 3 2, Cn 3 r_length [Cn 3 r_pdec1 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]]], Cn 3 r_neq [recf.Id 3 2, Cn 3 r_pdec2 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]]]))›*) using r_state_recfn (*‹recfn 2 r_state›*) by simp abbreviation dettime :: partial2 where "dettime i x ≡ eval r_dettime [i, x]" lemma r_dettime: shows "determined i x ⟹ dettime i x ↓= (LEAST t. x < e_length (block i t) ∧ x ≠ gap i t)" and "¬ determined i x ⟹ dettime i x ↑" proof (-) (*goals: 1. ‹determined i x ⟹ dettime i x ↓= (LEAST t. x < e_length (block i t) ∧ x ≠ gap i t)› 2. ‹¬ determined i x ⟹ dettime i x ↑›*) define f where "f = (Cn 3 r_and [Cn 3 r_less [Id 3 2, Cn 3 r_length [Cn 3 r_pdec1 [Cn 3 r_state [Id 3 0, Id 3 1]]]], Cn 3 r_neq [Id 3 2, Cn 3 r_pdec2 [Cn 3 r_state [Id 3 0, Id 3 1]]]])" then have "r_dettime = Mn 2 f" unfolding f_def r_dettime_def (*goal: ‹Mn (2::nat) (Cn (3::nat) r_and [Cn (3::nat) r_less [recf.Id (3::nat) (2::nat), Cn (3::nat) r_length [Cn (3::nat) r_pdec1 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]]], Cn (3::nat) r_neq [recf.Id (3::nat) (2::nat), Cn (3::nat) r_pdec2 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]]]) = Mn (2::nat) (Cn (3::nat) r_and [Cn (3::nat) r_less [recf.Id (3::nat) (2::nat), Cn (3::nat) r_length [Cn (3::nat) r_pdec1 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]]], Cn (3::nat) r_neq [recf.Id (3::nat) (2::nat), Cn (3::nat) r_pdec2 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]]])›*) by simp have "recfn 3 f" unfolding f_def (*goal: ‹recfn 3 (Cn 3 r_and [Cn 3 r_less [recf.Id 3 2, Cn 3 r_length [Cn 3 r_pdec1 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]]], Cn 3 r_neq [recf.Id 3 2, Cn 3 r_pdec2 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]]])›*) using r_state_recfn (*‹recfn 2 r_state›*) by simp then have "total f" unfolding f_def (*goal: ‹Partial_Recursive.total (Cn 3 r_and [Cn 3 r_less [recf.Id 3 2, Cn 3 r_length [Cn 3 r_pdec1 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]]], Cn 3 r_neq [recf.Id 3 2, Cn 3 r_pdec2 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]]])›*) using Cn_total (*‹⟦∀g::recf∈set (?gs::recf list). Partial_Recursive.total g; Partial_Recursive.total (?f::recf); recfn (?n::nat) (Cn ?n ?f ?gs)⟧ ⟹ Partial_Recursive.total (Cn ?n ?f ?gs)›*) r_state_total (*‹Partial_Recursive.total r_state›*) Mn_free_imp_total (*‹⟦wellf ?f; Mn_free ?f⟧ ⟹ Partial_Recursive.total ?f›*) by simp have f: "eval f [t, i, x] ↓= (if x < e_length (block i t) ∧ x ≠ gap i t then 0 else 1)" for t proof (-) (*goal: ‹eval f [t, i, x] ↓= (if x < e_length (block i t) ∧ x ≠ gap i t then 0 else 1)›*) let ?b = "Cn 3 r_pdec1 [Cn 3 r_state [Id 3 0, Id 3 1]]" let ?k = "Cn 3 r_pdec2 [Cn 3 r_state [Id 3 0, Id 3 1]]" have "eval ?b [t, i, x] ↓= pdec1 (the (eval r_state [t, i]))" using r_state_recfn (*‹recfn (2::nat) r_state›*) r_state_total (*‹Partial_Recursive.total r_state›*) by simp then have b: "eval ?b [t, i, x] ↓= block i t" using block_def (*‹block ?i ?t ≡ pdec1 (the (eval r_state [?t, ?i]))›*) by simp have "eval ?k [t, i, x] ↓= pdec2 (the (eval r_state [t, i]))" using r_state_recfn (*‹recfn (2::nat) r_state›*) r_state_total (*‹Partial_Recursive.total r_state›*) by simp then have k: "eval ?k [t, i, x] ↓= gap i t" using gap_def (*‹gap ?i ?t ≡ pdec2 (the (eval r_state [?t, ?i]))›*) by simp have "eval (Cn 3 r_neq [Id 3 2, Cn 3 r_pdec2 [Cn 3 r_state [Id 3 0, Id 3 1]]]) [t, i, x] ↓= (if x ≠ gap i t then 0 else 1)" using b (*‹eval (Cn 3 r_pdec1 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]) [t, i, x] ↓= block i t›*) k (*‹eval (Cn 3 r_pdec2 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]) [t, i, x] ↓= gap i t›*) r_state_recfn (*‹recfn (2::nat) r_state›*) r_state_total (*‹Partial_Recursive.total r_state›*) by simp moreover have "eval (Cn 3 r_less [Id 3 2, Cn 3 r_length [Cn 3 r_pdec1 [Cn 3 r_state [Id 3 0, Id 3 1]]]]) [t, i, x] ↓= (if x < e_length (block i t) then 0 else 1)" using b (*‹eval (Cn 3 r_pdec1 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]) [t, i, x] ↓= block i t›*) k (*‹eval (Cn 3 r_pdec2 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]) [t, i, x] ↓= gap i t›*) r_state_recfn (*‹recfn 2 r_state›*) r_state_total (*‹Partial_Recursive.total r_state›*) by simp ultimately show "?thesis" (*goal: ‹eval (f::recf) [t::nat, i::nat, x::nat] ↓= (if x < e_length (block i t) ∧ x ≠ gap i t then 0::nat else (1::nat))›*) unfolding f_def (*goal: ‹eval (Cn (3::nat) r_and [Cn (3::nat) r_less [recf.Id (3::nat) (2::nat), Cn (3::nat) r_length [Cn (3::nat) r_pdec1 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]]], Cn (3::nat) r_neq [recf.Id (3::nat) (2::nat), Cn (3::nat) r_pdec2 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]]]) [t::nat, i::nat, x::nat] ↓= (if x < e_length (block i t) ∧ x ≠ gap i t then 0::nat else (1::nat))›*) using b (*‹eval (Cn 3 r_pdec1 [Cn 3 r_state [recf.Id 3 0, recf.Id 3 1]]) [t, i, x] ↓= block i t›*) k (*‹eval (Cn (3::nat) r_pdec2 [Cn (3::nat) r_state [recf.Id (3::nat) (0::nat), recf.Id (3::nat) (1::nat)]]) [t::nat, i::nat, x::nat] ↓= gap i t›*) r_state_recfn (*‹recfn (2::nat) r_state›*) r_state_total (*‹Partial_Recursive.total r_state›*) by simp qed { assume "determined i x" (*‹determined (i::nat) (x::nat)›*) with f (*‹eval f [?t, i, x] ↓= (if x < e_length (block i ?t) ∧ x ≠ gap i ?t then 0 else 1)›*) have "∃t. eval f [t, i, x] ↓= 0" by simp then have "dettime i x ↓= (LEAST t. eval f [t, i, x] ↓= 0)" using ‹total f› (*‹Partial_Recursive.total f›*) ‹r_dettime = Mn 2 f› (*‹r_dettime = Mn 2 f›*) r_dettime_recfn (*‹recfn 2 r_dettime›*) ‹recfn 3 f› (*‹recfn 3 f›*) eval_Mn_total[of 2 f "[i, x]"] (*‹⟦recfn (length [i, x]) (Mn 2 f); Partial_Recursive.total f⟧ ⟹ eval (Mn 2 f) [i, x] = (if ∃z. eval f [z, i, x] ↓= 0 then Some (LEAST z. eval f [z, i, x] ↓= 0) else None)›*) by simp then show "dettime i x ↓= (LEAST t. x < e_length (block i t) ∧ x ≠ gap i t)" using f (*‹eval f [?t, i, x] ↓= (if x < e_length (block i ?t) ∧ x ≠ gap i ?t then 0 else 1)›*) by simp next (*goal: ‹¬ determined i x ⟹ dettime i x ↑›*) assume "¬ determined i x" (*‹¬ determined (i::nat) (x::nat)›*) with f (*‹eval f [?t, i, x] ↓= (if x < e_length (block i ?t) ∧ x ≠ gap i ?t then 0 else 1)›*) have "¬ (∃t. eval f [t, i, x] ↓= 0)" by simp then have "dettime i x ↑" using ‹total f› (*‹Partial_Recursive.total f›*) ‹r_dettime = Mn 2 f› (*‹r_dettime = Mn 2 f›*) r_dettime_recfn (*‹recfn 2 r_dettime›*) ‹recfn 3 f› (*‹recfn 3 f›*) eval_Mn_total[of 2 f "[i, x]"] (*‹⟦recfn (length [i, x]) (Mn 2 f); Partial_Recursive.total f⟧ ⟹ eval (Mn 2 f) [i, x] = (if ∃z. eval f [z, i, x] ↓= 0 then Some (LEAST z. eval f [z, i, x] ↓= 0) else None)›*) by simp with f (*‹eval f [?t, i, x] ↓= (if x < e_length (block i ?t) ∧ x ≠ gap i ?t then 0 else 1)›*) show "dettime i x ↑" by simp } qed lemma r_dettimeI: assumes "x < e_length (block i t) ∧ x ≠ gap i t" and "⋀T. x < e_length (block i T) ∧ x ≠ gap i T ⟹ t ≤ T" shows "dettime i x ↓= t" proof (-) (*goal: ‹dettime i x ↓= t›*) let ?P = "λT. x < e_length (block i T) ∧ x ≠ gap i T" have "determined i x" using assms(1) (*‹x < e_length (block i t) ∧ x ≠ gap i t›*) by auto moreover have "Least ?P = t" using assms (*‹x < e_length (block i t) ∧ x ≠ gap i t› ‹x < e_length (block i ?T) ∧ x ≠ gap i ?T ⟹ t ≤ ?T›*) Least_equality[of ?P t] (*‹⟦x < e_length (block i t) ∧ x ≠ gap i t; ⋀y. x < e_length (block i y) ∧ x ≠ gap i y ⟹ t ≤ y⟧ ⟹ (LEAST T. x < e_length (block i T) ∧ x ≠ gap i T) = t›*) by simp ultimately show "?thesis" (*goal: ‹dettime i x ↓= t›*) using r_dettime (*‹determined ?i ?x ⟹ dettime ?i ?x ↓= (LEAST t. ?x < e_length (block ?i t) ∧ ?x ≠ gap ?i t)› ‹¬ determined ?i ?x ⟹ dettime ?i ?x ↑›*) by simp qed lemma r_dettime_0: "dettime i 0 ↓= 0" using r_dettimeI[of _ i 0] (*‹⟦?x < e_length (block i 0) ∧ ?x ≠ gap i 0; ⋀T. ?x < e_length (block i T) ∧ ?x ≠ gap i T ⟹ 0 ≤ T⟧ ⟹ dettime i ?x ↓= 0›*) determined_0 (*‹determined ?i 0›*) gap_gr0[of i 0] (*‹(0::nat) < gap (i::nat) (0::nat)›*) gap_in_block[of i 0] (*‹gap (i::nat) (0::nat) < e_length (block i (0::nat))›*) by fastforce text ‹Computing the value of $\tau_i(x)$ works by running the process @{term r_state} for @{term "dettime i x"} iterations and taking the value at index $x$ of the resulting block.› definition "r_tau ≡ Cn 2 r_nth [Cn 2 r_pdec1 [Cn 2 r_state [r_dettime, Id 2 0]], Id 2 1]" lemma r_tau_recfn: "recfn 2 r_tau" unfolding r_tau_def (*goal: ‹recfn 2 (Cn 2 r_nth [Cn 2 r_pdec1 [Cn 2 r_state [r_dettime, recf.Id 2 0]], recf.Id 2 1])›*) using r_dettime_recfn (*‹recfn 2 r_dettime›*) r_state_recfn (*‹recfn 2 r_state›*) by simp abbreviation tau :: partial2 ("τ") where "τ i x ≡ eval r_tau [i, x]" lemma tau_in_P2: "τ ∈ 𝒫²" using r_tau_recfn (*‹recfn 2 r_tau›*) by auto lemma tau_diverg: assumes "¬ determined i x" shows "τ i x ↑" unfolding r_tau_def (*goal: ‹eval (Cn 2 r_nth [Cn 2 r_pdec1 [Cn 2 r_state [r_dettime, recf.Id 2 0]], recf.Id 2 1]) [i, x] ↑›*) using assms (*‹¬ determined (i::nat) (x::nat)›*) r_dettime (*‹determined ?i ?x ⟹ dettime ?i ?x ↓= (LEAST t. ?x < e_length (block ?i t) ∧ ?x ≠ gap ?i t)› ‹¬ determined ?i ?x ⟹ dettime ?i ?x ↑›*) r_dettime_recfn (*‹recfn 2 r_dettime›*) r_state_recfn (*‹recfn (2::nat) r_state›*) by simp lemma tau_converg: assumes "determined i x" shows "τ i x ↓= e_nth (block i (the (dettime i x))) x" proof (-) (*goal: ‹τ i x ↓= e_nth (block i (the (dettime i x))) x›*) from assms (*‹determined i x›*) obtain t where t: "dettime i x ↓= t" (*goal: ‹(⋀t. dettime i x ↓= t ⟹ thesis) ⟹ thesis›*) using r_dettime(1) (*‹determined ?i ?x ⟹ dettime ?i ?x ↓= (LEAST t. ?x < e_length (block ?i t) ∧ ?x ≠ gap ?i t)›*) by blast then have "eval (Cn 2 r_state [r_dettime, Id 2 0]) [i, x] = eval r_state [t, i]" using r_state_recfn (*‹recfn 2 r_state›*) r_dettime_recfn (*‹recfn (2::nat) r_dettime›*) by simp moreover have "eval r_state [t, i] ↓" using r_state_total (*‹Partial_Recursive.total r_state›*) r_state_recfn (*‹recfn 2 r_state›*) by simp ultimately have "eval (Cn 2 r_pdec1 [Cn 2 r_state [r_dettime, Id 2 0]]) [i, x] = eval r_pdec1 [the (eval r_state [t, i])]" using r_state_recfn (*‹recfn 2 r_state›*) r_dettime_recfn (*‹recfn 2 r_dettime›*) by simp then show "?thesis" (*goal: ‹τ i x ↓= e_nth (block i (the (dettime i x))) x›*) unfolding r_tau_def (*goal: ‹eval (Cn 2 r_nth [Cn 2 r_pdec1 [Cn 2 r_state [r_dettime, recf.Id 2 0]], recf.Id 2 1]) [i, x] ↓= e_nth (block i (the (dettime i x))) x›*) using r_state_recfn (*‹recfn 2 r_state›*) r_dettime_recfn (*‹recfn 2 r_dettime›*) t (*‹dettime i x ↓= t›*) block_def (*‹block ?i ?t ≡ pdec1 (the (eval r_state [?t, ?i]))›*) by simp qed lemma tau_converg': assumes "dettime i x ↓= t" shows "τ i x ↓= e_nth (block i t) x" using assms (*‹dettime i x ↓= t›*) tau_converg[of x i] (*‹determined i x ⟹ τ i x ↓= e_nth (block i (the (dettime i x))) x›*) r_dettime(2)[of x i] (*‹¬ determined (i::nat) (x::nat) ⟹ dettime i x ↑›*) by fastforce lemma tau_at_0: "τ i 0 ↓= i" proof (-) (*goal: ‹τ i 0 ↓= i›*) have "τ i 0 ↓= e_nth (block i 0) 0" using tau_converg'[OF r_dettime_0] (*‹τ (?i::nat) (0::nat) ↓= e_nth (block ?i (0::nat)) (0::nat)›*) by simp then show "?thesis" (*goal: ‹τ i 0 ↓= i›*) using block_def (*‹block ?i ?t ≡ pdec1 (the (eval r_state [?t, ?i]))›*) by (simp add: r_state_at_0 (*‹eval r_state [0::nat, ?i::nat] ↓= prod_encode (Partial_Recursive.list_encode [?i, 0::nat], 1::nat)›*)) qed lemma state_unchanged: assumes "gap i t - 1 ≤ y" and "y ≤ t" shows "gap i t = gap i y" proof (-) (*goal: ‹gap i t = gap i y›*) have "gap i t = gap i (gap i t - 1)" proof (induction t) (*goals: 1. ‹gap (i::nat) (0::nat) = gap i (gap i (0::nat) - (1::nat))› 2. ‹⋀t::nat. gap (i::nat) t = gap i (gap i t - (1::nat)) ⟹ gap i (Suc t) = gap i (gap i (Suc t) - (1::nat))›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹gap i 0 = gap i (gap i 0 - 1)›*) by (simp add: gap_def (*‹gap ?i ?t ≡ pdec2 (the (eval r_state [?t, ?i]))›*) r_state_at_0 (*‹eval r_state [0, ?i] ↓= prod_encode (Partial_Recursive.list_encode [?i, 0], 1)›*)) next (*goal: ‹⋀t::nat. gap (i::nat) t = gap i (gap i t - (1::nat)) ⟹ gap i (Suc t) = gap i (gap i (Suc t) - (1::nat))›*) case (Suc t) (*‹gap i t = gap i (gap i t - 1)›*) show "?case" (*goal: ‹gap (i::nat) (Suc (t::nat)) = gap i (gap i (Suc t) - (1::nat))›*) proof (cases "gap i (Suc t) = t + 2") (*goals: 1. ‹gap i (Suc t) = t + 2 ⟹ gap i (Suc t) = gap i (gap i (Suc t) - 1)› 2. ‹gap i (Suc t) ≠ t + 2 ⟹ gap i (Suc t) = gap i (gap i (Suc t) - 1)›*) case True (*‹gap i (Suc t) = t + 2›*) then show "?thesis" (*goal: ‹gap i (Suc t) = gap i (gap i (Suc t) - 1)›*) by simp next (*goal: ‹gap (i::nat) (Suc (t::nat)) ≠ t + (2::nat) ⟹ gap i (Suc t) = gap i (gap i (Suc t) - (1::nat))›*) case False (*‹gap i (Suc t) ≠ t + 2›*) then show "?thesis" (*goal: ‹gap i (Suc t) = gap i (gap i (Suc t) - 1)›*) using Suc (*‹gap i t = gap i (gap i t - 1)›*) state_change_on_either(2) (*‹gap ?i (Suc ?t) ≠ gap ?i ?t ⟹ gap ?i (Suc ?t) = e_length (block ?i ?t)›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by force qed qed moreover have "gap i (gap i t - 1) ≤ gap i y" using assms(1) (*‹gap (i::nat) (t::nat) - (1::nat) ≤ (y::nat)›*) gap_monotone (*‹(?t₁::nat) ≤ (?t₂::nat) ⟹ gap (?i::nat) ?t₁ ≤ gap ?i ?t₂›*) by simp moreover have "gap i y ≤ gap i t" using assms(2) (*‹y ≤ t›*) gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) by simp ultimately show "?thesis" (*goal: ‹gap i t = gap i y›*) by simp qed text ‹The values of the non-gap indices $x$ of every block created in the diagonalization process equal $\tau_i(x)$.› lemma tau_eq_state: assumes "j < e_length (block i t)" and "j ≠ gap i t" shows "τ i j ↓= e_nth (block i t) j" using assms (*‹(j::nat) < e_length (block (i::nat) (t::nat))› ‹j ≠ gap i t›*) proof (induction t) (*goals: 1. ‹⟦(j::nat) < e_length (block (i::nat) (0::nat)); j ≠ gap i (0::nat)⟧ ⟹ τ i j ↓= e_nth (block i (0::nat)) j› 2. ‹⋀t::nat. ⟦⟦(j::nat) < e_length (block (i::nat) t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i t) j; j < e_length (block i (Suc t)); j ≠ gap i (Suc t)⟧ ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case 0 (*‹j < e_length (block i 0)› ‹j ≠ gap i 0›*) then have "j = 0" using gap_gr0[of i 0] (*‹0 < gap i 0›*) gap_in_block[of i 0] (*‹gap i 0 < e_length (block i 0)›*) length_block[of i 0] (*‹e_length (block i 0) = Suc (Suc 0)›*) by simp then have "τ (e_hd (block i t)) j ↓= e_nth (block i (the (dettime i 0))) 0" using determined_0 (*‹determined ?i 0›*) tau_converg (*‹determined ?i ?x ⟹ τ ?i ?x ↓= e_nth (block ?i (the (dettime ?i ?x))) ?x›*) hd_block (*‹e_hd (block ?i ?t) = ?i›*) by simp then have "τ (e_hd (block i t)) j ↓= e_nth (block i 0) 0" using r_dettime_0 (*‹dettime ?i 0 ↓= 0›*) by simp then show "?case" (*goal: ‹τ i j ↓= e_nth (block i 0) j›*) using ‹j = 0› (*‹j = 0›*) r_dettime_0 (*‹dettime ?i 0 ↓= 0›*) tau_converg' (*‹dettime (?i::nat) (?x::nat) ↓= (?t::nat) ⟹ τ ?i ?x ↓= e_nth (block ?i ?t) ?x›*) by simp next (*goal: ‹⋀t::nat. ⟦⟦(j::nat) < e_length (block (i::nat) t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i t) j; j < e_length (block i (Suc t)); j ≠ gap i (Suc t)⟧ ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case (Suc t) (*‹⟦j < e_length (block i t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i t) j› ‹j < e_length (block i (Suc t))› ‹j ≠ gap i (Suc t)›*) let ?b = "block i t" let ?bb = "block i (Suc t)" let ?k = "gap i t" let ?kk = "gap i (Suc t)" show "?case" (*goal: ‹τ i j ↓= e_nth (block i (Suc t)) j›*) proof (cases "?kk = ?k") (*goals: 1. ‹gap i (Suc t) = gap i t ⟹ τ i j ↓= e_nth (block i (Suc t)) j› 2. ‹gap i (Suc t) ≠ gap i t ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case kk_eq_k: True (*‹gap i (Suc t) = gap i t›*) then have bb_b0: "?bb = e_snoc ?b 0" using state_change_on_neither (*‹gap ?i (Suc ?t) = gap ?i ?t ⟹ change_on_neither (block ?i ?t) (gap ?i ?t)› ‹gap ?i (Suc ?t) = gap ?i ?t ⟹ block ?i (Suc ?t) = e_snoc (block ?i ?t) 0›*) by simp show "τ i j ↓= e_nth ?bb j" proof (cases "j < e_length ?b") (*goals: 1. ‹(j::nat) < e_length (block (i::nat) (t::nat)) ⟹ τ i j ↓= e_nth (block i (Suc t)) j› 2. ‹¬ (j::nat) < e_length (block (i::nat) (t::nat)) ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case True (*‹j < e_length (block i t)›*) then have "e_nth ?bb j = e_nth ?b j" using bb_b0 (*‹block (i::nat) (Suc (t::nat)) = e_snoc (block i t) (0::nat)›*) by (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) moreover have "j ≠ ?k" using Suc (*‹⟦j < e_length (block i t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i t) j› ‹j < e_length (block i (Suc t))› ‹j ≠ gap i (Suc t)›*) kk_eq_k (*‹gap i (Suc t) = gap i t›*) by simp ultimately show "?thesis" (*goal: ‹τ i j ↓= e_nth (block i (Suc t)) j›*) using Suc (*‹⟦j < e_length (block i t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i t) j› ‹(j::nat) < e_length (block (i::nat) (Suc (t::nat)))› ‹(j::nat) ≠ gap (i::nat) (Suc (t::nat))›*) True (*‹j < e_length (block i t)›*) by simp next (*goal: ‹¬ (j::nat) < e_length (block (i::nat) (t::nat)) ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case False (*‹¬ j < e_length (block i t)›*) then have j: "j = e_length ?b" using Suc.prems(1) (*‹j < e_length (block i (Suc t))›*) length_block (*‹e_length (block (?i::nat) (?t::nat)) = Suc (Suc ?t)›*) by auto then have "e_nth ?bb j = 0" using bb_b0 (*‹block (i::nat) (Suc (t::nat)) = e_snoc (block i t) (0::nat)›*) by simp have "dettime i j ↓= Suc t" proof (rule r_dettimeI (*‹⟦?x < e_length (block ?i ?t) ∧ ?x ≠ gap ?i ?t; ⋀T. ?x < e_length (block ?i T) ∧ ?x ≠ gap ?i T ⟹ ?t ≤ T⟧ ⟹ dettime ?i ?x ↓= ?t›*)) (*goals: 1. ‹j < e_length (block i (Suc t)) ∧ j ≠ gap i (Suc t)› 2. ‹⋀T. j < e_length (block i T) ∧ j ≠ gap i T ⟹ Suc t ≤ T›*) show "j < e_length ?bb ∧ j ≠ ?kk" using Suc.prems(1,2) (*‹j < e_length (block i (Suc t))› ‹j ≠ gap i (Suc t)›*) by linarith show "⋀T. j < e_length (block i T) ∧ j ≠ gap i T ⟹ Suc t ≤ T" using length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) j (*‹j = e_length (block i t)›*) by simp qed with tau_converg' (*‹dettime ?i ?x ↓= ?t ⟹ τ ?i ?x ↓= e_nth (block ?i ?t) ?x›*) show "?thesis" (*goal: ‹τ i j ↓= e_nth (block i (Suc t)) j›*) by simp qed next (*goal: ‹gap i (Suc t) ≠ gap i t ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case False (*‹gap i (Suc t) ≠ gap i t›*) then have kk_lenb: "?kk = e_length ?b" using state_change_on_either (*‹gap (?i::nat) (Suc (?t::nat)) ≠ gap ?i ?t ⟹ ¬ change_on_neither (block ?i ?t) (gap ?i ?t)› ‹gap ?i (Suc ?t) ≠ gap ?i ?t ⟹ gap ?i (Suc ?t) = e_length (block ?i ?t)›*) by simp then show "?thesis" (*goal: ‹τ i j ↓= e_nth (block i (Suc t)) j›*) proof (cases "j = ?k") (*goals: 1. ‹⟦gap i (Suc t) = e_length (block i t); j = gap i t⟧ ⟹ τ i j ↓= e_nth (block i (Suc t)) j› 2. ‹⟦gap i (Suc t) = e_length (block i t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case j_eq_k: True (*‹j = gap i t›*) have "dettime i j ↓= Suc t" proof (rule r_dettimeI (*‹⟦?x < e_length (block ?i ?t) ∧ ?x ≠ gap ?i ?t; ⋀T. ?x < e_length (block ?i T) ∧ ?x ≠ gap ?i T ⟹ ?t ≤ T⟧ ⟹ dettime ?i ?x ↓= ?t›*)) (*goals: 1. ‹j < e_length (block i (Suc t)) ∧ j ≠ gap i (Suc t)› 2. ‹⋀T. j < e_length (block i T) ∧ j ≠ gap i T ⟹ Suc t ≤ T›*) show "j < e_length ?bb ∧ j ≠ ?kk" using Suc.prems(1,2) (*‹j < e_length (block i (Suc t))› ‹j ≠ gap i (Suc t)›*) by simp show "Suc t ≤ T" if "j < e_length (block i T) ∧ j ≠ gap i T" for T proof (rule ccontr (*‹(¬ (?P::bool) ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ Suc t ≤ T ⟹ False›*) assume "¬ (Suc t ≤ T)" (*‹¬ Suc (t::nat) ≤ (T::nat)›*) then have "T < Suc t" by simp then show False proof (cases "T < ?k - 1") (*goals: 1. ‹⟦T < Suc t; T < gap i t - 1⟧ ⟹ False› 2. ‹⟦T < Suc t; ¬ T < gap i t - 1⟧ ⟹ False›*) case True (*‹T < gap i t - 1›*) then have "e_length (block i T) = T + 2" using length_block (*‹e_length (block (?i::nat) (?t::nat)) = Suc (Suc ?t)›*) by simp then have "e_length (block i T) < ?k + 1" using True (*‹(T::nat) < gap (i::nat) (t::nat) - (1::nat)›*) by simp then have "e_length (block i T) ≤ ?k" by simp then have "e_length (block i T) ≤ j" using j_eq_k (*‹j = gap i t›*) by simp then show False using that (*‹(j::nat) < e_length (block (i::nat) (T::nat)) ∧ j ≠ gap i T›*) by simp next (*goal: ‹⟦T < Suc t; ¬ T < gap i t - 1⟧ ⟹ False›*) case False (*‹¬ T < gap i t - 1›*) then have "?k - 1 ≤ T" and "T ≤ t" using ‹T < Suc t› (*‹T < Suc t›*) apply - (*goals: 1. ‹⟦¬ T < gap i t - 1; T < Suc t⟧ ⟹ gap i t - 1 ≤ T› 2. ‹⟦¬ T < gap i t - 1; T < Suc t⟧ ⟹ T ≤ t› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with state_unchanged (*‹⟦gap ?i ?t - 1 ≤ ?y; ?y ≤ ?t⟧ ⟹ gap ?i ?t = gap ?i ?y›*) have "gap i t = gap i T" by blast then show False using j_eq_k (*‹j = gap i t›*) that (*‹(j::nat) < e_length (block (i::nat) (T::nat)) ∧ j ≠ gap i T›*) by simp qed qed qed then show "?thesis" (*goal: ‹τ i j ↓= e_nth (block i (Suc t)) j›*) using tau_converg' (*‹dettime ?i ?x ↓= ?t ⟹ τ ?i ?x ↓= e_nth (block ?i ?t) ?x›*) by simp next (*goal: ‹⟦gap i (Suc t) = e_length (block i t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i (Suc t)) j›*) case False (*‹j ≠ gap i t›*) then have "j < e_length ?b" using kk_lenb (*‹gap i (Suc t) = e_length (block i t)›*) Suc.prems(1,2) (*‹j < e_length (block i (Suc t))› ‹j ≠ gap i (Suc t)›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by auto then show "?thesis" (*goal: ‹τ i j ↓= e_nth (block i (Suc t)) j›*) using Suc (*‹⟦j < e_length (block i t); j ≠ gap i t⟧ ⟹ τ i j ↓= e_nth (block i t) j› ‹(j::nat) < e_length (block (i::nat) (Suc (t::nat)))› ‹j ≠ gap i (Suc t)›*) False (*‹j ≠ gap i t›*) block_stable (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ e_nth (block ?i ?t) ?j = e_nth (block ?i (Suc ?t)) ?j›*) by fastforce qed qed qed lemma tau_eq_state': assumes "j < t + 2" and " j ≠ gap i t" shows "τ i j ↓= e_nth (block i t) j" using assms (*‹j < t + 2› ‹j ≠ gap i t›*) tau_eq_state (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by simp text ‹We now consider the two cases described in the proof sketch. In Case~2 there is a gap that never gets filled, or equivalently there is a rightmost gap.› abbreviation "case_two i ≡ (∃t. ∀T. gap i T ≤ gap i t)" abbreviation "case_one i ≡ ¬ case_two i" text ‹Another characterization of Case~2 is that from some iteration on only @{term change_on_neither} holds.› lemma case_two_iff_forever_neither: "case_two i ⟷ (∃t. ∀T≥t. change_on_neither (block i T) (gap i T))" proof (standard) (*goals: 1. ‹case_two i ⟹ ∃t. ∀T≥t. change_on_neither (block i T) (gap i T)› 2. ‹∃t. ∀T≥t. change_on_neither (block i T) (gap i T) ⟹ case_two i›*) assume "∃t. ∀T≥t. change_on_neither (block i T) (gap i T)" (*‹∃t::nat. ∀T≥t. change_on_neither (block (i::nat) T) (gap i T)›*) then obtain t where t: "∀T≥t. change_on_neither (block i T) (gap i T)" (*goal: ‹(⋀t. ∀T≥t. change_on_neither (block i T) (gap i T) ⟹ thesis) ⟹ thesis›*) by auto have "(gap i T) ≤ (gap i t)" for T proof (cases "T ≤ t") (*goals: 1. ‹T ≤ t ⟹ gap i T ≤ gap i t› 2. ‹¬ T ≤ t ⟹ gap i T ≤ gap i t›*) case True (*‹(T::nat) ≤ (t::nat)›*) then show "?thesis" (*goal: ‹gap i T ≤ gap i t›*) using gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) by simp next (*goal: ‹¬ T ≤ t ⟹ gap i T ≤ gap i t›*) case False (*‹¬ T ≤ t›*) then show "?thesis" (*goal: ‹gap i T ≤ gap i t›*) proof (induction T) (*goals: 1. ‹¬ 0 ≤ t ⟹ gap i 0 ≤ gap i t› 2. ‹⋀T. ⟦¬ T ≤ t ⟹ gap i T ≤ gap i t; ¬ Suc T ≤ t⟧ ⟹ gap i (Suc T) ≤ gap i t›*) case 0 (*‹¬ (0::nat) ≤ (t::nat)›*) then show "?case" (*goal: ‹gap (i::nat) (0::nat) ≤ gap i (t::nat)›*) by simp next (*goal: ‹⋀T. ⟦¬ T ≤ t ⟹ gap i T ≤ gap i t; ¬ Suc T ≤ t⟧ ⟹ gap i (Suc T) ≤ gap i t›*) case (Suc T) (*‹¬ T ≤ t ⟹ gap i T ≤ gap i t› ‹¬ Suc T ≤ t›*) with t (*‹∀T≥t. change_on_neither (block i T) (gap i T)›*) have "change_on_neither ((block i T)) ((gap i T))" by simp then show "?case" (*goal: ‹gap i (Suc T) ≤ gap i t›*) using Suc.IH (*‹¬ T ≤ t ⟹ gap i T ≤ gap i t›*) state_change_on_either(1)[of i T] (*‹gap i (Suc T) ≠ gap i T ⟹ ¬ change_on_neither (block i T) (gap i T)›*) gap_monotone[of T t i] (*‹(T::nat) ≤ (t::nat) ⟹ gap (i::nat) T ≤ gap i t›*) by metis qed qed then show "∃t. ∀T. gap i T ≤ gap i t" by auto next (*goal: ‹case_two i ⟹ ∃t. ∀T≥t. change_on_neither (block i T) (gap i T)›*) assume "∃t. ∀T. gap i T ≤ gap i t" (*‹case_two (i::nat)›*) then obtain t where t: "∀T. gap i T ≤ gap i t" (*goal: ‹(⋀t::nat. ∀T::nat. gap (i::nat) T ≤ gap i t ⟹ thesis::bool) ⟹ thesis›*) by auto have "change_on_neither (block i T) (gap i T)" if "T≥t" for T proof (-) (*goal: ‹change_on_neither (block (i::nat) (T::nat)) (gap i T)›*) have T: "(gap i T) ≥ (gap i t)" using gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) that (*‹t ≤ T›*) by simp show "?thesis" (*goal: ‹change_on_neither (block i T) (gap i T)›*) proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ change_on_neither (block i T) (gap i T) ⟹ False›*) assume "¬ change_on_neither (block i T) (gap i T)" (*‹¬ change_on_neither (block (i::nat) (T::nat)) (gap i T)›*) then have "change_on_0 (block i T) (gap i T) ∨ change_on_1 (block i T) (gap i T)" by simp then have "gap i (Suc T) > gap i T" using gap_le_Suc[of i] (*‹gap i ?t ≤ gap i (Suc ?t)›*) state_change_on_either(2)[of i] (*‹gap i (Suc ?t) ≠ gap i ?t ⟹ gap i (Suc ?t) = e_length (block i ?t)›*) state_change_on_neither(1)[of i] (*‹gap i (Suc ?t) = gap i ?t ⟹ change_on_neither (block i ?t) (gap i ?t)›*) dual_order.strict_iff_order (*‹(?b < ?a) = (?b ≤ ?a ∧ ?a ≠ ?b)›*) by blast with T (*‹gap i t ≤ gap i T›*) have "gap i (Suc T) > gap i t" by simp with t (*‹∀T. gap i T ≤ gap i t›*) show False using not_le (*‹(¬ ?x ≤ ?y) = (?y < ?x)›*) by auto qed qed then show "∃t. ∀T≥t. change_on_neither (block i T) (gap i T)" by auto qed text ‹In Case~1, $\tau_i$ is total.› lemma case_one_tau_total: assumes "case_one i" shows "τ i x ↓" proof (cases "x = gap i x") (*goals: 1. ‹(x::nat) = gap (i::nat) x ⟹ τ i x ↓› 2. ‹(x::nat) ≠ gap (i::nat) x ⟹ τ i x ↓›*) case True (*‹x = gap i x›*) from assms (*‹case_one i›*) have "∀t. ∃T. gap i T > gap i t" using le_less_linear (*‹?x ≤ ?y ∨ ?y < ?x›*) gap_def[of i x] (*‹gap (i::nat) (x::nat) ≡ pdec2 (the (eval r_state [x, i]))›*) by blast then obtain T where T: "gap i T > gap i x" (*goal: ‹(⋀T. gap i x < gap i T ⟹ thesis) ⟹ thesis›*) by auto then have "T > x" using gap_monotone (*‹(?t₁::nat) ≤ (?t₂::nat) ⟹ gap (?i::nat) ?t₁ ≤ gap ?i ?t₂›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) le_less_linear (*‹?x ≤ ?y ∨ ?y < ?x›*) by blast then have "x < T + 2" by simp moreover from T (*‹gap i x < gap i T›*) True (*‹x = gap i x›*) have "x ≠ gap i T" by simp ultimately show "?thesis" (*goal: ‹τ i x ↓›*) using tau_eq_state' (*‹⟦?j < ?t + 2; ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by simp next (*goal: ‹x ≠ gap i x ⟹ τ i x ↓›*) case False (*‹x ≠ gap i x›*) moreover have "x < x + 2" by simp ultimately show "?thesis" (*goal: ‹τ i x ↓›*) using tau_eq_state' (*‹⟦?j < ?t + 2; ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by blast qed text ‹In Case~2, $\tau_i$ is undefined only at the gap that never gets filled.› lemma case_two_tau_not_quite_total: assumes "∀T. gap i T ≤ gap i t" shows "τ i (gap i t) ↑" and "x ≠ gap i t ⟹ τ i x ↓" proof (-) (*goals: 1. ‹τ i (gap i t) ↑› 2. ‹x ≠ gap i t ⟹ τ i x ↓›*) let ?k = "gap i t" have "¬ determined i ?k" proof (standard) (*goal: ‹determined i (gap i t) ⟹ False›*) assume "determined i ?k" (*‹determined (i::nat) (gap i (t::nat))›*) then obtain T where T: "?k < e_length (block i T) ∧ ?k ≠ gap i T" (*goal: ‹(⋀T. gap i t < e_length (block i T) ∧ gap i t ≠ gap i T ⟹ thesis) ⟹ thesis›*) by auto with assms (*‹∀T. gap i T ≤ gap i t›*) have snd_le: "gap i T < ?k" by (simp add: dual_order.strict_iff_order (*‹((?b::?'a::order) < (?a::?'a::order)) = (?b ≤ ?a ∧ ?a ≠ ?b)›*)) then have "T < t" using gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) by (metis leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) le_less_linear (*‹?x ≤ ?y ∨ ?y < ?x›*)) from T (*‹gap i t < e_length (block i T) ∧ gap i t ≠ gap i T›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) have "?k < T + 2" by simp moreover have "?k ≠ T + 1" using T (*‹gap i t < e_length (block i T) ∧ gap i t ≠ gap i T›*) state_change_on_either(2) (*‹gap ?i (Suc ?t) ≠ gap ?i ?t ⟹ gap ?i (Suc ?t) = e_length (block ?i ?t)›*) ‹T < t› (*‹(T::nat) < (t::nat)›*) state_unchanged (*‹⟦gap ?i ?t - 1 ≤ ?y; ?y ≤ ?t⟧ ⟹ gap ?i ?t = gap ?i ?y›*) by (metis Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) add_diff_cancel_right' (*‹?a + ?b - ?b = ?a›*) le_add1 (*‹?n ≤ ?n + ?m›*) nat_neq_iff (*‹(?m ≠ ?n) = (?m < ?n ∨ ?n < ?m)›*)) ultimately have "?k ≤ T" by simp then have "gap i T = gap i ?k" using state_unchanged[of i T "?k"] (*‹⟦gap i T - 1 ≤ gap i t; gap i t ≤ T⟧ ⟹ gap i T = gap i (gap i t)›*) ‹?k < T + 2› (*‹gap i t < T + 2›*) snd_le (*‹gap i T < gap i t›*) by simp then show False by (metis diff_le_self (*‹?m - ?n ≤ ?m›*) state_unchanged (*‹⟦gap ?i ?t - 1 ≤ ?y; ?y ≤ ?t⟧ ⟹ gap ?i ?t = gap ?i ?y›*) leD (*‹?y ≤ ?x ⟹ ¬ ?x < ?y›*) nat_le_linear (*‹?m ≤ ?n ∨ ?n ≤ ?m›*) gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) snd_le (*‹gap i T < gap i t›*)) qed with tau_diverg (*‹¬ determined ?i ?x ⟹ τ ?i ?x ↑›*) show "τ i ?k ↑" by simp assume "x ≠ ?k" (*‹(x::nat) ≠ gap (i::nat) (t::nat)›*) show "τ i x ↓" proof (cases "x < t + 2") (*goals: 1. ‹x < t + 2 ⟹ τ i x ↓› 2. ‹¬ x < t + 2 ⟹ τ i x ↓›*) case True (*‹x < t + 2›*) with ‹x ≠ ?k› (*‹x ≠ gap i t›*) tau_eq_state' (*‹⟦?j < ?t + 2; ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) show "?thesis" (*goal: ‹τ i x ↓›*) by simp next (*goal: ‹¬ x < t + 2 ⟹ τ i x ↓›*) case False (*‹¬ x < t + 2›*) then have "gap i x = ?k" using assms (*‹∀T. gap i T ≤ gap i t›*) by (simp add: dual_order.antisym (*‹⟦(?b::?'a) ≤ (?a::?'a); ?a ≤ ?b⟧ ⟹ ?a = ?b›*) gap_monotone (*‹(?t₁::nat) ≤ (?t₂::nat) ⟹ gap (?i::nat) ?t₁ ≤ gap ?i ?t₂›*)) with ‹x ≠ ?k› (*‹x ≠ gap i t›*) have "x ≠ gap i x" by simp then show "?thesis" (*goal: ‹τ i x ↓›*) using tau_eq_state'[of x x] (*‹⟦x < x + 2; x ≠ gap ?i x⟧ ⟹ τ ?i x ↓= e_nth (block ?i x) x›*) by simp qed qed lemma case_two_tau_almost_total: assumes "∃t. ∀T. gap i T ≤ gap i t" (is "∃t. ?P t") shows "τ i (gap i (Least ?P)) ↑" and "x ≠ gap i (Least ?P) ⟹ τ i x ↓" proof (-) (*goals: 1. ‹τ i (gap i (LEAST t. ∀T. gap i T ≤ gap i t)) ↑› 2. ‹x ≠ gap i (LEAST t. ∀T. gap i T ≤ gap i t) ⟹ τ i x ↓›*) from assms (*‹case_two i›*) have "?P (Least ?P)" using LeastI_ex[of ?P] (*‹case_two i ⟹ ∀T. gap i T ≤ gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) by simp then show "τ i (gap i (Least ?P)) ↑" and "x ≠ gap i (Least ?P) ⟹ τ i x ↓" using case_two_tau_not_quite_total (*‹∀T. gap ?i T ≤ gap ?i ?t ⟹ τ ?i (gap ?i ?t) ↑› ‹⟦∀T::nat. gap (?i::nat) T ≤ gap ?i (?t::nat); (?x::nat) ≠ gap ?i ?t⟧ ⟹ τ ?i ?x ↓›*) apply - (*goals: 1. ‹⟦∀T. gap i T ≤ gap i (LEAST t. ∀T. gap i T ≤ gap i t); ⋀i t. ∀T. gap i T ≤ gap i t ⟹ τ i (gap i t) ↑; ⋀i t x. ⟦∀T. gap i T ≤ gap i t; x ≠ gap i t⟧ ⟹ τ i x ↓⟧ ⟹ τ i (gap i (LEAST t. ∀T. gap i T ≤ gap i t)) ↑› 2. ‹⟦x ≠ gap i (LEAST t. ∀T. gap i T ≤ gap i t); ∀T. gap i T ≤ gap i (LEAST t. ∀T. gap i T ≤ gap i t); ⋀i t. ∀T. gap i T ≤ gap i t ⟹ τ i (gap i t) ↑; ⋀i t x. ⟦∀T. gap i T ≤ gap i t; x ≠ gap i t⟧ ⟹ τ i x ↓⟧ ⟹ τ i x ↓› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . qed text ‹Some more properties of $\tau$.› lemma init_tau_gap: "(τ i) ▹ (gap i t - 1) = e_take (gap i t) (block i t)" proof (intro initI' (*‹⟦e_length ?e = Suc ?n; ⋀x. x < Suc ?n ⟹ ?f x ↓= e_nth ?e x⟧ ⟹ ?f ▹ ?n = ?e›*)) (*goals: 1. ‹e_length (e_take (gap i t) (block i t)) = Suc (gap i t - 1)› 2. ‹⋀x. x < Suc (gap i t - 1) ⟹ τ i x ↓= e_nth (e_take (gap i t) (block i t)) x›*) show 1: "e_length (e_take (gap i t) (block i t)) = Suc (gap i t - 1)" proof (-) (*goal: ‹e_length (e_take (gap i t) (block i t)) = Suc (gap i t - 1)›*) have "gap i t > 0" using gap_gr0 (*‹0 < gap ?i ?t›*) by simp moreover have "gap i t < e_length (block i t)" using gap_in_block (*‹gap ?i ?t < e_length (block ?i ?t)›*) by simp ultimately have "e_length (e_take (gap i t) (block i t)) = gap i t" by simp then show "?thesis" (*goal: ‹e_length (e_take (gap i t) (block i t)) = Suc (gap i t - 1)›*) using gap_gr0 (*‹0 < gap ?i ?t›*) by simp qed show "τ i x ↓= e_nth (e_take (gap i t) (block i t)) x" if "x < Suc (gap i t - 1)" for x proof (-) (*goal: ‹τ i x ↓= e_nth (e_take (gap i t) (block i t)) x›*) have x_le: "x < gap i t" using that (*‹x < Suc (gap i t - 1)›*) gap_gr0 (*‹0 < gap ?i ?t›*) by simp then have "x < e_length (block i t)" using gap_in_block (*‹gap ?i ?t < e_length (block ?i ?t)›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) by blast then have "*": "τ i x ↓= e_nth (block i t) x" using x_le (*‹x < gap i t›*) tau_eq_state (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by auto have "x < e_length (e_take (gap i t) (block i t))" using x_le (*‹x < gap i t›*) "1" (*‹e_length (e_take (gap i t) (block i t)) = Suc (gap i t - 1)›*) by simp then have "e_nth (block i t) x = e_nth (e_take (gap i t) (block i t)) x" using x_le (*‹x < gap i t›*) by simp then show "?thesis" (*goal: ‹τ i x ↓= e_nth (e_take (gap i t) (block i t)) x›*) using "*" (*‹τ i x ↓= e_nth (block i t) x›*) by simp qed qed lemma change_on_0_init_tau: assumes "change_on_0 (block i t) (gap i t)" shows "(τ i) ▹ (t + 1) = block i t" proof (intro initI' (*‹⟦e_length ?e = Suc ?n; ⋀x. x < Suc ?n ⟹ ?f x ↓= e_nth ?e x⟧ ⟹ ?f ▹ ?n = ?e›*)) (*goals: 1. ‹e_length (block i t) = Suc (t + 1)› 2. ‹⋀x. x < Suc (t + 1) ⟹ τ i x ↓= e_nth (block i t) x›*) let ?b = "block i t" and ?k = "gap i t" show "e_length (block i t) = Suc (t + 1)" using length_block (*‹e_length (block (?i::nat) (?t::nat)) = Suc (Suc ?t)›*) by simp show "(τ i) x ↓= e_nth (block i t) x" if "x < Suc (t + 1)" for x proof (cases "x = ?k") (*goals: 1. ‹x = gap i t ⟹ τ i x ↓= e_nth (block i t) x› 2. ‹x ≠ gap i t ⟹ τ i x ↓= e_nth (block i t) x›*) case True (*‹(x::nat) = gap (i::nat) (t::nat)›*) have "gap i (Suc t) = e_length ?b" and b: "block i (Suc t) = e_snoc ?b 0" using gap_Suc(1) (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) block_Suc(1) (*‹⟦?b = block ?i ?t; ?k = gap ?i ?t; change_on_0 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc ?b 0›*) assms (*‹change_on_0 (block i t) (gap i t)›*) apply - (*goals: 1. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ block i (Suc t) = e_snoc b 0; change_on_0 (block i t) (gap i t)⟧ ⟹ gap i (Suc t) = e_length (block i t)› 2. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_0 b k⟧ ⟹ block i (Suc t) = e_snoc b 0; change_on_0 (block i t) (gap i t)⟧ ⟹ block i (Suc t) = e_snoc (block i t) 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have "x < e_length (block i (Suc t))" "x ≠ gap i (Suc t)" using that (*‹x < Suc (t + 1)›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) apply - (*goals: 1. ‹⟦gap i (Suc t) = e_length (block i t); block i (Suc t) = e_snoc (block i t) 0; x < Suc (t + 1); ⋀i t. e_length (block i t) = Suc (Suc t)⟧ ⟹ x < e_length (block i (Suc t))› 2. ‹⟦gap i (Suc t) = e_length (block i t); block i (Suc t) = e_snoc (block i t) 0; x < Suc (t + 1); ⋀i t. e_length (block i t) = Suc (Suc t)⟧ ⟹ x ≠ gap i (Suc t)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have "τ i x ↓= e_nth (block i (Suc t)) x" using tau_eq_state (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by simp then show "?thesis" (*goal: ‹τ i x ↓= e_nth (block i t) x›*) using that (*‹x < Suc (t + 1)›*) assms (*‹change_on_0 (block i t) (gap i t)›*) b (*‹block i (Suc t) = e_snoc (block i t) 0›*) by (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) next (*goal: ‹x ≠ gap i t ⟹ τ i x ↓= e_nth (block i t) x›*) case False (*‹x ≠ gap i t›*) then show "?thesis" (*goal: ‹τ (i::nat) (x::nat) ↓= e_nth (block i (t::nat)) x›*) using that (*‹(x::nat) < Suc ((t::nat) + (1::nat))›*) assms (*‹change_on_0 (block i t) (gap i t)›*) tau_eq_state' (*‹⟦?j < ?t + 2; ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by simp qed qed lemma change_on_0_hyp_change: assumes "change_on_0 (block i t) (gap i t)" shows "σ i ((τ i) ▹ (t + 1)) ≠ σ i ((τ i) ▹ (gap i t - 1))" using assms (*‹change_on_0 (block i t) (gap i t)›*) hd_block (*‹e_hd (block ?i ?t) = ?i›*) init_tau_gap (*‹τ (?i::nat) ▹ (gap ?i (?t::nat) - (1::nat)) = e_take (gap ?i ?t) (block ?i ?t)›*) change_on_0_init_tau (*‹change_on_0 (block ?i ?t) (gap ?i ?t) ⟹ τ ?i ▹ (?t + 1) = block ?i ?t›*) by simp lemma change_on_1_init_tau: assumes "change_on_1 (block i t) (gap i t)" shows "(τ i) ▹ (t + 1) = e_update (block i t) (gap i t) 1" proof (intro initI' (*‹⟦e_length ?e = Suc ?n; ⋀x. x < Suc ?n ⟹ ?f x ↓= e_nth ?e x⟧ ⟹ ?f ▹ ?n = ?e›*)) (*goals: 1. ‹e_length (e_update (block i t) (gap i t) 1) = Suc (t + 1)› 2. ‹⋀x. x < Suc (t + 1) ⟹ τ i x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) let ?b = "block i t" and ?k = "gap i t" show "e_length (e_update ?b ?k 1) = Suc (t + 1)" using length_block (*‹e_length (block (?i::nat) (?t::nat)) = Suc (Suc ?t)›*) by simp show "(τ i) x ↓= e_nth (e_update ?b ?k 1) x" if "x < Suc (t + 1)" for x proof (cases "x = ?k") (*goals: 1. ‹x = gap i t ⟹ τ i x ↓= e_nth (e_update (block i t) (gap i t) 1) x› 2. ‹x ≠ gap i t ⟹ τ i x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) case True (*‹(x::nat) = gap (i::nat) (t::nat)›*) have "gap i (Suc t) = e_length ?b" and b: "block i (Suc t) = e_snoc (e_update ?b ?k 1) 0" using gap_Suc(2) (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ gap ?i (Suc ?t) = e_length ?b›*) block_Suc(2) (*‹⟦(?b::nat) = block (?i::nat) (?t::nat); (?k::nat) = gap ?i ?t; change_on_1 ?b ?k⟧ ⟹ block ?i (Suc ?t) = e_snoc (e_update ?b ?k (1::nat)) (0::nat)›*) assms (*‹change_on_1 (block i t) (gap i t)›*) apply - (*goals: 1. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0; change_on_1 (block i t) (gap i t)⟧ ⟹ gap i (Suc t) = e_length (block i t)› 2. ‹⟦⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ gap i (Suc t) = e_length b; ⋀b i t k. ⟦b = block i t; k = gap i t; change_on_1 b k⟧ ⟹ block i (Suc t) = e_snoc (e_update b k 1) 0; change_on_1 (block i t) (gap i t)⟧ ⟹ block i (Suc t) = e_snoc (e_update (block i t) (gap i t) 1) 0› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have "x < e_length (block i (Suc t))" "x ≠ gap i (Suc t)" using that (*‹x < Suc (t + 1)›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) apply - (*goals: 1. ‹⟦gap i (Suc t) = e_length (block i t); block i (Suc t) = e_snoc (e_update (block i t) (gap i t) 1) 0; x < Suc (t + 1); ⋀i t. e_length (block i t) = Suc (Suc t)⟧ ⟹ x < e_length (block i (Suc t))› 2. ‹⟦gap i (Suc t) = e_length (block i t); block i (Suc t) = e_snoc (e_update (block i t) (gap i t) 1) 0; x < Suc (t + 1); ⋀i t. e_length (block i t) = Suc (Suc t)⟧ ⟹ x ≠ gap i (Suc t)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have "τ i x ↓= e_nth (block i (Suc t)) x" using tau_eq_state (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by simp then show "?thesis" (*goal: ‹τ i x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) using that (*‹x < Suc (t + 1)›*) assms (*‹change_on_1 (block i t) (gap i t)›*) b (*‹block (i::nat) (Suc (t::nat)) = e_snoc (e_update (block i t) (gap i t) (1::nat)) (0::nat)›*) nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) by (simp add: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) next (*goal: ‹(x::nat) ≠ gap (i::nat) (t::nat) ⟹ τ i x ↓= e_nth (e_update (block i t) (gap i t) (1::nat)) x›*) case False (*‹x ≠ gap i t›*) then show "?thesis" (*goal: ‹τ (i::nat) (x::nat) ↓= e_nth (e_update (block i (t::nat)) (gap i t) (1::nat)) x›*) using that (*‹x < Suc (t + 1)›*) assms (*‹change_on_1 (block i t) (gap i t)›*) tau_eq_state' (*‹⟦(?j::nat) < (?t::nat) + (2::nat); ?j ≠ gap (?i::nat) ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) by simp qed qed lemma change_on_1_hyp_change: assumes "change_on_1 (block i t) (gap i t)" shows "σ i ((τ i) ▹ (t + 1)) ≠ σ i ((τ i) ▹ (gap i t - 1))" using assms (*‹change_on_1 (block (i::nat) (t::nat)) (gap i t)›*) hd_block (*‹e_hd (block ?i ?t) = ?i›*) init_tau_gap (*‹τ (?i::nat) ▹ (gap ?i (?t::nat) - (1::nat)) = e_take (gap ?i ?t) (block ?i ?t)›*) change_on_1_init_tau (*‹change_on_1 (block ?i ?t) (gap ?i ?t) ⟹ τ ?i ▹ (?t + 1) = e_update (block ?i ?t) (gap ?i ?t) 1›*) by simp lemma change_on_either_hyp_change: assumes "¬ change_on_neither (block i t) (gap i t)" shows "σ i ((τ i) ▹ (t + 1)) ≠ σ i ((τ i) ▹ (gap i t - 1))" using assms (*‹¬ change_on_neither (block i t) (gap i t)›*) change_on_0_hyp_change (*‹change_on_0 (block ?i ?t) (gap ?i ?t) ⟹ σ ?i (τ ?i ▹ (?t + 1)) ≠ σ ?i (τ ?i ▹ (gap ?i ?t - 1))›*) change_on_1_hyp_change (*‹change_on_1 (block (?i::nat) (?t::nat)) (gap ?i ?t) ⟹ σ ?i (τ ?i ▹ (?t + (1::nat))) ≠ σ ?i (τ ?i ▹ (gap ?i ?t - (1::nat)))›*) by auto lemma filled_gap_0_init_tau: assumes "f₀ = (τ i)((gap i t):=Some 0)" shows "f₀ ▹ (t + 1) = block i t" proof (intro initI' (*‹⟦e_length ?e = Suc ?n; ⋀x. x < Suc ?n ⟹ ?f x ↓= e_nth ?e x⟧ ⟹ ?f ▹ ?n = ?e›*)) (*goals: 1. ‹e_length (block i t) = Suc (t + 1)› 2. ‹⋀x. x < Suc (t + 1) ⟹ f₀ x ↓= e_nth (block i t) x›*) show len: "e_length (block i t) = Suc (t + 1)" using assms (*‹f₀ = (τ i)(gap i t ↦ 0)›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by auto show "f₀ x ↓= e_nth (block i t) x" if "x < Suc (t + 1)" for x proof (cases "x = gap i t") (*goals: 1. ‹x = gap i t ⟹ f₀ x ↓= e_nth (block i t) x› 2. ‹x ≠ gap i t ⟹ f₀ x ↓= e_nth (block i t) x›*) case True (*‹x = gap i t›*) then show "?thesis" (*goal: ‹(f₀::nat ⇒ nat option) (x::nat) ↓= e_nth (block (i::nat) (t::nat)) x›*) using assms (*‹(f₀::nat ⇒ nat option) = (τ (i::nat))(gap i (t::nat) ↦ 0::nat)›*) last_block (*‹e_nth (block ?i ?t) (gap ?i ?t) = 0›*) by auto next (*goal: ‹x ≠ gap i t ⟹ f₀ x ↓= e_nth (block i t) x›*) case False (*‹x ≠ gap i t›*) then show "?thesis" (*goal: ‹f₀ x ↓= e_nth (block i t) x›*) using assms (*‹f₀ = (τ i)(gap i t ↦ 0)›*) len (*‹e_length (block i t) = Suc (t + 1)›*) tau_eq_state (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) that (*‹x < Suc (t + 1)›*) by auto qed qed lemma filled_gap_1_init_tau: assumes "f₁ = (τ i)((gap i t):=Some 1)" shows "f₁ ▹ (t + 1) = e_update (block i t) (gap i t) 1" proof (intro initI' (*‹⟦e_length ?e = Suc ?n; ⋀x. x < Suc ?n ⟹ ?f x ↓= e_nth ?e x⟧ ⟹ ?f ▹ ?n = ?e›*)) (*goals: 1. ‹e_length (e_update (block i t) (gap i t) 1) = Suc (t + 1)› 2. ‹⋀x. x < Suc (t + 1) ⟹ f₁ x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) show len: "e_length (e_update (block i t) (gap i t) 1) = Suc (t + 1)" using e_length_update (*‹e_length (e_update ?b ?k ?v) = e_length ?b›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by simp show "f₁ x ↓= e_nth (e_update (block i t) (gap i t) 1) x" if "x < Suc (t + 1)" for x proof (cases "x = gap i t") (*goals: 1. ‹(x::nat) = gap (i::nat) (t::nat) ⟹ (f₁::nat ⇒ nat option) x ↓= e_nth (e_update (block i t) (gap i t) (1::nat)) x› 2. ‹(x::nat) ≠ gap (i::nat) (t::nat) ⟹ (f₁::nat ⇒ nat option) x ↓= e_nth (e_update (block i t) (gap i t) (1::nat)) x›*) case True (*‹x = gap i t›*) moreover have "gap i t < e_length (block i t)" using gap_in_block (*‹gap ?i ?t < e_length (block ?i ?t)›*) by simp ultimately show "?thesis" (*goal: ‹f₁ x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) using assms (*‹f₁ = (τ i)(gap i t ↦ 1)›*) by simp next (*goal: ‹x ≠ gap i t ⟹ f₁ x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) case False (*‹(x::nat) ≠ gap (i::nat) (t::nat)›*) then show "?thesis" (*goal: ‹f₁ x ↓= e_nth (e_update (block i t) (gap i t) 1) x›*) using assms (*‹(f₁::nat ⇒ nat option) = (τ (i::nat))(gap i (t::nat) ↦ 1::nat)›*) len (*‹e_length (e_update (block i t) (gap i t) 1) = Suc (t + 1)›*) tau_eq_state (*‹⟦?j < e_length (block ?i ?t); ?j ≠ gap ?i ?t⟧ ⟹ τ ?i ?j ↓= e_nth (block ?i ?t) ?j›*) that (*‹x < Suc (t + 1)›*) by auto qed qed subsection ‹The separating class› text ‹Next we define the sets $V_i$ from the introductory proof sketch (page~\pageref{s:lim_bc}).› definition V_bclim :: "nat ⇒ partial1 set" where "V_bclim i ≡ if case_two i then let k = gap i (LEAST t. ∀T. gap i T ≤ gap i t) in {(τ i)(k:=Some 0), (τ i)(k:=Some 1)} else {τ i}" lemma V_subseteq_R1: "V_bclim i ⊆ ℛ" sorry lemma case_one_imp_gap_unbounded: assumes "case_one i" shows "∃t. gap i t - 1 > n" proof (induction n) (*goals: 1. ‹∃t. 0 < gap i t - 1› 2. ‹⋀n. ∃t. n < gap i t - 1 ⟹ ∃t. Suc n < gap i t - 1›*) case 0 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃t. 0 < gap i t - 1›*) using assms (*‹case_one i›*) gap_gr0[of i] (*‹0 < gap i ?t›*) state_at_0(2)[of i] (*‹gap i 0 = 1›*) by (metis diff_is_0_eq (*‹((?m::nat) - (?n::nat) = (0::nat)) = (?m ≤ ?n)›*) gr_zeroI (*‹((?n::?'a::canonically_ordered_monoid_add) = (0::?'a::canonically_ordered_monoid_add) ⟹ False) ⟹ (0::?'a::canonically_ordered_monoid_add) < ?n›*)) next (*goal: ‹⋀n::nat. ∃t::nat. n < gap (i::nat) t - (1::nat) ⟹ ∃t::nat. Suc n < gap i t - (1::nat)›*) case (Suc n) (*‹∃t. n < gap i t - 1›*) then obtain t where t: "gap i t - 1 > n" (*goal: ‹(⋀t::nat. (n::nat) < gap (i::nat) t - (1::nat) ⟹ thesis::bool) ⟹ thesis›*) by auto moreover from assms (*‹case_one i›*) have "∀t. ∃T. gap i T > gap i t" using leI (*‹¬ ?x < ?y ⟹ ?y ≤ ?x›*) by blast ultimately obtain T where "gap i T > gap i t" (*goal: ‹(⋀T. gap i t < gap i T ⟹ thesis) ⟹ thesis›*) by auto then have "gap i T - 1 > gap i t - 1" using gap_gr0[of i] (*‹(0::nat) < gap (i::nat) (?t::nat)›*) by (simp add: Suc_le_eq (*‹(Suc ?m ≤ ?n) = (?m < ?n)›*) diff_less_mono (*‹⟦?a < ?b; ?c ≤ ?a⟧ ⟹ ?a - ?c < ?b - ?c›*)) with t (*‹(n::nat) < gap (i::nat) (t::nat) - (1::nat)›*) have "gap i T - 1 > Suc n" by simp then show "?case" (*goal: ‹∃t::nat. Suc (n::nat) < gap (i::nat) t - (1::nat)›*) by auto qed lemma case_one_imp_not_learn_lim_V: assumes "case_one i" shows "¬ learn_lim φ (V_bclim i) (σ i)" proof (-) (*goal: ‹¬ learn_lim φ (V_bclim i) (σ i)›*) have V_bclim: "V_bclim i = {τ i}" using assms (*‹case_one i›*) V_bclim_def (*‹V_bclim ?i ≡ if case_two ?i then let k = gap ?i (LEAST t. ∀T. gap ?i T ≤ gap ?i t) in {(τ ?i)(k ↦ 0), (τ ?i)(k ↦ 1)} else {τ ?i}›*) by (auto simp add: Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*)) have "∃m₁>n. ∃m₂>n. (σ i) ((τ i) ▹ m₁) ≠ (σ i) ((τ i) ▹ m₂)" for n proof (-) (*goal: ‹∃m₁>n. ∃m₂>n. σ i (τ i ▹ m₁) ≠ σ i (τ i ▹ m₂)›*) obtain t where t: "gap i t - 1 > n" (*goal: ‹(⋀t. n < gap i t - 1 ⟹ thesis) ⟹ thesis›*) using case_one_imp_gap_unbounded[OF assms] (*‹∃t::nat. (?n::nat) < gap (i::nat) t - (1::nat)›*) by auto moreover have "∀t. ∃T≥t. ¬ change_on_neither (block i T) (gap i T)" using assms (*‹case_one i›*) case_two_iff_forever_neither (*‹case_two ?i = (∃t. ∀T≥t. change_on_neither (block ?i T) (gap ?i T))›*) by blast ultimately obtain T where T: "T ≥ t" "¬ change_on_neither (block i T) (gap i T)" (*goal: ‹(⋀T. ⟦t ≤ T; ¬ change_on_neither (block i T) (gap i T)⟧ ⟹ thesis) ⟹ thesis›*) by auto then have "(σ i) ((τ i) ▹ (T + 1)) ≠ (σ i) ((τ i) ▹ (gap i T - 1))" using change_on_either_hyp_change (*‹¬ change_on_neither (block ?i ?t) (gap ?i ?t) ⟹ σ ?i (τ ?i ▹ (?t + 1)) ≠ σ ?i (τ ?i ▹ (gap ?i ?t - 1))›*) by simp moreover have "gap i T - 1 > n" using t (*‹n < gap i t - 1›*) T(1) (*‹t ≤ T›*) gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) by (simp add: diff_le_mono (*‹?m ≤ ?n ⟹ ?m - ?l ≤ ?n - ?l›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*)) moreover have "T + 1 > n" proof (-) (*goal: ‹n < T + 1›*) have "gap i T - 1 ≤ T" using gap_in_block (*‹gap (?i::nat) (?t::nat) < e_length (block ?i ?t)›*) length_block (*‹e_length (block ?i ?t) = Suc (Suc ?t)›*) by (simp add: le_diff_conv (*‹(?j - ?k ≤ ?i) = (?j ≤ ?i + ?k)›*) less_Suc_eq_le (*‹(?m < Suc ?n) = (?m ≤ ?n)›*)) then show "?thesis" (*goal: ‹n < T + 1›*) using ‹gap i T - 1 > n› (*‹(n::nat) < gap (i::nat) (T::nat) - (1::nat)›*) by simp qed ultimately show "?thesis" (*goal: ‹∃m₁>n. ∃m₂>n. σ i (τ i ▹ m₁) ≠ σ i (τ i ▹ m₂)›*) by auto qed with infinite_hyp_changes_not_Lim (*‹⟦(?f::nat ⇒ nat option) ∈ (?U::(nat ⇒ nat option) set); ∀n::nat. ∃m₁>n. ∃m₂>n. (?s::nat ⇒ nat option) (?f ▹ m₁) ≠ ?s (?f ▹ m₂)⟧ ⟹ ¬ learn_lim (?ψ::nat ⇒ nat ⇒ nat option) ?U ?s›*) V_bclim (*‹V_bclim i = {τ i}›*) show "?thesis" (*goal: ‹¬ learn_lim φ (V_bclim i) (σ i)›*) by simp qed lemma case_two_imp_not_learn_lim_V: assumes "case_two i" shows "¬ learn_lim φ (V_bclim i) (σ i)" proof (-) (*goal: ‹¬ learn_lim φ (V_bclim i) (σ i)›*) let ?P = "λt. ∀T. (gap i T) ≤ (gap i t)" let ?t = "LEAST t. ?P t" let ?k = "gap i ?t" let ?b = "e_take ?k (block i ?t)" have t: "∀T. gap i T ≤ gap i ?t" using assms (*‹case_two i›*) LeastI_ex[of ?P] (*‹case_two (i::nat) ⟹ ∀T::nat. gap i T ≤ gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t)›*) by simp then have neither: "∀T≥?t. change_on_neither (block i T) (gap i T)" using gap_le_Suc (*‹gap ?i ?t ≤ gap ?i (Suc ?t)›*) gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) state_change_on_neither(1) (*‹gap ?i (Suc ?t) = gap ?i ?t ⟹ change_on_neither (block ?i ?t) (gap ?i ?t)›*) by (metis (no_types, lifting) antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) have gap_T: "∀T≥?t. gap i T = ?k" using t (*‹∀T. gap i T ≤ gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) gap_monotone (*‹?t₁ ≤ ?t₂ ⟹ gap ?i ?t₁ ≤ gap ?i ?t₂›*) antisym_conv (*‹(?y::?'a) ≤ (?x::?'a) ⟹ (?x ≤ ?y) = (?x = ?y)›*) by blast define f₀ where "f₀ = (τ i)(?k:=Some 0)" define f₁ where "f₁ = (τ i)(?k:=Some 1)" show "?thesis" (*goal: ‹¬ learn_lim φ (V_bclim i) (σ i)›*) proof (rule same_hyp_for_two_not_Lim (*‹⟦?f₁ ∈ ?U; ?f₂ ∈ ?U; ?f₁ ≠ ?f₂; ∀n≥?n₁. ?s (?f₁ ▹ n) = ?h; ∀n≥?n₂. ?s (?f₂ ▹ n) = ?h⟧ ⟹ ¬ learn_lim ?ψ ?U ?s›*)) (*goals: 1. ‹?f₁ ∈ V_bclim i› 2. ‹?f₂ ∈ V_bclim i› 3. ‹?f₁ ≠ ?f₂› 4. ‹∀n≥?n₁. σ i (?f₁ ▹ n) = ?h› 5. ‹∀n≥?n₂. σ i (?f₂ ▹ n) = ?h›*) show "f₀ ∈ V_bclim i" and "f₁ ∈ V_bclim i" using assms (*‹case_two (i::nat)›*) V_bclim_def (*‹V_bclim (?i::nat) ≡ if case_two ?i then let k::nat = gap ?i (LEAST t::nat. ∀T::nat. gap ?i T ≤ gap ?i t) in {(τ ?i)(k ↦ 0::nat), (τ ?i)(k ↦ 1::nat)} else {τ ?i}›*) "f₀_def" (*‹f₀ = (τ i)(gap i (LEAST t. ∀T. gap i T ≤ gap i t) ↦ 0)›*) "f₁_def" (*‹f₁ = (τ i)(gap i (LEAST t. ∀T. gap i T ≤ gap i t) ↦ 1)›*) apply - (*goals: 1. ‹⟦case_two (i::nat); ⋀i::nat. V_bclim i ≡ if case_two i then let k::nat = gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t) in {(τ i)(k ↦ 0::nat), (τ i)(k ↦ 1::nat)} else {τ i}; (f₀::nat ⇒ nat option) = (τ i)(gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t) ↦ 0::nat); (f₁::nat ⇒ nat option) = (τ i)(gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t) ↦ 1::nat)⟧ ⟹ f₀ ∈ V_bclim i› 2. ‹⟦case_two (i::nat); ⋀i::nat. V_bclim i ≡ if case_two i then let k::nat = gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t) in {(τ i)(k ↦ 0::nat), (τ i)(k ↦ 1::nat)} else {τ i}; (f₀::nat ⇒ nat option) = (τ i)(gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t) ↦ 0::nat); (f₁::nat ⇒ nat option) = (τ i)(gap i (LEAST t::nat. ∀T::nat. gap i T ≤ gap i t) ↦ 1::nat)⟧ ⟹ f₁ ∈ V_bclim i› discuss goal 1*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*discuss goal 2*) apply (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) (*proven 2 subgoals*) . show "f₀ ≠ f₁" using "f₀_def" (*‹f₀ = (τ i)(gap i (LEAST t. ∀T. gap i T ≤ gap i t) ↦ 0)›*) "f₁_def" (*‹f₁ = (τ i)(gap i (LEAST t. ∀T. gap i T ≤ gap i t) ↦ 1)›*) by (meson map_upd_eqD1 (*‹?m(?a ↦ ?x) = ?n(?a ↦ ?y) ⟹ ?x = ?y›*) zero_neq_one (*‹0 ≠ 1›*)) show "∀n≥Suc ?t. σ i (f₀ ▹ n) = σ i ?b" proof (-) (*goal: ‹∀n≥Suc (LEAST t. ∀T. gap i T ≤ gap i t). σ i (f₀ ▹ n) = σ i (e_take (gap i (LEAST t. ∀T. gap i T ≤ gap i t)) (block i (LEAST t. ∀T. gap i T ≤ gap i t)))›*) have "σ i (block i T) = σ i (e_take ?k (block i T))" if "T ≥ ?t" for T using that (*‹(LEAST t. ∀T. gap i T ≤ gap i t) ≤ T›*) gap_T (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. gap i T = gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) neither (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. change_on_neither (block i T) (gap i T)›*) hd_block (*‹e_hd (block ?i ?t) = ?i›*) by metis then have "σ i (block i T) = σ i ?b" if "T ≥ ?t" for T by (metis (no_types, lifting) init_tau_gap (*‹τ ?i ▹ (gap ?i ?t - 1) = e_take (gap ?i ?t) (block ?i ?t)›*) gap_T (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. gap i T = gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) that (*‹(LEAST t. ∀T. gap i T ≤ gap i t) ≤ T›*)) then have "σ i (f₀ ▹ (T + 1)) = σ i ?b" if "T ≥ ?t" for T using filled_gap_0_init_tau[of f₀ i T] (*‹f₀ = (τ i)(gap i T ↦ 0) ⟹ f₀ ▹ (T + 1) = block i T›*) "f₀_def" (*‹f₀ = (τ i)(gap i (LEAST t. ∀T. gap i T ≤ gap i t) ↦ 0)›*) gap_T (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. gap i T = gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) that (*‹(LEAST t. ∀T. gap i T ≤ gap i t) ≤ T›*) by (metis (no_types, lifting)) then have "σ i (f₀ ▹ T) = σ i ?b" if "T ≥ Suc ?t" for T using that (*‹Suc (LEAST t::nat. ∀T::nat. gap (i::nat) T ≤ gap i t) ≤ (T::nat)›*) by (metis (no_types, lifting) Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) Suc_le_D (*‹Suc ?n ≤ ?m' ⟹ ∃m. ?m' = Suc m›*) Suc_le_mono (*‹(Suc ?n ≤ Suc ?m) = (?n ≤ ?m)›*)) then show "?thesis" (*goal: ‹∀n≥Suc (LEAST t. ∀T. gap i T ≤ gap i t). σ i (f₀ ▹ n) = σ i (e_take (gap i (LEAST t. ∀T. gap i T ≤ gap i t)) (block i (LEAST t. ∀T. gap i T ≤ gap i t)))›*) by simp qed show "∀n≥Suc ?t. σ i (f₁ ▹ n) = σ i ?b" proof (-) (*goal: ‹∀n≥Suc (LEAST t. ∀T. gap i T ≤ gap i t). σ i (f₁ ▹ n) = σ i (e_take (gap i (LEAST t. ∀T. gap i T ≤ gap i t)) (block i (LEAST t. ∀T. gap i T ≤ gap i t)))›*) have "σ i (e_update (block i T) ?k 1) = σ i (e_take ?k (block i T))" if "T ≥ ?t" for T using neither (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. change_on_neither (block i T) (gap i T)›*) by (metis (no_types, lifting) hd_block (*‹e_hd (block ?i ?t) = ?i›*) gap_T (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. gap i T = gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) that (*‹(LEAST t. ∀T. gap i T ≤ gap i t) ≤ T›*)) then have "σ i (e_update (block i T) ?k 1) = σ i ?b" if "T ≥ ?t" for T using that (*‹(LEAST t. ∀T. gap i T ≤ gap i t) ≤ T›*) init_tau_gap[of i] (*‹τ i ▹ (gap i ?t - 1) = e_take (gap i ?t) (block i ?t)›*) gap_T (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. gap i T = gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) by (metis (no_types, lifting)) then have "σ i (f₁ ▹ (T + 1)) = σ i ?b" if "T ≥ ?t" for T using filled_gap_1_init_tau[of f₁ i T] (*‹f₁ = (τ i)(gap i T ↦ 1) ⟹ f₁ ▹ (T + 1) = e_update (block i T) (gap i T) 1›*) "f₁_def" (*‹f₁ = (τ i)(gap i (LEAST t. ∀T. gap i T ≤ gap i t) ↦ 1)›*) gap_T (*‹∀T≥LEAST t. ∀T. gap i T ≤ gap i t. gap i T = gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) that (*‹(LEAST t. ∀T. gap i T ≤ gap i t) ≤ T›*) by (metis (no_types, lifting)) then have "σ i (f₁ ▹ T) = σ i ?b" if "T ≥ Suc ?t" for T using that (*‹Suc (LEAST t::nat. ∀T::nat. gap (i::nat) T ≤ gap i t) ≤ (T::nat)›*) by (metis (no_types, lifting) Suc_eq_plus1 (*‹Suc ?n = ?n + 1›*) Suc_le_D (*‹Suc ?n ≤ ?m' ⟹ ∃m. ?m' = Suc m›*) Suc_le_mono (*‹(Suc ?n ≤ Suc ?m) = (?n ≤ ?m)›*)) then show "?thesis" (*goal: ‹∀n≥Suc (LEAST t. ∀T. gap i T ≤ gap i t). σ i (f₁ ▹ n) = σ i (e_take (gap i (LEAST t. ∀T. gap i T ≤ gap i t)) (block i (LEAST t. ∀T. gap i T ≤ gap i t)))›*) by simp qed qed qed corollary not_learn_lim_V: "¬ learn_lim φ (V_bclim i) (σ i)" using case_one_imp_not_learn_lim_V (*‹case_one ?i ⟹ ¬ learn_lim φ (V_bclim ?i) (σ ?i)›*) case_two_imp_not_learn_lim_V (*‹case_two ?i ⟹ ¬ learn_lim φ (V_bclim ?i) (σ ?i)›*) apply (cases "case_two i") (*goals: 1. ‹⟦⋀i. case_one i ⟹ ¬ learn_lim φ (V_bclim i) (σ i); ⋀i. case_two i ⟹ ¬ learn_lim φ (V_bclim i) (σ i); case_two i⟧ ⟹ ¬ learn_lim φ (V_bclim i) (σ i)› 2. ‹⟦⋀i. case_one i ⟹ ¬ learn_lim φ (V_bclim i) (σ i); ⋀i. case_two i ⟹ ¬ learn_lim φ (V_bclim i) (σ i); case_one i⟧ ⟹ ¬ learn_lim φ (V_bclim i) (σ i)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . text ‹Next we define the separating class.› definition V_BCLIM :: "partial1 set" ("V⇘BC-LIM⇙") where "V⇘BC-LIM⇙ ≡ ⋃i. V_bclim i" lemma V_BCLIM_R1: "V⇘BC-LIM⇙ ⊆ ℛ" using V_BCLIM_def (*‹V⇘BC-LIM⇙ ≡ ⋃ (range V_bclim)›*) V_subseteq_R1 (*‹V_bclim ?i ⊆ ℛ›*) by auto lemma V_BCLIM_not_in_Lim: "V⇘BC-LIM⇙ ∉ LIM" proof (standard) (*goal: ‹V⇘BC-LIM⇙ ∈ LIM ⟹ False›*) assume "V⇘BC-LIM⇙ ∈ LIM" (*‹V⇘BC-LIM⇙ ∈ LIM›*) then obtain s where s: "learn_lim φ V⇘BC-LIM⇙ s" (*goal: ‹(⋀s. learn_lim φ V⇘BC-LIM⇙ s ⟹ thesis) ⟹ thesis›*) using learn_lim_wrt_goedel[OF goedel_numbering_phi] (*‹learn_lim ?ψ ?U ?s ⟹ ∃t. learn_lim φ ?U t›*) Lim_def (*‹LIM ≡ {U. ∃ψ s. learn_lim ψ U s}›*) by blast moreover obtain i where "φ i = s" (*goal: ‹(⋀i::nat. φ i = (s::nat ⇒ nat option) ⟹ thesis::bool) ⟹ thesis›*) using s (*‹learn_lim φ V⇘BC-LIM⇙ s›*) learn_limE(1) (*‹learn_lim ?ψ ?U ?s ⟹ environment ?ψ ?U ?s›*) phi_universal (*‹⟦?f ∈ 𝒫; ⋀i. φ i = ?f ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast ultimately have "learn_lim φ V⇘BC-LIM⇙ (λx. eval r_sigma [i, x])" using learn_lim_sigma (*‹learn_lim ?ψ ?U (φ ?i) ⟹ learn_lim ?ψ ?U (σ ?i)›*) by simp moreover have "V_bclim i ⊆ V⇘BC-LIM⇙" using V_BCLIM_def (*‹V⇘BC-LIM⇙ ≡ ⋃ (range V_bclim)›*) by auto ultimately have "learn_lim φ (V_bclim i) (λx. eval r_sigma [i, x])" using learn_lim_closed_subseteq (*‹⟦learn_lim (?ψ::nat ⇒ nat ⇒ nat option) (?U::(nat ⇒ nat option) set) (?s::nat ⇒ nat option); (?V::(nat ⇒ nat option) set) ⊆ ?U⟧ ⟹ learn_lim ?ψ ?V ?s›*) by simp then show False using not_learn_lim_V (*‹¬ learn_lim φ (V_bclim ?i) (σ ?i)›*) by simp qed subsection ‹The separating class is in BC› text ‹In order to show @{term "V⇘BC-LIM⇙ ∈ BC"} we define a hypothesis space that for every function $\tau_i$ and every list $b$ of numbers contains a copy of $\tau_i$ with the first $|b|$ values replaced by $b$.› definition psitau :: partial2 ("ψ⇧τ") where "ψ⇧τ b x ≡ (if x < e_length b then Some (e_nth b x) else τ (e_hd b) x)" lemma psitau_in_P2: "ψ⇧τ ∈ 𝒫²" proof (-) (*goal: ‹ψ⇧τ ∈ 𝒫²›*) define r where "r ≡ Cn 2 (r_lifz r_nth (Cn 2 r_tau [Cn 2 r_hd [Id 2 0], Id 2 1])) [Cn 2 r_less [Id 2 1, Cn 2 r_length [Id 2 0]], Id 2 0, Id 2 1]" then have "recfn 2 r" using r_tau_recfn (*‹recfn 2 r_tau›*) by simp moreover have "eval r [b, x] = ψ⇧τ b x" for b and x proof (-) (*goal: ‹eval (r::recf) [b::nat, x::nat] = ψ⇧τ b x›*) let ?f = "Cn 2 r_tau [Cn 2 r_hd [Id 2 0], Id 2 1]" have "recfn 2 r_nth" "recfn 2 ?f" using r_tau_recfn (*‹recfn 2 r_tau›*) apply - (*goals: 1. ‹recfn 2 r_tau ⟹ recfn 2 r_nth› 2. ‹recfn 2 r_tau ⟹ recfn 2 (Cn 2 r_tau [Cn 2 r_hd [recf.Id 2 0], recf.Id 2 1])› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . then have "eval (r_lifz r_nth ?f) [c, b, x] = (if c = 0 then eval r_nth [b, x] else eval ?f [b, x])" for c by simp moreover have "eval r_nth [b, x] ↓= e_nth b x" by simp moreover have "eval ?f [b, x] = τ (e_hd b) x" using r_tau_recfn (*‹recfn 2 r_tau›*) by simp ultimately have "eval (r_lifz r_nth ?f) [c, b, x] = (if c = 0 then Some (e_nth b x) else τ (e_hd b) x)" for c by simp moreover have "eval (Cn 2 r_less [Id 2 1, Cn 2 r_length [Id 2 0]]) [b, x] ↓= (if x < e_length b then 0 else 1)" by simp ultimately show "?thesis" (*goal: ‹eval r [b, x] = ψ⇧τ b x›*) unfolding r_def psitau_def (*goal: ‹eval (Cn 2 (r_lifz r_nth (Cn 2 r_tau [Cn 2 r_hd [recf.Id 2 0], recf.Id 2 1])) [Cn 2 r_less [recf.Id 2 1, Cn 2 r_length [recf.Id 2 0]], recf.Id 2 0, recf.Id 2 1]) [b, x] = (if x < e_length b then Some (e_nth b x) else τ (e_hd b) x)›*) using r_tau_recfn (*‹recfn 2 r_tau›*) by simp qed ultimately show "?thesis" (*goal: ‹ψ⇧τ ∈ 𝒫²›*) by auto qed lemma psitau_init: "ψ⇧τ (f ▹ n) x = (if x < Suc n then Some (the (f x)) else τ (the (f 0)) x)" proof (-) (*goal: ‹ψ⇧τ (f ▹ n) x = (if x < Suc n then Some (the (f x)) else τ (the (f 0)) x)›*) let ?e = "f ▹ n" have "e_length ?e = Suc n" by simp moreover have "x < Suc n ⟹ e_nth ?e x = the (f x)" by simp moreover have "e_hd ?e = the (f 0)" using hd_init (*‹e_hd (?f ▹ ?n) = the (?f 0)›*) by simp ultimately show "?thesis" (*goal: ‹ψ⇧τ (f ▹ n) x = (if x < Suc n then Some (the (f x)) else τ (the (f 0)) x)›*) using psitau_def (*‹ψ⇧τ (?b::nat) (?x::nat) ≡ if ?x < e_length ?b then Some (e_nth ?b ?x) else τ (e_hd ?b) ?x›*) by simp qed text ‹The class @{term V_BCLIM} can be learned BC-style in the hypothesis space @{term psitau} by the identity function.› lemma learn_bc_V_BCLIM: "learn_bc ψ⇧τ V⇘BC-LIM⇙ Some" proof (rule learn_bcI (*‹⟦environment ?ψ ?U ?s; ⋀f. f ∈ ?U ⟹ ∃n₀. ∀n≥n₀. ?ψ (the (?s (f ▹ n))) = f⟧ ⟹ learn_bc ?ψ ?U ?s›*)) (*goals: 1. ‹environment ψ⇧τ V⇘BC-LIM⇙ Some› 2. ‹⋀f. f ∈ V⇘BC-LIM⇙ ⟹ ∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f›*) show "environment ψ⇧τ V⇘BC-LIM⇙ Some" using identity_in_R1 (*‹Some ∈ ℛ›*) V_BCLIM_R1 (*‹V⇘BC-LIM⇙ ⊆ ℛ›*) psitau_in_P2 (*‹ψ⇧τ ∈ 𝒫²›*) by auto show "∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f" if "f ∈ V⇘BC-LIM⇙" for f proof (-) (*goal: ‹∃n₀::nat. ∀n≥n₀. ψ⇧τ (the (Some ((f::nat ⇒ nat option) ▹ n))) = f›*) from that (*‹f ∈ V⇘BC-LIM⇙›*) V_BCLIM_def (*‹V⇘BC-LIM⇙ ≡ ⋃ (range V_bclim)›*) obtain i where i: "f ∈ V_bclim i" (*goal: ‹(⋀i. f ∈ V_bclim i ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹∃n₀::nat. ∀n≥n₀. ψ⇧τ (the (Some ((f::nat ⇒ nat option) ▹ n))) = f›*) proof (cases "case_two i") (*goals: 1. ‹case_two i ⟹ ∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f› 2. ‹case_one i ⟹ ∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f›*) case True (*‹case_two i›*) let ?P = "λt. ∀T. (gap i T) ≤ (gap i t)" let ?lmin = "LEAST t. ?P t" define k where "k ≡ gap i ?lmin" have V_bclim: "V_bclim i = {(τ i)(k:=Some 0), (τ i)(k:=Some 1)}" using True (*‹case_two i›*) V_bclim_def (*‹V_bclim ?i ≡ if case_two ?i then let k = gap ?i (LEAST t. ∀T. gap ?i T ≤ gap ?i t) in {(τ ?i)(k ↦ 0), (τ ?i)(k ↦ 1)} else {τ ?i}›*) k_def (*‹k ≡ gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) by (simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) moreover have "0 < k" using gap_gr0[of i] (*‹0 < gap i ?t›*) k_def (*‹k ≡ gap i (LEAST t. ∀T. gap i T ≤ gap i t)›*) by simp ultimately have "f 0 ↓= i" using tau_at_0[of i] (*‹τ i 0 ↓= i›*) i (*‹f ∈ V_bclim i›*) by auto have "ψ⇧τ (f ▹ n) = f" if "n ≥ k" for n proof (standard) (*goal: ‹⋀x. ψ⇧τ (f ▹ n) x = f x›*) fix x show "ψ⇧τ (f ▹ n) x = f x" proof (cases "x ≤ n") (*goals: 1. ‹x ≤ n ⟹ ψ⇧τ (f ▹ n) x = f x› 2. ‹¬ x ≤ n ⟹ ψ⇧τ (f ▹ n) x = f x›*) case True (*‹x ≤ n›*) then show "?thesis" (*goal: ‹ψ⇧τ (f ▹ n) x = f x›*) using R1_imp_total1 (*‹?f ∈ ℛ ⟹ total1 ?f›*) V_subseteq_R1 (*‹V_bclim ?i ⊆ ℛ›*) i (*‹f ∈ V_bclim i›*) psitau_init (*‹ψ⇧τ (?f ▹ ?n) ?x = (if ?x < Suc ?n then Some (the (?f ?x)) else τ (the (?f 0)) ?x)›*) by fastforce next (*goal: ‹¬ x ≤ n ⟹ ψ⇧τ (f ▹ n) x = f x›*) case False (*‹¬ (x::nat) ≤ (n::nat)›*) then have "ψ⇧τ (f ▹ n) x = τ (the (f 0)) x" using psitau_init (*‹ψ⇧τ (?f ▹ ?n) ?x = (if ?x < Suc ?n then Some (the (?f ?x)) else τ (the (?f 0)) ?x)›*) by simp then have "ψ⇧τ (f ▹ n) x = τ i x" using ‹f 0 ↓= i› (*‹f 0 ↓= i›*) by simp moreover have "f x = τ i x" using False (*‹¬ x ≤ n›*) V_bclim (*‹V_bclim i = {(τ i)(k ↦ 0), (τ i)(k ↦ 1)}›*) i (*‹f ∈ V_bclim i›*) that (*‹k ≤ n›*) by auto ultimately show "?thesis" (*goal: ‹ψ⇧τ (f ▹ n) x = f x›*) by simp qed qed then show "?thesis" (*goal: ‹∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f›*) by auto next (*goal: ‹case_one i ⟹ ∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f›*) case False (*‹case_one i›*) then have "V_bclim i = {τ i}" using V_bclim_def (*‹V_bclim ?i ≡ if case_two ?i then let k = gap ?i (LEAST t. ∀T. gap ?i T ≤ gap ?i t) in {(τ ?i)(k ↦ 0), (τ ?i)(k ↦ 1)} else {τ ?i}›*) by (auto simp add: Let_def (*‹Let ?s ?f ≡ ?f ?s›*)) then have f: "f = τ i" using i (*‹f ∈ V_bclim i›*) by simp have "ψ⇧τ (f ▹ n) = f" for n proof (standard) (*goal: ‹⋀x. ψ⇧τ (f ▹ n) x = f x›*) fix x show "ψ⇧τ (f ▹ n) x = f x" proof (cases "x ≤ n") (*goals: 1. ‹x ≤ n ⟹ ψ⇧τ (f ▹ n) x = f x› 2. ‹¬ x ≤ n ⟹ ψ⇧τ (f ▹ n) x = f x›*) case True (*‹x ≤ n›*) then show "?thesis" (*goal: ‹ψ⇧τ ((f::nat ⇒ nat option) ▹ (n::nat)) (x::nat) = f x›*) using R1_imp_total1 (*‹?f ∈ ℛ ⟹ total1 ?f›*) V_BCLIM_R1 (*‹V⇘BC-LIM⇙ ⊆ ℛ›*) psitau_init (*‹ψ⇧τ (?f ▹ ?n) ?x = (if ?x < Suc ?n then Some (the (?f ?x)) else τ (the (?f 0)) ?x)›*) that (*‹f ∈ V⇘BC-LIM⇙›*) by auto next (*goal: ‹¬ x ≤ n ⟹ ψ⇧τ (f ▹ n) x = f x›*) case False (*‹¬ x ≤ n›*) then show "?thesis" (*goal: ‹ψ⇧τ ((f::nat ⇒ nat option) ▹ (n::nat)) (x::nat) = f x›*) by (simp add: f (*‹f = τ i›*) psitau_init (*‹ψ⇧τ (?f ▹ ?n) ?x = (if ?x < Suc ?n then Some (the (?f ?x)) else τ (the (?f 0)) ?x)›*) tau_at_0 (*‹τ ?i 0 ↓= ?i›*)) qed qed then show "?thesis" (*goal: ‹∃n₀. ∀n≥n₀. ψ⇧τ (the (Some (f ▹ n))) = f›*) by simp qed qed qed text ‹Finally, the main result of this section:› theorem Lim_subset_BC: "LIM ⊂ BC" using learn_bc_V_BCLIM (*‹learn_bc ψ⇧τ V⇘BC-LIM⇙ Some›*) BC_def (*‹BC ≡ {U. ∃ψ s. learn_bc ψ U s}›*) Lim_subseteq_BC (*‹LIM ⊆ BC›*) V_BCLIM_not_in_Lim (*‹V⇘BC-LIM⇙ ∉ LIM›*) by auto end
{ "path": "afp-2025-02-12/thys/Inductive_Inference/LIM_BC.thy", "repo": "afp-2025-02-12", "sha": "9b932171be1cecf0af481c98fb24877c5b7adbe3f63a930afd91f6e8f72e596b" }
(* Author: Alexander Maletzky *) section ‹Preliminaries› theory Prelims imports Polynomials.Utils Groebner_Bases.General begin subsection ‹Lists› subsubsection ‹Sequences of Lists› lemma list_seq_length_mono: fixes seq :: "nat ⇒ 'a list" assumes "⋀i. (∃x. seq (Suc i) = x # seq i)" and "i < j" shows "length (seq i) < length (seq j)" proof (-) (*goal: ‹length (seq i) < length (seq j)›*) from assms(2) (*‹(i::nat) < (j::nat)›*) obtain k where "j = Suc (i + k)" (*goal: ‹(⋀k::nat. (j::nat) = Suc ((i::nat) + k) ⟹ thesis::bool) ⟹ thesis›*) using less_iff_Suc_add (*‹(?m < ?n) = (∃k. ?n = Suc (?m + k))›*) by auto show "?thesis" (*goal: ‹length (seq i) < length (seq j)›*) unfolding ‹j = Suc (i + k)› (*goal: ‹length (seq i) < length (seq (Suc (i + k)))›*) proof (induct k) (*goals: 1. ‹length (seq i) < length (seq (Suc (i + 0)))› 2. ‹⋀k. length (seq i) < length (seq (Suc (i + k))) ⟹ length (seq i) < length (seq (Suc (i + Suc k)))›*) case 0 (*no hyothesis introduced yet*) from assms(1) (*‹∃x. seq (Suc ?i) = x # seq ?i›*) obtain x where eq: "seq (Suc i) = x # seq i" (*goal: ‹(⋀x::'a::type. (seq::nat ⇒ 'a::type list) (Suc (i::nat)) = x # seq i ⟹ thesis::bool) ⟹ thesis›*) by standard show "?case" (*goal: ‹length (seq i) < length (seq (Suc (i + 0)))›*) by (simp add: eq (*‹seq (Suc i) = x # seq i›*)) next (*goal: ‹⋀k. length (seq i) < length (seq (Suc (i + k))) ⟹ length (seq i) < length (seq (Suc (i + Suc k)))›*) case (Suc k) (*‹length (seq i) < length (seq (Suc (i + k)))›*) from assms(1) (*‹∃x::'a. (seq::nat ⇒ 'a list) (Suc (?i::nat)) = x # seq ?i›*) obtain x where "seq (Suc (i + Suc k)) = x # seq (i + Suc k)" (*goal: ‹(⋀x. seq (Suc (i + Suc k)) = x # seq (i + Suc k) ⟹ thesis) ⟹ thesis›*) by standard hence eq: "seq (Suc (Suc (i + k))) = x # seq (Suc (i + k))" by simp note Suc (*‹length ((seq::nat ⇒ 'a list) (i::nat)) < length (seq (Suc (i + (k::nat))))›*) also (*calculation: ‹length (seq i) < length (seq (Suc (i + k)))›*) have "length (seq (Suc (i + k))) < length (seq (Suc (i + Suc k)))" by (simp add: eq (*‹(seq::nat ⇒ 'a::type list) (Suc (Suc ((i::nat) + (k::nat)))) = (x::'a::type) # seq (Suc (i + k))›*)) finally (*calculation: ‹length (seq i) < length (seq (Suc (i + Suc k)))›*) show "?case" (*goal: ‹length (seq i) < length (seq (Suc (i + Suc k)))›*) . qed qed corollary list_seq_length_mono_weak: fixes seq :: "nat ⇒ 'a list" assumes "⋀i. (∃x. seq (Suc i) = x # seq i)" and "i ≤ j" shows "length (seq i) ≤ length (seq j)" proof (cases "i = j") (*goals: 1. ‹i = j ⟹ length (seq i) ≤ length (seq j)› 2. ‹i ≠ j ⟹ length (seq i) ≤ length (seq j)›*) case True (*‹(i::nat) = (j::nat)›*) thus "?thesis" (*goal: ‹length (seq i) ≤ length (seq j)›*) by simp next (*goal: ‹i ≠ j ⟹ length (seq i) ≤ length (seq j)›*) case False (*‹i ≠ j›*) with assms(2) (*‹i ≤ j›*) have "i < j" by simp with assms(1) (*‹∃x. seq (Suc ?i) = x # seq ?i›*) have "length (seq i) < length (seq j)" by (rule list_seq_length_mono (*‹⟦⋀i. ∃x. ?seq (Suc i) = x # ?seq i; ?i < ?j⟧ ⟹ length (?seq ?i) < length (?seq ?j)›*)) thus "?thesis" (*goal: ‹length (seq i) ≤ length (seq j)›*) by simp qed lemma list_seq_indexE_length: fixes seq :: "nat ⇒ 'a list" assumes "⋀i. (∃x. seq (Suc i) = x # seq i)" obtains j where "i < length (seq j)" proof (induct i arbitrary: thesis) (*goals: 1. ‹⋀thesis. (⋀j. 0 < length (seq j) ⟹ thesis) ⟹ thesis› 2. ‹⋀i thesis. ⟦⋀thesis. (⋀j. i < length (seq j) ⟹ thesis) ⟹ thesis; ⋀j. Suc i < length (seq j) ⟹ thesis⟧ ⟹ thesis›*) case 0 (*‹0 < length (seq ?j) ⟹ thesis›*) have "0 ≤ length (seq 0)" by simp also (*calculation: ‹0 ≤ length (seq 0)›*) from assms (*‹∃x. seq (Suc ?i) = x # seq ?i›*) lessI (*‹?n < Suc ?n›*) have "... < length (seq (Suc 0))" by (rule list_seq_length_mono (*‹⟦⋀i::nat. ∃x::?'a. (?seq::nat ⇒ ?'a list) (Suc i) = x # ?seq i; (?i::nat) < (?j::nat)⟧ ⟹ length (?seq ?i) < length (?seq ?j)›*)) finally (*calculation: ‹0 < length (seq (Suc 0))›*) show "?case" (*goal: ‹thesis::bool›*) by (rule 0 (*‹0 < length (seq ?j) ⟹ thesis›*)) next (*goal: ‹⋀i thesis. ⟦⋀thesis. (⋀j. i < length (seq j) ⟹ thesis) ⟹ thesis; ⋀j. Suc i < length (seq j) ⟹ thesis⟧ ⟹ thesis›*) case (Suc i) (*‹(⋀j. i < length (seq j) ⟹ ?thesis) ⟹ ?thesis› ‹Suc i < length (seq ?j) ⟹ thesis›*) obtain j where "i < length (seq j)" (*goal: ‹(⋀j. i < length (seq j) ⟹ thesis) ⟹ thesis›*) by (rule Suc( (*‹(⋀j::nat. (i::nat) < length ((seq::nat ⇒ 'a list) j) ⟹ ?thesis::bool) ⟹ ?thesis›*) 1)) hence "Suc i ≤ length (seq j)" by simp also (*calculation: ‹Suc i ≤ length (seq j)›*) from assms (*‹∃x. seq (Suc ?i) = x # seq ?i›*) lessI (*‹?n < Suc ?n›*) have "... < length (seq (Suc j))" by (rule list_seq_length_mono (*‹⟦⋀i. ∃x. ?seq (Suc i) = x # ?seq i; ?i < ?j⟧ ⟹ length (?seq ?i) < length (?seq ?j)›*)) finally (*calculation: ‹Suc i < length (seq (Suc j))›*) show "?case" (*goal: ‹thesis›*) by (rule Suc( (*‹Suc i < length (seq ?j) ⟹ thesis›*) 2)) qed lemma list_seq_nth: fixes seq :: "nat ⇒ 'a list" assumes "⋀i. (∃x. seq (Suc i) = x # seq i)" and "i < length (seq j)" and "j ≤ k" shows "rev (seq k) ! i = rev (seq j) ! i" proof (-) (*goal: ‹rev (seq k) ! i = rev (seq j) ! i›*) from assms(3) (*‹j ≤ k›*) obtain l where "k = j + l" (*goal: ‹(⋀l. k = j + l ⟹ thesis) ⟹ thesis›*) using nat_le_iff_add (*‹(?m ≤ ?n) = (∃k. ?n = ?m + k)›*) by blast show "?thesis" (*goal: ‹rev (seq k) ! i = rev (seq j) ! i›*) unfolding ‹k = j + l› (*goal: ‹rev (seq (j + l)) ! i = rev (seq j) ! i›*) proof (induct l) (*goals: 1. ‹rev (seq (j + 0)) ! i = rev (seq j) ! i› 2. ‹⋀l. rev (seq (j + l)) ! i = rev (seq j) ! i ⟹ rev (seq (j + Suc l)) ! i = rev (seq j) ! i›*) case 0 (*no hyothesis introduced yet*) show "?case" (*goal: ‹rev (seq (j + 0)) ! i = rev (seq j) ! i›*) by simp next (*goal: ‹⋀l::nat. rev ((seq::nat ⇒ 'a list) ((j::nat) + l)) ! (i::nat) = rev (seq j) ! i ⟹ rev (seq (j + Suc l)) ! i = rev (seq j) ! i›*) case (Suc l) (*‹rev (seq (j + l)) ! i = rev (seq j) ! i›*) note assms(2) (*‹i < length (seq j)›*) also (*calculation: ‹i < length (seq j)›*) from assms(1) (*‹∃x. seq (Suc ?i) = x # seq ?i›*) le_add1 (*‹(?n::nat) ≤ ?n + (?m::nat)›*) have "length (seq j) ≤ length (seq (j + l))" by (rule list_seq_length_mono_weak (*‹⟦⋀i::nat. ∃x::?'a::type. (?seq::nat ⇒ ?'a::type list) (Suc i) = x # ?seq i; (?i::nat) ≤ (?j::nat)⟧ ⟹ length (?seq ?i) ≤ length (?seq ?j)›*)) finally (*calculation: ‹i < length (seq (j + l))›*) have i: "i < length (seq (j + l))" . from assms(1) (*‹∃x. seq (Suc ?i) = x # seq ?i›*) obtain x where "seq (Suc (j + l)) = x # seq (j + l)" (*goal: ‹(⋀x::'a. (seq::nat ⇒ 'a list) (Suc ((j::nat) + (l::nat))) = x # seq (j + l) ⟹ thesis::bool) ⟹ thesis›*) by standard thus "?case" (*goal: ‹rev (seq (j + Suc l)) ! i = rev (seq j) ! i›*) by (simp add: nth_append (*‹((?xs::?'a list) @ (?ys::?'a list)) ! (?n::nat) = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) i (*‹(i::nat) < length ((seq::nat ⇒ 'a list) ((j::nat) + (l::nat)))›*) Suc (*‹rev ((seq::nat ⇒ 'a list) ((j::nat) + (l::nat))) ! (i::nat) = rev (seq j) ! i›*)) qed qed corollary list_seq_nth': fixes seq :: "nat ⇒ 'a list" assumes "⋀i. (∃x. seq (Suc i) = x # seq i)" and "i < length (seq j)" and "i < length (seq k)" shows "rev (seq k) ! i = rev (seq j) ! i" proof (rule linorder_cases (*‹⟦?x < ?y ⟹ ?P; ?x = ?y ⟹ ?P; ?y < ?x ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹?x < ?y ⟹ rev (seq k) ! i = rev (seq j) ! i› 2. ‹?x = ?y ⟹ rev (seq k) ! i = rev (seq j) ! i› 3. ‹?y < ?x ⟹ rev (seq k) ! i = rev (seq j) ! i›*) assume "j < k" (*‹(j::nat) < (k::nat)›*) hence "j ≤ k" by simp with assms(1,2) (*‹∃x::'a. (seq::nat ⇒ 'a list) (Suc (?i::nat)) = x # seq ?i› ‹i < length (seq j)›*) show "?thesis" (*goal: ‹rev ((seq::nat ⇒ 'a list) (k::nat)) ! (i::nat) = rev (seq (j::nat)) ! i›*) by (rule list_seq_nth (*‹⟦⋀i. ∃x. ?seq (Suc i) = x # ?seq i; ?i < length (?seq ?j); ?j ≤ ?k⟧ ⟹ rev (?seq ?k) ! ?i = rev (?seq ?j) ! ?i›*)) next (*goals: 1. ‹j = k ⟹ rev (seq k) ! i = rev (seq j) ! i› 2. ‹k < j ⟹ rev (seq k) ! i = rev (seq j) ! i›*) assume "k < j" (*‹(k::nat) < (j::nat)›*) hence "k ≤ j" by simp with assms(1,3) (*‹∃x::'a. (seq::nat ⇒ 'a list) (Suc (?i::nat)) = x # seq ?i› ‹i < length (seq k)›*) have "rev (seq j) ! i = rev (seq k) ! i" by (rule list_seq_nth (*‹⟦⋀i. ∃x. ?seq (Suc i) = x # ?seq i; ?i < length (?seq ?j); ?j ≤ ?k⟧ ⟹ rev (?seq ?k) ! ?i = rev (?seq ?j) ! ?i›*)) thus "?thesis" (*goal: ‹rev (seq k) ! i = rev (seq j) ! i›*) by (rule HOL.sym (*‹?s = ?t ⟹ ?t = ?s›*)) next (*goal: ‹j = k ⟹ rev (seq k) ! i = rev (seq j) ! i›*) assume "j = k" (*‹(j::nat) = (k::nat)›*) thus "?thesis" (*goal: ‹rev (seq k) ! i = rev (seq j) ! i›*) by simp qed subsubsection ‹@{const filter}› lemma filter_merge_wrt_1: assumes "⋀y. y ∈ set ys ⟹ P y ⟹ False" shows "filter P (merge_wrt rel xs ys) = filter P xs" using assms (*‹⟦?y ∈ set ys; P ?y⟧ ⟹ False›*) proof (induct rel xs ys rule: merge_wrt.induct (*‹⟦⋀uu_ xs. ?P uu_ xs []; ⋀rel v va. ?P rel [] (v # va); ⋀rel x xs y ys. ⟦x = y ⟹ ?P rel xs ys; ⟦x ≠ y; rel x y⟧ ⟹ ?P rel xs (y # ys); ⟦x ≠ y; ¬ rel x y⟧ ⟹ ?P rel (x # xs) ys⟧ ⟹ ?P rel (x # xs) (y # ys)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ xs. (⋀y. ⟦y ∈ set []; P y⟧ ⟹ False) ⟹ filter P (merge_wrt uu_ xs []) = filter P xs› 2. ‹⋀rel v va. (⋀y. ⟦y ∈ set (v # va); P y⟧ ⟹ False) ⟹ filter P (merge_wrt rel [] (v # va)) = filter P []› 3. ‹⋀rel x xs y ys. ⟦⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs; ⟦x ≠ y; rel x y; ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs; ⟦x ≠ y; ¬ rel x y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs); ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (x # xs)›*) case (1 rel xs) (*‹⟦?y ∈ set []; P ?y⟧ ⟹ False›*) show "?case" (*goal: ‹filter P (merge_wrt rel xs []) = filter P xs›*) by simp next (*goals: 1. ‹⋀rel v va. (⋀y. ⟦y ∈ set (v # va); P y⟧ ⟹ False) ⟹ filter P (merge_wrt rel [] (v # va)) = filter P []› 2. ‹⋀rel x xs y ys. ⟦⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs; ⟦x ≠ y; rel x y; ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs; ⟦x ≠ y; ¬ rel x y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs); ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (x # xs)›*) case (2 rel y ys) (*‹⟦(?y::'a) ∈ set ((y::'a) # (ys::'a list)); (P::'a ⇒ bool) ?y⟧ ⟹ False›*) hence "P y ⟹ False" and "⋀z. z ∈ set ys ⟹ P z ⟹ False" apply - (*goals: 1. ‹⟦(P::'a ⇒ bool) (y::'a); ⋀ya::'a. ⟦ya ∈ set (y # (ys::'a list)); P ya⟧ ⟹ False⟧ ⟹ False› 2. ‹⋀z::'a. ⟦z ∈ set (ys::'a list); (P::'a ⇒ bool) z; ⋀ya::'a. ⟦ya ∈ set ((y::'a) # ys); P ya⟧ ⟹ False⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . thus "?case" (*goal: ‹filter (P::'a ⇒ bool) (merge_wrt (rel::'a ⇒ 'a ⇒ bool) [] ((y::'a) # (ys::'a list))) = filter P []›*) by (auto simp: filter_empty_conv (*‹(filter ?P ?xs = []) = (∀x∈set ?xs. ¬ ?P x)›*)) next (*goal: ‹⋀rel x xs y ys. ⟦⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs; ⟦x ≠ y; rel x y; ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs; ⟦x ≠ y; ¬ rel x y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs); ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (x # xs)›*) case (3 rel x xs y ys) (*‹⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs› ‹⟦x ≠ y; rel x y; ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs› ‹⟦(x::'a::type) ≠ (y::'a::type); ¬ (rel::'a::type ⇒ 'a::type ⇒ bool) x y; ⋀y::'a::type. ⟦y ∈ set (ys::'a::type list); (P::'a::type ⇒ bool) y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # (xs::'a::type list)) ys) = filter P (x # xs)› ‹⟦?y ∈ set (y # ys); P ?y⟧ ⟹ False›*) hence "¬ P y" and x: "⋀z. z ∈ set ys ⟹ P z ⟹ False" apply - (*goals: 1. ‹⟦⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs; ⟦x ≠ y; rel x y; ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs; ⟦x ≠ y; ¬ rel x y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs); ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ ¬ P y› 2. ‹⋀z. ⟦z ∈ set ys; P z; ⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs; ⟦x ≠ y; rel x y; ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs; ⟦x ≠ y; ¬ rel x y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs); ⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ False⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have a: "filter P (merge_wrt rel xs ys) = filter P xs" if "x = y" using that (*‹x = y›*) x (*‹⟦?z ∈ set ys; P ?z⟧ ⟹ False›*) apply (rule 3( (*‹⟦x = y; ⋀y. ⟦y ∈ set ys; P y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P xs›*) 1)) (*goals: 1. ‹⋀y. ⟦y ∈ set ys; P y⟧ ⟹ ?z y ∈ set ys› 2. ‹⋀y. ⟦y ∈ set ys; P y⟧ ⟹ P (?z y)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) have b: "filter P (merge_wrt rel xs (y # ys)) = filter P xs" if "x ≠ y" and "rel x y" using that (*‹x ≠ y› ‹rel x y›*) "3"(4) (*‹⟦?y ∈ set (y # ys); P ?y⟧ ⟹ False›*) apply (rule 3( (*‹⟦(x::'a) ≠ (y::'a); (rel::'a ⇒ 'a ⇒ bool) x y; ⋀ya::'a. ⟦ya ∈ set (y # (ys::'a list)); (P::'a ⇒ bool) ya⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (xs::'a list) (y # ys)) = filter P xs›*) 2)) (*goals: 1. ‹⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ ?y ya ∈ set (y # ys)› 2. ‹⋀ya. ⟦ya ∈ set (y # ys); P ya⟧ ⟹ P (?y ya)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) have c: "filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs)" if "x ≠ y" and "¬ rel x y" using that (*‹x ≠ y› ‹¬ rel x y›*) x (*‹⟦(?z::'a) ∈ set (ys::'a list); (P::'a ⇒ bool) ?z⟧ ⟹ False›*) apply (rule 3( (*‹⟦(x::'a::type) ≠ (y::'a::type); ¬ (rel::'a::type ⇒ 'a::type ⇒ bool) x y; ⋀y::'a::type. ⟦y ∈ set (ys::'a::type list); (P::'a::type ⇒ bool) y⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # (xs::'a::type list)) ys) = filter P (x # xs)›*) 3)) (*goals: 1. ‹⋀y. ⟦y ∈ set ys; P y⟧ ⟹ ?z y ∈ set ys› 2. ‹⋀y. ⟦y ∈ set ys; P y⟧ ⟹ P (?z y)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) show "?case" (*goal: ‹filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (x # xs)›*) by (simp add: a (*‹x = y ⟹ filter P (merge_wrt rel xs ys) = filter P xs›*) b (*‹⟦x ≠ y; rel x y⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P xs›*) c (*‹⟦x ≠ y; ¬ rel x y⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P (x # xs)›*) ‹¬ P y›) qed lemma filter_merge_wrt_2: assumes "⋀x. x ∈ set xs ⟹ P x ⟹ False" shows "filter P (merge_wrt rel xs ys) = filter P ys" using assms (*‹⟦?x ∈ set xs; P ?x⟧ ⟹ False›*) proof (induct rel xs ys rule: merge_wrt.induct (*‹⟦⋀(uu_::?'a ⇒ ?'a ⇒ bool) xs::?'a list. (?P::(?'a ⇒ ?'a ⇒ bool) ⇒ ?'a list ⇒ ?'a list ⇒ bool) uu_ xs []; ⋀(rel::?'a ⇒ ?'a ⇒ bool) (v::?'a) va::?'a list. ?P rel [] (v # va); ⋀(rel::?'a ⇒ ?'a ⇒ bool) (x::?'a) (xs::?'a list) (y::?'a) ys::?'a list. ⟦x = y ⟹ ?P rel xs ys; ⟦x ≠ y; rel x y⟧ ⟹ ?P rel xs (y # ys); ⟦x ≠ y; ¬ rel x y⟧ ⟹ ?P rel (x # xs) ys⟧ ⟹ ?P rel (x # xs) (y # ys)⟧ ⟹ ?P (?a0.0::?'a ⇒ ?'a ⇒ bool) (?a1.0::?'a list) (?a2.0::?'a list)›*)) (*goals: 1. ‹⋀(uu_::'a ⇒ 'a ⇒ bool) xs::'a list. (⋀x::'a. ⟦x ∈ set xs; (P::'a ⇒ bool) x⟧ ⟹ False) ⟹ filter P (merge_wrt uu_ xs []) = filter P []› 2. ‹⋀(rel::'a ⇒ 'a ⇒ bool) (v::'a) va::'a list. (⋀x::'a. ⟦x ∈ set []; (P::'a ⇒ bool) x⟧ ⟹ False) ⟹ filter P (merge_wrt rel [] (v # va)) = filter P (v # va)› 3. ‹⋀(rel::'a ⇒ 'a ⇒ bool) (x::'a) (xs::'a list) (y::'a) ys::'a list. ⟦⟦x = y; ⋀x::'a. ⟦x ∈ set xs; (P::'a ⇒ bool) x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys; ⟦x ≠ y; rel x y; ⋀x::'a. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys); ⟦x ≠ y; ¬ rel x y; ⋀xa::'a. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys; ⋀xa::'a. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (y # ys)›*) case (1 rel xs) (*‹⟦?x ∈ set xs; P ?x⟧ ⟹ False›*) thus "?case" (*goal: ‹filter (P::'a ⇒ bool) (merge_wrt (rel::'a ⇒ 'a ⇒ bool) (xs::'a list) []) = filter P []›*) by (auto simp: filter_empty_conv (*‹(filter ?P ?xs = []) = (∀x∈set ?xs. ¬ ?P x)›*)) next (*goals: 1. ‹⋀rel v va. (⋀x. ⟦x ∈ set []; P x⟧ ⟹ False) ⟹ filter P (merge_wrt rel [] (v # va)) = filter P (v # va)› 2. ‹⋀rel x xs y ys. ⟦⟦x = y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys; ⟦x ≠ y; rel x y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys); ⟦x ≠ y; ¬ rel x y; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (y # ys)›*) case (2 rel y ys) (*‹⟦?x ∈ set []; P ?x⟧ ⟹ False›*) show "?case" (*goal: ‹filter P (merge_wrt rel [] (y # ys)) = filter P (y # ys)›*) by simp next (*goal: ‹⋀rel x xs y ys. ⟦⟦x = y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys; ⟦x ≠ y; rel x y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys); ⟦x ≠ y; ¬ rel x y; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (y # ys)›*) case (3 rel x xs y ys) (*‹⟦x = y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys› ‹⟦x ≠ y; rel x y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys)› ‹⟦x ≠ y; ¬ rel x y; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys› ‹⟦?x ∈ set (x # xs); P ?x⟧ ⟹ False›*) hence "¬ P x" and x: "⋀z. z ∈ set xs ⟹ P z ⟹ False" apply - (*goals: 1. ‹⟦⟦x = y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys; ⟦x ≠ y; rel x y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys); ⟦x ≠ y; ¬ rel x y; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ ¬ P x› 2. ‹⋀z. ⟦z ∈ set xs; P z; ⟦x = y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys; ⟦x ≠ y; rel x y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys); ⟦x ≠ y; ¬ rel x y; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have a: "filter P (merge_wrt rel xs ys) = filter P ys" if "x = y" using that (*‹x = y›*) x (*‹⟦?z ∈ set xs; P ?z⟧ ⟹ False›*) apply (rule 3( (*‹⟦x = y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs ys) = filter P ys›*) 1)) (*goals: 1. ‹⋀x. ⟦x ∈ set xs; P x⟧ ⟹ ?z x ∈ set xs› 2. ‹⋀x. ⟦x ∈ set xs; P x⟧ ⟹ P (?z x)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) have b: "filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys)" if "x ≠ y" and "rel x y" using that (*‹x ≠ y› ‹rel x y›*) x (*‹⟦?z ∈ set xs; P ?z⟧ ⟹ False›*) apply (rule 3( (*‹⟦x ≠ y; rel x y; ⋀x. ⟦x ∈ set xs; P x⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys)›*) 2)) (*goals: 1. ‹⋀x. ⟦x ∈ set xs; P x⟧ ⟹ ?z x ∈ set xs› 2. ‹⋀x. ⟦x ∈ set xs; P x⟧ ⟹ P (?z x)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) have c: "filter P (merge_wrt rel (x # xs) ys) = filter P ys" if "x ≠ y" and "¬ rel x y" using that (*‹(x::'a) ≠ (y::'a)› ‹¬ rel x y›*) "3"(4) (*‹⟦?x ∈ set (x # xs); P ?x⟧ ⟹ False›*) apply (rule 3( (*‹⟦x ≠ y; ¬ rel x y; ⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ False⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys›*) 3)) (*goals: 1. ‹⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ ?x xa ∈ set (x # xs)› 2. ‹⋀xa. ⟦xa ∈ set (x # xs); P xa⟧ ⟹ P (?x xa)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) show "?case" (*goal: ‹filter P (merge_wrt rel (x # xs) (y # ys)) = filter P (y # ys)›*) by (simp add: a (*‹x = y ⟹ filter P (merge_wrt rel xs ys) = filter P ys›*) b (*‹⟦x ≠ y; rel x y⟧ ⟹ filter P (merge_wrt rel xs (y # ys)) = filter P (y # ys)›*) c (*‹⟦x ≠ y; ¬ rel x y⟧ ⟹ filter P (merge_wrt rel (x # xs) ys) = filter P ys›*) ‹¬ P x›) qed lemma length_filter_le_1: assumes "length (filter P xs) ≤ 1" and "i < length xs" and "j < length xs" and "P (xs ! i)" and "P (xs ! j)" shows "i = j" proof (-) (*goal: ‹i = j›*) have "*": thesis if "a < b" and "b < length xs" and "⋀as bs cs. as @ ((xs ! a) # (bs @ ((xs ! b) # cs))) = xs ⟹ thesis" for a and b and thesis proof (rule that( (*‹?as @ xs ! a # ?bs @ xs ! b # ?cs = xs ⟹ thesis›*) 3)) (*goal: ‹(?as::'a list) @ (xs::'a list) ! (a::nat) # (?bs::'a list) @ xs ! (b::nat) # (?cs::'a list) = xs›*) from that(1,2) (*‹a < b› ‹b < length xs›*) have 1: "a < length xs" by simp with that(1,2) (*‹(a::nat) < (b::nat)› ‹(b::nat) < length (xs::'a::type list)›*) have 2: "b - Suc a < length (drop (Suc a) xs)" by simp from that(1) (*‹a < b›*) ‹a < length xs› (*‹a < length xs›*) have eq: "xs ! b = drop (Suc a) xs ! (b - Suc a)" by simp show "(take a xs) @ ((xs ! a) # ((take (b - Suc a) (drop (Suc a) xs)) @ ((xs ! b) # drop (Suc (b - Suc a)) (drop (Suc a) xs)))) = xs" by (simp only: eq (*‹xs ! b = drop (Suc a) xs ! (b - Suc a)›*) id_take_nth_drop[OF 1, symmetric] (*‹take a xs @ xs ! a # drop (Suc a) xs = xs›*) id_take_nth_drop[OF 2, symmetric] (*‹take (b - Suc a) (drop (Suc a) xs) @ drop (Suc a) xs ! (b - Suc a) # drop (Suc (b - Suc a)) (drop (Suc a) xs) = drop (Suc a) xs›*)) qed show "?thesis" (*goal: ‹i = j›*) proof (rule linorder_cases (*‹⟦?x < ?y ⟹ ?P; ?x = ?y ⟹ ?P; ?y < ?x ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹?x < ?y ⟹ i = j› 2. ‹?x = ?y ⟹ i = j› 3. ‹?y < ?x ⟹ i = j›*) assume "i < j" (*‹(i::nat) < (j::nat)›*) then obtain as and bs and cs where "as @ ((xs ! i) # (bs @ ((xs ! j) # cs))) = xs" (*goal: ‹(⋀as bs cs. as @ xs ! i # bs @ xs ! j # cs = xs ⟹ thesis) ⟹ thesis›*) using assms(3) (*‹j < length xs›*) by (rule * (*‹⟦?a < ?b; ?b < length xs; ⋀as bs cs. as @ xs ! ?a # bs @ xs ! ?b # cs = xs ⟹ ?thesis⟧ ⟹ ?thesis›*)) hence "filter P xs = filter P (as @ ((xs ! i) # (bs @ ((xs ! j) # cs))))" by simp also (*calculation: ‹filter P xs = filter P (as @ xs ! i # bs @ xs ! j # cs)›*) from assms(4,5) (*‹P (xs ! i)› ‹P (xs ! j)›*) have "... = (filter P as) @ ((xs ! i) # ((filter P bs) @ ((xs ! j) # (filter P cs))))" by simp finally (*calculation: ‹filter P xs = filter P as @ xs ! i # filter P bs @ xs ! j # filter P cs›*) have "¬ length (filter P xs) ≤ 1" by simp thus "?thesis" (*goal: ‹i = j›*) using assms(1) (*‹length (filter (P::'a ⇒ bool) (xs::'a list)) ≤ (1::nat)›*) by standard next (*goals: 1. ‹i = j ⟹ i = j› 2. ‹j < i ⟹ i = j›*) assume "j < i" (*‹(j::nat) < (i::nat)›*) then obtain as and bs and cs where "as @ ((xs ! j) # (bs @ ((xs ! i) # cs))) = xs" (*goal: ‹(⋀(as::'a::type list) (bs::'a::type list) cs::'a::type list. as @ (xs::'a::type list) ! (j::nat) # bs @ xs ! (i::nat) # cs = xs ⟹ thesis::bool) ⟹ thesis›*) using assms(2) (*‹i < length xs›*) by (rule * (*‹⟦?a < ?b; ?b < length xs; ⋀as bs cs. as @ xs ! ?a # bs @ xs ! ?b # cs = xs ⟹ ?thesis⟧ ⟹ ?thesis›*)) hence "filter P xs = filter P (as @ ((xs ! j) # (bs @ ((xs ! i) # cs))))" by simp also (*calculation: ‹filter P xs = filter P (as @ xs ! j # bs @ xs ! i # cs)›*) from assms(4,5) (*‹P (xs ! i)› ‹(P::'a ⇒ bool) ((xs::'a list) ! (j::nat))›*) have "... = (filter P as) @ ((xs ! j) # ((filter P bs) @ ((xs ! i) # (filter P cs))))" by simp finally (*calculation: ‹filter P xs = filter P as @ xs ! j # filter P bs @ xs ! i # filter P cs›*) have "¬ length (filter P xs) ≤ 1" by simp thus "?thesis" (*goal: ‹i = j›*) using assms(1) (*‹length (filter P xs) ≤ 1›*) by standard qed qed lemma length_filter_eq [simp]: "length (filter ((=) x) xs) = count_list xs x" apply (induct xs) (*goals: 1. ‹length (filter ((=) x) []) = count_list [] x› 2. ‹⋀a xs. length (filter ((=) x) xs) = count_list xs x ⟹ length (filter ((=) x) (a # xs)) = count_list (a # xs) x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . subsubsection ‹@{const drop}› lemma nth_in_set_dropI: assumes "j ≤ i" and "i < length xs" shows "xs ! i ∈ set (drop j xs)" using assms (*‹j ≤ i› ‹i < length xs›*) proof (induct xs arbitrary: i j) (*goals: 1. ‹⋀i j. ⟦j ≤ i; i < length []⟧ ⟹ [] ! i ∈ set (drop j [])› 2. ‹⋀a xs i j. ⟦⋀i j. ⟦j ≤ i; i < length xs⟧ ⟹ xs ! i ∈ set (drop j xs); j ≤ i; i < length (a # xs)⟧ ⟹ (a # xs) ! i ∈ set (drop j (a # xs))›*) case Nil (*‹j ≤ i› ‹i < length []›*) thus "?case" (*goal: ‹[] ! i ∈ set (drop j [])›*) by simp next (*goal: ‹⋀a xs i j. ⟦⋀i j. ⟦j ≤ i; i < length xs⟧ ⟹ xs ! i ∈ set (drop j xs); j ≤ i; i < length (a # xs)⟧ ⟹ (a # xs) ! i ∈ set (drop j (a # xs))›*) case (Cons x xs) (*‹⟦?j ≤ ?i; ?i < length xs⟧ ⟹ xs ! ?i ∈ set (drop ?j xs)› ‹j ≤ i› ‹i < length (x # xs)›*) show "?case" (*goal: ‹(x # xs) ! i ∈ set (drop j (x # xs))›*) proof (cases j) (*goals: 1. ‹(j::nat) = (0::nat) ⟹ ((x::'a) # (xs::'a list)) ! (i::nat) ∈ set (drop j (x # xs))› 2. ‹⋀nat::nat. (j::nat) = Suc nat ⟹ ((x::'a) # (xs::'a list)) ! (i::nat) ∈ set (drop j (x # xs))›*) case 0 (*‹j = 0›*) with Cons(3) (*‹i < length (x # xs)›*) show "?thesis" (*goal: ‹(x # xs) ! i ∈ set (drop j (x # xs))›*) by (metis drop0 (*‹drop (0::nat) = (λx::?'a list. x)›*) nth_mem (*‹(?n::nat) < length (?xs::?'a list) ⟹ ?xs ! ?n ∈ set ?xs›*)) next (*goal: ‹⋀nat. j = Suc nat ⟹ (x # xs) ! i ∈ set (drop j (x # xs))›*) case (Suc j0) (*‹j = Suc j0›*) with Cons(2) (*‹j ≤ i›*) Suc_le_D (*‹Suc ?n ≤ ?m' ⟹ ∃m. ?m' = Suc m›*) obtain i0 where i: "i = Suc i0" (*goal: ‹(⋀i0. i = Suc i0 ⟹ thesis) ⟹ thesis›*) by blast with Cons(2) (*‹j ≤ i›*) have "j0 ≤ i0" by (simp add: ‹j = Suc j0›) moreover from Cons(3) (*‹i < length (x # xs)›*) have "i0 < length xs" by (simp add: i (*‹i = Suc i0›*)) ultimately have "xs ! i0 ∈ set (drop j0 xs)" by (rule Cons( (*‹⟦?j ≤ ?i; ?i < length xs⟧ ⟹ xs ! ?i ∈ set (drop ?j xs)›*) 1)) thus "?thesis" (*goal: ‹(x # xs) ! i ∈ set (drop j (x # xs))›*) by (simp add: i (*‹(i::nat) = Suc (i0::nat)›*) ‹j = Suc j0›) qed qed subsubsection ‹@{const count_list}› lemma count_list_upt [simp]: "count_list [a..<b] x = (if a ≤ x ∧ x < b then 1 else 0)" proof (cases "a ≤ b") (*goals: 1. ‹a ≤ b ⟹ count_list [a..<b] x = (if a ≤ x ∧ x < b then 1 else 0)› 2. ‹¬ a ≤ b ⟹ count_list [a..<b] x = (if a ≤ x ∧ x < b then 1 else 0)›*) case True (*‹a ≤ b›*) then obtain k where "b = a + k" (*goal: ‹(⋀k. b = a + k ⟹ thesis) ⟹ thesis›*) using le_Suc_ex (*‹?k ≤ ?l ⟹ ∃n. ?l = ?k + n›*) by blast show "?thesis" (*goal: ‹count_list [a..<b] x = (if a ≤ x ∧ x < b then 1 else 0)›*) unfolding ‹b = a + k› (*goal: ‹count_list [a..<a + k] x = (if a ≤ x ∧ x < a + k then 1 else 0)›*) apply (induct k) (*goals: 1. ‹count_list [a..<a + 0] x = (if a ≤ x ∧ x < a + 0 then 1 else 0)› 2. ‹⋀k. count_list [a..<a + k] x = (if a ≤ x ∧ x < a + k then 1 else 0) ⟹ count_list [a..<a + Suc k] x = (if a ≤ x ∧ x < a + Suc k then 1 else 0)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . next (*goal: ‹¬ a ≤ b ⟹ count_list [a..<b] x = (if a ≤ x ∧ x < b then 1 else 0)›*) case False (*‹¬ a ≤ b›*) thus "?thesis" (*goal: ‹count_list [a..<b] x = (if a ≤ x ∧ x < b then 1 else 0)›*) by simp qed subsubsection ‹@{const sorted_wrt}› lemma sorted_wrt_upt_iff: "sorted_wrt rel [a..<b] ⟷ (∀i j. a ≤ i ⟶ i < j ⟶ j < b ⟶ rel i j)" proof (cases "a ≤ b") (*goals: 1. ‹a ≤ b ⟹ sorted_wrt rel [a..<b] = (∀i j. a ≤ i ⟶ i < j ⟶ j < b ⟶ rel i j)› 2. ‹¬ a ≤ b ⟹ sorted_wrt rel [a..<b] = (∀i j. a ≤ i ⟶ i < j ⟶ j < b ⟶ rel i j)›*) case True (*‹a ≤ b›*) then obtain k where "b = a + k" (*goal: ‹(⋀k. b = a + k ⟹ thesis) ⟹ thesis›*) using le_Suc_ex (*‹(?k::nat) ≤ (?l::nat) ⟹ ∃n::nat. ?l = ?k + n›*) by blast show "?thesis" (*goal: ‹sorted_wrt rel [a..<b] = (∀i j. a ≤ i ⟶ i < j ⟶ j < b ⟶ rel i j)›*) unfolding ‹b = a + k› (*goal: ‹sorted_wrt rel [a..<a + k] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + k ⟶ rel i j)›*) proof (induct k) (*goals: 1. ‹sorted_wrt rel [a..<a + 0] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + 0 ⟶ rel i j)› 2. ‹⋀k. sorted_wrt rel [a..<a + k] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + k ⟶ rel i j) ⟹ sorted_wrt rel [a..<a + Suc k] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + Suc k ⟶ rel i j)›*) case 0 (*no hyothesis introduced yet*) show "?case" (*goal: ‹sorted_wrt rel [a..<a + 0] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + 0 ⟶ rel i j)›*) by simp next (*goal: ‹⋀k. sorted_wrt rel [a..<a + k] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + k ⟶ rel i j) ⟹ sorted_wrt rel [a..<a + Suc k] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + Suc k ⟶ rel i j)›*) case (Suc k) (*‹sorted_wrt (rel::nat ⇒ nat ⇒ bool) [a::nat..<a + (k::nat)] = (∀(i::nat) j::nat. a ≤ i ⟶ i < j ⟶ j < a + k ⟶ rel i j)›*) show "?case" (*goal: ‹sorted_wrt rel [a..<a + Suc k] = (∀i j. a ≤ i ⟶ i < j ⟶ j < a + Suc k ⟶ rel i j)›*) proof (simp add: sorted_wrt_append (*‹sorted_wrt (?P::?'a ⇒ ?'a ⇒ bool) ((?xs::?'a list) @ (?ys::?'a list)) = (sorted_wrt ?P ?xs ∧ sorted_wrt ?P ?ys ∧ (∀x::?'a∈set ?xs. ∀y::?'a∈set ?ys. ?P x y))›*) Suc (*‹sorted_wrt (rel::nat ⇒ nat ⇒ bool) [a::nat..<a + (k::nat)] = (∀(i::nat) j::nat. a ≤ i ⟶ i < j ⟶ j < a + k ⟶ rel i j)›*), intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*) allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*) conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀i j. ⟦(∀i≥a. ∀j>i. j < a + k ⟶ rel i j) ∧ (∀x∈{a..<a + k}. rel x (a + k)); a ≤ i; i < j; j < Suc (a + k)⟧ ⟹ rel i j› 2. ‹⋀i j. ⟦∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j; a ≤ i; i < j; j < a + k⟧ ⟹ rel i j› 3. ‹⋀x. ⟦∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j; x ∈ {a..<a + k}⟧ ⟹ rel x (a + k)›*) fix i and j assume "(∀i≥a. ∀j>i. j < a + k ⟶ rel i j) ∧ (∀x∈{a..<a + k}. rel x (a + k))" (*‹(∀i≥a::nat. ∀j>i. j < a + (k::nat) ⟶ (rel::nat ⇒ nat ⇒ bool) i j) ∧ (∀x::nat∈{a..<a + k}. rel x (a + k))›*) hence 1: "⋀i' j'. a ≤ i' ⟹ i' < j' ⟹ j' < a + k ⟹ rel i' j'" and 2: "⋀x. a ≤ x ⟹ x < a + k ⟹ rel x (a + k)" apply - (*goals: 1. ‹⋀i' j'. ⟦a ≤ i'; i' < j'; j' < a + k; (∀i≥a. ∀j>i. j < a + k ⟶ rel i j) ∧ (∀x∈{a..<a + k}. rel x (a + k))⟧ ⟹ rel i' j'› 2. ‹⋀x. ⟦a ≤ x; x < a + k; (∀i≥a. ∀j>i. j < a + k ⟶ rel i j) ∧ (∀x∈{a..<a + k}. rel x (a + k))⟧ ⟹ rel x (a + k)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . assume "a ≤ i" and "i < j" (*‹(a::nat) ≤ (i::nat)› ‹(i::nat) < (j::nat)›*) assume "j < Suc (a + k)" (*‹(j::nat) < Suc ((a::nat) + (k::nat))›*) hence "j < a + k ∨ j = a + k" by auto thus "rel i j" proof (standard) (*goals: 1. ‹j < a + k ⟹ rel i j› 2. ‹j = a + k ⟹ rel i j›*) assume "j < a + k" (*‹(j::nat) < (a::nat) + (k::nat)›*) with ‹a ≤ i› (*‹a ≤ i›*) ‹i < j› (*‹(i::nat) < (j::nat)›*) show "?thesis" (*goal: ‹(rel::nat ⇒ nat ⇒ bool) (i::nat) (j::nat)›*) by (rule 1 (*‹⟦a ≤ ?i'; ?i' < ?j'; ?j' < a + k⟧ ⟹ rel ?i' ?j'›*)) next (*goal: ‹j = a + k ⟹ rel i j›*) assume "j = a + k" (*‹(j::nat) = (a::nat) + (k::nat)›*) from ‹a ≤ i› (*‹a ≤ i›*) ‹i < j› (*‹(i::nat) < (j::nat)›*) show "?thesis" (*goal: ‹rel i j›*) unfolding ‹j = a + k› (*goal: ‹rel i (a + k)›*) by (rule 2 (*‹⟦a ≤ ?x; ?x < a + k⟧ ⟹ rel ?x (a + k)›*)) qed next (*goals: 1. ‹⋀i j. ⟦∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j; a ≤ i; i < j; j < a + k⟧ ⟹ rel i j› 2. ‹⋀x. ⟦∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j; x ∈ {a..<a + k}⟧ ⟹ rel x (a + k)›*) fix i and j assume "∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j" and "a ≤ i" and "i < j" and "j < a + k" (*‹∀i≥a::nat. ∀j>i. j < Suc (a + (k::nat)) ⟶ (rel::nat ⇒ nat ⇒ bool) i j› ‹(a::nat) ≤ (i::nat)› ‹(i::nat) < (j::nat)› ‹(j::nat) < (a::nat) + (k::nat)›*) thus "rel i j" by simp next (*goal: ‹⋀x. ⟦∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j; x ∈ {a..<a + k}⟧ ⟹ rel x (a + k)›*) fix x assume "x ∈ {a..<a + k}" (*‹(x::nat) ∈ {a::nat..<a + (k::nat)}›*) hence "a ≤ x" and "x < a + k" apply - (*goals: 1. ‹x ∈ {a..<a + k} ⟹ a ≤ x› 2. ‹x ∈ {a..<a + k} ⟹ x < a + k› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . moreover assume "∀i≥a. ∀j>i. j < Suc (a + k) ⟶ rel i j" (*‹∀i≥a::nat. ∀j>i. j < Suc (a + (k::nat)) ⟶ (rel::nat ⇒ nat ⇒ bool) i j›*) ultimately show "rel x (a + k)" by simp qed qed next (*goal: ‹¬ a ≤ b ⟹ sorted_wrt rel [a..<b] = (∀i j. a ≤ i ⟶ i < j ⟶ j < b ⟶ rel i j)›*) case False (*‹¬ a ≤ b›*) thus "?thesis" (*goal: ‹sorted_wrt rel [a..<b] = (∀i j. a ≤ i ⟶ i < j ⟶ j < b ⟶ rel i j)›*) by simp qed subsubsection ‹@{const insort_wrt} and @{const merge_wrt}› lemma map_insort_wrt: assumes "⋀x. x ∈ set xs ⟹ r2 (f y) (f x) ⟷ r1 y x" shows "map f (insort_wrt r1 y xs) = insort_wrt r2 (f y) (map f xs)" using assms (*‹?x ∈ set xs ⟹ r2 (f y) (f ?x) = r1 y ?x›*) proof (induct xs) (*goals: 1. ‹(⋀x. x ∈ set [] ⟹ r2 (f y) (f x) = r1 y x) ⟹ map f (insort_wrt r1 y []) = insort_wrt r2 (f y) (map f [])› 2. ‹⋀a xs. ⟦(⋀x. x ∈ set xs ⟹ r2 (f y) (f x) = r1 y x) ⟹ map f (insort_wrt r1 y xs) = insort_wrt r2 (f y) (map f xs); ⋀x. x ∈ set (a # xs) ⟹ r2 (f y) (f x) = r1 y x⟧ ⟹ map f (insort_wrt r1 y (a # xs)) = insort_wrt r2 (f y) (map f (a # xs))›*) case Nil (*‹?x ∈ set [] ⟹ r2 (f y) (f ?x) = r1 y ?x›*) show "?case" (*goal: ‹map f (insort_wrt r1 y []) = insort_wrt r2 (f y) (map f [])›*) by simp next (*goal: ‹⋀a xs. ⟦(⋀x. x ∈ set xs ⟹ r2 (f y) (f x) = r1 y x) ⟹ map f (insort_wrt r1 y xs) = insort_wrt r2 (f y) (map f xs); ⋀x. x ∈ set (a # xs) ⟹ r2 (f y) (f x) = r1 y x⟧ ⟹ map f (insort_wrt r1 y (a # xs)) = insort_wrt r2 (f y) (map f (a # xs))›*) case (Cons x xs) (*‹(⋀x. x ∈ set xs ⟹ r2 (f y) (f x) = r1 y x) ⟹ map f (insort_wrt r1 y xs) = insort_wrt r2 (f y) (map f xs)› ‹?x ∈ set (x # xs) ⟹ r2 (f y) (f ?x) = r1 y ?x›*) have "x ∈ set (x # xs)" by simp hence "r2 (f y) (f x) = r1 y x" by (rule Cons( (*‹?x ∈ set (x # xs) ⟹ r2 (f y) (f ?x) = r1 y ?x›*) 2)) moreover have "map f (insort_wrt r1 y xs) = insort_wrt r2 (f y) (map f xs)" proof (rule Cons( (*‹(⋀x. x ∈ set xs ⟹ r2 (f y) (f x) = r1 y x) ⟹ map f (insort_wrt r1 y xs) = insort_wrt r2 (f y) (map f xs)›*) 1)) (*goal: ‹⋀x. x ∈ set xs ⟹ r2 (f y) (f x) = r1 y x›*) fix x' assume "x' ∈ set xs" (*‹(x'::'a) ∈ set (xs::'a list)›*) hence "x' ∈ set (x # xs)" by simp thus "r2 (f y) (f x') = r1 y x'" by (rule Cons( (*‹?x ∈ set (x # xs) ⟹ r2 (f y) (f ?x) = r1 y ?x›*) 2)) qed ultimately show "?case" (*goal: ‹map f (insort_wrt r1 y (x # xs)) = insort_wrt r2 (f y) (map f (x # xs))›*) by simp qed lemma map_merge_wrt: assumes "f ` set xs ∩ f ` set ys = {}" and "⋀x y. x ∈ set xs ⟹ y ∈ set ys ⟹ r2 (f x) (f y) ⟷ r1 x y" shows "map f (merge_wrt r1 xs ys) = merge_wrt r2 (map f xs) (map f ys)" using assms (*‹f ` set xs ∩ f ` set ys = {}› ‹⟦?x ∈ set xs; ?y ∈ set ys⟧ ⟹ r2 (f ?x) (f ?y) = r1 ?x ?y›*) proof (induct r1 xs ys rule: merge_wrt.induct (*‹⟦⋀uu_ xs. ?P uu_ xs []; ⋀rel v va. ?P rel [] (v # va); ⋀rel x xs y ys. ⟦x = y ⟹ ?P rel xs ys; ⟦x ≠ y; rel x y⟧ ⟹ ?P rel xs (y # ys); ⟦x ≠ y; ¬ rel x y⟧ ⟹ ?P rel (x # xs) ys⟧ ⟹ ?P rel (x # xs) (y # ys)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀uu_ xs. ⟦f ` set xs ∩ f ` set [] = {}; ⋀x y. ⟦x ∈ set xs; y ∈ set []⟧ ⟹ r2 (f x) (f y) = uu_ x y⟧ ⟹ map f (merge_wrt uu_ xs []) = merge_wrt r2 (map f xs) (map f [])› 2. ‹⋀rel v va. ⟦f ` set [] ∩ f ` set (v # va) = {}; ⋀x y. ⟦x ∈ set []; y ∈ set (v # va)⟧ ⟹ r2 (f x) (f y) = rel x y⟧ ⟹ map f (merge_wrt rel [] (v # va)) = merge_wrt r2 (map f []) (map f (v # va))› 3. ‹⋀rel x xs y ys. ⟦⟦x = y; f ` set xs ∩ f ` set ys = {}; ⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ r2 (f x) (f y) = rel x y⟧ ⟹ map f (merge_wrt rel xs ys) = merge_wrt r2 (map f xs) (map f ys); ⟦x ≠ y; rel x y; f ` set xs ∩ f ` set (y # ys) = {}; ⋀x ya. ⟦x ∈ set xs; ya ∈ set (y # ys)⟧ ⟹ r2 (f x) (f ya) = rel x ya⟧ ⟹ map f (merge_wrt rel xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys)); ⟦x ≠ y; ¬ rel x y; f ` set (x # xs) ∩ f ` set ys = {}; ⋀xa y. ⟦xa ∈ set (x # xs); y ∈ set ys⟧ ⟹ r2 (f xa) (f y) = rel xa y⟧ ⟹ map f (merge_wrt rel (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys); f ` set (x # xs) ∩ f ` set (y # ys) = {}; ⋀xa ya. ⟦xa ∈ set (x # xs); ya ∈ set (y # ys)⟧ ⟹ r2 (f xa) (f ya) = rel xa ya⟧ ⟹ map f (merge_wrt rel (x # xs) (y # ys)) = merge_wrt r2 (map f (x # xs)) (map f (y # ys))›*) case (1 uu xs) (*‹f ` set xs ∩ f ` set [] = {}› ‹⟦?x ∈ set xs; ?y ∈ set []⟧ ⟹ r2 (f ?x) (f ?y) = uu ?x ?y›*) show "?case" (*goal: ‹map (f::'b ⇒ 'a) (merge_wrt (uu::'b ⇒ 'b ⇒ bool) (xs::'b list) []) = merge_wrt (r2::'a ⇒ 'a ⇒ bool) (map f xs) (map f [])›*) by simp next (*goals: 1. ‹⋀rel v va. ⟦f ` set [] ∩ f ` set (v # va) = {}; ⋀x y. ⟦x ∈ set []; y ∈ set (v # va)⟧ ⟹ r2 (f x) (f y) = rel x y⟧ ⟹ map f (merge_wrt rel [] (v # va)) = merge_wrt r2 (map f []) (map f (v # va))› 2. ‹⋀rel x xs y ys. ⟦⟦x = y; f ` set xs ∩ f ` set ys = {}; ⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ r2 (f x) (f y) = rel x y⟧ ⟹ map f (merge_wrt rel xs ys) = merge_wrt r2 (map f xs) (map f ys); ⟦x ≠ y; rel x y; f ` set xs ∩ f ` set (y # ys) = {}; ⋀x ya. ⟦x ∈ set xs; ya ∈ set (y # ys)⟧ ⟹ r2 (f x) (f ya) = rel x ya⟧ ⟹ map f (merge_wrt rel xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys)); ⟦x ≠ y; ¬ rel x y; f ` set (x # xs) ∩ f ` set ys = {}; ⋀xa y. ⟦xa ∈ set (x # xs); y ∈ set ys⟧ ⟹ r2 (f xa) (f y) = rel xa y⟧ ⟹ map f (merge_wrt rel (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys); f ` set (x # xs) ∩ f ` set (y # ys) = {}; ⋀xa ya. ⟦xa ∈ set (x # xs); ya ∈ set (y # ys)⟧ ⟹ r2 (f xa) (f ya) = rel xa ya⟧ ⟹ map f (merge_wrt rel (x # xs) (y # ys)) = merge_wrt r2 (map f (x # xs)) (map f (y # ys))›*) case (2 r1 v va) (*‹f ` set [] ∩ f ` set (v # va) = {}› ‹⟦(?x::'b) ∈ set []; (?y::'b) ∈ set ((v::'b) # (va::'b list))⟧ ⟹ (r2::'a ⇒ 'a ⇒ bool) ((f::'b ⇒ 'a) ?x) (f ?y) = (r1::'b ⇒ 'b ⇒ bool) ?x ?y›*) show "?case" (*goal: ‹map (f::'b ⇒ 'a) (merge_wrt (r1::'b ⇒ 'b ⇒ bool) [] ((v::'b) # (va::'b list))) = merge_wrt (r2::'a ⇒ 'a ⇒ bool) (map f []) (map f (v # va))›*) by simp next (*goal: ‹⋀rel x xs y ys. ⟦⟦x = y; f ` set xs ∩ f ` set ys = {}; ⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ r2 (f x) (f y) = rel x y⟧ ⟹ map f (merge_wrt rel xs ys) = merge_wrt r2 (map f xs) (map f ys); ⟦x ≠ y; rel x y; f ` set xs ∩ f ` set (y # ys) = {}; ⋀x ya. ⟦x ∈ set xs; ya ∈ set (y # ys)⟧ ⟹ r2 (f x) (f ya) = rel x ya⟧ ⟹ map f (merge_wrt rel xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys)); ⟦x ≠ y; ¬ rel x y; f ` set (x # xs) ∩ f ` set ys = {}; ⋀xa y. ⟦xa ∈ set (x # xs); y ∈ set ys⟧ ⟹ r2 (f xa) (f y) = rel xa y⟧ ⟹ map f (merge_wrt rel (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys); f ` set (x # xs) ∩ f ` set (y # ys) = {}; ⋀xa ya. ⟦xa ∈ set (x # xs); ya ∈ set (y # ys)⟧ ⟹ r2 (f xa) (f ya) = rel xa ya⟧ ⟹ map f (merge_wrt rel (x # xs) (y # ys)) = merge_wrt r2 (map f (x # xs)) (map f (y # ys))›*) case (3 r1 x xs y ys) (*‹⟦x = y; f ` set xs ∩ f ` set ys = {}; ⋀x y. ⟦x ∈ set xs; y ∈ set ys⟧ ⟹ r2 (f x) (f y) = r1 x y⟧ ⟹ map f (merge_wrt r1 xs ys) = merge_wrt r2 (map f xs) (map f ys)› ‹⟦x ≠ y; r1 x y; f ` set xs ∩ f ` set (y # ys) = {}; ⋀x ya. ⟦x ∈ set xs; ya ∈ set (y # ys)⟧ ⟹ r2 (f x) (f ya) = r1 x ya⟧ ⟹ map f (merge_wrt r1 xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys))› ‹⟦x ≠ y; ¬ r1 x y; f ` set (x # xs) ∩ f ` set ys = {}; ⋀xa y. ⟦xa ∈ set (x # xs); y ∈ set ys⟧ ⟹ r2 (f xa) (f y) = r1 xa y⟧ ⟹ map f (merge_wrt r1 (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys)› ‹f ` set (x # xs) ∩ f ` set (y # ys) = {}› ‹⟦(?x::'b::type) ∈ set ((x::'b::type) # (xs::'b::type list)); (?y::'b::type) ∈ set ((y::'b::type) # (ys::'b::type list))⟧ ⟹ (r2::'a::type ⇒ 'a::type ⇒ bool) ((f::'b::type ⇒ 'a::type) ?x) (f ?y) = (r1::'b::type ⇒ 'b::type ⇒ bool) ?x ?y›*) from "3"(4) (*‹f ` set (x # xs) ∩ f ` set (y # ys) = {}›*) have "f x ≠ f y" and 1: "f ` set xs ∩ f ` set (y # ys) = {}" and 2: "f ` set (x # xs) ∩ f ` set ys = {}" apply - (*goals: 1. ‹f ` set (x # xs) ∩ f ` set (y # ys) = {} ⟹ f x ≠ f y› 2. ‹f ` set (x # xs) ∩ f ` set (y # ys) = {} ⟹ f ` set xs ∩ f ` set (y # ys) = {}› 3. ‹f ` set (x # xs) ∩ f ` set (y # ys) = {} ⟹ f ` set (x # xs) ∩ f ` set ys = {}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . from this(1) (*‹f x ≠ f y›*) have "x ≠ y" by auto have eq2: "map f (merge_wrt r1 xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys))" if "r1 x y" using ‹x ≠ y› (*‹x ≠ y›*) that (*‹r1 x y›*) "1" (*‹f ` set xs ∩ f ` set (y # ys) = {}›*) proof (rule 3( (*‹⟦x ≠ y; r1 x y; f ` set xs ∩ f ` set (y # ys) = {}; ⋀x ya. ⟦x ∈ set xs; ya ∈ set (y # ys)⟧ ⟹ r2 (f x) (f ya) = r1 x ya⟧ ⟹ map f (merge_wrt r1 xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys))›*) 2)) (*goal: ‹⋀x ya. ⟦x ∈ set xs; ya ∈ set (y # ys)⟧ ⟹ r2 (f x) (f ya) = r1 x ya›*) fix a and b assume "a ∈ set xs" (*‹(a::'b) ∈ set (xs::'b list)›*) hence "a ∈ set (x # xs)" by simp moreover assume "b ∈ set (y # ys)" (*‹(b::'b) ∈ set ((y::'b) # (ys::'b list))›*) ultimately show "r2 (f a) (f b) ⟷ r1 a b" by (rule 3( (*‹⟦?x ∈ set (x # xs); ?y ∈ set (y # ys)⟧ ⟹ r2 (f ?x) (f ?y) = r1 ?x ?y›*) 5)) qed have eq3: "map f (merge_wrt r1 (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys)" if "¬ r1 x y" using ‹x ≠ y› (*‹x ≠ y›*) that (*‹¬ r1 x y›*) "2" (*‹(f::'b::type ⇒ 'a::type) ` set ((x::'b::type) # (xs::'b::type list)) ∩ f ` set (ys::'b::type list) = {}›*) proof (rule 3( (*‹⟦x ≠ y; ¬ r1 x y; f ` set (x # xs) ∩ f ` set ys = {}; ⋀xa y. ⟦xa ∈ set (x # xs); y ∈ set ys⟧ ⟹ r2 (f xa) (f y) = r1 xa y⟧ ⟹ map f (merge_wrt r1 (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys)›*) 3)) (*goal: ‹⋀xa y. ⟦xa ∈ set (x # xs); y ∈ set ys⟧ ⟹ r2 (f xa) (f y) = r1 xa y›*) fix a and b assume "a ∈ set (x # xs)" (*‹(a::'b) ∈ set ((x::'b) # (xs::'b list))›*) assume "b ∈ set ys" (*‹(b::'b) ∈ set (ys::'b list)›*) hence "b ∈ set (y # ys)" by simp with ‹a ∈ set (x # xs)› (*‹a ∈ set (x # xs)›*) show "r2 (f a) (f b) ⟷ r1 a b" by (rule 3( (*‹⟦?x ∈ set (x # xs); ?y ∈ set (y # ys)⟧ ⟹ r2 (f ?x) (f ?y) = r1 ?x ?y›*) 5)) qed have eq4: "r2 (f x) (f y) ⟷ r1 x y" apply (rule 3( (*‹⟦?x ∈ set (x # xs); ?y ∈ set (y # ys)⟧ ⟹ r2 (f ?x) (f ?y) = r1 ?x ?y›*) 5)) (*goals: 1. ‹x ∈ set (x # xs)› 2. ‹y ∈ set (y # ys)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . show "?case" (*goal: ‹map f (merge_wrt r1 (x # xs) (y # ys)) = merge_wrt r2 (map f (x # xs)) (map f (y # ys))›*) by (simp add: eq2 (*‹r1 x y ⟹ map f (merge_wrt r1 xs (y # ys)) = merge_wrt r2 (map f xs) (map f (y # ys))›*) eq3 (*‹¬ r1 x y ⟹ map f (merge_wrt r1 (x # xs) ys) = merge_wrt r2 (map f (x # xs)) (map f ys)›*) eq4 (*‹r2 (f x) (f y) = r1 x y›*) ‹f x ≠ f y› ‹x ≠ y›) qed subsection ‹Recursive Functions› locale recursive = fixes h' :: "'b ⇒ 'b" fixes b :: 'b assumes b_fixpoint: "h' b = b" begin context fixes Q :: "'a ⇒ bool" fixes g :: "'a ⇒ 'b" fixes h :: "'a ⇒ 'a" begin function (domintros) recfun_aux :: "'a ⇒ 'b" where "recfun_aux x = (if Q x then g x else h' (recfun_aux (h x)))" by pat_completeness auto lemmas [induct del] = recfun_aux.pinduct definition dom :: "'a ⇒ bool" where "dom x ⟷ (∃k. Q ((h ^^ k) x))" lemma domI: assumes "¬ Q x ⟹ dom (h x)" shows "dom x" proof (cases "Q x") (*goals: 1. ‹(Q::'a::type ⇒ bool) (x::'a::type) ⟹ local.dom x› 2. ‹¬ (Q::'a::type ⇒ bool) (x::'a::type) ⟹ local.dom x›*) case True (*‹Q x›*) hence "Q ((h ^^ 0) x)" by simp thus "?thesis" (*goal: ‹local.dom (x::'a)›*) unfolding dom_def (*goal: ‹∃k. Q ((h ^^ k) x)›*) by standard next (*goal: ‹¬ Q x ⟹ local.dom x›*) case False (*‹¬ (Q::'a ⇒ bool) (x::'a)›*) hence "dom (h x)" by (rule assms (*‹¬ (Q::'a ⇒ bool) (x::'a) ⟹ local.dom ((h::'a ⇒ 'a) x)›*)) then obtain k where "Q ((h ^^ k) (h x))" (*goal: ‹(⋀k::nat. (Q::'a ⇒ bool) (((h::'a ⇒ 'a) ^^ k) (h (x::'a))) ⟹ thesis::bool) ⟹ thesis›*) unfolding dom_def (*goal: ‹(⋀k. Q ((h ^^ k) (h x)) ⟹ thesis) ⟹ thesis›*) by standard hence "Q ((h ^^ (Suc k)) x)" by (simp add: funpow_swap1 (*‹?f ((?f ^^ ?n) ?x) = (?f ^^ ?n) (?f ?x)›*)) thus "?thesis" (*goal: ‹local.dom (x::'a)›*) unfolding dom_def (*goal: ‹∃k. Q ((h ^^ k) x)›*) by standard qed lemma domD: assumes "dom x" and "¬ Q x" shows "dom (h x)" proof (-) (*goal: ‹local.dom (h x)›*) from assms(1) (*‹local.dom x›*) obtain k where "*": "Q ((h ^^ k) x)" (*goal: ‹(⋀k. Q ((h ^^ k) x) ⟹ thesis) ⟹ thesis›*) unfolding dom_def (*goal: ‹(⋀k. Q ((h ^^ k) x) ⟹ thesis) ⟹ thesis›*) by standard with assms(2) (*‹¬ Q x›*) have "k ≠ 0" using funpow_0 (*‹(?f ^^ 0) ?x = ?x›*) by fastforce then obtain m where "k = Suc m" (*goal: ‹(⋀m. k = Suc m ⟹ thesis) ⟹ thesis›*) using nat.exhaust (*‹⟦?y = 0 ⟹ ?P; ⋀x2. ?y = Suc x2 ⟹ ?P⟧ ⟹ ?P›*) by blast with "*" (*‹Q ((h ^^ k) x)›*) have "Q ((h ^^ m) (h x))" by (simp add: funpow_swap1 (*‹(?f::?'a ⇒ ?'a) ((?f ^^ (?n::nat)) (?x::?'a)) = (?f ^^ ?n) (?f ?x)›*)) thus "?thesis" (*goal: ‹local.dom (h x)›*) unfolding dom_def (*goal: ‹∃k. Q ((h ^^ k) (h x))›*) by standard qed lemma recfun_aux_domI: assumes "dom x" shows "recfun_aux_dom x" proof (-) (*goal: ‹recfun_aux_dom x›*) from assms (*‹local.dom x›*) obtain k where "Q ((h ^^ k) x)" (*goal: ‹(⋀k. Q ((h ^^ k) x) ⟹ thesis) ⟹ thesis›*) unfolding dom_def (*goal: ‹(⋀k. Q ((h ^^ k) x) ⟹ thesis) ⟹ thesis›*) by standard thus "?thesis" (*goal: ‹recfun_aux_dom x›*) proof (induct k arbitrary: x) (*goals: 1. ‹⋀x. Q ((h ^^ 0) x) ⟹ recfun_aux_dom x› 2. ‹⋀k x. ⟦⋀x. Q ((h ^^ k) x) ⟹ recfun_aux_dom x; Q ((h ^^ Suc k) x)⟧ ⟹ recfun_aux_dom x›*) case 0 (*‹Q ((h ^^ 0) x)›*) hence "Q x" by simp with recfun_aux.domintros (*‹(¬ Q ?x ⟹ recfun_aux_dom (h ?x)) ⟹ recfun_aux_dom ?x›*) show "?case" (*goal: ‹recfun_aux_dom x›*) by blast next (*goal: ‹⋀k x. ⟦⋀x. Q ((h ^^ k) x) ⟹ recfun_aux_dom x; Q ((h ^^ Suc k) x)⟧ ⟹ recfun_aux_dom x›*) case (Suc k) (*‹(Q::'a::type ⇒ bool) (((h::'a::type ⇒ 'a::type) ^^ (k::nat)) (?x::'a::type)) ⟹ recfun_aux_dom ?x› ‹(Q::'a ⇒ bool) (((h::'a ⇒ 'a) ^^ Suc (k::nat)) (x::'a))›*) from Suc(2) (*‹Q ((h ^^ Suc k) x)›*) have "Q ((h ^^ k) (h x))" by (simp add: funpow_swap1 (*‹?f ((?f ^^ ?n) ?x) = (?f ^^ ?n) (?f ?x)›*)) hence "recfun_aux_dom (h x)" by (rule Suc( (*‹Q ((h ^^ k) ?x) ⟹ recfun_aux_dom ?x›*) 1)) with recfun_aux.domintros (*‹(¬ Q ?x ⟹ recfun_aux_dom (h ?x)) ⟹ recfun_aux_dom ?x›*) show "?case" (*goal: ‹recfun_aux_dom x›*) by blast qed qed lemma recfun_aux_domD: assumes "recfun_aux_dom x" shows "dom x" using assms (*‹recfun_aux_dom x›*) proof (induct x rule: recfun_aux.pinduct (*‹⟦recfun_aux_dom ?a0.0; ⋀x. ⟦recfun_aux_dom x; ¬ Q x ⟹ ?P (h x)⟧ ⟹ ?P x⟧ ⟹ ?P ?a0.0›*)) (*goal: ‹⋀x. ⟦recfun_aux_dom x; ¬ Q x ⟹ local.dom (h x)⟧ ⟹ local.dom x›*) case (1 x) (*‹recfun_aux_dom x› ‹¬ Q x ⟹ local.dom (h x)›*) show "?case" (*goal: ‹local.dom x›*) proof (cases "Q x") (*goals: 1. ‹Q x ⟹ local.dom x› 2. ‹¬ Q x ⟹ local.dom x›*) case True (*‹Q x›*) with domI (*‹(¬ (Q::'a ⇒ bool) (?x::'a) ⟹ local.dom ((h::'a ⇒ 'a) ?x)) ⟹ local.dom ?x›*) show "?thesis" (*goal: ‹local.dom x›*) by blast next (*goal: ‹¬ Q x ⟹ local.dom x›*) case False (*‹¬ Q x›*) hence "dom (h x)" by (rule 1( (*‹¬ (Q::'a ⇒ bool) (x::'a) ⟹ local.dom ((h::'a ⇒ 'a) x)›*) 2)) thus "?thesis" (*goal: ‹local.dom (x::'a)›*) using domI (*‹(¬ Q ?x ⟹ local.dom (h ?x)) ⟹ local.dom ?x›*) by blast qed qed corollary recfun_aux_dom_alt: "recfun_aux_dom = dom" by (auto dest: recfun_aux_domI (*‹local.dom ?x ⟹ recfun_aux_dom ?x›*) recfun_aux_domD (*‹recfun_aux_dom ?x ⟹ local.dom ?x›*)) definition "fun" :: "'a ⇒ 'b" where "fun x = (if recfun_aux_dom x then recfun_aux x else b)" lemma simps: "fun x = (if Q x then g x else h' (fun (h x)))" proof (cases "dom x") (*goals: 1. ‹local.dom (x::'a) ⟹ fun x = (if (Q::'a ⇒ bool) x then (g::'a ⇒ 'b) x else (h'::'b ⇒ 'b) (fun ((h::'a ⇒ 'a) x)))› 2. ‹¬ local.dom (x::'a) ⟹ fun x = (if (Q::'a ⇒ bool) x then (g::'a ⇒ 'b) x else (h'::'b ⇒ 'b) (fun ((h::'a ⇒ 'a) x)))›*) case True (*‹local.dom x›*) hence dom: "recfun_aux_dom x" by (rule recfun_aux_domI (*‹local.dom (?x::'a::type) ⟹ recfun_aux_dom ?x›*)) show "?thesis" (*goal: ‹fun x = (if Q x then g x else h' (fun (h x)))›*) proof (cases "Q x") (*goals: 1. ‹Q x ⟹ fun x = (if Q x then g x else h' (fun (h x)))› 2. ‹¬ Q x ⟹ fun x = (if Q x then g x else h' (fun (h x)))›*) case True (*‹(Q::'a ⇒ bool) (x::'a)›*) with dom (*‹recfun_aux_dom x›*) show "?thesis" (*goal: ‹fun (x::'a::type) = (if (Q::'a::type ⇒ bool) x then (g::'a::type ⇒ 'b::type) x else (h'::'b::type ⇒ 'b::type) (fun ((h::'a::type ⇒ 'a::type) x)))›*) by (simp add: fun_def (*‹fun ?x = (if recfun_aux_dom ?x then recfun_aux ?x else b)›*) recfun_aux.psimps (*‹recfun_aux_dom ?x ⟹ recfun_aux ?x = (if Q ?x then g ?x else h' (recfun_aux (h ?x)))›*)) next (*goal: ‹¬ Q x ⟹ fun x = (if Q x then g x else h' (fun (h x)))›*) case False (*‹¬ Q x›*) have "recfun_aux_dom (h x)" apply (rule recfun_aux_domI (*‹local.dom ?x ⟹ recfun_aux_dom ?x›*)) (*goal: ‹recfun_aux_dom ((h::'a ⇒ 'a) (x::'a))›*) apply (rule domD (*‹⟦local.dom (?x::'a::type); ¬ (Q::'a::type ⇒ bool) ?x⟧ ⟹ local.dom ((h::'a::type ⇒ 'a::type) ?x)›*)) (*goals: 1. ‹local.dom x› 2. ‹¬ Q x› discuss goal 1*) apply (fact True (*‹local.dom (x::'a)›*)) (*discuss goal 2*) apply (fact False (*‹¬ Q x›*)) (*proven 2 subgoals*) . thus "?thesis" (*goal: ‹fun x = (if Q x then g x else h' (fun (h x)))›*) by (simp add: fun_def (*‹fun ?x = (if recfun_aux_dom ?x then recfun_aux ?x else b)›*) dom (*‹recfun_aux_dom x›*) False (*‹¬ Q x›*) recfun_aux.psimps (*‹recfun_aux_dom ?x ⟹ recfun_aux ?x = (if Q ?x then g ?x else h' (recfun_aux (h ?x)))›*)) qed next (*goal: ‹¬ local.dom x ⟹ fun x = (if Q x then g x else h' (fun (h x)))›*) case False (*‹¬ local.dom x›*) moreover have "¬ Q x" proof (standard) (*goal: ‹(Q::'a ⇒ bool) (x::'a) ⟹ False›*) assume "Q x" (*‹(Q::'a ⇒ bool) (x::'a)›*) hence "dom x" using domI (*‹(¬ Q ?x ⟹ local.dom (h ?x)) ⟹ local.dom ?x›*) by blast with False (*‹¬ local.dom x›*) show False by standard qed moreover have "¬ dom (h x)" proof (standard) (*goal: ‹local.dom ((h::'a::type ⇒ 'a::type) (x::'a::type)) ⟹ False›*) assume "dom (h x)" (*‹local.dom ((h::'a ⇒ 'a) (x::'a))›*) hence "dom x" using domI (*‹(¬ (Q::'a ⇒ bool) (?x::'a) ⟹ local.dom ((h::'a ⇒ 'a) ?x)) ⟹ local.dom ?x›*) by blast with False (*‹¬ local.dom x›*) show False by standard qed ultimately show "?thesis" (*goal: ‹fun x = (if Q x then g x else h' (fun (h x)))›*) by (simp add: recfun_aux_dom_alt (*‹recfun_aux_dom = local.dom›*) fun_def (*‹fun ?x = (if recfun_aux_dom ?x then recfun_aux ?x else b)›*) b_fixpoint (*‹h' b = b›*) split del: if_split (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))›*)) qed lemma eq_fixpointI: "¬ dom x ⟹ fun x = b" by (simp add: fun_def (*‹fun ?x = (if recfun_aux_dom ?x then recfun_aux ?x else b)›*) recfun_aux_dom_alt (*‹recfun_aux_dom = local.dom›*)) lemma pinduct: "dom x ⟹ (⋀x. dom x ⟹ (¬ Q x ⟹ P (h x)) ⟹ P x) ⟹ P x" unfolding recfun_aux_dom_alt[symmetric] (*goal: ‹⟦recfun_aux_dom x; ⋀x. ⟦recfun_aux_dom x; ¬ Q x ⟹ P (h x)⟧ ⟹ P x⟧ ⟹ P x›*) by (fact recfun_aux.pinduct (*‹⟦recfun_aux_dom ?a0.0; ⋀x. ⟦recfun_aux_dom x; ¬ Q x ⟹ ?P (h x)⟧ ⟹ ?P x⟧ ⟹ ?P ?a0.0›*)) end end (* recursive *) interpretation tailrec: recursive "λx. x" undefined apply standard (*goal: ‹recursive (λx::'a. x) undefined›*) by (fact refl (*‹?t = ?t›*)) subsection ‹Binary Relations› lemma almost_full_on_Int: assumes "almost_full_on P1 A1" and "almost_full_on P2 A2" shows "almost_full_on (λx y. P1 x y ∧ P2 x y) (A1 ∩ A2)" (is "almost_full_on ?P ?A") proof (rule almost_full_onI (*‹(⋀f. ∀i. f i ∈ ?A ⟹ good ?P f) ⟹ almost_full_on ?P ?A›*)) (*goal: ‹⋀f. ∀i. f i ∈ A1 ∩ A2 ⟹ good (λx y. P1 x y ∧ P2 x y) f›*) fix f :: "nat ⇒ 'a" assume a: "∀i. f i ∈ ?A" (*‹∀i::nat. (f::nat ⇒ 'a) i ∈ (A1::'a set) ∩ (A2::'a set)›*) define g where "g = (λi. (f i, f i))" from assms (*‹almost_full_on P1 A1› ‹almost_full_on P2 A2›*) have "almost_full_on (prod_le P1 P2) (A1 × A2)" by (rule almost_full_on_Sigma (*‹⟦almost_full_on ?P1.0 ?A1.0; almost_full_on ?P2.0 ?A2.0⟧ ⟹ almost_full_on (prod_le ?P1.0 ?P2.0) (?A1.0 × ?A2.0)›*)) moreover from a (*‹∀i. f i ∈ A1 ∩ A2›*) have "⋀i. g i ∈ A1 × A2" by (simp add: g_def (*‹g = (λi. (f i, f i))›*)) ultimately obtain i and j where "i < j" and "prod_le P1 P2 (g i) (g j)" (*goal: ‹(⋀i j. ⟦i < j; prod_le P1 P2 (g i) (g j)⟧ ⟹ thesis) ⟹ thesis›*) by (rule almost_full_onD (*‹⟦almost_full_on (?P::?'a ⇒ ?'a ⇒ bool) (?A::?'a set); ⋀i::nat. (?f::nat ⇒ ?'a) i ∈ ?A; ⋀(i::nat) j::nat. ⟦i < j; ?P (?f i) (?f j)⟧ ⟹ ?thesis::bool⟧ ⟹ ?thesis›*)) from this(2) (*‹prod_le (P1::'a ⇒ 'a ⇒ bool) (P2::'a ⇒ 'a ⇒ bool) ((g::nat ⇒ 'a × 'a) (i::nat)) (g (j::nat))›*) have "?P (f i) (f j)" by (simp add: g_def (*‹g = (λi. (f i, f i))›*) prod_le_def (*‹prod_le ?P1.0 ?P2.0 = (λ(p1, p2) (q1, q2). ?P1.0 p1 q1 ∧ ?P2.0 p2 q2)›*)) with ‹i < j› (*‹i < j›*) show "good ?P f" by (rule goodI (*‹⟦?i < ?j; ?P (?f ?i) (?f ?j)⟧ ⟹ good ?P ?f›*)) qed corollary almost_full_on_same: assumes "almost_full_on P1 A" and "almost_full_on P2 A" shows "almost_full_on (λx y. P1 x y ∧ P2 x y) A" proof (-) (*goal: ‹almost_full_on (λ(x::'a) y::'a. (P1::'a ⇒ 'a ⇒ bool) x y ∧ (P2::'a ⇒ 'a ⇒ bool) x y) (A::'a set)›*) from assms (*‹almost_full_on P1 A› ‹almost_full_on P2 A›*) have "almost_full_on (λx y. P1 x y ∧ P2 x y) (A ∩ A)" by (rule almost_full_on_Int (*‹⟦almost_full_on ?P1.0 ?A1.0; almost_full_on ?P2.0 ?A2.0⟧ ⟹ almost_full_on (λx y. ?P1.0 x y ∧ ?P2.0 x y) (?A1.0 ∩ ?A2.0)›*)) thus "?thesis" (*goal: ‹almost_full_on (λx y. P1 x y ∧ P2 x y) A›*) by simp qed context ord begin definition is_le_rel :: "('a ⇒ 'a ⇒ bool) ⇒ bool" where "is_le_rel rel = (rel = (=) ∨ rel = (≤) ∨ rel = (<))" lemma is_le_relI [simp]: "is_le_rel (=)" "is_le_rel (≤)" "is_le_rel (<)" (*goals: 1. ‹is_le_rel (=)› 2. ‹is_le_rel (≤)› 3. ‹is_le_rel (<)› discuss goal 1*) apply (simp add: is_le_rel_def (*‹is_le_rel ?rel = (?rel = (=) ∨ ?rel = (≤) ∨ ?rel = (<))›*)) (*discuss goal 2*) apply (simp add: is_le_rel_def (*‹is_le_rel ?rel = (?rel = (=) ∨ ?rel = (≤) ∨ ?rel = (<))›*)) (*discuss goal 3*) apply (simp add: is_le_rel_def (*‹is_le_rel ?rel = (?rel = (=) ∨ ?rel = (≤) ∨ ?rel = (<))›*)) (*proven 3 subgoals*) . lemma is_le_relE: assumes "is_le_rel rel" obtains "rel = (=)" | "rel = (≤)" | "rel = (<)" using assms (*‹is_le_rel rel›*) unfolding is_le_rel_def (*goal: ‹⟦(rel::'a ⇒ 'a ⇒ bool) = (=) ⟹ thesis::bool; rel = (≤) ⟹ thesis; rel = (<) ⟹ thesis⟧ ⟹ thesis›*) by blast end (* ord *) context preorder begin lemma is_le_rel_le: assumes "is_le_rel rel" shows "rel x y ⟹ x ≤ y" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦rel x y; rel = (=)⟧ ⟹ x ≤ y› 2. ‹⟦rel x y; rel = (≤)⟧ ⟹ x ≤ y› 3. ‹⟦rel x y; rel = (<)⟧ ⟹ x ≤ y› discuss goal 1*) apply ((auto dest: less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 2*) apply ((auto dest: less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 3*) apply ((auto dest: less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*proven 3 subgoals*) . lemma is_le_rel_trans: assumes "is_le_rel rel" shows "rel x y ⟹ rel y z ⟹ rel x z" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦(rel::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type); rel y (z::'a::type); rel = (=)⟧ ⟹ rel x z› 2. ‹⟦(rel::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type); rel y (z::'a::type); rel = (≤)⟧ ⟹ rel x z› 3. ‹⟦(rel::'a::type ⇒ 'a::type ⇒ bool) (x::'a::type) (y::'a::type); rel y (z::'a::type); rel = (<)⟧ ⟹ rel x z› discuss goal 1*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*))[1]) (*discuss goal 2*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*))[1]) (*discuss goal 3*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) less_trans (*‹⟦?x < ?y; ?y < ?z⟧ ⟹ ?x < ?z›*))[1]) (*proven 3 subgoals*) . lemma is_le_rel_trans_le_left: assumes "is_le_rel rel" shows "x ≤ y ⟹ rel y z ⟹ x ≤ z" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦x ≤ y; rel y z; rel = (=)⟧ ⟹ x ≤ z› 2. ‹⟦x ≤ y; rel y z; rel = (≤)⟧ ⟹ x ≤ z› 3. ‹⟦x ≤ y; rel y z; rel = (<)⟧ ⟹ x ≤ z› discuss goal 1*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 2*) apply ((auto dest: order_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x ≤ ?z›*) le_less_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y < (?z::'a)⟧ ⟹ ?x < ?z›*) less_imp_le (*‹(?x::'a) < (?y::'a) ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 3*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*proven 3 subgoals*) . lemma is_le_rel_trans_le_right: assumes "is_le_rel rel" shows "rel x y ⟹ y ≤ z ⟹ x ≤ z" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel (?rel::'a ⇒ 'a ⇒ bool); ?rel = (=) ⟹ ?thesis::bool; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦rel x y; y ≤ z; rel = (=)⟧ ⟹ x ≤ z› 2. ‹⟦rel x y; y ≤ z; rel = (≤)⟧ ⟹ x ≤ z› 3. ‹⟦rel x y; y ≤ z; rel = (<)⟧ ⟹ x ≤ z› discuss goal 1*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 2*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 3*) apply ((auto dest: order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*) less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*proven 3 subgoals*) . lemma is_le_rel_trans_less_left: assumes "is_le_rel rel" shows "x < y ⟹ rel y z ⟹ x < z" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦(x::'a) < (y::'a); (rel::'a ⇒ 'a ⇒ bool) y (z::'a); rel = (=)⟧ ⟹ x < z› 2. ‹⟦(x::'a) < (y::'a); (rel::'a ⇒ 'a ⇒ bool) y (z::'a); rel = (≤)⟧ ⟹ x < z› 3. ‹⟦(x::'a) < (y::'a); (rel::'a ⇒ 'a ⇒ bool) y (z::'a); rel = (<)⟧ ⟹ x < z› discuss goal 1*) apply ((auto dest: less_le_trans (*‹⟦(?x::'a) < (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x < ?z›*) less_imp_le (*‹(?x::'a) < (?y::'a) ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 2*) apply ((auto dest: less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 3*) apply ((auto dest: less_le_trans (*‹⟦?x < ?y; ?y ≤ ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*proven 3 subgoals*) . lemma is_le_rel_trans_less_right: assumes "is_le_rel rel" shows "rel x y ⟹ y < z ⟹ x < z" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦rel x y; y < z; rel = (=)⟧ ⟹ x < z› 2. ‹⟦rel x y; y < z; rel = (≤)⟧ ⟹ x < z› 3. ‹⟦rel x y; y < z; rel = (<)⟧ ⟹ x < z› discuss goal 1*) apply ((auto dest: le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 2*) apply ((auto dest: le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*discuss goal 3*) apply ((auto dest: le_less_trans (*‹⟦?x ≤ ?y; ?y < ?z⟧ ⟹ ?x < ?z›*) less_imp_le (*‹?x < ?y ⟹ ?x ≤ ?y›*))[1]) (*proven 3 subgoals*) . end (* preorder *) context order begin lemma is_le_rel_distinct: assumes "is_le_rel rel" shows "rel x y ⟹ x ≠ y ⟹ x < y" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦rel x y; x ≠ y; rel = (=)⟧ ⟹ x < y› 2. ‹⟦rel x y; x ≠ y; rel = (≤)⟧ ⟹ x < y› 3. ‹⟦rel x y; x ≠ y; rel = (<)⟧ ⟹ x < y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . lemma is_le_rel_antisym: assumes "is_le_rel rel" shows "rel x y ⟹ rel y x ⟹ x = y" using assms (*‹is_le_rel rel›*) apply (rule is_le_relE (*‹⟦is_le_rel ?rel; ?rel = (=) ⟹ ?thesis; ?rel = (≤) ⟹ ?thesis; ?rel = (<) ⟹ ?thesis⟧ ⟹ ?thesis›*)) (*goals: 1. ‹⟦rel x y; rel y x; rel = (=)⟧ ⟹ x = y› 2. ‹⟦rel x y; rel y x; rel = (≤)⟧ ⟹ x = y› 3. ‹⟦rel x y; rel y x; rel = (<)⟧ ⟹ x = y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end (* order *) end (* theory *)
{ "path": "afp-2025-02-12/thys/Signature_Groebner/Prelims.thy", "repo": "afp-2025-02-12", "sha": "ece35c03ab008e40a3d60bd86fea334297cbe89f3527c5bc25f3e5d4c4836c93" }
(* Title: Executable multivariate polynomials Author: Christian Sternagel <christian.sternagel@uibk.ac.at> Rene Thiemann <rene.thiemann@uibk.ac.at> Maintainer: Christian Sternagel and Rene Thiemann License: LGPL *) (* Copyright 2009 Christian Sternagel, René Thiemann, Sarah Winkler, Harald Zankl This file is part of IsaFoR/CeTA. IsaFoR/CeTA is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. IsaFoR/CeTA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with IsaFoR/CeTA. If not, see <http://www.gnu.org/licenses/>. *) section ‹Monotonicity criteria of Neurauter, Zankl, and Middeldorp› theory NZM imports "Abstract-Rewriting.SN_Order_Carrier" Polynomials begin text ‹ We show that our check on monotonicity is strong enough to capture the exact criterion for polynomials of degree 2 that is presented in \<^cite>‹"NZM10"›: \begin{itemize} \item $ax^2 + bx + c$ is monotone if $b + a > 0$ and $a \geq 0$ \item $ax^2 + bx + c$ is weakly monotone if $b + a \geq 0$ and $a \geq 0$ \end{itemize} › lemma var_monom_x_x [simp]: "var_monom x * var_monom x ≠ 1" apply (unfold eq_monom_sum_var (*‹(?m = ?n) = (∀x. sum_var ?m x = sum_var ?n x)›*)) (*goal: ‹var_monom x * var_monom x ≠ 1›*) by (auto simp: sum_var_monom_mult (*‹sum_var (?m * ?n) ?x = sum_var ?m ?x + sum_var ?n ?x›*) sum_var_monom_var (*‹sum_var (var_monom ?x) ?y = (if ?x = ?y then 1 else 0)›*)) lemma monom_list_x_x[simp]: "monom_list (var_monom x * var_monom x) = [(x,2)]" apply transfer (*goal: ‹monom_list (var_monom x * var_monom x) = [(x, 2)]›*) by (auto simp: monom_mult_list.simps (*‹monom_mult_list [] ?n = ?n› ‹monom_mult_list ((?x, ?p) # ?m) ?n = (case ?n of [] ⇒ (?x, ?p) # ?m | (y, q) # n' ⇒ if ?x = y then (?x, ?p + q) # monom_mult_list ?m n' else if ?x < y then (?x, ?p) # monom_mult_list ?m ?n else (y, q) # monom_mult_list ((?x, ?p) # ?m) n')›*)) lemma assumes b: "b + a > 0" and a: "(a :: int) ≥ 0" shows "check_poly_strict_mono_discrete (>) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x" proof (-) (*goal: ‹check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) note [simp] = poly_add.simps (*‹poly_add [] (?q::(?'v::type monom × ?'a::semiring_0) list) = ?q› ‹poly_add ((?m, ?c) # ?p) ?q = (case List.extract (λmc. fst mc = ?m) ?q of None ⇒ (?m, ?c) # poly_add ?p ?q | Some (q1, (x, d), q2) ⇒ if ?c + d = 0 then poly_add ?p (q1 @ q2) else (?m, ?c + d) # poly_add ?p (q1 @ q2))›*) poly_mult.simps (*‹poly_mult [] ?q = []› ‹poly_mult ((?mc::?'v monom × ?'a) # (?p::(?'v monom × ?'a) list)) (?q::(?'v monom × ?'a) list) = poly_add (monom_mult_poly ?mc ?q) (poly_mult ?p ?q)›*) monom_mult_poly.simps (*‹monom_mult_poly ?uu [] = []› ‹monom_mult_poly (?m, ?c) ((?m', ?d) # ?p) = (if ?c * ?d = 0 then monom_mult_poly (?m, ?c) ?p else (?m * ?m', ?c * ?d) # monom_mult_poly (?m, ?c) ?p)›*) zero_poly_def (*‹zero_poly ≡ []›*) one_poly_def (*‹one_poly ≡ [(1::?'v monom, 1::?'a)]›*) extract_def (*‹List.extract (?P::?'a ⇒ bool) (?xs::?'a list) = (case dropWhile (Not ∘ ?P) ?xs of [] ⇒ None | (y::?'a) # (ys::?'a list) ⇒ Some (takeWhile (Not ∘ ?P) ?xs, y, ys))›*) check_poly_strict_mono_discrete_def (*‹check_poly_strict_mono_discrete (?gt::?'a::poly_carrier ⇒ ?'a::poly_carrier ⇒ bool) (?p::(?'v::linorder monom × ?'a::poly_carrier) list) (?v::?'v::linorder) ≡ check_poly_gt ?gt (poly_subst (λw::?'v::linorder. poly_of (if w = ?v then PSum [PNum (1::?'a::poly_carrier), PVar ?v] else PVar w)) ?p) ?p›*) poly_subst.simps (*‹poly_subst (?σ::?'v::linorder ⇒ (?'w::linorder monom × ?'a::comm_semiring_1) list) [] = zero_poly› ‹poly_subst ?σ ((?m, ?c) # ?p) = poly_add (poly_mult [(1, ?c)] (monom_subst ?σ ?m)) (poly_subst ?σ ?p)›*) monom_subst_def (*‹monom_subst ?σ ?m = monom_list_subst ?σ (monom_list ?m)›*) poly_power.simps (*‹poly_power (?uu::(?'v::linorder monom × ?'a::comm_semiring_1) list) (0::nat) = one_poly› ‹poly_power (?p::(?'v monom × ?'a) list) (Suc (?n::nat)) = poly_mult ?p (poly_power ?p ?n)›*) check_poly_gt_def (*‹check_poly_gt ?gt ?p ?q ≡ let (a1, p1) = poly_split 1 ?p; (b1, q1) = poly_split 1 ?q in ?gt a1 b1 ∧ check_poly_ge p1 q1›*) poly_split_def (*‹poly_split ?m ?p ≡ case List.extract (λ(n, uu_). ?m = n) ?p of None ⇒ (0, ?p) | Some (p1, (x, c), p2) ⇒ (c, p1 @ p2)›*) check_poly_ge.simps (*‹check_poly_ge [] ?q = list_all (λ(uu_, d). d ≤ 0) ?q› ‹check_poly_ge ((?m::?'v::type monom, ?c::?'a::SN_Orders.ordered_semiring_0) # (?p::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list)) (?q::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list) = (case List.extract (λnd::?'v::type monom × ?'a::SN_Orders.ordered_semiring_0. fst nd = ?m) ?q of None ⇒ (0::?'a::SN_Orders.ordered_semiring_0) ≤ ?c ∧ check_poly_ge ?p ?q | Some (q1::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list, (x::?'v::type monom, d::?'a::SN_Orders.ordered_semiring_0), q2::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list) ⇒ d ≤ ?c ∧ check_poly_ge ?p (q1 @ q2))›*) show "?thesis" (*goal: ‹check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) proof (cases "a = 0") (*goals: 1. ‹a = 0 ⟹ check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x› 2. ‹a ≠ 0 ⟹ check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) case True (*‹a = 0›*) with b (*‹0 < b + a›*) have b: "b > 0 ∧ b ≠ 0" by auto show "?thesis" (*goal: ‹check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) using b (*‹0 < b ∧ b ≠ 0›*) True (*‹a = 0›*) by simp next (*goal: ‹a ≠ 0 ⟹ check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) case False (*‹a ≠ 0›*) have [simp]: "2 = Suc (Suc 0)" by simp show "?thesis" (*goal: ‹check_poly_strict_mono_discrete (λx y. y < x) (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) using False (*‹a ≠ 0›*) a (*‹(0::int) ≤ (a::int)›*) b (*‹0 < b + a›*) by simp qed qed lemma assumes b: "b + a ≥ 0" and a: "(a :: int) ≥ 0" shows "check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x" proof (-) (*goal: ‹check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) note [simp] = poly_add.simps (*‹poly_add [] ?q = ?q› ‹poly_add ((?m, ?c) # ?p) ?q = (case List.extract (λmc. fst mc = ?m) ?q of None ⇒ (?m, ?c) # poly_add ?p ?q | Some (q1, (x, d), q2) ⇒ if ?c + d = 0 then poly_add ?p (q1 @ q2) else (?m, ?c + d) # poly_add ?p (q1 @ q2))›*) poly_mult.simps (*‹poly_mult [] ?q = []› ‹poly_mult (?mc # ?p) ?q = poly_add (monom_mult_poly ?mc ?q) (poly_mult ?p ?q)›*) monom_mult_poly.simps (*‹monom_mult_poly ?uu [] = []› ‹monom_mult_poly (?m, ?c) ((?m', ?d) # ?p) = (if ?c * ?d = 0 then monom_mult_poly (?m, ?c) ?p else (?m * ?m', ?c * ?d) # monom_mult_poly (?m, ?c) ?p)›*) zero_poly_def (*‹zero_poly ≡ []›*) one_poly_def (*‹one_poly ≡ [(1, 1)]›*) extract_def (*‹List.extract ?P ?xs = (case dropWhile (Not ∘ ?P) ?xs of [] ⇒ None | y # ys ⇒ Some (takeWhile (Not ∘ ?P) ?xs, y, ys))›*) check_poly_weak_mono_discrete_def (*‹check_poly_weak_mono_discrete ?p ?v ≡ check_poly_ge (poly_subst (λw. poly_of (if w = ?v then PSum [PNum 1, PVar ?v] else PVar w)) ?p) ?p›*) poly_subst.simps (*‹poly_subst (?σ::?'v ⇒ (?'w monom × ?'a) list) [] = zero_poly› ‹poly_subst ?σ ((?m, ?c) # ?p) = poly_add (poly_mult [(1, ?c)] (monom_subst ?σ ?m)) (poly_subst ?σ ?p)›*) monom_subst_def (*‹monom_subst ?σ ?m = monom_list_subst ?σ (monom_list ?m)›*) poly_power.simps (*‹poly_power ?uu 0 = one_poly› ‹poly_power ?p (Suc ?n) = poly_mult ?p (poly_power ?p ?n)›*) check_poly_gt_def (*‹check_poly_gt ?gt ?p ?q ≡ let (a1, p1) = poly_split 1 ?p; (b1, q1) = poly_split 1 ?q in ?gt a1 b1 ∧ check_poly_ge p1 q1›*) poly_split_def (*‹poly_split ?m ?p ≡ case List.extract (λ(n, uu_). ?m = n) ?p of None ⇒ (0, ?p) | Some (p1, (x, c), p2) ⇒ (c, p1 @ p2)›*) check_poly_ge.simps (*‹check_poly_ge [] ?q = list_all (λ(uu_, d). d ≤ 0) ?q› ‹check_poly_ge ((?m::?'v::type monom, ?c::?'a::SN_Orders.ordered_semiring_0) # (?p::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list)) (?q::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list) = (case List.extract (λnd::?'v::type monom × ?'a::SN_Orders.ordered_semiring_0. fst nd = ?m) ?q of None ⇒ (0::?'a::SN_Orders.ordered_semiring_0) ≤ ?c ∧ check_poly_ge ?p ?q | Some (q1::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list, (x::?'v::type monom, d::?'a::SN_Orders.ordered_semiring_0), q2::(?'v::type monom × ?'a::SN_Orders.ordered_semiring_0) list) ⇒ d ≤ ?c ∧ check_poly_ge ?p (q1 @ q2))›*) show "?thesis" (*goal: ‹check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) proof (cases "a = 0") (*goals: 1. ‹a = 0 ⟹ check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x› 2. ‹a ≠ 0 ⟹ check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) case True (*‹a = 0›*) with b (*‹0 ≤ b + a›*) have b: "0 ≤ b" by auto show "?thesis" (*goal: ‹check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) using b (*‹0 ≤ b›*) True (*‹a = 0›*) by simp next (*goal: ‹a ≠ 0 ⟹ check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) case False (*‹(a::int) ≠ (0::int)›*) have [simp]: "2 = Suc (Suc 0)" by simp show "?thesis" (*goal: ‹check_poly_weak_mono_discrete (poly_of (PSum [PNum c, PMult [PNum b, PVar x], PMult [PNum a, PVar x, PVar x]])) x›*) using False (*‹a ≠ 0›*) a (*‹0 ≤ a›*) b (*‹0 ≤ b + a›*) by simp qed qed end
{ "path": "afp-2025-02-12/thys/Polynomials/NZM.thy", "repo": "afp-2025-02-12", "sha": "4b0bc635b515854c2a30bdc0db7dbe0b59ca8bddb679a69cd6b7232d8e1f58e4" }
(* * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) * * SPDX-License-Identifier: BSD-2-Clause *) section "Words of Length 64" theory Word_64 imports Word_Lemmas Word_Names Word_Syntax Rsplit More_Word_Operations begin context includes bit_operations_syntax begin lemma len64: "len_of (x :: 64 itself) = 64" by simp lemma ucast_8_64_inj: "inj (ucast :: 8 word ⇒ 64 word)" apply (rule down_ucast_inj (*‹is_down UCAST(?'b → ?'a) ⟹ inj_on UCAST(?'a → ?'b) ?A›*)) (*goal: ‹inj UCAST(8 → 64)›*) by (clarsimp simp: is_down_def (*‹is_down ≡ map_fun (map_fun Word.Word Word.rep) id (λ_::int ⇒ int. LENGTH(?'b::len) ≤ LENGTH(?'a::len))›*) target_size (*‹target_size (?c::?'a::type ⇒ ?'b::len word) = LENGTH(?'b::len)›*) source_size (*‹source_size (?c::?'a::len word ⇒ ?'b::type) = LENGTH(?'a::len)›*)) lemmas unat_power_lower64' = unat_power_lower[where 'a=64] lemmas word64_less_sub_le' = word_less_sub_le[where 'a = 64] lemmas word64_power_less_1' = word_power_less_1[where 'a = 64] lemmas unat_of_nat64' = unat_of_nat_eq[where 'a=64] lemmas unat_mask_word64' = unat_mask[where 'a=64] lemmas word64_minus_one_le' = word_minus_one_le[where 'a=64] lemmas word64_minus_one_le = word64_minus_one_le'[simplified] lemma less_4_cases: "(x::word64) < 4 ⟹ x=0 ∨ x=1 ∨ x=2 ∨ x=3" apply clarsimp (*goal: ‹x < 4 ⟹ x = 0 ∨ x = 1 ∨ x = 2 ∨ x = 3›*) apply (drule word_less_cases (*‹?x < ?y ⟹ ?x = ?y - 1 ∨ ?x < ?y - 1›*)) (*goal: ‹⟦x < 4; x ≠ 0; x ≠ 1; x ≠ 3⟧ ⟹ x = 2›*) apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x = 4 - 1⟧ ⟹ x = 2› 2. ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x < 4 - 1⟧ ⟹ x = 2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x < 4 - 1⟧ ⟹ x = 2›*) apply (drule word_less_cases (*‹?x < ?y ⟹ ?x = ?y - 1 ∨ ?x < ?y - 1›*)) (*goal: ‹⟦(x::64 word) ≠ (0::64 word); x ≠ (1::64 word); x ≠ (3::64 word); x < (3::64 word)⟧ ⟹ x = (2::64 word)›*) apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x = 3 - 1⟧ ⟹ x = 2› 2. ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x < 3 - 1⟧ ⟹ x = 2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x < 3 - 1⟧ ⟹ x = 2›*) apply (drule word_less_cases (*‹?x < ?y ⟹ ?x = ?y - 1 ∨ ?x < ?y - 1›*)) (*goal: ‹⟦(x::64 word) ≠ (0::64 word); x ≠ (1::64 word); x ≠ (3::64 word); x < (2::64 word)⟧ ⟹ x = (2::64 word)›*) apply (erule disjE (*‹⟦?P ∨ ?Q; ?P ⟹ ?R; ?Q ⟹ ?R⟧ ⟹ ?R›*)) (*goals: 1. ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x = 2 - 1⟧ ⟹ x = 2› 2. ‹⟦x ≠ 0; x ≠ 1; x ≠ 3; x < 2 - 1⟧ ⟹ x = 2› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma ucast_le_ucast_8_64: "(ucast x ≤ (ucast y :: word64)) = (x ≤ (y :: 8 word))" by (simp add: ucast_le_ucast (*‹LENGTH(?'a) ≤ LENGTH(?'b) ⟹ (UCAST(?'a → ?'b) (?x::?'a word) ≤ UCAST(?'a → ?'b) (?y::?'a word)) = (?x ≤ ?y)›*)) lemma eq_2_64_0: "(2 ^ 64 :: word64) = 0" by simp lemmas mask_64_max_word = max_word_mask [symmetric, where 'a=64, simplified] lemma of_nat64_n_less_equal_power_2: "n < 64 ⟹ ((of_nat n)::64 word) < 2 ^ n" apply (rule of_nat_n_less_equal_power_2 (*‹?n < LENGTH(?'a) ⟹ word_of_nat ?n < 2 ^ ?n›*)) (*goal: ‹n < 64 ⟹ word_of_nat n < 2 ^ n›*) by (clarsimp simp: word_size (*‹size (?w::?'a::len word) = LENGTH(?'a::len)›*)) lemma unat_ucast_10_64 : fixes x :: "10 word" shows "unat (ucast x :: word64) = unat x" apply transfer (*goal: ‹unat (UCAST(10 → 64) x) = unat x›*) by simp lemma word64_bounds: "- (2 ^ (size (x :: word64) - 1)) = (-9223372036854775808 :: int)" "((2 ^ (size (x :: word64) - 1)) - 1) = (9223372036854775807 :: int)" "- (2 ^ (size (y :: 64 signed word) - 1)) = (-9223372036854775808 :: int)" "((2 ^ (size (y :: 64 signed word) - 1)) - 1) = (9223372036854775807 :: int)" (*goals: 1. ‹- (2 ^ (size x - 1)) = - 9223372036854775808› 2. ‹2 ^ (size x - 1) - 1 = 9223372036854775807› 3. ‹- (2 ^ (size y - 1)) = - 9223372036854775808› 4. ‹2 ^ (size y - 1) - 1 = 9223372036854775807› discuss goal 1*) apply (simp add: word_size (*‹size ?w = LENGTH(?'a)›*)) (*discuss goal 2*) apply (simp add: word_size (*‹size (?w::?'a word) = LENGTH(?'a)›*)) (*discuss goal 3*) apply (simp add: word_size (*‹size ?w = LENGTH(?'a)›*)) (*discuss goal 4*) apply (simp add: word_size (*‹size ?w = LENGTH(?'a)›*)) (*proven 4 subgoals*) . lemmas signed_arith_ineq_checks_to_eq_word64' = signed_arith_ineq_checks_to_eq[where 'a=64] signed_arith_ineq_checks_to_eq[where 'a="64 signed"] lemmas signed_arith_ineq_checks_to_eq_word64 = signed_arith_ineq_checks_to_eq_word64' [unfolded word64_bounds] lemmas signed_mult_eq_checks64_to_64' = signed_mult_eq_checks_double_size[where 'a=64 and 'b=64] signed_mult_eq_checks_double_size[where 'a="64 signed" and 'b=64] lemmas signed_mult_eq_checks64_to_64 = signed_mult_eq_checks64_to_64'[simplified] lemmas sdiv_word64_max' = sdiv_word_max [where 'a=64] sdiv_word_max [where 'a="64 signed"] lemmas sdiv_word64_max = sdiv_word64_max'[simplified word_size, simplified] lemmas sdiv_word64_min' = sdiv_word_min [where 'a=64] sdiv_word_min [where 'a="64 signed"] lemmas sdiv_word64_min = sdiv_word64_min' [simplified word_size, simplified] lemmas sint64_of_int_eq' = sint_of_int_eq [where 'a=64] lemmas sint64_of_int_eq = sint64_of_int_eq' [simplified] lemma ucast_of_nats [simp]: "(ucast (of_nat x :: word64) :: sword64) = (of_nat x)" "(ucast (of_nat x :: word64) :: 16 sword) = (of_nat x)" "(ucast (of_nat x :: word64) :: 8 sword) = (of_nat x)" (*goals: 1. ‹UCAST(64 → 64 signed) (word_of_nat (x::nat)) = word_of_nat x› 2. ‹UCAST(64 → 16 signed) (word_of_nat (x::nat)) = word_of_nat x› 3. ‹UCAST(64 → 8 signed) (word_of_nat (x::nat)) = word_of_nat x› discuss goal 1*) apply (simp add: of_nat_take_bit (*‹of_nat (take_bit ?n ?m) = take_bit ?n (of_nat ?m)›*) take_bit_word_eq_self (*‹LENGTH(?'a) ≤ ?n ⟹ take_bit ?n ?w = ?w›*) unsigned_of_nat (*‹unsigned (word_of_nat ?n) = of_nat (take_bit LENGTH(?'b) ?n)›*)) (*discuss goal 2*) apply (simp add: of_nat_take_bit (*‹of_nat (take_bit ?n ?m) = take_bit ?n (of_nat ?m)›*) take_bit_word_eq_self (*‹LENGTH(?'a) ≤ ?n ⟹ take_bit ?n ?w = ?w›*) unsigned_of_nat (*‹unsigned (word_of_nat ?n) = of_nat (take_bit LENGTH(?'b) ?n)›*)) (*discuss goal 3*) apply (simp add: of_nat_take_bit (*‹of_nat (take_bit ?n ?m) = take_bit ?n (of_nat ?m)›*) take_bit_word_eq_self (*‹LENGTH(?'a) ≤ ?n ⟹ take_bit ?n ?w = ?w›*) unsigned_of_nat (*‹unsigned (word_of_nat ?n) = of_nat (take_bit LENGTH(?'b) ?n)›*)) (*proven 3 subgoals*) . lemmas signed_shift_guard_simpler_64' = power_strict_increasing_iff[where b="2 :: nat" and y=31] lemmas signed_shift_guard_simpler_64 = signed_shift_guard_simpler_64'[simplified] lemma word64_31_less: "31 < len_of TYPE (64 signed)" "31 > (0 :: nat)" "31 < len_of TYPE (64)" "31 > (0 :: nat)" (*goals: 1. ‹31 < LENGTH(64 signed)› 2. ‹0 < 31› 3. ‹31 < LENGTH(64)› 4. ‹0 < 31› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . lemmas signed_shift_guard_to_word_64 = signed_shift_guard_to_word[OF word64_31_less(1-2)] signed_shift_guard_to_word[OF word64_31_less(3-4)] lemma mask_step_down_64: ‹∃x. mask x = b› if ‹b && 1 = 1› and ‹∃x. x < 64 ∧ mask x = b >> 1› for b :: ‹64word› proof (-) (*goal: ‹∃x. mask x = b›*) from ‹b && 1 = 1› (*‹b && 1 = 1›*) have "odd b" by (auto simp add: mod_2_eq_odd (*‹(?a::?'a) mod (2::?'a) = of_bool (odd ?a)›*) and_one_eq (*‹(?a::?'a) AND (1::?'a) = ?a mod (2::?'a)›*)) then have "b mod 2 = 1" using odd_iff_mod_2_eq_one (*‹odd ?a = (?a mod 2 = 1)›*) by blast from ‹∃x. x < 64 ∧ mask x = b >> 1› (*‹∃x<64. mask x = b >> 1›*) obtain x where "x < 64" "mask x = b >> 1" (*goal: ‹(⋀x. ⟦x < 64; mask x = b >> 1⟧ ⟹ thesis) ⟹ thesis›*) by blast then have "mask x = b div 2" using shiftr1_is_div_2[of b] (*‹b >> 1 = b div 2›*) by simp with ‹b mod 2 = 1› (*‹(b::64 word) mod (2::64 word) = (1::64 word)›*) have "2 * mask x + 1 = 2 * (b div 2) + b mod 2" by (simp only:) also (*calculation: ‹2 * mask x + 1 = 2 * (b div 2) + b mod 2›*) have "… = b" by (simp add: mult_div_mod_eq (*‹(?b::?'a::semiring_modulo) * ((?a::?'a::semiring_modulo) div ?b) + ?a mod ?b = ?a›*)) finally (*calculation: ‹2 * mask x + 1 = b›*) have "2 * mask x + 1 = b" . moreover have "mask (Suc x) = 2 * mask x + (1 :: 'a::len word)" by (simp add: mask_Suc_rec (*‹mask (Suc ?n) = 2 * mask ?n + 1›*)) ultimately show "?thesis" (*goal: ‹∃x. mask x = b›*) by auto qed lemma unat_of_int_64: "⟦i ≥ 0; i ≤ 2 ^ 63⟧ ⟹ (unat ((of_int i)::sword64)) = nat i" by (simp add: unsigned_of_int (*‹unsigned (word_of_int ?k) = of_nat (nat (take_bit LENGTH(?'b) ?k))›*) nat_take_bit_eq (*‹0 ≤ ?k ⟹ nat (take_bit ?n ?k) = take_bit ?n (nat ?k)›*) take_bit_nat_eq_self (*‹?m < 2 ^ ?n ⟹ take_bit ?n ?m = ?m›*)) lemmas word_ctz_not_minus_1_64 = word_ctz_not_minus_1[where 'a=64, simplified] lemma word64_and_max_simp: ‹x AND 0xFFFFFFFFFFFFFFFF = x› for x :: ‹64 word› using word_and_full_mask_simp[of x] (*‹x && mask LENGTH(64) = x›*) by (simp add: numeral_eq_Suc (*‹numeral ?k = Suc (pred_numeral ?k)›*) mask_Suc_exp (*‹mask (Suc ?n) = 2 ^ ?n OR mask ?n›*)) end end
{ "path": "afp-2025-02-12/thys/Word_Lib/Word_64.thy", "repo": "afp-2025-02-12", "sha": "9d1675df59bd11b4820ba3384a524a12caea9a662a8b45ed225e98db582b618f" }
(* Title: JinjaDCI/Compiler/TypeComp.thy Author: Tobias Nipkow, Susannah Mansky Copyright TUM 2003, UIUC 2019-20 Based on the Jinja theory Compiler/TypeComp.thy by Tobias Nipkow *) section ‹ Preservation of Well-Typedness › theory TypeComp imports Compiler "../BV/BVSpec" begin (*<*) declare nth_append[simp] (*>*) lemma max_stack1: "P,E ⊢₁ e :: T ⟹ 1 ≤ max_stack e" (*<*)using max_stack1'[OF WT₁_nsub_RI] (*‹(?P1::nat exp prog),(?E1::ty list) ⊢₁ (?e::nat exp) :: ?T1::ty ⟹ (1::nat) ≤ max_stack ?e›*) by simp(*>*) locale TC0 = fixes P :: "J₁_prog" and mxl :: nat begin definition "ty E e = (THE T. P,E ⊢₁ e :: T)" definition "ty⇩l E A' = map (λi. if i ∈ A' ∧ i < size E then OK(E!i) else Err) [0..<mxl]" definition "ty⇩i' ST E A = (case A of None ⇒ None | ⌊A'⌋ ⇒ Some(ST, ty⇩l E A'))" definition "after E A ST e = ty⇩i' (ty E e # ST) E (A ⊔ 𝒜 e)" end lemma (in TC0) ty_def2 [simp]: "P,E ⊢₁ e :: T ⟹ ty E e = T" (*<*)apply (unfold ty_def (*‹ty ?E ?e = (THE T. P,?E ⊢₁ ?e :: T)›*)) (*goal: ‹(P::nat exp prog),(E::ty list) ⊢₁ (e::nat exp) :: T::ty ⟹ ty E e = T›*) by (blast intro: the_equality (*‹⟦?P ?a; ⋀x. ?P x ⟹ x = ?a⟧ ⟹ (THE x. ?P x) = ?a›*) WT₁_unique (*‹⟦?P,?E ⊢₁ ?e :: ?T₁; ?P,?E ⊢₁ ?e :: ?T₂⟧ ⟹ ?T₁ = ?T₂›*))(*>*) lemma (in TC0) [simp]: "ty⇩i' ST E None = None" (*<*)by (simp add: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*))(*>*) lemma (in TC0) ty⇩l_app_diff[simp]: "ty⇩l (E@[T]) (A - {size E}) = ty⇩l E A" (*<*)by (auto simp add:ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*) lemma (in TC0) ty⇩i'_app_diff[simp]: "ty⇩i' ST (E @ [T]) (A ⊖ size E) = ty⇩i' ST E A" (*<*)by (auto simp add:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*) lemma (in TC0) ty⇩l_antimono: "A ⊆ A' ⟹ P ⊢ ty⇩l E A' [≤⇩⊤] ty⇩l E A" (*<*)by (auto simp:ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))(*>*) lemma (in TC0) ty⇩i'_antimono: "A ⊆ A' ⟹ P ⊢ ty⇩i' ST E ⌊A'⌋ ≤' ty⇩i' ST E ⌊A⌋" (*<*)by (auto simp:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))(*>*) lemma (in TC0) ty⇩l_env_antimono: "P ⊢ ty⇩l (E@[T]) A [≤⇩⊤] ty⇩l E A" (*<*)by (auto simp:ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))(*>*) lemma (in TC0) ty⇩i'_env_antimono: "P ⊢ ty⇩i' ST (E@[T]) A ≤' ty⇩i' ST E A" (*<*)by (auto simp:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))(*>*) lemma (in TC0) ty⇩i'_incr: "P ⊢ ty⇩i' ST (E @ [T]) ⌊insert (size E) A⌋ ≤' ty⇩i' ST E ⌊A⌋" (*<*)by (auto simp:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))(*>*) lemma (in TC0) ty⇩l_incr: "P ⊢ ty⇩l (E @ [T]) (insert (size E) A) [≤⇩⊤] ty⇩l E A" (*<*)by (auto simp: hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*) ty⇩l_def (*‹ty⇩l (?E::?'a list) (?A'::nat set) = map (λi::nat. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0::nat..<mxl::nat]›*) list_all2_conv_all_nth (*‹list_all2 (?P::?'a ⇒ ?'b ⇒ bool) (?xs::?'a list) (?ys::?'b list) = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*))(*>*) lemma (in TC0) ty⇩l_in_types: "set E ⊆ types P ⟹ ty⇩l E A ∈ nlists mxl (err (types P))" (*<*)by (auto simp add:ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) intro!:nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*) dest!: nth_mem (*‹?n < length ?xs ⟹ ?xs ! ?n ∈ set ?xs›*))(*>*) locale TC1 = TC0 begin primrec compT :: "ty list ⇒ nat hyperset ⇒ ty list ⇒ expr₁ ⇒ ty⇩i' list" and compTs :: "ty list ⇒ nat hyperset ⇒ ty list ⇒ expr₁ list ⇒ ty⇩i' list" where "compT E A ST (new C) = []" | "compT E A ST (Cast C e) = compT E A ST e @ [after E A ST e]" | "compT E A ST (Val v) = []" | "compT E A ST (e₁ «bop» e₂) = (let ST₁ = ty E e₁#ST; A₁ = A ⊔ 𝒜 e₁ in compT E A ST e₁ @ [after E A ST e₁] @ compT E A₁ ST₁ e₂ @ [after E A₁ ST₁ e₂])" | "compT E A ST (Var i) = []" | "compT E A ST (i := e) = compT E A ST e @ [after E A ST e, ty⇩i' ST E (A ⊔ 𝒜 e ⊔ ⌊{i}⌋)]" | "compT E A ST (e∙F{D}) = compT E A ST e @ [after E A ST e]" | "compT E A ST (C∙⇩sF{D}) = []" | "compT E A ST (e₁∙F{D} := e₂) = (let ST₁ = ty E e₁#ST; A₁ = A ⊔ 𝒜 e₁; A₂ = A₁ ⊔ 𝒜 e₂ in compT E A ST e₁ @ [after E A ST e₁] @ compT E A₁ ST₁ e₂ @ [after E A₁ ST₁ e₂] @ [ty⇩i' ST E A₂])" | "compT E A ST (C∙⇩sF{D} := e₂) = compT E A ST e₂ @ [after E A ST e₂] @ [ty⇩i' ST E (A ⊔ 𝒜 e₂)]" | "compT E A ST {i:T; e} = compT (E@[T]) (A⊖i) ST e" | "compT E A ST (e₁;;e₂) = (let A₁ = A ⊔ 𝒜 e₁ in compT E A ST e₁ @ [after E A ST e₁, ty⇩i' ST E A₁] @ compT E A₁ ST e₂)" | "compT E A ST (if (e) e₁ else e₂) = (let A₀ = A ⊔ 𝒜 e; τ = ty⇩i' ST E A₀ in compT E A ST e @ [after E A ST e, τ] @ compT E A₀ ST e₁ @ [after E A₀ ST e₁, τ] @ compT E A₀ ST e₂)" | "compT E A ST (while (e) c) = (let A₀ = A ⊔ 𝒜 e; A₁ = A₀ ⊔ 𝒜 c; τ = ty⇩i' ST E A₀ in compT E A ST e @ [after E A ST e, τ] @ compT E A₀ ST c @ [after E A₀ ST c, ty⇩i' ST E A₁, ty⇩i' ST E A₀])" | "compT E A ST (throw e) = compT E A ST e @ [after E A ST e]" | "compT E A ST (e∙M(es)) = compT E A ST e @ [after E A ST e] @ compTs E (A ⊔ 𝒜 e) (ty E e # ST) es" | "compT E A ST (C∙⇩sM(es)) = compTs E A ST es" | "compT E A ST (try e₁ catch(C i) e₂) = compT E A ST e₁ @ [after E A ST e₁] @ [ty⇩i' (Class C#ST) E A, ty⇩i' ST (E@[Class C]) (A ⊔ ⌊{i}⌋)] @ compT (E@[Class C]) (A ⊔ ⌊{i}⌋) ST e₂" | "compT E A ST (INIT C (Cs,b) ← e) = []" | "compT E A ST (RI(C,e');Cs ← e) = []" | "compTs E A ST [] = []" | "compTs E A ST (e#es) = compT E A ST e @ [after E A ST e] @ compTs E (A ⊔ (𝒜 e)) (ty E e # ST) es" definition compT⇩a :: "ty list ⇒ nat hyperset ⇒ ty list ⇒ expr₁ ⇒ ty⇩i' list" where "compT⇩a E A ST e = compT E A ST e @ [after E A ST e]" end lemma compE₂_not_Nil[simp]: "P,E ⊢₁ e :: T ⟹ compE₂ e ≠ []" (*<*)by (simp add: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*) WT₁_nsub_RI (*‹?P,?E ⊢₁ ?e :: ?T ⟹ ¬ sub_RI ?e›*))(*>*) lemma (in TC1) compT_sizes': shows "⋀E A ST. ¬sub_RI e ⟹ size(compT E A ST e) = size(compE₂ e) - 1" and "⋀E A ST. ¬sub_RIs es ⟹ size(compTs E A ST es) = size(compEs₂ es)" (*<*) apply (induct e and es rule: compE₂.induct compEs₂.induct) (*goals: 1. ‹⋀x E A ST. ¬ sub_RI (new x) ⟹ length (compT E A ST (new x)) = length (compE₂ (new x)) - 1› 2. ‹⋀x1 x2 E A ST. ⟦⋀E A ST. ¬ sub_RI x2 ⟹ length (compT E A ST x2) = length (compE₂ x2) - 1; ¬ sub_RI (Cast x1 x2)⟧ ⟹ length (compT E A ST (Cast x1 x2)) = length (compE₂ (Cast x1 x2)) - 1› 3. ‹⋀x E A ST. ¬ sub_RI (Val x) ⟹ length (compT E A ST (Val x)) = length (compE₂ (Val x)) - 1› 4. ‹⋀x1 x2 x3 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RI x3 ⟹ length (compT E A ST x3) = length (compE₂ x3) - 1; ¬ sub_RI (x1 «x2» x3)⟧ ⟹ length (compT E A ST (x1 «x2» x3)) = length (compE₂ (x1 «x2» x3)) - 1› 5. ‹⋀x E A ST. ¬ sub_RI (Var x) ⟹ length (compT E A ST (Var x)) = length (compE₂ (Var x)) - 1› 6. ‹⋀x1 x2 E A ST. ⟦⋀E A ST. ¬ sub_RI x2 ⟹ length (compT E A ST x2) = length (compE₂ x2) - 1; ¬ sub_RI (x1:=x2)⟧ ⟹ length (compT E A ST (x1:=x2)) = length (compE₂ (x1:=x2)) - 1› 7. ‹⋀x1 x2 x3 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ¬ sub_RI (x1∙x2{x3})⟧ ⟹ length (compT E A ST (x1∙x2{x3})) = length (compE₂ (x1∙x2{x3})) - 1› 8. ‹⋀x1 x2 x3 E A ST. ¬ sub_RI (x1∙⇩sx2{x3}) ⟹ length (compT E A ST (x1∙⇩sx2{x3})) = length (compE₂ (x1∙⇩sx2{x3})) - 1› 9. ‹⋀x1 x2 x3 x4 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RI x4 ⟹ length (compT E A ST x4) = length (compE₂ x4) - 1; ¬ sub_RI (x1∙x2{x3} := x4)⟧ ⟹ length (compT E A ST (x1∙x2{x3} := x4)) = length (compE₂ (x1∙x2{x3} := x4)) - 1› 10. ‹⋀x1 x2 x3 x4 E A ST. ⟦⋀E A ST. ¬ sub_RI x4 ⟹ length (compT E A ST x4) = length (compE₂ x4) - 1; ¬ sub_RI (x1∙⇩sx2{x3} := x4)⟧ ⟹ length (compT E A ST (x1∙⇩sx2{x3} := x4)) = length (compE₂ (x1∙⇩sx2{x3} := x4)) - 1› 11. ‹⋀x1 x2 x3 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RIs x3 ⟹ length (compTs E A ST x3) = length (compEs₂ x3); ¬ sub_RI (x1∙x2(x3))⟧ ⟹ length (compT E A ST (x1∙x2(x3))) = length (compE₂ (x1∙x2(x3))) - 1› 12. ‹⋀x1 x2 x3 E A ST. ⟦⋀E A ST. ¬ sub_RIs x3 ⟹ length (compTs E A ST x3) = length (compEs₂ x3); ¬ sub_RI (x1∙⇩sx2(x3))⟧ ⟹ length (compT E A ST (x1∙⇩sx2(x3))) = length (compE₂ (x1∙⇩sx2(x3))) - 1› 13. ‹⋀x1 x2 x3 E A ST. ⟦⋀E A ST. ¬ sub_RI x3 ⟹ length (compT E A ST x3) = length (compE₂ x3) - 1; ¬ sub_RI {x1:x2; x3}⟧ ⟹ length (compT E A ST {x1:x2; x3}) = length (compE₂ {x1:x2; x3}) - 1› 14. ‹⋀x1 x2 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RI x2 ⟹ length (compT E A ST x2) = length (compE₂ x2) - 1; ¬ sub_RI (x1;; x2)⟧ ⟹ length (compT E A ST (x1;; x2)) = length (compE₂ (x1;; x2)) - 1› 15. ‹⋀x1 x2 x3 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RI x2 ⟹ length (compT E A ST x2) = length (compE₂ x2) - 1; ⋀E A ST. ¬ sub_RI x3 ⟹ length (compT E A ST x3) = length (compE₂ x3) - 1; ¬ sub_RI (if (x1) x2 else x3)⟧ ⟹ length (compT E A ST (if (x1) x2 else x3)) = length (compE₂ (if (x1) x2 else x3)) - 1› 16. ‹⋀x1 x2 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RI x2 ⟹ length (compT E A ST x2) = length (compE₂ x2) - 1; ¬ sub_RI (while (x1) x2)⟧ ⟹ length (compT E A ST (while (x1) x2)) = length (compE₂ (while (x1) x2)) - 1› 17. ‹⋀x E A ST. ⟦⋀E A ST. ¬ sub_RI x ⟹ length (compT E A ST x) = length (compE₂ x) - 1; ¬ sub_RI (throw x)⟧ ⟹ length (compT E A ST (throw x)) = length (compE₂ (throw x)) - 1› 18. ‹⋀x1 x2 x3 x4 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RI x4 ⟹ length (compT E A ST x4) = length (compE₂ x4) - 1; ¬ sub_RI (try x1 catch(x2 x3) x4)⟧ ⟹ length (compT E A ST (try x1 catch(x2 x3) x4)) = length (compE₂ (try x1 catch(x2 x3) x4)) - 1› 19. ‹⋀x1 x2 x3 x4 E A ST. ⟦⋀E A ST. ¬ sub_RI x4 ⟹ length (compT E A ST x4) = length (compE₂ x4) - 1; ¬ sub_RI (INIT x1 (x2,x3) ← x4)⟧ ⟹ length (compT E A ST (INIT x1 (x2,x3) ← x4)) = length (compE₂ (INIT x1 (x2,x3) ← x4)) - 1› 20. ‹⋀x1 x2 x3 x4 E A ST. ⟦⋀E A ST. ¬ sub_RI x2 ⟹ length (compT E A ST x2) = length (compE₂ x2) - 1; ⋀E A ST. ¬ sub_RI x4 ⟹ length (compT E A ST x4) = length (compE₂ x4) - 1; ¬ sub_RI (RI (x1,x2) ; x3 ← x4)⟧ ⟹ length (compT E A ST (RI (x1,x2) ; x3 ← x4)) = length (compE₂ (RI (x1,x2) ; x3 ← x4)) - 1› 21. ‹⋀E A ST. ¬ sub_RIs [] ⟹ length (compTs E A ST []) = length (compEs₂ [])› 22. ‹⋀x1 x2 E A ST. ⟦⋀E A ST. ¬ sub_RI x1 ⟹ length (compT E A ST x1) = length (compE₂ x1) - 1; ⋀E A ST. ¬ sub_RIs x2 ⟹ length (compTs E A ST x2) = length (compEs₂ x2); ¬ sub_RIs (x1 # x2)⟧ ⟹ length (compTs E A ST (x1 # x2)) = length (compEs₂ (x1 # x2))› discuss goal 1*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 2*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 3*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 4*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 5*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 6*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 7*) apply ((auto split:bop.splits (*‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | Add ⇒ ?f2.0::?'a) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | Add ⇒ ?f2.0::?'a) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹(?P::nat ⇒ bool) ((?a::nat) - (?b::nat)) = ((?a < ?b ⟶ ?P (0::nat)) ∧ (∀d::nat. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI (?e::nat exp) ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 8*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 9*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 10*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 11*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 12*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 13*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 14*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 15*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 16*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 17*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 18*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 19*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 20*) apply ((auto split:bop.splits (*‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | Add ⇒ ?f2.0::?'a) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹(?P::?'a ⇒ bool) (case ?bop::bop of Eq ⇒ ?f1.0::?'a | Add ⇒ ?f2.0::?'a) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹(?P::nat ⇒ bool) ((?a::nat) - (?b::nat)) = ((?a < ?b ⟶ ?P (0::nat)) ∧ (∀d::nat. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI (?e::nat exp) ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 21*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*discuss goal 22*) apply ((auto split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*) nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*) simp: compE₂_not_Nil' (*‹¬ sub_RI ?e ⟹ compE₂ ?e ≠ []›*))[1]) (*proven 22 subgoals*) . (*>*) lemma (in TC1) compT_sizes[simp]: shows "⋀E A ST. P,E ⊢₁ e :: T ⟹ size(compT E A ST e) = size(compE₂ e) - 1" and "⋀E A ST. P,E ⊢₁ es [::] Ts ⟹ size(compTs E A ST es) = size(compEs₂ es)" (*<*)using compT_sizes' (*‹¬ sub_RI ?e ⟹ length (compT ?E ?A ?ST ?e) = length (compE₂ ?e) - 1› ‹¬ sub_RIs ?es ⟹ length (compTs ?E ?A ?ST ?es) = length (compEs₂ ?es)›*) "WT₁_nsub_RI" (*‹?P,?E ⊢₁ ?e :: ?T ⟹ ¬ sub_RI ?e›*) "WTs₁_nsub_RIs" (*‹?P,?E ⊢₁ ?es [::] ?Ts ⟹ ¬ sub_RIs ?es›*) apply - (*goals: 1. ‹⋀E A ST. ⟦P,E ⊢₁ e :: T; ⋀e E A ST. ¬ sub_RI e ⟹ length (compT E A ST e) = length (compE₂ e) - 1; ⋀es E A ST. ¬ sub_RIs es ⟹ length (compTs E A ST es) = length (compEs₂ es); ⋀P E e T. P,E ⊢₁ e :: T ⟹ ¬ sub_RI e; ⋀P E es Ts. P,E ⊢₁ es [::] Ts ⟹ ¬ sub_RIs es⟧ ⟹ length (compT E A ST e) = length (compE₂ e) - 1› 2. ‹⋀E A ST. ⟦P,E ⊢₁ es [::] Ts; ⋀e E A ST. ¬ sub_RI e ⟹ length (compT E A ST e) = length (compE₂ e) - 1; ⋀es E A ST. ¬ sub_RIs es ⟹ length (compTs E A ST es) = length (compEs₂ es); ⋀P E e T. P,E ⊢₁ e :: T ⟹ ¬ sub_RI e; ⋀P E es Ts. P,E ⊢₁ es [::] Ts ⟹ ¬ sub_RIs es⟧ ⟹ length (compTs E A ST es) = length (compEs₂ es)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) .(*>*) lemma (in TC1) [simp]: "⋀ST E. ⌊τ⌋ ∉ set (compT E None ST e)" and [simp]: "⋀ST E. ⌊τ⌋ ∉ set (compTs E None ST es)" (*<*)apply (induct e and es rule: compT.induct compTs.induct) (*goals: 1. ‹⋀x ST E. ⌊τ⌋ ∉ set (compT E None ST (new x))› 2. ‹⋀x1 x2 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x2)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (Cast x1 x2))› 3. ‹⋀x ST E. ⌊τ⌋ ∉ set (compT E None ST (Val x))› 4. ‹⋀x1 x2 x3 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x3)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1 «x2» x3))› 5. ‹⋀x ST E. ⌊τ⌋ ∉ set (compT E None ST (Var x))› 6. ‹⋀x1 x2 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x2)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1:=x2))› 7. ‹⋀x1 x2 x3 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1∙x2{x3}))› 8. ‹⋀x1 x2 x3 ST E. ⌊τ⌋ ∉ set (compT E None ST (x1∙⇩sx2{x3}))› 9. ‹⋀x1 x2 x3 x4 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x4)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1∙x2{x3} := x4))› 10. ‹⋀x1 x2 x3 x4 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x4)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1∙⇩sx2{x3} := x4))› 11. ‹⋀x1 x2 x3 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compTs E None ST x3)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1∙x2(x3)))› 12. ‹⋀x1 x2 x3 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compTs E None ST x3)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1∙⇩sx2(x3)))› 13. ‹⋀x1 x2 x3 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x3)) ⟹ ⌊τ⌋ ∉ set (compT E None ST {x1:x2; x3})› 14. ‹⋀x1 x2 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x2)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (x1;; x2))› 15. ‹⋀x1 x2 x3 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x2); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x3)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (if (x1) x2 else x3))› 16. ‹⋀x1 x2 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x2)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (while (x1) x2))› 17. ‹⋀x ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (throw x))› 18. ‹⋀x1 x2 x3 x4 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x4)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (try x1 catch(x2 x3) x4))› 19. ‹⋀x1 x2 x3 x4 ST E. (⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x4)) ⟹ ⌊τ⌋ ∉ set (compT E None ST (INIT x1 (x2,x3) ← x4))› 20. ‹⋀x1 x2 x3 x4 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x2); ⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x4)⟧ ⟹ ⌊τ⌋ ∉ set (compT E None ST (RI (x1,x2) ; x3 ← x4))› 21. ‹⋀ST E. ⌊τ⌋ ∉ set (compTs E None ST [])› 22. ‹⋀x1 x2 ST E. ⟦⋀ST E. ⌊τ⌋ ∉ set (compT E None ST x1); ⋀ST E. ⌊τ⌋ ∉ set (compTs E None ST x2)⟧ ⟹ ⌊τ⌋ ∉ set (compTs E None ST (x1 # x2))› discuss goal 1*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 2*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 3*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 4*) apply (simp add:after_def (*‹after (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 5*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 6*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 7*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 8*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 9*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 10*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 11*) apply (simp add:after_def (*‹after (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 12*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 13*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 14*) apply (simp add:after_def (*‹after (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 15*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 16*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 17*) apply (simp add:after_def (*‹after (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 18*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 19*) apply (simp add:after_def (*‹after (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 20*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 21*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*discuss goal 22*) apply (simp add:after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*)) (*proven 22 subgoals*) .(*>*) lemma (in TC0) pair_eq_ty⇩i'_conv: "(⌊(ST, LT)⌋ = ty⇩i' ST₀ E A) = (case A of None ⇒ False | Some A ⇒ (ST = ST₀ ∧ LT = ty⇩l E A))" (*<*)by (simp add:ty⇩i'_def (*‹ty⇩i' (?ST::?'a::type) (?E::?'b::type list) (?A::nat set option) = (case ?A of None ⇒ None | ⌊A'::nat set⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*))(*>*) lemma (in TC0) pair_conv_ty⇩i': "⌊(ST, ty⇩l E A)⌋ = ty⇩i' ST E ⌊A⌋" (*<*)by (simp add:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*))(*>*) (*<*) declare (in TC0) ty⇩i'_antimono [intro!] after_def[simp] pair_conv_ty⇩i'[simp] pair_eq_ty⇩i'_conv[simp] (*>*) lemma (in TC1) compT_LT_prefix: "⋀E A ST₀. ⟦ ⌊(ST,LT)⌋ ∈ set(compT E A ST₀ e); ℬ e (size E) ⟧ ⟹ P ⊢ ⌊(ST,LT)⌋ ≤' ty⇩i' ST E A" and "⋀E A ST₀. ⟦ ⌊(ST,LT)⌋ ∈ set(compTs E A ST₀ es); ℬs es (size E) ⟧ ⟹ P ⊢ ⌊(ST,LT)⌋ ≤' ty⇩i' ST E A" (*<*) proof (induct e and es rule: compT.induct compTs.induct) (*goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3)); ℬ (x1 «x2» x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3} := x4)); ℬ (x1∙x2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3}); ℬ {x1:x2; x3} (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2)); ℬ (x1;; x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3)); ℬ (if (x1) x2 else x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2)); ℬ (while (x1) x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 17. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 18. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 19. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 20. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 21. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 22. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case FAss (*‹⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x1_::nat exp)); ℬ x1_ (length ?E2)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x4_); ℬ x4_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_∙x2_{x3_} := x4_))› ‹ℬ (x1_∙x2_{x3_} := x4_) (length E)›*) thus "?case" (*goal: ‹(P::nat exp prog) ⊢ ⌊(ST::ty list, LT::ty err list)⌋ ≤' ty⇩i' ST (E::ty list) (A::nat set option)›*) by (fastforce simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) elim!:sup_state_opt_trans (*‹⟦?P ⊢ ?a ≤' ?b; ?P ⊢ ?b ≤' ?c⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) next (*goals: 1. ‹⋀(x::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀(x1::char list) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀(x::val) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀(x1::nat exp) (x2::bop) (x3::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3)); ℬ (x1 «x2» x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀(x::nat) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀(x1::nat) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀(x1::char list) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀(x1::nat exp) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀(x1::char list) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀(x1::nat) (x2::ty) (x3::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3}); ℬ {x1:x2; x3} (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀(x1::nat exp) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2)); ℬ (x1;; x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀(x1::nat exp) (x2::nat exp) (x3::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3)); ℬ (if (x1) x2 else x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀(x1::nat exp) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2)); ℬ (while (x1) x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀(x::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 17. ‹⋀(x1::nat exp) (x2::char list) (x3::nat) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 18. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 19. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 20. ‹⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 21. ‹⋀(x1::nat exp) (x2::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case BinOp (*‹⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x1_::nat exp)); ℬ x1_ (length ?E2)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x3_::nat exp)); ℬ x3_ (length ?E2)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_ «x2_» x3_))› ‹ℬ (x1_ «x2_» x3_) (length E)›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (fastforce simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) elim!:sup_state_opt_trans (*‹⟦?P ⊢ ?a ≤' ?b; ?P ⊢ ?b ≤' ?c⟧ ⟹ ?P ⊢ ?a ≤' ?c›*) split:bop.splits (*‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = ((?bop = Eq ⟶ ?P ?f1.0) ∧ (?bop = Add ⟶ ?P ?f2.0))› ‹?P (case ?bop of Eq ⇒ ?f1.0 | Add ⇒ ?f2.0) = (¬ (?bop = Eq ∧ ¬ ?P ?f1.0 ∨ ?bop = Add ∧ ¬ ?P ?f2.0))›*)) next (*goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3}); ℬ {x1:x2; x3} (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2)); ℬ (x1;; x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3)); ℬ (if (x1) x2 else x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2)); ℬ (while (x1) x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 17. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 18. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 19. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 20. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case Seq (*‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_); ℬ x1_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_); ℬ x2_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_;; x2_))› ‹ℬ ((x1_::nat exp);; (x2_::nat exp)) (length (E::ty list))›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (fastforce simp:hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*) elim!:sup_state_opt_trans (*‹⟦(?P::?'a prog) ⊢ (?a::(ty list × ty err list) option) ≤' (?b::(ty list × ty err list) option); ?P ⊢ ?b ≤' (?c::(ty list × ty err list) option)⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) next (*goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3}); ℬ {x1:x2; x3} (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3)); ℬ (if (x1) x2 else x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2)); ℬ (while (x1) x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 17. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 18. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 19. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case While (*‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_); ℬ x1_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_); ℬ x2_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1_) x2_))› ‹ℬ (while ((x1_::nat exp)) (x2_::nat exp)) (length (E::ty list))›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (fastforce simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) elim!:sup_state_opt_trans (*‹⟦?P ⊢ ?a ≤' ?b; ?P ⊢ ?b ≤' ?c⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) next (*goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3}); ℬ {x1:x2; x3} (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3)); ℬ (if (x1) x2 else x3) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 17. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 18. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case Cond (*‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_); ℬ x1_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_); ℬ x2_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x3_); ℬ x3_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ST₀::ty list) (if ((x1_::nat exp)) (x2_::nat exp) else (x3_::nat exp)))› ‹ℬ (if (x1_) x2_ else x3_) (length E)›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (msorry) next (*goals: 1. ‹⋀(x::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀(x1::char list) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀(x::val) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀(x::nat) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀(x1::nat) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀(x1::char list) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀(x1::nat exp) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀(x1::char list) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀(x1::nat) (x2::ty) (x3::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x3); ℬ x3 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3}); ℬ {x1:x2; x3} (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀(x::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀(x1::nat exp) (x2::char list) (x3::nat) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 17. ‹⋀(x1::nat exp) (x2::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case Block (*‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x3_); ℬ x3_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1_:x2_; x3_})› ‹ℬ {x1_::nat:x2_::ty; x3_::nat exp} (length (E::ty list))›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (force simp add:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) simp del:pair_conv_ty⇩i' (*‹⌊(?ST, ty⇩l ?E ?A)⌋ = ty⇩i' ?ST ?E ⌊?A⌋›*) elim!:sup_state_opt_trans (*‹⟦?P ⊢ ?a ≤' ?b; ?P ⊢ ?b ≤' ?c⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) next (*goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3))); ℬ (x1∙x2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 16. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case Call (*‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_); ℬ x1_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 x3_); ℬs x3_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_∙x2_(x3_)))› ‹ℬ (x1_∙x2_(x3_)) (length E)›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (fastforce simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) elim!:sup_state_opt_trans (*‹⟦?P ⊢ ?a ≤' ?b; ?P ⊢ ?b ≤' ?c⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) next (*goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 15. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2); ℬs x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2)); ℬs (x1 # x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case Cons_exp (*‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_); ℬ x1_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 x2_); ℬs x2_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1_ # x2_))› ‹ℬs (x1_ # x2_) (length E)›*) thus "?case" (*goal: ‹P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) by (fastforce simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) elim!:sup_state_opt_trans (*‹⟦?P ⊢ ?a ≤' ?b; ?P ⊢ ?b ≤' ?c⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) next (*goals: 1. ‹⋀(x::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀(x1::char list) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀(x::val) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀(x::nat) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀(x1::nat) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀(x1::char list) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀(x1::char list) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀(x::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀(x1::nat exp) (x2::char list) (x3::nat) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4)); ℬ (try x1 catch(x2 x3) x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 14. ‹⋀(E::ty list) (A::nat set option) ST₀::ty list. ⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) case TryCatch (*‹⟦⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x1_::nat exp)); ℬ x1_ (length ?E2)⟧ ⟹ (P::nat exp prog) ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⟦⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x4_); ℬ x4_ (length ?E2)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST ?E2 ?A2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1_ catch(x2_ x3_) x4_))› ‹ℬ (try x1_ catch(x2_ x3_) x4_) (length E)›*) thus "?case" (*goal: ‹(P::nat exp prog) ⊢ ⌊(ST::ty list, LT::ty err list)⌋ ≤' ty⇩i' ST (E::ty list) (A::nat set option)›*) by (fastforce simp:hyperset_defs (*‹(?A::?'a set option) ⊔ (?B::?'a set option) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ None | ⌊B::?'a set⌋ ⇒ ⌊A ∪ B⌋› ‹(?A::?'a set option) ⊓ (?B::?'a set option) ≡ case ?A of None ⇒ ?B | ⌊A::?'a set⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B::?'a set⌋ ⇒ ⌊A ∩ B⌋› ‹(?A::?'a set option) ⊖ (?a::?'a) ≡ case ?A of None ⇒ None | ⌊A::?'a set⌋ ⇒ ⌊A - {?a}⌋› ‹(?a::?'a) ∈∈ (?A::?'a set option) ≡ case ?A of None ⇒ True | ⌊A::?'a set⌋ ⇒ ?a ∈ A› ‹(?A::?'a set option) ⊑ (?B::?'a set option) ≡ case ?B of None ⇒ True | ⌊B::?'a set⌋ ⇒ case ?A of None ⇒ False | ⌊A::?'a set⌋ ⇒ A ⊆ B›*) intro!: ty⇩i'_incr (*‹(P::nat exp prog) ⊢ ty⇩i' (?ST::ty list) ((?E::ty list) @ [?T::ty]) ⌊insert (length ?E) (?A::nat set)⌋ ≤' ty⇩i' ?ST ?E ⌊?A⌋›*) elim!:sup_state_opt_trans (*‹⟦(?P::?'a prog) ⊢ (?a::(ty list × ty err list) option) ≤' (?b::(ty list × ty err list) option); ?P ⊢ ?b ≤' (?c::(ty list × ty err list) option)⟧ ⟹ ?P ⊢ ?a ≤' ?c›*)) qed (auto simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*)) (*solves the remaining goals: 1. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)); ℬ (new x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2)); ℬ (Cast x1 x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 3. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)); ℬ (Val x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 4. ‹⋀x E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)); ℬ (Var x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2)); ℬ (x1:=x2) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1); ℬ x1 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3})); ℬ (x1∙x2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})); ℬ (x1∙⇩sx2{x3}) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4)); ℬ (x1∙⇩sx2{x3} := x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3); ℬs x3 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3))); ℬ (x1∙⇩sx2(x3)) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 10. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x); ℬ x (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x)); ℬ (throw x) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 11. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4)); ℬ (INIT x1 (x2,x3) ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 12. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2); ℬ x2 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4); ℬ x4 (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4)); ℬ (RI (x1,x2) ; x3 ← x4) (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A› 13. ‹⋀E A ST₀. ⟦⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []); ℬs [] (length E)⟧ ⟹ P ⊢ ⌊(ST, LT)⌋ ≤' ty⇩i' ST E A›*) declare (in TC0) ty⇩i'_antimono [rule del] after_def[simp del] pair_conv_ty⇩i'[simp del] pair_eq_ty⇩i'_conv[simp del] (*>*) lemma [iff]: "OK None ∈ states P mxs mxl" (*<*)by (simp add: JVM_states_unfold (*‹states (?P::?'a prog) (?mxs::nat) (?mxl::nat) ≡ err (opt (⋃ {nlists n (types ?P) |n::nat. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*))(*>*) lemma (in TC0) after_in_states: assumes wf: "wf_prog p P" and wt: "P,E ⊢₁ e :: T" and Etypes: "set E ⊆ types P" and STtypes: "set ST ⊆ types P" and stack: "size ST + max_stack e ≤ mxs" shows "OK (after E A ST e) ∈ states P mxs mxl" (*<*) proof (-) (*goal: ‹OK (after E A ST e) ∈ states P mxs mxl›*) have "size ST + 1 ≤ mxs" using max_stack1[where e = e] (*‹?P,?E ⊢₁ e :: ?T ⟹ 1 ≤ max_stack e›*) wt (*‹(P::nat exp prog),(E::ty list) ⊢₁ (e::nat exp) :: T::ty›*) stack (*‹length ST + max_stack e ≤ mxs›*) by fastforce then show "?thesis" (*goal: ‹OK (after E A ST e) ∈ states P mxs mxl›*) using assms (*‹wf_prog (p::nat exp prog ⇒ char list ⇒ nat exp mdecl ⇒ bool) (P::nat exp prog)› ‹(P::nat exp prog),(E::ty list) ⊢₁ (e::nat exp) :: T::ty› ‹set (E::ty list) ⊆ types (P::nat exp prog)› ‹set ST ⊆ types P› ‹length ST + max_stack e ≤ mxs›*) apply (simp add: after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*) ty⇩l_in_types (*‹set ?E ⊆ types P ⟹ ty⇩l ?E ?A ∈ nlists mxl (err (types P))›*)) (*goal: ‹OK (after E A ST e) ∈ states P mxs mxl›*) by (blast intro!:nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*) WT₁_is_type (*‹⟦wf_prog ?p ?P; ?P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types ?P⟧ ⟹ is_type ?P ?T›*)) qed (*>*) lemma (in TC0) OK_ty⇩i'_in_statesI[simp]: "⟦ set E ⊆ types P; set ST ⊆ types P; size ST ≤ mxs ⟧ ⟹ OK (ty⇩i' ST E A) ∈ states P mxs mxl" (*<*) apply (simp add:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*) ty⇩l_in_types (*‹set ?E ⊆ types P ⟹ ty⇩l ?E ?A ∈ nlists mxl (err (types P))›*)) (*goal: ‹⟦set (E::ty list) ⊆ types (P::nat exp prog); set (ST::ty list) ⊆ types P; length ST ≤ (mxs::nat)⟧ ⟹ OK (ty⇩i' ST E (A::nat set option)) ∈ states P mxs (mxl::nat)›*) by (blast intro!:nlistsI (*‹⟦length ?xs = ?n; set ?xs ⊆ ?A⟧ ⟹ ?xs ∈ nlists ?n ?A›*)) (*>*) lemma is_class_type_aux: "is_class P C ⟹ is_type P (Class C)" (*<*)by simp(*>*) (*<*) declare is_type_simps[simp del] subsetI[rule del] (*>*) theorem (in TC1) compT_states: assumes wf: "wf_prog p P" shows "⋀E T A ST. ⟦ P,E ⊢₁ e :: T; set E ⊆ types P; set ST ⊆ types P; size ST + max_stack e ≤ mxs; size E + max_vars e ≤ mxl ⟧ ⟹ OK ` set(compT E A ST e) ⊆ states P mxs mxl" (*<*)(is "⋀E T A ST. PROP ?P e E T A ST")(*>*) and "⋀E Ts A ST. ⟦ P,E ⊢₁ es[::]Ts; set E ⊆ types P; set ST ⊆ types P; size ST + max_stacks es ≤ mxs; size E + max_varss es ≤ mxl ⟧ ⟹ OK ` set(compTs E A ST es) ⊆ states P mxs mxl" (*<*)(is "⋀E Ts A ST. PROP ?Ps es E Ts A ST") proof (induct e and es rule: compT.induct compTs.induct) (*goals: 1. ‹⋀x E T A ST. ⟦P,E ⊢₁ new x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (new x) ≤ mxs; length E + max_vars (new x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (new x)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ Cast x1 x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Cast x1 x2) ≤ mxs; length E + max_vars (Cast x1 x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Cast x1 x2)) ⊆ states P mxs mxl› 3. ‹⋀x E T A ST. ⟦P,E ⊢₁ Val x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Val x) ≤ mxs; length E + max_vars (Val x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Val x)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 5. ‹⋀x E T A ST. ⟦P,E ⊢₁ Var x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Var x) ≤ mxs; length E + max_vars (Var x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Var x)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1:=x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1:=x2) ≤ mxs; length E + max_vars (x1:=x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1:=x2)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3}) ≤ mxs; length E + max_vars (x1∙x2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3})) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 E T A ST. ⟦P,E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 15. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 16. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 17. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 18. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 19. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 20. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 21. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 22. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case new (*‹P,E ⊢₁ new x_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (new x_) ≤ mxs› ‹length E + max_vars (new x_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (new x_)) ⊆ states P mxs mxl›*) by simp next (*goals: 1. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ Cast x1 x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Cast x1 x2) ≤ mxs; length E + max_vars (Cast x1 x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Cast x1 x2)) ⊆ states P mxs mxl› 2. ‹⋀x E T A ST. ⟦P,E ⊢₁ Val x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Val x) ≤ mxs; length E + max_vars (Val x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Val x)) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 4. ‹⋀x E T A ST. ⟦P,E ⊢₁ Var x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Var x) ≤ mxs; length E + max_vars (Var x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Var x)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1:=x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1:=x2) ≤ mxs; length E + max_vars (x1:=x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1:=x2)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3}) ≤ mxs; length E + max_vars (x1∙x2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3})) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 E T A ST. ⟦P,E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 15. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 16. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 17. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 18. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 19. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 20. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 21. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case (Cast C e) (*‹⟦P,?E2 ⊢₁ e :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack e ≤ mxs; length ?E2 + max_vars e ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 e) ⊆ states P mxs mxl› ‹P,E ⊢₁ Cast C e :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (Cast C e) ≤ mxs› ‹length E + max_vars (Cast C e) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (Cast C e)) ⊆ states P mxs mxl›*) by (auto simp:after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x E T A ST. ⟦P,E ⊢₁ Val x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Val x) ≤ mxs; length E + max_vars (Val x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Val x)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 3. ‹⋀x E T A ST. ⟦P,E ⊢₁ Var x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Var x) ≤ mxs; length E + max_vars (Var x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (Var x)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1:=x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1:=x2) ≤ mxs; length E + max_vars (x1:=x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1:=x2)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3}) ≤ mxs; length E + max_vars (x1∙x2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3})) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 E T A ST. ⟦P,E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 15. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 16. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 17. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 18. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 19. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 20. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Val (*‹P,E ⊢₁ Val x_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length (ST::ty list) + max_stack (Val (x_::val)) ≤ (mxs::nat)› ‹length E + max_vars (Val x_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (Val x_)) ⊆ states P mxs mxl›*) by simp next (*goals: 1. ‹⋀(x1::nat exp) (x2::bop) (x3::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀(x::nat) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ Var x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (Var x) ≤ (mxs::nat); length E + max_vars (Var x) ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST (Var x)) ⊆ states P mxs mxl› 3. ‹⋀(x1::nat) (x2::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ (mxs::nat); length E + max_vars x2 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1:=x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1:=x2) ≤ mxs; length E + max_vars (x1:=x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1:=x2)) ⊆ states P mxs mxl› 4. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3}) ≤ mxs; length E + max_vars (x1∙x2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3})) ⊆ states P mxs mxl› 5. ‹⋀(x1::char list) (x2::char list) (x3::char list) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ (mxs::nat); length E + max_vars (x1∙⇩sx2{x3}) ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 6. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 7. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ (mxs::nat); length E + max_vars x4 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 8. ‹⋀(x1::nat exp) (x2::char list) (x3::nat exp list) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (Ts::ty list) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 9. ‹⋀(x1::char list) (x2::char list) (x3::nat exp list) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (Ts::ty list) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ (mxs::nat); length E + max_varss x3 ≤ (mxl::nat)⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 10. ‹⋀(x1::nat) (x2::ty) (x3::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ (mxs::nat); length E + max_vars x3 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 11. ‹⋀(x1::nat exp) (x2::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 12. ‹⋀(x1::nat exp) (x2::nat exp) (x3::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 13. ‹⋀(x1::nat exp) (x2::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 14. ‹⋀(x::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ (mxs::nat); length E + max_vars x ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 15. ‹⋀(x1::nat exp) (x2::char list) (x3::nat) (x4::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 16. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ (mxs::nat); length E + max_vars x4 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 17. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ (mxs::nat); length E + max_vars x2 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 18. ‹⋀(E::ty list) (Ts::ty list) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ (mxs::nat); length E + max_varss [] ≤ (mxl::nat)⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 19. ‹⋀(x1::nat exp) (x2::nat exp list) (E::ty list) (Ts::ty list) (A::nat set option) ST::ty list. ⟦⋀(E::ty list) (T::ty) (A::nat set option) ST::ty list. ⟦(P::nat exp prog),E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ (mxs::nat); length E + max_vars x1 ≤ (mxl::nat)⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀(E::ty list) (Ts::ty list) (A::nat set option) ST::ty list. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Var (*‹P,E ⊢₁ Var x_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (Var x_) ≤ mxs› ‹length (E::ty list) + max_vars (Var (x_::nat)) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (Var x_)) ⊆ states P mxs mxl›*) by simp next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1:=x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1:=x2) ≤ mxs; length E + max_vars (x1:=x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1:=x2)) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3}) ≤ mxs; length E + max_vars (x1∙x2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3})) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦P,E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 13. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 15. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 16. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 17. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 18. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case LAss (*‹⟦P,?E2 ⊢₁ x2_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x2_ ≤ mxs; length ?E2 + max_vars x2_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x2_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_:=x2_ :: T› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stack (x1_:=x2_) ≤ mxs› ‹length E + max_vars (x1_:=x2_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_:=x2_)) ⊆ states P mxs mxl›*) by (auto simp:after_in_states[OF wf] (*‹⟦(P::nat exp prog),(?E::ty list) ⊢₁ (?e::nat exp) :: ?T::ty; set ?E ⊆ types P; set (?ST::ty list) ⊆ types P; length ?ST + max_stack ?e ≤ (?mxs::nat)⟧ ⟹ OK (after ?E (?A::nat set option) ?ST ?e) ∈ states P ?mxs (mxl::nat)›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3}) ≤ mxs; length E + max_vars (x1∙x2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3})) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦P,E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 12. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 15. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 16. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 17. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case FAcc (*‹⟦P,?E2 ⊢₁ x1_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x1_ ≤ mxs; length ?E2 + max_vars x1_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x1_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_∙x2_{x3_} :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (x1_∙x2_{x3_}) ≤ mxs› ‹length (E::ty list) + max_vars ((x1_::nat exp)∙(x2_::char list){(x3_::char list)}) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_∙x2_{x3_})) ⊆ states P mxs mxl›*) by (auto simp:after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦P,E ⊢₁ x1∙⇩sx2{x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3}) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3}) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3})) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 11. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 15. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 16. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case SFAcc (*‹P,E ⊢₁ x1_∙⇩sx2_{x3_} :: T› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stack (x1_∙⇩sx2_{x3_}) ≤ mxs› ‹length (E::ty list) + max_vars ((x1_::char list)∙⇩s(x2_::char list){(x3_::char list)}) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_∙⇩sx2_{x3_})) ⊆ states P mxs mxl›*) by (auto simp:after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2{x3} := x4) ≤ mxs; length E + max_vars (x1∙x2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2{x3} := x4)) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 10. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 14. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 15. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case FAss (*‹⟦(P::nat exp prog),(?E2::ty list) ⊢₁ (x1_::nat exp) :: ?T2::ty; set ?E2 ⊆ types P; set (?ST2::ty list) ⊆ types P; length ?ST2 + max_stack x1_ ≤ (mxs::nat); length ?E2 + max_vars x1_ ≤ (mxl::nat)⟧ ⟹ OK ` set (compT ?E2 (?A2::nat set option) ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x4_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x4_ ≤ mxs; length ?E2 + max_vars x4_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x4_) ⊆ states P mxs mxl› ‹(P::nat exp prog),(E::ty list) ⊢₁ (x1_::nat exp)∙(x2_::char list){(x3_::char list)} := (x4_::nat exp) :: T::ty› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stack (x1_∙x2_{x3_} := x4_) ≤ mxs› ‹length E + max_vars (x1_∙x2_{x3_} := x4_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_∙x2_{x3_} := x4_)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2{x3} := x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2{x3} := x4) ≤ mxs; length E + max_vars (x1∙⇩sx2{x3} := x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2{x3} := x4)) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 9. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 13. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 14. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case SFAss (*‹⟦P,?E2 ⊢₁ x4_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x4_ ≤ mxs; length ?E2 + max_vars x4_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x4_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_∙⇩sx2_{x3_} := x4_ :: T› ‹set (E::ty list) ⊆ types (P::nat exp prog)› ‹set ST ⊆ types P› ‹length ST + max_stack (x1_∙⇩sx2_{x3_} := x4_) ≤ mxs› ‹length E + max_vars (x1_∙⇩sx2_{x3_} := x4_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_∙⇩sx2_{x3_} := x4_)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹(?f::?'b ⇒ ?'a) ` ((?A::?'b set) ∪ (?B::?'b set)) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦(P::nat exp prog),(?E::ty list) ⊢₁ (?e::nat exp) :: ?T::ty; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦(P::nat exp prog),(?E::ty list) ⊢₁ (?e::nat exp) :: ?T::ty; set ?E ⊆ types P; set (?ST::ty list) ⊆ types P; length ?ST + max_stack ?e ≤ (?mxs::nat)⟧ ⟹ OK (after ?E (?A::nat set option) ?ST ?e) ∈ states P ?mxs (mxl::nat)›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1;; x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1;; x2) ≤ mxs; length E + max_vars (x1;; x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1;; x2)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 8. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 12. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 13. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Seq (*‹⟦P,?E2 ⊢₁ x1_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x1_ ≤ mxs; length ?E2 + max_vars x1_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x2_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x2_ ≤ mxs; length ?E2 + max_vars x2_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x2_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_;; x2_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length (ST::ty list) + max_stack ((x1_::nat exp);; (x2_::nat exp)) ≤ (mxs::nat)› ‹length (E::ty list) + max_vars ((x1_::nat exp);; (x2_::nat exp)) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_;; x2_)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1 «x2» x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1 «x2» x3) ≤ mxs; length E + max_vars (x1 «x2» x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1 «x2» x3)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 7. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 11. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 12. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case BinOp (*‹⟦P,?E2 ⊢₁ x1_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x1_ ≤ mxs; length ?E2 + max_vars x1_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x3_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x3_ ≤ mxs; length ?E2 + max_vars x3_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x3_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_ «x2_» x3_ :: T› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stack (x1_ «x2_» x3_) ≤ mxs› ‹length E + max_vars (x1_ «x2_» x3_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_ «x2_» x3_)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ if (x1) x2 else x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (if (x1) x2 else x3) ≤ mxs; length E + max_vars (if (x1) x2 else x3) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (if (x1) x2 else x3)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 6. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 10. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 11. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Cond (*‹⟦(P::nat exp prog),(?E2::ty list) ⊢₁ (x1_::nat exp) :: ?T2::ty; set ?E2 ⊆ types P; set (?ST2::ty list) ⊆ types P; length ?ST2 + max_stack x1_ ≤ (mxs::nat); length ?E2 + max_vars x1_ ≤ (mxl::nat)⟧ ⟹ OK ` set (compT ?E2 (?A2::nat set option) ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x2_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x2_ ≤ mxs; length ?E2 + max_vars x2_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x2_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x3_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x3_ ≤ mxs; length ?E2 + max_vars x3_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x3_) ⊆ states P mxs mxl› ‹(P::nat exp prog),(E::ty list) ⊢₁ if ((x1_::nat exp)) (x2_::nat exp) else (x3_::nat exp) :: T::ty› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (if (x1_) x2_ else x3_) ≤ mxs› ‹length E + max_vars (if (x1_) x2_ else x3_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT (E::ty list) (A::nat set option) (ST::ty list) (if ((x1_::nat exp)) (x2_::nat exp) else (x3_::nat exp))) ⊆ states (P::nat exp prog) (mxs::nat) (mxl::nat)›*) by (force simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ while (x1) x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (while (x1) x2) ≤ mxs; length E + max_vars (while (x1) x2) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (while (x1) x2)) ⊆ states P mxs mxl› 5. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 9. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 10. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case While (*‹⟦(P::nat exp prog),(?E2::ty list) ⊢₁ (x1_::nat exp) :: ?T2::ty; set ?E2 ⊆ types P; set (?ST2::ty list) ⊆ types P; length ?ST2 + max_stack x1_ ≤ (mxs::nat); length ?E2 + max_vars x1_ ≤ (mxl::nat)⟧ ⟹ OK ` set (compT ?E2 (?A2::nat set option) ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x2_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x2_ ≤ mxs; length ?E2 + max_vars x2_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x2_) ⊆ states P mxs mxl› ‹P,E ⊢₁ while (x1_) x2_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (while (x1_) x2_) ≤ mxs› ‹length (E::ty list) + max_vars (while ((x1_::nat exp)) (x2_::nat exp)) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (while (x1_) x2_)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x3 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x3 ≤ mxs; length E + max_vars x3 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ {x1:x2; x3} :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack {x1:x2; x3} ≤ mxs; length E + max_vars {x1:x2; x3} ≤ mxl⟧ ⟹ OK ` set (compT E A ST {x1:x2; x3}) ⊆ states P mxs mxl› 4. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 8. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 9. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Block (*‹⟦(P::nat exp prog),(?E2::ty list) ⊢₁ (x3_::nat exp) :: ?T2::ty; set ?E2 ⊆ types P; set (?ST2::ty list) ⊆ types P; length ?ST2 + max_stack x3_ ≤ (mxs::nat); length ?E2 + max_vars x3_ ≤ (mxl::nat)⟧ ⟹ OK ` set (compT ?E2 (?A2::nat set option) ?ST2 x3_) ⊆ states P mxs mxl› ‹P,E ⊢₁ {x1_:x2_; x3_} :: T› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stack {x1_:x2_; x3_} ≤ mxs› ‹length E + max_vars {x1_:x2_; x3_} ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST {x1_:x2_; x3_}) ⊆ states P mxs mxl›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ try x1 catch(x2 x3) x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (try x1 catch(x2 x3) x4) ≤ mxs; length E + max_vars (try x1 catch(x2 x3) x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (try x1 catch(x2 x3) x4)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 7. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 8. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case (TryCatch e₁ C i e₂) (*‹⟦(P::nat exp prog),(?E2::ty list) ⊢₁ (e₁::nat exp) :: ?T2::ty; set ?E2 ⊆ types P; set (?ST2::ty list) ⊆ types P; length ?ST2 + max_stack e₁ ≤ (mxs::nat); length ?E2 + max_vars e₁ ≤ (mxl::nat)⟧ ⟹ OK ` set (compT ?E2 (?A2::nat set option) ?ST2 e₁) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ e₂ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack e₂ ≤ mxs; length ?E2 + max_vars e₂ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 e₂) ⊆ states P mxs mxl› ‹P,E ⊢₁ try e₁ catch(C i) e₂ :: T› ‹set (E::ty list) ⊆ types (P::nat exp prog)› ‹set ST ⊆ types P› ‹length ST + max_stack (try e₁ catch(C i) e₂) ≤ mxs› ‹length E + max_vars (try e₁ catch(C i) e₂) ≤ mxl›*) moreover have "size ST + 1 ≤ mxs" using TryCatch.prems (*‹P,E ⊢₁ try e₁ catch(C i) e₂ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (try e₁ catch(C i) e₂) ≤ mxs› ‹length E + max_vars (try e₁ catch(C i) e₂) ≤ mxl›*) max_stack1[where e = e₁] (*‹?P,?E ⊢₁ e₁ :: ?T ⟹ 1 ≤ max_stack e₁›*) by fastforce ultimately show "?case" (*goal: ‹OK ` set (compT E A ST (try e₁ catch(C i) e₂)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*) is_class_type_aux (*‹is_class ?P ?C ⟹ is_type ?P (Class ?C)›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 6. ‹⋀E Ts A ST. ⟦P,E ⊢₁ [] [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks [] ≤ mxs; length E + max_varss [] ≤ mxl⟧ ⟹ OK ` set (compTs E A ST []) ⊆ states P mxs mxl› 7. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Nil_exp (*‹P,E ⊢₁ [] [::] Ts› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stacks [] ≤ mxs› ‹length E + max_varss [] ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compTs (E::ty list) (A::nat set option) (ST::ty list) []) ⊆ states (P::nat exp prog) (mxs::nat) (mxl::nat)›*) by simp next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl› 6. ‹⋀x1 x2 E Ts A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x2 ≤ mxs; length E + max_varss x2 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x2) ⊆ states P mxs mxl; P,E ⊢₁ x1 # x2 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks (x1 # x2) ≤ mxs; length E + max_varss (x1 # x2) ≤ mxl⟧ ⟹ OK ` set (compTs E A ST (x1 # x2)) ⊆ states P mxs mxl›*) case Cons_exp (*‹⟦P,?E2 ⊢₁ x1_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x1_ ≤ mxs; length ?E2 + max_vars x1_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x2_ [::] ?Ts2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stacks x2_ ≤ mxs; length ?E2 + max_varss x2_ ≤ mxl⟧ ⟹ OK ` set (compTs ?E2 ?A2 ?ST2 x2_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_ # x2_ [::] Ts› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stacks (x1_ # x2_) ≤ mxs› ‹length E + max_varss (x1_ # x2_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compTs E A ST (x1_ # x2_)) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x ≤ mxs; length E + max_vars x ≤ mxl⟧ ⟹ OK ` set (compT E A ST x) ⊆ states P mxs mxl; P,E ⊢₁ throw x :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (throw x) ≤ mxs; length E + max_vars (throw x) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (throw x)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 5. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl›*) case throw (*‹⟦P,?E2 ⊢₁ x_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x_ ≤ mxs; length ?E2 + max_vars x_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x_) ⊆ states P mxs mxl› ‹P,E ⊢₁ throw x_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (throw x_) ≤ mxs› ‹length E + max_vars (throw x_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (throw x_)) ⊆ states P mxs mxl›*) by (auto simp: WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x1 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x1 ≤ mxs; length E + max_vars x1 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x1) ⊆ states P mxs mxl; ⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙x2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙x2(x3)) ≤ mxs; length E + max_vars (x1∙x2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙x2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 4. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl›*) case Call (*‹⟦P,?E2 ⊢₁ x1_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x1_ ≤ mxs; length ?E2 + max_vars x1_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x1_) ⊆ states P mxs mxl› ‹⟦(P::nat exp prog),(?E2::ty list) ⊢₁ (x3_::nat exp list) [::] ?Ts2::ty list; set ?E2 ⊆ types P; set (?ST2::ty list) ⊆ types P; length ?ST2 + max_stacks x3_ ≤ (mxs::nat); length ?E2 + max_varss x3_ ≤ (mxl::nat)⟧ ⟹ OK ` set (compTs ?E2 (?A2::nat set option) ?ST2 x3_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_∙x2_(x3_) :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (x1_∙x2_(x3_)) ≤ mxs› ‹length E + max_vars (x1_∙x2_(x3_)) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_∙x2_(x3_))) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 E T A ST. ⟦⋀E Ts A ST. ⟦P,E ⊢₁ x3 [::] Ts; set E ⊆ types P; set ST ⊆ types P; length ST + max_stacks x3 ≤ mxs; length E + max_varss x3 ≤ mxl⟧ ⟹ OK ` set (compTs E A ST x3) ⊆ states P mxs mxl; P,E ⊢₁ x1∙⇩sx2(x3) :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (x1∙⇩sx2(x3)) ≤ mxs; length E + max_vars (x1∙⇩sx2(x3)) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (x1∙⇩sx2(x3))) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 3. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl›*) case SCall (*‹⟦P,?E2 ⊢₁ x3_ [::] ?Ts2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stacks x3_ ≤ mxs; length ?E2 + max_varss x3_ ≤ mxl⟧ ⟹ OK ` set (compTs ?E2 ?A2 ?ST2 x3_) ⊆ states P mxs mxl› ‹P,E ⊢₁ x1_∙⇩sx2_(x3_) :: T› ‹set E ⊆ types P› ‹set (ST::ty list) ⊆ types (P::nat exp prog)› ‹length ST + max_stack (x1_∙⇩sx2_(x3_)) ≤ mxs› ‹length (E::ty list) + max_vars ((x1_::char list)∙⇩s(x2_::char list)(x3_::nat exp list)) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (x1_∙⇩sx2_(x3_))) ⊆ states P mxs mxl›*) by (auto simp:image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) WT₁_is_type[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P⟧ ⟹ is_type P ?T›*) after_in_states[OF wf] (*‹⟦P,?E ⊢₁ ?e :: ?T; set ?E ⊆ types P; set ?ST ⊆ types P; length ?ST + max_stack ?e ≤ ?mxs⟧ ⟹ OK (after ?E ?A ?ST ?e) ∈ states P ?mxs mxl›*)) next (*goals: 1. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ INIT x1 (x2,x3) ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (INIT x1 (x2,x3) ← x4) ≤ mxs; length E + max_vars (INIT x1 (x2,x3) ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (INIT x1 (x2,x3) ← x4)) ⊆ states P mxs mxl› 2. ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl›*) case INIT (*‹⟦P,?E2 ⊢₁ x4_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x4_ ≤ mxs; length ?E2 + max_vars x4_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x4_) ⊆ states P mxs mxl› ‹P,E ⊢₁ INIT x1_ (x2_,x3_) ← x4_ :: T› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length ST + max_stack (INIT x1_ (x2_,x3_) ← x4_) ≤ mxs› ‹length (E::ty list) + max_vars (INIT (x1_::char list) ((x2_::char list list),(x3_::bool)) ← (x4_::nat exp)) ≤ (mxl::nat)›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (INIT x1_ (x2_,x3_) ← x4_)) ⊆ states P mxs mxl›*) by simp next (*goal: ‹⋀x1 x2 x3 x4 E T A ST. ⟦⋀E T A ST. ⟦P,E ⊢₁ x2 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x2 ≤ mxs; length E + max_vars x2 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x2) ⊆ states P mxs mxl; ⋀E T A ST. ⟦P,E ⊢₁ x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack x4 ≤ mxs; length E + max_vars x4 ≤ mxl⟧ ⟹ OK ` set (compT E A ST x4) ⊆ states P mxs mxl; P,E ⊢₁ RI (x1,x2) ; x3 ← x4 :: T; set E ⊆ types P; set ST ⊆ types P; length ST + max_stack (RI (x1,x2) ; x3 ← x4) ≤ mxs; length E + max_vars (RI (x1,x2) ; x3 ← x4) ≤ mxl⟧ ⟹ OK ` set (compT E A ST (RI (x1,x2) ; x3 ← x4)) ⊆ states P mxs mxl›*) case RI (*‹⟦P,?E2 ⊢₁ x2_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x2_ ≤ mxs; length ?E2 + max_vars x2_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x2_) ⊆ states P mxs mxl› ‹⟦P,?E2 ⊢₁ x4_ :: ?T2; set ?E2 ⊆ types P; set ?ST2 ⊆ types P; length ?ST2 + max_stack x4_ ≤ mxs; length ?E2 + max_vars x4_ ≤ mxl⟧ ⟹ OK ` set (compT ?E2 ?A2 ?ST2 x4_) ⊆ states P mxs mxl› ‹(P::nat exp prog),(E::ty list) ⊢₁ RI ((x1_::char list),(x2_::nat exp)) ; (x3_::char list list) ← (x4_::nat exp) :: T::ty› ‹set E ⊆ types P› ‹set ST ⊆ types P› ‹length (ST::ty list) + max_stack (RI ((x1_::char list),(x2_::nat exp)) ; (x3_::char list list) ← (x4_::nat exp)) ≤ (mxs::nat)› ‹length E + max_vars (RI (x1_,x2_) ; x3_ ← x4_) ≤ mxl›*) thus "?case" (*goal: ‹OK ` set (compT E A ST (RI (x1_,x2_) ; x3_ ← x4_)) ⊆ states P mxs mxl›*) by simp qed declare is_type_simps[simp] subsetI[intro!] (*>*) definition shift :: "nat ⇒ ex_table ⇒ ex_table" where "shift n xt ≡ map (λ(from,to,C,handler,depth). (from+n,to+n,C,handler+n,depth)) xt" lemma [simp]: "shift 0 xt = xt" (*<*)apply (induct xt) (*goals: 1. ‹shift 0 [] = []› 2. ‹⋀a xt. shift 0 xt = xt ⟹ shift 0 (a # xt) = a # xt› discuss goal 1*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))[1]) (*discuss goal 2*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))[1]) (*proven 2 subgoals*) .(*>*) lemma [simp]: "shift n [] = []" (*<*)by (simp add:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))(*>*) lemma [simp]: "shift n (xt₁ @ xt₂) = shift n xt₁ @ shift n xt₂" (*<*)by (simp add:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))(*>*) lemma [simp]: "shift m (shift n xt) = shift (m+n) xt" (*<*)apply (induct xt) (*goals: 1. ‹shift m (shift n []) = shift (m + n) []› 2. ‹⋀a xt. shift m (shift n xt) = shift (m + n) xt ⟹ shift m (shift n (a # xt)) = shift (m + n) (a # xt)› discuss goal 1*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))[1]) (*discuss goal 2*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))[1]) (*proven 2 subgoals*) .(*>*) lemma [simp]: "pcs (shift n xt) = {pc+n|pc. pc ∈ pcs xt}" (*<*) proof (-) (*goal: ‹pcs (shift (n::nat) (xt::ex_table)) = {pc + n |pc::nat. pc ∈ pcs xt}›*) { fix x and f and t and C and h and d assume "(f,t,C,h,d) ∈ set xt" and "f + n ≤ x" and "x < t + n" (*‹(f::nat, t::nat, C::char list, h::nat, d::nat) ∈ set (xt::ex_table)› ‹(f::nat) + (n::nat) ≤ (x::nat)› ‹(x::nat) < (t::nat) + (n::nat)›*) then have "∃pc. x = pc + n ∧ (∃x∈set xt. pc ∈ (case x of (f, t, C, h, d) ⇒ {f..<t}))" apply (rule_tac x = "x-n" in exI (*‹?P ?x ⟹ ∃x. ?P x›*)) (*goal: ‹∃pc. x = pc + n ∧ (∃x∈set xt. pc ∈ (case x of (f, t, C, h, d) ⇒ {f..<t}))›*) by (force split:nat_diff_split (*‹?P (?a - ?b) = ((?a < ?b ⟶ ?P 0) ∧ (∀d. ?a = ?b + d ⟶ ?P d))›*)) } then show "?thesis" (*goal: ‹pcs (shift n xt) = {pc + n |pc. pc ∈ pcs xt}›*) apply (auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) pcs_def (*‹pcs (?xt::ex_table) ≡ ⋃(f::nat, t::nat, C::char list, h::nat, d::nat)∈set ?xt. {f..<t}›*)) (*goal: ‹pcs (shift (n::nat) (xt::ex_table)) = {pc + n |pc::nat. pc ∈ pcs xt}›*) by fast qed (*>*) lemma shift_compxE₂: shows "⋀pc pc' d. shift pc (compxE₂ e pc' d) = compxE₂ e (pc' + pc) d" and "⋀pc pc' d. shift pc (compxEs₂ es pc' d) = compxEs₂ es (pc' + pc) d" (*<*) apply (induct e and es rule: compxE₂.induct compxEs₂.induct) (*goals: 1. ‹⋀x pc pc' d. shift pc (compxE₂ (new x) pc' d) = compxE₂ (new x) (pc' + pc) d› 2. ‹⋀x1 x2 pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x2 pc' d) = compxE₂ x2 (pc' + pc) d) ⟹ shift pc (compxE₂ (Cast x1 x2) pc' d) = compxE₂ (Cast x1 x2) (pc' + pc) d› 3. ‹⋀x pc pc' d. shift pc (compxE₂ (Val x) pc' d) = compxE₂ (Val x) (pc' + pc) d› 4. ‹⋀x1 x2 x3 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x3 pc' d) = compxE₂ x3 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (x1 «x2» x3) pc' d) = compxE₂ (x1 «x2» x3) (pc' + pc) d› 5. ‹⋀x pc pc' d. shift pc (compxE₂ (Var x) pc' d) = compxE₂ (Var x) (pc' + pc) d› 6. ‹⋀x1 x2 pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x2 pc' d) = compxE₂ x2 (pc' + pc) d) ⟹ shift pc (compxE₂ (x1:=x2) pc' d) = compxE₂ (x1:=x2) (pc' + pc) d› 7. ‹⋀x1 x2 x3 pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d) ⟹ shift pc (compxE₂ (x1∙x2{x3}) pc' d) = compxE₂ (x1∙x2{x3}) (pc' + pc) d› 8. ‹⋀x1 x2 x3 pc pc' d. shift pc (compxE₂ (x1∙⇩sx2{x3}) pc' d) = compxE₂ (x1∙⇩sx2{x3}) (pc' + pc) d› 9. ‹⋀x1 x2 x3 x4 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x4 pc' d) = compxE₂ x4 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (x1∙x2{x3} := x4) pc' d) = compxE₂ (x1∙x2{x3} := x4) (pc' + pc) d› 10. ‹⋀x1 x2 x3 x4 pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x4 pc' d) = compxE₂ x4 (pc' + pc) d) ⟹ shift pc (compxE₂ (x1∙⇩sx2{x3} := x4) pc' d) = compxE₂ (x1∙⇩sx2{x3} := x4) (pc' + pc) d› 11. ‹⋀x1 x2 x3 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxEs₂ x3 pc' d) = compxEs₂ x3 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (x1∙x2(x3)) pc' d) = compxE₂ (x1∙x2(x3)) (pc' + pc) d› 12. ‹⋀x1 x2 x3 pc pc' d. (⋀pc pc' d. shift pc (compxEs₂ x3 pc' d) = compxEs₂ x3 (pc' + pc) d) ⟹ shift pc (compxE₂ (x1∙⇩sx2(x3)) pc' d) = compxE₂ (x1∙⇩sx2(x3)) (pc' + pc) d› 13. ‹⋀x1 x2 x3 pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x3 pc' d) = compxE₂ x3 (pc' + pc) d) ⟹ shift pc (compxE₂ {x1:x2; x3} pc' d) = compxE₂ {x1:x2; x3} (pc' + pc) d› 14. ‹⋀x1 x2 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x2 pc' d) = compxE₂ x2 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (x1;; x2) pc' d) = compxE₂ (x1;; x2) (pc' + pc) d› 15. ‹⋀x1 x2 x3 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x2 pc' d) = compxE₂ x2 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x3 pc' d) = compxE₂ x3 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (if (x1) x2 else x3) pc' d) = compxE₂ (if (x1) x2 else x3) (pc' + pc) d› 16. ‹⋀x1 x2 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x2 pc' d) = compxE₂ x2 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (while (x1) x2) pc' d) = compxE₂ (while (x1) x2) (pc' + pc) d› 17. ‹⋀x pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x pc' d) = compxE₂ x (pc' + pc) d) ⟹ shift pc (compxE₂ (throw x) pc' d) = compxE₂ (throw x) (pc' + pc) d› 18. ‹⋀x1 x2 x3 x4 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x4 pc' d) = compxE₂ x4 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (try x1 catch(x2 x3) x4) pc' d) = compxE₂ (try x1 catch(x2 x3) x4) (pc' + pc) d› 19. ‹⋀x1 x2 x3 x4 pc pc' d. (⋀pc pc' d. shift pc (compxE₂ x4 pc' d) = compxE₂ x4 (pc' + pc) d) ⟹ shift pc (compxE₂ (INIT x1 (x2,x3) ← x4) pc' d) = compxE₂ (INIT x1 (x2,x3) ← x4) (pc' + pc) d› 20. ‹⋀x1 x2 x3 x4 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x2 pc' d) = compxE₂ x2 (pc' + pc) d; ⋀pc pc' d. shift pc (compxE₂ x4 pc' d) = compxE₂ x4 (pc' + pc) d⟧ ⟹ shift pc (compxE₂ (RI (x1,x2) ; x3 ← x4) pc' d) = compxE₂ (RI (x1,x2) ; x3 ← x4) (pc' + pc) d› 21. ‹⋀pc pc' d. shift pc (compxEs₂ [] pc' d) = compxEs₂ [] (pc' + pc) d› 22. ‹⋀x1 x2 pc pc' d. ⟦⋀pc pc' d. shift pc (compxE₂ x1 pc' d) = compxE₂ x1 (pc' + pc) d; ⋀pc pc' d. shift pc (compxEs₂ x2 pc' d) = compxEs₂ x2 (pc' + pc) d⟧ ⟹ shift pc (compxEs₂ (x1 # x2) pc' d) = compxEs₂ (x1 # x2) (pc' + pc) d› discuss goal 1*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 2*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 3*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 4*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 5*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 6*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 7*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 8*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 9*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 10*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 11*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 12*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 13*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 14*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 15*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 16*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 17*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 18*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a::semigroup_add) + (?b::?'a::semigroup_add) + (?c::?'a::semigroup_add) = ?a + (?b + ?c)› ‹(?a::?'a::ab_semigroup_add) + (?b::?'a::ab_semigroup_add) = ?b + ?a› ‹(?b::?'a::ab_semigroup_add) + ((?a::?'a::ab_semigroup_add) + (?c::?'a::ab_semigroup_add)) = ?a + (?b + ?c)› ‹(?a::?'a::semigroup_mult) * (?b::?'a::semigroup_mult) * (?c::?'a::semigroup_mult) = ?a * (?b * ?c)› ‹(?a::?'a::ab_semigroup_mult) * (?b::?'a::ab_semigroup_mult) = ?b * ?a› ‹(?b::?'a::ab_semigroup_mult) * ((?a::?'a::ab_semigroup_mult) * (?c::?'a::ab_semigroup_mult)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 19*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 20*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 21*) apply ((auto simp:shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(((?a::bool) ∧ (?b::bool)) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹((?a::bool) ∧ (?b::bool)) = (?b ∧ ?a)› ‹((?b::bool) ∧ (?a::bool) ∧ (?c::bool)) = (?a ∧ ?b ∧ ?c)› ‹(((?a::bool) ∨ (?b::bool)) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› ‹((?a::bool) ∨ (?b::bool)) = (?b ∨ ?a)› ‹((?b::bool) ∨ (?a::bool) ∨ (?c::bool)) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*discuss goal 22*) apply ((auto simp:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) ac_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹((?a ∧ ?b) ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹(?a ∧ ?b) = (?b ∧ ?a)› ‹(?b ∧ ?a ∧ ?c) = (?a ∧ ?b ∧ ?c)› ‹((?a ∨ ?b) ∨ ?c) = (?a ∨ ?b ∨ ?c)› ‹(?a ∨ ?b) = (?b ∨ ?a)› ‹(?b ∨ ?a ∨ ?c) = (?a ∨ ?b ∨ ?c)› and more 30 facts*))[1]) (*proven 22 subgoals*) . (*>*) lemma compxE₂_size_convs[simp]: shows "n ≠ 0 ⟹ compxE₂ e n d = shift n (compxE₂ e 0 d)" and "n ≠ 0 ⟹ compxEs₂ es n d = shift n (compxEs₂ es 0 d)" (*<*) (*goals: 1. ‹n ≠ 0 ⟹ compxE₂ e n d = shift n (compxE₂ e 0 d)› 2. ‹n ≠ 0 ⟹ compxEs₂ es n d = shift n (compxEs₂ es 0 d)› discuss goal 1*) apply (simp add:shift_compxE₂ (*‹shift (?pc::nat) (compxE₂ (?e::nat exp) (?pc'::nat) (?d::nat)) = compxE₂ ?e (?pc' + ?pc) ?d› ‹shift (?pc::nat) (compxEs₂ (?es::nat exp list) (?pc'::nat) (?d::nat)) = compxEs₂ ?es (?pc' + ?pc) ?d›*)) (*discuss goal 2*) apply (simp add:shift_compxE₂ (*‹shift ?pc (compxE₂ ?e ?pc' ?d) = compxE₂ ?e (?pc' + ?pc) ?d› ‹shift ?pc (compxEs₂ ?es ?pc' ?d) = compxEs₂ ?es (?pc' + ?pc) ?d›*)) (*proven 2 subgoals*) .(*>*) locale TC2 = TC1 + fixes T⇩r :: ty and mxs :: pc begin definition wt_instrs :: "instr list ⇒ ex_table ⇒ ty⇩i' list ⇒ bool" ("(⊢ _, _ /[::]/ _)" [0,0,51] 50) where "⊢ is,xt [::] τs ⟷ size is < size τs ∧ pcs xt ⊆ {0..<size is} ∧ (∀pc< size is. P,T⇩r,mxs,size τs,xt ⊢ is!pc,pc :: τs)" end notation TC2.wt_instrs ("(_,_,_ ⊢/ _, _ /[::]/ _)" [50,50,50,50,50,51] 50) (*<*) lemmas (in TC2) wt_defs = wt_instrs_def wt_instr_def app_def eff_def norm_eff_def (*>*) lemma (in TC2) [simp]: "τs ≠ [] ⟹ ⊢ [],[] [::] τs" (*<*) by (simp add: wt_defs (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*)) (*>*) lemma [simp]: "eff i P pc et None = []" (*<*)by (simp add: Effect.eff_def (*‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*))(*>*) (*<*) declare split_comp_eq[simp del] (*>*) lemma wt_instr_appR: "⟦ P,T,m,mpc,xt ⊢ is!pc,pc :: τs; pc < size is; size is < size τs; mpc ≤ size τs; mpc ≤ mpc' ⟧ ⟹ P,T,m,mpc',xt ⊢ is!pc,pc :: τs@τs'" (*<*)by (fastforce simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))(*>*) lemma relevant_entries_shift [simp]: "relevant_entries P i (pc+n) (shift n xt) = shift n (relevant_entries P i pc xt)" (*<*) proof (induct xt) (*goals: 1. ‹relevant_entries (P::'a prog) (i::instr) ((pc::nat) + (n::nat)) (shift n []) = shift n (relevant_entries P i pc [])› 2. ‹⋀(a::ex_entry) xt::ex_table. relevant_entries (P::'a prog) (i::instr) ((pc::nat) + (n::nat)) (shift n xt) = shift n (relevant_entries P i pc xt) ⟹ relevant_entries P i (pc + n) (shift n (a # xt)) = shift n (relevant_entries P i pc (a # xt))›*) case Nil (*no hyothesis introduced yet*) then show "?case" (*goal: ‹relevant_entries (P::'a prog) (i::instr) ((pc::nat) + (n::nat)) (shift n []) = shift n (relevant_entries P i pc [])›*) by (simp add: relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*) shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*)) next (*goal: ‹⋀a xt. relevant_entries P i (pc + n) (shift n xt) = shift n (relevant_entries P i pc xt) ⟹ relevant_entries P i (pc + n) (shift n (a # xt)) = shift n (relevant_entries P i pc (a # xt))›*) case (Cons a xt) (*‹relevant_entries (P::'a prog) (i::instr) ((pc::nat) + (n::nat)) (shift n (xt::ex_table)) = shift n (relevant_entries P i pc xt)›*) then show "?case" (*goal: ‹relevant_entries P i (pc + n) (shift n (a # xt)) = shift n (relevant_entries P i pc (a # xt))›*) by (auto simp add: relevant_entries_def (*‹relevant_entries (?P::?'m prog) (?i::instr) (?pc::nat) = filter (is_relevant_entry ?P ?i ?pc)›*) shift_def (*‹shift (?n::nat) (?xt::ex_table) ≡ map (λ(from::nat, to::nat, C::char list, handler::nat, depth::nat). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) is_relevant_entry_def (*‹is_relevant_entry (?P::?'m prog) (?i::instr) (?pc::nat) (?e::ex_entry) = (let (f::nat, t::nat, C::char list, h::nat, d::nat) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*)) qed (*>*) lemma [simp]: "xcpt_eff i P (pc+n) τ (shift n xt) = map (λ(pc,τ). (pc + n, τ)) (xcpt_eff i P pc τ xt)" (*<*) proof (-) (*goal: ‹xcpt_eff i P (pc + n) τ (shift n xt) = map (λ(pc, τ). (pc + n, τ)) (xcpt_eff i P pc τ xt)›*) obtain ST and LT where "τ = (ST, LT)" (*goal: ‹(⋀ST LT. τ = (ST, LT) ⟹ thesis) ⟹ thesis›*) apply (cases τ) (*goal: ‹(⋀(ST::ty list) LT::ty err list. (τ::ty list × ty err list) = (ST, LT) ⟹ thesis::bool) ⟹ thesis›*) by simp then show "?thesis" (*goal: ‹xcpt_eff i P (pc + n) τ (shift n xt) = map (λ(pc, τ). (pc + n, τ)) (xcpt_eff i P pc τ xt)›*) apply (simp add: xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*)) (*goal: ‹xcpt_eff i P (pc + n) τ (shift n xt) = map (λ(pc, τ). (pc + n, τ)) (xcpt_eff i P pc τ xt)›*) by (auto simp add: shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*)) qed (*>*) lemma [simp]: "app⇩i (i, P, pc, m, T, τ) ⟹ eff i P (pc+n) (shift n xt) (Some τ) = map (λ(pc,τ). (pc+n,τ)) (eff i P pc xt (Some τ))" (*<*)apply (cases "i") (*goals: 1. ‹⋀x1. ⟦app⇩i (i, P, pc, m, T, τ); i = Load x1⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 2. ‹⋀x2. ⟦app⇩i (i, P, pc, m, T, τ); i = Store x2⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 3. ‹⋀x3. ⟦app⇩i (i, P, pc, m, T, τ); i = Push x3⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 4. ‹⋀x4. ⟦app⇩i (i, P, pc, m, T, τ); i = New x4⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 5. ‹⋀x51 x52. ⟦app⇩i (i, P, pc, m, T, τ); i = Getfield x51 x52⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 6. ‹⋀x61 x62 x63. ⟦app⇩i (i, P, pc, m, T, τ); i = Getstatic x61 x62 x63⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 7. ‹⋀x71 x72. ⟦app⇩i (i, P, pc, m, T, τ); i = Putfield x71 x72⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 8. ‹⋀x81 x82 x83. ⟦app⇩i (i, P, pc, m, T, τ); i = Putstatic x81 x82 x83⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 9. ‹⋀x9. ⟦app⇩i (i, P, pc, m, T, τ); i = Checkcast x9⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 10. ‹⋀x101 x102. ⟦app⇩i (i, P, pc, m, T, τ); i = Invoke x101 x102⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 11. ‹⋀x111 x112 x113. ⟦app⇩i (i, P, pc, m, T, τ); i = Invokestatic x111 x112 x113⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 12. ‹⟦app⇩i (i, P, pc, m, T, τ); i = Return⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 13. ‹⟦app⇩i (i, P, pc, m, T, τ); i = Pop⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 14. ‹⟦app⇩i (i, P, pc, m, T, τ); i = IAdd⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 15. ‹⋀x15. ⟦app⇩i (i, P, pc, m, T, τ); i = Goto x15⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 16. ‹⟦app⇩i (i, P, pc, m, T, τ); i = CmpEq⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 17. ‹⋀x17. ⟦app⇩i (i, P, pc, m, T, τ); i = IfFalse x17⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› 18. ‹⟦app⇩i (i, P, pc, m, T, τ); i = instr.Throw⟧ ⟹ eff i P (pc + n) (shift n xt) ⌊τ⌋ = map (λ(pc, τ). (pc + n, τ)) (eff i P pc xt ⌊τ⌋)› discuss goal 1*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 2*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 3*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 4*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 5*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 6*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 7*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 8*) apply ((auto simp add:eff_def (*‹eff (?i::instr) (?P::?'m::type prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff (?i::instr) (?P::?'m::type prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 9*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 10*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 11*) apply ((auto simp add:eff_def (*‹eff (?i::instr) (?P::?'m::type prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff (?i::instr) (?P::?'m::type prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 12*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 13*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 14*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 15*) apply ((auto simp add:eff_def (*‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 16*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 17*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*discuss goal 18*) apply ((auto simp add:eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))[1]) (*proven 18 subgoals*) .(*>*) lemma [simp]: "xcpt_app i P (pc+n) mxs (shift n xt) τ = xcpt_app i P pc mxs xt τ" (*<*)apply (simp add: xcpt_app_def (*‹xcpt_app ?i ?P ?pc ?mxs ?xt ?τ = (∀(f, t, C, h, d)∈set (relevant_entries ?P ?i ?pc ?xt). is_class ?P C ∧ d ≤ length (fst ?τ) ∧ d < ?mxs)›*)) (*goal: ‹xcpt_app (i::instr) (P::'a prog) ((pc::nat) + (n::nat)) (mxs::nat) (shift n (xt::ex_table)) (τ::ty list × ty err list) = xcpt_app i P pc mxs xt τ›*) by (auto simp add: shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))(*>*) lemma wt_instr_appL: assumes "P,T,m,mpc,xt ⊢ i,pc :: τs" and "pc < size τs" and "mpc ≤ size τs" shows "P,T,m,mpc + size τs',shift (size τs') xt ⊢ i,pc+size τs' :: τs'@τs" (*<*) proof (-) (*goal: ‹P,T,m,mpc + length τs',shift (length τs') xt ⊢ i,pc + length τs' :: τs' @ τs›*) let ?t = "(τs'@τs)!(pc+size τs')" show "?thesis" (*goal: ‹P,T,m,mpc + length τs',shift (length τs') xt ⊢ i,pc + length τs' :: τs' @ τs›*) proof (cases ?t) (*goals: 1. ‹(τs' @ τs) ! (pc + length τs') = None ⟹ P,T,m,mpc + length τs',shift (length τs') xt ⊢ i,pc + length τs' :: τs' @ τs› 2. ‹⋀a. (τs' @ τs) ! (pc + length τs') = ⌊a⌋ ⟹ P,T,m,mpc + length τs',shift (length τs') xt ⊢ i,pc + length τs' :: τs' @ τs›*) case (Some τ) (*‹(τs' @ τs) ! (pc + length τs') = ⌊τ⌋›*) obtain ST and LT where [simp]: "τ = (ST, LT)" (*goal: ‹(⋀ST LT. τ = (ST, LT) ⟹ thesis) ⟹ thesis›*) apply (cases τ) (*goal: ‹(⋀ST LT. τ = (ST, LT) ⟹ thesis) ⟹ thesis›*) by simp have "app⇩i (i, P, pc + length τs', m, T, τ)" using Some (*‹(τs' @ τs) ! (pc + length τs') = ⌊τ⌋›*) assms (*‹(P::'a::type prog),T::ty,m::nat,mpc::nat,xt::ex_table ⊢ i::instr,pc::nat :: (τs::(ty list × ty err list) option list)› ‹pc < length τs› ‹mpc ≤ length τs›*) apply (cases "i") (*goals: 1. ‹⋀x1. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Load x1⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 2. ‹⋀x2. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Store x2⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 3. ‹⋀x3. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Push x3⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 4. ‹⋀x4. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = New x4⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 5. ‹⋀x51 x52. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Getfield x51 x52⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 6. ‹⋀x61 x62 x63. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Getstatic x61 x62 x63⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 7. ‹⋀x71 x72. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Putfield x71 x72⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 8. ‹⋀x81 x82 x83. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Putstatic x81 x82 x83⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 9. ‹⋀x9. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Checkcast x9⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 10. ‹⋀x101 x102. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Invoke x101 x102⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 11. ‹⋀x111 x112 x113. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Invokestatic x111 x112 x113⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 12. ‹⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Return⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 13. ‹⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Pop⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 14. ‹⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = IAdd⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 15. ‹⋀x15. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = Goto x15⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 16. ‹⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = CmpEq⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 17. ‹⋀x17. ⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = IfFalse x17⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› 18. ‹⟦(τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs; i = instr.Throw⟧ ⟹ app⇩i (i, P, pc + length τs', m, T, τ)› discuss goal 1*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 2*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 3*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 4*) apply ((auto simp:wt_instr_def (*‹(?P::?'m::type prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app (?i::instr) (?P::?'m::type prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 5*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 6*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 7*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 8*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 9*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 10*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 11*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 12*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 13*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 14*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 15*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 16*) apply ((auto simp:wt_instr_def (*‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 17*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 18*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*proven 18 subgoals*) . moreover { fix pc' and τ' assume "(pc',τ') ∈ set (eff i P pc xt ?t)" (*‹(pc'::nat, τ'::(ty list × ty err list) option) ∈ set (eff (i::instr) (P::'a prog) (pc::nat) (xt::ex_table) (((τs'::(ty list × ty err list) option list) @ (τs::(ty list × ty err list) option list)) ! (pc + length τs')))›*) then have "P ⊢ τ' ≤' τs!pc'" and "pc' < mpc" using Some (*‹(τs' @ τs) ! (pc + length τs') = ⌊τ⌋›*) assms (*‹P,T,m,mpc,xt ⊢ i,pc :: τs› ‹pc < length τs› ‹(mpc::nat) ≤ length (τs::(ty list × ty err list) option list)›*) apply - (*goals: 1. ‹⟦(pc', τ') ∈ set (eff i P pc xt ((τs' @ τs) ! (pc + length τs'))); (τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs⟧ ⟹ P ⊢ τ' ≤' τs ! pc'› 2. ‹⟦(pc', τ') ∈ set (eff i P pc xt ((τs' @ τs) ! (pc + length τs'))); (τs' @ τs) ! (pc + length τs') = ⌊τ⌋; P,T,m,mpc,xt ⊢ i,pc :: τs; pc < length τs; mpc ≤ length τs⟧ ⟹ pc' < mpc› discuss goal 1*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*discuss goal 2*) apply ((auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*))[1]) (*proven 2 subgoals*) . } ultimately show "?thesis" (*goal: ‹P,T,m,mpc + length τs',shift (length τs') xt ⊢ i,pc + length τs' :: τs' @ τs›*) using Some (*‹(τs' @ τs) ! (pc + length τs') = ⌊τ⌋›*) assms (*‹(P::'a::type prog),T::ty,m::nat,mpc::nat,xt::ex_table ⊢ i::instr,pc::nat :: (τs::(ty list × ty err list) option list)› ‹pc < length τs› ‹mpc ≤ length τs›*) by (fastforce simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) qed (auto simp:wt_instr_def (*‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) (*solved the remaining goal: ‹(τs' @ τs) ! (pc + length τs') = None ⟹ P,T,m,mpc + length τs',shift (length τs') xt ⊢ i,pc + length τs' :: τs' @ τs›*) qed (*>*) lemma wt_instr_Cons: assumes wti: "P,T,m,mpc - 1,[] ⊢ i,pc - 1 :: τs" and pcl: "0 < pc" and mpcl: "0 < mpc" and pcu: "pc < size τs + 1" and mpcu: "mpc ≤ size τs + 1" shows "P,T,m,mpc,[] ⊢ i,pc :: τ#τs" (*<*) proof (-) (*goal: ‹P,T,m,mpc,[] ⊢ i,pc :: τ # τs›*) have "pc - 1 < length τs" using pcl (*‹0 < pc›*) pcu (*‹pc < length τs + 1›*) by arith moreover have "mpc - 1 ≤ length τs" using mpcl (*‹0 < mpc›*) mpcu (*‹mpc ≤ length τs + 1›*) by arith ultimately have "P,T,m,mpc - 1 + length [τ],shift (length [τ]) [] ⊢ i,pc - 1 + length [τ] :: [τ] @ τs" by (rule wt_instr_appL[where τs' = "[τ]", OF wti] (*‹⟦pc - 1 < length τs; mpc - 1 ≤ length τs⟧ ⟹ P,T,m,mpc - 1 + length [τ],shift (length [τ]) [] ⊢ i,pc - 1 + length [τ] :: [τ] @ τs›*)) then show "?thesis" (*goal: ‹P,T,m,mpc,[] ⊢ i,pc :: τ # τs›*) using pcl (*‹(0::nat) < (pc::nat)›*) mpcl (*‹0 < mpc›*) by (simp split:nat_diff_split_asm (*‹?P (?a - ?b) = (¬ (?a < ?b ∧ ¬ ?P 0 ∨ (∃d. ?a = ?b + d ∧ ¬ ?P d)))›*)) qed (*>*) lemma wt_instr_append: assumes wti: "P,T,m,mpc - size τs',[] ⊢ i,pc - size τs' :: τs" and pcl: "size τs' ≤ pc" and mpcl: "size τs' ≤ mpc" and pcu: "pc < size τs + size τs'" and mpcu: "mpc ≤ size τs + size τs'" shows "P,T,m,mpc,[] ⊢ i,pc :: τs'@τs" (*<*) proof (-) (*goal: ‹P,T,m,mpc,[] ⊢ i,pc :: τs' @ τs›*) have "pc - length τs' < length τs" using pcl (*‹length τs' ≤ pc›*) pcu (*‹pc < length τs + length τs'›*) by arith moreover have "mpc - length τs' ≤ length τs" using mpcl (*‹length τs' ≤ mpc›*) mpcu (*‹mpc ≤ length τs + length τs'›*) by arith thm wt_instr_appL[where τs' = "τs'", OF wti] ultimately have "P,T,m,mpc - length τs' + length τs',shift (length τs') [] ⊢ i,pc - length τs' + length τs' :: τs' @ τs" by (rule wt_instr_appL[where τs' = "τs'", OF wti] (*‹⟦(pc::nat) - length (τs'::(ty list × ty err list) option list) < length (τs::(ty list × ty err list) option list); (mpc::nat) - length τs' ≤ length τs⟧ ⟹ (P::'a prog),T::ty,m::nat,mpc - length τs' + length τs',shift (length τs') [] ⊢ i::instr,pc - length τs' + length τs' :: τs' @ τs›*)) then show "?thesis" (*goal: ‹P,T,m,mpc,[] ⊢ i,pc :: τs' @ τs›*) using pcl (*‹length τs' ≤ pc›*) mpcl (*‹length τs' ≤ mpc›*) by (simp split:nat_diff_split_asm (*‹(?P::nat ⇒ bool) ((?a::nat) - (?b::nat)) = (¬ (?a < ?b ∧ ¬ ?P (0::nat) ∨ (∃d::nat. ?a = ?b + d ∧ ¬ ?P d)))›*)) qed (*>*) lemma xcpt_app_pcs: "pc ∉ pcs xt ⟹ xcpt_app i P pc mxs xt τ" (*<*) by (auto simp add: xcpt_app_def (*‹xcpt_app ?i ?P ?pc ?mxs ?xt ?τ = (∀(f, t, C, h, d)∈set (relevant_entries ?P ?i ?pc ?xt). is_class ?P C ∧ d ≤ length (fst ?τ) ∧ d < ?mxs)›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*) is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*) pcs_def (*‹pcs ?xt ≡ ⋃(f, t, C, h, d)∈set ?xt. {f..<t}›*)) (*>*) lemma xcpt_eff_pcs: "pc ∉ pcs xt ⟹ xcpt_eff i P pc τ xt = []" (*<*) apply (cases τ) (*goal: ‹(pc::nat) ∉ pcs (xt::ex_table) ⟹ xcpt_eff (i::instr) (P::'a prog) pc (τ::ty list × ty err list) xt = []›*) by (auto simp add: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*) xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*) pcs_def (*‹pcs ?xt ≡ ⋃(f, t, C, h, d)∈set ?xt. {f..<t}›*) intro!: filter_False (*‹∀x∈set ?xs. ¬ ?P x ⟹ filter ?P ?xs = []›*)) (*>*) lemma pcs_shift: "pc < n ⟹ pc ∉ pcs (shift n xt)" (*<*)by (auto simp add: shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*) pcs_def (*‹pcs ?xt ≡ ⋃(f, t, C, h, d)∈set ?xt. {f..<t}›*))(*>*) lemma wt_instr_appRx: "⟦ P,T,m,mpc,xt ⊢ is!pc,pc :: τs; pc < size is; size is < size τs; mpc ≤ size τs ⟧ ⟹ P,T,m,mpc,xt @ shift (size is) xt' ⊢ is!pc,pc :: τs" (*<*)by (auto simp:wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*) xcpt_app_pcs (*‹?pc ∉ pcs ?xt ⟹ xcpt_app ?i ?P ?pc ?mxs ?xt ?τ›*) xcpt_eff_pcs (*‹?pc ∉ pcs ?xt ⟹ xcpt_eff ?i ?P ?pc ?τ ?xt = []›*))(*>*) lemma wt_instr_appLx: "⟦ P,T,m,mpc,xt ⊢ i,pc :: τs; pc ∉ pcs xt' ⟧ ⟹ P,T,m,mpc,xt'@xt ⊢ i,pc :: τs" (*<*)by (auto simp:wt_instr_def (*‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) app_def (*‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*) eff_def (*‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) xcpt_app_pcs (*‹(?pc::nat) ∉ pcs (?xt::ex_table) ⟹ xcpt_app (?i::instr) (?P::?'a prog) ?pc (?mxs::nat) ?xt (?τ::ty list × ty err list)›*) xcpt_eff_pcs (*‹(?pc::nat) ∉ pcs (?xt::ex_table) ⟹ xcpt_eff (?i::instr) (?P::?'a prog) ?pc (?τ::ty list × ty err list) ?xt = []›*))(*>*) lemma (in TC2) wt_instrs_extR: "⊢ is,xt [::] τs ⟹ ⊢ is,xt [::] τs @ τs'" (*<*)by (auto simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) wt_instr_appR (*‹⟦?P,?T,?m,?mpc,?xt ⊢ ?is ! ?pc,?pc :: ?τs; ?pc < length ?is; length ?is < length ?τs; ?mpc ≤ length ?τs; ?mpc ≤ ?mpc'⟧ ⟹ ?P,?T,?m,?mpc',?xt ⊢ ?is ! ?pc,?pc :: ?τs @ ?τs'›*))(*>*) lemma (in TC2) wt_instrs_ext: assumes wt₁: "⊢ is₁,xt₁ [::] τs₁@τs₂" and wt₂: "⊢ is₂,xt₂ [::] τs₂" and τs_size: "size τs₁ = size is₁" shows "⊢ is₁@is₂, xt₁ @ shift (size is₁) xt₂ [::] τs₁@τs₂" (*<*) proof (-) (*goal: ‹⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τs₂›*) let ?is = "is₁@is₂" and ?xt = "xt₁ @ shift (size is₁) xt₂" and ?τs = "τs₁@τs₂" have "size ?is < size ?τs" using "wt₂" (*‹⊢ is₂, xt₂ [::] τs₂›*) "τs_size" (*‹length τs₁ = length is₁›*) by (fastforce simp:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) moreover have "pcs ?xt ⊆ {0..<size ?is}" using "wt₁" (*‹⊢ is₁::bytecode, xt₁::ex_table [::] (τs₁::(ty list × ty err list) option list) @ (τs₂::(ty list × ty err list) option list)›*) "wt₂" (*‹⊢ is₂, xt₂ [::] τs₂›*) by (fastforce simp:wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) moreover { fix pc assume pc: "pc<size ?is" (*‹(pc::nat) < length ((is₁::bytecode) @ (is₂::bytecode))›*) have "P,T⇩r,mxs,size ?τs,?xt ⊢ ?is!pc,pc :: ?τs" proof (cases "pc < length is₁") (*goals: 1. ‹pc < length is₁ ⟹ P,T⇩r,mxs,length (τs₁ @ τs₂),xt₁ @ shift (length is₁) xt₂ ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ τs₂› 2. ‹¬ pc < length is₁ ⟹ P,T⇩r,mxs,length (τs₁ @ τs₂),xt₁ @ shift (length is₁) xt₂ ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ τs₂›*) case True (*‹pc < length is₁›*) then show "?thesis" (*goal: ‹(P::nat exp prog),T⇩r::ty,mxs::nat,length ((τs₁::(ty list × ty err list) option list) @ (τs₂::(ty list × ty err list) option list)),(xt₁::ex_table) @ shift (length (is₁::bytecode)) (xt₂::ex_table) ⊢ (is₁ @ (is₂::bytecode)) ! (pc::nat),pc :: τs₁ @ τs₂›*) using "wt₁" (*‹⊢ is₁, xt₁ [::] τs₁ @ τs₂›*) pc (*‹pc < length (is₁ @ is₂)›*) by (fastforce simp: wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) wt_instr_appRx (*‹⟦?P,?T,?m,?mpc,?xt ⊢ ?is ! ?pc,?pc :: ?τs; ?pc < length ?is; length ?is < length ?τs; ?mpc ≤ length ?τs⟧ ⟹ ?P,?T,?m,?mpc,?xt @ shift (length ?is) ?xt' ⊢ ?is ! ?pc,?pc :: ?τs›*)) next (*goal: ‹¬ pc < length is₁ ⟹ P,T⇩r,mxs,length (τs₁ @ τs₂),xt₁ @ shift (length is₁) xt₂ ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ τs₂›*) case False (*‹¬ (pc::nat) < length (is₁::bytecode)›*) then have "pc - length is₁ < length is₂" using pc (*‹pc < length (is₁ @ is₂)›*) by fastforce then have "P,T⇩r,mxs,length τs₂,xt₂ ⊢ is₂ ! (pc - length is₁),pc - length is₁ :: τs₂" using "wt₂" (*‹⊢ is₂, xt₂ [::] τs₂›*) by (clarsimp simp: wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) moreover have "pc - length is₁ < length τs₂" using pc (*‹pc < length (is₁ @ is₂)›*) "wt₂" (*‹⊢ is₂, xt₂ [::] τs₂›*) apply (clarsimp simp: wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) (*goal: ‹(pc::nat) - length (is₁::bytecode) < length (τs₂::(ty list × ty err list) option list)›*) by arith moreover have "length τs₂ ≤ length τs₂" by simp moreover have "pc - length is₁ + length τs₁ ∉ pcs xt₁" using "wt₁" (*‹⊢ is₁::bytecode, xt₁::ex_table [::] (τs₁::(ty list × ty err list) option list) @ (τs₂::(ty list × ty err list) option list)›*) "τs_size" (*‹length τs₁ = length is₁›*) by (fastforce simp: wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) ultimately have "P,T⇩r,mxs,length τs₂ + length τs₁,xt₁ @ shift (length τs₁) xt₂ ⊢ is₂ ! (pc - length is₁),pc - length is₁ + length τs₁ :: τs₁ @ τs₂" by (rule wt_instr_appLx[OF wt_instr_appL[where τs' = "τs₁"]] (*‹⟦(?P::?'a prog),?T::ty,?m::nat,?mpc1::nat,?xt1::ex_table ⊢ ?i::instr,?pc1::nat :: (?τs1::(ty list × ty err list) option list); ?pc1 < length ?τs1; ?mpc1 ≤ length ?τs1; ?pc1 + length (τs₁::(ty list × ty err list) option list) ∉ pcs (?xt'::ex_table)⟧ ⟹ ?P,?T,?m,?mpc1 + length τs₁,?xt' @ shift (length τs₁) ?xt1 ⊢ ?i,?pc1 + length τs₁ :: τs₁ @ ?τs1›*)) then show "?thesis" (*goal: ‹P,T⇩r,mxs,length (τs₁ @ τs₂),xt₁ @ shift (length is₁) xt₂ ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ τs₂›*) using False (*‹¬ (pc::nat) < length (is₁::bytecode)›*) "τs_size" (*‹length τs₁ = length is₁›*) by (simp add:add.commute (*‹?a + ?b = ?b + ?a›*)) qed } ultimately show "?thesis" (*goal: ‹⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τs₂›*) by (clarsimp simp:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) qed (*>*) corollary (in TC2) wt_instrs_ext2: "⟦ ⊢ is₂,xt₂ [::] τs₂; ⊢ is₁,xt₁ [::] τs₁@τs₂; size τs₁ = size is₁ ⟧ ⟹ ⊢ is₁@is₂, xt₁ @ shift (size is₁) xt₂ [::] τs₁@τs₂" (*<*)apply (rule wt_instrs_ext (*‹⟦⊢ ?is₁, ?xt₁ [::] ?τs₁ @ ?τs₂; ⊢ ?is₂, ?xt₂ [::] ?τs₂; length ?τs₁ = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] ?τs₁ @ ?τs₂›*)) (*goals: 1. ‹⟦⊢ is₂, xt₂ [::] τs₂; ⊢ is₁, xt₁ [::] τs₁ @ τs₂; length τs₁ = length is₁⟧ ⟹ ⊢ is₁, xt₁ [::] τs₁ @ τs₂› 2. ‹⟦⊢ is₂, xt₂ [::] τs₂; ⊢ is₁, xt₁ [::] τs₁ @ τs₂; length τs₁ = length is₁⟧ ⟹ ⊢ is₂, xt₂ [::] τs₂› 3. ‹⟦⊢ is₂, xt₂ [::] τs₂; ⊢ is₁, xt₁ [::] τs₁ @ τs₂; length τs₁ = length is₁⟧ ⟹ length τs₁ = length is₁› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) apply ((assumption)[1]) (*discuss goal 3*) . (*proven 3 subgoals*)(*>*) corollary (in TC2) wt_instrs_ext_prefix [trans]: "⟦ ⊢ is₁,xt₁ [::] τs₁@τs₂; ⊢ is₂,xt₂ [::] τs₃; size τs₁ = size is₁; prefix τs₃ τs₂ ⟧ ⟹ ⊢ is₁@is₂, xt₁ @ shift (size is₁) xt₂ [::] τs₁@τs₂" (*<*)by (bestsimp simp:prefix_def (*‹prefix (?xs::?'a list) (?ys::?'a list) = (∃zs::?'a list. ?ys = ?xs @ zs)›*) elim: wt_instrs_ext (*‹⟦⊢ ?is₁::bytecode, ?xt₁::ex_table [::] (?τs₁::(ty list × ty err list) option list) @ (?τs₂::(ty list × ty err list) option list); ⊢ ?is₂::bytecode, ?xt₂::ex_table [::] ?τs₂; length ?τs₁ = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] ?τs₁ @ ?τs₂›*) dest:wt_instrs_extR (*‹⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list) ⟹ ⊢ ?is, ?xt [::] ?τs @ (?τs'::(ty list × ty err list) option list)›*))(*>*) corollary (in TC2) wt_instrs_app: assumes is₁: "⊢ is₁,xt₁ [::] τs₁@[τ]" assumes is₂: "⊢ is₂,xt₂ [::] τ#τs₂" assumes s: "size τs₁ = size is₁" shows "⊢ is₁@is₂, xt₁@shift (size is₁) xt₂ [::] τs₁@τ#τs₂" (*<*) proof (-) (*goal: ‹⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τ # τs₂›*) from "is₁" (*‹⊢ is₁, xt₁ [::] τs₁ @ [τ]›*) have "⊢ is₁,xt₁ [::] (τs₁@[τ])@τs₂" by (rule wt_instrs_extR (*‹⊢ ?is, ?xt [::] ?τs ⟹ ⊢ ?is, ?xt [::] ?τs @ ?τs'›*)) hence "⊢ is₁,xt₁ [::] τs₁@τ#τs₂" by simp from this (*‹⊢ is₁, xt₁ [::] τs₁ @ τ # τs₂›*) "is₂" (*‹⊢ is₂, xt₂ [::] τ # τs₂›*) s (*‹length τs₁ = length is₁›*) show "?thesis" (*goal: ‹⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τ # τs₂›*) by (rule wt_instrs_ext (*‹⟦⊢ ?is₁::bytecode, ?xt₁::ex_table [::] (?τs₁::(ty list × ty err list) option list) @ (?τs₂::(ty list × ty err list) option list); ⊢ ?is₂::bytecode, ?xt₂::ex_table [::] ?τs₂; length ?τs₁ = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] ?τs₁ @ ?τs₂›*)) qed (*>*) corollary (in TC2) wt_instrs_app_last[trans]: assumes "⊢ is₂,xt₂ [::] τ#τs₂" "⊢ is₁,xt₁ [::] τs₁" "last τs₁ = τ" "size τs₁ = size is₁+1" shows "⊢ is₁@is₂, xt₁@shift (size is₁) xt₂ [::] τs₁@τs₂" (*<*) using assms (*‹⊢ is₂::bytecode, xt₂::ex_table [::] (τ::(ty list × ty err list) option) # (τs₂::(ty list × ty err list) option list)› ‹⊢ is₁::bytecode, xt₁::ex_table [::] (τs₁::(ty list × ty err list) option list)› ‹last τs₁ = τ› ‹length (τs₁::(ty list × ty err list) option list) = length (is₁::bytecode) + (1::nat)›*) proof (cases τs₁ rule:rev_cases (*‹⟦?xs = [] ⟹ ?P; ⋀ys y. ?xs = ys @ [y] ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦⊢ is₂, xt₂ [::] τ # τs₂; ⊢ is₁, xt₁ [::] τs₁; last τs₁ = τ; length τs₁ = length is₁ + 1; τs₁ = []⟧ ⟹ ⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τs₂› 2. ‹⋀ys y. ⟦⊢ is₂, xt₂ [::] τ # τs₂; ⊢ is₁, xt₁ [::] τs₁; last τs₁ = τ; length τs₁ = length is₁ + 1; τs₁ = ys @ [y]⟧ ⟹ ⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τs₂›*) case (snoc ys y) (*‹τs₁ = ys @ [y]›*) then show "?thesis" (*goal: ‹⊢ (is₁::bytecode) @ (is₂::bytecode), (xt₁::ex_table) @ shift (length is₁) (xt₂::ex_table) [::] (τs₁::(ty list × ty err list) option list) @ (τs₂::(ty list × ty err list) option list)›*) using assms (*‹⊢ is₂, xt₂ [::] τ # τs₂› ‹⊢ is₁, xt₁ [::] τs₁› ‹last τs₁ = τ› ‹length τs₁ = length is₁ + 1›*) by (simp add:wt_instrs_app (*‹⟦⊢ ?is₁, ?xt₁ [::] ?τs₁ @ [?τ]; ⊢ ?is₂, ?xt₂ [::] ?τ # ?τs₂; length ?τs₁ = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] ?τs₁ @ ?τ # ?τs₂›*)) qed (simp) (*solved the remaining goal: ‹⟦⊢ is₂, xt₂ [::] τ # τs₂; ⊢ is₁, xt₁ [::] τs₁; last τs₁ = τ; length τs₁ = length is₁ + 1; τs₁ = []⟧ ⟹ ⊢ is₁ @ is₂, xt₁ @ shift (length is₁) xt₂ [::] τs₁ @ τs₂›*) (*>*) corollary (in TC2) wt_instrs_append_last[trans]: assumes wtis: "⊢ is,xt [::] τs" and wti: "P,T⇩r,mxs,mpc,[] ⊢ i,pc :: τs" and pc: "pc = size is" and mpc: "mpc = size τs" and is_τs: "size is + 1 < size τs" shows "⊢ is@[i],xt [::] τs" (*<*) proof (-) (*goal: ‹⊢ is @ [i], xt [::] τs›*) have pc_xt: "pc ∉ pcs xt" using wtis (*‹⊢ is, xt [::] τs›*) pc (*‹pc = length is›*) by (fastforce simp:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) have "pcs xt ⊆ {..<Suc (length is)}" using wtis (*‹⊢ is::bytecode, xt::ex_table [::] (τs::(ty list × ty err list) option list)›*) by (fastforce simp:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) moreover { fix pc' assume pc': "¬ pc' < length is" "pc' < Suc (length is)" (*‹¬ (pc'::nat) < length (is::bytecode)› ‹(pc'::nat) < Suc (length (is::bytecode))›*) have "P,T⇩r,mxs,length τs,xt ⊢ i,pc' :: τs" using wt_instr_appLx[where xt = "[]", simplified, OF wti pc_xt] (*‹(P::nat exp prog),T⇩r::ty,mxs::nat,mpc::nat,xt::ex_table ⊢ i::instr,pc::nat :: (τs::(ty list × ty err list) option list)›*) less_antisym[OF pc'] (*‹length is = pc'›*) pc (*‹pc = length is›*) mpc (*‹mpc = length τs›*) by simp } ultimately show "?thesis" (*goal: ‹⊢ is @ [i], xt [::] τs›*) using wtis (*‹⊢ is, xt [::] τs›*) "is_τs" (*‹length is + 1 < length τs›*) by (clarsimp simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) qed (*>*) corollary (in TC2) wt_instrs_app2: "⟦ ⊢ is₂,xt₂ [::] τ'#τs₂; ⊢ is₁,xt₁ [::] τ#τs₁@[τ']; xt' = xt₁ @ shift (size is₁) xt₂; size τs₁+1 = size is₁ ⟧ ⟹ ⊢ is₁@is₂,xt' [::] τ#τs₁@τ'#τs₂" (*<*)using wt_instrs_app[where ?τs₁.0 = "τ # τs₁"] (*‹⟦⊢ ?is₁, ?xt₁ [::] (τ # τs₁) @ [?τ]; ⊢ ?is₂, ?xt₂ [::] ?τ # ?τs₂; length (τ # τs₁) = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] (τ # τs₁) @ ?τ # ?τs₂›*) by simp (*>*) corollary (in TC2) wt_instrs_app2_simp[trans,simp]: "⟦ ⊢ is₂,xt₂ [::] τ'#τs₂; ⊢ is₁,xt₁ [::] τ#τs₁@[τ']; size τs₁+1 = size is₁ ⟧ ⟹ ⊢ is₁@is₂, xt₁@shift (size is₁) xt₂ [::] τ#τs₁@τ'#τs₂" (*<*)using wt_instrs_app[where ?τs₁.0 = "τ # τs₁"] (*‹⟦⊢ ?is₁, ?xt₁ [::] (τ # τs₁) @ [?τ]; ⊢ ?is₂, ?xt₂ [::] ?τ # ?τs₂; length (τ # τs₁) = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] (τ # τs₁) @ ?τ # ?τs₂›*) by simp(*>*) corollary (in TC2) wt_instrs_Cons[simp]: "⟦ τs ≠ []; ⊢ [i],[] [::] [τ,τ']; ⊢ is,xt [::] τ'#τs ⟧ ⟹ ⊢ i#is,shift 1 xt [::] τ#τ'#τs" (*<*) using wt_instrs_app2[where ?is₁.0 = "[i]" and ?τs₁.0 = "[]" and ?is₂.0 = "is" and ?xt₁.0 = "[]"] (*‹⟦⊢ is, ?xt₂ [::] ?τ' # ?τs₂; ⊢ [i], [] [::] ?τ # [] @ [?τ']; ?xt' = [] @ shift (length [i]) ?xt₂; length [] + 1 = length [i]⟧ ⟹ ⊢ [i] @ is, ?xt' [::] ?τ # [] @ ?τ' # ?τs₂›*) by simp corollary (in TC2) wt_instrs_Cons2[trans]: assumes τs: "⊢ is,xt [::] τs" assumes i: "P,T⇩r,mxs,mpc,[] ⊢ i,0 :: τ#τs" assumes mpc: "mpc = size τs + 1" shows "⊢ i#is,shift 1 xt [::] τ#τs" (*<*) proof (-) (*goal: ‹⊢ (i::instr) # (is::bytecode), shift (1::nat) (xt::ex_table) [::] (τ::(ty list × ty err list) option) # (τs::(ty list × ty err list) option list)›*) from "τs" (*‹⊢ is, xt [::] τs›*) have "τs ≠ []" by (auto simp: wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) with mpc (*‹(mpc::nat) = length (τs::(ty list × ty err list) option list) + (1::nat)›*) i (*‹P,T⇩r,mxs,mpc,[] ⊢ i,0 :: τ # τs›*) have "⊢ [i],[] [::] [τ]@τs" by (simp add: wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) with "τs" (*‹⊢ is, xt [::] τs›*) show "?thesis" (*goal: ‹⊢ i # is, shift 1 xt [::] τ # τs›*) by (fastforce dest: wt_instrs_ext (*‹⟦⊢ ?is₁, ?xt₁ [::] ?τs₁ @ ?τs₂; ⊢ ?is₂, ?xt₂ [::] ?τs₂; length ?τs₁ = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt₁ @ shift (length ?is₁) ?xt₂ [::] ?τs₁ @ ?τs₂›*)) qed (*>*) lemma (in TC2) wt_instrs_last_incr[trans]: assumes wtis: "⊢ is,xt [::] τs@[τ]" and ss: "P ⊢ τ ≤' τ'" shows "⊢ is,xt [::] τs@[τ']" (*<*) proof (-) (*goal: ‹⊢ is, xt [::] τs @ [τ']›*) let ?τs = "τs@[τ]" and ?τs' = "τs@[τ']" { fix pc assume pc: "pc< size is" (*‹(pc::nat) < length (is::bytecode)›*) let ?i = "is!pc" have app_pc: "app (is ! pc) P mxs T⇩r pc (length ?τs) xt (τs ! pc)" using wtis (*‹⊢ is::bytecode, xt::ex_table [::] (τs::(ty list × ty err list) option list) @ [τ::(ty list × ty err list) option]›*) pc (*‹pc < length is›*) by (clarsimp simp add:wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) wt_instr_def (*‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) then have "Apcτ'": "⋀pc' τ'. (pc',τ') ∈ set (eff ?i P pc xt (?τs!pc)) ⟹ pc' < length ?τs" using wtis (*‹⊢ is, xt [::] τs @ [τ]›*) pc (*‹pc < length is›*) by (fastforce simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) have "Aepcτ'": "⋀pc' τ'. (pc',τ') ∈ set (eff ?i P pc xt (?τs!pc)) ⟹ P ⊢ τ' ≤' ?τs!pc'" using wtis (*‹⊢ is, xt [::] τs @ [τ]›*) pc (*‹pc < length is›*) by (fastforce simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) { fix pc1 and τ1 assume "pcτ1": "(pc1,τ1) ∈ set (eff ?i P pc xt (?τs'!pc))" (*‹(pc1::nat, τ1::(ty list × ty err list) option) ∈ set (eff ((is::bytecode) ! (pc::nat)) (P::nat exp prog) pc (xt::ex_table) (((τs::(ty list × ty err list) option list) @ [τ'::(ty list × ty err list) option]) ! pc))›*) then have "epcτ'": "(pc1,τ1) ∈ set (eff ?i P pc xt (?τs!pc))" using wtis (*‹⊢ is, xt [::] τs @ [τ]›*) pc (*‹(pc::nat) < length (is::bytecode)›*) by (simp add:wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) have "P ⊢ τ1 ≤' ?τs'!pc1" proof (cases "pc1 < length τs") (*goals: 1. ‹pc1 < length τs ⟹ P ⊢ τ1 ≤' (τs @ [τ']) ! pc1› 2. ‹¬ pc1 < length τs ⟹ P ⊢ τ1 ≤' (τs @ [τ']) ! pc1›*) case True (*‹pc1 < length τs›*) then show "?thesis" (*goal: ‹P ⊢ τ1 ≤' (τs @ [τ']) ! pc1›*) using wtis (*‹⊢ is::bytecode, xt::ex_table [::] (τs::(ty list × ty err list) option list) @ [τ::(ty list × ty err list) option]›*) pc (*‹pc < length is›*) "pcτ1" (*‹(pc1, τ1) ∈ set (eff (is ! pc) P pc xt ((τs @ [τ']) ! pc))›*) by (fastforce simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) next (*goal: ‹¬ pc1 < length τs ⟹ P ⊢ τ1 ≤' (τs @ [τ']) ! pc1›*) case False (*‹¬ pc1 < length τs›*) then have "pc1 < length ?τs" using "Apcτ'"[OF epcτ'] (*‹pc1 < length (τs @ [τ])›*) by simp then have [simp]: "pc1 = size τs" using False (*‹¬ pc1 < length τs›*) by clarsimp have "P ⊢ τ1 ≤' τ" using "Aepcτ'"[OF epcτ'] (*‹P ⊢ τ1 ≤' (τs @ [τ]) ! pc1›*) by simp then have "P ⊢ τ1 ≤' τ'" by (rule sup_state_opt_trans[OF _ ss] (*‹P ⊢ ?a ≤' τ ⟹ P ⊢ ?a ≤' τ'›*)) then show "?thesis" (*goal: ‹P ⊢ τ1 ≤' (τs @ [τ']) ! pc1›*) by simp qed } then have "P,T⇩r,mxs,size ?τs',xt ⊢ is!pc,pc :: ?τs'" using wtis (*‹⊢ is, xt [::] τs @ [τ]›*) pc (*‹pc < length is›*) by (clarsimp simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*) wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) } then show "?thesis" (*goal: ‹⊢ is, xt [::] τs @ [τ']›*) using wtis (*‹⊢ is::bytecode, xt::ex_table [::] (τs::(ty list × ty err list) option list) @ [τ::(ty list × ty err list) option]›*) by (simp add:wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) qed (*>*) lemma [iff]: "xcpt_app i P pc mxs [] τ" (*<*)by (simp add: xcpt_app_def (*‹xcpt_app ?i ?P ?pc ?mxs ?xt ?τ = (∀(f, t, C, h, d)∈set (relevant_entries ?P ?i ?pc ?xt). is_class ?P C ∧ d ≤ length (fst ?τ) ∧ d < ?mxs)›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*))(*>*) lemma [simp]: "xcpt_eff i P pc τ [] = []" (*<*)by (simp add: xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*))(*>*) lemma (in TC2) wt_New: "⟦ is_class P C; size ST < mxs ⟧ ⟹ ⊢ [New C],[] [::] [ty⇩i' ST E A, ty⇩i' (Class C#ST) E A]" (*<*)by (simp add:wt_defs (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) ty⇩i'_def (*‹ty⇩i' (?ST::?'a) (?E::?'b list) (?A::nat set option) = (case ?A of None ⇒ None | ⌊A'::nat set⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*))(*>*) lemma (in TC2) wt_Cast: "is_class P C ⟹ ⊢ [Checkcast C],[] [::] [ty⇩i' (Class D # ST) E A, ty⇩i' (Class C # ST) E A]" (*<*)by (simp add: ty⇩i'_def (*‹ty⇩i' (?ST::?'a) (?E::?'b list) (?A::nat set option) = (case ?A of None ⇒ None | ⌊A'::nat set⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_Push: "⟦ size ST < mxs; typeof v = Some T ⟧ ⟹ ⊢ [Push v],[] [::] [ty⇩i' ST E A, ty⇩i' (T#ST) E A]" (*<*)by (simp add: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_Pop: "⊢ [Pop],[] [::] (ty⇩i' (T#ST) E A # ty⇩i' ST E A # τs)" (*<*)by (simp add: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_CmpEq: "⟦ P ⊢ T₁ ≤ T₂ ∨ P ⊢ T₂ ≤ T₁⟧ ⟹ ⊢ [CmpEq],[] [::] [ty⇩i' (T₂ # T₁ # ST) E A, ty⇩i' (Boolean # ST) E A]" (*<*) by (auto simp:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) elim!: refTE (*‹⟦is_refT ?T; ?T = NT ⟹ ?P; ⋀C. ?T = Class C ⟹ ?P⟧ ⟹ ?P›*) not_refTE (*‹⟦¬ is_refT ?T; ?T = Void ∨ ?T = Boolean ∨ ?T = Integer ⟹ ?P⟧ ⟹ ?P›*)) (*>*) lemma (in TC2) wt_IAdd: "⊢ [IAdd],[] [::] [ty⇩i' (Integer#Integer#ST) E A, ty⇩i' (Integer#ST) E A]" (*<*)by (simp add:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_Load: "⟦ size ST < mxs; size E ≤ mxl; i ∈∈ A; i < size E ⟧ ⟹ ⊢ [Load i],[] [::] [ty⇩i' ST E A, ty⇩i' (E!i # ST) E A]" (*<*)by (auto simp add:ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*))(*>*) lemma (in TC2) wt_Store: "⟦ P ⊢ T ≤ E!i; i < size E; size E ≤ mxl ⟧ ⟹ ⊢ [Store i],[] [::] [ty⇩i' (T#ST) E A, ty⇩i' ST E (⌊{i}⌋ ⊔ A)]" (*<*) by (auto simp:hyperset_defs (*‹?A ⊔ ?B ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ case ?B of None ⇒ None | ⌊B⌋ ⇒ ⌊A ∪ B⌋› ‹?A ⊓ ?B ≡ case ?A of None ⇒ ?B | ⌊A⌋ ⇒ case ?B of None ⇒ ⌊A⌋ | ⌊B⌋ ⇒ ⌊A ∩ B⌋› ‹?A ⊖ ?a ≡ case ?A of None ⇒ None | ⌊A⌋ ⇒ ⌊A - {?a}⌋› ‹?a ∈∈ ?A ≡ case ?A of None ⇒ True | ⌊A⌋ ⇒ ?a ∈ A› ‹?A ⊑ ?B ≡ case ?B of None ⇒ True | ⌊B⌋ ⇒ case ?A of None ⇒ False | ⌊A⌋ ⇒ A ⊆ B›*) nth_list_update (*‹?i < length ?xs ⟹ ?xs[?i := ?x] ! ?j = (if ?i = ?j then ?x else ?xs ! ?j)›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) intro:list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*)) (*>*) lemma (in TC2) wt_Get: "⟦ P ⊢ C sees F,NonStatic:T in D ⟧ ⟹ ⊢ [Getfield F D],[] [::] [ty⇩i' (Class C # ST) E A, ty⇩i' (T # ST) E A]" (*<*)by (auto simp: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) dest: sees_field_idemp (*‹?P ⊢ ?C sees ?F,?b:?T in ?D ⟹ ?P ⊢ ?D sees ?F,?b:?T in ?D›*) sees_field_decl_above (*‹?P ⊢ ?C sees ?F,?b:?T in ?D ⟹ ?P ⊢ ?C ≼⇧* ?D›*))(*>*) lemma (in TC2) wt_GetS: "⟦ size ST < mxs; P ⊢ C sees F,Static:T in D ⟧ ⟹ ⊢ [Getstatic C F D],[] [::] [ty⇩i' ST E A, ty⇩i' (T # ST) E A]" (*<*)by (auto simp: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) dest: sees_field_idemp (*‹?P ⊢ ?C sees ?F,?b:?T in ?D ⟹ ?P ⊢ ?D sees ?F,?b:?T in ?D›*) sees_field_decl_above (*‹?P ⊢ ?C sees ?F,?b:?T in ?D ⟹ ?P ⊢ ?C ≼⇧* ?D›*))(*>*) lemma (in TC2) wt_Put: "⟦ P ⊢ C sees F,NonStatic:T in D; P ⊢ T' ≤ T ⟧ ⟹ ⊢ [Putfield F D],[] [::] [ty⇩i' (T' # Class C # ST) E A, ty⇩i' ST E A]" (*<*)by (auto intro: sees_field_idemp (*‹(?P::?'a prog) ⊢ (?C::char list) sees (?F::char list),(?b::staticb):(?T::ty) in (?D::char list) ⟹ ?P ⊢ ?D sees ?F,?b:?T in ?D›*) sees_field_decl_above (*‹(?P::?'a prog) ⊢ (?C::char list) sees (?F::char list),(?b::staticb):(?T::ty) in (?D::char list) ⟹ ?P ⊢ ?C ≼⇧* ?D›*) simp: ty⇩i'_def (*‹ty⇩i' (?ST::?'a) (?E::?'b list) (?A::nat set option) = (case ?A of None ⇒ None | ⌊A'::nat set⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹(?P::?'m prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_PutS: "⟦ P ⊢ C sees F,Static:T in D; P ⊢ T' ≤ T ⟧ ⟹ ⊢ [Putstatic C F D],[] [::] [ty⇩i' (T' # ST) E A, ty⇩i' ST E A]" (*<*)by (auto intro: sees_field_idemp (*‹?P ⊢ ?C sees ?F,?b:?T in ?D ⟹ ?P ⊢ ?D sees ?F,?b:?T in ?D›*) sees_field_decl_above (*‹?P ⊢ ?C sees ?F,?b:?T in ?D ⟹ ?P ⊢ ?C ≼⇧* ?D›*) simp: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_Throw: "⊢ [Throw],[] [::] [ty⇩i' (Class C # ST) E A, τ']" (*<*)by (auto simp: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_IfFalse: "⟦ 2 ≤ i; nat i < size τs + 2; P ⊢ ty⇩i' ST E A ≤' τs ! nat(i - 2) ⟧ ⟹ ⊢ [IfFalse i],[] [::] ty⇩i' (Boolean # ST) E A # ty⇩i' ST E A # τs" (*<*) by (simp add: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) eval_nat_numeral (*‹Numeral1 = Suc 0› ‹numeral (num.Bit0 ?n) = Suc (numeral (Num.BitM ?n))› ‹numeral (num.Bit1 ?n) = Suc (numeral (num.Bit0 ?n))›*) nat_diff_distrib (*‹⟦0 ≤ ?z'; ?z' ≤ ?z⟧ ⟹ nat (?z - ?z') = nat ?z - nat ?z'›*)) (*>*) lemma wt_Goto: "⟦ 0 ≤ int pc + i; nat (int pc + i) < size τs; size τs ≤ mpc; P ⊢ τs!pc ≤' τs ! nat (int pc + i) ⟧ ⟹ P,T,mxs,mpc,[] ⊢ Goto i,pc :: τs" (*<*)by (clarsimp simp add: TC2.wt_defs (*‹(?P,?T⇩r,?mxs ⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. ?P,?T⇩r,?mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_Invoke: "⟦ size es = size Ts'; P ⊢ C sees M,NonStatic: Ts→T = m in D; P ⊢ Ts' [≤] Ts ⟧ ⟹ ⊢ [Invoke M (size es)],[] [::] [ty⇩i' (rev Ts' @ Class C # ST) E A, ty⇩i' (T#ST) E A]" (*<*)by (fastforce simp add: ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) lemma (in TC2) wt_Invokestatic: "⟦ size ST < mxs; size es = size Ts'; M ≠ clinit; P ⊢ C sees M,Static: Ts→T = m in D; P ⊢ Ts' [≤] Ts ⟧ ⟹ ⊢ [Invokestatic C M (size es)],[] [::] [ty⇩i' (rev Ts' @ ST) E A, ty⇩i' (T#ST) E A]" (*<*)by (fastforce simp add: ty⇩i'_def (*‹ty⇩i' (?ST::?'a::type) (?E::?'b::type list) (?A::nat set option) = (case ?A of None ⇒ None | ⌊A'::nat set⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) wt_defs (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹(?P::?'m::type prog),?T::ty,?mxs::nat,?mpc::nat,?xt::ex_table ⊢ ?i::instr,?pc::nat :: (?τs::(ty list × ty err list) option list) ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app (?i::instr) (?P::?'m::type prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff (?i::instr) (?P::?'m::type prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff (?i::instr) (?P::?'m::type prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*))(*>*) corollary (in TC2) wt_instrs_app3[simp]: "⟦ ⊢ is₂,[] [::] (τ' # τs₂); ⊢ is₁,xt₁ [::] τ # τs₁ @ [τ']; size τs₁+1 = size is₁⟧ ⟹ ⊢ (is₁ @ is₂),xt₁ [::] τ # τs₁ @ τ' # τs₂" (*<*)using wt_instrs_app2[where ?xt₂.0 = "[]"] (*‹⟦⊢ ?is₂, [] [::] ?τ' # ?τs₂; ⊢ ?is₁, ?xt₁ [::] ?τ # ?τs₁ @ [?τ']; ?xt' = ?xt₁ @ shift (length ?is₁) []; length ?τs₁ + 1 = length ?is₁⟧ ⟹ ⊢ ?is₁ @ ?is₂, ?xt' [::] ?τ # ?τs₁ @ ?τ' # ?τs₂›*) by (simp add:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*))(*>*) corollary (in TC2) wt_instrs_Cons3[simp]: "⟦ τs ≠ []; ⊢ [i],[] [::] [τ,τ']; ⊢ is,[] [::] τ'#τs ⟧ ⟹ ⊢ (i # is),[] [::] τ # τ' # τs" (*<*) using wt_instrs_Cons[where ?xt = "[]"] (*‹⟦?τs ≠ []; ⊢ [?i], [] [::] [?τ, ?τ']; ⊢ ?is, [] [::] ?τ' # ?τs⟧ ⟹ ⊢ ?i # ?is, shift 1 [] [::] ?τ # ?τ' # ?τs›*) by (simp add:shift_def (*‹shift ?n ?xt ≡ map (λ(from, to, C, handler, depth). (from + ?n, to + ?n, C, handler + ?n, depth)) ?xt›*)) (*<*) declare nth_append[simp del] declare [[simproc del: list_to_set_comprehension]] (*>*) lemma (in TC2) wt_instrs_xapp[trans]: assumes wtis: "⊢ is₁ @ is₂, xt [::] τs₁ @ ty⇩i' (Class C # ST) E A # τs₂" and P_τs₁: "∀τ ∈ set τs₁. ∀ST' LT'. τ = Some(ST',LT') ⟶ size ST ≤ size ST' ∧ P ⊢ Some (drop (size ST' - size ST) ST',LT') ≤' ty⇩i' ST E A" and is_τs: "size is₁ = size τs₁" and PC: "is_class P C" and ST_mxs: "size ST < mxs" shows "⊢ is₁ @ is₂, xt @ [(0,size is₁ - 1,C,size is₁,size ST)] [::] τs₁ @ ty⇩i' (Class C # ST) E A # τs₂" (*<*)(is "⊢ ?is, xt@[?xte] [::] ?τs" is "⊢ ?is, ?xt' [::] ?τs") proof (-) (*goal: ‹⊢ is₁ @ is₂, xt @ [(0, length is₁ - 1, C, length is₁, length ST)] [::] τs₁ @ ty⇩i' (Class C # ST) E A # τs₂›*) have "P_τs₁'": "⋀τ. τ ∈ set τs₁ ⟹ (∀ST' LT'. τ = Some(ST',LT') ⟶ size ST ≤ size ST' ∧ P ⊢ Some (drop (size ST' - size ST) ST',LT') ≤' ty⇩i' ST E A)" using "P_τs₁" (*‹∀τ∈set τs₁. ∀ST' LT'. τ = ⌊(ST', LT')⌋ ⟶ length ST ≤ length ST' ∧ P ⊢ ⌊(drop (length ST' - length ST) ST', LT')⌋ ≤' ty⇩i' ST E A›*) by fast have "size ?is < size ?τs" and "pcs ?xt' ⊆ {0..<size ?is}" and P_pc: "⋀pc. pc< size ?is ⟹ P,T⇩r,mxs,size ?τs,xt ⊢ ?is!pc,pc :: ?τs" using wtis (*‹⊢ (is₁::bytecode) @ (is₂::bytecode), xt::ex_table [::] (τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)›*) apply - (*goals: 1. ‹⊢ (is₁::bytecode) @ (is₂::bytecode), xt::ex_table [::] (τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list) ⟹ length (is₁ @ is₂) < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)› 2. ‹⊢ (is₁::bytecode) @ (is₂::bytecode), xt::ex_table [::] (τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list) ⟹ pcs (xt @ [(0::nat, length is₁ - (1::nat), C, length is₁, length ST)]) ⊆ {0::nat..<length (is₁ @ is₂)}› 3. ‹⋀pc::nat. ⟦pc < length ((is₁::bytecode) @ (is₂::bytecode)); ⊢ is₁ @ is₂, xt::ex_table [::] (τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)⟧ ⟹ (P::nat exp prog),T⇩r::ty,mxs::nat,length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂),xt ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ ty⇩i' (Class C # ST) E A # τs₂› discuss goal 1*) apply (simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) (*discuss goal 2*) apply (simp add:wt_instrs_def (*‹(⊢ ?is::bytecode, ?xt::ex_table [::] (?τs::(ty list × ty err list) option list)) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0::nat..<length ?is} ∧ (∀pc<length ?is. (P::nat exp prog),T⇩r::ty,mxs::nat,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) (*discuss goal 3*) apply (simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) (*proven 3 subgoals*) . moreover { fix pc let ?mpc = "size ?τs" and ?i = "?is!pc" and ?t = "?τs!pc" assume "pc< size ?is" (*‹(pc::nat) < length ((is₁::bytecode) @ (is₂::bytecode))›*) then have wti: "P,T⇩r,mxs,?mpc,xt ⊢ ?i,pc :: ?τs" by (rule P_pc (*‹?pc2 < length (is₁ @ is₂) ⟹ P,T⇩r,mxs,length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂),xt ⊢ (is₁ @ is₂) ! ?pc2,?pc2 :: τs₁ @ ty⇩i' (Class C # ST) E A # τs₂›*)) then have app: "app ?i P mxs T⇩r pc ?mpc xt ?t" and eff_ss: "⋀pc' τ'. (pc',τ') ∈ set (eff ?i P pc xt (?τs!pc)) ⟹ P ⊢ τ' ≤' ?τs!pc'" apply - (*goals: 1. ‹P,T⇩r,mxs,length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂),xt ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ ty⇩i' (Class C # ST) E A # τs₂ ⟹ app ((is₁ @ is₂) ! pc) P mxs T⇩r pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)› 2. ‹⋀pc' τ'. ⟦(pc', τ') ∈ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)); P,T⇩r,mxs,length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂),xt ⊢ (is₁ @ is₂) ! pc,pc :: τs₁ @ ty⇩i' (Class C # ST) E A # τs₂⟧ ⟹ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'› discuss goal 1*) apply (fastforce simp add: wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) (*discuss goal 2*) apply (fastforce simp add: wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) (*proven 2 subgoals*) . have "app ?i P mxs T⇩r pc ?mpc ?xt' ?t ∧ (∀(pc',τ') ∈ set (eff ?i P pc ?xt' ?t). P ⊢ τ' ≤' ?τs!pc')" proof (cases ?t) (*goals: 1. ‹((τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)) ! (pc::nat) = None ⟹ app (((is₁::bytecode) @ (is₂::bytecode)) ! pc) (P::nat exp prog) (mxs::nat) (T⇩r::ty) pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) ((xt::ex_table) @ [(0::nat, length is₁ - (1::nat), C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ((is₁ @ is₂) ! pc) P pc (xt @ [(0::nat, length is₁ - (1::nat), C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)). P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc')› 2. ‹⋀a::ty list × ty err list. ((τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)) ! (pc::nat) = ⌊a⌋ ⟹ app (((is₁::bytecode) @ (is₂::bytecode)) ! pc) (P::nat exp prog) (mxs::nat) (T⇩r::ty) pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) ((xt::ex_table) @ [(0::nat, length is₁ - (1::nat), C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc) ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ((is₁ @ is₂) ! pc) P pc (xt @ [(0::nat, length is₁ - (1::nat), C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)). P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc')›*) case (Some τ) (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) obtain ST' and LT' where "τ": "τ = (ST', LT')" (*goal: ‹(⋀(ST'::ty list) LT'::ty err list. (τ::ty list × ty err list) = (ST', LT') ⟹ thesis::bool) ⟹ thesis›*) apply (cases τ) (*goal: ‹(⋀ST' LT'. τ = (ST', LT') ⟹ thesis) ⟹ thesis›*) by simp have "app⇩i": "app⇩i (?i,P,pc,mxs,T⇩r,τ)" and xcpt_app: "xcpt_app ?i P pc mxs xt τ" and eff_pc: "⋀pc' τ'. (pc',τ') ∈ set (eff ?i P pc xt ?t) ⟹ pc' < ?mpc" using Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) app (*‹app (((is₁::bytecode) @ (is₂::bytecode)) ! (pc::nat)) (P::nat exp prog) (mxs::nat) (T⇩r::ty) pc (length ((τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list))) (xt::ex_table) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)›*) apply - (*goals: 1. ‹⟦(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋; app ((is₁ @ is₂) ! pc) P mxs T⇩r pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)⟧ ⟹ app⇩i ((is₁ @ is₂) ! pc, P, pc, mxs, T⇩r, τ)› 2. ‹⟦(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋; app ((is₁ @ is₂) ! pc) P mxs T⇩r pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)⟧ ⟹ xcpt_app ((is₁ @ is₂) ! pc) P pc mxs xt τ› 3. ‹⋀pc' τ'. ⟦(pc', τ') ∈ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)); (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋; app ((is₁ @ is₂) ! pc) P mxs T⇩r pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)⟧ ⟹ pc' < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)› discuss goal 1*) apply (fastforce simp add: app_def (*‹app (?i::instr) (?P::?'m::type prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) (*discuss goal 2*) apply (fastforce simp add: app_def (*‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) (*discuss goal 3*) apply (fastforce simp add: app_def (*‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) (*proven 3 subgoals*) . have "xcpt_app ?i P pc mxs ?xt' τ" proof (cases "pc < length τs₁ - 1") (*goals: 1. ‹(pc::nat) < length (τs₁::(ty list × ty err list) option list) - (1::nat) ⟹ xcpt_app (((is₁::bytecode) @ (is₂::bytecode)) ! pc) (P::nat exp prog) pc (mxs::nat) ((xt::ex_table) @ [(0::nat, length is₁ - (1::nat), C::char list, length is₁, length (ST::ty list))]) (τ::ty list × ty err list)› 2. ‹¬ (pc::nat) < length (τs₁::(ty list × ty err list) option list) - (1::nat) ⟹ xcpt_app (((is₁::bytecode) @ (is₂::bytecode)) ! pc) (P::nat exp prog) pc (mxs::nat) ((xt::ex_table) @ [(0::nat, length is₁ - (1::nat), C::char list, length is₁, length (ST::ty list))]) (τ::ty list × ty err list)›*) case False (*‹¬ (pc::nat) < length (τs₁::(ty list × ty err list) option list) - (1::nat)›*) then show "?thesis" (*goal: ‹xcpt_app (((is₁::bytecode) @ (is₂::bytecode)) ! (pc::nat)) (P::nat exp prog) pc (mxs::nat) ((xt::ex_table) @ [(0::nat, length is₁ - (1::nat), C::char list, length is₁, length (ST::ty list))]) (τ::ty list × ty err list)›*) using Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) "τ" (*‹τ = (ST', LT')›*) "is_τs" (*‹length is₁ = length τs₁›*) xcpt_app (*‹xcpt_app ((is₁ @ is₂) ! pc) P pc mxs xt τ›*) by (clarsimp simp: xcpt_app_def (*‹xcpt_app (?i::instr) (?P::?'m prog) (?pc::nat) (?mxs::nat) (?xt::ex_table) (?τ::ty list × ty err list) = (∀(f::nat, t::nat, C::char list, h::nat, d::nat)∈set (relevant_entries ?P ?i ?pc ?xt). is_class ?P C ∧ d ≤ length (fst ?τ) ∧ d < ?mxs)›*) relevant_entries_def (*‹relevant_entries (?P::?'m prog) (?i::instr) (?pc::nat) = filter (is_relevant_entry ?P ?i ?pc)›*) is_relevant_entry_def (*‹is_relevant_entry (?P::?'m prog) (?i::instr) (?pc::nat) (?e::ex_entry) = (let (f::nat, t::nat, C::char list, h::nat, d::nat) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*)) next (*goal: ‹pc < length τs₁ - 1 ⟹ xcpt_app ((is₁ @ is₂) ! pc) P pc mxs (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) τ›*) case True (*‹pc < length τs₁ - 1›*) then have True': "pc < length τs₁" by simp then have "τs₁ ! pc = ?t" by (fastforce simp: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) moreover have "τs₁_pc": "τs₁ ! pc ∈ set τs₁" by (rule nth_mem[OF True'] (*‹τs₁ ! pc ∈ set τs₁›*)) ultimately show "?thesis" (*goal: ‹xcpt_app ((is₁ @ is₂) ! pc) P pc mxs (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) τ›*) using Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) "τ" (*‹τ = (ST', LT')›*) PC (*‹is_class P C›*) ST_mxs (*‹length (ST::ty list) < (mxs::nat)›*) xcpt_app (*‹xcpt_app ((is₁ @ is₂) ! pc) P pc mxs xt τ›*) "P_τs₁'"[OF τs₁_pc] (*‹∀ST' LT'. τs₁ ! pc = ⌊(ST', LT')⌋ ⟶ length ST ≤ length ST' ∧ P ⊢ ⌊(drop (length ST' - length ST) ST', LT')⌋ ≤' ty⇩i' ST E A›*) by (simp add: xcpt_app_def (*‹xcpt_app ?i ?P ?pc ?mxs ?xt ?τ = (∀(f, t, C, h, d)∈set (relevant_entries ?P ?i ?pc ?xt). is_class ?P C ∧ d ≤ length (fst ?τ) ∧ d < ?mxs)›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*)) qed moreover { fix pc' and τ' assume efft: "(pc',τ') ∈ set (eff ?i P pc ?xt' ?t)" (*‹(pc'::nat, τ'::(ty list × ty err list) option) ∈ set (eff (((is₁::bytecode) @ (is₂::bytecode)) ! (pc::nat)) (P::nat exp prog) pc ((xt::ex_table) @ [(0::nat, length is₁ - (1::nat), C::char list, length is₁, length (ST::ty list))]) (((τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class C # ST) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)) ! pc))›*) have "pc' < ?mpc ∧ P ⊢ τ' ≤' ?τs!pc'" (is "?P1 ∧ ?P2") proof (cases "(pc',τ') ∈ set (eff ?i P pc xt ?t)") (*goals: 1. ‹(pc', τ') ∈ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)) ⟹ pc' < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ∧ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'› 2. ‹(pc', τ') ∉ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)) ⟹ pc' < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ∧ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) case True (*‹(pc', τ') ∈ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc))›*) have "?P1" using True (*‹(pc', τ') ∈ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc))›*) by (rule eff_pc (*‹(?pc'2, ?τ'2) ∈ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)) ⟹ ?pc'2 < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)›*)) moreover have "?P2" using True (*‹(pc'::nat, τ'::(ty list × ty err list) option) ∈ set (eff (((is₁::bytecode) @ (is₂::bytecode)) ! (pc::nat)) (P::nat exp prog) pc (xt::ex_table) (((τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)) ! pc))›*) by (rule eff_ss (*‹(?pc'2::nat, ?τ'2::(ty list × ty err list) option) ∈ set (eff (((is₁::bytecode) @ (is₂::bytecode)) ! (pc::nat)) (P::nat exp prog) pc (xt::ex_table) (((τs₁::(ty list × ty err list) option list) @ ty⇩i' (Class (C::char list) # (ST::ty list)) (E::ty list) (A::nat set option) # (τs₂::(ty list × ty err list) option list)) ! pc)) ⟹ P ⊢ ?τ'2 ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! ?pc'2›*)) ultimately show "?thesis" (*goal: ‹pc' < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ∧ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) by simp next (*goal: ‹(pc', τ') ∉ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)) ⟹ pc' < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ∧ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) case False (*‹(pc', τ') ∉ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc))›*) then have xte: "(pc',τ') ∈ set (xcpt_eff ?i P pc τ [?xte])" using efft (*‹(pc', τ') ∈ set (eff ((is₁ @ is₂) ! pc) P pc (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc))›*) Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) by (clarsimp simp: eff_def (*‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*)) then have "?P1" using Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) "τ" (*‹(τ::ty list × ty err list) = (ST'::ty list, LT'::ty err list)›*) "is_τs" (*‹length is₁ = length τs₁›*) by (clarsimp simp: xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) moreover have "?P2" proof (cases "pc < length τs₁ - 1") (*goals: 1. ‹pc < length τs₁ - 1 ⟹ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'› 2. ‹¬ pc < length τs₁ - 1 ⟹ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) case False': False (*‹¬ (pc::nat) < length (τs₁::(ty list × ty err list) option list) - (1::nat)›*) then show "?thesis" (*goal: ‹P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) using False (*‹(pc', τ') ∉ set (eff ((is₁ @ is₂) ! pc) P pc xt ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc))›*) Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) "τ" (*‹τ = (ST', LT')›*) xte (*‹(pc', τ') ∈ set (xcpt_eff ((is₁ @ is₂) ! pc) P pc τ [(0, length is₁ - 1, C, length is₁, length ST)])›*) "is_τs" (*‹length (is₁::bytecode) = length (τs₁::(ty list × ty err list) option list)›*) by (simp add: xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*) is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*)) next (*goal: ‹pc < length τs₁ - 1 ⟹ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) case True (*‹pc < length τs₁ - 1›*) then have True': "pc < length τs₁" by simp have "τs₁_pc": "τs₁ ! pc ∈ set τs₁" by (rule nth_mem[OF True'] (*‹τs₁ ! pc ∈ set τs₁›*)) have "P ⊢ ⌊(Class C # drop (length ST' - length ST) ST', LT')⌋ ≤' ty⇩i' (Class C # ST) E A" using True' (*‹pc < length τs₁›*) Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) "τ" (*‹τ = (ST', LT')›*) "P_τs₁'"[OF τs₁_pc] (*‹∀ST' LT'. τs₁ ! pc = ⌊(ST', LT')⌋ ⟶ length ST ≤ length ST' ∧ P ⊢ ⌊(drop (length ST' - length ST) ST', LT')⌋ ≤' ty⇩i' ST E A›*) by (fastforce simp: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*)) then show "?thesis" (*goal: ‹P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) using "τ" (*‹τ = (ST', LT')›*) xte (*‹(pc', τ') ∈ set (xcpt_eff ((is₁ @ is₂) ! pc) P pc τ [(0, length is₁ - 1, C, length is₁, length ST)])›*) "is_τs" (*‹length is₁ = length τs₁›*) by (simp add: xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*) split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) qed ultimately show "?thesis" (*goal: ‹pc' < length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ∧ P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc'›*) by simp qed } ultimately show "?thesis" (*goal: ‹app ((is₁ @ is₂) ! pc) P mxs T⇩r pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc) ∧ (∀(pc', τ')∈set (eff ((is₁ @ is₂) ! pc) P pc (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)). P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc')›*) using Some (*‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = ⌊τ⌋›*) "app⇩i" (*‹app⇩i ((is₁ @ is₂) ! pc, P, pc, mxs, T⇩r, τ)›*) by (fastforce simp add: app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*)) qed (simp) (*solved the remaining goal: ‹(τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc = None ⟹ app ((is₁ @ is₂) ! pc) P mxs T⇩r pc (length (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂)) (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc) ∧ (∀(pc', τ')∈set (eff ((is₁ @ is₂) ! pc) P pc (xt @ [(0, length is₁ - 1, C, length is₁, length ST)]) ((τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc)). P ⊢ τ' ≤' (τs₁ @ ty⇩i' (Class C # ST) E A # τs₂) ! pc')›*) then have "P,T⇩r,mxs,size ?τs,?xt' ⊢ ?is!pc,pc :: ?τs" by (simp add: wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*)) } ultimately show "?thesis" (*goal: ‹⊢ is₁ @ is₂, xt @ [(0, length is₁ - 1, C, length is₁, length ST)] [::] τs₁ @ ty⇩i' (Class C # ST) E A # τs₂›*) by (simp add:wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) qed declare [[simproc add: list_to_set_comprehension]] declare nth_append[simp] (*>*) lemma drop_Cons_Suc: "⋀xs. drop n xs = y#ys ⟹ drop (Suc n) xs = ys" proof (induct n) (*goals: 1. ‹⋀xs. drop 0 xs = y # ys ⟹ drop (Suc 0) xs = ys› 2. ‹⋀n xs. ⟦⋀xs. drop n xs = y # ys ⟹ drop (Suc n) xs = ys; drop (Suc n) xs = y # ys⟧ ⟹ drop (Suc (Suc n)) xs = ys›*) case (Suc n) (*‹drop n ?xs = y # ys ⟹ drop (Suc n) ?xs = ys› ‹drop (Suc n) xs = y # ys›*) then show "?case" (*goal: ‹drop (Suc (Suc n)) xs = ys›*) by (simp add: drop_Suc (*‹drop (Suc ?n) ?xs = drop ?n (tl ?xs)›*)) qed (simp) (*solved the remaining goal: ‹⋀xs. drop 0 xs = y # ys ⟹ drop (Suc 0) xs = ys›*) lemma drop_mess: assumes "Suc (length xs₀) ≤ length xs" and "drop (length xs - Suc (length xs₀)) xs = x # xs₀" shows "drop (length xs - length xs₀) xs = xs₀" using assms (*‹Suc (length xs₀) ≤ length xs› ‹drop (length xs - Suc (length xs₀)) xs = x # xs₀›*) proof (cases xs) (*goals: 1. ‹⟦Suc (length xs₀) ≤ length xs; drop (length xs - Suc (length xs₀)) xs = x # xs₀; xs = []⟧ ⟹ drop (length xs - length xs₀) xs = xs₀› 2. ‹⋀a list. ⟦Suc (length xs₀) ≤ length xs; drop (length xs - Suc (length xs₀)) xs = x # xs₀; xs = a # list⟧ ⟹ drop (length xs - length xs₀) xs = xs₀›*) case (Cons a list) (*‹xs = a # list›*) then show "?thesis" (*goal: ‹drop (length (xs::'a list) - length (xs₀::'a list)) xs = xs₀›*) using assms (*‹Suc (length (xs₀::'a list)) ≤ length (xs::'a list)› ‹drop (length xs - Suc (length xs₀)) xs = x # xs₀›*) proof (cases "length list - length xs₀") (*goals: 1. ‹⟦(xs::'a list) = (a::'a) # (list::'a list); Suc (length (xs₀::'a list)) ≤ length xs; drop (length xs - Suc (length xs₀)) xs = (x::'a) # xs₀; length list - length xs₀ = (0::nat)⟧ ⟹ drop (length xs - length xs₀) xs = xs₀› 2. ‹⋀nat::nat. ⟦(xs::'a list) = (a::'a) # (list::'a list); Suc (length (xs₀::'a list)) ≤ length xs; drop (length xs - Suc (length xs₀)) xs = (x::'a) # xs₀; length list - length xs₀ = Suc nat⟧ ⟹ drop (length xs - length xs₀) xs = xs₀›*) case Suc (*‹length (list::'a list) - length (xs₀::'a list) = Suc (nat_::nat)›*) then show "?thesis" (*goal: ‹drop (length xs - length xs₀) xs = xs₀›*) using Cons (*‹xs = a # list›*) assms (*‹Suc (length xs₀) ≤ length xs› ‹drop (length xs - Suc (length xs₀)) xs = x # xs₀›*) by (simp add: Suc_diff_le (*‹?n ≤ ?m ⟹ Suc ?m - ?n = Suc (?m - ?n)›*) drop_Cons_Suc (*‹drop ?n ?xs = ?y # ?ys ⟹ drop (Suc ?n) ?xs = ?ys›*)) qed (simp) (*solved the remaining goal: ‹⟦xs = a # list; Suc (length xs₀) ≤ length xs; drop (length xs - Suc (length xs₀)) xs = x # xs₀; length list - length xs₀ = 0⟧ ⟹ drop (length xs - length xs₀) xs = xs₀›*) qed (simp) (*solved the remaining goal: ‹⟦Suc (length xs₀) ≤ length xs; drop (length xs - Suc (length xs₀)) xs = x # xs₀; xs = []⟧ ⟹ drop (length xs - length xs₀) xs = xs₀›*) (*<*) declare (in TC0) after_def[simp] pair_eq_ty⇩i'_conv[simp] (*>*) lemma (in TC1) compT_ST_prefix: "⋀E A ST₀. ⌊(ST,LT)⌋ ∈ set(compT E A ST₀ e) ⟹ size ST₀ ≤ size ST ∧ drop (size ST - size ST₀) ST = ST₀" and "⋀E A ST₀. ⌊(ST,LT)⌋ ∈ set(compTs E A ST₀ es) ⟹ size ST₀ ≤ size ST ∧ drop (size ST - size ST₀) ST = ST₀" (*<*) proof (induct e and es rule: compT.induct compTs.induct) (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3})⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 17. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 18. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 19. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 20. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 21. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 22. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case (FAss e₁ F D e₂) (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e₁) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (e₂::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (e₁∙F{D} := e₂))›*) moreover { let ?ST₀ = "ty E e₁ # ST₀" fix A assume "⌊(ST, LT)⌋ ∈ set (compT E A ?ST₀ e₂)" (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ty E (e₁::nat exp) # (ST₀::ty list)) (e₂::nat exp))›*) with FAss (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e₁) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (e₂::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A__::nat set option) (ST₀::ty list) ((e₁::nat exp)∙(F::char list){(D::char list)} := (e₂::nat exp)))›*) have "length ?ST₀ ≤ length ST ∧ drop (size ST - size ?ST₀) ST = ?ST₀" by blast hence "?case" by (clarsimp simp add: drop_mess (*‹⟦Suc (length ?xs₀) ≤ length ?xs; drop (length ?xs - Suc (length ?xs₀)) ?xs = ?x # ?xs₀⟧ ⟹ drop (length ?xs - length ?xs₀) ?xs = ?xs₀›*)) } ultimately show "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3})⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 17. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1 catch(x2 x3) x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 18. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 19. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 20. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 21. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case TryCatch (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x4_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (try x1_ catch(x2_ x3_) x4_))›*) thus "?case" (*goal: ‹length (ST₀::ty list) ≤ length (ST::ty list) ∧ drop (length ST - length ST₀) ST = ST₀›*) apply - (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by ((msorry)[1]) next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1:x2; x3})⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 17. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 18. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 19. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 20. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Block (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x3_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ {x1_:x2_; x3_})›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1;; x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 17. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 18. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 19. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Seq (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x1_::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_;; x2_))›*) thus "?case" (*goal: ‹length (ST₀::ty list) ≤ length (ST::ty list) ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1) x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 17. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 18. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case While (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x1_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (while (x1_) x2_))›*) thus "?case" (*goal: ‹length (ST₀::ty list) ≤ length (ST::ty list) ∧ drop (length ST - length ST₀) ST = ST₀›*) apply - (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by (msorry) next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (if (x1) x2 else x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 17. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Cond (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x1_::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x3_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ST₀::ty list) (if ((x1_::nat exp)) (x2_::nat exp) else (x3_::nat exp)))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by (msorry) next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 16. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case (Call e M es) (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 es) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (e∙M(es)))›*) moreover { let ?ST₀ = "ty E e # ST₀" fix A assume "⌊(ST, LT)⌋ ∈ set (compTs E A ?ST₀ es)" (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs (E::ty list) (A::nat set option) (ty E (e::nat exp) # (ST₀::ty list)) (es::nat exp list))›*) with Call (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 es) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A__ ST₀ (e∙M(es)))›*) have "length ?ST₀ ≤ length ST ∧ drop (size ST - size ?ST₀) ST = ?ST₀" by blast hence "?case" by (clarsimp simp add: drop_mess (*‹⟦Suc (length ?xs₀) ≤ length ?xs; drop (length ?xs - Suc (length ?xs₀)) ?xs = ?x # ?xs₀⟧ ⟹ drop (length ?xs - length ?xs₀) ?xs = ?xs₀›*)) } ultimately show "?case" (*goal: ‹length (ST₀::ty list) ≤ length (ST::ty list) ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀(x::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀(x1::char list) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀(x::val) (E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀(x1::nat exp) (x2::bop) (x3::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀(x::nat) (E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀(x1::nat) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀(x1::char list) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀(x1::char list) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀(x::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 15. ‹⋀(x1::nat exp) (x2::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (x1 # x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case (Cons_exp e es) (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (e::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 es) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ (e # es))›*) moreover { let ?ST₀ = "ty E e # ST₀" fix A assume "⌊(ST, LT)⌋ ∈ set (compTs E A ?ST₀ es)" (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs (E::ty list) (A::nat set option) (ty E (e::nat exp) # (ST₀::ty list)) (es::nat exp list))›*) with Cons_exp (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 es) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compTs E A__ ST₀ (e # es))›*) have "length ?ST₀ ≤ length ST ∧ drop (size ST - size ?ST₀) ST = ?ST₀" by blast hence "?case" by (clarsimp simp add: drop_mess (*‹⟦Suc (length (?xs₀::?'a list)) ≤ length (?xs::?'a list); drop (length ?xs - Suc (length ?xs₀)) ?xs = (?x::?'a) # ?xs₀⟧ ⟹ drop (length ?xs - length ?xs₀) ?xs = ?xs₀›*)) } ultimately show "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1 «x2» x3))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 14. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case (BinOp e₁ bop e₂) (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (e₁::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e₂) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (e₁ «bop» e₂))›*) moreover { let ?ST₀ = "ty E e₁ # ST₀" fix A assume "⌊(ST, LT)⌋ ∈ set (compT E A ?ST₀ e₂)" (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ty E (e₁::nat exp) # (ST₀::ty list)) (e₂::nat exp))›*) with BinOp (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e₁) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 e₂) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A__ ST₀ (e₁ «bop» e₂))›*) have "length ?ST₀ ≤ length ST ∧ drop (size ST - size ?ST₀) ST = ?ST₀" by blast hence "?case" by (clarsimp simp add: drop_mess (*‹⟦Suc (length ?xs₀) ≤ length ?xs; drop (length ?xs - Suc (length ?xs₀)) ?xs = ?x # ?xs₀⟧ ⟹ drop (length ?xs - length ?xs₀) ?xs = ?xs₀›*)) } ultimately show "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (new x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 13. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case new (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ST₀::ty list) (new (x_::char list)))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 12. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Val (*‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Val x_))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀(x1::char list) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1 x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀(x::nat) (E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀(x1::nat) (x2::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀(x1::nat exp) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀(x1::char list) (x2::char list) (x3::char list) (E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀(x1::char list) (x2::char list) (x3::char list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀(x1::char list) (x2::char list) (x3::nat exp list) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀(x::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀(x1::char list) (x2::char list list) (x3::bool) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 11. ‹⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Cast (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Cast x1_ x2_))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x)) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 10. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Var (*‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (Var x_))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1:=x2))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 9. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case LAss (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_:=x2_))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (throw x))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 8. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case throw (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x_::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ST₀::ty list) (throw (x_::nat exp)))›*) thus "?case" (*goal: ‹length (ST₀::ty list) ≤ length (ST::ty list) ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x1) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙x2{x3}))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 7. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case FAcc (*‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (?E2::ty list) (?A2::nat set option) (?ST₀2::ty list) (x1_::nat exp)) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_∙x2_{x3_}))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3})) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 6. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case SFAcc (*‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_∙⇩sx2_{x3_}))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2{x3} := x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 5. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case SFAss (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x4_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1_∙⇩sx2_{x3_} := x4_))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ x3) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (x1∙⇩sx2(x3)))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 4. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case (SCall C M es) (*‹⌊(ST, LT)⌋ ∈ set (compTs ?E2 ?A2 ?ST₀2 es) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (C∙⇩sM(es)))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1 (x2,x3) ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀x1 x2 x3 x4 E A ST₀. ⟦⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 3. ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case INIT (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x4_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (INIT x1_ (x2_,x3_) ← x4_))›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goals: 1. ‹⋀(x1::char list) (x2::nat exp) (x3::char list list) (x4::nat exp) (E::ty list) (A::nat set option) ST₀::ty list. ⟦⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT E A ST₀ x2) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ x4) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀; ⌊(ST, LT)⌋ ∈ set (compT E A ST₀ (RI (x1,x2) ; x3 ← x4))⟧ ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀› 2. ‹⋀(E::ty list) (A::nat set option) ST₀::ty list. ⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case RI (*‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x2_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST, LT)⌋ ∈ set (compT ?E2 ?A2 ?ST₀2 x4_) ⟹ length ?ST₀2 ≤ length ST ∧ drop (length ST - length ?ST₀2) ST = ?ST₀2› ‹⌊(ST::ty list, LT::ty err list)⌋ ∈ set (compT (E::ty list) (A::nat set option) (ST₀::ty list) (RI ((x1_::char list),(x2_::nat exp)) ; (x3_::char list list) ← (x4_::nat exp)))›*) thus "?case" (*goal: ‹length (ST₀::ty list) ≤ length (ST::ty list) ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto next (*goal: ‹⋀E A ST₀. ⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ []) ⟹ length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) case Nil_exp (*‹⌊(ST, LT)⌋ ∈ set (compTs E A ST₀ [])›*) thus "?case" (*goal: ‹length ST₀ ≤ length ST ∧ drop (length ST - length ST₀) ST = ST₀›*) by auto qed declare (in TC0) after_def[simp del] pair_eq_ty⇩i'_conv[simp del] (*>*) (* FIXME *) lemma fun_of_simp [simp]: "fun_of S x y = ((x,y) ∈ S)" (*<*) by (simp add: fun_of_def (*‹fun_of (?S::(?'a × ?'b) set) ≡ λ(x::?'a) y::?'b. (x, y) ∈ ?S›*))(*>*) theorem (in TC2) compT_wt_instrs: "⋀E T A ST. ⟦ P,E ⊢₁ e :: T; 𝒟 e A; ℬ e (size E); size ST + max_stack e ≤ mxs; size E + max_vars e ≤ mxl ⟧ ⟹ ⊢ compE₂ e, compxE₂ e 0 (size ST) [::] ty⇩i' ST E A # compT E A ST e @ [after E A ST e]" (*<*)(is "⋀E T A ST. PROP ?P e E T A ST")(*>*) and "⋀E Ts A ST. ⟦ P,E ⊢₁ es[::]Ts; 𝒟s es A; ℬs es (size E); size ST + max_stacks es ≤ mxs; size E + max_varss es ≤ mxl ⟧ ⟹ let τs = ty⇩i' ST E A # compTs E A ST es in ⊢ compEs₂ es,compxEs₂ es 0 (size ST) [::] τs ∧ last τs = ty⇩i' (rev Ts @ ST) E (A ⊔ 𝒜s es)" (*<*) (is "⋀E Ts A ST. PROP ?Ps es E Ts A ST") proof(induct e and es rule: compxE₂.induct compxEs₂.induct) case (TryCatch e₁ C i e₂) hence [simp]: "i = size E" by simp have wt₁: "P,E ⊢₁ e₁ :: T" and wt₂: "P,E@[Class C] ⊢₁ e₂ :: T" and "class": "is_class P C" using TryCatch by auto let ?A₁ = "A ⊔ 𝒜 e₁" let ?A⇩i = "A ⊔ ⌊{i}⌋" let ?E⇩i = "E @ [Class C]" let ?τ = "ty⇩i' ST E A" let ?τs₁ = "compT E A ST e₁" let ?τ₁ = "ty⇩i' (T#ST) E ?A₁" let ?τ₂ = "ty⇩i' (Class C#ST) E A" let ?τ₃ = "ty⇩i' ST ?E⇩i ?A⇩i" let ?τs₂ = "compT ?E⇩i ?A⇩i ST e₂" let ?τ₂' = "ty⇩i' (T#ST) ?E⇩i (?A⇩i ⊔ 𝒜 e₂)" let ?τ' = "ty⇩i' (T#ST) E (A ⊔ 𝒜 e₁ ⊓ (𝒜 e₂ ⊖ i))" let ?go = "Goto (int(size(compE₂ e₂)) + 2)" have "PROP ?P e₂ ?E⇩i T ?A⇩i ST" by fact hence "⊢ compE₂ e₂,compxE₂ e₂ 0 (size ST) [::] (?τ₃ # ?τs₂) @ [?τ₂']" using TryCatch.prems by(auto simp:after_def) also have "?A⇩i ⊔ 𝒜 e₂ = (A ⊔ 𝒜 e₂) ⊔ ⌊{size E}⌋" by(fastforce simp:hyperset_defs) also have "P ⊢ ty⇩i' (T#ST) ?E⇩i … ≤' ty⇩i' (T#ST) E (A ⊔ 𝒜 e₂)" by(simp add:hyperset_defs ty⇩l_incr ty⇩i'_def) also have "P ⊢ … ≤' ty⇩i' (T#ST) E (A ⊔ 𝒜 e₁ ⊓ (𝒜 e₂ ⊖ i))" by(auto intro!: ty⇩l_antimono simp:hyperset_defs ty⇩i'_def) also have "(?τ₃ # ?τs₂) @ [?τ'] = ?τ₃ # ?τs₂ @ [?τ']" by simp also have "⊢ [Store i],[] [::] ?τ₂ # [] @ [?τ₃]" using TryCatch.prems by(auto simp:nth_list_update wt_defs ty⇩i'_def ty⇩l_def list_all2_conv_all_nth hyperset_defs) also have "[] @ (?τ₃ # ?τs₂ @ [?τ']) = (?τ₃ # ?τs₂ @ [?τ'])" by simp also have "P,T⇩r,mxs,size(compE₂ e₂)+3,[] ⊢ ?go,0 :: ?τ₁#?τ₂#?τ₃#?τs₂ @ [?τ']" using wt₂ by (auto simp: hyperset_defs ty⇩i'_def wt_defs nth_Cons nat_add_distrib fun_of_def intro: ty⇩l_antimono list_all2_refl split:nat.split) also have "⊢ compE₂ e₁,compxE₂ e₁ 0 (size ST) [::] ?τ # ?τs₁ @ [?τ₁]" using TryCatch by(auto simp:after_def) also have "?τ # ?τs₁ @ ?τ₁ # ?τ₂ # ?τ₃ # ?τs₂ @ [?τ'] = (?τ # ?τs₁ @ [?τ₁]) @ ?τ₂ # ?τ₃ # ?τs₂ @ [?τ']" by simp also have "compE₂ e₁ @ ?go # [Store i] @ compE₂ e₂ = (compE₂ e₁ @ [?go]) @ (Store i # compE₂ e₂)" by simp also let "?Q τ" = "∀ST' LT'. τ = ⌊(ST', LT')⌋ ⟶ size ST ≤ size ST' ∧ P ⊢ Some (drop (size ST' - size ST) ST',LT') ≤' ty⇩i' ST E A" { have "?Q (ty⇩i' ST E A)" by (clarsimp simp add: ty⇩i'_def) moreover have "?Q (ty⇩i' (T # ST) E ?A₁)" by (fastforce simp add: ty⇩i'_def hyperset_defs intro!: ty⇩l_antimono) moreover have "⋀τ. τ ∈ set (compT E A ST e₁) ⟹ ?Q τ" using TryCatch.prems by clarsimp (frule compT_ST_prefix, fastforce dest!: compT_LT_prefix simp add: ty⇩i'_def) ultimately have "∀τ∈set (ty⇩i' ST E A # compT E A ST e₁ @ [ty⇩i' (T # ST) E ?A₁]). ?Q τ" by auto } also from TryCatch.prems max_stack1[OF wt₁] have "size ST + 1 ≤ mxs" by auto ultimately show ?case using wt₁ wt₂ TryCatch.prems "class" by (simp add:after_def) next case new thus ?case by(auto simp add:after_def wt_New) next case (BinOp e₁ bop e₂) let ?op = "case bop of Eq ⇒ [CmpEq] | Add ⇒ [IAdd]" have T: "P,E ⊢₁ e₁ «bop» e₂ :: T" by fact then obtain T₁ T₂ where T₁: "P,E ⊢₁ e₁ :: T₁" and T₂: "P,E ⊢₁ e₂ :: T₂" and bopT: "case bop of Eq ⇒ (P ⊢ T₁ ≤ T₂ ∨ P ⊢ T₂ ≤ T₁) ∧ T = Boolean | Add ⇒ T₁ = Integer ∧ T₂ = Integer ∧ T = Integer" by auto let ?A₁ = "A ⊔ 𝒜 e₁" let ?A₂ = "?A₁ ⊔ 𝒜 e₂" let ?τ = "ty⇩i' ST E A" let ?τs₁ = "compT E A ST e₁" let ?τ₁ = "ty⇩i' (T₁#ST) E ?A₁" let ?τs₂ = "compT E ?A₁ (T₁#ST) e₂" let ?τ₂ = "ty⇩i' (T₂#T₁#ST) E ?A₂" let ?τ' = "ty⇩i' (T#ST) E ?A₂" from bopT have "⊢ ?op,[] [::] [?τ₂,?τ']" by (cases bop) (auto simp add: wt_CmpEq wt_IAdd) also have "PROP ?P e₂ E T₂ ?A₁ (T₁#ST)" by fact with BinOp.prems T₂ have "⊢ compE₂ e₂, compxE₂ e₂ 0 (size (T₁#ST)) [::] ?τ₁#?τs₂@[?τ₂]" by (auto simp: after_def) also from BinOp T₁ have "⊢ compE₂ e₁, compxE₂ e₁ 0 (size ST) [::] ?τ#?τs₁@[?τ₁]" by (auto simp: after_def) finally show ?case using T T₁ T₂ by (simp add: after_def hyperUn_assoc) next case (Cons_exp e es) have "P,E ⊢₁ e # es [::] Ts" by fact then obtain T⇩e Ts' where T⇩e: "P,E ⊢₁ e :: T⇩e" and Ts': "P,E ⊢₁ es [::] Ts'" and Ts: "Ts = T⇩e#Ts'" by auto let ?A⇩e = "A ⊔ 𝒜 e" let ?τ = "ty⇩i' ST E A" let ?τs⇩e = "compT E A ST e" let ?τ⇩e = "ty⇩i' (T⇩e#ST) E ?A⇩e" let ?τs' = "compTs E ?A⇩e (T⇩e#ST) es" let ?τs = "?τ # ?τs⇩e @ (?τ⇩e # ?τs')" have Ps: "PROP ?Ps es E Ts' ?A⇩e (T⇩e#ST)" by fact with Cons_exp.prems T⇩e Ts' have "⊢ compEs₂ es, compxEs₂ es 0 (size (T⇩e#ST)) [::] ?τ⇩e#?τs'" by (simp add: after_def) also from Cons_exp T⇩e have "⊢ compE₂ e, compxE₂ e 0 (size ST) [::] ?τ#?τs⇩e@[?τ⇩e]" by (auto simp: after_def) moreover from Ps Cons_exp.prems T⇩e Ts' Ts have "last ?τs = ty⇩i' (rev Ts@ST) E (?A⇩e ⊔ 𝒜s es)" by simp ultimately show ?case using T⇩e by (simp add: after_def hyperUn_assoc) next case (FAss e₁ F D e₂) hence Void: "P,E ⊢₁ e₁∙F{D} := e₂ :: Void" by auto then obtain C T T' where C: "P,E ⊢₁ e₁ :: Class C" and sees: "P ⊢ C sees F,NonStatic:T in D" and T': "P,E ⊢₁ e₂ :: T'" and T'_T: "P ⊢ T' ≤ T" by auto let ?A₁ = "A ⊔ 𝒜 e₁" let ?A₂ = "?A₁ ⊔ 𝒜 e₂" let ?τ = "ty⇩i' ST E A" let ?τs₁ = "compT E A ST e₁" let ?τ₁ = "ty⇩i' (Class C#ST) E ?A₁" let ?τs₂ = "compT E ?A₁ (Class C#ST) e₂" let ?τ₂ = "ty⇩i' (T'#Class C#ST) E ?A₂" let ?τ₃ = "ty⇩i' ST E ?A₂" let ?τ' = "ty⇩i' (Void#ST) E ?A₂" from FAss.prems sees T'_T have "⊢ [Putfield F D,Push Unit],[] [::] [?τ₂,?τ₃,?τ']" by (fastforce simp add: wt_Push wt_Put) also have "PROP ?P e₂ E T' ?A₁ (Class C#ST)" by fact with FAss.prems T' have "⊢ compE₂ e₂, compxE₂ e₂ 0 (size ST+1) [::] ?τ₁#?τs₂@[?τ₂]" by (auto simp add: after_def hyperUn_assoc) also from FAss C have "⊢ compE₂ e₁, compxE₂ e₁ 0 (size ST) [::] ?τ#?τs₁@[?τ₁]" by (auto simp add: after_def) finally show ?case using Void C T' by (simp add: after_def hyperUn_assoc) next case (SFAss C F D e₂) hence Void: "P,E ⊢₁ C∙⇩sF{D} := e₂ :: Void" by auto then obtain T T' where sees: "P ⊢ C sees F,Static:T in D" and T': "P,E ⊢₁ e₂ :: T'" and T'_T: "P ⊢ T' ≤ T" by auto let ?A₂ = "A ⊔ 𝒜 e₂" let ?τ = "ty⇩i' ST E A" let ?τs₂ = "compT E A ST e₂" let ?τ₂ = "ty⇩i' (T'#ST) E ?A₂" let ?τ₃ = "ty⇩i' ST E ?A₂" let ?τ' = "ty⇩i' (Void#ST) E ?A₂" from SFAss.prems sees T'_T max_stack1[OF T'] have "⊢ [Putstatic C F D,Push Unit],[] [::] [?τ₂,?τ₃,?τ']" by (fastforce simp add: wt_Push wt_PutS) also have "PROP ?P e₂ E T' A ST" by fact with SFAss.prems T' have "⊢ compE₂ e₂, compxE₂ e₂ 0 (size ST) [::] ?τ#?τs₂@[?τ₂]" by (auto simp add: after_def hyperUn_assoc) finally show ?case using Void T' by (simp add: after_def hyperUn_assoc) next case Val thus ?case by(auto simp:after_def wt_Push) next case Cast thus ?case by (auto simp:after_def wt_Cast) next case (Block i T⇩i e) let ?τs = "ty⇩i' ST E A # compT (E @ [T⇩i]) (A⊖i) ST e" have IH: "PROP ?P e (E@[T⇩i]) T (A⊖i) ST" by fact hence "⊢ compE₂ e, compxE₂ e 0 (size ST) [::] ?τs @ [ty⇩i' (T#ST) (E@[T⇩i]) (A⊖(size E) ⊔ 𝒜 e)]" using Block.prems by (auto simp add: after_def) also have "P ⊢ ty⇩i' (T # ST) (E@[T⇩i]) (A ⊖ size E ⊔ 𝒜 e) ≤' ty⇩i' (T # ST) (E@[T⇩i]) ((A ⊔ 𝒜 e) ⊖ size E)" by(auto simp add:hyperset_defs intro: ty⇩i'_antimono) also have "… = ty⇩i' (T # ST) E (A ⊔ 𝒜 e)" by simp also have "P ⊢ … ≤' ty⇩i' (T # ST) E (A ⊔ (𝒜 e ⊖ i))" by(auto simp add:hyperset_defs intro: ty⇩i'_antimono) finally show ?case using Block.prems by(simp add: after_def) next case Var thus ?case by(auto simp:after_def wt_Load) next case FAcc thus ?case by(auto simp:after_def wt_Get) next case SFAcc thus ?case by(auto simp: after_def wt_GetS) next case (LAss i e) then obtain T' where wt: "P,E ⊢₁ e :: T'" by auto show ?case using max_stack1[OF wt] LAss by(auto simp: hyper_insert_comm after_def wt_Store wt_Push) next case Nil_exp thus ?case by auto next case throw thus ?case by(auto simp add: after_def wt_Throw) next case (While e c) obtain Tc where wte: "P,E ⊢₁ e :: Boolean" and wtc: "P,E ⊢₁ c :: Tc" and [simp]: "T = Void" using While by auto have [simp]: "ty E (while (e) c) = Void" using While by simp let ?A₀ = "A ⊔ 𝒜 e" let ?A₁ = "?A₀ ⊔ 𝒜 c" let ?τ = "ty⇩i' ST E A" let ?τs⇩e = "compT E A ST e" let ?τ⇩e = "ty⇩i' (Boolean#ST) E ?A₀" let ?τ₁ = "ty⇩i' ST E ?A₀" let ?τs⇩c = "compT E ?A₀ ST c" let ?τ⇩c = "ty⇩i' (Tc#ST) E ?A₁" let ?τ₂ = "ty⇩i' ST E ?A₁" let ?τ' = "ty⇩i' (Void#ST) E ?A₀" let ?τs = "(?τ # ?τs⇩e @ [?τ⇩e]) @ ?τ₁ # ?τs⇩c @ [?τ⇩c, ?τ₂, ?τ₁, ?τ']" have "⊢ [],[] [::] [] @ ?τs" by(simp add:wt_instrs_def) also have "PROP ?P e E Boolean A ST" by fact hence "⊢ compE₂ e,compxE₂ e 0 (size ST) [::] ?τ # ?τs⇩e @ [?τ⇩e]" using While.prems by (auto simp:after_def) also have "[] @ ?τs = (?τ # ?τs⇩e) @ ?τ⇩e # ?τ₁ # ?τs⇩c @ [?τ⇩c,?τ₂,?τ₁,?τ']" by simp also let ?n⇩e = "size(compE₂ e)" let ?n⇩c = "size(compE₂ c)" thm compT_sizes(1) let ?if = "IfFalse (int ?n⇩c + 3)" from wtc wte have "compE₂ c ≠ []" and "compE₂ e ≠ []" using WT₁_nsub_RI by auto then have compe2c: "length (compE₂ c) > 0" and compe2e: "length (compE₂ e) > 0" by auto have Suc_pred'_auxi: "⋀n. 0 < n ⟹ n = Suc (n - Suc 0)" using Suc_pred'[OF compe2c] by auto have "⊢ [?if],[] [::] ?τ⇩e # ?τ₁ # ?τs⇩c @ [?τ⇩c, ?τ₂, ?τ₁, ?τ']" proof-{ show ?thesis apply (rule wt_IfFalse) apply simp apply simp apply (subgoal_tac "length (compE₂ c) = length (compT E (A ⊔ 𝒜 e) ST c) + 1" "nat (int (length (compE₂ c)) + 3 - 2) > length (compT E (A ⊔ 𝒜 e) ST c)") apply (insert Suc_pred'_auxi[OF compe2c]) apply (simp add:compT_sizes(1)[OF wtc] )+ done } qed also have "(?τ # ?τs⇩e) @ (?τ⇩e # ?τ₁ # ?τs⇩c @ [?τ⇩c, ?τ₂, ?τ₁, ?τ']) = ?τs" by simp also have "PROP ?P c E Tc ?A₀ ST" by fact hence "⊢ compE₂ c,compxE₂ c 0 (size ST) [::] ?τ₁ # ?τs⇩c @ [?τ⇩c]" using While.prems wtc by (auto simp:after_def) also have "?τs = (?τ # ?τs⇩e @ [?τ⇩e,?τ₁] @ ?τs⇩c) @ [?τ⇩c,?τ₂,?τ₁,?τ']" by simp also have "⊢ [Pop],[] [::] [?τ⇩c, ?τ₂]" by(simp add:wt_Pop) also have "(?τ # ?τs⇩e @ [?τ⇩e,?τ₁] @ ?τs⇩c) @ [?τ⇩c,?τ₂,?τ₁,?τ'] = ?τs" by simp also let ?go = "Goto (-int(?n⇩c+?n⇩e+2))" have "P ⊢ ?τ₂ ≤' ?τ" by(fastforce intro: ty⇩i'_antimono simp: hyperset_defs) hence "P,T⇩r,mxs,size ?τs,[] ⊢ ?go,?n⇩e+?n⇩c+2 :: ?τs" using wte wtc proof-{ let ?t1 = "ty⇩i' ST E A" let ?t2 = "ty⇩i' (Boolean # ST) E (A ⊔ 𝒜 e)" let ?t3 = "ty⇩i' ST E (A ⊔ 𝒜 e)" let ?t4 = "[ty⇩i' (Tc # ST) E (A ⊔ 𝒜 e ⊔ 𝒜 c), ty⇩i' ST E (A ⊔ 𝒜 e ⊔ 𝒜 c), ty⇩i' ST E (A ⊔ 𝒜 e), ty⇩i' (Void # ST) E (A ⊔ 𝒜 e)]" let ?c = " compT E (A ⊔ 𝒜 e) ST c" let ?e = "compT E A ST e" assume ass: "P ⊢ ty⇩i' ST E (A ⊔ 𝒜 e ⊔ 𝒜 c) ≤' ?t1" show ?thesis apply (rule wt_Goto) apply simp apply simp apply simp proof-{ let ?s1 = "((?t1 # ?e @ [?t2]) @ ?t3 # ?c)" have len1: "length ?c = length (compE₂ c) - 1" using compT_sizes(1)[OF wtc] by simp have len2: "length ?e = length (compE₂ e) - 1" using compT_sizes(1)[OF wte] by simp hence "length (compE₂ e) + length (compE₂ c) + 2 > length ?s1" using len1 compe2c compe2e by auto hence "(?s1 @ ?t4) ! (length (compE₂ e) + length (compE₂ c) + 2) = ?t4 ! (length (compE₂ e) + length (compE₂ c) + 2 - length ?s1)" by (auto simp only:nth_append split: if_splits) hence "(?s1 @ ?t4) ! (length (compE₂ e) + length (compE₂ c) + 2) = ty⇩i' ST E (A ⊔ 𝒜 e ⊔ 𝒜 c)" using len1 len2 compe2c compe2e by auto hence "P ⊢ (?s1 @ ?t4) ! (length (compE₂ e) + length (compE₂ c) + 2) ≤' ty⇩i' ST E A" using ass by simp thus "P ⊢ ((?t1 # ?e @ [?t2]) @ ?t3 # ?c @ ?t4) ! (length (compE₂ e) + length (compE₂ c) + 2) ≤' ((?t1 # ?e @ [?t2]) @ ?t3 # ?c @ ?t4) ! nat (int (length (compE₂ e) + length (compE₂ c) + 2) + - int (length (compE₂ c) + length (compE₂ e) + 2))" by simp }qed }qed also have "?τs = (?τ # ?τs⇩e @ [?τ⇩e,?τ₁] @ ?τs⇩c @ [?τ⇩c, ?τ₂]) @ [?τ₁, ?τ']" by simp also have "⊢ [Push Unit],[] [::] [?τ₁,?τ']" using While.prems max_stack1[OF wtc] by(auto simp add:wt_Push) finally show ?case using wtc wte by (simp add:after_def) next case (Cond e e₁ e₂) obtain T₁ T₂ where wte: "P,E ⊢₁ e :: Boolean" and wt₁: "P,E ⊢₁ e₁ :: T₁" and wt₂: "P,E ⊢₁ e₂ :: T₂" and sub₁: "P ⊢ T₁ ≤ T" and sub₂: "P ⊢ T₂ ≤ T" using Cond by auto from wte wt₁ wt₂ have "compE₂ e₁ ≠ []" and "compE₂ e₂ ≠ []" and "compE₂ e ≠ []" using WT₁_nsub_RI by auto then have compe: "length (compE₂ e) > 0" and compe1: "length (compE₂ e₁) > 0" and compe2: "length (compE₂ e₂) > 0" by auto have [simp]: "ty E (if (e) e₁ else e₂) = T" using Cond by simp let ?A₀ = "A ⊔ 𝒜 e" let ?A₂ = "?A₀ ⊔ 𝒜 e₂" let ?A₁ = "?A₀ ⊔ 𝒜 e₁" let ?A' = "?A₀ ⊔ 𝒜 e₁ ⊓ 𝒜 e₂" let ?τ₂ = "ty⇩i' ST E ?A₀" let ?τ' = "ty⇩i' (T#ST) E ?A'" let ?τs₂ = "compT E ?A₀ ST e₂" have "PROP ?P e₂ E T₂ ?A₀ ST" by fact hence "⊢ compE₂ e₂, compxE₂ e₂ 0 (size ST) [::] (?τ₂#?τs₂) @ [ty⇩i' (T₂#ST) E ?A₂]" using Cond.prems wt₂ by(auto simp add:after_def) also have "P ⊢ ty⇩i' (T₂#ST) E ?A₂ ≤' ?τ'" using sub₂ by(auto simp add: hyperset_defs ty⇩i'_def intro!: ty⇩l_antimono) also let ?τ₃ = "ty⇩i' (T₁ # ST) E ?A₁" let ?g₂ = "Goto(int (size (compE₂ e₂) + 1))" from sub₁ have "P,T⇩r,mxs,size(compE₂ e₂)+2,[] ⊢ ?g₂,0 :: ?τ₃#(?τ₂#?τs₂)@[?τ']" using wt₂ by(auto simp: hyperset_defs wt_defs nth_Cons ty⇩i'_def split:nat.split intro!: ty⇩l_antimono) also let ?τs₁ = "compT E ?A₀ ST e₁" have "PROP ?P e₁ E T₁ ?A₀ ST" by fact hence "⊢ compE₂ e₁,compxE₂ e₁ 0 (size ST) [::] ?τ₂ # ?τs₁ @ [?τ₃]" using Cond.prems wt₁ by(auto simp add:after_def) also let ?τs₁₂ = "?τ₂ # ?τs₁ @ ?τ₃ # (?τ₂ # ?τs₂) @ [?τ']" let ?τ₁ = "ty⇩i' (Boolean#ST) E ?A₀" let ?g₁ = "IfFalse(int (size (compE₂ e₁) + 2))" let ?code = "compE₂ e₁ @ ?g₂ # compE₂ e₂" have len1: "length ?τs₁ = length (compE₂ e₁) - 1" using compT_sizes(1)[OF wt₁] by simp have len2: "length ?τs₂ = length (compE₂ e₂) - 1" using compT_sizes(1)[OF wt₂] by simp have len_auxi: "length (compE₂ e₁) - (length (compE₂ e₁) - Suc 0) = Suc 0" using compe1 by (simp add:diff_Suc split:nat.split) have "⊢ [?g₁],[] [::] [?τ₁] @ ?τs₁₂" proof-{ show ?thesis apply clarsimp apply (rule wt_IfFalse) apply (simp only:nat_add_distrib) apply simp apply (auto simp only:nth_append split:if_splits) apply (simp add:len1) apply (simp only: len1 compe1) apply (simp add:len1 len2 compe1 compe2 ) apply (insert len_auxi) apply simp done }qed also (wt_instrs_ext2) have "[?τ₁] @ ?τs₁₂ = ?τ₁ # ?τs₁₂" by simp also let ?τ = "ty⇩i' ST E A" have "PROP ?P e E Boolean A ST" by fact hence "⊢ compE₂ e, compxE₂ e 0 (size ST) [::] ?τ # compT E A ST e @ [?τ₁]" using Cond.prems wte by(auto simp add:after_def) finally show ?case using wte wt₁ wt₂ by(simp add:after_def hyperUn_assoc) next case (Call e M es) obtain C D Ts m Ts' where C: "P,E ⊢₁ e :: Class C" and "method": "P ⊢ C sees M,NonStatic:Ts → T = m in D" and wtes: "P,E ⊢₁ es [::] Ts'" and subs: "P ⊢ Ts' [≤] Ts" using Call.prems by auto from wtes have same_size: "size es = size Ts'" by(rule WTs₁_same_size) let ?A₀ = "A ⊔ 𝒜 e" let ?A₁ = "?A₀ ⊔ 𝒜s es" let ?τ = "ty⇩i' ST E A" let ?τs⇩e = "compT E A ST e" let ?τ⇩e = "ty⇩i' (Class C # ST) E ?A₀" let ?τs⇩e⇩s = "compTs E ?A₀ (Class C # ST) es" let ?τ₁ = "ty⇩i' (rev Ts' @ Class C # ST) E ?A₁" let ?τ' = "ty⇩i' (T # ST) E ?A₁" have "⊢ [Invoke M (size es)],[] [::] [?τ₁,?τ']" by(rule wt_Invoke[OF same_size "method" subs]) also have "PROP ?Ps es E Ts' ?A₀ (Class C # ST)" by fact hence "⊢ compEs₂ es,compxEs₂ es 0 (size ST+1) [::] ?τ⇩e # ?τs⇩e⇩s" "last (?τ⇩e # ?τs⇩e⇩s) = ?τ₁" using Call.prems wtes by(auto simp add:after_def) also have "(?τ⇩e # ?τs⇩e⇩s) @ [?τ'] = ?τ⇩e # ?τs⇩e⇩s @ [?τ']" by simp also have "⊢ compE₂ e,compxE₂ e 0 (size ST) [::] ?τ # ?τs⇩e @ [?τ⇩e]" using Call C by(auto simp add:after_def) finally show ?case using Call.prems C wtes by(simp add:after_def hyperUn_assoc) next case (SCall C M es) obtain D Ts m Ts' where "method": "P ⊢ C sees M,Static:Ts → T = m in D" and wtes: "P,E ⊢₁ es [::] Ts'" and subs: "P ⊢ Ts' [≤] Ts" using SCall.prems by auto from SCall.prems(1) have nclinit: "M ≠ clinit" by auto from wtes have same_size: "size es = size Ts'" by(rule WTs₁_same_size) have mxs: "length ST < mxs" using WT₁_nsub_RI[OF SCall.prems(1)] SCall.prems(4) by simp let ?A₁ = "A ⊔ 𝒜s es" let ?τ = "ty⇩i' ST E A" let ?τs⇩e⇩s = "compTs E A ST es" let ?τ₁ = "ty⇩i' (rev Ts' @ ST) E ?A₁" let ?τ' = "ty⇩i' (T # ST) E ?A₁" have "⊢ [Invokestatic C M (size es)],[] [::] [?τ₁,?τ']" by(rule wt_Invokestatic[OF mxs same_size nclinit "method" subs]) also have "PROP ?Ps es E Ts' A ST" by fact hence "⊢ compEs₂ es,compxEs₂ es 0 (size ST) [::] ?τ # ?τs⇩e⇩s" "last (?τ # ?τs⇩e⇩s) = ?τ₁" using SCall.prems wtes by(auto simp add:after_def) also have "(?τ # ?τs⇩e⇩s) @ [?τ'] = ?τ # ?τs⇩e⇩s @ [?τ']" by simp finally show ?case using SCall.prems wtes by(simp add:after_def hyperUn_assoc) next case Seq thus ?case by(auto simp:after_def) (fastforce simp:wt_Push wt_Pop hyperUn_assoc intro:wt_instrs_app2 wt_instrs_Cons) next case (INIT C Cs b e) have "P,E ⊢₁ INIT C (Cs,b) ← e :: T" by fact thus ?case using WT₁_nsub_RI by simp next case (RI C e' Cs e) have "P,E ⊢₁ RI (C,e') ; Cs ← e :: T" by fact thus ?case using WT₁_nsub_RI by simp qed (*>*) lemma [simp]: "types (compP f P) = types P" (*<*)by auto(*>*) lemma [simp]: "states (compP f P) mxs mxl = states P mxs mxl" (*<*)by (simp add: JVM_states_unfold (*‹states ?P ?mxs ?mxl ≡ err (opt (⋃ {nlists n (types ?P) |n. n ≤ ?mxs} × nlists ?mxl (err (types ?P))))›*))(*>*) lemma [simp]: "app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)" (*<*)(is "?A = ?B") proof (-) (*goal: ‹app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)›*) obtain ST and LT where "τ": "τ = (ST, LT)" (*goal: ‹(⋀ST LT. τ = (ST, LT) ⟹ thesis) ⟹ thesis›*) apply (cases τ) (*goal: ‹(⋀ST LT. τ = (ST, LT) ⟹ thesis) ⟹ thesis›*) by simp then show "?thesis" (*goal: ‹app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)›*) proof (cases i) (*goals: 1. ‹⋀x1. ⟦τ = (ST, LT); i = Load x1⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 2. ‹⋀x2. ⟦τ = (ST, LT); i = Store x2⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 3. ‹⋀x3. ⟦τ = (ST, LT); i = Push x3⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 4. ‹⋀x4. ⟦τ = (ST, LT); i = New x4⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 5. ‹⋀x51 x52. ⟦τ = (ST, LT); i = Getfield x51 x52⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 6. ‹⋀x61 x62 x63. ⟦τ = (ST, LT); i = Getstatic x61 x62 x63⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 7. ‹⋀x71 x72. ⟦τ = (ST, LT); i = Putfield x71 x72⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 8. ‹⋀x81 x82 x83. ⟦τ = (ST, LT); i = Putstatic x81 x82 x83⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 9. ‹⋀x9. ⟦τ = (ST, LT); i = Checkcast x9⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 10. ‹⋀x101 x102. ⟦τ = (ST, LT); i = Invoke x101 x102⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 11. ‹⋀x111 x112 x113. ⟦τ = (ST, LT); i = Invokestatic x111 x112 x113⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 12. ‹⟦τ = (ST, LT); i = Return⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 13. ‹⟦τ = (ST, LT); i = Pop⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 14. ‹⟦τ = (ST, LT); i = IAdd⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 15. ‹⋀x15. ⟦τ = (ST, LT); i = Goto x15⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 16. ‹⟦τ = (ST, LT); i = CmpEq⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 17. ‹⋀x17. ⟦τ = (ST, LT); i = IfFalse x17⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 18. ‹⟦τ = (ST, LT); i = instr.Throw⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)›*) case Invoke (*‹i = Invoke x101_ x102_›*) show "?thesis" (*goal: ‹app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)›*) proof (rule iffI (*‹⟦?P::bool ⟹ ?Q::bool; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹app⇩i (i, compP f P, pc, mpc, T, τ) ⟹ app⇩i (i, P, pc, mpc, T, τ)› 2. ‹app⇩i (i, P, pc, mpc, T, τ) ⟹ app⇩i (i, compP f P, pc, mpc, T, τ)›*) assume "?A" (*‹app⇩i (i::instr, compP (f::staticb ⇒ 'b ⇒ 'a) (P::'b prog), pc::nat, mpc::nat, T::ty, τ::ty list × ty err list)›*) then show "?B" using Invoke (*‹i = Invoke x101_ x102_›*) "τ" (*‹τ = (ST, LT)›*) apply auto (*goal: ‹app⇩i (i, P, pc, mpc, T, τ)›*) by (fastforce dest!: sees_method_compPD (*‹compP ?f ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?fm in ?D ⟹ ∃m. ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = m in ?D ∧ ?f ?b m = ?fm›*)) next (*goal: ‹app⇩i (i::instr, P::'b prog, pc::nat, mpc::nat, T::ty, τ::ty list × ty err list) ⟹ app⇩i (i, compP (f::staticb ⇒ 'b ⇒ 'a) P, pc, mpc, T, τ)›*) assume "?B" (*‹app⇩i (i::instr, P::'b prog, pc::nat, mpc::nat, T::ty, τ::ty list × ty err list)›*) then show "?A" using Invoke (*‹i = Invoke x101_ x102_›*) "τ" (*‹(τ::ty list × ty err list) = (ST::ty list, LT::ty err list)›*) apply auto (*goal: ‹app⇩i (i, compP f P, pc, mpc, T, τ)›*) by (force dest: sees_method_compP (*‹?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?m in ?D ⟹ compP ?f ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?f ?b ?m in ?D›*)) qed next (*goals: 1. ‹⋀x1. ⟦τ = (ST, LT); i = Load x1⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 2. ‹⋀x2. ⟦τ = (ST, LT); i = Store x2⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 3. ‹⋀x3. ⟦τ = (ST, LT); i = Push x3⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 4. ‹⋀x4. ⟦τ = (ST, LT); i = New x4⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 5. ‹⋀x51 x52. ⟦τ = (ST, LT); i = Getfield x51 x52⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 6. ‹⋀x61 x62 x63. ⟦τ = (ST, LT); i = Getstatic x61 x62 x63⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 7. ‹⋀x71 x72. ⟦τ = (ST, LT); i = Putfield x71 x72⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 8. ‹⋀x81 x82 x83. ⟦τ = (ST, LT); i = Putstatic x81 x82 x83⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 9. ‹⋀x9. ⟦τ = (ST, LT); i = Checkcast x9⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 10. ‹⋀x111 x112 x113. ⟦τ = (ST, LT); i = Invokestatic x111 x112 x113⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 11. ‹⟦τ = (ST, LT); i = Return⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 12. ‹⟦τ = (ST, LT); i = Pop⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 13. ‹⟦τ = (ST, LT); i = IAdd⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 14. ‹⋀x15. ⟦τ = (ST, LT); i = Goto x15⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 15. ‹⟦τ = (ST, LT); i = CmpEq⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 16. ‹⋀x17. ⟦τ = (ST, LT); i = IfFalse x17⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 17. ‹⟦τ = (ST, LT); i = instr.Throw⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)›*) case (Invokestatic x111 x112 x113) (*‹i = Invokestatic x111 x112 x113›*) show "?thesis" (*goal: ‹app⇩i (i::instr, compP (f::staticb ⇒ 'b ⇒ 'a) (P::'b prog), pc::nat, mpc::nat, T::ty, τ::ty list × ty err list) = app⇩i (i, P, pc, mpc, T, τ)›*) proof (rule iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goals: 1. ‹app⇩i (i, compP f P, pc, mpc, T, τ) ⟹ app⇩i (i, P, pc, mpc, T, τ)› 2. ‹app⇩i (i, P, pc, mpc, T, τ) ⟹ app⇩i (i, compP f P, pc, mpc, T, τ)›*) assume "?A" (*‹app⇩i (i::instr, compP (f::staticb ⇒ 'b ⇒ 'a) (P::'b prog), pc::nat, mpc::nat, T::ty, τ::ty list × ty err list)›*) then show "?B" using Invokestatic (*‹i = Invokestatic x111 x112 x113›*) "τ" (*‹τ = (ST, LT)›*) apply auto (*goal: ‹app⇩i (i, P, pc, mpc, T, τ)›*) by (fastforce dest!: sees_method_compPD (*‹compP ?f ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?fm in ?D ⟹ ∃m. ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = m in ?D ∧ ?f ?b m = ?fm›*)) next (*goal: ‹app⇩i (i, P, pc, mpc, T, τ) ⟹ app⇩i (i, compP f P, pc, mpc, T, τ)›*) assume "?B" (*‹app⇩i (i::instr, P::'b prog, pc::nat, mpc::nat, T::ty, τ::ty list × ty err list)›*) then show "?A" using Invokestatic (*‹i = Invokestatic x111 x112 x113›*) "τ" (*‹τ = (ST, LT)›*) apply auto (*goal: ‹app⇩i (i::instr, compP (f::staticb ⇒ 'b ⇒ 'a) (P::'b prog), pc::nat, mpc::nat, T::ty, τ::ty list × ty err list)›*) by (force dest: sees_method_compP (*‹?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?m in ?D ⟹ compP ?f ?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?f ?b ?m in ?D›*)) qed qed (auto) (*solves the remaining goals: 1. ‹⋀x1. ⟦τ = (ST, LT); i = Load x1⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 2. ‹⋀x2. ⟦τ = (ST, LT); i = Store x2⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 3. ‹⋀x3. ⟦τ = (ST, LT); i = Push x3⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 4. ‹⋀x4. ⟦τ = (ST, LT); i = New x4⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 5. ‹⋀x51 x52. ⟦τ = (ST, LT); i = Getfield x51 x52⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 6. ‹⋀x61 x62 x63. ⟦τ = (ST, LT); i = Getstatic x61 x62 x63⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 7. ‹⋀x71 x72. ⟦τ = (ST, LT); i = Putfield x71 x72⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 8. ‹⋀x81 x82 x83. ⟦τ = (ST, LT); i = Putstatic x81 x82 x83⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 9. ‹⋀x9. ⟦τ = (ST, LT); i = Checkcast x9⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 10. ‹⟦τ = (ST, LT); i = Return⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 11. ‹⟦τ = (ST, LT); i = Pop⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 12. ‹⟦τ = (ST, LT); i = IAdd⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 13. ‹⋀x15. ⟦τ = (ST, LT); i = Goto x15⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 14. ‹⟦τ = (ST, LT); i = CmpEq⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 15. ‹⋀x17. ⟦τ = (ST, LT); i = IfFalse x17⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)› 16. ‹⟦τ = (ST, LT); i = instr.Throw⟧ ⟹ app⇩i (i, compP f P, pc, mpc, T, τ) = app⇩i (i, P, pc, mpc, T, τ)›*) qed (*>*) lemma [simp]: "is_relevant_entry (compP f P) i = is_relevant_entry P i" (*<*) proof (-) (*goal: ‹is_relevant_entry (compP f P) i = is_relevant_entry P i›*) { fix pc and e have "is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e" apply (cases i) (*goals: 1. ‹⋀x1. i = Load x1 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 2. ‹⋀x2. i = Store x2 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 3. ‹⋀x3. i = Push x3 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 4. ‹⋀x4. i = New x4 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 5. ‹⋀x51 x52. i = Getfield x51 x52 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 6. ‹⋀x61 x62 x63. i = Getstatic x61 x62 x63 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 7. ‹⋀x71 x72. i = Putfield x71 x72 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 8. ‹⋀x81 x82 x83. i = Putstatic x81 x82 x83 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 9. ‹⋀x9. i = Checkcast x9 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 10. ‹⋀x101 x102. i = Invoke x101 x102 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 11. ‹⋀x111 x112 x113. i = Invokestatic x111 x112 x113 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 12. ‹i = Return ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 13. ‹i = Pop ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 14. ‹i = IAdd ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 15. ‹⋀x15. i = Goto x15 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 16. ‹i = CmpEq ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 17. ‹⋀x17. i = IfFalse x17 ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› 18. ‹i = instr.Throw ⟹ is_relevant_entry (compP f P) i pc e = is_relevant_entry P i pc e› discuss goal 1*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry (?P::?'m prog) (?i::instr) (?pc::nat) (?e::ex_entry) = (let (f::nat, t::nat, C::char list, h::nat, d::nat) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 2*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry (?P::?'m::type prog) (?i::instr) (?pc::nat) (?e::ex_entry) = (let (f::nat, t::nat, C::char list, h::nat, d::nat) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 3*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 4*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 5*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 6*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 7*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 8*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 9*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 10*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 11*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 12*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 13*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 14*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 15*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 16*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry (?P::?'m prog) (?i::instr) (?pc::nat) (?e::ex_entry) = (let (f::nat, t::nat, C::char list, h::nat, d::nat) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 17*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*discuss goal 18*) apply ((auto simp: is_relevant_entry_def (*‹is_relevant_entry ?P ?i ?pc ?e = (let (f, t, C, h, d) = ?e in is_relevant_class ?i ?P C ∧ ?pc ∈ {f..<t})›*))[1]) (*proven 18 subgoals*) . } then show "?thesis" (*goal: ‹is_relevant_entry (compP (f::staticb ⇒ 'b ⇒ 'a) (P::'b prog)) (i::instr) = is_relevant_entry P i›*) by fast qed (*>*) lemma [simp]: "relevant_entries (compP f P) i pc xt = relevant_entries P i pc xt" (*<*) by (simp add: relevant_entries_def (*‹relevant_entries ?P ?i ?pc = filter (is_relevant_entry ?P ?i ?pc)›*))(*>*) lemma [simp]: "app i (compP f P) mpc T pc mxl xt τ = app i P mpc T pc mxl xt τ" (*<*) apply (simp add: app_def (*‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*) xcpt_app_def (*‹xcpt_app ?i ?P ?pc ?mxs ?xt ?τ = (∀(f, t, C, h, d)∈set (relevant_entries ?P ?i ?pc ?xt). is_class ?P C ∧ d ≤ length (fst ?τ) ∧ d < ?mxs)›*) eff_def (*‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) xcpt_eff_def (*‹xcpt_eff ?i ?P ?pc ?τ ?et = (let (ST, LT) = ?τ in map (λ(f, t, C, h, d). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) norm_eff_def (*‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*)) (*goal: ‹app i (compP f P) mpc T pc mxl xt τ = app i P mpc T pc mxl xt τ›*) by (fastforce simp add: image_def (*‹?f ` ?A = {y. ∃x∈?A. y = ?f x}›*)) (*>*) lemma [simp]: assumes "app i P mpc T pc mxl xt τ" shows "eff i (compP f P) pc xt τ = eff i P pc xt τ" (*<*) using assms (*‹app i P mpc T pc mxl xt τ›*) proof (clarsimp simp: eff_def (*‹eff (?i::instr) (?P::?'m prog) (?pc::nat) (?et::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ [] | ⌊τ::ty list × ty err list⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)›*) norm_eff_def (*‹norm_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) = map (λpc'::nat. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) xcpt_eff_def (*‹xcpt_eff (?i::instr) (?P::?'m prog) (?pc::nat) (?τ::ty list × ty err list) (?et::ex_table) = (let (ST::ty list, LT::ty err list) = ?τ in map (λ(f::nat, t::nat, C::char list, h::nat, d::nat). (h, ⌊(Class C # drop (length ST - d) ST, LT)⌋)) (relevant_entries ?P ?i ?pc ?et))›*) app_def (*‹app (?i::instr) (?P::?'m prog) (?mxs::nat) (?T⇩r::ty) (?pc::nat) (?mpc::nat) (?xt::ex_table) (?t::(ty list × ty err list) option) = (case ?t of None ⇒ True | ⌊τ::ty list × ty err list⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc'::nat, τ'::(ty list × ty err list) option)∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))›*), cases i) (*goals: 1. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x1::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Load x1⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 2. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x2::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Store x2⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 3. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x3::val. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Push x3⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 4. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x4::char list. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = New x4⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 5. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) (x51::char list) x52::char list. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Getfield x51 x52⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 6. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) (x61::char list) (x62::char list) x63::char list. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Getstatic x61 x62 x63⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 7. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) (x71::char list) x72::char list. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Putfield x71 x72⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 8. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) (x81::char list) (x82::char list) x83::char list. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Putstatic x81 x82 x83⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 9. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x9::char list. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Checkcast x9⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 10. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) (x101::char list) x102::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Invoke x101 x102⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 11. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) (x111::char list) (x112::char list) x113::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Invokestatic x111 x112 x113⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 12. ‹⋀(aa::ty list) (ba::ty err list) x::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Return⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 13. ‹⋀(aa::ty list) (ba::ty err list) x::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Pop⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 14. ‹⋀(aa::ty list) (ba::ty err list) x::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = IAdd⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 15. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x15::int. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Goto x15⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 16. ‹⋀(aa::ty list) (ba::ty err list) x::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = CmpEq⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 17. ‹⋀(aa::ty list) (ba::ty err list) (x::nat) x17::int. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = IfFalse x17⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)› 18. ‹⋀(aa::ty list) (ba::ty err list) x::nat. ⟦(τ::(ty list × ty err list) option) = ⌊(aa, ba)⌋; app⇩i (i::instr, P::'a::type prog, pc::nat, mpc::nat, T::ty, aa, ba); xcpt_app i P pc mpc (xt::ex_table) (aa, ba); ∀x::nat × (ty list × ty err list) option∈(λpc'::nat. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx::ex_entry. case x of (f::nat, t::nat, C::char list, h::nat, d::nat) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc'::nat, τ'::(ty list × ty err list) option) ⇒ pc' < (mxl::nat); x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = instr.Throw⟧ ⟹ eff⇩i (i, compP (f::staticb ⇒ 'a::type ⇒ 'b::type) P, aa, ba) = eff⇩i (i, P, aa, ba)›*) qed (auto) (*solves the remaining goals: 1. ‹⋀aa ba x x1. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Load x1⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 2. ‹⋀aa ba x x2. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Store x2⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 3. ‹⋀aa ba x x3. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Push x3⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 4. ‹⋀aa ba x x4. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = New x4⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 5. ‹⋀aa ba x x51 x52. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Getfield x51 x52⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 6. ‹⋀aa ba x x61 x62 x63. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Getstatic x61 x62 x63⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 7. ‹⋀aa ba x x71 x72. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Putfield x71 x72⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 8. ‹⋀aa ba x x81 x82 x83. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Putstatic x81 x82 x83⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 9. ‹⋀aa ba x x9. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Checkcast x9⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 10. ‹⋀aa ba x x101 x102. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Invoke x101 x102⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 11. ‹⋀aa ba x x111 x112 x113. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Invokestatic x111 x112 x113⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 12. ‹⋀aa ba x. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Return⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 13. ‹⋀aa ba x. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Pop⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 14. ‹⋀aa ba x. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = IAdd⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 15. ‹⋀aa ba x x15. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = Goto x15⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 16. ‹⋀aa ba x. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = CmpEq⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 17. ‹⋀aa ba x x17. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = IfFalse x17⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)› 18. ‹⋀aa ba x. ⟦τ = ⌊(aa, ba)⌋; app⇩i (i, P, pc, mpc, T, aa, ba); xcpt_app i P pc mpc xt (aa, ba); ∀x∈(λpc'. (pc', ⌊eff⇩i (i, P, aa, ba)⌋)) ` set (succs i (aa, ba) pc) ∪ (λx. case x of (f, t, C, h, d) ⇒ (h, ⌊(Class C # drop (length aa - d) aa, ba)⌋)) ` set (relevant_entries P i pc xt). case x of (pc', τ') ⇒ pc' < mxl; x ∈ set (succs i (aa, ba) pc); app i P mpc T pc mxl xt τ; i = instr.Throw⟧ ⟹ eff⇩i (i, compP f P, aa, ba) = eff⇩i (i, P, aa, ba)›*) (*>*) lemma [simp]: "subtype (compP f P) = subtype P" (*<*)apply (rule ext (*‹(⋀x::?'a. (?f::?'a ⇒ ?'b) x = (?g::?'a ⇒ ?'b) x) ⟹ ?f = ?g›*)) (*goal: ‹subtype (compP f P) = subtype P›*) apply (rule ext (*‹(⋀x. ?f x = ?g x) ⟹ ?f = ?g›*)) (*goal: ‹⋀x. subtype (compP f P) x = subtype P x›*) by simp(*>*) lemma [simp]: "compP f P ⊢ τ ≤' τ' = P ⊢ τ ≤' τ'" (*<*) by (simp add: sup_state_opt_def (*‹sup_state_opt (?P::?'c prog) ≡ Opt.le (sup_state ?P)›*) sup_state_def (*‹sup_state (?P::?'c prog) ≡ Product.le (Listn.le (subtype ?P)) (Listn.le (sup_ty_opt ?P))›*) sup_ty_opt_def (*‹sup_ty_opt (?P::?'c prog) ≡ Err.le (subtype ?P)›*))(*>*) lemma [simp]: "compP f P,T,mpc,mxl,xt ⊢ i,pc :: τs = P,T,mpc,mxl,xt ⊢ i,pc :: τs" (*<*)by (simp add: wt_instr_def (*‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')›*) cong: conj_cong (*‹⟦?P = ?P'; ?P' ⟹ ?Q = ?Q'⟧ ⟹ (?P ∧ ?Q) = (?P' ∧ ?Q')›*))(*>*) declare TC1.compT_sizes[simp] TC0.ty_def2[simp] context TC2 begin lemma compT_method_NonStatic: fixes e and A and C and Ts and mxl₀ defines [simp]: "E ≡ Class C # Ts" and [simp]: "A ≡ ⌊{..size Ts}⌋" and [simp]: "A' ≡ A ⊔ 𝒜 e" and [simp]: "mxl₀ ≡ max_vars e" assumes mxs: "max_stack e = mxs" and mxl: "Suc (length Ts + max_vars e) = mxl" assumes wf: "wf_prog p P" and wte: "P,E ⊢₁ e :: T" and 𝒟: "𝒟 e A" and ℬ: "ℬ e (size E)" and E_P: "set E ⊆ types P" and wid: "P ⊢ T ≤ T⇩r" shows "wt_method (compP₂ P) C NonStatic Ts T⇩r mxs mxl₀ (compE₂ e @ [Return]) (compxE₂ e 0 0) (ty⇩i' [] E A # compT⇩a E A [] e)" (*<*)(is "wt_method ?P C ?b Ts T⇩r mxs mxl₀ ?is ?xt ?τs") proof (-) (*goal: ‹wt_method (compP₂ (P::nat exp prog)) (C::char list) NonStatic (Ts::ty list) (T⇩r::ty) (mxs::nat) (mxl₀::nat) (compE₂ (e::nat exp) @ [Return]) (compxE₂ e (0::nat) (0::nat)) (ty⇩i' [] (E::ty list) (A::nat set option) # compT⇩a E A [] e)›*) let ?n = "length E + mxl₀" have wt_compE: "P,T⇩r,mxs ⊢ compE₂ e, compxE₂ e 0 (length []) [::] TC0.ty⇩i' ?n [] E A # TC1.compT P ?n E A [] e @[TC0.after P ?n E A [] e]" using mxs (*‹max_stack e = mxs›*) TC2.compT_wt_instrs[OF wte 𝒟 ℬ, of "[]" mxs ?n T⇩r] (*‹⟦length [] + max_stack e ≤ mxs; length E + max_vars e ≤ length E + mxl₀⟧ ⟹ ⊢ compE₂ e, compxE₂ e 0 (length []) [::] TC0.ty⇩i' (length E + mxl₀) [] E A # TC1.compT P (length E + mxl₀) E A [] e @ [TC0.after P (length E + mxl₀) E A [] e]›*) by simp have "OK (ty⇩i' [T] E A') ∈ states P mxs mxl" using mxs (*‹max_stack e = mxs›*) "WT₁_is_type"[OF wf wte E_P] (*‹is_type P T›*) max_stack1[OF wte] (*‹1 ≤ max_stack e›*) "OK_ty⇩i'_in_statesI"[OF E_P] (*‹⟦set ?ST ⊆ types P; length ?ST ≤ ?mxs⟧ ⟹ OK (ty⇩i' ?ST E ?A) ∈ states P ?mxs mxl›*) by simp moreover have "OK ` set (compT E A [] e) ⊆ states P mxs mxl" using mxs (*‹max_stack (e::nat exp) = (mxs::nat)›*) mxl (*‹Suc (length Ts + max_vars e) = mxl›*) wid (*‹subtype P T T⇩r›*) compT_states(1)[OF wf wte E_P] (*‹⟦set ?ST ⊆ types P; length ?ST + max_stack e ≤ ?mxs; length E + max_vars e ≤ mxl⟧ ⟹ OK ` set (compT E ?A ?ST e) ⊆ states P ?mxs mxl›*) by simp ultimately have "check_types ?P mxs ?n (map OK ?τs)" using mxl (*‹Suc (length Ts + max_vars e) = mxl›*) wte (*‹P,E ⊢₁ e :: T›*) E_P (*‹set E ⊆ types P›*) by (simp add: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*) after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) check_types_def (*‹check_types ?P ?mxs ?mxl ?τs ≡ set ?τs ⊆ states ?P ?mxs ?mxl›*)) moreover have "wt_start ?P C ?b Ts mxl₀ ?τs" using mxl (*‹Suc (length Ts + max_vars e) = mxl›*) by (auto simp: wt_start_def (*‹wt_start ?P ?C ?b ?Ts ?mxl₀ ?τs ≡ case ?b of Static ⇒ ?P ⊢ ⌊([], map OK ?Ts @ replicate ?mxl₀ Err)⌋ ≤' ?τs ! 0 | NonStatic ⇒ ?P ⊢ ⌊([], OK (Class ?C) # map OK ?Ts @ replicate ?mxl₀ Err)⌋ ≤' ?τs ! 0›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) nth_Cons (*‹(?x # ?xs) ! ?n = (case ?n of 0 ⇒ ?x | Suc k ⇒ ?xs ! k)›*) split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) moreover { fix pc assume pc: "pc < size ?is" (*‹(pc::nat) < length (compE₂ (e::nat exp) @ [Return])›*) then have "?P,T⇩r,mxs,size ?is,?xt ⊢ ?is!pc,pc :: ?τs" proof (cases "pc < length (compE₂ e)") (*goals: 1. ‹⟦(pc::nat) < length (compE₂ (e::nat exp) @ [Return]); pc < length (compE₂ e)⟧ ⟹ compP₂ (P::nat exp prog),T⇩r::ty,mxs::nat,length (compE₂ e @ [Return]),compxE₂ e (0::nat) (0::nat) ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] (E::ty list) (A::nat set option) # compT⇩a E A [] e› 2. ‹⟦(pc::nat) < length (compE₂ (e::nat exp) @ [Return]); ¬ pc < length (compE₂ e)⟧ ⟹ compP₂ (P::nat exp prog),T⇩r::ty,mxs::nat,length (compE₂ e @ [Return]),compxE₂ e (0::nat) (0::nat) ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] (E::ty list) (A::nat set option) # compT⇩a E A [] e›*) case True (*‹pc < length (compE₂ e)›*) then show "?thesis" (*goal: ‹compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) using mxs (*‹max_stack (e::nat exp) = (mxs::nat)›*) wte (*‹P,E ⊢₁ e :: T›*) wt_compE (*‹⊢ compE₂ e, compxE₂ e 0 (length []) [::] TC0.ty⇩i' (length E + mxl₀) [] E A # TC1.compT P (length E + mxl₀) E A [] e @ [TC0.after P (length E + mxl₀) E A [] e]›*) by (clarsimp simp: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*) mxl (*‹Suc (length Ts + max_vars e) = mxl›*) after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) next (*goal: ‹⟦pc < length (compE₂ e @ [Return]); ¬ pc < length (compE₂ e)⟧ ⟹ compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) case False (*‹¬ pc < length (compE₂ e)›*) have "length (compE₂ e) = pc" using less_antisym[OF False] (*‹pc < Suc (length (compE₂ e)) ⟹ length (compE₂ e) = pc›*) pc (*‹pc < length (compE₂ e @ [Return])›*) by simp then show "?thesis" (*goal: ‹compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) using mxl (*‹Suc (length Ts + max_vars e) = mxl›*) wte (*‹P,E ⊢₁ e :: T›*) E_P (*‹set (E::ty list) ⊆ types (P::nat exp prog)›*) wid (*‹subtype P T T⇩r›*) by (clarsimp simp: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*) after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) xcpt_app_pcs (*‹?pc ∉ pcs ?xt ⟹ xcpt_app ?i ?P ?pc ?mxs ?xt ?τ›*) xcpt_eff_pcs (*‹?pc ∉ pcs ?xt ⟹ xcpt_eff ?i ?P ?pc ?τ ?xt = []›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*)) qed } moreover have "0 < size ?is" and "size ?τs = size ?is" using wte (*‹P,E ⊢₁ e :: T›*) apply - (*goals: 1. ‹P,E ⊢₁ e :: T ⟹ 0 < length (compE₂ e @ [Return])› 2. ‹P,E ⊢₁ e :: T ⟹ length (ty⇩i' [] E A # compT⇩a E A [] e) = length (compE₂ e @ [Return])› discuss goal 1*) apply (simp add: compT⇩a_def (*‹compT⇩a (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*)) (*discuss goal 2*) apply (simp add: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*)) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹wt_method (compP₂ P) C NonStatic Ts T⇩r mxs mxl₀ (compE₂ e @ [Return]) (compxE₂ e 0 0) (ty⇩i' [] E A # compT⇩a E A [] e)›*) by (simp add: wt_method_def (*‹wt_method ?P ?C ?b ?Ts ?T⇩r ?mxs ?mxl₀ ?is ?xt ?τs ≡ (?b = Static ∨ ?b = NonStatic) ∧ 0 < length ?is ∧ length ?τs = length ?is ∧ check_types ?P ?mxs ((case ?b of Static ⇒ 0 | NonStatic ⇒ 1) + length ?Ts + ?mxl₀) (map OK ?τs) ∧ wt_start ?P ?C ?b ?Ts ?mxl₀ ?τs ∧ (∀pc<length ?is. ?P,?T⇩r,?mxs,length ?is,?xt ⊢ ?is ! pc,pc :: ?τs)›*)) qed (*>*) lemma compT_method_Static: fixes e and A and C and Ts and mxl₀ defines [simp]: "E ≡ Ts" and [simp]: "A ≡ ⌊{..<size Ts}⌋" and [simp]: "A' ≡ A ⊔ 𝒜 e" and [simp]: "mxl₀ ≡ max_vars e" assumes mxs: "max_stack e = mxs" and mxl: "length Ts + max_vars e = mxl" assumes wf: "wf_prog p P" and wte: "P,E ⊢₁ e :: T" and 𝒟: "𝒟 e A" and ℬ: "ℬ e (size E)" and E_P: "set E ⊆ types P" and wid: "P ⊢ T ≤ T⇩r" shows "wt_method (compP₂ P) C Static Ts T⇩r mxs mxl₀ (compE₂ e @ [Return]) (compxE₂ e 0 0) (ty⇩i' [] E A # compT⇩a E A [] e)" (*<*)(is "wt_method ?P C ?b Ts T⇩r mxs mxl₀ ?is ?xt ?τs") proof (-) (*goal: ‹wt_method (compP₂ (P::nat exp prog)) (C::char list) Static (Ts::ty list) (T⇩r::ty) (mxs::nat) (mxl₀::nat) (compE₂ (e::nat exp) @ [Return]) (compxE₂ e (0::nat) (0::nat)) (ty⇩i' [] (E::ty list) (A::nat set option) # compT⇩a E A [] e)›*) let ?n = "length E + mxl₀" have wt_compE: "P,T⇩r,mxs ⊢ compE₂ e, compxE₂ e 0 (length []) [::] TC0.ty⇩i' ?n [] E A # TC1.compT P ?n E A [] e @[TC0.after P ?n E A [] e]" using mxs (*‹max_stack e = mxs›*) TC2.compT_wt_instrs[OF wte 𝒟 ℬ, of "[]" mxs ?n T⇩r] (*‹⟦length [] + max_stack e ≤ mxs; length E + max_vars e ≤ length E + mxl₀⟧ ⟹ ⊢ compE₂ e, compxE₂ e 0 (length []) [::] TC0.ty⇩i' (length E + mxl₀) [] E A # TC1.compT P (length E + mxl₀) E A [] e @ [TC0.after P (length E + mxl₀) E A [] e]›*) by simp have "OK (ty⇩i' [T] E A') ∈ states P mxs mxl" using mxs (*‹max_stack (e::nat exp) = (mxs::nat)›*) "WT₁_is_type"[OF wf wte E_P] (*‹is_type P T›*) max_stack1[OF wte] (*‹(1::nat) ≤ max_stack (e::nat exp)›*) "OK_ty⇩i'_in_statesI"[OF E_P] (*‹⟦set (?ST::ty list) ⊆ types (P::nat exp prog); length ?ST ≤ (?mxs::nat)⟧ ⟹ OK (ty⇩i' ?ST (E::ty list) (?A::nat set option)) ∈ states P ?mxs (mxl::nat)›*) by simp moreover have "OK ` set (compT E A [] e) ⊆ states P mxs mxl" using mxs (*‹max_stack e = mxs›*) mxl (*‹length Ts + max_vars e = mxl›*) wid (*‹subtype P T T⇩r›*) compT_states(1)[OF wf wte E_P] (*‹⟦set ?ST ⊆ types P; length ?ST + max_stack e ≤ ?mxs; length E + max_vars e ≤ mxl⟧ ⟹ OK ` set (compT E ?A ?ST e) ⊆ states P ?mxs mxl›*) by simp ultimately have "check_types ?P mxs ?n (map OK ?τs)" using mxl (*‹length Ts + max_vars e = mxl›*) wte (*‹P,E ⊢₁ e :: T›*) E_P (*‹set E ⊆ types P›*) by (simp add: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*) after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) check_types_def (*‹check_types ?P ?mxs ?mxl ?τs ≡ set ?τs ⊆ states ?P ?mxs ?mxl›*)) moreover have "wt_start ?P C ?b Ts mxl₀ ?τs" using mxl (*‹length Ts + max_vars e = mxl›*) by (auto simp: wt_start_def (*‹wt_start ?P ?C ?b ?Ts ?mxl₀ ?τs ≡ case ?b of Static ⇒ ?P ⊢ ⌊([], map OK ?Ts @ replicate ?mxl₀ Err)⌋ ≤' ?τs ! 0 | NonStatic ⇒ ?P ⊢ ⌊([], OK (Class ?C) # map OK ?Ts @ replicate ?mxl₀ Err)⌋ ≤' ?τs ! 0›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*) ty⇩l_def (*‹ty⇩l ?E ?A' = map (λi. if i ∈ ?A' ∧ i < length ?E then OK (?E ! i) else Err) [0..<mxl]›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) nth_Cons (*‹(?x # ?xs) ! ?n = (case ?n of 0 ⇒ ?x | Suc k ⇒ ?xs ! k)›*) split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) moreover { fix pc assume pc: "pc < size ?is" (*‹(pc::nat) < length (compE₂ (e::nat exp) @ [Return])›*) then have "?P,T⇩r,mxs,size ?is,?xt ⊢ ?is!pc,pc :: ?τs" proof (cases "pc < length (compE₂ e)") (*goals: 1. ‹⟦pc < length (compE₂ e @ [Return]); pc < length (compE₂ e)⟧ ⟹ compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e› 2. ‹⟦pc < length (compE₂ e @ [Return]); ¬ pc < length (compE₂ e)⟧ ⟹ compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) case True (*‹pc < length (compE₂ e)›*) then show "?thesis" (*goal: ‹compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) using mxs (*‹max_stack e = mxs›*) wte (*‹P,E ⊢₁ e :: T›*) wt_compE (*‹⊢ compE₂ e, compxE₂ e 0 (length []) [::] TC0.ty⇩i' (length E + mxl₀) [] E A # TC1.compT P (length E + mxl₀) E A [] e @ [TC0.after P (length E + mxl₀) E A [] e]›*) by (clarsimp simp: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*) mxl (*‹length Ts + max_vars e = mxl›*) after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) wt_instrs_def (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))›*)) next (*goal: ‹⟦pc < length (compE₂ e @ [Return]); ¬ pc < length (compE₂ e)⟧ ⟹ compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) case False (*‹¬ pc < length (compE₂ e)›*) have "length (compE₂ e) = pc" using less_antisym[OF False] (*‹pc < Suc (length (compE₂ e)) ⟹ length (compE₂ e) = pc›*) pc (*‹pc < length (compE₂ e @ [Return])›*) by simp then show "?thesis" (*goal: ‹compP₂ P,T⇩r,mxs,length (compE₂ e @ [Return]),compxE₂ e 0 0 ⊢ (compE₂ e @ [Return]) ! pc,pc :: ty⇩i' [] E A # compT⇩a E A [] e›*) using mxl (*‹length Ts + max_vars e = mxl›*) wte (*‹P,E ⊢₁ e :: T›*) E_P (*‹set E ⊆ types P›*) wid (*‹subtype P T T⇩r›*) by (clarsimp simp: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*) after_def (*‹after ?E ?A ?ST ?e = ty⇩i' (ty ?E ?e # ?ST) ?E (?A ⊔ 𝒜 ?e)›*) wt_defs (*‹(⊢ ?is, ?xt [::] ?τs) = (length ?is < length ?τs ∧ pcs ?xt ⊆ {0..<length ?is} ∧ (∀pc<length ?is. P,T⇩r,mxs,length ?τs,?xt ⊢ ?is ! pc,pc :: ?τs))› ‹?P,?T,?mxs,?mpc,?xt ⊢ ?i,?pc :: ?τs ≡ app ?i ?P ?mxs ?T ?pc ?mpc ?xt (?τs ! ?pc) ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt (?τs ! ?pc)). ?P ⊢ τ' ≤' ?τs ! pc')› ‹app ?i ?P ?mxs ?T⇩r ?pc ?mpc ?xt ?t = (case ?t of None ⇒ True | ⌊τ⌋ ⇒ app⇩i (?i, ?P, ?pc, ?mxs, ?T⇩r, τ) ∧ xcpt_app ?i ?P ?pc ?mxs ?xt τ ∧ (∀(pc', τ')∈set (eff ?i ?P ?pc ?xt ?t). pc' < ?mpc))› ‹eff ?i ?P ?pc ?et ?t = (case ?t of None ⇒ [] | ⌊τ⌋ ⇒ norm_eff ?i ?P ?pc τ @ xcpt_eff ?i ?P ?pc τ ?et)› ‹norm_eff ?i ?P ?pc ?τ = map (λpc'. (pc', ⌊eff⇩i (?i, ?P, ?τ)⌋)) (succs ?i ?τ ?pc)›*) xcpt_app_pcs (*‹?pc ∉ pcs ?xt ⟹ xcpt_app ?i ?P ?pc ?mxs ?xt ?τ›*) xcpt_eff_pcs (*‹?pc ∉ pcs ?xt ⟹ xcpt_eff ?i ?P ?pc ?τ ?xt = []›*) ty⇩i'_def (*‹ty⇩i' ?ST ?E ?A = (case ?A of None ⇒ None | ⌊A'⌋ ⇒ ⌊(?ST, ty⇩l ?E A')⌋)›*)) qed } moreover have "0 < size ?is" and "size ?τs = size ?is" using wte (*‹P,E ⊢₁ e :: T›*) apply - (*goals: 1. ‹P,E ⊢₁ e :: T ⟹ 0 < length (compE₂ e @ [Return])› 2. ‹P,E ⊢₁ e :: T ⟹ length (ty⇩i' [] E A # compT⇩a E A [] e) = length (compE₂ e @ [Return])› discuss goal 1*) apply (simp add: compT⇩a_def (*‹compT⇩a (?E::ty list) (?A::nat set option) (?ST::ty list) (?e::nat exp) = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*)) (*discuss goal 2*) apply (simp add: compT⇩a_def (*‹compT⇩a ?E ?A ?ST ?e = compT ?E ?A ?ST ?e @ [after ?E ?A ?ST ?e]›*)) (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹wt_method (compP₂ P) C Static Ts T⇩r mxs mxl₀ (compE₂ e @ [Return]) (compxE₂ e 0 0) (ty⇩i' [] E A # compT⇩a E A [] e)›*) by (simp add: wt_method_def (*‹wt_method ?P ?C ?b ?Ts ?T⇩r ?mxs ?mxl₀ ?is ?xt ?τs ≡ (?b = Static ∨ ?b = NonStatic) ∧ 0 < length ?is ∧ length ?τs = length ?is ∧ check_types ?P ?mxs ((case ?b of Static ⇒ 0 | NonStatic ⇒ 1) + length ?Ts + ?mxl₀) (map OK ?τs) ∧ wt_start ?P ?C ?b ?Ts ?mxl₀ ?τs ∧ (∀pc<length ?is. ?P,?T⇩r,?mxs,length ?is,?xt ⊢ ?is ! pc,pc :: ?τs)›*)) qed (*>*) end definition compTP :: "J₁_prog ⇒ ty⇩P" where "compTP P C M = ( let (D,b,Ts,T,e) = method P C M; E = case b of Static ⇒ Ts | NonStatic ⇒ Class C # Ts; A = case b of Static ⇒ ⌊{..<size Ts}⌋ | NonStatic ⇒ ⌊{..size Ts}⌋; mxl = (case b of Static ⇒ 0 | NonStatic ⇒ 1) + size Ts + max_vars e in (TC0.ty⇩i' mxl [] E A # TC1.compT⇩a P mxl E A [] e))" theorem wt_compP₂: assumes wf: "wf_J₁_prog P" shows "wf_jvm_prog (compP₂ P)" (*<*) proof (-) (*goal: ‹wf_jvm_prog (compP₂ P)›*) let ?Φ = "compTP P" and ?f = "compMb₂" let ?wf₂ = "λP C (M, b, Ts, T⇩r, mxs, mxl₀, is, xt). wt_method P C b Ts T⇩r mxs mxl₀ is xt (?Φ C M)" and ?P = "compP ?f P" { fix C and M and b and Ts and T and m let ?md = "(M,b,Ts,T,m)::expr₁ mdecl" assume cM: "P ⊢ C sees M, b : Ts→T = m in C" and wfm: "wf_mdecl wf_J₁_mdecl P C ?md" (*‹(P::nat exp prog) ⊢ (C::char list) sees (M::char list), (b::staticb) : (Ts::ty list)→(T::ty) = (m::nat exp) in C› ‹wf_mdecl wf_J₁_mdecl (P::nat exp prog) (C::char list) (M::char list, b::staticb, Ts::ty list, T::ty, m::nat exp)›*) then have Ts_types: "∀T'∈set Ts. is_type P T'" and T_type: "is_type P T" and "wfm₁": "wf_J₁_mdecl P C ?md" apply - (*goals: 1. ‹⟦P ⊢ C sees M, b : Ts→T = m in C; wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)⟧ ⟹ ∀T'∈set Ts. is_type P T'› 2. ‹⟦P ⊢ C sees M, b : Ts→T = m in C; wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)⟧ ⟹ is_type P T› 3. ‹⟦P ⊢ C sees M, b : Ts→T = m in C; wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)⟧ ⟹ wf_J₁_mdecl P C (M, b, Ts, T, m)› discuss goal 1*) apply (simp add: wf_mdecl_def (*‹wf_mdecl ?wf_md ?P ?C ≡ λ(M, b, Ts, T, m). (∀T∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) (*discuss goal 2*) apply (simp add: wf_mdecl_def (*‹wf_mdecl (?wf_md::?'m::type prog ⇒ char list ⇒ ?'m::type mdecl ⇒ bool) (?P::?'m::type prog) (?C::char list) ≡ λ(M::char list, b::staticb, Ts::ty list, T::ty, m::?'m::type). (∀T::ty∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) (*discuss goal 3*) apply (simp add: wf_mdecl_def (*‹wf_mdecl (?wf_md::?'m prog ⇒ char list ⇒ ?'m mdecl ⇒ bool) (?P::?'m prog) (?C::char list) ≡ λ(M::char list, b::staticb, Ts::ty list, T::ty, m::?'m). (∀T::ty∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) (*proven 3 subgoals*) . have Ts_P: "set Ts ⊆ types P" using sees_wf_mdecl[OF wf cM] (*‹wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)›*) by (clarsimp simp: wf_mdecl_def (*‹wf_mdecl ?wf_md ?P ?C ≡ λ(M, b, Ts, T, m). (∀T∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) then have CTs_P: "is_class P C ∧ set Ts ⊆ types P" using sees_method_is_class[OF cM] (*‹is_class P C›*) by simp have "?wf₂ ?P C (M,b,Ts,T,?f b m)" proof (cases b) (*goals: 1. ‹b = Static ⟹ case (M, b, Ts, T, compMb₂ b m) of (M, b, Ts, T⇩r, mxs, mxl₀, is, xt) ⇒ wt_method (compP compMb₂ P) C b Ts T⇩r mxs mxl₀ is xt (compTP P C M)› 2. ‹b = NonStatic ⟹ case (M, b, Ts, T, compMb₂ b m) of (M, b, Ts, T⇩r, mxs, mxl₀, is, xt) ⇒ wt_method (compP compMb₂ P) C b Ts T⇩r mxs mxl₀ is xt (compTP P C M)›*) case Static (*‹b = Static›*) then obtain T' where wte: "P,Ts ⊢₁ m :: T'" and wid: "P ⊢ T' ≤ T" and "𝒟": "𝒟 m ⌊{..<size Ts}⌋" and "ℬ": "ℬ m (size Ts)" (*goal: ‹(⋀T'. ⟦P,Ts ⊢₁ m :: T'; subtype P T' T; 𝒟 m ⌊{..<length Ts}⌋; ℬ m (length Ts)⟧ ⟹ thesis) ⟹ thesis›*) using "wfm₁" (*‹wf_J₁_mdecl P C (M, b, Ts, T, m)›*) by (auto simp: wf_mdecl_def (*‹wf_mdecl ?wf_md ?P ?C ≡ λ(M, b, Ts, T, m). (∀T∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) show "?thesis" (*goal: ‹case (M, b, Ts, T, compMb₂ b m) of (M, b, Ts, T⇩r, mxs, mxl₀, is, xt) ⇒ wt_method (compP compMb₂ P) C b Ts T⇩r mxs mxl₀ is xt (compTP P C M)›*) using Static (*‹b = Static›*) cM (*‹P ⊢ C sees M, b : Ts→T = m in C›*) TC2.compT_method_Static[OF _ _ wf wte 𝒟 ℬ Ts_P wid] (*‹⟦max_stack m = ?mxs; length Ts + max_vars m = ?mxl⟧ ⟹ wt_method (compP₂ P) ?C Static Ts T ?mxs (max_vars m) (compE₂ m @ [Return]) (compxE₂ m 0 0) (TC0.ty⇩i' ?mxl [] Ts ⌊{..<length Ts}⌋ # TC1.compT⇩a P ?mxl Ts ⌊{..<length Ts}⌋ [] m)›*) by (simp add: compTP_def (*‹compTP (?P::nat exp prog) (?C::char list) (?M::char list) = (let (D::char list, b::staticb, Ts::ty list, T::ty, e::nat exp) = method ?P ?C ?M; E::ty list = case b of Static ⇒ Ts | NonStatic ⇒ Class ?C # Ts; A::nat set option = case b of Static ⇒ ⌊{..<length Ts}⌋ | NonStatic ⇒ ⌊{..length Ts}⌋; mxl::nat = (case b of Static ⇒ 0::nat | NonStatic ⇒ 1::nat) + length Ts + max_vars e in TC0.ty⇩i' mxl [] E A # TC1.compT⇩a ?P mxl E A [] e)›*)) next (*goal: ‹b = NonStatic ⟹ case (M, b, Ts, T, compMb₂ b m) of (M, b, Ts, T⇩r, mxs, mxl₀, is, xt) ⇒ wt_method (compP compMb₂ P) C b Ts T⇩r mxs mxl₀ is xt (compTP P C M)›*) case NonStatic (*‹(b::staticb) = NonStatic›*) then obtain T' where wte: "P,Class C#Ts ⊢₁ m :: T'" and wid: "P ⊢ T' ≤ T" and "𝒟": "𝒟 m ⌊{..size Ts}⌋" and "ℬ": "ℬ m (Suc (size Ts))" (*goal: ‹(⋀T'. ⟦P,Class C # Ts ⊢₁ m :: T'; subtype P T' T; 𝒟 m ⌊{..length Ts}⌋; ℬ m (Suc (length Ts))⟧ ⟹ thesis) ⟹ thesis›*) using "wfm₁" (*‹wf_J₁_mdecl P C (M, b, Ts, T, m)›*) by (auto simp: wf_mdecl_def (*‹wf_mdecl (?wf_md::?'m::type prog ⇒ char list ⇒ ?'m::type mdecl ⇒ bool) (?P::?'m::type prog) (?C::char list) ≡ λ(M::char list, b::staticb, Ts::ty list, T::ty, m::?'m::type). (∀T::ty∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) have Ts_P: "set Ts ⊆ types P" using sees_wf_mdecl[OF wf cM] (*‹wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)›*) by (fastforce simp: wf_mdecl_def (*‹wf_mdecl ?wf_md ?P ?C ≡ λ(M, b, Ts, T, m). (∀T∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*) intro: sees_method_is_class (*‹?P ⊢ ?C sees ?M, ?b : ?Ts→?T = ?m in ?D ⟹ is_class ?P ?C›*)) show "?thesis" (*goal: ‹case (M, b, Ts, T, compMb₂ b m) of (M, b, Ts, T⇩r, mxs, mxl₀, is, xt) ⇒ wt_method (compP compMb₂ P) C b Ts T⇩r mxs mxl₀ is xt (compTP P C M)›*) using NonStatic (*‹b = NonStatic›*) cM (*‹P ⊢ C sees M, b : Ts→T = m in C›*) TC2.compT_method_NonStatic[simplified, OF _ _ wf wte 𝒟 ℬ CTs_P wid] (*‹⟦max_stack (m::nat exp) = (?mxs::nat); Suc (length (Ts::ty list) + max_vars m) = (?mxl::nat)⟧ ⟹ wt_method (compP compMb₂ (P::nat exp prog)) (C::char list) NonStatic Ts (T::ty) ?mxs (max_vars m) (compE₂ m @ [Return]) (compxE₂ m (0::nat) (0::nat)) (TC0.ty⇩i' ?mxl [] (Class C # Ts) ⌊{..length Ts}⌋ # TC1.compT⇩a P ?mxl (Class C # Ts) ⌊{..length Ts}⌋ [] m)›*) by (simp add: compTP_def (*‹compTP ?P ?C ?M = (let (D, b, Ts, T, e) = method ?P ?C ?M; E = case b of Static ⇒ Ts | NonStatic ⇒ Class ?C # Ts; A = case b of Static ⇒ ⌊{..<length Ts}⌋ | NonStatic ⇒ ⌊{..length Ts}⌋; mxl = (case b of Static ⇒ 0 | NonStatic ⇒ 1) + length Ts + max_vars e in TC0.ty⇩i' mxl [] E A # TC1.compT⇩a ?P mxl E A [] e)›*)) qed then have "wf_mdecl ?wf₂ ?P C (M, b, Ts, T, ?f b m)" using Ts_types (*‹∀T'∈set Ts. is_type P T'›*) T_type (*‹is_type P T›*) by (simp add: wf_mdecl_def (*‹wf_mdecl (?wf_md::?'m::type prog ⇒ char list ⇒ ?'m::type mdecl ⇒ bool) (?P::?'m::type prog) (?C::char list) ≡ λ(M::char list, b::staticb, Ts::ty list, T::ty, m::?'m::type). (∀T::ty∈set Ts. is_type ?P T) ∧ is_type ?P T ∧ ?wf_md ?P ?C (M, b, Ts, T, m)›*)) } then have "wf_prog ?wf₂ (compP ?f P)" apply (rule wf_prog_compPI[OF _ wf] (*‹(⋀C M b Ts T m. ⟦P ⊢ C sees M, b : Ts→T = m in C; wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)⟧ ⟹ wf_mdecl ?wf₂ (compP ?f P) C (M, b, Ts, T, ?f b m)) ⟹ wf_prog ?wf₂ (compP ?f P)›*)) (*goals: 1. ‹⋀C M b Ts T m. ⟦P ⊢ C sees M, b : Ts→T = m in C; wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)⟧ ⟹ P ⊢ C sees M, b : Ts→T = m in C› 2. ‹⋀C M b Ts T m. ⟦P ⊢ C sees M, b : Ts→T = m in C; wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)⟧ ⟹ wf_mdecl wf_J₁_mdecl P C (M, b, Ts, T, m)› discuss goal 1*) apply ((assumption)[1]) (*discuss goal 2*) . (*proven 2 subgoals*) then show "?thesis" (*goal: ‹wf_jvm_prog (compP₂ P)›*) apply (simp add: wf_jvm_prog_def (*‹wf_jvm_prog ?P ≡ ∃Φ. wf_jvm_prog⇘Φ⇙ ?P›*) wf_jvm_prog_phi_def (*‹wf_jvm_prog⇘?Φ⇙ ≡ wf_prog (λP C (M, b, Ts, T⇩r, mxs, mxl₀, is, xt). wt_method P C b Ts T⇩r mxs mxl₀ is xt (?Φ C M))›*)) (*goal: ‹wf_jvm_prog (compP₂ P)›*) by fast qed (*>*) theorem wt_J2JVM: "wf_J_prog P ⟹ wf_jvm_prog (J2JVM P)" (*<*) apply (simp only:o_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) J2JVM_def (*‹J2JVM ≡ compP₂ ∘ compP₁›*)) (*goal: ‹wf_J_prog (P::(char list list × char list exp) prog) ⟹ wf_jvm_prog (J2JVM P)›*) by (blast intro:wt_compP₂ (*‹wf_J₁_prog ?P ⟹ wf_jvm_prog (compP₂ ?P)›*) compP₁_pres_wf (*‹wf_J_prog ?P ⟹ wf_J₁_prog (compP₁ ?P)›*)) end
{ "path": "afp-2025-02-12/thys/JinjaDCI/Compiler/TypeComp.thy", "repo": "afp-2025-02-12", "sha": "c14f75220faaf56d54d5aa1ef800a4f7b18cdfee9c99e40c7c34a537fad209b5" }
theory Left_Coset imports Coset (*This instance of Coset.thy but for left cosets is due to Jonas Rädle and has been imported from the AFP entry Orbit_Stabiliser. *) begin definition LCOSETS :: "[_, 'a set] ⇒ ('a set)set" ("lcosetsı _" [81] 80) where "lcosets⇘G⇙ H = (⋃a∈carrier G. {a <#⇘G⇙ H})" definition LFactGroup :: "[('a,'b) monoid_scheme, 'a set] ⇒ ('a set) monoid" (infixl "LMod" 65) ― ‹Actually defined for groups rather than monoids› where "LFactGroup G H = ⦇carrier = lcosets⇘G⇙ H, mult = set_mult G, one = H⦈" lemma (in group) lcos_self: "[| x ∈ carrier G; subgroup H G |] ==> x ∈ x <# H" by (simp add: group_l_invI (*‹(⋀x. x ∈ carrier G ⟹ ∃y∈carrier G. y ⊗ x = 𝟭) ⟹ Group.group G›*) subgroup.lcos_module_rev (*‹⟦subgroup ?H ?G; Group.group ?G; ?x ∈ carrier ?G; ?x' ∈ carrier ?G; inv⇘?G⇙ ?x ⊗⇘?G⇙ ?x' ∈ ?H⟧ ⟹ ?x' ∈ ?x <#⇘?G⇙ ?H›*) subgroup.one_closed (*‹subgroup ?H ?G ⟹ 𝟭⇘?G⇙ ∈ ?H›*)) text ‹Elements of a left coset are in the carrier› lemma (in subgroup) elemlcos_carrier: assumes "group G" "a ∈ carrier G" "a' ∈ a <# H" shows "a' ∈ carrier G" by (meson assms (*‹Group.group G› ‹a ∈ carrier G› ‹a' ∈ a <# H›*) group.l_coset_carrier (*‹⟦Group.group ?G; ?y ∈ ?x <#⇘?G⇙ ?H; ?x ∈ carrier ?G; subgroup ?H ?G⟧ ⟹ ?y ∈ carrier ?G›*) subgroup_axioms (*‹subgroup H G›*)) text ‹Step one for lemma ‹rcos_module›› lemma (in subgroup) lcos_module_imp: assumes "group G" assumes xcarr: "x ∈ carrier G" and x'cos: "x' ∈ x <# H" shows "(inv x ⊗ x') ∈ H" proof (-) (*goal: ‹inv x ⊗ x' ∈ H›*) interpret group G by fact obtain h where hH: "h ∈ H" and x': "x' = x ⊗ h" and hcarr: "h ∈ carrier G" (*goal: ‹(⋀h. ⟦h ∈ H; x' = x ⊗ h; h ∈ carrier G⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹Group.group G› ‹x ∈ carrier G› ‹(x'::'a) ∈ (x::'a) <# (H::'a set)›*) by (auto simp: l_coset_def (*‹?a <#⇘?G⇙ ?H = (⋃h∈?H. {?a ⊗⇘?G⇙ h})›*)) have "(inv x) ⊗ x' = (inv x) ⊗ (x ⊗ h)" by (simp add: x' (*‹x' = x ⊗ h›*)) have "… = (x ⊗ inv x) ⊗ h" by (metis hcarr (*‹h ∈ carrier G›*) inv_closed (*‹?x ∈ carrier G ⟹ inv ?x ∈ carrier G›*) inv_inv (*‹?x ∈ carrier G ⟹ inv (inv ?x) = ?x›*) l_inv (*‹?x ∈ carrier G ⟹ inv ?x ⊗ ?x = 𝟭›*) m_assoc (*‹⟦?x ∈ carrier G; ?y ∈ carrier G; ?z ∈ carrier G⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*) xcarr (*‹x ∈ carrier G›*)) also (*calculation: ‹inv x ⊗ (x ⊗ h) = x ⊗ inv x ⊗ h›*) have "… = h" by (simp add: hcarr (*‹h ∈ carrier G›*) xcarr (*‹x ∈ carrier G›*)) finally (*calculation: ‹inv (x::'a) ⊗ (x ⊗ (h::'a)) = h›*) have "(inv x) ⊗ x' = h" using x' (*‹x' = x ⊗ h›*) by metis then show "(inv x) ⊗ x' ∈ H" using hH (*‹h ∈ H›*) by force qed text ‹Left cosets are subsets of the carrier.› lemma (in subgroup) lcosets_carrier: assumes "group G" assumes XH: "X ∈ lcosets H" shows "X ⊆ carrier G" proof (-) (*goal: ‹(X::'a::type set) ⊆ carrier G›*) interpret group G by fact show "X ⊆ carrier G" using XH (*‹X ∈ lcosets H›*) l_coset_subset_G (*‹⟦?H ⊆ carrier G; ?x ∈ carrier G⟧ ⟹ ?x <# ?H ⊆ carrier G›*) subset (*‹H ⊆ carrier G›*) by (auto simp: LCOSETS_def (*‹lcosets⇘?G⇙ ?H = (⋃a∈carrier ?G. {a <#⇘?G⇙ ?H})›*)) qed lemma (in group) lcosets_part_G: assumes "subgroup H G" shows "⋃(lcosets H) = carrier G" proof (-) (*goal: ‹⋃ (lcosets (H::'a set)) = carrier G›*) interpret subgroup H G by fact show "?thesis" (*goal: ‹⋃ (lcosets H) = carrier G›*) proof (standard) (*goals: 1. ‹⋃ (lcosets H) ⊆ carrier G› 2. ‹carrier G ⊆ ⋃ (lcosets H)›*) show "⋃ (lcosets H) ⊆ carrier G" by (force simp add: LCOSETS_def (*‹lcosets⇘?G⇙ ?H = (⋃a∈carrier ?G. {a <#⇘?G⇙ ?H})›*) l_coset_def (*‹?a <#⇘?G⇙ ?H = (⋃h∈?H. {?a ⊗⇘?G⇙ h})›*)) show "carrier G ⊆ ⋃ (lcosets H)" by (auto simp add: LCOSETS_def (*‹lcosets⇘?G::(?'a, ?'b) monoid_scheme⇙ (?H::?'a::type set) = (⋃a::?'a::type∈carrier ?G. {a <#⇘?G⇙ ?H})›*) intro: lcos_self (*‹⟦(?x::'a::type) ∈ carrier G; subgroup (?H::'a::type set) G⟧ ⟹ ?x ∈ ?x <# ?H›*) assms (*‹subgroup (H::'a::type set) G›*)) qed qed lemma (in group) lcosets_subset_PowG: "subgroup H G ⟹ lcosets H ⊆ Pow(carrier G)" using lcosets_part_G (*‹subgroup ?H G ⟹ ⋃ (lcosets ?H) = carrier G›*) subset_Pow_Union (*‹?A ⊆ Pow (⋃ ?A)›*) by blast lemma (in group) lcos_disjoint: assumes "subgroup H G" assumes p: "a ∈ lcosets H" "b ∈ lcosets H" "a≠b" shows "a ∩ b = {}" proof (-) (*goal: ‹a ∩ b = {}›*) interpret subgroup H G by fact show "?thesis" (*goal: ‹a ∩ b = {}›*) using p (*‹a ∈ lcosets H› ‹b ∈ lcosets H› ‹(a::'a set) ≠ (b::'a set)›*) l_repr_independence (*‹⟦?y ∈ ?x <# ?H; ?x ∈ carrier G; subgroup ?H G⟧ ⟹ ?x <# ?H = ?y <# ?H›*) subgroup_axioms (*‹subgroup (H::'a::type set) G›*) unfolding LCOSETS_def disjoint_iff (*goal: ‹∀x. x ∈ a ⟶ x ∉ b›*) by blast qed text‹The next two lemmas support the proof of ‹card_cosets_equal›.› lemma (in group) inj_on_f': "⟦H ⊆ carrier G; a ∈ carrier G⟧ ⟹ inj_on (λy. y ⊗ inv a) (a <# H)" by (simp add: inj_on_g (*‹⟦?H ⊆ carrier G; ?a ∈ carrier G⟧ ⟹ inj_on (λy. y ⊗ ?a) ?H›*) l_coset_subset_G (*‹⟦?H ⊆ carrier G; ?x ∈ carrier G⟧ ⟹ ?x <# ?H ⊆ carrier G›*)) lemma (in group) inj_on_f'': "⟦H ⊆ carrier G; a ∈ carrier G⟧ ⟹ inj_on (λy. inv a ⊗ y) (a <# H)" by (meson inj_on_cmult (*‹?c ∈ carrier G ⟹ inj_on ((⊗) ?c) (carrier G)›*) inv_closed (*‹?x ∈ carrier G ⟹ inv ?x ∈ carrier G›*) l_coset_subset_G (*‹⟦?H ⊆ carrier G; ?x ∈ carrier G⟧ ⟹ ?x <# ?H ⊆ carrier G›*) subset_inj_on (*‹⟦inj_on ?f ?B; ?A ⊆ ?B⟧ ⟹ inj_on ?f ?A›*)) lemma (in group) inj_on_g': "⟦H ⊆ carrier G; a ∈ carrier G⟧ ⟹ inj_on (λy. a ⊗ y) H" using inj_on_cmult (*‹?c ∈ carrier G ⟹ inj_on ((⊗) ?c) (carrier G)›*) inj_on_subset (*‹⟦inj_on ?f ?A; ?B ⊆ ?A⟧ ⟹ inj_on ?f ?B›*) by blast lemma (in group) l_card_cosets_equal: assumes "c ∈ lcosets H" and H: "H ⊆ carrier G" and fin: "finite(carrier G)" shows "card H = card c" proof (-) (*goal: ‹card (H::'a::type set) = card (c::'a::type set)›*) obtain x where x: "x ∈ carrier G" and c: "c = x <# H" (*goal: ‹(⋀x. ⟦x ∈ carrier G; c = x <# H⟧ ⟹ thesis) ⟹ thesis›*) using assms (*‹(c::'a set) ∈ lcosets (H::'a set)› ‹H ⊆ carrier G› ‹finite (carrier G)›*) by (auto simp add: LCOSETS_def (*‹lcosets⇘?G⇙ ?H = (⋃a∈carrier ?G. {a <#⇘?G⇙ ?H})›*)) have "inj_on ((⊗) x) H" by (simp add: H (*‹H ⊆ carrier G›*) group.inj_on_g' (*‹⟦Group.group ?G; ?H ⊆ carrier ?G; ?a ∈ carrier ?G⟧ ⟹ inj_on ((⊗⇘?G⇙) ?a) ?H›*) x (*‹x ∈ carrier G›*)) moreover have "(⊗) x ` H ⊆ x <# H" by (force simp add: m_assoc (*‹⟦?x ∈ carrier G; ?y ∈ carrier G; ?z ∈ carrier G⟧ ⟹ ?x ⊗ ?y ⊗ ?z = ?x ⊗ (?y ⊗ ?z)›*) subsetD (*‹⟦?A ⊆ ?B; ?c ∈ ?A⟧ ⟹ ?c ∈ ?B›*) l_coset_def (*‹?a <#⇘?G⇙ ?H = (⋃h∈?H. {?a ⊗⇘?G⇙ h})›*)) moreover have "inj_on ((⊗) (inv x)) (x <# H)" by (simp add: H (*‹(H::'a set) ⊆ carrier G›*) group.inj_on_f'' (*‹⟦Group.group (?G::(?'a, ?'b) monoid_scheme); (?H::?'a set) ⊆ carrier ?G; (?a::?'a) ∈ carrier ?G⟧ ⟹ inj_on ((⊗⇘?G⇙) (inv⇘?G⇙ ?a)) (?a <#⇘?G⇙ ?H)›*) x (*‹(x::'a) ∈ carrier G›*)) moreover have "⋀h. h ∈ H ⟹ inv x ⊗ (x ⊗ h) ∈ H" by (metis H (*‹(H::'a set) ⊆ carrier G›*) in_mono (*‹(?A::?'a set) ⊆ (?B::?'a set) ⟹ (?x::?'a) ∈ ?A ⟶ ?x ∈ ?B›*) inv_solve_left (*‹⟦(?a::'a) ∈ carrier G; (?b::'a) ∈ carrier G; (?c::'a) ∈ carrier G⟧ ⟹ (?a = inv ?b ⊗ ?c) = (?c = ?b ⊗ ?a)›*) m_closed (*‹⟦(?x::'a) ∈ carrier G; (?y::'a) ∈ carrier G⟧ ⟹ ?x ⊗ ?y ∈ carrier G›*) x (*‹(x::'a) ∈ carrier G›*)) then have "(⊗) (inv x) ` (x <# H) ⊆ H" by (auto simp: l_coset_def (*‹?a <#⇘?G⇙ ?H = (⋃h∈?H. {?a ⊗⇘?G⇙ h})›*)) ultimately show "?thesis" (*goal: ‹card H = card c›*) by (metis H (*‹H ⊆ carrier G›*) fin (*‹finite (carrier G)›*) c (*‹c = x <# H›*) card_bij_eq (*‹⟦inj_on ?f ?A; ?f ` ?A ⊆ ?B; inj_on ?g ?B; ?g ` ?B ⊆ ?A; finite ?A; finite ?B⟧ ⟹ card ?A = card ?B›*) finite_imageD (*‹⟦finite (?f ` ?A); inj_on ?f ?A⟧ ⟹ finite ?A›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*)) qed theorem (in group) l_lagrange: assumes "finite(carrier G)" "subgroup H G" shows "card(lcosets H) * card(H) = order(G)" proof (-) (*goal: ‹card (lcosets H) * card H = order G›*) have "card H * card (lcosets H) = card (⋃ (lcosets H))" using card_partition (*‹⟦finite (?C::?'a set set); finite (⋃ ?C); ⋀c::?'a set. c ∈ ?C ⟹ card c = (?k::nat); ⋀(c1::?'a set) c2::?'a set. ⟦c1 ∈ ?C; c2 ∈ ?C; c1 ≠ c2⟧ ⟹ c1 ∩ c2 = {}⟧ ⟹ ?k * card ?C = card (⋃ ?C)›*) by (metis (no_types, lifting) assms (*‹finite (carrier G)› ‹subgroup H G›*) finite_UnionD (*‹finite (⋃ ?A) ⟹ finite ?A›*) l_card_cosets_equal (*‹⟦?c ∈ lcosets ?H; ?H ⊆ carrier G; finite (carrier G)⟧ ⟹ card ?H = card ?c›*) lcos_disjoint (*‹⟦subgroup ?H G; ?a ∈ lcosets ?H; ?b ∈ lcosets ?H; ?a ≠ ?b⟧ ⟹ ?a ∩ ?b = {}›*) lcosets_part_G (*‹subgroup ?H G ⟹ ⋃ (lcosets ?H) = carrier G›*) subgroup.subset (*‹subgroup ?H ?G ⟹ ?H ⊆ carrier ?G›*)) then show "?thesis" (*goal: ‹card (lcosets (H::'a set)) * card H = order G›*) by (simp add: assms( (*‹subgroup H G›*) 2) lcosets_part_G (*‹subgroup ?H G ⟹ ⋃ (lcosets ?H) = carrier G›*) mult.commute (*‹?a * ?b = ?b * ?a›*) order_def (*‹order ?S = card (carrier ?S)›*)) qed end
{ "path": "Isabelle2024/src/HOL/Algebra/Left_Coset.thy", "repo": "Isabelle2024", "sha": "335986f2f64c6d3f50fde2db0bae8c4bb47495f26e55fb718348c8e85c406516" }
section‹Pseudo-Hoops› theory PseudoHoops imports RightComplementedMonoid begin lemma drop_assumption: "p ⟹ True" by simp class pseudo_hoop_algebra = left_complemented_monoid_algebra + right_complemented_monoid_nole_algebra + assumes left_right_impl_times: "(a l→ b) * a = a * (a r→ b)" begin definition "inf_rr a b = a * (a r→ b)" definition "lesseq_r a b = (a r→ b = 1)" definition "less_r a b = (lesseq_r a b ∧ ¬ lesseq_r b a)" end (* sublocale pseudo_hoop_algebra < right: right_complemented_monoid_algebra lesseq_r less_r 1 "( * )" inf_rr "(r→)"; apply unfold_locales; apply simp_all; apply (simp add: less_r_def); apply (simp add: inf_rr_def); apply (rule right_impl_times, rule right_impl_ded); by (simp add: lesseq_r_def); *) context pseudo_hoop_algebra begin lemma right_complemented_monoid_algebra: "class.right_complemented_monoid_algebra lesseq_r less_r 1 (*) inf_rr (r→)" (* by unfold_locales;*) sorry lemma inf_rr_inf [simp]: "inf_rr = (⊓)" apply (unfold fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹inf_rr = (⊓)›*) by (simp add: inf_rr_def (*‹inf_rr ?a ?b = ?a * (?a r→ ?b)›*) inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*) left_right_impl_times (*‹(?a l→ ?b) * ?a = ?a * (?a r→ ?b)›*)) lemma lesseq_lesseq_r: "lesseq_r a b = (a ≤ b)" proof (-) (*goal: ‹lesseq_r a b = (a ≤ b)›*) interpret A: right_complemented_monoid_algebra lesseq_r less_r 1 "(*)" inf_rr "(r→)" by (rule right_complemented_monoid_algebra (*‹class.right_complemented_monoid_algebra lesseq_r less_r 1 (*) inf_rr (r→)›*)) show "lesseq_r a b = (a ≤ b)" apply (subst le_iff_inf (*‹(?x ≤ ?y) = (?x ⊓ ?y = ?x)›*)) (*goal: ‹lesseq_r a b = (a ≤ b)›*) apply (subst A.dual_algebra.inf.absorb_iff1 [of a b] (*‹lesseq_r a b = (inf_rr a b = a)›*)) (*goal: ‹lesseq_r a b = (a ⊓ b = a)›*) apply (unfold inf_rr_inf [THEN sym] (*‹(⊓) = inf_rr›*)) (*goal: ‹(inf_rr a b = a) = (a ⊓ b = a)›*) by simp qed lemma [simp]: "lesseq_r = (≤)" apply (unfold fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹lesseq_r = (≤)›*) by (simp add: lesseq_lesseq_r (*‹lesseq_r ?a ?b = (?a ≤ ?b)›*)) lemma [simp]: "less_r = (<)" apply (unfold fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹less_r = (<)›*) by (simp add: less_r_def (*‹less_r (?a::'a) (?b::'a) = (lesseq_r ?a ?b ∧ ¬ lesseq_r ?b ?a)›*) less_le_not_le (*‹((?x::'a) < (?y::'a)) = (?x ≤ ?y ∧ ¬ ?y ≤ ?x)›*)) subclass right_complemented_monoid_algebra apply (cut_tac right_complemented_monoid_algebra) by simp end sublocale pseudo_hoop_algebra < pseudo_hoop_dual: pseudo_hoop_algebra "λ a b . b * a" "(⊓)" "(r→)" "(≤)" "(<)" 1 "(l→)" apply unfold_locales (*goals: 1. ‹⋀a b. a ⊓ b = (a l→ b) * a› 2. ‹⋀a. a l→ a = 1› 3. ‹⋀a b. (a l→ b) * a = (b l→ a) * b› 4. ‹⋀a b c. b * a l→ c = b l→ a l→ c› 5. ‹⋀a b. a * (a r→ b) = (a l→ b) * a› discuss goal 1*) apply (simp add: inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*)) (*discuss goal 2*) apply simp (*discuss goal 3*) apply (simp add: left_impl_times (*‹(?a l→ ?b) * ?a = (?b l→ ?a) * ?b›*)) (*discuss goal 4*) apply (simp add: left_impl_ded (*‹(?a::'a::type) * (?b::'a::type) l→ (?c::'a::type) = ?a l→ ?b l→ ?c›*)) (*discuss goal 5*) apply (simp add: left_right_impl_times (*‹(?a l→ ?b) * ?a = ?a * (?a r→ ?b)›*)) (*proven 5 subgoals*) . context pseudo_hoop_algebra begin lemma commutative_ps: "(∀ a b . a * b = b * a) = ((l→) = (r→))" apply (simp add: fun_eq_iff (*‹(?f = ?g) = (∀x. ?f x = ?g x)›*)) (*goal: ‹(∀a b. a * b = b * a) = ((l→) = (r→))›*) apply safe (*goals: 1. ‹⋀(x::'a::type) xa::'a::type. ∀(a::'a::type) b::'a::type. a * b = b * a ⟹ x l→ xa = x r→ xa› 2. ‹⋀(a::'a::type) b::'a::type. ∀(x::'a::type) xa::'a::type. x l→ xa = x r→ xa ⟹ a * b = b * a› discuss goal 1*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⋀x xa. ∀a b. a * b = b * a ⟹ x l→ xa ≤ x r→ xa› 2. ‹⋀x xa. ∀a b. a * b = b * a ⟹ x r→ xa ≤ x l→ xa› discuss goal 1*) apply (simp add: right_residual [THEN sym] (*‹((?x1::'a) ≤ (?a1::'a) r→ (?b1::'a)) = (?a1 * ?x1 ≤ ?b1)›*)) (*top goal: ‹⋀x xa. ∀a b. a * b = b * a ⟹ x l→ xa ≤ x r→ xa› and 2 goals remain*) apply (subgoal_tac "x * (x l→ xa) = (x l→ xa) * x") (*goals: 1. ‹⋀x xa. ⟦∀a b. a * b = b * a; x * (x l→ xa) = (x l→ xa) * x⟧ ⟹ x * (x l→ xa) ≤ xa› 2. ‹⋀x xa. ∀a b. a * b = b * a ⟹ x * (x l→ xa) = (x l→ xa) * x› discuss goal 1*) apply (drule drop_assumption (*‹?p ⟹ True›*)) (*top goal: ‹⋀x xa. ⟦∀a b. a * b = b * a; x * (x l→ xa) = (x l→ xa) * x⟧ ⟹ x * (x l→ xa) ≤ xa› and 3 goals remain*) apply simp (*top goal: ‹⋀x xa. ⟦x * (x l→ xa) = (x l→ xa) * x; True⟧ ⟹ x * (x l→ xa) ≤ xa› and 3 goals remain*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: left_residual [THEN sym] (*‹((?x1::'a) ≤ (?a1::'a) l→ (?b1::'a)) = (?x1 * ?a1 ≤ ?b1)›*)) (*top goal: ‹⋀x xa. ∀a b. a * b = b * a ⟹ x r→ xa ≤ x l→ xa› and 1 goal remains*) apply (simp add: right_residual (*‹(?a * ?x ≤ ?b) = (?x ≤ ?a r→ ?b)›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⋀a b. ∀x xa. x l→ xa = x r→ xa ⟹ a * b ≤ b * a› 2. ‹⋀a b. ∀x xa. x l→ xa = x r→ xa ⟹ b * a ≤ a * b› discuss goal 1*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*top goal: ‹⋀(a::'a) b::'a. ∀(x::'a) xa::'a. x l→ xa = x r→ xa ⟹ a * b ≤ b * a› and 1 goal remains*) apply (simp add: right_residual [THEN sym] (*‹(?x1 ≤ ?a1 r→ ?b1) = (?a1 * ?x1 ≤ ?b1)›*)) (*discuss goal 2*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*goal: ‹⋀a b. ∀x xa. x l→ xa = x r→ xa ⟹ b * a ≤ a * b›*) apply (simp add: right_residual [THEN sym] (*‹((?x1::'a) ≤ (?a1::'a) r→ (?b1::'a)) = (?a1 * ?x1 ≤ ?b1)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lemma_2_4_5: "a l→ b ≤ (c l→ a) l→ (c l→ b)" apply (simp add: left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*) mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) (*goal: ‹a l→ b ≤ (c l→ a) l→ c l→ b›*) apply (rule_tac y = "(a l→ b) * a" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹(a l→ b) * ((c l→ a) * c) ≤ (a l→ b) * a› 2. ‹(a l→ b) * a ≤ b› discuss goal 1*) apply (rule mult_left_mono (*‹?a ≤ ?b ⟹ ?c * ?a ≤ ?c * ?b›*)) (*top goal: ‹(a l→ b) * ((c l→ a) * c) ≤ (a l→ b) * a› and 1 goal remains*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*discuss goal 2*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_4_6: "a r→ b ≤ (c r→ a) r→ (c r→ b)" by (rule pseudo_hoop_dual.lemma_2_4_5 (*‹?a r→ ?b ≤ (?c r→ ?a) r→ ?c r→ ?b›*)) primrec imp_power_l:: "'a => nat ⇒ 'a ⇒ 'a" ("(_) l-(_)→ (_)" [65,0,65] 65) where "a l-0→ b = b" | "a l-(Suc n)→ b = (a l→ (a l-n→ b))" primrec imp_power_r:: "'a => nat ⇒ 'a ⇒ 'a" ("(_) r-(_)→ (_)" [65,0,65] 65) where "a r-0→ b = b" | "a r-(Suc n)→ b = (a r→ (a r-n→ b))" lemma lemma_2_4_7_a: "a l-n→ b = a ^ n l→ b" apply (induct_tac n) (*goals: 1. ‹a l-0→ b = a ^ 0 l→ b› 2. ‹⋀n. a l-n→ b = a ^ n l→ b ⟹ a l-Suc n→ b = a ^ Suc n l→ b› discuss goal 1*) apply (simp add: left_impl_ded (*‹?a * ?b l→ ?c = ?a l→ ?b l→ ?c›*)) (*discuss goal 2*) apply (simp add: left_impl_ded (*‹(?a::'a) * (?b::'a) l→ (?c::'a) = ?a l→ ?b l→ ?c›*)) (*proven 2 subgoals*) . lemma lemma_2_4_7_b: "a r-n→ b = a ^ n r→ b" apply (induct_tac n) (*goals: 1. ‹a r-0→ b = a ^ 0 r→ b› 2. ‹⋀n. a r-n→ b = a ^ n r→ b ⟹ a r-Suc n→ b = a ^ Suc n r→ b› discuss goal 1*) apply (simp add: right_impl_ded [THEN sym] (*‹(?b1::'a) r→ (?a1::'a) r→ (?c1::'a) = ?a1 * ?b1 r→ ?c1›*) power_commutes (*‹(?a::'a) ^ (?n::nat) * ?a = ?a * ?a ^ ?n›*)) (*discuss goal 2*) apply (simp add: right_impl_ded [THEN sym] (*‹?b1 r→ ?a1 r→ ?c1 = ?a1 * ?b1 r→ ?c1›*) power_commutes (*‹?a ^ ?n * ?a = ?a * ?a ^ ?n›*)) (*proven 2 subgoals*) . lemma lemma_2_5_8_a [simp]: "a * b ≤ a" by (rule dual_algebra.H (*‹?b * ?a ≤ ?b›*)) lemma lemma_2_5_8_b [simp]: "a * b ≤ b" by (rule H (*‹?a * ?b ≤ ?b›*)) lemma lemma_2_5_9_a: "a ≤ b l→ a" by (simp add: left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*) dual_algebra.H (*‹?b * ?a ≤ ?b›*)) lemma lemma_2_5_9_b: "a ≤ b r→ a" by (simp add: right_residual [THEN sym] (*‹(?x1 ≤ ?a1 r→ ?b1) = (?a1 * ?x1 ≤ ?b1)›*) H (*‹?a * ?b ≤ ?b›*)) lemma lemma_2_5_11: "a * b ≤ a ⊓ b" by simp lemma lemma_2_5_12_a: "a ≤ b ⟹ c l→ a ≤ c l→ b" apply (subst left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*goal: ‹a ≤ b ⟹ c l→ a ≤ c l→ b›*) apply (subst left_impl_times (*‹(?a l→ ?b) * ?a = (?b l→ ?a) * ?b›*)) (*goal: ‹(a::'a) ≤ (b::'a) ⟹ ((c::'a) l→ a) * c ≤ b›*) apply (rule_tac y = "(a l→ c) * b" in order_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹a ≤ b ⟹ (a l→ c) * a ≤ (a l→ c) * b› 2. ‹a ≤ b ⟹ (a l→ c) * b ≤ b› discuss goal 1*) apply (simp add: mult_left_mono (*‹?a ≤ ?b ⟹ ?c * ?a ≤ ?c * ?b›*)) (*discuss goal 2*) apply (rule H (*‹?a * ?b ≤ ?b›*)) (*proven 2 subgoals*) . lemma lemma_2_5_13_a: "a ≤ b ⟹ b l→ c ≤ a l→ c" apply (simp add: left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*goal: ‹a ≤ b ⟹ b l→ c ≤ a l→ c›*) apply (rule_tac y = "(b l→ c) * b" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹a ≤ b ⟹ (b l→ c) * a ≤ (b l→ c) * b› 2. ‹a ≤ b ⟹ (b l→ c) * b ≤ c› discuss goal 1*) apply (simp add: mult_left_mono (*‹(?a::'a) ≤ (?b::'a) ⟹ (?c::'a) * ?a ≤ ?c * ?b›*)) (*discuss goal 2*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*proven 2 subgoals*) . lemma lemma_2_5_14: "(b l→ c) * (a l→ b) ≤ a l→ c" apply (simp add: left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*goal: ‹(b l→ c) * (a l→ b) ≤ a l→ c›*) apply (simp add: mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*)) (*goal: ‹((b::'a) l→ (c::'a)) * ((a::'a) l→ b) * a ≤ c›*) apply (subst left_impl_times (*‹(?a l→ ?b) * ?a = (?b l→ ?a) * ?b›*)) (*goal: ‹(b l→ c) * ((a l→ b) * a) ≤ c›*) apply (subst mult.assoc [THEN sym] (*‹?a1 * (?b1 * ?c1) = ?a1 * ?b1 * ?c1›*)) (*goal: ‹(b l→ c) * ((b l→ a) * b) ≤ c›*) apply (subst left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*goal: ‹((b::'a) l→ (c::'a)) * (b l→ (a::'a)) * b ≤ c›*) by (rule dual_algebra.H (*‹(?b::'a) * (?a::'a) ≤ ?b›*)) lemma lemma_2_5_16: "(a l→ b) ≤ (b l→ c) r→ (a l→ c)" apply (simp add: right_residual [THEN sym] (*‹(?x1 ≤ ?a1 r→ ?b1) = (?a1 * ?x1 ≤ ?b1)›*)) (*goal: ‹a l→ b ≤ (b l→ c) r→ a l→ c›*) by (rule lemma_2_5_14 (*‹(?b l→ ?c) * (?a l→ ?b) ≤ ?a l→ ?c›*)) lemma lemma_2_5_18: "(a l→ b) ≤ a * c l→ b * c" apply (simp add: left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*goal: ‹a l→ b ≤ a * c l→ b * c›*) apply (subst mult.assoc [THEN sym] (*‹?a1 * (?b1 * ?c1) = ?a1 * ?b1 * ?c1›*)) (*goal: ‹((a::'a::type) l→ (b::'a::type)) * (a * (c::'a::type)) ≤ b * c›*) apply (rule mult_right_mono (*‹?a ≤ ?b ⟹ ?a * ?c ≤ ?b * ?c›*)) (*goal: ‹(a l→ b) * a * c ≤ b * c›*) apply (subst left_impl_times (*‹(?a l→ ?b) * ?a = (?b l→ ?a) * ?b›*)) (*goal: ‹((a::'a) l→ (b::'a)) * a ≤ b›*) by (rule H (*‹(?a::'a) * (?b::'a) ≤ ?b›*)) end context pseudo_hoop_algebra begin lemma lemma_2_5_12_b: "a ≤ b ⟹ c r→ a ≤ c r→ b" by (rule pseudo_hoop_dual.lemma_2_5_12_a (*‹?a ≤ ?b ⟹ ?c r→ ?a ≤ ?c r→ ?b›*)) lemma lemma_2_5_13_b: "a ≤ b ⟹ b r→ c ≤ a r→ c" by (rule pseudo_hoop_dual.lemma_2_5_13_a (*‹(?a::'a) ≤ (?b::'a) ⟹ ?b r→ (?c::'a) ≤ ?a r→ ?c›*)) lemma lemma_2_5_15: "(a r→ b) * (b r→ c) ≤ a r→ c" by (rule pseudo_hoop_dual.lemma_2_5_14 (*‹((?a::'a::type) r→ (?b::'a::type)) * (?b r→ (?c::'a::type)) ≤ ?a r→ ?c›*)) lemma lemma_2_5_17: "(a r→ b) ≤ (b r→ c) l→ (a r→ c)" by (rule pseudo_hoop_dual.lemma_2_5_16 (*‹?a r→ ?b ≤ (?b r→ ?c) l→ ?a r→ ?c›*)) lemma lemma_2_5_19: "(a r→ b) ≤ c * a r→ c * b" by (rule pseudo_hoop_dual.lemma_2_5_18 (*‹?a r→ ?b ≤ ?c * ?a r→ ?c * ?b›*)) definition "lower_bound A = {a . ∀ x ∈ A . a ≤ x}" definition "infimum A = {a ∈ lower_bound A . (∀ x ∈ lower_bound A . x ≤ a)}" lemma infimum_unique: "(infimum A = {x}) = (x ∈ infimum A)" apply safe (*goals: 1. ‹infimum A = {x} ⟹ x ∈ infimum A› 2. ‹⋀xa. ⟦x ∈ infimum A; xa ∈ infimum A; xa ∉ {}⟧ ⟹ xa = x› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⋀xa. ⟦x ∈ infimum A; xa ∈ infimum A; xa ∉ {}⟧ ⟹ xa ≤ x› 2. ‹⋀xa. ⟦x ∈ infimum A; xa ∈ infimum A; xa ∉ {}⟧ ⟹ x ≤ xa› discuss goal 1*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*)) (*discuss goal 2*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lemma_2_6_20: "a ∈ infimum A ⟹ b l→ a ∈ infimum (((l→) b)`A)" apply (subst infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*)) (*goal: ‹a ∈ infimum A ⟹ b l→ a ∈ infimum ((l→) b ` A)›*) apply safe (*goals: 1. ‹a ∈ infimum A ⟹ b l→ a ∈ lower_bound ((l→) b ` A)› 2. ‹⋀x. ⟦a ∈ infimum A; x ∈ lower_bound ((l→) b ` A)⟧ ⟹ x ≤ b l→ a› discuss goal 1*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*) lemma_2_5_12_a (*‹?a ≤ ?b ⟹ ?c l→ ?a ≤ ?c l→ ?b›*)) (*discuss goal 2*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*) left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_6_21: "a ∈ infimum A ⟹ b r→ a ∈ infimum (((r→) b)`A)" by (rule pseudo_hoop_dual.lemma_2_6_20 (*‹?a ∈ infimum ?A ⟹ ?b r→ ?a ∈ infimum ((r→) ?b ` ?A)›*)) lemma infimum_pair: "a ∈ infimum {x . x = b ∨ x = c} = (a = b ⊓ c)" apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*)) (*goal: ‹(a ∈ infimum {x. x = b ∨ x = c}) = (a = b ⊓ c)›*) apply safe (*goals: 1. ‹⟦∀x::'a::type. (x = (b::'a::type) ⟶ (a::'a::type) ≤ b) ∧ (x = (c::'a::type) ⟶ a ≤ c); ∀x::'a::type. (∀xa::'a::type. (xa = b ⟶ x ≤ b) ∧ (xa = c ⟶ x ≤ c)) ⟶ x ≤ a⟧ ⟹ a = b ⊓ c› 2. ‹⋀x::'a::type. (a::'a::type) = (b::'a::type) ⊓ (c::'a::type) ⟹ b ⊓ c ≤ b› 3. ‹⋀x::'a::type. (a::'a::type) = (b::'a::type) ⊓ (c::'a::type) ⟹ b ⊓ c ≤ c› 4. ‹⋀x::'a::type. ⟦(a::'a::type) = (b::'a::type) ⊓ (c::'a::type); ∀xa::'a::type. (xa = b ⟶ x ≤ b) ∧ (xa = c ⟶ x ≤ c)⟧ ⟹ x ≤ b ⊓ c› discuss goal 1*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦∀x. (x = b ⟶ a ≤ b) ∧ (x = c ⟶ a ≤ c); ∀x. (∀xa. (xa = b ⟶ x ≤ b) ∧ (xa = c ⟶ x ≤ c)) ⟶ x ≤ a⟧ ⟹ a ≤ b ⊓ c› 2. ‹⟦∀x. (x = b ⟶ a ≤ b) ∧ (x = c ⟶ a ≤ c); ∀x. (∀xa. (xa = b ⟶ x ≤ b) ∧ (xa = c ⟶ x ≤ c)) ⟶ x ≤ a⟧ ⟹ b ⊓ c ≤ a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . lemma lemma_2_6_20_a: "a l→ (b ⊓ c) = (a l→ b) ⊓ (a l→ c)" apply (subgoal_tac "b ⊓ c ∈ infimum {x . x = b ∨ x = c}") (*goals: 1. ‹b ⊓ c ∈ infimum {x. x = b ∨ x = c} ⟹ a l→ b ⊓ c = (a l→ b) ⊓ (a l→ c)› 2. ‹b ⊓ c ∈ infimum {x. x = b ∨ x = c}› discuss goal 1*) apply (drule_tac b = a in lemma_2_6_20 (*‹?a ∈ infimum ?A ⟹ ?b l→ ?a ∈ infimum ((l→) ?b ` ?A)›*)) (*top goal: ‹(b::'a) ⊓ (c::'a) ∈ infimum {x::'a. x = b ∨ x = c} ⟹ (a::'a) l→ b ⊓ c = (a l→ b) ⊓ (a l→ c)› and 1 goal remains*) apply (case_tac "((l→) a) ` {x . ((x = b) ∨ (x = c))} = {x . x = a l→ b ∨ x = a l→ c}") (*goals: 1. ‹⟦a l→ b ⊓ c ∈ infimum ((l→) a ` {x. x = b ∨ x = c}); (l→) a ` {x. x = b ∨ x = c} = {x. x = a l→ b ∨ x = a l→ c}⟧ ⟹ a l→ b ⊓ c = (a l→ b) ⊓ (a l→ c)› 2. ‹⟦a l→ b ⊓ c ∈ infimum ((l→) a ` {x. x = b ∨ x = c}); (l→) a ` {x. x = b ∨ x = c} ≠ {x. x = a l→ b ∨ x = a l→ c}⟧ ⟹ a l→ b ⊓ c = (a l→ b) ⊓ (a l→ c)› discuss goal 1*) apply (simp add: infimum_pair (*‹(?a ∈ infimum {x. x = ?b ∨ x = ?c}) = (?a = ?b ⊓ ?c)›*)) (*discuss goal 2*) apply (simp add: infimum_pair (*‹(?a ∈ infimum {x. x = ?b ∨ x = ?c}) = (?a = ?b ⊓ ?c)›*)) (*top goal: ‹⟦a l→ b ⊓ c ∈ infimum ((l→) a ` {x. x = b ∨ x = c}); (l→) a ` {x. x = b ∨ x = c} ≠ {x. x = a l→ b ∨ x = a l→ c}⟧ ⟹ a l→ b ⊓ c = (a l→ b) ⊓ (a l→ c)› and 1 goal remains*) apply auto (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: infimum_pair (*‹((?a::'a) ∈ infimum {x::'a. x = (?b::'a) ∨ x = (?c::'a)}) = (?a = ?b ⊓ ?c)›*)) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_6_21_a: "a r→ (b ⊓ c) = (a r→ b) ⊓ (a r→ c)" by (rule pseudo_hoop_dual.lemma_2_6_20_a (*‹(?a::'a) r→ (?b::'a) ⊓ (?c::'a) = (?a r→ ?b) ⊓ (?a r→ ?c)›*)) lemma mult_mono: "a ≤ b ⟹ c ≤ d ⟹ a * c ≤ b * d" apply (rule_tac y = "a * d" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⟦a ≤ b; c ≤ d⟧ ⟹ a * c ≤ a * d› 2. ‹⟦a ≤ b; c ≤ d⟧ ⟹ a * d ≤ b * d› discuss goal 1*) apply (simp add: mult_right_mono (*‹?a ≤ ?b ⟹ ?a * ?c ≤ ?b * ?c›*) mult_left_mono (*‹?a ≤ ?b ⟹ ?c * ?a ≤ ?c * ?b›*)) (*discuss goal 2*) apply (simp add: mult_right_mono (*‹?a ≤ ?b ⟹ ?a * ?c ≤ ?b * ?c›*) mult_left_mono (*‹?a ≤ ?b ⟹ ?c * ?a ≤ ?c * ?b›*)) (*proven 2 subgoals*) . lemma lemma_2_7_22: "(a l→ b) * (c l→ d) ≤ (a ⊓ c) l→ (b ⊓ d)" apply (rule_tac y = "(a ⊓ c l→ b) * (a ⊓ c l→ d)" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹((a::'a) l→ (b::'a)) * ((c::'a) l→ (d::'a)) ≤ (a ⊓ c l→ b) * (a ⊓ c l→ d)› 2. ‹((a::'a) ⊓ (c::'a) l→ (b::'a)) * (a ⊓ c l→ (d::'a)) ≤ a ⊓ c l→ b ⊓ d› discuss goal 1*) apply (rule mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d⟧ ⟹ ?a * ?c ≤ ?b * ?d›*)) (*goals: 1. ‹a l→ b ≤ a ⊓ c l→ b› 2. ‹c l→ d ≤ a ⊓ c l→ d› discuss goal 1*) apply (simp add: lemma_2_5_13_a (*‹(?a::'a::type) ≤ (?b::'a::type) ⟹ ?b l→ (?c::'a::type) ≤ ?a l→ ?c›*)) (*discuss goal 2*) apply (simp add: lemma_2_5_13_a (*‹(?a::'a) ≤ (?b::'a) ⟹ ?b l→ (?c::'a) ≤ ?a l→ ?c›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (rule_tac y = "(a ⊓ c l→ b) ⊓ (a ⊓ c l→ d)" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹(a ⊓ c l→ b) * (a ⊓ c l→ d) ≤ (a ⊓ c l→ b) ⊓ (a ⊓ c l→ d)› 2. ‹(a ⊓ c l→ b) ⊓ (a ⊓ c l→ d) ≤ a ⊓ c l→ b ⊓ d› discuss goal 1*) apply (rule lemma_2_5_11 (*‹(?a::'a::type) * (?b::'a::type) ≤ ?a ⊓ ?b›*)) (*discuss goal 2*) apply (simp add: lemma_2_6_20_a (*‹(?a::'a) l→ (?b::'a) ⊓ (?c::'a) = (?a l→ ?b) ⊓ (?a l→ ?c)›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_7_23: "(a r→ b) * (c r→ d) ≤ (a ⊓ c) r→ (b ⊓ d)" apply (rule_tac y = "(c ⊓ a) r→ (d ⊓ b)" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹(a r→ b) * (c r→ d) ≤ c ⊓ a r→ d ⊓ b› 2. ‹c ⊓ a r→ d ⊓ b ≤ a ⊓ c r→ b ⊓ d› discuss goal 1*) apply (rule pseudo_hoop_dual.lemma_2_7_22 (*‹(?c r→ ?d) * (?a r→ ?b) ≤ ?a ⊓ ?c r→ ?b ⊓ ?d›*)) (*discuss goal 2*) apply (simp add: inf_commute (*‹?x ⊓ ?y = ?y ⊓ ?x›*)) (*proven 2 subgoals*) . definition "upper_bound A = {a . ∀ x ∈ A . x ≤ a}" definition "supremum A = {a ∈ upper_bound A . (∀ x ∈ upper_bound A . a ≤ x)}" lemma supremum_unique: "a ∈ supremum A ⟹ b ∈ supremum A ⟹ a = b" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹⟦a ∈ supremum A; b ∈ supremum A⟧ ⟹ a = b›*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦(∀x::'a∈A::'a set. x ≤ (a::'a)) ∧ (∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ a ≤ x); (∀x::'a∈A. x ≤ (b::'a)) ∧ (∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x)⟧ ⟹ a ≤ b› 2. ‹⟦(∀x::'a∈A::'a set. x ≤ (a::'a)) ∧ (∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ a ≤ x); (∀x::'a∈A. x ≤ (b::'a)) ∧ (∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x)⟧ ⟹ b ≤ a› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma lemma_2_8_i: "a ∈ supremum A ⟹ a l→ b ∈ infimum ((λ x . x l→ b)`A)" apply (subst infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*)) (*goal: ‹a ∈ supremum A ⟹ a l→ b ∈ infimum ((λx. x l→ b) ` A)›*) apply safe (*goals: 1. ‹a ∈ supremum A ⟹ a l→ b ∈ lower_bound ((λx. x l→ b) ` A)› 2. ‹⋀x. ⟦a ∈ supremum A; x ∈ lower_bound ((λx. x l→ b) ` A)⟧ ⟹ x ≤ a l→ b› discuss goal 1*) apply (simp add: supremum_def (*‹supremum (?A::'a set) = {a::'a ∈ upper_bound ?A. ∀x::'a∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound (?A::'a set) = {a::'a. ∀x::'a∈?A. x ≤ a}›*) lower_bound_def (*‹lower_bound (?A::'a set) = {a::'a. ∀x::'a∈?A. a ≤ x}›*) lemma_2_5_13_a (*‹(?a::'a) ≤ (?b::'a) ⟹ ?b l→ (?c::'a) ≤ ?a l→ ?c›*)) (*discuss goal 2*) apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*) left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*goal: ‹⋀x. ⟦a ∈ supremum A; x ∈ lower_bound ((λx. x l→ b) ` A)⟧ ⟹ x ≤ a l→ b›*) apply (simp add: right_residual (*‹(?a * ?x ≤ ?b) = (?x ≤ ?a r→ ?b)›*)) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_8_i1: "a ∈ supremum A ⟹ a r→ b ∈ infimum ((λ x . x r→ b)`A)" by (fact pseudo_hoop_dual.lemma_2_8_i (*‹?a ∈ supremum ?A ⟹ ?a r→ ?b ∈ infimum ((λx. x r→ ?b) ` ?A)›*)) definition times_set :: "'a set ⇒ 'a set ⇒ 'a set" (infixl "**" 70) where "(A ** B) = {a . ∃ x ∈ A . ∃ y ∈ B . a = x * y}" lemma times_set_assoc: "A ** (B ** C) = (A ** B) ** C" apply (simp add: times_set_def (*‹?A ** ?B = {a. ∃x∈?A. ∃y∈?B. a = x * y}›*)) (*goal: ‹A ** (B ** C) = A ** B ** C›*) apply ((safe)[1]) (*goals: 1. ‹⋀x xa y xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ∃x. (∃xa∈A. ∃y∈B. x = xa * y) ∧ (∃y∈C. xa * (xb * ya) = x * y)› 2. ‹⋀x xa xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ ∃x∈A. ∃yb. (∃x∈B. ∃y∈C. yb = x * y) ∧ xb * ya * y = x * yb› discuss goal 1*) apply ((rule_tac x = "xa * xb" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))[1]) (*top goal: ‹⋀(x::'a) (xa::'a) (y::'a) (xb::'a) ya::'a. ⟦xa ∈ (A::'a set); xb ∈ (B::'a set); ya ∈ (C::'a set)⟧ ⟹ ∃x::'a. (∃xa::'a∈A. ∃y::'a∈B. x = xa * y) ∧ (∃y::'a∈C. xa * (xb * ya) = x * y)› and 1 goal remains*) apply ((safe)[1]) (*goals: 1. ‹⋀x xa y xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ∃x∈A. ∃y∈B. xa * xb = x * y› 2. ‹⋀x xa y xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ∃y∈C. xa * (xb * ya) = xa * xb * y› discuss goal 1*) apply ((rule_tac x = xa in bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))[1]) (*goals: 1. ‹⋀x xa y xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ∃y∈B. xa * xb = xa * y› 2. ‹⋀x xa y xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ xa ∈ A› discuss goal 1*) apply ((rule_tac x = xb in bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))[1]) (*goals: 1. ‹⋀(x::'a) (xa::'a) (y::'a) (xb::'a) ya::'a. ⟦xa ∈ (A::'a set); xb ∈ (B::'a set); ya ∈ (C::'a set)⟧ ⟹ xa * xb = xa * xb› 2. ‹⋀(x::'a) (xa::'a) (y::'a) (xb::'a) ya::'a. ⟦xa ∈ (A::'a set); xb ∈ (B::'a set); ya ∈ (C::'a set)⟧ ⟹ xb ∈ B› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*top goal: ‹⋀x xa y xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ∃y∈C. xa * (xb * ya) = xa * xb * y› and 1 goal remains*) apply ((subst mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*))[1]) (*top goal: ‹⋀xa xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ∃y∈C. xa * (xb * ya) = xa * xb * y› and 1 goal remains*) apply ((rule_tac x = ya in bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))[1]) (*goals: 1. ‹⋀xa xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ xa * (xb * ya) = xa * (xb * ya)› 2. ‹⋀xa xb ya. ⟦xa ∈ A; xb ∈ B; ya ∈ C⟧ ⟹ ya ∈ C› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*goal: ‹⋀x xa xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ ∃x∈A. ∃yb. (∃x∈B. ∃y∈C. yb = x * y) ∧ xb * ya * y = x * yb›*) apply ((rule_tac x = xb in bexI (*‹⟦?P ?x; ?x ∈ ?A⟧ ⟹ ∃x∈?A. ?P x›*))[1]) (*goals: 1. ‹⋀xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ ∃yb. (∃x∈B. ∃y∈C. yb = x * y) ∧ xb * ya * y = xb * yb› 2. ‹⋀xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ xb ∈ A› discuss goal 1*) apply ((rule_tac x = "ya * y" in exI (*‹?P ?x ⟹ ∃x. ?P x›*))[1]) (*top goal: ‹⋀xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ ∃yb. (∃x∈B. ∃y∈C. yb = x * y) ∧ xb * ya * y = xb * yb› and 1 goal remains*) apply ((subst mult.assoc (*‹?a * ?b * ?c = ?a * (?b * ?c)›*))[1]) (*top goal: ‹⋀xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ (∃x∈B. ∃yb∈C. ya * y = x * yb) ∧ xb * ya * y = xb * (ya * y)› and 1 goal remains*) apply simp (*top goal: ‹⋀xb y ya. ⟦xb ∈ A; y ∈ C; ya ∈ B⟧ ⟹ (∃x∈B. ∃yb∈C. ya * y = x * yb) ∧ xb * (ya * y) = xb * (ya * y)› and 1 goal remains*) apply ((auto)[1]) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . primrec power_set :: "'a set ⇒ nat ⇒ 'a set" (infixr "*^" 80) where power_set_0: "(A *^ 0) = {1}" | power_set_Suc: "(A *^ (Suc n)) = (A ** (A *^ n))" lemma infimum_singleton [simp]: "infimum {a} = {a}" apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*)) (*goal: ‹infimum {a} = {a}›*) by auto lemma lemma_2_8_ii: "a ∈ supremum A ⟹ (a ^ n) l→ b ∈ infimum ((λ x . x l→ b)`(A *^ n))" apply (induct_tac n) (*goals: 1. ‹a ∈ supremum A ⟹ a ^ 0 l→ b ∈ infimum ((λx. x l→ b) ` (A *^ 0))› 2. ‹⋀n. ⟦a ∈ supremum A; a ^ n l→ b ∈ infimum ((λx. x l→ b) ` (A *^ n))⟧ ⟹ a ^ Suc n l→ b ∈ infimum ((λx. x l→ b) ` (A *^ Suc n))› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: left_impl_ded (*‹(?a::'a) * (?b::'a) l→ (?c::'a) = ?a l→ ?b l→ ?c›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a ^ n l→ b ∈ infimum ((λx. x l→ b) ` (A *^ n))⟧ ⟹ a ^ Suc n l→ b ∈ infimum ((λx. x l→ b) ` (A *^ Suc n))›*) apply (drule_tac a = "a ^ n l→ b" and b = a in lemma_2_6_20 (*‹?a ∈ infimum ?A ⟹ ?b l→ ?a ∈ infimum ((l→) ?b ` ?A)›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a ^ n l→ b ∈ infimum ((λx. x l→ b) ` (A *^ n))⟧ ⟹ a l→ a ^ n l→ b ∈ infimum ((λx. x l→ b) ` (A ** A *^ n))›*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*) times_set_def (*‹?A ** ?B = {a. ∃x∈?A. ∃y∈?B. a = x * y}›*)) (*goal: ‹⋀n::nat. ⟦(a::'a) ∈ supremum (A::'a set); a l→ a ^ n l→ (b::'a) ∈ infimum ((l→) a ` (λx::'a. x l→ b) ` (A *^ n))⟧ ⟹ a l→ a ^ n l→ b ∈ infimum ((λx::'a. x l→ b) ` (A ** A *^ n))›*) apply safe (*goals: 1. ‹⋀n x xa y. ⟦a ∈ supremum A; ∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; xa ∈ A; y ∈ A *^ n⟧ ⟹ a l→ a ^ n l→ b ≤ xa * y l→ b› 2. ‹⋀n x. ⟦a ∈ supremum A; ∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b⟧ ⟹ x ≤ a l→ a ^ n l→ b› discuss goal 1*) apply (drule_tac b = "y l→ b" in lemma_2_8_i (*‹?a ∈ supremum ?A ⟹ ?a l→ ?b ∈ infimum ((λx. x l→ ?b) ` ?A)›*)) (*top goal: ‹⋀(n::nat) (x::'a) (xa::'a) y::'a. ⟦(a::'a) ∈ supremum (A::'a set); ∀x::'a∈A *^ n. a l→ a ^ n l→ (b::'a) ≤ a l→ x l→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; xa ∈ A; y ∈ A *^ n⟧ ⟹ a l→ a ^ n l→ b ≤ xa * y l→ b› and 1 goal remains*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*) times_set_def (*‹?A ** ?B = {a. ∃x∈?A. ∃y∈?B. a = x * y}›*) left_impl_ded (*‹?a * ?b l→ ?c = ?a l→ ?b l→ ?c›*)) (*top goal: ‹⋀n x xa y. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; xa ∈ A; y ∈ A *^ n; a l→ y l→ b ∈ infimum ((λx. x l→ y l→ b) ` A)⟧ ⟹ a l→ a ^ n l→ b ≤ xa * y l→ b› and 1 goal remains*) apply (rule_tac y = "a l→ y l→ b" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀(n::nat) (xa::'a) y::'a. ⟦∀x::'a∈(A::'a set) *^ n. (a::'a) l→ a ^ n l→ (b::'a) ≤ a l→ x l→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; xa ∈ A; y ∈ A *^ n; (∀x::'a∈A. a l→ y l→ b ≤ x l→ y l→ b) ∧ (∀x::'a. (∀xa::'a∈A. x ≤ xa l→ y l→ b) ⟶ x ≤ a l→ y l→ b)⟧ ⟹ a l→ a ^ n l→ b ≤ a l→ y l→ b› 2. ‹⋀(n::nat) (xa::'a) y::'a. ⟦∀x::'a∈(A::'a set) *^ n. (a::'a) l→ a ^ n l→ (b::'a) ≤ a l→ x l→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; xa ∈ A; y ∈ A *^ n; (∀x::'a∈A. a l→ y l→ b ≤ x l→ y l→ b) ∧ (∀x::'a. (∀xa::'a∈A. x ≤ xa l→ y l→ b) ⟶ x ≤ a l→ y l→ b)⟧ ⟹ a l→ y l→ b ≤ xa l→ y l→ b› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (subgoal_tac "(∀xa ∈ A *^ n. x ≤ a l→ xa l→ b)") (*goals: 1. ‹⋀n x. ⟦a ∈ supremum A; ∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; ∀xa∈A *^ n. x ≤ a l→ xa l→ b⟧ ⟹ x ≤ a l→ a ^ n l→ b› 2. ‹⋀n x. ⟦a ∈ supremum A; ∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b⟧ ⟹ ∀xa∈A *^ n. x ≤ a l→ xa l→ b› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀(n::nat) x::'a. ⟦(a::'a) ∈ supremum (A::'a set); ∀x::'a∈A *^ n. a l→ a ^ n l→ (b::'a) ≤ a l→ x l→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa::'a. (∃x::'a∈A. ∃y::'a∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b⟧ ⟹ ∀xa::'a∈A *^ n. x ≤ a l→ xa l→ b›*) apply (drule_tac b = "xa l→ b" in lemma_2_8_i (*‹?a ∈ supremum ?A ⟹ ?a l→ ?b ∈ infimum ((λx. x l→ ?b) ` ?A)›*)) (*goal: ‹⋀n x xa. ⟦a ∈ supremum A; ∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n⟧ ⟹ x ≤ a l→ xa l→ b›*) apply (simp add: infimum_def (*‹infimum (?A::'a::type set) = {a::'a::type ∈ lower_bound ?A. ∀x::'a::type∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound (?A::'a::type set) = {a::'a::type. ∀x::'a::type∈?A. a ≤ x}›*)) (*goal: ‹⋀n x xa. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; a l→ xa l→ b ∈ infimum ((λx. x l→ xa l→ b) ` A)⟧ ⟹ x ≤ a l→ xa l→ b›*) apply safe (*goal: ‹⋀n x xa. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; (∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b) ∧ (∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b)⟧ ⟹ x ≤ a l→ xa l→ b›*) apply (subgoal_tac "(∀xb ∈ A. x ≤ xb l→ xa l→ b)") (*goals: 1. ‹⋀n x xa. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b; ∀xb∈A. x ≤ xb l→ xa l→ b⟧ ⟹ x ≤ a l→ xa l→ b› 2. ‹⋀n x xa. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b⟧ ⟹ ∀xb∈A. x ≤ xb l→ xa l→ b› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀n x xa. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b⟧ ⟹ ∀xb∈A. x ≤ xb l→ xa l→ b›*) apply (subgoal_tac "x ≤ xb * xa l→ b") (*goals: 1. ‹⋀n x xa xb. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b; xb ∈ A; x ≤ xb * xa l→ b⟧ ⟹ x ≤ xb l→ xa l→ b› 2. ‹⋀n x xa xb. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b; xb ∈ A⟧ ⟹ x ≤ xb * xa l→ b› discuss goal 1*) apply (simp add: left_impl_ded (*‹?a * ?b l→ ?c = ?a l→ ?b l→ ?c›*)) (*discuss goal 2*) apply (subgoal_tac "(∃x ∈ A. ∃y ∈ A *^ n. xb * xa = x * y)") (*goals: 1. ‹⋀n x xa xb. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b; xb ∈ A; ∃x∈A. ∃y∈A *^ n. xb * xa = x * y⟧ ⟹ x ≤ xb * xa l→ b› 2. ‹⋀n x xa xb. ⟦∀x∈A *^ n. a l→ a ^ n l→ b ≤ a l→ x l→ b; ∀x. (∀xa∈A *^ n. x ≤ a l→ xa l→ b) ⟶ x ≤ a l→ a ^ n l→ b; ∀xa. (∃x∈A. ∃y∈A *^ n. xa = x * y) ⟶ x ≤ xa l→ b; xa ∈ A *^ n; ∀x∈A. a l→ xa l→ b ≤ x l→ xa l→ b; ∀x. (∀xb∈A. x ≤ xb l→ xa l→ b) ⟶ x ≤ a l→ xa l→ b; xb ∈ A⟧ ⟹ ∃x∈A. ∃y∈A *^ n. xb * xa = x * y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma power_set_Suc2: "A *^ (Suc n) = A *^ n ** A" apply (induct_tac n) (*goals: 1. ‹A *^ Suc 0 = A *^ 0 ** A› 2. ‹⋀n. A *^ Suc n = A *^ n ** A ⟹ A *^ Suc (Suc n) = A *^ Suc n ** A› discuss goal 1*) apply (simp add: times_set_def (*‹?A ** ?B = {a. ∃x∈?A. ∃y∈?B. a = x * y}›*)) (*discuss goal 2*) apply simp (*goal: ‹⋀n. A *^ Suc n = A *^ n ** A ⟹ A *^ Suc (Suc n) = A *^ Suc n ** A›*) apply (subst times_set_assoc (*‹?A ** (?B ** ?C) = ?A ** ?B ** ?C›*)) (*goal: ‹⋀n. A ** A *^ n = A *^ n ** A ⟹ A ** (A *^ n ** A) = A *^ n ** A ** A›*) apply simp (*proven 2 subgoals*) . lemma power_set_add: "A *^ (n + m) = (A *^ n) ** (A *^ m)" apply (induct_tac m) (*goals: 1. ‹A *^ (n + 0) = A *^ n ** A *^ 0› 2. ‹⋀na. A *^ (n + na) = A *^ n ** A *^ na ⟹ A *^ (n + Suc na) = A *^ n ** A *^ Suc na› discuss goal 1*) apply simp (*top goal: ‹A *^ (n + 0) = A *^ n ** A *^ 0› and 1 goal remains*) apply (simp add: times_set_def (*‹?A ** ?B = {a. ∃x∈?A. ∃y∈?B. a = x * y}›*)) (*discuss goal 2*) apply simp (*goal: ‹⋀na. A *^ (n + na) = A *^ n ** A *^ na ⟹ A *^ (n + Suc na) = A *^ n ** A *^ Suc na›*) apply (subst times_set_assoc (*‹?A ** (?B ** ?C) = ?A ** ?B ** ?C›*)) (*goal: ‹⋀na. A *^ (n + na) = A *^ n ** A *^ na ⟹ A ** (A *^ n ** A *^ na) = A *^ n ** (A ** A *^ na)›*) apply (subst times_set_assoc (*‹?A ** (?B ** ?C) = ?A ** ?B ** ?C›*)) (*goal: ‹⋀na. A *^ (n + na) = A *^ n ** A *^ na ⟹ A ** A *^ n ** A *^ na = A *^ n ** (A ** A *^ na)›*) apply (subst power_set_Suc2 [THEN sym] (*‹?A1 *^ ?n1 ** ?A1 = ?A1 *^ Suc ?n1›*)) (*goal: ‹⋀na. A *^ (n + na) = A *^ n ** A *^ na ⟹ A ** A *^ n ** A *^ na = A *^ n ** A ** A *^ na›*) apply simp (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_8_ii1: "a ∈ supremum A ⟹ (a ^ n) r→ b ∈ infimum ((λ x . x r→ b)`(A *^ n))" apply (induct_tac n) (*goals: 1. ‹a ∈ supremum A ⟹ a ^ 0 r→ b ∈ infimum ((λx. x r→ b) ` (A *^ 0))› 2. ‹⋀n. ⟦a ∈ supremum A; a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n))⟧ ⟹ a ^ Suc n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ Suc n))› discuss goal 1*) apply simp (*discuss goal 2*) apply (subst power_Suc2 (*‹?a ^ Suc ?n = ?a ^ ?n * ?a›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n))⟧ ⟹ a ^ Suc n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ Suc n))›*) apply (subst power_set_Suc2 (*‹(?A::'a::type set) *^ Suc (?n::nat) = ?A *^ ?n ** ?A›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n))⟧ ⟹ a ^ n * a r→ b ∈ infimum ((λx. x r→ b) ` (A *^ Suc n))›*) apply (simp add: right_impl_ded (*‹(?a::'a) * (?b::'a) r→ (?c::'a) = ?b r→ ?a r→ ?c›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n))⟧ ⟹ a ^ n * a r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n ** A))›*) apply (drule_tac a = "a ^ n r→ b" and b = a in lemma_2_6_21 (*‹(?a::'a) ∈ infimum (?A::'a set) ⟹ (?b::'a) r→ ?a ∈ infimum ((r→) ?b ` ?A)›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n))⟧ ⟹ a r→ a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n ** A))›*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*) times_set_def (*‹?A ** ?B = {a. ∃x∈?A. ∃y∈?B. a = x * y}›*)) (*goal: ‹⋀n. ⟦a ∈ supremum A; a r→ a ^ n r→ b ∈ infimum ((r→) a ` (λx. x r→ b) ` (A *^ n))⟧ ⟹ a r→ a ^ n r→ b ∈ infimum ((λx. x r→ b) ` (A *^ n ** A))›*) apply safe (*goals: 1. ‹⋀n x xa y. ⟦a ∈ supremum A; ∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; xa ∈ A *^ n; y ∈ A⟧ ⟹ a r→ a ^ n r→ b ≤ xa * y r→ b› 2. ‹⋀n x. ⟦a ∈ supremum A; ∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b⟧ ⟹ x ≤ a r→ a ^ n r→ b› discuss goal 1*) apply (drule_tac b = "xa r→ b" in lemma_2_8_i1 (*‹?a ∈ supremum ?A ⟹ ?a r→ ?b ∈ infimum ((λx. x r→ ?b) ` ?A)›*)) (*top goal: ‹⋀n x xa y. ⟦a ∈ supremum A; ∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; xa ∈ A *^ n; y ∈ A⟧ ⟹ a r→ a ^ n r→ b ≤ xa * y r→ b› and 1 goal remains*) apply (simp add: infimum_def (*‹infimum (?A::'a::type set) = {a::'a::type ∈ lower_bound ?A. ∀x::'a::type∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound (?A::'a::type set) = {a::'a::type. ∀x::'a::type∈?A. a ≤ x}›*) times_set_def (*‹(?A::'a::type set) ** (?B::'a::type set) = {a::'a::type. ∃x::'a::type∈?A. ∃y::'a::type∈?B. a = x * y}›*) right_impl_ded (*‹(?a::'a::type) * (?b::'a::type) r→ (?c::'a::type) = ?b r→ ?a r→ ?c›*)) (*top goal: ‹⋀n x xa y. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; xa ∈ A *^ n; y ∈ A; a r→ xa r→ b ∈ infimum ((λx. x r→ xa r→ b) ` A)⟧ ⟹ a r→ a ^ n r→ b ≤ xa * y r→ b› and 1 goal remains*) apply (rule_tac y = "a r→ xa r→ b" in order_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀n xa y. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; xa ∈ A *^ n; y ∈ A; (∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b) ∧ (∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b)⟧ ⟹ a r→ a ^ n r→ b ≤ a r→ xa r→ b› 2. ‹⋀n xa y. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; xa ∈ A *^ n; y ∈ A; (∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b) ∧ (∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b)⟧ ⟹ a r→ xa r→ b ≤ y r→ xa r→ b› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (subgoal_tac "(∀xa ∈ A *^ n. x ≤ a r→ xa r→ b)") (*goals: 1. ‹⋀(n::nat) x::'a. ⟦(a::'a) ∈ supremum (A::'a set); ∀x::'a∈A *^ n. a r→ a ^ n r→ (b::'a) ≤ a r→ x r→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa::'a. (∃x::'a∈A *^ n. ∃y::'a∈A. xa = x * y) ⟶ x ≤ xa r→ b; ∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b⟧ ⟹ x ≤ a r→ a ^ n r→ b› 2. ‹⋀(n::nat) x::'a. ⟦(a::'a) ∈ supremum (A::'a set); ∀x::'a∈A *^ n. a r→ a ^ n r→ (b::'a) ≤ a r→ x r→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa::'a. (∃x::'a∈A *^ n. ∃y::'a∈A. xa = x * y) ⟶ x ≤ xa r→ b⟧ ⟹ ∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀(n::nat) x::'a. ⟦(a::'a) ∈ supremum (A::'a set); ∀x::'a∈A *^ n. a r→ a ^ n r→ (b::'a) ≤ a r→ x r→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa::'a. (∃x::'a∈A *^ n. ∃y::'a∈A. xa = x * y) ⟶ x ≤ xa r→ b⟧ ⟹ ∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b›*) apply (drule_tac b = "xa r→ b" in lemma_2_8_i1 (*‹?a ∈ supremum ?A ⟹ ?a r→ ?b ∈ infimum ((λx. x r→ ?b) ` ?A)›*)) (*goal: ‹⋀n x xa. ⟦a ∈ supremum A; ∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n⟧ ⟹ x ≤ a r→ xa r→ b›*) apply (simp add: infimum_def (*‹infimum ?A = {a ∈ lower_bound ?A. ∀x∈lower_bound ?A. x ≤ a}›*) lower_bound_def (*‹lower_bound ?A = {a. ∀x∈?A. a ≤ x}›*)) (*goal: ‹⋀n x xa. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; a r→ xa r→ b ∈ infimum ((λx. x r→ xa r→ b) ` A)⟧ ⟹ x ≤ a r→ xa r→ b›*) apply safe (*goal: ‹⋀n x xa. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; (∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b) ∧ (∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b)⟧ ⟹ x ≤ a r→ xa r→ b›*) apply (subgoal_tac "(∀xb ∈ A. x ≤ xb r→ xa r→ b)") (*goals: 1. ‹⋀n x xa. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b; ∀xb∈A. x ≤ xb r→ xa r→ b⟧ ⟹ x ≤ a r→ xa r→ b› 2. ‹⋀n x xa. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b⟧ ⟹ ∀xb∈A. x ≤ xb r→ xa r→ b› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀n x xa. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b⟧ ⟹ ∀xb∈A. x ≤ xb r→ xa r→ b›*) apply (subgoal_tac "x ≤ xa * xb r→ b") (*goals: 1. ‹⋀n x xa xb. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b; xb ∈ A; x ≤ xa * xb r→ b⟧ ⟹ x ≤ xb r→ xa r→ b› 2. ‹⋀n x xa xb. ⟦∀x∈A *^ n. a r→ a ^ n r→ b ≤ a r→ x r→ b; ∀x. (∀xa∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa. (∃x∈A *^ n. ∃y∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x. (∀xb∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b; xb ∈ A⟧ ⟹ x ≤ xa * xb r→ b› discuss goal 1*) apply (simp add: right_impl_ded (*‹?a * ?b r→ ?c = ?b r→ ?a r→ ?c›*)) (*discuss goal 2*) apply (subgoal_tac "(∃x ∈ A *^ n. ∃y ∈ A . xa * xb = x * y)") (*goals: 1. ‹⋀(n::nat) (x::'a) (xa::'a) xb::'a. ⟦∀x::'a∈(A::'a set) *^ n. (a::'a) r→ a ^ n r→ (b::'a) ≤ a r→ x r→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa::'a. (∃x::'a∈A *^ n. ∃y::'a∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x::'a∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x::'a. (∀xb::'a∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b; xb ∈ A; ∃x::'a∈A *^ n. ∃y::'a∈A. xa * xb = x * y⟧ ⟹ x ≤ xa * xb r→ b› 2. ‹⋀(n::nat) (x::'a) (xa::'a) xb::'a. ⟦∀x::'a∈(A::'a set) *^ n. (a::'a) r→ a ^ n r→ (b::'a) ≤ a r→ x r→ b; ∀x::'a. (∀xa::'a∈A *^ n. x ≤ a r→ xa r→ b) ⟶ x ≤ a r→ a ^ n r→ b; ∀xa::'a. (∃x::'a∈A *^ n. ∃y::'a∈A. xa = x * y) ⟶ x ≤ xa r→ b; xa ∈ A *^ n; ∀x::'a∈A. a r→ xa r→ b ≤ x r→ xa r→ b; ∀x::'a. (∀xb::'a∈A. x ≤ xb r→ xa r→ b) ⟶ x ≤ a r→ xa r→ b; xb ∈ A⟧ ⟹ ∃x::'a∈A *^ n. ∃y::'a∈A. xa * xb = x * y› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lemma_2_9_i: "b ∈ supremum A ⟹ a * b ∈ supremum ((*) a ` A)" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹b ∈ supremum A ⟹ a * b ∈ supremum ((*) a ` A)›*) apply safe (*goals: 1. ‹⋀x. ⟦∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; x ∈ A⟧ ⟹ a * x ≤ a * b› 2. ‹⋀x. ⟦∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀xa∈A. a * xa ≤ x⟧ ⟹ a * b ≤ x› discuss goal 1*) apply (simp add: mult_left_mono (*‹?a ≤ ?b ⟹ ?c * ?a ≤ ?c * ?b›*)) (*discuss goal 2*) apply (simp add: right_residual (*‹(?a * ?x ≤ ?b) = (?x ≤ ?a r→ ?b)›*)) (*proven 2 subgoals*) . lemma lemma_2_9_i1: "b ∈ supremum A ⟹ b * a ∈ supremum ((λ x . x * a) ` A)" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹b ∈ supremum A ⟹ b * a ∈ supremum ((λx. x * a) ` A)›*) apply safe (*goals: 1. ‹⋀x. ⟦∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; x ∈ A⟧ ⟹ x * a ≤ b * a› 2. ‹⋀x. ⟦∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀xa∈A. xa * a ≤ x⟧ ⟹ b * a ≤ x› discuss goal 1*) apply (simp add: mult_right_mono (*‹?a ≤ ?b ⟹ ?a * ?c ≤ ?b * ?c›*)) (*discuss goal 2*) apply (simp add: left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*proven 2 subgoals*) . lemma lemma_2_9_ii: "b ∈ supremum A ⟹ a ⊓ b ∈ supremum ((⊓) a ` A)" apply (subst supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*)) (*goal: ‹b ∈ supremum A ⟹ a ⊓ b ∈ supremum ((⊓) a ` A)›*) apply safe (*goals: 1. ‹b ∈ supremum A ⟹ a ⊓ b ∈ upper_bound ((⊓) a ` A)› 2. ‹⋀x. ⟦b ∈ supremum A; x ∈ upper_bound ((⊓) a ` A)⟧ ⟹ a ⊓ b ≤ x› discuss goal 1*) apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*top goal: ‹b ∈ supremum A ⟹ a ⊓ b ∈ upper_bound ((⊓) a ` A)› and 1 goal remains*) apply safe (*top goal: ‹(∀x∈A. x ≤ b) ∧ (∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x) ⟹ ∀x∈A. a ⊓ x ≤ b› and 1 goal remains*) apply (rule_tac y = x in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀x. ⟦x ∈ A; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x⟧ ⟹ a ⊓ x ≤ x› 2. ‹⋀x. ⟦x ∈ A; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x⟧ ⟹ x ≤ b› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*goal: ‹⋀x. ⟦b ∈ supremum A; x ∈ upper_bound ((⊓) a ` A)⟧ ⟹ a ⊓ b ≤ x›*) apply (subst inf_commute (*‹(?x::'a::type) ⊓ (?y::'a::type) = ?y ⊓ ?x›*)) (*goal: ‹⋀x. ⟦b ∈ supremum A; x ∈ upper_bound ((⊓) a ` A)⟧ ⟹ a ⊓ b ≤ x›*) apply (subst inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*)) (*goal: ‹⋀x. ⟦b ∈ supremum A; x ∈ upper_bound ((⊓) a ` A)⟧ ⟹ b ⊓ a ≤ x›*) apply (subst left_right_impl_times (*‹((?a::'a) l→ (?b::'a)) * ?a = ?a * (?a r→ ?b)›*)) (*goal: ‹⋀x::'a. ⟦(b::'a) ∈ supremum (A::'a set); x ∈ upper_bound ((⊓) (a::'a) ` A)⟧ ⟹ (b l→ a) * b ≤ x›*) apply (frule_tac a = "(b r→ a)" in lemma_2_9_i1 (*‹?b ∈ supremum ?A ⟹ ?b * ?a ∈ supremum ((λx. x * ?a) ` ?A)›*)) (*goal: ‹⋀x. ⟦b ∈ supremum A; x ∈ upper_bound ((⊓) a ` A)⟧ ⟹ b * (b r→ a) ≤ x›*) apply (simp add: right_residual (*‹(?a * ?x ≤ ?b) = (?x ≤ ?a r→ ?b)›*)) (*goal: ‹⋀x::'a. ⟦(b::'a) ∈ supremum (A::'a set); x ∈ upper_bound ((⊓) (a::'a) ` A); b * (b r→ a) ∈ supremum ((λx::'a. x * (b r→ a)) ` A)⟧ ⟹ b * (b r→ a) ≤ x›*) apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹⋀x. ⟦b ∈ supremum A; x ∈ upper_bound ((⊓) a ` A); b * (b r→ a) ∈ supremum ((λx. x * (b r→ a)) ` A)⟧ ⟹ b r→ a ≤ b r→ x›*) apply (simp add: right_residual (*‹(?a * ?x ≤ ?b) = (?x ≤ ?a r→ ?b)›*)) (*goal: ‹⋀x. ⟦(∀x∈A. x ≤ b) ∧ (∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x); ∀xa∈A. a ⊓ xa ≤ x; (∀x∈A. x * (b r→ a) ≤ b * (b r→ a)) ∧ (∀x. (∀xa∈A. xa * (b r→ a) ≤ x) ⟶ b * (b r→ a) ≤ x)⟧ ⟹ b r→ a ≤ b r→ x›*) apply safe (*goal: ‹⋀x::'a. ⟦(∀x::'a∈A::'a set. x ≤ (b::'a)) ∧ (∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x); ∀xa::'a∈A. (a::'a) ⊓ xa ≤ x; (∀x::'a∈A. b r→ a ≤ x r→ b * (b r→ a)) ∧ (∀x::'a. (∀xa::'a∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x)⟧ ⟹ b r→ a ≤ b r→ x›*) apply (subgoal_tac "(∀xa ∈ A. b r→ a ≤ xa r→ x)") (*goals: 1. ‹⋀x::'a. ⟦∀xa::'a∈A::'a set. (a::'a) ⊓ xa ≤ x; ∀x::'a∈A. x ≤ (b::'a); ∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x; ∀x::'a∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x::'a. (∀xa::'a∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; ∀xa::'a∈A. b r→ a ≤ xa r→ x⟧ ⟹ b r→ a ≤ b r→ x› 2. ‹⋀x::'a. ⟦∀xa::'a∈A::'a set. (a::'a) ⊓ xa ≤ x; ∀x::'a∈A. x ≤ (b::'a); ∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x; ∀x::'a∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x::'a. (∀xa::'a∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x⟧ ⟹ ∀xa::'a∈A. b r→ a ≤ xa r→ x› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀x. ⟦∀xa∈A. a ⊓ xa ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x⟧ ⟹ ∀xa∈A. b r→ a ≤ xa r→ x›*) apply (simp add: inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*)) (*goal: ‹⋀x xa. ⟦∀xa∈A. a ⊓ xa ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ b r→ a ≤ xa r→ x›*) apply (simp add: left_right_impl_times (*‹(?a l→ ?b) * ?a = ?a * (?a r→ ?b)›*)) (*goal: ‹⋀x xa. ⟦∀xa∈A. (a l→ xa) * a ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ b r→ a ≤ xa r→ x›*) apply (rule_tac y = "xa r→ b * (b r→ a)" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀(x::'a) xa::'a. ⟦∀xa::'a∈A::'a set. (a::'a) * (a r→ xa) ≤ x; ∀x::'a∈A. x ≤ (b::'a); ∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x; ∀x::'a∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x::'a. (∀xa::'a∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ b r→ a ≤ xa r→ b * (b r→ a)› 2. ‹⋀(x::'a) xa::'a. ⟦∀xa::'a∈A::'a set. (a::'a) * (a r→ xa) ≤ x; ∀x::'a∈A. x ≤ (b::'a); ∀x::'a. (∀xa::'a∈A. xa ≤ x) ⟶ b ≤ x; ∀x::'a∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x::'a. (∀xa::'a∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ xa r→ b * (b r→ a) ≤ xa r→ x› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule lemma_2_5_12_b (*‹?a ≤ ?b ⟹ ?c r→ ?a ≤ ?c r→ ?b›*)) (*goal: ‹⋀x xa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ xa r→ b * (b r→ a) ≤ xa r→ x›*) apply (subst left_residual (*‹(?x * ?a ≤ ?b) = (?x ≤ ?a l→ ?b)›*)) (*goal: ‹⋀x xa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ b * (b r→ a) ≤ x›*) apply (subgoal_tac "(∀xa∈A. xa ≤ (b r→ a) l→ x)") (*goals: 1. ‹⋀x xa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; ∀xa∈A. xa ≤ (b r→ a) l→ x⟧ ⟹ b ≤ (b r→ a) l→ x› 2. ‹⋀x xa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ ∀xa∈A. xa ≤ (b r→ a) l→ x› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀x xa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A⟧ ⟹ ∀xa∈A. xa ≤ (b r→ a) l→ x›*) apply (subst left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*goal: ‹⋀x xa xaa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; xaa ∈ A⟧ ⟹ xaa ≤ (b r→ a) l→ x›*) apply (rule_tac y = "xaa * (xaa r→ a)" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀x xa xaa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; xaa ∈ A⟧ ⟹ xaa * (b r→ a) ≤ xaa * (xaa r→ a)› 2. ‹⋀x xa xaa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; xaa ∈ A⟧ ⟹ xaa * (xaa r→ a) ≤ x› discuss goal 1*) apply (rule mult_left_mono (*‹?a ≤ ?b ⟹ ?c * ?a ≤ ?c * ?b›*)) (*top goal: ‹⋀x xa xaa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; xaa ∈ A⟧ ⟹ xaa * (b r→ a) ≤ xaa * (xaa r→ a)› and 1 goal remains*) apply (rule lemma_2_5_13_b (*‹?a ≤ ?b ⟹ ?b r→ ?c ≤ ?a r→ ?c›*)) (*top goal: ‹⋀x xa xaa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; xaa ∈ A⟧ ⟹ b r→ a ≤ xaa r→ a› and 1 goal remains*) apply simp (*discuss goal 2*) apply (subst right_impl_times (*‹?a * (?a r→ ?b) = ?b * (?b r→ ?a)›*)) (*goal: ‹⋀x xa xaa. ⟦∀xa∈A. a * (a r→ xa) ≤ x; ∀x∈A. x ≤ b; ∀x. (∀xa∈A. xa ≤ x) ⟶ b ≤ x; ∀x∈A. b r→ a ≤ x r→ b * (b r→ a); ∀x. (∀xa∈A. b r→ a ≤ xa r→ x) ⟶ b r→ a ≤ b r→ x; xa ∈ A; xaa ∈ A⟧ ⟹ xaa * (xaa r→ a) ≤ x›*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lemma_2_10_24: "a ≤ (a l→ b) r→ b" by (simp add: right_residual [THEN sym] (*‹(?x1 ≤ ?a1 r→ ?b1) = (?a1 * ?x1 ≤ ?b1)›*) inf_l_def [THEN sym] (*‹(?a1 l→ ?b1) * ?a1 = ?a1 ⊓ ?b1›*)) lemma lemma_2_10_25: "a ≤ (a l→ b) r→ a" by (rule lemma_2_5_9_b (*‹?a ≤ ?b r→ ?a›*)) end context pseudo_hoop_algebra begin lemma lemma_2_10_26: "a ≤ (a r→ b) l→ b" by (rule pseudo_hoop_dual.lemma_2_10_24 (*‹?a ≤ (?a r→ ?b) l→ ?b›*)) lemma lemma_2_10_27: "a ≤ (a r→ b) l→ a" by (rule lemma_2_5_9_a (*‹(?a::'a::type) ≤ (?b::'a::type) l→ ?a›*)) lemma lemma_2_10_28: "b l→ ((a l→ b) r→ a) = b l→ a" apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹(b::'a) l→ ((a::'a) l→ b) r→ a ≤ b l→ a› 2. ‹(b::'a) l→ (a::'a) ≤ b l→ (a l→ b) r→ a› discuss goal 1*) apply (subst left_residual [THEN sym] (*‹(?x1 ≤ ?a1 l→ ?b1) = (?x1 * ?a1 ≤ ?b1)›*)) (*top goal: ‹b l→ (a l→ b) r→ a ≤ b l→ a› and 1 goal remains*) apply (rule_tac y = "((a l→ b) r→ a) ⊓ a" in order_trans (*‹⟦(?x::'a) ≤ (?y::'a); ?y ≤ (?z::'a)⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹(b l→ (a l→ b) r→ a) * b ≤ ((a l→ b) r→ a) ⊓ a› 2. ‹((a l→ b) r→ a) ⊓ a ≤ a› discuss goal 1*) apply (subst inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*)) (*top goal: ‹(b l→ (a l→ b) r→ a) * b ≤ ((a l→ b) r→ a) ⊓ a› and 2 goals remain*) apply (rule_tac y = "(((a l→ b) r→ a) l→ b) * ((a l→ b) r→ a)" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹(b l→ (a l→ b) r→ a) * b ≤ (((a l→ b) r→ a) l→ b) * ((a l→ b) r→ a)› 2. ‹(((a l→ b) r→ a) l→ b) * ((a l→ b) r→ a) ≤ (((a l→ b) r→ a) l→ a) * ((a l→ b) r→ a)› discuss goal 1*) apply (subst left_impl_times (*‹(?a l→ ?b) * ?a = (?b l→ ?a) * ?b›*)) (*top goal: ‹(b l→ (a l→ b) r→ a) * b ≤ (((a l→ b) r→ a) l→ b) * ((a l→ b) r→ a)› and 3 goals remain*) apply simp (*discuss goal 2*) apply (rule mult_right_mono (*‹?a ≤ ?b ⟹ ?a * ?c ≤ ?b * ?c›*)) (*top goal: ‹(((a l→ b) r→ a) l→ b) * ((a l→ b) r→ a) ≤ (((a l→ b) r→ a) l→ a) * ((a l→ b) r→ a)› and 2 goals remain*) apply (rule_tac y = "a l→ b" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹((a l→ b) r→ a) l→ b ≤ a l→ b› 2. ‹a l→ b ≤ ((a l→ b) r→ a) l→ a› discuss goal 1*) apply (rule lemma_2_5_13_a (*‹?a ≤ ?b ⟹ ?b l→ ?c ≤ ?a l→ ?c›*)) (*top goal: ‹((a l→ b) r→ a) l→ b ≤ a l→ b› and 3 goals remain*) apply (fact lemma_2_10_25 (*‹(?a::'a) ≤ (?a l→ (?b::'a)) r→ ?a›*)) (*discuss goal 2*) apply (fact lemma_2_10_26 (*‹(?a::'a) ≤ (?a r→ (?b::'a)) l→ ?b›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (rule lemma_2_5_12_a (*‹(?a::'a) ≤ (?b::'a) ⟹ (?c::'a) l→ ?a ≤ ?c l→ ?b›*)) (*goal: ‹b l→ a ≤ b l→ (a l→ b) r→ a›*) apply (fact lemma_2_10_25 (*‹?a ≤ (?a l→ ?b) r→ ?a›*)) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_10_29: "b r→ ((a r→ b) l→ a) = b r→ a" by (rule pseudo_hoop_dual.lemma_2_10_28 (*‹(?b::'a) r→ ((?a::'a) r→ ?b) l→ ?a = ?b r→ ?a›*)) lemma lemma_2_10_30: "((b l→ a) r→ a) l→ a = b l→ a" apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹((b l→ a) r→ a) l→ a ≤ b l→ a› 2. ‹b l→ a ≤ ((b l→ a) r→ a) l→ a› discuss goal 1*) apply (rule lemma_2_5_13_a (*‹(?a::'a) ≤ (?b::'a) ⟹ ?b l→ (?c::'a) ≤ ?a l→ ?c›*)) (*top goal: ‹((b l→ a) r→ a) l→ a ≤ b l→ a› and 1 goal remains*) apply (rule lemma_2_10_24 (*‹(?a::'a) ≤ (?a l→ (?b::'a)) r→ ?b›*)) (*discuss goal 2*) apply (simp add: lemma_2_10_26 (*‹?a ≤ (?a r→ ?b) l→ ?b›*)) (*proven 2 subgoals*) . end context pseudo_hoop_algebra begin lemma lemma_2_10_31: "((b r→ a) l→ a) r→ a = b r→ a" by (rule pseudo_hoop_dual.lemma_2_10_30 (*‹(((?b::'a::type) r→ (?a::'a::type)) l→ ?a) r→ ?a = ?b r→ ?a›*)) lemma lemma_2_10_32: "(((b l→ a) r→ a) l→ b) l→ (b l→ a) = b l→ a" proof (-) (*goal: ‹(((b l→ a) r→ a) l→ b) l→ b l→ a = b l→ a›*) have "((((b l→ a) r→ a) l→ b) l→ (b l→ a) = (((b l→ a) r→ a) l→ b) l→ (((b l→ a) r→ a) l→ a))" by (simp add: lemma_2_10_30 (*‹(((?b::'a::type) l→ (?a::'a::type)) r→ ?a) l→ ?a = ?b l→ ?a›*)) also (*calculation: ‹(((b l→ a) r→ a) l→ b) l→ b l→ a = (((b l→ a) r→ a) l→ b) l→ ((b l→ a) r→ a) l→ a›*) have "… = ((((b l→ a) r→ a) l→ b) * ((b l→ a) r→ a) l→ a)" by (simp add: left_impl_ded (*‹?a * ?b l→ ?c = ?a l→ ?b l→ ?c›*)) also (*calculation: ‹(((b l→ a) r→ a) l→ b) l→ b l→ a = (((b l→ a) r→ a) l→ b) * ((b l→ a) r→ a) l→ a›*) have "… = (((b l→ a) r→ a) ⊓ b) l→ a" by (simp add: inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*)) also (*calculation: ‹(((b l→ a) r→ a) l→ b) l→ b l→ a = ((b l→ a) r→ a) ⊓ b l→ a›*) have "… = b l→ a" apply (subgoal_tac "((b l→ a) r→ a) ⊓ b = b") (*goals: 1. ‹((b l→ a) r→ a) ⊓ b = b ⟹ ((b l→ a) r→ a) ⊓ b l→ a = b l→ a› 2. ‹((b l→ a) r→ a) ⊓ b = b› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹((b l→ a) r→ a) ⊓ b ≤ b› 2. ‹b ≤ ((b l→ a) r→ a) ⊓ b› discuss goal 1*) apply (simp add: lemma_2_10_24 (*‹?a ≤ (?a l→ ?b) r→ ?b›*)) (*discuss goal 2*) apply (simp add: lemma_2_10_24 (*‹?a ≤ (?a l→ ?b) r→ ?b›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) . finally (*calculation: ‹(((b l→ a) r→ a) l→ b) l→ b l→ a = b l→ a›*) show "?thesis" (*goal: ‹(((b l→ a) r→ a) l→ b) l→ b l→ a = b l→ a›*) . qed end context pseudo_hoop_algebra begin lemma lemma_2_10_33: "(((b r→ a) l→ a) r→ b) r→ (b r→ a) = b r→ a" by (rule pseudo_hoop_dual.lemma_2_10_32 (*‹(((?b r→ ?a) l→ ?a) r→ ?b) r→ ?b r→ ?a = ?b r→ ?a›*)) end class pseudo_hoop_sup_algebra = pseudo_hoop_algebra + sup + assumes sup_comute: "a ⊔ b = b ⊔ a" and sup_le [simp]: "a ≤ a ⊔ b" and le_sup_equiv: "(a ≤ b) = (a ⊔ b = b)" begin lemma sup_le_2 [simp]: "b ≤ a ⊔ b" apply (subst sup_comute (*‹?a ⊔ ?b = ?b ⊔ ?a›*)) (*goal: ‹(b::'a::type) ≤ (a::'a::type) ⊔ b›*) by simp lemma le_sup_equiv_r: "(a ⊔ b = b) = (a ≤ b)" by (simp add: le_sup_equiv (*‹(?a ≤ ?b) = (?a ⊔ ?b = ?b)›*)) lemma sup_idemp [simp]: "a ⊔ a = a" by (simp add: le_sup_equiv_r (*‹(?a ⊔ ?b = ?b) = (?a ≤ ?b)›*)) end class pseudo_hoop_sup1_algebra = pseudo_hoop_algebra + sup + assumes sup_def: "a ⊔ b = ((a l→ b) r→ b) ⊓ ((b l→ a) r→ a)" begin lemma sup_comute1: "a ⊔ b = b ⊔ a" apply (simp add: sup_def (*‹?a ⊔ ?b = ((?a l→ ?b) r→ ?b) ⊓ ((?b l→ ?a) r→ ?a)›*)) (*goal: ‹a ⊔ b = b ⊔ a›*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹((a l→ b) r→ b) ⊓ ((b l→ a) r→ a) ≤ ((b l→ a) r→ a) ⊓ ((a l→ b) r→ b)› 2. ‹((b l→ a) r→ a) ⊓ ((a l→ b) r→ b) ≤ ((a l→ b) r→ b) ⊓ ((b l→ a) r→ a)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma sup_le1 [simp]: "a ≤ a ⊔ b" by (simp add: sup_def (*‹?a ⊔ ?b = ((?a l→ ?b) r→ ?b) ⊓ ((?b l→ ?a) r→ ?a)›*) lemma_2_10_24 (*‹?a ≤ (?a l→ ?b) r→ ?b›*) lemma_2_5_9_b (*‹?a ≤ ?b r→ ?a›*)) lemma le_sup_equiv1: "(a ≤ b) = (a ⊔ b = b)" apply safe (*goals: 1. ‹a ≤ b ⟹ a ⊔ b = b› 2. ‹a ⊔ b = b ⟹ a ≤ b› discuss goal 1*) apply (simp add: left_lesseq (*‹(?a ≤ ?b) = (?a l→ ?b = 1)›*)) (*top goal: ‹a ≤ b ⟹ a ⊔ b = b› and 1 goal remains*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹a l→ b = 1 ⟹ a ⊔ b ≤ b› 2. ‹a l→ b = 1 ⟹ b ≤ a ⊔ b› discuss goal 1*) apply (simp add: sup_def (*‹?a ⊔ ?b = ((?a l→ ?b) r→ ?b) ⊓ ((?b l→ ?a) r→ ?a)›*)) (*discuss goal 2*) apply (simp add: sup_def (*‹?a ⊔ ?b = ((?a l→ ?b) r→ ?b) ⊓ ((?b l→ ?a) r→ ?a)›*)) (*top goal: ‹(a::'a::type) l→ (b::'a::type) = (1::'a::type) ⟹ b ≤ a ⊔ b› and 1 goal remains*) apply (simp add: lemma_2_10_24 (*‹?a ≤ (?a l→ ?b) r→ ?b›*)) (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: le_iff_inf (*‹(?x ≤ ?y) = (?x ⊓ ?y = ?x)›*)) (*goal: ‹a ⊔ b = b ⟹ a ≤ b›*) apply (subgoal_tac "(a ⊓ b = a ⊓ (a ⊔ b)) ∧ (a ⊓ (a ⊔ b) = a)") (*goals: 1. ‹⟦a ⊔ b = b; a ⊓ b = a ⊓ (a ⊔ b) ∧ a ⊓ (a ⊔ b) = a⟧ ⟹ a ⊓ b = a› 2. ‹a ⊔ b = b ⟹ a ⊓ b = a ⊓ (a ⊔ b) ∧ a ⊓ (a ⊔ b) = a› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goals: 1. ‹a ⊔ b = b ⟹ a ⊓ b = a ⊓ (a ⊔ b)› 2. ‹a ⊔ b = b ⟹ a ⊓ (a ⊔ b) = a› discuss goal 1*) apply simp (*discuss goal 2*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹a ⊔ b = b ⟹ a ⊓ (a ⊔ b) ≤ a› 2. ‹a ⊔ b = b ⟹ a ≤ a ⊓ (a ⊔ b)› discuss goal 1*) apply simp (*discuss goal 2*) apply (drule drop_assumption (*‹?p ⟹ True›*)) (*goal: ‹a ⊔ b = b ⟹ a ≤ a ⊓ (a ⊔ b)›*) apply (simp add: sup_comute1 (*‹?a ⊔ ?b = ?b ⊔ ?a›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . subclass pseudo_hoop_sup_algebra apply unfold_locales apply (simp add: sup_comute1) apply simp by (simp add: le_sup_equiv1) end class pseudo_hoop_sup2_algebra = pseudo_hoop_algebra + sup + assumes sup_2_def: "a ⊔ b = ((a r→ b) l→ b) ⊓ ((b r→ a) l→ a)" context pseudo_hoop_sup1_algebra begin end sublocale pseudo_hoop_sup2_algebra < sup1_dual: pseudo_hoop_sup1_algebra "(⊔)" "λ a b . b * a" "(⊓)" "(r→)" "(≤)" "(<)" 1 "(l→)" apply unfold_locales (*goal: ‹class.pseudo_hoop_sup1_algebra (⊔) (λa b. b * a) (⊓) (r→) (≤) (<) 1 (l→)›*) by (simp add: sup_2_def (*‹(?a::'a::type) ⊔ (?b::'a::type) = ((?a r→ ?b) l→ ?b) ⊓ ((?b r→ ?a) l→ ?a)›*)) context pseudo_hoop_sup2_algebra begin lemma sup_comute_2: "a ⊔ b = b ⊔ a" by (rule sup1_dual.sup_comute (*‹?a ⊔ ?b = ?b ⊔ ?a›*)) lemma sup_le2 [simp]: "a ≤ a ⊔ b" by (rule sup1_dual.sup_le (*‹(?a::'a) ≤ ?a ⊔ (?b::'a)›*)) lemma le_sup_equiv2: "(a ≤ b) = (a ⊔ b = b)" by (rule sup1_dual.le_sup_equiv (*‹(?a ≤ ?b) = (?a ⊔ ?b = ?b)›*)) subclass pseudo_hoop_sup_algebra apply unfold_locales apply (simp add: sup_comute_2) apply simp by (simp add: le_sup_equiv2) end class pseudo_hoop_lattice_a = pseudo_hoop_sup_algebra + assumes sup_inf_le_distr: "a ⊔ (b ⊓ c) ≤ (a ⊔ b) ⊓ (a ⊔ c)" begin lemma sup_lower_upper_bound [simp]: "a ≤ c ⟹ b ≤ c ⟹ a ⊔ b ≤ c" apply ((subst le_iff_inf (*‹(?x ≤ ?y) = (?x ⊓ ?y = ?x)›*))[1]) (*goal: ‹⟦a ≤ c; b ≤ c⟧ ⟹ a ⊔ b ≤ c›*) apply ((subgoal_tac "(a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ (b ⊓ c) ≤ (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ (b ⊓ c) = a ⊔ b")[1]) (*goals: 1. ‹⟦a ≤ c; b ≤ c; (a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c ≤ (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c = a ⊔ b⟧ ⟹ (a ⊔ b) ⊓ c = a ⊔ b› 2. ‹⟦a ≤ c; b ≤ c⟧ ⟹ (a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c ≤ (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c = a ⊔ b› discuss goal 1*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦a ≤ c; b ≤ c; (a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c ≤ (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c = a ⊔ b⟧ ⟹ (a ⊔ b) ⊓ c ≤ a ⊔ b› 2. ‹⟦a ≤ c; b ≤ c; (a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c ≤ (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c = a ⊔ b⟧ ⟹ a ⊔ b ≤ (a ⊔ b) ⊓ c› discuss goal 1*) apply simp (*discuss goal 2*) apply ((safe)[1]) (*top goal: ‹⟦a ≤ c; b ≤ c; (a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c ≤ (a ⊔ b) ⊓ (a ⊔ c) ∧ a ⊔ b ⊓ c = a ⊔ b⟧ ⟹ a ⊔ b ≤ (a ⊔ b) ⊓ c› and 1 goal remains*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((safe)[1]) (*goals: 1. ‹⟦a ≤ c; b ≤ c⟧ ⟹ (a ⊔ b) ⊓ c = (a ⊔ b) ⊓ (a ⊔ c)› 2. ‹⟦a ≤ c; b ≤ c⟧ ⟹ a ⊔ b ⊓ c ≤ (a ⊔ b) ⊓ (a ⊔ c)› 3. ‹⟦a ≤ c; b ≤ c⟧ ⟹ a ⊔ b ⊓ c = a ⊔ b› discuss goal 1*) apply (simp add: le_sup_equiv (*‹(?a ≤ ?b) = (?a ⊔ ?b = ?b)›*)) (*discuss goal 2*) apply (rule sup_inf_le_distr (*‹?a ⊔ ?b ⊓ ?c ≤ (?a ⊔ ?b) ⊓ (?a ⊔ ?c)›*)) (*discuss goal 3*) apply (simp add: le_iff_inf (*‹(?x ≤ ?y) = (?x ⊓ ?y = ?x)›*)) (*proven 3 subgoals*) (*proven 2 subgoals*) . end sublocale pseudo_hoop_lattice_a < lattice "(⊓)" "(≤)" "(<)" "(⊔)" apply unfold_locales (*goals: 1. ‹⋀x y. x ≤ x ⊔ y› 2. ‹⋀y x. y ≤ x ⊔ y› 3. ‹⋀y x z. ⟦y ≤ x; z ≤ x⟧ ⟹ y ⊔ z ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . class pseudo_hoop_lattice_b = pseudo_hoop_sup_algebra + assumes le_sup_cong: "a ≤ b ⟹ a ⊔ c ≤ b ⊔ c" begin lemma sup_lower_upper_bound_b [simp]: "a ≤ c ⟹ b ≤ c ⟹ a ⊔ b ≤ c" proof (-) (*goal: ‹⟦a ≤ c; b ≤ c⟧ ⟹ a ⊔ b ≤ c›*) assume A: "a ≤ c" (*‹(a::'a) ≤ (c::'a)›*) assume B: "b ≤ c" (*‹(b::'a) ≤ (c::'a)›*) have "a ⊔ b ≤ c ⊔ b" apply (cut_tac A (*‹a ≤ c›*)) (*goal: ‹(a::'a) ⊔ (b::'a) ≤ (c::'a) ⊔ b›*) by (simp add: le_sup_cong (*‹?a ≤ ?b ⟹ ?a ⊔ ?c ≤ ?b ⊔ ?c›*)) also (*calculation: ‹a ⊔ b ≤ c ⊔ b›*) have "… = b ⊔ c" by (simp add: sup_comute (*‹(?a::'a) ⊔ (?b::'a) = ?b ⊔ ?a›*)) also (*calculation: ‹a ⊔ b ≤ b ⊔ c›*) have "… ≤ c ⊔ c" apply (cut_tac B (*‹b ≤ c›*)) (*goal: ‹b ⊔ c ≤ c ⊔ c›*) apply (rule le_sup_cong (*‹?a ≤ ?b ⟹ ?a ⊔ ?c ≤ ?b ⊔ ?c›*)) (*goal: ‹b ≤ c ⟹ b ⊔ c ≤ c ⊔ c›*) by simp also (*calculation: ‹(a::'a) ⊔ (b::'a) ≤ (c::'a) ⊔ c›*) have "… = c" by simp finally (*calculation: ‹a ⊔ b ≤ c›*) show "?thesis" (*goal: ‹a ⊔ b ≤ c›*) . qed lemma sup_inf_le_distr_b: "a ⊔ (b ⊓ c) ≤ (a ⊔ b) ⊓ (a ⊔ c)" apply (rule sup_lower_upper_bound_b (*‹⟦?a ≤ ?c; ?b ≤ ?c⟧ ⟹ ?a ⊔ ?b ≤ ?c›*)) (*goals: 1. ‹(a::'a) ≤ (a ⊔ (b::'a)) ⊓ (a ⊔ (c::'a))› 2. ‹(b::'a) ⊓ (c::'a) ≤ ((a::'a) ⊔ b) ⊓ (a ⊔ c)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*goal: ‹(b::'a) ⊓ (c::'a) ≤ ((a::'a) ⊔ b) ⊓ (a ⊔ c)›*) apply safe (*goals: 1. ‹b ⊓ c ≤ a ⊔ b› 2. ‹b ⊓ c ≤ a ⊔ c› discuss goal 1*) apply (subst sup_comute (*‹?a ⊔ ?b = ?b ⊔ ?a›*)) (*top goal: ‹b ⊓ c ≤ a ⊔ b› and 1 goal remains*) apply (rule_tac y = "b" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹b ⊓ c ≤ b› 2. ‹b ≤ b ⊔ a› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (rule_tac y = "c" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹b ⊓ c ≤ c› 2. ‹c ≤ a ⊔ c› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . end context pseudo_hoop_lattice_a begin end sublocale pseudo_hoop_lattice_b < pseudo_hoop_lattice_a "(⊔)" "(*)" "(⊓)" "(l→)" "(≤)" "(<)" 1 "(r→)" apply unfold_locales (*goal: ‹class.pseudo_hoop_lattice_a (⊔) (*) (⊓) (l→) (≤) (<) (1::'a) (r→)›*) by (rule sup_inf_le_distr_b (*‹?a ⊔ ?b ⊓ ?c ≤ (?a ⊔ ?b) ⊓ (?a ⊔ ?c)›*)) class pseudo_hoop_lattice = pseudo_hoop_sup_algebra + assumes sup_assoc_1: "a ⊔ (b ⊔ c) = (a ⊔ b) ⊔ c" begin lemma le_sup_cong_c: "a ≤ b ⟹ a ⊔ c ≤ b ⊔ c" proof (-) (*goal: ‹a ≤ b ⟹ a ⊔ c ≤ b ⊔ c›*) assume A: "a ≤ b" (*‹(a::'a) ≤ (b::'a)›*) have "a ⊔ c ⊔ (b ⊔ c) = a ⊔ (c ⊔ (b ⊔ c))" by (simp add: sup_assoc_1 (*‹?a ⊔ (?b ⊔ ?c) = ?a ⊔ ?b ⊔ ?c›*)) also (*calculation: ‹(a::'a) ⊔ (c::'a) ⊔ ((b::'a) ⊔ c) = a ⊔ (c ⊔ (b ⊔ c))›*) have "… = a ⊔ ((b ⊔ c) ⊔ c)" by (simp add: sup_comute (*‹(?a::'a) ⊔ (?b::'a) = ?b ⊔ ?a›*)) also (*calculation: ‹a ⊔ c ⊔ (b ⊔ c) = a ⊔ (b ⊔ c ⊔ c)›*) have "… = a ⊔ (b ⊔ (c ⊔ c))" by (simp add: sup_assoc_1 [THEN sym] (*‹(?a1::'a) ⊔ (?b1::'a) ⊔ (?c1::'a) = ?a1 ⊔ (?b1 ⊔ ?c1)›*)) also (*calculation: ‹a ⊔ c ⊔ (b ⊔ c) = a ⊔ (b ⊔ (c ⊔ c))›*) have "… = (a ⊔ b) ⊔ c" by (simp add: sup_assoc_1 (*‹(?a::'a::type) ⊔ ((?b::'a::type) ⊔ (?c::'a::type)) = ?a ⊔ ?b ⊔ ?c›*)) also (*calculation: ‹a ⊔ c ⊔ (b ⊔ c) = a ⊔ b ⊔ c›*) have "… = b ⊔ c" apply (cut_tac A (*‹a ≤ b›*)) (*goal: ‹a ⊔ b ⊔ c = b ⊔ c›*) by (simp add: le_sup_equiv (*‹(?a ≤ ?b) = (?a ⊔ ?b = ?b)›*)) finally (*calculation: ‹(a::'a) ⊔ (c::'a) ⊔ ((b::'a) ⊔ c) = b ⊔ c›*) show "?thesis" (*goal: ‹a ⊔ c ≤ b ⊔ c›*) by (simp add: le_sup_equiv (*‹(?a ≤ ?b) = (?a ⊔ ?b = ?b)›*)) qed end sublocale pseudo_hoop_lattice < pseudo_hoop_lattice_b "(⊔)" "(*)" "(⊓)" "(l→)" "(≤)" "(<)" 1 "(r→)" apply unfold_locales (*goal: ‹class.pseudo_hoop_lattice_b (⊔) (*) (⊓) (l→) (≤) (<) 1 (r→)›*) by (rule le_sup_cong_c (*‹?a ≤ ?b ⟹ ?a ⊔ ?c ≤ ?b ⊔ ?c›*)) sublocale pseudo_hoop_lattice < semilattice_sup "(⊔)" "(≤)" "(<)" by (unfold_locales, simp_all) sublocale pseudo_hoop_lattice < lattice "(⊓)" "(≤)" "(<)" "(⊔)" by unfold_locales lemma (in pseudo_hoop_lattice_a) supremum_pair [simp]: "supremum {a, b} = {a ⊔ b}" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹supremum {a, b} = {a ⊔ b}›*) apply safe (*goals: 1. ‹⋀x. ⟦x ∉ {}; a ≤ x; b ≤ x; ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa⟧ ⟹ x = a ⊔ b› 2. ‹⋀x. a ≤ a ⊔ b› 3. ‹⋀x. b ≤ a ⊔ b› 4. ‹⋀x xa. ⟦a ≤ xa; b ≤ xa⟧ ⟹ a ⊔ b ≤ xa› discuss goal 1*) apply simp (*top goal: ‹⋀x. ⟦x ∉ {}; a ≤ x; b ≤ x; ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa⟧ ⟹ x = a ⊔ b› and 3 goals remain*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⋀x. ⟦a ≤ x; b ≤ x; ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa⟧ ⟹ x ≤ a ⊔ b› 2. ‹⋀x. ⟦a ≤ x; b ≤ x; ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa⟧ ⟹ a ⊔ b ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*proven 4 subgoals*) . sublocale pseudo_hoop_lattice < distrib_lattice "(⊓)" "(≤)" "(<)" "(⊔)" apply unfold_locales (*goal: ‹class.distrib_lattice (⊓) (≤) (<) (⊔)›*) apply (rule distrib_imp1 (*‹(⋀x y z. x ⊓ (y ⊔ z) = x ⊓ y ⊔ x ⊓ z) ⟹ ?x ⊔ ?y ⊓ ?z = (?x ⊔ ?y) ⊓ (?x ⊔ ?z)›*)) (*goal: ‹⋀(x::'a) (y::'a) z::'a. x ⊔ y ⊓ z = (x ⊔ y) ⊓ (x ⊔ z)›*) apply (case_tac "xa ⊓ (ya ⊔ za) ∈ supremum ((⊓) xa ` {ya, za})") (*goals: 1. ‹⋀x y z xa ya za. xa ⊓ (ya ⊔ za) ∈ supremum ((⊓) xa ` {ya, za}) ⟹ xa ⊓ (ya ⊔ za) = xa ⊓ ya ⊔ xa ⊓ za› 2. ‹⋀x y z xa ya za. xa ⊓ (ya ⊔ za) ∉ supremum ((⊓) xa ` {ya, za}) ⟹ xa ⊓ (ya ⊔ za) = xa ⊓ ya ⊔ xa ⊓ za› discuss goal 1*) apply (simp add: supremum_pair (*‹supremum {?a, ?b} = {?a ⊔ ?b}›*)) (*discuss goal 2*) apply (erule notE (*‹⟦¬ ?P; ?P⟧ ⟹ ?R›*)) (*goal: ‹⋀(x::'a) (y::'a) (z::'a) (xa::'a) (ya::'a) za::'a. xa ⊓ (ya ⊔ za) ∉ supremum ((⊓) xa ` {ya, za}) ⟹ xa ⊓ (ya ⊔ za) = xa ⊓ ya ⊔ xa ⊓ za›*) apply (rule lemma_2_9_ii (*‹?b ∈ supremum ?A ⟹ ?a ⊓ ?b ∈ supremum ((⊓) ?a ` ?A)›*)) (*goal: ‹⋀(x::'a) (y::'a) (z::'a) (xa::'a) (ya::'a) za::'a. xa ⊓ (ya ⊔ za) ∈ supremum ((⊓) xa ` {ya, za})›*) apply (simp add: supremum_pair (*‹supremum {?a, ?b} = {?a ⊔ ?b}›*)) (*proven 2 subgoals*) . class bounded_semilattice_inf_top = semilattice_inf + order_top begin lemma inf_eq_top_iff [simp]: "(inf x y = top) = (x = top ∧ y = top)" by (simp add: order.eq_iff (*‹(?a = ?b) = (?a ≤ ?b ∧ ?b ≤ ?a)›*)) end sublocale pseudo_hoop_algebra < bounded_semilattice_inf_top "(⊓)" "(≤)" "(<)" "1" apply unfold_locales (*goal: ‹PseudoHoops.class.bounded_semilattice_inf_top (⊓) (≤) (<) 1›*) by simp definition (in pseudo_hoop_algebra) sup1::"'a ⇒ 'a ⇒ 'a" (infixl "⊔1" 70) where "a ⊔1 b = ((a l→ b) r→ b) ⊓ ((b l→ a) r→ a)" sublocale pseudo_hoop_algebra < sup1: pseudo_hoop_sup1_algebra "(⊔1)" "(*)" "(⊓)" "(l→)" "(≤)" "(<)" 1 "(r→)" apply unfold_locales (*goal: ‹class.pseudo_hoop_sup1_algebra (⊔1) (*) (⊓) (l→) (≤) (<) (1::'a) (r→)›*) by (simp add: sup1_def (*‹?a ⊔1 ?b = ((?a l→ ?b) r→ ?b) ⊓ ((?b l→ ?a) r→ ?a)›*)) definition (in pseudo_hoop_algebra) sup2::"'a ⇒ 'a ⇒ 'a" (infixl "⊔2" 70) where "a ⊔2 b = ((a r→ b) l→ b) ⊓ ((b r→ a) l→ a)" sublocale pseudo_hoop_algebra < sup2: pseudo_hoop_sup2_algebra "(⊔2)" "(*)" "(⊓)" "(l→)" "(≤)" "(<)" 1 "(r→)" apply unfold_locales (*goal: ‹class.pseudo_hoop_sup2_algebra (⊔2) (*) (⊓) (l→) (≤) (<) 1 (r→)›*) by (simp add: sup2_def (*‹?a ⊔2 ?b = ((?a r→ ?b) l→ ?b) ⊓ ((?b r→ ?a) l→ ?a)›*)) context pseudo_hoop_algebra begin lemma lemma_2_15_i: "1 ∈ supremum {a, b} ⟹ a * b = a ⊓ b" apply (rule order.antisym (*‹⟦(?a::'a) ≤ (?b::'a); ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹1 ∈ supremum {a, b} ⟹ a * b ≤ a ⊓ b› 2. ‹1 ∈ supremum {a, b} ⟹ a ⊓ b ≤ a * b› discuss goal 1*) apply (rule lemma_2_5_11 (*‹?a * ?b ≤ ?a ⊓ ?b›*)) (*discuss goal 2*) apply (simp add: inf_l_def (*‹?a ⊓ ?b = (?a l→ ?b) * ?a›*)) (*goal: ‹1 ∈ supremum {a, b} ⟹ a ⊓ b ≤ a * b›*) apply (subst left_impl_times (*‹(?a l→ ?b) * ?a = (?b l→ ?a) * ?b›*)) (*goal: ‹1 ∈ supremum {a, b} ⟹ (a l→ b) * a ≤ a * b›*) apply (rule mult_right_mono (*‹?a ≤ ?b ⟹ ?a * ?c ≤ ?b * ?c›*)) (*goal: ‹1 ∈ supremum {a, b} ⟹ (b l→ a) * b ≤ a * b›*) apply (subst right_lesseq (*‹(?a ≤ ?b) = (?a r→ ?b = 1)›*)) (*goal: ‹1 ∈ supremum {a, b} ⟹ b l→ a ≤ a›*) apply (subgoal_tac "a ⊔1 b = 1") (*goals: 1. ‹⟦(1::'a) ∈ supremum {a::'a, b::'a}; a ⊔1 b = (1::'a)⟧ ⟹ (b l→ a) r→ a = (1::'a)› 2. ‹(1::'a) ∈ supremum {a::'a, b::'a} ⟹ a ⊔1 b = (1::'a)› discuss goal 1*) apply (simp add: sup1_def (*‹(?a::'a) ⊔1 (?b::'a) = ((?a l→ ?b) r→ ?b) ⊓ ((?b l→ ?a) r→ ?a)›*)) (*discuss goal 2*) apply (rule order.antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹(1::'a) ∈ supremum {a::'a, b::'a} ⟹ a ⊔1 b ≤ (1::'a)› 2. ‹(1::'a) ∈ supremum {a::'a, b::'a} ⟹ (1::'a) ≤ a ⊔1 b› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lemma_2_15_ii: "1 ∈ supremum {a, b} ⟹ a ≤ c ⟹ b ≤ d ⟹ 1 ∈ supremum {c, d}" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹⟦1 ∈ supremum {a, b}; a ≤ c; b ≤ d⟧ ⟹ 1 ∈ supremum {c, d}›*) apply safe (*goal: ‹⟦∀x. a ≤ x ∧ b ≤ x ⟶ 1 ≤ x; a ≤ c; b ≤ d⟧ ⟹ ∀x. c ≤ x ∧ d ≤ x ⟶ 1 ≤ x›*) apply (drule_tac x = x in spec (*‹∀x::?'a. (?P::?'a ⇒ bool) x ⟹ ?P (?x::?'a)›*)) (*goal: ‹⋀x. ⟦∀x. a ≤ x ∧ b ≤ x ⟶ 1 ≤ x; a ≤ c; b ≤ d; c ≤ x; d ≤ x⟧ ⟹ 1 ≤ x›*) apply safe (*goals: 1. ‹⋀x. ⟦a ≤ c; b ≤ d; c ≤ x; d ≤ x; ¬ 1 ≤ x⟧ ⟹ a ≤ x› 2. ‹⋀x. ⟦a ≤ c; b ≤ d; c ≤ x; d ≤ x; ¬ 1 ≤ x⟧ ⟹ b ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma sup_union: "a ∈ supremum A ⟹ b ∈ supremum B ⟹ supremum {a, b} = supremum (A ∪ B)" apply safe (*goals: 1. ‹⋀x::'a. ⟦(a::'a) ∈ supremum (A::'a set); (b::'a) ∈ supremum (B::'a set); x ∈ supremum {a, b}⟧ ⟹ x ∈ supremum (A ∪ B)› 2. ‹⋀x::'a. ⟦(a::'a) ∈ supremum (A::'a set); (b::'a) ∈ supremum (B::'a set); x ∈ supremum (A ∪ B)⟧ ⟹ x ∈ supremum {a, b}› discuss goal 1*) apply (simp add: supremum_def (*‹supremum (?A::'a::type set) = {a::'a::type ∈ upper_bound ?A. ∀x::'a::type∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound (?A::'a::type set) = {a::'a::type. ∀x::'a::type∈?A. x ≤ a}›*)) (*top goal: ‹⋀x. ⟦a ∈ supremum A; b ∈ supremum B; x ∈ supremum {a, b}⟧ ⟹ x ∈ supremum (A ∪ B)› and 1 goal remains*) apply ((safe)[1]) (*goals: 1. ‹⋀x xa. ⟦∀x∈A. x ≤ a; ∀x. (∀xa∈A. xa ≤ x) ⟶ a ≤ x; ∀x∈B. x ≤ b; ∀x. (∀xa∈B. xa ≤ x) ⟶ b ≤ x; a ≤ x; b ≤ x; ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa; xa ∈ A⟧ ⟹ xa ≤ x› 2. ‹⋀x xa. ⟦∀x∈A. x ≤ a; ∀x. (∀xa∈A. xa ≤ x) ⟶ a ≤ x; ∀x∈B. x ≤ b; ∀x. (∀xa∈B. xa ≤ x) ⟶ b ≤ x; a ≤ x; b ≤ x; ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa; xa ∈ B⟧ ⟹ xa ≤ x› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹⋀x::'a. ⟦(a::'a) ∈ supremum (A::'a set); (b::'a) ∈ supremum (B::'a set); x ∈ supremum (A ∪ B)⟧ ⟹ x ∈ supremum {a, b}›*) apply ((safe)[1]) (*goal: ‹⋀x. ⟦(∀x∈A. x ≤ a) ∧ (∀x. (∀xa∈A. xa ≤ x) ⟶ a ≤ x); (∀x∈B. x ≤ b) ∧ (∀x. (∀xa∈B. xa ≤ x) ⟶ b ≤ x); (∀xa∈A ∪ B. xa ≤ x) ∧ (∀xa. (∀x∈A ∪ B. x ≤ xa) ⟶ x ≤ xa)⟧ ⟹ ∀xa. a ≤ xa ∧ b ≤ xa ⟶ x ≤ xa›*) apply (subgoal_tac "(∀x ∈ A ∪ B. x ≤ xa)") (*goals: 1. ‹⋀x xa. ⟦∀x∈A. x ≤ a; ∀x. (∀xa∈A. xa ≤ x) ⟶ a ≤ x; ∀x∈B. x ≤ b; ∀x. (∀xa∈B. xa ≤ x) ⟶ b ≤ x; ∀xa∈A ∪ B. xa ≤ x; ∀xa. (∀x∈A ∪ B. x ≤ xa) ⟶ x ≤ xa; a ≤ xa; b ≤ xa; ∀x∈A ∪ B. x ≤ xa⟧ ⟹ x ≤ xa› 2. ‹⋀x xa. ⟦∀x∈A. x ≤ a; ∀x. (∀xa∈A. xa ≤ x) ⟶ a ≤ x; ∀x∈B. x ≤ b; ∀x. (∀xa∈B. xa ≤ x) ⟶ b ≤ x; ∀xa∈A ∪ B. xa ≤ x; ∀xa. (∀x∈A ∪ B. x ≤ xa) ⟶ x ≤ xa; a ≤ xa; b ≤ xa⟧ ⟹ ∀x∈A ∪ B. x ≤ xa› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma sup_singleton [simp]: "a ∈ supremum {a}" by (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) lemma sup_union_singleton: "a ∈ supremum X ⟹ supremum {a, b} = supremum (X ∪ {b})" apply (rule_tac B = "{b}" in sup_union (*‹⟦(?a::'a) ∈ supremum (?A::'a set); (?b::'a) ∈ supremum (?B::'a set)⟧ ⟹ supremum {?a, ?b} = supremum (?A ∪ ?B)›*)) (*goals: 1. ‹a ∈ supremum X ⟹ a ∈ supremum X› 2. ‹a ∈ supremum X ⟹ b ∈ supremum {b}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma sup_le_union [simp]: "a ≤ b ⟹ supremum (A ∪ {a, b}) = supremum (A ∪ {b})" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹(a::'a) ≤ (b::'a) ⟹ supremum ((A::'a set) ∪ {a, b}) = supremum (A ∪ {b})›*) by auto lemma sup_sup_union: "a ∈ supremum A ⟹ b ∈ supremum (B ∪ {a}) ⟹ b ∈ supremum (A ∪ B)" apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹⟦a ∈ supremum A; b ∈ supremum (B ∪ {a})⟧ ⟹ b ∈ supremum (A ∪ B)›*) by auto end (* context monoid_mult begin lemma "a ^ 2 = a * a" by (simp add: power2_eq_square) end *) lemma [simp]: "n ≤ 2 ^ n" apply (induct_tac n) (*goals: 1. ‹0 ≤ 2 ^ 0› 2. ‹⋀n. n ≤ 2 ^ n ⟹ Suc n ≤ 2 ^ Suc n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀n::nat. n ≤ (2::nat) ^ n ⟹ Suc n ≤ (2::nat) ^ Suc n›*) apply (rule_tac y = "1 + 2 ^ n" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀n. Suc n ≤ 1 + 2 ^ n› 2. ‹⋀n. 1 + 2 ^ n ≤ 2 * 2 ^ n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . context pseudo_hoop_algebra begin lemma sup_le_union_2: "a ≤ b ⟹ a ∈ A ⟹ b ∈ A ⟹ supremum A = supremum ((A - {a}) ∪ {b})" apply ((case_tac "supremum ((A - {a , b}) ∪ {a, b}) = supremum ((A - {a, b}) ∪ {b})")[1]) (*goals: 1. ‹⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b})⟧ ⟹ supremum A = supremum (A - {a} ∪ {b})› 2. ‹⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) ≠ supremum (A - {a, b} ∪ {b})⟧ ⟹ supremum A = supremum (A - {a} ∪ {b})› discuss goal 1*) apply ((case_tac "((A - {a, b}) ∪ {a, b} = A) ∧ ((A - {a, b}) ∪ {b} = (A - {a}) ∪ {b})")[1]) (*goals: 1. ‹⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b}); A - {a, b} ∪ {a, b} = A ∧ A - {a, b} ∪ {b} = A - {a} ∪ {b}⟧ ⟹ supremum A = supremum (A - {a} ∪ {b})› 2. ‹⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b}); ¬ (A - {a, b} ∪ {a, b} = A ∧ A - {a, b} ∪ {b} = A - {a} ∪ {b})⟧ ⟹ supremum A = supremum (A - {a} ∪ {b})› discuss goal 1*) apply ((safe)[1]) (*goals: 1. ‹⋀x. ⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b}); A - {a, b} ∪ {a, b} = A; A - {a, b} ∪ {b} = A - {a} ∪ {b}; x ∈ supremum A⟧ ⟹ x ∈ supremum (A - {a} ∪ {b})› 2. ‹⋀x. ⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b}); A - {a, b} ∪ {a, b} = A; A - {a, b} ∪ {b} = A - {a} ∪ {b}; x ∈ supremum (A - {a} ∪ {b})⟧ ⟹ x ∈ supremum A› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply ((erule notE (*‹⟦¬ ?P; ?P⟧ ⟹ ?R›*))[1]) (*top goal: ‹⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b}); ¬ (A - {a, b} ∪ {a, b} = A ∧ A - {a, b} ∪ {b} = A - {a} ∪ {b})⟧ ⟹ supremum A = supremum (A - {a} ∪ {b})› and 1 goal remains*) apply ((safe)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((erule notE (*‹⟦¬ (?P::bool); ?P⟧ ⟹ ?R::bool›*))[1]) (*goal: ‹⟦a ≤ b; a ∈ A; b ∈ A; supremum (A - {a, b} ∪ {a, b}) ≠ supremum (A - {a, b} ∪ {b})⟧ ⟹ supremum A = supremum (A - {a} ∪ {b})›*) apply (rule sup_le_union (*‹(?a::'a) ≤ (?b::'a) ⟹ supremum ((?A::'a set) ∪ {?a, ?b}) = supremum (?A ∪ {?b})›*)) (*goal: ‹⟦a ≤ b; a ∈ A; b ∈ A⟧ ⟹ supremum (A - {a, b} ∪ {a, b}) = supremum (A - {a, b} ∪ {b})›*) apply simp (*proven 2 subgoals*) . lemma lemma_2_15_iii_0: "1 ∈ supremum {a, b} ⟹ 1 ∈ supremum {a ^ 2, b ^ 2}" apply ((frule_tac a = a in lemma_2_9_i (*‹?b ∈ supremum ?A ⟹ ?a * ?b ∈ supremum ((*) ?a ` ?A)›*))[1]) (*goal: ‹1 ∈ supremum {a, b} ⟹ 1 ∈ supremum {a², b²}›*) apply simp (*goal: ‹⟦1 ∈ supremum {a, b}; a * 1 ∈ supremum ((*) a ` {a, b})⟧ ⟹ 1 ∈ supremum {a², b²}›*) apply ((frule_tac a = a and b = b in sup_union_singleton (*‹?a ∈ supremum ?X ⟹ supremum {?a, ?b} = supremum (?X ∪ {?b})›*))[1]) (*goal: ‹⟦1 ∈ supremum {a, b}; a ∈ supremum {a * a, a * b}⟧ ⟹ 1 ∈ supremum {a², b²}›*) apply ((subgoal_tac "supremum ({a * a, a * b} ∪ {b}) = supremum ({a * a, b})")[1]) (*goals: 1. ‹⟦1 ∈ supremum {a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum ({a * a, a * b} ∪ {b}); supremum ({a * a, a * b} ∪ {b}) = supremum {a * a, b}⟧ ⟹ 1 ∈ supremum {a², b²}› 2. ‹⟦1 ∈ supremum {a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum ({a * a, a * b} ∪ {b})⟧ ⟹ supremum ({a * a, a * b} ∪ {b}) = supremum {a * a, b}› discuss goal 1*) apply simp (*top goal: ‹⟦1 ∈ supremum {a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum ({a * a, a * b} ∪ {b}); supremum ({a * a, a * b} ∪ {b}) = supremum {a * a, b}⟧ ⟹ 1 ∈ supremum {a², b²}› and 1 goal remains*) apply ((frule_tac a = b in lemma_2_9_i (*‹?b ∈ supremum ?A ⟹ ?a * ?b ∈ supremum ((*) ?a ` ?A)›*))[1]) (*top goal: ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}⟧ ⟹ (1::'a) ∈ supremum {a², b²}› and 1 goal remains*) apply simp (*top goal: ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; b * 1 ∈ supremum ((*) b ` {a * a, b})⟧ ⟹ 1 ∈ supremum {a², b²}› and 1 goal remains*) apply ((drule_tac a = b and A = "{b * (a * a), b * b}" and b = 1 and B = "{a * a}" in sup_sup_union (*‹⟦?a ∈ supremum ?A; ?b ∈ supremum (?B ∪ {?a})⟧ ⟹ ?b ∈ supremum (?A ∪ ?B)›*))[1]) (*goals: 1. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}⟧ ⟹ 1 ∈ supremum ({a * a} ∪ {b})› 2. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; 1 ∈ supremum ({b * (a * a), b * b} ∪ {a * a})⟧ ⟹ 1 ∈ supremum {a², b²}› discuss goal 1*) apply simp (*top goal: ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}⟧ ⟹ 1 ∈ supremum ({a * a} ∪ {b})› and 2 goals remain*) apply ((case_tac "{a * a, b} = {b, a * a}")[1]) (*goals: 1. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; {a * a, b} = {b, a * a}⟧ ⟹ 1 ∈ supremum {b, a * a}› 2. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; {a * a, b} ≠ {b, a * a}⟧ ⟹ 1 ∈ supremum {b, a * a}› discuss goal 1*) apply simp (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*top goal: ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; 1 ∈ supremum ({b * (a * a), b * b} ∪ {a * a})⟧ ⟹ 1 ∈ supremum {a², b²}› and 1 goal remains*) apply ((subgoal_tac "supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}")[1]) (*goals: 1. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; 1 ∈ supremum {a * a, b * (a * a), b * b}; supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}⟧ ⟹ 1 ∈ supremum {a², b²}› 2. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; 1 ∈ supremum {a * a, b * (a * a), b * b}⟧ ⟹ supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}› discuss goal 1*) apply (simp add: power2_eq_square (*‹?a² = ?a * ?a›*)) (*discuss goal 2*) apply ((case_tac "b * (a * a) = b * b")[1]) (*goals: 1. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; 1 ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) = b * b⟧ ⟹ supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}› 2. ‹⟦1 ∈ supremum {a * a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; 1 ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b⟧ ⟹ supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((cut_tac A = "{a * a, b * (a * a), b * b}" and a = "b * (a * a)" and b = "a * a" in sup_le_union_2 (*‹⟦(?a::'a) ≤ (?b::'a); ?a ∈ (?A::'a set); ?b ∈ ?A⟧ ⟹ supremum ?A = supremum (?A - {?a} ∪ {?b})›*))[1]) (*goals: 1. ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; (1::'a) ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b⟧ ⟹ b * (a * a) ≤ a * a› 2. ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; (1::'a) ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b⟧ ⟹ b * (a * a) ∈ {a * a, b * (a * a), b * b}› 3. ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; (1::'a) ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b⟧ ⟹ a * a ∈ {a * a, b * (a * a), b * b}› 4. ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; (1::'a) ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b; supremum {a * a, b * (a * a), b * b} = supremum ({a * a, b * (a * a), b * b} - {b * (a * a)} ∪ {a * a})⟧ ⟹ supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply ((subgoal_tac "({a * a, b * (a * a), b * b} - {b * (a * a)} ∪ {a * a}) = {a * a, b * b}")[1]) (*goals: 1. ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; (1::'a) ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b; supremum {a * a, b * (a * a), b * b} = supremum ({a * a, b * (a * a), b * b} - {b * (a * a)} ∪ {a * a}); {a * a, b * (a * a), b * b} - {b * (a * a)} ∪ {a * a} = {a * a, b * b}⟧ ⟹ supremum {a * a, b * (a * a), b * b} = supremum {a * a, b * b}› 2. ‹⟦(1::'a) ∈ supremum {(a::'a) * a, b::'a}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {a * a, b}; supremum {b, a * a, a * b} = supremum {a * a, b}; (1::'a) ∈ supremum {a * a, b * (a * a), b * b}; b * (a * a) ≠ b * b; supremum {a * a, b * (a * a), b * b} = supremum ({a * a, b * (a * a), b * b} - {b * (a * a)} ∪ {a * a})⟧ ⟹ {a * a, b * (a * a), b * b} - {b * (a * a)} ∪ {a * a} = {a * a, b * b}› discuss goal 1*) apply simp (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 4 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply simp (*goal: ‹⟦1 ∈ supremum {a, b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum ({a * a, a * b} ∪ {b})⟧ ⟹ supremum ({a * a, a * b} ∪ {b}) = supremum {a * a, b}›*) apply ((case_tac "a * a = a * b")[1]) (*goals: 1. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a = a * b⟧ ⟹ supremum {b, a * a, a * b} = supremum {a * a, b}› 2. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b⟧ ⟹ supremum {b, a * a, a * b} = supremum {a * a, b}› discuss goal 1*) apply ((subgoal_tac "{b, a * a, a * b} = {a * a, b}")[1]) (*goals: 1. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a = a * b; {b, a * a, a * b} = {a * a, b}⟧ ⟹ supremum {b, a * a, a * b} = supremum {a * a, b}› 2. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a = a * b⟧ ⟹ {b, a * a, a * b} = {a * a, b}› discuss goal 1*) apply simp (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply ((cut_tac A = "{b, a * a, a * b}" and a = "a * b" and b = "b" in sup_le_union_2 (*‹⟦?a ≤ ?b; ?a ∈ ?A; ?b ∈ ?A⟧ ⟹ supremum ?A = supremum (?A - {?a} ∪ {?b})›*))[1]) (*goals: 1. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b⟧ ⟹ a * b ≤ b› 2. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b⟧ ⟹ a * b ∈ {b, a * a, a * b}› 3. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b⟧ ⟹ b ∈ {b, a * a, a * b}› 4. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b; supremum {b, a * a, a * b} = supremum ({b, a * a, a * b} - {a * b} ∪ {b})⟧ ⟹ supremum {b, a * a, a * b} = supremum {a * a, b}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply ((subgoal_tac "{b, a * a, a * b} - {a * b} ∪ {b} = {a * a, b}")[1]) (*goals: 1. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b; supremum {b, a * a, a * b} = supremum ({b, a * a, a * b} - {a * b} ∪ {b}); {b, a * a, a * b} - {a * b} ∪ {b} = {a * a, b}⟧ ⟹ supremum {b, a * a, a * b} = supremum {a * a, b}› 2. ‹⟦1 ∈ supremum {b, a * a, a * b}; a ∈ supremum {a * a, a * b}; supremum {a, b} = supremum {b, a * a, a * b}; a * a ≠ a * b; supremum {b, a * a, a * b} = supremum ({b, a * a, a * b} - {a * b} ∪ {b})⟧ ⟹ {b, a * a, a * b} - {a * b} ∪ {b} = {a * a, b}› discuss goal 1*) apply simp (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 4 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma [simp]: "m ≤ n ⟹ a ^ n ≤ a ^ m" apply (subgoal_tac "a ^ n = (a ^ m) * (a ^ (n-m))") (*goals: 1. ‹⟦m ≤ n; a ^ n = a ^ m * a ^ (n - m)⟧ ⟹ a ^ n ≤ a ^ m› 2. ‹m ≤ n ⟹ a ^ n = a ^ m * a ^ (n - m)› discuss goal 1*) apply simp (*discuss goal 2*) apply (cut_tac a = a and m = "m" and n = "n - m" in power_add (*‹(?a::'a) ^ ((?m::nat) + (?n::nat)) = ?a ^ ?m * ?a ^ ?n›*)) (*goal: ‹m ≤ n ⟹ a ^ n = a ^ m * a ^ (n - m)›*) apply simp (*proven 2 subgoals*) . lemma [simp]: "a ^ (2 ^ n) ≤ a ^ n" by simp lemma lemma_2_15_iii_1: "1 ∈ supremum {a, b} ⟹ 1 ∈ supremum {a ^ (2 ^ n), b ^ (2 ^ n)}" apply (induct_tac n) (*goals: 1. ‹1 ∈ supremum {a, b} ⟹ 1 ∈ supremum {a ^ 2 ^ 0, b ^ 2 ^ 0}› 2. ‹⋀n. ⟦1 ∈ supremum {a, b}; 1 ∈ supremum {a ^ 2 ^ n, b ^ 2 ^ n}⟧ ⟹ 1 ∈ supremum {a ^ 2 ^ Suc n, b ^ 2 ^ Suc n}› discuss goal 1*) apply auto (*discuss goal 2*) apply (drule drop_assumption (*‹?p ⟹ True›*)) (*goal: ‹⋀n. ⟦1 ∈ supremum {a, b}; 1 ∈ supremum {a ^ 2 ^ n, b ^ 2 ^ n}⟧ ⟹ 1 ∈ supremum {a ^ (2 * 2 ^ n), b ^ (2 * 2 ^ n)}›*) apply (drule lemma_2_15_iii_0 (*‹1 ∈ supremum {?a, ?b} ⟹ 1 ∈ supremum {?a², ?b²}›*)) (*goal: ‹⋀n::nat. ⟦(1::'a::type) ∈ supremum {(a::'a::type) ^ (2::nat) ^ n, (b::'a::type) ^ (2::nat) ^ n}; True⟧ ⟹ (1::'a::type) ∈ supremum {a ^ ((2::nat) * (2::nat) ^ n), b ^ ((2::nat) * (2::nat) ^ n)}›*) apply (subgoal_tac "∀a . (a ^ (2::nat) ^ n)² = a ^ (2::nat) ^ Suc n") (*goals: 1. ‹⋀n. ⟦True; 1 ∈ supremum {(a ^ 2 ^ n)², (b ^ 2 ^ n)²}; ∀a. (a ^ 2 ^ n)² = a ^ 2 ^ Suc n⟧ ⟹ 1 ∈ supremum {a ^ (2 * 2 ^ n), b ^ (2 * 2 ^ n)}› 2. ‹⋀n. ⟦True; 1 ∈ supremum {(a ^ 2 ^ n)², (b ^ 2 ^ n)²}⟧ ⟹ ∀a. (a ^ 2 ^ n)² = a ^ 2 ^ Suc n› discuss goal 1*) apply simp (*discuss goal 2*) apply safe (*goal: ‹⋀n. ⟦True; 1 ∈ supremum {(a ^ 2 ^ n)², (b ^ 2 ^ n)²}⟧ ⟹ ∀a. (a ^ 2 ^ n)² = a ^ 2 ^ Suc n›*) apply (cut_tac a = aa and m = "2 ^ n" and n = 2 in power_mult (*‹?a ^ (?m * ?n) = (?a ^ ?m) ^ ?n›*)) (*goal: ‹⋀n aa. ⟦True; 1 ∈ supremum {(a ^ 2 ^ n)², (b ^ 2 ^ n)²}⟧ ⟹ (aa ^ 2 ^ n)² = aa ^ 2 ^ Suc n›*) apply auto (*goal: ‹⋀(n::nat) aa::'a. ⟦True; (1::'a) ∈ supremum {((a::'a) ^ (2::nat) ^ n)², ((b::'a) ^ (2::nat) ^ n)²}; aa ^ ((2::nat) ^ n * (2::nat)) = (aa ^ (2::nat) ^ n)²⟧ ⟹ (aa ^ (2::nat) ^ n)² = aa ^ (2::nat) ^ Suc n›*) apply (subgoal_tac "((2::nat) ^ n * (2::nat)) = ((2::nat) * (2::nat) ^ n)") (*goals: 1. ‹⋀(n::nat) aa::'a::type. ⟦(1::'a::type) ∈ supremum {((a::'a::type) ^ (2::nat) ^ n)², ((b::'a::type) ^ (2::nat) ^ n)²}; aa ^ ((2::nat) ^ n * (2::nat)) = (aa ^ (2::nat) ^ n)²; (2::nat) ^ n * (2::nat) = (2::nat) * (2::nat) ^ n⟧ ⟹ (aa ^ (2::nat) ^ n)² = aa ^ ((2::nat) * (2::nat) ^ n)› 2. ‹⋀(n::nat) aa::'a::type. ⟦(1::'a::type) ∈ supremum {((a::'a::type) ^ (2::nat) ^ n)², ((b::'a::type) ^ (2::nat) ^ n)²}; aa ^ ((2::nat) ^ n * (2::nat)) = (aa ^ (2::nat) ^ n)²⟧ ⟹ (2::nat) ^ n * (2::nat) = (2::nat) * (2::nat) ^ n› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . lemma lemma_2_15_iii: "1 ∈ supremum {a, b} ⟹ 1 ∈ supremum {a ^ n, b ^ n}" apply (drule_tac n = n in lemma_2_15_iii_1 (*‹1 ∈ supremum {?a, ?b} ⟹ 1 ∈ supremum {?a ^ 2 ^ ?n, ?b ^ 2 ^ ?n}›*)) (*goal: ‹1 ∈ supremum {a, b} ⟹ 1 ∈ supremum {a ^ n, b ^ n}›*) apply (simp add: supremum_def (*‹supremum ?A = {a ∈ upper_bound ?A. ∀x∈upper_bound ?A. a ≤ x}›*) upper_bound_def (*‹upper_bound ?A = {a. ∀x∈?A. x ≤ a}›*)) (*goal: ‹1 ∈ supremum {a ^ 2 ^ n, b ^ 2 ^ n} ⟹ 1 ∈ supremum {a ^ n, b ^ n}›*) apply safe (*goal: ‹∀x::'a. (a::'a) ^ (2::nat) ^ (n::nat) ≤ x ∧ (b::'a) ^ (2::nat) ^ n ≤ x ⟶ (1::'a) ≤ x ⟹ ∀x::'a. a ^ n ≤ x ∧ b ^ n ≤ x ⟶ (1::'a) ≤ x›*) apply (drule_tac x = x in spec (*‹∀x. ?P x ⟹ ?P ?x›*)) (*goal: ‹⋀x. ⟦∀x. a ^ 2 ^ n ≤ x ∧ b ^ 2 ^ n ≤ x ⟶ 1 ≤ x; a ^ n ≤ x; b ^ n ≤ x⟧ ⟹ 1 ≤ x›*) apply safe (*goals: 1. ‹⋀x. ⟦a ^ n ≤ x; b ^ n ≤ x; ¬ 1 ≤ x⟧ ⟹ a ^ 2 ^ n ≤ x› 2. ‹⋀x. ⟦a ^ n ≤ x; b ^ n ≤ x; ¬ 1 ≤ x⟧ ⟹ b ^ 2 ^ n ≤ x› discuss goal 1*) apply (rule_tac y = "a ^ n" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀x. ⟦a ^ n ≤ x; b ^ n ≤ x; ¬ 1 ≤ x⟧ ⟹ a ^ 2 ^ n ≤ a ^ n› 2. ‹⋀x. ⟦a ^ n ≤ x; b ^ n ≤ x; ¬ 1 ≤ x⟧ ⟹ a ^ n ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*discuss goal 2*) apply (rule_tac y = "b ^ n" in order_trans (*‹⟦?x ≤ ?y; ?y ≤ ?z⟧ ⟹ ?x ≤ ?z›*)) (*goals: 1. ‹⋀x. ⟦a ^ n ≤ x; b ^ n ≤ x; ¬ 1 ≤ x⟧ ⟹ b ^ 2 ^ n ≤ b ^ n› 2. ‹⋀x. ⟦a ^ n ≤ x; b ^ n ≤ x; ¬ 1 ≤ x⟧ ⟹ b ^ n ≤ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) (*proven 2 subgoals*) . end end
{ "path": "afp-2025-02-12/thys/PseudoHoops/PseudoHoops.thy", "repo": "afp-2025-02-12", "sha": "f99e3da541f98b2e50ba94df77bcd83981b9ab47c6ca8c572d2f65b863b18bdb" }
section "Logic" theory Logic imports Theory Term_Subst SortConstants Name BetaNormProof EtaNormProof begin term proves abbreviation "inst_ok Θ insts ≡ distinct (map fst insts) ―‹No duplicates, makes stuff easier› ∧ list_all (typ_ok Θ) (map snd insts) ―‹Stuff I substitute in is well typed› ∧ list_all (λ((idn, S), T) . has_sort (osig (sig Θ)) T S) insts" ―‹Types "fit" in the Fviables› lemma inst_ok_imp_wf_inst: "inst_ok Θ insts ⟹ wf_inst Θ (λidn S .the_default (Tv idn S) (lookup (λx. x=(idn, S)) insts))" apply (induction insts) (*goals: 1. ‹inst_ok Θ [] ⟹ wf_inst Θ (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) []))› 2. ‹⋀a insts. ⟦inst_ok Θ insts ⟹ wf_inst Θ (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) insts)); inst_ok Θ (a # insts)⟧ ⟹ wf_inst Θ (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) (a # insts)))› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a::type ⇒ bool) (if ?Q::bool then ?x::?'a::type else (?y::?'a::type)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) prod.splits (*‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∀(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∄(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . lemma term_ok'_eta_norm: "term_ok' Σ t ⟹ term_ok' Σ (eta_norm t)" apply (induction t rule: eta_norm.induct (*‹⟦⋀T t. ⟦?P t; ⋀x51 x52 x3. ⟦eta_norm t = x51 $ x52; x52 = Bv x3; x3 = 0; ¬ is_dependent x51⟧ ⟹ ?P x51⟧ ⟹ ?P (Abs T t); ⋀t u. ⟦?P t; ?P u⟧ ⟹ ?P (t $ u); ⋀v va. ?P (Ct v va); ⋀v va. ?P (Fv v va); ⋀v. ?P (Bv v)⟧ ⟹ ?P ?a0.0›*)) (*goals: 1. ‹⋀T t. ⟦term_ok' Σ t ⟹ term_ok' Σ (eta_norm t); ⋀x51 x52 x3. ⟦eta_norm t = x51 $ x52; x52 = Bv x3; x3 = 0; ¬ is_dependent x51; term_ok' Σ x51⟧ ⟹ term_ok' Σ (eta_norm x51); term_ok' Σ (Abs T t)⟧ ⟹ term_ok' Σ (eta_norm (Abs T t))› 2. ‹⋀t u. ⟦term_ok' Σ t ⟹ term_ok' Σ (eta_norm t); term_ok' Σ u ⟹ term_ok' Σ (eta_norm u); term_ok' Σ (t $ u)⟧ ⟹ term_ok' Σ (eta_norm (t $ u))› 3. ‹⋀v va. term_ok' Σ (Ct v va) ⟹ term_ok' Σ (eta_norm (Ct v va))› 4. ‹⋀v va. term_ok' Σ (Fv v va) ⟹ term_ok' Σ (eta_norm (Fv v va))› 5. ‹⋀v. term_ok' Σ (Bv v) ⟹ term_ok' Σ (eta_norm (Bv v))› discuss goal 1*) apply ((auto split: term.splits (*‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = ((∀x11 x12. ?term = Ct x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22. ?term = Fv x21 x22 ⟶ ?P (?f2.0 x21 x22)) ∧ (∀x3. ?term = Bv x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x41 x42. ?term = Abs x41 x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?term = x51 $ x52 ⟶ ?P (?f5.0 x51 x52)))› ‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = (¬ ((∃x11 x12. ?term = Ct x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃x21 x22. ?term = Fv x21 x22 ∧ ¬ ?P (?f2.0 x21 x22)) ∨ (∃x3. ?term = Bv x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x41 x42. ?term = Abs x41 x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃x51 x52. ?term = x51 $ x52 ∧ ¬ ?P (?f5.0 x51 x52))))›*) nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: term_ok'_decr (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (decr ?i ?t)›*) is_dependent_def (*‹is_dependent ?t ≡ loose_bvar1 ?t 0›*))[1]) (*discuss goal 2*) apply ((auto split: term.splits (*‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = ((∀x11 x12. ?term = Ct x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22. ?term = Fv x21 x22 ⟶ ?P (?f2.0 x21 x22)) ∧ (∀x3. ?term = Bv x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x41 x42. ?term = Abs x41 x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?term = x51 $ x52 ⟶ ?P (?f5.0 x51 x52)))› ‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = (¬ ((∃x11 x12. ?term = Ct x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃x21 x22. ?term = Fv x21 x22 ∧ ¬ ?P (?f2.0 x21 x22)) ∨ (∃x3. ?term = Bv x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x41 x42. ?term = Abs x41 x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃x51 x52. ?term = x51 $ x52 ∧ ¬ ?P (?f5.0 x51 x52))))›*) nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: term_ok'_decr (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (decr ?i ?t)›*) is_dependent_def (*‹is_dependent ?t ≡ loose_bvar1 ?t 0›*))[1]) (*discuss goal 3*) apply ((auto split: term.splits (*‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = ((∀x11 x12. ?term = Ct x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22. ?term = Fv x21 x22 ⟶ ?P (?f2.0 x21 x22)) ∧ (∀x3. ?term = Bv x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x41 x42. ?term = Abs x41 x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?term = x51 $ x52 ⟶ ?P (?f5.0 x51 x52)))› ‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = (¬ ((∃x11 x12. ?term = Ct x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃x21 x22. ?term = Fv x21 x22 ∧ ¬ ?P (?f2.0 x21 x22)) ∨ (∃x3. ?term = Bv x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x41 x42. ?term = Abs x41 x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃x51 x52. ?term = x51 $ x52 ∧ ¬ ?P (?f5.0 x51 x52))))›*) nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: term_ok'_decr (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (decr ?i ?t)›*) is_dependent_def (*‹is_dependent ?t ≡ loose_bvar1 ?t 0›*))[1]) (*discuss goal 4*) apply ((auto split: term.splits (*‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = ((∀x11 x12. ?term = Ct x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22. ?term = Fv x21 x22 ⟶ ?P (?f2.0 x21 x22)) ∧ (∀x3. ?term = Bv x3 ⟶ ?P (?f3.0 x3)) ∧ (∀x41 x42. ?term = Abs x41 x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀x51 x52. ?term = x51 $ x52 ⟶ ?P (?f5.0 x51 x52)))› ‹?P (case ?term of Ct x xa ⇒ ?f1.0 x xa | Fv x xa ⇒ ?f2.0 x xa | Bv x ⇒ ?f3.0 x | Abs x xa ⇒ ?f4.0 x xa | x $ xa ⇒ ?f5.0 x xa) = (¬ ((∃x11 x12. ?term = Ct x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃x21 x22. ?term = Fv x21 x22 ∧ ¬ ?P (?f2.0 x21 x22)) ∨ (∃x3. ?term = Bv x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃x41 x42. ?term = Abs x41 x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃x51 x52. ?term = x51 $ x52 ∧ ¬ ?P (?f5.0 x51 x52))))›*) nat.splits (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = (¬ (?nat = 0 ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: term_ok'_decr (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (decr ?i ?t)›*) is_dependent_def (*‹is_dependent ?t ≡ loose_bvar1 ?t 0›*))[1]) (*discuss goal 5*) apply ((auto split: term.splits (*‹(?P::?'a::type ⇒ bool) (case ?term::Core.term of Ct (x::String.literal) (xa::typ) ⇒ (?f1.0::String.literal ⇒ typ ⇒ ?'a::type) x xa | Fv (x::variable) (xa::typ) ⇒ (?f2.0::variable ⇒ typ ⇒ ?'a::type) x xa | Bv (x::nat) ⇒ (?f3.0::nat ⇒ ?'a::type) x | Abs (x::typ) (xa::Core.term) ⇒ (?f4.0::typ ⇒ Core.term ⇒ ?'a::type) x xa | (x::Core.term) $ (xa::Core.term) ⇒ (?f5.0::Core.term ⇒ Core.term ⇒ ?'a::type) x xa) = ((∀(x11::String.literal) x12::typ. ?term = Ct x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀(x21::variable) x22::typ. ?term = Fv x21 x22 ⟶ ?P (?f2.0 x21 x22)) ∧ (∀x3::nat. ?term = Bv x3 ⟶ ?P (?f3.0 x3)) ∧ (∀(x41::typ) x42::Core.term. ?term = Abs x41 x42 ⟶ ?P (?f4.0 x41 x42)) ∧ (∀(x51::Core.term) x52::Core.term. ?term = x51 $ x52 ⟶ ?P (?f5.0 x51 x52)))› ‹(?P::?'a::type ⇒ bool) (case ?term::Core.term of Ct (x::String.literal) (xa::typ) ⇒ (?f1.0::String.literal ⇒ typ ⇒ ?'a::type) x xa | Fv (x::variable) (xa::typ) ⇒ (?f2.0::variable ⇒ typ ⇒ ?'a::type) x xa | Bv (x::nat) ⇒ (?f3.0::nat ⇒ ?'a::type) x | Abs (x::typ) (xa::Core.term) ⇒ (?f4.0::typ ⇒ Core.term ⇒ ?'a::type) x xa | (x::Core.term) $ (xa::Core.term) ⇒ (?f5.0::Core.term ⇒ Core.term ⇒ ?'a::type) x xa) = (¬ ((∃(x11::String.literal) x12::typ. ?term = Ct x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃(x21::variable) x22::typ. ?term = Fv x21 x22 ∧ ¬ ?P (?f2.0 x21 x22)) ∨ (∃x3::nat. ?term = Bv x3 ∧ ¬ ?P (?f3.0 x3)) ∨ (∃(x41::typ) x42::Core.term. ?term = Abs x41 x42 ∧ ¬ ?P (?f4.0 x41 x42)) ∨ (∃(x51::Core.term) x52::Core.term. ?term = x51 $ x52 ∧ ¬ ?P (?f5.0 x51 x52))))›*) nat.splits (*‹(?P::?'a::type ⇒ bool) (case ?nat::nat of 0::nat ⇒ ?f1.0::?'a::type | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a::type) x) = ((?nat = (0::nat) ⟶ ?P ?f1.0) ∧ (∀x2::nat. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'a::type ⇒ bool) (case ?nat::nat of 0::nat ⇒ ?f1.0::?'a::type | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a::type) x) = (¬ (?nat = (0::nat) ∧ ¬ ?P ?f1.0 ∨ (∃x2::nat. ?nat = Suc x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: term_ok'_decr (*‹term_ok' (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ⟹ term_ok' ?Σ (decr (?i::nat) ?t)›*) is_dependent_def (*‹is_dependent (?t::Core.term) ≡ loose_bvar1 ?t (0::nat)›*))[1]) (*proven 5 subgoals*) . corollary term_ok_eta_norm: "term_ok thy t ⟹ term_ok thy (eta_norm t)" using wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) typ_of_eta_norm (*‹typ_of ?t = Some ?ty ⟹ typ_of (eta_norm ?t) = Some ?ty›*) term_ok'_eta_norm (*‹term_ok' (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ⟹ term_ok' ?Σ (eta_norm ?t)›*) by auto abbreviation "beta_eta_norm t ≡ map_option eta_norm (beta_norm t)" lemma "beta_eta_norm t = Some t' ⟹ ¬ eta_reducible t'" using not_eta_reducible_eta_norm (*‹¬ eta_reducible (eta_norm ?t)›*) by auto lemma term_ok_beta_eta_norm: "term_ok thy t ⟹ beta_eta_norm t = Some t' ⟹ term_ok thy t'" using term_ok_eta_norm (*‹term_ok ?thy ?t ⟹ term_ok ?thy (eta_norm ?t)›*) term_ok_beta_norm (*‹⟦term_ok ?thy ?t; beta_norm ?t = Some ?t'⟧ ⟹ term_ok ?thy ?t'›*) by blast lemma typ_of_beta_eta_norm: "typ_of t = Some T ⟹ beta_eta_norm t = Some t' ⟹ typ_of t' = Some T" using beta_norm_imp_beta_reds (*‹beta_norm ?t = Some ?t' ⟹ ?t →⇩β⇧* ?t'›*) beta_star_preserves_typ_of1 (*‹⟦?r →⇩β⇧* ?s; typ_of1 ?Ts ?r = Some ?T⟧ ⟹ typ_of1 ?Ts ?s = Some ?T›*) typ_of1_eta_norm (*‹typ_of1 ?Ts ?t = Some ?ty ⟹ typ_of1 ?Ts (eta_norm ?t) = Some ?ty›*) typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*) by fastforce lemma inst_ok_nil[simp]: "inst_ok Θ []" by simp lemma axiom_subst_typ': assumes "wf_theory Θ" "A∈axioms Θ" "inst_ok Θ insts" shows "Θ, Γ ⊢ subst_typ' insts A" proof (-) (*goal: ‹Θ,Γ ⊢ subst_typ' insts A›*) have "wf_inst Θ (λidn S . the_default (Tv idn S) (lookup (λx. x=(idn, S)) insts))" using inst_ok_imp_wf_inst (*‹inst_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?insts::((variable × String.literal set) × typ) list) ⟹ wf_inst ?Θ (λ(idn::variable) S::String.literal set. the_default (Tv idn S) (lookup (λx::variable × String.literal set. x = (idn, S)) ?insts))›*) assms(3) (*‹inst_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (insts::((variable × String.literal set) × typ) list)›*) by blast moreover have "subst_typ' insts A = tsubst A (λidn S . the_default (Tv idn S) (lookup (λx. x=(idn, S)) insts))" by (simp add: tsubst_simulates_subst_typ' (*‹subst_typ' ?insts ?T = tsubst ?T (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) ?insts))›*)) ultimately show "?thesis" (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ subst_typ' (insts::((variable × String.literal set) × typ) list) (A::Core.term)›*) using assms (*‹wf_theory Θ› ‹A ∈ axioms Θ› ‹inst_ok Θ insts›*) axiom (*‹⟦wf_theory ?Θ; ?A ∈ axioms ?Θ; wf_inst ?Θ ?ρ⟧ ⟹ ?Θ,?Γ ⊢ tsubst ?A ?ρ›*) by simp qed corollary axiom': "wf_theory Θ ⟹ A ∈ axioms Θ ⟹ Θ, Γ ⊢ A" apply (subst subst_typ'_nil[symmetric] (*‹?t = subst_typ' [] ?t›*)) (*goal: ‹⟦wf_theory Θ; A ∈ axioms Θ⟧ ⟹ Θ,Γ ⊢ A›*) using axiom_subst_typ' (*‹⟦wf_theory ?Θ; ?A ∈ axioms ?Θ; inst_ok ?Θ ?insts⟧ ⟹ ?Θ,?Γ ⊢ subst_typ' ?insts ?A›*) inst_ok_nil (*‹inst_ok ?Θ []›*) by metis lemma has_sort_Tv_refl: "wf_osig oss ⟹ sort_ex (subclass oss) S ⟹ has_sort oss (Tv v S) S" apply (cases oss) (*goal: ‹⟦wf_osig oss; sort_ex (subclass oss) S⟧ ⟹ has_sort oss (Tv v S) S›*) by (simp add: osig_subclass_loc (*‹wf_osig (?oss::(String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) ⟹ wf_subclass_loc (subclass ?oss)›*) wf_subclass_loc.intro (*‹wf_subclass (?cs::(String.literal × String.literal) set) ⟹ wf_subclass_loc ?cs›*) has_sort_Tv (*‹sort_leq (?sub::(String.literal × String.literal) set) (?S::String.literal set) (?S'::String.literal set) ⟹ has_sort (?sub, ?tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) (Tv (?a::variable) ?S) ?S'›*) wf_subclass_loc.sort_leq_refl (*‹⟦wf_subclass_loc (?cs::(String.literal × String.literal) set); sort_ex ?cs (?s::String.literal set)⟧ ⟹ sort_leq ?cs ?s ?s›*)) lemma has_sort_Tv_refl': "wf_theory Θ ⟹ typ_ok Θ (Tv v S) ⟹ has_sort (osig (sig Θ)) (Tv v S) S" using has_sort_Tv_refl (*‹⟦wf_osig (?oss::(String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); sort_ex (subclass ?oss) (?S::String.literal set)⟧ ⟹ has_sort ?oss (Tv (?v::variable) ?S) ?S›*) by (metis wf_sig.simps (*‹wf_sig (?ctf, ?arf, ?oss) = (wf_osig ?oss ∧ dom (tcsigs ?oss) = dom ?arf ∧ (∀type∈dom (tcsigs ?oss). ∀ars∈ran (the (tcsigs ?oss type)). the (?arf type) = length ars) ∧ Ball (ran ?ctf) (wf_type (?ctf, ?arf, ?oss)))›*) osig.elims (*‹⟦osig ?x = ?y; ⋀uu_ uv_ oss. ⟦?x = (uu_, uv_, oss); ?y = oss⟧ ⟹ ?P⟧ ⟹ ?P›*) wf_theory_imp_wf_sig (*‹wf_theory ?Θ ⟹ wf_sig (sig ?Θ)›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) wf_type_imp_typ_ok_sig (*‹wf_type ?Σ ?T ⟹ typ_ok_sig ?Σ ?T›*) typ_ok_sig.simps( (*‹typ_ok_sig ?Σ (Tv ?uu ?S) = wf_sort (subclass (osig ?Σ)) ?S›*) 2) wf_sort_def (*‹wf_sort ?sub ?S = (normalized_sort ?sub ?S ∧ sort_ex ?sub ?S)›*)) lemma wf_inst_imp_inst_ok: "wf_theory Θ ⟹ distinct l ⟹ ∀(v, S) ∈ set l . typ_ok Θ (Tv v S) ⟹ wf_inst Θ ρ ⟹ inst_ok Θ (map (λ(v, S) . ((v, S), ρ v S)) l)" proof (induction l) (*goals: 1. ‹⟦wf_theory Θ; distinct []; ∀(v, S)∈set []. typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) [])› 2. ‹⋀a l. ⟦⟦wf_theory Θ; distinct l; ∀(v, S)∈set l. typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) l); wf_theory Θ; distinct (a # l); ∀(v, S)∈set (a # l). typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) (a # l))›*) case Nil (*‹wf_theory Θ› ‹distinct []› ‹∀a∈set []. case a of (v, S) ⇒ typ_ok Θ (Tv v S)› ‹wf_inst Θ ρ›*) then show "?case" (*goal: ‹inst_ok Θ (map (λa. case a of (v, S) ⇒ ((v, S), ρ v S)) [])›*) by simp next (*goal: ‹⋀a l. ⟦⟦wf_theory Θ; distinct l; ∀(v, S)∈set l. typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) l); wf_theory Θ; distinct (a # l); ∀(v, S)∈set (a # l). typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) (a # l))›*) case (Cons a l) (*‹⟦wf_theory Θ; distinct l; ∀a∈set l. case a of (v, S) ⇒ typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λa. case a of (v, S) ⇒ ((v, S), ρ v S)) l)› ‹wf_theory Θ› ‹distinct ((a::variable × String.literal set) # (l::(variable × String.literal set) list))› ‹∀a∈set (a # l). case a of (v, S) ⇒ typ_ok Θ (Tv v S)› ‹wf_inst Θ ρ›*) have I: "inst_ok Θ (map (λ(v,S) . ((v, S), ρ v S)) l)" using Cons (*‹⟦wf_theory Θ; distinct l; ∀a∈set l. case a of (v, S) ⇒ typ_ok Θ (Tv v S); wf_inst Θ ρ⟧ ⟹ inst_ok Θ (map (λa. case a of (v, S) ⇒ ((v, S), ρ v S)) l)› ‹wf_theory Θ› ‹distinct (a # l)› ‹∀a::variable × String.literal set∈set ((a::variable × String.literal set) # (l::(variable × String.literal set) list)). case a of (v::variable, S::String.literal set) ⇒ typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Tv v S)› ‹wf_inst Θ ρ›*) by fastforce have "a ∉ set l" using Cons.prems(2) (*‹distinct (a # l)›*) by auto hence "(a, case_prod ρ a) ∉ set (map (λ(v,S) . ((v, S), ρ v S)) l)" by (simp add: image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*) prod.case_eq_if (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*)) moreover have "distinct (map (λ(v,S) . ((v, S), ρ v S)) l)" using I (*‹inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) l)›*) distinct_kv_list (*‹distinct (?l::?'a list) ⟹ distinct (map (λx::?'a. (x, (?f::?'a ⇒ ?'b) x)) ?l)›*) distinct_map (*‹distinct (map ?f ?xs) = (distinct ?xs ∧ inj_on ?f (set ?xs))›*) by fast ultimately have "distinct (map (λ(v,S) . ((v, S), ρ v S)) (a#l))" by (auto split: prod.splits (*‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∀(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∄(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) moreover have "wf_type (sig Θ) (case_prod ρ a)" using Cons.prems(3-4) (*‹∀a∈set (a # l). case a of (v, S) ⇒ typ_ok Θ (Tv v S)› ‹wf_inst Θ ρ›*) apply auto (*goal: ‹wf_type (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (case a::variable × String.literal set of (x::variable, xa::String.literal set) ⇒ (ρ::variable ⇒ String.literal set ⇒ typ) x xa)›*) by (metis typ_ok_Tv (*‹wf_sort (subclass (osig ?Σ)) ?S ⟹ wf_type ?Σ (Tv ?a ?S)›*) wf_type_imp_typ_ok_sig (*‹wf_type ?Σ ?T ⟹ typ_ok_sig ?Σ ?T›*)) moreover hence "typ_ok Θ (case_prod ρ a)" by simp moreover hence "has_sort (osig (sig Θ)) (case_prod ρ a) (snd a)" using Cons.prems (*‹wf_theory Θ› ‹distinct (a # l)› ‹∀a∈set (a # l). case a of (v, S) ⇒ typ_ok Θ (Tv v S)› ‹wf_inst Θ ρ›*) by (metis (full_types) has_sort_Tv_refl' (*‹⟦wf_theory ?Θ; typ_ok ?Θ (Tv ?v ?S)⟧ ⟹ has_sort (osig (sig ?Θ)) (Tv ?v ?S) ?S›*) prod.case_eq_if (*‹(case ?prod of (x, xa) ⇒ ?f x xa) = ?f (fst ?prod) (snd ?prod)›*) wf_inst_def (*‹wf_inst ?Θ ?ρ ≡ ∀v S. ?ρ v S ≠ Tv v S ⟶ has_sort (osig (sig ?Θ)) (?ρ v S) S ∧ wf_type (sig ?Θ) (?ρ v S)›*)) ultimately show "?case" (*goal: ‹inst_ok Θ (map (λa. case a of (v, S) ⇒ ((v, S), ρ v S)) (a # l))›*) using I (*‹inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) l)›*) by (auto simp del: typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) qed (* MOVE to term, also use for transfering proofs *) lemma typs_of_fv_subset_Types: "snd ` fv t ⊆ Types t" apply (induction t) (*goals: 1. ‹⋀x1 x2. snd ` fv (Ct x1 x2) ⊆ Types (Ct x1 x2)› 2. ‹⋀x1 x2. snd ` fv (Fv x1 x2) ⊆ Types (Fv x1 x2)› 3. ‹⋀x. snd ` fv (Bv x) ⊆ Types (Bv x)› 4. ‹⋀x1 t. snd ` fv t ⊆ Types t ⟹ snd ` fv (Abs x1 t) ⊆ Types (Abs x1 t)› 5. ‹⋀t1 t2. ⟦snd ` fv t1 ⊆ Types t1; snd ` fv t2 ⊆ Types t2⟧ ⟹ snd ` fv (t1 $ t2) ⊆ Types (t1 $ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma osig_tvsT_subset_SortsT: "snd ` tvsT T ⊆ SortsT T" apply (induction T) (*goals: 1. ‹⋀(x1::String.literal) x2::typ list. (⋀x2a::typ. x2a ∈ set x2 ⟹ snd ` tvsT x2a ⊆ SortsT x2a) ⟹ snd ` tvsT (Ty x1 x2) ⊆ SortsT (Ty x1 x2)› 2. ‹⋀(x1::variable) x2::String.literal set. snd ` tvsT (Tv x1 x2) ⊆ SortsT (Tv x1 x2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma osig_tvs_subset_Sorts: "snd ` tvs t ⊆ Sorts t" apply (induction t) (*goals: 1. ‹⋀x1 x2. snd ` tvs (Ct x1 x2) ⊆ Sorts (Ct x1 x2)› 2. ‹⋀x1 x2. snd ` tvs (Fv x1 x2) ⊆ Sorts (Fv x1 x2)› 3. ‹⋀x. snd ` tvs (Bv x) ⊆ Sorts (Bv x)› 4. ‹⋀x1 t. snd ` tvs t ⊆ Sorts t ⟹ snd ` tvs (Abs x1 t) ⊆ Sorts (Abs x1 t)› 5. ‹⋀t1 t2. ⟦snd ` tvs t1 ⊆ Sorts t1; snd ` tvs t2 ⊆ Sorts t2⟧ ⟹ snd ` tvs (t1 $ t2) ⊆ Sorts (t1 $ t2)› discuss goal 1*) apply ((use osig_tvsT_subset_SortsT in ‹auto simp add: image_subset_iff›)[1]) (*discuss goal 2*) apply ((use osig_tvsT_subset_SortsT in ‹auto simp add: image_subset_iff›)[1]) (*discuss goal 3*) apply ((use osig_tvsT_subset_SortsT in ‹auto simp add: image_subset_iff›)[1]) (*discuss goal 4*) apply ((use osig_tvsT_subset_SortsT in ‹auto simp add: image_subset_iff›)[1]) (*discuss goal 5*) apply ((use osig_tvsT_subset_SortsT in ‹auto simp add: image_subset_iff›)[1]) (*proven 5 subgoals*) . lemma term_ok_Types_imp_typ_ok_pre: "is_std_sig Σ ⟹ term_ok' Σ t ⟹ τ ∈ Types t ⟹ typ_ok_sig Σ τ" apply (induction t arbitrary: τ) (*goals: 1. ‹⋀x1 x2 τ. ⟦is_std_sig Σ; term_ok' Σ (Ct x1 x2); τ ∈ Types (Ct x1 x2)⟧ ⟹ typ_ok_sig Σ τ› 2. ‹⋀x1 x2 τ. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); τ ∈ Types (Fv x1 x2)⟧ ⟹ typ_ok_sig Σ τ› 3. ‹⋀x τ. ⟦is_std_sig Σ; term_ok' Σ (Bv x); τ ∈ Types (Bv x)⟧ ⟹ typ_ok_sig Σ τ› 4. ‹⋀x1 t τ. ⟦⋀τ. ⟦is_std_sig Σ; term_ok' Σ t; τ ∈ Types t⟧ ⟹ typ_ok_sig Σ τ; is_std_sig Σ; term_ok' Σ (Abs x1 t); τ ∈ Types (Abs x1 t)⟧ ⟹ typ_ok_sig Σ τ› 5. ‹⋀t1 t2 τ. ⟦⋀τ. ⟦is_std_sig Σ; term_ok' Σ t1; τ ∈ Types t1⟧ ⟹ typ_ok_sig Σ τ; ⋀τ. ⟦is_std_sig Σ; term_ok' Σ t2; τ ∈ Types t2⟧ ⟹ typ_ok_sig Σ τ; is_std_sig Σ; term_ok' Σ (t1 $ t2); τ ∈ Types (t1 $ t2)⟧ ⟹ typ_ok_sig Σ τ› discuss goal 1*) apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 2*) apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 3*) apply ((auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 4*) apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 5*) apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*proven 5 subgoals*) . lemma term_ok_Types_typ_ok: "wf_theory Θ ⟹ term_ok Θ t ⟹ τ ∈ Types t ⟹ typ_ok Θ τ" apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹⟦wf_theory Θ; term_ok Θ t; τ ∈ Types t⟧ ⟹ typ_ok Θ τ›*) by (fastforce simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) intro: term_ok_Types_imp_typ_ok_pre (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; ?τ ∈ Types ?t⟧ ⟹ typ_ok_sig ?Σ ?τ›*)) lemma term_ok_fv_imp_typ_ok_pre: "is_std_sig Σ ⟹ term_ok' Σ t ⟹ (x,τ) ∈ fv t ⟹ typ_ok_sig Σ τ" using typs_of_fv_subset_Types (*‹snd ` fv (?t::Core.term) ⊆ Types ?t›*) term_ok_Types_imp_typ_ok_pre (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; ?τ ∈ Types ?t⟧ ⟹ typ_ok_sig ?Σ ?τ›*) by (metis image_subset_iff (*‹(?f ` ?A ⊆ ?B) = (∀x∈?A. ?f x ∈ ?B)›*) snd_conv (*‹snd (?x1.0, ?x2.0) = ?x2.0›*)) lemma term_ok_vars_typ_ok: "wf_theory Θ ⟹ term_ok Θ t ⟹ (x, τ) ∈ fv t ⟹ typ_ok Θ τ" using term_ok_Types_typ_ok (*‹⟦wf_theory ?Θ; term_ok ?Θ ?t; ?τ ∈ Types ?t⟧ ⟹ typ_ok ?Θ ?τ›*) typs_of_fv_subset_Types (*‹snd ` fv (?t::Core.term) ⊆ Types ?t›*) by (metis image_subset_iff (*‹((?f::?'b ⇒ ?'a) ` (?A::?'b set) ⊆ (?B::?'a set)) = (∀x::?'b∈?A. ?f x ∈ ?B)›*) snd_conv (*‹snd (?x1.0::?'aa, ?x2.0::?'a) = ?x2.0›*)) lemma typ_ok_TFreesT_imp_sort_ok_pre: "is_std_sig Σ ⟹ typ_ok_sig Σ T ⟹ (x, S) ∈ tvsT T ⟹ wf_sort (subclass (osig Σ)) S" proof (induction T) (*goals: 1. ‹⋀x1 x2. ⟦⋀x2a. ⟦x2a ∈ set x2; is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (Ty x1 x2); (x, S) ∈ tvsT (Ty x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀x1 x2. ⟦is_std_sig Σ; typ_ok_sig Σ (Tv x1 x2); (x, S) ∈ tvsT (Tv x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (Ty n Ts) (*‹⟦?x2a ∈ set Ts; is_std_sig Σ; typ_ok_sig Σ ?x2a; (x, S) ∈ tvsT ?x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S› ‹is_std_sig Σ› ‹typ_ok_sig Σ (Ty n Ts)› ‹(x, S) ∈ tvsT (Ty n Ts)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)))) (S::String.literal set)›*) apply (induction Ts) (*goals: 1. ‹⟦⋀x2a. ⟦x2a ∈ set []; is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (constT n); (x, S) ∈ tvsT (constT n)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀a Ts. ⟦⟦⋀x2a. ⟦x2a ∈ set Ts; is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (Ty n Ts); (x, S) ∈ tvsT (Ty n Ts)⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀x2a. ⟦x2a ∈ set (a # Ts); is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (Ty n (a # Ts)); (x, S) ∈ tvsT (Ty n (a # Ts))⟧ ⟹ wf_sort (subclass (osig Σ)) S› discuss goal 1*) apply (fastforce dest: split_list (*‹?x ∈ set ?xs ⟹ ∃ys zs. ?xs = ys @ ?x # zs›*) split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 2*) apply (fastforce dest: split_list (*‹?x ∈ set ?xs ⟹ ∃ys zs. ?xs = ys @ ?x # zs›*) split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*proven 2 subgoals*) . qed (auto simp add: wf_sort_def (*‹wf_sort ?sub ?S = (normalized_sort ?sub ?S ∧ sort_ex ?sub ?S)›*)) (*solved the remaining goal: ‹⋀x1 x2. ⟦is_std_sig Σ; typ_ok_sig Σ (Tv x1 x2); (x, S) ∈ tvsT (Tv x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) lemma term_ok_TFrees_imp_sort_ok_pre: "is_std_sig Σ ⟹ term_ok' Σ t ⟹ (x, S) ∈ tvs t ⟹ wf_sort (subclass (osig Σ)) S" proof (induction t arbitrary: S) (*goals: 1. ‹⋀x1 x2 S. ⟦is_std_sig Σ; term_ok' Σ (Ct x1 x2); (x, S) ∈ tvs (Ct x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀x1 x2 S. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); (x, S) ∈ tvs (Fv x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 3. ‹⋀xa S. ⟦is_std_sig Σ; term_ok' Σ (Bv xa); (x, S) ∈ tvs (Bv xa)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 4. ‹⋀x1 t S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t; (x, S) ∈ tvs t⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (Abs x1 t); (x, S) ∈ tvs (Abs x1 t)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 5. ‹⋀t1 t2 S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t1; (x, S) ∈ tvs t1⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀S. ⟦is_std_sig Σ; term_ok' Σ t2; (x, S) ∈ tvs t2⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (t1 $ t2); (x, S) ∈ tvs (t1 $ t2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (Ct n T) (*‹is_std_sig Σ› ‹term_ok' Σ (Ct n T)› ‹(x, S) ∈ tvs (Ct n T)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig Σ)) S›*) apply (clarsimp split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*goal: ‹wf_sort (subclass (osig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)))) (S::String.literal set)›*) by (use typ_ok_TFreesT_imp_sort_ok_pre wf_sort_def in auto) next (*goals: 1. ‹⋀x1 x2 S. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); (x, S) ∈ tvs (Fv x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀xa S. ⟦is_std_sig Σ; term_ok' Σ (Bv xa); (x, S) ∈ tvs (Bv xa)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 3. ‹⋀x1 t S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t; (x, S) ∈ tvs t⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (Abs x1 t); (x, S) ∈ tvs (Abs x1 t)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 4. ‹⋀t1 t2 S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t1; (x, S) ∈ tvs t1⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀S. ⟦is_std_sig Σ; term_ok' Σ t2; (x, S) ∈ tvs t2⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (t1 $ t2); (x, S) ∈ tvs (t1 $ t2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (Fv n T) (*‹is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))› ‹term_ok' Σ (Fv n T)› ‹(x, S) ∈ tvs (Fv n T)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig Σ)) S›*) apply (clarsimp split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*goal: ‹wf_sort (subclass (osig Σ)) S›*) by (use typ_ok_TFreesT_imp_sort_ok_pre wf_sort_def in auto) next (*goals: 1. ‹⋀xa S. ⟦is_std_sig Σ; term_ok' Σ (Bv xa); (x, S) ∈ tvs (Bv xa)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀x1 t S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t; (x, S) ∈ tvs t⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (Abs x1 t); (x, S) ∈ tvs (Abs x1 t)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 3. ‹⋀t1 t2 S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t1; (x, S) ∈ tvs t1⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀S. ⟦is_std_sig Σ; term_ok' Σ t2; (x, S) ∈ tvs t2⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (t1 $ t2); (x, S) ∈ tvs (t1 $ t2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (Bv n) (*‹is_std_sig Σ› ‹term_ok' Σ (Bv n)› ‹(x, S) ∈ tvs (Bv n)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig Σ)) S›*) by (clarsimp split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) next (*goals: 1. ‹⋀x1 t S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t; (x, S) ∈ tvs t⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (Abs x1 t); (x, S) ∈ tvs (Abs x1 t)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀t1 t2 S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t1; (x, S) ∈ tvs t1⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀S. ⟦is_std_sig Σ; term_ok' Σ t2; (x, S) ∈ tvs t2⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (t1 $ t2); (x, S) ∈ tvs (t1 $ t2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (Abs T t) (*‹⟦is_std_sig Σ; term_ok' Σ t; (x, ?S) ∈ tvs t⟧ ⟹ wf_sort (subclass (osig Σ)) ?S› ‹is_std_sig Σ› ‹term_ok' Σ (Abs T t)› ‹(x, S) ∈ tvs (Abs T t)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)))) (S::String.literal set)›*) apply simp (*goal: ‹wf_sort (subclass (osig Σ)) S›*) using typ_ok_TFreesT_imp_sort_ok_pre (*‹⟦is_std_sig ?Σ; typ_ok_sig ?Σ ?T; (?x, ?S) ∈ tvsT ?T⟧ ⟹ wf_sort (subclass (osig ?Σ)) ?S›*) wf_sort_def (*‹wf_sort ?sub ?S = (normalized_sort ?sub ?S ∧ sort_ex ?sub ?S)›*) by meson next (*goal: ‹⋀t1 t2 S. ⟦⋀S. ⟦is_std_sig Σ; term_ok' Σ t1; (x, S) ∈ tvs t1⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀S. ⟦is_std_sig Σ; term_ok' Σ t2; (x, S) ∈ tvs t2⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; term_ok' Σ (t1 $ t2); (x, S) ∈ tvs (t1 $ t2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (App t1 t2) (*‹⟦is_std_sig Σ; term_ok' Σ t1; (x, ?S) ∈ tvs t1⟧ ⟹ wf_sort (subclass (osig Σ)) ?S› ‹⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ (t2::Core.term); (x::variable, ?S::String.literal set) ∈ tvs t2⟧ ⟹ wf_sort (subclass (osig Σ)) ?S› ‹is_std_sig Σ› ‹term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) ((t1::Core.term) $ (t2::Core.term))› ‹(x, S) ∈ tvs (t1 $ t2)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig Σ)) S›*) by auto qed lemma typ_ok_tvsT_imp_sort_ok_pre: "is_std_sig Σ ⟹ typ_ok_sig Σ T ⟹ (x,S) ∈ tvsT T ⟹ wf_sort (subclass (osig Σ)) S" proof (induction T) (*goals: 1. ‹⋀x1 x2. ⟦⋀x2a. ⟦x2a ∈ set x2; is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (Ty x1 x2); (x, S) ∈ tvsT (Ty x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀x1 x2. ⟦is_std_sig Σ; typ_ok_sig Σ (Tv x1 x2); (x, S) ∈ tvsT (Tv x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) case (Ty n Ts) (*‹⟦(?x2a::typ) ∈ set (Ts::typ list); is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); typ_ok_sig Σ ?x2a; (x::variable, S::String.literal set) ∈ tvsT ?x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S› ‹is_std_sig Σ› ‹typ_ok_sig Σ (Ty n Ts)› ‹(x, S) ∈ tvsT (Ty n Ts)›*) then show "?case" (*goal: ‹wf_sort (subclass (osig Σ)) S›*) apply (induction Ts) (*goals: 1. ‹⟦⋀x2a. ⟦x2a ∈ set []; is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (constT n); (x, S) ∈ tvsT (constT n)⟧ ⟹ wf_sort (subclass (osig Σ)) S› 2. ‹⋀a Ts. ⟦⟦⋀x2a. ⟦x2a ∈ set Ts; is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (Ty n Ts); (x, S) ∈ tvsT (Ty n Ts)⟧ ⟹ wf_sort (subclass (osig Σ)) S; ⋀x2a. ⟦x2a ∈ set (a # Ts); is_std_sig Σ; typ_ok_sig Σ x2a; (x, S) ∈ tvsT x2a⟧ ⟹ wf_sort (subclass (osig Σ)) S; is_std_sig Σ; typ_ok_sig Σ (Ty n (a # Ts)); (x, S) ∈ tvsT (Ty n (a # Ts))⟧ ⟹ wf_sort (subclass (osig Σ)) S› discuss goal 1*) apply (fastforce dest: split_list (*‹?x ∈ set ?xs ⟹ ∃ys zs. ?xs = ys @ ?x # zs›*) split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*discuss goal 2*) apply (fastforce dest: split_list (*‹?x ∈ set ?xs ⟹ ∃ys zs. ?xs = ys @ ?x # zs›*) split: option.split_asm (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*proven 2 subgoals*) . qed (auto simp add: wf_sort_def (*‹wf_sort (?sub::(String.literal × String.literal) set) (?S::String.literal set) = (normalized_sort ?sub ?S ∧ sort_ex ?sub ?S)›*)) (*solved the remaining goal: ‹⋀x1 x2. ⟦is_std_sig Σ; typ_ok_sig Σ (Tv x1 x2); (x, S) ∈ tvsT (Tv x1 x2)⟧ ⟹ wf_sort (subclass (osig Σ)) S›*) lemma term_ok_tvars_sort_ok: assumes "wf_theory Θ" "term_ok Θ t" "(x, S) ∈ tvs t" shows "wf_sort (subclass (osig (sig Θ))) S" proof (-) (*goal: ‹wf_sort (subclass (osig (sig Θ))) S›*) have "term_ok' (sig Θ) t" using assms(2) (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (t::Core.term)›*) by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) moreover have "is_std_sig (sig Θ)" using assms (*‹wf_theory Θ› ‹term_ok Θ t› ‹(x, S) ∈ tvs t›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀(cto::?'a::type) (tao::?'b::type) (sorts::?'c::type) axioms::?'d::type. (?Θ::(?'a::type × ?'b::type × ?'c::type) × ?'d::type) = ((cto, tao, sorts), axioms) ⟹ ?P::bool) ⟹ ?P›*)) (*goal: ‹is_std_sig (sig Θ)›*) by simp ultimately show "?thesis" (*goal: ‹wf_sort (subclass (osig (sig Θ))) S›*) using assms(3) (*‹(x, S) ∈ tvs t›*) term_ok_TFrees_imp_sort_ok_pre (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; (?x, ?S) ∈ tvs ?t⟧ ⟹ wf_sort (subclass (osig ?Σ)) ?S›*) by simp qed lemma term_ok'_bind_fv2: assumes "term_ok' Σ t" shows "term_ok' Σ (bind_fv2 (v,T) lev t)" using assms (*‹term_ok' Σ t›*) apply (induction "(v,T)" lev t rule: bind_fv2.induct (*‹⟦⋀vT n v T. ?P vT n (Fv v T); ⋀vT n T t. ?P vT (n + 1) t ⟹ ?P vT n (Abs T t); ⋀vT n f u. ⟦?P vT n f; ?P vT n u⟧ ⟹ ?P vT n (f $ u); ⋀uu_ uv_ v va. ?P uu_ uv_ (Ct v va); ⋀uu_ uv_ v. ?P uu_ uv_ (Bv v)⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀(n::nat) (va::variable) Ta::typ. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Fv va Ta) ⟹ term_ok' Σ (bind_fv2 (v::variable, T::typ) n (Fv va Ta))› 2. ‹⋀(n::nat) (Ta::typ) t::Core.term. ⟦term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) t ⟹ term_ok' Σ (bind_fv2 (v::variable, T::typ) (n + (1::nat)) t); term_ok' Σ (Abs Ta t)⟧ ⟹ term_ok' Σ (bind_fv2 (v, T) n (Abs Ta t))› 3. ‹⋀(n::nat) (f::Core.term) u::Core.term. ⟦term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) f ⟹ term_ok' Σ (bind_fv2 (v::variable, T::typ) n f); term_ok' Σ u ⟹ term_ok' Σ (bind_fv2 (v, T) n u); term_ok' Σ (f $ u)⟧ ⟹ term_ok' Σ (bind_fv2 (v, T) n (f $ u))› 4. ‹⋀(uv_::nat) (va::String.literal) vaa::typ. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Ct va vaa) ⟹ term_ok' Σ (bind_fv2 (v::variable, T::typ) uv_ (Ct va vaa))› 5. ‹⋀(uv_::nat) va::nat. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Bv va) ⟹ term_ok' Σ (bind_fv2 (v::variable, T::typ) uv_ (Bv va))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma term_ok'_bind_fv: assumes "term_ok' Σ t" shows "term_ok' Σ (bind_fv (v,τ) t)" using term_ok'_bind_fv2 (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (bind_fv2 (?v, ?T) ?lev ?t)›*) bind_fv_def (*‹bind_fv ?vT ?t = bind_fv2 ?vT 0 ?t›*) assms (*‹term_ok' Σ t›*) by metis lemma term_ok'_Abs_fv: assumes "term_ok' Σ t" "typ_ok_sig Σ τ" shows "term_ok' Σ (Abs τ (bind_fv (v,τ) t))" using term_ok'_bind_fv (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (bind_fv (?v, ?τ) ?t)›*) assms (*‹term_ok' Σ t› ‹typ_ok_sig Σ τ›*) by simp lemma term_ok'_mk_all: assumes "wf_theory Θ" and "term_ok' (sig Θ) B" and "typ_of B = Some propT" and "typ_ok Θ τ" shows "term_ok' (sig Θ) (mk_all x τ B)" using assms (*‹wf_theory Θ› ‹term_ok' (sig Θ) B› ‹typ_of (B::Core.term) = Some propT› ‹typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (τ::typ)›*) term_ok'_bind_fv (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (bind_fv (?v, ?τ) ?t)›*) apply (cases Θ rule: wf_theory.cases (*‹(⋀Σ axs. ?x = (Σ, axs) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹term_ok' (sig Θ) (mk_all x τ B)›*) by (auto simp add: typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) tinstT_def (*‹tinstT ?T1.0 ?T2.0 ≡ ∃ρ. tsubstT ?T2.0 ρ = ?T1.0›*)) lemma term_ok_mk_all: assumes "wf_theory Θ" and "term_ok' (sig Θ) B" and "typ_of B = Some propT" and "typ_ok Θ τ" shows "term_ok Θ (mk_all x τ B)" using typ_of_mk_all (*‹typ_of ?A = Some propT ⟹ typ_of (mk_all ?x ?ty ?A) = Some propT›*) term_ok'_mk_all (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok' (sig ?Θ) (?B::Core.term); typ_of ?B = Some propT; typ_ok ?Θ (?τ::typ)⟧ ⟹ term_ok' (sig ?Θ) (mk_all (?x::variable) ?τ ?B)›*) assms (*‹wf_theory Θ› ‹term_ok' (sig Θ) B› ‹typ_of (B::Core.term) = Some propT› ‹typ_ok Θ τ›*) by (auto simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) lemma term_ok'_incr_boundvars: "term_ok' (sig Θ) t ⟹ term_ok' (sig Θ) (incr_boundvars lev t)" using term_ok'_incr_bv (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (incr_bv ?inc ?lev ?t)›*) incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*) by simp lemma term_ok'_subst_bv1: assumes "term_ok' (sig Θ) f" and "term_ok' (sig Θ) u" shows "term_ok' (sig Θ) (subst_bv1 f lev u)" using assms (*‹term_ok' (sig Θ) f› ‹term_ok' (sig Θ) u›*) apply (induction f lev u rule: subst_bv1.induct (*‹⟦⋀(i::nat) (lev::nat) u::Core.term. (?P::Core.term ⇒ nat ⇒ Core.term ⇒ bool) (Bv i) lev u; ⋀(T::typ) (body::Core.term) (lev::nat) u::Core.term. ?P body (lev + (1::nat)) u ⟹ ?P (Abs T body) lev u; ⋀(f::Core.term) (t::Core.term) (lev::nat) u::Core.term. ⟦?P f lev u; ?P t lev u⟧ ⟹ ?P (f $ t) lev u; ⋀(v::String.literal) (va::typ) (uu_::nat) uv_::Core.term. ?P (Ct v va) uu_ uv_; ⋀(v::variable) (va::typ) (uu_::nat) uv_::Core.term. ?P (Fv v va) uu_ uv_⟧ ⟹ ?P (?a0.0::Core.term) (?a1.0::nat) (?a2.0::Core.term)›*)) (*goals: 1. ‹⋀(i::nat) (lev::nat) u::Core.term. ⟦term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (Bv i); term_ok' (sig Θ) u⟧ ⟹ term_ok' (sig Θ) (subst_bv1 (Bv i) lev u)› 2. ‹⋀(T::typ) (body::Core.term) (lev::nat) u::Core.term. ⟦⟦term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) body; term_ok' (sig Θ) u⟧ ⟹ term_ok' (sig Θ) (subst_bv1 body (lev + (1::nat)) u); term_ok' (sig Θ) (Abs T body); term_ok' (sig Θ) u⟧ ⟹ term_ok' (sig Θ) (subst_bv1 (Abs T body) lev u)› 3. ‹⋀(f::Core.term) (t::Core.term) (lev::nat) u::Core.term. ⟦⟦term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) f; term_ok' (sig Θ) u⟧ ⟹ term_ok' (sig Θ) (subst_bv1 f lev u); ⟦term_ok' (sig Θ) t; term_ok' (sig Θ) u⟧ ⟹ term_ok' (sig Θ) (subst_bv1 t lev u); term_ok' (sig Θ) (f $ t); term_ok' (sig Θ) u⟧ ⟹ term_ok' (sig Θ) (subst_bv1 (f $ t) lev u)› 4. ‹⋀(v::String.literal) (va::typ) (uu_::nat) uv_::Core.term. ⟦term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (Ct v va); term_ok' (sig Θ) uv_⟧ ⟹ term_ok' (sig Θ) (subst_bv1 (Ct v va) uu_ uv_)› 5. ‹⋀(v::variable) (va::typ) (uu_::nat) uv_::Core.term. ⟦term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (Fv v va); term_ok' (sig Θ) uv_⟧ ⟹ term_ok' (sig Θ) (subst_bv1 (Fv v va) uu_ uv_)› discuss goal 1*) apply ((use term_ok'_incr_boundvars in auto)[1]) (*discuss goal 2*) apply ((use term_ok'_incr_boundvars in auto)[1]) (*discuss goal 3*) apply ((use term_ok'_incr_boundvars in auto)[1]) (*discuss goal 4*) apply ((use term_ok'_incr_boundvars in auto)[1]) (*discuss goal 5*) apply ((use term_ok'_incr_boundvars in auto)[1]) (*proven 5 subgoals*) . lemma term_ok'_subst_bv: assumes "term_ok' (sig Θ) f" and "term_ok' (sig Θ) u" shows "term_ok' (sig Θ) (subst_bv f u)" using assms (*‹term_ok' (sig Θ) f› ‹term_ok' (sig Θ) u›*) term_ok'_subst_bv1 (*‹⟦term_ok' (sig ?Θ) ?f; term_ok' (sig ?Θ) ?u⟧ ⟹ term_ok' (sig ?Θ) (subst_bv1 ?f ?lev ?u)›*) subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*) by simp lemma term_ok'_betapply: assumes "term_ok' (sig Θ) f" "term_ok' (sig Θ) u" shows "term_ok' (sig Θ) (f ∙ u)" proof (cases "f") (*goals: 1. ‹⋀(x11::String.literal) x12::typ. (f::Core.term) = Ct x11 x12 ⟹ term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (f ∙ (u::Core.term))› 2. ‹⋀(x21::variable) x22::typ. (f::Core.term) = Fv x21 x22 ⟹ term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (f ∙ (u::Core.term))› 3. ‹⋀x3::nat. (f::Core.term) = Bv x3 ⟹ term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (f ∙ (u::Core.term))› 4. ‹⋀(x41::typ) x42::Core.term. (f::Core.term) = Abs x41 x42 ⟹ term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (f ∙ (u::Core.term))› 5. ‹⋀(x51::Core.term) x52::Core.term. (f::Core.term) = x51 $ x52 ⟹ term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (f ∙ (u::Core.term))›*) case (Abs T t) (*‹f = Abs T t›*) then show "?thesis" (*goal: ‹term_ok' (sig Θ) (f ∙ u)›*) using assms (*‹term_ok' (sig Θ) f› ‹term_ok' (sig Θ) u›*) term_ok'_subst_bv1 (*‹⟦term_ok' (sig ?Θ) ?f; term_ok' (sig ?Θ) ?u⟧ ⟹ term_ok' (sig ?Θ) (subst_bv1 ?f ?lev ?u)›*) by (simp add: subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*)) qed (use assms in auto) (*solves the remaining goals: 1. ‹⋀x11 x12. f = Ct x11 x12 ⟹ term_ok' (sig Θ) (f ∙ u)› 2. ‹⋀x21 x22. f = Fv x21 x22 ⟹ term_ok' (sig Θ) (f ∙ u)› 3. ‹⋀x3. f = Bv x3 ⟹ term_ok' (sig Θ) (f ∙ u)› 4. ‹⋀x51 x52. f = x51 $ x52 ⟹ term_ok' (sig Θ) (f ∙ u)›*) lemma term_ok_betapply: assumes "term_ok Θ f" "term_ok Θ u" assumes "typ_of f = Some (uty → tty)" "typ_of u = Some uty" shows "term_ok Θ (f ∙ u)" using assms (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (f::Core.term)› ‹term_ok Θ u› ‹typ_of f = Some (uty → tty)› ‹typ_of u = Some uty›*) term_ok'_betapply (*‹⟦term_ok' (sig ?Θ) ?f; term_ok' (sig ?Θ) ?u⟧ ⟹ term_ok' (sig ?Θ) (?f ∙ ?u)›*) wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) typ_of_betaply (*‹⟦typ_of ?t = Some (?uty → ?tty); typ_of ?u = Some ?uty⟧ ⟹ typ_of (?t ∙ ?u) = Some ?tty›*) assms (*‹term_ok Θ f› ‹term_ok Θ u› ‹typ_of f = Some (uty → tty)› ‹typ_of u = Some uty›*) by auto lemma typ_ok_sig_subst_typ: assumes "is_std_sig Σ" and "typ_ok_sig Σ ty" and "distinct (map fst insts)" and "list_all (typ_ok_sig Σ) (map snd insts)" shows "typ_ok_sig Σ (subst_typ insts ty)" using assms (*‹is_std_sig Σ› ‹typ_ok_sig Σ ty› ‹distinct (map fst insts)› ‹list_all (typ_ok_sig Σ) (map snd insts)›*) proof (induction insts ty rule: subst_typ.induct (*‹⟦⋀insts a Ts. (⋀x. x ∈ set Ts ⟹ ?P insts x) ⟹ ?P insts (Ty a Ts); ⋀insts idn S. ?P insts (Tv idn S)⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀(insts::((variable × String.literal set) × typ) list) (a::String.literal) Ts::typ list. ⟦⋀x::typ. ⟦x ∈ set Ts; is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); typ_ok_sig Σ x; distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ typ_ok_sig Σ (subst_typ insts x); is_std_sig Σ; typ_ok_sig Σ (Ty a Ts); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Ty a Ts))› 2. ‹⋀(insts::((variable × String.literal set) × typ) list) (idn::variable) S::String.literal set. ⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); typ_ok_sig Σ (Tv idn S); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Tv idn S))›*) case (1 inst a Ts) (*‹⟦?x ∈ set Ts; is_std_sig Σ; typ_ok_sig Σ ?x; distinct (map fst inst); list_all (typ_ok_sig Σ) (map snd inst)⟧ ⟹ typ_ok_sig Σ (subst_typ inst ?x)› ‹is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))› ‹typ_ok_sig Σ (Ty a Ts)› ‹distinct (map fst inst)› ‹list_all (typ_ok_sig Σ) (map snd inst)›*) have "typ_ok_sig Σ (subst_typ inst ty)" if "ty ∈ set Ts" for ty using that (*‹ty ∈ set Ts›*) "1" (*‹⟦?x ∈ set Ts; is_std_sig Σ; typ_ok_sig Σ ?x; distinct (map fst inst); list_all (typ_ok_sig Σ) (map snd inst)⟧ ⟹ typ_ok_sig Σ (subst_typ inst ?x)› ‹is_std_sig Σ› ‹typ_ok_sig Σ (Ty a Ts)› ‹distinct (map fst (inst::((variable × String.literal set) × typ) list))› ‹list_all (typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))) (map snd (inst::((variable × String.literal set) × typ) list))›*) by (auto simp add: list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) hence "∀ty ∈ set (map (subst_typ inst) Ts) . typ_ok_sig Σ ty" by simp hence "list_all (typ_ok_sig Σ) (map (subst_typ inst) Ts)" using list_all_iff (*‹list_all (?P::?'a ⇒ bool) (?x::?'a list) = Ball (set ?x) ?P›*) by blast moreover have "length (map (subst_typ inst) Ts) = length Ts" by simp ultimately show "?case" (*goal: ‹typ_ok_sig Σ (subst_typ inst (Ty a Ts))›*) using "1.prems" (*‹is_std_sig Σ› ‹typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Ty (a::String.literal) (Ts::typ list))› ‹distinct (map fst inst)› ‹list_all (typ_ok_sig Σ) (map snd inst)›*) by (auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) next (*goal: ‹⋀insts idn S. ⟦is_std_sig Σ; typ_ok_sig Σ (Tv idn S); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Tv idn S))›*) case (2 inst idn S) (*‹is_std_sig Σ› ‹typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Tv (idn::variable) (S::String.literal set))› ‹distinct (map fst inst)› ‹list_all (typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))) (map snd (inst::((variable × String.literal set) × typ) list))›*) then show "?case" (*goal: ‹typ_ok_sig Σ (subst_typ inst (Tv idn S))›*) proof (cases "lookup (λx. x = (idn, S)) inst ≠ None") (*goals: 1. ‹⟦is_std_sig Σ; typ_ok_sig Σ (Tv idn S); distinct (map fst inst); list_all (typ_ok_sig Σ) (map snd inst); lookup (λx. x = (idn, S)) inst ≠ None⟧ ⟹ typ_ok_sig Σ (subst_typ inst (Tv idn S))› 2. ‹⟦is_std_sig Σ; typ_ok_sig Σ (Tv idn S); distinct (map fst inst); list_all (typ_ok_sig Σ) (map snd inst); ¬ lookup (λx. x = (idn, S)) inst ≠ None⟧ ⟹ typ_ok_sig Σ (subst_typ inst (Tv idn S))›*) case True (*‹lookup (λx. x = (idn, S)) inst ≠ None›*) from this (*‹lookup (λx::variable × String.literal set. x = (idn::variable, S::String.literal set)) (inst::((variable × String.literal set) × typ) list) ≠ None›*) "2" (*‹is_std_sig Σ› ‹typ_ok_sig Σ (Tv idn S)› ‹distinct (map fst inst)› ‹list_all (typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))) (map snd (inst::((variable × String.literal set) × typ) list))›*) obtain res where res: "lookup (λx. x = (idn, S)) inst = Some res" (*goal: ‹(⋀res. lookup (λx. x = (idn, S)) inst = Some res ⟹ thesis) ⟹ thesis›*) by auto have "res ∈ set (map snd inst)" using "2" (*‹is_std_sig Σ› ‹typ_ok_sig Σ (Tv idn S)› ‹distinct (map fst (inst::((variable × String.literal set) × typ) list))› ‹list_all (typ_ok_sig Σ) (map snd inst)›*) res (*‹lookup (λx. x = (idn, S)) inst = Some res›*) apply (induction inst) (*goals: 1. ‹⟦is_std_sig Σ; typ_ok_sig Σ (Tv idn S); distinct (map fst []); list_all (typ_ok_sig Σ) (map snd []); lookup (λx. x = (idn, S)) [] = Some res⟧ ⟹ res ∈ set (map snd [])› 2. ‹⋀a inst. ⟦⟦is_std_sig Σ; typ_ok_sig Σ (Tv idn S); distinct (map fst inst); list_all (typ_ok_sig Σ) (map snd inst); lookup (λx. x = (idn, S)) inst = Some res⟧ ⟹ res ∈ set (map snd inst); is_std_sig Σ; typ_ok_sig Σ (Tv idn S); distinct (map fst (a # inst)); list_all (typ_ok_sig Σ) (map snd (a # inst)); lookup (λx. x = (idn, S)) (a # inst) = Some res⟧ ⟹ res ∈ set (map snd (a # inst))› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . hence "typ_ok_sig Σ res" using "2"(4) (*‹list_all (typ_ok_sig Σ) (map snd inst)›*) res (*‹lookup (λx. x = (idn, S)) inst = Some res›*) apply (induction inst) (*goals: 1. ‹⟦res ∈ set (map snd []); list_all (typ_ok_sig Σ) (map snd []); lookup (λx. x = (idn, S)) [] = Some res⟧ ⟹ typ_ok_sig Σ res› 2. ‹⋀a inst. ⟦⟦res ∈ set (map snd inst); list_all (typ_ok_sig Σ) (map snd inst); lookup (λx. x = (idn, S)) inst = Some res⟧ ⟹ typ_ok_sig Σ res; res ∈ set (map snd (a # inst)); list_all (typ_ok_sig Σ) (map snd (a # inst)); lookup (λx. x = (idn, S)) (a # inst) = Some res⟧ ⟹ typ_ok_sig Σ res› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: rev_image_eqI (*‹⟦?x ∈ ?A; ?b = ?f ?x⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: rev_image_eqI (*‹⟦?x ∈ ?A; ?b = ?f ?x⟧ ⟹ ?b ∈ ?f ` ?A›*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹typ_ok_sig Σ (subst_typ inst (Tv idn S))›*) using res (*‹lookup (λx. x = (idn, S)) inst = Some res›*) by simp next (*goal: ‹⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); typ_ok_sig Σ (Tv (idn::variable) (S::String.literal set)); distinct (map fst (inst::((variable × String.literal set) × typ) list)); list_all (typ_ok_sig Σ) (map snd inst); ¬ lookup (λx::variable × String.literal set. x = (idn, S)) inst ≠ None⟧ ⟹ typ_ok_sig Σ (subst_typ inst (Tv idn S))›*) case False (*‹¬ lookup (λx. x = (idn, S)) inst ≠ None›*) hence rewr: "subst_typ inst (Tv idn S) = Tv idn S" by auto then show "?thesis" (*goal: ‹typ_ok_sig Σ (subst_typ inst (Tv idn S))›*) using "2.prems"(2) (*‹typ_ok_sig Σ (Tv idn S)›*) by simp qed qed (* MOVE *) corollary subst_typ_tinstT: "tinstT (subst_typ insts ty) ty" unfolding tinstT_def (*goal: ‹∃ρ. tsubstT ty ρ = subst_typ insts ty›*) using tsubstT_simulates_subst_typ (*‹subst_typ ?insts ?T = tsubstT ?T (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) ?insts))›*) by fastforce lemma tsubstT_trans: "tsubstT ty ρ1 = ty1 ⟹ tsubstT ty1 ρ2 = ty2 ⟹ tsubstT ty (λidx s . case ρ1 idx s of Tv idx' s' ⇒ ρ2 idx' s' | Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts)) = ty2" unfolding tinstT_def (*goal: ‹⟦tsubstT (ty::typ) (ρ1::variable ⇒ String.literal set ⇒ typ) = (ty1::typ); tsubstT ty1 (ρ2::variable ⇒ String.literal set ⇒ typ) = (ty2::typ)⟧ ⟹ tsubstT ty (λ(idx::variable) s::String.literal set. case ρ1 idx s of Ty (s::String.literal) (Ts::typ list) ⇒ Ty s (map (λT::typ. tsubstT T ρ2) Ts) | Tv (idx'::variable) (s'::String.literal set) ⇒ ρ2 idx' s') = ty2›*) proof (induction ty arbitrary: ty1 ty2) (*goals: 1. ‹⋀x1 x2 ty1 ty2. ⟦⋀x2a ty1 ty2. ⟦x2a ∈ set x2; tsubstT x2a ρ1 = ty1; tsubstT ty1 ρ2 = ty2⟧ ⟹ tsubstT x2a (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv x xa ⇒ ρ2 x xa) = ty2; tsubstT (Ty x1 x2) ρ1 = ty1; tsubstT ty1 ρ2 = ty2⟧ ⟹ tsubstT (Ty x1 x2) (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv x xa ⇒ ρ2 x xa) = ty2› 2. ‹⋀x1 x2 ty1 ty2. ⟦tsubstT (Tv x1 x2) ρ1 = ty1; tsubstT ty1 ρ2 = ty2⟧ ⟹ tsubstT (Tv x1 x2) (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv x xa ⇒ ρ2 x xa) = ty2›*) case (Tv idx s) (*‹tsubstT (Tv idx s) ρ1 = ty1› ‹tsubstT ty1 ρ2 = ty2›*) then show "?case" (*goal: ‹tsubstT (Tv (idx::variable) (s::String.literal set)) (λ(idx::variable) s::String.literal set. case (ρ1::variable ⇒ String.literal set ⇒ typ) idx s of Ty (s::String.literal) (Ts::typ list) ⇒ Ty s (map (λT::typ. tsubstT T (ρ2::variable ⇒ String.literal set ⇒ typ)) Ts) | Tv (a::variable) (b::String.literal set) ⇒ ρ2 a b) = (ty2::typ)›*) apply (cases "ρ1 idx s") (*goals: 1. ‹⋀x11 x12. ⟦tsubstT (Tv idx s) ρ1 = ty1; tsubstT ty1 ρ2 = ty2; ρ1 idx s = Ty x11 x12⟧ ⟹ tsubstT (Tv idx s) (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv a b ⇒ ρ2 a b) = ty2› 2. ‹⋀x21 x22. ⟦tsubstT (Tv idx s) ρ1 = ty1; tsubstT ty1 ρ2 = ty2; ρ1 idx s = Tv x21 x22⟧ ⟹ tsubstT (Tv idx s) (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv a b ⇒ ρ2 a b) = ty2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (auto) (*solved the remaining goal: ‹⋀x1 x2 ty1 ty2. ⟦⋀x2a ty1 ty2. ⟦x2a ∈ set x2; tsubstT x2a ρ1 = ty1; tsubstT ty1 ρ2 = ty2⟧ ⟹ tsubstT x2a (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv x xa ⇒ ρ2 x xa) = ty2; tsubstT (Ty x1 x2) ρ1 = ty1; tsubstT ty1 ρ2 = ty2⟧ ⟹ tsubstT (Ty x1 x2) (λidx s. case ρ1 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ρ2) Ts) | Tv x xa ⇒ ρ2 x xa) = ty2›*) corollary tinstT_trans: "tinstT ty1 ty ⟹ tinstT ty2 ty1 ⟹ tinstT ty2 ty" unfolding tinstT_def (*goal: ‹⟦∃ρ. tsubstT ty ρ = ty1; ∃ρ. tsubstT ty1 ρ = ty2⟧ ⟹ ∃ρ. tsubstT ty ρ = ty2›*) using tsubstT_trans (*‹⟦tsubstT ?ty ?ρ1.0 = ?ty1.0; tsubstT ?ty1.0 ?ρ2.0 = ?ty2.0⟧ ⟹ tsubstT ?ty (λidx s. case ?ρ1.0 idx s of Ty s Ts ⇒ Ty s (map (λT. tsubstT T ?ρ2.0) Ts) | Tv idx' s' ⇒ ?ρ2.0 idx' s') = ?ty2.0›*) by blast lemma term_ok'_subst_typ': assumes "is_std_sig Σ" and "term_ok' Σ t" and "distinct (map fst insts)" and "list_all (typ_ok_sig Σ) (map snd insts)" shows "term_ok' Σ (subst_typ' insts t)" using assms (*‹is_std_sig Σ› ‹term_ok' Σ t› ‹distinct (map fst insts)› ‹list_all (typ_ok_sig Σ) (map snd insts)›*) apply (induction t) (*goals: 1. ‹⋀x1 x2. ⟦is_std_sig Σ; term_ok' Σ (Ct x1 x2); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts (Ct x1 x2))› 2. ‹⋀x1 x2. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts (Fv x1 x2))› 3. ‹⋀x. ⟦is_std_sig Σ; term_ok' Σ (Bv x); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts (Bv x))› 4. ‹⋀x1 t. ⟦⟦is_std_sig Σ; term_ok' Σ t; distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts t); is_std_sig Σ; term_ok' Σ (Abs x1 t); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts (Abs x1 t))› 5. ‹⋀t1 t2. ⟦⟦is_std_sig Σ; term_ok' Σ t1; distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts t1); ⟦is_std_sig Σ; term_ok' Σ t2; distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts t2); is_std_sig Σ; term_ok' Σ (t1 $ t2); distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts (t1 $ t2))› discuss goal 1*) apply ((use typ_ok_sig_subst_typ subst_typ_tinstT tinstT_trans in ‹auto split: option.splits›)[1]) (*discuss goal 2*) apply ((use typ_ok_sig_subst_typ subst_typ_tinstT tinstT_trans in ‹auto split: option.splits›)[1]) (*discuss goal 3*) apply ((use typ_ok_sig_subst_typ subst_typ_tinstT tinstT_trans in ‹auto split: option.splits›)[1]) (*discuss goal 4*) apply ((use typ_ok_sig_subst_typ subst_typ_tinstT tinstT_trans in ‹auto split: option.splits›)[1]) (*discuss goal 5*) apply ((use typ_ok_sig_subst_typ subst_typ_tinstT tinstT_trans in ‹auto split: option.splits›)[1]) (*proven 5 subgoals*) . (* This is a bit suspect, as I am disregarding abstractions... *) lemma term_ok'_occs: "is_std_sig Σ ⟹ term_ok' Σ t ⟹ occs u t ⟹ term_ok' Σ u" apply (induction t) (*goals: 1. ‹⋀(x1::String.literal) x2::typ. ⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ (Ct x1 x2); occs (u::Core.term) (Ct x1 x2)⟧ ⟹ term_ok' Σ u› 2. ‹⋀(x1::variable) x2::typ. ⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ (Fv x1 x2); occs (u::Core.term) (Fv x1 x2)⟧ ⟹ term_ok' Σ u› 3. ‹⋀x::nat. ⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ (Bv x); occs (u::Core.term) (Bv x)⟧ ⟹ term_ok' Σ u› 4. ‹⋀(x1::typ) t::Core.term. ⟦⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ t; occs (u::Core.term) t⟧ ⟹ term_ok' Σ u; is_std_sig Σ; term_ok' Σ (Abs x1 t); occs u (Abs x1 t)⟧ ⟹ term_ok' Σ u› 5. ‹⋀(t1::Core.term) t2::Core.term. ⟦⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ t1; occs (u::Core.term) t1⟧ ⟹ term_ok' Σ u; ⟦is_std_sig Σ; term_ok' Σ t2; occs u t2⟧ ⟹ term_ok' Σ u; is_std_sig Σ; term_ok' Σ (t1 $ t2); occs u (t1 $ t2)⟧ ⟹ term_ok' Σ u› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma typ_of1_tsubst: "typ_of1 Ts t = Some ty ⟹ typ_of1 (map (λT . tsubstT T ρ) Ts) (tsubst t ρ) = Some (tsubstT ty ρ)" proof (induction Ts t arbitrary: ty rule: typ_of1.induct) (*goals: 1. ‹⋀uu_ uv_ T ty. typ_of1 uu_ (Ct uv_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uu_) (tsubst (Ct uv_ T) ρ) = Some (tsubstT ty ρ)› 2. ‹⋀Ts i ty. typ_of1 Ts (Bv i) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (Bv i) ρ) = Some (tsubstT ty ρ)› 3. ‹⋀uw_ ux_ T ty. typ_of1 uw_ (Fv ux_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uw_) (tsubst (Fv ux_ T) ρ) = Some (tsubstT ty ρ)› 4. ‹⋀Ts T body ty. ⟦⋀ty. typ_of1 (T # Ts) body = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) (T # Ts)) (tsubst body ρ) = Some (tsubstT ty ρ); typ_of1 Ts (Abs T body) = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (Abs T body) ρ) = Some (tsubstT ty ρ)› 5. ‹⋀Ts t u ty. ⟦⋀ty. typ_of1 Ts u = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst u ρ) = Some (tsubstT ty ρ); ⋀a ty. ⟦typ_of1 Ts u = Some a; typ_of1 Ts t = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst t ρ) = Some (tsubstT ty ρ); typ_of1 Ts (t $ u) = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (t $ u) ρ) = Some (tsubstT ty ρ)›*) case (2 Ts i) (*‹typ_of1 Ts (Bv i) = Some ty›*) then show "?case" (*goal: ‹typ_of1 (map (λT::typ. tsubstT T (ρ::variable ⇒ String.literal set ⇒ typ)) (Ts::typ list)) (tsubst (Bv (i::nat)) ρ) = Some (tsubstT (ty::typ) ρ)›*) by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goals: 1. ‹⋀uu_ uv_ T ty. typ_of1 uu_ (Ct uv_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uu_) (tsubst (Ct uv_ T) ρ) = Some (tsubstT ty ρ)› 2. ‹⋀uw_ ux_ T ty. typ_of1 uw_ (Fv ux_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uw_) (tsubst (Fv ux_ T) ρ) = Some (tsubstT ty ρ)› 3. ‹⋀Ts T body ty. ⟦⋀ty. typ_of1 (T # Ts) body = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) (T # Ts)) (tsubst body ρ) = Some (tsubstT ty ρ); typ_of1 Ts (Abs T body) = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (Abs T body) ρ) = Some (tsubstT ty ρ)› 4. ‹⋀Ts t u ty. ⟦⋀ty. typ_of1 Ts u = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst u ρ) = Some (tsubstT ty ρ); ⋀a ty. ⟦typ_of1 Ts u = Some a; typ_of1 Ts t = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst t ρ) = Some (tsubstT ty ρ); typ_of1 Ts (t $ u) = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (t $ u) ρ) = Some (tsubstT ty ρ)›*) case (4 Ts T body) (*‹typ_of1 ((T::typ) # (Ts::typ list)) (body::Core.term) = Some (?ty::typ) ⟹ typ_of1 (map (λT::typ. tsubstT T (ρ::variable ⇒ String.literal set ⇒ typ)) (T # Ts)) (tsubst body ρ) = Some (tsubstT ?ty ρ)› ‹typ_of1 (Ts::typ list) (Abs (T::typ) (body::Core.term)) = Some (ty::typ)›*) then show "?case" (*goal: ‹typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (Abs T body) ρ) = Some (tsubstT ty ρ)›*) by (auto simp add: bind_eq_Some_conv (*‹(Option.bind (?f::?'b option) (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*)) next (*goals: 1. ‹⋀uu_ uv_ T ty. typ_of1 uu_ (Ct uv_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uu_) (tsubst (Ct uv_ T) ρ) = Some (tsubstT ty ρ)› 2. ‹⋀uw_ ux_ T ty. typ_of1 uw_ (Fv ux_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uw_) (tsubst (Fv ux_ T) ρ) = Some (tsubstT ty ρ)› 3. ‹⋀Ts t u ty. ⟦⋀ty. typ_of1 Ts u = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst u ρ) = Some (tsubstT ty ρ); ⋀a ty. ⟦typ_of1 Ts u = Some a; typ_of1 Ts t = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst t ρ) = Some (tsubstT ty ρ); typ_of1 Ts (t $ u) = Some ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (t $ u) ρ) = Some (tsubstT ty ρ)›*) case (5 Ts f u) (*‹typ_of1 Ts u = Some ?ty ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst u ρ) = Some (tsubstT ?ty ρ)› ‹⟦typ_of1 Ts u = Some ?a; typ_of1 Ts f = Some ?ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst f ρ) = Some (tsubstT ?ty ρ)› ‹typ_of1 Ts (f $ u) = Some ty›*) from "5.prems" (*‹typ_of1 Ts (f $ u) = Some ty›*) obtain u_ty where u_ty: "typ_of1 Ts u = Some u_ty" (*goal: ‹(⋀u_ty. typ_of1 Ts u = Some u_ty ⟹ thesis) ⟹ thesis›*) by (auto simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*)) from this (*‹typ_of1 Ts u = Some u_ty›*) "5.prems" (*‹typ_of1 Ts (f $ u) = Some ty›*) have f_ty: "typ_of1 Ts f = Some (u_ty → ty)" by (auto simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) typ_of1_arg_typ[OF "5.prems"(1)] (*‹typ_of1 Ts u = Some ?U ⟹ typ_of1 Ts f = Some (?U → ty)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) typ.splits (*‹?P (case ?typ of Ty x xa ⇒ ?f1.0 x xa | Tv x xa ⇒ ?f2.0 x xa) = ((∀x11 x12. ?typ = Ty x11 x12 ⟶ ?P (?f1.0 x11 x12)) ∧ (∀x21 x22. ?typ = Tv x21 x22 ⟶ ?P (?f2.0 x21 x22)))› ‹?P (case ?typ of Ty x xa ⇒ ?f1.0 x xa | Tv x xa ⇒ ?f2.0 x xa) = (¬ ((∃x11 x12. ?typ = Ty x11 x12 ∧ ¬ ?P (?f1.0 x11 x12)) ∨ (∃x21 x22. ?typ = Tv x21 x22 ∧ ¬ ?P (?f2.0 x21 x22))))›*) option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) from u_ty (*‹typ_of1 Ts u = Some u_ty›*) "5.IH"(1) (*‹typ_of1 Ts u = Some ?ty ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst u ρ) = Some (tsubstT ?ty ρ)›*) have "typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst u ρ) = Some (tsubstT u_ty ρ)" by simp moreover from u_ty (*‹typ_of1 Ts u = Some u_ty›*) f_ty (*‹typ_of1 Ts f = Some (u_ty → ty)›*) "5.IH"(2) (*‹⟦typ_of1 Ts u = Some ?a; typ_of1 Ts f = Some ?ty⟧ ⟹ typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst f ρ) = Some (tsubstT ?ty ρ)›*) have "typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst f ρ) = Some (tsubstT (u_ty → ty) ρ)" by simp ultimately show "?case" (*goal: ‹typ_of1 (map (λT. tsubstT T ρ) Ts) (tsubst (f $ u) ρ) = Some (tsubstT ty ρ)›*) by simp qed (auto) (*solves the remaining goals: 1. ‹⋀uu_ uv_ T ty. typ_of1 uu_ (Ct uv_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uu_) (tsubst (Ct uv_ T) ρ) = Some (tsubstT ty ρ)› 2. ‹⋀uw_ ux_ T ty. typ_of1 uw_ (Fv ux_ T) = Some ty ⟹ typ_of1 (map (λT. tsubstT T ρ) uw_) (tsubst (Fv ux_ T) ρ) = Some (tsubstT ty ρ)›*) corollary typ_of1_tsubst_weak: assumes "typ_of1 Ts t = Some ty" assumes "typ_of1 (map (λT . tsubstT T ρ) Ts) (tsubst t ρ) = Some ty'" shows "tsubstT ty ρ = ty'" using assms (*‹typ_of1 Ts t = Some ty› ‹typ_of1 (map (λT::typ. tsubstT T (ρ::variable ⇒ String.literal set ⇒ typ)) (Ts::typ list)) (tsubst (t::Core.term) ρ) = Some (ty'::typ)›*) typ_of1_tsubst (*‹typ_of1 (?Ts::typ list) (?t::Core.term) = Some (?ty::typ) ⟹ typ_of1 (map (λT::typ. tsubstT T (?ρ::variable ⇒ String.literal set ⇒ typ)) ?Ts) (tsubst ?t ?ρ) = Some (tsubstT ?ty ?ρ)›*) by auto lemma tsubstT_no_change[simp]: "tsubstT T Tv = T" apply (induction T) (*goals: 1. ‹⋀x1 x2. (⋀x2a. x2a ∈ set x2 ⟹ tsubstT x2a Tv = x2a) ⟹ tsubstT (Ty x1 x2) Tv = Ty x1 x2› 2. ‹⋀x1 x2. tsubstT (Tv x1 x2) Tv = Tv x1 x2› discuss goal 1*) apply ((auto simp add: map_idI (*‹(⋀x. x ∈ set ?xs ⟹ ?f x = x) ⟹ map ?f ?xs = ?xs›*))[1]) (*discuss goal 2*) apply ((auto simp add: map_idI (*‹(⋀x::?'a. x ∈ set (?xs::?'a list) ⟹ (?f::?'a ⇒ ?'a) x = x) ⟹ map ?f ?xs = ?xs›*))[1]) (*proven 2 subgoals*) . lemma term_ok_mk_eq_same_typ: assumes "wf_theory Θ" assumes "term_ok Θ (mk_eq s t)" shows "typ_of s = typ_of t" using assms (*‹wf_theory Θ› ‹term_ok Θ (mk_eq s t)›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹typ_of s = typ_of t›*) by (fastforce simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) tinstT_def (*‹tinstT ?T1.0 ?T2.0 ≡ ∃ρ. tsubstT ?T2.0 ρ = ?T1.0›*)) lemma typ_of_eta_expand: "typ_of f = Some (τ → τ') ⟹ typ_of (Abs τ (f $ Bv 0)) = Some (τ → τ')" using typ_of1_weaken (*‹typ_of1 ?Ts ?t = Some ?T ⟹ typ_of1 (?Ts @ ?Ts') ?t = Some ?T›*) by (fastforce simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) lemma term_okI: "term_ok' (sig Θ) t ⟹ typ_of t ≠ None ⟹ term_ok Θ t" by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) lemma term_okD1: "term_ok Θ t ⟹ term_ok' (sig Θ) t" by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) lemma term_okD2: "term_ok Θ t ⟹ typ_of t ≠ None" by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) lemma term_ok_imp_typ_ok': assumes "wf_theory Θ" "term_ok Θ t" shows "typ_ok Θ (the (typ_of t))" proof (-) (*goal: ‹typ_ok Θ (the (typ_of t))›*) obtain ty where ty: "typ_of t = Some ty" (*goal: ‹(⋀ty. typ_of t = Some ty ⟹ thesis) ⟹ thesis›*) by (meson assms (*‹wf_theory Θ› ‹term_ok Θ t›*) option.exhaust (*‹⟦?y = None ⟹ ?P; ⋀x2. ?y = Some x2 ⟹ ?P⟧ ⟹ ?P›*) term_okD2 (*‹term_ok ?Θ ?t ⟹ typ_of ?t ≠ None›*)) hence "typ_ok Θ ty" using term_ok_imp_typ_ok (*‹⟦wf_theory (?thy::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok ?thy (?t::Core.term); typ_of ?t = Some (?ty::typ)⟧ ⟹ typ_ok ?thy ?ty›*) assms (*‹wf_theory Θ› ‹term_ok Θ t›*) by blast thus "?thesis" (*goal: ‹typ_ok Θ (the (typ_of t))›*) using ty (*‹typ_of t = Some ty›*) by simp qed lemma term_ok_mk_eqI: assumes "wf_theory Θ" "term_ok Θ s" "term_ok Θ t" "typ_of s = typ_of t" shows"term_ok Θ (mk_eq s t)" proof (rule term_okI (*‹⟦term_ok' (sig ?Θ) ?t; typ_of ?t ≠ None⟧ ⟹ term_ok ?Θ ?t›*)) (*goals: 1. ‹term_ok' (sig Θ) (mk_eq s t)› 2. ‹typ_of (mk_eq s t) ≠ None›*) have "typ_ok Θ (the (typ_of t))" using assms(1) (*‹wf_theory Θ›*) assms(3) (*‹term_ok Θ t›*) term_ok_imp_typ_ok' (*‹⟦wf_theory ?Θ; term_ok ?Θ ?t⟧ ⟹ typ_ok ?Θ (the (typ_of ?t))›*) by blast hence "typ_ok_sig (sig Θ) (the (typ_of t))" by simp then show "term_ok' (sig Θ) (mk_eq s t)" using assms (*‹wf_theory Θ› ‹term_ok Θ s› ‹term_ok Θ t› ‹typ_of s = typ_of t›*) apply - (*goal: ‹term_ok' (sig Θ) (mk_eq s t)›*) apply (drule term_okD1 (*‹term_ok ?Θ ?t ⟹ term_ok' (sig ?Θ) ?t›*)) (*goal: ‹⟦typ_ok_sig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (the (typ_of (t::Core.term))); wf_theory Θ; term_ok Θ (s::Core.term); term_ok Θ t; typ_of s = typ_of t⟧ ⟹ term_ok' (sig Θ) (mk_eq s t)›*) apply (drule term_okD1 (*‹term_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?t::Core.term) ⟹ term_ok' (sig ?Θ) ?t›*)) (*goal: ‹⟦typ_ok_sig (sig Θ) (the (typ_of t)); wf_theory Θ; term_ok Θ t; typ_of s = typ_of t; term_ok' (sig Θ) s⟧ ⟹ term_ok' (sig Θ) (mk_eq s t)›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹⟦typ_ok_sig (sig Θ) (the (typ_of t)); wf_theory Θ; typ_of s = typ_of t; term_ok' (sig Θ) s; term_ok' (sig Θ) t⟧ ⟹ term_ok' (sig Θ) (mk_eq s t)›*) by (auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: tinstT_def (*‹tinstT (?T1.0::typ) (?T2.0::typ) ≡ ∃ρ::variable ⇒ String.literal set ⇒ typ. tsubstT ?T2.0 ρ = ?T1.0›*)) next (*goal: ‹typ_of (mk_eq s t) ≠ None›*) show "typ_of (mk_eq s t) ≠ None" using assms (*‹wf_theory Θ› ‹term_ok Θ s› ‹term_ok Θ t› ‹typ_of s = typ_of t›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) by (auto dest: term_okD2 (*‹term_ok ?Θ ?t ⟹ typ_of ?t ≠ None›*) simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) qed lemma typ_of1_decr': "¬ loose_bvar1 t 0 ⟹ typ_of1 (T#Ts) t = Some τ ⟹ typ_of1 Ts (decr 0 t) = Some τ" proof (induction Ts t arbitrary: T τ rule: typ_of1.induct) (*goals: 1. ‹⋀uu_ uv_ T Ta τ. ⟦¬ loose_bvar1 (Ct uv_ T) 0; typ_of1 (Ta # uu_) (Ct uv_ T) = Some τ⟧ ⟹ typ_of1 uu_ (decr 0 (Ct uv_ T)) = Some τ› 2. ‹⋀Ts i T τ. ⟦¬ loose_bvar1 (Bv i) 0; typ_of1 (T # Ts) (Bv i) = Some τ⟧ ⟹ typ_of1 Ts (decr 0 (Bv i)) = Some τ› 3. ‹⋀uw_ ux_ T Ta τ. ⟦¬ loose_bvar1 (Fv ux_ T) 0; typ_of1 (Ta # uw_) (Fv ux_ T) = Some τ⟧ ⟹ typ_of1 uw_ (decr 0 (Fv ux_ T)) = Some τ› 4. ‹⋀Ts T body Ta τ. ⟦⋀Ta τ. ⟦¬ loose_bvar1 body 0; typ_of1 (Ta # T # Ts) body = Some τ⟧ ⟹ typ_of1 (T # Ts) (decr 0 body) = Some τ; ¬ loose_bvar1 (Abs T body) 0; typ_of1 (Ta # Ts) (Abs T body) = Some τ⟧ ⟹ typ_of1 Ts (decr 0 (Abs T body)) = Some τ› 5. ‹⋀Ts t u T τ. ⟦⋀T τ. ⟦¬ loose_bvar1 u 0; typ_of1 (T # Ts) u = Some τ⟧ ⟹ typ_of1 Ts (decr 0 u) = Some τ; ⋀a T τ. ⟦typ_of1 Ts u = Some a; ¬ loose_bvar1 t 0; typ_of1 (T # Ts) t = Some τ⟧ ⟹ typ_of1 Ts (decr 0 t) = Some τ; ¬ loose_bvar1 (t $ u) 0; typ_of1 (T # Ts) (t $ u) = Some τ⟧ ⟹ typ_of1 Ts (decr 0 (t $ u)) = Some τ›*) case (4 Ts B body) (*‹⟦¬ loose_bvar1 body 0; typ_of1 (?T # B # Ts) body = Some ?τ⟧ ⟹ typ_of1 (B # Ts) (decr 0 body) = Some ?τ› ‹¬ loose_bvar1 (Abs B body) 0› ‹typ_of1 (T # Ts) (Abs B body) = Some τ›*) then show "?case" (*goal: ‹typ_of1 Ts (decr 0 (Abs B body)) = Some τ›*) using typ_of1_decr_gen (*‹⟦typ_of1 (?Ts @ [?T] @ ?Ts') ?t = ?tyo; ¬ loose_bvar1 ?t (length ?Ts)⟧ ⟹ typ_of1 (?Ts @ ?Ts') (decr (length ?Ts) ?t) = ?tyo›*) apply (simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*goal: ‹typ_of1 Ts (decr 0 (Abs B body)) = Some τ›*) by (metis append_Cons (*‹(?x # ?xs) @ ?ys = ?x # ?xs @ ?ys›*) append_Nil (*‹[] @ ?ys = ?ys›*) length_Cons (*‹length (?x # ?xs) = Suc (length ?xs)›*) list.size( (*‹length [] = 0›*) 3) typ_of1_decr_gen (*‹⟦typ_of1 (?Ts @ [?T] @ ?Ts') ?t = ?tyo; ¬ loose_bvar1 ?t (length ?Ts)⟧ ⟹ typ_of1 (?Ts @ ?Ts') (decr (length ?Ts) ?t) = ?tyo›*)) next (*goals: 1. ‹⋀uu_ uv_ T Ta τ. ⟦¬ loose_bvar1 (Ct uv_ T) 0; typ_of1 (Ta # uu_) (Ct uv_ T) = Some τ⟧ ⟹ typ_of1 uu_ (decr 0 (Ct uv_ T)) = Some τ› 2. ‹⋀Ts i T τ. ⟦¬ loose_bvar1 (Bv i) 0; typ_of1 (T # Ts) (Bv i) = Some τ⟧ ⟹ typ_of1 Ts (decr 0 (Bv i)) = Some τ› 3. ‹⋀uw_ ux_ T Ta τ. ⟦¬ loose_bvar1 (Fv ux_ T) 0; typ_of1 (Ta # uw_) (Fv ux_ T) = Some τ⟧ ⟹ typ_of1 uw_ (decr 0 (Fv ux_ T)) = Some τ› 4. ‹⋀Ts t u T τ. ⟦⋀T τ. ⟦¬ loose_bvar1 u 0; typ_of1 (T # Ts) u = Some τ⟧ ⟹ typ_of1 Ts (decr 0 u) = Some τ; ⋀a T τ. ⟦typ_of1 Ts u = Some a; ¬ loose_bvar1 t 0; typ_of1 (T # Ts) t = Some τ⟧ ⟹ typ_of1 Ts (decr 0 t) = Some τ; ¬ loose_bvar1 (t $ u) 0; typ_of1 (T # Ts) (t $ u) = Some τ⟧ ⟹ typ_of1 Ts (decr 0 (t $ u)) = Some τ›*) case (5 Ts f u) (*‹⟦¬ loose_bvar1 u 0; typ_of1 (?T # Ts) u = Some ?τ⟧ ⟹ typ_of1 Ts (decr 0 u) = Some ?τ› ‹⟦typ_of1 Ts u = Some ?a; ¬ loose_bvar1 f 0; typ_of1 (?T # Ts) f = Some ?τ⟧ ⟹ typ_of1 Ts (decr 0 f) = Some ?τ› ‹¬ loose_bvar1 (f $ u) 0› ‹typ_of1 (T # Ts) (f $ u) = Some τ›*) then show "?case" (*goal: ‹typ_of1 Ts (decr 0 (f $ u)) = Some τ›*) apply (simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*goal: ‹typ_of1 Ts (decr 0 (f $ u)) = Some τ›*) by (smt no_loose_bvar1_subst_bv2_decr (*‹¬ loose_bvar1 ?t ?i ⟹ subst_bv2 ?t ?i ?x = decr ?i ?t›*) subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*) substn_subst_0' (*‹subst_bv ?s ?t = subst_bv2 ?t 0 ?s›*) typ_of1.simps( (*‹typ_of1 ?uw (Fv ?ux ?T) = Some ?T›*) 3) typ_of1_subst_bv_gen' (*‹⟦typ_of1 (?uty # ?Ts) ?t = Some ?tty; typ_of1 ?Ts ?u = Some ?uty⟧ ⟹ typ_of1 ?Ts (subst_bv1 ?t 0 ?u) = Some ?tty›*)) qed (auto simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*solves the remaining goals: 1. ‹⋀uu_ uv_ T Ta τ. ⟦¬ loose_bvar1 (Ct uv_ T) 0; typ_of1 (Ta # uu_) (Ct uv_ T) = Some τ⟧ ⟹ typ_of1 uu_ (decr 0 (Ct uv_ T)) = Some τ› 2. ‹⋀Ts i T τ. ⟦¬ loose_bvar1 (Bv i) 0; typ_of1 (T # Ts) (Bv i) = Some τ⟧ ⟹ typ_of1 Ts (decr 0 (Bv i)) = Some τ› 3. ‹⋀uw_ ux_ T Ta τ. ⟦¬ loose_bvar1 (Fv ux_ T) 0; typ_of1 (Ta # uw_) (Fv ux_ T) = Some τ⟧ ⟹ typ_of1 uw_ (decr 0 (Fv ux_ T)) = Some τ›*) lemma typ_of1_eta_red_step_pre: "¬ loose_bvar1 t 0 ⟹ typ_of1 Ts (Abs τ (t $ Bv 0)) = Some (τ → τ') ⟹ typ_of1 Ts (decr 0 t) = Some (τ → τ')" using typ_of1_decr' (*‹⟦¬ loose_bvar1 (?t::Core.term) (0::nat); typ_of1 ((?T::typ) # (?Ts::typ list)) ?t = Some (?τ::typ)⟧ ⟹ typ_of1 ?Ts (decr (0::nat) ?t) = Some ?τ›*) by (smt length_Cons (*‹length (?x # ?xs) = Suc (length ?xs)›*) nth_Cons_0 (*‹(?x # ?xs) ! 0 = ?x›*) typ_of1.simps( (*‹typ_of1 ?Ts (Bv ?i) = (if ?i < length ?Ts then Some (?Ts ! ?i) else None)›*) 2) typ_of1_arg_typ (*‹⟦typ_of1 ?Ts (?t $ ?u) = Some ?R; typ_of1 ?Ts ?u = Some ?U⟧ ⟹ typ_of1 ?Ts ?t = Some (?U → ?R)›*) typ_of_Abs_body_typ' (*‹typ_of1 ?Ts (Abs ?T ?t) = Some ?ty ⟹ ∃rty. ?ty = ?T → rty ∧ typ_of1 (?T # ?Ts) ?t = Some rty›*) zero_less_Suc (*‹0 < Suc ?n›*)) lemma typ_of1_eta_red_step: "¬ is_dependent t ⟹ typ_of (Abs τ (t $ Bv 0)) = Some (τ → τ') ⟹ typ_of (decr 0 t) = Some (τ → τ')" using typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) is_dependent_def (*‹is_dependent (?t::Core.term) ≡ loose_bvar1 ?t (0::nat)›*) typ_of1_eta_red_step_pre (*‹⟦¬ loose_bvar1 ?t 0; typ_of1 ?Ts (Abs ?τ (?t $ Bv 0)) = Some (?τ → ?τ')⟧ ⟹ typ_of1 ?Ts (decr 0 ?t) = Some (?τ → ?τ')›*) by simp (* MOVE *) lemma distinct_add_vars': "distinct acc ⟹ distinct (add_vars' t acc)" unfolding add_vars'_def (*goal: ‹distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) t acc)›*) apply (induction t arbitrary: acc) (*goals: 1. ‹⋀x1 x2 acc. distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) (Ct x1 x2) acc)› 2. ‹⋀x1 x2 acc. distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) (Fv x1 x2) acc)› 3. ‹⋀x acc. distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) (Bv x) acc)› 4. ‹⋀x1 t acc. ⟦⋀acc. distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) t acc); distinct acc⟧ ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) (Abs x1 t) acc)› 5. ‹⋀t1 t2 acc. ⟦⋀acc. distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) t1 acc); ⋀acc. distinct acc ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) t2 acc); distinct acc⟧ ⟹ distinct (fold_aterms (λx l. case x of Fv idn s ⇒ List.insert (idn, s) l | _ ⇒ l) (t1 $ t2) acc)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma distinct_add_tvarsT': "distinct acc ⟹ distinct (add_tvarsT' T acc)" proof (induction T arbitrary: acc) (*goals: 1. ‹⋀x1 x2 acc. ⟦⋀x2a acc. ⟦x2a ∈ set x2; distinct acc⟧ ⟹ distinct (add_tvarsT' x2a acc); distinct acc⟧ ⟹ distinct (add_tvarsT' (Ty x1 x2) acc)› 2. ‹⋀x1 x2 acc. distinct acc ⟹ distinct (add_tvarsT' (Tv x1 x2) acc)›*) case (Ty n Ts) (*‹⟦?x2a ∈ set Ts; distinct ?acc⟧ ⟹ distinct (add_tvarsT' ?x2a ?acc)› ‹distinct acc›*) then show "?case" (*goal: ‹distinct (add_tvarsT' (Ty n Ts) acc)›*) apply (induction Ts rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦⋀x2a acc. ⟦x2a ∈ set []; distinct acc⟧ ⟹ distinct (add_tvarsT' x2a acc); distinct acc⟧ ⟹ distinct (add_tvarsT' (constT n) acc)› 2. ‹⋀x xs. ⟦⟦⋀x2a acc. ⟦x2a ∈ set xs; distinct acc⟧ ⟹ distinct (add_tvarsT' x2a acc); distinct acc⟧ ⟹ distinct (add_tvarsT' (Ty n xs) acc); ⋀x2a acc. ⟦x2a ∈ set (xs @ [x]); distinct acc⟧ ⟹ distinct (add_tvarsT' x2a acc); distinct acc⟧ ⟹ distinct (add_tvarsT' (Ty n (xs @ [x])) acc)› discuss goal 1*) apply ((auto simp add: add_tvarsT'_def (*‹add_tvarsT' = fold_atyps (λ(x::typ) l::(variable × String.literal set) list. case x of Ty (literal::String.literal) (list::typ list) ⇒ l | Tv (idn::variable) (s::String.literal set) ⇒ List.insert (idn, s) l)›*))[1]) (*discuss goal 2*) apply ((auto simp add: add_tvarsT'_def (*‹add_tvarsT' = fold_atyps (λ(x::typ) l::(variable × String.literal set) list. case x of Ty (literal::String.literal) (list::typ list) ⇒ l | Tv (idn::variable) (s::String.literal set) ⇒ List.insert (idn, s) l)›*))[1]) (*proven 2 subgoals*) . qed (simp add: add_tvarsT'_def (*‹add_tvarsT' = fold_atyps (λx l. case x of Ty literal list ⇒ l | Tv idn s ⇒ List.insert (idn, s) l)›*)) (*solved the remaining goal: ‹⋀x1 x2 acc. distinct acc ⟹ distinct (add_tvarsT' (Tv x1 x2) acc)›*) lemma distinct_add_tvars': "distinct acc ⟹ distinct (add_tvars' t acc)" apply (induction t arbitrary: acc) (*goals: 1. ‹⋀x1 x2 acc. distinct acc ⟹ distinct (add_tvars' (Ct x1 x2) acc)› 2. ‹⋀x1 x2 acc. distinct acc ⟹ distinct (add_tvars' (Fv x1 x2) acc)› 3. ‹⋀x acc. distinct acc ⟹ distinct (add_tvars' (Bv x) acc)› 4. ‹⋀x1 t acc. ⟦⋀acc. distinct acc ⟹ distinct (add_tvars' t acc); distinct acc⟧ ⟹ distinct (add_tvars' (Abs x1 t) acc)› 5. ‹⋀t1 t2 acc. ⟦⋀acc. distinct acc ⟹ distinct (add_tvars' t1 acc); ⋀acc. distinct acc ⟹ distinct (add_tvars' t2 acc); distinct acc⟧ ⟹ distinct (add_tvars' (t1 $ t2) acc)› discuss goal 1*) apply (simp add: add_tvars'_def (*‹add_tvars' = fold_types add_tvarsT'›*) fold_types_def (*‹fold_types (?f::typ ⇒ ?'a ⇒ ?'a) = fold_term_types (λx::Core.term. ?f)›*) distinct_add_tvarsT' (*‹distinct (?acc::(variable × String.literal set) list) ⟹ distinct (add_tvarsT' (?T::typ) ?acc)›*)) (*discuss goal 2*) apply (simp add: add_tvars'_def (*‹add_tvars' = fold_types add_tvarsT'›*) fold_types_def (*‹fold_types ?f = fold_term_types (λx. ?f)›*) distinct_add_tvarsT' (*‹distinct ?acc ⟹ distinct (add_tvarsT' ?T ?acc)›*)) (*discuss goal 3*) apply (simp add: add_tvars'_def (*‹add_tvars' = fold_types add_tvarsT'›*) fold_types_def (*‹fold_types ?f = fold_term_types (λx. ?f)›*) distinct_add_tvarsT' (*‹distinct ?acc ⟹ distinct (add_tvarsT' ?T ?acc)›*)) (*discuss goal 4*) apply (simp add: add_tvars'_def (*‹add_tvars' = fold_types add_tvarsT'›*) fold_types_def (*‹fold_types ?f = fold_term_types (λx. ?f)›*) distinct_add_tvarsT' (*‹distinct ?acc ⟹ distinct (add_tvarsT' ?T ?acc)›*)) (*discuss goal 5*) apply (simp add: add_tvars'_def (*‹add_tvars' = fold_types add_tvarsT'›*) fold_types_def (*‹fold_types ?f = fold_term_types (λx. ?f)›*) distinct_add_tvarsT' (*‹distinct ?acc ⟹ distinct (add_tvarsT' ?T ?acc)›*)) (*proven 5 subgoals*) . (* Figure out better syntax for goal *) lemma proved_terms_well_formed_pre: "Θ, Γ ⊢ p ⟹ typ_of p = Some propT ∧ term_ok Θ p" proof (induction Γ p rule: proves.induct (*‹⟦?Θ,?x1.0 ⊢ ?x2.0; ⋀A ρ Γ. ⟦wf_theory ?Θ; A ∈ axioms ?Θ; wf_inst ?Θ ρ⟧ ⟹ ?P Γ (tsubst A ρ); ⋀A Γ. ⟦wf_term (sig ?Θ) A; ⊢⇩τ A : propT; A ∈ Γ⟧ ⟹ ?P Γ A; ⋀Γ B x τ. ⟦wf_theory ?Θ; ?Θ,Γ ⊢ B; ?P Γ B; (x, τ) ∉ FV Γ; wf_type (sig ?Θ) τ⟧ ⟹ ?P Γ (mk_all x τ B); ⋀Γ τ B a. ⟦?Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ?P Γ (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B); ⊢⇩τ a : τ; wf_term (sig ?Θ) a⟧ ⟹ ?P Γ (subst_bv a B); ⋀Γ B A. ⟦wf_theory ?Θ; ?Θ,Γ ⊢ B; ?P Γ B; wf_term (sig ?Θ) A; ⊢⇩τ A : propT⟧ ⟹ ?P (Γ - {A}) (A ⟼ B); ⋀Γ₁ A B Γ₂. ⟦?Θ,Γ₁ ⊢ A ⟼ B; ?P Γ₁ (A ⟼ B); ?Θ,Γ₂ ⊢ A; ?P Γ₂ A⟧ ⟹ ?P (Γ₁ ∪ Γ₂) B; ⋀c T Γ. ⟦wf_theory ?Θ; const_type (sig ?Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig ?Θ) T; has_sort (osig (sig ?Θ)) T (insert c full_sort)⟧ ⟹ ?P Γ (mk_of_class T c); ⋀T t u Γ. ⟦wf_theory ?Θ; wt_term (sig ?Θ) (Abs T t); wf_term (sig ?Θ) u; ⊢⇩τ u : T⟧ ⟹ ?P Γ (mk_eq (Abs T t $ u) (subst_bv u t)); ⋀t τ τ' Γ. ⟦wf_theory ?Θ; wf_term (sig ?Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ ?P Γ (mk_eq (Abs τ (t $ Bv 0)) t)⟧ ⟹ ?P ?x1.0 ?x2.0›*)) (*goals: 1. ‹⋀A ρ Γ. ⟦wf_theory Θ; A ∈ axioms Θ; wf_inst Θ ρ⟧ ⟹ typ_of (tsubst A ρ) = Some propT ∧ term_ok Θ (tsubst A ρ)› 2. ‹⋀A Γ. ⟦wf_term (sig Θ) A; ⊢⇩τ A : propT; A ∈ Γ⟧ ⟹ typ_of A = Some propT ∧ term_ok Θ A› 3. ‹⋀Γ B x τ. ⟦wf_theory Θ; Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ⟧ ⟹ typ_of (mk_all x τ B) = Some propT ∧ term_ok Θ (mk_all x τ B)› 4. ‹⋀Γ τ B a. ⟦Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; typ_of (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B) = Some propT ∧ term_ok Θ (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B); ⊢⇩τ a : τ; wf_term (sig Θ) a⟧ ⟹ typ_of (subst_bv a B) = Some propT ∧ term_ok Θ (subst_bv a B)› 5. ‹⋀Γ B A. ⟦wf_theory Θ; Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; wf_term (sig Θ) A; ⊢⇩τ A : propT⟧ ⟹ typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)› 6. ‹⋀Γ₁ A B Γ₂. ⟦Θ,Γ₁ ⊢ A ⟼ B; typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B); Θ,Γ₂ ⊢ A; typ_of A = Some propT ∧ term_ok Θ A⟧ ⟹ typ_of B = Some propT ∧ term_ok Θ B› 7. ‹⋀c T Γ. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 8. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 9. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (axiom A ρ) (*‹wf_theory Θ› ‹A ∈ axioms Θ› ‹wf_inst Θ ρ›*) from axiom (*‹wf_theory Θ› ‹A ∈ axioms Θ› ‹wf_inst Θ ρ›*) have ty: "typ_of1 [] A = Some propT" apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹typ_of1 [] A = Some propT›*) by (simp add: wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*)) let ?l = "add_tvars' A []" let ?l' = "map (λ(v, S) . ((v, S), ρ v S)) ?l" have dist: "distinct ?l" using distinct_add_tvars' (*‹distinct ?acc ⟹ distinct (add_tvars' ?t ?acc)›*) by simp moreover have "∀(v, S) ∈ set ?l . typ_ok Θ (Tv v S)" proof (-) (*goal: ‹∀(v, S)∈set (add_tvars' A []). typ_ok Θ (Tv v S)›*) have "typ_ok Θ (Tv v T)" if "(v, T) ∈ tvs A" for v and T using axiom.hyps(1) (*‹wf_theory Θ›*) axiom.hyps(2) (*‹A ∈ axioms Θ›*) axioms_terms_ok (*‹⟦wf_theory ?thy; ?A ∈ axioms ?thy⟧ ⟹ term_ok ?thy ?A›*) term_ok_tvars_sort_ok (*‹⟦wf_theory ?Θ; term_ok ?Θ ?t; (?x, ?S) ∈ tvs ?t⟧ ⟹ wf_sort (subclass (osig (sig ?Θ))) ?S›*) that (*‹(v, T) ∈ tvs A›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) typ_ok_Tv (*‹wf_sort (subclass (osig ?Σ)) ?S ⟹ wf_type ?Σ (Tv ?a ?S)›*) by (meson wf_sort_def (*‹wf_sort ?sub ?S = (normalized_sort ?sub ?S ∧ sort_ex ?sub ?S)›*)) moreover have "set ?l = tvs A" by auto ultimately show "?thesis" (*goal: ‹∀(v, S)∈set (add_tvars' A []). typ_ok Θ (Tv v S)›*) by auto qed moreover hence "∀(v, S) ∈ set ?l . has_sort (osig (sig Θ)) (Tv v S) S" using axiom.hyps(1) (*‹wf_theory Θ›*) has_sort_Tv_refl' (*‹⟦wf_theory ?Θ; typ_ok ?Θ (Tv ?v ?S)⟧ ⟹ has_sort (osig (sig ?Θ)) (Tv ?v ?S) ?S›*) by blast ultimately have "inst_ok Θ ?l'" apply - (*goal: ‹inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A []))›*) apply (rule wf_inst_imp_inst_ok (*‹⟦wf_theory ?Θ; distinct ?l; ∀(v, S)∈set ?l. typ_ok ?Θ (Tv v S); wf_inst ?Θ ?ρ⟧ ⟹ inst_ok ?Θ (map (λ(v, S). ((v, S), ?ρ v S)) ?l)›*)) (*goal: ‹⟦distinct (add_tvars' A []); ∀(v, S)∈set (add_tvars' A []). typ_ok Θ (Tv v S); ∀(v, S)∈set (add_tvars' A []). has_sort (osig (sig Θ)) (Tv v S) S⟧ ⟹ inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A []))›*) using axiom.hyps(1) (*‹wf_theory Θ›*) axiom.hyps(3) (*‹wf_inst Θ ρ›*) apply - (*goals: 1. ‹⟦distinct (add_tvars' (A::Core.term) []); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Tv v S); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). has_sort (osig (sig Θ)) (Tv v S) S; wf_theory Θ; wf_inst Θ (ρ::variable ⇒ String.literal set ⇒ typ)⟧ ⟹ wf_theory Θ› 2. ‹⟦distinct (add_tvars' (A::Core.term) []); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Tv v S); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). has_sort (osig (sig Θ)) (Tv v S) S; wf_theory Θ; wf_inst Θ (ρ::variable ⇒ String.literal set ⇒ typ)⟧ ⟹ distinct (add_tvars' A [])› 3. ‹⟦distinct (add_tvars' (A::Core.term) []); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Tv v S); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). has_sort (osig (sig Θ)) (Tv v S) S; wf_theory Θ; wf_inst Θ (ρ::variable ⇒ String.literal set ⇒ typ)⟧ ⟹ ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). typ_ok Θ (Tv v S)› 4. ‹⟦distinct (add_tvars' (A::Core.term) []); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Tv v S); ∀(v::variable, S::String.literal set)∈set (add_tvars' A []). has_sort (osig (sig Θ)) (Tv v S) S; wf_theory Θ; wf_inst Θ (ρ::variable ⇒ String.literal set ⇒ typ)⟧ ⟹ wf_inst Θ ρ› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*proven 4 subgoals*) . have simp: "tsubst A ρ = subst_typ' ?l' A" using dist (*‹distinct (add_tvars' A [])›*) subst_typ'_simulates_tsubst_gen' (*‹⟦distinct ?pairs; tvs ?t ⊆ set ?pairs⟧ ⟹ tsubst ?t ?ρ = subst_typ' (map (λ(x, y). ((x, y), ?ρ x y)) ?pairs) ?t›*) by auto have "typ_of1 [] (tsubst A ρ) = Some propT" using tsubst_simulates_subst_typ' (*‹subst_typ' ?insts ?T = tsubst ?T (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) ?insts))›*) axioms_typ_of_propT (*‹⟦wf_theory (?thy::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); (?A::Core.term) ∈ axioms ?thy⟧ ⟹ typ_of ?A = Some propT›*) typ_of1_tsubst (*‹typ_of1 ?Ts ?t = Some ?ty ⟹ typ_of1 (map (λT. tsubstT T ?ρ) ?Ts) (tsubst ?t ?ρ) = Some (tsubstT ?ty ?ρ)›*) ty (*‹typ_of1 [] (A::Core.term) = Some propT›*) by fastforce hence 1: "typ_of1 [] (subst_typ' ?l' A) = Some propT" using simp (*‹tsubst A ρ = subst_typ' (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A [])) A›*) by simp from axiom (*‹wf_theory Θ› ‹(A::Core.term) ∈ axioms (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹wf_inst Θ ρ›*) have "term_ok' (sig Θ) A" apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹term_ok' (sig Θ) A›*) by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) hence 2: "term_ok' (sig Θ) (subst_typ' ?l' A)" using axiom (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹(A::Core.term) ∈ axioms (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹wf_inst Θ ρ›*) term_ok'_subst_typ' (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; distinct (map fst ?insts); list_all (typ_ok_sig ?Σ) (map snd ?insts)⟧ ⟹ term_ok' ?Σ (subst_typ' ?insts ?t)›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹term_ok' (sig Θ) (subst_typ' (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A [])) A)›*) apply (simp add: list_all_iff (*‹list_all (?P::?'a::type ⇒ bool) (?x::?'a::type list) = Ball (set ?x) ?P›*) wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*)) (*goal: ‹⋀cto tao sorts axiomsa. ⟦term_ok' (sig Θ) A; wf_theory Θ; A ∈ axioms Θ; wf_inst Θ ρ; ⋀Σ t insts. ⟦is_std_sig Σ; term_ok' Σ t; distinct (map fst insts); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ term_ok' Σ (subst_typ' insts t); Θ = ((cto, tao, sorts), axiomsa)⟧ ⟹ term_ok' (sig Θ) (subst_typ' (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A [])) A)›*) by (metis (no_types, lifting) ‹inst_ok Θ (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A []))› axiom.hyps( (*‹wf_theory Θ›*) 1) list.pred_mono_strong (*‹⟦list_all ?P ?x; ⋀z. ⟦z ∈ set ?x; ?P z⟧ ⟹ ?Pa z⟧ ⟹ list_all ?Pa ?x›*) sig.simps (*‹sig (?Σ, ?uu) = ?Σ›*) term_ok'_subst_typ' (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; distinct (map fst ?insts); list_all (typ_ok_sig ?Σ) (map snd ?insts)⟧ ⟹ term_ok' ?Σ (subst_typ' ?insts ?t)›*) wf_theory.simps (*‹wf_theory (?Σ, ?axs) = ((∀p∈?axs. wt_term ?Σ p ∧ ⊢⇩τ p : propT) ∧ is_std_sig ?Σ ∧ wf_sig ?Σ ∧ eq_axs ⊆ ?axs)›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) wf_type_imp_typ_ok_sig (*‹wf_type ?Σ ?T ⟹ typ_ok_sig ?Σ ?T›*)) from "1" (*‹typ_of1 [] (subst_typ' (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A [])) A) = Some propT›*) "2" (*‹term_ok' (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (subst_typ' (map (λ(v::variable, S::String.literal set). ((v, S), (ρ::variable ⇒ String.literal set ⇒ typ) v S)) (add_tvars' (A::Core.term) [])) A)›*) show "?case" (*goal: ‹typ_of (tsubst A ρ) = Some propT ∧ term_ok Θ (tsubst A ρ)›*) using simp (*‹tsubst A ρ = subst_typ' (map (λ(v, S). ((v, S), ρ v S)) (add_tvars' A [])) A›*) by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) next (*goals: 1. ‹⋀(A::Core.term) Γ::Core.term set. ⟦wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) A; ⊢⇩τ A : propT; A ∈ Γ⟧ ⟹ typ_of A = Some propT ∧ term_ok Θ A› 2. ‹⋀(Γ::Core.term set) (B::Core.term) (x::variable) τ::typ. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ⟧ ⟹ typ_of (mk_all x τ B) = Some propT ∧ term_ok Θ (mk_all x τ B)› 3. ‹⋀(Γ::Core.term set) (τ::typ) (B::Core.term) a::Core.term. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; typ_of (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B) = Some propT ∧ term_ok Θ (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B); ⊢⇩τ a : τ; wf_term (sig Θ) a⟧ ⟹ typ_of (subst_bv a B) = Some propT ∧ term_ok Θ (subst_bv a B)› 4. ‹⋀(Γ::Core.term set) (B::Core.term) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; wf_term (sig Θ) A; ⊢⇩τ A : propT⟧ ⟹ typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)› 5. ‹⋀(Γ₁::Core.term set) (A::Core.term) (B::Core.term) Γ₂::Core.term set. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ₁ ⊢ A ⟼ B; typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B); Θ,Γ₂ ⊢ A; typ_of A = Some propT ∧ term_ok Θ A⟧ ⟹ typ_of B = Some propT ∧ term_ok Θ B› 6. ‹⋀(c::String.literal) (T::typ) Γ::Core.term set. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 7. ‹⋀(T::typ) (t::Core.term) (u::Core.term) Γ::Core.term set. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 8. ‹⋀(t::Core.term) (τ::typ) (τ'::typ) Γ::Core.term set. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv (0::nat))) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv (0::nat))) t)›*) case (assume A) (*‹wf_term (sig Θ) A› ‹⊢⇩τ A : propT› ‹A ∈ Γ_›*) then show "?case" (*goal: ‹typ_of A = Some propT ∧ term_ok Θ A›*) by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) next (*goals: 1. ‹⋀Γ B x τ. ⟦wf_theory Θ; Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ⟧ ⟹ typ_of (mk_all x τ B) = Some propT ∧ term_ok Θ (mk_all x τ B)› 2. ‹⋀Γ τ B a. ⟦Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; typ_of (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B) = Some propT ∧ term_ok Θ (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B); ⊢⇩τ a : τ; wf_term (sig Θ) a⟧ ⟹ typ_of (subst_bv a B) = Some propT ∧ term_ok Θ (subst_bv a B)› 3. ‹⋀Γ B A. ⟦wf_theory Θ; Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; wf_term (sig Θ) A; ⊢⇩τ A : propT⟧ ⟹ typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)› 4. ‹⋀Γ₁ A B Γ₂. ⟦Θ,Γ₁ ⊢ A ⟼ B; typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B); Θ,Γ₂ ⊢ A; typ_of A = Some propT ∧ term_ok Θ A⟧ ⟹ typ_of B = Some propT ∧ term_ok Θ B› 5. ‹⋀c T Γ. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 6. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 7. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (forall_intro Γ B x τ) (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹Θ,Γ ⊢ B› ‹(x, τ) ∉ FV Γ› ‹wf_type (sig Θ) τ› ‹typ_of B = Some propT ∧ term_ok Θ B›*) hence "term_ok' (sig Θ) B" and "typ_of B = Some propT" apply - (*goals: 1. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ; typ_of B = Some propT ∧ term_ok Θ B⟧ ⟹ term_ok' (sig Θ) B› 2. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ; typ_of B = Some propT ∧ term_ok Θ B⟧ ⟹ typ_of B = Some propT› discuss goal 1*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) (*discuss goal 2*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) (*proven 2 subgoals*) . show "?case" (*goal: ‹typ_of (mk_all x τ B) = Some propT ∧ term_ok Θ (mk_all x τ B)›*) using typ_of_mk_all (*‹typ_of ?A = Some propT ⟹ typ_of (mk_all ?x ?ty ?A) = Some propT›*) forall_intro (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹(x, τ) ∉ FV Γ› ‹wf_type (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (τ::typ)› ‹typ_of B = Some propT ∧ term_ok Θ B›*) term_ok_mk_all[OF ‹wf_theory Θ› ‹term_ok' (sig Θ) B› ‹typ_of B = Some propT› _, of _ x] (*‹typ_ok Θ ?τ ⟹ term_ok Θ (mk_all x ?τ B)›*) ‹wf_type (sig Θ) τ› (*‹wf_type (sig Θ) τ›*) by auto next (*goals: 1. ‹⋀Γ τ B a. ⟦Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; typ_of (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B) = Some propT ∧ term_ok Θ (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B); ⊢⇩τ a : τ; wf_term (sig Θ) a⟧ ⟹ typ_of (subst_bv a B) = Some propT ∧ term_ok Θ (subst_bv a B)› 2. ‹⋀Γ B A. ⟦wf_theory Θ; Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; wf_term (sig Θ) A; ⊢⇩τ A : propT⟧ ⟹ typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)› 3. ‹⋀Γ₁ A B Γ₂. ⟦Θ,Γ₁ ⊢ A ⟼ B; typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B); Θ,Γ₂ ⊢ A; typ_of A = Some propT ∧ term_ok Θ A⟧ ⟹ typ_of B = Some propT ∧ term_ok Θ B› 4. ‹⋀c T Γ. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 5. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 6. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (forall_elim Γ τ B a) (*‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ Ct STR ''Pure.all'' (((τ::typ) → propT) → propT) $ Abs τ (B::Core.term)› ‹⊢⇩τ (a::Core.term) : (τ::typ)› ‹wf_term (sig Θ) a› ‹typ_of (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B) = Some propT ∧ term_ok Θ (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B)›*) thus "?case" (*goal: ‹typ_of (subst_bv a B) = Some propT ∧ term_ok Θ (subst_bv a B)›*) using term_ok'_subst_bv1 (*‹⟦term_ok' (sig ?Θ) ?f; term_ok' (sig ?Θ) ?u⟧ ⟹ term_ok' (sig ?Θ) (subst_bv1 ?f ?lev ?u)›*) by (auto simp add: typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*) term_ok'_subst_bv (*‹⟦term_ok' (sig (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (?f::Core.term); term_ok' (sig ?Θ) (?u::Core.term)⟧ ⟹ term_ok' (sig ?Θ) (subst_bv ?f ?u)›*) tinstT_def (*‹tinstT (?T1.0::typ) (?T2.0::typ) ≡ ∃ρ::variable ⇒ String.literal set ⇒ typ. tsubstT ?T2.0 ρ = ?T1.0›*) wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) bind_eq_Some_conv (*‹(Option.bind (?f::?'b option) (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) subst_bv_def (*‹subst_bv (?u::Core.term) (?t::Core.term) ≡ subst_bv1 ?t (0::nat) ?u›*) typ_of1_subst_bv_gen' (*‹⟦typ_of1 ((?uty::typ) # (?Ts::typ list)) (?t::Core.term) = Some (?tty::typ); typ_of1 ?Ts (?u::Core.term) = Some ?uty⟧ ⟹ typ_of1 ?Ts (subst_bv1 ?t (0::nat) ?u) = Some ?tty›*) split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) next (*goals: 1. ‹⋀Γ B A. ⟦wf_theory Θ; Θ,Γ ⊢ B; typ_of B = Some propT ∧ term_ok Θ B; wf_term (sig Θ) A; ⊢⇩τ A : propT⟧ ⟹ typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)› 2. ‹⋀Γ₁ A B Γ₂. ⟦Θ,Γ₁ ⊢ A ⟼ B; typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B); Θ,Γ₂ ⊢ A; typ_of A = Some propT ∧ term_ok Θ A⟧ ⟹ typ_of B = Some propT ∧ term_ok Θ B› 3. ‹⋀c T Γ. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 4. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 5. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (implies_intro Γ B A) (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (A::Core.term)› ‹⊢⇩τ A : propT› ‹typ_of B = Some propT ∧ term_ok Θ B›*) then show "?case" (*goal: ‹typ_of ((A::Core.term) ⟼ (B::Core.term)) = Some propT ∧ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A ⟼ B)›*) apply (cases Θ rule: wf_theory.cases (*‹(⋀(Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) axs::Core.term set. (?x::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) = (Σ, axs) ⟹ ?P::bool) ⟹ ?P›*)) (*goal: ‹typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)›*) by (auto simp add: typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) tinstT_def (*‹tinstT ?T1.0 ?T2.0 ≡ ∃ρ. tsubstT ?T2.0 ρ = ?T1.0›*)) next (*goals: 1. ‹⋀Γ₁ A B Γ₂. ⟦Θ,Γ₁ ⊢ A ⟼ B; typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B); Θ,Γ₂ ⊢ A; typ_of A = Some propT ∧ term_ok Θ A⟧ ⟹ typ_of B = Some propT ∧ term_ok Θ B› 2. ‹⋀c T Γ. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 3. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 4. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (implies_elim Γ₁ A B Γ₂) (*‹Θ,Γ₁ ⊢ A ⟼ B› ‹Θ,Γ₂ ⊢ A› ‹typ_of (A ⟼ B) = Some propT ∧ term_ok Θ (A ⟼ B)› ‹typ_of A = Some propT ∧ term_ok Θ A›*) then show "?case" (*goal: ‹typ_of B = Some propT ∧ term_ok Θ B›*) by (auto simp add: bind_eq_Some_conv (*‹(Option.bind (?f::?'b option) (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*) typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*) wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) tinstT_def (*‹tinstT (?T1.0::typ) (?T2.0::typ) ≡ ∃ρ::variable ⇒ String.literal set ⇒ typ. tsubstT ?T2.0 ρ = ?T1.0›*) split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) next (*goals: 1. ‹⋀c T Γ. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort)⟧ ⟹ typ_of (mk_of_class T c) = Some propT ∧ term_ok Θ (mk_of_class T c)› 2. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 3. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (of_class c iT T) (*‹wf_theory Θ› ‹const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT)› ‹wf_type (sig Θ) iT› ‹has_sort (osig (sig Θ)) iT (insert c full_sort)›*) then show "?case" (*goal: ‹typ_of (mk_of_class iT c) = Some propT ∧ term_ok Θ (mk_of_class iT c)›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹typ_of (mk_of_class iT c) = Some propT ∧ term_ok Θ (mk_of_class iT c)›*) by (auto simp add: bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) tinstT_def (*‹tinstT ?T1.0 ?T2.0 ≡ ∃ρ. tsubstT ?T2.0 ρ = ?T1.0›*) mk_of_class_def (*‹mk_of_class ?ty ?c = Ct (const_of_class ?c) (itselfT ?ty → propT) $ mk_type ?ty›*) mk_type_def (*‹mk_type ?ty = Ct STR ''Pure.type'' (itselfT ?ty)›*)) next (*goals: 1. ‹⋀T t u Γ. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T⟧ ⟹ typ_of (mk_eq (Abs T t $ u) (subst_bv u t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ u) (subst_bv u t))› 2. ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (β_conversion T t x) (*‹wf_theory Θ› ‹wt_term (sig Θ) (Abs T t)› ‹wf_term (sig Θ) x› ‹⊢⇩τ x : T›*) hence 1: "typ_of (mk_eq (Abs T t $ x) (subst_bv x t)) = Some propT" by (auto simp add: typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*) bind_eq_Some_conv (*‹(Option.bind ?f ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) typ_of1_subst_bv_gen' (*‹⟦typ_of1 (?uty # ?Ts) ?t = Some ?tty; typ_of1 ?Ts ?u = Some ?uty⟧ ⟹ typ_of1 ?Ts (subst_bv1 ?t 0 ?u) = Some ?tty›*)) moreover have "term_ok Θ (mk_eq (Abs T t $ x) (subst_bv x t))" proof (-) (*goal: ‹term_ok Θ (mk_eq (Abs T t $ x) (subst_bv x t))›*) have "typ_of (mk_eq (Abs T t $ x) (subst_bv x t)) ≠ None" using "1" (*‹typ_of (mk_eq (Abs T t $ x) (subst_bv x t)) = Some propT›*) by simp moreover have "term_ok' (sig Θ) (mk_eq (Abs T t $ x) (subst_bv x t))" proof (-) (*goal: ‹term_ok' (sig Θ) (mk_eq (Abs T t $ x) (subst_bv x t))›*) have "term_ok' (sig Θ) (Abs T t $ x)" using "β_conversion.hyps"(2) (*‹wt_term (sig Θ) (Abs T t)›*) "β_conversion.hyps"(3) (*‹wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (x::Core.term)›*) term_ok'.simps(4) (*‹term_ok' (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) ((?t::Core.term) $ (?u::Core.term)) = (term_ok' ?Σ ?t ∧ term_ok' ?Σ ?u)›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) term_ok_def (*‹term_ok ?Θ ?t ≡ wt_term (sig ?Θ) ?t›*) by blast moreover hence "term_ok' (sig Θ) (subst_bv x t)" using subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*) term_ok'_subst_bv1 (*‹⟦term_ok' (sig ?Θ) ?f; term_ok' (sig ?Θ) ?u⟧ ⟹ term_ok' (sig ?Θ) (subst_bv1 ?f ?lev ?u)›*) by auto moreover have "const_type (sig Θ) STR ''Pure.eq'' = Some ((Tv (Var (STR '''a'', 0)) full_sort) → ((Tv (Var (STR '''a'', 0)) full_sort) → propT))" using "β_conversion.hyps"(1) (*‹wf_theory Θ›*) apply (cases Θ) (*goal: ‹const_type (sig Θ) STR ''Pure.eq'' = Some (Core.aT → Core.aT → propT)›*) by fastforce moreover obtain t' where "typ_of (Abs T t $ x) = Some t'" (*goal: ‹(⋀t'. typ_of (Abs T t $ x) = Some t' ⟹ thesis) ⟹ thesis›*) by (smt "1" (*‹typ_of (mk_eq (Abs (T::typ) (t::Core.term) $ (x::Core.term)) (subst_bv x t)) = Some propT›*) typ_of1_split_App (*‹typ_of1 (?Ts::typ list) ((?t::Core.term) $ (?u::Core.term)) = Some (?ty::typ) ⟹ ∃uty::typ. typ_of1 ?Ts ?t = Some (uty → ?ty) ∧ typ_of1 ?Ts ?u = Some uty›*) typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*)) moreover hence "typ_of (subst_bv x t) = Some t'" by (smt list.simps( (*‹(?x21.0 # ?x22.0 = ?y21.0 # ?y22.0) = (?x21.0 = ?y21.0 ∧ ?x22.0 = ?y22.0)›*) 1) subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*) typ.simps( (*‹(Ty ?x11.0 ?x12.0 = Ty ?y11.0 ?y12.0) = (?x11.0 = ?y11.0 ∧ ?x12.0 = ?y12.0)›*) 1) typ_of1_split_App (*‹typ_of1 ?Ts (?t $ ?u) = Some ?ty ⟹ ∃uty. typ_of1 ?Ts ?t = Some (uty → ?ty) ∧ typ_of1 ?Ts ?u = Some uty›*) typ_of1_subst_bv_gen' (*‹⟦typ_of1 (?uty # ?Ts) ?t = Some ?tty; typ_of1 ?Ts ?u = Some ?uty⟧ ⟹ typ_of1 ?Ts (subst_bv1 ?t 0 ?u) = Some ?tty›*) typ_of_Abs_body_typ' (*‹typ_of1 ?Ts (Abs ?T ?t) = Some ?ty ⟹ ∃rty. ?ty = ?T → rty ∧ typ_of1 (?T # ?Ts) ?t = Some rty›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) moreover have "typ_ok_sig (sig Θ) t'" using "β_conversion.hyps"(1) (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)›*) calculation(2) (*‹term_ok' (sig Θ) (subst_bv x t)›*) calculation(5) (*‹typ_of (subst_bv x t) = Some t'›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) term_ok_imp_typ_ok (*‹⟦wf_theory ?thy; term_ok ?thy ?t; typ_of ?t = Some ?ty⟧ ⟹ typ_ok ?thy ?ty›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) by auto moreover hence "typ_ok_sig (sig Θ) (t' → propT) " using ‹wf_theory Θ› (*‹wf_theory Θ›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀(cto::?'a) (tao::?'b) (sorts::?'c) axioms::?'d. (?Θ::(?'a × ?'b × ?'c) × ?'d) = ((cto, tao, sorts), axioms) ⟹ ?P::bool) ⟹ ?P›*)) (*goal: ‹typ_ok_sig (sig Θ) (t' → propT)›*) by auto moreover have "tinstT (T → (T → propT)) ((Tv (Var (STR '''a'', 0)) full_sort) → ((Tv (Var (STR '''a'', 0)) full_sort) → propT))" unfolding tinstT_def (*goal: ‹∃ρ. tsubstT (Core.aT → Core.aT → propT) ρ = T → T → propT›*) by auto moreover have "tinstT (t' → (t' → propT)) ((Tv (Var (STR '''a'', 0)) full_sort) → ((Tv (Var (STR '''a'', 0)) full_sort) → propT))" unfolding tinstT_def (*goal: ‹∃ρ. tsubstT (Core.aT → Core.aT → propT) ρ = t' → t' → propT›*) by auto ultimately show "?thesis" (*goal: ‹term_ok' (sig Θ) (mk_eq (Abs T t $ x) (subst_bv x t))›*) using ‹wf_theory Θ› (*‹wf_theory Θ›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀(cto::?'a) (tao::?'b) (sorts::?'c) axioms::?'d. (?Θ::(?'a × ?'b × ?'c) × ?'d) = ((cto, tao, sorts), axioms) ⟹ ?P::bool) ⟹ ?P›*)) (*goal: ‹term_ok' (sig Θ) (mk_eq (Abs T t $ x) (subst_bv x t))›*) by auto qed ultimately show "?thesis" (*goal: ‹term_ok Θ (mk_eq (Abs T t $ x) (subst_bv x t))›*) using wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) by simp qed ultimately show "?case" (*goal: ‹typ_of (mk_eq (Abs T t $ x) (subst_bv x t)) = Some propT ∧ term_ok Θ (mk_eq (Abs T t $ x) (subst_bv x t))›*) by simp next (*goal: ‹⋀t τ τ' Γ. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'⟧ ⟹ typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) case (eta t τ τ') (*‹wf_theory Θ› ‹wf_term (sig Θ) t› ‹⊢⇩τ t : τ → τ'›*) hence tyeta: "typ_of (Abs τ (t $ Bv 0)) = Some (τ → τ')" using typ_of_eta_expand (*‹typ_of ?f = Some (?τ → ?τ') ⟹ typ_of (Abs ?τ (?f $ Bv 0)) = Some (?τ → ?τ')›*) by auto moreover have "¬ is_dependent t" proof (-) (*goal: ‹¬ is_dependent (t::Core.term)›*) have "is_closed t" using eta.hyps(3) (*‹⊢⇩τ (t::Core.term) : (τ::typ) → (τ'::typ)›*) typ_of_imp_closed (*‹typ_of ?t = Some ?ty ⟹ is_closed ?t›*) by blast thus "?thesis" (*goal: ‹¬ is_dependent t›*) using is_dependent_def (*‹is_dependent (?t::Core.term) ≡ loose_bvar1 ?t (0::nat)›*) is_open_def (*‹is_open ?t ≡ loose_bvar ?t 0›*) loose_bvar1_imp_loose_bvar (*‹loose_bvar1 ?t ?n ⟹ loose_bvar ?t ?n›*) by blast qed ultimately have ty_decr: "typ_of (decr 0 t) = Some (τ → τ')" using typ_of1_eta_red_step (*‹⟦¬ is_dependent ?t; typ_of (Abs ?τ (?t $ Bv 0)) = Some (?τ → ?τ')⟧ ⟹ typ_of (decr 0 ?t) = Some (?τ → ?τ')›*) by blast hence 1: "typ_of (mk_eq (Abs τ (t $ Bv 0)) (decr 0 t)) = Some propT" using eta (*‹wf_theory Θ› ‹wf_term (sig Θ) t› ‹⊢⇩τ t : τ → τ'›*) tyeta (*‹typ_of (Abs τ (t $ Bv 0)) = Some (τ → τ')›*) by (auto simp add: typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) have "typ_ok Θ (τ → τ')" using eta (*‹wf_theory Θ› ‹wf_term (sig Θ) t› ‹⊢⇩τ t : τ → τ'›*) term_ok_imp_typ_ok (*‹⟦wf_theory ?thy; term_ok ?thy ?t; typ_of ?t = Some ?ty⟧ ⟹ typ_ok ?thy ?ty›*) by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) del: typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*)) hence tyok: "typ_ok Θ τ" "typ_ok Θ τ'" unfolding typ_ok_def (*goals: 1. ‹wf_type (sig Θ) τ› 2. ‹wf_type (sig Θ) τ'›*) apply - (*goals: 1. ‹wf_type (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) ((τ::typ) → (τ'::typ)) ⟹ wf_type (sig Θ) τ› 2. ‹wf_type (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) ((τ::typ) → (τ'::typ)) ⟹ wf_type (sig Θ) τ'› discuss goal 1*) apply ((auto split: option.splits (*‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b ⇒ bool) (case ?option::?'a option of None ⇒ ?f1.0::?'b | Some (x::?'a) ⇒ (?f2.0::?'a ⇒ ?'b) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*discuss goal 2*) apply ((auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*))[1]) (*proven 2 subgoals*) . hence "term_ok Θ (Abs τ (t $ Bv 0))" using eta(2) (*‹wf_term (sig Θ) t›*) tyeta (*‹typ_of (Abs τ (t $ Bv 0)) = Some (τ → τ')›*) by (simp add: wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*)) moreover have "term_ok Θ (decr 0 t)" using eta (*‹wf_theory Θ› ‹wf_term (sig Θ) t› ‹⊢⇩τ (t::Core.term) : (τ::typ) → (τ'::typ)›*) term_ok'_decr (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (decr ?i ?t)›*) tyeta (*‹typ_of (Abs τ (t $ Bv 0)) = Some (τ → τ')›*) ty_decr (*‹typ_of (decr 0 t) = Some (τ → τ')›*) wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) tyok (*‹typ_ok Θ τ› ‹typ_ok Θ τ'›*) apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹term_ok Θ (decr 0 t)›*) by (auto split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*) simp add: tinstT_def (*‹tinstT ?T1.0 ?T2.0 ≡ ∃ρ. tsubstT ?T2.0 ρ = ?T1.0›*)) ultimately have "term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) (decr 0 t))" using eta.hyps (*‹wf_theory Θ› ‹wf_term (sig Θ) t› ‹⊢⇩τ t : τ → τ'›*) ty_decr (*‹typ_of (decr 0 t) = Some (τ → τ')›*) tyeta (*‹typ_of (Abs τ (t $ Bv 0)) = Some (τ → τ')›*) tyok (*‹typ_ok Θ τ› ‹typ_ok Θ τ'›*) "1" (*‹typ_of (mk_eq (Abs (τ::typ) ((t::Core.term) $ Bv (0::nat))) (decr (0::nat) t)) = Some propT›*) term_ok_mk_eqI (*‹⟦wf_theory ?Θ; term_ok ?Θ ?s; term_ok ?Θ ?t; typ_of ?s = typ_of ?t⟧ ⟹ term_ok ?Θ (mk_eq ?s ?t)›*) by metis then show "?case" (*goal: ‹typ_of (mk_eq (Abs τ (t $ Bv 0)) t) = Some propT ∧ term_ok Θ (mk_eq (Abs τ (t $ Bv 0)) t)›*) using "1" (*‹typ_of (mk_eq (Abs τ (t $ Bv 0)) (decr 0 t)) = Some propT›*) using eta.hyps(2) (*‹wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (t::Core.term)›*) eta.hyps(3) (*‹⊢⇩τ t : τ → τ'›*) has_typ_imp_closed (*‹⊢⇩τ ?t : ?ty ⟹ is_closed ?t›*) term_ok_subst_bv_no_change (*‹term_ok ?Θ ?t ⟹ subst_bv ?u ?t = ?t›*) closed_subst_bv_no_change (*‹is_closed (?t::Core.term) ⟹ subst_bv (?u::Core.term) ?t = ?t›*) by auto qed corollary proved_terms_well_formed: assumes "Θ, Γ ⊢ p" shows "typ_of p = Some propT" "term_ok Θ p" using assms (*‹Θ,Γ ⊢ p›*) proved_terms_well_formed_pre (*‹?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ::Core.term set ⊢ ?p::Core.term ⟹ typ_of ?p = Some propT ∧ term_ok ?Θ ?p›*) apply - (*goals: 1. ‹⟦Θ,Γ ⊢ p; ⋀Θ Γ p. Θ,Γ ⊢ p ⟹ typ_of p = Some propT ∧ term_ok Θ p⟧ ⟹ typ_of p = Some propT› 2. ‹⟦Θ,Γ ⊢ p; ⋀Θ Γ p. Θ,Γ ⊢ p ⟹ typ_of p = Some propT ∧ term_ok Θ p⟧ ⟹ term_ok Θ p› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma forall_intros: "wf_theory Θ ⟹ Θ,Γ ⊢ B ⟹ ∀(x, τ)∈set frees . (x,τ) ∉ FV Γ ∧ typ_ok Θ τ ⟹ Θ,Γ ⊢ mk_all_list frees B" apply (induction frees arbitrary: B) (*goals: 1. ‹⋀B. ⟦wf_theory Θ; Θ,Γ ⊢ B; ∀(x, τ)∈set []. (x, τ) ∉ FV Γ ∧ typ_ok Θ τ⟧ ⟹ Θ,Γ ⊢ mk_all_list [] B› 2. ‹⋀a frees B. ⟦⋀B. ⟦wf_theory Θ; Θ,Γ ⊢ B; ∀(x, τ)∈set frees. (x, τ) ∉ FV Γ ∧ typ_ok Θ τ⟧ ⟹ Θ,Γ ⊢ mk_all_list frees B; wf_theory Θ; Θ,Γ ⊢ B; ∀(x, τ)∈set (a # frees). (x, τ) ∉ FV Γ ∧ typ_ok Θ τ⟧ ⟹ Θ,Γ ⊢ mk_all_list (a # frees) B› discuss goal 1*) apply ((auto intro: proves.forall_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; (?x, ?τ) ∉ FV ?Γ; wf_type (sig ?Θ) ?τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all ?x ?τ ?B›*) simp add: mk_all_list_def (*‹mk_all_list ?l ?t = fold (λ(n, T). mk_all n T) ?l ?t›*) simp del: FV_def (*‹FV ?S = ⋃ (fv ` ?S)›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*discuss goal 2*) apply ((auto intro: proves.forall_intro (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); ?Θ,?Γ::Core.term set ⊢ ?B::Core.term; (?x::variable, ?τ::typ) ∉ FV ?Γ; wf_type (sig ?Θ) ?τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all ?x ?τ ?B›*) simp add: mk_all_list_def (*‹mk_all_list (?l::(variable × typ) list) (?t::Core.term) = fold (λ(n::variable, T::typ). mk_all n T) ?l ?t›*) simp del: FV_def (*‹FV (?S::Core.term set) = ⋃ (fv ` ?S)›*) split: prod.splits (*‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∀(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c::type ⇒ bool) (case ?prod::?'a::type × ?'b::type of (x::?'a::type, xa::?'b::type) ⇒ (?f::?'a::type ⇒ ?'b::type ⇒ ?'c::type) x xa) = (∄(x1::?'a::type) x2::?'b::type. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*))[1]) (*proven 2 subgoals*) . (* MOVE *) lemma term_ok_var[simp]: "term_ok Θ (Fv idn τ) = typ_ok Θ τ" by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) lemma typ_of_var[simp]: "typ_of (Fv idn τ) = Some τ" by (simp add: typ_of_def (*‹typ_of (?t::Core.term) ≡ typ_of1 [] ?t›*)) (* Is this a simp rule? *) lemma is_closed_Fv[simp]: "is_closed (Fv idn τ)" by (simp add: is_open_def (*‹is_open (?t::Core.term) ≡ loose_bvar ?t (0::nat)›*)) corollary proved_terms_closed: "Θ, Γ ⊢ B ⟹ is_closed B" by (simp add: proved_terms_well_formed( (*‹?Θ,?Γ ⊢ ?p ⟹ typ_of ?p = Some propT›*) 1) typ_of_imp_closed (*‹typ_of ?t = Some ?ty ⟹ is_closed ?t›*)) lemma not_loose_bvar_bind_fv2: "¬ loose_bvar t lev ⟹ ¬ loose_bvar (bind_fv2 v lev t) (Suc lev)" apply (induction t arbitrary: lev) (*goals: 1. ‹⋀(x1::String.literal) (x2::typ) lev::nat. ¬ loose_bvar (Ct x1 x2) lev ⟹ ¬ loose_bvar (bind_fv2 (v::variable × typ) lev (Ct x1 x2)) (Suc lev)› 2. ‹⋀(x1::variable) (x2::typ) lev::nat. ¬ loose_bvar (Fv x1 x2) lev ⟹ ¬ loose_bvar (bind_fv2 (v::variable × typ) lev (Fv x1 x2)) (Suc lev)› 3. ‹⋀(x::nat) lev::nat. ¬ loose_bvar (Bv x) lev ⟹ ¬ loose_bvar (bind_fv2 (v::variable × typ) lev (Bv x)) (Suc lev)› 4. ‹⋀(x1::typ) (t::Core.term) lev::nat. ⟦⋀lev::nat. ¬ loose_bvar t lev ⟹ ¬ loose_bvar (bind_fv2 (v::variable × typ) lev t) (Suc lev); ¬ loose_bvar (Abs x1 t) lev⟧ ⟹ ¬ loose_bvar (bind_fv2 v lev (Abs x1 t)) (Suc lev)› 5. ‹⋀(t1::Core.term) (t2::Core.term) lev::nat. ⟦⋀lev::nat. ¬ loose_bvar t1 lev ⟹ ¬ loose_bvar (bind_fv2 (v::variable × typ) lev t1) (Suc lev); ⋀lev::nat. ¬ loose_bvar t2 lev ⟹ ¬ loose_bvar (bind_fv2 v lev t2) (Suc lev); ¬ loose_bvar (t1 $ t2) lev⟧ ⟹ ¬ loose_bvar (bind_fv2 v lev (t1 $ t2)) (Suc lev)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma not_loose_bvar_bind_fv2_: "¬ loose_bvar (bind_fv2 v lev t) lev ⟹ ¬ loose_bvar t lev" apply (induction t arbitrary: lev) (*goals: 1. ‹⋀x1 x2 lev. ¬ loose_bvar (bind_fv2 v lev (Ct x1 x2)) lev ⟹ ¬ loose_bvar (Ct x1 x2) lev› 2. ‹⋀x1 x2 lev. ¬ loose_bvar (bind_fv2 v lev (Fv x1 x2)) lev ⟹ ¬ loose_bvar (Fv x1 x2) lev› 3. ‹⋀x lev. ¬ loose_bvar (bind_fv2 v lev (Bv x)) lev ⟹ ¬ loose_bvar (Bv x) lev› 4. ‹⋀x1 t lev. ⟦⋀lev. ¬ loose_bvar (bind_fv2 v lev t) lev ⟹ ¬ loose_bvar t lev; ¬ loose_bvar (bind_fv2 v lev (Abs x1 t)) lev⟧ ⟹ ¬ loose_bvar (Abs x1 t) lev› 5. ‹⋀t1 t2 lev. ⟦⋀lev. ¬ loose_bvar (bind_fv2 v lev t1) lev ⟹ ¬ loose_bvar t1 lev; ⋀lev. ¬ loose_bvar (bind_fv2 v lev t2) lev ⟹ ¬ loose_bvar t2 lev; ¬ loose_bvar (bind_fv2 v lev (t1 $ t2)) lev⟧ ⟹ ¬ loose_bvar (t1 $ t2) lev› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 3*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 4*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 5*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 5 subgoals*) . lemma fold_add_vars'_FV_pre: "set (fold add_vars' Hs acc) = set acc ∪ FV (set Hs)" apply (induction Hs arbitrary: acc) (*goals: 1. ‹⋀acc. set (fold add_vars' [] acc) = set acc ∪ FV (set [])› 2. ‹⋀a Hs acc. (⋀acc. set (fold add_vars' Hs acc) = set acc ∪ FV (set Hs)) ⟹ set (fold add_vars' (a # Hs) acc) = set acc ∪ FV (set (a # Hs))› discuss goal 1*) apply ((auto simp add: add_vars'_fv_pre (*‹set (add_vars' ?t ?acc) = set ?acc ∪ fv ?t›*))[1]) (*discuss goal 2*) apply ((auto simp add: add_vars'_fv_pre (*‹set (add_vars' ?t ?acc) = set ?acc ∪ fv ?t›*))[1]) (*proven 2 subgoals*) . corollary fold_add_vars'_FV[simp]: "set (fold (add_vars') Hs []) = FV (set Hs)" using fold_add_vars'_FV_pre (*‹set (fold add_vars' ?Hs ?acc) = set ?acc ∪ FV (set ?Hs)›*) by simp lemma forall_intro_vars: assumes "wf_theory Θ" "Θ, set Hs ⊢ B" shows "Θ, set Hs ⊢ forall_intro_vars B Hs" apply (rule forall_intros (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; ∀(x, τ)∈set ?frees. (x, τ) ∉ FV ?Γ ∧ typ_ok ?Θ τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all_list ?frees ?B›*)) (*goal: ‹Θ,set Hs ⊢ forall_intro_vars B Hs›*) using assms (*‹wf_theory Θ› ‹Θ,set Hs ⊢ B›*) apply simp_all (*top goal: ‹wf_theory Θ› and 2 goals remain*) apply clarsimp (*goal: ‹⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,set (Hs::Core.term list) ⊢ B::Core.term⟧ ⟹ ∀x::variable × typ∈set (add_vars' B []) - ⋃ (fv ` set Hs). case x of (x::variable, τ::typ) ⇒ (∀xa::Core.term∈set Hs. (x, τ) ∉ fv xa) ∧ typ_ok_sig (sig Θ) τ›*) using add_vars'_fv (*‹set (add_vars' ?t []) = fv ?t›*) proved_terms_well_formed_pre (*‹?Θ,?Γ ⊢ ?p ⟹ typ_of ?p = Some propT ∧ term_ok ?Θ ?p›*) term_ok_vars_typ_ok (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok ?Θ (?t::Core.term); (?x::variable, ?τ::typ) ∈ fv ?t⟧ ⟹ typ_ok ?Θ ?τ›*) by (metis term_ok_vars_typ_ok (*‹⟦wf_theory ?Θ; term_ok ?Θ ?t; (?x, ?τ) ∈ fv ?t⟧ ⟹ typ_ok ?Θ ?τ›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) wf_type_imp_typ_ok_sig (*‹wf_type ?Σ ?T ⟹ typ_ok_sig ?Σ ?T›*)) (* MOVE *) lemma mk_all_list'_preserves_term_ok_typ_of: assumes "wf_theory Θ" "term_ok Θ B" "typ_of B = Some propT" "∀(idn,ty)∈set vs . typ_ok Θ ty" shows "term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT" using assms (*‹wf_theory Θ› ‹term_ok Θ B› ‹typ_of B = Some propT› ‹∀(idn, ty)∈set vs. typ_ok Θ ty›*) proof (induction vs rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok Θ (B::Core.term); typ_of B = Some propT; ∀(idn::variable, y::typ)∈set []. typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list [] B) ∧ typ_of (mk_all_list [] B) = Some propT› 2. ‹⋀(x::variable × typ) xs::(variable × typ) list. ⟦⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok Θ (B::Core.term); typ_of B = Some propT; ∀(idn::variable, y::typ)∈set xs. typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list xs B) ∧ typ_of (mk_all_list xs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn::variable, y::typ)∈set (xs @ [x]). typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list (xs @ [x]) B) ∧ typ_of (mk_all_list (xs @ [x]) B) = Some propT›*) case Nil (*‹wf_theory Θ› ‹term_ok Θ B› ‹typ_of B = Some propT› ‹∀a∈set []. case a of (idn, a) ⇒ typ_ok Θ a›*) then show "?case" (*goal: ‹term_ok Θ (mk_all_list [] B) ∧ typ_of (mk_all_list [] B) = Some propT›*) by simp next (*goal: ‹⋀(x::variable × typ) xs::(variable × typ) list. ⟦⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok Θ (B::Core.term); typ_of B = Some propT; ∀(idn::variable, y::typ)∈set xs. typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list xs B) ∧ typ_of (mk_all_list xs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn::variable, y::typ)∈set (xs @ [x]). typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list (xs @ [x]) B) ∧ typ_of (mk_all_list (xs @ [x]) B) = Some propT›*) case (snoc v vs) (*‹⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set vs. case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT› ‹wf_theory Θ› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (B::Core.term)› ‹typ_of B = Some propT› ‹∀a::variable × typ∈set ((vs::(variable × typ) list) @ [v::variable × typ]). case a of (idn::variable, a::typ) ⇒ typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) a›*) hence I: "term_ok Θ (mk_all_list vs B)" "typ_of (mk_all_list vs B) = Some propT" apply - (*goals: 1. ‹⟦⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok Θ (B::Core.term); typ_of B = Some propT; ∀a::variable × typ∈set (vs::(variable × typ) list). case a of (idn::variable, a::typ) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a::variable × typ∈set (vs @ [v::variable × typ]). case a of (idn::variable, a::typ) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B)› 2. ‹⟦⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok Θ (B::Core.term); typ_of B = Some propT; ∀a::variable × typ∈set (vs::(variable × typ) list). case a of (idn::variable, a::typ) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a::variable × typ∈set (vs @ [v::variable × typ]). case a of (idn::variable, a::typ) ⇒ typ_ok Θ a⟧ ⟹ typ_of (mk_all_list vs B) = Some propT› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . obtain idn and ty where v: "v=(idn,ty)" (*goal: ‹(⋀idn ty. v = (idn, ty) ⟹ thesis) ⟹ thesis›*) by fastforce hence s: "(mk_all_list (vs @ [v]) B) = mk_all idn ty (mk_all_list (vs) B)" by (simp add: mk_all_list_def (*‹mk_all_list ?l ?t = fold (λ(n, T). mk_all n T) ?l ?t›*)) have "typ_ok Θ ty" using v (*‹v = (idn, ty)›*) snoc.prems (*‹wf_theory Θ› ‹term_ok Θ B› ‹typ_of (B::Core.term) = Some propT› ‹∀a∈set (vs @ [v]). case a of (idn, a) ⇒ typ_ok Θ a›*) by simp then show "?case" (*goal: ‹term_ok Θ (mk_all_list (vs @ [v]) B) ∧ typ_of (mk_all_list (vs @ [v]) B) = Some propT›*) using I (*‹term_ok Θ (mk_all_list vs B)› ‹typ_of (mk_all_list vs B) = Some propT›*) s (*‹mk_all_list (vs @ [v]) B = mk_all idn ty (mk_all_list vs B)›*) term_ok_mk_all (*‹⟦wf_theory ?Θ; term_ok' (sig ?Θ) ?B; typ_of ?B = Some propT; typ_ok ?Θ ?τ⟧ ⟹ term_ok ?Θ (mk_all ?x ?τ ?B)›*) snoc.prems(1) (*‹wf_theory Θ›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_mk_all (*‹typ_of ?A = Some propT ⟹ typ_of (mk_all ?x ?ty ?A) = Some propT›*) by auto qed corollary forall_intro_vars_preserves_term_ok_typ_of: assumes "wf_theory Θ" "term_ok Θ B" "typ_of B = Some propT" shows "term_ok Θ (forall_intro_vars B Hs) ∧ typ_of (forall_intro_vars B Hs) = Some propT" proof (-) (*goal: ‹term_ok Θ (forall_intro_vars B Hs) ∧ typ_of (forall_intro_vars B Hs) = Some propT›*) have 1: "∀(idn,ty)∈set (add_vars' B []) . typ_ok Θ ty" using add_vars'_fv (*‹set (add_vars' ?t []) = fv ?t›*) assms(1) (*‹wf_theory Θ›*) assms(2) (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (B::Core.term)›*) term_ok_vars_typ_ok (*‹⟦wf_theory ?Θ; term_ok ?Θ ?t; (?x, ?τ) ∈ fv ?t⟧ ⟹ typ_ok ?Θ ?τ›*) by blast thus "?thesis" (*goal: ‹term_ok Θ (forall_intro_vars B Hs) ∧ typ_of (forall_intro_vars B Hs) = Some propT›*) using assms (*‹wf_theory Θ› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (B::Core.term)› ‹typ_of B = Some propT›*) mk_all_list'_preserves_term_ok_typ_of (*‹⟦wf_theory ?Θ; term_ok ?Θ ?B; typ_of ?B = Some propT; ∀(idn, ty)∈set ?vs. typ_ok ?Θ ty⟧ ⟹ term_ok ?Θ (mk_all_list ?vs ?B) ∧ typ_of (mk_all_list ?vs ?B) = Some propT›*) by simp qed (* MOVE and rename *) lemma bind_fv_remove_var_from_fv: "fv (bind_fv (idn, τ) t) = fv t - {(idn, τ)}" using bind_fv2_Fv_fv (*‹fv (bind_fv2 (?x, ?τ) ?lev ?t) = fv ?t - {(?x, ?τ)}›*) bind_fv_def (*‹bind_fv ?vT ?t = bind_fv2 ?vT 0 ?t›*) by simp lemma forall_intro_vars_remove_fv[simp]: "fv (forall_intro_vars t []) = {}" using mk_all_list_fv_unchanged (*‹fv (mk_all_list ?l ?B) = fv ?B - set ?l›*) add_vars'_fv (*‹set (add_vars' ?t []) = fv ?t›*) by simp lemma term_ok_mk_all_list: assumes "wf_theory Θ" assumes "term_ok Θ B" assumes "typ_of B = Some propT" assumes "∀(idn, τ) ∈ set l . typ_ok Θ τ" shows "term_ok Θ (mk_all_list l B) ∧ typ_of (mk_all_list l B) = Some propT" using assms (*‹wf_theory Θ› ‹term_ok Θ B› ‹typ_of B = Some propT› ‹∀(idn, τ)∈set l. typ_ok Θ τ›*) proof (induction l rule: rev_induct (*‹⟦(?P::?'a list ⇒ bool) []; ⋀(x::?'a) xs::?'a list. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P (?xs::?'a list)›*)) (*goals: 1. ‹⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn, y)∈set []. typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list [] B) ∧ typ_of (mk_all_list [] B) = Some propT› 2. ‹⋀x xs. ⟦⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn, y)∈set xs. typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list xs B) ∧ typ_of (mk_all_list xs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn, y)∈set (xs @ [x]). typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list (xs @ [x]) B) ∧ typ_of (mk_all_list (xs @ [x]) B) = Some propT›*) case Nil (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (B::Core.term)› ‹typ_of B = Some propT› ‹∀a∈set []. case a of (idn, a) ⇒ typ_ok Θ a›*) then show "?case" (*goal: ‹term_ok Θ (mk_all_list [] B) ∧ typ_of (mk_all_list [] B) = Some propT›*) by simp next (*goal: ‹⋀x xs. ⟦⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn, y)∈set xs. typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list xs B) ∧ typ_of (mk_all_list xs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀(idn, y)∈set (xs @ [x]). typ_ok Θ y⟧ ⟹ term_ok Θ (mk_all_list (xs @ [x]) B) ∧ typ_of (mk_all_list (xs @ [x]) B) = Some propT›*) case (snoc v vs) (*‹⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set vs. case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT› ‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹term_ok Θ B› ‹typ_of B = Some propT› ‹∀a∈set (vs @ [v]). case a of (idn, a) ⇒ typ_ok Θ a›*) obtain idn and τ where v: "v = (idn, τ)" (*goal: ‹(⋀(idn::variable) τ::typ. (v::variable × typ) = (idn, τ) ⟹ thesis::bool) ⟹ thesis›*) by fastforce hence simp: "mk_all_list (vs@[v]) B = mk_all idn τ (mk_all_list vs B)" by (auto simp add: mk_all_list_def (*‹mk_all_list ?l ?t = fold (λ(n, T). mk_all n T) ?l ?t›*)) have I: "term_ok Θ (mk_all_list vs B)" "typ_of (mk_all_list vs B) = Some propT" using snoc (*‹⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set vs. case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT› ‹wf_theory Θ› ‹term_ok Θ B› ‹typ_of B = Some propT› ‹∀a∈set (vs @ [v]). case a of (idn, a) ⇒ typ_ok Θ a›*) apply - (*goals: 1. ‹⟦⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set vs. case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set (vs @ [v]). case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B)› 2. ‹⟦⟦wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set vs. case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ term_ok Θ (mk_all_list vs B) ∧ typ_of (mk_all_list vs B) = Some propT; wf_theory Θ; term_ok Θ B; typ_of B = Some propT; ∀a∈set (vs @ [v]). case a of (idn, a) ⇒ typ_ok Θ a⟧ ⟹ typ_of (mk_all_list vs B) = Some propT› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "term_ok Θ (mk_all idn τ (mk_all_list vs B))" using term_ok_mk_all (*‹⟦wf_theory ?Θ; term_ok' (sig ?Θ) ?B; typ_of ?B = Some propT; typ_ok ?Θ ?τ⟧ ⟹ term_ok ?Θ (mk_all ?x ?τ ?B)›*) snoc.prems (*‹wf_theory Θ› ‹term_ok Θ B› ‹typ_of (B::Core.term) = Some propT› ‹∀a::variable × typ∈set ((vs::(variable × typ) list) @ [v::variable × typ]). case a of (idn::variable, a::typ) ⇒ typ_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) a›*) I (*‹term_ok Θ (mk_all_list vs B)› ‹typ_of (mk_all_list vs B) = Some propT›*) v (*‹v = (idn, τ)›*) by (auto simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) moreover have "typ_of (mk_all idn τ (mk_all_list vs B)) = Some propT" using I(2) (*‹typ_of (mk_all_list vs B) = Some propT›*) v (*‹v = (idn, τ)›*) typ_of_mk_all (*‹typ_of (?A::Core.term) = Some propT ⟹ typ_of (mk_all (?x::variable) (?ty::typ) ?A) = Some propT›*) by simp ultimately show "?case" (*goal: ‹term_ok Θ (mk_all_list (vs @ [v]) B) ∧ typ_of (mk_all_list (vs @ [v]) B) = Some propT›*) by (simp add: simp (*‹mk_all_list (vs @ [v]) B = mk_all idn τ (mk_all_list vs B)›*)) qed (* Move, also see if these are not subsumed *) lemma tvs_bind_fv2: "tvs (bind_fv2 (v, T) lev t) ∪ tvsT T = tvs t ∪ tvsT T" apply (induction "(v, T)" lev t rule: bind_fv2.induct (*‹⟦⋀(vT::variable × typ) (n::nat) (v::variable) T::typ. (?P::variable × typ ⇒ nat ⇒ Core.term ⇒ bool) vT n (Fv v T); ⋀(vT::variable × typ) (n::nat) (T::typ) t::Core.term. ?P vT (n + (1::nat)) t ⟹ ?P vT n (Abs T t); ⋀(vT::variable × typ) (n::nat) (f::Core.term) u::Core.term. ⟦?P vT n f; ?P vT n u⟧ ⟹ ?P vT n (f $ u); ⋀(uu_::variable × typ) (uv_::nat) (v::String.literal) va::typ. ?P uu_ uv_ (Ct v va); ⋀(uu_::variable × typ) (uv_::nat) v::nat. ?P uu_ uv_ (Bv v)⟧ ⟹ ?P (?a0.0::variable × typ) (?a1.0::nat) (?a2.0::Core.term)›*)) (*goals: 1. ‹⋀n va Ta. tvs (bind_fv2 (v, T) n (Fv va Ta)) ∪ tvsT T = tvs (Fv va Ta) ∪ tvsT T› 2. ‹⋀n Ta t. tvs (bind_fv2 (v, T) (n + 1) t) ∪ tvsT T = tvs t ∪ tvsT T ⟹ tvs (bind_fv2 (v, T) n (Abs Ta t)) ∪ tvsT T = tvs (Abs Ta t) ∪ tvsT T› 3. ‹⋀n f u. ⟦tvs (bind_fv2 (v, T) n f) ∪ tvsT T = tvs f ∪ tvsT T; tvs (bind_fv2 (v, T) n u) ∪ tvsT T = tvs u ∪ tvsT T⟧ ⟹ tvs (bind_fv2 (v, T) n (f $ u)) ∪ tvsT T = tvs (f $ u) ∪ tvsT T› 4. ‹⋀uv_ va vaa. tvs (bind_fv2 (v, T) uv_ (Ct va vaa)) ∪ tvsT T = tvs (Ct va vaa) ∪ tvsT T› 5. ‹⋀uv_ va. tvs (bind_fv2 (v, T) uv_ (Bv va)) ∪ tvsT T = tvs (Bv va) ∪ tvsT T› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma tvs_bind_fv: "tvs (bind_fv (v,T) t) ∪ tvsT T = tvs t ∪ tvsT T" using tvs_bind_fv2 (*‹tvs (bind_fv2 (?v, ?T) ?lev ?t) ∪ tvsT ?T = tvs ?t ∪ tvsT ?T›*) bind_fv_def (*‹bind_fv ?vT ?t = bind_fv2 ?vT 0 ?t›*) by simp lemma tvs_mk_all': "tvs (mk_all idn ty B) = tvs B ∪ tvsT ty" using tvs_bind_fv (*‹tvs (bind_fv (?v, ?T) ?t) ∪ tvsT ?T = tvs ?t ∪ tvsT ?T›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) is_variable.simps(2) (*‹is_variable (Ct ?v ?va) = False›*) by fastforce lemma tvs_mk_all_list: "tvs (mk_all_list vs B) = tvs B ∪ tvsT_Set (snd ` set vs)" proof (induction vs rule: rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹tvs (mk_all_list [] B) = tvs B ∪ tvsT_Set (snd ` set [])› 2. ‹⋀x xs. tvs (mk_all_list xs B) = tvs B ∪ tvsT_Set (snd ` set xs) ⟹ tvs (mk_all_list (xs @ [x]) B) = tvs B ∪ tvsT_Set (snd ` set (xs @ [x]))›*) case Nil (*no hyothesis introduced yet*) then show "?case" (*goal: ‹tvs (mk_all_list [] B) = tvs B ∪ tvsT_Set (snd ` set [])›*) by simp next (*goal: ‹⋀x xs. tvs (mk_all_list xs B) = tvs B ∪ tvsT_Set (snd ` set xs) ⟹ tvs (mk_all_list (xs @ [x]) B) = tvs B ∪ tvsT_Set (snd ` set (xs @ [x]))›*) case (snoc v vs) (*‹tvs (mk_all_list vs B) = tvs B ∪ tvsT_Set (snd ` set vs)›*) obtain idn and τ where v: "v = (idn, τ)" (*goal: ‹(⋀idn τ. v = (idn, τ) ⟹ thesis) ⟹ thesis›*) by fastforce show "?case" (*goal: ‹tvs (mk_all_list (vs @ [v]) B) = tvs B ∪ tvsT_Set (snd ` set (vs @ [v]))›*) using snoc (*‹tvs (mk_all_list vs B) = tvs B ∪ tvsT_Set (snd ` set vs)›*) v (*‹v = (idn, τ)›*) tvs_mk_all' (*‹tvs (mk_all ?idn ?ty ?B) = tvs ?B ∪ tvsT ?ty›*) by (auto simp add: mk_all_list_def (*‹mk_all_list (?l::(variable × typ) list) (?t::Core.term) = fold (λ(n::variable, T::typ). mk_all n T) ?l ?t›*)) qed lemma tvs_occs: "occs v t ⟹ tvs v ⊆ tvs t" apply (induction t) (*goals: 1. ‹⋀x1 x2. occs v (Ct x1 x2) ⟹ tvs v ⊆ tvs (Ct x1 x2)› 2. ‹⋀x1 x2. occs v (Fv x1 x2) ⟹ tvs v ⊆ tvs (Fv x1 x2)› 3. ‹⋀x. occs v (Bv x) ⟹ tvs v ⊆ tvs (Bv x)› 4. ‹⋀x1 t. ⟦occs v t ⟹ tvs v ⊆ tvs t; occs v (Abs x1 t)⟧ ⟹ tvs v ⊆ tvs (Abs x1 t)› 5. ‹⋀t1 t2. ⟦occs v t1 ⟹ tvs v ⊆ tvs t1; occs v t2 ⟹ tvs v ⊆ tvs t2; occs v (t1 $ t2)⟧ ⟹ tvs v ⊆ tvs (t1 $ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma tvs_forall_intro_vars: "tvs (forall_intro_vars B Hs) = tvs B" proof (-) (*goal: ‹tvs (forall_intro_vars B Hs) = tvs B›*) have "∀(idn, ty)∈fv B . occs (Fv idn ty) B" using fv_occs (*‹(?x, ?τ) ∈ fv ?t ⟹ occs (Fv ?x ?τ) ?t›*) by blast hence "∀(idn, ty)∈fv B . tvs (Fv idn ty) ⊆ tvs B" using tvs_occs (*‹occs ?v ?t ⟹ tvs ?v ⊆ tvs ?t›*) by blast hence "∀(idn, ty)∈fv B . tvsT ty ⊆ tvs B" by simp hence "tvsT_Set (snd ` fv B) ⊆ tvs B" by fastforce hence "tvsT_Set (snd ` set (add_vars' B [])) ⊆ tvs B" by (simp add: add_vars'_fv (*‹set (add_vars' ?t []) = fv ?t›*)) thus "?thesis" (*goal: ‹tvs (forall_intro_vars B Hs) = tvs B›*) using tvs_mk_all_list (*‹tvs (mk_all_list (?vs::(variable × typ) list) (?B::Core.term)) = tvs ?B ∪ tvsT_Set (snd ` set ?vs)›*) by auto qed lemma "strip_all_single_var B = Some τ ⟹ strip_all_single_body B ≠ B" using strip_all_vars_step (*‹strip_all_single_var (?t::Core.term) = Some (?T::typ) ⟹ ?T # strip_all_vars (strip_all_single_body ?t) = strip_all_vars ?t›*) by fastforce lemma strip_all_body_unchanged_iff_strip_all_single_body_unchanged: "strip_all_body B = B ⟷ strip_all_single_body B = B" by (metis not_Cons_self2 (*‹(?x::?'a) # (?xs::?'a list) ≠ ?xs›*) not_None_eq (*‹((?x::?'a option) ≠ None) = (∃y::?'a. ?x = Some y)›*) not_is_all_imp_strip_all_body_unchanged (*‹¬ is_all (?t::Core.term) ⟹ strip_all_body ?t = ?t›*) strip_all_body_single_simp' (*‹strip_all_single_body (strip_all_body (?t::Core.term)) = strip_all_body ?t›*) strip_all_single_var_is_all (*‹(strip_all_single_var (?t::Core.term) ≠ None) = is_all ?t›*) strip_all_vars_step (*‹strip_all_single_var (?t::Core.term) = Some (?T::typ) ⟹ ?T # strip_all_vars (strip_all_single_body ?t) = strip_all_vars ?t›*)) lemma strip_all_body_unchanged_imp_strip_all_vars_no: assumes "strip_all_body B = B" shows "strip_all_vars B = []" by (smt assms (*‹strip_all_body B = B›*) not_Cons_self2 (*‹?x # ?xs ≠ ?xs›*) strip_all_body_single_simp' (*‹strip_all_single_body (strip_all_body ?t) = strip_all_body ?t›*) strip_all_single_body.simps( (*‹strip_all_single_body (Ct ?all ?S $ Abs ?T ?t) = (if ?all = STR ''Pure.all'' ∧ ?S = (?T → propT) → propT then ?t else Ct ?all ?S $ Abs ?T ?t)›*) 1) strip_all_vars.elims (*‹⟦strip_all_vars ?x = ?y; ⋀all S T t. ⟦?x = Ct all S $ Abs T t; ?y = (if all = STR ''Pure.all'' ∧ S = (T → propT) → propT then T # strip_all_vars t else [])⟧ ⟹ ?P; ⋀v va. ⟦?x = Ct v va; ?y = []⟧ ⟹ ?P; ⋀v va. ⟦?x = Fv v va; ?y = []⟧ ⟹ ?P; ⋀v. ⟦?x = Bv v; ?y = []⟧ ⟹ ?P; ⋀v va. ⟦?x = Abs v va; ?y = []⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Fv vb vc $ va; ?y = []⟧ ⟹ ?P; ⋀vb va. ⟦?x = Bv vb $ va; ?y = []⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Abs vb vc $ va; ?y = []⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = vb $ vc $ va; ?y = []⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Ct vb vc; ?y = []⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Fv vb vc; ?y = []⟧ ⟹ ?P; ⋀v vb. ⟦?x = v $ Bv vb; ?y = []⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ (vb $ vc); ?y = []⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma strip_all_body_unchanged_imp_strip_all_single_body_unchanged: "strip_all_body B = B ⟹ strip_all_single_body B = B" by (smt (z3) not_Cons_self2 (*‹?x # ?xs ≠ ?xs›*) strip_all_body_single_simp' (*‹strip_all_single_body (strip_all_body ?t) = strip_all_body ?t›*) strip_all_single_body.simps( (*‹strip_all_single_body (Ct ?all ?S $ Abs ?T ?t) = (if ?all = STR ''Pure.all'' ∧ ?S = (?T → propT) → propT then ?t else Ct ?all ?S $ Abs ?T ?t)›*) 1) strip_all_vars.simps( (*‹strip_all_vars (Ct ?all ?S $ Abs ?T ?t) = (if ?all = STR ''Pure.all'' ∧ ?S = (?T → propT) → propT then ?T # strip_all_vars ?t else [])›*) 1)) lemma strip_all_single_body_unchanged_imp_strip_all_body_unchanged: "strip_all_single_body B = B ⟹ strip_all_body B = B" by (auto elim!: strip_all_single_body.elims (*‹⟦strip_all_single_body ?x = ?y; ⋀all S T t. ⟦?x = Ct all S $ Abs T t; ?y = (if all = STR ''Pure.all'' ∧ S = (T → propT) → propT then t else Ct all S $ Abs T t)⟧ ⟹ ?P; ⋀v va. ⟦?x = Ct v va; ?y = Ct v va⟧ ⟹ ?P; ⋀v va. ⟦?x = Fv v va; ?y = Fv v va⟧ ⟹ ?P; ⋀v. ⟦?x = Bv v; ?y = Bv v⟧ ⟹ ?P; ⋀v va. ⟦?x = Abs v va; ?y = Abs v va⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Fv vb vc $ va; ?y = Fv vb vc $ va⟧ ⟹ ?P; ⋀vb va. ⟦?x = Bv vb $ va; ?y = Bv vb $ va⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Abs vb vc $ va; ?y = Abs vb vc $ va⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = vb $ vc $ va; ?y = vb $ vc $ va⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Ct vb vc; ?y = v $ Ct vb vc⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Fv vb vc; ?y = v $ Fv vb vc⟧ ⟹ ?P; ⋀v vb. ⟦?x = v $ Bv vb; ?y = v $ Bv vb⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ (vb $ vc); ?y = v $ (vb $ vc)⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma strip_all_single_var_np_imp_strip_all_body_single_unchanged: "strip_all_single_var B = None ⟹ strip_all_single_body B = B" by (auto elim!: strip_all_single_var.elims (*‹⟦strip_all_single_var ?x = ?y; ⋀all S T t. ⟦?x = Ct all S $ Abs T t; ?y = (if all = STR ''Pure.all'' ∧ S = (T → propT) → propT then Some T else None)⟧ ⟹ ?P; ⋀v va. ⟦?x = Ct v va; ?y = None⟧ ⟹ ?P; ⋀v va. ⟦?x = Fv v va; ?y = None⟧ ⟹ ?P; ⋀v. ⟦?x = Bv v; ?y = None⟧ ⟹ ?P; ⋀v va. ⟦?x = Abs v va; ?y = None⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Fv vb vc $ va; ?y = None⟧ ⟹ ?P; ⋀vb va. ⟦?x = Bv vb $ va; ?y = None⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Abs vb vc $ va; ?y = None⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = vb $ vc $ va; ?y = None⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Ct vb vc; ?y = None⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Fv vb vc; ?y = None⟧ ⟹ ?P; ⋀v vb. ⟦?x = v $ Bv vb; ?y = None⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ (vb $ vc); ?y = None⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma strip_all_single_form: "strip_all_single_var B = Some τ ⟹ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B) = B" by (auto elim!: strip_all_single_var.elims (*‹⟦strip_all_single_var ?x = ?y; ⋀all S T t. ⟦?x = Ct all S $ Abs T t; ?y = (if all = STR ''Pure.all'' ∧ S = (T → propT) → propT then Some T else None)⟧ ⟹ ?P; ⋀v va. ⟦?x = Ct v va; ?y = None⟧ ⟹ ?P; ⋀v va. ⟦?x = Fv v va; ?y = None⟧ ⟹ ?P; ⋀v. ⟦?x = Bv v; ?y = None⟧ ⟹ ?P; ⋀v va. ⟦?x = Abs v va; ?y = None⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Fv vb vc $ va; ?y = None⟧ ⟹ ?P; ⋀vb va. ⟦?x = Bv vb $ va; ?y = None⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = Abs vb vc $ va; ?y = None⟧ ⟹ ?P; ⋀vb vc va. ⟦?x = vb $ vc $ va; ?y = None⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Ct vb vc; ?y = None⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ Fv vb vc; ?y = None⟧ ⟹ ?P; ⋀v vb. ⟦?x = v $ Bv vb; ?y = None⟧ ⟹ ?P; ⋀v vb vc. ⟦?x = v $ (vb $ vc); ?y = None⟧ ⟹ ?P⟧ ⟹ ?P›*) split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) lemma proves_strip_all_single: assumes "Θ, Γ ⊢ B" "strip_all_single_var B = Some τ" "typ_of t = Some τ" "term_ok Θ t" shows "Θ, Γ ⊢ subst_bv t (strip_all_single_body B)" proof (-) (*goal: ‹Θ,Γ ⊢ subst_bv t (strip_all_single_body B)›*) have 1: "Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B) = B" using assms(2) (*‹strip_all_single_var B = Some τ›*) strip_all_single_form (*‹strip_all_single_var ?B = Some ?τ ⟹ Ct STR ''Pure.all'' ((?τ → propT) → propT) $ Abs ?τ (strip_all_single_body ?B) = ?B›*) by blast hence "Θ, Γ ⊢ Abs τ (strip_all_single_body B) ∙ t" using assms (*‹Θ,Γ ⊢ B› ‹strip_all_single_var (B::Core.term) = Some (τ::typ)› ‹typ_of t = Some τ› ‹term_ok Θ t›*) forall_elim (*‹⟦?Θ,?Γ ⊢ Ct STR ''Pure.all'' ((?τ → propT) → propT) $ Abs ?τ ?B; ⊢⇩τ ?a : ?τ; wf_term (sig ?Θ) ?a⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?a ?B›*) proof (-) (*goal: ‹⟦Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B) = B; Θ,Γ ⊢ B; strip_all_single_var B = Some τ; typ_of t = Some τ; term_ok Θ t; ⋀Θ Γ τ B a. ⟦Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⊢⇩τ a : τ; wf_term (sig Θ) a⟧ ⟹ Θ,Γ ⊢ subst_bv a B⟧ ⟹ Θ,Γ ⊢ Abs τ (strip_all_single_body B) ∙ t›*) have "has_typ t τ" by (meson ‹typ_of t = Some τ› has_typ_iff_typ_of (*‹⊢⇩τ ?t : ?ty = (typ_of ?t = Some ?ty)›*)) then show "?thesis" (*goal: ‹Θ,Γ ⊢ Abs τ (strip_all_single_body B) ∙ t›*) by (metis "1" (*‹Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B) = B›*) assms( (*‹Θ,Γ ⊢ B›*) 1) assms( (*‹term_ok Θ t›*) 4) betapply.simps( (*‹Abs ?uu ?t ∙ ?u = subst_bv ?u ?t›*) 1) forall_elim (*‹⟦?Θ,?Γ ⊢ Ct STR ''Pure.all'' ((?τ → propT) → propT) $ Abs ?τ ?B; ⊢⇩τ ?a : ?τ; wf_term (sig ?Θ) ?a⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?a ?B›*) term_ok_def (*‹term_ok ?Θ ?t ≡ wt_term (sig ?Θ) ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) qed thus "?thesis" (*goal: ‹Θ,Γ ⊢ subst_bv t (strip_all_single_body B)›*) by simp qed corollary proves_strip_all_single_Fv: assumes "Θ, Γ ⊢ B" "strip_all_single_var B = Some τ" shows "Θ, Γ ⊢ subst_bv (Fv x τ) (strip_all_single_body B)" proof (-) (*goal: ‹Θ,Γ ⊢ subst_bv (Fv x τ) (strip_all_single_body B)›*) have ok: "term_ok Θ B" using assms(1) (*‹Θ,Γ ⊢ B›*) proved_terms_well_formed(2) (*‹?Θ,?Γ ⊢ ?p ⟹ term_ok ?Θ ?p›*) by auto thm strip_all_single_form wt_term_def term_ok_var typ_of_var typ_ok_def proves_strip_all_single strip_all_single_form have s: "B = Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B)" using assms(2) (*‹strip_all_single_var (B::Core.term) = Some (τ::typ)›*) strip_all_single_form[symmetric] (*‹strip_all_single_var (?t::Core.term) = Some (?τ::typ) ⟹ ?t = Ct STR ''Pure.all'' ((?τ → propT) → propT) $ Abs ?τ (strip_all_single_body ?t)›*) by simp have "τ ∈ Types B" apply (subst s (*‹B = Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B)›*)) (*goal: ‹(τ::typ) ∈ Types (B::Core.term)›*) by simp hence "typ_ok Θ τ" by (metis ok (*‹term_ok Θ B›*) s (*‹B = Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_single_body B)›*) term_ok'.simps( (*‹term_ok' ?Σ (?t $ ?u) = (term_ok' ?Σ ?t ∧ term_ok' ?Σ ?u)›*) 4) term_ok'.simps( (*‹term_ok' ?Σ (Abs ?T ?t) = (typ_ok_sig ?Σ ?T ∧ term_ok' ?Σ ?t)›*) 5) term_okD1 (*‹term_ok ?Θ ?t ⟹ term_ok' (sig ?Θ) ?t›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) typ_ok_sig_imp_wf_type (*‹typ_ok_sig ?Σ ?T ⟹ wf_type ?Σ ?T›*)) hence "term_ok Θ (Fv x τ)" using term_ok_var (*‹term_ok ?Θ (Fv ?idn ?τ) = typ_ok ?Θ ?τ›*) by blast then show "?thesis" (*goal: ‹Θ,Γ ⊢ subst_bv (Fv x τ) (strip_all_single_body B)›*) using assms (*‹Θ,Γ ⊢ B› ‹strip_all_single_var B = Some τ›*) proves_strip_all_single[where τ = τ] (*‹⟦?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ::Core.term set ⊢ ?B::Core.term; strip_all_single_var ?B = Some (τ::typ); typ_of (?t::Core.term) = Some τ; term_ok ?Θ ?t⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?t (strip_all_single_body ?B)›*) by auto qed lemma strip_all_vars_no_strip_all_body_unchanged[simp]: "strip_all_vars B = [] ⟹ strip_all_body B = B" by (auto elim!: strip_all_vars.elims (*‹⟦strip_all_vars (?x::Core.term) = (?y::typ list); ⋀(all::String.literal) (S::typ) (T::typ) t::Core.term. ⟦?x = Ct all S $ Abs T t; ?y = (if all = STR ''Pure.all'' ∧ S = (T → propT) → propT then T # strip_all_vars t else [])⟧ ⟹ ?P::bool; ⋀(v::String.literal) va::typ. ⟦?x = Ct v va; ?y = []⟧ ⟹ ?P; ⋀(v::variable) va::typ. ⟦?x = Fv v va; ?y = []⟧ ⟹ ?P; ⋀v::nat. ⟦?x = Bv v; ?y = []⟧ ⟹ ?P; ⋀(v::typ) va::Core.term. ⟦?x = Abs v va; ?y = []⟧ ⟹ ?P; ⋀(vb::variable) (vc::typ) va::Core.term. ⟦?x = Fv vb vc $ va; ?y = []⟧ ⟹ ?P; ⋀(vb::nat) va::Core.term. ⟦?x = Bv vb $ va; ?y = []⟧ ⟹ ?P; ⋀(vb::typ) (vc::Core.term) va::Core.term. ⟦?x = Abs vb vc $ va; ?y = []⟧ ⟹ ?P; ⋀(vb::Core.term) (vc::Core.term) va::Core.term. ⟦?x = vb $ vc $ va; ?y = []⟧ ⟹ ?P; ⋀(v::Core.term) (vb::String.literal) vc::typ. ⟦?x = v $ Ct vb vc; ?y = []⟧ ⟹ ?P; ⋀(v::Core.term) (vb::variable) vc::typ. ⟦?x = v $ Fv vb vc; ?y = []⟧ ⟹ ?P; ⋀(v::Core.term) vb::nat. ⟦?x = v $ Bv vb; ?y = []⟧ ⟹ ?P; ⋀(v::Core.term) (vb::Core.term) vc::Core.term. ⟦?x = v $ (vb $ vc); ?y = []⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma "strip_all_vars B = (τs@[τ]) ⟹ strip_all_body B = strip_all_single_body (Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (strip_all_body B))" by simp lemma strip_all_vars_incr_bv: "strip_all_vars (incr_bv inc lev t) = strip_all_vars t" apply (induction t arbitrary: lev rule: strip_all_vars.induct) (*goals: 1. ‹⋀(alla::String.literal) (S::typ) (T::typ) (t::Core.term) lev::nat. (⋀lev::nat. alla = STR ''Pure.all'' ∧ S = (T → propT) → propT ⟹ strip_all_vars (incr_bv (inc::nat) lev t) = strip_all_vars t) ⟹ strip_all_vars (incr_bv inc lev (Ct alla S $ Abs T t)) = strip_all_vars (Ct alla S $ Abs T t)› 2. ‹⋀(v::String.literal) (va::typ) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Ct v va)) = strip_all_vars (Ct v va)› 3. ‹⋀(v::variable) (va::typ) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Fv v va)) = strip_all_vars (Fv v va)› 4. ‹⋀(v::nat) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Bv v)) = strip_all_vars (Bv v)› 5. ‹⋀(v::typ) (va::Core.term) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Abs v va)) = strip_all_vars (Abs v va)› 6. ‹⋀(vb::variable) (vc::typ) (va::Core.term) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Fv vb vc $ va)) = strip_all_vars (Fv vb vc $ va)› 7. ‹⋀(vb::nat) (va::Core.term) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Bv vb $ va)) = strip_all_vars (Bv vb $ va)› 8. ‹⋀(vb::typ) (vc::Core.term) (va::Core.term) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (Abs vb vc $ va)) = strip_all_vars (Abs vb vc $ va)› 9. ‹⋀(vb::Core.term) (vc::Core.term) (va::Core.term) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (vb $ vc $ va)) = strip_all_vars (vb $ vc $ va)› 10. ‹⋀(v::Core.term) (vb::String.literal) (vc::typ) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (v $ Ct vb vc)) = strip_all_vars (v $ Ct vb vc)› 11. ‹⋀(v::Core.term) (vb::variable) (vc::typ) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (v $ Fv vb vc)) = strip_all_vars (v $ Fv vb vc)› 12. ‹⋀(v::Core.term) (vb::nat) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (v $ Bv vb)) = strip_all_vars (v $ Bv vb)› 13. ‹⋀(v::Core.term) (vb::Core.term) (vc::Core.term) lev::nat. strip_all_vars (incr_bv (inc::nat) lev (v $ (vb $ vc))) = strip_all_vars (v $ (vb $ vc))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*discuss goal 8*) apply ((auto)[1]) (*discuss goal 9*) apply ((auto)[1]) (*discuss goal 10*) apply ((auto)[1]) (*discuss goal 11*) apply ((auto)[1]) (*discuss goal 12*) apply ((auto)[1]) (*discuss goal 13*) apply ((auto)[1]) (*proven 13 subgoals*) . lemma strip_all_vars_incr_boundvars: "strip_all_vars (incr_boundvars inc t) = strip_all_vars t" using incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*) strip_all_vars_incr_bv (*‹strip_all_vars (incr_bv (?inc::nat) (?lev::nat) (?t::Core.term)) = strip_all_vars ?t›*) by simp lemma strip_all_vars_subst_bv1_Fv: "strip_all_vars (subst_bv1 B lev (Fv x τ)) = strip_all_vars B" apply (induction B arbitrary: lev rule: strip_all_vars.induct) (*goals: 1. ‹⋀alla S T t lev. (⋀lev. alla = STR ''Pure.all'' ∧ S = (T → propT) → propT ⟹ strip_all_vars (subst_bv1 t lev (Fv x τ)) = strip_all_vars t) ⟹ strip_all_vars (subst_bv1 (Ct alla S $ Abs T t) lev (Fv x τ)) = strip_all_vars (Ct alla S $ Abs T t)› 2. ‹⋀v va lev. strip_all_vars (subst_bv1 (Ct v va) lev (Fv x τ)) = strip_all_vars (Ct v va)› 3. ‹⋀v va lev. strip_all_vars (subst_bv1 (Fv v va) lev (Fv x τ)) = strip_all_vars (Fv v va)› 4. ‹⋀v lev. strip_all_vars (subst_bv1 (Bv v) lev (Fv x τ)) = strip_all_vars (Bv v)› 5. ‹⋀v va lev. strip_all_vars (subst_bv1 (Abs v va) lev (Fv x τ)) = strip_all_vars (Abs v va)› 6. ‹⋀vb vc va lev. strip_all_vars (subst_bv1 (Fv vb vc $ va) lev (Fv x τ)) = strip_all_vars (Fv vb vc $ va)› 7. ‹⋀vb va lev. strip_all_vars (subst_bv1 (Bv vb $ va) lev (Fv x τ)) = strip_all_vars (Bv vb $ va)› 8. ‹⋀vb vc va lev. strip_all_vars (subst_bv1 (Abs vb vc $ va) lev (Fv x τ)) = strip_all_vars (Abs vb vc $ va)› 9. ‹⋀vb vc va lev. strip_all_vars (subst_bv1 (vb $ vc $ va) lev (Fv x τ)) = strip_all_vars (vb $ vc $ va)› 10. ‹⋀v vb vc lev. strip_all_vars (subst_bv1 (v $ Ct vb vc) lev (Fv x τ)) = strip_all_vars (v $ Ct vb vc)› 11. ‹⋀v vb vc lev. strip_all_vars (subst_bv1 (v $ Fv vb vc) lev (Fv x τ)) = strip_all_vars (v $ Fv vb vc)› 12. ‹⋀v vb lev. strip_all_vars (subst_bv1 (v $ Bv vb) lev (Fv x τ)) = strip_all_vars (v $ Bv vb)› 13. ‹⋀v vb vc lev. strip_all_vars (subst_bv1 (v $ (vb $ vc)) lev (Fv x τ)) = strip_all_vars (v $ (vb $ vc))› discuss goal 1*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 2*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 3*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 4*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 5*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 6*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 7*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 8*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 9*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 10*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*discuss goal 11*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars (?inc::nat) (?t::Core.term) = incr_bv ?inc (0::nat) ?t›*))[1]) (*discuss goal 12*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars (?inc::nat) (?t::Core.term) = incr_bv ?inc (0::nat) ?t›*))[1]) (*discuss goal 13*) apply ((auto simp add: incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*))[1]) (*proven 13 subgoals*) . lemma strip_all_vars_subst_bv_Fv: "strip_all_vars (subst_bv (Fv x τ) B) = strip_all_vars B" by (simp add: strip_all_vars_subst_bv1_Fv (*‹strip_all_vars (subst_bv1 ?B ?lev (Fv ?x ?τ)) = strip_all_vars ?B›*) subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*)) lemma "strip_all_single_var B = Some τ ⟹ strip_all_vars (subst_bv (Fv x τ) (strip_all_single_body B)) = tl (strip_all_vars B)" by (metis list.sel( (*‹tl (?x21.0 # ?x22.0) = ?x22.0›*) 3) strip_all_vars_step (*‹strip_all_single_var ?t = Some ?T ⟹ ?T # strip_all_vars (strip_all_single_body ?t) = strip_all_vars ?t›*) strip_all_vars_subst_bv_Fv (*‹strip_all_vars (subst_bv (Fv ?x ?τ) ?B) = strip_all_vars ?B›*)) (* Allowing general terms instead of just vars here is more difficult as one could create new leading ⋀s *) corollary proves_strip_all_vars_Fv: assumes "length xs = length (strip_all_vars B)" "Θ, Γ ⊢ B" shows "Θ, Γ ⊢ fold (λ(x,τ). subst_bv (Fv x τ) o strip_all_single_body) (zip xs (strip_all_vars B)) B" using assms (*‹length (xs::variable list) = length (strip_all_vars (B::Core.term))› ‹Θ,Γ ⊢ B›*) proof (induction xs "strip_all_vars B" arbitrary: B rule: list_induct2) (*goals: 1. ‹⋀B::Core.term. ⟦[] = strip_all_vars B; Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B⟧ ⟹ Θ,Γ ⊢ fold (λ(x::variable, τ::typ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip [] (strip_all_vars B)) B› 2. ‹⋀(x::variable) (xs::variable list) (y::typ) (ys::typ list) B::Core.term. ⟦length xs = length ys; ⋀B::Core.term. ⟦ys = strip_all_vars B; Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B⟧ ⟹ Θ,Γ ⊢ fold (λ(x::variable, τ::typ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip xs (strip_all_vars B)) B; y # ys = strip_all_vars B; Θ,Γ ⊢ B⟧ ⟹ Θ,Γ ⊢ fold (λ(x::variable, τ::typ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip (x # xs) (strip_all_vars B)) B›*) case Nil (*‹[] = strip_all_vars B› ‹Θ,Γ ⊢ B›*) then show "?case" (*goal: ‹Θ,Γ ⊢ fold (λa. case a of (x, τ) ⇒ subst_bv (Fv x τ) ∘ strip_all_single_body) (zip [] (strip_all_vars B)) B›*) by simp next (*goal: ‹⋀x xs y ys B. ⟦length xs = length ys; ⋀B. ⟦ys = strip_all_vars B; Θ,Γ ⊢ B⟧ ⟹ Θ,Γ ⊢ fold (λ(x, τ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip xs (strip_all_vars B)) B; y # ys = strip_all_vars B; Θ,Γ ⊢ B⟧ ⟹ Θ,Γ ⊢ fold (λ(x, τ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip (x # xs) (strip_all_vars B)) B›*) case (Cons x xs τ τs) (*‹length (xs::variable list) = length (τs::typ list)› ‹⟦τs = strip_all_vars ?B; Θ,Γ ⊢ ?B⟧ ⟹ Θ,Γ ⊢ fold (λ(x, τ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip xs (strip_all_vars ?B)) ?B› ‹(τ::typ) # (τs::typ list) = strip_all_vars (B::Core.term)› ‹Θ,Γ ⊢ B›*) have st: "strip_all_single_var B = Some τ" by (metis Cons.hyps( (*‹τ # τs = strip_all_vars B›*) 3) is_all_iff_strip_all_vars_not_empty (*‹is_all ?t = (strip_all_vars ?t ≠ [])›*) list.distinct( (*‹[] ≠ ?x21.0 # ?x22.0›*) 1) list.inject (*‹(?x21.0 # ?x22.0 = ?y21.0 # ?y22.0) = (?x21.0 = ?y21.0 ∧ ?x22.0 = ?y22.0)›*) option.exhaust (*‹⟦?y = None ⟹ ?P; ⋀x2. ?y = Some x2 ⟹ ?P⟧ ⟹ ?P›*) strip_all_single_var_is_all (*‹(strip_all_single_var ?t ≠ None) = is_all ?t›*) strip_all_vars_step (*‹strip_all_single_var ?t = Some ?T ⟹ ?T # strip_all_vars (strip_all_single_body ?t) = strip_all_vars ?t›*)) moreover have "term_ok Θ (Fv x τ)" proof (-) (*goal: ‹term_ok Θ (Fv x τ)›*) obtain B' where "Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B' = B" (*goal: ‹(⋀B'::Core.term. Ct STR ''Pure.all'' (((τ::typ) → propT) → propT) $ Abs τ B' = (B::Core.term) ⟹ thesis::bool) ⟹ thesis›*) using st (*‹strip_all_single_var B = Some τ›*) strip_all_single_form (*‹strip_all_single_var ?B = Some ?τ ⟹ Ct STR ''Pure.all'' ((?τ → propT) → propT) $ Abs ?τ (strip_all_single_body ?B) = ?B›*) by blast moreover have "term_ok Θ B" using Cons.prems (*‹Θ,Γ ⊢ B›*) proved_terms_well_formed(2) (*‹?Θ,?Γ ⊢ ?p ⟹ term_ok ?Θ ?p›*) by auto ultimately have "typ_ok Θ τ" using term_ok'.simps(5) (*‹term_ok' ?Σ (Abs ?T ?t) = (typ_ok_sig ?Σ ?T ∧ term_ok' ?Σ ?t)›*) term_ok'.simps(4) (*‹term_ok' ?Σ (?t $ ?u) = (term_ok' ?Σ ?t ∧ term_ok' ?Σ ?u)›*) term_ok_def (*‹term_ok ?Θ ?t ≡ wt_term (sig ?Θ) ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) by blast thus "?thesis" (*goal: ‹term_ok Θ (Fv x τ)›*) unfolding term_ok_def wt_term_def typ_ok_def (*goal: ‹wf_term (sig Θ) (Fv x τ) ∧ (∃T. ⊢⇩τ Fv x τ : T)›*) by simp qed ultimately have 1: "Θ,Γ ⊢ subst_bv (Fv x τ) (strip_all_single_body B)" using proves_strip_all_single (*‹⟦?Θ,?Γ ⊢ ?B; strip_all_single_var ?B = Some ?τ; typ_of ?t = Some ?τ; term_ok ?Θ ?t⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?t (strip_all_single_body ?B)›*) by (simp add: Cons.prems (*‹Θ,Γ ⊢ B›*) proves_strip_all_single_Fv (*‹⟦?Θ,?Γ ⊢ ?B; strip_all_single_var ?B = Some ?τ⟧ ⟹ ?Θ,?Γ ⊢ subst_bv (Fv ?x ?τ) (strip_all_single_body ?B)›*)) have "Θ,Γ ⊢ fold (λ(x, τ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip xs (strip_all_vars (subst_bv (Fv x τ) (strip_all_single_body B)))) (subst_bv (Fv x τ) (strip_all_single_body B))" apply (rule Cons.hyps (*‹length xs = length τs› ‹⟦τs = strip_all_vars ?B; Θ,Γ ⊢ ?B⟧ ⟹ Θ,Γ ⊢ fold (λ(x, τ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip xs (strip_all_vars ?B)) ?B› ‹τ # τs = strip_all_vars B›*)) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ fold (λ(x::variable, τ::typ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip (xs::variable list) (strip_all_vars (subst_bv (Fv (x::variable) (τ::typ)) (strip_all_single_body (B::Core.term))))) (subst_bv (Fv x τ) (strip_all_single_body B))›*) apply (metis Cons.hyps( (*‹τ # τs = strip_all_vars B›*) 3) list.inject (*‹(?x21.0 # ?x22.0 = ?y21.0 # ?y22.0) = (?x21.0 = ?y21.0 ∧ ?x22.0 = ?y22.0)›*) st (*‹strip_all_single_var B = Some τ›*) strip_all_vars_step (*‹strip_all_single_var ?t = Some ?T ⟹ ?T # strip_all_vars (strip_all_single_body ?t) = strip_all_vars ?t›*) strip_all_vars_subst_bv_Fv (*‹strip_all_vars (subst_bv (Fv ?x ?τ) ?B) = strip_all_vars ?B›*)) (*top goal: ‹(τs::typ list) = strip_all_vars (subst_bv (Fv (x::variable) (τ::typ)) (strip_all_single_body (B::Core.term)))› and 1 goal remains*) using "1" (*‹Θ,Γ ⊢ subst_bv (Fv x τ) (strip_all_single_body B)›*) by simp moreover have "strip_all_vars B = τ # τs" using Cons.hyps(3) (*‹τ # τs = strip_all_vars B›*) by auto ultimately show "?case" (*goal: ‹Θ,Γ ⊢ fold (λ(x, τ). subst_bv (Fv x τ) ∘ strip_all_single_body) (zip (x # xs) (strip_all_vars B)) B›*) using st (*‹strip_all_single_var B = Some τ›*) strip_all_vars_step (*‹strip_all_single_var ?t = Some ?T ⟹ ?T # strip_all_vars (strip_all_single_body ?t) = strip_all_vars ?t›*) strip_all_vars_subst_bv_Fv (*‹strip_all_vars (subst_bv (Fv ?x ?τ) ?B) = strip_all_vars ?B›*) by fastforce qed lemma trivial_pre_depr: "term_ok Θ c ⟹ typ_of c = Some propT ⟹ Θ, {c} ⊢ c" apply (rule "assume" (*‹⟦wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A›*)) (*goals: 1. ‹⟦term_ok Θ c; typ_of c = Some propT⟧ ⟹ wf_term (sig Θ) c› 2. ‹⟦term_ok Θ c; typ_of c = Some propT⟧ ⟹ ⊢⇩τ c : propT› 3. ‹⟦term_ok Θ c; typ_of c = Some propT⟧ ⟹ c ∈ {c}› discuss goal 1*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) (*discuss goal 2*) apply (simp add: wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*)) (*discuss goal 3*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) (*proven 3 subgoals*) . lemma trivial_pre: assumes "wf_theory Θ" "term_ok Θ c" "typ_of c = Some propT" shows "Θ, {} ⊢ c ⟼ c" proof (-) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,{} ⊢ (c::Core.term) ⟼ c›*) have s: "{} = {c} - {c}" by simp show "?thesis" (*goal: ‹Θ,{} ⊢ c ⟼ c›*) apply (subst s (*‹{} = {c} - {c}›*)) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,{} ⊢ (c::Core.term) ⟼ c›*) apply (rule "implies_intro" (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B›*)) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,{c::Core.term} - {c} ⊢ c ⟼ c›*) using assms (*‹wf_theory Θ› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (c::Core.term)› ‹typ_of (c::Core.term) = Some propT›*) apply - (*goals: 1. ‹⟦wf_theory Θ; term_ok Θ c; typ_of c = Some propT⟧ ⟹ wf_theory Θ› 2. ‹⟦wf_theory Θ; term_ok Θ c; typ_of c = Some propT⟧ ⟹ Θ,{c} ⊢ c› 3. ‹⟦wf_theory Θ; term_ok Θ c; typ_of c = Some propT⟧ ⟹ wf_term (sig Θ) c› 4. ‹⟦wf_theory Θ; term_ok Θ c; typ_of c = Some propT⟧ ⟹ ⊢⇩τ c : propT› discuss goal 1*) apply ((auto simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) intro: "assume" (*‹⟦wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A›*))[1]) (*discuss goal 2*) apply ((auto simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) intro: "assume" (*‹⟦wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A›*))[1]) (*discuss goal 3*) apply ((auto simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) intro: "assume" (*‹⟦wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A›*))[1]) (*discuss goal 4*) apply ((auto simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) intro: "assume" (*‹⟦wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A›*))[1]) (*proven 4 subgoals*) . qed lemma inst_var: assumes wf_theory: "wf_theory Θ" assumes B: "Θ, Γ ⊢ B" assumes a_ok: "term_ok Θ a" assumes typ_a: "typ_of a = Some τ" assumes free: "(x,τ) ∉ FV Γ" shows "Θ, Γ ⊢ subst_term [((x, τ), a)] B" proof (-) (*goal: ‹Θ,Γ ⊢ subst_term [((x, τ), a)] B›*) have s1: "mk_all x τ B = Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ (bind_fv (x, τ) B)" by (simp add: typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) have closed_B: "is_closed B" using B (*‹Θ,Γ ⊢ B›*) proved_terms_well_formed_pre (*‹?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ::Core.term set ⊢ ?p::Core.term ⟹ typ_of ?p = Some propT ∧ term_ok ?Θ ?p›*) using typ_of_imp_closed (*‹typ_of (?t::Core.term) = Some (?ty::typ) ⟹ is_closed ?t›*) by blast have "typ_ok Θ τ" using wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_ok_def (*‹typ_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?T::typ) ≡ wf_type (sig ?Θ) ?T›*) term_ok_imp_typ_ok (*‹⟦wf_theory ?thy; term_ok ?thy ?t; typ_of ?t = Some ?ty⟧ ⟹ typ_ok ?thy ?ty›*) using a_ok (*‹term_ok Θ a›*) wf_theory (*‹wf_theory Θ›*) typ_a (*‹typ_of a = Some τ›*) by blast hence p1: "Θ, Γ ⊢ mk_all x τ B" using forall_intro[OF wf_theory B] (*‹⟦(?x, ?τ) ∉ FV Γ; wf_type (sig Θ) ?τ⟧ ⟹ Θ,Γ ⊢ mk_all ?x ?τ B›*) B (*‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term›*) typ_a (*‹typ_of (a::Core.term) = Some (τ::typ)›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) wf_theory (*‹wf_theory Θ›*) term_ok_imp_typ_ok (*‹⟦wf_theory ?thy; term_ok ?thy ?t; typ_of ?t = Some ?ty⟧ ⟹ typ_ok ?thy ?ty›*) free (*‹(x::variable, τ::typ) ∉ FV (Γ::Core.term set)›*) by simp have "Θ, Γ ⊢ subst_bv a (bind_fv (x, τ) B)" using forall_elim[of _ _ τ] (*‹⟦?Θ,?Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ ?B; ⊢⇩τ ?a : τ; wf_term (sig ?Θ) ?a⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?a ?B›*) p1 (*‹Θ,Γ ⊢ mk_all x τ B›*) typ_a (*‹typ_of (a::Core.term) = Some (τ::typ)›*) a_ok (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (a::Core.term)›*) proves_strip_all_single (*‹⟦?Θ,?Γ ⊢ ?B; strip_all_single_var ?B = Some ?τ; typ_of ?t = Some ?τ; term_ok ?Θ ?t⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?t (strip_all_single_body ?B)›*) by (meson has_typ_iff_typ_of (*‹⊢⇩τ ?t : ?ty = (typ_of ?t = Some ?ty)›*) term_ok_def (*‹term_ok ?Θ ?t ≡ wt_term (sig ?Θ) ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) have "Θ, Γ ⊢ subst_bv a ((bind_fv (x, τ) B))" using forall_elim[of _ _ τ] (*‹⟦?Θ,?Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ ?B; ⊢⇩τ ?a : τ; wf_term (sig ?Θ) ?a⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?a ?B›*) p1 (*‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ mk_all (x::variable) (τ::typ) (B::Core.term)›*) typ_a (*‹typ_of a = Some τ›*) a_ok (*‹term_ok Θ a›*) proves_strip_all_single (*‹⟦?Θ,?Γ ⊢ ?B; strip_all_single_var ?B = Some ?τ; typ_of ?t = Some ?τ; term_ok ?Θ ?t⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?t (strip_all_single_body ?B)›*) by (meson has_typ_iff_typ_of (*‹⊢⇩τ ?t : ?ty = (typ_of ?t = Some ?ty)›*) term_ok_def (*‹term_ok ?Θ ?t ≡ wt_term (sig ?Θ) ?t›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) thus "Θ, Γ ⊢ subst_term [((x, τ), a)] B" using instantiate_var_same_type'' (*‹⟦typ_of ?a = Some ?τ; is_closed ?B⟧ ⟹ Abs_fv ?x ?τ ?B ∙ ?a = subst_term [((?x, ?τ), ?a)] ?B›*) assms (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹term_ok Θ a› ‹typ_of a = Some τ› ‹(x, τ) ∉ FV Γ›*) closed_B (*‹is_closed (B::Core.term)›*) by simp qed (* MOVE *) lemma subst_term_single_no_change[simp]: assumes nvar: "(x,τ)∉fv B" shows "subst_term [((x,τ), t)] B = B" using assms (*‹(x, τ) ∉ fv B›*) apply (induction B) (*goals: 1. ‹⋀x1 x2. (x, τ) ∉ fv (Ct x1 x2) ⟹ subst_term [((x, τ), t)] (Ct x1 x2) = Ct x1 x2› 2. ‹⋀x1 x2. (x, τ) ∉ fv (Fv x1 x2) ⟹ subst_term [((x, τ), t)] (Fv x1 x2) = Fv x1 x2› 3. ‹⋀xa. (x, τ) ∉ fv (Bv xa) ⟹ subst_term [((x, τ), t)] (Bv xa) = Bv xa› 4. ‹⋀x1 B. ⟦(x, τ) ∉ fv B ⟹ subst_term [((x, τ), t)] B = B; (x, τ) ∉ fv (Abs x1 B)⟧ ⟹ subst_term [((x, τ), t)] (Abs x1 B) = Abs x1 B› 5. ‹⋀B1 B2. ⟦(x, τ) ∉ fv B1 ⟹ subst_term [((x, τ), t)] B1 = B1; (x, τ) ∉ fv B2 ⟹ subst_term [((x, τ), t)] B2 = B2; (x, τ) ∉ fv (B1 $ B2)⟧ ⟹ subst_term [((x, τ), t)] (B1 $ B2) = B1 $ B2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma fv_subst_term_single: assumes var: "(x,τ)∈fv B" assumes "⋀p . p ∈ fv t ⟹ p ~= (x,τ)" shows "fv (subst_term [((x,τ), t)] B) = fv B - {(x,τ)} ∪ fv t" using assms (*‹(x, τ) ∈ fv B› ‹?p ∈ fv t ⟹ ?p ≠ (x, τ)›*) proof (induction B) (*goals: 1. ‹⋀x1 x2. ⟦(x, τ) ∈ fv (Ct x1 x2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Ct x1 x2)) = fv (Ct x1 x2) - {(x, τ)} ∪ fv t› 2. ‹⋀x1 x2. ⟦(x, τ) ∈ fv (Fv x1 x2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Fv x1 x2)) = fv (Fv x1 x2) - {(x, τ)} ∪ fv t› 3. ‹⋀xa. ⟦(x, τ) ∈ fv (Bv xa); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Bv xa)) = fv (Bv xa) - {(x, τ)} ∪ fv t› 4. ‹⋀x1 B. ⟦⟦(x, τ) ∈ fv B; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B) = fv B - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (Abs x1 B); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Abs x1 B)) = fv (Abs x1 B) - {(x, τ)} ∪ fv t› 5. ‹⋀B1 B2. ⟦⟦(x, τ) ∈ fv B1; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv B2; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t›*) case (App B1 B2) (*‹⟦(x, τ) ∈ fv B1; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t› ‹⟦(x, τ) ∈ fv B2; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t› ‹(x, τ) ∈ fv (B1 $ B2)› ‹?p ∈ fv t ⟹ ?p ≠ (x, τ)›*) then show "?case" (*goal: ‹fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t›*) apply (cases "(x,τ)∈fv B1") (*goals: 1. ‹⟦⟦(x, τ) ∈ fv B1; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv B2; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ); (x, τ) ∈ fv B1⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t› 2. ‹⟦⟦(x, τ) ∈ fv B1; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv B2; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ); (x, τ) ∉ fv B1⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t› discuss goal 1*) apply (cases "(x,τ)∈fv B2") (*goals: 1. ‹⟦⟦(x::variable, τ::typ) ∈ fv (B1::Core.term); ⋀p::variable × typ. p ∈ fv (t::Core.term) ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv (B2::Core.term); ⋀p::variable × typ. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p::variable × typ. p ∈ fv t ⟹ p ≠ (x, τ); (x, τ) ∈ fv B1; (x, τ) ∈ fv B2⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t› 2. ‹⟦⟦(x::variable, τ::typ) ∈ fv (B1::Core.term); ⋀p::variable × typ. p ∈ fv (t::Core.term) ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv (B2::Core.term); ⋀p::variable × typ. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p::variable × typ. p ∈ fv t ⟹ p ≠ (x, τ); (x, τ) ∈ fv B1; (x, τ) ∉ fv B2⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases "(x,τ)∈fv B2") (*goals: 1. ‹⟦⟦(x, τ) ∈ fv B1; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv B2; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ); (x, τ) ∉ fv B1; (x, τ) ∈ fv B2⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t› 2. ‹⟦⟦(x, τ) ∈ fv B1; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B1) = fv B1 - {(x, τ)} ∪ fv t; ⟦(x, τ) ∈ fv B2; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B2) = fv B2 - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (B1 $ B2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ); (x, τ) ∉ fv B1; (x, τ) ∉ fv B2⟧ ⟹ fv (subst_term [((x, τ), t)] (B1 $ B2)) = fv (B1 $ B2) - {(x, τ)} ∪ fv t› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . qed (simp_all) (*solves the remaining goals: 1. ‹⋀x1 x2. ⟦(x, τ) ∈ fv (Ct x1 x2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Ct x1 x2)) = fv (Ct x1 x2) - {(x, τ)} ∪ fv t› 2. ‹⋀x1 x2. ⟦(x, τ) ∈ fv (Fv x1 x2); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Fv x1 x2)) = fv (Fv x1 x2) - {(x, τ)} ∪ fv t› 3. ‹⋀xa. ⟦(x, τ) ∈ fv (Bv xa); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Bv xa)) = fv (Bv xa) - {(x, τ)} ∪ fv t› 4. ‹⋀x1 B. ⟦⟦(x, τ) ∈ fv B; ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] B) = fv B - {(x, τ)} ∪ fv t; (x, τ) ∈ fv (Abs x1 B); ⋀p. p ∈ fv t ⟹ p ≠ (x, τ)⟧ ⟹ fv (subst_term [((x, τ), t)] (Abs x1 B)) = fv (Abs x1 B) - {(x, τ)} ∪ fv t›*) (* TODO: Get rid of distinctness and non_overlap by performing standard single to parallel substitution construction: Rename variables, then substitute the now non problematic terms TODO: Check assms for useless ones, improve syntax *) lemma inst_vars_pre: assumes wf_theory: "wf_theory Θ" assumes B: "Θ, Γ ⊢ B" (*assumes vars: "set (map fst insts) ⊆ fv B"*) assumes vars_ok: "list_all (term_ok Θ) (map snd insts)" assumes typs_ok: "list_all (λ((idx, ty), t) . typ_of t = Some ty) insts" assumes free: "list_all (λ((idx, ty), t) . (idx, ty) ∉ FV Γ) insts" assumes typ_a: "typ_of a = Some τ" assumes distinct: "distinct (map fst insts)" assumes no_overlap: "⋀x . x ∈ (⋃t ∈ snd ` (set insts) . fv t) ⟹ x ∉ fst ` (set insts)" shows "Θ, Γ ⊢ fold (λsingle. subst_term [single]) insts B" using assms (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term› ‹list_all (term_ok Θ) (map snd insts)› ‹list_all (λ((idx, ty), t). typ_of t = Some ty) insts› ‹list_all (λ((idx, ty), t). (idx, ty) ∉ FV Γ) insts› ‹typ_of a = Some τ› ‹distinct (map fst insts)› ‹?x ∈ ⋃ (fv ` snd ` set insts) ⟹ ?x ∉ fst ` set insts›*) proof (induction insts arbitrary: B) (*goals: 1. ‹⋀B. ⟦wf_theory Θ; Θ,Γ ⊢ B; list_all (term_ok Θ) (map snd []); list_all (λ((idx, ty), t). typ_of t = Some ty) []; list_all (λ((idx, ty), t). (idx, ty) ∉ FV Γ) []; typ_of a = Some τ; distinct (map fst []); ⋀x. x ∈ ⋃ (fv ` snd ` set []) ⟹ x ∉ fst ` set []⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) [] B› 2. ‹⋀aa insts B. ⟦⋀B. ⟦wf_theory Θ; Θ,Γ ⊢ B; list_all (term_ok Θ) (map snd insts); list_all (λ((idx, ty), t). typ_of t = Some ty) insts; list_all (λ((idx, ty), t). (idx, ty) ∉ FV Γ) insts; typ_of a = Some τ; distinct (map fst insts); ⋀x. x ∈ ⋃ (fv ` snd ` set insts) ⟹ x ∉ fst ` set insts⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) insts B; wf_theory Θ; Θ,Γ ⊢ B; list_all (term_ok Θ) (map snd (aa # insts)); list_all (λ((idx, ty), t). typ_of t = Some ty) (aa # insts); list_all (λ((idx, ty), t). (idx, ty) ∉ FV Γ) (aa # insts); typ_of a = Some τ; distinct (map fst (aa # insts)); ⋀x. x ∈ ⋃ (fv ` snd ` set (aa # insts)) ⟹ x ∉ fst ` set (aa # insts)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (aa # insts) B›*) case Nil (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹list_all (term_ok Θ) (map snd [])› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) []› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. (idx, ty) ∉ FV Γ) b) []› ‹typ_of a = Some τ› ‹distinct (map fst [])› ‹?x ∈ ⋃ (fv ` snd ` set []) ⟹ ?x ∉ fst ` set []›*) then show "?case" (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) [] B›*) using B (*‹Θ,Γ ⊢ B›*) by simp next (*goal: ‹⋀aa insts B. ⟦⋀B. ⟦wf_theory Θ; Θ,Γ ⊢ B; list_all (term_ok Θ) (map snd insts); list_all (λ((idx, ty), t). typ_of t = Some ty) insts; list_all (λ((idx, ty), t). (idx, ty) ∉ FV Γ) insts; typ_of a = Some τ; distinct (map fst insts); ⋀x. x ∈ ⋃ (fv ` snd ` set insts) ⟹ x ∉ fst ` set insts⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) insts B; wf_theory Θ; Θ,Γ ⊢ B; list_all (term_ok Θ) (map snd (aa # insts)); list_all (λ((idx, ty), t). typ_of t = Some ty) (aa # insts); list_all (λ((idx, ty), t). (idx, ty) ∉ FV Γ) (aa # insts); typ_of a = Some τ; distinct (map fst (aa # insts)); ⋀x. x ∈ ⋃ (fv ` snd ` set (aa # insts)) ⟹ x ∉ fst ` set (aa # insts)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (aa # insts) B›*) case (Cons x xs) (*‹⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ::Core.term set ⊢ ?B::Core.term; list_all (term_ok Θ) (map snd (xs::((variable × typ) × Core.term) list)); list_all (λa::(variable × typ) × Core.term. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (idx::variable, ty::typ) ⇒ λt::Core.term. typ_of t = Some ty) b) xs; list_all (λa::(variable × typ) × Core.term. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (idx::variable, ty::typ) ⇒ λt::Core.term. (idx, ty) ∉ FV Γ) b) xs; typ_of (a::Core.term) = Some (τ::typ); distinct (map fst xs); ⋀x::variable × typ. x ∈ ⋃ (fv ` snd ` set xs) ⟹ x ∉ fst ` set xs⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) xs ?B› ‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹list_all (term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (map snd ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list)))› ‹list_all (λa::(variable × typ) × Core.term. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (idx::variable, ty::typ) ⇒ λt::Core.term. typ_of t = Some ty) b) ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list))› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. (idx, ty) ∉ FV Γ) b) (x # xs)› ‹typ_of a = Some τ› ‹distinct (map fst (x # xs))› ‹?x ∈ ⋃ (fv ` snd ` set (x # xs)) ⟹ ?x ∉ fst ` set (x # xs)›*) from this (*‹⟦wf_theory Θ; Θ,Γ ⊢ ?B; list_all (term_ok Θ) (map snd xs); list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) xs; list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. (idx, ty) ∉ FV Γ) b) xs; typ_of a = Some τ; distinct (map fst xs); ⋀x. x ∈ ⋃ (fv ` snd ` set xs) ⟹ x ∉ fst ` set xs⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) xs ?B› ‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹Θ,Γ ⊢ B› ‹list_all (term_ok Θ) (map snd (x # xs))› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) (x # xs)› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. (idx, ty) ∉ FV Γ) b) (x # xs)› ‹typ_of a = Some τ› ‹distinct (map fst (x # xs))› ‹(?x::variable × typ) ∈ ⋃ (fv ` snd ` set ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list))) ⟹ ?x ∉ fst ` set (x # xs)›*) obtain idn and ty and t where x: "x = ((idn, ty), t)" (*goal: ‹(⋀(idn::variable) (ty::typ) t::Core.term. (x::(variable × typ) × Core.term) = ((idn, ty), t) ⟹ thesis::bool) ⟹ thesis›*) by (metis prod.collapse (*‹(fst ?prod, snd ?prod) = ?prod›*)) have "Θ, Γ ⊢ fold (λsingle. subst_term [single]) (x # xs) B ⟷ Θ, Γ ⊢ fold (λsingle. subst_term [single]) xs (subst_term [x] B)" by simp moreover have "Θ, Γ ⊢ fold (λsingle. subst_term [single]) xs (subst_term [x] B)" proof (-) (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) xs (subst_term [x] B)›*) have single: "Θ, Γ ⊢ (subst_term [x] B)" using inst_var (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; term_ok ?Θ ?a; typ_of ?a = Some ?τ; (?x, ?τ) ∉ FV ?Γ⟧ ⟹ ?Θ,?Γ ⊢ subst_term [((?x, ?τ), ?a)] ?B›*) Cons (*‹⟦wf_theory Θ; Θ,Γ ⊢ ?B; list_all (term_ok Θ) (map snd xs); list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) xs; list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. (idx, ty) ∉ FV Γ) b) xs; typ_of a = Some τ; distinct (map fst xs); ⋀x. x ∈ ⋃ (fv ` snd ` set xs) ⟹ x ∉ fst ` set xs⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) xs ?B› ‹wf_theory Θ› ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term› ‹list_all (term_ok Θ) (map snd (x # xs))› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) (x # xs)› ‹list_all (λa::(variable × typ) × Core.term. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (idx::variable, ty::typ) ⇒ λt::Core.term. (idx, ty) ∉ FV (Γ::Core.term set)) b) ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list))› ‹typ_of (a::Core.term) = Some (τ::typ)› ‹distinct (map fst (x # xs))› ‹(?x::variable × typ) ∈ ⋃ (fv ` snd ` set ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list))) ⟹ ?x ∉ fst ` set (x # xs)›*) by (simp add: x (*‹x = ((idn, ty), t)›*)) show "?thesis" (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) xs (subst_term [x] B)›*) using Cons (*‹⟦wf_theory Θ; Θ,Γ ⊢ ?B; list_all (term_ok Θ) (map snd xs); list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) xs; list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. (idx, ty) ∉ FV Γ) b) xs; typ_of a = Some τ; distinct (map fst xs); ⋀x. x ∈ ⋃ (fv ` snd ` set xs) ⟹ x ∉ fst ` set xs⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) xs ?B› ‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹list_all (term_ok Θ) (map snd (x # xs))› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idx, ty) ⇒ λt. typ_of t = Some ty) b) (x # xs)› ‹list_all (λa::(variable × typ) × Core.term. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (idx::variable, ty::typ) ⇒ λt::Core.term. (idx, ty) ∉ FV (Γ::Core.term set)) b) ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list))› ‹typ_of a = Some τ› ‹distinct (map fst (x # xs))› ‹?x ∈ ⋃ (fv ` snd ` set (x # xs)) ⟹ ?x ∉ fst ` set (x # xs)›*) single (*‹Θ,Γ ⊢ subst_term [x] B›*) by simp qed ultimately show "?case" (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) ((x::(variable × typ) × Core.term) # (xs::((variable × typ) × Core.term) list)) (B::Core.term)›*) by simp qed (* MOVE *) lemma subterm_term_ok': "is_std_sig Σ ⟹ term_ok' Σ t ⟹ is_closed st ⟹ occs st t ⟹ term_ok' Σ st" proof (induction t arbitrary: st) (*goals: 1. ‹⋀x1 x2 st. ⟦is_std_sig Σ; term_ok' Σ (Ct x1 x2); is_closed st; occs st (Ct x1 x2)⟧ ⟹ term_ok' Σ st› 2. ‹⋀x1 x2 st. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); is_closed st; occs st (Fv x1 x2)⟧ ⟹ term_ok' Σ st› 3. ‹⋀x st. ⟦is_std_sig Σ; term_ok' Σ (Bv x); is_closed st; occs st (Bv x)⟧ ⟹ term_ok' Σ st› 4. ‹⋀x1 t st. ⟦⋀st. ⟦is_std_sig Σ; term_ok' Σ t; is_closed st; occs st t⟧ ⟹ term_ok' Σ st; is_std_sig Σ; term_ok' Σ (Abs x1 t); is_closed st; occs st (Abs x1 t)⟧ ⟹ term_ok' Σ st› 5. ‹⋀t1 t2 st. ⟦⋀st. ⟦is_std_sig Σ; term_ok' Σ t1; is_closed st; occs st t1⟧ ⟹ term_ok' Σ st; ⋀st. ⟦is_std_sig Σ; term_ok' Σ t2; is_closed st; occs st t2⟧ ⟹ term_ok' Σ st; is_std_sig Σ; term_ok' Σ (t1 $ t2); is_closed st; occs st (t1 $ t2)⟧ ⟹ term_ok' Σ st›*) case (Abs T t) (*‹⟦is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); term_ok' Σ (t::Core.term); is_closed (?st::Core.term); occs ?st t⟧ ⟹ term_ok' Σ ?st› ‹is_std_sig Σ› ‹term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Abs (T::typ) (t::Core.term))› ‹is_closed (st::Core.term)› ‹occs st (Abs T t)›*) then show "?case" (*goal: ‹term_ok' Σ st›*) by (auto simp add: is_open_def (*‹is_open ?t ≡ loose_bvar ?t 0›*)) next (*goals: 1. ‹⋀x1 x2 st. ⟦is_std_sig Σ; term_ok' Σ (Ct x1 x2); is_closed st; occs st (Ct x1 x2)⟧ ⟹ term_ok' Σ st› 2. ‹⋀x1 x2 st. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); is_closed st; occs st (Fv x1 x2)⟧ ⟹ term_ok' Σ st› 3. ‹⋀x st. ⟦is_std_sig Σ; term_ok' Σ (Bv x); is_closed st; occs st (Bv x)⟧ ⟹ term_ok' Σ st› 4. ‹⋀t1 t2 st. ⟦⋀st. ⟦is_std_sig Σ; term_ok' Σ t1; is_closed st; occs st t1⟧ ⟹ term_ok' Σ st; ⋀st. ⟦is_std_sig Σ; term_ok' Σ t2; is_closed st; occs st t2⟧ ⟹ term_ok' Σ st; is_std_sig Σ; term_ok' Σ (t1 $ t2); is_closed st; occs st (t1 $ t2)⟧ ⟹ term_ok' Σ st›*) case (App t1 t2) (*‹⟦is_std_sig Σ; term_ok' Σ t1; is_closed ?st; occs ?st t1⟧ ⟹ term_ok' Σ ?st› ‹⟦is_std_sig Σ; term_ok' Σ t2; is_closed ?st; occs ?st t2⟧ ⟹ term_ok' Σ ?st› ‹is_std_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))› ‹term_ok' Σ (t1 $ t2)› ‹is_closed st› ‹occs st (t1 $ t2)›*) then show "?case" (*goal: ‹term_ok' Σ st›*) using term_ok'_occs (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; occs ?u ?t⟧ ⟹ term_ok' ?Σ ?u›*) by blast qed (auto) (*solves the remaining goals: 1. ‹⋀x1 x2 st. ⟦is_std_sig Σ; term_ok' Σ (Ct x1 x2); is_closed st; occs st (Ct x1 x2)⟧ ⟹ term_ok' Σ st› 2. ‹⋀x1 x2 st. ⟦is_std_sig Σ; term_ok' Σ (Fv x1 x2); is_closed st; occs st (Fv x1 x2)⟧ ⟹ term_ok' Σ st› 3. ‹⋀x st. ⟦is_std_sig Σ; term_ok' Σ (Bv x); is_closed st; occs st (Bv x)⟧ ⟹ term_ok' Σ st›*) (* MOVE *) lemma infinite_fv_UNIV: "infinite (UNIV :: (indexname × typ) set)" by (simp add: finite_prod (*‹finite UNIV = (finite UNIV ∧ finite UNIV)›*)) lemma implies_intro'_pre: assumes "wf_theory Θ" "Θ, Γ ⊢ B" "term_ok Θ A" "typ_of A = Some propT" "A ∉ Γ" shows "Θ, Γ ⊢ A ⟼ B" using assms (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹A ∉ Γ›*) proves.implies_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B›*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ (A::Core.term) ⟼ (B::Core.term)›*) by (metis Diff_empty (*‹(?A::?'a set) - {} = ?A›*) Diff_insert0 (*‹(?x::?'a) ∉ (?A::?'a set) ⟹ ?A - insert ?x (?B::?'a set) = ?A - ?B›*)) lemma implies_intro'_pre2: assumes "wf_theory Θ" "Θ, Γ ⊢ B" "term_ok Θ A" "typ_of A = Some propT" "A ∈ Γ" shows "Θ, Γ ⊢ A ⟼ B" proof (-) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ (A::Core.term) ⟼ (B::Core.term)›*) have 1: "Θ, Γ - {A} ⊢ A ⟼ B" using assms (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term› ‹term_ok Θ A› ‹typ_of (A::Core.term) = Some propT› ‹A ∈ Γ›*) proves.implies_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B›*) by (simp add: wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*)) have "Θ, Γ - {A} - {A} ⊢ A ⟼ (A ⟼ B)" using assms (*‹wf_theory Θ› ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹(A::Core.term) ∈ (Γ::Core.term set)›*) proves.implies_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B›*) by (simp add: 1 (*‹Θ,Γ - {A} ⊢ A ⟼ B›*) implies_intro'_pre (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; term_ok ?Θ ?A; typ_of ?A = Some propT; ?A ∉ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A ⟼ ?B›*)) moreover have "Θ, {A} ⊢ A" using proves.assume (*‹⟦wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A›*) assms (*‹wf_theory Θ› ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)› ‹typ_of A = Some propT› ‹A ∈ Γ›*) by (simp add: trivial_pre_depr (*‹⟦term_ok ?Θ ?c; typ_of ?c = Some propT⟧ ⟹ ?Θ,{?c} ⊢ ?c›*)) moreover have "Γ = (Γ - {A} - {A}) ∪ {A}" using assms (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹Θ,Γ ⊢ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹A ∈ Γ›*) by auto ultimately show "?thesis" (*goal: ‹Θ,Γ ⊢ A ⟼ B›*) using proves.implies_elim (*‹⟦?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ₁::Core.term set ⊢ (?A::Core.term) ⟼ (?B::Core.term); ?Θ,?Γ₂::Core.term set ⊢ ?A⟧ ⟹ ?Θ,?Γ₁ ∪ ?Γ₂ ⊢ ?B›*) by metis qed (* Names are suspect, change *) lemma subst_term_preserves_typ_of1[simp]: "typ_of1 Ts (subst_term [((x, τ), Fv y τ)] t) = typ_of1 Ts t" apply (induction Ts t rule: typ_of1.induct (*‹⟦⋀uu_ uv_ T. ?P uu_ (Ct uv_ T); ⋀Ts i. ?P Ts (Bv i); ⋀uw_ ux_ T. ?P uw_ (Fv ux_ T); ⋀Ts T body. ?P (T # Ts) body ⟹ ?P Ts (Abs T body); ⋀Ts t u. ⟦?P Ts u; ⋀a. typ_of1 Ts u = Some a ⟹ ?P Ts t⟧ ⟹ ?P Ts (t $ u)⟧ ⟹ ?P ?a0.0 ?a1.0›*)) (*goals: 1. ‹⋀uu_ uv_ T. typ_of1 uu_ (subst_term [((x, τ), Fv y τ)] (Ct uv_ T)) = typ_of1 uu_ (Ct uv_ T)› 2. ‹⋀Ts i. typ_of1 Ts (subst_term [((x, τ), Fv y τ)] (Bv i)) = typ_of1 Ts (Bv i)› 3. ‹⋀uw_ ux_ T. typ_of1 uw_ (subst_term [((x, τ), Fv y τ)] (Fv ux_ T)) = typ_of1 uw_ (Fv ux_ T)› 4. ‹⋀Ts T body. typ_of1 (T # Ts) (subst_term [((x, τ), Fv y τ)] body) = typ_of1 (T # Ts) body ⟹ typ_of1 Ts (subst_term [((x, τ), Fv y τ)] (Abs T body)) = typ_of1 Ts (Abs T body)› 5. ‹⋀Ts t u. ⟦typ_of1 Ts (subst_term [((x, τ), Fv y τ)] u) = typ_of1 Ts u; ⋀a. typ_of1 Ts u = Some a ⟹ typ_of1 Ts (subst_term [((x, τ), Fv y τ)] t) = typ_of1 Ts t⟧ ⟹ typ_of1 Ts (subst_term [((x, τ), Fv y τ)] (t $ u)) = typ_of1 Ts (t $ u)› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*discuss goal 3*) apply fastforce (*discuss goal 4*) apply fastforce (*discuss goal 5*) apply fastforce (*proven 5 subgoals*) . lemma subst_term_preserves_typ_of[simp]: "typ_of (subst_term [((x, τ), Fv y τ)] t) = typ_of t" using typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) by simp lemma subst_term_preserves_term_ok'[simp]: "term_ok' Σ (subst_term [((x, τ), Fv y τ)] t) ⟷ term_ok' Σ t" apply (induction t) (*goals: 1. ‹⋀(x1::String.literal) x2::typ. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] (Ct x1 x2)) = term_ok' Σ (Ct x1 x2)› 2. ‹⋀(x1::variable) x2::typ. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] (Fv x1 x2)) = term_ok' Σ (Fv x1 x2)› 3. ‹⋀xa::nat. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] (Bv xa)) = term_ok' Σ (Bv xa)› 4. ‹⋀(x1::typ) t::Core.term. term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] t) = term_ok' Σ t ⟹ term_ok' Σ (subst_term [((x, τ), Fv y τ)] (Abs x1 t)) = term_ok' Σ (Abs x1 t)› 5. ‹⋀(t1::Core.term) t2::Core.term. ⟦term_ok' (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] t1) = term_ok' Σ t1; term_ok' Σ (subst_term [((x, τ), Fv y τ)] t2) = term_ok' Σ t2⟧ ⟹ term_ok' Σ (subst_term [((x, τ), Fv y τ)] (t1 $ t2)) = term_ok' Σ (t1 $ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma subst_term_preserves_term_ok[simp]: "term_ok Θ (subst_term [((x, τ), Fv y τ)] A) ⟷ term_ok Θ A" by (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*)) lemma not_in_FV_in_fv_not_in: "(x,τ) ∉ FV Γ ⟹ (x,τ) ∈ fv t ⟹ t ∉ Γ" by auto lemma subst_term_fv: "fv (subst_term [((x, τ), Fv y τ)] t) = (if (x,τ) ∈ fv t then insert (y,τ) else id) (fv t - {(x,τ)})" apply (induction t) (*goals: 1. ‹⋀x1 x2. fv (subst_term [((x, τ), Fv y τ)] (Ct x1 x2)) = (if (x, τ) ∈ fv (Ct x1 x2) then insert (y, τ) else id) (fv (Ct x1 x2) - {(x, τ)})› 2. ‹⋀x1 x2. fv (subst_term [((x, τ), Fv y τ)] (Fv x1 x2)) = (if (x, τ) ∈ fv (Fv x1 x2) then insert (y, τ) else id) (fv (Fv x1 x2) - {(x, τ)})› 3. ‹⋀xa. fv (subst_term [((x, τ), Fv y τ)] (Bv xa)) = (if (x, τ) ∈ fv (Bv xa) then insert (y, τ) else id) (fv (Bv xa) - {(x, τ)})› 4. ‹⋀x1 t. fv (subst_term [((x, τ), Fv y τ)] t) = (if (x, τ) ∈ fv t then insert (y, τ) else id) (fv t - {(x, τ)}) ⟹ fv (subst_term [((x, τ), Fv y τ)] (Abs x1 t)) = (if (x, τ) ∈ fv (Abs x1 t) then insert (y, τ) else id) (fv (Abs x1 t) - {(x, τ)})› 5. ‹⋀t1 t2. ⟦fv (subst_term [((x, τ), Fv y τ)] t1) = (if (x, τ) ∈ fv t1 then insert (y, τ) else id) (fv t1 - {(x, τ)}); fv (subst_term [((x, τ), Fv y τ)] t2) = (if (x, τ) ∈ fv t2 then insert (y, τ) else id) (fv t2 - {(x, τ)})⟧ ⟹ fv (subst_term [((x, τ), Fv y τ)] (t1 $ t2)) = (if (x, τ) ∈ fv (t1 $ t2) then insert (y, τ) else id) (fv (t1 $ t2) - {(x, τ)})› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma rename_free: assumes wf_theory: "wf_theory Θ" assumes B: "Θ, Γ ⊢ B" assumes free: "(x,τ)∉ FV Γ" shows "Θ, Γ ⊢ subst_term [((x, τ), Fv y τ)] B" by (metis B (*‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term›*) free (*‹(x::variable, τ::typ) ∉ FV (Γ::Core.term set)›*) inst_var (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); ?Θ,?Γ::Core.term set ⊢ ?B::Core.term; term_ok ?Θ (?a::Core.term); typ_of ?a = Some (?τ::typ); (?x::variable, ?τ) ∉ FV ?Γ⟧ ⟹ ?Θ,?Γ ⊢ subst_term [((?x, ?τ), ?a)] ?B›*) proved_terms_well_formed( (*‹?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ::Core.term set ⊢ ?p::Core.term ⟹ term_ok ?Θ ?p›*) 2) subst_term_single_no_change (*‹(?x::variable, ?τ::typ) ∉ fv (?B::Core.term) ⟹ subst_term [((?x, ?τ), ?t::Core.term)] ?B = ?B›*) term_ok_vars_typ_ok (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); term_ok ?Θ (?t::Core.term); (?x::variable, ?τ::typ) ∈ fv ?t⟧ ⟹ typ_ok ?Θ ?τ›*) term_ok_var (*‹term_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv (?idn::variable) (?τ::typ)) = typ_ok ?Θ ?τ›*) wf_theory (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)›*) typ_of_var (*‹typ_of (Fv (?idn::variable) (?τ::typ)) = Some ?τ›*)) lemma tvs_subst_term_single[simp]: "tvs (subst_term [((x, τ), Fv y τ)] A) = tvs A" apply (induction A) (*goals: 1. ‹⋀x1 x2. tvs (subst_term [((x, τ), Fv y τ)] (Ct x1 x2)) = tvs (Ct x1 x2)› 2. ‹⋀x1 x2. tvs (subst_term [((x, τ), Fv y τ)] (Fv x1 x2)) = tvs (Fv x1 x2)› 3. ‹⋀xa. tvs (subst_term [((x, τ), Fv y τ)] (Bv xa)) = tvs (Bv xa)› 4. ‹⋀x1 A. tvs (subst_term [((x, τ), Fv y τ)] A) = tvs A ⟹ tvs (subst_term [((x, τ), Fv y τ)] (Abs x1 A)) = tvs (Abs x1 A)› 5. ‹⋀A1 A2. ⟦tvs (subst_term [((x, τ), Fv y τ)] A1) = tvs A1; tvs (subst_term [((x, τ), Fv y τ)] A2) = tvs A2⟧ ⟹ tvs (subst_term [((x, τ), Fv y τ)] (A1 $ A2)) = tvs (A1 $ A2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . (* Conditions are a bit random, clear up *) lemma weaken_proves': "Θ, Γ ⊢ B ⟹ term_ok Θ A ⟹ typ_of A = Some propT ⟹ A ∉ Γ ⟹ finite Γ ⟹ Θ, insert A Γ ⊢ B" proof (induction Γ B arbitrary: A rule: proves.induct) (*goals: 1. ‹⋀(A::Core.term) (ρ::variable ⇒ String.literal set ⇒ typ) (Γ::Core.term set) Aa::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); A ∈ axioms Θ; wf_inst Θ ρ; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ; finite Γ⟧ ⟹ Θ,insert Aa Γ ⊢ tsubst A ρ› 2. ‹⋀(A::Core.term) (Γ::Core.term set) Aa::Core.term. ⟦wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) A; ⊢⇩τ A : propT; A ∈ Γ; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ; finite Γ⟧ ⟹ Θ,insert Aa Γ ⊢ A› 3. ‹⋀(Γ::Core.term set) (B::Core.term) (x::variable) (τ::typ) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ ⊢ B; ⋀A::Core.term. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_all x τ B› 4. ‹⋀(Γ::Core.term set) (τ::typ) (B::Core.term) (a::Core.term) A::Core.term. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⋀A::Core.term. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⊢⇩τ a : τ; wf_term (sig Θ) a; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ subst_bv a B› 5. ‹⋀(Γ::Core.term set) (B::Core.term) (A::Core.term) Aa::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ ⊢ B; ⋀A::Core.term. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; wf_term (sig Θ) A; ⊢⇩τ A : propT; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ - {A}; finite (Γ - {A})⟧ ⟹ Θ,insert Aa (Γ - {A}) ⊢ A ⟼ B› 6. ‹⋀(Γ₁::Core.term set) (A::Core.term) (B::Core.term) (Γ₂::Core.term set) Aa::Core.term. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ₁ ⊢ A ⟼ B; ⋀Aa::Core.term. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert Aa Γ₁ ⊢ A ⟼ B; Θ,Γ₂ ⊢ A; ⋀Aa::Core.term. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert Aa Γ₂ ⊢ A; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁ ∪ Γ₂; finite (Γ₁ ∪ Γ₂)⟧ ⟹ Θ,insert Aa (Γ₁ ∪ Γ₂) ⊢ B› 7. ‹⋀(c::String.literal) (T::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 8. ‹⋀(T::typ) (t::Core.term) (u::Core.term) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 9. ‹⋀(t::Core.term) (τ::typ) (τ'::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv (0::nat))) t›*) case (axiom A insts Γ A') (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹A ∈ axioms Θ› ‹wf_inst Θ insts› ‹term_ok Θ A'› ‹typ_of A' = Some propT› ‹A' ∉ Γ› ‹finite (Γ::Core.term set)›*) then show "?case" (*goal: ‹Θ,insert A' Γ ⊢ tsubst A insts›*) using proves.axiom (*‹⟦wf_theory ?Θ; ?A ∈ axioms ?Θ; wf_inst ?Θ ?ρ⟧ ⟹ ?Θ,?Γ ⊢ tsubst ?A ?ρ›*) axiom (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹A ∈ axioms Θ› ‹wf_inst (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (insts::variable ⇒ String.literal set ⇒ typ)› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A'::Core.term)› ‹typ_of A' = Some propT› ‹A' ∉ Γ› ‹finite Γ›*) by metis next (*goals: 1. ‹⋀A Γ Aa. ⟦wf_term (sig Θ) A; ⊢⇩τ A : propT; A ∈ Γ; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ; finite Γ⟧ ⟹ Θ,insert Aa Γ ⊢ A› 2. ‹⋀Γ B x τ A. ⟦wf_theory Θ; Θ,Γ ⊢ B; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_all x τ B› 3. ‹⋀Γ τ B a A. ⟦Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⊢⇩τ a : τ; wf_term (sig Θ) a; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ subst_bv a B› 4. ‹⋀Γ B A Aa. ⟦wf_theory Θ; Θ,Γ ⊢ B; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; wf_term (sig Θ) A; ⊢⇩τ A : propT; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ - {A}; finite (Γ - {A})⟧ ⟹ Θ,insert Aa (Γ - {A}) ⊢ A ⟼ B› 5. ‹⋀Γ₁ A B Γ₂ Aa. ⟦Θ,Γ₁ ⊢ A ⟼ B; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert Aa Γ₁ ⊢ A ⟼ B; Θ,Γ₂ ⊢ A; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert Aa Γ₂ ⊢ A; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁ ∪ Γ₂; finite (Γ₁ ∪ Γ₂)⟧ ⟹ Θ,insert Aa (Γ₁ ∪ Γ₂) ⊢ B› 6. ‹⋀c T Γ A. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 7. ‹⋀T t u Γ A. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 8. ‹⋀t τ τ' Γ A. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv 0)) t›*) case (assume A Γ A') (*‹wf_term (sig Θ) A› ‹⊢⇩τ (A::Core.term) : propT› ‹A ∈ Γ› ‹term_ok Θ A'› ‹typ_of (A'::Core.term) = Some propT› ‹A' ∉ Γ› ‹finite (Γ::Core.term set)›*) then show "?case" (*goal: ‹Θ,insert A' Γ ⊢ A›*) using proves.intros (*‹⟦wf_theory ?Θ; ?A ∈ axioms ?Θ; wf_inst ?Θ ?ρ⟧ ⟹ ?Θ,?Γ ⊢ tsubst ?A ?ρ› ‹⟦wf_term (sig (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (?A::Core.term); ⊢⇩τ ?A : propT; ?A ∈ (?Γ::Core.term set)⟧ ⟹ ?Θ,?Γ ⊢ ?A› ‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; (?x, ?τ) ∉ FV ?Γ; wf_type (sig ?Θ) ?τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all ?x ?τ ?B› ‹⟦?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ::Core.term set ⊢ Ct STR ''Pure.all'' (((?τ::typ) → propT) → propT) $ Abs ?τ (?B::Core.term); ⊢⇩τ (?a::Core.term) : ?τ; wf_term (sig ?Θ) ?a⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?a ?B› ‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B› ‹⟦?Θ,?Γ₁ ⊢ ?A ⟼ ?B; ?Θ,?Γ₂ ⊢ ?A⟧ ⟹ ?Θ,?Γ₁ ∪ ?Γ₂ ⊢ ?B› ‹⟦wf_theory ?Θ; const_type (sig ?Θ) (const_of_class ?c) = Some (itselfT Core.aT → propT); wf_type (sig ?Θ) ?T; has_sort (osig (sig ?Θ)) ?T (insert ?c full_sort)⟧ ⟹ ?Θ,?Γ ⊢ mk_of_class ?T ?c› ‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wt_term (sig ?Θ) (Abs (?T::typ) (?t::Core.term)); wf_term (sig ?Θ) (?u::Core.term); ⊢⇩τ ?u : ?T⟧ ⟹ ?Θ,?Γ::Core.term set ⊢ mk_eq (Abs ?T ?t $ ?u) (subst_bv ?u ?t)› ‹⟦wf_theory ?Θ; wf_term (sig ?Θ) ?t; ⊢⇩τ ?t : ?τ → ?τ'⟧ ⟹ ?Θ,?Γ ⊢ mk_eq (Abs ?τ (?t $ Bv 0)) ?t›*) by blast next (*goals: 1. ‹⋀(Γ::Core.term set) (B::Core.term) (x::variable) (τ::typ) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ ⊢ B; ⋀A::Core.term. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; (x, τ) ∉ FV Γ; wf_type (sig Θ) τ; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_all x τ B› 2. ‹⋀(Γ::Core.term set) (τ::typ) (B::Core.term) (a::Core.term) A::Core.term. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⋀A::Core.term. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⊢⇩τ a : τ; wf_term (sig Θ) a; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ subst_bv a B› 3. ‹⋀(Γ::Core.term set) (B::Core.term) (A::Core.term) Aa::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); Θ,Γ ⊢ B; ⋀A::Core.term. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; wf_term (sig Θ) A; ⊢⇩τ A : propT; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ - {A}; finite (Γ - {A})⟧ ⟹ Θ,insert Aa (Γ - {A}) ⊢ A ⟼ B› 4. ‹⋀(Γ₁::Core.term set) (A::Core.term) (B::Core.term) (Γ₂::Core.term set) Aa::Core.term. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ₁ ⊢ A ⟼ B; ⋀Aa::Core.term. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert Aa Γ₁ ⊢ A ⟼ B; Θ,Γ₂ ⊢ A; ⋀Aa::Core.term. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert Aa Γ₂ ⊢ A; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁ ∪ Γ₂; finite (Γ₁ ∪ Γ₂)⟧ ⟹ Θ,insert Aa (Γ₁ ∪ Γ₂) ⊢ B› 5. ‹⋀(c::String.literal) (T::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 6. ‹⋀(T::typ) (t::Core.term) (u::Core.term) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 7. ‹⋀(t::Core.term) (τ::typ) (τ'::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv (0::nat))) t›*) case (forall_intro Γ B x τ) (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹Θ,Γ ⊢ B› ‹(x, τ) ∉ FV Γ› ‹wf_type (sig Θ) τ› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)› ‹typ_of A = Some propT› ‹A ∉ Γ› ‹finite Γ›*) have "∃y . y∉fst ` (fv A ∪ fv B ∪ FV Γ)" proof (-) (*goal: ‹∃y::variable. y ∉ fst ` (fv (A::Core.term) ∪ fv (B::Core.term) ∪ FV (Γ::Core.term set))›*) have "finite (FV Γ)" using finite_fv (*‹finite (fv ?t)›*) forall_intro.prems (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)› ‹typ_of A = Some propT› ‹A ∉ Γ› ‹finite Γ›*) by auto hence "finite (fv A ∪ fv B ∪ FV Γ)" by simp hence "finite (fst ` (fv A ∪ fv B ∪ FV Γ))" by simp thus "?thesis" (*goal: ‹∃y::variable. y ∉ fst ` (fv (A::Core.term) ∪ fv (B::Core.term) ∪ FV (Γ::Core.term set))›*) using variant_variable_fresh (*‹finite ?S ⟹ fst (variant_variable ?s ?S) ∉ ?S›*) by blast qed from this (*‹∃y. y ∉ fst ` (fv A ∪ fv B ∪ FV Γ)›*) obtain y where "y∉fst ` (fv A ∪ fv B ∪ FV Γ)" (*goal: ‹(⋀y. y ∉ fst ` (fv A ∪ fv B ∪ FV Γ) ⟹ thesis) ⟹ thesis›*) by auto have not_in_ren: "subst_term [((x, τ), Fv y τ)] A ∉ Γ" proof (cases "(x, τ) ∈ fv A") (*goals: 1. ‹(x, τ) ∈ fv A ⟹ subst_term [((x, τ), Fv y τ)] A ∉ Γ› 2. ‹(x, τ) ∉ fv A ⟹ subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) case True (*‹(x, τ) ∈ fv A›*) show "?thesis" (*goal: ‹subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) apply (rule not_in_FV_in_fv_not_in[of y τ] (*‹⟦(y, τ) ∉ FV ?Γ; (y, τ) ∈ fv ?t⟧ ⟹ ?t ∉ ?Γ›*)) (*goal: ‹subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) apply (metis (full_types) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹y ∉ fst ` (fv A ∪ fv B ∪ FV Γ)› fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) (*top goal: ‹(y, τ) ∉ FV Γ› and 1 goal remains*) using True (*‹(x, τ) ∈ fv A›*) subst_term_fv (*‹fv (subst_term [((?x, ?τ), Fv ?y ?τ)] ?t) = (if (?x, ?τ) ∈ fv ?t then insert (?y, ?τ) else id) (fv ?t - {(?x, ?τ)})›*) by auto next (*goal: ‹(x, τ) ∉ fv A ⟹ subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) case False (*‹(x, τ) ∉ fv A›*) hence "subst_term [((x, τ), Fv y τ)] A = A" by simp then show "?thesis" (*goal: ‹subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) by (simp add: forall_intro.prems( (*‹A ∉ Γ›*) 3)) qed have term_ok_ren: "term_ok Θ (subst_term [((x, τ), Fv y τ)] A)" using forall_intro.prems(1) (*‹term_ok Θ A›*) subst_term_preserves_term_ok (*‹term_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (subst_term [((?x::variable, ?τ::typ), Fv (?y::variable) ?τ)] (?A::Core.term)) = term_ok ?Θ ?A›*) by blast have typ_of_ren: "typ_of (subst_term [((x, τ), Fv y τ)] A) = Some propT" using forall_intro.prems (*‹term_ok Θ A› ‹typ_of A = Some propT› ‹(A::Core.term) ∉ (Γ::Core.term set)› ‹finite Γ›*) by auto hence "Θ, insert (subst_term [((x, τ), Fv y τ)] A) Γ ⊢ B" using forall_intro.IH (*‹⟦term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?A::Core.term); typ_of ?A = Some propT; ?A ∉ (Γ::Core.term set); finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B::Core.term›*) forall_intro.prems(3) (*‹A ∉ Γ›*) forall_intro.prems(4) (*‹finite Γ›*) not_in_ren (*‹subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) term_ok_ren (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] (A::Core.term))›*) typ_of_ren (*‹typ_of (subst_term [((x::variable, τ::typ), Fv (y::variable) τ)] (A::Core.term)) = Some propT›*) by blast have "Θ, insert (subst_term [((x, τ), Fv y τ)] A) Γ ⊢ mk_all x τ B" apply (rule proves.forall_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; (?x, ?τ) ∉ FV ?Γ; wf_type (sig ?Θ) ?τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all ?x ?τ ?B›*)) (*goal: ‹Θ,insert (subst_term [((x, τ), Fv y τ)] A) Γ ⊢ mk_all x τ B›*) apply (simp add: forall_intro.hyps( (*‹wf_theory Θ›*) 1)) (*top goal: ‹wf_theory Θ› and 3 goals remain*) using ‹Θ, insert (subst_term [((x, τ), Fv y τ)] A) Γ ⊢ B› (*‹Θ,insert (subst_term [((x, τ), Fv y τ)] A) Γ ⊢ B›*) apply blast (*top goal: ‹Θ,insert (subst_term [((x, τ), Fv y τ)] A) Γ ⊢ B› and 2 goals remain*) subgoal for using subst_term_fv (*‹fv (subst_term [((?x, ?τ), Fv ?y ?τ)] ?t) = (if (?x, ?τ) ∈ fv ?t then insert (?y, ?τ) else id) (fv ?t - {(?x, ?τ)})›*) ‹(x, τ) ∉ FV Γ› (*‹(x, τ) ∉ FV Γ›*) apply simp (*goal: ‹(x, τ) ∉ FV (insert (subst_term [((x, τ), Fv y τ)] A) Γ)›*) by (metis Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹y ∉ fst ` (fv A ∪ fv B ∪ FV Γ)› fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) using forall_intro.hyps(4) (*‹wf_type (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (τ::typ)›*) by blast hence "Θ, Γ ⊢ subst_term [((x, τ), Fv y τ)] A ⟼ mk_all x τ B" using forall_intro.hyps(1) (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)›*) forall_intro.hyps(2) (*‹Θ,Γ ⊢ B›*) forall_intro.hyps(4) (*‹wf_type (sig Θ) τ›*) forall_intro.prems(1) (*‹term_ok Θ A›*) forall_intro.prems(3) (*‹A ∉ Γ›*) implies_intro'_pre (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; term_ok ?Θ ?A; typ_of ?A = Some propT; ?A ∉ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A ⟼ ?B›*) local.forall_intro (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹(x, τ) ∉ FV Γ› ‹wf_type (sig Θ) τ› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹(A::Core.term) ∉ (Γ::Core.term set)› ‹finite Γ›*) not_in_ren (*‹subst_term [((x, τ), Fv y τ)] A ∉ Γ›*) proves.forall_intro (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); ?Θ,?Γ::Core.term set ⊢ ?B::Core.term; (?x::variable, ?τ::typ) ∉ FV ?Γ; wf_type (sig ?Θ) ?τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all ?x ?τ ?B›*) subst_term_preserves_typ_of (*‹typ_of (subst_term [((?x, ?τ), Fv ?y ?τ)] ?t) = typ_of ?t›*) term_ok_ren (*‹term_ok Θ (subst_term [((x, τ), Fv y τ)] A)›*) by auto hence "Θ, Γ ⊢ subst_term [((y, τ), Fv x τ)] (subst_term [((x, τ), Fv y τ)] A ⟼ mk_all x τ B)" by (smt Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) ‹y ∉ fst ` (fv A ∪ fv B ∪ FV Γ)› forall_intro.hyps( (*‹wf_theory Θ›*) 1) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*) rename_free (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; (?x, ?τ) ∉ FV ?Γ⟧ ⟹ ?Θ,?Γ ⊢ subst_term [((?x, ?τ), Fv ?y ?τ)] ?B›*)) hence "Θ, Γ ⊢ A ⟼ mk_all x τ B" using forall_intro (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹(x::variable, τ::typ) ∉ FV (Γ::Core.term set)› ‹wf_type (sig Θ) τ› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹A ∉ Γ› ‹finite Γ›*) proves.forall_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; (?x, ?τ) ∉ FV ?Γ; wf_type (sig ?Θ) ?τ⟧ ⟹ ?Θ,?Γ ⊢ mk_all ?x ?τ ?B›*) implies_intro'_pre (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; term_ok ?Θ ?A; typ_of ?A = Some propT; ?A ∉ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A ⟼ ?B›*) by auto moreover have "Θ, {A} ⊢ A" using forall_intro.prems(1) (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)›*) local.forall_intro(7) (*‹typ_of (A::Core.term) = Some propT›*) trivial_pre_depr (*‹⟦term_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?c::Core.term); typ_of ?c = Some propT⟧ ⟹ ?Θ,{?c} ⊢ ?c›*) by blast ultimately show "?case" (*goal: ‹Θ,insert A Γ ⊢ mk_all x τ B›*) using implies_elim (*‹⟦?Θ,?Γ₁ ⊢ ?A ⟼ ?B; ?Θ,?Γ₂ ⊢ ?A⟧ ⟹ ?Θ,?Γ₁ ∪ ?Γ₂ ⊢ ?B›*) by fastforce next (*goals: 1. ‹⋀Γ τ B a A. ⟦Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B; ⊢⇩τ a : τ; wf_term (sig Θ) a; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ subst_bv a B› 2. ‹⋀Γ B A Aa. ⟦wf_theory Θ; Θ,Γ ⊢ B; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; wf_term (sig Θ) A; ⊢⇩τ A : propT; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ - {A}; finite (Γ - {A})⟧ ⟹ Θ,insert Aa (Γ - {A}) ⊢ A ⟼ B› 3. ‹⋀Γ₁ A B Γ₂ Aa. ⟦Θ,Γ₁ ⊢ A ⟼ B; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert Aa Γ₁ ⊢ A ⟼ B; Θ,Γ₂ ⊢ A; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert Aa Γ₂ ⊢ A; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁ ∪ Γ₂; finite (Γ₁ ∪ Γ₂)⟧ ⟹ Θ,insert Aa (Γ₁ ∪ Γ₂) ⊢ B› 4. ‹⋀c T Γ A. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 5. ‹⋀T t u Γ A. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 6. ‹⋀t τ τ' Γ A. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv 0)) t›*) case (forall_elim Γ τ B a) (*‹Θ,Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B› ‹⊢⇩τ a : τ› ‹wf_term (sig Θ) a› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ Ct STR ''Pure.all'' ((τ → propT) → propT) $ Abs τ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹A ∉ Γ› ‹finite Γ›*) then show "?case" (*goal: ‹Θ,insert A Γ ⊢ subst_bv a B›*) using proves.forall_elim (*‹⟦?Θ,?Γ ⊢ Ct STR ''Pure.all'' ((?τ → propT) → propT) $ Abs ?τ ?B; ⊢⇩τ ?a : ?τ; wf_term (sig ?Θ) ?a⟧ ⟹ ?Θ,?Γ ⊢ subst_bv ?a ?B›*) by blast next (*goals: 1. ‹⋀Γ B A Aa. ⟦wf_theory Θ; Θ,Γ ⊢ B; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; wf_term (sig Θ) A; ⊢⇩τ A : propT; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ - {A}; finite (Γ - {A})⟧ ⟹ Θ,insert Aa (Γ - {A}) ⊢ A ⟼ B› 2. ‹⋀Γ₁ A B Γ₂ Aa. ⟦Θ,Γ₁ ⊢ A ⟼ B; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert Aa Γ₁ ⊢ A ⟼ B; Θ,Γ₂ ⊢ A; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert Aa Γ₂ ⊢ A; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁ ∪ Γ₂; finite (Γ₁ ∪ Γ₂)⟧ ⟹ Θ,insert Aa (Γ₁ ∪ Γ₂) ⊢ B› 3. ‹⋀c T Γ A. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 4. ‹⋀T t u Γ A. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 5. ‹⋀t τ τ' Γ A. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv 0)) t›*) case (implies_intro Γ B N) (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (N::Core.term)› ‹⊢⇩τ N : propT› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹(A::Core.term) ∉ (Γ::Core.term set) - {N::Core.term}› ‹finite (Γ - {N})›*) then show "?case" (*goal: ‹Θ,insert A (Γ - {N}) ⊢ N ⟼ B›*) proof (cases "A=N") (*goals: 1. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; term_ok Θ A; typ_of A = Some propT; A ∉ Γ - {N}; finite (Γ - {N}); A = N⟧ ⟹ Θ,insert A (Γ - {N}) ⊢ N ⟼ B› 2. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; term_ok Θ A; typ_of A = Some propT; A ∉ Γ - {N}; finite (Γ - {N}); A ≠ N⟧ ⟹ Θ,insert A (Γ - {N}) ⊢ N ⟼ B›*) case True (*‹(A::Core.term) = (N::Core.term)›*) hence "Θ,Γ - {N} ⊢ N ⟼ B" using implies_intro.hyps(1) (*‹wf_theory Θ›*) implies_intro.hyps(2) (*‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term›*) implies_intro.hyps(3) (*‹wf_term (sig Θ) N›*) implies_intro.hyps(4) (*‹⊢⇩τ N : propT›*) proves.implies_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B›*) by blast hence "Θ,Γ - {N} ⊢ A ⟼ N ⟼ B" using True (*‹A = N›*) implies_intro'_pre (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); ?Θ,?Γ::Core.term set ⊢ ?B::Core.term; term_ok ?Θ (?A::Core.term); typ_of ?A = Some propT; ?A ∉ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A ⟼ ?B›*) implies_intro.hyps(1) (*‹wf_theory Θ›*) implies_intro.hyps(3) (*‹wf_term (sig Θ) N›*) implies_intro.hyps(4) (*‹⊢⇩τ N : propT›*) implies_intro.prems(1) (*‹term_ok Θ A›*) by blast hence "Θ,insert N Γ ⊢ B" using True (*‹A = N›*) implies_elim (*‹⟦?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,?Γ₁::Core.term set ⊢ (?A::Core.term) ⟼ (?B::Core.term); ?Θ,?Γ₂::Core.term set ⊢ ?A⟧ ⟹ ?Θ,?Γ₁ ∪ ?Γ₂ ⊢ ?B›*) implies_intro (*‹wf_theory Θ› ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ B::Core.term› ‹wf_term (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) (N::Core.term)› ‹⊢⇩τ N : propT› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B› ‹term_ok Θ A› ‹typ_of A = Some propT› ‹A ∉ Γ - {N}› ‹finite (Γ - {N})›*) insert_absorb (*‹(?a::?'a) ∈ (?A::?'a set) ⟹ insert ?a ?A = ?A›*) by fastforce then show "?thesis" (*goal: ‹Θ,insert A (Γ - {N}) ⊢ N ⟼ B›*) using True (*‹A = N›*) implies_elim (*‹⟦?Θ,?Γ₁ ⊢ ?A ⟼ ?B; ?Θ,?Γ₂ ⊢ ?A⟧ ⟹ ?Θ,?Γ₁ ∪ ?Γ₂ ⊢ ?B›*) implies_intro.hyps(3) (*‹wf_term (sig Θ) N›*) implies_intro.hyps(4) (*‹⊢⇩τ N : propT›*) implies_intro.prems(1) (*‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)›*) trivial_pre_depr (*‹⟦term_ok ?Θ ?c; typ_of ?c = Some propT⟧ ⟹ ?Θ,{?c} ⊢ ?c›*) by (simp add: implies_intro'_pre2 (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; term_ok ?Θ ?A; typ_of ?A = Some propT; ?A ∈ ?Γ⟧ ⟹ ?Θ,?Γ ⊢ ?A ⟼ ?B›*) implies_intro.hyps( (*‹wf_theory Θ›*) 1)) next (*goal: ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; ⋀A. ⟦term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ B; term_ok Θ A; typ_of A = Some propT; A ∉ Γ - {N}; finite (Γ - {N}); A ≠ N⟧ ⟹ Θ,insert A (Γ - {N}) ⊢ N ⟼ B›*) case False (*‹A ≠ N›*) hence s: "insert A (Γ - {N}) = insert A Γ - {N}" by auto have I: "Θ,insert A Γ ⊢ B" using implies_intro.prems (*‹term_ok Θ A› ‹typ_of A = Some propT› ‹(A::Core.term) ∉ (Γ::Core.term set) - {N::Core.term}› ‹finite (Γ - {N})›*) False (*‹A ≠ N›*) by (auto intro!: implies_intro.IH (*‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ; finite Γ⟧ ⟹ Θ,insert ?A Γ ⊢ B›*)) show "?thesis" (*goal: ‹Θ,insert A (Γ - {N}) ⊢ N ⟼ B›*) apply (subst s (*‹insert A (Γ - {N}) = insert A Γ - {N}›*)) (*goal: ‹Θ,insert A (Γ - {N}) ⊢ N ⟼ B›*) apply (rule proves.implies_intro (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; wf_term (sig ?Θ) ?A; ⊢⇩τ ?A : propT⟧ ⟹ ?Θ,?Γ - {?A} ⊢ ?A ⟼ ?B›*)) (*goal: ‹Θ,insert A Γ - {N} ⊢ N ⟼ B›*) using implies_intro.hyps (*‹wf_theory Θ› ‹Θ,Γ ⊢ B› ‹wf_term (sig Θ) N› ‹⊢⇩τ N : propT›*) I (*‹Θ,insert A Γ ⊢ B›*) apply - (*goals: 1. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; Θ,insert A Γ ⊢ B⟧ ⟹ wf_theory Θ› 2. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; Θ,insert A Γ ⊢ B⟧ ⟹ Θ,insert A Γ ⊢ B› 3. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; Θ,insert A Γ ⊢ B⟧ ⟹ wf_term (sig Θ) N› 4. ‹⟦wf_theory Θ; Θ,Γ ⊢ B; wf_term (sig Θ) N; ⊢⇩τ N : propT; Θ,insert A Γ ⊢ B⟧ ⟹ ⊢⇩τ N : propT› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed next (*goals: 1. ‹⋀Γ₁ A B Γ₂ Aa. ⟦Θ,Γ₁ ⊢ A ⟼ B; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert Aa Γ₁ ⊢ A ⟼ B; Θ,Γ₂ ⊢ A; ⋀Aa. ⟦term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert Aa Γ₂ ⊢ A; term_ok Θ Aa; typ_of Aa = Some propT; Aa ∉ Γ₁ ∪ Γ₂; finite (Γ₁ ∪ Γ₂)⟧ ⟹ Θ,insert Aa (Γ₁ ∪ Γ₂) ⊢ B› 2. ‹⋀c T Γ A. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 3. ‹⋀T t u Γ A. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 4. ‹⋀t τ τ' Γ A. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv 0)) t›*) case (implies_elim Γ₁ A' B Γ₂) (*‹Θ,Γ₁ ⊢ A' ⟼ B› ‹Θ,Γ₂ ⊢ A'› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert ?A Γ₁ ⊢ A' ⟼ B› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ₂; finite Γ₂⟧ ⟹ Θ,insert ?A Γ₂ ⊢ A'› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)› ‹typ_of A = Some propT› ‹A ∉ Γ₁ ∪ Γ₂› ‹finite (Γ₁ ∪ Γ₂)›*) show "?case" (*goal: ‹Θ,insert A (Γ₁ ∪ Γ₂) ⊢ B›*) using proves.implies_elim (*‹⟦?Θ,?Γ₁ ⊢ ?A ⟼ ?B; ?Θ,?Γ₂ ⊢ ?A⟧ ⟹ ?Θ,?Γ₁ ∪ ?Γ₂ ⊢ ?B›*) implies_elim (*‹Θ,Γ₁ ⊢ A' ⟼ B› ‹Θ,Γ₂ ⊢ A'› ‹⟦term_ok Θ ?A; typ_of ?A = Some propT; ?A ∉ Γ₁; finite Γ₁⟧ ⟹ Θ,insert ?A Γ₁ ⊢ A' ⟼ B› ‹⟦term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?A::Core.term); typ_of ?A = Some propT; ?A ∉ (Γ₂::Core.term set); finite Γ₂⟧ ⟹ Θ,insert ?A Γ₂ ⊢ A'::Core.term› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (A::Core.term)› ‹typ_of A = Some propT› ‹A ∉ Γ₁ ∪ Γ₂› ‹finite (Γ₁ ∪ Γ₂)›*) by (metis UnCI (*‹(?c ∉ ?B ⟹ ?c ∈ ?A) ⟹ ?c ∈ ?A ∪ ?B›*) Un_insert_left (*‹insert ?a ?B ∪ ?C = insert ?a (?B ∪ ?C)›*) finite_Un (*‹finite (?F ∪ ?G) = (finite ?F ∧ finite ?G)›*)) next (*goals: 1. ‹⋀c T Γ A. ⟦wf_theory Θ; const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 2. ‹⋀T t u Γ A. ⟦wf_theory Θ; wt_term (sig Θ) (Abs T t); wf_term (sig Θ) u; ⊢⇩τ u : T; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs T t $ u) (subst_bv u t)› 3. ‹⋀t τ τ' Γ A. ⟦wf_theory Θ; wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv 0)) t›*) case (β_conversion Γ s T t x) (*‹wf_theory Θ› ‹wt_term (sig Θ) (Abs Γ s)› ‹wf_term (sig Θ) T› ‹⊢⇩τ T : Γ› ‹term_ok Θ x› ‹typ_of x = Some propT› ‹x ∉ t› ‹finite t›*) then show "?case" (*goal: ‹Θ,insert x t ⊢ mk_eq (Abs Γ s $ T) (subst_bv T s)›*) using "proves.β_conversion" (*‹⟦wf_theory ?Θ; wt_term (sig ?Θ) (Abs ?T ?t); wf_term (sig ?Θ) ?u; ⊢⇩τ ?u : ?T⟧ ⟹ ?Θ,?Γ ⊢ mk_eq (Abs ?T ?t $ ?u) (subst_bv ?u ?t)›*) by blast next (*goals: 1. ‹⋀(c::String.literal) (T::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c› 2. ‹⋀(t::Core.term) (τ::typ) (τ'::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); wf_term (sig Θ) t; ⊢⇩τ t : τ → τ'; term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_eq (Abs τ (t $ Bv (0::nat))) t›*) case (eta t τ τ') (*‹wf_theory Θ› ‹wf_term (sig Θ) t› ‹⊢⇩τ t : τ → τ'› ‹term_ok Θ A› ‹typ_of (A::Core.term) = Some propT› ‹A ∉ Γ_› ‹finite Γ_›*) then show "?case" (*goal: ‹Θ,insert A Γ_ ⊢ mk_eq (Abs τ (t $ Bv 0)) t›*) using proves.eta (*‹⟦wf_theory ?Θ; wf_term (sig ?Θ) ?t; ⊢⇩τ ?t : ?τ → ?τ'⟧ ⟹ ?Θ,?Γ ⊢ mk_eq (Abs ?τ (?t $ Bv 0)) ?t›*) by simp next (*goal: ‹⋀(c::String.literal) (T::typ) (Γ::Core.term set) A::Core.term. ⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT); wf_type (sig Θ) T; has_sort (osig (sig Θ)) T (insert c full_sort); term_ok Θ A; typ_of A = Some propT; A ∉ Γ; finite Γ⟧ ⟹ Θ,insert A Γ ⊢ mk_of_class T c›*) case (of_class c T' T Γ) (*‹wf_theory Θ› ‹const_type (sig Θ) (const_of_class c) = Some (itselfT Core.aT → propT)› ‹wf_type (sig Θ) T'› ‹has_sort (osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set))) (T'::typ) (insert (c::String.literal) full_sort)› ‹term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Γ::Core.term)› ‹typ_of Γ = Some propT› ‹Γ ∉ T› ‹finite T›*) then show "?case" (*goal: ‹Θ,insert Γ T ⊢ mk_of_class T' c›*) by (simp add: proves.of_class (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); const_type (sig ?Θ) (const_of_class (?c::String.literal)) = Some (itselfT Core.aT → propT); wf_type (sig ?Θ) (?T::typ); has_sort (osig (sig ?Θ)) ?T (insert ?c full_sort)⟧ ⟹ ?Θ,?Γ::Core.term set ⊢ mk_of_class ?T ?c›*)) qed corollary weaken_proves: "Θ, Γ ⊢ B ⟹ term_ok Θ A ⟹ typ_of A = Some propT ⟹ finite Γ ⟹ Θ, insert A Γ ⊢ B" using weaken_proves' (*‹⟦?Θ,?Γ ⊢ ?B; term_ok ?Θ ?A; typ_of ?A = Some propT; ?A ∉ ?Γ; finite ?Γ⟧ ⟹ ?Θ,insert ?A ?Γ ⊢ ?B›*) by (metis insert_absorb (*‹?a ∈ ?A ⟹ insert ?a ?A = ?A›*)) lemma weaken_proves_set: "finite Γ2 ⟹ Θ, Γ ⊢ B ⟹ ∀A∈Γ2 . term_ok Θ A ⟹ ∀A∈Γ2 . typ_of A = Some propT ⟹ finite Γ ⟹ Θ, Γ ∪ Γ2 ⊢ B" apply (induction Γ2 arbitrary: Γ rule: finite_induct) (*goals: 1. ‹⋀Γ::Core.term set. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ ⊢ B::Core.term; Ball {} (term_ok Θ); ∀A::Core.term∈{}. typ_of A = Some propT; finite Γ⟧ ⟹ Θ,Γ ∪ {} ⊢ B› 2. ‹⋀(x::Core.term) (F::Core.term set) Γ::Core.term set. ⟦finite F; x ∉ F; ⋀Γ::Core.term set. ⟦Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ ⊢ B::Core.term; Ball F (term_ok Θ); ∀A::Core.term∈F. typ_of A = Some propT; finite Γ⟧ ⟹ Θ,Γ ∪ F ⊢ B; Θ,Γ ⊢ B; Ball (insert x F) (term_ok Θ); ∀A::Core.term∈insert x F. typ_of A = Some propT; finite Γ⟧ ⟹ Θ,Γ ∪ insert x F ⊢ B› discuss goal 1*) apply ((use weaken_proves in auto)[1]) (*discuss goal 2*) apply ((use weaken_proves in auto)[1]) (*proven 2 subgoals*) . (* Maybe do directly instead *) lemma no_tvsT_imp_subst_typ_unchanged: "tvsT T = empty ⟹ subst_typ insts T = T" by (simp add: no_tvsT_imp_tsubsT_unchanged (*‹tvsT ?T = {} ⟹ tsubstT ?T ?ρ = ?T›*) tsubstT_simulates_subst_typ (*‹subst_typ ?insts ?T = tsubstT ?T (λidn S. the_default (Tv idn S) (lookup (λx. x = (idn, S)) ?insts))›*)) lemma subst_typ_fv: shows "apsnd (subst_typ insts) ` fv B = fv (subst_typ' insts B)" apply (induction B) (*goals: 1. ‹⋀x1 x2. apsnd (subst_typ insts) ` fv (Ct x1 x2) = fv (subst_typ' insts (Ct x1 x2))› 2. ‹⋀x1 x2. apsnd (subst_typ insts) ` fv (Fv x1 x2) = fv (subst_typ' insts (Fv x1 x2))› 3. ‹⋀x. apsnd (subst_typ insts) ` fv (Bv x) = fv (subst_typ' insts (Bv x))› 4. ‹⋀x1 B. apsnd (subst_typ insts) ` fv B = fv (subst_typ' insts B) ⟹ apsnd (subst_typ insts) ` fv (Abs x1 B) = fv (subst_typ' insts (Abs x1 B))› 5. ‹⋀B1 B2. ⟦apsnd (subst_typ insts) ` fv B1 = fv (subst_typ' insts B1); apsnd (subst_typ insts) ` fv B2 = fv (subst_typ' insts B2)⟧ ⟹ apsnd (subst_typ insts) ` fv (B1 $ B2) = fv (subst_typ' insts (B1 $ B2))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma subst_typ_fv_point: assumes "(x, τ) ∈ fv B" shows "(x, subst_typ insts τ) ∈ fv (subst_typ' insts B)" using subst_typ_fv (*‹apsnd (subst_typ ?insts) ` fv ?B = fv (subst_typ' ?insts ?B)›*) by (metis apsnd_conv (*‹apsnd (?f::?'c ⇒ ?'b) (?x::?'a, ?y::?'c) = (?x, ?f ?y)›*) assms (*‹(x::variable, τ::typ) ∈ fv (B::Core.term)›*) image_eqI (*‹⟦(?b::?'a) = (?f::?'b ⇒ ?'a) (?x::?'b); ?x ∈ (?A::?'b set)⟧ ⟹ ?b ∈ ?f ` ?A›*)) lemma subst_typ_typ_ok: assumes "typ_ok_sig Σ τ" assumes "list_all (typ_ok_sig Σ) (map snd insts)" shows "typ_ok_sig Σ (subst_typ insts τ)" using assms (*‹typ_ok_sig Σ τ› ‹list_all (typ_ok_sig Σ) (map snd insts)›*) proof (induction τ) (*goals: 1. ‹⋀(x1::String.literal) x2::typ list. ⟦⋀x2a::typ. ⟦x2a ∈ set x2; typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) x2a; list_all (typ_ok_sig Σ) (map snd (insts::((variable × String.literal set) × typ) list))⟧ ⟹ typ_ok_sig Σ (subst_typ insts x2a); typ_ok_sig Σ (Ty x1 x2); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Ty x1 x2))› 2. ‹⋀(x1::variable) x2::String.literal set. ⟦typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Tv x1 x2); list_all (typ_ok_sig Σ) (map snd (insts::((variable × String.literal set) × typ) list))⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Tv x1 x2))›*) case (Tv idn τ) (*‹typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Tv (idn::variable) (τ::String.literal set))› ‹list_all (typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option))) (map snd (insts::((variable × String.literal set) × typ) list))›*) then show "?case" (*goal: ‹typ_ok_sig Σ (subst_typ insts (Tv idn τ))›*) apply (cases "lookup (λx. x = (idn, τ)) insts") (*goals: 1. ‹⟦typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Tv (idn::variable) (τ::String.literal set)); list_all (typ_ok_sig Σ) (map snd (insts::((variable × String.literal set) × typ) list)); lookup (λx::variable × String.literal set. x = (idn, τ)) insts = None⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Tv idn τ))› 2. ‹⋀a::typ. ⟦typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Tv (idn::variable) (τ::String.literal set)); list_all (typ_ok_sig Σ) (map snd (insts::((variable × String.literal set) × typ) list)); lookup (λx::variable × String.literal set. x = (idn, τ)) insts = Some a⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Tv idn τ))› discuss goal 1*) apply (fastforce simp add: list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*) dest: lookup_present_eq_key' (*‹lookup (λx. x = ?k) ?al = Some ?v ⟹ (?k, ?v) ∈ set ?al›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*discuss goal 2*) apply (fastforce simp add: list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*) dest: lookup_present_eq_key' (*‹lookup (λx. x = ?k) ?al = Some ?v ⟹ (?k, ?v) ∈ set ?al›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*proven 2 subgoals*) . qed (auto simp add: list_all_iff (*‹list_all ?P ?x = Ball (set ?x) ?P›*) lookup_present_eq_key' (*‹lookup (λx. x = ?k) ?al = Some ?v ⟹ (?k, ?v) ∈ set ?al›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) (*solved the remaining goal: ‹⋀(x1::String.literal) x2::typ list. ⟦⋀x2a::typ. ⟦x2a ∈ set x2; typ_ok_sig (Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) x2a; list_all (typ_ok_sig Σ) (map snd (insts::((variable × String.literal set) × typ) list))⟧ ⟹ typ_ok_sig Σ (subst_typ insts x2a); typ_ok_sig Σ (Ty x1 x2); list_all (typ_ok_sig Σ) (map snd insts)⟧ ⟹ typ_ok_sig Σ (subst_typ insts (Ty x1 x2))›*) lemma subst_typ_comp_single_left: "subst_typ [single] (subst_typ insts T) = subst_typ (map (apsnd (subst_typ [single])) insts@[single]) T" proof (induction T) (*goals: 1. ‹⋀x1 x2. (⋀x2a. x2a ∈ set x2 ⟹ subst_typ [single] (subst_typ insts x2a) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) x2a) ⟹ subst_typ [single] (subst_typ insts (Ty x1 x2)) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) (Ty x1 x2)› 2. ‹⋀x1 x2. subst_typ [single] (subst_typ insts (Tv x1 x2)) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) (Tv x1 x2)›*) case (Tv idn ty) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹subst_typ [single] (subst_typ insts (Tv idn ty)) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) (Tv idn ty)›*) apply (induction insts) (*goals: 1. ‹subst_typ [single::(variable × String.literal set) × typ] (subst_typ [] (Tv (idn::variable) (ty::String.literal set))) = subst_typ (map (apsnd (subst_typ [single])) [] @ [single]) (Tv idn ty)› 2. ‹⋀(a::(variable × String.literal set) × typ) insts::((variable × String.literal set) × typ) list. subst_typ [single::(variable × String.literal set) × typ] (subst_typ insts (Tv (idn::variable) (ty::String.literal set))) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) (Tv idn ty) ⟹ subst_typ [single] (subst_typ (a # insts) (Tv idn ty)) = subst_typ (map (apsnd (subst_typ [single])) (a # insts) @ [single]) (Tv idn ty)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (auto) (*solved the remaining goal: ‹⋀(x1::String.literal) x2::typ list. (⋀x2a::typ. x2a ∈ set x2 ⟹ subst_typ [single::(variable × String.literal set) × typ] (subst_typ (insts::((variable × String.literal set) × typ) list) x2a) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) x2a) ⟹ subst_typ [single] (subst_typ insts (Ty x1 x2)) = subst_typ (map (apsnd (subst_typ [single])) insts @ [single]) (Ty x1 x2)›*) lemma subst_typ_comp_single_left_stronger: "subst_typ [single] (subst_typ insts T) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) T" proof (induction T) (*goals: 1. ‹⋀(x1::String.literal) x2::typ list. (⋀x2a::typ. x2a ∈ set x2 ⟹ subst_typ [single::(variable × String.literal set) × typ] (subst_typ (insts::((variable × String.literal set) × typ) list) x2a) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) x2a) ⟹ subst_typ [single] (subst_typ insts (Ty x1 x2)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Ty x1 x2)› 2. ‹⋀(x1::variable) x2::String.literal set. subst_typ [single::(variable × String.literal set) × typ] (subst_typ (insts::((variable × String.literal set) × typ) list) (Tv x1 x2)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv x1 x2)›*) case (Tv idn S) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) proof (cases "lookup (λx. x = (idn,S)) insts") (*goals: 1. ‹lookup (λx. x = (idn, S)) insts = None ⟹ subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)› 2. ‹⋀a. lookup (λx. x = (idn, S)) insts = Some a ⟹ subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) case None (*‹lookup (λx. x = (idn, S)) insts = None›*) hence "lookup (λx. x = (idn, S)) (map (apsnd (subst_typ [single])) insts) = None" apply (induction insts) (*goals: 1. ‹lookup (λx::variable × String.literal set. x = (idn::variable, S::String.literal set)) [] = None ⟹ lookup (λx::variable × String.literal set. x = (idn, S)) (map (apsnd (subst_typ [single::(variable × String.literal set) × typ])) []) = None› 2. ‹⋀(a::(variable × String.literal set) × typ) insts::((variable × String.literal set) × typ) list. ⟦lookup (λx::variable × String.literal set. x = (idn::variable, S::String.literal set)) insts = None ⟹ lookup (λx::variable × String.literal set. x = (idn, S)) (map (apsnd (subst_typ [single::(variable × String.literal set) × typ])) insts) = None; lookup (λx::variable × String.literal set. x = (idn, S)) (a # insts) = None⟧ ⟹ lookup (λx::variable × String.literal set. x = (idn, S)) (map (apsnd (subst_typ [single])) (a # insts)) = None› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹subst_typ [single::(variable × String.literal set) × typ] (subst_typ (insts::((variable × String.literal set) × typ) list) (Tv (idn::variable) (S::String.literal set))) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) using None (*‹lookup (λx::variable × String.literal set. x = (idn::variable, S::String.literal set)) (insts::((variable × String.literal set) × typ) list) = None›*) apply simp (*goal: ‹subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) by (metis eq_fst_iff (*‹(?a = fst ?p) = (∃b. ?p = (?a, b))›*) list.set_map (*‹set (map ?f ?v) = ?f ` set ?v›*) lookup.simps( (*‹lookup ?f ((?x, ?y) # ?xs) = (if ?f ?x then Some ?y else lookup ?f ?xs)›*) 2) lookup_None_iff (*‹(lookup ?P ?xs = None) = (∄x. x ∈ set (map fst ?xs) ∧ ?P x)›*) subst_typ.simps( (*‹subst_typ ?insts (Tv ?idn ?S) = the_default (Tv ?idn ?S) (lookup (λx. x = (?idn, ?S)) ?insts)›*) 2) subst_typ_comp (*‹subst_typ ?inst1.0 (subst_typ ?inst2.0 ?T) = subst_typ (map (apsnd (subst_typ ?inst1.0)) ?inst2.0 @ ?inst1.0) ?T›*) subst_typ_nil (*‹subst_typ [] ?T = ?T›*) the_default.simps( (*‹the_default ?a None = ?a›*) 1)) next (*goal: ‹⋀a. lookup (λx. x = (idn, S)) insts = Some a ⟹ subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) case (Some a) (*‹lookup (λx. x = (idn, S)) insts = Some a›*) hence "lookup (λx. x = (idn, S)) (map (apsnd (subst_typ [single])) insts) = Some (subst_typ [single] a)" apply (induction insts) (*goals: 1. ‹lookup (λx. x = (idn, S)) [] = Some a ⟹ lookup (λx. x = (idn, S)) (map (apsnd (subst_typ [single])) []) = Some (subst_typ [single] a)› 2. ‹⋀aa insts. ⟦lookup (λx. x = (idn, S)) insts = Some a ⟹ lookup (λx. x = (idn, S)) (map (apsnd (subst_typ [single])) insts) = Some (subst_typ [single] a); lookup (λx. x = (idn, S)) (aa # insts) = Some a⟧ ⟹ lookup (λx. x = (idn, S)) (map (apsnd (subst_typ [single])) (aa # insts)) = Some (subst_typ [single] a)› discuss goal 1*) apply ((auto split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . then show "?thesis" (*goal: ‹subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) using Some (*‹lookup (λx. x = (idn, S)) insts = Some a›*) apply simp (*goal: ‹subst_typ [single] (subst_typ insts (Tv idn S)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Tv idn S)›*) by (metis subst_typ.simps( (*‹subst_typ ?insts (Tv ?idn ?S) = the_default (Tv ?idn ?S) (lookup (λx. x = (?idn, ?S)) ?insts)›*) 2) subst_typ_comp_single_left (*‹subst_typ [?single] (subst_typ ?insts ?T) = subst_typ (map (apsnd (subst_typ [?single])) ?insts @ [?single]) ?T›*) the_default.simps( (*‹the_default ?uu (Some ?b) = ?b›*) 2)) qed qed (auto) (*solved the remaining goal: ‹⋀x1 x2. (⋀x2a. x2a ∈ set x2 ⟹ subst_typ [single] (subst_typ insts x2a) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) x2a) ⟹ subst_typ [single] (subst_typ insts (Ty x1 x2)) = subst_typ (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Ty x1 x2)›*) lemma subst_typ'_comp_single_left: "subst_typ' [single] (subst_typ' insts t) = subst_typ' (map (apsnd (subst_typ [single])) insts@[single]) t" apply (induction t) (*goals: 1. ‹⋀x1 x2. subst_typ' [single] (subst_typ' insts (Ct x1 x2)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) (Ct x1 x2)› 2. ‹⋀x1 x2. subst_typ' [single] (subst_typ' insts (Fv x1 x2)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) (Fv x1 x2)› 3. ‹⋀x. subst_typ' [single] (subst_typ' insts (Bv x)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) (Bv x)› 4. ‹⋀x1 t. subst_typ' [single] (subst_typ' insts t) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) t ⟹ subst_typ' [single] (subst_typ' insts (Abs x1 t)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) (Abs x1 t)› 5. ‹⋀t1 t2. ⟦subst_typ' [single] (subst_typ' insts t1) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) t1; subst_typ' [single] (subst_typ' insts t2) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) t2⟧ ⟹ subst_typ' [single] (subst_typ' insts (t1 $ t2)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ [single]) (t1 $ t2)› discuss goal 1*) apply ((use subst_typ_comp_single_left in auto)[1]) (*discuss goal 2*) apply ((use subst_typ_comp_single_left in auto)[1]) (*discuss goal 3*) apply ((use subst_typ_comp_single_left in auto)[1]) (*discuss goal 4*) apply ((use subst_typ_comp_single_left in auto)[1]) (*discuss goal 5*) apply ((use subst_typ_comp_single_left in auto)[1]) (*proven 5 subgoals*) . lemma subst_typ'_comp_single_left_stronger: "subst_typ' [single] (subst_typ' insts t) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) t" apply (induction t) (*goals: 1. ‹⋀x1 x2. subst_typ' [single] (subst_typ' insts (Ct x1 x2)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Ct x1 x2)› 2. ‹⋀x1 x2. subst_typ' [single] (subst_typ' insts (Fv x1 x2)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Fv x1 x2)› 3. ‹⋀x. subst_typ' [single] (subst_typ' insts (Bv x)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Bv x)› 4. ‹⋀x1 t. subst_typ' [single] (subst_typ' insts t) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) t ⟹ subst_typ' [single] (subst_typ' insts (Abs x1 t)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (Abs x1 t)› 5. ‹⋀t1 t2. ⟦subst_typ' [single] (subst_typ' insts t1) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) t1; subst_typ' [single] (subst_typ' insts t2) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) t2⟧ ⟹ subst_typ' [single] (subst_typ' insts (t1 $ t2)) = subst_typ' (map (apsnd (subst_typ [single])) insts @ (if fst single ∈ set (map fst insts) then [] else [single])) (t1 $ t2)› discuss goal 1*) apply ((use subst_typ_comp_single_left_stronger in auto)[1]) (*discuss goal 2*) apply ((use subst_typ_comp_single_left_stronger in auto)[1]) (*discuss goal 3*) apply ((use subst_typ_comp_single_left_stronger in auto)[1]) (*discuss goal 4*) apply ((use subst_typ_comp_single_left_stronger in auto)[1]) (*discuss goal 5*) apply ((use subst_typ_comp_single_left_stronger in auto)[1]) (*proven 5 subgoals*) . lemma subst_typ_preserves_typ_ok: assumes "wf_theory Θ" assumes "typ_ok Θ T" assumes "list_all (typ_ok Θ) (map snd insts)" shows "typ_ok Θ (subst_typ insts T)" using assms (*‹wf_theory Θ› ‹typ_ok Θ T› ‹list_all (typ_ok Θ) (map snd insts)›*) proof (induction T) (*goals: 1. ‹⋀x1 x2. ⟦⋀x2a. ⟦x2a ∈ set x2; wf_theory Θ; typ_ok Θ x2a; list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts x2a); wf_theory Θ; typ_ok Θ (Ty x1 x2); list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts (Ty x1 x2))› 2. ‹⋀x1 x2. ⟦wf_theory Θ; typ_ok Θ (Tv x1 x2); list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts (Tv x1 x2))›*) case (Ty n Ts) (*‹⟦?x2a ∈ set Ts; wf_theory Θ; typ_ok Θ ?x2a; list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts ?x2a)› ‹wf_theory Θ› ‹typ_ok Θ (Ty n Ts)› ‹list_all (typ_ok Θ) (map snd insts)›*) have I: "∀x ∈ set Ts . typ_ok Θ (subst_typ insts x)" using Ty (*‹⟦?x2a ∈ set Ts; wf_theory Θ; typ_ok Θ ?x2a; list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts ?x2a)› ‹wf_theory Θ› ‹typ_ok Θ (Ty n Ts)› ‹list_all (typ_ok Θ) (map snd insts)›*) by (auto simp add: typ_ok_def (*‹typ_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?T::typ) ≡ wf_type (sig ?Θ) ?T›*) list_all_iff (*‹list_all (?P::?'a::type ⇒ bool) (?x::?'a::type list) = Ball (set ?x) ?P›*) split: option.splits (*‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a::type. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a::type. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) moreover have "(∀x ∈ set Ts . typ_ok Θ (subst_typ insts x)) = (∀x ∈ set (map (subst_typ insts) Ts) . typ_ok Θ x)" apply (induction Ts) (*goals: 1. ‹(∀x∈set []. typ_ok Θ (subst_typ insts x)) = (∀x∈set (map (subst_typ insts) []). typ_ok Θ x)› 2. ‹⋀a Ts. (∀x∈set Ts. typ_ok Θ (subst_typ insts x)) = (∀x∈set (map (subst_typ insts) Ts). typ_ok Θ x) ⟹ (∀x∈set (a # Ts). typ_ok Θ (subst_typ insts x)) = (∀x∈set (map (subst_typ insts) (a # Ts)). typ_ok Θ x)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . ultimately have "list_all (wf_type (sig Θ)) (map (subst_typ insts) Ts)" using list_allI (*‹(⋀x. x ∈ set ?l ⟹ ?P x) ⟹ list_all ?P ?l›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) Ball_set (*‹Ball (set ?xs) ?P = list_all ?P ?xs›*) typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) by fastforce then show "?case" (*goal: ‹typ_ok Θ (subst_typ insts (Ty n Ts))›*) using Ty (*‹⟦?x2a ∈ set Ts; wf_theory Θ; typ_ok Θ ?x2a; list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts ?x2a)› ‹wf_theory Θ› ‹typ_ok Θ (Ty n Ts)› ‹list_all (typ_ok Θ) (map snd insts)›*) list.pred_mono_strong (*‹⟦list_all ?P ?x; ⋀z. ⟦z ∈ set ?x; ?P z⟧ ⟹ ?Pa z⟧ ⟹ list_all ?Pa ?x›*) by (force split: option.splits (*‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2::?'a::type. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹(?P::?'b::type ⇒ bool) (case ?option::?'a::type option of None ⇒ ?f1.0::?'b::type | Some (x::?'a::type) ⇒ (?f2.0::?'a::type ⇒ ?'b::type) x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2::?'a::type. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) next (*goal: ‹⋀x1 x2. ⟦wf_theory Θ; typ_ok Θ (Tv x1 x2); list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts (Tv x1 x2))›*) case (Tv idn τ) (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹typ_ok Θ (Tv idn τ)› ‹list_all (typ_ok Θ) (map snd insts)›*) then show "?case" (*goal: ‹typ_ok Θ (subst_typ insts (Tv idn τ))›*) apply (induction insts) (*goals: 1. ‹⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); typ_ok Θ (Tv (idn::variable) (τ::String.literal set)); list_all (typ_ok Θ) (map snd [])⟧ ⟹ typ_ok Θ (subst_typ [] (Tv idn τ))› 2. ‹⋀(a::(variable × String.literal set) × typ) insts::((variable × String.literal set) × typ) list. ⟦⟦wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); typ_ok Θ (Tv (idn::variable) (τ::String.literal set)); list_all (typ_ok Θ) (map snd insts)⟧ ⟹ typ_ok Θ (subst_typ insts (Tv idn τ)); wf_theory Θ; typ_ok Θ (Tv idn τ); list_all (typ_ok Θ) (map snd (a # insts))⟧ ⟹ typ_ok Θ (subst_typ (a # insts) (Tv idn τ))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed lemma typ_ok_Ty[simp]: "typ_ok Θ (Ty n Ts) ⟹ list_all (typ_ok Θ) Ts" by (auto simp add: typ_ok_def (*‹typ_ok ?Θ ?T ≡ wf_type (sig ?Θ) ?T›*) list.pred_mono_strong (*‹⟦list_all ?P ?x; ⋀z. ⟦z ∈ set ?x; ?P z⟧ ⟹ ?Pa z⟧ ⟹ list_all ?Pa ?x›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) lemma typ_ok_sig_Ty[simp]: "typ_ok_sig Σ (Ty n Ts) ⟹ list_all (typ_ok_sig Σ) Ts" by (auto simp add: list.pred_mono_strong (*‹⟦list_all ?P ?x; ⋀z. ⟦z ∈ set ?x; ?P z⟧ ⟹ ?Pa z⟧ ⟹ list_all ?Pa ?x›*) split: option.splits (*‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = ((?option = None ⟶ ?P ?f1.0) ∧ (∀x2. ?option = Some x2 ⟶ ?P (?f2.0 x2)))› ‹?P (case ?option of None ⇒ ?f1.0 | Some x ⇒ ?f2.0 x) = (¬ (?option = None ∧ ¬ ?P ?f1.0 ∨ (∃x2. ?option = Some x2 ∧ ¬ ?P (?f2.0 x2))))›*)) lemma wf_theory_imp_wf_osig: "wf_theory Θ ⟹ wf_osig (osig (sig Θ))" apply (cases Θ rule: theory_full_exhaust (*‹(⋀cto tao sorts axioms. ?Θ = ((cto, tao, sorts), axioms) ⟹ ?P) ⟹ ?P›*)) (*goal: ‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) ⟹ wf_osig (osig (sig Θ))›*) by simp lemma the_lift2_option_Somes[simp]: "the (lift2_option f (Some a) (Some b)) = f a b" by simp lemma class_les_mgd: assumes "wf_osig oss" assumes "tcsigs oss type = Some mgd" assumes "mgd C' = Some Ss'" assumes "class_les (subclass oss) C' C" shows "mgd C ≠ None" proof (-) (*goal: ‹mgd C ≠ None›*) have "complete_tcsigs (subclass oss) (tcsigs oss)" using assms(1) (*‹wf_osig oss›*) apply (cases oss) (*goal: ‹complete_tcsigs (subclass oss) (tcsigs oss)›*) by simp thus "?thesis" (*goal: ‹mgd C ≠ None›*) using assms(2-4) (*‹tcsigs oss type = Some mgd› ‹mgd C' = Some Ss'› ‹class_les (subclass oss) C' C›*) by (auto simp add: class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) class_leq_def (*‹class_leq ?sub ?c1.0 ?c2.0 = ((?c1.0, ?c2.0) ∈ ?sub)›*) complete_tcsigs_def (*‹complete_tcsigs ?sub ?tcs ≡ ∀ars∈ran ?tcs. ∀(c₁, c₂)∈?sub. c₁ ∈ dom ars ⟶ c₂ ∈ dom ars›*) intro!: domI (*‹?m ?a = Some ?b ⟹ ?a ∈ dom ?m›*) ranI (*‹?m ?a = Some ?b ⟹ ?b ∈ ran ?m›*)) qed lemma has_sort_sort_leq_osig: assumes "wf_osig (sub, tcs)" "has_sort (sub,tcs) T S" "sort_leq sub S S'" shows "has_sort (sub,tcs) T S'" using assms(2,3,1) (*‹has_sort (sub, tcs) T S› ‹sort_leq sub S S'› ‹wf_osig (sub, tcs)›*) proof (induction "(sub,tcs)" T S arbitrary: S' rule: has_sort.induct) (*goals: 1. ‹⋀S S' a S'a. ⟦sort_leq sub S S'; sort_leq sub S' S'a; wf_osig (sub, tcs)⟧ ⟹ has_sort (sub, tcs) (Tv a S) S'a› 2. ‹⋀κ dm S Ts S'. ⟦tcs κ = Some dm; ∀c∈S. ∃Ss. dm c = Some Ss ∧ list_all2 (λx1 x2. has_sort (sub, tcs) x1 x2 ∧ (True ∧ True ⟶ (∀x. sort_leq sub x2 x ⟶ wf_osig (sub, tcs) ⟶ has_sort (sub, tcs) x1 x))) Ts Ss; sort_leq sub S S'; wf_osig (sub, tcs)⟧ ⟹ has_sort (sub, tcs) (Ty κ Ts) S'›*) case (has_sort_Tv S S' tcs a) (*‹sort_leq (sub::(String.literal × String.literal) set) (S::String.literal set) (S'::String.literal set)› ‹sort_leq sub S' a› ‹wf_osig (sub::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option)›*) then show "?case" (*goal: ‹has_sort (sub, tcs) (Tv tcs S) a›*) using wf_osig.simps (*‹wf_osig (?sub, ?tcs) = (wf_subclass ?sub ∧ wf_tcsigs ?sub ?tcs)›*) wf_subclass_loc.intro (*‹wf_subclass ?cs ⟹ wf_subclass_loc ?cs›*) wf_subclass_loc.sort_leq_trans (*‹⟦wf_subclass_loc (?cs::(String.literal × String.literal) set); sort_leq ?cs (?x::String.literal set) (?y::String.literal set); sort_leq ?cs ?y (?z::String.literal set)⟧ ⟹ sort_leq ?cs ?x ?z›*) by blast next (*goal: ‹⋀κ dm S Ts S'. ⟦tcs κ = Some dm; ∀c∈S. ∃Ss. dm c = Some Ss ∧ list_all2 (λx1 x2. has_sort (sub, tcs) x1 x2 ∧ (True ∧ True ⟶ (∀x. sort_leq sub x2 x ⟶ wf_osig (sub, tcs) ⟶ has_sort (sub, tcs) x1 x))) Ts Ss; sort_leq sub S S'; wf_osig (sub, tcs)⟧ ⟹ has_sort (sub, tcs) (Ty κ Ts) S'›*) case (has_sort_Ty κ K S Ts) (*‹tcs κ = Some K› ‹∀c∈S. ∃Ss. K c = Some Ss ∧ list_all2 (λx1 x2. has_sort (sub, tcs) x1 x2 ∧ (True ∧ True ⟶ (∀x. sort_leq sub x2 x ⟶ wf_osig (sub, tcs) ⟶ has_sort (sub, tcs) x1 x))) Ts Ss› ‹sort_leq (sub::(String.literal × String.literal) set) (S::String.literal set) (S'::String.literal set)› ‹wf_osig (sub, tcs)›*) show "?case" (*goal: ‹has_sort (sub::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) (Ty (κ::String.literal) (Ts::typ list)) (S'::String.literal set)›*) proof (rule has_sort.has_sort_Ty[where dm=K] (*‹⟦?tcs ?κ = Some K; ∀c∈?S. ∃Ss. K c = Some Ss ∧ list_all2 (has_sort (?sub, ?tcs)) ?Ts Ss⟧ ⟹ has_sort (?sub, ?tcs) (Ty ?κ ?Ts) ?S›*)) (*goals: 1. ‹tcs κ = Some K› 2. ‹∀c∈S'. ∃Ss. K c = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss›*) show "tcs κ = Some K" using has_sort_Ty.hyps(1) (*‹tcs κ = Some K›*) . next (*goal: ‹∀c∈S'. ∃Ss. K c = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss›*) show "∀C∈S'. ∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss" proof (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀C. C ∈ S' ⟹ ∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss›*) fix C assume C: "C ∈ S'" (*‹(C::String.literal) ∈ (S'::String.literal set)›*) show "∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss" proof (cases "C ∈ S") (*goals: 1. ‹C ∈ S ⟹ ∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss› 2. ‹C ∉ S ⟹ ∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss›*) case True (*‹C ∈ S›*) then show "?thesis" (*goal: ‹∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss›*) using list_all2_mono (*‹⟦list_all2 ?P ?xs ?ys; ⋀xs ys. ?P xs ys ⟹ ?Q xs ys⟧ ⟹ list_all2 ?Q ?xs ?ys›*) has_sort_Ty.hyps(2) (*‹∀c::String.literal∈S::String.literal set. ∃Ss::String.literal set list. (K::String.literal ⇒ String.literal set list option) c = Some Ss ∧ list_all2 (λ(x1::typ) x2::String.literal set. has_sort (sub::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) x1 x2 ∧ (True ∧ True ⟶ (∀x::String.literal set. sort_leq sub x2 x ⟶ wf_osig (sub, tcs) ⟶ has_sort (sub, tcs) x1 x))) (Ts::typ list) Ss›*) by fastforce next (*goal: ‹C ∉ S ⟹ ∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss›*) case False (*‹C ∉ S›*) from this (*‹C ∉ S›*) obtain C' where C': "C' ∈ S" "class_les sub C' C" (*goal: ‹(⋀C'. ⟦C' ∈ S; class_les sub C' C⟧ ⟹ thesis) ⟹ thesis›*) by (metis C (*‹(C::String.literal) ∈ (S'::String.literal set)›*) class_les_def (*‹class_les (?sub::(?'a × ?'a) set) (?c1.0::?'a) (?c2.0::?'a) = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) has_sort_Ty.prems( (*‹sort_leq (sub::(String.literal × String.literal) set) (S::String.literal set) (S'::String.literal set)›*) 1) has_sort_Ty.prems( (*‹wf_osig (sub::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option)›*) 2) sort_leq_def (*‹sort_leq (?sub::(?'a × ?'b) set) (?s1.0::?'a set) (?s2.0::?'b set) = (∀c₂::?'b∈?s2.0. ∃c₁::?'a∈?s1.0. class_leq ?sub c₁ c₂)›*) subclass.simps (*‹subclass (?cl::(String.literal × String.literal) set, ?uu::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) = ?cl›*) wf_osig_imp_wf_subclass_loc (*‹wf_osig (?oss::(String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) ⟹ wf_subclass_loc (subclass ?oss)›*) wf_subclass_loc.class_leq_antisym (*‹⟦wf_subclass_loc (?cs::(String.literal × String.literal) set); class_leq ?cs (?c1.0::String.literal) (?c2.0::String.literal); class_leq ?cs ?c2.0 ?c1.0⟧ ⟹ ?c1.0 = ?c2.0›*)) from this (*‹C' ∈ S› ‹class_les sub C' C›*) obtain Ss' where Ss': "K C' = Some Ss'" "list_all2 (has_sort (sub,tcs)) Ts Ss'" (*goal: ‹(⋀Ss'. ⟦K C' = Some Ss'; list_all2 (has_sort (sub, tcs)) Ts Ss'⟧ ⟹ thesis) ⟹ thesis›*) using list_all2_mono (*‹⟦list_all2 (?P::?'a ⇒ ?'b ⇒ bool) (?xs::?'a list) (?ys::?'b list); ⋀(xs::?'a) ys::?'b. ?P xs ys ⟹ (?Q::?'a ⇒ ?'b ⇒ bool) xs ys⟧ ⟹ list_all2 ?Q ?xs ?ys›*) has_sort_Ty.hyps(2) (*‹∀c::String.literal∈S::String.literal set. ∃Ss::String.literal set list. (K::String.literal ⇒ String.literal set list option) c = Some Ss ∧ list_all2 (λ(x1::typ) x2::String.literal set. has_sort (sub::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) x1 x2 ∧ (True ∧ True ⟶ (∀x::String.literal set. sort_leq sub x2 x ⟶ wf_osig (sub, tcs) ⟶ has_sort (sub, tcs) x1 x))) (Ts::typ list) Ss›*) by fastforce from this (*‹(K::String.literal ⇒ String.literal set list option) (C'::String.literal) = Some (Ss'::String.literal set list)› ‹list_all2 (has_sort (sub::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (Ts::typ list) (Ss'::String.literal set list)›*) obtain Ss where Ss: "K C = Some Ss" (*goal: ‹(⋀Ss. K C = Some Ss ⟹ thesis) ⟹ thesis›*) using has_sort_Ty.prems (*‹sort_leq sub S S'› ‹wf_osig (sub, tcs)›*) class_les_mgd (*‹⟦wf_osig (?oss::(String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)); tcsigs ?oss (?type::String.literal) = Some (?mgd::String.literal ⇒ String.literal set list option); ?mgd (?C'::String.literal) = Some (?Ss'::String.literal set list); class_les (subclass ?oss) ?C' (?C::String.literal)⟧ ⟹ ?mgd ?C ≠ None›*) C'(2) (*‹class_les sub C' C›*) has_sort_Ty.hyps(1) (*‹tcs κ = Some K›*) wf_theory_imp_wf_osig (*‹wf_theory ?Θ ⟹ wf_osig (osig (sig ?Θ))›*) by force have lengthSs': "length Ts = length Ss'" using Ss'(2) (*‹list_all2 (has_sort (sub, tcs)) Ts Ss'›*) list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*) by auto have coregular: "coregular_tcsigs sub tcs" using has_sort_Ty.prems(2) (*‹wf_osig (sub, tcs)›*) wf_theory_imp_wf_osig (*‹wf_theory ?Θ ⟹ wf_osig (osig (sig ?Θ))›*) wf_tcsigs_def (*‹wf_tcsigs (?sub::(String.literal × String.literal) set) (?tcs::?'a::type ⇒ (String.literal ⇒ String.literal set list option) option) = (coregular_tcsigs ?sub ?tcs ∧ complete_tcsigs ?sub ?tcs ∧ consistent_length_tcsigs ?tcs ∧ all_normalized_and_ex_tcsigs ?sub ?tcs)›*) by (metis wf_osig.simps (*‹wf_osig (?sub, ?tcs) = (wf_subclass ?sub ∧ wf_tcsigs ?sub ?tcs)›*)) hence leq: "list_all2 (sort_leq sub) Ss' Ss" using C'(2) (*‹class_les sub C' C›*) Ss'(1) (*‹K C' = Some Ss'›*) Ss (*‹K C = Some Ss›*) has_sort_Ty.hyps(1) (*‹tcs κ = Some K›*) ranI (*‹?m ?a = Some ?b ⟹ ?b ∈ ran ?m›*) by (metis class_les_def (*‹class_les ?sub ?c1.0 ?c2.0 = (class_leq ?sub ?c1.0 ?c2.0 ∧ ¬ class_leq ?sub ?c2.0 ?c1.0)›*) coregular_tcsigs_def (*‹coregular_tcsigs ?sub ?tcs ≡ ∀ars∈ran ?tcs. ∀c₁∈dom ars. ∀c₂∈dom ars. class_leq ?sub c₁ c₂ ⟶ list_all2 (sort_leq ?sub) (the (ars c₁)) (the (ars c₂))›*) domI (*‹?m ?a = Some ?b ⟹ ?a ∈ dom ?m›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) have "list_all2 (has_sort (sub,tcs)) Ts Ss" proof (rule list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*)) (*goals: 1. ‹length Ts = length Ss› 2. ‹⋀n. n < length Ts ⟹ has_sort (sub, tcs) (Ts ! n) (Ss ! n)›*) show "length Ts = length Ss" using Ss (*‹K C = Some Ss›*) Ss'(1) (*‹K C' = Some Ss'›*) lengthSs' (*‹length (Ts::typ list) = length (Ss'::String.literal set list)›*) wf_theory_imp_wf_osig (*‹wf_theory ?Θ ⟹ wf_osig (osig (sig ?Θ))›*) leq (*‹list_all2 (sort_leq sub) Ss' Ss›*) list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*) by auto next (*goal: ‹⋀n. n < length Ts ⟹ has_sort (sub, tcs) (Ts ! n) (Ss ! n)›*) fix n assume n: "n < length Ts" (*‹(n::nat) < length (Ts::typ list)›*) hence "sort_leq sub (Ss' ! n) (Ss ! n)" using leq (*‹list_all2 (sort_leq sub) Ss' Ss›*) by (simp add: lengthSs' (*‹length Ts = length Ss'›*) list_all2_nthD (*‹⟦list_all2 ?P ?xs ?ys; ?p < length ?xs⟧ ⟹ ?P (?xs ! ?p) (?ys ! ?p)›*)) thus "has_sort (sub,tcs) (Ts ! n) (Ss ! n)" using has_sort_Ty.hyps(2) (*‹∀c∈S. ∃Ss. K c = Some Ss ∧ list_all2 (λx1 x2. has_sort (sub, tcs) x1 x2 ∧ (True ∧ True ⟶ (∀x. sort_leq sub x2 x ⟶ wf_osig (sub, tcs) ⟶ has_sort (sub, tcs) x1 x))) Ts Ss›*) has_sort_Ty.prems(2) (*‹wf_osig (sub, tcs)›*) C'(1) (*‹C' ∈ S›*) Ss'(1) (*‹K C' = Some Ss'›*) n (*‹n < length Ts›*) list_all2_nthD (*‹⟦list_all2 ?P ?xs ?ys; ?p < length ?xs⟧ ⟹ ?P (?xs ! ?p) (?ys ! ?p)›*) by fastforce qed thus "∃Ss. K C = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss" using Ss (*‹(K::String.literal ⇒ String.literal set list option) (C::String.literal) = Some (Ss::String.literal set list)›*) by simp qed qed qed qed lemma has_sort_sort_leq: "wf_theory Θ ⟹ has_sort (osig (sig Θ)) T S ⟹ sort_leq (subclass (osig (sig Θ))) S S' ⟹ has_sort (osig (sig Θ)) T S'" by (metis has_sort_sort_leq_osig (*‹⟦wf_osig (?sub, ?tcs); has_sort (?sub, ?tcs) ?T ?S; sort_leq ?sub ?S ?S'⟧ ⟹ has_sort (?sub, ?tcs) ?T ?S'›*) subclass.elims (*‹⟦subclass ?x = ?y; ⋀cl uu_. ⟦?x = (cl, uu_); ?y = cl⟧ ⟹ ?P⟧ ⟹ ?P›*) wf_theory_imp_wf_osig (*‹wf_theory ?Θ ⟹ wf_osig (osig (sig ?Θ))›*)) lemma subst_typ_preserves_has_sort: assumes "wf_theory Θ" assumes "has_sort (osig (sig Θ)) T S" assumes "list_all (λ((idn, S), T). has_sort (osig (sig Θ)) T S) insts" shows "has_sort (osig (sig Θ)) (subst_typ insts T) S" using assms (*‹wf_theory Θ› ‹has_sort (osig (sig Θ)) T S› ‹list_all (λ((idn, S), T). has_sort (osig (sig Θ)) T S) insts›*) proof (induction T arbitrary: S) (*goals: 1. ‹⋀x1 x2 S. ⟦⋀x2a S. ⟦x2a ∈ set x2; wf_theory Θ; has_sort (osig (sig Θ)) x2a S; list_all (λ((idn, S), T). has_sort (osig (sig Θ)) T S) insts⟧ ⟹ has_sort (osig (sig Θ)) (subst_typ insts x2a) S; wf_theory Θ; has_sort (osig (sig Θ)) (Ty x1 x2) S; list_all (λ((idn, S), T). has_sort (osig (sig Θ)) T S) insts⟧ ⟹ has_sort (osig (sig Θ)) (subst_typ insts (Ty x1 x2)) S› 2. ‹⋀x1 x2 S. ⟦wf_theory Θ; has_sort (osig (sig Θ)) (Tv x1 x2) S; list_all (λ((idn, S), T). has_sort (osig (sig Θ)) T S) insts⟧ ⟹ has_sort (osig (sig Θ)) (subst_typ insts (Tv x1 x2)) S›*) case (Ty κ Ts) (*‹⟦(?x2a::typ) ∈ set (Ts::typ list); wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); has_sort (osig (sig Θ)) ?x2a (?S::String.literal set); list_all (λa::(variable × String.literal set) × typ. case a of (a::variable × String.literal set, b::typ) ⇒ (case a of (idn::variable, S::String.literal set) ⇒ λT::typ. has_sort (osig (sig Θ)) T S) b) (insts::((variable × String.literal set) × typ) list)⟧ ⟹ has_sort (osig (sig Θ)) (subst_typ insts ?x2a) ?S› ‹wf_theory Θ› ‹has_sort (osig (sig Θ)) (Ty κ Ts) S› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idn, S) ⇒ λT. has_sort (osig (sig Θ)) T S) b) insts›*) obtain cl and tcs where cltcs: "osig (sig Θ) = (cl, tcs)" (*goal: ‹(⋀cl tcs. osig (sig Θ) = (cl, tcs) ⟹ thesis) ⟹ thesis›*) by fastforce moreover obtain K where "tcsigs (osig (sig Θ)) κ = Some K" (*goal: ‹(⋀K. tcsigs (osig (sig Θ)) κ = Some K ⟹ thesis) ⟹ thesis›*) using Ty.prems(2) (*‹has_sort (osig (sig Θ)) (Ty κ Ts) S›*) has_sort.simps (*‹has_sort (?a1.0::(String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?a2.0::typ) (?a3.0::String.literal set) = ((∃(sub::(String.literal × String.literal) set) (S::String.literal set) (S'::String.literal set) (tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) a::variable. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Tv a S ∧ ?a3.0 = S' ∧ sort_leq sub S S') ∨ (∃(tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) (κ::String.literal) (dm::String.literal ⇒ String.literal set list option) (S::String.literal set) (sub::(String.literal × String.literal) set) Ts::typ list. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Ty κ Ts ∧ ?a3.0 = S ∧ tcs κ = Some dm ∧ (∀c::String.literal∈S. ∃Ss::String.literal set list. dm c = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss)))›*) by auto ultimately have mgd: "tcs κ = Some K" by simp have "has_sort (osig (sig Θ)) (subst_typ insts (Ty κ Ts)) S = has_sort (osig (sig Θ)) (Ty κ (map (subst_typ insts) Ts)) S" by simp moreover have "has_sort (osig (sig Θ)) (Ty κ (map (subst_typ insts) Ts)) S" apply (subst cltcs (*‹osig (sig Θ) = (cl, tcs)›*)) (*goal: ‹has_sort (osig (sig Θ)) (Ty κ (map (subst_typ insts) Ts)) S›*) apply (rule has_sort_Ty[of tcs, OF mgd] (*‹∀c∈?S. ∃Ss. K c = Some Ss ∧ list_all2 (has_sort (?sub, tcs)) ?Ts Ss ⟹ has_sort (?sub, tcs) (Ty κ ?Ts) ?S›*)) (*goal: ‹has_sort (cl::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option) (Ty (κ::String.literal) (map (subst_typ (insts::((variable × String.literal set) × typ) list)) (Ts::typ list))) (S::String.literal set)›*) proof (rule ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀c. c ∈ S ⟹ ∃Ss. K c = Some Ss ∧ list_all2 (has_sort (cl, tcs)) (map (subst_typ insts) Ts) Ss›*) fix C assume C: "C ∈ S" (*‹(C::String.literal) ∈ (S::String.literal set)›*) obtain Ss where Ss: "K C = Some Ss" (*goal: ‹(⋀Ss. K C = Some Ss ⟹ thesis) ⟹ thesis›*) using C (*‹C ∈ S›*) Ty.prems(2) (*‹has_sort (osig (sig Θ)) (Ty κ Ts) S›*) mgd (*‹tcs κ = Some K›*) has_sort.simps (*‹has_sort ?a1.0 ?a2.0 ?a3.0 = ((∃sub S S' tcs a. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Tv a S ∧ ?a3.0 = S' ∧ sort_leq sub S S') ∨ (∃tcs κ dm S sub Ts. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Ty κ Ts ∧ ?a3.0 = S ∧ tcs κ = Some dm ∧ (∀c∈S. ∃Ss. dm c = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss)))›*) cltcs (*‹osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) = (cl::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option)›*) by auto have "list_all2 (has_sort (osig (sig Θ))) (map (subst_typ insts) Ts) Ss" proof (rule list_all2_all_nthI (*‹⟦length ?a = length ?b; ⋀n. n < length ?a ⟹ ?P (?a ! n) (?b ! n)⟧ ⟹ list_all2 ?P ?a ?b›*)) (*goals: 1. ‹length (map (subst_typ insts) Ts) = length Ss› 2. ‹⋀n. n < length (map (subst_typ insts) Ts) ⟹ has_sort (osig (sig Θ)) (map (subst_typ insts) Ts ! n) (Ss ! n)›*) show "length (map (subst_typ insts) Ts) = length Ss" using C (*‹(C::String.literal) ∈ (S::String.literal set)›*) Ss (*‹K C = Some Ss›*) Ty.prems(2) (*‹has_sort (osig (sig Θ)) (Ty κ Ts) S›*) list_all2_lengthD (*‹list_all2 ?P ?xs ?ys ⟹ length ?xs = length ?ys›*) mgd (*‹tcs κ = Some K›*) has_sort.simps (*‹has_sort ?a1.0 ?a2.0 ?a3.0 = ((∃sub S S' tcs a. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Tv a S ∧ ?a3.0 = S' ∧ sort_leq sub S S') ∨ (∃tcs κ dm S sub Ts. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Ty κ Ts ∧ ?a3.0 = S ∧ tcs κ = Some dm ∧ (∀c∈S. ∃Ss. dm c = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss)))›*) cltcs (*‹osig (sig Θ) = (cl, tcs)›*) by fastforce next (*goal: ‹⋀n. n < length (map (subst_typ insts) Ts) ⟹ has_sort (osig (sig Θ)) (map (subst_typ insts) Ts ! n) (Ss ! n)›*) fix n assume n: "n < length (map (subst_typ insts) Ts)" (*‹(n::nat) < length (map (subst_typ (insts::((variable × String.literal set) × typ) list)) (Ts::typ list))›*) have "list_all2 (has_sort (cl, tcs)) Ts Ss" using C (*‹C ∈ S›*) Ss (*‹K C = Some Ss›*) Ty.prems(2) (*‹has_sort (osig (sig Θ)) (Ty κ Ts) S›*) cltcs (*‹osig (sig Θ) = (cl, tcs)›*) has_sort.simps (*‹has_sort ?a1.0 ?a2.0 ?a3.0 = ((∃sub S S' tcs a. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Tv a S ∧ ?a3.0 = S' ∧ sort_leq sub S S') ∨ (∃tcs κ dm S sub Ts. ?a1.0 = (sub, tcs) ∧ ?a2.0 = Ty κ Ts ∧ ?a3.0 = S ∧ tcs κ = Some dm ∧ (∀c∈S. ∃Ss. dm c = Some Ss ∧ list_all2 (has_sort (sub, tcs)) Ts Ss)))›*) mgd (*‹tcs κ = Some K›*) by auto hence 1: "has_sort (osig (sig Θ)) (Ts ! n) (Ss ! n)" using cltcs (*‹osig (sig Θ) = (cl, tcs)›*) list_all2_conv_all_nth (*‹list_all2 ?P ?xs ?ys = (length ?xs = length ?ys ∧ (∀i<length ?xs. ?P (?xs ! i) (?ys ! i)))›*) n (*‹(n::nat) < length (map (subst_typ (insts::((variable × String.literal set) × typ) list)) (Ts::typ list))›*) by auto have "has_sort (osig (sig Θ)) (subst_typ insts (Ts ! n)) (Ss ! n)" using "1" (*‹has_sort (osig (sig Θ)) (Ts ! n) (Ss ! n)›*) n (*‹n < length (map (subst_typ insts) Ts)›*) Ty.prems (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹has_sort (osig (sig Θ)) (Ty κ Ts) S› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idn, S) ⇒ λT. has_sort (osig (sig Θ)) T S) b) insts›*) cltcs (*‹osig (sig Θ) = (cl, tcs)›*) C (*‹C ∈ S›*) Ss (*‹K C = Some Ss›*) mgd (*‹tcs κ = Some K›*) Ty.IH (*‹⟦?x2a ∈ set Ts; wf_theory Θ; has_sort (osig (sig Θ)) ?x2a ?S; list_all (λa. case a of (a, b) ⇒ (case a of (idn, S) ⇒ λT. has_sort (osig (sig Θ)) T S) b) insts⟧ ⟹ has_sort (osig (sig Θ)) (subst_typ insts ?x2a) ?S›*) by auto then show "has_sort (osig (sig Θ)) (map (subst_typ insts) Ts ! n) (Ss ! n)" using n (*‹(n::nat) < length (map (subst_typ (insts::((variable × String.literal set) × typ) list)) (Ts::typ list))›*) by auto qed thus "∃Ss. K C = Some Ss ∧ list_all2 (has_sort (cl, tcs)) (map (subst_typ insts) Ts) Ss" using Ss (*‹(K::String.literal ⇒ String.literal set list option) (C::String.literal) = Some (Ss::String.literal set list)›*) cltcs (*‹osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)) = (cl::(String.literal × String.literal) set, tcs::String.literal ⇒ (String.literal ⇒ String.literal set list option) option)›*) by simp qed ultimately show "?case" (*goal: ‹has_sort (osig (sig Θ)) (subst_typ insts (Ty κ Ts)) S›*) by simp next (*goal: ‹⋀x1 x2 S. ⟦wf_theory Θ; has_sort (osig (sig Θ)) (Tv x1 x2) S; list_all (λ((idn, S), T). has_sort (osig (sig Θ)) T S) insts⟧ ⟹ has_sort (osig (sig Θ)) (subst_typ insts (Tv x1 x2)) S›*) case (Tv idn S') (*‹wf_theory Θ› ‹has_sort (osig (sig Θ)) (Tv idn S') S› ‹list_all (λa::(variable × String.literal set) × typ. case a of (a::variable × String.literal set, b::typ) ⇒ (case a of (idn::variable, S::String.literal set) ⇒ λT::typ. has_sort (osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set))) T S) b) (insts::((variable × String.literal set) × typ) list)›*) show "?case" (*goal: ‹has_sort (osig (sig Θ)) (subst_typ insts (Tv idn S')) S›*) proof (cases "(lookup (λx. x = (idn, S')) insts)") (*goals: 1. ‹lookup (λx. x = (idn, S')) insts = None ⟹ has_sort (osig (sig Θ)) (subst_typ insts (Tv idn S')) S› 2. ‹⋀a. lookup (λx. x = (idn, S')) insts = Some a ⟹ has_sort (osig (sig Θ)) (subst_typ insts (Tv idn S')) S›*) case None (*‹lookup (λx. x = (idn, S')) insts = None›*) then show "?thesis" (*goal: ‹has_sort (osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set))) (subst_typ (insts::((variable × String.literal set) × typ) list) (Tv (idn::variable) (S'::String.literal set))) (S::String.literal set)›*) using Tv (*‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› ‹has_sort (osig (sig Θ)) (Tv idn S') S› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idn, S) ⇒ λT. has_sort (osig (sig Θ)) T S) b) insts›*) by simp next (*goal: ‹⋀a::typ. lookup (λx::variable × String.literal set. x = (idn::variable, S'::String.literal set)) (insts::((variable × String.literal set) × typ) list) = Some a ⟹ has_sort (osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set))) (subst_typ insts (Tv idn S')) (S::String.literal set)›*) case (Some res) (*‹lookup (λx. x = (idn, S')) insts = Some res›*) hence "((idn, S'), res) ∈ set insts" using lookup_present_eq_key' (*‹lookup (λx. x = ?k) ?al = Some ?v ⟹ (?k, ?v) ∈ set ?al›*) by fast hence "has_sort (osig (sig Θ)) res S'" using Tv (*‹wf_theory Θ› ‹has_sort (osig (sig Θ)) (Tv idn S') S› ‹list_all (λa. case a of (a, b) ⇒ (case a of (idn, S) ⇒ λT. has_sort (osig (sig Θ)) T S) b) insts›*) using split_list (*‹?x ∈ set ?xs ⟹ ∃ys zs. ?xs = ys @ ?x # zs›*) by fastforce moreover have 1: "sort_leq (subclass (osig (sig Θ))) S' S" using Tv.prems(2) (*‹has_sort (osig (sig Θ)) (Tv idn S') S›*) has_sort_Tv_imp_sort_leq (*‹has_sort ?oss (Tv ?idn ?S) ?S' ⟹ sort_leq (subclass ?oss) ?S ?S'›*) by blast ultimately show "?thesis" (*goal: ‹has_sort (osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set))) (subst_typ (insts::((variable × String.literal set) × typ) list) (Tv (idn::variable) (S'::String.literal set))) (S::String.literal set)›*) using Some (*‹lookup (λx::variable × String.literal set. x = (idn::variable, S'::String.literal set)) (insts::((variable × String.literal set) × typ) list) = Some (res::typ)›*) Tv(2) (*‹has_sort (osig (sig Θ)) (Tv idn S') S›*) has_sort_Tv_imp_sort_leq (*‹has_sort ?oss (Tv ?idn ?S) ?S' ⟹ sort_leq (subclass ?oss) ?S ?S'›*) apply simp (*goal: ‹has_sort (osig (sig Θ)) (subst_typ insts (Tv idn S')) S›*) using assms(1) (*‹wf_theory Θ›*) "1" (*‹sort_leq (subclass (osig (sig (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)))) (S'::String.literal set) (S::String.literal set)›*) has_sort_sort_leq (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); has_sort (osig (sig ?Θ)) (?T::typ) (?S::String.literal set); sort_leq (subclass (osig (sig ?Θ))) ?S (?S'::String.literal set)⟧ ⟹ has_sort (osig (sig ?Θ)) ?T ?S'›*) by blast qed qed lemma subst_typ_preserves_Some_typ_of1: assumes "typ_of1 Ts t = Some T" shows "typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t) = Some (subst_typ insts T)" using assms (*‹typ_of1 Ts t = Some T›*) proof (induction t arbitrary: T Ts) (*goals: 1. ‹⋀x1 x2 T Ts. typ_of1 Ts (Ct x1 x2) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Ct x1 x2)) = Some (subst_typ insts T)› 2. ‹⋀x1 x2 T Ts. typ_of1 Ts (Fv x1 x2) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Fv x1 x2)) = Some (subst_typ insts T)› 3. ‹⋀x T Ts. typ_of1 Ts (Bv x) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Bv x)) = Some (subst_typ insts T)› 4. ‹⋀x1 t T Ts. ⟦⋀T Ts. typ_of1 Ts t = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t) = Some (subst_typ insts T); typ_of1 Ts (Abs x1 t) = Some T⟧ ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Abs x1 t)) = Some (subst_typ insts T)› 5. ‹⋀t1 t2 T Ts. ⟦⋀T Ts. typ_of1 Ts t1 = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t1) = Some (subst_typ insts T); ⋀T Ts. typ_of1 Ts t2 = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t2) = Some (subst_typ insts T); typ_of1 Ts (t1 $ t2) = Some T⟧ ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (t1 $ t2)) = Some (subst_typ insts T)›*) next (*goals: 1. ‹⋀x1 x2 T Ts. typ_of1 Ts (Ct x1 x2) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Ct x1 x2)) = Some (subst_typ insts T)› 2. ‹⋀x1 x2 T Ts. typ_of1 Ts (Fv x1 x2) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Fv x1 x2)) = Some (subst_typ insts T)› 3. ‹⋀x T Ts. typ_of1 Ts (Bv x) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Bv x)) = Some (subst_typ insts T)› 4. ‹⋀x1 t T Ts. ⟦⋀T Ts. typ_of1 Ts t = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t) = Some (subst_typ insts T); typ_of1 Ts (Abs x1 t) = Some T⟧ ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Abs x1 t)) = Some (subst_typ insts T)› 5. ‹⋀t1 t2 T Ts. ⟦⋀T Ts. typ_of1 Ts t1 = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t1) = Some (subst_typ insts T); ⋀T Ts. typ_of1 Ts t2 = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t2) = Some (subst_typ insts T); typ_of1 Ts (t1 $ t2) = Some T⟧ ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (t1 $ t2)) = Some (subst_typ insts T)›*) case (App t1 t2) (*‹typ_of1 ?Ts t1 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t1) = Some (subst_typ insts ?T)› ‹typ_of1 ?Ts t2 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t2) = Some (subst_typ insts ?T)› ‹typ_of1 Ts (t1 $ t2) = Some T›*) from this (*‹typ_of1 ?Ts t1 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t1) = Some (subst_typ insts ?T)› ‹typ_of1 ?Ts t2 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t2) = Some (subst_typ insts ?T)› ‹typ_of1 Ts (t1 $ t2) = Some T›*) obtain RT where "typ_of1 Ts t1 = Some (RT → T)" (*goal: ‹(⋀RT. typ_of1 Ts t1 = Some (RT → T) ⟹ thesis) ⟹ thesis›*) using typ_of1_split_App_obtains (*‹⟦typ_of1 ?Ts (?t $ ?u) = Some ?ty; ⋀uty. ⟦typ_of1 ?Ts ?t = Some (uty → ?ty); typ_of1 ?Ts ?u = Some uty⟧ ⟹ ?thesis⟧ ⟹ ?thesis›*) by blast hence "typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t1) = Some (subst_typ insts (RT → T))" using App.IH(1) (*‹typ_of1 ?Ts t1 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t1) = Some (subst_typ insts ?T)›*) by blast moreover have "typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t2) = Some (subst_typ insts RT)" using App (*‹typ_of1 ?Ts t1 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t1) = Some (subst_typ insts ?T)› ‹typ_of1 ?Ts t2 = Some ?T ⟹ typ_of1 (map (subst_typ insts) ?Ts) (subst_typ' insts t2) = Some (subst_typ insts ?T)› ‹typ_of1 Ts (t1 $ t2) = Some T›*) ‹typ_of1 Ts t1 = Some (RT → T)› (*‹typ_of1 Ts t1 = Some (RT → T)›*) typ_of1_fun_typ (*‹⟦typ_of1 ?Ts (?t $ ?u) = Some ?R; typ_of1 ?Ts ?t = Some (?U → ?R)⟧ ⟹ typ_of1 ?Ts ?u = Some ?U›*) by blast ultimately show "?case" (*goal: ‹typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (t1 $ t2)) = Some (subst_typ insts T)›*) by simp qed ((fastforce split: if_splits (*‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹(?P::?'a ⇒ bool) (if ?Q::bool then ?x::?'a else (?y::?'a)) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*) simp add: bind_eq_Some_conv (*‹(Option.bind (?f::?'b option) (?g::?'b ⇒ ?'a option) = Some (?x::?'a)) = (∃y::?'b. ?f = Some y ∧ ?g y = Some ?x)›*))+) (*solves the remaining goals: 1. ‹⋀x1 x2 T Ts. typ_of1 Ts (Ct x1 x2) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Ct x1 x2)) = Some (subst_typ insts T)› 2. ‹⋀x1 x2 T Ts. typ_of1 Ts (Fv x1 x2) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Fv x1 x2)) = Some (subst_typ insts T)› 3. ‹⋀x T Ts. typ_of1 Ts (Bv x) = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Bv x)) = Some (subst_typ insts T)› 4. ‹⋀x1 t T Ts. ⟦⋀T Ts. typ_of1 Ts t = Some T ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts t) = Some (subst_typ insts T); typ_of1 Ts (Abs x1 t) = Some T⟧ ⟹ typ_of1 (map (subst_typ insts) Ts) (subst_typ' insts (Abs x1 t)) = Some (subst_typ insts T)›*) corollary subst_typ_preserves_Some_typ_of: assumes "typ_of t = Some T" shows "typ_of (subst_typ' insts t) = Some (subst_typ insts T)" using assms (*‹typ_of (t::Core.term) = Some (T::typ)›*) subst_typ_preserves_Some_typ_of1 (*‹typ_of1 ?Ts ?t = Some ?T ⟹ typ_of1 (map (subst_typ ?insts) ?Ts) (subst_typ' ?insts ?t) = Some (subst_typ ?insts ?T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*) by fastforce lemma subst_typ'_incr_bv: "subst_typ' insts (incr_bv inc lev t) = incr_bv inc lev (subst_typ' insts t)" apply (induction inc lev t rule: incr_bv.induct (*‹⟦⋀(inc::nat) (n::nat) i::nat. (?P::nat ⇒ nat ⇒ Core.term ⇒ bool) inc n (Bv i); ⋀(inc::nat) (n::nat) (T::typ) body::Core.term. ?P inc (n + (1::nat)) body ⟹ ?P inc n (Abs T body); ⋀(inc::nat) (n::nat) (f::Core.term) t::Core.term. ⟦?P inc n f; ?P inc n t⟧ ⟹ ?P inc n (f $ t); ⋀(uu_::nat) (uv_::nat) (v::String.literal) va::typ. ?P uu_ uv_ (Ct v va); ⋀(uu_::nat) (uv_::nat) (v::variable) va::typ. ?P uu_ uv_ (Fv v va)⟧ ⟹ ?P (?a0.0::nat) (?a1.0::nat) (?a2.0::Core.term)›*)) (*goals: 1. ‹⋀inc n i. subst_typ' insts (incr_bv inc n (Bv i)) = incr_bv inc n (subst_typ' insts (Bv i))› 2. ‹⋀inc n T body. subst_typ' insts (incr_bv inc (n + 1) body) = incr_bv inc (n + 1) (subst_typ' insts body) ⟹ subst_typ' insts (incr_bv inc n (Abs T body)) = incr_bv inc n (subst_typ' insts (Abs T body))› 3. ‹⋀inc n f t. ⟦subst_typ' insts (incr_bv inc n f) = incr_bv inc n (subst_typ' insts f); subst_typ' insts (incr_bv inc n t) = incr_bv inc n (subst_typ' insts t)⟧ ⟹ subst_typ' insts (incr_bv inc n (f $ t)) = incr_bv inc n (subst_typ' insts (f $ t))› 4. ‹⋀uu_ uv_ v va. subst_typ' insts (incr_bv uu_ uv_ (Ct v va)) = incr_bv uu_ uv_ (subst_typ' insts (Ct v va))› 5. ‹⋀uu_ uv_ v va. subst_typ' insts (incr_bv uu_ uv_ (Fv v va)) = incr_bv uu_ uv_ (subst_typ' insts (Fv v va))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma subst_typ'_incr_boundvars: "subst_typ' insts (incr_boundvars lev t) = incr_boundvars lev (subst_typ' insts t)" using subst_typ'_incr_bv (*‹subst_typ' ?insts (incr_bv ?inc ?lev ?t) = incr_bv ?inc ?lev (subst_typ' ?insts ?t)›*) incr_boundvars_def (*‹incr_boundvars ?inc ?t = incr_bv ?inc 0 ?t›*) by simp lemma subst_typ'_subst_bv1: "subst_typ' insts (subst_bv1 t n u) = subst_bv1 (subst_typ' insts t) n (subst_typ' insts u)" apply (induction t n u rule: subst_bv1.induct (*‹⟦⋀i lev u. ?P (Bv i) lev u; ⋀T body lev u. ?P body (lev + 1) u ⟹ ?P (Abs T body) lev u; ⋀f t lev u. ⟦?P f lev u; ?P t lev u⟧ ⟹ ?P (f $ t) lev u; ⋀v va uu_ uv_. ?P (Ct v va) uu_ uv_; ⋀v va uu_ uv_. ?P (Fv v va) uu_ uv_⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0›*)) (*goals: 1. ‹⋀i lev u. subst_typ' insts (subst_bv1 (Bv i) lev u) = subst_bv1 (subst_typ' insts (Bv i)) lev (subst_typ' insts u)› 2. ‹⋀T body lev u. subst_typ' insts (subst_bv1 body (lev + 1) u) = subst_bv1 (subst_typ' insts body) (lev + 1) (subst_typ' insts u) ⟹ subst_typ' insts (subst_bv1 (Abs T body) lev u) = subst_bv1 (subst_typ' insts (Abs T body)) lev (subst_typ' insts u)› 3. ‹⋀f t lev u. ⟦subst_typ' insts (subst_bv1 f lev u) = subst_bv1 (subst_typ' insts f) lev (subst_typ' insts u); subst_typ' insts (subst_bv1 t lev u) = subst_bv1 (subst_typ' insts t) lev (subst_typ' insts u)⟧ ⟹ subst_typ' insts (subst_bv1 (f $ t) lev u) = subst_bv1 (subst_typ' insts (f $ t)) lev (subst_typ' insts u)› 4. ‹⋀v va uu_ uv_. subst_typ' insts (subst_bv1 (Ct v va) uu_ uv_) = subst_bv1 (subst_typ' insts (Ct v va)) uu_ (subst_typ' insts uv_)› 5. ‹⋀v va uu_ uv_. subst_typ' insts (subst_bv1 (Fv v va) uu_ uv_) = subst_bv1 (subst_typ' insts (Fv v va)) uu_ (subst_typ' insts uv_)› discuss goal 1*) apply ((auto simp add: subst_typ'_incr_boundvars (*‹subst_typ' ?insts (incr_boundvars ?lev ?t) = incr_boundvars ?lev (subst_typ' ?insts ?t)›*))[1]) (*discuss goal 2*) apply ((auto simp add: subst_typ'_incr_boundvars (*‹subst_typ' (?insts::((variable × String.literal set) × typ) list) (incr_boundvars (?lev::nat) (?t::Core.term)) = incr_boundvars ?lev (subst_typ' ?insts ?t)›*))[1]) (*discuss goal 3*) apply ((auto simp add: subst_typ'_incr_boundvars (*‹subst_typ' ?insts (incr_boundvars ?lev ?t) = incr_boundvars ?lev (subst_typ' ?insts ?t)›*))[1]) (*discuss goal 4*) apply ((auto simp add: subst_typ'_incr_boundvars (*‹subst_typ' (?insts::((variable × String.literal set) × typ) list) (incr_boundvars (?lev::nat) (?t::Core.term)) = incr_boundvars ?lev (subst_typ' ?insts ?t)›*))[1]) (*discuss goal 5*) apply ((auto simp add: subst_typ'_incr_boundvars (*‹subst_typ' ?insts (incr_boundvars ?lev ?t) = incr_boundvars ?lev (subst_typ' ?insts ?t)›*))[1]) (*proven 5 subgoals*) . lemma subst_typ'_subst_bv: "subst_typ' insts (subst_bv t u) = subst_bv (subst_typ' insts t) (subst_typ' insts u)" using subst_typ'_subst_bv1 (*‹subst_typ' (?insts::((variable × String.literal set) × typ) list) (subst_bv1 (?t::Core.term) (?n::nat) (?u::Core.term)) = subst_bv1 (subst_typ' ?insts ?t) ?n (subst_typ' ?insts ?u)›*) subst_bv_def (*‹subst_bv ?u ?t ≡ subst_bv1 ?t 0 ?u›*) by simp lemma subst_typ_no_tvsT_unchanged: "∀(f, s) ∈ set insts . f ∉ tvsT T ⟹ subst_typ insts T = T" proof (induction T) (*goals: 1. ‹⋀x1 x2. ⟦⋀x2a. ⟦x2a ∈ set x2; ∀(f, s)∈set insts. f ∉ tvsT x2a⟧ ⟹ subst_typ insts x2a = x2a; ∀(f, s)∈set insts. f ∉ tvsT (Ty x1 x2)⟧ ⟹ subst_typ insts (Ty x1 x2) = Ty x1 x2› 2. ‹⋀x1 x2. ∀(f, s)∈set insts. f ∉ tvsT (Tv x1 x2) ⟹ subst_typ insts (Tv x1 x2) = Tv x1 x2›*) case (Ty n Ts) (*‹⟦?x2a ∈ set Ts; ∀a∈set insts. case a of (f, s) ⇒ f ∉ tvsT ?x2a⟧ ⟹ subst_typ insts ?x2a = ?x2a› ‹∀a∈set insts. case a of (f, s) ⇒ f ∉ tvsT (Ty n Ts)›*) then show "?case" (*goal: ‹subst_typ insts (Ty n Ts) = Ty n Ts›*) apply (induction Ts) (*goals: 1. ‹⟦⋀x2a. ⟦x2a ∈ set []; ∀(f, s)∈set insts. f ∉ tvsT x2a⟧ ⟹ subst_typ insts x2a = x2a; ∀(f, s)∈set insts. f ∉ tvsT (constT n)⟧ ⟹ subst_typ insts (constT n) = constT n› 2. ‹⋀a Ts. ⟦⟦⋀x2a. ⟦x2a ∈ set Ts; ∀(f, s)∈set insts. f ∉ tvsT x2a⟧ ⟹ subst_typ insts x2a = x2a; ∀(f, s)∈set insts. f ∉ tvsT (Ty n Ts)⟧ ⟹ subst_typ insts (Ty n Ts) = Ty n Ts; ⋀x2a. ⟦x2a ∈ set (a # Ts); ∀(f, s)∈set insts. f ∉ tvsT x2a⟧ ⟹ subst_typ insts x2a = x2a; ∀(f, s)∈set insts. f ∉ tvsT (Ty n (a # Ts))⟧ ⟹ subst_typ insts (Ty n (a # Ts)) = Ty n (a # Ts)› discuss goal 1*) apply (fastforce split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*discuss goal 2*) apply (fastforce split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*proven 2 subgoals*) . next (*goal: ‹⋀x1 x2. ∀(f, s)∈set insts. f ∉ tvsT (Tv x1 x2) ⟹ subst_typ insts (Tv x1 x2) = Tv x1 x2›*) case (Tv idn S) (*‹∀a::(variable × String.literal set) × typ∈set (insts::((variable × String.literal set) × typ) list). case a of (f::variable × String.literal set, s::typ) ⇒ f ∉ tvsT (Tv (idn::variable) (S::String.literal set))›*) then show "?case" (*goal: ‹subst_typ insts (Tv idn S) = Tv idn S›*) apply simp (*goal: ‹subst_typ insts (Tv idn S) = Tv idn S›*) by (smt case_prodD (*‹case (?a, ?b) of (c, d) ⇒ ?f c d ⟹ ?f ?a ?b›*) case_prodE (*‹⟦case ?p of (a, b) ⇒ ?c a b; ⋀x y. ⟦?p = (x, y); ?c x y⟧ ⟹ ?Q⟧ ⟹ ?Q›*) find_None_iff (*‹(List.find ?P ?xs = None) = (∄x. x ∈ set ?xs ∧ ?P x)›*) lookup_None_iff_find_None (*‹(lookup ?P ?xs = None) = (List.find (λ(k, uu_). ?P k) ?xs = None)›*) the_default.simps( (*‹the_default ?a None = ?a›*) 1)) qed lemma subst_typ'_no_tvs_unchanged: "∀(f, s) ∈ set insts . f ∉ tvs t ⟹ subst_typ' insts t = t" apply (induction t) (*goals: 1. ‹⋀x1 x2. ∀(f, s)∈set insts. f ∉ tvs (Ct x1 x2) ⟹ subst_typ' insts (Ct x1 x2) = Ct x1 x2› 2. ‹⋀x1 x2. ∀(f, s)∈set insts. f ∉ tvs (Fv x1 x2) ⟹ subst_typ' insts (Fv x1 x2) = Fv x1 x2› 3. ‹⋀x. ∀(f, s)∈set insts. f ∉ tvs (Bv x) ⟹ subst_typ' insts (Bv x) = Bv x› 4. ‹⋀x1 t. ⟦∀(f, s)∈set insts. f ∉ tvs t ⟹ subst_typ' insts t = t; ∀(f, s)∈set insts. f ∉ tvs (Abs x1 t)⟧ ⟹ subst_typ' insts (Abs x1 t) = Abs x1 t› 5. ‹⋀t1 t2. ⟦∀(f, s)∈set insts. f ∉ tvs t1 ⟹ subst_typ' insts t1 = t1; ∀(f, s)∈set insts. f ∉ tvs t2 ⟹ subst_typ' insts t2 = t2; ∀(f, s)∈set insts. f ∉ tvs (t1 $ t2)⟧ ⟹ subst_typ' insts (t1 $ t2) = t1 $ t2› discuss goal 1*) apply ((use subst_typ_no_tvsT_unchanged in ‹fastforce+›)[1]) (*discuss goal 2*) apply ((use subst_typ_no_tvsT_unchanged in ‹fastforce+›)[1]) (*discuss goal 3*) apply ((use subst_typ_no_tvsT_unchanged in ‹fastforce+›)[1]) (*discuss goal 4*) apply ((use subst_typ_no_tvsT_unchanged in ‹fastforce+›)[1]) (*discuss goal 5*) apply ((use subst_typ_no_tvsT_unchanged in ‹fastforce+›)[1]) (*proven 5 subgoals*) . (* This is weaker than the previously proved version, but probably easier to use... *) lemma subst_typ'_preserves_term_ok': assumes "wf_theory Θ" assumes "inst_ok Θ insts" assumes "term_ok' (sig Θ) t" shows "term_ok' (sig Θ) (subst_typ' insts t)" using assms (*‹wf_theory Θ› ‹inst_ok Θ insts› ‹term_ok' (sig Θ) t›*) term_ok'_subst_typ' (*‹⟦is_std_sig ?Σ; term_ok' ?Σ ?t; distinct (map fst ?insts); list_all (typ_ok_sig ?Σ) (map snd ?insts)⟧ ⟹ term_ok' ?Σ (subst_typ' ?insts ?t)›*) typ_ok_def (*‹typ_ok (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (?T::typ) ≡ wf_type (sig ?Θ) ?T›*) by (metis list.pred_mono_strong (*‹⟦list_all ?P ?x; ⋀z. ⟦z ∈ set ?x; ?P z⟧ ⟹ ?Pa z⟧ ⟹ list_all ?Pa ?x›*) wf_theory_imp_is_std_sig (*‹wf_theory ?Θ ⟹ is_std_sig (sig ?Θ)›*) wf_type_imp_typ_ok_sig (*‹wf_type ?Σ ?T ⟹ typ_ok_sig ?Σ ?T›*)) lemma subst_typ'_preserves_term_ok: assumes "wf_theory Θ" assumes "inst_ok Θ insts" assumes "term_ok Θ t" shows "term_ok Θ (subst_typ' insts t)" using assms (*‹wf_theory Θ› ‹inst_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (insts::((variable × String.literal set) × typ) list)› ‹term_ok Θ t›*) subst_typ_preserves_Some_typ_of (*‹typ_of (?t::Core.term) = Some (?T::typ) ⟹ typ_of (subst_typ' (?insts::((variable × String.literal set) × typ) list) ?t) = Some (subst_typ ?insts ?T)›*) wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) subst_typ'_preserves_term_ok' (*‹⟦wf_theory (?Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set); inst_ok ?Θ (?insts::((variable × String.literal set) × typ) list); term_ok' (sig ?Θ) (?t::Core.term)⟧ ⟹ term_ok' (sig ?Θ) (subst_typ' ?insts ?t)›*) by auto lemma subst_typ_rename_vars_cancel: assumes "y ∉ fst ` tvsT T" shows "subst_typ [((y,S), Tv x S)] (subst_typ [((x,S), Tv y S)] T) = T" using assms (*‹y ∉ fst ` tvsT T›*) proof (induction T) (*goals: 1. ‹⋀x1 x2. ⟦⋀x2a. ⟦x2a ∈ set x2; y ∉ fst ` tvsT x2a⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] x2a) = x2a; y ∉ fst ` tvsT (Ty x1 x2)⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] (Ty x1 x2)) = Ty x1 x2› 2. ‹⋀x1 x2. y ∉ fst ` tvsT (Tv x1 x2) ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] (Tv x1 x2)) = Tv x1 x2›*) case (Ty n Ts) (*‹⟦?x2a ∈ set Ts; y ∉ fst ` tvsT ?x2a⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] ?x2a) = ?x2a› ‹y ∉ fst ` tvsT (Ty n Ts)›*) then show "?case" (*goal: ‹subst_typ [((y::variable, S::String.literal set), Tv (x::variable) S)] (subst_typ [((x, S), Tv y S)] (Ty (n::String.literal) (Ts::typ list))) = Ty n Ts›*) apply (induction Ts) (*goals: 1. ‹⟦⋀x2a. ⟦x2a ∈ set []; y ∉ fst ` tvsT x2a⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] x2a) = x2a; y ∉ fst ` tvsT (constT n)⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] (constT n)) = constT n› 2. ‹⋀a Ts. ⟦⟦⋀x2a. ⟦x2a ∈ set Ts; y ∉ fst ` tvsT x2a⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] x2a) = x2a; y ∉ fst ` tvsT (Ty n Ts)⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] (Ty n Ts)) = Ty n Ts; ⋀x2a. ⟦x2a ∈ set (a # Ts); y ∉ fst ` tvsT x2a⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] x2a) = x2a; y ∉ fst ` tvsT (Ty n (a # Ts))⟧ ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] (Ty n (a # Ts))) = Ty n (a # Ts)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . qed (auto) (*solved the remaining goal: ‹⋀x1 x2. y ∉ fst ` tvsT (Tv x1 x2) ⟹ subst_typ [((y, S), Tv x S)] (subst_typ [((x, S), Tv y S)] (Tv x1 x2)) = Tv x1 x2›*) lemma subst_typ'_rename_tvars_cancel: assumes "y ∉ fst ` tvs t" assumes "y ∉ fst ` tvsT τ" shows "subst_typ' [((y,S), Tv x S)] ((bind_fv2 (x, subst_typ [((x,S), Tv y S)] τ)) lev (subst_typ' [((x,S), Tv y S)] t)) = bind_fv2 (x, τ) lev t" using assms (*‹y ∉ fst ` tvs t› ‹(y::variable) ∉ fst ` tvsT (τ::typ)›*) proof (induction t arbitrary: lev) (*goals: 1. ‹⋀x1 x2 lev. ⟦y ∉ fst ` tvs (Ct x1 x2); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Ct x1 x2))) = bind_fv2 (x, τ) lev (Ct x1 x2)› 2. ‹⋀x1 x2 lev. ⟦y ∉ fst ` tvs (Fv x1 x2); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, τ) lev (Fv x1 x2)› 3. ‹⋀xa lev. ⟦y ∉ fst ` tvs (Bv xa); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, τ) lev (Bv xa)› 4. ‹⋀x1 t lev. ⟦⋀lev. ⟦y ∉ fst ` tvs t; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, τ) lev t; y ∉ fst ` tvs (Abs x1 t); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, τ) lev (Abs x1 t)› 5. ‹⋀t1 t2 lev. ⟦⋀lev. ⟦y ∉ fst ` tvs t1; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, τ) lev t1; ⋀lev. ⟦y ∉ fst ` tvs t2; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, τ) lev t2; y ∉ fst ` tvs (t1 $ t2); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, τ) lev (t1 $ t2)›*) case (Ct n T) (*‹y ∉ fst ` tvs (Ct n T)› ‹y ∉ fst ` tvsT τ›*) then show "?case" (*goal: ‹subst_typ' [((y::variable, S::String.literal set), Tv (x::variable) S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] (τ::typ)) (lev::nat) (subst_typ' [((x, S), Tv y S)] (Ct (n::String.literal) (T::typ)))) = bind_fv2 (x, τ) lev (Ct n T)›*) by (simp add: subst_typ_rename_vars_cancel (*‹?y ∉ fst ` tvsT ?T ⟹ subst_typ [((?y, ?S), Tv ?x ?S)] (subst_typ [((?x, ?S), Tv ?y ?S)] ?T) = ?T›*)) next (*goals: 1. ‹⋀(x1::variable) (x2::typ) lev::nat. ⟦(y::variable) ∉ fst ` tvs (Fv x1 x2); y ∉ fst ` tvsT (τ::typ)⟧ ⟹ subst_typ' [((y, S::String.literal set), Tv (x::variable) S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, τ) lev (Fv x1 x2)› 2. ‹⋀(xa::nat) lev::nat. ⟦(y::variable) ∉ fst ` tvs (Bv xa); y ∉ fst ` tvsT (τ::typ)⟧ ⟹ subst_typ' [((y, S::String.literal set), Tv (x::variable) S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, τ) lev (Bv xa)› 3. ‹⋀(x1::typ) (t::Core.term) lev::nat. ⟦⋀lev::nat. ⟦(y::variable) ∉ fst ` tvs t; y ∉ fst ` tvsT (τ::typ)⟧ ⟹ subst_typ' [((y, S::String.literal set), Tv (x::variable) S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, τ) lev t; y ∉ fst ` tvs (Abs x1 t); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, τ) lev (Abs x1 t)› 4. ‹⋀(t1::Core.term) (t2::Core.term) lev::nat. ⟦⋀lev::nat. ⟦(y::variable) ∉ fst ` tvs t1; y ∉ fst ` tvsT (τ::typ)⟧ ⟹ subst_typ' [((y, S::String.literal set), Tv (x::variable) S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, τ) lev t1; ⋀lev::nat. ⟦y ∉ fst ` tvs t2; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, τ) lev t2; y ∉ fst ` tvs (t1 $ t2); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, τ) lev (t1 $ t2)›*) case (Fv idn T) (*‹y ∉ fst ` tvs (Fv idn T)› ‹y ∉ fst ` tvsT τ›*) then show "?case" (*goal: ‹subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Fv idn T))) = bind_fv2 (x, τ) lev (Fv idn T)›*) apply (clarsimp simp add: subst_typ_rename_vars_cancel (*‹?y ∉ fst ` tvsT ?T ⟹ subst_typ [((?y, ?S), Tv ?x ?S)] (subst_typ [((?x, ?S), Tv ?y ?S)] ?T) = ?T›*)) (*goal: ‹subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Fv idn T))) = bind_fv2 (x, τ) lev (Fv idn T)›*) by (metis subst_typ_rename_vars_cancel (*‹?y ∉ fst ` tvsT ?T ⟹ subst_typ [((?y, ?S), Tv ?x ?S)] (subst_typ [((?x, ?S), Tv ?y ?S)] ?T) = ?T›*)) next (*goals: 1. ‹⋀xa lev. ⟦y ∉ fst ` tvs (Bv xa); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, τ) lev (Bv xa)› 2. ‹⋀x1 t lev. ⟦⋀lev. ⟦y ∉ fst ` tvs t; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, τ) lev t; y ∉ fst ` tvs (Abs x1 t); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, τ) lev (Abs x1 t)› 3. ‹⋀t1 t2 lev. ⟦⋀lev. ⟦y ∉ fst ` tvs t1; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, τ) lev t1; ⋀lev. ⟦y ∉ fst ` tvs t2; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, τ) lev t2; y ∉ fst ` tvs (t1 $ t2); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, τ) lev (t1 $ t2)›*) case (Abs T t) (*‹⟦y ∉ fst ` tvs t; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) ?lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, τ) ?lev t› ‹(y::variable) ∉ fst ` tvs (Abs (T::typ) (t::Core.term))› ‹y ∉ fst ` tvsT τ›*) thus "?case" (*goal: ‹subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Abs T t))) = bind_fv2 (x, τ) lev (Abs T t)›*) by (simp add: image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*) subst_typ_rename_vars_cancel (*‹?y ∉ fst ` tvsT ?T ⟹ subst_typ [((?y, ?S), Tv ?x ?S)] (subst_typ [((?x, ?S), Tv ?y ?S)] ?T) = ?T›*)) next (*goals: 1. ‹⋀xa lev. ⟦y ∉ fst ` tvs (Bv xa); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, τ) lev (Bv xa)› 2. ‹⋀t1 t2 lev. ⟦⋀lev. ⟦y ∉ fst ` tvs t1; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, τ) lev t1; ⋀lev. ⟦y ∉ fst ` tvs t2; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, τ) lev t2; y ∉ fst ` tvs (t1 $ t2); y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, τ) lev (t1 $ t2)›*) case (App t1 t2) (*‹⟦y ∉ fst ` tvs t1; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) ?lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, τ) ?lev t1› ‹⟦y ∉ fst ` tvs t2; y ∉ fst ` tvsT τ⟧ ⟹ subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) ?lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, τ) ?lev t2› ‹y ∉ fst ` tvs (t1 $ t2)› ‹y ∉ fst ` tvsT τ›*) then show "?case" (*goal: ‹subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, τ) lev (t1 $ t2)›*) by (simp add: image_Un (*‹?f ` (?A ∪ ?B) = ?f ` ?A ∪ ?f ` ?B›*)) qed (auto) (*solved the remaining goal: ‹⋀(xa::nat) lev::nat. ⟦(y::variable) ∉ fst ` tvs (Bv xa); y ∉ fst ` tvsT (τ::typ)⟧ ⟹ subst_typ' [((y, S::String.literal set), Tv (x::variable) S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] τ) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, τ) lev (Bv xa)›*) lemma bind_fv2_renamed_var: assumes "y ∉ fst ` fv t" shows "bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t) = bind_fv2 (x, τ) i t" using assms (*‹y ∉ fst ` fv t›*) proof (induction t arbitrary: i) (*goals: 1. ‹⋀x1 x2 i. y ∉ fst ` fv (Ct x1 x2) ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Ct x1 x2)) = bind_fv2 (x, τ) i (Ct x1 x2)› 2. ‹⋀x1 x2 i. y ∉ fst ` fv (Fv x1 x2) ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Fv x1 x2)) = bind_fv2 (x, τ) i (Fv x1 x2)› 3. ‹⋀xa i. y ∉ fst ` fv (Bv xa) ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Bv xa)) = bind_fv2 (x, τ) i (Bv xa)› 4. ‹⋀x1 t i. ⟦⋀i. y ∉ fst ` fv t ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t) = bind_fv2 (x, τ) i t; y ∉ fst ` fv (Abs x1 t)⟧ ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Abs x1 t)) = bind_fv2 (x, τ) i (Abs x1 t)› 5. ‹⋀t1 t2 i. ⟦⋀i. y ∉ fst ` fv t1 ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t1) = bind_fv2 (x, τ) i t1; ⋀i. y ∉ fst ` fv t2 ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t2) = bind_fv2 (x, τ) i t2; y ∉ fst ` fv (t1 $ t2)⟧ ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (t1 $ t2)) = bind_fv2 (x, τ) i (t1 $ t2)›*) qed (auto) (*solves the remaining goals: 1. ‹⋀x1 x2 i. y ∉ fst ` fv (Ct x1 x2) ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Ct x1 x2)) = bind_fv2 (x, τ) i (Ct x1 x2)› 2. ‹⋀x1 x2 i. y ∉ fst ` fv (Fv x1 x2) ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Fv x1 x2)) = bind_fv2 (x, τ) i (Fv x1 x2)› 3. ‹⋀xa i. y ∉ fst ` fv (Bv xa) ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Bv xa)) = bind_fv2 (x, τ) i (Bv xa)› 4. ‹⋀x1 t i. ⟦⋀i. y ∉ fst ` fv t ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t) = bind_fv2 (x, τ) i t; y ∉ fst ` fv (Abs x1 t)⟧ ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (Abs x1 t)) = bind_fv2 (x, τ) i (Abs x1 t)› 5. ‹⋀t1 t2 i. ⟦⋀i. y ∉ fst ` fv t1 ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t1) = bind_fv2 (x, τ) i t1; ⋀i. y ∉ fst ` fv t2 ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] t2) = bind_fv2 (x, τ) i t2; y ∉ fst ` fv (t1 $ t2)⟧ ⟹ bind_fv2 (y, τ) i (subst_term [((x, τ), Fv y τ)] (t1 $ t2)) = bind_fv2 (x, τ) i (t1 $ t2)›*) lemma bind_fv_renamed_var: assumes "y ∉ fst ` fv t" shows "bind_fv (y, τ) (subst_term [((x, τ), Fv y τ)] t) = bind_fv (x, τ) t" using bind_fv2_renamed_var (*‹(?y::variable) ∉ fst ` fv (?t::Core.term) ⟹ bind_fv2 (?y, ?τ::typ) (?i::nat) (subst_term [((?x::variable, ?τ), Fv ?y ?τ)] ?t) = bind_fv2 (?x, ?τ) ?i ?t›*) bind_fv_def (*‹bind_fv (?vT::variable × typ) (?t::Core.term) = bind_fv2 ?vT (0::nat) ?t›*) assms (*‹y ∉ fst ` fv t›*) by auto lemma subst_typ'_rename_tvar_bind_fv2: assumes "y ∉ fst ` fv t" assumes "(b, S) ∉ tvs t" assumes "(b, S) ∉ tvsT τ" shows "bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a,S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t)) = subst_typ' [((a,S), Tv b S)] (bind_fv2 (x, τ) i t)" using assms (*‹y ∉ fst ` fv t› ‹(b, S) ∉ tvs t› ‹(b, S) ∉ tvsT τ›*) proof (induction t arbitrary: i) (*goals: 1. ‹⋀x1 x2 i. ⟦y ∉ fst ` fv (Ct x1 x2); (b, S) ∉ tvs (Ct x1 x2); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Ct x1 x2))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Ct x1 x2))› 2. ‹⋀x1 x2 i. ⟦y ∉ fst ` fv (Fv x1 x2); (b, S) ∉ tvs (Fv x1 x2); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Fv x1 x2))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Fv x1 x2))› 3. ‹⋀xa i. ⟦y ∉ fst ` fv (Bv xa); (b, S) ∉ tvs (Bv xa); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Bv xa))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Bv xa))› 4. ‹⋀x1 t i. ⟦⋀i. ⟦y ∉ fst ` fv t; (b, S) ∉ tvs t; (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t)) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i t); y ∉ fst ` fv (Abs x1 t); (b, S) ∉ tvs (Abs x1 t); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Abs x1 t))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Abs x1 t))› 5. ‹⋀t1 t2 i. ⟦⋀i. ⟦y ∉ fst ` fv t1; (b, S) ∉ tvs t1; (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t1)) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i t1); ⋀i. ⟦y ∉ fst ` fv t2; (b, S) ∉ tvs t2; (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t2)) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i t2); y ∉ fst ` fv (t1 $ t2); (b, S) ∉ tvs (t1 $ t2); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (t1 $ t2))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (t1 $ t2))›*) qed (auto) (*solves the remaining goals: 1. ‹⋀x1 x2 i. ⟦y ∉ fst ` fv (Ct x1 x2); (b, S) ∉ tvs (Ct x1 x2); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Ct x1 x2))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Ct x1 x2))› 2. ‹⋀x1 x2 i. ⟦y ∉ fst ` fv (Fv x1 x2); (b, S) ∉ tvs (Fv x1 x2); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Fv x1 x2))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Fv x1 x2))› 3. ‹⋀xa i. ⟦y ∉ fst ` fv (Bv xa); (b, S) ∉ tvs (Bv xa); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Bv xa))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Bv xa))› 4. ‹⋀x1 t i. ⟦⋀i. ⟦y ∉ fst ` fv t; (b, S) ∉ tvs t; (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t)) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i t); y ∉ fst ` fv (Abs x1 t); (b, S) ∉ tvs (Abs x1 t); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (Abs x1 t))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (Abs x1 t))› 5. ‹⋀t1 t2 i. ⟦⋀i. ⟦y ∉ fst ` fv t1; (b, S) ∉ tvs t1; (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t1)) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i t1); ⋀i. ⟦y ∉ fst ` fv t2; (b, S) ∉ tvs t2; (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t2)) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i t2); y ∉ fst ` fv (t1 $ t2); (b, S) ∉ tvs (t1 $ t2); (b, S) ∉ tvsT τ⟧ ⟹ bind_fv2 (y, subst_typ [((a, S), Tv b S)] τ) i (subst_typ' [((a, S), Tv b S)] (subst_term [((x, τ), Fv y τ)] (t1 $ t2))) = subst_typ' [((a, S), Tv b S)] (bind_fv2 (x, τ) i (t1 $ t2))›*) lemma subst_typ'_rename_tvar_bind_fv: assumes "y ∉ fst ` fv t" assumes "(b, S) ∉ tvs t" assumes "(b, S) ∉ tvsT τ" shows "bind_fv (y, subst_typ [((a,S), Tv b S)] τ) (subst_typ' [((a,S), Tv b S)] (subst_term [((x, τ), Fv y τ)] t)) = subst_typ' [((a,S), Tv b S)] (bind_fv (x, τ) t)" using bind_fv_def (*‹bind_fv ?vT ?t = bind_fv2 ?vT 0 ?t›*) assms (*‹y ∉ fst ` fv t› ‹(b, S) ∉ tvs t› ‹(b::variable, S::String.literal set) ∉ tvsT (τ::typ)›*) subst_typ'_rename_tvar_bind_fv2 (*‹⟦(?y::variable) ∉ fst ` fv (?t::Core.term); (?b::variable, ?S::String.literal set) ∉ tvs ?t; (?b, ?S) ∉ tvsT (?τ::typ)⟧ ⟹ bind_fv2 (?y, subst_typ [((?a::variable, ?S), Tv ?b ?S)] ?τ) (?i::nat) (subst_typ' [((?a, ?S), Tv ?b ?S)] (subst_term [((?x::variable, ?τ), Fv ?y ?τ)] ?t)) = subst_typ' [((?a, ?S), Tv ?b ?S)] (bind_fv2 (?x, ?τ) ?i ?t)›*) by auto lemma tvar_in_fv_in_tvs: "(a, τ) ∈ fv B ⟹ (x, S) ∈ tvsT τ ⟹ (x, S) ∈ tvs B" apply (induction B) (*goals: 1. ‹⋀x1 x2. ⟦(a, τ) ∈ fv (Ct x1 x2); (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs (Ct x1 x2)› 2. ‹⋀x1 x2. ⟦(a, τ) ∈ fv (Fv x1 x2); (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs (Fv x1 x2)› 3. ‹⋀xa. ⟦(a, τ) ∈ fv (Bv xa); (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs (Bv xa)› 4. ‹⋀x1 B. ⟦⟦(a, τ) ∈ fv B; (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs B; (a, τ) ∈ fv (Abs x1 B); (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs (Abs x1 B)› 5. ‹⋀B1 B2. ⟦⟦(a, τ) ∈ fv B1; (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs B1; ⟦(a, τ) ∈ fv B2; (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs B2; (a, τ) ∈ fv (B1 $ B2); (x, S) ∈ tvsT τ⟧ ⟹ (x, S) ∈ tvs (B1 $ B2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma tvs_bind_fv2_subset: "tvs (bind_fv2 (a, τ) i B) ⊆ tvs B" apply (induction B arbitrary: i) (*goals: 1. ‹⋀(x1::String.literal) (x2::typ) i::nat. tvs (bind_fv2 (a::variable, τ::typ) i (Ct x1 x2)) ⊆ tvs (Ct x1 x2)› 2. ‹⋀(x1::variable) (x2::typ) i::nat. tvs (bind_fv2 (a::variable, τ::typ) i (Fv x1 x2)) ⊆ tvs (Fv x1 x2)› 3. ‹⋀(x::nat) i::nat. tvs (bind_fv2 (a::variable, τ::typ) i (Bv x)) ⊆ tvs (Bv x)› 4. ‹⋀(x1::typ) (B::Core.term) i::nat. (⋀i::nat. tvs (bind_fv2 (a::variable, τ::typ) i B) ⊆ tvs B) ⟹ tvs (bind_fv2 (a, τ) i (Abs x1 B)) ⊆ tvs (Abs x1 B)› 5. ‹⋀(B1::Core.term) (B2::Core.term) i::nat. ⟦⋀i::nat. tvs (bind_fv2 (a::variable, τ::typ) i B1) ⊆ tvs B1; ⋀i::nat. tvs (bind_fv2 (a, τ) i B2) ⊆ tvs B2⟧ ⟹ tvs (bind_fv2 (a, τ) i (B1 $ B2)) ⊆ tvs (B1 $ B2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma tvs_bind_fv_subset: "tvs (bind_fv (a, τ) B) ⊆ tvs B" using tvs_bind_fv2_subset (*‹tvs (bind_fv2 (?a, ?τ) ?i ?B) ⊆ tvs ?B›*) bind_fv_def (*‹bind_fv ?vT ?t = bind_fv2 ?vT 0 ?t›*) by simp lemma subst_typ_rename_tvar_preserves_eq: "(y, S) ∉ tvsT T ⟹ (y, S) ∉ tvsT τ ⟹ subst_typ [((x, S), Tv y S)] T = subst_typ [((x, S), Tv y S)] τ ⟹ T=τ" proof (induction T arbitrary: τ) (*goals: 1. ‹⋀(x1::String.literal) (x2::typ list) τ::typ. ⟦⋀(x2a::typ) τ::typ. ⟦x2a ∈ set x2; (y::variable, S::String.literal set) ∉ tvsT x2a; (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] x2a = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ x2a = τ; (y, S) ∉ tvsT (Ty x1 x2); (y, S) ∉ tvsT τ; subst_typ [((x, S), Tv y S)] (Ty x1 x2) = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ Ty x1 x2 = τ› 2. ‹⋀(x1::variable) (x2::String.literal set) τ::typ. ⟦(y::variable, S::String.literal set) ∉ tvsT (Tv x1 x2); (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] (Tv x1 x2) = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ Tv x1 x2 = τ›*) case (Ty n Ts) (*‹⟦?x2a ∈ set Ts; (y, S) ∉ tvsT ?x2a; (y, S) ∉ tvsT ?τ; subst_typ [((x, S), Tv y S)] ?x2a = subst_typ [((x, S), Tv y S)] ?τ⟧ ⟹ ?x2a = ?τ› ‹(y::variable, S::String.literal set) ∉ tvsT (Ty (n::String.literal) (Ts::typ list))› ‹(y, S) ∉ tvsT τ› ‹subst_typ [((x::variable, S::String.literal set), Tv (y::variable) S)] (Ty (n::String.literal) (Ts::typ list)) = subst_typ [((x, S), Tv y S)] (τ::typ)›*) then show "?case" (*goal: ‹Ty n Ts = τ›*) proof (induction τ) (*goals: 1. ‹⋀(x1::String.literal) x2::typ list. ⟦⋀x2a::typ. ⟦x2a ∈ set x2; ⋀(x2a::typ) τ::typ. ⟦x2a ∈ set (Ts::typ list); (y::variable, S::String.literal set) ∉ tvsT x2a; (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] x2a = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ x2a = τ; (y, S) ∉ tvsT (Ty (n::String.literal) Ts); (y, S) ∉ tvsT x2a; subst_typ [((x, S), Tv y S)] (Ty n Ts) = subst_typ [((x, S), Tv y S)] x2a⟧ ⟹ Ty n Ts = x2a; ⋀(x2a::typ) τ::typ. ⟦x2a ∈ set Ts; (y, S) ∉ tvsT x2a; (y, S) ∉ tvsT τ; subst_typ [((x, S), Tv y S)] x2a = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ x2a = τ; (y, S) ∉ tvsT (Ty n Ts); (y, S) ∉ tvsT (Ty x1 x2); subst_typ [((x, S), Tv y S)] (Ty n Ts) = subst_typ [((x, S), Tv y S)] (Ty x1 x2)⟧ ⟹ Ty n Ts = Ty x1 x2› 2. ‹⋀(x1::variable) x2::String.literal set. ⟦⋀(x2a::typ) τ::typ. ⟦x2a ∈ set (Ts::typ list); (y::variable, S::String.literal set) ∉ tvsT x2a; (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] x2a = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ x2a = τ; (y, S) ∉ tvsT (Ty (n::String.literal) Ts); (y, S) ∉ tvsT (Tv x1 x2); subst_typ [((x, S), Tv y S)] (Ty n Ts) = subst_typ [((x, S), Tv y S)] (Tv x1 x2)⟧ ⟹ Ty n Ts = Tv x1 x2›*) case (Ty n Ts) (*‹⟦(?x2a::typ) ∈ set (Ts::typ list); ⋀(x2a::typ) τ::typ. ⟦x2a ∈ set (Ts__::typ list); (y::variable, S::String.literal set) ∉ tvsT x2a; (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] x2a = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ x2a = τ; (y, S) ∉ tvsT (Ty (n__::String.literal) Ts__); (y, S) ∉ tvsT ?x2a; subst_typ [((x, S), Tv y S)] (Ty n__ Ts__) = subst_typ [((x, S), Tv y S)] ?x2a⟧ ⟹ Ty n__ Ts__ = ?x2a› ‹⟦?x2a ∈ set Ts__; (y, S) ∉ tvsT ?x2a; (y, S) ∉ tvsT ?τ; subst_typ [((x, S), Tv y S)] ?x2a = subst_typ [((x, S), Tv y S)] ?τ⟧ ⟹ ?x2a = ?τ› ‹(y, S) ∉ tvsT (Ty n__ Ts__)› ‹(y, S) ∉ tvsT (Ty n Ts)› ‹subst_typ [((x, S), Tv y S)] (Ty n__ Ts__) = subst_typ [((x, S), Tv y S)] (Ty n Ts)›*) then show "?case" (*goal: ‹Ty (n__::String.literal) (Ts__::typ list) = Ty (n::String.literal) (Ts::typ list)›*) apply simp (*goal: ‹Ty n__ Ts__ = Ty n Ts›*) by (smt list.inj_map_strong (*‹⟦⋀z za. ⟦z ∈ set ?x; za ∈ set ?xa; ?f z = ?fa za⟧ ⟹ z = za; map ?f ?x = map ?fa ?xa⟧ ⟹ ?x = ?xa›*)) next (*goal: ‹⋀(x1::variable) x2::String.literal set. ⟦⋀(x2a::typ) τ::typ. ⟦x2a ∈ set (Ts::typ list); (y::variable, S::String.literal set) ∉ tvsT x2a; (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] x2a = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ x2a = τ; (y, S) ∉ tvsT (Ty (n::String.literal) Ts); (y, S) ∉ tvsT (Tv x1 x2); subst_typ [((x, S), Tv y S)] (Ty n Ts) = subst_typ [((x, S), Tv y S)] (Tv x1 x2)⟧ ⟹ Ty n Ts = Tv x1 x2›*) case (Tv n S) (*‹⟦?x2a ∈ set Ts; (y, S) ∉ tvsT ?x2a; (y, S) ∉ tvsT ?τ; subst_typ [((x, S), Tv y S)] ?x2a = subst_typ [((x, S), Tv y S)] ?τ⟧ ⟹ ?x2a = ?τ› ‹(y::variable, S::String.literal set) ∉ tvsT (Ty (n__::String.literal) (Ts::typ list))› ‹(y, S) ∉ tvsT (Tv n S)› ‹subst_typ [((x::variable, S::String.literal set), Tv (y::variable) S)] (Ty (n__::String.literal) (Ts::typ list)) = subst_typ [((x, S), Tv y S)] (Tv (n::variable) (S::String.literal set))›*) then show "?case" (*goal: ‹Ty (n__::String.literal) (Ts::typ list) = Tv (n::variable) (S::String.literal set)›*) by (auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) qed next (*goal: ‹⋀(x1::variable) (x2::String.literal set) τ::typ. ⟦(y::variable, S::String.literal set) ∉ tvsT (Tv x1 x2); (y, S) ∉ tvsT τ; subst_typ [((x::variable, S), Tv y S)] (Tv x1 x2) = subst_typ [((x, S), Tv y S)] τ⟧ ⟹ Tv x1 x2 = τ›*) case (Tv n S) (*‹(y, S) ∉ tvsT (Tv n S)› ‹(y, S) ∉ tvsT τ› ‹subst_typ [((x, S), Tv y S)] (Tv n S) = subst_typ [((x, S), Tv y S)] τ›*) then show "?case" (*goal: ‹Tv n S = τ›*) apply (induction τ) (*goals: 1. ‹⋀x1 x2. ⟦⋀x2a. ⟦x2a ∈ set x2; (y, S) ∉ tvsT (Tv n S); (y, S) ∉ tvsT x2a; subst_typ [((x, S), Tv y S)] (Tv n S) = subst_typ [((x, S), Tv y S)] x2a⟧ ⟹ Tv n S = x2a; (y, S) ∉ tvsT (Tv n S); (y, S) ∉ tvsT (Ty x1 x2); subst_typ [((x, S), Tv y S)] (Tv n S) = subst_typ [((x, S), Tv y S)] (Ty x1 x2)⟧ ⟹ Tv n S = Ty x1 x2› 2. ‹⋀x1 x2. ⟦(y, S) ∉ tvsT (Tv n S); (y, S) ∉ tvsT (Tv x1 x2); subst_typ [((x, S), Tv y S)] (Tv n S) = subst_typ [((x, S), Tv y S)] (Tv x1 x2)⟧ ⟹ Tv n S = Tv x1 x2› discuss goal 1*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*discuss goal 2*) apply ((auto split: if_splits (*‹?P (if ?Q then ?x else ?y) = ((?Q ⟶ ?P ?x) ∧ (¬ ?Q ⟶ ?P ?y))› ‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*))[1]) (*proven 2 subgoals*) . qed lemma subst_typ'_subst_term_rename_var_swap: assumes "b ∉ fst ` fv B" assumes "(y, S) ∉ tvs B" assumes "(y, S) ∉ tvsT τ" shows "subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] B) = subst_term [((a, (subst_typ [((x, S), Tv y S)] τ)), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B)" using assms (*‹(b::variable) ∉ fst ` fv (B::Core.term)› ‹(y, S) ∉ tvs B› ‹(y, S) ∉ tvsT τ›*) proof (induction B) (*goals: 1. ‹⋀(x1::String.literal) x2::typ. ⟦(b::variable) ∉ fst ` fv (Ct x1 x2); (y::variable, S::String.literal set) ∉ tvs (Ct x1 x2); (y, S) ∉ tvsT (τ::typ)⟧ ⟹ subst_typ' [((x::variable, S), Tv y S)] (subst_term [((a::variable, τ), Fv b τ)] (Ct x1 x2)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Ct x1 x2))› 2. ‹⋀(x1::variable) x2::typ. ⟦(b::variable) ∉ fst ` fv (Fv x1 x2); (y::variable, S::String.literal set) ∉ tvs (Fv x1 x2); (y, S) ∉ tvsT (τ::typ)⟧ ⟹ subst_typ' [((x::variable, S), Tv y S)] (subst_term [((a::variable, τ), Fv b τ)] (Fv x1 x2)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))› 3. ‹⋀xa::nat. ⟦(b::variable) ∉ fst ` fv (Bv xa); (y::variable, S::String.literal set) ∉ tvs (Bv xa); (y, S) ∉ tvsT (τ::typ)⟧ ⟹ subst_typ' [((x::variable, S), Tv y S)] (subst_term [((a::variable, τ), Fv b τ)] (Bv xa)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Bv xa))› 4. ‹⋀(x1::typ) B::Core.term. ⟦⟦(b::variable) ∉ fst ` fv B; (y::variable, S::String.literal set) ∉ tvs B; (y, S) ∉ tvsT (τ::typ)⟧ ⟹ subst_typ' [((x::variable, S), Tv y S)] (subst_term [((a::variable, τ), Fv b τ)] B) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B); b ∉ fst ` fv (Abs x1 B); (y, S) ∉ tvs (Abs x1 B); (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] (Abs x1 B)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Abs x1 B))› 5. ‹⋀(B1::Core.term) B2::Core.term. ⟦⟦(b::variable) ∉ fst ` fv B1; (y::variable, S::String.literal set) ∉ tvs B1; (y, S) ∉ tvsT (τ::typ)⟧ ⟹ subst_typ' [((x::variable, S), Tv y S)] (subst_term [((a::variable, τ), Fv b τ)] B1) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B1); ⟦b ∉ fst ` fv B2; (y, S) ∉ tvs B2; (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] B2) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B2); b ∉ fst ` fv (B1 $ B2); (y, S) ∉ tvs (B1 $ B2); (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] (B1 $ B2)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (B1 $ B2))›*) case (Fv idn T) (*‹b ∉ fst ` fv (Fv idn T)› ‹(y, S) ∉ tvs (Fv idn T)› ‹(y, S) ∉ tvsT τ›*) then show "?case" (*goal: ‹subst_typ' [((x::variable, S::String.literal set), Tv (y::variable) S)] (subst_term [((a::variable, τ::typ), Fv (b::variable) τ)] (Fv (idn::variable) (T::typ))) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Fv idn T))›*) using subst_typ_rename_tvar_preserves_eq (*‹⟦(?y, ?S) ∉ tvsT ?T; (?y, ?S) ∉ tvsT ?τ; subst_typ [((?x, ?S), Tv ?y ?S)] ?T = subst_typ [((?x, ?S), Tv ?y ?S)] ?τ⟧ ⟹ ?T = ?τ›*) by auto qed (auto) (*solves the remaining goals: 1. ‹⋀x1 x2. ⟦b ∉ fst ` fv (Ct x1 x2); (y, S) ∉ tvs (Ct x1 x2); (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] (Ct x1 x2)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Ct x1 x2))› 2. ‹⋀xa. ⟦b ∉ fst ` fv (Bv xa); (y, S) ∉ tvs (Bv xa); (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] (Bv xa)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Bv xa))› 3. ‹⋀x1 B. ⟦⟦b ∉ fst ` fv B; (y, S) ∉ tvs B; (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] B) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B); b ∉ fst ` fv (Abs x1 B); (y, S) ∉ tvs (Abs x1 B); (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] (Abs x1 B)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (Abs x1 B))› 4. ‹⋀B1 B2. ⟦⟦b ∉ fst ` fv B1; (y, S) ∉ tvs B1; (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] B1) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B1); ⟦b ∉ fst ` fv B2; (y, S) ∉ tvs B2; (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] B2) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] B2); b ∉ fst ` fv (B1 $ B2); (y, S) ∉ tvs (B1 $ B2); (y, S) ∉ tvsT τ⟧ ⟹ subst_typ' [((x, S), Tv y S)] (subst_term [((a, τ), Fv b τ)] (B1 $ B2)) = subst_term [((a, subst_typ [((x, S), Tv y S)] τ), Fv b (subst_typ [((x, S), Tv y S)] τ))] (subst_typ' [((x, S), Tv y S)] (B1 $ B2))›*) (* My naming needs work, also those lemmas might be subsumed *) lemma tvar_not_in_term_imp_free_not_in_term: "(y, S) ∈ tvsT τ ⟹ (y,S) ∉ tvs t ⟹ (a, τ) ∉ fv t" apply (induction t) (*goals: 1. ‹⋀x1 x2. ⟦(y, S) ∈ tvsT τ; (y, S) ∉ tvs (Ct x1 x2)⟧ ⟹ (a, τ) ∉ fv (Ct x1 x2)› 2. ‹⋀x1 x2. ⟦(y, S) ∈ tvsT τ; (y, S) ∉ tvs (Fv x1 x2)⟧ ⟹ (a, τ) ∉ fv (Fv x1 x2)› 3. ‹⋀x. ⟦(y, S) ∈ tvsT τ; (y, S) ∉ tvs (Bv x)⟧ ⟹ (a, τ) ∉ fv (Bv x)› 4. ‹⋀x1 t. ⟦⟦(y, S) ∈ tvsT τ; (y, S) ∉ tvs t⟧ ⟹ (a, τ) ∉ fv t; (y, S) ∈ tvsT τ; (y, S) ∉ tvs (Abs x1 t)⟧ ⟹ (a, τ) ∉ fv (Abs x1 t)› 5. ‹⋀t1 t2. ⟦⟦(y, S) ∈ tvsT τ; (y, S) ∉ tvs t1⟧ ⟹ (a, τ) ∉ fv t1; ⟦(y, S) ∈ tvsT τ; (y, S) ∉ tvs t2⟧ ⟹ (a, τ) ∉ fv t2; (y, S) ∈ tvsT τ; (y, S) ∉ tvs (t1 $ t2)⟧ ⟹ (a, τ) ∉ fv (t1 $ t2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . lemma tvar_not_in_term_imp_free_not_in_term_set: "finite Γ ⟹ (y, S) ∈ tvsT τ ⟹ (y,S) ∉ tvs_Set Γ ⟹ (a, τ) ∉ FV Γ" using tvar_not_in_term_imp_free_not_in_term (*‹⟦(?y::variable, ?S::String.literal set) ∈ tvsT (?τ::typ); (?y, ?S) ∉ tvs (?t::Core.term)⟧ ⟹ (?a::variable, ?τ) ∉ fv ?t›*) by simp (* I can probably weaken vars a bit, should only need wf criteria on insts, nothing more *) lemma inst_var_multiple: assumes wf_theory: "wf_theory Θ" assumes B: "Θ, Γ ⊢ B" assumes vars: "∀(x,τ)∈fst ` set insts . term_ok Θ (Fv x τ)" assumes a_ok: "∀a∈snd ` set insts . term_ok Θ a" assumes typ_a: "∀((_,τ), a)∈set insts . typ_of a = Some τ" assumes free: "∀(v, _)∈set insts . v ∉ FV Γ" assumes distinct: "distinct (map fst insts)" assumes finite: "finite Γ" shows "Θ, Γ ⊢ subst_term insts B" proof (-) (*goal: ‹Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set,Γ::Core.term set ⊢ subst_term (insts::((variable × typ) × Core.term) list) (B::Core.term)›*) obtain fresh_idns where fresh_idns: "length fresh_idns = length insts" "∀idn ∈ set fresh_idns . idn ∉ fst ` (fv B ∪ (⋃t∈snd ` set insts . (fv t)) ∪ (fst ` set insts)) ∪ fst ` (FV Γ)" "distinct fresh_idns" (*goal: ‹(⋀fresh_idns::variable list. ⟦length fresh_idns = length (insts::((variable × typ) × Core.term) list); ∀idn::variable∈set fresh_idns. idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set insts) ∪ fst ` set insts) ∪ fst ` FV (Γ::Core.term set); distinct fresh_idns⟧ ⟹ thesis::bool) ⟹ thesis›*) using distinct_fresh_rename_idns (*‹finite ?G ⟹ distinct (fresh_rename_idns ?n ?B ?insts ?G)›*) fresh_fresh_rename_idns (*‹finite ?G ⟹ ∀nm∈set (fresh_rename_idns ?n ?B ?insts ?G). nm ∉ fst ` (fv ?B ∪ ⋃ (fv ` snd ` set ?insts) ∪ fst ` set ?insts) ∪ ?G›*) length_fresh_rename_idns (*‹finite ?G ⟹ length (fresh_rename_idns ?n ?B ?insts ?G) = ?n›*) finite_FV (*‹finite ?S ⟹ finite (FV ?S)›*) finite (*‹finite Γ›*) by (metis finite_imageI (*‹finite (?F::?'a set) ⟹ finite ((?h::?'a ⇒ ?'b) ` ?F)›*)) have 0: "subst_term insts B = fold (λsingle acc . subst_term [single] acc) (zip (zip fresh_idns (map snd (map fst insts))) (map snd insts)) (fold (λsingle acc . subst_term [single] acc) (zip (map fst insts) (map2 Fv fresh_idns (map snd (map fst insts)))) B)" using fresh_idns (*‹length fresh_idns = length insts› ‹∀idn∈set fresh_idns. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set insts) ∪ fst ` set insts) ∪ fst ` FV Γ› ‹distinct (fresh_idns::variable list)›*) distinct (*‹distinct (map fst (insts::((variable × typ) × Core.term) list))›*) subst_term_combine' (*‹⟦length ?fresh_idns = length ?insts; distinct ?fresh_idns; distinct (map fst ?insts); ∀idn∈set ?fresh_idns. idn ∉ fst ` (fv ?t ∪ ⋃ (fv ` snd ` set ?insts) ∪ fst ` set ?insts)⟧ ⟹ subst_term ?insts ?t = fold (λsingle. subst_term [single]) (zip (zip ?fresh_idns (map snd (map fst ?insts))) (map snd ?insts)) (fold (λsingle. subst_term [single]) (zip (map fst ?insts) (map2 Fv ?fresh_idns (map snd (map fst ?insts)))) ?t)›*) by simp from fresh_idns (*‹length fresh_idns = length insts› ‹∀idn∈set fresh_idns. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set insts) ∪ fst ` set insts) ∪ fst ` FV Γ› ‹distinct fresh_idns›*) vars (*‹∀(x, τ)∈fst ` set insts. term_ok Θ (Fv x τ)›*) a_ok (*‹∀a∈snd ` set insts. term_ok Θ a›*) typ_a (*‹∀((uu_, τ), a)∈set insts. typ_of a = Some τ›*) free (*‹∀(v, uu_)∈set insts. v ∉ FV Γ›*) distinct (*‹distinct (map fst insts)›*) have 1: "Θ, Γ ⊢ (fold (λsingle acc . subst_term [single] acc) (zip (map fst insts) (map2 Fv fresh_idns (map snd (map fst insts)))) B)" proof (induction fresh_idns insts rule: rev_induct2 (*‹⟦length ?xs = length ?ys; ?P [] []; ⋀x xs y ys. ⟦length xs = length ys; ?P xs ys⟧ ⟹ ?P (xs @ [x]) (ys @ [y])⟧ ⟹ ?P ?xs ?ys›*)) (*goals: 1. ‹⟦∀idn::variable∈set []. idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set []) ∪ fst ` set []) ∪ fst ` FV (Γ::Core.term set); distinct []; ∀(x::variable, τ::typ)∈fst ` set []. term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); Ball (snd ` set []) (term_ok Θ); ∀((uu_::variable, τ::typ), a::Core.term)∈set []. typ_of a = Some τ; ∀(v::variable × typ, uu_::Core.term)∈set []. v ∉ FV Γ; distinct (map fst [])⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (map fst []) (map2 Fv [] (map snd (map fst [])))) B› 2. ‹⋀(x::variable) (xs::variable list) (y::(variable × typ) × Core.term) ys::((variable × typ) × Core.term) list. ⟦length xs = length ys; ⟦∀idn::variable∈set xs. idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV (Γ::Core.term set); distinct xs; ∀(x::variable, τ::typ)∈fst ` set ys. term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); Ball (snd ` set ys) (term_ok Θ); ∀((uu_::variable, τ::typ), a::Core.term)∈set ys. typ_of a = Some τ; ∀(v::variable × typ, uu_::Core.term)∈set ys. v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B; ∀idn::variable∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ; distinct (xs @ [x]); ∀(x::variable, τ::typ)∈fst ` set (ys @ [y]). term_ok Θ (Fv x τ); Ball (snd ` set (ys @ [y])) (term_ok Θ); ∀((uu_::variable, τ::typ), a::Core.term)∈set (ys @ [y]). typ_of a = Some τ; ∀(v::variable × typ, uu_::Core.term)∈set (ys @ [y]). v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (map fst (ys @ [y])) (map2 Fv (xs @ [x]) (map snd (map fst (ys @ [y]))))) B›*) case Nil (*‹∀idn∈set []. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set []) ∪ fst ` set []) ∪ fst ` FV Γ› ‹distinct []› ‹∀a::variable × typ∈fst ` set []. case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ)› ‹∀a∈snd ` set []. term_ok Θ a› ‹∀a::(variable × typ) × Core.term∈set []. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b› ‹∀a∈set []. case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst [])›*) then show "?case" (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst []) (map2 Fv [] (map snd (map fst [])))) B›*) using B (*‹Θ,Γ ⊢ B›*) by simp next (*goal: ‹⋀x xs y ys. ⟦length xs = length ys; ⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀(x, τ)∈fst ` set ys. term_ok Θ (Fv x τ); Ball (snd ` set ys) (term_ok Θ); ∀((uu_, τ), a)∈set ys. typ_of a = Some τ; ∀(v, uu_)∈set ys. v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B; ∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ; distinct (xs @ [x]); ∀(x, τ)∈fst ` set (ys @ [y]). term_ok Θ (Fv x τ); Ball (snd ` set (ys @ [y])) (term_ok Θ); ∀((uu_, τ), a)∈set (ys @ [y]). typ_of a = Some τ; ∀(v, uu_)∈set (ys @ [y]). v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst (ys @ [y])) (map2 Fv (xs @ [x]) (map snd (map fst (ys @ [y]))))) B›*) case (snoc x xs y ys) (*‹length xs = length ys› ‹⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀a∈fst ` set ys. case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set ys. term_ok Θ a; ∀a∈set ys. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set ys. case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B› ‹∀idn::variable∈set ((xs::variable list) @ [x::variable]). idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV (Γ::Core.term set)› ‹distinct (xs @ [x])› ‹∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst (ys @ [y]))›*) from snoc (*‹length (xs::variable list) = length (ys::((variable × typ) × Core.term) list)› ‹⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀a∈fst ` set ys. case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set ys. term_ok Θ a; ∀a∈set ys. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set ys. case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B› ‹∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ› ‹distinct ((xs::variable list) @ [x::variable])› ‹∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]))›*) have term_oky: "term_ok Θ (Fv (fst (fst y)) (snd (fst y)))" by (auto simp add: wt_term_def (*‹wt_term (?Σ::(String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) (?t::Core.term) ≡ wf_term ?Σ ?t ∧ (∃T::typ. ⊢⇩τ ?t : T)›*) split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) have 1: "Θ, Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B" apply (rule snoc.IH (*‹⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀a∈fst ` set ys. case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set ys. term_ok Θ a; ∀a∈set ys. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set ys. case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B›*)) (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B›*) subgoal for using snoc.prems(1) (*‹∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ›*) apply (clarsimp split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹∀idn::variable∈set (xs::variable list). idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set (ys::((variable × typ) × Core.term) list)) ∪ fst ` set ys) ∪ fst ` FV (Γ::Core.term set)›*) by (smt UN_I (*‹⟦?a ∈ ?A; ?b ∈ ?B ?a⟧ ⟹ ?b ∈ ⋃ (?B ` ?A)›*) Un_iff (*‹(?c ∈ ?A ∪ ?B) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) image_iff (*‹(?z ∈ ?f ` ?A) = (∃x∈?A. ?z = ?f x)›*)) using snoc.prems(2-7) (*‹distinct (xs @ [x])› ‹∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a::(variable × typ) × Core.term∈set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]))›*) apply - (*goals: 1. ‹⟦distinct ((xs::variable list) @ [x::variable]); ∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set (ys @ [y]). term_ok Θ a; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set); distinct (map fst (ys @ [y]))⟧ ⟹ distinct xs› 2. ‹⟦distinct ((xs::variable list) @ [x::variable]); ∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set (ys @ [y]). term_ok Θ a; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set); distinct (map fst (ys @ [y]))⟧ ⟹ ∀a::variable × typ∈fst ` set ys. case a of (x::variable, τ::typ) ⇒ term_ok Θ (Fv x τ)› 3. ‹⟦distinct ((xs::variable list) @ [x::variable]); ∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set (ys @ [y]). term_ok Θ a; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set); distinct (map fst (ys @ [y]))⟧ ⟹ ∀a::Core.term∈snd ` set ys. term_ok Θ a› 4. ‹⟦distinct ((xs::variable list) @ [x::variable]); ∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set (ys @ [y]). term_ok Θ a; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set); distinct (map fst (ys @ [y]))⟧ ⟹ ∀a::(variable × typ) × Core.term∈set ys. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b› 5. ‹⟦distinct ((xs::variable list) @ [x::variable]); ∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set (ys @ [y]). term_ok Θ a; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set); distinct (map fst (ys @ [y]))⟧ ⟹ ∀a::(variable × typ) × Core.term∈set ys. case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV Γ› 6. ‹⟦distinct ((xs::variable list) @ [x::variable]); ∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set (ys @ [y]). term_ok Θ a; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set (ys @ [y]). case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set); distinct (map fst (ys @ [y]))⟧ ⟹ distinct (map fst ys)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . moreover obtain yn and n where ynn: "fst y = (yn, n)" (*goal: ‹(⋀yn n. fst y = (yn, n) ⟹ thesis) ⟹ thesis›*) by fastforce moreover have "Θ,Γ ⊢ subst_term [(fst y, Fv x n)] (fold (λsingle. subst_term [single]) (zip (map fst (ys)) (map2 Fv (xs) (map snd (map fst (ys))))) B)" apply (simp only: ynn (*‹fst y = (yn, n)›*)) (*goal: ‹Θ,Γ ⊢ subst_term [(fst y, Fv x n)] (fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B)›*) apply (rule inst_var[of "Θ" Γ "(fold (λsingle. subst_term [single]) (zip (map fst (ys)) (map2 Fv (xs) (map snd (map fst (ys))))) B)" "(Fv x n)" "n" "yn"] (*‹⟦wf_theory Θ; Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B; term_ok Θ (Fv x n); typ_of (Fv x n) = Some n; (yn, n) ∉ FV Γ⟧ ⟹ Θ,Γ ⊢ subst_term [((yn, n), Fv x n)] (fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B)›*)) (*goal: ‹Θ,Γ ⊢ subst_term [((yn, n), Fv x n)] (fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B)›*) using snoc.prems (*‹∀idn::variable∈set ((xs::variable list) @ [x::variable]). idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV (Γ::Core.term set)› ‹distinct (xs @ [x])› ‹∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a::(variable × typ) × Core.term∈set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst (ys @ [y]))›*) ‹wf_theory Θ› (*‹wf_theory Θ›*) "1" (*‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B›*) apply ((solves simp)+) (*top goal: ‹wf_theory (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set)› and 4 goals remain*) using term_oky (*‹term_ok Θ (Fv (fst (fst y)) (snd (fst y)))›*) ynn (*‹fst (y::(variable × typ) × Core.term) = (yn::variable, n::typ)›*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) (*top goal: ‹term_ok Θ (Fv x n)› and 2 goals remain*) using term_oky (*‹term_ok Θ (Fv (fst (fst y)) (snd (fst y)))›*) ynn (*‹fst y = (yn, n)›*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) (*top goal: ‹typ_of (Fv (x::variable) (n::typ)) = Some n› and 1 goal remains*) using snoc.prems(6) (*‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ›*) ynn (*‹fst y = (yn, n)›*) by auto moreover have "fold (λsingle. subst_term [single]) (zip (map fst (ys @ [y])) (map2 Fv (xs @ [x]) (map snd (map fst (ys @ [y]))))) B = subst_term [(fst y, Fv x (snd (fst y)))] (fold (λsingle. subst_term [single]) (zip (map fst (ys)) (map2 Fv (xs) (map snd (map fst (ys))))) B)" using snoc.hyps (*‹length xs = length ys›*) apply (induction xs ys rule: list_induct2 (*‹⟦length ?xs = length ?ys; ?P [] []; ⋀x xs y ys. ⟦length xs = length ys; ?P xs ys⟧ ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?xs ?ys›*)) (*goals: 1. ‹fold (λsingle. subst_term [single]) (zip (map fst ([] @ [y])) (map2 Fv ([] @ [x]) (map snd (map fst ([] @ [y]))))) B = subst_term [(fst y, Fv x (snd (fst y)))] (fold (λsingle. subst_term [single]) (zip (map fst []) (map2 Fv [] (map snd (map fst [])))) B)› 2. ‹⋀xa xs ya ys. ⟦length xs = length ys; fold (λsingle. subst_term [single]) (zip (map fst (ys @ [y])) (map2 Fv (xs @ [x]) (map snd (map fst (ys @ [y]))))) B = subst_term [(fst y, Fv x (snd (fst y)))] (fold (λsingle. subst_term [single]) (zip (map fst ys) (map2 Fv xs (map snd (map fst ys)))) B)⟧ ⟹ fold (λsingle. subst_term [single]) (zip (map fst ((ya # ys) @ [y])) (map2 Fv ((xa # xs) @ [x]) (map snd (map fst ((ya # ys) @ [y]))))) B = subst_term [(fst y, Fv x (snd (fst y)))] (fold (λsingle. subst_term [single]) (zip (map fst (ya # ys)) (map2 Fv (xa # xs) (map snd (map fst (ya # ys))))) B)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . ultimately show "?case" (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst (ys @ [y])) (map2 Fv (xs @ [x]) (map snd (map fst (ys @ [y]))))) B›*) by simp qed define point where "point ≡ (fold (λsingle acc . subst_term [single] acc) (zip (map fst insts) (map2 Fv fresh_idns (map snd (map fst insts)))) B)" from fresh_idns (*‹length fresh_idns = length insts› ‹∀idn∈set fresh_idns. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set insts) ∪ fst ` set insts) ∪ fst ` FV Γ› ‹distinct fresh_idns›*) vars (*‹∀(x, τ)∈fst ` set insts. term_ok Θ (Fv x τ)›*) a_ok (*‹∀a∈snd ` set insts. term_ok Θ a›*) typ_a (*‹∀((uu_::variable, τ::typ), a::Core.term)∈set (insts::((variable × typ) × Core.term) list). typ_of a = Some τ›*) free (*‹∀(v, uu_)∈set insts. v ∉ FV Γ›*) distinct (*‹distinct (map fst insts)›*) have 2: "Θ, Γ ⊢ fold (λsingle acc . subst_term [single] acc) (zip (zip fresh_idns (map snd (map fst insts))) (map snd insts)) point" proof (induction fresh_idns insts rule: rev_induct2 (*‹⟦length ?xs = length ?ys; ?P [] []; ⋀x xs y ys. ⟦length xs = length ys; ?P xs ys⟧ ⟹ ?P (xs @ [x]) (ys @ [y])⟧ ⟹ ?P ?xs ?ys›*)) (*goals: 1. ‹⟦∀idn::variable∈set []. idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set []) ∪ fst ` set []) ∪ fst ` FV (Γ::Core.term set); distinct []; ∀(x::variable, τ::typ)∈fst ` set []. term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); Ball (snd ` set []) (term_ok Θ); ∀((uu_::variable, τ::typ), a::Core.term)∈set []. typ_of a = Some τ; ∀(v::variable × typ, uu_::Core.term)∈set []. v ∉ FV Γ; distinct (map fst [])⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip [] (map snd (map fst []))) (map snd [])) (point::Core.term)› 2. ‹⋀(x::variable) (xs::variable list) (y::(variable × typ) × Core.term) ys::((variable × typ) × Core.term) list. ⟦length xs = length ys; ⟦∀idn::variable∈set xs. idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV (Γ::Core.term set); distinct xs; ∀(x::variable, τ::typ)∈fst ` set ys. term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); Ball (snd ` set ys) (term_ok Θ); ∀((uu_::variable, τ::typ), a::Core.term)∈set ys. typ_of a = Some τ; ∀(v::variable × typ, uu_::Core.term)∈set ys. v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) (point::Core.term); ∀idn::variable∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ; distinct (xs @ [x]); ∀(x::variable, τ::typ)∈fst ` set (ys @ [y]). term_ok Θ (Fv x τ); Ball (snd ` set (ys @ [y])) (term_ok Θ); ∀((uu_::variable, τ::typ), a::Core.term)∈set (ys @ [y]). typ_of a = Some τ; ∀(v::variable × typ, uu_::Core.term)∈set (ys @ [y]). v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip (xs @ [x]) (map snd (map fst (ys @ [y])))) (map snd (ys @ [y]))) point›*) case Nil (*‹∀idn∈set []. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set []) ∪ fst ` set []) ∪ fst ` FV Γ› ‹distinct []› ‹∀a∈fst ` set []. case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› ‹∀a∈snd ` set []. term_ok Θ a› ‹∀a∈set []. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a::(variable × typ) × Core.term∈set []. case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV (Γ::Core.term set)› ‹distinct (map fst [])›*) then show "?case" (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip [] (map snd (map fst []))) (map snd [])) point›*) using B (*‹Θ,Γ ⊢ B›*) using "1" (*‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst insts) (map2 Fv fresh_idns (map snd (map fst insts)))) B›*) point_def (*‹point::Core.term ≡ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (map fst (insts::((variable × typ) × Core.term) list)) (map2 Fv (fresh_idns::variable list) (map snd (map fst insts)))) (B::Core.term)›*) by auto next (*goal: ‹⋀x xs y ys. ⟦length xs = length ys; ⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀(x, τ)∈fst ` set ys. term_ok Θ (Fv x τ); Ball (snd ` set ys) (term_ok Θ); ∀((uu_, τ), a)∈set ys. typ_of a = Some τ; ∀(v, uu_)∈set ys. v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point; ∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ; distinct (xs @ [x]); ∀(x, τ)∈fst ` set (ys @ [y]). term_ok Θ (Fv x τ); Ball (snd ` set (ys @ [y])) (term_ok Θ); ∀((uu_, τ), a)∈set (ys @ [y]). typ_of a = Some τ; ∀(v, uu_)∈set (ys @ [y]). v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip (xs @ [x]) (map snd (map fst (ys @ [y])))) (map snd (ys @ [y]))) point›*) case (snoc x xs y ys) (*‹length xs = length ys› ‹⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀a∈fst ` set ys. case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set ys. term_ok Θ a; ∀a∈set ys. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set ys. case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point› ‹∀idn::variable∈set ((xs::variable list) @ [x::variable]). idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV (Γ::Core.term set)› ‹distinct ((xs::variable list) @ [x::variable])› ‹∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]))›*) from snoc (*‹length xs = length ys› ‹⟦∀idn::variable∈set (xs::variable list). idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set (ys::((variable × typ) × Core.term) list)) ∪ fst ` set ys) ∪ fst ` FV (Γ::Core.term set); distinct xs; ∀a::variable × typ∈fst ` set ys. case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ); ∀a::Core.term∈snd ` set ys. term_ok Θ a; ∀a::(variable × typ) × Core.term∈set ys. case a of (a::variable × typ, b::Core.term) ⇒ (case a of (uu_::variable, τ::typ) ⇒ λa::Core.term. typ_of a = Some τ) b; ∀a::(variable × typ) × Core.term∈set ys. case a of (v::variable × typ, uu_::Core.term) ⇒ v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) (point::Core.term)› ‹∀idn::variable∈set ((xs::variable list) @ [x::variable]). idn ∉ fst ` (fv (B::Core.term) ∪ ⋃ (fv ` snd ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV (Γ::Core.term set)› ‹distinct (xs @ [x])› ‹∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst (ys @ [y]))›*) have typ_ofy: "typ_of (snd y) = Some (snd (fst y))" by auto have 1: " Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point" apply (rule snoc.IH (*‹⟦∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ; distinct xs; ∀a∈fst ` set ys. case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set ys. term_ok Θ a; ∀a∈set ys. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set ys. case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst ys)⟧ ⟹ Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point›*)) (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point›*) subgoal for using snoc.prems(1) (*‹∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ›*) apply (clarsimp split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹∀idn∈set xs. idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set ys) ∪ fst ` set ys) ∪ fst ` FV Γ›*) by (smt UN_I (*‹⟦(?a::?'a) ∈ (?A::?'a set); (?b::?'b) ∈ (?B::?'a ⇒ ?'b set) ?a⟧ ⟹ ?b ∈ ⋃ (?B ` ?A)›*) Un_iff (*‹((?c::?'a) ∈ (?A::?'a set) ∪ (?B::?'a set)) = (?c ∈ ?A ∨ ?c ∈ ?B)›*) fst_conv (*‹fst (?x1.0::?'a, ?x2.0::?'b) = ?x1.0›*) image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*)) using snoc.prems(2-7) (*‹distinct (xs @ [x])› ‹∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst (ys @ [y]))›*) apply - (*goals: 1. ‹⟦distinct (xs @ [x]); ∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set (ys @ [y]). term_ok Θ a; ∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ distinct xs› 2. ‹⟦distinct (xs @ [x]); ∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set (ys @ [y]). term_ok Θ a; ∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ ∀a∈fst ` set ys. case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› 3. ‹⟦distinct (xs @ [x]); ∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set (ys @ [y]). term_ok Θ a; ∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ ∀a∈snd ` set ys. term_ok Θ a› 4. ‹⟦distinct (xs @ [x]); ∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set (ys @ [y]). term_ok Θ a; ∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ ∀a∈set ys. case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› 5. ‹⟦distinct (xs @ [x]); ∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set (ys @ [y]). term_ok Θ a; ∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ ∀a∈set ys. case a of (v, uu_) ⇒ v ∉ FV Γ› 6. ‹⟦distinct (xs @ [x]); ∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ); ∀a∈snd ` set (ys @ [y]). term_ok Θ a; ∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b; ∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ; distinct (map fst (ys @ [y]))⟧ ⟹ distinct (map fst ys)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*proven 6 subgoals*) . moreover obtain yn and n where ynn: "fst y = (yn, n)" (*goal: ‹(⋀yn n. fst y = (yn, n) ⟹ thesis) ⟹ thesis›*) by fastforce moreover have "Θ,Γ ⊢ subst_term [((x, snd (fst y)), snd y)] (fold (λsingle. subst_term [single]) (zip (zip (xs) (map snd (map fst (ys)))) (map snd (ys))) point)" apply (simp only: ynn (*‹fst y = (yn, n)›*)) (*goal: ‹Θ,Γ ⊢ subst_term [((x, snd (fst y)), snd y)] (fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point)›*) apply (rule inst_var (*‹⟦wf_theory ?Θ; ?Θ,?Γ ⊢ ?B; term_ok ?Θ ?a; typ_of ?a = Some ?τ; (?x, ?τ) ∉ FV ?Γ⟧ ⟹ ?Θ,?Γ ⊢ subst_term [((?x, ?τ), ?a)] ?B›*)) (*goal: ‹Θ,Γ ⊢ subst_term [((x, snd (yn, n)), snd y)] (fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point)›*) using snoc.prems (*‹∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ› ‹distinct (xs @ [x])› ‹∀a::variable × typ∈fst ` set ((ys::((variable × typ) × Core.term) list) @ [y::(variable × typ) × Core.term]). case a of (x::variable, τ::typ) ⇒ term_ok (Θ::((String.literal ⇒ typ option) × (String.literal ⇒ nat option) × (String.literal × String.literal) set × (String.literal ⇒ (String.literal ⇒ String.literal set list option) option)) × Core.term set) (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst (ys @ [y]))›*) ‹wf_theory Θ› (*‹wf_theory Θ›*) "1" (*‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point›*) apply ((solves simp)+) (*top goal: ‹wf_theory Θ› and 4 goals remain*) using typ_ofy (*‹typ_of (snd y) = Some (snd (fst y))›*) ynn (*‹fst (y::(variable × typ) × Core.term) = (yn::variable, n::typ)›*) apply (simp add: wt_term_def (*‹wt_term ?Σ ?t ≡ wf_term ?Σ ?t ∧ (∃T. ⊢⇩τ ?t : T)›*) typ_of_def (*‹typ_of ?t ≡ typ_of1 [] ?t›*)) (*top goal: ‹typ_of (snd (y::(variable × typ) × Core.term)) = Some (snd (yn::variable, n::typ))› and 1 goal remains*) using snoc.prems (*‹∀idn∈set (xs @ [x]). idn ∉ fst ` (fv B ∪ ⋃ (fv ` snd ` set (ys @ [y])) ∪ fst ` set (ys @ [y])) ∪ fst ` FV Γ› ‹distinct (xs @ [x])› ‹∀a∈fst ` set (ys @ [y]). case a of (x, τ) ⇒ term_ok Θ (Fv x τ)› ‹∀a∈snd ` set (ys @ [y]). term_ok Θ a› ‹∀a∈set (ys @ [y]). case a of (a, b) ⇒ (case a of (uu_, τ) ⇒ λa. typ_of a = Some τ) b› ‹∀a∈set (ys @ [y]). case a of (v, uu_) ⇒ v ∉ FV Γ› ‹distinct (map fst (ys @ [y]))›*) apply simp (*goal: ‹(x, snd (yn, n)) ∉ FV Γ›*) by (metis (full_types, opaque_lifting) UN_I (*‹⟦?a ∈ ?A; ?b ∈ ?B ?a⟧ ⟹ ?b ∈ ⋃ (?B ` ?A)›*) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) image_eqI (*‹⟦?b = ?f ?x; ?x ∈ ?A⟧ ⟹ ?b ∈ ?f ` ?A›*)) moreover have "fold (λsingle. subst_term [single]) (zip (zip (xs @ [x]) (map snd (map fst (ys @ [y])))) (map snd (ys @ [y]))) point = subst_term [((x, snd (fst y)), snd y)] (fold (λsingle. subst_term [single]) (zip (zip (xs) (map snd (map fst (ys)))) (map snd (ys))) point)" using snoc.hyps (*‹length xs = length ys›*) apply (induction xs ys rule: list_induct2 (*‹⟦length ?xs = length ?ys; ?P [] []; ⋀x xs y ys. ⟦length xs = length ys; ?P xs ys⟧ ⟹ ?P (x # xs) (y # ys)⟧ ⟹ ?P ?xs ?ys›*)) (*goals: 1. ‹fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip ([] @ [x::variable]) (map snd (map fst ([] @ [y::(variable × typ) × Core.term])))) (map snd ([] @ [y]))) (point::Core.term) = subst_term [((x, snd (fst y)), snd y)] (fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip [] (map snd (map fst []))) (map snd [])) point)› 2. ‹⋀(xa::variable) (xs::variable list) (ya::(variable × typ) × Core.term) ys::((variable × typ) × Core.term) list. ⟦length xs = length ys; fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip (xs @ [x::variable]) (map snd (map fst (ys @ [y::(variable × typ) × Core.term])))) (map snd (ys @ [y]))) (point::Core.term) = subst_term [((x, snd (fst y)), snd y)] (fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip xs (map snd (map fst ys))) (map snd ys)) point)⟧ ⟹ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip ((xa # xs) @ [x]) (map snd (map fst ((ya # ys) @ [y])))) (map snd ((ya # ys) @ [y]))) point = subst_term [((x, snd (fst y)), snd y)] (fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (zip (xa # xs) (map snd (map fst (ya # ys)))) (map snd (ya # ys))) point)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . ultimately show "?case" (*goal: ‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip (xs @ [x]) (map snd (map fst (ys @ [y])))) (map snd (ys @ [y]))) point›*) by simp qed from "0" (*‹subst_term insts B = fold (λsingle. subst_term [single]) (zip (zip fresh_idns (map snd (map fst insts))) (map snd insts)) (fold (λsingle. subst_term [single]) (zip (map fst insts) (map2 Fv fresh_idns (map snd (map fst insts)))) B)›*) "1" (*‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (map fst insts) (map2 Fv fresh_idns (map snd (map fst insts)))) B›*) "2" (*‹Θ,Γ ⊢ fold (λsingle. subst_term [single]) (zip (zip fresh_idns (map snd (map fst insts))) (map snd insts)) point›*) show "?thesis" (*goal: ‹Θ,Γ ⊢ subst_term insts B›*) using point_def (*‹point::Core.term ≡ fold (λsingle::(variable × typ) × Core.term. subst_term [single]) (zip (map fst (insts::((variable × typ) × Core.term) list)) (map2 Fv (fresh_idns::variable list) (map snd (map fst insts)))) (B::Core.term)›*) by simp qed lemma term_ok_eta_red_step: "¬ is_dependent t ⟹ term_ok Θ (Abs T (t $ Bv 0)) ⟹ term_ok Θ (decr 0 t)" unfolding term_ok_def wt_term_def (*goal: ‹⟦¬ is_dependent t; wf_term (sig Θ) (Abs T (t $ Bv 0)) ∧ (∃Ta. ⊢⇩τ Abs T (t $ Bv 0) : Ta)⟧ ⟹ wf_term (sig Θ) (decr 0 t) ∧ (∃T. ⊢⇩τ decr 0 t : T)›*) using term_ok'_decr (*‹term_ok' ?Σ ?t ⟹ term_ok' ?Σ (decr ?i ?t)›*) eta_preserves_typ_of (*‹⟦?t →⇩η ?t'; typ_of ?t = Some ?τ⟧ ⟹ typ_of ?t' = Some ?τ›*) apply simp (*goal: ‹⟦¬ is_dependent t; wf_term (sig Θ) (Abs T (t $ Bv 0)) ∧ (∃Ta. ⊢⇩τ Abs T (t $ Bv 0) : Ta)⟧ ⟹ wf_term (sig Θ) (decr 0 t) ∧ (∃T. ⊢⇩τ decr 0 t : T)›*) by blast end
{ "path": "afp-2025-02-12/thys/Metalogic_ProofChecker/Logic.thy", "repo": "afp-2025-02-12", "sha": "f16eba8ce00650c908fa5b56d5742d2228092a954f4577f3ef89710eba7475dc" }
theory BPlusTree_Iter imports BPlusTree_Imp "HOL-Real_Asymp.Inst_Existentials" "Separation_Logic_Imperative_HOL.Imp_List_Spec" Flatten_Iter_Spec Partially_Filled_Array_Iter Subst_Mod_Mult_AC begin (* TODO use list_zip? → not well defined return type *) fun bplustree_assn_leafs :: "nat ⇒ ('a::heap) bplustree ⇒ 'a btnode ref ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode ref list ⇒ assn" where "bplustree_assn_leafs k (Leaf xs) a r z leafptrs = (∃⇩A xsi fwd. a ↦⇩r Btleaf xsi fwd * is_pfa (2*k) xs xsi * ↑(fwd = z) * ↑(r = Some a) * ↑(leafptrs = [a]) )" | "bplustree_assn_leafs k (Node ts t) a r z leafptrs = (∃⇩A tsi ti tsi' tsi'' rs split. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r#rs)) (last (rs@[z])) (last split) * is_pfa (2*k) tsi' tsi * ↑(concat split = leafptrs) * ↑(length tsi' = length rs) * ↑(length split = length rs + 1) * ↑(tsi'' = zip (zip (map fst tsi') (zip (butlast (r#rs)) (zip (butlast (rs@[z])) (butlast split)))) (map snd tsi')) * list_assn ((λ t (ti,r',z',lptrs). bplustree_assn_leafs k t (the ti) r' z' lptrs) ×⇩a id_assn) ts tsi'' )" (*fun make_list_list where "make_list_list xs = [xs]" lemma make_list_list_concat: "concat (make_list_list ys) = ys" by auto lemma ex_concat: "∃xs. concat xs = ys" using make_list_list_concat by blast*) lemma inst_same: "(⋀x. P x = Q x) ⟹ (∃⇩A x. P x) = (∃⇩A x. Q x)" by simp lemma reorder_ex: "⋀z. (∃⇩Aa b c d e f g. z a b c d e f g) = (∃⇩Ab c d e f a g. z a b c d e f g)" "⋀z. (∃⇩Aa b . z a b) = (∃⇩Ab a. z a b)" "⋀z. (∃⇩Aa b c d. z a b c d) = (∃⇩Ab c a d. z a b c d)" (*goals: 1. ‹⋀z::'a ⇒ 'b ⇒ 'c ⇒ 'd ⇒ 'e ⇒ 'f ⇒ 'g ⇒ assn. (∃⇩A(a::'a) (b::'b) (c::'c) (d::'d) (e::'e) (f::'f) g::'g. z a b c d e f g) = (∃⇩A(b::'b) (c::'c) (d::'d) (e::'e) (f::'f) (a::'a) g::'g. z a b c d e f g)› 2. ‹⋀z::'h ⇒ 'i ⇒ assn. (∃⇩A(a::'h) b::'i. z a b) = (∃⇩A(b::'i) a::'h. z a b)› 3. ‹⋀z::'j ⇒ 'k ⇒ 'l ⇒ 'm ⇒ assn. (∃⇩A(a::'j) (b::'k) (c::'l) d::'m. z a b c d) = (∃⇩A(b::'k) (c::'l) (a::'j) d::'m. z a b c d)› discuss goal 1*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀z. ∃⇩Aa b c d e f g. z a b c d e f g ⟹⇩A ∃⇩Ab c d e f a g. z a b c d e f g› 2. ‹⋀z. ∃⇩Ab c d e f a g. z a b c d e f g ⟹⇩A ∃⇩Aa b c d e f g. z a b c d e f g› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*discuss goal 2*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀z. ∃⇩Aa b. z a b ⟹⇩A ∃⇩Ab a. z a b› 2. ‹⋀z. ∃⇩Ab a. z a b ⟹⇩A ∃⇩Aa b. z a b› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*discuss goal 3*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goals: 1. ‹⋀z. ∃⇩Aa b c d. z a b c d ⟹⇩A ∃⇩Ab c a d. z a b c d› 2. ‹⋀z. ∃⇩Ab c a d. z a b c d ⟹⇩A ∃⇩Aa b c d. z a b c d› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*proven 3 subgoals*) . lemma inst_same2: "(⋀x. P = Q x) ⟹ P = (∃⇩A x. Q x)" by simp lemma pure_eq_pre: "(P ⟹ Q = R) ⟹ (Q * ↑P = R * ↑P)" by fastforce lemma otf_lem_comm_ex: "⋀a b c d e f g. (∃⇩A x. a * b x * c * d x * e x * f x * g x) = a * c * (∃⇩A x. b x * d x * e x * f x * g x)" "⋀a b c d e. (∃⇩Aaa x. a * b x * c * d aa * e aa) = (a * c * (∃⇩A aa x. b x * d aa * e aa))" "⋀b d e. (∃⇩A aa x. b x * d aa * e aa) = (∃⇩A x. b x) * (∃⇩A aa. d aa * e aa)" (*goals: 1. ‹⋀a b c d e f g. (∃⇩Ax. a * b x * c * d x * e x * f x * g x) = a * c * (∃⇩Ax. b x * d x * e x * f x * g x)› 2. ‹⋀a b c d e. (∃⇩Aaa x. a * b x * c * d aa * e aa) = a * c * (∃⇩Aaa x. b x * d aa * e aa)› 3. ‹⋀b d e. (∃⇩Aaa x. b x * d aa * e aa) = (∃⇩Ax. b x) * (∃⇩Aaa. d aa * e aa)› discuss goal 1*) apply ((auto simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))[1]) (*discuss goal 2*) apply ((auto simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))[1]) (*discuss goal 3*) apply ((auto simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*))[1]) (*proven 3 subgoals*) . declare last.simps[simp del] butlast.simps[simp del] lemma bplustree_extract_leafs: "bplustree_assn k t ti r z = (∃⇩Aleafptrs. bplustree_assn_leafs k t ti r z leafptrs)" proof (induction arbitrary: r rule: bplustree_assn.induct) (*goals: 1. ‹⋀k xs a r z ra. bplustree_assn k (Leaf xs) a ra z = ex_assn (bplustree_assn_leafs k (Leaf xs) a ra z)› 2. ‹⋀k ts t a r z ra. ⟦⋀x xa xb xc xd r. bplustree_assn k t xa r (last (xd @ [z])) = ex_assn (bplustree_assn_leafs k t xa r (last (xd @ [z]))); ⋀x xa xb xc xd xe y xf ya xg yb r. ⟦xe ∈ set ts; y ∈ set xc; (xf, ya) = fst y; (xg, yb) = ya⟧ ⟹ bplustree_assn k (fst xe) (the xf) r yb = ex_assn (bplustree_assn_leafs k (fst xe) (the xf) r yb)⟧ ⟹ bplustree_assn k (Node ts t) a ra z = ex_assn (bplustree_assn_leafs k (Node ts t) a ra z)›*) case (1 k xs a r z) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹bplustree_assn k (Leaf xs) a r z = (∃⇩Ab. bplustree_assn_leafs k (Leaf xs) a r z b)›*) apply (rule ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹bplustree_assn k (Leaf xs) a r z = (∃⇩Ab. bplustree_assn_leafs k (Leaf xs) a r z b)›*) subgoal for apply (inst_ex_assn "[a]") (*goal: ‹bplustree_assn k (Leaf xs) a r z ⟹⇩A ∃⇩Ab. bplustree_assn_leafs k (Leaf xs) a r z b›*) by sep_auto subgoal for apply (rule ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Ab. bplustree_assn_leafs k (Leaf xs) a r z b ⟹⇩A bplustree_assn k (Leaf xs) a r z›*) apply clarsimp (*goal: ‹⋀x. bplustree_assn_leafs k (Leaf xs) a r z x ⟹⇩A bplustree_assn k (Leaf xs) a r z›*) apply ((rule ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*))+) (*goal: ‹⋀x. ∃⇩Axsi fwd. a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) xs xsi * ↑ (fwd = z ∧ r = Some a ∧ x = [a]) ⟹⇩A ∃⇩Axsi fwd. a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) xs xsi * ↑ (fwd = z ∧ r = Some a)›*) subgoal for x and xsi and fwd apply (inst_ex_assn xsi fwd) (*goal: ‹a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) xs xsi * ↑ (fwd = z ∧ r = Some a ∧ x = [a]) ⟹⇩A ∃⇩Axsi fwd. a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) xs xsi * ↑ (fwd = z ∧ r = Some a)›*) by simp . . next (*goal: ‹⋀k ts t a r z ra. ⟦⋀x xa xb xc xd r. bplustree_assn k t xa r (last (xd @ [z])) = ex_assn (bplustree_assn_leafs k t xa r (last (xd @ [z]))); ⋀x xa xb xc xd xe y xf ya xg yb r. ⟦xe ∈ set ts; y ∈ set xc; (xf, ya) = fst y; (xg, yb) = ya⟧ ⟹ bplustree_assn k (fst xe) (the xf) r yb = ex_assn (bplustree_assn_leafs k (fst xe) (the xf) r yb)⟧ ⟹ bplustree_assn k (Node ts t) a ra z = ex_assn (bplustree_assn_leafs k (Node ts t) a ra z)›*) case Istep: (2 k ts t a r z) (*‹bplustree_assn k t ?xa ?r (last (?xd @ [z])) = (∃⇩Aa. bplustree_assn_leafs k t ?xa ?r (last (?xd @ [z])) a)› ‹⟦(?xe::'a::heap bplustree × 'a::heap) ∈ set (ts::('a::heap bplustree × 'a::heap) list); (?y::('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option) × 'a::heap) ∈ set (?xc::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option) × 'a::heap) list); (?xf::'a::heap btnode ref option, ?ya::'a::heap btnode ref option × 'a::heap btnode ref option) = fst ?y; (?xg::'a::heap btnode ref option, ?yb::'a::heap btnode ref option) = ?ya⟧ ⟹ bplustree_assn (k::nat) (fst ?xe) (the ?xf) (?r::'a::heap btnode ref option) ?yb = (∃⇩Aa::'a::heap btnode ref list. bplustree_assn_leafs k (fst ?xe) (the ?xf) ?r ?yb a)›*) show "?case" (*goal: ‹bplustree_assn k (Node ts t) a r z = (∃⇩Ab. bplustree_assn_leafs k (Node ts t) a r z b)›*) apply (simp (no_asm)) (*goal: ‹bplustree_assn (k::nat) (Node (ts::('a bplustree × 'a) list) (t::'a bplustree)) (a::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option) = (∃⇩Ab::'a btnode ref list. bplustree_assn_leafs k (Node ts t) a r z b)›*) thm bplustree_assn_leafs.simps(2) apply (subst reorder_ex( (*‹(∃⇩Aa b c d e f g. ?z a b c d e f g) = (∃⇩Ab c d e f a g. ?z a b c d e f g)›*) 1)) (*goal: ‹(∃⇩A(tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) (tsi'::('a btnode ref option × 'a) list) (tsi''::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option) × 'a) list) rs::'a btnode ref option list. (a::'a btnode ref) ↦⇩r Btnode tsi ti * bplustree_assn (k::nat) (t::'a bplustree) ti (last ((r::'a btnode ref option) # rs)) (z::'a btnode ref option) * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k (ts::('a bplustree × 'a) list) tsi'' * ↑ (length tsi' = length rs ∧ tsi'' = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) = (∃⇩A(b::'a btnode ref list) (tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) (tsi'::('a btnode ref option × 'a) list) (tsi''::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) (rs::'a btnode ref option list) split::'a btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts tsi'' * ↑ (concat split = b ∧ length tsi' = length rs ∧ length split = Suc (length rs) ∧ tsi'' = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')))›*) apply (intro inst_same (*‹(⋀x. ?P x = ?Q x) ⟹ (∃⇩Ax. ?P x) = (∃⇩Ax. ?Q x)›*)) (*goal: ‹(∃⇩Atsi ti tsi' tsi'' rs. a ↦⇩r Btnode tsi ti * bplustree_assn k t ti (last (r # rs)) z * is_pfa (2 * k) tsi' tsi * blist_assn k ts tsi'' * ↑ (length tsi' = length rs ∧ tsi'' = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) = (∃⇩Ab c d e f aa g. a ↦⇩r Btnode b c * bplustree_assn_leafs k t c (last (r # f)) z (last g) * is_pfa (2 * k) d b * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts e * ↑ (concat g = aa ∧ length d = length f ∧ length g = Suc (length f) ∧ e = zip (zip (subtrees d) (zip (butlast (r # f)) (zip f (butlast g)))) (separators d)))›*) thm reorder_ex(2) apply (subst reorder_ex( (*‹(∃⇩Aa b. ?z a b) = (∃⇩Ab a. ?z a b)›*) 2)) (*goal: ‹⋀(tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) tsi'::('a btnode ref option × 'a) list. (∃⇩A(tsi''::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option) × 'a) list) rs::'a btnode ref option list. (a::'a btnode ref) ↦⇩r Btnode tsi ti * bplustree_assn (k::nat) (t::'a bplustree) ti (last ((r::'a btnode ref option) # rs)) (z::'a btnode ref option) * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k (ts::('a bplustree × 'a) list) tsi'' * ↑ (length tsi' = length rs ∧ tsi'' = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) = (∃⇩A(e::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) (f::'a btnode ref option list) (aa::'a btnode ref list) g::'a btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # f)) z (last g) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts e * ↑ (concat g = aa ∧ length tsi' = length f ∧ length g = Suc (length f) ∧ e = zip (zip (subtrees tsi') (zip (butlast (r # f)) (zip f (butlast g)))) (separators tsi')))›*) apply (subst reorder_ex( (*‹(∃⇩Aa b c d. ?z a b c d) = (∃⇩Ab c a d. ?z a b c d)›*) 3)) (*goal: ‹⋀tsi ti tsi'. (∃⇩Ab aa. a ↦⇩r Btnode tsi ti * bplustree_assn k t ti (last (r # b)) z * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length b ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # b)) b)) (separators tsi'))) = (∃⇩Ae f aa g. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # f)) z (last g) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts e * ↑ (concat g = aa ∧ length tsi' = length f ∧ length g = Suc (length f) ∧ e = zip (zip (subtrees tsi') (zip (butlast (r # f)) (zip f (butlast g)))) (separators tsi')))›*) apply (rule inst_same (*‹(⋀x. ?P x = ?Q x) ⟹ (∃⇩Ax. ?P x) = (∃⇩Ax. ?Q x)›*)) (*goal: ‹⋀tsi ti tsi'. (∃⇩Ab aa. a ↦⇩r Btnode tsi ti * bplustree_assn k t ti (last (r # b)) z * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length b ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # b)) b)) (separators tsi'))) = (∃⇩Ab c aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # b)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length b ∧ length d = Suc (length b) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # b)) (zip b (butlast d)))) (separators tsi')))›*) proof (goal_cases) (*goal: ‹⋀(tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) (tsi'::('a btnode ref option × 'a) list) b::'a btnode ref option list. (∃⇩Aaa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option) × 'a) list. (a::'a btnode ref) ↦⇩r Btnode tsi ti * bplustree_assn (k::nat) (t::'a bplustree) ti (last ((r::'a btnode ref option) # b)) (z::'a btnode ref option) * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k (ts::('a bplustree × 'a) list) aa * ↑ (length tsi' = length b ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # b)) b)) (separators tsi'))) = (∃⇩A(c::'a btnode ref list) (aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) d::'a btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # b)) z (last d) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length b ∧ length d = Suc (length b) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # b)) (zip b (butlast d)))) (separators tsi')))›*) case (1 tsi ti tsi' rs) (*no hyothesis introduced yet*) have "*": " length tsi's = length tss ⟹ length tss = length rss ⟹ set tsi's ⊆ set tsi' ⟹ set rss ⊆ set rs ⟹ set tss ⊆ set ts ⟹ blist_assn k tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) rss)) (separators tsi's)) = (∃⇩Asplit. list_assn ((λ t (ti,r',z',lptrs). bplustree_assn_leafs k t (the ti) r' z' lptrs) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss split))) (separators tsi's)) * ↑(length split = length rss))" for rss and tsi's and tss and ra proof (induct arbitrary: ra rule: list_induct3) (*goals: 1. ‹⋀ra. ⟦set [] ⊆ set tsi'; set [] ⊆ set rs; set [] ⊆ set ts⟧ ⟹ blist_assn k [] (zip (zip (subtrees []) (zip (butlast [ra]) [])) (separators [])) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] split))) (separators [])) * ↑ (length split = length []))› 2. ‹⋀x xs y ys z zs ra. ⟦length xs = length ys; length ys = length zs; ⋀ra. ⟦set xs ⊆ set tsi'; set zs ⊆ set rs; set ys ⊆ set ts⟧ ⟹ blist_assn k ys (zip (zip (subtrees xs) (zip (butlast (ra # zs)) zs)) (separators xs)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ys (zip (zip (subtrees xs) (zip (butlast (ra # zs)) (zip zs split))) (separators xs)) * ↑ (length split = length zs)); set (x # xs) ⊆ set tsi'; set (z # zs) ⊆ set rs; set (y # ys) ⊆ set ts⟧ ⟹ blist_assn k (y # ys) (zip (zip (subtrees (x # xs)) (zip (butlast (ra # z # zs)) (z # zs))) (separators (x # xs))) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (y # ys) (zip (zip (subtrees (x # xs)) (zip (butlast (ra # z # zs)) (zip (z # zs) split))) (separators (x # xs))) * ↑ (length split = length (z # zs)))›*) case Nil (*‹set [] ⊆ set tsi'› ‹set [] ⊆ set rs› ‹set [] ⊆ set ts›*) then show "?case" (*goal: ‹blist_assn (k::nat) [] (zip (zip (subtrees []) (zip (butlast [ra::'a::heap btnode ref option]) [])) (separators [])) = (∃⇩Asplit::'a::heap btnode ref list list. list_assn ((λ(t::'a::heap bplustree) a::'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list. case a of (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, a::'a::heap btnode ref option, c::'a::heap btnode ref list) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] split))) (separators [])) * ↑ (length split = length []))›*) apply sep_auto (*goal: ‹blist_assn (k::nat) [] (zip (zip (subtrees []) (zip (butlast [ra::'a::heap btnode ref option]) [])) (separators [])) = (∃⇩Asplit::'a::heap btnode ref list list. list_assn ((λ(t::'a::heap bplustree) a::'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list. case a of (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, a::'a::heap btnode ref option, c::'a::heap btnode ref list) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] split))) (separators [])) * ↑ (length split = length []))›*) apply (subst ex_one_point_gen[where v="[]"] (*‹(⋀h x. h ⊨ ?P x ⟹ x = []) ⟹ (∃⇩Ax. ?P x) = ?P []›*)) (*goals: 1. ‹⋀(h::heap × nat set) x::'a btnode ref list list. h ⊨ ↑ (x = []) ⟹ x = []› 2. ‹↑ ([] = []) = emp› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . next (*goal: ‹⋀x xs y ys z zs ra. ⟦length xs = length ys; length ys = length zs; ⋀ra. ⟦set xs ⊆ set tsi'; set zs ⊆ set rs; set ys ⊆ set ts⟧ ⟹ blist_assn k ys (zip (zip (subtrees xs) (zip (butlast (ra # zs)) zs)) (separators xs)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ys (zip (zip (subtrees xs) (zip (butlast (ra # zs)) (zip zs split))) (separators xs)) * ↑ (length split = length zs)); set (x # xs) ⊆ set tsi'; set (z # zs) ⊆ set rs; set (y # ys) ⊆ set ts⟧ ⟹ blist_assn k (y # ys) (zip (zip (subtrees (x # xs)) (zip (butlast (ra # z # zs)) (z # zs))) (separators (x # xs))) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (y # ys) (zip (zip (subtrees (x # xs)) (zip (butlast (ra # z # zs)) (zip (z # zs) split))) (separators (x # xs))) * ↑ (length split = length (z # zs)))›*) case (Cons subsepi tsi's subsep tss subleaf rss r) (*‹length (tsi's::('a::heap btnode ref option × 'a::heap) list) = length (tss::('a::heap bplustree × 'a::heap) list)› ‹length tss = length rss› ‹⟦set (tsi's::('a btnode ref option × 'a) list) ⊆ set (tsi'::('a btnode ref option × 'a) list); set (rss::'a btnode ref option list) ⊆ set (rs::'a btnode ref option list); set (tss::('a bplustree × 'a) list) ⊆ set (ts::('a bplustree × 'a) list)⟧ ⟹ blist_assn (k::nat) tss (zip (zip (subtrees tsi's) (zip (butlast ((?ra::'a btnode ref option) # rss)) rss)) (separators tsi's)) = (∃⇩Asplit::'a btnode ref list list. list_assn ((λ(t::'a bplustree) a::'a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list. case a of (ti::'a btnode ref option, r'::'a btnode ref option, a::'a btnode ref option, c::'a btnode ref list) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (?ra # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss))› ‹set (subsepi # tsi's) ⊆ set tsi'› ‹set (subleaf # rss) ⊆ set rs› ‹set (subsep # tss) ⊆ set ts›*) then show "?case" (*goal: ‹blist_assn k (subsep # tss) (zip (zip (subtrees (subsepi # tsi's)) (zip (butlast (r # subleaf # rss)) (subleaf # rss))) (separators (subsepi # tsi's))) = (∃⇩Asplit. list_assn ((λt a. case a of (ti, r', a, c) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) (subsep # tss) (zip (zip (subtrees (subsepi # tsi's)) (zip (butlast (r # subleaf # rss)) (zip (subleaf # rss) split))) (separators (subsepi # tsi's))) * ↑ (length split = length (subleaf # rss)))›*) apply (auto simp add: butlast_double_Cons (*‹butlast (?x # ?y # ?xs) = ?x # butlast (?y # ?xs)›*) last_double_Cons (*‹last (?x # ?y # ?xs) = last (?y # ?xs)›*)) (*goal: ‹blist_assn k (subsep # tss) (zip (zip (subtrees (subsepi # tsi's)) (zip (butlast (r # subleaf # rss)) (subleaf # rss))) (separators (subsepi # tsi's))) = (∃⇩Asplit. list_assn ((λt a. case a of (ti, r', a, c) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) (subsep # tss) (zip (zip (subtrees (subsepi # tsi's)) (zip (butlast (r # subleaf # rss)) (zip (subleaf # rss) split))) (separators (subsepi # tsi's))) * ↑ (length split = length (subleaf # rss)))›*) apply (auto simp add: prod_assn_def (*‹(?P1.0 ×⇩a ?P2.0) ?a ?c ≡ case (?a, ?c) of ((a1, a2), c1, c2) ⇒ ?P1.0 a1 c1 * ?P2.0 a2 c2›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹⟦length tsi's = length rss; length tss = length rss; ⋀ra. blist_assn k tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) rss)) (separators tsi's)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)); subsepi ∈ set tsi'; set tsi's ⊆ set tsi'; subleaf ∈ set rs; set rss ⊆ set rs; subsep ∈ set ts; set tss ⊆ set ts⟧ ⟹ (∃⇩Asplit. ((λt (ti, x, y). bplustree_assn k t (the ti) x y) ×⇩a id_assn) subsep ((fst subsepi, r, subleaf), snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (subsep # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)))›*) proof (goal_cases) (*goal: ‹⋀(x1::'a::heap bplustree) x2::'a::heap. ⟦length (tsi's::('a::heap btnode ref option × 'a::heap) list) = length (rss::'a::heap btnode ref option list); length (tss::('a::heap bplustree × 'a::heap) list) = length rss; ⋀ra::'a::heap btnode ref option. blist_assn (k::nat) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) rss)) (separators tsi's)) = (∃⇩Asplit::'a::heap btnode ref list list. list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)); (subsepi::'a::heap btnode ref option × 'a::heap) ∈ set (tsi'::('a::heap btnode ref option × 'a::heap) list); set tsi's ⊆ set tsi'; (subleaf::'a::heap btnode ref option) ∈ set (rs::'a::heap btnode ref option list); set rss ⊆ set rs; (x1, x2) ∈ set (ts::('a::heap bplustree × 'a::heap) list); set tss ⊆ set ts; (subsep::'a::heap bplustree × 'a::heap) = (x1, x2)⟧ ⟹ (∃⇩Asplit::'a::heap btnode ref list list. bplustree_assn k x1 (the (fst subsepi)) (r::'a::heap btnode ref option) subleaf * id_assn x2 (snd subsepi) * list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)) = (∃⇩Asplit::'a::heap btnode ref list list. list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((x1, x2) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)))›*) case (1 sub sep) (*‹length tsi's = length rss› ‹length tss = length rss› ‹blist_assn (k::nat) (tss::('a bplustree × 'a) list) (zip (zip (subtrees (tsi's::('a btnode ref option × 'a) list)) (zip (butlast ((?ra::'a btnode ref option) # (rss::'a btnode ref option list))) rss)) (separators tsi's)) = (∃⇩Asplit::'a btnode ref list list. list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (?ra # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss))› ‹subsepi ∈ set tsi'› ‹set tsi's ⊆ set tsi'› ‹subleaf ∈ set rs› ‹set rss ⊆ set rs› ‹(sub, sep) ∈ set ts› ‹set tss ⊆ set ts› ‹(subsep::'a::heap bplustree × 'a::heap) = (sub::'a::heap bplustree, sep::'a::heap)›*) then have "*": "bplustree_assn k sub (the (fst subsepi)) r subleaf = (∃⇩As. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf s)" proof (-) (*goal: ‹⟦length (tsi's::('a btnode ref option × 'a) list) = length (rss::'a btnode ref option list); length (tss::('a bplustree × 'a) list) = length rss; ⋀ra::'a btnode ref option. blist_assn (k::nat) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) rss)) (separators tsi's)) = (∃⇩Asplit::'a btnode ref list list. list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)); (subsepi::'a btnode ref option × 'a) ∈ set (tsi'::('a btnode ref option × 'a) list); set tsi's ⊆ set tsi'; (subleaf::'a btnode ref option) ∈ set (rs::'a btnode ref option list); set rss ⊆ set rs; (sub::'a bplustree, sep::'a) ∈ set (ts::('a bplustree × 'a) list); set tss ⊆ set ts; (subsep::'a bplustree × 'a) = (sub, sep)⟧ ⟹ bplustree_assn k sub (the (fst subsepi)) (r::'a btnode ref option) subleaf = (∃⇩As::'a btnode ref list. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf s)›*) have "subsep ∈ set ts" by (simp add: "1" (*‹subsep = (sub, sep)›*) (10) "1" (*‹(sub, sep) ∈ set ts›*) (8)) moreover obtain temp1 and temp2 where "((fst subsepi, (temp1:: 'a btnode ref option), subleaf), (temp2::'a)) ∈ set [((fst subsepi, temp1, subleaf), temp2)]" (*goal: ‹(⋀temp1 temp2. ((fst subsepi, temp1, subleaf), temp2) ∈ set [((fst subsepi, temp1, subleaf), temp2)] ⟹ thesis) ⟹ thesis›*) by auto ultimately show "?thesis" (*goal: ‹bplustree_assn (k::nat) (sub::'a bplustree) (the (fst (subsepi::'a btnode ref option × 'a))) (r::'a btnode ref option) (subleaf::'a btnode ref option) = (∃⇩As::'a btnode ref list. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf s)›*) using Istep(2)[of "(sub,sep)" "((fst subsepi, temp1, subleaf), temp2)" "[((fst subsepi, temp1, subleaf), temp2)]" "fst subsepi" "(temp1, subleaf)" temp1 subleaf r] (*‹⟦(sub, sep) ∈ set ts; ((fst subsepi, temp1, subleaf), temp2) ∈ set [((fst subsepi, temp1, subleaf), temp2)]; (fst subsepi, temp1, subleaf) = fst ((fst subsepi, temp1, subleaf), temp2); (temp1, subleaf) = (temp1, subleaf)⟧ ⟹ bplustree_assn k (fst (sub, sep)) (the (fst subsepi)) r subleaf = (∃⇩Aa. bplustree_assn_leafs k (fst (sub, sep)) (the (fst subsepi)) r subleaf a)›*) using "1" (*‹length tsi's = length rss› ‹length tss = length rss› ‹blist_assn k tss (zip (zip (subtrees tsi's) (zip (butlast (?ra # rss)) rss)) (separators tsi's)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (?ra # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss))› ‹subsepi ∈ set tsi'› ‹set (tsi's::('a btnode ref option × 'a) list) ⊆ set (tsi'::('a btnode ref option × 'a) list)› ‹(subleaf::'a::heap btnode ref option) ∈ set (rs::'a::heap btnode ref option list)› ‹set rss ⊆ set rs› ‹(sub, sep) ∈ set ts› ‹set (tss::('a bplustree × 'a) list) ⊆ set (ts::('a bplustree × 'a) list)› ‹subsep = (sub, sep)›*) by simp qed show "?case" (*goal: ‹(∃⇩Asplit. bplustree_assn k sub (the (fst subsepi)) r subleaf * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)))›*) apply (simp add: * (*‹bplustree_assn k sub (the (fst subsepi)) r subleaf = (∃⇩As. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf s)›*) 1(3)[of subleaf] (*‹blist_assn k tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) rss)) (separators tsi's)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss))›*)) (*goal: ‹(∃⇩Asplit. bplustree_assn k sub (the (fst subsepi)) r subleaf * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)))›*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹(∃⇩Asplit x. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)) = (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)))›*) subgoal for apply (intro ent_ex_preI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a::type. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Asplit x. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss) ⟹⇩A ∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss))›*) subgoal for split and x apply (inst_ex_assn "x#split") (*goal: ‹bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss) ⟹⇩A ∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss))›*) by simp . subgoal for apply (intro ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Asplit::'a btnode ref list list. list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) r' x y) ×⇩a id_assn) ((sub::'a bplustree, sep::'a) # (tss::('a bplustree × 'a) list)) (zip (zip (fst (subsepi::'a btnode ref option × 'a) # subtrees (tsi's::('a btnode ref option × 'a) list)) (zip ((r::'a btnode ref option) # butlast ((subleaf::'a btnode ref option) # (rss::'a btnode ref option list))) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)) ⟹⇩A ∃⇩A(split::'a btnode ref list list) x::'a btnode ref list. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)›*) subgoal for split apply (cases split) (*goal: ‹list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)) ⟹⇩A ∃⇩Asplit x. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)›*) apply simp (*top goal: ‹split = [] ⟹ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)) ⟹⇩A ∃⇩Asplit x. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)› and 1 goal remains*) subgoal for hdsplit and tlsplit apply (inst_ex_assn "tlsplit" "hdsplit") (*goal: ‹split = hdsplit # tlsplit ⟹ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ((sub, sep) # tss) (zip (zip (fst subsepi # subtrees tsi's) (zip (r # butlast (subleaf # rss)) (zip (subleaf # rss) split))) (snd subsepi # separators tsi's)) * ↑ (length split = Suc (length rss)) ⟹⇩A ∃⇩Asplit x. bplustree_assn_leafs k sub (the (fst subsepi)) r subleaf x * id_assn sep (snd subsepi) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss split))) (separators tsi's)) * ↑ (length split = length rss)›*) by auto . . . qed qed have "**": "bplustree_assn k t ti (last (r # rs)) z = (∃⇩Alsplit. bplustree_assn_leafs k t ti (last (r # rs)) z lsplit)" using Istep(1)[of ti "last(r #rs)" "[]"] (*‹bplustree_assn k t ti (last (r # rs)) (last ([] @ [z])) = (∃⇩Aa. bplustree_assn_leafs k t ti (last (r # rs)) (last ([] @ [z])) a)›*) by (auto simp add: last.simps (*‹last (?x # ?xs) = (if ?xs = [] then ?x else last ?xs)›*)) show "?case" (*goal: ‹(∃⇩Aaa. a ↦⇩r Btnode tsi ti * bplustree_assn k t ti (last (r # rs)) z * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) = (∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')))›*) apply (subst ** (*‹bplustree_assn (k::nat) (t::'a::heap bplustree) (ti::'a::heap btnode ref) (last ((r::'a::heap btnode ref option) # (rs::'a::heap btnode ref option list))) (z::'a::heap btnode ref option) = (∃⇩Alsplit::'a::heap btnode ref list. bplustree_assn_leafs k t ti (last (r # rs)) z lsplit)›*)) (*goal: ‹(∃⇩Aaa. a ↦⇩r Btnode tsi ti * bplustree_assn k t ti (last (r # rs)) z * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) = (∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')))›*) apply (simp add: inst_same[OF bplustree_assn_leafs.simps(2)] (*‹(∃⇩Ax. bplustree_assn_leafs (?k1 x) (Node (?ts1 x) (?t1 x)) (?a1 x) (?r1 x) (?z1 x) (?leafptrs1 x)) = (∃⇩Ax tsi ti tsi' tsi'' rs split. ?a1 x ↦⇩r Btnode tsi ti * bplustree_assn_leafs (?k1 x) (?t1 x) ti (last (?r1 x # rs)) (last (rs @ [?z1 x])) (last split) * is_pfa (2 * ?k1 x) tsi' tsi * ↑ (concat split = ?leafptrs1 x) * ↑ (length tsi' = length rs) * ↑ (length split = length rs + 1) * ↑ (tsi'' = zip (zip (subtrees tsi') (zip (butlast (?r1 x # rs)) (zip (butlast (rs @ [?z1 x])) (butlast split)))) (separators tsi')) * list_assn ((λt (ti, r', xa, y). bplustree_assn_leafs (?k1 x) t (the ti) r' xa y) ×⇩a id_assn) (?ts1 x) tsi'')›*)) (*goal: ‹(∃⇩Aaa. a ↦⇩r Btnode tsi ti * ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) = (∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')))›*) proof (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*), goal_cases) (*goals: 1. ‹∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))› 2. ‹∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) case _: 1 (*no hyothesis introduced yet*) show "?case" (*goal: ‹∃⇩A(aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option) × 'a::heap) list) x::'a::heap btnode ref list. (a::'a::heap btnode ref) ↦⇩r Btnode (tsi::('a::heap btnode ref option × 'a::heap) array × nat) (ti::'a::heap btnode ref) * bplustree_assn_leafs (k::nat) (t::'a::heap bplustree) ti (last ((r::'a::heap btnode ref option) # (rs::'a::heap btnode ref option list))) (z::'a::heap btnode ref option) x * is_pfa ((2::nat) * k) (tsi'::('a::heap btnode ref option × 'a::heap) list) tsi * blist_assn k (ts::('a::heap bplustree × 'a::heap) list) aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩A(c::'a::heap btnode ref list) (aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list) d::'a::heap btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply (rule entails_preI (*‹(⋀h. h ⊨ ?P ⟹ ?P ⟹⇩A ?Q) ⟹ ?P ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply (intro ent_ex_preI (*‹(⋀x::?'a. (?P::?'a ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a. ?P x ⟹⇩A ?Q›*)) (*goal: ‹⋀h. h ⊨ (∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) ⟹ ∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply (clarsimp dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹?h ⊨ list_assn ?A ?xs ?ys ⟹ length ?xs = length ?ys›*)) (*goal: ‹⋀(h::heap × nat set) (aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option) × 'a::heap) list) x::'a::heap btnode ref list. h ⊨ (∃⇩A(aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option) × 'a::heap) list) x::'a::heap btnode ref list. (a::'a::heap btnode ref) ↦⇩r Btnode (tsi::('a::heap btnode ref option × 'a::heap) array × nat) (ti::'a::heap btnode ref) * bplustree_assn_leafs (k::nat) (t::'a::heap bplustree) ti (last ((r::'a::heap btnode ref option) # (rs::'a::heap btnode ref option list))) (z::'a::heap btnode ref option) x * is_pfa ((2::nat) * k) (tsi'::('a::heap btnode ref option × 'a::heap) list) tsi * blist_assn k (ts::('a::heap bplustree × 'a::heap) list) aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) ⟹ a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩A(c::'a::heap btnode ref list) (aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list) d::'a::heap btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply (subst *[of tsi' ts rs] (*‹⟦length tsi' = length ts; length ts = length rs; set tsi' ⊆ set tsi'; set rs ⊆ set rs; set ts ⊆ set ts⟧ ⟹ blist_assn k ts (zip (zip (subtrees tsi') (zip (butlast (?ra # rs)) rs)) (separators tsi')) = (∃⇩Asplit. list_assn ((λt (ti, r', z', lptrs). bplustree_assn_leafs k t (the ti) r' z' lptrs) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (?ra # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs))›*)) (*goal: ‹⋀x xa ae bd af be ag bf. ⟦length tsi' = length rs; length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z xa⟧ ⟹ a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply simp_all (*top goal: ‹⋀(x::'a btnode ref list) (xa::'a btnode ref list) (ae::heap) (bd::nat set) (af::heap) (be::nat set) (ag::heap) bf::nat set. ⟦length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list); length (ts::('a bplustree × 'a) list) = length rs; (ae, bd) ⊨ is_pfa ((2::nat) * (k::nat)) tsi' (tsi::('a btnode ref option × 'a) array × nat); (af, be) ⊨ (a::'a btnode ref) ↦⇩r Btnode tsi (ti::'a btnode ref); (ag, bf) ⊨ bplustree_assn_leafs k (t::'a bplustree) ti (last ((r::'a btnode ref option) # rs)) (z::'a btnode ref option) xa⟧ ⟹ length tsi' = length ts› and 5 goals remain*) apply (intro ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹⋀x xa ae bd af be ag bf. ⟦length tsi' = length rs; length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z xa⟧ ⟹ ∃⇩Asplit. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply (rule entails_preI (*‹(⋀h. h ⊨ ?P ⟹ ?P ⟹⇩A ?Q) ⟹ ?P ⟹⇩A ?Q›*)) (*goal: ‹⋀x xa ae bd af be ag bf split. ⟦length tsi' = length rs; length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z xa⟧ ⟹ a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) apply (clarsimp dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹?h ⊨ list_assn ?A ?xs ?ys ⟹ length ?xs = length ?ys›*)) (*goal: ‹⋀x xa ae bd af be ag bf split h. ⟦length tsi' = length rs; length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z xa; h ⊨ a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs)⟧ ⟹ a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) subgoal for lsplit and _ and _ and _ and _ and _ and _ and _ and split find_theorems "∃⇩A_._" apply (inst_ex_assn "concat (split@[lsplit])" "zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast (split@[lsplit]))))) (separators tsi')" "split@[lsplit]") (*goal: ‹⟦length tsi' = length rs; (ae_, bd_) ⊨ is_pfa (2 * k) tsi' tsi; (af_, be_) ⊨ a ↦⇩r Btnode tsi ti; (ag_, bf_) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z xa_; length split = length rs; length ts = length rs; (ad_, bg_) ⊨ is_pfa (2 * k) tsi' tsi; (ah_, bh_) ⊨ a ↦⇩r Btnode tsi ti; (ai_, bi_) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z lsplit⟧ ⟹ a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z lsplit * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) ⟹⇩A ∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))›*) by (sep_auto simp add: last.simps butlast.simps) . next (*goal: ‹∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) case _: 2 (*no hyothesis introduced yet*) show "?case" (*goal: ‹∃⇩A(c::'a btnode ref list) (aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) d::'a btnode ref list list. (a::'a btnode ref) ↦⇩r Btnode (tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) * bplustree_assn_leafs (k::nat) (t::'a bplustree) ti (last ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (z::'a btnode ref option) (last d) * is_pfa ((2::nat) * k) (tsi'::('a btnode ref option × 'a) list) tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (ts::('a bplustree × 'a) list) aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩A(aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option) × 'a) list) x::'a btnode ref list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply (rule entails_preI (*‹(⋀h. h ⊨ ?P ⟹ ?P ⟹⇩A ?Q) ⟹ ?P ⟹⇩A ?Q›*)) (*goal: ‹∃⇩A(c::'a::heap btnode ref list) (aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list) d::'a::heap btnode ref list list. (a::'a::heap btnode ref) ↦⇩r Btnode (tsi::('a::heap btnode ref option × 'a::heap) array × nat) (ti::'a::heap btnode ref) * bplustree_assn_leafs (k::nat) (t::'a::heap bplustree) ti (last ((r::'a::heap btnode ref option) # (rs::'a::heap btnode ref option list))) (z::'a::heap btnode ref option) (last d) * is_pfa ((2::nat) * k) (tsi'::('a::heap btnode ref option × 'a::heap) list) tsi * list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (ts::('a::heap bplustree × 'a::heap) list) aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩A(aa::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option) × 'a::heap) list) x::'a::heap btnode ref list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply (rule ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹⋀h::heap × nat set. h ⊨ (∃⇩A(c::'a btnode ref list) (aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) d::'a btnode ref list list. (a::'a btnode ref) ↦⇩r Btnode (tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) * bplustree_assn_leafs (k::nat) (t::'a bplustree) ti (last ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (z::'a btnode ref option) (last d) * is_pfa ((2::nat) * k) (tsi'::('a btnode ref option × 'a) list) tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (ts::('a bplustree × 'a) list) aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))) ⟹ ∃⇩A(c::'a btnode ref list) (aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) d::'a btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩A(aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option) × 'a) list) x::'a btnode ref list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply (rule ent_ex_preI (*‹(⋀x::?'a. (?P::?'a ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a. ?P x ⟹⇩A ?Q›*)) (*goal: ‹⋀h c. h ⊨ (∃⇩Ac aa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))) ⟹ ∃⇩Aaa d. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply (clarsimp dest!: mod_starD (*‹(?h::heap × nat set) ⊨ (?A::assn) * (?B::assn) ⟹ ∃(h1::heap × nat set) h2::heap × nat set. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹(?h::heap × nat set) ⊨ list_assn (?A::?'a ⇒ ?'b ⇒ assn) (?xs::?'a list) (?ys::?'b list) ⟹ length ?xs = length ?ys›*)) (*goal: ‹⋀(h::heap × nat set) (c::'a btnode ref list) aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list. h ⊨ (∃⇩A(c::'a btnode ref list) (aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list) d::'a btnode ref list list. (a::'a btnode ref) ↦⇩r Btnode (tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref) * bplustree_assn_leafs (k::nat) (t::'a bplustree) ti (last ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (z::'a btnode ref option) (last d) * is_pfa ((2::nat) * k) (tsi'::('a btnode ref option × 'a) list) tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (ts::('a bplustree × 'a) list) aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi'))) ⟹ ∃⇩Ad::'a btnode ref list list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa ((2::nat) * k) tsi' tsi * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length tsi' = length rs ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩A(aa::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option) × 'a) list) x::'a btnode ref list. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa ((2::nat) * k) tsi' tsi * blist_assn k ts aa * ↑ (length tsi' = length rs ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply ((subst merge_pure_star[symmetric] (*‹↑ (?a ∧ ?b) = ↑ ?a * ↑ ?b›*) mult.left_assoc (*‹?a * (?b * ?c) = ?a * ?b * ?c›*))+) (*goal: ‹⋀c aa d ae bd af be ag bf. ⟦length tsi' = length rs; length d = Suc (length rs); length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)⟧ ⟹ ∃⇩Ad. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c ∧ length d = Suc (length rs) ∧ aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply ((subst otf_lem_comm_ex (*‹(∃⇩Ax. ?a * ?b x * ?c * ?d x * ?e x * ?f x * ?g x) = ?a * ?c * (∃⇩Ax. ?b x * ?d x * ?e x * ?f x * ?g x)› ‹(∃⇩Aaa x. ?a * ?b x * ?c * ?d aa * ?e aa) = ?a * ?c * (∃⇩Aaa x. ?b x * ?d aa * ?e aa)› ‹(∃⇩Aaa x. ?b x * ?d aa * ?e aa) = (∃⇩Ax. ?b x) * (∃⇩Aaa. ?d aa * ?e aa)›*))+) (*goal: ‹⋀c aa d ae bd af be ag bf. ⟦length tsi' = length rs; length d = Suc (length rs); length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)⟧ ⟹ ∃⇩Ad. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last d) * is_pfa (2 * k) tsi' tsi * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat d = c) * ↑ (length d = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast d)))) (separators tsi')) ⟹⇩A ∃⇩Aaa x. a ↦⇩r Btnode tsi ti * bplustree_assn_leafs k t ti (last (r # rs)) z x * is_pfa (2 * k) tsi' tsi * blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*) apply (rule ent_star_mono (*‹⟦?P ⟹⇩A ?P'; ?Q ⟹⇩A ?Q'⟧ ⟹ ?P * ?Q ⟹⇩A ?P' * ?Q'›*)) (*goal: ‹⋀c aa d ae bd af be ag bf. ⟦length tsi' = length rs; length d = Suc (length rs); length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)⟧ ⟹ a ↦⇩r Btnode tsi ti * is_pfa (2 * k) tsi' tsi * (∃⇩Ax. bplustree_assn_leafs k t ti (last (r # rs)) z (last x) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat x = c) * ↑ (length x = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast x)))) (separators tsi'))) ⟹⇩A a ↦⇩r Btnode tsi ti * is_pfa (2 * k) tsi' tsi * (ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) * (∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))))›*) subgoal for by sep_auto proof (goal_cases) (*goal: ‹⋀c aa d ae bd af be ag bf. ⟦length tsi' = length rs; length d = Suc (length rs); length ts = length rs; (ae, bd) ⊨ is_pfa (2 * k) tsi' tsi; (af, be) ⊨ a ↦⇩r Btnode tsi ti; (ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)⟧ ⟹ ∃⇩Ax. bplustree_assn_leafs k t ti (last (r # rs)) z (last x) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat x = c) * ↑ (length x = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast x)))) (separators tsi')) ⟹⇩A ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) * (∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')))›*) case (1 c aa d ae bd af be ag bf) (*‹length tsi' = length rs› ‹length d = Suc (length rs)› ‹length ts = length rs› ‹(ae, bd) ⊨ is_pfa (2 * k) tsi' tsi› ‹(af, be) ⊨ a ↦⇩r Btnode tsi ti› ‹(ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)›*) have "**": "(∃⇩Ax. bplustree_assn_leafs k t ti (last (r # rs)) z (last x) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat x = c) * ↑ (length x = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast x)))) (separators tsi'))) ⟹⇩A ((∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs)) * (∃⇩Alsplit. bplustree_assn_leafs k t ti (last (r # rs)) z lsplit) )" using "1" (*‹length tsi' = length rs› ‹length d = Suc (length rs)› ‹length ts = length rs› ‹(ae::heap, bd::nat set) ⊨ is_pfa ((2::nat) * (k::nat)) (tsi'::('a btnode ref option × 'a) list) (tsi::('a btnode ref option × 'a) array × nat)› ‹(af, be) ⊨ a ↦⇩r Btnode tsi ti› ‹(ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)›*) by sep_auto from "**" (*‹∃⇩Ax. bplustree_assn_leafs k t ti (last (r # rs)) z (last x) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat x = c) * ↑ (length x = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast x)))) (separators tsi')) ⟹⇩A (∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs)) * (∃⇩Alsplit. bplustree_assn_leafs k t ti (last (r # rs)) z lsplit)›*) show "?case" (*goal: ‹∃⇩Ax. bplustree_assn_leafs k t ti (last (r # rs)) z (last x) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat x = c) * ↑ (length x = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast x)))) (separators tsi')) ⟹⇩A ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) * (∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')))›*) apply (rule ent_trans (*‹⟦?P ⟹⇩A ?Q; ?Q ⟹⇩A ?R⟧ ⟹ ?P ⟹⇩A ?R›*)) (*goal: ‹∃⇩Ax. bplustree_assn_leafs k t ti (last (r # rs)) z (last x) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts aa * ↑ (concat x = c) * ↑ (length x = Suc (length rs)) * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast x)))) (separators tsi')) ⟹⇩A ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) * (∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')))›*) apply (subst mult.commute[of "ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z)"] (*‹ex_assn (bplustree_assn_leafs (k::nat) (t::'a bplustree) (ti::'a btnode ref) (last ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (z::'a btnode ref option)) * (?b::assn) = ?b * ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z)›*)) (*goal: ‹(∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs)) * (∃⇩Alsplit. bplustree_assn_leafs k t ti (last (r # rs)) z lsplit) ⟹⇩A ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) * (∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')))›*) apply (rule ent_star_mono (*‹⟦?P ⟹⇩A ?P'; ?Q ⟹⇩A ?Q'⟧ ⟹ ?P * ?Q ⟹⇩A ?P' * ?Q'›*)) (*goal: ‹(∃⇩Asplit. list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs)) * ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) ⟹⇩A (∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))) * ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z)›*) prefer 2 (*top goal: ‹ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z) ⟹⇩A ex_assn (bplustree_assn_leafs k t ti (last (r # rs)) z)› and 1 goal remains*) subgoal for by sep_auto subgoal for apply (subst *[of tsi' ts rs r, symmetric] (*‹⟦length tsi' = length ts; length ts = length rs; set tsi' ⊆ set tsi'; set rs ⊆ set rs; set ts ⊆ set ts⟧ ⟹ (∃⇩Asplit. list_assn ((λt (ti, r', z', lptrs). bplustree_assn_leafs k t (the ti) r' z' lptrs) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs split))) (separators tsi')) * ↑ (length split = length rs)) = blist_assn k ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))›*)) (*goals: 1. ‹length tsi' = length ts› 2. ‹length ts = length rs› 3. ‹set tsi' ⊆ set tsi'› 4. ‹set rs ⊆ set rs› 5. ‹set ts ⊆ set ts› 6. ‹blist_assn k ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi')) ⟹⇩A ∃⇩Aaa. blist_assn k ts aa * ↑ (aa = zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))› discuss goal 1*) apply (simp add: 1 (*‹length tsi' = length rs› ‹length d = Suc (length rs)› ‹length ts = length rs› ‹(ae, bd) ⊨ is_pfa (2 * k) tsi' tsi› ‹(af, be) ⊨ a ↦⇩r Btnode tsi ti› ‹(ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)›*)) (*discuss goal 2*) apply (simp add: 1 (*‹length tsi' = length rs› ‹length d = Suc (length rs)› ‹length ts = length rs› ‹(ae, bd) ⊨ is_pfa (2 * k) tsi' tsi› ‹(af, be) ⊨ a ↦⇩r Btnode tsi ti› ‹(ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)›*)) (*discuss goal 3*) apply (simp add: 1 (*‹length tsi' = length rs› ‹length d = Suc (length rs)› ‹length ts = length rs› ‹(ae, bd) ⊨ is_pfa (2 * k) tsi' tsi› ‹(af, be) ⊨ a ↦⇩r Btnode tsi ti› ‹(ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)›*)) (*discuss goal 4*) apply (simp add: 1 (*‹length tsi' = length rs› ‹length d = Suc (length rs)› ‹length ts = length rs› ‹(ae, bd) ⊨ is_pfa (2 * k) tsi' tsi› ‹(af, be) ⊨ a ↦⇩r Btnode tsi ti› ‹(ag, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last d)›*)) (*discuss goal 5*) apply (simp add: 1 (*‹length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list)› ‹length (d::'a btnode ref list list) = Suc (length (rs::'a btnode ref option list))› ‹length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list)› ‹(ae::heap, bd::nat set) ⊨ is_pfa ((2::nat) * (k::nat)) (tsi'::('a btnode ref option × 'a) list) (tsi::('a btnode ref option × 'a) array × nat)› ‹(af::heap, be::nat set) ⊨ (a::'a btnode ref) ↦⇩r Btnode (tsi::('a btnode ref option × 'a) array × nat) (ti::'a btnode ref)› ‹(ag::heap, bf::nat set) ⊨ bplustree_assn_leafs (k::nat) (t::'a bplustree) (ti::'a btnode ref) (last ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (z::'a btnode ref option) (last (d::'a btnode ref list list))›*)) (*discuss goal 6*) apply sep_auto (*proven 6 subgoals*) . . qed qed qed qed declare last.simps[simp add] butlast.simps[simp add] (* even without the existential quantifier, we get our general assertion, used in insertion etc back*) lemma bplustree_discard_leafs: "bplustree_assn_leafs k t ti r z leafptrs ⟹⇩A bplustree_assn k t ti r z" by (simp add: bplustree_extract_leafs (*‹bplustree_assn ?k ?t ?ti ?r ?z = (∃⇩Aleafptrs. bplustree_assn_leafs ?k ?t ?ti ?r ?z leafptrs)›*)) fun leaf_nodes_assn :: "nat ⇒ ('a::heap) bplustree list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode ref list ⇒ assn" where "leaf_nodes_assn k ((Leaf xs)#lns) (Some r) z (r'#lptrs) = (∃⇩A xsi fwd. r ↦⇩r Btleaf xsi fwd * is_pfa (2*k) xs xsi * leaf_nodes_assn k lns fwd z lptrs * ↑(r = r') )" | "leaf_nodes_assn k [] r z [] = ↑(r = z)" | "leaf_nodes_assn _ _ _ _ _ = false" fun trunk_assn :: "nat ⇒ ('a::heap) bplustree ⇒ 'a btnode ref ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode ref list ⇒ assn" where "trunk_assn k (Leaf xs) a r z lptrs = ↑(r = Some a ∧ lptrs = [a])" | "trunk_assn k (Node ts t) a r z lptrs = (∃⇩A tsi ti tsi' tsi'' rs split. a ↦⇩r Btnode tsi ti * trunk_assn k t ti (last (r#rs)) (last (rs@[z])) (last split) * is_pfa (2*k) tsi' tsi * ↑(concat split = lptrs) * ↑(length tsi' = length rs) * ↑(length split = length rs + 1) * ↑(tsi'' = zip (zip (map fst tsi') (zip (butlast (r#rs)) (zip (butlast (rs@[z])) (butlast split)))) (map snd tsi')) * list_assn ((λ t (ti,r',z',lptrs). trunk_assn k t (the ti) r' z' lptrs) ×⇩a id_assn) ts tsi'' )" lemma leaf_nodes_assn_split: "length xs = length xsi ⟹ ysi = (yi#ysr) ⟹ leaf_nodes_assn k (xs @ ys) r z (xsi @ ysi) = leaf_nodes_assn k xs r (Some yi) xsi * leaf_nodes_assn k ys (Some yi) z ysi" proof (induction arbitrary: r rule: list_induct2) (*goals: 1. ‹⋀r. ysi = yi # ysr ⟹ leaf_nodes_assn k ([] @ ys) r z ([] @ ysi) = leaf_nodes_assn k [] r (Some yi) [] * leaf_nodes_assn k ys (Some yi) z ysi› 2. ‹⋀x xs y ysa r. ⟦length xs = length ysa; ⋀r. ysi = yi # ysr ⟹ leaf_nodes_assn k (xs @ ys) r z (ysa @ ysi) = leaf_nodes_assn k xs r (Some yi) ysa * leaf_nodes_assn k ys (Some yi) z ysi; ysi = yi # ysr⟧ ⟹ leaf_nodes_assn k ((x # xs) @ ys) r z ((y # ysa) @ ysi) = leaf_nodes_assn k (x # xs) r (Some yi) (y # ysa) * leaf_nodes_assn k ys (Some yi) z ysi›*) case (Nil r) (*‹ysi = yi # ysr›*) then show "?case" (*goal: ‹leaf_nodes_assn k ([] @ ys) r z ([] @ ysi) = leaf_nodes_assn k [] r (Some yi) [] * leaf_nodes_assn k ys (Some yi) z ysi›*) apply (cases r; cases ys) (*goal: ‹leaf_nodes_assn k ([] @ ys) r z ([] @ ysi) = leaf_nodes_assn k [] r (Some yi) [] * leaf_nodes_assn k ys (Some yi) z ysi›*) apply clarsimp_all (*top goal: ‹⟦ysi = yi # ysr; r = None; ysi = yi # ysr; ys = []⟧ ⟹ leaf_nodes_assn k ([] @ ys) r z ([] @ ysi) = leaf_nodes_assn k [] r (Some yi) [] * leaf_nodes_assn k ys (Some yi) z ysi› and 3 goals remain*) subgoal for _ and t and _ apply (cases t) (*goals: 1. ‹⋀x1. ⟦r = Some a_; ysi = yi # ysr; ys = t # list_; t = Leaf x1⟧ ⟹ leaf_nodes_assn k (t # list_) (Some a_) z (yi # ysr) = leaf_nodes_assn k (t # list_) (Some yi) z (yi # ysr) * ↑ (a_ = yi)› 2. ‹⋀x21 x22. ⟦r = Some a_; ysi = yi # ysr; ys = t # list_; t = Node x21 x22⟧ ⟹ leaf_nodes_assn k (t # list_) (Some a_) z (yi # ysr) = leaf_nodes_assn k (t # list_) (Some yi) z (yi # ysr) * ↑ (a_ = yi)› discuss goal 1*) apply clarsimp (*top goal: ‹⋀x1. ⟦r = Some a_; ysi = yi # ysr; ys = t # list_; t = Leaf x1⟧ ⟹ leaf_nodes_assn k (t # list_) (Some a_) z (yi # ysr) = leaf_nodes_assn k (t # list_) (Some yi) z (yi # ysr) * ↑ (a_ = yi)› and 1 goal remains*) apply (intro inst_same (*‹(⋀x::?'a. (?P::?'a ⇒ assn) x = (?Q::?'a ⇒ assn) x) ⟹ (∃⇩Ax::?'a. ?P x) = (∃⇩Ax::?'a. ?Q x)›*)) (*top goal: ‹⋀x1::'a::heap list. ⟦(r::'a::heap btnode ref option) = Some (a_::'a::heap btnode ref); (ysi::'a::heap btnode ref list) = (yi::'a::heap btnode ref) # (ysr::'a::heap btnode ref list); (ys::'a::heap bplustree list) = Leaf x1 # (list_::'a::heap bplustree list); (t::'a::heap bplustree) = Leaf x1⟧ ⟹ (∃⇩A(xsi::'a::heap array × nat) fwd::'a::heap btnode ref option. a_ ↦⇩r Btleaf xsi fwd * is_pfa ((2::nat) * (k::nat)) x1 xsi * leaf_nodes_assn k list_ fwd (z::'a::heap btnode ref option) ysr * ↑ (a_ = yi)) = (∃⇩A(xsi::'a::heap array × nat) fwd::'a::heap btnode ref option. yi ↦⇩r Btleaf xsi fwd * is_pfa ((2::nat) * k) x1 xsi * leaf_nodes_assn k list_ fwd z ysr * ↑ (a_ = yi))› and 1 goal remains*) apply (rule pure_eq_pre (*‹(?P ⟹ ?Q = ?R) ⟹ ?Q * ↑ ?P = ?R * ↑ ?P›*)) (*top goal: ‹⋀x1 xsi fwd. ⟦r = Some a_; ysi = yi # ysr; ys = Leaf x1 # list_; t = Leaf x1⟧ ⟹ a_ ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k list_ fwd z ysr * ↑ (a_ = yi) = yi ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k list_ fwd z ysr * ↑ (a_ = yi)› and 1 goal remains*) apply ((clarsimp_all)[1]) (*discuss goal 2*) apply ((clarsimp_all)[1]) (*proven 2 subgoals*) . . next (*goal: ‹⋀x xs y ysa r. ⟦length xs = length ysa; ⋀r. ysi = yi # ysr ⟹ leaf_nodes_assn k (xs @ ys) r z (ysa @ ysi) = leaf_nodes_assn k xs r (Some yi) ysa * leaf_nodes_assn k ys (Some yi) z ysi; ysi = yi # ysr⟧ ⟹ leaf_nodes_assn k ((x # xs) @ ys) r z ((y # ysa) @ ysi) = leaf_nodes_assn k (x # xs) r (Some yi) (y # ysa) * leaf_nodes_assn k ys (Some yi) z ysi›*) case (Cons x xs xi xsi r) (*‹length xs = length xsi› ‹ysi = yi # ysr ⟹ leaf_nodes_assn k (xs @ ys) ?r z (xsi @ ysi) = leaf_nodes_assn k xs ?r (Some yi) xsi * leaf_nodes_assn k ys (Some yi) z ysi› ‹ysi = yi # ysr›*) show "?case" (*goal: ‹leaf_nodes_assn k ((x # xs) @ ys) r z ((xi # xsi) @ ysi) = leaf_nodes_assn k (x # xs) r (Some yi) (xi # xsi) * leaf_nodes_assn k ys (Some yi) z ysi›*) apply (cases r; cases x) (*goal: ‹leaf_nodes_assn (k::nat) (((x::'a::heap bplustree) # (xs::'a::heap bplustree list)) @ (ys::'a::heap bplustree list)) (r::'a::heap btnode ref option) (z::'a::heap btnode ref option) (((xi::'a::heap btnode ref) # (xsi::'a::heap btnode ref list)) @ (ysi::'a::heap btnode ref list)) = leaf_nodes_assn k (x # xs) r (Some (yi::'a::heap btnode ref)) (xi # xsi) * leaf_nodes_assn k ys (Some yi) z ysi›*) apply clarsimp_all (*top goal: ‹⋀x1. ⟦r = None; x = Leaf x1⟧ ⟹ leaf_nodes_assn k ((x # xs) @ ys) r z ((xi # xsi) @ ysi) = leaf_nodes_assn k (x # xs) r (Some yi) (xi # xsi) * leaf_nodes_assn k ys (Some yi) z ysi› and 3 goals remain*) apply (intro inst_same (*‹(⋀x. ?P x = ?Q x) ⟹ (∃⇩Ax. ?P x) = (∃⇩Ax. ?Q x)›*)) (*goal: ‹⋀a x1. ⟦r = Some a; x = Leaf x1⟧ ⟹ (∃⇩Axsi fwd. a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k (xs @ ys) fwd z (xsi @ ysi) * ↑ (a = xi)) = (∃⇩Axsi fwd. a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k xs fwd (Some yi) xsi * leaf_nodes_assn k ys (Some yi) z ysi * ↑ (a = xi))›*) apply (rule pure_eq_pre (*‹(?P ⟹ ?Q = ?R) ⟹ ?Q * ↑ ?P = ?R * ↑ ?P›*)) (*goal: ‹⋀a x1 xsi fwd. ⟦r = Some a; x = Leaf x1⟧ ⟹ a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k (xs @ ys) fwd z (xsi @ ysi) * ↑ (a = xi) = a ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k xs fwd (Some yi) xsi * leaf_nodes_assn k ys (Some yi) z ysi * ↑ (a = xi)›*) subgoal for a and x1 and xsi' and fwd using Cons.IH[of fwd, OF Cons.prems] (*‹leaf_nodes_assn k (xs @ ys) fwd z (xsi @ ysi) = leaf_nodes_assn k xs fwd (Some yi) xsi * leaf_nodes_assn k ys (Some yi) z ysi›*) by (clarsimp simp add: mult.assoc (*‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)›*)) . qed lemma "length xs ≠ length xsi ⟹ leaf_nodes_assn k xs r z xsi = false" apply (induction rule: leaf_nodes_assn.induct (*‹⟦⋀k xs lns r z r' lptrs. (⋀x xa. ?P k lns xa z lptrs) ⟹ ?P k (Leaf xs # lns) (Some r) z (r' # lptrs); ⋀k r z. ?P k [] r z []; ⋀uu_ uw_ ux_ v va. ?P uu_ [] uw_ ux_ (v # va); ⋀uu_ vb vc va uw_ ux_ uy_. ?P uu_ (Node vb vc # va) uw_ ux_ uy_; ⋀uu_ v va ux_ uy_. ?P uu_ (v # va) None ux_ uy_; ⋀uu_ uv_ ux_ v va. ?P uu_ uv_ None ux_ (v # va); ⋀uu_ v va uw_ ux_. ?P uu_ (v # va) uw_ ux_ []⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0 ?a3.0 ?a4.0›*)) (*goals: 1. ‹⋀k xs lns r z r' lptrs. ⟦⋀x xa. length lns ≠ length lptrs ⟹ leaf_nodes_assn k lns xa z lptrs = false; length (Leaf xs # lns) ≠ length (r' # lptrs)⟧ ⟹ leaf_nodes_assn k (Leaf xs # lns) (Some r) z (r' # lptrs) = false› 2. ‹⋀k r z. length [] ≠ length [] ⟹ leaf_nodes_assn k [] r z [] = false› 3. ‹⋀uu_ uw_ ux_ v va. length [] ≠ length (v # va) ⟹ leaf_nodes_assn uu_ [] uw_ ux_ (v # va) = false› 4. ‹⋀uu_ vb vc va uw_ ux_ uy_. length (Node vb vc # va) ≠ length uy_ ⟹ leaf_nodes_assn uu_ (Node vb vc # va) uw_ ux_ uy_ = false› 5. ‹⋀uu_ v va ux_ uy_. length (v # va) ≠ length uy_ ⟹ leaf_nodes_assn uu_ (v # va) None ux_ uy_ = false› 6. ‹⋀uu_ uv_ ux_ v va. length uv_ ≠ length (v # va) ⟹ leaf_nodes_assn uu_ uv_ None ux_ (v # va) = false› 7. ‹⋀uu_ v va uw_ ux_. length (v # va) ≠ length [] ⟹ leaf_nodes_assn uu_ (v # va) uw_ ux_ [] = false› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . lemma imp_eq_pure: "(∀h. h ⊨ P ⟶ Q) = (P = P * ↑(Q))" apply (intro iffI (*‹⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q›*)) (*goal: ‹(∀h. h ⊨ P ⟶ Q) = (P = P * ↑ Q)›*) subgoal for using ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*) by force subgoal for by (metis mod_pure_star_dist (*‹((?h::heap × nat set) ⊨ (?P::assn) * ↑ (?b::bool)) = (?h ⊨ ?P ∧ ?b)›*)) . lemma imp_imp_pure: "(⋀h. h ⊨ P ⟹ Q) ⟹ (P = P * ↑(Q))" using imp_eq_pure (*‹(∀h. h ⊨ ?P ⟶ ?Q) = (?P = ?P * ↑ ?Q)›*) by blast thm concat_append lemma concat_append_butlast: "xs ≠ [] ⟹ concat (butlast xs) @ last xs = concat xs" apply (induction xs) (*goals: 1. ‹[] ≠ [] ⟹ concat (butlast []) @ last [] = concat []› 2. ‹⋀a xs. ⟦xs ≠ [] ⟹ concat (butlast xs) @ last xs = concat xs; a # xs ≠ []⟧ ⟹ concat (butlast (a # xs)) @ last (a # xs) = concat (a # xs)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . declare last.simps[simp del] butlast.simps[simp del] lemma bplustree_assn_leafs_len_imp: "h ⊨ bplustree_assn_leafs k t a r z leafptrs ⟹ length leafptrs = length (leaf_nodes t)" proof (induction k t a r z leafptrs arbitrary: h rule: bplustree_assn_leafs.induct) (*goals: 1. ‹⋀k xs a r z leafptrs h. h ⊨ bplustree_assn_leafs k (Leaf xs) a r z leafptrs ⟹ length leafptrs = length (leaf_nodes (Leaf xs))› 2. ‹⋀k ts t a r z leafptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ bplustree_assn_leafs k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ length (last xe) = length (leaf_nodes t); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ bplustree_assn_leafs k (fst xf) (the xg) xh xi yc⟧ ⟹ length yc = length (leaf_nodes (fst xf)); h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs⟧ ⟹ length leafptrs = length (leaf_nodes (Node ts t))›*) case (1 k xs a r z leafptrs) (*‹h ⊨ bplustree_assn_leafs k (Leaf xs) a r z leafptrs›*) then show "?case" (*goal: ‹length (leafptrs::'a btnode ref list) = length (leaf_nodes (Leaf (xs::'a list)))›*) by clarsimp next (*goal: ‹⋀k ts t a r z leafptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ bplustree_assn_leafs k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ length (last xe) = length (leaf_nodes t); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ bplustree_assn_leafs k (fst xf) (the xg) xh xi yc⟧ ⟹ length yc = length (leaf_nodes (fst xf)); h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs⟧ ⟹ length leafptrs = length (leaf_nodes (Node ts t))›*) case (2 k ts t a r z leafptrs h) (*‹?h ⊨ bplustree_assn_leafs k t ?xa (last (r # ?xd)) (last (?xd @ [z])) (last ?xe) ⟹ length (last ?xe) = length (leaf_nodes t)› ‹⟦(?xf::'a bplustree × 'a) ∈ set (ts::('a bplustree × 'a) list); (?y::('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) ∈ set (?xc::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list); (?xg::'a btnode ref option, ?ya::'a btnode ref option × 'a btnode ref option × 'a btnode ref list) = fst ?y; (?xh::'a btnode ref option, ?yb::'a btnode ref option × 'a btnode ref list) = ?ya; (?xi::'a btnode ref option, ?yc::'a btnode ref list) = ?yb; (?h::heap × nat set) ⊨ bplustree_assn_leafs (k::nat) (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ length ?yc = length (leaf_nodes (fst ?xf))› ‹h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs›*) from "2.prems" (*‹h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs›*) show "?case" (*goal: ‹length leafptrs = length (leaf_nodes (Node ts t))›*) apply sep_auto (*goal: ‹length leafptrs = length (leaf_nodes (Node ts t))›*) proof (goal_cases) (*goal: ‹⋀a b ti tsi' rs split. ⟦h ⊨ a ↦⇩r Btnode (a, b) ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (a, b) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs)⟧ ⟹ length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) case (1 tsia tsin ti tsi' rs split) (*‹h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹leafptrs = concat split› ‹length tsi' = length rs› ‹length split = Suc (length rs)›*) have "*": " length tss = length splits ⟹ length splits = length tsi's ⟹ length tsi's = length rss ⟹ set tss ⊆ set ts ⟹ set tsi's ⊆ set tsi' ⟹ set rss ⊆ set rs ⟹ h ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss splits))) (separators tsi's)) ⟹ (length (concat splits)) = length (concat (map (leaf_nodes ∘ fst) tss))" for h and tss and tsi's and splits and rss and ra proof (induction arbitrary: ra h rule: list_induct4) (*goals: 1. ‹⋀(ra::'a btnode ref option) h::heap × nat set. ⟦set [] ⊆ set (ts::('a bplustree × 'a) list); set [] ⊆ set (tsi'::('a btnode ref option × 'a) list); set [] ⊆ set (rs::'a btnode ref option list); h ⊨ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) r' x y) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] []))) (separators []))⟧ ⟹ length (concat []) = length (concat (map (leaf_nodes ∘ fst) []))› 2. ‹⋀(x::'a bplustree × 'a) (xs::('a bplustree × 'a) list) (y::'a btnode ref list) (ys::'a btnode ref list list) (z::'a btnode ref option × 'a) (zs::('a btnode ref option × 'a) list) (w::'a btnode ref option) (ws::'a btnode ref option list) (ra::'a btnode ref option) h::heap × nat set. ⟦length xs = length ys; length ys = length zs; length zs = length ws; ⋀(ra::'a btnode ref option) h::heap × nat set. ⟦set xs ⊆ set (ts::('a bplustree × 'a) list); set zs ⊆ set (tsi'::('a btnode ref option × 'a) list); set ws ⊆ set (rs::'a btnode ref option list); h ⊨ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs)); set (x # xs) ⊆ set ts; set (z # zs) ⊆ set tsi'; set (w # ws) ⊆ set rs; h ⊨ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))⟧ ⟹ length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) case Nil (*‹set [] ⊆ set ts› ‹set [] ⊆ set tsi'› ‹set [] ⊆ set rs› ‹h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] []))) (separators []))›*) then show "?case" (*goal: ‹length (concat []) = length (concat (map (leaf_nodes ∘ fst) []))›*) by sep_auto next (*goal: ‹⋀x xs y ys z zs w ws ra h. ⟦length xs = length ys; length ys = length zs; length zs = length ws; ⋀ra h. ⟦set xs ⊆ set ts; set zs ⊆ set tsi'; set ws ⊆ set rs; h ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs)); set (x # xs) ⊆ set ts; set (z # zs) ⊆ set tsi'; set (w # ws) ⊆ set rs; h ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))⟧ ⟹ length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) case (Cons x xs y ys z zs w ws) (*‹length xs = length ys› ‹length ys = length zs› ‹length zs = length ws› ‹⟦set xs ⊆ set ts; set zs ⊆ set tsi'; set ws ⊆ set rs; ?h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (?ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs))› ‹set (x # xs) ⊆ set ts› ‹set (z # zs) ⊆ set tsi'› ‹set (w # ws) ⊆ set rs› ‹(h::heap × nat set) ⊨ list_assn ((λ(t::'a bplustree) a::'a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list. case a of (ti::'a btnode ref option, r'::'a btnode ref option, a::'a btnode ref option, c::'a btnode ref list) ⇒ bplustree_assn_leafs (k::nat) t (the ti) r' a c) ×⇩a id_assn) ((x::'a bplustree × 'a) # (xs::('a bplustree × 'a) list)) (zip (zip (subtrees ((z::'a btnode ref option × 'a) # (zs::('a btnode ref option × 'a) list))) (zip (butlast ((ra::'a btnode ref option) # (w::'a btnode ref option) # (ws::'a btnode ref option list))) (zip (w # ws) ((y::'a btnode ref list) # (ys::'a btnode ref list list))))) (separators (z # zs)))›*) from Cons.prems (*‹set (x # xs) ⊆ set ts› ‹set (z # zs) ⊆ set tsi'› ‹set (w # ws) ⊆ set rs› ‹h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))›*) show "?case" (*goal: ‹length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) apply (auto simp add: butlast_double_Cons (*‹butlast (?x # ?y # ?xs) = ?x # butlast (?y # ?xs)›*) last_double_Cons (*‹last (?x # ?y # ?xs) = last (?y # ?xs)›*)) (*goal: ‹length (concat ((y::'a btnode ref list) # (ys::'a btnode ref list list))) = length (concat (map (leaf_nodes ∘ fst) ((x::'a bplustree × 'a) # (xs::('a bplustree × 'a) list))))›*) apply (auto simp add: prod_assn_def (*‹(?P1.0 ×⇩a ?P2.0) ?a ?c ≡ case (?a, ?c) of ((a1, a2), c1, c2) ⇒ ?P1.0 a1 c1 * ?P2.0 a2 c2›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹⟦(h::heap × nat set) ⊨ ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) r' x y) ×⇩a id_assn) (x::'a bplustree × 'a) ((fst (z::'a btnode ref option × 'a), ra::'a btnode ref option, w::'a btnode ref option, y::'a btnode ref list), snd z) * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) (xs::('a bplustree × 'a) list) (zip (zip (subtrees (zs::('a btnode ref option × 'a) list)) (zip (butlast (w # (ws::'a btnode ref option list))) (zip ws (ys::'a btnode ref list list)))) (separators zs)); x ∈ set (ts::('a bplustree × 'a) list); set xs ⊆ set ts; z ∈ set (tsi'::('a btnode ref option × 'a) list); set zs ⊆ set tsi'; w ∈ set (rs::'a btnode ref option list); set ws ⊆ set rs⟧ ⟹ length y + length (concat ys) = length (leaf_nodes (fst x)) + length (concat (map (λa::'a bplustree × 'a. leaf_nodes (fst a)) xs))›*) apply (auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*)) (*goal: ‹⋀x1 x2. ⟦(x1, x2) ∈ set ts; set xs ⊆ set ts; z ∈ set tsi'; set zs ⊆ set tsi'; w ∈ set rs; set ws ⊆ set rs; x = (x1, x2); h ⊨ bplustree_assn_leafs k x1 (the (fst z)) ra w y * id_assn x2 (snd z) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length y + length (concat ys) = length (leaf_nodes x1) + length (concat (map (λa. leaf_nodes (fst a)) xs))›*) using Cons.IH (*‹⟦set xs ⊆ set ts; set zs ⊆ set tsi'; set ws ⊆ set rs; ?h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ bplustree_assn_leafs k t (the ti) r' a c) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (?ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs))›*) apply auto (*goal: ‹⋀(x1::'a bplustree) (aa::heap) (ba::nat set) (ab::heap) bb::nat set. ⟦(x1, snd (z::'a btnode ref option × 'a)) ∈ set (ts::('a bplustree × 'a) list); set (xs::('a bplustree × 'a) list) ⊆ set ts; z ∈ set (tsi'::('a btnode ref option × 'a) list); set (zs::('a btnode ref option × 'a) list) ⊆ set tsi'; (w::'a btnode ref option) ∈ set (rs::'a btnode ref option list); set (ws::'a btnode ref option list) ⊆ set rs; (x::'a bplustree × 'a) = (x1, snd z); (aa, ba) ⊨ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws (ys::'a btnode ref list list)))) (separators zs)); (ab, bb) ⊨ bplustree_assn_leafs k x1 (the (fst z)) (ra::'a btnode ref option) w (y::'a btnode ref list)⟧ ⟹ length y + length (concat ys) = length (leaf_nodes x1) + length (concat (map (λa::'a bplustree × 'a. leaf_nodes (fst a)) xs))›*) using "2.IH"(2) (*‹⟦(?xf::'a::heap bplustree × 'a::heap) ∈ set (ts::('a::heap bplustree × 'a::heap) list); (?y::('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) ∈ set (?xc::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list); (?xg::'a::heap btnode ref option, ?ya::'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) = fst ?y; (?xh::'a::heap btnode ref option, ?yb::'a::heap btnode ref option × 'a::heap btnode ref list) = ?ya; (?xi::'a::heap btnode ref option, ?yc::'a::heap btnode ref list) = ?yb; (?h::heap × nat set) ⊨ bplustree_assn_leafs (k::nat) (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ length ?yc = length (leaf_nodes (fst ?xf))›*) apply sep_auto (*goal: ‹⋀x1 aa ba ab bb. ⟦(x1, snd z) ∈ set ts; set xs ⊆ set ts; z ∈ set tsi'; set zs ⊆ set tsi'; w ∈ set rs; set ws ⊆ set rs; x = (x1, snd z); (aa, ba) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws ys))) (separators zs)); (ab, bb) ⊨ bplustree_assn_leafs k x1 (the (fst z)) ra w y; ⋀ra a b. (a, b) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (ra # ws)) (zip ws ys))) (separators zs)) ⟹ length (concat ys) = length (concat (map (λa. leaf_nodes (fst a)) xs))⟧ ⟹ length y = length (leaf_nodes x1)›*) by (meson list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1)) qed have "**": "length ts = length rs" "split ≠ []" using "1" (*‹h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹leafptrs = concat split› ‹length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list)› ‹length split = Suc (length rs)›*) apply - (*goals: 1. ‹⟦h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs)⟧ ⟹ length ts = length rs› 2. ‹⟦h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs)⟧ ⟹ split ≠ []› discuss goal 1*) apply ((auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹?h ⊨ list_assn ?A ?xs ?ys ⟹ length ?xs = length ?ys›*))[1]) (*discuss goal 2*) apply ((auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹?h ⊨ list_assn ?A ?xs ?ys ⟹ length ?xs = length ?ys›*))[1]) (*proven 2 subgoals*) . from "1" (*‹h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * bplustree_assn_leafs k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹leafptrs = concat split› ‹length tsi' = length rs› ‹length split = Suc (length rs)›*) show "?case" (*goal: ‹length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) apply (auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*)) (*goal: ‹length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) apply (subst concat_append_butlast[symmetric] (*‹?xs ≠ [] ⟹ concat ?xs = concat (butlast ?xs) @ last ?xs›*)) (*goal: ‹⋀aaa ba ac bc ad bd ae be. ⟦leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs); (aaa, ba) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); (ac, bc) ⊨ is_pfa (2 * k) tsi' (tsia, tsin); (ad, bd) ⊨ a ↦⇩r Btnode (tsia, tsin) ti; (ae, be) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last split)⟧ ⟹ length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) subgoal for using "**" (*‹length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list)› ‹split ≠ []›*) by sep_auto subgoal for h1 and h2 and h3 and h4 and h5 and h6 and h7 and h8 using "*"[of ts "butlast split" tsi' rs r "(h1,h2)"] (*‹⟦length ts = length (butlast split); length (butlast split) = length tsi'; length tsi' = length rs; set ts ⊆ set ts; set tsi' ⊆ set tsi'; set rs ⊆ set rs; (h1, h2) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))⟧ ⟹ length (concat (butlast split)) = length (concat (map (leaf_nodes ∘ fst) ts))›*) "2.IH"(1)[of ti rs split "(h7,h8)"] (*‹(h7::heap, h8::nat set) ⊨ bplustree_assn_leafs (k::nat) (t::'a bplustree) (ti::'a btnode ref) (last ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (last (rs @ [z::'a btnode ref option])) (last (split::'a btnode ref list list)) ⟹ length (last split) = length (leaf_nodes t)›*) using "**" (*‹length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list)› ‹split ≠ []›*) by sep_auto . qed qed declare last.simps[simp add] butlast.simps[simp add] lemma bplustree_assn_leafs_len_aux: "bplustree_assn_leafs k t a r z leafptrs = bplustree_assn_leafs k t a r z leafptrs * ↑(length leafptrs = length (leaf_nodes t))" by (meson bplustree_assn_leafs_len_imp (*‹(?h::heap × nat set) ⊨ bplustree_assn_leafs (?k::nat) (?t::?'a bplustree) (?a::?'a btnode ref) (?r::?'a btnode ref option) (?z::?'a btnode ref option) (?leafptrs::?'a btnode ref list) ⟹ length ?leafptrs = length (leaf_nodes ?t)›*) imp_imp_pure (*‹(⋀h::heap × nat set. h ⊨ (?P::assn) ⟹ ?Q::bool) ⟹ ?P = ?P * ↑ ?Q›*)) declare last.simps[simp del] butlast.simps[simp del] lemma trunk_assn_leafs_len_imp: "h ⊨ trunk_assn k t a r z leafptrs ⟹ length leafptrs = length (leaf_nodes t)" (* same procedure as for bplustree_nodes_assn_leaf *) proof (induction k t a r z leafptrs arbitrary: h rule: trunk_assn.induct) (*goals: 1. ‹⋀k xs a r z lptrs h. h ⊨ trunk_assn k (Leaf xs) a r z lptrs ⟹ length lptrs = length (leaf_nodes (Leaf xs))› 2. ‹⋀k ts t a r z lptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ trunk_assn k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ length (last xe) = length (leaf_nodes t); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ trunk_assn k (fst xf) (the xg) xh xi yc⟧ ⟹ length yc = length (leaf_nodes (fst xf)); h ⊨ trunk_assn k (Node ts t) a r z lptrs⟧ ⟹ length lptrs = length (leaf_nodes (Node ts t))›*) case (1 k xs a r z leafptrs) (*‹h ⊨ trunk_assn k (Leaf xs) a r z leafptrs›*) then show "?case" (*goal: ‹length leafptrs = length (leaf_nodes (Leaf xs))›*) by clarsimp next (*goal: ‹⋀k ts t a r z lptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ trunk_assn k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ length (last xe) = length (leaf_nodes t); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ trunk_assn k (fst xf) (the xg) xh xi yc⟧ ⟹ length yc = length (leaf_nodes (fst xf)); h ⊨ trunk_assn k (Node ts t) a r z lptrs⟧ ⟹ length lptrs = length (leaf_nodes (Node ts t))›*) case (2 k ts t a r z leafptrs h) (*‹?h ⊨ trunk_assn k t ?xa (last (r # ?xd)) (last (?xd @ [z])) (last ?xe) ⟹ length (last ?xe) = length (leaf_nodes t)› ‹⟦(?xf::'a bplustree × 'a) ∈ set (ts::('a bplustree × 'a) list); (?y::('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) ∈ set (?xc::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list); (?xg::'a btnode ref option, ?ya::'a btnode ref option × 'a btnode ref option × 'a btnode ref list) = fst ?y; (?xh::'a btnode ref option, ?yb::'a btnode ref option × 'a btnode ref list) = ?ya; (?xi::'a btnode ref option, ?yc::'a btnode ref list) = ?yb; (?h::heap × nat set) ⊨ trunk_assn (k::nat) (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ length ?yc = length (leaf_nodes (fst ?xf))› ‹h ⊨ trunk_assn k (Node ts t) a r z leafptrs›*) from "2.prems" (*‹h ⊨ trunk_assn k (Node ts t) a r z leafptrs›*) show "?case" (*goal: ‹length leafptrs = length (leaf_nodes (Node ts t))›*) apply sep_auto (*goal: ‹length (leafptrs::'a::heap btnode ref list) = length (leaf_nodes (Node (ts::('a::heap bplustree × 'a::heap) list) (t::'a::heap bplustree)))›*) proof (goal_cases) (*goal: ‹⋀a b ti tsi' rs split. ⟦h ⊨ a ↦⇩r Btnode (a, b) ti * trunk_assn k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (a, b) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs)⟧ ⟹ length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) case (1 tsia tsin ti tsi' rs split) (*‹h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * trunk_assn k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹leafptrs = concat split› ‹length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list)› ‹length (split::'a::heap btnode ref list list) = Suc (length (rs::'a::heap btnode ref option list))›*) have "*": " length tss = length splits ⟹ length splits = length tsi's ⟹ length tsi's = length rss ⟹ set tss ⊆ set ts ⟹ set tsi's ⊆ set tsi' ⟹ set rss ⊆ set rs ⟹ h ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss splits))) (separators tsi's)) ⟹ (length (concat splits)) = length (concat (map (leaf_nodes ∘ fst) tss))" for h and tss and tsi's and splits and rss and ra proof (induction arbitrary: ra h rule: list_induct4) (*goals: 1. ‹⋀ra h. ⟦set [] ⊆ set ts; set [] ⊆ set tsi'; set [] ⊆ set rs; h ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] []))) (separators []))⟧ ⟹ length (concat []) = length (concat (map (leaf_nodes ∘ fst) []))› 2. ‹⋀x xs y ys z zs w ws ra h. ⟦length xs = length ys; length ys = length zs; length zs = length ws; ⋀ra h. ⟦set xs ⊆ set ts; set zs ⊆ set tsi'; set ws ⊆ set rs; h ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs)); set (x # xs) ⊆ set ts; set (z # zs) ⊆ set tsi'; set (w # ws) ⊆ set rs; h ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))⟧ ⟹ length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) case Nil (*‹set [] ⊆ set ts› ‹set [] ⊆ set tsi'› ‹set [] ⊆ set rs› ‹h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ trunk_assn k t (the ti) r' a c) ×⇩a id_assn) [] (zip (zip (subtrees []) (zip (butlast [ra]) (zip [] []))) (separators []))›*) then show "?case" (*goal: ‹length (concat []) = length (concat (map (leaf_nodes ∘ fst) []))›*) by sep_auto next (*goal: ‹⋀(x::'a::heap bplustree × 'a::heap) (xs::('a::heap bplustree × 'a::heap) list) (y::'a::heap btnode ref list) (ys::'a::heap btnode ref list list) (z::'a::heap btnode ref option × 'a::heap) (zs::('a::heap btnode ref option × 'a::heap) list) (w::'a::heap btnode ref option) (ws::'a::heap btnode ref option list) (ra::'a::heap btnode ref option) h::heap × nat set. ⟦length xs = length ys; length ys = length zs; length zs = length ws; ⋀(ra::'a::heap btnode ref option) h::heap × nat set. ⟦set xs ⊆ set (ts::('a::heap bplustree × 'a::heap) list); set zs ⊆ set (tsi'::('a::heap btnode ref option × 'a::heap) list); set ws ⊆ set (rs::'a::heap btnode ref option list); h ⊨ list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). trunk_assn (k::nat) t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs)); set (x # xs) ⊆ set ts; set (z # zs) ⊆ set tsi'; set (w # ws) ⊆ set rs; h ⊨ list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, r'::'a::heap btnode ref option, x::'a::heap btnode ref option, y::'a::heap btnode ref list). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))⟧ ⟹ length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) case (Cons x xs y ys z zs w ws) (*‹length xs = length ys› ‹length ys = length zs› ‹length (zs::('a btnode ref option × 'a) list) = length (ws::'a btnode ref option list)› ‹⟦set xs ⊆ set ts; set zs ⊆ set tsi'; set ws ⊆ set rs; ?h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ trunk_assn k t (the ti) r' a c) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (?ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs))› ‹set ((x::'a::heap bplustree × 'a::heap) # (xs::('a::heap bplustree × 'a::heap) list)) ⊆ set (ts::('a::heap bplustree × 'a::heap) list)› ‹set (z # zs) ⊆ set tsi'› ‹set ((w::'a btnode ref option) # (ws::'a btnode ref option list)) ⊆ set (rs::'a btnode ref option list)› ‹h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ trunk_assn k t (the ti) r' a c) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))›*) from Cons.prems (*‹set (x # xs) ⊆ set ts› ‹set (z # zs) ⊆ set tsi'› ‹set (w # ws) ⊆ set rs› ‹h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ trunk_assn k t (the ti) r' a c) ×⇩a id_assn) (x # xs) (zip (zip (subtrees (z # zs)) (zip (butlast (ra # w # ws)) (zip (w # ws) (y # ys)))) (separators (z # zs)))›*) show "?case" (*goal: ‹length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) apply (auto simp add: butlast_double_Cons (*‹butlast (?x # ?y # ?xs) = ?x # butlast (?y # ?xs)›*) last_double_Cons (*‹last (?x # ?y # ?xs) = last (?y # ?xs)›*)) (*goal: ‹length (concat (y # ys)) = length (concat (map (leaf_nodes ∘ fst) (x # xs)))›*) apply (auto simp add: prod_assn_def (*‹(?P1.0 ×⇩a ?P2.0) ?a ?c ≡ case (?a, ?c) of ((a1, a2), c1, c2) ⇒ ?P1.0 a1 c1 * ?P2.0 a2 c2›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹⟦h ⊨ ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) x ((fst z, ra, w, y), snd z) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws ys))) (separators zs)); x ∈ set ts; set xs ⊆ set ts; z ∈ set tsi'; set zs ⊆ set tsi'; w ∈ set rs; set ws ⊆ set rs⟧ ⟹ length y + length (concat ys) = length (leaf_nodes (fst x)) + length (concat (map (λa. leaf_nodes (fst a)) xs))›*) apply (auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*)) (*goal: ‹⋀(x1::'a bplustree) x2::'a. ⟦(x1, x2) ∈ set (ts::('a bplustree × 'a) list); set (xs::('a bplustree × 'a) list) ⊆ set ts; (z::'a btnode ref option × 'a) ∈ set (tsi'::('a btnode ref option × 'a) list); set (zs::('a btnode ref option × 'a) list) ⊆ set tsi'; (w::'a btnode ref option) ∈ set (rs::'a btnode ref option list); set (ws::'a btnode ref option list) ⊆ set rs; (x::'a bplustree × 'a) = (x1, x2); (h::heap × nat set) ⊨ trunk_assn (k::nat) x1 (the (fst z)) (ra::'a btnode ref option) w (y::'a btnode ref list) * id_assn x2 (snd z) * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws (ys::'a btnode ref list list)))) (separators zs))⟧ ⟹ length y + length (concat ys) = length (leaf_nodes x1) + length (concat (map (λa::'a bplustree × 'a. leaf_nodes (fst a)) xs))›*) using Cons.IH (*‹⟦set xs ⊆ set ts; set zs ⊆ set tsi'; set ws ⊆ set rs; ?h ⊨ list_assn ((λt a. case a of (ti, r', a, c) ⇒ trunk_assn k t (the ti) r' a c) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (?ra # ws)) (zip ws ys))) (separators zs))⟧ ⟹ length (concat ys) = length (concat (map (leaf_nodes ∘ fst) xs))›*) apply auto (*goal: ‹⋀x1 aa ba ab bb. ⟦(x1, snd z) ∈ set ts; set xs ⊆ set ts; z ∈ set tsi'; set zs ⊆ set tsi'; w ∈ set rs; set ws ⊆ set rs; x = (x1, snd z); (aa, ba) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws ys))) (separators zs)); (ab, bb) ⊨ trunk_assn k x1 (the (fst z)) ra w y⟧ ⟹ length y + length (concat ys) = length (leaf_nodes x1) + length (concat (map (λa. leaf_nodes (fst a)) xs))›*) using "2.IH"(2) (*‹⟦(?xf::'a::heap bplustree × 'a::heap) ∈ set (ts::('a::heap bplustree × 'a::heap) list); (?y::('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) ∈ set (?xc::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list); (?xg::'a::heap btnode ref option, ?ya::'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) = fst ?y; (?xh::'a::heap btnode ref option, ?yb::'a::heap btnode ref option × 'a::heap btnode ref list) = ?ya; (?xi::'a::heap btnode ref option, ?yc::'a::heap btnode ref list) = ?yb; (?h::heap × nat set) ⊨ trunk_assn (k::nat) (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ length ?yc = length (leaf_nodes (fst ?xf))›*) apply sep_auto (*goal: ‹⋀x1 aa ba ab bb. ⟦(x1, snd z) ∈ set ts; set xs ⊆ set ts; z ∈ set tsi'; set zs ⊆ set tsi'; w ∈ set rs; set ws ⊆ set rs; x = (x1, snd z); (aa, ba) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (w # ws)) (zip ws ys))) (separators zs)); (ab, bb) ⊨ trunk_assn k x1 (the (fst z)) ra w y; ⋀ra a b. (a, b) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) xs (zip (zip (subtrees zs) (zip (butlast (ra # ws)) (zip ws ys))) (separators zs)) ⟹ length (concat ys) = length (concat (map (λa. leaf_nodes (fst a)) xs))⟧ ⟹ length y = length (leaf_nodes x1)›*) by (meson list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1)) qed have "**": "length ts = length rs" "split ≠ []" using "1" (*‹h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * trunk_assn k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹leafptrs = concat split› ‹length tsi' = length rs› ‹length split = Suc (length rs)›*) apply - (*goals: 1. ‹⟦h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * trunk_assn k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs)⟧ ⟹ length ts = length rs› 2. ‹⟦h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * trunk_assn k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs)⟧ ⟹ split ≠ []› discuss goal 1*) apply ((auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹?h ⊨ list_assn ?A ?xs ?ys ⟹ length ?xs = length ?ys›*))[1]) (*discuss goal 2*) apply ((auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) list_assn_len (*‹?h ⊨ list_assn ?A ?xs ?ys ⟹ length ?xs = length ?ys›*))[1]) (*proven 2 subgoals*) . from "1" (*‹h ⊨ a ↦⇩r Btnode (tsia, tsin) ti * trunk_assn k t ti (last (r # rs)) z (last split) * is_pfa (2 * k) tsi' (tsia, tsin) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹leafptrs = concat split› ‹length tsi' = length rs› ‹length split = Suc (length rs)›*) show "?case" (*goal: ‹length (concat (split::'a btnode ref list list)) = length (concat (map (leaf_nodes ∘ fst) (ts::('a bplustree × 'a) list))) + length (leaf_nodes (t::'a bplustree))›*) apply (auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*)) (*goal: ‹length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) apply (subst concat_append_butlast[symmetric] (*‹?xs ≠ [] ⟹ concat ?xs = concat (butlast ?xs) @ last ?xs›*)) (*goal: ‹⋀aaa ba ac bc ad bd ae be. ⟦leafptrs = concat split; length tsi' = length rs; length split = Suc (length rs); (aaa, ba) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); (ac, bc) ⊨ is_pfa (2 * k) tsi' (tsia, tsin); (ad, bd) ⊨ a ↦⇩r Btnode (tsia, tsin) ti; (ae, be) ⊨ trunk_assn k t ti (last (r # rs)) z (last split)⟧ ⟹ length (concat split) = length (concat (map (leaf_nodes ∘ fst) ts)) + length (leaf_nodes t)›*) subgoal for using "**" (*‹length ts = length rs› ‹split ≠ []›*) by sep_auto subgoal for h1 and h2 and h3 and h4 and h5 and h6 and h7 and h8 using "*"[of ts "butlast split" tsi' rs r "(h1,h2)"] (*‹⟦length (ts::('a bplustree × 'a) list) = length (butlast (split::'a btnode ref list list)); length (butlast split) = length (tsi'::('a btnode ref option × 'a) list); length tsi' = length (rs::'a btnode ref option list); set ts ⊆ set ts; set tsi' ⊆ set tsi'; set rs ⊆ set rs; (h1::heap, h2::nat set) ⊨ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). trunk_assn (k::nat) t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast ((r::'a btnode ref option) # rs)) (zip rs (butlast split)))) (separators tsi'))⟧ ⟹ length (concat (butlast split)) = length (concat (map (leaf_nodes ∘ fst) ts))›*) "2.IH"(1)[of ti rs split "(h7,h8)"] (*‹(h7::heap, h8::nat set) ⊨ trunk_assn (k::nat) (t::'a::heap bplustree) (ti::'a::heap btnode ref) (last ((r::'a::heap btnode ref option) # (rs::'a::heap btnode ref option list))) (last (rs @ [z::'a::heap btnode ref option])) (last (split::'a::heap btnode ref list list)) ⟹ length (last split) = length (leaf_nodes t)›*) using "**" (*‹length ts = length rs› ‹(split::'a btnode ref list list) ≠ []›*) by sep_auto . qed qed declare last.simps[simp add] butlast.simps[simp add] lemma trunk_assn_leafs_len_aux: "trunk_assn k t a r z leafptrs = trunk_assn k t a r z leafptrs * ↑(length leafptrs = length (leaf_nodes t))" by (meson trunk_assn_leafs_len_imp (*‹?h ⊨ trunk_assn ?k ?t ?a ?r ?z ?leafptrs ⟹ length ?leafptrs = length (leaf_nodes ?t)›*) imp_imp_pure (*‹(⋀h. h ⊨ ?P ⟹ ?Q) ⟹ ?P = ?P * ↑ ?Q›*)) declare last.simps[simp del] butlast.simps[simp del] lemma bplustree_assn_leafs_not_empty_aux: "bplustree_assn_leafs k t a r z leafptrs = bplustree_assn_leafs k t a r z leafptrs * ↑(leafptrs ≠ [])" apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹bplustree_assn_leafs (k::nat) (t::'a bplustree) (a::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option) (leafptrs::'a btnode ref list) = bplustree_assn_leafs k t a r z leafptrs * ↑ (leafptrs ≠ [])›*) subgoal for apply (subst bplustree_assn_leafs_len_aux (*‹bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs = bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs * ↑ (length ?leafptrs = length (leaf_nodes ?t))›*)) (*goal: ‹bplustree_assn_leafs (k::nat) (t::'a bplustree) (a::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option) (leafptrs::'a btnode ref list) ⟹⇩A bplustree_assn_leafs k t a r z leafptrs * ↑ (leafptrs ≠ [])›*) using leaf_nodes_not_empty (*‹leaf_nodes ?t ≠ []›*) by sep_auto subgoal for by sep_auto . lemma trunk_assn_not_empty_aux: "trunk_assn k t a r z leafptrs = trunk_assn k t a r z leafptrs * ↑(leafptrs ≠ [])" apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹trunk_assn k t a r z leafptrs = trunk_assn k t a r z leafptrs * ↑ (leafptrs ≠ [])›*) subgoal for apply (subst trunk_assn_leafs_len_aux (*‹trunk_assn (?k::nat) (?t::?'a bplustree) (?a::?'a btnode ref) (?r::?'a btnode ref option) (?z::?'a btnode ref option) (?leafptrs::?'a btnode ref list) = trunk_assn ?k ?t ?a ?r ?z ?leafptrs * ↑ (length ?leafptrs = length (leaf_nodes ?t))›*)) (*goal: ‹trunk_assn (k::nat) (t::'a bplustree) (a::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option) (leafptrs::'a btnode ref list) ⟹⇩A trunk_assn k t a r z leafptrs * ↑ (leafptrs ≠ [])›*) using leaf_nodes_not_empty (*‹leaf_nodes ?t ≠ []›*) by sep_auto subgoal for by sep_auto . declare last.simps[simp add] butlast.simps[simp add] declare last.simps[simp del] butlast.simps[simp del] lemma bplustree_assn_leafs_hd: "h ⊨ bplustree_assn_leafs k t a r z leafptrs ⟹ r = Some (hd leafptrs)" proof (induction k t a r z leafptrs arbitrary: h rule: bplustree_assn_leafs.induct) (*goals: 1. ‹⋀k xs a r z leafptrs h. h ⊨ bplustree_assn_leafs k (Leaf xs) a r z leafptrs ⟹ r = Some (hd leafptrs)› 2. ‹⋀k ts t a r z leafptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ bplustree_assn_leafs k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ last (r # xd) = Some (hd (last xe)); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ bplustree_assn_leafs k (fst xf) (the xg) xh xi yc⟧ ⟹ xh = Some (hd yc); h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs⟧ ⟹ r = Some (hd leafptrs)›*) case (1 k xs a r z leafptrs) (*‹(h::heap × nat set) ⊨ bplustree_assn_leafs (k::nat) (Leaf (xs::'a list)) (a::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option) (leafptrs::'a btnode ref list)›*) then show "?case" (*goal: ‹r = Some (hd leafptrs)›*) by clarsimp next (*goal: ‹⋀k ts t a r z leafptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ bplustree_assn_leafs k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ last (r # xd) = Some (hd (last xe)); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ bplustree_assn_leafs k (fst xf) (the xg) xh xi yc⟧ ⟹ xh = Some (hd yc); h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs⟧ ⟹ r = Some (hd leafptrs)›*) case (2 k ts t a r z leafptrs h) (*‹?h ⊨ bplustree_assn_leafs k t ?xa (last (r # ?xd)) (last (?xd @ [z])) (last ?xe) ⟹ last (r # ?xd) = Some (hd (last ?xe))› ‹⟦?xf ∈ set ts; ?y ∈ set ?xc; (?xg, ?ya) = fst ?y; (?xh, ?yb) = ?ya; (?xi, ?yc) = ?yb; ?h ⊨ bplustree_assn_leafs k (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ ?xh = Some (hd ?yc)› ‹(h::heap × nat set) ⊨ bplustree_assn_leafs (k::nat) (Node (ts::('a bplustree × 'a) list) (t::'a bplustree)) (a::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option) (leafptrs::'a btnode ref list)›*) from "2.prems" (*‹h ⊨ bplustree_assn_leafs k (Node ts t) a r z leafptrs›*) show "?case" (*goal: ‹r = Some (hd leafptrs)›*) apply (sep_auto dest!: mod_starD) (*goal: ‹r = Some (hd leafptrs)›*) proof (goal_cases) (*goal: ‹⋀a b ti tsi' rs split ab bb ad bd ae be af bf. ⟦leafptrs = concat split; (ab, bb) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); length tsi' = length rs; length split = Suc (length rs); (ad, bd) ⊨ is_pfa (2 * k) tsi' (a, b); (ae, be) ⊨ a ↦⇩r Btnode (a, b) ti; (af, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last split)⟧ ⟹ r = Some (hd (concat split))›*) case (1 a b ti tsi' rs split ab bb ad bd ae be af bf) (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list)› ‹length split = Suc (length rs)› ‹(ad::heap, bd::nat set) ⊨ is_pfa ((2::nat) * (k::nat)) (tsi'::('a btnode ref option × 'a) list) (a::('a btnode ref option × 'a) array, b::nat)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (a, b) ti› ‹(af, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last split)›*) have "length ts = length rs" using "1" (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list)› ‹length split = Suc (length rs)› ‹(ad::heap, bd::nat set) ⊨ is_pfa ((2::nat) * (k::nat)) (tsi'::('a btnode ref option × 'a) list) (a::('a btnode ref option × 'a) array, b::nat)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (a, b) ti› ‹(af, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last split)›*) by (auto dest!: list_assn_len (*‹(?h::heap × nat set) ⊨ list_assn (?A::?'a ⇒ ?'b ⇒ assn) (?xs::?'a list) (?ys::?'b list) ⟹ length ?xs = length ?ys›*)) then show "?case" (*goal: ‹(r::'a btnode ref option) = Some (hd (concat (split::'a btnode ref list list)))›*) proof (cases ts) (*goals: 1. ‹⟦length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list); ts = []⟧ ⟹ (r::'a btnode ref option) = Some (hd (concat (split::'a btnode ref list list)))› 2. ‹⋀(a::'a bplustree × 'a) list::('a bplustree × 'a) list. ⟦length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list); ts = a # list⟧ ⟹ (r::'a btnode ref option) = Some (hd (concat (split::'a btnode ref list list)))›*) case Nil (*‹ts = []›*) then have "length split = 1" "rs = []" using "1"(4) (*‹length split = Suc (length rs)›*) ‹length ts = length rs› (*‹length ts = length rs›*) apply - (*goals: 1. ‹⟦ts = []; length split = Suc (length rs); length ts = length rs⟧ ⟹ length split = 1› 2. ‹⟦ts = []; length split = Suc (length rs); length ts = length rs⟧ ⟹ rs = []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "*": "split = [last split]" by (metis append_butlast_last_id (*‹?xs ≠ [] ⟹ butlast ?xs @ [last ?xs] = ?xs›*) list.distinct( (*‹[] ≠ ?x21.0 # ?x22.0›*) 1) list_decomp_1 (*‹length ?l = 1 ⟹ ∃a. ?l = [a]›*) list_se_match( (*‹?l2.0 ≠ [] ⟹ ([?a] = ?l1.0 @ ?l2.0) = (?l1.0 = [] ∧ ?l2.0 = [?a])›*) 4)) then have "concat split = last split" apply (subst * (*‹split = [last split]›*)) (*goal: ‹concat (split::'a::heap btnode ref list list) = last split›*) unfolding concat.simps (*goal: ‹split = [last split] ⟹ last split @ [] = last split›*) by simp then show "?thesis" (*goal: ‹r = Some (hd (concat split))›*) using "1" (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length tsi' = length rs› ‹length split = Suc (length rs)› ‹(ad, bd) ⊨ is_pfa (2 * k) tsi' (a, b)› ‹(ae::heap, be::nat set) ⊨ (aa__::'a btnode ref) ↦⇩r Btnode (a::('a btnode ref option × 'a) array, b::nat) (ti::'a btnode ref)› ‹(af, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last split)›*) using "2.IH"(1)[of ti rs split "(af,bf)"] (*‹(af, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) (last (rs @ [z])) (last split) ⟹ last (r # rs) = Some (hd (last split))›*) using ‹rs = []› (*‹rs = []›*) by (auto simp add: last.simps (*‹last (?x # ?xs) = (if ?xs = [] then ?x else last ?xs)›*)) next (*goal: ‹⋀a list. ⟦length ts = length rs; ts = a # list⟧ ⟹ r = Some (hd (concat split))›*) case (Cons a list) (*‹ts = a # list›*) then obtain ra and rss and ss1 and ss2 and splits and tss and tsi's where "*": "rs = ra#rss" "split = ss1 # ss2 # splits" "tsi' = tss # tsi's" (*goal: ‹(⋀(ra::'a btnode ref option) (rss::'a btnode ref option list) (ss1::'a btnode ref list) (ss2::'a btnode ref list) (splits::'a btnode ref list list) (tss::'a btnode ref option × 'a) tsi's::('a btnode ref option × 'a) list. ⟦(rs::'a btnode ref option list) = ra # rss; (split::'a btnode ref list list) = ss1 # ss2 # splits; (tsi'::('a btnode ref option × 'a) list) = tss # tsi's⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis (no_types, lifting) "1" (*‹length (tsi'::('a::heap btnode ref option × 'a::heap) list) = length (rs::'a::heap btnode ref option list)›*) (3) "1" (*‹length (split::'a::heap btnode ref list list) = Suc (length (rs::'a::heap btnode ref option list))›*) (4) Suc_length_conv (*‹(Suc (?n::nat) = length (?xs::?'a::type list)) = (∃(y::?'a::type) ys::?'a::type list. ?xs = y # ys ∧ length ys = ?n)›*) ‹length ts = length rs›) obtain h1 and h2 where first_subtree: "(h1, h2) ⊨ bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1" (*goal: ‹(⋀h1 h2. (h1, h2) ⊨ bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1 ⟹ thesis) ⟹ thesis›*) using "1" (*‹leafptrs = concat split› ‹(ab::heap, bb::nat set) ⊨ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, r'::'a btnode ref option, x::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) r' x y) ×⇩a id_assn) (ts::('a bplustree × 'a) list) (zip (zip (subtrees (tsi'::('a btnode ref option × 'a) list)) (zip (butlast ((r::'a btnode ref option) # (rs::'a btnode ref option list))) (zip rs (butlast (split::'a btnode ref list list))))) (separators tsi'))› ‹length (tsi'::('a::heap btnode ref option × 'a::heap) list) = length (rs::'a::heap btnode ref option list)› ‹length split = Suc (length rs)› ‹(ad, bd) ⊨ is_pfa (2 * k) tsi' (ab__, b)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (ab__, b) ti› ‹(af, bf) ⊨ bplustree_assn_leafs k t ti (last (r # rs)) z (last split)›*) apply (auto simp add: butlast_double_Cons (*‹butlast (?x # ?y # ?xs) = ?x # butlast (?y # ?xs)›*) last_double_Cons (*‹last (?x # ?y # ?xs) = last (?y # ?xs)›*) * (*‹rs = ra # rss› ‹split = ss1 # ss2 # splits› ‹tsi' = tss # tsi's›*) Cons (*‹ts = a # list›*)) (*goal: ‹(⋀h1 h2. (h1, h2) ⊨ bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1 ⟹ thesis) ⟹ thesis›*) apply (auto simp add: prod_assn_def (*‹(?P1.0 ×⇩a ?P2.0) ?a ?c ≡ case (?a, ?c) of ((a1, a2), c1, c2) ⇒ ?P1.0 a1 c1 * ?P2.0 a2 c2›*) split: prod.splits (*‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∀x1 x2. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹?P (case ?prod of (x, xa) ⇒ ?f x xa) = (∄x1 x2. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹⟦⋀h1 h2. (h1, h2) ⊨ bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1 ⟹ thesis; leafptrs = ss1 @ ss2 @ concat splits; (ab, bb) ⊨ ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) a ((fst tss, r, ra, ss1), snd tss) * list_assn ((λt (ti, r', x, y). bplustree_assn_leafs k t (the ti) r' x y) ×⇩a id_assn) list (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss (butlast (ss2 # splits))))) (separators tsi's)); length tsi's = length rss; length splits = length rss; (ad, bd) ⊨ is_pfa (2 * k) (tss # tsi's) (ab__, b); (ae, be) ⊨ aa__ ↦⇩r Btnode (ab__, b) ti; (af, bf) ⊨ bplustree_assn_leafs k t ti (last (ra # rss)) z (last (ss2 # splits))⟧ ⟹ thesis›*) by (auto dest!: mod_starD (*‹(?h::heap × nat set) ⊨ (?A::assn) * (?B::assn) ⟹ ∃(h1::heap × nat set) h2::heap × nat set. h1 ⊨ ?A ∧ h2 ⊨ ?B›*)) then have "ss1 ≠ []" using bplustree_assn_leafs_not_empty_aux[of k "(fst a)" "(the (fst tss))" r ra ss1] (*‹bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1 = bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1 * ↑ (ss1 ≠ [])›*) by auto then have "hd (concat split) = hd ss1" by (simp add: "*" (*‹split = ss1 # ss2 # splits›*) (2)) then show "?thesis" (*goal: ‹(r::'a btnode ref option) = Some (hd (concat (split::'a btnode ref list list)))›*) using first_subtree (*‹(h1, h2) ⊨ bplustree_assn_leafs k (fst a) (the (fst tss)) r ra ss1›*) apply auto (*goal: ‹r = Some (hd (concat split))›*) by (metis "2.IH" (*‹⟦(?xf::'a bplustree × 'a) ∈ set (ts::('a bplustree × 'a) list); (?y::('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) ∈ set (?xc::(('a btnode ref option × 'a btnode ref option × 'a btnode ref option × 'a btnode ref list) × 'a) list); (?xg::'a btnode ref option, ?ya::'a btnode ref option × 'a btnode ref option × 'a btnode ref list) = fst ?y; (?xh::'a btnode ref option, ?yb::'a btnode ref option × 'a btnode ref list) = ?ya; (?xi::'a btnode ref option, ?yc::'a btnode ref list) = ?yb; (?h::heap × nat set) ⊨ bplustree_assn_leafs (k::nat) (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ ?xh = Some (hd ?yc)›*) (2) fst_conv (*‹fst (?x1.0::?'a, ?x2.0::?'b) = ?x1.0›*) list.set_intros( (*‹(?x21.0::?'a) ∈ set (?x21.0 # (?x22.0::?'a list))›*) 1) local.Cons (*‹(ts::('a bplustree × 'a) list) = (a::'a bplustree × 'a) # (list::('a bplustree × 'a) list)›*)) qed qed qed declare last.simps[simp add] butlast.simps[simp add] lemma bplustree_assn_leafs_hd_aux: "bplustree_assn_leafs k t a r z leafptrs = bplustree_assn_leafs k t a r z leafptrs * ↑(r = Some (hd leafptrs))" by (meson bplustree_assn_leafs_hd (*‹?h ⊨ bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs ⟹ ?r = Some (hd ?leafptrs)›*) imp_imp_pure (*‹(⋀h. h ⊨ ?P ⟹ ?Q) ⟹ ?P = ?P * ↑ ?Q›*)) declare last.simps[simp del] butlast.simps[simp del] lemma trunk_assn_hd: "h ⊨ trunk_assn k t a r z leafptrs ⟹ r = Some (hd leafptrs)" proof (induction k t a r z leafptrs arbitrary: h rule: trunk_assn.induct) (*goals: 1. ‹⋀(k::nat) (xs::'a::heap list) (a::'a::heap btnode ref) (r::'a::heap btnode ref option) (z::'a::heap btnode ref option) (lptrs::'a::heap btnode ref list) h::heap × nat set. h ⊨ trunk_assn k (Leaf xs) a r z lptrs ⟹ r = Some (hd lptrs)› 2. ‹⋀(k::nat) (ts::('a::heap bplustree × 'a::heap) list) (t::'a::heap bplustree) (a::'a::heap btnode ref) (r::'a::heap btnode ref option) (z::'a::heap btnode ref option) (lptrs::'a::heap btnode ref list) h::heap × nat set. ⟦⋀(x::('a::heap btnode ref option × 'a::heap) array × nat) (xa::'a::heap btnode ref) (xb::('a::heap btnode ref option × 'a::heap) list) (xc::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list) (xd::'a::heap btnode ref option list) (xe::'a::heap btnode ref list list) h::heap × nat set. h ⊨ trunk_assn k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ last (r # xd) = Some (hd (last xe)); ⋀(x::('a::heap btnode ref option × 'a::heap) array × nat) (xa::'a::heap btnode ref) (xb::('a::heap btnode ref option × 'a::heap) list) (xc::(('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) list) (xd::'a::heap btnode ref option list) (xe::'a::heap btnode ref list list) (xf::'a::heap bplustree × 'a::heap) (y::('a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) × 'a::heap) (xg::'a::heap btnode ref option) (ya::'a::heap btnode ref option × 'a::heap btnode ref option × 'a::heap btnode ref list) (xh::'a::heap btnode ref option) (yb::'a::heap btnode ref option × 'a::heap btnode ref list) (xi::'a::heap btnode ref option) (yc::'a::heap btnode ref list) h::heap × nat set. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ trunk_assn k (fst xf) (the xg) xh xi yc⟧ ⟹ xh = Some (hd yc); h ⊨ trunk_assn k (Node ts t) a r z lptrs⟧ ⟹ r = Some (hd lptrs)›*) case (1 k xs a r z leafptrs) (*‹h ⊨ trunk_assn k (Leaf xs) a r z leafptrs›*) then show "?case" (*goal: ‹r = Some (hd leafptrs)›*) by clarsimp next (*goal: ‹⋀k ts t a r z lptrs h. ⟦⋀x xa xb xc xd xe h. h ⊨ trunk_assn k t xa (last (r # xd)) (last (xd @ [z])) (last xe) ⟹ last (r # xd) = Some (hd (last xe)); ⋀x xa xb xc xd xe xf y xg ya xh yb xi yc h. ⟦xf ∈ set ts; y ∈ set xc; (xg, ya) = fst y; (xh, yb) = ya; (xi, yc) = yb; h ⊨ trunk_assn k (fst xf) (the xg) xh xi yc⟧ ⟹ xh = Some (hd yc); h ⊨ trunk_assn k (Node ts t) a r z lptrs⟧ ⟹ r = Some (hd lptrs)›*) case (2 k ts t a r z leafptrs h) (*‹?h ⊨ trunk_assn k t ?xa (last (r # ?xd)) (last (?xd @ [z])) (last ?xe) ⟹ last (r # ?xd) = Some (hd (last ?xe))› ‹⟦?xf ∈ set ts; ?y ∈ set ?xc; (?xg, ?ya) = fst ?y; (?xh, ?yb) = ?ya; (?xi, ?yc) = ?yb; ?h ⊨ trunk_assn k (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ ?xh = Some (hd ?yc)› ‹h ⊨ trunk_assn k (Node ts t) a r z leafptrs›*) from "2.prems" (*‹h ⊨ trunk_assn k (Node ts t) a r z leafptrs›*) show "?case" (*goal: ‹r = Some (hd leafptrs)›*) apply (sep_auto dest!: mod_starD) (*goal: ‹r = Some (hd leafptrs)›*) proof (goal_cases) (*goal: ‹⋀a b ti tsi' rs split ab bb ad bd ae be af bf. ⟦leafptrs = concat split; (ab, bb) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi')); length tsi' = length rs; length split = Suc (length rs); (ad, bd) ⊨ is_pfa (2 * k) tsi' (a, b); (ae, be) ⊨ a ↦⇩r Btnode (a, b) ti; (af, bf) ⊨ trunk_assn k t ti (last (r # rs)) z (last split)⟧ ⟹ r = Some (hd (concat split))›*) case (1 a b ti tsi' rs split ab bb ad bd ae be af bf) (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length tsi' = length rs› ‹length split = Suc (length rs)› ‹(ad, bd) ⊨ is_pfa (2 * k) tsi' (a, b)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (a, b) ti› ‹(af, bf) ⊨ trunk_assn k t ti (last (r # rs)) z (last split)›*) have "length ts = length rs" using "1" (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length tsi' = length rs› ‹length split = Suc (length rs)› ‹(ad, bd) ⊨ is_pfa (2 * k) tsi' (a, b)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (a, b) ti› ‹(af, bf) ⊨ trunk_assn k t ti (last (r # rs)) z (last split)›*) by (auto dest!: list_assn_len (*‹(?h::heap × nat set) ⊨ list_assn (?A::?'a ⇒ ?'b ⇒ assn) (?xs::?'a list) (?ys::?'b list) ⟹ length ?xs = length ?ys›*)) then show "?case" (*goal: ‹r = Some (hd (concat split))›*) proof (cases ts) (*goals: 1. ‹⟦length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list); ts = []⟧ ⟹ (r::'a btnode ref option) = Some (hd (concat (split::'a btnode ref list list)))› 2. ‹⋀(a::'a bplustree × 'a) list::('a bplustree × 'a) list. ⟦length (ts::('a bplustree × 'a) list) = length (rs::'a btnode ref option list); ts = a # list⟧ ⟹ (r::'a btnode ref option) = Some (hd (concat (split::'a btnode ref list list)))›*) case Nil (*‹ts = []›*) then have "length split = 1" "rs = []" using "1"(4) (*‹length split = Suc (length rs)›*) ‹length ts = length rs› (*‹length ts = length rs›*) apply - (*goals: 1. ‹⟦ts = []; length split = Suc (length rs); length ts = length rs⟧ ⟹ length split = 1› 2. ‹⟦ts = []; length split = Suc (length rs); length ts = length rs⟧ ⟹ rs = []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . then have "*": "split = [last split]" by (metis append_butlast_last_id (*‹?xs ≠ [] ⟹ butlast ?xs @ [last ?xs] = ?xs›*) list.distinct( (*‹[] ≠ ?x21.0 # ?x22.0›*) 1) list_decomp_1 (*‹length ?l = 1 ⟹ ∃a. ?l = [a]›*) list_se_match( (*‹?l2.0 ≠ [] ⟹ ([?a] = ?l1.0 @ ?l2.0) = (?l1.0 = [] ∧ ?l2.0 = [?a])›*) 4)) then have "concat split = last split" apply (subst * (*‹split = [last split]›*)) (*goal: ‹concat split = last split›*) unfolding concat.simps (*goal: ‹split = [last split] ⟹ last split @ [] = last split›*) by simp then show "?thesis" (*goal: ‹r = Some (hd (concat split))›*) using "1" (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length tsi' = length rs› ‹length (split::'a btnode ref list list) = Suc (length (rs::'a btnode ref option list))› ‹(ad, bd) ⊨ is_pfa (2 * k) tsi' (a, b)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (a, b) ti› ‹(af, bf) ⊨ trunk_assn k t ti (last (r # rs)) z (last split)›*) using "2.IH"(1)[of ti rs split "(af,bf)"] (*‹(af, bf) ⊨ trunk_assn k t ti (last (r # rs)) (last (rs @ [z])) (last split) ⟹ last (r # rs) = Some (hd (last split))›*) using ‹rs = []› (*‹rs = []›*) by (auto simp add: last.simps (*‹last (?x # ?xs) = (if ?xs = [] then ?x else last ?xs)›*)) next (*goal: ‹⋀a list. ⟦length ts = length rs; ts = a # list⟧ ⟹ r = Some (hd (concat split))›*) case (Cons a list) (*‹ts = a # list›*) then obtain ra and rss and ss1 and ss2 and splits and tss and tsi's where "*": "rs = ra#rss" "split = ss1 # ss2 # splits" "tsi' = tss # tsi's" (*goal: ‹(⋀ra rss ss1 ss2 splits tss tsi's. ⟦rs = ra # rss; split = ss1 # ss2 # splits; tsi' = tss # tsi's⟧ ⟹ thesis) ⟹ thesis›*) by (metis (no_types, lifting) "1" (*‹length (tsi'::('a btnode ref option × 'a) list) = length (rs::'a btnode ref option list)›*) (3) "1" (*‹length (split::'a btnode ref list list) = Suc (length (rs::'a btnode ref option list))›*) (4) Suc_length_conv (*‹(Suc (?n::nat) = length (?xs::?'a list)) = (∃(y::?'a) ys::?'a list. ?xs = y # ys ∧ length ys = ?n)›*) ‹length ts = length rs›) obtain h1 and h2 where first_subtree: "(h1, h2) ⊨ trunk_assn k (fst a) (the (fst tss)) r ra ss1" (*goal: ‹(⋀h1 h2. (h1, h2) ⊨ trunk_assn k (fst a) (the (fst tss)) r ra ss1 ⟹ thesis) ⟹ thesis›*) using "1" (*‹leafptrs = concat split› ‹(ab, bb) ⊨ list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) ts (zip (zip (subtrees tsi') (zip (butlast (r # rs)) (zip rs (butlast split)))) (separators tsi'))› ‹length tsi' = length rs› ‹length split = Suc (length rs)› ‹(ad, bd) ⊨ is_pfa (2 * k) tsi' (ab__, b)› ‹(ae, be) ⊨ aa__ ↦⇩r Btnode (ab__, b) ti› ‹(af, bf) ⊨ trunk_assn k t ti (last (r # rs)) z (last split)›*) apply (auto simp add: butlast_double_Cons (*‹butlast (?x # ?y # ?xs) = ?x # butlast (?y # ?xs)›*) last_double_Cons (*‹last (?x # ?y # ?xs) = last (?y # ?xs)›*) * (*‹rs = ra # rss› ‹split = ss1 # ss2 # splits› ‹tsi' = tss # tsi's›*) Cons (*‹ts = a # list›*)) (*goal: ‹(⋀(h1::heap) h2::nat set. (h1, h2) ⊨ trunk_assn (k::nat) (fst (a::'a bplustree × 'a)) (the (fst (tss::'a btnode ref option × 'a))) (r::'a btnode ref option) (ra::'a btnode ref option) (ss1::'a btnode ref list) ⟹ thesis::bool) ⟹ thesis›*) apply (auto simp add: prod_assn_def (*‹((?P1.0::?'a1.0 ⇒ ?'c1.0 ⇒ assn) ×⇩a (?P2.0::?'a2.0 ⇒ ?'c2.0 ⇒ assn)) (?a::?'a1.0 × ?'a2.0) (?c::?'c1.0 × ?'c2.0) ≡ case (?a, ?c) of ((a1::?'a1.0, a2::?'a2.0), c1::?'c1.0, c2::?'c2.0) ⇒ ?P1.0 a1 c1 * ?P2.0 a2 c2›*) split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹⟦⋀h1 h2. (h1, h2) ⊨ trunk_assn k (fst a) (the (fst tss)) r ra ss1 ⟹ thesis; leafptrs = ss1 @ ss2 @ concat splits; (ab, bb) ⊨ ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) a ((fst tss, r, ra, ss1), snd tss) * list_assn ((λt (ti, r', x, y). trunk_assn k t (the ti) r' x y) ×⇩a id_assn) list (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss (butlast (ss2 # splits))))) (separators tsi's)); length tsi's = length rss; length splits = length rss; (ad, bd) ⊨ is_pfa (2 * k) (tss # tsi's) (ab__, b); (ae, be) ⊨ aa__ ↦⇩r Btnode (ab__, b) ti; (af, bf) ⊨ trunk_assn k t ti (last (ra # rss)) z (last (ss2 # splits))⟧ ⟹ thesis›*) by (auto dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*)) then have "ss1 ≠ []" using trunk_assn_not_empty_aux[of k "(fst a)" "(the (fst tss))" r ra ss1] (*‹trunk_assn k (fst a) (the (fst tss)) r ra ss1 = trunk_assn k (fst a) (the (fst tss)) r ra ss1 * ↑ (ss1 ≠ [])›*) by auto then have "hd (concat split) = hd ss1" by (simp add: "*" (*‹split = ss1 # ss2 # splits›*) (2)) then show "?thesis" (*goal: ‹r = Some (hd (concat split))›*) using first_subtree (*‹(h1, h2) ⊨ trunk_assn k (fst a) (the (fst tss)) r ra ss1›*) apply auto (*goal: ‹r = Some (hd (concat split))›*) by (metis "2.IH" (*‹⟦?xf ∈ set ts; ?y ∈ set ?xc; (?xg, ?ya) = fst ?y; (?xh, ?yb) = ?ya; (?xi, ?yc) = ?yb; ?h ⊨ trunk_assn k (fst ?xf) (the ?xg) ?xh ?xi ?yc⟧ ⟹ ?xh = Some (hd ?yc)›*) (2) fst_conv (*‹fst (?x1.0, ?x2.0) = ?x1.0›*) list.set_intros( (*‹?x21.0 ∈ set (?x21.0 # ?x22.0)›*) 1) local.Cons (*‹ts = a # list›*)) qed qed qed declare last.simps[simp add] butlast.simps[simp add] lemma trunk_assn_hd_aux: "trunk_assn k t a r z leafptrs = trunk_assn k t a r z leafptrs * ↑(r = Some (hd leafptrs))" by (simp add: imp_imp_pure (*‹(⋀h. h ⊨ ?P ⟹ ?Q) ⟹ ?P = ?P * ↑ ?Q›*) trunk_assn_hd (*‹?h ⊨ trunk_assn ?k ?t ?a ?r ?z ?leafptrs ⟹ ?r = Some (hd ?leafptrs)›*)) declare last.simps[simp del] butlast.simps[simp del] lemma subleaf_at_head_of_concat_inner: "length tsi's = length rss ⟹ length rss = length tss ⟹ length tss = length splits ⟹ list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss * ↑(Some (hd (concat splits@ss)) = subleaf)" apply (cases splits) (*goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits⟧ ⟹ list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)›*) subgoal for apply (sep_auto simp add: last.simps) (*goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits; splits = []⟧ ⟹ list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)›*) by (metis (mono_tags, opaque_lifting) trunk_assn_hd_aux (*‹trunk_assn ?k ?t ?a ?r ?z ?leafptrs = trunk_assn ?k ?t ?a ?r ?z ?leafptrs * ↑ (?r = Some (hd ?leafptrs))›*) pure_assn_eq_conv (*‹(↑ ?P = ↑ ?Q) = (?P = ?Q)›*)) subgoal for apply (cases tss; cases rss; cases tsi's) (*goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits; splits = a_ # list_⟧ ⟹ list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)›*) apply simp_all (*top goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits; splits = a_ # list_; tss = []; rss = []; tsi's = []⟧ ⟹ list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)› and 7 goals remain*) apply (sep_auto simp add: butlast_double_Cons last_double_Cons) (*goal: ‹⋀aa lista aaa listaa ab listb. ⟦length listb = length list_; length listaa = length list_; length lista = length list_; splits = a_ # list_; tss = aa # lista; rss = aaa # listaa; tsi's = ab # listb⟧ ⟹ list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) (aa # lista) (zip (zip (fst ab # subtrees listb) (zip (butlast (subleaf # aaa # listaa)) ((aaa, a_) # zip listaa list_))) (snd ab # separators listb)) * trunk_assn k t ti (last (subleaf # aaa # listaa)) z ss = list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) (aa # lista) (zip (zip (fst ab # subtrees listb) (zip (butlast (subleaf # aaa # listaa)) ((aaa, a_) # zip listaa list_))) (snd ab # separators listb)) * trunk_assn k t ti (last (subleaf # aaa # listaa)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹⋀(aa::'a bplustree) (b::'c) (lista::('a bplustree × 'c) list) (aaa::'a btnode ref option) (listaa::'a btnode ref option list) (ab::'a btnode ref option) (ba::'b) listb::('a btnode ref option × 'b) list. ⟦length listb = length (list_::'a btnode ref list list); length listaa = length list_; length lista = length list_; (splits::'a btnode ref list list) = (a_::'a btnode ref list) # list_; (tss::('a bplustree × 'c) list) = (aa, b) # lista; (rss::'a btnode ref option list) = aaa # listaa; (tsi's::('a btnode ref option × 'b) list) = (ab, ba) # listb⟧ ⟹ trunk_assn (k::nat) aa (the ab) (subleaf::'a btnode ref option) aaa a_ * (R::'c ⇒ 'b ⇒ assn) b ba * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, x::'a btnode ref option, xa::'a btnode ref option, y::'a btnode ref list). trunk_assn k t (the ti) x xa y) ×⇩a R) lista (zip (zip (subtrees listb) (zip (butlast (aaa # listaa)) (zip listaa list_))) (separators listb)) * trunk_assn k (t::'a bplustree) (ti::'a btnode ref) (last (aaa # listaa)) (z::'a btnode ref option) (ss::'a btnode ref list) = trunk_assn k aa (the ab) subleaf aaa a_ * R b ba * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, x::'a btnode ref option, xa::'a btnode ref option, y::'a btnode ref list). trunk_assn k t (the ti) x xa y) ×⇩a R) lista (zip (zip (subtrees listb) (zip (butlast (aaa # listaa)) (zip listaa list_))) (separators listb)) * trunk_assn k t ti (last (aaa # listaa)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) subgoal for apply (subst trunk_assn_hd_aux (*‹trunk_assn ?k ?t ?a ?r ?z ?leafptrs = trunk_assn ?k ?t ?a ?r ?z ?leafptrs * ↑ (?r = Some (hd ?leafptrs))›*)) (*goal: ‹⟦length listb_ = length list_; length listaa_ = length list_; length lista_ = length list_; splits = a_ # list_; tss = (aa_, b_) # lista_; rss = aaa_ # listaa_; tsi's = (ab_, ba_) # listb_⟧ ⟹ trunk_assn k aa_ (the ab_) subleaf aaa_ a_ * R b_ ba_ * list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * trunk_assn k t ti (last (aaa_ # listaa_)) z ss ⟹⇩A trunk_assn k aa_ (the ab_) subleaf aaa_ a_ * R b_ ba_ * list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * trunk_assn k t ti (last (aaa_ # listaa_)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) apply (subst trunk_assn_not_empty_aux (*‹trunk_assn (?k::nat) (?t::?'a bplustree) (?a::?'a btnode ref) (?r::?'a btnode ref option) (?z::?'a btnode ref option) (?leafptrs::?'a btnode ref list) = trunk_assn ?k ?t ?a ?r ?z ?leafptrs * ↑ (?leafptrs ≠ [])›*)) (*goal: ‹⟦length listb_ = length list_; length listaa_ = length list_; length lista_ = length list_; splits = a_ # list_; tss = (aa_, b_) # lista_; rss = aaa_ # listaa_; tsi's = (ab_, ba_) # listb_⟧ ⟹ trunk_assn k aa_ (the ab_) subleaf aaa_ a_ * ↑ (subleaf = Some (hd a_)) * R b_ ba_ * list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * trunk_assn k t ti (last (aaa_ # listaa_)) z ss ⟹⇩A trunk_assn k aa_ (the ab_) subleaf aaa_ a_ * R b_ ba_ * list_assn ((λt (ti, x, xa, y). trunk_assn k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * trunk_assn k t ti (last (aaa_ # listaa_)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) by sep_auto subgoal for by sep_auto . . lemma subleaf_at_head_of_concat_bplustree: "length tsi's = length rss ⟹ length rss = length tss ⟹ length tss = length splits ⟹ list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss * ↑(Some (hd (concat splits@ss)) = subleaf)" apply (cases splits) (*goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits⟧ ⟹ list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)›*) subgoal for apply (sep_auto simp add: last.simps) (*goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits; splits = []⟧ ⟹ list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)›*) by (metis (mono_tags, opaque_lifting) bplustree_assn_leafs_hd_aux (*‹bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs = bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs * ↑ (?r = Some (hd ?leafptrs))›*) pure_assn_eq_conv (*‹(↑ ?P = ↑ ?Q) = (?P = ?Q)›*)) subgoal for apply (cases tss; cases rss; cases tsi's) (*goal: ‹⟦length (tsi's::('a::heap btnode ref option × 'b::type) list) = length (rss::'a::heap btnode ref option list); length rss = length (tss::('a::heap bplustree × 'c::type) list); length tss = length (splits::'a::heap btnode ref list list); splits = (a_::'a::heap btnode ref list) # (list_::'a::heap btnode ref list list)⟧ ⟹ list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, x::'a::heap btnode ref option, xa::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) x xa y) ×⇩a (R::'c::type ⇒ 'b::type ⇒ assn)) tss (zip (zip (subtrees tsi's) (zip (butlast ((subleaf::'a::heap btnode ref option) # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k (t::'a::heap bplustree) (ti::'a::heap btnode ref) (last (subleaf # rss)) (z::'a::heap btnode ref option) (ss::'a::heap btnode ref list) = list_assn ((λ(t::'a::heap bplustree) (ti::'a::heap btnode ref option, x::'a::heap btnode ref option, xa::'a::heap btnode ref option, y::'a::heap btnode ref list). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)›*) apply simp_all (*top goal: ‹⟦length tsi's = length rss; length rss = length tss; length tss = length splits; splits = a_ # list_; tss = []; rss = []; tsi's = []⟧ ⟹ list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss = list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) tss (zip (zip (subtrees tsi's) (zip (butlast (subleaf # rss)) (zip rss splits))) (separators tsi's)) * bplustree_assn_leafs k t ti (last (subleaf # rss)) z ss * ↑ (Some (hd (concat splits @ ss)) = subleaf)› and 7 goals remain*) apply (sep_auto simp add: butlast_double_Cons last_double_Cons) (*goal: ‹⋀(aa::'a bplustree × 'c) (lista::('a bplustree × 'c) list) (aaa::'a btnode ref option) (listaa::'a btnode ref option list) (ab::'a btnode ref option × 'b) listb::('a btnode ref option × 'b) list. ⟦length listb = length (list_::'a btnode ref list list); length listaa = length list_; length lista = length list_; (splits::'a btnode ref list list) = (a_::'a btnode ref list) # list_; (tss::('a bplustree × 'c) list) = aa # lista; (rss::'a btnode ref option list) = aaa # listaa; (tsi's::('a btnode ref option × 'b) list) = ab # listb⟧ ⟹ list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, x::'a btnode ref option, xa::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs (k::nat) t (the ti) x xa y) ×⇩a (R::'c ⇒ 'b ⇒ assn)) (aa # lista) (zip (zip (fst ab # subtrees listb) (zip (butlast ((subleaf::'a btnode ref option) # aaa # listaa)) ((aaa, a_) # zip listaa list_))) (snd ab # separators listb)) * bplustree_assn_leafs k (t::'a bplustree) (ti::'a btnode ref) (last (subleaf # aaa # listaa)) (z::'a btnode ref option) (ss::'a btnode ref list) = list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, x::'a btnode ref option, xa::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) (aa # lista) (zip (zip (fst ab # subtrees listb) (zip (butlast (subleaf # aaa # listaa)) ((aaa, a_) # zip listaa list_))) (snd ab # separators listb)) * bplustree_assn_leafs k t ti (last (subleaf # aaa # listaa)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹⋀aa b lista aaa listaa ab ba listb. ⟦length listb = length list_; length listaa = length list_; length lista = length list_; splits = a_ # list_; tss = (aa, b) # lista; rss = aaa # listaa; tsi's = (ab, ba) # listb⟧ ⟹ bplustree_assn_leafs k aa (the ab) subleaf aaa a_ * R b ba * list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) lista (zip (zip (subtrees listb) (zip (butlast (aaa # listaa)) (zip listaa list_))) (separators listb)) * bplustree_assn_leafs k t ti (last (aaa # listaa)) z ss = bplustree_assn_leafs k aa (the ab) subleaf aaa a_ * R b ba * list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) lista (zip (zip (subtrees listb) (zip (butlast (aaa # listaa)) (zip listaa list_))) (separators listb)) * bplustree_assn_leafs k t ti (last (aaa # listaa)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) subgoal for apply (subst bplustree_assn_leafs_hd_aux (*‹bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs = bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs * ↑ (?r = Some (hd ?leafptrs))›*)) (*goal: ‹⟦length (listb_::('a btnode ref option × 'b) list) = length (list_::'a btnode ref list list); length (listaa_::'a btnode ref option list) = length list_; length (lista_::('a bplustree × 'c) list) = length list_; (splits::'a btnode ref list list) = (a_::'a btnode ref list) # list_; (tss::('a bplustree × 'c) list) = (aa_::'a bplustree, b_::'c) # lista_; (rss::'a btnode ref option list) = (aaa_::'a btnode ref option) # listaa_; (tsi's::('a btnode ref option × 'b) list) = (ab_::'a btnode ref option, ba_::'b) # listb_⟧ ⟹ bplustree_assn_leafs (k::nat) aa_ (the ab_) (subleaf::'a btnode ref option) aaa_ a_ * (R::'c ⇒ 'b ⇒ assn) b_ ba_ * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, x::'a btnode ref option, xa::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * bplustree_assn_leafs k (t::'a bplustree) (ti::'a btnode ref) (last (aaa_ # listaa_)) (z::'a btnode ref option) (ss::'a btnode ref list) ⟹⇩A bplustree_assn_leafs k aa_ (the ab_) subleaf aaa_ a_ * R b_ ba_ * list_assn ((λ(t::'a bplustree) (ti::'a btnode ref option, x::'a btnode ref option, xa::'a btnode ref option, y::'a btnode ref list). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * bplustree_assn_leafs k t ti (last (aaa_ # listaa_)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) apply (subst bplustree_assn_leafs_not_empty_aux (*‹bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs = bplustree_assn_leafs ?k ?t ?a ?r ?z ?leafptrs * ↑ (?leafptrs ≠ [])›*)) (*goal: ‹⟦length listb_ = length list_; length listaa_ = length list_; length lista_ = length list_; splits = a_ # list_; tss = (aa_, b_) # lista_; rss = aaa_ # listaa_; tsi's = (ab_, ba_) # listb_⟧ ⟹ bplustree_assn_leafs k aa_ (the ab_) subleaf aaa_ a_ * ↑ (subleaf = Some (hd a_)) * R b_ ba_ * list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * bplustree_assn_leafs k t ti (last (aaa_ # listaa_)) z ss ⟹⇩A bplustree_assn_leafs k aa_ (the ab_) subleaf aaa_ a_ * R b_ ba_ * list_assn ((λt (ti, x, xa, y). bplustree_assn_leafs k t (the ti) x xa y) ×⇩a R) lista_ (zip (zip (subtrees listb_) (zip (butlast (aaa_ # listaa_)) (zip listaa_ list_))) (separators listb_)) * bplustree_assn_leafs k t ti (last (aaa_ # listaa_)) z ss * ↑ (Some (hd (a_ @ concat list_ @ ss)) = subleaf)›*) by sep_auto subgoal for by sep_auto . . declare last.simps[simp add] butlast.simps[simp add] declare last.simps[simp del] butlast.simps[simp del] lemma bplustree_leaf_nodes_sep: "bplustree_assn_leafs k t ti r z lptrs = leaf_nodes_assn k (leaf_nodes t) r z lptrs * trunk_assn k t ti r z lptrs" proof(induction arbitrary: r rule: bplustree_assn_leafs.induct) case (1 k xs a r z) then show ?case apply(intro ent_iffI) apply sep_auto+ done next case (2 k ts t a r z lptrs ra) show ?case apply simp apply(intro inst_same) apply (clarsimp simp add: mult.left_assoc) apply(intro pure_eq_pre) apply(clarsimp) proof(goal_cases) case (1 tsia tsin ti tsi' rs split) have *: " length tsi's = length rss ⟹ length rss = length tss ⟹ length tss = length splits ⟹ set tsi's ⊆ set tsi' ⟹ set rss ⊆ set rs ⟹ set tss ⊆ set ts ⟹ set splits ⊆ set split ⟹ bplustree_assn_leafs k t ti (last (ra # rss)) z (last split)* list_assn ((λt (ti, x, y, s). bplustree_assn_leafs k t (the ti) x y s) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss splits))) (separators tsi's)) = leaf_nodes_assn k (concat (map (leaf_nodes ∘ fst) tss) @ leaf_nodes t) ra z (concat splits @ last split) * list_assn ((λt (ti, x, y, s). trunk_assn k t (the ti) x y s) ×⇩a id_assn) tss (zip (zip (subtrees tsi's) (zip (butlast (ra # rss)) (zip rss splits))) (separators tsi's)) * trunk_assn k t ti (last (ra#rss)) z (last split)" for rss tsi's tss splits proof (induct arbitrary: ra rule: list_induct4) case (Nil r) then show ?case apply(clarsimp) using 2(1)[of ti r "[]" "split"] apply (simp add: last.simps) done next case (Cons subsepi tsi's subleaf rss subsep tss fsplit splits r) show ?case apply (sep_auto simp add: butlast_double_Cons last_double_Cons) apply(subst prod_assn_def)+ apply(simp split!: prod.splits add: mult.left_assoc) subgoal for sub sep (* extract fact that length of leaf nodes of subleaf matches leaf_nodes_assn_split req *) apply(subst bplustree_assn_leafs_len_aux[of k sub]) apply(subst trunk_assn_leafs_len_aux[of k sub]) apply sep_auto apply(intro pure_eq_pre) (* extract fact that the remaining list is not empty *) apply(subst bplustree_assn_leafs_not_empty_aux[of k t]) apply(subst trunk_assn_not_empty_aux[of k t]) apply sep_auto apply(intro pure_eq_pre) supply R = leaf_nodes_assn_split[of "leaf_nodes sub" fsplit "concat splits @ last split" "hd (concat splits @ last split)" "tl (concat splits @ last split)"] thm R apply(subst R) subgoal by simp subgoal by simp (* show that r = hd fsplit *) apply(subst bplustree_assn_leafs_hd_aux[of k sub]) apply(subst trunk_assn_hd_aux[of k sub]) apply sep_auto apply(intro pure_eq_pre) (* refactor multiplication s.t. we can apply the lemma about two mult. factors with an OTF lemma *) supply R = subleaf_at_head_of_concat_inner[of tsi's rss tss splits k id_assn subleaf t ti z "last split"] thm R apply (subst_mod_mult_ac R) subgoal using Cons by simp subgoal using Cons by simp subgoal using Cons by simp apply(simp add: mult.left_assoc)? (* refactor multiplication s.t. we can apply the lemma about two mult. factors with an OTF lemma *) supply R=subleaf_at_head_of_concat_bplustree[of tsi's rss tss splits k id_assn subleaf t ti z "last split"] thm R apply (subst_mod_mult_ac R) subgoal using Cons by simp subgoal using Cons by simp subgoal using Cons by simp apply(simp add: mult.left_assoc)? apply(intro pure_eq_pre) proof(goal_cases) case 1 moreover have p: "set tsi's ⊆ set tsi'" "set rss ⊆ set rs" "set tss ⊆ set ts" "set splits ⊆ set split" using Cons.prems by auto moreover have "(sub,sep) ∈ set ts" using "1" Cons.prems(3) by force moreover obtain temp1 temp2 where "((fst subsepi, (temp1:: 'a btnode ref option), subleaf, fsplit), (temp2::'a)) ∈ set [((fst subsepi, temp1, subleaf, fsplit), temp2)]" by auto ultimately show ?case apply(inst_ex_assn subleaf) using "Cons.hyps"(4)[of subleaf, OF p, simplified] apply (auto simp add: algebra_simps) using "2.IH"(2)[of subsep "((fst subsepi, temp1, subleaf, fsplit),temp2)" "[((fst subsepi, temp1, subleaf, fsplit),temp2)]" "fst subsepi" "(temp1, subleaf, fsplit)" temp1 "(subleaf, fsplit)" subleaf fsplit r, simplified] apply auto using assn_times_assoc ent_refl by presburger qed done qed show ?case apply(intro ent_iffI) subgoal apply(rule entails_preI) using 1 apply(auto dest!: mod_starD list_assn_len) apply(subst_mod_mult_ac *[of tsi' rs ts "butlast split", simplified]) subgoal by auto subgoal by auto subgoal by auto subgoal by (meson in_set_butlastD subset_code(1)) subgoal apply(subgoal_tac "concat (butlast split) @ (last split) = concat split") prefer 2 subgoal apply(subst concat_append_butlast) apply auto done subgoal by sep_auto done done subgoal apply(rule entails_preI) using 1 apply(auto dest!: mod_starD list_assn_len) apply(subgoal_tac "concat split = concat (butlast split) @ (last split)") prefer 2 subgoal apply(subst concat_append_butlast) apply auto done apply simp apply(subst_mod_mult_ac *[of tsi' rs ts "butlast split", simplified, symmetric]) subgoal by auto subgoal by auto subgoal by auto subgoal by (meson in_set_butlastD subset_code(1)) subgoal by sep_auto done done qed qed declare last.simps[simp add] butlast.simps[simp add] fun leaf_node:: "('a::heap) bplustree ⇒ 'a list ⇒ assn" where "leaf_node (Leaf xs) xsi = ↑(xs = xsi)" | "leaf_node _ _ = false" fun leafs_assn :: "('a::heap) pfarray list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ assn" where "leafs_assn (ln#lns) (r'#lptrs) (Some r) z = (∃⇩A fwd. r ↦⇩r Btleaf ln fwd * leafs_assn lns lptrs fwd z * ↑(r' = r) )" | "leafs_assn [] [] r z = ↑(r = z)" | "leafs_assn _ _ _ _ = false" lemma leafs_assn_aux_append: "length xs = length xsi ⟹ leafs_assn (xs@ys) (xsi@ysi) r z = (∃⇩Al. leafs_assn xs xsi r l * leafs_assn ys ysi l z)" apply (induction xs xsi r z rule: leafs_assn.induct (*‹⟦⋀ln lns r' lptrs r z. (⋀x. ?P lns lptrs x z) ⟹ ?P (ln # lns) (r' # lptrs) (Some r) z; ⋀r z. ?P [] [] r z; ⋀v va uw_ ux_. ?P [] (v # va) uw_ ux_; ⋀v va uw_ ux_. ?P (v # va) [] uw_ ux_; ⋀v va uv_ ux_. ?P (v # va) uv_ None ux_; ⋀uu_ v va ux_. ?P uu_ (v # va) None ux_⟧ ⟹ ?P ?a0.0 ?a1.0 ?a2.0 ?a3.0›*)) (*goals: 1. ‹⋀ln lns r' lptrs r z. ⟦⋀x. length lns = length lptrs ⟹ leafs_assn (lns @ ys) (lptrs @ ysi) x z = (∃⇩Al. leafs_assn lns lptrs x l * leafs_assn ys ysi l z); length (ln # lns) = length (r' # lptrs)⟧ ⟹ leafs_assn ((ln # lns) @ ys) ((r' # lptrs) @ ysi) (Some r) z = (∃⇩Al. leafs_assn (ln # lns) (r' # lptrs) (Some r) l * leafs_assn ys ysi l z)› 2. ‹⋀r z. length [] = length [] ⟹ leafs_assn ([] @ ys) ([] @ ysi) r z = (∃⇩Al. leafs_assn [] [] r l * leafs_assn ys ysi l z)› 3. ‹⋀v va uw_ ux_. length [] = length (v # va) ⟹ leafs_assn ([] @ ys) ((v # va) @ ysi) uw_ ux_ = (∃⇩Al. leafs_assn [] (v # va) uw_ l * leafs_assn ys ysi l ux_)› 4. ‹⋀v va uw_ ux_. length (v # va) = length [] ⟹ leafs_assn ((v # va) @ ys) ([] @ ysi) uw_ ux_ = (∃⇩Al. leafs_assn (v # va) [] uw_ l * leafs_assn ys ysi l ux_)› 5. ‹⋀v va uv_ ux_. length (v # va) = length uv_ ⟹ leafs_assn ((v # va) @ ys) (uv_ @ ysi) None ux_ = (∃⇩Al. leafs_assn (v # va) uv_ None l * leafs_assn ys ysi l ux_)› 6. ‹⋀uu_ v va ux_. length uu_ = length (v # va) ⟹ leafs_assn (uu_ @ ys) ((v # va) @ ysi) None ux_ = (∃⇩Al. leafs_assn uu_ (v # va) None l * leafs_assn ys ysi l ux_)› discuss goal 1*) apply (sep_auto intro!: ent_iffI) (*discuss goal 2*) apply (sep_auto intro!: ent_iffI) (*discuss goal 3*) apply (sep_auto intro!: ent_iffI) (*discuss goal 4*) apply (sep_auto intro!: ent_iffI) (*discuss goal 5*) apply (sep_auto intro!: ent_iffI) (*discuss goal 6*) apply (sep_auto intro!: ent_iffI) (*proven 6 subgoals*) . abbreviation "leaf_lists ≡ λt. map leaves (leaf_nodes t)" lemma leaf_nodes_assn_flatten_help: "length ts = length lptrs ⟹ leaf_nodes_assn k ts r z lptrs = (∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2*k)) (map leaves ts) ps * leafs_assn ps lptrs r z)" proof (induction ts lptrs arbitrary: r rule: list_induct2) (*goals: 1. ‹⋀r. leaf_nodes_assn k [] r z [] = (∃⇩Aps. list_assn leaf_node [] (map leaves []) * list_assn (is_pfa (2 * k)) (map leaves []) ps * leafs_assn ps [] r z)› 2. ‹⋀x xs y ys r. ⟦length xs = length ys; ⋀r. leaf_nodes_assn k xs r z ys = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps ys r z)⟧ ⟹ leaf_nodes_assn k (x # xs) r z (y # ys) = (∃⇩Aps. list_assn leaf_node (x # xs) (map leaves (x # xs)) * list_assn (is_pfa (2 * k)) (map leaves (x # xs)) ps * leafs_assn ps (y # ys) r z)›*) case Nil (*no hyothesis introduced yet*) then show "?case" (*goal: ‹leaf_nodes_assn (k::nat) [] (r::'a::heap btnode ref option) (z::'a::heap btnode ref option) [] = (∃⇩Aps::('a::heap array × nat) list. list_assn leaf_node [] (map leaves []) * list_assn (is_pfa ((2::nat) * k)) (map leaves []) ps * leafs_assn ps [] r z)›*) apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹leaf_nodes_assn k [] r z [] = (∃⇩Aps. list_assn leaf_node [] (map leaves []) * list_assn (is_pfa (2 * k)) (map leaves []) ps * leafs_assn ps [] r z)›*) subgoal for by sep_auto subgoal for by sep_auto . next (*goal: ‹⋀x xs y ys r. ⟦length xs = length ys; ⋀r. leaf_nodes_assn k xs r z ys = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps ys r z)⟧ ⟹ leaf_nodes_assn k (x # xs) r z (y # ys) = (∃⇩Aps. list_assn leaf_node (x # xs) (map leaves (x # xs)) * list_assn (is_pfa (2 * k)) (map leaves (x # xs)) ps * leafs_assn ps (y # ys) r z)›*) case (Cons a xs r' lptrs r) (*‹length xs = length lptrs› ‹leaf_nodes_assn k xs ?r z lptrs = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs ?r z)›*) then show "?case" (*goal: ‹leaf_nodes_assn (k::nat) ((a::'a bplustree) # (xs::'a bplustree list)) (r::'a btnode ref option) (z::'a btnode ref option) ((r'::'a btnode ref) # (lptrs::'a btnode ref list)) = (∃⇩Aps::('a array × nat) list. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa ((2::nat) * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z)›*) proof (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*), goal_cases) (*goals: 1. ‹⟦length xs = length lptrs; ⋀r. leaf_nodes_assn k xs r z lptrs = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs r z)⟧ ⟹ leaf_nodes_assn k (a # xs) r z (r' # lptrs) ⟹⇩A ∃⇩Aps. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z› 2. ‹⟦length xs = length lptrs; ⋀r. leaf_nodes_assn k xs r z lptrs = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs r z)⟧ ⟹ ∃⇩Aps. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z ⟹⇩A leaf_nodes_assn k (a # xs) r z (r' # lptrs)›*) case 1 (*‹length xs = length lptrs› ‹leaf_nodes_assn k xs ?r z lptrs = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs ?r z)›*) show "?case" (*goal: ‹leaf_nodes_assn (k::nat) ((a::'a bplustree) # (xs::'a bplustree list)) (r::'a btnode ref option) (z::'a btnode ref option) ((r'::'a btnode ref) # (lptrs::'a btnode ref list)) ⟹⇩A ∃⇩Aps::('a array × nat) list. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa ((2::nat) * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z›*) apply (cases r; cases a) (*goal: ‹leaf_nodes_assn (k::nat) ((a::'a bplustree) # (xs::'a bplustree list)) (r::'a btnode ref option) (z::'a btnode ref option) ((r'::'a btnode ref) # (lptrs::'a btnode ref list)) ⟹⇩A ∃⇩Aps::('a array × nat) list. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa ((2::nat) * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z›*) apply simp_all (*top goal: ‹⋀x1. ⟦r = None; a = Leaf x1⟧ ⟹ leaf_nodes_assn k (a # xs) r z (r' # lptrs) ⟹⇩A ∃⇩Aps. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z› and 3 goals remain*) find_theorems "∃⇩A_._ ⟹⇩A_" apply ((rule ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*))+) (*goal: ‹⋀(aa::'a::heap btnode ref) x1::'a::heap list. ⟦(r::'a::heap btnode ref option) = Some aa; (a::'a::heap bplustree) = Leaf x1⟧ ⟹ ∃⇩A(xsi::'a::heap array × nat) fwd::'a::heap btnode ref option. aa ↦⇩r Btleaf xsi fwd * is_pfa ((2::nat) * (k::nat)) x1 xsi * leaf_nodes_assn k (xs::'a::heap bplustree list) fwd (z::'a::heap btnode ref option) (lptrs::'a::heap btnode ref list) * ↑ (aa = (r'::'a::heap btnode ref)) ⟹⇩A ∃⇩Aps::('a::heap array × nat) list. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa ((2::nat) * k)) (x1 # map leaves xs) ps * leafs_assn ps (r' # lptrs) (Some aa) z›*) subgoal for aa and x1 and xsi and fwd apply (subst "Cons.IH"[of fwd] (*‹leaf_nodes_assn k xs fwd z lptrs = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs fwd z)›*)) (*goal: ‹⟦r = Some aa; a = Leaf x1⟧ ⟹ aa ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k xs fwd z lptrs * ↑ (aa = r') ⟹⇩A ∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (x1 # map leaves xs) ps * leafs_assn ps (r' # lptrs) (Some aa) z›*) apply simp (*goal: ‹⟦(r::'a::heap btnode ref option) = Some (aa::'a::heap btnode ref); (a::'a::heap bplustree) = Leaf (x1::'a::heap list)⟧ ⟹ aa ↦⇩r Btleaf (xsi::'a::heap array × nat) (fwd::'a::heap btnode ref option) * is_pfa ((2::nat) * (k::nat)) x1 xsi * (∃⇩Aps::('a::heap array × nat) list. list_assn leaf_node (xs::'a::heap bplustree list) (map leaves xs) * list_assn (is_pfa ((2::nat) * k)) (map leaves xs) ps * leafs_assn ps (lptrs::'a::heap btnode ref list) fwd (z::'a::heap btnode ref option)) * ↑ (aa = (r'::'a::heap btnode ref)) ⟹⇩A ∃⇩Aps::('a::heap array × nat) list. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa ((2::nat) * k)) (x1 # map leaves xs) ps * leafs_assn ps (r' # lptrs) (Some aa) z›*) apply ((rule ent_ex_preI (*‹(⋀x::?'a. (?P::?'a ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a. ?P x ⟹⇩A ?Q›*))+) (*goal: ‹⟦r = Some aa; a = Leaf x1⟧ ⟹ ∃⇩Aps. aa ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * (list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs fwd z) * ↑ (aa = r') ⟹⇩A ∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (x1 # map leaves xs) ps * leafs_assn ps (r' # lptrs) (Some aa) z›*) subgoal for ps apply (inst_ex_assn "xsi#ps") (*goal: ‹⟦(r::'a btnode ref option) = Some (aa::'a btnode ref); (a::'a bplustree) = Leaf (x1::'a list)⟧ ⟹ aa ↦⇩r Btleaf (xsi::'a array × nat) (fwd::'a btnode ref option) * is_pfa ((2::nat) * (k::nat)) x1 xsi * (list_assn leaf_node (xs::'a bplustree list) (map leaves xs) * list_assn (is_pfa ((2::nat) * k)) (map leaves xs) (ps::('a array × nat) list) * leafs_assn ps (lptrs::'a btnode ref list) fwd (z::'a btnode ref option)) * ↑ (aa = (r'::'a btnode ref)) ⟹⇩A ∃⇩Aps::('a array × nat) list. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa ((2::nat) * k)) (x1 # map leaves xs) ps * leafs_assn ps (r' # lptrs) (Some aa) z›*) apply simp (*goal: ‹⟦r = Some aa; a = Leaf x1⟧ ⟹ aa ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * (list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs fwd z) * ↑ (aa = r') ⟹⇩A list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (x1 # map leaves xs) (xsi # ps) * leafs_assn (xsi # ps) (r' # lptrs) (Some aa) z›*) apply (inst_ex_assn fwd) (*goal: ‹⟦r = Some aa; a = Leaf x1⟧ ⟹ aa = r' ⟶ (r' ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * (list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs fwd z) ⟹⇩A ∃⇩Afwd. list_assn leaf_node xs (map leaves xs) * (is_pfa (2 * k) x1 xsi * list_assn (is_pfa (2 * k)) (map leaves xs) ps) * (r' ↦⇩r Btleaf xsi fwd * leafs_assn ps lptrs fwd z))›*) by sep_auto . . next (*goal: ‹⟦length (xs::'a bplustree list) = length (lptrs::'a btnode ref list); ⋀r::'a btnode ref option. leaf_nodes_assn (k::nat) xs r (z::'a btnode ref option) lptrs = (∃⇩Aps::('a array × nat) list. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa ((2::nat) * k)) (map leaves xs) ps * leafs_assn ps lptrs r z)⟧ ⟹ ∃⇩Aps::('a array × nat) list. list_assn leaf_node ((a::'a bplustree) # xs) (map leaves (a # xs)) * list_assn (is_pfa ((2::nat) * k)) (map leaves (a # xs)) ps * leafs_assn ps ((r'::'a btnode ref) # lptrs) (r::'a btnode ref option) z ⟹⇩A leaf_nodes_assn k (a # xs) r z (r' # lptrs)›*) case 2 (*‹length xs = length lptrs› ‹leaf_nodes_assn k xs ?r z lptrs = (∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs ?r z)›*) have "*": "list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps' * leafs_assn ps' lptrs r'' z ⟹⇩A leaf_nodes_assn k xs r'' z lptrs" for ps' and r'' using assn_eq_split(1)[OF sym [ OF "Cons.IH" [ of r'' ] ]] (*‹∃⇩Aps. list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) ps * leafs_assn ps lptrs r'' z ⟹⇩A leaf_nodes_assn k xs r'' z lptrs›*) ent_ex_inst[where Q = "leaf_nodes_assn k xs r'' z lptrs" and y = ps'] (*‹∃⇩Ax. ?P x ⟹⇩A leaf_nodes_assn k xs r'' z lptrs ⟹ ?P ps' ⟹⇩A leaf_nodes_assn k xs r'' z lptrs›*) by blast show "?case" (*goal: ‹∃⇩Aps. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z ⟹⇩A leaf_nodes_assn k (a # xs) r z (r' # lptrs)›*) apply ((rule ent_ex_preI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a::type. ?P x ⟹⇩A ?Q›*))+) (*goal: ‹∃⇩Aps. list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z ⟹⇩A leaf_nodes_assn k (a # xs) r z (r' # lptrs)›*) subgoal for ps apply (cases ps; cases r; cases a) (*goal: ‹list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z ⟹⇩A leaf_nodes_assn k (a # xs) r z (r' # lptrs)›*) apply simp_all (*top goal: ‹⋀x1. ⟦ps = []; r = None; a = Leaf x1⟧ ⟹ list_assn leaf_node (a # xs) (map leaves (a # xs)) * list_assn (is_pfa (2 * k)) (map leaves (a # xs)) ps * leafs_assn ps (r' # lptrs) r z ⟹⇩A leaf_nodes_assn k (a # xs) r z (r' # lptrs)› and 7 goals remain*) apply ((rule ent_ex_preI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a::type. ?P x ⟹⇩A ?Q›*))+) (*goal: ‹⋀aa list aaa x1. ⟦ps = aa # list; r = Some aaa; a = Leaf x1⟧ ⟹ ∃⇩Afwd. list_assn leaf_node xs (map leaves xs) * (is_pfa (2 * k) x1 aa * list_assn (is_pfa (2 * k)) (map leaves xs) list) * (aaa ↦⇩r Btleaf aa fwd * leafs_assn list lptrs fwd z) * ↑ (r' = aaa) ⟹⇩A ∃⇩Axsi fwd. aaa ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k xs fwd z lptrs * ↑ (aaa = r')›*) subgoal for aa and list and aaa and x1 and fwd apply (inst_ex_assn aa fwd) (*goal: ‹⟦ps = aa # list; r = Some aaa; a = Leaf x1⟧ ⟹ list_assn leaf_node xs (map leaves xs) * (is_pfa (2 * k) x1 aa * list_assn (is_pfa (2 * k)) (map leaves xs) list) * (aaa ↦⇩r Btleaf aa fwd * leafs_assn list lptrs fwd z) * ↑ (r' = aaa) ⟹⇩A ∃⇩Axsi fwd. aaa ↦⇩r Btleaf xsi fwd * is_pfa (2 * k) x1 xsi * leaf_nodes_assn k xs fwd z lptrs * ↑ (aaa = r')›*) apply sep_auto (*goal: ‹⟦ps = aa # list; r = Some aaa; a = Leaf x1⟧ ⟹ list_assn leaf_node xs (map leaves xs) * (is_pfa (2 * k) x1 aa * list_assn (is_pfa (2 * k)) (map leaves xs) list) * (aaa ↦⇩r Btleaf aa fwd * leafs_assn list lptrs fwd z) * ↑ (r' = aaa) ⟹⇩A aaa ↦⇩r Btleaf aa fwd * is_pfa (2 * k) x1 aa * leaf_nodes_assn k xs fwd z lptrs * ↑ (aaa = r')›*) using "*"[of list fwd] (*‹list_assn leaf_node xs (map leaves xs) * list_assn (is_pfa (2 * k)) (map leaves xs) list * leafs_assn list lptrs fwd z ⟹⇩A leaf_nodes_assn k xs fwd z lptrs›*) by (smt (z3) assn_aci( (*‹?a * (?b * ?c) = ?a * ?b * ?c›*) 9) assn_times_comm (*‹?P * ?Q = ?Q * ?P›*) fr_refl (*‹?A ⟹⇩A ?B ⟹ ?A * ?C ⟹⇩A ?B * ?C›*)) . . qed qed lemma leaf_nodes_assn_impl_length: "h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs" apply (induction xs arbitrary: h r lptrs) (*goal: ‹h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs›*) subgoal for h and r and lptrs apply (cases r) (*goals: 1. ‹⟦h ⊨ leaf_nodes_assn k [] r z lptrs; r = None⟧ ⟹ length [] = length lptrs› 2. ‹⋀a. ⟦h ⊨ leaf_nodes_assn k [] r z lptrs; r = Some a⟧ ⟹ length [] = length lptrs› discuss goal 1*) apply (cases lptrs) (*goals: 1. ‹⟦h ⊨ leaf_nodes_assn k [] r z lptrs; r = None; lptrs = []⟧ ⟹ length [] = length lptrs› 2. ‹⋀a list. ⟦h ⊨ leaf_nodes_assn k [] r z lptrs; r = None; lptrs = a # list⟧ ⟹ length [] = length lptrs› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*discuss goal 2*) apply (cases lptrs) (*goals: 1. ‹⋀a. ⟦h ⊨ leaf_nodes_assn k [] r z lptrs; r = Some a; lptrs = []⟧ ⟹ length [] = length lptrs› 2. ‹⋀a aa list. ⟦h ⊨ leaf_nodes_assn k [] r z lptrs; r = Some a; lptrs = aa # list⟧ ⟹ length [] = length lptrs› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*proven 2 subgoals*) . subgoal for a and xs and h and r and lptrs apply (cases r) (*goals: 1. ‹⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = None⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀aa. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = Some aa⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (cases lptrs) (*goals: 1. ‹⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = None; lptrs = []⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀aa list. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = None; lptrs = aa # list⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (cases a) (*goals: 1. ‹⋀x1. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = None; lptrs = []; a = Leaf x1⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀x21 x22. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = None; lptrs = []; a = Node x21 x22⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (sep_auto dest: mod_starD) (*discuss goal 2*) apply (sep_auto dest: mod_starD) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases a) (*goals: 1. ‹⋀(aa::'a::heap btnode ref) (list::'a::heap btnode ref list) x1::'a::heap list. ⟦⋀(h::heap × nat set) (r::'a::heap btnode ref option) lptrs::'a::heap btnode ref list. h ⊨ leaf_nodes_assn (k::nat) (xs::'a::heap bplustree list) r (z::'a::heap btnode ref option) lptrs ⟹ length xs = length lptrs; (h::heap × nat set) ⊨ leaf_nodes_assn k ((a::'a::heap bplustree) # xs) (r::'a::heap btnode ref option) z (lptrs::'a::heap btnode ref list); r = None; lptrs = aa # list; a = Leaf x1⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀(aa::'a::heap btnode ref) (list::'a::heap btnode ref list) (x21::('a::heap bplustree × 'a::heap) list) x22::'a::heap bplustree. ⟦⋀(h::heap × nat set) (r::'a::heap btnode ref option) lptrs::'a::heap btnode ref list. h ⊨ leaf_nodes_assn (k::nat) (xs::'a::heap bplustree list) r (z::'a::heap btnode ref option) lptrs ⟹ length xs = length lptrs; (h::heap × nat set) ⊨ leaf_nodes_assn k ((a::'a::heap bplustree) # xs) (r::'a::heap btnode ref option) z (lptrs::'a::heap btnode ref list); r = None; lptrs = aa # list; a = Node x21 x22⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (sep_auto dest: mod_starD) (*discuss goal 2*) apply (sep_auto dest: mod_starD) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases lptrs) (*goals: 1. ‹⋀aa. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = Some aa; lptrs = []⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀aa aaa list. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = Some aa; lptrs = aaa # list⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (cases a) (*goals: 1. ‹⋀aa x1. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = Some aa; lptrs = []; a = Leaf x1⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀aa x21 x22. ⟦⋀h r lptrs. h ⊨ leaf_nodes_assn k xs r z lptrs ⟹ length xs = length lptrs; h ⊨ leaf_nodes_assn k (a # xs) r z lptrs; r = Some aa; lptrs = []; a = Node x21 x22⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (sep_auto dest: mod_starD) (*discuss goal 2*) apply (sep_auto dest: mod_starD) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases a) (*goals: 1. ‹⋀(aa::'a btnode ref) (aaa::'a btnode ref) (list::'a btnode ref list) x1::'a list. ⟦⋀(h::heap × nat set) (r::'a btnode ref option) lptrs::'a btnode ref list. h ⊨ leaf_nodes_assn (k::nat) (xs::'a bplustree list) r (z::'a btnode ref option) lptrs ⟹ length xs = length lptrs; (h::heap × nat set) ⊨ leaf_nodes_assn k ((a::'a bplustree) # xs) (r::'a btnode ref option) z (lptrs::'a btnode ref list); r = Some aa; lptrs = aaa # list; a = Leaf x1⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀(aa::'a btnode ref) (aaa::'a btnode ref) (list::'a btnode ref list) (x21::('a bplustree × 'a) list) x22::'a bplustree. ⟦⋀(h::heap × nat set) (r::'a btnode ref option) lptrs::'a btnode ref list. h ⊨ leaf_nodes_assn (k::nat) (xs::'a bplustree list) r (z::'a btnode ref option) lptrs ⟹ length xs = length lptrs; (h::heap × nat set) ⊨ leaf_nodes_assn k ((a::'a bplustree) # xs) (r::'a btnode ref option) z (lptrs::'a btnode ref list); r = Some aa; lptrs = aaa # list; a = Node x21 x22⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (sep_auto dest: mod_starD) (*discuss goal 2*) apply (sep_auto dest: mod_starD) (*proven 2 subgoals*) (*proven 2 subgoals*) (*proven 2 subgoals*) . . lemma leafs_assn_impl_length: "h ⊨ leafs_assn xs lptrs r z ⟹ length xs = length lptrs" apply (induction xs arbitrary: h r lptrs) (*goal: ‹h ⊨ leafs_assn xs lptrs r z ⟹ length xs = length lptrs›*) subgoal for h and r and lptrs apply (cases r) (*goals: 1. ‹⟦h ⊨ leafs_assn [] lptrs r z; r = None⟧ ⟹ length [] = length lptrs› 2. ‹⋀a. ⟦h ⊨ leafs_assn [] lptrs r z; r = Some a⟧ ⟹ length [] = length lptrs› discuss goal 1*) apply (cases lptrs) (*goals: 1. ‹⟦h ⊨ leafs_assn [] lptrs r z; r = None; lptrs = []⟧ ⟹ length [] = length lptrs› 2. ‹⋀a list. ⟦h ⊨ leafs_assn [] lptrs r z; r = None; lptrs = a # list⟧ ⟹ length [] = length lptrs› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*discuss goal 2*) apply (cases lptrs) (*goals: 1. ‹⋀a. ⟦h ⊨ leafs_assn [] lptrs r z; r = Some a; lptrs = []⟧ ⟹ length [] = length lptrs› 2. ‹⋀a aa list. ⟦h ⊨ leafs_assn [] lptrs r z; r = Some a; lptrs = aa # list⟧ ⟹ length [] = length lptrs› discuss goal 1*) apply sep_auto (*discuss goal 2*) apply sep_auto (*proven 2 subgoals*) (*proven 2 subgoals*) . subgoal for a and xs and h and r and lptrs apply (cases r) (*goals: 1. ‹⟦⋀h r lptrs. h ⊨ leafs_assn xs lptrs r z ⟹ length xs = length lptrs; h ⊨ leafs_assn (a # xs) lptrs r z; r = None⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀aa. ⟦⋀h r lptrs. h ⊨ leafs_assn xs lptrs r z ⟹ length xs = length lptrs; h ⊨ leafs_assn (a # xs) lptrs r z; r = Some aa⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (cases lptrs) (*goals: 1. ‹⟦⋀(h::heap × nat set) (r::'a btnode ref option) lptrs::'a btnode ref list. h ⊨ leafs_assn (xs::('a array × nat) list) lptrs r (z::'a btnode ref option) ⟹ length xs = length lptrs; (h::heap × nat set) ⊨ leafs_assn ((a::'a array × nat) # xs) (lptrs::'a btnode ref list) (r::'a btnode ref option) z; r = None; lptrs = []⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀(aa::'a btnode ref) list::'a btnode ref list. ⟦⋀(h::heap × nat set) (r::'a btnode ref option) lptrs::'a btnode ref list. h ⊨ leafs_assn (xs::('a array × nat) list) lptrs r (z::'a btnode ref option) ⟹ length xs = length lptrs; (h::heap × nat set) ⊨ leafs_assn ((a::'a array × nat) # xs) (lptrs::'a btnode ref list) (r::'a btnode ref option) z; r = None; lptrs = aa # list⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (sep_auto dest: mod_starD) (*discuss goal 2*) apply (sep_auto dest: mod_starD) (*proven 2 subgoals*) (*discuss goal 2*) apply (cases lptrs) (*goals: 1. ‹⋀aa. ⟦⋀h r lptrs. h ⊨ leafs_assn xs lptrs r z ⟹ length xs = length lptrs; h ⊨ leafs_assn (a # xs) lptrs r z; r = Some aa; lptrs = []⟧ ⟹ length (a # xs) = length lptrs› 2. ‹⋀aa aaa list. ⟦⋀h r lptrs. h ⊨ leafs_assn xs lptrs r z ⟹ length xs = length lptrs; h ⊨ leafs_assn (a # xs) lptrs r z; r = Some aa; lptrs = aaa # list⟧ ⟹ length (a # xs) = length lptrs› discuss goal 1*) apply (sep_auto dest: mod_starD) (*discuss goal 2*) apply (sep_auto dest: mod_starD) (*proven 2 subgoals*) (*proven 2 subgoals*) . . lemma leaf_nodes_assn_flatten: "leaf_nodes_assn k ts r z lptrs = (∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2*k)) (map leaves ts) ps * leafs_assn ps lptrs r z)" proof (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*), goal_cases) (*goals: 1. ‹leaf_nodes_assn k ts r z lptrs ⟹⇩A ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z› 2. ‹∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z ⟹⇩A leaf_nodes_assn k ts r z lptrs›*) case 1 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹leaf_nodes_assn k ts r z lptrs ⟹⇩A ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z›*) apply (rule entails_preI (*‹(⋀h. h ⊨ ?P ⟹ ?P ⟹⇩A ?Q) ⟹ ?P ⟹⇩A ?Q›*)) (*goal: ‹leaf_nodes_assn k ts r z lptrs ⟹⇩A ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z›*) apply (subst leaf_nodes_assn_flatten_help (*‹length (?ts::?'a bplustree list) = length (?lptrs::?'a btnode ref list) ⟹ leaf_nodes_assn (?k::nat) ?ts (?r::?'a btnode ref option) (?z::?'a btnode ref option) ?lptrs = (∃⇩Aps::(?'a array × nat) list. list_assn leaf_node ?ts (map leaves ?ts) * list_assn (is_pfa ((2::nat) * ?k)) (map leaves ?ts) ps * leafs_assn ps ?lptrs ?r ?z)›*)) (*goal: ‹⋀h. h ⊨ leaf_nodes_assn k ts r z lptrs ⟹ leaf_nodes_assn k ts r z lptrs ⟹⇩A ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z›*) subgoal for by (sep_auto dest!: mod_starD leaf_nodes_assn_impl_length) subgoal for by sep_auto . next (*goal: ‹∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z ⟹⇩A leaf_nodes_assn k ts r z lptrs›*) case 2 (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z ⟹⇩A leaf_nodes_assn k ts r z lptrs›*) apply (rule entails_preI (*‹(⋀h. h ⊨ ?P ⟹ ?P ⟹⇩A ?Q) ⟹ ?P ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z ⟹⇩A leaf_nodes_assn k ts r z lptrs›*) apply (subst leaf_nodes_assn_flatten_help (*‹length ?ts = length ?lptrs ⟹ leaf_nodes_assn ?k ?ts ?r ?z ?lptrs = (∃⇩Aps. list_assn leaf_node ?ts (map leaves ?ts) * list_assn (is_pfa (2 * ?k)) (map leaves ?ts) ps * leafs_assn ps ?lptrs ?r ?z)›*)) (*goal: ‹⋀h. h ⊨ (∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z) ⟹ ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r z ⟹⇩A leaf_nodes_assn k ts r z lptrs›*) subgoal for by (sep_auto dest!: mod_starD leafs_assn_impl_length list_assn_len) subgoal for by sep_auto . qed subsection "Iterator" partial_function (heap) first_leaf :: "('a::heap) btnode ref ⇒ 'a btnode ref option Heap" where "first_leaf p = do { node ← !p; (case node of Btleaf _ _ ⇒ do { return (Some p) } | Btnode tsi ti ⇒ do { s ← pfa_get tsi 0; let (sub,sep) = s in do { first_leaf (the sub) } } )}" partial_function (heap) last_leaf :: "('a::heap) btnode ref ⇒ 'a btnode ref option Heap" where "last_leaf p = do { node ← !p; (case node of Btleaf _ z ⇒ do { return z } | Btnode tsi ti ⇒ do { last_leaf ti } )}" declare last.simps[simp del] butlast.simps[simp del] lemma first_leaf_rule[sep_heap_rules]: assumes "k > 0" "root_order k t" shows "<bplustree_assn k t ti r z> first_leaf ti <λu. bplustree_assn k t ti r z * ↑(u = r)>⇩t" using assms proof(induction t arbitrary: ti z) case (Leaf x) then show ?case apply(subst first_leaf.simps) apply (sep_auto dest!: mod_starD) done next case (Node ts t) then obtain sub sep tts where Cons: "ts = (sub,sep)#tts" apply(cases ts) by auto then show ?case apply(subst first_leaf.simps) apply (sep_auto simp add: butlast.simps) subgoal for tsia tsil ti tsi' rs subi sepi apply(cases rs; cases tsi') apply simp_all subgoal for subleaf rrs _ ttsi' supply R = "Node.IH"(1)[of "(sub,sep)" sub "(the subi)" subleaf] thm R using "Node.prems"(1) apply (sep_auto heap add: R) subgoal by (metis Node.prems(2) assms(1) bplustree.inject(2) bplustree.simps(4) Cons list.set_intros(1) order_impl_root_order root_order.elims(2) some_child_sub(1)) apply (sep_auto eintros del: exI) apply(inst_existentials tsia tsil ti "(subi, sepi) # ttsi'" "((subi, (r, subleaf)),sepi)#(zip (zip (subtrees ttsi') (zip (butlast (subleaf # rrs)) rrs)) (separators ttsi'))" "subleaf # rrs") apply (sep_auto simp add: last.simps butlast.simps)+ done done done qed declare last.simps[simp add] butlast.simps[simp add] declare last.simps[simp del] butlast.simps[simp del] lemma last_leaf_rule[sep_heap_rules]: assumes "k > 0" "root_order k t" shows "<bplustree_assn k t ti r z> last_leaf ti <λu. bplustree_assn k t ti r z * ↑(u = z)>⇩t" using assms proof(induction t arbitrary: ti r) case (Leaf x) then show ?case apply(subst last_leaf.simps) apply (sep_auto dest!: mod_starD) done next case (Node ts t) show ?case apply(subst last_leaf.simps) supply R = "Node.IH"(2) apply (sep_auto heap add: R) subgoal using "Node.prems" by simp subgoal by (metis Node.prems(2) assms(1) bplustree.inject(2) bplustree.simps(4) Cons list.set_intros(1) order_impl_root_order root_order.elims(2) some_child_sub(1)) apply (sep_auto eintros del: exI) subgoal for tsia tsil ti tsi' rs apply(inst_existentials tsia tsil ti "tsi'" " (zip (zip (subtrees tsi') (zip (butlast (r # rs)) rs)) (separators tsi'))" rs) apply (sep_auto simp add: last.simps butlast.simps)+ done done qed declare last.simps[simp add] butlast.simps[simp add] definition tree_leaf_iter_init where "tree_leaf_iter_init p = do { r ← first_leaf (the p); z ← last_leaf (the p); return (r, z) }" lemma tree_leaf_iter_init_rule_help: assumes "k > 0" "root_order k t" shows "<bplustree_assn k t ti r z> tree_leaf_iter_init (Some ti) <λ(u,v). bplustree_assn k t ti r z * ↑(u = r ∧ v = z)>⇩t" using assms (*‹0 < k› ‹root_order (k::nat) (t::'a bplustree)›*) unfolding tree_leaf_iter_init_def (*goal: ‹<bplustree_assn (k::nat) (t::'a::heap bplustree) (ti::'a::heap btnode ref) (r::'a::heap btnode ref option) (z::'a::heap btnode ref option)> first_leaf (the (Some ti)) ⤜ (λr::'a::heap btnode ref option. last_leaf (the (Some ti)) ⤜ (λz::'a::heap btnode ref option. return (r, z))) <λra::'a::heap btnode ref option × 'a::heap btnode ref option. case ra of (u::'a::heap btnode ref option, v::'a::heap btnode ref option) ⇒ bplustree_assn k t ti r z * ↑ (u = r ∧ v = z)>⇩t›*) by sep_auto lemma tree_leaf_iter_init_rule: assumes "k > 0" "root_order k t" shows "<bplustree_assn k t ti r z> tree_leaf_iter_init (Some ti) <λ(u,v). ∃⇩A lptrs. leaf_nodes_assn k (leaf_nodes t) r z lptrs * trunk_assn k t ti r z lptrs * ↑(u = r ∧ v = z)>⇩t" using assms (*‹0 < k› ‹root_order k t›*) apply (vcg heap add: tree_leaf_iter_init_rule_help) (*goal: ‹<bplustree_assn (k::nat) (t::'a bplustree) (ti::'a btnode ref) (r::'a btnode ref option) (z::'a btnode ref option)> tree_leaf_iter_init (Some ti) <λra::'a btnode ref option × 'a btnode ref option. case ra of (u::'a btnode ref option, v::'a btnode ref option) ⇒ ∃⇩Alptrs::'a btnode ref list. leaf_nodes_assn k (leaf_nodes t) r z lptrs * trunk_assn k t ti r z lptrs * ↑ (u = r ∧ v = z)>⇩t›*) by (simp add: bplustree_extract_leafs (*‹bplustree_assn ?k ?t ?ti ?r ?z = (∃⇩Aleafptrs. bplustree_assn_leafs ?k ?t ?ti ?r ?z leafptrs)›*) bplustree_leaf_nodes_sep (*‹bplustree_assn_leafs ?k ?t ?ti ?r ?z ?lptrs = leaf_nodes_assn ?k (leaf_nodes ?t) ?r ?z ?lptrs * trunk_assn ?k ?t ?ti ?r ?z ?lptrs›*)) lemma tree_leaf_iter_init_rule_alt: assumes "k > 0" "root_order k t" shows "<bplustree_assn k t ti r z> tree_leaf_iter_init (Some ti) <λ(u,v). ∃⇩A lptrs ps. list_assn leaf_node (leaf_nodes t) (map leaves (leaf_nodes t)) * list_assn (is_pfa (2*k)) (map leaves (leaf_nodes t)) ps * leafs_assn ps lptrs r z * trunk_assn k t ti r z lptrs * ↑(u = r ∧ v = z)>⇩t" using assms (*‹0 < k› ‹root_order k t›*) apply (vcg heap add: tree_leaf_iter_init_rule) (*goal: ‹<bplustree_assn k t ti r z> tree_leaf_iter_init (Some ti) <λra. case ra of (u, v) ⇒ ∃⇩Alptrs ps. list_assn leaf_node (leaf_nodes t) (leaf_lists t) * list_assn (is_pfa (2 * k)) (leaf_lists t) ps * leafs_assn ps lptrs r z * trunk_assn k t ti r z lptrs * ↑ (u = r ∧ v = z)>⇩t›*) by (sep_auto simp add: leaf_nodes_assn_flatten) (* TODO derive version that yields leaf_iter_assn *) definition leaf_iter_next where "leaf_iter_next = (λ(r,z). do { p ← !(the r); return (vals p, (fwd p, z)) })" lemma leaf_iter_next_rule_help: "<leafs_assn (x#xs) (l#lptrs) r z> leaf_iter_next (r,z) <λ(p,(n,z')). leafs_assn [x] [l] r n * leafs_assn xs lptrs n z' * ↑(p = x) * ↑(z=z')>" apply (subst leaf_iter_next_def (*‹leaf_iter_next = (λ(r, z). !the r ⤜ (λp. return (BPlusTree_Imp.vals p, fwd p, z)))›*)) (*goal: ‹<leafs_assn (x # xs) (l # lptrs) r z> leaf_iter_next (r, z) <λ(p, n, z'). leafs_assn [x] [l] r n * leafs_assn xs lptrs n z' * ↑ (p = x) * ↑ (z = z')>›*) apply (cases r) (*goals: 1. ‹r = None ⟹ <leafs_assn (x # xs) (l # lptrs) r z> case (r, z) of (r, z) ⇒ !the r ⤜ (λp. return (BPlusTree_Imp.vals p, fwd p, z)) <λ(p, n, z'). leafs_assn [x] [l] r n * leafs_assn xs lptrs n z' * ↑ (p = x) * ↑ (z = z')>› 2. ‹⋀a. r = Some a ⟹ <leafs_assn (x # xs) (l # lptrs) r z> case (r, z) of (r, z) ⇒ !the r ⤜ (λp. return (BPlusTree_Imp.vals p, fwd p, z)) <λ(p, n, z'). leafs_assn [x] [l] r n * leafs_assn xs lptrs n z' * ↑ (p = x) * ↑ (z = z')>› discuss goal 1*) apply (cases x) (*top goal: ‹r = None ⟹ <leafs_assn (x # xs) (l # lptrs) r z> case (r, z) of (r, z) ⇒ !the r ⤜ (λp. return (BPlusTree_Imp.vals p, fwd p, z)) <λ(p, n, z'). leafs_assn [x] [l] r n * leafs_assn xs lptrs n z' * ↑ (p = x) * ↑ (z = z')>› and 1 goal remains*) apply sep_auto (*discuss goal 2*) apply (cases x) (*goal: ‹⋀a. r = Some a ⟹ <leafs_assn (x # xs) (l # lptrs) r z> case (r, z) of (r, z) ⇒ !the r ⤜ (λp. return (BPlusTree_Imp.vals p, fwd p, z)) <λ(p, n, z'). leafs_assn [x] [l] r n * leafs_assn xs lptrs n z' * ↑ (p = x) * ↑ (z = z')>›*) apply sep_auto (*proven 2 subgoals*) . definition leaf_iter_assn where "leaf_iter_assn xs lptrs r xs2 = (λ(n,z). (∃⇩Axs1 lptrs1 lptrs2. ↑(xs = xs1@xs2) * ↑(lptrs = lptrs1@lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑(z=None)))" lemma leaf_nodes_assn_imp_iter_assn: "leafs_assn xs lptrs r None ⟹⇩A leaf_iter_assn xs lptrs r xs (r,None)" unfolding leaf_iter_assn_def (*goal: ‹leafs_assn xs lptrs r None ⟹⇩A (case (r, None) of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs lptrs2 n z * ↑ (z = None))›*) by sep_auto definition leaf_iter_init where "leaf_iter_init p = do { return (p, None) }" lemma leaf_iter_init_rule: shows "<leafs_assn xs lptrs r None> leaf_iter_init r <λu. leaf_iter_assn xs lptrs r xs u>" unfolding leaf_iter_init_def (*goal: ‹<leafs_assn xs lptrs r None> return (r, None) <leaf_iter_assn xs lptrs r xs>›*) using leaf_nodes_assn_imp_iter_assn (*‹leafs_assn ?xs ?lptrs ?r None ⟹⇩A leaf_iter_assn ?xs ?lptrs ?r ?xs (?r, None)›*) by sep_auto lemma leaf_iter_next_rule: "<leaf_iter_assn xs lptrs r (x#xs2) it> leaf_iter_next it <λ(p, it'). leaf_iter_assn xs lptrs r xs2 it' * ↑(p = x)>" unfolding leaf_iter_assn_def (*goal: ‹<case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ x # xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn (x # xs2) lptrs2 n z * ↑ (z = None)> leaf_iter_next it <λ(p, it'). (case it' of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (p = x)>›*) apply (clarsimp split: prod.splits (*‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∀(x1::?'a) x2::?'b. ?prod = (x1, x2) ⟶ ?P (?f x1 x2))› ‹(?P::?'c ⇒ bool) (case ?prod::?'a × ?'b of (x::?'a, xa::?'b) ⇒ (?f::?'a ⇒ ?'b ⇒ ?'c) x xa) = (∄(x1::?'a) x2::?'b. ?prod = (x1, x2) ∧ ¬ ?P (?f x1 x2))›*)) (*goal: ‹<case it::'a btnode ref option × 'a btnode ref option of (n::'a btnode ref option, z::'a btnode ref option) ⇒ ∃⇩A(xs1::('a array × nat) list) (lptrs1::'a btnode ref list) lptrs2::'a btnode ref list. ↑ ((xs::('a array × nat) list) = xs1 @ (x::'a array × nat) # (xs2::('a array × nat) list)) * ↑ ((lptrs::'a btnode ref list) = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 (r::'a btnode ref option) n * leafs_assn (x # xs2) lptrs2 n z * ↑ (z = None)> leaf_iter_next it <λ(p::'a array × nat, it'::'a btnode ref option × 'a btnode ref option). (case it' of (n::'a btnode ref option, z::'a btnode ref option) ⇒ ∃⇩A(xs1::('a array × nat) list) (lptrs1::'a btnode ref list) lptrs2::'a btnode ref list. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (p = x)>›*) apply (intro norm_pre_ex_rule (*‹(⋀x. <?P x> ?f <?Q>) ⟹ <∃⇩Ax. ?P x> ?f <?Q>›*)) (*goal: ‹⋀x1 x2. it = (x1, x2) ⟹ <∃⇩Axs1 lptrs1 lptrs2. leafs_assn xs1 lptrs1 r x1 * leafs_assn (x # xs2) lptrs2 x1 x2 * ↑ (xs = xs1 @ x # xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ x2 = None)> leaf_iter_next (x1, x2) <λ(p, it'). (case it' of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (p = x)>›*) subgoal for n and z and xs1 and lptrs1 and lptrs2 apply (rule hoare_triple_preI (*‹(⋀h. h ⊨ ?P ⟹ <?P> ?c <?Q>) ⟹ <?P> ?c <?Q>›*)) (*goal: ‹it = (n, z) ⟹ <leafs_assn xs1 lptrs1 r n * leafs_assn (x # xs2) lptrs2 n z * ↑ (xs = xs1 @ x # xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ z = None)> leaf_iter_next (n, z) <λ(p, it'). (case it' of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (p = x)>›*) apply (clarsimp dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹?h ⊨ leafs_assn ?xs ?lptrs ?r ?z ⟹ length ?xs = length ?lptrs›*)) (*goal: ‹⋀h::heap × nat set. ⟦(it::'a::heap btnode ref option × 'a::heap btnode ref option) = (n::'a::heap btnode ref option, z::'a::heap btnode ref option); h ⊨ leafs_assn (xs1::('a::heap array × nat) list) (lptrs1::'a::heap btnode ref list) (r::'a::heap btnode ref option) n * leafs_assn ((x::'a::heap array × nat) # (xs2::('a::heap array × nat) list)) (lptrs2::'a::heap btnode ref list) n z * ↑ ((xs::('a::heap array × nat) list) = xs1 @ x # xs2 ∧ (lptrs::'a::heap btnode ref list) = lptrs1 @ lptrs2 ∧ z = None)⟧ ⟹ <leafs_assn xs1 lptrs1 r n * leafs_assn (x # xs2) lptrs2 n z * ↑ (xs = xs1 @ x # xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ z = None)> leaf_iter_next (n, z) <λ(p::'a::heap array × nat, it'::'a::heap btnode ref option × 'a::heap btnode ref option). (case it' of (n::'a::heap btnode ref option, z::'a::heap btnode ref option) ⇒ ∃⇩A(xs1::('a::heap array × nat) list) (lptrs1::'a::heap btnode ref list) lptrs2::'a::heap btnode ref list. ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (p = x)>›*) apply (cases lptrs2; clarsimp) (*goal: ‹⟦it = (n, None); xs = xs1 @ x # xs2; length xs1 = length lptrs1; Suc (length xs2) = length lptrs2; lptrs = lptrs1 @ lptrs2; z = None⟧ ⟹ <leafs_assn xs1 lptrs1 r n * leafs_assn (x # xs2) lptrs2 n None> leaf_iter_next (n, None) <λ(p, it'). (case it' of (n, z) ⇒ ∃⇩Axs1a lptrs1a lptrs2a. ↑ (xs1 @ [x] = xs1a ∧ lptrs1 @ lptrs2 = lptrs1a @ lptrs2a) * leafs_assn xs1a lptrs1a r n * leafs_assn xs2 lptrs2a n z * ↑ (z = None)) * ↑ (p = x)>›*) subgoal for l and llptrs2 apply (sep_auto heap add: leaf_iter_next_rule_help eintros del: exI) (*goal: ‹⟦(it::'a btnode ref option × 'a btnode ref option) = (n::'a btnode ref option, None); (xs::('a array × nat) list) = (xs1::('a array × nat) list) @ (x::'a array × nat) # (xs2::('a array × nat) list); length xs1 = length (lptrs1::'a btnode ref list); length xs2 = length (llptrs2::'a btnode ref list); (lptrs::'a btnode ref list) = lptrs1 @ (l::'a btnode ref) # llptrs2; (z::'a btnode ref option) = None; (lptrs2::'a btnode ref list) = l # llptrs2⟧ ⟹ <leafs_assn xs1 lptrs1 (r::'a btnode ref option) n * leafs_assn (x # xs2) (l # llptrs2) n None> leaf_iter_next (n, None) <λ(p::'a array × nat, it'::'a btnode ref option × 'a btnode ref option). (case it' of (n::'a btnode ref option, z::'a btnode ref option) ⇒ ∃⇩A(xs1a::('a array × nat) list) (lptrs1a::'a btnode ref list) lptrs2::'a btnode ref list. ↑ (xs1 @ [x] = xs1a ∧ lptrs1 @ l # llptrs2 = lptrs1a @ lptrs2) * leafs_assn xs1a lptrs1a r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (p = x)>›*) apply (inst_existentials "xs1@[x]" "lptrs1@[l]" llptrs2) (*goal: ‹⋀a b aa. ⟦it = (n, None); xs = xs1 @ (a, b) # xs2; length xs1 = length lptrs1; length xs2 = length llptrs2; lptrs = lptrs1 @ l # llptrs2; z = None; lptrs2 = l # llptrs2; x = (a, b)⟧ ⟹ ∃lptrs2 lptrs2a lptrs2b. ((∃ab ba. (ab, ba) ⊨ leafs_assn [(a, b)] [l] n aa * leafs_assn xs2 llptrs2 aa None * leafs_assn xs1 lptrs1 r n) ⟶ xs1 @ [(a, b)] = lptrs2 ∧ lptrs1 @ l # llptrs2 = lptrs2a @ lptrs2b) ∧ (leafs_assn [(a, b)] [l] n aa * leafs_assn xs2 llptrs2 aa None * leafs_assn xs1 lptrs1 r n ⟹⇩A leafs_assn lptrs2 lptrs2a r aa * leafs_assn xs2 lptrs2b aa None)›*) subgoal for by sep_auto subgoal for by (sep_auto simp add: leafs_assn_aux_append) . . . definition leaf_iter_has_next where "leaf_iter_has_next = (λ(r,z). return (r ≠ z))" (* TODO this so far only works for the whole tree (z = None) for subintervals, we would need to show that the list of pointers is indeed distinct, hence r = z can only occur at the end *) lemma leaf_iter_has_next_rule: "<leaf_iter_assn xs lptrs r xs2 it> leaf_iter_has_next it <λu. leaf_iter_assn xs lptrs r xs2 it * ↑(u ⟷ xs2 ≠ [])>" unfolding leaf_iter_has_next_def leaf_iter_assn_def (*goal: ‹<case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)> case it of (r, z) ⇒ return (r ≠ z) <λu. (case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (u = (xs2 ≠ []))>›*) apply (cases it) (*goal: ‹<case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)> case it of (r, z) ⇒ return (r ≠ z) <λu. (case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (u = (xs2 ≠ []))>›*) apply simp (*goal: ‹⋀(a::'a btnode ref option) b::'a btnode ref option. (it::'a btnode ref option × 'a btnode ref option) = (a, b) ⟹ <case it of (n::'a btnode ref option, z::'a btnode ref option) ⇒ ∃⇩A(xs1::('a array × nat) list) (lptrs1::'a btnode ref list) lptrs2::'a btnode ref list. ↑ ((xs::('a array × nat) list) = xs1 @ (xs2::('a array × nat) list)) * ↑ ((lptrs::'a btnode ref list) = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 (r::'a btnode ref option) n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)> case it of (r::'a btnode ref option, z::'a btnode ref option) ⇒ return (r ≠ z) <λu::bool. (case it of (n::'a btnode ref option, z::'a btnode ref option) ⇒ ∃⇩A(xs1::('a array × nat) list) (lptrs1::'a btnode ref list) lptrs2::'a btnode ref list. ↑ (xs = xs1 @ xs2) * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 r n * leafs_assn xs2 lptrs2 n z * ↑ (z = None)) * ↑ (u = (xs2 ≠ []))>›*) apply (intro norm_pre_ex_rule (*‹(⋀x. <?P x> ?f <?Q>) ⟹ <∃⇩Ax. ?P x> ?f <?Q>›*)) (*goal: ‹⋀a b. it = (a, b) ⟹ <∃⇩Axs1 lptrs1 lptrs2. leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None)> return (a ≠ b) <λu. ∃⇩Axs1 lptrs1 lptrs2. leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None ∧ u = (xs2 ≠ []))>›*) apply (rule hoare_triple_preI (*‹(⋀h::heap × nat set. h ⊨ (?P::assn) ⟹ <?P> ?c::?'a Heap <?Q::?'a ⇒ assn>) ⟹ <?P> ?c <?Q>›*)) (*goal: ‹⋀a b xs1 lptrs1 lptrs2. it = (a, b) ⟹ <leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None)> return (a ≠ b) <λu. ∃⇩Axs1 lptrs1 lptrs2. leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None ∧ u = (xs2 ≠ []))>›*) apply (clarsimp dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹?h ⊨ leafs_assn ?xs ?lptrs ?r ?z ⟹ length ?xs = length ?lptrs›*)) (*goal: ‹⋀a b xs1 lptrs1 lptrs2 h. ⟦it = (a, b); h ⊨ leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None)⟧ ⟹ <leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None)> return (a ≠ b) <λu. ∃⇩Axs1 lptrs1 lptrs2. leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a b * ↑ (xs = xs1 @ xs2 ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None ∧ u = (xs2 ≠ []))>›*) apply (sep_auto split!: prod.splits dest!: mod_starD) (*goal: ‹⋀a xs1 lptrs1 lptrs2. ⟦it = (a, None); xs = xs1 @ xs2; lptrs = lptrs1 @ lptrs2; length xs1 = length lptrs1; length xs2 = length lptrs2⟧ ⟹ <leafs_assn xs1 lptrs1 r a * leafs_assn xs2 lptrs2 a None> return (∃y. a = Some y) <λu. ∃⇩Axs1a lptrs1a lptrs2a. leafs_assn xs1a lptrs1a r a * leafs_assn xs2 lptrs2a a None * ↑ (xs1 = xs1a ∧ lptrs1 @ lptrs2 = lptrs1a @ lptrs2a ∧ u = (xs2 ≠ []))>›*) by (metis leafs_assn.simps (*‹leafs_assn (?ln # ?lns) (?r' # ?lptrs) (Some ?r) ?z = (∃⇩Afwd. ?r ↦⇩r Btleaf ?ln fwd * leafs_assn ?lns ?lptrs fwd ?z * ↑ (?r' = ?r))› ‹leafs_assn [] [] ?r ?z = ↑ (?r = ?z)› ‹leafs_assn [] (?v # ?va) ?uw ?ux = false› ‹leafs_assn (?v # ?va) [] ?uw ?ux = false› ‹leafs_assn (?v # ?va) ?uv None ?ux = false› ‹leafs_assn ?uu (?v # ?va) None ?ux = false›*) list.exhaust (*‹⟦?y = [] ⟹ ?P; ⋀x21 x22. ?y = x21 # x22 ⟹ ?P⟧ ⟹ ?P›*) mod_false (*‹¬ ?h ⊨ false›*) option.exhaust (*‹⟦?y = None ⟹ ?P; ⋀x2. ?y = Some x2 ⟹ ?P⟧ ⟹ ?P›*)) (* copied from peter lammichs lseg_prec2, don't ask what happens in the induction step (or ask peter lammich) *) declare mult.left_commute[simp add] lemma leafs_assn_prec2: "∀l l'. (h⊨ (leafs_assn l lptrs p None * F1) ∧⇩A (leafs_assn l' lptrs p None * F2)) ⟶ l=l'" apply (intro allI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ bool) x) ⟹ ∀x::?'a::type. ?P x›*)) (*goal: ‹∀l l'. h ⊨ leafs_assn l lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ l = l'›*) subgoal for l and l' proof (induct l arbitrary: lptrs p l' F1 F2) (*goals: 1. ‹⋀lptrs p l' F1 F2. h ⊨ leafs_assn [] lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ [] = l'› 2. ‹⋀a l lptrs p l' F1 F2. (⋀lptrs p l' F1 F2. h ⊨ leafs_assn l lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ l = l') ⟹ h ⊨ leafs_assn (a # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ a # l = l'›*) case Nil (*no hyothesis introduced yet*) thus "?case" (*goal: ‹h ⊨ leafs_assn [] lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ [] = l'›*) apply (cases l') (*goals: 1. ‹l' = [] ⟹ h ⊨ leafs_assn [] lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ [] = l'› 2. ‹⋀a list. l' = a # list ⟹ h ⊨ leafs_assn [] lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ [] = l'› discuss goal 1*) apply simp (*discuss goal 2*) apply (cases p) (*goals: 1. ‹⋀(a::'a array × nat) list::('a array × nat) list. ⟦(l'::('a array × nat) list) = a # list; (p::'a btnode ref option) = None⟧ ⟹ (h::heap × nat set) ⊨ leafs_assn [] (lptrs::'a btnode ref list) p None * (F1::assn) ∧⇩A leafs_assn l' lptrs p None * (F2::assn) ⟶ [] = l'› 2. ‹⋀(a::'a array × nat) (list::('a array × nat) list) aa::'a btnode ref. ⟦(l'::('a array × nat) list) = a # list; (p::'a btnode ref option) = Some aa⟧ ⟹ (h::heap × nat set) ⊨ leafs_assn [] (lptrs::'a btnode ref list) p None * (F1::assn) ∧⇩A leafs_assn l' lptrs p None * (F2::assn) ⟶ [] = l'› discuss goal 1*) apply ((auto simp add: mod_and_dist (*‹(?h ⊨ ?P ∧⇩A ?Q) = (?h ⊨ ?P ∧ ?h ⊨ ?Q)›*) dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹?h ⊨ leafs_assn ?xs ?lptrs ?r ?z ⟹ length ?xs = length ?lptrs›*))[1]) (*discuss goal 2*) apply ((auto simp add: mod_and_dist (*‹((?h::heap × nat set) ⊨ (?P::assn) ∧⇩A (?Q::assn)) = (?h ⊨ ?P ∧ ?h ⊨ ?Q)›*) dest!: mod_starD (*‹(?h::heap × nat set) ⊨ (?A::assn) * (?B::assn) ⟹ ∃(h1::heap × nat set) h2::heap × nat set. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹(?h::heap × nat set) ⊨ leafs_assn (?xs::(?'a array × nat) list) (?lptrs::?'a btnode ref list) (?r::?'a btnode ref option) (?z::?'a btnode ref option) ⟹ length ?xs = length ?lptrs›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . next (*goal: ‹⋀(a::'a::heap array × nat) (l::('a::heap array × nat) list) (lptrs::'a::heap btnode ref list) (p::'a::heap btnode ref option) (l'::('a::heap array × nat) list) (F1::assn) F2::assn. (⋀(lptrs::'a::heap btnode ref list) (p::'a::heap btnode ref option) (l'::('a::heap array × nat) list) (F1::assn) F2::assn. (h::heap × nat set) ⊨ leafs_assn l lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ l = l') ⟹ h ⊨ leafs_assn (a # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ a # l = l'›*) case (Cons y l) (*‹(h::heap × nat set) ⊨ leafs_assn (l::('a::heap array × nat) list) (?lptrs::'a::heap btnode ref list) (?p::'a::heap btnode ref option) None * (?F1.0::assn) ∧⇩A leafs_assn (?l'::('a::heap array × nat) list) ?lptrs ?p None * (?F2.0::assn) ⟶ l = ?l'›*) from Cons.prems show "?case" (*goal: ‹h ⊨ leafs_assn (y # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ y # l = l'›*) apply (cases p) (*goal: ‹h ⊨ leafs_assn (y # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ y # l = l'›*) apply simp (*top goal: ‹(p::'a btnode ref option) = None ⟹ (h::heap × nat set) ⊨ leafs_assn ((y::'a array × nat) # (l::('a array × nat) list)) (lptrs::'a btnode ref list) p None * (F1::assn) ∧⇩A leafs_assn (l'::('a array × nat) list) lptrs p None * (F2::assn) ⟶ y # l = l'› and 1 goal remains*) apply (cases l') (*goal: ‹⋀a. p = Some a ⟹ h ⊨ leafs_assn (y # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ y # l = l'›*) subgoal for by (auto simp add: mod_and_dist (*‹(?h ⊨ ?P ∧⇩A ?Q) = (?h ⊨ ?P ∧ ?h ⊨ ?Q)›*) dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹?h ⊨ leafs_assn ?xs ?lptrs ?r ?z ⟹ length ?xs = length ?lptrs›*)) apply (cases lptrs) (*goal: ‹⋀a aa list. ⟦p = Some a; l' = aa # list⟧ ⟹ h ⊨ leafs_assn (y # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ y # l = l'›*) subgoal for by (auto simp add: mod_and_dist (*‹(?h ⊨ ?P ∧⇩A ?Q) = (?h ⊨ ?P ∧ ?h ⊨ ?Q)›*) dest!: mod_starD (*‹?h ⊨ ?A * ?B ⟹ ∃h1 h2. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹?h ⊨ leafs_assn ?xs ?lptrs ?r ?z ⟹ length ?xs = length ?lptrs›*)) apply rule (*goal: ‹⋀a aa list ab lista. ⟦p = Some a; l' = aa # list; lptrs = ab # lista⟧ ⟹ h ⊨ leafs_assn (y # l) lptrs p None * F1 ∧⇩A leafs_assn l' lptrs p None * F2 ⟶ y # l = l'›*) apply clarsimp (*goal: ‹⋀(a::'a btnode ref) (aa::'a array × nat) (list::('a array × nat) list) (ab::'a btnode ref) lista::'a btnode ref list. ⟦(p::'a btnode ref option) = Some a; (l'::('a array × nat) list) = aa # list; (lptrs::'a btnode ref list) = ab # lista; (h::heap × nat set) ⊨ leafs_assn ((y::'a array × nat) # (l::('a array × nat) list)) lptrs p None * (F1::assn) ∧⇩A leafs_assn l' lptrs p None * (F2::assn)⟧ ⟹ y # l = l'›*) apply (subgoal_tac "y = (aa, b) ∧ fwd = fwda", simp) (*goal: ‹⋀a aa b list lista fwd fwda. ⟦p = Some a; l' = (aa, b) # list; lptrs = a # lista; h ⊨ a ↦⇩r Btleaf y fwda * leafs_assn l lista fwda None * F1 ∧⇩A a ↦⇩r Btleaf (aa, b) fwd * leafs_assn list lista fwd None * F2⟧ ⟹ y = (aa, b) ∧ l = list›*) using Cons.hyps (*‹h ⊨ leafs_assn l ?lptrs ?p None * ?F1.0 ∧⇩A leafs_assn ?l' ?lptrs ?p None * ?F2.0 ⟶ l = ?l'›*) (*goals: 1. ‹⋀a aa b list lista fwd. ⟦p = Some a; l' = (aa, b) # list; lptrs = a # lista; h ⊨ a ↦⇩r Btleaf (aa, b) fwd * leafs_assn l lista fwd None * F1 ∧⇩A a ↦⇩r Btleaf (aa, b) fwd * leafs_assn list lista fwd None * F2; y = (aa, b)⟧ ⟹ l = list› 2. ‹⋀a aa b list lista fwd fwda. ⟦p = Some a; l' = (aa, b) # list; lptrs = a # lista; h ⊨ a ↦⇩r Btleaf y fwda * leafs_assn l lista fwda None * F1 ∧⇩A a ↦⇩r Btleaf (aa, b) fwd * leafs_assn list lista fwd None * F2⟧ ⟹ y = (aa, b) ∧ fwd = fwda› discuss goal 1*) apply (erule prec_frame' (*‹⟦?h ⊨ ?P ?x * ?F1.0 ∧⇩A ?P ?y * ?F2.0 ⟶ ?x = ?y; ?h ⊨ ?R1.0 ∧⇩A ?R2.0; ?R1.0 ⟹⇩A ?P ?x * ?F1.0; ?R2.0 ⟹⇩A ?P ?y * ?F2.0⟧ ⟹ ?x = ?y›*)) (*goals: 1. ‹⋀a aa b list lista fwd. ⟦p = Some a; l' = (aa, b) # list; lptrs = a # lista; y = (aa, b)⟧ ⟹ a ↦⇩r Btleaf (aa, b) fwd * leafs_assn l lista fwd None * F1 ⟹⇩A leafs_assn l (?lptrs13 a aa b list lista fwd l) (?p12 a aa b list lista fwd l) None * ?F1.10 a aa b list lista fwd› 2. ‹⋀a aa b list lista fwd. ⟦p = Some a; l' = (aa, b) # list; lptrs = a # lista; y = (aa, b)⟧ ⟹ a ↦⇩r Btleaf (aa, b) fwd * leafs_assn list lista fwd None * F2 ⟹⇩A leafs_assn list (?lptrs13 a aa b list lista fwd list) (?p12 a aa b list lista fwd list) None * ?F2.10 a aa b list lista fwd› discuss goal 1*) apply frame_inference (*discuss goal 2*) apply frame_inference (*proven 2 subgoals*) (*discuss goal 2*) apply (drule_tac p=a in prec_frame[OF sngr_prec] (*‹⟦(?h::heap × nat set) ⊨ (?R1.0::assn) ∧⇩A (?R2.0::assn); ?R1.0 ⟹⇩A (?p::?'a1::heap ref) ↦⇩r (?x::?'a1::heap) * (?F1.0::assn); ?R2.0 ⟹⇩A ?p ↦⇩r (?y::?'a1::heap) * (?F2.0::assn)⟧ ⟹ ?x = ?y›*)) (*goals: 1. ‹⋀(a::'a btnode ref) (aa::'a array) (b::nat) (list::('a array × nat) list) (lista::'a btnode ref list) (fwd::'a btnode ref option) fwda::'a btnode ref option. ⟦(p::'a btnode ref option) = Some a; (l'::('a array × nat) list) = (aa, b) # list; (lptrs::'a btnode ref list) = a # lista⟧ ⟹ a ↦⇩r Btleaf (y::'a array × nat) fwda * leafs_assn (l::('a array × nat) list) lista fwda None * (F1::assn) ⟹⇩A a ↦⇩r (?x31::'a btnode ref ⇒ 'a array ⇒ nat ⇒ ('a array × nat) list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode) a aa b list lista fwd fwda * (?F1.31::'a btnode ref ⇒ 'a array ⇒ nat ⇒ ('a array × nat) list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ assn) a aa b list lista fwd fwda› 2. ‹⋀(a::'a btnode ref) (aa::'a array) (b::nat) (list::('a array × nat) list) (lista::'a btnode ref list) (fwd::'a btnode ref option) fwda::'a btnode ref option. ⟦(p::'a btnode ref option) = Some a; (l'::('a array × nat) list) = (aa, b) # list; (lptrs::'a btnode ref list) = a # lista⟧ ⟹ a ↦⇩r Btleaf (aa, b) fwd * leafs_assn list lista fwd None * (F2::assn) ⟹⇩A a ↦⇩r (?y31::'a btnode ref ⇒ 'a array ⇒ nat ⇒ ('a array × nat) list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode) a aa b list lista fwd fwda * (?F2.31::'a btnode ref ⇒ 'a array ⇒ nat ⇒ ('a array × nat) list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ assn) a aa b list lista fwd fwda› 3. ‹⋀(a::'a btnode ref) (aa::'a array) (b::nat) (list::('a array × nat) list) (lista::'a btnode ref list) (fwd::'a btnode ref option) fwda::'a btnode ref option. ⟦(p::'a btnode ref option) = Some a; (l'::('a array × nat) list) = (aa, b) # list; (lptrs::'a btnode ref list) = a # lista; (?x31::'a btnode ref ⇒ 'a array ⇒ nat ⇒ ('a array × nat) list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode) a aa b list lista fwd fwda = (?y31::'a btnode ref ⇒ 'a array ⇒ nat ⇒ ('a array × nat) list ⇒ 'a btnode ref list ⇒ 'a btnode ref option ⇒ 'a btnode ref option ⇒ 'a btnode) a aa b list lista fwd fwda⟧ ⟹ (y::'a array × nat) = (aa, b) ∧ fwd = fwda› discuss goal 1*) apply frame_inference (*discuss goal 2*) apply frame_inference (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . qed . declare mult.left_commute[simp del] interpretation leaf_node_it: imp_list_iterate "λx y. leafs_assn x lptrs y None" "λx y. leaf_iter_assn x lptrs y" leaf_iter_init leaf_iter_has_next leaf_iter_next apply unfold_locales (*goal: ‹imp_list_iterate (λx y. leafs_assn x lptrs y None) (λx. leaf_iter_assn x lptrs) leaf_iter_init leaf_iter_has_next leaf_iter_next›*) subgoal for by (simp add: leafs_assn_prec2 (*‹∀l l'. ?h ⊨ leafs_assn l ?lptrs ?p None * ?F1.0 ∧⇩A leafs_assn l' ?lptrs ?p None * ?F2.0 ⟶ l = l'›*) precise_def (*‹precise ?R ≡ ∀a a' h p F F'. h ⊨ ?R a p * F ∧⇩A ?R a' p * F' ⟶ a = a'›*)) subgoal for l and p by (sep_auto heap add: leaf_iter_init_rule) subgoal for l' and l and p and it thm leaf_iter_next_rule apply (cases l') (*goals: 1. ‹⟦l' ≠ []; l' = []⟧ ⟹ <leaf_iter_assn l lptrs p l' it> leaf_iter_next it <λr. case r of (a, it') ⇒ leaf_iter_assn l lptrs p (tl l') it' * ↑ (a = hd l')>⇩t› 2. ‹⋀a list. ⟦l' ≠ []; l' = a # list⟧ ⟹ <leaf_iter_assn l lptrs p l' it> leaf_iter_next it <λr. case r of (a, it') ⇒ leaf_iter_assn l lptrs p (tl l') it' * ↑ (a = hd l')>⇩t› discuss goal 1*) apply (cases it) (*top goal: ‹⟦l' ≠ []; l' = []⟧ ⟹ <leaf_iter_assn l lptrs p l' it> leaf_iter_next it <λr. case r of (a, it') ⇒ leaf_iter_assn l lptrs p (tl l') it' * ↑ (a = hd l')>⇩t› and 1 goal remains*) apply (sep_auto heap add: leaf_iter_next_rule) (*discuss goal 2*) apply (cases it) (*goal: ‹⋀a list. ⟦l' ≠ []; l' = a # list⟧ ⟹ <leaf_iter_assn l lptrs p l' it> leaf_iter_next it <λr. case r of (a, it') ⇒ leaf_iter_assn l lptrs p (tl l') it' * ↑ (a = hd l')>⇩t›*) apply (sep_auto heap add: leaf_iter_next_rule) (*proven 2 subgoals*) . subgoal for l and p and l' and it' thm leaf_iter_has_next_rule apply (cases it') (*goal: ‹<leaf_iter_assn l lptrs p l' it'> leaf_iter_has_next it' <λr. leaf_iter_assn l lptrs p l' it' * ↑ (r = (l' ≠ []))>⇩t›*) apply (rule hoare_triple_preI (*‹(⋀h::heap × nat set. h ⊨ (?P::assn) ⟹ <?P> ?c::?'a Heap <?Q::?'a ⇒ assn>) ⟹ <?P> ?c <?Q>›*)) (*goal: ‹⋀a b. it' = (a, b) ⟹ <leaf_iter_assn l lptrs p l' it'> leaf_iter_has_next it' <λr. leaf_iter_assn l lptrs p l' it' * ↑ (r = (l' ≠ []))>⇩t›*) by (sep_auto heap add: leaf_iter_has_next_rule) subgoal for l and p and l' and it unfolding leaf_iter_assn_def (*goal: ‹(case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (l = xs1 @ l') * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 p n * leafs_assn l' lptrs2 n z * ↑ (z = None)) ⟹⇩A leafs_assn l lptrs p None * true›*) apply (cases it) (*goal: ‹(case it::'a btnode ref option × 'a btnode ref option of (n::'a btnode ref option, z::'a btnode ref option) ⇒ ∃⇩A(xs1::('a array × nat) list) (lptrs1::'a btnode ref list) lptrs2::'a btnode ref list. ↑ ((l::('a array × nat) list) = xs1 @ (l'::('a array × nat) list)) * ↑ ((lptrs::'a btnode ref list) = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 (p::'a btnode ref option) n * leafs_assn l' lptrs2 n z * ↑ (z = None)) ⟹⇩A leafs_assn l lptrs p None * true›*) apply simp (*goal: ‹⋀a b. it = (a, b) ⟹ (case it of (n, z) ⇒ ∃⇩Axs1 lptrs1 lptrs2. ↑ (l = xs1 @ l') * ↑ (lptrs = lptrs1 @ lptrs2) * leafs_assn xs1 lptrs1 p n * leafs_assn l' lptrs2 n z * ↑ (z = None)) ⟹⇩A leafs_assn l lptrs p None * true›*) apply (intro ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹⋀(a::'a btnode ref option) b::'a btnode ref option. (it::'a btnode ref option × 'a btnode ref option) = (a, b) ⟹ ∃⇩A(xs1::('a array × nat) list) (lptrs1::'a btnode ref list) lptrs2::'a btnode ref list. leafs_assn xs1 lptrs1 (p::'a btnode ref option) a * leafs_assn (l'::('a array × nat) list) lptrs2 a b * ↑ ((l::('a array × nat) list) = xs1 @ l' ∧ (lptrs::'a btnode ref list) = lptrs1 @ lptrs2 ∧ b = None) ⟹⇩A leafs_assn l lptrs p None * true›*) apply (rule entails_preI (*‹(⋀h. h ⊨ ?P ⟹ ?P ⟹⇩A ?Q) ⟹ ?P ⟹⇩A ?Q›*)) (*goal: ‹⋀a b xs1 lptrs1 lptrs2. it = (a, b) ⟹ leafs_assn xs1 lptrs1 p a * leafs_assn l' lptrs2 a b * ↑ (l = xs1 @ l' ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None) ⟹⇩A leafs_assn l lptrs p None * true›*) apply (clarsimp dest!: mod_starD (*‹(?h::heap × nat set) ⊨ (?A::assn) * (?B::assn) ⟹ ∃(h1::heap × nat set) h2::heap × nat set. h1 ⊨ ?A ∧ h2 ⊨ ?B›*) leafs_assn_impl_length (*‹(?h::heap × nat set) ⊨ leafs_assn (?xs::(?'a array × nat) list) (?lptrs::?'a btnode ref list) (?r::?'a btnode ref option) (?z::?'a btnode ref option) ⟹ length ?xs = length ?lptrs›*)) (*goal: ‹⋀(a::'a::heap btnode ref option) (b::'a::heap btnode ref option) (xs1::('a::heap array × nat) list) (lptrs1::'a::heap btnode ref list) (lptrs2::'a::heap btnode ref list) h::heap × nat set. ⟦(it::'a::heap btnode ref option × 'a::heap btnode ref option) = (a, b); h ⊨ leafs_assn xs1 lptrs1 (p::'a::heap btnode ref option) a * leafs_assn (l'::('a::heap array × nat) list) lptrs2 a b * ↑ ((l::('a::heap array × nat) list) = xs1 @ l' ∧ (lptrs::'a::heap btnode ref list) = lptrs1 @ lptrs2 ∧ b = None)⟧ ⟹ leafs_assn xs1 lptrs1 p a * leafs_assn l' lptrs2 a b * ↑ (l = xs1 @ l' ∧ lptrs = lptrs1 @ lptrs2 ∧ b = None) ⟹⇩A leafs_assn l lptrs p None * true›*) by (sep_auto simp add: leafs_assn_aux_append) . global_interpretation leaf_values_iter: flatten_iter "λx y. leafs_assn x lptrs y None" "λx y. leaf_iter_assn x lptrs y" leaf_iter_init leaf_iter_has_next leaf_iter_next "is_pfa (2*k)" "pfa_is_it (2*k)" pfa_it_init pfa_it_has_next pfa_it_next defines leaf_values_adjust = leaf_values_iter.flatten_it_adjust and leaf_values_init = leaf_values_iter.flatten_it_init and leaf_values_next = leaf_values_iter.flatten_it_next and leaf_values_has_next = leaf_values_iter.flatten_it_has_next by unfold_locales thm leaf_values_iter.is_flatten_list.simps thm leaf_values_iter.is_flatten_it.simps thm leaf_values_init_def thm leaf_values_iter.flatten_it_init_def print_theorems fun bplustree_iter_init :: "('a::heap) btnode ref ⇒ _" where "bplustree_iter_init ti = do { rz ← tree_leaf_iter_init (Some ti); it ← leaf_values_init (fst rz); return it }" lemma leaf_nodes_imp_flatten_list: "leaf_nodes_assn k ts r None lptrs ⟹⇩A list_assn leaf_node ts (map leaves ts) * leaf_values_iter.is_flatten_list lptrs k (map leaves ts) (concat (map leaves ts)) r" apply (simp add: leaf_nodes_assn_flatten (*‹leaf_nodes_assn ?k ?ts ?r ?z ?lptrs = (∃⇩Aps. list_assn leaf_node ?ts (map leaves ?ts) * list_assn (is_pfa (2 * ?k)) (map leaves ?ts) ps * leafs_assn ps ?lptrs ?r ?z)›*)) (*goal: ‹leaf_nodes_assn k ts r None lptrs ⟹⇩A list_assn leaf_node ts (map leaves ts) * leaf_values_iter.is_flatten_list lptrs k (map leaves ts) (concat (map leaves ts)) r›*) apply (intro ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r None ⟹⇩A ∃⇩Alsi'. list_assn leaf_node ts (map leaves ts) * (leafs_assn lsi' lptrs r None * list_assn (is_pfa (2 * k)) (map leaves ts) lsi')›*) subgoal for ps apply (inst_ex_assn ps "map leaves ts") (*goal: ‹list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r None ⟹⇩A ∃⇩Alsi'. list_assn leaf_node ts (map leaves ts) * (leafs_assn lsi' lptrs r None * list_assn (is_pfa (2 * k)) (map leaves ts) lsi')›*) by sep_auto . lemma leaf_nodes_imp_flatten_list_back: "list_assn leaf_node ts (map leaves ts) * leaf_values_iter.is_flatten_list lptrs k (map leaves ts) (concat (map leaves ts)) r ⟹⇩A leaf_nodes_assn k ts r None lptrs" apply (simp add: leaf_nodes_assn_flatten (*‹leaf_nodes_assn ?k ?ts ?r ?z ?lptrs = (∃⇩Aps. list_assn leaf_node ?ts (map leaves ?ts) * list_assn (is_pfa (2 * ?k)) (map leaves ?ts) ps * leafs_assn ps ?lptrs ?r ?z)›*)) (*goal: ‹list_assn leaf_node ts (map leaves ts) * leaf_values_iter.is_flatten_list lptrs k (map leaves ts) (concat (map leaves ts)) r ⟹⇩A leaf_nodes_assn k ts r None lptrs›*) apply (intro ent_ex_preI (*‹(⋀x::?'a::type. (?P::?'a::type ⇒ assn) x ⟹⇩A (?Q::assn)) ⟹ ∃⇩Ax::?'a::type. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Alsi'. list_assn leaf_node ts (map leaves ts) * (leafs_assn lsi' lptrs r None * list_assn (is_pfa (2 * k)) (map leaves ts) lsi') ⟹⇩A ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r None›*) subgoal for ps apply (inst_ex_assn ps "map leaves ts") (*goal: ‹list_assn leaf_node ts (map leaves ts) * (leafs_assn ps lptrs r None * list_assn (is_pfa (2 * k)) (map leaves ts) ps) ⟹⇩A ∃⇩Aps. list_assn leaf_node ts (map leaves ts) * list_assn (is_pfa (2 * k)) (map leaves ts) ps * leafs_assn ps lptrs r None›*) by sep_auto . lemma leaf_nodes_flatten_list: "leaf_nodes_assn k ts r None lptrs = list_assn leaf_node ts (map leaves ts) * leaf_values_iter.is_flatten_list lptrs k (map leaves ts) (concat (map leaves ts)) r" apply (intro ent_iffI (*‹⟦?A ⟹⇩A ?B; ?B ⟹⇩A ?A⟧ ⟹ ?A = ?B›*)) (*goal: ‹leaf_nodes_assn (k::nat) (ts::'a bplustree list) (r::'a btnode ref option) None (lptrs::'a btnode ref list) = list_assn leaf_node ts (map leaves ts) * leaf_values_iter.is_flatten_list lptrs k (map leaves ts) (concat (map leaves ts)) r›*) subgoal for by (rule leaf_nodes_imp_flatten_list (*‹leaf_nodes_assn ?k ?ts ?r None ?lptrs ⟹⇩A list_assn leaf_node ?ts (map leaves ?ts) * leaf_values_iter.is_flatten_list ?lptrs ?k (map leaves ?ts) (concat (map leaves ?ts)) ?r›*)) subgoal for by (rule leaf_nodes_imp_flatten_list_back (*‹list_assn leaf_node ?ts (map leaves ?ts) * leaf_values_iter.is_flatten_list ?lptrs ?k (map leaves ?ts) (concat (map leaves ?ts)) ?r ⟹⇩A leaf_nodes_assn ?k ?ts ?r None ?lptrs›*)) . definition "bplustree_iter_list k t ti r = (∃⇩A lptrs. leaf_values_iter.is_flatten_list lptrs k (map leaves (leaf_nodes t)) (leaves t) r * list_assn leaf_node (leaf_nodes t) (map leaves (leaf_nodes t)) * trunk_assn k t ti r None lptrs)" lemma bplustree_iff_leaf_view: "bplustree_assn k t ti r None = bplustree_iter_list k t ti r" unfolding bplustree_iter_list_def (*goal: ‹bplustree_assn k t ti r None = (∃⇩Alptrs. leaf_values_iter.is_flatten_list lptrs k (leaf_lists t) (leaves t) r * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs)›*) apply (simp add: bplustree_extract_leafs (*‹bplustree_assn ?k ?t ?ti ?r ?z = (∃⇩Aleafptrs. bplustree_assn_leafs ?k ?t ?ti ?r ?z leafptrs)›*) bplustree_leaf_nodes_sep (*‹bplustree_assn_leafs ?k ?t ?ti ?r ?z ?lptrs = leaf_nodes_assn ?k (leaf_nodes ?t) ?r ?z ?lptrs * trunk_assn ?k ?t ?ti ?r ?z ?lptrs›*) leaf_nodes_flatten_list (*‹leaf_nodes_assn ?k ?ts ?r None ?lptrs = list_assn leaf_node ?ts (map leaves ?ts) * leaf_values_iter.is_flatten_list ?lptrs ?k (map leaves ?ts) (concat (map leaves ?ts)) ?r›*) concat_leaf_nodes_leaves (*‹concat (leaf_lists ?t) = leaves ?t›*)) (*goal: ‹bplustree_assn k t ti r None = (∃⇩Alptrs. leaf_values_iter.is_flatten_list lptrs k (leaf_lists t) (leaves t) r * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs)›*) by (auto simp add: algebra_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 11 facts*)) definition "bplustree_iter k t ti r vs it = (∃⇩A fringe. leaf_values_iter.is_flatten_it fringe k (map leaves (leaf_nodes t)) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (map leaves (leaf_nodes t)) * trunk_assn k t ti r None fringe)" (* Now finally, we can hide away that we extracted anything and just provide the user with some pretty definitions *) lemma bplustree_iter_init_rule: assumes "k > 0" "root_order k t" shows "<bplustree_assn k t ti r None> bplustree_iter_init ti <λit. bplustree_iter k t ti r (leaves t) it>⇩t" unfolding bplustree_iter_init.simps (*goal: ‹<bplustree_assn (k::nat) (t::'a bplustree) (ti::'a btnode ref) (r::'a btnode ref option) None> tree_leaf_iter_init (Some ti) ⤜ (λrz::'a btnode ref option × 'a btnode ref option. leaf_values_init (fst rz) ⤜ return) <bplustree_iter k t ti r (leaves t)>⇩t›*) unfolding bplustree_iter_def (*goal: ‹<bplustree_assn k t ti r None> tree_leaf_iter_init (Some ti) ⤜ (λrz. leaf_values_init (fst rz) ⤜ return) <λra. ∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r (leaves t) ra * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe>⇩t›*) using assms (*‹0 < k› ‹root_order k t›*) apply (sep_auto heap add: tree_leaf_iter_init_rule) (*goal: ‹<bplustree_assn k t ti r None> tree_leaf_iter_init (Some ti) ⤜ (λrz. leaf_values_init (fst rz) ⤜ return) <λra. ∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r (leaves t) ra * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe>⇩t›*) apply (subst leaf_nodes_flatten_list (*‹leaf_nodes_assn (?k::nat) (?ts::?'a bplustree list) (?r::?'a btnode ref option) None (?lptrs::?'a btnode ref list) = list_assn leaf_node ?ts (map leaves ?ts) * leaf_values_iter.is_flatten_list ?lptrs ?k (map leaves ?ts) (concat (map leaves ?ts)) ?r›*)) (*goal: ‹⋀lptrs. ⟦0 < k; root_order k t⟧ ⟹ <leaf_nodes_assn k (leaf_nodes t) r None lptrs * trunk_assn k t ti r None lptrs * true> leaf_values_init r <λra. ∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r (leaves t) ra * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe * true>›*) apply (vcg heap add: leaf_values_iter.flatten_it_init_rule) (*goal: ‹⋀lptrs. ⟦0 < k; root_order k t⟧ ⟹ <list_assn leaf_node (leaf_nodes t) (leaf_lists t) * leaf_values_iter.is_flatten_list lptrs k (leaf_lists t) (concat (leaf_lists t)) r * trunk_assn k t ti r None lptrs * true> leaf_values_init r <λra. ∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r (leaves t) ra * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe * true>›*) subgoal for lptrs apply (inst_ex_assn lptrs) (*goal: ‹⟦(0::nat) < (k::nat); root_order k (t::'a bplustree)⟧ ⟹ leaf_values_iter.is_flatten_it (lptrs::'a btnode ref list) k (leaf_lists t) (concat (leaf_lists t)) (r::'a btnode ref option) (concat (leaf_lists t)) (x_::('a btnode ref option × 'a btnode ref option) × (('a array × nat) × nat) option) * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t (ti::'a btnode ref) r None lptrs * true ⟹⇩A ∃⇩Afringe::'a btnode ref list. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r (leaves t) x_ * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe * true›*) by (sep_auto simp add: concat_leaf_nodes_leaves) . (* using is_flatten_it we can now iterate through elements in the leafs *) abbreviation "bplustree_iter_next ≡ leaf_values_next" lemma bplustree_iter_next_rule: "vs ≠ [] ⟹ <bplustree_iter k t ti r vs it> bplustree_iter_next it <λ(a, it'). bplustree_iter k t ti r (tl vs) it' * ↑ (a = hd vs)>⇩t" unfolding bplustree_iter_def (*goal: ‹vs ≠ [] ⟹ <∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe> bplustree_iter_next it <λra. case ra of (a, it') ⇒ (∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r (tl vs) it' * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe) * ↑ (a = hd vs)>⇩t›*) by (sep_auto heap add: leaf_values_iter.flatten_it_next_rule) abbreviation "bplustree_iter_has_next ≡ leaf_values_has_next" lemma bplustree_iter_has_next_rule: " <bplustree_iter k t ti r vs it> bplustree_iter_has_next it <λr'. bplustree_iter k t ti r vs it * ↑ (r' = (vs ≠ []))>⇩t" unfolding bplustree_iter_def (*goal: ‹<∃⇩Afringe::'a btnode ref list. leaf_values_iter.is_flatten_it fringe (k::nat) (leaf_lists (t::'a bplustree)) (leaves t) (r::'a btnode ref option) (vs::'a list) (it::('a btnode ref option × 'a btnode ref option) × (('a array × nat) × nat) option) * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t (ti::'a btnode ref) r None fringe> bplustree_iter_has_next it <λra::bool. (∃⇩Afringe::'a btnode ref list. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe) * ↑ (ra = (vs ≠ []))>⇩t›*) by (sep_auto heap add: leaf_values_iter.flatten_it_has_next_rule) lemma bplustree_iter_quit: "bplustree_iter k t ti r vs it ⟹⇩A bplustree_assn k t ti r None * true" unfolding bplustree_iter_def (*goal: ‹∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe ⟹⇩A bplustree_assn k t ti r None * true›*) apply (rule ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Afringe. leaf_values_iter.is_flatten_it fringe k (leaf_lists t) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None fringe ⟹⇩A bplustree_assn k t ti r None * true›*) subgoal for lptrs apply (rule ent_frame_fwd[OF leaf_values_iter.flatten_quit_iteration, where F="list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs" ] (*‹⟦?Ps ⟹⇩A leaf_values_iter.is_flatten_it ?lptrs1 ?k1 ?lsi''1 ?l1 ?p1 ?l'1 ?it1 * (list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs); leaf_values_iter.is_flatten_list ?lptrs1 ?k1 ?lsi''1 ?l1 ?p1 * true * (list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs) ⟹⇩A ?Q⟧ ⟹ ?Ps ⟹⇩A ?Q›*)) (*goal: ‹leaf_values_iter.is_flatten_it lptrs k (leaf_lists t) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs ⟹⇩A bplustree_assn k t ti r None * true›*) apply solve_entails (*top goal: ‹leaf_values_iter.is_flatten_it lptrs k (leaf_lists t) (leaves t) r vs it * list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs ⟹⇩A leaf_values_iter.is_flatten_it ?lptrs1 ?k1 ?lsi''1 ?l1 ?p1 ?l'1 ?it1 * (list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs)› and 1 goal remains*) apply (simp add: bplustree_extract_leafs (*‹bplustree_assn ?k ?t ?ti ?r ?z = (∃⇩Aleafptrs. bplustree_assn_leafs ?k ?t ?ti ?r ?z leafptrs)›*) bplustree_leaf_nodes_sep (*‹bplustree_assn_leafs ?k ?t ?ti ?r ?z ?lptrs = leaf_nodes_assn ?k (leaf_nodes ?t) ?r ?z ?lptrs * trunk_assn ?k ?t ?ti ?r ?z ?lptrs›*) leaf_nodes_flatten_list (*‹leaf_nodes_assn ?k ?ts ?r None ?lptrs = list_assn leaf_node ?ts (map leaves ?ts) * leaf_values_iter.is_flatten_list ?lptrs ?k (map leaves ?ts) (concat (map leaves ?ts)) ?r›*) concat_leaf_nodes_leaves (*‹concat (leaf_lists ?t) = leaves ?t›*)) (*goal: ‹leaf_values_iter.is_flatten_list lptrs k (leaf_lists t) (leaves t) r * true * (list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs) ⟹⇩A bplustree_assn k t ti r None * true›*) apply (rule ent_ex_preI (*‹(⋀x. ?P x ⟹⇩A ?Q) ⟹ ∃⇩Ax. ?P x ⟹⇩A ?Q›*)) (*goal: ‹∃⇩Alsi'. leafs_assn lsi' lptrs r None * list_assn (is_pfa (2 * k)) (leaf_lists t) lsi' * (list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t ti r None lptrs) * true ⟹⇩A ∃⇩Aleafptrs lsi'. list_assn leaf_node (leaf_nodes t) (leaf_lists t) * (leafs_assn lsi' leafptrs r None * list_assn (is_pfa (2 * k)) (leaf_lists t) lsi') * trunk_assn k t ti r None leafptrs * true›*) subgoal for lsi' apply (inst_ex_assn lptrs lsi') (*goal: ‹leafs_assn (lsi'::('a array × nat) list) (lptrs::'a btnode ref list) (r::'a btnode ref option) None * list_assn (is_pfa ((2::nat) * (k::nat))) (leaf_lists (t::'a bplustree)) lsi' * (list_assn leaf_node (leaf_nodes t) (leaf_lists t) * trunk_assn k t (ti::'a btnode ref) r None lptrs) * true ⟹⇩A ∃⇩A(leafptrs::'a btnode ref list) lsi'::('a array × nat) list. list_assn leaf_node (leaf_nodes t) (leaf_lists t) * (leafs_assn lsi' leafptrs r None * list_assn (is_pfa ((2::nat) * k)) (leaf_lists t) lsi') * trunk_assn k t ti r None leafptrs * true›*) by sep_auto . . declare first_leaf.simps[code] declare last_leaf.simps[code] (* declare leaf_values_iter.flatten_it_adjust.simps[code] *) (* Code exports can be found with in ImpSplitCE *) end
{ "path": "afp-2025-02-12/thys/BTree/BPlusTree_Iter.thy", "repo": "afp-2025-02-12", "sha": "c178cf55139319e2a01a35b23918d29d90c16eb99f222a173dddd0394fd2f673" }
(* Author: Tobias Nipkow *) section ‹Weight-Balanced Trees Have Logarithmic Height, and More› theory Weight_Balanced_Trees_log imports Complex_Main "HOL-Library.Tree" begin (* FIXME add these to field_simps *) lemmas neq0_if = less_imp_neq dual_order.strict_implies_not_eq subsection ‹Logarithmic Height› text ‹The locale below is parameterized wrt to ‹Δ›. The original definition of weight-balanced trees \<^cite>‹"NievergeltR72" and "NievergeltR73"› uses ‹α›. The constants ‹α› and ‹Δ› are interdefinable. Below we start from ‹Δ› but derive ‹α›-versions of theorems as well.› locale WBT0 = fixes Δ :: real begin fun balanced1 :: "'a tree ⇒ 'a tree ⇒ bool" where "balanced1 t1 t2 = (size1 t1 ≤ Δ * size1 t2)" fun wbt :: "'a tree ⇒ bool" where "wbt Leaf = True" | "wbt (Node l _ r) = (balanced1 l r ∧ balanced1 r l ∧ wbt l ∧ wbt r)" end locale WBT1 = WBT0 + assumes Delta: "Δ ≥ 1" begin definition α :: real where "α = 1/(Δ+1)" lemma Delta_def: "Δ = 1/α - 1" unfolding "α_def" (*goal: ‹Δ = 1 / (1 / (Δ + 1)) - 1›*) by auto lemma shows alpha_pos: "0 < α" and alpha_ub: "α ≤ 1/2" unfolding "α_def" (*goals: 1. ‹(0::real) < (1::real) / ((Δ::real) + (1::real))› 2. ‹(1::real) / ((Δ::real) + (1::real)) ≤ (1::real) / (2::real)›*) using Delta (*‹(1::real) ≤ (Δ::real)›*) apply - (*goals: 1. ‹1 ≤ Δ ⟹ 0 < 1 / (Δ + 1)› 2. ‹1 ≤ Δ ⟹ 1 / (Δ + 1) ≤ 1 / 2› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma wbt_Node_alpha: "wbt (Node l x r) = ((let q = size1 l / (size1 l + size1 r) in α ≤ q ∧ q ≤ 1 - α) ∧ wbt l ∧ wbt r)" proof (-) (*goal: ‹wbt ⟨l::'a tree, x::'a, r::'a tree⟩ = ((let q::real = real (size1 l) / real (size1 l + size1 r) in α ≤ q ∧ q ≤ (1::real) - α) ∧ wbt l ∧ wbt r)›*) have "l > 0 ⟹ r > 0 ⟹ (1/(Δ+1) ≤ l/(l+r) ⟷ r/l ≤ Δ) ∧ (1/(Δ+1) ≤ r/(l+r) ⟷ l/r ≤ Δ) ∧ (l/(l+r) ≤ 1 - 1/(Δ+1) ⟷ l/r ≤ Δ) ∧ (r/(l+r) ≤ 1 - 1/(Δ+1) ⟷ r/l ≤ Δ)" for l and r using Delta (*‹1 ≤ Δ›*) by (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*) divide_le_eq (*‹(?b / ?c ≤ ?a) = (if 0 < ?c then ?b ≤ ?a * ?c else if ?c < 0 then ?a * ?c ≤ ?b else 0 ≤ ?a)›*)) thus "?thesis" (*goal: ‹wbt ⟨l, x, r⟩ = ((let q = real (size1 l) / real (size1 l + size1 r) in α ≤ q ∧ q ≤ 1 - α) ∧ wbt l ∧ wbt r)›*) using Delta (*‹1 ≤ Δ›*) by (auto simp: α_def (*‹α = 1 / (Δ + 1)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) pos_divide_le_eq (*‹0 < ?c ⟹ (?b / ?c ≤ ?a) = (?b ≤ ?a * ?c)›*) add_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*)) qed lemma height_size1_Delta: "wbt t ⟹ (1 + 1/Δ) ^ (height t) ≤ size1 t" proof (induction t) (*goals: 1. ‹wbt ⟨⟩ ⟹ (1 + 1 / Δ) ^ height ⟨⟩ ≤ real (size1 ⟨⟩)› 2. ‹⋀t1 x2 t2. ⟦wbt t1 ⟹ (1 + 1 / Δ) ^ height t1 ≤ real (size1 t1); wbt t2 ⟹ (1 + 1 / Δ) ^ height t2 ≤ real (size1 t2); wbt ⟨t1, x2, t2⟩⟧ ⟹ (1 + 1 / Δ) ^ height ⟨t1, x2, t2⟩ ≤ real (size1 ⟨t1, x2, t2⟩)›*) case Leaf (*‹wbt ⟨⟩›*) thus "?case" (*goal: ‹(1 + 1 / Δ) ^ height ⟨⟩ ≤ real (size1 ⟨⟩)›*) by simp next (*goal: ‹⋀t1 x2 t2. ⟦wbt t1 ⟹ (1 + 1 / Δ) ^ height t1 ≤ real (size1 t1); wbt t2 ⟹ (1 + 1 / Δ) ^ height t2 ≤ real (size1 t2); wbt ⟨t1, x2, t2⟩⟧ ⟹ (1 + 1 / Δ) ^ height ⟨t1, x2, t2⟩ ≤ real (size1 ⟨t1, x2, t2⟩)›*) case (Node l a r) (*‹wbt l ⟹ (1 + 1 / Δ) ^ height l ≤ real (size1 l)› ‹wbt r ⟹ (1 + 1 / Δ) ^ height r ≤ real (size1 r)› ‹wbt ⟨l::'a tree, a::'a, r::'a tree⟩›*) let ?t = "Node l a r" let ?s = "size1 ?t" let ?d = "1 + 1/Δ" from Node.prems(1) (*‹wbt ⟨l, a, r⟩›*) have 1: "size1 l * ?d ≤ ?s" and 2: "size1 r * ?d ≤ ?s" using Delta (*‹1 ≤ Δ›*) apply - (*goals: 1. ‹⟦wbt ⟨l, a, r⟩; 1 ≤ Δ⟧ ⟹ real (size1 l) * (1 + 1 / Δ) ≤ real (size1 ⟨l, a, r⟩)› 2. ‹⟦wbt ⟨l, a, r⟩; 1 ≤ Δ⟧ ⟹ real (size1 r) * (1 + 1 / Δ) ≤ real (size1 ⟨l, a, r⟩)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*) add_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) neq0_if (*‹?x < ?y ⟹ ?x ≠ ?y› ‹?b < ?a ⟹ ?a ≠ ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*) add_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) neq0_if (*‹?x < ?y ⟹ ?x ≠ ?y› ‹?b < ?a ⟹ ?a ≠ ?b›*))[1]) (*proven 2 subgoals*) . show "?case" (*goal: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) proof (cases "height l ≤ height r") (*goals: 1. ‹height l ≤ height r ⟹ (1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)› 2. ‹¬ height l ≤ height r ⟹ (1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) case True (*‹height l ≤ height r›*) hence "?d ^ (height ?t) = ?d ^ (height r) * ?d" by simp also (*calculation: ‹((1::real) + (1::real) / (Δ::real)) ^ height ⟨l::'a tree, a::'a, r::'a tree⟩ = ((1::real) + (1::real) / Δ) ^ height r * ((1::real) + (1::real) / Δ)›*) have "… ≤ size1 r * ?d" using Node.IH(2) (*‹wbt (r::'a tree) ⟹ ((1::real) + (1::real) / (Δ::real)) ^ height r ≤ real (size1 r)›*) Node.prems (*‹wbt ⟨l::'a tree, a::'a, r::'a tree⟩›*) Delta (*‹1 ≤ Δ›*) unfolding wbt.simps (*goal: ‹(1 + 1 / Δ) ^ height r * (1 + 1 / Δ) ≤ real (size1 r) * (1 + 1 / Δ)›*) by (smt (verit) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*)) also (*calculation: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 r) * (1 + 1 / Δ)›*) have "… ≤ ?s" using "2" (*‹real (size1 (r::'a tree)) * ((1::real) + (1::real) / (Δ::real)) ≤ real (size1 ⟨l::'a tree, a::'a, r⟩)›*) by simp finally (*calculation: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) show "?thesis" (*goal: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) . next (*goal: ‹¬ height l ≤ height r ⟹ (1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) case False (*‹¬ height l ≤ height r›*) hence "?d ^ (height ?t) = ?d ^ (height l) * ?d" by simp also (*calculation: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ = (1 + 1 / Δ) ^ height l * (1 + 1 / Δ)›*) have "… ≤ size1 l * ?d" using Node.IH(1) (*‹wbt l ⟹ (1 + 1 / Δ) ^ height l ≤ real (size1 l)›*) Node.prems (*‹wbt ⟨l, a, r⟩›*) Delta (*‹(1::real) ≤ (Δ::real)›*) unfolding wbt.simps (*goal: ‹(1 + 1 / Δ) ^ height l * (1 + 1 / Δ) ≤ real (size1 l) * (1 + 1 / Δ)›*) by (smt (verit) divide_nonneg_nonneg (*‹⟦0 ≤ ?x; 0 ≤ ?y⟧ ⟹ 0 ≤ ?x / ?y›*) mult_mono (*‹⟦?a ≤ ?b; ?c ≤ ?d; 0 ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?d›*) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*)) also (*calculation: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 l) * (1 + 1 / Δ)›*) have "… ≤ ?s" using "1" (*‹real (size1 (l::'a::type tree)) * ((1::real) + (1::real) / (Δ::real)) ≤ real (size1 ⟨l, a::'a::type, r::'a::type tree⟩)›*) by simp finally (*calculation: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) show "?thesis" (*goal: ‹(1 + 1 / Δ) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) . qed qed lemma height_size1_alpha: "wbt t ⟹ (1/(1-α)) ^ (height t) ≤ size1 t" proof (induction t) (*goals: 1. ‹wbt ⟨⟩ ⟹ (1 / (1 - α)) ^ height ⟨⟩ ≤ real (size1 ⟨⟩)› 2. ‹⋀t1 x2 t2. ⟦wbt t1 ⟹ (1 / (1 - α)) ^ height t1 ≤ real (size1 t1); wbt t2 ⟹ (1 / (1 - α)) ^ height t2 ≤ real (size1 t2); wbt ⟨t1, x2, t2⟩⟧ ⟹ (1 / (1 - α)) ^ height ⟨t1, x2, t2⟩ ≤ real (size1 ⟨t1, x2, t2⟩)›*) case Leaf (*‹wbt ⟨⟩›*) thus "?case" (*goal: ‹(1 / (1 - α)) ^ height ⟨⟩ ≤ real (size1 ⟨⟩)›*) by simp next (*goal: ‹⋀t1 x2 t2. ⟦wbt t1 ⟹ (1 / (1 - α)) ^ height t1 ≤ real (size1 t1); wbt t2 ⟹ (1 / (1 - α)) ^ height t2 ≤ real (size1 t2); wbt ⟨t1, x2, t2⟩⟧ ⟹ (1 / (1 - α)) ^ height ⟨t1, x2, t2⟩ ≤ real (size1 ⟨t1, x2, t2⟩)›*) note wbt.simps[simp del] (*‹wbt ⟨⟩ = True› ‹wbt ⟨?l, ?uu, ?r⟩ = (balanced1 ?l ?r ∧ balanced1 ?r ?l ∧ wbt ?l ∧ wbt ?r)›*) wbt_Node_alpha[simp] (*‹wbt ⟨?l, ?x, ?r⟩ = ((let q = real (size1 ?l) / real (size1 ?l + size1 ?r) in α ≤ q ∧ q ≤ 1 - α) ∧ wbt ?l ∧ wbt ?r)›*) case (Node l a r) (*‹wbt (l::'a tree) ⟹ ((1::real) / ((1::real) - α)) ^ height l ≤ real (size1 l)› ‹wbt r ⟹ (1 / (1 - α)) ^ height r ≤ real (size1 r)› ‹wbt ⟨l, a, r⟩›*) let ?t = "Node l a r" let ?s = "size1 ?t" from Node.prems(1) (*‹wbt ⟨l::'a tree, a::'a, r::'a tree⟩›*) have 1: "size1 l / (1-α) ≤ ?s" and 2: "size1 r / (1-α) ≤ ?s" using alpha_ub (*‹α ≤ (1::real) / (2::real)›*) apply - (*goals: 1. ‹⟦wbt ⟨l::'a::type tree, a::'a::type, r::'a::type tree⟩; α ≤ (1::real) / (2::real)⟧ ⟹ real (size1 l) / ((1::real) - α) ≤ real (size1 ⟨l, a, r⟩)› 2. ‹⟦wbt ⟨l::'a::type tree, a::'a::type, r::'a::type tree⟩; α ≤ (1::real) / (2::real)⟧ ⟹ real (size1 r) / ((1::real) - α) ≤ real (size1 ⟨l, a, r⟩)› discuss goal 1*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*) add_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) neq0_if (*‹?x < ?y ⟹ ?x ≠ ?y› ‹?b < ?a ⟹ ?a ≠ ?b›*))[1]) (*discuss goal 2*) apply ((auto simp: Let_def (*‹Let ?s ?f ≡ ?f ?s›*) field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 69 facts*) add_pos_pos (*‹⟦0 < ?a; 0 < ?b⟧ ⟹ 0 < ?a + ?b›*) neq0_if (*‹?x < ?y ⟹ ?x ≠ ?y› ‹?b < ?a ⟹ ?a ≠ ?b›*))[1]) (*proven 2 subgoals*) . show "?case" (*goal: ‹((1::real) / ((1::real) - α)) ^ height ⟨l::'a tree, a::'a, r::'a tree⟩ ≤ real (size1 ⟨l, a, r⟩)›*) proof (cases "height l ≤ height r") (*goals: 1. ‹height l ≤ height r ⟹ (1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)› 2. ‹¬ height l ≤ height r ⟹ (1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) case True (*‹height l ≤ height r›*) hence "(1/(1-α)) ^ (height ?t) = (1/(1-α)) ^ (height r) * (1/(1-α))" by simp also (*calculation: ‹(1 / (1 - α)) ^ height ⟨l, a, r⟩ = (1 / (1 - α)) ^ height r * (1 / (1 - α))›*) have "… ≤ size1 r * (1/(1-α))" using Node.IH(2) (*‹wbt r ⟹ (1 / (1 - α)) ^ height r ≤ real (size1 r)›*) Node.prems (*‹wbt ⟨l::'a tree, a::'a, r::'a tree⟩›*) unfolding wbt_Node_alpha (*goal: ‹(1 / (1 - α)) ^ height r * (1 / (1 - α)) ≤ real (size1 r) * (1 / (1 - α))›*) by (smt (verit) mult_right_mono (*‹⟦(?a::?'a) ≤ (?b::?'a); (0::?'a) ≤ (?c::?'a)⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) zero_le_divide_1_iff (*‹((0::?'a) ≤ (1::?'a) / (?a::?'a)) = ((0::?'a) ≤ ?a)›*)) also (*calculation: ‹(1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 r) * (1 / (1 - α))›*) have "… ≤ ?s" using "2" (*‹real (size1 r) / (1 - α) ≤ real (size1 ⟨l, a, r⟩)›*) by simp finally (*calculation: ‹(1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) show "?thesis" (*goal: ‹(1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) . next (*goal: ‹¬ height l ≤ height r ⟹ (1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) case False (*‹¬ height l ≤ height r›*) hence "(1/(1-α)) ^ (height ?t) = (1/(1-α)) ^ (height l) * (1/(1-α))" by simp also (*calculation: ‹(1 / (1 - α)) ^ height ⟨l, a, r⟩ = (1 / (1 - α)) ^ height l * (1 / (1 - α))›*) have "… ≤ size1 l * (1/(1-α))" using Node.IH(1) (*‹wbt (l::'a::type tree) ⟹ ((1::real) / ((1::real) - α)) ^ height l ≤ real (size1 l)›*) Node.prems (*‹wbt ⟨l, a, r⟩›*) unfolding wbt_Node_alpha (*goal: ‹((1::real) / ((1::real) - α)) ^ height (l::'a tree) * ((1::real) / ((1::real) - α)) ≤ real (size1 l) * ((1::real) / ((1::real) - α))›*) by (smt (verit) mult_right_mono (*‹⟦?a ≤ ?b; 0 ≤ ?c⟧ ⟹ ?a * ?c ≤ ?b * ?c›*) zero_le_divide_1_iff (*‹(0 ≤ 1 / ?a) = (0 ≤ ?a)›*)) also (*calculation: ‹((1::real) / ((1::real) - α)) ^ height ⟨l::'a tree, a::'a, r::'a tree⟩ ≤ real (size1 l) * ((1::real) / ((1::real) - α))›*) have "… ≤ ?s" using "1" (*‹real (size1 l) / (1 - α) ≤ real (size1 ⟨l, a, r⟩)›*) by simp finally (*calculation: ‹(1 / (1 - α)) ^ height ⟨l, a, r⟩ ≤ real (size1 ⟨l, a, r⟩)›*) show "?thesis" (*goal: ‹((1::real) / ((1::real) - α)) ^ height ⟨l::'a tree, a::'a, r::'a tree⟩ ≤ real (size1 ⟨l, a, r⟩)›*) . qed qed lemma height_size1_log_Delta: assumes "wbt t" shows "height t ≤ log 2 (size1 t) / log 2 (1 + 1/Δ)" proof (-) (*goal: ‹real (height t) ≤ log 2 (real (size1 t)) / log 2 (1 + 1 / Δ)›*) from height_size1_Delta[OF assms] (*‹(1 + 1 / Δ) ^ height t ≤ real (size1 t)›*) have "height t ≤ log (1 + 1/Δ) (size1 t)" using Delta (*‹1 ≤ Δ›*) le_log_of_power (*‹⟦?b ^ ?n ≤ ?m; 1 < ?b⟧ ⟹ real ?n ≤ log ?b ?m›*) by auto also (*calculation: ‹real (height t) ≤ log (1 + 1 / Δ) (real (size1 t))›*) have "… = log 2 (size1 t) / log 2 (1 + 1/Δ)" by (simp add: log_base_change (*‹⟦(0::real) < (?a::real); ?a ≠ (1::real)⟧ ⟹ log (?b::real) (?x::real) = log ?a ?x / log ?a ?b›*)) finally (*calculation: ‹real (height t) ≤ log 2 (real (size1 t)) / log 2 (1 + 1 / Δ)›*) show "?thesis" (*goal: ‹real (height t) ≤ log 2 (real (size1 t)) / log 2 (1 + 1 / Δ)›*) . qed lemma height_size1_log_alpha: assumes "wbt t" shows "height t ≤ log 2 (size1 t) / log 2 (1/(1-α))" proof (-) (*goal: ‹real (height t) ≤ log 2 (real (size1 t)) / log 2 (1 / (1 - α))›*) from height_size1_alpha[OF assms] (*‹((1::real) / ((1::real) - α)) ^ height (t::'a tree) ≤ real (size1 t)›*) have "height t ≤ log (1/(1-α)) (size1 t)" using alpha_pos (*‹(0::real) < α›*) alpha_ub (*‹α ≤ 1 / 2›*) le_log_of_power (*‹⟦?b ^ ?n ≤ ?m; 1 < ?b⟧ ⟹ real ?n ≤ log ?b ?m›*) by auto also (*calculation: ‹real (height t) ≤ log (1 / (1 - α)) (real (size1 t))›*) have "… = log 2 (size1 t) / log 2 (1/(1-α))" by (simp add: log_base_change (*‹⟦0 < ?a; ?a ≠ 1⟧ ⟹ log ?b ?x = log ?a ?x / log ?a ?b›*)) finally (*calculation: ‹real (height t) ≤ log 2 (real (size1 t)) / log 2 (1 / (1 - α))›*) show "?thesis" (*goal: ‹real (height t) ≤ log 2 (real (size1 t)) / log 2 (1 / (1 - α))›*) . qed end subsection ‹Every ‹1 ≤ Δ < 2› Yields Exactly the Complete Trees› declare WBT0.wbt.simps [simp] WBT0.balanced1.simps [simp] lemma wbt1_if_complete: assumes "1 ≤ Δ" shows "complete t ⟹ WBT0.wbt Δ t" apply (induction t) (*goals: 1. ‹Tree.complete ⟨⟩ ⟹ WBT0.wbt Δ ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦Tree.complete t1 ⟹ WBT0.wbt Δ t1; Tree.complete t2 ⟹ WBT0.wbt Δ t2; Tree.complete ⟨t1, x2, t2⟩⟧ ⟹ WBT0.wbt Δ ⟨t1, x2, t2⟩› discuss goal 1*) apply simp (*discuss goal 2*) apply (simp add: assms (*‹1 ≤ Δ›*) size1_if_complete (*‹Tree.complete ?t ⟹ size1 ?t = 2 ^ height ?t›*)) (*proven 2 subgoals*) . lemma complete_if_wbt2: assumes "Δ < 2" shows "WBT0.wbt Δ t ⟹ complete t" proof (induction t) (*goals: 1. ‹WBT0.wbt Δ ⟨⟩ ⟹ Tree.complete ⟨⟩› 2. ‹⋀t1 x2 t2. ⟦WBT0.wbt Δ t1 ⟹ Tree.complete t1; WBT0.wbt Δ t2 ⟹ Tree.complete t2; WBT0.wbt Δ ⟨t1, x2, t2⟩⟧ ⟹ Tree.complete ⟨t1, x2, t2⟩›*) case Leaf (*‹WBT0.wbt Δ ⟨⟩›*) then show "?case" (*goal: ‹Tree.complete ⟨⟩›*) by simp next (*goal: ‹⋀t1 x2 t2. ⟦WBT0.wbt Δ t1 ⟹ Tree.complete t1; WBT0.wbt Δ t2 ⟹ Tree.complete t2; WBT0.wbt Δ ⟨t1, x2, t2⟩⟧ ⟹ Tree.complete ⟨t1, x2, t2⟩›*) case (Node t1 x t2) (*‹WBT0.wbt Δ t1 ⟹ Tree.complete t1› ‹WBT0.wbt Δ t2 ⟹ Tree.complete t2› ‹WBT0.wbt Δ ⟨t1, x, t2⟩›*) let ?h1 = "height t1" let ?h2 = "height t2" from Node (*‹WBT0.wbt Δ t1 ⟹ Tree.complete t1› ‹WBT0.wbt Δ t2 ⟹ Tree.complete t2› ‹WBT0.wbt (Δ::real) ⟨t1::'a tree, x::'a, t2::'a tree⟩›*) have "*": "complete t1 ∧ complete t2" by auto hence sz: "size1 t1 = 2 ^ ?h1 ∧ size1 t2 = 2 ^ ?h2" using size1_if_complete (*‹Tree.complete (?t::?'a tree) ⟹ size1 ?t = (2::nat) ^ height ?t›*) by blast show "?case" (*goal: ‹Tree.complete ⟨t1, x, t2⟩›*) proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹¬ Tree.complete ⟨t1, x, t2⟩ ⟹ False›*) assume "¬ complete ⟨t1, x, t2⟩" (*‹¬ Tree.complete ⟨t1::'a tree, x::'a, t2::'a tree⟩›*) hence "?h1 ≠ ?h2" using "*" (*‹Tree.complete (t1::'a tree) ∧ Tree.complete (t2::'a tree)›*) by auto thus False proof (cases "?h1 < ?h2") (*goals: 1. ‹⟦height t1 ≠ height t2; height t1 < height t2⟧ ⟹ False› 2. ‹⟦height t1 ≠ height t2; ¬ height t1 < height t2⟧ ⟹ False›*) case True (*‹height t1 < height t2›*) hence "2 * (2::real) ^ ?h1 ≤ 2 ^ ?h2" by (metis Suc_leI (*‹?m < ?n ⟹ Suc ?m ≤ ?n›*) one_le_numeral (*‹1 ≤ numeral ?n›*) power_Suc (*‹?a ^ Suc ?n = ?a * ?a ^ ?n›*) power_increasing (*‹⟦?n ≤ ?N; 1 ≤ ?a⟧ ⟹ ?a ^ ?n ≤ ?a ^ ?N›*)) also (*calculation: ‹(2::real) * (2::real) ^ height (t1::'a::type tree) ≤ (2::real) ^ height (t2::'a::type tree)›*) have "… ≤ Δ * 2 ^ ?h1" using sz (*‹size1 t1 = 2 ^ height t1 ∧ size1 t2 = 2 ^ height t2›*) Node.prems (*‹WBT0.wbt Δ ⟨t1, x, t2⟩›*) by simp finally (*calculation: ‹2 * 2 ^ height t1 ≤ Δ * 2 ^ height t1›*) show False using ‹Δ < 2› (*‹Δ < 2›*) by simp next (*goal: ‹⟦height (t1::'a::type tree) ≠ height (t2::'a::type tree); ¬ height t1 < height t2⟧ ⟹ False›*) case False (*‹¬ height t1 < height t2›*) with ‹?h1 ≠ ?h2› (*‹height t1 ≠ height t2›*) have "?h2 < ?h1" by linarith hence "2 * (2::real) ^ ?h2 ≤ 2 ^ ?h1" by (metis Suc_leI (*‹(?m::nat) < (?n::nat) ⟹ Suc ?m ≤ ?n›*) one_le_numeral (*‹(1::?'a::linordered_nonzero_semiring) ≤ numeral (?n::num)›*) power_Suc (*‹(?a::?'a::power) ^ Suc (?n::nat) = ?a * ?a ^ ?n›*) power_increasing (*‹⟦(?n::nat) ≤ (?N::nat); (1::?'a::linordered_semidom) ≤ (?a::?'a::linordered_semidom)⟧ ⟹ ?a ^ ?n ≤ ?a ^ ?N›*)) also (*calculation: ‹2 * 2 ^ height t2 ≤ 2 ^ height t1›*) have "… ≤ Δ * 2 ^ ?h2" using sz (*‹size1 (t1::'a tree) = (2::nat) ^ height t1 ∧ size1 (t2::'a tree) = (2::nat) ^ height t2›*) Node.prems (*‹WBT0.wbt Δ ⟨t1, x, t2⟩›*) by simp finally (*calculation: ‹2 * 2 ^ height t2 ≤ Δ * 2 ^ height t2›*) show False using ‹Δ < 2› (*‹Δ < 2›*) by simp qed qed qed end
{ "path": "afp-2025-02-12/thys/Weight_Balanced_Trees/Weight_Balanced_Trees_log.thy", "repo": "afp-2025-02-12", "sha": "efa0c43ed6462854a13efcfda9df8b14d60ab519d8909020c0617f6c61bfac8e" }
theory Simplicial_complex imports Boolean_functions begin section‹Simplicial Complexes› lemma Pow_singleton: "Pow {a} = {{},{a}}" by auto lemma Pow_pair: "Pow {a,b} = {{},{a},{b},{a,b}}" by auto locale simplicial_complex = fixes n::"nat" begin text‹A simplex (in $n$ vertexes) is any set of vertexes, including the empty set.› definition simplices :: "nat set set" where "simplices = Pow {0..<n}" lemma "{} ∈ simplices" unfolding simplices_def (*goal: ‹{} ∈ Pow {0::nat..<n::nat}›*) by simp lemma "{0..<n} ∈ simplices" unfolding simplices_def (*goal: ‹{0::nat..<n::nat} ∈ Pow {0::nat..<n}›*) by simp lemma finite_simplex: assumes "σ ∈ simplices" shows "finite σ" by (metis Pow_iff (*‹(?A ∈ Pow ?B) = (?A ⊆ ?B)›*) assms (*‹σ ∈ simplices›*) finite_atLeastLessThan (*‹finite {?l..<?u}›*) finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) simplices_def (*‹simplices = Pow {0..<n}›*)) text‹A simplicial complex (in $n$ vertexes) is a collection of sets of vertexes such that every subset of a set of vertexes also belongs to the simplicial complex.› definition simplicial_complex :: "nat set set => bool" where "simplicial_complex K ≡ (∀σ∈K. (σ ∈ simplices) ∧ (Pow σ) ⊆ K)" lemma finite_simplicial_complex: assumes "simplicial_complex K" shows "finite K" by (metis assms (*‹simplicial_complex (K::nat set set)›*) finite_Pow_iff (*‹finite (Pow (?A::?'a set)) = finite ?A›*) finite_atLeastLessThan (*‹finite {?l::nat..<?u::nat}›*) rev_finite_subset (*‹⟦finite (?B::?'a set); (?A::?'a set) ⊆ ?B⟧ ⟹ finite ?A›*) simplices_def (*‹simplices = Pow {0::nat..<n::nat}›*) simplicial_complex_def (*‹simplicial_complex (?K::nat set set) ≡ ∀σ::nat set∈?K. σ ∈ simplices ∧ Pow σ ⊆ ?K›*) subsetI (*‹(⋀x::?'a. x ∈ (?A::?'a set) ⟹ x ∈ (?B::?'a set)) ⟹ ?A ⊆ ?B›*)) lemma finite_simplices: assumes "simplicial_complex K" and "v ∈ K" shows "finite v" using assms (*‹simplicial_complex (K::nat set set)› ‹(v::nat set) ∈ (K::nat set set)›*) finite_simplex (*‹?σ ∈ simplices ⟹ finite ?σ›*) simplicial_complex.simplicial_complex_def (*‹simplicial_complex.simplicial_complex ?n ?K ≡ ∀σ∈?K. σ ∈ simplicial_complex.simplices ?n ∧ Pow σ ⊆ ?K›*) by blast definition simplicial_complex_set :: "nat set set set" where "simplicial_complex_set = (Collect simplicial_complex)" lemma simplicial_complex_empty_set: fixes K::"nat set set" assumes k: "simplicial_complex K" shows "K = {} ∨ {} ∈ K" using k (*‹simplicial_complex (K::nat set set)›*) unfolding simplicial_complex_def Pow_def (*goal: ‹K = {} ∨ {} ∈ K›*) by auto lemma simplicial_complex_monotone: fixes K::"nat set set" assumes k: "simplicial_complex K" and s: "s ∈ K" and rs: "r ⊆ s" shows "r ∈ K" using k (*‹simplicial_complex K›*) rs (*‹r ⊆ s›*) s (*‹(s::nat set) ∈ (K::nat set set)›*) unfolding simplicial_complex_def Pow_def (*goal: ‹r ∈ K›*) by auto text‹One example of simplicial complex with four simplices.› lemma assumes three: "(3::nat) < n" shows "simplicial_complex {{},{0},{1},{2},{3}}" apply (simp_all add: Pow_singleton simplicial_complex_def simplices_def) (*goal: ‹simplicial_complex {{}, {0}, {1}, {2}, {3}}›*) using Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) three (*‹3 < n›*) by presburger lemma "¬ simplicial_complex {{0,1},{1}}" by (simp add: Pow_pair (*‹Pow {?a, ?b} = {{}, {?a}, {?b}, {?a, ?b}}›*) simplicial_complex_def (*‹simplicial_complex ?K ≡ ∀σ∈?K. σ ∈ simplices ∧ Pow σ ⊆ ?K›*)) text‹Another example of simplicial complex with five simplices.› lemma assumes three: "(3::nat) < n" shows "simplicial_complex {{},{0},{1},{2},{3},{0,1}}" apply (simp add: Pow_pair (*‹Pow {?a, ?b} = {{}, {?a}, {?b}, {?a, ?b}}›*) Pow_singleton (*‹Pow {?a} = {{}, {?a}}›*) simplicial_complex_def (*‹simplicial_complex ?K ≡ ∀σ∈?K. σ ∈ simplices ∧ Pow σ ⊆ ?K›*) simplices_def (*‹simplices = Pow {0..<n}›*)) (*goal: ‹simplicial_complex {{}, {0}, {1}, {2}, {3}, {0, 1}}›*) using Suc_lessD (*‹Suc (?m::nat) < (?n::nat) ⟹ ?m < ?n›*) three (*‹3 < n›*) by presburger text‹Another example of simplicial complex with ten simplices.› lemma assumes three: "(3::nat) < n" shows "simplicial_complex {{2,3},{1,3},{1,2},{0,3},{0,2},{3},{2},{1},{0},{}}" apply (simp add: Pow_pair (*‹Pow {?a::?'a::type, ?b::?'a::type} = {{}, {?a}, {?b}, {?a, ?b}}›*) Pow_singleton (*‹Pow {?a::?'a::type} = {{}, {?a}}›*) simplicial_complex_def (*‹simplicial_complex (?K::nat set set) ≡ ∀σ::nat set∈?K. σ ∈ simplices ∧ Pow σ ⊆ ?K›*) simplices_def (*‹simplices = Pow {0::nat..<n::nat}›*)) (*goal: ‹simplicial_complex {{2, 3}, {1, 3}, {1, 2}, {0, 3}, {0, 2}, {3}, {2}, {1}, {0}, {}}›*) using Suc_lessD (*‹Suc ?m < ?n ⟹ ?m < ?n›*) three (*‹3 < n›*) by presburger end section‹Simplicial complex induced by a monotone Boolean function› text‹In this section we introduce the definition of the simplicial complex induced by a monotone Boolean function, following the definition in Scoville~\<^cite>‹‹Def. 6.9› in "SC19"›.› text‹First we introduce the set of tuples for which a Boolean function is @{term False}.› definition ceros_of_boolean_input :: "bool vec => nat set" where "ceros_of_boolean_input v = {x. x < dim_vec v ∧ vec_index v x = False}" lemma ceros_of_boolean_input_l_dim: assumes a: "a ∈ ceros_of_boolean_input v" shows "a < dim_vec v" using a (*‹a ∈ ceros_of_boolean_input v›*) unfolding ceros_of_boolean_input_def (*goal: ‹a < dim_vec v›*) by simp lemma "ceros_of_boolean_input v = {x. x < dim_vec v ∧ ¬ vec_index v x}" unfolding ceros_of_boolean_input_def (*goal: ‹{x. x < dim_vec v ∧ v $ x = False} = {x. x < dim_vec v ∧ ¬ v $ x}›*) by simp lemma ceros_of_boolean_input_complementary: shows "ceros_of_boolean_input v = {x. x < dim_vec v} - {x. vec_index v x}" unfolding ceros_of_boolean_input_def (*goal: ‹{x. x < dim_vec v ∧ v $ x = False} = {x. x < dim_vec v} - {x. v $ x}›*) by auto (*lemma ceros_in_UNIV: "ceros_of_boolean_input f ⊆ (UNIV::nat set)" using subset_UNIV .*) lemma monotone_ceros_of_boolean_input: fixes r and s::"bool vec" assumes r_le_s: "r ≤ s" shows "ceros_of_boolean_input s ⊆ ceros_of_boolean_input r" proof (intro subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*), unfold ceros_of_boolean_input_def (*‹ceros_of_boolean_input ?v = {x. x < dim_vec ?v ∧ ?v $ x = False}›*), intro CollectI (*‹(?P::?'a::type ⇒ bool) (?a::?'a::type) ⟹ ?a ∈ {x::?'a::type. ?P x}›*), rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀x. x ∈ {x. x < dim_vec s ∧ s $ x = False} ⟹ x < dim_vec r› 2. ‹⋀x. x ∈ {x. x < dim_vec s ∧ s $ x = False} ⟹ r $ x = False›*) fix x assume "x ∈ {x. x < dim_vec s ∧ vec_index s x = False}" (*‹(x::nat) ∈ {x::nat. x < dim_vec (s::bool vec) ∧ s $ x = False}›*) hence xl: "x < dim_vec s" and nr: "vec_index s x = False" apply - (*goals: 1. ‹x ∈ {x. x < dim_vec s ∧ s $ x = False} ⟹ x < dim_vec s› 2. ‹x ∈ {x. x < dim_vec s ∧ s $ x = False} ⟹ s $ x = False› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . show "vec_index r x = False" using r_le_s (*‹r ≤ s›*) nr (*‹s $ x = False›*) xl (*‹x < dim_vec s›*) unfolding less_eq_vec_def (*goal: ‹r $ x = False›*) by auto show "x < dim_vec r" using r_le_s (*‹r ≤ s›*) xl (*‹x < dim_vec s›*) unfolding less_eq_vec_def (*goal: ‹x < dim_vec r›*) by auto qed text‹We introduce here instantiations of the typ‹bool› type for the type classes class‹zero› and class‹one› that will simplify notation at some points:› instantiation bool :: "{zero,one}" begin definition zero_bool_def: "0 == False" definition one_bool_def: "1 == True" instance proof qed end text‹Definition of the simplicial complex induced by a Boolean function ‹f› in dimension ‹n›.› definition simplicial_complex_induced_by_monotone_boolean_function :: "nat => (bool vec => bool) => nat set set" where "simplicial_complex_induced_by_monotone_boolean_function n f = {y. ∃x. dim_vec x = n ∧ f x ∧ ceros_of_boolean_input x = y}" text‹The simplicial complex induced by a Boolean function is a subset of the powerset of the set of vertexes.› lemma simplicial_complex_induced_by_monotone_boolean_function_subset: "simplicial_complex_induced_by_monotone_boolean_function n (v::bool vec => bool) ⊆ Pow (({0..n}::nat set))" using ceros_of_boolean_input_def (*‹ceros_of_boolean_input ?v = {x. x < dim_vec ?v ∧ ?v $ x = False}›*) simplicial_complex_induced_by_monotone_boolean_function_def (*‹simplicial_complex_induced_by_monotone_boolean_function ?n ?f = {y. ∃x. dim_vec x = ?n ∧ ?f x ∧ ceros_of_boolean_input x = y}›*) by force corollary "simplicial_complex_induced_by_monotone_boolean_function n (v::bool vec => bool) ⊆ Pow ((UNIV::nat set))" by simp text‹The simplicial complex induced by a monotone Boolean function is a simplicial complex. This result is proven in Scoville as part of the proof of Proposition 6.16~\<^cite>‹‹Prop. 6.16› in "SC19"›.› context simplicial_complex begin lemma monotone_bool_fun_induces_simplicial_complex: assumes mon: "boolean_functions.monotone_bool_fun n f" shows "simplicial_complex (simplicial_complex_induced_by_monotone_boolean_function n f)" unfolding simplicial_complex_def (*goal: ‹∀σ∈simplicial_complex_induced_by_monotone_boolean_function n f. σ ∈ simplices ∧ Pow σ ⊆ simplicial_complex_induced_by_monotone_boolean_function n f›*) proof (rule, unfold simplicial_complex_induced_by_monotone_boolean_function_def (*‹simplicial_complex_induced_by_monotone_boolean_function ?n ?f = {y. ∃x. dim_vec x = ?n ∧ ?f x ∧ ceros_of_boolean_input x = y}›*), safe) (*goals: 1. ‹⋀σ x. ⟦n = dim_vec x; f x⟧ ⟹ ceros_of_boolean_input x ∈ simplicial_complex.simplices (dim_vec x)› 2. ‹⋀σ x xa. ⟦n = dim_vec x; f x; xa ⊆ ceros_of_boolean_input x⟧ ⟹ ∃xb. dim_vec xb = dim_vec x ∧ f xb ∧ ceros_of_boolean_input xb = xa›*) fix σ :: "nat set" and x :: "bool vec" assume fx: "f x" and dim_vec_x: "n = dim_vec x" (*‹(f::bool vec ⇒ bool) (x::bool vec)› ‹(n::nat) = dim_vec (x::bool vec)›*) show "ceros_of_boolean_input x ∈ simplicial_complex.simplices (dim_vec x)" using ceros_of_boolean_input_def (*‹ceros_of_boolean_input ?v = {x. x < dim_vec ?v ∧ ?v $ x = False}›*) dim_vec_x (*‹n = dim_vec x›*) simplices_def (*‹simplices = Pow {0::nat..<n::nat}›*) by force next (*goal: ‹⋀σ x xa. ⟦n = dim_vec x; f x; xa ⊆ ceros_of_boolean_input x⟧ ⟹ ∃xb. dim_vec xb = dim_vec x ∧ f xb ∧ ceros_of_boolean_input xb = xa›*) fix σ :: "nat set" and x :: "bool vec" and τ :: "nat set" assume fx: "f x" and dim_vec_x: "n = dim_vec x" and tau_def: "τ ⊆ ceros_of_boolean_input x" (*‹(f::bool vec ⇒ bool) (x::bool vec)› ‹(n::nat) = dim_vec (x::bool vec)› ‹(τ::nat set) ⊆ ceros_of_boolean_input (x::bool vec)›*) show "∃xb. dim_vec xb = dim_vec x ∧ f xb ∧ ceros_of_boolean_input xb = τ" proof (rule exI [of _ "vec n (λi. if i ∈ τ then False else True)"] (*‹?P (vec n (λi. if i ∈ τ then False else True)) ⟹ ∃x. ?P x›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹dim_vec (vec n (λi. if i ∈ τ then False else True)) = dim_vec x› 2. ‹f (vec n (λi. if i ∈ τ then False else True))› 3. ‹ceros_of_boolean_input (vec n (λi. if i ∈ τ then False else True)) = τ›*) show "dim_vec (vec n (λi. if i ∈ τ then False else True)) = dim_vec x" unfolding dim_vec (*goal: ‹n = dim_vec x›*) using dim_vec_x (*‹(n::nat) = dim_vec (x::bool vec)›*) . from mon (*‹boolean_functions.monotone_bool_fun n f›*) have mono: "mono_on (carrier_vec n) f" unfolding boolean_functions.monotone_bool_fun_def (*goal: ‹mono_on (carrier_vec n) f›*) . show "f (vec n (λi. if i ∈ τ then False else True))" proof (-) (*goal: ‹f (vec n (λi. if i ∈ τ then False else True))›*) have "f x ≤ f (vec n (λi. if i ∈ τ then False else True))" proof (rule mono_onD [OF mono] (*‹⟦?r ∈ carrier_vec n; ?s ∈ carrier_vec n; ?r ≤ ?s⟧ ⟹ f ?r ≤ f ?s›*)) (*goals: 1. ‹x ∈ carrier_vec n› 2. ‹vec n (λi. if i ∈ τ then False else True) ∈ carrier_vec n› 3. ‹x ≤ vec n (λi. if i ∈ τ then False else True)›*) show "x ∈ carrier_vec n" using dim_vec_x (*‹n = dim_vec x›*) by simp show "vec n (λi. if i ∈ τ then False else True) ∈ carrier_vec n" by simp show "x ≤ vec n (λi. if i ∈ τ then False else True)" using tau_def (*‹τ ⊆ ceros_of_boolean_input x›*) dim_vec_x (*‹n = dim_vec x›*) unfolding ceros_of_boolean_input_def (*goal: ‹(x::bool vec) ≤ vec (n::nat) (λi::nat. if i ∈ (τ::nat set) then False else True)›*) using less_eq_vec_def (*‹(?v ≤ ?w) = (dim_vec ?v = dim_vec ?w ∧ (∀i<dim_vec ?w. ?v $ i ≤ ?w $ i))›*) by fastforce qed thus "?thesis" (*goal: ‹f (vec n (λi. if i ∈ τ then False else True))›*) using fx (*‹f x›*) by simp qed show "ceros_of_boolean_input (vec n (λi. if i ∈ τ then False else True)) = τ" using ‹τ ⊆ ceros_of_boolean_input x› (*‹(τ::nat set) ⊆ ceros_of_boolean_input (x::bool vec)›*) ceros_of_boolean_input_def (*‹ceros_of_boolean_input ?v = {x. x < dim_vec ?v ∧ ?v $ x = False}›*) dim_vec_x (*‹(n::nat) = dim_vec (x::bool vec)›*) by auto qed qed end text‹Example 6.10 in Scoville, the threshold function for $2$ in dimension $4$ (with vertexes $0$,$1$,$2$,$3$)› definition bool_fun_threshold_2_3 :: "bool vec => bool" where "bool_fun_threshold_2_3 = (λv. if 2 ≤ count_true v then True else False)" lemma set_list_four: shows "{0..<4} = set [0,1,2,3::nat]" by auto lemma comp_fun_commute_lambda: "comp_fun_commute_on UNIV ((+) ∘ (λi. if vec 4 f $ i then 1 else (0::nat)))" unfolding comp_fun_commute_on_def (*goal: ‹∀x y. x ∈ UNIV ⟶ y ∈ UNIV ⟶ ((+) ∘ (λi. if vec 4 f $ i then 1 else 0)) y ∘ ((+) ∘ (λi. if vec 4 f $ i then 1 else 0)) x = ((+) ∘ (λi. if vec 4 f $ i then 1 else 0)) x ∘ ((+) ∘ (λi. if vec 4 f $ i then 1 else 0)) y›*) by auto lemma "bool_fun_threshold_2_3 (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) = True" unfolding bool_fun_threshold_2_3_def (*goal: ‹(if 2 ≤ count_true (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) then True else False) = True›*) unfolding count_true_def (*goal: ‹(if (2::nat) ≤ (∑i::nat = 0::nat..<dim_vec (vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False)). if vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ i then 1::nat else (0::nat)) then True else False) = True›*) unfolding dim_vec (*goal: ‹(if (2::nat) ≤ (∑i::nat = 0::nat..<4::nat. if vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ i then 1::nat else (0::nat)) then True else False) = True›*) unfolding sum.eq_fold (*goal: ‹(if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ i then 1 else 0)) 0 {0..<4} then True else False) = True›*) using index_vec[of _ 4] (*‹(?i::nat) < (4::nat) ⟹ vec (4::nat) (?f::nat ⇒ ?'a) $ ?i = ?f ?i›*) apply auto (*goal: ‹(if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ i then 1 else 0)) 0 {0..<4} then True else False) = True›*) unfolding set_list_four (*goal: ‹2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. i = 0 ∨ i = Suc 0) $ i then 1 else 0)) 0 (set [0, 1, 2, 3])›*) unfolding comp_fun_commute_on.fold_set_fold_remdups[OF comp_fun_commute_lambda, simplified] (*goal: ‹2 ≤ fold ((+) ∘ (λi. if vec 4 (λi. i = 0 ∨ i = Suc 0) $ i then 1 else 0)) (remdups [0, 1, 2, 3]) 0›*) by simp lemma "0 ∉ ceros_of_boolean_input (vec 4 (λi. if i = 0 ∨ i = 1 then True else False))" and "1 ∉ ceros_of_boolean_input (vec 4 (λi. if i = 0 ∨ i = 1 then True else False))" and "2 ∈ ceros_of_boolean_input (vec 4 (λi. if i = 0 ∨ i = 1 then True else False))" and "3 ∈ ceros_of_boolean_input (vec 4 (λi. if i = 0 ∨ i = 1 then True else False))" and "{2,3} ⊆ ceros_of_boolean_input (vec 4 (λi. if i = 0 ∨ i = 1 then True else False))" unfolding ceros_of_boolean_input_def (*goals: 1. ‹(0::nat) ∉ {x::nat. x < dim_vec (vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False)) ∧ vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ x = False}› 2. ‹(1::nat) ∉ {x::nat. x < dim_vec (vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False)) ∧ vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ x = False}› 3. ‹(2::nat) ∈ {x::nat. x < dim_vec (vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False)) ∧ vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ x = False}› 4. ‹(3::nat) ∈ {x::nat. x < dim_vec (vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False)) ∧ vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ x = False}› 5. ‹{2::nat, 3::nat} ⊆ {x::nat. x < dim_vec (vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False)) ∧ vec (4::nat) (λi::nat. if i = (0::nat) ∨ i = (1::nat) then True else False) $ x = False}›*) (*goals: 1. ‹0 ∉ {x. x < dim_vec (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) ∧ vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ x = False}› 2. ‹1 ∉ {x. x < dim_vec (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) ∧ vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ x = False}› 3. ‹2 ∈ {x. x < dim_vec (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) ∧ vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ x = False}› 4. ‹3 ∈ {x. x < dim_vec (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) ∧ vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ x = False}› 5. ‹{2, 3} ⊆ {x. x < dim_vec (vec 4 (λi. if i = 0 ∨ i = 1 then True else False)) ∧ vec 4 (λi. if i = 0 ∨ i = 1 then True else False) $ x = False}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . lemma "bool_fun_threshold_2_3 (vec 4 (λi. if i = 3 then True else False)) = False" unfolding bool_fun_threshold_2_3_def (*goal: ‹(if 2 ≤ count_true (vec 4 (λi. if i = 3 then True else False)) then True else False) = False›*) unfolding count_true_def (*goal: ‹(if 2 ≤ (∑i = 0..<dim_vec (vec 4 (λi. if i = 3 then True else False)). if vec 4 (λi. if i = 3 then True else False) $ i then 1 else 0) then True else False) = False›*) unfolding dim_vec (*goal: ‹(if 2 ≤ (∑i = 0..<4. if vec 4 (λi. if i = 3 then True else False) $ i then 1 else 0) then True else False) = False›*) unfolding sum.eq_fold (*goal: ‹(if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i = 3 then True else False) $ i then 1 else 0)) 0 {0..<4} then True else False) = False›*) using index_vec[of _ 4] (*‹?i < 4 ⟹ vec 4 ?f $ ?i = ?f ?i›*) apply auto (*goal: ‹(if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i = 3 then True else False) $ i then 1 else 0)) 0 {0..<4} then True else False) = False›*) unfolding set_list_four (*goal: ‹2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. i = 3) $ i then 1 else 0)) 0 (set [0, 1, 2, 3]) ⟹ False›*) unfolding comp_fun_commute_on.fold_set_fold_remdups[OF comp_fun_commute_lambda, simplified] (*goal: ‹2 ≤ fold ((+) ∘ (λi. if vec 4 (λi. i = 3) $ i then 1 else 0)) (remdups [0, 1, 2, 3]) 0 ⟹ False›*) by simp lemma "bool_fun_threshold_2_3 (vec 4 (λi. if i = 0 then False else True))" unfolding bool_fun_threshold_2_3_def (*goal: ‹if 2 ≤ count_true (vec 4 (λi. if i = 0 then False else True)) then True else False›*) unfolding count_true_def (*goal: ‹if 2 ≤ (∑i = 0..<dim_vec (vec 4 (λi. if i = 0 then False else True)). if vec 4 (λi. if i = 0 then False else True) $ i then 1 else 0) then True else False›*) unfolding dim_vec (*goal: ‹if 2 ≤ (∑i = 0..<4. if vec 4 (λi. if i = 0 then False else True) $ i then 1 else 0) then True else False›*) unfolding sum.eq_fold (*goal: ‹if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i = 0 then False else True) $ i then 1 else 0)) 0 {0..<4} then True else False›*) using index_vec[of _ 4] (*‹?i < 4 ⟹ vec 4 ?f $ ?i = ?f ?i›*) apply auto (*goal: ‹if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i = 0 then False else True) $ i then 1 else 0)) 0 {0..<4} then True else False›*) unfolding set_list_four (*goal: ‹2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 ((<) 0) $ i then 1 else 0)) 0 (set [0, 1, 2, 3])›*) unfolding comp_fun_commute_on.fold_set_fold_remdups[OF comp_fun_commute_lambda, simplified] (*goal: ‹2 ≤ fold ((+) ∘ (λi. if vec 4 ((<) 0) $ i then 1 else 0)) (remdups [0, 1, 2, 3]) 0›*) by simp section‹The simplicial complex induced by the threshold function› lemma empty_set_in_simplicial_complex_induced: "{} ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3" unfolding simplicial_complex_induced_by_monotone_boolean_function_def (*goal: ‹{} ∈ {y. ∃x. dim_vec x = 4 ∧ bool_fun_threshold_2_3 x ∧ ceros_of_boolean_input x = y}›*) unfolding bool_fun_threshold_2_3_def (*goal: ‹{} ∈ {y. ∃x. dim_vec x = 4 ∧ (if 2 ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = y}›*) apply rule (*goal: ‹{} ∈ {y. ∃x. dim_vec x = 4 ∧ (if 2 ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = y}›*) apply (rule exI [of _ "vec 4 (λx. True)"] (*‹(?P::bool vec ⇒ bool) (vec (4::nat) (λx::nat. True)) ⟹ ∃x::bool vec. ?P x›*)) (*goal: ‹∃x. dim_vec x = 4 ∧ (if 2 ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = {}›*) unfolding count_true_def ceros_of_boolean_input_def (*goal: ‹dim_vec (vec 4 (λx. True)) = 4 ∧ (if 2 ≤ (∑i = 0..<dim_vec (vec 4 (λx. True)). if vec 4 (λx. True) $ i then 1 else 0) then True else False) ∧ {x. x < dim_vec (vec 4 (λx. True)) ∧ vec 4 (λx. True) $ x = False} = {}›*) by auto lemma singleton_in_simplicial_complex_induced: assumes x: "x < 4" shows "{x} ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3" (is "?A ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3") proof (unfold simplicial_complex_induced_by_monotone_boolean_function_def (*‹simplicial_complex_induced_by_monotone_boolean_function ?n ?f = {y. ∃x. dim_vec x = ?n ∧ ?f x ∧ ceros_of_boolean_input x = y}›*), rule, rule exI [of _ "vec 4 (λi. if i ∈ ?A then False else True)"] (*‹?P (vec 4 (λi. if i ∈ {x} then False else True)) ⟹ ∃x. ?P x›*), intro conjI (*‹⟦?P::bool; ?Q::bool⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹dim_vec (vec (4::nat) (λi::nat. if i ∈ {x::nat} then False else True)) = (4::nat)› 2. ‹bool_fun_threshold_2_3 (vec (4::nat) (λi::nat. if i ∈ {x::nat} then False else True))› 3. ‹ceros_of_boolean_input (vec (4::nat) (λi::nat. if i ∈ {x::nat} then False else True)) = {x}›*) show "dim_vec (vec 4 (λi. if i ∈ {x} then False else True)) = 4" by simp show "bool_fun_threshold_2_3 (vec 4 (λi. if i ∈ ?A then False else True))" unfolding bool_fun_threshold_2_3_def (*goal: ‹if 2 ≤ count_true (vec 4 (λi. if i ∈ {x} then False else True)) then True else False›*) unfolding count_true_def (*goal: ‹if (2::nat) ≤ (∑i::nat = 0::nat..<dim_vec (vec (4::nat) (λi::nat. if i ∈ {x} then False else True)). if vec (4::nat) (λi::nat. if i ∈ {x::nat} then False else True) $ i then 1::nat else (0::nat)) then True else False›*) unfolding dim_vec (*goal: ‹if 2 ≤ (∑i = 0..<4. if vec 4 (λi. if i ∈ {x} then False else True) $ i then 1 else 0) then True else False›*) unfolding sum.eq_fold (*goal: ‹if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i ∈ {x} then False else True) $ i then 1 else 0)) 0 {0..<4} then True else False›*) using index_vec[of _ 4] (*‹?i < 4 ⟹ vec 4 ?f $ ?i = ?f ?i›*) apply auto (*goal: ‹if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i ∈ {x} then False else True) $ i then 1 else 0)) 0 {0..<4} then True else False›*) unfolding set_list_four (*goal: ‹2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. i ≠ x) $ i then 1 else 0)) 0 (set [0, 1, 2, 3])›*) unfolding comp_fun_commute_on.fold_set_fold_remdups[OF comp_fun_commute_lambda, simplified] (*goal: ‹(2::nat) ≤ fold ((+) ∘ (λi::nat. if vec (4::nat) (λi::nat. i ≠ (x::nat)) $ i then 1::nat else (0::nat))) (remdups [0::nat, 1::nat, 2::nat, 3::nat]) (0::nat)›*) by simp show "ceros_of_boolean_input (vec 4 (λi. if i ∈ ?A then False else True)) = ?A" unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec (vec 4 (λi. if i ∈ {x} then False else True)) ∧ vec 4 (λi. if i ∈ {x} then False else True) $ xa = False} = {x}›*) using x (*‹(x::nat) < (4::nat)›*) by auto qed lemma pair_in_simplicial_complex_induced: assumes x: "x < 4" and y: "y < 4" shows "{x,y} ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3" (is "?A ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3") proof (unfold simplicial_complex_induced_by_monotone_boolean_function_def (*‹simplicial_complex_induced_by_monotone_boolean_function ?n ?f = {y. ∃x. dim_vec x = ?n ∧ ?f x ∧ ceros_of_boolean_input x = y}›*), rule, rule exI [of _ "vec 4 (λi. if i ∈ ?A then False else True)"] (*‹?P (vec 4 (λi. if i ∈ {x, y} then False else True)) ⟹ ∃x. ?P x›*), intro conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹dim_vec (vec 4 (λi. if i ∈ {x, y} then False else True)) = 4› 2. ‹bool_fun_threshold_2_3 (vec 4 (λi. if i ∈ {x, y} then False else True))› 3. ‹ceros_of_boolean_input (vec 4 (λi. if i ∈ {x, y} then False else True)) = {x, y}›*) show "dim_vec (vec 4 (λi. if i ∈ {x, y} then False else True)) = 4" by simp show "bool_fun_threshold_2_3 (vec 4 (λi. if i ∈ ?A then False else True))" unfolding bool_fun_threshold_2_3_def (*goal: ‹if (2::nat) ≤ count_true (vec (4::nat) (λi::nat. if i ∈ {x::nat, y::nat} then False else True)) then True else False›*) unfolding count_true_def (*goal: ‹if 2 ≤ (∑i = 0..<dim_vec (vec 4 (λi. if i ∈ {x, y} then False else True)). if vec 4 (λi. if i ∈ {x, y} then False else True) $ i then 1 else 0) then True else False›*) unfolding dim_vec (*goal: ‹if 2 ≤ (∑i = 0..<4. if vec 4 (λi. if i ∈ {x, y} then False else True) $ i then 1 else 0) then True else False›*) unfolding sum.eq_fold (*goal: ‹if 2 ≤ Finite_Set.fold ((+) ∘ (λi. if vec 4 (λi. if i ∈ {x, y} then False else True) $ i then 1 else 0)) 0 {0..<4} then True else False›*) using index_vec[of _ 4] (*‹(?i::nat) < (4::nat) ⟹ vec (4::nat) (?f::nat ⇒ ?'a) $ ?i = ?f ?i›*) apply auto (*goal: ‹if (2::nat) ≤ Finite_Set.fold ((+) ∘ (λi::nat. if vec (4::nat) (λi::nat. if i ∈ {x::nat, y::nat} then False else True) $ i then 1::nat else (0::nat))) (0::nat) {0::nat..<4::nat} then True else False›*) unfolding set_list_four (*goal: ‹(2::nat) ≤ Finite_Set.fold ((+) ∘ (λi::nat. if vec (4::nat) (λi::nat. i ≠ (x::nat) ∧ i ≠ (y::nat)) $ i then 1::nat else (0::nat))) (0::nat) (set [0::nat, 1::nat, 2::nat, 3::nat])›*) unfolding comp_fun_commute_on.fold_set_fold_remdups[OF comp_fun_commute_lambda, simplified] (*goal: ‹2 ≤ fold ((+) ∘ (λi. if vec 4 (λi. i ≠ x ∧ i ≠ y) $ i then 1 else 0)) (remdups [0, 1, 2, 3]) 0›*) by simp show "ceros_of_boolean_input (vec 4 (λi. if i ∈ ?A then False else True)) = ?A" unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec (vec 4 (λi. if i ∈ {x, y} then False else True)) ∧ vec 4 (λi. if i ∈ {x, y} then False else True) $ xa = False} = {x, y}›*) using x (*‹x < 4›*) y (*‹(y::nat) < (4::nat)›*) by auto qed lemma finite_False: "finite {x. x < dim_vec a ∧ vec_index (a::bool vec) x = False}" by auto lemma finite_True: "finite {x. x < dim_vec a ∧ vec_index (a::bool vec) x = True}" by auto lemma UNIV_disjoint: "{x. x < dim_vec a ∧ vec_index (a::bool vec) x = True} ∩ {x. x < dim_vec a ∧ vec_index (a::bool vec) x = False} = {}" by auto lemma UNIV_union: "{x. x < dim_vec a ∧ vec_index (a::bool vec) x = True} ∪ {x. x < dim_vec a ∧ vec_index (a::bool vec) x = False} = {x. x < dim_vec a}" by auto lemma card_UNIV_union: "card {x. x < dim_vec a ∧ vec_index (a::bool vec) x = True} + card {x. x < dim_vec a ∧ vec_index (a::bool vec) x = False} = card {x. x < dim_vec a}" (is "card ?true + card ?false = _") proof (-) (*goal: ‹card {x. x < dim_vec a ∧ a $ x = True} + card {x. x < dim_vec a ∧ a $ x = False} = card {x. x < dim_vec a}›*) have "card ?true + card ?false = card (?true ∪ ?false) + card (?true ∩ ?false)" using card_Un_Int[OF finite_True [ of a ] finite_False [ of a ]] (*‹card {x. x < dim_vec a ∧ a $ x = True} + card {x. x < dim_vec a ∧ a $ x = False} = card ({x. x < dim_vec a ∧ a $ x = True} ∪ {x. x < dim_vec a ∧ a $ x = False}) + card ({x. x < dim_vec a ∧ a $ x = True} ∩ {x. x < dim_vec a ∧ a $ x = False})›*) . also (*calculation: ‹card {x. x < dim_vec a ∧ a $ x = True} + card {x. x < dim_vec a ∧ a $ x = False} = card ({x. x < dim_vec a ∧ a $ x = True} ∪ {x. x < dim_vec a ∧ a $ x = False}) + card ({x. x < dim_vec a ∧ a $ x = True} ∩ {x. x < dim_vec a ∧ a $ x = False})›*) have "... = card {x. x < dim_vec a}" unfolding UNIV_union UNIV_disjoint (*goal: ‹card {x. x < dim_vec a} + card {} = card {x. x < dim_vec a}›*) by simp finally (*calculation: ‹card {x. x < dim_vec a ∧ a $ x = True} + card {x. x < dim_vec a ∧ a $ x = False} = card {x. x < dim_vec a}›*) show "?thesis" (*goal: ‹card {x. x < dim_vec a ∧ a $ x = True} + card {x. x < dim_vec a ∧ a $ x = False} = card {x. x < dim_vec a}›*) by simp qed lemma card_complementary: "card (ceros_of_boolean_input v) + card {x. x < (dim_vec v) ∧ (vec_index v x = True)} = (dim_vec v)" unfolding ceros_of_boolean_input_def (*goal: ‹card {x. x < dim_vec v ∧ v $ x = False} + card {x. x < dim_vec v ∧ v $ x = True} = dim_vec v›*) using card_UNIV_union[of v] (*‹card {x. x < dim_vec v ∧ v $ x = True} + card {x. x < dim_vec v ∧ v $ x = False} = card {x. x < dim_vec v}›*) by simp corollary card_ceros_of_boolean_input: shows "card (ceros_of_boolean_input a) ≤ dim_vec a" using card_complementary[of a] (*‹card (ceros_of_boolean_input a) + card {x. x < dim_vec a ∧ a $ x = True} = dim_vec a›*) by simp lemma vec_fun: assumes "v ∈ carrier_vec n" shows "∃f. v = vec n f" using assms (*‹v ∈ carrier_vec n›*) unfolding carrier_vec_def (*goal: ‹∃f::nat ⇒ 'a::type. (v::'a::type vec) = vec (n::nat) f›*) by fastforce corollary assumes "dim_vec v = n" shows "∃f. v = vec n f" using carrier_vecI[OF assms] (*‹v ∈ carrier_vec n›*) unfolding carrier_vec_def (*goal: ‹∃f. v = vec n f›*) by fastforce lemma vec_l_eq: assumes "i < n" shows "vec (Suc n) f $ i = vec n f $ i" by (simp add: assms (*‹i < n›*) less_SucI (*‹?m < ?n ⟹ ?m < Suc ?n›*)) lemma card_boolean_function: assumes d: "v ∈ carrier_vec n" shows "card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else (0::nat))" using d (*‹(v::bool vec) ∈ carrier_vec (n::nat)›*) proof (induction n arbitrary: v rule: nat_less_induct) (*goal: ‹⋀n v. ⟦∀m<n. ∀x. x ∈ carrier_vec m ⟶ card {xa. xa < m ∧ x $ xa = True} = (∑i = 0..<m. if x $ i then 1 else 0); v ∈ carrier_vec n⟧ ⟹ card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)›*) case (1 n) (*‹∀m<n. ∀x. x ∈ carrier_vec m ⟶ card {xa. xa < m ∧ x $ xa = True} = (∑i = 0..<m. if x $ i then 1 else 0)› ‹v ∈ carrier_vec n›*) assume hyp: "∀m<n. ∀x. x ∈ carrier_vec m ⟶ card {xa. xa < m ∧ x $ xa = True} = (∑i = 0..<m. if x $ i then 1 else 0)" and d: "v ∈ carrier_vec n" (*‹∀m<n::nat. ∀x::bool vec. x ∈ carrier_vec m ⟶ card {xa::nat. xa < m ∧ x $ xa = True} = (∑i::nat = 0::nat..<m. if x $ i then 1::nat else (0::nat))› ‹(v::bool vec) ∈ carrier_vec (n::nat)›*) show "card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)" using d (*‹(v::bool vec) ∈ carrier_vec (n::nat)›*) proof (cases n) (*goals: 1. ‹⟦v ∈ carrier_vec n; n = 0⟧ ⟹ card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)› 2. ‹⋀nat. ⟦v ∈ carrier_vec n; n = Suc nat⟧ ⟹ card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)›*) case 0 (*‹n = 0›*) then show "?thesis" (*goal: ‹card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)›*) by simp next (*goal: ‹⋀nat. ⟦v ∈ carrier_vec n; n = Suc nat⟧ ⟹ card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)›*) case (Suc m) (*‹n = Suc m›*) assume v: "v ∈ carrier_vec n" (*‹(v::bool vec) ∈ carrier_vec (n::nat)›*) obtain f :: "nat => bool" where v_f: "v = vec n f" (*goal: ‹(⋀f. v = vec n f ⟹ thesis) ⟹ thesis›*) using vec_fun[OF v] (*‹∃f. v = vec n f›*) by auto have "card {x. x < m ∧ (vec m f) $ x = True} = (∑i = 0..<m. if (vec m f) $ i then 1 else 0)" using hyp (*‹∀m<n. ∀x. x ∈ carrier_vec m ⟶ card {xa. xa < m ∧ x $ xa = True} = (∑i = 0..<m. if x $ i then 1 else 0)›*) v (*‹(v::bool vec) ∈ carrier_vec (n::nat)›*) Suc (*‹n = Suc m›*) by simp show "?thesis" (*goal: ‹card {x. x < n ∧ v $ x = True} = (∑i = 0..<n. if v $ i then 1 else 0)›*) unfolding v_f (*goal: ‹card {x. x < n ∧ vec n f $ x = True} = (∑i = 0..<n. if vec n f $ i then 1 else 0)›*) unfolding Suc (*goal: ‹card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = (∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0)›*) proof (cases "vec (Suc m) f $ m = True") (*goals: 1. ‹vec (Suc m) f $ m = True ⟹ card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = (∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0)› 2. ‹vec (Suc m) f $ m ≠ True ⟹ card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = (∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0)›*) case True (*‹vec (Suc m) f $ m = True›*) have one: "{x. x < Suc m ∧ vec (Suc m) f $ x = True} = ({x. x < m ∧ vec (Suc m) f $ x = True} ∪ {x. x = m ∧ (vec (Suc m) f) $ x = True})" by auto have two: "disjnt {x. x < m ∧ vec (Suc m) f $ x = True} {x. x = m ∧ (vec (Suc m) f) $ x = True}" using disjnt_iff (*‹disjnt ?A ?B = (∀x. ¬ (x ∈ ?A ∧ x ∈ ?B))›*) by blast have "card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ (vec (Suc m) f) $ x = True} + card {x. x = m ∧ (vec (Suc m) f) $ x = True}" unfolding one (*goal: ‹card ({x. x < m ∧ vec (Suc m) f $ x = True} ∪ {x. x = m ∧ vec (Suc m) f $ x = True}) = card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True}›*) apply (rule card_Un_disjnt [OF _ _ two] (*‹⟦finite {x. x < m ∧ vec (Suc m) f $ x = True}; finite {x. x = m ∧ vec (Suc m) f $ x = True}⟧ ⟹ card ({x. x < m ∧ vec (Suc m) f $ x = True} ∪ {x. x = m ∧ vec (Suc m) f $ x = True}) = card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True}›*)) (*goals: 1. ‹finite {x. x < m ∧ vec (Suc m) f $ x = True}› 2. ‹finite {x. x = m ∧ vec (Suc m) f $ x = True}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True}›*) have "... = card {x. x < m ∧ (vec m f) $ x = True} + 1" proof (-) (*goal: ‹card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 1›*) have one: "{x. x < m ∧ vec (Suc m) f $ x = True} = {x. x < m ∧ vec m f $ x = True}" using vec_l_eq[of _ m] (*‹?i < m ⟹ vec (Suc m) ?f $ ?i = vec m ?f $ ?i›*) by auto have eq: "{x. x = m ∧ vec (Suc m) f $ x = True} = {m}" using True (*‹vec (Suc m) f $ m = True›*) by auto hence two: "card {x. x = m ∧ vec (Suc m) f $ x = True} = 1" by simp show "?thesis" (*goal: ‹card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 1›*) using one (*‹{x. x < m ∧ vec (Suc m) f $ x = True} = {x. x < m ∧ vec m f $ x = True}›*) two (*‹card {x. x = m ∧ vec (Suc m) f $ x = True} = 1›*) by simp qed finally (*calculation: ‹card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 1›*) have lhs: "card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 1" . have "(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec (Suc m) f $ i then 1 else 0) + (if vec (Suc m) f $ m then 1 else 0)" by simp also (*calculation: ‹(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec (Suc m) f $ i then 1 else 0) + (if vec (Suc m) f $ m then 1 else 0)›*) have "... = (∑i = 0..<m. if vec m f $ i then 1 else 0) + 1" using vec_l_eq[of _ m] (*‹?i < m ⟹ vec (Suc m) ?f $ ?i = vec m ?f $ ?i›*) True (*‹vec (Suc m) f $ m = True›*) by simp finally (*calculation: ‹(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec m f $ i then 1 else 0) + 1›*) have rhs: "(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec m f $ i then 1 else 0) + 1" . show "card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = (∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0)" unfolding lhs rhs (*goal: ‹card {x. x < m ∧ vec m f $ x = True} + 1 = (∑i = 0..<m. if vec m f $ i then 1 else 0) + 1›*) using hyp (*‹∀m<n. ∀x. x ∈ carrier_vec m ⟶ card {xa. xa < m ∧ x $ xa = True} = (∑i = 0..<m. if x $ i then 1 else 0)›*) Suc (*‹(n::nat) = Suc (m::nat)›*) by simp next (*goal: ‹vec (Suc m) f $ m ≠ True ⟹ card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = (∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0)›*) case False (*‹vec (Suc (m::nat)) (f::nat ⇒ bool) $ m ≠ True›*) have one: "{x. x < Suc m ∧ vec (Suc m) f $ x = True} = ({x. x < m ∧ vec (Suc m) f $ x = True} ∪ {x. x = m ∧ (vec (Suc m) f) $ x = True})" by auto have two: "disjnt {x. x < m ∧ vec (Suc m) f $ x = True} {x. x = m ∧ (vec (Suc m) f) $ x = True}" using disjnt_iff (*‹disjnt (?A::?'a set) (?B::?'a set) = (∀x::?'a. ¬ (x ∈ ?A ∧ x ∈ ?B))›*) by blast have "card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ (vec (Suc m) f) $ x = True} + card {x. x = m ∧ (vec (Suc m) f) $ x = True}" unfolding one (*goal: ‹card ({x. x < m ∧ vec (Suc m) f $ x = True} ∪ {x. x = m ∧ vec (Suc m) f $ x = True}) = card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True}›*) apply (rule card_Un_disjnt [OF _ _ two] (*‹⟦finite {x. x < m ∧ vec (Suc m) f $ x = True}; finite {x. x = m ∧ vec (Suc m) f $ x = True}⟧ ⟹ card ({x. x < m ∧ vec (Suc m) f $ x = True} ∪ {x. x = m ∧ vec (Suc m) f $ x = True}) = card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True}›*)) (*goals: 1. ‹finite {x. x < m ∧ vec (Suc m) f $ x = True}› 2. ‹finite {x. x = m ∧ vec (Suc m) f $ x = True}› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . also (*calculation: ‹card {x::nat. x < Suc (m::nat) ∧ vec (Suc m) (f::nat ⇒ bool) $ x = True} = card {x::nat. x < m ∧ vec (Suc m) f $ x = True} + card {x::nat. x = m ∧ vec (Suc m) f $ x = True}›*) have "... = card {x. x < m ∧ (vec m f) $ x = True} + 0" proof (-) (*goal: ‹card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 0›*) have one: "{x. x < m ∧ vec (Suc m) f $ x = True} = {x. x < m ∧ vec m f $ x = True}" using vec_l_eq[of _ m] (*‹(?i::nat) < (m::nat) ⟹ vec (Suc m) (?f::nat ⇒ ?'a) $ ?i = vec m ?f $ ?i›*) by auto have eq: "{x. x = m ∧ vec (Suc m) f $ x = True} = {}" using False (*‹vec (Suc (m::nat)) (f::nat ⇒ bool) $ m ≠ True›*) by auto hence two: "card {x. x = m ∧ vec (Suc m) f $ x = True} = 0" by simp show "?thesis" (*goal: ‹card {x. x < m ∧ vec (Suc m) f $ x = True} + card {x. x = m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 0›*) using one (*‹{x. x < m ∧ vec (Suc m) f $ x = True} = {x. x < m ∧ vec m f $ x = True}›*) two (*‹card {x. x = m ∧ vec (Suc m) f $ x = True} = 0›*) by simp qed finally (*calculation: ‹card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 0›*) have lhs: "card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = card {x. x < m ∧ vec m f $ x = True} + 0" . have "(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec (Suc m) f $ i then 1 else 0) + (if vec (Suc m) f $ m then 1 else 0)" by simp also (*calculation: ‹(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec (Suc m) f $ i then 1 else 0) + (if vec (Suc m) f $ m then 1 else 0)›*) have "... = (∑i = 0..<m. if vec m f $ i then 1 else 0)" using vec_l_eq[of _ m] (*‹?i < m ⟹ vec (Suc m) ?f $ ?i = vec m ?f $ ?i›*) False (*‹vec (Suc (m::nat)) (f::nat ⇒ bool) $ m ≠ True›*) by simp finally (*calculation: ‹(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec m f $ i then 1 else 0)›*) have rhs: "(∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0) = (∑i = 0..<m. if vec m f $ i then 1 else 0)" . show "card {x. x < Suc m ∧ vec (Suc m) f $ x = True} = (∑i = 0..<Suc m. if vec (Suc m) f $ i then 1 else 0)" unfolding lhs rhs (*goal: ‹card {x::nat. x < (m::nat) ∧ vec m (f::nat ⇒ bool) $ x = True} + (0::nat) = (∑i::nat = 0::nat..<m. if vec m f $ i then 1::nat else (0::nat))›*) using hyp (*‹∀m<n::nat. ∀x::bool vec. x ∈ carrier_vec m ⟶ card {xa::nat. xa < m ∧ x $ xa = True} = (∑i::nat = 0::nat..<m. if x $ i then 1::nat else (0::nat))›*) Suc (*‹n = Suc m›*) by simp qed qed qed lemma card_ceros_count_UNIV: shows "card (ceros_of_boolean_input a) + count_true ((a::bool vec)) = dim_vec a" using card_complementary[of a] (*‹card (ceros_of_boolean_input a) + card {x. x < dim_vec a ∧ a $ x = True} = dim_vec a›*) using card_boolean_function (*‹?v ∈ carrier_vec ?n ⟹ card {x. x < ?n ∧ ?v $ x = True} = (∑i = 0..<?n. if ?v $ i then 1 else 0)›*) unfolding ceros_of_boolean_input_def (*goal: ‹card {x. x < dim_vec a ∧ a $ x = False} + count_true a = dim_vec a›*) unfolding count_true_def (*goal: ‹card {x. x < dim_vec a ∧ a $ x = False} + (∑i = 0..<dim_vec a. if a $ i then 1 else 0) = dim_vec a›*) by simp text‹We calculate the carrier set of the @{const ceros_of_boolean_input} function for dimensions $2$, $3$ and $4$.› text‹Vectors of dimension $2$.› lemma dim_vec_2_cases: assumes dx: "dim_vec x = 2" shows "(x $ 0 = x $ 1 = True) ∨ (x $ 0 = False ∧ x $ 1 = True) ∨ (x $ 0 = True ∧ x $ 1 = False) ∨ (x $ 0 = x $ 1 = False)" by auto lemma tt_2: assumes dx: "dim_vec x = 2" and be: "x $ 0 = True ∧ x $ 1 = True" shows "ceros_of_boolean_input x = {}" using dx (*‹dim_vec x = 2›*) be (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {}›*) using less_2_cases (*‹?n < 2 ⟹ ?n = 0 ∨ ?n = Suc 0›*) by auto lemma tf_2: assumes dx: "dim_vec x = 2" and be: "x $ 0 = True ∧ x $ 1 = False" shows "ceros_of_boolean_input x = {1}" using dx (*‹dim_vec x = 2›*) be (*‹x $ 0 = True ∧ x $ 1 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {1}›*) using less_2_cases (*‹?n < 2 ⟹ ?n = 0 ∨ ?n = Suc 0›*) by auto lemma ft_2: assumes dx: "dim_vec x = 2" and be: "x $ 0 = False ∧ x $ 1 = True" shows "ceros_of_boolean_input x = {0}" using dx (*‹dim_vec (x::bool vec) = (2::nat)›*) be (*‹x $ 0 = False ∧ x $ 1 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0}›*) using less_2_cases (*‹?n < 2 ⟹ ?n = 0 ∨ ?n = Suc 0›*) by auto lemma ff_2: assumes dx: "dim_vec x = 2" and be: "x $ 0 = False ∧ x $ 1 = False" shows "ceros_of_boolean_input x = {0,1}" using dx (*‹dim_vec x = 2›*) be (*‹x $ 0 = False ∧ x $ 1 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0, 1}›*) using less_2_cases (*‹(?n::nat) < (2::nat) ⟹ ?n = (0::nat) ∨ ?n = Suc (0::nat)›*) by auto lemma assumes dx: "dim_vec x = 2" shows "ceros_of_boolean_input x ∈ {{},{0},{1},{0,1}}" using dim_vec_2_cases[OF] (*‹dim_vec ?x = 2 ⟹ (?x $ 0 = ?x $ 1) = True ∨ ?x $ 0 = False ∧ ?x $ 1 = True ∨ ?x $ 0 = True ∧ ?x $ 1 = False ∨ (?x $ 0 = ?x $ 1) = False›*) using tt_2[OF dx] (*‹x $ 0 = True ∧ x $ 1 = True ⟹ ceros_of_boolean_input x = {}›*) tf_2[OF dx] (*‹x $ 0 = True ∧ x $ 1 = False ⟹ ceros_of_boolean_input x = {1}›*) ft_2[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ⟹ ceros_of_boolean_input x = {0}›*) ff_2[OF dx] (*‹(x::bool vec) $ (0::nat) = False ∧ x $ (1::nat) = False ⟹ ceros_of_boolean_input x = {0::nat, 1::nat}›*) by (metis insertCI (*‹((?a::?'a) ∉ (?B::?'a set) ⟹ ?a = (?b::?'a)) ⟹ ?a ∈ insert ?b ?B›*)) text‹Vectors of dimension $3$.› lemma less_3_cases: assumes n: "n < 3" shows "n = 0 ∨ n = 1 ∨ n = (2::nat)" using n (*‹n < 3›*) by linarith lemma dim_vec_3_cases: assumes dx: "dim_vec x = 3" shows "(x $ 0 = x $ 1 = x $ 2 = False) ∨ (x $ 0 = x $ 1 = False ∧ x $ 2 = True) ∨ (x $ 0 = x $ 2 = False ∧ x $ 1 = True) ∨ (x $ 0 = False ∧ x $ 1 = x $ 2 = True) ∨ (x $ 0 = True ∧ x $ 1 = x $ 2 = False) ∨ (x $ 0 = x $ 2 = True ∧ x $ 1 = False) ∨ (x $ 0 = x $ 1 = True ∧ x $ 2 = False) ∨ (x $ 0 = x $ 1 = x $ 2 = True)" by auto lemma fff_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False" shows "ceros_of_boolean_input x = {0,1,2}" using dx (*‹dim_vec x = 3›*) be (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0, 1, 2}›*) using less_3_cases (*‹?n < 3 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2›*) by auto lemma fft_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True" shows "ceros_of_boolean_input x = {0,1}" using dx (*‹dim_vec x = 3›*) be (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0, 1}›*) using less_3_cases (*‹?n < 3 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2›*) by auto lemma ftf_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False" shows "ceros_of_boolean_input x = {0,2}" using dx (*‹dim_vec x = 3›*) be (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {0::nat, 2::nat}›*) using less_3_cases (*‹?n < 3 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2›*) by fastforce lemma ftt_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True" shows "ceros_of_boolean_input x = {0}" using dx (*‹dim_vec x = 3›*) be (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {0::nat}›*) using less_3_cases (*‹?n < 3 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2›*) by auto lemma tff_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False" shows "ceros_of_boolean_input x = {1,2}" using dx (*‹dim_vec x = 3›*) be (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {1, 2}›*) using less_3_cases (*‹?n < 3 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2›*) by auto lemma tft_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True" shows "ceros_of_boolean_input x = {1}" using dx (*‹dim_vec x = 3›*) be (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {1}›*) using less_3_cases (*‹(?n::nat) < (3::nat) ⟹ ?n = (0::nat) ∨ ?n = (1::nat) ∨ ?n = (2::nat)›*) by auto lemma ttf_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = False" shows "ceros_of_boolean_input x = {2}" using dx (*‹dim_vec x = 3›*) be (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = True ∧ x $ (2::nat) = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {2}›*) using less_3_cases (*‹?n < 3 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2›*) by fastforce lemma ttt_3: assumes dx: "dim_vec x = 3" and be: "x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True" shows "ceros_of_boolean_input x = {}" using dx (*‹dim_vec (x::bool vec) = (3::nat)›*) be (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {}›*) using less_3_cases (*‹(?n::nat) < (3::nat) ⟹ ?n = (0::nat) ∨ ?n = (1::nat) ∨ ?n = (2::nat)›*) by auto lemma assumes dx: "dim_vec x = 3" shows "ceros_of_boolean_input x ∈ {{},{0},{1},{2},{0,1},{0,2},{1,2},{0,1,2}}" using dim_vec_3_cases[OF] (*‹dim_vec ?x = 3 ⟹ ((?x $ 0 = ?x $ 1) = ?x $ 2) = False ∨ (?x $ 0 = ?x $ 1) = False ∧ ?x $ 2 = True ∨ (?x $ 0 = ?x $ 2) = False ∧ ?x $ 1 = True ∨ ?x $ 0 = False ∧ (?x $ 1 = ?x $ 2) = True ∨ ?x $ 0 = True ∧ (?x $ 1 = ?x $ 2) = False ∨ (?x $ 0 = ?x $ 2) = True ∧ ?x $ 1 = False ∨ (?x $ 0 = ?x $ 1) = True ∧ ?x $ 2 = False ∨ ((?x $ 0 = ?x $ 1) = ?x $ 2) = True›*) using fff_3[OF dx] (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False ⟹ ceros_of_boolean_input x = {0, 1, 2}›*) fft_3[OF dx] (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True ⟹ ceros_of_boolean_input x = {0, 1}›*) ftf_3[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False ⟹ ceros_of_boolean_input x = {0, 2}›*) ftt_3[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True ⟹ ceros_of_boolean_input x = {0}›*) using tff_3[OF dx] (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = False ∧ x $ (2::nat) = False ⟹ ceros_of_boolean_input x = {1::nat, 2::nat}›*) tft_3[OF dx] (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ⟹ ceros_of_boolean_input x = {1}›*) ttf_3[OF dx] (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = False ⟹ ceros_of_boolean_input x = {2}›*) ttt_3[OF dx] (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = True ∧ x $ (2::nat) = True ⟹ ceros_of_boolean_input x = {}›*) by (smt (z3) insertCI (*‹((?a::?'a) ∉ (?B::?'a set) ⟹ ?a = (?b::?'a)) ⟹ ?a ∈ insert ?b ?B›*)) text‹Vectors of dimension $4$.› lemma less_4_cases: assumes n: "n < 4" shows "n = 0 ∨ n = 1 ∨ n = 2 ∨ n = (3::nat)" using n (*‹(n::nat) < (4::nat)›*) by linarith lemma dim_vec_4_cases: assumes dx: "dim_vec x = 4" shows "(x $ 0 = x $ 1 = x $ 2 = x $ 3 = False) ∨ (x $ 0 = x $ 1 = x $ 2 = False ∧ x $ 3 = True) ∨ (x $ 0 = x $ 1 = x $ 3 = False ∧ x $ 2 = True) ∨ (x $ 0 = x $ 1 = False ∧ x $ 2 = x $ 3 = True) ∨ (x $ 0 = x $ 2 = x $ 3 = False ∧ x $ 1 = True) ∨ (x $ 0 = x $ 2 = False ∧ x $ 1 = x $ 3 = True) ∨ (x $ 0 = x $ 3 = False ∧ x $ 1 = x $ 2 = True) ∨ (x $ 0 = False ∧ x $ 1 = x $ 2 = x $ 3 = True) ∨ (x $ 0 = True ∧ x $ 1 = x $ 2 = x $ 3 = False) ∨ (x $ 0 = x $ 3 = True ∧ x $ 1 = x $ 2 = False) ∨ (x $ 0 = x $ 2 = True ∧ x $ 1 = x $ 3 = False) ∨ (x $ 0 = x $ 2 = x $ 3 = True ∧ x $ 1 = False) ∨ (x $ 0 = x $ 1 = True ∧ x $ 2 = x $ 3 = False) ∨ (x $ 0 = x $ 1 = x $ 3 = True ∧ x $ 2 = False) ∨ (x $ 0 = x $ 1 = x $ 2 = True ∧ x $ 3 = False) ∨ (x $ 0 = x $ 1 = x $ 2 = x $ 3 = True)" by blast lemma ffff_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {0,1,2,3}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {0::nat, 1::nat, 2::nat, 3::nat}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma ffft_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {0,1,2}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0, 1, 2}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma fftf_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {0,1,3}" using dx (*‹dim_vec x = 4›*) be (*‹(x::bool vec) $ (0::nat) = False ∧ x $ (1::nat) = False ∧ x $ (2::nat) = True ∧ x $ (3::nat) = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0, 1, 3}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma fftt_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {0,1}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {0::nat, 1::nat}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma ftff_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {0,2,3}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0, 2, 3}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma ftft_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {0,2}" using dx (*‹dim_vec x = 4›*) be (*‹(x::bool vec) $ (0::nat) = False ∧ x $ (1::nat) = True ∧ x $ (2::nat) = False ∧ x $ (3::nat) = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {0::nat, 2::nat}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma fttf_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {0,3}" using dx (*‹dim_vec x = 4›*) be (*‹(x::bool vec) $ (0::nat) = False ∧ x $ (1::nat) = True ∧ x $ (2::nat) = True ∧ x $ (3::nat) = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {0::nat, 3::nat}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma fttt_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {0}" using dx (*‹dim_vec (x::bool vec) = (4::nat)›*) be (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {0}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma tfff_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {1,2,3}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {1, 2, 3}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma tfft_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {1,2}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {1, 2}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma tftf_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {1,3}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {1, 3}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma tftt_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {1}" using dx (*‹dim_vec (x::bool vec) = (4::nat)›*) be (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa::nat. xa < dim_vec (x::bool vec) ∧ x $ xa = False} = {1::nat}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma ttff_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {2,3}" using dx (*‹dim_vec (x::bool vec) = (4::nat)›*) be (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {2, 3}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma ttft_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {2}" using dx (*‹dim_vec (x::bool vec) = (4::nat)›*) be (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = True ∧ x $ (2::nat) = False ∧ x $ (3::nat) = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {2}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma tttf_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = False" shows "ceros_of_boolean_input x = {3}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = False›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {3}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma tttt_4: assumes dx: "dim_vec x = 4" and be: "x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = True" shows "ceros_of_boolean_input x = {}" using dx (*‹dim_vec x = 4›*) be (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = True›*) unfolding ceros_of_boolean_input_def (*goal: ‹{xa. xa < dim_vec x ∧ x $ xa = False} = {}›*) using less_4_cases (*‹?n < 4 ⟹ ?n = 0 ∨ ?n = 1 ∨ ?n = 2 ∨ ?n = 3›*) by auto lemma ceros_of_boolean_input_set: assumes dx: "dim_vec x = 4" shows "ceros_of_boolean_input x ∈ {{},{0},{1},{2},{3},{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}, {0,1,2},{0,1,3},{0,2,3},{1,2,3},{0,1,2,3}}" using dim_vec_4_cases[OF] (*‹dim_vec ?x = 4 ⟹ (((?x $ 0 = ?x $ 1) = ?x $ 2) = ?x $ 3) = False ∨ ((?x $ 0 = ?x $ 1) = ?x $ 2) = False ∧ ?x $ 3 = True ∨ ((?x $ 0 = ?x $ 1) = ?x $ 3) = False ∧ ?x $ 2 = True ∨ (?x $ 0 = ?x $ 1) = False ∧ (?x $ 2 = ?x $ 3) = True ∨ ((?x $ 0 = ?x $ 2) = ?x $ 3) = False ∧ ?x $ 1 = True ∨ (?x $ 0 = ?x $ 2) = False ∧ (?x $ 1 = ?x $ 3) = True ∨ (?x $ 0 = ?x $ 3) = False ∧ (?x $ 1 = ?x $ 2) = True ∨ ?x $ 0 = False ∧ ((?x $ 1 = ?x $ 2) = ?x $ 3) = True ∨ ?x $ 0 = True ∧ ((?x $ 1 = ?x $ 2) = ?x $ 3) = False ∨ (?x $ 0 = ?x $ 3) = True ∧ (?x $ 1 = ?x $ 2) = False ∨ (?x $ 0 = ?x $ 2) = True ∧ (?x $ 1 = ?x $ 3) = False ∨ ((?x $ 0 = ?x $ 2) = ?x $ 3) = True ∧ ?x $ 1 = False ∨ (?x $ 0 = ?x $ 1) = True ∧ (?x $ 2 = ?x $ 3) = False ∨ ((?x $ 0 = ?x $ 1) = ?x $ 3) = True ∧ ?x $ 2 = False ∨ ((?x $ 0 = ?x $ 1) = ?x $ 2) = True ∧ ?x $ 3 = False ∨ (((?x $ 0 = ?x $ 1) = ?x $ 2) = ?x $ 3) = True›*) using ffff_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {0, 1, 2, 3}›*) ffft_4[OF dx] (*‹(x::bool vec) $ (0::nat) = False ∧ x $ (1::nat) = False ∧ x $ (2::nat) = False ∧ x $ (3::nat) = True ⟹ ceros_of_boolean_input x = {0::nat, 1::nat, 2::nat}›*) fftf_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {0, 1, 3}›*) fftt_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = True ⟹ ceros_of_boolean_input x = {0, 1}›*) using ftff_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {0, 2, 3}›*) ftft_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = True ⟹ ceros_of_boolean_input x = {0, 2}›*) fttf_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {0, 3}›*) fttt_4[OF dx] (*‹x $ 0 = False ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = True ⟹ ceros_of_boolean_input x = {0}›*) using tfff_4[OF dx] (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = False ∧ x $ (2::nat) = False ∧ x $ (3::nat) = False ⟹ ceros_of_boolean_input x = {1::nat, 2::nat, 3::nat}›*) tfft_4[OF dx] (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = False ∧ x $ 3 = True ⟹ ceros_of_boolean_input x = {1, 2}›*) tftf_4[OF dx] (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {1, 3}›*) tftt_4[OF dx] (*‹x $ 0 = True ∧ x $ 1 = False ∧ x $ 2 = True ∧ x $ 3 = True ⟹ ceros_of_boolean_input x = {1}›*) using ttff_4[OF dx] (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = False ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {2, 3}›*) ttft_4[OF dx] (*‹(x::bool vec) $ (0::nat) = True ∧ x $ (1::nat) = True ∧ x $ (2::nat) = False ∧ x $ (3::nat) = True ⟹ ceros_of_boolean_input x = {2::nat}›*) tttf_4[OF dx] (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = False ⟹ ceros_of_boolean_input x = {3}›*) tttt_4[OF dx] (*‹x $ 0 = True ∧ x $ 1 = True ∧ x $ 2 = True ∧ x $ 3 = True ⟹ ceros_of_boolean_input x = {}›*) by (smt (z3) insertCI (*‹((?a::?'a::type) ∉ (?B::?'a::type set) ⟹ ?a = (?b::?'a::type)) ⟹ ?a ∈ insert ?b ?B›*)) context simplicial_complex begin text‹The simplicial complex induced by the monotone Boolean function @{const bool_fun_threshold_2_3} has the following explicit expression.› lemma simplicial_complex_induced_by_monotone_boolean_function_4_bool_fun_threshold_2_3: shows "{{},{0},{1},{2},{3},{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}} = simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3" (is "{{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j} = _") proof (rule) (*goals: 1. ‹{{}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}} ⊆ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3› 2. ‹simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3 ⊆ {{}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}›*) show "{{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j} ⊆ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3" by (simp add: empty_set_in_simplicial_complex_induced (*‹{} ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3›*) singleton_in_simplicial_complex_induced (*‹?x < 4 ⟹ {?x} ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3›*) pair_in_simplicial_complex_induced (*‹⟦?x < 4; ?y < 4⟧ ⟹ {?x, ?y} ∈ simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3›*)) show "simplicial_complex_induced_by_monotone_boolean_function 4 bool_fun_threshold_2_3 ⊆ {{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j}" unfolding simplicial_complex_induced_by_monotone_boolean_function_def (*goal: ‹{y::nat set. ∃x::bool vec. dim_vec x = (4::nat) ∧ bool_fun_threshold_2_3 x ∧ ceros_of_boolean_input x = y} ⊆ {{}, {0::nat}, {1::nat}, {2::nat}, {3::nat}, {0::nat, 1::nat}, {0::nat, 2::nat}, {0::nat, 3::nat}, {1::nat, 2::nat}, {1::nat, 3::nat}, {2::nat, 3::nat}}›*) unfolding bool_fun_threshold_2_3_def (*goal: ‹{y::nat set. ∃x::bool vec. dim_vec x = (4::nat) ∧ (if (2::nat) ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = y} ⊆ {{}, {0::nat}, {1::nat}, {2::nat}, {3::nat}, {0::nat, 1::nat}, {0::nat, 2::nat}, {0::nat, 3::nat}, {1::nat, 2::nat}, {1::nat, 3::nat}, {2::nat, 3::nat}}›*) proof (standard) (*goal: ‹⋀x. x ∈ {y. ∃x. dim_vec x = 4 ∧ (if 2 ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = y} ⟹ x ∈ {{}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}›*) fix y :: "nat set" assume y: "y ∈ {y. ∃x. dim_vec x = 4 ∧ (if 2 ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = y}" (*‹(y::nat set) ∈ {y::nat set. ∃x::bool vec. dim_vec x = (4::nat) ∧ (if (2::nat) ≤ count_true x then True else False) ∧ ceros_of_boolean_input x = y}›*) then obtain x :: "bool vec" where ct_ge_2: "(if 2 ≤ count_true x then True else False)" and cx: "ceros_of_boolean_input x = y" and dx: "dim_vec x = 4" (*goal: ‹(⋀x. ⟦if 2 ≤ count_true x then True else False; ceros_of_boolean_input x = y; dim_vec x = 4⟧ ⟹ thesis) ⟹ thesis›*) by auto have "count_true x + card (ceros_of_boolean_input x) = dim_vec x" using card_ceros_count_UNIV[of x] (*‹card (ceros_of_boolean_input x) + count_true x = dim_vec x›*) by simp hence "card (ceros_of_boolean_input x) ≤ 2" using ct_ge_2 (*‹if 2 ≤ count_true x then True else False›*) using card_boolean_function (*‹?v ∈ carrier_vec ?n ⟹ card {x. x < ?n ∧ ?v $ x = True} = (∑i = 0..<?n. if ?v $ i then 1 else 0)›*) using dx (*‹dim_vec x = 4›*) by presburger hence card_le: "card y ≤ 2" using cx (*‹ceros_of_boolean_input x = y›*) by simp have "y ∈ {{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j}" proof (rule ccontr (*‹(¬ ?P ⟹ False) ⟹ ?P›*)) (*goal: ‹y ∉ {{}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}} ⟹ False›*) assume "y ∉ {{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j}" (*‹(y::nat set) ∉ {{}, {0::nat}, {1::nat}, {2::nat}, {3::nat}, {0::nat, 1::nat}, {0::nat, 2::nat}, {0::nat, 3::nat}, {1::nat, 2::nat}, {1::nat, 3::nat}, {2::nat, 3::nat}}›*) then have y_nin: "y ∉ set [{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j]" by simp have "y ∈ set [{0,1,2},{0,1,3},{0,2,3},{1,2,3},{0,1,2,3}]" using ceros_of_boolean_input_set[OF dx] (*‹ceros_of_boolean_input x ∈ {{}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}, {0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}}›*) y_nin (*‹y ∉ set [{}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}]›*) unfolding cx (*goal: ‹y ∈ set [{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}]›*) by simp hence "card y ≥ 3" by auto thus False using card_le (*‹card y ≤ 2›*) by simp qed then show "y ∈ {{},?a,?b,?c,?d,?e,?f,?g,?h,?i,?j}" by simp qed qed end end
{ "path": "afp-2025-02-12/thys/Simplicial_complexes_and_boolean_functions/Simplicial_complex.thy", "repo": "afp-2025-02-12", "sha": "2cbe1c38606092be0b8ec1bdea9cc2eb87a235a414297dca9de54b5ce505dda7" }
(* Title: While_Combinator_Exts.thy Author: Denis Lohner *) section ‹Code Generation› subsection ‹While Combinator Extensions› theory While_Combinator_Exts imports "HOL-Library.While_Combinator" begin lemma while_option_None_invD: assumes "while_option b c s = None" and "wf r" and "I s" and "⋀s. ⟦ I s; b s ⟧ ⟹ I (c s)" and "⋀s. ⟦ I s; b s ⟧ ⟹ (c s, s ) ∈ r" shows "False" using assms (*‹while_option b c s = None› ‹wf r› ‹I s› ‹⟦I ?s; b ?s⟧ ⟹ I (c ?s)› ‹⟦I ?s; b ?s⟧ ⟹ (c ?s, ?s) ∈ r›*) apply - (*goal: ‹False›*) apply (drule wf_rel_while_option_Some [of r I b c] (*‹⟦wf (r::('a × 'a) set); ⋀s::'a. (I::'a ⇒ bool) s ∧ (b::'a ⇒ bool) s ⟹ ((c::'a ⇒ 'a) s, s) ∈ r; ⋀s::'a. I s ∧ b s ⟹ I (c s); I (?s::'a)⟧ ⟹ ∃t::'a. while_option b c ?s = Some t›*)) (*goals: 1. ‹⋀sa. ⟦while_option b c s = None; I s; ⋀s. ⟦I s; b s⟧ ⟹ I (c s); ⋀s. ⟦I s; b s⟧ ⟹ (c s, s) ∈ r; I sa ∧ b sa⟧ ⟹ (c sa, sa) ∈ r› 2. ‹⋀sa. ⟦while_option b c s = None; I s; ⋀s. ⟦I s; b s⟧ ⟹ I (c s); ⋀s. ⟦I s; b s⟧ ⟹ (c s, s) ∈ r; I sa ∧ b sa⟧ ⟹ I (c sa)› 3. ‹⟦while_option b c s = None; I s; ⋀s. ⟦I s; b s⟧ ⟹ I (c s); ⋀s. ⟦I s; b s⟧ ⟹ (c s, s) ∈ r⟧ ⟹ I ?s7› 4. ‹⟦while_option b c s = None; I s; ⋀s. ⟦I s; b s⟧ ⟹ I (c s); ⋀s. ⟦I s; b s⟧ ⟹ (c s, s) ∈ r; ∃t. while_option b c ?s7 = Some t⟧ ⟹ False› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) by ((auto)[1]) (*proven 4 subgoals*) lemma while_option_NoneD: assumes "while_option b c s = None" and "wf r" and "⋀s. b s ⟹ (c s, s) ∈ r" shows "False" using assms (*‹while_option b c s = None› ‹wf r› ‹(b::'a ⇒ bool) (?s::'a) ⟹ ((c::'a ⇒ 'a) ?s, ?s) ∈ (r::('a × 'a) set)›*) by (blast intro: while_option_None_invD (*‹⟦while_option ?b ?c ?s = None; wf ?r; ?I ?s; ⋀s. ⟦?I s; ?b s⟧ ⟹ ?I (?c s); ⋀s. ⟦?I s; ?b s⟧ ⟹ (?c s, s) ∈ ?r⟧ ⟹ False›*)) lemma while_option_sim: assumes start: "R (Some s1) (Some s2)" and cond: "⋀s1 s2. ⟦ R (Some s1) (Some s2); I s1 ⟧ ⟹ b1 s1 = b2 s2" and step : "⋀s1 s2. ⟦ R (Some s1) (Some s2); I s1; b1 s1 ⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2))" and diverge: "R None None" and inv_start: "I s1" and inv_step: "⋀s1. ⟦ I s1; b1 s1 ⟧ ⟹ I (c1 s1)" shows "R (while_option b1 c1 s1) (while_option b2 c2 s2)" proof (-) (*goal: ‹R (while_option b1 c1 s1) (while_option b2 c2 s2)›*) { fix k assume "∀k' < k. b1 ((c1 ^^ k') s1)" (*‹∀k'<k::nat. (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ k') (s1::'a))›*) with start (*‹(R::'a option ⇒ 'b option ⇒ bool) (Some (s1::'a)) (Some (s2::'b))›*) cond (*‹⟦R (Some ?s1.0) (Some ?s2.0); I ?s1.0⟧ ⟹ b1 ?s1.0 = b2 ?s2.0›*) step (*‹⟦R (Some ?s1.0) (Some ?s2.0); I ?s1.0; b1 ?s1.0⟧ ⟹ R (Some (c1 ?s1.0)) (Some (c2 ?s2.0))›*) inv_start (*‹I s1›*) inv_step (*‹⟦I ?s1.0; b1 ?s1.0⟧ ⟹ I (c1 ?s1.0)›*) have "b1 ((c1 ^^ k) s1) = b2 ((c2 ^^ k) s2)" and "I ((c1 ^^ k) s1)" and "R (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2))" apply - (*goals: 1. ‹⟦(R::'a option ⇒ 'b option ⇒ bool) (Some (s1::'a)) (Some (s2::'b)); ⋀(s1::'a) s2::'b. ⟦R (Some s1) (Some s2); (I::'a ⇒ bool) s1⟧ ⟹ (b1::'a ⇒ bool) s1 = (b2::'b ⇒ bool) s2; ⋀(s1::'a) s2::'b. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some ((c1::'a ⇒ 'a) s1)) (Some ((c2::'b ⇒ 'b) s2)); I s1; ⋀s1::'a. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<k::nat. b1 ((c1 ^^ k') s1)⟧ ⟹ b1 ((c1 ^^ k) s1) = b2 ((c2 ^^ k) s2)› 2. ‹⟦(R::'a option ⇒ 'b option ⇒ bool) (Some (s1::'a)) (Some (s2::'b)); ⋀(s1::'a) s2::'b. ⟦R (Some s1) (Some s2); (I::'a ⇒ bool) s1⟧ ⟹ (b1::'a ⇒ bool) s1 = (b2::'b ⇒ bool) s2; ⋀(s1::'a) s2::'b. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some ((c1::'a ⇒ 'a) s1)) (Some ((c2::'b ⇒ 'b) s2)); I s1; ⋀s1::'a. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<k::nat. b1 ((c1 ^^ k') s1)⟧ ⟹ I ((c1 ^^ k) s1)› 3. ‹⟦(R::'a option ⇒ 'b option ⇒ bool) (Some (s1::'a)) (Some (s2::'b)); ⋀(s1::'a) s2::'b. ⟦R (Some s1) (Some s2); (I::'a ⇒ bool) s1⟧ ⟹ (b1::'a ⇒ bool) s1 = (b2::'b ⇒ bool) s2; ⋀(s1::'a) s2::'b. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some ((c1::'a ⇒ 'a) s1)) (Some ((c2::'b ⇒ 'b) s2)); I s1; ⋀s1::'a. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<k::nat. b1 ((c1 ^^ k') s1)⟧ ⟹ R (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2))› discuss goal 1*) apply (induction k) (*goals: 1. ‹⟦R (Some s1) (Some s2); ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1⟧ ⟹ b1 s1 = b2 s2; ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2)); I s1; ⋀s1. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<0. b1 ((c1 ^^ k') s1)⟧ ⟹ b1 ((c1 ^^ 0) s1) = b2 ((c2 ^^ 0) s2)› 2. ‹⋀k. ⟦⟦R (Some s1) (Some s2); ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1⟧ ⟹ b1 s1 = b2 s2; ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2)); I s1; ⋀s1. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<k. b1 ((c1 ^^ k') s1)⟧ ⟹ b1 ((c1 ^^ k) s1) = b2 ((c2 ^^ k) s2); R (Some s1) (Some s2); ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1⟧ ⟹ b1 s1 = b2 s2; ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2)); I s1; ⋀s1. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<Suc k. b1 ((c1 ^^ k') s1)⟧ ⟹ b1 ((c1 ^^ Suc k) s1) = b2 ((c2 ^^ Suc k) s2)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goals: 1. ‹⋀k. ⟦b2 ((c2 ^^ k) s2); R (Some s1) (Some s2); ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1⟧ ⟹ b1 s1 = b2 s2; ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1; b2 s2⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2)); I s1; ⋀s1. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<Suc k. b1 ((c1 ^^ k') s1); b1 (c1 ((c1 ^^ k) s1))⟧ ⟹ b2 (c2 ((c2 ^^ k) s2))› 2. ‹⋀k. ⟦b2 ((c2 ^^ k) s2); R (Some s1) (Some s2); ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1⟧ ⟹ b1 s1 = b2 s2; ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1; b2 s2⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2)); I s1; ⋀s1. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<Suc k. b1 ((c1 ^^ k') s1); b2 (c2 ((c2 ^^ k) s2))⟧ ⟹ b1 (c1 ((c1 ^^ k) s1))› discuss goal 1*) apply ((msorry)[1]) (*discuss goal 2*) apply ((msorry)[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) (*discuss goal 2*) apply ((auto)[1]) (*top goal: ‹⟦(R::'a::type option ⇒ 'b::type option ⇒ bool) (Some (s1::'a::type)) (Some (s2::'b::type)); ⋀(s1::'a::type) s2::'b::type. ⟦R (Some s1) (Some s2); (I::'a::type ⇒ bool) s1⟧ ⟹ (b1::'a::type ⇒ bool) s1 = (b2::'b::type ⇒ bool) s2; ⋀(s1::'a::type) s2::'b::type. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some ((c1::'a::type ⇒ 'a::type) s1)) (Some ((c2::'b::type ⇒ 'b::type) s2)); I s1; ⋀s1::'a::type. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<k::nat. b1 ((c1 ^^ k') s1)⟧ ⟹ I ((c1 ^^ k) s1)› and 1 goal remains*) apply ((msorry)[1]) (*discuss goal 3*) apply ((auto)[1]) (*goal: ‹⟦R (Some s1) (Some s2); ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1⟧ ⟹ b1 s1 = b2 s2; ⋀s1 s2. ⟦R (Some s1) (Some s2); I s1; b1 s1⟧ ⟹ R (Some (c1 s1)) (Some (c2 s2)); I s1; ⋀s1. ⟦I s1; b1 s1⟧ ⟹ I (c1 s1); ∀k'<k. b1 ((c1 ^^ k') s1)⟧ ⟹ R (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2))›*) apply ((msorry)[1]) (*proven 3 subgoals*) . } moreover { fix k assume "¬ b1 ((c1 ^^ k) s1)" (*‹¬ (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ (k::nat)) (s1::'a))›*) hence "∀k' < LEAST k. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1)" by (metis (lifting) not_less_Least (*‹?k < (LEAST x. ?P x) ⟹ ¬ ?P ?k›*)) } moreover { fix k assume "¬ b2 ((c2 ^^ k) s2)" (*‹¬ (b2::'b ⇒ bool) (((c2::'b ⇒ 'b) ^^ (k::nat)) (s2::'b))›*) hence "∀k' < LEAST k. ¬ b2 ((c2 ^^ k) s2). b2 ((c2 ^^ k') s2)" by (metis (lifting) not_less_Least (*‹?k < (LEAST x. ?P x) ⟹ ¬ ?P ?k›*)) } moreover { assume "∃k. ¬ b1 ((c1 ^^ k) s1)" and "∃k. ¬ b2 ((c2 ^^ k) s2)" (*‹∃k::nat. ¬ (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ k) (s1::'a))› ‹∃k::nat. ¬ (b2::'b ⇒ bool) (((c2::'b ⇒ 'b) ^^ k) (s2::'b))›*) hence not_cond_Least: "¬ b1 ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1)" "¬ b2 ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2)" apply - (*top goal: ‹¬ (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ (LEAST k::nat. ¬ b1 ((c1 ^^ k) (s1::'a)))) s1)› and 1 goal remains*) by ((drule LeastI_ex (*‹∃x. ?P x ⟹ ?P (Least ?P)›*), assumption)+) { fix k assume "∀k' < k. b1 ((c1 ^^ k') s1)" (*‹∀k'<k::nat. (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ k') (s1::'a))›*) with calculation(1) (*‹∀k'<?k2. b1 ((c1 ^^ k') s1) ⟹ b1 ((c1 ^^ ?k2) s1) = b2 ((c2 ^^ ?k2) s2)›*) dual_order.strict_trans (*‹⟦?b < ?a; ?c < ?b⟧ ⟹ ?c < ?a›*) have "∀k' < k. b2 ((c2 ^^ k') s2)" by blast } hence "(LEAST k'. ¬ b1 ((c1 ^^ k') s1)) = (LEAST k'. ¬ b2 ((c2 ^^ k') s2))" by (metis (no_types, lifting) not_cond_Least (*‹¬ b1 ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1)› ‹¬ b2 ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2)›*) calculation( (*‹∀k'<?k2. b1 ((c1 ^^ k') s1) ⟹ b1 ((c1 ^^ ?k2) s1) = b2 ((c2 ^^ ?k2) s2)› ‹¬ b1 ((c1 ^^ ?k2) s1) ⟹ ∀k'<LEAST k. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1)› ‹¬ b2 ((c2 ^^ ?k2) s2) ⟹ ∀k'<LEAST k. ¬ b2 ((c2 ^^ k) s2). b2 ((c2 ^^ k') s2)›*) 1,4,5) less_linear (*‹?x < ?y ∨ ?x = ?y ∨ ?y < ?x›*)) with calculation(3,4) (*‹∀k'<?k2. b1 ((c1 ^^ k') s1) ⟹ R (Some ((c1 ^^ ?k2) s1)) (Some ((c2 ^^ ?k2) s2))› ‹¬ b1 ((c1 ^^ ?k2) s1) ⟹ ∀k'<LEAST k. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1)›*) have "R (Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1)) (Some ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2))" by auto } ultimately show "?thesis" (*goal: ‹R (while_option b1 c1 s1) (while_option b2 c2 s2)›*) using diverge (*‹R None None›*) unfolding while_option_def (*goal: ‹(R::'a::type option ⇒ 'b::type option ⇒ bool) (if ∃k::nat. ¬ (b1::'a::type ⇒ bool) (((c1::'a::type ⇒ 'a::type) ^^ k) (s1::'a::type)) then Some ((c1 ^^ (LEAST k::nat. ¬ b1 ((c1 ^^ k) s1))) s1) else None) (if ∃k::nat. ¬ (b2::'b::type ⇒ bool) (((c2::'b::type ⇒ 'b::type) ^^ k) (s2::'b::type)) then Some ((c2 ^^ (LEAST k::nat. ¬ b2 ((c2 ^^ k) s2))) s2) else None)›*) apply (split if_split) (*goal: ‹(R::'a option ⇒ 'b option ⇒ bool) (if ∃k::nat. ¬ (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ k) (s1::'a)) then Some ((c1 ^^ (LEAST k::nat. ¬ b1 ((c1 ^^ k) s1))) s1) else None) (if ∃k::nat. ¬ (b2::'b ⇒ bool) (((c2::'b ⇒ 'b) ^^ k) (s2::'b)) then Some ((c2 ^^ (LEAST k::nat. ¬ b2 ((c2 ^^ k) s2))) s2) else None)›*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⟦⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ b1 ((c1 ^^ k) s1) = b2 ((c2 ^^ k) s2); ⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ I ((c1 ^^ k) s1); ⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ R (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2)); ⋀k. ¬ b1 ((c1 ^^ k) s1) ⟹ ∀k'<LEAST k. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1); ⋀k. ¬ b2 ((c2 ^^ k) s2) ⟹ ∀k'<LEAST k. ¬ b2 ((c2 ^^ k) s2). b2 ((c2 ^^ k') s2); ⟦∃k. ¬ b1 ((c1 ^^ k) s1); ∃k. ¬ b2 ((c2 ^^ k) s2)⟧ ⟹ R (Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1)) (Some ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2)); R None None⟧ ⟹ (∃k. ¬ b2 ((c2 ^^ k) s2)) ⟶ R (if ∃k. ¬ b1 ((c1 ^^ k) s1) then Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1) else None) (Some ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2))› 2. ‹⟦⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ b1 ((c1 ^^ k) s1) = b2 ((c2 ^^ k) s2); ⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ I ((c1 ^^ k) s1); ⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ R (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2)); ⋀k. ¬ b1 ((c1 ^^ k) s1) ⟹ ∀k'<LEAST k. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1); ⋀k. ¬ b2 ((c2 ^^ k) s2) ⟹ ∀k'<LEAST k. ¬ b2 ((c2 ^^ k) s2). b2 ((c2 ^^ k') s2); ⟦∃k. ¬ b1 ((c1 ^^ k) s1); ∃k. ¬ b2 ((c2 ^^ k) s2)⟧ ⟹ R (Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1)) (Some ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2)); R None None⟧ ⟹ (∄k. ¬ b2 ((c2 ^^ k) s2)) ⟶ R (if ∃k. ¬ b1 ((c1 ^^ k) s1) then Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1) else None) None› discuss goal 1*) apply (split if_split) (*top goal: ‹⟦⋀k::nat. ∀k'<k. (b1::'a ⇒ bool) (((c1::'a ⇒ 'a) ^^ k') (s1::'a)) ⟹ b1 ((c1 ^^ k) s1) = (b2::'b ⇒ bool) (((c2::'b ⇒ 'b) ^^ k) (s2::'b)); ⋀k::nat. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ (I::'a ⇒ bool) ((c1 ^^ k) s1); ⋀k::nat. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ (R::'a option ⇒ 'b option ⇒ bool) (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2)); ⋀k::nat. ¬ b1 ((c1 ^^ k) s1) ⟹ ∀k'<LEAST k::nat. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1); ⋀k::nat. ¬ b2 ((c2 ^^ k) s2) ⟹ ∀k'<LEAST k::nat. ¬ b2 ((c2 ^^ k) s2). b2 ((c2 ^^ k') s2); ⟦∃k::nat. ¬ b1 ((c1 ^^ k) s1); ∃k::nat. ¬ b2 ((c2 ^^ k) s2)⟧ ⟹ R (Some ((c1 ^^ (LEAST k::nat. ¬ b1 ((c1 ^^ k) s1))) s1)) (Some ((c2 ^^ (LEAST k::nat. ¬ b2 ((c2 ^^ k) s2))) s2)); R None None⟧ ⟹ (∃k::nat. ¬ b2 ((c2 ^^ k) s2)) ⟶ R (if ∃k::nat. ¬ b1 ((c1 ^^ k) s1) then Some ((c1 ^^ (LEAST k::nat. ¬ b1 ((c1 ^^ k) s1))) s1) else None) (Some ((c2 ^^ (LEAST k::nat. ¬ b2 ((c2 ^^ k) s2))) s2))› and 1 goal remains*) apply metis (*discuss goal 2*) apply (split if_split) (*goal: ‹⟦⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ b1 ((c1 ^^ k) s1) = b2 ((c2 ^^ k) s2); ⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ I ((c1 ^^ k) s1); ⋀k. ∀k'<k. b1 ((c1 ^^ k') s1) ⟹ R (Some ((c1 ^^ k) s1)) (Some ((c2 ^^ k) s2)); ⋀k. ¬ b1 ((c1 ^^ k) s1) ⟹ ∀k'<LEAST k. ¬ b1 ((c1 ^^ k) s1). b1 ((c1 ^^ k') s1); ⋀k. ¬ b2 ((c2 ^^ k) s2) ⟹ ∀k'<LEAST k. ¬ b2 ((c2 ^^ k) s2). b2 ((c2 ^^ k') s2); ⟦∃k. ¬ b1 ((c1 ^^ k) s1); ∃k. ¬ b2 ((c2 ^^ k) s2)⟧ ⟹ R (Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1)) (Some ((c2 ^^ (LEAST k. ¬ b2 ((c2 ^^ k) s2))) s2)); R None None⟧ ⟹ (∄k. ¬ b2 ((c2 ^^ k) s2)) ⟶ R (if ∃k. ¬ b1 ((c1 ^^ k) s1) then Some ((c1 ^^ (LEAST k. ¬ b1 ((c1 ^^ k) s1))) s1) else None) None›*) apply (metis (lifting) LeastI_ex (*‹∃x. ?P x ⟹ ?P (Least ?P)›*)) (*proven 2 subgoals*) . qed end
{ "path": "afp-2025-02-12/thys/Formal_SSA/While_Combinator_Exts.thy", "repo": "afp-2025-02-12", "sha": "aaeb392a527292bbd1c376b003f5f4cf365c76e587a44ec00997c7eea9337619" }
(* Title: Parallel_Compositionality.thy Author: Andreas Viktor Hess, DTU Author: Sebastian A. Mödersheim, DTU Author: Achim D. Brucker, The University of Sheffield SPDX-License-Identifier: BSD-3-Clause *) section ‹Parallel Compositionality of Security Protocols› theory Parallel_Compositionality imports Typing_Result Labeled_Strands begin text‹\label{sec:Parallel-Compositionality}› subsection ‹Definitions: Labeled Typed Model Locale› locale labeled_typed_model = typed_model arity public Ana Γ for arity::"'fun ⇒ nat" and public::"'fun ⇒ bool" and Ana::"('fun,'var) term ⇒ (('fun,'var) term list × ('fun,'var) term list)" and Γ::"('fun,'var) term ⇒ ('fun,'atom::finite) term_type" + fixes label_witness1 and label_witness2::"'lbl" assumes at_least_2_labels: "label_witness1 ≠ label_witness2" begin text ‹The Ground Sub-Message Patterns (GSMP)› definition GSMP::"('fun,'var) terms ⇒ ('fun,'var) terms" where "GSMP P ≡ {t ∈ SMP P. fv t = {}}" definition typing_cond where "typing_cond 𝒜 ≡ wf⇩s⇩t {} 𝒜 ∧ fv⇩s⇩t 𝒜 ∩ bvars⇩s⇩t 𝒜 = {} ∧ tfr⇩s⇩t 𝒜 ∧ wf⇩t⇩r⇩m⇩s (trms⇩s⇩t 𝒜) ∧ Ana_invar_subst (ik⇩s⇩t 𝒜 ∪ assignment_rhs⇩s⇩t 𝒜)" subsection ‹Definitions: GSMP Disjointness and Parallel Composability› definition GSMP_disjoint where "GSMP_disjoint P1 P2 Secrets ≡ GSMP P1 ∩ GSMP P2 ⊆ Secrets ∪ {m. {} ⊢⇩c m}" definition declassified⇩l⇩s⇩t where "declassified⇩l⇩s⇩t (𝒜::('fun,'var,'lbl) labeled_strand) ℐ ≡ {s. ⋃{set ts | ts. (⋆, Receive ts) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)} ⊢ s}" definition par_comp where "par_comp (𝒜::('fun,'var,'lbl) labeled_strand) (Secrets::('fun,'var) terms) ≡ (∀l1 l2. l1 ≠ l2 ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l1 𝒜) (trms_proj⇩l⇩s⇩t l2 𝒜) Secrets) ∧ (∀s ∈ Secrets. ¬{} ⊢⇩c s) ∧ ground Secrets" definition strand_leaks⇩l⇩s⇩t where "strand_leaks⇩l⇩s⇩t 𝒜 Sec ℐ ≡ (∃t ∈ Sec - declassified⇩l⇩s⇩t 𝒜 ℐ. ∃l. (ℐ ⊨ ⟨proj_unl l 𝒜@[Send1 t]⟩))" subsection ‹Definitions: GSMP-Restricted Intruder Deduction Variant› definition intruder_deduct_hom:: "('fun,'var) terms ⇒ ('fun,'var,'lbl) labeled_strand ⇒ ('fun,'var) term ⇒ bool" ("⟨_;_⟩ ⊢⇩G⇩S⇩M⇩P _" 50) where "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t ≡ ⟨M; λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t" lemma intruder_deduct_hom_AxiomH[simp]: assumes "t ∈ M" shows "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" using intruder_deduct_restricted.AxiomR[of t M] (*‹t ∈ M ⟹ ⟨M;?Q⟩ ⊢⇩r t›*) assms (*‹t ∈ M›*) unfolding intruder_deduct_hom_def (*goal: ‹⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t›*) by blast lemma intruder_deduct_hom_ComposeH[simp]: assumes "length X = arity f" "public f" "⋀x. x ∈ set X ⟹ ⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P x" and "Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" shows "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f X" using intruder_deduct_restricted.ComposeR[of X f M "λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)"] (*‹⟦length X = arity f; public f; ⋀t. t ∈ set X ⟹ ⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t; Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ ⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r Fun f X›*) assms (*‹length (X::('fun, 'var) Term.term list) = (arity::'fun ⇒ nat) (f::'fun)› ‹(public::'fun ⇒ bool) (f::'fun)› ‹(?x2::('fun::type, 'var::type) Term.term) ∈ set (X::('fun::type, 'var::type) Term.term list) ⟹ ⟨M::('fun::type, 'var::type) Term.term set;𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P ?x2› ‹Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) unfolding intruder_deduct_hom_def (*goal: ‹⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r Fun f X›*) by blast lemma intruder_deduct_hom_DecomposeH: assumes "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" "Ana t = (K, T)" "⋀k. k ∈ set K ⟹ ⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P k" "t⇩i ∈ set T" shows "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i" using intruder_deduct_restricted.DecomposeR[of M "λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" t] (*‹⟦⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t; Ana t = (?K, ?T); ⋀k. k ∈ set ?K ⟹ ⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r k; ?t⇩i ∈ set ?T⟧ ⟹ ⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r ?t⇩i›*) assms (*‹⟨M::('fun, 'var) Term.term set;𝒜::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P t::('fun, 'var) Term.term› ‹Ana t = (K, T)› ‹?k2 ∈ set K ⟹ ⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?k2› ‹(t⇩i::('fun, 'var) Term.term) ∈ set (T::('fun, 'var) Term.term list)›*) unfolding intruder_deduct_hom_def (*goal: ‹⟨M::('fun, 'var) Term.term set;λt::('fun, 'var) Term.term. t ∈ GSMP (trms⇩l⇩s⇩t (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list))⟩ ⊢⇩r t⇩i::('fun, 'var) Term.term›*) by blast lemma intruder_deduct_hom_induct[consumes 1, case_names AxiomH ComposeH DecomposeH]: assumes "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" "⋀t. t ∈ M ⟹ P M t" "⋀X f. ⟦length X = arity f; public f; ⋀x. x ∈ set X ⟹ ⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set X ⟹ P M x; Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜) ⟧ ⟹ P M (Fun f X)" "⋀t K T t⇩i. ⟦⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; P M t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ P M k; t⇩i ∈ set T⟧ ⟹ P M t⇩i" shows "P M t" using intruder_deduct_restricted_induct[of M "λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" t "λM Q t. P M t"] (*‹⟦⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t; ⋀t. t ∈ M ⟹ P M t; ⋀T f. ⟦length T = arity f; public f; ⋀t. t ∈ set T ⟹ ⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t; ⋀t. t ∈ set T ⟹ P M t; Fun f T ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ P M (Fun f T); ⋀t K T t⇩i. ⟦⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t; P M t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r k; ⋀k. k ∈ set K ⟹ P M k; t⇩i ∈ set T⟧ ⟹ P M t⇩i⟧ ⟹ P M t›*) assms (*‹⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t› ‹(?t2::('fun, 'var) Term.term) ∈ (M::('fun, 'var) Term.term set) ⟹ (P::('fun, 'var) Term.term set ⇒ ('fun, 'var) Term.term ⇒ bool) M ?t2› ‹⟦length ?X2 = arity ?f2; public ?f2; ⋀x. x ∈ set ?X2 ⟹ ⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set ?X2 ⟹ P M x; Fun ?f2 ?X2 ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ P M (Fun ?f2 ?X2)› ‹⟦⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?t2; P M ?t2; Ana ?t2 = (?K2, ?T2); ⋀k. k ∈ set ?K2 ⟹ ⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set ?K2 ⟹ P M k; ?t⇩i2 ∈ set ?T2⟧ ⟹ P M ?t⇩i2›*) unfolding intruder_deduct_hom_def (*goal: ‹P M t›*) by blast lemma ideduct_hom_mono: "⟦⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; M ⊆ M'⟧ ⟹ ⟨M'; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" using ideduct_restricted_mono[of M _ t M'] (*‹⟦⟨M;?P⟩ ⊢⇩r t; M ⊆ M'⟧ ⟹ ⟨M';?P⟩ ⊢⇩r t›*) unfolding intruder_deduct_hom_def (*goal: ‹⟦⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t; M ⊆ M'⟧ ⟹ ⟨M';λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t›*) by fast subsection ‹Lemmata: GSMP› lemma GSMP_disjoint_empty[simp]: "GSMP_disjoint {} A Sec" "GSMP_disjoint A {} Sec" unfolding GSMP_disjoint_def GSMP_def (*goals: 1. ‹{t ∈ SMP {}. fv t = {}} ∩ {t ∈ SMP A. fv t = {}} ⊆ Sec ∪ {m. {} ⊢⇩c m}› 2. ‹{t ∈ SMP A. fv t = {}} ∩ {t ∈ SMP {}. fv t = {}} ⊆ Sec ∪ {m. {} ⊢⇩c m}›*) (*goals: 1. ‹{t ∈ SMP {}. fv t = {}} ∩ {t ∈ SMP A. fv t = {}} ⊆ Sec ∪ {m. {} ⊢⇩c m}› 2. ‹{t ∈ SMP A. fv t = {}} ∩ {t ∈ SMP {}. fv t = {}} ⊆ Sec ∪ {m. {} ⊢⇩c m}› discuss goal 1*) apply fastforce (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . lemma GSMP_mono: assumes "N ⊆ M" shows "GSMP N ⊆ GSMP M" using SMP_mono[OF assms] (*‹SMP N ⊆ SMP M›*) unfolding GSMP_def (*goal: ‹{t ∈ SMP N. fv t = {}} ⊆ {t ∈ SMP M. fv t = {}}›*) by fast lemma GSMP_SMP_mono: assumes "SMP N ⊆ SMP M" shows "GSMP N ⊆ GSMP M" using assms (*‹SMP N ⊆ SMP M›*) unfolding GSMP_def (*goal: ‹{t ∈ SMP N. fv t = {}} ⊆ {t ∈ SMP M. fv t = {}}›*) by fast lemma GSMP_subterm: assumes "t ∈ GSMP M" "t' ⊑ t" shows "t' ∈ GSMP M" using SMP.Subterm[of t M t'] (*‹⟦t ∈ SMP M; t' ⊑ t⟧ ⟹ t' ∈ SMP M›*) ground_subterm[of t t'] (*‹⟦fv t = {}; t' ⊑ t⟧ ⟹ fv t' = {}›*) assms (*‹t ∈ GSMP M› ‹(t'::('fun::type, 'var::type) Term.term) ⊑ (t::('fun::type, 'var::type) Term.term)›*) unfolding GSMP_def (*goal: ‹t' ∈ {t ∈ SMP M. fv t = {}}›*) by auto lemma GSMP_subterms: "subterms⇩s⇩e⇩t (GSMP M) = GSMP M" using GSMP_subterm[of _ M] (*‹⟦(?t::('fun, 'var) Term.term) ∈ GSMP (M::('fun, 'var) Term.term set); (?t'::('fun, 'var) Term.term) ⊑ ?t⟧ ⟹ ?t' ∈ GSMP M›*) by blast lemma GSMP_Ana_key: assumes "t ∈ GSMP M" "Ana t = (K,T)" "k ∈ set K" shows "k ∈ GSMP M" using SMP.Ana[of t M K T k] (*‹⟦t ∈ SMP M; Ana t = (K, T); k ∈ set K⟧ ⟹ k ∈ SMP M›*) Ana_keys_fv[of t K T] (*‹(Ana::('fun::type, 'var::type) Term.term ⇒ ('fun::type, 'var::type) Term.term list × ('fun::type, 'var::type) Term.term list) (t::('fun::type, 'var::type) Term.term) = (K::('fun::type, 'var::type) Term.term list, T::('fun::type, 'var::type) Term.term list) ⟹ fv⇩s⇩e⇩t (set K) ⊆ fv t›*) assms (*‹t ∈ GSMP M› ‹Ana t = (K, T)› ‹k ∈ set K›*) unfolding GSMP_def (*goal: ‹k ∈ {t ∈ SMP M. fv t = {}}›*) by auto lemma GSMP_union: "GSMP (A ∪ B) = GSMP A ∪ GSMP B" using SMP_union[of A B] (*‹SMP ((A::('fun::type, 'var::type) Term.term set) ∪ (B::('fun::type, 'var::type) Term.term set)) = SMP A ∪ SMP B›*) unfolding GSMP_def (*goal: ‹{t ∈ SMP (A ∪ B). fv t = {}} = {t ∈ SMP A. fv t = {}} ∪ {t ∈ SMP B. fv t = {}}›*) by auto lemma GSMP_Union: "GSMP (trms⇩l⇩s⇩t A) = (⋃l. GSMP (trms_proj⇩l⇩s⇩t l A))" proof (-) (*goal: ‹GSMP (trms⇩l⇩s⇩t A) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l A)))›*) define P where "P ≡ (λl. trms_proj⇩l⇩s⇩t l A)" define Q where "Q ≡ trms⇩l⇩s⇩t A" have "SMP (⋃l. P l) = (⋃l. SMP (P l))" "Q = (⋃l. P l)" unfolding P_def Q_def (*goals: 1. ‹SMP (⋃l::'a::type. trms⇩l⇩s⇩t (proj l (A::('a::type strand_label × ('fun::type, 'var::type) strand_step) list))) = (⋃l::'a::type. SMP (trms⇩l⇩s⇩t (proj l A)))› 2. ‹trms⇩l⇩s⇩t (A::('a::type strand_label × ('fun::type, 'var::type) strand_step) list) = (⋃l::'a::type. trms⇩l⇩s⇩t (proj l A))›*) (*goals: 1. ‹SMP (⋃l. trms⇩l⇩s⇩t (proj l A)) = (⋃l. SMP (trms⇩l⇩s⇩t (proj l A)))› 2. ‹trms⇩l⇩s⇩t A = (⋃l. trms⇩l⇩s⇩t (proj l A))› discuss goal 1*) apply (metis SMP_Union (*‹SMP (⋃ (?f ` ?M)) = (⋃m∈?M. SMP (?f m))›*)) (*discuss goal 2*) apply (metis trms⇩l⇩s⇩t_union (*‹trms⇩l⇩s⇩t (?A::(?'c::type strand_label × (?'a::type, ?'b::type) strand_step) list) = (⋃l::?'c::type. trms⇩l⇩s⇩t (proj l ?A))›*)) (*proven 2 subgoals*) . hence "GSMP Q = (⋃l. GSMP (P l))" unfolding GSMP_def (*goal: ‹{t::('fun, 'var) Term.term ∈ SMP (Q::('fun, 'var) Term.term set). fv t = {}} = (⋃l::'a. {t::('fun, 'var) Term.term ∈ SMP ((P::'a ⇒ ('fun, 'var) Term.term set) l). fv t = {}})›*) by auto thus "?thesis" (*goal: ‹GSMP (trms⇩l⇩s⇩t A) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l A)))›*) unfolding P_def Q_def (*goal: ‹GSMP (trms⇩l⇩s⇩t A) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l A)))›*) by metis qed lemma in_GSMP_in_proj: "t ∈ GSMP (trms⇩l⇩s⇩t A) ⟹ ∃n. t ∈ GSMP (trms_proj⇩l⇩s⇩t n A)" using GSMP_Union[of A] (*‹GSMP (trms⇩l⇩s⇩t A) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l A)))›*) by blast lemma in_proj_in_GSMP: "t ∈ GSMP (trms_proj⇩l⇩s⇩t n A) ⟹ t ∈ GSMP (trms⇩l⇩s⇩t A)" using GSMP_Union[of A] (*‹GSMP (trms⇩l⇩s⇩t A) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l A)))›*) by blast lemma GSMP_disjointE: assumes A: "GSMP_disjoint (trms_proj⇩l⇩s⇩t n A) (trms_proj⇩l⇩s⇩t m A) Sec" shows "GSMP (trms_proj⇩l⇩s⇩t n A) ∩ GSMP (trms_proj⇩l⇩s⇩t m A) ⊆ Sec ∪ {m. {} ⊢⇩c m}" using assms (*‹GSMP_disjoint (trms⇩l⇩s⇩t (proj n A)) (trms⇩l⇩s⇩t (proj m A)) Sec›*) unfolding GSMP_disjoint_def (*goal: ‹GSMP (trms⇩l⇩s⇩t (proj n A)) ∩ GSMP (trms⇩l⇩s⇩t (proj m A)) ⊆ Sec ∪ {m. {} ⊢⇩c m}›*) by auto lemma GSMP_disjoint_term: assumes "GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" shows "t ∉ GSMP (trms_proj⇩l⇩s⇩t l 𝒜) ∨ t ∉ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜) ∨ t ∈ Sec ∨ {} ⊢⇩c t" using assms (*‹GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec›*) unfolding GSMP_disjoint_def (*goal: ‹t ∉ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∨ t ∉ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)) ∨ t ∈ Sec ∨ {} ⊢⇩c t›*) by blast lemma GSMP_wt_subst_subset: assumes "t ∈ GSMP (M ⋅⇩s⇩e⇩t ℐ)" "wt⇩s⇩u⇩b⇩s⇩t ℐ" "wf⇩t⇩r⇩m⇩s (subst_range ℐ)" shows "t ∈ GSMP M" using SMP_wt_subst_subset[OF _ assms ( 2 , 3 ), of t M] (*‹t ∈ SMP (M ⋅⇩s⇩e⇩t ℐ) ⟹ t ∈ SMP M›*) assms(1) (*‹t ∈ GSMP (M ⋅⇩s⇩e⇩t ℐ)›*) unfolding GSMP_def (*goal: ‹t ∈ {t ∈ SMP M. fv t = {}}›*) by simp lemma GSMP_wt_substI: assumes "t ∈ M" "wt⇩s⇩u⇩b⇩s⇩t I" "wf⇩t⇩r⇩m⇩s (subst_range I)" "interpretation⇩s⇩u⇩b⇩s⇩t I" shows "t ⋅ I ∈ GSMP M" proof (-) (*goal: ‹t ⋅ I ∈ GSMP M›*) have "t ∈ SMP M" using assms(1) (*‹t ∈ M›*) by auto hence "*": "t ⋅ I ∈ SMP M" using SMP.Substitution (*‹⟦?t ∈ SMP ?M; wt⇩s⇩u⇩b⇩s⇩t ?δ; wf⇩t⇩r⇩m⇩s (subst_range ?δ)⟧ ⟹ ?t ⋅ ?δ ∈ SMP ?M›*) assms(2,3) (*‹wt⇩s⇩u⇩b⇩s⇩t I› ‹wf⇩t⇩r⇩m⇩s (subst_range I)›*) wf_trm_subst_range_iff[of I] (*‹(∀x. wf⇩t⇩r⇩m (I x)) = wf⇩t⇩r⇩m⇩s (subst_range I)›*) by simp moreover have "fv (t ⋅ I) = {}" using assms(1) (*‹t ∈ M›*) interpretation_grounds_all'[OF assms ( 4 )] (*‹Messages.ground (?M ⋅⇩s⇩e⇩t I)›*) by auto ultimately show "?thesis" (*goal: ‹t ⋅ I ∈ GSMP M›*) unfolding GSMP_def (*goal: ‹t ⋅ I ∈ {t ∈ SMP M. fv t = {}}›*) by simp qed lemma GSMP_disjoint_subset: assumes "GSMP_disjoint L R S" "L' ⊆ L" "R' ⊆ R" shows "GSMP_disjoint L' R' S" using assms(1) (*‹GSMP_disjoint (L::('fun, 'var) Term.term set) (R::('fun, 'var) Term.term set) (S::('fun, 'var) Term.term set)›*) SMP_mono[OF assms ( 2 )] (*‹SMP L' ⊆ SMP L›*) SMP_mono[OF assms ( 3 )] (*‹SMP R' ⊆ SMP R›*) by (auto simp add: GSMP_def (*‹GSMP ?P ≡ {t ∈ SMP ?P. fv t = {}}›*) GSMP_disjoint_def (*‹GSMP_disjoint ?P1.0 ?P2.0 ?Secrets ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m. {} ⊢⇩c m}›*)) subsection ‹Lemmata: Intruder Knowledge and Declassification› lemma declassified⇩l⇩s⇩t_alt_def: "declassified⇩l⇩s⇩t 𝒜 ℐ = {s. (⋃{set ts | ts. (⋆, Receive ts) ∈ set 𝒜}) ⋅⇩s⇩e⇩t ℐ ⊢ s}" proof (-) (*goal: ‹declassified⇩l⇩s⇩t 𝒜 ℐ = {s. ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) have 0: "(l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ) = (∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ)" (is "?A 𝒜 = ?B 𝒜") for ts and l proof (standard) (*goals: 1. ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› 2. ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)›*) show "?A 𝒜 ⟹ ?B 𝒜" proof (induction 𝒜) (*goals: 1. ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) []) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set [] ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› 2. ‹⋀a 𝒜. ⟦(l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) 𝒜) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ; (l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) (a # 𝒜))⟧ ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) case (Cons a 𝒜) (*‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› ‹(l::'lbl::type strand_label, receive⟨ts::('fun::type, 'var::type) Term.term list⟩⇩s⇩t) ∈ set ((a::'lbl::type strand_label × ('fun::type, 'var::type) strand_step) # (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) ⋅⇩l⇩s⇩t (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term))›*) obtain k and b where a: "a = (k,b)" (*goal: ‹(⋀k b. a = (k, b) ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) show "?case" (*goal: ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) proof (cases "?A 𝒜") (*goals: 1. ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› 2. ‹(l, receive⟨ts⟩⇩s⇩t) ∉ set (𝒜 ⋅⇩l⇩s⇩t ℐ) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) case False (*‹(l, receive⟨ts⟩⇩s⇩t) ∉ set (𝒜 ⋅⇩l⇩s⇩t ℐ)›*) hence "(l,receive⟨ts⟩⇩s⇩t) = a ⋅⇩l⇩s⇩t⇩p ℐ" using Cons.prems (*‹(l::'lbl::type strand_label, receive⟨ts::('fun::type, 'var::type) Term.term list⟩⇩s⇩t) ∈ set ((a::'lbl::type strand_label × ('fun::type, 'var::type) strand_step) # (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) ⋅⇩l⇩s⇩t (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term))›*) by auto thus "?thesis" (*goal: ‹∃ts'::('fun::type, 'var::type) Term.term list. (l::'lbl::type strand_label, receive⟨ts'⟩⇩s⇩t) ∈ set ((a::'lbl::type strand_label × ('fun::type, 'var::type) strand_step) # (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)) ∧ (ts::('fun::type, 'var::type) Term.term list) = ts' ⋅⇩l⇩i⇩s⇩t (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term)›*) unfolding a (*goal: ‹∃ts'::('fun, 'var) Term.term list. (l::'lbl strand_label, receive⟨ts'⟩⇩s⇩t) ∈ set ((k::'lbl strand_label, b::('fun, 'var) strand_step) # (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)) ∧ (ts::('fun, 'var) Term.term list) = ts' ⋅⇩l⇩i⇩s⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term)›*) apply (cases b) (*goals: 1. ‹⋀x1. ⟦(l, receive⟨ts⟩⇩s⇩t) = (k, b) ⋅⇩l⇩s⇩t⇩p ℐ; b = send⟨x1⟩⇩s⇩t⟧ ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set ((k, b) # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› 2. ‹⋀x2. ⟦(l, receive⟨ts⟩⇩s⇩t) = (k, b) ⋅⇩l⇩s⇩t⇩p ℐ; b = receive⟨x2⟩⇩s⇩t⟧ ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set ((k, b) # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› 3. ‹⋀x31 x32 x33. ⟦(l, receive⟨ts⟩⇩s⇩t) = (k, b) ⋅⇩l⇩s⇩t⇩p ℐ; b = ⟨x31: x32 ≐ x33⟩⇩s⇩t⟧ ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set ((k, b) # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› 4. ‹⋀x41 x42. ⟦(l, receive⟨ts⟩⇩s⇩t) = (k, b) ⋅⇩l⇩s⇩t⇩p ℐ; b = ∀x41⟨∨≠: x42⟩⇩s⇩t⟧ ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set ((k, b) # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed (use Cons.IH in auto) (*solved the remaining goal: ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) qed (simp) (*solved the remaining goal: ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) []) ⟹ ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set [] ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) show "?B 𝒜 ⟹ ?A 𝒜" proof (induction 𝒜) (*goals: 1. ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set [] ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) [])› 2. ‹⋀a 𝒜. ⟦∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) 𝒜); ∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ⟧ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) (a # 𝒜))›*) case (Cons a 𝒜) (*‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)› ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set (a # 𝒜) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) obtain k and b where a: "a = (k,b)" (*goal: ‹(⋀k b. a = (k, b) ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) show "?case" (*goal: ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (a # 𝒜 ⋅⇩l⇩s⇩t ℐ)›*) proof (cases "?B 𝒜") (*goals: 1. ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (a # 𝒜 ⋅⇩l⇩s⇩t ℐ)› 2. ‹∄ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (a # 𝒜 ⋅⇩l⇩s⇩t ℐ)›*) case False (*‹∄ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ›*) hence "∃ts'. a = (l, receive⟨ts'⟩⇩s⇩t) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ" using Cons.prems (*‹∃ts'::('fun::type, 'var::type) Term.term list. (l::'lbl::type strand_label, receive⟨ts'⟩⇩s⇩t) ∈ set ((a::'lbl::type strand_label × ('fun::type, 'var::type) strand_step) # (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)) ∧ (ts::('fun::type, 'var::type) Term.term list) = ts' ⋅⇩l⇩i⇩s⇩t (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term)›*) by auto thus "?thesis" (*goal: ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set (a # 𝒜 ⋅⇩l⇩s⇩t ℐ)›*) unfolding a (*goal: ‹(l, receive⟨ts⟩⇩s⇩t) ∈ set ((k, b) # 𝒜 ⋅⇩l⇩s⇩t ℐ)›*) apply (cases b) (*goals: 1. ‹⋀x1. ⟦∃ts'. (k, b) = (l, receive⟨ts'⟩⇩s⇩t) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ; b = send⟨x1⟩⇩s⇩t⟧ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set ((k, b) # 𝒜 ⋅⇩l⇩s⇩t ℐ)› 2. ‹⋀x2. ⟦∃ts'. (k, b) = (l, receive⟨ts'⟩⇩s⇩t) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ; b = receive⟨x2⟩⇩s⇩t⟧ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set ((k, b) # 𝒜 ⋅⇩l⇩s⇩t ℐ)› 3. ‹⋀x31 x32 x33. ⟦∃ts'. (k, b) = (l, receive⟨ts'⟩⇩s⇩t) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ; b = ⟨x31: x32 ≐ x33⟩⇩s⇩t⟧ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set ((k, b) # 𝒜 ⋅⇩l⇩s⇩t ℐ)› 4. ‹⋀x41 x42. ⟦∃ts'. (k, b) = (l, receive⟨ts'⟩⇩s⇩t) ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ; b = ∀x41⟨∨≠: x42⟩⇩s⇩t⟧ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set ((k, b) # 𝒜 ⋅⇩l⇩s⇩t ℐ)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . qed (use Cons.IH in auto) (*solved the remaining goal: ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (a # 𝒜 ⋅⇩l⇩s⇩t ℐ)›*) qed (simp) (*solved the remaining goal: ‹∃ts'. (l, receive⟨ts'⟩⇩s⇩t) ∈ set [] ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ ⟹ (l, receive⟨ts⟩⇩s⇩t) ∈ set (map (λ(l, s). (l, s ⋅⇩s⇩t⇩p ℐ)) [])›*) qed let ?M = "λA. ⋃{set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A}" have 1: "?M (𝒜 ⋅⇩l⇩s⇩t ℐ) = ?M 𝒜 ⋅⇩s⇩e⇩t ℐ" (is "?A = ?B") proof (standard) (*goals: 1. ‹⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set ((𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) ⋅⇩l⇩s⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term))} ⊆ ⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ› 2. ‹⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)} ⋅⇩s⇩e⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term) ⊆ ⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)}›*) show "?A ⊆ ?B" proof (standard) (*goal: ‹⋀x. x ∈ ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)} ⟹ x ∈ ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ›*) fix t assume t: "t ∈ ?A" (*‹(t::('fun, 'var) Term.term) ∈ ⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set ((𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) ⋅⇩l⇩s⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term))}›*) then obtain ts where ts: "t ∈ set ts" "(⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)" (*goal: ‹(⋀ts::('fun, 'var) Term.term list. ⟦(t::('fun, 'var) Term.term) ∈ set ts; (⋆, receive⟨ts⟩⇩s⇩t) ∈ set ((𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) ⋅⇩l⇩s⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term))⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast thus "t ∈ ?B" using "0"[of ⋆ ts] (*‹((⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)) = (∃ts'. (⋆, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts = ts' ⋅⇩l⇩i⇩s⇩t ℐ)›*) by fastforce qed show "?B ⊆ ?A" proof (standard) (*goal: ‹⋀x. x ∈ ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ ⟹ x ∈ ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)}›*) fix t assume t: "t ∈ ?B" (*‹(t::('fun, 'var) Term.term) ∈ ⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)} ⋅⇩s⇩e⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term)›*) then obtain ts where ts: "t ∈ set ts ⋅⇩s⇩e⇩t ℐ" "(⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜" (*goal: ‹(⋀ts::('fun::type, 'var::type) Term.term list. ⟦(t::('fun::type, 'var::type) Term.term) ∈ set ts ⋅⇩s⇩e⇩t (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term); (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)⟧ ⟹ thesis::bool) ⟹ thesis›*) by blast hence "(⋆, receive⟨ts ⋅⇩l⇩i⇩s⇩t ℐ⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)" using "0"[of ⋆ "ts ⋅⇩l⇩i⇩s⇩t ℐ"] (*‹((⋆, receive⟨ts ⋅⇩l⇩i⇩s⇩t ℐ⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)) = (∃ts'. (⋆, receive⟨ts'⟩⇩s⇩t) ∈ set 𝒜 ∧ ts ⋅⇩l⇩i⇩s⇩t ℐ = ts' ⋅⇩l⇩i⇩s⇩t ℐ)›*) by blast thus "t ∈ ?A" using ts(1) (*‹t ∈ set ts ⋅⇩s⇩e⇩t ℐ›*) by force qed qed show "?thesis" (*goal: ‹declassified⇩l⇩s⇩t (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) (ℐ::'var ⇒ ('fun, 'var) Term.term) = {s::('fun, 'var) Term.term. ⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) using "1" (*‹⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)} = ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ›*) unfolding "declassified⇩l⇩s⇩t_def" (*goal: ‹{s. ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (𝒜 ⋅⇩l⇩s⇩t ℐ)} ⊢ s} = {s. ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) by argo qed lemma declassified⇩l⇩s⇩t_star_receive_supset: "{t | t ts. (⋆, Receive ts) ∈ set 𝒜 ∧ t ∈ set ts} ⋅⇩s⇩e⇩t ℐ ⊆ declassified⇩l⇩s⇩t 𝒜 ℐ" unfolding "declassified⇩l⇩s⇩t_alt_def" (*goal: ‹{uu_. ∃t ts. uu_ = t ∧ (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜 ∧ t ∈ set ts} ⋅⇩s⇩e⇩t ℐ ⊆ Collect ((⊢) (⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set 𝒜} ⋅⇩s⇩e⇩t ℐ))›*) by (fastforce intro: intruder_deduct.Axiom (*‹(?t::('fun::type, 'var::type) Term.term) ∈ (?M::('fun::type, 'var::type) Term.term set) ⟹ ?M ⊢ ?t›*)) lemma ik_proj_subst_GSMP_subset: assumes I: "wt⇩s⇩u⇩b⇩s⇩t I" "wf⇩t⇩r⇩m⇩s (subst_range I)" "interpretation⇩s⇩u⇩b⇩s⇩t I" shows "ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⊆ GSMP (trms_proj⇩l⇩s⇩t n A)" proof (standard) (*goal: ‹⋀x. x ∈ ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⟹ x ∈ GSMP (trms⇩l⇩s⇩t (proj n A))›*) fix t assume "t ∈ ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I" (*‹(t::('fun, 'var) Term.term) ∈ ik⇩s⇩t (proj_unl (n::'a) (A::('a strand_label × ('fun, 'var) strand_step) list)) ⋅⇩s⇩e⇩t (I::'var ⇒ ('fun, 'var) Term.term)›*) hence "*": "t ∈ trms_proj⇩l⇩s⇩t n A ⋅⇩s⇩e⇩t I" by auto then obtain s where "s ∈ trms_proj⇩l⇩s⇩t n A" "t = s ⋅ I" (*goal: ‹(⋀s. ⟦s ∈ trms⇩l⇩s⇩t (proj n A); t = s ⋅ I⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "t ∈ SMP (trms_proj⇩l⇩s⇩t n A)" using SMP_I (*‹⟦?s ∈ ?M; wt⇩s⇩u⇩b⇩s⇩t ?δ; ?t ⊑ ?s ⋅ ?δ; ⋀v. wf⇩t⇩r⇩m (?δ v)⟧ ⟹ ?t ∈ SMP ?M›*) I(1,2) (*‹wt⇩s⇩u⇩b⇩s⇩t I› ‹wf⇩t⇩r⇩m⇩s (subst_range I)›*) wf_trm_subst_range_iff[of I] (*‹(∀x. wf⇩t⇩r⇩m (I x)) = wf⇩t⇩r⇩m⇩s (subst_range I)›*) by simp moreover have "fv t = {}" using "*" (*‹t ∈ trms⇩l⇩s⇩t (proj n A) ⋅⇩s⇩e⇩t I›*) interpretation_grounds_all'[OF I ( 3 )] (*‹Messages.ground (?M ⋅⇩s⇩e⇩t I)›*) by auto ultimately show "t ∈ GSMP (trms_proj⇩l⇩s⇩t n A)" unfolding GSMP_def (*goal: ‹t ∈ {t ∈ SMP (trms⇩l⇩s⇩t (proj n A)). fv t = {}}›*) by simp qed lemma ik_proj_subst_subterms_GSMP_subset: assumes I: "wt⇩s⇩u⇩b⇩s⇩t I" "wf⇩t⇩r⇩m⇩s (subst_range I)" "interpretation⇩s⇩u⇩b⇩s⇩t I" shows "subterms⇩s⇩e⇩t (ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I) ⊆ GSMP (trms_proj⇩l⇩s⇩t n A)" (is "?A ⊆ ?B") proof (standard) (*goal: ‹⋀x. x ⊑⇩s⇩e⇩t ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⟹ x ∈ GSMP (trms⇩l⇩s⇩t (proj n A))›*) fix t assume "t ⊑⇩s⇩e⇩t ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I" (*‹(t::('fun, 'var) Term.term) ⊑⇩s⇩e⇩t ik⇩s⇩t (proj_unl (n::'a) (A::('a strand_label × ('fun, 'var) strand_step) list)) ⋅⇩s⇩e⇩t (I::'var ⇒ ('fun, 'var) Term.term)›*) then obtain s where "s ∈ ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I" "t ⊑ s" (*goal: ‹(⋀s. ⟦s ∈ ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I; t ⊑ s⟧ ⟹ thesis) ⟹ thesis›*) by fast thus "t ∈ ?B" using ik_proj_subst_GSMP_subset[OF I, of n A] (*‹ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⊆ GSMP (trms⇩l⇩s⇩t (proj n A))›*) ground_subterm[of s t] (*‹⟦fv s = {}; t ⊑ s⟧ ⟹ fv t = {}›*) SMP.Subterm[of s "trms⇩l⇩s⇩t (proj n A)" t] (*‹⟦s ∈ SMP (trms⇩l⇩s⇩t (proj n A)); t ⊑ s⟧ ⟹ t ∈ SMP (trms⇩l⇩s⇩t (proj n A))›*) unfolding GSMP_def (*goal: ‹t ∈ {t ∈ SMP (trms⇩l⇩s⇩t (proj n A)). fv t = {}}›*) by blast qed lemma declassified_proj_eq: "declassified⇩l⇩s⇩t A I = declassified⇩l⇩s⇩t (proj n A) I" unfolding "declassified⇩l⇩s⇩t_alt_def" proj_def (*goal: ‹Collect ((⊢) (⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I)) = Collect ((⊢) (⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (filter (λs. has_LabelN n s ∨ has_LabelS s) A)} ⋅⇩s⇩e⇩t I))›*) by auto lemma declassified_prefix_subset: assumes AB: "prefix A B" shows "declassified⇩l⇩s⇩t A I ⊆ declassified⇩l⇩s⇩t B I" proof (standard) (*goal: ‹⋀x::('fun, 'var) Term.term. x ∈ declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) (I::'var ⇒ ('fun, 'var) Term.term) ⟹ x ∈ declassified⇩l⇩s⇩t (B::('lbl strand_label × ('fun, 'var) strand_step) list) I›*) fix t assume t: "t ∈ declassified⇩l⇩s⇩t A I" (*‹(t::('fun, 'var) Term.term) ∈ declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) (I::'var ⇒ ('fun, 'var) Term.term)›*) obtain C where C: "B = A@C" (*goal: ‹(⋀C::('lbl strand_label × ('fun, 'var) strand_step) list. (B::('lbl strand_label × ('fun, 'var) strand_step) list) = (A::('lbl strand_label × ('fun, 'var) strand_step) list) @ C ⟹ thesis::bool) ⟹ thesis›*) using prefixE[OF AB] (*‹(⋀zs. B = A @ zs ⟹ ?thesis) ⟹ ?thesis›*) by metis show "t ∈ declassified⇩l⇩s⇩t B I" using t (*‹t ∈ declassified⇩l⇩s⇩t A I›*) ideduct_mono[of "⋃{set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I" t "⋃{set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set B} ⋅⇩s⇩e⇩t I"] (*‹⟦⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I ⊢ t; ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I ⊆ ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set B} ⋅⇩s⇩e⇩t I⟧ ⟹ ⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set B} ⋅⇩s⇩e⇩t I ⊢ t›*) unfolding C "declassified⇩l⇩s⇩t_alt_def" (*goal: ‹(t::('fun, 'var) Term.term) ∈ Collect ((⊢) (⋃ {set ts |ts::('fun, 'var) Term.term list. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ (C::('lbl strand_label × ('fun, 'var) strand_step) list))} ⋅⇩s⇩e⇩t (I::'var ⇒ ('fun, 'var) Term.term)))›*) by auto qed lemma declassified_proj_ik_subset: "declassified⇩l⇩s⇩t A I ⊆ {s. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⊢ s}" (is "?A A ⊆ ?P A A") proof (-) (*goal: ‹declassified⇩l⇩s⇩t A I ⊆ {s. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⊢ s}›*) have "*": "⋃{set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I ⊆ ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I" using "proj_ik⇩s⇩t_is_proj_rcv_set" (*‹ik⇩s⇩t (proj_unl ?n ?A) = {t. ∃ts. ((ln ?n, receive⟨ts⟩⇩s⇩t) ∈ set ?A ∨ (⋆, receive⟨ts⟩⇩s⇩t) ∈ set ?A) ∧ t ∈ set ts}›*) by fastforce show "?thesis" (*goal: ‹declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) (I::'var ⇒ ('fun, 'var) Term.term) ⊆ {s::('fun, 'var) Term.term. ik⇩s⇩t (proj_unl (n::'lbl) A) ⋅⇩s⇩e⇩t I ⊢ s}›*) using ideduct_mono[OF _ *] (*‹⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I ⊢ ?t ⟹ ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⊢ ?t›*) unfolding "declassified⇩l⇩s⇩t_alt_def" (*goal: ‹Collect ((⊢) (⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I)) ⊆ {s. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t I ⊢ s}›*) by blast qed lemma deduct_proj_priv_term_prefix_ex: assumes A: "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t I ⊢ t" and t: "¬{} ⊢⇩c t" shows "∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B@[(k,receive⟨s⟩⇩s⇩t)]) A ∧ declassified⇩l⇩s⇩t ((B@[(k,receive⟨s⟩⇩s⇩t)])) I = declassified⇩l⇩s⇩t A I ∧ ik⇩s⇩t (proj_unl l (B@[(k,receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l A)" using A (*‹ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t I ⊢ t›*) proof (induction A rule: List.rev_induct (*‹⟦?P []; ⋀x xs. ?P xs ⟹ ?P (xs @ [x])⟧ ⟹ ?P ?xs›*)) (*goals: 1. ‹ik⇩s⇩t (proj_unl l []) ⋅⇩s⇩e⇩t I ⊢ t ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) [] ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t [] I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l [])› 2. ‹⋀x xs. ⟦ik⇩s⇩t (proj_unl l xs) ⋅⇩s⇩e⇩t I ⊢ t ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) xs ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t xs I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l xs); ik⇩s⇩t (proj_unl l (xs @ [x])) ⋅⇩s⇩e⇩t I ⊢ t⟧ ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) (xs @ [x]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (xs @ [x]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (xs @ [x]))›*) case Nil (*‹intruder_deduct (ik⇩s⇩t (proj_unl l []) ⋅⇩s⇩e⇩t I) t›*) have "ik⇩s⇩t (proj_unl l []) ⋅⇩s⇩e⇩t I = {}" by auto thus "?case" (*goal: ‹∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) [] ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t [] I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l [])›*) using Nil (*‹intruder_deduct (ik⇩s⇩t (proj_unl l []) ⋅⇩s⇩e⇩t I) t›*) t (*‹¬ {} ⊢⇩c t›*) deducts_eq_if_empty_ik[of t] (*‹({} ⊢ t) = ({} ⊢⇩c t)›*) by argo next (*goal: ‹⋀(x::'lbl::type strand_label × ('fun::type, 'var::type) strand_step) xs::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list. ⟦ik⇩s⇩t (proj_unl (l::'lbl::type) xs) ⋅⇩s⇩e⇩t (I::'var::type ⇒ ('fun::type, 'var::type) Term.term) ⊢ (t::('fun::type, 'var::type) Term.term) ⟹ ∃(B::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) (k::'lbl::type strand_label) s::('fun::type, 'var::type) Term.term list. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) xs ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t xs I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l xs); ik⇩s⇩t (proj_unl l (xs @ [x])) ⋅⇩s⇩e⇩t I ⊢ t⟧ ⟹ ∃(B::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) (k::'lbl::type strand_label) s::('fun::type, 'var::type) Term.term list. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) (xs @ [x]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (xs @ [x]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (xs @ [x]))›*) case (snoc a A) (*‹intruder_deduct (ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t I) t ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) A ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t A I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l A)› ‹intruder_deduct (ik⇩s⇩t (proj_unl l (A @ [a])) ⋅⇩s⇩e⇩t I) t›*) obtain k and b where a: "a = (k,b)" (*goal: ‹(⋀k b. a = (k, b) ⟹ thesis) ⟹ thesis›*) by (metis surj_pair (*‹∃x y. ?p = (x, y)›*)) let ?P = "k = ⋆ ∨ k = (ln l)" let ?Q = "∃ts. b = receive⟨ts⟩⇩s⇩t" have 0: "ik⇩s⇩t (proj_unl l (A@[a])) = ik⇩s⇩t (proj_unl l A)" if "?P ⟹ ¬?Q" using that (*‹k = ⋆ ∨ k = ln l ⟹ ∄ts. b = receive⟨ts⟩⇩s⇩t›*) "ik⇩s⇩t_snoc_no_receive_eq"[OF that, of I "proj_unl l A"] (*‹k = ⋆ ∨ k = ln l ⟹ ik⇩s⇩t (proj_unl l A @ [b]) ⋅⇩s⇩e⇩t I = ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t I›*) unfolding "ik⇩s⇩t_is_rcv_set" a (*goal: ‹{uu_. ∃ts t. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l (A @ [(k, b)])) ∧ t ∈ set ts} = {uu_. ∃ts t. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l A) ∧ t ∈ set ts}›*) apply (cases "k = ⋆ ∨ k = (ln l)") (*goals: 1. ‹⟦(k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl ⟹ ∄ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t; k = ⋆ ∨ k = ln l ⟹ {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l (A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [b]) ∧ t ∈ set ts} ⋅⇩s⇩e⇩t (I::'var ⇒ ('fun, 'var) Term.term) = {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l A) ∧ t ∈ set ts} ⋅⇩s⇩e⇩t I; k = ⋆ ∨ k = ln l⟧ ⟹ {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l (A @ [(k, b)])) ∧ t ∈ set ts} = {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l A) ∧ t ∈ set ts}› 2. ‹⟦(k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl ⟹ ∄ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t; k = ⋆ ∨ k = ln l ⟹ {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l (A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [b]) ∧ t ∈ set ts} ⋅⇩s⇩e⇩t (I::'var ⇒ ('fun, 'var) Term.term) = {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l A) ∧ t ∈ set ts} ⋅⇩s⇩e⇩t I; ¬ (k = ⋆ ∨ k = ln l)⟧ ⟹ {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l (A @ [(k, b)])) ∧ t ∈ set ts} = {uu_::('fun, 'var) Term.term. ∃(ts::('fun, 'var) Term.term list) t::('fun, 'var) Term.term. uu_ = t ∧ receive⟨ts⟩⇩s⇩t ∈ set (proj_unl l A) ∧ t ∈ set ts}› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have 1: "declassified⇩l⇩s⇩t (A@[a]) I = declassified⇩l⇩s⇩t A I" if "?P ⟹ ¬?Q" using that (*‹(k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl ⟹ ∄ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t›*) snoc.prems (*‹intruder_deduct (ik⇩s⇩t (proj_unl l (A @ [a])) ⋅⇩s⇩e⇩t I) t›*) unfolding "declassified⇩l⇩s⇩t_alt_def" a (*goal: ‹Collect ((⊢) (⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set (A @ [(k, b)])} ⋅⇩s⇩e⇩t I)) = Collect ((⊢) (⋃ {set ts |ts. (⋆, receive⟨ts⟩⇩s⇩t) ∈ set A} ⋅⇩s⇩e⇩t I))›*) by (metis (no_types, lifting) UnCI (*‹((?c::?'a) ∉ (?B::?'a set) ⟹ ?c ∈ (?A::?'a set)) ⟹ ?c ∈ ?A ∪ ?B›*) UnE (*‹⟦(?c::?'a) ∈ (?A::?'a set) ∪ (?B::?'a set); ?c ∈ ?A ⟹ ?P::bool; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) empty_iff (*‹((?c::?'a) ∈ {}) = False›*) insert_iff (*‹((?a::?'a) ∈ insert (?b::?'a) (?A::?'a set)) = (?a = ?b ∨ ?a ∈ ?A)›*) list.set (*‹set [] = {}› ‹set ((?x21.0::?'a) # (?x22.0::?'a list)) = insert ?x21.0 (set ?x22.0)›*) prod.inject (*‹((?x1.0::?'a, ?x2.0::?'b) = (?y1.0::?'a, ?y2.0::?'b)) = (?x1.0 = ?y1.0 ∧ ?x2.0 = ?y2.0)›*) set_append (*‹set ((?xs::?'a list) @ (?ys::?'a list)) = set ?xs ∪ set ?ys›*)) note 2 = snoc.prems (*‹intruder_deduct (ik⇩s⇩t (proj_unl (l::'lbl) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step])) ⋅⇩s⇩e⇩t (I::'var ⇒ ('fun, 'var) Term.term)) (t::('fun, 'var) Term.term)›*) snoc.IH (*‹intruder_deduct (ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t I) t ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) A ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t A I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l A)›*) "0" (*‹(k = ⋆ ∨ k = ln l ⟹ ∄ts. b = receive⟨ts⟩⇩s⇩t) ⟹ ik⇩s⇩t (proj_unl l (A @ [a])) = ik⇩s⇩t (proj_unl l A)›*) "1" (*‹((k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl ⟹ ∄ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t) ⟹ declassified⇩l⇩s⇩t ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) (I::'var ⇒ ('fun, 'var) Term.term) = declassified⇩l⇩s⇩t A I›*) show "?case" (*goal: ‹∃(B::('lbl strand_label × ('fun, 'var) strand_step) list) (k::'lbl strand_label) s::('fun, 'var) Term.term list. (k = ⋆ ∨ k = ln l::'lbl) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) (I::'var ⇒ ('fun, 'var) Term.term) = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) proof (cases ?P) (*goals: 1. ‹k = ⋆ ∨ k = ln l ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) (A @ [a]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))› 2. ‹¬ (k = ⋆ ∨ k = ln l) ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) (A @ [a]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) case True (*‹k = ⋆ ∨ k = ln l›*) note T = this (*‹k = ⋆ ∨ k = ln l›*) thus "?thesis" (*goal: ‹∃(B::('lbl strand_label × ('fun, 'var) strand_step) list) (k::'lbl strand_label) s::('fun, 'var) Term.term list. (k = ⋆ ∨ k = ln l::'lbl) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) (I::'var ⇒ ('fun, 'var) Term.term) = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) proof (cases ?Q) (*goals: 1. ‹⟦(k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl; ∃ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t⟧ ⟹ ∃(B::('lbl strand_label × ('fun, 'var) strand_step) list) (k::'lbl strand_label) s::('fun, 'var) Term.term list. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) (I::'var ⇒ ('fun, 'var) Term.term) = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))› 2. ‹⟦(k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl; ∄ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t⟧ ⟹ ∃(B::('lbl strand_label × ('fun, 'var) strand_step) list) (k::'lbl strand_label) s::('fun, 'var) Term.term list. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) (I::'var ⇒ ('fun, 'var) Term.term) = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) case True (*‹∃ts::('fun, 'var) Term.term list. (b::('fun, 'var) strand_step) = receive⟨ts⟩⇩s⇩t›*) thus "?thesis" (*goal: ‹∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) (A @ [a]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) using T (*‹(k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl›*) unfolding a (*goal: ‹∃B ka s. (ka = ⋆ ∨ ka = ln l) ∧ prefix (B @ [(ka, receive⟨s⟩⇩s⇩t)]) (A @ [(k, b)]) ∧ declassified⇩l⇩s⇩t (B @ [(ka, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (A @ [(k, b)]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(ka, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [(k, b)]))›*) by blast qed (use 2 in auto) (*solved the remaining goal: ‹⟦k = ⋆ ∨ k = ln l; ∄ts. b = receive⟨ts⟩⇩s⇩t⟧ ⟹ ∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) (A @ [a]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) I = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) qed (use 2 in auto) (*solved the remaining goal: ‹¬ ((k::'lbl strand_label) = ⋆ ∨ k = ln l::'lbl) ⟹ ∃(B::('lbl strand_label × ('fun, 'var) strand_step) list) (k::'lbl strand_label) s::('fun, 'var) Term.term list. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) (I::'var ⇒ ('fun, 'var) Term.term) = declassified⇩l⇩s⇩t (A @ [a]) I ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l (A @ [a]))›*) qed subsection ‹Lemmata: Homogeneous and Heterogeneous Terms (Deprecated Theory)› text ‹The following theory is no longer needed for the compositionality result› context begin private definition proj_specific where "proj_specific n t 𝒜 Secrets ≡ t ∈ GSMP (trms_proj⇩l⇩s⇩t n 𝒜) - (Secrets ∪ {m. {} ⊢⇩c m})" private definition heterogeneous⇩l⇩s⇩t where "heterogeneous⇩l⇩s⇩t t 𝒜 Secrets ≡ ( (∃l1 l2. ∃s1 ∈ subterms t. ∃s2 ∈ subterms t. l1 ≠ l2 ∧ proj_specific l1 s1 𝒜 Secrets ∧ proj_specific l2 s2 𝒜 Secrets))" private abbreviation homogeneous⇩l⇩s⇩t where "homogeneous⇩l⇩s⇩t t 𝒜 Secrets ≡ ¬heterogeneous⇩l⇩s⇩t t 𝒜 Secrets" private definition intruder_deduct_hom':: "('fun,'var) terms ⇒ ('fun,'var,'lbl) labeled_strand ⇒ ('fun,'var) terms ⇒ ('fun,'var) term ⇒ bool" ("⟨_;_;_⟩ ⊢⇩h⇩o⇩m _" 50) where "⟨M; 𝒜; Sec⟩ ⊢⇩h⇩o⇩m t ≡ ⟨M; λt. homogeneous⇩l⇩s⇩t t 𝒜 Sec ∧ t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r t" private lemma GSMP_disjoint_fst_specific_not_snd_specific: assumes "GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" "l ≠ l'" and "proj_specific l m 𝒜 Sec" shows "¬proj_specific l' m 𝒜 Sec" using assms (*‹GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec› ‹l ≠ l'› ‹proj_specific l m 𝒜 Sec›*) by (fastforce simp add: GSMP_disjoint_def (*‹GSMP_disjoint (?P1.0::('fun, 'var) Term.term set) (?P2.0::('fun, 'var) Term.term set) (?Secrets::('fun, 'var) Term.term set) ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m}›*) proj_specific_def (*‹proj_specific (?n::?'a) (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m})›*)) private lemma GSMP_disjoint_snd_specific_not_fst_specific: assumes "GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and "proj_specific l' m 𝒜 Sec" shows "¬proj_specific l m 𝒜 Sec" using assms (*‹GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec› ‹proj_specific l' m 𝒜 Sec›*) by (auto simp add: GSMP_disjoint_def (*‹GSMP_disjoint ?P1.0 ?P2.0 ?Secrets ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m. {} ⊢⇩c m}›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*)) private lemma GSMP_disjoint_intersection_not_specific: assumes "GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and "t ∈ Sec ∨ {} ⊢⇩c t" shows "¬proj_specific l t 𝒜 Sec" "¬proj_specific l t 𝒜 Sec" using assms (*‹GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec› ‹(t::('fun, 'var) Term.term) ∈ (Sec::('fun, 'var) Term.term set) ∨ {} ⊢⇩c t›*) apply - (*goals: 1. ‹⟦GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec; t ∈ Sec ∨ {} ⊢⇩c t⟧ ⟹ ¬ proj_specific l t 𝒜 Sec› 2. ‹⟦GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec; t ∈ Sec ∨ {} ⊢⇩c t⟧ ⟹ ¬ proj_specific l t 𝒜 Sec› discuss goal 1*) apply ((auto simp add: GSMP_disjoint_def (*‹GSMP_disjoint (?P1.0::('fun, 'var) Term.term set) (?P2.0::('fun, 'var) Term.term set) (?Secrets::('fun, 'var) Term.term set) ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m}›*) proj_specific_def (*‹proj_specific (?n::?'a) (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m})›*))[1]) (*discuss goal 2*) apply ((auto simp add: GSMP_disjoint_def (*‹GSMP_disjoint ?P1.0 ?P2.0 ?Secrets ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m. {} ⊢⇩c m}›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*))[1]) (*proven 2 subgoals*) . private lemma proj_specific_secrets_anti_mono: assumes "proj_specific l t 𝒜 Sec" "Sec' ⊆ Sec" shows "proj_specific l t 𝒜 Sec'" using assms (*‹proj_specific (l::'a::type) (t::('fun::type, 'var::type) Term.term) (𝒜::('a::type strand_label × ('fun::type, 'var::type) strand_step) list) (Sec::('fun::type, 'var::type) Term.term set)› ‹Sec' ⊆ Sec›*) unfolding proj_specific_def (*goal: ‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) - (Sec' ∪ {m. {} ⊢⇩c m})›*) by fast private lemma heterogeneous_secrets_anti_mono: assumes "heterogeneous⇩l⇩s⇩t t 𝒜 Sec" "Sec' ⊆ Sec" shows "heterogeneous⇩l⇩s⇩t t 𝒜 Sec'" using assms (*‹heterogeneous⇩l⇩s⇩t t 𝒜 Sec› ‹Sec' ⊆ Sec›*) proj_specific_secrets_anti_mono (*‹⟦proj_specific (?l::?'a::type) (?t::('fun::type, 'var::type) Term.term) (?𝒜::(?'a::type strand_label × ('fun::type, 'var::type) strand_step) list) (?Sec::('fun::type, 'var::type) Term.term set); (?Sec'::('fun::type, 'var::type) Term.term set) ⊆ ?Sec⟧ ⟹ proj_specific ?l ?t ?𝒜 ?Sec'›*) unfolding "heterogeneous⇩l⇩s⇩t_def" (*goal: ‹∃l1 l2. ∃s1∈subterms t. ∃s2∈subterms t. l1 ≠ l2 ∧ proj_specific l1 s1 𝒜 Sec' ∧ proj_specific l2 s2 𝒜 Sec'›*) by metis private lemma homogeneous_secrets_mono: assumes "homogeneous⇩l⇩s⇩t t 𝒜 Sec'" "Sec' ⊆ Sec" shows "homogeneous⇩l⇩s⇩t t 𝒜 Sec" using assms (*‹homogeneous⇩l⇩s⇩t t 𝒜 Sec'› ‹Sec' ⊆ Sec›*) heterogeneous_secrets_anti_mono (*‹⟦heterogeneous⇩l⇩s⇩t ?t ?𝒜 ?Sec; ?Sec' ⊆ ?Sec⟧ ⟹ heterogeneous⇩l⇩s⇩t ?t ?𝒜 ?Sec'›*) by blast private lemma heterogeneous_supterm: assumes "heterogeneous⇩l⇩s⇩t t 𝒜 Sec" "t ⊑ t'" shows "heterogeneous⇩l⇩s⇩t t' 𝒜 Sec" proof (-) (*goal: ‹heterogeneous⇩l⇩s⇩t (t'::('fun, 'var) Term.term) (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)›*) obtain l1 and l2 and s1 and s2 where "*": "l1 ≠ l2" "s1 ⊑ t" "proj_specific l1 s1 𝒜 Sec" "s2 ⊑ t" "proj_specific l2 s2 𝒜 Sec" (*goal: ‹(⋀l1 l2 s1 s2. ⟦l1 ≠ l2; s1 ⊑ t; proj_specific l1 s1 𝒜 Sec; s2 ⊑ t; proj_specific l2 s2 𝒜 Sec⟧ ⟹ thesis) ⟹ thesis›*) using assms(1) (*‹heterogeneous⇩l⇩s⇩t t 𝒜 Sec›*) unfolding "heterogeneous⇩l⇩s⇩t_def" (*goal: ‹(⋀(l1::'a) (l2::'a) (s1::('fun, 'var) Term.term) s2::('fun, 'var) Term.term. ⟦l1 ≠ l2; s1 ⊑ (t::('fun, 'var) Term.term); proj_specific l1 s1 (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set); s2 ⊑ t; proj_specific l2 s2 𝒜 Sec⟧ ⟹ thesis::bool) ⟹ thesis›*) by fast thus "?thesis" (*goal: ‹heterogeneous⇩l⇩s⇩t t' 𝒜 Sec›*) using term.order_trans[OF * ( 2 ) assms ( 2 )] (*‹s1 ⊑ t'›*) term.order_trans[OF * ( 4 ) assms ( 2 )] (*‹s2 ⊑ t'›*) by (auto simp add: heterogeneous⇩l⇩s⇩t_def (*‹heterogeneous⇩l⇩s⇩t (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ∃(l1::?'a) l2::?'a. ∃s1::('fun, 'var) Term.term∈subterms ?t. ∃s2::('fun, 'var) Term.term∈subterms ?t. l1 ≠ l2 ∧ proj_specific l1 s1 ?𝒜 ?Secrets ∧ proj_specific l2 s2 ?𝒜 ?Secrets›*)) qed private lemma homogeneous_subterm: assumes "homogeneous⇩l⇩s⇩t t 𝒜 Sec" "t' ⊑ t" shows "homogeneous⇩l⇩s⇩t t' 𝒜 Sec" by (metis assms (*‹homogeneous⇩l⇩s⇩t (t::('fun, 'var) Term.term) (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)› ‹(t'::('fun, 'var) Term.term) ⊑ (t::('fun, 'var) Term.term)›*) heterogeneous_supterm (*‹⟦heterogeneous⇩l⇩s⇩t (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Sec::('fun, 'var) Term.term set); ?t ⊑ (?t'::('fun, 'var) Term.term)⟧ ⟹ heterogeneous⇩l⇩s⇩t ?t' ?𝒜 ?Sec›*)) private lemma proj_specific_subterm: assumes "t ⊑ t'" "proj_specific l t' 𝒜 Sec" shows "proj_specific l t 𝒜 Sec ∨ t ∈ Sec ∨ {} ⊢⇩c t" using GSMP_subterm[OF _ assms ( 1 )] (*‹t' ∈ GSMP ?M ⟹ t ∈ GSMP ?M›*) assms(2) (*‹proj_specific l t' 𝒜 Sec›*) by (auto simp add: proj_specific_def (*‹proj_specific (?n::?'a) (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m})›*)) private lemma heterogeneous_term_is_Fun: assumes "heterogeneous⇩l⇩s⇩t t A S" shows "∃f T. t = Fun f T" using assms (*‹heterogeneous⇩l⇩s⇩t t A S›*) apply (cases t) (*goals: 1. ‹⋀x1. ⟦heterogeneous⇩l⇩s⇩t t A S; t = Var x1⟧ ⟹ ∃f T. t = Fun f T› 2. ‹⋀x21 x22. ⟦heterogeneous⇩l⇩s⇩t t A S; t = Fun x21 x22⟧ ⟹ ∃f T. t = Fun f T› discuss goal 1*) apply ((auto simp add: GSMP_def (*‹GSMP ?P ≡ {t ∈ SMP ?P. fv t = {}}›*) heterogeneous⇩l⇩s⇩t_def (*‹heterogeneous⇩l⇩s⇩t ?t ?𝒜 ?Secrets ≡ ∃l1 l2. ∃s1∈subterms ?t. ∃s2∈subterms ?t. l1 ≠ l2 ∧ proj_specific l1 s1 ?𝒜 ?Secrets ∧ proj_specific l2 s2 ?𝒜 ?Secrets›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*))[1]) (*discuss goal 2*) apply ((auto simp add: GSMP_def (*‹GSMP ?P ≡ {t ∈ SMP ?P. fv t = {}}›*) heterogeneous⇩l⇩s⇩t_def (*‹heterogeneous⇩l⇩s⇩t ?t ?𝒜 ?Secrets ≡ ∃l1 l2. ∃s1∈subterms ?t. ∃s2∈subterms ?t. l1 ≠ l2 ∧ proj_specific l1 s1 ?𝒜 ?Secrets ∧ proj_specific l2 s2 ?𝒜 ?Secrets›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*))[1]) (*proven 2 subgoals*) . private lemma proj_specific_is_homogeneous: assumes 𝒜: "∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and t: "proj_specific l m 𝒜 Sec" shows "homogeneous⇩l⇩s⇩t m 𝒜 Sec" proof (standard) (*goal: ‹heterogeneous⇩l⇩s⇩t m 𝒜 Sec ⟹ False›*) assume "heterogeneous⇩l⇩s⇩t m 𝒜 Sec" (*‹heterogeneous⇩l⇩s⇩t (m::('fun, 'var) Term.term) (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)›*) then obtain s and l' where s: "s ∈ subterms m" "proj_specific l' s 𝒜 Sec" "l ≠ l'" (*goal: ‹(⋀(s::('fun, 'var) Term.term) l'::'a. ⟦s ⊑ (m::('fun, 'var) Term.term); proj_specific l' s (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set); (l::'a) ≠ l'⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding "heterogeneous⇩l⇩s⇩t_def" (*goal: ‹(⋀s l'. ⟦s ⊑ m; proj_specific l' s 𝒜 Sec; l ≠ l'⟧ ⟹ thesis) ⟹ thesis›*) apply atomize_elim (*goal: ‹(⋀s l'. ⟦s ⊑ m; proj_specific l' s 𝒜 Sec; l ≠ l'⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "s ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" "s ∈ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)" using t (*‹proj_specific (l::'a) (m::('fun, 'var) Term.term) (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)›*) apply - (*goals: 1. ‹⟦s ⊑ m; proj_specific l' s 𝒜 Sec; l ≠ l'; proj_specific l m 𝒜 Sec⟧ ⟹ s ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))› 2. ‹⟦s ⊑ m; proj_specific l' s 𝒜 Sec; l ≠ l'; proj_specific l m 𝒜 Sec⟧ ⟹ s ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))› discuss goal 1*) apply ((auto simp add: GSMP_def (*‹GSMP (?P::('fun, 'var) Term.term set) ≡ {t::('fun, 'var) Term.term ∈ SMP ?P. fv t = {}}›*) proj_specific_def (*‹proj_specific (?n::?'a) (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m})›*))[1]) (*discuss goal 2*) apply ((auto simp add: GSMP_def (*‹GSMP ?P ≡ {t ∈ SMP ?P. fv t = {}}›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*))[1]) (*proven 2 subgoals*) . hence "s ∈ Sec ∨ {} ⊢⇩c s" using "𝒜" (*‹∀(l::'a) l'::'a. l ≠ l' ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l (𝒜::('a strand_label × ('fun, 'var) strand_step) list))) (trms⇩l⇩s⇩t (proj l' 𝒜)) (Sec::('fun, 'var) Term.term set)›*) s(3) (*‹l ≠ l'›*) by (auto simp add: GSMP_disjoint_def (*‹GSMP_disjoint (?P1.0::('fun, 'var) Term.term set) (?P2.0::('fun, 'var) Term.term set) (?Secrets::('fun, 'var) Term.term set) ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m}›*)) thus False using s(2) (*‹proj_specific l' s 𝒜 Sec›*) by (auto simp add: proj_specific_def (*‹proj_specific (?n::?'a::type) (?t::('fun::type, 'var::type) Term.term) (?𝒜::(?'a::type strand_label × ('fun::type, 'var::type) strand_step) list) (?Secrets::('fun::type, 'var::type) Term.term set) ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m::('fun::type, 'var::type) Term.term. {} ⊢⇩c m})›*)) qed private lemma deduct_synth_homogeneous: assumes "{} ⊢⇩c t" shows "homogeneous⇩l⇩s⇩t t 𝒜 Sec" proof (-) (*goal: ‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) have "∀s ∈ subterms t. {} ⊢⇩c s" using deduct_synth_subterm[OF assms] (*‹⟦(?s::('fun, 'var) Term.term) ⊑ (t::('fun, 'var) Term.term); ∀m::('fun, 'var) Term.term∈{}. ∀s::('fun, 'var) Term.term∈subterms m. {} ⊢⇩c s⟧ ⟹ {} ⊢⇩c ?s›*) by auto thus "?thesis" (*goal: ‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) unfolding "heterogeneous⇩l⇩s⇩t_def" proj_specific_def (*goal: ‹∄(l1::'a) l2::'a. ∃s1::('fun, 'var) Term.term∈subterms (t::('fun, 'var) Term.term). ∃s2::('fun, 'var) Term.term∈subterms t. l1 ≠ l2 ∧ s1 ∈ GSMP (trms⇩l⇩s⇩t (proj l1 (𝒜::('a strand_label × ('fun, 'var) strand_step) list))) - ((Sec::('fun, 'var) Term.term set) ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m}) ∧ s2 ∈ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) - (Sec ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m})›*) by auto qed private lemma GSMP_proj_is_homogeneous: assumes "∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l A) (trms_proj⇩l⇩s⇩t l' A) Sec" and "t ∈ GSMP (trms_proj⇩l⇩s⇩t l A)" "t ∉ Sec" shows "homogeneous⇩l⇩s⇩t t A Sec" proof (standard) (*goal: ‹heterogeneous⇩l⇩s⇩t (t::('fun, 'var) Term.term) (A::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set) ⟹ False›*) assume "heterogeneous⇩l⇩s⇩t t A Sec" (*‹heterogeneous⇩l⇩s⇩t (t::('fun, 'var) Term.term) (A::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)›*) then obtain s and l' where s: "s ∈ subterms t" "proj_specific l' s A Sec" "l ≠ l'" (*goal: ‹(⋀(s::('fun::type, 'var::type) Term.term) l'::'a::type. ⟦s ⊑ (t::('fun::type, 'var::type) Term.term); proj_specific l' s (A::('a::type strand_label × ('fun::type, 'var::type) strand_step) list) (Sec::('fun::type, 'var::type) Term.term set); (l::'a::type) ≠ l'⟧ ⟹ thesis::bool) ⟹ thesis›*) unfolding "heterogeneous⇩l⇩s⇩t_def" (*goal: ‹(⋀(s::('fun, 'var) Term.term) l'::'a. ⟦s ⊑ (t::('fun, 'var) Term.term); proj_specific l' s (A::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set); (l::'a) ≠ l'⟧ ⟹ thesis::bool) ⟹ thesis›*) apply atomize_elim (*goal: ‹(⋀s l'. ⟦s ⊑ t; proj_specific l' s A Sec; l ≠ l'⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "s ∈ GSMP (trms_proj⇩l⇩s⇩t l A)" "s ∈ GSMP (trms_proj⇩l⇩s⇩t l' A)" using assms (*‹∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l A)) (trms⇩l⇩s⇩t (proj l' A)) Sec› ‹(t::('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (l::'a) (A::('a strand_label × ('fun, 'var) strand_step) list)))› ‹t ∉ Sec›*) apply - (*goals: 1. ‹⟦(s::('fun, 'var) Term.term) ⊑ (t::('fun, 'var) Term.term); proj_specific (l'::'a) s (A::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set); (l::'a) ≠ l'; ∀(l::'a) l'::'a. l ≠ l' ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l A)) (trms⇩l⇩s⇩t (proj l' A)) Sec; t ∈ GSMP (trms⇩l⇩s⇩t (proj l A)); t ∉ Sec⟧ ⟹ s ∈ GSMP (trms⇩l⇩s⇩t (proj l A))› 2. ‹⟦(s::('fun, 'var) Term.term) ⊑ (t::('fun, 'var) Term.term); proj_specific (l'::'a) s (A::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set); (l::'a) ≠ l'; ∀(l::'a) l'::'a. l ≠ l' ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l A)) (trms⇩l⇩s⇩t (proj l' A)) Sec; t ∈ GSMP (trms⇩l⇩s⇩t (proj l A)); t ∉ Sec⟧ ⟹ s ∈ GSMP (trms⇩l⇩s⇩t (proj l' A))› discuss goal 1*) apply ((auto simp add: GSMP_def (*‹GSMP (?P::('fun, 'var) Term.term set) ≡ {t::('fun, 'var) Term.term ∈ SMP ?P. fv t = {}}›*) proj_specific_def (*‹proj_specific (?n::?'a) (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m})›*))[1]) (*discuss goal 2*) apply ((auto simp add: GSMP_def (*‹GSMP ?P ≡ {t ∈ SMP ?P. fv t = {}}›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*))[1]) (*proven 2 subgoals*) . hence "s ∈ Sec ∨ {} ⊢⇩c s" using assms(1) (*‹∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l A)) (trms⇩l⇩s⇩t (proj l' A)) Sec›*) s(3) (*‹(l::'a) ≠ (l'::'a)›*) by (auto simp add: GSMP_disjoint_def (*‹GSMP_disjoint ?P1.0 ?P2.0 ?Secrets ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m. {} ⊢⇩c m}›*)) thus False using s(2) (*‹proj_specific l' s A Sec›*) by (auto simp add: proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*)) qed private lemma homogeneous_is_not_proj_specific: assumes "homogeneous⇩l⇩s⇩t m 𝒜 Sec" shows "∃l::'lbl. ¬proj_specific l m 𝒜 Sec" proof (-) (*goal: ‹∃l. ¬ proj_specific l m 𝒜 Sec›*) let ?P = "λl s. proj_specific l s 𝒜 Sec" have "∀l1 l2. ∀s1∈subterms m. ∀s2∈subterms m. (l1 ≠ l2 ⟶ (¬?P l1 s1 ∨ ¬?P l2 s2))" using assms (*‹homogeneous⇩l⇩s⇩t m 𝒜 Sec›*) "heterogeneous⇩l⇩s⇩t_def" (*‹heterogeneous⇩l⇩s⇩t (?t::('fun, 'var) Term.term) (?𝒜::(?'a strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ ∃(l1::?'a) l2::?'a. ∃s1::('fun, 'var) Term.term∈subterms ?t. ∃s2::('fun, 'var) Term.term∈subterms ?t. l1 ≠ l2 ∧ proj_specific l1 s1 ?𝒜 ?Secrets ∧ proj_specific l2 s2 ?𝒜 ?Secrets›*) by metis then obtain l1 and l2 where "l1 ≠ l2" "¬?P l1 m ∨ ¬?P l2 m" (*goal: ‹(⋀(l1::'lbl::type) l2::'lbl::type. ⟦l1 ≠ l2; ¬ proj_specific l1 (m::('fun::type, 'var::type) Term.term) (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) (Sec::('fun::type, 'var::type) Term.term set) ∨ ¬ proj_specific l2 m 𝒜 Sec⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis term.order_refl (*‹?x ⊑ ?x›*) at_least_2_labels (*‹label_witness1 ≠ label_witness2›*)) thus "?thesis" (*goal: ‹∃l. ¬ proj_specific l m 𝒜 Sec›*) by metis qed private lemma secrets_are_homogeneous: assumes "∀s ∈ Sec. P s ⟶ (∀s' ∈ subterms s. {} ⊢⇩c s' ∨ s' ∈ Sec)" "s ∈ Sec" "P s" shows "homogeneous⇩l⇩s⇩t s 𝒜 Sec" using assms (*‹∀s∈Sec. P s ⟶ (∀s'∈subterms s. {} ⊢⇩c s' ∨ s' ∈ Sec)› ‹(s::('fun, 'var) Term.term) ∈ (Sec::('fun, 'var) Term.term set)› ‹(P::('fun, 'var) Term.term ⇒ bool) (s::('fun, 'var) Term.term)›*) by (auto simp add: heterogeneous⇩l⇩s⇩t_def (*‹heterogeneous⇩l⇩s⇩t ?t ?𝒜 ?Secrets ≡ ∃l1 l2. ∃s1∈subterms ?t. ∃s2∈subterms ?t. l1 ≠ l2 ∧ proj_specific l1 s1 ?𝒜 ?Secrets ∧ proj_specific l2 s2 ?𝒜 ?Secrets›*) proj_specific_def (*‹proj_specific ?n ?t ?𝒜 ?Secrets ≡ ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n ?𝒜)) - (?Secrets ∪ {m. {} ⊢⇩c m})›*)) private lemma GSMP_is_homogeneous: assumes 𝒜: "∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and t: "t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" "t ∉ Sec" shows "homogeneous⇩l⇩s⇩t t 𝒜 Sec" proof (-) (*goal: ‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) obtain n where n: "t ∈ GSMP (trms_proj⇩l⇩s⇩t n 𝒜)" (*goal: ‹(⋀n::'a. (t::('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj n (𝒜::('a strand_label × ('fun, 'var) strand_step) list))) ⟹ thesis::bool) ⟹ thesis›*) using in_GSMP_in_proj[OF t ( 1 )] (*‹∃n. t ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜))›*) apply atomize_elim (*goal: ‹(⋀n::'a::type. (t::('fun::type, 'var::type) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj n (𝒜::('a::type strand_label × ('fun::type, 'var::type) strand_step) list))) ⟹ thesis::bool) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) using GSMP_proj_is_homogeneous[OF 𝒜 n t ( 2 )] (*‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) by metis qed private lemma GSMP_intersection_is_homogeneous: assumes 𝒜: "∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and t: "t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜) ∩ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)" "l ≠ l'" shows "homogeneous⇩l⇩s⇩t t 𝒜 Sec" proof (-) (*goal: ‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) define M where "M ≡ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" define M' where "M' ≡ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)" have t_in: "t ∈ M ∩ M'" "t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" using t(1) (*‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))›*) in_proj_in_GSMP[of t _ 𝒜] (*‹t ∈ GSMP (trms⇩l⇩s⇩t (proj ?n 𝒜)) ⟹ t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) unfolding M_def M'_def (*goals: 1. ‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))› 2. ‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) apply - (*goals: 1. ‹⟦t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)); ⋀n. t ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)) ⟹ t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))› 2. ‹⟦t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)); ⋀n. t ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)) ⟹ t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . have "M ∩ M' ⊆ Sec ∪ {m. {} ⊢⇩c m}" using "𝒜" (*‹∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec›*) GSMP_disjointE[of l 𝒜 l' Sec] (*‹GSMP_disjoint (trms⇩l⇩s⇩t (proj l 𝒜)) (trms⇩l⇩s⇩t (proj l' 𝒜)) Sec ⟹ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)) ⊆ Sec ∪ {m. {} ⊢⇩c m}›*) t(2) (*‹l ≠ l'›*) unfolding M_def M'_def (*goal: ‹GSMP (trms⇩l⇩s⇩t (proj (l::'a) (𝒜::('a strand_label × ('fun, 'var) strand_step) list))) ∩ GSMP (trms⇩l⇩s⇩t (proj (l'::'a) 𝒜)) ⊆ (Sec::('fun, 'var) Term.term set) ∪ {m::('fun, 'var) Term.term. {} ⊢⇩c m}›*) by presburger moreover have "subterms⇩s⇩e⇩t (M ∩ M') = M ∩ M'" using GSMP_subterms (*‹subterms⇩s⇩e⇩t (GSMP ?M) = GSMP ?M›*) unfolding M_def M'_def (*goal: ‹subterms⇩s⇩e⇩t (GSMP (trms⇩l⇩s⇩t (proj (l::'a) (𝒜::('a strand_label × ('fun, 'var) strand_step) list))) ∩ GSMP (trms⇩l⇩s⇩t (proj (l'::'a) 𝒜))) = GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))›*) by blast ultimately have "*": "subterms⇩s⇩e⇩t (M ∩ M') ⊆ Sec ∪ {m. {} ⊢⇩c m}" by blast show "?thesis" (*goal: ‹homogeneous⇩l⇩s⇩t (t::('fun, 'var) Term.term) (𝒜::('a strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)›*) proof (cases "t ∈ Sec") (*goals: 1. ‹t ∈ Sec ⟹ homogeneous⇩l⇩s⇩t t 𝒜 Sec› 2. ‹t ∉ Sec ⟹ homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) case True (*‹t ∈ Sec›*) thus "?thesis" (*goal: ‹homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) using "*" (*‹subterms⇩s⇩e⇩t (M ∩ M') ⊆ Sec ∪ {m. {} ⊢⇩c m}›*) secrets_are_homogeneous[of Sec "λt. t ∈ M ∩ M'", OF _ _ t_in ( 1 )] (*‹⟦∀s∈Sec. s ∈ M ∩ M' ⟶ (∀s'∈subterms s. {} ⊢⇩c s' ∨ s' ∈ Sec); t ∈ Sec⟧ ⟹ homogeneous⇩l⇩s⇩t t ?𝒜 Sec›*) by fast qed (metis GSMP_is_homogeneous[OF 𝒜 t_in(2)] (*‹t ∉ Sec ⟹ homogeneous⇩l⇩s⇩t t 𝒜 Sec›*)) (*solved the remaining goal: ‹(t::('fun, 'var) Term.term) ∉ (Sec::('fun, 'var) Term.term set) ⟹ homogeneous⇩l⇩s⇩t t (𝒜::('a strand_label × ('fun, 'var) strand_step) list) Sec›*) qed private lemma GSMP_is_homogeneous': assumes 𝒜: "∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and t: "t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" "t ∉ Sec - ⋃{GSMP (trms_proj⇩l⇩s⇩t l1 𝒜) ∩ GSMP (trms_proj⇩l⇩s⇩t l2 𝒜) | l1 l2. l1 ≠ l2}" shows "homogeneous⇩l⇩s⇩t t 𝒜 Sec" using GSMP_is_homogeneous[OF 𝒜 t ( 1 )] (*‹t ∉ Sec ⟹ homogeneous⇩l⇩s⇩t t 𝒜 Sec›*) GSMP_intersection_is_homogeneous[OF 𝒜] (*‹⟦(?t::('fun::type, 'var::type) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (?l::'a::type) (𝒜::('a::type strand_label × ('fun::type, 'var::type) strand_step) list))) ∩ GSMP (trms⇩l⇩s⇩t (proj (?l'::'a::type) 𝒜)); ?l ≠ ?l'⟧ ⟹ homogeneous⇩l⇩s⇩t ?t 𝒜 (Sec::('fun::type, 'var::type) Term.term set)›*) t(2) (*‹(t::('fun, 'var) Term.term) ∉ (Sec::('fun, 'var) Term.term set) - ⋃ {GSMP (trms⇩l⇩s⇩t (proj l1 (𝒜::('a strand_label × ('fun, 'var) strand_step) list))) ∩ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) |(l1::'a) l2::'a. l1 ≠ l2}›*) by blast private lemma Ana_keys_homogeneous: assumes 𝒜: "∀l l'. l ≠ l' ⟶ GSMP_disjoint (trms_proj⇩l⇩s⇩t l 𝒜) (trms_proj⇩l⇩s⇩t l' 𝒜) Sec" and t: "t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" and k: "Ana t = (K,T)" "k ∈ set K" "k ∉ Sec - ⋃{GSMP (trms_proj⇩l⇩s⇩t l1 𝒜) ∩ GSMP (trms_proj⇩l⇩s⇩t l2 𝒜) | l1 l2. l1 ≠ l2}" shows "homogeneous⇩l⇩s⇩t k 𝒜 Sec" proof (cases "k ∈ ⋃{GSMP (trms_proj⇩l⇩s⇩t l1 𝒜) ∩ GSMP (trms_proj⇩l⇩s⇩t l2 𝒜) | l1 l2. l1 ≠ l2}") (*goals: 1. ‹k ∈ ⋃ {GSMP (trms⇩l⇩s⇩t (proj l1 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) |l1 l2. l1 ≠ l2} ⟹ homogeneous⇩l⇩s⇩t k 𝒜 Sec› 2. ‹k ∉ ⋃ {GSMP (trms⇩l⇩s⇩t (proj l1 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) |l1 l2. l1 ≠ l2} ⟹ homogeneous⇩l⇩s⇩t k 𝒜 Sec›*) case False (*‹k ∉ ⋃ {GSMP (trms⇩l⇩s⇩t (proj l1 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) |l1 l2. l1 ≠ l2}›*) hence "k ∉ Sec" using k(3) (*‹k ∉ Sec - ⋃ {GSMP (trms⇩l⇩s⇩t (proj l1 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) |l1 l2. l1 ≠ l2}›*) by fast moreover have "k ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" using t (*‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) SMP.Ana[OF _ k ( 1 , 2 )] (*‹t ∈ SMP ?M ⟹ k ∈ SMP ?M›*) Ana_keys_fv[OF k ( 1 )] (*‹fv⇩s⇩e⇩t (set (K::('fun, 'var) Term.term list)) ⊆ fv (t::('fun, 'var) Term.term)›*) k(2) (*‹k ∈ set K›*) unfolding GSMP_def (*goal: ‹k ∈ {t ∈ SMP (trms⇩l⇩s⇩t 𝒜). fv t = {}}›*) by auto ultimately show "?thesis" (*goal: ‹homogeneous⇩l⇩s⇩t k 𝒜 Sec›*) using GSMP_is_homogeneous[OF 𝒜, of k] (*‹⟦k ∈ GSMP (trms⇩l⇩s⇩t 𝒜); k ∉ Sec⟧ ⟹ homogeneous⇩l⇩s⇩t k 𝒜 Sec›*) by metis qed (use GSMP_intersection_is_homogeneous[OF 𝒜] in blast) (*solved the remaining goal: ‹k ∈ ⋃ {GSMP (trms⇩l⇩s⇩t (proj l1 𝒜)) ∩ GSMP (trms⇩l⇩s⇩t (proj l2 𝒜)) |l1 l2. l1 ≠ l2} ⟹ homogeneous⇩l⇩s⇩t k 𝒜 Sec›*) end subsection ‹Lemmata: Intruder Deduction Equivalences› lemma deduct_if_hom_deduct: "⟨M;A⟩ ⊢⇩G⇩S⇩M⇩P m ⟹ M ⊢ m" using deduct_if_restricted_deduct (*‹⟨?M::('fun, 'var) Term.term set;?P::('fun, 'var) Term.term ⇒ bool⟩ ⊢⇩r ?m::('fun, 'var) Term.term ⟹ ?M ⊢ ?m›*) unfolding intruder_deduct_hom_def (*goal: ‹⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t A)⟩ ⊢⇩r m ⟹ M ⊢ m›*) by blast lemma hom_deduct_if_hom_ik: assumes "⟨M;A⟩ ⊢⇩G⇩S⇩M⇩P m" "∀m ∈ M. m ∈ GSMP (trms⇩l⇩s⇩t A)" shows "m ∈ GSMP (trms⇩l⇩s⇩t A)" proof (-) (*goal: ‹m ∈ GSMP (trms⇩l⇩s⇩t A)›*) let ?Q = "λm. m ∈ GSMP (trms⇩l⇩s⇩t A)" have "?Q t'" if "?Q t" "t' ⊑ t" for t and t' using GSMP_subterm[OF _ that ( 2 )] (*‹t ∈ GSMP ?M ⟹ t' ∈ GSMP ?M›*) that(1) (*‹t ∈ GSMP (trms⇩l⇩s⇩t A)›*) by blast thus "?thesis" (*goal: ‹m ∈ GSMP (trms⇩l⇩s⇩t A)›*) using assms(1) (*‹⟨M::('fun, 'var) Term.term set;A::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P m::('fun, 'var) Term.term›*) restricted_deduct_if_restricted_ik[OF _ assms ( 2 )] (*‹⟦⟨M;λm. m ∈ GSMP (trms⇩l⇩s⇩t A)⟩ ⊢⇩r ?m; ∀t t'. t ∈ GSMP (trms⇩l⇩s⇩t A) ⟶ t' ⊑ t ⟶ t' ∈ GSMP (trms⇩l⇩s⇩t A)⟧ ⟹ ?m ∈ GSMP (trms⇩l⇩s⇩t A)›*) unfolding intruder_deduct_hom_def (*goal: ‹m ∈ GSMP (trms⇩l⇩s⇩t A)›*) by blast qed lemma deduct_hom_if_synth: assumes hom: "m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" and m: "M ⊢⇩c m" shows "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P m" proof (-) (*goal: ‹⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P m›*) let ?Q = "λm. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" have "?Q t'" if "?Q t" "t' ⊑ t" for t and t' using GSMP_subterm[OF _ that ( 2 )] (*‹t ∈ GSMP ?M ⟹ t' ∈ GSMP ?M›*) that(1) (*‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by blast thus "?thesis" (*goal: ‹⟨M::('fun, 'var) Term.term set;𝒜::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P m::('fun, 'var) Term.term›*) using assms (*‹m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)› ‹(M::('fun, 'var) Term.term set) ⊢⇩c (m::('fun, 'var) Term.term)›*) deduct_restricted_if_synth[of ?Q] (*‹⟦?m ∈ GSMP (trms⇩l⇩s⇩t 𝒜); ∀t t'. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜) ⟶ t' ⊑ t ⟶ t' ∈ GSMP (trms⇩l⇩s⇩t 𝒜); ?M ⊢⇩c ?m⟧ ⟹ ⟨?M;λm. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r ?m›*) unfolding intruder_deduct_hom_def (*goal: ‹⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r m›*) by blast qed lemma hom_deduct_if_deduct: assumes M: "∀m ∈ M. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" and m: "M ⊢ m" "m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" shows "⟨M; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P m" proof (-) (*goal: ‹⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P m›*) let ?P = "λx. x ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" have P_Ana: "?P k" if "?P t" "Ana t = (K, T)" "k ∈ set K" for t and K and T and k using GSMP_Ana_key[OF _ that ( 2 , 3 ), of "trms⇩l⇩s⇩t 𝒜"] (*‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜) ⟹ k ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) that (*‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)› ‹Ana t = (K, T)› ‹k ∈ set K›*) by presburger have P_subterm: "?P t'" if "?P t" "t' ⊑ t" for t and t' using GSMP_subterm[of _ "trms⇩l⇩s⇩t 𝒜"] (*‹⟦?t ∈ GSMP (trms⇩l⇩s⇩t 𝒜); ?t' ⊑ ?t⟧ ⟹ ?t' ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) that (*‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)› ‹t' ⊑ t›*) by blast have P_m: "?P m" using m(2) (*‹m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by metis show "?thesis" (*goal: ‹⟨M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P m›*) using restricted_deduct_if_deduct'[OF M _ _ m ( 1 ) P_m] (*‹⟦∀t t'. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜) ⟶ t' ⊑ t ⟶ t' ∈ GSMP (trms⇩l⇩s⇩t 𝒜); ∀t K T k. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜) ⟶ Ana t = (K, T) ⟶ k ∈ set K ⟶ k ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ ⟨M;λa. a ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r m›*) P_Ana (*‹⟦?t5 ∈ GSMP (trms⇩l⇩s⇩t 𝒜); Ana ?t5 = (?K5, ?T5); ?k5 ∈ set ?K5⟧ ⟹ ?k5 ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) P_subterm (*‹⟦?t5 ∈ GSMP (trms⇩l⇩s⇩t 𝒜); ?t'5 ⊑ ?t5⟧ ⟹ ?t'5 ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) unfolding intruder_deduct_hom_def (*goal: ‹⟨M;λt. t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟩ ⊢⇩r m›*) by fast qed subsection ‹Lemmata: Deduction Reduction of Parallel Composable Constraints› lemma par_comp_hom_deduct: assumes 𝒜: "par_comp 𝒜 Sec" and M: "∀l. M l ⊆ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" "∀l. Discl ⊆ {s. M l ⊢ s}" and Sec: "∀l. ∀s ∈ Sec - Discl. ¬(⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P s)" and t: "⟨⋃l. M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" shows "t ∉ Sec - Discl" (is ?A) "∀l. t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜) ⟶ ⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" (is ?B) proof (-) (*goals: 1. ‹t ∉ Sec - Discl› 2. ‹∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*) have M': "∀l. ∀m ∈ M l. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) ballI (*‹(⋀x. x ∈ ?A ⟹ ?P x) ⟹ ∀x∈?A. ?P x›*)) (*goal: ‹⋀(l::'lbl) m::('fun, 'var) Term.term. m ∈ (M::'lbl ⇒ ('fun, 'var) Term.term set) l ⟹ m ∈ GSMP (trms⇩l⇩s⇩t (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list))›*) fix l and m show "m ∈ M l ⟹ m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" using M(1) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) in_proj_in_GSMP[of m l 𝒜] (*‹m ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by blast qed have Discl_hom_deduct: "⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P u" if u: "u ∈ Discl" "u ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" for l and u proof (-) (*goal: ‹⟨(M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) (l::'lbl::type);𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P u::('fun::type, 'var::type) Term.term›*) have "M l ⊢ u" using M(2) (*‹∀l. Discl ⊆ {s. M l ⊢ s}›*) u (*‹u ∈ Discl› ‹u ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by auto thus "?thesis" (*goal: ‹⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P u›*) using hom_deduct_if_deduct[of "M l" 𝒜 u] (*‹⟦∀m∈M l. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜); M l ⊢ u; u ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P u›*) M(1) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) M' (*‹∀l::'lbl::type. ∀m::('fun::type, 'var::type) Term.term∈(M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) l. m ∈ GSMP (trms⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))›*) u (*‹(u::('fun, 'var) Term.term) ∈ (Discl::('fun, 'var) Term.term set)› ‹u ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by auto qed show "?A" "?B" using t (*‹⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*) proof (induction t rule: intruder_deduct_hom_induct (*‹⟦⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?t; ⋀t. t ∈ ?M ⟹ ?P ?M t; ⋀X f. ⟦length X = arity f; public f; ⋀x. x ∈ set X ⟹ ⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set X ⟹ ?P ?M x; Fun f X ∈ GSMP (trms⇩l⇩s⇩t ?𝒜)⟧ ⟹ ?P ?M (Fun f X); ⋀t K T t⇩i. ⟦⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; ?P ?M t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ ?P ?M k; t⇩i ∈ set T⟧ ⟹ ?P ?M t⇩i⟧ ⟹ ?P ?M ?t›*)) (*goals: 1. ‹⋀t. t ∈ ⋃ (range M) ⟹ t ∉ Sec - Discl› 2. ‹⋀t. t ∈ ⋃ (range M) ⟹ ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t› 3. ‹⋀X f. ⟦length X = arity f; public f; ⋀x. x ∈ set X ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set X ⟹ x ∉ Sec - Discl; ⋀x. x ∈ set X ⟹ ∀l. x ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ Fun f X ∉ Sec - Discl› 4. ‹⋀X f. ⟦length X = arity f; public f; ⋀x. x ∈ set X ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set X ⟹ x ∉ Sec - Discl; ⋀x. x ∈ set X ⟹ ∀l. x ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ ∀l. Fun f X ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f X› 5. ‹⋀t K T t⇩i. ⟦⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; t ∉ Sec - Discl; ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ k ∉ Sec - Discl; ⋀k. k ∈ set K ⟹ ∀l. k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; t⇩i ∈ set T⟧ ⟹ t⇩i ∉ Sec - Discl› 6. ‹⋀t K T t⇩i. ⟦⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; t ∉ Sec - Discl; ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ k ∉ Sec - Discl; ⋀k. k ∈ set K ⟹ ∀l. k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; t⇩i ∈ set T⟧ ⟹ ∀l. t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) case (AxiomH t) (*‹t ∈ ⋃ (range M)›*) then obtain lt where t_in_proj_ik: "t ∈ M lt" (*goal: ‹(⋀lt. t ∈ M lt ⟹ thesis) ⟹ thesis›*) apply atomize_elim (*goal: ‹(⋀lt. t ∈ M lt ⟹ thesis) ⟹ thesis›*) by auto show t_not_Sec: "t ∉ Sec - Discl" proof (standard) (*goal: ‹t ∈ Sec - Discl ⟹ False›*) assume "t ∈ Sec - Discl" (*‹(t::('fun, 'var) Term.term) ∈ (Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set)›*) hence "∀l. ¬(⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t)" using Sec (*‹∀l::'lbl. ∀s::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set). ¬ ⟨(M::'lbl ⇒ ('fun, 'var) Term.term set) l;𝒜::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P s›*) by auto thus False using intruder_deduct_hom_AxiomH[OF t_in_proj_ik] (*‹⟨M lt;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*) by metis qed have 1: "∀l. t ∈ M l ⟶ t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" using M(1,2) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))› ‹∀l::'lbl. (Discl::('fun, 'var) Term.term set) ⊆ {s::('fun, 'var) Term.term. (M::'lbl ⇒ ('fun, 'var) Term.term set) l ⊢ s}›*) AxiomH (*‹t ∈ ⋃ (range M)›*) by auto have 3: "{} ⊢⇩c t ∨ t ∈ Discl" if "l1 ≠ l2" "t ∈ GSMP (trms_proj⇩l⇩s⇩t l1 𝒜) ∩ GSMP (trms_proj⇩l⇩s⇩t l2 𝒜)" for l1 and l2 using "𝒜" (*‹par_comp 𝒜 Sec›*) t_not_Sec (*‹t ∉ Sec - Discl›*) that (*‹l1 ≠ l2› ‹(t::('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (l1::'lbl) (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list))) ∩ GSMP (trms⇩l⇩s⇩t (proj (l2::'lbl) 𝒜))›*) by (auto simp add: par_comp_def (*‹par_comp ?𝒜 ?Secrets ≡ (∀l1 l2. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 ?𝒜)) (trms⇩l⇩s⇩t (proj l2 ?𝒜)) ?Secrets) ∧ (∀s∈?Secrets. ¬ {} ⊢⇩c s) ∧ Messages.ground ?Secrets›*) GSMP_disjoint_def (*‹GSMP_disjoint ?P1.0 ?P2.0 ?Secrets ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m. {} ⊢⇩c m}›*)) have 4: "t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" using M(1) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) M' (*‹∀l. ∀m∈M l. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) t_in_proj_ik (*‹(t::('fun::type, 'var::type) Term.term) ∈ (M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) (lt::'lbl::type)›*) by auto show "∀l. t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜) ⟶ ⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t" by (metis (lifting) Int_iff (*‹((?c::?'a::type) ∈ (?A::?'a::type set) ∩ (?B::?'a::type set)) = (?c ∈ ?A ∧ ?c ∈ ?B)›*) empty_subsetI (*‹{} ⊆ (?A::?'a::type set)›*) 1 (*‹∀l::'lbl::type. (t::('fun::type, 'var::type) Term.term) ∈ (M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) l ⟶ t ∈ GSMP (trms⇩l⇩s⇩t (proj l (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)))›*) 3 (*‹⟦(?l1.5::'lbl::type) ≠ (?l2.5::'lbl::type); (t::('fun::type, 'var::type) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj ?l1.5 (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))) ∩ GSMP (trms⇩l⇩s⇩t (proj ?l2.5 𝒜))⟧ ⟹ {} ⊢⇩c t ∨ t ∈ (Discl::('fun::type, 'var::type) Term.term set)›*) 4 (*‹(t::('fun::type, 'var::type) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))›*) Discl_hom_deduct (*‹⟦(?u5::('fun::type, 'var::type) Term.term) ∈ (Discl::('fun::type, 'var::type) Term.term set); ?u5 ∈ GSMP (trms⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))⟧ ⟹ ⟨(M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) (?l5::'lbl::type);𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?u5›*) t_in_proj_ik (*‹(t::('fun::type, 'var::type) Term.term) ∈ (M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) (lt::'lbl::type)›*) intruder_deduct_hom_AxiomH[of t _ 𝒜] (*‹(t::('fun::type, 'var::type) Term.term) ∈ (?M::('fun::type, 'var::type) Term.term set) ⟹ ⟨?M;𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P t›*) deduct_hom_if_synth[of t 𝒜 "{}"] (*‹⟦(t::('fun::type, 'var::type) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)); {} ⊢⇩c t⟧ ⟹ ⟨{};𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*) ideduct_hom_mono[of "{}" 𝒜 t] (*‹⟦⟨{};𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P t::('fun::type, 'var::type) Term.term; {} ⊆ (?M'::('fun::type, 'var::type) Term.term set)⟧ ⟹ ⟨?M';𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*)) next (*goals: 1. ‹⋀X f. ⟦length X = arity f; public f; ⋀x. x ∈ set X ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set X ⟹ x ∉ Sec - Discl; ⋀x. x ∈ set X ⟹ ∀l. x ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ Fun f X ∉ Sec - Discl› 2. ‹⋀X f. ⟦length X = arity f; public f; ⋀x. x ∈ set X ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; ⋀x. x ∈ set X ⟹ x ∉ Sec - Discl; ⋀x. x ∈ set X ⟹ ∀l. x ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P x; Fun f X ∈ GSMP (trms⇩l⇩s⇩t 𝒜)⟧ ⟹ ∀l. Fun f X ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f X› 3. ‹⋀t K T t⇩i. ⟦⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; t ∉ Sec - Discl; ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ k ∉ Sec - Discl; ⋀k. k ∈ set K ⟹ ∀l. k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; t⇩i ∈ set T⟧ ⟹ t⇩i ∉ Sec - Discl› 4. ‹⋀t K T t⇩i. ⟦⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; t ∉ Sec - Discl; ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ k ∉ Sec - Discl; ⋀k. k ∈ set K ⟹ ∀l. k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; t⇩i ∈ set T⟧ ⟹ ∀l. t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) case (ComposeH T f) (*‹length T = arity f› ‹public f› ‹?x5 ∈ set T ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?x5› ‹Fun f T ∈ GSMP (trms⇩l⇩s⇩t 𝒜)› ‹?x5 ∈ set T ⟹ ?x5 ∉ Sec - Discl› ‹?x5 ∈ set T ⟹ ∀l. ?x5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?x5›*) show "∀l. Fun f T ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜) ⟶ ⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f T" proof (intro allI (*‹(⋀x. ?P x) ⟹ ∀x. ?P x›*) impI (*‹(?P ⟹ ?Q) ⟹ ?P ⟶ ?Q›*)) (*goal: ‹⋀l. Fun f T ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f T›*) fix l assume "Fun f T ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" (*‹Fun (f::'fun) (T::('fun, 'var) Term.term list) ∈ GSMP (trms⇩l⇩s⇩t (proj (l::'lbl) (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)))›*) hence "t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" if "t ∈ set T" for t using that (*‹(t::('fun, 'var) Term.term) ∈ set (T::('fun, 'var) Term.term list)›*) GSMP_subterm[OF _ subtermeqI''] (*‹⟦Fun (?f1::'fun) (?T1::('fun, 'var) Term.term list) ∈ GSMP (?M::('fun, 'var) Term.term set); (?t'::('fun, 'var) Term.term) ∈ set ?T1⟧ ⟹ ?t' ∈ GSMP ?M›*) by auto thus "⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f T" using ComposeH.IH(2) (*‹?x5 ∈ set T ⟹ ∀l. ?x5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?x5›*) intruder_deduct_hom_ComposeH[OF ComposeH.hyps ( 1 , 2 ) _ ComposeH.hyps ( 4 )] (*‹(⋀x. x ∈ set T ⟹ ⟨?M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P x) ⟹ ⟨?M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P Fun f T›*) by simp qed thus "Fun f T ∉ Sec - Discl" using Sec (*‹∀l. ∀s∈Sec - Discl. ¬ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P s›*) ComposeH.hyps(4) (*‹Fun f T ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) "trms⇩l⇩s⇩t_union"[of 𝒜] (*‹trms⇩l⇩s⇩t 𝒜 = (⋃l. trms⇩l⇩s⇩t (proj l 𝒜))›*) GSMP_Union[of 𝒜] (*‹GSMP (trms⇩l⇩s⇩t 𝒜) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l 𝒜)))›*) by blast next (*goals: 1. ‹⋀t K T t⇩i. ⟦⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; t ∉ Sec - Discl; ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ k ∉ Sec - Discl; ⋀k. k ∈ set K ⟹ ∀l. k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; t⇩i ∈ set T⟧ ⟹ t⇩i ∉ Sec - Discl› 2. ‹⋀t K T t⇩i. ⟦⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; t ∉ Sec - Discl; ∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; ⋀k. k ∈ set K ⟹ k ∉ Sec - Discl; ⋀k. k ∈ set K ⟹ ∀l. k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P k; t⇩i ∈ set T⟧ ⟹ ∀l. t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) case (DecomposeH t K T t⇩i) (*‹⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t› ‹(Ana::('fun, 'var) Term.term ⇒ ('fun, 'var) Term.term list × ('fun, 'var) Term.term list) (t::('fun, 'var) Term.term) = (K::('fun, 'var) Term.term list, T::('fun, 'var) Term.term list)› ‹?k5 ∈ set K ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?k5› ‹(t⇩i::('fun, 'var) Term.term) ∈ set (T::('fun, 'var) Term.term list)› ‹(t::('fun, 'var) Term.term) ∉ (Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set)› ‹∀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t› ‹?k5 ∈ set K ⟹ ?k5 ∉ Sec - Discl› ‹?k5 ∈ set K ⟹ ∀l. ?k5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?k5›*) have ti_subt: "t⇩i ⊑ t" using Ana_subterm[OF DecomposeH.hyps ( 2 )] (*‹set T ⊂ subterms t›*) ‹t⇩i ∈ set T› (*‹t⇩i ∈ set T›*) by auto have t: "t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" using DecomposeH.hyps(1) (*‹⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*) hom_deduct_if_hom_ik (*‹⟦⟨?M::('fun, 'var) Term.term set;?A::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P ?m::('fun, 'var) Term.term; ∀m::('fun, 'var) Term.term∈?M. m ∈ GSMP (trms⇩l⇩s⇩t ?A)⟧ ⟹ ?m ∈ GSMP (trms⇩l⇩s⇩t ?A)›*) M(1) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) M' (*‹∀l. ∀m∈M l. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by auto have ti: "t⇩i ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" using intruder_deduct_hom_DecomposeH[OF DecomposeH.hyps] (*‹(⋀k. k ∈ set K ⟹ k ∈ set K) ⟹ ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) hom_deduct_if_hom_ik (*‹⟦⟨?M::('fun, 'var) Term.term set;?A::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P ?m::('fun, 'var) Term.term; ∀m::('fun, 'var) Term.term∈?M. m ∈ GSMP (trms⇩l⇩s⇩t ?A)⟧ ⟹ ?m ∈ GSMP (trms⇩l⇩s⇩t ?A)›*) M(1) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) M' (*‹∀l. ∀m∈M l. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by auto obtain l where l: "t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" (*goal: ‹(⋀l. t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ thesis) ⟹ thesis›*) using in_GSMP_in_proj[of _ 𝒜] (*‹?t ∈ GSMP (trms⇩l⇩s⇩t 𝒜) ⟹ ∃n. ?t ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜))›*) ti (*‹t⇩i ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) t (*‹t ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by presburger have K_IH: "⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P k" if "k ∈ set K" for k using that (*‹k ∈ set K›*) GSMP_Ana_key[OF _ DecomposeH.hyps ( 2 )] (*‹⟦(t::('fun::type, 'var::type) Term.term) ∈ GSMP (?M::('fun::type, 'var::type) Term.term set); (?k::('fun::type, 'var::type) Term.term) ∈ set (K::('fun::type, 'var::type) Term.term list)⟧ ⟹ ?k ∈ GSMP ?M›*) DecomposeH.IH(4) (*‹?k5 ∈ set K ⟹ ∀l. ?k5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?k5›*) l (*‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) by auto have ti_IH: "⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i" using K_IH (*‹?k5 ∈ set K ⟹ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?k5›*) DecomposeH.IH(2) (*‹∀l::'lbl. (t::('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list))) ⟶ ⟨(M::'lbl ⇒ ('fun, 'var) Term.term set) l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t›*) l (*‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) intruder_deduct_hom_DecomposeH[OF _ DecomposeH.hyps ( 2 ) _ ‹t⇩i ∈ set T›] (*‹⟦⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P t; ⋀k. k ∈ set K ⟹ ⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P k⟧ ⟹ ⟨?M;?𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) by blast thus ti_not_Sec: "t⇩i ∉ Sec - Discl" using Sec (*‹∀l. ∀s∈Sec - Discl. ¬ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P s›*) by blast have "{} ⊢⇩c t⇩i ∨ t⇩i ∈ Discl" if "t⇩i ∈ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)" "l' ≠ l" for l' proof (-) (*goal: ‹{} ⊢⇩c (t⇩i::('fun, 'var) Term.term) ∨ t⇩i ∈ (Discl::('fun, 'var) Term.term set)›*) have "GSMP_disjoint (trms_proj⇩l⇩s⇩t l' 𝒜) (trms_proj⇩l⇩s⇩t l 𝒜) Sec" using that(2) (*‹l' ≠ l›*) "𝒜" (*‹par_comp (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) (Sec::('fun, 'var) Term.term set)›*) by (simp add: par_comp_def (*‹par_comp ?𝒜 ?Secrets ≡ (∀l1 l2. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 ?𝒜)) (trms⇩l⇩s⇩t (proj l2 ?𝒜)) ?Secrets) ∧ (∀s∈?Secrets. ¬ {} ⊢⇩c s) ∧ Messages.ground ?Secrets›*)) thus "?thesis" (*goal: ‹{} ⊢⇩c t⇩i ∨ t⇩i ∈ Discl›*) using ti_not_Sec (*‹(t⇩i::('fun, 'var) Term.term) ∉ (Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set)›*) GSMP_subterm[OF l ti_subt] (*‹(t⇩i::('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (l::'lbl) (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)))›*) that(1) (*‹t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))›*) by (auto simp add: GSMP_disjoint_def (*‹GSMP_disjoint ?P1.0 ?P2.0 ?Secrets ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m. {} ⊢⇩c m}›*)) qed hence "⟨M l'; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i" if "t⇩i ∈ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)" "l' ≠ l" for l' using that (*‹t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))› ‹l' ≠ l›*) Discl_hom_deduct[OF _ ti] (*‹t⇩i ∈ Discl ⟹ ⟨M ?l5;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) deduct_hom_if_synth[OF ti, THEN ideduct_hom_mono [ OF _ empty_subsetI ]] (*‹{} ⊢⇩c t⇩i ⟹ ⟨?M';𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i›*) apply (cases "t⇩i ∈ Discl") (*goals: 1. ‹⟦⋀l'. ⟦t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)); l' ≠ l⟧ ⟹ {} ⊢⇩c t⇩i ∨ t⇩i ∈ Discl; t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)); l' ≠ l; ⋀l. t⇩i ∈ Discl ⟹ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i; ⋀M'. {} ⊢⇩c t⇩i ⟹ ⟨M';𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i; t⇩i ∈ Discl⟧ ⟹ ⟨M l';𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i› 2. ‹⟦⋀l'. ⟦t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)); l' ≠ l⟧ ⟹ {} ⊢⇩c t⇩i ∨ t⇩i ∈ Discl; t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜)); l' ≠ l; ⋀l. t⇩i ∈ Discl ⟹ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i; ⋀M'. {} ⊢⇩c t⇩i ⟹ ⟨M';𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i; t⇩i ∉ Discl⟧ ⟹ ⟨M l';𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . thus "∀l. t⇩i ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜) ⟶ ⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i" using ti_IH (*‹⟨(M::'lbl ⇒ ('fun, 'var) Term.term set) (l::'lbl);𝒜::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P t⇩i::('fun, 'var) Term.term›*) by blast qed qed lemma par_comp_deduct_proj: assumes 𝒜: "par_comp 𝒜 Sec" and M: "∀l. M l ⊆ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" "∀l. Discl ⊆ {s. M l ⊢ s}" and t: "(⋃l. M l) ⊢ t" "t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" shows "M l ⊢ t ∨ (∃s ∈ Sec - Discl. ∃l. M l ⊢ s)" using t (*‹⋃ (range (M::'lbl ⇒ ('fun, 'var) Term.term set)) ⊢ (t::('fun, 'var) Term.term)› ‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) proof (induction t rule: intruder_deduct_induct (*‹⟦?M ⊢ ?t; ⋀t. t ∈ ?M ⟹ ?P ?M t; ⋀T f. ⟦length T = arity f; public f; ⋀t. t ∈ set T ⟹ ?M ⊢ t; ⋀t. t ∈ set T ⟹ ?P ?M t⟧ ⟹ ?P ?M (Fun f T); ⋀t K T t⇩i. ⟦?M ⊢ t; ?P ?M t; Ana t = (K, T); ⋀k. k ∈ set K ⟹ ?M ⊢ k; ⋀k. k ∈ set K ⟹ ?P ?M k; t⇩i ∈ set T⟧ ⟹ ?P ?M t⇩i⟧ ⟹ ?P ?M ?t›*)) (*goals: 1. ‹⋀t. ⟦t ∈ ⋃ (range M); t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ t ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s)› 2. ‹⋀T f. ⟦length T = arity f; public f; ⋀t. t ∈ set T ⟹ ⋃ (range M) ⊢ t; ⋀t. ⟦t ∈ set T; t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ t ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); Fun f T ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ Fun f T ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s)› 3. ‹⋀t K T t⇩i. ⟦⋃ (range M) ⊢ t; t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ M l ⊢ t ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⋃ (range M) ⊢ k; ⋀k. ⟦k ∈ set K; k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ k ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); t⇩i ∈ set T; t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ t⇩i ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s)›*) case (Axiom t) (*‹t ∈ ⋃ (range M)› ‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) then obtain l' where t_in_ik_proj: "t ∈ M l'" (*goal: ‹(⋀l'. t ∈ M l' ⟹ thesis) ⟹ thesis›*) apply atomize_elim (*goal: ‹(⋀l'::'lbl. (t::('fun, 'var) Term.term) ∈ (M::'lbl ⇒ ('fun, 'var) Term.term set) l' ⟹ thesis::bool) ⟹ thesis›*) by auto show "?case" (*goal: ‹intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)›*) proof (cases "t ∈ Sec - Discl ∨ {} ⊢⇩c t") (*goals: 1. ‹t ∈ Sec - Discl ∨ {} ⊢⇩c t ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› 2. ‹¬ (t ∈ Sec - Discl ∨ {} ⊢⇩c t) ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)›*) case True (*‹t ∈ Sec - Discl ∨ {} ⊢⇩c t›*) thus "?thesis" (*goal: ‹intruder_deduct ((M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) (l::'lbl::type)) (t::('fun::type, 'var::type) Term.term) ∨ (∃s::('fun::type, 'var::type) Term.term∈(Sec::('fun::type, 'var::type) Term.term set) - (Discl::('fun::type, 'var::type) Term.term set). ∃l::'lbl::type. intruder_deduct (M l) s)›*) apply (cases "t ∈ Sec - Discl") (*goals: 1. ‹⟦t ∈ Sec - Discl ∨ {} ⊢⇩c t; t ∈ Sec - Discl⟧ ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› 2. ‹⟦t ∈ Sec - Discl ∨ {} ⊢⇩c t; t ∉ Sec - Discl⟧ ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› discuss goal 1*) apply (metis intruder_deduct.Axiom[OF t_in_ik_proj] (*‹M l' ⊢ t›*)) (*discuss goal 2*) apply (use ideduct_mono[of "{}" t "M l"] in blast) (*proven 2 subgoals*) . next (*goal: ‹¬ (t ∈ Sec - Discl ∨ {} ⊢⇩c t) ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)›*) case False (*‹¬ (t ∈ Sec - Discl ∨ {} ⊢⇩c t)›*) hence "t ∉ Sec - Discl" "¬{} ⊢⇩c t" "t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" using Axiom (*‹t ∈ ⋃ (range M)› ‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) apply - (*goals: 1. ‹⟦¬ (t ∈ Sec - Discl ∨ {} ⊢⇩c t); t ∈ ⋃ (range M); t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ t ∉ Sec - Discl› 2. ‹⟦¬ (t ∈ Sec - Discl ∨ {} ⊢⇩c t); t ∈ ⋃ (range M); t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ ¬ {} ⊢⇩c t› 3. ‹⟦¬ (t ∈ Sec - Discl ∨ {} ⊢⇩c t); t ∈ ⋃ (range M); t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . hence "(∀l'. l ≠ l' ⟶ t ∉ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)) ∨ t ∈ Discl" using "𝒜" (*‹par_comp 𝒜 Sec›*) unfolding GSMP_disjoint_def par_comp_def (*goal: ‹(∀l'. l ≠ l' ⟶ t ∉ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))) ∨ t ∈ Discl›*) by auto hence "(∀l'. l ≠ l' ⟶ t ∉ GSMP (trms_proj⇩l⇩s⇩t l' 𝒜)) ∨ M l ⊢ t ∨ {} ⊢⇩c t" using M (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))› ‹∀l. Discl ⊆ {s. M l ⊢ s}›*) by blast thus "?thesis" (*goal: ‹intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)›*) apply (cases "∃s ∈ M l. t ⊑ s ∧ {s} ⊢ t") (*goals: 1. ‹⟦(∀l'. l ≠ l' ⟶ t ∉ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))) ∨ M l ⊢ t ∨ {} ⊢⇩c t; ∃s∈M l. t ⊑ s ∧ {s} ⊢ t⟧ ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› 2. ‹⟦(∀l'. l ≠ l' ⟶ t ∉ GSMP (trms⇩l⇩s⇩t (proj l' 𝒜))) ∨ M l ⊢ t ∨ {} ⊢⇩c t; ¬ (∃s∈M l. t ⊑ s ∧ {s} ⊢ t)⟧ ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› discuss goal 1*) apply (blast intro: ideduct_mono[of _ t "M l"] (*‹⟦?M ⊢ t; ?M ⊆ M l⟧ ⟹ M l ⊢ t›*)) (*discuss goal 2*) apply (metis (no_types, lifting) False (*‹¬ ((t::('fun, 'var) Term.term) ∈ (Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set) ∨ {} ⊢⇩c t)›*) M( (*‹∀l::'lbl. (M::'lbl ⇒ ('fun, 'var) Term.term set) l ⊆ GSMP (trms⇩l⇩s⇩t (proj l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)))›*) 1) intruder_deduct.Axiom (*‹(?t::('fun, 'var) Term.term) ∈ (?M::('fun, 'var) Term.term set) ⟹ ?M ⊢ ?t›*) subsetCE (*‹⟦(?A::?'a set) ⊆ (?B::?'a set); (?c::?'a) ∉ ?A ⟹ ?P::bool; ?c ∈ ?B ⟹ ?P⟧ ⟹ ?P›*) t_in_ik_proj (*‹(t::('fun, 'var) Term.term) ∈ (M::'lbl ⇒ ('fun, 'var) Term.term set) (l'::'lbl)›*)) (*proven 2 subgoals*) . qed next (*goals: 1. ‹⋀T f. ⟦length T = arity f; public f; ⋀t. t ∈ set T ⟹ ⋃ (range M) ⊢ t; ⋀t. ⟦t ∈ set T; t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ t ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); Fun f T ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ Fun f T ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s)› 2. ‹⋀t K T t⇩i. ⟦⋃ (range M) ⊢ t; t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ M l ⊢ t ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⋃ (range M) ⊢ k; ⋀k. ⟦k ∈ set K; k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ k ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); t⇩i ∈ set T; t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ t⇩i ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s)›*) case (Compose T f) (*‹length (T::('fun, 'var) Term.term list) = (arity::'fun ⇒ nat) (f::'fun)› ‹public f› ‹?t5 ∈ set T ⟹ ⋃ (range M) ⊢ ?t5› ‹⟦?t5 ∈ set T; ?t5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ intruder_deduct (M l) ?t5 ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› ‹Fun f T ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) hence "Fun f T ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" using Compose.prems (*‹Fun (f::'fun) (T::('fun, 'var) Term.term list) ∈ GSMP (trms⇩l⇩s⇩t (proj (l::'lbl) (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)))›*) by auto hence "t ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" if "t ∈ set T" for t using that (*‹t ∈ set T›*) unfolding GSMP_def (*goal: ‹t ∈ {t ∈ SMP (trms⇩l⇩s⇩t (proj l 𝒜)). fv t = {}}›*) by auto hence IH: "M l ⊢ t ∨ (∃s ∈ Sec - Discl. ∃l. M l ⊢ s)" if "t ∈ set T" for t using that (*‹t ∈ set T›*) Compose.IH (*‹⟦?t5 ∈ set T; ?t5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ intruder_deduct (M l) ?t5 ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)›*) by auto show "?case" (*goal: ‹intruder_deduct (M l) (Fun f T) ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)›*) apply (cases "∀t ∈ set T. M l ⊢ t") (*goals: 1. ‹∀t∈set T. M l ⊢ t ⟹ intruder_deduct (M l) (Fun f T) ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› 2. ‹¬ (∀t∈set T. M l ⊢ t) ⟹ intruder_deduct (M l) (Fun f T) ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› discuss goal 1*) apply (metis intruder_deduct.Compose[OF Compose.hyps(1,2)] (*‹(⋀t. t ∈ set T ⟹ ?M ⊢ t) ⟹ ?M ⊢ Fun f T›*)) (*discuss goal 2*) apply (metis IH (*‹(?t5::('fun::type, 'var::type) Term.term) ∈ set (T::('fun::type, 'var::type) Term.term list) ⟹ (M::'lbl::type ⇒ ('fun::type, 'var::type) Term.term set) (l::'lbl::type) ⊢ ?t5 ∨ (∃s::('fun::type, 'var::type) Term.term∈(Sec::('fun::type, 'var::type) Term.term set) - (Discl::('fun::type, 'var::type) Term.term set). ∃l::'lbl::type. M l ⊢ s)›*)) (*proven 2 subgoals*) . next (*goal: ‹⋀t K T t⇩i. ⟦⋃ (range M) ⊢ t; t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ M l ⊢ t ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); Ana t = (K, T); ⋀k. k ∈ set K ⟹ ⋃ (range M) ⊢ k; ⋀k. ⟦k ∈ set K; k ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ k ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s); t⇩i ∈ set T; t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ M l ⊢ t⇩i ∨ (∃s∈Sec - Discl. ∃l. M l ⊢ s)›*) case (Decompose t K T t⇩i) (*‹⋃ (range M) ⊢ t› ‹Ana t = (K, T)› ‹(?k5::('fun, 'var) Term.term) ∈ set (K::('fun, 'var) Term.term list) ⟹ ⋃ (range (M::'lbl ⇒ ('fun, 'var) Term.term set)) ⊢ ?k5› ‹(t⇩i::('fun, 'var) Term.term) ∈ set (T::('fun, 'var) Term.term list)› ‹t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ intruder_deduct (M l) t ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› ‹⟦?k5 ∈ set K; ?k5 ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))⟧ ⟹ intruder_deduct (M l) ?k5 ∨ (∃s∈Sec - Discl. ∃l. intruder_deduct (M l) s)› ‹t⇩i ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) have hom_ik: "m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" if m: "m ∈ M l" for m and l using in_proj_in_GSMP[of m l 𝒜] (*‹m ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟹ m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) M(1) (*‹∀l. M l ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))›*) m (*‹m ∈ M l›*) by blast have "⟨⋃l. M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i" using intruder_deduct.Decompose[OF Decompose.hyps] (*‹(⋀k::('fun, 'var) Term.term. k ∈ set (K::('fun, 'var) Term.term list) ⟹ k ∈ set K) ⟹ ⋃ (range (M::'lbl ⇒ ('fun, 'var) Term.term set)) ⊢ (t⇩i::('fun, 'var) Term.term)›*) hom_deduct_if_deduct[of "⋃l. M l"] (*‹⟦∀m::('fun, 'var) Term.term∈⋃ (range (M::'lbl ⇒ ('fun, 'var) Term.term set)). m ∈ GSMP (trms⇩l⇩s⇩t (?𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)); ⋃ (range M) ⊢ (?m::('fun, 'var) Term.term); ?m ∈ GSMP (trms⇩l⇩s⇩t ?𝒜)⟧ ⟹ ⟨⋃ (range M);?𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?m›*) hom_ik (*‹?m5 ∈ M ?l5 ⟹ ?m5 ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) in_proj_in_GSMP[OF Decompose.prems ( 1 )] (*‹t⇩i ∈ GSMP (trms⇩l⇩s⇩t 𝒜)›*) by blast hence "(⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P t⇩i) ∨ (∃s ∈ Sec-Discl. ∃l. ⟨M l; 𝒜⟩ ⊢⇩G⇩S⇩M⇩P s)" using par_comp_hom_deduct(2)[OF 𝒜 M] (*‹⟦∀l::'lbl. ∀s::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set). ¬ ⟨(M::'lbl ⇒ ('fun, 'var) Term.term set) l;𝒜::('lbl strand_label × ('fun, 'var) strand_step) list⟩ ⊢⇩G⇩S⇩M⇩P s; ⟨⋃ (range M);𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?t::('fun, 'var) Term.term⟧ ⟹ ∀l::'lbl. ?t ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜)) ⟶ ⟨M l;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?t›*) Decompose.prems(1) (*‹(t⇩i::('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (l::'lbl) (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)))›*) by blast thus "?case" (*goal: ‹intruder_deduct ((M::'lbl ⇒ ('fun, 'var) Term.term set) (l::'lbl)) (t⇩i::('fun, 'var) Term.term) ∨ (∃s::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - (Discl::('fun, 'var) Term.term set). ∃l::'lbl. intruder_deduct (M l) s)›*) using deduct_if_hom_deduct[of _ 𝒜] (*‹⟨?M;𝒜⟩ ⊢⇩G⇩S⇩M⇩P ?m ⟹ ?M ⊢ ?m›*) by auto qed subsection ‹Theorem: Parallel Compositionality for Labeled Constraints› lemma par_comp_prefix: assumes "par_comp (A@B) M" shows "par_comp A M" proof (-) (*goal: ‹par_comp A M›*) let ?L = "λl. trms_proj⇩l⇩s⇩t l A ∪ trms_proj⇩l⇩s⇩t l B" have "GSMP_disjoint (?L l1) (?L l2) M" if "l1 ≠ l2" for l1 and l2 using that (*‹(l1::'lbl) ≠ (l2::'lbl)›*) assms (*‹par_comp (A @ B) M›*) unfolding par_comp_def (*goal: ‹GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 A) ∪ trms⇩l⇩s⇩t (proj l1 B)) (trms⇩l⇩s⇩t (proj l2 A) ∪ trms⇩l⇩s⇩t (proj l2 B)) M›*) by (metis trms⇩s⇩t_append (*‹trms⇩s⇩t (?A @ ?B) = trms⇩s⇩t ?A ∪ trms⇩s⇩t ?B›*) proj_append( (*‹proj_unl ?l (?A @ ?B) = proj_unl ?l ?A @ proj_unl ?l ?B›*) 2) unlabel_append (*‹unlabel (?A @ ?B) = unlabel ?A @ unlabel ?B›*)) hence "GSMP_disjoint (trms_proj⇩l⇩s⇩t l1 A) (trms_proj⇩l⇩s⇩t l2 A) M" if "l1 ≠ l2" for l1 and l2 using that (*‹l1 ≠ l2›*) SMP_union (*‹SMP (?A ∪ ?B) = SMP ?A ∪ SMP ?B›*) by (auto simp add: GSMP_def (*‹GSMP (?P::('fun::type, 'var::type) Term.term set) ≡ {t::('fun::type, 'var::type) Term.term ∈ SMP ?P. fv t = {}}›*) GSMP_disjoint_def (*‹GSMP_disjoint (?P1.0::('fun::type, 'var::type) Term.term set) (?P2.0::('fun::type, 'var::type) Term.term set) (?Secrets::('fun::type, 'var::type) Term.term set) ≡ GSMP ?P1.0 ∩ GSMP ?P2.0 ⊆ ?Secrets ∪ {m::('fun::type, 'var::type) Term.term. {} ⊢⇩c m}›*)) thus "?thesis" (*goal: ‹par_comp A M›*) using assms (*‹par_comp (A @ B) M›*) unfolding par_comp_def (*goal: ‹(∀l1 l2. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 A)) (trms⇩l⇩s⇩t (proj l2 A)) M) ∧ (∀s∈M. ¬ {} ⊢⇩c s) ∧ Messages.ground M›*) by blast qed theorem par_comp_constr_typed: assumes 𝒜: "par_comp 𝒜 Sec" and ℐ: "ℐ ⊨ ⟨unlabel 𝒜⟩" "interpretation⇩s⇩u⇩b⇩s⇩t ℐ" "wt⇩s⇩u⇩b⇩s⇩t ℐ" "wf⇩t⇩r⇩m⇩s (subst_range ℐ)" shows "(∀l. (ℐ ⊨ ⟨proj_unl l 𝒜⟩)) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ (strand_leaks⇩l⇩s⇩t 𝒜' Sec ℐ))" proof (-) (*goal: ‹(∀l::'lbl. ℐ::'var ⇒ ('fun, 'var) Term.term ⊨ ⟨proj_unl l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟩) ∨ (∃(𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list) (l'::'lbl strand_label) t::('fun, 'var) Term.term list. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ strand_leaks⇩l⇩s⇩t 𝒜' (Sec::('fun, 'var) Term.term set) ℐ)›*) let ?sem = "λ𝒜. ⟦{}; 𝒜⟧⇩d ℐ" let ?Q = "λ𝒜. ∀l. ?sem (proj_unl l 𝒜)" let ?L = "λ𝒜'. ∃t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ?sem (proj_unl l 𝒜'@[send⟨[t]⟩⇩s⇩t])" let ?P = "λ𝒜 𝒜' l' ts. prefix (𝒜'@[(l',receive⟨ts⟩⇩s⇩t)]) 𝒜 ∧ ?L (𝒜'@[(l',receive⟨ts⟩⇩s⇩t)])" have "⟦{}; unlabel 𝒜⟧⇩d ℐ" using "ℐ" (*‹ℐ ⊨ ⟨unlabel 𝒜⟩› ‹subst_domain ℐ = 𝒱 ∧ Messages.ground (subst_range ℐ)› ‹wt⇩s⇩u⇩b⇩s⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term)› ‹wf⇩t⇩r⇩m⇩s (subst_range ℐ)›*) by (simp add: constr_sem_d_def (*‹?ℐ ⊨ ⟨?S,?θ⟩ ≡ ?θ supports ?ℐ ∧ ⟦{}; ?S⟧⇩d ?ℐ›*)) with "𝒜" (*‹par_comp 𝒜 Sec›*) have aux: "?Q 𝒜 ∨ (∃𝒜'. prefix 𝒜' 𝒜 ∧ ?L 𝒜')" proof (induction "unlabel 𝒜" arbitrary: 𝒜 rule: List.rev_induct) (*goals: 1. ‹⋀𝒜. ⟦[] = unlabel 𝒜; par_comp 𝒜 Sec; ⟦{}; unlabel 𝒜⟧⇩d ℐ⟧ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))› 2. ‹⋀x xs 𝒜. ⟦⋀𝒜. ⟦xs = unlabel 𝒜; par_comp 𝒜 Sec; ⟦{}; unlabel 𝒜⟧⇩d ℐ⟧ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ)); xs @ [x] = unlabel 𝒜; par_comp 𝒜 Sec; ⟦{}; unlabel 𝒜⟧⇩d ℐ⟧ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))›*) case Nil (*‹[] = unlabel 𝒜› ‹par_comp 𝒜 Sec› ‹⟦{}; unlabel 𝒜⟧⇩d ℐ›*) hence "𝒜 = []" using unlabel_nil_only_if_nil (*‹unlabel ?A = [] ⟹ ?A = []›*) by simp thus "?case" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) by auto next (*goal: ‹⋀x xs 𝒜. ⟦⋀𝒜. ⟦xs = unlabel 𝒜; par_comp 𝒜 Sec; ⟦{}; unlabel 𝒜⟧⇩d ℐ⟧ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ)); xs @ [x] = unlabel 𝒜; par_comp 𝒜 Sec; ⟦{}; unlabel 𝒜⟧⇩d ℐ⟧ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))›*) case (snoc b B 𝒜) (*‹⟦B = unlabel ?𝒜6; par_comp ?𝒜6 Sec; ⟦{}; unlabel ?𝒜6⟧⇩d ℐ⟧ ⟹ (∀l. ⟦{}; proj_unl l ?𝒜6⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' ?𝒜6 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))› ‹(B::('fun::type, 'var::type) strand_step list) @ [b::('fun::type, 'var::type) strand_step] = unlabel (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)› ‹par_comp 𝒜 Sec› ‹⟦{}; unlabel 𝒜⟧⇩d ℐ›*) hence disj: "GSMP_disjoint (trms_proj⇩l⇩s⇩t l1 𝒜) (trms_proj⇩l⇩s⇩t l2 𝒜) Sec" if "l1 ≠ l2" for l1 and l2 using that (*‹l1 ≠ l2›*) by (auto simp add: par_comp_def (*‹par_comp (?𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) (?Secrets::('fun, 'var) Term.term set) ≡ (∀(l1::'lbl) l2::'lbl. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 ?𝒜)) (trms⇩l⇩s⇩t (proj l2 ?𝒜)) ?Secrets) ∧ (∀s::('fun, 'var) Term.term∈?Secrets. ¬ {} ⊢⇩c s) ∧ Messages.ground ?Secrets›*)) obtain a and A and n where a: "𝒜 = A@[a]" "a = (ln n, b) ∨ a = (⋆, b)" (*goal: ‹(⋀(A::('lbl strand_label × ('fun, 'var) strand_step) list) (a::'lbl strand_label × ('fun, 'var) strand_step) n::'lbl. ⟦(𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) = A @ [a]; a = (ln n, b::('fun, 'var) strand_step) ∨ a = (⋆, b)⟧ ⟹ thesis::bool) ⟹ thesis›*) using unlabel_snoc_inv[OF snoc.hyps ( 2 ) [ symmetric ]] (*‹∃A'. (∃n. 𝒜 = A' @ [(ln n, b)]) ∨ 𝒜 = A' @ [(⋆, b)]›*) apply atomize_elim (*goal: ‹(⋀A a n. ⟦𝒜 = A @ [a]; a = (ln n, b) ∨ a = (⋆, b)⟧ ⟹ thesis) ⟹ thesis›*) by auto hence A: "𝒜 = A@[(ln n, b)] ∨ 𝒜 = A@[(⋆, b)]" by metis have 1: "B = unlabel A" using a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) snoc.hyps(2) (*‹(B::('fun, 'var) strand_step list) @ [b::('fun, 'var) strand_step] = unlabel (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)›*) unlabel_append[of A "[a]"] (*‹unlabel (A @ [a]) = unlabel A @ unlabel [a]›*) by auto have 2: "par_comp A Sec" using par_comp_prefix (*‹par_comp (?A @ ?B) ?M ⟹ par_comp ?A ?M›*) snoc.prems(1) (*‹par_comp 𝒜 Sec›*) a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) by metis have 3: "⟦{}; unlabel A⟧⇩d ℐ" by (metis 1 (*‹B = unlabel A›*) snoc.prems( (*‹⟦{}; unlabel 𝒜⟧⇩d ℐ›*) 2) snoc.hyps( (*‹B @ [b] = unlabel 𝒜›*) 2) strand_sem_split( (*‹⟦?M; ?S @ ?S'⟧⇩d ?θ ⟹ ⟦?M; ?S⟧⇩d ?θ›*) 3)) have IH: "(∀l. ⟦{}; proj_unl l A⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' A ∧ ?L 𝒜')" by (rule snoc.hyps(1)[OF 1 2 3] (*‹(∀l::'lbl. ⟦{}; proj_unl l (A::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term)) ∨ (∃𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list. prefix 𝒜' A ∧ (∃t::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l::'lbl. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))›*)) show "?case" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) proof (cases "∀l. ⟦{}; proj_unl l A⟧⇩d ℐ") (*goals: 1. ‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹¬ (∀l. ⟦{}; proj_unl l A⟧⇩d ℐ) ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case False (*‹¬ (∀l. ⟦{}; proj_unl l A⟧⇩d ℐ)›*) then obtain 𝒜' where "𝒜'": "prefix 𝒜' A" "?L 𝒜'" (*goal: ‹(⋀𝒜'. ⟦prefix 𝒜' A; ∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ⟧ ⟹ thesis) ⟹ thesis›*) by (metis IH (*‹(∀l. ⟦{}; proj_unl l A⟧⇩d ℐ) ∨ (∃𝒜'. prefix 𝒜' A ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))›*)) hence "prefix 𝒜' (A@[a])" using a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) prefix_prefix[of _ A "[a]"] (*‹prefix ?xs A ⟹ prefix ?xs (A @ [a])›*) by simp thus "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using "𝒜'"(2) (*‹∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ›*) a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) by auto next (*goal: ‹∀l::'lbl::type. ⟦{}; proj_unl l (A::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)⟧⇩d (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term) ⟹ (∀l::'lbl::type. ⟦{}; proj_unl l (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)⟧⇩d ℐ) ∨ (∃𝒜''::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list. prefix 𝒜'' 𝒜 ∧ (∃t::('fun::type, 'var::type) Term.term∈(Sec::('fun::type, 'var::type) Term.term set) - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l::'lbl::type. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case True (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) note IH' = True (*‹∀l::'lbl. ⟦{}; proj_unl l (A::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term)›*) show "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) proof (cases b) (*goals: 1. ‹⋀x1. b = send⟨x1⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹⋀x2. b = receive⟨x2⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 3. ‹⋀x31 x32 x33. b = ⟨x31: x32 ≐ x33⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 4. ‹⋀x41 x42. b = ∀x41⟨∨≠: x42⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case (Send ts) (*‹b = send⟨ts⟩⇩s⇩t›*) hence "∀t ∈ set ts. ik⇩s⇩t (unlabel A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ" using a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) ‹⟦{}; unlabel 𝒜⟧⇩d ℐ› (*‹⟦{}; unlabel 𝒜⟧⇩d ℐ›*) strand_sem_split(2)[of "{}" "unlabel A" "unlabel [a]" ℐ] (*‹⟦{}; unlabel A @ unlabel [a]⟧⇩c ℐ ⟹ ⟦{} ∪ (ik⇩s⇩t (unlabel A) ⋅⇩s⇩e⇩t ℐ); unlabel [a]⟧⇩c ℐ›*) unlabel_append[of A "[a]"] (*‹unlabel (A @ [a]) = unlabel A @ unlabel [a]›*) by auto hence "*": "∀t ∈ set ts. (⋃l. (ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ)) ⊢ t ⋅ ℐ" using proj_ik_union_is_unlabel_ik (*‹ik⇩s⇩t (unlabel ?A) = (⋃l. ik⇩s⇩t (proj_unl l ?A))›*) image_UN (*‹?f ` ⋃ (?B ` ?A) = (⋃x∈?A. ?f ` ?B x)›*) by metis have "ik⇩s⇩t (proj_unl l 𝒜) = ik⇩s⇩t (proj_unl l A)" for l using Send (*‹b = send⟨ts⟩⇩s⇩t›*) A (*‹𝒜 = A @ [(ln n, b)] ∨ 𝒜 = A @ [(⋆, b)]›*) by (metis append_Nil2 (*‹?xs @ [] = ?xs›*) ik⇩s⇩t.simps( (*‹ik⇩s⇩t (send⟨?v⟩⇩s⇩t # ?S) = ik⇩s⇩t ?S›*) 3) proj_unl_cons( (*‹proj_unl ?l ((⋆, ?a) # ?A) = ?a # proj_unl ?l ?A›*) 3) proj_nil( (*‹proj_unl ?n [] = []›*) 2) singleton_lst_proj( (*‹proj_unl ?l [(ln ?l, ?a)] = [?a]› ‹?l ≠ ?l' ⟹ proj_unl ?l' [(ln ?l, ?a)] = []›*) 1,2) proj_ik_append (*‹ik⇩s⇩t (proj_unl ?l (?A @ ?B)) = ik⇩s⇩t (proj_unl ?l ?A) ∪ ik⇩s⇩t (proj_unl ?l ?B)›*)) hence "**": "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" for l using ik_proj_subst_GSMP_subset[OF ℐ ( 3 , 4 , 2 ), of _ 𝒜] (*‹ik⇩s⇩t (proj_unl ?n 𝒜) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms⇩l⇩s⇩t (proj ?n 𝒜))›*) by auto note Discl = declassified_proj_ik_subset(1)[of A ℐ] (*‹declassified⇩l⇩s⇩t A ℐ ⊆ {s. ik⇩s⇩t (proj_unl ?n A) ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) have Sec: "ground Sec" using "𝒜" (*‹par_comp 𝒜 Sec›*) by (auto simp add: par_comp_def (*‹par_comp (?𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) (?Secrets::('fun::type, 'var::type) Term.term set) ≡ (∀(l1::'lbl::type) l2::'lbl::type. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 ?𝒜)) (trms⇩l⇩s⇩t (proj l2 ?𝒜)) ?Secrets) ∧ (∀s::('fun::type, 'var::type) Term.term∈?Secrets. ¬ {} ⊢⇩c s) ∧ Messages.ground ?Secrets›*)) have "∀m∈ik⇩s⇩t (proj_unl l 𝒜) ⋅⇩s⇩e⇩t ℐ. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)" "ik⇩s⇩t (proj_unl l 𝒜) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" for l using ik_proj_subst_GSMP_subset[OF ℐ ( 3 , 4 , 2 ), of _ 𝒜] (*‹ik⇩s⇩t (proj_unl ?n 𝒜) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms⇩l⇩s⇩t (proj ?n 𝒜))›*) GSMP_Union[of 𝒜] (*‹GSMP (trms⇩l⇩s⇩t 𝒜) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l 𝒜)))›*) apply - (*goals: 1. ‹⟦⋀n. ik⇩s⇩t (proj_unl n 𝒜) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)); GSMP (trms⇩l⇩s⇩t 𝒜) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l 𝒜)))⟧ ⟹ ∀m∈ik⇩s⇩t (proj_unl l 𝒜) ⋅⇩s⇩e⇩t ℐ. m ∈ GSMP (trms⇩l⇩s⇩t 𝒜)› 2. ‹⟦⋀n. ik⇩s⇩t (proj_unl n 𝒜) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)); GSMP (trms⇩l⇩s⇩t 𝒜) = (⋃l. GSMP (trms⇩l⇩s⇩t (proj l 𝒜)))⟧ ⟹ ik⇩s⇩t (proj_unl l 𝒜) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . moreover have "ik⇩s⇩t (proj_unl l [a]) = {}" for l using Send (*‹b = send⟨ts⟩⇩s⇩t›*) "proj_ik⇩s⇩t_is_proj_rcv_set"[of _ "[a]"] (*‹ik⇩s⇩t (proj_unl ?n [a]) = {t. ∃ts. ((ln ?n, receive⟨ts⟩⇩s⇩t) ∈ set [a] ∨ (⋆, receive⟨ts⟩⇩s⇩t) ∈ set [a]) ∧ t ∈ set ts}›*) a(2) (*‹a = (ln n, b) ∨ a = (⋆, b)›*) by auto ultimately have M: "∀l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊆ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)" using a(1) (*‹𝒜 = A @ [a]›*) proj_ik_append[of _ A "[a]"] (*‹ik⇩s⇩t (proj_unl ?l (A @ [a])) = ik⇩s⇩t (proj_unl ?l A) ∪ ik⇩s⇩t (proj_unl ?l [a])›*) by auto have prefix_A: "prefix A 𝒜" using A (*‹𝒜 = A @ [(ln n, b)] ∨ 𝒜 = A @ [(⋆, b)]›*) by auto have "s ⋅ ℐ = s" if "s ∈ Sec" for s using that (*‹(s::('fun::type, 'var::type) Term.term) ∈ (Sec::('fun::type, 'var::type) Term.term set)›*) Sec (*‹Messages.ground Sec›*) by auto hence leakage_case: "⟦{}; proj_unl l A@[Send1 s]⟧⇩d ℐ" if "s ∈ Sec - declassified⇩l⇩s⇩t A ℐ" "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s" for l and s using that (*‹s ∈ Sec - declassified⇩l⇩s⇩t A ℐ› ‹ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s›*) strand_sem_append(2) (*‹⟦⟦?M; ?S⟧⇩d ?θ; ⟦?M ∪ (ik⇩s⇩t ?S ⋅⇩s⇩e⇩t ?θ); ?S'⟧⇩d ?θ⟧ ⟹ ⟦?M; ?S @ ?S'⟧⇩d ?θ›*) IH' (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) by auto have proj_deduct_case_n: "∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A@[a])⟧⇩d ℐ" "∀t ∈ set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ ⟹ ⟦{}; proj_unl n (A@[a])⟧⇩d ℐ" if "a = (ln n, Send ts)" using that (*‹(a::'lbl strand_label × ('fun, 'var) strand_step) = (ln n::'lbl, send⟨ts::('fun, 'var) Term.term list⟩⇩s⇩t)›*) IH' (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) proj_append(2)[of _ A] (*‹proj_unl ?l (A @ ?B) = proj_unl ?l A @ proj_unl ?l ?B›*) apply - (*goals: 1. ‹⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀l. ⟦{}; proj_unl l A⟧⇩d ℐ; ⋀l B. proj_unl l (A @ B) = proj_unl l A @ proj_unl l B⟧ ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ› 2. ‹⟦∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ; a = (ln n, send⟨ts⟩⇩s⇩t); ∀l. ⟦{}; proj_unl l A⟧⇩d ℐ; ⋀l B. proj_unl l (A @ B) = proj_unl l A @ proj_unl l B⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have proj_deduct_case_star: "⟦{}; proj_unl l (A@[a])⟧⇩d ℐ" if "a = (⋆, Send ts)" "∀t ∈ set ts. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ" for l using that (*‹a = (⋆, send⟨ts⟩⇩s⇩t)› ‹∀t∈set ts. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ›*) IH' (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) proj_append(2)[of _ A] (*‹proj_unl ?l (A @ ?B) = proj_unl ?l A @ proj_unl ?l ?B›*) by auto show "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) proof (cases "∃l. ∃m ∈ ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ. m ∈ Sec - declassified⇩l⇩s⇩t A ℐ") (*goals: 1. ‹∃l. ∃m∈ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ. m ∈ Sec - declassified⇩l⇩s⇩t A ℐ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹∄l. ∃m∈ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ. m ∈ Sec - declassified⇩l⇩s⇩t A ℐ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case True (*‹∃l. ∃m∈ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ. m ∈ Sec - declassified⇩l⇩s⇩t A ℐ›*) then obtain l and s where ls: "s ∈ Sec - declassified⇩l⇩s⇩t A ℐ" "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s" (*goal: ‹(⋀s l. ⟦s ∈ Sec - declassified⇩l⇩s⇩t A ℐ; ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s⟧ ⟹ thesis) ⟹ thesis›*) using intruder_deduct.Axiom (*‹?t ∈ ?M ⟹ ?M ⊢ ?t›*) by metis thus "?thesis" (*goal: ‹(∀l::'lbl. ⟦{}; proj_unl l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term)) ∨ (∃𝒜''::('lbl strand_label × ('fun, 'var) strand_step) list. prefix 𝒜'' 𝒜 ∧ (∃t::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l::'lbl. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using leakage_case (*‹⟦(?s6::('fun, 'var) Term.term) ∈ (Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) (ℐ::'var ⇒ ('fun, 'var) Term.term); ik⇩s⇩t (proj_unl (?l6::'lbl) A) ⋅⇩s⇩e⇩t ℐ ⊢ ?s6⟧ ⟹ ⟦{}; proj_unl ?l6 A @ [Send1 ?s6]⟧⇩d ℐ›*) prefix_A (*‹prefix A 𝒜›*) by blast next (*goal: ‹∄l. ∃m∈ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ. m ∈ Sec - declassified⇩l⇩s⇩t A ℐ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case False (*‹∄l. ∃m∈ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ. m ∈ Sec - declassified⇩l⇩s⇩t A ℐ›*) have A_decl_subset: "∀l. declassified⇩l⇩s⇩t A ℐ ⊆ {s. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s}" using Discl (*‹declassified⇩l⇩s⇩t A ℐ ⊆ {s. ik⇩s⇩t (proj_unl ?n A) ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) unfolding a(1) (*goal: ‹∀l. declassified⇩l⇩s⇩t A ℐ ⊆ {s. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) by auto note deduct_proj_lemma = par_comp_deduct_proj[OF snoc.prems ( 1 ) M A_decl_subset] (*‹⟦(⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ ?t; ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?l 𝒜))⟧ ⟹ ik⇩s⇩t (proj_unl ?l A) ⋅⇩s⇩e⇩t ℐ ⊢ ?t ∨ (∃s∈Sec - declassified⇩l⇩s⇩t A ℐ. ∃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s)›*) from a(2) (*‹a = (ln n, b) ∨ a = (⋆, b)›*) show "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) proof (standard) (*goals: 1. ‹a = (ln n, b) ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹a = (⋆, b) ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) assume "a = (ln n, b)" (*‹(a::'lbl strand_label × ('fun, 'var) strand_step) = (ln n::'lbl, b::('fun, 'var) strand_step)›*) hence "a = (ln n, Send ts)" "∀t ∈ set ts. t ⋅ ℐ ∈ GSMP (trms_proj⇩l⇩s⇩t n 𝒜)" using Send (*‹b = send⟨ts⟩⇩s⇩t›*) a(1) (*‹𝒜 = A @ [a]›*) "trms_proj⇩l⇩s⇩t_append"[of n A "[a]"] (*‹trms⇩l⇩s⇩t (proj n (A @ [a])) = trms⇩l⇩s⇩t (proj n A) ∪ trms⇩l⇩s⇩t (proj n [a])›*) GSMP_wt_substI[OF _ ℐ ( 3 , 4 , 2 )] (*‹?t ∈ ?M ⟹ ?t ⋅ ℐ ∈ GSMP ?M›*) apply - (*goals: 1. ‹⟦a = (ln n, b); b = send⟨ts⟩⇩s⇩t; 𝒜 = A @ [a]; trms⇩l⇩s⇩t (proj n (A @ [a])) = trms⇩l⇩s⇩t (proj n A) ∪ trms⇩l⇩s⇩t (proj n [a]); ⋀t M. t ∈ M ⟹ t ⋅ ℐ ∈ GSMP M⟧ ⟹ a = (ln n, send⟨ts⟩⇩s⇩t)› 2. ‹⟦a = (ln n, b); b = send⟨ts⟩⇩s⇩t; 𝒜 = A @ [a]; trms⇩l⇩s⇩t (proj n (A @ [a])) = trms⇩l⇩s⇩t (proj n A) ∪ trms⇩l⇩s⇩t (proj n [a]); ⋀t M. t ∈ M ⟹ t ⋅ ℐ ∈ GSMP M⟧ ⟹ ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜))› discuss goal 1*) apply metis (*discuss goal 2*) apply force (*proven 2 subgoals*) . hence "a = (ln n, Send ts)" "∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A@[a])⟧⇩d ℐ" "∀t ∈ set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ ⟹ ⟦{}; proj_unl n (A@[a])⟧⇩d ℐ" "∀t ∈ set ts. t ⋅ ℐ ∈ GSMP (trms_proj⇩l⇩s⇩t n 𝒜)" using proj_deduct_case_n (*‹a = (ln n, send⟨ts⟩⇩s⇩t) ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ› ‹⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ›*) apply - (*goals: 1. ‹⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)); a = (ln n, send⟨ts⟩⇩s⇩t) ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ; ⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ⟧ ⟹ a = (ln n, send⟨ts⟩⇩s⇩t)› 2. ‹⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)); a = (ln n, send⟨ts⟩⇩s⇩t) ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ; ⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ⟧ ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ› 3. ‹⟦∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ; a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)); a = (ln n, send⟨ts⟩⇩s⇩t) ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ; ⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ› 4. ‹⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜)); a = (ln n, send⟨ts⟩⇩s⇩t) ⟹ ∀m. m ≠ n ⟶ ⟦{}; proj_unl m (A @ [a])⟧⇩d ℐ; ⟦a = (ln n, send⟨ts⟩⇩s⇩t); ∀t∈set ts. ik⇩s⇩t (proj_unl n A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ⟧ ⟹ ⟦{}; proj_unl n (A @ [a])⟧⇩d ℐ⟧ ⟹ ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj n 𝒜))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*proven 4 subgoals*) . hence "(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃s ∈ Sec-declassified⇩l⇩s⇩t A ℐ. ∃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s)" using deduct_proj_lemma (*‹⟦(⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ ?t; ?t ∈ GSMP (trms⇩l⇩s⇩t (proj ?l 𝒜))⟧ ⟹ ik⇩s⇩t (proj_unl ?l A) ⋅⇩s⇩e⇩t ℐ ⊢ ?t ∨ (∃s∈Sec - declassified⇩l⇩s⇩t A ℐ. ∃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s)›*) "*" (*‹∀t∈set ts. (⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ t ⋅ ℐ›*) unfolding a(1) list_all_iff (*goal: ‹(∀l. ⟦{}; proj_unl l (A @ [a])⟧⇩d ℐ) ∨ (∃s∈Sec - declassified⇩l⇩s⇩t A ℐ. ∃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s)›*) by metis thus "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using leakage_case (*‹⟦?s6 ∈ Sec - declassified⇩l⇩s⇩t A ℐ; ik⇩s⇩t (proj_unl ?l6 A) ⋅⇩s⇩e⇩t ℐ ⊢ ?s6⟧ ⟹ ⟦{}; proj_unl ?l6 A @ [Send1 ?s6]⟧⇩d ℐ›*) prefix_A (*‹prefix A 𝒜›*) by metis next (*goal: ‹a = (⋆, b) ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) assume "a = (⋆, b)" (*‹(a::'lbl strand_label × ('fun, 'var) strand_step) = (⋆, b::('fun, 'var) strand_step)›*) hence "***": "a = (⋆, Send ts)" "list_all (λt. t ⋅ ℐ ∈ GSMP (trms_proj⇩l⇩s⇩t l 𝒜)) ts" for l using Send (*‹b = send⟨ts⟩⇩s⇩t›*) a(1) (*‹(𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) = (A::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) @ [a::'lbl::type strand_label × ('fun::type, 'var::type) strand_step]›*) GSMP_wt_substI[OF _ ℐ ( 3 , 4 , 2 )] (*‹?t ∈ ?M ⟹ ?t ⋅ ℐ ∈ GSMP ?M›*) unfolding list_all_iff (*goals: 1. ‹(a::'lbl strand_label × ('fun, 'var) strand_step) = (⋆, send⟨ts::('fun, 'var) Term.term list⟩⇩s⇩t)› 2. ‹∀t::('fun, 'var) Term.term∈set (ts::('fun, 'var) Term.term list). t ⋅ (ℐ::'var ⇒ ('fun, 'var) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (l::'lbl) (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)))›*) apply - (*goals: 1. ‹⟦a = (⋆, b); b = send⟨ts⟩⇩s⇩t; 𝒜 = A @ [a]; ⋀t M. t ∈ M ⟹ t ⋅ ℐ ∈ GSMP M⟧ ⟹ a = (⋆, send⟨ts⟩⇩s⇩t)› 2. ‹⟦a = (⋆, b); b = send⟨ts⟩⇩s⇩t; 𝒜 = A @ [a]; ⋀t M. t ∈ M ⟹ t ⋅ ℐ ∈ GSMP M⟧ ⟹ ∀t∈set ts. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj l 𝒜))› discuss goal 1*) apply metis (*discuss goal 2*) apply force (*proven 2 subgoals*) . hence "t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ {m. {} ⊢⇩c m}" if "t ∈ set ts" for t using that (*‹(t::('fun, 'var) Term.term) ∈ set (ts::('fun, 'var) Term.term list)›*) snoc.prems(1) (*‹par_comp 𝒜 Sec›*) a(1) (*‹𝒜 = A @ [a]›*) at_least_2_labels (*‹(label_witness1::'lbl::type) ≠ (label_witness2::'lbl::type)›*) unfolding par_comp_def GSMP_disjoint_def list_all_iff (*goal: ‹t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ {m. {} ⊢⇩c m}›*) by blast hence "(∃t ∈ set ts. t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ) ∨ (∀t ∈ set ts. t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ {m. {} ⊢⇩c m})" by blast thus "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) proof (standard) (*goals: 1. ‹∃t∈set ts. t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹∀t∈set ts. t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ {m. {} ⊢⇩c m} ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) assume "∃t ∈ set ts. t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ" (*‹∃t::('fun, 'var) Term.term∈set (ts::('fun, 'var) Term.term list). t ⋅ (ℐ::'var ⇒ ('fun, 'var) Term.term) ∈ (Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) ℐ›*) then obtain t where t: "t ∈ set ts" "t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ" "(⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ t ⋅ ℐ" (*goal: ‹(⋀t. ⟦t ∈ set ts; t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ; (⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ t ⋅ ℐ⟧ ⟹ thesis) ⟹ thesis›*) using "*" (*‹∀t∈set ts. (⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ t ⋅ ℐ›*) unfolding list_all_iff (*goal: ‹(⋀t. ⟦t ∈ set ts; t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ; (⋃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ) ⊢ t ⋅ ℐ⟧ ⟹ thesis) ⟹ thesis›*) by blast have "∃s ∈ Sec - declassified⇩l⇩s⇩t A ℐ. ∃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s" using t(1,2) (*‹t ∈ set ts› ‹t ⋅ ℐ ∈ Sec - declassified⇩l⇩s⇩t A ℐ›*) deduct_proj_lemma[OF t ( 3 )] (*‹(t::('fun::type, 'var::type) Term.term) ⋅ (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term) ∈ GSMP (trms⇩l⇩s⇩t (proj (?l::'lbl::type) (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))) ⟹ ik⇩s⇩t (proj_unl ?l (A::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ ∨ (∃s::('fun::type, 'var::type) Term.term∈(Sec::('fun::type, 'var::type) Term.term set) - declassified⇩l⇩s⇩t A ℐ. ∃l::'lbl::type. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s)›*) "***"(2) (*‹list_all (λt. t ⋅ ℐ ∈ GSMP (trms⇩l⇩s⇩t (proj ?l6 𝒜))) ts›*) A (*‹𝒜 = A @ [(ln n, b)] ∨ 𝒜 = A @ [(⋆, b)]›*) a (*‹(𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) = (A::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) @ [a::'lbl::type strand_label × ('fun::type, 'var::type) strand_step]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) Discl (*‹declassified⇩l⇩s⇩t A ℐ ⊆ {s. ik⇩s⇩t (proj_unl ?n A) ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) unfolding list_all_iff (*goal: ‹∃s∈Sec - declassified⇩l⇩s⇩t A ℐ. ∃l. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ s›*) by blast thus "?thesis" (*goal: ‹(∀l::'lbl. ⟦{}; proj_unl l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term)) ∨ (∃𝒜''::('lbl strand_label × ('fun, 'var) strand_step) list. prefix 𝒜'' 𝒜 ∧ (∃t::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l::'lbl. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using prefix_A (*‹prefix A 𝒜›*) leakage_case (*‹⟦?s6 ∈ Sec - declassified⇩l⇩s⇩t A ℐ; ik⇩s⇩t (proj_unl ?l6 A) ⋅⇩s⇩e⇩t ℐ ⊢ ?s6⟧ ⟹ ⟦{}; proj_unl ?l6 A @ [Send1 ?s6]⟧⇩d ℐ›*) by blast next (*goal: ‹∀t∈set ts. t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ {m. {} ⊢⇩c m} ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) assume t: "∀t ∈ set ts. t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ ∨ t ⋅ ℐ ∈ {m. {} ⊢⇩c m}" (*‹∀t::('fun, 'var) Term.term∈set (ts::('fun, 'var) Term.term list). t ⋅ (ℐ::'var ⇒ ('fun, 'var) Term.term) ∈ declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) ℐ ∨ t ⋅ ℐ ∈ {m::('fun, 'var) Term.term. {} ⊢⇩c m}›*) moreover { fix t and l assume "t ∈ set ts" "t ⋅ ℐ ∈ declassified⇩l⇩s⇩t A ℐ" (*‹(t::('fun, 'var) Term.term) ∈ set (ts::('fun, 'var) Term.term list)› ‹(t::('fun, 'var) Term.term) ⋅ (ℐ::'var ⇒ ('fun, 'var) Term.term) ∈ declassified⇩l⇩s⇩t (A::('lbl strand_label × ('fun, 'var) strand_step) list) ℐ›*) hence "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ" using intruder_deduct.Axiom (*‹?t ∈ ?M ⟹ ?M ⊢ ?t›*) Discl(1)[of l] (*‹declassified⇩l⇩s⇩t (A::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term) ⊆ {s::('fun::type, 'var::type) Term.term. ik⇩s⇩t (proj_unl (l::'lbl::type) A) ⋅⇩s⇩e⇩t ℐ ⊢ s}›*) ideduct_mono[of _ "t ⋅ ℐ" "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ"] (*‹⟦?M ⊢ t ⋅ ℐ; ?M ⊆ ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ⟧ ⟹ ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ›*) by blast } moreover { fix t and l assume "t ∈ set ts" "t ⋅ ℐ ∈ {m. {} ⊢⇩c m}" (*‹(t::('fun, 'var) Term.term) ∈ set (ts::('fun, 'var) Term.term list)› ‹(t::('fun, 'var) Term.term) ⋅ (ℐ::'var ⇒ ('fun, 'var) Term.term) ∈ {m::('fun, 'var) Term.term. {} ⊢⇩c m}›*) hence "ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ" using ideduct_mono[OF deduct_if_synth] (*‹⟦?M ⊢⇩c ?t; ?M ⊆ ?M'⟧ ⟹ ?M' ⊢ ?t›*) by blast } ultimately have "∀t ∈ set ts. ik⇩s⇩t (proj_unl l A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ" for l by blast thus "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using proj_deduct_case_star[OF *** ( 1 )] (*‹∀t∈set ts. ik⇩s⇩t (proj_unl ?l6 A) ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ ⟹ ⟦{}; proj_unl ?l6 (A @ [a])⟧⇩d ℐ›*) a(1) (*‹𝒜 = A @ [a]›*) by fast qed qed qed next (*goals: 1. ‹⋀x2. b = receive⟨x2⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹⋀x31 x32 x33. b = ⟨x31: x32 ≐ x33⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 3. ‹⋀x41 x42. b = ∀x41⟨∨≠: x42⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case (Receive t) (*‹b = receive⟨t⟩⇩s⇩t›*) hence "⟦{}; proj_unl l 𝒜⟧⇩d ℐ" for l using IH' (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) proj_append(2)[of l A "[a]"] (*‹proj_unl l (A @ [a]) = proj_unl l A @ proj_unl l [a]›*) unfolding unlabel_def proj_def (*goal: ‹⟦{}; map snd (filter (λs. has_LabelN l s ∨ has_LabelS s) 𝒜)⟧⇩d ℐ›*) by auto thus "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) by metis next (*goals: 1. ‹⋀x31 x32 x33. b = ⟨x31: x32 ≐ x33⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))› 2. ‹⋀x41 x42. b = ∀x41⟨∨≠: x42⟩⇩s⇩t ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case (Equality ac t t') (*‹b = ⟨ac: t ≐ t'⟩⇩s⇩t›*) hence "*": "⟦M; [Equality ac t t']⟧⇩d ℐ" for M using a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) ‹⟦{}; unlabel 𝒜⟧⇩d ℐ› (*‹⟦{}; unlabel 𝒜⟧⇩d ℐ›*) unlabel_append[of A "[a]"] (*‹unlabel (A @ [a]) = unlabel A @ unlabel [a]›*) by auto show "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) proj_append(2)[of _ A "[a]"] (*‹proj_unl (?l::'lbl) ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) = proj_unl ?l A @ proj_unl ?l [a]›*) Equality (*‹b = ⟨ac: t ≐ t'⟩⇩s⇩t›*) strand_sem_append(2)[OF _ *] (*‹⟦?M; ?S⟧⇩d ℐ ⟹ ⟦?M; ?S @ [⟨ac: t ≐ t'⟩⇩s⇩t]⟧⇩d ℐ›*) IH' (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) unfolding unlabel_def proj_def (*goal: ‹(∀l. ⟦{}; map snd (filter (λs. has_LabelN l s ∨ has_LabelS s) 𝒜)⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; map snd (filter (λs. has_LabelN l s ∨ has_LabelS s) 𝒜'') @ [Send1 t]⟧⇩d ℐ))›*) by auto next (*goal: ‹⋀(x41::'var list) x42::(('fun, 'var) Term.term × ('fun, 'var) Term.term) list. (b::('fun, 'var) strand_step) = ∀x41⟨∨≠: x42⟩⇩s⇩t ⟹ (∀l::'lbl. ⟦{}; proj_unl l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term)) ∨ (∃𝒜''::('lbl strand_label × ('fun, 'var) strand_step) list. prefix 𝒜'' 𝒜 ∧ (∃t::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l::'lbl. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) case (Inequality X F) (*‹b = ∀X⟨∨≠: F⟩⇩s⇩t›*) hence "*": "⟦M; [Inequality X F]⟧⇩d ℐ" for M using a (*‹(𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) = (A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) ‹⟦{}; unlabel 𝒜⟧⇩d ℐ› (*‹⟦{}; unlabel (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term)›*) unlabel_append[of A "[a]"] (*‹unlabel ((A::('lbl strand_label × ('fun, 'var) strand_step) list) @ [a::'lbl strand_label × ('fun, 'var) strand_step]) = unlabel A @ unlabel [a]›*) by auto show "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜''. prefix 𝒜'' 𝒜 ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l. ⟦{}; proj_unl l 𝒜'' @ [Send1 t]⟧⇩d ℐ))›*) using a (*‹𝒜 = A @ [a]› ‹a = (ln n, b) ∨ a = (⋆, b)›*) proj_append(2)[of _ A "[a]"] (*‹proj_unl ?l (A @ [a]) = proj_unl ?l A @ proj_unl ?l [a]›*) Inequality (*‹b = ∀X⟨∨≠: F⟩⇩s⇩t›*) strand_sem_append(2)[OF _ *] (*‹⟦?M; ?S⟧⇩d ℐ ⟹ ⟦?M; ?S @ [∀X⟨∨≠: F⟩⇩s⇩t]⟧⇩d ℐ›*) IH' (*‹∀l. ⟦{}; proj_unl l A⟧⇩d ℐ›*) unfolding unlabel_def proj_def (*goal: ‹(∀l::'lbl::type. ⟦{}; map snd (filter (λs::'lbl::type strand_label × ('fun::type, 'var::type) strand_step. has_LabelN l s ∨ has_LabelS s) (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))⟧⇩d (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term)) ∨ (∃𝒜''::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list. prefix 𝒜'' 𝒜 ∧ (∃t::('fun::type, 'var::type) Term.term∈(Sec::('fun::type, 'var::type) Term.term set) - declassified⇩l⇩s⇩t 𝒜'' ℐ. ∃l::'lbl::type. ⟦{}; map snd (filter (λs::'lbl::type strand_label × ('fun::type, 'var::type) strand_step. has_LabelN l s ∨ has_LabelS s) 𝒜'') @ [Send1 t]⟧⇩d ℐ))›*) by auto qed qed qed from aux (*‹(∀l::'lbl::type. ⟦{}; proj_unl l (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)⟧⇩d (ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term)) ∨ (∃𝒜'::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list. prefix 𝒜' 𝒜 ∧ (∃t::('fun::type, 'var::type) Term.term∈(Sec::('fun::type, 'var::type) Term.term set) - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l::'lbl::type. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))›*) have "?Q 𝒜 ∨ (∃𝒜' l' t. ?P 𝒜 𝒜' l' t)" proof (standard) (*goals: 1. ‹∀l::'lbl. ⟦{}; proj_unl l (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟧⇩d (ℐ::'var ⇒ ('fun, 'var) Term.term) ⟹ (∀l::'lbl. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃(𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list) (l'::'lbl strand_label) t::('fun, 'var) Term.term list. prefix (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) 𝒜 ∧ (∃ta::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) ℐ. ∃l::'lbl. ⟦{}; proj_unl l (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) @ [Send1 ta]⟧⇩d ℐ))› 2. ‹∃𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list. prefix 𝒜' (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) ∧ (∃t::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t 𝒜' (ℐ::'var ⇒ ('fun, 'var) Term.term). ∃l::'lbl. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ) ⟹ (∀l::'lbl. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃(𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list) (l'::'lbl strand_label) t::('fun, 'var) Term.term list. prefix (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) 𝒜 ∧ (∃ta::('fun, 'var) Term.term∈Sec - declassified⇩l⇩s⇩t (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) ℐ. ∃l::'lbl. ⟦{}; proj_unl l (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) @ [Send1 ta]⟧⇩d ℐ))›*) assume "∃𝒜'. prefix 𝒜' 𝒜 ∧ ?L 𝒜'" (*‹∃𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list. prefix 𝒜' (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list) ∧ (∃t::('fun, 'var) Term.term∈(Sec::('fun, 'var) Term.term set) - declassified⇩l⇩s⇩t 𝒜' (ℐ::'var ⇒ ('fun, 'var) Term.term). ∃l::'lbl. ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ)›*) then obtain 𝒜' and t and l where "𝒜'": "prefix 𝒜' 𝒜" "t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ" "?sem (proj_unl l 𝒜'@[send⟨[t]⟩⇩s⇩t])" (*goal: ‹(⋀𝒜' t l. ⟦prefix 𝒜' 𝒜; t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ; ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ⟧ ⟹ thesis) ⟹ thesis›*) by blast have "*": "ik⇩s⇩t (proj_unl l 𝒜') ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ" "¬{} ⊢⇩c t ⋅ ℐ" using "𝒜'"(2) (*‹t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ›*) "𝒜" (*‹par_comp 𝒜 Sec›*) subst_ground_ident[of t ℐ] (*‹fv t = {} ⟹ t ⋅ ℐ = t›*) strand_sem_split(4)[OF 𝒜' ( 3 )] (*‹⟦{} ∪ (ik⇩s⇩t (proj_unl (l::'lbl) (𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list)) ⋅⇩s⇩e⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term)); [Send1 (t::('fun, 'var) Term.term)]⟧⇩d ℐ›*) unfolding par_comp_def (*goals: 1. ‹ik⇩s⇩t (proj_unl l 𝒜') ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ› 2. ‹¬ {} ⊢⇩c t ⋅ ℐ›*) apply - (*goals: 1. ‹⟦t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ; (∀l1 l2. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 𝒜)) (trms⇩l⇩s⇩t (proj l2 𝒜)) Sec) ∧ (∀s∈Sec. ¬ {} ⊢⇩c s) ∧ Messages.ground Sec; fv t = {} ⟹ t ⋅ ℐ = t; ⟦{} ∪ (ik⇩s⇩t (proj_unl l 𝒜') ⋅⇩s⇩e⇩t ℐ); [Send1 t]⟧⇩d ℐ⟧ ⟹ ik⇩s⇩t (proj_unl l 𝒜') ⋅⇩s⇩e⇩t ℐ ⊢ t ⋅ ℐ› 2. ‹⟦t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ; (∀l1 l2. l1 ≠ l2 ⟶ GSMP_disjoint (trms⇩l⇩s⇩t (proj l1 𝒜)) (trms⇩l⇩s⇩t (proj l2 𝒜)) Sec) ∧ (∀s∈Sec. ¬ {} ⊢⇩c s) ∧ Messages.ground Sec; fv t = {} ⟹ t ⋅ ℐ = t; ⟦{} ∪ (ik⇩s⇩t (proj_unl l 𝒜') ⋅⇩s⇩e⇩t ℐ); [Send1 t]⟧⇩d ℐ⟧ ⟹ ¬ {} ⊢⇩c t ⋅ ℐ› discuss goal 1*) apply simp (*discuss goal 2*) apply fastforce (*proven 2 subgoals*) . obtain B and k and s where B: "k = ⋆ ∨ k = ln l" "prefix (B@[(k, receive⟨s⟩⇩s⇩t)]) 𝒜'" "declassified⇩l⇩s⇩t (B@[(k, receive⟨s⟩⇩s⇩t)]) ℐ = declassified⇩l⇩s⇩t 𝒜' ℐ" "ik⇩s⇩t (proj_unl l (B@[(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l 𝒜')" (*goal: ‹(⋀k B s. ⟦k = ⋆ ∨ k = ln l; prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) 𝒜'; declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) ℐ = declassified⇩l⇩s⇩t 𝒜' ℐ; ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l 𝒜')⟧ ⟹ thesis) ⟹ thesis›*) using deduct_proj_priv_term_prefix_ex[OF *] (*‹∃B k s. (k = ⋆ ∨ k = ln l) ∧ prefix (B @ [(k, receive⟨s⟩⇩s⇩t)]) 𝒜' ∧ declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) ℐ = declassified⇩l⇩s⇩t 𝒜' ℐ ∧ ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) = ik⇩s⇩t (proj_unl l 𝒜')›*) by force have "prefix (B@[(k, receive⟨s⟩⇩s⇩t)]) 𝒜" using B(2) (*‹prefix ((B::('lbl strand_label × ('fun, 'var) strand_step) list) @ [(k::'lbl strand_label, receive⟨s::('fun, 'var) Term.term list⟩⇩s⇩t)]) (𝒜'::('lbl strand_label × ('fun, 'var) strand_step) list)›*) "𝒜'"(1) (*‹prefix (𝒜'::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)›*) unfolding prefix_def (*goal: ‹∃zs. 𝒜 = (B @ [(k, receive⟨s⟩⇩s⇩t)]) @ zs›*) by force moreover have "t ∈ Sec - declassified⇩l⇩s⇩t (B@[(k, receive⟨s⟩⇩s⇩t)]) ℐ" using B(3) (*‹declassified⇩l⇩s⇩t (B @ [(k, receive⟨s⟩⇩s⇩t)]) ℐ = declassified⇩l⇩s⇩t 𝒜' ℐ›*) "𝒜'"(2) (*‹t ∈ Sec - declassified⇩l⇩s⇩t 𝒜' ℐ›*) by blast moreover have "?sem (proj_unl l (B@[(k, receive⟨s⟩⇩s⇩t)])@[send⟨[t]⟩⇩s⇩t])" using "*"(1)[unfolded B ( 4 ) [ symmetric ]] (*‹ik⇩s⇩t (proj_unl (l::'lbl) ((B::('lbl strand_label × ('fun, 'var) strand_step) list) @ [(k::'lbl strand_label, receive⟨s::('fun, 'var) Term.term list⟩⇩s⇩t)])) ⋅⇩s⇩e⇩t (ℐ::'var ⇒ ('fun, 'var) Term.term) ⊢ (t::('fun, 'var) Term.term) ⋅ ℐ›*) prefix_proj(2)[OF B ( 2 ), of l, unfolded prefix_def] (*‹∃zs. proj_unl l 𝒜' = proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)]) @ zs›*) strand_sem_split(3)[OF 𝒜' ( 3 )] (*‹⟦{}; proj_unl l 𝒜'⟧⇩d ℐ›*) strand_sem_append(2)[of _ _ ℐ "[send⟨[t]⟩⇩s⇩t]", OF strand_sem_split ( 3 ) [ of "{}" "proj_unl l (B@[(k, receive⟨s⟩⇩s⇩t)])" ]] (*‹⟦⟦{}; proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)]) @ ?S'1⟧⇩d ℐ; ⟦{} ∪ (ik⇩s⇩t (proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)])) ⋅⇩s⇩e⇩t ℐ); [Send1 t]⟧⇩d ℐ⟧ ⟹ ⟦{}; proj_unl l (B @ [(k, receive⟨s⟩⇩s⇩t)]) @ [Send1 t]⟧⇩d ℐ›*) by force ultimately show "?thesis" (*goal: ‹(∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜' l' t. prefix (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) 𝒜 ∧ (∃ta∈Sec - declassified⇩l⇩s⇩t (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) ℐ. ∃l. ⟦{}; proj_unl l (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) @ [Send1 ta]⟧⇩d ℐ))›*) by blast qed (simp) (*solved the remaining goal: ‹∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ ⟹ (∀l. ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜' l' t. prefix (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) 𝒜 ∧ (∃ta∈Sec - declassified⇩l⇩s⇩t (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) ℐ. ∃l. ⟦{}; proj_unl l (𝒜' @ [(l', receive⟨t⟩⇩s⇩t)]) @ [Send1 ta]⟧⇩d ℐ))›*) thus "?thesis" (*goal: ‹(∀l. ℐ ⊨ ⟨proj_unl l 𝒜⟩) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ strand_leaks⇩l⇩s⇩t 𝒜' Sec ℐ)›*) using "ℐ"(1) (*‹ℐ::'var::type ⇒ ('fun::type, 'var::type) Term.term ⊨ ⟨unlabel (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)⟩›*) unfolding "strand_leaks⇩l⇩s⇩t_def" suffix_def constr_sem_d_def (*goal: ‹(∀l. Var supports ℐ ∧ ⟦{}; proj_unl l 𝒜⟧⇩d ℐ) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ (∃zs. 𝒜' = zs @ [(l', receive⟨t⟩⇩s⇩t)]) ∧ (∃t∈Sec - declassified⇩l⇩s⇩t 𝒜' ℐ. ∃l. Var supports ℐ ∧ ⟦{}; proj_unl l 𝒜' @ [Send1 t]⟧⇩d ℐ))›*) by blast qed end locale labeled_typing = labeled_typed_model arity public Ana Γ label_witness1 label_witness2 + typing_result arity public Ana Γ for arity::"'fun ⇒ nat" and public::"'fun ⇒ bool" and Ana::"('fun,'var) term ⇒ (('fun,'var) term list × ('fun,'var) term list)" and Γ::"('fun,'var) term ⇒ ('fun,'atom::finite) term_type" and label_witness1::"'lbl" and label_witness2::"'lbl" begin theorem par_comp_constr: assumes 𝒜: "par_comp 𝒜 Sec" "typing_cond (unlabel 𝒜)" and ℐ: "ℐ ⊨ ⟨unlabel 𝒜⟩" "interpretation⇩s⇩u⇩b⇩s⇩t ℐ" shows "∃ℐ⇩τ. interpretation⇩s⇩u⇩b⇩s⇩t ℐ⇩τ ∧ wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ ∧ wf⇩t⇩r⇩m⇩s (subst_range ℐ⇩τ) ∧ (ℐ⇩τ ⊨ ⟨unlabel 𝒜⟩) ∧ ((∀l. (ℐ⇩τ ⊨ ⟨proj_unl l 𝒜⟩)) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ (strand_leaks⇩l⇩s⇩t 𝒜' Sec ℐ⇩τ)))" proof (-) (*goal: ‹∃ℐ⇩τ. (subst_domain ℐ⇩τ = 𝒱 ∧ Messages.ground (subst_range ℐ⇩τ)) ∧ wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ ∧ wf⇩t⇩r⇩m⇩s (subst_range ℐ⇩τ) ∧ ℐ⇩τ ⊨ ⟨unlabel 𝒜⟩ ∧ ((∀l. ℐ⇩τ ⊨ ⟨proj_unl l 𝒜⟩) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ strand_leaks⇩l⇩s⇩t 𝒜' Sec ℐ⇩τ))›*) from "𝒜"(2) (*‹typing_cond (unlabel 𝒜)›*) have "*": "wf⇩s⇩t {} (unlabel 𝒜)" "fv⇩s⇩t (unlabel 𝒜) ∩ bvars⇩s⇩t (unlabel 𝒜) = {}" "tfr⇩s⇩t (unlabel 𝒜)" "wf⇩t⇩r⇩m⇩s (trms⇩s⇩t (unlabel 𝒜))" "Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜))" unfolding typing_cond_def "tfr⇩s⇩t_def" (*goals: 1. ‹wf⇩l⇩s⇩t {} (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)› 2. ‹fv⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list) ∩ bvars⇩l⇩s⇩t 𝒜 = {}› 3. ‹tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)› 4. ‹wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list))› 5. ‹Ana_invar_subst (ik⇩s⇩t (unlabel (𝒜::('lbl::type strand_label × ('fun::type, 'var::type) strand_step) list)) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜))›*) apply - (*goals: 1. ‹wf⇩l⇩s⇩t {} 𝒜 ∧ fv⇩l⇩s⇩t 𝒜 ∩ bvars⇩l⇩s⇩t 𝒜 = {} ∧ (tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t 𝒜) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)) ∧ wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t 𝒜) ∧ Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜)) ⟹ wf⇩l⇩s⇩t {} 𝒜› 2. ‹wf⇩l⇩s⇩t {} 𝒜 ∧ fv⇩l⇩s⇩t 𝒜 ∩ bvars⇩l⇩s⇩t 𝒜 = {} ∧ (tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t 𝒜) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)) ∧ wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t 𝒜) ∧ Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜)) ⟹ fv⇩l⇩s⇩t 𝒜 ∩ bvars⇩l⇩s⇩t 𝒜 = {}› 3. ‹wf⇩l⇩s⇩t {} 𝒜 ∧ fv⇩l⇩s⇩t 𝒜 ∩ bvars⇩l⇩s⇩t 𝒜 = {} ∧ (tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t 𝒜) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)) ∧ wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t 𝒜) ∧ Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜)) ⟹ tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t 𝒜) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)› 4. ‹wf⇩l⇩s⇩t {} 𝒜 ∧ fv⇩l⇩s⇩t 𝒜 ∩ bvars⇩l⇩s⇩t 𝒜 = {} ∧ (tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t 𝒜) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)) ∧ wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t 𝒜) ∧ Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜)) ⟹ wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t 𝒜)› 5. ‹wf⇩l⇩s⇩t {} 𝒜 ∧ fv⇩l⇩s⇩t 𝒜 ∩ bvars⇩l⇩s⇩t 𝒜 = {} ∧ (tfr⇩s⇩e⇩t (trms⇩l⇩s⇩t 𝒜) ∧ list_all tfr⇩s⇩t⇩p (unlabel 𝒜)) ∧ wf⇩t⇩r⇩m⇩s (trms⇩l⇩s⇩t 𝒜) ∧ Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜)) ⟹ Ana_invar_subst (ik⇩s⇩t (unlabel 𝒜) ∪ assignment_rhs⇩s⇩t (unlabel 𝒜))› discuss goal 1*) apply metis (*discuss goal 2*) apply metis (*discuss goal 3*) apply metis (*discuss goal 4*) apply metis (*discuss goal 5*) apply metis (*proven 5 subgoals*) . obtain ℐ⇩τ where "ℐ⇩τ": "ℐ⇩τ ⊨ ⟨unlabel 𝒜⟩" "interpretation⇩s⇩u⇩b⇩s⇩t ℐ⇩τ" "wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ" "wf⇩t⇩r⇩m⇩s (subst_range ℐ⇩τ)" (*goal: ‹(⋀ℐ⇩τ. ⟦ℐ⇩τ ⊨ ⟨unlabel 𝒜⟩; subst_domain ℐ⇩τ = 𝒱 ∧ Messages.ground (subst_range ℐ⇩τ); wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ; wf⇩t⇩r⇩m⇩s (subst_range ℐ⇩τ)⟧ ⟹ thesis) ⟹ thesis›*) using wt_attack_if_tfr_attack_d[OF * ℐ ( 2 , 1 )] (*‹∃ℐ⇩τ. (subst_domain ℐ⇩τ = 𝒱 ∧ Messages.ground (subst_range ℐ⇩τ)) ∧ ℐ⇩τ ⊨ ⟨unlabel 𝒜⟩ ∧ wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ ∧ wf⇩t⇩r⇩m⇩s (subst_range ℐ⇩τ)›*) by metis show "?thesis" (*goal: ‹∃ℐ⇩τ. (subst_domain ℐ⇩τ = 𝒱 ∧ Messages.ground (subst_range ℐ⇩τ)) ∧ wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ ∧ wf⇩t⇩r⇩m⇩s (subst_range ℐ⇩τ) ∧ ℐ⇩τ ⊨ ⟨unlabel 𝒜⟩ ∧ ((∀l. ℐ⇩τ ⊨ ⟨proj_unl l 𝒜⟩) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ strand_leaks⇩l⇩s⇩t 𝒜' Sec ℐ⇩τ))›*) using par_comp_constr_typed[OF 𝒜 ( 1 ) ℐ⇩τ] (*‹(∀l. ℐ⇩τ ⊨ ⟨proj_unl l 𝒜⟩) ∨ (∃𝒜' l' t. prefix 𝒜' 𝒜 ∧ suffix [(l', receive⟨t⟩⇩s⇩t)] 𝒜' ∧ strand_leaks⇩l⇩s⇩t 𝒜' Sec ℐ⇩τ)›*) "ℐ⇩τ" (*‹ℐ⇩τ::'var ⇒ ('fun, 'var) Term.term ⊨ ⟨unlabel (𝒜::('lbl strand_label × ('fun, 'var) strand_step) list)⟩› ‹subst_domain ℐ⇩τ = 𝒱 ∧ Messages.ground (subst_range ℐ⇩τ)› ‹wt⇩s⇩u⇩b⇩s⇩t ℐ⇩τ› ‹wf⇩t⇩r⇩m⇩s (subst_range (ℐ⇩τ::'var ⇒ ('fun, 'var) Term.term))›*) by auto qed end subsection ‹Automated GSMP Disjointness› locale labeled_typed_model' = typed_model' arity public Ana Γ + labeled_typed_model arity public Ana Γ label_witness1 label_witness2 for arity::"'fun ⇒ nat" and public::"'fun ⇒ bool" and Ana::"('fun,(('fun,'atom::finite) term_type × nat)) term ⇒ (('fun,(('fun,'atom) term_type × nat)) term list × ('fun,(('fun,'atom) term_type × nat)) term list)" and Γ::"('fun,(('fun,'atom) term_type × nat)) term ⇒ ('fun,'atom) term_type" and label_witness1 label_witness2::'lbl begin lemma GSMP_disjointI: fixes A' A B B'::"('fun, ('fun, 'atom) term × nat) terms" defines "f ≡ λM. {t ⋅ δ | t δ. t ∈ M ∧ wt⇩s⇩u⇩b⇩s⇩t δ ∧ wf⇩t⇩r⇩m⇩s (subst_range δ) ∧ fv (t ⋅ δ) = {}}" and "δ ≡ var_rename (max_var_set (fv⇩s⇩e⇩t A))" assumes A'_wf: "wf⇩t⇩r⇩m⇩s' arity A'" and B'_wf: "wf⇩t⇩r⇩m⇩s' arity B'" and A_inst: "has_all_wt_instances_of Γ A' A" and B_inst: "has_all_wt_instances_of Γ B' (B ⋅⇩s⇩e⇩t δ)" and A_SMP_repr: "finite_SMP_representation arity Ana Γ A" and B_SMP_repr: "finite_SMP_representation arity Ana Γ (B ⋅⇩s⇩e⇩t δ)" and AB_trms_disj: "∀t ∈ A. ∀s ∈ B ⋅⇩s⇩e⇩t δ. Γ t = Γ s ∧ mgu t s ≠ None ⟶ (intruder_synth' public arity {} t) ∨ ((∃u ∈ Sec. is_wt_instance_of_cond Γ t u))" and Sec_wf: "wf⇩t⇩r⇩m⇩s Sec" shows "GSMP_disjoint A' B' ((f Sec) - {m. {} ⊢⇩c m})" proof (-) (*goal: ‹GSMP_disjoint A' B' (f Sec - {m. {} ⊢⇩c m})›*) have A_wf: "wf⇩t⇩r⇩m⇩s A" and B_wf: "wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ)" and A'_wf': "wf⇩t⇩r⇩m⇩s A'" and B'_wf': "wf⇩t⇩r⇩m⇩s B'" and A_finite: "finite A" and B_finite: "finite (B ⋅⇩s⇩e⇩t δ)" using finite_SMP_representationD[OF A_SMP_repr] (*‹wf⇩t⇩r⇩m⇩s A› ‹has_all_wt_instances_of (Γ::('fun, ('fun, 'atom) Term.term × nat) Term.term ⇒ ('fun, 'atom) Term.term) (subterms⇩s⇩e⇩t (A::('fun, ('fun, 'atom) Term.term × nat) Term.term set)) A› ‹has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A› ‹is_TComp_var_instance_closed Γ A› ‹finite A›*) finite_SMP_representationD[OF B_SMP_repr] (*‹wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ)› ‹has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ)› ‹has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ)› ‹is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ)› ‹finite ((B::('fun, ('fun, 'atom) Term.term × nat) Term.term set) ⋅⇩s⇩e⇩t (δ::('fun, 'atom) Term.term × nat ⇒ ('fun, ('fun, 'atom) Term.term × nat) Term.term))›*) A'_wf (*‹wf⇩t⇩r⇩m⇩s' arity A'›*) B'_wf (*‹wf⇩t⇩r⇩m⇩s' (arity::'fun ⇒ nat) (B'::('fun, ('fun, 'atom) Term.term × nat) Term.term set)›*) unfolding "wf⇩t⇩r⇩m⇩s_code"[symmetric] "wf⇩t⇩r⇩m_code"[symmetric] list_all_iff (*goals: 1. ‹wf⇩t⇩r⇩m⇩s A› 2. ‹wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ)› 3. ‹wf⇩t⇩r⇩m⇩s A'› 4. ‹wf⇩t⇩r⇩m⇩s B'› 5. ‹finite A› 6. ‹finite (B ⋅⇩s⇩e⇩t δ)›*) apply - (*goals: 1. ‹⟦wf⇩t⇩r⇩m⇩s A; has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t A) A; has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A; is_TComp_var_instance_closed Γ A; finite A; wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ); is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ); finite (B ⋅⇩s⇩e⇩t δ); wf⇩t⇩r⇩m⇩s A'; wf⇩t⇩r⇩m⇩s B'⟧ ⟹ wf⇩t⇩r⇩m⇩s A› 2. ‹⟦wf⇩t⇩r⇩m⇩s A; has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t A) A; has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A; is_TComp_var_instance_closed Γ A; finite A; wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ); is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ); finite (B ⋅⇩s⇩e⇩t δ); wf⇩t⇩r⇩m⇩s A'; wf⇩t⇩r⇩m⇩s B'⟧ ⟹ wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ)› 3. ‹⟦wf⇩t⇩r⇩m⇩s A; has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t A) A; has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A; is_TComp_var_instance_closed Γ A; finite A; wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ); is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ); finite (B ⋅⇩s⇩e⇩t δ); wf⇩t⇩r⇩m⇩s A'; wf⇩t⇩r⇩m⇩s B'⟧ ⟹ wf⇩t⇩r⇩m⇩s A'› 4. ‹⟦wf⇩t⇩r⇩m⇩s A; has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t A) A; has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A; is_TComp_var_instance_closed Γ A; finite A; wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ); is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ); finite (B ⋅⇩s⇩e⇩t δ); wf⇩t⇩r⇩m⇩s A'; wf⇩t⇩r⇩m⇩s B'⟧ ⟹ wf⇩t⇩r⇩m⇩s B'› 5. ‹⟦wf⇩t⇩r⇩m⇩s A; has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t A) A; has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A; is_TComp_var_instance_closed Γ A; finite A; wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ); is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ); finite (B ⋅⇩s⇩e⇩t δ); wf⇩t⇩r⇩m⇩s A'; wf⇩t⇩r⇩m⇩s B'⟧ ⟹ finite A› 6. ‹⟦wf⇩t⇩r⇩m⇩s A; has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t A) A; has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` A)) A; is_TComp_var_instance_closed Γ A; finite A; wf⇩t⇩r⇩m⇩s (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (subterms⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ)) (B ⋅⇩s⇩e⇩t δ); has_all_wt_instances_of Γ (⋃ ((set ∘ fst ∘ Ana) ` (B ⋅⇩s⇩e⇩t δ))) (B ⋅⇩s⇩e⇩t δ); is_TComp_var_instance_closed Γ (B ⋅⇩s⇩e⇩t δ); finite (B ⋅⇩s⇩e⇩t δ); wf⇩t⇩r⇩m⇩s A'; wf⇩t⇩r⇩m⇩s B'⟧ ⟹ finite (B ⋅⇩s⇩e⇩t δ)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*discuss goal 3*) apply blast (*discuss goal 4*) apply blast (*discuss goal 5*) apply blast (*discuss goal 6*) apply blast (*proven 6 subgoals*) . have AB_fv_disj: "fv⇩s⇩e⇩t A ∩ fv⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ) = {}" using var_rename_fv_set_disjoint'[of A B, unfolded δ_def [ symmetric ]] (*‹finite A ⟹ fv⇩s⇩e⇩t A ∩ fv⇩s⇩e⇩t (B ⋅⇩s⇩e⇩t δ) = {}›*) A_finite (*‹finite A›*) by simp have "GSMP_disjoint A (B ⋅⇩s⇩e⇩t δ) ((f Sec) - {m. {} ⊢⇩c m})" using ground_SMP_disjointI[OF AB_fv_disj A_SMP_repr B_SMP_repr Sec_wf AB_trms_disj] (*‹{t::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term ∈ SMP (A::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term set). fv t = {}} ∩ {t::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term ∈ SMP ((B::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term set) ⋅⇩s⇩e⇩t (δ::('fun::type, 'atom::finite) Term.term × nat ⇒ ('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term)). fv t = {}} ⊆ {t ⋅ δ |(t::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term) δ::('fun::type, 'atom::finite) Term.term × nat ⇒ ('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term. t ∈ (Sec::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term set) ∧ wt⇩s⇩u⇩b⇩s⇩t δ ∧ wf⇩t⇩r⇩m⇩s (subst_range δ) ∧ fv (t ⋅ δ) = {}} ∪ {m::('fun::type, ('fun::type, 'atom::finite) Term.term × nat) Term.term. {} ⊢⇩c m}›*) unfolding GSMP_def GSMP_disjoint_def f_def (*goal: ‹{t ∈ SMP A. fv t = {}} ∩ {t ∈ SMP (B ⋅⇩s⇩e⇩t δ). fv t = {}} ⊆ {t ⋅ δ |t δ. t ∈ Sec ∧ wt⇩s⇩u⇩b⇩s⇩t δ ∧ wf⇩t⇩r⇩m⇩s (subst_range δ) ∧ fv (t ⋅ δ) = {}} - Collect ((⊢⇩c) {}) ∪ {m. {} ⊢⇩c m}›*) by blast moreover have "SMP A' ⊆ SMP A" "SMP B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ)" using SMP_I'[OF A'_wf' A_wf A_inst] (*‹?t ∈ A' ⟹ ?t ∈ SMP A›*) SMP_SMP_subset[of A' A] (*‹(A'::('fun, ('fun, 'atom) Term.term × nat) Term.term set) ⊆ SMP (A::('fun, ('fun, 'atom) Term.term × nat) Term.term set) ⟹ SMP A' ⊆ SMP A›*) SMP_I'[OF B'_wf' B_wf B_inst] (*‹?t ∈ B' ⟹ ?t ∈ SMP (B ⋅⇩s⇩e⇩t δ)›*) SMP_SMP_subset[of B' "B ⋅⇩s⇩e⇩t δ"] (*‹B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ) ⟹ SMP B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ)›*) apply - (*goals: 1. ‹⟦⋀t. t ∈ A' ⟹ t ∈ SMP A; A' ⊆ SMP A ⟹ SMP A' ⊆ SMP A; ⋀t. t ∈ B' ⟹ t ∈ SMP (B ⋅⇩s⇩e⇩t δ); B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ) ⟹ SMP B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ)⟧ ⟹ SMP A' ⊆ SMP A› 2. ‹⟦⋀t. t ∈ A' ⟹ t ∈ SMP A; A' ⊆ SMP A ⟹ SMP A' ⊆ SMP A; ⋀t. t ∈ B' ⟹ t ∈ SMP (B ⋅⇩s⇩e⇩t δ); B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ) ⟹ SMP B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ)⟧ ⟹ SMP B' ⊆ SMP (B ⋅⇩s⇩e⇩t δ)› discuss goal 1*) apply blast (*discuss goal 2*) apply blast (*proven 2 subgoals*) . ultimately show "?thesis" (*goal: ‹GSMP_disjoint A' B' (f Sec - {m. {} ⊢⇩c m})›*) unfolding GSMP_def GSMP_disjoint_def (*goal: ‹{t ∈ SMP A'. fv t = {}} ∩ {t ∈ SMP B'. fv t = {}} ⊆ f Sec - Collect ((⊢⇩c) {}) ∪ {m. {} ⊢⇩c m}›*) by auto qed end end
{ "path": "afp-2025-02-12/thys/Stateful_Protocol_Composition_and_Typing/Parallel_Compositionality.thy", "repo": "afp-2025-02-12", "sha": "7abf20dc75e201ed7f3f0a50e4c6e82e7a2054b02cd5775c715f4ec38adbf092" }
(* Title: Continuations.thy Author: Peter Gammie *) section ‹Relating direct and continuation semantics› (*<*) theory Continuations imports PCF begin (*>*) text‹ \label{sec:continuations} This is a fairly literal version of \<^citet>‹"DBLP:conf/icalp/Reynolds74"›, adapted to untyped PCF. A more abstract account has been given by \<^citet>‹"DBLP:journals/tcs/Filinski07"› in terms of a monadic meta language, which is difficult to model in Isabelle (but see \<^citet>‹"Huffman:MonadTransformers:2012"›). We begin by giving PCF a continuation semantics following the modern account of \<^citet>‹"wadler92:_essence_of_funct_progr"›. We use the symmetric function space ‹('o ValK, 'o) K → ('o ValK, 'o) K› as our language includes call-by-name. › type_synonym ('a, 'o) K = "('a → 'o) → 'o" domain 'o ValK = ValKF (lazy appKF :: "('o ValK, 'o) K → ('o ValK, 'o) K") | ValKTT | ValKFF | ValKN (lazy "nat") type_synonym 'o ValKM = "('o ValK, 'o) K" (*<*) lemma ValK_case_ID [simp]: "ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN = ID" apply (rule cfun_eqI (*‹(⋀x. ?f⋅x = ?g⋅x) ⟹ ?f = ?g›*)) (*goal: ‹ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN = ID›*) apply (case_tac x) (*goals: 1. ‹⋀x. x = ⊥ ⟹ ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN⋅x = ID⋅x› 2. ‹⋀x cfun. x = ValKF⋅cfun ⟹ ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN⋅x = ID⋅x› 3. ‹⋀x. x = ValKTT ⟹ ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN⋅x = ID⋅x› 4. ‹⋀x. x = ValKFF ⟹ ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN⋅x = ID⋅x› 5. ‹⋀x nat. x = ValKN⋅nat ⟹ ValK_case⋅ValKF⋅ValKTT⋅ValKFF⋅ValKN⋅x = ID⋅x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . lemma below_monic_ValKF [iff]: "below_monic_cfun ValKF" apply (rule below_monicI (*‹(⋀x y. ?f x ⊑ ?f y ⟹ x ⊑ y) ⟹ below_monic ?f›*)) (*goal: ‹below_monic_cfun ValKF›*) by simp lemma below_monic_ValKN [iff]: "below_monic_cfun ValKN" apply (rule below_monicI (*‹(⋀(x::?'a::cpo) y::?'a::cpo. (?f::?'a::cpo ⇒ ?'b::cpo) x ⊑ ?f y ⟹ x ⊑ y) ⟹ below_monic ?f›*)) (*goal: ‹below_monic_cfun ValKN›*) by simp (*>*) text‹ We use the standard continuation monad to ease the semantic definition. › definition unitK :: "'o ValK → 'o ValKM" where "unitK ≡ Λ a. Λ c. c⋅a" definition bindK :: "'o ValKM → ('o ValK → 'o ValKM) → 'o ValKM" where "bindK ≡ Λ m k. Λ c. m⋅(Λ a. k⋅a⋅c)" definition appKM :: "'o ValKM → 'o ValKM → 'o ValKM" where "appKM ≡ Λ fK xK. bindK⋅fK⋅(Λ (ValKF⋅f). f⋅xK)" (*<*) lemma unitK_simps [simp]: "unitK⋅v⋅c = c⋅v" unfolding unitK_def (*goal: ‹(Λ a c. c⋅a)⋅v⋅c = c⋅v›*) by simp lemma bindK_strict: "bindK⋅⊥ = ⊥" unfolding bindK_def (*goal: ‹(Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅⊥ = ⊥›*) by (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) lemma bindK_unitl: "bindK⋅(unitK⋅e)⋅f = f⋅e" unfolding bindK_def unitK_def (*goal: ‹(Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅((Λ a c. c⋅a)⋅e)⋅f = f⋅e›*) by (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) lemma bindK_unitr: "bindK⋅e⋅unitK = e" unfolding bindK_def unitK_def (*goal: ‹(Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅e⋅(Λ a c. c⋅a) = e›*) by (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) lemma bindK_assoc: "bindK⋅(bindK⋅f⋅g)⋅h = bindK⋅f⋅(Λ v. bindK⋅(g⋅v)⋅h)" unfolding bindK_def unitK_def (*goal: ‹(Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅((Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅f⋅g)⋅h = (Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅f⋅(Λ v. (Λ m k c. m⋅(Λ a. k⋅a⋅c))⋅(g⋅v)⋅h)›*) by simp lemmas bindK_simps[simp] = bindK_strict bindK_unitl bindK_unitr bindK_assoc (*>*) text‹The interpretations of the constants.› definition condK :: "'o ValKM → 'o ValKM → 'o ValKM → 'o ValKM" where "condK ≡ Λ iK tK eK. bindK⋅iK⋅(Λ i. case i of ValKF⋅f ⇒ ⊥ | ValKTT ⇒ tK | ValKFF ⇒ eK | ValKN⋅n ⇒ ⊥)" definition succK :: "'o ValKM → 'o ValKM" where "succK ≡ Λ nK. bindK⋅nK⋅(Λ (ValKN⋅n). unitK⋅(ValKN⋅(n + 1)))" definition predK :: "'o ValKM → 'o ValKM" where "predK ≡ Λ nK. bindK⋅nK⋅(Λ (ValKN⋅n). case n of 0 ⇒ ⊥ | Suc n ⇒ unitK⋅(ValKN⋅n))" definition isZeroK :: "'o ValKM → 'o ValKM" where "isZeroK ≡ Λ nK. bindK⋅nK⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))" text ‹ A continuation semantics for PCF. If we had defined our direct semantics using a monad then the correspondence would be more syntactically obvious. › type_synonym 'o EnvK = "'o ValKM Env" primrec evalK :: "expr ⇒ 'o EnvK → 'o ValKM" where "evalK (Var v) = (Λ ρ. ρ⋅v)" | "evalK (App f x) = (Λ ρ. appKM⋅(evalK f⋅ρ)⋅(evalK x⋅ρ))" | "evalK (AbsN v e) = (Λ ρ. unitK⋅(ValKF⋅(Λ x. evalK e⋅(env_ext⋅v⋅x⋅ρ))))" | "evalK (AbsV v e) = (Λ ρ. unitK⋅(ValKF⋅(Λ x c. x⋅(Λ x'. evalK e⋅(env_ext⋅v⋅(unitK⋅x')⋅ρ)⋅c))))" | "evalK (Diverge) = (Λ ρ. ⊥)" | "evalK (Fix v e) = (Λ ρ. μ x. evalK e⋅(env_ext⋅v⋅x⋅ρ))" | "evalK (tt) = (Λ ρ. unitK⋅ValKTT)" | "evalK (ff) = (Λ ρ. unitK⋅ValKFF)" | "evalK (Cond i t e) = (Λ ρ. condK⋅(evalK i⋅ρ)⋅(evalK t⋅ρ)⋅(evalK e⋅ρ))" | "evalK (Num n) = (Λ ρ. unitK⋅(ValKN⋅n))" | "evalK (Succ e) = (Λ ρ. succK⋅(evalK e⋅ρ))" | "evalK (Pred e) = (Λ ρ. predK⋅(evalK e⋅ρ))" | "evalK (IsZero e) = (Λ ρ. isZeroK⋅(evalK e⋅ρ))" text‹ To establish the chain completeness (admissibility) of our logical relation, we need to show that @{term "unitK"} is an \emph{order monic}, i.e., if @{term "unitK⋅x ⊑ unitK⋅y"} then @{term "x ⊑ y"}. This is an order-theoretic version of injectivity. In order to define a continuation that witnesses this, we need to be able to distinguish converging and diverging computations. We therefore require our observation domain to contain at least two elements: › locale at_least_two_elements = fixes some_non_bottom_element :: "'o::domain" assumes some_non_bottom_element: "some_non_bottom_element ≠ ⊥" text‹ Following \<^citet>‹"DBLP:conf/icalp/Reynolds74"› and \<^citet>‹‹Remark 47› in "DBLP:journals/tcs/Filinski07"› we use the following continuation: › lemma cont_below [simp, cont2cont]: "cont (λx::'a::pcpo. if x ⊑ d then ⊥ else c)" (*<*) proof (rule contI2 (*‹⟦monofun (?f::?'a ⇒ ?'b); ⋀Y::nat ⇒ ?'a. ⟦chain Y; chain (λi::nat. ?f (Y i))⟧ ⟹ ?f (⨆i::nat. Y i) ⊑ (⨆i::nat. ?f (Y i))⟧ ⟹ cont ?f›*)) (*goals: 1. ‹monofun (λx. if x ⊑ d then ⊥ else c)› 2. ‹⋀Y. ⟦chain Y; chain (λi. if Y i ⊑ d then ⊥ else c)⟧ ⟹ (if (⨆i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i. if Y i ⊑ d then ⊥ else c)›*) show "monofun (λx. if x ⊑ d then ⊥ else c)" apply (rule monofunI (*‹(⋀x y. x ⊑ y ⟹ ?f x ⊑ ?f y) ⟹ monofun ?f›*)) (*goal: ‹monofun (λx. if x ⊑ d then ⊥ else c)›*) apply clarsimp (*goal: ‹⋀x y. x ⊑ y ⟹ (if x ⊑ d then ⊥ else c) ⊑ (if y ⊑ d then ⊥ else c)›*) apply (cut_tac x=x and y=y and z=d in below_trans (*‹⟦?x ⊑ ?y; ?y ⊑ ?z⟧ ⟹ ?x ⊑ ?z›*)) (*goals: 1. ‹⋀x y. ⟦x ⊑ y; x \<notsqsubseteq> d; y ⊑ d⟧ ⟹ x ⊑ y› 2. ‹⋀x y. ⟦x ⊑ y; x \<notsqsubseteq> d; y ⊑ d⟧ ⟹ y ⊑ d› 3. ‹⋀x y. ⟦x ⊑ y; x \<notsqsubseteq> d; y ⊑ d; x ⊑ d⟧ ⟹ c = ⊥› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . next (*goal: ‹⋀Y::nat ⇒ 'a. ⟦chain Y; chain (λi::nat. if Y i ⊑ (d::'a) then ⊥ else (c::'b))⟧ ⟹ (if (⨆i::nat. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i::nat. if Y i ⊑ d then ⊥ else c)›*) fix Y :: "nat ⇒ 'a::pcpo" assume Y: "chain Y" (*‹chain (Y::nat ⇒ 'a)›*) assume "chain (λi. if Y i ⊑ d then ⊥ else c)" (*‹chain (λi::nat. if (Y::nat ⇒ 'a) i ⊑ (d::'a) then ⊥ else (c::'b))›*) show "(if (⨆ i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆ i. if Y i ⊑ d then ⊥ else c)" proof (cases "∀i. Y i ⊑ d") (*goals: 1. ‹∀i. Y i ⊑ d ⟹ (if (⨆i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i. if Y i ⊑ d then ⊥ else c)› 2. ‹¬ (∀i. Y i ⊑ d) ⟹ (if (⨆i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i. if Y i ⊑ d then ⊥ else c)›*) case True (*‹∀i::nat. (Y::nat ⇒ 'a) i ⊑ (d::'a)›*) hence "Lub Y ⊑ d" using lub_below_iff[OF Y] (*‹((⨆i. Y i) ⊑ ?x) = (∀i. Y i ⊑ ?x)›*) by simp thus "?thesis" (*goal: ‹(if (⨆i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i. if Y i ⊑ d then ⊥ else c)›*) by simp next (*goal: ‹¬ (∀i. Y i ⊑ d) ⟹ (if (⨆i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i. if Y i ⊑ d then ⊥ else c)›*) case False (*‹¬ (∀i. Y i ⊑ d)›*) let ?f = "λi. if Y i ⊑ d then ⊥ else c" from False (*‹¬ (∀i. Y i ⊑ d)›*) have LubY: "¬ Lub Y ⊑ d" using lub_below_iff[OF Y] (*‹((⨆i. Y i) ⊑ ?x) = (∀i. Y i ⊑ ?x)›*) by simp from False (*‹¬ (∀i. Y i ⊑ d)›*) have F: "chain ?f" apply - (*goal: ‹chain (λi. if Y i ⊑ d then ⊥ else c)›*) apply (rule chainI (*‹(⋀i. ?Y i ⊑ ?Y (Suc i)) ⟹ chain ?Y›*)) (*goal: ‹¬ (∀i. Y i ⊑ d) ⟹ chain (λi. if Y i ⊑ d then ⊥ else c)›*) apply clarsimp (*goal: ‹⋀i. ¬ (∀i. Y i ⊑ d) ⟹ (if Y i ⊑ d then ⊥ else c) ⊑ (if Y (Suc i) ⊑ d then ⊥ else c)›*) apply (cut_tac i=i and j="Suc i" in chain_mono[OF Y] (*‹?i ≤ ?j ⟹ Y ?i ⊑ Y ?j›*)) (*goals: 1. ‹⋀i ia. ⟦Y ia \<notsqsubseteq> d; Y i \<notsqsubseteq> d; Y (Suc i) ⊑ d⟧ ⟹ i ≤ Suc i› 2. ‹⋀i ia. ⟦Y ia \<notsqsubseteq> d; Y i \<notsqsubseteq> d; Y (Suc i) ⊑ d; Y i ⊑ Y (Suc i)⟧ ⟹ c = ⊥› discuss goal 1*) apply clarsimp (*discuss goal 2*) apply (cut_tac x="Y i" and y="Y (Suc i)" and z=d in below_trans (*‹⟦(?x::?'a) ⊑ (?y::?'a); ?y ⊑ (?z::?'a)⟧ ⟹ ?x ⊑ ?z›*)) (*goals: 1. ‹⋀(i::nat) ia::nat. ⟦(Y::nat ⇒ 'a::pcpo) ia \<notsqsubseteq> (d::'a::pcpo); Y i \<notsqsubseteq> d; Y (Suc i) ⊑ d; Y i ⊑ Y (Suc i)⟧ ⟹ Y i ⊑ Y (Suc i)› 2. ‹⋀(i::nat) ia::nat. ⟦(Y::nat ⇒ 'a::pcpo) ia \<notsqsubseteq> (d::'a::pcpo); Y i \<notsqsubseteq> d; Y (Suc i) ⊑ d; Y i ⊑ Y (Suc i)⟧ ⟹ Y (Suc i) ⊑ d› 3. ‹⋀(i::nat) ia::nat. ⟦(Y::nat ⇒ 'a::pcpo) ia \<notsqsubseteq> (d::'a::pcpo); Y i \<notsqsubseteq> d; Y (Suc i) ⊑ d; Y i ⊑ Y (Suc i); Y i ⊑ d⟧ ⟹ (c::'b::pcpo) = ⊥› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) . from False (*‹¬ (∀i. Y i ⊑ d)›*) obtain i where Yi: "¬ Y i ⊑ d" (*goal: ‹(⋀i. Y i \<notsqsubseteq> d ⟹ thesis) ⟹ thesis›*) by blast hence M: "max_in_chain i ?f" apply - (*goal: ‹max_in_chain i (λi. if Y i ⊑ d then ⊥ else c)›*) apply (rule max_in_chainI (*‹(⋀j. ?i ≤ j ⟹ ?Y ?i = ?Y j) ⟹ max_in_chain ?i ?Y›*)) (*goal: ‹Y i \<notsqsubseteq> d ⟹ max_in_chain i (λi. if Y i ⊑ d then ⊥ else c)›*) apply clarsimp (*goal: ‹⋀j. ⟦Y i \<notsqsubseteq> d; i ≤ j⟧ ⟹ (if Y i ⊑ d then ⊥ else c) = (if Y j ⊑ d then ⊥ else c)›*) apply (drule chain_mono[OF Y] (*‹?i ≤ ?j ⟹ Y ?i ⊑ Y ?j›*)) (*goal: ‹⋀j. ⟦Y i \<notsqsubseteq> d; i ≤ j; Y j ⊑ d⟧ ⟹ c = ⊥›*) apply (cut_tac x="Y i" and y="Y j" and z=d in below_trans (*‹⟦?x ⊑ ?y; ?y ⊑ ?z⟧ ⟹ ?x ⊑ ?z›*)) (*goals: 1. ‹⋀j. ⟦Y i \<notsqsubseteq> d; Y j ⊑ d; Y i ⊑ Y j⟧ ⟹ Y i ⊑ Y j› 2. ‹⋀j. ⟦Y i \<notsqsubseteq> d; Y j ⊑ d; Y i ⊑ Y j⟧ ⟹ Y j ⊑ d› 3. ‹⋀j. ⟦Y i \<notsqsubseteq> d; Y j ⊑ d; Y i ⊑ Y j; Y i ⊑ d⟧ ⟹ c = ⊥› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . from LubY (*‹Lub Y \<notsqsubseteq> d›*) Yi (*‹Y i \<notsqsubseteq> d›*) show "?thesis" (*goal: ‹(if (⨆i. Y i) ⊑ d then ⊥ else c) ⊑ (⨆i. if Y i ⊑ d then ⊥ else c)›*) using iffD1[OF maxinch_is_thelub, OF F M] (*‹(⨆i. if Y i ⊑ d then ⊥ else c) = (if Y i ⊑ d then ⊥ else c)›*) by simp qed qed (*>*) text‹› lemma (in at_least_two_elements) below_monic_unitK [intro, simp]: "below_monic_cfun (unitK :: 'o ValK → 'o ValKM)" proof (rule below_monicI (*‹(⋀(x::?'a::cpo) y::?'a::cpo. (?f::?'a::cpo ⇒ ?'b::cpo) x ⊑ ?f y ⟹ x ⊑ y) ⟹ below_monic ?f›*)) (*goal: ‹⋀(x::'o::domain ValK) y::'o::domain ValK. unitK⋅x ⊑ unitK⋅y ⟹ x ⊑ y›*) fix v :: "'o ValK" and v' :: "'o ValK" assume vv': "unitK⋅v ⊑ unitK⋅v'" (*‹unitK⋅(v::'o ValK) ⊑ unitK⋅(v'::'o ValK)›*) let ?k = "Λ x. if x ⊑ v' then ⊥ else some_non_bottom_element" from vv' (*‹unitK⋅(v::'o ValK) ⊑ unitK⋅(v'::'o ValK)›*) have "unitK⋅v⋅?k ⊑ unitK⋅v'⋅?k" by (rule monofun_cfun_fun (*‹(?f::?'a::cpo → ?'b::cpo) ⊑ (?g::?'a::cpo → ?'b::cpo) ⟹ ?f⋅(?x::?'a::cpo) ⊑ ?g⋅?x›*)) hence "?k⋅v ⊑ ?k⋅v'" by (simp add: unitK_def (*‹unitK ≡ Λ a c. c⋅a›*)) with some_non_bottom_element (*‹some_non_bottom_element ≠ ⊥›*) show "v ⊑ v'" by (auto split: if_split_asm (*‹?P (if ?Q then ?x else ?y) = (¬ (?Q ∧ ¬ ?P ?x ∨ ¬ ?Q ∧ ¬ ?P ?y))›*)) qed subsection‹Logical relation› text‹ We follow \<^citet>‹"DBLP:conf/icalp/Reynolds74"› by simultaneously defining a pair of relations over values and functions. Both are bottom-reflecting, in contrast to the situation for computational adequacy in \S\ref{sec:compad}. \<^citet>‹"DBLP:journals/tcs/Filinski07"› differs by assuming that values are always defined, and relates values and monadic computations. › type_synonym 'o lfr = "(ValD, 'o ValKM, ValD → ValD, 'o ValKM → 'o ValKM) lf_pair_rep" type_synonym 'o lflf = "(ValD, 'o ValKM, ValD → ValD, 'o ValKM → 'o ValKM) lf_pair" context at_least_two_elements begin abbreviation lr_eta_rep_N where "lr_eta_rep_N ≡ { (e, e') . (e = ⊥ ∧ e' = ⊥) ∨ (e = ValTT ∧ e' = unitK⋅ValKTT) ∨ (e = ValFF ∧ e' = unitK⋅ValKFF) ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n)) }" abbreviation lr_eta_rep_F where "lr_eta_rep_F ≡ λ(rm, rp). { (e, e') . (e = ⊥ ∧ e' = ⊥) ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp)) }" definition lr_eta_rep where "lr_eta_rep ≡ λr. lr_eta_rep_N ∪ lr_eta_rep_F r" definition lr_theta_rep where "lr_theta_rep ≡ λ(rm, rp). { (f, f') . (∀(x, x') ∈ unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)) }" definition lr_rep :: "'o lfr" where "lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)" abbreviation lr :: "'o lflf" where "lr ≡ λr. (mklr (fst (lr_rep r)), mklr (snd (lr_rep r)))" (*<*) text‹ Properties of the logical relation. › lemma admS_eta_rep [intro, simp]: "fst (lr_rep r) ∈ admS" unfolding lr_rep_def lr_eta_rep_def (*goal: ‹fst ({(e::ValD, e'::('o::domain ValK → 'o::domain) → 'o::domain). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n::nat. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r::((ValD × (('o::domain ValK → 'o::domain) → 'o::domain)) admS × ((ValD → ValD) × ((('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)) admS) dual × (ValD × (('o::domain ValK → 'o::domain) → 'o::domain)) admS × ((ValD → ValD) × ((('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)) admS of (rm::((ValD × (('o::domain ValK → 'o::domain) → 'o::domain)) admS × ((ValD → ValD) × ((('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)) admS) dual, rp::(ValD × (('o::domain ValK → 'o::domain) → 'o::domain)) admS × ((ValD → ValD) × ((('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)) admS) ⇒ {(e::ValD, e'::('o::domain ValK → 'o::domain) → 'o::domain). e = ⊥ ∧ e' = ⊥ ∨ (∃(f::ValD → ValD) f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))}), lr_theta_rep r) ∈ admS›*) apply simp (*goal: ‹fst ({(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))}), lr_theta_rep r) ∈ admS›*) apply rule (*goal: ‹{(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f. e = ValF⋅f ∧ (∃f'. e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp)))}) ∈ admS›*) apply (auto intro!: adm_disj (*‹⟦adm ?P; adm ?Q⟧ ⟹ adm (λx. ?P x ∨ ?Q x)›*) simp: split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*top goal: ‹⊥ ∈ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f. e = ValF⋅f ∧ (∃f'. e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp)))})› and 1 goal remains*) using adm_below_monic_exists[OF _ below_monic_pair [ OF below_monic_ValN below_monic_cfcomp2 [ OF below_monic_unitK below_monic_ValKN ] ], where P = "λ_. True"] (*‹⟦adm (λ_. True); cont (Rep_cfun (Λ x. (ValN⋅x, (unitK oo ValKN)⋅x)))⟧ ⟹ adm (λx. ∃y. x = (Λ x. (ValN⋅x, (unitK oo ValKN)⋅x))⋅y ∧ True)›*) apply (simp add: prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*)) (*top goal: ‹adm (λx::ValD × (('o ValK → 'o) → 'o). ∃n::nat. fst x = ValN⋅n ∧ snd x = unitK⋅(ValKN⋅n))› and 1 goal remains*) using adm_below_monic_exists[OF _ below_monic_pair_split [ OF below_monic_ValF below_monic_cfcomp2 [ OF below_monic_unitK below_monic_ValKF ] ], where P = "λx. x ∈ unlr (snd (snd r))"] (*‹⟦adm (λx. x ∈ unlr (snd (snd r))); cont (Rep_cfun (Λ x. (ValF⋅(fst x), (unitK oo ValKF)⋅(snd x))))⟧ ⟹ adm (λx. ∃y. x = (Λ x. (ValF⋅(fst x), (unitK oo ValKF)⋅(snd x)))⋅y ∧ y ∈ unlr (snd (snd r)))›*) by (simp add: prod_eq_iff (*‹(?s = ?t) = (fst ?s = fst ?t ∧ snd ?s = snd ?t)›*)) lemma admS_theta_rep [intro, simp]: "snd (lr_rep r) ∈ admS" proof (standard) (*goals: 1. ‹⊥ ∈ snd (lr_rep (r::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual × (ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS))› 2. ‹adm (λx::(ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). x ∈ snd (lr_rep (r::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual × (ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS)))›*) show "⊥ ∈ snd (lr_rep r)" unfolding lr_rep_def lr_theta_rep_def (*goal: ‹⊥ ∈ snd (lr_eta_rep r, case r of (rm, rp) ⇒ {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)})›*) apply (cases r) (*goal: ‹⊥ ∈ snd (lr_eta_rep r, case r of (rm, rp) ⇒ {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)})›*) by simp next (*goal: ‹adm (λx::(ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). x ∈ snd (lr_rep (r::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual × (ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS)))›*) show "adm (λx. x ∈ snd (lr_rep r))" apply (rule admI (*‹(⋀Y. ⟦chain Y; ∀i. ?P (Y i)⟧ ⟹ ?P (⨆i. Y i)) ⟹ adm ?P›*)) (*goal: ‹adm (λx. x ∈ snd (lr_rep r))›*) unfolding lr_rep_def lr_theta_rep_def (*goal: ‹⋀Y. ⟦chain Y; ∀i. Y i ∈ snd (lr_eta_rep r, case r of (rm, rp) ⇒ {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)})⟧ ⟹ (⨆i. Y i) ∈ snd (lr_eta_rep r, case r of (rm, rp) ⇒ {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)})›*) apply (clarsimp simp: split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*goal: ‹⋀Y. ⟦chain Y; ∀i. Y i ∈ snd (lr_eta_rep r, case r of (rm, rp) ⇒ {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)})⟧ ⟹ (⨆i. Y i) ∈ snd (lr_eta_rep r, case r of (rm, rp) ⇒ {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)})›*) apply (rule admD (*‹⟦adm (?P::?'a::cpo ⇒ bool); chain (?Y::nat ⇒ ?'a::cpo); ⋀i::nat. ?P (?Y i)⟧ ⟹ ?P (⨆i::nat. ?Y i)›*)) (*goals: 1. ‹⋀Y a b. ⟦chain Y; ∀i. ∀x∈unlr (fst (undual (fst r))). (fst (Y i)⋅(fst x), snd (Y i)⋅(snd x)) ∈ unlr (fst (snd r)); (a, b) ∈ unlr (fst (undual (fst r)))⟧ ⟹ adm (λc. (fst c⋅a, snd c⋅b) ∈ unlr (fst (snd r)))› 2. ‹⋀Y a b. ⟦chain Y; ∀i. ∀x∈unlr (fst (undual (fst r))). (fst (Y i)⋅(fst x), snd (Y i)⋅(snd x)) ∈ unlr (fst (snd r)); (a, b) ∈ unlr (fst (undual (fst r)))⟧ ⟹ chain Y› 3. ‹⋀Y a b i. ⟦chain Y; ∀i. ∀x∈unlr (fst (undual (fst r))). (fst (Y i)⋅(fst x), snd (Y i)⋅(snd x)) ∈ unlr (fst (snd r)); (a, b) ∈ unlr (fst (undual (fst r)))⟧ ⟹ (fst (Y i)⋅a, snd (Y i)⋅b) ∈ unlr (fst (snd r))› discuss goal 1*) apply (rule adm_subst (*‹⟦cont ?t; adm ?P⟧ ⟹ adm (λx. ?P (?t x))›*)) (*goals: 1. ‹⋀Y a b. ⟦chain Y; ∀i. ∀x∈unlr (fst (undual (fst r))). (fst (Y i)⋅(fst x), snd (Y i)⋅(snd x)) ∈ unlr (fst (snd r)); (a, b) ∈ unlr (fst (undual (fst r)))⟧ ⟹ cont (λx. (fst x⋅a, snd x⋅b))› 2. ‹⋀Y a b. ⟦chain Y; ∀i. ∀x∈unlr (fst (undual (fst r))). (fst (Y i)⋅(fst x), snd (Y i)⋅(snd x)) ∈ unlr (fst (snd r)); (a, b) ∈ unlr (fst (undual (fst r)))⟧ ⟹ adm (λa. a ∈ unlr (fst (snd r)))› discuss goal 1*) apply force (*discuss goal 2*) apply force (*proven 2 subgoals*) (*discuss goal 2*) apply force (*discuss goal 3*) apply force (*proven 3 subgoals*) . qed lemma mono_lr: shows "mono (lr :: 'o lflf)" apply (rule monoI (*‹(⋀x y. x ≤ y ⟹ ?f x ≤ ?f y) ⟹ mono ?f›*)) (*goal: ‹mono lr›*) apply simp (*goal: ‹⋀x y. x ≤ y ⟹ lr x ≤ lr y›*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*)) (*goal: ‹⋀x y. x ≤ y ⟹ fst (lr_rep x) ⊆ fst (lr_rep y) ∧ snd (lr_rep x) ⊆ snd (lr_rep y)›*) apply (rule conjI (*‹⟦?P; ?Q⟧ ⟹ ?P ∧ ?Q›*)) (*goals: 1. ‹⋀x y. x ≤ y ⟹ lr_eta_rep x ⊆ lr_eta_rep y› 2. ‹⋀x y. x ≤ y ⟹ lr_theta_rep x ⊆ lr_theta_rep y› discuss goal 1*) apply (force simp: lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) dual_less_eq_iff (*‹(?x ≤ ?y) = (undual ?y ≤ undual ?x)›*) unlr_leq[symmetric] (*‹(?x ≤ ?y) = (unlr ?x ⊆ unlr ?y)›*)) (*discuss goal 2*) apply (auto simp: lr_theta_rep_def (*‹lr_theta_rep ≡ λ(rm, rp). {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)}›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) dual_less_eq_iff (*‹(?x ≤ ?y) = (undual ?y ≤ undual ?x)›*) unlr_leq[symmetric] (*‹(?x ≤ ?y) = (unlr ?x ⊆ unlr ?y)›*)) (*goal: ‹⋀(x::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual × (ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) y::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual × (ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS. x ≤ y ⟹ lr_theta_rep x ⊆ lr_theta_rep y›*) apply (drule_tac x="(ae, bc)" in bspec (*‹⟦∀x∈?A. ?P x; ?x ∈ ?A⟧ ⟹ ?P ?x›*)) (*goals: 1. ‹⋀a aa b ab ac ba ad bb ae bc. ⟦(ae, bc) ∈ unlr (fst (undual ab)); undual ab ≤ undual a; unlr aa ⊆ unlr ac; unlr b ⊆ unlr ba⟧ ⟹ (ae, bc) ∈ unlr (fst (undual a))› 2. ‹⋀a aa b ab ac ba ad bb ae bc. ⟦(ae, bc) ∈ unlr (fst (undual ab)); undual ab ≤ undual a; unlr aa ⊆ unlr ac; unlr b ⊆ unlr ba; (ad⋅(fst (ae, bc)), bb⋅(snd (ae, bc))) ∈ unlr aa⟧ ⟹ (ad⋅ae, bb⋅bc) ∈ unlr ac› discuss goal 1*) apply (case_tac a) (*top goal: ‹⋀a aa b ab ac ba ad bb ae bc. ⟦(ae, bc) ∈ unlr (fst (undual ab)); undual ab ≤ undual a; unlr aa ⊆ unlr ac; unlr b ⊆ unlr ba⟧ ⟹ (ae, bc) ∈ unlr (fst (undual a))› and 1 goal remains*) apply (case_tac ab) (*top goal: ‹⋀a aa b ab ac ba ad bb ae bc y. ⟦(ae, bc) ∈ unlr (fst (undual ab)); undual ab ≤ undual a; unlr aa ⊆ unlr ac; unlr b ⊆ unlr ba; a = dual y; y ∈ UNIV⟧ ⟹ (ae, bc) ∈ unlr (fst (undual a))› and 1 goal remains*) apply ((auto simp: unlr_leq[symmetric] (*‹(?x ≤ ?y) = (unlr ?x ⊆ unlr ?y)›*))[1]) (*discuss goal 2*) apply ((auto simp: unlr_leq[symmetric] (*‹((?x::?'a admS) ≤ (?y::?'a admS)) = (unlr ?x ⊆ unlr ?y)›*))[1]) (*proven 2 subgoals*) (*proven 2 subgoals*) . (*>*) end (* context at_least_two_elements *) text‹ It takes some effort to set up the minimal invariant relating the two pairs of domains. One might hope this would be easier using deflations (which might compose) rather than ``copy'' functions (which certainly don't). We elide these as they are tedious. › (*<*) primrec ValD_copy_i :: "nat ⇒ ValD → ValD" where "ValD_copy_i 0 = ⊥" | "ValD_copy_i (Suc n) = (Λ v. case v of ValF⋅f ⇒ ValF⋅(ValD_copy_i n oo f oo ValD_copy_i n) | ValTT ⇒ ValTT | ValFF ⇒ ValFF | ValN⋅m ⇒ ValN⋅m)" abbreviation "ValD_copy_lub ≡ (⨆i. ValD_copy_i i)" lemma ValD_copy_chain [intro, simp]: "chain ValD_copy_i" proof (rule chainI (*‹(⋀i. ?Y i ⊑ ?Y (Suc i)) ⟹ chain ?Y›*)) (*goal: ‹⋀i. ValD_copy_i i ⊑ ValD_copy_i (Suc i)›*) fix i show "ValD_copy_i i ⊑ ValD_copy_i (Suc i)" proof (induct i) (*goals: 1. ‹ValD_copy_i 0 ⊑ ValD_copy_i (Suc 0)› 2. ‹⋀i. ValD_copy_i i ⊑ ValD_copy_i (Suc i) ⟹ ValD_copy_i (Suc i) ⊑ ValD_copy_i (Suc (Suc i))›*) case (Suc i) (*‹ValD_copy_i i ⊑ ValD_copy_i (Suc i)›*) { fix x have "ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x" proof (cases x) (*goals: 1. ‹x = ⊥ ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 2. ‹⋀cfun. x = ValF⋅cfun ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 3. ‹x = ValTT ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 4. ‹x = ValFF ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 5. ‹⋀nat. x = ValN⋅nat ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x›*) case (ValF f) (*‹x = ValF⋅f›*) with Suc (*‹ValD_copy_i i ⊑ ValD_copy_i (Suc i)›*) show "?thesis" (*goal: ‹ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x›*) by (clarsimp simp: cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) qed (simp_all) (*solves the remaining goals: 1. ‹x = ⊥ ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 2. ‹x = ValTT ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 3. ‹x = ValFF ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x› 4. ‹⋀nat. x = ValN⋅nat ⟹ ValD_copy_i (Suc i)⋅x ⊑ ValD_copy_i (Suc (Suc i))⋅x›*) } thus "?case" (*goal: ‹ValD_copy_i (Suc i) ⊑ ValD_copy_i (Suc (Suc i))›*) by (simp add: cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*)) qed (simp) (*solved the remaining goal: ‹ValD_copy_i 0 ⊑ ValD_copy_i (Suc 0)›*) qed lemma ValD_copy_lub_ID: "ValD_copy_lub = ID" proof (-) (*goal: ‹ValD_copy_lub = ID›*) { fix x :: ValD fix i :: nat have "ValD_take i⋅(ValD_copy_i i⋅(ValD_take i⋅x)) = ValD_take i⋅x" proof (induct i arbitrary: x) (*goals: 1. ‹⋀x::ValD. ValD_take (0::nat)⋅(ValD_copy_i (0::nat)⋅(ValD_take (0::nat)⋅x)) = ValD_take (0::nat)⋅x› 2. ‹⋀(i::nat) x::ValD. (⋀x::ValD. ValD_take i⋅(ValD_copy_i i⋅(ValD_take i⋅x)) = ValD_take i⋅x) ⟹ ValD_take (Suc i)⋅(ValD_copy_i (Suc i)⋅(ValD_take (Suc i)⋅x)) = ValD_take (Suc i)⋅x›*) case (Suc n) (*‹ValD_take n⋅(ValD_copy_i n⋅(ValD_take n⋅?x)) = ValD_take n⋅?x›*) thus "?case" (*goal: ‹ValD_take (Suc n)⋅(ValD_copy_i (Suc n)⋅(ValD_take (Suc n)⋅x)) = ValD_take (Suc n)⋅x›*) apply (cases x) (*goals: 1. ‹⟦⋀x. ValD_take n⋅(ValD_copy_i n⋅(ValD_take n⋅x)) = ValD_take n⋅x; x = ⊥⟧ ⟹ ValD_take (Suc n)⋅(ValD_copy_i (Suc n)⋅(ValD_take (Suc n)⋅x)) = ValD_take (Suc n)⋅x› 2. ‹⋀cfun. ⟦⋀x. ValD_take n⋅(ValD_copy_i n⋅(ValD_take n⋅x)) = ValD_take n⋅x; x = ValF⋅cfun⟧ ⟹ ValD_take (Suc n)⋅(ValD_copy_i (Suc n)⋅(ValD_take (Suc n)⋅x)) = ValD_take (Suc n)⋅x› 3. ‹⟦⋀x. ValD_take n⋅(ValD_copy_i n⋅(ValD_take n⋅x)) = ValD_take n⋅x; x = ValTT⟧ ⟹ ValD_take (Suc n)⋅(ValD_copy_i (Suc n)⋅(ValD_take (Suc n)⋅x)) = ValD_take (Suc n)⋅x› 4. ‹⟦⋀x. ValD_take n⋅(ValD_copy_i n⋅(ValD_take n⋅x)) = ValD_take n⋅x; x = ValFF⟧ ⟹ ValD_take (Suc n)⋅(ValD_copy_i (Suc n)⋅(ValD_take (Suc n)⋅x)) = ValD_take (Suc n)⋅x› 5. ‹⋀nat. ⟦⋀x. ValD_take n⋅(ValD_copy_i n⋅(ValD_take n⋅x)) = ValD_take n⋅x; x = ValN⋅nat⟧ ⟹ ValD_take (Suc n)⋅(ValD_copy_i (Suc n)⋅(ValD_take (Suc n)⋅x)) = ValD_take (Suc n)⋅x› discuss goal 1*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 2*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 3*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 4*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 5*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*proven 5 subgoals*) . qed (simp) (*solved the remaining goal: ‹⋀x. ValD_take 0⋅(ValD_copy_i 0⋅(ValD_take 0⋅x)) = ValD_take 0⋅x›*) } hence "⋀x :: ValD. (⨆i. ValD_take i⋅(ValD_copy_i i⋅(ValD_take i⋅x))) = (⨆i. ValD_take i⋅x)" by (blast intro: lub_eq (*‹(⋀i. ?X i = ?Y i) ⟹ (⨆i. ?X i) = (⨆i. ?Y i)›*)) thus "?thesis" (*goal: ‹ValD_copy_lub = ID›*) by (simp add: lub_distribs (*‹⟦chain ?F; chain ?Y⟧ ⟹ (⨆i. ?F i⋅(?Y i)) = (⨆i. ?F i)⋅(⨆i. ?Y i)› ‹⟦⋀x. chain (λi. ?F i x); ⋀i. cont (?F i)⟧ ⟹ (⨆i. Λ x. ?F i x) = (Λ x. ⨆i. ?F i x)›*) ValD.lub_take (*‹(⨆n. ValD_take n) = ID›*) cfun_eq_iff (*‹(?f = ?g) = (∀x. ?f⋅x = ?g⋅x)›*)) qed text‹ Continuations: we need to ensure the observation type is always the same. › definition KM_map :: "('o ValK → 'o ValK) → 'o ValKM → 'o ValKM" where "KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID" lemma KM_map_id [intro, simp]: "KM_map⋅ID = ID" unfolding KM_map_def (*goal: ‹(Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID)⋅ID = ID›*) by (simp add: cfun_map_ID (*‹cfun_map⋅ID⋅ID = ID›*)) lemma KM_map_strict [intro, simp]: "KM_map⋅f⋅⊥ = ⊥" unfolding KM_map_def (*goal: ‹(Λ (f::'a::domain ValK → 'a::domain ValK). cfun_map⋅(cfun_map⋅f⋅ID)⋅ID)⋅(f::'a::domain ValK → 'a::domain ValK)⋅⊥ = ⊥›*) by (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) primrec ValK_copy_i :: "nat ⇒ 'o ValK → 'o ValK" where "ValK_copy_i 0 = ⊥" | "ValK_copy_i (Suc n) = (Λ v. case v of ValKF⋅f ⇒ ValKF⋅(cfun_map⋅(KM_map⋅(ValK_copy_i n))⋅(KM_map⋅(ValK_copy_i n))⋅f) | ValKTT ⇒ ValKTT | ValKFF ⇒ ValKFF | ValKN⋅m ⇒ ValKN⋅m)" abbreviation "ValK_copy ≡ (⨆i. ValK_copy_i i)" lemma ValK_copy_chain [intro, simp]: "chain (ValK_copy_i :: nat ⇒ 'o ValK → 'o ValK)" proof (rule chainI (*‹(⋀i. ?Y i ⊑ ?Y (Suc i)) ⟹ chain ?Y›*)) (*goal: ‹⋀i. ValK_copy_i i ⊑ ValK_copy_i (Suc i)›*) fix i show "ValK_copy_i i ⊑ (ValK_copy_i (Suc i) :: 'o ValK → 'o ValK)" proof (induct i) (*goals: 1. ‹ValK_copy_i 0 ⊑ ValK_copy_i (Suc 0)› 2. ‹⋀i. ValK_copy_i i ⊑ ValK_copy_i (Suc i) ⟹ ValK_copy_i (Suc i) ⊑ ValK_copy_i (Suc (Suc i))›*) case (Suc i) (*‹ValK_copy_i i ⊑ ValK_copy_i (Suc i)›*) { fix x :: "'o ValK" have "ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x" proof (cases x) (*goals: 1. ‹x = ⊥ ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 2. ‹⋀cfun. x = ValKF⋅cfun ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 3. ‹x = ValKTT ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 4. ‹x = ValKFF ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 5. ‹⋀nat. x = ValKN⋅nat ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x›*) case (ValKF f) (*‹x = ValKF⋅f›*) with Suc (*‹ValK_copy_i i ⊑ ValK_copy_i (Suc i)›*) show "?thesis" (*goal: ‹ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x›*) by (clarsimp simp: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*)) qed (simp_all) (*solves the remaining goals: 1. ‹x = ⊥ ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 2. ‹x = ValKTT ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 3. ‹x = ValKFF ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x› 4. ‹⋀nat. x = ValKN⋅nat ⟹ ValK_copy_i (Suc i)⋅x ⊑ ValK_copy_i (Suc (Suc i))⋅x›*) } thus "?case" (*goal: ‹ValK_copy_i (Suc i) ⊑ ValK_copy_i (Suc (Suc i))›*) by (simp add: cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*)) qed (simp) (*solved the remaining goal: ‹ValK_copy_i 0 ⊑ ValK_copy_i (Suc 0)›*) qed lemma ValK_copy_fix: "ValK_copy = (ID :: 'o ValK → 'o ValK)" proof (-) (*goal: ‹ValK_copy = ID›*) { fix x :: "'o ValK" fix i :: nat have "ValK_take i⋅(ValK_copy_i i⋅(ValK_take i⋅x)) = ValK_take i⋅x" proof (induct i arbitrary: x) (*goals: 1. ‹⋀x. ValK_take 0⋅(ValK_copy_i 0⋅(ValK_take 0⋅x)) = ValK_take 0⋅x› 2. ‹⋀i x. (⋀x. ValK_take i⋅(ValK_copy_i i⋅(ValK_take i⋅x)) = ValK_take i⋅x) ⟹ ValK_take (Suc i)⋅(ValK_copy_i (Suc i)⋅(ValK_take (Suc i)⋅x)) = ValK_take (Suc i)⋅x›*) case (Suc n) (*‹ValK_take n⋅(ValK_copy_i n⋅(ValK_take n⋅?x)) = ValK_take n⋅?x›*) thus "?case" (*goal: ‹ValK_take (Suc (n::nat))⋅(ValK_copy_i (Suc n)⋅(ValK_take (Suc n)⋅(x::'o ValK))) = ValK_take (Suc n)⋅x›*) apply (cases x) (*goals: 1. ‹⟦⋀x. ValK_take n⋅(ValK_copy_i n⋅(ValK_take n⋅x)) = ValK_take n⋅x; x = ⊥⟧ ⟹ ValK_take (Suc n)⋅(ValK_copy_i (Suc n)⋅(ValK_take (Suc n)⋅x)) = ValK_take (Suc n)⋅x› 2. ‹⋀cfun. ⟦⋀x. ValK_take n⋅(ValK_copy_i n⋅(ValK_take n⋅x)) = ValK_take n⋅x; x = ValKF⋅cfun⟧ ⟹ ValK_take (Suc n)⋅(ValK_copy_i (Suc n)⋅(ValK_take (Suc n)⋅x)) = ValK_take (Suc n)⋅x› 3. ‹⟦⋀x. ValK_take n⋅(ValK_copy_i n⋅(ValK_take n⋅x)) = ValK_take n⋅x; x = ValKTT⟧ ⟹ ValK_take (Suc n)⋅(ValK_copy_i (Suc n)⋅(ValK_take (Suc n)⋅x)) = ValK_take (Suc n)⋅x› 4. ‹⟦⋀x. ValK_take n⋅(ValK_copy_i n⋅(ValK_take n⋅x)) = ValK_take n⋅x; x = ValKFF⟧ ⟹ ValK_take (Suc n)⋅(ValK_copy_i (Suc n)⋅(ValK_take (Suc n)⋅x)) = ValK_take (Suc n)⋅x› 5. ‹⋀nat. ⟦⋀x. ValK_take n⋅(ValK_copy_i n⋅(ValK_take n⋅x)) = ValK_take n⋅x; x = ValKN⋅nat⟧ ⟹ ValK_take (Suc n)⋅(ValK_copy_i (Suc n)⋅(ValK_take (Suc n)⋅x)) = ValK_take (Suc n)⋅x› discuss goal 1*) apply (simp add: KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 2*) apply (simp add: KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 3*) apply (simp add: KM_map_def (*‹KM_map ≡ Λ (f::?'o ValK → ?'o ValK). cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ (a::?'b → ?'a) (b::?'c → ?'d) (f::?'a → ?'c) (x::?'b). b⋅(f⋅(a⋅x)))›*)) (*discuss goal 4*) apply (simp add: KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 5*) apply (simp add: KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*proven 5 subgoals*) . qed (simp) (*solved the remaining goal: ‹⋀x. ValK_take 0⋅(ValK_copy_i 0⋅(ValK_take 0⋅x)) = ValK_take 0⋅x›*) } hence "⋀x :: 'o ValK. (⨆i. ValK_take i⋅(ValK_copy_i i⋅(ValK_take i⋅x))) = (⨆i. ValK_take i⋅x)" by (blast intro: lub_eq (*‹(⋀i. ?X i = ?Y i) ⟹ (⨆i. ?X i) = (⨆i. ?Y i)›*)) thus "?thesis" (*goal: ‹ValK_copy = ID›*) by (simp add: lub_distribs (*‹⟦chain ?F; chain ?Y⟧ ⟹ (⨆i. ?F i⋅(?Y i)) = (⨆i. ?F i)⋅(⨆i. ?Y i)› ‹⟦⋀x. chain (λi. ?F i x); ⋀i. cont (?F i)⟧ ⟹ (⨆i. Λ x. ?F i x) = (Λ x. ⨆i. ?F i x)›*) ValK.lub_take (*‹(⨆n. ValK_take n) = ID›*) cfun_eq_iff (*‹(?f = ?g) = (∀x. ?f⋅x = ?g⋅x)›*)) qed lemma ValK_strict [intro, simp]: "ValK_copy⋅⊥ = ⊥" by (simp add: ValK_copy_fix (*‹ValK_copy = ID›*)) text‹ We need to respect the purported domain structure, and positive and negative occurrences. › fixrec ValD_copy_rec :: "((ValD → ValD) × ((ValD → ValD) → (ValD → ValD))) → ((ValD → ValD) × ((ValD → ValD) → (ValD → ValD)))" where "ValD_copy_rec⋅r = (Λ v. case v of ValF⋅f ⇒ ValF⋅(snd r⋅f) | ValTT ⇒ ValTT | ValFF ⇒ ValFF | ValN⋅n ⇒ ValN⋅n, Λ f. cfun_map⋅(strictify⋅(fst r))⋅(strictify⋅(fst r))⋅f)" abbreviation ValD_copy_eta :: "nat ⇒ ValD → ValD" where "ValD_copy_eta i ≡ fst (iterate i⋅ValD_copy_rec⋅⊥)" abbreviation ValD_copy_theta :: "nat ⇒ (ValD → ValD) → (ValD → ValD)" where "ValD_copy_theta i ≡ snd (iterate i⋅ValD_copy_rec⋅⊥)" lemma ValD_copy_eta_theta_strict [intro, simp]: "ValD_copy_eta n⋅⊥ = ⊥" "ValD_copy_theta n⋅⊥ = ⊥" apply (induct n) (*goals: 1. ‹ValD_copy_eta 0⋅⊥ = ⊥› 2. ‹ValD_copy_theta 0⋅⊥ = ⊥› 3. ‹⋀n. ⟦ValD_copy_eta n⋅⊥ = ⊥; ValD_copy_theta n⋅⊥ = ⊥⟧ ⟹ ValD_copy_eta (Suc n)⋅⊥ = ⊥› 4. ‹⋀n. ⟦ValD_copy_eta n⋅⊥ = ⊥; ValD_copy_theta n⋅⊥ = ⊥⟧ ⟹ ValD_copy_theta (Suc n)⋅⊥ = ⊥› discuss goal 1*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 2*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ (a::?'b::cpo → ?'a::cpo) (b::?'c::cpo → ?'d::cpo) (f::?'a::cpo → ?'c::cpo) (x::?'b::cpo). b⋅(f⋅(a⋅x)))›*)) (*discuss goal 3*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 4*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ (a::?'b → ?'a) (b::?'c → ?'d) (f::?'a → ?'c) (x::?'b). b⋅(f⋅(a⋅x)))›*)) (*proven 4 subgoals*) . lemma ValD_copy_fix_strict [simp]: "fst (fix⋅ValD_copy_rec)⋅⊥ = ⊥" "snd (fix⋅ValD_copy_rec)⋅⊥ = ⊥" (*goals: 1. ‹fst (fix⋅Continuations.ValD_copy_rec)⋅⊥ = ⊥› 2. ‹snd (fix⋅Continuations.ValD_copy_rec)⋅⊥ = ⊥› discuss goal 1*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*top goal: ‹fst (fix⋅Continuations.ValD_copy_rec)⋅⊥ = ⊥› and 1 goal remains*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 2*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹snd (fix⋅Continuations.ValD_copy_rec)⋅⊥ = ⊥›*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*proven 2 subgoals*) . lemma ValD_copy_rec_ValD_copy_lub: "fix⋅ValD_copy_rec = (ValD_copy_lub, cfun_map⋅ValD_copy_lub⋅ValD_copy_lub)" (is "?lhs = ?rhs") proof (rule below_antisym (*‹⟦(?x::?'a) ⊑ (?y::?'a); ?y ⊑ ?x⟧ ⟹ ?x = ?y›*)) (*goals: 1. ‹fix⋅Continuations.ValD_copy_rec ⊑ (ValD_copy_lub, cfun_map⋅ValD_copy_lub⋅ValD_copy_lub)› 2. ‹(ValD_copy_lub, cfun_map⋅ValD_copy_lub⋅ValD_copy_lub) ⊑ fix⋅Continuations.ValD_copy_rec›*) show "?lhs ⊑ ?rhs" apply (rule fix_least (*‹?F⋅?x = ?x ⟹ fix⋅?F ⊑ ?x›*)) (*goal: ‹fix⋅Continuations.ValD_copy_rec ⊑ (ValD_copy_lub, cfun_map⋅ValD_copy_lub⋅ValD_copy_lub)›*) by (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) ValD_copy_lub_ID (*‹ValD_copy_lub = ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) ID_def (*‹ID = (Λ x. x)›*)) next (*goal: ‹(ValD_copy_lub, cfun_map⋅ValD_copy_lub⋅ValD_copy_lub) ⊑ fix⋅Continuations.ValD_copy_rec›*) { fix i have "ValD_copy_i i ⊑ fst (fix⋅ValD_copy_rec)" proof (induct i) (*goals: 1. ‹ValD_copy_i 0 ⊑ fst (fix⋅Continuations.ValD_copy_rec)› 2. ‹⋀i. ValD_copy_i i ⊑ fst (fix⋅Continuations.ValD_copy_rec) ⟹ ValD_copy_i (Suc i) ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) case (Suc i) (*‹ValD_copy_i i ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) thus "?case" (*goal: ‹ValD_copy_i (Suc (i::nat)) ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) apply - (*goal: ‹ValD_copy_i (Suc (i::nat)) ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) apply (subst fix_eq (*‹fix⋅(?F::?'a::pcpo → ?'a::pcpo) = ?F⋅(fix⋅?F)›*)) (*goal: ‹ValD_copy_i i ⊑ fst (fix⋅Continuations.ValD_copy_rec) ⟹ ValD_copy_i (Suc i) ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹ValD_copy_i (i::nat) ⊑ fst (fix⋅Continuations.ValD_copy_rec) ⟹ ValD_copy_i (Suc i) ⊑ fst (Continuations.ValD_copy_rec⋅(fix⋅Continuations.ValD_copy_rec))›*) apply (simp add: eta_cfun (*‹(Λ (x::?'a::cpo). (?f::?'a::cpo → ?'b::cpo)⋅x) = ?f›*) strictify_cancel (*‹(?f::?'b::pcpo → ?'a::pcpo)⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) cfcomp1 (*‹(?f::?'c::cpo → ?'b::cpo) oo (?g::?'a::cpo → ?'c::cpo) = (Λ (x::?'a::cpo). ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ (a::?'b::cpo → ?'a::cpo) (b::?'c::cpo → ?'d::cpo) (f::?'a::cpo → ?'c::cpo) (x::?'b::cpo). b⋅(f⋅(a⋅x)))›*)) (*goal: ‹ValD_copy_i i ⊑ fst (fix⋅Continuations.ValD_copy_rec) ⟹ ValD_copy_i (Suc i) ⊑ fst (Continuations.ValD_copy_rec⋅(Continuations.ValD_copy_rec⋅(fix⋅Continuations.ValD_copy_rec)))›*) apply (intro monofun_cfun_fun (*‹?f ⊑ ?g ⟹ ?f⋅?x ⊑ ?g⋅?x›*) monofun_cfun_arg (*‹?x ⊑ ?y ⟹ ?f⋅?x ⊑ ?f⋅?y›*)) (*goal: ‹ValD_copy_i i ⊑ fst (fix⋅Continuations.ValD_copy_rec) ⟹ ValD_case⋅(Λ f. ValF⋅(Λ x. ValD_copy_i i⋅(f⋅(ValD_copy_i i⋅x))))⋅ValTT⋅ValFF⋅ValN ⊑ ValD_case⋅(Λ f. ValF⋅(Λ x. fst (fix⋅Continuations.ValD_copy_rec)⋅(f⋅(fst (fix⋅Continuations.ValD_copy_rec)⋅x))))⋅ValTT⋅ValFF⋅ValN›*) by (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*)) qed (simp) (*solved the remaining goal: ‹ValD_copy_i 0 ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) } hence D: "ValD_copy_lub ⊑ fst (fix⋅ValD_copy_rec)" by (simp add: lub_below_iff (*‹chain (?S::nat ⇒ ?'a) ⟹ ((⨆i::nat. ?S i) ⊑ (?x::?'a)) = (∀i::nat. ?S i ⊑ ?x)›*)) moreover from D (*‹ValD_copy_lub ⊑ fst (fix⋅Continuations.ValD_copy_rec)›*) have "cfun_map⋅ValD_copy_lub⋅ValD_copy_lub ⊑ snd (fix⋅ValD_copy_rec)" apply (subst fix_eq (*‹fix⋅(?F::?'a::pcpo → ?'a::pcpo) = ?F⋅(fix⋅?F)›*)) (*goal: ‹cfun_map⋅ValD_copy_lub⋅ValD_copy_lub ⊑ snd (fix⋅Continuations.ValD_copy_rec)›*) by (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) ultimately show "?rhs ⊑ ?lhs" by (simp add: prod_belowI (*‹⟦fst ?p ⊑ fst ?q; snd ?p ⊑ snd ?q⟧ ⟹ ?p ⊑ ?q›*)) qed lemma fix_ValD_copy_rec_ID: "fix⋅ValD_copy_rec = (ID, ID)" using ValD_copy_rec_ValD_copy_lub (*‹fix⋅Continuations.ValD_copy_rec = (ValD_copy_lub, cfun_map⋅ValD_copy_lub⋅ValD_copy_lub)›*) ValD_copy_lub_ID (*‹ValD_copy_lub = ID›*) cfun_map_ID (*‹cfun_map⋅ID⋅ID = ID›*) by simp fixrec ValK_copy_rec :: "(('o ValKM → 'o ValKM) × (('o ValKM → 'o ValKM) → ('o ValKM → 'o ValKM))) → ('o ValKM → 'o ValKM) × (('o ValKM → 'o ValKM) → ('o ValKM → 'o ValKM))" where "ValK_copy_rec⋅r = (Λ vm. KM_map⋅(Λ v. case v of ValKF⋅f ⇒ ValKF⋅(snd r⋅f) | ValKTT ⇒ ValKTT | ValKFF ⇒ ValKFF | ValKN⋅a ⇒ ValKN⋅a)⋅vm, Λ f. cfun_map⋅(strictify⋅(fst r))⋅(strictify⋅(fst r))⋅f)" abbreviation ValK_copy_eta where "ValK_copy_eta i ≡ fst (iterate i⋅ValK_copy_rec⋅⊥)" abbreviation ValK_copy_theta where "ValK_copy_theta i ≡ snd (iterate i⋅ValK_copy_rec⋅⊥)" lemma ValK_copy_strict [intro, simp]: "ValK_copy_eta n⋅⊥ = (⊥ :: 'o ValKM)" "ValK_copy_theta n⋅⊥ = (⊥ :: 'o ValKM → 'o ValKM)" apply (induct n) (*goals: 1. ‹ValK_copy_eta 0⋅⊥ = ⊥› 2. ‹ValK_copy_theta 0⋅⊥ = ⊥› 3. ‹⋀n. ⟦ValK_copy_eta n⋅⊥ = ⊥; ValK_copy_theta n⋅⊥ = ⊥⟧ ⟹ ValK_copy_eta (Suc n)⋅⊥ = ⊥› 4. ‹⋀n. ⟦ValK_copy_eta n⋅⊥ = ⊥; ValK_copy_theta n⋅⊥ = ⊥⟧ ⟹ ValK_copy_theta (Suc n)⋅⊥ = ⊥› discuss goal 1*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 2*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 3*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ (a::?'b::cpo → ?'a::cpo) (b::?'c::cpo → ?'d::cpo) (f::?'a::cpo → ?'c::cpo) (x::?'b::cpo). b⋅(f⋅(a⋅x)))›*)) (*discuss goal 4*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*proven 4 subgoals*) . lemma ValK_copy_fix_strict [simp]: "fst (fix⋅ValK_copy_rec)⋅⊥ = ⊥" "snd (fix⋅ValK_copy_rec)⋅⊥ = ⊥" (*goals: 1. ‹fst (fix⋅ValK_copy_rec)⋅⊥ = ⊥› 2. ‹snd (fix⋅ValK_copy_rec)⋅⊥ = ⊥› discuss goal 1*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*top goal: ‹fst (fix⋅ValK_copy_rec)⋅⊥ = ⊥› and 1 goal remains*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 2*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹snd (fix⋅ValK_copy_rec)⋅⊥ = ⊥›*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*proven 2 subgoals*) . lemma ValK_copy_rec_ValK_copy: "fix⋅ValK_copy_rec = (KM_map⋅(ValK_copy :: 'o ValK → 'o ValK), cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy))" (is "?lhs = ?rhs") proof (rule below_antisym (*‹⟦?x ⊑ ?y; ?y ⊑ ?x⟧ ⟹ ?x = ?y›*)) (*goals: 1. ‹fix⋅ValK_copy_rec ⊑ (KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy))› 2. ‹(KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy)) ⊑ fix⋅ValK_copy_rec›*) show "?lhs ⊑ ?rhs" apply (rule fix_least (*‹(?F::?'a → ?'a)⋅(?x::?'a) = ?x ⟹ fix⋅?F ⊑ ?x›*)) (*goal: ‹fix⋅ValK_copy_rec ⊑ (KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy))›*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) ID_def (*‹ID = (Λ x. x)›*)) (*goal: ‹ValK_copy_rec⋅(KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy)) = (KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy))›*) apply (intro cfun_eqI (*‹(⋀x. ?f⋅x = ?g⋅x) ⟹ ?f = ?g›*)) (*goal: ‹KM_map⋅(ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(Λ (x::('o ValK → 'o) → 'o). KM_map⋅ValK_copy⋅(f⋅(KM_map⋅ValK_copy⋅x))))⋅ValKTT⋅ValKFF⋅ValKN) = KM_map⋅ValK_copy›*) by (simp add: KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) ValK_copy_fix (*‹ValK_copy = ID›*) eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) next (*goal: ‹(KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy)) ⊑ fix⋅ValK_copy_rec›*) { fix i have "KM_map⋅(ValK_copy_i i :: 'o ValK → 'o ValK) ⊑ fst (fix⋅ValK_copy_rec)" and "(ValK_copy_i i :: 'o ValK → 'o ValK) ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN" proof (induct i) (*goals: 1. ‹KM_map⋅(ValK_copy_i 0) ⊑ fst (fix⋅ValK_copy_rec)› 2. ‹ValK_copy_i 0 ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN› 3. ‹⋀i. ⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ KM_map⋅(ValK_copy_i (Suc i)) ⊑ fst (fix⋅ValK_copy_rec)› 4. ‹⋀i. ⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_copy_i (Suc i) ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) case 0 (*no hyothesis introduced yet*) { case 1 (*no hyothesis introduced yet*) show "?case" (*goal: ‹KM_map⋅(ValK_copy_i (0::nat)) ⊑ fst (fix⋅ValK_copy_rec)›*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹KM_map⋅(ValK_copy_i 0) ⊑ fst (fix⋅ValK_copy_rec)›*) by (auto iff: cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*) intro!: monofun_cfun_arg (*‹?x ⊑ ?y ⟹ ?f⋅?x ⊑ ?f⋅?y›*) simp: KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) } { case 2 (*no hyothesis introduced yet*) show "?case" (*goal: ‹ValK_copy_i 0 ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) by simp } next (*goals: 1. ‹⋀i. ⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ KM_map⋅(ValK_copy_i (Suc i)) ⊑ fst (fix⋅ValK_copy_rec)› 2. ‹⋀i. ⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_copy_i (Suc i) ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) case (Suc i) (*‹KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec)› ‹ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) { case 1 (*no hyothesis introduced yet*) from Suc (*‹KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec)› ‹ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) show "?case" (*goal: ‹KM_map⋅(ValK_copy_i (Suc (i::nat))) ⊑ fst (fix⋅ValK_copy_rec)›*) apply - (*goal: ‹KM_map⋅(ValK_copy_i (Suc (i::nat))) ⊑ fst (fix⋅ValK_copy_rec)›*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ KM_map⋅(ValK_copy_i (Suc i)) ⊑ fst (fix⋅ValK_copy_rec)›*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹⟦KM_map⋅(ValK_copy_i (i::nat)) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ KM_map⋅(ValK_copy_i (Suc i)) ⊑ fst (ValK_copy_rec⋅(fix⋅ValK_copy_rec))›*) apply (simp add: eta_cfun (*‹(Λ (x::?'a). (?f::?'a → ?'b)⋅x) = ?f›*) strictify_cancel (*‹(?f::?'b → ?'a)⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) cfcomp1 (*‹(?f::?'c → ?'b) oo (?g::?'a → ?'c) = (Λ (x::?'a). ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ (a::?'b → ?'a) (b::?'c → ?'d) (f::?'a → ?'c) (x::?'b). b⋅(f⋅(a⋅x)))›*) KM_map_def (*‹KM_map ≡ Λ (f::?'o ValK → ?'o ValK). cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*)) (*goal: ‹⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ KM_map⋅(ValK_copy_i (Suc i)) ⊑ fst (ValK_copy_rec⋅(ValK_copy_rec⋅(fix⋅ValK_copy_rec)))›*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*goal: ‹⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ f x. f⋅(Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xa))) ⊑ (Λ vm x. vm⋅(Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xa)))›*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*)) (*goal: ‹⋀x xa. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ f x. f⋅(Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xa)))⋅x⋅xa ⊑ (Λ vm x. vm⋅(Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xa)))⋅x⋅xa›*) apply (intro monofun_cfun_arg (*‹?x ⊑ ?y ⟹ ?f⋅?x ⊑ ?f⋅?y›*)) (*goal: ‹⋀x xa. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ x⋅(Λ x. xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅x)) ⊑ x⋅(Λ x. xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅x))›*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*goal: ‹⋀x xa. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅x)) ⊑ (Λ x. xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅x))›*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*)) (*goal: ‹⋀x xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅x))⋅xb ⊑ (Λ x. xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅x))⋅xb›*) apply (intro monofun_cfun_arg (*‹?x ⊑ ?y ⟹ ?f⋅?x ⊑ ?f⋅?y›*)) (*goal: ‹⋀xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xb) ⊑ xa⋅(ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xb)›*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*goal: ‹⋀xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_case⋅(Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xb ⊑ ValK_case⋅(Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅ValKTT⋅ValKFF⋅ValKN⋅xb›*) apply (intro monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*goals: 1. ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_case ⊑ ValK_case› 2. ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))) ⊑ (Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))› 3. ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValKTT ⊑ ValKTT› 4. ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValKFF ⊑ ValKFF› 5. ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValKN ⊑ ValKN› 6. ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ xb ⊑ xb› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*top goal: ‹⋀xb::'o::domain ValK. ⟦(Λ (f::('o::domain ValK → 'o::domain) → 'o::domain) (x::'o::domain ValK → 'o::domain). f⋅(Λ (xa::'o::domain ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(Λ (x::('o::domain ValK → 'o::domain) → 'o::domain) (xa::'o::domain ValK → 'o::domain). f⋅(Λ (xa::'o::domain ValK → 'o::domain). x⋅(Λ (x::'o::domain ValK). xa⋅(ValK_copy_i i⋅x)))⋅(Λ (x::'o::domain ValK). xa⋅(ValK_copy_i i⋅x)))) ⊑ (Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(Λ (x::('o::domain ValK → 'o::domain) → 'o::domain). fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))› and 4 goals remain*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*top goal: ‹⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))) ⊑ (Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))› and 4 goals remain*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*top goal: ‹⋀x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ f. ValKF⋅(Λ x xa. f⋅(Λ xa. x⋅(Λ x. xa⋅(ValK_copy_i i⋅x)))⋅(Λ x. xa⋅(ValK_copy_i i⋅x))))⋅x ⊑ (Λ f. ValKF⋅(Λ x. fst (fix⋅ValK_copy_rec)⋅(f⋅(fst (fix⋅ValK_copy_rec)⋅x))))⋅x› and 4 goals remain*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*top goal: ‹⋀x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ xa xb. x⋅(Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa)))⋅(Λ x. xb⋅(ValK_copy_i i⋅x))) ⊑ (Λ xa. fst (fix⋅ValK_copy_rec)⋅(x⋅(fst (fix⋅ValK_copy_rec)⋅xa)))› and 4 goals remain*) apply (subst fix_eq (*‹fix⋅(?F::?'a → ?'a) = ?F⋅(fix⋅?F)›*)) (*top goal: ‹⋀x xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ xa xb. x⋅(Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa)))⋅(Λ x. xb⋅(ValK_copy_i i⋅x)))⋅xa⋅xb ⊑ (Λ xa. fst (fix⋅ValK_copy_rec)⋅(x⋅(fst (fix⋅ValK_copy_rec)⋅xa)))⋅xa⋅xb› and 4 goals remain*) apply (simp add: eta_cfun (*‹(Λ (x::?'a). (?f::?'a → ?'b)⋅x) = ?f›*) strictify_cancel (*‹(?f::?'b → ?'a)⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) monofun_cfun (*‹⟦(?f::?'a → ?'b) ⊑ (?g::?'a → ?'b); (?x::?'a) ⊑ (?y::?'a)⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) cfcomp1 (*‹(?f::?'c → ?'b) oo (?g::?'a → ?'c) = (Λ (x::?'a). ?f⋅(?g⋅x))›*) KM_map_def (*‹KM_map ≡ Λ (f::?'o ValK → ?'o ValK). cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ (a::?'b → ?'a) (b::?'c → ?'d) (f::?'a → ?'c) (x::?'b). b⋅(f⋅(a⋅x)))›*)) (*top goal: ‹⋀x xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ xa xb. x⋅(Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa)))⋅(Λ x. xb⋅(ValK_copy_i i⋅x)))⋅xa⋅xb ⊑ (Λ xa. fst (ValK_copy_rec⋅(fix⋅ValK_copy_rec))⋅(x⋅(fst (fix⋅ValK_copy_rec)⋅xa)))⋅xa⋅xb› and 4 goals remain*) apply (intro monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*goals: 1. ‹⋀(x::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) (xa::('o ValK → 'o) → 'o) xb::'o ValK → 'o. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ x ⊑ x› 2. ‹⋀(x::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) (xa::('o ValK → 'o) → 'o) xb::'o ValK → 'o. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ (x::'o ValK → 'o). xa⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec)⋅xa› 3. ‹⋀(x::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) (xa::('o ValK → 'o) → 'o) xb::'o ValK → 'o. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ (x::'o ValK). xb⋅(ValK_copy_i i⋅x)) ⊑ (Λ (x::'o ValK). xb⋅(ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅x))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*top goal: ‹⋀x xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec)⋅xa› and 5 goals remain*) apply (subst fix_eq (*‹fix⋅(?F::?'a::pcpo → ?'a::pcpo) = ?F⋅(fix⋅?F)›*)) (*top goal: ‹⋀xa. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec)⋅xa› and 5 goals remain*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*top goal: ‹⋀xa. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (ValK_copy_rec⋅(fix⋅ValK_copy_rec))⋅xa› and 5 goals remain*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*top goal: ‹⋀xa x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xa⋅(Λ xa. x⋅(ValK_copy_i i⋅xa)))⋅x ⊑ fst (ValK_copy_rec⋅(fix⋅ValK_copy_rec))⋅xa⋅x› and 5 goals remain*) apply (intro monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*goals: 1. ‹⋀xa x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ xa ⊑ xa› 2. ‹⋀xa x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ xa. x⋅(ValK_copy_i i⋅xa)) ⊑ (Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅xa))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*top goal: ‹⋀xa x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ xa. x⋅(ValK_copy_i i⋅xa)) ⊑ (Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅xa))› and 5 goals remain*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*top goal: ‹⋀x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ xa. x⋅(ValK_copy_i i⋅xa)) ⊑ (Λ xa. x⋅(ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅xa))› and 5 goals remain*) apply simp (*top goal: ‹⋀(x::'o ValK → 'o) xa::'o ValK. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ (xa::'o ValK). x⋅(ValK_copy_i i⋅xa))⋅xa ⊑ (Λ (xa::'o ValK). x⋅(ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅xa))⋅xa› and 5 goals remain*) apply (intro monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*goals: 1. ‹⋀(x::'o ValK → 'o) xa::'o ValK. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ x ⊑ x› 2. ‹⋀(x::'o ValK → 'o) xa::'o ValK. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN› 3. ‹⋀(x::'o ValK → 'o) xa::'o ValK. ⟦(Λ (f::('o ValK → 'o) → 'o) (x::'o ValK → 'o). f⋅(Λ (xa::'o ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ xa ⊑ xa› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 2 subgoals*) (*discuss goal 3*) apply simp (*top goal: ‹⋀x xa xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xb⋅(ValK_copy_i i⋅x)) ⊑ (Λ x. xb⋅(ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅x))› and 4 goals remain*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*top goal: ‹⋀xb. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xb⋅(ValK_copy_i i⋅x)) ⊑ (Λ x. xb⋅(ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅x))› and 4 goals remain*) apply simp (*top goal: ‹⋀xb x. ⟦(Λ f x. f⋅(Λ xa. x⋅(ValK_copy_i i⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ (Λ x. xb⋅(ValK_copy_i i⋅x))⋅x ⊑ (Λ x. xb⋅(ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⋅x))⋅x› and 4 goals remain*) apply (intro monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*goals: 1. ‹⋀(xb::'o::domain ValK → 'o::domain) x::'o::domain ValK. ⟦(Λ (f::('o::domain ValK → 'o::domain) → 'o::domain) (x::'o::domain ValK → 'o::domain). f⋅(Λ (xa::'o::domain ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ xb ⊑ xb› 2. ‹⋀(xb::'o::domain ValK → 'o::domain) x::'o::domain ValK. ⟦(Λ (f::('o::domain ValK → 'o::domain) → 'o::domain) (x::'o::domain ValK → 'o::domain). f⋅(Λ (xa::'o::domain ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN› 3. ‹⋀(xb::'o::domain ValK → 'o::domain) x::'o::domain ValK. ⟦(Λ (f::('o::domain ValK → 'o::domain) → 'o::domain) (x::'o::domain ValK → 'o::domain). f⋅(Λ (xa::'o::domain ValK). x⋅(ValK_copy_i (i::nat)⋅xa))) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ x ⊑ x› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) (*proven 3 subgoals*) (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*proven 6 subgoals*) . } { case 2 (*no hyothesis introduced yet*) from Suc (*‹KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec)› ‹ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) show "?case" (*goal: ‹ValK_copy_i (Suc i) ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) apply - (*goal: ‹ValK_copy_i (Suc i) ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹⟦KM_map⋅(ValK_copy_i i) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_copy_i (Suc i) ⊑ ValK_case⋅(Λ f. ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) apply (subst fix_eq (*‹fix⋅?F = ?F⋅(fix⋅?F)›*)) (*goal: ‹⟦KM_map⋅(ValK_copy_i (i::nat)) ⊑ fst (fix⋅ValK_copy_rec); ValK_copy_i i ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (fix⋅ValK_copy_rec)⋅f))⋅ValKTT⋅ValKFF⋅ValKN⟧ ⟹ ValK_copy_i (Suc i) ⊑ ValK_case⋅(Λ (f::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o). ValKF⋅(snd (ValK_copy_rec⋅(fix⋅ValK_copy_rec))⋅f))⋅ValKTT⋅ValKFF⋅ValKN›*) by (auto simp: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*) intro!: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) } qed } hence "(⨆i. KM_map⋅(ValK_copy_i i :: 'o ValK → 'o ValK)) ⊑ fst (fix⋅ValK_copy_rec)" by (simp add: lub_below_iff (*‹chain ?S ⟹ ((⨆i. ?S i) ⊑ ?x) = (∀i. ?S i ⊑ ?x)›*)) hence D: "KM_map⋅(ValK_copy :: 'o ValK → 'o ValK) ⊑ fst (fix⋅ValK_copy_rec)" by (simp add: contlub_cfun_arg[symmetric] (*‹chain ?Y ⟹ (⨆i. ?f⋅(?Y i)) = ?f⋅(⨆i. ?Y i)›*)) from D (*‹KM_map⋅ValK_copy ⊑ fst (fix⋅ValK_copy_rec)›*) have E: "cfun_map⋅(KM_map⋅(ValK_copy :: 'o ValK → 'o ValK))⋅(KM_map⋅ValK_copy) ⊑ snd (fix⋅ValK_copy_rec)" apply (subst fix_eq (*‹fix⋅(?F::?'a → ?'a) = ?F⋅(fix⋅?F)›*)) (*goal: ‹cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy) ⊑ snd (fix⋅ValK_copy_rec)›*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*)) (*goal: ‹KM_map⋅ValK_copy ⊑ fst (fix⋅ValK_copy_rec) ⟹ cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy) ⊑ snd (ValK_copy_rec⋅(fix⋅ValK_copy_rec))›*) apply (intro monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) (*goals: 1. ‹cfun_map⋅(cfun_map⋅ValK_copy⋅ID)⋅ID ⊑ fst (fix⋅ValK_copy_rec) ⟹ cfun_map ⊑ cfun_map› 2. ‹cfun_map⋅(cfun_map⋅ValK_copy⋅ID)⋅ID ⊑ fst (fix⋅ValK_copy_rec) ⟹ cfun_map⋅(cfun_map⋅ValK_copy⋅ID)⋅ID ⊑ fst (fix⋅ValK_copy_rec)› 3. ‹cfun_map⋅(cfun_map⋅ValK_copy⋅ID)⋅ID ⊑ fst (fix⋅ValK_copy_rec) ⟹ cfun_map⋅(cfun_map⋅ValK_copy⋅ID)⋅ID ⊑ fst (fix⋅ValK_copy_rec)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*proven 3 subgoals*) . show "?rhs ⊑ ?lhs" by (simp add: prod_belowI (*‹⟦fst ?p ⊑ fst ?q; snd ?p ⊑ snd ?q⟧ ⟹ ?p ⊑ ?q›*) D (*‹KM_map⋅ValK_copy ⊑ fst (fix⋅ValK_copy_rec)›*) E (*‹cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy) ⊑ snd (fix⋅ValK_copy_rec)›*)) qed lemma fix_ValK_copy_rec_ID: "fix⋅ValK_copy_rec = (ID, ID)" by (simp add: ValK_copy_rec_ValK_copy (*‹fix⋅ValK_copy_rec = (KM_map⋅ValK_copy, cfun_map⋅(KM_map⋅ValK_copy)⋅(KM_map⋅ValK_copy))›*) ValK_copy_fix (*‹ValK_copy = ID›*) cfun_map_ID (*‹cfun_map⋅ID⋅ID = ID›*)) lemma (in at_least_two_elements) min_inv_lr: assumes "fst ea⋅⊥ = ⊥" assumes "fst eb⋅⊥ = ⊥" assumes "eRSP ea eb R S" shows "eRSP (ValD_copy_rec⋅ea) (ValK_copy_rec⋅eb) (dual ((lr :: 'o lflf) (dual S, undual R))) (lr (R, S))" using assms (*‹fst ea⋅⊥ = ⊥› ‹fst (eb::((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) × (((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) → (('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o))⋅⊥ = ⊥› ‹eRSP ea eb R S›*) some_non_bottom_element (*‹some_non_bottom_element ≠ ⊥›*) apply (simp add: split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) (*goal: ‹eRSP (Continuations.ValD_copy_rec⋅ea) (ValK_copy_rec⋅eb) (dual (lr (dual S, undual R))) (lr (R, S))›*) apply (auto simp: split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*) lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*) lr_theta_rep_def (*‹lr_theta_rep ≡ λ(rm, rp). {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)}›*) KM_map_def (*‹KM_map ≡ Λ f. cfun_map⋅(cfun_map⋅f⋅ID)⋅ID›*) cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) unitK_def (*‹unitK ≡ Λ a c. c⋅a›*)) (*goal: ‹⟦fst ea⋅⊥ = ⊥; fst eb⋅⊥ = ⊥; (∀x∈unlr (fst (undual R)). (fst ea⋅(fst x), fst eb⋅(snd x)) ∈ unlr (fst S)) ∧ (∀x∈unlr (snd (undual R)). (snd ea⋅(fst x), snd eb⋅(snd x)) ∈ unlr (snd S)); some_non_bottom_element ≠ ⊥⟧ ⟹ (∀x∈fst (lr_rep (dual S, undual R)). (ValD_case⋅(Λ f. ValF⋅(snd ea⋅f))⋅ValTT⋅ValFF⋅(Abs_cfun (Rep_cfun ValN))⋅(fst x), KM_map⋅(Abs_cfun (Rep_cfun (ValK_case⋅(Λ f. ValKF⋅(snd eb⋅f))⋅ValKTT⋅ValKFF⋅(Abs_cfun (Rep_cfun ValKN)))))⋅(snd x)) ∈ fst (lr_rep (R, S))) ∧ (∀x∈snd (lr_rep (dual S, undual R)). (cfun_map⋅(strictify⋅(fst ea))⋅(strictify⋅(fst ea))⋅(fst x), cfun_map⋅(strictify⋅(fst eb))⋅(strictify⋅(fst eb))⋅(snd x)) ∈ snd (lr_rep (R, S)))›*) by (force simp: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) strictify_cancel (*‹?f⋅⊥ = ⊥ ⟹ strictify⋅?f = ?f›*) unitK_def (*‹unitK ≡ Λ a c. c⋅a›*)) (*>*) sublocale at_least_two_elements < F: DomSolP lr ValD_copy_rec ValK_copy_rec apply standard (*goals: 1. ‹mono lr› 2. ‹fix⋅Continuations.ValD_copy_rec = (ID, ID)› 3. ‹fix⋅ValK_copy_rec = (ID, ID)› 4. ‹⋀r. fst (Continuations.ValD_copy_rec⋅r)⋅⊥ = ⊥› 5. ‹⋀r. snd (Continuations.ValD_copy_rec⋅r)⋅⊥ = ⊥› 6. ‹⋀r. fst (ValK_copy_rec⋅r)⋅⊥ = ⊥› 7. ‹⋀r. snd (ValK_copy_rec⋅r)⋅⊥ = ⊥› 8. ‹⋀R ea eb S. ⟦eRSP ea eb R S; fst ea⋅⊥ = ⊥; snd ea⋅⊥ = ⊥; fst eb⋅⊥ = ⊥; snd ea⋅⊥ = ⊥⟧ ⟹ eRSP (Continuations.ValD_copy_rec⋅ea) (ValK_copy_rec⋅eb) (dual (lr (dual S, undual R))) (lr (R, S))› discuss goal 1*) apply (rule mono_lr (*‹mono lr›*)) (*discuss goal 2*) apply (rule fix_ValD_copy_rec_ID (*‹fix⋅Continuations.ValD_copy_rec = (ID, ID)›*)) (*discuss goal 3*) apply (rule fix_ValK_copy_rec_ID (*‹fix⋅ValK_copy_rec = (ID, ID)›*)) (*discuss goal 4*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 5*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 6*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*)) (*discuss goal 7*) apply (simp add: cfun_map_def (*‹cfun_map = (Λ (a::?'b → ?'a) (b::?'c → ?'d) (f::?'a → ?'c) (x::?'b). b⋅(f⋅(a⋅x)))›*)) (*discuss goal 8*) apply (erule (2) min_inv_lr (*‹⟦fst (?ea::(ValD → ValD) × ((ValD → ValD) → ValD → ValD))⋅⊥ = ⊥; fst (?eb::((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) × (((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) → (('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o))⋅⊥ = ⊥; eRSP ?ea ?eb (?R::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual) (?S::(ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS)⟧ ⟹ eRSP (Continuations.ValD_copy_rec⋅?ea) (ValK_copy_rec⋅?eb) (dual (lr (dual ?S, undual ?R))) (lr (?R, ?S))›*)) (*proven 8 subgoals*) . subsection‹A retraction between the two definitions› text‹ We can use the relation to establish a strong connection between the direct and continuation semantics. All results depend on the observation type being rich enough. › context at_least_two_elements begin abbreviation mrel ("η: _ ↦ _" [50, 51] 50) where "η: x ↦ x' ≡ (x, x') ∈ unlr (fst F.delta)" abbreviation vrel ("θ: _ ↦ _" [50, 51] 50) where "θ: y ↦ y' ≡ (y, y') ∈ unlr (snd F.delta)" (*<*) lemma F_bottom_triv [intro, simp]: "η: ⊥ ↦ ⊥" "θ: ⊥ ↦ ⊥" (*goals: 1. ‹η: ⊥ ↦ ⊥› 2. ‹θ: ⊥ ↦ ⊥› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . lemma etaI [intro, simp]: "η: ValTT ↦ unitK⋅ValKTT" "η: ValFF ↦ unitK⋅ValKFF" "η: ValN⋅n ↦ unitK⋅(ValKN⋅n)" (*goals: 1. ‹η: ValTT ↦ unitK⋅ValKTT› 2. ‹η: ValFF ↦ unitK⋅ValKFF› 3. ‹η: ValN⋅n ↦ unitK⋅(ValKN⋅n)› discuss goal 1*) apply (subst F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*top goal: ‹η: ValTT ↦ unitK⋅ValKTT› and 2 goals remain*) apply simp (*top goal: ‹(ValTT, unitK⋅ValKTT) ∈ unlr (fst (lr (dual F.delta, F.delta)))› and 2 goals remain*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*discuss goal 2*) apply (subst F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*top goal: ‹η: ValFF ↦ unitK⋅ValKFF› and 1 goal remains*) apply simp (*top goal: ‹(ValFF, unitK⋅ValKFF) ∈ unlr (fst (lr (dual F.delta, F.delta)))› and 1 goal remains*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*discuss goal 3*) apply (subst F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*goal: ‹η: ValN⋅n ↦ unitK⋅(ValKN⋅n)›*) apply simp (*goal: ‹(ValN⋅n, unitK⋅(ValKN⋅n)) ∈ unlr (fst (lr (dual F.delta, F.delta)))›*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*proven 3 subgoals*) . lemma eta_F: "θ: f ↦ f' ⟹ η: ValF⋅f ↦ unitK⋅(ValKF⋅f')" apply (subst F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*goal: ‹θ: f ↦ f' ⟹ η: ValF⋅f ↦ unitK⋅(ValKF⋅f')›*) apply simp (*goal: ‹θ: f ↦ f' ⟹ (ValF⋅f, unitK⋅(ValKF⋅f')) ∈ unlr (fst (lr (dual F.delta, F.delta)))›*) apply (subst lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*)) (*goal: ‹θ: (f::ValD → ValD) ↦ (f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain) ⟹ (ValF⋅f, unitK⋅(ValKF⋅f')) ∈ fst (lr_rep (dual F.delta, F.delta))›*) by (fastforce simp: lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) lemma theta_F: "(⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ θ: f ↦ f'" apply (subst F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*goal: ‹(⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ θ: f ↦ f'›*) apply simp (*goal: ‹(⋀(x::ValD) x'::('o ValK → 'o) → 'o. η: x ↦ x' ⟹ η: (f::ValD → ValD)⋅x ↦ (f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)⋅x') ⟹ (f, f') ∈ unlr (snd (lr (dual F.delta, F.delta)))›*) apply (subst lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*)) (*goal: ‹(⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ (f, f') ∈ snd (lr_rep (dual F.delta, F.delta))›*) by (simp add: lr_theta_rep_def (*‹lr_theta_rep ≡ λ(rm, rp). {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)}›*) split_def (*‹case_prod = (λc p. c (fst p) (snd p))›*)) lemma eta_induct[case_names bottom N F, consumes 1]: "⟦ η: x ↦ x'; ⟦ x = ⊥; x' = ⊥ ⟧ ⟹ P x x'; ⋀n. ⟦ x = ValTT; x' = unitK⋅ValKTT ⟧ ⟹ P x x'; ⋀n. ⟦ x = ValFF; x' = unitK⋅ValKFF ⟧ ⟹ P x x'; ⋀n. ⟦ x = ValN⋅n; x' = unitK⋅(ValKN⋅n) ⟧ ⟹ P x x'; ⋀f f'. ⟦ x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f' ⟧ ⟹ P x x' ⟧ ⟹ P x x'" apply (cases x) (*goals: 1. ‹⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ⊥⟧ ⟹ P x x'› 2. ‹⋀cfun. ⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValF⋅cfun⟧ ⟹ P x x'› 3. ‹⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValTT⟧ ⟹ P x x'› 4. ‹⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValFF⟧ ⟹ P x x'› 5. ‹⋀nat. ⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValN⋅nat⟧ ⟹ P x x'› discuss goal 1*) apply (subst (asm) F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*top goal: ‹⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ⊥⟧ ⟹ P x x'› and 4 goals remain*) apply simp (*top goal: ‹⟦(x, x') ∈ unlr (fst (lr (dual F.delta, F.delta))); ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ⊥⟧ ⟹ P x x'› and 4 goals remain*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*discuss goal 2*) apply simp (*top goal: ‹⋀cfun::ValD → ValD. ⟦η: (x::ValD) ↦ (x'::('o::domain ValK → 'o::domain) → 'o::domain); ⟦x = ⊥; x' = ⊥⟧ ⟹ (P::ValD ⇒ (('o::domain ValK → 'o::domain) → 'o::domain) ⇒ bool) x x'; ⋀n::'a::type. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n::'b::type. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n::nat. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀(f::ValD → ValD) f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValF⋅cfun⟧ ⟹ P x x'› and 3 goals remain*) apply (subst (asm) F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*top goal: ‹⋀cfun::ValD → ValD. ⟦η: ValF⋅cfun ↦ (x'::('o ValK → 'o) → 'o); ⋀(f::ValD → ValD) f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o. ⟦cfun = f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ (P::ValD ⇒ (('o ValK → 'o) → 'o) ⇒ bool) (ValF⋅f) (unitK⋅(ValKF⋅f')); (x::ValD) = ValF⋅cfun⟧ ⟹ P (ValF⋅cfun) x'› and 3 goals remain*) apply simp (*top goal: ‹⋀cfun. ⟦(ValF⋅cfun, x') ∈ unlr (fst (lr (dual F.delta, F.delta))); ⋀f f'. ⟦cfun = f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P (ValF⋅f) (unitK⋅(ValKF⋅f')); x = ValF⋅cfun⟧ ⟹ P (ValF⋅cfun) x'› and 3 goals remain*) apply (subst (asm) lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*)) (*top goal: ‹⋀cfun::ValD → ValD. ⟦(ValF⋅cfun, x'::('o ValK → 'o) → 'o) ∈ fst (lr_rep (dual F.delta, F.delta)); ⋀(f::ValD → ValD) f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o. ⟦cfun = f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ (P::ValD ⇒ (('o ValK → 'o) → 'o) ⇒ bool) (ValF⋅f) (unitK⋅(ValKF⋅f')); (x::ValD) = ValF⋅cfun⟧ ⟹ P (ValF⋅cfun) x'› and 3 goals remain*) apply (subst (asm) lr_eta_rep_def (*‹lr_eta_rep ≡ λr::?'a × ?'b × ((ValD → ValD) × (((?'c ValK → ?'c) → ?'c) → (?'c ValK → ?'c) → ?'c)) admS. {(e::ValD, e'::(?'c ValK → ?'c) → ?'c). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n::nat. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm::?'a, rp::?'b × ((ValD → ValD) × (((?'c ValK → ?'c) → ?'c) → (?'c ValK → ?'c) → ?'c)) admS) ⇒ {(e::ValD, e'::(?'c ValK → ?'c) → ?'c). e = ⊥ ∧ e' = ⊥ ∨ (∃(f::ValD → ValD) f'::((?'c ValK → ?'c) → ?'c) → (?'c ValK → ?'c) → ?'c. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*top goal: ‹⋀cfun. ⟦(ValF⋅cfun, x') ∈ fst (lr_eta_rep (dual F.delta, F.delta), lr_theta_rep (dual F.delta, F.delta)); ⋀f f'. ⟦cfun = f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P (ValF⋅f) (unitK⋅(ValKF⋅f')); x = ValF⋅cfun⟧ ⟹ P (ValF⋅cfun) x'› and 3 goals remain*) apply clarsimp (*discuss goal 3*) apply (subst (asm) F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*top goal: ‹⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValTT⟧ ⟹ P x x'› and 2 goals remain*) apply simp (*top goal: ‹⟦(x, x') ∈ unlr (fst (lr (dual F.delta, F.delta))); ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValTT⟧ ⟹ P x x'› and 2 goals remain*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*discuss goal 4*) apply (subst (asm) F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*top goal: ‹⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValFF⟧ ⟹ P x x'› and 1 goal remains*) apply simp (*top goal: ‹⟦(x, x') ∈ unlr (fst (lr (dual F.delta, F.delta))); ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValFF⟧ ⟹ P x x'› and 1 goal remains*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr. {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm, rp) ⇒ {(e, e'). e = ⊥ ∧ e' = ⊥ ∨ (∃f f'. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*discuss goal 5*) apply (subst (asm) F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*goal: ‹⋀nat. ⟦η: x ↦ x'; ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValN⋅nat⟧ ⟹ P x x'›*) apply simp (*goal: ‹⋀nat. ⟦(x, x') ∈ unlr (fst (lr (dual F.delta, F.delta))); ⟦x = ⊥; x' = ⊥⟧ ⟹ P x x'; ⋀n. ⟦x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ P x x'; ⋀n. ⟦x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ P x x'; ⋀n. ⟦x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ P x x'; ⋀f f'. ⟦x = ValF⋅f; x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ P x x'; x = ValN⋅nat⟧ ⟹ P x x'›*) apply (simp add: lr_rep_def (*‹lr_rep ≡ λr::((ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS) dual × (ValD × (('o ValK → 'o) → 'o)) admS × ((ValD → ValD) × ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)) admS. (lr_eta_rep r, lr_theta_rep r)›*) lr_eta_rep_def (*‹lr_eta_rep ≡ λr::?'a × ?'b × ((ValD → ValD) × (((?'c ValK → ?'c) → ?'c) → (?'c ValK → ?'c) → ?'c)) admS. {(e::ValD, e'::(?'c ValK → ?'c) → ?'c). e = ⊥ ∧ e' = ⊥ ∨ e = ValTT ∧ e' = unitK⋅ValKTT ∨ e = ValFF ∧ e' = unitK⋅ValKFF ∨ (∃n::nat. e = ValN⋅n ∧ e' = unitK⋅(ValKN⋅n))} ∪ (case r of (rm::?'a, rp::?'b × ((ValD → ValD) × (((?'c ValK → ?'c) → ?'c) → (?'c ValK → ?'c) → ?'c)) admS) ⇒ {(e::ValD, e'::(?'c ValK → ?'c) → ?'c). e = ⊥ ∧ e' = ⊥ ∨ (∃(f::ValD → ValD) f'::((?'c ValK → ?'c) → ?'c) → (?'c ValK → ?'c) → ?'c. e = ValF⋅f ∧ e' = unitK⋅(ValKF⋅f') ∧ (f, f') ∈ unlr (snd rp))})›*)) (*proven 5 subgoals*) . lemma theta_induct[case_names F, consumes 1]: "⟦ θ: f ↦ f'; (⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ P f f' ⟧ ⟹ P f f'" apply (subst (asm) F.delta_sol (*‹F.delta = lr (dual F.delta, F.delta)›*)) (*goal: ‹⟦θ: f ↦ f'; (⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ P f f'⟧ ⟹ P f f'›*) apply simp (*goal: ‹⟦(f, f') ∈ unlr (snd (lr (dual F.delta, F.delta))); (⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ P f f'⟧ ⟹ P f f'›*) apply (subst (asm) lr_rep_def (*‹lr_rep ≡ λr. (lr_eta_rep r, lr_theta_rep r)›*)) (*goal: ‹⟦(f::ValD → ValD, f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) ∈ snd (lr_rep (dual F.delta, F.delta)); (⋀(x::ValD) x'::('o ValK → 'o) → 'o. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ (P::(ValD → ValD) ⇒ ((('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) ⇒ bool) f f'⟧ ⟹ P f f'›*) apply (subst (asm) lr_theta_rep_def (*‹lr_theta_rep ≡ λ(rm, rp). {(f, f'). ∀(x, x')∈unlr (fst (undual rm)). (f⋅x, f'⋅x') ∈ unlr (fst rp)}›*)) (*goal: ‹⟦(f, f') ∈ snd (lr_eta_rep (dual F.delta, F.delta), lr_theta_rep (dual F.delta, F.delta)); (⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x') ⟹ P f f'⟧ ⟹ P f f'›*) by fastforce (*>*) text‹ Theorem 1 from \<^citet>‹"DBLP:conf/icalp/Reynolds74"›. › lemma AbsV_aux: assumes "η: ValF⋅f ↦ unitK⋅(ValKF⋅f')" shows "η: ValF⋅(strictify⋅f) ↦ unitK⋅(ValKF⋅(Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c)))" (*<*) apply (rule eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*goal: ‹η: ValF⋅(strictify⋅f) ↦ unitK⋅(ValKF⋅(Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c)))›*) apply (rule theta_F (*‹(⋀(x::ValD) x'::('o::domain ValK → 'o::domain) → 'o::domain. η: x ↦ x' ⟹ η: (?f::ValD → ValD)⋅x ↦ (?f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)⋅x') ⟹ θ: ?f ↦ ?f'›*)) (*goal: ‹θ: strictify⋅(f::ValD → ValD) ↦ (Λ (x::('o ValK → 'o) → 'o) (c::'o ValK → 'o). x⋅(Λ (x'::'o ValK). (f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o)⋅(unitK⋅x')⋅c))›*) using assms (*‹η: ValF⋅f ↦ unitK⋅(ValKF⋅f')›*) apply (rule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goals: 1. ‹⋀x x'. ⟦η: x ↦ x'; ValF⋅f = ⊥; unitK⋅(ValKF⋅f') = ⊥⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c))⋅x'› 2. ‹⋀x x' n. ⟦η: x ↦ x'; ValF⋅f = ValTT; unitK⋅(ValKF⋅f') = unitK⋅ValKTT⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c))⋅x'› 3. ‹⋀x x' n. ⟦η: x ↦ x'; ValF⋅f = ValFF; unitK⋅(ValKF⋅f') = unitK⋅ValKFF⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c))⋅x'› 4. ‹⋀x x' n. ⟦η: x ↦ x'; ValF⋅f = ValN⋅n; unitK⋅(ValKF⋅f') = unitK⋅(ValKN⋅n)⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c))⋅x'› 5. ‹⋀x x' fa f'a. ⟦η: x ↦ x'; ValF⋅f = ValF⋅fa; unitK⋅(ValKF⋅f') = unitK⋅(ValKF⋅f'a); θ: fa ↦ f'a⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c))⋅x'› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*goal: ‹⋀x x' fa f'a. ⟦η: x ↦ x'; ValF⋅f = ValF⋅fa; unitK⋅(ValKF⋅f') = unitK⋅(ValKF⋅f'a); θ: fa ↦ f'a⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ x c. x⋅(Λ x'. f'⋅(unitK⋅x')⋅c))⋅x'›*) apply (drule injD[OF below_monic_inj[OF below_monic_unitK]] (*‹unitK⋅?x = unitK⋅?y ⟹ ?x = ?y›*)) (*goal: ‹⋀x x' fa f'a. ⟦η: x ↦ x'; f = fa; unitK⋅(ValKF⋅f') = unitK⋅(ValKF⋅f'a); θ: fa ↦ f'a⟧ ⟹ η: strictify⋅fa⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))›*) apply clarsimp (*goal: ‹⋀(x::ValD) (x'::('o::domain ValK → 'o::domain) → 'o::domain) (fa::ValD → ValD) f'a::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain. ⟦η: x ↦ x'; (f::ValD → ValD) = fa; θ: fa ↦ f'a; ValKF⋅(f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain) = ValKF⋅f'a⟧ ⟹ η: strictify⋅fa⋅x ↦ (Λ (c::'o::domain ValK → 'o::domain). x'⋅(Λ (x'::'o::domain ValK). f'⋅(unitK⋅x')⋅c))›*) apply (erule theta_induct (*‹⟦θ: ?f ↦ ?f'; (⋀x x'. η: x ↦ x' ⟹ η: ?f⋅x ↦ ?f'⋅x') ⟹ ?P ?f ?f'⟧ ⟹ ?P ?f ?f'›*)) (*goal: ‹⋀x x'. ⟦η: x ↦ x'; θ: f ↦ f'⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))›*) apply (erule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goals: 1. ‹⋀x x'. ⟦⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x'; x = ⊥; x' = ⊥⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))› 2. ‹⋀x x' n. ⟦⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x'; x = ValTT; x' = unitK⋅ValKTT⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))› 3. ‹⋀x x' n. ⟦⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x'; x = ValFF; x' = unitK⋅ValKFF⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))› 4. ‹⋀x x' n. ⟦⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x'; x = ValN⋅n; x' = unitK⋅(ValKN⋅n)⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))› 5. ‹⋀x x' fa f'a. ⟦⋀x x'. η: x ↦ x' ⟹ η: f⋅x ↦ f'⋅x'; x = ValF⋅fa; x' = unitK⋅(ValKF⋅f'a); θ: fa ↦ f'a⟧ ⟹ η: strictify⋅f⋅x ↦ (Λ c. x'⋅(Λ x'. f'⋅(unitK⋅x')⋅c))› discuss goal 1*) apply (simp add: eta_cfun (*‹(Λ (x::?'a::cpo). (?f::?'a::cpo → ?'b::cpo)⋅x) = ?f›*) eta_F (*‹θ: (?f::ValD → ValD) ↦ (?f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain) ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*discuss goal 2*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*discuss goal 3*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*discuss goal 4*) apply (simp add: eta_cfun (*‹(Λ (x::?'a::cpo). (?f::?'a::cpo → ?'b::cpo)⋅x) = ?f›*) eta_F (*‹θ: (?f::ValD → ValD) ↦ (?f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain) ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*discuss goal 5*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*) eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*proven 5 subgoals*) (*proven 5 subgoals*) . (*>*) text‹› theorem Theorem1: assumes "∀v. η: ρ⋅v ↦ ρ'⋅v" shows "η: evalD e⋅ρ ↦ evalK e⋅ρ'" (*<*) using assms (*‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) proof (induct e arbitrary: ρ ρ') (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀e1 e2 ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1⟧ρ ↦ evalK e1⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2⟧ρ ↦ evalK e2⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦App e1 e2⟧ρ ↦ evalK (App e1 e2)⋅ρ'› 3. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦AbsN x1a e⟧ρ ↦ evalK (AbsN x1a e)⋅ρ'› 4. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦AbsV x1a e⟧ρ ↦ evalK (AbsV x1a e)⋅ρ'› 5. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 6. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Fix x1a e⟧ρ ↦ evalK (Fix x1a e)⋅ρ'› 7. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 8. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 9. ‹⋀e1 e2 e3 ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1⟧ρ ↦ evalK e1⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2⟧ρ ↦ evalK e2⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3⟧ρ ↦ evalK e3⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Cond e1 e2 e3⟧ρ ↦ evalK (Cond e1 e2 e3)⋅ρ'› 10. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 11. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Succ e⟧ρ ↦ evalK (Succ e)⋅ρ'› 12. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 13. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case App (*‹∀v::nat. η: (?ρ::nat → ValD)⋅v ↦ (?ρ'::nat → ('o::domain ValK → 'o::domain) → 'o::domain)⋅v ⟹ η: ⟦e1_::expr⟧?ρ ↦ evalK e1_⋅?ρ'› ‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e2_⟧?ρ ↦ evalK e2_⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) show "?case" (*goal: ‹η: ⟦App e1_ e2_⟧ρ ↦ evalK (App e1_ e2_)⋅ρ'›*) apply simp (*goal: ‹η: ⟦App e1_ e2_⟧ρ ↦ evalK (App e1_ e2_)⋅ρ'›*) apply (simp add: appKM_def (*‹appKM ≡ Λ fK xK. bindK⋅fK⋅(Λ (ValKF⋅f). f⋅xK)›*) bindK_def (*‹bindK ≡ Λ m k c. m⋅(Λ a. k⋅a⋅c)›*)) (*goal: ‹η: appF⋅(⟦e1_⟧ρ)⋅(⟦e2_⟧ρ) ↦ appKM⋅(evalK e1_⋅ρ')⋅(evalK e2_⋅ρ')›*) using App.hyps(1)[OF App ( 3 )] (*‹η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'›*) apply (rule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goal: ‹η: appF⋅(⟦e1_::expr⟧(ρ::nat → ValD))⋅(⟦e2_::expr⟧ρ) ↦ (Λ (c::'o::domain ValK → 'o::domain). evalK e1_⋅(ρ'::nat → ('o::domain ValK → 'o::domain) → 'o::domain)⋅(Λ (a::'o::domain ValK). (Λ (ValKF⋅(f::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)). f⋅(evalK e2_⋅ρ'))⋅a⋅c))›*) apply simp_all (*top goal: ‹⟦⟦e1_⟧ρ = ⊥; evalK e1_⋅ρ' = ⊥⟧ ⟹ η: appF⋅(⟦e1_⟧ρ)⋅(⟦e2_⟧ρ) ↦ (Λ c. evalK e1_⋅ρ'⋅(Λ a. (Λ (ValKF⋅f). f⋅(evalK e2_⋅ρ'))⋅a⋅c))› and 4 goals remain*) apply (simp add: eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) (*goal: ‹⋀f f'. ⟦⟦e1_⟧ρ = ValF⋅f; evalK e1_⋅ρ' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ η: f⋅(⟦e2_⟧ρ) ↦ (Λ c. f'⋅(evalK e2_⋅ρ')⋅c)›*) apply (erule theta_induct (*‹⟦θ: ?f ↦ ?f'; (⋀x x'. η: x ↦ x' ⟹ η: ?f⋅x ↦ ?f'⋅x') ⟹ ?P ?f ?f'⟧ ⟹ ?P ?f ?f'›*)) (*goal: ‹⋀f f'. ⟦⟦e1_⟧ρ = ValF⋅f; evalK e1_⋅ρ' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ η: f⋅(⟦e2_⟧ρ) ↦ f'⋅(evalK e2_⋅ρ')›*) using App.hyps(2)[OF App ( 3 )] (*‹η: ⟦e2_⟧ρ ↦ evalK e2_⋅ρ'›*) by simp next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦AbsN x1a e⟧ρ ↦ evalK (AbsN x1a e)⋅ρ'› 3. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦AbsV x1a e⟧ρ ↦ evalK (AbsV x1a e)⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 5. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Fix x1a e⟧ρ ↦ evalK (Fix x1a e)⋅ρ'› 6. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 7. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 8. ‹⋀e1 e2 e3 ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1⟧ρ ↦ evalK e1⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2⟧ρ ↦ evalK e2⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3⟧ρ ↦ evalK e3⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Cond e1 e2 e3⟧ρ ↦ evalK (Cond e1 e2 e3)⋅ρ'› 9. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 10. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Succ e⟧ρ ↦ evalK (Succ e)⋅ρ'› 11. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 12. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case AbsN (*‹∀v::nat. η: (?ρ::nat → ValD)⋅v ↦ (?ρ'::nat → ('o ValK → 'o) → 'o)⋅v ⟹ η: ⟦e_::expr⟧?ρ ↦ evalK e_⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) show "?case" (*goal: ‹η: ⟦AbsN x1a_ e_⟧ρ ↦ evalK (AbsN x1a_ e_)⋅ρ'›*) apply simp (*goal: ‹η: ⟦AbsN x1a_ e_⟧ρ ↦ evalK (AbsN x1a_ e_)⋅ρ'›*) apply (rule eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*goal: ‹η: ValF⋅(Λ x. ⟦e_⟧(env_ext⋅x1a_⋅x⋅ρ)) ↦ unitK⋅(ValKF⋅(Λ x. evalK e_⋅(env_ext⋅x1a_⋅x⋅ρ')))›*) apply (rule theta_F (*‹(⋀(x::ValD) x'::('o::domain ValK → 'o::domain) → 'o::domain. η: x ↦ x' ⟹ η: (?f::ValD → ValD)⋅x ↦ (?f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain)⋅x') ⟹ θ: ?f ↦ ?f'›*)) (*goal: ‹θ: (Λ x. ⟦e_⟧(env_ext⋅x1a_⋅x⋅ρ)) ↦ (Λ x. evalK e_⋅(env_ext⋅x1a_⋅x⋅ρ'))›*) apply simp (*goal: ‹⋀(x::ValD) x'::('o ValK → 'o) → 'o. η: x ↦ x' ⟹ η: (Λ (x::ValD). ⟦e_::expr⟧(env_ext⋅(x1a_::nat)⋅x⋅(ρ::nat → ValD)))⋅x ↦ (Λ (x::('o ValK → 'o) → 'o). evalK e_⋅(env_ext⋅x1a_⋅x⋅(ρ'::nat → ('o ValK → 'o) → 'o)))⋅x'›*) apply (rule AbsN.hyps (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e_⟧?ρ ↦ evalK e_⋅?ρ'›*)) (*goal: ‹⋀x x'. η: x ↦ x' ⟹ η: ⟦e_⟧(env_ext⋅x1a_⋅x⋅ρ) ↦ evalK e_⋅(env_ext⋅x1a_⋅x'⋅ρ')›*) using AbsN(2) (*‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) unfolding env_ext_def (*goal: ‹⋀x x'. η: x ↦ x' ⟹ ∀v. η: (Λ v x ρ v'. if v = v' then x else ρ⋅v')⋅x1a_⋅x⋅ρ⋅v ↦ (Λ v x ρ v'. if v = v' then x else ρ⋅v')⋅x1a_⋅x'⋅ρ'⋅v›*) by simp next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦AbsV x1a e⟧ρ ↦ evalK (AbsV x1a e)⋅ρ'› 3. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 4. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Fix x1a e⟧ρ ↦ evalK (Fix x1a e)⋅ρ'› 5. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 6. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 7. ‹⋀e1 e2 e3 ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1⟧ρ ↦ evalK e1⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2⟧ρ ↦ evalK e2⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3⟧ρ ↦ evalK e3⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Cond e1 e2 e3⟧ρ ↦ evalK (Cond e1 e2 e3)⋅ρ'› 8. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 9. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Succ e⟧ρ ↦ evalK (Succ e)⋅ρ'› 10. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 11. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case (AbsV v e ρ ρ') (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e⟧?ρ ↦ evalK e⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) have "η: ValF⋅(Λ x. evalD e⋅(env_ext⋅v⋅x⋅ρ)) ↦ unitK⋅(ValKF⋅(Λ x. evalK e⋅(env_ext⋅v⋅x⋅ρ')))" apply (rule eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*goal: ‹η: ValF⋅(Λ x. ⟦e⟧(env_ext⋅v⋅x⋅ρ)) ↦ unitK⋅(ValKF⋅(Λ x. evalK e⋅(env_ext⋅v⋅x⋅ρ')))›*) apply (rule theta_F (*‹(⋀x x'. η: x ↦ x' ⟹ η: ?f⋅x ↦ ?f'⋅x') ⟹ θ: ?f ↦ ?f'›*)) (*goal: ‹θ: (Λ x. ⟦e⟧(env_ext⋅v⋅x⋅ρ)) ↦ (Λ x. evalK e⋅(env_ext⋅v⋅x⋅ρ'))›*) apply simp (*goal: ‹⋀x x'. η: x ↦ x' ⟹ η: (Λ x. ⟦e⟧(env_ext⋅v⋅x⋅ρ))⋅x ↦ (Λ x. evalK e⋅(env_ext⋅v⋅x⋅ρ'))⋅x'›*) apply (rule AbsV.hyps (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e⟧?ρ ↦ evalK e⋅?ρ'›*)) (*goal: ‹⋀x x'. η: x ↦ x' ⟹ η: ⟦e⟧(env_ext⋅v⋅x⋅ρ) ↦ evalK e⋅(env_ext⋅v⋅x'⋅ρ')›*) using AbsV(2) (*‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) unfolding env_ext_def (*goal: ‹⋀x x'. η: x ↦ x' ⟹ ∀va. η: (Λ v x ρ v'. if v = v' then x else ρ⋅v')⋅v⋅x⋅ρ⋅va ↦ (Λ v x ρ v'. if v = v' then x else ρ⋅v')⋅v⋅x'⋅ρ'⋅va›*) by simp thus "?case" (*goal: ‹η: ⟦AbsV v e⟧ρ ↦ evalK (AbsV v e)⋅ρ'›*) by (fastforce dest: AbsV_aux (*‹η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f') ⟹ η: ValF⋅(strictify⋅?f) ↦ unitK⋅(ValKF⋅(Λ x c. x⋅(Λ x'. ?f'⋅(unitK⋅x')⋅c)))›*)) next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 3. ‹⋀x1a e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Fix x1a e⟧ρ ↦ evalK (Fix x1a e)⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 5. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 6. ‹⋀e1 e2 e3 ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1⟧ρ ↦ evalK e1⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2⟧ρ ↦ evalK e2⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3⟧ρ ↦ evalK e3⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Cond e1 e2 e3⟧ρ ↦ evalK (Cond e1 e2 e3)⋅ρ'› 7. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 8. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Succ e⟧ρ ↦ evalK (Succ e)⋅ρ'› 9. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 10. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case Fix (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e_⟧?ρ ↦ evalK e_⋅?ρ'› ‹∀v::nat. η: (ρ::nat → ValD)⋅v ↦ (ρ'::nat → ('o ValK → 'o) → 'o)⋅v›*) thus "?case" (*goal: ‹η: ⟦Fix x1a_ e_⟧ρ ↦ evalK (Fix x1a_ e_)⋅ρ'›*) apply simp (*goal: ‹η: ⟦Fix (x1a_::nat) (e_::expr)⟧(ρ::nat → ValD) ↦ evalK (Fix x1a_ e_)⋅(ρ'::nat → ('o ValK → 'o) → 'o)›*) apply (rule parallel_fix_ind (*‹⟦adm (λx. ?P (fst x) (snd x)); ?P ⊥ ⊥; ⋀x y. ?P x y ⟹ ?P (?F⋅x) (?G⋅y)⟧ ⟹ ?P (fix⋅?F) (fix⋅?G)›*)) (*goals: 1. ‹⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ adm (λx. η: fst x ↦ snd x)› 2. ‹⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⊥ ↦ ⊥› 3. ‹⋀x y. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; η: x ↦ y⟧ ⟹ η: (Λ x. ⟦e_⟧(env_ext⋅x1a_⋅x⋅ρ))⋅x ↦ (Λ x. evalK e_⋅(env_ext⋅x1a_⋅x⋅ρ'))⋅y› discuss goal 1*) apply (simp add: env_ext_def (*‹env_ext ≡ Λ v x ρ v'. if v = v' then x else ρ⋅v'›*)) (*discuss goal 2*) apply (simp add: env_ext_def (*‹env_ext ≡ Λ v x ρ v'. if v = v' then x else ρ⋅v'›*)) (*discuss goal 3*) apply (simp add: env_ext_def (*‹env_ext ≡ Λ v x ρ v'. if v = v' then x else ρ⋅v'›*)) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 3. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 5. ‹⋀e1 e2 e3 ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1⟧ρ ↦ evalK e1⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2⟧ρ ↦ evalK e2⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3⟧ρ ↦ evalK e3⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Cond e1 e2 e3⟧ρ ↦ evalK (Cond e1 e2 e3)⋅ρ'› 6. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 7. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Succ e⟧ρ ↦ evalK (Succ e)⋅ρ'› 8. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 9. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case Cond (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e1_⟧?ρ ↦ evalK e1_⋅?ρ'› ‹∀v::nat. η: (?ρ::nat → ValD)⋅v ↦ (?ρ'::nat → ('o ValK → 'o) → 'o)⋅v ⟹ η: ⟦e2_::expr⟧?ρ ↦ evalK e2_⋅?ρ'› ‹∀v::nat. η: (?ρ::nat → ValD)⋅v ↦ (?ρ'::nat → ('o::domain ValK → 'o::domain) → 'o::domain)⋅v ⟹ η: ⟦e3_::expr⟧?ρ ↦ evalK e3_⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) thus "?case" (*goal: ‹η: ⟦Cond e1_ e2_ e3_⟧ρ ↦ evalK (Cond e1_ e2_ e3_)⋅ρ'›*) apply (simp add: cond_def (*‹cond ≡ Λ i t e. case i of ValF⋅f ⇒ ⊥ | ValTT ⇒ t | ValFF ⇒ e | ValN⋅n ⇒ ⊥›*) condK_def (*‹condK ≡ Λ iK tK eK. bindK⋅iK⋅(Λ i. case i of ValKF⋅f ⇒ ⊥ | ValKTT ⇒ tK | ValKFF ⇒ eK | ValKN⋅n ⇒ ⊥)›*) eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) (*goal: ‹η: ⟦Cond (e1_::expr) (e2_::expr) (e3_::expr)⟧(ρ::nat → ValD) ↦ evalK (Cond e1_ e2_ e3_)⋅(ρ'::nat → ('o::domain ValK → 'o::domain) → 'o::domain)›*) using Cond(1)[OF Cond ( 4 )] (*‹η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'›*) apply (rule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goals: 1. ‹⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2_⟧ρ ↦ evalK e2_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3_⟧ρ ↦ evalK e3_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e1_⟧ρ = ⊥; evalK e1_⋅ρ' = ⊥⟧ ⟹ η: ValD_case⋅⊥⋅(⟦e2_⟧ρ)⋅(⟦e3_⟧ρ)⋅⊥⋅(⟦e1_⟧ρ) ↦ bindK⋅(evalK e1_⋅ρ')⋅(ValK_case⋅⊥⋅(evalK e2_⋅ρ')⋅(evalK e3_⋅ρ')⋅⊥)› 2. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2_⟧ρ ↦ evalK e2_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3_⟧ρ ↦ evalK e3_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e1_⟧ρ = ValTT; evalK e1_⋅ρ' = unitK⋅ValKTT⟧ ⟹ η: ValD_case⋅⊥⋅(⟦e2_⟧ρ)⋅(⟦e3_⟧ρ)⋅⊥⋅(⟦e1_⟧ρ) ↦ bindK⋅(evalK e1_⋅ρ')⋅(ValK_case⋅⊥⋅(evalK e2_⋅ρ')⋅(evalK e3_⋅ρ')⋅⊥)› 3. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2_⟧ρ ↦ evalK e2_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3_⟧ρ ↦ evalK e3_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e1_⟧ρ = ValFF; evalK e1_⋅ρ' = unitK⋅ValKFF⟧ ⟹ η: ValD_case⋅⊥⋅(⟦e2_⟧ρ)⋅(⟦e3_⟧ρ)⋅⊥⋅(⟦e1_⟧ρ) ↦ bindK⋅(evalK e1_⋅ρ')⋅(ValK_case⋅⊥⋅(evalK e2_⋅ρ')⋅(evalK e3_⋅ρ')⋅⊥)› 4. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2_⟧ρ ↦ evalK e2_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3_⟧ρ ↦ evalK e3_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e1_⟧ρ = ValN⋅n; evalK e1_⋅ρ' = unitK⋅(ValKN⋅n)⟧ ⟹ η: ValD_case⋅⊥⋅(⟦e2_⟧ρ)⋅(⟦e3_⟧ρ)⋅⊥⋅(⟦e1_⟧ρ) ↦ bindK⋅(evalK e1_⋅ρ')⋅(ValK_case⋅⊥⋅(evalK e2_⋅ρ')⋅(evalK e3_⋅ρ')⋅⊥)› 5. ‹⋀f f'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e1_⟧ρ ↦ evalK e1_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e2_⟧ρ ↦ evalK e2_⋅ρ'; ⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e3_⟧ρ ↦ evalK e3_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e1_⟧ρ = ValF⋅f; evalK e1_⋅ρ' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ η: ValD_case⋅⊥⋅(⟦e2_⟧ρ)⋅(⟦e3_⟧ρ)⋅⊥⋅(⟦e1_⟧ρ) ↦ bindK⋅(evalK e1_⋅ρ')⋅(ValK_case⋅⊥⋅(evalK e2_⋅ρ')⋅(evalK e3_⋅ρ')⋅⊥)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 3. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 5. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 6. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Succ e⟧ρ ↦ evalK (Succ e)⋅ρ'› 7. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 8. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case Succ (*‹∀v::nat. η: (?ρ::nat → ValD)⋅v ↦ (?ρ'::nat → ('o::domain ValK → 'o::domain) → 'o::domain)⋅v ⟹ η: ⟦e_::expr⟧?ρ ↦ evalK e_⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) thus "?case" (*goal: ‹η: ⟦Succ e_⟧ρ ↦ evalK (Succ e_)⋅ρ'›*) apply (simp add: succ_def (*‹succ ≡ Λ (ValN⋅(n::nat)). ValN⋅(n + (1::nat))›*) succK_def (*‹succK ≡ Λ (nK::(?'o ValK → ?'o) → ?'o). bindK⋅nK⋅(Λ (ValKN⋅(n::nat)). unitK⋅(ValKN⋅(n + (1::nat))))›*) eta_cfun (*‹(Λ (x::?'a). (?f::?'a → ?'b)⋅x) = ?f›*)) (*goal: ‹η: ⟦Succ e_⟧ρ ↦ evalK (Succ e_)⋅ρ'›*) using Succ(1)[OF Succ ( 2 )] (*‹η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'›*) apply (rule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goals: 1. ‹⟦⋀(ρ::nat → ValD) ρ'::nat → ('o ValK → 'o) → 'o. ∀v::nat. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_::expr⟧ρ ↦ evalK e_⋅ρ'; ∀v::nat. η: (ρ::nat → ValD)⋅v ↦ (ρ'::nat → ('o ValK → 'o) → 'o)⋅v; ⟦e_⟧ρ = ⊥; evalK e_⋅ρ' = ⊥⟧ ⟹ η: (Λ (ValN⋅(n::nat)). ValN⋅(Suc n))⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅(n::nat)). unitK⋅(ValKN⋅(Suc n)))› 2. ‹⋀n::?'a39. ⟦⋀(ρ::nat → ValD) ρ'::nat → ('o ValK → 'o) → 'o. ∀v::nat. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_::expr⟧ρ ↦ evalK e_⋅ρ'; ∀v::nat. η: (ρ::nat → ValD)⋅v ↦ (ρ'::nat → ('o ValK → 'o) → 'o)⋅v; ⟦e_⟧ρ = ValTT; evalK e_⋅ρ' = unitK⋅ValKTT⟧ ⟹ η: (Λ (ValN⋅(n::nat)). ValN⋅(Suc n))⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅(n::nat)). unitK⋅(ValKN⋅(Suc n)))› 3. ‹⋀n::?'b39. ⟦⋀(ρ::nat → ValD) ρ'::nat → ('o ValK → 'o) → 'o. ∀v::nat. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_::expr⟧ρ ↦ evalK e_⋅ρ'; ∀v::nat. η: (ρ::nat → ValD)⋅v ↦ (ρ'::nat → ('o ValK → 'o) → 'o)⋅v; ⟦e_⟧ρ = ValFF; evalK e_⋅ρ' = unitK⋅ValKFF⟧ ⟹ η: (Λ (ValN⋅(n::nat)). ValN⋅(Suc n))⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅(n::nat)). unitK⋅(ValKN⋅(Suc n)))› 4. ‹⋀n::nat. ⟦⋀(ρ::nat → ValD) ρ'::nat → ('o ValK → 'o) → 'o. ∀v::nat. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_::expr⟧ρ ↦ evalK e_⋅ρ'; ∀v::nat. η: (ρ::nat → ValD)⋅v ↦ (ρ'::nat → ('o ValK → 'o) → 'o)⋅v; ⟦e_⟧ρ = ValN⋅n; evalK e_⋅ρ' = unitK⋅(ValKN⋅n)⟧ ⟹ η: (Λ (ValN⋅(n::nat)). ValN⋅(Suc n))⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅(n::nat)). unitK⋅(ValKN⋅(Suc n)))› 5. ‹⋀(f::ValD → ValD) f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o. ⟦⋀(ρ::nat → ValD) ρ'::nat → ('o ValK → 'o) → 'o. ∀v::nat. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_::expr⟧ρ ↦ evalK e_⋅ρ'; ∀v::nat. η: (ρ::nat → ValD)⋅v ↦ (ρ'::nat → ('o ValK → 'o) → 'o)⋅v; ⟦e_⟧ρ = ValF⋅f; evalK e_⋅ρ' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ η: (Λ (ValN⋅(n::nat)). ValN⋅(Suc n))⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅(n::nat)). unitK⋅(ValKN⋅(Suc n)))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*proven 5 subgoals*) . next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 3. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 5. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 6. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦Pred e⟧ρ ↦ evalK (Pred e)⋅ρ'› 7. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case Pred (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e_⟧?ρ ↦ evalK e_⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) thus "?case" (*goal: ‹η: ⟦Pred (e_::expr)⟧(ρ::nat → ValD) ↦ evalK (Pred e_)⋅(ρ'::nat → ('o ValK → 'o) → 'o)›*) apply (simp add: pred_def (*‹pred ≡ Λ (ValN⋅(n::nat)). case n of 0::nat ⇒ ⊥ | Suc (n::nat) ⇒ ValN⋅n›*) predK_def (*‹predK ≡ Λ (nK::(?'o::domain ValK → ?'o::domain) → ?'o::domain). bindK⋅nK⋅(Λ (ValKN⋅(n::nat)). case n of 0::nat ⇒ ⊥ | Suc (n::nat) ⇒ unitK⋅(ValKN⋅n))›*) eta_cfun (*‹(Λ (x::?'a::cpo). (?f::?'a::cpo → ?'b::cpo)⋅x) = ?f›*)) (*goal: ‹η: ⟦Pred e_⟧ρ ↦ evalK (Pred e_)⋅ρ'›*) using Pred(1)[OF Pred ( 2 )] (*‹η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'›*) apply (rule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goals: 1. ‹⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ⊥; evalK e_⋅ρ' = ⊥⟧ ⟹ η: (Λ (ValN⋅a). case a of 0 ⇒ ⊥ | Suc a ⇒ ValN⋅a)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅a). case a of 0 ⇒ ⊥ | Suc n ⇒ unitK⋅(ValKN⋅n))› 2. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValTT; evalK e_⋅ρ' = unitK⋅ValKTT⟧ ⟹ η: (Λ (ValN⋅a). case a of 0 ⇒ ⊥ | Suc a ⇒ ValN⋅a)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅a). case a of 0 ⇒ ⊥ | Suc n ⇒ unitK⋅(ValKN⋅n))› 3. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValFF; evalK e_⋅ρ' = unitK⋅ValKFF⟧ ⟹ η: (Λ (ValN⋅a). case a of 0 ⇒ ⊥ | Suc a ⇒ ValN⋅a)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅a). case a of 0 ⇒ ⊥ | Suc n ⇒ unitK⋅(ValKN⋅n))› 4. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValN⋅n; evalK e_⋅ρ' = unitK⋅(ValKN⋅n)⟧ ⟹ η: (Λ (ValN⋅a). case a of 0 ⇒ ⊥ | Suc a ⇒ ValN⋅a)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅a). case a of 0 ⇒ ⊥ | Suc n ⇒ unitK⋅(ValKN⋅n))› 5. ‹⋀f f'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValF⋅f; evalK e_⋅ρ' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ η: (Λ (ValN⋅a). case a of 0 ⇒ ⊥ | Suc a ⇒ ValN⋅a)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅a). case a of 0 ⇒ ⊥ | Suc n ⇒ unitK⋅(ValKN⋅n))› discuss goal 1*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 2*) apply (simp split: nat.split (*‹(?P::?'a::type ⇒ bool) (case ?nat::nat of 0::nat ⇒ ?f1.0::?'a::type | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a::type) x) = ((?nat = (0::nat) ⟶ ?P ?f1.0) ∧ (∀x2::nat. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 3*) apply (simp split: nat.split (*‹(?P::?'a ⇒ bool) (case ?nat::nat of 0::nat ⇒ ?f1.0::?'a | Suc (x::nat) ⇒ (?f2.0::nat ⇒ ?'a) x) = ((?nat = (0::nat) ⟶ ?P ?f1.0) ∧ (∀x2::nat. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 4*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 5*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*proven 5 subgoals*) . next (*goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 3. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 5. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'› 6. ‹⋀e ρ ρ'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e⟧ρ ↦ evalK e⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v⟧ ⟹ η: ⟦IsZero e⟧ρ ↦ evalK (IsZero e)⋅ρ'›*) case IsZero (*‹∀v. η: ?ρ⋅v ↦ ?ρ'⋅v ⟹ η: ⟦e_⟧?ρ ↦ evalK e_⋅?ρ'› ‹∀v. η: ρ⋅v ↦ ρ'⋅v›*) thus "?case" (*goal: ‹η: ⟦IsZero e_⟧ρ ↦ evalK (IsZero e_)⋅ρ'›*) apply (simp add: isZero_def (*‹isZero ≡ Λ (ValN⋅n). if n = 0 then ValTT else ValFF›*) isZeroK_def (*‹isZeroK ≡ Λ nK. bindK⋅nK⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))›*) eta_cfun (*‹(Λ x. ?f⋅x) = ?f›*)) (*goal: ‹η: ⟦IsZero e_⟧ρ ↦ evalK (IsZero e_)⋅ρ'›*) using IsZero(1)[OF IsZero ( 2 )] (*‹η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'›*) apply (rule eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goals: 1. ‹⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ⊥; evalK e_⋅ρ' = ⊥⟧ ⟹ η: (Λ (ValN⋅n). if n = 0 then ValTT else ValFF)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))› 2. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValTT; evalK e_⋅ρ' = unitK⋅ValKTT⟧ ⟹ η: (Λ (ValN⋅n). if n = 0 then ValTT else ValFF)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))› 3. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValFF; evalK e_⋅ρ' = unitK⋅ValKFF⟧ ⟹ η: (Λ (ValN⋅n). if n = 0 then ValTT else ValFF)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))› 4. ‹⋀n. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValN⋅n; evalK e_⋅ρ' = unitK⋅(ValKN⋅n)⟧ ⟹ η: (Λ (ValN⋅n). if n = 0 then ValTT else ValFF)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))› 5. ‹⋀f f'. ⟦⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦e_⟧ρ ↦ evalK e_⋅ρ'; ∀v. η: ρ⋅v ↦ ρ'⋅v; ⟦e_⟧ρ = ValF⋅f; evalK e_⋅ρ' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ η: (Λ (ValN⋅n). if n = 0 then ValTT else ValFF)⋅(⟦e_⟧ρ) ↦ bindK⋅(evalK e_⋅ρ')⋅(Λ (ValKN⋅n). unitK⋅(if n = 0 then ValKTT else ValKFF))› discuss goal 1*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 2*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 3*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 4*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*discuss goal 5*) apply (simp split: nat.split (*‹?P (case ?nat of 0 ⇒ ?f1.0 | Suc x ⇒ ?f2.0 x) = ((?nat = 0 ⟶ ?P ?f1.0) ∧ (∀x2. ?nat = Suc x2 ⟶ ?P (?f2.0 x2)))›*)) (*proven 5 subgoals*) . qed (simp_all) (*solves the remaining goals: 1. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Var x⟧ρ ↦ evalK (Var x)⋅ρ'› 2. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Ω⟧ρ ↦ evalK Ω⋅ρ'› 3. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦tt⟧ρ ↦ evalK tt⋅ρ'› 4. ‹⋀ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦ff⟧ρ ↦ evalK ff⋅ρ'› 5. ‹⋀x ρ ρ'. ∀v. η: ρ⋅v ↦ ρ'⋅v ⟹ η: ⟦Num x⟧ρ ↦ evalK (Num x)⋅ρ'›*) (*>*) end text‹ The retraction between the two value and monadic value spaces. Note we need to work with an observation type that can represent the ``explicit values'', i.e. @{typ "'o ValK"}. › locale value_retraction = fixes VtoO :: "'o ValK → 'o" fixes OtoV :: "'o → 'o ValK" assumes OV: "OtoV oo VtoO = ID" sublocale value_retraction < at_least_two_elements "VtoO⋅(ValKN⋅0)" using OV (*‹(OtoV::'o → 'o ValK) oo (VtoO::'o ValK → 'o) = ID›*) apply - (*goal: ‹at_least_two_elements (VtoO⋅(ValKN⋅0))›*) apply standard (*goal: ‹OtoV oo VtoO = ID ⟹ at_least_two_elements (VtoO⋅(ValKN⋅0))›*) by (simp add: injection_defined (*‹⟦∀x. ?f⋅(?g⋅x) = x; ?z ≠ ⊥⟧ ⟹ ?g⋅?z ≠ ⊥›*) cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*) cfun_eq_iff (*‹(?f = ?g) = (∀x. ?f⋅x = ?g⋅x)›*)) context value_retraction begin fun DtoKM_i :: "nat ⇒ ValD → 'o ValKM" and KMtoD_i :: "nat ⇒ 'o ValKM → ValD" where "DtoKM_i 0 = ⊥" | "DtoKM_i (Suc n) = (Λ v. case v of ValF⋅f ⇒ unitK⋅(ValKF⋅(cfun_map⋅(KMtoD_i n)⋅(DtoKM_i n)⋅f)) | ValTT ⇒ unitK⋅ValKTT | ValFF ⇒ unitK⋅ValKFF | ValN⋅m ⇒ unitK⋅(ValKN⋅m))" | "KMtoD_i 0 = ⊥" | "KMtoD_i (Suc n) = (Λ v. case OtoV⋅(v⋅VtoO) of ValKF⋅f ⇒ ValF⋅(cfun_map⋅(DtoKM_i n)⋅(KMtoD_i n)⋅f) | ValKTT ⇒ ValTT | ValKFF ⇒ ValFF | ValKN⋅m ⇒ ValN⋅m)" abbreviation "DtoKM ≡ (⨆i. DtoKM_i i)" abbreviation "KMtoD ≡ (⨆i. KMtoD_i i)" (*<*) lemma DtoKM_KMtoD_chain [intro, simp]: "chain DtoKM_i" "chain KMtoD_i" proof (-) (*goals: 1. ‹chain DtoKM_i› 2. ‹chain KMtoD_i›*) let ?C = "λi. (DtoKM_i i, KMtoD_i i)" have "chain ?C" proof (rule chainI (*‹(⋀i::nat. (?Y::nat ⇒ ?'a) i ⊑ ?Y (Suc i)) ⟹ chain ?Y›*)) (*goal: ‹⋀i. (DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i))›*) fix i show "?C i ⊑ ?C (Suc i)" proof (induct i) (*goals: 1. ‹(DtoKM_i 0, KMtoD_i 0) ⊑ (DtoKM_i (Suc 0), KMtoD_i (Suc 0))› 2. ‹⋀i. (DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i)) ⟹ (DtoKM_i (Suc i), KMtoD_i (Suc i)) ⊑ (DtoKM_i (Suc (Suc i)), KMtoD_i (Suc (Suc i)))›*) case (Suc i) (*‹(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i))›*) show "?case" (*goal: ‹(DtoKM_i (Suc i), KMtoD_i (Suc i)) ⊑ (DtoKM_i (Suc (Suc i)), KMtoD_i (Suc (Suc i)))›*) proof (rule monofun_pair (*‹⟦?x1.0 ⊑ ?x2.0; ?y1.0 ⊑ ?y2.0⟧ ⟹ (?x1.0, ?y1.0) ⊑ (?x2.0, ?y2.0)›*)) (*goals: 1. ‹DtoKM_i (Suc i) ⊑ DtoKM_i (Suc (Suc i))› 2. ‹KMtoD_i (Suc i) ⊑ KMtoD_i (Suc (Suc i))›*) show "DtoKM_i (Suc i) ⊑ DtoKM_i (Suc (Suc i))" proof (rule cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*goal: ‹⋀x::ValD. DtoKM_i (Suc (i::nat))⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x›*) fix x from Suc (*‹(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i))›*) show "DtoKM_i (Suc i)⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x" apply (cases x) (*goals: 1. ‹⟦(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i)); x = ⊥⟧ ⟹ DtoKM_i (Suc i)⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x› 2. ‹⋀cfun. ⟦(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i)); x = ValF⋅cfun⟧ ⟹ DtoKM_i (Suc i)⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x› 3. ‹⟦(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i)); x = ValTT⟧ ⟹ DtoKM_i (Suc i)⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x› 4. ‹⟦(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i)); x = ValFF⟧ ⟹ DtoKM_i (Suc i)⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x› 5. ‹⋀nat. ⟦(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i)); x = ValN⋅nat⟧ ⟹ DtoKM_i (Suc i)⋅x ⊑ DtoKM_i (Suc (Suc i))⋅x› discuss goal 1*) apply ((auto intro!: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) simp: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*))[1]) (*discuss goal 2*) apply ((auto intro!: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) simp: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*))[1]) (*discuss goal 3*) apply ((auto intro!: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) simp: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*))[1]) (*discuss goal 4*) apply ((auto intro!: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) simp: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*))[1]) (*discuss goal 5*) apply ((auto intro!: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*) simp: cfun_map_def (*‹cfun_map = (Λ a b f x. b⋅(f⋅(a⋅x)))›*) cfun_below_iff (*‹(?f ⊑ ?g) = (∀x. ?f⋅x ⊑ ?g⋅x)›*))[1]) (*proven 5 subgoals*) . qed show "KMtoD_i (Suc i) ⊑ KMtoD_i (Suc (Suc i))" proof (rule cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*goal: ‹⋀x. KMtoD_i (Suc i)⋅x ⊑ KMtoD_i (Suc (Suc i))⋅x›*) fix x from Suc (*‹(DtoKM_i i, KMtoD_i i) ⊑ (DtoKM_i (Suc i), KMtoD_i (Suc i))›*) show "KMtoD_i (Suc i)⋅x ⊑ KMtoD_i (Suc (Suc i))⋅x" apply (simp add: eta_cfun (*‹(Λ (x::?'a). (?f::?'a → ?'b)⋅x) = ?f›*)) (*goal: ‹KMtoD_i (Suc i)⋅x ⊑ KMtoD_i (Suc (Suc i))⋅x›*) apply (intro monofun_cfun_fun (*‹(?f::?'a → ?'b) ⊑ (?g::?'a → ?'b) ⟹ ?f⋅(?x::?'a) ⊑ ?g⋅?x›*) monofun_cfun_arg (*‹(?x::?'a) ⊑ (?y::?'a) ⟹ (?f::?'a → ?'b)⋅?x ⊑ ?f⋅?y›*)) (*goal: ‹DtoKM_i i ⊑ ValD_case⋅(Λ f. unitK⋅(ValKF⋅(cfun_map⋅(KMtoD_i i)⋅(DtoKM_i i)⋅f)))⋅(unitK⋅ValKTT)⋅(unitK⋅ValKFF)⋅(Λ m. unitK⋅(ValKN⋅m)) ∧ KMtoD_i i ⊑ (Λ v. ValK_case⋅(Λ f. ValF⋅(cfun_map⋅(DtoKM_i i)⋅(KMtoD_i i)⋅f))⋅ValTT⋅ValFF⋅ValN⋅(OtoV⋅(v⋅VtoO))) ⟹ ValK_case⋅(Λ f. ValF⋅(cfun_map⋅(DtoKM_i i)⋅(KMtoD_i i)⋅f))⋅ValTT⋅ValFF⋅ValN⋅(OtoV⋅(x⋅VtoO)) ⊑ ValK_case⋅(Λ f. ValF⋅(cfun_map⋅(ValD_case⋅(Λ f. unitK⋅(ValKF⋅(cfun_map⋅(KMtoD_i i)⋅(DtoKM_i i)⋅f)))⋅(unitK⋅ValKTT)⋅(unitK⋅ValKFF)⋅(Λ m. unitK⋅(ValKN⋅m)))⋅(Λ v. ValK_case⋅(Λ f. ValF⋅(cfun_map⋅(DtoKM_i i)⋅(KMtoD_i i)⋅f))⋅ValTT⋅ValFF⋅ValN⋅(OtoV⋅(v⋅VtoO)))⋅f))⋅ValTT⋅ValFF⋅ValN⋅(OtoV⋅(x⋅VtoO))›*) apply (intro cfun_belowI (*‹(⋀x. ?f⋅x ⊑ ?g⋅x) ⟹ ?f ⊑ ?g›*)) (*goal: ‹DtoKM_i i ⊑ ValD_case⋅(Λ f. unitK⋅(ValKF⋅(cfun_map⋅(KMtoD_i i)⋅(DtoKM_i i)⋅f)))⋅(unitK⋅ValKTT)⋅(unitK⋅ValKFF)⋅(Λ m. unitK⋅(ValKN⋅m)) ∧ KMtoD_i i ⊑ (Λ v. ValK_case⋅(Λ f. ValF⋅(cfun_map⋅(DtoKM_i i)⋅(KMtoD_i i)⋅f))⋅ValTT⋅ValFF⋅ValN⋅(OtoV⋅(v⋅VtoO))) ⟹ (Λ f. ValF⋅(cfun_map⋅(DtoKM_i i)⋅(KMtoD_i i)⋅f)) ⊑ (Λ f. ValF⋅(cfun_map⋅(ValD_case⋅(Λ f. unitK⋅(ValKF⋅(cfun_map⋅(KMtoD_i i)⋅(DtoKM_i i)⋅f)))⋅(unitK⋅ValKTT)⋅(unitK⋅ValKFF)⋅(Λ m. unitK⋅(ValKN⋅m)))⋅(Λ v. ValK_case⋅(Λ f. ValF⋅(cfun_map⋅(DtoKM_i i)⋅(KMtoD_i i)⋅f))⋅ValTT⋅ValFF⋅ValN⋅(OtoV⋅(v⋅VtoO)))⋅f))›*) by (auto intro: monofun_cfun (*‹⟦?f ⊑ ?g; ?x ⊑ ?y⟧ ⟹ ?f⋅?x ⊑ ?g⋅?y›*)) qed qed qed (simp) (*solved the remaining goal: ‹(DtoKM_i (0::nat), KMtoD_i (0::nat)) ⊑ (DtoKM_i (Suc (0::nat)), KMtoD_i (Suc (0::nat)))›*) qed then show "chain DtoKM_i" "chain KMtoD_i" apply - (*goals: 1. ‹chain (λi::nat. (DtoKM_i i, KMtoD_i i)) ⟹ chain DtoKM_i› 2. ‹chain (λi::nat. (DtoKM_i i, KMtoD_i i)) ⟹ chain KMtoD_i› discuss goal 1*) apply ((auto dest: ch2ch_fst (*‹chain ?Y ⟹ chain (λi. fst (?Y i))›*) ch2ch_snd (*‹chain ?Y ⟹ chain (λi. snd (?Y i))›*))[1]) (*discuss goal 2*) apply ((auto dest: ch2ch_fst (*‹chain ?Y ⟹ chain (λi. fst (?Y i))›*) ch2ch_snd (*‹chain ?Y ⟹ chain (λi. snd (?Y i))›*))[1]) (*proven 2 subgoals*) . qed (*>*) text‹ Lemma 1 from \<^citet>‹"DBLP:conf/icalp/Reynolds74"›. › lemma Lemma1: "η: x ↦ DtoKM⋅x" "η: x ↦ x' ⟹ x = KMtoD⋅x'" (*<*) proof (-) (*goals: 1. ‹η: x ↦ Lub DtoKM_i⋅x› 2. ‹η: x ↦ x' ⟹ x = Lub KMtoD_i⋅x'›*) have K: "η: ValD_copy_i i⋅x ↦ DtoKM_i i⋅x" and L: "η: x ↦ x' ⟹ ValD_copy_i i⋅x = KMtoD_i i⋅x'" for x and x' and i proof (induct i arbitrary: x x') (*goals: 1. ‹⋀x. η: ValD_copy_i 0⋅x ↦ DtoKM_i 0⋅x› 2. ‹⋀x x'. η: x ↦ x' ⟹ ValD_copy_i 0⋅x = KMtoD_i 0⋅x'› 3. ‹⋀i x. ⟦⋀x. η: ValD_copy_i i⋅x ↦ DtoKM_i i⋅x; ⋀x x'. η: x ↦ x' ⟹ ValD_copy_i i⋅x = KMtoD_i i⋅x'⟧ ⟹ η: ValD_copy_i (Suc i)⋅x ↦ DtoKM_i (Suc i)⋅x› 4. ‹⋀i x x'. ⟦⋀x. η: ValD_copy_i i⋅x ↦ DtoKM_i i⋅x; ⋀x x'. η: x ↦ x' ⟹ ValD_copy_i i⋅x = KMtoD_i i⋅x'; η: x ↦ x'⟧ ⟹ ValD_copy_i (Suc i)⋅x = KMtoD_i (Suc i)⋅x'›*) case (Suc i) (*‹η: ValD_copy_i i⋅?x ↦ DtoKM_i i⋅?x› ‹η: ?x ↦ ?x' ⟹ ValD_copy_i i⋅?x = KMtoD_i i⋅?x'›*) { case 1 (*no hyothesis introduced yet*) show "?case" (*goal: ‹η: ValD_copy_i (Suc i)⋅x ↦ DtoKM_i (Suc i)⋅x›*) apply (cases x) (*goal: ‹η: ValD_copy_i (Suc i)⋅x ↦ DtoKM_i (Suc i)⋅x›*) apply simp_all (*top goal: ‹x = ⊥ ⟹ η: ValD_copy_i (Suc i)⋅x ↦ DtoKM_i (Suc i)⋅x› and 4 goals remain*) apply (rule eta_F (*‹θ: ?f ↦ ?f' ⟹ η: ValF⋅?f ↦ unitK⋅(ValKF⋅?f')›*)) (*goal: ‹⋀cfun. x = ValF⋅cfun ⟹ η: ValF⋅(ValD_copy_i i oo cfun oo ValD_copy_i i) ↦ unitK⋅(ValKF⋅(cfun_map⋅(KMtoD_i i)⋅(DtoKM_i i)⋅cfun))›*) apply (rule theta_F (*‹(⋀x x'. η: x ↦ x' ⟹ η: ?f⋅x ↦ ?f'⋅x') ⟹ θ: ?f ↦ ?f'›*)) (*goal: ‹⋀cfun. x = ValF⋅cfun ⟹ θ: ValD_copy_i i oo cfun oo ValD_copy_i i ↦ cfun_map⋅(KMtoD_i i)⋅(DtoKM_i i)⋅cfun›*) using Suc (*‹η: ValD_copy_i i⋅?x ↦ DtoKM_i i⋅?x› ‹η: (?x::ValD) ↦ (?x'::('o ValK → 'o) → 'o) ⟹ ValD_copy_i (i::nat)⋅?x = KMtoD_i i⋅?x'›*) by simp } { case 2 (*‹η: x ↦ x'›*) thus "?case" (*goal: ‹ValD_copy_i (Suc i)⋅x = KMtoD_i (Suc i)⋅x'›*) apply (induct rule: eta_induct (*‹⟦η: ?x ↦ ?x'; ⟦?x = ⊥; ?x' = ⊥⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValTT; ?x' = unitK⋅ValKTT⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValFF; ?x' = unitK⋅ValKFF⟧ ⟹ ?P ?x ?x'; ⋀n. ⟦?x = ValN⋅n; ?x' = unitK⋅(ValKN⋅n)⟧ ⟹ ?P ?x ?x'; ⋀f f'. ⟦?x = ValF⋅f; ?x' = unitK⋅(ValKF⋅f'); θ: f ↦ f'⟧ ⟹ ?P ?x ?x'⟧ ⟹ ?P ?x ?x'›*)) (*goal: ‹ValD_copy_i (Suc i)⋅x = KMtoD_i (Suc i)⋅x'›*) using OV (*‹OtoV oo VtoO = ID›*) apply (simp_all add: cfun_eq_iff retraction_strict) (*top goal: ‹⟦x = ⊥; x' = ⊥⟧ ⟹ ValD_copy_i (Suc i)⋅x = KMtoD_i (Suc i)⋅x'› and 4 goals remain*) apply (clarsimp simp: cfun_eq_iff (*‹((?f::?'a → ?'b) = (?g::?'a → ?'b)) = (∀x::?'a. ?f⋅x = ?g⋅x)›*)) (*goal: ‹⋀f f'. ⟦x = ValF⋅f; ∀x. x'⋅x = x⋅(ValKF⋅f'); θ: f ↦ f'; ∀x. OtoV⋅(VtoO⋅x) = x⟧ ⟹ ∀x. ValD_copy_i i⋅(f⋅(ValD_copy_i i⋅x)) = KMtoD_i i⋅(f'⋅(DtoKM_i i⋅x))›*) apply (erule theta_induct (*‹⟦θ: (?f::ValD → ValD) ↦ (?f'::(('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain); (⋀(x::ValD) x'::('o::domain ValK → 'o::domain) → 'o::domain. η: x ↦ x' ⟹ η: ?f⋅x ↦ ?f'⋅x') ⟹ (?P::(ValD → ValD) ⇒ ((('o::domain ValK → 'o::domain) → 'o::domain) → ('o::domain ValK → 'o::domain) → 'o::domain) ⇒ bool) ?f ?f'⟧ ⟹ ?P ?f ?f'›*)) (*goal: ‹⋀(f::ValD → ValD) (f'::(('o ValK → 'o) → 'o) → ('o ValK → 'o) → 'o) x::ValD. ⟦(x::ValD) = ValF⋅f; ∀x::'o ValK → 'o. (x'::('o ValK → 'o) → 'o)⋅x = x⋅(ValKF⋅f'); θ: f ↦ f'; ∀x::'o ValK. (OtoV::'o → 'o ValK)⋅((VtoO::'o ValK → 'o)⋅x) = x⟧ ⟹ ValD_copy_i (i::nat)⋅(f⋅(ValD_copy_i i⋅x)) = KMtoD_i i⋅(f'⋅(DtoKM_i i⋅x))›*) using Suc (*‹η: ValD_copy_i i⋅?x ↦ DtoKM_i i⋅?x› ‹η: ?x ↦ ?x' ⟹ ValD_copy_i i⋅?x = KMtoD_i i⋅?x'›*) by simp } qed (simp_all) (*solves the remaining goals: 1. ‹⋀x. η: ValD_copy_i 0⋅x ↦ DtoKM_i 0⋅x› 2. ‹⋀x x'. η: x ↦ x' ⟹ ValD_copy_i 0⋅x = KMtoD_i 0⋅x'›*) let ?C1 = "λi. (ValD_copy_i i, DtoKM_i i)" let ?P1 = "λf. η: (fst f)⋅x ↦ (snd f)⋅x" have "adm ?P1" apply (rule adm_subst (*‹⟦cont ?t; adm ?P⟧ ⟹ adm (λx. ?P (?t x))›*)) (*goals: 1. ‹cont (λf. (fst f⋅x, snd f⋅x))› 2. ‹adm (λa. a ∈ unlr (fst F.delta))› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*proven 2 subgoals*) . with K (*‹η: ValD_copy_i ?i⋅?x ↦ DtoKM_i ?i⋅?x›*) have "?P1 (⨆i. ValD_copy_i i, ⨆i. DtoKM_i i)" using admD[where P = "?P1" and Y = "?C1"] (*‹⟦adm (λf::(ValD → ValD) × (ValD → ('o::domain ValK → 'o::domain) → 'o::domain). η: fst f⋅(x::ValD) ↦ snd f⋅x); chain (λi::nat. (ValD_copy_i i, DtoKM_i i)); ⋀i::nat. η: fst (ValD_copy_i i, DtoKM_i i)⋅x ↦ snd (ValD_copy_i i, DtoKM_i i)⋅x⟧ ⟹ η: fst (⨆i::nat. (ValD_copy_i i, DtoKM_i i))⋅x ↦ snd (⨆i::nat. (ValD_copy_i i, DtoKM_i i))⋅x›*) lub_prod[where S = "?C1"] (*‹chain (λi::nat. (ValD_copy_i i, DtoKM_i i)) ⟹ (⨆i::nat. (ValD_copy_i i, DtoKM_i i)) = (⨆i::nat. fst (ValD_copy_i i, DtoKM_i i), ⨆i::nat. snd (ValD_copy_i i, DtoKM_i i))›*) by simp moreover { fix x :: ValD fix x' :: "'o ValKM" let ?C2 = "λi. (ValD_copy_i i, KMtoD_i i)" let ?P2 = "λf. (fst f)⋅x = (snd f)⋅x'" have "adm (λf. ?P2 f)" by simp with L (*‹η: ?x ↦ ?x' ⟹ ValD_copy_i ?i⋅?x = KMtoD_i ?i⋅?x'›*) have "η: x ↦ x' ⟹ ?P2 (⨆i. ValD_copy_i i, ⨆i. KMtoD_i i)" using admD[where P = "?P2" and Y = "?C2"] (*‹⟦adm (λf. fst f⋅x = snd f⋅x'); chain (λi. (ValD_copy_i i, KMtoD_i i)); ⋀i. fst (ValD_copy_i i, KMtoD_i i)⋅x = snd (ValD_copy_i i, KMtoD_i i)⋅x'⟧ ⟹ fst (⨆i. (ValD_copy_i i, KMtoD_i i))⋅x = snd (⨆i. (ValD_copy_i i, KMtoD_i i))⋅x'›*) lub_prod[where S = "?C2"] (*‹chain (λi. (ValD_copy_i i, KMtoD_i i)) ⟹ (⨆i. (ValD_copy_i i, KMtoD_i i)) = (⨆i. fst (ValD_copy_i i, KMtoD_i i), ⨆i. snd (ValD_copy_i i, KMtoD_i i))›*) by simp } ultimately show "η: x ↦ DtoKM⋅x" "η: x ↦ x' ⟹ x = KMtoD⋅x'" apply - (*goals: 1. ‹⟦η: fst (ValD_copy_lub, Lub DtoKM_i)⋅x ↦ snd (ValD_copy_lub, Lub DtoKM_i)⋅x; ⋀xa x'a. η: xa ↦ x'a ⟹ fst (ValD_copy_lub, Lub KMtoD_i)⋅xa = snd (ValD_copy_lub, Lub KMtoD_i)⋅x'a⟧ ⟹ η: x ↦ Lub DtoKM_i⋅x› 2. ‹⟦η: x ↦ x'; η: fst (ValD_copy_lub, Lub DtoKM_i)⋅x ↦ snd (ValD_copy_lub, Lub DtoKM_i)⋅x; ⋀xa x'a. η: xa ↦ x'a ⟹ fst (ValD_copy_lub, Lub KMtoD_i)⋅xa = snd (ValD_copy_lub, Lub KMtoD_i)⋅x'a⟧ ⟹ x = Lub KMtoD_i⋅x'› discuss goal 1*) apply (simp add: ValD_copy_lub_ID (*‹ValD_copy_lub = ID›*)) (*discuss goal 2*) apply (simp add: ValD_copy_lub_ID (*‹ValD_copy_lub = ID›*)) (*proven 2 subgoals*) . qed (*>*) text‹ Theorem 2 from \<^citet>‹"DBLP:conf/icalp/Reynolds74"›. › theorem Theorem2: "evalD e⋅ρ = KMtoD⋅(evalK e⋅(DtoKM oo ρ))" using Lemma1(2)[OF Theorem1] (*‹∀v. η: ?ρ1⋅v ↦ ?ρ'1⋅v ⟹ ⟦?e1⟧?ρ1 = Lub KMtoD_i⋅(evalK ?e1⋅?ρ'1)›*) Lemma1(1) (*‹η: ?x ↦ Lub DtoKM_i⋅?x›*) by (simp add: cfcomp1 (*‹?f oo ?g = (Λ x. ?f⋅(?g⋅x))›*)) end text‹ \<^citet>‹‹Remark~48› in "DBLP:journals/tcs/Filinski07"› observes that there will not be a retraction between direct and continuation semantics for languages with richer notions of effects. It should be routine to extend the above approach to the higher-order backtracking language of \<^citet>‹"DBLP:conf/icfp/WandV04"›. I wonder if it is possible to construct continuation semantics from direct semantics as proposed by \<^citet>‹"DBLP:journals/jacm/SethiT80"›. Roughly we might hope to lift a retraction between two value domains to a retraction at higher types by synthesising a suitable logical relation. › (*<*) end (*>*)
{ "path": "afp-2025-02-12/thys/PCF/Continuations.thy", "repo": "afp-2025-02-12", "sha": "b4e884c5a089c154a5b1c88fd9b85c67ed864afc2fc122252ea6586bb5e0aac6" }
theory Independent_DYNAMIC_Post_ISSUER imports "Independent_Post_Observation_Setup_ISSUER" "Independent_DYNAMIC_Post_Value_Setup_ISSUER" "Bounded_Deducibility_Security.Compositional_Reasoning" begin subsubsection ‹Issuer declassification bound› (* We verify that a group of users, allowed to take normal actions to the system and observe their outputs *and additionally allowed to observe communication*, learn nothing about the updates to a post and the sends of that post to other APIs beyond: (1) the updates that occur during the times when: -- either a user in the group is the post's owner -- or a user in the group is a friend of the owner -- or the group has at least one registered user and the post is marked "public" (2) the presence of the sends (i.e., the number of the sending actions) (3) and the public knowledge that what is being sent is always the last version (modeled as the correlation predicate) *) context Post begin fun T :: "(state,act,out) trans ⇒ bool" where "T _ = False" text ‹We again use the dynamic declassification bound for the issuer node (Section~\ref{sec:dynamic-post-issuer}).› inductive BC :: "value list ⇒ value list ⇒ bool" and BO :: "value list ⇒ value list ⇒ bool" where BC_PVal[simp,intro!]: "list_all (Not o isOVal) ul ⟹ list_all (Not o isOVal) ul1 ⟹ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ⟹ (ul = [] ⟶ ul1 = []) ⟹ BC ul ul1" |BC_BO[intro]: "BO vl vl1 ⟹ list_all (Not o isOVal) ul ⟹ list_all (Not o isOVal) ul1 ⟹ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ⟹ (ul = [] ⟷ ul1 = []) ⟹ (ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1) ⟹ list_all isPValS sul ⟹ BC (ul @ sul @ OVal True # vl) (ul1 @ sul @ OVal True # vl1)" (* *) |BO_PVal[simp,intro!]: "list_all (Not o isOVal) ul ⟹ BO ul ul" |BO_BC[intro]: "BC vl vl1 ⟹ list_all (Not o isOVal) ul ⟹ BO (ul @ OVal False # vl) (ul @ OVal False # vl1)" lemma list_all_filter_Not_isOVal: assumes "list_all (Not ∘ isOVal) ul" and "filter isPValS ul = []" and "filter isPVal ul = []" shows "ul = []" using assms (*‹list_all (Not ∘ isOVal) ul› ‹filter isPValS ul = []› ‹filter isPVal ul = []›*) value.exhaust_disc (*‹⟦isPVal (?value::value) ⟹ ?P::bool; isPValS ?value ⟹ ?P; isOVal ?value ⟹ ?P⟧ ⟹ ?P›*) apply (induct ul) (*goals: 1. ‹⟦list_all (Not ∘ isOVal) []; filter isPValS [] = []; filter isPVal [] = []; ⋀value P. ⟦isPVal value ⟹ P; isPValS value ⟹ P; isOVal value ⟹ P⟧ ⟹ P⟧ ⟹ [] = []› 2. ‹⋀a ul. ⟦⟦list_all (Not ∘ isOVal) ul; filter isPValS ul = []; filter isPVal ul = []; ⋀value P. ⟦isPVal value ⟹ P; isPValS value ⟹ P; isOVal value ⟹ P⟧ ⟹ P⟧ ⟹ ul = []; list_all (Not ∘ isOVal) (a # ul); filter isPValS (a # ul) = []; filter isPVal (a # ul) = []; ⋀value P. ⟦isPVal value ⟹ P; isPValS value ⟹ P; isOVal value ⟹ P⟧ ⟹ P⟧ ⟹ a # ul = []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma BC_not_Nil: "BC vl vl1 ⟹ vl = [] ⟹ vl1 = []" by (auto elim: BC.cases (*‹⟦BC ?a1.0 ?a2.0; ⋀ul ul1. ⟦?a1.0 = ul; ?a2.0 = ul1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul = [] ⟶ ul1 = []⟧ ⟹ ?P; ⋀vl vl1 ul ul1 sul. ⟦?a1.0 = ul @ sul @ OVal True # vl; ?a2.0 = ul1 @ sul @ OVal True # vl1; BO vl vl1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ ?P⟧ ⟹ ?P›*)) lemma BC_OVal_True: assumes "BC (OVal True # vl') vl1" shows "∃ vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'" proof (-) (*goal: ‹∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) define vl where vl: "vl ≡ OVal True # vl'" have "BC vl vl1" using assms (*‹BC (OVal True # vl') vl1›*) unfolding vl (*goal: ‹BC (OVal True # vl') vl1›*) by auto thus "?thesis" (*goal: ‹∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) proof (cases) (*goals: 1. ‹⟦list_all (Not ∘ isOVal) (vl::value list); list_all (Not ∘ isOVal) (vl1::value list); map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1); vl = [] ⟶ vl1 = []⟧ ⟹ ∃vl1'::value list. BO (vl'::value list) vl1' ∧ vl1 = OVal True # vl1'› 2. ‹⋀(vla::value list) (vl1a::value list) (ul::value list) (ul1::value list) sul::value list. ⟦(vl::value list) = ul @ sul @ OVal True # vla; (vl1::value list) = ul1 @ sul @ OVal True # vl1a; BO vla vl1a; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ ∃vl1'::value list. BO (vl'::value list) vl1' ∧ vl1 = OVal True # vl1'›*) case (BC_BO vll vll1 ul ul1 sul) (*‹vl = ul @ sul @ OVal True # vll› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO vll vll1› ‹list_all (Not ∘ isOVal) (ul::value list)› ‹list_all (Not ∘ isOVal) ul1› ‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)› ‹((ul::value list) = []) = ((ul1::value list) = [])› ‹ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1› ‹list_all isPValS (sul::value list)›*) hence ul: "ul = []" unfolding vl (*goal: ‹ul = []›*) apply simp (*goal: ‹ul = []›*) by (metis (no_types) Post.value.disc( (*‹isOVal (OVal ?x3.0)›*) 9) append_eq_Cons_conv (*‹(?ys @ ?zs = ?x # ?xs) = (?ys = [] ∧ ?zs = ?x # ?xs ∨ (∃ys'. ?ys = ?x # ys' ∧ ys' @ ?zs = ?xs))›*) list.map( (*‹map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0›*) 2) list.pred_inject( (*‹list_all ?P (?a # ?aa) = (?P ?a ∧ list_all ?P ?aa)›*) 2) list_all_map (*‹list_all (?h ∘ ?i) ?l = list_all ?h (map ?i ?l)›*)) have sul: "sul = []" using BC_BO (*‹vl = ul @ sul @ OVal True # vll› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO vll vll1› ‹list_all (Not ∘ isOVal) ul› ‹list_all (Not ∘ isOVal) (ul1::value list)› ‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)› ‹(ul = []) = (ul1 = [])› ‹(ul::value list) ≠ [] ⟹ isPVal (last ul) ∧ last ul = last (ul1::value list)› ‹list_all isPValS sul›*) unfolding vl ul (*goal: ‹sul = []›*) apply simp (*goal: ‹sul = []›*) by (metis Post.value.disc( (*‹¬ isPValS (OVal ?x3.0)›*) 6) append_eq_Cons_conv (*‹(?ys @ ?zs = ?x # ?xs) = (?ys = [] ∧ ?zs = ?x # ?xs ∨ (∃ys'. ?ys = ?x # ys' ∧ ys' @ ?zs = ?xs))›*) list.pred_inject( (*‹list_all ?P (?a # ?aa) = (?P ?a ∧ list_all ?P ?aa)›*) 2)) show "?thesis" (*goal: ‹∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) apply - (*goal: ‹∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) using BC_BO (*‹vl = ul @ sul @ OVal True # vll› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO (vll::value list) (vll1::value list)› ‹list_all (Not ∘ isOVal) ul› ‹list_all (Not ∘ isOVal) (ul1::value list)› ‹map tgtAPI (filter isPValS (ul::value list)) = map tgtAPI (filter isPValS (ul1::value list))› ‹(ul = []) = (ul1 = [])› ‹(ul::value list) ≠ [] ⟹ isPVal (last ul) ∧ last ul = last (ul1::value list)› ‹list_all isPValS (sul::value list)›*) using list_all_filter_Not_isOVal[of ul1] (*‹⟦list_all (Not ∘ isOVal) (ul1::value list); filter isPValS ul1 = []; filter isPVal ul1 = []⟧ ⟹ ul1 = []›*) unfolding ul sul vl (*goal: ‹BO (vl'::value list) (vll1::value list) ∧ (vl1::value list) = OVal True # vll1›*) by auto qed (unfold vl (*‹vl ≡ OVal True # vl'›*), auto) (*solved the remaining goal: ‹⟦list_all (Not ∘ isOVal) vl; list_all (Not ∘ isOVal) vl1; map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1); vl = [] ⟶ vl1 = []⟧ ⟹ ∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) qed (* Correlation is defined to mean: always send what was last uploaded, or emptyPost if nothing had been uploaded. This needs the auxiliary notion of "coherence from" *) fun corrFrom :: "post ⇒ value list ⇒ bool" where "corrFrom pst [] = True" |"corrFrom pst (PVal pstt # vl) = corrFrom pstt vl" |"corrFrom pst (PValS aid pstt # vl) = (pst = pstt ∧ corrFrom pst vl)" |"corrFrom pst (OVal b # vl) = (corrFrom pst vl)" abbreviation corr :: "value list ⇒ bool" where "corr ≡ corrFrom emptyPost" definition B where "B vl vl1 ≡ BC vl vl1 ∧ corr vl1" (* lemma vl_Nil_filter_not: assumes "filter (%v. isPVal v ∨ isOVal v) Vl = [] ∧ filter (Not o isPVal) Vl = []" shows "Vl = []" using assms by (induct Vl) auto *) lemma B_not_Nil: assumes B: "B vl vl1" and vl: "vl = []" shows "vl1 = []" using B (*‹B vl vl1›*) Post.BC_not_Nil (*‹⟦BC (?vl::value list) (?vl1.0::value list); ?vl = []⟧ ⟹ ?vl1.0 = []›*) Post.B_def (*‹B ?vl ?vl1.0 ≡ BC ?vl ?vl1.0 ∧ corrFrom emptyPost ?vl1.0›*) vl (*‹vl = []›*) by blast sublocale BD_Security_IO where istate = istate and step = step and φ = φ and f = f and γ = γ and g = g and T = T and B = B done subsubsection ‹Issuer unwinding proof› lemma reach_PublicV_imples_FriendV[simp]: assumes "reach s" and "vis s pid ≠ PublicV" shows "vis s pid = FriendV" using assms (*‹reach (s::state)› ‹vis s pid ≠ PublicV›*) reach_vis (*‹reach (?s::state) ⟹ vis ?s (?pID::postID) ∈ {FriendV, PublicV}›*) by auto (* major *) lemma eqButPID_step_γ_out: assumes ss1: "eqButPID s s1" and step: "step s a = (ou,s')" and step1: "step s1 a = (ou1,s1')" and op: "¬ open s" and sT: "reachNT s" and s1: "reach s1" and γ: "γ (Trans s a ou s')" shows "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" proof- note [simp] = all_defs open_def note s = reachNT_reach[OF sT] note willUse = step step1 γ not_open_eqButPID[OF op ss1] reach_vis[OF s] eqButPID_stateSelectors[OF ss1] (* eqButPID_postSelectors[OF ss1] *) eqButPID_actions[OF ss1] eqButPID_update[OF ss1] (* eqButPID_setTextPost[OF ss1] *) eqButPID_not_PID[OF ss1] (* added to cope with extra leak towards the admin, when moving from CoSMed to CoSMeDis: *) (* eqButPID_eqButT[OF ss1] *) eqButPID_eqButF[OF ss1] eqButPID_setShared[OF ss1] eqButPID_updateShared[OF ss1] eeqButPID_F_not_PID eqButPID_not_PID_sharedWith eqButPID_insert2[OF ss1] show ?thesis proof (cases a) case (Sact x1) with willUse show ?thesis by (cases x1) auto next case (Cact x2) with willUse show ?thesis by (cases x2) auto next case (Dact x3) with willUse show ?thesis by (cases x3) auto next case (Uact x4) with willUse show ?thesis by (cases x4) auto next case (Ract x5) with willUse show ?thesis proof (cases x5) case (rPost uid p pid) with Ract willUse show ?thesis by (cases "pid = PID") auto qed auto next case (Lact x6) with willUse show ?thesis proof (cases x6) case (lClientsPost uid p pid) with Lact willUse show ?thesis by (cases "pid = PID") auto qed auto next case (COMact x7) with willUse show ?thesis by (cases x7) auto qed qed (* major *) lemma eqButPID_step_eq: assumes ss1: "eqButPID s s1" and a: "a = Uact (uPost uid p PID pst)" "ou = outOK" and step: "step s a = (ou, s')" and step1: "step s1 a = (ou', s1')" shows "s' = s1'" using ss1 (*‹eqButPID s s1›*) step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) step1 (*‹step s1 a = (ou', s1')›*) using eqButPID_stateSelectors[OF ss1] (*‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) eqButPID_update[OF ss1] (*‹(post s)(PID := ?txt) = (post s1)(PID := ?txt)›*) eqButPID_setShared[OF ss1] (*‹(sharedWith s)(PID := map (λ(aID, uu_). (aID, ?b)) (sharedWith s PID)) = (sharedWith s1)(PID := map (λ(aID, uu_). (aID, ?b)) (sharedWith s1 PID))›*) unfolding a (*goal: ‹s' = s1'›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) definition Δ0 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ0 s vl s1 vl1 ≡ ¬ PID ∈∈ postIDs s ∧ s = s1 ∧ BC vl vl1 ∧ corr vl1" definition Δ1 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ1 s vl s1 vl1 ≡ PID ∈∈ postIDs s ∧ list_all (Not o isOVal) vl ∧ list_all (Not o isOVal) vl1 ∧ map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1) ∧ (vl = [] ⟶ vl1 = []) ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1" definition Δ11 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ11 s vl s1 vl1 ≡ PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1" definition Δ2 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ2 s vl s1 vl1 ≡ PID ∈∈ postIDs s ∧ list_all (Not o isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1" definition Δ31 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ31 s vl s1 vl1 ≡ PID ∈∈ postIDs s ∧ (∃ ul ul1 sul vll vll1. BO vll vll1 ∧ list_all (Not o isOVal) ul ∧ list_all (Not o isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ vl = ul @ sul @ OVal True # vll ∧ vl1 = ul1 @ sul @ OVal True # vll1) ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1" definition Δ32 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ32 s vl s1 vl1 ≡ PID ∈∈ postIDs s ∧ (∃ sul vll vll1. BO vll vll1 ∧ list_all isPValS sul ∧ vl = sul @ OVal True # vll ∧ vl1 = sul @ OVal True # vll1) ∧ s = s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1" definition Δ4 :: "state ⇒ value list ⇒ state ⇒ value list ⇒ bool" where "Δ4 s vl s1 vl1 ≡ PID ∈∈ postIDs s ∧ (∃ ul vll vll1. BC vll vll1 ∧ list_all (Not o isOVal) ul ∧ vl = ul @ OVal False # vll ∧ vl1 = ul @ OVal False # vll1) ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1" lemma istate_Δ0: assumes B: "B vl vl1" shows "Δ0 istate vl istate vl1" using assms (*‹B vl vl1›*) unfolding "Δ0_def" istate_def B_def (*goal: ‹PID ∉ set (postIDs ⦇admin = emptyUserID, pendingUReqs = [], userReq = λuID. emptyRequestInfo, userIDs = [], user = λuID. emptyUser, pass = λuID. emptyPass, pendingFReqs = λuID. [], friendReq = λuID uID'. emptyRequestInfo, friendIDs = λuID. [], sentOuterFriendIDs = λuID. [], recvOuterFriendIDs = λuID. [], postIDs = [], post = λpapID. emptyPost, owner = λpID. emptyUserID, vis = λpID. FriendV, pendingSApiReqs = [], sApiReq = λaID. emptyRequestInfo, serverApiIDs = [], serverPass = λaID. emptyPass, outerPostIDs = λaID. [], outerPost = λaID papID. emptyPost, outerOwner = λaID papID. emptyUserID, outerVis = λaID pID. FriendV, pendingCApiReqs = [], cApiReq = λaID. emptyRequestInfo, clientApiIDs = [], clientPass = λaID. emptyPass, sharedWith = λpID. []⦈) ∧ ⦇admin = emptyUserID, pendingUReqs = [], userReq = λuID. emptyRequestInfo, userIDs = [], user = λuID. emptyUser, pass = λuID. emptyPass, pendingFReqs = λuID. [], friendReq = λuID uID'. emptyRequestInfo, friendIDs = λuID. [], sentOuterFriendIDs = λuID. [], recvOuterFriendIDs = λuID. [], postIDs = [], post = λpapID. emptyPost, owner = λpID. emptyUserID, vis = λpID. FriendV, pendingSApiReqs = [], sApiReq = λaID. emptyRequestInfo, serverApiIDs = [], serverPass = λaID. emptyPass, outerPostIDs = λaID. [], outerPost = λaID papID. emptyPost, outerOwner = λaID papID. emptyUserID, outerVis = λaID pID. FriendV, pendingCApiReqs = [], cApiReq = λaID. emptyRequestInfo, clientApiIDs = [], clientPass = λaID. emptyPass, sharedWith = λpID. []⦈ = ⦇admin = emptyUserID, pendingUReqs = [], userReq = λuID. emptyRequestInfo, userIDs = [], user = λuID. emptyUser, pass = λuID. emptyPass, pendingFReqs = λuID. [], friendReq = λuID uID'. emptyRequestInfo, friendIDs = λuID. [], sentOuterFriendIDs = λuID. [], recvOuterFriendIDs = λuID. [], postIDs = [], post = λpapID. emptyPost, owner = λpID. emptyUserID, vis = λpID. FriendV, pendingSApiReqs = [], sApiReq = λaID. emptyRequestInfo, serverApiIDs = [], serverPass = λaID. emptyPass, outerPostIDs = λaID. [], outerPost = λaID papID. emptyPost, outerOwner = λaID papID. emptyUserID, outerVis = λaID pID. FriendV, pendingCApiReqs = [], cApiReq = λaID. emptyRequestInfo, clientApiIDs = [], clientPass = λaID. emptyPass, sharedWith = λpID. []⦈ ∧ BC vl vl1 ∧ corrFrom emptyPost vl1›*) by auto (* by (auto simp: list_all_isOVal_filter_isPValS) (auto intro!: exI[of _ "[]"]) *) lemma list_all_filter[simp]: assumes "list_all PP xs" shows "filter PP xs = xs" using assms (*‹list_all PP xs›*) apply (induct xs) (*goals: 1. ‹list_all PP [] ⟹ filter PP [] = []› 2. ‹⋀a xs. ⟦list_all PP xs ⟹ filter PP xs = xs; list_all PP (a # xs)⟧ ⟹ filter PP (a # xs) = a # xs› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . lemma unwind_cont_Δ0: "unwind_cont Δ0 {Δ0,Δ1,Δ2,Δ31,Δ32,Δ4}" apply rule (*goal: ‹unwind_cont Δ0 {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}›*) proof (simp) (*goal: ‹⋀s vl s1 vl1. ⟦reachNT s; reach s1; Δ0 s vl s1 vl1⟧ ⟹ iaction (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ0 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ0 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) hence rs: "reach s" and ss1: "s1 = s" and BC: "BC vl vl1" and PID: "¬ PID ∈∈ postIDs s" and cor1: "corr vl1" using reachNT_reach (*‹reachNT ?s ⟹ reach ?s›*) unfolding "Δ0_def" (*goals: 1. ‹reach (s::state)› 2. ‹(s1::state) = (s::state)› 3. ‹BC (vl::value list) (vl1::value list)› 4. ‹(PID::postID) ∉ set (postIDs (s::state))› 5. ‹corrFrom emptyPost (vl1::value list)›*) apply - (*goals: 1. ‹⟦reachNT s; reach s1; PID ∉ set (postIDs s) ∧ s = s1 ∧ BC vl vl1 ∧ corrFrom emptyPost vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ reach s› 2. ‹⟦reachNT s; reach s1; PID ∉ set (postIDs s) ∧ s = s1 ∧ BC vl vl1 ∧ corrFrom emptyPost vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ s1 = s› 3. ‹⟦reachNT s; reach s1; PID ∉ set (postIDs s) ∧ s = s1 ∧ BC vl vl1 ∧ corrFrom emptyPost vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ BC vl vl1› 4. ‹⟦reachNT s; reach s1; PID ∉ set (postIDs s) ∧ s = s1 ∧ BC vl vl1 ∧ corrFrom emptyPost vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ PID ∉ set (postIDs s)› 5. ‹⟦reachNT s; reach s1; PID ∉ set (postIDs s) ∧ s = s1 ∧ BC vl vl1 ∧ corrFrom emptyPost vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ corrFrom emptyPost vl1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . have vis: "vis s PID = FriendV" using reach_not_postIDs_friendV[OF rs PID] (*‹vis s PID = FriendV›*) . have pPID: "post s1 PID = emptyPost" by (simp add: PID (*‹PID ∉ set (postIDs s)›*) reach_not_postIDs_emptyPost (*‹⟦reach ?s; ?PID ∉ set (postIDs ?s)⟧ ⟹ post ?s ?PID = emptyPost›*) rs (*‹reach s›*) ss1 (*‹s1 = s›*)) have vlvl1: "vl = [] ⟹ vl1 = []" using BC_not_Nil (*‹⟦BC ?vl ?vl1.0; ?vl = []⟧ ⟹ ?vl1.0 = []›*) BC (*‹BC vl vl1›*) by auto have op: "¬ open s" using PID (*‹PID ∉ set (postIDs s)›*) unfolding open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV))›*) by auto show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (-) (*goal: ‹iaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) (s::state) (vl::value list) (s1::state) (vl1::value list) ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) have "?react" proof (standard) (*goal: ‹⋀(a::act) (ou::out) (s'::state) vl'::value list. ⟦step (s::state) a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') (vl::value list) vl'⟧ ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s (s1::state) (vl1::value list) a ou s' vl' ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" let ?trn1 = "Trans s1 a ou s'" assume step: "step s a = (ou, s')" and T: "¬ T ?trn" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹¬ T (Trans (s::state) (a::act) (ou::out) (s'::state))› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) hence pPID': "post s' PID = emptyPost" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) pPID (*‹post s1 PID = emptyPost›*) ss1 (*‹(s1::state) = (s::state)›*) PID (*‹PID ∉ set (postIDs s)›*) apply (cases a) (*goal: ‹post s' PID = emptyPost›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Sact x1⟧ ⟹ post s' PID = emptyPost›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s' PID = emptyPost› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = emptyPost› 3. ‹⋀x31 x32 x33. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = emptyPost› 4. ‹⋀x41 x42 x43 x44. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = emptyPost› 5. ‹⋀x51 x52 x53. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = emptyPost› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Dact x3⟧ ⟹ post s' PID = emptyPost›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = emptyPost› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = emptyPost› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = emptyPost› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = emptyPost› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = emptyPost› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = emptyPost› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = emptyPost› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = emptyPost› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = emptyPost› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = emptyPost› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = emptyPost› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = emptyPost› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'; step s a = (ou, s'); post s1 PID = emptyPost; s1 = s; PID ∉ set (postIDs s); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = emptyPost› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (-) (*goal: ‹match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) have "?match" proof (cases "∃ uid p. a = Cact (cPost uid p PID) ∧ ou = outOK") (*goals: 1. ‹∃uid p. a = Cact (cPost uid p PID) ∧ ou = outOK ⟹ match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK ⟹ match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹∃uid p. a = Cact (cPost uid p PID) ∧ ou = outOK›*) then obtain uid and p where a: "a = Cact (cPost uid p PID)" and ou: "ou = outOK" (*goal: ‹(⋀uid p. ⟦a = Cact (cPost uid p PID); ou = outOK⟧ ⟹ thesis) ⟹ thesis›*) by auto have PID': "PID ∈∈ postIDs s'" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) PID (*‹PID ∉ set (postIDs s)›*) unfolding a ou (*goal: ‹PID ∈∈ postIDs s'›*) by (auto simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (cases "∃ uid' ∈ UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid)") (*goals: 1. ‹∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid) ⟹ match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ (∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid)) ⟹ match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹∃uid'::userID∈UIDs::userID set. uid' ∈∈ userIDs (s::state) ∧ (uid' = admin s ∨ uid' = (uid::userID) ∨ uid' ∈∈ friendIDs s uid)›*) note uid = True (*‹∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid)›*) have op': "open s'" using uid (*‹∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid)›*) using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) PID' (*‹PID ∈∈ postIDs s'›*) unfolding a ou (*goal: ‹open (s'::state)›*) by (auto simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*) open_def (*‹open (?s::?'a state_scheme) ≡ ∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs ?s ∧ (PID::postID) ∈∈ postIDs ?s ∧ (uid = admin ?s ∨ uid = owner ?s PID ∨ uid ∈∈ friendIDs ?s (owner ?s PID) ∨ vis ?s PID = PublicV)›*)) have "φ": "φ ?trn" using op (*‹¬ open s›*) op' (*‹open s'›*) unfolding "φ_def2"[OF step] (*goal: ‹(∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'›*) by simp then obtain v where vl: "vl = v # vl'" and f: "f ?trn = v" (*goal: ‹(⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def "φ_def2" (*goal: ‹(⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) apply (cases vl) (*goals: 1. ‹⟦⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have v: "v = OVal True" using f (*‹f (Trans s a ou s') = v›*) op (*‹¬ open s›*) op' (*‹open s'›*) unfolding a (*goal: ‹v = OVal True›*) by simp then obtain ul1 and vl1' where BO': "BO vl' vl1'" and vl1: "vl1 = ul1 @ OVal True # vl1'" and ul1: "list_all (Not ∘ isOVal) ul1" (*goal: ‹(⋀vl1' ul1. ⟦BO vl' vl1'; vl1 = ul1 @ OVal True # vl1'; list_all (Not ∘ isOVal) ul1⟧ ⟹ thesis) ⟹ thesis›*) using BC_OVal_True[OF BC [ unfolded vl v ]] (*‹∃vl1'. BO vl' vl1' ∧ vl1 = OVal True # vl1'›*) by auto have ul1: "ul1 = []" using BC (*‹BC (vl::value list) (vl1::value list)›*) BC_OVal_True (*‹BC (OVal True # ?vl') ?vl1.0 ⟹ ∃vl1'. BO ?vl' vl1' ∧ ?vl1.0 = OVal True # vl1'›*) list_all_Not_isOVal_OVal_True (*‹⟦list_all (Not ∘ isOVal) ?ul; ?ul @ ?vll = OVal True # ?vll'⟧ ⟹ ?ul = []›*) ul1 (*‹list_all (Not ∘ isOVal) (ul1::value list)›*) v (*‹(v::value) = OVal True›*) vl (*‹vl = v # vl'›*) vl1 (*‹(vl1::value list) = (ul1::value list) @ OVal True # (vl1'::value list)›*) by blast hence vl1: "vl1 = OVal True # vl1'" using vl1 (*‹(vl1::value list) = (ul1::value list) @ OVal True # (vl1'::value list)›*) by simp show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ0 s' vl' ?s1' ?vl1' ∨ Δ1 s' vl' ?s1' ?vl1' ∨ Δ2 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ0 s' vl' s' ?vl1' ∨ Δ1 s' vl' s' ?vl1' ∨ Δ2 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl1'" using "φ" (*‹φ (Trans s a ou s')›*) f (*‹f (Trans s a ou s') = v›*) unfolding vl1 v consume_def ss1 (*goal: ‹if φ (Trans s a ou s') then OVal True # vl1' ≠ [] ∧ f (Trans s a ou s') = hd (OVal True # vl1') ∧ vl1' = tl (OVal True # vl1') else vl1' = OVal True # vl1'›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) a ou s')› 2. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a ou s')› 3. ‹Δ0 (s'::state) (vl'::value list) s' (vl1'::value list) ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ0 s' vl' s' vl1' ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ0 (s'::state) (vl'::value list) s' (vl1'::value list) ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) show "?Δ s' vl' s' vl1'" using BO' (*‹BO vl' vl1'›*) proof (cases rule: BO.cases (*‹⟦BO ?a1.0 ?a2.0; ⋀ul. ⟦?a1.0 = ul; ?a2.0 = ul; list_all (Not ∘ isOVal) ul⟧ ⟹ ?P; ⋀vl vl1 ul. ⟦?a1.0 = ul @ OVal False # vl; ?a2.0 = ul @ OVal False # vl1; BC vl vl1; list_all (Not ∘ isOVal) ul⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦vl1' = vl'; list_all (Not ∘ isOVal) vl'⟧ ⟹ Δ0 s' vl' s' vl1' ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'› 2. ‹⋀vl vl1 ul. ⟦vl' = ul @ OVal False # vl; vl1' = ul @ OVal False # vl1; BC vl vl1; list_all (Not ∘ isOVal) ul⟧ ⟹ Δ0 s' vl' s' vl1' ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) case BO_PVal (*‹vl1' = vl'› ‹list_all (Not ∘ isOVal) vl'›*) hence "Δ2 s' vl' s' vl1'" using PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹open s'›*) cor1 (*‹corrFrom emptyPost vl1›*) unfolding "Δ2_def" vl1 pPID' (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl' ∧ vl' = vl1' ∧ s' = s' ∧ open s' ∧ corrFrom emptyPost vl1'›*) by auto thus "?thesis" (*goal: ‹Δ0 s' vl' s' vl1' ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) by simp next (*goal: ‹⋀vl vl1 ul. ⟦vl' = ul @ OVal False # vl; vl1' = ul @ OVal False # vl1; BC vl vl1; list_all (Not ∘ isOVal) ul⟧ ⟹ Δ0 s' vl' s' vl1' ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) case (BO_BC vll vll1 textl) (*‹vl' = textl @ OVal False # vll› ‹(vl1'::value list) = (textl::value list) @ OVal False # (vll1::value list)› ‹BC vll vll1› ‹list_all (Not ∘ isOVal) (textl::value list)›*) hence "Δ4 s' vl' s' vl1'" using PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) op' (*‹open (s'::state)›*) cor1 (*‹corrFrom emptyPost vl1›*) unfolding "Δ4_def" vl1 pPID' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul vll vll1. BC vll vll1 ∧ list_all (Not ∘ isOVal) ul ∧ vl' = ul @ OVal False # vll ∧ vl1' = ul @ OVal False # vll1) ∧ s' = s' ∧ open s' ∧ corrFrom emptyPost vl1'›*) by auto thus "?thesis" (*goal: ‹Δ0 s' vl' s' vl1' ∨ Δ1 s' vl' s' vl1' ∨ Δ2 s' vl' s' vl1' ∨ Δ31 s' vl' s' vl1' ∨ Δ32 s' vl' s' vl1' ∨ Δ4 s' vl' s' vl1'›*) by simp qed qed next (*goal: ‹¬ (∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid)) ⟹ match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ (∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid))›*) note uid = False (*‹¬ (∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid))›*) have op': "¬ open s'" using step (*‹step s a = (ou, s')›*) op (*‹¬ open s›*) uid (*‹¬ (∃uid'∈UIDs. uid' ∈∈ userIDs s ∧ (uid' = admin s ∨ uid' = uid ∨ uid' ∈∈ friendIDs s uid))›*) vis (*‹vis s PID = FriendV›*) unfolding open_def a (*goal: ‹¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs (s'::state) ∧ (PID::postID) ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))›*) by (auto simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) have "φ": "¬ φ ?trn" using op (*‹¬ open s›*) op' (*‹¬ open (s'::state)›*) a (*‹a = Cact (cPost uid p PID)›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s')›*) by auto hence vl': "vl' = vl" using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹vl' = vl›*) by simp show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ0 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list) ∨ Δ1 s' vl' ?s1' ?vl1' ∨ Δ2 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ0 s' vl' s' ?vl1' ∨ Δ1 s' vl' s' ?vl1' ∨ Δ2 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ" (*‹¬ φ (Trans s a ou s')›*) unfolding consume_def ss1 (*goal: ‹if φ (Trans s a ou s') then vl1 ≠ [] ∧ f (Trans s a ou s') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by auto next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) show "?Δ s' vl' s' vl1" using BC (*‹BC vl vl1›*) proof (cases rule: BC.cases (*‹⟦BC ?a1.0 ?a2.0; ⋀ul ul1. ⟦?a1.0 = ul; ?a2.0 = ul1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul = [] ⟶ ul1 = []⟧ ⟹ ?P; ⋀vl vl1 ul ul1 sul. ⟦?a1.0 = ul @ sul @ OVal True # vl; ?a2.0 = ul1 @ sul @ OVal True # vl1; BO vl vl1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦list_all (Not ∘ isOVal) vl; list_all (Not ∘ isOVal) vl1; map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1); vl = [] ⟶ vl1 = []⟧ ⟹ Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1› 2. ‹⋀vla vl1a ul ul1 sul. ⟦vl = ul @ sul @ OVal True # vla; vl1 = ul1 @ sul @ OVal True # vl1a; BO vla vl1a; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) case BC_PVal (*‹list_all (Not ∘ isOVal) vl› ‹list_all (Not ∘ isOVal) (vl1::value list)› ‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)› ‹vl = [] ⟶ vl1 = []›*) hence "Δ1 s' vl' s' vl1" using PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹¬ open s'›*) cor1 (*‹corrFrom emptyPost vl1›*) unfolding "Δ1_def" vl' pPID' (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl ∧ list_all (Not ∘ isOVal) vl1 ∧ map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1) ∧ (vl = [] ⟶ vl1 = []) ∧ eqButPID s' s' ∧ ¬ open s' ∧ corrFrom emptyPost vl1›*) by auto thus "?thesis" (*goal: ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) by simp next (*goal: ‹⋀vla vl1a ul ul1 sul. ⟦vl = ul @ sul @ OVal True # vla; vl1 = ul1 @ sul @ OVal True # vl1a; BO vla vl1a; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) case (BC_BO vll vll1 ul ul1 sul) (*‹(vl::value list) = (ul::value list) @ (sul::value list) @ OVal True # (vll::value list)› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO vll vll1› ‹list_all (Not ∘ isOVal) ul› ‹list_all (Not ∘ isOVal) ul1› ‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)› ‹(ul = []) = (ul1 = [])› ‹ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1› ‹list_all isPValS sul›*) show "?thesis" (*goal: ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) proof (cases "ul ≠ [] ∧ ul1 ≠ []") (*goals: 1. ‹(ul::value list) ≠ [] ∧ (ul1::value list) ≠ [] ⟹ Δ0 (s'::state) (vl'::value list) s' (vl1::value list) ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1› 2. ‹¬ ((ul::value list) ≠ [] ∧ (ul1::value list) ≠ []) ⟹ Δ0 (s'::state) (vl'::value list) s' (vl1::value list) ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) case True (*‹ul ≠ [] ∧ ul1 ≠ []›*) hence "Δ31 s' vl' s' vl1" using BC_BO (*‹vl = ul @ sul @ OVal True # vll› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO vll vll1› ‹list_all (Not ∘ isOVal) ul› ‹list_all (Not ∘ isOVal) ul1› ‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)› ‹(ul = []) = (ul1 = [])› ‹ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1› ‹list_all isPValS sul›*) PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹¬ open s'›*) cor1 (*‹corrFrom emptyPost vl1›*) unfolding "Δ31_def" vl' pPID' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1 sul vll vll1. BO vll vll1 ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ vl = ul @ sul @ OVal True # vll ∧ vl1 = ul1 @ sul @ OVal True # vll1) ∧ eqButPID s' s' ∧ ¬ open s' ∧ corrFrom emptyPost vl1›*) apply auto (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(ul::value list) (ul1::value list) (sul::value list) (vll::value list) vll1::value list. BO vll vll1 ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ (vl::value list) = ul @ sul @ OVal True # vll ∧ (vl1::value list) = ul1 @ sul @ OVal True # vll1) ∧ eqButPID s' s' ∧ ¬ open s' ∧ corrFrom emptyPost vl1›*) apply (rule exI[of _ "ul"] (*‹(?P::value list ⇒ bool) (ul::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦ul1 ≠ []; vl = ul @ sul @ OVal True # vll; vl1 = ul1 @ sul @ OVal True # vll1; BO vll vll1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul ≠ []; list_all isPValS sul; PID ∈∈ postIDs s'; ¬ open s'; corrFrom emptyPost (ul1 @ sul @ OVal True # vll1); isPVal (last ul1); last ul = last ul1⟧ ⟹ ∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ul1"] (*‹?P ul1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(ul1::value list) ≠ []; (vl::value list) = (ul::value list) @ (sul::value list) @ OVal True # (vll::value list); (vl1::value list) = ul1 @ sul @ OVal True # (vll1::value list); BO vll vll1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul ≠ []; list_all isPValS sul; (PID::postID) ∈∈ postIDs (s'::state); ¬ open s'; corrFrom emptyPost (ul1 @ sul @ OVal True # vll1); isPVal (last ul1); last ul = last ul1⟧ ⟹ ∃(ul1a::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "sul"] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦ul1 ≠ []; vl = ul @ sul @ OVal True # vll; vl1 = ul1 @ sul @ OVal True # vll1; BO vll vll1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul ≠ []; list_all isPValS sul; PID ∈∈ postIDs s'; ¬ open s'; corrFrom emptyPost (ul1 @ sul @ OVal True # vll1); isPVal (last ul1); last ul = last ul1⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹(?P::value list ⇒ bool) (vll::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦(ul1::value list) ≠ []; (vl::value list) = (ul::value list) @ (sul::value list) @ OVal True # (vll::value list); (vl1::value list) = ul1 @ sul @ OVal True # (vll1::value list); BO vll vll1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul ≠ []; list_all isPValS sul; (PID::postID) ∈∈ postIDs (s'::state); ¬ open s'; corrFrom emptyPost (ul1 @ sul @ OVal True # vll1); isPVal (last ul1); last ul = last ul1⟧ ⟹ ∃(vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹(?P::value list ⇒ bool) (vll1::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦ul1 ≠ []; vl = ul @ sul @ OVal True # vll; vl1 = ul1 @ sul @ OVal True # vll1; BO vll vll1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); ul ≠ []; list_all isPValS sul; PID ∈∈ postIDs s'; ¬ open s'; corrFrom emptyPost (ul1 @ sul @ OVal True # vll1); isPVal (last ul1); last ul = last ul1⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vll ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) by auto thus "?thesis" (*goal: ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) by simp next (*goal: ‹¬ (ul ≠ [] ∧ ul1 ≠ []) ⟹ Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) case False (*‹¬ (ul ≠ [] ∧ ul1 ≠ [])›*) hence 0: "ul = [] ∧ ul1 = []" using BC_BO (*‹vl = ul @ sul @ OVal True # vll› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO vll vll1› ‹list_all (Not ∘ isOVal) (ul::value list)› ‹list_all (Not ∘ isOVal) ul1› ‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)› ‹((ul::value list) = []) = ((ul1::value list) = [])› ‹ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1› ‹list_all isPValS sul›*) by simp hence 1: "list_all isPValS ul ∧ list_all isPValS ul1" using ‹list_all (Not ∘ isOVal) ul› (*‹list_all (Not ∘ isOVal) ul›*) ‹list_all (Not ∘ isOVal) ul1› (*‹list_all (Not ∘ isOVal) ul1›*) using filter_list_all_isPValS_isOVal (*‹⟦list_all (Not ∘ isOVal) ?ul; filter isPVal ?ul = []⟧ ⟹ list_all isPValS ?ul›*) by auto have "Δ32 s' vl' s' vl1" using BC_BO (*‹vl = ul @ sul @ OVal True # vll› ‹vl1 = ul1 @ sul @ OVal True # vll1› ‹BO vll vll1› ‹list_all (Not ∘ isOVal) ul› ‹list_all (Not ∘ isOVal) ul1› ‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)› ‹((ul::value list) = []) = ((ul1::value list) = [])› ‹ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1› ‹list_all isPValS sul›*) PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹¬ open (s'::state)›*) cor1 (*‹corrFrom emptyPost vl1›*) "0" (*‹ul = [] ∧ ul1 = []›*) "1" (*‹list_all isPValS (ul::value list) ∧ list_all isPValS (ul1::value list)›*) unfolding "Δ32_def" vl' pPID' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃sul vll vll1. BO vll vll1 ∧ list_all isPValS sul ∧ vl = sul @ OVal True # vll ∧ vl1 = sul @ OVal True # vll1) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom emptyPost vl1›*) apply simp (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(sul::value list) (vll::value list) vll1::value list. BO vll vll1 ∧ list_all isPValS sul ∧ (vl::value list) = sul @ OVal True # vll ∧ (vl1::value list) = sul @ OVal True # vll1) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom emptyPost vl1›*) apply (rule exI[of _ "sul"] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦vl = sul @ OVal True # vll; vl1 = sul @ OVal True # vll1; BO vll vll1; list_all isPValS sul; PID ∈∈ postIDs s'; ¬ open s'; corrFrom emptyPost (sul @ OVal True # vll1); ul = [] ∧ ul1 = []⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all isPValS sula ∧ sul @ OVal True # vll = sula @ OVal True # vlla ∧ sul @ OVal True # vll1 = sula @ OVal True # vll1a›*) apply (rule exI[of _ vll] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦vl = sul @ OVal True # vll; vl1 = sul @ OVal True # vll1; BO vll vll1; list_all isPValS sul; PID ∈∈ postIDs s'; ¬ open s'; corrFrom emptyPost (sul @ OVal True # vll1); ul = [] ∧ ul1 = []⟧ ⟹ ∃vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ sul @ OVal True # vll = sul @ OVal True # vlla ∧ sul @ OVal True # vll1 = sul @ OVal True # vll1a›*) apply (rule exI[of _ vll1] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦vl = sul @ OVal True # vll; vl1 = sul @ OVal True # vll1; BO vll vll1; list_all isPValS sul; PID ∈∈ postIDs s'; ¬ open s'; corrFrom emptyPost (sul @ OVal True # vll1); ul = [] ∧ ul1 = []⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all isPValS sul ∧ sul @ OVal True # vll = sul @ OVal True # vll ∧ sul @ OVal True # vll1 = sul @ OVal True # vll1a›*) by auto thus "?thesis" (*goal: ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) by simp qed qed qed qed next (*goal: ‹∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK ⟹ match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK›*) note a = False (*‹∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK›*) have op': "¬ open s'" using a (*‹∄(uid::userID) p::password. (a::act) = Cact (cPost uid p (PID::postID)) ∧ (ou::out) = outOK›*) step (*‹step s a = (ou, s')›*) PID (*‹(PID::postID) ∉ set (postIDs (s::state))›*) op (*‹¬ open s›*) unfolding open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))›*) apply (cases a) (*goal: ‹¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs (s'::state) ∧ (PID::postID) ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Sact x1⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 2. ‹⋀x21 x22 x23 x24. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 3. ‹⋀x31 x32 x33. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 4. ‹⋀x41 x42 x43 x44. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 5. ‹⋀x51 x52 x53. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Dact x3⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀(x11::userID) (x12::password) (x13::password) (x14::name) x15::inform. ⟦∄(uid::userID) p::password. (a::act) = Cact (cPost uid p (PID::postID)) ∧ (ou::out) = outOK; step (s::state) a = (ou, s'::state); PID ∉ set (postIDs s); ¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Uact (x4::uActt); x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ ¬ (∃uid::userID∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 2. ‹⋀(x21::userID) (x22::password) (x23::postID) x24::post. ⟦∄(uid::userID) p::password. (a::act) = Cact (cPost uid p (PID::postID)) ∧ (ou::out) = outOK; step (s::state) a = (ou, s'::state); PID ∉ set (postIDs s); ¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Uact (x4::uActt); x4 = uPost x21 x22 x23 x24⟧ ⟹ ¬ (∃uid::userID∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 3. ‹⋀(x31::userID) (x32::password) (x33::postID) x34::vis. ⟦∄(uid::userID) p::password. (a::act) = Cact (cPost uid p (PID::postID)) ∧ (ou::out) = outOK; step (s::state) a = (ou, s'::state); PID ∉ set (postIDs s); ¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = Uact (x4::uActt); x4 = uVisPost x31 x32 x33 x34⟧ ⟹ ¬ (∃uid::userID∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 2. ‹⋀x21 x22. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 3. ‹⋀x31 x32 x33 x34. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 4. ‹⋀x41 x42. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 6. ‹⋀x61 x62 x63 x64. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 7. ‹⋀x71 x72 x73 x74. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 8. ‹⋀x81 x82 x83 x84. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 9. ‹⋀x91 x92 x93 x94. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› 10. ‹⋀x101 x102 x103 x104. ⟦∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; step s a = (ou, s'); PID ∉ set (postIDs s); ¬ (∃uid∈UIDs. uid ∈∈ userIDs s ∧ PID ∈∈ postIDs s ∧ (uid = admin s ∨ uid = owner s PID ∨ uid ∈∈ friendIDs s (owner s PID) ∨ vis s PID = PublicV)); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ ¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have "φ": "¬ φ ?trn" using PID (*‹PID ∉ set (postIDs s)›*) step (*‹step s a = (ou, s')›*) op (*‹¬ open (s::state)›*) op' (*‹¬ open s'›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s')›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*) com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) hence vl': "vl' = vl" using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹vl' = vl›*) by simp have PID': "¬ PID ∈∈ postIDs s'" using step (*‹step s a = (ou, s')›*) PID (*‹PID ∉ set (postIDs s)›*) a (*‹∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK›*) apply (cases a) (*goal: ‹PID ∉ set (postIDs s')›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Sact x1⟧ ⟹ PID ∉ set (postIDs s')›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ PID ∉ set (postIDs s')› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ PID ∉ set (postIDs s')› 3. ‹⋀x31 x32 x33. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ PID ∉ set (postIDs s')› 4. ‹⋀x41 x42 x43 x44. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ PID ∉ set (postIDs s')› 5. ‹⋀x51 x52 x53. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ PID ∉ set (postIDs s')› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Dact x3⟧ ⟹ PID ∉ set (postIDs s')›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ PID ∉ set (postIDs s')› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ PID ∉ set (postIDs s')› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ PID ∉ set (postIDs s')› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ PID ∉ set (postIDs s')› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ PID ∉ set (postIDs s')› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ PID ∉ set (postIDs s')› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ PID ∉ set (postIDs s')› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ PID ∉ set (postIDs s')› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ PID ∉ set (postIDs s')› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ PID ∉ set (postIDs s')› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ PID ∉ set (postIDs s')› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ PID ∉ set (postIDs s')› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); PID ∉ set (postIDs s); ∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK; a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ PID ∉ set (postIDs s')› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ0 s' vl' ?s1' ?vl1' ∨ Δ1 s' vl' ?s1' ?vl1' ∨ Δ2 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ0 s' vl' s' ?vl1' ∨ Δ1 s' vl' s' ?vl1' ∨ Δ2 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ" (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) unfolding consume_def ss1 (*goal: ‹if φ (Trans s a ou s') then vl1 ≠ [] ∧ f (Trans s a ou s') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by auto next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a ou s')› 2. ‹Δ0 (s'::state) (vl'::value list) s' (vl1::value list) ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ0 s' vl' s' vl1 ∨ Δ1 s' vl' s' vl1 ∨ Δ2 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) have "Δ0 s' vl' s' vl1" using a (*‹∄uid p. a = Cact (cPost uid p PID) ∧ ou = outOK›*) BC (*‹BC (vl::value list) (vl1::value list)›*) PID' (*‹PID ∉ set (postIDs s')›*) cor1 (*‹corrFrom emptyPost vl1›*) unfolding "Δ0_def" vl' (*goal: ‹PID ∉ set (postIDs s') ∧ s' = s' ∧ BC vl vl1 ∧ corrFrom emptyPost vl1›*) by simp thus "?Δ s' vl' s' vl1" by simp qed qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ0 s vl s1 vl1 ∨ Δ1 s vl s1 vl1 ∨ Δ2 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) using vlvl1 (*‹vl = [] ⟹ vl1 = []›*) by simp qed qed lemma unwind_cont_Δ1: "unwind_cont Δ1 {Δ1,Δ11}" apply rule (*goal: ‹unwind_cont Δ1 {Δ1, Δ11}›*) proof (simp) (*goal: ‹⋀s vl s1 vl1. ⟦reachNT s; reach s1; Δ1 s vl s1 vl1⟧ ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ1 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ1 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) then obtain lvl: "list_all (Not ∘ isOVal) vl" and lvl1: "list_all (Not ∘ isOVal) vl1" and map: "map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)" and rs: "reach s" and ss1: "eqButPID s s1" and op: "¬ open s" and PID: "PID ∈∈ postIDs s" and vlvl1: "vl = [] ⟹ vl1 = []" and cor1: "corrFrom (post s1 PID) vl1" (*goal: ‹(⟦list_all (Not ∘ isOVal) (vl::value list); list_all (Not ∘ isOVal) (vl1::value list); map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1); reach (s::state); eqButPID s (s1::state); ¬ open s; (PID::postID) ∈∈ postIDs s; vl = [] ⟹ vl1 = []; corrFrom (post s1 PID) vl1⟧ ⟹ thesis::bool) ⟹ thesis›*) using reachNT_reach (*‹reachNT ?s ⟹ reach ?s›*) unfolding "Δ1_def" (*goal: ‹(⟦list_all (Not ∘ isOVal) (vl::value list); list_all (Not ∘ isOVal) (vl1::value list); map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1); reach (s::state); eqButPID s (s1::state); ¬ open s; (PID::postID) ∈∈ postIDs s; vl = [] ⟹ vl1 = []; corrFrom (post s1 PID) vl1⟧ ⟹ thesis::bool) ⟹ thesis›*) by auto have PID1: "PID ∈∈ postIDs s1" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) PID (*‹PID ∈∈ postIDs s›*) by auto have own: "owner s PID ∈ set (userIDs s)" using reach_owner_userIDs[OF rs PID] (*‹owner s PID ∈∈ userIDs s›*) . hence own1: "owner s1 PID ∈ set (userIDs s1)" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) by auto have adm: "admin s ∈ set (userIDs s)" using reach_admin_userIDs[OF rs own] (*‹admin s ∈∈ userIDs s›*) . hence adm1: "admin s1 ∈ set (userIDs s1)" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) by auto have op1: "¬ open s1" using op (*‹¬ open s›*) ss1 (*‹eqButPID s s1›*) eqButPID_open (*‹eqButPID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) by auto show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (cases vl1) (*goals: 1. ‹vl1 = [] ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1› 2. ‹⋀a list. vl1 = a # list ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) case (Cons v1 vll1) (*‹vl1 = v1 # vll1›*) note vl1 = Cons (*‹(vl1::value list) = (v1::value) # (vll1::value list)›*) show "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) proof (cases v1) (*goals: 1. ‹⋀x1::post. (v1::value) = PVal x1 ⟹ iaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (vl::value list) (s1::state) (vl1::value list) ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1› 2. ‹⋀(x21::apiID) x22::post. (v1::value) = PValS x21 x22 ⟹ iaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (vl::value list) (s1::state) (vl1::value list) ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1› 3. ‹⋀x3::bool. (v1::value) = OVal x3 ⟹ iaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (vl::value list) (s1::state) (vl1::value list) ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) case (PVal pst1) (*‹v1 = PVal pst1›*) note v1 = PVal (*‹v1 = PVal pst1›*) define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" define a1 where a1: "a1 ≡ Uact (uPost uid p PID pst1)" have uid1: "uid = owner s1 PID" and p1: "p = pass s1 uid" unfolding uid p (*goals: 1. ‹owner s PID = owner s1 PID› 2. ‹pass s (owner s PID) = pass s1 (owner s PID)›*) using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) apply - (*goals: 1. ‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ owner s PID = owner s1 PID› 2. ‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ pass s (owner s PID) = pass s1 (owner s PID)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a1 = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a1 = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a1") (*goal: ‹(⋀ou1 s1'. step s1 a1 = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have ou1: "ou1 = outOK" using step1 (*‹step s1 a1 = (ou1, s1')›*) PID1 (*‹PID ∈∈ postIDs s1›*) own1 (*‹owner s1 PID ∈∈ userIDs s1›*) unfolding a1 uid1 p1 (*goal: ‹ou1 = outOK›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have op1': "¬ open s1'" using step1 (*‹step (s1::state) (a1::act) = (ou1::out, s1'::state)›*) op1 (*‹¬ open s1›*) unfolding a1 ou1 open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s1' ∧ PID ∈∈ postIDs s1' ∧ (uid = admin s1' ∨ uid = owner s1' PID ∨ uid ∈∈ friendIDs s1' (owner s1' PID) ∨ vis s1' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have uid: "uid ∉ UIDs" unfolding uid (*goal: ‹owner s PID ∉ UIDs›*) using op (*‹¬ open s›*) PID (*‹PID ∈∈ postIDs s›*) own (*‹owner (s::state) (PID::postID) ∈∈ userIDs s›*) unfolding open_def (*goal: ‹owner s PID ∉ UIDs›*) by auto have pPID1': "post s1' PID = pst1" using step1 (*‹step s1 a1 = (ou1, s1')›*) unfolding a1 ou1 (*goal: ‹post (s1'::state) (PID::postID) = (pst1::post)›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) let ?trn1 = "Trans s1 a1 ou1 s1'" have "?iact" proof (standard) (*goals: 1. ‹step s1 ?a1.0 = (?ou1.0, ?s1')› 2. ‹φ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 3. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 4. ‹¬ γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s vl ?s1' ?vl1' ∨ Δ11 s vl ?s1' ?vl1'›*) show "step s1 a1 = (ou1, s1')" using step1 (*‹step (s1::state) (a1::act) = (ou1::out, s1'::state)›*) . next (*goals: 1. ‹φ (Trans s1 a1 ou1 s1')› 2. ‹consume (Trans s1 a1 ou1 s1') vl1 ?vl1'› 3. ‹¬ γ (Trans s1 a1 ou1 s1')› 4. ‹Δ1 s vl s1' ?vl1' ∨ Δ11 s vl s1' ?vl1'›*) show "φ": "φ ?trn1" unfolding "φ_def2"[OF step1] a1 ou1 (*goal: ‹φ (Trans s1 (Uact (uPost uid p PID pst1)) outOK s1')›*) by simp show "consume ?trn1 vl1 vll1" using "φ" (*‹φ (Trans s1 a1 ou1 s1')›*) unfolding vl1 consume_def v1 a1 (*goal: ‹if φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1') then PVal pst1 # vll1 ≠ [] ∧ f (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1') = hd (PVal pst1 # vll1) ∧ vll1 = tl (PVal pst1 # vll1) else vll1 = PVal pst1 # vll1›*) by auto next (*goals: 1. ‹¬ γ (Trans s1 a1 ou1 s1')› 2. ‹Δ1 s vl s1' vll1 ∨ Δ11 s vl s1' vll1›*) show "¬ γ ?trn1" using uid (*‹uid ∉ UIDs›*) unfolding a1 (*goal: ‹¬ γ (Trans (s1::state) (Uact (uPost (uid::userID) (p::password) (PID::postID) (pst1::post))) (ou1::out) (s1'::state))›*) by auto next (*goal: ‹Δ1 (s::state) (vl::value list) (s1'::state) (vll1::value list) ∨ Δ11 s vl s1' vll1›*) have "eqButPID s1 s1'" using Uact_uPaperC_step_eqButPID[OF _ step1] (*‹a1 = Uact (uPost ?uid ?p PID ?pst) ⟹ eqButPID s1 s1'›*) a1 (*‹a1 ≡ Uact (uPost uid p PID pst1)›*) by auto hence ss1': "eqButPID s s1'" using eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID s s1›*) by blast show "?Δ s vl s1' vll1" using PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) op (*‹¬ open s›*) ss1' (*‹eqButPID s s1'›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) map (*‹map tgtAPI (filter isPValS (vl::value list)) = map tgtAPI (filter isPValS (vl1::value list))›*) vlvl1 (*‹vl = [] ⟹ vl1 = []›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding "Δ1_def" vl1 v1 pPID1' (*goal: ‹PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ list_all (Not ∘ isOVal) vll1 ∧ map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vll1) ∧ (vl = [] ⟶ vll1 = []) ∧ eqButPID s s1' ∧ ¬ open s ∧ corrFrom pst1 vll1 ∨ Δ11 s vl s1' vll1›*) by auto qed thus "?thesis" (*goal: ‹iaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (vl::value list) (s1::state) (vl1::value list) ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) by simp next (*goals: 1. ‹⋀x21 x22. v1 = PValS x21 x22 ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1› 2. ‹⋀x3. v1 = OVal x3 ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) case (PValS aid1 pst1) (*‹v1 = PValS aid1 pst1›*) note v1 = PValS (*‹(v1::value) = PValS (aid1::apiID) (pst1::post)›*) have pPID1: "post s1 PID = pst1" using cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding vl1 v1 (*goal: ‹post s1 PID = pst1›*) by auto then obtain v and vll where vl: "vl = v # vll" (*goal: ‹(⋀v vll. vl = v # vll ⟹ thesis) ⟹ thesis›*) using map (*‹map tgtAPI (filter isPValS (vl::value list)) = map tgtAPI (filter isPValS (vl1::value list))›*) unfolding vl1 v1 (*goal: ‹(⋀v vll. vl = v # vll ⟹ thesis) ⟹ thesis›*) apply (cases vl) (*goals: 1. ‹⟦⋀v vll. vl = v # vll ⟹ thesis; post s1 PID = pst1; map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS (PValS aid1 pst1 # vll1)); vl = []⟧ ⟹ thesis› 2. ‹⋀a list. ⟦⋀v vll. vl = v # vll ⟹ thesis; post s1 PID = pst1; map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS (PValS aid1 pst1 # vll1)); vl = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have "?react" proof (standard) (*goal: ‹⋀a ou s' vl'. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'⟧ ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) by auto let ?trn1 = "Trans s1 a ou1 s1'" show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s (s1::state) (vl1::value list) a ou s' (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s (s1::state) (vl1::value list) a ou s' (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain f: "f ?trn = v" and vl': "vl' = vll" (*goal: ‹(⟦f (Trans (s::state) (a::act) (ou::out) (s'::state)) = (v::value); (vl'::value list) = (vll::value list)⟧ ⟹ thesis::bool) ⟹ thesis›*) using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding vl consume_def "φ_def2" (*goal: ‹(⟦f (Trans s a ou s') = v; vl' = vll⟧ ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (cases v) (*goals: 1. ‹⋀x1. v = PVal x1 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'› 3. ‹⋀x3. v = OVal x3 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (PVal pst) (*‹v = PVal pst›*) note v = PVal (*‹v = PVal pst›*) have vll: "vll ≠ []" using map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) unfolding vl1 v1 vl v (*goal: ‹vll ≠ []›*) by auto define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" have a: "a = Uact (uPost uid p PID pst)" using f_eq_PVal[OF step φ f [ unfolded v ]] (*‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) unfolding uid p (*goal: ‹(a::act) = Uact (uPost (owner (s::state) (PID::postID)) (pass s (owner s PID)) PID (pst::post))›*) . have "eqButPID s s'" using Uact_uPaperC_step_eqButPID[OF a step] (*‹eqButPID s s'›*) by auto hence s's1: "eqButPID s' s1" using eqButPID_sym (*‹eqButPID ?s ?s1.0 ⟹ eqButPID ?s1.0 ?s›*) eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID (s::state) (s1::state)›*) by blast have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹(a::act) = Uact (uPost (uid::userID) (p::password) (PID::postID) (pst::post))›*) op (*‹¬ open s›*) by auto have "?ignore" proof (standard) (*goals: 1. ‹¬ γ (Trans (s::state) (a::act) (ou::out) (s'::state))› 2. ‹Δ1 (s'::state) (vl'::value list) (s1::state) (vl1::value list) ∨ Δ11 s' vl' s1 vl1›*) show "γ": "¬ γ ?trn" using "step_open_φ_f_PVal_γ"[OF rs step PID op φ f [ unfolded v ]] (*‹¬ γ (Trans s a ou s')›*) . show "?Δ s' vl' s1 vl1" using lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) lvl (*‹list_all (Not ∘ isOVal) (vl::value list)›*) PID' (*‹PID ∈∈ postIDs s'›*) map (*‹map tgtAPI (filter isPValS (vl::value list)) = map tgtAPI (filter isPValS (vl1::value list))›*) s's1 (*‹eqButPID s' s1›*) op' (*‹¬ open s'›*) vll (*‹vll ≠ []›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding "Δ1_def" vl1 vl vl' v (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vll ∧ list_all (Not ∘ isOVal) (v1 # vll1) ∧ map tgtAPI (filter isPValS vll) = map tgtAPI (filter isPValS (v1 # vll1)) ∧ (vll = [] ⟶ v1 # vll1 = []) ∧ eqButPID s' s1 ∧ ¬ open s' ∧ corrFrom (post s1 PID) (v1 # vll1) ∨ Δ11 s' vll s1 (v1 # vll1)›*) by auto qed thus "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp next (*goals: 1. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀x3. v = OVal x3 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (PValS aid pst) (*‹v = PValS aid pst›*) note v = PValS (*‹v = PValS aid pst›*) define uid where uid: "uid ≡ admin s" define p where p: "p ≡ pass s uid" have a: "a = COMact (comSendPost (admin s) p aid PID)" using f_eq_PValS[OF step φ f [ unfolded v ]] (*‹a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)›*) unfolding uid p (*goal: ‹(a::act) = COMact (comSendPost (admin (s::state)) (pass s (admin s)) (aid::apiID) (PID::postID))›*) . have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹a = COMact (comSendPost (admin s) p aid PID)›*) op (*‹¬ open s›*) by auto have aid1: "aid1 = aid" using map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) unfolding vl1 v1 vl v (*goal: ‹(aid1::apiID) = (aid::apiID)›*) by simp have uid1: "uid = admin s1" and p1: "p = pass s1 uid" unfolding uid p (*goals: 1. ‹admin s = admin s1› 2. ‹pass s (admin s) = pass s1 (admin s)›*) using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) apply - (*goals: 1. ‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ admin s = admin s1› 2. ‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ pass s (admin s) = pass s1 (admin s)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have pPID1': "post s1' PID = pst1" using pPID1 (*‹post s1 PID = pst1›*) step1 (*‹step s1 a = (ou1, s1')›*) unfolding a (*goal: ‹post s1' PID = pst1›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) have uid: "uid ∉ UIDs" unfolding uid (*goal: ‹admin s ∉ UIDs›*) using op (*‹¬ open (s::state)›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) adm (*‹admin s ∈∈ userIDs s›*) unfolding open_def (*goal: ‹admin s ∉ UIDs›*) by auto have op1': "¬ open s1'" using step1 (*‹step s1 a = (ou1, s1')›*) op1 (*‹¬ open s1›*) unfolding a open_def (*goal: ‹¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs (s1'::state) ∧ (PID::postID) ∈∈ postIDs s1' ∧ (uid = admin s1' ∨ uid = owner s1' PID ∨ uid ∈∈ friendIDs s1' (owner s1' PID) ∨ vis s1' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*) com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "φ ?trn1" using "eqButPID_step_φ_imp"[OF ss1 step step1 φ] (*‹φ (Trans s1 a ou1 s1')›*) . have ou1: "ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)" using "φ1" (*‹φ (Trans s1 a ou1 s1')›*) step1 (*‹step s1 a = (ou1, s1')›*) adm1 (*‹admin s1 ∈∈ userIDs s1›*) PID1 (*‹PID ∈∈ postIDs s1›*) unfolding a (*goal: ‹ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)›*) apply (cases ou1) (*goals: 1. ‹⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outOK⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 2. ‹⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outErr⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 3. ‹⋀x3. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outBool x3⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 4. ‹⋀x4. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outName x4⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 5. ‹⋀x5. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outPost x5⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 6. ‹⋀x6. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outVis x6⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 7. ‹⋀x7. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outReq x7⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 8. ‹⋀x8. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outUID x8⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 9. ‹⋀x9. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outUIDL x9⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 10. ‹⋀x10. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDL x10⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 11. ‹⋀x11. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDBL x11⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 12. ‹⋀x12. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outUIDPIDL x12⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 13. ‹⋀x13. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDPIDL x13⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 14. ‹⋀x14. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDUIDL x14⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 15. ‹⋀x15. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendServerReq x15⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 16. ‹⋀x16. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_connectClient x16⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 17. ‹⋀x17. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendPost x17⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 18. ‹⋀x18. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendCreateOFriend x18⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 19. ‹⋀x19. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendDeleteOFriend x19⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› discuss goal 1*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 2*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 3*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 4*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 5*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 6*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 7*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 8*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 9*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 10*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 11*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 12*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 13*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 14*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 15*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 16*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 17*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 18*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 19*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*proven 19 subgoals*) . have f1: "f ?trn1 = v1" using "φ1" (*‹φ (Trans s1 a ou1 s1')›*) unfolding "φ_def2"[OF step1] v1 a ou1 aid1 pPID1 (*goal: ‹f (Trans s1 (COMact (comSendPost (admin s) p aid PID)) (O_sendPost (aid, clientPass s1 aid, PID, pst1, owner s1 PID, vis s1 PID)) s1') = PValS aid pst1›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ1 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list) ∨ Δ11 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ1 s' vl' s1' ?vl1' ∨ Δ11 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vll1" using "φ1" (*‹φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*) unfolding consume_def vl1 f1 (*goal: ‹if φ (Trans s1 a ou1 s1') then v1 # vll1 ≠ [] ∧ v1 = hd (v1 # vll1) ∧ vll1 = tl (v1 # vll1) else vll1 = v1 # vll1›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) a (ou1::out) (s1'::state))› 2. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a (ou1::out) (s1'::state))› 3. ‹Δ1 (s'::state) (vl'::value list) (s1'::state) (vll1::value list) ∨ Δ11 s' vl' s1' vll1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ1 s' vl' s1' vll1 ∨ Δ11 s' vl' s1' vll1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ1 (s'::state) (vl'::value list) (s1'::state) (vll1::value list) ∨ Δ11 s' vl' s1' vll1›*) show "?Δ s' vl' s1' vll1" proof (cases "vll = []") (*goals: 1. ‹vll = [] ⟹ Δ1 s' vl' s1' vll1 ∨ Δ11 s' vl' s1' vll1› 2. ‹vll ≠ [] ⟹ Δ1 s' vl' s1' vll1 ∨ Δ11 s' vl' s1' vll1›*) case True (*‹(vll::value list) = []›*) note vll = True (*‹(vll::value list) = []›*) hence "filter isPValS vll1 = []" using map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) unfolding vl vl1 v v1 (*goal: ‹filter isPValS vll1 = []›*) by simp hence lvl1: "list_all isPVal vll1" using filter_list_all_isPVal_isOVal (*‹⟦list_all (Not ∘ isOVal) ?ul; filter isPValS ?ul = []⟧ ⟹ list_all isPVal ?ul›*) lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) unfolding vl1 v1 (*goal: ‹list_all isPVal vll1›*) by auto hence "Δ11 s' vl' s1' vll1" using s's1' (*‹eqButPID s' s1'›*) op1' (*‹¬ open (s1'::state)›*) op' (*‹¬ open s'›*) PID' (*‹PID ∈∈ postIDs s'›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) lvl1 (*‹list_all isPVal vll1›*) map (*‹map tgtAPI (filter isPValS (vl::value list)) = map tgtAPI (filter isPValS (vl1::value list))›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) pPID1 (*‹post s1 PID = pst1›*) pPID1' (*‹post s1' PID = pst1›*) unfolding "Δ11_def" vl vl' vl1 v v1 vll (*goal: ‹PID ∈∈ postIDs s' ∧ [] = [] ∧ list_all isPVal vll1 ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) vll1›*) by auto thus "?thesis" (*goal: ‹Δ1 (s'::state) (vl'::value list) (s1'::state) (vll1::value list) ∨ Δ11 s' vl' s1' vll1›*) by auto next (*goal: ‹vll ≠ [] ⟹ Δ1 s' vl' s1' vll1 ∨ Δ11 s' vl' s1' vll1›*) case False (*‹vll ≠ []›*) note vll = False (*‹vll ≠ []›*) hence "Δ1 s' vl' s1' vll1" using s's1' (*‹eqButPID s' s1'›*) op1' (*‹¬ open s1'›*) op' (*‹¬ open s'›*) PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) pPID1 (*‹post s1 PID = pst1›*) pPID1' (*‹post s1' PID = pst1›*) unfolding "Δ1_def" vl vl' vl1 v v1 (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vll ∧ list_all (Not ∘ isOVal) vll1 ∧ map tgtAPI (filter isPValS vll) = map tgtAPI (filter isPValS vll1) ∧ (vll = [] ⟶ vll1 = []) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) vll1›*) by auto thus "?thesis" (*goal: ‹Δ1 s' vl' s1' vll1 ∨ Δ11 s' vl' s1' vll1›*) by auto qed qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) using vl (*‹(vl::value list) = (v::value) # (vll::value list)›*) by simp qed (insert lvl (*‹list_all (Not ∘ isOVal) vl›*) vl (*‹vl = v # vll›*), auto) (*solved the remaining goal: ‹⋀x3::bool. (v::value) = OVal x3 ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) next (*goal: ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ φ (Trans s a ou s')›*) note "φ" = False (*‹¬ φ (Trans s a ou s')›*) hence vl': "vl' = vl" using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹vl' = vl›*) by auto obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "¬ φ ?trn1" using "φ" (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) ss1 (*‹eqButPID s s1›*) by (simp add: eqButPID_step_φ (*‹⟦eqButPID ?s ?s1.0; step ?s ?a = (?ou, ?s'); step ?s1.0 ?a = (?ou1.0, ?s1')⟧ ⟹ φ (Trans ?s ?a ?ou ?s') = φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*) step (*‹step s a = (ou, s')›*) step1 (*‹step s1 a = (ou1, s1')›*)) have pPID1': "post s1' PID = pst1" using PID1 (*‹PID ∈∈ postIDs s1›*) pPID1 (*‹post s1 PID = pst1›*) step1 (*‹step s1 a = (ou1, s1')›*) "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) apply (cases a) (*goal: ‹post s1' PID = pst1›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Sact x1⟧ ⟹ post s1' PID = pst1›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s1' PID = pst1› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s1' PID = pst1› 3. ‹⋀x31 x32 x33. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s1' PID = pst1› 4. ‹⋀x41 x42 x43 x44. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s1' PID = pst1› 5. ‹⋀x51 x52 x53. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s1' PID = pst1› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Dact x3⟧ ⟹ post s1' PID = pst1›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s1' PID = pst1› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s1' PID = pst1› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s1' PID = pst1› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s1' PID = pst1› 2. ‹⋀x21 x22. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s1' PID = pst1› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s1' PID = pst1› 4. ‹⋀x41 x42. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s1' PID = pst1› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s1' PID = pst1› 6. ‹⋀x61 x62 x63 x64. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s1' PID = pst1› 7. ‹⋀x71 x72 x73 x74. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s1' PID = pst1› 8. ‹⋀x81 x82 x83 x84. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s1' PID = pst1› 9. ‹⋀x91 x92 x93 x94. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s1' PID = pst1› 10. ‹⋀x101 x102 x103 x104. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s1' PID = pst1› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step1] (*goal: ‹¬ open s'›*) apply (cases a) (*goal: ‹¬ open s'›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ φ (Trans s a ou s'); ¬ open s; a = Sact x1⟧ ⟹ ¬ open s'›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for by auto subgoal for by auto subgoal for x4 using "φ_def2" (*‹step (?s::state) (?a::act) = (?ou::out, ?s'::state) ⟹ φ (Trans ?s ?a ?ou ?s') = ((∃(uid::userID) (p::password) pst::post. ?a = Uact (uPost uid p (PID::postID) pst) ∧ ?ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. ?a = COMact (comSendPost uid p aid PID) ∧ ?ou ≠ outErr) ∨ open ?s ≠ open ?s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) by blast subgoal for by auto subgoal for by auto subgoal for using "φ_def2" (*‹step ?s ?a = (?ou, ?s') ⟹ φ (Trans ?s ?a ?ou ?s') = ((∃uid p pst. ?a = Uact (uPost uid p PID pst) ∧ ?ou = outOK) ∨ (∃uid p aid. ?a = COMact (comSendPost uid p aid PID) ∧ ?ou ≠ outErr) ∨ open ?s ≠ open ?s')›*) "φ" (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) by blast . have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s' vl' ?s1' ?vl1' ∨ Δ11 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ1 s' vl' s1' ?vl1' ∨ Δ11 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) unfolding consume_def (*goal: ‹if φ (Trans s1 a ou1 s1') then vl1 ≠ [] ∧ f (Trans s1 a ou1 s1') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ1 s' vl' s1' vl1 ∨ Δ11 s' vl' s1' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a (ou1::out) (s1'::state))› 2. ‹Δ1 (s'::state) (vl'::value list) (s1'::state) (vl1::value list) ∨ Δ11 s' vl' s1' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ1 s' vl' s1' vl1 ∨ Δ11 s' vl' s1' vl1›*) have "Δ1 s' vl' s1' vl1" using s's1' (*‹eqButPID s' s1'›*) PID' (*‹PID ∈∈ postIDs s'›*) pPID1 (*‹post s1 PID = pst1›*) pPID1' (*‹post s1' PID = pst1›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) op' (*‹¬ open (s'::state)›*) unfolding "Δ1_def" vl vl' (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) (v # vll) ∧ list_all (Not ∘ isOVal) vl1 ∧ map tgtAPI (filter isPValS (v # vll)) = map tgtAPI (filter isPValS vl1) ∧ (v # vll = [] ⟶ vl1 = []) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) vl1›*) by auto thus "?Δ s' vl' s1' vl1" by simp qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) using vlvl1 (*‹vl = [] ⟹ vl1 = []›*) by simp qed (insert lvl1 (*‹list_all (Not ∘ isOVal) vl1›*) vl1 (*‹vl1 = v1 # vll1›*), auto) (*solved the remaining goal: ‹⋀x3. v1 = OVal x3 ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) next (*goal: ‹vl1 = [] ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) case Nil (*‹vl1 = []›*) note vl1 = Nil (*‹vl1 = []›*) have "?react" proof (standard) (*goal: ‹⋀a ou s' vl'. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'⟧ ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" assume step: "step s a = (ou, s')" and T: "¬ T ?trn" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹¬ T (Trans (s::state) (a::act) (ou::out) (s'::state))› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹PID ∈∈ postIDs s'›*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto let ?trn1 = "Trans s1 a ou1 s1'" show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (cases "∃ uid p pstt. a = Uact (uPost uid p PID pstt) ∧ ou = outOK") (*goals: 1. ‹∃(uid::userID) (p::password) pstt::post. (a::act) = Uact (uPost uid p (PID::postID) pstt) ∧ (ou::out) = outOK ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) a ou (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹∄(uid::userID) (p::password) pstt::post. (a::act) = Uact (uPost uid p (PID::postID) pstt) ∧ (ou::out) = outOK ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) a ou (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹∃uid p pstt. a = Uact (uPost uid p PID pstt) ∧ ou = outOK›*) then obtain uid and p and pstt where a: "a = Uact (uPost uid p PID pstt)" and ou: "ou = outOK" (*goal: ‹(⋀uid p pstt. ⟦a = Uact (uPost uid p PID pstt); ou = outOK⟧ ⟹ thesis) ⟹ thesis›*) by auto hence "φ": "φ ?trn" unfolding "φ_def2"[OF step] (*goal: ‹(∃(uid::userID) (p::password) pst::post. (a::act) = Uact (uPost uid p (PID::postID) pst) ∧ (ou::out) = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open (s::state) ≠ open (s'::state)›*) by auto then obtain v where vl: "vl = v # vl'" and f: "f ?trn = v" (*goal: ‹(⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) using c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) unfolding consume_def "φ_def2" (*goal: ‹(⋀v::value. ⟦(vl::value list) = v # (vl'::value list); f (Trans (s::state) (a::act) (ou::out) (s'::state)) = v⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (cases vl) (*goals: 1. ‹⟦⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain pst where v: "v = PVal pst" (*goal: ‹(⋀pst. v = PVal pst ⟹ thesis) ⟹ thesis›*) using map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) lvl (*‹list_all (Not ∘ isOVal) (vl::value list)›*) unfolding vl vl1 (*goal: ‹(⋀pst. v = PVal pst ⟹ thesis) ⟹ thesis›*) apply (cases v) (*goals: 1. ‹⋀x1. ⟦⋀pst. v = PVal pst ⟹ thesis; map tgtAPI (filter isPValS (v # vl')) = map tgtAPI (filter isPValS []); list_all (Not ∘ isOVal) (v # vl'); v = PVal x1⟧ ⟹ thesis› 2. ‹⋀x21 x22. ⟦⋀pst. v = PVal pst ⟹ thesis; map tgtAPI (filter isPValS (v # vl')) = map tgtAPI (filter isPValS []); list_all (Not ∘ isOVal) (v # vl'); v = PValS x21 x22⟧ ⟹ thesis› 3. ‹⋀x3. ⟦⋀pst. v = PVal pst ⟹ thesis; map tgtAPI (filter isPValS (v # vl')) = map tgtAPI (filter isPValS []); list_all (Not ∘ isOVal) (v # vl'); v = OVal x3⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have pstt: "pstt = pst" using f (*‹f (Trans s a ou s') = v›*) unfolding a v (*goal: ‹pstt = pst›*) by auto have uid: "uid ∉ UIDs" using step (*‹step s a = (ou, s')›*) op (*‹¬ open s›*) PID (*‹PID ∈∈ postIDs s›*) unfolding a ou open_def (*goal: ‹uid ∉ UIDs›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have "eqButPID s s'" using Uact_uPaperC_step_eqButPID[OF a step] (*‹eqButPID s s'›*) by auto hence s's1: "eqButPID s' s1" using eqButPID_sym (*‹eqButPID (?s::state) (?s1.0::state) ⟹ eqButPID ?s1.0 ?s›*) eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID s s1›*) by blast have op': "¬ open s'" using step (*‹step s a = (ou, s')›*) PID' (*‹PID ∈∈ postIDs s'›*) op (*‹¬ open s›*) unfolding a ou open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have "?ignore" proof (standard) (*goals: 1. ‹¬ γ (Trans s a ou s')› 2. ‹Δ1 s' vl' s1 vl1 ∨ Δ11 s' vl' s1 vl1›*) show "¬ γ ?trn" unfolding a (*goal: ‹¬ γ (Trans s (Uact (uPost uid p PID pstt)) ou s')›*) using uid (*‹uid ∉ UIDs›*) by auto next (*goal: ‹Δ1 s' vl' s1 vl1 ∨ Δ11 s' vl' s1 vl1›*) show "?Δ s' vl' s1 vl1" using PID' (*‹PID ∈∈ postIDs s'›*) s's1 (*‹eqButPID s' s1›*) op' (*‹¬ open s'›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) unfolding "Δ1_def" vl1 vl (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl' ∧ list_all (Not ∘ isOVal) [] ∧ map tgtAPI (filter isPValS vl') = map tgtAPI (filter isPValS []) ∧ (vl' = [] ⟶ [] = []) ∧ eqButPID s' s1 ∧ ¬ open s' ∧ corrFrom (post s1 PID) [] ∨ Δ11 s' vl' s1 []›*) by auto qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp next (*goal: ‹∄(uid::userID) (p::password) pstt::post. (a::act) = Uact (uPost uid p (PID::postID) pstt) ∧ (ou::out) = outOK ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) a ou (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹∄uid p pstt. a = Uact (uPost uid p PID pstt) ∧ ou = outOK›*) note a = False (*‹∄uid p pstt. a = Uact (uPost uid p PID pstt) ∧ ou = outOK›*) { assume "φ": "φ ?trn" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) then obtain v and vl' where vl: "vl = v # vl'" and f: "f ?trn = v" (*goal: ‹(⋀v vl'. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹(⋀v vl'. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) apply (cases vl) (*goals: 1. ‹⟦⋀v vl'. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀v vl'. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain pst where v: "v = PVal pst" (*goal: ‹(⋀pst. v = PVal pst ⟹ thesis) ⟹ thesis›*) using map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) unfolding vl vl1 (*goal: ‹(⋀pst. v = PVal pst ⟹ thesis) ⟹ thesis›*) apply (cases v) (*goals: 1. ‹⋀x1. ⟦⋀pst. v = PVal pst ⟹ thesis; map tgtAPI (filter isPValS (v # vl')) = map tgtAPI (filter isPValS []); list_all (Not ∘ isOVal) (v # vl'); v = PVal x1⟧ ⟹ thesis› 2. ‹⋀x21 x22. ⟦⋀pst. v = PVal pst ⟹ thesis; map tgtAPI (filter isPValS (v # vl')) = map tgtAPI (filter isPValS []); list_all (Not ∘ isOVal) (v # vl'); v = PValS x21 x22⟧ ⟹ thesis› 3. ‹⋀x3. ⟦⋀pst. v = PVal pst ⟹ thesis; map tgtAPI (filter isPValS (v # vl')) = map tgtAPI (filter isPValS []); list_all (Not ∘ isOVal) (v # vl'); v = OVal x3⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have False using f (*‹f (Trans s a ou s') = v›*) f_eq_PVal[OF step φ, of pst] (*‹f (Trans s a ou s') = PVal pst ⟹ a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) a (*‹∄uid p pstt. a = Uact (uPost uid p PID pstt) ∧ ou = outOK›*) "φ" (*‹φ (Trans s a ou s')›*) v (*‹v = PVal pst›*) by auto } hence "φ": "¬ φ ?trn" by auto have "φ1": "¬ φ ?trn1" by (metis φ (*‹¬ φ (Trans s a ou s')›*) eqButPID_step_φ (*‹⟦eqButPID ?s ?s1.0; step ?s ?a = (?ou, ?s'); step ?s1.0 ?a = (?ou1.0, ?s1')⟧ ⟹ φ (Trans ?s ?a ?ou ?s') = φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*) step (*‹step s a = (ou, s')›*) ss1 (*‹eqButPID s s1›*) step1 (*‹step s1 a = (ou1, s1')›*)) have op': "¬ open s'" using a (*‹∄uid p pstt. a = Uact (uPost uid p PID pstt) ∧ ou = outOK›*) op (*‹¬ open s›*) "φ" (*‹¬ φ (Trans s a ou s')›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) by auto have vl': "vl' = vl" using c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) "φ" (*‹¬ φ (Trans s a ou s')›*) unfolding consume_def (*goal: ‹vl' = vl›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . have op1': "¬ open s1'" using op' (*‹¬ open s'›*) eqButPID_open[OF s's1'] (*‹open s' = open s1'›*) by simp have "⋀ uid p pst. e_updatePost s1 uid p PID pst ⟷ e_updatePost s uid p PID pst" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) unfolding u_defs (*goal: ‹⋀uid p pst. (IDsOK s1 [uid] [PID] [] [] ∧ pass s1 uid = p ∧ owner s1 PID = uid) = (IDsOK s [uid] [PID] [] [] ∧ pass s uid = p ∧ owner s PID = uid)›*) by auto hence ou1: "⋀ uid p pst. a = Uact (uPost uid p PID pst) ⟹ ou1 = ou" using step (*‹step s a = (ou, s')›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) by auto have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s' vl' ?s1' ?vl1' ∨ Δ11 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ1 s' vl' s1' ?vl1' ∨ Δ11 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) unfolding consume_def (*goal: ‹if φ (Trans s1 a ou1 s1') then vl1 ≠ [] ∧ f (Trans s1 a ou1 s1') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ1 s' vl' s1' vl1 ∨ Δ11 s' vl' s1' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ1 s' vl' s1' vl1 ∨ Δ11 s' vl' s1' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ1 s' vl' s1' vl1 ∨ Δ11 s' vl' s1' vl1›*) show "?Δ s' vl' s1' vl1" using s's1' (*‹eqButPID s' s1'›*) op' (*‹¬ open s'›*) PID' (*‹PID ∈∈ postIDs s'›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) map (*‹map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS vl1)›*) unfolding "Δ1_def" vl' vl1 (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl ∧ list_all (Not ∘ isOVal) [] ∧ map tgtAPI (filter isPValS vl) = map tgtAPI (filter isPValS []) ∧ (vl = [] ⟶ [] = []) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) [] ∨ Δ11 s' vl s1' []›*) by auto qed thus "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) (s::state) (vl::value list) (s1::state) (vl1::value list) ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ11 s vl s1 vl1) s vl s1 vl1›*) using vlvl1 (*‹vl = [] ⟹ vl1 = []›*) by simp qed qed lemma unwind_cont_Δ11: "unwind_cont Δ11 {Δ11}" apply rule (*goal: ‹unwind_cont Δ11 {Δ11}›*) proof (simp) (*goal: ‹⋀s vl s1 vl1. ⟦reachNT s; reach s1; Δ11 s vl s1 vl1⟧ ⟹ iaction Δ11 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ11 s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ11 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ11 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ11 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) hence vl: "vl = []" and lvl1: "list_all isPVal vl1" and rs: "reach s" and ss1: "eqButPID s s1" and op: "¬ open s" and PID: "PID ∈∈ postIDs s" and cor1: "corrFrom (post s1 PID) vl1" using reachNT_reach (*‹reachNT ?s ⟹ reach ?s›*) unfolding "Δ11_def" (*goals: 1. ‹vl = []› 2. ‹list_all isPVal vl1› 3. ‹reach s› 4. ‹eqButPID s s1› 5. ‹¬ open s› 6. ‹PID ∈∈ postIDs s› 7. ‹corrFrom (post s1 PID) vl1›*) apply - (*goals: 1. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ vl = []› 2. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ list_all isPVal vl1› 3. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ reach s› 4. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ eqButPID s s1› 5. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ ¬ open s› 6. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ PID ∈∈ postIDs s› 7. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ vl = [] ∧ list_all isPVal vl1 ∧ eqButPID s s1 ∧ ¬ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ corrFrom (post s1 PID) vl1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . have PID1: "PID ∈∈ postIDs s1" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) PID (*‹PID ∈∈ postIDs s›*) by auto have own: "owner s PID ∈ set (userIDs s)" using reach_owner_userIDs[OF rs PID] (*‹owner s PID ∈∈ userIDs s›*) . hence own1: "owner s1 PID ∈ set (userIDs s1)" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) by auto have adm: "admin s ∈ set (userIDs s)" using reach_admin_userIDs[OF rs own] (*‹admin s ∈∈ userIDs s›*) . hence adm1: "admin s1 ∈ set (userIDs s1)" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) by auto have op1: "¬ open s1" using op (*‹¬ open s›*) ss1 (*‹eqButPID s s1›*) eqButPID_open (*‹eqButPID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) by auto show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (cases vl1) (*goals: 1. ‹vl1 = [] ⟹ iaction Δ11 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ11 s vl s1 vl1› 2. ‹⋀a list. vl1 = a # list ⟹ iaction Δ11 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ11 s vl s1 vl1›*) case (Cons v1 vll1) (*‹vl1 = v1 # vll1›*) note vl1 = Cons (*‹vl1 = v1 # vll1›*) then obtain pst1 where v1: "v1 = PVal pst1" (*goal: ‹(⋀pst1::post. (v1::value) = PVal pst1 ⟹ thesis::bool) ⟹ thesis›*) using lvl1 (*‹list_all isPVal (vl1::value list)›*) unfolding vl1 (*goal: ‹(⋀pst1::post. (v1::value) = PVal pst1 ⟹ thesis::bool) ⟹ thesis›*) apply (cases v1) (*goals: 1. ‹⋀x1. ⟦⋀pst1. v1 = PVal pst1 ⟹ thesis; v1 # vll1 = v1 # vll1; list_all isPVal (v1 # vll1); v1 = PVal x1⟧ ⟹ thesis› 2. ‹⋀x21 x22. ⟦⋀pst1. v1 = PVal pst1 ⟹ thesis; v1 # vll1 = v1 # vll1; list_all isPVal (v1 # vll1); v1 = PValS x21 x22⟧ ⟹ thesis› 3. ‹⋀x3. ⟦⋀pst1. v1 = PVal pst1 ⟹ thesis; v1 # vll1 = v1 # vll1; list_all isPVal (v1 # vll1); v1 = OVal x3⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" define a1 where a1: "a1 ≡ Uact (uPost uid p PID pst1)" have uid1: "uid = owner s1 PID" and p1: "p = pass s1 uid" unfolding uid p (*goals: 1. ‹owner s PID = owner s1 PID› 2. ‹pass s (owner s PID) = pass s1 (owner s PID)›*) using eqButPID_stateSelectors[OF ss1] (*‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) apply - (*goals: 1. ‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ owner s PID = owner s1 PID› 2. ‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ pass s (owner s PID) = pass s1 (owner s PID)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a1 = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a1 = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a1") (*goal: ‹(⋀ou1 s1'. step s1 a1 = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have ou1: "ou1 = outOK" using step1 (*‹step s1 a1 = (ou1, s1')›*) PID1 (*‹PID ∈∈ postIDs s1›*) own1 (*‹owner s1 PID ∈∈ userIDs s1›*) unfolding a1 uid1 p1 (*goal: ‹ou1 = outOK›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have op1': "¬ open s1'" using step1 (*‹step s1 a1 = (ou1, s1')›*) op1 (*‹¬ open s1›*) unfolding a1 ou1 open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s1' ∧ PID ∈∈ postIDs s1' ∧ (uid = admin s1' ∨ uid = owner s1' PID ∨ uid ∈∈ friendIDs s1' (owner s1' PID) ∨ vis s1' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have uid: "uid ∉ UIDs" unfolding uid (*goal: ‹owner s PID ∉ UIDs›*) using op (*‹¬ open s›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) own (*‹owner s PID ∈∈ userIDs s›*) unfolding open_def (*goal: ‹owner (s::state) (PID::postID) ∉ (UIDs::userID set)›*) by auto have pPID1': "post s1' PID = pst1" using step1 (*‹step (s1::state) (a1::act) = (ou1::out, s1'::state)›*) unfolding a1 ou1 (*goal: ‹post (s1'::state) (PID::postID) = (pst1::post)›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) let ?trn1 = "Trans s1 a1 ou1 s1'" have "?iact" proof (standard) (*goals: 1. ‹step s1 ?a1.0 = (?ou1.0, ?s1')› 2. ‹φ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 3. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 4. ‹¬ γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ11 s vl ?s1' ?vl1'›*) show "step s1 a1 = (ou1, s1')" using step1 (*‹step (s1::state) (a1::act) = (ou1::out, s1'::state)›*) . next (*goals: 1. ‹φ (Trans (s1::state) (a1::act) (ou1::out) (s1'::state))› 2. ‹consume (Trans (s1::state) (a1::act) (ou1::out) (s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹¬ γ (Trans (s1::state) (a1::act) (ou1::out) (s1'::state))› 4. ‹Δ11 (s::state) (vl::value list) (s1'::state) (?vl1'::value list)›*) show "φ": "φ ?trn1" unfolding "φ_def2"[OF step1] a1 ou1 (*goal: ‹φ (Trans s1 (Uact (uPost uid p PID pst1)) outOK s1')›*) by simp show "consume ?trn1 vl1 vll1" using "φ" (*‹φ (Trans s1 a1 ou1 s1')›*) unfolding vl1 consume_def v1 a1 (*goal: ‹if φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1') then PVal pst1 # vll1 ≠ [] ∧ f (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1') = hd (PVal pst1 # vll1) ∧ vll1 = tl (PVal pst1 # vll1) else vll1 = PVal pst1 # vll1›*) by auto next (*goals: 1. ‹¬ γ (Trans s1 a1 ou1 s1')› 2. ‹Δ11 s vl s1' vll1›*) show "¬ γ ?trn1" using uid (*‹uid ∉ UIDs›*) unfolding a1 (*goal: ‹¬ γ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1')›*) by auto next (*goal: ‹Δ11 s vl s1' vll1›*) have "eqButPID s1 s1'" using Uact_uPaperC_step_eqButPID[OF _ step1] (*‹a1 = Uact (uPost ?uid ?p PID ?pst) ⟹ eqButPID s1 s1'›*) a1 (*‹a1::act ≡ Uact (uPost (uid::userID) (p::password) (PID::postID) (pst1::post))›*) by auto hence ss1': "eqButPID s s1'" using eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID s s1›*) by blast show "?Δ s vl s1' vll1" using PID (*‹PID ∈∈ postIDs s›*) op (*‹¬ open s›*) ss1' (*‹eqButPID s s1'›*) lvl1 (*‹list_all isPVal (vl1::value list)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding "Δ11_def" vl1 v1 vl pPID1' (*goal: ‹PID ∈∈ postIDs s ∧ [] = [] ∧ list_all isPVal vll1 ∧ eqButPID s s1' ∧ ¬ open s ∧ corrFrom pst1 vll1›*) by auto qed thus "?thesis" (*goal: ‹iaction Δ11 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ11 s vl s1 vl1›*) by simp next (*goal: ‹vl1 = [] ⟹ iaction Δ11 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ11 s vl s1 vl1›*) case Nil (*‹vl1 = []›*) note vl1 = Nil (*‹vl1 = []›*) have "?react" proof (standard) (*goal: ‹⋀a ou s' vl'. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'⟧ ⟹ match Δ11 s s1 vl1 a ou s' vl' ∨ ignore Δ11 s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹PID ∈∈ postIDs s'›*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) by auto let ?trn1 = "Trans s1 a ou1 s1'" have "φ": "¬ φ ?trn" using c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) unfolding consume_def vl (*goal: ‹¬ φ (Trans s a ou s')›*) by auto show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (-) (*goal: ‹match Δ11 s s1 vl1 a ou s' vl' ∨ ignore Δ11 s s1 vl1 a ou s' vl'›*) have vl': "vl' = vl" using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding vl consume_def (*goal: ‹vl' = []›*) by auto obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "¬ φ ?trn1" using "φ" (*‹¬ φ (Trans s a ou s')›*) ss1 (*‹eqButPID (s::state) (s1::state)›*) by (simp add: eqButPID_step_φ (*‹⟦eqButPID (?s::state) (?s1.0::state); step ?s (?a::act) = (?ou::out, ?s'::state); step ?s1.0 ?a = (?ou1.0::out, ?s1'::state)⟧ ⟹ φ (Trans ?s ?a ?ou ?s') = φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*) step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*)) have pPID1': "post s1' PID = post s1 PID" using PID1 (*‹(PID::postID) ∈∈ postIDs (s1::state)›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) "φ1" (*‹¬ φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*) apply (cases a) (*goal: ‹post s1' PID = post s1 PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Sact x1⟧ ⟹ post s1' PID = post s1 PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s1' PID = post s1 PID› 4. ‹⋀x41 x42 x43 x44. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s1' PID = post s1 PID› 5. ‹⋀x51 x52 x53. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Dact x3⟧ ⟹ post s1' PID = post s1 PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀(x11::userID) (x12::password) (x13::password) (x14::name) x15::inform. ⟦(PID::postID) ∈∈ postIDs (s1::state); step s1 (a::act) = (ou1::out, s1'::state); ¬ φ (Trans s1 a ou1 s1'); a = Uact (x4::uActt); x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀(x21::userID) (x22::password) (x23::postID) x24::post. ⟦(PID::postID) ∈∈ postIDs (s1::state); step s1 (a::act) = (ou1::out, s1'::state); ¬ φ (Trans s1 a ou1 s1'); a = Uact (x4::uActt); x4 = uPost x21 x22 x23 x24⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀(x31::userID) (x32::password) (x33::postID) x34::vis. ⟦(PID::postID) ∈∈ postIDs (s1::state); step s1 (a::act) = (ou1::out, s1'::state); ¬ φ (Trans s1 a ou1 s1'); a = Uact (x4::uActt); x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s1' PID = post s1 PID› 4. ‹⋀x41 x42. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s1' PID = post s1 PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s1' PID = post s1 PID› 6. ‹⋀x61 x62 x63 x64. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s1' PID = post s1 PID› 7. ‹⋀x71 x72 x73 x74. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s1' PID = post s1 PID› 8. ‹⋀x81 x82 x83 x84. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s1' PID = post s1 PID› 9. ‹⋀x91 x92 x93 x94. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s1' PID = post s1 PID› 10. ‹⋀x101 x102 x103 x104. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) by auto have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ11 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step s1 a = (ou1, s1')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ11 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) unfolding consume_def (*goal: ‹if φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state)) then (vl1::value list) ≠ [] ∧ f (Trans s1 a ou1 s1') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ11 s' vl' s1' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a (ou1::out) (s1'::state))› 2. ‹Δ11 (s'::state) (vl'::value list) (s1'::state) (vl1::value list)›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ11 (s'::state) (vl'::value list) (s1'::state) (vl1::value list)›*) have "?Δ s' vl' s1' vl1" using s's1' (*‹eqButPID s' s1'›*) PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) pPID1' (*‹post s1' PID = post s1 PID›*) lvl1 (*‹list_all isPVal vl1›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) op' (*‹¬ open s'›*) unfolding "Δ11_def" vl vl' (*goal: ‹PID ∈∈ postIDs s' ∧ [] = [] ∧ list_all isPVal vl1 ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) vl1›*) by auto thus "?Δ s' vl' s1' vl1" by simp qed thus "?thesis" (*goal: ‹match Δ11 (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore Δ11 s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction Δ11 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ11 s vl s1 vl1›*) using vl1 (*‹(vl1::value list) = []›*) by simp qed qed lemma unwind_cont_Δ31: "unwind_cont Δ31 {Δ31,Δ32}" apply rule (*goal: ‹unwind_cont Δ31 {Δ31, Δ32}›*) proof (simp) (*goal: ‹⋀s vl s1 vl1. ⟦reachNT s; reach s1; Δ31 s vl s1 vl1⟧ ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ31 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ31 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) then obtain ul and ul1 and sul and vll and vll1 where lul: "list_all (Not ∘ isOVal) ul" and lul1: "list_all (Not ∘ isOVal) ul1" and map: "map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)" and rs: "reach s" and ss1: "eqButPID s s1" and op: "¬ open s" and PID: "PID ∈∈ postIDs s" and cor1: "corrFrom (post s1 PID) vl1" and ful: "ul ≠ []" and ful1: "ul1 ≠ []" and lastul: "isPVal (last ul)" and ulul1: "last ul = last ul1" and lsul: "list_all isPValS sul" and vl: "vl = ul @ sul @ OVal True # vll" and vl1: "vl1 = ul1 @ sul @ OVal True # vll1" and BO: "BO vll vll1" (*goal: ‹(⋀ul ul1 sul vll vll1. ⟦list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); reach s; eqButPID s s1; ¬ open s; PID ∈∈ postIDs s; corrFrom (post s1 PID) vl1; ul ≠ []; ul1 ≠ []; isPVal (last ul); last ul = last ul1; list_all isPValS sul; vl = ul @ sul @ OVal True # vll; vl1 = ul1 @ sul @ OVal True # vll1; BO vll vll1⟧ ⟹ thesis) ⟹ thesis›*) using reachNT_reach (*‹reachNT ?s ⟹ reach ?s›*) unfolding "Δ31_def" (*goal: ‹(⋀ul ul1 sul vll vll1. ⟦list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); reach s; eqButPID s s1; ¬ open s; PID ∈∈ postIDs s; corrFrom (post s1 PID) vl1; ul ≠ []; ul1 ≠ []; isPVal (last ul); last ul = last ul1; list_all isPValS sul; vl = ul @ sul @ OVal True # vll; vl1 = ul1 @ sul @ OVal True # vll1; BO vll vll1⟧ ⟹ thesis) ⟹ thesis›*) by auto have ulNE: "ul ≠ []" and ul1NE: "ul1 ≠ []" using ful (*‹ul ≠ []›*) ful1 (*‹ul1 ≠ []›*) apply - (*goals: 1. ‹⟦ul ≠ []; ul1 ≠ []⟧ ⟹ ul ≠ []› 2. ‹⟦ul ≠ []; ul1 ≠ []⟧ ⟹ ul1 ≠ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have PID1: "PID ∈∈ postIDs s1" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) PID (*‹PID ∈∈ postIDs s›*) by auto have own: "owner s PID ∈ set (userIDs s)" using reach_owner_userIDs[OF rs PID] (*‹owner s PID ∈∈ userIDs s›*) . hence own1: "owner s1 PID ∈ set (userIDs s1)" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) by auto have adm: "admin s ∈ set (userIDs s)" using reach_admin_userIDs[OF rs own] (*‹admin (s::state) ∈∈ userIDs s›*) . hence adm1: "admin s1 ∈ set (userIDs s1)" using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) by auto have op1: "¬ open s1" using op (*‹¬ open (s::state)›*) ss1 (*‹eqButPID s s1›*) eqButPID_open (*‹eqButPID ?s ?s1.0 ⟹ open ?s = open ?s1.0›*) by auto obtain v1 and ull1 where ul1: "ul1 = v1 # ull1" (*goal: ‹(⋀(v1::value) ull1::value list. (ul1::value list) = v1 # ull1 ⟹ thesis::bool) ⟹ thesis›*) using ful1 (*‹ul1 ≠ []›*) apply (cases ul1) (*goals: 1. ‹⟦⋀v1 ull1. ul1 = v1 # ull1 ⟹ thesis; ul1 ≠ []; ul1 = []⟧ ⟹ thesis› 2. ‹⋀a list. ⟦⋀v1 ull1. ul1 = v1 # ull1 ⟹ thesis; ul1 ≠ []; ul1 = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (cases v1) (*goals: 1. ‹⋀x1. v1 = PVal x1 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1› 2. ‹⋀x21 x22. v1 = PValS x21 x22 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1› 3. ‹⋀x3. v1 = OVal x3 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) case (PVal pst1) (*‹v1 = PVal pst1›*) note v1 = PVal (*‹v1 = PVal pst1›*) show "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) proof (cases "list_ex isPVal ull1") (*goals: 1. ‹list_ex isPVal ull1 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1› 2. ‹¬ list_ex isPVal ull1 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) case True (*‹list_ex isPVal ull1›*) note lull1 = True (*‹list_ex isPVal ull1›*) hence full1: "filter isPVal ull1 ≠ []" apply (induct ull1) (*goals: 1. ‹list_ex isPVal [] ⟹ filter isPVal [] ≠ []› 2. ‹⋀a ull1. ⟦list_ex isPVal ull1 ⟹ filter isPVal ull1 ≠ []; list_ex isPVal (a # ull1)⟧ ⟹ filter isPVal (a # ull1) ≠ []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence ull1NE: "ull1 ≠ []" by auto define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" define a1 where a1: "a1 ≡ Uact (uPost uid p PID pst1)" have uid1: "uid = owner s1 PID" and p1: "p = pass s1 uid" unfolding uid p (*goals: 1. ‹owner s PID = owner s1 PID› 2. ‹pass s (owner s PID) = pass s1 (owner s PID)›*) using eqButPID_stateSelectors[OF ss1] (*‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) apply - (*goals: 1. ‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ owner s PID = owner s1 PID› 2. ‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ pass s (owner s PID) = pass s1 (owner s PID)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a1 = (ou1, s1')" (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a1::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) apply (cases "step s1 a1") (*goal: ‹(⋀ou1 s1'. step s1 a1 = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have ou1: "ou1 = outOK" using step1 (*‹step s1 a1 = (ou1, s1')›*) PID1 (*‹PID ∈∈ postIDs s1›*) own1 (*‹owner s1 PID ∈∈ userIDs s1›*) unfolding a1 uid1 p1 (*goal: ‹(ou1::out) = outOK›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have op1': "¬ open s1'" using step1 (*‹step s1 a1 = (ou1, s1')›*) op1 (*‹¬ open s1›*) unfolding a1 ou1 open_def (*goal: ‹¬ (∃uid::userID∈UIDs::userID set. uid ∈∈ userIDs (s1'::state) ∧ (PID::postID) ∈∈ postIDs s1' ∧ (uid = admin s1' ∨ uid = owner s1' PID ∨ uid ∈∈ friendIDs s1' (owner s1' PID) ∨ vis s1' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have uid: "uid ∉ UIDs" unfolding uid (*goal: ‹owner s PID ∉ UIDs›*) using op (*‹¬ open s›*) PID (*‹PID ∈∈ postIDs s›*) own (*‹owner s PID ∈∈ userIDs s›*) unfolding open_def (*goal: ‹owner s PID ∉ UIDs›*) by auto have pPID1': "post s1' PID = pst1" using step1 (*‹step s1 a1 = (ou1, s1')›*) unfolding a1 ou1 (*goal: ‹post (s1'::state) (PID::postID) = (pst1::post)›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) let ?trn1 = "Trans s1 a1 ou1 s1'" let ?vl1' = "ull1 @ sul @ OVal True # vll1" have "?iact" proof (standard) (*goals: 1. ‹step s1 ?a1.0 = (?ou1.0, ?s1')› 2. ‹φ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 3. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 4. ‹¬ γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ31 s vl ?s1' ?vl1' ∨ Δ32 s vl ?s1' ?vl1'›*) show "step s1 a1 = (ou1, s1')" using step1 (*‹step s1 a1 = (ou1, s1')›*) . next (*goals: 1. ‹φ (Trans s1 a1 ou1 s1')› 2. ‹consume (Trans s1 a1 ou1 s1') vl1 ?vl1'› 3. ‹¬ γ (Trans s1 a1 ou1 s1')› 4. ‹Δ31 s vl s1' ?vl1' ∨ Δ32 s vl s1' ?vl1'›*) show "φ": "φ ?trn1" unfolding "φ_def2"[OF step1] a1 ou1 (*goal: ‹φ (Trans s1 (Uact (uPost uid p PID pst1)) outOK s1')›*) by simp show "consume ?trn1 vl1 ?vl1'" using "φ" (*‹φ (Trans s1 a1 ou1 s1')›*) unfolding vl1 ul1 consume_def v1 a1 (*goal: ‹if φ (Trans (s1::state) (Uact (uPost (uid::userID) (p::password) (PID::postID) (pst1::post))) (ou1::out) (s1'::state)) then (PVal pst1 # (ull1::value list)) @ (sul::value list) @ OVal True # (vll1::value list) ≠ [] ∧ f (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1') = hd ((PVal pst1 # ull1) @ sul @ OVal True # vll1) ∧ ull1 @ sul @ OVal True # vll1 = tl ((PVal pst1 # ull1) @ sul @ OVal True # vll1) else ull1 @ sul @ OVal True # vll1 = (PVal pst1 # ull1) @ sul @ OVal True # vll1›*) by simp next (*goals: 1. ‹¬ γ (Trans (s1::state) (a1::act) (ou1::out) (s1'::state))› 2. ‹Δ31 (s::state) (vl::value list) (s1'::state) ((ull1::value list) @ (sul::value list) @ OVal True # (vll1::value list)) ∨ Δ32 s vl s1' (ull1 @ sul @ OVal True # vll1)›*) show "¬ γ ?trn1" using uid (*‹uid ∉ UIDs›*) unfolding a1 (*goal: ‹¬ γ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1')›*) by auto next (*goal: ‹Δ31 (s::state) (vl::value list) (s1'::state) ((ull1::value list) @ (sul::value list) @ OVal True # (vll1::value list)) ∨ Δ32 s vl s1' (ull1 @ sul @ OVal True # vll1)›*) have "eqButPID s1 s1'" using Uact_uPaperC_step_eqButPID[OF _ step1] (*‹a1 = Uact (uPost ?uid ?p PID ?pst) ⟹ eqButPID s1 s1'›*) a1 (*‹a1 ≡ Uact (uPost uid p PID pst1)›*) by auto hence ss1': "eqButPID s s1'" using eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID s s1›*) by blast have "Δ31 s vl s1' ?vl1'" using PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) op (*‹¬ open s›*) ss1' (*‹eqButPID (s::state) (s1'::state)›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) (ul1::value list)›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last ul = last ul1›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO (vll::value list) (vll1::value list)›*) ull1NE (*‹ull1 ≠ []›*) ful (*‹ul ≠ []›*) ful1 (*‹ul1 ≠ []›*) full1 (*‹filter isPVal ull1 ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last (ul::value list) = last (ul1::value list)›*) lsul (*‹list_all isPValS sul›*) unfolding "Δ31_def" vl vl1 ul1 v1 pPID1' (*goal: ‹PID ∈∈ postIDs s ∧ (∃ula ul1 sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1) ∧ ula ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a) ∧ eqButPID s s1' ∧ ¬ open s ∧ corrFrom pst1 (ull1 @ sul @ OVal True # vll1)›*) apply auto (*goal: ‹PID ∈∈ postIDs s ∧ (∃ula ul1 sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1) ∧ ula ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a) ∧ eqButPID s s1' ∧ ¬ open s ∧ corrFrom pst1 (ull1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ul"] (*‹(?P::value list ⇒ bool) (ul::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s; ¬ open s; eqButPID s s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ull1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1); corrFrom pst1 (ull1 @ sul @ OVal True # vll1); BO vll vll1; ull1 ≠ []; ul ≠ []; filter isPVal ull1 ≠ []; isPVal (last ull1); last ul = last ull1; list_all isPValS sul⟧ ⟹ ∃ula ul1 sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1) ∧ ula ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ull1"] (*‹(?P::value list ⇒ bool) (ull1::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s; ¬ open s; eqButPID s s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ull1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1); corrFrom pst1 (ull1 @ sul @ OVal True # vll1); BO vll vll1; ull1 ≠ []; ul ≠ []; filter isPVal ull1 ≠ []; isPVal (last ull1); last ul = last ull1; list_all isPValS sul⟧ ⟹ ∃ul1 sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s::state); ¬ open s; eqButPID s (s1'::state); list_all (Not ∘ isOVal) (ul::value list); list_all (Not ∘ isOVal) (ull1::value list); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1); corrFrom (pst1::post) (ull1 @ (sul::value list) @ OVal True # (vll1::value list)); BO (vll::value list) vll1; ull1 ≠ []; ul ≠ []; filter isPVal ull1 ≠ []; isPVal (last ull1); last ul = last ull1; list_all isPValS sul⟧ ⟹ ∃(sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ull1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1) ∧ ul ≠ [] ∧ ull1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ull1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ull1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹(?P::value list ⇒ bool) (vll::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s; ¬ open s; eqButPID s s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ull1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1); corrFrom pst1 (ull1 @ sul @ OVal True # vll1); BO vll vll1; ull1 ≠ []; ul ≠ []; filter isPVal ull1 ≠ []; isPVal (last ull1); last ul = last ull1; list_all isPValS sul⟧ ⟹ ∃vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ull1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1) ∧ ul ≠ [] ∧ ull1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ull1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ull1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s::state); ¬ open s; eqButPID s (s1'::state); list_all (Not ∘ isOVal) (ul::value list); list_all (Not ∘ isOVal) (ull1::value list); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1); corrFrom (pst1::post) (ull1 @ (sul::value list) @ OVal True # (vll1::value list)); BO (vll::value list) vll1; ull1 ≠ []; ul ≠ []; filter isPVal ull1 ≠ []; isPVal (last ull1); last ul = last ull1; list_all isPValS sul⟧ ⟹ ∃vll1a::value list. BO vll vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ull1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ull1) ∧ ul ≠ [] ∧ ull1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ull1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vll ∧ ull1 @ sul @ OVal True # vll1 = ull1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s vl s1' ?vl1'" by auto qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) by simp next (*goal: ‹¬ list_ex isPVal ull1 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) case False (*‹¬ list_ex isPVal ull1›*) note lull1 = False (*‹¬ list_ex isPVal (ull1::value list)›*) hence ull1: "ull1 = []" using lastul (*‹isPVal (last ul)›*) unfolding ulul1 ul1 v1 (*goal: ‹ull1 = []›*) apply simp (*goal: ‹ull1 = []›*) by (meson Bex_set (*‹Bex (set ?xs) ?P = list_ex ?P ?xs›*) last_in_set (*‹?as ≠ [] ⟹ last ?as ∈∈ ?as›*)) hence ul1: "ul1 = [PVal pst1]" unfolding ul1 v1 (*goal: ‹PVal pst1 # ull1 = [PVal pst1]›*) by simp obtain ulll where ul_ulll: "ul = ulll ## PVal pst1" (*goal: ‹(⋀ulll. ul = ulll ## PVal pst1 ⟹ thesis) ⟹ thesis›*) using lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) ulNE (*‹ul ≠ []›*) unfolding ul1 ull1 v1 (*goal: ‹(⋀ulll. ul = ulll ## PVal pst1 ⟹ thesis) ⟹ thesis›*) apply (cases ul rule: rev_cases (*‹⟦(?xs::?'a::type list) = [] ⟹ ?P::bool; ⋀(ys::?'a::type list) y::?'a::type. ?xs = ys ## y ⟹ ?P⟧ ⟹ ?P›*)) (*goals: 1. ‹⟦⋀ulll::value list. (ul::value list) = ulll ## PVal (pst1::post) ⟹ thesis::bool; isPVal (last ul); last ul = last [PVal pst1]; ul ≠ []; ul = []⟧ ⟹ thesis› 2. ‹⋀(ys::value list) y::value. ⟦⋀ulll::value list. (ul::value list) = ulll ## PVal (pst1::post) ⟹ thesis::bool; isPVal (last ul); last ul = last [PVal pst1]; ul ≠ []; ul = ys ## y⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence ulNE: "ul ≠ []" by simp have "filter isPValS ulll = []" using map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) unfolding ul_ulll ul1 v1 ull1 (*goal: ‹filter isPValS ulll = []›*) by simp hence lull: "list_all isPVal ulll" using lul (*‹list_all (Not ∘ isOVal) ul›*) filter_list_all_isPVal_isOVal (*‹⟦list_all (Not ∘ isOVal) ?ul; filter isPValS ?ul = []⟧ ⟹ list_all isPVal ?ul›*) unfolding ul_ulll (*goal: ‹list_all isPVal ulll›*) by auto have "?react" proof (standard) (*goal: ‹⋀a ou s' vl'. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'⟧ ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹PID ∈∈ postIDs s'›*) . obtain ul' where cc: "consume ?trn ul ul'" and vl': "vl' = ul' @ sul @ OVal True # vll" (*goal: ‹(⋀ul'::value list. ⟦consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (ul::value list) ul'; (vl'::value list) = ul' @ (sul::value list) @ OVal True # (vll::value list)⟧ ⟹ thesis::bool) ⟹ thesis›*) using c (*‹consume (Trans s a ou s') vl vl'›*) ulNE (*‹(ul::value list) ≠ []›*) unfolding consume_def vl (*goal: ‹(⋀ul'::value list. ⟦if φ (Trans (s::state) (a::act) (ou::out) (s'::state)) then (ul::value list) ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; (vl'::value list) = ul' @ (sul::value list) @ OVal True # (vll::value list)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (cases "φ ?trn") (*goals: 1. ‹⟦⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ sul @ OVal True # vll⟧ ⟹ thesis; if φ (Trans s a ou s') then ul @ sul @ OVal True # vll ≠ [] ∧ f (Trans s a ou s') = hd (ul @ sul @ OVal True # vll) ∧ vl' = tl (ul @ sul @ OVal True # vll) else vl' = ul @ sul @ OVal True # vll; ul ≠ []; φ (Trans s a ou s')⟧ ⟹ thesis› 2. ‹⟦⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ sul @ OVal True # vll⟧ ⟹ thesis; if φ (Trans s a ou s') then ul @ sul @ OVal True # vll ≠ [] ∧ f (Trans s a ou s') = hd (ul @ sul @ OVal True # vll) ∧ vl' = tl (ul @ sul @ OVal True # vll) else vl' = ul @ sul @ OVal True # vll; ul ≠ []; ¬ φ (Trans s a ou s')⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) by auto let ?trn1 = "Trans s1 a ou1 s1'" show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (cases ulll) (*goals: 1. ‹(ulll::value list) = [] ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀(aa::value) list::value list. (ulll::value list) = aa # list ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case Nil (*‹ulll = []›*) hence ul: "ul = [PVal pst1]" unfolding ul_ulll (*goal: ‹(ulll::value list) ## PVal (pst1::post) = [PVal pst1]›*) by simp have "?match" proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain f: "f ?trn = PVal pst1" and ul': "ul' = []" (*goal: ‹(⟦f (Trans s a ou s') = PVal pst1; ul' = []⟧ ⟹ thesis) ⟹ thesis›*) using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding ul consume_def "φ_def2" (*goal: ‹(⟦f (Trans s a ou s') = PVal pst1; ul' = []⟧ ⟹ thesis) ⟹ thesis›*) by auto define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" have a: "a = Uact (uPost uid p PID pst1)" using f_eq_PVal[OF step φ f] (*‹(a::act) = Uact (uPost (owner (s::state) (PID::postID)) (pass s (owner s PID)) PID (pst1::post))›*) unfolding uid p (*goal: ‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst1)›*) . have uid1: "uid = owner s1 PID" and p1: "p = pass s1 uid" unfolding uid p (*goals: 1. ‹owner s PID = owner s1 PID› 2. ‹pass s (owner s PID) = pass s1 (owner s PID)›*) using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) apply - (*goals: 1. ‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ owner s (PID::postID) = owner s1 PID› 2. ‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ pass s (owner s (PID::postID)) = pass s1 (owner s PID)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) by auto let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "φ ?trn1" using "eqButPID_step_φ_imp"[OF ss1 step step1 φ] (*‹φ (Trans s1 a ou1 s1')›*) . have ou1: "ou1 = outOK" using "φ1" (*‹φ (Trans s1 a ou1 s1')›*) step1 (*‹step s1 a = (ou1, s1')›*) PID1 (*‹(PID::postID) ∈∈ postIDs (s1::state)›*) unfolding a (*goal: ‹ou1 = outOK›*) apply (cases ou1) (*goals: 1. ‹⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outOK⟧ ⟹ ou1 = outOK› 2. ‹⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outErr⟧ ⟹ ou1 = outOK› 3. ‹⋀x3. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outBool x3⟧ ⟹ ou1 = outOK› 4. ‹⋀x4. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outName x4⟧ ⟹ ou1 = outOK› 5. ‹⋀x5. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outPost x5⟧ ⟹ ou1 = outOK› 6. ‹⋀x6. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outVis x6⟧ ⟹ ou1 = outOK› 7. ‹⋀x7. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outReq x7⟧ ⟹ ou1 = outOK› 8. ‹⋀x8. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outUID x8⟧ ⟹ ou1 = outOK› 9. ‹⋀x9. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outUIDL x9⟧ ⟹ ou1 = outOK› 10. ‹⋀x10. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outAIDL x10⟧ ⟹ ou1 = outOK› 11. ‹⋀x11. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outAIDBL x11⟧ ⟹ ou1 = outOK› 12. ‹⋀x12. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outUIDPIDL x12⟧ ⟹ ou1 = outOK› 13. ‹⋀x13. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outAIDPIDL x13⟧ ⟹ ou1 = outOK› 14. ‹⋀x14. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = outAIDUIDL x14⟧ ⟹ ou1 = outOK› 15. ‹⋀x15. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = O_sendServerReq x15⟧ ⟹ ou1 = outOK› 16. ‹⋀x16. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = O_connectClient x16⟧ ⟹ ou1 = outOK› 17. ‹⋀x17. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = O_sendPost x17⟧ ⟹ ou1 = outOK› 18. ‹⋀x18. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = O_sendCreateOFriend x18⟧ ⟹ ou1 = outOK› 19. ‹⋀x19. ⟦φ (Trans s1 (Uact (uPost uid p PID pst1)) ou1 s1'); step s1 (Uact (uPost uid p PID pst1)) = (ou1, s1'); PID ∈∈ postIDs s1; ou1 = O_sendDeleteOFriend x19⟧ ⟹ ou1 = outOK› discuss goal 1*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 2*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 3*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 4*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 5*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 6*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 7*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 8*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 9*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 10*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 11*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 12*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 13*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 14*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 15*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 16*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 17*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 18*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 19*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*proven 19 subgoals*) . have pPID': "post s' PID = pst1" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) "φ" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) unfolding a (*goal: ‹post s' PID = pst1›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have pPID1': "post s1' PID = pst1" using step1 (*‹step s1 a = (ou1, s1')›*) "φ1" (*‹φ (Trans s1 a ou1 s1')›*) unfolding a (*goal: ‹post s1' PID = pst1›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have uid: "uid ∉ UIDs" unfolding uid (*goal: ‹owner s PID ∉ UIDs›*) using op (*‹¬ open s›*) PID (*‹PID ∈∈ postIDs s›*) own (*‹owner s PID ∈∈ userIDs s›*) unfolding open_def (*goal: ‹owner s PID ∉ UIDs›*) by auto have op1': "¬ open s1'" using step1 (*‹step s1 a = (ou1, s1')›*) op1 (*‹¬ open s1›*) unfolding a open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s1' ∧ PID ∈∈ postIDs s1' ∧ (uid = admin s1' ∨ uid = owner s1' PID ∨ uid ∈∈ friendIDs s1' (owner s1' PID) ∨ vis s1' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*) com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) have f1: "f ?trn1 = PVal pst1" using "φ1" (*‹φ (Trans s1 a ou1 s1')›*) unfolding "φ_def2"[OF step1] v1 a ou1 (*goal: ‹f (Trans s1 (Uact (uPost uid p PID pst1)) outOK s1') = PVal pst1›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹a = Uact (uPost uid p PID pst1)›*) op (*‹¬ open s›*) by auto have ou: "ou = outOK" using "φ" (*‹φ (Trans s a ou s')›*) op (*‹¬ open s›*) op' (*‹¬ open s'›*) unfolding "φ_def2"[OF step] a (*goal: ‹ou = outOK›*) by auto let ?vl' = "sul @ OVal True # vll" let ?vl1' = "sul @ OVal True # vll1" show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step s1 a = (ou1, s1')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ31 s' vl' s1' ?vl1' ∨ Δ32 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 ?vl1'" using "φ1" (*‹φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*) unfolding consume_def ul1 f1 vl1 (*goal: ‹if φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state)) then [PVal (pst1::post)] @ (sul::value list) @ OVal True # (vll1::value list) ≠ [] ∧ PVal pst1 = hd ([PVal pst1] @ sul @ OVal True # vll1) ∧ sul @ OVal True # vll1 = tl ([PVal pst1] @ sul @ OVal True # vll1) else sul @ OVal True # vll1 = [PVal pst1] @ sul @ OVal True # vll1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ31 s' vl' s1' (sul @ OVal True # vll1) ∨ Δ32 s' vl' s1' (sul @ OVal True # vll1)›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ31 s' vl' s1' (sul @ OVal True # vll1) ∨ Δ32 s' vl' s1' (sul @ OVal True # vll1)›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) thus "g ?trn = g ?trn1" using ou (*‹(ou::out) = outOK›*) ou1 (*‹ou1 = outOK›*) apply (cases a) (*goals: 1. ‹⋀x1. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦γ (Trans s a ou s'); ou = outOK; ou1 = outOK; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ31 s' vl' s1' (sul @ OVal True # vll1) ∨ Δ32 s' vl' s1' (sul @ OVal True # vll1)›*) have s': "s' = s1'" using eqButPID_step_eq[OF ss1 a ou step step1] (*‹s' = s1'›*) . have corr1: "corrFrom (post s1' PID) ?vl1'" using cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding vl1 ul1 v1 pPID1' (*goal: ‹corrFrom pst1 (sul @ OVal True # vll1)›*) by auto have "Δ32 s' vl' s1' ?vl1'" using PID' (*‹PID ∈∈ postIDs s'›*) op1 (*‹¬ open s1›*) op' (*‹¬ open s'›*) s's1' (*‹eqButPID s' s1'›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) (ul1::value list)›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last ul = last ul1›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) ful (*‹ul ≠ []›*) ful1 (*‹ul1 ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last (ul::value list) = last (ul1::value list)›*) lsul (*‹list_all isPValS sul›*) corr1 (*‹corrFrom (post (s1'::state) (PID::postID)) ((sul::value list) @ OVal True # (vll1::value list))›*) unfolding "Δ32_def" vl vl1 v1 vl' ul' ul ul1 s' (*goal: ‹PID ∈∈ postIDs s1' ∧ (∃sula vlla vll1a. BO vlla vll1a ∧ list_all isPValS sula ∧ [] @ sul @ OVal True # vll = sula @ OVal True # vlla ∧ sul @ OVal True # vll1 = sula @ OVal True # vll1a) ∧ s1' = s1' ∧ ¬ open s1' ∧ corrFrom (post s1' PID) (sul @ OVal True # vll1)›*) apply simp (*goal: ‹PID ∈∈ postIDs s1' ∧ (∃sula vlla vll1a. BO vlla vll1a ∧ list_all isPValS sula ∧ [] @ sul @ OVal True # vll = sula @ OVal True # vlla ∧ sul @ OVal True # vll1 = sula @ OVal True # vll1a) ∧ s1' = s1' ∧ ¬ open s1' ∧ corrFrom (post s1' PID) (sul @ OVal True # vll1)›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s1'; ¬ open s1; ¬ open s1'; corrFrom pst1 (sul @ OVal True # vll1); BO vll vll1; list_all isPValS sul; corrFrom (post s1' PID) (sul @ OVal True # vll1)⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all isPValS sula ∧ sul @ OVal True # vll = sula @ OVal True # vlla ∧ sul @ OVal True # vll1 = sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹(?P::value list ⇒ bool) (vll::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s1'; ¬ open s1; ¬ open s1'; corrFrom pst1 (sul @ OVal True # vll1); BO vll vll1; list_all isPValS sul; corrFrom (post s1' PID) (sul @ OVal True # vll1)⟧ ⟹ ∃vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ sul @ OVal True # vll = sul @ OVal True # vlla ∧ sul @ OVal True # vll1 = sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s1'; ¬ open s1; ¬ open s1'; corrFrom pst1 (sul @ OVal True # vll1); BO vll vll1; list_all isPValS sul; corrFrom (post s1' PID) (sul @ OVal True # vll1)⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all isPValS sul ∧ sul @ OVal True # vll = sul @ OVal True # vll ∧ sul @ OVal True # vll1 = sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1' ?vl1'" by simp qed next (*goal: ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "φ" = False (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) hence ul': "ul' = ul" using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding consume_def (*goal: ‹(ul'::value list) = (ul::value list)›*) by auto obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "¬ φ ?trn1" using "φ" (*‹¬ φ (Trans s a ou s')›*) ss1 (*‹eqButPID (s::state) (s1::state)›*) by (simp add: eqButPID_step_φ (*‹⟦eqButPID ?s ?s1.0; step ?s ?a = (?ou, ?s'); step ?s1.0 ?a = (?ou1.0, ?s1')⟧ ⟹ φ (Trans ?s ?a ?ou ?s') = φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*) step (*‹step s a = (ou, s')›*) step1 (*‹step s1 a = (ou1, s1')›*)) have pPID1': "post s1' PID = post s1 PID" using PID1 (*‹(PID::postID) ∈∈ postIDs (s1::state)›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) "φ1" (*‹¬ φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*) apply (cases a) (*goal: ‹post s1' PID = post s1 PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Sact x1⟧ ⟹ post s1' PID = post s1 PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s1' PID = post s1 PID› 4. ‹⋀x41 x42 x43 x44. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s1' PID = post s1 PID› 5. ‹⋀x51 x52 x53. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s1::state); step s1 (a::act) = (ou1::out, s1'::state); ¬ φ (Trans s1 a ou1 s1'); a = Dact (x3::dActt)⟧ ⟹ post s1' PID = post s1 PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s1' PID = post s1 PID› 4. ‹⋀x41 x42. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s1' PID = post s1 PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s1' PID = post s1 PID› 6. ‹⋀x61 x62 x63 x64. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s1' PID = post s1 PID› 7. ‹⋀x71 x72 x73 x74. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s1' PID = post s1 PID› 8. ‹⋀x81 x82 x83 x84. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s1' PID = post s1 PID› 9. ‹⋀x91 x92 x93 x94. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s1' PID = post s1 PID› 10. ‹⋀x101 x102 x103 x104. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) by auto have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ31 s' vl' s1' ?vl1' ∨ Δ32 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) unfolding consume_def (*goal: ‹if φ (Trans s1 a ou1 s1') then vl1 ≠ [] ∧ f (Trans s1 a ou1 s1') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1::sActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 2. ‹⋀x2::cActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 3. ‹⋀x3::dActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 4. ‹⋀x4::uActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 5. ‹⋀x5::rActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 6. ‹⋀x6::lActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 7. ‹⋀x7::comActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) have "Δ31 s' vl' s1' vl1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID1' (*‹post s1' PID = post s1 PID›*) op' (*‹¬ open (s'::state)›*) s's1' (*‹eqButPID s' s1'›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) ul1›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last (ul::value list) = last (ul1::value list)›*) cor1 (*‹corrFrom (post (s1::state) (PID::postID)) (vl1::value list)›*) BO (*‹BO vll vll1›*) ful (*‹ul ≠ []›*) ful1 (*‹(ul1::value list) ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) lsul (*‹list_all isPValS sul›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding "Δ31_def" vl vl1 v1 vl' ul' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ul1 @ sul @ OVal True # vll1)›*) apply simp (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ul1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ul"] (*‹?P ul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ul1"] (*‹?P ul1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹(?P::value list ⇒ bool) (vll::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vll ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1' vl1" by simp qed thus "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list)›*) by simp qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp next (*goal: ‹⋀aa list. ulll = aa # list ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (Cons v ullll) (*‹ulll = v # ullll›*) note ulll = Cons (*‹(ulll::value list) = (v::value) # (ullll::value list)›*) then obtain pst where v: "v = PVal pst" (*goal: ‹(⋀pst. v = PVal pst ⟹ thesis) ⟹ thesis›*) using lull (*‹list_all isPVal ulll›*) ul_ulll (*‹ul = ulll ## PVal pst1›*) ulll (*‹(ulll::value list) = (v::value) # (ullll::value list)›*) lul (*‹list_all (Not ∘ isOVal) (ul::value list)›*) apply (cases v) (*goals: 1. ‹⋀x1. ⟦⋀pst. v = PVal pst ⟹ thesis; ulll = v # ullll; list_all isPVal ulll; ul = ulll ## PVal pst1; ulll = v # ullll; list_all (Not ∘ isOVal) ul; v = PVal x1⟧ ⟹ thesis› 2. ‹⋀x21 x22. ⟦⋀pst. v = PVal pst ⟹ thesis; ulll = v # ullll; list_all isPVal ulll; ul = ulll ## PVal pst1; ulll = v # ullll; list_all (Not ∘ isOVal) ul; v = PValS x21 x22⟧ ⟹ thesis› 3. ‹⋀x3. ⟦⋀pst. v = PVal pst ⟹ thesis; ulll = v # ullll; list_all isPVal ulll; ul = ulll ## PVal pst1; ulll = v # ullll; list_all (Not ∘ isOVal) ul; v = OVal x3⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . define ull where ull: "ull ≡ ullll ## PVal pst1" have ul: "ul = v # ull" unfolding ul_ulll ull ulll (*goal: ‹(v # ullll) ## PVal pst1 = v # ullll ## PVal pst1›*) by simp show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain f: "f ?trn = v" and ul': "ul' = ull" (*goal: ‹(⟦f (Trans s a ou s') = v; ul' = ull⟧ ⟹ thesis) ⟹ thesis›*) using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding ul consume_def "φ_def2" (*goal: ‹(⟦f (Trans s a ou s') = v; ul' = ull⟧ ⟹ thesis) ⟹ thesis›*) by auto define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" have a: "a = Uact (uPost uid p PID pst)" using f_eq_PVal[OF step φ f [ unfolded v ]] (*‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) unfolding uid p (*goal: ‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) . have "eqButPID s s'" using Uact_uPaperC_step_eqButPID[OF a step] (*‹eqButPID (s::state) (s'::state)›*) by auto hence s's1: "eqButPID s' s1" using eqButPID_sym (*‹eqButPID ?s ?s1.0 ⟹ eqButPID ?s1.0 ?s›*) eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID s s1›*) by blast have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹a = Uact (uPost uid p PID pst)›*) op (*‹¬ open (s::state)›*) by auto have "?ignore" proof (standard) (*goals: 1. ‹¬ γ (Trans s a ou s')› 2. ‹Δ31 s' vl' s1 vl1 ∨ Δ32 s' vl' s1 vl1›*) show "γ": "¬ γ ?trn" using "step_open_φ_f_PVal_γ"[OF rs step PID op φ f [ unfolded v ]] (*‹¬ γ (Trans s a ou s')›*) . have "Δ31 s' vl' s1 vl1" using PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹¬ open s'›*) s's1 (*‹eqButPID s' s1›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) ul1›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last ul = last ul1›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) ful (*‹(ul::value list) ≠ []›*) ful1 (*‹(ul1::value list) ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) lsul (*‹list_all isPValS sul›*) ull (*‹ull ≡ ullll ## PVal pst1›*) unfolding "Δ31_def" vl vl1 v1 vl' ul' ul v (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1 ∧ ¬ open s' ∧ corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)›*) apply simp (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1 ∧ ¬ open s' ∧ corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ull"] (*‹(?P::value list ⇒ bool) (ull::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ullll; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ullll) = map tgtAPI (filter isPValS ul1); PVal pst1 = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≡ ullll ## last ul1⟧ ⟹ ∃ul ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ullll @ last ul1 # sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ul1"] (*‹?P ul1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ullll; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ullll) = map tgtAPI (filter isPValS ul1); PVal pst1 = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≡ ullll ## last ul1⟧ ⟹ ∃ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1a) ∧ ull ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1a ∧ list_all isPValS sula ∧ ullll @ last ul1 # sul @ OVal True # vll = ull @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ullll; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ullll) = map tgtAPI (filter isPValS ul1); PVal pst1 = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≡ ullll ## last ul1⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sula ∧ ullll @ last ul1 # sul @ OVal True # vll = ull @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹(?P::value list ⇒ bool) (vll::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ullll; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ullll) = map tgtAPI (filter isPValS ul1); PVal pst1 = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≡ ullll ## last ul1⟧ ⟹ ∃vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sul ∧ ullll @ last ul1 # sul @ OVal True # vll = ull @ sul @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ullll; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ullll) = map tgtAPI (filter isPValS ul1); PVal pst1 = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≡ ullll ## last ul1⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sul ∧ ullll @ last ul1 # sul @ OVal True # vll = ull @ sul @ OVal True # vll ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1 vl1" by auto qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp next (*goal: ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ φ (Trans s a ou s')›*) note "φ" = False (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) hence ul': "ul' = ul" using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding consume_def (*goal: ‹ul' = ul›*) by auto obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID (s'::state) (s1'::state)›*) . let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "¬ φ ?trn1" using "φ" (*‹¬ φ (Trans s a ou s')›*) ss1 (*‹eqButPID s s1›*) by (simp add: eqButPID_step_φ (*‹⟦eqButPID ?s ?s1.0; step ?s ?a = (?ou, ?s'); step ?s1.0 ?a = (?ou1.0, ?s1')⟧ ⟹ φ (Trans ?s ?a ?ou ?s') = φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*) step (*‹step s a = (ou, s')›*) step1 (*‹step s1 a = (ou1, s1')›*)) have pPID1': "post s1' PID = post s1 PID" using PID1 (*‹(PID::postID) ∈∈ postIDs (s1::state)›*) step1 (*‹step s1 a = (ou1, s1')›*) "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) apply (cases a) (*goal: ‹post s1' PID = post s1 PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Sact x1⟧ ⟹ post s1' PID = post s1 PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s1' PID = post s1 PID› 4. ‹⋀x41 x42 x43 x44. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s1' PID = post s1 PID› 5. ‹⋀x51 x52 x53. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Dact x3⟧ ⟹ post s1' PID = post s1 PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s1' PID = post s1 PID› 2. ‹⋀x21 x22. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s1' PID = post s1 PID› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s1' PID = post s1 PID› 4. ‹⋀x41 x42. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s1' PID = post s1 PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s1' PID = post s1 PID› 6. ‹⋀x61 x62 x63 x64. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s1' PID = post s1 PID› 7. ‹⋀x71 x72 x73 x74. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s1' PID = post s1 PID› 8. ‹⋀x81 x82 x83 x84. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s1' PID = post s1 PID› 9. ‹⋀x91 x92 x93 x94. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s1' PID = post s1 PID› 10. ‹⋀x101 x102 x103 x104. ⟦PID ∈∈ postIDs s1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s1' PID = post s1 PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) by auto have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step s1 a = (ou1, s1')›*) by simp next (*goals: 1. ‹consume (Trans (s1::state) (a::act) (ou1::out) (s1'::state)) (vl1::value list) (?vl1'::value list)› 2. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) a (ou1::out) (s1'::state))› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a (ou1::out) (s1'::state))› 4. ‹Δ31 (s'::state) (vl'::value list) (s1'::state) (?vl1'::value list) ∨ Δ32 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) unfolding consume_def (*goal: ‹if φ (Trans s1 a ou1 s1') then vl1 ≠ [] ∧ f (Trans s1 a ou1 s1') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) have "Δ31 s' vl' s1' vl1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID1' (*‹post s1' PID = post s1 PID›*) op' (*‹¬ open (s'::state)›*) s's1' (*‹eqButPID s' s1'›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) ul1›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last ul = last ul1›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) ful (*‹(ul::value list) ≠ []›*) ful1 (*‹ul1 ≠ []›*) lastul (*‹isPVal (last (ul::value list))›*) ulul1 (*‹last ul = last ul1›*) lsul (*‹list_all isPValS sul›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding "Δ31_def" vl vl1 v1 vl' ul' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ul1 @ sul @ OVal True # vll1)›*) apply simp (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(ula::value list) (ul1a::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ (ul::value list) @ (sul::value list) @ OVal True # (vll::value list) = ula @ sula @ OVal True # vlla ∧ (ul1::value list) @ sul @ OVal True # (vll1::value list) = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' (s1'::state) ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ul1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ul"] (*‹?P ul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s'::state); post (s1'::state) PID = post (s1::state) PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) (ul::value list); list_all (Not ∘ isOVal) (ul1::value list); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO (vll::value list) (vll1::value list); ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS (sul::value list); corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃(ula::value list) (ul1a::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ul1"] (*‹(?P::value list ⇒ bool) (ul1::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s'::state); post (s1'::state) PID = post (s1::state) PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) (ul::value list); list_all (Not ∘ isOVal) (ul1::value list); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO (vll::value list) (vll1::value list); ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS (sul::value list); corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃(vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1' PID = post s1 PID; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vll ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1' vl1" by simp qed thus "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) using vl (*‹(vl::value list) = (ul::value list) @ (sul::value list) @ OVal True # (vll::value list)›*) by simp qed next (*goals: 1. ‹⋀x21 x22. v1 = PValS x21 x22 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1› 2. ‹⋀x3. v1 = OVal x3 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) case (PValS aid1 pst1) (*‹v1 = PValS aid1 pst1›*) note v1 = PValS (*‹v1 = PValS aid1 pst1›*) have pPID1: "post s1 PID = pst1" using cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding vl1 ul1 v1 (*goal: ‹post s1 PID = pst1›*) by auto then obtain v and ull where ul: "ul = v # ull" (*goal: ‹(⋀v ull. ul = v # ull ⟹ thesis) ⟹ thesis›*) using map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) unfolding ul1 v1 (*goal: ‹(⋀v ull. ul = v # ull ⟹ thesis) ⟹ thesis›*) apply (cases ul) (*goals: 1. ‹⟦⋀(v::value) ull::value list. (ul::value list) = v # ull ⟹ thesis::bool; post (s1::state) (PID::postID) = (pst1::post); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS (PValS (aid1::apiID) pst1 # (ull1::value list))); ul = []⟧ ⟹ thesis› 2. ‹⋀(a::value) list::value list. ⟦⋀(v::value) ull::value list. (ul::value list) = v # ull ⟹ thesis::bool; post (s1::state) (PID::postID) = (pst1::post); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS (PValS (aid1::apiID) pst1 # (ull1::value list))); ul = a # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?vl1' = "ull1 @ sul @ OVal True # vll1" have "?react" proof (standard) (*goal: ‹⋀(a::act) (ou::out) (s'::state) vl'::value list. ⟦step (s::state) a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') (vl::value list) vl'⟧ ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s (s1::state) (vl1::value list) a ou s' vl' ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹PID ∈∈ postIDs s'›*) . obtain ul' where cc: "consume ?trn ul ul'" and vl': "vl' = ul' @ sul @ OVal True # vll" (*goal: ‹(⋀ul'. ⟦consume (Trans s a ou s') ul ul'; vl' = ul' @ sul @ OVal True # vll⟧ ⟹ thesis) ⟹ thesis›*) using c (*‹consume (Trans s a ou s') vl vl'›*) ul (*‹ul = v # ull›*) unfolding consume_def vl (*goal: ‹(⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ sul @ OVal True # vll⟧ ⟹ thesis) ⟹ thesis›*) apply (cases "φ ?trn") (*goals: 1. ‹⟦⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ sul @ OVal True # vll⟧ ⟹ thesis; if φ (Trans s a ou s') then ul @ sul @ OVal True # vll ≠ [] ∧ f (Trans s a ou s') = hd (ul @ sul @ OVal True # vll) ∧ vl' = tl (ul @ sul @ OVal True # vll) else vl' = ul @ sul @ OVal True # vll; ul = v # ull; φ (Trans s a ou s')⟧ ⟹ thesis› 2. ‹⟦⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ sul @ OVal True # vll⟧ ⟹ thesis; if φ (Trans s a ou s') then ul @ sul @ OVal True # vll ≠ [] ∧ f (Trans s a ou s') = hd (ul @ sul @ OVal True # vll) ∧ vl' = tl (ul @ sul @ OVal True # vll) else vl' = ul @ sul @ OVal True # vll; ul = v # ull; ¬ φ (Trans s a ou s')⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀(ou1::out) s1'::state. step (s1::state) (a::act) = (ou1, s1') ⟹ thesis::bool) ⟹ thesis›*) by auto let ?trn1 = "Trans s1 a ou1 s1'" show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain f: "f ?trn = v" and ul': "ul' = ull" (*goal: ‹(⟦f (Trans s a ou s') = v; ul' = ull⟧ ⟹ thesis) ⟹ thesis›*) using cc (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (ul::value list) (ul'::value list)›*) unfolding ul consume_def "φ_def2" (*goal: ‹(⟦f (Trans s a ou s') = v; ul' = ull⟧ ⟹ thesis) ⟹ thesis›*) by auto show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (cases v) (*goals: 1. ‹⋀x1. v = PVal x1 ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 3. ‹⋀x3. v = OVal x3 ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (PVal pst) (*‹v = PVal pst›*) note v = PVal (*‹v = PVal pst›*) have full: "ull ≠ []" using map (*‹map tgtAPI (filter isPValS (ul::value list)) = map tgtAPI (filter isPValS (ul1::value list))›*) unfolding ul1 v1 ul v (*goal: ‹ull ≠ []›*) by auto define uid where uid: "uid ≡ owner s PID" define p where p: "p ≡ pass s uid" have a: "a = Uact (uPost uid p PID pst)" using f_eq_PVal[OF step φ f [ unfolded v ]] (*‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) unfolding uid p (*goal: ‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) . have "eqButPID s s'" using Uact_uPaperC_step_eqButPID[OF a step] (*‹eqButPID s s'›*) by auto hence s's1: "eqButPID s' s1" using eqButPID_sym (*‹eqButPID ?s ?s1.0 ⟹ eqButPID ?s1.0 ?s›*) eqButPID_trans (*‹⟦eqButPID ?s ?s1.0; eqButPID ?s1.0 ?s2.0⟧ ⟹ eqButPID ?s ?s2.0›*) ss1 (*‹eqButPID (s::state) (s1::state)›*) by blast have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹a = Uact (uPost uid p PID pst)›*) op (*‹¬ open s›*) by auto have "?ignore" proof (standard) (*goals: 1. ‹¬ γ (Trans s a ou s')› 2. ‹Δ31 s' vl' s1 vl1 ∨ Δ32 s' vl' s1 vl1›*) show "γ": "¬ γ ?trn" using "step_open_φ_f_PVal_γ"[OF rs step PID op φ f [ unfolded v ]] (*‹¬ γ (Trans s a ou s')›*) . have "Δ31 s' vl' s1 vl1" using PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹¬ open s'›*) s's1 (*‹eqButPID s' s1›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) ul1›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last ul = last ul1›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO (vll::value list) (vll1::value list)›*) ful (*‹ul ≠ []›*) ful1 (*‹ul1 ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) lsul (*‹list_all isPValS sul›*) full (*‹(ull::value list) ≠ []›*) unfolding "Δ31_def" vl vl1 v1 vl' ul' ul v (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1 ∧ ¬ open s' ∧ corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)›*) apply simp (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(ul::value list) (ul1a::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ (ull::value list) @ (sul::value list) @ OVal True # (vll::value list) = ul @ sula @ OVal True # vlla ∧ (ul1::value list) @ sul @ OVal True # (vll1::value list) = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' (s1::state) ∧ ¬ open s' ∧ corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ull"] (*‹?P ull ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1); last ull = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≠ []⟧ ⟹ ∃ul ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ul1"] (*‹?P ul1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s'::state); ¬ open s'; eqButPID s' (s1::state); list_all (Not ∘ isOVal) (ull::value list); list_all (Not ∘ isOVal) (ul1::value list); map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1); last ull = last ul1; corrFrom (post s1 PID) (ul1 @ (sul::value list) @ OVal True # (vll1::value list)); BO (vll::value list) vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≠ []⟧ ⟹ ∃(ul1a::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1a) ∧ ull ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1a ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ull @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1); last ull = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≠ []⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ull @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s'::state); ¬ open s'; eqButPID s' (s1::state); list_all (Not ∘ isOVal) (ull::value list); list_all (Not ∘ isOVal) (ul1::value list); map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1); last ull = last ul1; corrFrom (post s1 PID) (ul1 @ (sul::value list) @ OVal True # (vll1::value list)); BO (vll::value list) vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≠ []⟧ ⟹ ∃(vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sul ∧ ull @ sul @ OVal True # vll = ull @ sul @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1); last ull = last ul1; corrFrom (post s1 PID) (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul1 ≠ []; isPVal (last ul1); list_all isPValS sul; ull ≠ []⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sul ∧ ull @ sul @ OVal True # vll = ull @ sul @ OVal True # vll ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1 vl1" by auto qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp next (*goals: 1. ‹⋀(x21::apiID) x22::post. (v::value) = PValS x21 x22 ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀x3::bool. (v::value) = OVal x3 ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (PValS aid pst) (*‹v = PValS aid pst›*) note v = PValS (*‹v = PValS aid pst›*) define uid where uid: "uid ≡ admin s" define p where p: "p ≡ pass s uid" have a: "a = COMact (comSendPost (admin s) p aid PID)" using f_eq_PValS[OF step φ f [ unfolded v ]] (*‹a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)›*) unfolding uid p (*goal: ‹a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)›*) . have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹a = COMact (comSendPost (admin s) p aid PID)›*) op (*‹¬ open s›*) by auto have aid1: "aid1 = aid" using map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) unfolding ul1 v1 ul v (*goal: ‹aid1 = aid›*) by simp have uid1: "uid = admin s1" and p1: "p = pass s1 uid" unfolding uid p (*goals: 1. ‹admin s = admin s1› 2. ‹pass s (admin s) = pass s1 (admin s)›*) using eqButPID_stateSelectors[OF ss1] (*‹admin s = admin s1 ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1›*) apply - (*goals: 1. ‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ admin s = admin s1› 2. ‹admin (s::state) = admin (s1::state) ∧ pendingUReqs s = pendingUReqs s1 ∧ userReq s = userReq s1 ∧ userIDs s = userIDs s1 ∧ user s = user s1 ∧ pass s = pass s1 ∧ pendingFReqs s = pendingFReqs s1 ∧ friendReq s = friendReq s1 ∧ friendIDs s = friendIDs s1 ∧ sentOuterFriendIDs s = sentOuterFriendIDs s1 ∧ recvOuterFriendIDs s = recvOuterFriendIDs s1 ∧ postIDs s = postIDs s1 ∧ admin s = admin s1 ∧ eeqButPID (post s) (post s1) ∧ owner s = owner s1 ∧ vis s = vis s1 ∧ pendingSApiReqs s = pendingSApiReqs s1 ∧ sApiReq s = sApiReq s1 ∧ serverApiIDs s = serverApiIDs s1 ∧ serverPass s = serverPass s1 ∧ outerPostIDs s = outerPostIDs s1 ∧ outerPost s = outerPost s1 ∧ outerOwner s = outerOwner s1 ∧ outerVis s = outerVis s1 ∧ pendingCApiReqs s = pendingCApiReqs s1 ∧ cApiReq s = cApiReq s1 ∧ clientApiIDs s = clientApiIDs s1 ∧ clientPass s = clientPass s1 ∧ eeqButPID_F (sharedWith s) (sharedWith s1) ∧ IDsOK s = IDsOK s1 ⟹ pass s (admin s) = pass s1 (admin s)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have pPID1': "post s1' PID = pst1" using pPID1 (*‹post s1 PID = pst1›*) step1 (*‹step s1 a = (ou1, s1')›*) unfolding a (*goal: ‹post (s1'::state) (PID::postID) = (pst1::post)›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) have uid: "uid ∉ UIDs" unfolding uid (*goal: ‹admin s ∉ UIDs›*) using op (*‹¬ open s›*) PID (*‹PID ∈∈ postIDs s›*) adm (*‹admin s ∈∈ userIDs s›*) unfolding open_def (*goal: ‹admin s ∉ UIDs›*) by auto have op1': "¬ open s1'" using step1 (*‹step s1 a = (ou1, s1')›*) op1 (*‹¬ open s1›*) unfolding a open_def (*goal: ‹¬ (∃uid∈UIDs. uid ∈∈ userIDs s1' ∧ PID ∈∈ postIDs s1' ∧ (uid = admin s1' ∨ uid = owner s1' PID ∨ uid ∈∈ friendIDs s1' (owner s1' PID) ∨ vis s1' PID = PublicV))›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*) com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "φ ?trn1" using "eqButPID_step_φ_imp"[OF ss1 step step1 φ] (*‹φ (Trans s1 a ou1 s1')›*) . have ou1: "ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)" using "φ1" (*‹φ (Trans s1 a ou1 s1')›*) step1 (*‹step s1 a = (ou1, s1')›*) adm1 (*‹admin s1 ∈∈ userIDs s1›*) PID1 (*‹PID ∈∈ postIDs s1›*) unfolding a (*goal: ‹ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)›*) apply (cases ou1) (*goals: 1. ‹⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outOK⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 2. ‹⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outErr⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 3. ‹⋀x3. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outBool x3⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 4. ‹⋀x4. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outName x4⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 5. ‹⋀x5. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outPost x5⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 6. ‹⋀x6. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outVis x6⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 7. ‹⋀x7. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outReq x7⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 8. ‹⋀x8. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outUID x8⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 9. ‹⋀x9. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outUIDL x9⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 10. ‹⋀x10. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDL x10⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 11. ‹⋀x11. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDBL x11⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 12. ‹⋀x12. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outUIDPIDL x12⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 13. ‹⋀x13. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDPIDL x13⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 14. ‹⋀x14. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = outAIDUIDL x14⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 15. ‹⋀x15. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendServerReq x15⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 16. ‹⋀x16. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_connectClient x16⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 17. ‹⋀x17. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendPost x17⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 18. ‹⋀x18. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendCreateOFriend x18⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› 19. ‹⋀x19. ⟦φ (Trans s1 (COMact (comSendPost (admin s) p aid PID)) ou1 s1'); step s1 (COMact (comSendPost (admin s) p aid PID)) = (ou1, s1'); admin s1 ∈∈ userIDs s1; PID ∈∈ postIDs s1; ou1 = O_sendDeleteOFriend x19⟧ ⟹ ou1 = O_sendPost (aid, clientPass s1 aid, PID, post s1 PID, owner s1 PID, vis s1 PID)› discuss goal 1*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 2*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 3*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 4*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 5*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 6*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 7*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 8*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 9*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 10*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 11*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 12*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 13*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 14*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 15*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 16*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 17*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 18*) apply ((auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*discuss goal 19*) apply ((auto simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*))[1]) (*proven 19 subgoals*) . have f1: "f ?trn1 = v1" using "φ1" (*‹φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*) unfolding "φ_def2"[OF step1] v1 a ou1 aid1 pPID1 (*goal: ‹f (Trans s1 (COMact (comSendPost (admin s) p aid PID)) (O_sendPost (aid, clientPass s1 aid, PID, pst1, owner s1 PID, vis s1 PID)) s1') = PValS aid pst1›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID (s'::state) (s1'::state)›*) . have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step s1 a = (ou1, s1')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ31 s' vl' s1' ?vl1' ∨ Δ32 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 ?vl1'" using "φ1" (*‹φ (Trans (s1::state) (a::act) (ou1::out) (s1'::state))›*) unfolding consume_def ul1 f1 vl1 (*goal: ‹if φ (Trans s1 a ou1 s1') then (v1 # ull1) @ sul @ OVal True # vll1 ≠ [] ∧ v1 = hd ((v1 # ull1) @ sul @ OVal True # vll1) ∧ ull1 @ sul @ OVal True # vll1 = tl ((v1 # ull1) @ sul @ OVal True # vll1) else ull1 @ sul @ OVal True # vll1 = (v1 # ull1) @ sul @ OVal True # vll1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ31 s' vl' s1' (ull1 @ sul @ OVal True # vll1) ∨ Δ32 s' vl' s1' (ull1 @ sul @ OVal True # vll1)›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ31 s' vl' s1' (ull1 @ sul @ OVal True # vll1) ∨ Δ32 s' vl' s1' (ull1 @ sul @ OVal True # vll1)›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹⋀x2. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹⋀x3. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹⋀x4. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 5. ‹⋀x5. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 6. ‹⋀x6. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 7. ‹⋀x7. ⟦(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ31 s' vl' s1' (ull1 @ sul @ OVal True # vll1) ∨ Δ32 s' vl' s1' (ull1 @ sul @ OVal True # vll1)›*) have corr1: "corrFrom (post s1' PID) ?vl1'" using cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding vl1 ul1 v1 pPID1' (*goal: ‹corrFrom pst1 (ull1 @ sul @ OVal True # vll1)›*) by auto have ullull1: "ull1 ≠ [] ⟶ ull ≠ []" using ul (*‹(ul::value list) = (v::value) # (ull::value list)›*) ul1 (*‹ul1 = v1 # ull1›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) unfolding v v1 (*goal: ‹(ull1::value list) ≠ [] ⟶ (ull::value list) ≠ []›*) by fastforce have "Δ31 s' vl' s1' ?vl1'" using PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) op' (*‹¬ open s'›*) s's1' (*‹eqButPID s' s1'›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) (ul1::value list)›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last ul = last ul1›*) cor1 (*‹corrFrom (post (s1::state) (PID::postID)) (vl1::value list)›*) BO (*‹BO vll vll1›*) ful (*‹ul ≠ []›*) ful1 (*‹ul1 ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) lsul (*‹list_all isPValS sul›*) corr1 (*‹corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1)›*) ullull1 (*‹ull1 ≠ [] ⟶ ull ≠ []›*) unfolding "Δ31_def" vl vl1 v1 vl' ul' ul ul1 v (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1 sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1)›*) apply auto (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(ul::value list) (ul1::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ (ull::value list) @ (sul::value list) @ OVal True # (vll::value list) = ul @ sula @ OVal True # vlla ∧ (ull1::value list) @ sul @ OVal True # (vll1::value list) = ul1 @ sula @ OVal True # vll1a) ∧ eqButPID s' (s1'::state) ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ull"] (*‹(?P::value list ⇒ bool) (ull::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦BO (vll::value list) (vll1::value list); isPVal (last (ull1::value list)); list_all isPValS (sul::value list); corrFrom (post (s1'::state) (PID::postID)) (ull1 @ sul @ OVal True # vll1); (ull::value list) ≠ []; PID ∈∈ postIDs (s'::state); ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ull1; ull1 ≠ []; corrFrom (post (s1::state) PID) (ull1 @ sul @ OVal True # vll1); (aid::apiID) = (aid1::apiID); map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1); last ull = last ull1; (pst1::post) = post s1 PID⟧ ⟹ ∃(ul::value list) (ul1::value list) (sula::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ull1"] (*‹(?P::value list ⇒ bool) (ull1::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦BO vll vll1; isPVal (last ull1); list_all isPValS sul; corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1); ull ≠ []; PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ull1; ull1 ≠ []; corrFrom (post s1 PID) (ull1 @ sul @ OVal True # vll1); aid = aid1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1); last ull = last ull1; pst1 = post s1 PID⟧ ⟹ ∃ul1 sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ul1) ∧ ull ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ul1 ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ull @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦BO vll vll1; isPVal (last ull1); list_all isPValS sul; corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1); ull ≠ []; PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ull1; ull1 ≠ []; corrFrom (post s1 PID) (ull1 @ sul @ OVal True # vll1); aid = aid1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1); last ull = last ull1; pst1 = post s1 PID⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ull1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1) ∧ ull ≠ [] ∧ ull1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ull1 ∧ list_all isPValS sula ∧ ull @ sul @ OVal True # vll = ull @ sula @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ull1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦BO vll vll1; isPVal (last ull1); list_all isPValS sul; corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1); ull ≠ []; PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ull1; ull1 ≠ []; corrFrom (post s1 PID) (ull1 @ sul @ OVal True # vll1); aid = aid1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1); last ull = last ull1; pst1 = post s1 PID⟧ ⟹ ∃vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ull1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1) ∧ ull ≠ [] ∧ ull1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ull1 ∧ list_all isPValS sul ∧ ull @ sul @ OVal True # vll = ull @ sul @ OVal True # vlla ∧ ull1 @ sul @ OVal True # vll1 = ull1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦BO vll vll1; isPVal (last ull1); list_all isPValS sul; corrFrom (post s1' PID) (ull1 @ sul @ OVal True # vll1); ull ≠ []; PID ∈∈ postIDs s'; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ull; list_all (Not ∘ isOVal) ull1; ull1 ≠ []; corrFrom (post s1 PID) (ull1 @ sul @ OVal True # vll1); aid = aid1; map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1); last ull = last ull1; pst1 = post s1 PID⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ull ∧ list_all (Not ∘ isOVal) ull1 ∧ map tgtAPI (filter isPValS ull) = map tgtAPI (filter isPValS ull1) ∧ ull ≠ [] ∧ ull1 ≠ [] ∧ isPVal (last ull) ∧ last ull = last ull1 ∧ list_all isPValS sul ∧ ull @ sul @ OVal True # vll = ull @ sul @ OVal True # vll ∧ ull1 @ sul @ OVal True # vll1 = ull1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1' ?vl1'" by simp qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) using ul (*‹(ul::value list) = (v::value) # (ull::value list)›*) by simp next (*goal: ‹⋀x3::bool. (v::value) = OVal x3 ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) qed (insert lul (*‹list_all (Not ∘ isOVal) ul›*) ul (*‹ul = v # ull›*), auto) (*solved the remaining goal: ‹⋀x3::bool. (v::value) = OVal x3 ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) next (*goal: ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ φ (Trans s a ou s')›*) note "φ" = False (*‹¬ φ (Trans s a ou s')›*) hence ul': "ul' = ul" using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding consume_def (*goal: ‹(ul'::value list) = (ul::value list)›*) by auto obtain ou1 and s1' where step1: "step s1 a = (ou1, s1')" (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) apply (cases "step s1 a") (*goal: ‹(⋀ou1 s1'. step s1 a = (ou1, s1') ⟹ thesis) ⟹ thesis›*) by auto have s's1': "eqButPID s' s1'" using eqButPID_step[OF ss1 step step1] (*‹eqButPID s' s1'›*) . let ?trn1 = "Trans s1 a ou1 s1'" have "φ1": "¬ φ ?trn1" using "φ" (*‹¬ φ (Trans s a ou s')›*) ss1 (*‹eqButPID (s::state) (s1::state)›*) by (simp add: eqButPID_step_φ (*‹⟦eqButPID ?s ?s1.0; step ?s ?a = (?ou, ?s'); step ?s1.0 ?a = (?ou1.0, ?s1')⟧ ⟹ φ (Trans ?s ?a ?ou ?s') = φ (Trans ?s1.0 ?a ?ou1.0 ?s1')›*) step (*‹step s a = (ou, s')›*) step1 (*‹step s1 a = (ou1, s1')›*)) have pPID1': "post s1' PID = pst1" using PID1 (*‹(PID::postID) ∈∈ postIDs (s1::state)›*) pPID1 (*‹post s1 PID = pst1›*) step1 (*‹step (s1::state) (a::act) = (ou1::out, s1'::state)›*) "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) apply (cases a) (*goal: ‹post (s1'::state) (PID::postID) = (pst1::post)›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Sact x1⟧ ⟹ post s1' PID = pst1›*) by (fastforce simp: s_defs (*‹e_startSys (?s::state) (?uID::userID) (?p::password) ≡ userIDs ?s = []› ‹startSys (?s::state) (?uID::userID) (?p::password) ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s1' PID = pst1› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s1' PID = pst1› 3. ‹⋀x31 x32 x33. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s1' PID = pst1› 4. ‹⋀x41 x42 x43 x44. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s1' PID = pst1› 5. ‹⋀x51 x52 x53. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s1' PID = pst1› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s1::state); post s1 PID = (pst1::post); step s1 (a::act) = (ou1::out, s1'::state); ¬ φ (Trans s1 a ou1 s1'); a = Dact (x3::dActt)⟧ ⟹ post s1' PID = pst1›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s1' PID = pst1› 2. ‹⋀x21 x22 x23 x24. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s1' PID = pst1› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s1' PID = pst1› discuss goal 1*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 2*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*discuss goal 3*) apply (fastforce simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s1' PID = pst1› 2. ‹⋀x21 x22. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s1' PID = pst1› 3. ‹⋀x31 x32 x33 x34. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s1' PID = pst1› 4. ‹⋀x41 x42. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s1' PID = pst1› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s1' PID = pst1› 6. ‹⋀x61 x62 x63 x64. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s1' PID = pst1› 7. ‹⋀x71 x72 x73 x74. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s1' PID = pst1› 8. ‹⋀x81 x82 x83 x84. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s1' PID = pst1› 9. ‹⋀x91 x92 x93 x94. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s1' PID = pst1› 10. ‹⋀x101 x102 x103 x104. ⟦PID ∈∈ postIDs s1; post s1 PID = pst1; step s1 a = (ou1, s1'); ¬ φ (Trans s1 a ou1 s1'); a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s1' PID = pst1› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) by auto have "?match" proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step1 (*‹step s1 a = (ou1, s1')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou1 s1') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 4. ‹Δ31 s' vl' s1' ?vl1' ∨ Δ32 s' vl' s1' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ1" (*‹¬ φ (Trans s1 a ou1 s1')›*) unfolding consume_def (*goal: ‹if φ (Trans s1 a ou1 s1') then vl1 ≠ [] ∧ f (Trans s1 a ou1 s1') = hd vl1 ∧ vl1 = tl vl1 else vl1 = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou1 s1')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 3. ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) a (ou1::out) (s1'::state))›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou1 s1')› 2. ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) have ou: "(∃ uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1" using "eqButPID_step_γ_out"[OF ss1 step step1 op rsT rs1 γ] (*‹(∃uid p aid pid. a = COMact (comSendPost uid p aid pid) ∧ outPurge ou = outPurge ou1) ∨ ou = ou1›*) . thus "g ?trn = g ?trn1" apply (cases a) (*goals: 1. ‹⋀x1::sActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Sact x1⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 2. ‹⋀x2::cActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Cact x2⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 3. ‹⋀x3::dActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Dact x3⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 4. ‹⋀x4::uActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Uact x4⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 5. ‹⋀x5::rActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Ract x5⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 6. ‹⋀x6::lActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = Lact x6⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› 7. ‹⋀x7::comActt. ⟦(∃(uid::userID) (p::password) (aid::apiID) pid::postID. (a::act) = COMact (comSendPost uid p aid pid) ∧ outPurge (ou::out) = outPurge (ou1::out)) ∨ ou = ou1; a = COMact x7⟧ ⟹ g (Trans (s::state) a ou (s'::state)) = g (Trans (s1::state) a ou1 (s1'::state))› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . next (*goal: ‹Δ31 s' vl' s1' vl1 ∨ Δ32 s' vl' s1' vl1›*) have "Δ31 s' vl' s1' vl1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID1 (*‹post (s1::state) (PID::postID) = (pst1::post)›*) pPID1' (*‹post s1' PID = pst1›*) op' (*‹¬ open s'›*) s's1' (*‹eqButPID s' s1'›*) lul (*‹list_all (Not ∘ isOVal) ul›*) lul1 (*‹list_all (Not ∘ isOVal) ul1›*) map (*‹map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1)›*) ulul1 (*‹last (ul::value list) = last (ul1::value list)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) ful (*‹(ul::value list) ≠ []›*) ful1 (*‹ul1 ≠ []›*) lastul (*‹isPVal (last ul)›*) ulul1 (*‹last ul = last ul1›*) lsul (*‹list_all isPValS (sul::value list)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) unfolding "Δ31_def" vl vl1 v1 vl' ul' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ul1 @ sul @ OVal True # vll1)›*) apply simp (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a) ∧ eqButPID s' s1' ∧ ¬ open s' ∧ corrFrom (post s1' PID) (ul1 @ sul @ OVal True # vll1)›*) apply (rule exI[of _ "ul"] (*‹?P ul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1 PID = pst1; post s1' PID = pst1; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); corrFrom pst1 (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul⟧ ⟹ ∃ula ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ula ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ula) = map tgtAPI (filter isPValS ul1a) ∧ ula ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ula) ∧ last ula = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ula @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "ul1"] (*‹?P ul1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1 PID = pst1; post s1' PID = pst1; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); corrFrom pst1 (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul⟧ ⟹ ∃ul1a sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1a ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1a) ∧ ul ≠ [] ∧ ul1a ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1a ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1a @ sula @ OVal True # vll1a›*) apply (rule exI[of _ sul] (*‹?P sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1 PID = pst1; post s1' PID = pst1; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); corrFrom pst1 (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul⟧ ⟹ ∃sula vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sula ∧ ul @ sul @ OVal True # vll = ul @ sula @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sula @ OVal True # vll1a›*) apply (rule exI[of _ "vll"] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s'::state); post (s1::state) PID = (pst1::post); post (s1'::state) PID = pst1; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) (ul::value list); list_all (Not ∘ isOVal) (ul1::value list); map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); corrFrom pst1 (ul1 @ (sul::value list) @ OVal True # (vll1::value list)); BO (vll::value list) vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul⟧ ⟹ ∃(vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vlla ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) apply (rule exI[of _ "vll1"] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s1 PID = pst1; post s1' PID = pst1; ¬ open s'; eqButPID s' s1'; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); corrFrom pst1 (ul1 @ sul @ OVal True # vll1); BO vll vll1; ul ≠ []; ul1 ≠ []; isPVal (last ul1); last ul = last ul1; list_all isPValS sul⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ ul @ sul @ OVal True # vll = ul @ sul @ OVal True # vll ∧ ul1 @ sul @ OVal True # vll1 = ul1 @ sul @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s1' vl1" by simp qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) using vl (*‹(vl::value list) = (ul::value list) @ (sul::value list) @ OVal True # (vll::value list)›*) by simp qed (insert lul1 (*‹list_all (Not ∘ isOVal) ul1›*) ul1 (*‹ul1 = v1 # ull1›*), auto) (*solved the remaining goal: ‹⋀x3. v1 = OVal x3 ⟹ iaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1) s vl s1 vl1›*) qed lemma unwind_cont_Δ32: "unwind_cont Δ32 {Δ2,Δ32,Δ4}" apply rule (*goal: ‹unwind_cont Δ32 {Δ2, Δ32, Δ4}›*) proof (simp) (*goal: ‹⋀s vl s1 vl1. ⟦reachNT s; reach s1; Δ32 s vl s1 vl1⟧ ⟹ iaction (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ32 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ32 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) then obtain ul and vll and vll1 where lul: "list_all isPValS ul" and rs: "reach s" and ss1: "s1 = s" and op: "¬ open s" and PID: "PID ∈∈ postIDs s" and cor1: "corrFrom (post s1 PID) vl1" and vl: "vl = ul @ OVal True # vll" and vl1: "vl1 = ul @ OVal True # vll1" and BO: "BO vll vll1" (*goal: ‹(⋀(ul::value list) (vll::value list) vll1::value list. ⟦list_all isPValS ul; reach (s::state); (s1::state) = s; ¬ open s; (PID::postID) ∈∈ postIDs s; corrFrom (post s1 PID) (vl1::value list); (vl::value list) = ul @ OVal True # vll; vl1 = ul @ OVal True # vll1; BO vll vll1⟧ ⟹ thesis::bool) ⟹ thesis›*) using reachNT_reach (*‹reachNT ?s ⟹ reach ?s›*) unfolding "Δ32_def" (*goal: ‹(⋀ul vll vll1. ⟦list_all isPValS ul; reach s; s1 = s; ¬ open s; PID ∈∈ postIDs s; corrFrom (post s1 PID) vl1; vl = ul @ OVal True # vll; vl1 = ul @ OVal True # vll1; BO vll vll1⟧ ⟹ thesis) ⟹ thesis›*) by blast have own: "owner s PID ∈ set (userIDs s)" using reach_owner_userIDs[OF rs PID] (*‹owner s PID ∈∈ userIDs s›*) . have adm: "admin s ∈ set (userIDs s)" using reach_admin_userIDs[OF rs own] (*‹admin s ∈∈ userIDs s›*) . show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (-) (*goal: ‹iaction (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) have "?react" proof (standard) (*goal: ‹⋀a ou s' vl'. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'⟧ ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" let ?trn1 = "Trans s1 a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹PID ∈∈ postIDs s'›*) . show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (-) (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) have "?match" proof (cases "ul = []") (*goals: 1. ‹ul = [] ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹ul ≠ [] ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹ul ≠ []›*) note ul = False (*‹ul ≠ []›*) then obtain ul' where cc: "consume ?trn ul ul'" and vl': "vl' = ul' @ OVal True # vll" (*goal: ‹(⋀ul'. ⟦consume (Trans s a ou s') ul ul'; vl' = ul' @ OVal True # vll⟧ ⟹ thesis) ⟹ thesis›*) using vl (*‹(vl::value list) = (ul::value list) @ OVal True # (vll::value list)›*) c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹(⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ OVal True # vll⟧ ⟹ thesis) ⟹ thesis›*) apply (cases "φ ?trn") (*goals: 1. ‹⟦⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ OVal True # vll⟧ ⟹ thesis; ul ≠ []; vl = ul @ OVal True # vll; if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; φ (Trans s a ou s')⟧ ⟹ thesis› 2. ‹⟦⋀ul'. ⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; vl' = ul' @ OVal True # vll⟧ ⟹ thesis; ul ≠ []; vl = ul @ OVal True # vll; if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; ¬ φ (Trans s a ou s')⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?vl1' = "ul' @ OVal True # vll1" show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ2 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list) ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step (*‹step s a = (ou, s')›*) unfolding ss1 (*goal: ‹validTrans (Trans (s::state) (a::act) (ou::out) (s'::state))›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ2 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 ?vl1'" using cc (*‹consume (Trans s a ou s') ul ul'›*) ul (*‹ul ≠ []›*) unfolding vl1 consume_def ss1 (*goal: ‹if φ (Trans s a ou s') then ul @ OVal True # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal True # vll1) ∧ ul' @ OVal True # vll1 = tl (ul @ OVal True # vll1) else ul' @ OVal True # vll1 = ul @ OVal True # vll1›*) apply (cases "φ ?trn") (*goals: 1. ‹⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; ul ≠ []; φ (Trans s a ou s')⟧ ⟹ if φ (Trans s a ou s') then ul @ OVal True # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal True # vll1) ∧ ul' @ OVal True # vll1 = tl (ul @ OVal True # vll1) else ul' @ OVal True # vll1 = ul @ OVal True # vll1› 2. ‹⟦if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; ul ≠ []; ¬ φ (Trans s a ou s')⟧ ⟹ if φ (Trans s a ou s') then ul @ OVal True # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal True # vll1) ∧ ul' @ OVal True # vll1 = tl (ul @ OVal True # vll1) else ul' @ OVal True # vll1 = ul @ OVal True # vll1› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ2 s' vl' s' (ul' @ OVal True # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal True # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal True # vll1)›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a ou s')› 2. ‹Δ2 (s'::state) (vl'::value list) s' ((ul'::value list) @ OVal True # (vll1::value list)) ∨ Δ32 s' vl' s' (ul' @ OVal True # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal True # vll1)›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans (s::state) (a::act) (ou::out) (s'::state)) = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ2 s' vl' s' (ul' @ OVal True # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal True # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal True # vll1)›*) have "Δ32 s' vl' s' ?vl1'" proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ Δ32 s' vl' s' (ul' @ OVal True # vll1)› 2. ‹¬ φ (Trans s a ou s') ⟹ Δ32 s' vl' s' (ul' @ OVal True # vll1)›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain v where f: "f ?trn = v" and ul: "ul = v # ul'" (*goal: ‹(⋀v::value. ⟦f (Trans (s::state) (a::act) (ou::out) (s'::state)) = v; (ul::value list) = v # (ul'::value list)⟧ ⟹ thesis::bool) ⟹ thesis›*) using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding consume_def (*goal: ‹(⋀v::value. ⟦f (Trans (s::state) (a::act) (ou::out) (s'::state)) = v; (ul::value list) = v # (ul'::value list)⟧ ⟹ thesis::bool) ⟹ thesis›*) apply (cases ul) (*goals: 1. ‹⟦⋀v. ⟦f (Trans s a ou s') = v; ul = v # ul'⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; ul = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀v. ⟦f (Trans s a ou s') = v; ul = v # ul'⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; ul = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . define uid where uid: "uid ≡ admin s" define p where p: "p ≡ pass s uid" obtain aid and pst where v: "v = PValS aid pst" (*goal: ‹(⋀aid pst. v = PValS aid pst ⟹ thesis) ⟹ thesis›*) using lul (*‹list_all isPValS ul›*) unfolding ul (*goal: ‹(⋀aid pst. v = PValS aid pst ⟹ thesis) ⟹ thesis›*) apply (cases v) (*goals: 1. ‹⋀x1. ⟦⋀aid pst. v = PValS aid pst ⟹ thesis; list_all isPValS (v # ul'); v = PVal x1⟧ ⟹ thesis› 2. ‹⋀x21 x22. ⟦⋀aid pst. v = PValS aid pst ⟹ thesis; list_all isPValS (v # ul'); v = PValS x21 x22⟧ ⟹ thesis› 3. ‹⋀x3. ⟦⋀aid pst. v = PValS aid pst ⟹ thesis; list_all isPValS (v # ul'); v = OVal x3⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . have a: "a = COMact (comSendPost (admin s) p aid PID)" using f_eq_PValS[OF step φ f [ unfolded v ]] (*‹(a::act) = COMact (comSendPost (admin (s::state)) (pass s (admin s)) (aid::apiID) (PID::postID))›*) unfolding uid p (*goal: ‹a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)›*) . have op': "¬ open s'" using uPost_comSendPost_open_eq[OF step] (*‹a = Uact (uPost ?uid ?p ?pid ?pst) ∨ a = COMact (comSendPost ?uid ?p ?aid ?pid) ⟹ open s' = open s›*) a (*‹a = COMact (comSendPost (admin s) p aid PID)›*) op (*‹¬ open (s::state)›*) by auto have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) unfolding a (*goal: ‹post s' PID = post s PID›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) show "?thesis" (*goal: ‹Δ32 s' vl' s' (ul' @ OVal True # vll1)›*) using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹¬ open s'›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) lul (*‹list_all isPValS ul›*) unfolding "Δ32_def" vl1 ul ss1 v vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃sul vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ ul' @ OVal True # vll = sul @ OVal True # vlla ∧ ul' @ OVal True # vll1 = sul @ OVal True # vll1a) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom (post s' PID) (ul' @ OVal True # vll1)›*) by auto next (*goal: ‹¬ φ (Trans s a ou s') ⟹ Δ32 s' vl' s' (ul' @ OVal True # vll1)›*) case False (*‹¬ φ (Trans s a ou s')›*) note "φ" = False (*‹¬ φ (Trans s a ou s')›*) hence ul: "ul = ul'" using cc (*‹consume (Trans s a ou s') ul ul'›*) unfolding consume_def (*goal: ‹ul = ul'›*) apply (cases ul) (*goals: 1. ‹⟦¬ φ (Trans s a ou s'); if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; ul = []⟧ ⟹ ul = ul'› 2. ‹⋀aa list. ⟦¬ φ (Trans s a ou s'); if φ (Trans s a ou s') then ul ≠ [] ∧ f (Trans s a ou s') = hd ul ∧ ul' = tl ul else ul' = ul; ul = aa # list⟧ ⟹ ul = ul'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) op (*‹¬ open s›*) apply (cases a) (*goal: ‹post s' PID = post s PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; a = Sact (x1::sActt)⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀(x11::userID) x12::requestInfo. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; a = Cact (x2::cActt); x2 = cNUReq x11 x12⟧ ⟹ post s' PID = post s PID› 2. ‹⋀(x21::userID) (x22::password) (x23::userID) x24::password. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; a = Cact (x2::cActt); x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀(x31::userID) (x32::password) x33::postID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; a = Cact (x2::cActt); x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = post s PID› 4. ‹⋀(x41::userID) (x42::password) (x43::userID) x44::requestInfo. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; a = Cact (x2::cActt); x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = post s PID› 5. ‹⋀(x51::userID) (x52::password) x53::userID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; a = Cact (x2::cActt); x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Dact x3⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = post s PID› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = post s PID› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = post s PID› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = post s PID› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = post s PID› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) by auto show "?thesis" (*goal: ‹Δ32 s' vl' s' (ul' @ OVal True # vll1)›*) using PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) pPID' (*‹post (s'::state) (PID::postID) = post (s::state) PID›*) op' (*‹¬ open (s'::state)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO (vll::value list) (vll1::value list)›*) lul (*‹list_all isPValS ul›*) unfolding "Δ32_def" vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃sul vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ ul' @ OVal True # vll = sul @ OVal True # vlla ∧ ul' @ OVal True # vll1 = sul @ OVal True # vll1a) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom (post s' PID) (ul' @ OVal True # vll1)›*) by auto qed thus "?Δ s' vl' s' ?vl1'" by simp qed next (*goal: ‹ul = [] ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹ul = []›*) note ul = True (*‹ul = []›*) show "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list)›*) proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "φ" = True (*‹φ (Trans s a ou s')›*) hence f: "f ?trn = OVal True" and vl': "vl' = vll" using vl (*‹vl = ul @ OVal True # vll›*) c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def ul (*goals: 1. ‹f (Trans (s::state) (a::act) (ou::out) (s'::state)) = OVal True› 2. ‹(vl'::value list) = (vll::value list)›*) apply - (*goals: 1. ‹⟦φ (Trans s a ou s'); vl = [] @ OVal True # vll; if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl⟧ ⟹ f (Trans s a ou s') = OVal True› 2. ‹⟦φ (Trans s a ou s'); vl = [] @ OVal True # vll; if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl⟧ ⟹ vl' = vll› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have op': "open s'" using f_eq_OVal[OF step φ f] (*‹open s' ≠ open s›*) op (*‹¬ open (s::state)›*) by simp show "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list)›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ2 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step (*‹step s a = (ou, s')›*) unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ2 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vll1" using ul (*‹ul = []›*) "φ" (*‹φ (Trans s a ou s')›*) c (*‹consume (Trans s a ou s') vl vl'›*) unfolding vl1 vl' vl ss1 consume_def (*goal: ‹if φ (Trans s a ou s') then ul @ OVal True # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal True # vll1) ∧ vll1 = tl (ul @ OVal True # vll1) else vll1 = ul @ OVal True # vll1›*) by auto next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹φ (Trans s a ou s')›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) op (*‹¬ open s›*) op' (*‹open (s'::state)›*) f (*‹f (Trans s a ou s') = OVal True›*) apply (cases a) (*goal: ‹post (s'::state) (PID::postID) = post (s::state) PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Sact (x1::sActt)⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀(x11::userID) x12::requestInfo. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Cact (x2::cActt); x2 = cNUReq x11 x12⟧ ⟹ post s' PID = post s PID› 2. ‹⋀(x21::userID) (x22::password) (x23::userID) x24::password. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Cact (x2::cActt); x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀(x31::userID) (x32::password) x33::postID. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Cact (x2::cActt); x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = post s PID› 4. ‹⋀(x41::userID) (x42::password) (x43::userID) x44::requestInfo. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Cact (x2::cActt); x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = post s PID› 5. ‹⋀(x51::userID) (x52::password) x53::userID. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Cact (x2::cActt); x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Dact x3⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀(x11::userID) (x12::password) (x13::password) (x14::name) x15::inform. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Uact (x4::uActt); x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = post s PID› 2. ‹⋀(x21::userID) (x22::password) (x23::postID) x24::post. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Uact (x4::uActt); x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀(x31::userID) (x32::password) (x33::postID) x34::vis. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = Uact (x4::uActt); x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = post s PID› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = post s PID› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = post s PID› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = post s PID› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = post s PID› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; open s'; f (Trans s a ou s') = OVal True; a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . show "?Δ s' vl' s' vll1" using BO (*‹BO (vll::value list) (vll1::value list)›*) proof (cases) (*goals: 1. ‹⟦vll1 = vll; list_all (Not ∘ isOVal) vll⟧ ⟹ Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1› 2. ‹⋀vl vl1 ul. ⟦vll = ul @ OVal False # vl; vll1 = ul @ OVal False # vl1; BC vl vl1; list_all (Not ∘ isOVal) ul⟧ ⟹ Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) case BO_PVal (*‹vll1 = vll› ‹list_all (Not ∘ isOVal) vll›*) hence "Δ2 s' vl' s' vll1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹open s'›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO (vll::value list) (vll1::value list)›*) lul (*‹list_all isPValS ul›*) unfolding "Δ2_def" vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vll ∧ vll = vll1 ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) vll1›*) by auto thus "?thesis" (*goal: ‹Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) by simp next (*goal: ‹⋀vl vl1 ul. ⟦vll = ul @ OVal False # vl; vll1 = ul @ OVal False # vl1; BC vl vl1; list_all (Not ∘ isOVal) ul⟧ ⟹ Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) case BO_BC (*‹vll = ul_ @ OVal False # vl_› ‹(vll1::value list) = (ul_::value list) @ OVal False # (vl1_::value list)› ‹BC vl_ vl1_› ‹list_all (Not ∘ isOVal) ul_›*) hence "Δ4 s' vl' s' vll1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹open (s'::state)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) lul (*‹list_all isPValS ul›*) unfolding "Δ4_def" vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul vlla vll1a. BC vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ vll = ul @ OVal False # vlla ∧ vll1 = ul @ OVal False # vll1a) ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) vll1›*) by auto thus "?thesis" (*goal: ‹Δ2 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) by simp qed qed next (*goal: ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ φ (Trans s a ou s')›*) note "φ" = False (*‹¬ φ (Trans s a ou s')›*) hence vl': "vl' = vl" using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹vl' = vl›*) by auto have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) PID (*‹PID ∈∈ postIDs s›*) op (*‹¬ open s›*) apply (cases a) (*goal: ‹post s' PID = post s PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Sact x1⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42 x43 x44. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Dact x3⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = post s PID› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = post s PID› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = post s PID› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = post s PID› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = post s PID› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; ¬ open s; a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "¬ open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹¬ open s›*) unfolding "φ_def2"[OF step] (*goal: ‹¬ open s'›*) apply (cases a) (*goals: 1. ‹⋀x1. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = Sact x1⟧ ⟹ ¬ open s'› 2. ‹⋀x2. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = Cact x2⟧ ⟹ ¬ open s'› 3. ‹⋀x3. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = Dact x3⟧ ⟹ ¬ open s'› 4. ‹⋀x4. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = Uact x4⟧ ⟹ ¬ open s'› 5. ‹⋀x5. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = Ract x5⟧ ⟹ ¬ open s'› 6. ‹⋀x6. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = Lact x6⟧ ⟹ ¬ open s'› 7. ‹⋀x7. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); ¬ open s; a = COMact x7⟧ ⟹ ¬ open s'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ2 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list) ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) by simp next (*goals: 1. ‹consume (Trans (s1::state) (a::act) (ou::out) (s'::state)) (vl1::value list) (?vl1'::value list)› 2. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) a ou s')› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a ou s')› 4. ‹Δ2 (s'::state) (vl'::value list) s' (?vl1'::value list) ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl1" using ul (*‹ul = []›*) "φ" (*‹¬ φ (Trans s a ou s')›*) unfolding vl1 consume_def ss1 (*goal: ‹if φ (Trans s a ou s') then ul @ OVal True # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal True # vll1) ∧ ul @ OVal True # vll1 = tl (ul @ OVal True # vll1) else ul @ OVal True # vll1 = ul @ OVal True # vll1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ2 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ2 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ2 (s'::state) (vl'::value list) s' (vl1::value list) ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) have "Δ32 s' vl' s' vl1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹¬ open s'›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BO (*‹BO vll vll1›*) lul (*‹list_all isPValS ul›*) unfolding "Δ32_def" vl vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃sul vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ [] @ OVal True # vll = sul @ OVal True # vlla ∧ [] @ OVal True # vll1 = sul @ OVal True # vll1a) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom (post s' PID) ([] @ OVal True # vll1)›*) apply simp (*goal: ‹PID ∈∈ postIDs s' ∧ (∃sul vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ [] @ OVal True # vll = sul @ OVal True # vlla ∧ [] @ OVal True # vll1 = sul @ OVal True # vll1a) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom (post s' PID) ([] @ OVal True # vll1)›*) apply (rule exI[of _ "[]"] (*‹?P [] ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) vll1; BO vll vll1⟧ ⟹ ∃sul vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ OVal True # vll = sul @ OVal True # vlla ∧ OVal True # vll1 = sul @ OVal True # vll1a›*) apply (rule exI[of _ vll] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(PID::postID) ∈∈ postIDs (s'::state); post s' PID = post (s::state) PID; ¬ open s'; corrFrom (post s PID) (vll1::value list); BO (vll::value list) vll1⟧ ⟹ ∃(vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all isPValS [] ∧ OVal True # vll = [] @ OVal True # vlla ∧ OVal True # vll1 = [] @ OVal True # vll1a›*) apply (rule exI[of _ vll1] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) vll1; BO vll vll1⟧ ⟹ ∃vll1a. BO vll vll1a ∧ list_all isPValS [] ∧ OVal True # vll = [] @ OVal True # vll ∧ OVal True # vll1 = [] @ OVal True # vll1a›*) by auto thus "?Δ s' vl' s' vl1" by simp qed qed qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ2 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) using vl (*‹(vl::value list) = (ul::value list) @ OVal True # (vll::value list)›*) by simp qed qed lemma unwind_cont_Δ2: "unwind_cont Δ2 {Δ2}" apply rule (*goal: ‹unwind_cont Δ2 {Δ2}›*) proof (simp) (*goal: ‹⋀(s::state) (vl::value list) (s1::state) vl1::value list. ⟦reachNT s; reach s1; Δ2 s vl s1 vl1⟧ ⟹ iaction Δ2 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ2 s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ2 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ2 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ2 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) hence vlvl1: "vl = vl1" and rs: "reach s" and ss1: "s1 = s" and op: "open s" and PID: "PID ∈∈ postIDs s" and cor1: "corrFrom (post s1 PID) vl1" and lvl: "list_all (Not ∘ isOVal) vl" using reachNT_reach (*‹reachNT ?s ⟹ reach ?s›*) unfolding "Δ2_def" (*goals: 1. ‹vl = vl1› 2. ‹reach s› 3. ‹s1 = s› 4. ‹open s› 5. ‹PID ∈∈ postIDs s› 6. ‹corrFrom (post s1 PID) vl1› 7. ‹list_all (Not ∘ isOVal) vl›*) apply - (*goals: 1. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ vl = vl1› 2. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ reach s› 3. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ s1 = s› 4. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ open s› 5. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ PID ∈∈ postIDs s› 6. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ corrFrom (post s1 PID) vl1› 7. ‹⟦reachNT s; reach s1; PID ∈∈ postIDs s ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl1 ∧ s = s1 ∧ open s ∧ corrFrom (post s1 PID) vl1; ⋀s. reachNT s ⟹ reach s⟧ ⟹ list_all (Not ∘ isOVal) vl› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . have own: "owner s PID ∈ set (userIDs s)" using reach_owner_userIDs[OF rs PID] (*‹owner s PID ∈∈ userIDs s›*) . have adm: "admin s ∈ set (userIDs s)" using reach_admin_userIDs[OF rs own] (*‹admin s ∈∈ userIDs s›*) . show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (-) (*goal: ‹iaction Δ2 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ2 s vl s1 vl1›*) have "?react" proof (standard) (*goal: ‹⋀a ou s' vl'. ⟦step s a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') vl vl'⟧ ⟹ match Δ2 s s1 vl1 a ou s' vl' ∨ ignore Δ2 s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" let ?trn1 = "Trans s1 a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) . show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (-) (*goal: ‹match Δ2 s s1 vl1 a ou s' vl' ∨ ignore Δ2 s s1 vl1 a ou s' vl'›*) have "?match" proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ match Δ2 s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans s a ou s') ⟹ match Δ2 s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain v where vl: "vl = v # vl'" and f: "f ?trn = v" (*goal: ‹(⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) using c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) unfolding consume_def "φ_def2" (*goal: ‹(⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) apply (cases vl) (*goals: 1. ‹⟦⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹match Δ2 s s1 vl1 a ou s' vl'›*) proof (cases v) (*goals: 1. ‹⋀x1. v = PVal x1 ⟹ match Δ2 s s1 vl1 a ou s' vl'› 2. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match Δ2 s s1 vl1 a ou s' vl'› 3. ‹⋀x3. v = OVal x3 ⟹ match Δ2 s s1 vl1 a ou s' vl'›*) case (PVal pst) (*‹v = PVal pst›*) note v = PVal (*‹v = PVal pst›*) have a: "a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)" using f_eq_PVal[OF step φ f [ unfolded v ]] (*‹a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)›*) . have ou: "ou = outOK" using step (*‹step s a = (ou, s')›*) own (*‹owner (s::state) (PID::postID) ∈∈ userIDs s›*) PID (*‹PID ∈∈ postIDs s›*) unfolding a (*goal: ‹ou = outOK›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have op': "open s'" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) op (*‹open (s::state)›*) PID (*‹PID ∈∈ postIDs s›*) PID' (*‹PID ∈∈ postIDs s'›*) "φ" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) unfolding open_def a (*goal: ‹∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV)›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have pPID': "post s' PID = pst" using step (*‹step s a = (ou, s')›*) "φ" (*‹φ (Trans s a ou s')›*) PID (*‹PID ∈∈ postIDs s›*) op (*‹open s›*) f (*‹f (Trans s a ou s') = v›*) op' (*‹open s'›*) unfolding a (*goal: ‹post s' PID = pst›*) by (auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) show "?thesis" (*goal: ‹match Δ2 s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ2 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list)›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ2 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl'" using "φ" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) vlvl1 (*‹vl = vl1›*) unfolding ss1 consume_def vl f (*goal: ‹if φ (Trans (s::state) (a::act) (ou::out) (s'::state)) then (vl1::value list) ≠ [] ∧ (v::value) = hd vl1 ∧ (vl'::value list) = tl vl1 else vl' = vl1›*) by auto next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ2 s' vl' s' vl'›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ2 s' vl' s' vl'›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ2 s' vl' s' vl'›*) show "?Δ s' vl' s' vl'" using cor1 (*‹corrFrom (post s1 PID) vl1›*) PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = pst›*) op' (*‹open s'›*) lvl (*‹list_all (Not ∘ isOVal) (vl::value list)›*) vlvl1 (*‹vl = vl1›*) ss1 (*‹s1 = s›*) unfolding "Δ2_def" vl v (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl' ∧ vl' = vl' ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) vl'›*) by auto qed next (*goals: 1. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match Δ2 s s1 vl1 a ou s' vl'› 2. ‹⋀x3. v = OVal x3 ⟹ match Δ2 s s1 vl1 a ou s' vl'›*) case (PValS aid pid) (*‹v = PValS aid pid›*) note v = PValS (*‹v = PValS aid pid›*) have a: "a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)" using f_eq_PValS[OF step φ f [ unfolded v ]] (*‹(a::act) = COMact (comSendPost (admin (s::state)) (pass s (admin s)) (aid::apiID) (PID::postID))›*) . have op': "open s'" using step (*‹step s a = (ou, s')›*) op (*‹open s›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) PID' (*‹PID ∈∈ postIDs s'›*) "φ" (*‹φ (Trans s a ou s')›*) unfolding open_def a (*goal: ‹∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV)›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) have ou: "ou ≠ outErr" using "φ" (*‹φ (Trans s a ou s')›*) op (*‹open s›*) op' (*‹open s'›*) unfolding "φ_def2"[OF step] (*goal: ‹ou ≠ outErr›*) unfolding a (*goal: ‹ou ≠ outErr›*) by auto have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹φ (Trans s a ou s')›*) PID (*‹PID ∈∈ postIDs s›*) op (*‹open s›*) f (*‹f (Trans s a ou s') = v›*) op' (*‹open s'›*) unfolding a (*goal: ‹post s' PID = post s PID›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) show "?thesis" (*goal: ‹match Δ2 s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ2 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list)›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ2 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl'" using "φ" (*‹φ (Trans s a ou s')›*) vlvl1 (*‹vl = vl1›*) unfolding ss1 consume_def vl f (*goal: ‹if φ (Trans (s::state) (a::act) (ou::out) (s'::state)) then (vl1::value list) ≠ [] ∧ (v::value) = hd vl1 ∧ (vl'::value list) = tl vl1 else vl' = vl1›*) by auto next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ2 s' vl' s' vl'›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ2 s' vl' s' vl'›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans (s::state) (a::act) (ou::out) (s'::state)) = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ2 (s'::state) (vl'::value list) s' vl'›*) show "?Δ s' vl' s' vl'" using cor1 (*‹corrFrom (post s1 PID) vl1›*) PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post (s'::state) (PID::postID) = post (s::state) PID›*) op' (*‹open (s'::state)›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) vlvl1 (*‹vl = vl1›*) ss1 (*‹s1 = s›*) unfolding "Δ2_def" vl v (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl' ∧ vl' = vl' ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) vl'›*) by auto qed qed (insert vl (*‹vl = v # vl'›*) lvl (*‹list_all (Not ∘ isOVal) vl›*), auto) (*solved the remaining goal: ‹⋀x3. v = OVal x3 ⟹ match Δ2 s s1 vl1 a ou s' vl'›*) next (*goal: ‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ match Δ2 s (s1::state) (vl1::value list) a ou s' (vl'::value list)›*) case False (*‹¬ φ (Trans s a ou s')›*) note "φ" = False (*‹¬ φ (Trans s a ou s')›*) hence vl': "vl' = vl" using c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) unfolding consume_def (*goal: ‹vl' = vl›*) by auto have pPID': "post s' PID = post s PID" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) "φ" (*‹¬ φ (Trans s a ou s')›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) op (*‹open s›*) apply (cases a) (*goal: ‹post s' PID = post s PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Sact x1⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: s_defs (*‹e_startSys (?s::state) (?uID::userID) (?p::password) ≡ userIDs ?s = []› ‹startSys (?s::state) (?uID::userID) (?p::password) ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42 x43 x44. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Dact x3⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀(x11::userID) (x12::password) (x13::password) (x14::name) x15::inform. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = Uact (x4::uActt); x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = post s PID› 2. ‹⋀(x21::userID) (x22::password) (x23::postID) x24::post. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = Uact (x4::uActt); x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀(x31::userID) (x32::password) (x33::postID) x34::vis. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = Uact (x4::uActt); x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = post s PID› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = post s PID› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = post s PID› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = post s PID› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = post s PID› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹open (s::state)›*) unfolding "φ_def2"[OF step] (*goal: ‹open s'›*) apply (cases a) (*goals: 1. ‹⋀x1::sActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Sact x1⟧ ⟹ open s'› 2. ‹⋀x2::cActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Cact x2⟧ ⟹ open s'› 3. ‹⋀x3::dActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Dact x3⟧ ⟹ open s'› 4. ‹⋀x4::uActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Uact x4⟧ ⟹ open s'› 5. ‹⋀x5::rActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Ract x5⟧ ⟹ open s'› 6. ‹⋀x6::lActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Lact x6⟧ ⟹ open s'› 7. ‹⋀x7::comActt. ⟦(PID::postID) ∈∈ postIDs (s::state); step s (a::act) = (ou::out, s'::state); ¬ ((∃(uid::userID) (p::password) pst::post. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃(uid::userID) (p::password) aid::apiID. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = COMact x7⟧ ⟹ open s'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . show "?thesis" (*goal: ‹match Δ2 s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 2. ‹consume (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state)) (vl1::value list) (?vl1'::value list)› 3. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 4. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) (?a1.0::act) (?ou1.0::out) (?s1'::state))› 5. ‹Δ2 (s'::state) (vl'::value list) (?s1'::state) (?vl1'::value list)›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ2 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl" using "φ" (*‹¬ φ (Trans s a ou s')›*) vlvl1 (*‹vl = vl1›*) unfolding ss1 consume_def vl' (*goal: ‹if φ (Trans s a ou s') then vl1 ≠ [] ∧ f (Trans s a ou s') = hd vl1 ∧ vl = tl vl1 else vl = vl1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ2 s' vl' s' vl›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ2 s' vl' s' vl›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ2 (s'::state) (vl'::value list) s' (vl::value list)›*) show "?Δ s' vl' s' vl" using cor1 (*‹corrFrom (post s1 PID) vl1›*) PID' (*‹PID ∈∈ postIDs s'›*) op' (*‹open (s'::state)›*) lvl (*‹list_all (Not ∘ isOVal) vl›*) vlvl1 (*‹vl = vl1›*) pPID' (*‹post (s'::state) (PID::postID) = post (s::state) PID›*) unfolding "Δ2_def" vl' ss1 (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vl ∧ vl = vl ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) vl›*) by auto qed qed thus "?thesis" (*goal: ‹match Δ2 s s1 vl1 a ou s' vl' ∨ ignore Δ2 s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction Δ2 s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction Δ2 s vl s1 vl1›*) using vlvl1 (*‹vl = vl1›*) by simp qed qed lemma unwind_cont_Δ4: "unwind_cont Δ4 {Δ1,Δ31,Δ32,Δ4}" apply rule (*goal: ‹unwind_cont Δ4 {Δ1, Δ31, Δ32, Δ4}›*) proof (simp) (*goal: ‹⋀s vl s1 vl1. ⟦reachNT s; reach s1; Δ4 s vl s1 vl1⟧ ⟹ iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) let ?Δ = "λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1" fix s :: state and s1 :: state and vl :: "value list" and vl1 :: "value list" assume rsT: "reachNT s" and rs1: "reach s1" and "Δ4 s vl s1 vl1" (*‹reachNT (s::state)› ‹reach (s1::state)› ‹Δ4 (s::state) (vl::value list) (s1::state) (vl1::value list)›*) then obtain ul and vll and vll1 where vl: "vl = ul @ OVal False # vll" and vl1: "vl1 = ul @ OVal False # vll1" and rs: "reach s" and ss1: "s1 = s" and op: "open s" and PID: "PID ∈∈ postIDs s" and cor1: "corrFrom (post s1 PID) vl1" and lul: "list_all (Not ∘ isOVal) ul" and BC: "BC vll vll1" (*goal: ‹(⋀(ul::value list) (vll::value list) vll1::value list. ⟦(vl::value list) = ul @ OVal False # vll; (vl1::value list) = ul @ OVal False # vll1; reach (s::state); (s1::state) = s; open s; (PID::postID) ∈∈ postIDs s; corrFrom (post s1 PID) vl1; list_all (Not ∘ isOVal) ul; BC vll vll1⟧ ⟹ thesis::bool) ⟹ thesis›*) using reachNT_reach (*‹reachNT (?s::state) ⟹ reach ?s›*) unfolding "Δ4_def" (*goal: ‹(⋀ul vll vll1. ⟦vl = ul @ OVal False # vll; vl1 = ul @ OVal False # vll1; reach s; s1 = s; open s; PID ∈∈ postIDs s; corrFrom (post s1 PID) vl1; list_all (Not ∘ isOVal) ul; BC vll vll1⟧ ⟹ thesis) ⟹ thesis›*) by blast have own: "owner s PID ∈ set (userIDs s)" using reach_owner_userIDs[OF rs PID] (*‹owner s PID ∈∈ userIDs s›*) . have adm: "admin s ∈ set (userIDs s)" using reach_admin_userIDs[OF rs own] (*‹admin s ∈∈ userIDs s›*) . show "iaction ?Δ s vl s1 vl1 ∨ ((vl = [] ⟶ vl1 = []) ∧ reaction ?Δ s vl s1 vl1)" (is "?iact ∨ (_ ∧ ?react)") proof (-) (*goal: ‹iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) have "?react" proof (standard) (*goal: ‹⋀(a::act) (ou::out) (s'::state) vl'::value list. ⟦step (s::state) a = (ou, s'); ¬ T (Trans s a ou s'); consume (Trans s a ou s') (vl::value list) vl'⟧ ⟹ match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s (s1::state) (vl1::value list) a ou s' vl' ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) fix a :: act and ou :: out and s' :: state and vl' let ?trn = "Trans s a ou s'" let ?trn1 = "Trans s1 a ou s'" assume step: "step s a = (ou, s')" and c: "consume ?trn vl vl'" (*‹step (s::state) (a::act) = (ou::out, s'::state)› ‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) have PID': "PID ∈∈ postIDs s'" using reach_postIDs_persist[OF PID step] (*‹PID ∈∈ postIDs s'›*) . show "match ?Δ s s1 vl1 a ou s' vl' ∨ ignore ?Δ s s1 vl1 a ou s' vl'" (is "?match ∨ ?ignore") proof (-) (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list) ∨ ignore (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) have "?match" proof (cases "φ ?trn") (*goals: 1. ‹φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹φ (Trans s a ou s')›*) note "φ" = True (*‹φ (Trans s a ou s')›*) then obtain v where vl_vl': "vl = v # vl'" and f: "f ?trn = v" (*goal: ‹(⋀v::value. ⟦(vl::value list) = v # (vl'::value list); f (Trans (s::state) (a::act) (ou::out) (s'::state)) = v⟧ ⟹ thesis::bool) ⟹ thesis›*) using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def "φ_def2" (*goal: ‹(⋀v. ⟦vl = v # vl'; f (Trans s a ou s') = v⟧ ⟹ thesis) ⟹ thesis›*) apply (cases vl) (*goals: 1. ‹⟦⋀v::value. ⟦(vl::value list) = v # (vl'::value list); f (Trans (s::state) (a::act) (ou::out) (s'::state)) = v⟧ ⟹ thesis::bool; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = []⟧ ⟹ thesis› 2. ‹⋀(aa::value) list::value list. ⟦⋀v::value. ⟦(vl::value list) = v # (vl'::value list); f (Trans (s::state) (a::act) (ou::out) (s'::state)) = v⟧ ⟹ thesis::bool; φ (Trans s a ou s'); if φ (Trans s a ou s') then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ vl' = tl vl else vl' = vl; vl = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (cases "ul = []") (*goals: 1. ‹ul = [] ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹ul ≠ [] ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹(ul::value list) ≠ []›*) note ul = False (*‹ul ≠ []›*) then obtain ul' where ul: "ul = v # ul'" and vl': "vl' = ul' @ OVal False # vll" (*goal: ‹(⋀ul'. ⟦ul = v # ul'; vl' = ul' @ OVal False # vll⟧ ⟹ thesis) ⟹ thesis›*) using c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) "φ" (*‹φ (Trans s a ou s')›*) f (*‹f (Trans s a ou s') = v›*) unfolding consume_def vl (*goal: ‹(⋀ul'. ⟦ul = v # ul'; vl' = ul' @ OVal False # vll⟧ ⟹ thesis) ⟹ thesis›*) apply (cases ul) (*goals: 1. ‹⟦⋀ul'. ⟦ul = v # ul'; vl' = ul' @ OVal False # vll⟧ ⟹ thesis; ul ≠ []; if φ (Trans s a ou s') then ul @ OVal False # vll ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal False # vll) ∧ vl' = tl (ul @ OVal False # vll) else vl' = ul @ OVal False # vll; φ (Trans s a ou s'); f (Trans s a ou s') = v; ul = []⟧ ⟹ thesis› 2. ‹⋀aa list. ⟦⋀ul'. ⟦ul = v # ul'; vl' = ul' @ OVal False # vll⟧ ⟹ thesis; ul ≠ []; if φ (Trans s a ou s') then ul @ OVal False # vll ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal False # vll) ∧ vl' = tl (ul @ OVal False # vll) else vl' = ul @ OVal False # vll; φ (Trans s a ou s'); f (Trans s a ou s') = v; ul = aa # list⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . let ?vl1' = "ul' @ OVal False # vll1" show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (cases v) (*goals: 1. ‹⋀x1. v = PVal x1 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 3. ‹⋀x3. v = OVal x3 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (PVal pst) (*‹v = PVal pst›*) note v = PVal (*‹v = PVal pst›*) have a: "a = Uact (uPost (owner s PID) (pass s (owner s PID)) PID pst)" using f_eq_PVal[OF step φ f [ unfolded v ]] (*‹(a::act) = Uact (uPost (owner (s::state) (PID::postID)) (pass s (owner s PID)) PID (pst::post))›*) . have ou: "ou = outOK" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) own (*‹owner s PID ∈∈ userIDs s›*) PID (*‹PID ∈∈ postIDs s›*) unfolding a (*goal: ‹ou = outOK›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have op': "open s'" using step (*‹step (s::state) (a::act) = (ou::out, s'::state)›*) op (*‹open s›*) PID (*‹PID ∈∈ postIDs s›*) PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) "φ" (*‹φ (Trans s a ou s')›*) unfolding open_def a (*goal: ‹∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV)›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) have pPID': "post s' PID = pst" using step (*‹step s a = (ou, s')›*) "φ" (*‹φ (Trans s a ou s')›*) PID (*‹PID ∈∈ postIDs s›*) op (*‹open (s::state)›*) f (*‹f (Trans s a ou s') = v›*) op' (*‹open s'›*) unfolding a (*goal: ‹post (s'::state) (PID::postID) = (pst::post)›*) by (auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*)) show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ1 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 ?vl1'" using "φ" (*‹φ (Trans s a ou s')›*) unfolding ss1 consume_def vl f ul vl1 vl' (*goal: ‹if φ (Trans s a ou s') then (v # ul') @ OVal False # vll1 ≠ [] ∧ v = hd ((v # ul') @ OVal False # vll1) ∧ ul' @ OVal False # vll1 = tl ((v # ul') @ OVal False # vll1) else ul' @ OVal False # vll1 = (v # ul') @ OVal False # vll1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ1 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ31 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal False # vll1)›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ1 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ31 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal False # vll1)›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ1 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ31 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal False # vll1)›*) have "Δ4 s' vl' s' ?vl1'" using cor1 (*‹corrFrom (post (s1::state) (PID::postID)) (vl1::value list)›*) PID' (*‹(PID::postID) ∈∈ postIDs (s'::state)›*) pPID' (*‹post s' PID = pst›*) op' (*‹open s'›*) vl1 (*‹vl1 = ul @ OVal False # vll1›*) ss1 (*‹s1 = s›*) lul (*‹list_all (Not ∘ isOVal) ul›*) BC (*‹BC vll vll1›*) unfolding "Δ4_def" vl v ul vl' (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(ul::value list) (vlla::value list) vll1a::value list. BC vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ (ul'::value list) @ OVal False # (vll::value list) = ul @ OVal False # vlla ∧ ul' @ OVal False # (vll1::value list) = ul @ OVal False # vll1a) ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) (ul' @ OVal False # vll1)›*) apply simp (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul vlla vll1a. BC vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ ul' @ OVal False # vll = ul @ OVal False # vlla ∧ ul' @ OVal False # vll1 = ul @ OVal False # vll1a) ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) (ul' @ OVal False # vll1)›*) apply (rule exI[of _ ul'] (*‹?P ul' ⟹ ∃x. ?P x›*)) (*goal: ‹⟦corrFrom pst (ul' @ OVal False # vll1); PID ∈∈ postIDs s'; post s' PID = pst; open s'; vl1 = PVal pst # ul' @ OVal False # vll1; s1 = s; list_all (Not ∘ isOVal) ul'; BC vll vll1⟧ ⟹ ∃ul vlla vll1a. BC vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ ul' @ OVal False # vll = ul @ OVal False # vlla ∧ ul' @ OVal False # vll1 = ul @ OVal False # vll1a›*) apply (rule exI[of _ vll] (*‹?P vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦corrFrom (pst::post) ((ul'::value list) @ OVal False # (vll1::value list)); (PID::postID) ∈∈ postIDs (s'::state); post s' PID = pst; open s'; (vl1::value list) = PVal pst # ul' @ OVal False # vll1; (s1::state) = (s::state); list_all (Not ∘ isOVal) ul'; BC (vll::value list) vll1⟧ ⟹ ∃(vlla::value list) vll1a::value list. BC vlla vll1a ∧ list_all (Not ∘ isOVal) ul' ∧ ul' @ OVal False # vll = ul' @ OVal False # vlla ∧ ul' @ OVal False # vll1 = ul' @ OVal False # vll1a›*) apply (rule exI[of _ vll1] (*‹?P vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦corrFrom pst (ul' @ OVal False # vll1); PID ∈∈ postIDs s'; post s' PID = pst; open s'; vl1 = PVal pst # ul' @ OVal False # vll1; s1 = s; list_all (Not ∘ isOVal) ul'; BC vll vll1⟧ ⟹ ∃vll1a. BC vll vll1a ∧ list_all (Not ∘ isOVal) ul' ∧ ul' @ OVal False # vll = ul' @ OVal False # vll ∧ ul' @ OVal False # vll1 = ul' @ OVal False # vll1a›*) by auto thus "?Δ s' vl' s' ?vl1'" by simp qed next (*goals: 1. ‹⋀x21 x22. v = PValS x21 x22 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'› 2. ‹⋀x3. v = OVal x3 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case (PValS aid pid) (*‹(v::value) = PValS (aid::apiID) (pid::post)›*) note v = PValS (*‹(v::value) = PValS (aid::apiID) (pid::post)›*) have a: "a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)" using f_eq_PValS[OF step φ f [ unfolded v ]] (*‹a = COMact (comSendPost (admin s) (pass s (admin s)) aid PID)›*) . have op': "open s'" using step (*‹step s a = (ou, s')›*) op (*‹open s›*) PID (*‹PID ∈∈ postIDs s›*) PID' (*‹PID ∈∈ postIDs s'›*) "φ" (*‹φ (Trans s a ou s')›*) unfolding open_def a (*goal: ‹∃uid∈UIDs. uid ∈∈ userIDs s' ∧ PID ∈∈ postIDs s' ∧ (uid = admin s' ∨ uid = owner s' PID ∨ uid ∈∈ friendIDs s' (owner s' PID) ∨ vis s' PID = PublicV)›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) have ou: "ou ≠ outErr" using "φ" (*‹φ (Trans s a ou s')›*) op (*‹open s›*) op' (*‹open s'›*) unfolding "φ_def2"[OF step] (*goal: ‹(ou::out) ≠ outErr›*) unfolding a (*goal: ‹(ou::out) ≠ outErr›*) by auto have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹φ (Trans s a ou s')›*) PID (*‹PID ∈∈ postIDs s›*) op (*‹open (s::state)›*) f (*‹f (Trans s a ou s') = v›*) op' (*‹open s'›*) unfolding a (*goal: ‹post s' PID = post s PID›*) by (auto simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ1 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 ?vl1'" using "φ" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) unfolding ss1 consume_def vl f ul vl1 vl' (*goal: ‹if φ (Trans s a ou s') then (v # ul') @ OVal False # vll1 ≠ [] ∧ v = hd ((v # ul') @ OVal False # vll1) ∧ ul' @ OVal False # vll1 = tl ((v # ul') @ OVal False # vll1) else ul' @ OVal False # vll1 = (v # ul') @ OVal False # vll1›*) by simp next (*goals: 1. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans (s1::state) a ou s')› 2. ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) ⟹ g (Trans s a ou s') = g (Trans (s1::state) a ou s')› 3. ‹Δ1 (s'::state) (vl'::value list) s' ((ul'::value list) @ OVal False # (vll1::value list)) ∨ Δ31 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal False # vll1)›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans (s::state) (a::act) (ou::out) (s'::state)) = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ1 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ31 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal False # vll1)›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ1 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ31 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ32 s' vl' s' (ul' @ OVal False # vll1) ∨ Δ4 s' vl' s' (ul' @ OVal False # vll1)›*) have "Δ4 s' vl' s' ?vl1'" using cor1 (*‹corrFrom (post (s1::state) (PID::postID)) (vl1::value list)›*) PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹open s'›*) vl1 (*‹vl1 = ul @ OVal False # vll1›*) ss1 (*‹s1 = s›*) lul (*‹list_all (Not ∘ isOVal) (ul::value list)›*) BC (*‹BC vll vll1›*) unfolding "Δ4_def" vl v ul vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul vlla vll1a. BC vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ ul' @ OVal False # vll = ul @ OVal False # vlla ∧ ul' @ OVal False # vll1 = ul @ OVal False # vll1a) ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) (ul' @ OVal False # vll1)›*) by auto thus "?Δ s' vl' s' ?vl1'" by simp qed qed (insert vl (*‹vl = ul @ OVal False # vll›*) lul (*‹list_all (Not ∘ isOVal) ul›*) ul (*‹ul = v # ul'›*), auto) (*solved the remaining goal: ‹⋀x3. v = OVal x3 ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) next (*goal: ‹ul = [] ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case True (*‹ul = []›*) note ul = True (*‹(ul::value list) = []›*) hence f: "f ?trn = OVal False" and vl': "vl' = vll" using vl (*‹vl = ul @ OVal False # vll›*) c (*‹consume (Trans s a ou s') vl vl'›*) f (*‹f (Trans (s::state) (a::act) (ou::out) (s'::state)) = (v::value)›*) "φ" (*‹φ (Trans s a ou s')›*) unfolding consume_def ul (*goals: 1. ‹f (Trans s a ou s') = OVal False› 2. ‹vl' = vll›*) apply - (*goals: 1. ‹⟦[] = []; (vl::value list) = [] @ OVal False # (vll::value list); if φ (Trans (s::state) (a::act) (ou::out) (s'::state)) then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ (vl'::value list) = tl vl else vl' = vl; f (Trans s a ou s') = (v::value); φ (Trans s a ou s')⟧ ⟹ f (Trans s a ou s') = OVal False› 2. ‹⟦[] = []; (vl::value list) = [] @ OVal False # (vll::value list); if φ (Trans (s::state) (a::act) (ou::out) (s'::state)) then vl ≠ [] ∧ f (Trans s a ou s') = hd vl ∧ (vl'::value list) = tl vl else vl' = vl; f (Trans s a ou s') = (v::value); φ (Trans s a ou s')⟧ ⟹ vl' = vll› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . have op': "¬ open s'" using f_eq_OVal[OF step φ f] (*‹open (s'::state) ≠ open (s::state)›*) op (*‹open s›*) by simp show "?thesis" (*goal: ‹match (λ(s::state) (vl::value list) (s1::state) vl1::value list. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) (s::state) (s1::state) (vl1::value list) (a::act) (ou::out) (s'::state) (vl'::value list)›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" using step (*‹step s a = (ou, s')›*) unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ1 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vll1" using ul (*‹ul = []›*) "φ" (*‹φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) c (*‹consume (Trans (s::state) (a::act) (ou::out) (s'::state)) (vl::value list) (vl'::value list)›*) unfolding vl1 vl' vl ss1 consume_def (*goal: ‹if φ (Trans s a ou s') then ul @ OVal False # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal False # vll1) ∧ vll1 = tl (ul @ OVal False # vll1) else vll1 = ul @ OVal False # vll1›*) by auto next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ1 s' vl' s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ1 s' vl' s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "γ" = this (*‹γ (Trans s a ou s')›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ1 s' vl' s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹φ (Trans s a ou s')›*) PID (*‹PID ∈∈ postIDs s›*) op (*‹open (s::state)›*) op' (*‹¬ open s'›*) f (*‹f (Trans s a ou s') = OVal False›*) apply (cases a) (*goal: ‹post s' PID = post s PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Sact x1⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42 x43 x44. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Dact x3⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀(x11::userID) (x12::password) (x13::password) (x14::name) x15::inform. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Uact (x4::uActt); x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = post s PID› 2. ‹⋀(x21::userID) (x22::password) (x23::postID) x24::post. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Uact (x4::uActt); x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀(x31::userID) (x32::password) (x33::postID) x34::vis. ⟦step (s::state) (a::act) = (ou::out, s'::state); φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = Uact (x4::uActt); x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply ((auto simp: u_defs (*‹e_updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser (?s::state) (?uID::userID) (?p::password) (?p'::password) (?name::name) (?info::inform) ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?pst::post) ≡ let sW::postID ⇒ (apiID × bool) list = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID::apiID, uu_::bool). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) (?vs::vis) ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀x11 x12 x13 x14. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53 x54 x55 x56. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = post s PID› 6. ‹⋀x61 x62 x63 x64. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = post s PID› 7. ‹⋀x71 x72 x73 x74. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = post s PID› 8. ‹⋀x81 x82 x83 x84. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = post s PID› 9. ‹⋀x91 x92 x93 x94. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = post s PID› 10. ‹⋀x101 x102 x103 x104. ⟦step s a = (ou, s'); φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; ¬ open s'; f (Trans s a ou s') = OVal False; a = COMact x7; x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . show "?Δ s' vl' s' vll1" using BC (*‹BC (vll::value list) (vll1::value list)›*) proof (cases) (*goals: 1. ‹⟦list_all (Not ∘ isOVal) vll; list_all (Not ∘ isOVal) vll1; map tgtAPI (filter isPValS vll) = map tgtAPI (filter isPValS vll1); vll = [] ⟶ vll1 = []⟧ ⟹ Δ1 s' vl' s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1› 2. ‹⋀vl vl1 ul ul1 sul. ⟦vll = ul @ sul @ OVal True # vl; vll1 = ul1 @ sul @ OVal True # vl1; BO vl vl1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ Δ1 s' vl' s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) case BC_PVal (*‹list_all (Not ∘ isOVal) (vll::value list)› ‹list_all (Not ∘ isOVal) vll1› ‹map tgtAPI (filter isPValS vll) = map tgtAPI (filter isPValS vll1)› ‹vll = [] ⟶ vll1 = []›*) hence "Δ1 s' vl' s' vll1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹¬ open s'›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BC (*‹BC vll vll1›*) lul (*‹list_all (Not ∘ isOVal) ul›*) unfolding "Δ1_def" vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ list_all (Not ∘ isOVal) vll ∧ list_all (Not ∘ isOVal) vll1 ∧ map tgtAPI (filter isPValS vll) = map tgtAPI (filter isPValS vll1) ∧ (vll = [] ⟶ vll1 = []) ∧ eqButPID s' s' ∧ ¬ open s' ∧ corrFrom (post s' PID) vll1›*) by auto thus "?thesis" (*goal: ‹Δ1 (s'::state) (vl'::value list) s' (vll1::value list) ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) by simp next (*goal: ‹⋀(vl::value list) (vl1::value list) (ul::value list) (ul1::value list) sul::value list. ⟦(vll::value list) = ul @ sul @ OVal True # vl; (vll1::value list) = ul1 @ sul @ OVal True # vl1; BO vl vl1; list_all (Not ∘ isOVal) ul; list_all (Not ∘ isOVal) ul1; map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1); (ul = []) = (ul1 = []); ul ≠ [] ⟹ isPVal (last ul) ∧ last ul = last ul1; list_all isPValS sul⟧ ⟹ Δ1 (s'::state) (vl'::value list) s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) case (BC_BO Vll Vll1 Ul Ul1 Sul) (*‹vll = Ul @ Sul @ OVal True # Vll› ‹vll1 = Ul1 @ Sul @ OVal True # Vll1› ‹BO Vll Vll1› ‹list_all (Not ∘ isOVal) Ul› ‹list_all (Not ∘ isOVal) Ul1› ‹map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1)› ‹(Ul = []) = (Ul1 = [])› ‹Ul ≠ [] ⟹ isPVal (last Ul) ∧ last Ul = last Ul1› ‹list_all isPValS Sul›*) show "?thesis" (*goal: ‹Δ1 (s'::state) (vl'::value list) s' (vll1::value list) ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) proof (cases "Ul ≠ [] ∧ Ul1 ≠ []") (*goals: 1. ‹(Ul::value list) ≠ [] ∧ (Ul1::value list) ≠ [] ⟹ Δ1 (s'::state) (vl'::value list) s' (vll1::value list) ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1› 2. ‹¬ ((Ul::value list) ≠ [] ∧ (Ul1::value list) ≠ []) ⟹ Δ1 (s'::state) (vl'::value list) s' (vll1::value list) ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) case True (*‹Ul ≠ [] ∧ Ul1 ≠ []›*) hence "Δ31 s' vl' s' vll1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹¬ open (s'::state)›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BC (*‹BC (vll::value list) (vll1::value list)›*) BC_BO (*‹(vll::value list) = (Ul::value list) @ (Sul::value list) @ OVal True # (Vll::value list)› ‹vll1 = Ul1 @ Sul @ OVal True # Vll1› ‹BO Vll Vll1› ‹list_all (Not ∘ isOVal) Ul› ‹list_all (Not ∘ isOVal) Ul1› ‹map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1)› ‹((Ul::value list) = []) = ((Ul1::value list) = [])› ‹(Ul::value list) ≠ [] ⟹ isPVal (last Ul) ∧ last Ul = last (Ul1::value list)› ‹list_all isPValS Sul›*) lul (*‹list_all (Not ∘ isOVal) (ul::value list)›*) unfolding "Δ31_def" vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1 sul vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ vll = ul @ sul @ OVal True # vlla ∧ vll1 = ul1 @ sul @ OVal True # vll1a) ∧ eqButPID s' s' ∧ ¬ open s' ∧ corrFrom (post s' PID) vll1›*) apply simp (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ul ul1 sul vlla vll1a. BO vlla vll1a ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ vll = ul @ sul @ OVal True # vlla ∧ vll1 = ul1 @ sul @ OVal True # vll1a) ∧ eqButPID s' s' ∧ ¬ open s' ∧ corrFrom (post s' PID) vll1›*) apply (rule exI[of _ Ul] (*‹?P Ul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦Ul1 ≠ []; PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) (Ul1 @ Sul @ OVal True # Vll1); BC (Ul @ Sul @ OVal True # Vll) (Ul1 @ Sul @ OVal True # Vll1); vll = Ul @ Sul @ OVal True # Vll; vll1 = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); Ul ≠ []; isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ ∃ul ul1 sul vll vll1. BO vll vll1 ∧ list_all (Not ∘ isOVal) ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS ul) = map tgtAPI (filter isPValS ul1) ∧ ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last ul) ∧ last ul = last ul1 ∧ list_all isPValS sul ∧ Ul @ Sul @ OVal True # Vll = ul @ sul @ OVal True # vll ∧ Ul1 @ Sul @ OVal True # Vll1 = ul1 @ sul @ OVal True # vll1›*) apply (rule exI[of _ Ul1] (*‹?P Ul1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(Ul1::value list) ≠ []; (PID::postID) ∈∈ postIDs (s'::state); post s' PID = post (s::state) PID; ¬ open s'; corrFrom (post s PID) (Ul1 @ (Sul::value list) @ OVal True # (Vll1::value list)); BC ((Ul::value list) @ Sul @ OVal True # (Vll::value list)) (Ul1 @ Sul @ OVal True # Vll1); (vll::value list) = Ul @ Sul @ OVal True # Vll; (vll1::value list) = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); Ul ≠ []; isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ ∃(ul1::value list) (sul::value list) (vll::value list) vll1::value list. BO vll vll1 ∧ list_all (Not ∘ isOVal) Ul ∧ list_all (Not ∘ isOVal) ul1 ∧ map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS ul1) ∧ Ul ≠ [] ∧ ul1 ≠ [] ∧ isPVal (last Ul) ∧ last Ul = last ul1 ∧ list_all isPValS sul ∧ Ul @ Sul @ OVal True # Vll = Ul @ sul @ OVal True # vll ∧ Ul1 @ Sul @ OVal True # Vll1 = ul1 @ sul @ OVal True # vll1›*) apply (rule exI[of _ Sul] (*‹?P Sul ⟹ ∃x. ?P x›*)) (*goal: ‹⟦Ul1 ≠ []; PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) (Ul1 @ Sul @ OVal True # Vll1); BC (Ul @ Sul @ OVal True # Vll) (Ul1 @ Sul @ OVal True # Vll1); vll = Ul @ Sul @ OVal True # Vll; vll1 = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); Ul ≠ []; isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ ∃sul vll vll1. BO vll vll1 ∧ list_all (Not ∘ isOVal) Ul ∧ list_all (Not ∘ isOVal) Ul1 ∧ map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1) ∧ Ul ≠ [] ∧ Ul1 ≠ [] ∧ isPVal (last Ul) ∧ last Ul = last Ul1 ∧ list_all isPValS sul ∧ Ul @ Sul @ OVal True # Vll = Ul @ sul @ OVal True # vll ∧ Ul1 @ Sul @ OVal True # Vll1 = Ul1 @ sul @ OVal True # vll1›*) apply (rule exI[of _ Vll] (*‹?P Vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦(Ul1::value list) ≠ []; (PID::postID) ∈∈ postIDs (s'::state); post s' PID = post (s::state) PID; ¬ open s'; corrFrom (post s PID) (Ul1 @ (Sul::value list) @ OVal True # (Vll1::value list)); BC ((Ul::value list) @ Sul @ OVal True # (Vll::value list)) (Ul1 @ Sul @ OVal True # Vll1); (vll::value list) = Ul @ Sul @ OVal True # Vll; (vll1::value list) = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); Ul ≠ []; isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ ∃(vll::value list) vll1::value list. BO vll vll1 ∧ list_all (Not ∘ isOVal) Ul ∧ list_all (Not ∘ isOVal) Ul1 ∧ map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1) ∧ Ul ≠ [] ∧ Ul1 ≠ [] ∧ isPVal (last Ul) ∧ last Ul = last Ul1 ∧ list_all isPValS Sul ∧ Ul @ Sul @ OVal True # Vll = Ul @ Sul @ OVal True # vll ∧ Ul1 @ Sul @ OVal True # Vll1 = Ul1 @ Sul @ OVal True # vll1›*) apply (rule exI[of _ Vll1] (*‹?P Vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦Ul1 ≠ []; PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) (Ul1 @ Sul @ OVal True # Vll1); BC (Ul @ Sul @ OVal True # Vll) (Ul1 @ Sul @ OVal True # Vll1); vll = Ul @ Sul @ OVal True # Vll; vll1 = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); Ul ≠ []; isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ ∃vll1. BO Vll vll1 ∧ list_all (Not ∘ isOVal) Ul ∧ list_all (Not ∘ isOVal) Ul1 ∧ map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1) ∧ Ul ≠ [] ∧ Ul1 ≠ [] ∧ isPVal (last Ul) ∧ last Ul = last Ul1 ∧ list_all isPValS Sul ∧ Ul @ Sul @ OVal True # Vll = Ul @ Sul @ OVal True # Vll ∧ Ul1 @ Sul @ OVal True # Vll1 = Ul1 @ Sul @ OVal True # vll1›*) by auto thus "?thesis" (*goal: ‹Δ1 s' vl' s' vll1 ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) by simp next (*goal: ‹¬ ((Ul::value list) ≠ [] ∧ (Ul1::value list) ≠ []) ⟹ Δ1 (s'::state) (vl'::value list) s' (vll1::value list) ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) case False (*‹¬ (Ul ≠ [] ∧ Ul1 ≠ [])›*) hence 0: "Ul = []" "Ul1 = []" using BC_BO (*‹vll = Ul @ Sul @ OVal True # Vll› ‹vll1 = Ul1 @ Sul @ OVal True # Vll1› ‹BO (Vll::value list) (Vll1::value list)› ‹list_all (Not ∘ isOVal) Ul› ‹list_all (Not ∘ isOVal) (Ul1::value list)› ‹map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1)› ‹(Ul = []) = (Ul1 = [])› ‹Ul ≠ [] ⟹ isPVal (last Ul) ∧ last Ul = last Ul1› ‹list_all isPValS Sul›*) apply - (*goals: 1. ‹⟦¬ (Ul ≠ [] ∧ Ul1 ≠ []); vll = Ul @ Sul @ OVal True # Vll; vll1 = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); (Ul = []) = (Ul1 = []); Ul ≠ [] ⟹ isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ Ul = []› 2. ‹⟦¬ (Ul ≠ [] ∧ Ul1 ≠ []); vll = Ul @ Sul @ OVal True # Vll; vll1 = Ul1 @ Sul @ OVal True # Vll1; BO Vll Vll1; list_all (Not ∘ isOVal) Ul; list_all (Not ∘ isOVal) Ul1; map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1); (Ul = []) = (Ul1 = []); Ul ≠ [] ⟹ isPVal (last Ul) ∧ last Ul = last Ul1; list_all isPValS Sul⟧ ⟹ Ul1 = []› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . hence "Δ32 s' vl' s' vll1" using PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post (s'::state) (PID::postID) = post (s::state) PID›*) op' (*‹¬ open s'›*) cor1 (*‹corrFrom (post s1 PID) vl1›*) BC (*‹BC vll vll1›*) BC_BO (*‹(vll::value list) = (Ul::value list) @ (Sul::value list) @ OVal True # (Vll::value list)› ‹vll1 = Ul1 @ Sul @ OVal True # Vll1› ‹BO Vll Vll1› ‹list_all (Not ∘ isOVal) Ul› ‹list_all (Not ∘ isOVal) (Ul1::value list)› ‹map tgtAPI (filter isPValS Ul) = map tgtAPI (filter isPValS Ul1)› ‹(Ul = []) = (Ul1 = [])› ‹Ul ≠ [] ⟹ isPVal (last Ul) ∧ last Ul = last Ul1› ‹list_all isPValS Sul›*) lul (*‹list_all (Not ∘ isOVal) ul›*) unfolding "Δ32_def" vl1 ul ss1 vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃sul vlla vll1a. BO vlla vll1a ∧ list_all isPValS sul ∧ vll = sul @ OVal True # vlla ∧ vll1 = sul @ OVal True # vll1a) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom (post s' PID) vll1›*) apply simp (*goal: ‹(PID::postID) ∈∈ postIDs (s'::state) ∧ (∃(sul::value list) (vlla::value list) vll1a::value list. BO vlla vll1a ∧ list_all isPValS sul ∧ (vll::value list) = sul @ OVal True # vlla ∧ (vll1::value list) = sul @ OVal True # vll1a) ∧ s' = s' ∧ ¬ open s' ∧ corrFrom (post s' PID) vll1›*) apply (rule exI[of _ Sul] (*‹(?P::value list ⇒ bool) (Sul::value list) ⟹ ∃x::value list. ?P x›*)) (*goal: ‹⟦Ul1 = []; PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) (Sul @ OVal True # Vll1); BC (Sul @ OVal True # Vll) (Sul @ OVal True # Vll1); vll = Sul @ OVal True # Vll; vll1 = Sul @ OVal True # Vll1; BO Vll Vll1; Ul = []; list_all isPValS Sul⟧ ⟹ ∃sul vll vll1. BO vll vll1 ∧ list_all isPValS sul ∧ Sul @ OVal True # Vll = sul @ OVal True # vll ∧ Sul @ OVal True # Vll1 = sul @ OVal True # vll1›*) apply (rule exI[of _ Vll] (*‹?P Vll ⟹ ∃x. ?P x›*)) (*goal: ‹⟦Ul1 = []; PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) (Sul @ OVal True # Vll1); BC (Sul @ OVal True # Vll) (Sul @ OVal True # Vll1); vll = Sul @ OVal True # Vll; vll1 = Sul @ OVal True # Vll1; BO Vll Vll1; Ul = []; list_all isPValS Sul⟧ ⟹ ∃vll vll1. BO vll vll1 ∧ list_all isPValS Sul ∧ Sul @ OVal True # Vll = Sul @ OVal True # vll ∧ Sul @ OVal True # Vll1 = Sul @ OVal True # vll1›*) apply (rule exI[of _ Vll1] (*‹?P Vll1 ⟹ ∃x. ?P x›*)) (*goal: ‹⟦Ul1 = []; PID ∈∈ postIDs s'; post s' PID = post s PID; ¬ open s'; corrFrom (post s PID) (Sul @ OVal True # Vll1); BC (Sul @ OVal True # Vll) (Sul @ OVal True # Vll1); vll = Sul @ OVal True # Vll; vll1 = Sul @ OVal True # Vll1; BO Vll Vll1; Ul = []; list_all isPValS Sul⟧ ⟹ ∃vll1. BO Vll vll1 ∧ list_all isPValS Sul ∧ Sul @ OVal True # Vll = Sul @ OVal True # Vll ∧ Sul @ OVal True # Vll1 = Sul @ OVal True # vll1›*) by auto thus "?thesis" (*goal: ‹Δ1 (s'::state) (vl'::value list) s' (vll1::value list) ∨ Δ31 s' vl' s' vll1 ∨ Δ32 s' vl' s' vll1 ∨ Δ4 s' vl' s' vll1›*) by simp qed qed qed qed next (*goal: ‹¬ φ (Trans s a ou s') ⟹ match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) case False (*‹¬ φ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) note "φ" = False (*‹¬ φ (Trans s a ou s')›*) hence vl': "vl' = vl" using c (*‹consume (Trans s a ou s') vl vl'›*) unfolding consume_def (*goal: ‹vl' = vl›*) by auto have pPID': "post s' PID = post s PID" using step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) PID (*‹(PID::postID) ∈∈ postIDs (s::state)›*) op (*‹open s›*) apply (cases a) (*goal: ‹post s' PID = post s PID›*) subgoal for x1 apply (cases x1) (*goal: ‹⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Sact x1⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: s_defs (*‹e_startSys ?s ?uID ?p ≡ userIDs ?s = []› ‹startSys ?s ?uID ?p ≡ ?s⦇admin := ?uID, userIDs := [?uID], user := (user ?s)(?uID := emptyUser), pass := (pass ?s)(?uID := ?p)⦈›*)) subgoal for x2 apply (cases x2) (*goals: 1. ‹⋀x11 x12. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cNUReq x11 x12⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cUser x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cPost x31 x32 x33⟧ ⟹ post s' PID = post s PID› 4. ‹⋀x41 x42 x43 x44. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cFriendReq x41 x42 x43 x44⟧ ⟹ post s' PID = post s PID› 5. ‹⋀x51 x52 x53. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Cact x2; x2 = cFriend x51 x52 x53⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 2*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 3*) apply (fastforce simp: c_defs (*‹e_createNUReq (?s::state) (?uID::userID) (?requestInfo::requestInfo) ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq (?s::state) (?uID::userID) (?reqInfo::requestInfo) ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?p'::password) ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost (?s::state) (?uID::userID) (?p::password) (?pID::postID) ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq (?s::state) (?uID::userID) (?p::password) (?uID'::userID) (?req::requestInfo) ≡ let pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend (?s::state) (?uID::userID) (?p::password) (?uID'::userID) ≡ let fr::userID ⇒ userID list = friendIDs ?s; pfr::userID ⇒ userID list = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 4*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*discuss goal 5*) apply (fastforce simp: c_defs (*‹e_createNUReq ?s ?uID ?requestInfo ≡ admin ?s ∈∈ userIDs ?s ∧ ?uID ∉ set (userIDs ?s) ∧ ?uID ∉ set (pendingUReqs ?s)› ‹createNUReq ?s ?uID ?reqInfo ≡ ?s⦇pendingUReqs := pendingUReqs ?s ## ?uID, userReq := (userReq ?s)(?uID := ?reqInfo)⦈› ‹e_createUser ?s ?uID ?p ?uID' ?p' ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?uID' ∈∈ pendingUReqs ?s› ‹createUser ?s ?uID ?p ?uID' ?p' ≡ ?s⦇userIDs := ?uID' # userIDs ?s, user := (user ?s)(?uID' := emptyUser), pass := (pass ?s)(?uID' := ?p'), pendingUReqs := remove1 ?uID' (pendingUReqs ?s), userReq := (userReq ?s)(?uID := emptyRequestInfo)⦈› ‹e_createPost ?s ?uID ?p ?pID ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?pID ∉ set (postIDs ?s)› ‹createPost ?s ?uID ?p ?pID ≡ ?s⦇postIDs := ?pID # postIDs ?s, post := (post ?s)(?pID := emptyPost), owner := (owner ?s)(?pID := ?uID)⦈› ‹e_createFriendReq ?s ?uID ?p ?uID' ?req ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID ∉ set (pendingFReqs ?s ?uID') ∧ ?uID ∉ set (friendIDs ?s ?uID')› ‹createFriendReq ?s ?uID ?p ?uID' ?req ≡ let pfr = pendingFReqs ?s in ?s⦇pendingFReqs := pfr(?uID' := pfr ?uID' ## ?uID), friendReq := fun_upd2 (friendReq ?s) ?uID ?uID' ?req⦈› ‹e_createFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ pendingFReqs ?s ?uID› ‹createFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s; pfr = pendingFReqs ?s in ?s⦇friendIDs := fr(?uID := fr ?uID ## ?uID', ?uID' := fr ?uID' ## ?uID), pendingFReqs := pfr(?uID := remove1 ?uID' (pfr ?uID), ?uID' := remove1 ?uID (pfr ?uID')), friendReq := fun_upd2 (fun_upd2 (friendReq ?s) ?uID' ?uID emptyRequestInfo) ?uID ?uID' emptyRequestInfo⦈›*)) (*proven 5 subgoals*) . subgoal for x3 apply (cases x3) (*goal: ‹⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = Dact (x3::dActt)⟧ ⟹ post s' PID = post s PID›*) by (fastforce simp: d_defs (*‹e_deleteFriend ?s ?uID ?p ?uID' ≡ IDsOK ?s [?uID, ?uID'] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID' ∈∈ friendIDs ?s ?uID› ‹deleteFriend ?s ?uID ?p ?uID' ≡ let fr = friendIDs ?s in ?s⦇friendIDs := fr(?uID := removeAll ?uID' (fr ?uID), ?uID' := removeAll ?uID (fr ?uID'))⦈›*)) subgoal for x4 apply (cases x4) (*goals: 1. ‹⋀x11 x12 x13 x14 x15. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Uact x4; x4 = uUser x11 x12 x13 x14 x15⟧ ⟹ post s' PID = post s PID› 2. ‹⋀x21 x22 x23 x24. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Uact x4; x4 = uPost x21 x22 x23 x24⟧ ⟹ post s' PID = post s PID› 3. ‹⋀x31 x32 x33 x34. ⟦step s a = (ou, s'); ¬ φ (Trans s a ou s'); PID ∈∈ postIDs s; open s; a = Uact x4; x4 = uVisPost x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 2*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*discuss goal 3*) apply ((auto simp: u_defs (*‹e_updateUser ?s ?uID ?p ?p' ?name ?info ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p› ‹updateUser ?s ?uID ?p ?p' ?name ?info ≡ ?s⦇user := (user ?s)(?uID := Usr ?name ?info), pass := (pass ?s)(?uID := ?p')⦈› ‹e_updatePost ?s ?uID ?p ?pID ?pst ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID› ‹updatePost ?s ?uID ?p ?pID ?pst ≡ let sW = sharedWith ?s in ?s⦇post := (post ?s)(?pID := ?pst), sharedWith := sW(?pID := map (λ(aID, uu_). (aID, False)) (sW ?pID))⦈› ‹e_updateVisPost ?s ?uID ?p ?pID ?vs ≡ IDsOK ?s [?uID] [?pID] [] [] ∧ pass ?s ?uID = ?p ∧ owner ?s ?pID = ?uID ∧ ?vs ∈ {FriendV, PublicV}› ‹updateVisPost ?s ?uID ?p ?pID ?vs ≡ ?s⦇vis := (vis ?s)(?pID := ?vs)⦈›*))[1]) (*proven 3 subgoals*) . subgoal for by auto subgoal for by auto subgoal for x7 apply (cases x7) (*goals: 1. ‹⋀(x11::userID) (x12::password) (x13::apiID) x14::requestInfo. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comSendServerReq x11 x12 x13 x14⟧ ⟹ post s' PID = post s PID› 2. ‹⋀(x21::apiID) x22::requestInfo. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comReceiveClientReq x21 x22⟧ ⟹ post s' PID = post s PID› 3. ‹⋀(x31::userID) (x32::password) (x33::apiID) x34::password. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comConnectClient x31 x32 x33 x34⟧ ⟹ post s' PID = post s PID› 4. ‹⋀(x41::apiID) x42::password. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comConnectServer x41 x42⟧ ⟹ post s' PID = post s PID› 5. ‹⋀(x51::apiID) (x52::password) (x53::postID) (x54::post) (x55::userID) x56::vis. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comReceivePost x51 x52 x53 x54 x55 x56⟧ ⟹ post s' PID = post s PID› 6. ‹⋀(x61::userID) (x62::password) (x63::apiID) x64::postID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comSendPost x61 x62 x63 x64⟧ ⟹ post s' PID = post s PID› 7. ‹⋀(x71::apiID) (x72::password) (x73::userID) x74::userID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comReceiveCreateOFriend x71 x72 x73 x74⟧ ⟹ post s' PID = post s PID› 8. ‹⋀(x81::userID) (x82::password) (x83::apiID) x84::userID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comSendCreateOFriend x81 x82 x83 x84⟧ ⟹ post s' PID = post s PID› 9. ‹⋀(x91::apiID) (x92::password) (x93::userID) x94::userID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comReceiveDeleteOFriend x91 x92 x93 x94⟧ ⟹ post s' PID = post s PID› 10. ‹⋀(x101::userID) (x102::password) (x103::apiID) x104::userID. ⟦step (s::state) (a::act) = (ou::out, s'::state); ¬ φ (Trans s a ou s'); (PID::postID) ∈∈ postIDs s; open s; a = COMact (x7::comActt); x7 = comSendDeleteOFriend x101 x102 x103 x104⟧ ⟹ post s' PID = post s PID› discuss goal 1*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 2*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 3*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 4*) apply (fastforce simp: com_defs (*‹sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?reqInfo::requestInfo) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq (?s::state) (?aID::apiID) (?reqInfo::requestInfo) ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?cp::password) ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer (?s::state) (?aID::apiID) (?sp::password) ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?pst::post) (?uID::userID) (?vs::vis) ≡ let opIDs::apiID ⇒ postID list = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost (?s::state) (?aID::apiID) (?sp::password) (?pID::postID) (?nt::post) (?uID::userID) (?vs::vis) ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost (?s::state) (?uID::userID) (?p::password) (?aID::apiID) (?pID::postID) ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 5*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 6*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 7*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 8*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 9*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*discuss goal 10*) apply (fastforce simp: com_defs (*‹sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ ((?aID, ?reqInfo), ?s⦇pendingSApiReqs := pendingSApiReqs ?s ## ?aID, sApiReq := (sApiReq ?s)(?aID := ?reqInfo)⦈)› ‹e_sendServerReq ?s ?uID ?p ?aID ?reqInfo ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∉ set (pendingSApiReqs ?s)› ‹receiveClientReq ?s ?aID ?reqInfo ≡ ?s⦇pendingCApiReqs := pendingCApiReqs ?s ## ?aID, cApiReq := (cApiReq ?s)(?aID := ?reqInfo)⦈› ‹e_receiveClientReq ?s ?aID ?reqInfo ≡ ?aID ∉ set (pendingCApiReqs ?s) ∧ admin ?s ∈∈ userIDs ?s› ‹connectClient ?s ?uID ?p ?aID ?cp ≡ ((?aID, ?cp), ?s⦇clientApiIDs := ?aID # clientApiIDs ?s, clientPass := (clientPass ?s)(?aID := ?cp), pendingCApiReqs := remove1 ?aID (pendingCApiReqs ?s), cApiReq := (cApiReq ?s)(?aID := emptyRequestInfo)⦈)› ‹e_connectClient ?s ?uID ?p ?aID ?cp ≡ IDsOK ?s [?uID] [] [] [] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ pendingCApiReqs ?s ∧ ?aID ∉ set (clientApiIDs ?s)› ‹connectServer ?s ?aID ?sp ≡ ?s⦇serverApiIDs := ?aID # serverApiIDs ?s, serverPass := (serverPass ?s)(?aID := ?sp), pendingSApiReqs := remove1 ?aID (pendingSApiReqs ?s), sApiReq := (sApiReq ?s)(?aID := emptyRequestInfo)⦈› ‹e_connectServer ?s ?aID ?sp ≡ ?aID ∈∈ pendingSApiReqs ?s ∧ ?aID ∉ set (serverApiIDs ?s)› ‹receivePost ?s ?aID ?sp ?pID ?pst ?uID ?vs ≡ let opIDs = outerPostIDs ?s in ?s⦇outerPostIDs := opIDs(?aID := List.insert ?pID (opIDs ?aID)), outerPost := fun_upd2 (outerPost ?s) ?aID ?pID ?pst, outerOwner := fun_upd2 (outerOwner ?s) ?aID ?pID ?uID, outerVis := fun_upd2 (outerVis ?s) ?aID ?pID ?vs⦈› ‹e_receivePost ?s ?aID ?sp ?pID ?nt ?uID ?vs ≡ IDsOK ?s [] [] [(?aID, [])] [] ∧ serverPass ?s ?aID = ?sp› ‹sendPost ?s ?uID ?p ?aID ?pID ≡ ((?aID, clientPass ?s ?aID, ?pID, post ?s ?pID, owner ?s ?pID, vis ?s ?pID), ?s⦇sharedWith := (sharedWith ?s)(?pID := insert2 ?aID True (sharedWith ?s ?pID))⦈)› ‹e_sendPost ?s ?uID ?p ?aID ?pID ≡ IDsOK ?s [?uID] [?pID] [] [?aID] ∧ pass ?s ?uID = ?p ∧ ?uID = admin ?s ∧ ?aID ∈∈ clientApiIDs ?s› and more 8 facts*)) (*proven 10 subgoals*) . . have op': "open s'" using PID (*‹PID ∈∈ postIDs s›*) step (*‹step s a = (ou, s')›*) "φ" (*‹¬ φ (Trans s a ou s')›*) op (*‹open s›*) unfolding "φ_def2"[OF step] (*goal: ‹open s'›*) apply (cases a) (*goals: 1. ‹⋀x1. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Sact x1⟧ ⟹ open s'› 2. ‹⋀x2. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Cact x2⟧ ⟹ open s'› 3. ‹⋀x3. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Dact x3⟧ ⟹ open s'› 4. ‹⋀x4. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Uact x4⟧ ⟹ open s'› 5. ‹⋀x5. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Ract x5⟧ ⟹ open s'› 6. ‹⋀x6. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = Lact x6⟧ ⟹ open s'› 7. ‹⋀x7. ⟦PID ∈∈ postIDs s; step s a = (ou, s'); ¬ ((∃uid p pst. a = Uact (uPost uid p PID pst) ∧ ou = outOK) ∨ (∃uid p aid. a = COMact (comSendPost uid p aid PID) ∧ ou ≠ outErr) ∨ open s ≠ open s'); open s; a = COMact x7⟧ ⟹ open s'› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . show "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) proof (standard) (*goals: 1. ‹validTrans (Trans s1 ?a1.0 ?ou1.0 ?s1')› 2. ‹consume (Trans s1 ?a1.0 ?ou1.0 ?s1') vl1 ?vl1'› 3. ‹γ (Trans s a ou s') = γ (Trans s1 ?a1.0 ?ou1.0 ?s1')› 4. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 ?a1.0 ?ou1.0 ?s1')› 5. ‹Δ1 s' vl' ?s1' ?vl1' ∨ Δ31 s' vl' ?s1' ?vl1' ∨ Δ32 s' vl' ?s1' ?vl1' ∨ Δ4 s' vl' ?s1' ?vl1'›*) show "validTrans ?trn1" unfolding ss1 (*goal: ‹validTrans (Trans s a ou s')›*) using step (*‹step s a = (ou, s')›*) by simp next (*goals: 1. ‹consume (Trans s1 a ou s') vl1 ?vl1'› 2. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 3. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 4. ‹Δ1 s' vl' s' ?vl1' ∨ Δ31 s' vl' s' ?vl1' ∨ Δ32 s' vl' s' ?vl1' ∨ Δ4 s' vl' s' ?vl1'›*) show "consume ?trn1 vl1 vl1" using "φ" (*‹¬ φ (Trans s a ou s')›*) unfolding ss1 consume_def vl' vl vl1 (*goal: ‹if φ (Trans s a ou s') then ul @ OVal False # vll1 ≠ [] ∧ f (Trans s a ou s') = hd (ul @ OVal False # vll1) ∧ ul @ OVal False # vll1 = tl (ul @ OVal False # vll1) else ul @ OVal False # vll1 = ul @ OVal False # vll1›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') = γ (Trans s1 a ou s')› 2. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 3. ‹Δ1 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) show "γ ?trn = γ ?trn1" unfolding ss1 (*goal: ‹γ (Trans s a ou s') = γ (Trans s a ou s')›*) by simp next (*goals: 1. ‹γ (Trans s a ou s') ⟹ g (Trans s a ou s') = g (Trans s1 a ou s')› 2. ‹Δ1 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) assume "γ ?trn" (*‹γ (Trans (s::state) (a::act) (ou::out) (s'::state))›*) thus "g ?trn = g ?trn1" unfolding ss1 (*goal: ‹g (Trans s a ou s') = g (Trans s a ou s')›*) by simp next (*goal: ‹Δ1 s' vl' s' vl1 ∨ Δ31 s' vl' s' vl1 ∨ Δ32 s' vl' s' vl1 ∨ Δ4 s' vl' s' vl1›*) have "Δ4 s' vl' s' vl1" using cor1 (*‹corrFrom (post s1 PID) vl1›*) PID' (*‹PID ∈∈ postIDs s'›*) pPID' (*‹post s' PID = post s PID›*) op' (*‹open s'›*) vl1 (*‹vl1 = ul @ OVal False # vll1›*) ss1 (*‹s1 = s›*) lul (*‹list_all (Not ∘ isOVal) (ul::value list)›*) BC (*‹BC vll vll1›*) unfolding "Δ4_def" vl vl' (*goal: ‹PID ∈∈ postIDs s' ∧ (∃ula vlla vll1. BC vlla vll1 ∧ list_all (Not ∘ isOVal) ula ∧ ul @ OVal False # vll = ula @ OVal False # vlla ∧ vl1 = ula @ OVal False # vll1) ∧ s' = s' ∧ open s' ∧ corrFrom (post s' PID) vl1›*) by auto thus "?Δ s' vl' s' vl1" by simp qed qed thus "?thesis" (*goal: ‹match (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl' ∨ ignore (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s s1 vl1 a ou s' vl'›*) by simp qed qed thus "?thesis" (*goal: ‹iaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1 ∨ (vl = [] ⟶ vl1 = []) ∧ reaction (λs vl s1 vl1. Δ1 s vl s1 vl1 ∨ Δ31 s vl s1 vl1 ∨ Δ32 s vl s1 vl1 ∨ Δ4 s vl s1 vl1) s vl s1 vl1›*) using vl (*‹vl = ul @ OVal False # vll›*) by simp qed qed definition Gr where "Gr = { (Δ0, {Δ0,Δ1,Δ2,Δ31,Δ32,Δ4}), (Δ1, {Δ1,Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31,Δ32}), (Δ32, {Δ2,Δ32,Δ4}), (Δ4, {Δ1,Δ31,Δ32,Δ4}) }" theorem secure: secure apply (rule unwind_decomp_secure_graph[of Gr Δ0] (*‹⟦∀Δ::state ⇒ value list ⇒ state ⇒ value list ⇒ bool∈Domain Gr. ∃Δs⊆Domain Gr. (Δ, Δs) ∈ Gr; Δ0 ∈ Domain Gr; ⋀(vl::value list) vl1::value list. B vl vl1 ⟹ Δ0 istate vl istate vl1; ⋀Δ::state ⇒ value list ⇒ state ⇒ value list ⇒ bool. unwind_exit Δ ∨ (∀Δs::(state ⇒ value list ⇒ state ⇒ value list ⇒ bool) set. (Δ, Δs) ∈ Gr ⟶ unwind_cont Δ Δs)⟧ ⟹ secure›*)) (*goal: ‹secure›*) unfolding Gr_def (*goals: 1. ‹∀Δ::state ⇒ value list ⇒ state ⇒ value list ⇒ bool∈Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}. ∃Δs⊆Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}. (Δ, Δs) ∈ {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}› 2. ‹Δ0 ∈ Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}› 3. ‹⋀(vl::value list) vl1::value list. B vl vl1 ⟹ Δ0 istate vl istate vl1› 4. ‹⋀Δ::state ⇒ value list ⇒ state ⇒ value list ⇒ bool. unwind_exit Δ ∨ (∀Δs::(state ⇒ value list ⇒ state ⇒ value list ⇒ bool) set. (Δ, Δs) ∈ {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})} ⟶ unwind_cont Δ Δs)›*) apply (simp, smt insert_subset (*‹(insert ?x ?A ⊆ ?B) = (?x ∈ ?B ∧ ?A ⊆ ?B)›*) order_refl (*‹?x ≤ ?x›*)) (*top goal: ‹∀Δ∈Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}. ∃Δs⊆Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}. (Δ, Δs) ∈ {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}› and 3 goals remain*) using "istate_Δ0" (*‹B ?vl ?vl1.0 ⟹ Δ0 istate ?vl istate ?vl1.0›*) "unwind_cont_Δ0" (*‹unwind_cont Δ0 {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}›*) "unwind_cont_Δ1" (*‹unwind_cont Δ1 {Δ1, Δ11}›*) "unwind_cont_Δ11" (*‹unwind_cont Δ11 {Δ11}›*) "unwind_cont_Δ31" (*‹unwind_cont Δ31 {Δ31, Δ32}›*) "unwind_cont_Δ32" (*‹unwind_cont Δ32 {Δ2, Δ32, Δ4}›*) "unwind_cont_Δ2" (*‹unwind_cont Δ2 {Δ2}›*) "unwind_cont_Δ4" (*‹unwind_cont Δ4 {Δ1, Δ31, Δ32, Δ4}›*) unfolding Gr_def (*goals: 1. ‹Δ0 ∈ Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}› 2. ‹⋀(vl::value list) vl1::value list. B vl vl1 ⟹ Δ0 istate vl istate vl1› 3. ‹⋀Δ::state ⇒ value list ⇒ state ⇒ value list ⇒ bool. unwind_exit Δ ∨ (∀Δs::(state ⇒ value list ⇒ state ⇒ value list ⇒ bool) set. (Δ, Δs) ∈ {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})} ⟶ unwind_cont Δ Δs)›*) apply - (*goals: 1. ‹⟦⋀vl vl1. B vl vl1 ⟹ Δ0 istate vl istate vl1; unwind_cont Δ0 {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}; unwind_cont Δ1 {Δ1, Δ11}; unwind_cont Δ11 {Δ11}; unwind_cont Δ31 {Δ31, Δ32}; unwind_cont Δ32 {Δ2, Δ32, Δ4}; unwind_cont Δ2 {Δ2}; unwind_cont Δ4 {Δ1, Δ31, Δ32, Δ4}⟧ ⟹ Δ0 ∈ Domain {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})}› 2. ‹⋀vl vl1. ⟦B vl vl1; ⋀vl vl1. B vl vl1 ⟹ Δ0 istate vl istate vl1; unwind_cont Δ0 {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}; unwind_cont Δ1 {Δ1, Δ11}; unwind_cont Δ11 {Δ11}; unwind_cont Δ31 {Δ31, Δ32}; unwind_cont Δ32 {Δ2, Δ32, Δ4}; unwind_cont Δ2 {Δ2}; unwind_cont Δ4 {Δ1, Δ31, Δ32, Δ4}⟧ ⟹ Δ0 istate vl istate vl1› 3. ‹⋀Δ. ⟦⋀vl vl1. B vl vl1 ⟹ Δ0 istate vl istate vl1; unwind_cont Δ0 {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}; unwind_cont Δ1 {Δ1, Δ11}; unwind_cont Δ11 {Δ11}; unwind_cont Δ31 {Δ31, Δ32}; unwind_cont Δ32 {Δ2, Δ32, Δ4}; unwind_cont Δ2 {Δ2}; unwind_cont Δ4 {Δ1, Δ31, Δ32, Δ4}⟧ ⟹ unwind_exit Δ ∨ (∀Δs. (Δ, Δs) ∈ {(Δ0, {Δ0, Δ1, Δ2, Δ31, Δ32, Δ4}), (Δ1, {Δ1, Δ11}), (Δ11, {Δ11}), (Δ2, {Δ2}), (Δ31, {Δ31, Δ32}), (Δ32, {Δ2, Δ32, Δ4}), (Δ4, {Δ1, Δ31, Δ32, Δ4})} ⟶ unwind_cont Δ Δs)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . end end
{ "path": "afp-2025-02-12/thys/CoSMeDis/Post_Confidentiality/Independent_Posts/Independent_DYNAMIC_Post_ISSUER.thy", "repo": "afp-2025-02-12", "sha": "5fcc3ecfc43e5e4000cccde6215c0d128d3bc70f121fb00b0b5e3d97eaffe996" }
theory ArityTransform imports ArityAnalysisSig AbstractTransform ArityEtaExpansionSafe begin context ArityAnalysisHeapEqvt begin sublocale AbstractTransformBound "λ a . inc⋅a" "λ a . pred⋅a" "λ Δ e a . (a, Aheap Δ e⋅a)" "fst" "snd" "λ _. 0" "Aeta_expand" "snd" apply standard (*goals: 1. ‹⋀π. π ∙ Rep_cfun inc ≡ Rep_cfun inc› 2. ‹⋀π. π ∙ Rep_cfun pred ≡ Rep_cfun pred› 3. ‹⋀π. π ∙ (λΔ e a. (a, Aheap Δ e⋅a)) ≡ λΔ e a. (a, Aheap Δ e⋅a)› 4. ‹⋀π. π ∙ fst ≡ fst› 5. ‹⋀π. π ∙ snd ≡ snd› 6. ‹⋀π. π ∙ (λ_. 0) ≡ λ_. 0› 7. ‹⋀π. π ∙ snd = snd› 8. ‹⋀π. π ∙ Aeta_expand = Aeta_expand› discuss goal 1*) apply (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*)) (*top goal: ‹⋀π. π ∙ Rep_cfun inc ≡ Rep_cfun inc› and 7 goals remain*) apply perm_simp (*top goal: ‹⋀π. π ∙ Rep_cfun inc = Rep_cfun inc› and 7 goals remain*) apply rule (*discuss goal 2*) apply (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*)) (*top goal: ‹⋀π. π ∙ Rep_cfun pred ≡ Rep_cfun pred› and 6 goals remain*) apply perm_simp (*top goal: ‹⋀π. π ∙ Rep_cfun pred = Rep_cfun pred› and 6 goals remain*) apply rule (*discuss goal 3*) apply (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*)) (*top goal: ‹⋀π::perm. π ∙ (λ(Δ::(Vars.var × exp) list) (e::exp) a::Arity. (a, (Aheap::(Vars.var × exp) list ⇒ exp ⇒ Arity → Vars.var ⇒ Arity⇩⊥) Δ e⋅a)) ≡ λ(Δ::(Vars.var × exp) list) (e::exp) a::Arity. (a, Aheap Δ e⋅a)› and 5 goals remain*) apply perm_simp (*top goal: ‹⋀π::perm. π ∙ (λ(Δ::(Vars.var × exp) list) (e::exp) a::Arity. (a, (Aheap::(Vars.var × exp) list ⇒ exp ⇒ Arity → Vars.var ⇒ Arity⇩⊥) Δ e⋅a)) = (λ(Δ::(Vars.var × exp) list) (e::exp) a::Arity. (a, Aheap Δ e⋅a))› and 5 goals remain*) apply rule (*discuss goal 4*) apply (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*)) (*top goal: ‹⋀π. π ∙ fst ≡ fst› and 4 goals remain*) apply perm_simp (*top goal: ‹⋀π. π ∙ fst = fst› and 4 goals remain*) apply rule (*discuss goal 5*) apply (rule eq_reflection (*‹?x = ?y ⟹ ?x ≡ ?y›*)) (*top goal: ‹⋀π. π ∙ snd ≡ snd› and 3 goals remain*) apply perm_simp (*top goal: ‹⋀π::perm. π ∙ snd = snd› and 3 goals remain*) apply rule (*discuss goal 6*) apply (rule eq_reflection (*‹(?x::?'a::type) = (?y::?'a::type) ⟹ ?x ≡ ?y›*)) (*top goal: ‹⋀π. π ∙ (λ_. 0) ≡ λ_. 0› and 2 goals remain*) apply perm_simp (*top goal: ‹⋀π. π ∙ (λ_. 0) = (λ_. 0)› and 2 goals remain*) apply rule (*discuss goal 7*) apply perm_simp (*top goal: ‹⋀π. π ∙ snd = snd› and 1 goal remains*) apply rule (*discuss goal 8*) apply perm_simp (*goal: ‹⋀π. π ∙ Aeta_expand = Aeta_expand›*) apply rule (*proven 8 subgoals*) . abbreviation transform_syn ("𝒯⇘_⇙") where "𝒯⇘a⇙ ≡ transform a" lemma transform_simps: "𝒯⇘a⇙ (App e x) = App (𝒯⇘inc⋅a⇙ e) x" "𝒯⇘a⇙ (Lam [x]. e) = Lam [x]. 𝒯⇘pred⋅a⇙ e" "𝒯⇘a⇙ (Var x) = Var x" "𝒯⇘a⇙ (Let Γ e) = Let (map_transform Aeta_expand (Aheap Γ e⋅a) (map_transform (λa. 𝒯⇘a⇙) (Aheap Γ e⋅a) Γ)) (𝒯⇘a⇙ e)" "𝒯⇘a⇙ (Bool b) = Bool b" "𝒯⇘a⇙ (scrut ? e1 : e2) = (𝒯⇘0⇙ scrut ? 𝒯⇘a⇙ e1 : 𝒯⇘a⇙ e2)" (*goals: 1. ‹𝒯⇘a⇙ (App e x) = App (𝒯⇘inc⋅a⇙ e) x› 2. ‹𝒯⇘a⇙ (Lam [x]. e) = Lam [x]. 𝒯⇘pred⋅a⇙ e› 3. ‹𝒯⇘a⇙ (Var x) = Var x› 4. ‹𝒯⇘a⇙ (Terms.Let Γ e) = Terms.Let (map_transform Aeta_expand (Aheap Γ e⋅a) (map_transform transform_syn (Aheap Γ e⋅a) Γ)) (𝒯⇘a⇙ e)› 5. ‹𝒯⇘a⇙ (Bool b) = Bool b› 6. ‹𝒯⇘a⇙ (scrut ? e1 : e2) = (𝒯⇘0⇙ scrut ? 𝒯⇘a⇙ e1 : 𝒯⇘a⇙ e2)› discuss goal 1*) apply simp (*discuss goal 2*) apply simp (*discuss goal 3*) apply simp (*discuss goal 4*) apply simp (*discuss goal 5*) apply simp (*discuss goal 6*) apply simp (*proven 6 subgoals*) . end end
{ "path": "afp-2025-02-12/thys/Call_Arity/ArityTransform.thy", "repo": "afp-2025-02-12", "sha": "96fbe041f80990ab12f240cf99772ff7430b1a87376ac49054596aa3c1705a39" }
(* Title: Sensors.thy Author: Sven Linker Defines perfect sensors for cars. Cars can perceive both the physical size and braking distance of all other cars. *) section‹ Sensors for Cars› text‹ This section presents the abstract definition of a function determining the sensor capabilities of cars. Such a function takes a car \(e\), a traffic snapshot \(ts\) and another car \(c\), and returns the length of \(c\) as perceived by \(e\) at the situation determined by \(ts\). The only restriction we impose is that this length is always greater than zero. With such a function, we define a derived notion of the \emph{space} the car \(c\) occupies as perceived by \(e\). However, this does not define the lanes \(c\) occupies, but only a continuous interval. The lanes occupied by \(c\) are given by the reservation and claim functions of the traffic snapshot \(ts\). › theory Sensors imports "Traffic" "Views" begin locale sensors = traffic + view + fixes sensors::"(cars) ⇒ traffic ⇒ (cars) ⇒ real" assumes sensors_ge:"(sensors e ts c) > 0" begin definition space ::" traffic ⇒ view ⇒ cars ⇒ real_int" where "space ts v c ≡ Abs_real_int (pos ts c, pos ts c + sensors (own v) ts c)" lemma left_space: "left (space ts v c) = pos ts c" proof (-) (*goal: ‹left (space ts v c) = pos ts c›*) have 1: "pos ts c < pos ts c + sensors (own v) ts c" using sensors_ge (*‹0 < sensors ?e ?ts ?c›*) by (metis (no_types, opaque_lifting) less_add_same_cancel1 (*‹(?a < ?a + ?b) = (0 < ?b)›*)) show "left (space ts v c ) = pos ts c" using space_def (*‹space ?ts ?v ?c ≡ Abs_real_int (pos ?ts ?c, pos ?ts ?c + sensors (own ?v) ?ts ?c)›*) Abs_real_int_inverse (*‹(?y::real × real) ∈ {r::real × real. fst r ≤ snd r} ⟹ Rep_real_int (Abs_real_int ?y) = ?y›*) "1" (*‹pos (ts::traffic) (c::cars) < pos ts c + (sensors::cars ⇒ traffic ⇒ cars ⇒ real) (own (v::view)) ts c›*) by simp qed lemma right_space: "right (space ts v c) = pos ts c + sensors (own v) ts c" proof (-) (*goal: ‹right (space ts v c) = pos ts c + sensors (own v) ts c›*) have 1: "pos ts c < pos ts c + sensors (own v) ts c" using sensors_ge (*‹0 < sensors ?e ?ts ?c›*) by (metis (no_types, opaque_lifting) less_add_same_cancel1 (*‹(?a < ?a + ?b) = (0 < ?b)›*)) show 3: "right(space ts v c ) = pos ts c + sensors (own v) ts c" using space_def (*‹space ?ts ?v ?c ≡ Abs_real_int (pos ?ts ?c, pos ?ts ?c + sensors (own ?v) ?ts ?c)›*) Abs_real_int_inverse (*‹(?y::real × real) ∈ {r::real × real. fst r ≤ snd r} ⟹ Rep_real_int (Abs_real_int ?y) = ?y›*) "1" (*‹pos (ts::traffic) (c::cars) < pos ts c + (sensors::cars ⇒ traffic ⇒ cars ⇒ real) (own (v::view)) ts c›*) by simp qed lemma space_nonempty:"left (space ts v c ) < right (space ts v c)" using left_space (*‹left (space ?ts ?v ?c) = pos ?ts ?c›*) right_space (*‹right (space (?ts::traffic) (?v::view) (?c::cars)) = pos ?ts ?c + (sensors::cars ⇒ traffic ⇒ cars ⇒ real) (own ?v) ?ts ?c›*) sensors_ge (*‹0 < sensors ?e ?ts ?c›*) by simp end end
{ "path": "afp-2025-02-12/thys/Hybrid_Multi_Lane_Spatial_Logic/Sensors.thy", "repo": "afp-2025-02-12", "sha": "0a27f5ecc69a62baec478edd4359bc7e10a5456dc764c8df5ebd67a29070af51" }
theory FOR_Check_Impl imports FOR_Check Regular_Tree_Relations.Regular_Relation_Impl NF_Impl begin section ‹Inference checking implementation› (* we define epsilon free agtt/gtt constructions *) definition "ftrancl_eps_free_closures 𝒜 = eps_free_automata (eps 𝒜) 𝒜" abbreviation "ftrancl_eps_free_reg 𝒜 ≡ Reg (fin 𝒜) (ftrancl_eps_free_closures (ta 𝒜))" lemma ftrancl_eps_free_ta_derI: "(eps 𝒜)|⁺| = eps 𝒜 ⟹ ta_der (ftrancl_eps_free_closures 𝒜) (term_of_gterm t) = ta_der 𝒜 (term_of_gterm t)" using eps_free[of 𝒜] (*‹eps_free 𝒜 = eps_free_automata ((eps 𝒜)|⁺|) 𝒜›*) ta_res_eps_free[of 𝒜] (*‹ta_der (eps_free 𝒜) (term_of_gterm ?t) = ta_der 𝒜 (term_of_gterm ?t)›*) by (auto simp add: ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*)) lemma ℒ_ftrancl_eps_free_closuresI: "(eps (ta 𝒜))|⁺| = eps (ta 𝒜) ⟹ ℒ (ftrancl_eps_free_reg 𝒜) = ℒ 𝒜" using ftrancl_eps_free_ta_derI[of "ta 𝒜"] (*‹(eps (ta 𝒜))|⁺| = eps (ta 𝒜) ⟹ ta_der (ftrancl_eps_free_closures (ta 𝒜)) (term_of_gterm ?t) = ta_der (ta 𝒜) (term_of_gterm ?t)›*) unfolding "ℒ_def" (*goal: ‹(eps (ta 𝒜))|⁺| = eps (ta 𝒜) ⟹ gta_lang (fin (ftrancl_eps_free_reg 𝒜)) (ta (ftrancl_eps_free_reg 𝒜)) = gta_lang (fin 𝒜) (ta 𝒜)›*) by (auto simp: gta_lang_def (*‹gta_lang ?Q ?𝒜 = {t. ?Q |∩| gta_der ?𝒜 t ≠ {||}}›*) gta_der_def (*‹gta_der ?𝒜 ?t = ta_der ?𝒜 (term_of_gterm ?t)›*)) definition "root_step R ℱ ≡ (let (TA1, TA2) = agtt_grrstep R ℱ in (ftrancl_eps_free_closures TA1, TA2))" definition AGTT_trancl_eps_free :: "('q, 'f) gtt ⇒ ('q + 'q, 'f) gtt" where "AGTT_trancl_eps_free 𝒢 = (let (𝒜, ℬ) = AGTT_trancl 𝒢 in (ftrancl_eps_free_closures 𝒜, ℬ))" definition GTT_trancl_eps_free where "GTT_trancl_eps_free 𝒢 = (let (𝒜, ℬ) = GTT_trancl 𝒢 in (ftrancl_eps_free_closures 𝒜, ftrancl_eps_free_closures ℬ))" definition AGTT_comp_eps_free where "AGTT_comp_eps_free 𝒢₁ 𝒢₂ = (let (𝒜, ℬ) = AGTT_comp' 𝒢₁ 𝒢₂ in (ftrancl_eps_free_closures 𝒜, ℬ))" definition GTT_comp_eps_free where "GTT_comp_eps_free 𝒢₁ 𝒢₂ =(let (𝒜, ℬ) = GTT_comp' 𝒢₁ 𝒢₂ in (ftrancl_eps_free_closures 𝒜, ftrancl_eps_free_closures ℬ))" (* epsilon free proves *) lemma eps_free_relable [simp]: "is_gtt_eps_free (relabel_gtt 𝒢) = is_gtt_eps_free 𝒢" by (auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) relabel_gtt_def (*‹relabel_gtt ?G = fmap_states_gtt (map_fset_to_nat (gtt_states ?G)) ?G›*) fmap_states_gtt_def (*‹fmap_states_gtt ?f ≡ map_both (fmap_states_ta ?f)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*)) lemma eps_free_prod_swap: "is_gtt_eps_free (𝒜, ℬ) ⟹ is_gtt_eps_free (ℬ, 𝒜)" by (auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free (?𝒢::(?'q::type, ?'f::type) ta × (?'p::type, ?'g::type) ta) = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*)) lemma eps_free_root_step: "is_gtt_eps_free (root_step R ℱ)" by (auto simp add: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) root_step_def (*‹root_step ?R ?ℱ ≡ let (TA1, TA2) = agtt_grrstep ?R ?ℱ in (ftrancl_eps_free_closures TA1, TA2)›*) pair_at_to_agtt'_def (*‹pair_at_to_agtt' ?𝒢 ?Q = (let 𝒜 = fmap_states_ta Inl (fst ?𝒢); ℬ = fmap_states_ta Inr (snd ?𝒢); Q' = ?Q |∩| 𝒬 (fst ?𝒢) |×| 𝒬 (snd ?𝒢) in pair_at_to_agtt (𝒜, ℬ) (map_prod Inl Inr |`| Q'))›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*)) lemma eps_free_AGTT_trancl_eps_free: "is_gtt_eps_free 𝒢 ⟹ is_gtt_eps_free (AGTT_trancl_eps_free 𝒢)" by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) AGTT_trancl_def (*‹AGTT_trancl ?𝒢 = (let 𝒜 = fmap_states_ta CInl (fst ?𝒢) in (add_eps 𝒜 (map_prod CInl CInr |`| Δ_Atrans_gtt ?𝒢 (fId_on (gtt_interface ?𝒢))), TA (map_ta_rule CInr id |`| rules (snd ?𝒢)) (map_both CInr |`| eps (snd ?𝒢))))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) AGTT_trancl_eps_free_def (*‹AGTT_trancl_eps_free ?𝒢 = (let (𝒜, ℬ) = AGTT_trancl ?𝒢 in (ftrancl_eps_free_closures 𝒜, ℬ))›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*)) lemma eps_free_GTT_trancl_eps_free: "is_gtt_eps_free 𝒢 ⟹ is_gtt_eps_free (GTT_trancl_eps_free 𝒢)" by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) GTT_trancl_eps_free_def (*‹GTT_trancl_eps_free ?𝒢 = (let (𝒜, ℬ) = GTT_trancl ?𝒢 in (ftrancl_eps_free_closures 𝒜, ftrancl_eps_free_closures ℬ))›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*)) lemma eps_free_AGTT_comp_eps_free: "is_gtt_eps_free 𝒢₂ ⟹ is_gtt_eps_free (AGTT_comp_eps_free 𝒢₁ 𝒢₂)" by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) AGTT_comp_eps_free_def (*‹AGTT_comp_eps_free ?𝒢₁ ?𝒢₂ = (let (𝒜, ℬ) = AGTT_comp' ?𝒢₁ ?𝒢₂ in (ftrancl_eps_free_closures 𝒜, ℬ))›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) AGTT_comp_def (*‹AGTT_comp ?𝒢₁ ?𝒢₂ = (let (𝒜, ℬ) = (fst ?𝒢₁, snd ?𝒢₂) in (add_eps 𝒜 (Δ⇩ε (snd ?𝒢₁) (fst ?𝒢₂) |∩| gtt_interface ?𝒢₁ |×| gtt_interface ?𝒢₂), TA (rules ℬ) (eps ℬ)))›*) fmap_states_gtt_def (*‹fmap_states_gtt ?f ≡ map_both (fmap_states_ta ?f)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*)) lemma eps_free_GTT_comp_eps_free: "is_gtt_eps_free (GTT_comp_eps_free 𝒢₁ 𝒢₂)" by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) GTT_comp_eps_free_def (*‹GTT_comp_eps_free ?𝒢₁ ?𝒢₂ = (let (𝒜, ℬ) = GTT_comp' ?𝒢₁ ?𝒢₂ in (ftrancl_eps_free_closures 𝒜, ftrancl_eps_free_closures ℬ))›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*)) lemmas eps_free_const = eps_free_prod_swap eps_free_root_step eps_free_AGTT_trancl_eps_free eps_free_GTT_trancl_eps_free eps_free_AGTT_comp_eps_free eps_free_GTT_comp_eps_free (* lang preserve proofs *) lemma agtt_lang_derI: assumes "⋀ t. ta_der (fst 𝒜) (term_of_gterm t) = ta_der (fst ℬ) (term_of_gterm t)" and "⋀ t. ta_der (snd 𝒜) (term_of_gterm t) = ta_der (snd ℬ) (term_of_gterm t)" shows "agtt_lang 𝒜 = agtt_lang ℬ" using assms (*‹ta_der (fst 𝒜) (term_of_gterm ?t) = ta_der (fst ℬ) (term_of_gterm ?t)› ‹ta_der (snd (𝒜::('b, 'a) ta × ('b, 'a) ta)) (term_of_gterm (?t::'a gterm)) = ta_der (snd (ℬ::('b, 'a) ta × ('b, 'a) ta)) (term_of_gterm ?t)›*) by (auto simp: agtt_lang_def (*‹agtt_lang ?𝒢 = {uu_. ∃t u q. uu_ = (t, u) ∧ q |∈| gta_der (fst ?𝒢) t ∧ q |∈| gta_der (snd ?𝒢) u}›*) gta_der_def (*‹gta_der ?𝒜 ?t = ta_der ?𝒜 (term_of_gterm ?t)›*)) lemma agtt_lang_root_step_conv: "agtt_lang (root_step R ℱ) = agtt_lang (agtt_grrstep R ℱ)" using ftrancl_eps_free_ta_derI[OF agtt_grrstep_eps_trancl ( 1 ), of R ℱ] (*‹ta_der (ftrancl_eps_free_closures (fst (agtt_grrstep (R::(('a::type, 'b::type) Term.term × ('a::type, 'b::type) Term.term) fset) (ℱ::('a::type × fvar) fset)))) (term_of_gterm (?t::'a::type gterm)) = ta_der (fst (agtt_grrstep R ℱ)) (term_of_gterm ?t)›*) by (auto simp: case_prod_beta (*‹(case ?p::?'b × ?'c of (x::?'b, xa::?'c) ⇒ (?f::?'b ⇒ ?'c ⇒ ?'a) x xa) = ?f (fst ?p) (snd ?p)›*) root_step_def (*‹root_step (?R::((?'a, ?'b) Term.term × (?'a, ?'b) Term.term) fset) (?ℱ::(?'a × fvar) fset) ≡ let (TA1::(?'a bot_term + ?'a bot_term, ?'a) ta, TA2::(?'a bot_term + ?'a bot_term, ?'a) ta) = agtt_grrstep ?R ?ℱ in (ftrancl_eps_free_closures TA1, TA2)›*) intro!: agtt_lang_derI (*‹⟦⋀t::?'a gterm. ta_der (fst (?𝒜::(?'b, ?'a) ta × (?'b, ?'a) ta)) (term_of_gterm t) = ta_der (fst (?ℬ::(?'b, ?'a) ta × (?'b, ?'a) ta)) (term_of_gterm t); ⋀t::?'a gterm. ta_der (snd ?𝒜) (term_of_gterm t) = ta_der (snd ?ℬ) (term_of_gterm t)⟧ ⟹ agtt_lang ?𝒜 = agtt_lang ?ℬ›*)) lemma agtt_lang_AGTT_trancl_eps_free_conv: assumes "is_gtt_eps_free 𝒢" shows "agtt_lang (AGTT_trancl_eps_free 𝒢) = agtt_lang (AGTT_trancl 𝒢)" proof (-) (*goal: ‹agtt_lang (AGTT_trancl_eps_free (𝒢::('a, 'b) ta × ('a, 'b) ta)) = agtt_lang (AGTT_trancl 𝒢)›*) let ?eps = "eps (fst (AGTT_trancl 𝒢))" have "?eps |O| ?eps = {||}" using assms (*‹is_gtt_eps_free 𝒢›*) by (auto simp: AGTT_trancl_def (*‹AGTT_trancl ?𝒢 = (let 𝒜 = fmap_states_ta CInl (fst ?𝒢) in (add_eps 𝒜 (map_prod CInl CInr |`| Δ_Atrans_gtt ?𝒢 (fId_on (gtt_interface ?𝒢))), TA (map_ta_rule CInr id |`| rules (snd ?𝒢)) (map_both CInr |`| eps (snd ?𝒢))))›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*)) from ftrancl_eps_free_ta_derI[OF frelcomp_empty_ftrancl_simp [ OF this ]] (*‹ta_der (ftrancl_eps_free_closures (fst (AGTT_trancl 𝒢))) (term_of_gterm ?t) = ta_der (fst (AGTT_trancl 𝒢)) (term_of_gterm ?t)›*) show "?thesis" (*goal: ‹agtt_lang (AGTT_trancl_eps_free 𝒢) = agtt_lang (AGTT_trancl 𝒢)›*) by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) AGTT_trancl_eps_free_def (*‹AGTT_trancl_eps_free ?𝒢 = (let (𝒜, ℬ) = AGTT_trancl ?𝒢 in (ftrancl_eps_free_closures 𝒜, ℬ))›*) intro!: agtt_lang_derI (*‹⟦⋀t. ta_der (fst ?𝒜) (term_of_gterm t) = ta_der (fst ?ℬ) (term_of_gterm t); ⋀t. ta_der (snd ?𝒜) (term_of_gterm t) = ta_der (snd ?ℬ) (term_of_gterm t)⟧ ⟹ agtt_lang ?𝒜 = agtt_lang ?ℬ›*)) qed lemma agtt_lang_GTT_trancl_eps_free_conv: assumes "is_gtt_eps_free 𝒢" shows "agtt_lang (GTT_trancl_eps_free 𝒢) = agtt_lang (GTT_trancl 𝒢)" proof (-) (*goal: ‹agtt_lang (GTT_trancl_eps_free (𝒢::('a, 'b) ta × ('a, 'b) ta)) = agtt_lang (GTT_trancl 𝒢)›*) have "(eps (fst (GTT_trancl 𝒢)))|⁺| = eps (fst (GTT_trancl 𝒢))" "(eps (snd (GTT_trancl 𝒢)))|⁺| = eps (snd (GTT_trancl 𝒢))" using assms (*‹is_gtt_eps_free 𝒢›*) apply - (*goals: 1. ‹is_gtt_eps_free 𝒢 ⟹ (eps (fst (GTT_trancl 𝒢)))|⁺| = eps (fst (GTT_trancl 𝒢))› 2. ‹is_gtt_eps_free 𝒢 ⟹ (eps (snd (GTT_trancl 𝒢)))|⁺| = eps (snd (GTT_trancl 𝒢))› discuss goal 1*) apply ((auto simp: GTT_trancl_def (*‹GTT_trancl ?G = (let Δ = Δ_trancl (snd ?G) (fst ?G) in (add_eps (fst ?G) Δ, add_eps (snd ?G) (Δ|¯|)))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) Δ_trancl_inv (*‹(Δ_trancl ?A ?B)|¯| = Δ_trancl ?B ?A›*))[1]) (*discuss goal 2*) apply ((auto simp: GTT_trancl_def (*‹GTT_trancl ?G = (let Δ = Δ_trancl (snd ?G) (fst ?G) in (add_eps (fst ?G) Δ, add_eps (snd ?G) (Δ|¯|)))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) Δ_trancl_inv (*‹(Δ_trancl ?A ?B)|¯| = Δ_trancl ?B ?A›*))[1]) (*proven 2 subgoals*) . from ftrancl_eps_free_ta_derI[OF this ( 1 )] (*‹ta_der (ftrancl_eps_free_closures (fst (GTT_trancl 𝒢))) (term_of_gterm ?t) = ta_der (fst (GTT_trancl 𝒢)) (term_of_gterm ?t)›*) ftrancl_eps_free_ta_derI[OF this ( 2 )] (*‹ta_der (ftrancl_eps_free_closures (snd (GTT_trancl 𝒢))) (term_of_gterm ?t) = ta_der (snd (GTT_trancl 𝒢)) (term_of_gterm ?t)›*) show "?thesis" (*goal: ‹agtt_lang (GTT_trancl_eps_free (𝒢::('a::type, 'b::type) ta × ('a::type, 'b::type) ta)) = agtt_lang (GTT_trancl 𝒢)›*) by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) GTT_trancl_eps_free_def (*‹GTT_trancl_eps_free ?𝒢 = (let (𝒜, ℬ) = GTT_trancl ?𝒢 in (ftrancl_eps_free_closures 𝒜, ftrancl_eps_free_closures ℬ))›*) intro!: agtt_lang_derI (*‹⟦⋀t. ta_der (fst ?𝒜) (term_of_gterm t) = ta_der (fst ?ℬ) (term_of_gterm t); ⋀t. ta_der (snd ?𝒜) (term_of_gterm t) = ta_der (snd ?ℬ) (term_of_gterm t)⟧ ⟹ agtt_lang ?𝒜 = agtt_lang ?ℬ›*)) qed lemma agtt_lang_AGTT_comp_eps_free_conv: assumes "is_gtt_eps_free 𝒢₁" "is_gtt_eps_free 𝒢₂" shows "agtt_lang (AGTT_comp_eps_free 𝒢₁ 𝒢₂) = agtt_lang (AGTT_comp' 𝒢₁ 𝒢₂)" proof (-) (*goal: ‹agtt_lang (AGTT_comp_eps_free 𝒢₁ 𝒢₂) = agtt_lang (AGTT_comp' 𝒢₁ 𝒢₂)›*) have "(eps (fst (AGTT_comp' 𝒢₁ 𝒢₂)))|⁺| = eps (fst (AGTT_comp' 𝒢₁ 𝒢₂))" using assms (*‹is_gtt_eps_free 𝒢₁› ‹is_gtt_eps_free 𝒢₂›*) by (auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) fmap_states_gtt_def (*‹fmap_states_gtt ?f ≡ map_both (fmap_states_ta ?f)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) AGTT_comp_def (*‹AGTT_comp ?𝒢₁ ?𝒢₂ = (let (𝒜, ℬ) = (fst ?𝒢₁, snd ?𝒢₂) in (add_eps 𝒜 (Δ⇩ε (snd ?𝒢₁) (fst ?𝒢₂) |∩| gtt_interface ?𝒢₁ |×| gtt_interface ?𝒢₂), TA (rules ℬ) (eps ℬ)))›*) gtt_interface_def (*‹gtt_interface ?𝒢 = 𝒬 (fst ?𝒢) |∩| 𝒬 (snd ?𝒢)›*) 𝒬_def (*‹𝒬 ?𝒜 = rule_states (rules ?𝒜) |∪| eps_states (eps ?𝒜)›*) intro!: frelcomp_empty_ftrancl_simp (*‹?R |O| ?R = {||} ⟹ ?R|⁺| = ?R›*)) from ftrancl_eps_free_ta_derI[OF this] (*‹ta_der (ftrancl_eps_free_closures (fst (AGTT_comp' 𝒢₁ 𝒢₂))) (term_of_gterm ?t) = ta_der (fst (AGTT_comp' 𝒢₁ 𝒢₂)) (term_of_gterm ?t)›*) show "?thesis" (*goal: ‹agtt_lang (AGTT_comp_eps_free (𝒢₁::('a::type, 'b::type) ta × ('a::type, 'b::type) ta) (𝒢₂::('c::type, 'b::type) ta × ('c::type, 'b::type) ta)) = agtt_lang (AGTT_comp' 𝒢₁ 𝒢₂)›*) by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) AGTT_comp_eps_free_def (*‹AGTT_comp_eps_free ?𝒢₁ ?𝒢₂ = (let (𝒜, ℬ) = AGTT_comp' ?𝒢₁ ?𝒢₂ in (ftrancl_eps_free_closures 𝒜, ℬ))›*) intro!: agtt_lang_derI (*‹⟦⋀t. ta_der (fst ?𝒜) (term_of_gterm t) = ta_der (fst ?ℬ) (term_of_gterm t); ⋀t. ta_der (snd ?𝒜) (term_of_gterm t) = ta_der (snd ?ℬ) (term_of_gterm t)⟧ ⟹ agtt_lang ?𝒜 = agtt_lang ?ℬ›*)) qed lemma agtt_lang_GTT_comp_eps_free_conv: assumes "is_gtt_eps_free 𝒢₁" "is_gtt_eps_free 𝒢₂" shows "agtt_lang (GTT_comp_eps_free 𝒢₁ 𝒢₂) = agtt_lang (GTT_comp' 𝒢₁ 𝒢₂)" proof (-) (*goal: ‹agtt_lang (GTT_comp_eps_free 𝒢₁ 𝒢₂) = agtt_lang (GTT_comp' 𝒢₁ 𝒢₂)›*) have "(eps (fst (GTT_comp' 𝒢₁ 𝒢₂)))|⁺| = eps (fst (GTT_comp' 𝒢₁ 𝒢₂))" "(eps (snd (GTT_comp' 𝒢₁ 𝒢₂)))|⁺| = eps (snd (GTT_comp' 𝒢₁ 𝒢₂))" using assms (*‹is_gtt_eps_free 𝒢₁› ‹is_gtt_eps_free 𝒢₂›*) apply - (*goals: 1. ‹⟦is_gtt_eps_free 𝒢₁; is_gtt_eps_free 𝒢₂⟧ ⟹ (eps (fst (GTT_comp' 𝒢₁ 𝒢₂)))|⁺| = eps (fst (GTT_comp' 𝒢₁ 𝒢₂))› 2. ‹⟦is_gtt_eps_free 𝒢₁; is_gtt_eps_free 𝒢₂⟧ ⟹ (eps (snd (GTT_comp' 𝒢₁ 𝒢₂)))|⁺| = eps (snd (GTT_comp' 𝒢₁ 𝒢₂))› discuss goal 1*) apply ((auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) fmap_states_gtt_def (*‹fmap_states_gtt ?f ≡ map_both (fmap_states_ta ?f)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) Δ⇩ε_fmember (*‹((?p, ?q) |∈| Δ⇩ε ?𝒜 ?ℬ) = (∃t. Term_Context.ground t ∧ ?p |∈| ta_der ?𝒜 t ∧ ?q |∈| ta_der ?ℬ t)›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) GTT_comp_def (*‹GTT_comp ?𝒢₁ ?𝒢₂ = (let Δ = Δ⇩ε (snd ?𝒢₁) (fst ?𝒢₂) in (TA (gtt_rules (fst ?𝒢₁, fst ?𝒢₂)) (eps (fst ?𝒢₁) |∪| eps (fst ?𝒢₂) |∪| Δ), TA (gtt_rules (snd ?𝒢₁, snd ?𝒢₂)) (eps (snd ?𝒢₁) |∪| eps (snd ?𝒢₂) |∪| Δ|¯|)))›*) gtt_interface_def (*‹gtt_interface ?𝒢 = 𝒬 (fst ?𝒢) |∩| 𝒬 (snd ?𝒢)›*) 𝒬_def (*‹𝒬 ?𝒜 = rule_states (rules ?𝒜) |∪| eps_states (eps ?𝒜)›*) dest!: ground_ta_der_statesD (*‹⟦Term_Context.ground ?t; ?c |∈| ta_der ?𝒜 ?t⟧ ⟹ ?c |∈| 𝒬 ?𝒜›*) intro!: frelcomp_empty_ftrancl_simp (*‹?R |O| ?R = {||} ⟹ ?R|⁺| = ?R›*))[1]) (*discuss goal 2*) apply ((auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) fmap_states_gtt_def (*‹fmap_states_gtt ?f ≡ map_both (fmap_states_ta ?f)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) Δ⇩ε_fmember (*‹((?p, ?q) |∈| Δ⇩ε ?𝒜 ?ℬ) = (∃t. Term_Context.ground t ∧ ?p |∈| ta_der ?𝒜 t ∧ ?q |∈| ta_der ?ℬ t)›*) case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) GTT_comp_def (*‹GTT_comp ?𝒢₁ ?𝒢₂ = (let Δ = Δ⇩ε (snd ?𝒢₁) (fst ?𝒢₂) in (TA (gtt_rules (fst ?𝒢₁, fst ?𝒢₂)) (eps (fst ?𝒢₁) |∪| eps (fst ?𝒢₂) |∪| Δ), TA (gtt_rules (snd ?𝒢₁, snd ?𝒢₂)) (eps (snd ?𝒢₁) |∪| eps (snd ?𝒢₂) |∪| Δ|¯|)))›*) gtt_interface_def (*‹gtt_interface ?𝒢 = 𝒬 (fst ?𝒢) |∩| 𝒬 (snd ?𝒢)›*) 𝒬_def (*‹𝒬 ?𝒜 = rule_states (rules ?𝒜) |∪| eps_states (eps ?𝒜)›*) dest!: ground_ta_der_statesD (*‹⟦Term_Context.ground ?t; ?c |∈| ta_der ?𝒜 ?t⟧ ⟹ ?c |∈| 𝒬 ?𝒜›*) intro!: frelcomp_empty_ftrancl_simp (*‹?R |O| ?R = {||} ⟹ ?R|⁺| = ?R›*))[1]) (*proven 2 subgoals*) . from ftrancl_eps_free_ta_derI[OF this ( 1 )] (*‹ta_der (ftrancl_eps_free_closures (fst (GTT_comp' 𝒢₁ 𝒢₂))) (term_of_gterm ?t) = ta_der (fst (GTT_comp' 𝒢₁ 𝒢₂)) (term_of_gterm ?t)›*) ftrancl_eps_free_ta_derI[OF this ( 2 )] (*‹ta_der (ftrancl_eps_free_closures (snd (GTT_comp' 𝒢₁ 𝒢₂))) (term_of_gterm ?t) = ta_der (snd (GTT_comp' 𝒢₁ 𝒢₂)) (term_of_gterm ?t)›*) show "?thesis" (*goal: ‹agtt_lang (GTT_comp_eps_free 𝒢₁ 𝒢₂) = agtt_lang (GTT_comp' 𝒢₁ 𝒢₂)›*) by (auto simp: case_prod_beta (*‹(case ?p of (x, xa) ⇒ ?f x xa) = ?f (fst ?p) (snd ?p)›*) GTT_comp_eps_free_def (*‹GTT_comp_eps_free ?𝒢₁ ?𝒢₂ = (let (𝒜, ℬ) = GTT_comp' ?𝒢₁ ?𝒢₂ in (ftrancl_eps_free_closures 𝒜, ftrancl_eps_free_closures ℬ))›*) intro!: agtt_lang_derI (*‹⟦⋀t. ta_der (fst ?𝒜) (term_of_gterm t) = ta_der (fst ?ℬ) (term_of_gterm t); ⋀t. ta_der (snd ?𝒜) (term_of_gterm t) = ta_der (snd ?ℬ) (term_of_gterm t)⟧ ⟹ agtt_lang ?𝒜 = agtt_lang ?ℬ›*)) qed fun gtt_of_gtt_rel_impl :: "('f × nat) fset ⇒ ('f :: linorder, 'v) fin_trs list ⇒ ftrs gtt_rel ⇒ (nat, 'f) gtt option" where "gtt_of_gtt_rel_impl ℱ Rs (ARoot is) = liftO1 (λR. relabel_gtt (root_step R ℱ)) (is_to_trs' Rs is)" | "gtt_of_gtt_rel_impl ℱ Rs (GInv g) = liftO1 prod.swap (gtt_of_gtt_rel_impl ℱ Rs g)" | "gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = liftO2 (λg1 g2. relabel_gtt (AGTT_union' g1 g2)) (gtt_of_gtt_rel_impl ℱ Rs g1) (gtt_of_gtt_rel_impl ℱ Rs g2)" | "gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = liftO1 (relabel_gtt ∘ AGTT_trancl_eps_free) (gtt_of_gtt_rel_impl ℱ Rs g)" | "gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = liftO1 GTT_trancl_eps_free (gtt_of_gtt_rel_impl ℱ Rs g)" | "gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = liftO2 (λg1 g2. relabel_gtt (AGTT_comp_eps_free g1 g2)) (gtt_of_gtt_rel_impl ℱ Rs g1) (gtt_of_gtt_rel_impl ℱ Rs g2)" | "gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = liftO2 (λg1 g2. relabel_gtt (GTT_comp_eps_free g1 g2)) (gtt_of_gtt_rel_impl ℱ Rs g1) (gtt_of_gtt_rel_impl ℱ Rs g2)" lemma gtt_of_gtt_rel_impl_is_gtt_eps_free: "gtt_of_gtt_rel_impl ℱ Rs g = Some g' ⟹ is_gtt_eps_free g'" proof (induct g arbitrary: g') (*goals: 1. ‹⋀x g'. gtt_of_gtt_rel_impl ℱ Rs (ARoot x) = Some g' ⟹ is_gtt_eps_free g'› 2. ‹⋀g g'. ⟦⋀g'. gtt_of_gtt_rel_impl ℱ Rs g = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (GInv g) = Some g'⟧ ⟹ is_gtt_eps_free g'› 3. ‹⋀g1 g2 g'. ⟦⋀g'. gtt_of_gtt_rel_impl ℱ Rs g1 = Some g' ⟹ is_gtt_eps_free g'; ⋀g'. gtt_of_gtt_rel_impl ℱ Rs g2 = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = Some g'⟧ ⟹ is_gtt_eps_free g'› 4. ‹⋀g g'. ⟦⋀g'. gtt_of_gtt_rel_impl ℱ Rs g = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'⟧ ⟹ is_gtt_eps_free g'› 5. ‹⋀g g'. ⟦⋀g'. gtt_of_gtt_rel_impl ℱ Rs g = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'⟧ ⟹ is_gtt_eps_free g'› 6. ‹⋀g1 g2 g'. ⟦⋀g'. gtt_of_gtt_rel_impl ℱ Rs g1 = Some g' ⟹ is_gtt_eps_free g'; ⋀g'. gtt_of_gtt_rel_impl ℱ Rs g2 = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'⟧ ⟹ is_gtt_eps_free g'› 7. ‹⋀g1 g2 g'. ⟦⋀g'. gtt_of_gtt_rel_impl ℱ Rs g1 = Some g' ⟹ is_gtt_eps_free g'; ⋀g'. gtt_of_gtt_rel_impl ℱ Rs g2 = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'⟧ ⟹ is_gtt_eps_free g'›*) case (AUnion g1 g2) (*‹gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) (g1::ftrs gtt_rel) = Some (?g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) ⟹ is_gtt_eps_free ?g'› ‹gtt_of_gtt_rel_impl ℱ Rs g2 = Some ?g' ⟹ is_gtt_eps_free ?g'› ‹gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = Some g'›*) then show "?case" (*goal: ‹is_gtt_eps_free (g'::(fvar, 'a) ta × (fvar, 'a) ta)›*) by (auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) AGTT_union_def (*‹AGTT_union ?𝒢₁ ?𝒢₂ ≡ (ta_union (fst ?𝒢₁) (fst ?𝒢₂), ta_union (snd ?𝒢₁) (snd ?𝒢₂))›*) fmap_states_gtt_def (*‹fmap_states_gtt ?f ≡ map_both (fmap_states_ta ?f)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) relabel_gtt_def (*‹relabel_gtt ?G = fmap_states_gtt (map_fset_to_nat (gtt_states ?G)) ?G›*)) qed (auto simp: eps_free_const (*‹is_gtt_eps_free (?𝒜::(?'a::type, ?'b::type) ta, ?ℬ::(?'c::type, ?'d::type) ta) ⟹ is_gtt_eps_free (?ℬ, ?𝒜)› ‹is_gtt_eps_free (root_step (?R::((?'a::type, ?'b::type) Term.term × (?'a::type, ?'b::type) Term.term) fset) (?ℱ::(?'a::type × fvar) fset))› ‹is_gtt_eps_free (?𝒢::(?'a::type, ?'b::type) ta × (?'a::type, ?'b::type) ta) ⟹ is_gtt_eps_free (AGTT_trancl_eps_free ?𝒢)› ‹is_gtt_eps_free (?𝒢::(?'a::type, ?'b::type) ta × (?'a::type, ?'b::type) ta) ⟹ is_gtt_eps_free (GTT_trancl_eps_free ?𝒢)› ‹is_gtt_eps_free (?𝒢₂::(?'a::type, ?'b::type) ta × (?'a::type, ?'b::type) ta) ⟹ is_gtt_eps_free (AGTT_comp_eps_free (?𝒢₁::(?'c::type, ?'b::type) ta × (?'c::type, ?'b::type) ta) ?𝒢₂)› ‹is_gtt_eps_free (GTT_comp_eps_free (?𝒢₁::(?'a::type, ?'c::type) ta × (?'a::type, ?'c::type) ta) (?𝒢₂::(?'b::type, ?'c::type) ta × (?'b::type, ?'c::type) ta))›*)) (*solves the remaining goals: 1. ‹⋀(x::ftrs list) g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (ARoot x) = Some g' ⟹ is_gtt_eps_free g'› 2. ‹⋀(g::ftrs gtt_rel) g'::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (GInv g) = Some g'⟧ ⟹ is_gtt_eps_free g'› 3. ‹⋀(g::ftrs gtt_rel) g'::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'⟧ ⟹ is_gtt_eps_free g'› 4. ‹⋀(g::ftrs gtt_rel) g'::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'⟧ ⟹ is_gtt_eps_free g'› 5. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) g'::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 = Some g' ⟹ is_gtt_eps_free g'; ⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl ℱ Rs g2 = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'⟧ ⟹ is_gtt_eps_free g'› 6. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) g'::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 = Some g' ⟹ is_gtt_eps_free g'; ⋀g'::(fvar, 'a) ta × (fvar, 'a) ta. gtt_of_gtt_rel_impl ℱ Rs g2 = Some g' ⟹ is_gtt_eps_free g'; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'⟧ ⟹ is_gtt_eps_free g'›*) lemma gtt_of_gtt_rel_impl_gtt_of_gtt_rel: "gtt_of_gtt_rel_impl ℱ Rs g ≠ None ⟷ gtt_of_gtt_rel ℱ Rs g ≠ None" (is "?Ls ⟷ ?Rs") proof (-) (*goal: ‹(gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None)›*) have "?Ls ⟹ ?Rs" apply (induct g) (*goals: 1. ‹⋀x. gtt_of_gtt_rel_impl ℱ Rs (ARoot x) ≠ None ⟹ gtt_of_gtt_rel ℱ Rs (ARoot x) ≠ None› 2. ‹⋀g. ⟦gtt_of_gtt_rel_impl ℱ Rs g ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g ≠ None; gtt_of_gtt_rel_impl ℱ Rs (GInv g) ≠ None⟧ ⟹ gtt_of_gtt_rel ℱ Rs (GInv g) ≠ None› 3. ‹⋀g1 g2. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g1 ≠ None; gtt_of_gtt_rel_impl ℱ Rs g2 ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g2 ≠ None; gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) ≠ None⟧ ⟹ gtt_of_gtt_rel ℱ Rs (AUnion g1 g2) ≠ None› 4. ‹⋀g. ⟦gtt_of_gtt_rel_impl ℱ Rs g ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g ≠ None; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) ≠ None⟧ ⟹ gtt_of_gtt_rel ℱ Rs (ATrancl g) ≠ None› 5. ‹⋀g. ⟦gtt_of_gtt_rel_impl ℱ Rs g ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g ≠ None; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) ≠ None⟧ ⟹ gtt_of_gtt_rel ℱ Rs (GTrancl g) ≠ None› 6. ‹⋀g1 g2. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g1 ≠ None; gtt_of_gtt_rel_impl ℱ Rs g2 ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g2 ≠ None; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) ≠ None⟧ ⟹ gtt_of_gtt_rel ℱ Rs (AComp g1 g2) ≠ None› 7. ‹⋀g1 g2. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g1 ≠ None; gtt_of_gtt_rel_impl ℱ Rs g2 ≠ None ⟹ gtt_of_gtt_rel ℱ Rs g2 ≠ None; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) ≠ None⟧ ⟹ gtt_of_gtt_rel ℱ Rs (GComp g1 g2) ≠ None› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . moreover have "?Rs ⟹ ?Ls" apply (induct g) (*goals: 1. ‹⋀x::ftrs list. gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (ARoot x) ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs (ARoot x) ≠ None› 2. ‹⋀g::ftrs gtt_rel. ⟦gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g ≠ None; gtt_of_gtt_rel ℱ Rs (GInv g) ≠ None⟧ ⟹ gtt_of_gtt_rel_impl ℱ Rs (GInv g) ≠ None› 3. ‹⋀(g1::ftrs gtt_rel) g2::ftrs gtt_rel. ⟦gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g1 ≠ None; gtt_of_gtt_rel ℱ Rs g2 ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g2 ≠ None; gtt_of_gtt_rel ℱ Rs (AUnion g1 g2) ≠ None⟧ ⟹ gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) ≠ None› 4. ‹⋀g::ftrs gtt_rel. ⟦gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g ≠ None; gtt_of_gtt_rel ℱ Rs (ATrancl g) ≠ None⟧ ⟹ gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) ≠ None› 5. ‹⋀g::ftrs gtt_rel. ⟦gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g ≠ None; gtt_of_gtt_rel ℱ Rs (GTrancl g) ≠ None⟧ ⟹ gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) ≠ None› 6. ‹⋀(g1::ftrs gtt_rel) g2::ftrs gtt_rel. ⟦gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g1 ≠ None; gtt_of_gtt_rel ℱ Rs g2 ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g2 ≠ None; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) ≠ None⟧ ⟹ gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) ≠ None› 7. ‹⋀(g1::ftrs gtt_rel) g2::ftrs gtt_rel. ⟦gtt_of_gtt_rel (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g1 ≠ None; gtt_of_gtt_rel ℱ Rs g2 ≠ None ⟹ gtt_of_gtt_rel_impl ℱ Rs g2 ≠ None; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) ≠ None⟧ ⟹ gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) ≠ None› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*discuss goal 6*) apply ((auto)[1]) (*discuss goal 7*) apply ((auto)[1]) (*proven 7 subgoals*) . ultimately show "?thesis" (*goal: ‹(gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None)›*) by blast qed lemma gtt_of_gtt_rel_impl_sound: "gtt_of_gtt_rel_impl ℱ Rs g = Some g' ⟹ gtt_of_gtt_rel ℱ Rs g = Some g'' ⟹ agtt_lang g' = agtt_lang g''" proof (induct g arbitrary: g' g'') (*goals: 1. ‹⋀(x::ftrs list) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (ARoot x) = Some g'; gtt_of_gtt_rel ℱ Rs (ARoot x) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 2. ‹⋀(g::ftrs gtt_rel) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GInv g) = Some g'; gtt_of_gtt_rel ℱ Rs (GInv g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 3. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AUnion g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 4. ‹⋀(g::ftrs gtt_rel) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (ATrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 5. ‹⋀(g::ftrs gtt_rel) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (GTrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 6. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 7. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a) ta × (fvar, 'a) ta) g''::(fvar, 'a) ta × (fvar, 'a) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (ARoot x) (*‹gtt_of_gtt_rel_impl ℱ Rs (ARoot x) = Some g'› ‹gtt_of_gtt_rel ℱ Rs (ARoot x) = Some g''›*) then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) by (simp add: agtt_lang_root_step_conv (*‹agtt_lang (root_step ?R ?ℱ) = agtt_lang (agtt_grrstep ?R ?ℱ)›*)) next (*goals: 1. ‹⋀g g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GInv g) = Some g'; gtt_of_gtt_rel ℱ Rs (GInv g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 2. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AUnion g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 3. ‹⋀g g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (ATrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 4. ‹⋀g g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (GTrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 5. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 6. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (GInv g) (*‹⟦gtt_of_gtt_rel_impl ℱ Rs g = Some ?g'; gtt_of_gtt_rel ℱ Rs g = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (GInv (g::ftrs gtt_rel)) = Some (g'::(fvar, 'a) ta × (fvar, 'a) ta)› ‹gtt_of_gtt_rel ℱ Rs (GInv g) = Some g''›*) then have "agtt_lang (prod.swap g') = agtt_lang (prod.swap g'')" by auto then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) by (metis converse_agtt_lang (*‹(agtt_lang ?𝒢)¯ = agtt_lang (prod.swap ?𝒢)›*) converse_converse (*‹(?r¯)¯ = ?r›*)) next (*goals: 1. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AUnion g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 2. ‹⋀(g::ftrs gtt_rel) (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (ATrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 3. ‹⋀(g::ftrs gtt_rel) (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (GTrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 4. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 5. ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (AUnion g1 g2) (*‹⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some ?g'; gtt_of_gtt_rel ℱ Rs g1 = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some ?g'; gtt_of_gtt_rel ℱ Rs g2 = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹gtt_of_gtt_rel_impl ℱ Rs (AUnion g1 g2) = Some g'› ‹gtt_of_gtt_rel ℱ Rs (AUnion g1 g2) = Some g''›*) then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) apply simp (*goal: ‹agtt_lang g' = agtt_lang g''›*) by (metis AGTT_union'_sound (*‹agtt_lang (AGTT_union' (?𝒢₁::(?'q, ?'f) ta × (?'q, ?'f) ta) (?𝒢₂::(?'q, ?'f) ta × (?'q, ?'f) ta)) = agtt_lang ?𝒢₁ ∪ agtt_lang ?𝒢₂›*) option.sel (*‹the (Some (?x2.0::?'a)) = ?x2.0›*)) next (*goals: 1. ‹⋀g g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (ATrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 2. ‹⋀g g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (GTrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 3. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 4. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (ATrancl g) (*‹⟦gtt_of_gtt_rel_impl ℱ Rs g = Some ?g'; gtt_of_gtt_rel ℱ Rs g = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹gtt_of_gtt_rel_impl ℱ Rs (ATrancl g) = Some g'› ‹gtt_of_gtt_rel ℱ Rs (ATrancl g) = Some g''›*) then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) using agtt_lang_AGTT_trancl_eps_free_conv[OF gtt_of_gtt_rel_impl_is_gtt_eps_free, of ℱ Rs g] (*‹gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (g::ftrs gtt_rel) = Some (?𝒢::(fvar, 'a) ta × (fvar, 'a) ta) ⟹ agtt_lang (AGTT_trancl_eps_free ?𝒢) = agtt_lang (AGTT_trancl ?𝒢)›*) apply simp (*goal: ‹agtt_lang (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) = agtt_lang (g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta)›*) by (metis AGTT_trancl_sound (*‹agtt_lang (AGTT_trancl ?𝒢) = (agtt_lang ?𝒢)⁺›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) next (*goals: 1. ‹⋀g g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g = Some g'; gtt_of_gtt_rel ℱ Rs g = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'; gtt_of_gtt_rel ℱ Rs (GTrancl g) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 2. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 3. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (GTrancl g) (*‹⟦gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (g::ftrs gtt_rel) = Some (?g'::(fvar, 'a) ta × (fvar, 'a) ta); gtt_of_gtt_rel ℱ Rs g = Some (?g''::(fvar, 'a) ta × (fvar, 'a) ta)⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹gtt_of_gtt_rel_impl ℱ Rs (GTrancl g) = Some g'› ‹gtt_of_gtt_rel ℱ Rs (GTrancl g) = Some g''›*) then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) using agtt_lang_GTT_trancl_eps_free_conv[OF gtt_of_gtt_rel_impl_is_gtt_eps_free, of ℱ Rs g] (*‹gtt_of_gtt_rel_impl ℱ Rs g = Some ?𝒢 ⟹ agtt_lang (GTT_trancl_eps_free ?𝒢) = agtt_lang (GTT_trancl ?𝒢)›*) apply simp (*goal: ‹agtt_lang g' = agtt_lang g''›*) by (metis GTT_trancl_alang (*‹agtt_lang (GTT_trancl ?G) = gtrancl_rel UNIV (agtt_lang ?G)›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) next (*goals: 1. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''› 2. ‹⋀g1 g2 g' g''. ⟦⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀g' g''. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (AComp g1 g2) (*‹⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some ?g'; gtt_of_gtt_rel ℱ Rs g1 = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some ?g'; gtt_of_gtt_rel ℱ Rs g2 = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹gtt_of_gtt_rel_impl ℱ Rs (AComp g1 g2) = Some g'› ‹gtt_of_gtt_rel ℱ Rs (AComp g1 g2) = Some g''›*) then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) using agtt_lang_AGTT_comp_eps_free_conv[OF gtt_of_gtt_rel_impl_is_gtt_eps_free, of ℱ Rs g "the (gtt_of_gtt_rel_impl ℱ Rs g1)" "the (gtt_of_gtt_rel_impl ℱ Rs g2)"] (*‹⟦gtt_of_gtt_rel_impl ℱ Rs g = Some (the (gtt_of_gtt_rel_impl ℱ Rs g1)); is_gtt_eps_free (the (gtt_of_gtt_rel_impl ℱ Rs g2))⟧ ⟹ agtt_lang (AGTT_comp_eps_free (the (gtt_of_gtt_rel_impl ℱ Rs g1)) (the (gtt_of_gtt_rel_impl ℱ Rs g2))) = agtt_lang (AGTT_comp' (the (gtt_of_gtt_rel_impl ℱ Rs g1)) (the (gtt_of_gtt_rel_impl ℱ Rs g2)))›*) apply simp (*goal: ‹agtt_lang g' = agtt_lang g''›*) by (metis AGTT_comp'_sound (*‹agtt_lang (AGTT_comp' ?𝒢₁ ?𝒢₂) = agtt_lang ?𝒢₁ O agtt_lang ?𝒢₂›*) agtt_lang_AGTT_comp_eps_free_conv (*‹⟦is_gtt_eps_free ?𝒢₁; is_gtt_eps_free ?𝒢₂⟧ ⟹ agtt_lang (AGTT_comp_eps_free ?𝒢₁ ?𝒢₂) = agtt_lang (AGTT_comp' ?𝒢₁ ?𝒢₂)›*) gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) option.sel (*‹the (Some ?x2.0) = ?x2.0›*)) next (*goal: ‹⋀(g1::ftrs gtt_rel) (g2::ftrs gtt_rel) (g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g1 = Some g'; gtt_of_gtt_rel ℱ Rs g1 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; ⋀(g'::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta) g''::(fvar, 'a::linorder) ta × (fvar, 'a::linorder) ta. ⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some g'; gtt_of_gtt_rel ℱ Rs g2 = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''; gtt_of_gtt_rel_impl ℱ Rs (GComp g1 g2) = Some g'; gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''⟧ ⟹ agtt_lang g' = agtt_lang g''›*) case (GComp g1 g2) (*‹⟦gtt_of_gtt_rel_impl ℱ Rs g1 = Some ?g'; gtt_of_gtt_rel ℱ Rs g1 = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹⟦gtt_of_gtt_rel_impl ℱ Rs g2 = Some ?g'; gtt_of_gtt_rel ℱ Rs g2 = Some ?g''⟧ ⟹ agtt_lang ?g' = agtt_lang ?g''› ‹gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (GComp (g1::ftrs gtt_rel) (g2::ftrs gtt_rel)) = Some (g'::(fvar, 'a) ta × (fvar, 'a) ta)› ‹gtt_of_gtt_rel ℱ Rs (GComp g1 g2) = Some g''›*) then show "?case" (*goal: ‹agtt_lang g' = agtt_lang g''›*) using agtt_lang_GTT_comp_eps_free_conv[OF gtt_of_gtt_rel_impl_is_gtt_eps_free, of ℱ Rs g "the (gtt_of_gtt_rel_impl ℱ Rs g1)" "the (gtt_of_gtt_rel_impl ℱ Rs g2)"] (*‹⟦gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) (g::ftrs gtt_rel) = Some (the (gtt_of_gtt_rel_impl ℱ Rs (g1::ftrs gtt_rel))); is_gtt_eps_free (the (gtt_of_gtt_rel_impl ℱ Rs (g2::ftrs gtt_rel)))⟧ ⟹ agtt_lang (GTT_comp_eps_free (the (gtt_of_gtt_rel_impl ℱ Rs g1)) (the (gtt_of_gtt_rel_impl ℱ Rs g2))) = agtt_lang (GTT_comp' (the (gtt_of_gtt_rel_impl ℱ Rs g1)) (the (gtt_of_gtt_rel_impl ℱ Rs g2)))›*) apply simp (*goal: ‹agtt_lang g' = agtt_lang g''›*) by (metis agtt_lang_GTT_comp_eps_free_conv (*‹⟦is_gtt_eps_free (?𝒢₁::(?'a, ?'b) ta × (?'a, ?'b) ta); is_gtt_eps_free (?𝒢₂::(?'c, ?'b) ta × (?'c, ?'b) ta)⟧ ⟹ agtt_lang (GTT_comp_eps_free ?𝒢₁ ?𝒢₂) = agtt_lang (GTT_comp' ?𝒢₁ ?𝒢₂)›*) gtt_comp'_alang (*‹agtt_lang (GTT_comp' (?𝒢₁::(?'b, ?'a) ta × (?'b, ?'a) ta) (?𝒢₂::(?'c, ?'a) ta × (?'c, ?'a) ta)) = gcomp_rel UNIV (agtt_lang ?𝒢₁) (agtt_lang ?𝒢₂)›*) gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl (?ℱ::(?'a × fvar) fset) (?Rs::((?'a, ?'b) Term.term × (?'a, ?'b) Term.term) fset list) (?g::ftrs gtt_rel) = Some (?g'::(fvar, ?'a) ta × (fvar, ?'a) ta) ⟹ is_gtt_eps_free ?g'›*) option.sel (*‹the (Some (?x2.0::?'a)) = ?x2.0›*)) qed (* eps free closure constructions *) lemma ℒ_eps_free_nhole_ctxt_closure_reg: assumes "is_ta_eps_free (ta 𝒜)" shows "ℒ (ftrancl_eps_free_reg (nhole_ctxt_closure_reg ℱ 𝒜)) = ℒ (nhole_ctxt_closure_reg ℱ 𝒜)" proof (-) (*goal: ‹ℒ (ftrancl_eps_free_reg (nhole_ctxt_closure_reg (ℱ::('b::type × fvar) fset) (𝒜::('a::type, 'b::type) reg))) = ℒ (nhole_ctxt_closure_reg ℱ 𝒜)›*) have "eps (ta (nhole_ctxt_closure_reg ℱ 𝒜)) |O| eps (ta (nhole_ctxt_closure_reg ℱ 𝒜)) = {||}" using assms (*‹is_ta_eps_free (ta 𝒜)›*) by (auto simp: nhole_ctxt_closure_reg_def (*‹nhole_ctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = fmap_states_reg Inl (reg_Restr_Q⇩f ?𝒜) in gen_nhole_ctxt_closure_reg ?ℱ ℬ (Inr cl_state) (Inr tr_state) (Inr fin_state))›*) gen_nhole_ctxt_closure_reg_def (*‹gen_nhole_ctxt_closure_reg ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = Reg {|?q⇩f|} (gen_nhole_ctxt_closure_automaton (fin ?𝒜) ?ℱ (ta ?𝒜) ?q⇩c ?q⇩i ?q⇩f)›*) gen_nhole_ctxt_closure_automaton_def (*‹gen_nhole_ctxt_closure_automaton ?Q ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = ta_union ?𝒜 (reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f)›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) reflcl_over_nhole_ctxt_ta_def (*‹reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ TA (reflcl_rules ?ℱ ?q⇩c |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩i ?q⇩f |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩f ?q⇩f) ((λp. (p, ?q⇩i)) |`| ?Q)›*) fmap_states_reg_def (*‹fmap_states_reg ?f ?R = Reg (?f |`| fin ?R) (fmap_states_ta ?f (ta ?R))›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) reg_Restr_Q⇩f_def (*‹reg_Restr_Q⇩f ?R = Reg (fin ?R |∩| 𝒬⇩r ?R) (ta ?R)›*)) from frelcomp_empty_ftrancl_simp[OF this] (*‹(eps (ta (nhole_ctxt_closure_reg ℱ 𝒜)))|⁺| = eps (ta (nhole_ctxt_closure_reg ℱ 𝒜))›*) show "?thesis" (*goal: ‹ℒ (ftrancl_eps_free_reg (nhole_ctxt_closure_reg (ℱ::('b::type × fvar) fset) (𝒜::('a::type, 'b::type) reg))) = ℒ (nhole_ctxt_closure_reg ℱ 𝒜)›*) apply (intro ℒ_ftrancl_eps_free_closuresI (*‹(eps (ta ?𝒜))|⁺| = eps (ta ?𝒜) ⟹ ℒ (ftrancl_eps_free_reg ?𝒜) = ℒ ?𝒜›*)) (*goal: ‹ℒ (ftrancl_eps_free_reg (nhole_ctxt_closure_reg ℱ 𝒜)) = ℒ (nhole_ctxt_closure_reg ℱ 𝒜)›*) by simp qed lemma ℒ_eps_free_ctxt_closure_reg: assumes "is_ta_eps_free (ta 𝒜)" shows "ℒ (ftrancl_eps_free_reg (ctxt_closure_reg ℱ 𝒜)) = ℒ (ctxt_closure_reg ℱ 𝒜)" proof (-) (*goal: ‹ℒ (ftrancl_eps_free_reg (ctxt_closure_reg ℱ 𝒜)) = ℒ (ctxt_closure_reg ℱ 𝒜)›*) have "eps (ta (ctxt_closure_reg ℱ 𝒜)) |O| eps (ta (ctxt_closure_reg ℱ 𝒜)) = {||}" using assms (*‹is_ta_eps_free (ta (𝒜::('a::type, 'b::type) reg))›*) by (auto simp: ctxt_closure_reg_def (*‹ctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = fmap_states_reg Inl (reg_Restr_Q⇩f ?𝒜) in gen_ctxt_closure_reg ?ℱ ℬ (Inr False) (Inr True))›*) gen_ctxt_closure_reg_def (*‹gen_ctxt_closure_reg ?ℱ ?𝒜 ?q⇩c ?q⇩f = Reg {|?q⇩f|} (gen_ctxt_closure_automaton (fin ?𝒜) ?ℱ (ta ?𝒜) ?q⇩c ?q⇩f)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) gen_ctxt_closure_automaton_def (*‹gen_ctxt_closure_automaton ?Q ?ℱ ?𝒜 ?q⇩c ?q⇩f = ta_union ?𝒜 (reflcl_over_single_ta ?Q ?ℱ ?q⇩c ?q⇩f)›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) reflcl_over_single_ta_def (*‹reflcl_over_single_ta ?Q ?ℱ ?q⇩c ?q⇩f ≡ TA (reflcl_rules ?ℱ ?q⇩c |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩f ?q⇩f) ((λp. (p, ?q⇩f)) |`| ?Q)›*) fmap_states_reg_def (*‹fmap_states_reg ?f ?R = Reg (?f |`| fin ?R) (fmap_states_ta ?f (ta ?R))›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) reg_Restr_Q⇩f_def (*‹reg_Restr_Q⇩f ?R = Reg (fin ?R |∩| 𝒬⇩r ?R) (ta ?R)›*)) from frelcomp_empty_ftrancl_simp[OF this] (*‹(eps (ta (ctxt_closure_reg ℱ 𝒜)))|⁺| = eps (ta (ctxt_closure_reg ℱ 𝒜))›*) show "?thesis" (*goal: ‹ℒ (ftrancl_eps_free_reg (ctxt_closure_reg ℱ 𝒜)) = ℒ (ctxt_closure_reg ℱ 𝒜)›*) apply (intro ℒ_ftrancl_eps_free_closuresI (*‹(eps (ta ?𝒜))|⁺| = eps (ta ?𝒜) ⟹ ℒ (ftrancl_eps_free_reg ?𝒜) = ℒ ?𝒜›*)) (*goal: ‹ℒ (ftrancl_eps_free_reg (ctxt_closure_reg ℱ 𝒜)) = ℒ (ctxt_closure_reg ℱ 𝒜)›*) by simp qed lemma ℒ_eps_free_parallel_closure_reg: assumes "is_ta_eps_free (ta 𝒜)" shows "ℒ (ftrancl_eps_free_reg (parallel_closure_reg ℱ 𝒜)) = ℒ (parallel_closure_reg ℱ 𝒜)" proof (-) (*goal: ‹ℒ (ftrancl_eps_free_reg (parallel_closure_reg ℱ 𝒜)) = ℒ (parallel_closure_reg ℱ 𝒜)›*) have "eps (ta (parallel_closure_reg ℱ 𝒜)) |O| eps (ta (parallel_closure_reg ℱ 𝒜)) = {||}" using assms (*‹is_ta_eps_free (ta 𝒜)›*) by (auto simp: parallel_closure_reg_def (*‹parallel_closure_reg ?ℱ ?𝒜 = (let ℬ = fmap_states_reg Some ?𝒜 in Reg {|None|} (gen_parallel_closure_automaton (fin ℬ) ?ℱ (ta ℬ) None))›*) gen_parallel_closure_automaton_def (*‹gen_parallel_closure_automaton ?Q ?ℱ ?𝒜 ?q = ta_union ?𝒜 (refl_over_states_ta ?Q ?ℱ ?𝒜 ?q)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) refl_over_states_ta_def (*‹refl_over_states_ta ?Q ?ℱ ?𝒜 ?q = TA (reflcl_rules ?ℱ ?q) ((λp. (p, ?q)) |`| (?Q |∩| 𝒬 ?𝒜))›*) fmap_states_reg_def (*‹fmap_states_reg ?f ?R = Reg (?f |`| fin ?R) (fmap_states_ta ?f (ta ?R))›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) reg_Restr_Q⇩f_def (*‹reg_Restr_Q⇩f ?R = Reg (fin ?R |∩| 𝒬⇩r ?R) (ta ?R)›*)) from frelcomp_empty_ftrancl_simp[OF this] (*‹(eps (ta (parallel_closure_reg ℱ 𝒜)))|⁺| = eps (ta (parallel_closure_reg ℱ 𝒜))›*) show "?thesis" (*goal: ‹ℒ (ftrancl_eps_free_reg (parallel_closure_reg ℱ 𝒜)) = ℒ (parallel_closure_reg ℱ 𝒜)›*) apply (intro ℒ_ftrancl_eps_free_closuresI (*‹(eps (ta ?𝒜))|⁺| = eps (ta ?𝒜) ⟹ ℒ (ftrancl_eps_free_reg ?𝒜) = ℒ ?𝒜›*)) (*goal: ‹ℒ (ftrancl_eps_free_reg (parallel_closure_reg ℱ 𝒜)) = ℒ (parallel_closure_reg ℱ 𝒜)›*) by simp qed abbreviation "eps_free_reg' S R ≡ Reg (fin R) (eps_free_automata S (ta R))" definition "eps_free_mctxt_closure_reg ℱ 𝒜 = (let ℬ = mctxt_closure_reg ℱ 𝒜 in eps_free_reg' ((λ p. (fst p, Inr cl_state)) |`| (eps (ta ℬ)) |∪| eps (ta ℬ)) ℬ)" definition "eps_free_nhole_mctxt_reflcl_reg ℱ 𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ℱ 𝒜 in eps_free_reg' ((λ p. (fst p, Inl (Inr cl_state))) |`| (eps (ta ℬ)) |∪| eps (ta ℬ)) ℬ)" definition "eps_free_nhole_mctxt_closure_reg ℱ 𝒜 = (let ℬ = nhole_mctxt_closure_reg ℱ 𝒜 in eps_free_reg' ((λ p. (fst p, (Inr cl_state))) |`| (eps (ta ℬ)) |∪| eps (ta ℬ)) ℬ)" lemma ℒ_eps_free_reg'I: "(eps (ta 𝒜))|⁺| = S ⟹ ℒ (eps_free_reg' S 𝒜) = ℒ 𝒜" by (auto simp: ℒ_def (*‹ℒ ?𝒜 = gta_lang (fin ?𝒜) (ta ?𝒜)›*) gta_lang_def (*‹gta_lang ?Q ?𝒜 = {t. ?Q |∩| gta_der ?𝒜 t ≠ {||}}›*) gta_der_def (*‹gta_der ?𝒜 ?t = ta_der ?𝒜 (term_of_gterm ?t)›*) ta_res_eps_free (*‹ta_der (eps_free ?𝒜) (term_of_gterm ?t) = ta_der ?𝒜 (term_of_gterm ?t)›*) simp flip: eps_free (*‹eps_free ?𝒜 = eps_free_automata ((eps ?𝒜)|⁺|) ?𝒜›*)) lemma ℒ_eps_free_mctxt_closure_reg: assumes "is_ta_eps_free (ta 𝒜)" shows "ℒ (eps_free_mctxt_closure_reg ℱ 𝒜) = ℒ (mctxt_closure_reg ℱ 𝒜)" using assms (*‹is_ta_eps_free (ta (𝒜::('a, 'b) reg))›*) unfolding eps_free_mctxt_closure_reg_def Let_def (*goal: ‹ℒ (eps_free_reg' ((λp::('a + cl_states) × ('a + cl_states). (fst p, Inr cl_state)) |`| eps (ta (mctxt_closure_reg (ℱ::('b × fvar) fset) (𝒜::('a, 'b) reg))) |∪| eps (ta (mctxt_closure_reg ℱ 𝒜))) (mctxt_closure_reg ℱ 𝒜)) = ℒ (mctxt_closure_reg ℱ 𝒜)›*) apply (intro ℒ_eps_free_reg'I (*‹(eps (ta ?𝒜))|⁺| = ?S ⟹ ℒ (eps_free_reg' ?S ?𝒜) = ℒ ?𝒜›*)) (*goal: ‹ℒ (eps_free_reg' ((λp::('a + cl_states) × ('a + cl_states). (fst p, Inr cl_state)) |`| eps (ta (mctxt_closure_reg (ℱ::('b × fvar) fset) (𝒜::('a, 'b) reg))) |∪| eps (ta (mctxt_closure_reg ℱ 𝒜))) (mctxt_closure_reg ℱ 𝒜)) = ℒ (mctxt_closure_reg ℱ 𝒜)›*) apply (auto simp: comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) mctxt_closure_reg_def (*‹mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = fmap_states_reg Inl (reg_Restr_Q⇩f ?𝒜) in gen_mctxt_closure_reg ?ℱ ℬ (Inr cl_state) (Inr tr_state) (Inr fin_state))›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) gen_nhole_mctxt_closure_automaton_def (*‹gen_nhole_mctxt_closure_automaton ?Q ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = ta_union ?𝒜 (reflcl_over_nhole_mctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f)›*) reflcl_over_nhole_mctxt_ta_def (*‹reflcl_over_nhole_mctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ add_eps (reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f) {|(?q⇩i, ?q⇩c)|}›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) reflcl_over_nhole_ctxt_ta_def (*‹reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ TA (reflcl_rules ?ℱ ?q⇩c |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩i ?q⇩f |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩f ?q⇩f) ((λp. (p, ?q⇩i)) |`| ?Q)›*) gen_mctxt_closure_reg_def (*‹gen_mctxt_closure_reg ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = Reg {|?q⇩f, ?q⇩i|} (gen_nhole_mctxt_closure_automaton (fin ?𝒜) ?ℱ (ta ?𝒜) ?q⇩c ?q⇩i ?q⇩f)›*) reg_Restr_Q⇩f_def (*‹reg_Restr_Q⇩f ?R = Reg (fin ?R |∩| 𝒬⇩r ?R) (ta ?R)›*) fmap_states_reg_def (*‹fmap_states_reg ?f ?R = Reg (?f |`| fin ?R) (fmap_states_ta ?f (ta ?R))›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) dest: ftranclD (*‹(?x, ?y) |∈| ?R|⁺| ⟹ ∃z. (?x, z) |∈| ?R ∧ (z = ?y ∨ (z, ?y) |∈| ?R|⁺|)›*) ftranclD2 (*‹(?x, ?y) |∈| ?R|⁺| ⟹ ∃z. (?x = z ∨ (?x, z) |∈| ?R|⁺|) ∧ (z, ?y) |∈| ?R›*)) (*goal: ‹is_ta_eps_free (ta 𝒜) ⟹ (eps (ta (mctxt_closure_reg ℱ 𝒜)))|⁺| = (λp. (fst p, Inr cl_state)) |`| eps (ta (mctxt_closure_reg ℱ 𝒜)) |∪| eps (ta (mctxt_closure_reg ℱ 𝒜))›*) by (meson fimageI (*‹?x |∈| ?A ⟹ ?f ?x |∈| ?f |`| ?A›*) finsert_iff (*‹(?a |∈| finsert ?b ?A) = (?a = ?b ∨ ?a |∈| ?A)›*) finterI (*‹⟦?c |∈| ?A; ?c |∈| ?B⟧ ⟹ ?c |∈| ?A |∩| ?B›*) fr_into_trancl (*‹(?a, ?b) |∈| ?r ⟹ (?a, ?b) |∈| ?r|⁺|›*) ftrancl_into_trancl (*‹⟦(?a, ?b) |∈| ?r|⁺|; (?b, ?c) |∈| ?r⟧ ⟹ (?a, ?c) |∈| ?r|⁺|›*)) lemma ℒ_eps_free_nhole_mctxt_reflcl_reg: assumes "is_ta_eps_free (ta 𝒜)" shows "ℒ (eps_free_nhole_mctxt_reflcl_reg ℱ 𝒜) = ℒ (nhole_mctxt_reflcl_reg ℱ 𝒜)" using assms (*‹is_ta_eps_free (ta 𝒜)›*) unfolding eps_free_nhole_mctxt_reflcl_reg_def Let_def (*goal: ‹ℒ (eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜)) |∪| eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜))) (nhole_mctxt_reflcl_reg ℱ 𝒜)) = ℒ (nhole_mctxt_reflcl_reg ℱ 𝒜)›*) apply (intro ℒ_eps_free_reg'I (*‹(eps (ta ?𝒜))|⁺| = ?S ⟹ ℒ (eps_free_reg' ?S ?𝒜) = ℒ ?𝒜›*)) (*goal: ‹ℒ (eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜)) |∪| eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜))) (nhole_mctxt_reflcl_reg ℱ 𝒜)) = ℒ (nhole_mctxt_reflcl_reg ℱ 𝒜)›*) apply (auto simp: comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) nhole_mctxt_reflcl_reg_def (*‹nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = reg_union (nhole_mctxt_closure_reg ?ℱ ?𝒜) (Reg {|fin_clstate|} (refl_ta ?ℱ fin_clstate))›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) nhole_mctxt_closure_reg_def (*‹nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = fmap_states_reg Inl (reg_Restr_Q⇩f ?𝒜) in gen_nhole_mctxt_closure_reg ?ℱ ℬ (Inr cl_state) (Inr tr_state) (Inr fin_state))›*) gen_nhole_mctxt_closure_reg_def (*‹gen_nhole_mctxt_closure_reg ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = Reg {|?q⇩f|} (gen_nhole_mctxt_closure_automaton (fin ?𝒜) ?ℱ (ta ?𝒜) ?q⇩c ?q⇩i ?q⇩f)›*) reg_union_def (*‹reg_union ?R ?L = Reg (Inl |`| (fin ?R |∩| 𝒬⇩r ?R) |∪| Inr |`| (fin ?L |∩| 𝒬⇩r ?L)) (ta_union (fmap_states_ta Inl (ta ?R)) (fmap_states_ta Inr (ta ?L)))›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) gen_nhole_mctxt_closure_automaton_def (*‹gen_nhole_mctxt_closure_automaton ?Q ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = ta_union ?𝒜 (reflcl_over_nhole_mctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f)›*) reflcl_over_nhole_mctxt_ta_def (*‹reflcl_over_nhole_mctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ add_eps (reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f) {|(?q⇩i, ?q⇩c)|}›*) reflcl_over_nhole_ctxt_ta_def (*‹reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ TA (reflcl_rules ?ℱ ?q⇩c |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩i ?q⇩f |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩f ?q⇩f) ((λp. (p, ?q⇩i)) |`| ?Q)›*) reg_Restr_Q⇩f_def (*‹reg_Restr_Q⇩f ?R = Reg (fin ?R |∩| 𝒬⇩r ?R) (ta ?R)›*) fmap_states_reg_def (*‹fmap_states_reg ?f ?R = Reg (?f |`| fin ?R) (fmap_states_ta ?f (ta ?R))›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) dest: ftranclD (*‹(?x, ?y) |∈| ?R|⁺| ⟹ ∃z. (?x, z) |∈| ?R ∧ (z = ?y ∨ (z, ?y) |∈| ?R|⁺|)›*) ftranclD2 (*‹(?x, ?y) |∈| ?R|⁺| ⟹ ∃z. (?x = z ∨ (?x, z) |∈| ?R|⁺|) ∧ (z, ?y) |∈| ?R›*)) (*goal: ‹is_ta_eps_free (ta 𝒜) ⟹ (eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜)))|⁺| = (λp. (fst p, Inl (Inr cl_state))) |`| eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜)) |∪| eps (ta (nhole_mctxt_reflcl_reg ℱ 𝒜))›*) by (meson fimageI (*‹(?x::?'a::type) |∈| (?A::?'a::type fset) ⟹ (?f::?'a::type ⇒ ?'b::type) ?x |∈| ?f |`| ?A›*) finsert_iff (*‹((?a::?'a::type) |∈| finsert (?b::?'a::type) (?A::?'a::type fset)) = (?a = ?b ∨ ?a |∈| ?A)›*) finterI (*‹⟦(?c::?'a::type) |∈| (?A::?'a::type fset); ?c |∈| (?B::?'a::type fset)⟧ ⟹ ?c |∈| ?A |∩| ?B›*) fr_into_trancl (*‹(?a::?'a::type, ?b::?'a::type) |∈| (?r::(?'a::type × ?'a::type) fset) ⟹ (?a, ?b) |∈| ?r|⁺|›*) ftrancl_into_trancl (*‹⟦(?a::?'a::type, ?b::?'a::type) |∈| (?r::(?'a::type × ?'a::type) fset)|⁺|; (?b, ?c::?'a::type) |∈| ?r⟧ ⟹ (?a, ?c) |∈| ?r|⁺|›*)) lemma ℒ_eps_free_nhole_mctxt_closure_reg: assumes "is_ta_eps_free (ta 𝒜)" shows "ℒ (eps_free_nhole_mctxt_closure_reg ℱ 𝒜) = ℒ (nhole_mctxt_closure_reg ℱ 𝒜)" using assms (*‹is_ta_eps_free (ta 𝒜)›*) unfolding eps_free_nhole_mctxt_closure_reg_def Let_def (*goal: ‹ℒ (eps_free_reg' ((λp::('a + cl_states) × ('a + cl_states). (fst p, Inr cl_state)) |`| eps (ta (nhole_mctxt_closure_reg (ℱ::('b × fvar) fset) (𝒜::('a, 'b) reg))) |∪| eps (ta (nhole_mctxt_closure_reg ℱ 𝒜))) (nhole_mctxt_closure_reg ℱ 𝒜)) = ℒ (nhole_mctxt_closure_reg ℱ 𝒜)›*) apply (intro ℒ_eps_free_reg'I (*‹(eps (ta (?𝒜::(?'a, ?'b) reg)))|⁺| = (?S::(?'a × ?'a) fset) ⟹ ℒ (eps_free_reg' ?S ?𝒜) = ℒ ?𝒜›*)) (*goal: ‹ℒ (eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta (nhole_mctxt_closure_reg ℱ 𝒜)) |∪| eps (ta (nhole_mctxt_closure_reg ℱ 𝒜))) (nhole_mctxt_closure_reg ℱ 𝒜)) = ℒ (nhole_mctxt_closure_reg ℱ 𝒜)›*) apply (auto simp: comp_def (*‹?f ∘ ?g = (λx. ?f (?g x))›*) nhole_mctxt_closure_reg_def (*‹nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = fmap_states_reg Inl (reg_Restr_Q⇩f ?𝒜) in gen_nhole_mctxt_closure_reg ?ℱ ℬ (Inr cl_state) (Inr tr_state) (Inr fin_state))›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) gen_nhole_mctxt_closure_reg_def (*‹gen_nhole_mctxt_closure_reg ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = Reg {|?q⇩f|} (gen_nhole_mctxt_closure_automaton (fin ?𝒜) ?ℱ (ta ?𝒜) ?q⇩c ?q⇩i ?q⇩f)›*) reg_Restr_Q⇩f_def (*‹reg_Restr_Q⇩f ?R = Reg (fin ?R |∩| 𝒬⇩r ?R) (ta ?R)›*) fmap_states_reg_def (*‹fmap_states_reg ?f ?R = Reg (?f |`| fin ?R) (fmap_states_ta ?f (ta ?R))›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) gen_nhole_mctxt_closure_automaton_def (*‹gen_nhole_mctxt_closure_automaton ?Q ?ℱ ?𝒜 ?q⇩c ?q⇩i ?q⇩f = ta_union ?𝒜 (reflcl_over_nhole_mctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f)›*) reflcl_over_nhole_mctxt_ta_def (*‹reflcl_over_nhole_mctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ add_eps (reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f) {|(?q⇩i, ?q⇩c)|}›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) reflcl_over_nhole_ctxt_ta_def (*‹reflcl_over_nhole_ctxt_ta ?Q ?ℱ ?q⇩c ?q⇩i ?q⇩f ≡ TA (reflcl_rules ?ℱ ?q⇩c |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩i ?q⇩f |∪| semantic_path_rules ?ℱ ?q⇩c ?q⇩f ?q⇩f) ((λp. (p, ?q⇩i)) |`| ?Q)›*) dest: ftranclD (*‹(?x, ?y) |∈| ?R|⁺| ⟹ ∃z. (?x, z) |∈| ?R ∧ (z = ?y ∨ (z, ?y) |∈| ?R|⁺|)›*) ftranclD2 (*‹(?x, ?y) |∈| ?R|⁺| ⟹ ∃z. (?x = z ∨ (?x, z) |∈| ?R|⁺|) ∧ (z, ?y) |∈| ?R›*)) (*goal: ‹is_ta_eps_free (ta 𝒜) ⟹ (eps (ta (nhole_mctxt_closure_reg ℱ 𝒜)))|⁺| = (λp. (fst p, Inr cl_state)) |`| eps (ta (nhole_mctxt_closure_reg ℱ 𝒜)) |∪| eps (ta (nhole_mctxt_closure_reg ℱ 𝒜))›*) by (meson fimageI (*‹?x |∈| ?A ⟹ ?f ?x |∈| ?f |`| ?A›*) finsert_iff (*‹(?a |∈| finsert ?b ?A) = (?a = ?b ∨ ?a |∈| ?A)›*) finterI (*‹⟦?c |∈| ?A; ?c |∈| ?B⟧ ⟹ ?c |∈| ?A |∩| ?B›*) fr_into_trancl (*‹(?a, ?b) |∈| ?r ⟹ (?a, ?b) |∈| ?r|⁺|›*) ftrancl_into_trancl (*‹⟦(?a, ?b) |∈| ?r|⁺|; (?b, ?c) |∈| ?r⟧ ⟹ (?a, ?c) |∈| ?r|⁺|›*)) fun rr1_of_rr1_rel_impl :: "('f × nat) fset ⇒ ('f :: linorder, 'v) fin_trs list ⇒ ftrs rr1_rel ⇒ (nat, 'f) reg option" and rr2_of_rr2_rel_impl :: "('f × nat) fset ⇒ ('f, 'v) fin_trs list ⇒ ftrs rr2_rel ⇒ (nat, 'f option × 'f option) reg option" where "rr1_of_rr1_rel_impl ℱ Rs R1Terms = Some (relabel_reg (term_reg ℱ))" | "rr1_of_rr1_rel_impl ℱ Rs (R1NF is) = liftO1 (λR. (simplify_reg (nf_reg (fst |`| R) ℱ))) (is_to_trs' Rs is)" | "rr1_of_rr1_rel_impl ℱ Rs (R1Inf r) = liftO1 (λR. let 𝒜 = trim_reg R in simplify_reg (proj_1_reg (Inf_reg_impl 𝒜)) ) (rr2_of_rr2_rel_impl ℱ Rs r)" | "rr1_of_rr1_rel_impl ℱ Rs (R1Proj i r) = (case i of 0 ⇒ liftO1 (trim_reg ∘ proj_1_reg) (rr2_of_rr2_rel_impl ℱ Rs r) | _ ⇒ liftO1 (trim_reg ∘ proj_2_reg) (rr2_of_rr2_rel_impl ℱ Rs r))" | "rr1_of_rr1_rel_impl ℱ Rs (R1Union s1 s2) = liftO2 (λ x y. relabel_reg (reg_union x y)) (rr1_of_rr1_rel_impl ℱ Rs s1) (rr1_of_rr1_rel_impl ℱ Rs s2)" | "rr1_of_rr1_rel_impl ℱ Rs (R1Inter s1 s2) = liftO2 (λ x y. simplify_reg (reg_intersect x y)) (rr1_of_rr1_rel_impl ℱ Rs s1) (rr1_of_rr1_rel_impl ℱ Rs s2)" | "rr1_of_rr1_rel_impl ℱ Rs (R1Diff s1 s2) = liftO2 (λ x y. relabel_reg (trim_reg (difference_reg x y))) (rr1_of_rr1_rel_impl ℱ Rs s1) (rr1_of_rr1_rel_impl ℱ Rs s2)" | "rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel g w x) = (case w of PRoot ⇒ (case x of ESingle ⇒ liftO1 (simplify_reg ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g) | EParallel ⇒ liftO1 (simplify_reg ∘ reflcl_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g) | EStrictParallel ⇒ liftO1 (simplify_reg ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g)) | PNonRoot ⇒ (case x of ESingle ⇒ liftO1 (simplify_reg ∘ ftrancl_eps_free_reg ∘ nhole_ctxt_closure_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g) | EParallel ⇒ liftO1 (simplify_reg ∘ eps_free_nhole_mctxt_reflcl_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g) | EStrictParallel ⇒ liftO1 (simplify_reg ∘ eps_free_nhole_mctxt_closure_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g)) | PAny ⇒ (case x of ESingle ⇒ liftO1 (simplify_reg ∘ ftrancl_eps_free_reg ∘ ctxt_closure_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g) | EParallel ⇒ liftO1 (simplify_reg ∘ ftrancl_eps_free_reg ∘ parallel_closure_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g) | EStrictParallel ⇒ liftO1 (simplify_reg ∘ eps_free_mctxt_closure_reg (lift_sig_RR2 |`| ℱ) ∘ GTT_to_RR2_root_reg) (gtt_of_gtt_rel_impl ℱ Rs g)))" | "rr2_of_rr2_rel_impl ℱ Rs (R2Diag s) = liftO1 (λ x. fmap_funs_reg (λf. (Some f, Some f)) x) (rr1_of_rr1_rel_impl ℱ Rs s)" | "rr2_of_rr2_rel_impl ℱ Rs (R2Prod s1 s2) = liftO2 (λ x y. simplify_reg (pair_automaton_reg x y)) (rr1_of_rr1_rel_impl ℱ Rs s1) (rr1_of_rr1_rel_impl ℱ Rs s2)" | "rr2_of_rr2_rel_impl ℱ Rs (R2Inv r) = liftO1 (fmap_funs_reg prod.swap) (rr2_of_rr2_rel_impl ℱ Rs r)" | "rr2_of_rr2_rel_impl ℱ Rs (R2Union r1 r2) = liftO2 (λ x y. relabel_reg (reg_union x y)) (rr2_of_rr2_rel_impl ℱ Rs r1) (rr2_of_rr2_rel_impl ℱ Rs r2)" | "rr2_of_rr2_rel_impl ℱ Rs (R2Inter r1 r2) = liftO2 (λ x y. simplify_reg (reg_intersect x y)) (rr2_of_rr2_rel_impl ℱ Rs r1) (rr2_of_rr2_rel_impl ℱ Rs r2)" | "rr2_of_rr2_rel_impl ℱ Rs (R2Diff r1 r2) = liftO2 (λ x y. simplify_reg (difference_reg x y)) (rr2_of_rr2_rel_impl ℱ Rs r1) (rr2_of_rr2_rel_impl ℱ Rs r2)" | "rr2_of_rr2_rel_impl ℱ Rs (R2Comp r1 r2) = liftO2 (λ x y. simplify_reg (rr2_compositon ℱ x y)) (rr2_of_rr2_rel_impl ℱ Rs r1) (rr2_of_rr2_rel_impl ℱ Rs r2)" lemmas ta_simp_unfold = simplify_reg_def relabel_reg_def trim_reg_def relabel_ta_def term_reg_def lemma is_ta_eps_free_trim_reg [intro!]: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (trim_reg R))" by (simp add: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) trim_reg_def (*‹trim_reg ?R = Reg (fin ?R) (trim_ta (fin ?R) (ta ?R))›*) trim_ta_def (*‹trim_ta ?P ?𝒜 = ta_only_prod ?P (ta_only_reach ?𝒜)›*) ta_restrict_def (*‹ta_restrict ?𝒜 ?Q = TA {|f qs → q |f qs q. f qs → q |∈| rules ?𝒜 ∧ fset_of_list qs |⊆| ?Q ∧ q |∈| ?Q|} (fRestr (eps ?𝒜) ?Q)›*)) lemma is_ta_eps_free_relabel_reg [intro!]: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (relabel_reg R))" by (simp add: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) relabel_reg_def (*‹relabel_reg ?R = Reg (relabel_Q⇩f (fin ?R) (ta ?R)) (relabel_ta (ta ?R))›*) relabel_ta_def (*‹relabel_ta ?𝒜 = fmap_states_ta (map_fset_to_nat (𝒬 ?𝒜)) ?𝒜›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*)) lemma is_ta_eps_free_simplify_reg [intro!]: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (simplify_reg R))" by (simp add: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) ta_simp_unfold (*‹simplify_reg ?𝒜 = relabel_reg (trim_reg ?𝒜)› ‹relabel_reg ?R = Reg (relabel_Q⇩f (fin ?R) (ta ?R)) (relabel_ta (ta ?R))› ‹trim_reg ?R = Reg (fin ?R) (trim_ta (fin ?R) (ta ?R))› ‹relabel_ta ?𝒜 = fmap_states_ta (map_fset_to_nat (𝒬 ?𝒜)) ?𝒜› ‹term_reg ?ℱ = Reg {|()|} (term_automaton ?ℱ)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) trim_ta_def (*‹trim_ta ?P ?𝒜 = ta_only_prod ?P (ta_only_reach ?𝒜)›*) ta_restrict_def (*‹ta_restrict ?𝒜 ?Q = TA {|f qs → q |f qs q. f qs → q |∈| rules ?𝒜 ∧ fset_of_list qs |⊆| ?Q ∧ q |∈| ?Q|} (fRestr (eps ?𝒜) ?Q)›*)) lemma is_ta_emptyI [simp]: "is_ta_eps_free (TA R {||}) ⟷ True" by (simp add: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) lemma is_ta_empty_trim_reg: "is_ta_eps_free (ta A) ⟹ eps (ta (trim_reg A)) = {||}" by (auto simp: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) trim_reg_def (*‹trim_reg ?R = Reg (fin ?R) (trim_ta (fin ?R) (ta ?R))›*) trim_ta_def (*‹trim_ta ?P ?𝒜 = ta_only_prod ?P (ta_only_reach ?𝒜)›*) ta_restrict_def (*‹ta_restrict ?𝒜 ?Q = TA {|f qs → q |f qs q. f qs → q |∈| rules ?𝒜 ∧ fset_of_list qs |⊆| ?Q ∧ q |∈| ?Q|} (fRestr (eps ?𝒜) ?Q)›*)) lemma is_proj_ta_eps_empty: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (proj_1_reg R))" "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (proj_2_reg R))" (*goals: 1. ‹is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (proj_1_reg R))› 2. ‹is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (proj_2_reg R))› discuss goal 1*) apply ((auto simp: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) proj_1_reg_def (*‹proj_1_reg ?A = collapse_automaton_reg (fmap_funs_reg fst (trim_reg ?A))›*) proj_2_reg_def (*‹proj_2_reg ?A = collapse_automaton_reg (fmap_funs_reg snd (trim_reg ?A))›*) collapse_automaton_reg_def (*‹collapse_automaton_reg ?R = Reg (fin ?R) (collapse_automaton (ta ?R))›*) collapse_automaton_def (*‹collapse_automaton ?A = TA (collapse_rule_fset ?A (Qn ?A) (Qs ?A)) (eps ?A)›*) fmap_funs_reg_def (*‹fmap_funs_reg ?f ?R = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*) fmap_funs_ta_def (*‹fmap_funs_ta ?f ?𝒜 = TA (map_ta_rule id ?f |`| rules ?𝒜) (eps ?𝒜)›*) trim_reg_def (*‹trim_reg ?R = Reg (fin ?R) (trim_ta (fin ?R) (ta ?R))›*) trim_ta_def (*‹trim_ta ?P ?𝒜 = ta_only_prod ?P (ta_only_reach ?𝒜)›*) ta_restrict_def (*‹ta_restrict ?𝒜 ?Q = TA {|f qs → q |f qs q. f qs → q |∈| rules ?𝒜 ∧ fset_of_list qs |⊆| ?Q ∧ q |∈| ?Q|} (fRestr (eps ?𝒜) ?Q)›*))[1]) (*discuss goal 2*) apply ((auto simp: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) proj_1_reg_def (*‹proj_1_reg ?A = collapse_automaton_reg (fmap_funs_reg fst (trim_reg ?A))›*) proj_2_reg_def (*‹proj_2_reg ?A = collapse_automaton_reg (fmap_funs_reg snd (trim_reg ?A))›*) collapse_automaton_reg_def (*‹collapse_automaton_reg ?R = Reg (fin ?R) (collapse_automaton (ta ?R))›*) collapse_automaton_def (*‹collapse_automaton ?A = TA (collapse_rule_fset ?A (Qn ?A) (Qs ?A)) (eps ?A)›*) fmap_funs_reg_def (*‹fmap_funs_reg ?f ?R = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*) fmap_funs_ta_def (*‹fmap_funs_ta ?f ?𝒜 = TA (map_ta_rule id ?f |`| rules ?𝒜) (eps ?𝒜)›*) trim_reg_def (*‹trim_reg ?R = Reg (fin ?R) (trim_ta (fin ?R) (ta ?R))›*) trim_ta_def (*‹trim_ta ?P ?𝒜 = ta_only_prod ?P (ta_only_reach ?𝒜)›*) ta_restrict_def (*‹ta_restrict ?𝒜 ?Q = TA {|f qs → q |f qs q. f qs → q |∈| rules ?𝒜 ∧ fset_of_list qs |⊆| ?Q ∧ q |∈| ?Q|} (fRestr (eps ?𝒜) ?Q)›*))[1]) (*proven 2 subgoals*) . lemma is_pod_ta_eps_empty: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta L) ⟹ is_ta_eps_free (ta (reg_intersect R L))" by (auto simp: reg_intersect_def (*‹reg_intersect (?R::(?'a, ?'c) reg) (?L::(?'b, ?'c) reg) = Reg (fin ?R |×| fin ?L) (prod_ta (ta ?R) (ta ?L))›*) prod_ta_def (*‹prod_ta (?𝒜::(?'q1.0, ?'f) ta) (?ℬ::(?'q2.0, ?'f) ta) = TA (prod_ta_rules ?𝒜 ?ℬ) (fCollect (prod_epsLp ?𝒜 ?ℬ) |∪| fCollect (prod_epsRp ?𝒜 ?ℬ))›*) prod_epsRp_def (*‹prod_epsRp (?𝒜::(?'a, ?'c) ta) (?ℬ::(?'b, ?'d) ta) = (λ(p::?'a × ?'b, q::?'a × ?'b). (snd p, snd q) |∈| eps ?ℬ ∧ fst p = fst q ∧ fst q |∈| 𝒬 ?𝒜)›*) prod_epsLp_def (*‹prod_epsLp (?𝒜::(?'a, ?'c) ta) (?ℬ::(?'b, ?'d) ta) = (λ(p::?'a × ?'b, q::?'a × ?'b). (fst p, fst q) |∈| eps ?𝒜 ∧ snd p = snd q ∧ snd q |∈| 𝒬 ?ℬ)›*) is_ta_eps_free_def (*‹is_ta_eps_free (?𝒜::(?'q, ?'f) ta) = (eps ?𝒜 = {||})›*)) lemma is_fmap_funs_reg_eps_empty: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (fmap_funs_reg f R))" by (auto simp: fmap_funs_reg_def (*‹fmap_funs_reg ?f ?R = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*) fmap_funs_ta_def (*‹fmap_funs_ta ?f ?𝒜 = TA (map_ta_rule id ?f |`| rules ?𝒜) (eps ?𝒜)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) lemma is_collapse_automaton_reg_eps_empty: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta (collapse_automaton_reg R))" by (auto simp: collapse_automaton_reg_def (*‹collapse_automaton_reg ?R = Reg (fin ?R) (collapse_automaton (ta ?R))›*) collapse_automaton_def (*‹collapse_automaton ?A = TA (collapse_rule_fset ?A (Qn ?A) (Qs ?A)) (eps ?A)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) lemma is_pair_automaton_reg_eps_empty: "is_ta_eps_free (ta R) ⟹ is_ta_eps_free (ta L) ⟹ is_ta_eps_free (ta (pair_automaton_reg R L))" by (auto simp: pair_automaton_reg_def (*‹pair_automaton_reg ?R ?L = Reg (Some |`| fin ?R |×| Some |`| fin ?L) (pair_automaton (ta ?R) (ta ?L))›*) pair_automaton_def (*‹pair_automaton ?A ?B = TA (map_ta_rule lift_Some_None lift_Some_None |`| rules ?A |∪| map_ta_rule lift_None_Some lift_None_Some |`| rules ?B |∪| pair_rule |`| (rules ?A |×| rules ?B)) (pair_eps ?A ?B |∪| map_both prod.swap |`| pair_eps ?B ?A)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) lemma is_reflcl_automaton_eps_free: "is_ta_eps_free A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ℱ) A)" by (auto simp: is_ta_eps_free_def (*‹is_ta_eps_free (?𝒜::(?'q::type, ?'f::type) ta) = (eps ?𝒜 = {||})›*) reflcl_automaton_def (*‹reflcl_automaton (?ℱ::(?'b::type × fvar) fset) (?𝒜::(?'a::type, ?'b::type) ta) = (let ℬ::(?'a::type option, ?'b::type) ta = fmap_states_ta Some ?𝒜 in gen_reflcl_automaton ?ℱ ℬ None)›*) ta_union_def (*‹ta_union (?𝒜::(?'a::type, ?'b::type) ta) (?ℬ::(?'a::type, ?'b::type) ta) = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) gen_reflcl_automaton_def (*‹gen_reflcl_automaton (?ℱ::(?'f::type × fvar) fset) (?𝒜::(?'q::type, ?'f::type) ta) (?q::?'q::type) = ta_union ?𝒜 (refl_ta ?ℱ ?q)›*) Let_def (*‹Let (?s::?'a::type) (?f::?'a::type ⇒ ?'b::type) ≡ ?f ?s›*) fmap_states_ta_def (*‹fmap_states_ta (?f::?'a::type ⇒ ?'b::type) (?𝒜::(?'a::type, ?'f::type) ta) = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*)) lemma is_GTT_to_RR2_root_eps_empty: "is_gtt_eps_free 𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root 𝒢)" by (auto simp: is_gtt_eps_free_def (*‹is_gtt_eps_free ?𝒢 = (eps (fst ?𝒢) = {||} ∧ eps (snd ?𝒢) = {||})›*) GTT_to_RR2_root_def (*‹GTT_to_RR2_root ?𝒢 = pair_automaton (fst ?𝒢) (snd ?𝒢)›*) pair_automaton_def (*‹pair_automaton ?A ?B = TA (map_ta_rule lift_Some_None lift_Some_None |`| rules ?A |∪| map_ta_rule lift_None_Some lift_None_Some |`| rules ?B |∪| pair_rule |`| (rules ?A |×| rules ?B)) (pair_eps ?A ?B |∪| map_both prod.swap |`| pair_eps ?B ?A)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) lemma is_term_automata_eps_empty: "is_ta_eps_free (ta (term_reg ℱ)) ⟷ True" by (auto simp: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) term_reg_def (*‹term_reg ?ℱ = Reg {|()|} (term_automaton ?ℱ)›*) term_automaton_def (*‹term_automaton ?ℱ = TA ((λ(f, n). f replicate n () → ()) |`| ?ℱ) {||}›*)) lemma is_ta_eps_free_eps_free_automata [simp]: " is_ta_eps_free (eps_free_automata S R) ⟷ True" by (auto simp: eps_free_automata_def (*‹eps_free_automata ?epscl ?𝒜 = (let ruleps = λr. finsert (r_rhs r) (?epscl |``| {|r_rhs r|}); rules = (λr. TA_rule (r_root r) (r_lhs_states r) |`| ruleps r) |`| rules ?𝒜 in TA (|⋃| rules) {||})›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) lemma rr2_of_rr2_rel_impl_eps_free: shows "∀ A. rr1_of_rr1_rel_impl ℱ Rs r1 = Some A ⟶ is_ta_eps_free (ta A)" "∀ A. rr2_of_rr2_rel_impl ℱ Rs r2 = Some A ⟶ is_ta_eps_free (ta A)" proof (induct r1 and r2) (*goals: 1. ‹∀A. rr1_of_rr1_rel_impl ℱ Rs R1Terms = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1NF x) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀x1 x2 x3. ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 10. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 11. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 12. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 13. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 14. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 15. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case R1Terms (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∀A::(fvar, 'a) reg. rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) R1Terms = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) term_automaton_def (*‹term_automaton ?ℱ = TA ((λ(f, n). f replicate n () → ()) |`| ?ℱ) {||}›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) ta_simp_unfold (*‹simplify_reg ?𝒜 = relabel_reg (trim_reg ?𝒜)› ‹relabel_reg ?R = Reg (relabel_Q⇩f (fin ?R) (ta ?R)) (relabel_ta (ta ?R))› ‹trim_reg ?R = Reg (fin ?R) (trim_ta (fin ?R) (ta ?R))› ‹relabel_ta ?𝒜 = fmap_states_ta (map_fset_to_nat (𝒬 ?𝒜)) ?𝒜› ‹term_reg ?ℱ = Reg {|()|} (term_automaton ?ℱ)›*)) next (*goals: 1. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1NF x) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x1 x2 x3. ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 10. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 11. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 12. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 13. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 14. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R1NF x) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∀A. rr1_of_rr1_rel_impl ℱ Rs (R1NF x) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: nf_reg_def (*‹nf_reg ?R ?ℱ = Reg (NF.fstates ?R) (nf_ta ?R ?ℱ)›*) nf_ta_def (*‹nf_ta ?R ?ℱ = TA (nf_rules ?R ?ℱ) {||}›*)) next (*goals: 1. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x1 x2 x3. ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 10. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 11. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 12. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 13. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R1Inf x) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: Inf_reg_impl_def (*‹Inf_reg_impl (?R::(?'a, ?'b option × ?'b option) reg) = Inf_reg ?R (fQ_inf_e (ta ?R))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) Inf_reg_def (*‹Inf_reg (?𝒜::(?'a, ?'b option × ?'b option) reg) (?Q::?'a fset) = Reg (CInr |`| fin ?𝒜) (Inf_automata (ta ?𝒜) ?Q)›*) Inf_automata_def (*‹Inf_automata (?𝒜::(?'q, ?'f option × ?'f option) ta) (?Q::?'q fset) = TA (|⋃| (q_inf_dash_intro_rules ?Q |`| rules ?𝒜) |∪| |⋃| ((fset_of_list ∘ q_inf_dash_closure_rules) |`| rules ?𝒜) |∪| map_ta_rule CInl id |`| rules ?𝒜) (map_both CInl |`| eps ?𝒜 |∪| map_both CInr |`| eps ?𝒜)›*) is_ta_empty_trim_reg (*‹is_ta_eps_free (ta (?A::(?'a, ?'b) reg)) ⟹ eps (ta (trim_reg ?A)) = {||}›*) intro!: is_proj_ta_eps_empty (*‹is_ta_eps_free (ta (?R::(?'a, ?'b option × ?'c option) reg)) ⟹ is_ta_eps_free (ta (proj_1_reg ?R))› ‹is_ta_eps_free (ta (?R::(?'a, ?'b option × ?'c option) reg)) ⟹ is_ta_eps_free (ta (proj_2_reg ?R))›*)) next (*goals: 1. ‹⋀x1 x2. ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2 x3. ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 10. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 11. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 12. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R1Proj n x2) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj n x2) = Some A ⟶ is_ta_eps_free (ta A)›*) apply (cases n) (*goals: 1. ‹⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A); n = 0⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj n x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀nat. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A); n = Suc nat⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Proj n x2) = Some A ⟶ is_ta_eps_free (ta A)› discuss goal 1*) apply ((auto intro!: is_proj_ta_eps_empty (*‹is_ta_eps_free (ta ?R) ⟹ is_ta_eps_free (ta (proj_1_reg ?R))› ‹is_ta_eps_free (ta ?R) ⟹ is_ta_eps_free (ta (proj_2_reg ?R))›*))[1]) (*discuss goal 2*) apply ((auto intro!: is_proj_ta_eps_empty (*‹is_ta_eps_free (ta ?R) ⟹ is_ta_eps_free (ta (proj_1_reg ?R))› ‹is_ta_eps_free (ta ?R) ⟹ is_ta_eps_free (ta (proj_2_reg ?R))›*))[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2 x3. ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 10. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 11. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R1Union x1 x2) (*‹∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A::(fvar, 'a) reg. rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (R1Union (x1::ftrs rr1_rel) (x2::ftrs rr1_rel)) = Some A ⟶ is_ta_eps_free (ta A)›*) by (simp add: reg_union_def (*‹reg_union ?R ?L = Reg (Inl |`| (fin ?R |∩| 𝒬⇩r ?R) |∪| Inr |`| (fin ?L |∩| 𝒬⇩r ?L)) (ta_union (fmap_states_ta Inl (ta ?R)) (fmap_states_ta Inr (ta ?L)))›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) relabel_reg_def (*‹relabel_reg ?R = Reg (relabel_Q⇩f (fin ?R) (ta ?R)) (relabel_ta (ta ?R))›*) relabel_ta_def (*‹relabel_ta ?𝒜 = fmap_states_ta (map_fset_to_nat (𝒬 ?𝒜)) ?𝒜›*)) next (*goals: 1. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2 x3. ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 10. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R1Inter x1 x2) (*‹∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto intro: is_pod_ta_eps_empty (*‹⟦is_ta_eps_free (ta ?R); is_ta_eps_free (ta ?L)⟧ ⟹ is_ta_eps_free (ta (reg_intersect ?R ?L))›*)) next (*goals: 1. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦∀A::(fvar, 'a::linorder) reg. rr1_of_rr1_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a::linorder) reg. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a::linorder) reg. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀(x1::ftrs gtt_rel) (x2::pos_step) x3::ext_step. ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x::ftrs rr1_rel. ∀A::(fvar, 'a::linorder) reg. rr1_of_rr1_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦∀A::(fvar, 'a::linorder) reg. rr1_of_rr1_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a::linorder) reg. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x::ftrs rr2_rel. ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 9. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a::linorder option × 'a::linorder option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R1Diff x1 x2) (*‹∀A::(fvar, 'a) reg. rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (x1::ftrs rr1_rel) = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: difference_reg_def (*‹difference_reg (?R::(?'a, ?'c) reg) (?L::(?'b, ?'c) reg) = (let F::(?'c × fvar) fset = ta_sig (ta ?R) in reg_intersect ?R (trim_reg (complement_reg (filter_ta_reg F ?L) F)))›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) complement_reg_def (*‹complement_reg (?R::(?'a, ?'b) reg) (?ℱ::(?'b × fvar) fset) = (let 𝒜::((unit + ?'a) FSet_Lex_Wrapper, ?'b) reg = ps_reg (reg_union (sig_ta_reg ?ℱ) ?R) in Reg (𝒬⇩r 𝒜 |-| fin 𝒜) (ta 𝒜))›*) ps_reg_def (*‹ps_reg (?R::(?'a, ?'b) reg) = Reg (ps_ta_Q⇩f (fin ?R) (ta ?R)) (ps_ta (ta ?R))›*) ps_ta_def (*‹ps_ta (?𝒜::(?'q, ?'f) ta) = (let Q::?'q FSet_Lex_Wrapper fset = ps_states ?𝒜 in TA (ps_rules ?𝒜 Q) {||})›*) intro!: is_pod_ta_eps_empty (*‹⟦is_ta_eps_free (ta (?R::(?'a, ?'b) reg)); is_ta_eps_free (ta (?L::(?'c, ?'b) reg))⟧ ⟹ is_ta_eps_free (ta (reg_intersect ?R ?L))›*)) next (*goals: 1. ‹⋀(x1::ftrs gtt_rel) (x2::pos_step) x3::ext_step. ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x::ftrs rr1_rel. ∀A::(fvar, 'a) reg. rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦∀A::(fvar, 'a) reg. rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a) reg. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x::ftrs rr2_rel. ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 8. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A::(fvar, 'a option × 'a option) reg. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2GTT_Rel x1 x2 x3) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)›*) apply (cases x2) (*goals: 1. ‹x2 = PRoot ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹x2 = PNonRoot ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹x2 = PAny ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› discuss goal 1*) apply (cases x3) (*goals: 1. ‹⟦x2 = PRoot; x3 = ESingle⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⟦x2 = PRoot; x3 = EParallel⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⟦x2 = PRoot; x3 = EStrictParallel⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› discuss goal 1*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*discuss goal 2*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*discuss goal 3*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg (?𝒢::(?'a, ?'b) ta × (?'a, ?'b) ta) = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures (?𝒜::(?'a, ?'b) ta) = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = (let ℬ::(?'a + cl_states, ?'b) reg = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp::(?'a + cl_states) × (?'a + cl_states). (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = (let ℬ::((?'a + cl_states) + cl_states, ?'b) reg = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp::((?'a + cl_states) + cl_states) × ((?'a + cl_states) + cl_states). (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = (let ℬ::(?'a + cl_states, ?'b) reg = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp::(?'a + cl_states) × (?'a + cl_states). (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl (?ℱ::(?'a × fvar) fset) (?Rs::((?'a, ?'b) Term.term × (?'a, ?'b) Term.term) fset list) (?g::ftrs gtt_rel) = Some (?g'::(fvar, ?'a) ta × (fvar, ?'a) ta) ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free (?𝒢::(?'a, ?'b) ta × (?'a, ?'b) ta) ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free (?A::(?'a, ?'b option × ?'b option) ta) ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| (?ℱ::(?'b × fvar) fset)) ?A)›*))[1]) (*proven 3 subgoals*) (*discuss goal 2*) apply (cases x3) (*goals: 1. ‹⟦x2 = PNonRoot; x3 = ESingle⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⟦x2 = PNonRoot; x3 = EParallel⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⟦x2 = PNonRoot; x3 = EStrictParallel⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› discuss goal 1*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg (?𝒢::(?'a, ?'b) ta × (?'a, ?'b) ta) = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures (?𝒜::(?'a, ?'b) ta) = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = (let ℬ::(?'a + cl_states, ?'b) reg = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp::(?'a + cl_states) × (?'a + cl_states). (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = (let ℬ::((?'a + cl_states) + cl_states, ?'b) reg = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp::((?'a + cl_states) + cl_states) × ((?'a + cl_states) + cl_states). (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let (?s::?'a) (?f::?'a ⇒ ?'b) ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = (let ℬ::(?'a + cl_states, ?'b) reg = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp::(?'a + cl_states) × (?'a + cl_states). (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg (?ℱ::(?'b × fvar) fset) (?𝒜::(?'a, ?'b) reg) = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl (?ℱ::(?'a × fvar) fset) (?Rs::((?'a, ?'b) Term.term × (?'a, ?'b) Term.term) fset list) (?g::ftrs gtt_rel) = Some (?g'::(fvar, ?'a) ta × (fvar, ?'a) ta) ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free (?𝒢::(?'a, ?'b) ta × (?'a, ?'b) ta) ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free (?A::(?'a, ?'b option × ?'b option) ta) ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| (?ℱ::(?'b × fvar) fset)) ?A)›*))[1]) (*discuss goal 2*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*discuss goal 3*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*proven 3 subgoals*) (*discuss goal 3*) apply (cases x3) (*goals: 1. ‹⟦x2 = PAny; x3 = ESingle⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⟦x2 = PAny; x3 = EParallel⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⟦x2 = PAny; x3 = EStrictParallel⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) = Some A ⟶ is_ta_eps_free (ta A)› discuss goal 1*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*discuss goal 2*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*discuss goal 3*) apply ((auto simp: GTT_to_RR2_root_reg_def (*‹GTT_to_RR2_root_reg ?𝒢 = Reg (map_both Some |`| fId_on (gtt_states ?𝒢)) (GTT_to_RR2_root ?𝒢)›*) ftrancl_eps_free_closures_def (*‹ftrancl_eps_free_closures ?𝒜 = eps_free_automata (eps ?𝒜) ?𝒜›*) eps_free_nhole_mctxt_closure_reg_def (*‹eps_free_nhole_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) eps_free_nhole_mctxt_reflcl_reg_def (*‹eps_free_nhole_mctxt_reflcl_reg ?ℱ ?𝒜 = (let ℬ = nhole_mctxt_reflcl_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inl (Inr cl_state))) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) eps_free_mctxt_closure_reg_def (*‹eps_free_mctxt_closure_reg ?ℱ ?𝒜 = (let ℬ = mctxt_closure_reg ?ℱ ?𝒜 in eps_free_reg' ((λp. (fst p, Inr cl_state)) |`| eps (ta ℬ) |∪| eps (ta ℬ)) ℬ)›*) reflcl_reg_def (*‹reflcl_reg ?ℱ ?𝒜 = Reg (finsert None (Some |`| fin ?𝒜)) (reflcl_automaton ?ℱ (ta ?𝒜))›*) dest: gtt_of_gtt_rel_impl_is_gtt_eps_free (*‹gtt_of_gtt_rel_impl ?ℱ ?Rs ?g = Some ?g' ⟹ is_gtt_eps_free ?g'›*) intro!: is_GTT_to_RR2_root_eps_empty (*‹is_gtt_eps_free ?𝒢 ⟹ is_ta_eps_free (GTT_to_RR2_root ?𝒢)›*) is_reflcl_automaton_eps_free (*‹is_ta_eps_free ?A ⟹ is_ta_eps_free (reflcl_automaton (lift_sig_RR2 |`| ?ℱ) ?A)›*))[1]) (*proven 3 subgoals*) (*proven 3 subgoals*) . next (*goals: 1. ‹⋀x. ∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 7. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Diag x) (*‹∀A. rr1_of_rr1_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: fmap_funs_reg_def (*‹fmap_funs_reg ?f ?R = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*) fmap_funs_ta_def (*‹fmap_funs_ta ?f ?𝒜 = TA (map_ta_rule id ?f |`| rules ?𝒜) (eps ?𝒜)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) next (*goals: 1. ‹⋀x1 x2. ⟦∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 6. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Prod x1 x2) (*‹∀A. rr1_of_rr1_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr1_of_rr1_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto intro: is_pair_automaton_reg_eps_empty (*‹⟦is_ta_eps_free (ta (?R::(?'a, ?'b) reg)); is_ta_eps_free (ta (?L::(?'c, ?'d) reg))⟧ ⟹ is_ta_eps_free (ta (pair_automaton_reg ?R ?L))›*)) next (*goals: 1. ‹⋀x. ∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A) ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 5. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Inv x) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: fmap_funs_reg_def (*‹fmap_funs_reg ?f ?R = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*) fmap_funs_ta_def (*‹fmap_funs_ta ?f ?𝒜 = TA (map_ta_rule id ?f |`| rules ?𝒜) (eps ?𝒜)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*)) next (*goals: 1. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 4. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Union x1 x2) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (simp add: reg_union_def (*‹reg_union ?R ?L = Reg (Inl |`| (fin ?R |∩| 𝒬⇩r ?R) |∪| Inr |`| (fin ?L |∩| 𝒬⇩r ?L)) (ta_union (fmap_states_ta Inl (ta ?R)) (fmap_states_ta Inr (ta ?L)))›*) ta_union_def (*‹ta_union ?𝒜 ?ℬ = TA (rules ?𝒜 |∪| rules ?ℬ) (eps ?𝒜 |∪| eps ?ℬ)›*) fmap_states_ta_def (*‹fmap_states_ta ?f ?𝒜 = TA (map_ta_rule ?f id |`| rules ?𝒜) (map_both ?f |`| eps ?𝒜)›*) is_ta_eps_free_def (*‹is_ta_eps_free ?𝒜 = (eps ?𝒜 = {||})›*) relabel_reg_def (*‹relabel_reg ?R = Reg (relabel_Q⇩f (fin ?R) (ta ?R)) (relabel_ta (ta ?R))›*) relabel_ta_def (*‹relabel_ta ?𝒜 = fmap_states_ta (map_fset_to_nat (𝒬 ?𝒜)) ?𝒜›*)) next (*goals: 1. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 3. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Inter x1 x2) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto intro: is_pod_ta_eps_empty (*‹⟦is_ta_eps_free (ta ?R); is_ta_eps_free (ta ?L)⟧ ⟹ is_ta_eps_free (ta (reg_intersect ?R ?L))›*)) next (*goals: 1. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)› 2. ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Diff x1 x2) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: difference_reg_def (*‹difference_reg ?R ?L = (let F = ta_sig (ta ?R) in reg_intersect ?R (trim_reg (complement_reg (filter_ta_reg F ?L) F)))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) complement_reg_def (*‹complement_reg ?R ?ℱ = (let 𝒜 = ps_reg (reg_union (sig_ta_reg ?ℱ) ?R) in Reg (𝒬⇩r 𝒜 |-| fin 𝒜) (ta 𝒜))›*) ps_reg_def (*‹ps_reg ?R = Reg (ps_ta_Q⇩f (fin ?R) (ta ?R)) (ps_ta (ta ?R))›*) ps_ta_def (*‹ps_ta ?𝒜 = (let Q = ps_states ?𝒜 in TA (ps_rules ?𝒜 Q) {||})›*) intro!: is_pod_ta_eps_empty (*‹⟦is_ta_eps_free (ta ?R); is_ta_eps_free (ta ?L)⟧ ⟹ is_ta_eps_free (ta (reg_intersect ?R ?L))›*)) next (*goal: ‹⋀x1 x2. ⟦∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A); ∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)⟧ ⟹ ∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) case (R2Comp x1 x2) (*‹∀A. rr2_of_rr2_rel_impl ℱ Rs x1 = Some A ⟶ is_ta_eps_free (ta A)› ‹∀A. rr2_of_rr2_rel_impl ℱ Rs x2 = Some A ⟶ is_ta_eps_free (ta A)›*) then show "?case" (*goal: ‹∀A. rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) = Some A ⟶ is_ta_eps_free (ta A)›*) by (auto simp: is_term_automata_eps_empty (*‹is_ta_eps_free (ta (term_reg ?ℱ)) = True›*) rr2_compositon_def (*‹rr2_compositon ?ℱ ?A ?B = (let A' = RR2_to_RRn ?A; B' = RR2_to_RRn ?B; F = true_RRn ?ℱ 1; CA = trim_reg (fmap_funs_reg (pad_with_Nones 2 1) (pair_automaton_reg A' F)); CB = trim_reg (fmap_funs_reg (pad_with_Nones 1 2) (pair_automaton_reg F B')); PI = trim_reg (fmap_funs_reg (λxs. map ((!) xs) [1, 0, 2]) (reg_intersect CA CB)) in RRn_to_RR2 (collapse_automaton_reg (fmap_funs_reg (drop_none_rule 1) PI)))›*) Let_def (*‹Let ?s ?f ≡ ?f ?s›*) intro!: is_pod_ta_eps_empty (*‹⟦is_ta_eps_free (ta ?R); is_ta_eps_free (ta ?L)⟧ ⟹ is_ta_eps_free (ta (reg_intersect ?R ?L))›*) is_fmap_funs_reg_eps_empty (*‹is_ta_eps_free (ta ?R) ⟹ is_ta_eps_free (ta (fmap_funs_reg ?f ?R))›*) is_collapse_automaton_reg_eps_empty (*‹is_ta_eps_free (ta ?R) ⟹ is_ta_eps_free (ta (collapse_automaton_reg ?R))›*) is_pair_automaton_reg_eps_empty (*‹⟦is_ta_eps_free (ta ?R); is_ta_eps_free (ta ?L)⟧ ⟹ is_ta_eps_free (ta (pair_automaton_reg ?R ?L))›*)) qed lemma rr_of_rr_rel_impl_complete: "rr1_of_rr1_rel_impl ℱ Rs r1 ≠ None ⟷ rr1_of_rr1_rel ℱ Rs r1 ≠ None" "rr2_of_rr2_rel_impl ℱ Rs r2 ≠ None ⟷ rr2_of_rr2_rel ℱ Rs r2 ≠ None" proof (induct r1 and r2) (*goals: 1. ‹(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) R1Terms ≠ None) = (rr1_of_rr1_rel ℱ Rs R1Terms ≠ None)› 2. ‹⋀x::ftrs list. (rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (R1NF x) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1NF x) ≠ None)› 3. ‹⋀x::ftrs rr2_rel. (rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x ≠ None) = (rr2_of_rr2_rel ℱ Rs x ≠ None) ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Inf x) ≠ None)› 4. ‹⋀(x1::fvar) x2::ftrs rr2_rel. (rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None) ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Proj x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Proj x1 x2) ≠ None)› 5. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Union x1 x2) ≠ None)› 6. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Inter x1 x2) ≠ None)› 7. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Diff x1 x2) ≠ None)› 8. ‹⋀(x1::ftrs gtt_rel) (x2::pos_step) x3::ext_step. (rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (R2GTT_Rel x1 x2 x3) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 x2 x3) ≠ None)› 9. ‹⋀x::ftrs rr1_rel. (rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x ≠ None) = (rr1_of_rr1_rel ℱ Rs x ≠ None) ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Diag x) ≠ None)› 10. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Prod x1 x2) ≠ None)› 11. ‹⋀x::ftrs rr2_rel. (rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x ≠ None) = (rr2_of_rr2_rel ℱ Rs x ≠ None) ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Inv x) ≠ None)› 12. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Union x1 x2) ≠ None)› 13. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Inter x1 x2) ≠ None)› 14. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Diff x1 x2) ≠ None)› 15. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Comp x1 x2) ≠ None)›*) case (R1Proj n x2) (*‹(rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)›*) then show "?case" (*goal: ‹(rr1_of_rr1_rel_impl ℱ Rs (R1Proj n x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Proj n x2) ≠ None)›*) apply (cases n) (*goals: 1. ‹⟦(rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None); n = 0⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Proj n x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Proj n x2) ≠ None)› 2. ‹⋀nat. ⟦(rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None); n = Suc nat⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Proj n x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Proj n x2) ≠ None)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*proven 2 subgoals*) . next (*goals: 1. ‹(rr1_of_rr1_rel_impl ℱ Rs R1Terms ≠ None) = (rr1_of_rr1_rel ℱ Rs R1Terms ≠ None)› 2. ‹⋀x. (rr1_of_rr1_rel_impl ℱ Rs (R1NF x) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1NF x) ≠ None)› 3. ‹⋀x. (rr2_of_rr2_rel_impl ℱ Rs x ≠ None) = (rr2_of_rr2_rel ℱ Rs x ≠ None) ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Inf x) ≠ None)› 4. ‹⋀x1 x2. ⟦(rr1_of_rr1_rel_impl ℱ Rs x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Union x1 x2) ≠ None)› 5. ‹⋀x1 x2. ⟦(rr1_of_rr1_rel_impl ℱ Rs x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Inter x1 x2) ≠ None)› 6. ‹⋀x1 x2. ⟦(rr1_of_rr1_rel_impl ℱ Rs x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Diff x1 x2) ≠ None)› 7. ‹⋀x1 x2 x3. (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 x2 x3) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 x2 x3) ≠ None)› 8. ‹⋀x. (rr1_of_rr1_rel_impl ℱ Rs x ≠ None) = (rr1_of_rr1_rel ℱ Rs x ≠ None) ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Diag x) ≠ None)› 9. ‹⋀x1 x2. ⟦(rr1_of_rr1_rel_impl ℱ Rs x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Prod x1 x2) ≠ None)› 10. ‹⋀x. (rr2_of_rr2_rel_impl ℱ Rs x ≠ None) = (rr2_of_rr2_rel ℱ Rs x ≠ None) ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Inv x) ≠ None)› 11. ‹⋀x1 x2. ⟦(rr2_of_rr2_rel_impl ℱ Rs x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Union x1 x2) ≠ None)› 12. ‹⋀x1 x2. ⟦(rr2_of_rr2_rel_impl ℱ Rs x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Inter x1 x2) ≠ None)› 13. ‹⋀x1 x2. ⟦(rr2_of_rr2_rel_impl ℱ Rs x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Diff x1 x2) ≠ None)› 14. ‹⋀x1 x2. ⟦(rr2_of_rr2_rel_impl ℱ Rs x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Comp x1 x2) ≠ None)›*) case (R2GTT_Rel x1 n p) (*no hyothesis introduced yet*) then show "?case" (*goal: ‹(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (R2GTT_Rel (x1::ftrs gtt_rel) (n::pos_step) (p::ext_step)) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)›*) using gtt_of_gtt_rel_impl_gtt_of_gtt_rel[of ℱ Rs] (*‹(gtt_of_gtt_rel_impl ℱ Rs ?g ≠ None) = (gtt_of_gtt_rel ℱ Rs ?g ≠ None)›*) apply (cases p) (*goals: 1. ‹⟦⋀g. (gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); p = ESingle⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 2. ‹⟦⋀g. (gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); p = EParallel⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 3. ‹⟦⋀g. (gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); p = EStrictParallel⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› discuss goal 1*) apply (cases n) (*goals: 1. ‹⟦⋀g. (gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); p = ESingle; n = PRoot⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 2. ‹⟦⋀g. (gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); p = ESingle; n = PNonRoot⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 3. ‹⟦⋀g. (gtt_of_gtt_rel_impl ℱ Rs g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); p = ESingle; n = PAny⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel x1 n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*discuss goal 2*) apply (cases n) (*goals: 1. ‹⟦⋀g::ftrs gtt_rel. (gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); (p::ext_step) = EParallel; (n::pos_step) = PRoot⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel (x1::ftrs gtt_rel) n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 2. ‹⟦⋀g::ftrs gtt_rel. (gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); (p::ext_step) = EParallel; (n::pos_step) = PNonRoot⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel (x1::ftrs gtt_rel) n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 3. ‹⟦⋀g::ftrs gtt_rel. (gtt_of_gtt_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); (p::ext_step) = EParallel; (n::pos_step) = PAny⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel (x1::ftrs gtt_rel) n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*discuss goal 3*) apply (cases n) (*goals: 1. ‹⟦⋀g::ftrs gtt_rel. (gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); (p::ext_step) = EStrictParallel; (n::pos_step) = PRoot⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel (x1::ftrs gtt_rel) n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 2. ‹⟦⋀g::ftrs gtt_rel. (gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); (p::ext_step) = EStrictParallel; (n::pos_step) = PNonRoot⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel (x1::ftrs gtt_rel) n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› 3. ‹⟦⋀g::ftrs gtt_rel. (gtt_of_gtt_rel_impl (ℱ::('a::linorder × fvar) fset) (Rs::(('a::linorder, 'b::type) Term.term × ('a::linorder, 'b::type) Term.term) fset list) g ≠ None) = (gtt_of_gtt_rel ℱ Rs g ≠ None); (p::ext_step) = EStrictParallel; (n::pos_step) = PAny⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2GTT_Rel (x1::ftrs gtt_rel) n p) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2GTT_Rel x1 n p) ≠ None)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) (*proven 3 subgoals*) . qed (auto) (*solves the remaining goals: 1. ‹(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) R1Terms ≠ None) = (rr1_of_rr1_rel ℱ Rs R1Terms ≠ None)› 2. ‹⋀x::ftrs list. (rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (R1NF x) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1NF x) ≠ None)› 3. ‹⋀x::ftrs rr2_rel. (rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x ≠ None) = (rr2_of_rr2_rel ℱ Rs x ≠ None) ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Inf x) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Inf x) ≠ None)› 4. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Union x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Union x1 x2) ≠ None)› 5. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Inter x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Inter x1 x2) ≠ None)› 6. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr1_of_rr1_rel_impl ℱ Rs (R1Diff x1 x2) ≠ None) = (rr1_of_rr1_rel ℱ Rs (R1Diff x1 x2) ≠ None)› 7. ‹⋀x::ftrs rr1_rel. (rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x ≠ None) = (rr1_of_rr1_rel ℱ Rs x ≠ None) ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Diag x) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Diag x) ≠ None)› 8. ‹⋀(x1::ftrs rr1_rel) x2::ftrs rr1_rel. ⟦(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr1_of_rr1_rel ℱ Rs x1 ≠ None); (rr1_of_rr1_rel_impl ℱ Rs x2 ≠ None) = (rr1_of_rr1_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Prod x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Prod x1 x2) ≠ None)› 9. ‹⋀x::ftrs rr2_rel. (rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x ≠ None) = (rr2_of_rr2_rel ℱ Rs x ≠ None) ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Inv x) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Inv x) ≠ None)› 10. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Union x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Union x1 x2) ≠ None)› 11. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Inter x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Inter x1 x2) ≠ None)› 12. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Diff x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Diff x1 x2) ≠ None)› 13. ‹⋀(x1::ftrs rr2_rel) x2::ftrs rr2_rel. ⟦(rr2_of_rr2_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) x1 ≠ None) = (rr2_of_rr2_rel ℱ Rs x1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs x2 ≠ None) = (rr2_of_rr2_rel ℱ Rs x2 ≠ None)⟧ ⟹ (rr2_of_rr2_rel_impl ℱ Rs (R2Comp x1 x2) ≠ None) = (rr2_of_rr2_rel ℱ Rs (R2Comp x1 x2) ≠ None)›*) lemma 𝒬_fmap_funs_reg [simp]: "𝒬⇩r (fmap_funs_reg f 𝒜) = 𝒬⇩r 𝒜" by (auto simp: fmap_funs_reg_def (*‹fmap_funs_reg (?f::?'f::type ⇒ ?'g::type) (?R::(?'a::type, ?'f::type) reg) = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*)) lemma ta_reachable_fmap_funs_reg [simp]: "ta_reachable (ta (fmap_funs_reg f 𝒜)) = ta_reachable (ta 𝒜)" by (auto simp: fmap_funs_reg_def (*‹fmap_funs_reg ?f ?R = Reg (fin ?R) (fmap_funs_ta ?f (ta ?R))›*)) lemma collapse_reg_cong: "𝒬⇩r 𝒜 |⊆| ta_reachable (ta 𝒜) ⟹ 𝒬⇩r ℬ |⊆| ta_reachable (ta ℬ) ⟹ ℒ 𝒜 = ℒ ℬ ⟹ ℒ (collapse_automaton_reg 𝒜) = ℒ (collapse_automaton_reg ℬ)" by (auto simp: collapse_automaton_reg_def (*‹collapse_automaton_reg ?R = Reg (fin ?R) (collapse_automaton (ta ?R))›*) ℒ_def (*‹ℒ ?𝒜 = gta_lang (fin ?𝒜) (ta ?𝒜)›*) collapse_automaton' (*‹𝒬 ?A |⊆| ta_reachable ?A ⟹ gta_lang ?Q (collapse_automaton ?A) = the ` (gcollapse ` gta_lang ?Q ?A - {None})›*)) lemma ℒ_fmap_funs_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℒ (fmap_funs_reg h 𝒜) = ℒ (fmap_funs_reg h ℬ)" by (auto simp: fmap_funs_ℒ (*‹ℒ (fmap_funs_reg ?h ?R) = map_gterm ?h ` ℒ ?R›*)) lemma ℒ_pair_automaton_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℒ 𝒞 = ℒ 𝒟 ⟹ ℒ (pair_automaton_reg 𝒜 𝒞) = ℒ (pair_automaton_reg ℬ 𝒟)" by (auto simp: pair_automaton' (*‹ℒ (pair_automaton_reg ?A ?B) = (λ(x, y). gpair x y) ` (ℒ ?A × ℒ ?B)›*)) lemma ℒ_nhole_ctxt_closure_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℱ = 𝒢 ⟹ ℒ (nhole_ctxt_closure_reg ℱ 𝒜) = ℒ (nhole_ctxt_closure_reg 𝒢 ℬ)" by (auto simp: nhole_ctxtcl_lang (*‹ℒ (nhole_ctxt_closure_reg ?ℱ ?𝒜) = {C⟨s⟩⇩G |C s. C ≠ □⇩G ∧ funas_gctxt C ⊆ fset ?ℱ ∧ s ∈ ℒ ?𝒜}›*)) lemma ℒ_nhole_mctxt_closure_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℱ = 𝒢 ⟹ ℒ (nhole_mctxt_closure_reg ℱ 𝒜) = ℒ (nhole_mctxt_closure_reg 𝒢 ℬ)" by (auto simp: nhole_gmctxt_closure_lang (*‹ℒ (nhole_mctxt_closure_reg ?ℱ ?𝒜) = {fill_gholes C ss |C ss. num_gholes C = length ss ∧ 0 < num_gholes C ∧ C ≠ GMHole ∧ funas_gmctxt C ⊆ fset ?ℱ ∧ (∀i<length ss. ss ! i ∈ ℒ ?𝒜)}›*)) lemma ℒ_ctxt_closure_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℱ = 𝒢 ⟹ ℒ (ctxt_closure_reg ℱ 𝒜) = ℒ (ctxt_closure_reg 𝒢 ℬ)" by (auto simp: gctxt_closure_lang (*‹ℒ (ctxt_closure_reg ?ℱ ?𝒜) = {C⟨s⟩⇩G |C s. funas_gctxt C ⊆ fset ?ℱ ∧ s ∈ ℒ ?𝒜}›*)) lemma ℒ_parallel_closure_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℱ = 𝒢 ⟹ ℒ (parallel_closure_reg ℱ 𝒜) = ℒ (parallel_closure_reg 𝒢 ℬ)" by (auto simp: parallelcl_gmctxt_lang (*‹ℒ (parallel_closure_reg ?ℱ ?𝒜) = {fill_gholes C ss |C ss. num_gholes C = length ss ∧ funas_gmctxt C ⊆ fset ?ℱ ∧ (∀i<length ss. ss ! i ∈ ℒ ?𝒜)}›*)) lemma ℒ_mctxt_closure_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℱ = 𝒢 ⟹ ℒ (mctxt_closure_reg ℱ 𝒜) = ℒ (mctxt_closure_reg 𝒢 ℬ)" by (auto simp: gmctxt_closure_lang (*‹ℒ (mctxt_closure_reg ?ℱ ?𝒜) = {fill_gholes C ss |C ss. num_gholes C = length ss ∧ 0 < num_gholes C ∧ funas_gmctxt C ⊆ fset ?ℱ ∧ (∀i<length ss. ss ! i ∈ ℒ ?𝒜)}›*)) lemma ℒ_nhole_mctxt_reflcl_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℱ = 𝒢 ⟹ ℒ (nhole_mctxt_reflcl_reg ℱ 𝒜) = ℒ (nhole_mctxt_reflcl_reg 𝒢 ℬ)" unfolding nhole_mctxt_reflcl_lang (*goal: ‹⟦ℒ (𝒜::('b::type, 'a::type) reg) = ℒ (ℬ::('c::type, 'a::type) reg); (ℱ::('a::type × fvar) fset) = (𝒢::('a::type × fvar) fset)⟧ ⟹ ℒ (nhole_mctxt_closure_reg ℱ 𝒜) ∪ 𝒯⇩G (fset ℱ) = ℒ (nhole_mctxt_closure_reg 𝒢 ℬ) ∪ 𝒯⇩G (fset 𝒢)›*) apply (intro arg_cong2[where ?f = "(∪)"] (*‹⟦(?a::?'d1::type set) = (?b::?'d1::type set); (?c::?'d1::type set) = (?d::?'d1::type set)⟧ ⟹ ?a ∪ ?c = ?b ∪ ?d›*) ℒ_nhole_mctxt_closure_reg_cong (*‹⟦ℒ (?𝒜::(?'b::type, ?'a::type) reg) = ℒ (?ℬ::(?'c::type, ?'a::type) reg); (?ℱ::(?'a::type × fvar) fset) = (?𝒢::(?'a::type × fvar) fset)⟧ ⟹ ℒ (nhole_mctxt_closure_reg ?ℱ ?𝒜) = ℒ (nhole_mctxt_closure_reg ?𝒢 ?ℬ)›*)) (*goals: 1. ‹⟦ℒ 𝒜 = ℒ ℬ; ℱ = 𝒢⟧ ⟹ ℒ 𝒜 = ℒ ℬ› 2. ‹⟦ℒ 𝒜 = ℒ ℬ; ℱ = 𝒢⟧ ⟹ ℱ = 𝒢› 3. ‹⟦ℒ 𝒜 = ℒ ℬ; ℱ = 𝒢⟧ ⟹ 𝒯⇩G (fset ℱ) = 𝒯⇩G (fset 𝒢)› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*proven 3 subgoals*) . declare equalityI[rule del] declare fsubsetI[rule del] lemma ℒ_proj_1_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℒ (proj_1_reg 𝒜) = ℒ (proj_1_reg ℬ)" by (auto simp: proj_1_reg_def (*‹proj_1_reg ?A = collapse_automaton_reg (fmap_funs_reg fst (trim_reg ?A))›*) ℒ_trim (*‹ℒ (trim_reg ?R) = ℒ ?R›*) intro!: collapse_reg_cong (*‹⟦𝒬⇩r ?𝒜 |⊆| ta_reachable (ta ?𝒜); 𝒬⇩r ?ℬ |⊆| ta_reachable (ta ?ℬ); ℒ ?𝒜 = ℒ ?ℬ⟧ ⟹ ℒ (collapse_automaton_reg ?𝒜) = ℒ (collapse_automaton_reg ?ℬ)›*) ℒ_fmap_funs_reg_cong (*‹ℒ ?𝒜 = ℒ ?ℬ ⟹ ℒ (fmap_funs_reg ?h ?𝒜) = ℒ (fmap_funs_reg ?h ?ℬ)›*)) lemma ℒ_proj_2_reg_cong: "ℒ 𝒜 = ℒ ℬ ⟹ ℒ (proj_2_reg 𝒜) = ℒ (proj_2_reg ℬ)" by (auto simp: proj_2_reg_def (*‹proj_2_reg ?A = collapse_automaton_reg (fmap_funs_reg snd (trim_reg ?A))›*) ℒ_trim (*‹ℒ (trim_reg ?R) = ℒ ?R›*) intro!: collapse_reg_cong (*‹⟦𝒬⇩r ?𝒜 |⊆| ta_reachable (ta ?𝒜); 𝒬⇩r ?ℬ |⊆| ta_reachable (ta ?ℬ); ℒ ?𝒜 = ℒ ?ℬ⟧ ⟹ ℒ (collapse_automaton_reg ?𝒜) = ℒ (collapse_automaton_reg ?ℬ)›*) ℒ_fmap_funs_reg_cong (*‹ℒ ?𝒜 = ℒ ?ℬ ⟹ ℒ (fmap_funs_reg ?h ?𝒜) = ℒ (fmap_funs_reg ?h ?ℬ)›*)) lemma rr2_of_rr2_rel_impl_sound: assumes "∀R ∈ set Rs. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ" shows "⋀ A B. rr1_of_rr1_rel_impl ℱ Rs r1 = Some A ⟹ rr1_of_rr1_rel ℱ Rs r1 = Some B ⟹ ℒ A = ℒ B" "⋀ A B. rr2_of_rr2_rel_impl ℱ Rs r2 = Some A ⟹ rr2_of_rr2_rel ℱ Rs r2 = Some B ⟹ ℒ A = ℒ B" proof (induct r1 and r2) case (R1Inf r) then obtain C D where inf: "rr2_of_rr2_rel_impl ℱ Rs r = Some C" "rr2_of_rr2_rel ℱ Rs r = Some D" "ℒ C = ℒ D" by auto have spec: "RR2_spec C (eval_rr2_rel (fset ℱ) (map fset Rs) r)" "RR2_spec D (eval_rr2_rel (fset ℱ) (map fset Rs) r)" using rr12_of_rr12_rel_correct(2)[OF assms, rule_format, OF inf(2)] inf(3) by (auto simp: RR2_spec_def) then have trim_spec: "RR2_spec (trim_reg C) (eval_rr2_rel (fset ℱ) (map fset Rs) r)" "RR2_spec (trim_reg D) (eval_rr2_rel (fset ℱ) (map fset Rs) r)" by (auto simp: RR2_spec_def ℒ_trim) let ?C = "Inf_reg (trim_reg C) (Q_infty (ta (trim_reg C)) ℱ)" let ?D = "Inf_reg (trim_reg D) (Q_infty (ta (trim_reg D)) ℱ)" from spec have *: "ℒ (Inf_reg_impl (trim_reg C)) = ℒ ?C" using eval_rr12_rel_sig(2)[of "fset ℱ" "map fset Rs" r] by (intro Inf_reg_impl_sound) (auto simp: RR2_spec_def ℒ_trim 𝒯⇩G_equivalent_def) from spec have **: "ℒ (Inf_reg_impl (trim_reg D)) = ℒ ?D" using eval_rr12_rel_sig(2)[of "fset ℱ" "map fset Rs" r] by (intro Inf_reg_impl_sound) (auto simp: RR2_spec_def ℒ_trim 𝒯⇩G_equivalent_def) then have C: "RR2_spec ?C {(s, t) | s t. gpair s t ∈ ℒ ?C}" and D: "RR2_spec ?D {(s, t) | s t. gpair s t ∈ ℒ ?D}" using subset_trans[OF Inf_automata_subseteq[of "trim_reg C" ℱ], of "ℒ C"] spec using subset_trans[OF Inf_automata_subseteq[of "trim_reg D" ℱ], of "ℒ D"] using eval_rr12_rel_sig(2)[of "fset ℱ" "map fset Rs" r] by (auto simp: RR2_spec_def ℒ_trim 𝒯⇩G_equivalent_def intro!: equalityI fsubsetI) from * ** have r: "ℒ (proj_1_reg (Inf_reg_impl (trim_reg C))) = ℒ (proj_1_reg ?C)" "ℒ (proj_1_reg (Inf_reg_impl (trim_reg D))) = ℒ (proj_1_reg ?D)" by (auto intro: ℒ_proj_1_reg_cong) from ℒ_Inf_reg[OF trim_spec(1), of ℱ] ℒ_Inf_reg[OF trim_spec(2), of ℱ] show ?case using R1Inf eval_rr12_rel_sig(2)[of "fset ℱ" "map fset Rs" r] by (auto simp: liftO1_def r inf 𝒯⇩G_equivalent_def ℒ_proj(1)[OF C] ℒ_proj(1)[OF D]) next case (R1Proj n x2) then show ?case by (cases n) (auto simp: liftO1_def ℒ_trim proj_1_reg_def proj_2_reg_def intro!: fsubsetI ℒ_fmap_funs_reg_cong collapse_reg_cong, (meson fin_mono trim_reg_reach)+) next case (R2GTT_Rel g p n) note IH = this note ass = R2GTT_Rel consider (a) "∃ A. gtt_of_gtt_rel_impl ℱ Rs g = Some A" | (b) "gtt_of_gtt_rel_impl ℱ Rs g = None" by blast then show ?case proof cases case a then obtain C D where gtt [simp]: "gtt_of_gtt_rel_impl ℱ Rs g = Some C" "gtt_of_gtt_rel ℱ Rs g = Some D" using gtt_of_gtt_rel_impl_gtt_of_gtt_rel by blast from gtt_of_gtt_rel_impl_sound[OF this] have spec [simp]: "agtt_lang C = agtt_lang D" by auto have eps [simp]: "is_ta_eps_free (ta (GTT_to_RR2_root_reg C))" using gtt_of_gtt_rel_impl_is_gtt_eps_free[OF gtt(1)] by (auto simp: GTT_to_RR2_root_reg_def GTT_to_RR2_root_def pair_automaton_def is_ta_eps_free_def is_gtt_eps_free_def) have lang: "ℒ (GTT_to_RR2_root_reg C) = ℒ (GTT_to_RR2_root_reg D)" by (metis (no_types, lifting) GTT_to_RR2_root RR2_spec_def spec) show ?thesis proof (cases p) case PRoot then show ?thesis using IH spec lang by (cases n) (auto simp: ℒ_eps_free ℒ_reflcl_reg) next case PNonRoot then show ?thesis using IH by (cases n) (auto simp: ℒ_eps_free ℒ_eps_free_nhole_ctxt_closure_reg[OF eps] ℒ_eps_free_nhole_mctxt_reflcl_reg[OF eps] ℒ_eps_free_nhole_mctxt_closure_reg[OF eps] lang intro: ℒ_nhole_ctxt_closure_reg_cong ℒ_nhole_mctxt_reflcl_reg_cong ℒ_nhole_mctxt_closure_reg_cong) next case PAny then show ?thesis using IH by (cases n) (auto simp: ℒ_eps_free ℒ_eps_free_ctxt_closure_reg[OF eps] ℒ_eps_free_parallel_closure_reg[OF eps] ℒ_eps_free_mctxt_closure_reg[OF eps] lang intro!: ℒ_ctxt_closure_reg_cong ℒ_parallel_closure_reg_cong ℒ_mctxt_closure_reg_cong) qed next case b then show ?thesis using IH by (cases p; cases n) auto qed next case (R2Comp x1 x2) then show ?case by (auto simp: liftO1_def rr2_compositon_def ℒ_trim ℒ_intersect Let_def intro!: ℒ_pair_automaton_reg_cong ℒ_fmap_funs_reg_cong collapse_reg_cong arg_cong2[where ?f = "(∩)"]) qed (auto simp: liftO1_def ℒ_intersect ℒ_union ℒ_trim ℒ_difference_reg intro!: ℒ_fmap_funs_reg_cong ℒ_pair_automaton_reg_cong) declare equalityI[intro!] declare fsubsetI[intro!] lemma rr12_of_rr12_rel_impl_correct: assumes "∀R ∈ set Rs. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ" shows "∀ta1. rr1_of_rr1_rel_impl ℱ Rs r1 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) r1)" "∀ta2. rr2_of_rr2_rel_impl ℱ Rs r2 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) r2)" using rr12_of_rr12_rel_correct(1)[OF assms, of r1] (*‹∀ta1. rr1_of_rr1_rel ℱ Rs r1 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) r1)›*) using rr12_of_rr12_rel_correct(2)[OF assms, of r2] (*‹∀ta2. rr2_of_rr2_rel ℱ Rs r2 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) r2)›*) using rr2_of_rr2_rel_impl_sound(1)[OF assms, of r1] (*‹⟦rr1_of_rr1_rel_impl ℱ Rs r1 = Some ?A; rr1_of_rr1_rel ℱ Rs r1 = Some ?B⟧ ⟹ ℒ ?A = ℒ ?B›*) using rr2_of_rr2_rel_impl_sound(2)[OF assms, of r2] (*‹⟦rr2_of_rr2_rel_impl ℱ Rs r2 = Some ?A; rr2_of_rr2_rel ℱ Rs r2 = Some ?B⟧ ⟹ ℒ ?A = ℒ ?B›*) using rr_of_rr_rel_impl_complete(1)[of ℱ Rs r1] (*‹(rr1_of_rr1_rel_impl (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (r1::ftrs rr1_rel) ≠ None) = (rr1_of_rr1_rel ℱ Rs r1 ≠ None)›*) using rr_of_rr_rel_impl_complete(2)[of ℱ Rs r2] (*‹(rr2_of_rr2_rel_impl ℱ Rs r2 ≠ None) = (rr2_of_rr2_rel ℱ Rs r2 ≠ None)›*) apply - (*goals: 1. ‹⟦∀ta1. rr1_of_rr1_rel ℱ Rs r1 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) r1); ∀ta2. rr2_of_rr2_rel ℱ Rs r2 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) r2); ⋀A B. ⟦rr1_of_rr1_rel_impl ℱ Rs r1 = Some A; rr1_of_rr1_rel ℱ Rs r1 = Some B⟧ ⟹ ℒ A = ℒ B; ⋀A B. ⟦rr2_of_rr2_rel_impl ℱ Rs r2 = Some A; rr2_of_rr2_rel ℱ Rs r2 = Some B⟧ ⟹ ℒ A = ℒ B; (rr1_of_rr1_rel_impl ℱ Rs r1 ≠ None) = (rr1_of_rr1_rel ℱ Rs r1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs r2 ≠ None) = (rr2_of_rr2_rel ℱ Rs r2 ≠ None)⟧ ⟹ ∀ta1. rr1_of_rr1_rel_impl ℱ Rs r1 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) r1)› 2. ‹⟦∀ta1. rr1_of_rr1_rel ℱ Rs r1 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) r1); ∀ta2. rr2_of_rr2_rel ℱ Rs r2 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) r2); ⋀A B. ⟦rr1_of_rr1_rel_impl ℱ Rs r1 = Some A; rr1_of_rr1_rel ℱ Rs r1 = Some B⟧ ⟹ ℒ A = ℒ B; ⋀A B. ⟦rr2_of_rr2_rel_impl ℱ Rs r2 = Some A; rr2_of_rr2_rel ℱ Rs r2 = Some B⟧ ⟹ ℒ A = ℒ B; (rr1_of_rr1_rel_impl ℱ Rs r1 ≠ None) = (rr1_of_rr1_rel ℱ Rs r1 ≠ None); (rr2_of_rr2_rel_impl ℱ Rs r2 ≠ None) = (rr2_of_rr2_rel ℱ Rs r2 ≠ None)⟧ ⟹ ∀ta2. rr2_of_rr2_rel_impl ℱ Rs r2 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) r2)› discuss goal 1*) apply (force simp: RR1_spec_def (*‹RR1_spec (?A::(?'a, ?'b) reg) (?T::?'b gterm set) = (ℒ ?A = ?T)›*) RR2_spec_def (*‹RR2_spec (?A::(?'a, ?'b option × ?'c option) reg) (?T::(?'b gterm × ?'c gterm) set) = (ℒ ?A = {gpair t u |(t::?'b gterm) u::?'c gterm. (t, u) ∈ ?T})›*)) (*discuss goal 2*) apply (force simp: RR1_spec_def (*‹RR1_spec ?A ?T = (ℒ ?A = ?T)›*) RR2_spec_def (*‹RR2_spec ?A ?T = (ℒ ?A = {gpair t u |t u. (t, u) ∈ ?T})›*)) (*proven 2 subgoals*) . lemma check_inference_rrn_impl_correct: assumes sig: "𝒯⇩G (fset ℱ) ≠ {}" and Rs: "∀R ∈ set Rs. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ" assumes infs: "⋀fvA. fvA ∈ set infs ⟹ formula_spec (fset ℱ) (map fset Rs) (fst (snd fvA)) (snd (snd fvA)) (fst fvA)" assumes inf: "check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs infs (l, step, fm, is) = Some (fm', vs, A')" shows "l = length infs ∧ fm = fm' ∧ formula_spec (fset ℱ) (map fset Rs) vs A' fm'" using check_inference_correct[where ?rr1c = rr1_of_rr1_rel_impl and ?rr2c = rr2_of_rr2_rel_impl, OF assms] (*‹⟦⋀fvA. fvA ∈ set infs ⟹ fvA ∈ set infs; ⋀r1. ∀ta1. rr1_of_rr1_rel_impl ℱ Rs r1 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) r1); ⋀r2. ∀ta2. rr2_of_rr2_rel_impl ℱ Rs r2 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) r2)⟧ ⟹ l = length infs ∧ fm = fm' ∧ formula_spec (fset ℱ) (map fset Rs) vs A' fm'›*) using rr12_of_rr12_rel_impl_correct[OF Rs] (*‹∀ta1. rr1_of_rr1_rel_impl ℱ Rs ?r1.0 = Some ta1 ⟶ RR1_spec ta1 (eval_rr1_rel (fset ℱ) (map fset Rs) ?r1.0)› ‹∀ta2. rr2_of_rr2_rel_impl ℱ Rs ?r2.0 = Some ta2 ⟶ RR2_spec ta2 (eval_rr2_rel (fset ℱ) (map fset Rs) ?r2.0)›*) by auto definition check_sig_nempty where "check_sig_nempty ℱ = (0 |∈| snd |`| ℱ)" definition check_trss where "check_trss ℛ ℱ = list_all (λ R. lv_trs (fset R) ∧ funas_trs (fset R) ⊆ fset ℱ) ℛ" lemma check_sig_nempty: "check_sig_nempty ℱ ⟷ 𝒯⇩G (fset ℱ) ≠ {}" (is "?Ls ⟷ ?Rs") proof (-) (*goal: ‹check_sig_nempty ℱ = (𝒯⇩G (fset ℱ) ≠ {})›*) { assume "?Ls" (*‹check_sig_nempty (ℱ::('a × fvar) fset)›*) then obtain a where "(a, 0) |∈| ℱ" (*goal: ‹(⋀a. (a, 0) |∈| ℱ ⟹ thesis) ⟹ thesis›*) by (auto simp: check_sig_nempty_def (*‹check_sig_nempty ?ℱ = (0 |∈| snd |`| ?ℱ)›*)) then have "GFun a [] ∈ 𝒯⇩G (fset ℱ)" apply (intro const (*‹(?a, 0) ∈ ?ℱ ⟹ GFun ?a [] ∈ 𝒯⇩G ?ℱ›*)) (*goal: ‹GFun a [] ∈ 𝒯⇩G (fset ℱ)›*) by simp then have "?Rs" by blast } moreover { assume "?Rs" (*‹𝒯⇩G (fset (ℱ::('a × fvar) fset)) ≠ {}›*) then obtain s where "s ∈ 𝒯⇩G (fset ℱ)" (*goal: ‹(⋀s::'a gterm. s ∈ 𝒯⇩G (fset (ℱ::('a × fvar) fset)) ⟹ thesis::bool) ⟹ thesis›*) by blast then obtain a where "(a, 0) |∈| ℱ" (*goal: ‹(⋀a. (a, 0) |∈| ℱ ⟹ thesis) ⟹ thesis›*) apply (induct s) (*goals: 1. ‹⋀a. ⟦(a, 0) |∈| ℱ; ⋀a. (a, 0) |∈| ℱ ⟹ thesis⟧ ⟹ thesis› 2. ‹⋀f n ss. ⟦(f, n) |∈| ℱ; length ss = n; ⋀i. i < length ss ⟹ ss ! i ∈ 𝒯⇩G (fset ℱ); ⋀i. ⟦i < length ss; ⋀a. (a, 0) |∈| ℱ ⟹ thesis⟧ ⟹ thesis; ⋀a. (a, 0) |∈| ℱ ⟹ thesis⟧ ⟹ thesis› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*goal: ‹⋀f n ss. ⟦(f, n) |∈| ℱ; length ss = n; ⋀i. i < length ss ⟹ ss ! i ∈ 𝒯⇩G (fset ℱ); ⋀i. ⟦i < length ss; ⋀a. (a, 0) |∈| ℱ ⟹ thesis⟧ ⟹ thesis; ⋀a. (a, 0) |∈| ℱ ⟹ thesis⟧ ⟹ thesis›*) apply force (*proven 2 subgoals*) . then have "?Ls" unfolding check_sig_nempty_def (*goal: ‹0 |∈| snd |`| ℱ›*) by (auto simp: image_iff (*‹((?z::?'a) ∈ (?f::?'b ⇒ ?'a) ` (?A::?'b set)) = (∃x::?'b∈?A. ?z = ?f x)›*) Bex_def (*‹Bex (?A::?'a set) (?P::?'a ⇒ bool) = (∃x::?'a. x ∈ ?A ∧ ?P x)›*)) } ultimately show "?thesis" (*goal: ‹check_sig_nempty ℱ = (𝒯⇩G (fset ℱ) ≠ {})›*) by blast qed lemma check_trss: "check_trss ℛ ℱ ⟷ (∀ R ∈ set ℛ. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ)" unfolding check_trss_def list_all_iff (*goal: ‹(∀R∈set ℛ. lv_trs (fset R) ∧ funas_trs (fset R) ⊆ fset ℱ) = (∀R∈set ℛ. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ)›*) by (auto simp: ffunas_trs.rep_eq (*‹fset (ffunas_trs ?x) = funas_trs (fset ?x)›*) less_eq_fset.rep_eq (*‹(?x |⊆| ?xa) = (fset ?x ⊆ fset ?xa)›*)) fun check_inference_list :: "('f × nat) fset ⇒ ('f :: {compare,linorder}, 'v) fin_trs list ⇒ (nat × ftrs inference × ftrs formula × info list) list ⇒ (ftrs formula × nat list × (nat, 'f option list) reg) list option" where "check_inference_list ℱ Rs infs = do { guard (check_sig_nempty ℱ); guard (check_trss Rs ℱ); foldl (λ tas inf. do { tas' ← tas; r ← check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs tas' inf; Some (tas' @ [r]) }) (Some []) infs }" lemma check_inference_list_correct: assumes "check_inference_list ℱ Rs infs = Some fvAs" shows "length infs = length fvAs ∧ (∀ i < length fvAs. fst (snd (snd (infs ! i))) = fst (fvAs ! i)) ∧ (∀ i < length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i)))" using assms (*‹check_inference_list ℱ Rs infs = Some fvAs›*) proof (induct infs arbitrary: fvAs rule: rev_induct) (*goals: 1. ‹⋀fvAs. check_inference_list ℱ Rs [] = Some fvAs ⟹ length [] = length fvAs ∧ (∀i<length fvAs. fst (snd (snd ([] ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i)))› 2. ‹⋀x xs fvAs. ⟦⋀fvAs. check_inference_list ℱ Rs xs = Some fvAs ⟹ length xs = length fvAs ∧ (∀i<length fvAs. fst (snd (snd (xs ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i))); check_inference_list ℱ Rs (xs @ [x]) = Some fvAs⟧ ⟹ length (xs @ [x]) = length fvAs ∧ (∀i<length fvAs. fst (snd (snd ((xs @ [x]) ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i)))›*) note [simp] = bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) guard_simps (*‹(guard ?b = Some ?x) = ?b› ‹(guard ?b = None) = (¬ ?b)›*) { case Nil (*‹check_inference_list ℱ Rs [] = Some fvAs›*) then show "?case" (*goal: ‹length [] = length fvAs ∧ (∀i<length fvAs. fst (snd (snd ([] ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i)))›*) by auto next (*goal: ‹⋀x xs fvAs. ⟦⋀fvAs. check_inference_list ℱ Rs xs = Some fvAs ⟹ length xs = length fvAs ∧ (∀i<length fvAs. fst (snd (snd (xs ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i))); check_inference_list ℱ Rs (xs @ [x]) = Some fvAs⟧ ⟹ length (xs @ [x]) = length fvAs ∧ (∀i<length fvAs. fst (snd (snd ((xs @ [x]) ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i)))›*) case (snoc a infs) (*‹check_inference_list ℱ Rs infs = Some ?fvAs ⟹ length infs = length ?fvAs ∧ (∀i<length ?fvAs. fst (snd (snd (infs ! i))) = fst (?fvAs ! i)) ∧ (∀i<length ?fvAs. formula_spec (fset ℱ) (map fset Rs) (fst (snd (?fvAs ! i))) (snd (snd (?fvAs ! i))) (fst (?fvAs ! i)))› ‹check_inference_list ℱ Rs (infs @ [a]) = Some fvAs›*) have inv: "𝒯⇩G (fset ℱ) ≠ {}" "∀R∈set Rs. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ" using snoc(2) (*‹check_inference_list ℱ Rs (infs @ [a]) = Some fvAs›*) apply - (*goals: 1. ‹check_inference_list ℱ Rs (infs @ [a]) = Some fvAs ⟹ 𝒯⇩G (fset ℱ) ≠ {}› 2. ‹check_inference_list ℱ Rs (infs @ [a]) = Some fvAs ⟹ ∀R∈set Rs. lv_trs (fset R) ∧ ffunas_trs R |⊆| ℱ› discuss goal 1*) apply ((auto simp: check_sig_nempty (*‹check_sig_nempty ?ℱ = (𝒯⇩G (fset ?ℱ) ≠ {})›*) check_trss (*‹check_trss ?ℛ ?ℱ = (∀R∈set ?ℛ. lv_trs (fset R) ∧ ffunas_trs R |⊆| ?ℱ)›*))[1]) (*discuss goal 2*) apply ((auto simp: check_sig_nempty (*‹check_sig_nempty ?ℱ = (𝒯⇩G (fset ?ℱ) ≠ {})›*) check_trss (*‹check_trss ?ℛ ?ℱ = (∀R∈set ?ℛ. lv_trs (fset R) ∧ ffunas_trs R |⊆| ?ℱ)›*))[1]) (*proven 2 subgoals*) . from snoc(2) (*‹check_inference_list ℱ Rs (infs @ [a]) = Some fvAs›*) obtain fvAs' and l and steps and fm and fm' and is' and vs and A' where ch: "check_inference_list ℱ Rs infs = Some fvAs'" "a = (l, steps, fm, is')" "check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs fvAs' (l, steps, fm, is') = Some (fm', vs, A')" "fvAs = fvAs' @ [(fm', vs, A')]" (*goal: ‹(⋀fvAs' l steps fm is' fm' vs A'. ⟦check_inference_list ℱ Rs infs = Some fvAs'; a = (l, steps, fm, is'); check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs fvAs' (l, steps, fm, is') = Some (fm', vs, A'); fvAs = fvAs' @ [(fm', vs, A')]⟧ ⟹ thesis) ⟹ thesis›*) apply (auto simp del: check_inference.simps (*‹check_inference ?rr1c ?rr2c ?ℱ ?Rs ?infs (?l, ?step, ?fm, ?is) = guard (?l = length ?infs) ⤜ (λ_. case ?step of IRR1 s x ⇒ guard (?fm = FRR1 s x) ⤜ (λ_. liftO1 (λta. (FRR1 s x, [x], fmap_funs_reg (λf. [Some f]) ta)) (?rr1c ?ℱ ?Rs s)) | IRR2 r x y ⇒ guard (?fm = FRR2 r x y) ⤜ (λ_. case compare x y of Eq ⇒ liftO1 (λta. (FRR2 r x y, [x], fmap_funs_reg (λf. [Some f]) ta)) (liftO1 (simplify_reg ∘ proj_1_reg) (liftO2 (λt1 t2. simplify_reg (reg_intersect t1 t2)) (?rr2c ?ℱ ?Rs r) (?rr2c ?ℱ ?Rs (R2Diag R1Terms)))) | Lt ⇒ liftO1 (λta. (FRR2 r x y, [x, y], RR2_to_RRn ta)) (?rr2c ?ℱ ?Rs r) | Gt ⇒ liftO1 (λta. (FRR2 r x y, [y, x], fmap_funs_reg (λ(f, g). [g, f]) ta)) (?rr2c ?ℱ ?Rs r)) | IAnd ls ⇒ guard (∀l'∈set ls. l' < ?l) ⤜ (λ_. guard (?fm = FAnd (map (λl'. fst (?infs ! l')) ls)) ⤜ (λ_. let (vs', tas') = fit_rrns ?ℱ (map ((!) ?infs) ls) in Some (?fm, vs', fand_rrn ?ℱ (length vs') tas'))) | IOr ls ⇒ guard (∀l'∈set ls. l' < ?l) ⤜ (λ_. guard (?fm = FOr (map (λl'. fst (?infs ! l')) ls)) ⤜ (λ_. let (vs', tas') = fit_rrns ?ℱ (map ((!) ?infs) ls) in Some (?fm, vs', for_rrn tas'))) | INot l' ⇒ guard (l' < ?l) ⤜ (λ_. guard (?fm = FNot (fst (?infs ! l'))) ⤜ (λ_. let (vs', tas') = snd (?infs ! l') in Some (?fm, vs', simplify_reg (difference_reg (true_RRn ?ℱ (length vs')) tas')))) | IExists l' ⇒ guard (l' < ?l) ⤜ (λ_. guard (?fm = FExists (fst (?infs ! l'))) ⤜ (λ_. let (vs', tas') = snd (?infs ! l') in if length vs' = 0 then Some (?fm, [], tas') else if reg_empty tas' then Some (?fm, [], empty_reg) else if 0 ∉ set vs' then Some (?fm, map (λx. x - 1) vs', tas') else if 1 = length vs' then Some (?fm, [], true_RRn ?ℱ 0) else Some (?fm, upd_bruijn vs', rrn_drop_fst tas'))) | IRename l' vs ⇒ guard (l' < ?l) ⤜ (λ_. None) | INNFPlus l' ⇒ guard (l' < ?l) ⤜ (λ_. let fm' = fst (?infs ! l') in guard (ord_form_list_aci (nnf_to_list_aci (nnf (form_of_formula fm'))) = ord_form_list_aci (nnf_to_list_aci (nnf (form_of_formula ?fm)))) ⤜ (λ_. Some (?fm, snd (?infs ! l')))) | IRepl eq pos l' ⇒ guard (l' < ?l) ⤜ (λ_. None))›*)) (*goal: ‹(⋀(fvAs'::(ftrs formula × fvar list × (fvar, 'a option list) reg) list) (l::fvar) (steps::ftrs inference) (fm::ftrs formula) (is'::info list) (fm'::ftrs formula) (vs::fvar list) A'::(fvar, 'a option list) reg. ⟦check_inference_list (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (infs::(fvar × ftrs inference × ftrs formula × info list) list) = Some fvAs'; (a::fvar × ftrs inference × ftrs formula × info list) = (l, steps, fm, is'); check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs fvAs' (l, steps, fm, is') = Some (fm', vs, A'); (fvAs::(ftrs formula × fvar list × (fvar, 'a option list) reg) list) = fvAs' @ [(fm', vs, A')]⟧ ⟹ thesis::bool) ⟹ thesis›*) by (metis prod_cases4 (*‹(⋀a b c d. ?y = (a, b, c, d) ⟹ ?thesis) ⟹ ?thesis›*)) from snoc(1)[OF ch ( 1 )] (*‹length (infs::(fvar × ftrs inference × ftrs formula × info list) list) = length (fvAs'::(ftrs formula × fvar list × (fvar, 'a option list) reg) list) ∧ (∀i<length fvAs'. fst (snd (snd (infs ! i))) = fst (fvAs' ! i)) ∧ (∀i<length fvAs'. formula_spec (fset (ℱ::('a × fvar) fset)) (map fset (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list)) (fst (snd (fvAs' ! i))) (snd (snd (fvAs' ! i))) (fst (fvAs' ! i)))›*) have "fvA ∈ set fvAs' ⟹ formula_spec (fset ℱ) (map fset Rs) (fst (snd fvA)) (snd (snd fvA)) (fst fvA)" for fvA by (auto dest: in_set_idx (*‹(?x::?'a) ∈ set (?xs::?'a list) ⟹ ∃i<length ?xs. ?xs ! i = ?x›*)) from check_inference_rrn_impl_correct[OF inv this, of fvAs'] (*‹⟦⋀fvA. fvA ∈ set fvAs' ⟹ fvA ∈ set fvAs'; check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs fvAs' (?l, ?step, ?fm, ?is) = Some (?fm', ?vs, ?A')⟧ ⟹ ?l = length fvAs' ∧ ?fm = ?fm' ∧ formula_spec (fset ℱ) (map fset Rs) ?vs ?A' ?fm'›*) this (*‹?fvA ∈ set fvAs' ⟹ formula_spec (fset ℱ) (map fset Rs) (fst (snd ?fvA)) (snd (snd ?fvA)) (fst ?fvA)›*) show "?case" (*goal: ‹length ((infs::(fvar × ftrs inference × ftrs formula × info list) list) @ [a::fvar × ftrs inference × ftrs formula × info list]) = length (fvAs::(ftrs formula × fvar list × (fvar, 'a option list) reg) list) ∧ (∀i<length fvAs. fst (snd (snd ((infs @ [a]) ! i))) = fst (fvAs ! i)) ∧ (∀i<length fvAs. formula_spec (fset (ℱ::('a × fvar) fset)) (map fset (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list)) (fst (snd (fvAs ! i))) (snd (snd (fvAs ! i))) (fst (fvAs ! i)))›*) using snoc(1)[OF ch ( 1 )] (*‹length infs = length fvAs' ∧ (∀i<length fvAs'. fst (snd (snd (infs ! i))) = fst (fvAs' ! i)) ∧ (∀i<length fvAs'. formula_spec (fset ℱ) (map fset Rs) (fst (snd (fvAs' ! i))) (snd (snd (fvAs' ! i))) (fst (fvAs' ! i)))›*) ch (*‹check_inference_list (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (infs::(fvar × ftrs inference × ftrs formula × info list) list) = Some (fvAs'::(ftrs formula × fvar list × (fvar, 'a option list) reg) list)› ‹(a::fvar × ftrs inference × ftrs formula × info list) = (l::fvar, steps::ftrs inference, fm::ftrs formula, is'::info list)› ‹check_inference rr1_of_rr1_rel_impl rr2_of_rr2_rel_impl ℱ Rs fvAs' (l, steps, fm, is') = Some (fm', vs, A')› ‹fvAs = fvAs' @ [(fm', vs, A')]›*) by (auto simp del: check_inference.simps (*‹check_inference ?rr1c ?rr2c ?ℱ ?Rs ?infs (?l, ?step, ?fm, ?is) = guard (?l = length ?infs) ⤜ (λ_. case ?step of IRR1 s x ⇒ guard (?fm = FRR1 s x) ⤜ (λ_. liftO1 (λta. (FRR1 s x, [x], fmap_funs_reg (λf. [Some f]) ta)) (?rr1c ?ℱ ?Rs s)) | IRR2 r x y ⇒ guard (?fm = FRR2 r x y) ⤜ (λ_. case compare x y of Eq ⇒ liftO1 (λta. (FRR2 r x y, [x], fmap_funs_reg (λf. [Some f]) ta)) (liftO1 (simplify_reg ∘ proj_1_reg) (liftO2 (λt1 t2. simplify_reg (reg_intersect t1 t2)) (?rr2c ?ℱ ?Rs r) (?rr2c ?ℱ ?Rs (R2Diag R1Terms)))) | Lt ⇒ liftO1 (λta. (FRR2 r x y, [x, y], RR2_to_RRn ta)) (?rr2c ?ℱ ?Rs r) | Gt ⇒ liftO1 (λta. (FRR2 r x y, [y, x], fmap_funs_reg (λ(f, g). [g, f]) ta)) (?rr2c ?ℱ ?Rs r)) | IAnd ls ⇒ guard (∀l'∈set ls. l' < ?l) ⤜ (λ_. guard (?fm = FAnd (map (λl'. fst (?infs ! l')) ls)) ⤜ (λ_. let (vs', tas') = fit_rrns ?ℱ (map ((!) ?infs) ls) in Some (?fm, vs', fand_rrn ?ℱ (length vs') tas'))) | IOr ls ⇒ guard (∀l'∈set ls. l' < ?l) ⤜ (λ_. guard (?fm = FOr (map (λl'. fst (?infs ! l')) ls)) ⤜ (λ_. let (vs', tas') = fit_rrns ?ℱ (map ((!) ?infs) ls) in Some (?fm, vs', for_rrn tas'))) | INot l' ⇒ guard (l' < ?l) ⤜ (λ_. guard (?fm = FNot (fst (?infs ! l'))) ⤜ (λ_. let (vs', tas') = snd (?infs ! l') in Some (?fm, vs', simplify_reg (difference_reg (true_RRn ?ℱ (length vs')) tas')))) | IExists l' ⇒ guard (l' < ?l) ⤜ (λ_. guard (?fm = FExists (fst (?infs ! l'))) ⤜ (λ_. let (vs', tas') = snd (?infs ! l') in if length vs' = 0 then Some (?fm, [], tas') else if reg_empty tas' then Some (?fm, [], empty_reg) else if 0 ∉ set vs' then Some (?fm, map (λx. x - 1) vs', tas') else if 1 = length vs' then Some (?fm, [], true_RRn ?ℱ 0) else Some (?fm, upd_bruijn vs', rrn_drop_fst tas'))) | IRename l' vs ⇒ guard (l' < ?l) ⤜ (λ_. None) | INNFPlus l' ⇒ guard (l' < ?l) ⤜ (λ_. let fm' = fst (?infs ! l') in guard (ord_form_list_aci (nnf_to_list_aci (nnf (form_of_formula fm'))) = ord_form_list_aci (nnf_to_list_aci (nnf (form_of_formula ?fm)))) ⤜ (λ_. Some (?fm, snd (?infs ! l')))) | IRepl eq pos l' ⇒ guard (l' < ?l) ⤜ (λ_. None))›*) simp: nth_append (*‹(?xs @ ?ys) ! ?n = (if ?n < length ?xs then ?xs ! ?n else ?ys ! (?n - length ?xs))›*)) } qed fun check_certificate where "check_certificate ℱ Rs A fm (Certificate infs claim n) = do { guard (n < length infs); guard (A ⟷ claim = Nonempty); guard (fm = fst (snd (snd (infs ! n)))); fvA ← check_inference_list ℱ Rs (take (Suc n) infs); (let E = reg_empty (snd (snd (last fvA))) in case claim of Empty ⇒ Some E | _ ⇒ Some (¬ E)) }" definition formula_unsatisfiable where "formula_unsatisfiable ℱ Rs fm ⟷ (formula_satisfiable ℱ Rs fm = False)" definition correct_certificate where "correct_certificate ℱ Rs claim infs n ≡ (claim = Empty ⟷ (formula_unsatisfiable (fset ℱ) (map fset Rs) (fst (snd (snd (infs ! n))))) ∧ claim = Nonempty ⟷ formula_satisfiable (fset ℱ) (map fset Rs) (fst (snd (snd (infs ! n)))))" lemma check_certificate_sound: assumes "check_certificate ℱ Rs A fm (Certificate infs claim n) = Some B" shows "fm = fst (snd (snd (infs ! n)))" "A ⟷ claim = Nonempty" using assms (*‹check_certificate ℱ Rs A fm (Certificate infs claim n) = Some B›*) apply - (*goals: 1. ‹check_certificate (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (A::bool) (fm::ftrs formula) (Certificate (infs::(fvar × ftrs inference × ftrs formula × info list) list) (claim::claim) (n::fvar)) = Some (B::bool) ⟹ fm = fst (snd (snd (infs ! n)))› 2. ‹check_certificate (ℱ::('a × fvar) fset) (Rs::(('a, 'b) Term.term × ('a, 'b) Term.term) fset list) (A::bool) (fm::ftrs formula) (Certificate (infs::(fvar × ftrs inference × ftrs formula × info list) list) (claim::claim) (n::fvar)) = Some (B::bool) ⟹ A = (claim = Nonempty)› discuss goal 1*) apply ((auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) guard_simps (*‹(guard ?b = Some ?x) = ?b› ‹(guard ?b = None) = (¬ ?b)›*))[1]) (*discuss goal 2*) apply ((auto simp: bind_eq_Some_conv (*‹(?f ⤜ ?g = Some ?x) = (∃y. ?f = Some y ∧ ?g y = Some ?x)›*) guard_simps (*‹(guard ?b = Some ?x) = ?b› ‹(guard ?b = None) = (¬ ?b)›*))[1]) (*proven 2 subgoals*) . lemma check_certificate_correct: assumes "check_certificate ℱ Rs A fm (Certificate infs claim n) = Some B" shows "(B = True ⟶ correct_certificate ℱ Rs claim infs n) ∧ (B = False ⟶ correct_certificate ℱ Rs (case_claim Nonempty Empty claim) infs n)" proof - note [simp] = bind_eq_Some_conv guard_simps from assms obtain fvAs where inf: "check_inference_list ℱ Rs (take (Suc n) infs) = Some fvAs" by auto from assms have len: "n < length infs" by auto from check_inference_list_correct[OF inf] have inv: "length fvAs = n + 1" "fst (snd (snd (infs ! n))) = fst (fvAs ! n)" "formula_spec (fset ℱ) (map fset Rs) (fst (snd (last fvAs))) (snd (snd (last fvAs))) (fst (last fvAs))" using len last_conv_nth[of fvAs] by force+ have nth: "fst (last fvAs) = fst (fvAs ! n)" using inv(1) using len last_conv_nth[of fvAs] by force note spec = formula_spec_empty[OF _ inv(3)] formula_spec_nt_empty_form_sat[OF _ inv(3)] consider (a) "claim = Empty" | (b) "claim = Nonempty" using claim.exhaust by blast then show ?thesis proof cases case a then have *: "B = reg_empty (snd (snd (last fvAs)))" using inv using assms len last_conv_nth[of fvAs] by (auto simp: inf simp del: check_inference_list.simps) show ?thesis using a inv spec unfolding * by (auto simp: formula_satisfiable_def nth correct_certificate_def formula_unsatisfiable_def simp del: reg_empty) next case b then have *: "B ⟷ ¬ (reg_empty (snd (snd (last fvAs))))" using inv using assms len last_conv_nth[of fvAs] by (auto simp: inf simp del: check_inference_list.simps) show ?thesis using b inv spec unfolding * by (auto simp: formula_satisfiable_def nth formula_unsatisfiable_def correct_certificate_def simp del: reg_empty) qed qed definition check_certificate_string :: "(integer list × fvar) fset ⇒ ((integer list, integer list) Term.term × (integer list, integer list) Term.term) fset list ⇒ bool ⇒ ftrs formula ⇒ ftrs certificate ⇒ bool option" where "check_certificate_string = check_certificate" (***********************************) export_code check_certificate_string Var Fun fset_of_list nat_of_integer Certificate R2GTT_Rel R2Eq R2Reflc R2Step R2StepEq R2Steps R2StepsEq R2StepsNF R2ParStep R2RootStep R2RootStepEq R2RootSteps R2RootStepsEq R2NonRootStep R2NonRootStepEq R2NonRootSteps R2NonRootStepsEq R2Meet R2Join ARoot GSteps PRoot ESingle Empty Size EDistribAndOr R1Terms R1Fin FRR1 FRestrict FTrue FFalse IRR1 Fwd in Haskell module_name FOR end
{ "path": "afp-2025-02-12/thys/FO_Theory_Rewriting/FOR_Check_Impl.thy", "repo": "afp-2025-02-12", "sha": "faacafa8304d01c78e7a3f5f8b8537b027f34901f7476319fab6d57b76172ecd" }
(* Title: JinjaThreads/Compiler/J1WellForm.thy Author: Andreas Lochbihler, Tobias Nipkow *) section ‹Well-Formedness of Intermediate Language› theory J1WellForm imports "../J/DefAss" J1WellType begin subsection‹Well-formedness› definition wf_J1_mdecl :: "'addr J1_prog ⇒ cname ⇒ 'addr expr1 mdecl ⇒ bool" where "wf_J1_mdecl P C ≡ λ(M,Ts,T,body). (∃T'. P,Class C#Ts ⊢1 body :: T' ∧ P ⊢ T' ≤ T) ∧ 𝒟 body ⌊{..size Ts}⌋ ∧ ℬ body (size Ts + 1) ∧ syncvars body" lemma wf_J1_mdecl[simp]: "wf_J1_mdecl P C (M,Ts,T,body) ≡ ((∃T'. P,Class C#Ts ⊢1 body :: T' ∧ P ⊢ T' ≤ T) ∧ 𝒟 body ⌊{..size Ts}⌋ ∧ ℬ body (size Ts + 1)) ∧ syncvars body" by (simp add:wf_J1_mdecl_def (*‹wf_J1_mdecl ?P ?C ≡ λ(M, Ts, T, body). (∃T'. ?P,Class ?C # Ts ⊢1 body :: T' ∧ ?P ⊢ T' ≤ T) ∧ 𝒟 body ⌊{..length Ts}⌋ ∧ ℬ body (length Ts + 1) ∧ syncvars body›*)) abbreviation wf_J1_prog :: "'addr J1_prog ⇒ bool" where "wf_J1_prog == wf_prog wf_J1_mdecl" end
{ "path": "afp-2025-02-12/thys/JinjaThreads/Compiler/J1WellForm.thy", "repo": "afp-2025-02-12", "sha": "486e355c75f1e4a3c937c08159db4b6e91f8e871346a9c007d3e7847427dde88" }
section ‹Some Facts About Number-Theoretic Functions› theory Number_Theoretic_Functions_Extras imports "Dirichlet_Series.Dirichlet_Series_Analysis" "Dirichlet_Series.Divisor_Count" Lambert_Series_Library begin lemma (in nat_power_field) nat_power_minus: "a ≠ 0 ∨ n ≠ 0 ⟹ nat_power n (-a) = inverse (nat_power n a)" using nat_power_diff[of n 0 a] (*‹0 < n ⟹ nat_power n (0 - a) = nat_power n 0 / nat_power n a›*) apply (cases "n = 0") (*goals: 1. ‹⟦(a::'a) ≠ (0::'a) ∨ (n::nat) ≠ (0::nat); (0::nat) < n ⟹ nat_power n ((0::'a) - a) = nat_power n (0::'a) / nat_power n a; n = (0::nat)⟧ ⟹ nat_power n (- a) = inverse (nat_power n a)› 2. ‹⟦(a::'a) ≠ (0::'a) ∨ (n::nat) ≠ (0::nat); (0::nat) < n ⟹ nat_power n ((0::'a) - a) = nat_power n (0::'a) / nat_power n a; n ≠ (0::nat)⟧ ⟹ nat_power n (- a) = inverse (nat_power n a)› discuss goal 1*) apply (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 108 facts*)) (*discuss goal 2*) apply (simp add: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 108 facts*)) (*proven 2 subgoals*) . lemma divisor_sigma_minus: fixes a :: "'a :: {nat_power_field, field_char_0}" shows "divisor_sigma (-a) n = divisor_sigma a n / nat_power n a" proof (cases "n = 0") (*goals: 1. ‹n = 0 ⟹ divisor_sigma (- a) n = divisor_sigma a n / nat_power n a› 2. ‹n ≠ 0 ⟹ divisor_sigma (- a) n = divisor_sigma a n / nat_power n a›*) case n: False (*‹n ≠ 0›*) have "divisor_sigma (-a :: 'a) n = (∑d | d dvd n. nat_power d (-a))" by (simp add: divisor_sigma_def (*‹divisor_sigma ?x ?n = (∑d | d dvd ?n. nat_power d ?x)›*)) also (*calculation: ‹divisor_sigma (- a) n = (∑d | d dvd n. nat_power d (- a))›*) have "… = (∑d | d dvd n. nat_power d a / nat_power n a)" using n (*‹n ≠ 0›*) apply (intro sum.reindex_bij_witness[of _ "λd. n div d" "λd. n div d"] (*‹⟦⋀a. a ∈ ?S ⟹ n div (n div a) = a; ⋀a. a ∈ ?S ⟹ n div a ∈ ?T; ⋀b. b ∈ ?T ⟹ n div (n div b) = b; ⋀b. b ∈ ?T ⟹ n div b ∈ ?S; ⋀a. a ∈ ?S ⟹ ?h (n div a) = ?g a⟧ ⟹ sum ?g ?S = sum ?h ?T›*)) (*goals: 1. ‹⋀a::nat. ⟦(n::nat) ≠ (0::nat); a ∈ {d::nat. d dvd n}⟧ ⟹ n div (n div a) = a› 2. ‹⋀a::nat. ⟦(n::nat) ≠ (0::nat); a ∈ {d::nat. d dvd n}⟧ ⟹ n div a ∈ {d::nat. d dvd n}› 3. ‹⋀b::nat. ⟦(n::nat) ≠ (0::nat); b ∈ {d::nat. d dvd n}⟧ ⟹ n div (n div b) = b› 4. ‹⋀b::nat. ⟦(n::nat) ≠ (0::nat); b ∈ {d::nat. d dvd n}⟧ ⟹ n div b ∈ {d::nat. d dvd n}› 5. ‹⋀aa::nat. ⟦(n::nat) ≠ (0::nat); aa ∈ {d::nat. d dvd n}⟧ ⟹ nat_power (n div aa) (a::'a::{nat_power_field,field_char_0}) / nat_power n a = nat_power aa (- a)› discuss goal 1*) apply ((auto elim!: dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*) simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) nat_power_minus (*‹?a ≠ 0 ∨ ?n ≠ 0 ⟹ nat_power ?n (- ?a) = inverse (nat_power ?n ?a)›*) nat_power_mult_distrib (*‹⟦0 < ?m; 0 < ?n⟧ ⟹ nat_power (?m * ?n) ?a = nat_power ?m ?a * nat_power ?n ?a›*))[1]) (*discuss goal 2*) apply ((auto elim!: dvdE (*‹⟦(?b::?'a) dvd (?a::?'a); ⋀k::?'a. ?a = ?b * k ⟹ ?P::bool⟧ ⟹ ?P›*) simp: field_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 77 facts*) nat_power_minus (*‹(?a::?'a) ≠ (0::?'a) ∨ (?n::nat) ≠ (0::nat) ⟹ nat_power ?n (- ?a) = inverse (nat_power ?n ?a)›*) nat_power_mult_distrib (*‹⟦(0::nat) < (?m::nat); (0::nat) < (?n::nat)⟧ ⟹ nat_power (?m * ?n) (?a::?'a) = nat_power ?m ?a * nat_power ?n ?a›*))[1]) (*discuss goal 3*) apply ((auto elim!: dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*) simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) nat_power_minus (*‹?a ≠ 0 ∨ ?n ≠ 0 ⟹ nat_power ?n (- ?a) = inverse (nat_power ?n ?a)›*) nat_power_mult_distrib (*‹⟦0 < ?m; 0 < ?n⟧ ⟹ nat_power (?m * ?n) ?a = nat_power ?m ?a * nat_power ?n ?a›*))[1]) (*discuss goal 4*) apply ((auto elim!: dvdE (*‹⟦(?b::?'a) dvd (?a::?'a); ⋀k::?'a. ?a = ?b * k ⟹ ?P::bool⟧ ⟹ ?P›*) simp: field_simps (*‹(?a::?'a) + (?b::?'a) + (?c::?'a) = ?a + (?b + ?c)› ‹(?a::?'a) + (?b::?'a) = ?b + ?a› ‹(?b::?'a) + ((?a::?'a) + (?c::?'a)) = ?a + (?b + ?c)› ‹(?a::?'a) * (?b::?'a) * (?c::?'a) = ?a * (?b * ?c)› ‹(?a::?'a) * (?b::?'a) = ?b * ?a› ‹(?b::?'a) * ((?a::?'a) * (?c::?'a)) = ?a * (?b * ?c)› ‹(?a::?'a) - (?b::?'a) - (?c::?'a) = ?a - (?b + ?c)› ‹(?a::?'a) + ((?b::?'a) - (?c::?'a)) = ?a + ?b - ?c› ‹((?a::?'a) - (?b::?'a) = (?c::?'a)) = (?a = ?c + ?b)› ‹((?a::?'a) = (?c::?'a) - (?b::?'a)) = (?a + ?b = ?c)› ‹(?a::?'a) - ((?b::?'a) - (?c::?'a)) = ?a + ?c - ?b› ‹(?a::?'a) - (?b::?'a) + (?c::?'a) = ?a + ?c - ?b› and more 77 facts*) nat_power_minus (*‹(?a::?'a) ≠ (0::?'a) ∨ (?n::nat) ≠ (0::nat) ⟹ nat_power ?n (- ?a) = inverse (nat_power ?n ?a)›*) nat_power_mult_distrib (*‹⟦(0::nat) < (?m::nat); (0::nat) < (?n::nat)⟧ ⟹ nat_power (?m * ?n) (?a::?'a) = nat_power ?m ?a * nat_power ?n ?a›*))[1]) (*discuss goal 5*) apply ((auto elim!: dvdE (*‹⟦?b dvd ?a; ⋀k. ?a = ?b * k ⟹ ?P⟧ ⟹ ?P›*) simp: field_simps (*‹?a + ?b + ?c = ?a + (?b + ?c)› ‹?a + ?b = ?b + ?a› ‹?b + (?a + ?c) = ?a + (?b + ?c)› ‹?a * ?b * ?c = ?a * (?b * ?c)› ‹?a * ?b = ?b * ?a› ‹?b * (?a * ?c) = ?a * (?b * ?c)› ‹?a - ?b - ?c = ?a - (?b + ?c)› ‹?a + (?b - ?c) = ?a + ?b - ?c› ‹(?a - ?b = ?c) = (?a = ?c + ?b)› ‹(?a = ?c - ?b) = (?a + ?b = ?c)› ‹?a - (?b - ?c) = ?a + ?c - ?b› ‹?a - ?b + ?c = ?a + ?c - ?b› and more 77 facts*) nat_power_minus (*‹?a ≠ 0 ∨ ?n ≠ 0 ⟹ nat_power ?n (- ?a) = inverse (nat_power ?n ?a)›*) nat_power_mult_distrib (*‹⟦0 < ?m; 0 < ?n⟧ ⟹ nat_power (?m * ?n) ?a = nat_power ?m ?a * nat_power ?n ?a›*))[1]) (*proven 5 subgoals*) . also (*calculation: ‹divisor_sigma (- (a::'a)) (n::nat) = (∑d::nat | d dvd n. nat_power d a / nat_power n a)›*) have "… = divisor_sigma a n / nat_power n a" by (simp add: sum_divide_distrib (*‹sum ?f ?A / ?r = (∑n∈?A. ?f n / ?r)›*) divisor_sigma_def (*‹divisor_sigma ?x ?n = (∑d | d dvd ?n. nat_power d ?x)›*)) finally (*calculation: ‹divisor_sigma (- a) n = divisor_sigma a n / nat_power n a›*) show "?thesis" (*goal: ‹divisor_sigma (- a) n = divisor_sigma a n / nat_power n a›*) . qed (auto) (*solved the remaining goal: ‹n = 0 ⟹ divisor_sigma (- a) n = divisor_sigma a n / nat_power n a›*) lemma norm_moebius_mu: "norm (moebius_mu n ::'a :: {real_normed_algebra_1, comm_ring_1}) = ind squarefree n" apply (subst of_int_moebius_mu [symmetric] (*‹moebius_mu ?n = of_int (moebius_mu ?n)›*)) (*goal: ‹norm (moebius_mu n) = ind squarefree n›*) apply (subst norm_of_int (*‹norm (of_int (?z::int)) = ¦real_of_int ?z¦›*)) (*goal: ‹norm (of_int (moebius_mu (n::nat))) = ind squarefree n›*) by (auto simp: abs_moebius_mu (*‹¦moebius_mu ?n¦ = ind squarefree ?n›*)) lemma conv_radius_nat_power: "conv_radius (λn. nat_power n a :: 'a :: {nat_power_normed_field, banach}) = 1" proof (rule tendsto_imp_conv_radius_eq (*‹⟦(λn. ereal (norm (?f n) powr (1 / real n))) ⇢ ?c'; ?c = inverse ?c'⟧ ⟹ conv_radius ?f = ?c›*)) (*goals: 1. ‹(λn. ereal (norm (nat_power n a) powr (1 / real n))) ⇢ ?c'› 2. ‹1 = inverse ?c'›*) show "(λn. ereal (norm (nat_power n a :: 'a) powr (1 / real n))) ⇢ ereal 1" proof (rule Lim_transform_eventually (*‹⟦(?f ⤏ ?l) ?F; ∀⇩F x in ?F. ?f x = ?g x⟧ ⟹ (?g ⤏ ?l) ?F›*)) (*goals: 1. ‹?f ⇢ ereal 1› 2. ‹∀⇩F x in sequentially. ?f x = ereal (norm (nat_power x a) powr (1 / real x))›*) show "(λn. ereal ((real n powr (a ∙ 1)) powr (1 / real n))) ⇢ ereal 1" apply (rule tendsto_ereal (*‹(?f ⤏ ?x) ?F ⟹ ((λx. ereal (?f x)) ⤏ ereal ?x) ?F›*)) (*goal: ‹(λn. ereal ((real n powr (a ∙ 1)) powr (1 / real n))) ⇢ ereal 1›*) by real_asymp show "eventually (λn. (real n powr (a ∙ 1)) powr (1 / real n) = ereal (norm (nat_power n a :: 'a) powr (1 / real n))) at_top" using eventually_gt_at_top[of 0] (*‹eventually ((<) 0) at_top›*) apply eventually_elim (*goal: ‹∀⇩F n::nat in sequentially. ereal ((real n powr ((a::'a::{nat_power_normed_field,banach}) ∙ (1::'a::{nat_power_normed_field,banach}))) powr ((1::real) / real n)) = ereal (norm (nat_power n a) powr ((1::real) / real n))›*) by (simp add: norm_nat_power (*‹0 < ?n ⟹ norm (nat_power ?n ?y) = real ?n powr (?y ∙ 1)›*)) qed qed (simp_all add: one_ereal_def) (*solved the remaining goal: ‹1 = inverse (ereal 1)›*) lemma not_convergent_liouville_lambda: "¬convergent (liouville_lambda :: nat ⇒ 'a :: {real_normed_algebra, comm_ring_1, semiring_char_0})" proof (-) (*goal: ‹¬ convergent liouville_lambda›*) have "¬(liouville_lambda :: nat ⇒ 'a) ⇢ c" for c proof (rule oscillation_imp_not_tendsto (*‹⟦∀⇩F n in sequentially. ?f (?g n) ∈ ?A; filterlim ?g ?F sequentially; ∀⇩F n in sequentially. ?f (?h n) ∈ ?B; filterlim ?h ?F sequentially; closed ?A; closed ?B; ?A ∩ ?B = {}⟧ ⟹ ¬ (?f ⤏ ?c) ?F›*)) (*goals: 1. ‹∀⇩F n in sequentially. liouville_lambda (?g n) ∈ ?A› 2. ‹filterlim ?g sequentially sequentially› 3. ‹∀⇩F n in sequentially. liouville_lambda (?h n) ∈ ?B› 4. ‹filterlim ?h sequentially sequentially› 5. ‹closed ?A› 6. ‹closed ?B› 7. ‹?A ∩ ?B = {}›*) show "eventually (λn. liouville_lambda (2 ^ (2 * n)) ∈ {1 :: 'a}) sequentially" by auto show "filterlim (λn. 2 ^ (2 * n) :: nat) at_top sequentially" by real_asymp show "eventually (λn. liouville_lambda (2 ^ (2 * n + 1)) ∈ {-1 :: 'a}) sequentially" apply (subst liouville_lambda.power (*‹liouville_lambda (?n ^ ?m) = liouville_lambda ?n ^ ?m›*)) (*goal: ‹∀⇩F n in sequentially. liouville_lambda (2 ^ (2 * n + 1)) ∈ {- 1}›*) by auto show "filterlim (λn. 2 ^ (2 * n + 1) :: nat) at_top sequentially" by real_asymp qed (auto) (*solves the remaining goals: 1. ‹closed {1}› 2. ‹closed {- 1}› 3. ‹{1} ∩ {- 1} = {}›*) thus "?thesis" (*goal: ‹¬ convergent liouville_lambda›*) by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) qed lemma conv_radius_liouville_lambda: "conv_radius (liouville_lambda :: nat ⇒ 'a :: {real_normed_field, banach}) = 1" proof (-) (*goal: ‹conv_radius liouville_lambda = 1›*) have "¬summable (liouville_lambda :: nat ⇒ 'a)" using not_convergent_liouville_lambda[where ?'a = 'a] (*‹¬ convergent liouville_lambda›*) summable_LIMSEQ_zero (*‹summable ?f ⟹ ?f ⇢ 0›*) by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) hence "conv_radius (liouville_lambda :: nat ⇒ 'a) ≤ norm (1 :: 'a)" apply (intro conv_radius_leI' (*‹¬ summable (λn::nat. (?f::nat ⇒ ?'a) n * (?z::?'a) ^ n) ⟹ conv_radius ?f ≤ ereal (norm ?z)›*)) (*goal: ‹conv_radius liouville_lambda ≤ ereal (norm 1)›*) by auto moreover have "conv_radius (liouville_lambda :: nat ⇒ 'a) ≥ 1" proof (rule conv_radius_bigo_polynomial (*‹?f ∈ O(λn. of_nat n ^ ?k) ⟹ 1 ≤ conv_radius ?f›*)) (*goal: ‹liouville_lambda ∈ O(λn. of_nat n ^ ?k)›*) show "(liouville_lambda :: nat ⇒ 'a) ∈ O(λn. of_nat n ^ 0)" apply (intro bigoI[of _ 1] (*‹∀⇩F x::?'a in ?F::?'a filter. norm ((?f::?'a ⇒ ?'b) x) ≤ (1::real) * norm ((?g::?'a ⇒ ?'b) x) ⟹ ?f ∈ O[?F](?g)›*) eventually_mono[OF eventually_gt_at_top[of 0]] (*‹(⋀x::?'b2. (0::?'b2) < x ⟹ (?Q::?'b2 ⇒ bool) x) ⟹ eventually ?Q at_top›*)) (*goal: ‹liouville_lambda ∈ O(λn::nat. of_nat n ^ (0::nat))›*) by (auto simp: liouville_lambda_def (*‹liouville_lambda ?n = (if ?n = 0 then 0 else (- 1) ^ size (prime_factorization ?n))›*) norm_power (*‹norm (?x ^ ?n) = norm ?x ^ ?n›*)) qed ultimately show "?thesis" (*goal: ‹conv_radius liouville_lambda = 1›*) apply (intro antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦conv_radius liouville_lambda ≤ ereal (norm 1); 1 ≤ conv_radius liouville_lambda⟧ ⟹ conv_radius liouville_lambda ≤ 1› 2. ‹⟦conv_radius liouville_lambda ≤ ereal (norm 1); 1 ≤ conv_radius liouville_lambda⟧ ⟹ 1 ≤ conv_radius liouville_lambda› discuss goal 1*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*discuss goal 2*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*proven 2 subgoals*) . qed lemma not_convergent_mangoldt: "¬convergent (mangoldt :: nat ⇒ 'a :: {real_normed_algebra_1})" proof (-) (*goal: ‹¬ convergent mangoldt›*) have "*": "¬primepow (6 * n :: nat)" for n apply (rule not_primepowI[of 2 3] (*‹⟦prime 2; prime 3; 2 ≠ 3; 2 dvd ?n; 3 dvd ?n⟧ ⟹ ¬ primepow ?n›*)) (*goals: 1. ‹prime 2› 2. ‹prime 3› 3. ‹2 ≠ 3› 4. ‹even (6 * n)› 5. ‹3 dvd 6 * n› discuss goal 1*) apply ((auto)[1]) (*discuss goal 2*) apply ((auto)[1]) (*discuss goal 3*) apply ((auto)[1]) (*discuss goal 4*) apply ((auto)[1]) (*discuss goal 5*) apply ((auto)[1]) (*proven 5 subgoals*) . have "¬(mangoldt :: nat ⇒ 'a) ⇢ c" for c proof (rule oscillation_imp_not_tendsto (*‹⟦∀⇩F n in sequentially. ?f (?g n) ∈ ?A; filterlim ?g ?F sequentially; ∀⇩F n in sequentially. ?f (?h n) ∈ ?B; filterlim ?h ?F sequentially; closed ?A; closed ?B; ?A ∩ ?B = {}⟧ ⟹ ¬ (?f ⤏ ?c) ?F›*)) (*goals: 1. ‹∀⇩F n::nat in sequentially. mangoldt ((?g::nat ⇒ nat) n) ∈ (?A::'a set)› 2. ‹filterlim (?g::nat ⇒ nat) sequentially sequentially› 3. ‹∀⇩F n::nat in sequentially. mangoldt ((?h::nat ⇒ nat) n) ∈ (?B::'a set)› 4. ‹filterlim (?h::nat ⇒ nat) sequentially sequentially› 5. ‹closed (?A::'a set)› 6. ‹closed (?B::'a set)› 7. ‹(?A::'a set) ∩ (?B::'a set) = {}›*) show "eventually (λn. mangoldt (2 ^ n) ∈ {of_real (ln 2) :: 'a}) sequentially" by (auto simp: mangoldt_primepow (*‹prime (?p::nat) ⟹ mangoldt (?p ^ (?k::nat)) = (if (0::nat) < ?k then of_real (ln (real ?p)) else (0::?'a))›*)) show "filterlim (λn. 2 ^ n :: nat) at_top sequentially" by real_asymp show "eventually (λn. mangoldt (6 * n) ∈ {0 :: 'a}) sequentially" using "*" (*‹¬ primepow (6 * ?n)›*) by (auto simp: mangoldt_def (*‹mangoldt ?n = (if primepow ?n then of_real (ln (real (aprimedivisor ?n))) else 0)›*)) show "filterlim (λn. 6 * n :: nat) at_top sequentially" by real_asymp qed (auto) (*solves the remaining goals: 1. ‹closed {of_real (ln (2::real))}› 2. ‹closed {0::'a}› 3. ‹{of_real (ln (2::real))} ∩ {0::'a} = {}›*) thus "?thesis" (*goal: ‹¬ convergent mangoldt›*) by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) qed lemma conv_radius_mangoldt: "conv_radius (mangoldt :: nat ⇒ 'a :: {real_normed_field, banach}) = 1" proof (-) (*goal: ‹conv_radius mangoldt = 1›*) have "¬summable (mangoldt :: nat ⇒ 'a)" using not_convergent_mangoldt[where ?'a = 'a] (*‹¬ convergent mangoldt›*) summable_LIMSEQ_zero (*‹summable ?f ⟹ ?f ⇢ 0›*) by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) hence "conv_radius (mangoldt :: nat ⇒ 'a) ≤ norm (1 :: 'a)" apply (intro conv_radius_leI' (*‹¬ summable (λn. ?f n * ?z ^ n) ⟹ conv_radius ?f ≤ ereal (norm ?z)›*)) (*goal: ‹conv_radius mangoldt ≤ ereal (norm 1)›*) by auto moreover have "conv_radius (mangoldt :: nat ⇒ 'a) ≥ 1" proof (rule conv_radius_bigo_polynomial (*‹?f ∈ O(λn. of_nat n ^ ?k) ⟹ 1 ≤ conv_radius ?f›*)) (*goal: ‹mangoldt ∈ O(λn::nat. of_nat n ^ (?k::nat))›*) have "(mangoldt :: nat ⇒ 'a) ∈ O(λn. of_real (ln (real n)))" apply (intro bigoI[of _ 1] (*‹∀⇩F x in ?F. norm (?f x) ≤ 1 * norm (?g x) ⟹ ?f ∈ O[?F](?g)›*) eventually_mono[OF eventually_gt_at_top[of 0]] (*‹(⋀x. 0 < x ⟹ ?Q x) ⟹ eventually ?Q at_top›*)) (*goal: ‹mangoldt ∈ O(λn. of_real (ln (real n)))›*) by (auto simp: mangoldt_le (*‹0 < ?n ⟹ mangoldt ?n ≤ ln (real ?n)›*)) also (*calculation: ‹mangoldt ∈ O(λn. of_real (ln (real n)))›*) have "(λn. of_real (ln (real n))) ∈ O(λn. of_nat n :: 'a)" apply (subst landau_o.big.norm_iff [symmetric] (*‹((?f::?'a ⇒ ?'b) ∈ O[?F::?'a filter](?g::?'a ⇒ ?'b)) = ((λx::?'a. norm (?f x)) ∈ O[?F](λx::?'a. norm (?g x)))›*)) (*goal: ‹(λn::nat. of_real (ln (real n))) ∈ O(of_nat)›*) apply (unfold norm_of_real (*‹norm (of_real (?r::real)) = ¦?r¦›*) norm_of_nat (*‹norm (of_nat (?n::nat)) = real ?n›*)) (*goal: ‹(λx. norm (of_real (ln (real x)))) ∈ O(λx. norm (of_nat x))›*) by real_asymp finally (*calculation: ‹mangoldt ∈ O(of_nat)›*) show "(mangoldt :: nat ⇒ 'a) ∈ O(λn. of_nat n ^ 1)" by simp qed ultimately show "?thesis" (*goal: ‹conv_radius mangoldt = 1›*) apply (intro antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦conv_radius mangoldt ≤ ereal (norm 1); 1 ≤ conv_radius mangoldt⟧ ⟹ conv_radius mangoldt ≤ 1› 2. ‹⟦conv_radius mangoldt ≤ ereal (norm 1); 1 ≤ conv_radius mangoldt⟧ ⟹ 1 ≤ conv_radius mangoldt› discuss goal 1*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*discuss goal 2*) apply ((auto simp: one_ereal_def (*‹(1::ereal) = ereal (1::real)›*))[1]) (*proven 2 subgoals*) . qed lemma not_convergent_moebius_mu: "¬convergent (moebius_mu :: nat ⇒ 'a :: real_normed_field)" proof (rule oscillation_imp_not_convergent (*‹⟦∃⇩F n in sequentially. ?f n ∈ ?A; ∃⇩F n in sequentially. ?f n ∈ ?B; closed ?A; closed ?B; ?A ∩ ?B = {}⟧ ⟹ ¬ convergent ?f›*)) (*goals: 1. ‹∃⇩F n::nat in sequentially. moebius_mu n ∈ (?A::'a::real_normed_field set)› 2. ‹∃⇩F n::nat in sequentially. moebius_mu n ∈ (?B::'a::real_normed_field set)› 3. ‹closed (?A::'a::real_normed_field set)› 4. ‹closed (?B::'a::real_normed_field set)› 5. ‹(?A::'a::real_normed_field set) ∩ (?B::'a::real_normed_field set) = {}›*) have "infinite {p. prime (p :: nat)}" by (rule primes_infinite (*‹infinite {p. prime p}›*)) hence "frequently (prime :: nat ⇒ bool) cofinite" by (simp add: Inf_many_def (*‹Inf_many ?P = infinite {x. ?P x}›*)) hence "frequently (λn. moebius_mu n = (-1 :: 'a)) cofinite" apply (rule frequently_elim1 (*‹⟦frequently ?P ?F; ⋀i. ?P i ⟹ ?Q i⟧ ⟹ frequently ?Q ?F›*)) (*goal: ‹∃⇩∞n::nat. moebius_mu n = - (1::'a)›*) by (simp add: moebius_mu.prime (*‹prime ?p ⟹ moebius_mu ?p = - 1›*)) thus "frequently (λn. moebius_mu n ∈ {(-1 :: 'a)}) sequentially" using cofinite_eq_sequentially (*‹cofinite = sequentially›*) by fastforce next (*goals: 1. ‹∃⇩F n in sequentially. moebius_mu n ∈ ?B› 2. ‹closed {- 1}› 3. ‹closed ?B› 4. ‹{- 1} ∩ ?B = {}›*) have "infinite (range (λn. 4 * n :: nat))" apply (subst finite_image_iff (*‹inj_on (?f::?'a ⇒ ?'b) (?A::?'a set) ⟹ finite (?f ` ?A) = finite ?A›*)) (*goals: 1. ‹inj ((*) 4)› 2. ‹infinite UNIV› discuss goal 1*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*discuss goal 2*) apply ((auto simp: inj_on_def (*‹inj_on ?f ?A = (∀x∈?A. ∀y∈?A. ?f x = ?f y ⟶ x = y)›*))[1]) (*proven 2 subgoals*) . moreover { have "¬squarefree (2 ^ 2 :: nat)" apply (subst squarefree_power_iff (*‹squarefree (?n ^ ?m) = (?m = 0 ∨ is_unit ?n ∨ squarefree ?n ∧ ?m = 1)›*)) (*goal: ‹¬ squarefree (2²)›*) by auto also (*calculation: ‹¬ squarefree (2²)›*) have "2 ^ 2 = (4 :: nat)" by simp finally (*calculation: ‹¬ squarefree 4›*) have "range (λn. 4 * n :: nat) ⊆ {n::nat. ¬squarefree n}" by (auto dest: squarefree_multD (*‹squarefree (?a * ?b) ⟹ squarefree ?a› ‹squarefree (?a * ?b) ⟹ squarefree ?b›*)) } ultimately have "frequently (λn::nat. ¬squarefree n) cofinite" unfolding INFM_iff_infinite (*goal: ‹infinite {n::nat. ¬ squarefree n}›*) using finite_subset (*‹⟦?A ⊆ ?B; finite ?B⟧ ⟹ finite ?A›*) by blast thus "∃⇩F n in sequentially. moebius_mu n ∈ {0}" unfolding cofinite_eq_sequentially (*goal: ‹∃⇩F n::nat in sequentially. moebius_mu n ∈ {0::'b}›*) apply (rule frequently_elim1 (*‹⟦frequently ?P ?F; ⋀i. ?P i ⟹ ?Q i⟧ ⟹ frequently ?Q ?F›*)) (*goal: ‹∃⇩F n in sequentially. moebius_mu n ∈ {0}›*) by auto qed (auto) (*solves the remaining goals: 1. ‹closed {- 1}› 2. ‹closed {0}› 3. ‹{- 1} ∩ {0} = {}›*) lemma conv_radius_moebius_mu: "conv_radius (moebius_mu :: nat ⇒ 'a :: {real_normed_field, banach}) = 1" proof (-) (*goal: ‹conv_radius moebius_mu = 1›*) have "¬summable (moebius_mu :: nat ⇒ 'a)" using not_convergent_moebius_mu[where ?'a = 'a] (*‹¬ convergent moebius_mu›*) summable_LIMSEQ_zero (*‹summable (?f::nat ⇒ ?'a::real_normed_vector) ⟹ ?f ⇢ (0::?'a::real_normed_vector)›*) by (auto simp: convergent_def (*‹convergent ?X = (∃L. ?X ⇢ L)›*)) hence "conv_radius (moebius_mu :: nat ⇒ 'a) ≤ norm (1 :: 'a)" apply (intro conv_radius_leI' (*‹¬ summable (λn. ?f n * ?z ^ n) ⟹ conv_radius ?f ≤ ereal (norm ?z)›*)) (*goal: ‹conv_radius moebius_mu ≤ ereal (norm 1)›*) by auto moreover have "conv_radius (moebius_mu :: nat ⇒ 'a) ≥ conv_radius (λ_. 1 :: 'a)" apply (intro conv_radius_mono (*‹∀⇩F n in sequentially. norm (?g n) ≤ norm (?f n) ⟹ conv_radius ?f ≤ conv_radius ?g›*) always_eventually (*‹∀x. ?P x ⟹ eventually ?P ?F›*)) (*goal: ‹conv_radius (λ_::nat. 1::'a::{banach,real_normed_field}) ≤ conv_radius moebius_mu›*) by (auto simp: norm_moebius_mu (*‹norm (moebius_mu ?n) = ind squarefree ?n›*) ind_def (*‹ind ?P ?n = (if 0 < ?n ∧ ?P ?n then 1 else 0)›*)) ultimately show "?thesis" (*goal: ‹conv_radius moebius_mu = 1›*) apply (intro antisym (*‹⟦(?a::?'a::order) ≤ (?b::?'a::order); ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦conv_radius moebius_mu ≤ ereal (norm 1); conv_radius (λ_. 1) ≤ conv_radius moebius_mu⟧ ⟹ conv_radius moebius_mu ≤ 1› 2. ‹⟦conv_radius moebius_mu ≤ ereal (norm 1); conv_radius (λ_. 1) ≤ conv_radius moebius_mu⟧ ⟹ 1 ≤ conv_radius moebius_mu› discuss goal 1*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*discuss goal 2*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*proven 2 subgoals*) . qed lemma not_convergent_totient: "¬convergent (λn. of_nat (totient n) :: 'a :: {real_normed_field, banach})" proof (standard) (*goal: ‹convergent (λn. of_nat (totient n)) ⟹ False›*) assume "convergent (λn. of_nat (totient n) :: 'a)" (*‹convergent (λn::nat. of_nat (totient n))›*) then obtain L where L: "eventually (λn. totient n = L) at_top" (*goal: ‹(⋀L. ∀⇩F n in sequentially. totient n = L ⟹ thesis) ⟹ thesis›*) by (auto simp: convergent_def (*‹convergent (?X::nat ⇒ ?'a) = (∃L::?'a. ?X ⇢ L)›*) filterlim_of_nat_iff (*‹(?F::?'b filter) ≠ bot ⟹ ((λx::?'b. of_nat ((?f::?'b ⇒ nat) x)) ⤏ (?c::?'a)) ?F = (∃c'::nat. ?c = of_nat c' ∧ (∀⇩F x::?'b in ?F. ?f x = c'))›*)) then obtain N where N: "⋀n. n ≥ N ⟹ totient n = L" (*goal: ‹(⋀N. (⋀n. N ≤ n ⟹ totient n = L) ⟹ thesis) ⟹ thesis›*) unfolding eventually_at_top_linorder (*goal: ‹(⋀N. (⋀n. N ≤ n ⟹ totient n = L) ⟹ thesis) ⟹ thesis›*) by blast obtain p and q where "prime p" "p > N" "prime q" "q > p" (*goal: ‹(⋀p q. ⟦prime p; N < p; prime q; p < q⟧ ⟹ thesis) ⟹ thesis›*) using bigger_prime (*‹∃p. prime p ∧ ?n < p›*) by blast with N[of p] (*‹N ≤ p ⟹ totient p = L›*) N[of q] (*‹N ≤ q ⟹ totient q = L›*) show False by (auto simp: totient_prime (*‹prime ?p ⟹ totient ?p = ?p - 1›*)) qed lemma conv_radius_totient: "conv_radius (λn. of_nat (totient n) :: 'a :: {real_normed_field, banach}) = 1" proof (-) (*goal: ‹conv_radius (λn. of_nat (totient n)) = 1›*) have "¬summable (λn. of_nat (totient n) :: 'a)" using not_convergent_totient[where ?'a = 'a] (*‹¬ convergent (λn::nat. of_nat (totient n))›*) summable_LIMSEQ_zero (*‹summable ?f ⟹ ?f ⇢ 0›*) by (auto simp: convergent_def (*‹convergent (?X::nat ⇒ ?'a::topological_space) = (∃L::?'a::topological_space. ?X ⇢ L)›*)) hence "conv_radius (λn. of_nat (totient n) :: 'a) ≤ norm (1 :: 'a)" apply (intro conv_radius_leI' (*‹¬ summable (λn::nat. (?f::nat ⇒ ?'a) n * (?z::?'a) ^ n) ⟹ conv_radius ?f ≤ ereal (norm ?z)›*)) (*goal: ‹conv_radius (λn. of_nat (totient n)) ≤ ereal (norm 1)›*) by auto moreover have "conv_radius (λn. of_nat (totient n) :: 'a) ≥ 1" proof (rule conv_radius_bigo_polynomial (*‹?f ∈ O(λn. of_nat n ^ ?k) ⟹ 1 ≤ conv_radius ?f›*)) (*goal: ‹(λn. of_nat (totient n)) ∈ O(λn. of_nat n ^ ?k)›*) show "(λn. of_nat (totient n)) ∈ O(λn. of_nat n ^ 1)" apply (intro bigoI[of _ 1] (*‹∀⇩F x in ?F. norm (?f x) ≤ 1 * norm (?g x) ⟹ ?f ∈ O[?F](?g)›*) always_eventually (*‹∀x. ?P x ⟹ eventually ?P ?F›*)) (*goal: ‹(λn. of_nat (totient n)) ∈ O(λn. of_nat n ^ 1)›*) by (auto simp: totient_le (*‹totient ?n ≤ ?n›*)) qed ultimately show "?thesis" (*goal: ‹conv_radius (λn. of_nat (totient n)) = 1›*) apply (intro antisym (*‹⟦?a ≤ ?b; ?b ≤ ?a⟧ ⟹ ?a = ?b›*)) (*goals: 1. ‹⟦conv_radius (λn. of_nat (totient n)) ≤ ereal (norm 1); 1 ≤ conv_radius (λn. of_nat (totient n))⟧ ⟹ conv_radius (λn. of_nat (totient n)) ≤ 1› 2. ‹⟦conv_radius (λn. of_nat (totient n)) ≤ ereal (norm 1); 1 ≤ conv_radius (λn. of_nat (totient n))⟧ ⟹ 1 ≤ conv_radius (λn. of_nat (totient n))› discuss goal 1*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*discuss goal 2*) apply ((auto simp: one_ereal_def (*‹1 = ereal 1›*))[1]) (*proven 2 subgoals*) . qed end
{ "path": "afp-2025-02-12/thys/Lambert_Series/Number_Theoretic_Functions_Extras.thy", "repo": "afp-2025-02-12", "sha": "f94e1a4a39e52da0442f869d17ee268cfc44a9380ff7b78e72db5fca8bfba44c" }
(* Title: Lemmas_Disintegration.thy Author: Michikazu Hirata, Tokyo Institute of Technology *) section ‹ Lemmas › theory Lemmas_Disintegration imports "Standard_Borel_Spaces.StandardBorel" begin subsection ‹ Lemmas › lemma semiring_of_sets_binary_product_sets[simp]: "semiring_of_sets (space X × space Y) {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" proof (standard) (*goals: 1. ‹{a × b |a b. a ∈ sets X ∧ b ∈ sets Y} ⊆ Pow (space X × space Y)› 2. ‹{} ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}› 3. ‹⋀a b. ⟦a ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}; b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}⟧ ⟹ a ∩ b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}› 4. ‹⋀a b. ⟦a ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}; b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}⟧ ⟹ ∃C⊆{a × b |a b. a ∈ sets X ∧ b ∈ sets Y}. finite C ∧ disjoint C ∧ a - b = ⋃ C›*) show "{a × b |a b. a ∈ sets X ∧ b ∈ sets Y} ⊆ Pow (space X × space Y)" using pair_measure_closed (*‹{a × b |a b. a ∈ sets ?A ∧ b ∈ sets ?B} ⊆ Pow (space ?A × space ?B)›*) by blast next (*goals: 1. ‹{} ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}› 2. ‹⋀a b. ⟦a ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}; b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}⟧ ⟹ a ∩ b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}› 3. ‹⋀a b. ⟦a ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}; b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}⟧ ⟹ ∃C⊆{a × b |a b. a ∈ sets X ∧ b ∈ sets Y}. finite C ∧ disjoint C ∧ a - b = ⋃ C›*) fix c and d assume "c ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" "d ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" (*‹(c::('a × 'b) set) ∈ {a × b |(a::'a set) b::'b set. a ∈ sets (X::'a measure) ∧ b ∈ sets (Y::'b measure)}› ‹(d::('a × 'b) set) ∈ {a × b |(a::'a set) b::'b set. a ∈ sets (X::'a measure) ∧ b ∈ sets (Y::'b measure)}›*) then obtain ac and bc and ad and bd where "c = ac × bc" "ac ∈ sets X" "bc ∈ sets Y" "d = ad × bd" "ad ∈ sets X" "bd ∈ sets Y" (*goal: ‹(⋀ac bc ad bd. ⟦c = ac × bc; ac ∈ sets X; bc ∈ sets Y; d = ad × bd; ad ∈ sets X; bd ∈ sets Y⟧ ⟹ thesis) ⟹ thesis›*) by auto thus "c ∩ d ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" by (auto intro!: exI[where x="ac ∩ ad"] (*‹?P (ac ∩ ad) ⟹ ∃x. ?P x›*) exI[where x="bc ∩ bd"] (*‹?P (bc ∩ bd) ⟹ ∃x. ?P x›*)) next (*goals: 1. ‹{} ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}› 2. ‹⋀a b. ⟦a ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}; b ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}⟧ ⟹ ∃C⊆{a × b |a b. a ∈ sets X ∧ b ∈ sets Y}. finite C ∧ disjoint C ∧ a - b = ⋃ C›*) fix c and d assume "c ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" "d ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" (*‹(c::('a × 'b) set) ∈ {a × b |(a::'a set) b::'b set. a ∈ sets (X::'a measure) ∧ b ∈ sets (Y::'b measure)}› ‹(d::('a × 'b) set) ∈ {a × b |(a::'a set) b::'b set. a ∈ sets (X::'a measure) ∧ b ∈ sets (Y::'b measure)}›*) then obtain ac and bc and ad and bd where cd: "c = ac × bc" "ac ∈ sets X" "bc ∈ sets Y" "d = ad × bd" "ad ∈ sets X" "bd ∈ sets Y" (*goal: ‹(⋀ac bc ad bd. ⟦c = ac × bc; ac ∈ sets X; bc ∈ sets Y; d = ad × bd; ad ∈ sets X; bd ∈ sets Y⟧ ⟹ thesis) ⟹ thesis›*) by auto then have eq1: "c - d = ((ac - ad) × (bc - bd)) ∪ ((ac - ad) × (bc ∩ bd)) ∪ ((ac ∩ ad) × (bc - bd))" by blast obtain a1 where a1: "a1⊆sets X" "finite a1" "disjoint a1" "ac - ad = ⋃ a1" (*goal: ‹(⋀a1. ⟦a1 ⊆ sets X; finite a1; disjoint a1; ac - ad = ⋃ a1⟧ ⟹ thesis) ⟹ thesis›*) using cd (*‹c = ac × bc› ‹ac ∈ sets X› ‹(bc::'b set) ∈ sets (Y::'b measure)› ‹d = ad × bd› ‹ad ∈ sets X› ‹bd ∈ sets Y›*) sets.Diff_cover[of ac X ad] (*‹⟦ac ∈ sets X; ad ∈ sets X⟧ ⟹ ∃C⊆sets X. finite C ∧ disjoint C ∧ ac - ad = ⋃ C›*) by auto obtain a2 where a2: "a2⊆sets Y" "finite a2" "disjoint a2" "bc - bd = ⋃ a2" (*goal: ‹(⋀a2. ⟦a2 ⊆ sets Y; finite a2; disjoint a2; bc - bd = ⋃ a2⟧ ⟹ thesis) ⟹ thesis›*) using cd (*‹c = ac × bc› ‹(ac::'a set) ∈ sets (X::'a measure)› ‹(bc::'b::type set) ∈ sets (Y::'b::type measure)› ‹d = ad × bd› ‹ad ∈ sets X› ‹(bd::'b::type set) ∈ sets (Y::'b::type measure)›*) sets.Diff_cover[of bc Y bd] (*‹⟦(bc::'b::type set) ∈ sets (Y::'b::type measure); (bd::'b::type set) ∈ sets Y⟧ ⟹ ∃C⊆sets Y. finite C ∧ disjoint C ∧ bc - bd = ⋃ C›*) by auto define A1 and A2 and A3 where A1_def: "A1 ≡ {a × b|a b. a ∈ a1 ∧ b ∈ a2}" and A2_def: "A2 ≡ {a × (bc ∩ bd)|a . a ∈ a1}" and A3_def: "A3 ≡ {(ac ∩ ad) × b|b. b ∈ a2}" have disj: "disjoint (A1 ∪ A2 ∪ A3)" proof (-) (*goal: ‹disjoint (A1 ∪ A2 ∪ A3)›*) have [simp]: "disjoint A1" proof (standard) (*goal: ‹⋀x y. ⟦x ∈ A1; y ∈ A1; x ≠ y⟧ ⟹ disjnt x y›*) fix x and y assume "x ∈ A1" "y ∈ A1" "x ≠ y" (*‹(x::('a × 'b) set) ∈ (A1::('a × 'b) set set)› ‹(y::('a × 'b) set) ∈ (A1::('a × 'b) set set)› ‹(x::('a × 'b) set) ≠ (y::('a × 'b) set)›*) then obtain xa and xb and ya and yb where xy: "x = xa × xb" "xa ∈ a1" "xb ∈ a2" "y = ya × yb" "ya ∈ a1" "yb ∈ a2" (*goal: ‹(⋀xa xb ya yb. ⟦x = xa × xb; xa ∈ a1; xb ∈ a2; y = ya × yb; ya ∈ a1; yb ∈ a2⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*)) with ‹x ≠ y› (*‹x ≠ y›*) consider "xa ≠ ya" | "xb ≠ yb" (*goal: ‹⟦xa ≠ ya ⟹ thesis; xb ≠ yb ⟹ thesis⟧ ⟹ thesis›*) by auto thus "disjnt x y" proof (cases) (*goals: 1. ‹xa ≠ ya ⟹ disjnt x y› 2. ‹xb ≠ yb ⟹ disjnt x y›*) case 1 (*‹(xa::'a set) ≠ (ya::'a set)›*) then have "xa ∩ ya = {}" using a1(3) (*‹disjoint a1›*) xy (*‹x = xa × xb› ‹(xa::'a set) ∈ (a1::'a set set)› ‹xb ∈ a2› ‹y = ya × yb› ‹(ya::'a::type set) ∈ (a1::'a::type set set)› ‹yb ∈ a2›*) by (auto simp: disjoint_def (*‹disjoint ?A = (∀a∈?A. ∀b∈?A. a ≠ b ⟶ a ∩ b = {})›*)) thus "?thesis" (*goal: ‹disjnt (x::('a × 'b) set) (y::('a × 'b) set)›*) by (auto simp: xy (*‹x = xa × xb› ‹xa ∈ a1› ‹xb ∈ a2› ‹y = ya × yb› ‹ya ∈ a1› ‹yb ∈ a2›*) disjnt_def (*‹disjnt ?A ?B = (?A ∩ ?B = {})›*)) next (*goal: ‹xb ≠ yb ⟹ disjnt x y›*) case 2 (*‹xb ≠ yb›*) then have "xb ∩ yb = {}" using a2(3) (*‹disjoint a2›*) xy (*‹x = xa × xb› ‹xa ∈ a1› ‹(xb::'b set) ∈ (a2::'b set set)› ‹y = ya × yb› ‹(ya::'a::type set) ∈ (a1::'a::type set set)› ‹yb ∈ a2›*) by (auto simp: disjoint_def (*‹disjoint ?A = (∀a∈?A. ∀b∈?A. a ≠ b ⟶ a ∩ b = {})›*)) thus "?thesis" (*goal: ‹disjnt x y›*) by (auto simp: xy (*‹x = xa × xb› ‹xa ∈ a1› ‹xb ∈ a2› ‹y = ya × yb› ‹ya ∈ a1› ‹yb ∈ a2›*) disjnt_def (*‹disjnt ?A ?B = (?A ∩ ?B = {})›*)) qed qed have [simp]: "disjoint A2" proof (standard) (*goal: ‹⋀x y. ⟦x ∈ A2; y ∈ A2; x ≠ y⟧ ⟹ disjnt x y›*) fix x and y assume "x ∈ A2" "y ∈ A2" "x ≠ y" (*‹(x::('a × 'b) set) ∈ (A2::('a × 'b) set set)› ‹(y::('a × 'b) set) ∈ (A2::('a × 'b) set set)› ‹(x::('a × 'b) set) ≠ (y::('a × 'b) set)›*) then obtain xa and ya where xy: "x = xa × (bc ∩ bd)" "xa ∈ a1" "y = ya × (bc ∩ bd)" "ya ∈ a1" (*goal: ‹(⋀(xa::'a set) ya::'a set. ⟦(x::('a × 'b) set) = xa × ((bc::'b set) ∩ (bd::'b set)); xa ∈ (a1::'a set set); (y::('a × 'b) set) = ya × (bc ∩ bd); ya ∈ a1⟧ ⟹ thesis::bool) ⟹ thesis›*) by (auto simp: A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*)) with a1(3) (*‹disjoint a1›*) ‹x ≠ y› (*‹x ≠ y›*) have "xa ∩ ya = {}" by (auto simp: disjoint_def (*‹disjoint ?A = (∀a∈?A. ∀b∈?A. a ≠ b ⟶ a ∩ b = {})›*)) thus "disjnt x y" by (auto simp: xy (*‹(x::('a × 'b) set) = (xa::'a set) × ((bc::'b set) ∩ (bd::'b set))› ‹(xa::'a set) ∈ (a1::'a set set)› ‹(y::('a × 'b) set) = (ya::'a set) × ((bc::'b set) ∩ (bd::'b set))› ‹(ya::'a set) ∈ (a1::'a set set)›*) disjnt_def (*‹disjnt (?A::?'a set) (?B::?'a set) = (?A ∩ ?B = {})›*)) qed have [simp]: "disjoint A3" proof (standard) (*goal: ‹⋀x y. ⟦x ∈ A3; y ∈ A3; x ≠ y⟧ ⟹ disjnt x y›*) fix x and y assume "x ∈ A3" "y ∈ A3" "x ≠ y" (*‹(x::('a × 'b) set) ∈ (A3::('a × 'b) set set)› ‹(y::('a × 'b) set) ∈ (A3::('a × 'b) set set)› ‹(x::('a × 'b) set) ≠ (y::('a × 'b) set)›*) then obtain xb and yb where xy: "x = (ac ∩ ad) × xb" "xb ∈ a2" "y = (ac ∩ ad) × yb" "yb ∈ a2" (*goal: ‹(⋀xb yb. ⟦x = (ac ∩ ad) × xb; xb ∈ a2; y = (ac ∩ ad) × yb; yb ∈ a2⟧ ⟹ thesis) ⟹ thesis›*) by (auto simp: A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*)) with a2(3) (*‹disjoint a2›*) ‹x ≠ y› (*‹(x::('a::type × 'b::type) set) ≠ (y::('a::type × 'b::type) set)›*) have "xb ∩ yb = {}" by (auto simp: disjoint_def (*‹disjoint ?A = (∀a∈?A. ∀b∈?A. a ≠ b ⟶ a ∩ b = {})›*)) thus "disjnt x y" by (auto simp: xy (*‹x = (ac ∩ ad) × xb› ‹xb ∈ a2› ‹y = (ac ∩ ad) × yb› ‹yb ∈ a2›*) disjnt_def (*‹disjnt ?A ?B = (?A ∩ ?B = {})›*)) qed show "?thesis" (*goal: ‹disjoint (A1 ∪ A2 ∪ A3)›*) apply (auto intro!: disjoint_union (*‹⟦disjoint ?C; disjoint ?B; ⋃ ?C ∩ ⋃ ?B = {}⟧ ⟹ disjoint (?C ∪ ?B)›*)) (*goals: 1. ‹⋀a b X Xa. ⟦(a, b) ∈ X; X ∈ A1; (a, b) ∈ Xa; Xa ∈ A2⟧ ⟹ False› 2. ‹⋀a b X Xa. ⟦(a, b) ∈ X; (a, b) ∈ Xa; Xa ∈ A3; X ∈ A1⟧ ⟹ False› 3. ‹⋀a b X Xa. ⟦(a, b) ∈ X; (a, b) ∈ Xa; Xa ∈ A3; X ∈ A2⟧ ⟹ False› discuss goal 1*) apply ((insert a1 (*‹a1 ⊆ sets X› ‹finite a1› ‹disjoint a1› ‹ac - ad = ⋃ a1›*) a2 (*‹a2 ⊆ sets Y› ‹finite a2› ‹disjoint a2› ‹bc - bd = ⋃ a2›*))[1]) (*top goal: ‹⋀a b X Xa. ⟦(a, b) ∈ X; X ∈ A1; (a, b) ∈ Xa; Xa ∈ A2⟧ ⟹ False› and 2 goals remain*) apply ((auto simp: A1_def (*‹A1::('a × 'b) set set ≡ {a × b |(a::'a set) b::'b set. a ∈ (a1::'a set set) ∧ b ∈ (a2::'b set set)}›*) A2_def (*‹A2::('a × 'b) set set ≡ {a × ((bc::'b set) ∩ (bd::'b set)) |a::'a set. a ∈ (a1::'a set set)}›*) A3_def (*‹A3::('a × 'b) set set ≡ {((ac::'a set) ∩ (ad::'a set)) × b |b::'b set. b ∈ (a2::'b set set)}›*))[1]) (*discuss goal 2*) apply ((insert a1 (*‹(a1::'a set set) ⊆ sets (X::'a measure)› ‹finite (a1::'a set set)› ‹disjoint (a1::'a set set)› ‹(ac::'a set) - (ad::'a set) = ⋃ (a1::'a set set)›*) a2 (*‹(a2::'b set set) ⊆ sets (Y::'b measure)› ‹finite (a2::'b set set)› ‹disjoint (a2::'b set set)› ‹(bc::'b set) - (bd::'b set) = ⋃ (a2::'b set set)›*))[1]) (*top goal: ‹⋀a b X Xa. ⟦(a, b) ∈ X; (a, b) ∈ Xa; Xa ∈ A3; X ∈ A1⟧ ⟹ False› and 1 goal remains*) apply ((auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*) A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*) A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*))[1]) (*discuss goal 3*) apply ((insert a1 (*‹a1 ⊆ sets X› ‹finite a1› ‹disjoint a1› ‹ac - ad = ⋃ a1›*) a2 (*‹a2 ⊆ sets Y› ‹finite a2› ‹disjoint a2› ‹bc - bd = ⋃ a2›*))[1]) (*goal: ‹⋀a b X Xa. ⟦(a, b) ∈ X; (a, b) ∈ Xa; Xa ∈ A3; X ∈ A2⟧ ⟹ False›*) apply ((auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*) A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*) A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*))[1]) (*proven 3 subgoals*) . qed have fin: "finite (A1 ∪ A2 ∪ A3)" using a1 (*‹a1 ⊆ sets X› ‹finite a1› ‹disjoint a1› ‹(ac::'a set) - (ad::'a set) = ⋃ (a1::'a set set)›*) a2 (*‹a2 ⊆ sets Y› ‹finite a2› ‹disjoint a2› ‹bc - bd = ⋃ a2›*) by (auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*) A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*) A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*) finite_image_set2 (*‹⟦finite {x. ?P x}; finite {y. ?Q y}⟧ ⟹ finite {?f x y |x y. ?P x ∧ ?Q y}›*)) have cdeq: "c - d = ⋃ (A1 ∪ A2 ∪ A3)" proof (-) (*goal: ‹c - d = ⋃ (A1 ∪ A2 ∪ A3)›*) have [simp]: "⋃ a1 × ⋃ a2 = ⋃ A1" "⋃ a1 × (bc ∩ bd) = ⋃ A2" "(ac ∩ ad) × ⋃ a2 = ⋃ A3" (*goals: 1. ‹⋃ (a1::'a::type set set) × ⋃ (a2::'b::type set set) = ⋃ (A1::('a::type × 'b::type) set set)› 2. ‹⋃ (a1::'a::type set set) × ((bc::'b::type set) ∩ (bd::'b::type set)) = ⋃ (A2::('a::type × 'b::type) set set)› 3. ‹((ac::'a::type set) ∩ (ad::'a::type set)) × ⋃ (a2::'b::type set set) = ⋃ (A3::('a::type × 'b::type) set set)› discuss goal 1*) apply ((auto simp: A1_def (*‹A1::('a::type × 'b::type) set set ≡ {a × b |(a::'a::type set) b::'b::type set. a ∈ (a1::'a::type set set) ∧ b ∈ (a2::'b::type set set)}›*) A2_def (*‹A2::('a::type × 'b::type) set set ≡ {a × ((bc::'b::type set) ∩ (bd::'b::type set)) |a::'a::type set. a ∈ (a1::'a::type set set)}›*) A3_def (*‹A3::('a::type × 'b::type) set set ≡ {((ac::'a::type set) ∩ (ad::'a::type set)) × b |b::'b::type set. b ∈ (a2::'b::type set set)}›*))[1]) (*discuss goal 2*) apply ((auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*) A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*) A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*))[1]) (*discuss goal 3*) apply ((auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*) A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*) A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*))[1]) (*proven 3 subgoals*) . show "?thesis" (*goal: ‹c - d = ⋃ (A1 ∪ A2 ∪ A3)›*) using a1(4) (*‹ac - ad = ⋃ a1›*) a2(4) (*‹bc - bd = ⋃ a2›*) by (simp add: eq1 (*‹c - d = (ac - ad) × (bc - bd) ∪ (ac - ad) × (bc ∩ bd) ∪ (ac ∩ ad) × (bc - bd)›*)) qed have "A1 ∪ A2 ∪ A3 ⊆ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}" using a1(1) (*‹a1 ⊆ sets X›*) a2(1) (*‹a2 ⊆ sets Y›*) cd (*‹c = ac × bc› ‹ac ∈ sets X› ‹(bc::'b set) ∈ sets (Y::'b measure)› ‹d = ad × bd› ‹ad ∈ sets X› ‹bd ∈ sets Y›*) by (auto simp: A1_def (*‹A1 ≡ {a × b |a b. a ∈ a1 ∧ b ∈ a2}›*) A2_def (*‹A2 ≡ {a × (bc ∩ bd) |a. a ∈ a1}›*) A3_def (*‹A3 ≡ {(ac ∩ ad) × b |b. b ∈ a2}›*)) with fin (*‹finite (A1 ∪ A2 ∪ A3)›*) disj (*‹disjoint (A1 ∪ A2 ∪ A3)›*) cdeq (*‹(c::('a::type × 'b::type) set) - (d::('a::type × 'b::type) set) = ⋃ ((A1::('a::type × 'b::type) set set) ∪ (A2::('a::type × 'b::type) set set) ∪ (A3::('a::type × 'b::type) set set))›*) show "∃C⊆{a × b |a b. a ∈ sets X ∧ b ∈ sets Y}. finite C ∧ disjoint C ∧ c - d = ⋃ C" by (auto intro!: exI[where x="A1 ∪ A2 ∪ A3"] (*‹?P (A1 ∪ A2 ∪ A3) ⟹ ∃x. ?P x›*)) qed (auto) (*solved the remaining goal: ‹{} ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}›*) lemma sets_pair_restrict_space: "sets (restrict_space X A ⨂⇩M restrict_space Y B) = sets (restrict_space (X ⨂⇩M Y) (A × B))" (is "?lhs = ?rhs") proof (-) (*goal: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = sets (restrict_space (X ⨂⇩M Y) (A × B))›*) have "?lhs = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b |a b. a ∈ sets (restrict_space X A) ∧ b ∈ sets (restrict_space Y B)}" by (simp add: sets_pair_measure (*‹sets (?A ⨂⇩M ?B) = sigma_sets (space ?A × space ?B) {a × b |a b. a ∈ sets ?A ∧ b ∈ sets ?B}›*)) also (*calculation: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b |a b. a ∈ sets (restrict_space X A) ∧ b ∈ sets (restrict_space Y B)}›*) have "... = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |a b. a ∈ sets X ∧ b ∈ sets Y}" proof (-) (*goal: ‹sigma_sets (space (restrict_space (X::'a measure) (A::'a set)) × space (restrict_space (Y::'b measure) (B::'b set))) {a × b |(a::'a set) b::'b set. a ∈ sets (restrict_space X A) ∧ b ∈ sets (restrict_space Y B)} = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |(a::'a set) b::'b set. a ∈ sets X ∧ b ∈ sets Y}›*) have "{a × b |a b. a ∈ sets (restrict_space X A) ∧ b ∈ sets (restrict_space Y B)} = {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |a b. a ∈ sets X ∧ b ∈ sets Y}" unfolding space_restrict_space sets_restrict_space (*goal: ‹{a × b |a b. a ∈ sets.restricted_space X A ∧ b ∈ sets.restricted_space Y B} = {a × b ∩ (A ∩ space X) × (B ∩ space Y) |a b. a ∈ sets X ∧ b ∈ sets Y}›*) proof (safe) (*goals: 1. ‹⋀x a b xa xb. ⟦xa ∈ sets X; xb ∈ sets Y⟧ ⟹ ∃a b. (A ∩ xa) × (B ∩ xb) = a × b ∩ (A ∩ space X) × (B ∩ space Y) ∧ a ∈ sets X ∧ b ∈ sets Y› 2. ‹⋀x a b. ⟦a ∈ sets X; b ∈ sets Y⟧ ⟹ ∃aa ba. a × b ∩ (A ∩ space X) × (B ∩ space Y) = aa × ba ∧ aa ∈ sets.restricted_space X A ∧ ba ∈ sets.restricted_space Y B›*) fix xa and xb show "xa ∈ sets X ⟹ xb ∈ sets Y ⟹ ∃a b. (A ∩ xa) × (B ∩ xb) = a × b ∩ (A ∩ space X) × (B ∩ space Y) ∧ a ∈ sets X ∧ b ∈ sets Y" by (auto intro!: exI[where x=xa] (*‹?P xa ⟹ ∃x. ?P x›*) exI[where x=xb] (*‹?P xb ⟹ ∃x. ?P x›*) dest:sets.sets_into_space (*‹?x ∈ sets ?M ⟹ ?x ⊆ space ?M›*)) next (*goal: ‹⋀(x::('a × 'b) set) (a::'a set) b::'b set. ⟦a ∈ sets (X::'a measure); b ∈ sets (Y::'b measure)⟧ ⟹ ∃(aa::'a set) ba::'b set. a × b ∩ ((A::'a set) ∩ space X) × ((B::'b set) ∩ space Y) = aa × ba ∧ aa ∈ sets.restricted_space X A ∧ ba ∈ sets.restricted_space Y B›*) fix a and b show "a ∈ sets X ⟹ b ∈ sets Y ⟹ ∃aa ba. a × b ∩ (A ∩ space X) × (B ∩ space Y) = aa × ba ∧ aa ∈ sets.restricted_space X A ∧ ba ∈ sets.restricted_space Y B" by (auto intro!: exI[where x="a ∩ A"] (*‹?P (a ∩ A) ⟹ ∃x. ?P x›*) exI[where x="b ∩ B"] (*‹?P (b ∩ B) ⟹ ∃x. ?P x›*) dest:sets.sets_into_space (*‹?x ∈ sets ?M ⟹ ?x ⊆ space ?M›*)) qed thus "?thesis" (*goal: ‹sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b |a b. a ∈ sets (restrict_space X A) ∧ b ∈ sets (restrict_space Y B)} = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |a b. a ∈ sets X ∧ b ∈ sets Y}›*) by simp qed also (*calculation: ‹sets (restrict_space (X::'a measure) (A::'a set) ⨂⇩M restrict_space (Y::'b measure) (B::'b set)) = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |(a::'a set) b::'b set. a ∈ sets X ∧ b ∈ sets Y}›*) have "... = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ {a × b| a b. a ∈ sets X ∧ b ∈ sets Y}}" proof (-) (*goal: ‹sigma_sets (space (restrict_space (X::'a measure) (A::'a set)) × space (restrict_space (Y::'b measure) (B::'b set))) {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |(a::'a set) b::'b set. a ∈ sets X ∧ b ∈ sets Y} = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {(λx::'a × 'b. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c::('a × 'b) set. c ∈ {a × b |(a::'a set) b::'b set. a ∈ sets X ∧ b ∈ sets Y}}›*) have "{a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |a b. a ∈ sets X ∧ b ∈ sets Y} = {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ {a × b| a b. a ∈ sets X ∧ b ∈ sets Y}}" by auto thus "?thesis" (*goal: ‹sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {a × b ∩ space (restrict_space X A) × space (restrict_space Y B) |a b. a ∈ sets X ∧ b ∈ sets Y} = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}}›*) by simp qed also (*calculation: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}}›*) have "... = {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ sigma_sets (space X × space Y) {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}}" apply (rule sigma_sets_vimage_commute[symmetric] (*‹?X ∈ ?Ω → ?Ω' ⟹ sigma_sets ?Ω {?X -` A ∩ ?Ω |A. A ∈ ?M'} = {?X -` A ∩ ?Ω |A. A ∈ sigma_sets ?Ω' ?M'}›*)) (*goal: ‹sigma_sets (space (restrict_space X A) × space (restrict_space Y B)) {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}} = {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ sigma_sets (space X × space Y) {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}}›*) by (auto simp: space_restrict_space (*‹space (restrict_space ?M ?Ω) = ?Ω ∩ space ?M›*)) also (*calculation: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = {(λx. x) -` c ∩ space (restrict_space X A) × space (restrict_space Y B) |c. c ∈ sigma_sets (space X × space Y) {a × b |a b. a ∈ sets X ∧ b ∈ sets Y}}›*) have "... = {c ∩ (A ∩ space X) × (B ∩ space Y) |c. c ∈ sets (X ⨂⇩M Y)}" by (simp add: space_restrict_space (*‹space (restrict_space ?M ?Ω) = ?Ω ∩ space ?M›*) sets_pair_measure (*‹sets (?A ⨂⇩M ?B) = sigma_sets (space ?A × space ?B) {a × b |a b. a ∈ sets ?A ∧ b ∈ sets ?B}›*)) also (*calculation: ‹sets (restrict_space (X::'a measure) (A::'a set) ⨂⇩M restrict_space (Y::'b measure) (B::'b set)) = {c ∩ (A ∩ space X) × (B ∩ space Y) |c::('a × 'b) set. c ∈ sets (X ⨂⇩M Y)}›*) have "... = {c ∩ A × B |c. c ∈ sets (X ⨂⇩M Y)}" using sets.sets_into_space[of _ "X ⨂⇩M Y", simplified space_pair_measure] (*‹?x ∈ sets (X ⨂⇩M Y) ⟹ ?x ⊆ space X × space Y›*) by blast also (*calculation: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = {c ∩ A × B |c. c ∈ sets (X ⨂⇩M Y)}›*) have "... = ?rhs" by (auto simp: sets_restrict_space (*‹sets (restrict_space ?M ?Ω) = sets.restricted_space ?M ?Ω›*)) finally (*calculation: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = sets (restrict_space (X ⨂⇩M Y) (A × B))›*) show "?thesis" (*goal: ‹sets (restrict_space X A ⨂⇩M restrict_space Y B) = sets (restrict_space (X ⨂⇩M Y) (A × B))›*) . qed lemma restrict_space_space[simp]: "restrict_space M (space M) = M" by (auto intro!: measure_eqI (*‹⟦sets ?M = sets ?N; ⋀A. A ∈ sets ?M ⟹ emeasure ?M A = emeasure ?N A⟧ ⟹ ?M = ?N›*) simp: sets_restrict_space (*‹sets (restrict_space ?M ?Ω) = sets.restricted_space ?M ?Ω›*) emeasure_restrict_space (*‹⟦?Ω ∩ space ?M ∈ sets ?M; ?A ⊆ ?Ω⟧ ⟹ emeasure (restrict_space ?M ?Ω) ?A = emeasure ?M ?A›*) sets.sets_into_space (*‹?x ∈ sets ?M ⟹ ?x ⊆ space ?M›*)) lemma atMostq_Int_stable: "Int_stable {{..r} |r::real. r ∈ ℚ}" by (auto simp: Int_stable_def (*‹Int_stable ?M = (∀a∈?M. ∀b∈?M. a ∩ b ∈ ?M)›*) min_def (*‹min ?a ?b = (if ?a ≤ ?b then ?a else ?b)›*)) lemma rborel_eq_atMostq: "borel = sigma UNIV { {..r} | r::real. r ∈ ℚ}" proof (safe intro!: borel_eq_sigmaI1[OF borel_eq_atMost,where F=id,simplified] (*‹⟦⋀x. x ∈ range atMost ⟹ x ∈ sigma_sets UNIV ?A; ⋀i. i ∈ ?A ⟹ i ∈ sets borel⟧ ⟹ borel = sigma UNIV ?A›*)) (*goals: 1. ‹⋀x a. a ∈ UNIV ⟹ {..a} ∈ sigma_sets UNIV {{..r} |r. r ∈ ℚ}› 2. ‹⋀i r. r ∈ ℚ ⟹ {..r} ∈ sets borel›*) fix a :: real interpret s: sigma_algebra UNIV "sigma_sets UNIV {{..r} |r. r ∈ ℚ}" by (auto intro!: sigma_algebra_sigma_sets (*‹?a ⊆ Pow ?Ω ⟹ sigma_algebra ?Ω (sigma_sets ?Ω ?a)›*)) have [simp]: "{..a} = (⋂ ((λr. {..r}) ` {r. r ∈ ℚ ∧ a ≤ r}))" apply auto (*goal: ‹{..a} = ⋂ (atMost ` {r ∈ ℚ. a ≤ r})›*) by (metis Rats_dense_in_real (*‹?x < ?y ⟹ ∃r∈ℚ. ?x < r ∧ r < ?y›*) less_le_not_le (*‹(?x < ?y) = (?x ≤ ?y ∧ ¬ ?y ≤ ?x)›*) nle_le (*‹(¬ ?a ≤ ?b) = (?b ≤ ?a ∧ ?b ≠ ?a)›*)) show "{..a} ∈ sigma_sets UNIV {{..r} |r. r ∈ ℚ}" using countable_Collect (*‹countable ?A ⟹ countable {a ∈ ?A. ?φ a}›*) countable_rat (*‹countable ℚ›*) Rats_no_top_le (*‹∃q∈ℚ. ?x ≤ q›*) by (auto intro!: s.countable_INT' (*‹⟦countable ?X; ?X ≠ {}; ?A ` ?X ⊆ sigma_sets UNIV {{..r} |r. r ∈ ℚ}⟧ ⟹ ⋂ (?A ` ?X) ∈ sigma_sets UNIV {{..r} |r. r ∈ ℚ}›*)) qed (auto) (*solved the remaining goal: ‹⋀i r. r ∈ ℚ ⟹ {..r} ∈ sets borel›*) corollary rborel_eq_atMostq_sets: "sets borel = sigma_sets UNIV {{..r} |r::real. r ∈ ℚ}" by (simp add: rborel_eq_atMostq (*‹borel = sigma UNIV {{..r} |r. r ∈ ℚ}›*)) lemma mono_absolutely_continuous: assumes "sets μ = sets ν" "⋀A. A ∈ sets μ ⟹ μ A ≤ ν A" shows "absolutely_continuous ν μ" apply (auto simp: absolutely_continuous_def (*‹absolutely_continuous (?M::?'a measure) (?N::?'a measure) = (null_sets ?M ⊆ null_sets ?N)›*)) (*goal: ‹absolutely_continuous ν μ›*) by (metis assms( (*‹sets μ = sets ν›*) 1) assms( (*‹?A ∈ sets μ ⟹ emeasure μ ?A ≤ emeasure ν ?A›*) 2) fmeasurableD (*‹?A ∈ fmeasurable ?M ⟹ ?A ∈ sets ?M›*) fmeasurableI_null_sets (*‹?A ∈ null_sets ?M ⟹ ?A ∈ fmeasurable ?M›*) le_zero_eq (*‹(?n ≤ 0) = (?n = 0)›*) null_setsD1 (*‹?A ∈ null_sets ?M ⟹ emeasure ?M ?A = 0›*) null_setsI (*‹⟦emeasure ?M ?A = 0; ?A ∈ sets ?M⟧ ⟹ ?A ∈ null_sets ?M›*)) lemma ex_measure_countable_space: assumes "countable (space X)" and "sets X = Pow (space X)" shows "∃μ. sets μ = sets X ∧ (∀x∈space X. μ {x} = f x)" proof (-) (*goal: ‹∃μ. sets μ = sets X ∧ (∀x∈space X. emeasure μ {x} = f x)›*) define μ where "μ ≡ extend_measure (space X) (space X) (λx. {x}) f" have s: "sets μ = sets X" using sets_extend_measure[of "λx. {x}" "space X" "space X"] (*‹(λx::'a::type. {x}) ` space (X::'a::type measure) ⊆ Pow (space X) ⟹ sets (extend_measure (space X) (space X) (λx::'a::type. {x}) (?μ::'a::type ⇒ ennreal)) = sigma_sets (space X) ((λx::'a::type. {x}) ` space X)›*) sigma_sets_singletons[OF assms ( 1 )] (*‹sigma_sets (space X) ((λs. {s}) ` space X) = Pow (space X)›*) by (auto simp add: μ_def (*‹μ ≡ extend_measure (space X) (space X) (λx. {x}) f›*) assms( (*‹sets X = Pow (space X)›*) 2)) show "?thesis" (*goal: ‹∃μ. sets μ = sets X ∧ (∀x∈space X. emeasure μ {x} = f x)›*) proof (safe intro!: exI[where x=μ] (*‹?P μ ⟹ ∃x. ?P x›*)) (*goals: 1. ‹⋀x. x ∈ sets μ ⟹ x ∈ sets X› 2. ‹⋀x. x ∈ sets X ⟹ x ∈ sets μ› 3. ‹⋀x. x ∈ space X ⟹ emeasure μ {x} = f x›*) fix x assume x: "x ∈ space X" (*‹(x::'a) ∈ space (X::'a measure)›*) show "μ {x} = f x" proof (cases "finite (space X)") (*goals: 1. ‹finite (space X) ⟹ emeasure μ {x} = f x› 2. ‹infinite (space X) ⟹ emeasure μ {x} = f x›*) case fin: True (*‹finite (space X)›*) then have sets_fin: "x ∈ sets μ ⟹ finite x" for x by (auto intro!: rev_finite_subset[OF fin] (*‹?A ⊆ space X ⟹ finite ?A›*) sets.sets_into_space (*‹?x ∈ sets ?M ⟹ ?x ⊆ space ?M›*) simp: s (*‹sets μ = sets X›*)) define μ' where "μ' ≡ (λA. ∑x∈A. f x)" show "?thesis" (*goal: ‹emeasure μ {x} = f x›*) proof (rule emeasure_extend_measure[of μ "space X" "space X" _ f μ' x] (*‹⟦(μ::'a::type measure) = extend_measure (space (X::'a::type measure)) (space X) (?G::'a::type ⇒ 'a::type set) (f::'a::type ⇒ ennreal); ⋀i::'a::type. i ∈ space X ⟹ (μ'::'a::type set ⇒ ennreal) (?G i) = f i; ?G ` space X ⊆ Pow (space X); positive (sets μ) μ'; countably_additive (sets μ) μ'; (x::'a::type) ∈ space X⟧ ⟹ emeasure μ (?G x) = f x›*)) (*goals: 1. ‹(μ::'a measure) = extend_measure (space (X::'a measure)) (space X) (λa::'a. {a}) (f::'a ⇒ ennreal)› 2. ‹⋀i::'a. i ∈ space (X::'a measure) ⟹ (μ'::'a set ⇒ ennreal) {i} = (f::'a ⇒ ennreal) i› 3. ‹(λa::'a. {a}) ` space (X::'a measure) ⊆ Pow (space X)› 4. ‹positive (sets (μ::'a measure)) (μ'::'a set ⇒ ennreal)› 5. ‹countably_additive (sets (μ::'a measure)) (μ'::'a set ⇒ ennreal)› 6. ‹(x::'a) ∈ space (X::'a measure)›*) show "countably_additive (sets μ) μ'" using fin (*‹finite (space X)›*) sets_fin (*‹?x ∈ sets μ ⟹ finite ?x›*) by (auto intro!: sets.countably_additiveI_finite (*‹⟦finite (space ?M); positive (sets ?M) ?μ; Measure_Space.additive (sets ?M) ?μ⟧ ⟹ countably_additive (sets ?M) ?μ›*) simp: sets_eq_imp_space_eq[OF s] (*‹space μ = space X›*) positive_def (*‹positive ?M ?μ = (?μ {} = 0)›*) μ'_def (*‹μ' ≡ sum f›*) additive_def (*‹Measure_Space.additive ?M ?μ = (∀x∈?M. ∀y∈?M. x ∩ y = {} ⟶ ?μ (x ∪ y) = ?μ x + ?μ y)›*) comm_monoid_add_class.sum.union_disjoint (*‹⟦finite ?A; finite ?B; ?A ∩ ?B = {}⟧ ⟹ sum ?g (?A ∪ ?B) = sum ?g ?A + sum ?g ?B›*)) qed (auto simp: x (*‹x ∈ space X›*) μ_def (*‹μ ≡ extend_measure (space X) (space X) (λx. {x}) f›*) μ'_def (*‹μ' ≡ sum f›*) positive_def (*‹positive ?M ?μ = (?μ {} = 0)›*)) (*solves the remaining goals: 1. ‹(μ::'a measure) = extend_measure (space (X::'a measure)) (space X) (λa::'a. {a}) (f::'a ⇒ ennreal)› 2. ‹⋀i::'a. i ∈ space (X::'a measure) ⟹ (μ'::'a set ⇒ ennreal) {i} = (f::'a ⇒ ennreal) i› 3. ‹(λa::'a. {a}) ` space (X::'a measure) ⊆ Pow (space X)› 4. ‹positive (sets (μ::'a measure)) (μ'::'a set ⇒ ennreal)› 5. ‹(x::'a) ∈ space (X::'a measure)›*) next (*goal: ‹infinite (space (X::'a::type measure)) ⟹ emeasure (μ::'a::type measure) {x::'a::type} = (f::'a::type ⇒ ennreal) x›*) case inf: False (*‹infinite (space X)›*) define μ' where "μ' ≡ (λA. ∑n. if from_nat_into (space X) n ∈ A then f (from_nat_into (space X) n) else 0)" show "?thesis" (*goal: ‹emeasure μ {x} = f x›*) proof (rule emeasure_extend_measure[of μ "space X" "space X" _ f μ' x] (*‹⟦μ = extend_measure (space X) (space X) ?G f; ⋀i. i ∈ space X ⟹ μ' (?G i) = f i; ?G ` space X ⊆ Pow (space X); positive (sets μ) μ'; countably_additive (sets μ) μ'; x ∈ space X⟧ ⟹ emeasure μ (?G x) = f x›*)) (*goals: 1. ‹μ = extend_measure (space X) (space X) (λa. {a}) f› 2. ‹⋀i. i ∈ space X ⟹ μ' {i} = f i› 3. ‹(λa. {a}) ` space X ⊆ Pow (space X)› 4. ‹positive (sets μ) μ'› 5. ‹countably_additive (sets μ) μ'› 6. ‹x ∈ space X›*) fix i assume "i ∈ space X" (*‹(i::'a) ∈ space (X::'a measure)›*) then obtain n where n: "from_nat_into (space X) n = i" (*goal: ‹(⋀n. from_nat_into (space X) n = i ⟹ thesis) ⟹ thesis›*) using bij_betw_from_nat_into[OF assms ( 1 ) inf] (*‹bij_betw (from_nat_into (space X)) UNIV (space X)›*) by (meson f_the_inv_into_f_bij_betw (*‹⟦bij_betw ?f ?A ?B; bij_betw ?f ?A ?B ⟹ ?x ∈ ?B⟧ ⟹ ?f (the_inv_into ?A ?f ?x) = ?x›*)) then have "μ' {i} = (∑m. if m = n then f (from_nat_into (space X) n) else 0)" using from_nat_into_inj_infinite[OF assms ( 1 ) inf] (*‹(from_nat_into (space X) ?m = from_nat_into (space X) ?n) = (?m = ?n)›*) apply (auto simp: μ'_def (*‹μ' ≡ λA. ∑n. if from_nat_into (space X) n ∈ A then f (from_nat_into (space X) n) else 0›*)) (*goal: ‹μ' {i} = (∑m. if m = n then f (from_nat_into (space X) n) else 0)›*) by metis also (*calculation: ‹μ' {i} = (∑m. if m = n then f (from_nat_into (space X) n) else 0)›*) have "... = (∑m. if (m + (Suc n)) = n then f (from_nat_into (space X) n) else 0) + (∑m<Suc n. if m = n then f (from_nat_into (space X) n) else 0)" apply (rule suminf_offset (*‹summable (λj. ?f (j + ?i)) ⟹ suminf ?f = (∑j. ?f (j + ?i)) + sum ?f {..<?i}›*)) (*goal: ‹(∑m. if m = n then f (from_nat_into (space X) n) else 0) = (∑m. if m + Suc n = n then f (from_nat_into (space X) n) else 0) + (∑m<Suc n. if m = n then f (from_nat_into (space X) n) else 0)›*) by auto also (*calculation: ‹μ' {i} = (∑m. if m + Suc n = n then f (from_nat_into (space X) n) else 0) + (∑m<Suc n. if m = n then f (from_nat_into (space X) n) else 0)›*) have "... = f i" by (auto simp: n (*‹from_nat_into (space (X::'a::type measure)) (n::nat) = (i::'a::type)›*)) finally (*calculation: ‹(μ'::'a set ⇒ ennreal) {i::'a} = (f::'a ⇒ ennreal) i›*) show "μ' {i} = f i" . next (*goals: 1. ‹μ = extend_measure (space X) (space X) (λa. {a}) f› 2. ‹(λa. {a}) ` space X ⊆ Pow (space X)› 3. ‹positive (sets μ) μ'› 4. ‹countably_additive (sets μ) μ'› 5. ‹x ∈ space X›*) show "countably_additive (sets μ) μ'" proof (rule countably_additiveI (*‹(⋀A. ⟦range A ⊆ ?M; disjoint_family A; ⋃ (range A) ∈ ?M⟧ ⟹ (∑i. ?f (A i)) = ?f (⋃ (range A))) ⟹ countably_additive ?M ?f›*)) (*goal: ‹⋀A. ⟦range A ⊆ sets μ; disjoint_family A; ⋃ (range A) ∈ sets μ⟧ ⟹ (∑i. μ' (A i)) = μ' (⋃ (range A))›*) fix A :: "nat ⇒ _" assume h: "range A ⊆ sets μ" "disjoint_family A" "⋃ (range A) ∈ sets μ" (*‹range (A::nat ⇒ 'a set) ⊆ sets (μ::'a measure)› ‹disjoint_family (A::nat ⇒ 'a set)› ‹⋃ (range (A::nat ⇒ 'a set)) ∈ sets (μ::'a measure)›*) show "(∑i. μ' (A i)) = μ' (⋃ (range A))" proof (-) (*goal: ‹(∑i::nat. (μ'::'a set ⇒ ennreal) ((A::nat ⇒ 'a set) i)) = μ' (⋃ (range A))›*) have "(∑i. μ' (A i)) = (∫⁺ i. μ' (A i) ∂(count_space UNIV))" by (simp add: nn_integral_count_space_nat (*‹integral⇧N (count_space UNIV) ?f = (∑i. ?f i)›*)) also (*calculation: ‹(∑i::nat. (μ'::'a set ⇒ ennreal) ((A::nat ⇒ 'a set) i)) = ∫⁺ (i::nat). μ' (A i) ∂count_space UNIV›*) have "... = (∫⁺ i. (∑n. if from_nat_into (space X) n ∈ A i then f (from_nat_into (space X) n) else 0) ∂(count_space UNIV))" by (simp add: μ'_def (*‹μ' ≡ λA. ∑n. if from_nat_into (space X) n ∈ A then f (from_nat_into (space X) n) else 0›*)) also (*calculation: ‹(∑i. μ' (A i)) = ∫⁺ i. (∑n. if from_nat_into (space X) n ∈ A i then f (from_nat_into (space X) n) else 0) ∂count_space UNIV›*) have "... = (∑n. (∫⁺ i. (if from_nat_into (space X) n ∈ A i then f (from_nat_into (space X) n) else 0) ∂(count_space UNIV)))" by (simp add: nn_integral_suminf (*‹(⋀i::nat. (?f::nat ⇒ ?'a ⇒ ennreal) i ∈ borel_measurable (?M::?'a measure)) ⟹ ∫⁺ (x::?'a). (∑i::nat. ?f i x) ∂?M = (∑i::nat. integral⇧N ?M (?f i))›*)) also (*calculation: ‹(∑i. μ' (A i)) = (∑n. ∫⁺ i. (if from_nat_into (space X) n ∈ A i then f (from_nat_into (space X) n) else 0) ∂count_space UNIV)›*) have "... = (∑n. (∫⁺ i. f (from_nat_into (space X) n) * indicator (A i) (from_nat_into (space X) n) ∂(count_space UNIV)))" by (auto intro!: suminf_cong (*‹(⋀n. ?f n = ?g n) ⟹ suminf ?f = suminf ?g›*) nn_integral_cong (*‹(⋀x. x ∈ space ?M ⟹ ?u x = ?v x) ⟹ integral⇧N ?M ?u = integral⇧N ?M ?v›*)) also (*calculation: ‹(∑i. μ' (A i)) = (∑n. ∫⁺ i. f (from_nat_into (space X) n) * indicator (A i) (from_nat_into (space X) n) ∂count_space UNIV)›*) have "... = (∑n. (∑i. f (from_nat_into (space X) n) * indicator (A i) (from_nat_into (space X) n)))" by (simp add: nn_integral_count_space_nat (*‹integral⇧N (count_space UNIV) ?f = (∑i. ?f i)›*)) also (*calculation: ‹(∑i. μ' (A i)) = (∑n i. f (from_nat_into (space X) n) * indicator (A i) (from_nat_into (space X) n))›*) have "... = (∑n. f (from_nat_into (space X) n) * indicator (⋃ (range A)) (from_nat_into (space X) n))" by (simp add: suminf_indicator[OF h(2)] (*‹(∑n. indicator (A n) ?x) = indicator (⋃ (range A)) ?x›*)) also (*calculation: ‹(∑i::nat. (μ'::'a set ⇒ ennreal) ((A::nat ⇒ 'a set) i)) = (∑n::nat. (f::'a ⇒ ennreal) (from_nat_into (space (X::'a measure)) n) * indicator (⋃ (range A)) (from_nat_into (space X) n))›*) have "... = μ' (⋃ (range A))" by (auto simp: μ'_def (*‹μ' ≡ λA. ∑n. if from_nat_into (space X) n ∈ A then f (from_nat_into (space X) n) else 0›*) intro!: suminf_cong (*‹(⋀n. ?f n = ?g n) ⟹ suminf ?f = suminf ?g›*)) finally (*calculation: ‹(∑i. μ' (A i)) = μ' (⋃ (range A))›*) show "?thesis" (*goal: ‹(∑i::nat. (μ'::'a set ⇒ ennreal) ((A::nat ⇒ 'a set) i)) = μ' (⋃ (range A))›*) . qed qed qed (auto simp: x (*‹x ∈ space X›*) μ_def (*‹μ ≡ extend_measure (space X) (space X) (λx. {x}) f›*) μ'_def (*‹μ' ≡ λA. ∑n. if from_nat_into (space X) n ∈ A then f (from_nat_into (space X) n) else 0›*) positive_def (*‹positive ?M ?μ = (?μ {} = 0)›*)) (*solves the remaining goals: 1. ‹μ = extend_measure (space X) (space X) (λa. {a}) f› 2. ‹(λa. {a}) ` space X ⊆ Pow (space X)› 3. ‹positive (sets μ) μ'› 4. ‹x ∈ space X›*) qed qed (simp_all add: s) (*solves the remaining goals: 1. ‹⋀x. x ∈ sets μ ⟹ x ∈ sets X› 2. ‹⋀x. x ∈ sets X ⟹ x ∈ sets μ›*) qed lemma ex_prob_space_countable: assumes "space X ≠ {}" "countable (space X)" and "sets X = Pow (space X)" shows "∃μ. sets μ = sets X ∧ prob_space μ" proof (cases "finite (space X)") (*goals: 1. ‹finite (space X) ⟹ ∃μ. sets μ = sets X ∧ prob_space μ› 2. ‹infinite (space X) ⟹ ∃μ. sets μ = sets X ∧ prob_space μ›*) case fin: True (*‹finite (space X)›*) define n where "n ≡ card (space X)" with fin (*‹finite (space (X::'a measure))›*) assms(1) (*‹space (X::'a measure) ≠ {}›*) have n: "0 < n" by (simp add: card_gt_0_iff (*‹(0 < card ?A) = (?A ≠ {} ∧ finite ?A)›*)) obtain μ where "μ": "sets μ = sets X" "⋀x. x ∈ space X ⟹ μ {x} = ennreal (1 / real n)" (*goal: ‹(⋀μ::'a::type measure. ⟦sets μ = sets (X::'a::type measure); ⋀x::'a::type. x ∈ space X ⟹ emeasure μ {x} = ennreal ((1::real) / real (n::nat))⟧ ⟹ thesis::bool) ⟹ thesis›*) using ex_measure_countable_space[OF assms ( 2 , 3 )] (*‹∃μ. sets μ = sets X ∧ (∀x∈space X. emeasure μ {x} = ?f x)›*) by meson then have sets_fin: "x ∈ sets μ ⟹ finite x" for x by (auto intro!: rev_finite_subset[OF fin] (*‹?A ⊆ space X ⟹ finite ?A›*) sets.sets_into_space (*‹?x ∈ sets ?M ⟹ ?x ⊆ space ?M›*)) show "?thesis" (*goal: ‹∃μ::'a measure. sets μ = sets (X::'a measure) ∧ prob_space μ›*) proof (safe intro!: exI[where x=μ] (*‹(?P::'a::type measure ⇒ bool) (μ::'a::type measure) ⟹ ∃x::'a::type measure. ?P x›*)) (*goals: 1. ‹⋀x. x ∈ sets μ ⟹ x ∈ sets X› 2. ‹⋀x. x ∈ sets X ⟹ x ∈ sets μ› 3. ‹prob_space μ›*) show "prob_space μ" proof (standard) (*goal: ‹emeasure μ (space μ) = 1›*) have "emeasure μ (space μ) = (∑a∈space μ. ennreal (1/n))" using emeasure_eq_sum_singleton[OF sets_fin [ OF sets.top ], of μ] (*‹(⋀x. x ∈ space μ ⟹ {x} ∈ sets μ) ⟹ emeasure μ (space μ) = (∑x∈space μ. emeasure μ {x})›*) assms(3) (*‹sets X = Pow (space X)›*) "μ" (*‹sets μ = sets X› ‹?x ∈ space X ⟹ emeasure μ {?x} = ennreal (1 / real n)›*) by auto also (*calculation: ‹emeasure μ (space μ) = (∑a∈space μ. ennreal (1 / real n))›*) have "... = of_nat n * ennreal (1 / real n)" using "μ"(2) (*‹?x ∈ space X ⟹ emeasure μ {?x} = ennreal (1 / real n)›*) sets_eq_imp_space_eq[OF μ ( 1 )] (*‹space μ = space X›*) by (simp add: n_def (*‹n ≡ card (space X)›*)) also (*calculation: ‹emeasure μ (space μ) = of_nat n * ennreal (1 / real n)›*) have "... = 1" using n (*‹0 < n›*) apply (auto simp: ennreal_of_nat_eq_real_of_nat (*‹of_nat ?i = ennreal (real ?i)›*)) (*goal: ‹of_nat n * ennreal (1 / real n) = 1›*) by (metis ennreal_1 (*‹ennreal 1 = 1›*) ennreal_mult'' (*‹0 ≤ ?b ⟹ ennreal (?a * ?b) = ennreal ?a * ennreal ?b›*) mult.commute (*‹?a * ?b = ?b * ?a›*) nonzero_eq_divide_eq (*‹?c ≠ 0 ⟹ (?a = ?b / ?c) = (?a * ?c = ?b)›*) not_gr0 (*‹(¬ 0 < ?n) = (?n = 0)›*) of_nat_0_eq_iff (*‹(0 = of_nat ?n) = (0 = ?n)›*) of_nat_0_le_iff (*‹0 ≤ of_nat ?n›*)) finally (*calculation: ‹emeasure μ (space μ) = 1›*) show "emeasure μ (space μ) = 1" . qed qed (use μ in auto) (*solves the remaining goals: 1. ‹⋀x. x ∈ sets μ ⟹ x ∈ sets X› 2. ‹⋀x. x ∈ sets X ⟹ x ∈ sets μ›*) next (*goal: ‹infinite (space X) ⟹ ∃μ. sets μ = sets X ∧ prob_space μ›*) case inf: False (*‹infinite (space X)›*) obtain μ where "μ": "sets μ = sets X" "⋀x. x ∈ space X ⟹ μ {x} = (1/2)^(Suc (to_nat_on (space X) x))" (*goal: ‹(⋀μ::'a measure. ⟦sets μ = sets (X::'a measure); ⋀x::'a. x ∈ space X ⟹ emeasure μ {x} = ((1::ennreal) / (2::ennreal)) ^ Suc (to_nat_on (space X) x)⟧ ⟹ thesis::bool) ⟹ thesis›*) using ex_measure_countable_space[OF assms ( 2 , 3 ), of "λx. (1/2)^(Suc (to_nat_on (space X) x))"] (*‹∃μ. sets μ = sets X ∧ (∀x∈space X. emeasure μ {x} = (1 / 2) ^ Suc (to_nat_on (space X) x))›*) by auto show "?thesis" (*goal: ‹∃μ. sets μ = sets X ∧ prob_space μ›*) proof (safe intro!: exI[where x=μ] (*‹?P μ ⟹ ∃x. ?P x›*)) (*goals: 1. ‹⋀x. x ∈ sets μ ⟹ x ∈ sets X› 2. ‹⋀x. x ∈ sets X ⟹ x ∈ sets μ› 3. ‹prob_space μ›*) show "prob_space μ" proof (standard) (*goal: ‹emeasure μ (space μ) = 1›*) have "emeasure μ (space μ) = emeasure μ (⋃n. {from_nat_into (space X) n})" by (simp add: sets_eq_imp_space_eq[OF μ(1)] (*‹space μ = space X›*) UNION_singleton_eq_range (*‹(⋃x∈?A. {?f x}) = ?f ` ?A›*) assms( (*‹space X ≠ {}›*) 1) assms( (*‹countable (space X)›*) 2)) also (*calculation: ‹emeasure μ (space μ) = emeasure μ (⋃n. {from_nat_into (space X) n})›*) have "... = (∑n. μ {from_nat_into (space X) n})" using from_nat_into_inj_infinite[OF assms ( 2 ) inf] (*‹(from_nat_into (space X) ?m = from_nat_into (space X) ?n) = (?m = ?n)›*) from_nat_into[OF assms ( 1 )] (*‹from_nat_into (space X) ?n ∈ space X›*) assms(3) (*‹sets X = Pow (space X)›*) by (auto intro!: suminf_emeasure[symmetric] (*‹⟦range ?A ⊆ sets ?M; disjoint_family ?A⟧ ⟹ emeasure ?M (⋃ (range ?A)) = (∑i. emeasure ?M (?A i))›*) simp: μ( (*‹sets μ = sets X›*) 1) disjoint_family_on_def (*‹disjoint_family_on ?A ?S = (∀m∈?S. ∀n∈?S. m ≠ n ⟶ ?A m ∩ ?A n = {})›*)) also (*calculation: ‹emeasure (μ::'a measure) (space μ) = (∑n::nat. emeasure μ {from_nat_into (space (X::'a measure)) n})›*) have "... = (∑n. (1/2)^(Suc n))" by (simp add: μ(2)[OF from_nat_into[OF assms(1)]] (*‹emeasure μ {from_nat_into (space X) ?n1} = (1 / 2) ^ Suc (to_nat_on (space X) (from_nat_into (space X) ?n1))›*) to_nat_on_from_nat_into_infinite[OF assms(2) inf] (*‹to_nat_on (space X) (from_nat_into (space X) ?n) = ?n›*)) also (*calculation: ‹emeasure (μ::'a::type measure) (space μ) = (∑n::nat. ((1::ennreal) / (2::ennreal)) ^ Suc n)›*) have "... = (∑i. ennreal ((1 / 2) ^ Suc i))" by (metis (mono_tags, opaque_lifting) divide_ennreal (*‹⟦0 ≤ ?r; 0 < ?q⟧ ⟹ ennreal ?r / ennreal ?q = ennreal (?r / ?q)›*) divide_pos_pos (*‹⟦0 < ?x; 0 < ?y⟧ ⟹ 0 < ?x / ?y›*) ennreal_numeral (*‹ennreal (numeral ?n) = numeral ?n›*) ennreal_power (*‹0 ≤ ?r ⟹ ennreal ?r ^ ?n = ennreal (?r ^ ?n)›*) le_less (*‹(?x ≤ ?y) = (?x < ?y ∨ ?x = ?y)›*) power_0 (*‹?a ^ 0 = 1›*) zero_less_numeral (*‹0 < numeral ?n›*) zero_less_one (*‹0 < 1›*)) also (*calculation: ‹emeasure μ (space μ) = (∑i. ennreal ((1 / 2) ^ Suc i))›*) have "... = 1" using suminf_ennreal_eq[OF _ power_half_series] (*‹(⋀i. 0 ≤ (1 / 2) ^ Suc i) ⟹ (∑i. ennreal ((1 / 2) ^ Suc i)) = ennreal 1›*) by (metis ennreal_1 (*‹ennreal (1::real) = (1::ennreal)›*) zero_le_divide_1_iff (*‹((0::?'a) ≤ (1::?'a) / (?a::?'a)) = ((0::?'a) ≤ ?a)›*) zero_le_numeral (*‹(0::?'a) ≤ numeral (?n::num)›*) zero_le_power (*‹(0::?'a) ≤ (?a::?'a) ⟹ (0::?'a) ≤ ?a ^ (?n::nat)›*)) finally (*calculation: ‹emeasure μ (space μ) = 1›*) show "emeasure μ (space μ) = 1" . qed qed (use μ in auto) (*solves the remaining goals: 1. ‹⋀x. x ∈ sets μ ⟹ x ∈ sets X› 2. ‹⋀x. x ∈ sets X ⟹ x ∈ sets μ›*) qed lemma AE_I'': assumes "N ∈ null_sets M" and "⋀x. x ∈ space M ⟹ x ∉ N ⟹ P x" shows "AE x in M. P x" by (metis (no_types, lifting) assms (*‹N ∈ null_sets M› ‹⟦?x ∈ space M; ?x ∉ N⟧ ⟹ P ?x›*) eventually_ae_filter (*‹almost_everywhere ?M ?P = (∃N∈null_sets ?M. {x ∈ space ?M. ¬ ?P x} ⊆ N)›*) mem_Collect_eq (*‹(?a ∈ Collect ?P) = ?P ?a›*) subsetI (*‹(⋀x. x ∈ ?A ⟹ x ∈ ?B) ⟹ ?A ⊆ ?B›*)) lemma absolutely_continuous_trans: assumes "absolutely_continuous L M" "absolutely_continuous M N" shows "absolutely_continuous L N" using assms (*‹absolutely_continuous L M› ‹absolutely_continuous M N›*) by (auto simp: absolutely_continuous_def (*‹absolutely_continuous ?M ?N = (null_sets ?M ⊆ null_sets ?N)›*)) subsection ‹ Equivalence of Measures › abbreviation equivalence_measure :: "'a measure ⇒ 'a measure ⇒ bool" (infix "~⇩M" 60) where "equivalence_measure M N ≡ absolutely_continuous M N ∧ absolutely_continuous N M" lemma equivalence_measure_refl: "M ~⇩M M" by (auto simp: absolutely_continuous_def (*‹absolutely_continuous ?M ?N = (null_sets ?M ⊆ null_sets ?N)›*)) lemma equivalence_measure_sym: assumes "M ~⇩M N" shows "N ~⇩M M" using assms (*‹M ~⇩M N›*) by simp lemma equivalence_measure_trans: assumes "M ~⇩M N" "N ~⇩M L" shows "M ~⇩M L" using assms (*‹M ~⇩M N› ‹N ~⇩M L›*) by (auto simp: absolutely_continuous_def (*‹absolutely_continuous ?M ?N = (null_sets ?M ⊆ null_sets ?N)›*)) lemma equivalence_measureI: assumes "absolutely_continuous M N" "absolutely_continuous N M" shows "M ~⇩M N" by (simp add: assms (*‹absolutely_continuous (M::'a measure) (N::'a measure)› ‹absolutely_continuous (N::'a measure) (M::'a measure)›*)) end
{ "path": "afp-2025-02-12/thys/Disintegration/Lemmas_Disintegration.thy", "repo": "afp-2025-02-12", "sha": "7b2e8cbcf799b4890f8178bd553e86e91cc21a98565221807a049d440cfb701f" }